コード例 #1
0
 public static function parseDeleteData($postArr)
 {
     $payPeriods = array();
     if (is_array($postArr['chkPayPeriodId'])) {
         for ($i = 0; $i < count($postArr['chkPayPeriodId']); $i++) {
             $tmpObj = new HspPayPeriod();
             $tmpObj->setId($postArr['chkPayPeriodId'][$i]);
             $payPeriods[] = $tmpObj;
         }
     }
     return $payPeriods;
 }
コード例 #2
0
ファイル: Hsp.php プロジェクト: noikiy/owaspbwa
 /**
  * This function updates 'total_accrued' field in 'hs_hr_hsp_summary'.
  * It first calls 'hsp_accrued_last_updated' field from 'hs_hr_config' table.
  * If updated date is older than current day, it checks for new 'check_date's from
  * 'hs_hr_pay_period' table. If new check dates of current year are available, it checks current
  * HSP scheme and updates 'total_accrued' only for that scheme.
  */
 public static function updateAccrued($year)
 {
     if (Config::getHspAccruedLastUpdated() < date('Y-m-d')) {
         $checkDates = HspPayPeriod::countCheckDates(Config::getHspAccruedLastUpdated(), date('Y-m-d'));
         if ($checkDates > 0) {
             $selectTable = "`" . self::DB_TABLE_HSP_SUMMARY . "`";
             $selectFields[0] = "`" . self::DB_FIELD_SUMMARY_ID . "`";
             $selectFields[1] = "`" . self::DB_FIELD_HSP_PLAN_STATUS . "`";
             $selectFields[2] = "`" . self::DB_FIELD_EMPLOYER_AMOUNT . "`";
             $selectFields[3] = "`" . self::DB_FIELD_EMPLOYEE_AMOUNT . "`";
             $selectFields[4] = "`" . self::DB_FIELD_TOTAL_ACCRUED . "`";
             $selectFields[5] = "`" . self::DB_FIELD_EMPLOYEE_ID . "`";
             $selectConditions[0] = self::_twoHspPlansCondition(Config::getHspCurrentPlan());
             $selectConditions[1] = "`" . self::DB_FIELD_HSP_PLAN_YEAR . "`= '" . $year . "'";
             $sqlBuilder = new SQLQBuilder();
             $query = $sqlBuilder->simpleSelect($selectTable, $selectFields, $selectConditions);
             $dbConnection = new DMLFunctions();
             $result = $dbConnection->executeQuery($query);
             $rowCount = $dbConnection->dbObject->numberOfRows($result);
             for ($i = 0; $i < $rowCount; $i++) {
                 $row = $dbConnection->dbObject->getArray($result);
                 if (!Hsp::_isEmployeeTerminated($row[5])) {
                     if ($row[1] == Hsp::HSP_STATUS_ACTIVE || $row[1] == Hsp::HSP_STATUS_PENDING_HALT) {
                         $updatedArray[$i][0] = $row[0];
                         $updatedArray[$i][1] = $row[4] + $checkDates * ($row[2] + $row[3]);
                     } else {
                         $updatedArray[$i][0] = $row[0];
                         $updatedArray[$i][1] = $row[4];
                     }
                 } else {
                     $updatedArray[$i][0] = $row[0];
                     $updatedArray[$i][1] = $row[4];
                 }
             }
             for ($i = 0; $i < count($updatedArray); $i++) {
                 $updateTable = "`" . self::DB_TABLE_HSP_SUMMARY . "`";
                 $updateFields[0] = "`" . self::DB_FIELD_TOTAL_ACCRUED . "`";
                 $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::setHspAccruedLastUpdated(date('Y-m-d'));
     }
 }
コード例 #3
0
ファイル: HspPayPeriodTest.php プロジェクト: noikiy/owaspbwa
 public function testCountCheckDates()
 {
     $this->assertTrue(mysql_query("TRUNCATE TABLE `hs_hr_pay_period`"));
     $this->assertTrue(mysql_query("INSERT INTO hs_hr_pay_period VALUES(1, '2007-12-01', '2007-12-31', '2007-12-31', '2007-12-25', '2007-12-20')"));
     $this->assertTrue(mysql_query("INSERT INTO hs_hr_pay_period VALUES(2, '2008-01-01', '2008-01-31', '2008-01-31', '2008-01-25', '2008-01-20')"));
     $this->assertTrue(mysql_query("INSERT INTO hs_hr_pay_period VALUES(3, '2008-02-01', '2008-02-29', '2008-02-29', '2008-02-25', '2008-02-20')"));
     $this->assertTrue(mysql_query("INSERT INTO hs_hr_pay_period VALUES(4, '2008-03-01', '2008-03-31', '2008-03-31', '2008-03-25', '2008-03-20')"));
     $this->assertEquals(HspPayPeriod::countCheckDates("2008-01-01", "2008-04-01"), 3);
     $this->assertEquals(HspPayPeriod::countCheckDates("2007-12-01", "2008-04-01"), 3);
     $this->assertEquals(HspPayPeriod::countCheckDates("2005-12-01", "2008-04-01"), 3);
     $this->assertEquals(HspPayPeriod::countCheckDates("2008-01-25", "2008-03-31"), 2);
     $this->assertEquals(HspPayPeriod::countCheckDates("2008-03-31", "2008-05-31"), 0);
 }
コード例 #4
0
 public static function viewEditPayPeriod($year, $id)
 {
     $path = "/templates/benefits/editPayPeriods.php";
     $tmpOb[0] = $year;
     $tmpOb[1] = HspPayPeriod::getPayPeriod($id);
     $template = new TemplateMerger($tmpOb, $path);
     $template->display();
 }
コード例 #5
0
ファイル: HspPayPeriod.php プロジェクト: noikiy/owaspbwa
 private static function _buildObjArr($result)
 {
     $objArr = array();
     while ($row = mysql_fetch_assoc($result)) {
         $tmpArr = new HspPayPeriod();
         $tmpArr->setId($row[self::PAY_PERIOD_DB_FIELD_ID]);
         $tmpArr->setStartDate($row[self::PAY_PERIOD_DB_FIELD_START_DATE]);
         $tmpArr->setEndDate($row[self::PAY_PERIOD_DB_FIELD_END_DATE]);
         $tmpArr->setCloseDate($row[self::PAY_PERIOD_DB_FIELD_CLOSE_DATE]);
         $tmpArr->setCheckDate($row[self::PAY_PERIOD_DB_FIELD_CHECK_DATE]);
         $tmpArr->setTimesheetAprovalDueDate($row[self::PAY_PERIOD_DB_FIELD_TIMESHEET_APROVAL_DUE_DATE]);
         $objArr[] = $tmpArr;
     }
     return $objArr;
 }