コード例 #1
0
 public function init()
 {
     parent::init();
     $current_timestamp = strtotime('now');
     $now_iso = date('Y-m-d H:i:s', $current_timestamp);
     $this->view->now_iso = $now_iso;
     //debugMessage('now '.$now_iso.'-'.$current_timestamp);
     $onehourago_timestamp = strtotime('-1 hour');
     $onehourago_iso = date('Y-m-d H:i:s', $onehourago_timestamp);
     $this->view->onehourago_iso = $onehourago_iso;
     $this->view->onehourago_timestamp = $onehourago_timestamp;
     // debugMessage('now '.$onehourago_iso.'-'.$onehourago_timestamp);
     $sixhourago_timestamp = strtotime('-6 hour');
     $sixhourago_iso = date('Y-m-d H:i:s', $sixhourago_timestamp);
     $this->view->sixhourago_iso = $sixhourago_iso;
     $this->view->sixhourago_timestamp = $sixhourago_timestamp;
     $twelvehourago_timestamp = strtotime('-12 hour');
     $twelvehourago_iso = date('Y-m-d H:i:s', $twelvehourago_timestamp);
     $this->view->twelvehourago_timestamp = $twelvehourago_timestamp;
     $this->view->twelvehourago_iso = $twelvehourago_iso;
     // debugMessage($logged_today_sql);
     $today_iso = date('Y-m-d');
     $today = changeMySQLDateToPageFormat($today_iso);
     $this->view->today_iso = $today_iso;
     //debugMessage('today '.$today_iso);
     $today_iso_short = date('M j', $current_timestamp);
     $yestday_iso = date('Y-m-d', strtotime('1 day ago'));
     $yestday = changeMySQLDateToPageFormat($yestday_iso);
     $this->view->yestday_iso = $yestday_iso;
     //debugMessage('yesterday '.$yestday_iso);
     $yestday_iso_short = date('M j', strtotime($yestday_iso));
     $weekday = date("N");
     // monday of week
     $mondaythisweek_iso = date('Y-m-d', strtotime('monday this week'));
     $mondaythisweek = changeMySQLDateToPageFormat($mondaythisweek_iso);
     if ($weekday == 1) {
         $mondaythisweek_iso = $today_iso;
         $mondaythisweek = $today;
     }
     if ($weekday == 7) {
         $mondaythisweek_iso = date('Y-m-d', strtotime('monday last week'));
         $mondaythisweek = changeMySQLDateToPageFormat($mondaythisweek_iso);
     }
     $this->view->mondaythisweek_iso = $mondaythisweek_iso;
     //debugMessage('monday this week '.$mondaythisweek_iso);
     // sunday of week
     $sundaythisweek_iso = date('Y-m-d', strtotime('sunday this week'));
     $sundaythisweek = changeMySQLDateToPageFormat($sundaythisweek_iso);
     if ($weekday == 1) {
         $sundaythisweek_iso = date('Y-m-d', strtotime('today + 7 days'));
         $sundaythisweek = changeMySQLDateToPageFormat($sundaythisweek_iso);
     }
     if ($weekday == 7) {
         $sundaythisweek_iso = $today_iso;
         $sundaythisweek = $today;
     }
     $this->view->sundaythisweek_iso = $sundaythisweek_iso;
     // debugMessage('sunday this week '.$sundaythisweek_iso);
     // monday last week
     $mondaylastweek_iso = date('Y-m-d', strtotime('-7 days', strtotime($mondaythisweek_iso)));
     //debugMessage('monday last week '.$mondaylastweek_iso);
     $this->view->mondaylastweek_iso = $mondaylastweek_iso;
     // sunday last week
     $sundaylastweek_iso = date('Y-m-d', strtotime('-7 days', strtotime($sundaythisweek_iso)));
     // debugMessage('sunday last week '.$sundaylastweek_iso);
     $this->view->sundaylastweek_iso = $sundaylastweek_iso;
     // firstday this month
     $firstdayofthismonth_iso = getFirstDayOfCurrentMonth();
     //debugMessage('1st day this month '.$firstdayofthismonth_iso);
     $this->view->firstdayofthismonth_iso = $firstdayofthismonth_iso;
     // lastday this month
     $lastdayofthismonth_iso = getLastDayOfCurrentMonth();
     //debugMessage('last day this month '.$lastdayofthismonth_iso);
     $this->view->lastdayofthismonth_iso = $lastdayofthismonth_iso;
     // firstday last month
     $firstdayoflastmonth_iso = getFirstDayOfMonth(date('m') - 1, date('Y'));
     //debugMessage('1st day last month '.$firstdayoflastmonth_iso);
     $this->view->firstdayoflastmonth_iso = $firstdayoflastmonth_iso;
     // lastday last month
     $lastdayoflastmonth_iso = getLastDayOfMonth(date('m') - 1, date('Y'));
     //debugMessage('last day last month '.$lastdayoflastmonth_iso);
     $this->view->lastdayoflastmonth_iso = $lastdayoflastmonth_iso;
     // firstday 2 month ago
     $firstdayof2monthago_iso = getFirstDayOfMonth(date('m') - 2, date('Y'));
     //debugMessage('1st day 2 month ago '.$firstdayof2monthago_iso);
     $this->view->firstdayof2monthago_iso = $firstdayof2monthago_iso;
     // lastday 2 month ago
     $lastdayof2monthago_iso = getLastDayOfMonth(date('m') - 2, date('Y'));
     //debugMessage('last day last month '.$lastdayof2monthago_iso);
     $this->view->lastdayof2monthago_iso = $lastdayof2monthago_iso;
     // firstday 3 month ago
     $firstdayof3monthago_iso = getFirstDayOfMonth(date('m') - 3, date('Y'));
     //debugMessage('1st day 3 month ago '.$firstdayof3monthago_iso);
     $this->view->firstdayof3monthago_iso = $firstdayof3monthago_iso;
     // lastday 3 month ago
     $lastdayof3monthago_iso = getLastDayOfMonth(date('m') - 3, date('Y'));
     //debugMessage('last day last month '.$lastdayof3monthago_iso);
     $this->view->lastdayof3monthago_iso = $lastdayof3monthago_iso;
     // firstday this year
     $firstdayofyear_iso = getFirstDayOfMonth(1, date('Y'));
     //debugMessage('1st day this year '.$firstdayofyear_iso);
     $this->view->firstdayofyear_iso = $firstdayofyear_iso;
     // lastday this year
     $lastdayofyear_iso = getLastDayOfMonth(12, date('Y'));
     //debugMessage('last day this year '.$lastdayofyear_iso);
     $this->view->lastdayofyear_iso = $lastdayofyear_iso;
     // first day of month one year ago
     $startofmonth_oneyearago = getFirstDayOfMonth(date('m', strtotime('1 year ago')), date('Y', strtotime('1 year ago')));
     $this->view->startofmonth_oneyearago = $startofmonth_oneyearago;
     $firstsystemday_iso = '2013-01-01';
     $this->view->firstsystemday_iso = $firstsystemday_iso;
 }
