Exemple #1
0
 /**
  * For a give year, this function updates 'total_used' for all employees
  * based on current HSP Scheme and 'hsp_used_last_updated'
  */
 public static function updateUsed($year)
 {
     if (Config::getHspUsedLastUpdated() < date('Y-m-d')) {
         $selectTable = "`" . self::DB_TABLE_HSP_SUMMARY . "`";
         $selectFields[0] = "`" . self::DB_FIELD_SUMMARY_ID . "`";
         $selectFields[1] = "`" . self::DB_FIELD_EMPLOYEE_ID . "`";
         $selectFields[2] = "`" . self::DB_FIELD_HSP_PLAN_ID . "`";
         $selectFields[3] = "`" . self::DB_FIELD_TOTAL_USED . "`";
         $selectConditions[0] = "`" . self::DB_FIELD_HSP_PLAN_YEAR . "` = '" . $year . "'";
         $selectConditions[1] = self::_twoHspPlansCondition(Config::getHspCurrentPlan());
         $sqlBuilder = new SQLQBuilder();
         $query = $sqlBuilder->simpleSelect($selectTable, $selectFields, $selectConditions);
         $dbConnection = new DMLFunctions();
         $result = $dbConnection->executeQuery($query);
         $rowCount = $dbConnection->dbObject->numberOfRows($result);
         $hspUsedLastUpdated = Config::getHspUsedLastUpdated();
         for ($i = 0; $i < $rowCount; $i++) {
             $row = $dbConnection->dbObject->getArray($result);
             $updatedArray[$i][0] = $row[0];
             $updatedArray[$i][1] = $row[3] + HspPaymentRequest::calculateNewHspUsed($row[1], $row[2], $hspUsedLastUpdated);
         }
         for ($i = 0; $i < count($updatedArray); $i++) {
             $updateTable = "`" . self::DB_TABLE_HSP_SUMMARY . "`";
             $updateFields[0] = "`" . self::DB_FIELD_TOTAL_USED . "`";
             $updateValues[0] = "'" . $updatedArray[$i][1] . "'";
             $updateConditions[0] = "`" . self::DB_FIELD_SUMMARY_ID . "` = '" . $updatedArray[$i][0] . "'";
             $query = $sqlBuilder->simpleUpdate($updateTable, $updateFields, $updateValues, $updateConditions);
             $dbConnection->executeQuery($query);
         }
         Config::setHspUsedLastUpdated(date('Y-m-d'));
     }
 }
 /**
  * send email to hr admin group notifying hsp payment request made by a employee.
  * @param HspPaymentRequest $hspPaymentRequest model/HspPaymentRequest bean
  * @return boolean $success true if successfuly send or null otherwise
  **/
 public function sendHspPaymentRequestNotifications($hspPaymentRequest, $link)
 {
     $toAddress = null;
     $subject = null;
     $msg = null;
     $empId = null;
     $empName = null;
     $logMsg = '';
     $empId = $hspPaymentRequest->getEmployeeId();
     $empName = $this->_getEmployeeName($empId);
     $emailNotificationTypeId = EmailNotificationConfiguration::EMAILNOTIFICATIONCONFIGURATION_NOTIFICATION_TYPE_HSP;
     $toAddress = $this->_getNotificationAddress($emailNotificationTypeId);
     $subject = $this->_getPaymentRequestSubject($empName);
     $msg = $this->_getPaymentRequestMsg($empName, $link);
     $success = $this->_sendEmail($msg, $subject, $toAddress);
     return $success;
 }
 public function testCalculateNewHspUsed()
 {
     $this->assertTrue(mysql_query("TRUNCATE `hs_hr_employee`;", $this->connection), mysql_error());
     $this->assertTrue(mysql_query("TRUNCATE `hs_hr_hsp_payment_request`;", $this->connection), mysql_error());
     $this->assertTrue(mysql_query("INSERT INTO `hs_hr_employee` ({$this->employeeFields}) VALUES (1, '001', 'Arnold', 'Subasinghe', '', 'Arnold', 0, NULL, NULL, NULL, NULL, NULL, '', '', '', '', NULL, '', NULL, NULL, NULL, NULL, '', '', '', 'AF', '', '', '', '', '', '', NULL, NULL, '')"), mysql_error());
     $this->assertTrue(mysql_query("INSERT INTO `hs_hr_hsp_payment_request` ({$this->paymentRequestFields}) " . "VALUES (1, 1, 1, '" . date('Y') . "-02-01', 'Test provider', 'Tester', 'Just testing', '150', 'TestX', '12345GD', " . "'1231, Test Grove, Test City', 'Test', '" . date('Y') . "-02-02',  '123552-55821-ff25', 1)"), mysql_error());
     $this->assertTrue(mysql_query("INSERT INTO `hs_hr_hsp_payment_request` ({$this->paymentRequestFields}) " . "VALUES (2, 1, 1, '" . date('Y') . "-02-10', 'Test provider', 'Tester', 'Just testing', '100', 'TestX', '12345GD', " . "'1231, Test Grove, Test City', 'Test', '" . date('Y') . "-02-11',  '123552-55821-ff25', 1)"), mysql_error());
     $this->assertTrue(mysql_query("INSERT INTO `hs_hr_hsp_payment_request` ({$this->paymentRequestFields}) " . "VALUES (3, 1, 1, '" . date('Y') . "-02-20', 'Test provider', 'Tester', 'Just testing', '127', 'TestX', '12345GD', " . "'1231, Test Grove, Test City', 'Test', '" . date('Y') . "-02-21',  '123552-55821-ff25', 1)"), mysql_error());
     $lastUpdated = date('Y') . "-02-05";
     $this->assertEquals(HspPaymentRequest::calculateNewHspUsed(1, 1, $lastUpdated), 227);
     $lastUpdated = date('Y') - 1 . "-02-05";
     $this->assertEquals(HspPaymentRequest::calculateNewHspUsed(1, 1, $lastUpdated), 377);
     $this->assertTrue(mysql_query("TRUNCATE `hs_hr_employee`;", $this->connection), mysql_error());
     $this->assertTrue(mysql_query("TRUNCATE `hs_hr_hsp_payment_request`;", $this->connection), mysql_error());
 }
 public static function viewHspRequestView($id, $edit = false)
 {
     $year = date('Y');
     $authorizeObj = new authorize($_SESSION['empID'], $_SESSION['isAdmin']);
     $path = "/templates/benefits/editHspPaymentRequest.php";
     $request = HspPaymentRequest::getHspRequest($id);
     $empID = $_SESSION['empID'];
     $planId = $request->getHspId();
     $planName = DefineHsp::getHspPlanName($planId);
     $tmpOb[0] = $year;
     $tmpOb[1] = null;
     if ($edit) {
         $tmpOb[2] = 1;
     } else {
         $tmpOb[2] = 2;
     }
     $tmpOb[3] = $request;
     $tmpOb[4] = $authorizeObj;
     $tmpOb[5] = $_SESSION['empID'];
     $tmpOb[6] = $id;
     $tmpOb[9] = $planName;
     $template = new TemplateMerger($tmpOb, $path);
     $template->display();
 }
 public static function parseSaveData($postArr)
 {
     $hspPaymentRequest = new HspPaymentRequest();
     if (!empty($postArr['txtId'])) {
         $hspPaymentRequest->setId($postArr['txtId']);
     }
     if (!empty($postArr['txtEmployeeId'])) {
         $hspPaymentRequest->setEmployeeId($postArr['txtEmployeeId']);
     }
     if (!empty($postArr['cmbPlanName'])) {
         $hspPlanName = $postArr['cmbPlanName'];
     } else {
         if (!empty($postArr['hidPlanName'])) {
             $hspPlanName = $postArr['hidPlanName'];
         }
     }
     $hspPaymentRequest->setHspId(DefineHsp::getHspPlanId($hspPlanName));
     if (!empty($postArr['txtDateIncurred'])) {
         $hspPaymentRequest->setDateIncurred($postArr['txtDateIncurred']);
     }
     if (!empty($postArr['txtProviderName'])) {
         $hspPaymentRequest->setProviderName($postArr['txtProviderName']);
     }
     if (!empty($postArr['txtPersonIncurringExpense'])) {
         $hspPaymentRequest->setPersonIncurringExpense($postArr['txtPersonIncurringExpense']);
     }
     if (!empty($postArr['txtExpenseDescription'])) {
         $hspPaymentRequest->setExpenseDescription($postArr['txtExpenseDescription']);
     }
     if (!empty($postArr['txtExpenseAmount'])) {
         $hspPaymentRequest->setExpenseAmount($postArr['txtExpenseAmount']);
     }
     if (!empty($postArr['txtPaymentMadeTo'])) {
         $hspPaymentRequest->setPaymentMadeTo($postArr['txtPaymentMadeTo']);
     }
     if (!empty($postArr['txtThirdPartyAccountNumber'])) {
         $hspPaymentRequest->setThirdPartyAccountNumber($postArr['txtThirdPartyAccountNumber']);
     }
     if (!empty($postArr['txtMailAddress'])) {
         $hspPaymentRequest->setMailAddress($postArr['txtMailAddress']);
     }
     if (!empty($postArr['txtComments'])) {
         $hspPaymentRequest->setComments($postArr['txtComments']);
     }
     if (!empty($postArr['txtDatePaid'])) {
         $hspPaymentRequest->setDatePaid($postArr['txtDatePaid']);
     }
     if (!empty($postArr['txtCheckNumber'])) {
         $hspPaymentRequest->setCheckNumber($postArr['txtCheckNumber']);
     }
     if (!empty($postArr['checkPaperworkSubmitted'])) {
         $hspPaymentRequest->setPaperWorkSubmitted($postArr['checkPaperworkSubmitted']);
     }
     if (!empty($postArr['txtHrNotes'])) {
         $hspPaymentRequest->setHrNotes($postArr['txtHrNotes']);
     }
     return $hspPaymentRequest;
 }
 private static function _buildObjArr($result)
 {
     $objArr = array();
     while ($row = mysql_fetch_assoc($result)) {
         $tmpArr = new HspPaymentRequest();
         $tmpArr->setId($row[self::DB_FIELD_ID]);
         $tmpArr->setHspId($row[self::DB_FIELD_HSP_ID]);
         $tmpArr->setEmployeeId($row[self::DB_FIELD_EMPLOYEE_ID]);
         $tmpArr->setDateIncurred($row[self::DB_FIELD_DATE_INCURRED]);
         $tmpArr->setProviderName($row[self::DB_FIELD_PROVIDER_NAME]);
         $tmpArr->setPersonIncurringExpense($row[self::DB_FIELD_PERSON_INCURRING_EXPENSE]);
         $tmpArr->setExpenseDescription($row[self::DB_FIELD_EXPENSE_DESCRIPTION]);
         $tmpArr->setExpenseAmount($row[self::DB_FIELD_EXPENSE_AMOUNT]);
         $tmpArr->setPaymentMadeTo($row[self::DB_FIELD_PAYMENT_MADE_TO]);
         $tmpArr->setThirdPartyAccountNumber($row[self::DB_FIELD_THIRD_PARTY_ACCOUNT_NUMBER]);
         $tmpArr->setMailAddress($row[self::DB_FIELD_MAIL_ADDRESS]);
         $tmpArr->setComments($row[self::DB_FIELD_COMMENTS]);
         $tmpArr->setDatePaid($row[self::DB_FIELD_DATE_PAID]);
         $tmpArr->setCheckNumber($row[self::DB_FIELD_CHECK_NUMBER]);
         $tmpArr->setStatus($row[self::DB_FIELD_STATUS]);
         $tmpArr->setHrNotes($row[self::DB_FIELD_HR_NOTES]);
         $objArr[] = $tmpArr;
     }
     return $objArr;
 }