Helix Installation   Getting Started   Reference Documentation   Global Functions   Quick Start
ModulesClassesFunctions
 

Class Reference

class saleitem_db extends obj

Hide Inherited MembersE-Commerce
Description
No description.
 
Constants
constantTABLENAME ["com_saleitem"][ saleitem_db ]
 
Properties
protected_cdate[ saleitem_db ]
protected_cdate_dirty[ saleitem_db ]
protected_deleted[ saleitem_db ]
protected_deleted_dirty[ saleitem_db ]
protected_description[ saleitem_db ]
protected_description_dirty[ saleitem_db ]
protected_dirty[ obj ]
protected_id[ saleitem_db ]
protected_id_dirty[ saleitem_db ]
protected_mdate[ saleitem_db ]
protected_mdate_dirty[ saleitem_db ]
protected_name[ saleitem_db ]
protected_name_dirty[ saleitem_db ]
publicproperty_objects_array[ obj ]
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 ( )[ saleitem_db ]
Parameters
No parameters for this method
Code
110  public function commit()
111  {
112      if ($this->_id > 0)
113      {
114          $this->update();
115      }
116      else
117      {
118          $this->insert();
119      }
120 
121      foreach ($this->property_objects_array as $property=>$object)
122      {
123          $this->{$property} = $object;
124      }
125 
126      return true;
127  }
public__construct ( id )[ saleitem_db ]
Parameters
optionalid
Code
048  public function __construct($__id=null)
049  {
050      $this->_id = 0;
051      $this->_name = "";
052      $this->_description = "";
053      $this->_unit_price = 0;
054      $this->_unit_id = 0;
055      $this->_saleitem_type_id = 0;
056      $this->_mdate = null;
057      $this->_cdate = null;
058      $this->_deleted = false;
059 
060      $this->_id_dirty = false;
061      $this->_name_dirty = false;
062      $this->_description_dirty = false;
063      $this->_unit_price_dirty = false;
064      $this->_unit_id_dirty = false;
065      $this->_saleitem_type_id_dirty = false;
066      $this->_mdate_dirty = false;
067      $this->_cdate_dirty = false;
068      $this->_deleted_dirty = false;
069 
070      if (is_null($__id))
071      {
072          return;
073      }
074 
075      $db = saleitem::db();
076      $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_saleitem.mdate,com_saleitem.cdate,com_saleitem.deleted ";
077      $q .= " FROM com_saleitem ";       
078      if (!is_null($__id))
079      {
080          $q .= " WHERE id = '$__id' ";
081      }
082 
083      $db->query($q);
084      if ($db->next_record() && $db->num_rows() == 1)
085      {
086          $this->_id = $db->f("id");
087          $this->_name = $db->f("name");
088          $this->_description = $db->f("description");
089          $this->_unit_price = $db->f("unit_price");
090          $this->_unit_id = $db->f("unit_id");
091          $this->_saleitem_type_id = $db->f("saleitem_type_id");
092          $this->_mdate = $db->f("mdate");
093          $this->_cdate = $db->f("cdate");
094          $this->_deleted = $db->f("deleted");
095      }
096  }
protected staticdb ( )[ saleitem_db ]
Parameters
No parameters for this method
Code
782  protected static function db()
783  {
784      return new db();
785  }
publicdelete ( )[ saleitem_db ]
Parameters
No parameters for this method
Code
172  public function delete()
173  {
174      $db = saleitem::db();
175      $q  = " UPDATE com_saleitem SET ";
176      $q .= " deleted = 1 ";
177      $q .= " WHERE id = " . $this->_id;
178      $db->query($q);
179      $this->deleted = true;
180      return true;
181  }
public staticdelete_all ( )[ saleitem_db ]
Parameters
No parameters for this method
Code
280  public static function delete_all()
281  {
282      $db = saleitem::db();
283      $q  = " UPDATE com_saleitem SET ";
284      $q .= " deleted = 1 ";
285     
286      $db->query($q);
287      return true;
288  }
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] )[ saleitem_db ]
Parameters
requiredcolumns
optionalorder
optionallookups
optionalwhere_clause
optionallimit
optionaloffset [0]
Code
203  public static function get_columns($__columns, $__order=null, $__lookups=null, $__where_clause=null, $__limit=null, $__offset=0)
204  {
205      $lookups = is_array($__lookups) ? $__lookups : array($__lookups);
206      $colarray = is_array($__columns) ? $__columns : explode(",",$__columns);
207      $colstring = is_array($__columns) ? implode(",",$__columns) : $__columns;
208 
209      $db = saleitem::db();
210      $data = array();
211      $q  = " SELECT $colstring ";
212      $q .= " FROM com_saleitem ";
213      $q .= " WHERE com_saleitem.deleted = 0 ";
214      $q .= is_null($__where_clause) ? null : " AND ($__where_clause) ";
215      $q .= array_key_exists("unit_id",$lookups) ? " AND com_saleitem.unit_id='" . $lookups["unit_id"] . "' " : "";
216      $q .= array_key_exists("saleitem_type_id",$lookups) ? " AND com_saleitem.saleitem_type_id='" . $lookups["saleitem_type_id"] . "' " : "";
217 
218      if (is_string($__order))
219      {
220          $q .= "ORDER BY " . $__order;
221      }
222      else if (is_array($__order) and count($__order)>0)
223      {
224          $orderings = array();
225          foreach ($__order as $col=>$dir)
226          {
227              $orderings[] = " $col $dir ";
228          }
229          $q .= "ORDER BY " . implode(", ", $orderings);
230      }
231      else if (is_object($__order))
232      {
233          $q .= "";
234      }
235      else
236      {
237          // THERE IS NO `order` COLUMN ON THIS OBJECT
238      }
239 
240      if (!is_null($__limit))
241      {
242          $q .= " LIMIT $__offset , $__limit ";
243      }
244 
245      $db->query($q);
246 
247      if (count($colarray)>1 || $colstring=="*")
248      {
249          while ($db->next_record())
250          {
251              $data[] = $db->record;
252          }
253      }
254      else
255      {
256          while ($db->next_record())
257          {
258              $data[] = $db->f(0);
259          }
260      }
261 
262      return $data;
263  }
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] )[ saleitem_db ]
Parameters
optionalorder
optionallookups
optionalwhere_clause
optionallimit
optionaloffset [0]
Code
265  public static function get_ids($__order=null, $__lookups=null, $__where_clause=null, $__limit=null, $__offset=0)
266  {
267      return saleitem::get_columns("id", $__order, $__lookups, $__where_clause, $__limit, $__offset);
268  }
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] )[ saleitem_db ]
Parameters
optionalorder
optionallookups
optionalwhere_clause
optionallimit
optionaloffset [0]
Code
270  public static function get_objects($__order=null, $__lookups=null, $__where_clause=null, $__limit=null, $__offset=0)
271  {
272      $objects = array();
273      foreach (saleitem::get_columns("id", $__order, $__lookups, $__where_clause, $__limit, $__offset) as $id)
274      {
275          $objects[] = new saleitem($id);
276      }
277      return $objects;
278  }
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_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 ( )[ saleitem_db ]
Parameters
No parameters for this method
Code
129  protected function insert()
130  {
131      $db = saleitem::db();
132      $q  = " INSERT INTO com_saleitem ( ";
133      $q .= $db->param_string("name") . ", ";
134      $q .= $db->param_string("description") . ", ";
135      $q .= $db->param_string("unit_price") . ", ";
136      $q .= $db->param_string("unit_id") . ", ";
137      $q .= $db->param_string("saleitem_type_id") . ", ";
138      $q .= $db->param_string("mdate") . ", ";
139      $q .= $db->param_string("cdate") . ", ";
140      $q .= $db->param_string("deleted");
141      $q .= " ) VALUES ( ";
142      $q .= $db->value_string($this->_name) . ", ";
143      $q .= $db->value_string($this->_description) . ", ";
144      $q .= $db->value_string($this->_unit_price) . ", ";
145      $q .= $db->value_string($this->_unit_id) . ", ";
146      $q .= $db->value_string($this->_saleitem_type_id) . ", ";
147      $q .= $db->value_string(timestamp()) . ", ";
148      $q .= $db->value_string(timestamp()) . ", ";
149      $q .= $this->deleted ? "'1'" : "'0'";
150      $q .= " ) ";
151      $db->query($q);
152      $this->_id = $db->insert_id;
153      return true;
154  }
publicmap ( )[ saleitem_db ]
Parameters
No parameters for this method
Code
098  public function map()
099  {
100      $this->_name = array_key_exists("saleitem:name",$_REQUEST) ? reqval("saleitem:name") : $this->_name;
101      $this->_description = array_key_exists("saleitem:description",$_REQUEST) ? reqval("saleitem:description") : $this->_description;
102      $this->_unit_price = array_key_exists("saleitem:unit_price",$_REQUEST) ? reqval("saleitem:unit_price") : $this->_unit_price;
103      $this->_unit_id = array_key_exists("saleitem:unit_id",$_REQUEST) ? reqval("saleitem:unit_id") : $this->_unit_id;
104      $this->_saleitem_type_id = array_key_exists("saleitem:saleitem_type_id",$_REQUEST) ? reqval("saleitem:saleitem_type_id") : $this->_saleitem_type_id;
105      $this->_mdate = array_key_exists("saleitem:mdate",$_REQUEST) ? reqval("saleitem:mdate") : $this->_mdate;
106      $this->_cdate = array_key_exists("saleitem:cdate",$_REQUEST) ? reqval("saleitem:cdate") : $this->_cdate;
107      $this->_deleted = array_key_exists("saleitem:deleted",$_REQUEST) ? reqval("saleitem:deleted") : $this->_deleted;
108  }
publicpurge ( )[ saleitem_db ]
Parameters
No parameters for this method
Code
194  public function purge()
195  {
196      $db = saleitem::db();
197      $q  = " DELETE FROM com_saleitem ";
198      $q .= " WHERE id = " . $this->_id;
199      $db->query($q);
200      return true;
201  }
public staticsearch ( keyword )[ saleitem_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_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_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 ( )[ saleitem_db ]
Parameters
No parameters for this method
Code
338  public function __toString()
339  {
340      return (is_null($this->name) ? "" : $this->name);
341  }
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 ( )[ saleitem_db ]
Parameters
No parameters for this method
Code
183  public function undelete()
184  {
185      $db = saleitem::db();
186      $q  = " UPDATE com_saleitem SET ";
187      $q .= " deleted = 0 ";
188      $q .= " WHERE id = " . $this->_id;
189      $db->query($q);
190      $this->deleted = false;
191      return true;
192  }
protectedupdate ( )[ saleitem_db ]
Parameters
No parameters for this method
Code
156  protected function update()
157  {
158      $db = saleitem::db();
159      $q  = " UPDATE com_saleitem SET ";
160      $q .= $db->param_string("name") . " = " . $db->value_string($this->_name) . ", ";
161      $q .= $db->param_string("description") . " = " . $db->value_string($this->_description) . ", ";
162      $q .= $db->param_string("unit_price") . " = " . $db->value_string($this->_unit_price) . ", ";
163      $q .= $db->param_string("unit_id") . " = " . $db->value_string($this->_unit_id) . ", ";
164      $q .= $db->param_string("saleitem_type_id") . " = " . $db->value_string($this->_saleitem_type_id) . ", ";
165      $q .= $db->param_string("mdate") . " = " . $db->value_string(timestamp()) . ", ";
166      $q .= $db->param_string("deleted") . " = " . ($this->deleted ? "'1'" : "'0'");
167      $q .= " WHERE id = " . $this->_id;
168      $db->query($q);
169      return true;
170  }
 
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[ saleitem_db ]
Code
203  public static function get_columns($__columns, $__order=null, $__lookups=null, $__where_clause=null, $__limit=null, $__offset=0)
204  {
205      $lookups = is_array($__lookups) ? $__lookups : array($__lookups);
206      $colarray = is_array($__columns) ? $__columns : explode(",",$__columns);
207      $colstring = is_array($__columns) ? implode(",",$__columns) : $__columns;
208 
209      $db = saleitem::db();
210      $data = array();
211      $q  = " SELECT $colstring ";
212      $q .= " FROM com_saleitem ";
213      $q .= " WHERE com_saleitem.deleted = 0 ";
214      $q .= is_null($__where_clause) ? null : " AND ($__where_clause) ";
215      $q .= array_key_exists("unit_id",$lookups) ? " AND com_saleitem.unit_id='" . $lookups["unit_id"] . "' " : "";
216      $q .= array_key_exists("saleitem_type_id",$lookups) ? " AND com_saleitem.saleitem_type_id='" . $lookups["saleitem_type_id"] . "' " : "";
217 
218      if (is_string($__order))
219      {
220          $q .= "ORDER BY " . $__order;
221      }
222      else if (is_array($__order) and count($__order)>0)
223      {
224          $orderings = array();
225          foreach ($__order as $col=>$dir)
226          {
227              $orderings[] = " $col $dir ";
228          }
229          $q .= "ORDER BY " . implode(", ", $orderings);
230      }
231      else if (is_object($__order))
232      {
233          $q .= "";
234      }
235      else
236      {
237          // THERE IS NO `order` COLUMN ON THIS OBJECT
238      }
239 
240      if (!is_null($__limit))
241      {
242          $q .= " LIMIT $__offset , $__limit ";
243      }
244 
245      $db->query($q);
246 
247      if (count($colarray)>1 || $colstring=="*")
248      {
249          while ($db->next_record())
250          {
251              $data[] = $db->record;
252          }
253      }
254      else
255      {
256          while ($db->next_record())
257          {
258              $data[] = $db->f(0);
259          }
260      }
261 
262      return $data;
263  }
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  }
publicids[ saleitem_db ]
Code
265  public static function get_ids($__order=null, $__lookups=null, $__where_clause=null, $__limit=null, $__offset=0)
266  {
267      return saleitem::get_columns("id", $__order, $__lookups, $__where_clause, $__limit, $__offset);
268  }
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[ saleitem_db ]
Code
270  public static function get_objects($__order=null, $__lookups=null, $__where_clause=null, $__limit=null, $__offset=0)
271  {
272      $objects = array();
273      foreach (saleitem::get_columns("id", $__order, $__lookups, $__where_clause, $__limit, $__offset) as $id)
274      {
275          $objects[] = new saleitem($id);
276      }
277      return $objects;
278  }
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::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  }
publicorder_list[ saleitem_db ]
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  }
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  }
publicproperties[ obj ]
Code
121  public function get_properties()
122  {
123      return array_keys($this->array);
124  }
publicresource[ saleitem_db ]
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  }
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  }
publicresource_id[ saleitem_db ]
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  }
Code
642  public function set_resource_id($__v, $__type="default")
643  {
644      $this->set_resource_ids(array($__v),$__type);
645  }
publicresource_ids[ saleitem_db ]
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  }
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  }
publicresource_list[ saleitem_db ]
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  }
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  }
publicsaleitem_type[ saleitem_db ]
Code
372  public function get_saleitem_type()
373  {
374      return new saleitem_type($this->saleitem_type_id);
375  }
Code
376  public function set_saleitem_type($v)
377  {
378      if ($v->id > 0)
379      {
380          $this->saleitem_type_id = $v->id;
381      }
382  }
publicstring[ obj ]
Code
091  protected function get_string()
092  {
093      return method_exists($this,"__toString") ? $this->__toString() : null;
094  }
publictax[ saleitem_db ]
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  }
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  }
publictax_id[ saleitem_db ]
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  }
Code
741  public function set_tax_id($__v, $__type="default")
742  {
743      $this->set_tax_ids(array($__v),$__type);
744  }
publictax_ids[ saleitem_db ]
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  }
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  }
publictax_list[ saleitem_db ]
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  }
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  }
publictype[ saleitem_db ]
Code
349  public function get_type()
350  {
351      $type = new saleitem_type($this->_saleitem_type_id);
352      return $type->name;
353  }
Code
354  public function set_type($v)
355  {
356      $type = new saleitem_type(null, $v);
357      $this->saleitem_type_id = $type->id;
358  }
publicunit[ saleitem_db ]
Code
360  public function get_unit()
361  {
362      return new unit