29require_once DOL_DOCUMENT_ROOT.
'/core/class/commonobject.class.php';
30require_once DOL_DOCUMENT_ROOT.
'/core/class/commonobjectline.class.php';
31require_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
33if (isModEnabled(
'workstation')) {
34 require_once DOL_DOCUMENT_ROOT.
'/workstation/class/workstation.class.php';
49 public $module =
'bom';
54 public $element =
'bom';
59 public $table_element =
'bom_bom';
64 public $picto =
'bom';
71 const STATUS_DRAFT = 0;
72 const STATUS_VALIDATED = 1;
73 const STATUS_CANCELED = 9;
106 public $fields = array(
107 'rowid' => array(
'type' =>
'integer',
'label' =>
'TechnicalID',
'enabled' => 1,
'visible' => -2,
'position' => 1,
'notnull' => 1,
'index' => 1,
'comment' =>
"Id",),
108 'entity' => array(
'type' =>
'integer',
'label' =>
'Entity',
'enabled' => 1,
'visible' => 0,
'notnull' => 1,
'default' => 1,
'index' => 1,
'position' => 5),
109 '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'),
110 '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'),
111 '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'),
113 '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'),
114 'description' => array(
'type' =>
'text',
'label' =>
'Description',
'enabled' => 1,
'visible' => -1,
'position' => 60,
'notnull' => -1,),
115 'qty' => array(
'type' =>
'real',
'label' =>
'Quantity',
'enabled' => 1,
'visible' => 1,
'default' => 1,
'position' => 55,
'notnull' => 1,
'isameasure' => 1,
'css' =>
'maxwidth50imp right'),
117 'duration' => array(
'type' =>
'duration',
'label' =>
'EstimatedDuration',
'enabled' => 1,
'visible' => -1,
'position' => 101,
'notnull' => -1,
'css' =>
'maxwidth50imp',
'help' =>
'EstimatedDurationDesc'),
118 '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'),
119 'note_public' => array(
'type' =>
'html',
'label' =>
'NotePublic',
'enabled' => 1,
'visible' => -2,
'position' => 161,
'notnull' => -1,),
120 'note_private' => array(
'type' =>
'html',
'label' =>
'NotePrivate',
'enabled' => 1,
'visible' => -2,
'position' => 162,
'notnull' => -1,),
121 'date_creation' => array(
'type' =>
'datetime',
'label' =>
'DateCreation',
'enabled' => 1,
'visible' => -2,
'position' => 300,
'notnull' => 1,),
122 'tms' => array(
'type' =>
'timestamp',
'label' =>
'DateModification',
'enabled' => 1,
'visible' => -2,
'position' => 501,
'notnull' => 1,),
123 'date_valid' => array(
'type' =>
'datetime',
'label' =>
'DateValidation',
'enabled' => 1,
'visible' => -2,
'position' => 502,
'notnull' => 0,),
124 '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'),
125 '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'),
126 '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'),
127 'import_key' => array(
'type' =>
'varchar(14)',
'label' =>
'ImportId',
'enabled' => 1,
'visible' => -2,
'position' => 1000,
'notnull' => -1,),
128 'model_pdf' => array(
'type' =>
'varchar(255)',
'label' =>
'Model pdf',
'enabled' => 1,
'visible' => 0,
'position' => 1010),
129 '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')),
160 public $date_creation;
170 public $fk_user_creat;
175 public $fk_user_modif;
180 public $fk_user_valid;
185 public $fk_warehouse;
212 public $table_element_line =
'bom_bomline';
217 public $fk_element =
'fk_bom';
222 public $class_element_line =
'BOMLine';
232 protected $childtablesoncascade = array(
'bom_bomline');
237 public $lines = array();
242 public $total_cost = 0;
247 public $unit_cost = 0;
257 global $conf, $langs;
261 $this->ismultientitymanaged = 1;
262 $this->isextrafieldmanaged = 1;
265 $this->fields[
'rowid'][
'visible'] = 0;
267 if (!isModEnabled(
'multicompany') && isset($this->fields[
'entity'])) {
268 $this->fields[
'entity'][
'enabled'] = 0;
272 foreach ($this->fields as $key => $val) {
273 if (isset($val[
'enabled']) && empty($val[
'enabled'])) {
274 unset($this->fields[$key]);
279 foreach ($this->fields as $key => $val) {
280 if (!empty($val[
'arrayofkeyval']) && is_array($val[
'arrayofkeyval'])) {
281 foreach ($val[
'arrayofkeyval'] as $key2 => $val2) {
282 $this->fields[$key][
'arrayofkeyval'][$key2] = $langs->trans($val2);
297 if ($this->efficiency <= 0 || $this->efficiency > 1) {
298 $this->efficiency = 1;
313 global $langs, $hookmanager, $extrafields;
323 $result =
$object->fetchCommon($fromid);
324 if ($result > 0 && !empty(
$object->table_element_line)) {
338 $object->ref = empty($this->fields[
'ref'][
'default']) ? $langs->trans(
"copy_of_").$object->ref : $this->fields[
'ref'][
'default'];
339 $object->label = empty($this->fields[
'label'][
'default']) ? $langs->trans(
"CopyOf").
" ".
$object->label : $this->fields[
'label'][
'default'];
340 $object->status = self::STATUS_DRAFT;
343 if (is_array(
$object->array_options) && count(
$object->array_options) > 0) {
344 $extrafields->fetch_name_optionals_label(
$object->table_element);
345 foreach (
$object->array_options as $key => $option) {
346 $shortkey = preg_replace(
'/options_/',
'', $key);
347 if (!empty($extrafields->attributes[$this->element][
'unique'][$shortkey])) {
349 unset(
$object->array_options[$key]);
355 $object->context[
'createfromclone'] =
'createfromclone';
356 $result =
$object->createCommon($user);
360 $this->errors =
$object->errors;
372 if (property_exists($this,
'socid') && $this->socid ==
$object->socid) {
383 unset(
$object->context[
'createfromclone']);
390 $this->db->rollback();
402 public function fetch($id, $ref =
null)
406 if ($result > 0 && !empty($this->table_element_line)) {
421 $this->lines = array();
436 $this->lines = array();
438 $objectlineclassname = get_class($this).
'Line';
439 if (!class_exists($objectlineclassname)) {
440 $this->error =
'Error, class '.$objectlineclassname.
' not found during call of fetchLinesCommon';
444 $objectline =
new $objectlineclassname($this->db);
446 $sql =
"SELECT ".$objectline->getFieldList(
'l');
447 $sql .=
" FROM ".$this->db->prefix().$objectline->table_element.
" as l";
448 $sql .=
" LEFT JOIN ".$this->db->prefix().
"product as p ON p.rowid = l.fk_product";
449 $sql .=
" WHERE l.fk_".$this->db->escape($this->element).
" = ".((int) $this->
id);
450 $sql .=
" AND p.fk_product_type = ". ((int) $typeproduct);
451 if (isset($objectline->fields[
'position'])) {
452 $sql .= $this->db->order(
'position',
'ASC');
455 $resql = $this->db->query($sql);
457 $num_rows = $this->db->num_rows($resql);
459 while ($i < $num_rows) {
460 $obj = $this->db->fetch_object($resql);
462 $newline =
new $objectlineclassname($this->db);
463 $newline->setVarsFromFetchObj($obj);
465 $this->lines[] = $newline;
472 $this->error = $this->db->lasterror();
473 $this->errors[] = $this->error;
490 public function fetchAll($sortorder =
'', $sortfield =
'', $limit = 0, $offset = 0, $filter =
'', $filtermode =
'AND')
498 $sql .=
' FROM '.MAIN_DB_PREFIX.$this->table_element.
' as t';
499 if ($this->ismultientitymanaged) {
500 $sql .=
' WHERE t.entity IN ('.getEntity($this->element).
')';
502 $sql .=
' WHERE 1 = 1';
509 $this->errors[] = $errormessage;
510 dol_syslog(__METHOD__.
' '.implode(
',', $this->errors), LOG_ERR);
514 if (!empty($sortfield)) {
515 $sql .= $this->db->order($sortfield, $sortorder);
517 if (!empty($limit)) {
518 $sql .= $this->db->plimit($limit, $offset);
521 $resql = $this->db->query($sql);
523 $num = $this->db->num_rows($resql);
525 while ($obj = $this->db->fetch_object($resql)) {
526 $record =
new self($this->db);
527 $record->setVarsFromFetchObj($obj);
529 $records[$record->id] = $record;
531 $this->db->free($resql);
535 $this->errors[] =
'Error '.$this->db->lasterror();
536 dol_syslog(__METHOD__.
' '.implode(
',', $this->errors), LOG_ERR);
551 if ($this->efficiency <= 0 || $this->efficiency > 1) {
552 $this->efficiency = 1;
565 public function delete(
User $user, $notrigger = 1)
587 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 = 0, $array_options = array(), $fk_default_workstation =
null)
589 global $mysoc, $conf, $langs, $user;
591 $logtext =
"::addLine bomid=$this->id, qty=$qty, fk_product=$fk_product, qty_frozen=$qty_frozen, disable_stock_change=$disable_stock_change, efficiency=$efficiency";
592 $logtext .=
", fk_bom_child=$fk_bom_child, import_key=$import_key";
593 dol_syslog(get_class($this).$logtext, LOG_DEBUG);
595 if ($this->
statut == self::STATUS_DRAFT) {
596 include_once DOL_DOCUMENT_ROOT.
'/core/lib/price.lib.php';
602 if (empty($qty_frozen)) {
605 if (empty($disable_stock_change)) {
606 $disable_stock_change = 0;
608 if (empty($efficiency)) {
611 if (empty($fk_bom_child)) {
612 $fk_bom_child =
null;
614 if (empty($import_key)) {
617 if (empty($position)) {
622 $efficiency = (float)
price2num($efficiency);
623 $position = (float)
price2num($position);
629 $rankToUse = $position;
630 if ($rankToUse <= 0 or $rankToUse > $rangMax) {
631 $rankToUse = $rangMax + 1;
633 foreach ($this->lines as $bl) {
634 if ($bl->position >= $rankToUse) {
642 $line =
new BOMLine($this->db);
644 $line->context = $this->context;
646 $line->fk_bom = $this->id;
647 $line->fk_product = $fk_product;
649 $line->qty_frozen = $qty_frozen;
650 $line->disable_stock_change = $disable_stock_change;
651 $line->efficiency = $efficiency;
652 $line->fk_bom_child = $fk_bom_child;
653 $line->import_key = $import_key;
654 $line->position = $rankToUse;
655 $line->fk_unit = $fk_unit;
656 $line->fk_default_workstation = $fk_default_workstation;
658 if (is_array($array_options) && count($array_options) > 0) {
659 $line->array_options = $array_options;
662 $result = $line->create($user);
670 dol_syslog(get_class($this).
"::addLine error=".$this->error, LOG_ERR);
671 $this->db->rollback();
675 dol_syslog(get_class($this).
"::addLine status of BOM must be Draft to allow use of ->addLine()", LOG_ERR);
695 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)
699 $logtext =
"::updateLine bomid=$this->id, qty=$qty, qty_frozen=$qty_frozen, disable_stock_change=$disable_stock_change, efficiency=$efficiency";
700 $logtext .=
", import_key=$import_key";
701 dol_syslog(get_class($this).$logtext, LOG_DEBUG);
703 if ($this->
statut == self::STATUS_DRAFT) {
704 include_once DOL_DOCUMENT_ROOT.
'/core/lib/price.lib.php';
710 if (empty($qty_frozen)) {
713 if (empty($disable_stock_change)) {
714 $disable_stock_change = 0;
716 if (empty($efficiency)) {
719 if (empty($import_key)) {
722 if (empty($position)) {
727 $efficiency = (float)
price2num($efficiency);
728 $position = (float)
price2num($position);
733 $line =
new BOMLine($this->db);
734 $line->fetch($rowid);
735 $line->fetch_optionals();
737 $staticLine = clone $line;
738 $line->oldcopy = $staticLine;
739 $line->context = $this->context;
742 $rankToUse = (int) $position;
743 if ($rankToUse != $line->oldcopy->position) {
744 foreach ($this->lines as $bl) {
745 if ($bl->position >= $rankToUse and $bl->position < ($line->oldcopy->position + 1)) {
749 if ($bl->position <= $rankToUse and $bl->position > ($line->oldcopy->position)) {
757 $line->fk_bom = $this->id;
759 $line->qty_frozen = $qty_frozen;
760 $line->disable_stock_change = $disable_stock_change;
761 $line->efficiency = $efficiency;
762 $line->import_key = $import_key;
763 $line->position = $rankToUse;
766 if (!empty($fk_unit)) {
767 $line->fk_unit = $fk_unit;
771 if (is_array($array_options) && count($array_options) > 0) {
773 foreach ($array_options as $key => $value) {
774 $line->array_options[$key] = $array_options[$key];
777 if ($line->fk_default_workstation != $fk_default_workstation) {
778 $line->fk_default_workstation = ($fk_default_workstation > 0 ? $fk_default_workstation : 0);
781 $result = $line->update($user);
789 dol_syslog(get_class($this).
"::addLine error=".$this->error, LOG_ERR);
790 $this->db->rollback();
794 dol_syslog(get_class($this).
"::addLine status of BOM must be Draft to allow use of ->addLine()", LOG_ERR);
810 $this->error =
'ErrorDeleteLineNotAllowedByObjectStatus';
817 $line =
new BOMLine($this->db);
818 $line->fetch($idline);
819 $line->fetch_optionals();
821 $staticLine = clone $line;
822 $line->oldcopy = $staticLine;
823 $line->context = $this->context;
825 $result = $line->delete($user, $notrigger);
828 foreach ($this->lines as $bl) {
829 if ($bl->position > ($line->oldcopy->position)) {
841 dol_syslog(get_class($this).
"::addLine error=".$this->error, LOG_ERR);
842 $this->db->rollback();
856 global $langs, $conf;
866 $dirmodels = array_merge(array(
'/'), (array) $conf->modules_parts[
'models']);
867 foreach ($dirmodels as $reldir) {
871 $mybool = ((bool) @include_once $dir.$file) || $mybool;
874 if ($mybool ===
false) {
879 $obj =
new $classname();
880 $numref = $obj->getNextValue($prod, $this);
885 $this->error = $obj->error;
890 print $langs->trans(
"Error").
" ".$langs->trans(
"Error_BOM_ADDON_NotDefined");
906 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
911 if ($this->
status == self::STATUS_VALIDATED) {
912 dol_syslog(get_class($this).
"::validate action abandoned: already validated", LOG_WARNING);
921 if (!$error && (preg_match(
'/^[\(]?PROV/i', $this->
ref) || empty($this->
ref))) {
930 $sql =
"UPDATE ".MAIN_DB_PREFIX.$this->table_element;
931 $sql .=
" SET ref = '".$this->db->escape($num).
"',";
932 $sql .=
" status = ".self::STATUS_VALIDATED.
",";
933 $sql .=
" date_valid='".$this->db->idate($now).
"',";
934 $sql .=
" fk_user_valid = ".((int) $user->id);
935 $sql .=
" WHERE rowid = ".((int) $this->
id);
937 dol_syslog(get_class($this).
"::validate()", LOG_DEBUG);
938 $resql = $this->db->query($sql);
941 $this->error = $this->db->lasterror();
945 if (!$error && !$notrigger) {
955 $this->oldref = $this->ref;
958 if (preg_match(
'/^[\(]?PROV/i', $this->
ref)) {
960 $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).
"'";
961 $sql .=
" WHERE filename LIKE '".$this->db->escape($this->
ref).
"%' AND filepath = 'bom/".$this->db->escape($this->
ref).
"' and entity = ".$conf->entity;
962 $resql = $this->db->query($sql);
965 $this->error = $this->db->lasterror();
967 $sql =
'UPDATE '.MAIN_DB_PREFIX.
"ecm_files set filepath = 'bom/".$this->db->escape($this->newref).
"'";
968 $sql .=
" WHERE filepath = 'bom/".$this->db->escape($this->
ref).
"' and entity = ".$conf->entity;
969 $resql = $this->db->query($sql);
972 $this->error = $this->db->lasterror();
978 $dirsource = $conf->bom->dir_output.
'/'.$oldref;
979 $dirdest = $conf->bom->dir_output.
'/'.$newref;
980 if (!$error && file_exists($dirsource)) {
981 dol_syslog(get_class($this).
"::validate() rename dir ".$dirsource.
" into ".$dirdest);
983 if (@rename($dirsource, $dirdest)) {
986 $listoffiles =
dol_dir_list($conf->bom->dir_output.
'/'.$newref,
'files', 1,
'^'.preg_quote($oldref,
'/'));
987 foreach ($listoffiles as $fileentry) {
988 $dirsource = $fileentry[
'name'];
989 $dirdest = preg_replace(
'/^'.preg_quote($oldref,
'/').
'/', $newref, $dirsource);
990 $dirsource = $fileentry[
'path'].
'/'.$dirsource;
991 $dirdest = $fileentry[
'path'].
'/'.$dirdest;
992 @rename($dirsource, $dirdest);
1002 $this->
status = self::STATUS_VALIDATED;
1006 $this->db->commit();
1009 $this->db->rollback();
1024 if ($this->
status <= self::STATUS_DRAFT) {
1028 return $this->
setStatusCommon($user, self::STATUS_DRAFT, $notrigger,
'BOM_UNVALIDATE');
1038 public function cancel($user, $notrigger = 0)
1041 if ($this->
status != self::STATUS_VALIDATED) {
1045 return $this->
setStatusCommon($user, self::STATUS_CANCELED, $notrigger,
'BOM_CLOSE');
1055 public function reopen($user, $notrigger = 0)
1058 if ($this->
status != self::STATUS_CANCELED) {
1062 return $this->
setStatusCommon($user, self::STATUS_VALIDATED, $notrigger,
'BOM_REOPEN');
1073 global $conf, $langs, $user;
1075 $langs->loadLangs([
'product',
'mrp']);
1080 return [
'optimize' => $langs->trans(
"ShowBillOfMaterials")];
1082 $picto =
img_picto(
'', $this->picto).
' <u class="paddingrightonly">'.$langs->trans(
"BillOfMaterials").
'</u>';
1083 if (isset($this->
status)) {
1084 $picto .=
' '.$this->getLibStatut(5);
1086 $datas[
'picto'] = $picto;
1087 $datas[
'ref'] =
'<br><b>'.$langs->trans(
'Ref').
':</b> '.$this->ref;
1088 if (isset($this->label)) {
1089 $datas[
'label'] =
'<br><b>'.$langs->trans(
'Label').
':</b> '.$this->label;
1091 if (!empty($this->fk_product) && $this->fk_product > 0) {
1092 include_once DOL_DOCUMENT_ROOT.
'/product/class/product.class.php';
1093 $product =
new Product($this->db);
1094 $resultFetch = $product->fetch($this->fk_product);
1095 if ($resultFetch > 0) {
1096 $datas[
'product'] =
"<br><b>".$langs->trans(
"Product").
'</b>: '.$product->ref.
' - '.$product->label;
1113 public function getNomUrl($withpicto = 0, $option =
'', $notooltip = 0, $morecss =
'', $save_lastsearch_value = -1)
1115 global $db, $conf, $langs, $hookmanager;
1117 if (!empty($conf->dol_no_mouse_hover)) {
1124 'objecttype' => $this->element,
1125 'option' => $option,
1127 $classfortooltip =
'classfortooltip';
1130 $classfortooltip =
'classforajaxtooltip';
1131 $dataparams =
' data-params="'.dol_escape_htmltag(json_encode($params)).
'"';
1137 $url = DOL_URL_ROOT.
'/bom/bom_card.php?id='.$this->id;
1139 if ($option !=
'nolink') {
1141 $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0);
1142 if ($save_lastsearch_value == -1 && isset($_SERVER[
"PHP_SELF"]) && preg_match(
'/list\.php/', $_SERVER[
"PHP_SELF"])) {
1143 $add_save_lastsearch_values = 1;
1145 if ($add_save_lastsearch_values) {
1146 $url .=
'&save_lastsearch_values=1';
1151 if (empty($notooltip)) {
1153 $label = $langs->trans(
"ShowBillOfMaterials");
1154 $linkclose .=
' alt="'.dol_escape_htmltag($label, 1).
'"';
1156 $linkclose .= ($label ?
' title="'.dol_escape_htmltag($label, 1).
'"' :
' title="tocomplete"');
1157 $linkclose .= $dataparams.
' class="'.$classfortooltip.($morecss ?
' '.$morecss :
'').
'"';
1159 $linkclose = ($morecss ?
' class="'.$morecss.
'"' :
'');
1162 $linkstart =
'<a href="'.$url.
'"';
1163 $linkstart .= $linkclose.
'>';
1166 $result .= $linkstart;
1168 $result .=
img_object(($notooltip ?
'' : $label), ($this->picto ? $this->picto :
'generic'), (($withpicto != 2) ?
'class="paddingright"' :
''), 0, 0, $notooltip ? 0 : 1);
1170 if ($withpicto != 2) {
1171 $result .= $this->ref;
1173 $result .= $linkend;
1176 global $action, $hookmanager;
1177 $hookmanager->initHooks(array(
'bomdao'));
1178 $parameters = array(
'id' => $this->
id,
'getnomurl' => &$result);
1179 $reshook = $hookmanager->executeHooks(
'getNomUrl', $parameters, $this, $action);
1181 $result = $hookmanager->resPrint;
1183 $result .= $hookmanager->resPrint;
1211 if (empty($this->labelStatus)) {
1214 $this->labelStatus[self::STATUS_DRAFT] = $langs->transnoentitiesnoconv(
'Draft');
1215 $this->labelStatus[self::STATUS_VALIDATED] = $langs->transnoentitiesnoconv(
'Enabled');
1216 $this->labelStatus[self::STATUS_CANCELED] = $langs->transnoentitiesnoconv(
'Disabled');
1219 $statusType =
'status'.$status;
1220 if ($status == self::STATUS_VALIDATED) {
1221 $statusType =
'status4';
1223 if ($status == self::STATUS_CANCELED) {
1224 $statusType =
'status6';
1227 return dolGetStatus($this->labelStatus[$status], $this->labelStatus[$status],
'', $statusType, $mode);
1238 $sql =
'SELECT rowid, date_creation as datec, tms as datem,';
1239 $sql .=
' fk_user_creat, fk_user_modif';
1240 $sql .=
' FROM '.MAIN_DB_PREFIX.$this->table_element.
' as t';
1241 $sql .=
' WHERE t.rowid = '.((int) $id);
1242 $result = $this->db->query($sql);
1244 if ($this->db->num_rows($result)) {
1245 $obj = $this->db->fetch_object($result);
1247 $this->
id = $obj->rowid;
1249 $this->user_creation_id = $obj->fk_user_creat;
1250 $this->user_modification_id = $obj->fk_user_modif;
1251 $this->date_creation = $this->db->jdate($obj->datec);
1252 $this->date_modification = empty($obj->datem) ?
'' : $this->db->jdate($obj->datem);
1255 $this->db->free($result);
1268 $this->lines = array();
1270 $objectline =
new BOMLine($this->db);
1271 $result = $objectline->fetchAll(
'ASC',
'position', 0, 0,
'(fk_bom:=:'.((
int) $this->
id).
')');
1273 if (is_numeric($result)) {
1274 $this->error = $objectline->error;
1275 $this->errors = $objectline->errors;
1278 $this->lines = $result;
1279 return $this->lines;
1294 public function generateDocument($modele, $outputlangs, $hidedetails = 0, $hidedesc = 0, $hideref = 0, $moreparams =
null)
1296 global $conf, $langs;
1298 $langs->load(
"mrp");
1299 $outputlangs->load(
"products");
1304 if ($this->model_pdf) {
1305 $modele = $this->model_pdf;
1311 $modelpath =
"core/modules/bom/doc/";
1312 if (!empty($modele)) {
1313 return $this->
commonGenerateDocument($modelpath, $modele, $outputlangs, $hidedetails, $hidedesc, $hideref, $moreparams);
1329 include_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
1330 include_once DOL_DOCUMENT_ROOT.
'/core/lib/images.lib.php';
1332 $sdir .=
'/'.get_exdir(0, 0, 0, 0, $this,
'bom');
1335 if (file_exists($dir_osencoded)) {
1336 $handle = opendir($dir_osencoded);
1337 if (is_resource($handle)) {
1338 while (($file = readdir($handle)) !==
false) {
1340 $file = mb_convert_encoding($file,
'UTF-8',
'ISO-8859-1');
1360 $this->
ref =
'BOM-123';
1361 $this->date_creation =
dol_now() - 20000;
1375 global $conf, $langs;
1391 $this->db->commit();
1404 global $conf, $hookmanager;
1406 include_once DOL_DOCUMENT_ROOT.
'/product/class/product.class.php';
1407 $this->unit_cost = 0;
1408 $this->total_cost = 0;
1410 $parameters = array();
1411 $reshook = $hookmanager->executeHooks(
'calculateCostsBom', $parameters, $this);
1414 return $hookmanager->resPrint;
1417 if (is_array($this->lines) && count($this->lines)) {
1418 require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.product.class.php';
1420 $tmpproduct =
new Product($this->db);
1422 foreach ($this->lines as &$line) {
1423 $tmpproduct->cost_price = 0;
1424 $tmpproduct->pmp = 0;
1425 $result = $tmpproduct->fetch($line->fk_product,
'',
'',
'', 0, 1, 1);
1427 if ($tmpproduct->type == $tmpproduct::TYPE_PRODUCT) {
1428 if (empty($line->fk_bom_child)) {
1430 $this->error = $tmpproduct->error;
1434 $unit_cost = is_null($tmpproduct->cost_price) ? $tmpproduct->pmp : $tmpproduct->cost_price;
1435 if (is_null($unit_cost)) {
1436 if ($productFournisseur->find_min_price_product_fournisseur($line->fk_product) > 0) {
1437 if ($productFournisseur->fourn_remise_percent !=
"0") {
1438 $line->unit_cost = $productFournisseur->fourn_unitprice_with_discount;
1440 $line->unit_cost = $productFournisseur->fourn_unitprice;
1443 $line->unit_cost = 0;
1446 $line->unit_cost = (float)
price2num($unit_cost);
1449 $line->total_cost = (float)
price2num($line->qty * $line->unit_cost,
'MT');
1451 $this->total_cost += $line->total_cost;
1453 $bom_child =
new BOM($this->db);
1454 $res = $bom_child->fetch($line->fk_bom_child);
1456 $bom_child->calculateCosts();
1457 $line->childBom[] = $bom_child;
1458 $this->total_cost += (float)
price2num($bom_child->total_cost * $line->qty,
'MT');
1459 $this->total_cost += $line->total_cost;
1461 $this->error = $bom_child->error;
1470 if (isModEnabled(
'workstation') && !empty($line->fk_default_workstation)) {
1472 $res = $workstation->fetch($line->fk_default_workstation);
1475 $line->total_cost = (float)
price2num($qtyhourforline * ($workstation->thm_operator_estimated + $workstation->thm_machine_estimated),
'MT');
1477 $this->error = $workstation->error;
1481 $defaultdurationofservice = $tmpproduct->duration;
1483 $qtyhourservice = 0;
1484 if (preg_match(
'/^(\d+)([a-z]+)$/', $defaultdurationofservice, $reg)) {
1488 if ($qtyhourservice) {
1489 $line->total_cost = (float)
price2num($qtyhourforline / $qtyhourservice * $tmpproduct->cost_price,
'MT');
1491 $line->total_cost = (float)
price2num($line->qty * $tmpproduct->cost_price,
'MT');
1495 $this->total_cost += $line->total_cost;
1499 $this->total_cost = (float)
price2num($this->total_cost,
'MT');
1501 if ($this->qty > 0) {
1502 $this->unit_cost = (float)
price2num($this->total_cost / $this->qty,
'MU');
1503 } elseif ($this->qty < 0) {
1504 $this->unit_cost = (float)
price2num($this->total_cost * $this->qty,
'MU');
1537 if (!empty($this->lines)) {
1538 foreach ($this->lines as $line) {
1539 if (!empty($line->childBom)) {
1540 foreach ($line->childBom as $childBom) {
1541 $childBom->getNetNeeds($TNetNeeds, $line->qty * $qty);
1544 if (empty($TNetNeeds[$line->fk_product][
'qty'])) {
1545 $TNetNeeds[$line->fk_product][
'qty'] = 0.0;
1549 $TNetNeeds[$line->fk_product][
'fk_unit'] = $line->fk_unit;
1550 $TNetNeeds[$line->fk_product][
'qty'] += $line->qty * $qty;
1566 if (!empty($this->lines)) {
1567 foreach ($this->lines as $line) {
1568 if (!empty($line->childBom)) {
1569 foreach ($line->childBom as $childBom) {
1570 $TNetNeeds[$childBom->id][
'bom'] = $childBom;
1571 $TNetNeeds[$childBom->id][
'parentid'] = $this->id;
1575 $TNetNeeds[$childBom->id][
'qty'] = $line->qty * $qty;
1576 $TNetNeeds[$childBom->id][
'level'] = $level;
1577 $childBom->getNetNeedsTree($TNetNeeds, $line->qty * $qty, $level + 1);
1582 if (!isset($TNetNeeds[$this->
id][
'product'])) {
1583 $TNetNeeds[$this->id][
'product'] = array();
1585 if (!isset($TNetNeeds[$this->
id][
'product'][$line->fk_product])) {
1586 $TNetNeeds[$this->id][
'product'][$line->fk_product] = array();
1588 $TNetNeeds[$this->id][
'product'][$line->fk_product][
'fk_unit'] = $line->fk_unit;
1589 if (!isset($TNetNeeds[$this->
id][
'product'][$line->fk_product][
'qty'])) {
1590 $TNetNeeds[$this->id][
'product'][$line->fk_product][
'qty'] = 0.0;
1592 $TNetNeeds[$this->id][
'product'][$line->fk_product][
'qty'] += $line->qty * $qty;
1593 $TNetNeeds[$this->id][
'product'][$line->fk_product][
'level'] = $level;
1611 if ($level > 1000) {
1615 if (empty($bom_id)) {
1616 $bom_id = $this->id;
1619 $sql =
'SELECT l.fk_bom, b.label
1620 FROM '.MAIN_DB_PREFIX.
'bom_bomline l
1621 INNER JOIN '.MAIN_DB_PREFIX.$this->table_element.
' b ON b.rowid = l.fk_bom
1622 WHERE fk_bom_child = '.((int) $bom_id);
1624 $resql = $this->db->query($sql);
1625 if (!empty($resql)) {
1626 while ($res = $this->db->fetch_object($resql)) {
1627 $TParentBom[$res->fk_bom] = $res->fk_bom;
1644 $selected = (empty($arraydata[
'selected']) ? 0 : $arraydata[
'selected']);
1646 $return =
'<div class="box-flex-item box-flex-grow-zero">';
1647 $return .=
'<div class="info-box info-box-sm">';
1648 $return .=
'<span class="info-box-icon bg-infobox-action">';
1650 $return .=
'</span>';
1651 $return .=
'<div class="info-box-content">';
1652 $return .=
'<span class="info-box-ref inline-block tdoverflowmax150 valignmiddle">'.(method_exists($this,
'getNomUrl') ? $this->
getNomUrl() :
'').
'</span>';
1653 if ($selected >= 0) {
1654 $return .=
'<input id="cb'.$this->id.
'" class="flat checkforselect fright" type="checkbox" name="toselect[]" value="'.$this->
id.
'"'.($selected ?
' checked="checked"' :
'').
'>';
1656 if (property_exists($this,
'fields') && !empty($this->fields[
'bomtype'][
'arrayofkeyval'])) {
1657 $return .=
'<br><span class="info-box-label opacitymedium">'.$langs->trans(
"Type").
' : </span>';
1658 if ($this->bomtype == 0) {
1659 $return .=
'<span class="info-box-label">'.$this->fields[
'bomtype'][
'arrayofkeyval'][0].
'</span>';
1661 $return .=
'<span class="info-box-label">'.$this->fields[
'bomtype'][
'arrayofkeyval'][1].
'</span>';
1664 if (!empty($arraydata[
'prod'])) {
1665 $prod = $arraydata[
'prod'];
1666 $return .=
'<br><span class="info-box-label">'.$prod->getNomUrl(1).
'</span>';
1668 if (method_exists($this,
'getLibStatut')) {
1669 $return .=
'<br><div class="info-box-status">'.$this->getLibStatut(3).
'</div>';
1672 $return .=
'</div>';
1673 $return .=
'</div>';
1674 $return .=
'</div>';
1688 public $element =
'bomline';
1693 public $table_element =
'bom_bomline';
1708 public $picto =
'bomline';
1734 public $fields = array(
1735 'rowid' => array(
'type' =>
'integer',
'label' =>
'LineID',
'enabled' => 1,
'visible' => -1,
'position' => 1,
'notnull' => 1,
'index' => 1,
'comment' =>
"Id",),
1736 'fk_bom' => array(
'type' =>
'integer:BillOfMaterials:societe/class/bom.class.php',
'label' =>
'BillOfMaterials',
'enabled' => 1,
'visible' => 1,
'position' => 10,
'notnull' => 1,
'index' => 1,),
1737 'fk_product' => array(
'type' =>
'integer:Product:product/class/product.class.php',
'label' =>
'Product',
'enabled' => 1,
'visible' => 1,
'position' => 20,
'notnull' => 1,
'index' => 1,),
1738 'fk_bom_child' => array(
'type' =>
'integer:BOM:bom/class/bom.class.php',
'label' =>
'BillOfMaterials',
'enabled' => 1,
'visible' => -1,
'position' => 40,
'notnull' => -1,),
1739 'description' => array(
'type' =>
'text',
'label' =>
'Description',
'enabled' => 1,
'visible' => -1,
'position' => 60,
'notnull' => -1,),
1740 'qty' => array(
'type' =>
'double(24,8)',
'label' =>
'Quantity',
'enabled' => 1,
'visible' => 1,
'position' => 100,
'notnull' => 1,
'isameasure' => 1,),
1741 'qty_frozen' => array(
'type' =>
'smallint',
'label' =>
'QuantityFrozen',
'enabled' => 1,
'visible' => 1,
'default' =>
'0',
'position' => 105,
'css' =>
'maxwidth50imp',
'help' =>
'QuantityConsumedInvariable'),
1742 'disable_stock_change' => array(
'type' =>
'smallint',
'label' =>
'DisableStockChange',
'enabled' => 1,
'visible' => 1,
'default' =>
'0',
'position' => 108,
'css' =>
'maxwidth50imp',
'help' =>
'DisableStockChangeHelp'),
1743 'efficiency' => array(
'type' =>
'double(24,8)',
'label' =>
'ManufacturingEfficiency',
'enabled' => 1,
'visible' => 0,
'default' =>
'1',
'position' => 110,
'notnull' => 1,
'css' =>
'maxwidth50imp',
'help' =>
'ValueOfEfficiencyConsumedMeans'),
1744 'fk_unit' => array(
'type' =>
'integer',
'label' =>
'Unit',
'enabled' => 1,
'visible' => 1,
'position' => 120,
'notnull' => -1,),
1745 'position' => array(
'type' =>
'integer',
'label' =>
'Rank',
'enabled' => 1,
'visible' => 0,
'default' =>
'0',
'position' => 200,
'notnull' => 1,),
1746 'import_key' => array(
'type' =>
'varchar(14)',
'label' =>
'ImportId',
'enabled' => 1,
'visible' => -2,
'position' => 1000,
'notnull' => -1,),
1747 'fk_default_workstation' => array(
'type' =>
'integer',
'label' =>
'DefaultWorkstation',
'enabled' => 1,
'visible' => 1,
'notnull' => 0,
'position' => 1050)
1768 public $fk_bom_child;
1773 public $description;
1788 public $disable_stock_change;
1805 public $fk_default_workstation;
1821 public $total_cost = 0;
1826 public $unit_cost = 0;
1831 public $childBom = array();
1846 $this->ismultientitymanaged = 0;
1848 $this->isextrafieldmanaged = 1;
1850 if (!
getDolGlobalString(
'MAIN_SHOW_TECHNICAL_ID') && isset($this->fields[
'rowid'])) {
1851 $this->fields[
'rowid'][
'visible'] = 0;
1853 if (!isModEnabled(
'multicompany') && isset($this->fields[
'entity'])) {
1854 $this->fields[
'entity'][
'enabled'] = 0;
1858 foreach ($this->fields as $key => $val) {
1859 if (isset($val[
'enabled']) && empty($val[
'enabled'])) {
1860 unset($this->fields[$key]);
1865 foreach ($this->fields as $key => $val) {
1866 if (!empty($val[
'arrayofkeyval']) && is_array($val[
'arrayofkeyval'])) {
1867 foreach ($val[
'arrayofkeyval'] as $key2 => $val2) {
1868 $this->fields[$key][
'arrayofkeyval'][$key2] = $langs->trans($val2);
1883 if ($this->efficiency < 0 || $this->efficiency > 1) {
1884 $this->efficiency = 1;
1916 public function fetchAll($sortorder =
'', $sortfield =
'', $limit = 0, $offset = 0, $filter =
'', $filtermode =
'AND')
1924 $sql .=
' FROM '.MAIN_DB_PREFIX.$this->table_element.
' as t';
1925 if ($this->ismultientitymanaged) {
1926 $sql .=
' WHERE t.entity IN ('.getEntity($this->element).
')';
1928 $sql .=
' WHERE 1 = 1';
1934 if ($errormessage) {
1935 $this->errors[] = $errormessage;
1936 dol_syslog(__METHOD__.
' '.implode(
',', $this->errors), LOG_ERR);
1940 if (!empty($sortfield)) {
1941 $sql .= $this->db->order($sortfield, $sortorder);
1943 if (!empty($limit)) {
1944 $sql .= $this->db->plimit($limit, $offset);
1947 $resql = $this->db->query($sql);
1949 $num = $this->db->num_rows($resql);
1951 while ($obj = $this->db->fetch_object($resql)) {
1952 $record =
new self($this->db);
1953 $record->setVarsFromFetchObj($obj);
1954 $record->fetch_optionals();
1956 $records[$record->id] = $record;
1958 $this->db->free($resql);
1962 $this->errors[] =
'Error '.$this->db->lasterror();
1963 dol_syslog(__METHOD__.
' '.implode(
',', $this->errors), LOG_ERR);
1978 if ($this->efficiency < 0 || $this->efficiency > 1) {
1979 $this->efficiency = 1;
1992 public function delete(
User $user, $notrigger = 0)
2008 public function getNomUrl($withpicto = 0, $option =
'', $notooltip = 0, $morecss =
'', $save_lastsearch_value = -1)
2010 global $db, $conf, $langs, $hookmanager;
2012 if (!empty($conf->dol_no_mouse_hover)) {
2018 $label =
'<u>'.$langs->trans(
"BillOfMaterialsLine").
'</u>';
2020 $label .=
'<b>'.$langs->trans(
'Ref').
':</b> '.$this->ref;
2022 $url = DOL_URL_ROOT.
'/bom/bomline_card.php?id='.$this->id;
2024 if ($option !=
'nolink') {
2026 $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0);
2027 if ($save_lastsearch_value == -1 && isset($_SERVER[
"PHP_SELF"]) && preg_match(
'/list\.php/', $_SERVER[
"PHP_SELF"])) {
2028 $add_save_lastsearch_values = 1;
2030 if ($add_save_lastsearch_values) {
2031 $url .=
'&save_lastsearch_values=1';
2036 if (empty($notooltip)) {
2038 $label = $langs->trans(
"ShowBillOfMaterialsLine");
2039 $linkclose .=
' alt="'.dol_escape_htmltag($label, 1).
'"';
2041 $linkclose .=
' title="'.dol_escape_htmltag($label, 1).
'"';
2042 $linkclose .=
' class="classfortooltip'.($morecss ?
' '.$morecss :
'').
'"';
2044 $linkclose = ($morecss ?
' class="'.$morecss.
'"' :
'');
2047 $linkstart =
'<a href="'.$url.
'"';
2048 $linkstart .= $linkclose.
'>';
2051 $result .= $linkstart;
2053 $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);
2055 if ($withpicto != 2) {
2056 $result .= $this->ref;
2058 $result .= $linkend;
2061 global $action, $hookmanager;
2062 $hookmanager->initHooks(array(
'bomlinedao'));
2063 $parameters = array(
'id' => $this->
id,
'getnomurl' => &$result);
2064 $reshook = $hookmanager->executeHooks(
'getNomUrl', $parameters, $this, $action);
2066 $result = $hookmanager->resPrint;
2068 $result .= $hookmanager->resPrint;
2107 $sql =
'SELECT rowid, date_creation as datec, tms as datem,';
2108 $sql .=
' fk_user_creat, fk_user_modif';
2109 $sql .=
' FROM '.MAIN_DB_PREFIX.$this->table_element.
' as t';
2110 $sql .=
' WHERE t.rowid = '.((int) $id);
2111 $result = $this->db->query($sql);
2113 if ($this->db->num_rows($result)) {
2114 $obj = $this->db->fetch_object($result);
2116 $this->
id = $obj->rowid;
2118 $this->user_creation_id = $obj->fk_user_creat;
2119 $this->user_modification_id = $obj->fk_user_modif;
2120 $this->date_creation = $this->db->jdate($obj->datec);
2121 $this->date_modification = empty($obj->datem) ?
'' : $this->db->jdate($obj->datem);
2123 $this->db->free($result);
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
print $langs trans("AuditedSecurityEvents").'</strong >< span class="opacitymedium"></span >< br > status
Or an array listing all the potential status of the object: array: int of the status => translated la...
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.
is_photo_available($sdir)
Return if at least one photo is available.
__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.
create(User $user, $notrigger=0)
Create object into database.
validate($user, $notrigger=0)
Validate bom.
reopen($user, $notrigger=0)
Set cancel status.
cancel($user, $notrigger=0)
Set cancel status.
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.
deleteLine(User $user, $idline, $notrigger=0)
Delete a line of object in database.
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 optionally 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.
update(User $user, $notrigger=0)
Update object into database.
getNextNumRef($prod)
Returns the reference to the following non used BOM depending on the active numbering module defined ...
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.
getKanbanView($option='', $arraydata=null)
Return clicable link of object (with eventually picto)
fetchAll($sortorder='', $sortfield='', $limit=0, $offset=0, $filter='', $filtermode='AND')
Load list of objects in memory from the database.
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=0, $array_options=array(), $fk_default_workstation=null)
Add an BOM line into database (linked to BOM)
getNetNeedsTree(&$TNetNeeds=array(), $qty=0, $level=0)
Get/add Net needs Tree by product or bom.
fetch($id, $ref=null)
Load object in memory from the database.
getLibStatut($mode=0)
Return label of the status.
__construct(DoliDB $db)
Constructor.
update(User $user, $notrigger=0)
Update object into database.
fetchAll($sortorder='', $sortfield='', $limit=0, $offset=0, $filter='', $filtermode='AND')
Load list of objects in memory from the database.
getNomUrl($withpicto=0, $option='', $notooltip=0, $morecss='', $save_lastsearch_value=-1)
Return a link to the object card (with optionally 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.
create(User $user, $notrigger=0)
Create object into database.
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=0)
Create object in the database.
getFieldList($alias='', $excludefields=array())
Function to concat keys of fields.
updateCommon(User $user, $notrigger=0)
Update object into database.
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.
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.
deleteCommon(User $user, $notrigger=0, $forcechilddeletion=0)
Delete object in 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_is_file($pathoffile)
Return if path is a file.
dol_dir_list($utf8_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.
img_object($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0)
Show a picto called object_picto (generic function)
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
dol_osencode($str)
Return a string encoded into OS filesystem encoding.
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
dol_strlen($string, $stringencoding='UTF-8')
Make a strlen call.
forgeSQLFromUniversalSearchCriteria($filter, &$errorstr='', $noand=0, $nopar=0, $noerror=0)
forgeSQLFromUniversalSearchCriteria
dol_now($mode='auto')
Return date for now.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
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.
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
utf8_check($str)
Check if a string is in UTF8.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
image_format_supported($file, $acceptsvg=0)
Return if a filename is file name of a supported image format.
measuringUnitString($unit, $measuring_style='', $scale='', $use_short_label=0, $outputlangs=null)
Return translation label of a unit key.
publicphonebutton2 phonegreen basiclayout basiclayout TotalHT VATCode TotalVAT TotalLT1 TotalLT2 TotalTTC TotalHT clearboth nowraponall TAKEPOS_SHOW_SUBPRICE right right right takeposterminal SELECT e e e e e statut