예제 #1
0
 private function _markApprovedLeaveAsTaken()
 {
     if (self::$doneMarkingApprovedLeaveAsTaken) {
         return;
     } else {
         $date = date('Y-m-d');
         $conn = Doctrine_Manager::connection()->getDbh();
         $query = "SELECT l.id from ohrm_leave l WHERE l.`date` < ? AND l.status = ?";
         $statement = $conn->prepare($query);
         $result = $statement->execute(array($date, Leave::LEAVE_STATUS_LEAVE_APPROVED));
         if ($result) {
             $ids = $statement->fetchAll(PDO::FETCH_COLUMN, 0);
             if (count($ids) > 0) {
                 $q = Doctrine_Query::create()->update('Leave l')->set('l.status', Leave::LEAVE_STATUS_LEAVE_TAKEN)->whereIn('l.id', $ids);
                 $q->execute();
                 // TODO: Optimize
                 // No longer needed, since entitlement.used values are updated when leave is applied/assigned
                 /*$query = "SELECT le.entitlement_id, le.length_days FROM ohrm_leave_leave_entitlement le " .
                                             "WHERE le.leave_id IN (" . implode(',', $ids) . ")";
                 
                                     $statement = $conn->prepare($query);
                                     $result = $statement->execute();
                                     if ($result) {
                 
                                         $updateQuery = "UPDATE ohrm_leave_entitlement e " .
                                                 "SET e.days_used = e.days_used + ? " .
                                                 "WHERE e.id = ?";
                 
                                         $updateStatement = $conn->prepare($updateQuery);
                 
                                         while ($row = $statement->fetch()) {
                                             $updateStatement->execute(array($row['length_days'], $row['entitlement_id']));
                                         }
                                     }*/
             }
         }
         self::$doneMarkingApprovedLeaveAsTaken = true;
     }
 }
예제 #2
0
 private function _markApprovedLeaveAsTaken()
 {
     if (self::$doneMarkingApprovedLeaveAsTaken) {
         return;
     } else {
         $date = date('Y-m-d');
         $q = Doctrine_Query::create()->update('Leave l')->set('l.leave_status', Leave::LEAVE_STATUS_LEAVE_TAKEN)->where('l.leave_status = ?', Leave::LEAVE_STATUS_LEAVE_APPROVED)->andWhere('l.leave_date < ?', $date);
         $q->execute();
         self::$doneMarkingApprovedLeaveAsTaken = true;
     }
 }
 public function getLeaveItems()
 {
     $leaveRequestDao = new LeaveRequestDao();
     return $leaveRequestDao->fetchLeave($this->getId());
 }
 /**
  * @group orangehrmLeaveListDataExtractorCsvPlugin
  */
 public function testGetDetailedLeaveRequestSearchResultAsArray6()
 {
     $searchParams = new ParameterObject(array('dateRange' => new DateRange("2010-09-01", "2010-09-07"), 'statuses' => null, 'employeeFilter' => null, 'leavePeriod' => null, 'leaveType' => 'LTY002', 'noOfRecordsPerPage' => '', 'cmbWithTerminated' => 'yes'));
     $dao = new LeaveRequestDao();
     $this->assertEquals(2, sizeof($dao->getDetailedLeaveRequestSearchResultAsArray($searchParams)));
 }