Helix Installation   Getting Started   Reference Documentation   Global Functions   Quick Start
ModulesClassesFunctions
 

Class Reference

class contract extends contract_ext

Hide Inherited MembersContracts Management
Description
No description.
 
Constants
constantTABLENAME ["cont_contract"][ contract ]
 
Properties
protected_cdate[ contract_db ]
protected_cdate_dirty[ contract_db ]
protected_code[ contract_db ]
protected_code_dirty[ contract_db ]
protected_contractstatus_id[ contract_db ]
protected_contractstatus_id_dirty[ contract_db ]
protected_deleted[ contract_db ]
protected_deleted_dirty[ contract_db ]
protected_description[ contract_db ]
protected_description_dirty[ contract_db ]
protected_dirty[ obj ]
protected_id[ contract_db ]
protected_id_dirty[ contract_db ]
protected_mdate[ contract_db ]
protected_mdate_dirty[ contract_db ]
protected_name[ contract_db ]
protected_name_dirty[ contract_db ]
publicproperty_objects_array[ obj ]
protected_type_id[ contract_db ]
protected_type_id_dirty[ contract_db ]
 
Methods
publiccommit ( )[ contract_db ]
Parameters
No parameters for this method
Code
118  public function commit()
119  {
120      if ($this->_id > 0)
121      {
122          $this->update();
123      }
124      else
125      {
126          $this->insert();
127      }
128 
129      foreach ($this->property_objects_array as $property=>$object)
130      {
131          $this->{$property} = $object;
132      }
133 
134      return true;
135  }
public__construct ( id , name , code )[ contract_db ]
Parameters
optionalid
optionalname
optionalcode
Code
048  public function __construct($__id=null, $__name=null, $__code=null)
049  {
050      $this->_id = 0;
051      $this->_name = $__name;
052      $this->_code = $__code;
053      $this->_description = "";
054      $this->_contractstatus_id = 0;
055      $this->_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->_code_dirty = false;
063      $this->_description_dirty = false;
064      $this->_contractstatus_id_dirty = false;
065      $this->_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) && is_null($__name) && is_null($__code))
071      {
072          return;
073      }
074 
075      $db = contract::db();
076      $q  = " SELECT cont_contract.id,cont_contract.name,cont_contract.code,cont_contract.description,cont_contract.contractstatus_id,cont_contract.type_id,cont_contract.mdate,cont_contract.cdate,cont_contract.deleted ";
077      $q .= " FROM cont_contract ";       
078      if (!is_null($__id))
079      {
080          $q .= " WHERE id = '$__id' ";
081      }
082      else if (!is_null($__name))
083      {
084          $q .= " WHERE name = '$__name' ";
085      }
086      else if (!is_null($__code))
087      {
088          $q .= " WHERE code = '$__code' ";
089      }
090 
091      $db->query($q);
092      if ($db->next_record() && $db->num_rows() == 1)
093      {
094          $this->_id = $db->f("id");
095          $this->_name = $db->f("name");
096          $this->_code = $db->f("code");
097          $this->_description = $db->f("description");
098          $this->_contractstatus_id = $db->f("contractstatus_id");
099          $this->_type_id = $db->f("type_id");
100          $this->_mdate = $db->f("mdate");
101          $this->_cdate = $db->f("cdate");
102          $this->_deleted = $db->f("deleted");
103      }
104  }
protected staticdb ( )[ contract_db ]
Parameters
No parameters for this method
Code
573  protected static function db()
574  {
575      return new db();
576  }
publicdelete ( )[ contract_db ]
Parameters
No parameters for this method
Code
180  public function delete()
181  {
182      $db = contract::db();
183      $q  = " UPDATE cont_contract SET ";
184      $q .= " deleted = 1 ";
185      $q .= " WHERE id = " . $this->_id;
186      $db->query($q);
187      $this->deleted = true;
188      return true;
189  }
public staticdelete_all ( )[ contract_db ]
Parameters
No parameters for this method
Code
288  public static function delete_all()
289  {
290      $db = contract::db();
291      $q  = " UPDATE cont_contract SET ";
292      $q .= " deleted = 1 ";
293     
294      $db->query($q);
295      return true;
296  }
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] )[ contract_db ]
Parameters
requiredcolumns
optionalorder
optionallookups
optionalwhere_clause
optionallimit
optionaloffset [0]
Code
211  public static function get_columns($__columns, $__order=null, $__lookups=null, $__where_clause=null, $__limit=null, $__offset=0)
212  {
213      $lookups = is_array($__lookups) ? $__lookups : array($__lookups);
214      $colarray = is_array($__columns) ? $__columns : explode(",",$__columns);
215      $colstring = is_array($__columns) ? implode(",",$__columns) : $__columns;
216 
217      $db = contract::db();
218      $data = array();
219      $q  = " SELECT $colstring ";
220      $q .= " FROM cont_contract ";
221      $q .= " WHERE cont_contract.deleted = 0 ";
222      $q .= is_null($__where_clause) ? null : " AND ($__where_clause) ";
223      $q .= array_key_exists("contractstatus_id",$lookups) ? " AND cont_contract.contractstatus_id='" . $lookups["contractstatus_id"] . "' " : "";
224      $q .= array_key_exists("type_id",$lookups) ? " AND cont_contract.type_id='" . $lookups["type_id"] . "' " : "";
225 
226      if (is_string($__order))
227      {
228          $q .= "ORDER BY " . $__order;
229      }
230      else if (is_array($__order) and count($__order)>0)
231      {
232          $orderings = array();
233          foreach ($__order as $col=>$dir)
234          {
235              $orderings[] = " $col $dir ";
236          }
237          $q .= "ORDER BY " . implode(", ", $orderings);
238      }
239      else if (is_object($__order))
240      {
241          $q .= "";
242      }
243      else
244      {
245          // THERE IS NO `order` COLUMN ON THIS OBJECT
246      }
247 
248      if (!is_null($__limit))
249      {
250          $q .= " LIMIT $__offset , $__limit ";
251      }
252 
253      $db->query($q);
254 
255      if (count($colarray)>1 || $colstring=="*")
256      {
257          while ($db->next_record())
258          {
259              $data[] = $db->record;
260          }
261      }
262      else
263      {
264          while ($db->next_record())
265          {
266              $data[] = $db->f(0);
267          }
268      }
269 
270      return $data;
271  }
publicget_contract_type ( )[ contract_db ]
Parameters
No parameters for this method
Code
363  public function get_contract_type()
364  {
365      return new contract_type($this->contract_type_id);
366  }
publicget_contractstatus ( )[ contract_db ]
Parameters
No parameters for this method
Code
351  public function get_contractstatus()
352  {
353      return new contractstatus($this->contractstatus_id);
354  }
publicget_contractvalue ( type ["default"] )[ contract_db ]
Parameters
optionaltype ["default"]
Code
375  public function get_contractvalue($__type="default")
376  {
377      $object = is_null(keyval($this->property_objects_array,"{$__type}_contractvalue")) ? new contractvalue($this->get_contractvalue_id($__type)) : $this->property_objects_array["{$__type}_contractvalue"];
378      $this->property_objects_array["{$__type}_contractvalue"] = $object;
379      return $object;
380  }
publicget_contractvalue_id ( type ["default"] )[ contract_db ]
Parameters
optionaltype ["default"]
Code
381  public function get_contractvalue_id($__type="default")
382  {
383      $ids = $this->get_contractvalue_ids($__type, true);
384      return (count($ids)==1 ? $ids[0] : null);
385  }
publicget_contractvalue_ids ( type , order , where_clause , limit , offset [0] , get_primary [false] )[ contract_db ]
Parameters
optionaltype
optionalorder
optionalwhere_clause
optionallimit
optionaloffset [0]
optionalget_primary [false]
Code
386  public function get_contractvalue_ids($__type=null, $__order=null, $__where_clause=null, $__limit=null, $__offset=0, $__get_primary=false)
387  {
388      $contractvalue_ids = array();
389      $db = contract::db();
390      $q  = " SELECT cont_contractvalue.id FROM cont_contract_contractvalue INNER JOIN cont_contractvalue ON cont_contract_contractvalue.contractvalue_id=cont_contractvalue.id AND cont_contract_contractvalue.deleted=0 AND cont_contractvalue.deleted=0 AND cont_contract_contractvalue.contract_id='$this->id' " . (is_null($__type) ? "" : " AND cont_contract_contractvalue.contract_contractvalue_type_id='" . contract_contractvalue::type_id($__type) . "'") . ($__get_primary ? " AND cont_contract_contractvalue.primary=1 " : "");
391      $q .= is_null($__where_clause) ? "" : " WHERE {$__where_clause}";
392      $q .= is_null($__order) ? "" : " ORDER BY {$__order}";
393      $q .= is_null($__limit) ? "" : " LIMIT {$__offset}, {$__limit}";
394      $db->query($q);
395      while ($db->next_record())
396      {
397          $contractvalue_ids[] = $db->f("id");
398      }
399      return $contractvalue_ids;
400  }
publicget_contractvalue_list ( type , order , where_clause , limit , offset [0] , get_primary [false] )[ contract_db ]
Parameters
optionaltype
optionalorder
optionalwhere_clause
optionallimit
optionaloffset [0]
optionalget_primary [false]
Code
401  public function get_contractvalue_list($__type=null, $__order=null, $__where_clause=null, $__limit=null, $__offset=0, $__get_primary=false)
402  {
403      $ids = $this->get_contractvalue_ids($__type, $__order, $__where_clause, $__limit, $__offset, $__get_primary);
404      $objects = array();
405      foreach ($ids as $index=>$id)
406      {
407          $objects[$index] = new contractvalue($id);
408      }
409      return $objects;
410  }
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] )[ contract_db ]
Parameters
optionalorder
optionallookups
optionalwhere_clause
optionallimit
optionaloffset [0]
Code
273  public static function get_ids($__order=null, $__lookups=null, $__where_clause=null, $__limit=null, $__offset=0)
274  {
275      return contract::get_columns("id", $__order, $__lookups, $__where_clause, $__limit, $__offset);
276  }
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] )[ contract_db ]
Parameters
optionalorder
optionallookups
optionalwhere_clause
optionallimit
optionaloffset [0]
Code
278  public static function get_objects($__order=null, $__lookups=null, $__where_clause=null, $__limit=null, $__offset=0)
279  {
280      $objects = array();
281      foreach (contract::get_columns("id", $__order, $__lookups, $__where_clause, $__limit, $__offset) as $id)
282      {
283          $objects[] = new contract($id);
284      }
285      return $objects;
286  }
publicget_projectentity ( type ["default"] )[ contract_db ]
Parameters
optionaltype ["default"]
Code
474  public function get_projectentity($__type="default")
475  {
476      $object = is_null(keyval($this->property_objects_array,"{$__type}_projectentity")) ? new projectentity($this->get_projectentity_id($__type)) : $this->property_objects_array["{$__type}_projectentity"];
477      $this->property_objects_array["{$__type}_projectentity"] = $object;
478      return $object;
479  }
publicget_projectentity_id ( type ["default"] )[ contract_db ]
Parameters
optionaltype ["default"]
Code
480  public function get_projectentity_id($__type="default")
481  {
482      $ids = $this->get_projectentity_ids($__type, true);
483      return (count($ids)==1 ? $ids[0] : null);
484  }
publicget_projectentity_ids ( type , order , where_clause , limit , offset [0] , get_primary [false] )[ contract_db ]
Parameters
optionaltype
optionalorder
optionalwhere_clause
optionallimit
optionaloffset [0]
optionalget_primary [false]
Code
485  public function get_projectentity_ids($__type=null, $__order=null, $__where_clause=null, $__limit=null, $__offset=0, $__get_primary=false)
486  {
487      $projectentity_ids = array();
488      $db = contract::db();
489      $q  = " SELECT prj_projectentity.id FROM prj_contract_projectentity INNER JOIN prj_projectentity ON prj_contract_projectentity.projectentity_id=prj_projectentity.id AND prj_contract_projectentity.deleted=0 AND prj_projectentity.deleted=0 AND prj_contract_projectentity.contract_id='$this->id' " . (is_null($__type) ? "" : " AND prj_contract_projectentity.contract_projectentity_type_id='" . contract_projectentity::type_id($__type) . "'") . ($__get_primary ? " AND prj_contract_projectentity.primary=1 " : "");
490      $q .= is_null($__where_clause) ? "" : " WHERE {$__where_clause}";
491      $q .= is_null($__order) ? "" : " ORDER BY {$__order}";
492      $q .= is_null($__limit) ? "" : " LIMIT {$__offset}, {$__limit}";
493      $db->query($q);
494      while ($db->next_record())
495      {
496          $projectentity_ids[] = $db->f("id");
497      }
498      return $projectentity_ids;
499  }
publicget_projectentity_list ( type , order , where_clause , limit , offset [0] , get_primary [false] )[ contract_db ]
Parameters
optionaltype
optionalorder
optionalwhere_clause
optionallimit
optionaloffset [0]
optionalget_primary [false]
Code
500  public function get_projectentity_list($__type=null, $__order=null, $__where_clause=null, $__limit=null, $__offset=0, $__get_primary=false)
501  {
502      $ids = $this->get_projectentity_ids($__type, $__order, $__where_clause, $__limit, $__offset, $__get_primary);
503      $objects = array();
504      foreach ($ids as $index=>$id)
505      {
506          $objects[$index] = new projectentity($id);
507      }
508      return $objects;
509  }
publicget_properties ( )[ obj ]
Parameters
No parameters for this method
Code
121  public function get_properties()
122  {
123      return array_keys($this->array);
124  }
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  }
protectedinsert ( )[ contract_db ]
Parameters
No parameters for this method
Code
137  protected function insert()
138  {
139      $db = contract::db();
140      $q  = " INSERT INTO cont_contract ( ";
141      $q .= $db->param_string("name") . ", ";
142      $q .= $db->param_string("code") . ", ";
143      $q .= $db->param_string("description") . ", ";
144      $q .= $db->param_string("contractstatus_id") . ", ";
145      $q .= $db->param_string("type_id") . ", ";
146      $q .= $db->param_string("mdate") . ", ";
147      $q .= $db->param_string("cdate") . ", ";
148      $q .= $db->param_string("deleted");
149      $q .= " ) VALUES ( ";
150      $q .= $db->value_string($this->_name) . ", ";
151      $q .= $db->value_string($this->_code) . ", ";
152      $q .= $db->value_string($this->_description) . ", ";
153      $q .= $db->value_string($this->_contractstatus_id) . ", ";
154      $q .= $db->value_string($this->_type_id) . ", ";
155      $q .= $db->value_string(timestamp()) . ", ";
156      $q .= $db->value_string(timestamp()) . ", ";
157      $q .= $this->deleted ? "'1'" : "'0'";
158      $q .= " ) ";
159      $db->query($q);
160      $this->_id = $db->insert_id;
161      return true;
162  }
publicmap ( )[ contract_db ]
Parameters
No parameters for this method
Code
106  public function map()
107  {
108      $this->_name = array_key_exists("contract:name",$_REQUEST) ? reqval("contract:name") : $this->_name;
109      $this->_code = array_key_exists("contract:code",$_REQUEST) ? reqval("contract:code") : $this->_code;
110      $this->_description = array_key_exists("contract:description",$_REQUEST) ? reqval("contract:description") : $this->_description;
111      $this->_contractstatus_id = array_key_exists("contract:contractstatus_id",$_REQUEST) ? reqval("contract:contractstatus_id") : $this->_contractstatus_id;
112      $this->_type_id = array_key_exists("contract:type_id",$_REQUEST) ? reqval("contract:type_id") : $this->_type_id;
113      $this->_mdate = array_key_exists("contract:mdate",$_REQUEST) ? reqval("contract:mdate") : $this->_mdate;
114      $this->_cdate = array_key_exists("contract:cdate",$_REQUEST) ? reqval("contract:cdate") : $this->_cdate;
115      $this->_deleted = array_key_exists("contract:deleted",$_REQUEST) ? reqval("contract:deleted") : $this->_deleted;
116  }
publicpurge ( )[ contract_db ]
Parameters
No parameters for this method
Code
202  public function purge()
203  {
204      $db = contract::db();
205      $q  = " DELETE FROM cont_contract ";
206      $q .= " WHERE id = " . $this->_id;
207      $db->query($q);
208      return true;
209  }
public staticsearch ( keyword )[ contract_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_contract_type ( v )[ contract_db ]
Parameters
requiredv
Code
367  public function set_contract_type($v)
368  {
369      if ($v->id > 0)
370      {
371          $this->contract_type_id = $v->id;
372      }
373  }
publicset_contractstatus ( v )[ contract_db ]
Parameters
requiredv
Code
355  public function set_contractstatus($v)
356  {
357      if ($v->id > 0)
358      {
359          $this->contractstatus_id = $v->id;
360      }
361  }
publicset_contractvalue ( v , type ["default"] )[ contract_db ]
Parameters
requiredv
optionaltype ["default"]
Code
412  public function set_contractvalue($__v, $__type="default")
413  {
414      $object = is_null(keyval($this->property_objects_array,"{$__type}_contractvalue")) ? new contractvalue($this->get_contractvalue_id($__type)) : $this->property_objects_array["{$__type}_contractvalue"];
415      if (is_null($__v))
416      {
417          $rel = new contract_contractvalue(null,$this->id,$object->id,contract_contractvalue::type_id($__type));
418          $rel->delete();
419          if (!is_null(keyval($this->property_objects_array,"{$__type}_contractvalue")))
420          {
421              $this->property_objects_array["{$__type}_contractvalue"] = null;
422          }
423      }
424      else
425      {
426          $id = $object->id;
427          $object = $__v;
428          $object->id = $__v->id>0 ? $__v->id : $id;
429          $object->commit();
430          $this->set_contractvalue_ids(array($object->id),$__type);
431      }
432  }
publicset_contractvalue_id ( v , type ["default"] )[ contract_db ]
Parameters
requiredv
optionaltype ["default"]
Code
433  public function set_contractvalue_id($__v, $__type="default")
434  {
435      $this->set_contractvalue_ids(array($__v),$__type);
436  }
publicset_contractvalue_ids ( v , type ["default"] )[ contract_db ]
Parameters
requiredv
optionaltype ["default"]
Code
437  public function set_contractvalue_ids($__v, $__type="default")
438  {
439      if ($this->id == 0)
440      {
441          $this->commit();
442      }
443      $type_id = contract_contractvalue::type_id($__type);
444      contract_contractvalue::delete_all($this->id,null,$type_id);
445      if (is_array($__v))
446      {
447          foreach ($__v as $index=>$id)
448          {
449              $object = new contract_contractvalue(null,$this->id,$id,$type_id);
450              $object->deleted = false;
451              $object->contract_contractvalue_type_id = $type_id;
452              $object->commit();
453              if (count($__v)==1 && !is_null(keyval($this->property_objects_array,"{$__type}_contractvalue")))
454              {
455                  $this->property_objects_array["{$__type}_contractvalue"] = new contractvalue($object->contractvalue_id);
456              }
457          }
458          $this->_dirty = true;
459      }
460  }
publicset_contractvalue_list ( v , type ["default"] )[ contract_db ]
Parameters
requiredv
optionaltype ["default"]
Code
461  public function set_contractvalue_list($__v, $__type="default")
462  {
463      if (is_array($__v))
464      {
465          $ids = array();
466          foreach ($__v as $index=>$object)
467          {
468              $ids[] = $object->id;
469          }
470          $this->set_contractvalue_ids($ids,$__type);
471      }
472  }
publicset_projectentity ( v , type ["default"] )[ contract_db ]
Parameters
requiredv
optionaltype ["default"]
Code
511  public function set_projectentity($__v, $__type="default")
512  {
513      $object = is_null(keyval($this->property_objects_array,"{$__type}_projectentity")) ? new projectentity($this->get_projectentity_id($__type)) : $this->property_objects_array["{$__type}_projectentity"];
514      if (is_null($__v))
515      {
516          $rel = new contract_projectentity(null,$this->id,$object->id,contract_projectentity::type_id($__type));
517          $rel->delete();
518          if (!is_null(keyval($this->property_objects_array,"{$__type}_projectentity")))
519          {
520              $this->property_objects_array["{$__type}_projectentity"] = null;
521          }
522      }
523      else
524      {
525          $id = $object->id;
526          $object = $__v;
527          $object->id = $__v->id>0 ? $__v->id : $id;
528          $object->commit();
529          $this->set_projectentity_ids(array($object->id),$__type);
530      }
531  }
publicset_projectentity_id ( v , type ["default"] )[ contract_db ]
Parameters
requiredv
optionaltype ["default"]
Code
532  public function set_projectentity_id($__v, $__type="default")
533  {
534      $this->set_projectentity_ids(array($__v),$__type);
535  }
publicset_projectentity_ids ( v , type ["default"] )[ contract_db ]
Parameters
requiredv
optionaltype ["default"]
Code
536  public function set_projectentity_ids($__v, $__type="default")
537  {
538      if ($this->id == 0)
539      {
540          $this->commit();
541      }
542      $type_id = contract_projectentity::type_id($__type);
543      contract_projectentity::delete_all($this->id,null,$type_id);
544      if (is_array($__v))
545      {
546          foreach ($__v as $index=>$id)
547          {
548              $object = new contract_projectentity(null,$this->id,$id,$type_id);
549              $object->deleted = false;
550              $object->contract_projectentity_type_id = $type_id;
551              $object->commit();
552              if (count($__v)==1 && !is_null(keyval($this->property_objects_array,"{$__type}_projectentity")))
553              {
554                  $this->property_objects_array["{$__type}_projectentity"] = new projectentity($object->projectentity_id);
555              }
556          }
557          $this->_dirty = true;
558      }
559  }
publicset_projectentity_list ( v , type ["default"] )[ contract_db ]
Parameters
requiredv
optionaltype ["default"]
Code
560  public function set_projectentity_list($__v, $__type="default")
561  {
562      if (is_array($__v))
563      {
564          $ids = array();
565          foreach ($__v as $index=>$object)
566          {
567              $ids[] = $object->id;
568          }
569          $this->set_projectentity_ids($ids,$__type);
570      }
571  }
public__toString ( )[ contract_db ]
Parameters
No parameters for this method
Code
346  public function __toString()
347  {
348      return (is_null($this->name) ? "" : $this->name);
349  }
publicundelete ( )[ contract_db ]
Parameters
No parameters for this method
Code
191  public function undelete()
192  {
193      $db = contract::db();
194      $q  = " UPDATE cont_contract SET ";
195      $q .= " deleted = 0 ";
196      $q .= " WHERE id = " . $this->_id;
197      $db->query($q);
198      $this->deleted = false;
199      return true;
200  }
protectedupdate ( )[ contract_db ]
Parameters
No parameters for this method
Code
164  protected function update()
165  {
166      $db = contract::db();
167      $q  = " UPDATE cont_contract SET ";
168      $q .= $db->param_string("name") . " = " . $db->value_string($this->_name) . ", ";
169      $q .= $db->param_string("code") . " = " . $db->value_string($this->_code) . ", ";
170      $q .= $db->param_string("description") . " = " . $db->value_string($this->_description) . ", ";
171      $q .= $db->param_string("contractstatus_id") . " = " . $db->value_string($this->_contractstatus_id) . ", ";
172      $q .= $db->param_string("type_id") . " = " . $db->value_string($this->_type_id) . ", ";
173      $q .= $db->param_string("mdate") . " = " . $db->value_string(timestamp()) . ", ";
174      $q .= $db->param_string("deleted") . " = " . ($this->deleted ? "'1'" : "'0'");
175      $q .= " WHERE id = " . $this->_id;
176      $db->query($q);
177      return true;
178  }
 
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[ contract_db ]
Code
211  public static function get_columns($__columns, $__order=null, $__lookups=null, $__where_clause=null, $__limit=null, $__offset=0)
212  {
213      $lookups = is_array($__lookups) ? $__lookups : array($__lookups);
214      $colarray = is_array($__columns) ? $__columns : explode(",",$__columns);
215      $colstring = is_array($__columns) ? implode(",",$__columns) : $__columns;
216 
217      $db = contract::db();
218      $data = array();
219      $q  = " SELECT $colstring ";
220      $q .= " FROM cont_contract ";
221      $q .= " WHERE cont_contract.deleted = 0 ";
222      $q .= is_null($__where_clause) ? null : " AND ($__where_clause) ";
223      $q .= array_key_exists("contractstatus_id",$lookups) ? " AND cont_contract.contractstatus_id='" . $lookups["contractstatus_id"] . "' " : "";
224      $q .= array_key_exists("type_id",$lookups) ? " AND cont_contract.type_id='" . $lookups["type_id"] . "' " : "";
225 
226      if (is_string($__order))
227      {
228          $q .= "ORDER BY " . $__order;
229      }
230      else if (is_array($__order) and count($__order)>0)
231      {
232          $orderings = array();
233          foreach ($__order as $col=>$dir)
234          {
235              $orderings[] = " $col $dir ";
236          }
237          $q .= "ORDER BY " . implode(", ", $orderings);
238      }
239      else if (is_object($__order))
240      {
241          $q .= "";
242      }
243      else
244      {
245          // THERE IS NO `order` COLUMN ON THIS OBJECT
246      }
247 
248      if (!is_null($__limit))
249      {
250          $q .= " LIMIT $__offset , $__limit ";
251      }
252 
253      $db->query($q);
254 
255      if (count($colarray)>1 || $colstring=="*")
256      {
257          while ($db->next_record())
258          {
259              $data[] = $db->record;
260          }
261      }
262      else
263      {
264          while ($db->next_record())
265          {
266              $data[] = $db->f(0);
267          }
268      }
269 
270      return $data;
271  }
publiccontract_type[ contract_db ]
Code
363  public function get_contract_type()
364  {
365      return new contract_type($this->contract_type_id);
366  }
Code
367  public function set_contract_type($v)
368  {
369      if ($v->id > 0)
370      {
371          $this->contract_type_id = $v->id;
372      }
373  }
publiccontractstatus[ contract_db ]
Code
351  public function get_contractstatus()
352  {
353      return new contractstatus($this->contractstatus_id);
354  }
Code
355  public function set_contractstatus($v)
356  {
357      if ($v->id > 0)
358      {
359          $this->contractstatus_id = $v->id;
360      }
361  }
publiccontractvalue[ contract_db ]
Code
375  public function get_contractvalue($__type="default")
376  {
377      $object = is_null(keyval($this->property_objects_array,"{$__type}_contractvalue")) ? new contractvalue($this->get_contractvalue_id($__type)) : $this->property_objects_array["{$__type}_contractvalue"];
378      $this->property_objects_array["{$__type}_contractvalue"] = $object;
379      return $object;
380  }
Code
412  public function set_contractvalue($__v, $__type="default")
413  {
414      $object = is_null(keyval($this->property_objects_array,"{$__type}_contractvalue")) ? new contractvalue($this->get_contractvalue_id($__type)) : $this->property_objects_array["{$__type}_contractvalue"];
415      if (is_null($__v))
416      {
417          $rel = new contract_contractvalue(null,$this->id,$object->id,contract_contractvalue::type_id($__type));
418          $rel->delete();
419          if (!is_null(keyval($this->property_objects_array,"{$__type}_contractvalue")))
420          {
421              $this->property_objects_array["{$__type}_contractvalue"] = null;
422          }
423      }
424      else
425      {
426          $id = $object->id;
427          $object = $__v;
428          $object->id = $__v->id>0 ? $__v->id : $id;
429          $object->commit();
430          $this->set_contractvalue_ids(array($object->id),$__type);
431      }
432  }
publiccontractvalue_id[ contract_db ]
Code
381  public function get_contractvalue_id($__type="default")
382  {
383      $ids = $this->get_contractvalue_ids($__type, true);
384      return (count($ids)==1 ? $ids[0] : null);
385  }
Code
433  public function set_contractvalue_id($__v, $__type="default")
434  {
435      $this->set_contractvalue_ids(array($__v),$__type);
436  }
publiccontractvalue_ids[ contract_db ]
Code
386  public function get_contractvalue_ids($__type=null, $__order=null, $__where_clause=null, $__limit=null, $__offset=0, $__get_primary=false)
387  {
388      $contractvalue_ids = array();
389      $db = contract::db();
390      $q  = " SELECT cont_contractvalue.id FROM cont_contract_contractvalue INNER JOIN cont_contractvalue ON cont_contract_contractvalue.contractvalue_id=cont_contractvalue.id AND cont_contract_contractvalue.deleted=0 AND cont_contractvalue.deleted=0 AND cont_contract_contractvalue.contract_id='$this->id' " . (is_null($__type) ? "" : " AND cont_contract_contractvalue.contract_contractvalue_type_id='" . contract_contractvalue::type_id($__type) . "'") . ($__get_primary ? " AND cont_contract_contractvalue.primary=1 " : "");
391      $q .= is_null($__where_clause) ? "" : " WHERE {$__where_clause}";
392      $q .= is_null($__order) ? "" : " ORDER BY {$__order}";
393      $q .= is_null($__limit) ? "" : " LIMIT {$__offset}, {$__limit}";
394      $db->query($q);
395      while ($db->next_record())
396      {
397          $contractvalue_ids[] = $db->f("id");
398      }
399      return $contractvalue_ids;
400  }
Code
437  public function set_contractvalue_ids($__v, $__type="default")
438  {
439      if ($this->id == 0)
440      {
441          $this->commit();
442      }
443      $type_id = contract_contractvalue::type_id($__type);
444      contract_contractvalue::delete_all($this->id,null,$type_id);
445      if (is_array($__v))
446      {
447          foreach ($__v as $index=>$id)
448          {
449              $object = new contract_contractvalue(null,$this->id,$id,$type_id);
450              $object->deleted = false;
451              $object->contract_contractvalue_type_id = $type_id;
452              $object->commit();
453              if (count($__v)==1 && !is_null(keyval($this->property_objects_array,"{$__type}_contractvalue")))
454              {
455                  $this->property_objects_array["{$__type}_contractvalue"] = new contractvalue($object->contractvalue_id);
456              }
457          }
458          $this->_dirty = true;
459      }
460  }
publiccontractvalue_list[ contract_db ]
Code
401  public function get_contractvalue_list($__type=null, $__order=null, $__where_clause=null, $__limit=null, $__offset=0, $__get_primary=false)
402  {
403      $ids = $this->get_contractvalue_ids($__type, $__order, $__where_clause, $__limit, $__offset, $__get_primary);
404      $objects = array();
405      foreach ($ids as $index=>$id)
406      {
407          $objects[$index] = new contractvalue($id);
408      }
409      return $objects;
410  }
Code
461  public function set_contractvalue_list($__v, $__type="default")
462  {
463      if (is_array($__v))
464      {
465          $ids = array();
466          foreach ($__v as $index=>$object)
467          {
468              $ids[] = $object->id;
469          }
470          $this->set_contractvalue_ids($ids,$__type);
471      }
472  }
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[ contract_db ]
Code
273  public static function get_ids($__order=null, $__lookups=null, $__where_clause=null, $__limit=null, $__offset=0)
274  {
275      return contract::get_columns("id", $__order, $__lookups, $__where_clause, $__limit, $__offset);
276  }
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[ contract_db ]
Code
278  public static function get_objects($__order=null, $__lookups=null, $__where_clause=null, $__limit=null, $__offset=0)
279  {
280      $objects = array();
281      foreach (contract::get_columns("id", $__order, $__lookups, $__where_clause, $__limit, $__offset) as $id)
282      {
283          $objects[] = new contract($id);
284      }
285      return $objects;
286  }
publicprojectentity[ contract_db ]
Code
474  public function get_projectentity($__type="default")
475  {
476      $object = is_null(keyval($this->property_objects_array,"{$__type}_projectentity")) ? new projectentity($this->get_projectentity_id($__type)) : $this->property_objects_array["{$__type}_projectentity"];
477      $this->property_objects_array["{$__type}_projectentity"] = $object;
478      return $object;
479  }
Code
511  public function set_projectentity($__v, $__type="default")
512  {
513      $object = is_null(keyval($this->property_objects_array,"{$__type}_projectentity")) ? new projectentity($this->get_projectentity_id($__type)) : $this->property_objects_array["{$__type}_projectentity"];
514      if (is_null($__v))
515      {
516          $rel = new contract_projectentity(null,$this->id,$object->id,contract_projectentity::type_id($__type));
517          $rel->delete();
518          if (!is_null(keyval($this->property_objects_array,"{$__type}_projectentity")))
519          {
520              $this->property_objects_array["{$__type}_projectentity"] = null;
521          }
522      }
523      else
524      {
525          $id = $object->id;
526          $object = $__v;
527          $object->id = $__v->id>0 ? $__v->id : $id;
528          $object->commit();
529          $this->set_projectentity_ids(array($object->id),$__type);
530      }
531  }
publicprojectentity_id[ contract_db ]
Code
480  public function get_projectentity_id($__type="default")
481  {
482      $ids = $this->get_projectentity_ids($__type, true);
483      return (count($ids)==1 ? $ids[0] : null);
484  }
Code
532  public function set_projectentity_id($__v, $__type="default")
533  {
534      $this->set_projectentity_ids(array($__v),$__type);
535  }
publicprojectentity_ids[ contract_db ]
Code
485  public function get_projectentity_ids($__type=null, $__order=null, $__where_clause=null, $__limit=null, $__offset=0, $__get_primary=false)
486  {
487      $projectentity_ids = array();
488      $db = contract::db();
489      $q  = " SELECT prj_projectentity.id FROM prj_contract_projectentity INNER JOIN prj_projectentity ON prj_contract_projectentity.projectentity_id=prj_projectentity.id AND prj_contract_projectentity.deleted=0 AND prj_projectentity.deleted=0 AND prj_contract_projectentity.contract_id='$this->id' " . (is_null($__type) ? "" : " AND prj_contract_projectentity.contract_projectentity_type_id='" . contract_projectentity::type_id($__type) . "'") . ($__get_primary ? " AND prj_contract_projectentity.primary=1 " : "");
490      $q .= is_null($__where_clause) ? "" : " WHERE {$__where_clause}";
491      $q .= is_null($__order) ? "" : " ORDER BY {$__order}";
492      $q .= is_null($__limit) ? "" : " LIMIT {$__offset}, {$__limit}";
493      $db->query($q);
494      while ($db->next_record())
495      {
496          $projectentity_ids[] = $db->f("id");
497      }
498      return $projectentity_ids;
499  }
Code
536  public function set_projectentity_ids($__v, $__type="default")
537  {
538      if ($this->id == 0)
539      {
540          $this->commit();
541      }
542      $type_id = contract_projectentity::type_id($__type);
543      contract_projectentity::delete_all($this->id,null,$type_id);
544      if (is_array($__v))
545      {
546          foreach ($__v as $index=>$id)
547          {
548              $object = new contract_projectentity(null,$this->id,$id,$type_id);
549              $object->deleted = false;
550              $object->contract_projectentity_type_id = $type_id;
551              $object->commit();
552              if (count($__v)==1 && !is_null(keyval($this->property_objects_array,"{$__type}_projectentity")))
553              {
554                  $this->property_objects_array["{$__type}_projectentity"] = new projectentity($object->projectentity_id);
555              }
556          }
557          $this->_dirty = true;
558      }
559  }
publicprojectentity_list[ contract_db ]
Code
500  public function get_projectentity_list($__type=null, $__order=null, $__where_clause=null, $__limit=null, $__offset=0, $__get_primary=false)
501  {
502      $ids = $this->get_projectentity_ids($__type, $__order, $__where_clause, $__limit, $__offset, $__get_primary);
503      $objects = array();
504      foreach ($ids as $index=>$id)
505      {
506          $objects[$index] = new projectentity($id);
507      }
508      return $objects;
509  }
Code
560  public function set_projectentity_list($__v, $__type="default")
561  {
562      if (is_array($__v))
563      {
564          $ids = array();
565          foreach ($__v as $index=>$object)
566          {
567              $ids[] = $object->id;
568          }
569          $this->set_projectentity_ids($ids,$__type);
570      }
571  }
publicproperties[ obj ]
Code
121  public function get_properties()
122  {
123      return array_keys($this->array);
124  }
publicstring[ obj ]
Code
091  protected function get_string()
092  {
093      return method_exists($this,"__toString") ? $this->__toString() : null;
094  }
Get Helix PHP Framework at SourceForge.net. Fast, secure and Free Open Source software downloads