예제 #1
0
 /**
  * Browse all absence types
  *
  *
  * @return void
  * @access public
  * @static
  */
 function browse()
 {
     // get all hours location sorted by id
     $hoursLocation = array();
     $dao = new CRM_Hrjobcontract_DAO_HoursLocation();
     $dao->orderBy('id');
     $dao->find();
     while ($dao->fetch()) {
         $hoursLocation[$dao->id] = array();
         $hoursLocation[$dao->id]['id'] = $dao->id;
         $hoursLocation[$dao->id]['location'] = $dao->location;
         $hoursLocation[$dao->id]['standard_hours'] = $dao->standard_hours;
         $hoursLocation[$dao->id]['periodicity'] = $dao->periodicity;
         $hoursLocation[$dao->id]['is_active'] = $dao->is_active;
         // form all action links
         $action = array_sum(array_keys($this->links()));
         if ($dao->is_active) {
             $action -= CRM_Core_Action::ENABLE;
         } else {
             $action -= CRM_Core_Action::DISABLE;
         }
         //if this absence type has its related activities/leaves then don't show DELETE action
         $isDelete = FALSE;
         /*if ($dao->debit_activity_type_id) {
             $result = civicrm_api3('Activity', 'get', array('activity_type_id' => $dao->debit_activity_type_id));
             if (count($result['values'])) {
               $isDelete = TRUE;
             }
           }
           if (!$isDelete && $dao->credit_activity_type_id) {
             $result = civicrm_api3('Activity', 'get', array('activity_type_id' => $dao->credit_activity_type_id));
             if (count($result['values'])) {
               $isDelete = TRUE;
             }
           }*/
         if ($isDelete) {
             $action -= CRM_Core_Action::DELETE;
         }
         $hoursLocation[$dao->id]['action'] = CRM_Core_Action::formLink(self::links(), $action, array('id' => $dao->id));
     }
     $this->assign('rows', $hoursLocation);
 }