27require_once DOL_DOCUMENT_ROOT.
'/core/class/commonobject.class.php';
28require_once DOL_DOCUMENT_ROOT.
'/core/class/commonobjectline.class.php';
29require_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
31if (isModEnabled(
'workstation')) {
32 require_once DOL_DOCUMENT_ROOT.
'/workstation/class/workstation.class.php';
47 public $module =
'bom';
52 public $element =
'bom';
57 public $table_element =
'bom_bom';
62 public $ismultientitymanaged = 1;
67 public $isextrafieldmanaged = 1;
72 public $picto =
'bom';
79 const STATUS_DRAFT = 0;
80 const STATUS_VALIDATED = 1;
81 const STATUS_CANCELED = 9;
114 public $fields = array(
115 'rowid' => array(
'type'=>
'integer',
'label'=>
'TechnicalID',
'enabled'=>1,
'visible'=>-2,
'position'=>1,
'notnull'=>1,
'index'=>1,
'comment'=>
"Id",),
116 'entity' => array(
'type'=>
'integer',
'label'=>
'Entity',
'enabled'=>1,
'visible'=>0,
'notnull'=> 1,
'default'=>1,
'index'=>1,
'position'=>5),
117 'ref' => array(
'type'=>
'varchar(128)',
'label'=>
'Ref',
'enabled'=>1,
'noteditable'=>1,
'visible'=>4,
'position'=>10,
'notnull'=>1,
'default'=>
'(PROV)',
'index'=>1,
'searchall'=>1,
'comment'=>
"Reference of BOM",
'showoncombobox'=>
'1',
'csslist'=>
'nowraponall'),
118 'label' => array(
'type'=>
'varchar(255)',
'label'=>
'Label',
'enabled'=>1,
'visible'=>1,
'position'=>30,
'notnull'=>1,
'searchall'=>1,
'showoncombobox'=>
'2',
'autofocusoncreate'=>1,
'css'=>
'minwidth300 maxwidth400',
'csslist'=>
'tdoverflowmax200'),
119 'bomtype' => array(
'type'=>
'integer',
'label'=>
'Type',
'enabled'=>1,
'visible'=>1,
'position'=>33,
'notnull'=>1,
'default'=>
'0',
'arrayofkeyval'=>array(0=>
'Manufacturing', 1=>
'Disassemble'),
'css'=>
'minwidth175',
'csslist'=>
'minwidth175 center'),
121 'fk_product' => array(
'type'=>
'integer:Product:product/class/product.class.php:1:((finished:is:null) or (finished:!=:0))',
'label'=>
'Product',
'picto'=>
'product',
'enabled'=>1,
'visible'=>1,
'position'=>35,
'notnull'=>1,
'index'=>1,
'help'=>
'ProductBOMHelp',
'css'=>
'maxwidth500',
'csslist'=>
'tdoverflowmax100'),
122 'description' => array(
'type'=>
'text',
'label'=>
'Description',
'enabled'=>1,
'visible'=>-1,
'position'=>60,
'notnull'=>-1,),
123 'qty' => array(
'type'=>
'real',
'label'=>
'Quantity',
'enabled'=>1,
'visible'=>1,
'default'=>1,
'position'=>55,
'notnull'=>1,
'isameasure'=>
'1',
'css'=>
'maxwidth50imp right'),
125 'duration' => array(
'type'=>
'duration',
'label'=>
'EstimatedDuration',
'enabled'=>1,
'visible'=>-1,
'position'=>101,
'notnull'=>-1,
'css'=>
'maxwidth50imp',
'help'=>
'EstimatedDurationDesc'),
126 'fk_warehouse' => array(
'type'=>
'integer:Entrepot:product/stock/class/entrepot.class.php:0',
'label'=>
'WarehouseForProduction',
'picto'=>
'stock',
'enabled'=>1,
'visible'=>-1,
'position'=>102,
'css'=>
'maxwidth500',
'csslist'=>
'tdoverflowmax100'),
127 'note_public' => array(
'type'=>
'html',
'label'=>
'NotePublic',
'enabled'=>1,
'visible'=>-2,
'position'=>161,
'notnull'=>-1,),
128 'note_private' => array(
'type'=>
'html',
'label'=>
'NotePrivate',
'enabled'=>1,
'visible'=>-2,
'position'=>162,
'notnull'=>-1,),
129 'date_creation' => array(
'type'=>
'datetime',
'label'=>
'DateCreation',
'enabled'=>1,
'visible'=>-2,
'position'=>300,
'notnull'=>1,),
130 'tms' => array(
'type'=>
'timestamp',
'label'=>
'DateModification',
'enabled'=>1,
'visible'=>-2,
'position'=>501,
'notnull'=>1,),
131 'date_valid' => array(
'type'=>
'datetime',
'label'=>
'DateValidation',
'enabled'=>1,
'visible'=>-2,
'position'=>502,
'notnull'=>0,),
132 'fk_user_creat' => array(
'type'=>
'integer:User:user/class/user.class.php',
'label'=>
'UserCreation',
'picto'=>
'user',
'enabled'=>1,
'visible'=>-2,
'position'=>510,
'notnull'=>1,
'foreignkey'=>
'user.rowid',
'csslist'=>
'tdoverflowmax100'),
133 'fk_user_modif' => array(
'type'=>
'integer:User:user/class/user.class.php',
'label'=>
'UserModif',
'picto'=>
'user',
'enabled'=>1,
'visible'=>-2,
'position'=>511,
'notnull'=>-1,
'csslist'=>
'tdoverflowmax100'),
134 'fk_user_valid' => array(
'type'=>
'integer:User:user/class/user.class.php',
'label'=>
'UserValidation',
'picto'=>
'user',
'enabled'=>1,
'visible'=>-2,
'position'=>512,
'notnull'=>0,
'csslist'=>
'tdoverflowmax100'),
135 'import_key' => array(
'type'=>
'varchar(14)',
'label'=>
'ImportId',
'enabled'=>1,
'visible'=>-2,
'position'=>1000,
'notnull'=>-1,),
136 'model_pdf' =>array(
'type'=>
'varchar(255)',
'label'=>
'Model pdf',
'enabled'=>1,
'visible'=>0,
'position'=>1010),
137 'status' => array(
'type'=>
'integer',
'label'=>
'Status',
'enabled'=>1,
'visible'=>2,
'position'=>1000,
'notnull'=>1,
'default'=>0,
'index'=>1,
'arrayofkeyval'=>array(0=>
'Draft', 1=>
'Enabled', 9=>
'Disabled')),
168 public $date_creation;
180 public $fk_user_creat;
185 public $fk_user_modif;
190 public $fk_user_valid;
195 public $fk_warehouse;
222 public $table_element_line =
'bom_bomline';
227 public $fk_element =
'fk_bom';
232 public $class_element_line =
'BOMLine';
242 protected $childtablesoncascade = array(
'bom_bomline');
247 public $lines = array();
252 public $total_cost = 0;
257 public $unit_cost = 0;
267 global $conf, $langs;
272 $this->fields[
'rowid'][
'visible'] = 0;
274 if (!isModEnabled(
'multicompany') && isset($this->fields[
'entity'])) {
275 $this->fields[
'entity'][
'enabled'] = 0;
279 foreach ($this->fields as $key => $val) {
280 if (isset($val[
'enabled']) && empty($val[
'enabled'])) {
281 unset($this->fields[$key]);
286 foreach ($this->fields as $key => $val) {
287 if (!empty($val[
'arrayofkeyval']) && is_array($val[
'arrayofkeyval'])) {
288 foreach ($val[
'arrayofkeyval'] as $key2 => $val2) {
289 $this->fields[$key][
'arrayofkeyval'][$key2] = $langs->trans($val2);
304 if ($this->efficiency <= 0 || $this->efficiency > 1) {
305 $this->efficiency = 1;
320 global $langs, $hookmanager, $extrafields;
325 $object =
new self($this->db);
330 $result = $object->fetchCommon($fromid);
331 if ($result > 0 && !empty($object->table_element_line)) {
332 $object->fetchLines();
341 unset($object->fk_user_creat);
342 unset($object->import_key);
345 $object->ref = empty($this->fields[
'ref'][
'default']) ? $langs->trans(
"copy_of_").$object->ref : $this->fields[
'ref'][
'default'];
346 $object->label = empty($this->fields[
'label'][
'default']) ? $langs->trans(
"CopyOf").
" ".$object->label : $this->fields[
'label'][
'default'];
347 $object->status = self::STATUS_DRAFT;
350 if (is_array($object->array_options) && count($object->array_options) > 0) {
351 $extrafields->fetch_name_optionals_label($object->table_element);
352 foreach ($object->array_options as $key => $option) {
353 $shortkey = preg_replace(
'/options_/',
'', $key);
354 if (!empty($extrafields->attributes[$this->element][
'unique'][$shortkey])) {
356 unset($object->array_options[$key]);
362 $object->context[
'createfromclone'] =
'createfromclone';
363 $result = $object->createCommon($user);
366 $this->error = $object->error;
367 $this->errors = $object->errors;
379 if (property_exists($this,
'socid') && $this->socid == $object->socid) {
390 unset($object->context[
'createfromclone']);
397 $this->db->rollback();
409 public function fetch($id, $ref =
null)
413 if ($result > 0 && !empty($this->table_element_line)) {
428 $this->lines = array();
443 $this->lines = array();
445 $objectlineclassname = get_class($this).
'Line';
446 if (!class_exists($objectlineclassname)) {
447 $this->error =
'Error, class '.$objectlineclassname.
' not found during call of fetchLinesCommon';
451 $objectline =
new $objectlineclassname($this->db);
453 $sql =
"SELECT ".$objectline->getFieldList(
'l');
454 $sql .=
" FROM ".$this->db->prefix().$objectline->table_element.
" as l";
455 $sql .=
" LEFT JOIN ".$this->db->prefix().
"product as p ON p.rowid = l.fk_product";
456 $sql .=
" WHERE l.fk_".$this->db->escape($this->element).
" = ".((int) $this->
id);
457 $sql .=
" AND p.fk_product_type = ". ((int) $typeproduct);
458 if (isset($objectline->fields[
'position'])) {
459 $sql .= $this->db->order(
'position',
'ASC');
462 $resql = $this->db->query($sql);
464 $num_rows = $this->db->num_rows($resql);
466 while ($i < $num_rows) {
467 $obj = $this->db->fetch_object($resql);
469 $newline =
new $objectlineclassname($this->db);
470 $newline->setVarsFromFetchObj($obj);
472 $this->lines[] = $newline;
479 $this->error = $this->db->lasterror();
480 $this->errors[] = $this->error;
497 public function fetchAll($sortorder =
'', $sortfield =
'', $limit = 0, $offset = 0, array $filter = array(), $filtermode =
'AND')
507 $sql .=
' FROM '.MAIN_DB_PREFIX.$this->table_element.
' as t';
508 if ($this->ismultientitymanaged) {
509 $sql .=
' WHERE t.entity IN ('.getEntity($this->element).
')';
511 $sql .=
' WHERE 1 = 1';
515 if (count($filter) > 0) {
516 foreach ($filter as $key => $value) {
517 if ($key ==
't.rowid') {
518 $sqlwhere[] = $key.
" = ".((int) $value);
519 } elseif (strpos($key,
'date') !==
false) {
520 $sqlwhere[] = $key.
" = '".$this->db->idate($value).
"'";
521 } elseif ($key ==
'customsql') {
522 $sqlwhere[] = $value;
524 $sqlwhere[] = $key.
" LIKE '%".$this->db->escape($value).
"%'";
528 if (count($sqlwhere) > 0) {
529 $sql .=
" AND (".implode(
" ".$filtermode.
" ", $sqlwhere).
")";
532 if (!empty($sortfield)) {
533 $sql .= $this->db->order($sortfield, $sortorder);
535 if (!empty($limit)) {
536 $sql .= $this->db->plimit($limit, $offset);
539 $resql = $this->db->query($sql);
541 $num = $this->db->num_rows($resql);
543 while ($obj = $this->db->fetch_object($resql)) {
544 $record =
new self($this->db);
545 $record->setVarsFromFetchObj($obj);
547 $records[$record->id] = $record;
549 $this->db->free($resql);
553 $this->errors[] =
'Error '.$this->db->lasterror();
554 dol_syslog(__METHOD__.
' '.join(
',', $this->errors), LOG_ERR);
569 if ($this->efficiency <= 0 || $this->efficiency > 1) {
570 $this->efficiency = 1;
583 public function delete(
User $user, $notrigger =
false)
605 public function addLine($fk_product, $qty, $qty_frozen = 0, $disable_stock_change = 0, $efficiency = 1.0, $position = -1, $fk_bom_child =
null, $import_key =
null, $fk_unit =
'', $array_options = array(), $fk_default_workstation =
null)
607 global $mysoc, $conf, $langs, $user;
609 $logtext =
"::addLine bomid=$this->id, qty=$qty, fk_product=$fk_product, qty_frozen=$qty_frozen, disable_stock_change=$disable_stock_change, efficiency=$efficiency";
610 $logtext .=
", fk_bom_child=$fk_bom_child, import_key=$import_key";
611 dol_syslog(get_class($this).$logtext, LOG_DEBUG);
613 if ($this->
statut == self::STATUS_DRAFT) {
614 include_once DOL_DOCUMENT_ROOT.
'/core/lib/price.lib.php';
620 if (empty($qty_frozen)) {
623 if (empty($disable_stock_change)) {
624 $disable_stock_change = 0;
626 if (empty($efficiency)) {
629 if (empty($fk_bom_child)) {
630 $fk_bom_child =
null;
632 if (empty($import_key)) {
635 if (empty($position)) {
647 $rankToUse = $position;
648 if ($rankToUse <= 0 or $rankToUse > $rangMax) {
649 $rankToUse = $rangMax + 1;
651 foreach ($this->lines as $bl) {
652 if ($bl->position >= $rankToUse) {
660 $line =
new BOMLine($this->db);
662 $line->context = $this->context;
664 $line->fk_bom = $this->id;
665 $line->fk_product = $fk_product;
667 $line->qty_frozen = $qty_frozen;
668 $line->disable_stock_change = $disable_stock_change;
669 $line->efficiency = $efficiency;
670 $line->fk_bom_child = $fk_bom_child;
671 $line->import_key = $import_key;
672 $line->position = $rankToUse;
673 $line->fk_unit = $fk_unit;
674 $line->fk_default_workstation = $fk_default_workstation;
676 if (is_array($array_options) && count($array_options) > 0) {
677 $line->array_options = $array_options;
680 $result = $line->create($user);
688 dol_syslog(get_class($this).
"::addLine error=".$this->error, LOG_ERR);
689 $this->db->rollback();
693 dol_syslog(get_class($this).
"::addLine status of BOM must be Draft to allow use of ->addLine()", LOG_ERR);
713 public function updateLine($rowid, $qty, $qty_frozen = 0, $disable_stock_change = 0, $efficiency = 1.0, $position = -1, $import_key =
null, $fk_unit = 0, $array_options = array(), $fk_default_workstation =
null)
715 global $mysoc, $conf, $langs, $user;
717 $logtext =
"::updateLine bomid=$this->id, qty=$qty, qty_frozen=$qty_frozen, disable_stock_change=$disable_stock_change, efficiency=$efficiency";
718 $logtext .=
", import_key=$import_key";
719 dol_syslog(get_class($this).$logtext, LOG_DEBUG);
721 if ($this->
statut == self::STATUS_DRAFT) {
722 include_once DOL_DOCUMENT_ROOT.
'/core/lib/price.lib.php';
728 if (empty($qty_frozen)) {
731 if (empty($disable_stock_change)) {
732 $disable_stock_change = 0;
734 if (empty($efficiency)) {
737 if (empty($import_key)) {
740 if (empty($position)) {
751 $line =
new BOMLine($this->db);
752 $line->fetch($rowid);
753 $line->fetch_optionals();
755 $staticLine = clone $line;
756 $line->oldcopy = $staticLine;
757 $line->context = $this->context;
760 $rankToUse = (int) $position;
761 if ($rankToUse != $line->oldcopy->position) {
762 foreach ($this->lines as $bl) {
763 if ($bl->position >= $rankToUse and $bl->position < ($line->oldcopy->position + 1)) {
767 if ($bl->position <= $rankToUse and $bl->position > ($line->oldcopy->position)) {
775 $line->fk_bom = $this->id;
777 $line->qty_frozen = $qty_frozen;
778 $line->disable_stock_change = $disable_stock_change;
779 $line->efficiency = $efficiency;
780 $line->import_key = $import_key;
781 $line->position = $rankToUse;
784 if (!empty($fk_unit)) {
785 $line->fk_unit = $fk_unit;
789 if (is_array($array_options) && count($array_options) > 0) {
791 foreach ($array_options as $key => $value) {
792 $line->array_options[$key] = $array_options[$key];
795 if ($line->fk_default_workstation != $fk_default_workstation) {
796 $line->fk_default_workstation = $fk_default_workstation;
799 $result = $line->update($user);
807 dol_syslog(get_class($this).
"::addLine error=".$this->error, LOG_ERR);
808 $this->db->rollback();
812 dol_syslog(get_class($this).
"::addLine status of BOM must be Draft to allow use of ->addLine()", LOG_ERR);
828 $this->error =
'ErrorDeleteLineNotAllowedByObjectStatus';
835 $line =
new BOMLine($this->db);
836 $line->fetch($idline);
837 $line->fetch_optionals();
839 $staticLine = clone $line;
840 $line->oldcopy = $staticLine;
841 $line->context = $this->context;
843 $result = $line->delete($user, $notrigger);
846 foreach ($this->lines as $bl) {
847 if ($bl->position > ($line->oldcopy->position)) {
859 dol_syslog(get_class($this).
"::addLine error=".$this->error, LOG_ERR);
860 $this->db->rollback();
874 global $langs, $conf;
881 $classname = $conf->global->BOM_ADDON;
884 $dirmodels = array_merge(array(
'/'), (array) $conf->modules_parts[
'models']);
885 foreach ($dirmodels as $reldir) {
889 $mybool |= @include_once $dir.$file;
892 if ($mybool ===
false) {
897 $obj =
new $classname();
898 $numref = $obj->getNextValue($prod, $this);
903 $this->error = $obj->error;
908 print $langs->trans(
"Error").
" ".$langs->trans(
"Error_BOM_ADDON_NotDefined");
924 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
929 if ($this->
status == self::STATUS_VALIDATED) {
930 dol_syslog(get_class($this).
"::validate action abandonned: already validated", LOG_WARNING);
947 if (!$error && (preg_match(
'/^[\(]?PROV/i', $this->
ref) || empty($this->
ref))) {
956 $sql =
"UPDATE ".MAIN_DB_PREFIX.$this->table_element;
957 $sql .=
" SET ref = '".$this->db->escape($num).
"',";
958 $sql .=
" status = ".self::STATUS_VALIDATED.
",";
959 $sql .=
" date_valid='".$this->db->idate($now).
"',";
960 $sql .=
" fk_user_valid = ".((int) $user->id);
961 $sql .=
" WHERE rowid = ".((int) $this->
id);
963 dol_syslog(get_class($this).
"::validate()", LOG_DEBUG);
964 $resql = $this->db->query($sql);
967 $this->error = $this->db->lasterror();
971 if (!$error && !$notrigger) {
981 $this->oldref = $this->ref;
984 if (preg_match(
'/^[\(]?PROV/i', $this->
ref)) {
986 $sql =
'UPDATE '.MAIN_DB_PREFIX.
"ecm_files set filename = CONCAT('".$this->db->escape($this->newref).
"', SUBSTR(filename, ".(strlen($this->
ref) + 1).
")), filepath = 'bom/".$this->db->escape($this->newref).
"'";
987 $sql .=
" WHERE filename LIKE '".$this->db->escape($this->
ref).
"%' AND filepath = 'bom/".$this->db->escape($this->
ref).
"' and entity = ".$conf->entity;
988 $resql = $this->db->query($sql);
991 $this->error = $this->db->lasterror();
993 $sql =
'UPDATE '.MAIN_DB_PREFIX.
"ecm_files set filepath = 'bom/".$this->db->escape($this->newref).
"'";
994 $sql .=
" WHERE filepath = 'bom/".$this->db->escape($this->
ref).
"' and entity = ".$conf->entity;
995 $resql = $this->db->query($sql);
998 $this->error = $this->db->lasterror();
1004 $dirsource = $conf->bom->dir_output.
'/'.$oldref;
1005 $dirdest = $conf->bom->dir_output.
'/'.$newref;
1006 if (!$error && file_exists($dirsource)) {
1007 dol_syslog(get_class($this).
"::validate() rename dir ".$dirsource.
" into ".$dirdest);
1009 if (@rename($dirsource, $dirdest)) {
1012 $listoffiles =
dol_dir_list($conf->bom->dir_output.
'/'.$newref,
'files', 1,
'^'.preg_quote($oldref,
'/'));
1013 foreach ($listoffiles as $fileentry) {
1014 $dirsource = $fileentry[
'name'];
1015 $dirdest = preg_replace(
'/^'.preg_quote($oldref,
'/').
'/', $newref, $dirsource);
1016 $dirsource = $fileentry[
'path'].
'/'.$dirsource;
1017 $dirdest = $fileentry[
'path'].
'/'.$dirdest;
1018 @rename($dirsource, $dirdest);
1028 $this->
status = self::STATUS_VALIDATED;
1032 $this->db->commit();
1035 $this->db->rollback();
1050 if ($this->
status <= self::STATUS_DRAFT) {
1061 return $this->
setStatusCommon($user, self::STATUS_DRAFT, $notrigger,
'BOM_UNVALIDATE');
1071 public function cancel($user, $notrigger = 0)
1074 if ($this->
status != self::STATUS_VALIDATED) {
1085 return $this->
setStatusCommon($user, self::STATUS_CANCELED, $notrigger,
'BOM_CLOSE');
1095 public function reopen($user, $notrigger = 0)
1098 if ($this->
status != self::STATUS_CANCELED) {
1109 return $this->
setStatusCommon($user, self::STATUS_VALIDATED, $notrigger,
'BOM_REOPEN');
1120 global $conf, $langs, $user;
1122 $langs->loadLangs([
'product',
'mrp']);
1127 return [
'optimize' => $langs->trans(
"ShowBillOfMaterials")];
1129 $picto =
img_picto(
'', $this->picto).
' <u class="paddingrightonly">'.$langs->trans(
"BillOfMaterials").
'</u>';
1130 if (isset($this->
status)) {
1131 $picto .=
' '.$this->getLibStatut(5);
1133 $datas[
'picto'] = $picto;
1134 $datas[
'ref'] =
'<br><b>'.$langs->trans(
'Ref').
':</b> '.$this->ref;
1135 if (isset($this->label)) {
1136 $datas[
'label'] =
'<br><b>'.$langs->trans(
'Label').
':</b> '.$this->label;
1138 if (!empty($this->fk_product) && $this->fk_product > 0) {
1139 include_once DOL_DOCUMENT_ROOT.
'/product/class/product.class.php';
1140 $product =
new Product($this->db);
1141 $resultFetch = $product->fetch($this->fk_product);
1142 if ($resultFetch > 0) {
1143 $datas[
'product'] =
"<br><b>".$langs->trans(
"Product").
'</b>: '.$product->ref.
' - '.$product->label;
1160 public function getNomUrl($withpicto = 0, $option =
'', $notooltip = 0, $morecss =
'', $save_lastsearch_value = -1)
1162 global $db, $conf, $langs, $hookmanager;
1164 if (!empty($conf->dol_no_mouse_hover)) {
1171 'objecttype' => $this->element,
1172 'option' => $option,
1174 $classfortooltip =
'classfortooltip';
1177 $classfortooltip =
'classforajaxtooltip';
1178 $dataparams =
' data-params="'.dol_escape_htmltag(json_encode($params)).
'"';
1184 $url = DOL_URL_ROOT.
'/bom/bom_card.php?id='.$this->id;
1186 if ($option !=
'nolink') {
1188 $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0);
1189 if ($save_lastsearch_value == -1 && isset($_SERVER[
"PHP_SELF"]) && preg_match(
'/list\.php/', $_SERVER[
"PHP_SELF"])) {
1190 $add_save_lastsearch_values = 1;
1192 if ($add_save_lastsearch_values) {
1193 $url .=
'&save_lastsearch_values=1';
1198 if (empty($notooltip)) {
1200 $label = $langs->trans(
"ShowBillOfMaterials");
1201 $linkclose .=
' alt="'.dol_escape_htmltag($label, 1).
'"';
1203 $linkclose .= ($label ?
' title="'.dol_escape_htmltag($label, 1).
'"' :
' title="tocomplete"');
1204 $linkclose .= $dataparams.
' class="'.$classfortooltip.($morecss ?
' '.$morecss :
'').
'"';
1206 $linkclose = ($morecss ?
' class="'.$morecss.
'"' :
'');
1209 $linkstart =
'<a href="'.$url.
'"';
1210 $linkstart .= $linkclose.
'>';
1213 $result .= $linkstart;
1215 $result .=
img_object(($notooltip ?
'' : $label), ($this->picto ? $this->picto :
'generic'), (($withpicto != 2) ?
'class="paddingright"' :
''), 0, 0, $notooltip ? 0 : 1);
1217 if ($withpicto != 2) {
1218 $result .= $this->ref;
1220 $result .= $linkend;
1223 global $action, $hookmanager;
1224 $hookmanager->initHooks(array(
'bomdao'));
1225 $parameters = array(
'id'=>$this->
id,
'getnomurl' => &$result);
1226 $reshook = $hookmanager->executeHooks(
'getNomUrl', $parameters, $this, $action);
1228 $result = $hookmanager->resPrint;
1230 $result .= $hookmanager->resPrint;
1258 if (empty($this->labelStatus)) {
1261 $this->labelStatus[self::STATUS_DRAFT] = $langs->transnoentitiesnoconv(
'Draft');
1262 $this->labelStatus[self::STATUS_VALIDATED] = $langs->transnoentitiesnoconv(
'Enabled');
1263 $this->labelStatus[self::STATUS_CANCELED] = $langs->transnoentitiesnoconv(
'Disabled');
1266 $statusType =
'status'.$status;
1267 if ($status == self::STATUS_VALIDATED) {
1268 $statusType =
'status4';
1270 if ($status == self::STATUS_CANCELED) {
1271 $statusType =
'status6';
1274 return dolGetStatus($this->labelStatus[$status], $this->labelStatus[$status],
'', $statusType, $mode);
1285 $sql =
'SELECT rowid, date_creation as datec, tms as datem,';
1286 $sql .=
' fk_user_creat, fk_user_modif';
1287 $sql .=
' FROM '.MAIN_DB_PREFIX.$this->table_element.
' as t';
1288 $sql .=
' WHERE t.rowid = '.((int) $id);
1289 $result = $this->db->query($sql);
1291 if ($this->db->num_rows($result)) {
1292 $obj = $this->db->fetch_object($result);
1294 $this->
id = $obj->rowid;
1296 $this->user_creation_id = $obj->fk_user_creat;
1297 $this->user_modification_id = $obj->fk_user_modif;
1298 $this->date_creation = $this->db->jdate($obj->datec);
1299 $this->date_modification = empty($obj->datem) ?
'' : $this->db->jdate($obj->datem);
1302 $this->db->free($result);
1315 $this->lines = array();
1317 $objectline =
new BOMLine($this->db);
1318 $result = $objectline->fetchAll(
'ASC',
'position', 0, 0, array(
'customsql'=>
'fk_bom = '.((
int) $this->
id)));
1320 if (is_numeric($result)) {
1321 $this->error = $objectline->error;
1322 $this->errors = $objectline->errors;
1325 $this->lines = $result;
1326 return $this->lines;
1341 public function generateDocument($modele, $outputlangs, $hidedetails = 0, $hidedesc = 0, $hideref = 0, $moreparams =
null)
1343 global $conf, $langs;
1345 $langs->load(
"mrp");
1346 $outputlangs->load(
"products");
1351 if ($this->model_pdf) {
1352 $modele = $this->model_pdf;
1354 $modele = $conf->global->BOM_ADDON_PDF;
1358 $modelpath =
"core/modules/bom/doc/";
1359 if (!empty($modele)) {
1360 return $this->
commonGenerateDocument($modelpath, $modele, $outputlangs, $hidedetails, $hidedesc, $hideref, $moreparams);
1375 $this->
ref =
'BOM-123';
1376 $this->date_creation =
dol_now() - 20000;
1388 global $conf, $langs;
1404 $this->db->commit();
1417 global $conf, $hookmanager;
1419 include_once DOL_DOCUMENT_ROOT.
'/product/class/product.class.php';
1420 $this->unit_cost = 0;
1421 $this->total_cost = 0;
1423 $parameters=array();
1424 $reshook = $hookmanager->executeHooks(
'calculateCostsBom', $parameters, $this);
1427 return $hookmanager->resPrint;
1430 if (is_array($this->lines) && count($this->lines)) {
1431 require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.product.class.php';
1433 $tmpproduct =
new Product($this->db);
1435 foreach ($this->lines as &$line) {
1436 $tmpproduct->cost_price = 0;
1437 $tmpproduct->pmp = 0;
1438 $result = $tmpproduct->fetch($line->fk_product,
'',
'',
'', 0, 1, 1);
1440 if ($tmpproduct->type == $tmpproduct::TYPE_PRODUCT) {
1441 if (empty($line->fk_bom_child)) {
1443 $this->error = $tmpproduct->error;
1446 $line->unit_cost =
price2num((!empty($tmpproduct->cost_price)) ? $tmpproduct->cost_price : $tmpproduct->pmp);
1447 if (empty($line->unit_cost)) {
1448 if ($productFournisseur->find_min_price_product_fournisseur($line->fk_product) > 0) {
1449 if ($productFournisseur->fourn_remise_percent !=
"0") {
1450 $line->unit_cost = $productFournisseur->fourn_unitprice_with_discount;
1452 $line->unit_cost = $productFournisseur->fourn_unitprice;
1457 $line->total_cost =
price2num($line->qty * $line->unit_cost,
'MT');
1459 $this->total_cost += $line->total_cost;
1461 $bom_child =
new BOM($this->db);
1462 $res = $bom_child->fetch($line->fk_bom_child);
1464 $bom_child->calculateCosts();
1465 $line->childBom[] = $bom_child;
1466 $this->total_cost +=
price2num($bom_child->total_cost * $line->qty,
'MT');
1467 $this->total_cost += $line->total_cost;
1469 $this->error = $bom_child->error;
1478 if (isModEnabled(
'workstation') && !empty($line->fk_default_workstation)) {
1480 $res = $workstation->fetch($line->fk_default_workstation);
1483 $line->total_cost =
price2num($qtyhourforline * ($workstation->thm_operator_estimated + $workstation->thm_machine_estimated),
'MT');
1485 $this->error = $workstation->error;
1489 $defaultdurationofservice = $tmpproduct->duration;
1491 $qtyhourservice = 0;
1492 if (preg_match(
'/^(\d+)([a-z]+)$/', $defaultdurationofservice, $reg)) {
1496 if ($qtyhourservice) {
1497 $line->total_cost =
price2num($qtyhourforline / $qtyhourservice * $tmpproduct->cost_price,
'MT');
1499 $line->total_cost =
price2num($line->qty * $tmpproduct->cost_price,
'MT');
1503 $this->total_cost += $line->total_cost;
1507 $this->total_cost =
price2num($this->total_cost,
'MT');
1509 if ($this->qty > 0) {
1510 $this->unit_cost =
price2num($this->total_cost / $this->qty,
'MU');
1511 } elseif ($this->qty < 0) {
1512 $this->unit_cost =
price2num($this->total_cost * $this->qty,
'MU');
1545 if (!empty($this->lines)) {
1546 foreach ($this->lines as $line) {
1547 if (!empty($line->childBom)) {
1548 foreach ($line->childBom as $childBom) {
1549 $childBom->getNetNeeds($TNetNeeds, $line->qty*$qty);
1552 if (empty($TNetNeeds[$line->fk_product])) {
1553 $TNetNeeds[$line->fk_product] = 0;
1555 $TNetNeeds[$line->fk_product] += $line->qty*$qty;
1571 if (!empty($this->lines)) {
1572 foreach ($this->lines as $line) {
1573 if (!empty($line->childBom)) {
1574 foreach ($line->childBom as $childBom) {
1575 $TNetNeeds[$childBom->id][
'bom'] = $childBom;
1576 $TNetNeeds[$childBom->id][
'parentid'] = $this->id;
1577 $TNetNeeds[$childBom->id][
'qty'] = $line->qty*$qty;
1578 $TNetNeeds[$childBom->id][
'level'] = $level;
1579 $childBom->getNetNeedsTree($TNetNeeds, $line->qty*$qty, $level+1);
1582 $TNetNeeds[$this->id][
'product'][$line->fk_product][
'qty'] += $line->qty * $qty;
1583 $TNetNeeds[$this->id][
'product'][$line->fk_product][
'level'] = $level;
1601 if ($level > 1000) {
1605 if (empty($bom_id)) {
1609 $sql =
'SELECT l.fk_bom, b.label
1610 FROM '.MAIN_DB_PREFIX.
'bom_bomline l
1611 INNER JOIN '.MAIN_DB_PREFIX.$this->table_element.
' b ON b.rowid = l.fk_bom
1612 WHERE fk_bom_child = '.((int) $bom_id);
1614 $resql = $this->db->query($sql);
1615 if (!empty($resql)) {
1616 while ($res = $this->db->fetch_object($resql)) {
1617 $TParentBom[$res->fk_bom] = $res->fk_bom;
1634 $selected = (empty($arraydata[
'selected']) ? 0 : $arraydata[
'selected']);
1636 $return =
'<div class="box-flex-item box-flex-grow-zero">';
1637 $return .=
'<div class="info-box info-box-sm">';
1638 $return .=
'<span class="info-box-icon bg-infobox-action">';
1640 $return .=
'</span>';
1641 $return .=
'<div class="info-box-content">';
1642 $return .=
'<span class="info-box-ref inline-block tdoverflowmax150 valignmiddle">'.(method_exists($this,
'getNomUrl') ? $this->
getNomUrl() :
'').
'</span>';
1643 if ($selected >= 0) {
1644 $return .=
'<input id="cb'.$this->id.
'" class="flat checkforselect fright" type="checkbox" name="toselect[]" value="'.$this->
id.
'"'.($selected ?
' checked="checked"' :
'').
'>';
1646 if (property_exists($this,
'fields') && !empty($this->fields[
'bomtype'][
'arrayofkeyval'])) {
1647 $return .=
'<br><span class="info-box-label opacitymedium">'.$langs->trans(
"Type").
' : </span>';
1648 if ($this->bomtype == 0) {
1649 $return .=
'<span class="info-box-label">'.$this->fields[
'bomtype'][
'arrayofkeyval'][0].
'</span>';
1651 $return .=
'<span class="info-box-label">'.$this->fields[
'bomtype'][
'arrayofkeyval'][1].
'</span>';
1654 if (!empty($arraydata[
'prod'])) {
1655 $prod = $arraydata[
'prod'];
1656 $return .=
'<br><span class="info-box-label">'.$prod->getNomUrl(1).
'</span>';
1658 if (method_exists($this,
'getLibStatut')) {
1659 $return .=
'<br><div class="info-box-status">'.$this->getLibStatut(3).
'</div>';
1662 $return .=
'</div>';
1663 $return .=
'</div>';
1664 $return .=
'</div>';
1678 public $element =
'bomline';
1683 public $table_element =
'bom_bomline';
1688 public $ismultientitymanaged = 0;
1693 public $isextrafieldmanaged = 1;
1698 public $picto =
'bomline';
1724 public $fields = array(
1725 'rowid' => array(
'type'=>
'integer',
'label'=>
'LineID',
'enabled'=>1,
'visible'=>-1,
'position'=>1,
'notnull'=>1,
'index'=>1,
'comment'=>
"Id",),
1726 'fk_bom' => array(
'type'=>
'integer:BillOfMaterials:societe/class/bom.class.php',
'label'=>
'BillOfMaterials',
'enabled'=>1,
'visible'=>1,
'position'=>10,
'notnull'=>1,
'index'=>1,),
1727 'fk_product' => array(
'type'=>
'integer:Product:product/class/product.class.php',
'label'=>
'Product',
'enabled'=>1,
'visible'=>1,
'position'=>20,
'notnull'=>1,
'index'=>1,),
1728 'fk_bom_child' => array(
'type'=>
'integer:BOM:bom/class/bom.class.php',
'label'=>
'BillOfMaterials',
'enabled'=>1,
'visible'=>-1,
'position'=>40,
'notnull'=>-1,),
1729 'description' => array(
'type'=>
'text',
'label'=>
'Description',
'enabled'=>1,
'visible'=>-1,
'position'=>60,
'notnull'=>-1,),
1730 'qty' => array(
'type'=>
'double(24,8)',
'label'=>
'Quantity',
'enabled'=>1,
'visible'=>1,
'position'=>100,
'notnull'=>1,
'isameasure'=>
'1',),
1731 'qty_frozen' => array(
'type'=>
'smallint',
'label'=>
'QuantityFrozen',
'enabled'=>1,
'visible'=>1,
'default'=>0,
'position'=>105,
'css'=>
'maxwidth50imp',
'help'=>
'QuantityConsumedInvariable'),
1732 'disable_stock_change' => array(
'type'=>
'smallint',
'label'=>
'DisableStockChange',
'enabled'=>1,
'visible'=>1,
'default'=>0,
'position'=>108,
'css'=>
'maxwidth50imp',
'help'=>
'DisableStockChangeHelp'),
1733 'efficiency' => array(
'type'=>
'double(24,8)',
'label'=>
'ManufacturingEfficiency',
'enabled'=>1,
'visible'=>0,
'default'=>1,
'position'=>110,
'notnull'=>1,
'css'=>
'maxwidth50imp',
'help'=>
'ValueOfEfficiencyConsumedMeans'),
1734 'fk_unit' => array(
'type'=>
'integer',
'label'=>
'Unit',
'enabled'=>1,
'visible'=>1,
'position'=>120,
'notnull'=>-1,),
1735 'position' => array(
'type'=>
'integer',
'label'=>
'Rank',
'enabled'=>1,
'visible'=>0,
'default'=>0,
'position'=>200,
'notnull'=>1,),
1736 'import_key' => array(
'type'=>
'varchar(14)',
'label'=>
'ImportId',
'enabled'=>1,
'visible'=>-2,
'position'=>1000,
'notnull'=>-1,),
1737 'fk_default_workstation' =>array(
'type'=>
'integer',
'label'=>
'DefaultWorkstation',
'enabled'=>1,
'visible'=>1,
'notnull'=>0,
'position'=>1050)
1758 public $fk_bom_child;
1763 public $description;
1778 public $disable_stock_change;
1799 public $total_cost = 0;
1804 public $unit_cost = 0;
1809 public $childBom = array();
1819 public $fk_default_workstation;
1830 global $conf, $langs;
1834 if (!
getDolGlobalString(
'MAIN_SHOW_TECHNICAL_ID') && isset($this->fields[
'rowid'])) {
1835 $this->fields[
'rowid'][
'visible'] = 0;
1837 if (!isModEnabled(
'multicompany') && isset($this->fields[
'entity'])) {
1838 $this->fields[
'entity'][
'enabled'] = 0;
1842 foreach ($this->fields as $key => $val) {
1843 if (isset($val[
'enabled']) && empty($val[
'enabled'])) {
1844 unset($this->fields[$key]);
1849 foreach ($this->fields as $key => $val) {
1850 if (!empty($val[
'arrayofkeyval']) && is_array($val[
'arrayofkeyval'])) {
1851 foreach ($val[
'arrayofkeyval'] as $key2 => $val2) {
1852 $this->fields[$key][
'arrayofkeyval'][$key2] = $langs->trans($val2);
1867 if ($this->efficiency < 0 || $this->efficiency > 1) {
1868 $this->efficiency = 1;
1899 public function fetchAll($sortorder =
'', $sortfield =
'', $limit = 0, $offset = 0, array $filter = array(), $filtermode =
'AND')
1909 $sql .=
' FROM '.MAIN_DB_PREFIX.$this->table_element.
' as t';
1910 if ($this->ismultientitymanaged) {
1911 $sql .=
' WHERE t.entity IN ('.getEntity($this->element).
')';
1913 $sql .=
' WHERE 1 = 1';
1916 $sqlwhere = array();
1917 if (count($filter) > 0) {
1918 foreach ($filter as $key => $value) {
1919 if ($key ==
't.rowid') {
1920 $sqlwhere[] = $key.
" = ".((int) $value);
1921 } elseif (strpos($key,
'date') !==
false) {
1922 $sqlwhere[] = $key.
" = '".$this->db->idate($value).
"'";
1923 } elseif ($key ==
'customsql') {
1924 $sqlwhere[] = $value;
1926 $sqlwhere[] = $key.
" LIKE '%".$this->db->escape($value).
"%'";
1930 if (count($sqlwhere) > 0) {
1931 $sql .=
' AND ('.implode(
' '.$this->db->escape($filtermode).
' ', $sqlwhere).
')';
1934 if (!empty($sortfield)) {
1935 $sql .= $this->db->order($sortfield, $sortorder);
1937 if (!empty($limit)) {
1938 $sql .= $this->db->plimit($limit, $offset);
1941 $resql = $this->db->query($sql);
1943 $num = $this->db->num_rows($resql);
1945 while ($obj = $this->db->fetch_object($resql)) {
1946 $record =
new self($this->db);
1947 $record->setVarsFromFetchObj($obj);
1949 $records[$record->id] = $record;
1951 $this->db->free($resql);
1955 $this->errors[] =
'Error '.$this->db->lasterror();
1956 dol_syslog(__METHOD__.
' '.join(
',', $this->errors), LOG_ERR);
1971 if ($this->efficiency < 0 || $this->efficiency > 1) {
1972 $this->efficiency = 1;
1985 public function delete(
User $user, $notrigger =
false)
2001 public function getNomUrl($withpicto = 0, $option =
'', $notooltip = 0, $morecss =
'', $save_lastsearch_value = -1)
2003 global $db, $conf, $langs, $hookmanager;
2005 if (!empty($conf->dol_no_mouse_hover)) {
2011 $label =
'<u>'.$langs->trans(
"BillOfMaterialsLine").
'</u>';
2013 $label .=
'<b>'.$langs->trans(
'Ref').
':</b> '.$this->ref;
2015 $url = DOL_URL_ROOT.
'/bom/bomline_card.php?id='.$this->id;
2017 if ($option !=
'nolink') {
2019 $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0);
2020 if ($save_lastsearch_value == -1 && isset($_SERVER[
"PHP_SELF"]) && preg_match(
'/list\.php/', $_SERVER[
"PHP_SELF"])) {
2021 $add_save_lastsearch_values = 1;
2023 if ($add_save_lastsearch_values) {
2024 $url .=
'&save_lastsearch_values=1';
2029 if (empty($notooltip)) {
2031 $label = $langs->trans(
"ShowBillOfMaterialsLine");
2032 $linkclose .=
' alt="'.dol_escape_htmltag($label, 1).
'"';
2034 $linkclose .=
' title="'.dol_escape_htmltag($label, 1).
'"';
2035 $linkclose .=
' class="classfortooltip'.($morecss ?
' '.$morecss :
'').
'"';
2037 $linkclose = ($morecss ?
' class="'.$morecss.
'"' :
'');
2040 $linkstart =
'<a href="'.$url.
'"';
2041 $linkstart .= $linkclose.
'>';
2044 $result .= $linkstart;
2046 $result .=
img_object(($notooltip ?
'' : $label), ($this->picto ? $this->picto :
'generic'), ($notooltip ? (($withpicto != 2) ?
'class="paddingright"' :
'') :
'class="'.(($withpicto != 2) ?
'paddingright ' :
'').
'classfortooltip"'), 0, 0, $notooltip ? 0 : 1);
2048 if ($withpicto != 2) {
2049 $result .= $this->ref;
2051 $result .= $linkend;
2054 global $action, $hookmanager;
2055 $hookmanager->initHooks(array(
'bomlinedao'));
2056 $parameters = array(
'id'=>$this->
id,
'getnomurl' => &$result);
2057 $reshook = $hookmanager->executeHooks(
'getNomUrl', $parameters, $this, $action);
2059 $result = $hookmanager->resPrint;
2061 $result .= $hookmanager->resPrint;
2100 $sql =
'SELECT rowid, date_creation as datec, tms as datem,';
2101 $sql .=
' fk_user_creat, fk_user_modif';
2102 $sql .=
' FROM '.MAIN_DB_PREFIX.$this->table_element.
' as t';
2103 $sql .=
' WHERE t.rowid = '.((int) $id);
2104 $result = $this->db->query($sql);
2106 if ($this->db->num_rows($result)) {
2107 $obj = $this->db->fetch_object($result);
2109 $this->
id = $obj->rowid;
2111 $this->user_creation_id = $obj->fk_user_creat;
2112 $this->user_modification_id = $obj->fk_user_modif;
2113 $this->date_creation = $this->db->jdate($obj->datec);
2114 $this->date_modification = empty($obj->datem) ?
'' : $this->db->jdate($obj->datem);
2116 $this->db->free($result);
print $langs trans("AuditedSecurityEvents").'</strong >< span class="opacitymedium"></span >< br > status
static replaceProduct(DoliDB $db, $origin_id, $dest_id)
Function used to replace a product id with another one.
fetchLines()
Load object lines in memory from the database.
__construct(DoliDB $db)
Constructor.
calculateCosts()
BOM costs calculation based on cost_price or pmp of each BOM line.
info($id)
Load the info information in the object.
getLibStatut($mode=0)
Return label of the status.
initAsSpecimen()
Initialise object with example values Id must be 0 if object instance is a specimen.
validate($user, $notrigger=0)
Validate bom.
reopen($user, $notrigger=0)
Set cancel status.
fetchAll($sortorder='', $sortfield='', $limit=0, $offset=0, array $filter=array(), $filtermode='AND')
Load list of objects in memory from the database.
cancel($user, $notrigger=0)
Set cancel status.
create(User $user, $notrigger=false)
Create object into database.
LibStatut($status, $mode=0)
Return the status.
doScheduledJob()
Action executed by scheduler CAN BE A CRON TASK.
getParentBomTreeRecursive(&$TParentBom, $bom_id=0, $level=1)
Recursively retrieves all parent bom in the tree that leads to the $bom_id bom.
getTooltipContentArray($params)
getTooltipContentArray
fetchLinesbytypeproduct($typeproduct=0)
Load object lines in memory from the database by type of product.
createFromClone(User $user, $fromid)
Clone an object into another one.
fetch($id, $ref=null)
Load object in memory from the database.
getNomUrl($withpicto=0, $option='', $notooltip=0, $morecss='', $save_lastsearch_value=-1)
Return a link to the object card (with optionaly the picto)
updateLine($rowid, $qty, $qty_frozen=0, $disable_stock_change=0, $efficiency=1.0, $position=-1, $import_key=null, $fk_unit=0, $array_options=array(), $fk_default_workstation=null)
Update an BOM line into database.
getNetNeeds(&$TNetNeeds=array(), $qty=0)
Get Net needs by product.
getNextNumRef($prod)
Returns the reference to the following non used BOM depending on the active numbering module defined ...
addLine($fk_product, $qty, $qty_frozen=0, $disable_stock_change=0, $efficiency=1.0, $position=-1, $fk_bom_child=null, $import_key=null, $fk_unit='', $array_options=array(), $fk_default_workstation=null)
Add an BOM line into database (linked to BOM)
generateDocument($modele, $outputlangs, $hidedetails=0, $hidedesc=0, $hideref=0, $moreparams=null)
Create a document onto disk according to template module.
getLinesArray()
Create an array of lines.
setDraft($user, $notrigger=0)
Set draft status.
update(User $user, $notrigger=false)
Update object into database.
getKanbanView($option='', $arraydata=null)
Return clicable link of object (with eventually picto)
deleteLine(User $user, $idline, $notrigger=false)
Delete a line of object in database.
getNetNeedsTree(&$TNetNeeds=array(), $qty=0, $level=0)
Get Net needs Tree by product or bom.
create(User $user, $notrigger=false)
Create object into database.
fetchAll($sortorder='', $sortfield='', $limit=0, $offset=0, array $filter=array(), $filtermode='AND')
Load list of objects in memory from the database.
fetch($id, $ref=null)
Load object in memory from the database.
getLibStatut($mode=0)
Return label of the status.
update(User $user, $notrigger=false)
Update object into database.
__construct(DoliDB $db)
Constructor.
getNomUrl($withpicto=0, $option='', $notooltip=0, $morecss='', $save_lastsearch_value=-1)
Return a link to the object card (with optionaly the picto)
initAsSpecimen()
Initialise object with example values Id must be 0 if object instance is a specimen.
info($id)
Load the info information in the object.
LibStatut($status, $mode=0)
Return the status.
Parent class of all other business classes (invoices, contracts, proposals, orders,...
commonGenerateDocument($modelspath, $modele, $outputlangs, $hidedetails, $hidedesc, $hideref, $moreparams=null)
Common function for all objects extending CommonObject for generating documents.
setErrorsFromObject($object)
setErrorsFromObject
createCommon(User $user, $notrigger=false)
Create object into database.
deleteCommon(User $user, $notrigger=false, $forcechilddeletion=0)
Delete object in database.
getFieldList($alias='', $excludefields=array())
Function to concat keys of fields.
setStatusCommon($user, $status, $notrigger=0, $triggercode='')
Set to a status.
initAsSpecimenCommon()
Initialise object with example values Id must be 0 if object instance is a specimen.
copy_linked_contact($objFrom, $source='internal')
Copy contact from one element to current.
fetch_product()
Load the product with id $this->fk_product into this->product.
updateCommon(User $user, $notrigger=false)
Update object into database.
fetchLinesCommon($morewhere='', $noextrafields=0)
Load object in memory from the database.
static commonReplaceProduct(DoliDB $dbs, $origin_id, $dest_id, array $tables, $ignoreerrors=0)
Function used to replace a product id with another one.
line_max($fk_parent_line=0)
Get max value used for position of line (rang)
fetchCommon($id, $ref=null, $morewhere='', $noextrafields=0)
Load object in memory from the database.
call_trigger($triggerName, $user)
Call trigger based on this instance.
Parent class for class inheritance lines of business objects This class is useless for the moment so ...
Class to manage Dolibarr database access.
Class to manage predefined suppliers products.
Class to manage products or services.
Class to manage Dolibarr users.
convertDurationtoHour($duration_value, $duration_unit)
Convert duration to hour.
dol_dir_list($path, $types="all", $recursive=0, $filter="", $excludefilter=null, $sortcriteria="name", $sortorder=SORT_ASC, $mode=0, $nohook=0, $relativename="", $donotfollowsymlinks=0, $nbsecondsold=0)
Scan a directory and return a list of files/directories.
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
img_object($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0)
Show a picto called object_picto (generic function)
dol_strlen($string, $stringencoding='UTF-8')
Make a strlen call.
dol_now($mode='auto')
Return date for now.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
dol_sanitizeFileName($str, $newstr='_', $unaccent=1)
Clean a string to use it as a file name.
getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
publicphonebutton2 phonegreen basiclayout basiclayout TotalHT VATCode TotalVAT TotalLT1 TotalLT2 TotalTTC TotalHT clearboth nowraponall right right takeposterminal SELECT e e e e e statut
measuringUnitString($unit, $measuring_style='', $scale='', $use_short_label=0, $outputlangs=null)
Return translation label of a unit key.