Пример #1
0
        public ActionResult Add(ExpansViewModels model)
        {
            if (!ExpanseReportService.CheckDay(model))
            {
                ModelState.AddModelError("Day", "Ce jour ne fait pas parti de ce mois");
            }

            if (Service.CheckAmount(model) > 0)
            {
                ModelState.AddModelError("Amount_HT", "Vous avez dépassez le plafond pour ce frais de " + Service.CheckAmount(model) + "€");
            }


            if (ModelState.IsValid)
            {
                Service.Add(model);
                ExpanseReportService.UpdateAmount(model.ExpanseReport_ID);
            }

            ExpanseReportViewModels report = ExpanseReportService.GetById(model.ExpanseReport_ID);

            ViewBag.Days = new SelectList(report.Days);

            return(PartialView("_FormCreateExpanse", model));
        }
Пример #2
0
        public void Edit(ExpanseReportViewModels model)
        {
            ExpanseReport expanseReport = Repository.GetById(model.ExpanseReport_ID);

            expanseReport = Mapper.ModelToData(expanseReport, model);
            Repository.Save();
        }
Пример #3
0
        public void Add(ExpanseReportViewModels model)
        {
            ExpanseReport expanseReport = new ExpanseReport();

            expanseReport.ExpanseReport_ID = Guid.NewGuid();

            Repository.Add(Mapper.ModelToData(expanseReport, model));
            Repository.Save();
        }
        public ActionResult Details(string id, ExpanseReportViewModels model = null)
        {
            ExpanseReportViewModels report = Service.GetById(id);

            if (report != null)
            {
                ViewBag.Days = new SelectList(report.Days);
                return(View(report));
            }

            return(new HttpStatusCodeResult(404));
        }
        public ActionResult ManagerValidation(string id)
        {
            ExpanseReportViewModels report = Service.GetById(id);

            if (report != null && report.Employee.Pole.ManagerId == GetEmployeeId())
            {
                report.ManagerValidationDate = DateTime.Now;
                report.StatusCode            = ExpanseReportViewModels.STATUS_WAITING_FOR_ACCOUNTING;
                Service.Edit(report);
            }

            return(RedirectToAction("ToValidateManager"));
        }
        public ActionResult AccountingValidation(string id)
        {
            ExpanseReportViewModels report = Service.GetById(id);

            if (report != null)
            {
                report.AccountingValidationDate = DateTime.Now;
                report.StatusCode = ExpanseReportViewModels.STATUS_VALIDATED;
                Service.Edit(report);
            }

            return(RedirectToAction("ToValidateAccounting"));
        }
Пример #7
0
        public ActionResult Delete(string id)
        {
            ExpanseReportViewModels report = Service.GetById(id).ExpanseReport;

            if (report.Employee_ID == GetEmployeeId())
            {
                Service.Delete(id);
                ExpanseReportService.UpdateAmount(report.ExpanseReport_ID);

                return(Json(new { action = "removed", removed = true, error = "" }));
            }

            return(Json(new { action = "removed", removed = false, error = "Ce frais ne correspond pas au votre" }));
        }