コード例 #2
0
ファイル: Leave.php プロジェクト: 7thZoneTechnology/hrms-1
 function sendApprovalConfirmationNotification()
 {
     $template = new EmailTemplate();
     # create mail object
     $mail = getMailInstance();
     $view = new Zend_View();
     $session = SessionWrapper::getInstance();
     // assign values
     $template->assign('firstname', $this->getUser()->getFirstName());
     $statuslabel = $this->isApproved() ? "Approved" : "Rejected";
     $subject = "Leave " . $statuslabel;
     $save_toinbox = true;
     $type = "leave";
     $subtype = "leave_" . strtolower($statuslabel);
     $viewurl = $template->serverUrl($template->baseUrl('leave/view/id/' . encode($this->getID())));
     $rejectreason = "";
     if ($this->isRejected()) {
         $rejectreason = "<br><b>Synopsis:</b> " . $this->getComments() . "";
     }
     $days = $this->getDuration() / getHoursInDay();
     $message_contents = "<p>This is to confirm that your Leave Request from <b>" . changeMySQLDateToPageFormat($this->getStartDate()) . "</b> to <b> " . changeMySQLDateToPageFormat($this->getEndDate()) . "</b> has been successfully " . $statuslabel . $rejectreason . ".</p>\n\t\t<p>To view your request online <a href='" . $viewurl . "'>click here<a></p>\n\t\t<br />\n\t\t<p>" . $this->getApprover()->getName() . "<br />\n\t\t" . getAppName() . "</p>\n\t\t";
     $template->assign('contents', $message_contents);
     $mail->clearRecipients();
     $mail->clearSubject();
     $mail->setBodyHtml('');
     // configure base stuff
     $mail->addTo($this->getUser()->getEmail(), $this->getUser()->getName());
     // set the send of the email address
     $mail->setFrom(getDefaultAdminEmail(), getDefaultAdminName());
     $mail->setSubject($subject);
     // render the view as the body of the email
     $html = $template->render('default.phtml');
     $mail->setBodyHtml($html);
     // debugMessage($html); exit();
     if ($this->getUser()->allowEmailForTimesheetApproval() && !isEmptyString($this->getUser()->getEmail())) {
         try {
             $mail->send();
             $session->setVar("custommessage1", "Email sent to " . $this->getUser()->getEmail());
         } catch (Exception $e) {
             $session->setVar(ERROR_MESSAGE, 'Email notification not sent! ' . $e->getMessage());
         }
     }
     $mail->clearRecipients();
     $mail->clearSubject();
     $mail->setBodyHtml('');
     $mail->clearFrom();
     if ($save_toinbox) {
         # save copy of message to user's application inbox
         $message_dataarray = array("senderid" => DEFAULT_ID, "subject" => $subject, "contents" => $message_contents, "html" => $html, "type" => $type, "subtype" => $subtype, "refid" => $this->getID(), "recipients" => array(md5(1) => array("recipientid" => $this->getUserID())));
         // debugMessage($message_dataarray);
         // process message data
         $message = new Message();
         $message->processPost($message_dataarray);
         $message->save();
     }
     return true;
 }
