public ActionResult Index(string staffId)
        {
            //retrieve request history of selected staff
            StaffEF staff = staffService.GetStaff();

            ViewBag.staff = staff;
            List <StationeryRequestEF> requestList = rndService.FindRequestByDepartmentAndStatus(staff.Department, "all");
            List <string> requestDate = rndService.ConvertToDate(requestList);

            //
            if (staffId == "All Staff")
            {
                return(RedirectToAction("Index"));
            }
            else
            {
                int selectedStaff = int.Parse(staffId);
                List <StationeryRequestEF> staffList = new List <StationeryRequestEF>();
                foreach (StationeryRequestEF request in requestList)
                {
                    if (request.Staff.StaffId == selectedStaff)
                    {
                        staffList.Add(request);
                    }
                }
                requestList           = staffList;
                ViewBag.selectedStaff = selectedStaff;
            }

            ViewBag.requestList     = requestList;
            ViewBag.requestDate     = requestDate;
            ViewBag.departmentStaff = staffService.FindAllEmployeeByDepartmentCode(staff.DepartmentCode);

            return(View());
        }
Esempio n. 2
0
        public int CreatePO(StaffEF staff, PurchaseOrderFormDTO poForm)
        {
            PurchaseOrderEF po = new PurchaseOrderEF();

            po.CreatedById     = staff.StaffId;
            po.OrderDate       = (long)(DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1))).TotalSeconds;
            po.DeliverByDate   = (long)(poForm.SupplyItemBy.Subtract(new DateTime(1970, 1, 1))).TotalSeconds;
            po.SupplierCode    = poForm.SupplierId;
            po.DeliveryAddress = poForm.DeliveryAdd;
            po.Description     = poForm.Description;
            po.Status          = "Pending Delivery";

            po.OrderId = purchaseEFF.FindLastPOId();
            purchaseEFF.AddToPurchaseOrder(po);

            for (int i = 0; i < poForm.SupplierDetailIds.Count(); i++)
            {
                PurchaseOrderDetailsEF podet = new PurchaseOrderDetailsEF();
                podet.OrderId         = po.OrderId;
                podet.ItemCode        = poForm.Icodes[i];
                podet.QuantityOrdered = poForm.Quantities[i];

                purchaseEFF.AddToPurchaseOrderDetails(podet);
            }

            return(po.OrderId);
        }
        public ActionResult ViewRequest(string requestId)
        {
            //retrieve request details of selected request
            StaffEF staff = staffService.GetStaff();

            ViewBag.staff = staff;
            StationeryRequestEF request = rndService.FindRequestById(requestId);
            List <StationeryRequestDetailsEF> requestDetails = rndService.FindRequestDetailsByRequestId(requestId);

            if (request.Staff.DepartmentCode != staff.DepartmentCode)
            {
                return(RedirectToAction("Index"));
            }

            if (request.Status == "Submitted")
            {
                return(RedirectToAction("ViewRequest", "ApproveRequest", new { requestId }));
            }

            ViewBag.request        = request;
            ViewBag.requestDetails = requestDetails;

            ViewBag.requestdate = Timestamp.dateFromTimestamp(request.RequestDate);

            long decisionDate = request.DecisionDate.GetValueOrDefault();

            ViewBag.decisiondate = Timestamp.dateFromTimestamp(decisionDate);

            return(View());
        }
Esempio n. 4
0
        public string SaveAdjustmentVoucherAndDetails(StaffEF requester, AdjustmentVoucherEF voucher, List <AdjustmentVoucherDetailsDTO> detailsList, string approvalLevel)
        {
            var existing = stockEFF.FindAdjustmentVoucherById(voucher.VoucherId);

            if (existing == null)
            {
                int    year   = DateTime.Now.Year;
                string prefix = "VO/" + year + "/";
                int    num    = stockEFF.FindLastAdjustmentVoucher(prefix) + 1;
                voucher.VoucherId = prefix + num;

                long unixTimestamp = (long)(DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1))).TotalSeconds;
                voucher.DateIssued  = unixTimestamp;
                voucher.RequesterId = requester.StaffId;

                if (approvalLevel == "Manager")
                {
                    voucher.Status = "Pending Manager Approval";
                }
                else if (approvalLevel == "Supervisor")
                {
                    voucher.Status = "Pending Approval";
                }
                stockEFF.AddNewAdjustmentVoucherAndDetails(voucher, detailsList);
                //return stockEFF.AddNewAdjustmentVoucherAndDetails(voucher, detailsList);
            }
            else
            {
                stockEFF.FindAndReplaceAdjustmentVoucherDetails(voucher.VoucherId, detailsList);
            }
            //return false;
            return(voucher.VoucherId);
        }
