31require
'../main.inc.php';
40require_once DOL_DOCUMENT_ROOT.
'/bom/class/bom.class.php';
41require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formcompany.class.php';
42require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
43require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formprojet.class.php';
44require_once DOL_DOCUMENT_ROOT.
'/mrp/class/mo.class.php';
45require_once DOL_DOCUMENT_ROOT.
'/mrp/lib/mrp_mo.lib.php';
46require_once DOL_DOCUMENT_ROOT.
'/projet/class/project.class.php';
47require_once DOL_DOCUMENT_ROOT.
'/product/class/product.class.php';
48require_once DOL_DOCUMENT_ROOT.
'/product/class/html.formproduct.class.php';
49require_once DOL_DOCUMENT_ROOT.
'/product/stock/class/entrepot.class.php';
50require_once DOL_DOCUMENT_ROOT.
'/product/stock/class/productlot.class.php';
51require_once DOL_DOCUMENT_ROOT.
'/product/stock/class/mouvementstock.class.php';
52require_once DOL_DOCUMENT_ROOT.
'/workstation/class/workstation.class.php';
55$langs->loadLangs(array(
"mrp",
"stocks",
"other",
"product",
"productbatch"));
60$action =
GETPOST(
'action',
'aZ09');
61$confirm =
GETPOST(
'confirm',
'alpha');
63$contextpage =
GETPOST(
'contextpage',
'aZ') ?
GETPOST(
'contextpage',
'aZ') :
'mocard';
64$backtopage =
GETPOST(
'backtopage',
'alpha');
67$fk_default_warehouse =
GETPOSTINT(
'fk_default_warehouse');
69$collapse =
GETPOST(
'collapse',
'aZ09comma');
73$diroutputmassaction =
$conf->mrp->dir_output.
'/temp/massgeneration/'.$user->id;
76$hookmanager->initHooks(array(
'moproduction',
'globalcard'));
79$extrafields->fetch_name_optionals_label(
$object->table_element);
81$search_array_options = $extrafields->getOptionalsFromPost(
$object->table_element,
'',
'search_');
84$search_all =
GETPOST(
"search_all",
'alpha');
86foreach (
$object->fields as $key => $val) {
87 if (
GETPOST(
'search_'.$key,
'alpha')) {
88 $search[$key] =
GETPOST(
'search_'.$key,
'alpha');
92if (empty($action) && empty($id) && empty($ref)) {
97include DOL_DOCUMENT_ROOT.
'/core/actions_fetchobject.inc.php';
102$isdraft = ((
$object->status == $object::STATUS_DRAFT) ? 1 : 0);
106$permissionnote = $user->hasRight(
'mrp',
'write');
107$permissiondellink = $user->hasRight(
'mrp',
'write');
108$permissiontoadd = $user->hasRight(
'mrp',
'write');
109$permissiontodelete = $user->hasRight(
'mrp',
'delete') || ($permissiontoadd && isset(
$object->status) &&
$object->status == $object::STATUS_DRAFT);
111$permissiontoproduce = $permissiontoadd;
112$permissiontoupdatecost = $user->hasRight(
'bom',
'read');
121$parameters = array();
122$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
127if (empty($reshook)) {
130 $backurlforlist = DOL_URL_ROOT.
'/mrp/mo_list.php';
132 if (empty($backtopage) || ($cancel && empty($id))) {
134 if (empty($id) && (($action !=
'add' && $action !=
'create') || $cancel)) {
135 $backtopage = $backurlforlist;
137 $backtopage = DOL_URL_ROOT.
'/mrp/mo_production.php?id='.(
$id > 0 ?
$id :
'__ID__');
140 $triggermodname =
'MO_MODIFY';
142 if ($action ==
'confirm_cancel' && $confirm ==
'yes' && !empty($permissiontoadd)) {
143 $also_cancel_consumed_and_produced_lines = (
GETPOST(
'alsoCancelConsumedAndProducedLines',
'alpha') ? 1 : 0);
144 $result =
$object->cancel($user, 0, (
bool) $also_cancel_consumed_and_produced_lines);
146 header(
"Location: " . DOL_URL_ROOT.
'/mrp/mo_card.php?id=' .
$object->id);
152 } elseif ($action ==
'confirm_delete' && $confirm ==
'yes' && !empty($permissiontodelete)) {
153 $also_cancel_consumed_and_produced_lines = (
GETPOST(
'alsoCancelConsumedAndProducedLines',
'alpha') ? 1 : 0);
154 $result =
$object->delete($user, 0, (
bool) $also_cancel_consumed_and_produced_lines);
156 header(
"Location: " . $backurlforlist);
170 if ($action ==
'setqty' && $permissiontoadd &&
$object->status == Mo::STATUS_DRAFT) {
184 foreach (
$object->lines as $line) {
185 if ($line->role ===
'toproduce'
186 && (
int) $line->fk_product === (
int)
$object->fk_product
187 && empty($line->qty_frozen)
188 && (
float) $line->qty != (
float)
$object->qty) {
189 $line->qty = (float)
$object->qty;
190 $line->update($user);
198 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->trans(
"Qty")),
null,
'errors');
200 header(
"Location: ".$_SERVER[
"PHP_SELF"].
"?id=".
$object->id);
205 include DOL_DOCUMENT_ROOT.
'/core/actions_addupdatedelete.inc.php';
208 include DOL_DOCUMENT_ROOT.
'/core/actions_dellink.inc.php';
211 include DOL_DOCUMENT_ROOT.
'/core/actions_printing.inc.php';
214 $triggersendname =
'MO_SENTBYMAIL';
215 $autocopy =
'MAIN_MAIL_AUTOCOPY_MO_TO';
216 $trackid =
'mo'.$object->id;
217 include DOL_DOCUMENT_ROOT.
'/core/actions_sendmails.inc.php';
222 if ($action ==
'set_thirdparty' && $permissiontoadd) {
223 $object->setValueFrom(
'fk_soc',
GETPOSTINT(
'fk_soc'),
'',
null,
'date',
'', $user, $triggermodname);
225 if ($action ==
'classin' && $permissiontoadd) {
229 if ($action ==
'confirm_reopen' && $permissiontoadd &&
$object->status == $object::STATUS_PRODUCED) {
230 $result =
$object->setStatut($object::STATUS_INPROGRESS, 0,
'',
'MRP_REOPEN');
233 if (($action ==
'confirm_addconsumeline' &&
GETPOST(
'addconsumelinebutton') && $permissiontoadd)
234 || ($action ==
'confirm_addproduceline' &&
GETPOST(
'addproducelinebutton') && $permissiontoadd)) {
240 $moline->fk_product =
GETPOSTINT(
'productidtoadd');
241 if (
GETPOST(
'addconsumelinebutton')) {
242 $moline->role =
'toconsume';
244 $moline->role =
'toproduce';
246 $moline->origin_type =
'free';
247 $moline->position = 0;
250 if (!empty($moline->fk_product)) {
252 $tmpproduct->fetch($moline->fk_product);
254 $moline->fk_default_workstation = $tmpproduct->fk_default_workstation;
255 $moline->disable_stock_change = 1;
256 if ($tmpproduct->duration_unit) {
257 $moline->qty = $tmpproduct->duration_value;
258 include_once DOL_DOCUMENT_ROOT.
'/core/class/cunits.class.php';
260 $res = $cunits->fetch(0,
'', $tmpproduct->duration_unit,
'time');
262 $moline->fk_unit = $cunits->id;
266 $moline->disable_stock_change = 0;
268 $moline->fk_unit = $tmpproduct->fk_unit;
273 $extralabelsline = $extrafields->fetch_name_optionals_label(
$object->table_element_line);
274 $array_options = $extrafields->getOptionalsFromPost(
$object->table_element_line);
276 if (is_array($extralabelsline)) {
278 foreach ($extralabelsline as $key => $value) {
279 unset($_POST[
"options_".$key]);
282 if (is_array($array_options) && count($array_options) > 0) {
283 $moline->array_options = $array_options;
286 $resultline = $moline->create($user, 0);
287 if ($resultline <= 0) {
294 header(
"Location: ".$_SERVER[
"PHP_SELF"].
'?id='.
$object->id);
299 if (in_array($action, array(
'confirm_consumeorproduce',
'confirm_consumeandproduceall')) &&
$object->status != $object::STATUS_VALIDATED &&
$object->status != $object::STATUS_INPROGRESS) {
300 $langs->load(
"errors");
305 if (in_array($action, array(
'confirm_consumeorproduce',
'confirm_consumeandproduceall')) && $permissiontoproduce) {
308 $labelmovement =
GETPOST(
'inventorylabel',
'alphanohtml');
309 $codemovement =
GETPOST(
'inventorycode',
'alphanohtml');
314 foreach (
$object->lines as $line) {
315 if ($line->role ==
'toconsume') {
317 $tmpproduct->fetch($line->fk_product);
323 if ($qtytoprocess != 0) {
326 if (!(
GETPOST(
'idwarehouse-'.$line->id.
'-'.$i) > 0)) {
327 $langs->load(
"errors");
328 setEventMessages($langs->trans(
"ErrorFieldRequiredForProduct", $langs->transnoentitiesnoconv(
"Warehouse"), (
string) $tmpproduct->ref),
null,
'errors');
331 if (
isModEnabled(
'productbatch') && $tmpproduct->status_batch && (!
GETPOST(
'batch-'.$line->id.
'-'.$i))) {
332 $langs->load(
"errors");
333 setEventMessages($langs->trans(
"ErrorFieldRequiredForProduct", $langs->transnoentitiesnoconv(
"Batch"), (
string) $tmpproduct->ref),
null,
'errors');
339 if (!$error &&
GETPOST(
'idwarehouse-'.$line->id.
'-'.$i) > 0) {
341 $id_product_batch = 0;
343 $stockmove->context[
'mrp_role'] =
'toconsume';
345 if ($qtytoprocess >= 0) {
346 $idstockmove = $stockmove->livraison($user, $line->fk_product,
GETPOSTINT(
'idwarehouse-'.$line->id.
'-'.$i), $qtytoprocess, 0, $labelmovement,
dol_now(),
'',
'',
GETPOST(
'batch-'.$line->id.
'-'.$i), $id_product_batch, $codemovement);
348 $idstockmove = $stockmove->reception($user, $line->fk_product,
GETPOSTINT(
'idwarehouse-'.$line->id.
'-'.$i), $qtytoprocess * -1, 0, $labelmovement,
'',
'',
GETPOST(
'batch-'.$line->id.
'-'.$i),
dol_now(), $id_product_batch, $codemovement);
350 if ($idstockmove < 0) {
360 $moline->position = $pos;
361 $moline->fk_product = $line->fk_product;
362 $moline->fk_warehouse =
GETPOSTINT(
'idwarehouse-'.$line->id.
'-'.$i);
363 $moline->qty = $qtytoprocess;
364 $moline->batch =
GETPOST(
'batch-'.$line->id.
'-'.$i);
365 $moline->role =
'consumed';
366 $moline->fk_mrp_production = $line->id;
367 $moline->fk_stock_movement = $idstockmove == 0 ? null : $idstockmove;
368 $moline->fk_user_creat = $user->id;
370 $resultmoline = $moline->create($user);
371 if ($resultmoline <= 0) {
388 foreach (
$object->lines as $line) {
389 if ($line->role ==
'toproduce') {
391 $tmpproduct->fetch($line->fk_product);
394 while (
GETPOSTISSET(
'qtytoproduce-'.$line->id.
'-'.$i)) {
395 $qtytoprocess = (float)
price2num(
GETPOST(
'qtytoproduce-'.$line->id.
'-'.$i));
396 $pricetoprocess =
GETPOST(
'pricetoproduce-'.$line->id.
'-'.$i) ?
price2num(
GETPOST(
'pricetoproduce-'.$line->id.
'-'.$i)) : 0;
398 if ($qtytoprocess != 0) {
400 if (
GETPOSTISSET(
'idwarehousetoproduce-'.$line->id.
'-'.$i)) {
401 if (!(
GETPOST(
'idwarehousetoproduce-'.$line->id.
'-'.$i) > 0)) {
402 $langs->load(
"errors");
403 setEventMessages($langs->trans(
"ErrorFieldRequiredForProduct", $langs->transnoentitiesnoconv(
"Warehouse"), $tmpproduct->ref),
null,
'errors');
406 if (
isModEnabled(
'productbatch') && $tmpproduct->status_batch && (!
GETPOST(
'batchtoproduce-'.$line->id.
'-'.$i))) {
407 $langs->load(
"errors");
408 setEventMessages($langs->trans(
"ErrorFieldRequiredForProduct", $langs->transnoentitiesnoconv(
"Batch"), $tmpproduct->ref),
null,
'errors');
414 if (!$error &&
GETPOST(
'idwarehousetoproduce-'.$line->id.
'-'.$i) > 0) {
416 $id_product_batch = 0;
417 $stockmove->origin_type =
$object->element;
418 $stockmove->origin_id =
$object->id;
419 $stockmove->context[
'mrp_role'] =
'toproduce';
421 $idstockmove = $stockmove->reception($user, $line->fk_product,
GETPOSTINT(
'idwarehousetoproduce-'.$line->id.
'-'.$i), $qtytoprocess, $pricetoprocess, $labelmovement,
GETPOSTDATE(
'eatby-'.$line->id.
'-'.$i),
GETPOSTDATE(
'sellby-'.$line->id.
'-'.$i),
GETPOST(
'batchtoproduce-'.$line->id.
'-'.$i),
dol_now(), $id_product_batch, $codemovement);
422 if ($idstockmove < 0) {
432 $moline->position = $pos;
433 $moline->fk_product = $line->fk_product;
434 $moline->fk_warehouse =
GETPOSTINT(
'idwarehousetoproduce-'.$line->id.
'-'.$i);
435 $moline->qty = $qtytoprocess;
436 $moline->batch =
GETPOST(
'batchtoproduce-'.$line->id.
'-'.$i);
437 $moline->role =
'produced';
438 $moline->fk_mrp_production = $line->id;
439 $moline->fk_stock_movement = (($idstockmove == 0) ?
null : $idstockmove);
440 $moline->fk_user_creat = $user->id;
442 $resultmoline = $moline->create($user);
443 if ($resultmoline <= 0) {
458 $consumptioncomplete =
true;
459 $productioncomplete =
true;
462 foreach (
$object->lines as $line) {
464 $tmpproduct->fetch($line->fk_product);
465 if ((
int) $tmpproduct->stockable_product > 0) {
466 if ($line->role ==
'toconsume') {
467 $arrayoflines =
$object->fetchLinesLinked(
'consumed', $line->id);
468 $alreadyconsumed = 0;
469 foreach ($arrayoflines as $line2) {
470 $alreadyconsumed += $line2[
'qty'];
473 if ($alreadyconsumed < $line->qty) {
474 $consumptioncomplete =
false;
477 if ($line->role ==
'toproduce') {
478 $arrayoflines =
$object->fetchLinesLinked(
'produced', $line->id);
479 $alreadyproduced = 0;
480 foreach ($arrayoflines as $line2) {
481 $alreadyproduced += $line2[
'qty'];
484 if ($alreadyproduced < $line->qty) {
485 $productioncomplete =
false;
491 $consumptioncomplete =
false;
492 $productioncomplete =
false;
496 dol_syslog(
"consumptioncomplete = ".json_encode($consumptioncomplete).
" productioncomplete = ".json_encode($productioncomplete));
497 if ($consumptioncomplete && $productioncomplete) {
498 $result =
$object->setStatut($object::STATUS_PRODUCED, 0,
'',
'MRP_MO_PRODUCED');
500 $result =
$object->setStatut($object::STATUS_INPROGRESS, 0,
'',
'MRP_MO_PRODUCED');
509 $action = str_replace(
'confirm_',
'', $action);
515 header(
"Location: ".$_SERVER[
"PHP_SELF"].
'?id='.
$object->id);
521 if ($action ==
'confirm_produced' && $confirm ==
'yes' && $permissiontoadd) {
522 $result =
$object->setStatut($object::STATUS_PRODUCED, 0,
'',
'MRP_MO_PRODUCED');
526 $outputlangs = $langs;
529 $newlang =
GETPOST(
'lang_id',
'aZ09');
532 $newlang =
$object->thirdparty->default_lang;
534 if (!empty($newlang)) {
536 $outputlangs->setDefaultLang($newlang);
541 $object->generateDocument($model, $outputlangs, 0, 0, 0);
548 if ($action ==
'confirm_editline' && $permissiontoadd && !in_array(
$object->status, array($object::STATUS_PRODUCED, $object::STATUS_CANCELED))) {
550 $result = $moline->fetch(
GETPOSTINT(
'lineid'));
551 if ($result > 0 && $moline->fk_mo !=
$object->id) {
554 if ($result > 0 && in_array($moline->role, array(
'consumed',
'produced'))) {
558 $extrafields->fetch_name_optionals_label($moline->table_element);
559 if (!empty($extrafields->attributes[$moline->table_element][
'label'])) {
560 foreach ($extrafields->attributes[$moline->table_element][
'label'] as $key => $label) {
561 $value =
GETPOST(
'options_'.$key,
'alphanohtml');
562 $moline->array_options[
"options_".$key] = $value;
567 $moline->fk_warehouse = (
GETPOSTINT(
'warehouse_lineProduce') > 0 ?
GETPOSTINT(
'warehouse_lineProduce') : 0);
570 $moline->fk_default_workstation = (
GETPOSTINT(
'workstation_lineProduce') > 0 ?
GETPOSTINT(
'workstation_lineProduce') : 0);
573 $res = $moline->update($user);
577 header(
"Location: ".$_SERVER[
"PHP_SELF"].
'?id='.
$object->id);
580 header(
"Location: ".$_SERVER[
"PHP_SELF"].
'?id='.
$object->id);
599$title = $langs->trans(
'Mo');
600$help_url =
'EN:Module_Manufacturing_Orders|FR:Module_Ordres_de_Fabrication|DE:Modul_Fertigungsauftrag';
601$morejs = array(
'/mrp/js/lib_dispatch.js.php');
602llxHeader(
'', $title, $help_url,
'', 0, 0, $morejs,
'',
'',
'mod-mrp page-card_production');
607if (
$object->id > 0 && (empty($action) || ($action !=
'edit' && $action !=
'create' && $action !=
'reload'))) {
608 $res =
$object->fetch_thirdparty();
609 $res =
$object->fetch_optionals();
612 $tmpwarehouse->fetch((
int)
$object->fk_warehouse);
613 $fk_default_warehouse = (int)
$object->fk_warehouse;
623 if ($action ==
'delete') {
624 $formquestion = array(
626 'label' => $langs->trans(
'MoCancelConsumedAndProducedLines'),
627 'name' =>
'alsoCancelConsumedAndProducedLines',
628 'type' =>
'checkbox',
632 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'DeleteMo'), $langs->trans(
'ConfirmDeleteMo'),
'confirm_delete', $formquestion, 0, 1);
635 if ($action ==
'deleteline') {
636 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&lineid='.$lineid.
'&fk_movement='.$fk_movement, $langs->trans(
'DeleteLine'), $langs->trans(
'ConfirmDeleteLine'),
'confirm_deleteline',
'', 0, 1);
639 if ($action ==
'clone') {
641 $formquestion = array();
642 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'ToClone'), $langs->trans(
'ConfirmCloneMo',
$object->ref),
'confirm_clone', $formquestion,
'yes', 1);
646 if ($action ==
'validate') {
648 $ref = substr(
$object->ref, 1, 4);
649 if ($ref ==
'PROV') {
656 $text = $langs->trans(
'ConfirmValidateMo', $numref);
665 $formquestion = array();
668 require_once DOL_DOCUMENT_ROOT.
'/product/class/html.formproduct.class.php';
671 if (
$conf->browser->name ==
'ie') {
674 $formquestion = array(
681 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'Validate'), $text,
'confirm_validate', $formquestion, 0, 1, 220);
685 if ($action ==
'cancel') {
686 $formquestion = array(
688 'label' => $langs->trans(
'MoCancelConsumedAndProducedLines'),
689 'name' =>
'alsoCancelConsumedAndProducedLines',
690 'type' =>
'checkbox',
691 'value' => !
getDolGlobalString(
'MO_ALSO_CANCEL_CONSUMED_AND_PRODUCED_LINES_BY_DEFAULT') ? 0 : 1
694 $formconfirm = $form->formconfirm(
dolBuildUrl($_SERVER[
"PHP_SELF"], [
'id' =>
$object->id]), $langs->trans(
'CancelMo'), $langs->trans(
'ConfirmCancelMo'),
'confirm_cancel', $formquestion, 0, 1);
698 $parameters = array(
'formConfirm' => $formconfirm,
'lineid' => $lineid);
699 $reshook = $hookmanager->executeHooks(
'formConfirm', $parameters, $object, $action);
700 if (empty($reshook)) {
701 $formconfirm .= $hookmanager->resPrint;
702 } elseif ($reshook > 0) {
703 $formconfirm = $hookmanager->resPrint;
712 $linkback =
'<a href="'.DOL_URL_ROOT.
'/mrp/mo_list.php?restore_lastsearch_values=1'.(!empty($socid) ?
'&socid='.$socid :
'').
'">'.$langs->trans(
"BackToList").
'</a>';
714 $morehtmlref =
'<div class="refidno">';
723 if (is_object(
$object->thirdparty)) {
724 $morehtmlref .=
$object->thirdparty->getNomUrl(1,
'customer');
726 $morehtmlref .=
' (<a href="'.DOL_URL_ROOT.
'/commande/list.php?socid='.
$object->thirdparty->id.
'">'.$langs->trans(
"OtherOrders").
'</a>)';
732 $langs->load(
"projects");
733 if (is_object(
$object->thirdparty)) {
734 $morehtmlref .=
'<br>';
736 if ($permissiontoadd) {
737 $morehtmlref .=
img_picto($langs->trans(
"Project"),
'project',
'class="pictofixedwidth"');
738 if ($action !=
'classify') {
739 $morehtmlref .=
'<a class="editfielda" href="'.dolBuildUrl($_SERVER[
'PHP_SELF'], [
'action' =>
'classify',
'id' =>
$object->id],
true).
'">'.
img_edit($langs->transnoentitiesnoconv(
'SetProject')).
'</a> ';
741 $morehtmlref .= $form->form_project($_SERVER[
'PHP_SELF'].
'?id='.
$object->id,
$object->socid, (
string)
$object->fk_project, ($action ==
'classify' ?
'projectid' :
'none'), 0, 0, 0, 1,
'',
'maxwidth300');
743 if (!empty(
$object->fk_project)) {
745 $proj->fetch(
$object->fk_project);
746 $morehtmlref .= $proj->getNomUrl(1);
748 $morehtmlref .=
'<span class="opacitymedium"> - '.dol_escape_htmltag($proj->title).
'</span>';
753 $morehtmlref .=
'</div>';
756 dol_banner_tab($object,
'ref', $linkback, 1,
'ref',
'ref', $morehtmlref);
759 print
'<div class="fichecenter">';
760 print
'<div class="fichehalfleft">';
761 print
'<div class="underbanner clearboth"></div>';
762 print
'<table class="border centpercent tableforfield">'.
"\n";
765 $keyforbreak =
'fk_warehouse';
766 unset(
$object->fields[
'fk_project']);
767 unset(
$object->fields[
'fk_soc']);
773 if (
$object->status == Mo::STATUS_DRAFT && $permissiontoadd && isset(
$object->fields[
'qty'])) {
774 $object->fields[
'qty'][
'alwayseditable'] = 1;
775 if ($action ==
'editqty') {
776 $object->fields[
'qty'][
'type'] =
'numeric';
780 include DOL_DOCUMENT_ROOT.
'/core/tpl/commonfields_view.tpl.php';
783 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_view.tpl.php';
789 print
'<div class="clearboth"></div>';
794 if (!in_array($action, array(
'consumeorproduce',
'consumeandproduceall'))) {
795 print
'<div class="tabsAction">';
797 $parameters = array();
799 $reshook = $hookmanager->executeHooks(
'addMoreActionsButtons', $parameters, $object, $action);
800 if (empty($reshook)) {
802 if (
$object->status == $object::STATUS_DRAFT) {
803 if ($permissiontoadd) {
805 print
'<a class="butAction" href="'.$_SERVER[
'PHP_SELF'].
'?id='.
$object->id.
'&action=validate&token='.$newToken.
'">'.$langs->trans(
"Validate").
'</a>';
807 $langs->load(
"errors");
808 print
'<a class="butActionRefused" href="" title="'.$langs->trans(
"ErrorAddAtLeastOneLineFirst").
'">'.$langs->trans(
"Validate").
'</a>';
814 if (
$object->status == Mo::STATUS_VALIDATED ||
$object->status == Mo::STATUS_INPROGRESS) {
815 if ($permissiontoproduce) {
816 print
'<a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=consumeorproduce&token='.$newToken.
'">'.$langs->trans(
'ConsumeOrProduce').
'</a>';
818 print
'<a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans(
"NotEnoughPermissions").
'">'.$langs->trans(
'ConsumeOrProduce').
'</a>';
820 } elseif (
$object->status == Mo::STATUS_DRAFT) {
821 print
'<a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans(
"ValidateBefore").
'">'.$langs->trans(
'ConsumeOrProduce').
'</a>';
825 if (
$object->status == Mo::STATUS_VALIDATED ||
$object->status == Mo::STATUS_INPROGRESS) {
826 if ($permissiontoproduce) {
827 print
'<a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=consumeandproduceall&token='.$newToken.
'">'.$langs->trans(
'ConsumeAndProduceAll').
'</a>';
829 print
'<a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans(
"NotEnoughPermissions").
'">'.$langs->trans(
'ConsumeAndProduceAll').
'</a>';
831 } elseif (
$object->status == Mo::STATUS_DRAFT) {
832 print
'<a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans(
"ValidateBefore").
'">'.$langs->trans(
'ConsumeAndProduceAll').
'</a>';
836 if ($permissiontoadd) {
837 if (
$object->status == $object::STATUS_VALIDATED ||
$object->status == $object::STATUS_INPROGRESS) {
838 $arrayproduced =
$object->fetchLinesLinked(
'produced', 0);
840 foreach ($arrayproduced as $lineproduced) {
841 $nbProduced += $lineproduced[
'qty'];
843 if ($nbProduced > 0) {
844 print
'<a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=confirm_produced&confirm=yes&token='.$newToken.
'">'.$langs->trans(
"Close").
'</a>'.
"\n";
846 print
'<a class="butActionRefused" href="#" title="'.$langs->trans(
"GoOnTabProductionToProduceFirst", $langs->transnoentitiesnoconv(
"Production")).
'">'.$langs->trans(
"Close").
'</a>'.
"\n";
849 print
'<a class="butActionDelete" href="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=cancel&token='.$newToken.
'">'.$langs->trans(
"Cancel").
'</a>'.
"\n";
852 if (
$object->status == $object::STATUS_CANCELED) {
853 print
'<a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=confirm_reopen&confirm=yes&token='.$newToken.
'">'.$langs->trans(
"ReOpen").
'</a>'.
"\n";
856 if (
$object->status == $object::STATUS_PRODUCED) {
857 if ($permissiontoproduce) {
858 print
'<a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=confirm_reopen&token='.$newToken.
'">'.$langs->trans(
'ReOpen').
'</a>';
860 print
'<a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans(
"NotEnoughPermissions").
'">'.$langs->trans(
'ReOpen').
'</a>';
869 if (in_array($action, array(
'consumeorproduce',
'consumeandproduceall',
'addconsumeline',
'addproduceline',
'editline'))) {
870 print
'<!-- Form to enter value for consumption/production -->';
871 print
'<form method="POST" action="'.dolBuildUrl($_SERVER[
"PHP_SELF"]).
'">';
872 print
'<input type="hidden" name="token" value="'.newToken().
'">';
873 print
'<input type="hidden" name="action" value="confirm_'.$action.
'">';
874 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
875 print
'<input type="hidden" name="id" value="'.$id.
'">';
878 if (in_array($action, array(
'consumeorproduce',
'consumeandproduceall'))) {
879 $defaultstockmovementlabel =
GETPOST(
'inventorylabel',
'alphanohtml') ?
GETPOST(
'inventorylabel',
'alphanohtml') : $langs->trans(
"ProductionForRef",
$object->
ref);
882 print
'<div class="center'.(in_array($action, array(
'consumeorproduce',
'consumeandproduceall')) ?
' formconsumeproduce' :
'').
'">';
883 print
'<div class="opacitymedium hideonsmartphone paddingbottom marginbottomonly">'.$langs->trans(
"ConfirmProductionDesc", $langs->transnoentitiesnoconv(
"Confirm")).
'<br></div>';
884 print
'<span class="paddingright">'.$langs->trans(
"InventoryCode").
':</span>';
885 print
'<span class="clearbothonsmartphone"></span>';
886 print
'<input type="text" class="minwidth125 maxwidth150" name="inventorycode" value="'.$defaultstockmovementcode.
'">';
887 print
'<span class="hideonsmartphone"> </span>';
888 print
'<span class="clearbothonsmartphone"></span>';
889 print
'<span class="paddingright">'.$langs->trans(
"MovementLabel").
':</span>';
890 print
'<span class="clearbothonsmartphone"></span>';
891 print
'<input type="text" class="minwidth300" name="inventorylabel" value="'.$defaultstockmovementlabel.
'"><br><br>';
892 print
'<input type="checkbox" id="autoclose" name="autoclose" value="1"'.(GETPOSTISSET(
'inventorylabel') ? (
GETPOST(
'autoclose') ?
' checked="checked"' :
'') :
' checked="checked"').
'> <label for="autoclose">'.$langs->trans(
"AutoCloseMO").
'</label><br>';
893 print
'<input type="submit" class="button margintoponly" value="'.$langs->trans(
"Confirm").
'" name="confirm">';
895 print
'<input class="button margintoponly button-cancel" type="submit" value="'.$langs->trans(
"Cancel").
'" name="cancel">';
909 if (!empty(
$object->table_element_line)) {
916 $res = $bom->fetch(
$object->fk_bom);
918 $bom->calculateCosts();
919 $bomcost = $bom->unit_cost;
925 print
'<!-- Lines to consume -->'.
"\n";
926 print
'<div class="fichecenter">';
927 print
'<div class="fichehalfleft">';
928 print
'<div class="clearboth"></div>';
930 $url = $_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=addconsumeline&token='.
newToken();
931 $permissiontoaddaconsumeline = (
$object->status != $object::STATUS_PRODUCED &&
$object->status != $object::STATUS_CANCELED) ? 1 : -2;
932 $parameters = array(
'morecss' =>
'reposition');
934 if ($permissiontoaddaconsumeline == -2) {
935 $helpText = $langs->trans(
'MOIsClosed');
939 if ($action !=
'consumeorproduce' && $action !=
'consumeandproduceall') {
940 $newcardbutton =
dolGetButtonTitle($langs->trans(
'AddNewConsumeLines'), $helpText,
'fa fa-plus-circle size15x', $url,
'', $permissiontoaddaconsumeline, $parameters);
943 print
load_fiche_titre($langs->trans(
'Consumption'), $newcardbutton,
'', 0,
'',
'',
'');
945 print
'<div class="div-table-responsive-no-min">';
946 print
'<table class="noborder noshadow centpercent nobottom">';
948 print
'<!-- Line of title for products to consume -->'.
"\n";
949 print
'<tr class="liste_titre trheight5em">';
951 print
'<td>'.$langs->trans(
"Product").
'</td>';
953 print
'<td class="right">'.$langs->trans(
"Qty").
'</td>';
958 print
'<td class="right">'.$langs->trans(
"UnitCost").
'</td>';
961 print
'<td class="right classfortooltip" title="'.$langs->trans(
"QtyAlreadyConsumed").
'">';
962 print $langs->trans(
"QtyAlreadyConsumedShort");
966 if ($collapse || in_array($action, array(
'consumeorproduce',
'consumeandproduceall'))) {
967 print $langs->trans(
"Warehouse");
969 print
' '.$langs->trans(
"or").
' '.$langs->trans(
"Workstation");
972 if (in_array($action, array(
'consumeorproduce',
'consumeandproduceall'))) {
973 $listwarehouses = $tmpwarehouse->list_array(1);
974 if (count($listwarehouses) > 1) {
975 print
'<br>'.$form->selectarray(
'fk_default_warehouse', $listwarehouses, $fk_default_warehouse, $langs->trans(
"ForceTo"), 0, 0,
'', 0, 0, 0,
'',
'minwidth100 maxwidth200', 1);
976 } elseif (count($listwarehouses) == 1) {
977 print
'<br>'.$form->selectarray(
'fk_default_warehouse', $listwarehouses, $fk_default_warehouse, 0, 0, 0,
'', 0, 0, 0,
'',
'minwidth100 maxwidth200', 1);
985 print
'<td align="right">';
986 if ($collapse || in_array($action, array(
'consumeorproduce',
'consumeandproduceall'))) {
987 print $langs->trans(
"Stock");
994 if ($collapse || in_array($action, array(
'consumeorproduce',
'consumeandproduceall'))) {
995 print $langs->trans(
"Batch");
1007 if (
$object->status == Mo::STATUS_DRAFT) {
1012 if ($permissiontodelete) {
1018 if ($action ==
'addconsumeline') {
1019 print
'<!-- Add line to consume -->'.
"\n";
1020 print
'<tr class="liste_titre">';
1023 print $form->select_produits(0,
'productidtoadd',
'', 0, 0, -1, 2,
'', 1, array(), 0,
'1', 0,
'maxwidth150');
1026 print
'<td class="right"><input type="text" name="qtytoadd" value="1" class="width40 right"></td>';
1034 if ($permissiontoupdatecost &&
getDolGlobalString(
'MRP_SHOW_COST_FOR_CONSUMPTION')) {
1046 print
'<td colspan="'.$colspan.
'">';
1047 print
'<input type="submit" class="button buttongen button-add" name="addconsumelinebutton" value="'.$langs->trans(
"Add").
'">';
1048 print
'<input type="submit" class="button buttongen button-cancel" name="canceladdconsumelinebutton" value="'.$langs->trans(
"Cancel").
'">';
1053 if (
$object->status == Mo::STATUS_DRAFT) {
1057 if ($permissiontodelete) {
1063 if (is_object($objectline)) {
1064 $extrafields->fetch_name_optionals_label(
$object->table_element_line);
1065 $temps = $objectline->showOptionals($extrafields,
'edit', array(),
'',
'',
'1',
'line');
1066 if (!empty($temps)) {
1067 print
'<tr class="liste_titre"><td style="padding-top: 20px" colspan="9" id="extrafield_lines_area_edit" name="extrafield_lines_area_edit">';
1076 $bomcostupdated = 0;
1079 $nblinetoconsume = 0;
1080 foreach (
$object->lines as $line) {
1081 if ($line->role ==
'toconsume') {
1086 $nblinetoconsumecursor = 0;
1087 foreach (
$object->lines as $line) {
1088 if ($line->role ==
'toconsume') {
1089 $nblinetoconsumecursor++;
1092 $tmpproduct->fetch($line->fk_product);
1093 $linecost =
price2num($tmpproduct->pmp,
'MT');
1097 $costprice =
price2num((!empty($tmpproduct->cost_price)) ? $tmpproduct->cost_price : $tmpproduct->pmp);
1098 if (empty($costprice)) {
1099 require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.product.class.php';
1101 if ($productFournisseur->find_min_price_product_fournisseur($line->fk_product, $line->qty) > 0) {
1102 $costprice = $productFournisseur->fourn_unitprice;
1110 if ($useunit && $line->fk_unit > 0) {
1112 $qtyhourservice = 0;
1113 if (preg_match(
'/^(\d+)([a-z]+)$/', $tmpproduct->duration, $reg)) {
1116 $qtyhourforline = 0;
1117 if ($line->fk_unit) {
1123 if (
isModEnabled(
'workstation') && $line->fk_default_workstation > 0) {
1125 $workstation->fetch($line->fk_default_workstation);
1126 $linecost =
price2num($qtyhourforline * ($workstation->thm_operator_estimated + $workstation->thm_machine_estimated) /
$object->qty,
'MT');
1127 $bomcostupdated +=
price2num($qtyhourforline * ($workstation->thm_operator_estimated + $workstation->thm_machine_estimated) /
$object->qty,
'MU');
1128 } elseif ($qtyhourservice && $qtyhourforline) {
1129 $linecost =
price2num(($qtyhourforline / $qtyhourservice * $costprice) /
$object->qty,
'MT');
1130 $bomcostupdated +=
price2num(($qtyhourforline / $qtyhourservice * $costprice) /
$object->qty,
'MU');
1133 $bomcostupdated +=
price2num(($line->qty * $costprice) /
$object->qty,
'MU');
1137 $bomcostupdated +=
price2num(($line->qty * $costprice) /
$object->qty,
'MU');
1141 $bomcostupdated =
price2num($bomcostupdated,
'MU');
1142 $arrayoflines =
$object->fetchLinesLinked(
'consumed', $line->id);
1143 $alreadyconsumed = 0;
1144 foreach ($arrayoflines as $line2) {
1145 $alreadyconsumed += $line2[
'qty'];
1148 if ($action ==
'editline' && $lineid == $line->id) {
1149 $linecost =
price2num($tmpproduct->pmp,
'MT');
1151 $arrayoflines =
$object->fetchLinesLinked(
'consumed', $line->id);
1152 $alreadyconsumed = 0;
1153 if (is_array($arrayoflines) && !empty($arrayoflines)) {
1154 foreach ($arrayoflines as $line2) {
1155 $alreadyconsumed += $line2[
'qty'];
1158 $suffix =
'_' . $line->id;
1159 print
'<!-- Line to dispatch ' . $suffix .
' (line edited) -->' .
"\n";
1161 print
'<input id="qty_ordered' . $suffix .
'" type="hidden" value="' . $line->qty .
'">';
1163 print
'<input id="qty_dispatched' . $suffix .
'" type="hidden" value="' . $alreadyconsumed .
'">';
1165 print
'<input name="lineid" type="hidden" value="' . $line->id .
'">';
1168 print
'<td>' . $tmpproduct->getNomUrl(1);
1169 print
'<br><div class="opacitymedium small tdoverflowmax150" title="' .
dol_escape_htmltag($tmpproduct->label) .
'">' . $tmpproduct->label .
'</span>';
1173 print
'<td class="right nowraponall">';
1174 print
'<input class="width40 right" name="qty_lineProduce" value="'. $line->qty.
'">';
1178 print
'<td class="right nowraponall">';
1186 if ($permissiontoupdatecost &&
getDolGlobalString(
'MRP_SHOW_COST_FOR_CONSUMPTION')) {
1191 print
'<td class="right">';
1192 print
' ' .
price2num($alreadyconsumed,
'MS');
1198 print $formproduct->selectWarehouses($line->fk_warehouse,
'warehouse_lineProduce',
'warehouseopen', 1);
1200 print $formproduct->selectWorkstations($line->fk_default_workstation,
'workstation_lineProduce', 1);
1206 print
'<td class="nowraponall right">';
1207 if ($tmpproduct->isStockManaged()) {
1208 if ($tmpproduct->stock_reel < ($line->qty - $alreadyconsumed)) {
1209 print
img_warning($langs->trans(
'StockTooLow')).
' ';
1211 print
'<span class="left">'. $tmpproduct->stock_reel .
' </span>';
1221 print
'<td colspan="'.(3 + (
$object->status == Mo::STATUS_DRAFT ? 1 : 0) + ($permissiontodelete ? 1 : 0)).
'">';
1222 print
'<input type="submit" class="button buttongen button-add small nominwidth" name="save" value="' . $langs->trans(
"Save") .
'">';
1223 print
'<input type="submit" class="button buttongen button-cancel small nominwidth" name="cancel" value="' . $langs->trans(
"Cancel") .
'">';
1229 if (!empty($extrafields)) {
1230 $line->fetch_optionals();
1231 $temps = $line->showOptionals($extrafields,
'edit', array(),
'',
'',
'1',
'line');
1232 if (!empty($temps)) {
1234 print
'<tr><td colspan="'.$colspan.
'"><div style="padding-top: 20px" id="extrafield_lines_area_edit" name="extrafield_lines_area_edit">';
1236 print
'</div></td></tr>';
1240 $suffix =
'_' . $line->id;
1241 print
'<!-- Line to dispatch ' . $suffix .
' -->' .
"\n";
1243 print
'<input id="qty_ordered' . $suffix .
'" type="hidden" value="' . $line->qty .
'">';
1244 print
'<input id="qty_dispatched' . $suffix .
'" type="hidden" value="' . $alreadyconsumed .
'">';
1246 print
'<tr data-line-id="' . $line->id .
'">';
1249 print
'<td>' . $tmpproduct->getNomUrl(1);
1250 print
'<br><div class="opacitymedium small tdoverflowmax150" title="' .
dol_escape_htmltag($tmpproduct->label) .
'">' . $tmpproduct->label .
'</div>';
1254 print
'<td class="right nowraponall">';
1256 if ($line->qty_frozen) {
1257 $help = ($help ?
'<br>' :
'') .
'<strong>' . $langs->trans(
"QuantityFrozen") .
'</strong>: ' .
yn(1) .
' (' . $langs->trans(
"QuantityConsumedInvariable") .
')';
1258 print $form->textwithpicto(
'', $help, -1,
'lock') .
' ';
1260 if ($line->disable_stock_change) {
1261 $help = ($help ?
'<br>' :
'') .
'<strong>' . $langs->trans(
"DisableStockChange") .
'</strong>: ' .
yn(1) .
' (' . (($tmpproduct->type ==
Product::TYPE_SERVICE && !
getDolGlobalString(
'STOCK_SUPPORTS_SERVICES')) ? $langs->trans(
"NoStockChangeOnServices") : $langs->trans(
"DisableStockChangeHelp")) .
')';
1262 print $form->textwithpicto(
'', $help, -1,
'help') .
' ';
1268 print
'<td class="right nowraponall">';
1276 if ($permissiontoupdatecost &&
getDolGlobalString(
'MRP_SHOW_COST_FOR_CONSUMPTION')) {
1277 print
'<td class="right nowraponall">';
1278 print
price($linecost);
1283 print
'<td class="right">';
1284 if ($alreadyconsumed) {
1286 print
'jQuery(document).ready(function() {
1287 jQuery("#expandtoproduce' . $line->id .
'").click(function() {
1288 console.log("Expand mrp_production line ' . $line->id .
'");
1289 jQuery(".expanddetail' . $line->id .
'").toggle();';
1290 if ($nblinetoconsume == $nblinetoconsumecursor) {
1291 print
'if (jQuery("#tablelines").hasClass("nobottom")) { jQuery("#tablelines").removeClass("nobottom"); } else { jQuery("#tablelines").addClass("nobottom"); }';
1297 if (empty(
$conf->use_javascript_ajax)) {
1298 print
'<a href="' . $_SERVER[
"PHP_SELF"] .
'?collapse=' . $collapse .
',' . $line->id .
'">';
1300 print
img_picto($langs->trans(
"ShowDetails"),
"chevron-down",
'id="expandtoproduce' . $line->id .
'"');
1301 if (empty(
$conf->use_javascript_ajax)) {
1305 if ($nblinetoconsume == $nblinetoconsumecursor) {
1306 print
'<script>jQuery("#tablelines").removeClass("nobottom");</script>';
1309 print
' ' .
price2num($alreadyconsumed,
'MS');
1313 print
'<td class="tdoverflowmax100">';
1314 if ($tmpproduct->isStockManaged()) {
1316 if (
getDolGlobalString(
'STOCK_CONSUMPTION_FROM_MANUFACTURING_WAREHOUSE') && $tmpwarehouse->id > 0) {
1317 print
img_picto(
'', $tmpwarehouse->picto) .
" " . $tmpwarehouse->label;
1319 if ($line->fk_warehouse > 0) {
1321 $warehouseline->fetch($line->fk_warehouse);
1322 print $warehouseline->getNomUrl(1);
1326 if (
isModEnabled(
'workstation') && $line->fk_default_workstation > 0) {
1328 $tmpworkstation->fetch($line->fk_default_workstation);
1329 print $tmpworkstation->getNomUrl(1);
1335 print
'<td class="nowraponall right">';
1337 if (!$line->disable_stock_change && $tmpproduct->stock_reel < ($line->qty - $alreadyconsumed)) {
1338 print
img_warning($langs->trans(
'StockTooLow')) .
' ';
1340 if (!
getDolGlobalString(
'STOCK_CONSUMPTION_FROM_MANUFACTURING_WAREHOUSE') || empty($tmpwarehouse->id)) {
1341 print
price2num($tmpproduct->stock_reel,
'MS');
1344 $tmpproduct->load_stock();
1345 $wh_stock = $tmpproduct->stock_warehouse[$tmpwarehouse->id];
1346 if (!empty($wh_stock)) {
1368 if (
$object->status == Mo::STATUS_DRAFT) {
1369 $href = $_SERVER[
"PHP_SELF"] .
'?id=' . ((int)
$object->id) .
'&action=editline&token=' .
newToken() .
'&lineid=' . ((int) $line->id);
1370 print
'<td class="center">';
1371 print
'<a class="reposition editfielda" href="' . $href .
'">';
1372 print
img_picto($langs->trans(
'TooltipEditAndRevertStockMovement'),
'edit');
1378 if ($permissiontodelete && empty($arrayoflines)) {
1379 $href = $_SERVER[
"PHP_SELF"] .
'?id=' . ((int)
$object->id) .
'&action=deleteline&token=' .
newToken() .
'&lineid=' . ((int) $line->id);
1380 print
'<td class="center">';
1381 print
'<a class="reposition" href="' . $href .
'">';
1382 print
img_picto($langs->trans(
'TooltipDeleteAndRevertStockMovement'),
'delete');
1390 if (!empty($extrafields)) {
1391 $line->fetch_optionals();
1392 $temps = $line->showOptionals($extrafields,
'view', array(),
'',
'',
'1',
'line');
1393 if (!empty($temps)) {
1395 print
'<tr><td colspan="'.$colspan.
'"><div id="extrafield_lines_area_'.$line->id.
'" name="extrafield_lines_area_'.$line->id.
'">';
1397 print
'</div></td></tr>';
1403 foreach ($arrayoflines as $line2) {
1404 print
'<tr class="expanddetail'.$line->id.
' hideobject opacitylow">';
1408 $tmpstockmovement->id = $line2[
'fk_stock_movement'];
1409 print
'<a href="'.DOL_URL_ROOT.
'/product/stock/movement_list.php?search_ref='.$tmpstockmovement->id.
'">'.
img_picto($langs->trans(
"StockMovement"),
'movement',
'class="paddingright"').
'</a>';
1420 if ($permissiontoupdatecost &&
getDolGlobalString(
'MRP_SHOW_COST_FOR_CONSUMPTION')) {
1425 print
'<td class="right">'.$line2[
'qty'].
'</td>';
1428 print
'<td class="tdoverflowmax150">';
1429 if ($line2[
'fk_warehouse'] > 0) {
1430 $result = $tmpwarehouse->fetch($line2[
'fk_warehouse']);
1432 print $tmpwarehouse->getNomUrl(1);
1445 if ($line2[
'batch'] !=
'') {
1446 $tmpbatch->fetch(0, $line2[
'fk_product'], $line2[
'batch']);
1447 print $tmpbatch->getNomUrl(1);
1459 if (
$object->status == Mo::STATUS_DRAFT) {
1460 $href = $_SERVER[
"PHP_SELF"] .
'?id=' . ((int)
$object->id) .
'&action=editline&token=' .
newToken() .
'&lineid=' . ((int) $line2[
'rowid']);
1461 print
'<td class="center">';
1462 print
'<a class="reposition" href="' . $href .
'">';
1463 print
img_picto($langs->trans(
'TooltipEditAndRevertStockMovement'),
'edit');
1469 if ($permissiontodelete) {
1470 $href = $_SERVER[
"PHP_SELF"].
'?id='.((int)
$object->id).
'&action=deleteline&token='.
newToken().
'&lineid='.((int) $line2[
'rowid']).
'&fk_movement='.((int) $line2[
'fk_stock_movement']);
1471 print
'<td class="center">';
1472 print
'<a class="reposition" href="'.$href.
'">';
1473 print
img_picto($langs->trans(
'TooltipDeleteAndRevertStockMovement'),
'delete');
1481 if (in_array($action, array(
'consumeorproduce',
'consumeandproduceall'))) {
1483 print
'<!-- Enter line to consume -->'.
"\n";
1485 print
'<tr data-max-qty="'.$maxQty.
'" name="batch_'.$line->id.
'_'.$i.
'">';
1487 print
'<td><span class="opacitymedium">'.$langs->trans(
"ToConsume").
'</span></td>';
1488 $preselected = (
GETPOSTISSET(
'qty-'.$line->id.
'-'.$i) ?
GETPOST(
'qty-'.$line->id.
'-'.$i) : max(0, $line->qty - $alreadyconsumed));
1489 if ($action ==
'consumeorproduce' && !
getDolGlobalString(
'MRP_AUTO_SET_REMAINING_QUANTITIES_TO_BE_CONSUMED') && !
GETPOSTISSET(
'qty-'.$line->id.
'-'.$i)) {
1494 if (
getDolGlobalString(
'MRP_NEVER_CONSUME_MORE_THAN_EXPECTED') && ($line->qty - $alreadyconsumed) <= 0) {
1495 $disable =
'disabled';
1499 print
'<input type="hidden" name="product-'.$line->id.
'-'.$i.
'" value="'.$line->fk_product.
'">';
1502 print
'<td class="right">';
1503 if ((
int) $tmpproduct->stockable_product > 0) {
1504 print
'<input type="text" class="width50 right" id="qtytoconsume-' . $line->id .
'-' . $i .
'" name="qty-' . $line->id .
'-' . $i .
'" value="' . $preselected .
'" ' . $disable .
'>';
1506 print
'<input type="hidden" id="qtytoconsume-' . $line->id .
'-' . $i .
'" name="qty-' . $line->id .
'-' . $i .
'" value="0">';
1507 print
'<span class="opacitymedium">' . $langs->trans(
"StockDisabled") .
'</span>';
1515 if ($permissiontoupdatecost &&
getDolGlobalString(
'MRP_SHOW_COST_FOR_CONSUMPTION')) {
1525 && ((
int) $tmpproduct->stockable_product > 0)) {
1526 if (empty($line->disable_stock_change)) {
1527 $preselected = (
GETPOSTISSET(
'idwarehouse-'.$line->id.
'-'.$i) ?
GETPOST(
'idwarehouse-'.$line->id.
'-'.$i) : ($tmpproduct->fk_default_warehouse > 0 ? $tmpproduct->fk_default_warehouse :
'ifone'));
1528 print $formproduct->selectWarehouses($preselected,
'idwarehouse-'.$line->id.
'-'.$i,
'', 1, 0, $line->fk_product,
'', 1, 0, array(),
'maxwidth200 csswarehouse_'.$line->id.
'_'.$i);
1530 print
'<span class="opacitymedium">'.$langs->trans(
"DisableStockChange").
'</span>';
1533 if ((
int) $tmpproduct->stockable_product > 0) {
1534 print
'<span class="opacitymedium">' . $langs->trans(
"StockDisabled") .
'</span>';
1536 print
'<span class="opacitymedium">' . $langs->trans(
"NoStockChangeOnServices") .
'</span>';
1548 print
'<td class="nowraponall">';
1549 if ($tmpproduct->status_batch) {
1550 $preselected = (
GETPOSTISSET(
'batch-'.$line->id.
'-'.$i) ?
GETPOST(
'batch-'.$line->id.
'-'.$i) :
'');
1551 print
'<input type="text" class="width75" name="batch-'.$line->id.
'-'.$i.
'" value="'.$preselected.
'" list="batch-'.$line->id.
'-'.$i.
'">';
1552 print $formproduct->selectLotDataList(
'batch-'.$line->id.
'-'.$i, 0, $line->fk_product, 0, array());
1559 print
'<td align="right" class="split">';
1560 print
' '.img_picto($langs->trans(
'AddStockLocationLine'),
'split',
'class="splitbutton" onClick="addDispatchLine('.((int) $line->id).
', \''.
dol_escape_js($type).
'\', \
'qtymissingconsume\', 1)"');
1564 print
'<td align="right" class="splitall">';
1565 if (($action ==
'consumeorproduce' || $action ==
'consumeandproduceall') && $tmpproduct->status_batch == 2) {
1566 print
img_picto($langs->trans(
'SplitAllQuantity'),
'split',
'class="splitbutton splitallbutton field-error-icon" data-max-qty="1" onClick="addDispatchLine('.$line->id.
', \'batch\', \'allmissingconsume\', 1)"');
1571 if (
$object->status == Mo::STATUS_DRAFT) {
1576 if ($permissiontodelete) {
1590 print
'<script type="text/javascript">
1591 $(document).ready(function () {
1592 $("select[name=fk_default_warehouse]").change(function() {
1593 var fk_default_warehouse = $("option:selected", this).val();
1594 $("select[name^=idwarehouse-]").val(fk_default_warehouse).change();
1599 if (in_array($action, array(
'consumeorproduce',
'consumeandproduceall')) &&
1601 print
'<script>$(document).ready(function () {
1602 $("#fk_default_warehouse").change();
1610 print
'<div class="fichehalfright">';
1611 print
'<div class="clearboth"></div>';
1613 $nblinetoproduce = 0;
1614 $atLeastOneEatBy =
false;
1615 $atLeastOneSellBy =
false;
1616 foreach (
$object->lines as $line) {
1617 if ($line->role ==
'toproduce') {
1619 $tmpproduct->fetch($line->fk_product);
1621 $tmpproduct->sell_or_eat_by_mandatory == $tmpproduct::SELL_OR_EAT_BY_MANDATORY_ID_EAT_BY
1622 || $tmpproduct->sell_or_eat_by_mandatory == $tmpproduct::SELL_OR_EAT_BY_MANDATORY_ID_SELL_AND_EAT
1624 $atLeastOneEatBy =
true;
1627 $tmpproduct->sell_or_eat_by_mandatory == $tmpproduct::SELL_OR_EAT_BY_MANDATORY_ID_SELL_BY
1628 || $tmpproduct->sell_or_eat_by_mandatory == $tmpproduct::SELL_OR_EAT_BY_MANDATORY_ID_SELL_AND_EAT
1630 $atLeastOneSellBy =
true;
1636 $newcardbutton =
'';
1637 $url = $_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=addproduceline&token='.
newToken();
1638 $permissiontoaddaproductline =
$object->status != $object::STATUS_PRODUCED &&
$object->status != $object::STATUS_CANCELED;
1639 $parameters = array(
'morecss' =>
'reposition');
1640 if ($action !=
'consumeorproduce' && $action !=
'consumeandproduceall') {
1641 if ($nblinetoproduce == 0 ||
$object->mrptype == 1) {
1642 $newcardbutton =
dolGetButtonTitle($langs->trans(
'AddNewProduceLines'),
'',
'fa fa-plus-circle size15x', $url,
'', (
int) $permissiontoaddaproductline, $parameters);
1646 print
load_fiche_titre($langs->trans(
'Production'), $newcardbutton,
'', 0,
'',
'');
1648 print
'<div class="div-table-responsive-no-min">';
1649 print
'<table id="tablelinestoproduce" class="noborder noshadow nobottom centpercent">';
1651 print
'<tr class="liste_titre trheight5em">';
1653 print
'<td>'.$langs->trans(
"Product").
'</td>';
1655 print
'<td class="right">'.$langs->trans(
"Qty").
'</td>';
1658 print
'<td class="right">'.$langs->trans(
"Unit").
'</td>';
1661 if ($permissiontoupdatecost) {
1662 if (empty($bomcostupdated)) {
1663 print
'<td class="right classfortooltip" title="'.$langs->trans(
"AmountUsedToUpdateWAP").
'">';
1664 print $langs->trans(
"UnitCost");
1667 print
'<td class="right classfortooltip" title="'.$langs->trans(
"AmountUsedToUpdateWAP").
'">';
1668 print $langs->trans(
"ManufacturingPrice");
1673 print
'<td class="right classfortooltip" title="'.$langs->trans(
"QtyAlreadyProduced").
'">';
1674 print $langs->trans(
"QtyAlreadyProducedShort");
1678 if ($collapse || in_array($action, array(
'consumeorproduce',
'consumeandproduceall'))) {
1679 print $langs->trans(
"Warehouse");
1686 if ($collapse || in_array($action, array(
'consumeorproduce',
'consumeandproduceall'))) {
1687 print $langs->trans(
"Batch");
1698 if ($atLeastOneEatBy) {
1699 print
'<td>'.$langs->trans(
"EatByDate").
'</td>';
1703 if ($atLeastOneSellBy) {
1704 print
'<td>'.$langs->trans(
"SellByDate").
'</td>';
1709 if ($permissiontodelete) {
1715 if ($action ==
'addproduceline') {
1716 print
'<!-- Add line to produce -->'.
"\n";
1717 print
'<tr class="liste_titre">';
1721 print $form->select_produits(0,
'productidtoadd',
'', 0, 0, -1, 2,
'', 1, array(), 0,
'1', 0,
'maxwidth300');
1724 print
'<td class="right"><input type="text" name="qtytoadd" value="1" class="width50 right"></td>';
1730 if ($permissiontoupdatecost) {
1734 print
'<td colspan="2">';
1735 print
'<input type="submit" class="button buttongen button-add" name="addproducelinebutton" value="'.$langs->trans(
"Add").
'">';
1736 print
'<input type="submit" class="button buttongen button-cancel" name="canceladdproducelinebutton" value="'.$langs->trans(
"Cancel").
'">';
1749 if ($permissiontodelete) {
1756 $nblinetoproduce = 0;
1757 foreach (
$object->lines as $line) {
1758 if ($line->role ==
'toproduce') {
1763 $nblinetoproducecursor = 0;
1764 foreach (
$object->lines as $line) {
1765 if ($line->role ==
'toproduce') {
1768 $nblinetoproducecursor++;
1771 $tmpproduct->fetch($line->fk_product);
1773 $arrayoflines =
$object->fetchLinesLinked(
'produced', $line->id);
1774 $alreadyproduced = 0;
1775 foreach ($arrayoflines as $line2) {
1776 $alreadyproduced += $line2[
'qty'];
1779 $suffix =
'_'.$line->id;
1780 print
'<!-- Line to dispatch '.$suffix.
' (toproduce) -->'.
"\n";
1782 print
'<input id="qty_ordered'.$suffix.
'" type="hidden" value="'.$line->qty.
'">';
1783 print
'<input id="qty_dispatched'.$suffix.
'" type="hidden" value="'.$alreadyproduced.
'">';
1787 print
'<td>'.$tmpproduct->getNomUrl(1);
1788 print
'<br><span class="opacitymedium small">'.$tmpproduct->label.
'</span>';
1791 print
'<td class="right">'.$line->qty.
'</td>';
1794 print
'<td class="right">'.measuringUnitString($line->fk_unit,
'',
null, 1).
'</td>';
1797 if ($permissiontoupdatecost) {
1799 $manufacturingcost = 0;
1800 $manufacturingcostsrc =
'';
1802 $manufacturingcost = $bomcostupdated;
1803 $manufacturingcostsrc = $langs->trans(
"CalculatedFromProductsToConsume");
1804 if (empty($manufacturingcost)) {
1805 $manufacturingcost = $bomcost;
1806 $manufacturingcostsrc = $langs->trans(
"ValueFromBom");
1808 if (empty($manufacturingcost)) {
1809 $manufacturingcost =
price2num($tmpproduct->cost_price,
'MU');
1810 $manufacturingcostsrc = $langs->trans(
"CostPrice");
1812 if (empty($manufacturingcost)) {
1813 $manufacturingcost =
price2num($tmpproduct->pmp,
'MU');
1814 $manufacturingcostsrc = $langs->trans(
"PMPValue");
1818 print
'<td class="right nowraponall" title="'.dol_escape_htmltag($manufacturingcostsrc).
'">';
1819 if ($manufacturingcost) {
1820 print
price($manufacturingcost);
1825 print
'<td class="right nowraponall">';
1826 if ($alreadyproduced) {
1828 print
'jQuery(document).ready(function() {
1829 jQuery("#expandtoproduce'.$line->id.
'").click(function() {
1830 console.log("Expand mrp_production line '.$line->id.
'");
1831 jQuery(".expanddetailtoproduce'.$line->id.
'").toggle();';
1832 if ($nblinetoproduce == $nblinetoproducecursor) {
1833 print
'if (jQuery("#tablelinestoproduce").hasClass("nobottom")) { jQuery("#tablelinestoproduce").removeClass("nobottom"); } else { jQuery("#tablelinestoproduce").addClass("nobottom"); }';
1839 if (empty(
$conf->use_javascript_ajax)) {
1840 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?collapse='.$collapse.
','.$line->id.
'">';
1842 print
img_picto($langs->trans(
"ShowDetails"),
"chevron-down",
'id="expandtoproduce'.$line->id.
'"');
1843 if (empty(
$conf->use_javascript_ajax)) {
1847 print
' '.$alreadyproduced;
1863 if ($permissiontodelete) {
1864 if ($line->origin_type ==
'free' && empty($arrayoflines)) {
1865 $href = $_SERVER[
"PHP_SELF"];
1866 $href .=
'?id='.$object->id;
1867 $href .=
'&action=deleteline';
1868 $href .=
'&token='.newToken();
1869 $href .=
'&lineid='.$line->id;
1870 print
'<td class="center">';
1871 print
'<a class="reposition" href="'.$href.
'">';
1872 print
img_picto($langs->trans(
'TooltipDeleteAndRevertStockMovement'),
"delete");
1882 foreach ($arrayoflines as $line2) {
1883 print
'<tr class="expanddetailtoproduce'.$line->id.
' hideobject opacitylow">';
1886 $tmpstockmovement->id = $line2[
'fk_stock_movement'];
1887 print
'<a href="'.DOL_URL_ROOT.
'/product/stock/movement_list.php?search_ref='.$tmpstockmovement->id.
'">'.
img_picto($langs->trans(
"StockMovement"),
'movement',
'class="paddingright"').
'</a>';
1897 if ($permissiontoupdatecost) {
1901 print
'<td class="right">'.$line2[
'qty'].
'</td>';
1903 print
'<td class="tdoverflowmax150">';
1904 if ($line2[
'fk_warehouse'] > 0) {
1905 $result = $tmpwarehouse->fetch($line2[
'fk_warehouse']);
1907 print $tmpwarehouse->getNomUrl(1);
1914 if ($line2[
'batch'] !=
'') {
1915 $tmpbatch->fetch(0, $line2[
'fk_product'], $line2[
'batch']);
1916 print $tmpbatch->getNomUrl(1);
1927 if ($permissiontodelete) {
1933 if (in_array($action, array(
'consumeorproduce',
'consumeandproduceall'))) {
1934 print
'<!-- Enter line to produce -->'.
"\n";
1936 print
'<tr data-max-qty="'.$maxQty.
'" name="batch_'.$line->id.
'_'.$i.
'">';
1938 print
'<td><span class="opacitymedium">'.$langs->trans(
"ToProduce").
'</span></td>';
1939 $preselected = (
GETPOSTISSET(
'qtytoproduce-'.$line->id.
'-'.$i) ?
GETPOST(
'qtytoproduce-'.$line->id.
'-'.$i) : max(0, $line->qty - $alreadyproduced));
1940 if ($action ==
'consumeorproduce' && !
GETPOSTISSET(
'qtytoproduce-'.$line->id.
'-'.$i)) {
1944 print
'<td class="right"><input type="text" class="width50 right" id="qtytoproduce-'.$line->id.
'-'.$i.
'" name="qtytoproduce-'.$line->id.
'-'.$i.
'" value="'.$preselected.
'"></td>';
1947 print
'<td class="right"></td>';
1950 if ($permissiontoupdatecost) {
1952 $manufacturingcost = 0;
1953 $manufacturingcostsrc =
'';
1955 $manufacturingcost = $bomcostupdated;
1956 $manufacturingcostsrc = $langs->trans(
"CalculatedFromProductsToConsume");
1957 if (empty($manufacturingcost)) {
1958 $manufacturingcost = $bomcost;
1959 $manufacturingcostsrc = $langs->trans(
"ValueFromBom");
1961 if (empty($manufacturingcost)) {
1962 $manufacturingcost =
price2num($tmpproduct->cost_price,
'MU');
1963 $manufacturingcostsrc = $langs->trans(
"CostPrice");
1965 if (empty($manufacturingcost)) {
1966 $manufacturingcost =
price2num($tmpproduct->pmp,
'MU');
1967 $manufacturingcostsrc = $langs->trans(
"PMPValue");
1972 $preselected = (
GETPOSTISSET(
'pricetoproduce-'.$line->id.
'-'.$i) ?
GETPOST(
'pricetoproduce-'.$line->id.
'-'.$i) : ($manufacturingcost ?
price($manufacturingcost) :
''));
1973 print
'<td class="right"><input type="text" class="width75 right" name="pricetoproduce-'.$line->id.
'-'.$i.
'" value="'.$preselected.
'"></td>';
1975 print
'<td><input type="hidden" class="width50 right" name="pricetoproduce-'.$line->id.
'-'.$i.
'" value="'.($manufacturingcost ? $manufacturingcost :
'').
'"></td>';
1983 $preselected = (
GETPOSTISSET(
'idwarehousetoproduce-'.$line->id.
'-'.$i) ?
GETPOST(
'idwarehousetoproduce-'.$line->id.
'-'.$i) : (
$object->fk_warehouse > 0 ?
$object->fk_warehouse :
'ifone'));
1984 print $formproduct->selectWarehouses($preselected,
'idwarehousetoproduce-'.$line->id.
'-'.$i,
'', 1, 0, $line->fk_product,
'', 1, 0, array(),
'maxwidth200 csswarehouse_'.$line->id.
'_'.$i);
1986 print
'<span class="opacitymedium">'.$langs->trans(
"NoStockChangeOnServices").
'</span>';
1992 if ($tmpproduct->status_batch) {
1993 $preselected = (
GETPOSTISSET(
'batchtoproduce-'.$line->id.
'-'.$i) ?
GETPOST(
'batchtoproduce-'.$line->id.
'-'.$i) :
'');
1994 print
'<input type="text" class="width75" name="batchtoproduce-'.$line->id.
'-'.$i.
'" value="'.$preselected.
'">';
1998 if ($tmpproduct->status_batch) {
2000 print
'<td align="right" class="split">';
2001 print
img_picto($langs->trans(
'AddStockLocationLine'),
'split',
'class="splitbutton" onClick="addDispatchLine('.$line->id.
', \''.$type.
'\', \
'qtymissing\')"');
2004 print
'<td align="right" class="splitall">';
2005 if (($action ==
'consumeorproduce' || $action ==
'consumeandproduceall') && $tmpproduct->status_batch == 2) {
2006 print
img_picto($langs->trans(
'SplitAllQuantity'),
'split',
'class="splitbutton splitallbutton field-error-icon" onClick="addDispatchLine('.$line->id.
', \'batch\', \'alltoproduce\')"');
2017 if ($tmpproduct->sell_or_eat_by_mandatory == $tmpproduct::SELL_OR_EAT_BY_MANDATORY_ID_SELL_BY || $tmpproduct->sell_or_eat_by_mandatory == $tmpproduct::SELL_OR_EAT_BY_MANDATORY_ID_SELL_AND_EAT) {
2018 print
'<td align="right">';
2019 $preselectedSellBy = (
GETPOSTISSET(
'sellby-' . $line->id .
'-' . $i) ?
GETPOSTDATE(
'sellby-' . $line->id .
'-' . $i) :
'');
2020 print $form->selectDate($preselectedSellBy,
'sellby-' . $line->id .
'-' . $i, 0, 0, 1,
'', 1, 0);
2023 if ($atLeastOneSellBy) {
2029 if ($tmpproduct->sell_or_eat_by_mandatory == $tmpproduct::SELL_OR_EAT_BY_MANDATORY_ID_EAT_BY || $tmpproduct->sell_or_eat_by_mandatory == $tmpproduct::SELL_OR_EAT_BY_MANDATORY_ID_SELL_AND_EAT) {
2030 print
'<td align="right">';
2031 $preselectedEatBy = (
GETPOSTISSET(
'eatby-' . $line->id .
'-' . $i) ?
GETPOSTDATE(
'eatby-' . $line->id .
'-' . $i) :
'');
2032 print $form->selectDate($preselectedEatBy,
'eatby-' . $line->id .
'-' . $i, 0, 0, 1,
'', 1, 0);
2035 if ($atLeastOneEatBy) {
2056 if (in_array($action, array(
'consumeorproduce',
'consumeandproduceall',
'addconsumeline'))) {
2060 <script
type=
"text/javascript" language=
"javascript">
2062 $(document).ready(
function() {
2064 updateselectbatchbywarehouse();
2066 updateselectwarehousebybatch();
2069 function updateselectbatchbywarehouse() {
2070 $(document).on(
'change',
"select[name*='idwarehouse']",
function () {
2071 console.log(
"We change warehouse so we update the list of possible batch number");
2073 var selectwarehouse = $(
this);
2075 var selectbatch_name = selectwarehouse.attr(
'name').replace(
'idwarehouse',
'batch');
2076 var selectbatch = $(
"datalist[id*='" + selectbatch_name +
"']");
2077 var selectedbatch = selectbatch.val();
2079 var product_element_name = selectwarehouse.attr(
'name').replace(
'idwarehouse',
'product');
2083 url:
"<?php echo DOL_URL_ROOT . '/mrp/ajax/interface.php'; ?>",
2085 action:
"updateselectbatchbywarehouse",
2086 permissiontoproduce: <?php echo $permissiontoproduce ?>,
2087 warehouse_id: $(
this).val(),
2088 token:
'<?php echo currentToken(); ?>',
2089 product_id: $(
"input[name='" + product_element_name +
"']").val()
2091 }).done(
function (data) {
2093 selectbatch.empty();
2095 if (typeof data ==
"object") {
2096 console.log(
"data is already type object, no need to parse it");
2098 console.log(
"data is type "+(typeof data));
2099 data = JSON.parse(data);
2102 selectbatch.append($(
'<option>', {
2106 $.each(data,
function (key, value) {
2108 if(selectwarehouse.val() == -1) {
2109 var label = key +
" (<?php echo $langs->trans('TotalStock') ?> : " + value +
")";
2111 var label = key +
" (<?php echo $langs->trans('Stock') ?> : " + value +
")";
2114 if(key === selectedbatch) {
2115 var option =
'<option value="'+key+
'" selected>'+ label +
'</option>';
2117 var option =
'<option value="'+key+
'">'+ label +
'</option>';
2120 selectbatch.append(option);
2126 function updateselectwarehousebybatch() {
2127 $(document).on(
'change',
'input[name*=batch]',
function(){
2128 console.log(
"We change batch so we update the list of possible warehouses");
2130 var selectbatch = $(
this);
2132 var selectwarehouse_name = selectbatch.attr(
'name').replace(
'batch',
'idwarehouse');
2133 var selectwarehouse = $(
"select[name*='" + selectwarehouse_name +
"']");
2134 var selectedwarehouse = selectwarehouse.val();
2136 if(selectedwarehouse != -1){
2140 var product_element_name = selectbatch.attr(
'name').replace(
'batch',
'product');
2144 url:
"<?php echo DOL_URL_ROOT . '/mrp/ajax/interface.php'; ?>",
2146 action:
"updateselectwarehousebybatch",
2147 permissiontoproduce: <?php echo $permissiontoproduce ?>,
2148 batch: $(
this).val(),
2149 token:
'<?php echo currentToken(); ?>',
2150 product_id: $(
"input[name='" + product_element_name +
"']").val()
2152 }).done(
function (data) {
2154 if (typeof data ==
"object") {
2155 console.log(
"data is already type object, no need to parse it");
2157 console.log(
"data is type "+(typeof data));
2158 data = JSON.parse(data);
2162 selectwarehouse.val(data).change();
$id
Support class for third parties, contacts, members, users or resources.
if(! $sortfield) if(! $sortorder) $object
llxFooter($comment='', $zone='private', $disabledoutputofmessages=0)
Empty footer.
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
Class of dictionary type of thirdparty (used by imports)
Class to manage warehouses.
Class to manage stock movements.
Class to manage predefined suppliers products.
Class to manage products or services.
const TYPE_PRODUCT
Regular product.
const TYPE_SERVICE
Service.
Class with list of lots and properties.
Class to manage projects.
Class to manage translations.
convertDurationtoHour($duration_value, $duration_unit)
Convert duration to hour.
dol_now($mode='gmt')
Return date for now.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
GETPOSTDATE($prefix, $hourTime='', $gm='auto', $saverestore='')
Helper function that combines values of a dolibarr DatePicker (such as Form\selectDate) for year,...
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2, $allowothertags=array())
Show picto whatever it's its name (generic function)
img_warning($titlealt='default', $moreatt='', $morecss='pictowarning')
Show warning logo.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0, $morecssdiv='')
Show tabs of a record.
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
dolGetButtonTitle($label, $helpText='', $iconClass='fa fa-file', $url='', $id='', $status=1, $params=array())
Function dolGetButtonTitle : this kind of buttons are used in title in list.
dolBuildUrl($url, $params=[], $addtoken=false, $anchor='')
Return path of url.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
price($amount, $form=0, $outlangs='', $trunc=1, $rounding=-1, $forcerounding=-1, $currency_code='')
Function to format a value into an amount for visual output Function used into PDF and HTML pages.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
dol_escape_js($stringtoescape, $mode=0, $noescapebackslashn=0)
Returns text escaped for inclusion into JavaScript code.
newToken()
Return the value of token currently saved into session with name 'newtoken'.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0, $nodefault=0)
Return value of a param into GET or POST supervariable.
GETPOSTFLOAT($paramname, $rounding='', $option=2)
Return the value of a $_GET or $_POST supervariable, converted into float.
yn($yesno, $format=1, $color=0)
Return yes or no in current language.
GETPOSTINT($paramname, $method=0, $nodefault=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false, $decorate=0)
Output date in a string format according to outputlangs (or langs if not defined).
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='', $morecssonpicto='widthpictotitle')
Load a title with picto.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
isModEnabled($module)
Is Dolibarr module enabled.
img_edit($titlealt='default', $float=0, $other='')
Show logo edit/modify fiche.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
Returns text escaped for inclusion in HTML alt or title or value tags, or into values of HTML input f...
print $langs trans("Show") . '< td style="' . $timeColor . '" align="center"> s</td > badge status0 badge status4 badge status3 Error badge status8< td align="center">< span class="badge ' . $badge . '"></span ></td >< td align="center">< a href="#" class="button button-small" onclick="openLogModal(this)" data-req="' . dol_escape_htmltag($reqSafe) . '" data-res="' . dol_escape_htmltag($resSafe) . '" data-err="' . dol_escape_htmltag($errSafe) . '">< span class="fa fa-search-plus"></span ></a ></td ></tr >< tr >< td colspan="' . $colspan . '" class="opacitymedium"></td ></tr ></table ></div ></form > logModal none logModal none s a JSON string
buildzip.php
moPrepareHead($object)
Prepare array of tabs for Mo.
measuringUnitString($unitid, $measuring_style='', $unitscale=null, $use_short_label=0, $outputlangs=null)
Return translation label of a unit key.
if(preg_match('/(crypted|dolcrypt):/i', $dolibarr_main_db_pass)||!empty($dolibarr_main_db_encrypted_pass)) $conf db type
'integer', 'integer:ObjectClass:PathToClass[:AddCreateButtonOrNot[:Filter[:Sortfield]]]',...
restrictedArea(User $user, $features, $object=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $isdraft=0, $nodie=0, $mode='')
Check permissions of a user to show a page and an object.