Helix Installation   Getting Started   Reference Documentation   Global Functions   Quick Start
ModulesClassesFunctions
 

Class Reference

class asset extends asset_ext

Hide Inherited MembersAsset Management
Description
No description.
 
Constants
constantTABLENAME ["am_asset"][ asset ]
 
Properties
protected_asset_type_id[ asset_db ]
protected_asset_type_id_dirty[ asset_db ]
protected_assetstatus_id[ asset_db ]
protected_assetstatus_id_dirty[ asset_db ]
protected_capex[ asset_db ]
protected_capex_dirty[ asset_db ]
protected_cdate[ asset_db ]
protected_cdate_dirty[ asset_db ]
protected_deleted[ asset_db ]
protected_deleted_dirty[ asset_db ]
protected_department_id[ asset_db ]
protected_department_id_dirty[ asset_db ]
protected_description[ asset_db ]
protected_description_dirty[ asset_db ]
protected_dirty[ obj ]
protected_id[ asset_db ]
protected_id_dirty[ asset_db ]
protected_mdate[ asset_db ]
protected_mdate_dirty[ asset_db ]
protected_model[ asset_db ]
protected_model_dirty[ asset_db ]
protected_name[ asset_db ]
protected_name_dirty[ asset_db ]
protected_part_number[ asset_db ]
protected_part_number_dirty[ asset_db ]
publicproperty_objects_array[ obj ]
protected_quantity[ asset_db ]
protected_quantity_dirty[ asset_db ]
protected_serial_number[ asset_db ]
protected_serial_number_dirty[ asset_db ]
protected_sku[ asset_db ]
protected_sku_dirty[ asset_db ]
protected_unit_price[ asset_db ]
protected_unit_price_dirty[ asset_db ]
 
