示例#1
0
        /// <summary>
        /// Get the details of the leave
        /// </summary>
        /// <param name="vlvapplication">Gets the Leave Application ID</param>
        /// <returns>Returns a table containg the information of leave that is applied.</returns>
        /// <remarks>Creates a table in the Email that contains all the necessary ionformation for the leave application.</remarks>
        private static string GetLeaveDetails(VAT_LeaveApplication vlvapplication)
        {
            string type = vlvapplication.LeaveTypeName;

            if (vlvapplication.IsHalf == true)
            {
                type = type + " - Half";
                if (vlvapplication.FirstHalf == true)
                {
                    type = type + "(First)";
                }
                else
                {
                    type = type + "(Second)";
                }
            }
            string Body = "<table><tr><td>LEAVE TYPE</td><td>" + type + "</td></tr>"
                          + "<tr><td>STARTING DATE</td><td>" + vlvapplication.FromDate.ToString("dd-MMM-yyyy") + "</td></tr>"
                          + "<tr><td>ENDING DATE</td><td>" + vlvapplication.ToDate.ToString("dd-MMM-yyyy") + "</td></tr>"
                          + "<tr><td>RETURN DATE</td><td>" + vlvapplication.ReturnDate.Value.ToString("dd-MMM-yyyy") + "</td></tr>"
                          //+ "<tr><td>TOTAL DAYS</td><td>" + vlvapplication.NoOfDays.ToString() + "</td></tr>"
                          + "<tr><td>WORKING DAYS</td><td>" + vlvapplication.NoOfDays.ToString() + "</td></tr></table>";

            return(Body);
        }
示例#2
0
 public void CreateLeave(LeaveApplication lvapplication, LeaveType lvType, VMLoggedUser LoggedInUser)
 {
     try
     {
         //gets the information of leave and saving entries from logged in user to leaveApplication.
         lvapplication.LeaveDate = DateTime.Today;
         int _userID = (int)LoggedInUser.PUserID;
         lvapplication.LineManagerID     = (int)LoggedInUser.LineManagerID;
         lvapplication.CreatedBy         = _userID;
         lvapplication.Active            = true;
         lvapplication.LeaveStageID      = "P";
         lvapplication.SubmittedByUserID = LoggedInUser.PUserID;
         LeaveApplicationRepository.Add(lvapplication);
         LeaveApplicationRepository.Save();
         // Add notification to Line manager's end that he has a pending leave Request.
         DDService.SaveNotification(lvapplication.LineManagerID, "/ESSP/ESSPLeaveApp/PendingLeaveApplicationIndex",
                                    Convert.ToInt32(NTLeaveEnum.LeavePending), true, lvapplication.EmpID, lvapplication.PLeaveAppID);
         SaveLeaveApplicationFlow(lvapplication.LineManagerID, _userID, lvapplication.LeaveStageID, lvapplication.PLeaveAppID, lvapplication.LeaveReason, "");
         // Save entry in Notification Email table for where the email is generated through service.
         VHR_UserEmployee LMUser  = DDService.GetEmployeeUser(lvapplication.LineManagerID, null);
         VHR_UserEmployee EmpUser = DDService.GetEmployeeUser(null, lvapplication.EmpID);
         Expression <Func <VAT_LeaveApplication, bool> > SpecificEntries2 = c => c.PLeaveAppID == lvapplication.PLeaveAppID;
         VAT_LeaveApplication vlvApplication = VEPESSPLeaveApplicationReporsitory.FindBy(SpecificEntries2).First();
         DDService.GenerateEmail(LMUser.OfficialEmailID, "", "Leave Application # " + lvapplication.PLeaveAppID.ToString(),
                                 ESSPText.GetPendingLeaveText(vlvApplication, LMUser.UserEmployeeName), LoggedInUser.PUserID, Convert.ToInt32(NTLeaveEnum.LeavePending));
     }
     catch (Exception ex)
     {
     }
 }
