27require_once DOL_DOCUMENT_ROOT.
'/core/class/commonobject.class.php';
28require_once DOL_DOCUMENT_ROOT.
'/mrp/class/moline.class.php';
38 public $element =
'mo';
43 public $table_element =
'mrp_mo';
48 public $picto =
'mrp';
51 const STATUS_DRAFT = 0;
52 const STATUS_VALIDATED = 1;
53 const STATUS_INPROGRESS = 2;
54 const STATUS_PRODUCED = 3;
55 const STATUS_CANCELED = 9;
87 public $fields = array(
88 'rowid' => array(
'type' =>
'integer',
'label' =>
'TechnicalID',
'enabled' => 1,
'visible' => -2,
'position' => 1,
'notnull' => 1,
'index' => 1,
'comment' =>
"Id",),
89 'entity' => array(
'type' =>
'integer',
'label' =>
'Entity',
'enabled' => 1,
'visible' => 0,
'position' => 5,
'notnull' => 1,
'default' =>
'1',
'index' => 1),
90 'ref' => array(
'type' =>
'varchar(128)',
'label' =>
'Ref',
'enabled' => 1,
'visible' => 4,
'position' => 10,
'notnull' => 1,
'default' =>
'(PROV)',
'index' => 1,
'searchall' => 1,
'comment' =>
"Reference of object",
'showoncombobox' => 1,
'noteditable' => 1),
91 'fk_bom' => array(
'type' =>
'integer:Bom:bom/class/bom.class.php:0:(t.status:=:1)',
'filter' =>
'active=1',
'label' =>
'BOM',
'enabled' =>
'$conf->bom->enabled',
'visible' => 1,
'position' => 33,
'notnull' => -1,
'index' => 1,
'comment' =>
"Original BOM",
'css' =>
'minwidth100 maxwidth500',
'csslist' =>
'tdoverflowmax150',
'picto' =>
'bom'),
92 'mrptype' => array(
'type' =>
'integer',
'label' =>
'Type',
'enabled' => 1,
'visible' => 1,
'position' => 34,
'notnull' => 1,
'default' =>
'0',
'arrayofkeyval' => array(0 =>
'Manufacturing', 1 =>
'Disassemble'),
'css' =>
'minwidth150',
'csslist' =>
'minwidth150 center'),
93 'fk_product' => array(
'type' =>
'integer:Product:product/class/product.class.php:0',
'label' =>
'Product',
'enabled' =>
'isModEnabled("product")',
'visible' => 1,
'position' => 35,
'notnull' => 1,
'index' => 1,
'comment' =>
"Product to produce",
'css' =>
'maxwidth300',
'csslist' =>
'tdoverflowmax100',
'picto' =>
'product'),
94 'qty' => array(
'type' =>
'real',
'label' =>
'QtyToProduce',
'enabled' => 1,
'visible' => 1,
'position' => 40,
'notnull' => 1,
'comment' =>
"Qty to produce",
'css' =>
'width75',
'default' =>
'1',
'isameasure' => 1),
95 'label' => array(
'type' =>
'varchar(255)',
'label' =>
'Label',
'enabled' => 1,
'visible' => 1,
'position' => 42,
'notnull' => -1,
'searchall' => 1,
'showoncombobox' => 2,
'css' =>
'maxwidth300',
'csslist' =>
'tdoverflowmax200',
'alwayseditable' => 1),
96 'fk_soc' => array(
'type' =>
'integer:Societe:societe/class/societe.class.php:1',
'label' =>
'ThirdParty',
'picto' =>
'company',
'enabled' =>
'isModEnabled("societe")',
'visible' => -1,
'position' => 50,
'notnull' => -1,
'index' => 1,
'css' =>
'maxwidth400',
'csslist' =>
'tdoverflowmax150'),
97 'fk_project' => array(
'type' =>
'integer:Project:projet/class/project.class.php:1:(fk_statut:=:1)',
'label' =>
'Project',
'picto' =>
'project',
'enabled' =>
'$conf->project->enabled',
'visible' => -1,
'position' => 51,
'notnull' => -1,
'index' => 1,
'css' =>
'minwidth200 maxwidth400',
'csslist' =>
'tdoverflowmax100'),
98 'fk_warehouse' => array(
'type' =>
'integer:Entrepot:product/stock/class/entrepot.class.php:0',
'label' =>
'WarehouseForProduction',
'picto' =>
'stock',
'enabled' =>
'isModEnabled("stock")',
'visible' => 1,
'position' => 52,
'css' =>
'maxwidth400',
'csslist' =>
'tdoverflowmax200'),
99 'note_public' => array(
'type' =>
'html',
'label' =>
'NotePublic',
'enabled' => 1,
'visible' => 0,
'position' => 61,
'notnull' => -1,),
100 'note_private' => array(
'type' =>
'html',
'label' =>
'NotePrivate',
'enabled' => 1,
'visible' => 0,
'position' => 62,
'notnull' => -1,),
101 'date_creation' => array(
'type' =>
'datetime',
'label' =>
'DateCreation',
'enabled' => 1,
'visible' => -2,
'position' => 500,
'notnull' => 1,),
102 'tms' => array(
'type' =>
'timestamp',
'label' =>
'DateModification',
'enabled' => 1,
'visible' => -2,
'position' => 501,
'notnull' => 1,),
103 'date_valid' => array(
'type' =>
'datetime',
'label' =>
'DateValidation',
'enabled' => 1,
'visible' => -2,
'position' => 502,),
104 'fk_user_creat' => array(
'type' =>
'integer:User:user/class/user.class.php',
'label' =>
'UserAuthor',
'enabled' => 1,
'visible' => -2,
'position' => 510,
'notnull' => 1,
'foreignkey' =>
'user.rowid',
'csslist' =>
'tdoverflowmax100'),
105 'fk_user_modif' => array(
'type' =>
'integer:User:user/class/user.class.php',
'label' =>
'UserModif',
'enabled' => 1,
'visible' => -2,
'position' => 511,
'notnull' => -1,
'csslist' =>
'tdoverflowmax100'),
106 'date_start_planned' => array(
'type' =>
'datetime',
'label' =>
'DateStartPlannedMo',
'enabled' => 1,
'visible' => 1,
'position' => 55,
'notnull' => -1,
'index' => 1,
'help' =>
'KeepEmptyForAsap',
'alwayseditable' => 1,
'csslist' =>
'nowraponall'),
107 'date_end_planned' => array(
'type' =>
'datetime',
'label' =>
'DateEndPlannedMo',
'enabled' => 1,
'visible' => 1,
'position' => 56,
'notnull' => -1,
'index' => 1,
'alwayseditable' => 1,
'csslist' =>
'nowraponall'),
108 'import_key' => array(
'type' =>
'varchar(14)',
'label' =>
'ImportId',
'enabled' => 1,
'visible' => -2,
'position' => 1000,
'notnull' => -1,),
109 'model_pdf' => array(
'type' =>
'varchar(255)',
'label' =>
'Model pdf',
'enabled' => 1,
'visible' => 0,
'position' => 1010),
110 'status' => array(
'type' =>
'integer',
'label' =>
'Status',
'enabled' => 1,
'visible' => 2,
'position' => 1000,
'default' =>
'0',
'notnull' => 1,
'index' => 1,
'arrayofkeyval' => array(
'0' =>
'Draft',
'1' =>
'Validated',
'2' =>
'InProgress',
'3' =>
'StatusMOProduced',
'9' =>
'Canceled')),
111 'fk_parent_line' => array(
'type' =>
'integer:MoLine:mrp/class/mo.class.php',
'label' =>
'ParentMo',
'enabled' => 1,
'visible' => 0,
'position' => 1020,
'default' =>
'0',
'notnull' => 0,
'index' => 1,
'showoncombobox' => 0),
142 public $fk_warehouse;
160 public $note_private;
170 public $fk_user_creat;
174 public $fk_user_modif;
197 public $date_start_planned;
202 public $date_end_planned;
231 public $table_element_line =
'mrp_production';
236 public $fk_element =
'fk_mo';
241 public $class_element_line =
'MoLine';
246 protected $childtables = array();
251 protected $childtablesoncascade = array(
'mrp_production');
256 public $lines = array();
266 public $fk_parent_line;
285 $this->ismultientitymanaged = 1;
286 $this->isextrafieldmanaged = 1;
289 $this->fields[
'rowid'][
'visible'] = 0;
291 if (!isModEnabled(
'multicompany') && isset($this->fields[
'entity'])) {
292 $this->fields[
'entity'][
'enabled'] = 0;
296 foreach ($this->fields as $key => $val) {
297 if (isset($val[
'enabled']) && empty($val[
'enabled'])) {
298 unset($this->fields[$key]);
303 foreach ($this->fields as $key => $val) {
304 if (!empty($val[
'arrayofkeyval']) && is_array($val[
'arrayofkeyval'])) {
305 foreach ($val[
'arrayofkeyval'] as $key2 => $val2) {
306 $this->fields[$key][
'arrayofkeyval'][$key2] = $langs->trans($val2);
326 include_once DOL_DOCUMENT_ROOT.
'/product/class/product.class.php';
327 $tmpproduct =
new Product($this->db);
328 $tmpproduct->fetch($this->fk_product);
329 if ($tmpproduct->hasFatherOrChild(1) > 0) {
330 $this->error =
'ErrorAVirtualProductCantBeUsedIntoABomOrMo';
331 $this->errors[] = $this->error;
338 if ($this->fk_bom > 0) {
340 include_once DOL_DOCUMENT_ROOT.
'/bom/class/bom.class.php';
341 $tmpbom =
new BOM($this->db);
342 $tmpbom->fetch($this->fk_bom);
344 $this->mrptype = $tmpbom->bomtype;
349 if ($idcreated <= 0) {
365 $this->db->rollback();
379 global $langs, $extrafields;
389 $result =
$object->fetchCommon($fromid);
390 if ($result > 0 && !empty(
$object->table_element_line)) {
408 foreach ($TLines as $key => $line) {
409 if (in_array($line->role, array(
'consumed',
'produced'))) {
418 $object->ref = empty($this->fields[
'ref'][
'default']) ?
"copy_of_".$object->ref : $this->fields[
'ref'][
'default'];
420 $object->label = empty($this->fields[
'label'][
'default']) ? $langs->trans(
"CopyOf").
" ".
$object->label : $this->fields[
'label'][
'default'];
421 $object->status = self::STATUS_DRAFT;
424 if (is_array(
$object->array_options) && count(
$object->array_options) > 0) {
425 $extrafields->fetch_name_optionals_label($this->table_element);
426 foreach (
$object->array_options as $key => $option) {
427 $shortkey = preg_replace(
'/options_/',
'', $key);
428 if (!empty($extrafields->attributes[$this->element][
'unique'][$shortkey])) {
431 unset(
$object->array_options[$key]);
437 $object->context[
'createfromclone'] =
'createfromclone';
438 $result =
$object->createCommon($user);
442 $this->errors =
$object->errors;
454 if (property_exists($this,
'socid') && $this->socid ==
$object->socid) {
461 unset(
$object->context[
'createfromclone']);
468 $this->db->rollback();
480 public function fetch($id, $ref =
null)
483 if ($result > 0 && !empty($this->table_element_line)) {
487 $this->socid = $this->fk_soc;
499 $this->lines = array();
517 public function fetchAll($sortorder =
'', $sortfield =
'', $limit = 0, $offset = 0, $filter =
'', $filtermode =
'AND')
525 $sql .=
' FROM '.MAIN_DB_PREFIX.$this->table_element.
' as t';
526 if (isset($this->ismultientitymanaged) && $this->ismultientitymanaged == 1) {
527 $sql .=
' WHERE t.entity IN ('.getEntity($this->element).
')';
529 $sql .=
' WHERE 1 = 1';
533 if (is_array($filter)) {
535 if (count($filter) > 0) {
536 foreach ($filter as $key => $value) {
537 if ($key ==
't.rowid') {
538 $sqlwhere[] = $this->db->sanitize($key).
" = ".((int) $value);
539 } elseif (strpos($key,
'date') !==
false) {
540 $sqlwhere[] = $this->db->sanitize($key).
" = '".$this->db->idate($value).
"'";
542 $sqlwhere[] = $this->db->sanitize($key).
" LIKE '%".$this->db->escape($this->db->escapeforlike($value)).
"%'";
546 if (count($sqlwhere) > 0) {
547 $sql .=
' AND ('.implode(
' '.$this->db->escape($filtermode).
' ', $sqlwhere).
')';
557 $this->errors[] = $errormessage;
558 dol_syslog(__METHOD__.
' '.implode(
',', $this->errors), LOG_ERR);
562 if (!empty($sortfield)) {
563 $sql .= $this->db->order($sortfield, $sortorder);
565 if (!empty($limit)) {
566 $sql .= $this->db->plimit($limit, $offset);
569 $resql = $this->db->query($sql);
571 $num = $this->db->num_rows($resql);
573 while ($i < min($limit, $num)) {
574 $obj = $this->db->fetch_object($resql);
576 $record =
new self($this->db);
577 $record->setVarsFromFetchObj($obj);
579 $records[$record->id] = $record;
583 $this->db->free($resql);
587 $this->errors[] =
'Error '.$this->db->lasterror();
588 dol_syslog(__METHOD__.
' '.implode(
',', $this->errors), LOG_ERR);
604 $mostatic =
new MoLine($this->db);
607 $sql .= $mostatic->getFieldList();
608 $sql .=
' FROM '.MAIN_DB_PREFIX.$mostatic->table_element.
' as t';
609 $sql .=
" WHERE t.role = '".$this->db->escape($role).
"'";
611 $sql .=
' AND t.fk_mrp_production = '.((int) $lineid);
613 $sql .=
'AND t.fk_mo = '.((int) $this->
id);
616 $resql = $this->db->query($sql);
618 $num = $this->db->num_rows($resql);
622 $obj = $this->db->fetch_object($resql);
625 'rowid' => $obj->rowid,
626 'date' => $this->db->jdate($obj->date_creation),
628 'role' => $obj->role,
629 'fk_product' => $obj->fk_product,
630 'fk_warehouse' => $obj->fk_warehouse,
631 'batch' => $obj->batch,
632 'fk_stock_movement' => $obj->fk_stock_movement,
633 'fk_unit' => $obj->fk_unit
642 $this->error = $this->db->lasterror();
657 $sql =
'SELECT COUNT(rowid) as nb FROM '.MAIN_DB_PREFIX.
'stock_mouvement as sm';
658 $sql .=
" WHERE sm.origintype = 'mo' and sm.fk_origin = ".((int) $this->
id);
660 $resql = $this->db->query($sql);
662 $num = $this->db->num_rows($resql);
666 $obj = $this->db->fetch_object($resql);
674 $this->error = $this->db->lasterror();
709 $this->db->rollback();
727 if ($this->
status != self::STATUS_DRAFT) {
735 $sql =
'DELETE FROM '.MAIN_DB_PREFIX.
'mrp_production WHERE fk_mo = '.((int) $this->
id);
736 $this->db->query($sql);
738 $moline =
new MoLine($this->db);
741 $moline->fk_mo = $this->id;
742 $moline->qty = $this->qty;
743 $moline->fk_product = $this->fk_product;
744 $moline->position = 1;
745 include_once DOL_DOCUMENT_ROOT.
'/product/class/product.class.php';
746 $tmpproduct =
new Product($this->db);
747 $tmpproduct->fetch($this->fk_product);
748 $moline->fk_unit = $tmpproduct->fk_unit;
750 if ($this->fk_bom > 0) {
751 include_once DOL_DOCUMENT_ROOT.
'/bom/class/bom.class.php';
752 $bom =
new BOM($this->db);
753 $bom->fetch($this->fk_bom);
754 if ($bom->bomtype == 1) {
756 $moline->role =
'toconsume';
759 $moline->role =
'toproduce';
763 if ($this->mrptype == 1) {
764 $moline->role =
'toconsume';
766 $moline->role =
'toproduce';
770 $resultline = $moline->create($user,
false);
771 if ($resultline <= 0) {
773 $this->error = $moline->error;
774 $this->errors = $moline->errors;
777 if ($this->fk_bom > 0 && is_object($bom)) {
781 foreach ($bom->lines as $line) {
782 $moline =
new MoLine($this->db);
784 $moline->fk_mo = $this->id;
785 $moline->origin_id = $line->id;
786 $moline->origin_type =
'bomline';
787 if (!empty($line->fk_unit)) {
788 $moline->fk_unit = $line->fk_unit;
790 if ($line->qty_frozen) {
791 $moline->qty = $line->qty;
793 $moline->qty = (float)
price2num(($line->qty / (!empty($bom->qty) ? $bom->qty : 1)) * $this->qty / (!empty($line->efficiency) ? $line->efficiency : 1),
'MS');
795 if ($moline->qty <= 0) {
797 $this->error =
"BadValueForquantityToConsume";
798 $this->errors[] = $this->error;
801 $moline->fk_product = $line->fk_product;
802 $moline->role = $role;
803 $moline->position = $line->position;
804 $moline->qty_frozen = $line->qty_frozen;
805 $moline->disable_stock_change = $line->disable_stock_change;
806 if (!empty($line->fk_default_workstation)) {
807 $moline->fk_default_workstation = $line->fk_default_workstation;
810 $resultline = $moline->create($user,
false);
811 if ($resultline <= 0) {
813 $this->error = $moline->error;
814 $this->errors[] = $moline->error;
815 $this->errors = array_merge($this->errors, $moline->errors);
830 $this->db->rollback();
846 if ($this->
status != self::STATUS_DRAFT) {
852 $oldQty = $this->oldQty;
853 $newQty = $this->qty;
854 if ($newQty != $oldQty && !empty($this->oldQty)) {
855 $sql =
"SELECT rowid FROM " . MAIN_DB_PREFIX .
"mrp_production WHERE fk_mo = " . (int) $this->
id;
856 $resql = $this->db->query($sql);
858 while ($obj = $this->db->fetch_object($resql)) {
859 $moLine =
new MoLine($this->db);
860 $res = $moLine->fetch($obj->rowid);
865 if ($moLine->role ==
'toconsume' || $moLine->role ==
'toproduce') {
866 if (empty($moLine->qty_frozen)) {
867 $qty = $newQty * $moLine->qty / $oldQty;
868 $moLine->qty = (float)
price2num($qty,
'MS');
869 $res = $moLine->update($user);
882 $this->db->rollback();
896 public function delete(
User $user, $notrigger = 0, $also_cancel_consumed_and_produced_lines =
false)
901 if ($also_cancel_consumed_and_produced_lines) {
916 $this->db->rollback();
933 public function deleteLine(
User $user, $idline, $notrigger = 0, $fk_movement = 0)
936 $langs->loadLangs(array(
'stocks',
'mrp'));
939 $this->error =
'ErrorDeleteLineNotAllowedByObjectStatus';
942 $productstatic =
new Product($this->db);
950 if (!empty($arrayoflines)) {
953 $stockmove->setOrigin($this->element, $this->
id);
955 if (!empty($fk_movement)) {
957 $moline =
new MoLine($this->db);
958 $TArrayMoLine = $moline->fetchAll(
'',
'', 1, 0,
'(fk_stock_movement:=:'.((
int) $fk_movement).
')');
959 $moline = array_shift($TArrayMoLine);
962 $movement->fetch($fk_movement);
963 $productstatic->fetch($movement->product_id);
964 $qtytoprocess = $movement->qty;
967 $labelmovementCancel = $langs->trans(
"CancelProductionForRef", $productstatic->ref);
968 $codemovementCancel = $langs->trans(
"StockIncrease");
970 if (($qtytoprocess >= 0)) {
971 $idstockmove = $stockmove->reception($user, $movement->product_id, $movement->warehouse_id, $qtytoprocess, 0, $labelmovementCancel,
'',
'', $movement->batch,
dol_now(), 0, $codemovementCancel);
973 $idstockmove = $stockmove->livraison($user, $movement->product_id, $movement->warehouse_id, $qtytoprocess, 0, $labelmovementCancel,
dol_now(),
'',
'', $movement->batch, 0, $codemovementCancel);
975 if ($idstockmove < 0) {
979 $result = $moline->delete($user, $notrigger);
983 foreach ($arrayoflines as $key => $arrayofline) {
984 $lineDetails = $arrayoflines[$key];
985 $productstatic->fetch($lineDetails[
'fk_product']);
986 $qtytoprocess = $lineDetails[
'qty'];
989 $labelmovementCancel = $langs->trans(
"CancelProductionForRef", $productstatic->ref);
990 $codemovementCancel = $langs->trans(
"StockIncrease");
993 if ($qtytoprocess >= 0) {
994 $idstockmove = $stockmove->reception($user, $lineDetails[
'fk_product'], $lineDetails[
'fk_warehouse'], $qtytoprocess, 0, $labelmovementCancel,
'',
'', $lineDetails[
'batch'],
dol_now(), 0, $codemovementCancel);
996 $idstockmove = $stockmove->livraison($user, $lineDetails[
'fk_product'], $lineDetails[
'fk_warehouse'], $qtytoprocess, 0, $labelmovementCancel,
dol_now(),
'',
'', $lineDetails[
'batch'], 0, $codemovementCancel);
998 if ($idstockmove < 0) {
1002 $moline =
new MoLine($this->db);
1003 $moline->fetch($lineDetails[
'rowid']);
1005 $resdel = $moline->delete($user, $notrigger);
1013 if (empty($this->error)) {
1022 if (!empty($this->error) || $result <= 0) {
1023 $this->db->rollback();
1025 $this->db->commit();
1041 global $langs, $conf;
1042 $langs->load(
"mrp");
1051 $dirmodels = array_merge(array(
'/'), (array) $conf->modules_parts[
'models']);
1052 foreach ($dirmodels as $reldir) {
1056 $mybool = ((bool) @include_once $dir.$file) || $mybool;
1064 $obj =
new $classname();
1065 '@phan-var-force ModeleNumRefMos $obj';
1066 $numref = $obj->getNextValue($prod, $this);
1068 if ($numref !=
"") {
1071 $this->error = $obj->error;
1076 print $langs->trans(
"Error").
" ".$langs->trans(
"Error_MRP_MO_ADDON_NotDefined");
1092 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
1097 if ($this->
status == self::STATUS_VALIDATED) {
1098 dol_syslog(get_class($this).
"::validate action abandoned: already validated", LOG_WARNING);
1115 if (!$error && (preg_match(
'/^[\(]?PROV/i', $this->
ref) || empty($this->
ref))) {
1121 $this->newref = $num;
1124 $sql =
"UPDATE ".MAIN_DB_PREFIX.$this->table_element;
1125 $sql .=
" SET ref = '".$this->db->escape($num).
"',";
1126 $sql .=
" status = ".self::STATUS_VALIDATED.
",";
1127 $sql .=
" date_valid = '".$this->db->idate($now).
"',";
1128 $sql .=
" fk_user_valid = ".((int) $user->id);
1129 $sql .=
" WHERE rowid = ".((int) $this->
id);
1131 dol_syslog(get_class($this).
"::validate()", LOG_DEBUG);
1132 $resql = $this->db->query($sql);
1135 $this->error = $this->db->lasterror();
1139 if (!$error && !$notrigger) {
1141 $result = $this->
call_trigger(
'MRP_MO_VALIDATE', $user);
1149 $this->oldref = $this->ref;
1152 if (preg_match(
'/^[\(]?PROV/i', $this->
ref)) {
1154 $sql =
'UPDATE '.MAIN_DB_PREFIX.
"ecm_files set filename = CONCAT('".$this->db->escape($this->newref).
"', SUBSTR(filename, ".(strlen($this->
ref) + 1).
")), filepath = 'mrp/".$this->db->escape($this->newref).
"'";
1155 $sql .=
" WHERE filename LIKE '".$this->db->escape($this->
ref).
"%' AND filepath = 'mrp/".$this->db->escape($this->
ref).
"' and entity = ".$conf->entity;
1156 $resql = $this->db->query($sql);
1159 $this->error = $this->db->lasterror();
1161 $sql =
'UPDATE '.MAIN_DB_PREFIX.
"ecm_files set filepath = 'mrp/".$this->db->escape($this->newref).
"'";
1162 $sql .=
" WHERE filepath = 'mrp/".$this->db->escape($this->
ref).
"' and entity = ".$conf->entity;
1163 $resql = $this->db->query($sql);
1166 $this->error = $this->db->lasterror();
1172 $dirsource = $conf->mrp->dir_output.
'/'.$oldref;
1173 $dirdest = $conf->mrp->dir_output.
'/'.$newref;
1174 if (!$error && file_exists($dirsource)) {
1175 dol_syslog(get_class($this).
"::validate() rename dir ".$dirsource.
" into ".$dirdest);
1177 if (@rename($dirsource, $dirdest)) {
1180 $listoffiles =
dol_dir_list($conf->mrp->dir_output.
'/'.$newref,
'files', 1,
'^'.preg_quote($oldref,
'/'));
1181 foreach ($listoffiles as $fileentry) {
1182 $dirsource = $fileentry[
'name'];
1183 $dirdest = preg_replace(
'/^'.preg_quote($oldref,
'/').
'/', $newref, $dirsource);
1184 $dirsource = $fileentry[
'path'].
'/'.$dirsource;
1185 $dirdest = $fileentry[
'path'].
'/'.$dirdest;
1186 @rename($dirsource, $dirdest);
1196 $this->
status = self::STATUS_VALIDATED;
1200 $this->db->commit();
1203 $this->db->rollback();
1218 if ($this->
status <= self::STATUS_DRAFT) {
1229 return $this->
setStatusCommon($user, self::STATUS_DRAFT, $notrigger,
'MRP_MO_UNVALIDATE');
1240 public function cancel($user, $notrigger = 0, $also_cancel_consumed_and_produced_lines =
false)
1243 if ($this->
status != self::STATUS_VALIDATED && $this->
status != self::STATUS_INPROGRESS) {
1257 if ($also_cancel_consumed_and_produced_lines) {
1265 $result = $this->
setStatusCommon($user, self::STATUS_CANCELED, $notrigger,
'MRP_MO_CANCEL');
1272 $this->db->rollback();
1275 $this->db->commit();
1287 public function reopen($user, $notrigger = 0)
1290 if ($this->
status != self::STATUS_PRODUCED && $this->
status != self::STATUS_CANCELED) {
1301 return $this->
setStatusCommon($user, self::STATUS_VALIDATED, $notrigger,
'MRP_MO_REOPEN');
1317 if (!isModEnabled(
'stock')) {
1321 require_once DOL_DOCUMENT_ROOT .
'/product/class/product.class.php';
1322 require_once DOL_DOCUMENT_ROOT .
'/product/stock/class/mouvementstock.class.php';
1324 $langs->load(
'stocks');
1329 if (empty($mode) || $mode == 1) {
1331 if (!empty($arrayoflines)) {
1332 foreach ($arrayoflines as $key => $lineDetails) {
1333 $productstatic =
new Product($this->db);
1334 $productstatic->fetch($lineDetails[
'fk_product']);
1335 $qtytoprocess = $lineDetails[
'qty'];
1338 $labelmovementCancel = $langs->trans(
"CancelProductionForRef", $productstatic->ref);
1339 $codemovementCancel = $langs->trans(
"StockIncrease");
1342 $stockmove->setOrigin($this->element, $this->
id);
1343 if ($qtytoprocess >= 0) {
1344 $idstockmove = $stockmove->reception($user, $lineDetails[
'fk_product'], $lineDetails[
'fk_warehouse'], $qtytoprocess, 0, $labelmovementCancel,
'',
'', $lineDetails[
'batch'],
dol_now(), 0, $codemovementCancel);
1346 $idstockmove = $stockmove->livraison($user, $lineDetails[
'fk_product'], $lineDetails[
'fk_warehouse'], $qtytoprocess, 0, $labelmovementCancel,
dol_now(),
'',
'', $lineDetails[
'batch'], 0, $codemovementCancel);
1348 if ($idstockmove < 0) {
1349 $this->error = $stockmove->error;
1350 $this->errors = $stockmove->errors;
1355 if ($also_delete_lines) {
1356 $result = $this->
deleteLineCommon($user, $lineDetails[
'rowid'], $notrigger);
1367 if (empty($mode) || $mode == 2) {
1369 if (!empty($arrayoflines)) {
1370 foreach ($arrayoflines as $key => $lineDetails) {
1371 $productstatic =
new Product($this->db);
1372 $productstatic->fetch($lineDetails[
'fk_product']);
1373 $qtytoprocess = $lineDetails[
'qty'];
1376 $labelmovementCancel = $langs->trans(
"CancelProductionForRef", $productstatic->ref);
1377 $codemovementCancel = $langs->trans(
"StockDecrease");
1380 $stockmove->setOrigin($this->element, $this->
id);
1381 if ($qtytoprocess >= 0) {
1382 $idstockmove = $stockmove->livraison($user, $lineDetails[
'fk_product'], $lineDetails[
'fk_warehouse'], $qtytoprocess, 0, $labelmovementCancel,
dol_now(),
'',
'', $lineDetails[
'batch'], 0, $codemovementCancel);
1384 $idstockmove = $stockmove->reception($user, $lineDetails[
'fk_product'], $lineDetails[
'fk_warehouse'], $qtytoprocess, 0, $labelmovementCancel,
'',
'', $lineDetails[
'batch'],
dol_now(), 0, $codemovementCancel);
1386 if ($idstockmove < 0) {
1387 $this->error = $stockmove->error;
1388 $this->errors = $stockmove->errors;
1393 if ($also_delete_lines) {
1394 $result = $this->
deleteLineCommon($user, $lineDetails[
'rowid'], $notrigger);
1405 $this->db->rollback();
1408 $this->db->commit();
1423 $langs->loadLangs([
'mrp',
'products']);
1424 $nofetch = isset($params[
'nofetch']);
1428 $datas[
'picto'] =
img_picto(
'', $this->picto).
' <u class="paddingrightonly">'.$langs->trans(
"ManufacturingOrder").
'</u>';
1429 if (isset($this->
status)) {
1430 $datas[
'picto'] .=
' '.$this->getLibStatut(5);
1432 $datas[
'ref'] =
'<br><b>'.$langs->trans(
'Ref').
':</b> '.$this->ref;
1433 if (isset($this->label)) {
1434 $datas[
'label'] =
'<br><b>'.$langs->trans(
'Label').
':</b> '.$this->label;
1436 if (isset($this->mrptype)) {
1437 $datas[
'type'] =
'<br><b>'.$langs->trans(
'Type').
':</b> '.$this->fields[
'mrptype'][
'arrayofkeyval'][$this->mrptype];
1439 if (isset($this->qty)) {
1440 $datas[
'qty'] =
'<br><b>'.$langs->trans(
'QtyToProduce').
':</b> '.$this->qty;
1442 if (!$nofetch && isset($this->fk_product)) {
1443 require_once DOL_DOCUMENT_ROOT .
'/product/class/product.class.php';
1444 $product =
new Product($this->db);
1445 $product->fetch($this->fk_product);
1446 $datas[
'product'] =
'<br><b>'.$langs->trans(
'Product').
':</b> '.$product->getNomUrl(1,
'', 0, -1, 1);
1448 if (!$nofetch && isset($this->fk_warehouse)) {
1449 require_once DOL_DOCUMENT_ROOT .
'/product/stock/class/entrepot.class.php';
1450 $warehouse =
new Entrepot($this->db);
1451 $warehouse->fetch($this->fk_warehouse);
1452 $datas[
'warehouse'] =
'<br><b>'.$langs->trans(
'WarehouseForProduction').
':</b> '.$warehouse->getNomUrl(1,
'', 0, 1);
1468 public function getNomUrl($withpicto = 0, $option =
'', $notooltip = 0, $morecss =
'', $save_lastsearch_value = -1)
1470 global $conf, $langs, $action, $hookmanager;
1472 if (!empty($conf->dol_no_mouse_hover)) {
1479 'objecttype' => $this->element,
1480 'option' => $option,
1483 $classfortooltip =
'classfortooltip';
1486 $classfortooltip =
'classforajaxtooltip';
1487 $dataparams =
' data-params="'.dol_escape_htmltag(json_encode($params)).
'"';
1493 $url = DOL_URL_ROOT.
'/mrp/mo_card.php?id='.$this->id;
1494 if ($option ==
'production') {
1495 $url = DOL_URL_ROOT.
'/mrp/mo_production.php?id='.$this->id;
1498 if ($option !=
'nolink') {
1500 $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0);
1501 if ($save_lastsearch_value == -1 && isset($_SERVER[
"PHP_SELF"]) && preg_match(
'/list\.php/', $_SERVER[
"PHP_SELF"])) {
1502 $add_save_lastsearch_values = 1;
1504 if ($add_save_lastsearch_values) {
1505 $url .=
'&save_lastsearch_values=1';
1510 if (empty($notooltip)) {
1512 $label = $langs->trans(
"ShowMo");
1513 $linkclose .=
' alt="'.dol_escape_htmltag($label, 1).
'"';
1515 $linkclose .= ($label ?
' title="'.dol_escape_htmltag($label, 1).
'"' :
' title="tocomplete"');
1516 $linkclose .= $dataparams.
' class="'.$classfortooltip.($morecss ?
' '.$morecss :
'').
'"';
1518 $linkclose = ($morecss ?
' class="'.$morecss.
'"' :
'');
1521 $linkstart =
'<a href="'.$url.
'"';
1522 $linkstart .= $linkclose.
'>';
1525 $result .= $linkstart;
1527 $result .=
img_object(($notooltip ?
'' : $label), ($this->picto ? $this->picto :
'generic'), (($withpicto != 2) ?
'class="paddingright"' :
''), 0, 0, $notooltip ? 0 : 1);
1529 if ($withpicto != 2) {
1530 $result .= $this->ref;
1532 $result .= $linkend;
1535 $hookmanager->initHooks(array(
'modao'));
1536 $parameters = array(
'id' => $this->
id,
'getnomurl' => &$result);
1537 $reshook = $hookmanager->executeHooks(
'getNomUrl', $parameters, $this, $action);
1539 $result = $hookmanager->resPrint;
1541 $result .= $hookmanager->resPrint;
1569 if (empty($this->labelStatus)) {
1572 $this->labelStatus[self::STATUS_DRAFT] = $langs->transnoentitiesnoconv(
'Draft');
1573 $this->labelStatus[self::STATUS_VALIDATED] = $langs->transnoentitiesnoconv(
'ValidatedToProduce');
1574 $this->labelStatus[self::STATUS_INPROGRESS] = $langs->transnoentitiesnoconv(
'InProgress');
1575 $this->labelStatus[self::STATUS_PRODUCED] = $langs->transnoentitiesnoconv(
'StatusMOProduced');
1576 $this->labelStatus[self::STATUS_CANCELED] = $langs->transnoentitiesnoconv(
'Canceled');
1578 $this->labelStatusShort[self::STATUS_DRAFT] = $langs->transnoentitiesnoconv(
'Draft');
1579 $this->labelStatusShort[self::STATUS_VALIDATED] = $langs->transnoentitiesnoconv(
'Validated');
1580 $this->labelStatusShort[self::STATUS_INPROGRESS] = $langs->transnoentitiesnoconv(
'InProgress');
1581 $this->labelStatusShort[self::STATUS_PRODUCED] = $langs->transnoentitiesnoconv(
'StatusMOProduced');
1582 $this->labelStatusShort[self::STATUS_CANCELED] = $langs->transnoentitiesnoconv(
'Canceled');
1585 $statusType =
'status'.$status;
1586 if ($status == self::STATUS_VALIDATED) {
1587 $statusType =
'status1';
1589 if ($status == self::STATUS_INPROGRESS) {
1590 $statusType =
'status4';
1592 if ($status == self::STATUS_PRODUCED) {
1593 $statusType =
'status6';
1595 if ($status == self::STATUS_CANCELED) {
1596 $statusType =
'status9';
1599 return dolGetStatus($this->labelStatus[$status], $this->labelStatusShort[$status],
'', $statusType, $mode);
1610 $sql =
'SELECT rowid, date_creation as datec, tms as datem,';
1611 $sql .=
' fk_user_creat, fk_user_modif';
1612 $sql .=
' FROM '.MAIN_DB_PREFIX.$this->table_element.
' as t';
1613 $sql .=
' WHERE t.rowid = '.((int) $id);
1614 $result = $this->db->query($sql);
1616 if ($this->db->num_rows($result)) {
1617 $obj = $this->db->fetch_object($result);
1619 $this->
id = $obj->rowid;
1621 $this->user_creation_id = $obj->fk_user_creat;
1622 $this->user_modification_id = $obj->fk_user_modif;
1623 $this->date_creation = $this->db->jdate($obj->datec);
1624 $this->date_modification = empty($obj->datem) ?
'' : $this->db->jdate($obj->datem);
1627 $this->db->free($result);
1643 $this->lines = array();
1656 $this->lines = array();
1658 $objectline =
new MoLine($this->db);
1660 $filter =
'(fk_mo:=:'.((int) $this->
id).
')';
1661 if (!empty($rolefilter)) {
1662 $filter .=
" AND (role:=:'".$this->db->escape($rolefilter).
"')";
1664 $result = $objectline->fetchAll(
'ASC',
'position', 0, 0, $filter);
1666 if (is_numeric($result)) {
1667 $this->error = $objectline->error;
1668 $this->errors = $objectline->errors;
1671 $this->lines = $result;
1672 return $this->lines;
1687 public function generateDocument($modele, $outputlangs, $hidedetails = 0, $hidedesc = 0, $hideref = 0, $moreparams =
null)
1691 $langs->load(
"mrp");
1697 if ($this->model_pdf) {
1698 $modele = $this->model_pdf;
1704 $modelpath =
"core/modules/mrp/doc/";
1706 if (empty($modele)) {
1710 return $this->
commonGenerateDocument($modelpath, $modele, $outputlangs, $hidedetails, $hidedesc, $hideref, $moreparams);
1725 global $langs, $hookmanager, $form, $action;
1727 $langs->load(
'stocks');
1728 $text_stock_options = $langs->trans(
"RealStockDesc").
'<br>';
1729 $text_stock_options .= $langs->trans(
"RealStockWillAutomaticallyWhen").
'<br>';
1730 $text_stock_options .= (
getDolGlobalString(
'STOCK_CALCULATE_ON_SHIPMENT') ||
getDolGlobalString(
'STOCK_CALCULATE_ON_SHIPMENT_CLOSE') ?
'- '.$langs->trans(
"DeStockOnShipment").
'<br>' :
'');
1731 $text_stock_options .= (
getDolGlobalString(
'STOCK_CALCULATE_ON_VALIDATE_ORDER') ?
'- '.$langs->trans(
"DeStockOnValidateOrder").
'<br>' :
'');
1732 $text_stock_options .= (
getDolGlobalString(
'STOCK_CALCULATE_ON_BILL') ?
'- '.$langs->trans(
"DeStockOnBill").
'<br>' :
'');
1733 $text_stock_options .= (
getDolGlobalString(
'STOCK_CALCULATE_ON_SUPPLIER_BILL') ?
'- '.$langs->trans(
"ReStockOnBill").
'<br>' :
'');
1734 $text_stock_options .= (
getDolGlobalString(
'STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER') ?
'- '.$langs->trans(
"ReStockOnValidateOrder").
'<br>' :
'');
1735 $text_stock_options .= (
getDolGlobalString(
'STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER') ?
'- '.$langs->trans(
"ReStockOnDispatchOrder").
'<br>' :
'');
1736 $text_stock_options .= (
getDolGlobalString(
'STOCK_CALCULATE_ON_RECEPTION') ||
getDolGlobalString(
'STOCK_CALCULATE_ON_RECEPTION_CLOSE') ?
'- '.$langs->trans(
"StockOnReception").
'<br>' :
'');
1738 print
'<tr class="liste_titre">';
1740 print
'<td class="linecoldescription">'.$langs->trans(
'Ref');
1742 print
' <a id="show_all" href="#">'.img_picto(
'',
'folder-open',
'class="paddingright"').$langs->trans(
"ExpandAll").
'</a> ';
1743 print
'<a id="hide_all" href="#">'.img_picto(
'',
'folder',
'class="paddingright"').$langs->trans(
"UndoExpandAll").
'</a> ';
1747 print
'<td class="right">'.$langs->trans(
'Qty');
1748 if ($this->bom->bomtype == 0) {
1749 print
' <span class="opacitymedium">('.$langs->trans(
"ForAQuantityOf", $this->bom->qty).
')</span>';
1751 print
' <span class="opacitymedium">('.$langs->trans(
"ForAQuantityToConsumeOf", $this->bom->qty).
')</span>';
1754 print
'<td class="right">'.$langs->trans(
'Unit');
1757 print
'<td class="center">'.$form->textwithpicto($langs->trans(
"PhysicalStock"), $text_stock_options, 1).
'</td>';
1758 print
'<td class="center">'.$form->textwithpicto($langs->trans(
"VirtualStock"), $langs->trans(
"VirtualStockDesc")).
'</td>';
1759 print
'<td class="center">'.$langs->trans(
'QtyFrozen').
'</td>';
1760 print
'<td class="center">'.$langs->trans(
'DisableStockChange').
'</td>';
1761 print
'<td class="center">'.$langs->trans(
'MoChildGenerate').
'</td>';
1767 if (!empty($this->lines)) {
1768 foreach ($this->lines as $line) {
1770 if (is_object($hookmanager)) {
1771 $parameters = array(
'line' => $line,
'i' => $i,
'restrictlist' => $restrictlist,
'selectedLines' => $selectedLines);
1772 if (!empty($line->fk_parent_line)) {
1773 $parameters[
'fk_parent_line'] = $line->fk_parent_line;
1775 $reshook = $hookmanager->executeHooks(
'printOriginObjectLine', $parameters, $this, $action);
1777 if (empty($reshook)) {
1778 $this->
printOriginLine($line,
'', $restrictlist,
'/core/tpl', $selectedLines);
1800 public function printOriginLine($line, $var, $restrictlist =
'', $defaulttpldir =
'/core/tpl', $selectedLines = array())
1802 if (!$line instanceof
MoLine) {
1803 dol_syslog(__METHOD__.
'::pringOriginLine $line is '.get_class($line).
'<>MoLine', LOG_WARNING);
1804 parent::printOriginLine($line, $var, $restrictlist, $defaulttpldir, $selectedLines);
1807 $productstatic =
new Product($this->db);
1809 $this->tpl[
'id'] = $line->id;
1811 $this->tpl[
'label'] =
'';
1812 if (!empty($line->fk_product) && $line->fk_product > 0) {
1813 $productstatic->fetch($line->fk_product);
1814 $productstatic->load_virtual_stock();
1815 $this->tpl[
'label'] .= $productstatic->getNomUrl(1);
1822 $this->tpl[
'qty_bom'] = 1;
1823 if (is_object($this->bom) && $this->bom->qty > 1) {
1824 $this->tpl[
'qty_bom'] = $this->bom->qty;
1827 $this->tpl[
'stock'] = $productstatic->stock_reel;
1828 $this->tpl[
'seuil_stock_alerte'] = $productstatic->seuil_stock_alerte;
1829 $this->tpl[
'virtual_stock'] = $productstatic->stock_theorique;
1830 $this->tpl[
'qty'] = $line->qty;
1831 $this->tpl[
'fk_unit'] = $line->fk_unit;
1832 $this->tpl[
'qty_frozen'] = $line->qty_frozen;
1833 $this->tpl[
'disable_stock_change'] = $line->disable_stock_change;
1834 $this->tpl[
'efficiency'] = $line->efficiency;
1838 $res = include DOL_DOCUMENT_ROOT.
'/mrp/tpl/originproductline.tpl.php';
1851 $tables = array(
'mrp_mo');
1864 $TMoChilds = array();
1867 $sql =
"SELECT rowid FROM ".MAIN_DB_PREFIX.
"mrp_mo as mo_child";
1868 $sql .=
" WHERE fk_parent_line IN ";
1869 $sql .=
" (SELECT rowid FROM ".MAIN_DB_PREFIX.
"mrp_production as line_parent";
1870 $sql .=
" WHERE fk_mo=".((int) $this->
id).
")";
1872 $resql = $this->db->query($sql);
1875 if ($this->db->num_rows($resql) > 0) {
1876 while ($obj = $this->db->fetch_object($resql)) {
1877 $MoChild =
new Mo($this->db);
1878 $res = $MoChild->fetch($obj->rowid);
1880 $TMoChilds[$MoChild->id] = $MoChild;
1905 if ($depth > 1000) {
1909 $TMoChilds = array();
1914 if ($childMoList == -1) {
1918 foreach ($childMoList as $childMo) {
1919 $TMoChilds[$childMo->id] = $childMo;
1922 foreach ($childMoList as $childMo) {
1923 $childMoChildren = $childMo->getAllMoChilds($depth + 1);
1925 if ($childMoChildren == -1) {
1928 foreach ($childMoChildren as $child) {
1929 $TMoChilds[$child->id] = $child;
1950 $MoParent =
new Mo($this->db);
1953 $sql =
"SELECT lineparent.fk_mo as id_moparent FROM ".MAIN_DB_PREFIX.
"mrp_mo as mo";
1954 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"mrp_production lineparent ON mo.fk_parent_line = lineparent.rowid";
1955 $sql .=
" WHERE mo.rowid = ".((int) $this->
id);
1957 $resql = $this->db->query($sql);
1960 if ($this->db->num_rows($resql) > 0) {
1961 $obj = $this->db->fetch_object($resql);
1962 $res = $MoParent->fetch($obj->id_moparent);
1990 '@phan-var-force array{selected?:int<0,1>,bom?:Bom,product?:product} $arraydata';
1992 $selected = (empty($arraydata[
'selected']) ? 0 : $arraydata[
'selected']);
1994 $return =
'<div class="box-flex-item box-flex-grow-zero">';
1995 $return .=
'<div class="info-box info-box-sm">';
1996 $return .=
'<span class="info-box-icon bg-infobox-action">';
1999 $return .=
'</span>';
2000 $return .=
'<div class="info-box-content">';
2001 $return .=
'<span class="info-box-ref inline-block tdoverflowmax150 valignmiddle">'.(method_exists($this,
'getNomUrl') ? $this->
getNomUrl() : $this->ref).
'</span>';
2002 if ($selected >= 0) {
2003 $return .=
'<input id="cb'.$this->id.
'" class="flat checkforselect fright" type="checkbox" name="toselect[]" value="'.$this->
id.
'"'.($selected ?
' checked="checked"' :
'').
'>';
2005 if (!empty($arraydata[
'bom'])) {
2006 $return .=
'<br><span class="info-box-label">'.$arraydata[
'bom']->getNomUrl(1).
'</span>';
2008 if (!empty($arraydata[
'product'])) {
2009 $return .=
'<br><span class="info-box-label">'.$arraydata[
'product']->getNomUrl(1).
'</span>';
2010 if (property_exists($this,
'qty')) {
2011 $return .=
' <span class="info-box-label">('.$langs->trans(
"Qty").
' '.$this->qty.
')</span>';
2014 if (property_exists($this,
'qty')) {
2015 $return .=
'<br><span class="info-box-label">'.$langs->trans(
'Quantity').
' : '.$this->qty.
'</span>';
2018 if (method_exists($this,
'getLibStatut')) {
2019 $return .=
'<br><div class="info-box-status">'.$this->getLibStatut(3).
'</div>';
2021 $return .=
'</div>';
2022 $return .=
'</div>';
2023 $return .=
'</div>';
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
Parent class of all other business classes (invoices, contracts, proposals, orders,...
deleteLineCommon(User $user, $idline, $notrigger=0)
Delete a line of object in database.
commonGenerateDocument($modelspath, $modele, $outputlangs, $hidedetails, $hidedesc, $hideref, $moreparams=null)
Common function for all objects extending CommonObject for generating documents.
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.
static commonReplaceThirdparty(DoliDB $dbs, $origin_id, $dest_id, array $tables, $ignoreerrors=0)
Function used to replace a thirdparty id with another one.
fetch_product()
Load the product with id $this->fk_product into this->product.
fetchLinesCommon($morewhere='', $noextrafields=0)
Load object in memory from the database.
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.
Class to manage Dolibarr database access.
Class to manage warehouses.
__construct(DoliDB $db)
Constructor.
fetchLinesLinked($role, $lineid=0)
Get list of lines linked to current line for a defined role.
getMoChilds()
Function used to return children of Mo.
static replaceThirdparty($db, $origin_id, $dest_id)
Function used to replace a thirdparty id with another one.
$tpl
@ var array{id:int,label:string,qty_bom:int|float,stock:float,seuil_stock_alerte:float,...
printOriginLinesList($restrictlist='', $selectedLines=array())
Return HTML table table of source object lines TODO Move this and previous function into output html ...
fetchLines()
Load object lines in memory from the database.
getNextNumRef($prod)
Returns the reference to the following non used MO depending on the active numbering module defined i...
create(User $user, $notrigger=0)
Create object into database.
fetch($id, $ref=null)
Load object in memory from the database.
fetchAll($sortorder='', $sortfield='', $limit=0, $offset=0, $filter='', $filtermode='AND')
Load list of objects in memory from the database.
initAsSpecimen()
Initialise object with example values Id must be 0 if object instance is a specimen.
reopen($user, $notrigger=0)
Set back to validated status.
getMoParent()
Function used to return children of Mo.
getLinesArray($rolefilter='')
Create an array of lines.
updateProduction(User $user, $notrigger=0)
Update quantities in lines to consume and/or lines to produce.
LibStatut($status, $mode=0)
Return the status.
cancel($user, $notrigger=0, $also_cancel_consumed_and_produced_lines=false)
Set cancel status.
setDraft($user, $notrigger=0)
Set draft status.
printOriginLine($line, $var, $restrictlist='', $defaulttpldir='/core/tpl', $selectedLines=array())
Return HTML with a line of table array of source object lines TODO Move this and previous function in...
update(User $user, $notrigger=0)
Update object into database.
getAllMoChilds($depth=0)
Function used to return all child MOs recursively.
createProduction(User $user, $notrigger=0)
Erase and update the line to consume and to produce.
deleteLine(User $user, $idline, $notrigger=0, $fk_movement=0)
Delete a line of object in database.
getKanbanView($option='', $arraydata=null)
Return clickable link of object (with eventually picto)
validate($user, $notrigger=0)
Validate Mo.
cancelConsumedAndProducedLines($user, $mode=0, $also_delete_lines=false, $notrigger=0)
Cancel consumed and produced lines (movement stocks)
generateDocument($modele, $outputlangs, $hidedetails=0, $hidedesc=0, $hideref=0, $moreparams=null)
Create a document onto disk according to template module.
getTooltipContentArray($params)
getTooltipContentArray
getNomUrl($withpicto=0, $option='', $notooltip=0, $morecss='', $save_lastsearch_value=-1)
Return a link to the object card (with optionally the picto)
getLibStatut($mode=0)
Return label of the status.
info($id)
Load the info information in the object.
countMovements()
Count number of movement with origin of MO.
createFromClone(User $user, $fromid)
Clone an object into another one.
Class to manage stock movements.
Class to manage products or services.
Class to manage Dolibarr users.
print $langs trans("Ref").' m titre as m m statut as status
Or an array listing all the potential status of the object: array: int of the status => translated la...
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)
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
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 a Dolibarr global constant string value.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.