Пример #1
0
        public IActionResult Report(int id)
        {
            if (HttpContext.Session.GetString("LoginID") == null)
            {
                return(RedirectToAction("Login", "Users"));
            }
            if (id == 0)
            {
                return(RedirectToAction("ViewReports"));
            }

            CentricsContext context = HttpContext.RequestServices.GetService(typeof(Centrics.Models.CentricsContext)) as CentricsContext;

            if (HttpContext.Session.GetString("AdminValidity") == "Admin" || HttpContext.Session.GetString("AdminValidity") == "Super Admin" || context.getServiceReport(id).ReportFrom == context.GetUser(Convert.ToInt32(HttpContext.Session.GetString("LoginID"))).FirstName + context.GetUser(Convert.ToInt32(HttpContext.Session.GetString("LoginID"))).LastName)
            {
                ViewData["allowdelete"] = "weee";
            }
            if ((HttpContext.Session.GetString("AdminValidity") == "Admin" || HttpContext.Session.GetString("AdminValidity") == "Super Admin"))
            {
                ViewData["rights"] = "Admin";
            }


            ServiceReport model = context.getServiceReport(id);

            if (model.SerialNumber == 0)
            {
                return(RedirectToAction("ViewReports"));
            }
            return(View(model));
        }
Пример #2
0
        public IActionResult AddBilling(int id)
        {
            if (HttpContext.Session.GetString("LoginID") == null)
            {
                return(RedirectToAction("Login", "Users"));
            }
            CentricsContext context = HttpContext.RequestServices.GetService(typeof(Centrics.Models.CentricsContext)) as CentricsContext;

            ServiceReport model = context.getServiceReport(id);

            return(View(model));
        }
Пример #3
0
        public IActionResult ReportConfirm(int id)
        {
            if (HttpContext.Session.GetString("LoginID") == null)
            {
                return(RedirectToAction("Login", "Users"));
            }
            CentricsContext context = HttpContext.RequestServices.GetService(typeof(Centrics.Models.CentricsContext)) as CentricsContext;
            User            user    = context.GetUser(Convert.ToInt32(HttpContext.Session.GetString("LoginID")));

            if (!(HttpContext.Session.GetString("AdminValidity") == "Admin" || HttpContext.Session.GetString("AdminValidity") == "Super Admin"))
            {
                return(RedirectToAction("Error", "Admin"));
            }
            ServiceReport meh            = context.getServiceReport(id);
            double        totalmshremain = context.GetRemainingMSHByCompany(meh);

            if (totalmshremain < meh.MSHUsed)
            {
                TempData["error"] = "The company you are trying to confirm currently does not have enough remaining MSH.";

                return(RedirectToAction("Report", new { id }));
            }

            context.LogAction("Service Report", "Service Report (SRN: " + id + ") has been confirmed.", context.GetUser(Convert.ToInt32(HttpContext.Session.GetString("LoginID"))));
            context.ReportConfirm(id);


            ServiceReport remains = context.SubtractMSHUsingSR(context.getServiceReport(id));

            while (remains.MSHUsed != 0)
            {
                remains = context.SubtractMSHUsingSR(remains);
            }

            Debug.WriteLine("hi id = " + id);
            return(RedirectToAction("ViewReports"));
        }
Пример #4
0
        public IActionResult PrintReport(int id)
        {
            if (HttpContext.Session.GetString("LoginID") == null)
            {
                return(RedirectToAction("Login", "Users"));
            }
            CentricsContext context = HttpContext.RequestServices.GetService(typeof(Centrics.Models.CentricsContext)) as CentricsContext;
            ServiceReport   model   = context.getServiceReport(id);

            if (model.SerialNumber == 0)
            {
                return(RedirectToAction("ViewReports"));
            }
            string[] m = model.JobStatus;

            string jobcombined = "";

            if (model.JobStatus.Length > 1)
            {
                for (int i = 0; i < model.JobStatus.Length; i++)
                {
                    if (model.JobStatus[i] != model.JobStatus.Last())
                    {
                        jobcombined += model.JobStatus[i] + ",";
                    }
                    else
                    {
                        jobcombined += model.JobStatus[i];
                    }
                }
            }
            else if (model.JobStatus.Length == 1)
            {
                jobcombined = model.JobStatus[0];
            }
            model.JobStat = jobcombined;
            HttpContext.JsReportFeature()
            .Recipe(Recipe.PhantomPdf);

            return(View(model));
        }