示例#3
0
        public void RevertToLMLeaveApplication(VMESSPCommon vmESSPCommon, VMLoggedUser LoggedInUser)
        {
            //gets the First entry and comment box for the approval of the leave application
            LeaveApplication lvapplication = LeaveApplicationRepository.GetSingle((int)vmESSPCommon.PID);

            //Changes Leave Stage ID to "A" (Approved).
            lvapplication.LeaveStageID  = "L";
            lvapplication.LineManagerID = (int)lvapplication.SubmittedByUserID;
            LeaveApplicationRepository.Edit(lvapplication);
            UnitOfWork.Commit();
            //Generated the Notification to the Employee about the rejection of the leave application.
            VHR_UserEmployee LMUser  = DDService.GetEmployeeUser(lvapplication.LineManagerID, null);
            VHR_UserEmployee EmpUser = DDService.GetEmployeeUser(null, lvapplication.EmpID);

            DDService.SaveNotification((int)lvapplication.LineManagerID, "/ESSP/ESSPLeaveApp/PendingLeaveApplicationIndex",
                                       Convert.ToInt32(NTLeaveEnum.LeaveReverttoLM), true, LMUser.UserEmpID, lvapplication.PLeaveAppID);
            SaveLeaveApplicationFlow((int)LMUser.PUserID, (int)LoggedInUser.PUserID, lvapplication.LeaveStageID, lvapplication.PLeaveAppID, "", vmESSPCommon.Comment);
            //Generate Email to the employee that leave is Rejected.
            Expression <Func <VAT_LeaveApplication, bool> > SpecificEntries3 = c => c.PLeaveAppID == lvapplication.PLeaveAppID;
            VAT_LeaveApplication vlvApplication = VEPESSPLeaveApplicationReporsitory.FindBy(SpecificEntries3).First();

            DDService.GenerateEmail(EmpUser.OfficialEmailID, "", "Leave Application # " + lvapplication.PLeaveAppID.ToString(),
                                    ESSPText.GetRejectLeaveText(vlvApplication, EmpUser.UserEmployeeName, LMUser.UserEmployeeName, LMUser.DesignationName), LoggedInUser.PUserID, Convert.ToInt32(NTLeaveEnum.LeaveRejected));
            // Disable Notification ofPending Leave from the Line Manager's End.
            int notiTypeID1 = Convert.ToInt32(NTLeaveEnum.LeaveRecommend);
            Expression <Func <Notification, bool> > SpecificEntries = c => (c.UserID == LoggedInUser.PUserID && c.Status == true && (c.NotificationTypeID == notiTypeID1) && c.PID == lvapplication.PLeaveAppID);

            DDService.DeleteNotification(SpecificEntries);
        }