Пример #8
0
        public ActionResult UpdateExpansList(string id)
        {
            ExpanseReportViewModels report = ExpanseReportService.GetById(id);

            if (report != null)
            {
                if (report.Employee_ID == GetEmployeeId())
                {
                    ViewBag.Days = new SelectList(report.Days);
                    return(PartialView("_ExpansTable", report.Expanses));
                }
            }

            return(PartialView("_ExpansTable", new List <ExpansViewModels>()));
        }
        public ActionResult Cancelled(string id)
        {
            ExpanseReportViewModels report = Service.GetById(id);

            if (report != null)
            {
                if (report.Employee_ID == GetEmployeeId())
                {
                    report.StatusCode = ExpanseReportViewModels.STATUS_CANCELLED;
                    Service.Edit(report);
                }
            }

            return(RedirectToAction("Index"));
        }
        public ActionResult EmployeeValidationForAccouting(string id)
        {
            ExpanseReportViewModels report = Service.GetById(id);

            if (report != null)
            {
                if (report.Employee_ID == GetEmployeeId() && report.StatusCode == ExpanseReportViewModels.STATUS_ACCOUNTING_NEED_CORRECTION)
                {
                    report.StatusCode = ExpanseReportViewModels.STATUS_WAITING_FOR_ACCOUNTING;
                    Service.Edit(report);
                }
            }

            return(RedirectToAction("Index"));
        }
        public ActionResult EmployeeValidation(string id)
        {
            ExpanseReportViewModels report = Service.GetById(id);

            if (report != null)
            {
                if (report.Employee_ID == GetEmployeeId())
                {
                    report.StatusCode = ExpanseReportViewModels.STATUS_WAITING_FOR_MANAGER;
                    Service.Edit(report);
                }
            }

            return(RedirectToAction("Index"));
        }
        public ActionResult ExportPDF(string id)
        {
            ExpanseReportViewModels model = Service.GetById(id);

            if (model == null)
            {
                return(new HttpStatusCodeResult(404));
            }

            if (model.Employee.UserId != User.Identity.GetUserId() && model.Employee.Pole.Manager.UserId != User.Identity.GetUserId() && !User.IsInRole("Comptable") && !User.IsInRole("Ressource Humaine") && !User.IsInRole("SuperAdmin"))
            {
                return(new HttpStatusCodeResult(403));
            }

            return(new ViewAsPdf("PdfExport", model.Expanses));
        }
        public ExpanseReport ModelToData(ExpanseReport expanseReport, ExpanseReportViewModels model)
        {
            expanseReport.Employee_ID                = new Guid(model.Employee_ID);
            expanseReport.Author_ID                  = new Guid(model.Author_ID);
            expanseReport.CreationDate               = model.CreationDate;
            expanseReport.Year                       = model.Year;
            expanseReport.Month                      = model.Month;
            expanseReport.StatusCode                 = model.StatusCode;
            expanseReport.ManagerComment             = model.ManagerComment;
            expanseReport.ManagerValidationDate      = model.ManagerValidationDate;
            expanseReport.AccountingComment          = model.AccountingComment;
            expanseReport.AccountingValidatationDate = model.AccountingValidationDate;
            expanseReport.Total_HT                   = model.Total_HT;
            expanseReport.Total_TTC                  = model.Total_TTC;
            expanseReport.Total_TVA                  = model.Total_TVA;

            return(expanseReport);
        }
        public ActionResult AskForCorrectionManager(string id, string comment)
        {
            if (String.IsNullOrEmpty(comment))
            {
                return(Json(new { hasError = true, error = "Veuillez ajoutez un commentaire pour permettre à l'employé de faire ses modifications" }));
            }
            else
            {
                ExpanseReportViewModels report = Service.GetById(id);
                if (report != null && report.Employee.Pole.ManagerId == GetEmployeeId())
                {
                    report.ManagerComment = comment;
                    report.StatusCode     = ExpanseReportViewModels.STATUS_MANAGER_NEED_CORRECTION;
                    Service.Edit(report);
                }

                return(Json(new { hasError = false, error = "" }));
            }
        }
        public ActionResult AskForCorrectionAccounting(string id, string comment)
        {
            if (String.IsNullOrEmpty(comment))
            {
                return(Json(new { hasError = true, error = "Veuillez ajoutez un commentaire pour permettre à l'employé de faire ses modifications" }));
            }
            else
            {
                ExpanseReportViewModels report = Service.GetById(id);
                if (report != null)
                {
                    report.AccountingComment = comment;
                    report.StatusCode        = ExpanseReportViewModels.STATUS_ACCOUNTING_NEED_CORRECTION;
                    Service.Edit(report);
                }

                return(Json(new { hasError = false, error = "" }));
            }
        }
        public ExpanseReportViewModels DataToModel(ExpanseReport expanseReport)
        {
            ExpanseReportViewModels result = new ExpanseReportViewModels()
            {
                ExpanseReport_ID         = expanseReport.ExpanseReport_ID.ToString(),
                Employee_ID              = expanseReport.Employee_ID.ToString(),
                Author_ID                = expanseReport.Author_ID.ToString(),
                CreationDate             = expanseReport.CreationDate,
                Year                     = expanseReport.Year,
                Month                    = expanseReport.Month,
                StatusCode               = expanseReport.StatusCode,
                ManagerComment           = expanseReport.ManagerComment,
                ManagerValidationDate    = expanseReport.ManagerValidationDate,
                AccountingComment        = expanseReport.AccountingComment,
                AccountingValidationDate = expanseReport.AccountingValidatationDate,
                Total_HT                 = expanseReport.Total_HT,
                Total_TTC                = expanseReport.Total_TTC,
                Total_TVA                = expanseReport.Total_TVA
            };

            return(result);
        }