示例#1
0
        public ActionResult RaiseRequisition()
        {
            string    error = "";
            string    token = GetToken();
            UserModel um    = GetUser();
            DepartmentCollectionPointModel dcpm = new DepartmentCollectionPointModel();
            List <ItemModel>     ItemsList      = new List <ItemModel>();
            RequisitionViewModel reqvm          = new RequisitionViewModel();

            try
            {
                reqvm.Reqdate     = DateTime.Now;
                reqvm.Raisedby    = um.Userid;
                reqvm.Depid       = um.Deptid;
                dcpm              = APICollectionPoint.GetActiveDepartmentCollectionPointByDeptID(token, um.Deptid, out error);
                reqvm.Cpid        = dcpm.CpID;
                reqvm.Cpname      = dcpm.CpName;
                reqvm.Status      = ConRequisition.Status.PENDING;
                ItemsList         = APIItem.GetAllItems(token, out error);
                ViewBag.ItemsList = ItemsList;
            }
            catch (Exception ex)
            {
                return(RedirectToAction("Index", "Error", new { error = ex.Message }));
            }
            return(View(reqvm));
        }
示例#2
0
        public ActionResult CollectionPoint()
        {
            string    token = GetToken();
            UserModel um    = GetUser();
            DepartmentCollectionPointModel dcpm = new DepartmentCollectionPointModel();

            ViewBag.PendingCPR = false;
            List <CodeValue>                      CollectionPointsList = new List <CodeValue>();
            List <CollectionPointModel>           cpms  = new List <CollectionPointModel>();
            List <DepartmentCollectionPointModel> dcpms = new List <DepartmentCollectionPointModel>();

            try
            {
                // to show active collection point
                dcpms = APICollectionPoint.GetDepartmentCollectionPointByStatus(token, ConDepartmentCollectionPoint.Status.PENDING, out string error);

                dcpm = APICollectionPoint.GetActiveDepartmentCollectionPointByDeptID(token, um.Deptid, out error);
                ViewBag.ActiveCollectionPoint = dcpm.CpName;

                CollectionPointModel current =
                    APICollectionPoint.GetCollectionPointBycpid(token, dcpm.CpID, out error);

                ViewBag.Latitude  = current.Latitude;
                ViewBag.Longitude = current.Longitude;

                // to show pending list if exists
                dcpms = dcpms.Where(p => p.DeptID == um.Deptid).ToList();
                ViewBag.PendingCollectionPoints = dcpms;
                if (dcpms.Count > 0)
                {
                    ViewBag.PendingCPR = true;
                }


                // for radio button
                cpms = APICollectionPoint.GetAllCollectionPoints(token, out error);

                ViewBag.CollectionPointsList = cpms;
            }
            catch (Exception ex)
            {
                return(RedirectToAction("Index", "Error", new { error = ex.Message }));
            }


            return(View(cpms));
        }