示例#4
0
        public ActionResult CommentView(string FormName, int?PID)
        {
            VMESSPCommon vmEsspCommon = new VMESSPCommon();

            vmEsspCommon.FormName = FormName;
            vmEsspCommon.PID      = PID;
            if (vmEsspCommon.FormName == "JobCard")
            {
                ViewBag.StageID = new SelectList(DDService.GetJobCardStage().ToList().Where(aa => aa.PJobCardStageID != "P").ToList(), "PJobCardStageID", "JobCardStageName", "A");
            }
            else
            {
                Expression <Func <VAT_LeaveApplication, bool> > SpecificEntries97 = c => c.PLeaveAppID == PID;
                VAT_LeaveApplication vatLeaveApplication = VATLeaveApplicationService.GetIndexSpecific(SpecificEntries97).First();
                // Leave Stage D is for recomendation
                if (vatLeaveApplication.LeaveStageID == "D")
                {
                    // Leave Stage L is for revert to LM
                    ViewBag.StageID = new SelectList(DDService.GetLeaveStage().ToList().Where(aa => aa.PLeaveStageID == "L").OrderByDescending(aa => aa.PLeaveStageID).ToList(), "PLeaveStageID", "LeaveStageName", "L");
                }
                // Leave Stage R is for Rejected
                else if (vatLeaveApplication.LeaveStageID == "P")
                {
                    ViewBag.StageID = new SelectList(DDService.GetLeaveStage().ToList().Where(aa => aa.PLeaveStageID == "R").OrderByDescending(aa => aa.PLeaveStageID).ToList(), "PLeaveStageID", "LeaveStageName", "R");
                }
                else if (vatLeaveApplication.LeaveStageID == "L")
                {
                    ViewBag.StageID = new SelectList(DDService.GetLeaveStage().ToList().Where(aa => aa.PLeaveStageID == "R").OrderByDescending(aa => aa.PLeaveStageID).ToList(), "PLeaveStageID", "LeaveStageName", "R");
                }
            }
            return(View());
        }
        public ActionResult ViewLeaveApplication(int?id)
        {
            VMLoggedUser         vmf = Session["LoggedInUser"] as VMLoggedUser;
            VAT_LeaveApplication vAT_LeaveApplication = new VAT_LeaveApplication();
            Expression <Func <VAT_LeaveApplication, bool> > SpecificEntries = c => c.PLeaveAppID == id;

            return(View(VATLeaveApplicationService.GetIndexSpecific(SpecificEntries).First()));
        }
示例#6
0
        public string ApproveLeaveApplication(VMESSPCommon vmESSPCommon, VMLoggedUser LoggedInUser, string Message)
        {
            //gets the First entry and comment box for the approval of the leave application
            LeaveApplication lvapplication = LeaveApplicationRepository.GetSingle((int)vmESSPCommon.PID);
            //if (DDService.IsDateLieBetweenActivePayroll(lvapplication.FromDate))
            //{
            //Gets Employee Information about the access of the location and company of the employee.
            List <VHR_EmployeeProfile> _emp     = DDService.GetEmployeeInfo(LoggedInUser).Where(aa => aa.PEmployeeID == lvapplication.EmpID).ToList();
            VHR_EmployeeProfile        employee = DDService.GetEmployeeInfo(LoggedInUser).Where(aa => aa.PEmployeeID == lvapplication.EmpID).First();
            //Gets Employee Leave policy on the Type of leave applied
            LeavePolicy lvPolicy = AssistantLeave.GetEmployeeLeavePolicyID(_emp, lvapplication.LeaveTypeID, DDService.GetLeavePolicy().ToList());

            Expression <Func <PayrollPeriod, bool> > SpecificEntries96 = c => lvapplication.FromDate >= c.PRStartDate && lvapplication.FromDate <= c.PREndDate && c.PeriodStageID == "C";
            List <PayrollPeriod> dbPayrollPeriods = PayrollPeriodService.GetIndexSpecific(SpecificEntries96).ToList();

            if (dbPayrollPeriods.Count() > 0)
            {
                Message = "Cannot Approve leaves of Closed Payroll Period";
            }
            if (Message == "")
            {
                //Check the Leave balance if there are some leaves remaining of the employee whose leave is being approved.
                if (LeaveApplicationService.CheckLeaveBalance(lvapplication, lvPolicy))
                {
                    //Changes Leave Stage ID to "A" (Approved).
                    lvapplication.LeaveStageID = "A";
                    //Gets the leave Type through generic service.
                    LeaveType lvType = DDService.GetLeaveType().First(aa => aa.PLeaveTypeID == lvapplication.LeaveTypeID);
                    LeaveApplicationService.BalanceLeaves(lvapplication, lvType, AssistantLeave.GetPayRollPeriodID(DDService.GetPayrollPeriod().ToList(), lvapplication.FromDate));
                    LeaveApplicationRepository.Edit(lvapplication);
                    LeaveApplicationRepository.Save();
                    UnitOfWork.Commit();
                    //Adds leave to leave data frim where its impact is generated on the reports.
                    LeaveApplicationService.AddLeaveToLeaveData(lvapplication, lvType, lvPolicy);
                    //Add Leaves to Att Data where Daily and Monthy Reporcessing of attendance occurs on the day
                    LeaveApplicationService.AddLeaveToAttData(lvapplication, lvType);
                    VHR_UserEmployee LMUser  = DDService.GetEmployeeUser(lvapplication.LineManagerID, null);
                    VHR_UserEmployee EmpUser = DDService.GetEmployeeUser(null, lvapplication.EmpID);
                    // Add notification to the Employee that leave has been approved.
                    DDService.SaveNotification((int)EmpUser.PUserID, "/ESSP/ESSPLeaveApp/Index",
                                               Convert.ToInt32(NTLeaveEnum.LeaveApproved), true, lvapplication.LineManagerID, lvapplication.PLeaveAppID);
                    //Add entry in the flow table
                    SaveLeaveApplicationFlow((int)EmpUser.PUserID, lvapplication.LineManagerID, lvapplication.LeaveStageID, lvapplication.PLeaveAppID, "", vmESSPCommon.Comment);

                    //Save Email in the Notification Email table from where through services email is generated to employee about the approval of the leave Application.
                    Expression <Func <VAT_LeaveApplication, bool> > SpecificEntries3 = c => c.PLeaveAppID == lvapplication.PLeaveAppID;
                    VAT_LeaveApplication vlvApplication = VEPESSPLeaveApplicationReporsitory.FindBy(SpecificEntries3).First();
                    DDService.GenerateEmail(EmpUser.OfficialEmailID, "", "Leave Application # " + lvapplication.PLeaveAppID.ToString(),
                                            ESSPText.GetApprovedLeaveText(vlvApplication, EmpUser.UserEmployeeName, LMUser.UserEmployeeName, LMUser.DesignationName), LoggedInUser.PUserID, Convert.ToInt32(NTLeaveEnum.LeaveApproved));

                    // Disable Notification of the pending Leave.
                    int notiTypeID1 = Convert.ToInt32(NTLeaveEnum.LeavePending);
                    Expression <Func <Notification, bool> > SpecificEntries = c => (c.UserID == LoggedInUser.PUserID && c.Status == true && (c.NotificationTypeID == notiTypeID1) && c.PID == lvapplication.PLeaveAppID);
                    DDService.DeleteNotification(SpecificEntries);
                }
            }
            return(Message);
        }