Methods
publiccommit ( )[ asset_db ]
Parameters
No parameters for this method
Code
152  public function commit()
153  {
154      if ($this->_id > 0)
155      {
156          $this->update();
157      }
158      else
159      {
160          $this->insert();
161      }
162 
163      foreach ($this->property_objects_array as $property=>$object)
164      {
165          $this->{$property} = $object;
166      }
167 
168      return true;
169  }
public__construct ( id )[ asset_db ]
Parameters
optionalid
Code
062  public function __construct($__id=null)
063  {
064      $this->_id = 0;
065      $this->_name = "";
066      $this->_description = "";
067      $this->_asset_type_id = 0;
068      $this->_assetstatus_id = 0;
069      $this->_department_id = 0;
070      $this->_sku = "";
071      $this->_model = "";
072      $this->_part_number = "";
073      $this->_serial_number = "";
074      $this->_unit_price = 0;
075      $this->_quantity = 0;
076      $this->_capex = false;
077      $this->_mdate = null;
078      $this->_cdate = null;
079      $this->_deleted = false;
080 
081      $this->_id_dirty = false;
082      $this->_name_dirty = false;
083      $this->_description_dirty = false;
084      $this->_asset_type_id_dirty = false;
085      $this->_assetstatus_id_dirty = false;
086      $this->_department_id_dirty = false;
087      $this->_sku_dirty = false;
088      $this->_model_dirty = false;
089      $this->_part_number_dirty = false;
090      $this->_serial_number_dirty = false;
091      $this->_unit_price_dirty = false;
092      $this->_quantity_dirty = false;
093      $this->_capex_dirty = false;
094      $this->_mdate_dirty = false;
095      $this->_cdate_dirty = false;
096      $this->_deleted_dirty = false;
097 
098      if (is_null($__id))
099      {
100          return;
101      }
102 
103      $db = asset::db();
104      $q  = " SELECT am_asset.id,am_asset.name,am_asset.description,am_asset.asset_type_id,am_asset.assetstatus_id,am_asset.department_id,am_asset.sku,am_asset.model,am_asset.part_number,am_asset.serial_number,am_asset.unit_price,am_asset.quantity,am_asset.capex,am_asset.mdate,am_asset.cdate,am_asset.deleted ";
105      $q .= " FROM am_asset ";       
106      if (!is_null($__id))
107      {
108          $q .= " WHERE id = '$__id' ";
109      }
110 
111      $db->query($q);
112      if ($db->next_record() && $db->num_rows() == 1)
113      {
114          $this->_id = $db->f("id");
115          $this->_name = $db->f("name");
116          $this->_description = $db->f("description");
117          $this->_asset_type_id = $db->f("asset_type_id");
118          $this->_assetstatus_id = $db->f("assetstatus_id");
119          $this->_department_id = $db->f("department_id");
120          $this->_sku = $db->f("sku");
121          $this->_model = $db->f("model");
122          $this->_part_number = $db->f("part_number");
123          $this->_serial_number = $db->f("serial_number");
124          $this->_unit_price = $db->f("unit_price");
125          $this->_quantity = $db->f("quantity");
126          $this->_capex = $db->f("capex");
127          $this->_mdate = $db->f("mdate");
128          $this->_cdate = $db->f("cdate");
129          $this->_deleted = $db->f("deleted");
130      }
131  }
protected staticdb ( )[ asset_db ]
Parameters
No parameters for this method
Code
1054  protected static function db()
1055  {
1056      return new db();
1057  }
publicdelete ( )[ asset_db ]
Parameters
No parameters for this method
Code
235  public function delete()
236  {
237      $db = asset::db();
238      $q  = " UPDATE am_asset SET ";
239      $q .= " deleted = 1 ";
240      $q .= " WHERE id = " . $this->_id;
241      $db->query($q);
242      $this->deleted = true;
243      return true;
244  }
public staticdelete_all ( )[ asset_db ]
Parameters
No parameters for this method
Code
344  public static function delete_all()
345  {
346      $db = asset::db();
347      $q  = " UPDATE am_asset SET ";
348      $q .= " deleted = 1 ";
349     
350      $db->query($q);
351      return true;
352  }
public__get ( p )[ obj ]
Parameters
requiredp
Code
007  public function __get($p)
008  {
009      $methods = get_class_methods($this);
010      $properties = get_object_vars($this);
011      if (in_array("get_$p",$methods))
012      {
013          return $this->{"get_$p"}();
014      }
015      else if (array_key_exists("_$p",$properties))
016      {
017          return $this->{"_$p"};
018      }
019      else if (in_array("get_" . substr($p,strpos($p,"_")+1), $methods))
020      {
021          return $this->{"get_" . substr($p,strpos($p,"_")+1)}(substr($p,0,strpos($p,"_")));
022      }
023      else
024      {
025          trigger_error("This object [" . get_class($this) . ":$this->id] has no private property '_$p' for the requested public property '$p'",E_USER_WARNING);
026          return null;
027      }
028  }
publicget_array ( )[ obj ]
Parameters
No parameters for this method
Code
096  public function get_array()
097  {
098      return get_object_vars($this);
099  }
publicget_asset_type ( )[ asset_db ]
Parameters
No parameters for this method
Code
424  public function get_asset_type()
425  {
426      return new asset_type($this->asset_type_id);
427  }
publicget_assetdate ( type ["default"] )[ asset_db ]
Parameters
optionaltype ["default"]
Code
460  public function get_assetdate($__type="default")
461  {
462      $object = is_null(keyval($this->property_objects_array,"{$__type}_assetdate")) ? new assetdate($this->get_assetdate_id($__type)) : $this->property_objects_array["{$__type}_assetdate"];
463      $this->property_objects_array["{$__type}_assetdate"] = $object;
464      return $object;
465  }
publicget_assetdate_id ( type ["default"] )[ asset_db ]
Parameters
optionaltype ["default"]
Code
466  public function get_assetdate_id($__type="default")
467  {
468      $ids = $this->get_assetdate_ids($__type, true);
469      return (count($ids)==1 ? $ids[0] : null);
470  }
publicget_assetdate_ids ( type , order , where_clause , limit , offset [0] , get_primary [false] )[ asset_db ]
Parameters
optionaltype
optionalorder
optionalwhere_clause
optionallimit
optionaloffset [0]
optionalget_primary [false]
Code
471  public function get_assetdate_ids($__type=null, $__order=null, $__where_clause=null, $__limit=null, $__offset=0, $__get_primary=false)
472  {
473      $assetdate_ids = array();
474      $db = asset::db();
475      $q  = " SELECT am_assetdate.id FROM am_asset_assetdate INNER JOIN am_assetdate ON am_asset_assetdate.assetdate_id=am_assetdate.id AND am_asset_assetdate.deleted=0 AND am_assetdate.deleted=0 AND am_asset_assetdate.asset_id='$this->id' " . (is_null($__type) ? "" : " AND am_asset_assetdate.asset_assetdate_type_id='" . asset_assetdate::type_id($__type) . "'") . ($__get_primary ? " AND am_asset_assetdate.primary=1 " : "");
476      $q .= is_null($__where_clause) ? "" : " WHERE {$__where_clause}";
477      $q .= is_null($__order) ? "" : " ORDER BY {$__order}";
478      $q .= is_null($__limit) ? "" : " LIMIT {$__offset}, {$__limit}";
479      $db->query($q);
480      while ($db->next_record())
481      {
482          $assetdate_ids[] = $db->f("id");
483      }
484      return $assetdate_ids;
485  }
publicget_assetdate_list ( type , order , where_clause , limit , offset [0] , get_primary [false] )[ asset_db ]
Parameters
optionaltype
optionalorder
optionalwhere_clause
optionallimit
optionaloffset [0]
optionalget_primary [false]
Code
486  public function get_assetdate_list($__type=null, $__order=null, $__where_clause=null, $__limit=null, $__offset=0, $__get_primary=false)
487  {
488      $ids = $this->get_assetdate_ids($__type, $__order, $__where_clause, $__limit, $__offset, $__get_primary);
489      $objects = array();
490      foreach ($ids as $index=>$id)
491      {
492          $objects[$index] = new assetdate($id);
493      }
494      return $objects;
495  }
publicget_assetstatus ( )[ asset_db ]
Parameters
No parameters for this method
Code
436  public function get_assetstatus()
437  {
438      return new assetstatus($this->assetstatus_id);
439  }
publicget_business ( type ["default"] )[ asset_db ]
Parameters
optionaltype ["default"]
Code
657  public function get_business($__type="default")
658  {
659      $object = is_null(keyval($this->property_objects_array,"{$__type}_business")) ? new business($this->get_business_id($__type)) : $this->property_objects_array["{$__type}_business"];
660      $this->property_objects_array["{$__type}_business"] = $object;
661      return $object;
662  }
publicget_business_id ( type ["default"] )[ asset_db ]
Parameters
optionaltype ["default"]
Code
663  public function get_business_id($__type="default")
664  {
665      $ids = $this->get_business_ids($__type, true);
666      return (count($ids)==1 ? $ids[0] : null);
667  }
publicget_business_ids ( type , order , where_clause , limit , offset [0] , get_primary [false] )[ asset_db ]
Parameters
optionaltype
optionalorder
optionalwhere_clause
optionallimit
optionaloffset [0]
optionalget_primary [false]
Code
668  public function get_business_ids($__type=null, $__order=null, $__where_clause=null, $__limit=null, $__offset=0, $__get_primary=false)
669  {
670      $business_ids = array();
671      $db = asset::db();
672      $q  = " SELECT bus_business.entity_id FROM am_asset_business INNER JOIN bus_business ON am_asset_business.business_entity_id=bus_business.entity_id AND am_asset_business.deleted=0 AND bus_business.deleted=0 AND am_asset_business.asset_id='$this->id' " . (is_null($__type) ? "" : " AND am_asset_business.asset_business_type_id='" . asset_business::type_id($__type) . "'") . ($__get_primary ? " AND am_asset_business.primary=1 " : "");
673      $q .= is_null($__where_clause) ? "" : " WHERE {$__where_clause}";
674      $q .= is_null($__order) ? "" : " ORDER BY {$__order}";
675      $q .= is_null($__limit) ? "" : " LIMIT {$__offset}, {$__limit}";
676      $db->query($q);
677      while ($db->next_record())
678      {
679          $business_ids[] = $db->f("entity_id");
680      }
681      return $business_ids;
682  }
publicget_business_list ( type , order , where_clause , limit , offset [0] , get_primary [false] )[ asset_db ]
Parameters
optionaltype
optionalorder
optionalwhere_clause
optionallimit
optionaloffset [0]
optionalget_primary [false]
Code
683  public function get_business_list($__type=null, $__order=null, $__where_clause=null, $__limit=null, $__offset=0, $__get_primary=false)
684  {
685      $ids = $this->get_business_ids($__type, $__order, $__where_clause, $__limit, $__offset, $__get_primary);
686      $objects = array();
687      foreach ($ids as $index=>$id)
688      {
689          $objects[$index] = new business($id);
690      }
691      return $objects;
692  }
publicget_classname ( )[ obj ]
Parameters
No parameters for this method
Code
086  public function get_classname()
087  {
088      return get_class($this);
089  }
public staticget_columns ( columns , order , lookups , where_clause , limit , offset [0] )[ asset_db ]
Parameters
requiredcolumns
optionalorder
optionallookups
optionalwhere_clause
optionallimit
optionaloffset [0]
Code
266  public static function get_columns($__columns, $__order=null, $__lookups=null, $__where_clause=null, $__limit=null, $__offset=0)
267  {
268      $lookups = is_array($__lookups) ? $__lookups : array($__lookups);
269      $colarray = is_array($__columns) ? $__columns : explode(",",$__columns);
270      $colstring = is_array($__columns) ? implode(",",$__columns) : $__columns;
271 
272      $db = asset::db();
273      $data = array();
274      $q  = " SELECT $colstring ";
275      $q .= " FROM am_asset ";
276      $q .= " WHERE am_asset.deleted = 0 ";
277      $q .= is_null($__where_clause) ? null : " AND ($__where_clause) ";
278      $q .= array_key_exists("asset_type_id",$lookups) ? " AND am_asset.asset_type_id='" . $lookups["asset_type_id"] . "' " : "";
279      $q .= array_key_exists("assetstatus_id",$lookups) ? " AND am_asset.assetstatus_id='" . $lookups["assetstatus_id"] . "' " : "";
280      $q .= array_key_exists("department_id",$lookups) ? " AND am_asset.department_id='" . $lookups["department_id"] . "' " : "";
281 
282      if (is_string($__order))
283      {
284          $q .= "ORDER BY " . $__order;
285      }
286      else if (is_array($__order) and count($__order)>0)
287      {
288          $orderings = array();
289          foreach ($__order as $col=>$dir)
290          {
291              $orderings[] = " $col $dir ";
292          }
293          $q .= "ORDER BY " . implode(", ", $orderings);
294      }
295      else if (is_object($__order))
296      {
297          $q .= "";
298      }
299      else
300      {
301          // THERE IS NO `order` COLUMN ON THIS OBJECT
302      }
303 
304      if (!is_null($__limit))
305      {
306          $q .= " LIMIT $__offset , $__limit ";
307      }
308 
309      $db->query($q);
310 
311      if (count($colarray)>1 || $colstring=="*")
312      {
313          while ($db->next_record())
314          {
315              $data[] = $db->record;
316          }
317      }
318      else
319      {
320          while ($db->next_record())
321          {
322              $data[] = $db->f(0);
323          }
324      }
325 
326      return $data;
327  }
publicget_department ( )[ asset_db ]
Parameters
No parameters for this method
Code
448  public function get_department()
449  {
450      return new department($this->department_id);
451  }
publicget_dirty ( )[ obj ]
Parameters
No parameters for this method
Code
063  public function get_dirty()
064  {
065      if ($this->id === 0)
066      {
067          $this->_dirty = true;
068      }
069      else
070      {
071          foreach (get_object_vars($this) as $k=>$v)
072          {
073              if ($this->_dirty)
074              {
075                  break;
076              }
077              if (preg_match('/_dirty$/',$k))
078              {
079                  $this->_dirty = $this->_dirty || $v;
080              }
081          }
082      }
083      return $this->_dirty;
084  }
public staticget_ids ( order , lookups , where_clause , limit , offset [0] )[ asset_db ]
Parameters
optionalorder
optionallookups
optionalwhere_clause
optionallimit
optionaloffset [0]
Code
329  public static function get_ids($__order=null, $__lookups=null, $__where_clause=null, $__limit=null, $__offset=0)
330  {
331      return asset::get_columns("id", $__order, $__lookups, $__where_clause, $__limit, $__offset);
332  }
publicget_json ( )[ obj ]
Parameters
No parameters for this method
Code
101  public function get_json()
102  {
103      $class = new ReflectionClass($this->classname);
104      $methods = $class->getMethods();
105      usort($methods,"sort_reflection_objects");
106      $accessors = array();
107      foreach ($methods as $index=>$method)
108      {
109          $declarer = $method->getDeclaringClass()->name;
110          if (preg_match('/^(get|set|)_(.+)$/',$method->name,$matches))
111          {
112              $accessor = $matches[2];
113              $getset = $matches[1];
114              eval("\$accessors[\$accessor] = \$this->".$accessor.";");
115          }
116      }
117      //return json_encode($this->get_array());
118      return json_encode($accessors);
119  }
public staticget_objects ( order , lookups , where_clause , limit , offset [0] )[ asset_db ]
Parameters
optionalorder
optionallookups
optionalwhere_clause
optionallimit
optionaloffset [0]
Code
334  public static function get_objects($__order=null, $__lookups=null, $__where_clause=null, $__limit=null, $__offset=0)
335  {
336      $objects = array();
337      foreach (asset::get_columns("id", $__order, $__lookups, $__where_clause, $__limit, $__offset) as $id)
338      {
339          $objects[] = new asset($id);
340      }
341      return $objects;
342  }
publicget_office ( type ["default"] )[ asset_db ]
Parameters
optionaltype ["default"]
Code
558  public function get_office($__type="default")
559  {
560      $object = is_null(keyval($this->property_objects_array,"{$__type}_office")) ? new office($this->get_office_id($__type)) : $this->property_objects_array["{$__type}_office"];
561      $this->property_objects_array["{$__type}_office"] = $object;
562      return $object;
563  }
publicget_office_id ( type ["default"] )[ asset_db ]
Parameters
optionaltype ["default"]
Code
564  public function get_office_id($__type="default")
565  {
566      $ids = $this->get_office_ids($__type, true);
567      return (count($ids)==1 ? $ids[0] : null);
568  }
publicget_office_ids ( type , order , where_clause , limit , offset [0] , get_primary [false] )[ asset_db ]
Parameters
optionaltype
optionalorder
optionalwhere_clause
optionallimit
optionaloffset [0]
optionalget_primary [false]
Code
569  public function get_office_ids($__type=null, $__order=null, $__where_clause=null, $__limit=null, $__offset=0, $__get_primary=false)
570  {
571      $office_ids = array();
572      $db = asset::db();
573      $q  = " SELECT bus_office.entity_id FROM am_asset_office INNER JOIN bus_office ON am_asset_office.office_entity_id=bus_office.entity_id AND am_asset_office.deleted=0 AND bus_office.deleted=0 AND am_asset_office.asset_id='$this->id' " . (is_null($__type) ? "" : " AND am_asset_office.asset_office_type_id='" . asset_office::type_id($__type) . "'") . ($__get_primary ? " AND am_asset_office.primary=1 " : "");
574      $q .= is_null($__where_clause) ? "" : " WHERE {$__where_clause}";
575      $q .= is_null($__order) ? "" : " ORDER BY {$__order}";
576      $q .= is_null($__limit) ? "" : " LIMIT {$__offset}, {$__limit}";
577      $db->query($q);
578      while ($db->next_record())
579      {
580          $office_ids[] = $db->f("entity_id");
581      }
582      return $office_ids;
583  }
publicget_office_list ( type , order , where_clause , limit , offset [0] , get_primary [false] )[ asset_db ]
Parameters
optionaltype
optionalorder
optionalwhere_clause
optionallimit
optionaloffset [0]
optionalget_primary [false]
Code
584  public function get_office_list($__type=null, $__order=null, $__where_clause=null, $__limit=null, $__offset=0, $__get_primary=false)
585  {
586      $ids = $this->get_office_ids($__type, $__order, $__where_clause, $__limit, $__offset, $__get_primary);
587      $objects = array();
588      foreach ($ids as $index=>$id)
589      {
590          $objects[$index] = new office($id);
591      }
592      return $objects;
593  }
publicget_person ( type ["default"] )[ asset_db ]
Parameters
optionaltype ["default"]
Code
756  public function get_person($__type="default")
757  {
758      $object = is_null(keyval($this->property_objects_array,"{$__type}_person")) ? new person($this->get_person_id($__type)) : $this->property_objects_array["{$__type}_person"];
759      $this->property_objects_array["{$__type}_person"] = $object;
760      return $object;
761  }
publicget_person_id ( type ["default"] )[ asset_db ]
Parameters
optionaltype ["default"]
Code
762  public function get_person_id($__type="default")
763  {
764      $ids = $this->get_person_ids($__type, true);
765      return (count($ids)==1 ? $ids[0] : null);
766  }
publicget_person_ids ( type , order , where_clause , limit , offset [0] , get_primary [false] )[ asset_db ]
Parameters
optionaltype
optionalorder
optionalwhere_clause
optionallimit
optionaloffset [0]
optionalget_primary [false]
Code
767  public function get_person_ids($__type=null, $__order=null, $__where_clause=null, $__limit=null, $__offset=0, $__get_primary=false)
768  {
769      $person_ids = array();
770      $db = asset::db();
771      $q  = " SELECT cor_person.entity_id FROM am_asset_person INNER JOIN cor_person ON am_asset_person.person_entity_id=cor_person.entity_id AND am_asset_person.deleted=0 AND cor_person.deleted=0 AND am_asset_person.asset_id='$this->id' " . (is_null($__type) ? "" : " AND am_asset_person.asset_person_type_id='" . asset_person::type_id($__type) . "'") . ($__get_primary ? " AND am_asset_person.primary=1 " : "");
772      $q .= is_null($__where_clause) ? "" : " WHERE {$__where_clause}";
773      $q .= is_null($__order) ? "" : " ORDER BY {$__order}";
774      $q .= is_null($__limit) ? "" : " LIMIT {$__offset}, {$__limit}";
775      $db->query($q);
776      while ($db->next_record())
777      {
778          $person_ids[] = $db->f("entity_id");
779      }
780      return $person_ids;
781  }
publicget_person_list ( type , order , where_clause , limit , offset [0] , get_primary [false] )[ asset_db ]
Parameters
optionaltype
optionalorder
optionalwhere_clause
optionallimit
optionaloffset [0]
optionalget_primary [false]
Code
782  public function get_person_list($__type=null, $__order=null, $__where_clause=null, $__limit=null, $__offset=0, $__get_primary=false)
783  {
784      $ids = $this->get_person_ids($__type, $__order, $__where_clause, $__limit, $__offset, $__get_primary);
785      $objects = array();
786      foreach ($ids as $index=>$id)
787      {
788          $objects[$index] = new person($id);
789      }
790      return $objects;
791  }
publicget_properties ( )[ obj ]
Parameters
No parameters for this method
Code
121  public function get_properties()
122  {
123      return array_keys($this->array);
124  }
publicget_resource ( type ["default"] )[ asset_db ]
Parameters
optionaltype ["default"]
Code
953  public function get_resource($__type="default")
954  {
955      $object = is_null(keyval($this->property_objects_array,"{$__type}_resource")) ? new resource($this->get_resource_id($__type)) : $this->property_objects_array["{$__type}_resource"];
956      $this->property_objects_array["{$__type}_resource"] = $object;
957      return $object;
958  }
publicget_resource_id ( type ["default"] )[ asset_db ]
Parameters
optionaltype ["default"]
Code
959  public function get_resource_id($__type="default")
960  {
961      $ids = $this->get_resource_ids($__type, true);
962      return (count($ids)==1 ? $ids[0] : null);
963  }
publicget_resource_ids ( type , order , where_clause , limit , offset [0] , get_primary [false] )[ asset_db ]
Parameters
optionaltype
optionalorder
optionalwhere_clause
optionallimit
optionaloffset [0]
optionalget_primary [false]
Code
964  public function get_resource_ids($__type=null, $__order=null, $__where_clause=null, $__limit=null, $__offset=0, $__get_primary=false)
965  {
966      $resource_ids = array();
967      $db = asset::db();
968      $q  = " SELECT cor_resource.id FROM am_asset_resource INNER JOIN cor_resource ON am_asset_resource.resource_id=cor_resource.id AND am_asset_resource.deleted=0 AND cor_resource.deleted=0 AND am_asset_resource.asset_id='$this->id' " . (is_null($__type) ? "" : " AND am_asset_resource.asset_resource_type_id='" . asset_resource::type_id($__type) . "'") . ($__get_primary ? " AND am_asset_resource.primary=1 " : "");
969      $q .= is_null($__where_clause) ? "" : " WHERE {$__where_clause}";
970      $q .= is_null($__order) ? "" : " ORDER BY {$__order}";
971      $q .= is_null($__limit) ? "" : " LIMIT {$__offset}, {$__limit}";
972      $db->query($q);
973      while ($db->next_record())
974      {
975          $resource_ids[] = $db->f("id");
976      }
977      return $resource_ids;
978  }
publicget_resource_list ( type , order , where_clause , limit , offset [0] , get_primary [false] )[ asset_db ]
Parameters
optionaltype
optionalorder
optionalwhere_clause
optionallimit
optionaloffset [0]
optionalget_primary [false]
Code
979  public function get_resource_list($__type=null, $__order=null, $__where_clause=null, $__limit=null, $__offset=0, $__get_primary=false)
980  {
981      $ids = $this->get_resource_ids($__type, $__order, $__where_clause, $__limit, $__offset, $__get_primary);
982      $objects = array();
983      foreach ($ids as $index=>$id)
984      {
985          $objects[$index] = new resource($id);
986      }
987      return $objects;
988  }
protectedget_string ( )[ obj ]
Parameters
No parameters for this method
Code
091  protected function get_string()
092  {
093      return method_exists($this,"__toString") ? $this->__toString() : null;
094  }
publicget_type ( )[ asset_db ]
Parameters
No parameters for this method
Code
413  public function get_type()
414  {
415      $type = new asset_type($this->_asset_type_id);
416      return $type->name;
417  }
publicget_url ( type ["default"] )[ asset_db ]
Parameters
optionaltype ["default"]
Code
855  public function get_url($__type="default")
856  {
857      $object = is_null(keyval($this->property_objects_array,"{$__type}_url")) ? new url($this->get_url_id($__type)) : $this->property_objects_array["{$__type}_url"];
858      $this->property_objects_array["{$__type}_url"] = $object;
859      return $object;
860  }
publicget_url_id ( type ["default"] )[ asset_db ]
Parameters
optionaltype ["default"]
Code
861  public function get_url_id($__type="default")
862  {
863      $ids = $this->get_url_ids($__type, true);
864      return (count($ids)==1 ? $ids[0] : null);
865  }
publicget_url_ids ( type , order , where_clause , limit , offset [0] , get_primary [false] )[ asset_db ]
Parameters
optionaltype
optionalorder
optionalwhere_clause
optionallimit
optionaloffset [0]
optionalget_primary [false]
Code
866  public function get_url_ids($__type=null, $__order=null, $__where_clause=null, $__limit=null, $__offset=0, $__get_primary=false)
867  {
868      $url_ids = array();
869      $db = asset::db();
870      $q  = " SELECT cor_url.id FROM am_asset_url INNER JOIN cor_url ON am_asset_url.url_id=cor_url.id AND am_asset_url.deleted=0 AND cor_url.deleted=0 AND am_asset_url.asset_id='$this->id' " . (is_null($__type) ? "" : " AND am_asset_url.asset_url_type_id='" . asset_url::type_id($__type) . "'") . ($__get_primary ? " AND am_asset_url.primary=1 " : "");
871      $q .= is_null($__where_clause) ? "" : " WHERE {$__where_clause}";
872      $q .= is_null($__order) ? "" : " ORDER BY {$__order}";
873      $q .= is_null($__limit) ? "" : " LIMIT {$__offset}, {$__limit}";
874      $db->query($q);
875      while ($db->next_record())
876      {
877          $url_ids[] = $db->f("id");
878      }
879      return $url_ids;
880  }
publicget_url_list ( type , order , where_clause , limit , offset [0] , get_primary [false] )[ asset_db ]
Parameters
optionaltype
optionalorder
optionalwhere_clause
optionallimit
optionaloffset [0]
optionalget_primary [false]
Code
881  public function get_url_list($__type=null, $__order=null, $__where_clause=null, $__limit=null, $__offset=0, $__get_primary=false)
882  {
883      $ids = $this->get_url_ids($__type, $__order, $__where_clause, $__limit, $__offset, $__get_primary);
884      $objects = array();
885      foreach ($ids as $index=>$id)
886      {
887          $objects[$index] = new url($id);
888      }
889      return $objects;
890  }
protectedinsert ( )[ asset_db ]
Parameters
No parameters for this method
Code
171  protected function insert()
172  {
173      $db = asset::db();
174      $q  = " INSERT INTO am_asset ( ";
175      $q .= $db->param_string("name") . ", ";
176      $q .= $db->param_string("description") . ", ";
177      $q .= $db->param_string("asset_type_id") . ", ";
178      $q .= $db->param_string("assetstatus_id") . ", ";
179      $q .= $db->param_string("department_id") . ", ";
180      $q .= $db->param_string("sku") . ", ";
181      $q .= $db->param_string("model") . ", ";
182      $q .= $db->param_string("part_number") . ", ";
183      $q .= $db->param_string("serial_number") . ", ";
184      $q .= $db->param_string("unit_price") . ", ";
185      $q .= $db->param_string("quantity") . ", ";
186      $q .= $db->param_string("capex") . ", ";
187      $q .= $db->param_string("mdate") . ", ";
188      $q .= $db->param_string("cdate") . ", ";
189      $q .= $db->param_string("deleted");
190      $q .= " ) VALUES ( ";
191      $q .= $db->value_string($this->_name) . ", ";
192      $q .= $db->value_string($this->_description) . ", ";
193      $q .= $db->value_string($this->_asset_type_id) . ", ";
194      $q .= $db->value_string($this->_assetstatus_id) . ", ";
195      $q .= $db->value_string($this->_department_id) . ", ";
196      $q .= $db->value_string($this->_sku) . ", ";
197      $q .= $db->value_string($this->_model) . ", ";
198      $q .= $db->value_string($this->_part_number) . ", ";
199      $q .= $db->value_string($this->_serial_number) . ", ";
200      $q .= $db->value_string($this->_unit_price) . ", ";
201      $q .= $db->value_string($this->_quantity) . ", ";
202      $q .= ($this->_capex ? "'1'" : "'0'") . ", ";
203      $q .= $db->value_string(timestamp()) . ", ";
204      $q .= $db->value_string(timestamp()) . ", ";
205      $q .= $this->deleted ? "'1'" : "'0'";
206      $q .= " ) ";
207      $db->query($q);
208      $this->_id = $db->insert_id;
209      return true;
210  }
publicmap ( )[ asset_db ]
Parameters
No parameters for this method
Code
133  public function map()
134  {
135      $this->_name = array_key_exists("asset:name",$_REQUEST) ? reqval("asset:name") : $this->_name;
136      $this->_description = array_key_exists("asset:description",$_REQUEST) ? reqval("asset:description") : $this->_description;
137      $this->_asset_type_id = array_key_exists("asset:asset_type_id",$_REQUEST) ? reqval("asset:asset_type_id") : $this->_asset_type_id;
138      $this->_assetstatus_id = array_key_exists("asset:assetstatus_id",$_REQUEST) ? reqval("asset:assetstatus_id") : $this->_assetstatus_id;
139      $this->_department_id = array_key_exists("asset:department_id",$_REQUEST) ? reqval("asset:department_id") : $this->_department_id;
140      $this->_sku = array_key_exists("asset:sku",$_REQUEST) ? reqval("asset:sku") : $this->_sku;
141      $this->_model = array_key_exists("asset:model",$_REQUEST) ? reqval("asset:model") : $this->_model;
142      $this->_part_number = array_key_exists("asset:part_number",$_REQUEST) ? reqval("asset:part_number") : $this->_part_number;
143      $this->_serial_number = array_key_exists("asset:serial_number",$_REQUEST) ? reqval("asset:serial_number") : $this->_serial_number;
144      $this->_unit_price = array_key_exists("asset:unit_price",$_REQUEST) ? reqval("asset:unit_price") : $this->_unit_price;
145      $this->_quantity = array_key_exists("asset:quantity",$_REQUEST) ? reqval("asset:quantity") : $this->_quantity;
146      $this->_capex = array_key_exists("asset:capex",$_REQUEST) ? reqval("asset:capex") : $this->_capex;
147      $this->_mdate = array_key_exists("asset:mdate",$_REQUEST) ? reqval("asset:mdate") : $this->_mdate;
148      $this->_cdate = array_key_exists("asset:cdate",$_REQUEST) ? reqval("asset:cdate") : $this->_cdate;
149      $this->_deleted = array_key_exists("asset:deleted",$_REQUEST) ? reqval("asset:deleted") : $this->_deleted;
150  }
publicpurge ( )[ asset_db ]
Parameters
No parameters for this method
Code
257  public function purge()
258  {
259      $db = asset::db();
260      $q  = " DELETE FROM am_asset ";
261      $q .= " WHERE id = " . $this->_id;
262      $db->query($q);
263      return true;
264  }
public staticsearch ( keyword )[ asset_db ]
public__set ( p , v )[ obj ]
Parameters
requiredp
requiredv
Code
030  public function __set($p,$v)
031  {
032      $methods = get_class_methods($this);
033      $properties = get_object_vars($this);
034      if (in_array("set_$p",$methods))
035      {
036          $this->{"set_$p"}($v);
037      }
038      else if (array_key_exists("_$p",$properties))
039      {
040          if (!preg_match('/_dirty$/',$p) && property_exists($this,"_{$p}_dirty"))
041          {
042              if (is_object($this->{"_$p"}))
043              {
044                  $this->{"_$p"}->dirty = true;
045              }
046              else
047              {
048                  $this->{"_{$p}_dirty"} = $this->{$p}==$v ? false : true;
049              }
050          }
051          $this->{"_$p"} = $v;
052      }
053      else if (in_array("set_" . substr($p,strpos($p,"_")+1), $methods))
054      {
055          $this->{"set_" . substr($p,strpos($p,"_")+1)}($v,substr($p,0,strpos($p,"_")));
056      }
057      else
058      {
059          trigger_error("This object [" . get_class($this) . ":$this->id] has no private property '_$p' for the requested public property '$p'",E_USER_WARNING);
060      }
061  }
publicset_asset_type ( v )[ asset_db ]
Parameters
requiredv
Code
428  public function set_asset_type($v)
429  {
430      if ($v->id > 0)
431      {
432          $this->asset_type_id = $v->id;
433      }
434  }
publicset_assetdate ( v , type ["default"] )[ asset_db ]
Parameters
requiredv
optionaltype ["default"]
Code
497  public function set_assetdate($__v, $__type="default")
498  {
499      $object = is_null(keyval($this->property_objects_array,"{$__type}_assetdate")) ? new assetdate($this->get_assetdate_id($__type)) : $this->property_objects_array["{$__type}_assetdate"];
500      if (is_null($__v))
501      {
502          $rel = new asset_assetdate(null,$this->id,$object->id,asset_assetdate::type_id($__type));
503          $rel->delete();
504          $object->delete();
505          if (!is_null(keyval($this->property_objects_array,"{$__type}_assetdate")))
506          {
507              $this->property_objects_array["{$__type}_assetdate"] = null;
508          }
509      }
510      else
511      {
512          $object->value = is_object($__v) ? $__v->value : $__v;
513          $object->commit();
514          $this->set_assetdate_ids(array($object->id),$__type);
515      }
516  }
publicset_assetdate_id ( v , type ["default"] )[ asset_db ]
Parameters
requiredv
optionaltype ["default"]
Code
517  public function set_assetdate_id($__v, $__type="default")
518  {
519      $this->set_assetdate_ids(array($__v),$__type);
520  }
publicset_assetdate_ids ( v , type ["default"] )[ asset_db ]
Parameters
requiredv
optionaltype ["default"]
Code
521  public function set_assetdate_ids($__v, $__type="default")
522  {
523      if ($this->id == 0)
524      {
525          $this->commit();
526      }
527      $type_id = asset_assetdate::type_id($__type);
528      asset_assetdate::delete_all($this->id,null,$type_id);
529      if (is_array($__v))
530      {
531          foreach ($__v as $index=>$id)
532          {
533              $object = new asset_assetdate(null,$this->id,$id,$type_id);
534              $object->deleted = false;
535              $object->asset_assetdate_type_id = $type_id;
536              $object->commit();
537              if (count($__v)==1 && !is_null(keyval($this->property_objects_array,"{$__type}_assetdate")))
538              {
539                  $this->property_objects_array["{$__type}_assetdate"] = new assetdate($object->assetdate_id);
540              }
541          }
542          $this->_dirty = true;
543      }
544  }
publicset_assetdate_list ( v , type ["default"] )[ asset_db ]
Parameters
requiredv
optionaltype ["default"]
Code
545  public function set_assetdate_list($__v, $__type="default")
546  {
547      if (is_array($__v))
548      {
549          $ids = array();
550          foreach ($__v as $index=>$object)
551          {
552              $ids[] = $object->id;
553          }
554          $this->set_assetdate_ids($ids,$__type);
555      }
556  }
publicset_assetstatus ( v )[ asset_db ]
Parameters
requiredv
Code
440  public function set_assetstatus($v)
441  {
442      if ($v->id > 0)
443      {
444          $this->assetstatus_id = $v->id;
445      }
446  }
publicset_business ( v , type ["default"] )[ asset_db ]
Parameters
requiredv
optionaltype ["default"]
Code
694  public function set_business($__v, $__type="default")
695  {
696      $object = is_null(keyval($this->property_objects_array,"{$__type}_business")) ? new business($this->get_business_id($__type)) : $this->property_objects_array["{$__type}_business"];
697      if (is_null($__v))
698      {
699          $rel = new asset_business(null,$this->id,$object->id,asset_business::type_id($__type));
700          $rel->delete();
701          if (!is_null(keyval($this->property_objects_array,"{$__type}_business")))
702          {
703              $this->property_objects_array["{$__type}_business"] = null;
704          }
705      }
706      else
707      {
708          $id = $object->id;
709          $object = $__v;
710          $object->id = $__v->id>0 ? $__v->id : $id;
711          $object->commit();
712          $this->set_business_ids(array($object->id),$__type);
713      }
714  }
publicset_business_id ( v , type ["default"] )[ asset_db ]
Parameters
requiredv
optionaltype ["default"]
Code
715  public function set_business_id($__v, $__type="default")
716  {
717      $this->set_business_ids(array($__v),$__type);
718  }
publicset_business_ids ( v , type ["default"] )[ asset_db ]
Parameters
requiredv
optionaltype ["default"]
Code
719  public function set_business_ids($__v, $__type="default")
720  {
721      if ($this->id == 0)
722      {
723          $this->commit();
724      }
725      $type_id = asset_business::type_id($__type);
726      asset_business::delete_all($this->id,null,$type_id);
727      if (is_array($__v))
728      {
729          foreach ($__v as $index=>$id)
730          {
731              $object = new asset_business(null,$this->id,$id,$type_id);
732              $object->deleted = false;
733              $object->asset_business_type_id = $type_id;
734              $object->commit();
735              if (count($__v)==1 && !is_null(keyval($this->property_objects_array,"{$__type}_business")))
736              {
737                  $this->property_objects_array["{$__type}_business"] = new business($object->business_id);
738              }
739          }
740          $this->_dirty = true;
741      }
742  }
publicset_business_list ( v , type ["default"] )[ asset_db ]
Parameters
requiredv
optionaltype ["default"]
Code
743  public function set_business_list($__v, $__type="default")
744  {
745      if (is_array($__v))
746      {
747          $ids = array();
748          foreach ($__v as $index=>$object)
749          {
750              $ids[] = $object->id;
751          }
752          $this->set_business_ids($ids,$__type);
753      }
754  }
publicset_department ( v )[ asset_db ]
Parameters
requiredv
Code
452  public function set_department($v)
453  {
454      if ($v->id > 0)
455      {
456          $this->department_id = $v->id;
457      }
458  }
publicset_office ( v , type ["default"] )[ asset_db ]
Parameters
requiredv
optionaltype ["default"]
Code
595  public function set_office($__v, $__type="default")
596  {
597      $object = is_null(keyval($this->property_objects_array,"{$__type}_office")) ? new office($this->get_office_id($__type)) : $this->property_objects_array["{$__type}_office"];
598      if (is_null($__v))
599      {
600          $rel = new asset_office(null,$this->id,$object->id,asset_office::type_id($__type));
601          $rel->delete();
602          if (!is_null(keyval($this->property_objects_array,"{$__type}_office")))
603          {
604              $this->property_objects_array["{$__type}_office"] = null;
605          }
606      }
607      else
608      {
609          $id = $object->id;
610          $object = $__v;
611          $object->id = $__v->id>0 ? $__v->id : $id;
612          $object->commit();
613          $this->set_office_ids(array($object->id),$__type);
614      }
615  }
publicset_office_id ( v , type ["default"] )[ asset_db ]
Parameters
requiredv
optionaltype ["default"]
Code
616  public function set_office_id($__v, $__type="default")
617  {
618      $this->set_office_ids(array($__v),$__type);
619  }
publicset_office_ids ( v , type ["default"] )[ asset_db ]
Parameters
requiredv
optionaltype ["default"]
Code
620  public function set_office_ids($__v, $__type="default")
621  {
622      if ($this->id == 0)
623      {
624          $this->commit();
625      }
626      $type_id = asset_office::type_id($__type);
627      asset_office::delete_all($this->id,null,$type_id);
628      if (is_array($__v))
629      {
630          foreach ($__v as $index=>$id)
631          {
632              $object = new asset_office(null,$this->id,$id,$type_id);
633              $object->deleted = false;
634              $object->asset_office_type_id = $type_id;
635              $object->commit();
636              if (count($__v)==1 && !is_null(keyval($this->property_objects_array,"{$__type}_office")))
637              {
638                  $this->property_objects_array["{$__type}_office"] = new office($object->office_id);
639              }
640          }
641          $this->_dirty = true;
642      }
643  }
publicset_office_list ( v , type ["default"] )[ asset_db ]
Parameters
requiredv
optionaltype ["default"]
Code
644  public function set_office_list($__v, $__type="default")
645  {
646      if (is_array($__v))
647      {
648          $ids = array();
649          foreach ($__v as $index=>$object)
650          {
651              $ids[] = $object->id;
652          }
653          $this->set_office_ids($ids,$__type);
654      }
655  }
publicset_person ( v , type ["default"] )[ asset_db ]
Parameters
requiredv
optionaltype ["default"]
Code
793  public function set_person($__v, $__type="default")
794  {
795      $object = is_null(keyval($this->property_objects_array,"{$__type}_person")) ? new person($this->get_person_id($__type)) : $this->property_objects_array["{$__type}_person"];
796      if (is_null($__v))
797      {
798          $rel = new asset_person(null,$this->id,$object->id,asset_person::type_id($__type));
799          $rel->delete();
800          if (!is_null(keyval($this->property_objects_array,"{$__type}_person")))
801          {
802              $this->property_objects_array["{$__type}_person"] = null;
803          }
804      }
805      else
806      {
807          $id = $object->id;
808          $object = $__v;
809          $object->id = $__v->id>0 ? $__v->id : $id;
810          $object->commit();
811          $this->set_person_ids(array($object->id),$__type);
812      }
813  }
publicset_person_id ( v , type ["default"] )[ asset_db ]
Parameters
requiredv
optionaltype ["default"]
Code
814  public function set_person_id($__v, $__type="default")
815  {
816      $this->set_person_ids(array($__v),$__type);
817  }
publicset_person_ids ( v , type ["default"] )[ asset_db ]
Parameters
requiredv
optionaltype ["default"]
Code
818  public function set_person_ids($__v, $__type="default")
819  {
820      if ($this->id == 0)
821      {
822          $this->commit();
823      }
824      $type_id = asset_person::type_id($__type);
825      asset_person::delete_all($this->id,null,$type_id);
826      if (is_array($__v))
827      {
828          foreach ($__v as $index=>$id)
829          {
830              $object = new asset_person(null,$this->id,$id,$type_id);
831              $object->deleted = false;
832              $object->asset_person_type_id = $type_id;
833              $object->commit();
834              if (count($__v)==1 && !is_null(keyval($this->property_objects_array,"{$__type}_person")))
835              {
836                  $this->property_objects_array["{$__type}_person"] = new person($object->person_id);
837              }
838          }
839          $this->_dirty = true;
840      }
841  }
publicset_person_list ( v , type ["default"] )[ asset_db ]
Parameters
requiredv
optionaltype ["default"]
Code
842  public function set_person_list($__v, $__type="default")
843  {
844      if (is_array($__v))
845      {
846          $ids = array();
847          foreach ($__v as $index=>$object)
848          {
849              $ids[] = $object->id;
850          }
851          $this->set_person_ids($ids,$__type);
852      }
853  }
publicset_resource ( v , type ["default"] )[ asset_db ]
Parameters
requiredv
optionaltype ["default"]
Code
990  public function set_resource($__v, $__type="default")
991  {
992      $object = is_null(keyval($this->property_objects_array,"{$__type}_resource")) ? new resource($this->get_resource_id($__type)) : $this->property_objects_array["{$__type}_resource"];
993      if (is_null($__v))
994      {
995          $rel = new asset_resource(null,$this->id,$object->id,asset_resource::type_id($__type));
996          $rel->delete();
997          if (!is_null(keyval($this->property_objects_array,"{$__type}_resource")))
998          {
999              $this->property_objects_array["{$__type}_resource"] = null;
1000          }
1001      }
1002      else
1003      {
1004          $hash = $object->hash;
1005          $id = $object->id;
1006          $object = $__v;
1007          $object->hash = $__v->id>0 ? $__v->hash : $hash;
1008          $object->id = $__v->id>0 ? $__v->id : $id;
1009          $object->commit();
1010          $this->set_resource_ids(array($object->id),$__type);
1011      }
1012  }
publicset_resource_id ( v , type ["default"] )[ asset_db ]
Parameters
requiredv
optionaltype ["default"]
Code
1013  public function set_resource_id($__v, $__type="default")
1014  {
1015      $this->set_resource_ids(array($__v),$__type);
1016  }
publicset_resource_ids ( v , type ["default"] )[ asset_db ]
Parameters
requiredv
optionaltype ["default"]
Code
1017  public function set_resource_ids($__v, $__type="default")
1018  {
1019      if ($this->id == 0)
1020      {
1021          $this->commit();
1022      }
1023      $type_id = asset_resource::type_id($__type);
1024      asset_resource::delete_all($this->id,null,$type_id);
1025      if (is_array($__v))
1026      {
1027          foreach ($__v as $index=>$id)
1028          {
1029              $object = new asset_resource(null,$this->id,$id,$type_id);
1030              $object->deleted = false;
1031              $object->asset_resource_type_id = $type_id;
1032              $object->commit();
1033              if (count($__v)==1 && !is_null(keyval($this->property_objects_array,"{$__type}_resource")))
1034              {
1035                  $this->property_objects_array["{$__type}_resource"] = new resource($object->resource_id);
1036              }
1037          }
1038          $this->_dirty = true;
1039      }
1040  }
publicset_resource_list ( v , type ["default"] )[ asset_db ]
Parameters
requiredv
optionaltype ["default"]
Code
1041  public function set_resource_list($__v, $__type="default")
1042  {
1043      if (is_array($__v))
1044      {
1045          $ids = array();
1046          foreach ($__v as $index=>$object)
1047          {
1048              $ids[] = $object->id;
1049          }
1050          $this->set_resource_ids($ids,$__type);
1051      }
1052  }
publicset_type ( v )[ asset_db ]
Parameters
requiredv
Code
418  public function set_type($v)
419  {
420      $type = new asset_type(null, $v);
421      $this->asset_type_id = $type->id;
422  }
publicset_url ( v , type ["default"] )[ asset_db ]
Parameters
requiredv
optionaltype ["default"]
Code
892  public function set_url($__v, $__type="default")
893  {
894      $object = is_null(keyval($this->property_objects_array,"{$__type}_url")) ? new url($this->get_url_id($__type)) : $this->property_objects_array["{$__type}_url"];
895      if (is_null($__v))
896      {
897          $rel = new asset_url(null,$this->id,$object->id,asset_url::type_id($__type));
898          $rel->delete();
899          $object->delete();
900          if (!is_null(keyval($this->property_objects_array,"{$__type}_url")))
901          {
902              $this->property_objects_array["{$__type}_url"] = null;
903          }
904      }
905      else
906      {
907          $object->value = is_object($__v) ? $__v->value : $__v;
908          $object->commit();
909          $this->set_url_ids(array($object->id),$__type);
910      }
911  }
publicset_url_id ( v , type ["default"] )[ asset_db ]
Parameters
requiredv
optionaltype ["default"]
Code
912  public function set_url_id($__v, $__type="default")
913  {
914      $this->set_url_ids(array($__v),$__type);
915  }
publicset_url_ids ( v , type ["default"] )[ asset_db ]
Parameters
requiredv
optionaltype ["default"]
Code
916  public function set_url_ids($__v, $__type="default")
917  {
918      if ($this->id == 0)
919      {
920          $this->commit();
921      }
922      $type_id = asset_url::type_id($__type);
923      asset_url::delete_all($this->id,null,$type_id);
924      if (is_array($__v))
925      {
926          foreach ($__v as $index=>$id)
927          {
928              $object = new asset_url(null,$this->id,$id,$type_id);
929              $object->deleted = false;
930              $object->asset_url_type_id = $type_id;
931              $object->commit();
932              if (count($__v)==1 && !is_null(keyval($this->property_objects_array,"{$__type}_url")))
933              {
934                  $this->property_objects_array["{$__type}_url"] = new url($object->url_id);
935              }
936          }
937          $this->_dirty = true;
938      }
939  }
publicset_url_list ( v , type ["default"] )[ asset_db ]
Parameters
requiredv
optionaltype ["default"]
Code
940  public function set_url_list($__v, $__type="default")
941  {
942      if (is_array($__v))
943      {
944          $ids = array();
945          foreach ($__v as $index=>$object)
946          {
947              $ids[] = $object->id;
948          }
949          $this->set_url_ids($ids,$__type);
950      }
951  }
public__toString ( )[ asset_db ]
Parameters
No parameters for this method
Code
402  public function __toString()
403  {
404      return (is_null($this->name) ? "" : $this->name);
405  }
public statictype_id ( type_name )[ asset_db ]
Parameters
requiredtype_name
Code
407  public static function type_id($__type_name)
408  {
409      $type = new asset_type(null, $__type_name);
410      return $type->id;
411  }
publicundelete ( )[ asset_db ]
Parameters
No parameters for this method
Code
246  public function undelete()
247  {
248      $db = asset::db();
249      $q  = " UPDATE am_asset SET ";
250      $q .= " deleted = 0 ";
251      $q .= " WHERE id = " . $this->_id;
252      $db->query($q);
253      $this->deleted = false;
254      return true;
255  }
protectedupdate ( )[ asset_db ]
Parameters
No parameters for this method
Code
212  protected function update()
213  {
214      $db = asset::db();
215      $q  = " UPDATE am_asset SET ";
216      $q .= $db->param_string("name") . " = " . $db->value_string($this->_name) . ", ";
217      $q .= $db->param_string("description") . " = " . $db->value_string($this->_description) . ", ";
218      $q .= $db->param_string("asset_type_id") . " = " . $db->value_string($this->_asset_type_id) . ", ";
219      $q .= $db->param_string("assetstatus_id") . " = " . $db->value_string($this->_assetstatus_id) . ", ";
220      $q .= $db->param_string("department_id") . " = " . $db->value_string($this->_department_id) . ", ";
221      $q .= $db->param_string("sku") . " = " . $db->value_string($this->_sku) . ", ";
222      $q .= $db->param_string("model") . " = " . $db->value_string($this->_model) . ", ";
223      $q .= $db->param_string("part_number") . " = " . $db->value_string($this->_part_number) . ", ";
224      $q .= $db->param_string("serial_number") . " = " . $db->value_string($this->_serial_number) . ", ";
225      $q .= $db->param_string("unit_price") . " = " . $db->value_string($this->_unit_price) . ", ";
226      $q .= $db->param_string("quantity") . " = " . $db->value_string($this->_quantity) . ", ";
227      $q .= $db->param_string("capex") . " = " . ($this->_capex ? "'1'" : "'0'") . ", ";
228      $q .= $db->param_string("mdate") . " = " . $db->value_string(timestamp()) . ", ";
229      $q .= $db->param_string("deleted") . " = " . ($this->deleted ? "'1'" : "'0'");
230      $q .= " WHERE id = " . $this->_id;
231      $db->query($q);
232      return true;
233  }
 
