Helix Installation   Getting Started   Reference Documentation   Global Functions   Quick Start
ModulesClassesFunctions
 

Class Reference

class service extends service_ext

Hide Inherited MembersE-Commerce
Description
No description.
 
Constants
constantTABLENAME ["com_service"][ service ]
 
Properties
protected_cdate[ service_db ]
protected_cdate_dirty[ service_db ]
protected_deleted[ service_db ]
protected_deleted_dirty[ service_db ]
protected_description[ saleitem_db ]
protected_description_dirty[ saleitem_db ]
protected_dirty[ obj ]
protected__id[ service_db ]
protected_id[ saleitem_db ]
protected__id_dirty[ service_db ]
protected_id_dirty[ saleitem_db ]
protected_mdate[ service_db ]
protected_mdate_dirty[ service_db ]
protected_name[ saleitem_db ]
protected_name_dirty[ saleitem_db ]
publicproperty_objects_array[ obj ]
protected_saleitem_id[ service_db ]
protected_saleitem_id_dirty[ service_db ]
protected_saleitem_type_id[ saleitem_db ]
protected_saleitem_type_id_dirty[ saleitem_db ]
protected_unit_id[ saleitem_db ]
protected_unit_id_dirty[ saleitem_db ]
protected_unit_price[ saleitem_db ]
protected_unit_price_dirty[ saleitem_db ]
 