Пример #5
0
        public IActionResult ReportDelete(int id)
        {
            if (HttpContext.Session.GetString("LoginID") == null)
            {
                return(RedirectToAction("Login", "Users"));
            }
            //checkowner
            CentricsContext context = HttpContext.RequestServices.GetService(typeof(Centrics.Models.CentricsContext)) as CentricsContext;
            //enter user
            User user = context.GetUser(Convert.ToInt32(HttpContext.Session.GetString("LoginID")));

            if (!(HttpContext.Session.GetString("AdminValidity") == "Admin" || HttpContext.Session.GetString("AdminValidity") == "Super Admin" || (user.FirstName + user.LastName) == context.getServiceReport(id).ReportFrom))
            {
                return(RedirectToAction("Login", "Users"));
            }
            if (context.getServiceReport(id).ReportStatus != "Confirmed")
            {
                context.DeleteReport(id);
            }

            context.LogAction("Service Report", "Service Report (SRN: " + id + ") has been deleted.", context.GetUser(Convert.ToInt32(HttpContext.Session.GetString("LoginID"))));
            return(RedirectToAction("ViewReports"));
        }
Пример #6
0
        public IActionResult EditReport(ServiceReport report)
        {
            if (HttpContext.Session.GetString("LoginID") == null)
            {
                return(RedirectToAction("Login", "Users"));
            }

            List <SelectListItem> PurposeList = new List <SelectListItem>();

            PurposeList.Add(new SelectListItem {
                Value = "Project", Text = "Project"
            });
            PurposeList.Add(new SelectListItem {
                Value = "Installation", Text = "Installation"
            });
            PurposeList.Add(new SelectListItem {
                Value = "M.S.A", Text = "M.S.A"
            });
            PurposeList.Add(new SelectListItem {
                Value = "Chargable", Text = "Chargable"
            });
            PurposeList.Add(new SelectListItem {
                Value = "P.O.C", Text = "P.O.C"
            });
            PurposeList.Add(new SelectListItem {
                Value = "Delivery", Text = "Delivery"
            });
            PurposeList.Add(new SelectListItem {
                Value = "Return", Text = "Return"
            });
            PurposeList.Add(new SelectListItem {
                Value = "Others", Text = "Others"
            });
            ViewData["Purpose"] = PurposeList;

            List <SelectListItem> JobStatusList = new List <SelectListItem>();

            JobStatusList.Add(new SelectListItem {
                Value = "Completed", Text = "Completed"
            });
            JobStatusList.Add(new SelectListItem {
                Value = "Followup Required", Text = "Followup Required"
            });
            JobStatusList.Add(new SelectListItem {
                Value = "Recommendation Requied", Text = "Recommendation Required"
            });
            JobStatusList.Add(new SelectListItem {
                Value = "Escalated to Ext. Support", Text = "Escalated to Ext. Support"
            });
            ViewData["JobStatusList"] = JobStatusList;
            //update database
            CentricsContext context = HttpContext.RequestServices.GetService(typeof(Centrics.Models.CentricsContext)) as CentricsContext;
            User            user    = context.GetUser(Convert.ToInt32(HttpContext.Session.GetString("LoginID")));

            if (!(HttpContext.Session.GetString("AdminValidity") == "Admin" || HttpContext.Session.GetString("AdminValidity") == "Super Admin" || (user.FirstName + user.LastName) == context.getServiceReport(report.SerialNumber).ReportFrom))
            {
                return(RedirectToAction("Login", "Users"));
            }
            if (!ModelState.IsValid)
            {
                return(View(report));
            }

            if (ModelState.IsValid)
            {
                double totalmshremain = context.GetRemainingMSHByCompany(report);
                Debug.WriteLine("Debug from post editreport: Total MSH Remaining : " + totalmshremain);
                double calculatedhours = context.CalculateMSH(report.TimeStart, report.TimeEnd);
                //ModelState.AddModelError("", "The calculated MSH:" + calculatedhours);
                //return View(model);
                if (totalmshremain < calculatedhours)
                {
                    ModelState.AddModelError("", "The company you have selected does not have enough remaining MSH, Please contact your Boss immediately regarding this issue.");
                    return(View(report));
                }


                if (report.TimeStart > DateTime.Now || report.TimeEnd > DateTime.Now)
                {
                    ModelState.AddModelError("", "Please enter a report after the service is rendered");
                    return(View(report));
                }

                if (!(report.TimeStart.CompareTo(report.TimeEnd) <= 0))
                {
                    ModelState.AddModelError("", "your start time should be before your end time");
                    return(View(report));
                }

                context.ReportEdit(report);
                context.LogAction("Service Report", "Service Report (SRN: " + report.SerialNumber + ") has been edited.", context.GetUser(Convert.ToInt32(HttpContext.Session.GetString("LoginID"))));
                return(RedirectToAction("Report", new { id = report.SerialNumber }));
            }

            return(View(report));
        }