Esempio n. 5
0
        public JsonResult GetRequests(int staffId)
        {
            //Find the staff by their Id
            StaffEF staff = staffService.FindStaffById(staffId);

            // Pass all submitted request from the department
            List <StationeryRequestEF>     pendingList    = rndService.FindRequestByDepartmentAndStatus(staff.Department, "Submitted");
            MobileStationeryRequestListDTO requestListDTO = new MobileStationeryRequestListDTO()
            {
                StationeryRequests = new List <MobileStationeryRequestDTO>()
            };

            foreach (var item in pendingList)
            {
                requestListDTO.StationeryRequests.Add(new MobileStationeryRequestDTO
                {
                    RequestId   = item.RequestId,
                    StaffId     = item.Staff.StaffId,
                    StaffName   = item.Staff.Name,
                    RequestDate = item.RequestDate,
                    Status      = item.Status,
                });
            }

            return(Json(requestListDTO, JsonRequestBehavior.AllowGet));
        }
        public ActionResult Index(string update)
        {
            if (update == "success")
            {
                ViewBag.note = "Department collection details has been updated";
            }
            else if (update == "unchanged")
            {
                ViewBag.note = "No changes were made to the collection details";
            }

            // Retrieve list of department staff and collection points
            StaffEF staff = staffService.GetStaff();

            ViewBag.staff      = staff;
            ViewBag.department = staff.Department;
            List <StaffEF>           deptStaff        = staffService.FindAllEmployeeByDepartmentCode(staff.DepartmentCode);
            List <CollectionPointEF> collectionPoints = deptService.FindAllCollectionPoints();

            ManageCollectionDTO collectDTO = new ManageCollectionDTO();

            // Display current department rep and collection point
            collectDTO.Department       = staff.Department.DepartmentCode;
            collectDTO.CollectionPoints = collectionPoints;
            ViewBag.deptStaff           = deptStaff;

            return(View(collectDTO));
        }
Esempio n. 7
0
        public ActionResult ViewAdjustmentDetails(string voucherId, string choice)
        {
            AdjustmentVoucherEF voucher = stockService.FindAdjustmentVoucherById(voucherId);
            List <AdjustmentVoucherDetailsEF>  voucherDetailsList = stockService.FindAdjustmentDetailsById(voucherId);
            List <AdjustmentVoucherDetailsDTO> convertedList      = stockService.ConvertAdjVoucherDetailsToDTO(voucherDetailsList);

            StaffEF staff = staffService.GetStaff();

            bool needsManagerAuthority = stockService.VoucherExceedsSetValue(voucherDetailsList);

            ViewData["needsManagerAuthority"] = needsManagerAuthority;
            ViewData["adjustmentVoucher"]     = voucher;
            ViewData["voucherDetailsList"]    = convertedList;
            ViewData["staffRole"]             = staff.Role.Description;
            ViewData["staffId"] = staff.StaffId;

            if (choice != null && (voucher.Status == "Pending Approval" || voucher.Status == "Pending Manager Approval"))
            {
                if (choice == "Edit")
                {
                    return(RedirectToAction("CreateAdjustmentVoucher", "ManageAdjustmentVoucher", new { voucherId = voucherId }));
                }
                if (choice == "Approve" || choice == "Reject")
                {
                    stockService.UpdateAdjustmentVoucherStatus(staff, voucherId, choice);
                    SendEmailToStaffOnDecision(voucher.Requester, voucher);
                }
            }
            return(View());
        }
        public ActionResult ViewRequest(string requestId)
        {
            StaffEF staff = staffService.GetStaff();

            ViewBag.staff = staff;
            StationeryRequestEF request = rndService.FindRequestById(requestId);

            if (request.StaffId != staff.StaffId)
            {
                return(RedirectToAction("Index", "ManageRequest"));
            }

            List <StationeryRequestDetailsEF> requestDetails = rndService.FindRequestDetailsByRequestId(requestId);

            //check request status and redirect to create or view page
            if (request.Status == "Submitted")
            {
                RequestListDTO requestListDTO = rndService.AddToRequestListDTO(requestId, request.Status, requestDetails);
                TempData["requestListDTO"] = requestListDTO;

                return(RedirectToAction("CreateRequest"));
            }
            ViewBag.request        = request;
            ViewBag.requestDetails = requestDetails;

            ViewBag.requestdate = Timestamp.dateFromTimestamp(request.RequestDate);

            long decisionDate = request.DecisionDate.GetValueOrDefault();

            ViewBag.decisiondate = Timestamp.dateFromTimestamp(decisionDate);

            return(View());
        }
        public void OnAuthorization(AuthorizationContext ac)
        {
            bool         isAuthOK     = false;
            StaffService staffService = new StaffService();

            if (ac.HttpContext.Session["sessionId"] != null)
            {
                string  sessionId = ac.HttpContext.Session["sessionId"].ToString();
                StaffEF staff     = staffService.FindStaffBySessionId(sessionId);

                if (staff != null)
                {
                    isAuthOK = true;
                }
            }

            if (!isAuthOK)
            {
                ac.Result = new RedirectToRouteResult(
                    new RouteValueDictionary {
                    { "controller", "Login" },
                    { "action", "Index" }
                });
            }
        }
