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 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'); $managercomments = $this->_request->getParam('approvalcomments'); $date = new Zend_Date(); $leaverequestmodel = new Default_Model_Leaverequest(); $employeeleavetypesmodel = new Default_Model_Employeeleavetypes(); $menumodel = new Default_Model_Menu(); $actionflag = ''; $tableid = ''; $status = ''; $messagestr = ''; $leavetypetext = ''; if ($managerstatus == 1) { $updateemployeeleave = $leaverequestmodel->updateemployeeleaves($appliedleavescount, $employeeid); $status = 2; $messagestr = "Leave request approved."; } else { if ($managerstatus == 2) { $status = 3; $messagestr = "Leave request rejected."; } } if ($managerstatus == 1 || $managerstatus == 2) { $data = array('approvalcomments' => $managercomments, 'leavestatus' => $status, 'modifiedby' => $loginUserId, 'modifieddate' => gmdate("Y-m-d H:i:s")); if ($id != '') { $where = array('id=?' => $id); $actionflag = 2; } else { $data['approvalcomments'] = $managercomments; $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; } $leavetypeArr = $employeeleavetypesmodel->getLeavetypeDataByID($leavetypeid); if (!empty($leavetypeArr)) { $leavetypetext = $leavetypeArr[0]['leavetype']; } /* Mail to Employee */ $view = $this->getHelper('ViewRenderer')->view; $base_URL = 'http://' . $this->getRequest()->getHttpHost() . $this->getRequest()->getBaseUrl(); if ($messagestr == 'Leave request approved.') { //$options['subject'] = 'Leave request approved'; $mailpurpose = "The below leave(s) has been approved."; } else { //$options['subject'] = 'Leave request rejected'; $mailpurpose = "The below leave(s) has been rejected."; } $this->view->base_url = $base_URL; $this->view->application_name = APPLICATION_NAME; $this->view->type = "New"; $this->view->emp_name = $userfullname; $this->view->mailpurpose = $mailpurpose; $this->view->requester_name = $userfullname; $this->view->NoOfDays = 0; $this->view->leave_from = $from_date; $this->view->leave_to = $to_date; $this->view->reason_for_leave = $reason; $this->view->reporting_manager = ""; $this->view->approvalcomments = $managercomments; $options['subject'] = APPLICATION_NAME . ':Leave Request'; $options['header'] = 'Leave Request'; $options['toEmail'] = $employeeemail; $options['toName'] = $userfullname; $options['message'] = $view->render('mailtemplates/leaves.phtml'); sapp_Global::_sendEmail($options, "new"); //$result = sapp_Global::_sendEmail($options); /* END */ /* Mail to HR */ $view = $this->getHelper('ViewRenderer')->view; $base_URL = 'http://' . $this->getRequest()->getHttpHost() . $this->getRequest()->getBaseUrl(); if ($messagestr == 'Leave request approved.') { //$options['subject'] = 'Leave request approved'; $mailpurpose = "The below leave(s) has been approved."; } else { //$options['subject'] = 'Leave request rejected'; $mailpurpose = "The below leave(s) has been rejected."; } $this->view->base_url = $base_URL; $this->view->application_name = APPLICATION_NAME; $this->view->type = "New"; $this->view->emp_name = 'Leave Management'; $this->view->mailpurpose = $mailpurpose; $this->view->requester_name = $userfullname; $this->view->NoOfDays = 0; $this->view->leave_from = $from_date; $this->view->leave_to = $to_date; $this->view->reason_for_leave = $reason; $this->view->reporting_manager = ""; $options['subject'] = APPLICATION_NAME . ':Leave Request'; $options['header'] = 'Leave Request'; $options['toEmail'] = constant('LV_HR_0'); $options['toName'] = 'Leave Management'; $options['message'] = $view->render('mailtemplates/leaves.phtml'); sapp_Global::_sendEmail($options, "new"); //$result = sapp_Global::_sendEmail($options); /* END */ } $menuidArr = $menumodel->getMenuObjID('/manageremployeevacations'); $menuID = $menuidArr[0]['id']; $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; } }