示例#7
0
        /// <summary>
        /// Gets the Text for the leave that is rejected by the Line manager.
        /// </summary>
        /// <param name="vlvapplication">Get the leave application id.</param>
        /// <param name="ToName">To whom email is being sent.</param>
        /// <param name="LMName">Line managers Name who is sending the email.</param>
        /// <param name="LMDesignation">Line Manager's designation.</param>
        /// <returns></returns>
        /// <remarks>This method has the all the text that is required for the email by just calling this function in the controller</remarks>
        public static string GetRejectLeaveText(VAT_LeaveApplication vlvapplication, string ToName, string LMName, string LMDesignation)
        {
            string Body = GetHeader().ToString() +
                          "<body>Dear " + ToName + ", <br/><br/>Your Leave Application # " + vlvapplication.PLeaveAppID.ToString() + " has been <strong>Rejected</strong> by " + LMName + " [" + LMDesignation + "].";

            Body = Body + "<br/><br/> Further Details are:<br/><br/>" + GetLeaveDetails(vlvapplication).ToString();
            Body = Body + "<br/>You can access the ESSP account through following link: <br/>" + "http://essp-portal/";
            Body = Body + "<br/><br/><p>***This is System generated email. Please do not reply.***</p><p>Please print this email only if necessary. </p><p>Thank You!</p>" + "</body>";
            return(Body);
        }