Esempio n. 10
0
        public string CreateSession(StaffEF staff)
        {
            string sessionId = Guid.NewGuid().ToString();

            staff.SessionId = sessionId;
            staffEFF.SaveStaff(staff);
            return(sessionId);
        }
Esempio n. 11
0
        public void UpdatePurchaseOrderToDelivered(StaffEF staff, PurchaseOrderEF po)
        {
            po.DateDeliveredOn = (long)(DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1))).TotalSeconds;
            po.ReceivedById    = staff.StaffId;
            po.Status          = "Delivered";

            purchaseEFF.SavePurchaseOrder(po);
        }
Esempio n. 12
0
        private void SendEmailToStaffOnDecision(StaffEF staff, AdjustmentVoucherEF voucher)
        {
            string email = staff.Email;

            Email.SendEmail(email,
                            "Adjustment Voucher #" + voucher.VoucherId + " : has been " + voucher.Status.ToLower() + ".",
                            "Adjustment Voucher #" + voucher.VoucherId + " has been " + voucher.Status.ToLower() + " by " + voucher.Approver.Name + ".");
        }
Esempio n. 13
0
        // CLear session details and redirect to login
        public ActionResult Index()
        {
            StaffEF staff = staffService.GetStaff();

            staffService.Logout(staff);
            Session["sessionId"] = null;
            Session["staff"]     = null;

            return(RedirectToAction("Index", "Login"));
        }
Esempio n. 14
0
        //Supplier List
        public ActionResult Index()
        {
            StaffEF           staff     = staffService.GetStaff();
            string            staffRole = staff.Role.Description;
            List <SupplierEF> suppliers = purchaseService.FindAllSuppliers();

            ViewBag.suppliers = suppliers;
            ViewBag.staffRole = staffRole;
            return(View());
        }
Esempio n. 15
0
        public void CheckDelegation(DepartmentEF department)
        {
            long currentTimestamp = (long)(DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1))).TotalSeconds;

            if (department.DelegationEndDate < currentTimestamp || department.DelegationEndDate == null)
            {
                StaffEF deptHead = FindDepartmentHead(department.DepartmentCode);
                RemoveStaffDelegation(deptHead);
            }
        }
Esempio n. 16
0
        public void RemoveStaffDelegation(StaffEF staff)
        {
            DepartmentEF department = staff.Department;

            department.AuthorityId         = staff.StaffId;
            department.DelegationStartDate = null;
            department.DelegationEndDate   = null;

            departmentEFF.SaveDepartment(department);
        }
        public ActionResult Index()
        {
            StaffEF staff = staffService.GetStaff();

            ViewBag.staff = staff;
            List <RequestDTO> requestDTOList = rndService.FindRequestByStaffAndStatus(staff.StaffId, "Submitted");

            ViewBag.requestDTOList = requestDTOList;

            return(View());
        }
Esempio n. 18
0
        public JsonResult AcknowledgeDisbursement(int disbursementId)
        {
            StaffEF staff = staffService.GetStaff();

            ViewBag.staff = staff;
            StationeryDisbursementEF disbursement = rndService.FindDisbursementById(disbursementId);

            rndService.UpdateDisbursementStatus(disbursement);

            return(Json(new { status = "Delivery Acknowledged" }));
        }
Esempio n. 19
0
        public ActionResult ViewDisbursement(int disbursementId)
        {
            StaffEF staff = staffService.GetStaff();

            ViewBag.staff = staff;
            StationeryDisbursementEF disbursement = rndService.FindDisbursementById(disbursementId);
            List <StationeryDisbursementDetailsEF> disbursementDetails = rndService.FindDisbursementDetailsByDisbursementId(disbursementId);

            ViewBag.disbursement        = disbursement;
            ViewBag.disbursementDetails = disbursementDetails;
            return(View());
        }
Esempio n. 20
0
        public ActionResult Index()
        {
            //retrieve staff request history
            StaffEF staff = staffService.GetStaff();

            ViewBag.staff = staff;
            List <RequestDTO> requestDTOList = rndService.FindRequestsByStaff(staff.StaffId);

            ViewBag.requestDTOList = requestDTOList;

            return(View());
        }
