public function ffinitialize($appInitId, $tableid, $enable_to, $check) { if ($tableid) { $auth = Zend_Auth::getInstance(); if ($auth->hasIdentity()) { $loginUserId = $auth->getStorage()->read()->id; $loginuserRole = $auth->getStorage()->read()->emprole; $loginuserGroup = $auth->getStorage()->read()->group_id; $loginUserEmpId = $auth->getStorage()->read()->employeeId; $loginUserfullname = $auth->getStorage()->read()->userfullname; } $ffEmpRatingsModel = new Default_Model_Feedforwardemployeeratings(); $feedforwardInitModel = new Default_Model_Feedforwardinit(); $appraisalEmpsData = $feedforwardInitModel->getEmpsFromAppEmpRat($appInitId); $appEmpIDs = array(); if (sizeof($appraisalEmpsData) > 0) { foreach ($appraisalEmpsData as $appE) { $appEmpIDs[] = $appE['employee_id']; $where = ''; $data = array('ff_initialization_id' => $tableid, 'question_ids' => $check != '' ? implode(',', $check) : NULL, 'manager_id' => $appE['line_manager_1'], 'employee_id' => $appE['employee_id'], 'ff_status' => 1, 'createdby' => $loginUserId, 'createdby_role' => $loginuserRole, 'createdby_group' => $loginuserGroup, 'createddate' => gmdate("Y-m-d H:i:s")); $ffEmpRatingsModel->SaveorUpdateFFEmpRatingsData($data, $where); } } if (sizeof($appEmpIDs) > 0 && $enable_to == 1) { $appEmpIDsCsv = implode(',', $appEmpIDs); $allEmpsData = $feedforwardInitModel->getEmpsFromSummary($appEmpIDsCsv); if (sizeof($allEmpsData) > 0) { foreach ($allEmpsData as $allE) { $where1 = ''; $data1 = array('ff_initialization_id' => $tableid, 'question_ids' => $check != '' ? implode(',', $check) : NULL, 'manager_id' => $allE['reporting_manager'], 'employee_id' => $allE['user_id'], 'ff_status' => 1, 'createdby' => $loginUserId, 'createdby_role' => $loginuserRole, 'createdby_group' => $loginuserGroup, 'createddate' => gmdate("Y-m-d H:i:s")); $ffEmpRatingsModel->SaveorUpdateFFEmpRatingsData($data1, $where1); } } } $actionflag = 1; $tableid = ''; $menuID = INITIALIZE_FEEDFORWARD; $result = sapp_Global::logManager($menuID, $actionflag, $loginUserId, $tableid); /** Start * Sending Mails to Super Admin,Management,HR */ $appraisalratingsmodel = new Default_Model_Appraisalratings(); $appraisalconfigmodel = new Default_Model_Appraisalconfig(); //to get initialization details using appraisal Id for Business Unit,Department,To Year $appraisal_details = $appraisalratingsmodel->getappdata($appInitId); if (!empty($appraisal_details)) { $businessUnit = $appraisal_details['businessunit_id']; $department = $appraisal_details['deptid']; $bunit = $appraisal_details['unitname']; $dept = $appraisal_details['deptname']; $to_year = $appraisal_details['to_year']; $employeeDetailsArr = $appraisalconfigmodel->getUserDetailsByID($businessUnit, $department); if ($enable_to == 1) { $empforFF = $feedforwardInitModel->getEmpIdforFF($businessUnit, $department); } else { $empforFF = $feedforwardInitModel->getAppemployeeIDs($appInitId); } $ffEmpArr = array(); $ffEmpList = ''; if (!empty($empforFF)) { foreach ($empforFF as $emp) { array_push($ffEmpArr, $emp['employeeId']); } $ffEmpList = implode(',', $ffEmpArr); } $ffEmpEmailArr = array(); $ffemployeeDetailsArr = $feedforwardInitModel->getUserDetailsByIds($ffEmpList); if (!empty($ffemployeeDetailsArr)) { foreach ($ffemployeeDetailsArr as $empFF) { array_push($ffEmpEmailArr, $empFF['emailaddress']); } } $dept_str = $dept == '' ? " " : "and department <b>{$dept}</b> "; $emp_id_str = $loginuserRole == SUPERADMINROLE ? " " : "({$loginUserEmpId})"; //Preparing Employee array for Bcc $empArr = array(); $total_emp_arr = array(); if (!empty($employeeDetailsArr)) { $empArrList = ''; foreach ($employeeDetailsArr as $emp) { array_push($empArr, $emp['emailaddress']); } } $total_emp_arr = array_merge($empArr, $ffEmpEmailArr); //Sending mail to Super admin,HR,Management $options['subject'] = APPLICATION_NAME . ': Feedforward Initialization'; $options['header'] = 'Feedforward Initialization : ' . $to_year; $options['toEmail'] = SUPERADMIN_EMAIL; $options['toName'] = 'Super Admin'; $options['bcc'] = $total_emp_arr; $options['message'] = "<div style='padding: 0; text-align: left; font-size:14px; font-family:Arial, Helvetica, sans-serif;'>\t\t\t\t\n\t\t\t\t\t\t\t\t\t\t<span style='color:#3b3b3b;'>Hi,</span><br />\n\t\t\t\t\t\t\t\t\t\t<div style='padding:20px 0 0 0;color:#3b3b3b;'>Feedforward process have been initialized for the year <b>{$to_year}</b> for business unit <b>{$bunit}</b> {$dept_str} by " . $loginUserfullname . $emp_id_str . ". </div>\n\t\t\t\t\t\t\t\t\t\t<div style='padding:20px 0 10px 0;'>Please <a href=" . BASE_URL . " target='_blank' style='color:#b3512f;'>click here</a> to login to your <b>" . APPLICATION_NAME . "</b> account and check the details.</div>\n\t\t\t\t\t\t\t\t\t\t</div> "; //'Dear Super Admin, performance appraisal Initialized '.$mail_str; $mail_id = sapp_Global::_sendEmail($options); } } }
/** * This function is used to send mail when we delete any configurations. * @param String $config_menu_name = name of configuration screen (Ex: Positions) * @param String $config_name = name of configuration (Ex: "Developer one") */ public static function send_configuration_mail($config_menu_name, $config_name) { $auth = Zend_Auth::getInstance(); if ($auth->hasIdentity()) { $sess_values = $auth->getStorage()->read(); } $users_model = new Default_Model_Usermanagement(); $emp_arr = $users_model->getEmpForConfigMail(); foreach ($emp_arr as $empdata) { $text = "<div style='padding: 0; text-align: left; font-size:14px; font-family:Arial, Helvetica, sans-serif;'>\n <span style='color:#3b3b3b;'>Dear " . ucfirst($empdata['userfullname']) . ",</span><br />\n\n <div style='padding:20px 0 0 0;color:#3b3b3b;'><b>" . ucfirst($config_name) . "</b> " . $config_menu_name . " in configurations has been deleted by " . $sess_values->userfullname . ". </div> \n <div style='padding:20px 0 10px 0;'>Please <a href='" . BASE_URL . "index/popup' target='_blank' style='color:#b3512f;'>click here</a> to login and check the details.</div>\t\t\n\n </div> "; $options['subject'] = APPLICATION_NAME . ': ' . ucfirst($config_menu_name) . ' is deleted'; $options['header'] = ucfirst($config_menu_name) . ' is deleted'; $options['toEmail'] = $empdata['emailaddress']; $options['toName'] = $empdata['userfullname']; $options['message'] = $text; $options['cron'] = 'yes'; sapp_Global::_sendEmail($options); } }
public static function saveCronMail($optionArr) { $options['subject'] = APPLICATION_NAME . ':' . $optionArr['subject']; $options['header'] = $optionArr['header']; $options['toEmail'] = $optionArr['toname']; $options['toName'] = $optionArr['toemail']; $options['bcc'] = $optionArr['bcc']; $options['message'] = $optionArr['message']; $options['cron'] = $optionArr['cron']; sapp_Global::_sendEmail($options); }
/** * @name deletepocAction * * This action is used to delete a point of contact of an agency. * @author Asma * @version 1.0 */ public function deletepocAction() { try { $pocsmodel = new Default_Model_Bgpocdetails(); $agencylistmodel = new Default_Model_Agencylist(); $auth = Zend_Auth::getInstance(); if ($auth->hasIdentity()) { $loginUserId = $auth->getStorage()->read()->id; } $poc_name = ''; $agencyid = $this->_request->getParam('agencyid'); $pocid = $this->_request->getParam('pocid'); $pocdata = $pocsmodel->getSingleagencyPOCData($pocid); if (!empty($pocdata[0])) { $poc_name = $pocdata[0]['first_name'] . ' ' . $pocdata[0]['last_name']; } $messages['message'] = ''; $messages['msgtype'] = ''; $actionflag = 3; if (isset($pocdata[0]['contact_type']) && $pocdata[0]['contact_type'] == '2') { if ($pocid && $agencyid) { $data = array('isactive' => 0, 'modifiedby' => $loginUserId, 'modifieddate' => gmdate("Y-m-d H:i:s")); $where = array('id=?' => $pocid, 'bg_agencyid=?' => $agencyid); $result = $pocsmodel->SaveorUpdatePOCDetails($data, $where); $result_2 = $pocsmodel->deleteBGcheckdetails($agencyid, $pocid, $loginUserId); // Mail to Secondary contact $options['subject'] = APPLICATION_NAME . ' :: POC is deleted'; $options['header'] = 'POC deleted'; $options['toEmail'] = trim($pocdata[0]['email']); $options['toName'] = $pocdata[0]['userfullname']; $salutation = 'Dear ' . $pocdata[0]['first_name'] . ','; $custom_base_url = 'http://' . $this->getRequest()->getHttpHost() . $this->getRequest()->getBaseUrl(); $options['message'] = '<div> <div>' . $salutation . ' </div> <div></div> <div>You are deleted as a secondary point of contact from ' . $pocdata[0]['agencyname'] . ' agency.</div> <div> <table border="1" style="border-collapse:collapse;"> <tr><td>Name : </td><td>' . $poc_name . '</td></tr> <tr><td>Contact Number : </td><td>' . $pocdata[0]['contact_no'] . '</td></tr> <tr><td>Email : </td><td>' . $pocdata[0]['email'] . '</td></tr> </table> </div> <div></div> </div>'; $options['cron'] = 'Yes'; if ($options['toEmail'] != '') { $result_email = sapp_Global::_sendEmail($options); } // Mail to Primary contact $primary_poc = $pocsmodel->getPrimaryPOCData($agencyid); $primary_poc_name = $primary_poc[0]['first_name'] . ' ' . $primary_poc[0]['last_name']; $options['subject'] = APPLICATION_NAME . ' :: POC is deleted'; $options['header'] = 'POC deleted'; $options['toEmail'] = trim($primary_poc[0]['email']); $options['toName'] = $primary_poc_name; $salutation = 'Dear ' . $primary_poc[0]['first_name'] . ','; $options['message'] = '<div> <div>' . $salutation . ' </div> <div></div> <div>Secondary point of contact has been deleted from ' . $pocdata[0]['agencyname'] . ' agency. Please find the details below:</div> <div> <table border="1" style="border-collapse:collapse;"> <tr><td>Name : </td><td>' . $poc_name . '</td></tr> <tr><td>Contact Number : </td><td>' . $pocdata[0]['contact_no'] . '</td></tr> <tr><td>Email : </td><td>' . $pocdata[0]['email'] . '</td></tr> </table> </div> <div></div> <div style="padding:20px 0 10px 0;">Please <a href="' . $custom_base_url . '/index/popup" target="_blank" style="color:#b3512f;">click here</a> to login and check the agency details.</div> </div>'; $options['cron'] = 'Yes'; if ($options['toEmail'] != '') { $result_email = sapp_Global::_sendEmail($options); } // Mail to HR and Management $emailids = $agencylistmodel->getAllHRManagementEMails(); foreach ($emailids as $email) { $options['subject'] = APPLICATION_NAME . ' :: POC is deleted'; $options['header'] = 'POC deleted'; $options['toEmail'] = trim($email['groupEmail']); $options['toName'] = $email['group_name']; if ($email['group_id'] == 4) { $salutation = 'Dear HR,'; } else { $salutation = 'Dear Management,'; } $options['message'] = '<div> <div>' . $salutation . '</div> <div></div> <div>Secondary point of contact has been deleted from ' . $pocdata[0]['agencyname'] . ' agency. Please find the details below:</div> <div> <table cellpadding="0" cellspacing="0" border="1"> <tr><td>Name :</td><td>' . $poc_name . '</td></tr> <tr><td>Contact Number : </td><td>' . $pocdata[0]['contact_no'] . '</td></tr> <tr><td>Email : </td><td>' . $pocdata[0]['email'] . '</td></tr> </table> </div> <div></div> <div style="padding:20px 0 10px 0;">Please <a href="' . $custom_base_url . '/index/popup" target="_blank" style="color:#b3512f;">click here</a> to login and check the agency details.</div> </div>'; $options['cron'] = 'Yes'; if ($options['toEmail'] != '') { $result_email = sapp_Global::_sendEmail($options); } } if ($result) { $menuID = AGENCYLIST; $result = sapp_Global::logManager($menuID, $actionflag, $loginUserId, $agencyid, $pocid); $messages['message'] = 'Point Of Contact details deleted successfully.'; $messages['msgtype'] = 'success'; } else { $messages['message'] = 'POC cannot be deleted.'; $messages['msgtype'] = 'error'; } } else { $messages['message'] = 'POC cannot be deleted.'; $messages['msgtype'] = 'error'; } } else { $messages['message'] = 'Primary point of contact cannot be deleted.'; $messages['msgtype'] = 'error'; } $this->_helper->json($messages); } catch (Exception $e) { exit($e->getMessage()); } }
public function deleteAction() { $auth = Zend_Auth::getInstance(); if ($auth->hasIdentity()) { $loginUserId = $auth->getStorage()->read()->id; $loginUserEmail = $auth->getStorage()->read()->emailaddress; $loginUserName = $auth->getStorage()->read()->userfullname; } $id = $this->_request->getParam('objid'); $messages['message'] = ''; $actionflag = 5; $businessunitid = ''; $leavetypetext = ''; if ($id) { $leaverequestmodel = new Default_Model_Leaverequest(); $usersmodel = new Default_Model_Users(); $employeesmodel = new Default_Model_Employees(); $employeeleavetypesmodel = new Default_Model_Employeeleavetypes(); $loggedInEmployeeDetails = $employeesmodel->getLoggedInEmployeeDetails($loginUserId); if ($loggedInEmployeeDetails[0]['businessunit_id'] != '') { $businessunitid = $loggedInEmployeeDetails[0]['businessunit_id']; } $dataarr = array('leavestatus' => 4, 'modifieddate' => gmdate("Y-m-d H:i:s"), 'modifiedby' => $loginUserId); $where = array('id=?' => $id); $Id = $leaverequestmodel->SaveorUpdateLeaveRequest($dataarr, $where); $data = $leaverequestmodel->getsinglePendingLeavesData($id); $data = $data[0]; $appliedleavesdaycount = $data['appliedleavescount']; $to_date = $data['to_date']; $from_date = $data['from_date']; $reason = $data['reason']; $leavetypeid = $data['leavetypeid']; $repmngrnameArr = $usersmodel->getUserDetailsByID($data['rep_mang_id']); $reportingmanageremail = $repmngrnameArr[0]['emailaddress']; $reportingmanagername = $repmngrnameArr[0]['userfullname']; if ($Id == 'update') { $menuID = PENDINGLEAVES; $result = sapp_Global::logManager($menuID, $actionflag, $loginUserId, $id); /** MAILING CODE **/ if ($to_date == '' || $to_date == NULL) { $to_date = $from_date; } /* Mail to Employee */ $options['subject'] = 'Leave request cancelled'; $options['header'] = 'Leave Request'; $options['toEmail'] = $loginUserEmail; $options['toName'] = $loginUserName; $options['message'] = '<div>Hi,</div> <div>The below leave(s) has been cancelled.</div> <div> <table width="100%" cellspacing="0" cellpadding="15" border="0" style="border:3px solid #BBBBBB; font-size:16px; font-family:Arial, Helvetica, sans-serif; margin:30px 0 30px 0;" bgcolor="#ffffff"> <tbody><tr> <td width="28%" style="border-right:2px solid #BBBBBB;">Employee Name</td> <td width="72%">' . $loginUserName . '</td> </tr> <tr bgcolor="#e9f6fc"> <td style="border-right:2px solid #BBBBBB;">No. of Day(s)</td> <td>' . $appliedleavesdaycount . '</td> </tr> <tr> <td style="border-right:2px solid #BBBBBB;">From</td> <td>' . $from_date . '</td> </tr> <tr bgcolor="#e9f6fc"> <td style="border-right:2px solid #BBBBBB;">To</td> <td>' . $to_date . '</td> </tr> <tr bgcolor="#e9f6fc"> <td style="border-right:2px solid #BBBBBB;">Reason for Leave</td> <td>' . $reason . '</td> </tr> </tbody></table> </div> <div style="padding:20px 0 10px 0;">Please <a href="' . BASE_URL . '/index/popup" target="_blank" style="color:#b3512f;">click here</a> to login and check the leave details.</div>'; $result = sapp_Global::_sendEmail($options); /* End */ /* Mail to Reporting Manager */ $options['subject'] = 'Leave request cancelled'; $options['header'] = 'Leave Request'; $options['toEmail'] = $reportingmanageremail; $options['toName'] = $reportingmanagername; $options['message'] = '<div>Hi,</div> <div>The below leave(s) has been cancelled.</div> <div> <table width="100%" cellspacing="0" cellpadding="15" border="0" style="border:3px solid #BBBBBB; font-size:16px; font-family:Arial, Helvetica, sans-serif; margin:30px 0 30px 0;" bgcolor="#ffffff"> <tbody><tr> <td width="28%" style="border-right:2px solid #BBBBBB;">Employee Name</td> <td width="72%">' . $loginUserName . '</td> </tr> <tr bgcolor="#e9f6fc"> <td style="border-right:2px solid #BBBBBB;">No. of Day(s)</td> <td>' . $appliedleavesdaycount . '</td> </tr> <tr> <td style="border-right:2px solid #BBBBBB;">From</td> <td>' . $from_date . '</td> </tr> <tr bgcolor="#e9f6fc"> <td style="border-right:2px solid #BBBBBB;">To</td> <td>' . $to_date . '</td> </tr> <tr bgcolor="#e9f6fc"> <td style="border-right:2px solid #BBBBBB;">Reason for Leave</td> <td>' . $reason . '</td> </tr> </tbody></table> </div> <div style="padding:20px 0 10px 0;">Please <a href="' . BASE_URL . '/index/popup" target="_blank" style="color:#b3512f;">click here</a> to login and check the leave details.</div>'; $result = sapp_Global::_sendEmail($options); /* End */ /* Mail to HR */ if (defined('LV_HR_' . $businessunitid) && $businessunitid != '') { $options['subject'] = 'Leave request cancelled'; $options['header'] = 'Leave Request'; $options['toEmail'] = constant('LV_HR_' . $businessunitid); $options['toName'] = 'Leave management'; $options['message'] = '<div>Hi,</div> <div>The below leave(s) has been cancelled by the Employee.</div> <div> <table width="100%" cellspacing="0" cellpadding="15" border="0" style="border:3px solid #BBBBBB; font-size:16px; font-family:Arial, Helvetica, sans-serif; margin:30px 0 30px 0;" bgcolor="#ffffff"> <tbody><tr> <td width="28%" style="border-right:2px solid #BBBBBB;">Employee Name</td> <td width="72%">' . $loginUserName . '</td> </tr> <tr bgcolor="#e9f6fc"> <td style="border-right:2px solid #BBBBBB;">No. of Day(s)</td> <td>' . $appliedleavesdaycount . '</td> </tr> <tr> <td style="border-right:2px solid #BBBBBB;">From</td> <td>' . $from_date . '</td> </tr> <tr bgcolor="#e9f6fc"> <td style="border-right:2px solid #BBBBBB;">To</td> <td>' . $to_date . '</td> </tr> <tr bgcolor="#e9f6fc"> <td style="border-right:2px solid #BBBBBB;">Reason for Leave</td> <td>' . $reason . '</td> </tr> </tbody></table> </div> <div style="padding:20px 0 10px 0;">Please <a href="' . BASE_URL . '/index/popup" target="_blank" style="color:#b3512f;">click here</a> to login and check the leave details.</div>'; $options['cron'] = 'yes'; $result = sapp_Global::_sendEmail($options); } $messages['message'] = 'Leave request cancelled'; $messages['msgtype'] = 'success'; } else { $messages['message'] = 'Leave request cannot be cancelled'; $messages['msgtype'] = 'error'; } } else { $messages['message'] = 'Leave request cannot be cancelled'; $messages['msgtype'] = 'error'; } $this->_helper->json($messages); }
public function save($processesform, $processdata) { $baseUrl = DOMAIN; $baseUrl = rtrim($baseUrl, '/'); $auth = Zend_Auth::getInstance(); if ($auth->hasIdentity()) { $loginUserId = $auth->getStorage()->read()->id; $loginuserRole = $auth->getStorage()->read()->emprole; } $usermodel = new Default_Model_Users(); $hrem = 'true'; $mngmntem = 'true'; $agencyEmail = ''; $lmanager1Email = ''; $lmanager1Name = 'Manager'; $agencysalutationName = 'Agency'; $id = $this->getRequest()->getParam('id'); $idData = $this->getRequest()->getParam('unitId'); $idArr = array(); $idArr = explode('-', $idData); $specimen_id = $idArr[0]; $userflag = $idArr[1]; $msgarray = array(); if ($idArr[1] == 2) { $flag = 'cand'; $person = 'candidate'; } else { $flag = 'emp'; $person = 'employee'; } $processesmodel = new Default_Model_Processes(); $empscreeningModel = new Default_Model_Empscreening(); $statusFlag = ''; $close = ''; $controllername = 'processes'; $errorflag = 'true'; $BGStatus = ''; $oldbgstatus = ''; $mailsentflag = 0; if (!empty($processdata)) { $newStatus = $this->getRequest()->getParam('process_status'); $previousstatus = $processdata[0]['process_status']; $agencyid = $processdata[0]['agencyid']; $checktype = $processdata[0]['checktypeid']; $processStatus = $processesmodel->getProcessStatus($specimen_id, $userflag, $agencyid, $checktype); if (!empty($processStatus) && sizeof($processStatus) > 0) { $oldstatus = $processStatus[0]['process_status']; $BGStatus = $processStatus[0]['bgcheck_status']; /* Check - Adding a record with same userid, agencyid and check type */ $exists = 'false'; for ($i = 0; $i < sizeof($processStatus); $i++) { if (($processStatus[$i]['process_status'] == 'On hold' || $processStatus[$i]['process_status'] == 'In process') && $processStatus[$i]['process_status'] == $newStatus) { $exists = 'true'; } } if ($newStatus == $previousstatus) { $msgarray['StatusError'] = "Please change the status."; $errorflag = "false"; } else { if ($BGStatus != 'Complete' && $exists == 'true') { $msgarray['StatusError'] = "The " . $person . " is already assigned to the selected agency. Please re-assign the " . $person . " to another agency."; $errorflag = "false"; } } /* END */ } } else { $checktype = $this->_request->getParam('checktype'); $radio_pocId = $this->_request->getParam('contactRadio'); $agencyid = $this->_request->getParam('agencyids'); $newStatus = 'In process'; $agencyData = array(); $agencyPOCData = array(); if (empty($checktype) && $checktype == '') { $msgarray['checktype'] = "Please check atleast one screening type"; $errorflag = "false"; } else { if (empty($radio_pocId) || $radio_pocId == '') { $msgarray['contactRadio'] = "Please select point of contact"; $errorflag = "false"; } } if ($checktype) { $agencyArr = array(); $agencyArr = $checktype; $agencyData = $empscreeningModel->getAgencyData($agencyArr, '', ''); } if (!isset($agencyid) || $agencyid == '') { $agencyid = $this->getRequest()->getParam('defaultagencyid'); } if (!isset($agencyid) || $agencyid == '') { $msgarray['agencyids'] = "Please select agency."; $errorflag = "false"; } if ($agencyid) { $agencyPOCData = $empscreeningModel->getAgencyPOCData($agencyid); } $this->view->agencyData = $agencyData; $this->view->agencyPOCData = $agencyPOCData; /* Checking for configurations - screening type and agencies */ $checktypeModal = new Default_Model_Bgscreeningtype(); $agencymodel = new Default_Model_Agencylist(); $typesData = $checktypeModal->fetchAll('isactive=1', 'type')->toArray(); $agencyData = $agencymodel->fetchAll('isactive=1', 'agencyname')->toArray(); for ($i = 0; $i < sizeof($agencyPOCData); $i++) { if ($agencyPOCData[$i]['id'] == $radio_pocId) { $agencyEmail = $agencyPOCData[$i]['email']; $agencyfname = $agencyPOCData[$i]['first_name']; $agencylname = $agencyPOCData[$i]['last_name']; $agencysalutationName = $agencyfname . ' ' . $agencylname; } } if (empty($typesData)) { $msgarray['checktype'] = 'Screening types are not configured yet.'; $errorflag = 'false'; } if (empty($agencyData)) { $msgarray['agencyids'] = 'Agencies are not added yet.'; $errorflag = 'false'; } $this->view->msgarray = $msgarray; /* */ /* Check - Adding a record with same userid, agencyid and check type (for each check type ) */ if (is_array($checktype) && $errorflag != "false") { for ($i = 0; $i < sizeof($checktype); $i++) { $processStatus = array(); $processStatus = $processesmodel->getProcessStatus($specimen_id, $userflag, $agencyid, $checktype[$i]); if (!empty($processStatus) && sizeof($processStatus > 0)) { $exists = 'false'; for ($i = 0; $i < sizeof($processStatus); $i++) { if ($processStatus[$i]['process_status'] == 'On hold' || $processStatus[$i]['process_status'] == 'In process') { $exists = 'true'; } } $oldstatus = $processStatus[0]['process_status']; $BGStatus = $processStatus[0]['bgcheck_status']; if ($exists == 'true' && $BGStatus != 'Complete') { $msgarray['StatusError'] = "The " . $person . " is already assigned to the selected agency. Please re-assign the " . $person . " to another agency."; $errorflag = "false"; } } $oldbgstatusData = $processesmodel->getProcessStatus($specimen_id, $userflag, '', ''); if (!empty($oldbgstatusData)) { $oldbgstatus = $oldbgstatusData[0]['bgcheck_status']; } else { $oldbgstatus = ''; } } } /* END */ } if ($processesform->isValid($this->_request->getPost()) && $errorflag != 'false') { $date = new Zend_Date(); $menumodel = new Default_Model_Menu(); $actionflag = ''; $tableid = ''; /* A New process is created for a user whose background check status is in 'Complete' status. Then updating the bg status to 'In process' */ if (($BGStatus == 'Complete' || $oldbgstatus == 'Complete' || $BGStatus == 'On hold' || $oldbgstatus == 'On hold') && $newStatus == 'In process') { $totalstatusData = array('bgcheck_status' => 'In process', 'modifiedby' => $loginUserId, 'modifieddate' => gmdate("Y-m-d H:i:s")); $totalstatusWhere = array('specimen_id=?' => $specimen_id, 'flag=?' => $userflag); $empscreeningModel->SaveorUpdateDetails($totalstatusData, $totalstatusWhere); /* Updating back ground check status to In process in employees/candidates status */ if ($userflag == 1) { $empData = array('backgroundchk_status' => 'In process', 'modifiedby' => $loginUserId, 'modifieddate' => gmdate("Y-m-d H:i:s")); $empWhere = array('id=?' => $specimen_id); $usermodel->addOrUpdateUserModel($empData, $empWhere); } else { $candModel = new Default_Model_Candidatedetails(); $candData = array('backgroundchk_status' => 'In process', 'modifiedby' => $loginUserId, 'modifieddate' => gmdate("Y-m-d H:i:s")); $candWhere = array('id=?' => $specimen_id); $candModel->SaveorUpdateUserData($candData, $candWhere); } /* END */ /* Mail to HRD, Line 1 and Line 2 managers that the background checks has been re-opened */ if ($BGStatus != 'On hold' && $oldbgstatus != 'On hold') { $empData = $empscreeningModel->getEmpPersonalData($specimen_id, $userflag); if ($userflag == 1) { $username = $empData[0]['name']; $lmanager1Email = $empData[0]['rmanager_email']; $lmanager1Name = $empData[0]['reporting_manager']; } else { $username = $empData[0]['candidate_name']; $lmanager1Email = ''; } $bid = ''; if (isset($empData[0]['businessid'])) { $bid = $empData[0]['businessid']; } if (isset($lmanager1Email) && $lmanager1Email != '') { $manager1 = array($lmanager1Email); } else { $manager1 = array(); } if (isset($agencyEmail) && $agencyEmail != '') { $agencyemail1 = array($agencyEmail); } else { $agencyemail1 = array(); } if (defined('BG_CHECKS_MNGMNT_' . $bid) && $bid != '') { $mngmntemailId = explode(",", constant('BG_CHECKS_MNGMNT_' . $bid)); } else { $mngmntem = 'false'; $mngmntemailId = array(); } if (defined('BG_CHECKS_HR_' . $bid) && $bid != '') { $hremailId = explode(",", constant('BG_CHECKS_HR_' . $bid)); } else { $hrem = 'false'; $hremailId = array(); } $emailArr = array_merge($agencyemail1, $manager1, $mngmntemailId, $hremailId); for ($i = 0; $i < sizeof($emailArr); $i++) { $salutation = 'Dear Sir/Madam,'; if ($i == 0) { $salutation = 'Dear ' . ucfirst($agencysalutationName) . ','; $options['toName'] = ucfirst($agencysalutationName); } if ($i == 1) { $salutation = 'Dear ' . ucfirst($lmanager1Name) . ','; $options['toName'] = ucfirst($lmanager1Name); } if ($i == 2) { $salutation = 'Dear Management,'; $options['toName'] = 'Management'; } if ($i == 3) { $salutation = 'Dear HR,'; $options['toName'] = 'HR'; } $options['subject'] = APPLICATION_NAME . ' : Background checks re-opened'; $options['header'] = 'Background checks re-opened'; $options['toEmail'] = $emailArr[$i]; $createdbyName = $usermodel->getUserDetails($loginUserId); if ($i == 0) { $mailsentflag = 1; $options['message'] = '<div>' . $salutation . '<div>The background check for ' . ucfirst($username) . ' has been re-opened by ' . $createdbyName[0]['userfullname'] . '. </div> <div style="padding:20px 0 10px 0;">Please <a href="' . $baseUrl . '/index/popup" target="_blank" style="color:#b3512f;">click here</a> to login and check the details.</div> </div>'; } else { $options['message'] = '<div>' . $salutation . '<div>The background check for ' . ucfirst($username) . ' has been re-opened by ' . $createdbyName[0]['userfullname'] . '. </div> <div style="padding:20px 0 10px 0;">Please <a href="' . $baseUrl . '/index/popup" target="_blank" style="color:#b3512f;">click here</a> to login and check the details.</div> </div>'; } $options['cron'] = 'yes'; sapp_Global::_sendEmail($options); } } /* END */ } /* END */ $data = array('specimen_id' => $specimen_id, 'flag' => $userflag, 'bgagency_id' => $agencyid, 'modifiedby' => $loginUserId, 'modifieddate' => gmdate("Y-m-d H:i:s")); if ($id != '') { $data['process_status'] = $newStatus; $data['explanation'] = NULL; $where = array('id=?' => $id); $actionflag = 2; } else { $data['process_status'] = $newStatus; $data['bgagency_pocid'] = $radio_pocId; $data['createdby'] = $loginUserId; $data['createddate'] = gmdate("Y-m-d H:i:s"); $data['isactive'] = 1; $where = ''; $actionflag = 1; if ($newStatus == 'In process' && ($BGStatus != 'Complete' || $oldbgstatus != 'Complete' || $BGStatus != 'On hold' || $oldbgstatus != 'On hold') && $mailsentflag == 0) { $empData = $empscreeningModel->getEmpPersonalData($specimen_id, $userflag); $table = ''; if ($userflag == 1) { $username = $empData[0]['name']; $lmanager1Email = $empData[0]['rmanager_email']; $lmanager1Name = $empData[0]['reporting_manager']; $table = '<div> <table border="1" style="border-collapse:collapse;"> <tr><td>Employee ID</td><td>' . $empData[0]['employee_id'] . '</td></tr> <tr><td>Employee Email</td><td>' . $empData[0]['email_id'] . '</td></tr> <tr><td>Employee Designation</td><td>' . $empData[0]['designation'] . '</td></tr> </table> </div>'; } else { $username = $empData[0]['candidate_name']; $lmanager1Email = ''; $table = '<div>Candidate Email : ' . $empData[0]['email'] . '</div>'; } if ($agencysalutationName != '') { $salutation = 'Dear ' . ucfirst($agencysalutationName) . ','; $options['toName'] = ucfirst($agencysalutationName); } else { $salutation = 'Dear Sir/Madam,'; $options['toName'] = 'Agency'; } $createdbyName = $usermodel->getUserDetails($loginUserId); $options['subject'] = APPLICATION_NAME . ' : Background checks initiated'; $options['header'] = 'Background checks initiated'; $options['toEmail'] = $agencyEmail; $options['message'] = '<div>' . $salutation . '<div>' . ucfirst($username) . ' has been sent for background checks by ' . ucfirst($createdbyName[0]['userfullname']) . '. Please find the details below.</div>' . $table . ' <div style="padding:20px 0 10px 0;">Please <a href="' . $baseUrl . '/index/popup" target="_blank" style="color:#b3512f;">click here</a> to login and check the details.</div> </div>'; $options['cron'] = 'yes'; sapp_Global::_sendEmail($options); } } if (is_array($checktype)) { for ($i = 0; $i < sizeof($checktype); $i++) { $data['bgcheck_type'] = $checktype[$i]; $detailId = $empscreeningModel->SaveorUpdateDetails($data, $where); } } else { $data['bgcheck_type'] = $checktype; $detailId = $empscreeningModel->SaveorUpdateDetails($data, $where); } /* If all the processes are in 'Complete' status, then updating the background check status to 'Complete' and sending mail to HR, reporting manager */ $checkAllprocesses = $processesmodel->getProcessStatus($specimen_id, $userflag); $completecount = 0; $onholdcount = 0; for ($i = 0; $i < sizeof($checkAllprocesses); $i++) { if ($checkAllprocesses[$i]['process_status'] == 'Complete') { $completecount = $completecount + 1; } } if ($completecount == sizeof($checkAllprocesses)) { $totalstatusData = array('bgcheck_status' => 'Complete', 'modifiedby' => $loginUserId, 'modifieddate' => gmdate("Y-m-d H:i:s")); $totalstatusWhere = array('specimen_id=?' => $specimen_id, 'flag=?' => $userflag); $empscreeningModel->SaveorUpdateDetails($totalstatusData, $totalstatusWhere); /* Updating back ground check status to Completed in employees/candidates status */ if ($userflag == 1) { $usermodel = new Default_Model_Users(); $empData = array('backgroundchk_status' => 'Completed', 'modifiedby' => $loginUserId, 'modifieddate' => gmdate("Y-m-d H:i:s")); $empWhere = array('id=?' => $specimen_id); $usermodel->addOrUpdateUserModel($empData, $empWhere); } else { $candModel = new Default_Model_Candidatedetails(); $candData = array('backgroundchk_status' => 'Completed', 'modifiedby' => $loginUserId, 'modifieddate' => gmdate("Y-m-d H:i:s")); $candWhere = array('id=?' => $specimen_id); $candModel->SaveorUpdateUserData($candData, $candWhere); } /* END */ /* Mail to HRD, Line 1 and Line 2 managers */ if ($newStatus == 'Complete') { $empData = $empscreeningModel->getEmpPersonalData($specimen_id, $userflag); if ($userflag == 1) { $username = $empData[0]['name']; $lmanager1Email = $empData[0]['rmanager_email']; $lmanager1Name = $empData[0]['reporting_manager']; } else { $username = $empData[0]['name']; $lmanager1Email = ''; } $bid = ''; if (isset($empData[0]['businessid'])) { $bid = $empData[0]['businessid']; } if (isset($lmanager1Email) && $lmanager1Email != '') { $manager1 = array($lmanager1Email); } else { $manager1 = array(); } if (defined('BG_CHECKS_MNGMNT_' . $bid) && $bid != '') { $mngmntemailId = explode(",", constant('BG_CHECKS_MNGMNT_' . $bid)); } else { $mngmntemailId = array(); } if (defined('BG_CHECKS_HR_' . $bid) && $bid != '') { $hremailId = explode(",", constant('BG_CHECKS_HR_' . $bid)); } else { $hremailId = array(); } $emailArr = array_merge($manager1, $mngmntemailId, $hremailId); for ($i = 0; $i < sizeof($emailArr); $i++) { $salutation = 'Dear Sir/Madam,'; if ($i == 0) { $salutation = 'Dear ' . ucfirst($lmanager1Name) . ','; $options['toName'] = ucfirst($lmanager1Name); } else { if ($i == 1) { $salutation = 'Dear Management,'; $options['toName'] = 'Management'; } else { $salutation = 'Dear HR,'; $options['toName'] = 'HR'; } } $options['subject'] = APPLICATION_NAME . ' : Background checks completed'; $options['header'] = 'Background checks completed'; $options['toEmail'] = $emailArr[$i]; $options['message'] = '<div>' . $salutation . '<div>The background check for ' . ucfirst($username) . ' has been completed.</div> <div style="padding:20px 0 10px 0;">Please <a href="' . $baseUrl . '/index/popup" target="_blank" style="color:#b3512f;">click here</a> to login and check the details.</div> </div>'; $options['cron'] = 'yes'; sapp_Global::_sendEmail($options); } } /* END */ } /* End */ /* If all the processes are in 'On hold' status, then updating the background check status to 'On hold' */ for ($i = 0; $i < sizeof($checkAllprocesses); $i++) { if ($checkAllprocesses[$i]['process_status'] == 'On hold') { $onholdcount = $onholdcount + 1; } } if ($onholdcount == sizeof($checkAllprocesses)) { $totalstatusData = array('bgcheck_status' => 'On hold', 'modifiedby' => $loginUserId, 'modifieddate' => gmdate("Y-m-d H:i:s")); $totalstatusWhere = array('specimen_id=?' => $specimen_id, 'flag=?' => $userflag); $empscreeningModel->SaveorUpdateDetails($totalstatusData, $totalstatusWhere); /* Updating back ground check status to Completed in employees/candidates status */ if ($userflag == 1) { $usermodel = new Default_Model_Users(); $empData = array('backgroundchk_status' => 'On hold', 'modifiedby' => $loginUserId, 'modifieddate' => gmdate("Y-m-d H:i:s")); $empWhere = array('id=?' => $specimen_id); $usermodel->addOrUpdateUserModel($empData, $empWhere); } else { $candModel = new Default_Model_Candidatedetails(); $candData = array('backgroundchk_status' => 'On hold', 'modifiedby' => $loginUserId, 'modifieddate' => gmdate("Y-m-d H:i:s")); $candWhere = array('id=?' => $specimen_id); $candModel->SaveorUpdateUserData($candData, $candWhere); } /* END */ } /* END */ if ($detailId == 'update') { $tableid = $id; $this->view->eventact = 'updated'; } else { $tableid = $detailId; $this->view->eventact = 'added'; } $actionflag = 2; //Edit of the candidate or employee $menuidArr = $menumodel->getMenuObjID('/empscreening'); $menuID = $menuidArr[0]['id']; $result = sapp_Global::logManager($menuID, $actionflag, $loginUserId, $specimen_id . '-' . $userflag); $close = 'close'; $this->view->popup = $close; } else { $messages = $processesform->getMessages(); foreach ($messages as $key => $val) { foreach ($val as $key2 => $val2) { $msgarray[$key] = $val2; break; } if (empty($checktypesData)) { $msgarray['checktype'] = 'Screening types are not configured yet.'; } if (empty($checkagencyData)) { $msgarray['agencyids'] = 'Agencies are not added yet.'; } } return $msgarray; } $this->view->statusFlag = $statusFlag; }
public function addemppopupAction() { $flag = 'true'; $controllername = 'employee'; $msgarray = array(); $emptyFlag = 0; Zend_Layout::getMvcInstance()->setLayoutPath(APPLICATION_PATH . "/layouts/scripts/popup/"); $auth = Zend_Auth::getInstance(); if ($auth->hasIdentity()) { $loginUserId = $auth->getStorage()->read()->id; } $deptidforhead = $this->_getParam('deptidforhead', null); $report_opt = array(); $emp_form = new Default_Form_employee(); $user_model = new Default_Model_Usermanagement(); $role_model = new Default_Model_Roles(); $prefixModel = new Default_Model_Prefix(); $identity_code_model = new Default_Model_Identitycodes(); $jobtitlesModel = new Default_Model_Jobtitles(); $deptModel = new Default_Model_Departments(); $positionsmodel = new Default_Model_Positions(); $employeeModal = new Default_Model_Employee(); $usersModel2 = new Default_Model_Users(); $employmentstatusModel = new Default_Model_Employmentstatus(); $emp_form->setAction(BASE_URL . 'employee/addemppopup/deptidforhead/' . $deptidforhead); $emp_form->removeElement('department_id'); $emp_form->removeElement('modeofentry'); $identity_codes = $identity_code_model->getIdentitycodesRecord(); $emp_identity_code = isset($identity_codes[0]) ? $identity_codes[0]['employee_code'] : ""; if ($emp_identity_code != '') { $emp_id = $emp_identity_code . str_pad($user_model->getMaxEmpId($emp_identity_code), 4, '0', STR_PAD_LEFT); } else { $emp_id = ''; $msgarray['employeeId'] = 'Identity codes are not configured yet.'; $flag = 'false'; } $emp_form->employeeId->setValue($emp_id); $role_data = $role_model->getRolesList_Dept(); $emp_form->emprole->addMultiOptions(array('' => 'Select Role') + $role_data); if (empty($role_data)) { $msgarray['emprole'] = 'Roles are not configured yet.'; $flag = 'false'; } $prefixData = $prefixModel->getPrefixList(); $emp_form->prefix_id->addMultiOption('', 'Select Prefix'); if (!empty($prefixData)) { foreach ($prefixData as $prefixres) { $emp_form->prefix_id->addMultiOption($prefixres['id'], $prefixres['prefix']); } } else { $msgarray['prefix_id'] = 'Prefixes are not configured yet.'; //$flag = 'false'; } $jobtitleData = $jobtitlesModel->getJobTitleList(); if (!empty($jobtitleData)) { foreach ($jobtitleData as $jobtitleres) { $emp_form->jobtitle_id->addMultiOption($jobtitleres['id'], $jobtitleres['jobtitlename']); } } else { $msgarray['jobtitle_id'] = 'Job titles are not configured yet.'; $msgarray['position_id'] = 'Positions are not configured yet.'; //$flag = 'false'; } if (isset($_POST['jobtitle_id']) && $_POST['jobtitle_id'] != '') { $positionlistArr = $positionsmodel->getPositionList($_POST['jobtitle_id']); if (sizeof($positionlistArr) > 0) { $emp_form->position_id->addMultiOption('', 'Select Position'); foreach ($positionlistArr as $positionlistres) { $emp_form->position_id->addMultiOption($positionlistres['id'], $positionlistres['positionname']); } } } $employmentStatusData = $employmentstatusModel->getempstatusActivelist(); $emp_form->emp_status_id->addMultiOption('', 'Select Employment Status'); if (!empty($employmentStatusData)) { foreach ($employmentStatusData as $employmentStatusres) { $emp_form->emp_status_id->addMultiOption($employmentStatusres['workcodename'], $employmentStatusres['statusname']); } } else { $msgarray['emp_status_id'] = 'Employment status is not configured yet.'; $emptyFlag++; } $reportingManagerData = $usersModel2->getReportingManagerList_employees('', '', MANAGEMENT_GROUP); if (!empty($reportingManagerData)) { $report_opt = $reportingManagerData; if (isset($_POST['reporting_manager']) && $_POST['reporting_manager'] != '') { $emp_form->setDefault('reporting_manager', $_POST['reporting_manager']); } } else { $msgarray['reporting_manager'] = 'Reporting managers are not added yet.'; $flag = 'false'; } if ($this->getRequest()->getPost()) { if ($emp_form->isValid($this->_request->getPost()) && $flag == 'true') { $jobtitle_id = $this->_request->getParam('jobtitle_id', null); $position_id = $this->_request->getParam('position_id', null); $date_of_joining = sapp_Global::change_date($this->_request->getParam('date_of_joining', null), 'database'); $date_of_leaving = $this->_request->getParam('date_of_leaving', null); $date_of_leaving = sapp_Global::change_date($date_of_leaving, 'database'); $employeeId = $this->_getParam('employeeId', null); $emprole = $this->_getParam('emprole', null); $reporting_manager = $this->_getParam('reporting_manager', null); $emailaddress = $this->_getParam('emailaddress', null); $emppassword = sapp_Global::generatePassword(); $firstname = trim($this->_getParam('firstname', null)); $lastname = trim($this->_getParam('lastname', null)); $userfullname = $firstname . ' ' . $lastname; //$userfullname = trim($this->_request->getParam('userfullname',null)); $prefix_id = $this->_getParam('prefix_id', null); $user_id = $this->_getParam('user_id', null); $emp_status_id = $this->_getParam('emp_status_id', null); $user_data = array('emprole' => $emprole, 'firstname' => $firstname != '' ? $firstname : NULL, 'lastname' => $lastname != '' ? $lastname : NULL, 'userfullname' => $userfullname, 'emailaddress' => $emailaddress, 'jobtitle_id' => $jobtitle_id, 'modifiedby' => $loginUserId, 'modifieddate' => gmdate("Y-m-d H:i:s"), 'emppassword' => md5($emppassword), 'employeeId' => $employeeId, 'modeofentry' => 'Direct', 'selecteddate' => $date_of_joining, 'userstatus' => 'old'); $emp_data = array('user_id' => $user_id, 'jobtitle_id' => $jobtitle_id, 'position_id' => $position_id, 'prefix_id' => $prefix_id, 'department_id' => $deptidforhead, 'reporting_manager' => $reporting_manager, 'date_of_joining' => $date_of_joining, 'date_of_leaving' => $date_of_leaving != '' ? $date_of_leaving : NULL, 'emp_status_id' => $emp_status_id, 'modifiedby' => $loginUserId, 'modifieddate' => gmdate("Y-m-d H:i:s")); $user_data['createdby'] = $loginUserId; $user_data['createddate'] = gmdate("Y-m-d H:i:s"); $user_data['isactive'] = 1; if ($emp_identity_code != '') { $emp_id = $emp_identity_code . str_pad($user_model->getMaxEmpId($emp_identity_code), 4, '0', STR_PAD_LEFT); } else { $emp_id = ''; } $user_data['employeeId'] = $emp_id; $user_id = $user_model->SaveorUpdateUserData($user_data, ''); $emp_data['user_id'] = $user_id; $emp_data['createdby'] = $loginUserId; $emp_data['createddate'] = gmdate("Y-m-d H:i:s"); $emp_data['isactive'] = 1; $employeeModal->SaveorUpdateEmployeeData($emp_data, ''); //end of saving into employee table. $tableid = $user_id; $actionflag = 1; $menuID = ORGANISATIONINFO; try { $result = sapp_Global::logManager($menuID, $actionflag, $loginUserId, $tableid); } catch (Exception $e) { } $managementUsersData = $deptModel->getDeptHeads(); $opt = ''; foreach ($managementUsersData as $record) { $opt .= sapp_Global::selectOptionBuilder($record['id'], $record['userfullname']); } $this->view->managementUsersData = $opt; /* Send Mail to the user */ $base_url = 'http://' . $this->getRequest()->getHttpHost() . $this->getRequest()->getBaseUrl(); $view = $this->getHelper('ViewRenderer')->view; $this->view->emp_name = $userfullname; $this->view->password = $emppassword; $this->view->emp_id = $employeeId; $this->view->base_url = $base_url; $text = $view->render('mailtemplates/newpassword.phtml'); $options['subject'] = APPLICATION_NAME . ' login Credentials'; $options['header'] = 'Greetings from Sentrifugo'; $options['toEmail'] = $emailaddress; $options['toName'] = $this->view->emp_name; $options['message'] = $text; $result = sapp_Global::_sendEmail($options); /* END */ $this->view->eventact = 'added'; $close = 'close'; $this->view->popup = $close; } else { $messages = $emp_form->getMessages(); foreach ($messages as $key => $val) { foreach ($val as $key2 => $val2) { $msgarray[$key] = $val2; break; } } $this->view->msgarray = $msgarray; } } $this->view->msgarray = $msgarray; $this->view->report_opt = $report_opt; $this->view->controllername = $controllername; $this->view->emp_form = $emp_form; }
public function save($managerleaverequestform, $appliedleavescount, $employeeemail, $employeeid, $userfullname, $from_date, $to_date, $reason, $businessunitid, $leavetypeid) { $auth = Zend_Auth::getInstance(); if ($auth->hasIdentity()) { $loginUserId = $auth->getStorage()->read()->id; } if ($managerleaverequestform->isValid($this->_request->getPost())) { $id = $this->_request->getParam('id'); $managerstatus = $this->_request->getParam('managerstatus'); $comments = $this->_request->getParam('comments'); $date = new Zend_Date(); $leaverequestmodel = new Default_Model_Leaverequest(); $employeeleavetypesmodel = new Default_Model_Employeeleavetypes(); $actionflag = ''; $tableid = ''; $status = ''; $messagestr = ''; $leavetypetext = ''; $leavetypeArr = $employeeleavetypesmodel->getLeavetypeDataByID($leavetypeid); if ($managerstatus == 1 && !empty($leavetypeArr)) { if ($leavetypeArr[0]['leavepredeductable'] == 1) { $updateemployeeleave = $leaverequestmodel->updateemployeeleaves($appliedleavescount, $employeeid); } $status = 2; $messagestr = "Leave request approved."; $leavetypetext = $leavetypeArr[0]['leavetype']; } else { if ($managerstatus == 2) { $status = 3; $messagestr = "Leave request rejected."; } } if ($managerstatus == 1 || $managerstatus == 2) { $data = array('leavestatus' => $status, 'approver_comments' => $comments, 'modifiedby' => $loginUserId, 'modifieddate' => gmdate("Y-m-d H:i:s")); if ($id != '') { $where = array('id=?' => $id); $actionflag = 2; } else { $data['createdby'] = $loginUserId; $data['createddate'] = gmdate("Y-m-d H:i:s"); $data['isactive'] = 1; $where = ''; $actionflag = 1; } $Id = $leaverequestmodel->SaveorUpdateLeaveRequest($data, $where); if ($Id == 'update') { $tableid = $id; $this->_helper->getHelper("FlashMessenger")->addMessage($messagestr); } else { $tableid = $Id; $this->_helper->getHelper("FlashMessenger")->addMessage($messagestr); } /** MAILING CODE **/ if ($to_date == '' || $to_date == NULL) { $to_date = $from_date; } /* Mail to Employee */ $options['header'] = 'Leave Request'; $options['toEmail'] = $employeeemail; $options['toName'] = $userfullname; if ($messagestr == 'Leave request approved.') { $options['subject'] = 'Leave request approved'; $options['message'] = '<div>Hi,</div><div>The below leave(s) has been approved.</div>'; } else { $options['subject'] = 'Leave request rejected'; $options['message'] = '<div>Hi,</div><div>The below leave(s) has been rejected. </div>'; } $options['message'] .= '<div> <table width="100%" cellspacing="0" cellpadding="15" border="0" style="border:3px solid #BBBBBB; font-size:16px; font-family:Arial, Helvetica, sans-serif; margin:30px 0 30px 0;" bgcolor="#ffffff"> <tbody><tr> <td width="28%" style="border-right:2px solid #BBBBBB;">Employee Name</td> <td width="72%">' . $userfullname . '</td> </tr> <tr bgcolor="#e9f6fc"> <td style="border-right:2px solid #BBBBBB;">No. of Day(s)</td> <td>' . $appliedleavescount . '</td> </tr> <tr> <td style="border-right:2px solid #BBBBBB;">From</td> <td>' . $from_date . '</td> </tr> <tr bgcolor="#e9f6fc"> <td style="border-right:2px solid #BBBBBB;">To</td> <td>' . $to_date . '</td> </tr> <tr bgcolor="#e9f6fc"> <td style="border-right:2px solid #BBBBBB;">Reason for Leave</td> <td>' . $reason . '</td> </tr> </tbody></table> </div> <div style="padding:20px 0 10px 0;">Please <a href="' . BASE_URL . '/index/popup" target="_blank" style="color:#b3512f;">click here</a> to login and check the leave details.</div>'; $result = sapp_Global::_sendEmail($options); /* END */ /* Mail to HR */ if (defined('LV_HR_' . $businessunitid) && $businessunitid != '') { $options['header'] = 'Leave Request'; $options['toEmail'] = constant('LV_HR_' . $businessunitid); $options['toName'] = 'Leave Management'; if ($messagestr == 'Leave request approved.') { $options['subject'] = 'Leave request approved'; $options['message'] = '<div>Hi,</div><div>The below leave(s) has been approved.</div>'; } else { $options['subject'] = 'Leave request rejected '; $options['message'] = '<div>Hi,</div><div>The below leave(s) has been rejected.</div>'; } $options['message'] .= '<div> <table width="100%" cellspacing="0" cellpadding="15" border="0" style="border:3px solid #BBBBBB; font-size:16px; font-family:Arial, Helvetica, sans-serif; margin:30px 0 30px 0;" bgcolor="#ffffff"> <tbody> <tr> <td width="28%" style="border-right:2px solid #BBBBBB;">Employee Name</td> <td width="72%">' . $userfullname . '</td> </tr> <tr bgcolor="#e9f6fc"> <td style="border-right:2px solid #BBBBBB;">No. of Day(s)</td> <td>' . $appliedleavescount . '</td> </tr> <tr> <td style="border-right:2px solid #BBBBBB;">From</td> <td>' . $from_date . '</td> </tr> <tr bgcolor="#e9f6fc"> <td style="border-right:2px solid #BBBBBB;">To</td> <td>' . $to_date . '</td> </tr> <tr> <td style="border-right:2px solid #BBBBBB;">Leave Type</td> <td>' . ucfirst($leavetypetext) . '</td> </tr> <tr bgcolor="#e9f6fc"> <td style="border-right:2px solid #BBBBBB;">Reason for Leave</td> <td>' . $reason . '</td> </tr> </tbody> </table> </div> <div style="padding:20px 0 10px 0;">Please <a href="' . BASE_URL . '/index/popup" target="_blank" style="color:#b3512f;">click here</a> to login and check the leave details.</div>'; $result = sapp_Global::_sendEmail($options); } /* END */ } $menuID = MANAGEREMPLOYEEVACATIONS; $result = sapp_Global::logManager($menuID, $actionflag, $loginUserId, $tableid); $this->_redirect('manageremployeevacations'); } else { $messages = $managerleaverequestform->getMessages(); foreach ($messages as $key => $val) { foreach ($val as $key2 => $val2) { $msgarray[$key] = $val2; break; } } return $msgarray; } }
public function saveAction() { $auth = Zend_Auth::getInstance(); $loginuserFullName = ''; if ($auth->hasIdentity()) { $loginUserId = $auth->getStorage()->read()->id; $loginuserRole = $auth->getStorage()->read()->emprole; $loginuserGroup = $auth->getStorage()->read()->group_id; $loginuserProfileImg = $auth->getStorage()->read()->profileimg; $loginuserEmail = $auth->getStorage()->read()->emailaddress; $loginuserFullName = $auth->getStorage()->read()->userfullname; $loginUserEmpId = $auth->getStorage()->read()->employeeId; } try { $appEmpRatingsModel = new Default_Model_Appraisalemployeeratings(); $app_init_model = new Default_Model_Appraisalinit(); $id = $this->_request->getParam('id'); $employee_id = $this->_request->getParam('employee_id'); $initialization_id = $this->_request->getParam('initialization_id'); $config_id = $this->_request->getParam('config_id'); $flag = $this->_request->getParam('flag'); $app_status = $this->_request->getParam('app_status'); $mgr_levels = $this->_request->getParam('mgr_levels'); $ratingsData = $appEmpRatingsModel->getAppRatingsDataByConfgId($config_id, $initialization_id); $ratingValues = array(); foreach ($ratingsData as $rd) { $ratingValues[$rd['id']] = $rd['rating_value']; } $appData = array('modifiedby' => $loginUserId, 'modifiedby_role' => $loginuserRole, 'modifiedby_group' => $loginuserGroup, 'modifieddate' => gmdate("Y-m-d H:i:s")); $emp_rating_arr = $this->_request->getParam('emp_rating'); $emp_comment_arr = $this->_request->getParam('emp_comment'); $emp_response = array(); if (sizeof($emp_rating_arr) > 0 || sizeof($emp_comment_arr) > 0) { foreach ($emp_rating_arr as $qid => $val) { if (isset($emp_rating_arr[$qid])) { $rating_id = array_search($emp_rating_arr[$qid], $ratingValues); } else { $rating_id = ''; } $emp_response[$qid] = array('comment' => $emp_comment_arr[$qid], 'rating_id' => $rating_id); } } $appData['employee_response'] = json_encode($emp_response, true); $curent_level = array_search($app_status, $this->app_status_array); if ($flag == 'submit') { $appData['appraisal_status'] = $curent_level + 1; $history_desc = $this->app_history_disc_array[$curent_level]; $appHistoryData = array('employee_id' => $employee_id, 'pa_initialization_id' => $initialization_id, 'description' => $history_desc, 'desc_emp_id' => $loginUserId, 'desc_emp_name' => $loginuserFullName, 'desc_emp_profileimg' => $loginuserProfileImg, 'createdby' => $loginUserId, 'createddate' => gmdate("Y-m-d H:i:s"), 'modifiedby' => $loginUserId, 'modifieddate' => gmdate("Y-m-d H:i:s")); $appHistoryModel = new Default_Model_Appraisalhistory(); $result2 = $appHistoryModel->SaveorUpdateAppraisalHistoryData($appHistoryData); /* Update employee response column */ $appraisaldata = $app_init_model->getConfigData($initialization_id); if ($appraisaldata[0]['employee_response'] == 1) { $initdata = array('employee_response' => 2, 'modifiedby' => $loginUserId, 'modifiedby_role' => $loginuserRole, 'modifiedby_group' => $loginuserGroup, 'modifieddate' => gmdate("Y-m-d H:i:s")); $initwhere = array('id=?' => $initialization_id); $app_init_model->SaveorUpdateAppraisalInitData($initdata, $initwhere); } /* * Logs Storing */ $menumodel = new Default_Model_Menu(); $actionflag = ''; $tableid = ''; $actionflag = 1; $menuidArr = $menumodel->getMenuObjID('/appraisalself'); $menuID = $menuidArr[0]['id']; sapp_Global::logManager($menuID, $actionflag, $loginUserId, $tableid); /* * Logs storing ends */ /** Start * Sending Mails to employees */ //to get initialization details using appraisal Id for Business Unit,Department,To Year $appraisalratingsmodel = new Default_Model_Appraisalratings(); $appraisal_details = $appraisalratingsmodel->getappdata($initialization_id); if (!empty($appraisal_details)) { $bunit = $appraisal_details['unitname']; $dept = $appraisal_details['deptname']; $to_year = $appraisal_details['to_year']; } $dept_str = $dept == '' ? " " : "and <b>{$dept}</b> department"; $emp_id_str = $loginuserRole == SUPERADMINROLE ? " " : "({$loginUserEmpId})"; $app_manager_model = new Default_Model_Appraisalmanager(); $getLineManager = $app_manager_model->getLineMgr($initialization_id, $loginUserId); if (!empty($getLineManager)) { $line_mgr = $getLineManager['line_manager_1']; $employeeDetailsArr = $app_manager_model->getUserDetailsByEmpID($line_mgr); $employeeDetailsArr = $employeeDetailsArr[0]; // Sending mail to Manager if (!empty($employeeDetailsArr)) { $options['subject'] = APPLICATION_NAME . ': Self Appraisal Submitted'; $options['header'] = "Performance Appraisal : {$to_year}"; $options['toEmail'] = $employeeDetailsArr['emailaddress']; $options['toName'] = $employeeDetailsArr['userfullname']; $options['message'] = "<div style='padding: 0; text-align: left; font-size:14px; font-family:Arial, Helvetica, sans-serif;'>\t\t\t\t\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t<span style='color:#3b3b3b;'>Dear " . $employeeDetailsArr['userfullname'] . ",</span><br />\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t<div style='padding:20px 0 0 0;color:#3b3b3b;'> " . $loginuserFullName . $emp_id_str . " has submitted appraisal form.</div>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t<div style='padding:20px 0 10px 0;'>Please <a href=" . BASE_URL . " target='_blank' style='color:#b3512f;'>click here</a> to login to <b>" . APPLICATION_NAME . "</b> and check the appraisal ratings and comments.</div>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t</div> "; $mail_id = sapp_Global::_sendEmail($options); } } //Sending mail to Employee $options['subject'] = APPLICATION_NAME . ': Performance Appraisal Submitted to Line1 manager'; $options['header'] = "Performance Appraisal : {$to_year}"; $options['toEmail'] = $loginuserEmail; $options['toName'] = $loginuserFullName; $options['message'] = "<div style='padding: 0; text-align: left; font-size:14px; font-family:Arial, Helvetica, sans-serif;'>\t\t\t\t\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t<span style='color:#3b3b3b;'>Dear {$loginuserFullName},</span><br />\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t<div style='padding:20px 0 0 0;color:#3b3b3b;'>Your appraisal form is submitted successfully to your Line1 Manager," . $employeeDetailsArr['userfullname'] . "(" . $employeeDetailsArr['employeeId'] . ") </div>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t<div style='padding:20px 0 10px 0;'>Please <a href=" . BASE_URL . " target='_blank' style='color:#b3512f;'>click here</a> to login to your <b>" . APPLICATION_NAME . "</b> account.</div>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t</div> "; $mail_id = sapp_Global::_sendEmail($options); } /** * End */ $appWhere = array('id=?' => $id); $result1 = $appEmpRatingsModel->SaveorUpdateAppraisalSkillsData($appData, $appWhere); if ($result1) { $msg = 'saved'; } else { $msg = 'err'; } } catch (Exception $e) { //echo $e->getMessage(); //echo $e->getTrace(); //echo $e->getTraceAsString(); $msg = "Something went wrong, please try again."; } $this->_helper->json(array('msg' => $msg)); }
public function sendEMails($agencyData, $flag) { $baseUrl = $this->generateBaseurl(); $agencylistmodel = new Default_Model_Agencylist(); if ($flag == 'activated') { $emailids = $agencylistmodel->getAllHRManagementEMails(); foreach ($emailids as $email) { $options['subject'] = APPLICATION_NAME . ' : Agency activated'; $options['header'] = 'Agency activated'; $options['toEmail'] = $email['groupEmail']; if ($email['group_id'] == 4) { $salutation = 'Dear HR,'; $options['toName'] = 'HR'; } else { $salutation = 'Dear Management,'; $options['toName'] = 'Management'; } $options['message'] = '<div> <div>' . $salutation . '</div> <div></div> ' . $agencyData['userfullname'] . ' agency has been activated. <div></div> <div style="padding:20px 0 10px 0;">Please <a href="' . $baseUrl . '/index/popup" target="_blank" style="color:#b3512f;">click here</a> to login to your Sentrifugo account.</div> </div>'; $options['cron'] = 'yes'; $result = sapp_Global::_sendEmail($options); } $options['subject'] = APPLICATION_NAME . ' : Agency Activated'; $options['header'] = 'Agency Activated'; $options['toEmail'] = $agencyData['emailaddress']; $options['toName'] = $agencyData['userfullname']; $options['message'] = '<div> <div>Dear ' . $agencyData['userfullname'] . ',</div> <div></div> Your agency has been activated. For further details, please contact our HR directly. <div></div> <div style="padding:20px 0 10px 0;">Please <a href="' . $baseUrl . '/index/popup" target="_blank" style="color:#b3512f;">click here</a> to login to your Sentrifugo account.</div> </div>'; $options['cron'] = 'yes'; $result = sapp_Global::_sendEmail($options); } else { if ($flag == 'inactivated') { $emailids = $agencylistmodel->getAllHRManagementEMails(); foreach ($emailids as $email) { $options['subject'] = APPLICATION_NAME . ' : Agency is deleted'; $options['header'] = 'Agency deleted'; $options['toEmail'] = $email['groupEmail']; if ($email['group_id'] == 4) { $salutation = 'Dear HR,'; $options['toName'] = 'HR'; } else { $salutation = 'Dear Management,'; $options['toName'] = 'Management'; } $options['message'] = '<div> <div>' . $salutation . ' </div> <div></div> ' . $agencyData['userfullname'] . ' agency has been deleted. <div></div> <div style="padding:20px 0 10px 0;">Please <a href="' . $baseUrl . '/index/popup" target="_blank" style="color:#b3512f;">click here</a> to login to your Sentrifugo account.</div> </div>'; $options['cron'] = 'yes'; $result = sapp_Global::_sendEmail($options); } $options['subject'] = APPLICATION_NAME . ' :: Agency is deleted'; $options['header'] = 'Agency Deleted'; $options['toEmail'] = $agencyData['emailaddress']; $options['toName'] = $agencyData['userfullname']; $options['message'] = '<div> <div>Dear ' . $agencyData['userfullname'] . ',</div> <div></div> We regret to inform you that your agency has been deleted. <div></div> </div>'; $options['cron'] = 'yes'; $result = sapp_Global::_sendEmail($options); } } }
public function sendmailstoemployees($oldRM, $newRM) { $baseUrl = BASE_URL; $employeeModal = new Default_Model_Employee(); $employessunderEmpId = $employeeModal->getEmployeesUnderRM($oldRM); /* Send Mails to the employees whose reporting manager is changed */ $oldRMData = $employeeModal->getsingleEmployeeData($oldRM); $newRMData = $employeeModal->getsingleEmployeeData($newRM); if (!empty($newRMData)) { foreach ($employessunderEmpId as $employee) { $options['subject'] = APPLICATION_NAME . ' : Change of reporting manager'; $options['header'] = 'Change of reporting manager'; $options['toEmail'] = $employee['emailaddress']; $options['toName'] = $employee['userfullname']; $options['message'] = '<div>Hello ' . ucfirst($employee['userfullname']) . ', <div>' . ucfirst($newRMData[0]['userfullname']) . ' is your new reporting manager.</div> <div style="padding:20px 0 10px 0;">Please <a href="' . $baseUrl . '/index/popup" target="_blank" style="color:#b3512f;">click here</a> to login </div> </div>'; $result = sapp_Global::_sendEmail($options); } } }
public function mail_helper_action($subject, $message, $summary_data, $to_email) { $status = $summary_data['status']; $disp_arr = array('Closed' => 'Closed', 'Rejected' => 'Rejected'); $display_status = !array_key_exists($status, $disp_arr) ? "Open" : $disp_arr[$status]; $view = $this->getHelper('ViewRenderer')->view; $base_url = 'http://' . $this->getRequest()->getHttpHost() . $this->getRequest()->getBaseUrl(); $this->view->base_url = $base_url; $this->view->message = $message; $this->view->newSubject = $subject; $this->view->data = $summary_data; $text = $view->render('mailtemplates/sd_request.phtml'); $options['subject'] = APPLICATION_NAME . ":" . $subject; $options['header'] = $subject; $options['toEmail'] = $to_email; $options['toName'] = ''; $options['message'] = $text; $options['cron'] = 'yes'; if ($options['toEmail'] != '') { sapp_Global::_sendEmail($options, "sd_request"); } }
public function cancelleave($userid, $recordid) { $businessunitid = ''; $from_date = ''; $to_date = ''; $reason = ''; $appliedleavescount = ''; $userfullname = ''; $useremail = ''; $reportingmanagername = ''; $reportingmanageremail = ''; $db = Zend_Db_Table::getDefaultAdapter(); $date = gmdate("Y-m-d H:i:s"); /* Fetching the record to be updated with cancel satus for email purpose and updating the status */ if ($userid != '' && $recordid != '') { $leave_query = "SELECT l.reason,l.appliedleavescount,DATE_FORMAT(l.from_date,'" . DATEFORMAT_MYSQL . "') as from_date,\n\t\t\t\t\t\t\tDATE_FORMAT(l.to_date,'" . DATEFORMAT_MYSQL . "') as to_date FROM main_leaverequest AS l \n\t\t\t\t\t\t\twhere (l.id=" . $recordid . " and l.user_id =" . $userid . " and l.isactive=1)"; $leave_result = $db->query($leave_query)->fetch(); //echo "<pre>";print_r($leave_result);exit; if (!empty($leave_result)) { $from_date = $leave_result['from_date']; $to_date = $leave_result['to_date']; if ($to_date == '' || $to_date == NULL) { $to_date = $from_date; } $reason = $leave_result['reason']; $appliedleavescount = $leave_result['appliedleavescount']; } $db->query("update main_leaverequest set leavestatus = 4,modifiedby = " . $userid . ",\n\t\t\t\t\t\t\tmodifieddate = '" . $date . "' where (id=" . $recordid . " and user_id =" . $userid . " and isactive=1 )"); /* END */ $user_query = "SELECT u.userfullname,u.emailaddress,e.businessunit_id,e.reporting_manager FROM main_users AS u \n\t\t\t\t\t\t left join main_employees e on e.user_id=u.id\n\t\t\t\t\t\t WHERE (u.isactive = 1 AND u.id=" . $userid . ")"; $user_result = $db->query($user_query)->fetch(); if (!empty($user_result)) { $userfullname = $user_result['userfullname']; $useremail = $user_result['emailaddress']; $businessunitid = $user_result['businessunit_id']; $reportingmanagerid = $user_result['reporting_manager']; } if ($reportingmanagerid != '') { $rep_mangr_query = "SELECT u.userfullname,u.emailaddress FROM main_users AS u \n\t\t\t\t\t\t\t\t\tWHERE (u.isactive = 1 AND u.id=" . $reportingmanagerid . ")"; $repmanager_result = $db->query($rep_mangr_query)->fetch(); if (!empty($repmanager_result)) { $reportingmanagername = $repmanager_result['userfullname']; $reportingmanageremail = $repmanager_result['emailaddress']; } } if ($userfullname != '' && $useremail != '' && $from_date != '' && $reason != '' && $appliedleavescount != '') { /* Mail to Employee */ $options['subject'] = 'Leave Request'; $options['header'] = 'Leave Request'; $options['fromEmail'] = DONOTREPLYEMAIL; $options['fromName'] = DONOTREPLYNAME; $options['toEmail'] = $useremail; //$options['cc'] = $hremail; $options['toName'] = $userfullname; $options['message'] = '<div> <div>Name : ' . $userfullname . '</div> <div> No. of leaves applied : ' . $appliedleavescount . '</div> <div>From : ' . $from_date . '</div> <div>To : ' . $to_date . '.</div> <div> Reason : ' . $reason . '</div> </div>'; $result = sapp_Global::_sendEmail($options); /* End */ /* Mail to Reporting Manager */ $options['subject'] = 'Leave Request'; $options['header'] = 'Leave Request'; $options['fromEmail'] = DONOTREPLYEMAIL; $options['fromName'] = DONOTREPLYNAME; $options['toEmail'] = $reportingmanageremail; //$options['cc'] = $hremail; $options['toName'] = $reportingmanagername; $options['message'] = '<div> <div>Name : ' . $userfullname . '</div> <div> No. of leaves applied : ' . $appliedleavescount . '</div> <div>From : ' . $from_date . '</div> <div>To : ' . $to_date . '.</div> <div> Reason : ' . $reason . '</div> </div>'; $result = sapp_Global::_sendEmail($options); /* End */ /* Mail to HR */ if (defined('LV_HR_' . $businessunitid) && $businessunitid != '') { $options['subject'] = 'Leave Request'; $options['header'] = 'Leave Request'; $options['fromEmail'] = DONOTREPLYEMAIL; $options['fromName'] = DONOTREPLYNAME; $options['toEmail'] = constant('LV_HR_' . $businessunitid); //$options['cc'] = $hremail; $options['toName'] = 'Leave management'; $options['message'] = '<div> <div>Name : ' . $userfullname . '</div> <div> No. of leaves applied : ' . $appliedleavescount . '</div> <div>From : ' . $from_date . '</div> <div>To : ' . $to_date . '.</div> <div> Reason : ' . $reason . '</div> </div>'; //$options['cron'] = 'yes'; $result = sapp_Global::_sendEmail($options); } /*END */ } $data = array('status' => '1', 'message' => 'Leave request cancelled successfully.', 'result' => 'success'); } else { $data = array('status' => '0', 'message' => 'User Id cannot be empty.', 'result' => $result); } return $data; }
public function send_req_mails1($id) { $sd_req_model = new Default_Model_Servicerequests(); $summary_data = $sd_req_model->getDataSummary($id); $cc_req_ids = $sd_req_model->getCC_mails($summary_data['service_desk_conf_id']); if ($summary_data['status'] == 'Open') { $total_ids = array($cc_req_ids['request_recievers'], $cc_req_ids['cc_mail_recievers'], $summary_data['createdby']); } else { if ($summary_data['status'] == 'Closed') { $total_ids = array($summary_data['executor_id'], $cc_req_ids['cc_mail_recievers'], $summary_data['createdby']); } else { if ($summary_data['status'] == 'To manager approve') { $total_ids = array($summary_data['executor_id'], $cc_req_ids['cc_mail_recievers'], $summary_data['reporting_manager_id']); } else { if (in_array($summary_data['status'], array('To management approve', 'Management approved', 'Management rejected'))) { $total_ids = array($summary_data['executor_id'], $cc_req_ids['cc_mail_recievers'], $summary_data['approver_1'], $summary_data['approver_2'], $summary_data['approver_3']); } else { if ($summary_data['status'] == 'Manager approved' || $summary_data['status'] == 'Manager rejected') { $total_ids = array($summary_data['executor_id'], $cc_req_ids['cc_mail_recievers'], $summary_data['reporting_manager_id']); } } } } } $total_ids = array_filter($total_ids); $total_ids = implode(',', $total_ids); $email_ids = $sd_req_model->getEmailIds($total_ids); $req_receivers = explode(',', $cc_req_ids['request_recievers']); $cc = array(); if ($cc_req_ids['cc_mail_recievers'] != '') { $cc = explode(',', $cc_req_ids['cc_mail_recievers']); } $req_receivers[] = $summary_data['createdby']; $status = $summary_data['status']; $disp_arr = array('Closed' => 'Closed', 'Rejected' => 'Closed'); $display_status = !in_array($status, $disp_arr) ? "Open" : "Closed"; if (count($req_receivers) > 0) { foreach ($req_receivers as $rec) { $base_url = 'http://' . $this->getRequest()->getHttpHost() . $this->getRequest()->getBaseUrl(); $view = $this->getHelper('ViewRenderer')->view; $this->view->base_url = $base_url; $this->view->type = "receivers"; $this->view->data = $summary_data; $text = $view->render('mailtemplates/sdrequest.phtml'); $options['subject'] = "New Online request: Status - " . $display_status; $options['header'] = 'Online request'; $options['toEmail'] = isset($email_ids[$rec]) ? $email_ids[$rec] : ""; $options['toName'] = ''; $options['message'] = $text; $options['cron'] = 'yes'; if ($options['toEmail'] != '') { sapp_Global::_sendEmail($options); } } } if (count($cc) > 0) { foreach ($cc as $rec) { $base_url = 'http://' . $this->getRequest()->getHttpHost() . $this->getRequest()->getBaseUrl(); $view = $this->getHelper('ViewRenderer')->view; $this->view->base_url = $base_url; $this->view->type = "receivers"; $this->view->data = $summary_data; $text = $view->render('mailtemplates/sdrequest.phtml'); $options['subject'] = "New Online request: Status - Open"; $options['header'] = 'Online request'; $options['toEmail'] = $email_ids[$rec]; $options['toName'] = ''; $options['message'] = $text; $options['cron'] = 'yes'; if ($options['toEmail'] != '') { sapp_Global::_sendEmail($options); } } } }
public function save($appraisalconfigform) { $auth = Zend_Auth::getInstance(); if ($auth->hasIdentity()) { $loginUserId = $auth->getStorage()->read()->id; $loginuserRole = $auth->getStorage()->read()->emprole; $loginUserEmpId = $auth->getStorage()->read()->employeeId; $loginUserEmail = $auth->getStorage()->read()->emailaddress; $loginUsername = $auth->getStorage()->read()->userfullname; } $appraisalconfigmodel = new Default_Model_Appraisalconfig(); $departmentsmodel = new Default_Model_Departments(); $businessunitsmodel = new Default_Model_Businessunits(); $msgarray = array(); $resultArr = array(); $arrData = array(); $prevBusinessunit = ''; $errorflag = "true"; $id = $this->_request->getParam('id'); $businessunit_id = $this->_request->getParam('businessunit_id'); $performance_app_flag = $this->_request->getParam('performance_app_flag'); $department_id = $this->_request->getParam('department_id'); $appraisal_mode = $this->_request->getParam('appraisal_mode'); $approval_selection = $this->_request->getParam('approval_selection'); $appraisal_ratings = $this->_request->getParam('appraisal_ratings'); // Validation to check duplicate combinations $arrData = array("business_unit_id" => $businessunit_id, "department_id" => $department_id, "id" => $id); if ($appraisalconfigmodel->combinationExists($arrData)) { $msgarray['businessunit_id'] = 'Business unit or department configuration already exists.'; $errorflag = "false"; } /** Start * Validating selection of department if implementaion is department wise */ if ($performance_app_flag == 0) { if ($department_id == '') { $msgarray['department_id'] = 'Please select department.'; $errorflag = "false"; } } /** End validating selection of department */ /** Start Validating unique service desk department */ if ($businessunit_id != '' && $id == '') { $appraisalconigfArr = $appraisalconfigmodel->checkuniqueAppraisalConfigData($businessunit_id, $performance_app_flag, $department_id); if (!empty($appraisalconigfArr)) { if ($appraisalconigfArr[0]['count'] > 0) { $msgarray['department_id'] = 'Please select a different department.'; $errorflag = "false"; } } } /** End * Validating uniques department */ $db = Zend_Db_Table::getDefaultAdapter(); $db->beginTransaction(); if ($appraisalconfigform->isValid($this->_request->getPost()) && $errorflag == 'true') { try { $actionflag = ''; $tableid = ''; $data = array('businessunit_id' => $businessunit_id, 'department_id' => $department_id != '' ? $department_id : NULL, 'performance_app_flag' => $performance_app_flag, 'appraisal_mode' => $appraisal_mode, 'appraisal_ratings' => $appraisal_ratings, 'module_flag' => 1, 'modifiedby' => $loginUserId, 'modifieddate' => gmdate("Y-m-d H:i:s")); if ($id != '') { /* for Update record */ $where = array('id=?' => $id); $actionflag = 2; } else { /* for Insert new record */ $data['createdby'] = $loginUserId; $data['createddate'] = gmdate("Y-m-d H:i:s"); $data['isactive'] = 1; $where = ''; $actionflag = 1; } $Id = $appraisalconfigmodel->SaveorUpdateAppraisalConfigData($data, $where); if ($Id == 'update') { $tableid = $id; $this->_helper->getHelper("FlashMessenger")->addMessage(array("success" => "Appraisal settings updated successfully")); } else { $tableid = $Id; $this->_helper->getHelper("FlashMessenger")->addMessage(array("success" => "Appraisal settings added successfully")); } /* * Logs Storing */ $menuID = APPRAISAL_SETTINGS; $result = sapp_Global::logManager($menuID, $actionflag, $loginUserId, $tableid); /* * Logs storing ends */ /** Start * Sending Mails to employees */ if ($performance_app_flag == 0) { $appraisal_details = $appraisalconfigmodel->getBunitDept($businessunit_id, $department_id); } else { $appraisal_details = $appraisalconfigmodel->getBunit($businessunit_id); } $employeeDetailsArr = $appraisalconfigmodel->getUserDetailsByID($businessunit_id, $department_id); if (!empty($appraisal_details)) { $bunit = $appraisal_details['unitname']; $dept = $appraisal_details['deptname']; } $msg_add_update = $Id == 'update' ? "Updated" : "Configured"; $dept_str = $dept == '' ? " " : "and <b>{$dept}</b> department"; $emp_id_str = $loginuserRole == SUPERADMINROLE ? " " : "({$loginUserEmpId})"; //Preparing Employee array for BCc $empArr = array(); if (!empty($employeeDetailsArr)) { $empArrList = ''; foreach ($employeeDetailsArr as $emp) { array_push($empArr, $emp['emailaddress']); } } //Sending mail to Super admin $options['subject'] = APPLICATION_NAME . ': Performance Appraisal Configuration ' . ucfirst($msg_add_update); $options['header'] = 'Performance Appraisal'; $options['toEmail'] = SUPERADMIN_EMAIL; $options['bcc'] = $empArr; $options['toName'] = 'Super Admin'; $options['message'] = "<div style='padding: 0; text-align: left; font-size:14px; font-family:Arial, Helvetica, sans-serif;'>\t\t\t\t\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t<span style='color:#3b3b3b;'>Hi,</span><br />\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t<div style='padding:20px 0 0 0;color:#3b3b3b;'>Performance appraisal settings are {$msg_add_update} for <b>{$bunit}</b> business unit {$dept_str} by " . $loginUsername . $emp_id_str . " </div>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t<div style='padding:20px 0 10px 0;'>Please <a href=" . BASE_URL . " target='_blank' style='color:#b3512f;'>click here</a> to login to <b>" . APPLICATION_NAME . "</b> and check the details.</div>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t</div> "; $mail_id = sapp_Global::_sendEmail($options); /** * End */ $db->commit(); $this->_redirect('appraisalconfig'); throw new Exception("Some error message"); } catch (Exception $e) { $db->rollBack(); echo $e->getMessage(); echo $e->getTraceAsString(); return $msgarray; } } else { $messages = $appraisalconfigform->getMessages(); foreach ($messages as $key => $val) { foreach ($val as $key2 => $val2) { $msgarray[$key] = $val2; break; } } if (isset($businessunit_id) && $businessunit_id != '') { if ($performance_app_flag == 0) { $departmentlistArr = $departmentsmodel->getDepartmentList($businessunit_id); if (!empty($departmentlistArr)) { foreach ($departmentlistArr as $departmentlist) { $appraisalconfigform->department_id->addMultiOption($departmentlist['id'], utf8_encode($departmentlist['deptname'])); } } } if (isset($department_id) && $department_id != 0 && $department_id != '') { $appraisalconfigform->setDefault('department_id', $department_id); } } return $msgarray; } }
/** * * @param type $requisitionform * @param type $data * @return type */ public function save($requisitionform, $data) { $ipreporting_id = ""; $technicalskill_id = ""; $nontechnicalskill_id = ""; $auth = Zend_Auth::getInstance(); if ($auth->hasIdentity()) { $loginUserId = $auth->getStorage()->read()->id; $loginuserGroup = $auth->getStorage()->read()->group_id; } $requi_model = new Default_Model_Requisition(); $user_model = new Default_Model_Usermanagement(); $jobtitleModel = new Default_Model_Jobtitles(); $appr_mail = ''; $appr_per = ''; if ($requisitionform->isValid($this->_request->getPost())) { $trDb = Zend_Db_Table::getDefaultAdapter(); // starting transaction $trDb->beginTransaction(); try { $id = (int) $this->_getParam('id', null); $requisition_code = $this->_getParam('requisition_code', null); $onboard_date = $this->_getParam('onboard_date', null); $business_unit = $this->_getParam('business_unit', null); $department = $this->_getParam('department', null); $jobtitle = $this->_getParam('jobtitle', null); $position_id = $this->_getParam('position_id', null); $reporting_id = $this->_getParam('reporting_id', null); $req_no_positions = $this->_getParam('req_no_positions', null); $jobdescription = $this->_getParam('jobdescription', null); $req_skills = $this->_getParam('req_skills', null); $req_qualification = $this->_getParam('req_qualification', null); $req_exp_years = $this->_getParam('req_exp_years', null); $emp_type = $this->_getParam('emp_type', null); $req_priority = $this->_getParam('req_priority', null); $additional_info = $this->_getParam('additional_info', null); $req_status = $this->_getParam('req_status', null); $approver1 = $this->_getParam('approver1', null); $approver2 = $this->_getParam('approver2', null); $approver3 = $this->_getParam('approver3', null); $aflag = $this->_getParam('aflag', null); $edit_flag = $this->_getParam('edit_flag', null); $edit_order = $this->_getParam('edit_order', null); $requ_jd = $this->_getParam('requ_jd', null); $billable = $this->_getParam('billable', null); $billablefor = $this->_getParam('billablefor', null); $billable_empname = $this->_getParam('billable_empname', null); $interviewroundscount = $this->_getParam('interviewroundscount', null); $technology = $this->_getParam('technology', null); try { $ipbusiness_unit = 1; $ipdepartment = 1; $ipreporting_id = $this->_getParam('ipreporting_id', null); $technicalskill_id = $this->_getParam('technicalskill_id', null); $nontechnicalskill_id = $this->_getParam('nontechnicalskill_id', null); } catch (Exception $abc) { } $aorder = $this->_getParam('aorder', null); //1= approver1,2=approver2,3=approver3 if ($aflag != '' && $aflag == 'approver') { if ($req_status == 3) { //for rejected $data = array('modifiedby' => trim($loginUserId), 'modifiedon' => gmdate("Y-m-d H:i:s"), 'appstatus' . $aorder => $req_status, 'req_status' => $req_status); } else { //for approved if ($aorder == 1) { if ($approver2 != '') { $data = array('appstatus1' => $req_status, 'req_status' => $req_status); $appr_mail = $approver1; $appr_per = $approver1; } else { $data = array('appstatus1' => $req_status, 'req_status' => $req_status); $appr_mail = 'approved'; } } else { if ($aorder == 2) { if ($approver3 != '') { $data = array('appstatus2' => $req_status, 'req_status' => $req_status); $appr_mail = $approver2; $appr_per = $approver2; } else { $data = array('appstatus2' => $req_status, 'req_status' => $req_status); $appr_mail = 'approved'; } } } $data['modifiedby'] = trim($loginUserId); $data['modifiedon'] = gmdate("Y-m-d H:i:s"); } } else { $data = array('requisition_code' => trim($requisition_code), 'onboard_date' => sapp_Global::change_date(trim($onboard_date), 'database'), 'position_id' => trim($position_id), 'reporting_id' => trim($reporting_id), 'businessunit_id' => trim($business_unit), 'department_id' => trim($department), 'req_no_positions' => trim($req_no_positions), 'jobdescription' => trim($jobdescription), 'jobtitle' => trim($jobtitle), 'req_skills' => trim($req_skills), 'req_qualification' => trim($req_qualification), 'req_exp_years' => trim($req_exp_years), 'emp_type' => trim($emp_type), 'req_priority' => trim($req_priority), 'additional_info' => trim($additional_info), 'billable' => trim($billable), 'interviewroundscount' => trim($interviewroundscount), 'technology' => trim($technology), 'approver1' => $approver1, 'approver2' => $approver2 == '' ? null : $approver2, 'approver3' => $approver3 == '' ? null : $approver3, 'req_status' => 'Initiated', 'appstatus1' => 'Initiated', 'appstatus2' => null, 'appstatus3' => null, 'isactive' => 1, 'createdby' => trim($loginUserId), 'modifiedby' => trim($loginUserId), 'createdon' => gmdate("Y-m-d H:i:s"), 'modifiedon' => gmdate("Y-m-d H:i:s"), 'upload_jd' => trim($requ_jd), 'billable_for' => trim($billablefor), 'billable_empname' => trim($billable_empname)); if ($loginuserGroup == MANAGER_GROUP) { $data['reporting_id'] = $loginUserId; } if ($edit_flag != '' && $edit_flag == 'yes') { if ($edit_order == 1) { $data = array('modifiedby' => trim($loginUserId), 'modifiedon' => gmdate("Y-m-d H:i:s"), 'approver2' => $approver2 == '' ? null : $approver2, 'approver3' => $approver3 == '' ? null : $approver3, 'appstatus2' => 'Initiated'); if ($approver2 == '') { $data['appstatus2'] = null; } else { $appr_per = $edit_order; $appr_mail = $approver2; } } if ($edit_order == 2) { $data = array('modifiedby' => trim($loginUserId), 'modifiedon' => gmdate("Y-m-d H:i:s"), 'approver3' => $approver3 == '' ? null : $approver3, 'appstatus3' => 'Initiated'); if ($approver3 == '') { $data['appstatus3'] = null; } else { $appr_per = $edit_order; $appr_mail = $approver3; } } } } $where = ""; $actionflag = 1; //for mailing if ($id == '') { //for requisition code $identity_code_model = new Default_Model_Identitycodes(); $identity_codes = $identity_code_model->getIdentitycodesRecord(); $irequistion_code = isset($identity_codes[0]) ? $identity_codes[0]['requisition_code'] : ""; if ($irequistion_code != '') { $req_id = $requi_model->getMaxReqCode($irequistion_code . "/"); } else { $req_id = ''; } $data['requisition_code'] = $req_id; //end of requisition code $report_person_data = $user_model->getUserDataById($data['reporting_id']); $approver1_person_data = $user_model->getUserDataById($approver1); $Raisedby_person_data = $user_model->getUserDataById($data['createdby']); $jobttlArr = $jobtitleModel->getsingleJobTitleData(trim($jobtitle)); if (!empty($jobttlArr) && $jobttlArr != 'norows') { $jobtitlename = ' - ' . $jobttlArr[0]['jobtitlename']; } else { $jobtitlename = ''; } //$hrgroupemail = $requi_model->getgroupemailid("REQ_HR", $business_unit); //if (isset($hrgroupemail)) { //HR Group $mail_arr[0]['name'] = 'HR'; $mail_arr[0]['email'] = constant('REQ_HR_0'); $mail_arr[0]['type'] = 'HR'; //} //$mgmtgroupemail = $requi_model->getgroupemailid("REQ_MGMT", $business_unit); //if (isset($mgmtgroupemail)) { //HR Group $mail_arr[1]['name'] = 'Management'; $mail_arr[1]['email'] = constant('REQ_MGMT_0'); $mail_arr[1]['type'] = 'Management'; //} $mail_arr[2]['name'] = $Raisedby_person_data['userfullname']; $mail_arr[2]['email'] = $Raisedby_person_data['emailaddress']; $mail_arr[2]['type'] = 'RaiseNew'; $mail_arr[3]['name'] = $approver1_person_data['userfullname']; $mail_arr[3]['email'] = $approver1_person_data['emailaddress']; $mail_arr[3]['type'] = 'Approver'; $appr_str = ""; $appr_str = $approver1_person_data['userfullname']; $req_selected_skills = sprintf("Technical Skills (%s), Non-Technical Skills (%s).", $requi_model->getSkillNamesByIds(implode(",", $technicalskill_id), "Technical"), $requi_model->getSkillNamesByIds(implode(",", $nontechnicalskill_id), "Non-Technical")); for ($ii = 0; $ii < count($mail_arr); $ii++) { $base_url = 'http://' . $this->getRequest()->getHttpHost() . $this->getRequest()->getBaseUrl(); $view = $this->getHelper('ViewRenderer')->view; $this->view->emp_name = $mail_arr[$ii]['name']; $this->view->base_url = $base_url; $this->view->type = $mail_arr[$ii]['type']; $this->view->jobtitle = $jobtitlename; $this->view->requisition_code = $requisition_code; $this->view->approver_str = $appr_str; $this->view->raised_name = $Raisedby_person_data['userfullname']; if ($mail_arr[$ii]['type'] == "RaiseNew" || $mail_arr[$ii]['type'] == 'Raise' || $mail_arr[$ii]['type'] == 'RaiseNew' || $mail_arr[$ii]['type'] == 'HR' || $mail_arr[$ii]['type'] == 'Management' || $mail_arr[$ii]['type'] == 'Approver' || $mail_arr[$ii]['type'] == 'ReportingManager') { //values for new email template $bu_dept = $requi_model->getBusinessUnitDepartmentName(trim($department)); $this->view->department_name = $bu_dept['DepartmentName']; $this->view->businessunit_name = $bu_dept['BusinessUnitName']; $this->view->noofopenings = trim($req_no_positions); $this->view->position_name = trim($jobtitlename); $this->view->skills = trim($req_selected_skills); $this->view->application_name = APPLICATION_NAME; } $text = $view->render('mailtemplates/requisition.phtml'); $options['subject'] = APPLICATION_NAME . ': ' . $requisition_code . '-Requisition for approval'; $options['header'] = 'Requisition Status'; $options['toEmail'] = $mail_arr[$ii]['email']; $options['toName'] = $mail_arr[$ii]['name']; $options['message'] = $text; //var_dump($text); //$options['cron'] = 'yes'; if ($options['toEmail'] != '') { if ($mail_arr[$ii]['type'] == "RaiseNew" || $mail_arr[$ii]['type'] == 'Raise' || $mail_arr[$ii]['type'] == 'RaiseNew' || $mail_arr[$ii]['type'] == 'HR' || $mail_arr[$ii]['type'] == 'Management' || $mail_arr[$ii]['type'] == 'Approver' || $mail_arr[$ii]['type'] == 'ReportingManager') { sapp_Global::_sendEmail($options, "New", REQUISITIONMODULESENDEMAIL); } else { sapp_Global::_sendEmail($options, '', REQUISITIONMODULESENDEMAIL); } } } } if ($id != '') { unset($data['createdby']); unset($data['createdon']); unset($data['isactive']); $where = "id = " . $id; $tableid = $id; $actionflag = 2; } $result = $requi_model->SaveorUpdateRequisitionData($data, $where); //log approvals by approver if ($loginUserId == $approver1) { $requisition_data1 = $requi_model->getRequisitionDataById($id); $result1 = $requi_model->insert_requisition_approvalLog($id, $requisition_data1['requisition_code'], $req_status, $loginUserId, gmdate("Y-m-d H:i:s")); } /* * To Insert Interview Panel & Skill details when a new Requisition created */ $currReqIDinDB = $id; if ($currReqIDinDB <= 0) { $currReqIDinDB = $result; } $requisition_data2 = $requi_model->getRequisitionDataById($currReqIDinDB); $result1 = $requi_model->insert_requisition_interview_panel($requisition_data2['requisition_code'], $ipbusiness_unit, $ipdepartment, $ipreporting_id, $requ_jd); $result2 = $requi_model->insert_requisition_skills($requisition_data2['requisition_code'], $technicalskill_id, "Technical"); $result3 = $requi_model->insert_requisition_skills($requisition_data2['requisition_code'], $nontechnicalskill_id, "Non-Technical"); if ($id == '') { $tableid = $result; } if ($result != '') { if ($actionflag == 2) { //start of mailing $requisition_data = $requi_model->getRequisitionDataById($id); $report_person_data = $user_model->getUserDataById($requisition_data['reporting_id']); $st_arr = array('0' => 'Select status', '2' => 'Approved', '3' => 'Rejected'); if ($req_status == 3 || $appr_mail == 'approved') { //for rejected $approver1_person_data = $user_model->getUserDataById($requisition_data['approver1']); $Raisedby_person_data = $user_model->getUserDataById($requisition_data['createdby']); $jobttlArr = $jobtitleModel->getsingleJobTitleData(trim($requisition_data['jobtitle'])); if (!empty($jobttlArr) && $jobttlArr != 'norows') { $jobtitlename = ' - ' . $jobttlArr[0]['jobtitlename']; } else { $jobtitlename = ''; } /* $mail_arr[0]['name'] = 'HR'; $mail_arr[0]['email'] = defined('REQ_HR_' . $requisition_data['businessunit_id']) ? constant('REQ_HR_' . $requisition_data['businessunit_id']) : ""; $mail_arr[0]['type'] = 'HR'; $mail_arr[1]['name'] = 'Management'; $mail_arr[1]['email'] = defined('REQ_MGMT_' . $requisition_data['businessunit_id']) ? constant('REQ_MGMT_' . $requisition_data['businessunit_id']) : ""; $mail_arr[1]['type'] = 'Management'; */ //$hrgroupemail = $requi_model->getgroupemailid("REQ_HR", $requisition_data['businessunit_id']); //if (isset($hrgroupemail)) { //HR Group $mail_arr[0]['name'] = 'HR'; $mail_arr[0]['email'] = constant('REQ_HR_0'); $mail_arr[0]['type'] = 'HR'; //} //$mgmtgroupemail = $requi_model->getgroupemailid("REQ_MGMT", $requisition_data['businessunit_id']); //if (isset($mgmtgroupemail)) { //HR Group $mail_arr[1]['name'] = 'Management'; $mail_arr[1]['email'] = constant('REQ_MGMT_0'); $mail_arr[1]['type'] = 'Management'; //} $mail_arr[2]['name'] = $Raisedby_person_data['userfullname']; $mail_arr[2]['email'] = $Raisedby_person_data['emailaddress']; $mail_arr[2]['type'] = 'Raise'; $mail_arr[3]['name'] = $approver1_person_data['userfullname']; $mail_arr[3]['email'] = $approver1_person_data['emailaddress']; $mail_arr[3]['type'] = 'Approver'; // Check if the reporting person and raised person are same - Requisition raised by Manager case if ($requisition_data['reporting_id'] != $requisition_data['createdby']) { $mail_arr[4]['name'] = $report_person_data['userfullname']; $mail_arr[4]['email'] = $report_person_data['emailaddress']; $mail_arr[4]['type'] = 'ReportingManager'; } $appr_str = ""; $appr_str = $approver1_person_data['userfullname']; if ($requisition_data['approver2'] != '') { $approver2_person_data = $user_model->getUserDataById($requisition_data['approver2']); $appr_str .= ", " . $approver2_person_data['userfullname']; $mail_arr[5]['name'] = $approver2_person_data['userfullname']; $mail_arr[5]['email'] = $approver2_person_data['emailaddress']; $mail_arr[5]['type'] = 'Approver'; } if ($requisition_data['approver3'] != '') { $approver3_person_data = $user_model->getUserDataById($requisition_data['approver3']); $appr_str .= " and " . $approver3_person_data['userfullname']; $mail_arr[6]['name'] = $approver3_person_data['userfullname']; $mail_arr[6]['email'] = $approver3_person_data['emailaddress']; $mail_arr[6]['type'] = 'Approver'; } $mail = array(); for ($ii = 0; $ii < count($mail_arr); $ii++) { $base_url = 'http://' . $this->getRequest()->getHttpHost() . $this->getRequest()->getBaseUrl(); $view = $this->getHelper('ViewRenderer')->view; $this->view->emp_name = !empty($mail_arr[$ii]['name']) ? $mail_arr[$ii]['name'] : ''; $this->view->base_url = $base_url; $this->view->type = !empty($mail_arr[$ii]['type']) ? $mail_arr[$ii]['type'] : ''; $this->view->jobtitle = $jobtitlename; $this->view->requisition_code = $requisition_data['requisition_code']; $this->view->approver_str = $appr_str; $this->view->raised_name = $Raisedby_person_data['userfullname']; $this->view->req_status = $st_arr[$req_status]; $this->view->reporting_manager = $report_person_data['userfullname']; $text = $view->render('mailtemplates/changedrequisition.phtml'); $options['subject'] = strtolower($st_arr[$req_status]) == 'approved' ? APPLICATION_NAME . ': ' . $requisition_data['requisition_code'] . '-Requisition is approved' : APPLICATION_NAME . ': Requisition is rejected'; $options['header'] = 'Requisition Status'; $options['toEmail'] = !empty($mail_arr[$ii]['email']) ? $mail_arr[$ii]['email'] : ''; $options['toName'] = !empty($mail_arr[$ii]['name']) ? $mail_arr[$ii]['name'] : ''; $options['message'] = $text; $mail[$ii] = $options; //$options['cron'] = 'yes'; if ($options['toEmail'] != '') { sapp_Global::_sendEmail($options, "by_approver1", REQUISITIONMODULESENDEMAIL); } else { sapp_Global::_sendEmail($options, '', REQUISITIONMODULESENDEMAIL); } } } else { if ($req_status == 2) { //Approver $approver_person_data = $user_model->getUserDataById($appr_mail); $mail_arr[0]['name'] = $approver_person_data['userfullname']; $mail_arr[0]['email'] = $approver_person_data['emailaddress']; $mail_arr[0]['type'] = 'Approver'; //HR Group $mail_arr[1]['name'] = 'HR'; $mail_arr[1]['email'] = constant('REQ_HR_0'); $mail_arr[1]['type'] = 'HR'; //Management Group $mail_arr[2]['name'] = 'Management'; $mail_arr[2]['email'] = constant('REQ_MGMT_0'); $mail_arr[2]['type'] = 'Management'; //Requester $Raisedby_person_data = $user_model->getUserDataById($requisition_data['createdby']); $mail_arr[3]['name'] = $Raisedby_person_data['userfullname']; $mail_arr[3]['email'] = $Raisedby_person_data['emailaddress']; $mail_arr[3]['type'] = 'Raise'; if ($edit_flag == 'yes') { $approved_by_data = $user_model->getUserDataById($requisition_data['approver' . $appr_per]); $req_status = 2; } else { $approved_by_data = $user_model->getUserDataById($appr_per); } $Raisedby_person_data = $user_model->getUserDataById($requisition_data['createdby']); $appr_str = $approved_by_data['userfullname']; for ($ii = 0; $ii < count($mail_arr); $ii++) { $base_url = 'http://' . $this->getRequest()->getHttpHost() . $this->getRequest()->getBaseUrl(); $view = $this->getHelper('ViewRenderer')->view; $this->view->emp_name = $mail_arr[$ii]['name']; $this->view->base_url = $base_url; $this->view->type = $mail_arr[$ii]['type']; $this->view->requisition_code = $requisition_data['requisition_code']; $this->view->req_status = $st_arr[$req_status]; $this->view->raised_name = $Raisedby_person_data['userfullname']; $this->view->approver_str = $appr_str; $text = $view->render('mailtemplates/changedrequisition.phtml'); $options['subject'] = strtolower($st_arr[$req_status]) == 'approved' ? APPLICATION_NAME . ':' . $requisition_data['requisition_code'] . '-Requisition is approved' : APPLICATION_NAME . ': Requisition is rejected'; $options['header'] = 'Requisition Status'; $options['toEmail'] = $mail_arr[$ii]['email']; $options['toName'] = $mail_arr[$ii]['name']; $options['message'] = $text; //$options['cron'] = 'yes'; if ($options['toEmail'] != '') { sapp_Global::_sendEmail($options, "by_approver2", REQUISITIONMODULESENDEMAIL); } else { sapp_Global::_sendEmail($options, '', REQUISITIONMODULESENDEMAIL); } } } } //end of mailing } $menumodel = new Default_Model_Menu(); $objidArr = $menumodel->getMenuObjID('/requisition'); $objID = $objidArr[0]['id']; $result = sapp_Global::logManager($objID, $actionflag, $loginUserId, $tableid); if ($id != '') { $this->_helper->getHelper("FlashMessenger")->addMessage(array("success" => "Resource requisition updated successfully.")); } else { $this->_helper->getHelper("FlashMessenger")->addMessage(array("success" => "Resource requisition added successfully.")); } $trDb->commit(); $this->_redirect('/requisition'); } } catch (Exception $e) { $trDb->rollBack(); $this->_helper->getHelper("FlashMessenger")->addMessage(array("success" => "Something went wrong, please try again later.")); $this->_redirect('/requisition'); } } else { $messages = $requisitionform->getMessages(); foreach ($messages as $key => $val) { foreach ($val as $key2 => $val2) { $msgarray[$key] = $val2; break; } } return $msgarray; } }
public function mailing_function($sess_values, $role_name, $save_type, $roles_model) { $group_ids = MANAGEMENT_GROUP . "," . SYSTEMADMIN_GROUP; $object_id = ROLES; $emp_arr = $roles_model->getEmpForRoleMail($group_ids, $object_id); unset($emp_arr[$sess_values->id]); if ($save_type == 'add') { $hr_arr = $roles_model->getEmpForRoleMail(HR_GROUP, EMPLOYEE); unset($hr_arr[$sess_values->id]); $emp_arr = $emp_arr + $hr_arr; } if ($save_type == 'add') { $headerText = 'created'; } else { $headerText = 'updated'; } foreach ($emp_arr as $empdata) { $base_url = 'http://' . $this->getRequest()->getHttpHost() . $this->getRequest()->getBaseUrl(); $view = $this->getHelper('ViewRenderer')->view; $this->view->emp_name = $empdata['userfullname']; $this->view->base_url = $base_url; $this->view->type = $save_type; $this->view->created_by = $sess_values->userfullname; $this->view->role_name = $role_name; $text = $view->render('mailtemplates/role.phtml'); $options['subject'] = APPLICATION_NAME . ': Role is ' . $headerText . ''; $options['header'] = 'Role is ' . $headerText . ''; $options['toEmail'] = $empdata['emailaddress']; $options['toName'] = $empdata['userfullname']; $options['message'] = $text; $options['cron'] = 'yes'; sapp_Global::_sendEmail($options); } }
public function updatelinemanagerAction() { $this->_helper->layout->disableLayout(); $ajaxContext = $this->_helper->getHelper('AjaxContext'); $ajaxContext->addActionContext('updatelinemanager', 'json')->initContext(); $auth = Zend_Auth::getInstance(); if ($auth->hasIdentity()) { $loginUserId = $auth->getStorage()->read()->id; $loginuserRole = $auth->getStorage()->read()->emprole; $loginuserGroup = $auth->getStorage()->read()->group_id; $loginUserEmpId = $auth->getStorage()->read()->employeeId; $loginUserEmail = $auth->getStorage()->read()->emailaddress; $loginUsername = $auth->getStorage()->read()->userfullname; $loginUserprofileimg = $auth->getStorage()->read()->profileimg; } $appraisalPrivMainModel = new Default_Model_Appraisalqsmain(); $appraisalempratingsmodel = new Default_Model_Appraisalemployeeratings(); $result['result'] = 'success'; $result['msg'] = ''; $send_mails = false; $appraisalid = $this->_request->getParam('appraisalid'); $employeeid = $this->_request->getParam('employeeid'); $line_1_mgr = $this->_request->getParam('line_1_mgr'); $line_2_mgr = $this->_request->getParam('line_2_mgr'); $line_3_mgr = $this->_request->getParam('line_3_mgr'); $line_4_mgr = $this->_request->getParam('line_4_mgr'); $line_5_mgr = $this->_request->getParam('line_5_mgr'); $levels = $this->_request->getParam('levels'); //checking equality of manager levels for sending mails if ($appraisalid && $employeeid) { $appraisal_level_arr = $appraisalPrivMainModel->getAllManagerIds($appraisalid, $employeeid); $appraisal_level_arr = $appraisal_level_arr[0]; $levels_pre = $appraisal_level_arr['manager_levels']; if ($levels_pre == $levels) { $preLine_1_mgr = $appraisal_level_arr['line_manager_1']; $preLine_2_mgr = $appraisal_level_arr['line_manager_2']; $preLine_3_mgr = $appraisal_level_arr['line_manager_3']; $preLine_4_mgr = $appraisal_level_arr['line_manager_4']; $preLine_5_mgr = $appraisal_level_arr['line_manager_5']; for ($i = 1; $i <= $levels_pre; $i++) { $preLine_mgr = "preLine_" . $i . "_mgr"; $line_mgr = "line_" . $i . "_mgr"; if (${$line_mgr} != ${$preLine_mgr}) { $send_mails = true; } } } else { $send_mails = true; } } //end checking send mails to employees if ($appraisalid && $employeeid) { $trDb = Zend_Db_Table::getDefaultAdapter(); $trDb->beginTransaction(); try { $data = array('line_manager_1' => $line_1_mgr != '' ? $line_1_mgr : NULL, 'line_manager_2' => $line_2_mgr != '' ? $line_2_mgr : NULL, 'line_manager_3' => $line_3_mgr != '' ? $line_3_mgr : NULL, 'line_manager_4' => $line_4_mgr != '' ? $line_4_mgr : NULL, 'line_manager_5' => $line_5_mgr != '' ? $line_5_mgr : NULL, 'manager_levels' => is_numeric($levels) ? $levels : 1, 'modifiedby' => $loginUserId, 'modifiedby_role' => $loginuserRole, 'modifiedby_group' => $loginuserGroup, 'modifieddate' => gmdate("Y-m-d H:i:s")); $privilegeswhere = " employee_id = '" . $employeeid . "' and pa_initialization_id='" . $appraisalid . "' and module_flag=1 and isactive=1 "; $empratingswhere = " employee_id = '" . $employeeid . "' and pa_initialization_id='" . $appraisalid . "' and isactive=1 "; $appraisalPrivMainModel->SaveorUpdatePrivilegeData($data, $privilegeswhere); //remove the manager_levels as this column is not there in main_pa_employee_ratings table unset($data['manager_levels']); $appraisalempratingsmodel->SaveorUpdateAppraisalSkillsData($data, $empratingswhere); if ($send_mails == true) { /** Start * Sending Mails to employees */ $emp_id_str = $loginuserRole == SUPERADMINROLE ? " " : "({$loginUserEmpId})"; //Preparing string with line manager ids $mgrStr = ''; for ($i = 1; $i <= $levels; $i++) { $mgr_str = 'line_' . $i . '_mgr'; //$line_1_mgr if (is_numeric(${$mgr_str})) { $mgrStr .= ${$mgr_str} . ','; } } $mgrStr = rtrim($mgrStr, ","); $appraisalratingsmodel = new Default_Model_Appraisalratings(); $appraisal_details = $appraisalratingsmodel->getappdata($appraisalid); if (!empty($appraisal_details)) { $to_year = $appraisal_details['to_year']; } $employeeDetailsArr = $appraisalPrivMainModel->getManagerDetailsByIds($employeeid, $mgrStr); $mgr_array = array(); $mgr_array = explode(",", $mgrStr); //Preparing Employee array for Bcc $empArr = array(); if (!empty($employeeDetailsArr)) { $empArrList = ''; $empUserIdArr = array(); $toEmailId = ''; $toEmailName = ''; foreach ($employeeDetailsArr as $emp) { array_push($empArr, $emp['emailaddress']); //preparing Bcc array array_push($empUserIdArr, $emp['user_id']); if ($emp['user_id'] == $employeeid) { $toEmailId = $emp['emailaddress']; $toEmailName = $emp['userfullname']; $toEmpId = $emp['employeeId']; array_pop($empArr); } } $index = array_search($employeeid, $empUserIdArr); unset($employeeDetailsArr[$index]); $mail_str = ''; for ($j = 0; $j < sizeof($mgr_array); $j++) { foreach ($employeeDetailsArr as $employee) { if ($mgr_array[$j] == $employee['user_id']) { $profile_pic = $employee['profileimg']; $cnt = $j + 1; if ($profile_pic != '') { $src = DOMAIN . "public/uploads/profile/" . $profile_pic; } else { $src = MEDIA_PATH . "images/default-profile-pic.jpg"; } $mail_str .= "<div style='padding:20px 0 0 0;color:#3b3b3b;'>Line {$cnt} Manager : " . $employee['userfullname'] . " <img src=" . $src . " onError=this.src=" . MEDIA_PATH . "images/default-profile-pic.jpg width='30px' height='30px' /></div>"; } } } } //pushing loginUserEmail to Bcc array array_push($empArr, $loginUserEmail); $options['subject'] = APPLICATION_NAME . ': Change in Line Managers'; $options['header'] = 'Performance Appraisal : ' . $to_year; $options['bcc'] = $empArr; $options['toEmail'] = $toEmailId; $options['toName'] = $toEmailName; $options['message'] = "<div style='padding: 0; text-align: left; font-size:14px; font-family:Arial, Helvetica, sans-serif;'>\t\t\t\t\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t<span style='color:#3b3b3b;'>Hi,</span><br />\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t<div style='padding:20px 0 0 0;color:#3b3b3b;'>Line Managers for " . $toEmailName . "(" . $toEmpId . ") have been modified by " . $loginUsername . $emp_id_str . "</div>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t{$mail_str}\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t<div style='padding:20px 0 10px 0;'>Please <a href=" . BASE_URL . " target='_blank' style='color:#b3512f;'>click here</a> to login to your <b>" . APPLICATION_NAME . "</b> account and check the details.</div>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t</div> "; $mail_id = sapp_Global::_sendEmail($options); /** * End mails sending */ } $trDb->commit(); } catch (Exception $e) { $trDb->rollBack(); $result['result'] = 'error'; $result['msg'] = $e->getMessage(); } } $this->_helper->json($result); }
public function submitmanagerAction() { $auth = Zend_Auth::getInstance(); if ($auth->hasIdentity()) { $loginUserId = $auth->getStorage()->read()->id; $loginuserRole = $auth->getStorage()->read()->emprole; $loginuserGroup = $auth->getStorage()->read()->group_id; $loginuserFullname = $auth->getStorage()->read()->userfullname; $loginuserEmail = $auth->getStorage()->read()->emailaddress; $loginUserEmpId = $auth->getStorage()->read()->employeeId; } $post_values = $this->getRequest()->getPost(); $result = array('status' => 'fail', 'msg' => 'Something went wrong, please try again.'); $questions = ''; if (count($post_values) > 0) { $appraisal_id = $post_values['appraisal_id']; $manager_id = $post_values['manager_id']; if ($appraisal_id != '' && $manager_id != '') { $appraisal_id = sapp_Global::_decrypt($appraisal_id); $manager_id = sapp_Global::_decrypt($manager_id); $trDb = Zend_Db_Table::getDefaultAdapter(); $trDb->beginTransaction(); try { $app_init_model = new Default_Model_Appraisalinit(); $appraisalPrivMainModel = new Default_Model_Appraisalqsmain(); $qsdataArr = $appraisalPrivMainModel->getAppraisalQuestionsMain($appraisal_id); if (!empty($qsdataArr)) { foreach ($qsdataArr as $qs) { if (!empty($qs['manager_qs'])) { $questions .= $qs['manager_qs'] . ','; } } $questions = rtrim($questions, ','); } $questions = implode(',', array_keys(array_flip(explode(',', $questions)))); $submit_manager = $app_init_model->submitmanager($appraisal_id, $manager_id); sapp_PerformanceHelper::update_QsParmas_Allemps($questions, ''); /* * Logs Storing */ $actionflag = ''; $tableid = ''; $menuID = APPRAISAL_MANAGER; $actionflag = 1; sapp_Global::logManager($menuID, $actionflag, $loginUserId, $tableid); /* * Logs storing ends */ //to get initialization details using appraisal Id for Business Unit,Department,To Year $appraisalratingsmodel = new Default_Model_Appraisalratings(); $appraisal_details = $appraisalratingsmodel->getappdata($appraisal_id); if (!empty($appraisal_details)) { $bunit = $appraisal_details['unitname']; $dept = $appraisal_details['deptname']; $to_year = $appraisal_details['to_year']; } /** Start * Sending Mails to employees */ $appraisalconfigmodel = new Default_Model_Appraisalconfig(); $app_manager_model = new Default_Model_Appraisalmanager(); $getBunit_dept = $app_manager_model->getBunitDept($appraisal_id); if (!empty($getBunit_dept)) { $unitID = $getBunit_dept['businessunit_id']; $deptID = $getBunit_dept['department_id']; } $employeeDetailsArr = $appraisalconfigmodel->getUserDetailsByID($unitID, $deptID); $dept_str = $dept == '' ? " " : "and <b>{$dept}</b> department"; $emp_id_str = $loginuserRole == SUPERADMINROLE ? " " : "({$loginUserEmpId})"; $empArr = array(); if (!empty($employeeDetailsArr)) { $empArrList = ''; foreach ($employeeDetailsArr as $emp) { array_push($empArr, $emp['emailaddress']); } } // Sending mail to HR $options['subject'] = APPLICATION_NAME . ': Manager Appraisal Submitted.'; $options['header'] = 'Performance Appraisal : Manager Appraisal ' . $to_year; $options['toEmail'] = $loginuserEmail; $options['bcc'] = $empArr; $options['toEmail'] = $loginuserEmail; $options['toName'] = $loginuserFullname; $options['message'] = "<div style='padding: 0; text-align: left; font-size:14px; font-family:Arial, Helvetica, sans-serif;'>\t\t\t\t\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t<span style='color:#3b3b3b;'>Hi,</span><br />\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t<div style='padding:20px 0 0 0;color:#3b3b3b;'> " . $loginuserFullname . $emp_id_str . " has submitted the Manager appraisal form for the year <b>{$to_year}</b> for <b>{$bunit}</b> business unit {$dept_str} </div>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t<div style='padding:20px 0 10px 0;'>Please <a href=" . BASE_URL . " target='_blank' style='color:#b3512f;'>click here</a> to login to your <b>" . APPLICATION_NAME . "</b> account and check the details.</div>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t</div> "; $mail_id = sapp_Global::_sendEmail($options); /** * End */ $trDb->commit(); $result['status'] = 'success'; $result['msg'] = "Submitted successfully"; $this->_helper->getHelper("FlashMessenger")->addMessage(array("success" => "Initialization Submitted successfully. ")); } catch (Exception $e) { $trDb->rollBack(); $result['status'] = 'error'; $result['msg'] = $e->getMessage(); } } } $this->_helper->json($result); }
public function save($requisitionform, $data) { $auth = Zend_Auth::getInstance(); if ($auth->hasIdentity()) { $loginUserId = $auth->getStorage()->read()->id; $loginuserGroup = $auth->getStorage()->read()->group_id; } $requi_model = new Default_Model_Requisition(); $user_model = new Default_Model_Usermanagement(); $req_status = $this->_getParam('req_status', null); $flag = 'true'; if ($requisitionform->isValid($this->_request->getPost()) && $flag != 'false') { $id = $this->_getParam('id', null); $req_status = $this->_getParam('req_status', null); $onboard_date = $this->_getParam('onboard_date', null); $data = array('req_status' => $req_status, 'modifiedby' => trim($loginUserId), 'modifiedon' => gmdate("Y-m-d H:i:s")); if ($onboard_date != '') { $data = $data + array('onboard_date' => sapp_Global::change_date($onboard_date, 'database')); } $where = "id = " . $id; $result = $requi_model->SaveorUpdateRequisitionData($data, $where); $tableid = $id; $actionflag = 2; if ($result != '') { if ($req_status == 'Complete' || $req_status == 'Closed') { $requi_model->change_to_requisition_closed($id); $requisition_data = $requi_model->getReqDataForView($id); $requisition_data = $requisition_data[0]; $report_person_data = $user_model->getUserDataById($requisition_data['createdby']); $closed_person_data = $user_model->getUserDataById($loginUserId); $mail_arr[0]['name'] = 'HR'; $requisition_data['businessunit_id']; $mail_arr[0]['email'] = defined('REQ_HR_' . $requisition_data['businessunit_id']) ? constant('REQ_HR_' . $requisition_data['businessunit_id']) : ""; $mail_arr[0]['type'] = 'HR'; $mail_arr[1]['name'] = 'Management'; $mail_arr[1]['email'] = defined('REQ_MGMT_' . $requisition_data['businessunit_id']) ? constant('REQ_MGMT_' . $requisition_data['businessunit_id']) : ""; $mail_arr[1]['type'] = 'Management'; $mail_arr[2]['name'] = $report_person_data['userfullname']; $mail_arr[2]['email'] = $report_person_data['emailaddress']; $mail_arr[2]['type'] = 'Raise'; for ($ii = 0; $ii < count($mail_arr); $ii++) { $base_url = 'http://' . $this->getRequest()->getHttpHost() . $this->getRequest()->getBaseUrl(); $view = $this->getHelper('ViewRenderer')->view; $this->view->emp_name = $mail_arr[$ii]['name']; $this->view->base_url = $base_url; $this->view->type = $mail_arr[$ii]['type']; $this->view->requisition_code = $requisition_data['requisition_code']; $this->view->req_status = $status = strtolower($req_status == 'Complete' ? "Completed" : $req_status); $this->view->raised_name = $report_person_data['userfullname']; $this->view->approver_str = $closed_person_data['userfullname']; $text = $view->render('mailtemplates/changedrequisition.phtml'); $options['subject'] = APPLICATION_NAME . ': Requisition is ' . $status; $options['header'] = 'Requisition is ' . $status; $options['toEmail'] = $mail_arr[$ii]['email']; $options['toName'] = $mail_arr[$ii]['name']; $options['message'] = $text; $options['cron'] = 'yes'; sapp_Global::_sendEmail($options); } } $menumodel = new Default_Model_Menu(); $objidArr = $menumodel->getMenuObjID('/approvedrequisitions'); $objID = $objidArr[0]['id']; $result = sapp_Global::logManager($objID, $actionflag, $loginUserId, $tableid); if ($id != '') { $this->_helper->getHelper("FlashMessenger")->addMessage(array("success" => "Requisition updated successfully.")); } else { $this->_helper->getHelper("FlashMessenger")->addMessage(array("success" => "Requisition added successfully.")); } $this->_redirect('/approvedrequisitions'); } } else { $messages = $requisitionform->getMessages(); $msgarray = array(); foreach ($messages as $key => $val) { foreach ($val as $key2 => $val2) { $msgarray[$key] = $val2; break; } } return $msgarray; } }
/** * This action is used to send notification to inactive users. */ public function inactiveusersAction() { $this->_helper->viewRenderer->setNoRender(true); $this->_helper->layout()->disableLayout(); $email_model = new Default_Model_EmailLogs(); $cron_model = new Default_Model_Cronstatus(); $cron_status = $cron_model->getActiveCron('Inactive users'); if ($cron_status == 'yes') { try { //updating cron status table to in-progress $cron_data = array('cron_status' => 1, 'cron_type' => 'Inactive users', 'started_at' => gmdate("Y-m-d H:i:s")); $cron_id = $cron_model->SaveorUpdateCronStatusData($cron_data, ''); if ($cron_id != '') { $calc_date = new DateTime(date('Y-m-d')); $calc_date->sub(new DateInterval('P3M')); $print_date = $calc_date->format(DATEFORMAT_PHP); $calc_date = $calc_date->format('Y-m-d'); $mail_data = $email_model->getInactiveusersData($calc_date); if (count($mail_data) > 0) { foreach ($mail_data as $did => $mdata) { $base_url = 'http://' . $this->getRequest()->getHttpHost() . $this->getRequest()->getBaseUrl(); $view = $this->getHelper('ViewRenderer')->view; $this->view->emp_name = $mdata['userfullname']; $this->view->print_date = $print_date; $this->view->user_id = $mdata['employeeId']; $this->view->base_url = $base_url; $text = $view->render('mailtemplates/inactiveusercron.phtml'); $options['subject'] = APPLICATION_NAME . ': Sentrifugo account inactivated'; $options['header'] = 'Employee inactivated'; $options['toEmail'] = $mdata['emailaddress']; $options['toName'] = $mdata['userfullname']; $options['message'] = $text; $options['cron'] = 'yes'; sapp_Global::_sendEmail($options); } } $cron_data = array('cron_status' => 0, 'completed_at' => gmdate("Y-m-d H:i:s")); $cron_id = $cron_model->SaveorUpdateCronStatusData($cron_data, "id = " . $cron_id); } //end of cron status id if } catch (Exception $e) { } } //end of cron status if }
public function forcedfullupdateAction() { $baseUrl = BASE_URL; $baseUrl = rtrim($baseUrl, '/'); $auth = Zend_Auth::getInstance(); if ($auth->hasIdentity()) { $loginUserId = $auth->getStorage()->read()->id; } Zend_Layout::getMvcInstance()->setLayoutPath(APPLICATION_PATH . "/layouts/scripts/popup/"); $specimenId = $this->_request->getParam('specimenId'); $empFlag = $this->_request->getParam('empFlag'); $count = intval($this->_request->getParam('count')); $username = ''; $empscreeningModel = new Default_Model_Empscreening(); $getAllRecords = $empscreeningModel->checkbgstatus($specimenId, $empFlag, 'completedata'); $username = $getAllRecords[0]['username']; if (isset($getAllRecords[0]['rmanager_email'])) { $reportmanagerEmail = $getAllRecords[0]['rmanager_email']; } else { $reportmanagerEmail = ''; } if (isset($getAllRecords[0]['reporting_manager'])) { $reportmanagername = $getAllRecords[0]['reporting_manager']; } else { $reportmanagername = ''; } if ($count == '') { $this->view->dataArray = $getAllRecords; } $close = ''; if ($count != '') { for ($i = 0; $i < $count; $i++) { $id = intval($this->_request->getParam('id' . $i)); $explanation = $this->_request->getParam('text' . $i); $date = new Zend_Date(); $data = array('process_status' => 'Complete', 'explanation' => $explanation, 'modifiedby' => $loginUserId, 'modifieddate' => gmdate("Y-m-d H:i:s")); $where = array('specimen_id=?' => $specimenId, 'flag=?' => $empFlag, 'process_status=?' => 'In process', 'id=?' => $id); $detailId = $empscreeningModel->SaveorUpdateDetails($data, $where); $where = array('specimen_id=?' => $specimenId, 'flag=?' => $empFlag, 'process_status' => 'On hold', 'id=?' => $id); $detailId = $empscreeningModel->SaveorUpdateDetails($data, $where); if ($detailId == 'update') { $tableid = $id; } else { $tableid = $detailId; } $actionflag = 2; $menuID = EMPSCREENING; $result = sapp_Global::logManager($menuID, $actionflag, $loginUserId, $specimenId . '-' . $empFlag); } $bgdata = array('bgcheck_status' => 'Complete', 'modifiedby' => $loginUserId, 'modifieddate' => gmdate("Y-m-d H:i:s")); $where = array('specimen_id=?' => $specimenId, 'flag=?' => $empFlag, 'isactive = 1'); $actionflag = 2; $detailId = $empscreeningModel->SaveorUpdateDetails($bgdata, $where); /* Updating back ground check status to Completed in employees/candidates status */ if ($empFlag == 1) { $usermodel = new Default_Model_Users(); $empData = array('backgroundchk_status' => 'Completed', 'modifiedby' => $loginUserId, 'modifieddate' => gmdate("Y-m-d H:i:s")); $empWhere = array('id=?' => $specimenId); $usermodel->addOrUpdateUserModel($empData, $empWhere, $specimenId); } else { $candModel = new Default_Model_Candidatedetails(); $candData = array('backgroundchk_status' => 'Completed', 'modifiedby' => $loginUserId, 'modifieddate' => gmdate("Y-m-d H:i:s")); $candWhere = array('id=?' => $specimenId); $candModel->SaveorUpdateUserData($candData, $candWhere); } /* END */ /* Mail to HRD, L1 and L2 managers*/ $personalData = $empscreeningModel->getEmpPersonalData($specimenId, $empFlag); $bid = ''; if (isset($personalData[0]['businessid'])) { $bid = $personalData[0]['businessid']; } if (isset($reportmanagerEmail) && $reportmanagerEmail != '') { $manager1 = array($reportmanagerEmail); } else { $manager1 = array(); } if (defined('BG_CHECKS_MNGMNT_' . $bid) && $bid != '') { $mngmntemailId = explode(",", constant('BG_CHECKS_MNGMNT_' . $bid)); } else { $mngmntemailId = array(); } if (defined('BG_CHECKS_HR_' . $bid) && $bid != '') { $hremailId = explode(",", constant('BG_CHECKS_HR_' . $bid)); } else { $hremailId = array(); } $emailArr = array_merge($manager1, $mngmntemailId, $hremailId); for ($i = 0; $i < sizeof($emailArr); $i++) { $salutation = 'Dear Sir/Madam,'; if ($i == 0) { $salutation = 'Dear ' . ucfirst($reportmanagername) . ','; $options['toName'] = ucfirst($reportmanagername); } else { if ($i == 1) { $salutation = 'Dear Management,'; $options['toName'] = 'Management'; } else { if ($i == 2) { $salutation = 'Dear HR,'; $options['toName'] = 'HR'; } } } $options['subject'] = APPLICATION_NAME . ' :: Background check'; $options['header'] = 'Background check completed'; $options['toEmail'] = $emailArr[$i]; $options['message'] = '<div>' . $salutation . '<div>The background check for ' . ucfirst($username) . ' has been completed.'; if (!empty($personalData[0]['employee_id'])) { $options['message'] .= ' Please find the details below.</div> <div> <table border="1" style="border-collapse:collapse;"> <tr><td>Employee ID</td><td>' . $getAllRecords[0]['employee_id'] . '</td></tr> <tr><td>Employee Email</td><td>' . $getAllRecords[0]['email_id'] . '</td></tr> <tr><td>Employee Designation</td><td>' . $getAllRecords[0]['designation'] . '</td></tr> </table> </div>'; } $options['message'] .= '<div style="padding:20px 0 10px 0;">Please <a href="' . $baseUrl . '/index/popup" target="_blank" style="color:#b3512f;">click here</a> to login and check the details.</div> </div>'; $options['cron'] = 'yes'; $result = sapp_Global::_sendEmail($options); } /* END */ $updateresult['result'] = 'saved'; $updateresult['popup'] = 'close'; $this->_helper->json($updateresult); } }
public static function process_emp_excel($file_name) { require_once 'Classes/PHPExcel.php'; require_once 'Classes/PHPExcel/IOFactory.php'; $auth = Zend_Auth::getInstance(); if ($auth->hasIdentity()) { $loginUserId = $auth->getStorage()->read()->id; } $emp_model = new Default_Model_Employee(); $usersModel = new Default_Model_Usermanagement(); $identity_code_model = new Default_Model_Identitycodes(); $objReader = PHPExcel_IOFactory::createReaderForFile($file_name); $objPHPExcel = $objReader->load($file_name); //Read first sheet $sheet = $objPHPExcel->getSheet(0); // Get worksheet dimensions $sizeOfWorksheet = $sheet->getHighestDataRow(); $highestColumn = $sheet->getHighestDataColumn(); if ($sizeOfWorksheet > 1) { $arrReqHeaders = array('Prefix', 'First name', 'Last name', 'Role Type', 'Email', 'Business Unit', 'Department', 'Reporting manager', 'Job Title', 'Position', 'Employment Status', 'Date of joining', 'Date of leaving', 'Experience', 'Extension', 'Work telephone number', 'Fax'); //Get first/header from excel $firstRow = $sheet->rangeToArray('A' . 1 . ':' . $highestColumn . 1, NULL, TRUE, TRUE); $arrGivenHeaders = $firstRow[0]; $diffArray = array_diff_assoc($arrReqHeaders, $arrGivenHeaders); $prefix_arr = $emp_model->getPrefix_emp_excel(); $roles_arr = $emp_model->getRoles_emp_excel(); $bu_arr = $emp_model->getBU_emp_excel(); $dep_arr = $emp_model->getDep_emp_excel(); $job_arr = $emp_model->getJobs_emp_excel(); $positions_arr = $emp_model->getPositions_emp_excel(); $users_arr = $emp_model->getUsers_emp_excel(); $emp_stat_arr = $emp_model->getEstat_emp_excel(); $dol_emp_stat_arr = $emp_model->getDOLEstat_emp_excel(); $mng_roles_arr = $emp_model->getMngRoles_emp_excel(); $emps_arr = $emp_model->getEmps_emp_excel(); $emails_arr = $emps_arr['email']; $emp_ids_arr = $emps_arr['ids']; $emp_depts_arr = $emp_model->getEmpsDeptWise(); $dept_bu_arr = $emp_model->getDeptBUWise(); $pos_jt_arr = $emp_model->getPosJTWise(); $identity_codes = $identity_code_model->getIdentitycodesRecord(); $emp_identity_code = isset($identity_codes[0]) ? $identity_codes[0]['employee_code'] : ""; $trDb = Zend_Db_Table::getDefaultAdapter(); // starting transaction $trDb->beginTransaction(); try { //start of validations $ex_prefix_arr = array(); //$ex_fullname_arr = array(); $ex_firstname_arr = array(); $ex_lastname_arr = array(); $ex_role_arr = array(); $ex_email_arr = array(); $ex_bu_arr = array(); $ex_dep_arr = array(); $ex_rm_arr = array(); $ex_jt_arr = array(); $ex_pos_arr = array(); $ex_es_arr = array(); $ex_doj_arr = array(); $ex_dol_arr = array(); $ex_exp_arr = array(); $ex_ext_arr = array(); $ex_wn_arr = array(); $ex_fax_arr = array(); $tot_rec_cnt = 0; $err_msg = ""; for ($i = 2; $i <= $sizeOfWorksheet; $i++) { $rowData_org = $sheet->rangeToArray('A' . $i . ':' . $highestColumn . $i, NULL, TRUE, TRUE); $rowData = $rowData_org[0]; $rowData_cpy = $rowData; foreach ($rowData_cpy as $rkey => $rvalue) { $rowData[$rkey] = trim($rvalue); } //start of mandatory checking if (empty($rowData[0])) { $err_msg = "Prefix cannot be empty at row " . $i . "."; break; } /* if(empty($rowData[1])) { $err_msg = "Full Name cannot be empty at row ".$i."."; break; }*/ if (empty($rowData[1])) { $err_msg = "First name cannot be empty at row " . $i . "."; break; } if (empty($rowData[2])) { $err_msg = "Last name cannot be empty at row " . $i . "."; break; } if (empty($rowData[3])) { $err_msg = "Role type cannot be empty at row " . $i . "."; break; } if (empty($rowData[4])) { $err_msg = "Email cannot be empty at row " . $i . "."; break; } if (empty($rowData[7])) { $err_msg = "Reporting manager cannot be empty at row " . $i . "."; break; } if (empty($rowData[8])) { $err_msg = "Job title cannot be empty at row " . $i . "."; break; } if (empty($rowData[9])) { $err_msg = "Position cannot be empty at row " . $i . "."; break; } if (empty($rowData[10])) { $err_msg = "Employment status cannot be empty at row " . $i . "."; break; } if (empty($rowData[11])) { $err_msg = "Date of joining cannot be empty at row " . $i . "."; break; } if (!in_array($rowData[3], $mng_roles_arr) && empty($rowData[6])) { $err_msg = "Department cannot be empty at row " . $i . "."; break; } if (in_array($rowData[10], $dol_emp_stat_arr) && empty($rowData[12])) { $err_msg = "Date of leaving cannot be empty at row " . $i . "."; break; } if (!in_array($rowData[10], $dol_emp_stat_arr) && !empty($rowData[12]) && in_array($rowData[10], $emp_stat_arr)) { $err_msg = "Date of leaving must be empty for '" . $rowData[10] . "' at row " . $i . "."; break; } // end of mandatory checking // start of pattern checking if (!preg_match("/^(?=.*[a-zA-Z])([^ ][a-zA-Z0-9 ]*)\$/", trim($rowData[0])) && !empty($rowData[0])) { $err_msg = "Prefix is not a valid format at row " . $i . "."; break; } /* if (!preg_match("/^([a-zA-Z.]+ ?)+$/", $rowData[1]) && !empty($rowData[1])) { $err_msg = "Full Name is not a valid format at row ".$i."."; break; }*/ if (!preg_match("/^([a-zA-Z.]+ ?)+\$/", $rowData[1]) && !empty($rowData[1])) { $err_msg = "First name is not a valid format at row " . $i . "."; break; } if (!preg_match("/^([a-zA-Z.]+ ?)+\$/", $rowData[2]) && !empty($rowData[2])) { $err_msg = "Last name is not a valid format at row " . $i . "."; break; } if (!preg_match("/^[a-zA-Z]+?\$/", $rowData[3]) && !empty($rowData[3])) { $err_msg = "Role type is not a valid format at row " . $i . "."; break; } if (!preg_match("/^(?!.*\\.{2})[a-zA-Z0-9_.+-]+@[a-zA-Z0-9-]+\\.[a-zA-Z0-9-.]+\$/", $rowData[4]) && !empty($rowData[4])) { $err_msg = "Email is not a valid format at row " . $i . "."; break; } if (!preg_match("/^[a-zA-Z0-9\\&\\'\\.\\s]+\$/", $rowData[5]) && !empty($rowData[5])) { $err_msg = "Business unit is not a valid format at row " . $i . "."; break; } if (!preg_match("/^[a-zA-Z0-9\\&\\'\\.\\s]+\$/", $rowData[6]) && !empty($rowData[6])) { $err_msg = "Department is not a valid format at row " . $i . "."; break; } if (!preg_match("/^[a-zA-Z0-9\\&\\'\\.\\s]+\$/", $rowData[7]) && !empty($rowData[7])) { $err_msg = "Reporting manager is not a valid format at row " . $i . "."; break; } if (!preg_match("/^[a-zA-Z][a-zA-Z0-9\\s]*\$/", $rowData[8]) && !empty($rowData[8])) { $err_msg = "Job title is not a valid format at row " . $i . "."; break; } if (!preg_match("/^[a-zA-Z][a-zA-Z0-9\\-\\s]*\$/i", $rowData[9]) && !empty($rowData[9])) { $err_msg = "Position is not a valid format at row " . $i . "."; break; } if (!preg_match("/^(?=.*[a-zA-Z])([^ ][a-zA-Z0-9 ]*)\$/", $rowData[10]) && !empty($rowData[10])) { $err_msg = "Employment status is not a valid format at row " . $i . "."; break; } if (!empty($rowData[11])) { try { $test_doj = new DateTime($rowData[11]); } catch (Exception $ex) { return array('status' => 'error', 'msg' => "Date of joining is not a valid format at row " . $i . "."); } } if (!empty($rowData[12])) { try { $test_dol = new DateTime($rowData[12]); } catch (Exception $ex) { return array('status' => 'error', 'msg' => "Date of leaving is not a valid format at row " . $i . "."); } } if (!empty($rowData[12]) && $rowData[12] < $rowData[11]) { $err_msg = "Date of leaving must be greater than date of joining at row " . $i . "."; break; } if (!preg_match("/^[0-9]\\d{0,1}(\\.\\d*)?\$/", $rowData[13]) && !empty($rowData[13])) { $err_msg = "Experience is not a valid format at row " . $i . "."; break; } if (!preg_match("/^[0-9]+\$/", $rowData[14]) && !empty($rowData[14])) { $err_msg = "Extension is not a valid format at row " . $i . "."; break; } if (!preg_match("/^(?!0{10})[0-9\\+\\-\\)\\(]+\$/", $rowData[15]) && !empty($rowData[15])) { $err_msg = "Work telephone number is not a valid format at row " . $i . "."; break; } if (!preg_match("/^[0-9\\+\\-\\)\\(]+\$/", $rowData[16]) && !empty($rowData[16])) { $err_msg = "Fax is not a valid format at row " . $i . "."; break; } // end of pattern checking // start of checking existence in the system. if (!array_key_exists(strtolower($rowData[0]), $prefix_arr) && !empty($rowData[0])) { $err_msg = "Unknown prefix at row " . $i . "."; break; } if (!array_key_exists(strtolower($rowData[3]), $roles_arr) && !empty($rowData[3])) { $err_msg = "Unknown role type at row " . $i . "."; break; } if (!array_key_exists(strtolower($rowData[5]), $bu_arr) && !empty($rowData[5])) { $err_msg = "Unknown business unit at row " . $i . "."; break; } if (!array_key_exists(strtolower($rowData[6]), $dep_arr) && !empty($rowData[6])) { $err_msg = "Unknown department at row " . $i . "."; break; } if (in_array(strtolower($rowData[4]), $emails_arr) && !empty($rowData[4])) { $err_msg = "Email already exists at row " . $i . "."; break; } if (!in_array(strtolower($rowData[7]), $emp_ids_arr) && !empty($rowData[7])) { $err_msg = "Unknown reporting manager at row " . $i . "."; break; } if (!array_key_exists(strtolower($rowData[8]), $job_arr) && !empty($rowData[8])) { $err_msg = "Unknown job title at row " . $i . "."; break; } if (!array_key_exists(strtolower($rowData[9]), $positions_arr) && !empty($rowData[9])) { $err_msg = "Unknown position at row " . $i . "."; break; } if (!array_key_exists(strtolower($rowData[10]), $emp_stat_arr) && !empty($rowData[10])) { $err_msg = "Unknown employment status at row " . $i . "."; break; } // end of checking existence in the system. if (!empty($rowData[6])) { if (isset($emp_depts_arr[$dep_arr[strtolower($rowData[6])]]) && !in_array(strtolower($rowData[7]), $emp_depts_arr[$dep_arr[strtolower($rowData[6])]])) { if (isset($emp_depts_arr[0]) && is_array($emp_depts_arr[0])) { if (!in_array(strtolower($rowData[7]), $emp_depts_arr[0])) { $err_msg = "Reporting manager is not belongs to '" . $rowData[6] . "' department at row " . $i . "."; break; } } } } else { if (isset($emp_depts_arr[0]) && is_array($emp_depts_arr[0])) { if (!in_array(strtolower($rowData[7]), $emp_depts_arr[0])) { $err_msg = "Reporting manager is not belongs to management group at row " . $i . "."; break; } } } if (!empty($rowData[6])) { if (isset($dept_bu_arr[0]) && is_array($dept_bu_arr[0])) { if (in_array(strtolower($rowData[6]), $dept_bu_arr[0]) && !empty($rowData[5])) { $err_msg = "Business unit not needed for this department '" . $rowData[6] . "' at row " . $i . "."; break; } if (!in_array(strtolower($rowData[6]), $dept_bu_arr[0]) && empty($rowData[5])) { $err_msg = "Business unit cannot be empty at row " . $i . "."; break; } } if (!empty($rowData[5])) { if (isset($dept_bu_arr[$bu_arr[strtolower($rowData[5])]]) && !in_array(strtolower($rowData[6]), $dept_bu_arr[$bu_arr[strtolower($rowData[5])]]) && !empty($rowData[5])) { $err_msg = "Department is not belongs to '" . $rowData[5] . "' business unit at row " . $i . "."; break; } } } if (!empty($rowData[8]) && !empty($rowData[9])) { if (isset($pos_jt_arr[$job_arr[strtolower($rowData[8])]]) && !in_array(strtolower($rowData[9]), $pos_jt_arr[$job_arr[strtolower($rowData[8])]]) && !empty($rowData[8])) { $err_msg = "Position is not belongs to '" . $rowData[8] . "' job title at row " . $i . "."; break; } } } //end of for loop if (!empty($err_msg)) { return array('status' => 'error', 'msg' => $err_msg); } $err_msg = ""; for ($i = 2; $i <= $sizeOfWorksheet; $i++) { $rowData_org = $sheet->rangeToArray('A' . $i . ':' . $highestColumn . $i, NULL, TRUE, TRUE); $rowData = $rowData_org[0]; $rowData_cpy = $rowData; foreach ($rowData_cpy as $rkey => $rvalue) { $rowData[$rkey] = trim($rvalue); } $ex_prefix_arr[] = $rowData[0]; //$ex_fullname_arr[] = $rowData[1]; $ex_firstname_arr[] = $rowData[1]; $ex_lastname_arr[] = $rowData[2]; $ex_role_arr[] = $rowData[3]; $ex_email_arr[$i] = $rowData[4]; $ex_bu_arr[] = $rowData[5]; $ex_dep_arr[] = $rowData[6]; $ex_rm_arr[] = $rowData[7]; $ex_jt_arr[] = $rowData[8]; $ex_pos_arr[] = $rowData[9]; $ex_es_arr[] = $rowData[10]; $ex_doj_arr[] = $rowData[11]; $ex_dol_arr[] = $rowData[12]; $ex_exp_arr[] = $rowData[13]; $ex_ext_arr[] = $rowData[14]; $ex_wn_arr[] = $rowData[15]; $ex_fax_arr[] = $rowData[16]; $tot_rec_cnt++; } foreach ($ex_email_arr as $key1 => $value1) { $d = 0; foreach ($ex_email_arr as $key2 => $value2) { if ($key1 != $key2 && $value1 == $value2) { $err_msg = "Duplicate email entry at row " . $key2 . "."; $d++; break; } } if ($d > 0) { break; } } if (!empty($err_msg)) { return array('status' => 'error', 'msg' => $err_msg); } //end of validations //start of saving if ($tot_rec_cnt > 0) { for ($i = 2; $i <= $sizeOfWorksheet; $i++) { $emp_id = $emp_identity_code . str_pad($usersModel->getMaxEmpId($emp_identity_code), 4, '0', STR_PAD_LEFT); $rowData_org = $sheet->rangeToArray('A' . $i . ':' . $highestColumn . $i, NULL, TRUE, TRUE); $rowData = $rowData_org[0]; $rowData_cpy = $rowData; foreach ($rowData_cpy as $rkey => $rvalue) { $rowData[$rkey] = trim($rvalue); } $emppassword = sapp_Global::generatePassword(); $date = new DateTime($rowData[11]); $date_of_joining = $date->format('Y-m-d'); $date_of_leaving = ""; if ($rowData[12] != '') { $ldate = new DateTime($rowData[12]); $date_of_leaving = $ldate->format('Y-m-d'); } $userfullname = $rowData[1] . ' ' . $rowData[2]; $user_data = array('emprole' => $roles_arr[strtolower($rowData[3])], 'userfullname' => $userfullname, 'firstname' => $rowData[1], 'lastname' => $rowData[2], 'emailaddress' => $rowData[4], 'jobtitle_id' => $job_arr[strtolower($rowData[8])], 'modifiedby' => $loginUserId, 'modifieddate' => gmdate("Y-m-d H:i:s"), 'emppassword' => md5($emppassword), 'employeeId' => $emp_id, 'modeofentry' => "Direct", 'selecteddate' => $date_of_joining, 'userstatus' => 'old'); $user_data['createdby'] = $loginUserId; $user_data['createddate'] = gmdate("Y-m-d H:i:s"); $user_data['isactive'] = 1; $user_id = $usersModel->SaveorUpdateUserData($user_data, ''); $data = array('user_id' => $user_id, 'reporting_manager' => $users_arr[strtolower($rowData[7])], 'emp_status_id' => $emp_stat_arr[strtolower($rowData[10])], 'businessunit_id' => !empty($rowData[4]) ? $bu_arr[strtolower($rowData[5])] : 0, 'department_id' => !empty($rowData[5]) ? $dep_arr[strtolower($rowData[6])] : null, 'jobtitle_id' => $job_arr[strtolower($rowData[8])], 'position_id' => $positions_arr[strtolower($rowData[9])], 'prefix_id' => $prefix_arr[strtolower($rowData[0])], 'extension_number' => $rowData[13] != '' ? $rowData[14] : NULL, 'office_number' => $rowData[14] != '' ? $rowData[15] : NULL, 'office_faxnumber' => $rowData[15] != '' ? $rowData[16] : NULL, 'date_of_joining' => $date_of_joining, 'date_of_leaving' => $date_of_leaving != '' ? $date_of_leaving : NULL, 'years_exp' => $rowData[13] == '' ? null : $rowData[13], 'modifiedby' => $loginUserId, 'modifieddate' => gmdate("Y-m-d H:i:s")); $data['createdby'] = $loginUserId; $data['createddate'] = gmdate("Y-m-d H:i:s"); $data['isactive'] = 1; $emp_model->SaveorUpdateEmployeeData($data, ''); $text = "<div style='padding: 0; text-align: left; font-size:14px; font-family:Arial, Helvetica, sans-serif;'>\t\t\t\t\n\t<span style='color:#3b3b3b;'>Hello " . ucfirst($userfullname) . ",</span><br />\n\t\n\t<div style='padding:20px 0 0 0;color:#3b3b3b;'>You have been added to " . APPLICATION_NAME . ". The login credentials for your Sentrifugo account are:</div>\n\t\n\t<div style='padding:20px 0 0 0;color:#3b3b3b;'>Username: <strong>" . $emp_id . "</strong></div>\n\t<div style='padding:5px 0 0 0;color:#3b3b3b;'>Password: <strong>" . $emppassword . "</strong></div>\n\t\n\t<div style='padding:20px 0 10px 0;'>Please <a href='" . DOMAIN . "index/popup' target='_blank' style='color:#b3512f;'>click here</a> to login to your Sentrifugo account.</div>\n\n</div>"; $options['subject'] = APPLICATION_NAME . ': Login Credentials'; $options['header'] = 'Greetings from Sentrifugo'; $options['toEmail'] = $rowData[4]; $options['toName'] = $userfullname; $options['message'] = $text; $options['cron'] = 'yes'; $result = sapp_Global::_sendEmail($options); } //end of for loop $trDb->commit(); return array('status' => "success", 'msg' => 'Employees saved successfully.'); } else { return array('status' => 'error', 'msg' => "No records to save."); } //end of saving } catch (Exception $e) { $trDb->rollBack(); return array('status' => 'error', 'msg' => "Something went wrong,please try again."); } } else { return array('status' => 'error', 'msg' => "No records to save."); } }
/** * * @param type $form * @param type $data * @return type */ public function save($form, $data) { $auth = Zend_Auth::getInstance(); if ($auth->hasIdentity()) { $loginUserId = $auth->getStorage()->read()->id; } $cand_model = new Default_Model_Candidatedetails(); $requi_model = new Default_Model_Requisition(); $interview_model = new Default_Model_Interviewdetails(); $user_model = new Default_Model_Usermanagement(); $interview_round_model = new Default_Model_Interviewrounddetails(); $form->round_status->setRequired(false); $form->interview_feedback->setRequired(false); $cand_status = $this->_getParam('cand_status', null); $interview_status = $this->_getParam('interview_status', null); $flag = 'true'; if ($interview_status == 'On hold' && $cand_status != 'On hold') { $msgarray['statusErr'] = 'Since the interview status is onhold, the candidate status should be onhold.'; $flag = 'false'; } if ($interview_status == 'Completed' && ($cand_status != 'Disqualified' && $cand_status != 'Shortlisted')) { $msgarray['statusErr'] = 'Since interview status is completed, the candidate status can be either disqualified or shortlisted.'; $flag = 'false'; } if ($interview_status == 'In process' && ($cand_status == 'Disqualified' || $cand_status == 'Shortlisted')) { $msgarray['statusErr'] = 'Since the interview status is in process, the candidate cannot be shortlisted or disqualified.'; $flag = 'false'; } if ($form->isValid($this->_request->getPost()) && $flag != 'false') { $id = $this->_getParam('id', null); $requisition_id = $this->_getParam('req_id', null); $candidate_id = $this->_getParam('candidate_name', null); $interviewer_ids = $this->_getParam('interviewer_id', null); $interview_panel = implode(",", $interviewer_ids); $interviewer_id = 0; foreach ($interviewer_ids as $interview) { $interviewer_id = $interview; break; } $int_location = $this->_getParam('int_location', null); $country = $this->_getParam('country', null); $state = $this->_getParam('state', null); $city = $this->_getParam('city', null); $interview_mode = $this->_getParam('interview_mode', null); $interview_type_details = $this->_getParam('interview_Type_Details', null); $interview_time = $this->_getParam('interview_time', null); $interview_date = $this->_getParam('interview_date', null); $interview_round = $this->_getParam('interview_round', null); if (!isset($candidate_id)) { $candidate_id = $data['id']; } if (empty($data)) { $getExistingCandidateRecord = $interview_model->getCandidateInInterviewProcess(trim($candidate_id)); if ($getExistingCandidateRecord > 0) { $this->_helper->FlashMessenger()->setNamespace('success')->addMessage('Interview already scheduled for this candidate.'); $this->_redirect('/scheduleinterviews'); } } if (empty($data)) { $idata = array('req_id' => $requisition_id, 'candidate_id' => trim($candidate_id), 'interview_status' => trim($interview_status), 'isactive' => 1, 'createdby' => trim($loginUserId), 'modifiedby' => trim($loginUserId), 'createddate' => gmdate("Y-m-d H:i:s"), 'modifieddate' => gmdate("Y-m-d H:i:s")); $idata['interview_status'] = 'In process'; $iwhere = ""; $actionflag = 1; $iresult = $interview_model->SaveorUpdateInterviewData($idata, $iwhere); if ($id == '') { $tableid = $iresult; } if ($iresult != '') { $irdata = array('interview_id' => $iresult, 'req_id' => $requisition_id, 'candidate_id' => $candidate_id, 'interviewer_id' => $interviewer_id, 'interview_time' => sapp_Global::change_time(trim($interview_time), 'database'), 'interview_date' => sapp_Global::change_date($interview_date, 'database'), 'interview_mode' => $interview_mode, 'interview_mode_details' => $interview_type_details, 'interview_round_number' => 1, 'interview_round' => trim($interview_round), 'int_location' => trim($int_location), 'int_country' => trim(intval($country)), 'int_state' => trim(intval($state)), 'int_city' => trim(intval($city)), 'isactive' => 1, 'createdby' => trim($loginUserId), 'modifiedby' => trim($loginUserId), 'createddate' => gmdate("Y-m-d H:i:s"), 'modifieddate' => gmdate("Y-m-d H:i:s"), 'interview_panel' => $interview_panel); $ir_result = $interview_round_model->SaveorUpdateInterviewroundData($irdata, ''); $requisition_data = $requi_model->getRequisitionDataById($requisition_id); $cand_data = $cand_model->getCandidateById($candidate_id); $hrgroupemail = $requi_model->getgroupemailid("REQ_HR", $requisition_data["department_id"]); $requisition_data = $requi_model->getrequisitiondetails($requisition_id); $requesteremailaddress = $requi_model->getemployeeemailaddress($requisition_data["createdby"]); $reportingmanageremailaddress = $requi_model->getemployeeemailaddress($requisition_data["reporting_id"]); $mail_arr = array('HR' => $hrgroupemail["groupEmail"], $requesteremailaddress['userfullname'] => $requesteremailaddress['emailaddress'], $reportingmanageremailaddress['userfullname'] => $reportingmanageremailaddress['emailaddress']); $loginuser_person_data = $user_model->getUserDataById($loginUserId); $interview_panel = $interview_panel . "," . $loginUserId; $interviewpanelnamesemailaddresss = $requi_model->GetInterviewPanelMamesEmailaddress($interview_panel); /* $emailtemp = array(); $nametemp = array(); foreach ($interviewpanelnamesemailaddress as $row) { array_push($emailtemp, $row['emailaddress']); array_push($nametemp, $row['userfullname']); } $email = implode(";", $emailtemp); $ename = implode(";", $nametemp); */ $cal_unique_id = $this->getCalendarUniqueID(); foreach ($interviewpanelnamesemailaddresss as $interviewpanelnamesemailaddress) { $description = "Meeting From : " . $from_name . "\r\n" . "Candidate Name : " . $cand_data['candidate_name'] . "\r\n" . "Interview Type : " . $interview_mode . "\r\n" . "Interview Location : " . $int_location . "\r\n" . "Interview Date : " . $interview_date . "\r\n" . "Interview Time : " . sapp_Global::change_time($interview_time, 'view') . "\r\n" . " " . " " . "\r\n"; /* $base_url = 'http://' . $this->getRequest()->getHttpHost() . $this->getRequest()->getBaseUrl(); $options['subject'] = APPLICATION_NAME . ': Interview schedule'; $options['header'] = 'Interview schedule'; $options['toEmail'] = $interviewpanelnamesemailaddress['emailaddress']; $options['toName'] = $interviewpanelnamesemailaddress['userfullname']; $options['message'] = $description; $options['location'] = $int_location; $options['interviewdate'] = $interview_date; $options['starttime'] = sapp_Global::add_time($interview_time, 'view', 0); $options['endtime'] = sapp_Global::add_time($interview_time, 'view', 3600); //Interview Calendar Invite will be send from login user account $options['fromEmail'] = trim($loginuser_person_data['emailaddress']); $options['fromName'] = $loginuser_person_data['userfullname']; $options['calUniqueID'] = $cal_unique_id; $options['method'] = 'REQUEST'; //sapp_Global::_sendCalendarEmail($options); */ $from_name = trim($loginuser_person_data['userfullname']); $from_address = trim($loginuser_person_data['emailaddress']); $to_name = trim($interviewpanelnamesemailaddress['userfullname']); $to_address = trim($interviewpanelnamesemailaddress['emailaddress']); $startTime = sapp_Global::_getInterviewStartDateTime(sapp_Global::change_date($interview_date), sapp_Global::change_time(trim($interview_time)), 3600); $endTime = sapp_Global::_getInterviewStartDateTime(sapp_Global::change_date($interview_date), sapp_Global::change_time(trim($interview_time))); $subject = APPLICATION_NAME . ': Interview schedule'; $location = $int_location; $calRequest = 'REQUEST'; sapp_Global::sendIcalEvent($from_name, $from_address, $to_name, $to_address, $startTime, $endTime, $subject, $description, $location, $calRequest, $cal_unique_id); } // update Calendar Invite ID to DB $where = "id = " . $ir_result; $irdata = array('calendarinviteid' => $cal_unique_id); $ir_result1 = $interview_round_model->SaveorUpdateInterviewroundData($irdata, $where); $candData = array('cand_status' => 'Scheduled', 'modifiedby' => trim($loginUserId), 'modifieddate' => gmdate("Y-m-d H:i:s")); $where = "id = " . $candidate_id; $candResult = $cand_model->SaveorUpdateCandidateData($candData, $where); } } else { $idata = array('interview_status' => trim($interview_status), 'isactive' => 1, 'modifiedby' => trim($loginUserId), 'modifieddate' => gmdate("Y-m-d H:i:s")); $iwhere = "id = " . $id; $tableid = $id; $actionflag = 2; $iresult = $interview_model->SaveorUpdateInterviewData($idata, $iwhere); $candData = array('cand_status' => 'Scheduled', 'modifiedby' => trim($loginUserId), 'modifieddate' => gmdate("Y-m-d H:i:s")); if ($cand_status && $cand_status != '0') { $candData['cand_status'] = $cand_status; } $where = "id = " . $candidate_id; $candResult = $cand_model->SaveorUpdateCandidateData($candData, $where); //send email $currentInterviewData = $requi_model->getinterviewdetails($id); $requisition_data = $requi_model->getrequisitiondetails($currentInterviewData["req_id"]); $currentrequisition_data = $requi_model->getrequisitiondetails($currentInterviewData["req_id"]); $cand_data = $cand_model->getCandidateById($candidate_id); //$hrgroupemail = $requi_model->getgroupemailid("REQ_HR", $requisition_data["department_id"]); $requesteremailaddress = $requi_model->getemployeeemailaddress($requisition_data["createdby"]); $reportingmanageremailaddress = $requi_model->getemployeeemailaddress($requisition_data["reporting_id"]); //HR Group $mail_arr[0]['name'] = 'HR'; $mail_arr[0]['email'] = constant('REQ_HR_0'); //Requester $mail_arr[1]['name'] = $requesteremailaddress['userfullname']; $mail_arr[1]['email'] = $requesteremailaddress['emailaddress']; //Reporting Manager $mail_arr[2]['name'] = $reportingmanageremailaddress['userfullname']; $mail_arr[2]['email'] = $reportingmanageremailaddress['emailaddress']; //Management Group $mail_arr[3]['name'] = 'Management'; $mail_arr[3]['email'] = constant('REQ_MGMT_0'); //Recruiter Panel $requisition_recruiters_data = $requi_model->GetRequisitionRecruiterEmailaddress($currentrequisition_data["requisition_code"]); $emailCnt = 4; foreach ($requisition_recruiters_data as $requisition_recruiters_data1) { $mail_arr[$emailCnt]['name'] = $requisition_recruiters_data1['userfullname']; $mail_arr[$emailCnt]['email'] = $requisition_recruiters_data1['emailaddress']; $emailCnt = $emailCnt + 1; } //Technical Panel $pnlIDS = implode(',', $requi_model->getRequisitionInterviewPanelIDs($currentInterviewData["req_id"])); $interviewpanelnamesemailaddresss = $requi_model->GetInterviewPanelMamesEmailaddress($pnlIDS); foreach ($interviewpanelnamesemailaddresss as $interviewpanelnamesemailaddress1) { $mail_arr[$emailCnt]['name'] = $interviewpanelnamesemailaddress1['userfullname']; $mail_arr[$emailCnt]['email'] = $interviewpanelnamesemailaddress1['emailaddress']; $emailCnt = $emailCnt + 1; } for ($ii = 0; $ii < count($mail_arr); $ii++) { $base_url = 'http://' . $this->getRequest()->getHttpHost() . $this->getRequest()->getBaseUrl(); $view = $this->getHelper('ViewRenderer')->view; $this->view->emp_name = $mail_arr[$ii]['name']; $this->view->type = 'InterviewSummary'; $this->view->requisition_data = $currentrequisition_data; $this->view->candidate_details = $cand_data; $this->view->round_data = $currentInterviewData; $this->view->base_url = $base_url; $text = $view->render('mailtemplates/requisition.phtml'); $options['subject'] = APPLICATION_NAME . ': Interview feedback'; //$options['header'] = 'Interview feedback'; $options['toEmail'] = $mail_arr[$ii]['email']; $options['toName'] = $mail_arr[$ii]['name']; $options['message'] = $text; sapp_Global::_sendEmail($options, "interviewrounds_feedback", REQUISITIONMODULESENDEMAIL); } } $menumodel = new Default_Model_Menu(); $objidArr = $menumodel->getMenuObjID('/scheduleinterviews'); $objID = $objidArr[0]['id']; $result = sapp_Global::logManager($objID, $actionflag, $loginUserId, $tableid); if ($id == '') { $this->_helper->FlashMessenger()->setNamespace('success')->addMessage('Interview scheduled successfully.'); } else { $this->_helper->FlashMessenger()->setNamespace('success')->addMessage('Interview details updated successfully.'); } $this->_redirect('/scheduleinterviews'); } else { $messages = $form->getMessages(); foreach ($messages as $key => $val) { foreach ($val as $key2 => $val2) { $msgarray[$key] = $val2; break; } } return $msgarray; } }
public function updateempdetails($employeeform) { $emproleStr = ''; $roleArr = array(); $auth = Zend_Auth::getInstance(); if ($auth->hasIdentity()) { $loginUserId = $auth->getStorage()->read()->id; } $usersModel = new Default_Model_Usermanagement(); $employeeModal = new Default_Model_Employee(); $businessunit_id = $this->_request->getParam('businessunit_id', null); $department_id = $this->_request->getParam('department_id', null); $reporting_manager = $this->_request->getParam('reporting_manager', null); $jobtitle_id = $this->_request->getParam('jobtitle_id', null); $position_id = $this->_request->getParam('position_id', null); $user_id = $this->_getParam('user_id', null); $prefix_id = $this->_getParam('prefix_id', null); $extension_number = $this->_getParam('extension_number', null); if ($employeeform->isValid($this->_request->getPost())) { $id = $this->_request->getParam('id'); $emp_status_id = $this->_request->getParam('emp_status_id', null); $date_of_joining = $this->_request->getParam('date_of_joining', null); $date_of_joining = sapp_Global::change_date($date_of_joining, 'database'); $date_of_leaving = $this->_request->getParam('date_of_leaving', null); $date_of_leaving = sapp_Global::change_date($date_of_leaving, 'database'); $years_exp = $this->_request->getParam('years_exp'); //FOR USER table $employeeId = $this->_getParam('employeeId', null); $modeofentry = $this->_getParam('modeofentry', null); $hid_modeofentry = $this->_getParam('hid_modeofentry', null); $other_modeofentry = $this->_getParam('other_modeofentry', null); $userfullname = $this->_getParam('userfullname', null); $candidatereferredby = $this->_getParam('candidatereferredby', null); $rccandidatename = $this->_getParam('rccandidatename', null); $emprole = $this->_getParam('emprole', null); //roleid_group_id if ($emprole != "") { $roleArr = explode('_', $emprole); if (!empty($roleArr)) { $emproleStr = $roleArr[0]; } } $emailaddress = $this->_getParam('emailaddress', null); $tmp_name = $this->_request->getParam('tmp_emp_name', null); $act_inact = $this->_request->getParam("act_inact", null); //end of user table $date = new Zend_Date(); $menumodel = new Default_Model_Menu(); $empstatusarray = array(8, 9, 10); $actionflag = ''; $tableid = ''; if ($modeofentry == 'Direct' || $hid_modeofentry == 'Direct') { $candidate_key = 'userfullname'; $candidate_value = $userfullname; $emp_name = $userfullname; $candidate_flag = 'no'; } else { $candidate_key = 'rccandidatename'; $candidate_value = $rccandidatename; $emp_name = $tmp_name; $candidate_flag = 'yes'; } $trDb = Zend_Db_Table::getDefaultAdapter(); // starting transaction $trDb->beginTransaction(); try { $emppassword = sapp_Global::generatePassword(); $user_data = array('emprole' => $emproleStr, $candidate_key => $candidate_value, 'emailaddress' => $emailaddress, 'modifiedby' => $loginUserId, 'modifieddate' => Zend_Registry::get('currentdate'), 'emppassword' => md5($emppassword), 'employeeId' => $employeeId, 'modeofentry' => $id == '' ? $modeofentry : "", 'selecteddate' => $date_of_joining, 'candidatereferredby' => $candidatereferredby, 'userstatus' => 'old', 'other_modeofentry' => $other_modeofentry); if ($id != '') { $where = array('user_id=?' => $user_id); $actionflag = 2; $user_where = "id = " . $user_id; unset($user_data['candidatereferredby']); unset($user_data['userstatus']); unset($user_data['emppassword']); unset($user_data['employeeId']); unset($user_data['modeofentry']); unset($user_data['other_modeofentry']); } else { $data['createdby'] = $loginUserId; $data['createddate'] = gmdate("Y-m-d H:i:s"); $data['isactive'] = 1; $user_data['createdby'] = $loginUserId; $user_data['createddate'] = gmdate("Y-m-d H:i:s"); $user_data['isactive'] = 1; if ($modeofentry != 'Direct') { $user_data['userfullname'] = $emp_name; } $where = ''; $actionflag = 1; $user_where = ''; } $user_status = $usersModel->SaveorUpdateUserData($user_data, $user_where); if ($id == '') { $user_id = $user_status; } $data = array('user_id' => $user_id, 'reporting_manager' => $reporting_manager, 'emp_status_id' => $emp_status_id, 'businessunit_id' => $businessunit_id, 'department_id' => $department_id, 'jobtitle_id' => $jobtitle_id, 'position_id' => $position_id, 'prefix_id' => $prefix_id, 'extension_number' => $extension_number, 'date_of_joining' => $date_of_joining, 'date_of_leaving' => $date_of_leaving != '' ? $date_of_leaving : NULL, 'years_exp' => $years_exp == '' ? null : $years_exp, 'modifiedby' => $loginUserId, 'modifieddate' => gmdate("Y-m-d H:i:s")); $Id = $employeeModal->SaveorUpdateEmployeeData($data, $where); $statuswhere = array('id=?' => $user_id); if (in_array($emp_status_id, $empstatusarray)) { $isactivestatus = ''; if ($emp_status_id == 8) { $isactivestatus = 2; } else { if ($emp_status_id == 9) { $isactivestatus = 3; } else { if ($emp_status_id == 10) { $isactivestatus = 4; } } } $statusdata = array('isactive' => $isactivestatus); $empstatusId = $usersModel->SaveorUpdateUserData($statusdata, $statuswhere); } else { $statusdata = array('isactive' => 1); $empstatusId = $usersModel->SaveorUpdateUserData($statusdata, $statuswhere); } if ($Id == 'update') { $tableid = $id; $this->_helper->getHelper("FlashMessenger")->addMessage(array("success" => "Employee details updated successfully.")); } else { //start of mailing $base_url = 'http://' . $this->getRequest()->getHttpHost() . $this->getRequest()->getBaseUrl(); $view = $this->getHelper('ViewRenderer')->view; $this->view->emp_name = $emp_name; $this->view->password = $emppassword; $this->view->emp_id = $employeeId; $this->view->base_url = $base_url; $text = $view->render('mailtemplates/newpassword.phtml'); $options['subject'] = APPLICATION_NAME . ' login credentials'; $options['header'] = 'Greetings from Sentrifugo'; $options['toEmail'] = $emailaddress; $options['toName'] = $this->view->emp_name; $options['message'] = $text; $result = sapp_Global::_sendEmail($options); //end of mailing $tableid = $Id; $this->_helper->getHelper("FlashMessenger")->addMessage(array("success" => "Employee details added successfully.")); } $menuidArr = $menumodel->getMenuObjID('/employee'); $menuID = $menuidArr[0]['id']; $result = sapp_Global::logManager($menuID, $actionflag, $loginUserId, $tableid); $menuidArr = $menumodel->getMenuObjID('/usermanagement'); $menuID_user = $menuidArr[0]['id']; $result = sapp_Global::logManager($menuID, $actionflag, $loginUserId, $user_id); if ($act_inact == 1) { if ($user_data['isactive'] == 1) { $act_str = array("Activated" => Zend_Registry::get('currentdate')); } else { $act_str = array("Inactivated" => Zend_Registry::get('currentdate')); } $result = sapp_Global::logManager($menuID_user, 4, $loginUserId, $user_id, '', $act_str); } $trDb->commit(); $this->_redirect('employee/edit/id/' . $user_id); } catch (Exception $e) { $trDb->rollBack(); $msgarray['employeeId'] = "Something went wrong,please try again later."; return $msgarray; } } else { $messages = $employeeform->getMessages(); foreach ($messages as $key => $val) { foreach ($val as $key2 => $val2) { $msgarray[$key] = $val2; break; } } $usersModel = new Default_Model_Users(); if (isset($businessunit_id) && $businessunit_id != 0 && $businessunit_id != '') { $departmentsmodel = new Default_Model_Departments(); $departmentlistArr = $departmentsmodel->getDepartmentList($businessunit_id); $employeeform->department_id->clearMultiOptions(); $employeeform->reporting_manager->clearMultiOptions(); $employeeform->department_id->addMultiOption('', 'Select Department'); foreach ($departmentlistArr as $departmentlistresult) { $employeeform->department_id->addMultiOption($departmentlistresult['id'], utf8_encode($departmentlistresult['deptname'])); } if (isset($department_id) && $department_id != 0 && $department_id != '') { $employeeform->setDefault('department_id', $department_id); } } if (isset($department_id) && $department_id != 0 && $department_id != '') { $reportingManagerArr = $usersModel->getReportingManagerList($department_id, $user_id); $employeeform->reporting_manager->addMultiOption('', 'Select Reporting Manager'); foreach ($reportingManagerArr as $reportingManagerresult) { $employeeform->reporting_manager->addMultiOption($reportingManagerresult['id'], utf8_encode($reportingManagerresult['userfullname'])); } if (isset($reporting_manager) && $reporting_manager != 0 && $reporting_manager != '') { $employeeform->setDefault('reporting_manager', $reporting_manager); } } if (isset($jobtitle_id) && $jobtitle_id != 0 && $jobtitle_id != '') { $positionsmodel = new Default_Model_Positions(); $positionlistArr = $positionsmodel->getPositionList($jobtitle_id); $employeeform->position_id->clearMultiOptions(); $employeeform->position_id->addMultiOption('', 'Select Position'); foreach ($positionlistArr as $positionlistRes) { $employeeform->position_id->addMultiOption($positionlistRes['id'], utf8_encode($positionlistRes['positionname'])); } if (isset($position_id) && $position_id != 0 && $position_id != '') { $employeeform->setDefault('position_id', $position_id); } } return $msgarray; } }
public function save($requisitionform, $data) { $auth = Zend_Auth::getInstance(); if ($auth->hasIdentity()) { $loginUserId = $auth->getStorage()->read()->id; $loginuserGroup = $auth->getStorage()->read()->group_id; } $requi_model = new Default_Model_Requisition(); $user_model = new Default_Model_Usermanagement(); $jobtitleModel = new Default_Model_Jobtitles(); $appr_mail = ''; $appr_per = ''; if ($requisitionform->isValid($this->_request->getPost())) { $trDb = Zend_Db_Table::getDefaultAdapter(); // starting transaction $trDb->beginTransaction(); try { $id = (int) $this->_getParam('id', null); $requisition_code = $this->_getParam('requisition_code', null); $onboard_date = $this->_getParam('onboard_date', null); $business_unit = $this->_getParam('business_unit', null); $department = $this->_getParam('department', null); $jobtitle = $this->_getParam('jobtitle', null); $position_id = $this->_getParam('position_id', null); $reporting_id = $this->_getParam('reporting_id', null); $req_no_positions = $this->_getParam('req_no_positions', null); $jobdescription = $this->_getParam('jobdescription', null); $req_skills = $this->_getParam('req_skills', null); $req_qualification = $this->_getParam('req_qualification', null); $req_exp_years = $this->_getParam('req_exp_years', null); $emp_type = $this->_getParam('emp_type', null); $req_priority = $this->_getParam('req_priority', null); $additional_info = $this->_getParam('additional_info', null); $req_status = $this->_getParam('req_status', null); $approver1 = $this->_getParam('approver1', null); $approver2 = $this->_getParam('approver2', null); $approver3 = $this->_getParam('approver3', null); $aflag = $this->_getParam('aflag', null); $edit_flag = $this->_getParam('edit_flag', null); $edit_order = $this->_getParam('edit_order', null); $aorder = $this->_getParam('aorder', null); //1= approver1,2=approver2,3=approver3 if ($aflag != '' && $aflag == 'approver') { if ($req_status == 3) { $data = array('modifiedby' => trim($loginUserId), 'modifiedon' => gmdate("Y-m-d H:i:s"), 'appstatus' . $aorder => $req_status, 'req_status' => $req_status); } else { if ($aorder == 1) { if ($approver2 != '') { $data = array('appstatus1' => $req_status, 'appstatus2' => 'Initiated'); $appr_mail = $approver2; $appr_per = $approver1; } else { $data = array('appstatus1' => $req_status, 'req_status' => $req_status); $appr_mail = 'approved'; } } else { if ($aorder == 2) { if ($approver3 != '') { $data = array('appstatus2' => $req_status, 'appstatus3' => 'Initiated'); $appr_mail = $approver3; $appr_per = $approver2; } else { $data = array('appstatus2' => $req_status, 'req_status' => $req_status); $appr_mail = 'approved'; } } else { if ($aorder == 3) { $data = array('appstatus3' => $req_status, 'req_status' => $req_status); $appr_mail = 'approved'; } } } $data['modifiedby'] = trim($loginUserId); $data['modifiedon'] = gmdate("Y-m-d H:i:s"); } } else { $data = array('requisition_code' => trim($requisition_code), 'onboard_date' => sapp_Global::change_date(trim($onboard_date), 'database'), 'position_id' => trim($position_id), 'reporting_id' => trim($reporting_id), 'businessunit_id' => trim($business_unit), 'department_id' => trim($department), 'req_no_positions' => trim($req_no_positions), 'jobdescription' => trim($jobdescription), 'jobtitle' => trim($jobtitle), 'req_skills' => trim($req_skills), 'req_qualification' => trim($req_qualification), 'req_exp_years' => trim($req_exp_years), 'emp_type' => trim($emp_type), 'req_priority' => trim($req_priority), 'additional_info' => trim($additional_info), 'approver1' => $approver1, 'approver2' => $approver2 == '' ? null : $approver2, 'approver3' => $approver3 == '' ? null : $approver3, 'req_status' => 'Initiated', 'appstatus1' => 'Initiated', 'appstatus2' => null, 'appstatus3' => null, 'isactive' => 1, 'createdby' => trim($loginUserId), 'modifiedby' => trim($loginUserId), 'createdon' => gmdate("Y-m-d H:i:s"), 'modifiedon' => gmdate("Y-m-d H:i:s")); if ($loginuserGroup == MANAGER_GROUP) { $data['reporting_id'] = $loginUserId; } if ($edit_flag != '' && $edit_flag == 'yes') { if ($edit_order == 1) { $data = array('modifiedby' => trim($loginUserId), 'modifiedon' => gmdate("Y-m-d H:i:s"), 'approver2' => $approver2 == '' ? null : $approver2, 'approver3' => $approver3 == '' ? null : $approver3, 'appstatus2' => 'Initiated'); if ($approver2 == '') { $data['appstatus2'] = null; } else { $appr_per = $edit_order; $appr_mail = $approver2; } } if ($edit_order == 2) { $data = array('modifiedby' => trim($loginUserId), 'modifiedon' => gmdate("Y-m-d H:i:s"), 'approver3' => $approver3 == '' ? null : $approver3, 'appstatus3' => 'Initiated'); if ($approver3 == '') { $data['appstatus3'] = null; } else { $appr_per = $edit_order; $appr_mail = $approver3; } } } } $where = ""; $actionflag = 1; //for mailing if ($id == '') { //for requisition code $identity_code_model = new Default_Model_Identitycodes(); $identity_codes = $identity_code_model->getIdentitycodesRecord(); $irequistion_code = isset($identity_codes[0]) ? $identity_codes[0]['requisition_code'] : ""; if ($irequistion_code != '') { $req_id = $requi_model->getMaxReqCode($irequistion_code . "/"); } else { $req_id = ''; } $data['requisition_code'] = $req_id; //end of requisition code $report_person_data = $user_model->getUserDataById($data['reporting_id']); $approver1_person_data = $user_model->getUserDataById($approver1); $Raisedby_person_data = $user_model->getUserDataById($data['createdby']); $jobttlArr = $jobtitleModel->getsingleJobTitleData(trim($jobtitle)); if (!empty($jobttlArr) && $jobttlArr != 'norows') { $jobtitlename = ' - ' . $jobttlArr[0]['jobtitlename']; } else { $jobtitlename = ''; } $mail_arr[0]['name'] = 'HR'; $mail_arr[0]['email'] = defined('REQ_HR_' . $business_unit) ? constant('REQ_HR_' . $business_unit) : ""; $mail_arr[0]['type'] = 'HR'; $mail_arr[1]['name'] = 'Management'; $mail_arr[1]['email'] = defined('REQ_MGMT_' . $business_unit) ? constant('REQ_MGMT_' . $business_unit) : ""; $mail_arr[1]['type'] = 'Management'; $mail_arr[2]['name'] = $Raisedby_person_data['userfullname']; $mail_arr[2]['email'] = $Raisedby_person_data['emailaddress']; $mail_arr[2]['type'] = 'Raise'; $mail_arr[3]['name'] = $approver1_person_data['userfullname']; $mail_arr[3]['email'] = $approver1_person_data['emailaddress']; $mail_arr[3]['type'] = 'Approver'; $appr_str = ""; $appr_str = $approver1_person_data['userfullname']; if ($data['approver2'] != '') { $approver2_person_data = $user_model->getUserDataById($data['approver2']); $appr_str .= ", " . $approver2_person_data['userfullname']; $mail_arr[4]['name'] = $approver2_person_data['userfullname']; $mail_arr[4]['email'] = $approver2_person_data['emailaddress']; $mail_arr[4]['type'] = 'Approver'; } if ($data['approver3'] != '') { $approver3_person_data = $user_model->getUserDataById($data['approver3']); $appr_str .= " and " . $approver3_person_data['userfullname']; $mail_arr[5]['name'] = $approver3_person_data['userfullname']; $mail_arr[5]['email'] = $approver3_person_data['emailaddress']; $mail_arr[5]['type'] = 'Approver'; } for ($ii = 0; $ii < count($mail_arr); $ii++) { $base_url = 'http://' . $this->getRequest()->getHttpHost() . $this->getRequest()->getBaseUrl(); $view = $this->getHelper('ViewRenderer')->view; $this->view->emp_name = $mail_arr[$ii]['name']; $this->view->base_url = $base_url; $this->view->type = $mail_arr[$ii]['type']; $this->view->jobtitle = $jobtitlename; $this->view->requisition_code = $requisition_code; $this->view->approver_str = $appr_str; $this->view->raised_name = $Raisedby_person_data['userfullname']; $text = $view->render('mailtemplates/requisition.phtml'); $options['subject'] = APPLICATION_NAME . ': Requisition for approval'; $options['header'] = 'Requisition Status'; $options['toEmail'] = $mail_arr[$ii]['email']; $options['toName'] = $mail_arr[$ii]['name']; $options['message'] = $text; $options['cron'] = 'yes'; if ($options['toEmail'] != '') { sapp_Global::_sendEmail($options); } } } if ($id != '') { unset($data['createdby']); unset($data['createdon']); unset($data['isactive']); $where = "id = " . $id; $tableid = $id; $actionflag = 2; } $result = $requi_model->SaveorUpdateRequisitionData($data, $where); if ($id == '') { $tableid = $result; } if ($result != '') { if ($actionflag == 2) { //start of mailing $requisition_data = $requi_model->getRequisitionDataById($id); $report_person_data = $user_model->getUserDataById($requisition_data['reporting_id']); $st_arr = array('0' => 'Select status', '2' => 'Approved', '3' => 'Rejected'); if ($req_status == 3 || $appr_mail == 'approved') { $approver1_person_data = $user_model->getUserDataById($requisition_data['approver1']); $Raisedby_person_data = $user_model->getUserDataById($requisition_data['createdby']); $jobttlArr = $jobtitleModel->getsingleJobTitleData(trim($requisition_data['jobtitle'])); if (!empty($jobttlArr) && $jobttlArr != 'norows') { $jobtitlename = ' - ' . $jobttlArr[0]['jobtitlename']; } else { $jobtitlename = ''; } $mail_arr[0]['name'] = 'HR'; $mail_arr[0]['email'] = defined('REQ_HR_' . $requisition_data['businessunit_id']) ? constant('REQ_HR_' . $requisition_data['businessunit_id']) : ""; $mail_arr[0]['type'] = 'HR'; $mail_arr[1]['name'] = 'Management'; $mail_arr[1]['email'] = defined('REQ_MGMT_' . $requisition_data['businessunit_id']) ? constant('REQ_MGMT_' . $requisition_data['businessunit_id']) : ""; $mail_arr[1]['type'] = 'Management'; $mail_arr[2]['name'] = $Raisedby_person_data['userfullname']; $mail_arr[2]['email'] = $Raisedby_person_data['emailaddress']; $mail_arr[2]['type'] = 'Raise'; $mail_arr[3]['name'] = $approver1_person_data['userfullname']; $mail_arr[3]['email'] = $approver1_person_data['emailaddress']; $mail_arr[3]['type'] = 'Approver'; // Check if the reporting person and raised person are same - Requisition raised by Manager case if ($requisition_data['reporting_id'] != $requisition_data['createdby']) { $mail_arr[4]['name'] = $report_person_data['userfullname']; $mail_arr[4]['email'] = $report_person_data['emailaddress']; $mail_arr[4]['type'] = 'Report'; } $appr_str = ""; $appr_str = $approver1_person_data['userfullname']; if ($requisition_data['approver2'] != '') { $approver2_person_data = $user_model->getUserDataById($requisition_data['approver2']); $appr_str .= ", " . $approver2_person_data['userfullname']; $mail_arr[5]['name'] = $approver2_person_data['userfullname']; $mail_arr[5]['email'] = $approver2_person_data['emailaddress']; $mail_arr[5]['type'] = 'Approver'; } if ($requisition_data['approver3'] != '') { $approver3_person_data = $user_model->getUserDataById($requisition_data['approver3']); $appr_str .= " and " . $approver3_person_data['userfullname']; $mail_arr[6]['name'] = $approver3_person_data['userfullname']; $mail_arr[6]['email'] = $approver3_person_data['emailaddress']; $mail_arr[6]['type'] = 'Approver'; } $mail = array(); for ($ii = 0; $ii < count($mail_arr); $ii++) { $base_url = 'http://' . $this->getRequest()->getHttpHost() . $this->getRequest()->getBaseUrl(); $view = $this->getHelper('ViewRenderer')->view; $this->view->emp_name = !empty($mail_arr[$ii]['name']) ? $mail_arr[$ii]['name'] : ''; $this->view->base_url = $base_url; $this->view->type = !empty($mail_arr[$ii]['type']) ? $mail_arr[$ii]['type'] : ''; $this->view->jobtitle = $jobtitlename; $this->view->requisition_code = $requisition_data['requisition_code']; $this->view->approver_str = $appr_str; $this->view->raised_name = $Raisedby_person_data['userfullname']; $this->view->req_status = $st_arr[$req_status]; $this->view->reporting_manager = $report_person_data['userfullname']; $text = $view->render('mailtemplates/changedrequisition.phtml'); $options['subject'] = $st_arr[$req_status] == 'approved' ? APPLICATION_NAME . ': Requisition is approved' : APPLICATION_NAME . ': Requisition is rejected'; $options['header'] = 'Requisition Status'; $options['toEmail'] = !empty($mail_arr[$ii]['email']) ? $mail_arr[$ii]['email'] : ''; $options['toName'] = !empty($mail_arr[$ii]['name']) ? $mail_arr[$ii]['name'] : ''; $options['message'] = $text; $mail[$ii] = $options; $options['cron'] = 'yes'; if ($options['toEmail'] != '') { sapp_Global::_sendEmail($options); } } } else { if ($req_status == 2) { $approver_person_data = $user_model->getUserDataById($appr_mail); $mail_arr[0]['name'] = $approver_person_data['userfullname']; $mail_arr[0]['email'] = $approver_person_data['emailaddress']; $mail_arr[0]['type'] = 'Approver'; if ($edit_flag == 'yes') { $approved_by_data = $user_model->getUserDataById($requisition_data['approver' . $appr_per]); $req_status = 2; } else { $approved_by_data = $user_model->getUserDataById($appr_per); } $Raisedby_person_data = $user_model->getUserDataById($requisition_data['createdby']); $appr_str = $approved_by_data['userfullname']; for ($ii = 0; $ii < count($mail_arr); $ii++) { $base_url = 'http://' . $this->getRequest()->getHttpHost() . $this->getRequest()->getBaseUrl(); $view = $this->getHelper('ViewRenderer')->view; $this->view->emp_name = $mail_arr[$ii]['name']; $this->view->base_url = $base_url; $this->view->type = $mail_arr[$ii]['type']; $this->view->requisition_code = $requisition_data['requisition_code']; $this->view->req_status = $st_arr[$req_status]; $this->view->raised_name = $Raisedby_person_data['userfullname']; $this->view->approver_str = $appr_str; $text = $view->render('mailtemplates/changedrequisition.phtml'); $options['subject'] = $st_arr[$req_status] == 'approved' ? APPLICATION_NAME . ': Requisition is approved' : APPLICATION_NAME . ': Requisition is rejected'; $options['header'] = 'Requisition Status'; $options['toEmail'] = $mail_arr[$ii]['email']; $options['toName'] = $mail_arr[$ii]['name']; $options['message'] = $text; $options['cron'] = 'yes'; if ($options['toEmail'] != '') { sapp_Global::_sendEmail($options); } } } } //end of mailing } $menumodel = new Default_Model_Menu(); $objidArr = $menumodel->getMenuObjID('/requisition'); $objID = $objidArr[0]['id']; $result = sapp_Global::logManager($objID, $actionflag, $loginUserId, $tableid); if ($id != '') { $this->_helper->getHelper("FlashMessenger")->addMessage(array("success" => "Resource requisition updated successfully.")); } else { $this->_helper->getHelper("FlashMessenger")->addMessage(array("success" => "Resource requisition added successfully.")); } $trDb->commit(); $this->_redirect('/requisition'); } } catch (Exception $e) { $trDb->rollBack(); $this->_helper->getHelper("FlashMessenger")->addMessage(array("success" => "Something went wrong, please try again later.")); $this->_redirect('/requisition'); } } else { $messages = $requisitionform->getMessages(); foreach ($messages as $key => $val) { foreach ($val as $key2 => $val2) { $msgarray[$key] = $val2; break; } } return $msgarray; } }
/** * Send Emails * @param type $RequisitionCode * @param type $action */ public function requisition_cvupload_emails($requisition_id, $action, $candDetails) { $user_model = new Default_Model_Usermanagement(); $requi_model = new Default_Model_Requisition(); #$identity_code_model = new Default_Model_Identitycodes(); #$candiate_model = new Default_Model_Candidatedetails(); //Requisition Summary Data $requisition_data = $requi_model->getrequisitiondetails($requisition_id); if (isset($requisition_data)) { $reqDetails = sprintf("%s-%s-%s (%s)", $requisition_data['businessunit_name'], $requisition_data['department_name'], $requisition_data['jobtitle_name'], $requisition_data['requisition_code']); $RequisitionCode = $requisition_data["requisition_code"]; $requisition_recruiters_data = $requi_model->GetRequisitionRecruiterEmailaddress($RequisitionCode); //HRExecutive Details $hrexecutive_person_data = $user_model->getUserDataById($requisition_data["hrexecutive_id"]); //Requester Details $Raisedby_person_data = $user_model->getUserDataById($requisition_data["createdby"]); //Reporting Manager Details $Reportedto_person_data = $user_model->getUserDataById($requisition_data["reporting_id"]); //HR Group $mail_arr[0]['name'] = 'HR'; $mail_arr[0]['email'] = constant('REQ_HR_0'); $mail_arr[0]['type'] = 'CandidateCV'; //Requester $mail_arr[1]['name'] = $Raisedby_person_data['userfullname']; $mail_arr[1]['email'] = $Raisedby_person_data['emailaddress']; $mail_arr[1]['type'] = 'CandidateCV'; //HR Executive $mail_arr[2]['name'] = $hrexecutive_person_data['userfullname']; $mail_arr[2]['email'] = $hrexecutive_person_data['emailaddress']; $mail_arr[2]['type'] = 'CandidateCV'; //Reporting Manager $mail_arr[3]['name'] = $Reportedto_person_data['userfullname']; $mail_arr[3]['email'] = $Reportedto_person_data['emailaddress']; $mail_arr[3]['type'] = 'CandidateCV'; //Management Group $mail_arr[4]['name'] = 'Management'; $mail_arr[4]['email'] = constant('REQ_MGMT_0'); $mail_arr[4]['type'] = 'CandidateCV'; $emailCnt = 5; foreach ($requisition_recruiters_data as $requisition_recruiters_data1) { $mail_arr[$emailCnt]['name'] = $requisition_recruiters_data1['userfullname']; $mail_arr[$emailCnt]['email'] = $requisition_recruiters_data1['emailaddress']; $mail_arr[$emailCnt]['type'] = 'CandidateCV'; $emailCnt = $emailCnt + 1; } $appr_str = $hrexecutive_person_data['userfullname']; $jobtitle_name = $requisition_data["jobtitle_name"]; for ($ii = 0; $ii < count($mail_arr); $ii++) { $subjMsg = 'Uploaded CV modified for requisition.'; if ($action == "New") { $subjMsg = 'New CV uploaded to requisition.'; } if ($action == "Update") { $subjMsg = 'Uploaded CV modified for requisition.'; } $base_url = 'http://' . $this->getRequest()->getHttpHost() . $this->getRequest()->getBaseUrl(); $view = $this->getHelper('ViewRenderer')->view; $this->view->emp_name = $mail_arr[$ii]['name']; $this->view->subjMsg = $subjMsg; $this->view->base_url = $base_url; $this->view->type = $mail_arr[$ii]['type']; $this->view->requisition_details = $reqDetails; $this->view->candidate_details = $candDetails; $text = $view->render('mailtemplates/requisition.phtml'); $options['subject'] = APPLICATION_NAME . ':' . $subjMsg; $options['header'] = 'Requisition Status'; $options['toEmail'] = $mail_arr[$ii]['email']; $options['toName'] = $mail_arr[$ii]['name']; $options['message'] = $text; $options['cron'] = 'yes'; if ($options['toEmail'] != '') { sapp_Global::_sendEmail($options, "requisition", REQUISITIONMODULESENDEMAIL); } } } }
public function savemngresponseAction() { $post_values = $this->getRequest()->getPost(); $result = array('status' => 'fail', 'msg' => 'Something went wrong, please try again.'); if (count($post_values) > 0) { if (isset($post_values['hid_employee_id']) && $post_values['hid_employee_id'] != '' && isset($post_values['hid_appraisal_id']) && $post_values['hid_appraisal_id'] != '') { //if($post_values['consol_rating'] != '' && $post_values['consol_comments'] != '') //{ $auth = Zend_Auth::getInstance(); if ($auth->hasIdentity()) { $loginUserId = $auth->getStorage()->read()->id; $loginuserRole = $auth->getStorage()->read()->emprole; $loginuserGroup = $auth->getStorage()->read()->group_id; $loginuserFullName = $auth->getStorage()->read()->userfullname; $loginuserEmail = $auth->getStorage()->read()->emailaddress; $loginuserProfileImg = $auth->getStorage()->read()->profileimg; $loginuserEmpId = $auth->getStorage()->read()->employeeId; $loginuserArr = array('loginuserid' => $loginUserId, 'loginuserrole' => $loginuserRole, 'loginusergroup' => $loginuserGroup); } $model = new Default_Model_Appraisalemployeeratings(); $appEmpRatingsModel = new Default_Model_Appraisalemployeeratings(); $consol_rating = isset($post_values['consol_rating']) && trim($post_values['consol_rating']) != 0 ? $post_values['consol_rating'] : NULL; $consol_comments = isset($post_values['consol_comments']) ? $post_values['consol_comments'] : ''; $employee_id = $post_values['hid_employee_id']; $appraisal_id = $post_values['hid_appraisal_id']; $question_rating = isset($post_values['question_rating']) ? $post_values['question_rating'] : ''; $question_comments = isset($post_values['question_comments']) ? $post_values['question_comments'] : ''; $skill_ids = isset($post_values['emp_skills']) ? $post_values['emp_skills'] : ''; $skill_rating = isset($post_values['skill_rating']) ? $post_values['skill_rating'] : ''; $flag = $post_values['hid_btn_flag']; $ratings_ids_arr = $model->getRatingsByInitId($appraisal_id); $mng_response_arr = array(); $skill_response_arr = array(); $response_json = ''; $skill_json = ''; if (!empty($ratings_ids_arr)) { if (!empty($question_comments)) { foreach ($question_comments as $qid => $qc) { // if($qc!='') $mng_response_arr[$qid]['comment'] = isset($qc) && trim($qc) != '' ? $qc : ''; // if($qid!='' && $question_rating[$qid]!='') $mng_response_arr[$qid]['rating'] = isset($ratings_ids_arr[$question_rating[$qid]]) ? $ratings_ids_arr[$question_rating[$qid]] : ''; } } if (!empty($skill_ids)) { foreach ($skill_ids as $key => $sk_id) { $skill_response_arr[$sk_id] = isset($ratings_ids_arr[$skill_rating[$key]]) ? $ratings_ids_arr[$skill_rating[$key]] : 0; } } } if (!empty($mng_response_arr)) { $response_json = json_encode($mng_response_arr); } if (!empty($skill_response_arr)) { $skill_json = json_encode($skill_response_arr); } $save_data = array('manager_response' => $response_json != '' ? $response_json : NULL, 'skill_response' => $skill_json != '' ? $skill_json : NULL, 'line_comment_1' => $consol_comments, 'line_rating_1' => $consol_rating, 'consolidated_rating' => $consol_rating, 'modifiedby' => $loginUserId, 'modifiedby_role' => $loginuserRole, 'modifiedby_group' => $loginuserGroup, 'modifieddate' => gmdate("Y-m-d H:i:s")); if ($flag != 'draft') { $line_2_mgr = ''; $appEmpQuesPrivData = $appEmpRatingsModel->getAppEmpQuesPrivData($appraisal_id, $employee_id); $line_2_mgr = $appEmpQuesPrivData[0]['line_manager_2']; if (!isset($line_2_mgr) && $line_2_mgr == '') { $save_data['appraisal_status'] = "Completed"; $mail_sub = "Completed"; // using for mail sending scenario. } else { $save_data['appraisal_status'] = "Pending L2 ratings"; $mail_sub = "Submitted to Line 2 Manager."; } $history_desc = $this->app_history_disc_array[2]; $appHistoryData = array('employee_id' => $employee_id, 'pa_initialization_id' => $appraisal_id, 'description' => $history_desc, 'desc_emp_id' => $loginUserId, 'desc_emp_name' => $loginuserFullName, 'desc_emp_profileimg' => $loginuserProfileImg, 'createdby' => $loginUserId, 'createddate' => gmdate("Y-m-d H:i:s"), 'modifiedby' => $loginUserId, 'modifieddate' => gmdate("Y-m-d H:i:s")); $appHistoryModel = new Default_Model_Appraisalhistory(); $result2 = $appHistoryModel->SaveorUpdateAppraisalHistoryData($appHistoryData); //sending mails and Logsmanager action $menumodel = new Default_Model_Menu(); $tableid = ''; $actionflag = 1; $menuidArr = $menumodel->getMenuObjID('/appraisalself'); $menuID = $menuidArr[0]['id']; $result = sapp_Global::logManager($menuID, $actionflag, $loginUserId, $tableid); /** Start * Sending Mails to employees */ // Sending mail to Employee $employee_id_str = $employee_id; $app_manager_model = new Default_Model_Appraisalmanager(); if ($line_2_mgr != '' && is_numeric($line_2_mgr)) { $employee_id_str = $employee_id . ',' . $line_2_mgr; } $employeeDetailsArr = $app_manager_model->getUserDetailsByEmpID($employee_id_str); $appraisalratingsmodel = new Default_Model_Appraisalratings(); $appraisal_details = $appraisalratingsmodel->getappdata($appraisal_id); if (!empty($appraisal_details)) { $to_year = $appraisal_details['to_year']; } //Preparing Employee array for Bcc $empArr = array(); if (!empty($employeeDetailsArr)) { $empArrList = ''; $empUserIdArr = array(); $toEmailId = ''; $toEmailName = ''; foreach ($employeeDetailsArr as $emp) { array_push($empArr, $emp['emailaddress']); //preparing Bcc array array_push($empUserIdArr, $emp['user_id']); if ($emp['user_id'] == $employee_id) { $toEmailId = $emp['emailaddress']; $toEmailName = $emp['userfullname']; $toEmpId = $emp['employeeId']; array_pop($empArr); } } //pushing loginUserEmail to Bcc array array_push($empArr, $loginuserEmail); $options['subject'] = APPLICATION_NAME . ': Appraisal ' . $mail_sub; $options['header'] = 'Performance Appraisal : ' . $to_year; $options['toEmail'] = $toEmailId; $options['bcc'] = $empArr; $options['toName'] = $toEmailName; $options['message'] = "<div style='padding: 0; text-align: left; font-size:14px; font-family:Arial, Helvetica, sans-serif;'>\t\t\t\t\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t<span style='color:#3b3b3b;'>Hi,</span><br />\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t<div style='padding:20px 0 0 0;color:#3b3b3b;'>{$loginuserFullName}({$loginuserEmpId}) has Updated {$toEmailName}({$toEmpId}) appraisal form. </div>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t<div style='padding:20px 0 10px 0;'>Please <a href=" . BASE_URL . " target='_blank' style='color:#b3512f;'>click here</a> to login to your <b>" . APPLICATION_NAME . "</b> account and check the details.</div>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t</div> "; $mail_id = sapp_Global::_sendEmail($options); } } $save_where = " pa_initialization_id ='" . $appraisal_id . "' and employee_id = '" . $employee_id . "' and appraisal_status = 'Pending L1 ratings' "; $save_result = $model->SaveorUpdateAppraisalSkillsData($save_data, $save_where); if ($save_result) { $result = array('status' => 'success', 'msg' => 'Employee appraisal process ' . ($flag == 'draft' ? "drafted" : "submitted") . ' successfully'); } //} } } $this->_helper->json($result); }
public function save($employeeform) { $emproleStr = ''; $roleArr = array(); $empgroupStr = ''; $auth = Zend_Auth::getInstance(); if ($auth->hasIdentity()) { $loginUserId = $auth->getStorage()->read()->id; } $usersModel = new Default_Model_Usermanagement(); $employeeModal = new Default_Model_Employee(); $requimodel = new Default_Model_Requisition(); $candidate_model = new Default_Model_Candidatedetails(); $orgInfoModel = new Default_Model_Organisationinfo(); $unitid = ''; $deptid = ''; $errorflag = 'true'; $msgarray = array(); $id = $this->_request->getParam('id'); $businessunit_id = $this->_request->getParam('businessunit_id', null); $department_id = $this->_request->getParam('department_id', null); $reporting_manager = $this->_request->getParam('reporting_manager', null); $jobtitle_id = $this->_request->getParam('jobtitle_id', null); $position_id = $this->_request->getParam('position_id', null); $user_id = $this->_getParam('user_id', null); $prefix_id = $this->_getParam('prefix_id', null); $extension_number = $this->_getParam('extension_number', null); $office_number = $this->_request->getParam('office_number', null); $office_faxnumber = $this->_request->getParam('office_faxnumber', null); $date_of_joining = $this->_request->getParam('date_of_joining', null); $date_of_joining = sapp_Global::change_date($date_of_joining, 'database'); $isvalidorgstartdate = $orgInfoModel->validateEmployeeJoiningDate($date_of_joining, $unitid, $deptid); if (!empty($isvalidorgstartdate)) { $msgarray['date_of_joining'] = 'Employee joining date should be greater than organization start date.'; $errorflag = 'false'; } if ($employeeform->isValid($this->_request->getPost()) && $errorflag == 'true') { $id = $this->_request->getParam('id'); $emp_status_id = $this->_request->getParam('emp_status_id', null); $date_of_leaving = $this->_request->getParam('date_of_leaving', null); $date_of_leaving = sapp_Global::change_date($date_of_leaving, 'database'); $years_exp = $this->_request->getParam('years_exp'); //FOR USER table $employeeId = $this->_getParam('employeeId', null); $modeofentry = $this->_getParam('modeofentry', null); $firstname = trim($this->_getParam('firstname', null)); $lastname = trim($this->_getParam('lastname', null)); $userfullname = $firstname . ' ' . $lastname; $emprole = $this->_getParam('emprole', null); //roleid_group_id if ($emprole != "") { $roleArr = explode('_', $emprole); if (!empty($roleArr)) { $emproleStr = $roleArr[0]; $empgroupStr = $roleArr[0]; } } $emailaddress = $this->_getParam('emailaddress', null); //end of user table $date = new Zend_Date(); $menumodel = new Default_Model_Menu(); $empstatusarray = array(8, 9, 10); $actionflag = ''; $tableid = ''; $trDb = Zend_Db_Table::getDefaultAdapter(); // starting transaction $trDb->beginTransaction(); try { $emppassword = sapp_Global::generatePassword(); $user_data = array('emprole' => $emproleStr, 'firstname' => $firstname != '' ? $firstname : NULL, 'lastname' => $lastname != '' ? $lastname : NULL, 'userfullname' => $userfullname, 'emailaddress' => $emailaddress, 'jobtitle_id' => $jobtitle_id, 'modifiedby' => $loginUserId, 'modifieddate' => gmdate("Y-m-d H:i:s"), 'emppassword' => md5($emppassword), 'employeeId' => $employeeId, 'modeofentry' => $id == '' ? $modeofentry : "", 'selecteddate' => $date_of_joining, 'candidatereferredby' => 0, 'userstatus' => 'old'); if ($id != '') { $where = array('user_id=?' => $user_id); $actionflag = 2; $user_where = "id = " . $user_id; unset($user_data['candidatereferredby']); unset($user_data['userstatus']); unset($user_data['emppassword']); unset($user_data['employeeId']); unset($user_data['modeofentry']); } else { $user_data['createdby'] = $loginUserId; $user_data['createddate'] = gmdate("Y-m-d H:i:s"); $user_data['isactive'] = 1; $where = ''; $actionflag = 1; $user_where = ''; $identity_code_model = new Default_Model_Identitycodes(); $identity_codes = $identity_code_model->getIdentitycodesRecord(); $emp_identity_code = isset($identity_codes[0]) ? $identity_codes[0]['employee_code'] : ""; if ($emp_identity_code != '') { $emp_id = $emp_identity_code . str_pad($usersModel->getMaxEmpId($emp_identity_code), 4, '0', STR_PAD_LEFT); } else { $emp_id = ''; } $user_data['employeeId'] = $emp_id; } $user_status = $usersModel->SaveorUpdateUserData($user_data, $user_where); if ($id == '') { $user_id = $user_status; } $data = array('user_id' => $user_id, 'reporting_manager' => $reporting_manager, 'emp_status_id' => $emp_status_id, 'businessunit_id' => $businessunit_id, 'department_id' => $department_id, 'jobtitle_id' => $jobtitle_id, 'position_id' => $position_id, 'prefix_id' => $prefix_id, 'extension_number' => $extension_number != '' ? $extension_number : NULL, 'office_number' => $office_number != '' ? $office_number : NULL, 'office_faxnumber' => $office_faxnumber != '' ? $office_faxnumber : NULL, 'date_of_joining' => $date_of_joining, 'date_of_leaving' => $date_of_leaving != '' ? $date_of_leaving : NULL, 'years_exp' => $years_exp == '' ? null : $years_exp, 'modifiedby' => $loginUserId, 'modifieddate' => gmdate("Y-m-d H:i:s")); if ($id == '') { $data['createdby'] = $loginUserId; $data['createddate'] = gmdate("Y-m-d H:i:s"); $data['isactive'] = 1; } $Id = $employeeModal->SaveorUpdateEmployeeData($data, $where); $statuswhere = array('id=?' => $user_id); if ($id != '') { if (in_array($emp_status_id, $empstatusarray)) { $isactivestatus = ''; if ($emp_status_id == 8) { $isactivestatus = 2; } else { if ($emp_status_id == 9) { $isactivestatus = 3; } else { if ($emp_status_id == 10) { $isactivestatus = 4; } } } $statusdata = array('isactive' => $isactivestatus); $empstatusId = $usersModel->SaveorUpdateUserData($statusdata, $statuswhere); $employeeModal->SaveorUpdateEmployeeData($statusdata, "user_id = " . $user_id); } else { $edata = $usersModel->getUserDataById($id); $statusdata = array('isactive' => 1); if ($edata['isactive'] != 0) { if ($edata['emptemplock'] == 1) { $statusdata = array('isactive' => 0); } $empstatusId = $usersModel->SaveorUpdateUserData($statusdata, $statuswhere); $employeeModal->SaveorUpdateEmployeeData($statusdata, "user_id = " . $user_id); } } } if ($Id == 'update') { $tableid = $id; $this->_helper->getHelper("FlashMessenger")->addMessage(array("success" => "Employee details updated successfully.")); } else { //start of mailing $base_url = 'http://' . $this->getRequest()->getHttpHost() . $this->getRequest()->getBaseUrl(); $view = $this->getHelper('ViewRenderer')->view; $this->view->emp_name = $userfullname; $this->view->password = $emppassword; $this->view->emp_id = $employeeId; $this->view->base_url = $base_url; $text = $view->render('mailtemplates/newpassword.phtml'); $options['subject'] = APPLICATION_NAME . ': Login Credentials'; $options['header'] = 'Greetings from Sentrifugo'; $options['toEmail'] = $emailaddress; $options['toName'] = $this->view->emp_name; $options['message'] = $text; $result = sapp_Global::_sendEmail($options); //end of mailing $tableid = $Id; $this->_helper->getHelper("FlashMessenger")->addMessage(array("success" => "Employee details added successfully.")); } $menuidArr = $menumodel->getMenuObjID('/employee'); $menuID = $menuidArr[0]['id']; $result = sapp_Global::logManager($menuID, $actionflag, $loginUserId, $user_id); $trDb->commit(); // Send email to employee when his details are edited by other user. $options['subject'] = APPLICATION_NAME . ': Employee details updated'; $options['header'] = 'Employee details updated'; $options['toEmail'] = $emailaddress; $options['toName'] = $userfullname; $options['message'] = 'Dear ' . $userfullname . ', your employee details are updated.'; $options['cron'] = 'yes'; if (!empty($id)) { sapp_Global::_sendEmail($options); } $this->_redirect('myemployees/edit/id/' . $user_id); } catch (Exception $e) { $trDb->rollBack(); $msgarray['employeeId'] = "Something went wrong, please try again later."; return $msgarray; } } else { $messages = $employeeform->getMessages(); foreach ($messages as $key => $val) { foreach ($val as $key2 => $val2) { $msgarray[$key] = $val2; break; } } if (isset($jobtitle_id) && $jobtitle_id != 0 && $jobtitle_id != '') { $positionsmodel = new Default_Model_Positions(); $positionlistArr = $positionsmodel->getPositionList($jobtitle_id); $employeeform->position_id->clearMultiOptions(); $employeeform->position_id->addMultiOption('', 'Select Position'); foreach ($positionlistArr as $positionlistRes) { $employeeform->position_id->addMultiOption($positionlistRes['id'], utf8_encode($positionlistRes['positionname'])); } if (isset($position_id) && $position_id != 0 && $position_id != '') { $employeeform->setDefault('position_id', $position_id); } } return $msgarray; } }
/** * * @param array $data * @param type $requisition_code * @param type $hrExecutiveID */ public function hrexecutive_to_requisition_emails($data, $requisition_code, $hrExecutiveID) { $user_model = new Default_Model_Usermanagement(); $requi_model = new Default_Model_Requisition(); $identity_code_model = new Default_Model_Identitycodes(); //for requisition code $identity_codes = $identity_code_model->getIdentitycodesRecord(); $irequistion_code = isset($identity_codes[0]) ? $identity_codes[0]['requisition_code'] : ""; if ($irequistion_code != '') { $req_id = $requi_model->getMaxReqCode($irequistion_code . "/"); } else { $req_id = ''; } $data['requisition_code'] = $req_id; //end of requisition code $Raisedby_person_data = $user_model->getUserDataById($data['createdby']); $business_unit = $data['businessunit_id']; //HR Group $mail_arr[0]['name'] = 'HR'; $mail_arr[0]['email'] = constant('REQ_HR_0'); $mail_arr[0]['type'] = 'HR'; //Management Group $mail_arr[1]['name'] = 'Management'; $mail_arr[1]['email'] = constant('REQ_MGMT_0'); $mail_arr[1]['type'] = 'Management'; //Requester $mail_arr[2]['name'] = $Raisedby_person_data['userfullname']; $mail_arr[2]['email'] = $Raisedby_person_data['emailaddress']; $mail_arr[2]['type'] = 'Raise'; $currEmailCount = 3; foreach ($hrExecutiveID as $ipid) { $hrexecutive_person_data = $user_model->getUserDataById($ipid); $mail_arr[$currEmailCount]['name'] = $hrexecutive_person_data['userfullname']; $mail_arr[$currEmailCount]['email'] = $hrexecutive_person_data['emailaddress']; $mail_arr[$currEmailCount]['type'] = 'HRExecutive'; $currEmailCount = $currEmailCount + 1; } #$appr_str = $hrexecutive_person_data['userfullname']; $appr_str = $Raisedby_person_data['userfullname']; for ($ii = 0; $ii < count($mail_arr); $ii++) { $base_url = 'http://' . $this->getRequest()->getHttpHost() . $this->getRequest()->getBaseUrl(); $view = $this->getHelper('ViewRenderer')->view; $this->view->emp_name = $mail_arr[$ii]['name']; $this->view->base_url = $base_url; $this->view->type = $mail_arr[$ii]['type']; $this->view->jobtitle = ""; //Job doesnt require for this emails $this->view->requisition_code = $requisition_code; $this->view->approver_str = $appr_str; $this->view->raised_name = $Raisedby_person_data['userfullname']; $text = $view->render('mailtemplates/requisition.phtml'); $options['subject'] = APPLICATION_NAME . ':' . $requisition_code . '-Recruiter allocated for requisition.'; $options['header'] = 'Requisition Status'; $options['toEmail'] = $mail_arr[$ii]['email']; $options['toName'] = $mail_arr[$ii]['name']; $options['message'] = $text; //$options['cron'] = 'yes'; if ($options['toEmail'] != '') { sapp_Global::_sendEmail($options, "requisition", REQUISITIONMODULESENDEMAIL); } } }