Пример #7
0
        public IActionResult EditReport(int id)
        {
            if (HttpContext.Session.GetString("LoginID") == null)
            {
                return(RedirectToAction("Login", "Users"));
            }
            CentricsContext context = HttpContext.RequestServices.GetService(typeof(Centrics.Models.CentricsContext)) as CentricsContext;

            User user = context.GetUser(Convert.ToInt32(HttpContext.Session.GetString("LoginID")));

            ServiceReport model = new ServiceReport();

            //ViewData["Companies"] = context.GetClientByContract();

            #region prepare for failure codes
            List <SelectListItem> PurposeList = new List <SelectListItem>();
            PurposeList.Add(new SelectListItem {
                Value = "Project", Text = "Project"
            });
            PurposeList.Add(new SelectListItem {
                Value = "Installation", Text = "Installation"
            });
            PurposeList.Add(new SelectListItem {
                Value = "M.S.A", Text = "M.S.A"
            });
            PurposeList.Add(new SelectListItem {
                Value = "Chargable", Text = "Chargable"
            });
            PurposeList.Add(new SelectListItem {
                Value = "P.O.C", Text = "P.O.C"
            });
            PurposeList.Add(new SelectListItem {
                Value = "Delivery", Text = "Delivery"
            });
            PurposeList.Add(new SelectListItem {
                Value = "Return", Text = "Return"
            });
            PurposeList.Add(new SelectListItem {
                Value = "Others", Text = "Others"
            });
            ViewData["Purpose"] = PurposeList;

            List <SelectListItem> JobStatusList = new List <SelectListItem>();
            JobStatusList.Add(new SelectListItem {
                Value = "Completed", Text = "Completed"
            });
            JobStatusList.Add(new SelectListItem {
                Value = "Followup Required", Text = "Followup Required"
            });
            JobStatusList.Add(new SelectListItem {
                Value = "Recommendation Requied", Text = "Recommendation Required"
            });
            JobStatusList.Add(new SelectListItem {
                Value = "Escalated to Ext. Support", Text = "Escalated to Ext. Support"
            });
            ViewData["JobStatusList"] = JobStatusList;

            //model.SerialNumber = context.getReportCounts() + 1;
            #endregion
            //pull db
            model = context.getServiceReport(id);
            if (model.SerialNumber == 0)
            {
                return(RedirectToAction("Report"));
            }
            if (!(HttpContext.Session.GetString("AdminValidity") == "Admin" || HttpContext.Session.GetString("AdminValidity") == "Super Admin" || (user.FirstName + user.LastName) == context.getServiceReport(id).ReportFrom))
            {
                return(RedirectToAction("Error", "Admin"));
            }

            return(View(model));
        }