Example #1
0
        public ActionResult TargetInputForm(string UserName)
        {
            if (UserName == null || UserName.Equals(String.Empty))
            {
                ViewBag.ErrorMessage = "You must be logged in to continue.";
                return(RedirectToAction("AwaitingMyApproval", "AwaitingApproval"));
            }

            SuperInputTargetModel superInputTargetModel = new SuperInputTargetModel();

            if (TempData["superInputTargetModel"] != null)
            {
                superInputTargetModel = TempData["superInputTargetModel"] as SuperInputTargetModel;
            }
            else
            {
                //now resolve the user profile from AD and Xceed
                StaffADProfile staffADProfile = new StaffADProfile();
                staffADProfile.user_logon_name = UserName;

                //  staffADProfile.user_logon_name = "ADAMU.LAWANI";

                //AD
                ActiveDirectoryQuery activeDirectoryQuery = new ActiveDirectoryQuery(staffADProfile);
                staffADProfile = activeDirectoryQuery.GetStaffProfile();
                if (staffADProfile == null)
                {
                    ViewBag.ErrorMessage = "Your profile is not properly setup on the system. Please contact InfoTech.";
                    return(RedirectToAction("AwaitingMyApproval", "AwaitingApproval", new { UserName = Session["UserName"] as string }));
                }

                //Appraisal Initiaor Setup
                //Resolve the --branchname --branchcode --department --deptcode --appperiod from Tb_TargetInitiators table
                staffADProfile = new LINQCalls().setInitiatorFields(staffADProfile);
                if (staffADProfile.branch_code == null)
                {
                    ViewBag.ErrorMessage = "Your profile is not properly setup for Target. Please contact Human Resources.";
                    return(RedirectToAction("AwaitingMyApproval", "AwaitingApproval", new { UserName = Session["UserName"] as string }));
                }

                ViewBag.StaffBranch = staffADProfile.branch_name + ((staffADProfile.branch_code.Equals(HOBRCODE)) ? " | " + staffADProfile.hodeptcode : String.Empty);
                ViewBag.StaffNumber = staffADProfile.employee_number;
                //Check if the initiator/branch/has an existing entry for the AppraisalPeriod
                List <RequestDetails> requestDetails = new List <RequestDetails>();

                if (staffADProfile.branch_code != "001")
                {
                    requestDetails = new LINQCalls().getExistingTargetEntry(staffADProfile);
                }
                else
                {
                    ////staffprofile ho_staff_pro = new staffprofile();
                    //// ho_staff_pro = new LINQCalls().getProfile(staffADProfile.employee_number);
                    requestDetails = new LINQCalls().getExistingHOTargetEntry(staffADProfile);
                }


                //Great. Everything looks okay."
                //Now let's get the staff reporting to you--using branchcode and deptcode(HO only)
                //see if the requestdetails entry has anything
                if (requestDetails.Count <= 0)
                {
                    requestDetails = (staffADProfile.branch_code.Equals(HOBRCODE)) ? new LINQCalls().getMarketingStaff_HO(staffADProfile): new LINQCalls().getMarketingStaff_Branch(staffADProfile);
                }
                else
                {
                    //OH dear:-) You go some shit keyed in before now---we're gonna blast u to My Entries view--hold tight
                    //return RedirectToAction("MyEntries",new { UserName=UserName } );
                    return(RedirectToAction("MyEntries", "MyEntries", new { UserName = UserName }));
                }

                Debug.WriteLine(requestDetails);
                /**Now lets see if the list contains the others entry***/
                //if others is not found, add
                //if others exists, then send it to the bottom of the stack
                if (!requestDetails.Exists(x => x.name.ToUpper().Contains(OTHERS)))
                {
                    RequestDetails os = new RequestDetails();
                    os.employee_number
                             = NA;
                    os.name  = OTHERS;
                    os.grade = NA;
                    requestDetails.Add(os);
                }

                Debug.WriteLine(Session.SessionID.ToString().ToUpper());
                string workflowid = (requestDetails.ElementAt(0).workflowid.Equals(String.Empty)) ? Guid.NewGuid().ToString().ToUpper() : requestDetails.ElementAt(0).workflowid;
                //string workflowid     = ( requestDetails.ElementAt(0).workflowid.Equals(String.Empty) ) ? Session.SessionID.ToString().ToUpper() : requestDetails.ElementAt(0).workflowid;
                int      requeststageid  = requestDetails.ElementAt(0).requeststageid;
                string   requeststage    = requestDetails.ElementAt(0).requeststage ?? String.Empty;
                DateTime requestdate     = requestDetails.ElementAt(0).requestdate;
                string   initiatornumber = new LINQCalls().getInitiatorNumber(workflowid) ?? staffADProfile.employee_number;

                string cansave = (requeststage.Equals(INIT_STAGE) || requeststage.Equals(DENIED)) && initiatornumber.Equals(staffADProfile.employee_number)
                                            ? this.CANSAVE : "false";

                superInputTargetModel = new SuperInputTargetModel {
                    WorkflowID        = workflowid,
                    RequestStageID    = requeststageid,
                    RequestStage      = requeststage,
                    RequestDate       = requestdate,
                    CanSave           = cansave,
                    StaffADProfile    = staffADProfile,
                    RequestDetails    = requestDetails,
                    EntryModel        = null,
                    RequestBranch     = staffADProfile.branch_name,
                    RequestBranchCode = staffADProfile.branch_code
                };

                /*if( TempData["superInputTargetModel"]!=null ){
                 *  superInputTargetModel = TempData["superInputTargetModel"] as SuperInputTargetModel;
                 * } else {
                 *  superInputTargetModel = new SuperInputTargetModel{
                 *                                                      WorkflowID      = workflowid,
                 *                                                      RequestStageID  = requeststageid,
                 *                                                      RequestStage    = requeststage,
                 *                                                      RequestDate     = requestdate,
                 *                                                      StaffADProfile  = staffADProfile,
                 *                                                      RequestDetails  = requestDetails,
                 *                                                      EntriesModel    = null
                 *                                                   };
                 * }*/
            }

            //sort the list
            var d = from x in superInputTargetModel.RequestDetails
                    orderby x.name == OTHERS, x.name
            select x;

            superInputTargetModel.RequestDetails = d.ToList();

            Session["requestDetails"] = superInputTargetModel.RequestDetails;
            Session["UserName"]       = UserName;

            if (TempData["ErrorMessage"] != null)
            {
                ViewBag.ErrorMessage = TempData["ErrorMessage"] as string;
            }

            superInputTargetModel.StaffADProfile.in_StaffName   = "";
            superInputTargetModel.StaffADProfile.in_StaffNumber = "";
            superInputTargetModel.StaffADProfile.in_StaffGrade  = "";

            return(View(superInputTargetModel));
        }
