Helix Installation   Getting Started   Reference Documentation   Global Functions   Quick Start
ModulesClassesFunctions
 

Class Reference

class product extends product_ext

Hide Inherited MembersE-Commerce
Description
No description.
 
Constants
constantTABLENAME ["com_product"][ product ]
 
Properties
protected_cdate[ product_db ]
protected_cdate_dirty[ product_db ]
protected_deleted[ product_db ]
protected_deleted_dirty[ product_db ]
protected_description[ saleitem_db ]
protected_description_dirty[ saleitem_db ]
protected_dirty[ obj ]
protected__id[ product_db ]
protected_id[ saleitem_db ]
protected__id_dirty[ product_db ]
protected_id_dirty[ saleitem_db ]
protected_mdate[ product_db ]
protected_mdate_dirty[ product_db ]
protected_model_number[ product_db ]
protected_model_number_dirty[ product_db ]
protected_name[ saleitem_db ]
protected_name_dirty[ saleitem_db ]
publicproperty_objects_array[ obj ]
protected_quantity[ product_db ]
protected_quantity_dirty[ product_db ]
protected_saleitem_id[ product_db ]
protected_saleitem_id_dirty[ product_db ]
protected_saleitem_type_id[ saleitem_db ]
protected_saleitem_type_id_dirty[ saleitem_db ]
protected_sku[ product_db ]
protected_sku_dirty[ product_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 ( )[ product_db ]
Parameters
No parameters for this method
Code
124  public function commit()
125  {
126      if ($this->_saleitem_id > 0)
127      {
128          $this->update();
129      }
130      else
131      {
132          $this->insert();
133      }
134 
135      foreach ($this->property_objects_array as $property=>$object)
136      {
137          $this->{$property} = $object;
138      }
139 
140      return true;
141  }
public__construct ( saleitem_id )[ product_db ]
Parameters
optionalsaleitem_id
Code
046  public function __construct($__saleitem_id=null)
047  {
048      $this->__id = 0;
049      $this->_saleitem_id = 0;
050      $this->_quantity = 0;
051      $this->_model_number = "";
052      $this->_sku = "";
053      $this->_mdate = null;
054      $this->_cdate = null;
055      $this->_deleted = false;
056      $this->_id = 0;
057      $this->_name = "";
058      $this->_description = "";
059      $this->_unit_price = 0;
060      $this->_unit_id = 0;
061      $this->_saleitem_type_id = 0;
062 
063      $this->__id_dirty = false;
064      $this->_saleitem_id_dirty = false;
065      $this->_quantity_dirty = false;
066      $this->_model_number_dirty = false;
067      $this->_sku_dirty = false;
068      $this->_mdate_dirty = false;
069      $this->_cdate_dirty = false;
070      $this->_deleted_dirty = false;
071      $this->_id_dirty = false;
072      $this->_name_dirty = false;
073      $this->_description_dirty = false;
074      $this->_unit_price_dirty = false;
075      $this->_unit_id_dirty = false;
076      $this->_saleitem_type_id_dirty = false;
077 
078      if (is_null($__saleitem_id))
079      {
080          return;
081      }
082 
083      $db = product::db();
084      $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_product._id,com_product.saleitem_id,com_product.quantity,com_product.model_number,com_product.sku,com_product.mdate,com_product.cdate,com_product.deleted ";
085      $q .= " FROM com_product ";
086      $q .= " INNER JOIN com_saleitem ON com_product.saleitem_id=com_saleitem.id ";
087      $q .= is_null($__saleitem_id) ? "" : " AND com_saleitem.id='$__saleitem_id' ";       
088 
089      $db->query($q);
090      if ($db->next_record() && $db->num_rows() == 1)
091      {
092          $this->_id = $db->f("id");
093          $this->_name = $db->f("name");
094          $this->_description = $db->f("description");
095          $this->_unit_price = $db->f("unit_price");
096          $this->_unit_id = $db->f("unit_id");
097          $this->_saleitem_type_id = $db->f("saleitem_type_id");
098          $this->__id = $db->f("_id");
099          $this->_saleitem_id = $db->f("saleitem_id");
100          $this->_quantity = $db->f("quantity");
101          $this->_model_number = $db->f("model_number");
102          $this->_sku = $db->f("sku");
103          $this->_mdate = $db->f("mdate");
104          $this->_cdate = $db->f("cdate");
105          $this->_deleted = $db->f("deleted");
106      }
107  }
protected staticdb ( )[ product_db ]
Parameters
No parameters for this method
Code
373  protected static function db()
374  {
375      return new db();
376  }
publicdelete ( )[ product_db ]
Parameters
No parameters for this method
Code
185  public function delete()
186  {
187      parent::delete();
188      $db = product::db();
189      $q  = " UPDATE com_product SET ";
190      $q .= " deleted = 1 ";
191      $q .= " WHERE saleitem_id = " . $this->_saleitem_id;
192      $db->query($q);
193      $this->deleted = true;
194      return true;
195  }
public staticdelete_all ( )[ product_db ]
Parameters
No parameters for this method
Code
297  public static function delete_all()
298  {
299      $db = product::db();
300      $q  = " UPDATE com_product SET ";
301      $q .= " deleted = 1 ";
302     
303      $db->query($q);
304      return true;
305  }
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] )[ product_db ]
Parameters
requiredcolumns
optionalorder
optionallookups
optionalwhere_clause
optionallimit
optionaloffset [0]
Code
219  public static function get_columns($__columns, $__order=null, $__lookups=null, $__where_clause=null, $__limit=null, $__offset=0)
220  {
221      $lookups = is_array($__lookups) ? $__lookups : array($__lookups);
222      $colarray = is_array($__columns) ? $__columns : explode(",",$__columns);
223      $colstring = is_array($__columns) ? implode(",",$__columns) : $__columns;
224 
225      $db = product::db();
226      $data = array();
227      $q  = " SELECT $colstring ";
228      $q .= " FROM com_product ";
229      $q .= " INNER JOIN com_saleitem ON com_product.saleitem_id=com_saleitem.id ";
230      $q .= array_key_exists("unit_id",$lookups) ? " AND com_saleitem.unit_id='" . $lookups["unit_id"] . "' " : "";
231      $q .= array_key_exists("saleitem_type_id",$lookups) ? " AND com_saleitem.saleitem_type_id='" . $lookups["saleitem_type_id"] . "' " : "";
232      $q .= " WHERE com_product.deleted = 0 ";
233      $q .= is_null($__where_clause) ? null : " AND ($__where_clause) ";
234 
235      if (is_string($__order))
236      {
237          $q .= "ORDER BY " . $__order;
238      }
239      else if (is_array($__order) and count($__order)>0)
240      {
241          $orderings = array();
242          foreach ($__order as $col=>$dir)
243          {
244              $orderings[] = " $col $dir ";
245          }
246          $q .= "ORDER BY " . implode(", ", $orderings);
247      }
248      else if (is_object($__order))
249      {
250          $q .= "";
251      }
252      else
253      {
254          // THERE IS NO `order` COLUMN ON THIS OBJECT
255      }
256 
257      if (!is_null($__limit))
258      {
259          $q .= " LIMIT $__offset , $__limit ";
260      }
261 
262      $db->query($q);
263 
264      if (count($colarray)>1 || $colstring=="*")
265      {
266          while ($db->next_record())
267          {
268              $data[] = $db->record;
269          }
270      }
271      else
272      {
273          while ($db->next_record())
274          {
275              $data[] = $db->f(0);
276          }
277      }
278 
279      return $data;
280  }
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] )[ product_db ]
Parameters
optionalorder
optionallookups
optionalwhere_clause
optionallimit
optionaloffset [0]
Code
282  public static function get_ids($__order=null, $__lookups=null, $__where_clause=null, $__limit=null, $__offset=0)
283  {
284      return product::get_columns("saleitem_id", $__order, $__lookups, $__where_clause, $__limit, $__offset);
285  }
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] )[ product_db ]
Parameters
optionalorder
optionallookups
optionalwhere_clause
optionallimit
optionaloffset [0]
Code
287  public static function get_objects($__order=null, $__lookups=null, $__where_clause=null, $__limit=null, $__offset=0)
288  {
289      $objects = array();
290      foreach (product::get_columns("saleitem_id", $__order, $__lookups, $__where_clause, $__limit, $__offset) as $id)
291      {
292          $objects[] = new product($id);
293      }
294      return $objects;
295  }
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 ( )[ product_db ]
Parameters
No parameters for this method
Code
361  public function get_saleitem()
362  {
363      return new saleitem($this->saleitem_id);
364  }
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 ( )[ product_db ]
Parameters
No parameters for this method
Code
143  protected function insert()
144  {
145      parent::insert();
146      $this->_saleitem_id = $this->id;
147      $db = product::db();
148      $q  = " INSERT INTO com_product ( ";
149      $q .= $db->param_string("saleitem_id") . ", ";
150      $q .= $db->param_string("quantity") . ", ";
151      $q .= $db->param_string("model_number") . ", ";
152      $q .= $db->param_string("sku") . ", ";
153      $q .= $db->param_string("mdate") . ", ";
154      $q .= $db->param_string("cdate") . ", ";
155      $q .= $db->param_string("deleted");
156      $q .= " ) VALUES ( ";
157      $q .= $db->value_string($this->_saleitem_id) . ", ";
158      $q .= $db->value_string($this->_quantity) . ", ";
159      $q .= $db->value_string($this->_model_number) . ", ";
160      $q .= $db->value_string($this->_sku) . ", ";
161      $q .= $db->value_string(timestamp()) . ", ";
162      $q .= $db->value_string(timestamp()) . ", ";
163      $q .= $this->deleted ? "'1'" : "'0'";
164      $q .= " ) ";
165      $db->query($q);
166      return true;
167  }
publicmap ( )[ product_db ]
Parameters
No parameters for this method
Code
109  public function map()
110  {
111      $this->_name = array_key_exists("product:name",$_REQUEST) ? reqval("product:name") : $this->_name;
112      $this->_description = array_key_exists("product:description",$_REQUEST) ? reqval("product:description") : $this->_description;
113      $this->_unit_price = array_key_exists("product:unit_price",$_REQUEST) ? reqval("product:unit_price") : $this->_unit_price;
114      $this->_unit_id = array_key_exists("product:unit_id",$_REQUEST) ? reqval("product:unit_id") : $this->_unit_id;
115      $this->_saleitem_type_id = array_key_exists("product:saleitem_type_id",$_REQUEST) ? reqval("product:saleitem_type_id") : $this->_saleitem_type_id;
116      $this->_quantity = array_key_exists("product:quantity",$_REQUEST) ? reqval("product:quantity") : $this->_quantity;
117      $this->_model_number = array_key_exists("product:model_number",$_REQUEST) ? reqval("product:model_number") : $this->_model_number;
118      $this->_sku = array_key_exists("product:sku",$_REQUEST) ? reqval("product:sku") : $this->_sku;
119      $this->_mdate = array_key_exists("product:mdate",$_REQUEST) ? reqval("product:mdate") : $this->_mdate;
120      $this->_cdate = array_key_exists("product:cdate",$_REQUEST) ? reqval("product:cdate") : $this->_cdate;
121      $this->_deleted = array_key_exists("product:deleted",$_REQUEST) ? reqval("product:deleted") : $this->_deleted;
122  }
publicpurge ( )[ product_db ]
Parameters
No parameters for this method
Code
209  public function purge()
210  {
211      parent::purge();
212      $db = product::db();
213      $q  = " DELETE FROM com_product ";
214      $q .= " WHERE saleitem_id = " . $this->_saleitem_id;
215      $db->query($q);
216      return true;
217  }
public staticsearch ( keyword )[ product_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 ( v )[ product_db ]
Parameters
requiredv
Code
365  public function set_saleitem($v)
366  {
367      if ($v->id > 0)
368      {
369          $this->saleitem_id = $v->id;
370      }
371  }
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 ( )[ product_db ]
Parameters
No parameters for this method
Code
356  public function __toString()
357  {
358      return (is_null($this->id) ? "" : $this->id);
359  }
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 ( )[ product_db ]
Parameters
No parameters for this method
Code
197  public function undelete()
198  {
199      parent::undelete();
200      $db = product::db();
201      $q  = " UPDATE com_product SET ";
202      $q .= " deleted = 0 ";
203      $q .= " WHERE saleitem_id = " . $this->_saleitem_id;
204      $db->query($q);
205      $this->deleted = false;
206      return true;
207  }
protectedupdate ( )[ product_db ]
Parameters
No parameters for this method
Code
169  protected function update()
170  {
171      parent::update();
172      $db = product::db();
173      $q  = " UPDATE com_product SET ";
174      $q .= $db->param_string("saleitem_id") . " = " . $db->value_string($this->_saleitem_id) . ", ";
175      $q .= $db->param_string("quantity") . " = " . $db->value_string($this->_quantity) . ", ";
176      $q .= $db->param_string("model_number") . " = " . $db->value_string($this->_model_number) . ", ";
177      $q .= $db->param_string("sku") . " = " . $db->value_string($this->_sku) . ", ";
178      $q .= $db->param_string("mdate") . " = " . $db->value_string(timestamp()) . ", ";
179      $q .= $db->param_string("deleted") . " = " . ($this->deleted ? "'1'" : "'0'");
180      $q .= " WHERE saleitem_id = " . $this->_saleitem_id;
181      $db->query($q);
182      return true;
183  }
 
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[ product_db ]
Code
219  public static function get_columns($__columns, $__order=null, $__lookups=null, $__where_clause=null, $__limit=null, $__offset=0)
220  {
221      $lookups = is_array($__lookups) ? $__lookups : array($__lookups);
222      $colarray = is_array($__columns) ? $__columns : explode(",",$__columns);
223      $colstring = is_array($__columns) ? implode(",",$__columns) : $__columns;
224 
225      $db = product::db();
226      $data = array();
227      $q  = " SELECT $colstring ";
228      $q .= " FROM com_product ";
229      $q .= " INNER JOIN com_saleitem ON com_product.saleitem_id=com_saleitem.id ";
230      $q .= array_key_exists("unit_id",$lookups) ? " AND com_saleitem.unit_id='" . $lookups["unit_id"] . "' " : "";
231      $q .= array_key_exists("saleitem_type_id",$lookups) ? " AND com_saleitem.saleitem_type_id='" . $lookups["saleitem_type_id"] . "' " : "";
232      $q .= " WHERE com_product.deleted = 0 ";
233      $q .= is_null($__where_clause) ? null : " AND ($__where_clause) ";
234 
235      if (is_string($__order))
236      {
237          $q .= "ORDER BY " . $__order;
238      }
239      else if (is_array($__order) and count($__order)>0)
240      {
241          $orderings = array();
242          foreach ($__order as $col=>$dir)
243          {
244              $orderings[] = " $col $dir ";
245          }
246          $q .= "ORDER BY " . implode(", ", $orderings);
247      }
248      else if (is_object($__order))
249      {
250          $q .= "";
251      }
252      else
253      {
254          // THERE IS NO `order` COLUMN ON THIS OBJECT
255      }
256 
257      if (!is_null($__limit))
258      {
259          $q .= " LIMIT $__offset , $__limit ";
260      }
261 
262      $db->query($q);
263 
264      if (count($colarray)>1 || $colstring=="*")
265      {
266          while ($db->next_record())
267          {
268              $data[] = $db->record;
269          }
270      }
271      else
272      {
273          while ($db->next_record())
274          {
275              $data[] = $db->f(0);
276          }
277      }
278 
279      return $data;
280  }
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[ product_db ]
Code
282  public static function get_ids($__order=null, $__lookups=null, $__where_clause=null, $__limit=null, $__offset=0)
283  {
284      return product::get_columns("saleitem_id", $__order, $__lookups, $__where_clause, $__limit, $__offset);
285  }
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[ product_db ]
Code
287  public static function get_objects($__order=null, $__lookups=null, $__where_clause=null, $__limit=null, $__offset=0)
288  {
289      $objects = array();
290      foreach (product::get_columns("saleitem_id", $__order, $__lookups, $__where_clause, $__limit, $__offset) as $id)
291      {
292          $objects[] = new product($id);
293      }
294      return $objects;
295  }
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[ product_db ]
Code
361  public function get_saleitem()
362  {
363      return new saleitem($this->saleitem_id);
364  }
Code
365  public function set_saleitem($v)
366  {
367      if ($v->id > 0)
368      {
369          $this->saleitem_id = $v->id;
370      }
371  }
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