示例#3
0
        public ActionResult Index(int id)
        {
            string    error = "";
            string    token = GetToken();
            UserModel um    = GetUser();

            NotificationModel notim             = new NotificationModel();
            DepartmentCollectionPointModel dcpm = new DepartmentCollectionPointModel();

            notim = APINotification.UpdateNotificationAsRead(token, id, out error);

            switch (notim.NotiType)
            {
            case ConNotification.NotiType.Adjustment:
                if (notim.Role == ConUser.Role.SUPERVISOR)
                {
                    return(RedirectToAction("Approve", "Supervisor"));
                }
                else if (notim.Role == ConUser.Role.MANAGER)
                {
                    return(RedirectToAction("Approve", "Manager"));
                }
                else
                {
                    return(RedirectToAction("Inventory", "Clerk"));
                }

            case ConNotification.NotiType.ClerkApprovedCollectionPointChange:
                return(RedirectToAction("CollectionPoint", "HOD"));

            case ConNotification.NotiType.ClerkApprovedRequisition:
                return(RedirectToAction("TrackRequisition", "HOD", new { id = notim.ResID }));

            case ConNotification.NotiType.ClerkRejectedCollectionPointChange:
                return(RedirectToAction("CollectionPoint", "HOD"));

            case ConNotification.NotiType.CollectedRequistion:
                return(RedirectToAction("DisbursementDetail", "Clerk", new { id = notim.ResID }));

            case ConNotification.NotiType.CollectionPointChangeRequestApproval:
                return(RedirectToAction("ApproveCollectionPoint", "Clerk", new { id = notim.ResID }));

            case ConNotification.NotiType.DelegationAssigned:
                return(RedirectToAction("Index", "Home"));

            case ConNotification.NotiType.DelegationCancelled:
                return(RedirectToAction("Index", "Home"));

            case ConNotification.NotiType.DeliveredRequisition:
                dcpm = APICollectionPoint.GetActiveDepartmentCollectionPointByDeptID(token, um.Deptid, out error);
                if (dcpm == null)
                {
                    dcpm = new DepartmentCollectionPointModel
                    {
                        CpName = "Department Collection Point"
                    };
                }
                Session["noti"]        = true;
                Session["notitype"]    = "info";
                Session["notititle"]   = "Outstanding Requisiton";
                Session["notimessage"] = "Please go collect the items at " + dcpm.CpName;
                return(RedirectToAction("Index", "Home"));

            case ConNotification.NotiType.DeptRepAssigned:
                return(RedirectToAction("Index", "Home"));

            case ConNotification.NotiType.HODApprovedRequistion:
                if (notim.Role == ConUser.Role.EMPLOYEE)
                {
                    return(RedirectToAction("TrackRequisition", "Employee", new { id = notim.ResID }));
                }
                else if (notim.Role == ConUser.Role.DEPARTMENTREP)
                {
                    return(RedirectToAction("TrackRequisition", "Employee", new { id = notim.ResID }));
                }
                return(RedirectToAction("RequisitionDetail", "Clerk", new { id = notim.ResID }));

            case ConNotification.NotiType.OutstandingItemsCollected:
                return(RedirectToAction("OutstandingDetail", "Clerk", new { id = notim.ResID }));

            case ConNotification.NotiType.OutstandingItemsReadyToCollect:
                dcpm = APICollectionPoint.GetActiveDepartmentCollectionPointByDeptID(token, um.Deptid, out error);
                if (dcpm == null)
                {
                    dcpm = new DepartmentCollectionPointModel
                    {
                        CpName = "Department Collection Point"
                    };
                }
                Session["noti"]        = true;
                Session["notitype"]    = "info";
                Session["notititle"]   = "Outstanding Requisiton";
                Session["notimessage"] = "Please go collect the items at " + dcpm.CpName;
                return(RedirectToAction("Index", "Home"));

            case ConNotification.NotiType.RejectedRequistion:
                return(RedirectToAction("Index", "Home"));

            case ConNotification.NotiType.RequisitionApproval:
                return(RedirectToAction("ApproveRequisition", "HOD", new { id = notim.ResID }));
            }
            return(View());
        }