Example #2
0
        public ActionResult EditMemo(string WorkflowID, bool editMode, bool?myEntries)
        {
            _UserName           = User.Identity.Name;
            Session["UserName"] = User.Identity.Name;

            if (_UserName == null || _UserName.Equals(String.Empty))
            {
                ViewBag.ErrorMessage = "You must be logged in to continue.";
                return(RedirectToAction("AwaitingMyApproval", "AwaitingApproval"));
            }

            //now resolve the user profile from AD and Xceed
            StaffADProfile staffADProfile = new StaffADProfile();

            staffADProfile.user_logon_name = _UserName;

            //staffADProfile.user_logon_name = "adebisi.olumoto";

            //AD
            ActiveDirectoryQuery activeDirectoryQuery = new ActiveDirectoryQuery(staffADProfile);

            staffADProfile       = activeDirectoryQuery.GetStaffProfile();
            staffADProfile.grade = new LINQCalls().getStaffGrade(staffADProfile.employee_number);

            if (staffADProfile == null)
            {
                ViewBag.ErrorMessage = "Your profile is not properly setup on the system. Please contact InfoTech.";
                return(RedirectToAction("AwaitingMyApproval", "AwaitingApproval", new { UserName = Session["UserName"] as string }));
            }

            //Get the request identified by the Workflow ID
            MemoSetup memoSetup = new MemoSetup();

            memoSetup           = new LINQCalls().getWorkflowEntry(WorkflowID);
            ViewBag.StaffBranch = memoSetup.Branch;
            int      requeststageid  = memoSetup.RequestStageId;
            string   requeststage    = memoSetup.RequestStage;
            DateTime requestdate     = memoSetup.DateSubmitted;
            string   initiatornumber = new LINQCalls().getInitiatorNumber(WorkflowID) ?? staffADProfile.employee_number;

            string cansave = (requeststage.Equals(INIT_STAGE) || requeststage.Equals(DENIED)) && initiatornumber.Equals(staffADProfile.employee_number)
                                            ? this.CANSAVE : "false";

            XElement  ApprovalHistory = new LINQCalls().getApprovalHistory(WorkflowID);
            XDocument xDocument       = DataHandlers.ToXDocument(ApprovalHistory);

            List <ApprovalDetails> approvalHistory = xDocument.Descendants("Approvals")
                                                     .Select(det => new ApprovalDetails {
                ApproverNames        = det.Element("ApproverName").Value,
                ApproverStaffNumbers = det.Element("ApproverStaffNumber").Value,
                ApprovedStages       = det.Element("ApprovedStage").Value,
                ApproverAction       = det.Element("ApproverAction").Value,
                ApprovalDateTime     = det.Element("ApprovalDateTime").Value,
                ApproverComments     = det.Element("ApproverComment").Value
            }).ToList();

            memoSetup.SignerDetailsList = GetApprovers(memoSetup);

            editMode = editMode && memoSetup.RequestStageId.Equals(1);

            TempData["editMode"] = editMode;    //( editMode==true ) ? null : "false";
            ViewBag.editMode     = editMode;

            if (TempData["ErrorMessage"] != null)
            {
                ViewBag.ErrorMessage = TempData["ErrorMessage"] as string;
            }

            TempData["memoSetup"] = memoSetup;
            return(RedirectToAction("NewMemo", new { UserName = Session["UserName"] as string }));
        }