Esempio n. 21
0
        public StaffEF GetStaff()
        {
            StaffEF staff = null;

            if (HttpContext.Current.Session["sessionId"] != null)
            {
                string sessionId = HttpContext.Current.Session["sessionId"].ToString();
                staff = this.FindStaffBySessionId(sessionId);
            }

            return(staff);
        }
Esempio n. 22
0
        public void SaveStaff(StaffEF staff)
        {
            var existingStaff = context.Staff.Find(staff.StaffId);

            if (existingStaff == null)
            {
                context.Staff.Add(staff);
            }
            else
            {
                context.Entry(existingStaff).CurrentValues.SetValues(staff);
            }
            context.SaveChanges();
        }
        public ActionResult Index()
        {
            StaffEF staff = staffService.GetStaff();

            ViewBag.staff = staff;
            List <StationeryRequestEF> requestList = rndService.FindRequestByDepartmentAndStatus(staff.Department, "all");
            List <string> requestDate = rndService.ConvertToDate(requestList);

            ViewBag.requestList     = requestList;
            ViewBag.requestDate     = requestDate;
            ViewBag.departmentStaff = staffService.FindAllEmployeeByDepartmentCode(staff.DepartmentCode);

            return(View());
        }
        public ActionResult ApproveRequest(string requestId, string comment, string decision)
        {
            StaffEF staff = staffService.GetStaff();

            ViewBag.staff = staff;

            StationeryRequestEF request = rndService.FindRequestById(requestId);
            List <StationeryRequestDetailsEF> requestDetails = rndService.FindRequestDetailsByRequestId(requestId);

            // Update approval/rejection and comments to request
            rndService.UpdateRequestDecision(staff, request, comment, decision);

            return(RedirectToAction("Index"));
        }
Esempio n. 25
0
        public void OnAuthorization(AuthorizationContext context)
        {
            StaffEF staff = staffService.GetStaff();

            if (staff.RoleId != 3 && staff.RoleId != 4 && staff.RoleId != 5)
            {
                context.Result = new RedirectToRouteResult(
                    new RouteValueDictionary
                {
                    { "controller", "Error" },
                    { "action", "DepartmentRoleError" }
                }
                    );
            }
        }
Esempio n. 26
0
        public ActionResult ViewSupplier(string supplierCode, string decision)
        {
            SupplierEF supplier = purchaseService.FindSupplierBySupplierCode(supplierCode);

            ViewBag.supplier = supplier;
            StaffEF staff = staffService.GetStaff();

            ViewBag.staffRole = staff.Role.Description;

            if (decision == "edit")
            {
                return(RedirectToAction("EditSupplier", "ManageSupplier", new { supplierCode = supplier.SupplierCode }));
            }
            return(View());
        }
        public void OnAuthorization(AuthorizationContext context)
        {
            StaffEF staff = staffService.GetStaff();

            if (staff.Role.Description != "Store Supervisor")
            {
                context.Result = new RedirectToRouteResult(
                    new RouteValueDictionary
                {
                    { "controller", "Error" },
                    { "action", "StoreRoleError" }
                }
                    );
            }
        }
        public ActionResult ViewDisbursement(int disbursementId)
        {
            StationeryDisbursementEF disbursement = rndService.FindDisbursementById(disbursementId);

            ViewData["disbursement"] = disbursement;
            List <StationeryDisbursementDetailsEF> details = rndService.FindDisbursementDetailsByDisbursementId(disbursementId);
            // list of staff in that department
            List <StaffEF> deptStaff = staffService.FindAllEmployeeByDepartmentCode(disbursement.DepartmentCode);

            ViewData["deptStaff"] = deptStaff;
            StaffEF storeClerk = staffService.GetStaff();

            ViewData["storeClerk"] = storeClerk;
            return(View(details));
        }
Esempio n. 29
0
        public ActionResult ViewCatalogueItem(int catalogueId)
        {
            CatalogueItemEF catItem = stockService.FindCatalogueItemById(catalogueId);

            if (catItem == null)
            {
                return(View("Error"));
            }
            ViewData["catItem"] = catItem;

            StaffEF staff = staffService.GetStaff();

            ViewData["staff"] = staff;
            return(View());
        }
Esempio n. 30
0
        public ActionResult ViewDisbursement(int disbursementId, string decision)
        {
            if (decision == "Back")
            {
                return(RedirectToAction("Index"));
            }
            StaffEF staff = staffService.GetStaff();

            ViewBag.staff = staff;
            StationeryDisbursementEF disbursement = rndService.FindDisbursementById(disbursementId);

            rndService.UpdateDisbursementStatus(disbursement);

            return(RedirectToAction("ViewDisbursement", new { disbursementId }));
        }