示例#8
0
        /// <summary>
        /// This method Gets the pending Leaves text
        /// </summary>
        /// <param name="vlvapplication"> Gets the information of the applied leave.</param>
        /// <param name="ToName">To whom Email is being sent</param>
        /// <returns>generates a mail to the User </returns>
        /// <remarks>This methods get the Text of the email that is being sent to the user by just calling this functions.</remarks>
        public static string GetPendingLeaveText(VAT_LeaveApplication vlvapplication, string ToName)
        {
            string Body = "<head><style>body{font-family: calibri;}table{font-family: calibri; border-collapse: collapse; width: 100%;font-size:13px;}td, th{border: 1px solid #dddddd; text-align: left; padding: 8px;}</style></head>" +
                          "<body>Dear " + ToName + ", <br/><br/>Leave Application # " + vlvapplication.PLeaveAppID.ToString() + " was submitted by " + vlvapplication.EmployeeName + " [" + vlvapplication.DesignationName + "] is <strong>Pending</strong> for your approval.";

            Body = Body + "<br/><br/> Further Details are:<br/><br/>" + GetLeaveDetails(vlvapplication).ToString();
            Body = Body + "<br/>You can access the ESSP account through following link: <br/>" + "http://essp-portal/";
            Body = Body + "<br/><br/><p>***This is System generated email. Please do not reply.***</p><p>Please print this email only if necessary.</p><p>Thank You!</p>" + "</body>";
            return(Body);
        }
示例#9
0
        public ActionResult Delete(LeaveApplication obj)
        {
            VMLoggedUser LoggedInUser = Session["LoggedInUser"] as VMLoggedUser;
            Expression <Func <VAT_LeaveApplication, bool> > SpecificEntries2 = c => (c.PLeaveAppID == obj.PLeaveAppID);
            VAT_LeaveApplication vlvapplication = VATLeaveApplicationService.GetIndexSpecific(SpecificEntries2).First();

            ESSPLeaveService.PostDelete(obj);
            // Disable Notifications
            // Disable Notifications
            int notiTypeID1 = Convert.ToInt32(NTLeaveEnum.LeavePending);
            Expression <Func <Notification, bool> > SpecificEntries = c => (c.EmployeeID == LoggedInUser.UserEmpID && c.Status == true && (c.NotificationTypeID == notiTypeID1) && c.PID == vlvapplication.PLeaveAppID);

            DDService.DeleteNotification(SpecificEntries);
            ToasterMessages.Add("Leave Deleted successfully.");
            Session["ToasterMessages"] = ToasterMessages;
            return(Json("OK", JsonRequestBehavior.AllowGet));
        }
示例#10
0
        public FilePathResult OpenCertificate(int?fileName)
        {
            Expression <Func <VAT_LeaveApplication, bool> > SpecificEntries = aa => aa.PLeaveAppID == fileName;
            VAT_LeaveApplication vatleaveapp = VATLeaveApplicationService.GetIndexSpecific(SpecificEntries).First();
            var dir            = Server.MapPath("/UploadFiles");
            var checkextension = Path.GetExtension(vatleaveapp.PathName).ToLower();

            if (checkextension == ".pdf")
            {
                var path = Path.Combine(dir, fileName + ".pdf");
                return(base.File(path, "application/pdf"));
            }
            else
            {
                var path = Path.Combine(dir, fileName + ".jpg");
                return(base.File(path, "image/jpeg"));
            }
        }