Methods
publiccommit ( )[ service_db ]
Parameters
No parameters for this method
Code
106  public function commit()
107  {
108      if ($this->_saleitem_id > 0)
109      {
110          $this->update();
111      }
112      else
113      {
114          $this->insert();
115      }
116 
117      foreach ($this->property_objects_array as $property=>$object)
118      {
119          $this->{$property} = $object;
120      }
121 
122      return true;
123  }
public__construct ( saleitem_id )[ service_db ]
Parameters
optionalsaleitem_id
Code
040  public function __construct($__saleitem_id=null)
041  {
042      $this->__id = 0;
043      $this->_saleitem_id = 0;
044      $this->_mdate = null;
045      $this->_cdate = null;
046      $this->_deleted = false;
047      $this->_id = 0;
048      $this->_name = "";
049      $this->_description = "";
050      $this->_unit_price = 0;
051      $this->_unit_id = 0;
052      $this->_saleitem_type_id = 0;
053 
054      $this->__id_dirty = false;
055      $this->_saleitem_id_dirty = false;
056      $this->_mdate_dirty = false;
057      $this->_cdate_dirty = false;
058      $this->_deleted_dirty = false;
059      $this->_id_dirty = false;
060      $this->_name_dirty = false;
061      $this->_description_dirty = false;
062      $this->_unit_price_dirty = false;
063      $this->_unit_id_dirty = false;
064      $this->_saleitem_type_id_dirty = false;
065 
066      if (is_null($__saleitem_id))
067      {
068          return;
069      }
070 
071      $db = service::db();
072      $q  = " SELECT com_saleitem.id,com_saleitem.name,com_saleitem.description,com_saleitem.unit_price,com_saleitem.unit_id,com_saleitem.saleitem_type_id,com_service._id,com_service.saleitem_id,com_service.mdate,com_service.cdate,com_service.deleted ";
073      $q .= " FROM com_service ";
074      $q .= " INNER JOIN com_saleitem ON com_service.saleitem_id=com_saleitem.id ";
075      $q .= is_null($__saleitem_id) ? "" : " AND com_saleitem.id='$__saleitem_id' ";       
076 
077      $db->query($q);
078      if ($db->next_record() && $db->num_rows() == 1)
079      {
080          $this->_id = $db->f("id");
081          $this->_name = $db->f("name");
082          $this->_description = $db->f("description");
083          $this->_unit_price = $db->f("unit_price");
084          $this->_unit_id = $db->f("unit_id");
085          $this->_saleitem_type_id = $db->f("saleitem_type_id");
086          $this->__id = $db->f("_id");
087          $this->_saleitem_id = $db->f("saleitem_id");
088          $this->_mdate = $db->f("mdate");
089          $this->_cdate = $db->f("cdate");
090          $this->_deleted = $db->f("deleted");
091      }
092  }
protected staticdb ( )[ service_db ]
Parameters
No parameters for this method
Code
445  protected static function db()
446  {
447      return new db();
448  }
publicdelete ( )[ service_db ]
Parameters
No parameters for this method
Code
158  public function delete()
159  {
160      parent::delete();
161      $db = service::db();
162      $q  = " UPDATE com_service SET ";
163      $q .= " deleted = 1 ";
164      $q .= " WHERE saleitem_id = " . $this->_saleitem_id;
165      $db->query($q);
166      $this->deleted = true;
167      return true;
168  }
public staticdelete_all ( )[ service_db ]
Parameters
No parameters for this method
Code
270  public static function delete_all()
271  {
272      $db = service::db();
273      $q  = " UPDATE com_service SET ";
274      $q .= " deleted = 1 ";
275     
276      $db->query($q);
277      return true;
278  }
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_category ( type ["default"] )[ saleitem_db ]
Parameters
optionaltype ["default"]
Code
384  public function get_category($__type="default")
385  {
386      $object = is_null(keyval($this->property_objects_array,"{$__type}_category")) ? new category($this->get_category_id($__type)) : $this->property_objects_array["{$__type}_category"];
387      $this->property_objects_array["{$__type}_category"] = $object;
388      return $object;
389  }
publicget_category_id ( type ["default"] )[ saleitem_db ]
Parameters
optionaltype ["default"]
Code
390  public function get_category_id($__type="default")
391  {
392      $ids = $this->get_category_ids($__type, true);
393      return (count($ids)==1 ? $ids[0] : null);
394  }
publicget_category_ids ( type , order , where_clause , limit , offset [0] , get_primary [false] )[ saleitem_db ]
Parameters
optionaltype
optionalorder
optionalwhere_clause
optionallimit
optionaloffset [0]
optionalget_primary [false]
Code
395  public function get_category_ids($__type=null, $__order=null, $__where_clause=null, $__limit=null, $__offset=0, $__get_primary=false)
396  {
397      $category_ids = array();
398      $db = saleitem::db();
399      $q  = " SELECT cor_category.id FROM com_category_saleitem INNER JOIN cor_category ON com_category_saleitem.category_id=cor_category.id AND com_category_saleitem.deleted=0 AND cor_category.deleted=0 AND com_category_saleitem.saleitem_id='$this->id' " . (is_null($__type) ? "" : " AND com_category_saleitem.category_saleitem_type_id='" . category_saleitem::type_id($__type) . "'") . ($__get_primary ? " AND com_category_saleitem.primary=1 " : "");
400      $q .= is_null($__where_clause) ? "" : " WHERE {$__where_clause}";
401      $q .= is_null($__order) ? "" : " ORDER BY {$__order}";
402      $q .= is_null($__limit) ? "" : " LIMIT {$__offset}, {$__limit}";
403      $db->query($q);
404      while ($db->next_record())
405      {
406          $category_ids[] = $db->f("id");
407      }
408      return $category_ids;
409  }
publicget_category_list ( type , order , where_clause , limit , offset [0] , get_primary [false] )[ saleitem_db ]
Parameters
optionaltype
optionalorder
optionalwhere_clause
optionallimit
optionaloffset [0]
optionalget_primary [false]
Code
410  public function get_category_list($__type=null, $__order=null, $__where_clause=null, $__limit=null, $__offset=0, $__get_primary=false)
411  {
412      $ids = $this->get_category_ids($__type, $__order, $__where_clause, $__limit, $__offset, $__get_primary);
413      $objects = array();
414      foreach ($ids as $index=>$id)
415      {
416          $objects[$index] = new category($id);
417      }
418      return $objects;
419  }
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] )[ service_db ]
Parameters
requiredcolumns
optionalorder
optionallookups
optionalwhere_clause
optionallimit
optionaloffset [0]
Code
192  public static function get_columns($__columns, $__order=null, $__lookups=null, $__where_clause=null, $__limit=null, $__offset=0)
193  {
194      $lookups = is_array($__lookups) ? $__lookups : array($__lookups);
195      $colarray = is_array($__columns) ? $__columns : explode(",",$__columns);
196      $colstring = is_array($__columns) ? implode(",",$__columns) : $__columns;
197 
198      $db = service::db();
199      $data = array();
200      $q  = " SELECT $colstring ";
201      $q .= " FROM com_service ";
202      $q .= " INNER JOIN com_saleitem ON com_service.saleitem_id=com_saleitem.id ";
203      $q .= array_key_exists("unit_id",$lookups) ? " AND com_saleitem.unit_id='" . $lookups["unit_id"] . "' " : "";
204      $q .= array_key_exists("saleitem_type_id",$lookups) ? " AND com_saleitem.saleitem_type_id='" . $lookups["saleitem_type_id"] . "' " : "";
205      $q .= " WHERE com_service.deleted = 0 ";
206      $q .= is_null($__where_clause) ? null : " AND ($__where_clause) ";
207 
208      if (is_string($__order))
209      {
210          $q .= "ORDER BY " . $__order;
211      }
212      else if (is_array($__order) and count($__order)>0)
213      {
214          $orderings = array();
215          foreach ($__order as $col=>$dir)
216          {
217              $orderings[] = " $col $dir ";
218          }
219          $q .= "ORDER BY " . implode(", ", $orderings);
220      }
221      else if (is_object($__order))
222      {
223          $q .= "";
224      }
225      else
226      {
227          // THERE IS NO `order` COLUMN ON THIS OBJECT
228      }
229 
230      if (!is_null($__limit))
231      {
232          $q .= " LIMIT $__offset , $__limit ";
233      }
234 
235      $db->query($q);
236 
237      if (count($colarray)>1 || $colstring=="*")
238      {
239          while ($db->next_record())
240          {
241              $data[] = $db->record;
242          }
243      }
244      else
245      {
246          while ($db->next_record())
247          {
248              $data[] = $db->f(0);
249          }
250      }
251 
252      return $data;
253  }
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  }
publicget_event ( type ["default"] )[ service_db ]
Parameters
optionaltype ["default"]
Code
346  public function get_event($__type="default")
347  {
348      $object = is_null(keyval($this->property_objects_array,"{$__type}_event")) ? new event($this->get_event_id($__type)) : $this->property_objects_array["{$__type}_event"];
349      $this->property_objects_array["{$__type}_event"] = $object;
350      return $object;
351  }
publicget_event_id ( type ["default"] )[ service_db ]
Parameters
optionaltype ["default"]
Code
352  public function get_event_id($__type="default")
353  {
354      $ids = $this->get_event_ids($__type, true);
355      return (count($ids)==1 ? $ids[0] : null);
356  }
publicget_event_ids ( type , order , where_clause , limit , offset [0] , get_primary [false] )[ service_db ]
Parameters
optionaltype
optionalorder
optionalwhere_clause
optionallimit
optionaloffset [0]
optionalget_primary [false]
Code
357  public function get_event_ids($__type=null, $__order=null, $__where_clause=null, $__limit=null, $__offset=0, $__get_primary=false)
358  {
359      $event_ids = array();
360      $db = service::db();
361      $q  = " SELECT cal_event.id FROM cal_event_service INNER JOIN cal_event ON cal_event_service.event_id=cal_event.id AND cal_event_service.deleted=0 AND cal_event.deleted=0 AND cal_event_service.service_saleitem_id='$this->id' " . (is_null($__type) ? "" : " AND cal_event_service.event_service_type_id='" . event_service::type_id($__type) . "'") . ($__get_primary ? " AND cal_event_service.primary=1 " : "");
362      $q .= is_null($__where_clause) ? "" : " WHERE {$__where_clause}";
363      $q .= is_null($__order) ? "" : " ORDER BY {$__order}";
364      $q .= is_null($__limit) ? "" : " LIMIT {$__offset}, {$__limit}";
365      $db->query($q);
366      while ($db->next_record())
367      {
368          $event_ids[] = $db->f("id");
369      }
370      return $event_ids;
371  }
publicget_event_list ( type , order , where_clause , limit , offset [0] , get_primary [false] )[ service_db ]
Parameters
optionaltype
optionalorder
optionalwhere_clause
optionallimit
optionaloffset [0]
optionalget_primary [false]
Code
372  public function get_event_list($__type=null, $__order=null, $__where_clause=null, $__limit=null, $__offset=0, $__get_primary=false)
373  {
374      $ids = $this->get_event_ids($__type, $__order, $__where_clause, $__limit, $__offset, $__get_primary);
375      $objects = array();
376      foreach ($ids as $index=>$id)
377      {
378          $objects[$index] = new event($id);
379      }
380      return $objects;
381  }
public staticget_ids ( order , lookups , where_clause , limit , offset [0] )[ service_db ]
Parameters
optionalorder
optionallookups
optionalwhere_clause
optionallimit
optionaloffset [0]
Code
255  public static function get_ids($__order=null, $__lookups=null, $__where_clause=null, $__limit=null, $__offset=0)
256  {
257      return service::get_columns("saleitem_id", $__order, $__lookups, $__where_clause, $__limit, $__offset);
258  }
publicget_images ( )[ saleitem_ext ]
Parameters
No parameters for this method
Code
008  public function get_images()
009  {
010      $images = array();
011      foreach (resource_saleitem::get_ids(null,$this->_id) as $resource_saleitem_id)
012      {
013          $resource_saleitem = new resource_saleitem($resource_saleitem_id);
014          $resource = new resource($resource_saleitem->resource_id);
015          switch (mime($resource->filename))
016          {
017              case "image/gif" :
018              case "image/jpeg" :
019              case "image/png" :
020                  $images[] = $resource;
021          }
022      }
023      return $images;
024  }
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] )[ service_db ]
Parameters
optionalorder
optionallookups
optionalwhere_clause
optionallimit
optionaloffset [0]
Code
260  public static function get_objects($__order=null, $__lookups=null, $__where_clause=null, $__limit=null, $__offset=0)
261  {
262      $objects = array();
263      foreach (service::get_columns("saleitem_id", $__order, $__lookups, $__where_clause, $__limit, $__offset) as $id)
264      {
265          $objects[] = new service($id);
266      }
267      return $objects;
268  }
publicget_order ( type ["default"] )[ saleitem_db ]
Parameters
optionaltype ["default"]
Code
483  public function get_order($__type="default")
484  {
485      $object = is_null(keyval($this->property_objects_array,"{$__type}_order")) ? new order($this->get_order_id($__type)) : $this->property_objects_array["{$__type}_order"];
486      $this->property_objects_array["{$__type}_order"] = $object;
487      return $object;
488  }
publicget_order_id ( type ["default"] )[ saleitem_db ]
Parameters
optionaltype ["default"]
Code
489  public function get_order_id($__type="default")
490  {
491      $ids = $this->get_order_ids($__type, true);
492      return (count($ids)==1 ? $ids[0] : null);
493  }
publicget_order_ids ( type , order , where_clause , limit , offset [0] , get_primary [false] )[ saleitem_db ]
Parameters
optionaltype
optionalorder
optionalwhere_clause
optionallimit
optionaloffset [0]
optionalget_primary [false]
Code
494  public function get_order_ids($__type=null, $__order=null, $__where_clause=null, $__limit=null, $__offset=0, $__get_primary=false)
495  {
496      $order_ids = array();
497      $db = saleitem::db();
498      $q  = " SELECT com_order.id FROM com_order_saleitem INNER JOIN com_order ON com_order_saleitem.order_id=com_order.id AND com_order_saleitem.deleted=0 AND com_order.deleted=0 AND com_order_saleitem.saleitem_id='$this->id' " . (is_null($__type) ? "" : " AND com_order_saleitem.order_saleitem_type_id='" . order_saleitem::type_id($__type) . "'") . ($__get_primary ? " AND com_order_saleitem.primary=1 " : "");
499      $q .= is_null($__where_clause) ? "" : " WHERE {$__where_clause}";
500      $q .= is_null($__order) ? "" : " ORDER BY {$__order}";
501      $q .= is_null($__limit) ? "" : " LIMIT {$__offset}, {$__limit}";
502      $db->query($q);
503      while ($db->next_record())
504      {
505          $order_ids[] = $db->f("id");
506      }
507      return $order_ids;
508  }
publicget_order_list ( type , order , where_clause , limit , offset [0] , get_primary [false] )[ saleitem_db ]
Parameters
optionaltype
optionalorder
optionalwhere_clause
optionallimit
optionaloffset [0]
optionalget_primary [false]
Code
509  public function get_order_list($__type=null, $__order=null, $__where_clause=null, $__limit=null, $__offset=0, $__get_primary=false)
510  {
511      $ids = $this->get_order_ids($__type, $__order, $__where_clause, $__limit, $__offset, $__get_primary);
512      $objects = array();
513      foreach ($ids as $index=>$id)
514      {
515          $objects[$index] = new order($id);
516      }
517      return $objects;
518  }
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"] )[ saleitem_db ]
Parameters
optionaltype ["default"]
Code
582  public function get_resource($__type="default")
583  {
584      $object = is_null(keyval($this->property_objects_array,"{$__type}_resource")) ? new resource($this->get_resource_id($__type)) : $this->property_objects_array["{$__type}_resource"];
585      $this->property_objects_array["{$__type}_resource"] = $object;
586      return $object;
587  }
publicget_resource_id ( type ["default"] )[ saleitem_db ]
Parameters
optionaltype ["default"]
Code
588  public function get_resource_id($__type="default")
589  {
590      $ids = $this->get_resource_ids($__type, true);
591      return (count($ids)==1 ? $ids[0] : null);
592  }
publicget_resource_ids ( type , order , where_clause , limit , offset [0] , get_primary [false] )[ saleitem_db ]
Parameters
optionaltype
optionalorder
optionalwhere_clause
optionallimit
optionaloffset [0]
optionalget_primary [false]
Code
593  public function get_resource_ids($__type=null, $__order=null, $__where_clause=null, $__limit=null, $__offset=0, $__get_primary=false)
594  {
595      $resource_ids = array();
596      $db = saleitem::db();
597      $q  = " SELECT cor_resource.id FROM com_resource_saleitem INNER JOIN cor_resource ON com_resource_saleitem.resource_id=cor_resource.id AND com_resource_saleitem.deleted=0 AND cor_resource.deleted=0 AND com_resource_saleitem.saleitem_id='$this->id' " . (is_null($__type) ? "" : " AND com_resource_saleitem.resource_saleitem_type_id='" . resource_saleitem::type_id($__type) . "'") . ($__get_primary ? " AND com_resource_saleitem.primary=1 " : "");
598      $q .= is_null($__where_clause) ? "" : " WHERE {$__where_clause}";
599      $q .= is_null($__order) ? "" : " ORDER BY {$__order}";
600      $q .= is_null($__limit) ? "" : " LIMIT {$__offset}, {$__limit}";
601      $db->query($q);
602      while ($db->next_record())
603      {
604          $resource_ids[] = $db->f("id");
605      }
606      return $resource_ids;
607  }
publicget_resource_list ( type , order , where_clause , limit , offset [0] , get_primary [false] )[ saleitem_db ]
Parameters
optionaltype
optionalorder
optionalwhere_clause
optionallimit
optionaloffset [0]
optionalget_primary [false]
Code
608  public function get_resource_list($__type=null, $__order=null, $__where_clause=null, $__limit=null, $__offset=0, $__get_primary=false)
609  {
610      $ids = $this->get_resource_ids($__type, $__order, $__where_clause, $__limit, $__offset, $__get_primary);
611      $objects = array();
612      foreach ($ids as $index=>$id)
613      {
614          $objects[$index] = new resource($id);
615      }
616      return $objects;
617  }
publicget_saleitem ( )[ service_db ]
Parameters
No parameters for this method
Code
334  public function get_saleitem()
335  {
336      return new saleitem($this->saleitem_id);
337  }
publicget_saleitem_type ( )[ saleitem_db ]
Parameters
No parameters for this method
Code
372  public function get_saleitem_type()
373  {
374      return new saleitem_type($this->saleitem_type_id);
375  }
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_tax ( type ["default"] )[ saleitem_db ]
Parameters
optionaltype ["default"]
Code
683  public function get_tax($__type="default")
684  {
685      $object = is_null(keyval($this->property_objects_array,"{$__type}_tax")) ? new tax($this->get_tax_id($__type)) : $this->property_objects_array["{$__type}_tax"];
686      $this->property_objects_array["{$__type}_tax"] = $object;
687      return $object;
688  }
publicget_tax_id ( type ["default"] )[ saleitem_db ]
Parameters
optionaltype ["default"]
Code
689  public function get_tax_id($__type="default")
690  {
691      $ids = $this->get_tax_ids($__type, true);
692      return (count($ids)==1 ? $ids[0] : null);
693  }
publicget_tax_ids ( type , order , where_clause , limit , offset [0] , get_primary [false] )[ saleitem_db ]
Parameters
optionaltype
optionalorder
optionalwhere_clause
optionallimit
optionaloffset [0]
optionalget_primary [false]
Code
694  public function get_tax_ids($__type=null, $__order=null, $__where_clause=null, $__limit=null, $__offset=0, $__get_primary=false)
695  {
696      $tax_ids = array();
697      $db = saleitem::db();
698      $q  = " SELECT com_tax.id FROM com_saleitem_tax INNER JOIN com_tax ON com_saleitem_tax.tax_id=com_tax.id AND com_saleitem_tax.deleted=0 AND com_tax.deleted=0 AND com_saleitem_tax.saleitem_id='$this->id' " . (is_null($__type) ? "" : " AND com_saleitem_tax.saleitem_tax_type_id='" . saleitem_tax::type_id($__type) . "'") . ($__get_primary ? " AND com_saleitem_tax.primary=1 " : "");
699      $q .= is_null($__where_clause) ? "" : " WHERE {$__where_clause}";
700      $q .= is_null($__order) ? "" : " ORDER BY {$__order}";
701      $q .= is_null($__limit) ? "" : " LIMIT {$__offset}, {$__limit}";
702      $db->query($q);
703      while ($db->next_record())
704      {
705          $tax_ids[] = $db->f("id");
706      }
707      return $tax_ids;
708  }
publicget_tax_list ( type , order , where_clause , limit , offset [0] , get_primary [false] )[ saleitem_db ]
Parameters
optionaltype
optionalorder
optionalwhere_clause
optionallimit
optionaloffset [0]
optionalget_primary [false]
Code
709  public function get_tax_list($__type=null, $__order=null, $__where_clause=null, $__limit=null, $__offset=0, $__get_primary=false)
710  {
711      $ids = $this->get_tax_ids($__type, $__order, $__where_clause, $__limit, $__offset, $__get_primary);
712      $objects = array();
713      foreach ($ids as $index=>$id)
714      {
715          $objects[$index] = new tax($id);
716      }
717      return $objects;
718  }
publicget_type ( )[ saleitem_db ]
Parameters
No parameters for this method
Code
349  public function get_type()
350  {
351      $type = new saleitem_type($this->_saleitem_type_id);
352      return $type->name;
353  }
publicget_unit ( )[ saleitem_db ]
Parameters
No parameters for this method
Code
360  public function get_unit()
361  {
362      return new unit($this->unit_id);
363  }
protectedinsert ( )[ service_db ]
Parameters
No parameters for this method
Code
125  protected function insert()
126  {
127      parent::insert();
128      $this->_saleitem_id = $this->id;
129      $db = service::db();
130      $q  = " INSERT INTO com_service ( ";
131      $q .= $db->param_string("saleitem_id") . ", ";
132      $q .= $db->param_string("mdate") . ", ";
133      $q .= $db->param_string("cdate") . ", ";
134      $q .= $db->param_string("deleted");
135      $q .= " ) VALUES ( ";
136      $q .= $db->value_string($this->_saleitem_id) . ", ";
137      $q .= $db->value_string(timestamp()) . ", ";
138      $q .= $db->value_string(timestamp()) . ", ";
139      $q .= $this->deleted ? "'1'" : "'0'";
140      $q .= " ) ";
141      $db->query($q);
142      return true;
143  }
publicmap ( )[ service_db ]
Parameters
No parameters for this method
Code
094  public function map()
095  {
096      $this->_name = array_key_exists("service:name",$_REQUEST) ? reqval("service:name") : $this->_name;
097      $this->_description = array_key_exists("service:description",$_REQUEST) ? reqval("service:description") : $this->_description;
098      $this->_unit_price = array_key_exists("service:unit_price",$_REQUEST) ? reqval("service:unit_price") : $this->_unit_price;
099      $this->_unit_id = array_key_exists("service:unit_id",$_REQUEST) ? reqval("service:unit_id") : $this->_unit_id;
100      $this->_saleitem_type_id = array_key_exists("service:saleitem_type_id",$_REQUEST) ? reqval("service:saleitem_type_id") : $this->_saleitem_type_id;
101      $this->_mdate = array_key_exists("service:mdate",$_REQUEST) ? reqval("service:mdate") : $this->_mdate;
102      $this->_cdate = array_key_exists("service:cdate",$_REQUEST) ? reqval("service:cdate") : $this->_cdate;
103      $this->_deleted = array_key_exists("service:deleted",$_REQUEST) ? reqval("service:deleted") : $this->_deleted;
104  }
publicpurge ( )[ service_db ]
Parameters
No parameters for this method
Code
182  public function purge()
183  {
184      parent::purge();
185      $db = service::db();
186      $q  = " DELETE FROM com_service ";
187      $q .= " WHERE saleitem_id = " . $this->_saleitem_id;
188      $db->query($q);
189      return true;
190  }
public staticsearch ( keyword )[ service_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_category ( v , type ["default"] )[ saleitem_db ]
Parameters
requiredv
optionaltype ["default"]
Code
421  public function set_category($__v, $__type="default")
422  {
423      $object = is_null(keyval($this->property_objects_array,"{$__type}_category")) ? new category($this->get_category_id($__type)) : $this->property_objects_array["{$__type}_category"];
424      if (is_null($__v))
425      {
426          $rel = new category_saleitem(null,$object->id,$this->id,category_saleitem::type_id($__type));
427          $rel->delete();
428          if (!is_null(keyval($this->property_objects_array,"{$__type}_category")))
429          {
430              $this->property_objects_array["{$__type}_category"] = null;
431          }
432      }
433      else
434      {
435          $id = $object->id;
436          $object = $__v;
437          $object->id = $__v->id>0 ? $__v->id : $id;
438          $object->commit();
439          $this->set_category_ids(array($object->id),$__type);
440      }
441  }
publicset_category_id ( v , type ["default"] )[ saleitem_db ]
Parameters
requiredv
optionaltype ["default"]
Code
442  public function set_category_id($__v, $__type="default")
443  {
444      $this->set_category_ids(array($__v),$__type);
445  }
publicset_category_ids ( v , type ["default"] )[ saleitem_db ]
Parameters
requiredv
optionaltype ["default"]
Code
446  public function set_category_ids($__v, $__type="default")
447  {
448      if ($this->id == 0)
449      {
450          $this->commit();
451      }
452      $type_id = category_saleitem::type_id($__type);
453      category_saleitem::delete_all(null,$this->id,$type_id);
454      if (is_array($__v))
455      {
456          foreach ($__v as $index=>$id)
457          {
458              $object = new category_saleitem(null,$id,$this->id,$type_id);
459              $object->deleted = false;
460              $object->category_saleitem_type_id = $type_id;
461              $object->commit();
462              if (count($__v)==1 && !is_null(keyval($this->property_objects_array,"{$__type}_category")))
463              {
464                  $this->property_objects_array["{$__type}_category"] = new category($object->category_id);
465              }
466          }
467          $this->_dirty = true;
468      }
469  }
publicset_category_list ( v , type ["default"] )[ saleitem_db ]
Parameters
requiredv
optionaltype ["default"]
Code
470  public function set_category_list($__v, $__type="default")
471  {
472      if (is_array($__v))
473      {
474          $ids = array();
475          foreach ($__v as $index=>$object)
476          {
477              $ids[] = $object->id;
478          }
479          $this->set_category_ids($ids,$__type);
480      }
481  }
publicset_event ( v , type ["default"] )[ service_db ]
Parameters
requiredv
optionaltype ["default"]
Code
383  public function set_event($__v, $__type="default")
384  {
385      $object = is_null(keyval($this->property_objects_array,"{$__type}_event")) ? new event($this->get_event_id($__type)) : $this->property_objects_array["{$__type}_event"];
386      if (is_null($__v))
387      {
388          $rel = new event_service(null,$object->id,$this->id,event_service::type_id($__type));
389          $rel->delete();
390          if (!is_null(keyval($this->property_objects_array,"{$__type}_event")))
391          {
392              $this->property_objects_array["{$__type}_event"] = null;
393          }
394      }
395      else
396      {
397          $id = $object->id;
398          $object = $__v;
399          $object->id = $__v->id>0 ? $__v->id : $id;
400          $object->commit();
401          $this->set_event_ids(array($object->id),$__type);
402      }
403  }
publicset_event_id ( v , type ["default"] )[ service_db ]
Parameters
requiredv
optionaltype ["default"]
Code
404  public function set_event_id($__v, $__type="default")
405  {
406      $this->set_event_ids(array($__v),$__type);
407  }
publicset_event_ids ( v , type ["default"] )[ service_db ]
Parameters
requiredv
optionaltype ["default"]
Code
408  public function set_event_ids($__v, $__type="default")
409  {
410      if ($this->id == 0)
411      {
412          $this->commit();
413      }
414      $type_id = event_service::type_id($__type);
415      event_service::delete_all(null,$this->id,$type_id);
416      if (is_array($__v))
417      {
418          foreach ($__v as $index=>$id)
419          {
420              $object = new event_service(null,$id,$this->id,$type_id);
421              $object->deleted = false;
422              $object->event_service_type_id = $type_id;
423              $object->commit();
424              if (count($__v)==1 && !is_null(keyval($this->property_objects_array,"{$__type}_event")))
425              {
426                  $this->property_objects_array["{$__type}_event"] = new event($object->event_id);
427              }
428          }
429          $this->_dirty = true;
430      }
431  }
publicset_event_list ( v , type ["default"] )[ service_db ]
Parameters
requiredv
optionaltype ["default"]
Code
432  public function set_event_list($__v, $__type="default")
433  {
434      if (is_array($__v))
435      {
436          $ids = array();
437          foreach ($__v as $index=>$object)
438          {
439              $ids[] = $object->id;
440          }
441          $this->set_event_ids($ids,$__type);
442      }
443  }
publicset_order ( v , type ["default"] )[ saleitem_db ]
Parameters
requiredv
optionaltype ["default"]
Code
520  public function set_order($__v, $__type="default")
521  {
522      $object = is_null(keyval($this->property_objects_array,"{$__type}_order")) ? new order($this->get_order_id($__type)) : $this->property_objects_array["{$__type}_order"];
523      if (is_null($__v))
524      {
525          $rel = new order_saleitem(null,$object->id,$this->id,order_saleitem::type_id($__type));
526          $rel->delete();
527          if (!is_null(keyval($this->property_objects_array,"{$__type}_order")))
528          {
529              $this->property_objects_array["{$__type}_order"] = null;
530          }
531      }
532      else
533      {
534          $id = $object->id;
535          $object = $__v;
536          $object->id = $__v->id>0 ? $__v->id : $id;
537          $object->commit();
538          $this->set_order_ids(array($object->id),$__type);
539      }
540  }
publicset_order_id ( v , type ["default"] )[ saleitem_db ]
Parameters
requiredv
optionaltype ["default"]
Code
541  public function set_order_id($__v, $__type="default")
542  {
543      $this->set_order_ids(array($__v),$__type);
544  }
publicset_order_ids ( v , type ["default"] )[ saleitem_db ]
Parameters
requiredv
optionaltype ["default"]
Code
545  public function set_order_ids($__v, $__type="default")
546  {
547      if ($this->id == 0)
548      {
549          $this->commit();
550      }
551      $type_id = order_saleitem::type_id($__type);
552      order_saleitem::delete_all(null,$this->id,$type_id);
553      if (is_array($__v))
554      {
555          foreach ($__v as $index=>$id)
556          {
557              $object = new order_saleitem(null,$id,$this->id,$type_id);
558              $object->deleted = false;
559              $object->order_saleitem_type_id = $type_id;
560              $object->commit();
561              if (count($__v)==1 && !is_null(keyval($this->property_objects_array,"{$__type}_order")))
562              {
563                  $this->property_objects_array["{$__type}_order"] = new order($object->order_id);
564              }
565          }
566          $this->_dirty = true;
567      }
568  }
publicset_order_list ( v , type ["default"] )[ saleitem_db ]
Parameters
requiredv
optionaltype ["default"]
Code
569  public function set_order_list($__v, $__type="default")
570  {
571      if (is_array($__v))
572      {
573          $ids = array();
574          foreach ($__v as $index=>$object)
575          {
576              $ids[] = $object->id;
577          }
578          $this->set_order_ids($ids,$__type);
579      }
580  }
publicset_resource ( v , type ["default"] )[ saleitem_db ]
Parameters
requiredv
optionaltype ["default"]
Code
619  public function set_resource($__v, $__type="default")
620  {
621      $object = is_null(keyval($this->property_objects_array,"{$__type}_resource")) ? new resource($this->get_resource_id($__type)) : $this->property_objects_array["{$__type}_resource"];
622      if (is_null($__v))
623      {
624          $rel = new resource_saleitem(null,$object->id,$this->id,resource_saleitem::type_id($__type));
625          $rel->delete();
626          if (!is_null(keyval($this->property_objects_array,"{$__type}_resource")))
627          {
628              $this->property_objects_array["{$__type}_resource"] = null;
629          }
630      }
631      else
632      {
633          $hash = $object->hash;
634          $id = $object->id;
635          $object = $__v;
636          $object->hash = $__v->id>0 ? $__v->hash : $hash;
637          $object->id = $__v->id>0 ? $__v->id : $id;
638          $object->commit();
639          $this->set_resource_ids(array($object->id),$__type);
640      }
641  }
publicset_resource_id ( v , type ["default"] )[ saleitem_db ]
Parameters
requiredv
optionaltype ["default"]
Code
642  public function set_resource_id($__v, $__type="default")
643  {
644      $this->set_resource_ids(array($__v),$__type);
645  }
publicset_resource_ids ( v , type ["default"] )[ saleitem_db ]
Parameters
requiredv
optionaltype ["default"]
Code
646  public function set_resource_ids($__v, $__type="default")
647  {
648      if ($this->id == 0)
649      {
650          $this->commit();
651      }
652      $type_id = resource_saleitem::type_id($__type);
653      resource_saleitem::delete_all(null,$this->id,$type_id);
654      if (is_array($__v))
655      {
656          foreach ($__v as $index=>$id)
657          {
658              $object = new resource_saleitem(null,$id,$this->id,$type_id);
659              $object->deleted = false;
660              $object->resource_saleitem_type_id = $type_id;
661              $object->commit();
662              if (count($__v)==1 && !is_null(keyval($this->property_objects_array,"{$__type}_resource")))
663              {
664                  $this->property_objects_array["{$__type}_resource"] = new resource($object->resource_id);
665              }
666          }
667          $this->_dirty = true;
668      }
669  }
publicset_resource_list ( v , type ["default"] )[ saleitem_db ]
Parameters
requiredv
optionaltype ["default"]
Code
670  public function set_resource_list($__v, $__type="default")
671  {
672      if (is_array($__v))
673      {
674          $ids = array();
675          foreach ($__v as $index=>$object)
676          {
677              $ids[] = $object->id;
678          }
679          $this->set_resource_ids($ids,$__type);
680      }
681  }
publicset_saleitem ( v )[ service_db ]
Parameters
requiredv
Code
338  public function set_saleitem($v)
339  {
340      if ($v->id > 0)
341      {
342          $this->saleitem_id = $v->id;
343      }
344  }
publicset_saleitem_type ( v )[ saleitem_db ]
Parameters
requiredv
Code
376  public function set_saleitem_type($v)
377  {
378      if ($v->id > 0)
379      {
380          $this->saleitem_type_id = $v->id;
381      }
382  }
publicset_tax ( v , type ["default"] )[ saleitem_db ]
Parameters
requiredv
optionaltype ["default"]
Code
720  public function set_tax($__v, $__type="default")
721  {
722      $object = is_null(keyval($this->property_objects_array,"{$__type}_tax")) ? new tax($this->get_tax_id($__type)) : $this->property_objects_array["{$__type}_tax"];
723      if (is_null($__v))
724      {
725          $rel = new saleitem_tax(null,$this->id,$object->id,saleitem_tax::type_id($__type));
726          $rel->delete();
727          if (!is_null(keyval($this->property_objects_array,"{$__type}_tax")))
728          {
729              $this->property_objects_array["{$__type}_tax"] = null;
730          }
731      }
732      else
733      {
734          $id = $object->id;
735          $object = $__v;
736          $object->id = $__v->id>0 ? $__v->id : $id;
737          $object->commit();
738          $this->set_tax_ids(array($object->id),$__type);
739      }
740  }
publicset_tax_id ( v , type ["default"] )[ saleitem_db ]
Parameters
requiredv
optionaltype ["default"]
Code
741  public function set_tax_id($__v, $__type="default")
742  {
743      $this->set_tax_ids(array($__v),$__type);
744  }
publicset_tax_ids ( v , type ["default"] )[ saleitem_db ]
Parameters
requiredv
optionaltype ["default"]
Code
745  public function set_tax_ids($__v, $__type="default")
746  {
747      if ($this->id == 0)
748      {
749          $this->commit();
750      }
751      $type_id = saleitem_tax::type_id($__type);
752      saleitem_tax::delete_all($this->id,null,$type_id);
753      if (is_array($__v))
754      {
755          foreach ($__v as $index=>$id)
756          {
757              $object = new saleitem_tax(null,$this->id,$id,$type_id);
758              $object->deleted = false;
759              $object->saleitem_tax_type_id = $type_id;
760              $object->commit();
761              if (count($__v)==1 && !is_null(keyval($this->property_objects_array,"{$__type}_tax")))
762              {
763                  $this->property_objects_array["{$__type}_tax"] = new tax($object->tax_id);
764              }
765          }
766          $this->_dirty = true;
767      }
768  }
publicset_tax_list ( v , type ["default"] )[ saleitem_db ]
Parameters
requiredv
optionaltype ["default"]
Code
769  public function set_tax_list($__v, $__type="default")
770  {
771      if (is_array($__v))
772      {
773          $ids = array();
774          foreach ($__v as $index=>$object)
775          {
776              $ids[] = $object->id;
777          }
778          $this->set_tax_ids($ids,$__type);
779      }
780  }
publicset_type ( v )[ saleitem_db ]
Parameters
requiredv
Code
354  public function set_type($v)
355  {
356      $type = new saleitem_type(null, $v);
357      $this->saleitem_type_id = $type->id;
358  }
publicset_unit ( v )[ saleitem_db ]
Parameters
requiredv
Code
364  public function set_unit($v)
365  {
366      if ($v->id > 0)
367      {
368          $this->unit_id = $v->id;
369      }
370  }
public__toString ( )[ service_db ]
Parameters
No parameters for this method
Code
329  public function __toString()
330  {
331      return (is_null($this->id) ? "" : $this->id);
332  }
public statictype_id ( type_name )[ saleitem_db ]
Parameters
requiredtype_name
Code
343  public static function type_id($__type_name)
344  {
345      $type = new saleitem_type(null, $__type_name);
346      return $type->id;
347  }
publicundelete ( )[ service_db ]
Parameters
No parameters for this method
Code
170  public function undelete()
171  {
172      parent::undelete();
173      $db = service::db();
174      $q  = " UPDATE com_service SET ";
175      $q .= " deleted = 0 ";
176      $q .= " WHERE saleitem_id = " . $this->_saleitem_id;
177      $db->query($q);
178      $this->deleted = false;
179      return true;
180  }
protectedupdate ( )[ service_db ]
Parameters
No parameters for this method
Code
145  protected function update()
146  {
147      parent::update();
148      $db = service::db();
149      $q  = " UPDATE com_service SET ";
150      $q .= $db->param_string("saleitem_id") . " = " . $db->value_string($this->_saleitem_id) . ", ";
151      $q .= $db->param_string("mdate") . " = " . $db->value_string(timestamp()) . ", ";
152      $q .= $db->param_string("deleted") . " = " . ($this->deleted ? "'1'" : "'0'");
153      $q .= " WHERE saleitem_id = " . $this->_saleitem_id;
154      $db->query($q);
155      return true;
156  }
 
Accessors
publicarray[ obj ]
Code
096  public function get_array()
097  {
098      return get_object_vars($this);
099  }
publiccategory[ saleitem_db ]
Code
384  public function get_category($__type="default")
385  {
386      $object = is_null(keyval($this->property_objects_array,"{$__type}_category")) ? new category($this->get_category_id($__type)) : $this->property_objects_array["{$__type}_category"];
387      $this->property_objects_array["{$__type}_category"] = $object;
388      return $object;
389  }
Code
421  public function set_category($__v, $__type="default")
422  {
423      $object = is_null(keyval($this->property_objects_array,"{$__type}_category")) ? new category($this->get_category_id($__type)) : $this->property_objects_array["{$__type}_category"];
424      if (is_null($__v))
425      {
426          $rel = new category_saleitem(null,$object->id,$this->id,category_saleitem::type_id($__type));
427          $rel->delete();
428          if (!is_null(keyval($this->property_objects_array,"{$__type}_category")))
429          {
430              $this->property_objects_array["{$__type}_category"] = null;
431          }
432      }
433      else
434      {
435          $id = $object->id;
436          $object = $__v;
437          $object->id = $__v->id>0 ? $__v->id : $id;
438          $object->commit();
439          $this->set_category_ids(array($object->id),$__type);
440      }
441  }
publiccategory_id[ saleitem_db ]
Code
390  public function get_category_id($__type="default")
391  {
392      $ids = $this->get_category_ids($__type, true);
393      return (count($ids)==1 ? $ids[0] : null);
394  }
Code
442  public function set_category_id($__v, $__type="default")
443  {
444      $this->set_category_ids(array($__v),$__type);
445  }
publiccategory_ids[ saleitem_db ]
Code
395  public function get_category_ids($__type=null, $__order=null, $__where_clause=null, $__limit=null, $__offset=0, $__get_primary=false)
396  {
397      $category_ids = array();
398      $db = saleitem::db();
399      $q  = " SELECT cor_category.id FROM com_category_saleitem INNER JOIN cor_category ON com_category_saleitem.category_id=cor_category.id AND com_category_saleitem.deleted=0 AND cor_category.deleted=0 AND com_category_saleitem.saleitem_id='$this->id' " . (is_null($__type) ? "" : " AND com_category_saleitem.category_saleitem_type_id='" . category_saleitem::type_id($__type) . "'") . ($__get_primary ? " AND com_category_saleitem.primary=1 " : "");
400      $q .= is_null($__where_clause) ? "" : " WHERE {$__where_clause}";
401      $q .= is_null($__order) ? "" : " ORDER BY {$__order}";
402      $q .= is_null($__limit) ? "" : " LIMIT {$__offset}, {$__limit}";
403      $db->query($q);
404      while ($db->next_record())
405      {
406          $category_ids[] = $db->f("id");
407      }
408      return $category_ids;
409  }
Code
446  public function set_category_ids($__v, $__type="default")
447  {
448      if ($this->id == 0)
449      {
450          $this->commit();
451      }
452      $type_id = category_saleitem::type_id($__type);
453      category_saleitem::delete_all(null,$this->id,$type_id);
454      if (is_array($__v))
455      {
456          foreach ($__v as $index=>$id)
457          {
458              $object = new category_saleitem(null,$id,$this->id,$type_id);
459              $object->deleted = false;
460              $object->category_saleitem_type_id = $type_id;
461              $object->commit();
462              if (count($__v)==1 && !is_null(keyval($this->property_objects_array,"{$__type}_category")))
463              {
464                  $this->property_objects_array["{$__type}_category"] = new category($object->category_id);
465              }
466          }
467          $this->_dirty = true;
468      }
469  }
publiccategory_list[ saleitem_db ]
Code
410  public function get_category_list($__type=null, $__order=null, $__where_clause=null, $__limit=null, $__offset=0, $__get_primary=false)
411  {
412      $ids = $this->get_category_ids($__type, $__order, $__where_clause, $__limit, $__offset, $__get_primary);
413      $objects = array();
414      foreach ($ids as $index=>$id)
415      {
416          $objects[$index] = new category($id);
417      }
418      return $objects;
419  }
Code
470  public function set_category_list($__v, $__type="default")
471  {
472      if (is_array($__v))
473      {
474          $ids = array();
475          foreach ($__v as $index=>$object)
476          {
477              $ids[] = $object->id;
478          }
479          $this->set_category_ids($ids,$__type);
480      }
481  }
publicclassname[ obj ]
Code
086  public function get_classname()
087  {
088      return get_class($this);
089  }
publiccolumns[ service_db ]
Code
192  public static function get_columns($__columns, $__order=null, $__lookups=null, $__where_clause=null, $__limit=null, $__offset=0)
193  {
194      $lookups = is_array($__lookups) ? $__lookups : array($__lookups);
195      $colarray = is_array($__columns) ? $__columns : explode(",",$__columns);
196      $colstring = is_array($__columns) ? implode(",",$__columns) : $__columns;
197 
198      $db = service::db();
199      $data = array();
200      $q  = " SELECT $colstring ";
201      $q .= " FROM com_service ";
202      $q .= " INNER JOIN com_saleitem ON com_service.saleitem_id=com_saleitem.id ";
203      $q .= array_key_exists("unit_id",$lookups) ? " AND com_saleitem.unit_id='" . $lookups["unit_id"] . "' " : "";
204      $q .= array_key_exists("saleitem_type_id",$lookups) ? " AND com_saleitem.saleitem_type_id='" . $lookups["saleitem_type_id"] . "' " : "";
205      $q .= " WHERE com_service.deleted = 0 ";
206      $q .= is_null($__where_clause) ? null : " AND ($__where_clause) ";
207 
208      if (is_string($__order))
209      {
210          $q .= "ORDER BY " . $__order;
211      }
212      else if (is_array($__order) and count($__order)>0)
213      {
214          $orderings = array();
215          foreach ($__order as $col=>$dir)
216          {
217              $orderings[] = " $col $dir ";
218          }
219          $q .= "ORDER BY " . implode(", ", $orderings);
220      }
221      else if (is_object($__order))
222      {
223          $q .= "";
224      }
225      else
226      {
227          // THERE IS NO `order` COLUMN ON THIS OBJECT
228      }
229 
230      if (!is_null($__limit))
231      {
232          $q .= " LIMIT $__offset , $__limit ";
233      }
234 
235      $db->query($q);
236 
237      if (count($colarray)>1 || $colstring=="*")
238      {
239          while ($db->next_record())
240          {
241              $data[] = $db->record;
242          }
243      }
244      else
245      {
246          while ($db->next_record())
247          {
248              $data[] = $db->f(0);
249          }
250      }
251 
252      return $data;
253  }
publicdirty[ obj ]
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  }
publicevent[ service_db ]
Code
346  public function get_event($__type="default")
347  {
348      $object = is_null(keyval($this->property_objects_array,"{$__type}_event")) ? new event($this->get_event_id($__type)) : $this->property_objects_array["{$__type}_event"];
349      $this->property_objects_array["{$__type}_event"] = $object;
350      return $object;
351  }
Code
383  public function set_event($__v, $__type="default")
384  {
385      $object = is_null(keyval($this->property_objects_array,"{$__type}_event")) ? new event($this->get_event_id($__type)) : $this->property_objects_array["{$__type}_event"];
386      if (is_null($__v))
387      {
388          $rel = new event_service(null,$object->id,$this->id,event_service::type_id($__type));
389          $rel->delete();
390          if (!is_null(keyval($this->property_objects_array,"{$__type}_event")))
391          {
392              $this->property_objects_array["{$__type}_event"] = null;
393          }
394      }
395      else
396      {
397          $id = $object->id;
398          $object = $__v;
399          $object->id = $__v->id>0 ? $__v->id : $id;
400          $object->commit();
401          $this->set_event_ids(array($object->id),$__type);
402      }
403  }
publicevent_id[ service_db ]
Code
352  public function get_event_id($__type="default")
353  {
354      $ids = $this->get_event_ids($__type, true);
355      return (count($ids)==1 ? $ids[0] : null);
356  }
Code
404  public function set_event_id($__v, $__type="default")
405  {
406      $this->set_event_ids(array($__v),$__type);
407  }
publicevent_ids[ service_db ]
Code
357  public function get_event_ids($__type=null, $__order=null, $__where_clause=null, $__limit=null, $__offset=0, $__get_primary=false)
358  {
359      $event_ids = array();
360      $db = service::db();
361      $q  = " SELECT cal_event.id FROM cal_event_service INNER JOIN cal_event ON cal_event_service.event_id=cal_event.id AND cal_event_service.deleted=0 AND cal_event.deleted=0 AND cal_event_service.service_saleitem_id='$this->id' " . (is_null($__type) ? "" : " AND cal_event_service.event_service_type_id='" . event_service::type_id($__type) . "'") . ($__get_primary ? " AND cal_event_service.primary=1 " : "");
362      $q .= is_null($__where_clause) ? "" : " WHERE {$__where_clause}";
363      $q .= is_null($__order) ? "" : " ORDER BY {$__order}";
364      $q .= is_null($__limit) ? "" : " LIMIT {$__offset}, {$__limit}";
365      $db->query($q);
366      while ($db->next_record())
367      {
368          $event_ids[] = $db->f("id");
369      }
370      return $event_ids;
371  }
Code
408  public function set_event_ids($__v, $__type="default")
409  {
410      if ($this->id == 0)
411      {
412          $this->commit();
413      }
414      $type_id = event_service::type_id($__type);
415      event_service::delete_all(null,$this->id,$type_id);
416      if (is_array($__v))
417      {
418          foreach ($__v as $index=>$id)
419          {
420              $object = new event_service(null,$id,$this->id,$type_id);
421              $object->deleted = false;
422              $object->event_service_type_id = $type_id;
423              $object->commit();
424              if (count($__v)==1 && !is_null(keyval($this->property_objects_array,"{$__type}_event")))
425              {
426                  $this->property_objects_array["{$__type}_event"] = new event($object->event_id);
427              }
428          }
429          $this->_dirty = true;
430      }
431  }
publicevent_list[ service_db ]
Code
372  public function get_event_list($__type=null, $__order=null, $__where_clause=null, $__limit=null, $__offset=0, $__get_primary=false)
373  {
374      $ids = $this->get_event_ids($__type, $__order, $__where_clause, $__limit, $__offset, $__get_primary);
375      $objects = array();
376      foreach ($ids as $index=>$id)
377      {
378          $objects[$index] = new event($id);
379      }
380      return $objects;
381  }
Code
432  public function set_event_list($__v, $__type="default")
433  {
434      if (is_array($__v))
435      {
436          $ids = array();
437          foreach ($__v as $index=>$object)
438          {
439              $ids[] = $object->id;
440          }
441          $this->set_event_ids($ids,$__type);
442      }
443  }
publicids[ service_db ]
Code
255  public static function get_ids($__order=null, $__lookups=null, $__where_clause=null, $__limit=null, $__offset=0)
256  {
257      return service::get_columns("saleitem_id", $__order, $__lookups, $__where_clause, $__limit, $__offset);
258  }
publicimages[ saleitem_ext ]
Code
008  public function get_images()
009  {
010      $images = array();
011      foreach (resource_saleitem::get_ids(null,$this->_id) as $resource_saleitem_id)
012      {
013          $resource_saleitem = new resource_saleitem($resource_saleitem_id);
014          $resource = new resource($resource_saleitem->resource_id);
015          switch (mime($resource->filename))
016          {
017              case "image/gif" :
018              case "image/jpeg" :
019              case "image/png" :
020                  $images[] = $resource;
021          }
022      }
023      return $images;
024  }
publicjson[ obj ]
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  }
publicobjects[ service_db ]
Code
260  public static function get_objects($__order=null, $__lookups=null, $__where_clause=null, $__limit=null, $__offset=0)
261  {
262      $objects = array();
263      foreach (service::get_columns("saleitem_id", $__order, $__lookups, $__where_clause, $__limit, $__offset) as $id)
264      {
265          $objects[] = new service($id);
266      }
267      return $objects;
268  }
publicorder[ saleitem_db ]
Code
483  public function get_order($__type="default")
484  {
485      $object = is_null(keyval($this->property_objects_array,"{$__type}_order")) ? new order($this->get_order_id($__type)) : $this->property_objects_array["{$__type}_order"];
486      $this->property_objects_array["{$__type}_order"] = $object;
487      return $object;
488  }
Code
520  public function set_order($__v, $__type="default")
521  {
522      $object = is_null(keyval($this->property_objects_array,"{$__type}_order")) ? new order($this->get_order_id($__type)) : $this->property_objects_array["{$__type}_order"];
523      if (is_null($__v))
524      {
525          $rel = new order_saleitem(null,$object->id,$this->id,order_saleitem::type_id($__type));
526          $rel->delete();
527          if (!is_null(keyval($this->property_objects_array,"{$__type}_order")))
528          {
529              $this->property_objects_array["{$__type}_order"] = null;
530          }
531      }
532      else
533      {
534          $id = $object->id;
535          $object = $__v;
536          $object->id = $__v->id>0 ? $__v->id : $id;
537          $object->commit();
538          $this->set_order_ids(array($object->id),$__type);
539      }
540  }
publicorder_id[ saleitem_db ]
Code
489  public function get_order_id($__type="default")
490  {
491      $ids = $this->get_order_ids($__type, true);
492      return (count($ids)==1 ? $ids[0] : null);
493  }
Code
541  public function set_order_id($__v, $__type="default")
542  {
543      $this->set_order_ids(array($__v),$__type);
544  }
publicorder_ids[ saleitem_db ]
Code
494  public function get_order_ids($__type=null, $__order=null, $__where_clause=null, $__limit=null, $__offset=0, $__get_primary=false)
495  {
496      $order_ids = array();
497      $db = saleitem::db();
498      $q  = " SELECT com_order.id FROM com_order_saleitem INNER JOIN com_order ON com_order_saleitem.order_id=com_order.id AND com_order_saleitem.deleted=0 AND com_order.deleted=0 AND com_order_saleitem.saleitem_id='$this->id' " . (is_null($__type) ? "" : " AND com_order_saleitem.order_saleitem_type_id='" . order_saleitem::type_id($__type) . "'") . ($__get_primary ? " AND com_order_saleitem.primary=1 " : "");
499      $q .= is_null($__where_clause) ? "" : " WHERE {$__where_clause}";
500      $q .= is_null($__order) ? "" : " ORDER BY {$__order}";
501      $q .= is_null($__limit) ? "" : " LIMIT {$__offset}, {$__limit}";
502      $db->query($q);
503      while ($db->next_record())
504      {
505          $order_ids[] = $db->f("id");
506      }
507      return $order_ids;
508  }
Code
545  public function set_order_ids($__v, $__type="default")
546  {
547      if ($this->id == 0)
548      {
549          $this->commit();
550      }
551      $type_id = order_saleitem