Accessors
publicarray[ obj ]
Code
096  public function get_array()
097  {
098      return get_object_vars($this);
099  }
publicasset_type[ asset_db ]
Code
424  public function get_asset_type()
425  {
426      return new asset_type($this->asset_type_id);
427  }
Code
428  public function set_asset_type($v)
429  {
430      if ($v->id > 0)
431      {
432          $this->asset_type_id = $v->id;
433      }
434  }
publicassetdate[ asset_db ]
Code
460  public function get_assetdate($__type="default")
461  {
462      $object = is_null(keyval($this->property_objects_array,"{$__type}_assetdate")) ? new assetdate($this->get_assetdate_id($__type)) : $this->property_objects_array["{$__type}_assetdate"];
463      $this->property_objects_array["{$__type}_assetdate"] = $object;
464      return $object;
465  }
Code
497  public function set_assetdate($__v, $__type="default")
498  {
499      $object = is_null(keyval($this->property_objects_array,"{$__type}_assetdate")) ? new assetdate($this->get_assetdate_id($__type)) : $this->property_objects_array["{$__type}_assetdate"];
500      if (is_null($__v))
501      {
502          $rel = new asset_assetdate(null,$this->id,$object->id,asset_assetdate::type_id($__type));
503          $rel->delete();
504          $object->delete();
505          if (!is_null(keyval($this->property_objects_array,"{$__type}_assetdate")))
506          {
507              $this->property_objects_array["{$__type}_assetdate"] = null;
508          }
509      }
510      else
511      {
512          $object->value = is_object($__v) ? $__v->value : $__v;
513          $object->commit();
514          $this->set_assetdate_ids(array($object->id),$__type);
515      }
516  }
publicassetdate_id[ asset_db ]
Code
466  public function get_assetdate_id($__type="default")
467  {
468      $ids = $this->get_assetdate_ids($__type, true);
469      return (count($ids)==1 ? $ids[0] : null);
470  }
Code
517  public function set_assetdate_id($__v, $__type="default")
518  {
519      $this->set_assetdate_ids(array($__v),$__type);
520  }
publicassetdate_ids[ asset_db ]
Code
471  public function get_assetdate_ids($__type=null, $__order=null, $__where_clause=null, $__limit=null, $__offset=0, $__get_primary=false)
472  {
473      $assetdate_ids = array();
474      $db = asset::db();
475      $q  = " SELECT am_assetdate.id FROM am_asset_assetdate INNER JOIN am_assetdate ON am_asset_assetdate.assetdate_id=am_assetdate.id AND am_asset_assetdate.deleted=0 AND am_assetdate.deleted=0 AND am_asset_assetdate.asset_id='$this->id' " . (is_null($__type) ? "" : " AND am_asset_assetdate.asset_assetdate_type_id='" . asset_assetdate::type_id($__type) . "'") . ($__get_primary ? " AND am_asset_assetdate.primary=1 " : "");
476      $q .= is_null($__where_clause) ? "" : " WHERE {$__where_clause}";
477      $q .= is_null($__order) ? "" : " ORDER BY {$__order}";
478      $q .= is_null($__limit) ? "" : " LIMIT {$__offset}, {$__limit}";
479      $db->query($q);
480      while ($db->next_record())
481      {
482          $assetdate_ids[] = $db->f("id");
483      }
484      return $assetdate_ids;
485  }
Code
521  public function set_assetdate_ids($__v, $__type="default")
522  {
523      if ($this->id == 0)
524      {
525          $this->commit();
526      }
527      $type_id = asset_assetdate::type_id($__type);
528      asset_assetdate::delete_all($this->id,null,$type_id);
529      if (is_array($__v))
530      {
531          foreach ($__v as $index=>$id)
532          {
533              $object = new asset_assetdate(null,$this->id,$id,$type_id);
534              $object->deleted = false;
535              $object->asset_assetdate_type_id = $type_id;
536              $object->commit();
537              if (count($__v)==1 && !is_null(keyval($this->property_objects_array,"{$__type}_assetdate")))
538              {
539                  $this->property_objects_array["{$__type}_assetdate"] = new assetdate($object->assetdate_id);
540              }
541          }
542          $this->_dirty = true;
543      }
544  }
publicassetdate_list[ asset_db ]
Code
486  public function get_assetdate_list($__type=null, $__order=null, $__where_clause=null, $__limit=null, $__offset=0, $__get_primary=false)
487  {
488      $ids = $this->get_assetdate_ids($__type, $__order, $__where_clause, $__limit, $__offset, $__get_primary);
489      $objects = array();
490      foreach ($ids as $index=>$id)
491      {
492          $objects[$index] = new assetdate($id);
493      }
494      return $objects;
495  }
Code
545  public function set_assetdate_list($__v, $__type="default")
546  {
547      if (is_array($__v))
548      {
549          $ids = array();
550          foreach ($__v as $index=>$object)
551          {
552              $ids[] = $object->id;
553          }
554          $this->set_assetdate_ids($ids,$__type);
555      }
556  }
publicassetstatus[ asset_db ]
Code
436  public function get_assetstatus()
437  {
438      return new assetstatus($this->assetstatus_id);
439  }
Code
440  public function set_assetstatus($v)
441  {
442      if ($v->id > 0)
443      {
444          $this->assetstatus_id = $v->id;
445      }
446  }
publicbusiness[ asset_db ]
Code
657  public function get_business($__type="default")
658  {
659      $object = is_null(keyval($this->property_objects_array,"{$__type}_business")) ? new business($this->get_business_id($__type)) : $this->property_objects_array["{$__type}_business"];
660      $this->property_objects_array["{$__type}_business"] = $object;
661      return $object;
662  }
Code
694  public function set_business($__v, $__type="default")
695  {
696      $object = is_null(keyval($this->property_objects_array,"{$__type}_business")) ? new business($this->get_business_id($__type)) : $this->property_objects_array["{$__type}_business"];
697      if (is_null($__v))
698      {
699          $rel = new asset_business(null,$this->id,$object->id,asset_business::type_id($__type));
700          $rel->delete();
701          if (!is_null(keyval($this->property_objects_array,"{$__type}_business")))
702          {
703              $this->property_objects_array["{$__type}_business"] = null;
704          }
705      }
706      else
707      {
708          $id = $object->id;
709          $object = $__v;
710          $object->id = $__v->id>0 ? $__v->id : $id;
711          $object->commit();
712          $this->set_business_ids(array($object->id),$__type);
713      }
714  }
publicbusiness_id[ asset_db ]
Code
663  public function get_business_id($__type="default")
664  {
665      $ids = $this->get_business_ids($__type, true);
666      return (count($ids)==1 ? $ids[0] : null);
667  }
Code
715  public function set_business_id($__v, $__type="default")
716  {
717      $this->set_business_ids(array($__v),$__type);
718  }
publicbusiness_ids[ asset_db ]
Code
668  public function get_business_ids($__type=null, $__order=null, $__where_clause=null, $__limit=null, $__offset=0, $__get_primary=false)
669  {
670      $business_ids = array();
671      $db = asset::db();
672      $q  = " SELECT bus_business.entity_id FROM am_asset_business INNER JOIN bus_business ON am_asset_business.business_entity_id=bus_business.entity_id AND am_asset_business.deleted=0 AND bus_business.deleted=0 AND am_asset_business.asset_id='$this->id' " . (is_null($__type) ? "" : " AND am_asset_business.asset_business_type_id='" . asset_business::type_id($__type) . "'") . ($__get_primary ? " AND am_asset_business.primary=1 " : "");
673      $q .= is_null($__where_clause) ? "" : " WHERE {$__where_clause}";
674      $q .= is_null($__order) ? "" : " ORDER BY {$__order}";
675      $q .= is_null($__limit) ? "" : " LIMIT {$__offset}, {$__limit}";
676      $db->query($q);
677      while ($db->next_record())
678      {
679          $business_ids[] = $db->f("entity_id");
680      }
681      return $business_ids;
682  }
Code
719  public function set_business_ids($__v, $__type="default")
720  {
721      if ($this->id == 0)
722      {
723          $this->commit();
724      }
725      $type_id = asset_business::type_id($__type