示例#11
0
        public void ApprovalCode(VMESSPCommon vmESSPCommon, VMLoggedUser LoggedInUser, LeaveApplication lvapplication, LeavePolicy lvPolicy)
        {
            if (LeaveApplicationService.CheckLeaveBalance(lvapplication, lvPolicy))
            {
                //Changes Leave Stage ID to "A" (Approved).
                lvapplication.LeaveStageID = "A";
                //Gets the leave Type through generic service.
                LeaveType lvType = DDService.GetLeaveType().First(aa => aa.PLeaveTypeID == lvapplication.LeaveTypeID);
                LeaveApplicationService.BalanceLeaves(lvapplication, lvType, AssistantLeave.GetPayRollPeriodID(DDService.GetPayrollPeriod().ToList(), lvapplication.FromDate));
                LeaveApplicationRepository.Edit(lvapplication);
                LeaveApplicationRepository.Save();
                UnitOfWork.Commit();
                //Adds leave to leave data frim where its impact is generated on the reports.
                LeaveApplicationService.AddLeaveToLeaveData(lvapplication, lvType, lvPolicy);
                //Add Leaves to Att Data where Daily and Monthy Reporcessing of attendance occurs on the day
                LeaveApplicationService.AddLeaveToAttData(lvapplication, lvType);
                VHR_UserEmployee LMUser  = DDService.GetEmployeeUser(lvapplication.LineManagerID, null);
                VHR_UserEmployee EmpUser = DDService.GetEmployeeUser(null, lvapplication.EmpID);
                // Add notification to the Employee that leave has been approved.
                DDService.SaveNotification((int)EmpUser.PUserID, "/ESSP/ESSPLeaveApp/Index",
                                           Convert.ToInt32(NTLeaveEnum.LeaveApproved), true, lvapplication.LineManagerID, lvapplication.PLeaveAppID);
                //Add entry in the flow table
                SaveLeaveApplicationFlow((int)EmpUser.PUserID, lvapplication.LineManagerID, lvapplication.LeaveStageID, lvapplication.PLeaveAppID, "", vmESSPCommon.Comment);

                //Save Email in the Notification Email table from where through services email is generated to employee about the approval of the leave Application.
                Expression <Func <VAT_LeaveApplication, bool> > SpecificEntries3 = c => c.PLeaveAppID == lvapplication.PLeaveAppID;
                VAT_LeaveApplication vlvApplication = VEPESSPLeaveApplicationReporsitory.FindBy(SpecificEntries3).First();
                DDService.GenerateEmail(EmpUser.OfficialEmailID, "", "Leave Application # " + lvapplication.PLeaveAppID.ToString(),
                                        ESSPText.GetApprovedLeaveText(vlvApplication, EmpUser.UserEmployeeName, LMUser.UserEmployeeName, LMUser.DesignationName), LoggedInUser.PUserID, Convert.ToInt32(NTLeaveEnum.LeaveApproved));

                // Disable Notification of the pending Leave.
                int notiTypeID1 = Convert.ToInt32(NTLeaveEnum.LeavePending);
                Expression <Func <Notification, bool> > SpecificEntries = c => (c.UserID == LoggedInUser.PUserID && c.Status == true && (c.NotificationTypeID == notiTypeID1) && c.PID == lvapplication.PLeaveAppID);
                DDService.DeleteNotification(SpecificEntries);

                // Disable Notification of the pending Leave.
                int notiTypeID2 = Convert.ToInt32(NTLeaveEnum.LeaveRecommend);
                Expression <Func <Notification, bool> > SpecificEntries2 = c => (c.UserID == LoggedInUser.PUserID && c.Status == true && (c.NotificationTypeID == notiTypeID2) && c.PID == lvapplication.PLeaveAppID);
                DDService.DeleteNotification(SpecificEntries2);
            }
        }
