Helix Installation   Getting Started   Reference Documentation   Global Functions   Quick Start
ModulesClassesFunctions
 

Class Reference

class tax extends tax_ext

Hide Inherited MembersE-Commerce
Description
No description.
 
Constants
constantTABLENAME ["com_tax"][ tax ]
 
Properties
protected_cdate[ tax_db ]
protected_cdate_dirty[ tax_db ]
protected_deleted[ tax_db ]
protected_deleted_dirty[ tax_db ]
protected_dirty[ obj ]
protected_id[ tax_db ]
protected_id_dirty[ tax_db ]
protected_mdate[ tax_db ]
protected_mdate_dirty[ tax_db ]
publicproperty_objects_array[ obj ]
protected_rate[ tax_db ]
protected_rate_dirty[ tax_db ]
protected_tax_type_id[ tax_db ]
protected_tax_type_id_dirty[ tax_db ]
 
Methods
publiccommit ( )[ tax_db ]
Parameters
No parameters for this method
Code
092  public function commit()
093  {
094      if ($this->_id > 0)
095      {
096          $this->update();
097      }
098      else
099      {
100          $this->insert();
101      }
102 
103      foreach ($this->property_objects_array as $property=>$object)
104      {
105          $this->{$property} = $object;
106      }
107 
108      return true;
109  }
public__construct ( id )[ tax_db ]
Parameters
optionalid
Code
042  public function __construct($__id=null)
043  {
044      $this->_id = 0;
045      $this->_rate = 0;
046      $this->_tax_type_id = 0;
047      $this->_mdate = null;
048      $this->_cdate = null;
049      $this->_deleted = false;
050 
051      $this->_id_dirty = false;
052      $this->_rate_dirty = false;
053      $this->_tax_type_id_dirty = false;
054      $this->_mdate_dirty = false;
055      $this->_cdate_dirty = false;
056      $this->_deleted_dirty = false;
057 
058      if (is_null($__id))
059      {
060          return;
061      }
062 
063      $db = tax::db();
064      $q  = " SELECT com_tax.id,com_tax.rate,com_tax.tax_type_id,com_tax.mdate,com_tax.cdate,com_tax.deleted ";
065      $q .= " FROM com_tax ";       
066      if (!is_null($__id))
067      {
068          $q .= " WHERE id = '$__id' ";
069      }
070 
071      $db->query($q);
072      if ($db->next_record() && $db->num_rows() == 1)
073      {
074          $this->_id = $db->f("id");
075          $this->_rate = $db->f("rate");
076          $this->_tax_type_id = $db->f("tax_type_id");
077          $this->_mdate = $db->f("mdate");
078          $this->_cdate = $db->f("cdate");
079          $this->_deleted = $db->f("deleted");
080      }
081  }
protected staticdb ( )[ tax_db ]
Parameters
No parameters for this method
Code
443  protected static function db()
444  {
445      return new db();
446  }
publicdelete ( )[ tax_db ]
Parameters
No parameters for this method
Code
145  public function delete()
146  {
147      $db = tax::db();
148      $q  = " UPDATE com_tax SET ";
149      $q .= " deleted = 1 ";
150      $q .= " WHERE id = " . $this->_id;
151      $db->query($q);
152      $this->deleted = true;
153      return true;
154  }
public staticdelete_all ( )[ tax_db ]
Parameters
No parameters for this method
Code
252  public static function delete_all()
253  {
254      $db = tax::db();
255      $q  = " UPDATE com_tax SET ";
256      $q .= " deleted = 1 ";
257     
258      $db->query($q);
259      return true;
260  }
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_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] )[ tax_db ]
Parameters
requiredcolumns
optionalorder
optionallookups
optionalwhere_clause
optionallimit
optionaloffset [0]
Code
176  public static function get_columns($__columns, $__order=null, $__lookups=null, $__where_clause=null, $__limit=null, $__offset=0)
177  {
178      $lookups = is_array($__lookups) ? $__lookups : array($__lookups);
179      $colarray = is_array($__columns) ? $__columns : explode(",",$__columns);
180      $colstring = is_array($__columns) ? implode(",",$__columns) : $__columns;
181 
182      $db = tax::db();
183      $data = array();
184      $q  = " SELECT $colstring ";
185      $q .= " FROM com_tax ";
186      $q .= " WHERE com_tax.deleted = 0 ";
187      $q .= is_null($__where_clause) ? null : " AND ($__where_clause) ";
188      $q .= array_key_exists("tax_type_id",$lookups) ? " AND com_tax.tax_type_id='" . $lookups["tax_type_id"] . "' " : "";
189 
190      if (is_string($__order))
191      {
192          $q .= "ORDER BY " . $__order;
193      }
194      else if (is_array($__order) and count($__order)>0)
195      {
196          $orderings = array();
197          foreach ($__order as $col=>$dir)
198          {
199              $orderings[] = " $col $dir ";
200          }
201          $q .= "ORDER BY " . implode(", ", $orderings);
202      }
203      else if (is_object($__order))
204      {
205          $q .= "";
206      }
207      else
208      {
209          // THERE IS NO `order` COLUMN ON THIS OBJECT
210      }
211 
212      if (!is_null($__limit))
213      {
214          $q .= " LIMIT $__offset , $__limit ";
215      }
216 
217      $db->query($q);
218 
219      if (count($colarray)>1 || $colstring=="*")
220      {
221          while ($db->next_record())
222          {
223              $data[] = $db->record;
224          }
225      }
226      else
227      {
228          while ($db->next_record())
229          {
230              $data[] = $db->f(0);
231          }
232      }
233 
234      return $data;
235  }
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] )[ tax_db ]
Parameters
optionalorder
optionallookups
optionalwhere_clause
optionallimit
optionaloffset [0]
Code
237  public static function get_ids($__order=null, $__lookups=null, $__where_clause=null, $__limit=null, $__offset=0)
238  {
239      return tax::get_columns("id", $__order, $__lookups, $__where_clause, $__limit, $__offset);
240  }
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] )[ tax_db ]
Parameters
optionalorder
optionallookups
optionalwhere_clause
optionallimit
optionaloffset [0]
Code
242  public static function get_objects($__order=null, $__lookups=null, $__where_clause=null, $__limit=null, $__offset=0)
243  {
244      $objects = array();
245      foreach (tax::get_columns("id", $__order, $__lookups, $__where_clause, $__limit, $__offset) as $id)
246      {
247          $objects[] = new tax($id);
248      }
249      return $objects;
250  }
publicget_properties ( )[ obj ]
Parameters
No parameters for this method
Code
121  public function get_properties()
122  {
123      return array_keys($this->array);
124  }
publicget_saleitem ( type ["default"] )[ tax_db ]
Parameters
optionaltype ["default"]
Code
344  public function get_saleitem($__type="default")
345  {
346      $object = is_null(keyval($this->property_objects_array,"{$__type}_saleitem")) ? new saleitem($this->get_saleitem_id($__type)) : $this->property_objects_array["{$__type}_saleitem"];
347      $this->property_objects_array["{$__type}_saleitem"] = $object;
348      return $object;
349  }
publicget_saleitem_id ( type ["default"] )[ tax_db ]
Parameters
optionaltype ["default"]
Code
350  public function get_saleitem_id($__type="default")
351  {
352      $ids = $this->get_saleitem_ids($__type, true);
353      return (count($ids)==1 ? $ids[0] : null);
354  }
publicget_saleitem_ids ( type , order , where_clause , limit , offset [0] , get_primary [false] )[ tax_db ]
Parameters
optionaltype
optionalorder
optionalwhere_clause
optionallimit
optionaloffset [0]
optionalget_primary [false]
Code
355  public function get_saleitem_ids($__type=null, $__order=null, $__where_clause=null, $__limit=null, $__offset=0, $__get_primary=false)
356  {
357      $saleitem_ids = array();
358      $db = tax::db();
359      $q  = " SELECT com_saleitem.id FROM com_saleitem_tax INNER JOIN com_saleitem ON com_saleitem_tax.saleitem_id=com_saleitem.id AND com_saleitem_tax.deleted=0 AND com_saleitem.deleted=0 AND com_saleitem_tax.tax_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 " : "");
360      $q .= is_null($__where_clause) ? "" : " WHERE {$__where_clause}";
361      $q .= is_null($__order) ? "" : " ORDER BY {$__order}";
362      $q .= is_null($__limit) ? "" : " LIMIT {$__offset}, {$__limit}";
363      $db->query($q);
364      while ($db->next_record())
365      {
366          $saleitem_ids[] = $db->f("id");
367      }
368      return $saleitem_ids;
369  }
publicget_saleitem_list ( type , order , where_clause , limit , offset [0] , get_primary [false] )[ tax_db ]
Parameters
optionaltype
optionalorder
optionalwhere_clause
optionallimit
optionaloffset [0]
optionalget_primary [false]
Code
370  public function get_saleitem_list($__type=null, $__order=null, $__where_clause=null, $__limit=null, $__offset=0, $__get_primary=false)
371  {
372      $ids = $this->get_saleitem_ids($__type, $__order, $__where_clause, $__limit, $__offset, $__get_primary);
373      $objects = array();
374      foreach ($ids as $index=>$id)
375      {
376          $objects[$index] = new saleitem($id);
377      }
378      return $objects;
379  }
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 ( )[ tax_db ]
Parameters
No parameters for this method
Code
332  public function get_tax_type()
333  {
334      return new tax_type($this->tax_type_id);
335  }
publicget_type ( )[ tax_db ]
Parameters
No parameters for this method
Code
321  public function get_type()
322  {
323      $type = new tax_type($this->_tax_type_id);
324      return $type->name;
325  }
protectedinsert ( )[ tax_db ]
Parameters
No parameters for this method
Code
111  protected function insert()
112  {
113      $db = tax::db();
114      $q  = " INSERT INTO com_tax ( ";
115      $q .= $db->param_string("rate") . ", ";
116      $q .= $db->param_string("tax_type_id") . ", ";
117      $q .= $db->param_string("mdate") . ", ";
118      $q .= $db->param_string("cdate") . ", ";
119      $q .= $db->param_string("deleted");
120      $q .= " ) VALUES ( ";
121      $q .= $db->value_string($this->_rate) . ", ";
122      $q .= $db->value_string($this->_tax_type_id) . ", ";
123      $q .= $db->value_string(timestamp()) . ", ";
124      $q .= $db->value_string(timestamp()) . ", ";
125      $q .= $this->deleted ? "'1'" : "'0'";
126      $q .= " ) ";
127      $db->query($q);
128      $this->_id = $db->insert_id;
129      return true;
130  }
publicmap ( )[ tax_db ]
Parameters
No parameters for this method
Code
083  public function map()
084  {
085      $this->_rate = array_key_exists("tax:rate",$_REQUEST) ? reqval("tax:rate") : $this->_rate;
086      $this->_tax_type_id = array_key_exists("tax:tax_type_id",$_REQUEST) ? reqval("tax:tax_type_id") : $this->_tax_type_id;
087      $this->_mdate = array_key_exists("tax:mdate",$_REQUEST) ? reqval("tax:mdate") : $this->_mdate;
088      $this->_cdate = array_key_exists("tax:cdate",$_REQUEST) ? reqval("tax:cdate") : $this->_cdate;
089      $this->_deleted = array_key_exists("tax:deleted",$_REQUEST) ? reqval("tax:deleted") : $this->_deleted;
090  }
publicpurge ( )[ tax_db ]
Parameters
No parameters for this method
Code
167  public function purge()
168  {
169      $db = tax::db();
170      $q  = " DELETE FROM com_tax ";
171      $q .= " WHERE id = " . $this->_id;
172      $db->query($q);
173      return true;
174  }
public staticsearch ( keyword )[ tax_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_saleitem ( v , type ["default"] )[ tax_db ]
Parameters
requiredv
optionaltype ["default"]
Code
381  public function set_saleitem($__v, $__type="default")
382  {
383      $object = is_null(keyval($this->property_objects_array,"{$__type}_saleitem")) ? new saleitem($this->get_saleitem_id($__type)) : $this->property_objects_array["{$__type}_saleitem"];
384      if (is_null($__v))
385      {
386          $rel = new saleitem_tax(null,$object->id,$this->id,saleitem_tax::type_id($__type));
387          $rel->delete();
388          if (!is_null(keyval($this->property_objects_array,"{$__type}_saleitem")))
389          {
390              $this->property_objects_array["{$__type}_saleitem"] = null;
391          }
392      }
393      else
394      {
395          $id = $object->id;
396          $object = $__v;
397          $object->id = $__v->id>0 ? $__v->id : $id;
398          $object->commit();
399          $this->set_saleitem_ids(array($object->id),$__type);
400      }
401  }
publicset_saleitem_id ( v , type ["default"] )[ tax_db ]
Parameters
requiredv
optionaltype ["default"]
Code
402  public function set_saleitem_id($__v, $__type="default")
403  {
404      $this->set_saleitem_ids(array($__v),$__type);
405  }
publicset_saleitem_ids ( v , type ["default"] )[ tax_db ]
Parameters
requiredv
optionaltype ["default"]
Code
406  public function set_saleitem_ids($__v, $__type="default")
407  {
408      if ($this->id == 0)
409      {
410          $this->commit();
411      }
412      $type_id = saleitem_tax::type_id($__type);
413      saleitem_tax::delete_all(null,$this->id,$type_id);
414      if (is_array($__v))
415      {
416          foreach ($__v as $index=>$id)
417          {
418              $object = new saleitem_tax(null,$id,$this->id,$type_id);
419              $object->deleted = false;
420              $object->saleitem_tax_type_id = $type_id;
421              $object->commit();
422              if (count($__v)==1 && !is_null(keyval($this->property_objects_array,"{$__type}_saleitem")))
423              {
424                  $this->property_objects_array["{$__type}_saleitem"] = new saleitem($object->saleitem_id);
425              }
426          }
427          $this->_dirty = true;
428      }
429  }
publicset_saleitem_list ( v , type ["default"] )[ tax_db ]
Parameters
requiredv
optionaltype ["default"]
Code
430  public function set_saleitem_list($__v, $__type="default")
431  {
432      if (is_array($__v))
433      {
434          $ids = array();
435          foreach ($__v as $index=>$object)
436          {
437              $ids[] = $object->id;
438          }
439          $this->set_saleitem_ids($ids,$__type);
440      }
441  }
publicset_tax_type ( v )[ tax_db ]
Parameters
requiredv
Code
336  public function set_tax_type($v)
337  {
338      if ($v->id > 0)
339      {
340          $this->tax_type_id = $v->id;
341      }
342  }
publicset_type ( v )[ tax_db ]
Parameters
requiredv
Code
326  public function set_type($v)
327  {
328      $type = new tax_type(null, $v);
329      $this->tax_type_id = $type->id;
330  }
public__toString ( )[ tax_db ]
Parameters
No parameters for this method
Code
310  public function __toString()
311  {
312      return (is_null($this->id) ? "" : $this->id);
313  }
public statictype_id ( type_name )[ tax_db ]
Parameters
requiredtype_name
Code
315  public static function type_id($__type_name)
316  {
317      $type = new tax_type(null, $__type_name);
318      return $type->id;
319  }
publicundelete ( )[ tax_db ]
Parameters
No parameters for this method
Code
156  public function undelete()
157  {
158      $db = tax::db();
159      $q  = " UPDATE com_tax SET ";
160      $q .= " deleted = 0 ";
161      $q .= " WHERE id = " . $this->_id;
162      $db->query($q);
163      $this->deleted = false;
164      return true;
165  }
protectedupdate ( )[ tax_db ]
Parameters
No parameters for this method
Code
132  protected function update()
133  {
134      $db = tax::db();
135      $q  = " UPDATE com_tax SET ";
136      $q .= $db->param_string("rate") . " = " . $db->value_string($this->_rate) . ", ";
137      $q .= $db->param_string("tax_type_id") . " = " . $db->value_string($this->_tax_type_id) . ", ";
138      $q .= $db->param_string("mdate") . " = " . $db->value_string(timestamp()) . ", ";
139      $q .= $db->param_string("deleted") . " = " . ($this->deleted ? "'1'" : "'0'");
140      $q .= " WHERE id = " . $this->_id;
141      $db->query($q);
142      return true;
143  }
 
Accessors
publicarray[ obj ]
Code
096  public function get_array()
097  {
098      return get_object_vars($this);
099  }
publicclassname[ obj ]
Code
086  public function get_classname()
087  {
088      return get_class($this);
089  }
publiccolumns[ tax_db ]
Code
176  public static function get_columns($__columns, $__order=null, $__lookups=null, $__where_clause=null, $__limit=null, $__offset=0)
177  {
178      $lookups = is_array($__lookups) ? $__lookups : array($__lookups);
179      $colarray = is_array($__columns) ? $__columns : explode(",",$__columns);
180      $colstring = is_array($__columns) ? implode(",",$__columns) : $__columns;
181 
182      $db = tax::db();
183      $data = array();
184      $q  = " SELECT $colstring ";
185      $q .= " FROM com_tax ";
186      $q .= " WHERE com_tax.deleted = 0 ";
187      $q .= is_null($__where_clause) ? null : " AND ($__where_clause) ";
188      $q .= array_key_exists("tax_type_id",$lookups) ? " AND com_tax.tax_type_id='" . $lookups["tax_type_id"] . "' " : "";
189 
190      if (is_string($__order))
191      {
192          $q .= "ORDER BY " . $__order;
193      }
194      else if (is_array($__order) and count($__order)>0)
195      {
196          $orderings = array();
197          foreach ($__order as $col=>$dir)
198          {
199              $orderings[] = " $col $dir ";
200          }
201          $q .= "ORDER BY " . implode(", ", $orderings);
202      }
203      else if (is_object($__order))
204      {
205          $q .= "";
206      }
207      else
208      {
209          // THERE IS NO `order` COLUMN ON THIS OBJECT
210      }
211 
212      if (!is_null($__limit))
213      {
214          $q .= " LIMIT $__offset , $__limit ";
215      }
216 
217      $db->query($q);
218 
219      if (count($colarray)>1 || $colstring=="*")
220      {
221          while ($db->next_record())
222          {
223              $data[] = $db->record;
224          }
225      }
226      else
227      {
228          while ($db->next_record())
229          {
230              $data[] = $db->f(0);
231          }
232      }
233 
234      return $data;
235  }
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[ tax_db ]
Code
237  public static function get_ids($__order=null, $__lookups=null, $__where_clause=null, $__limit=null, $__offset=0)
238  {
239      return tax::get_columns("id", $__order, $__lookups, $__where_clause, $__limit, $__offset);
240  }
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[ tax_db ]
Code
242  public static function get_objects($__order=null, $__lookups=null, $__where_clause=null, $__limit=null, $__offset=0)
243  {
244      $objects = array();
245      foreach (tax::get_columns("id", $__order, $__lookups, $__where_clause, $__limit, $__offset) as $id)
246      {
247          $objects[] = new tax($id);
248      }
249      return $objects;
250  }
publicproperties[ obj ]
Code
121  public function get_properties()
122  {
123      return array_keys($this->array);
124  }
publicsaleitem[ tax_db ]
Code
344  public function get_saleitem($__type="default")
345  {
346      $object = is_null(keyval($this->property_objects_array,"{$__type}_saleitem")) ? new saleitem($this->get_saleitem_id($__type)) : $this->property_objects_array["{$__type}_saleitem"];
347      $this->property_objects_array["{$__type}_saleitem"] = $object;
348      return $object;
349  }
Code
381  public function set_saleitem($__v, $__type="default")
382  {
383      $object = is_null(keyval($this->property_objects_array,"{$__type}_saleitem")) ? new saleitem($this->get_saleitem_id($__type)) : $this->property_objects_array["{$__type}_saleitem"];
384      if (is_null($__v))
385      {
386          $rel = new saleitem_tax(null,$object->id,$this->id,saleitem_tax::type_id($__type));
387          $rel->delete();
388          if (!is_null(keyval($this->property_objects_array,"{$__type}_saleitem")))
389          {
390              $this->property_objects_array["{$__type}_saleitem"] = null;
391          }
392      }
393      else
394      {
395          $id = $object->id;
396          $object = $__v;
397          $object->id = $__v->id>0 ? $__v->id : $id;
398          $object->commit();
399          $this->set_saleitem_ids(array($object->id),$__type);
400      }
401  }
publicsaleitem_id[ tax_db ]
Code
350  public function get_saleitem_id($__type="default")
351  {
352      $ids = $this->get_saleitem_ids($__type, true);
353      return (count($ids)==1 ? $ids[0] : null);
354  }
Code
402  public function set_saleitem_id($__v, $__type="default")
403  {
404      $this->set_saleitem_ids(array($__v),$__type);
405  }
publicsaleitem_ids[ tax_db ]
Code
355  public function get_saleitem_ids($__type=null, $__order=null, $__where_clause=null, $__limit=null, $__offset=0, $__get_primary=false)
356  {
357      $saleitem_ids = array();
358      $db = tax::db();
359      $q  = " SELECT com_saleitem.id FROM com_saleitem_tax INNER JOIN com_saleitem ON com_saleitem_tax.saleitem_id=com_saleitem.id AND com_saleitem_tax.deleted=0 AND com_saleitem.deleted=0 AND com_saleitem_tax.tax_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 " : "");
360      $q .= is_null($__where_clause) ? "" : " WHERE {$__where_clause}";
361      $q .= is_null($__order) ? "" : " ORDER BY {$__order}";
362      $q .= is_null($__limit) ? "" : " LIMIT {$__offset}, {$__limit}";
363      $db->query($q);
364      while ($db->next_record())
365      {
366          $saleitem_ids[] = $db->f("id");
367      }
368      return $saleitem_ids;
369  }
Code
406  public function set_saleitem_ids($__v, $__type="default")
407  {
408      if ($this->id == 0)
409      {
410          $this->commit();
411      }
412      $type_id = saleitem_tax::type_id($__type);
413      saleitem_tax::delete_all(null,$this->id,$type_id);
414      if (is_array($__v))
415      {
416          foreach ($__v as $index=>$id)
417          {
418              $object = new saleitem_tax(null,$id,$this->id,$type_id);
419              $object->deleted = false;
420              $object->saleitem_tax_type_id = $type_id;
421              $object->commit();
422              if (count($__v)==1 && !is_null(keyval($this->property_objects_array,"{$__type}_saleitem")))
423              {
424                  $this->property_objects_array["{$__type}_saleitem"] = new saleitem($object->saleitem_id);
425              }
426          }
427          $this->_dirty = true;
428      }
429  }
publicsaleitem_list[ tax_db ]
Code
370  public function get_saleitem_list($__type=null, $__order=null, $__where_clause=null, $__limit=null, $__offset=0, $__get_primary=false)
371  {
372      $ids = $this->get_saleitem_ids($__type, $__order, $__where_clause, $__limit, $__offset, $__get_primary);
373      $objects = array();
374      foreach ($ids as $index=>$id)
375      {
376          $objects[$index] = new saleitem($id);
377      }
378      return $objects;
379  }
Code
430  public function set_saleitem_list($__v, $__type="default")
431  {
432      if (is_array($__v))
433      {
434          $ids = array();
435          foreach ($__v as $index=>$object)
436          {
437              $ids[] = $object->id;
438          }
439          $this->set_saleitem_ids($ids,$__type);
440      }
441  }
publicstring[ obj ]
Code
091  protected function get_string()
092  {
093      return method_exists($this,"__toString") ? $this->__toString() : null;
094  }
publictax_type[ tax_db ]
Code
332  public function get_tax_type()
333  {
334      return new tax_type($this->tax_type_id);
335  }
Code
336  public function set_tax_type($v)
337  {
338      if ($v->id > 0)
339      {
340          $this->tax_type_id = $v->id;
341      }
342  }
publictype[ tax_db ]
Code
321  public function get_type()
322  {
323      $type = new tax_type($this->_tax_type_id);
324      return $type->name;
325  }
Code
326  public function set_type($v)
327  {
328      $type = new tax_type(null, $v);
329      $this->tax_type_id = $type->id;
330  }
Get Helix PHP Framework at SourceForge.net. Fast, secure and Free Open Source software downloads