27 require_once DOL_DOCUMENT_ROOT.
'/core/class/commonobject.class.php';
28 require_once DOL_DOCUMENT_ROOT.
'/core/class/commonobjectline.class.php';
40 public $element =
'mo';
45 public $table_element =
'mrp_mo';
50 public $ismultientitymanaged = 1;
55 public $isextrafieldmanaged = 1;
60 public $picto =
'mrp';
63 const STATUS_DRAFT = 0;
64 const STATUS_VALIDATED = 1;
65 const STATUS_INPROGRESS = 2;
66 const STATUS_PRODUCED = 3;
67 const STATUS_CANCELED = 9;
100 public $fields = array(
101 'rowid' => array(
'type'=>
'integer',
'label'=>
'TechnicalID',
'enabled'=>1,
'visible'=>-2,
'position'=>1,
'notnull'=>1,
'index'=>1,
'comment'=>
"Id",),
102 'entity' => array(
'type'=>
'integer',
'label'=>
'Entity',
'enabled'=>1,
'visible'=>0,
'position'=>5,
'notnull'=>1,
'default'=>
'1',
'index'=>1),
103 '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),
104 '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'),
105 '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'),
106 'fk_product' => array(
'type'=>
'integer:Product:product/class/product.class.php:0',
'label'=>
'Product',
'enabled'=>
'$conf->product->enabled',
'visible'=>1,
'position'=>35,
'notnull'=>1,
'index'=>1,
'comment'=>
"Product to produce",
'css'=>
'maxwidth300',
'csslist'=>
'tdoverflowmax100',
'picto'=>
'product'),
107 'qty' => array(
'type'=>
'real',
'label'=>
'QtyToProduce',
'enabled'=>1,
'visible'=>1,
'position'=>40,
'notnull'=>1,
'comment'=>
"Qty to produce",
'css'=>
'width75',
'default'=>1,
'isameasure'=>1),
108 '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),
109 'fk_soc' => array(
'type'=>
'integer:Societe:societe/class/societe.class.php:1',
'label'=>
'ThirdParty',
'picto'=>
'company',
'enabled'=>
'$conf->societe->enabled',
'visible'=>-1,
'position'=>50,
'notnull'=>-1,
'index'=>1,
'css'=>
'maxwidth400',
'csslist'=>
'tdoverflowmax150'),
110 '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'),
111 'fk_warehouse' => array(
'type'=>
'integer:Entrepot:product/stock/class/entrepot.class.php:0',
'label'=>
'WarehouseForProduction',
'picto'=>
'stock',
'enabled'=>
'$conf->stock->enabled',
'visible'=>1,
'position'=>52,
'css'=>
'maxwidth400',
'csslist'=>
'tdoverflowmax200'),
112 'note_public' => array(
'type'=>
'html',
'label'=>
'NotePublic',
'enabled'=>1,
'visible'=>0,
'position'=>61,
'notnull'=>-1,),
113 'note_private' => array(
'type'=>
'html',
'label'=>
'NotePrivate',
'enabled'=>1,
'visible'=>0,
'position'=>62,
'notnull'=>-1,),
114 'date_creation' => array(
'type'=>
'datetime',
'label'=>
'DateCreation',
'enabled'=>1,
'visible'=>-2,
'position'=>500,
'notnull'=>1,),
115 'tms' => array(
'type'=>
'timestamp',
'label'=>
'DateModification',
'enabled'=>1,
'visible'=>-2,
'position'=>501,
'notnull'=>1,),
116 'date_valid' => array(
'type'=>
'datetime',
'label'=>
'DateValidation',
'enabled'=>1,
'visible'=>-2,
'position'=>502,),
117 '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'),
118 'fk_user_modif' => array(
'type'=>
'integer:User:user/class/user.class.php',
'label'=>
'UserModif',
'enabled'=>1,
'visible'=>-2,
'position'=>511,
'notnull'=>-1,
'csslist'=>
'tdoverflowmax100'),
119 'date_start_planned' => array(
'type'=>
'datetime',
'label'=>
'DateStartPlannedMo',
'enabled'=>1,
'visible'=>1,
'position'=>55,
'notnull'=>-1,
'index'=>1,
'help'=>
'KeepEmptyForAsap',
'alwayseditable'=>1),
120 'date_end_planned' => array(
'type'=>
'datetime',
'label'=>
'DateEndPlannedMo',
'enabled'=>1,
'visible'=>1,
'position'=>56,
'notnull'=>-1,
'index'=>1,
'alwayseditable'=>1),
121 'import_key' => array(
'type'=>
'varchar(14)',
'label'=>
'ImportId',
'enabled'=>1,
'visible'=>-2,
'position'=>1000,
'notnull'=>-1,),
122 'model_pdf' =>array(
'type'=>
'varchar(255)',
'label'=>
'Model pdf',
'enabled'=>1,
'visible'=>0,
'position'=>1010),
123 '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')),
124 '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),
132 public $fk_warehouse;
144 public $note_private;
149 public $date_creation;
153 public $fk_user_creat;
154 public $fk_user_modif;
162 public $date_start_planned;
167 public $date_end_planned;
180 public $table_element_line =
'mrp_production';
185 public $fk_element =
'fk_mo';
190 public $class_element_line =
'MoLine';
195 protected $childtables = array();
200 protected $childtablesoncascade = array(
'mrp_production');
205 public $lines = array();
211 public $fk_parent_line;
221 global $conf, $langs;
225 if (empty($conf->global->MAIN_SHOW_TECHNICAL_ID) && isset($this->fields[
'rowid'])) {
226 $this->fields[
'rowid'][
'visible'] = 0;
228 if (!
isModEnabled(
'multicompany') && isset($this->fields[
'entity'])) {
229 $this->fields[
'entity'][
'enabled'] = 0;
233 foreach ($this->fields as $key => $val) {
234 if (isset($val[
'enabled']) && empty($val[
'enabled'])) {
235 unset($this->fields[$key]);
240 foreach ($this->fields as $key => $val) {
241 if (!empty($val[
'arrayofkeyval']) && is_array($val[
'arrayofkeyval'])) {
242 foreach ($val[
'arrayofkeyval'] as $key2 => $val2) {
243 $this->fields[$key][
'arrayofkeyval'][$key2] = $langs->trans($val2);
263 include_once DOL_DOCUMENT_ROOT.
'/product/class/product.class.php';
265 $tmpproduct->fetch($this->fk_product);
266 if ($tmpproduct->hasFatherOrChild(1) > 0) {
267 $this->error =
'ErrorAVirtualProductCantBeUsedIntoABomOrMo';
268 $this->errors[] = $this->error;
275 if ($this->fk_bom > 0) {
277 include_once DOL_DOCUMENT_ROOT.
'/bom/class/bom.class.php';
278 $tmpbom =
new BOM($this->
db);
279 $tmpbom->fetch($this->fk_bom);
281 $this->mrptype = $tmpbom->bomtype;
286 if ($idcreated <= 0) {
301 $this->
db->rollback();
316 global $langs, $extrafields;
321 $object =
new self($this->db);
326 $result = $object->fetchCommon($fromid);
327 if ($result > 0 && !empty($object->table_element_line)) {
328 $object->fetchLines();
337 unset($object->fk_user_creat);
338 unset($object->import_key);
341 $object->ref = empty($this->fields[
'ref'][
'default']) ?
"copy_of_".$object->ref : $this->fields[
'ref'][
'default'];
342 $object->label = empty($this->fields[
'label'][
'default']) ? $langs->trans(
"CopyOf").
" ".$object->label : $this->fields[
'label'][
'default'];
343 $object->status = self::STATUS_DRAFT;
346 if (is_array($object->array_options) && count($object->array_options) > 0) {
347 $extrafields->fetch_name_optionals_label($this->table_element);
348 foreach ($object->array_options as $key => $option) {
349 $shortkey = preg_replace(
'/options_/',
'', $key);
350 if (!empty($extrafields->attributes[$this->element][
'unique'][$shortkey])) {
353 unset($object->array_options[$key]);
359 $object->context[
'createfromclone'] =
'createfromclone';
360 $result = $object->createCommon($user);
363 $this->error = $object->error;
364 $this->errors = $object->errors;
376 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)
405 if ($result > 0 && !empty($this->table_element_line)) {
409 $this->socid = $this->fk_soc;
421 $this->lines = array();
439 public function fetchAll($sortorder =
'', $sortfield =
'', $limit = 0, $offset = 0, array $filter = array(), $filtermode =
'AND')
449 $sql .=
' FROM '.MAIN_DB_PREFIX.$this->table_element.
' as t';
450 if (isset($this->ismultientitymanaged) && $this->ismultientitymanaged == 1) {
451 $sql .=
' WHERE t.entity IN ('.getEntity($this->element).
')';
453 $sql .=
' WHERE 1 = 1';
457 if (count($filter) > 0) {
458 foreach ($filter as $key => $value) {
459 if ($key ==
't.rowid') {
460 $sqlwhere[] = $key.
" = ".((int) $value);
461 } elseif (strpos($key,
'date') !==
false) {
462 $sqlwhere[] = $key.
" = '".$this->
db->idate($value).
"'";
463 } elseif ($key ==
'customsql') {
464 $sqlwhere[] = $value;
466 $sqlwhere[] = $key.
" LIKE '%".$this->
db->escape($value).
"%'";
470 if (count($sqlwhere) > 0) {
471 $sql .=
' AND ('.implode(
' '.$this->
db->escape($filtermode).
' ', $sqlwhere).
')';
474 if (!empty($sortfield)) {
475 $sql .= $this->
db->order($sortfield, $sortorder);
477 if (!empty($limit)) {
478 $sql .= $this->
db->plimit($limit, $offset);
485 while ($i < min($limit, $num)) {
486 $obj = $this->
db->fetch_object(
$resql);
488 $record =
new self($this->db);
489 $record->setVarsFromFetchObj($obj);
491 $records[$record->id] = $record;
499 $this->errors[] =
'Error '.$this->db->lasterror();
500 dol_syslog(__METHOD__.
' '.join(
',', $this->errors), LOG_ERR);
519 $sql .= $mostatic->getFieldList();
520 $sql .=
' FROM '.MAIN_DB_PREFIX.$mostatic->table_element.
' as t';
521 $sql .=
" WHERE t.role = '".$this->db->escape($role).
"'";
523 $sql .=
' AND t.fk_mrp_production = '.((int) $lineid);
525 $sql .=
'AND t.fk_mo = '.((int) $this->
id);
534 $obj = $this->
db->fetch_object(
$resql);
537 'rowid'=> $obj->rowid,
538 'date'=> $this->db->jdate($obj->date_creation),
540 'role' => $obj->role,
541 'fk_product' => $obj->fk_product,
542 'fk_warehouse' => $obj->fk_warehouse,
543 'batch' => $obj->batch,
544 'fk_stock_movement' => $obj->fk_stock_movement
553 $this->error = $this->
db->lasterror();
568 $sql =
'SELECT COUNT(rowid) as nb FROM '.MAIN_DB_PREFIX.
'stock_mouvement as sm';
569 $sql .=
" WHERE sm.origintype = 'mo' and sm.fk_origin = ".((int) $this->
id);
577 $obj = $this->
db->fetch_object(
$resql);
585 $this->error = $this->
db->lasterror();
622 $this->
db->rollback();
640 if ($this->status != self::STATUS_DRAFT) {
648 $sql =
'DELETE FROM '.MAIN_DB_PREFIX.
'mrp_production WHERE fk_mo = '.((int) $this->
id);
649 $this->
db->query($sql);
654 $moline->fk_mo = $this->id;
655 $moline->qty = $this->qty;
656 $moline->fk_product = $this->fk_product;
657 $moline->position = 1;
659 if ($this->fk_bom > 0) {
660 include_once DOL_DOCUMENT_ROOT.
'/bom/class/bom.class.php';
661 $bom =
new Bom($this->
db);
662 $bom->fetch($this->fk_bom);
663 if ($bom->bomtype == 1) {
665 $moline->role =
'toconsume';
668 $moline->role =
'toproduce';
671 if ($this->mrptype == 1) {
672 $moline->role =
'toconsume';
674 $moline->role =
'toproduce';
678 $resultline = $moline->create($user,
false);
679 if ($resultline <= 0) {
681 $this->error = $moline->error;
682 $this->errors = $moline->errors;
686 if ($this->fk_bom > 0) {
690 foreach ($bom->lines as $line) {
693 $moline->fk_mo = $this->id;
694 $moline->origin_id = $line->id;
695 $moline->origin_type =
'bomline';
696 if ($line->qty_frozen) {
697 $moline->qty = $line->qty;
699 $moline->qty =
price2num(($line->qty / ( !empty($bom->qty) ? $bom->qty : 1 ) ) * $this->qty / ( !empty($line->efficiency) ? $line->efficiency : 1 ),
'MS');
701 if ($moline->qty <= 0) {
703 $this->error =
"BadValueForquantityToConsume";
706 $moline->fk_product = $line->fk_product;
707 $moline->role = $role;
708 $moline->position = $line->position;
709 $moline->qty_frozen = $line->qty_frozen;
710 $moline->disable_stock_change = $line->disable_stock_change;
712 $resultline = $moline->create($user,
false);
713 if ($resultline <= 0) {
715 $this->error = $moline->error;
716 $this->errors = $moline->errors;
731 $this->
db->rollback();
747 if ($this->status != self::STATUS_DRAFT)
return 1;
751 $oldQty = $this->oldQty;
752 $newQty = $this->qty;
753 if ($newQty != $oldQty && !empty($this->oldQty)) {
754 $sql =
"SELECT rowid FROM " . MAIN_DB_PREFIX .
"mrp_production WHERE fk_mo = " . (int) $this->
id;
757 while ($obj = $this->
db->fetch_object(
$resql)) {
759 $res = $moLine->fetch($obj->rowid);
762 if ($moLine->role ==
'toconsume' || $moLine->role ==
'toproduce') {
763 if (empty($moLine->qty_frozen)) {
764 $qty = $newQty * $moLine->qty / $oldQty;
765 $moLine->qty =
price2num($qty * (!empty($line->efficiency) ? $line->efficiency : 1 ),
'MS');
766 $res = $moLine->update($user);
778 $this->
db->rollback();
791 public function delete(
User $user, $notrigger =
false)
808 $langs->load(
'stocks');
810 if ($this->status < 0) {
811 $this->error =
'ErrorDeleteLineNotAllowedByObjectStatus';
816 $fk_movement =
GETPOST(
'fk_movement',
'int');
819 if (!empty($arrayoflines)) {
823 $stockmove->setOrigin($this->element, $this->
id);
825 if (!empty($fk_movement)) {
827 $TArrayMoLine = $moline->fetchAll(
'',
'', 1, 0, array(
'customsql' =>
'fk_stock_movement ='.$fk_movement));
828 $moline = array_shift($TArrayMoLine);
831 $movement->fetch($fk_movement);
832 $productstatic->fetch($movement->product_id);
833 $qtytoprocess = $movement->qty;
836 $labelmovementCancel = $langs->trans(
"CancelProductionForRef", $productstatic->ref);
837 $codemovementCancel = $langs->trans(
"StockIncrease");
839 if (($qtytoprocess >= 0)) {
840 $idstockmove = $stockmove->reception($user, $movement->product_id, $movement->warehouse_id, $qtytoprocess, 0, $labelmovementCancel,
'',
'', $movement->batch,
dol_now(), 0, $codemovementCancel);
842 $idstockmove = $stockmove->livraison($user, $movement->product_id, $movement->warehouse_id, $qtytoprocess, 0, $labelmovementCancel,
dol_now(),
'',
'', $movement->batch, 0, $codemovementCancel);
844 if ($idstockmove < 0) {
846 $this->
db->rollback();
851 return $moline->delete($user, $notrigger);
853 foreach ($arrayoflines as $key => $arrayofline) {
854 $lineDetails = $arrayoflines[$key];
855 $productstatic->fetch($lineDetails[
'fk_product']);
856 $qtytoprocess = $lineDetails[
'qty'];
859 $labelmovementCancel = $langs->trans(
"CancelProductionForRef", $productstatic->ref);
860 $codemovementCancel = $langs->trans(
"StockIncrease");
862 if ($qtytoprocess >= 0) {
863 $idstockmove = $stockmove->reception($user, $lineDetails[
'fk_product'], $lineDetails[
'fk_warehouse'], $qtytoprocess, 0, $labelmovementCancel,
'',
'', $lineDetails[
'batch'],
dol_now(), 0, $codemovementCancel);
865 $idstockmove = $stockmove->livraison($user, $lineDetails[
'fk_product'], $lineDetails[
'fk_warehouse'], $qtytoprocess, 0, $labelmovementCancel,
dol_now(),
'',
'', $lineDetails[
'batch'], 0, $codemovementCancel);
867 if ($idstockmove < 0) {
869 $this->
db->rollback();
892 global $langs, $conf;
895 if (!empty($conf->global->MRP_MO_ADDON)) {
898 $file = $conf->global->MRP_MO_ADDON.
".php";
899 $classname = $conf->global->MRP_MO_ADDON;
902 $dirmodels = array_merge(array(
'/'), (array) $conf->modules_parts[
'models']);
903 foreach ($dirmodels as $reldir) {
907 $mybool |= @include_once $dir.$file;
910 if ($mybool ===
false) {
915 $obj =
new $classname();
916 $numref = $obj->getNextValue($prod, $this);
921 $this->error = $obj->error;
926 print $langs->trans(
"Error").
" ".$langs->trans(
"Error_MRP_MO_ADDON_NotDefined");
940 global $conf, $langs;
942 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
947 if ($this->status == self::STATUS_VALIDATED) {
948 dol_syslog(get_class($this).
"::validate action abandonned: already validated", LOG_WARNING);
965 if (!$error && (preg_match(
'/^[\(]?PROV/i', $this->
ref) || empty($this->
ref))) {
971 $this->newref = $num;
974 $sql =
"UPDATE ".MAIN_DB_PREFIX.$this->table_element;
975 $sql .=
" SET ref = '".$this->db->escape($num).
"',";
976 $sql .=
" status = ".self::STATUS_VALIDATED.
",";
977 $sql .=
" date_valid='".$this->db->idate($now).
"',";
978 $sql .=
" fk_user_valid = ".$user->id;
979 $sql .=
" WHERE rowid = ".((int) $this->
id);
981 dol_syslog(get_class($this).
"::validate()", LOG_DEBUG);
985 $this->error = $this->
db->lasterror();
989 if (!$error && !$notrigger) {
991 $result = $this->
call_trigger(
'MRP_MO_VALIDATE', $user);
999 $this->oldref = $this->ref;
1002 if (preg_match(
'/^[\(]?PROV/i', $this->
ref)) {
1004 $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).
"'";
1005 $sql .=
" WHERE filename LIKE '".$this->db->escape($this->
ref).
"%' AND filepath = 'mrp/".$this->
db->escape($this->
ref).
"' and entity = ".$conf->entity;
1008 $error++; $this->error = $this->
db->lasterror();
1014 $dirsource = $conf->mrp->dir_output.
'/'.$oldref;
1015 $dirdest = $conf->mrp->dir_output.
'/'.$newref;
1016 if (!$error && file_exists($dirsource)) {
1017 dol_syslog(get_class($this).
"::validate() rename dir ".$dirsource.
" into ".$dirdest);
1019 if (@rename($dirsource, $dirdest)) {
1022 $listoffiles =
dol_dir_list($conf->mrp->dir_output.
'/'.$newref,
'files', 1,
'^'.preg_quote($oldref,
'/'));
1023 foreach ($listoffiles as $fileentry) {
1024 $dirsource = $fileentry[
'name'];
1025 $dirdest = preg_replace(
'/^'.preg_quote($oldref,
'/').
'/', $newref, $dirsource);
1026 $dirsource = $fileentry[
'path'].
'/'.$dirsource;
1027 $dirdest = $fileentry[
'path'].
'/'.$dirdest;
1028 @rename($dirsource, $dirdest);
1038 $this->status = self::STATUS_VALIDATED;
1042 $this->
db->commit();
1045 $this->
db->rollback();
1060 if ($this->status <= self::STATUS_DRAFT) {
1071 return $this->
setStatusCommon($user, self::STATUS_DRAFT, $notrigger,
'MRP_MO_UNVALIDATE');
1081 public function cancel($user, $notrigger = 0)
1084 if ($this->status != self::STATUS_VALIDATED && $this->status != self::STATUS_INPROGRESS) {
1095 return $this->
setStatusCommon($user, self::STATUS_CANCELED, $notrigger,
'MRP_MO_CANCEL');
1105 public function reopen($user, $notrigger = 0)
1108 if ($this->status != self::STATUS_PRODUCED && $this->status != self::STATUS_CANCELED) {
1119 return $this->
setStatusCommon($user, self::STATUS_VALIDATED, $notrigger,
'MRP_MO_REOPEN');
1132 public function getNomUrl($withpicto = 0, $option =
'', $notooltip = 0, $morecss =
'', $save_lastsearch_value = -1)
1134 global $conf, $langs, $hookmanager;
1136 if (!empty($conf->dol_no_mouse_hover)) {
1142 $label =
img_picto(
'', $this->picto).
' <u class="paddingrightonly">'.$langs->trans(
"ManufacturingOrder").
'</u>';
1143 if (isset($this->status)) {
1144 $label .=
' '.$this->getLibStatut(5);
1147 $label .=
'<b>'.$langs->trans(
'Ref').
':</b> '.$this->ref;
1148 if (isset($this->label)) {
1149 $label .=
'<br><b>'.$langs->trans(
'Label').
':</b> '.$this->label;
1152 $url = DOL_URL_ROOT.
'/mrp/mo_card.php?id='.$this->id;
1153 if ($option ==
'production') {
1154 $url = DOL_URL_ROOT.
'/mrp/mo_production.php?id='.$this->id;
1157 if ($option !=
'nolink') {
1159 $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0);
1160 if ($save_lastsearch_value == -1 && preg_match(
'/list\.php/', $_SERVER[
"PHP_SELF"])) {
1161 $add_save_lastsearch_values = 1;
1163 if ($add_save_lastsearch_values) {
1164 $url .=
'&save_lastsearch_values=1';
1169 if (empty($notooltip)) {
1170 if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) {
1171 $label = $langs->trans(
"ShowMo");
1172 $linkclose .=
' alt="'.dol_escape_htmltag($label, 1).
'"';
1174 $linkclose .=
' title="'.dol_escape_htmltag($label, 1).
'"';
1175 $linkclose .=
' class="classfortooltip'.($morecss ?
' '.$morecss :
'').
'"';
1177 $linkclose = ($morecss ?
' class="'.$morecss.
'"' :
'');
1180 $linkstart =
'<a href="'.$url.
'"';
1181 $linkstart .= $linkclose.
'>';
1184 $result .= $linkstart;
1186 $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);
1188 if ($withpicto != 2) {
1189 $result .= $this->ref;
1191 $result .= $linkend;
1194 global $action, $hookmanager;
1195 $hookmanager->initHooks(array(
'modao'));
1196 $parameters = array(
'id'=>$this->
id,
'getnomurl' => &$result);
1197 $reshook = $hookmanager->executeHooks(
'getNomUrl', $parameters, $this, $action);
1199 $result = $hookmanager->resPrint;
1201 $result .= $hookmanager->resPrint;
1215 return $this->
LibStatut($this->status, $mode);
1229 if (empty($this->labelStatus)) {
1232 $this->labelStatus[self::STATUS_DRAFT] = $langs->transnoentitiesnoconv(
'Draft');
1233 $this->labelStatus[self::STATUS_VALIDATED] = $langs->transnoentitiesnoconv(
'ValidatedToProduce');
1234 $this->labelStatus[self::STATUS_INPROGRESS] = $langs->transnoentitiesnoconv(
'InProgress');
1235 $this->labelStatus[self::STATUS_PRODUCED] = $langs->transnoentitiesnoconv(
'StatusMOProduced');
1236 $this->labelStatus[self::STATUS_CANCELED] = $langs->transnoentitiesnoconv(
'Canceled');
1238 $this->labelStatusShort[self::STATUS_DRAFT] = $langs->transnoentitiesnoconv(
'Draft');
1239 $this->labelStatusShort[self::STATUS_VALIDATED] = $langs->transnoentitiesnoconv(
'Validated');
1240 $this->labelStatusShort[self::STATUS_INPROGRESS] = $langs->transnoentitiesnoconv(
'InProgress');
1241 $this->labelStatusShort[self::STATUS_PRODUCED] = $langs->transnoentitiesnoconv(
'StatusMOProduced');
1242 $this->labelStatusShort[self::STATUS_CANCELED] = $langs->transnoentitiesnoconv(
'Canceled');
1245 $statusType =
'status'.$status;
1246 if ($status == self::STATUS_VALIDATED) {
1247 $statusType =
'status1';
1249 if ($status == self::STATUS_INPROGRESS) {
1250 $statusType =
'status4';
1252 if ($status == self::STATUS_PRODUCED) {
1253 $statusType =
'status6';
1255 if ($status == self::STATUS_CANCELED) {
1256 $statusType =
'status9';
1259 return dolGetStatus($this->labelStatus[$status], $this->labelStatusShort[$status],
'', $statusType, $mode);
1270 $sql =
'SELECT rowid, date_creation as datec, tms as datem,';
1271 $sql .=
' fk_user_creat, fk_user_modif';
1272 $sql .=
' FROM '.MAIN_DB_PREFIX.$this->table_element.
' as t';
1273 $sql .=
' WHERE t.rowid = '.((int) $id);
1274 $result = $this->
db->query($sql);
1276 if ($this->
db->num_rows($result)) {
1277 $obj = $this->
db->fetch_object($result);
1278 $this->
id = $obj->rowid;
1280 $this->user_creation_id = $obj->fk_user_creat;
1281 $this->user_modification_id = $obj->fk_user_modif;
1282 $this->date_creation = $this->
db->jdate($obj->datec);
1283 $this->date_modification = empty($obj->datem) ?
'' : $this->
db->jdate($obj->datem);
1286 $this->
db->free($result);
1302 $this->lines = array();
1312 $this->lines = array();
1314 $objectline =
new MoLine($this->
db);
1316 $TFilters = array(
'customsql'=>
'fk_mo = '.((
int) $this->
id));
1317 if (!empty($rolefilter)) $TFilters[
'role'] = $rolefilter;
1318 $result = $objectline->fetchAll(
'ASC',
'position', 0, 0, $TFilters);
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");
1351 if ($this->model_pdf) {
1352 $modele = $this->model_pdf;
1353 } elseif (!empty($conf->global->MO_ADDON_PDF)) {
1354 $modele = $conf->global->MO_ADDON_PDF;
1358 $modelpath =
"core/modules/mrp/doc/";
1360 if (empty($modele)) {
1364 return $this->
commonGenerateDocument($modelpath, $modele, $outputlangs, $hidedetails, $hidedesc, $hideref, $moreparams);
1376 global $conf, $langs;
1392 $this->
db->commit();
1409 global $langs, $hookmanager, $conf,
$form;
1411 $langs->load(
'stocks');
1412 $text_stock_options = $langs->trans(
"RealStockDesc").
'<br>';
1413 $text_stock_options .= $langs->trans(
"RealStockWillAutomaticallyWhen").
'<br>';
1414 $text_stock_options .= (!empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT) || !empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT_CLOSE) ?
'- '.$langs->trans(
"DeStockOnShipment").
'<br>' :
'');
1415 $text_stock_options .= (!empty($conf->global->STOCK_CALCULATE_ON_VALIDATE_ORDER) ?
'- '.$langs->trans(
"DeStockOnValidateOrder").
'<br>' :
'');
1416 $text_stock_options .= (!empty($conf->global->STOCK_CALCULATE_ON_BILL) ?
'- '.$langs->trans(
"DeStockOnBill").
'<br>' :
'');
1417 $text_stock_options .= (!empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_BILL) ?
'- '.$langs->trans(
"ReStockOnBill").
'<br>' :
'');
1418 $text_stock_options .= (!empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER) ?
'- '.$langs->trans(
"ReStockOnValidateOrder").
'<br>' :
'');
1419 $text_stock_options .= (!empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER) ?
'- '.$langs->trans(
"ReStockOnDispatchOrder").
'<br>' :
'');
1420 $text_stock_options .= (!empty($conf->global->STOCK_CALCULATE_ON_RECEPTION) || !empty($conf->global->STOCK_CALCULATE_ON_RECEPTION_CLOSE) ?
'- '.$langs->trans(
"StockOnReception").
'<br>' :
'');
1422 print
'<tr class="liste_titre">';
1424 print
'<td class="linecoldescription">'.$langs->trans(
'Ref');
1425 if (!empty($conf->global->BOM_SUB_BOM)) {
1426 print
' <a id="show_all" href="#">'.img_picto(
'',
'folder-open',
'class="paddingright"').$langs->trans(
"ExpandAll").
'</a> ';
1427 print
'<a id="hide_all" href="#">'.img_picto(
'',
'folder',
'class="paddingright"').$langs->trans(
"UndoExpandAll").
'</a> ';
1431 print
'<td class="right">'.$langs->trans(
'Qty');
1432 if ($this->bom->bomtype == 0) {
1433 print
' <span class="opacitymedium">('.$langs->trans(
"ForAQuantityOf", $this->bom->qty).
')</span>';
1435 print
' <span class="opacitymedium">('.$langs->trans(
"ForAQuantityToConsumeOf", $this->bom->qty).
')</span>';
1438 print
'<td class="center">'.$form->textwithpicto($langs->trans(
"PhysicalStock"), $text_stock_options, 1).
'</td>';
1439 print
'<td class="center">'.$form->textwithpicto($langs->trans(
"VirtualStock"), $langs->trans(
"VirtualStockDesc")).
'</td>';
1440 print
'<td class="center">'.$langs->trans(
'QtyFrozen').
'</td>';
1441 print
'<td class="center">'.$langs->trans(
'DisableStockChange').
'</td>';
1442 print
'<td class="center">'.$langs->trans(
'MoChildGenerate').
'</td>';
1448 if (!empty($this->lines)) {
1449 foreach ($this->lines as $line) {
1451 if (is_object($hookmanager)) {
1452 $parameters = array(
'line'=>$line,
'i'=>$i,
'restrictlist'=>$restrictlist,
'selectedLines'=> $selectedLines);
1453 if (!empty($line->fk_parent_line)) { $parameters[
'fk_parent_line'] = $line->fk_parent_line; }
1454 $reshook = $hookmanager->executeHooks(
'printOriginObjectLine', $parameters, $this, $action);
1456 if (empty($reshook)) {
1457 $this->
printOriginLine($line,
'', $restrictlist,
'/core/tpl', $selectedLines);
1479 public function printOriginLine($line, $var, $restrictlist =
'', $defaulttpldir =
'/core/tpl', $selectedLines = array())
1481 global $langs, $conf;
1483 $this->tpl[
'id'] = $line->id;
1485 $this->tpl[
'label'] =
'';
1486 if (!empty($line->fk_product)) {
1487 $productstatic =
new Product($this->
db);
1488 $productstatic->fetch($line->fk_product);
1489 $productstatic->load_virtual_stock();
1490 $this->tpl[
'label'] .= $productstatic->getNomUrl(1);
1497 $this->tpl[
'qty_bom'] = 1;
1498 if (is_object($this->bom) && $this->bom->qty > 1) {
1499 $this->tpl[
'qty_bom'] = $this->bom->qty;
1502 $this->tpl[
'stock'] = $productstatic->stock_reel;
1503 $this->tpl[
'seuil_stock_alerte'] = $productstatic->seuil_stock_alerte;
1504 $this->tpl[
'virtual_stock'] = $productstatic->stock_theorique;
1505 $this->tpl[
'qty'] = $line->qty;
1506 $this->tpl[
'qty_frozen'] = $line->qty_frozen;
1507 $this->tpl[
'disable_stock_change'] = $line->disable_stock_change;
1508 $this->tpl[
'efficiency'] = $line->efficiency;
1510 $tpl = DOL_DOCUMENT_ROOT.
'/mrp/tpl/originproductline.tpl.php';
1511 $res = include $tpl;
1524 $tables = array(
'mrp_mo');
1538 $TMoChilds = array();
1541 $sql =
"SELECT rowid FROM ".MAIN_DB_PREFIX.
"mrp_mo as mo_child";
1542 $sql.=
" WHERE fk_parent_line IN ";
1543 $sql.=
" (SELECT rowid FROM ".MAIN_DB_PREFIX.
"mrp_production as line_parent";
1544 $sql.=
" WHERE fk_mo=".((int) $this->
id).
")";
1549 if ($this->
db->num_rows(
$resql) > 0) {
1550 while ($obj = $this->
db->fetch_object(
$resql)) {
1551 $MoChild =
new Mo($this->
db);
1552 $res = $MoChild->fetch($obj->rowid);
1553 if ($res > 0) $TMoChilds[$MoChild->id] = $MoChild;
1576 $MoParent =
new Mo($this->
db);
1579 $sql =
"SELECT lineparent.fk_mo as id_moparent FROM ".MAIN_DB_PREFIX.
"mrp_mo as mo";
1580 $sql.=
" LEFT JOIN ".MAIN_DB_PREFIX.
"mrp_production lineparent ON mo.fk_parent_line = lineparent.rowid";
1581 $sql.=
" WHERE mo.rowid = ".((int) $this->
id);
1586 if ($this->
db->num_rows(
$resql) > 0) {
1587 $obj = $this->
db->fetch_object(
$resql);
1588 $res = $MoParent->fetch($obj->id_moparent);
1589 if ($res < 0) $error++;
1613 public $element =
'mrp_production';
1618 public $table_element =
'mrp_production';
1623 public $ismultientitymanaged = 0;
1628 public $isextrafieldmanaged = 0;
1630 public $fields = array(
1631 'rowid' =>array(
'type'=>
'integer',
'label'=>
'ID',
'enabled'=>1,
'visible'=>-1,
'notnull'=>1,
'position'=>10),
1632 'fk_mo' =>array(
'type'=>
'integer',
'label'=>
'Mo',
'enabled'=>1,
'visible'=>-1,
'notnull'=>1,
'position'=>15),
1633 'origin_id' =>array(
'type'=>
'integer',
'label'=>
'Origin',
'enabled'=>1,
'visible'=>-1,
'notnull'=>0,
'position'=>17),
1634 'origin_type' =>array(
'type'=>
'varchar(10)',
'label'=>
'Origin type',
'enabled'=>1,
'visible'=>-1,
'notnull'=>0,
'position'=>18),
1635 'position' =>array(
'type'=>
'integer',
'label'=>
'Position',
'enabled'=>1,
'visible'=>-1,
'notnull'=>1,
'position'=>20),
1636 'fk_product' =>array(
'type'=>
'integer',
'label'=>
'Product',
'enabled'=>1,
'visible'=>-1,
'notnull'=>1,
'position'=>25),
1637 'fk_warehouse' =>array(
'type'=>
'integer',
'label'=>
'Warehouse',
'enabled'=>1,
'visible'=>-1,
'position'=>30),
1638 'qty' =>array(
'type'=>
'real',
'label'=>
'Qty',
'enabled'=>1,
'visible'=>-1,
'notnull'=>1,
'position'=>35),
1639 'qty_frozen' => array(
'type'=>
'smallint',
'label'=>
'QuantityFrozen',
'enabled'=>1,
'visible'=>1,
'default'=>0,
'position'=>105,
'css'=>
'maxwidth50imp',
'help'=>
'QuantityConsumedInvariable'),
1640 'disable_stock_change' => array(
'type'=>
'smallint',
'label'=>
'DisableStockChange',
'enabled'=>1,
'visible'=>1,
'default'=>0,
'position'=>108,
'css'=>
'maxwidth50imp',
'help'=>
'DisableStockChangeHelp'),
1641 'batch' =>array(
'type'=>
'varchar(30)',
'label'=>
'Batch',
'enabled'=>1,
'visible'=>-1,
'position'=>140),
1642 'role' =>array(
'type'=>
'varchar(10)',
'label'=>
'Role',
'enabled'=>1,
'visible'=>-1,
'position'=>145),
1643 'fk_mrp_production' =>array(
'type'=>
'integer',
'label'=>
'Fk mrp production',
'enabled'=>1,
'visible'=>-1,
'position'=>150),
1644 'fk_stock_movement' =>array(
'type'=>
'integer',
'label'=>
'StockMovement',
'enabled'=>1,
'visible'=>-1,
'position'=>155),
1645 'date_creation' =>array(
'type'=>
'datetime',
'label'=>
'DateCreation',
'enabled'=>1,
'visible'=>-2,
'notnull'=>1,
'position'=>160),
1646 'tms' =>array(
'type'=>
'timestamp',
'label'=>
'Tms',
'enabled'=>1,
'visible'=>-1,
'notnull'=>1,
'position'=>165),
1647 'fk_user_creat' =>array(
'type'=>
'integer',
'label'=>
'UserCreation',
'enabled'=>1,
'visible'=>-1,
'notnull'=>1,
'position'=>170),
1648 'fk_user_modif' =>array(
'type'=>
'integer',
'label'=>
'UserModification',
'enabled'=>1,
'visible'=>-1,
'position'=>175),
1649 'import_key' =>array(
'type'=>
'varchar(14)',
'label'=>
'ImportId',
'enabled'=>1,
'visible'=>-1,
'position'=>180),
1655 public $origin_type;
1658 public $fk_warehouse;
1661 public $disable_stock_change;
1664 public $fk_mrp_production;
1665 public $fk_stock_movement;
1666 public $date_creation;
1668 public $fk_user_creat;
1669 public $fk_user_modif;
1679 global $conf, $langs;
1683 if (empty($conf->global->MAIN_SHOW_TECHNICAL_ID) && isset($this->fields[
'rowid'])) {
1684 $this->fields[
'rowid'][
'visible'] = 0;
1686 if (!
isModEnabled(
'multicompany') && isset($this->fields[
'entity'])) {
1687 $this->fields[
'entity'][
'enabled'] = 0;
1691 foreach ($this->fields as $key => $val) {
1692 if (isset($val[
'enabled']) && empty($val[
'enabled'])) {
1693 unset($this->fields[$key]);
1698 if (is_object($langs)) {
1699 foreach ($this->fields as $key => $val) {
1700 if (!empty($val[
'arrayofkeyval']) && is_array($val[
'arrayofkeyval'])) {
1701 foreach ($val[
'arrayofkeyval'] as $key2 => $val2) {
1702 $this->fields[$key][
'arrayofkeyval'][$key2] = $langs->trans($val2);
1718 if (empty($this->qty)) {
1719 $this->error =
'BadValueForQty';
1750 public function fetchAll($sortorder =
'', $sortfield =
'', $limit = 0, $offset = 0, array $filter = array(), $filtermode =
'AND')
1760 $sql .=
' FROM '.MAIN_DB_PREFIX.$this->table_element.
' as t';
1761 if (isset($this->ismultientitymanaged) && $this->ismultientitymanaged == 1) {
1762 $sql .=
' WHERE t.entity IN ('.getEntity($this->element).
')';
1764 $sql .=
' WHERE 1 = 1';
1767 $sqlwhere = array();
1768 if (count($filter) > 0) {
1769 foreach ($filter as $key => $value) {
1770 if ($key ==
't.rowid') {
1771 $sqlwhere[] = $key.
" = ".((int) $value);
1772 } elseif (strpos($key,
'date') !==
false) {
1773 $sqlwhere[] = $key.
" = '".$this->
db->idate($value).
"'";
1774 } elseif ($key ==
'customsql') {
1775 $sqlwhere[] = $value;
1777 $sqlwhere[] = $key.
" LIKE '%".$this->
db->escape($value).
"%'";
1781 if (count($sqlwhere) > 0) {
1782 $sql .=
' AND ('.implode(
' '.$this->
db->escape($filtermode).
' ', $sqlwhere).
')';
1785 if (!empty($sortfield)) {
1786 $sql .= $this->
db->order($sortfield, $sortorder);
1788 if (!empty($limit)) {
1789 $sql .= $this->
db->plimit($limit, $offset);
1794 $num = $this->
db->num_rows(
$resql);
1796 while ($i < ($limit ? min($limit, $num) : $num)) {
1797 $obj = $this->
db->fetch_object(
$resql);
1799 $record =
new self($this->db);
1800 $record->setVarsFromFetchObj($obj);
1802 $records[$record->id] = $record;
1810 $this->errors[] =
'Error '.$this->db->lasterror();
1811 dol_syslog(__METHOD__.
' '.join(
',', $this->errors), LOG_ERR);
1836 public function delete(
User $user, $notrigger =
false)
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.
deleteLineCommon(User $user, $idline, $notrigger=false)
Delete a line of object in database.
getFieldList($alias='')
Function to concat keys of fields.
fetchCommon($id, $ref=null, $morewhere='')
Load object in memory from the database.
createCommon(User $user, $notrigger=false)
Create object into database.
deleteCommon(User $user, $notrigger=false, $forcechilddeletion=0)
Delete object in 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.
static commonReplaceThirdparty(DoliDB $db, $origin_id, $dest_id, array $tables, $ignoreerrors=0)
Function used to replace a thirdparty id with another one.
updateCommon(User $user, $notrigger=false)
Update object into database.
fetchLinesCommon($morewhere='')
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.
__construct(DoliDB $db)
Constructor.
update(User $user, $notrigger=false)
Update object into database.
fetchLinesLinked($role, $lineid=0)
Get list of lines linked to current line for a defined role.
getMoChilds()
Function used to return childs of Mo.
static replaceThirdparty($db, $origin_id, $dest_id)
Function used to replace a thirdparty id with another one.
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...
deleteLine(User $user, $idline, $notrigger=false)
Delete a line of object in database.
cancel($user, $notrigger=0)
Set cancel status.
fetch($id, $ref=null)
Load object 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.
updateProduction(User $user, $notrigger=true)
Update quantities in lines to consume and to produce.
getMoParent()
Function used to return childs of Mo.
getLinesArray($rolefilter='')
Create an array of lines.
LibStatut($status, $mode=0)
Return the 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...
fetchAll($sortorder='', $sortfield='', $limit=0, $offset=0, array $filter=array(), $filtermode='AND')
Load list of objects in memory from the database.
validate($user, $notrigger=0)
Validate Mo.
doScheduledJob()
Action executed by scheduler CAN BE A CRON TASK.
generateDocument($modele, $outputlangs, $hidedetails=0, $hidedesc=0, $hideref=0, $moreparams=null)
Create a document onto disk according to template module.
createProduction(User $user, $notrigger=true)
Erase and update the line to consume and to produce.
getNomUrl($withpicto=0, $option='', $notooltip=0, $morecss='', $save_lastsearch_value=-1)
Return a link to the object card (with optionaly the picto)
getLibStatut($mode=0)
Return label of the status.
info($id)
Load the info information in the object.
create(User $user, $notrigger=false)
Create object into database.
countMovements()
Count number of movement with origin of MO.
createFromClone(User $user, $fromid)
Clone an object into another one.
create(User $user, $notrigger=false)
Create object into database.
update(User $user, $notrigger=false)
Update object into database.
fetchAll($sortorder='', $sortfield='', $limit=0, $offset=0, array $filter=array(), $filtermode='AND')
Load list of objects in memory from the database.
__construct(DoliDB $db)
Constructor.
fetch($id, $ref=null)
Load object in memory from the database.
Class to manage stock movements.
Class to manage products or services.
Class to manage Dolibarr users.
if(isModEnabled('facture') &&!empty($user->rights->facture->lire)) if((isModEnabled('fournisseur') &&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->hasRight("fournisseur", "facture", "lire"))||(isModEnabled('supplier_invoice') && $user->hasRight("supplier_invoice", "lire"))) if(isModEnabled('don') &&!empty($user->rights->don->lire)) if(isModEnabled('tax') &&!empty($user->rights->tax->charges->lire)) if(isModEnabled('facture') &&isModEnabled('commande') && $user->hasRight("commande", "lire") &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) $resql
Social contributions to pay.
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
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)
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='')
Set event messages in dol_events session object.
dol_strlen($string, $stringencoding='UTF-8')
Make a strlen call.
dol_now($mode='auto')
Return date for now.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
dolGetStatus($statusLabel='', $statusLabelShort='', $html='', $statusType='status0', $displayMode=0, $url='', $params=array())
Output the badge of a status.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
if(!function_exists('utf8_encode')) if(!function_exists('utf8_decode')) getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
dol_sanitizeFileName($str, $newstr='_', $unaccent=1)
Clean a string to use it as a file name.
isModEnabled($module)
Is Dolibarr module enabled.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
$conf db
API class for accounts.