示例#12
0
        public VMESSPLeaveDetails GetESSPLeaveEmpDetail(int?id, VMLoggedUser LoggedInUser)
        {
            //Gets the Specific Leave flow id
            Expression <Func <VAT_LeaveApplicationFlow, bool> > SpecificEntries = c => c.LeaveAppID == id;
            List <VAT_LeaveApplicationFlow> vatLeaveApplicationFlows            = VATLeaveApplicationFlowReporsitory.FindBy(SpecificEntries);
            //Gets the Specific Leave id whose Detail is to shown.
            Expression <Func <VAT_LeaveApplication, bool> > SpecificEntries2 = c => c.PLeaveAppID == id;
            VAT_LeaveApplication dbVAT_LeaveApplication = VEPESSPLeaveApplicationReporsitory.FindBy(SpecificEntries2).First();
            //View Model of the leave to show Specific Leave's Data in the View.
            VMESSPLeaveDetails vMESSPLeaveDetail = new VMESSPLeaveDetails();

            vMESSPLeaveDetail.DBVATLeaveApplicationFlow = vatLeaveApplicationFlows;
            vMESSPLeaveDetail.LeaveTypeName             = dbVAT_LeaveApplication.LeaveTypeName;
            vMESSPLeaveDetail.PLeaveAppID     = dbVAT_LeaveApplication.PLeaveAppID;
            vMESSPLeaveDetail.DesignationName = dbVAT_LeaveApplication.DesignationName;
            vMESSPLeaveDetail.ReturnDate      = dbVAT_LeaveApplication.ReturnDate;
            vMESSPLeaveDetail.ToDate          = dbVAT_LeaveApplication.ToDate;
            vMESSPLeaveDetail.FromDate        = dbVAT_LeaveApplication.FromDate;
            vMESSPLeaveDetail.IsAccum         = dbVAT_LeaveApplication.IsAccum;
            vMESSPLeaveDetail.IsHalf          = dbVAT_LeaveApplication.IsHalf;
            vMESSPLeaveDetail.FirstHalf       = dbVAT_LeaveApplication.FirstHalf;
            vMESSPLeaveDetail.LeaveAddress    = dbVAT_LeaveApplication.LeaveAddress;
            vMESSPLeaveDetail.LeaveDate       = dbVAT_LeaveApplication.LeaveDate;

            vMESSPLeaveDetail.LeaveTypeID = dbVAT_LeaveApplication.LeaveTypeID;
            if (dbVAT_LeaveApplication.IsAccum == true)
            {
                vMESSPLeaveDetail.LeaveTypeName = "Accumulated";
            }
            vMESSPLeaveDetail.LeaveTypeName = dbVAT_LeaveApplication.LeaveTypeName;
            vMESSPLeaveDetail.LeaveStageID  = dbVAT_LeaveApplication.LeaveStageID;
            vMESSPLeaveDetail.CalenderDays  = dbVAT_LeaveApplication.CalenderDays;
            vMESSPLeaveDetail.LeaveReason   = dbVAT_LeaveApplication.LeaveReason;
            vMESSPLeaveDetail.NoOfDays      = dbVAT_LeaveApplication.NoOfDays;
            vMESSPLeaveDetail.RejectRemarks = dbVAT_LeaveApplication.RejectRemarks;
            vMESSPLeaveDetail.EmployeeName  = dbVAT_LeaveApplication.EmployeeName;
            vMESSPLeaveDetail.ApprovedBy    = dbVAT_LeaveApplication.ApprovedBy;
            vMESSPLeaveDetail.LMName        = LoggedInUser.LMEmployeeName;

            return(vMESSPLeaveDetail);
        }