示例#4
0
        public ActionResult Index()
        {
            string    error = "";
            string    token = GetToken();
            UserModel um    = GetUser();

            List <RequisitionModel> reqs             = new List <RequisitionModel>();
            UserModel CurrentRep                     = new UserModel();
            DepartmentCollectionPointModel CurrentCP = new DepartmentCollectionPointModel();
            DelegationModel CurrentTemp              = new DelegationModel();
            UserModel       CurrentTempUser          = new UserModel();

            try
            {
                reqs                   = APIRequisition.GetRequisitionByStatus(ConRequisition.Status.PENDING, token, out error);
                ViewBag.ReqCount       = 0;
                ViewBag.ReqCount       = reqs.Where(x => x.Depid == um.Deptid).Count();
                ViewBag.DelegationType = "Temporary HOD";

                CurrentRep      = APIUser.GetUserByRoleAndDeptID(ConUser.Role.DEPARTMENTREP, um.Deptid, token, out error).FirstOrDefault();
                ViewBag.RepName = CurrentRep.Fullname;
                if (ViewBag.RepName == null)
                {
                    ViewBag.RepName = "None";
                }


                CurrentCP = APICollectionPoint.GetActiveDepartmentCollectionPointByDeptID(token, um.Deptid, out error);
                ViewBag.CollectionPoint = CurrentCP.CpName;
                if (ViewBag.CollectionPoint == null)
                {
                    ViewBag.CollectionPoint = "None";
                }

                CurrentTemp = APIDelegation.GetPreviousDelegationByDepid(token, um.Deptid, out error);
                if (CurrentTemp.Delid != 0)
                {
                    CurrentTempUser  = APIUser.GetUserByUserID(CurrentTemp.Userid, token, out error);
                    ViewBag.TempHOD  = CurrentTempUser.Fullname;
                    ViewBag.TempDate = CurrentTemp.Startdate.Value.ToShortDateString() + " - " + CurrentTemp.Enddate.Value.ToShortDateString();
                    if (CurrentTemp.Startdate <= DateTime.Today && DateTime.Today <= CurrentTemp.Enddate)
                    {
                        ViewBag.DelegationType = "Current Temporary HOD";
                    }
                    else
                    {
                        ViewBag.DelegationType = "Upcoming Temporary HOD";
                    }
                }
                if (CurrentTemp.Delid == 0 || ViewBag.TempHOD == null)
                {
                    ViewBag.DelegationType = "Temporary HOD";
                    ViewBag.TempHOD        = "None";
                    ViewBag.TempDate       = "-";
                }
                return(View());
            }
            catch (Exception ex)
            {
                return(RedirectToAction("Index", "Error", new { error = ex.Message }));
            }
        }
示例#5
0
        public ActionResult RaiseRequisition(RequisitionViewModel reqvm)
        {
            if (reqvm.Requisitiondetails.Count < 1)
            {
                Session["noti"]        = true;
                Session["notitype"]    = "error";
                Session["notititle"]   = "Raise Requisition Error";
                Session["notimessage"] = "You cannot raise requisition without any items!";
                return(RedirectToAction("RaiseRequisition"));
            }

            bool duplicateExists = reqvm.Requisitiondetails.GroupBy(n => n.Itemid).Any(g => g.Count() > 1);

            if (duplicateExists)
            {
                Session["noti"]        = true;
                Session["notitype"]    = "error";
                Session["notititle"]   = "Raise Requisition Error";
                Session["notimessage"] = "You cannot raise requisition with duplicate items!";
                return(RedirectToAction("RaiseRequisition"));
            }

            string    token = GetToken();
            UserModel um    = GetUser();
            DepartmentCollectionPointModel dcpm = new DepartmentCollectionPointModel();
            List <ItemModel> ItemsList          = new List <ItemModel>();
            RequisitionModel reqm = new RequisitionModel();
            List <RequisitionDetailsModel> reqdms = new List <RequisitionDetailsModel>();

            try
            {
                reqm.Reqdate  = DateTime.Now;
                reqm.Raisedby = um.Userid;
                if (um.Role == ConUser.Role.TEMPHOD)
                {
                    reqm.Approvedby = um.Userid;
                }
                reqm.Depid  = um.Deptid;
                dcpm        = APICollectionPoint.GetActiveDepartmentCollectionPointByDeptID(token, um.Deptid, out string error);
                reqm.Cpid   = dcpm.CpID;
                reqm.Cpname = dcpm.CpName;
                reqm.Status = ConRequisition.Status.PENDING;
                reqm        = APIRequisition.CreateRequisition(reqm, token, out error);

                foreach (var reqd in reqvm.Requisitiondetails)
                {
                    RequisitionDetailsModel reqdm = new RequisitionDetailsModel
                    {
                        Reqid  = reqm.Reqid,
                        Itemid = reqd.Itemid,
                        Qty    = reqd.Qty
                    };
                    reqdms = APIRequisition.CreateRequisitionDetails(reqdm, token, out error);
                }
            }
            catch (Exception ex)
            {
                return(RedirectToAction("Index", "Error", new { error = ex.Message }));
            }
            return(RedirectToAction("TrackRequisition", "Employee", new { id = reqm.Reqid }));
        }