コード例 #3
0
 function getBirthDateFormatted()
 {
     $birth = "--";
     if (!isEmptyString($this->getDateOfBirth())) {
         $birth = changeMySQLDateToPageFormat($this->getDateOfBirth());
     }
     return $birth;
 }
コード例 #4
0
 function completeAction()
 {
     $this->_helper->layout->disableLayout();
     $this->_helper->viewRenderer->setNoRender(TRUE);
     $session = SessionWrapper::getInstance();
     $formvalues = $this->_getAllParams();
     // debugMessage($formvalues); exit;
     $config = Zend_Registry::get("config");
     $payroll = new Payroll();
     $payroll->populate($this->_getParam('id'));
     $payroll->setStatus($this->_getParam('status'));
     // debugMessage($payroll->getStartDate()." - ".$payroll->getEndDate());
     $ledger_collection = new Doctrine_Collection(Doctrine_Core::getTable("Ledger"));
     $timesheet_collection = new Doctrine_Collection(Doctrine_Core::getTable("Timesheet"));
     $leave_collection = new Doctrine_Collection(Doctrine_Core::getTable("Ledger"));
     $employees = $payroll->getdetails();
     // debugMessage($employees->toArray());
     foreach ($employees as $employee) {
         $results_credits_array = array();
         // check of benefit additions
         if (decode($employee->getbenefitdetails()) != "[]" && $employee->getbenefitdetails() != "W10=") {
             $results_credits_array = objectToArray(json_decode(decode($employee->getbenefitdetails())));
             // debugMessage($results_credits_array);
             foreach ($results_credits_array as $line) {
                 if (!isArrayKeyAnEmptyString('ids', $line)) {
                     $ids_array = explode(',', $line['ids']);
                     if (count($ids_array) > 0) {
                         foreach ($ids_array as $id) {
                             $ledger = new Ledger();
                             $ledger->populate($id);
                             $ledger->setPayrollID($employee->getPayrollID());
                             $ledger_collection->add($ledger);
                             // debugMessage($ledger->toArray());
                         }
                     }
                 }
             }
         }
         // check for deductions
         if (decode($employee->getdeductiondetails()) != "[]" && $employee->getdeductiondetails() != "W10=") {
             $results_debits_array = objectToArray(json_decode(decode($employee->getdeductiondetails())));
             // debugMessage($results_credits_array);
             foreach ($results_debits_array as $line) {
                 if (!isArrayKeyAnEmptyString('ids', $line)) {
                     $ids_array = explode(',', $line['ids']);
                     if (count($ids_array) > 0) {
                         foreach ($ids_array as $id) {
                             $ledger = new Ledger();
                             $ledger->populate($id);
                             $ledger->setPayrollID($employee->getPayrollID());
                             $ledger_collection->add($ledger);
                             // debugMessage($ledger->toArray());
                         }
                     }
                 }
             }
         }
         // fetch timesheets for each employeee
         $timesheets = $employee->getUser()->getTimesheetDetails($payroll->getStartDate(), $payroll->getEndDate());
         if ($timesheets->count() > 0) {
             // debugMessage($timesheets->toArray());
             foreach ($timesheets as $timesheet) {
                 $timesheet->setPayrollID($employee->getPayrollID());
                 $timesheet_collection->add($timesheet);
             }
         }
         // generate leave accruals for period
         if ($employee->getLeaveHrs() > '0.00' && $employee->getUser()->getIsTimesheetuser() == 1) {
             // debugMessage('>'.$employee->getLeaveHrs());
             $leave = new Ledger();
             $leave_array = array("payrollid" => $payroll->getID(), "userid" => $employee->getUserID(), "ledgertype" => 2, "trxntype" => 1, "leaveid" => 1, "trxndate" => $payroll->getEndDate(), "startdate" => $payroll->getStartDate(), "enddate" => $payroll->getEndDate(), "leavelength" => $employee->getLeaveHrs() * getHoursInDay(), "lengthtype" => 1, "status" => 1, "remarks" => "Auto Accrual from Payroll (" . changeMySQLDateToPageFormat($payroll->getStartDate()) . " - " . changeMySQLDateToPageFormat($payroll->getEndDate()) . ") ", "createdby" => $session->getVar("userid"), "approvedbyid" => $session->getVar("userid"), "dateapproved" => date('Y-m-d'), "payrolltrigger" => 1);
             $leave->processPost($leave_array);
             /* debugMessage($leave->toArray());
             			debugMessage('errors are '.$leave->getErrorStackAsString()); */
             if (!$leave->hasError()) {
                 $leave_collection->add($leave);
             }
         }
         if ($employee->getSickHrs() > '0.00' && $employee->getUser()->getIsTimesheetuser() == 1) {
             // debugMessage('>'.$employee->getLeaveHrs());
             $leave = new Ledger();
             $leave_array = array("payrollid" => $payroll->getID(), "userid" => $employee->getUserID(), "ledgertype" => 2, "trxntype" => 1, "leaveid" => 2, "trxndate" => $payroll->getEndDate(), "startdate" => $payroll->getStartDate(), "enddate" => $payroll->getEndDate(), "leavelength" => $employee->getSickHrs() * getHoursInDay(), "lengthtype" => 1, "status" => 1, "remarks" => "Auto Accrued from Payroll (" . changeMySQLDateToPageFormat($payroll->getStartDate()) . " - " . changeMySQLDateToPageFormat($payroll->getEndDate()) . ") ", "createdby" => $session->getVar("userid"), "approvedbyid" => $session->getVar("userid"), "dateapproved" => date('Y-m-d'), "payrolltrigger" => 1);
             $leave->processPost($leave_array);
             /*debugMessage($leave->toArray());
             		debugMessage('errors are '.$leave->getErrorStackAsString()); */
             if (!$leave->hasError()) {
                 $leave_collection->add($leave);
             }
         }
         // generate recurring monthly benefits
         $newledgertrxns = array();
         if (decode($employee->getrecurringtrxns()) != "[]" && $employee->getrecurringtrxns() != "W10=") {
             $newledgertrxns = objectToArray(json_decode(decode($employee->getrecurringtrxns())));
             // debugMessage($newledgertrxns);
             foreach ($newledgertrxns as $line) {
                 // debugMessage($line);
                 foreach ($line as $key => $value) {
                     $ledger = new Ledger();
                     $ledger_array = array("payrollid" => $payroll->getID(), "payrolltrigger" => 1, "userid" => $employee->getUserID(), "ledgertype" => 1, "trxntype" => $value['trxntype'], "benefitid" => $value['benefitid'], "trxndate" => $payroll->getEndDate(), "startdate" => $payroll->getStartDate(), "enddate" => $payroll->getEndDate(), "amount" => $value['amount'], "status" => 1, "remarks" => "Auto Accrued from Payroll (" . changeMySQLDateToPageFormat($payroll->getStartDate()) . " - " . changeMySQLDateToPageFormat($payroll->getEndDate()) . ") ", "createdby" => $session->getVar("userid"), "approvedbyid" => $session->getVar("userid"), "dateapproved" => date('Y-m-d'), "istaxable" => isArrayKeyAnEmptyString('istaxable', $value) ? 0 : $value['istaxable']);
                     $ledger->processPost($ledger_array);
                     /* debugMessage($ledger->toArray());
                     			debugMessage('errors are '.$ledger->getErrorStackAsString()); */
                     if (!$ledger->hasError()) {
                         $ledger_collection->add($ledger);
                     }
                 }
             }
         }
         // add nssf to benefits if it exists
         if ($employee->getNssf() > 0) {
             $ledger = new Ledger();
             $ledger_array = array("payrollid" => $payroll->getID(), "payrolltrigger" => 1, "userid" => $employee->getUserID(), "ledgertype" => 1, "trxntype" => 2, "benefitid" => 19, "trxndate" => $payroll->getEndDate(), "startdate" => $payroll->getStartDate(), "enddate" => $payroll->getEndDate(), "amount" => $employee->getNssf(), "status" => 1, "remarks" => "Auto Accrued from Payroll (" . changeMySQLDateToPageFormat($payroll->getStartDate()) . " - " . changeMySQLDateToPageFormat($payroll->getEndDate()) . ") ", "createdby" => $session->getVar("userid"), "approvedbyid" => $session->getVar("userid"), "dateapproved" => date('Y-m-d'));
             $ledger->processPost($ledger_array);
             /* debugMessage($ledger->toArray());
             		 debugMessage('errors are '.$ledger->getErrorStackAsString()); */
             if (!$ledger->hasError()) {
                 $ledger_collection->add($ledger);
             }
         }
         // add paye to benefits if it exists
         if ($employee->getPaye() > 0) {
             $ledger = new Ledger();
             $ledger_array = array("payrollid" => $payroll->getID(), "payrolltrigger" => 1, "userid" => $employee->getUserID(), "ledgertype" => 1, "trxntype" => 2, "benefitid" => 20, "trxndate" => $payroll->getEndDate(), "startdate" => $payroll->getStartDate(), "enddate" => $payroll->getEndDate(), "amount" => $employee->getPaye(), "status" => 1, "remarks" => "Auto Accrued from Payroll (" . changeMySQLDateToPageFormat($payroll->getStartDate()) . " - " . changeMySQLDateToPageFormat($payroll->getEndDate()) . ") ", "createdby" => $session->getVar("userid"), "approvedbyid" => $session->getVar("userid"), "dateapproved" => date('Y-m-d'));
             $ledger->processPost($ledger_array);
             /* debugMessage($ledger->toArray());
             		 debugMessage('errors are '.$ledger->getErrorStackAsString()); */
             if (!$ledger->hasError()) {
                 $ledger_collection->add($ledger);
             }
         }
     }
     // debugMessage('exiting here');
     // exit;
     // save collection
     try {
         // update payroll status
         $payroll->save();
         // update benefits on the payroll
         if ($ledger_collection->count() > 0) {
             // debugMessage($ledger_collection->toArray());
             $ledger_collection->save();
         }
         // update timesheets on the payroll
         if ($timesheet_collection->count() > 0) {
             // debugMessage($timesheet_collection->toArray());
             $timesheet_collection->save();
         }
         // assign leave benefits
         if ($leave_collection->count() > 0) {
             // debugMessage($leave_collection->toArray());
             $leave_collection->save();
         }
         // set success message
         $msg = "Payroll Successfully Completed and Approved. Please note that this has been locked from any further updates. ";
         if (!isEmptyString($this->_getParam(SUCCESS_MESSAGE))) {
             $msg = $this->_getParam($this->_translate->translate($this->_getParam(SUCCESS_MESSAGE)));
         }
         $session->setVar(SUCCESS_MESSAGE, $msg);
         // debugMessage('success '); exit;
     } catch (Exception $e) {
         $session->setVar(ERROR_MESSAGE, "Error in saving Payroll. " . $e->getMessage());
         // debugMessage('Error in completing payroll. '.$e->getMessage()); exit;
     }
     $url = $this->view->baseUrl('payroll/list/id/' . encode($payroll->getID()) . '/issuepayslips/1');
     if (!isEmptyString($this->_getParam(URL_SUCCESS))) {
         $url = decode($this->_getParam(URL_SUCCESS));
     }
     $session->setVar("issuepayslips", '1');
     $this->_helper->redirector->gotoUrl($url);
 }