示例#13
0
        public string RecommendLeaveApplication(VMESSPCommon vmESSPCommon, VMLoggedUser LoggedInUser, string Message)
        {
            //gets the First entry and comment box for the approval of the leave application
            LeaveApplication lvapplication = LeaveApplicationRepository.GetSingle((int)vmESSPCommon.PID);
            //if (DDService.IsDateLieBetweenActivePayroll(lvapplication.FromDate))
            //{
            //Gets Employee Information about the access of the location and company of the employee.
            List <VHR_EmployeeProfile> _emp     = DDService.GetEmployeeInfo(LoggedInUser).Where(aa => aa.PEmployeeID == lvapplication.EmpID).ToList();
            VHR_EmployeeProfile        employee = DDService.GetEmployeeInfo(LoggedInUser).Where(aa => aa.PEmployeeID == lvapplication.EmpID).First();
            //Gets Employee Leave policy on the Type of leave applied
            LeavePolicy lvPolicy = AssistantLeave.GetEmployeeLeavePolicyID(_emp, lvapplication.LeaveTypeID, DDService.GetLeavePolicy().ToList());

            Expression <Func <PayrollPeriod, bool> > SpecificEntries96 = c => lvapplication.FromDate >= c.PRStartDate && lvapplication.FromDate <= c.PREndDate && c.PeriodStageID == "C";
            List <PayrollPeriod> dbPayrollPeriods = PayrollPeriodService.GetIndexSpecific(SpecificEntries96).ToList();

            if (dbPayrollPeriods.Count() > 0)
            {
                Message = "Cannot Approve leaves of Closed Payroll Period";
            }
            if (Message == "")
            {
                if (employee.HasOneStep == false)
                {
                    if (LoggedInUser.LineManagerID == null && (lvapplication.LeaveStageID == "P" || lvapplication.LeaveStageID == "D"))
                    {
                        ApprovalCode(vmESSPCommon, LoggedInUser, lvapplication, lvPolicy);
                    }
                    else if (LoggedInUser.LineManagerID != null && (lvapplication.LeaveStageID == "P"))
                    {
                        //gets the information of leave and saving entries from logged in user to leaveApplication.

                        int _userID = (int)LoggedInUser.PUserID;
                        lvapplication.LineManagerID     = (int)LoggedInUser.LineManagerID;
                        lvapplication.SubmittedByUserID = LoggedInUser.PUserID;
                        lvapplication.LeaveStageID      = "D";
                        LeaveApplicationRepository.Edit(lvapplication);
                        LeaveApplicationRepository.Save();
                        // Add notification to Line manager's end that he has a pending leave Request.
                        DDService.SaveNotification(lvapplication.LineManagerID, "/ESSP/ESSPLeaveApp/PendingLeaveApplicationIndex",
                                                   Convert.ToInt32(NTLeaveEnum.LeaveRecommend), true, lvapplication.EmpID, lvapplication.PLeaveAppID);
                        SaveLeaveApplicationFlow(lvapplication.LineManagerID, _userID, lvapplication.LeaveStageID, lvapplication.PLeaveAppID, lvapplication.LeaveReason, "");
                        // Save entry in Notification Email table for where the email is generated through service.
                        VHR_UserEmployee LMUser  = DDService.GetEmployeeUser(lvapplication.LineManagerID, null);
                        VHR_UserEmployee EmpUser = DDService.GetEmployeeUser(null, lvapplication.EmpID);
                        Expression <Func <VAT_LeaveApplication, bool> > SpecificEntries2 = c => c.PLeaveAppID == lvapplication.PLeaveAppID;
                        VAT_LeaveApplication vlvApplication = VEPESSPLeaveApplicationReporsitory.FindBy(SpecificEntries2).First();
                        DDService.GenerateEmail(LMUser.OfficialEmailID, "", "Leave Application # " + lvapplication.PLeaveAppID.ToString(),
                                                ESSPText.GetPendingLeaveText(vlvApplication, LMUser.UserEmployeeName), LoggedInUser.PUserID, Convert.ToInt32(NTLeaveEnum.LeavePending));

                        // Disable Notification of the pending Leave.
                        int notiTypeID1 = Convert.ToInt32(NTLeaveEnum.LeavePending);
                        Expression <Func <Notification, bool> > SpecificEntries = c => (c.UserID == LoggedInUser.PUserID && c.Status == true && (c.NotificationTypeID == notiTypeID1) && c.PID == lvapplication.PLeaveAppID);
                        DDService.DeleteNotification(SpecificEntries);
                    }
                    else if (LoggedInUser.LineManagerID != null && (lvapplication.LeaveStageID == "D"))
                    {
                        ApprovalCode(vmESSPCommon, LoggedInUser, lvapplication, lvPolicy);
                    }
                }
                else
                {
                    if (lvapplication.LeaveStageID == "P")
                    {
                        ApprovalCode(vmESSPCommon, LoggedInUser, lvapplication, lvPolicy);
                    }
                }
            }
            return(Message);
        }