Example #1
0
 /**
  * Function to delete Resource
  *
  * @param  int  $id     Id of the Resource to be deleted.
  *
  * @return boolean
  *
  * @access public
  * @static
  */
 static function del($id)
 {
     $resource = new CRM_Booking_DAO_Resource();
     $resource->id = $id;
     $resource->is_deleted = 1;
     return $resource->save();
 }
Example #2
0
 /**
  * Browse all resources.
  *
  * @return void
  * @access public
  * @static
  */
 function browse($action = NULL)
 {
     $types = CRM_Booking_BAO_Resource::buildOptions('type_id', 'create');
     $locations = CRM_Booking_BAO_Resource::buildOptions('location_id', 'create');
     // get all custom groups sorted by weight
     $resources = array();
     $dao = new CRM_Booking_DAO_Resource();
     $dao->orderBy('weight');
     $dao->is_deleted = FALSE;
     $dao->find();
     while ($dao->fetch()) {
         $resources[$dao->id] = array();
         CRM_Core_DAO::storeValues($dao, $resources[$dao->id]);
         $resources[$dao->id]['type'] = CRM_Utils_Array::value(CRM_Utils_Array::value('type_id', $resources[$dao->id]), $types);
         $resources[$dao->id]['location'] = CRM_Utils_Array::value(CRM_Utils_Array::value('location_id', $resources[$dao->id]), $locations);
         // form all action links
         $action = array_sum(array_keys($this->links()));
         // update enable/disable links.
         if ($dao->is_active) {
             $action -= CRM_Core_Action::ENABLE;
         } else {
             $action -= CRM_Core_Action::DISABLE;
         }
         $resources[$dao->id]['action'] = CRM_Core_Action::formLink(self::links(), $action, array('id' => $dao->id));
     }
     $this->assign('rows', $resources);
 }
Example #3
0
 /**
  * returns the list of fields that can be exported
  *
  * @access public
  * return array
  * @static
  */
 static function &export($prefix = false)
 {
     if (!self::$_export) {
         self::$_export = array();
         $fields = self::fields();
         foreach ($fields as $name => $field) {
             if (CRM_Utils_Array::value('export', $field)) {
                 if ($prefix) {
                     self::$_export['booking_resource'] =& $fields[$name];
                 } else {
                     self::$_export[$name] =& $fields[$name];
                 }
             }
         }
     }
     return self::$_export;
 }