Example #3
0
        public ActionResult EditTarget(string UserName, string WorkflowID, bool editMode, bool?myEntries)
        {
            //  editMode = true;
            if (UserName == null || UserName.Equals(String.Empty))
            {
                ViewBag.ErrorMessage = "You must be logged in to continue.";
                return(RedirectToAction("AwaitingMyApproval", "AwaitingApproval"));
            }

            //now resolve the user profile from AD and Xceed
            StaffADProfile staffADProfile = new StaffADProfile();

            staffADProfile.user_logon_name = UserName;

            //staffADProfile.user_logon_name = "adebisi.olumoto";

            //AD
            ActiveDirectoryQuery activeDirectoryQuery = new ActiveDirectoryQuery(staffADProfile);

            staffADProfile = activeDirectoryQuery.GetStaffProfile();
            //GET ENTERY BRANC CODE

            staffADProfile.branch_code = new LINQCalls().getEntryProfile(WorkflowID).branch_code;
            staffADProfile.branch_name = new LINQCalls().getEntryProfile(WorkflowID).branch_name;

            if (staffADProfile == null)
            {
                ViewBag.ErrorMessage = "Your profile is not properly setup on the system. Please contact InfoTech.";
                return(RedirectToAction("AwaitingMyApproval", "AwaitingApproval", new { UserName = Session["UserName"] as string }));
            }

            //GET THE APPROVERS DETAILS FROM EXCEED //Approver Setup
            //Resolve the --branchname --branchcode --department --deptcode

            /*
             * staffADProfile = new LINQCalls().setInitiatorFields( staffADProfile );
             * if( staffADProfile.branch_code==null ){
             *  ViewBag.ErrorMessage="Your profile is not properly setup on Exceed. Please contact Human Resources.";
             *  return RedirectToAction( "AwaitingMyApproval","AwaitingApproval",new { UserName = Session["UserName"] as string } );
             * }
             * */

            //Get the request identified by the workflow id
            List <RequestDetails> requestDetails = new List <RequestDetails>();

            if (myEntries != null && myEntries == true)
            {
                string entrykey = staffADProfile.employee_number + "_" + staffADProfile.appperiod + "_" + staffADProfile.branch_code;
                requestDetails = new LINQCalls().getExistingTargetEntry(WorkflowID, staffADProfile.employee_number, entrykey);
            }
            else
            {
                requestDetails = new LINQCalls().getExistingTargetEntry(WorkflowID, staffADProfile.employee_number);
            }


            EntryModel entryModel = new EntryModel();

            entryModel          = new LINQCalls().getWorkflowEntry(WorkflowID);
            ViewBag.StaffBranch = entryModel.Branch;
            int      requeststageid  = entryModel.RequestStageId;
            string   requeststage    = entryModel.RequestStage;
            DateTime requestdate     = entryModel.DateSubmitted;
            string   initiatornumber = new LINQCalls().getInitiatorNumber(WorkflowID) ?? staffADProfile.employee_number;


            //staffADProfile.branch_code = new LINQCalls().getProfile(staffADProfile.employee_number).branch_code;
            //if (requeststage.Equals(INIT_STAGE))
            //{
            //   staffADProfile.branch_code = new LINQCalls().setInitiatorFields(staffADProfile).branch_code;
            //}


            string cansave = (requeststage.Equals(INIT_STAGE) || requeststage.Equals(DENIED)) && initiatornumber.Equals(staffADProfile.employee_number)
                                            ? this.CANSAVE : "false";

            staffADProfile.appperiod = entryModel.AppraisalPeriod;

            XElement  ApprovalHistory = new LINQCalls().getApprovalHistory(WorkflowID);
            XDocument xDocument       = DataHandlers.ToXDocument(ApprovalHistory);

            List <ApprovalDetails> approvalHistory = xDocument.Descendants("Approvals")
                                                     .Select(det => new ApprovalDetails {
                ApproverNames        = det.Element("ApproverName").Value,
                ApproverStaffNumbers = det.Element("ApproverStaffNumber").Value,
                ApprovedStages       = det.Element("ApprovedStage").Value,
                ApproverAction       = det.Element("ApproverAction").Value,
                ApprovalDateTime     = det.Element("ApprovalDateTime").Value
            })
                                                     .ToList();

            SuperInputTargetModel superInputTargetModel = new SuperInputTargetModel();

            if (TempData["superInputTargetModel"] != null)
            {
                superInputTargetModel = TempData["superInputTargetModel"] as SuperInputTargetModel;
            }
            else
            {
                superInputTargetModel = new SuperInputTargetModel {
                    WorkflowID        = WorkflowID,
                    RequestStageID    = entryModel.RequestStageId,
                    RequestStage      = entryModel.RequestStage,
                    RequestDate       = entryModel.DateSubmitted,
                    StaffADProfile    = staffADProfile,
                    RequestDetails    = requestDetails,
                    CanSave           = cansave,
                    ApprovalDetails   = approvalHistory,
                    EntryModel        = entryModel,
                    RequestBranch     = entryModel.Branch,
                    RequestBranchCode = entryModel.BranchCode
                };
            }

            //sort the list
            var d = from x in superInputTargetModel.RequestDetails
                    orderby x.name == OTHERS, x.name
            select x;

            superInputTargetModel.RequestDetails = d.ToList();

            Session["requestDetails"] = superInputTargetModel.RequestDetails;
            Session["UserName"]       = UserName;
            TempData["editMode"]      = (editMode == true) ? null : "false";

            if (TempData["ErrorMessage"] != null)
            {
                ViewBag.ErrorMessage = TempData["ErrorMessage"] as string;
            }

            TempData["superInputTargetModel"] = superInputTargetModel;
            return(RedirectToAction("TargetInputForm", new { UserName = Session["UserName"] as string }));
        }