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) {
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);
298 if (in_array($action, array(
'confirm_consumeorproduce',
'confirm_consumeandproduceall')) && $permissiontoproduce) {
301 $labelmovement =
GETPOST(
'inventorylabel',
'alphanohtml');
302 $codemovement =
GETPOST(
'inventorycode',
'alphanohtml');
307 foreach (
$object->lines as $line) {
308 if ($line->role ==
'toconsume') {
310 $tmpproduct->fetch($line->fk_product);
316 if ($qtytoprocess != 0) {
319 if (!(
GETPOST(
'idwarehouse-'.$line->id.
'-'.$i) > 0)) {
320 $langs->load(
"errors");
321 setEventMessages($langs->trans(
"ErrorFieldRequiredForProduct", $langs->transnoentitiesnoconv(
"Warehouse"), (
string) $tmpproduct->ref),
null,
'errors');
324 if ($tmpproduct->status_batch && (!
GETPOST(
'batch-'.$line->id.
'-'.$i))) {
325 $langs->load(
"errors");
326 setEventMessages($langs->trans(
"ErrorFieldRequiredForProduct", $langs->transnoentitiesnoconv(
"Batch"), (
string) $tmpproduct->ref),
null,
'errors');
332 if (!$error &&
GETPOST(
'idwarehouse-'.$line->id.
'-'.$i) > 0) {
334 $id_product_batch = 0;
336 $stockmove->context[
'mrp_role'] =
'toconsume';
338 if ($qtytoprocess >= 0) {
339 $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);
341 $idstockmove = $stockmove->reception($user, $line->fk_product,
GETPOSTINT(
'idwarehouse-'.$line->id.
'-'.$i), $qtytoprocess * -1, 0, $labelmovement,
dol_now(),
'',
'',
GETPOST(
'batch-'.$line->id.
'-'.$i), $id_product_batch, $codemovement);
343 if ($idstockmove < 0) {
353 $moline->position = $pos;
354 $moline->fk_product = $line->fk_product;
355 $moline->fk_warehouse =
GETPOSTINT(
'idwarehouse-'.$line->id.
'-'.$i);
356 $moline->qty = $qtytoprocess;
357 $moline->batch =
GETPOST(
'batch-'.$line->id.
'-'.$i);
358 $moline->role =
'consumed';
359 $moline->fk_mrp_production = $line->id;
360 $moline->fk_stock_movement = $idstockmove == 0 ? null : $idstockmove;
361 $moline->fk_user_creat = $user->id;
363 $resultmoline = $moline->create($user);
364 if ($resultmoline <= 0) {
381 foreach (
$object->lines as $line) {
382 if ($line->role ==
'toproduce') {
384 $tmpproduct->fetch($line->fk_product);
387 while (
GETPOSTISSET(
'qtytoproduce-'.$line->id.
'-'.$i)) {
388 $qtytoprocess = (float)
price2num(
GETPOST(
'qtytoproduce-'.$line->id.
'-'.$i));
389 $pricetoprocess =
GETPOST(
'pricetoproduce-'.$line->id.
'-'.$i) ?
price2num(
GETPOST(
'pricetoproduce-'.$line->id.
'-'.$i)) : 0;
391 if ($qtytoprocess != 0) {
393 if (
GETPOSTISSET(
'idwarehousetoproduce-'.$line->id.
'-'.$i)) {
394 if (!(
GETPOST(
'idwarehousetoproduce-'.$line->id.
'-'.$i) > 0)) {
395 $langs->load(
"errors");
396 setEventMessages($langs->trans(
"ErrorFieldRequiredForProduct", $langs->transnoentitiesnoconv(
"Warehouse"), $tmpproduct->ref),
null,
'errors');
399 if (
isModEnabled(
'productbatch') && $tmpproduct->status_batch && (!
GETPOST(
'batchtoproduce-'.$line->id.
'-'.$i))) {
400 $langs->load(
"errors");
401 setEventMessages($langs->trans(
"ErrorFieldRequiredForProduct", $langs->transnoentitiesnoconv(
"Batch"), $tmpproduct->ref),
null,
'errors');
407 if (!$error &&
GETPOST(
'idwarehousetoproduce-'.$line->id.
'-'.$i) > 0) {
409 $id_product_batch = 0;
410 $stockmove->origin_type =
$object->element;
411 $stockmove->origin_id =
$object->id;
412 $stockmove->context[
'mrp_role'] =
'toproduce';
414 $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);
415 if ($idstockmove < 0) {
425 $moline->position = $pos;
426 $moline->fk_product = $line->fk_product;
427 $moline->fk_warehouse =
GETPOSTINT(
'idwarehousetoproduce-'.$line->id.
'-'.$i);
428 $moline->qty = $qtytoprocess;
429 $moline->batch =
GETPOST(
'batchtoproduce-'.$line->id.
'-'.$i);
430 $moline->role =
'produced';
431 $moline->fk_mrp_production = $line->id;
432 $moline->fk_stock_movement = (($idstockmove == 0) ?
null : $idstockmove);
433 $moline->fk_user_creat = $user->id;
435 $resultmoline = $moline->create($user);
436 if ($resultmoline <= 0) {
451 $consumptioncomplete =
true;
452 $productioncomplete =
true;
455 foreach (
$object->lines as $line) {
457 $tmpproduct->fetch($line->fk_product);
458 if ((
int) $tmpproduct->stockable_product > 0) {
459 if ($line->role ==
'toconsume') {
460 $arrayoflines =
$object->fetchLinesLinked(
'consumed', $line->id);
461 $alreadyconsumed = 0;
462 foreach ($arrayoflines as $line2) {
463 $alreadyconsumed += $line2[
'qty'];
466 if ($alreadyconsumed < $line->qty) {
467 $consumptioncomplete =
false;
470 if ($line->role ==
'toproduce') {
471 $arrayoflines =
$object->fetchLinesLinked(
'produced', $line->id);
472 $alreadyproduced = 0;
473 foreach ($arrayoflines as $line2) {
474 $alreadyproduced += $line2[
'qty'];
477 if ($alreadyproduced < $line->qty) {
478 $productioncomplete =
false;
484 $consumptioncomplete =
false;
485 $productioncomplete =
false;
489 dol_syslog(
"consumptioncomplete = ".json_encode($consumptioncomplete).
" productioncomplete = ".json_encode($productioncomplete));
490 if ($consumptioncomplete && $productioncomplete) {
491 $result =
$object->setStatut($object::STATUS_PRODUCED, 0,
'',
'MRP_MO_PRODUCED');
493 $result =
$object->setStatut($object::STATUS_INPROGRESS, 0,
'',
'MRP_MO_PRODUCED');
502 $action = str_replace(
'confirm_',
'', $action);
508 header(
"Location: ".$_SERVER[
"PHP_SELF"].
'?id='.
$object->id);
514 if ($action ==
'confirm_produced' && $confirm ==
'yes' && $permissiontoadd) {
515 $result =
$object->setStatut($object::STATUS_PRODUCED, 0,
'',
'MRP_MO_PRODUCED');
519 $outputlangs = $langs;
522 $newlang =
GETPOST(
'lang_id',
'aZ09');
525 $newlang =
$object->thirdparty->default_lang;
527 if (!empty($newlang)) {
529 $outputlangs->setDefaultLang($newlang);
534 $object->generateDocument($model, $outputlangs, 0, 0, 0);
541 if ($action ==
'confirm_editline' && $permissiontoadd) {
545 $extrafields->fetch_name_optionals_label($moline->table_element);
546 if (!empty($extrafields->attributes[$moline->table_element][
'label'])) {
547 foreach ($extrafields->attributes[$moline->table_element][
'label'] as $key => $label) {
548 $value =
GETPOST(
'options_'.$key,
'alphanohtml');
549 $moline->array_options[
"options_".$key] = $value;
554 $moline->fk_warehouse = (
GETPOSTINT(
'warehouse_lineProduce') > 0 ?
GETPOSTINT(
'warehouse_lineProduce') : 0);
557 $moline->fk_default_workstation = (
GETPOSTINT(
'workstation_lineProduce') > 0 ?
GETPOSTINT(
'workstation_lineProduce') : 0);
560 $res = $moline->update($user);
564 header(
"Location: ".$_SERVER[
"PHP_SELF"].
'?id='.
$object->id);
567 header(
"Location: ".$_SERVER[
"PHP_SELF"].
'?id='.
$object->id);
586$title = $langs->trans(
'Mo');
587$help_url =
'EN:Module_Manufacturing_Orders|FR:Module_Ordres_de_Fabrication|DE:Modul_Fertigungsauftrag';
588$morejs = array(
'/mrp/js/lib_dispatch.js.php');
589llxHeader(
'', $title, $help_url,
'', 0, 0, $morejs,
'',
'',
'mod-mrp page-card_production');
594if (
$object->id > 0 && (empty($action) || ($action !=
'edit' && $action !=
'create' && $action !=
'reload'))) {
595 $res =
$object->fetch_thirdparty();
596 $res =
$object->fetch_optionals();
599 $tmpwarehouse->fetch((
int)
$object->fk_warehouse);
600 $fk_default_warehouse = (int)
$object->fk_warehouse;
610 if ($action ==
'delete') {
611 $formquestion = array(
613 'label' => $langs->trans(
'MoCancelConsumedAndProducedLines'),
614 'name' =>
'alsoCancelConsumedAndProducedLines',
615 'type' =>
'checkbox',
619 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'DeleteMo'), $langs->trans(
'ConfirmDeleteMo'),
'confirm_delete', $formquestion, 0, 1);
622 if ($action ==
'deleteline') {
623 $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);
626 if ($action ==
'clone') {
628 $formquestion = array();
629 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'ToClone'), $langs->trans(
'ConfirmCloneMo',
$object->ref),
'confirm_clone', $formquestion,
'yes', 1);
633 if ($action ==
'validate') {
635 $ref = substr(
$object->ref, 1, 4);
636 if ($ref ==
'PROV') {
643 $text = $langs->trans(
'ConfirmValidateMo', $numref);
652 $formquestion = array();
655 require_once DOL_DOCUMENT_ROOT.
'/product/class/html.formproduct.class.php';
658 if (
$conf->browser->name ==
'ie') {
661 $formquestion = array(
668 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'Validate'), $text,
'confirm_validate', $formquestion, 0, 1, 220);
672 if ($action ==
'cancel') {
673 $formquestion = array(
675 'label' => $langs->trans(
'MoCancelConsumedAndProducedLines'),
676 'name' =>
'alsoCancelConsumedAndProducedLines',
677 'type' =>
'checkbox',
678 'value' => !
getDolGlobalString(
'MO_ALSO_CANCEL_CONSUMED_AND_PRODUCED_LINES_BY_DEFAULT') ? 0 : 1
681 $formconfirm = $form->formconfirm(
dolBuildUrl($_SERVER[
"PHP_SELF"], [
'id' =>
$object->id]), $langs->trans(
'CancelMo'), $langs->trans(
'ConfirmCancelMo'),
'confirm_cancel', $formquestion, 0, 1);
685 $parameters = array(
'formConfirm' => $formconfirm,
'lineid' => $lineid);
686 $reshook = $hookmanager->executeHooks(
'formConfirm', $parameters, $object, $action);
687 if (empty($reshook)) {
688 $formconfirm .= $hookmanager->resPrint;
689 } elseif ($reshook > 0) {
690 $formconfirm = $hookmanager->resPrint;
699 $linkback =
'<a href="'.DOL_URL_ROOT.
'/mrp/mo_list.php?restore_lastsearch_values=1'.(!empty($socid) ?
'&socid='.$socid :
'').
'">'.$langs->trans(
"BackToList").
'</a>';
701 $morehtmlref =
'<div class="refidno">';
710 if (is_object(
$object->thirdparty)) {
711 $morehtmlref .=
$object->thirdparty->getNomUrl(1,
'customer');
713 $morehtmlref .=
' (<a href="'.DOL_URL_ROOT.
'/commande/list.php?socid='.
$object->thirdparty->id.
'">'.$langs->trans(
"OtherOrders").
'</a>)';
719 $langs->load(
"projects");
720 if (is_object(
$object->thirdparty)) {
721 $morehtmlref .=
'<br>';
723 if ($permissiontoadd) {
724 $morehtmlref .=
img_picto($langs->trans(
"Project"),
'project',
'class="pictofixedwidth"');
725 if ($action !=
'classify') {
726 $morehtmlref .=
'<a class="editfielda" href="'.dolBuildUrl($_SERVER[
'PHP_SELF'], [
'action' =>
'classify',
'id' =>
$object->id],
true).
'">'.
img_edit($langs->transnoentitiesnoconv(
'SetProject')).
'</a> ';
728 $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');
730 if (!empty(
$object->fk_project)) {
732 $proj->fetch(
$object->fk_project);
733 $morehtmlref .= $proj->getNomUrl(1);
735 $morehtmlref .=
'<span class="opacitymedium"> - '.dol_escape_htmltag($proj->title).
'</span>';
740 $morehtmlref .=
'</div>';
743 dol_banner_tab($object,
'ref', $linkback, 1,
'ref',
'ref', $morehtmlref);
746 print
'<div class="fichecenter">';
747 print
'<div class="fichehalfleft">';
748 print
'<div class="underbanner clearboth"></div>';
749 print
'<table class="border centpercent tableforfield">'.
"\n";
752 $keyforbreak =
'fk_warehouse';
753 unset(
$object->fields[
'fk_project']);
754 unset(
$object->fields[
'fk_soc']);
760 if (
$object->status == Mo::STATUS_DRAFT && $permissiontoadd && isset(
$object->fields[
'qty'])) {
761 $object->fields[
'qty'][
'alwayseditable'] = 1;
762 if ($action ==
'editqty') {
763 $object->fields[
'qty'][
'type'] =
'numeric';
767 include DOL_DOCUMENT_ROOT.
'/core/tpl/commonfields_view.tpl.php';
770 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_view.tpl.php';
776 print
'<div class="clearboth"></div>';
781 if (!in_array($action, array(
'consumeorproduce',
'consumeandproduceall'))) {
782 print
'<div class="tabsAction">';
784 $parameters = array();
786 $reshook = $hookmanager->executeHooks(
'addMoreActionsButtons', $parameters, $object, $action);
787 if (empty($reshook)) {
789 if (
$object->status == $object::STATUS_DRAFT) {
790 if ($permissiontoadd) {
792 print
'<a class="butAction" href="'.$_SERVER[
'PHP_SELF'].
'?id='.
$object->id.
'&action=validate&token='.$newToken.
'">'.$langs->trans(
"Validate").
'</a>';
794 $langs->load(
"errors");
795 print
'<a class="butActionRefused" href="" title="'.$langs->trans(
"ErrorAddAtLeastOneLineFirst").
'">'.$langs->trans(
"Validate").
'</a>';
801 if (
$object->status == Mo::STATUS_VALIDATED ||
$object->status == Mo::STATUS_INPROGRESS) {
802 if ($permissiontoproduce) {
803 print
'<a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=consumeorproduce&token='.$newToken.
'">'.$langs->trans(
'ConsumeOrProduce').
'</a>';
805 print
'<a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans(
"NotEnoughPermissions").
'">'.$langs->trans(
'ConsumeOrProduce').
'</a>';
807 } elseif (
$object->status == Mo::STATUS_DRAFT) {
808 print
'<a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans(
"ValidateBefore").
'">'.$langs->trans(
'ConsumeOrProduce').
'</a>';
812 if (
$object->status == Mo::STATUS_VALIDATED ||
$object->status == Mo::STATUS_INPROGRESS) {
813 if ($permissiontoproduce) {
814 print
'<a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=consumeandproduceall&token='.$newToken.
'">'.$langs->trans(
'ConsumeAndProduceAll').
'</a>';
816 print
'<a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans(
"NotEnoughPermissions").
'">'.$langs->trans(
'ConsumeAndProduceAll').
'</a>';
818 } elseif (
$object->status == Mo::STATUS_DRAFT) {
819 print
'<a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans(
"ValidateBefore").
'">'.$langs->trans(
'ConsumeAndProduceAll').
'</a>';
823 if ($permissiontoadd) {
824 if (
$object->status == $object::STATUS_VALIDATED ||
$object->status == $object::STATUS_INPROGRESS) {
825 $arrayproduced =
$object->fetchLinesLinked(
'produced', 0);
827 foreach ($arrayproduced as $lineproduced) {
828 $nbProduced += $lineproduced[
'qty'];
830 if ($nbProduced > 0) {
831 print
'<a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=confirm_produced&confirm=yes&token='.$newToken.
'">'.$langs->trans(
"Close").
'</a>'.
"\n";
833 print
'<a class="butActionRefused" href="#" title="'.$langs->trans(
"GoOnTabProductionToProduceFirst", $langs->transnoentitiesnoconv(
"Production")).
'">'.$langs->trans(
"Close").
'</a>'.
"\n";
836 print
'<a class="butActionDelete" href="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=cancel&token='.$newToken.
'">'.$langs->trans(
"Cancel").
'</a>'.
"\n";
839 if (
$object->status == $object::STATUS_CANCELED) {
840 print
'<a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=confirm_reopen&confirm=yes&token='.$newToken.
'">'.$langs->trans(
"ReOpen").
'</a>'.
"\n";
843 if (
$object->status == $object::STATUS_PRODUCED) {
844 if ($permissiontoproduce) {
845 print
'<a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=confirm_reopen&token='.$newToken.
'">'.$langs->trans(
'ReOpen').
'</a>';
847 print
'<a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans(
"NotEnoughPermissions").
'">'.$langs->trans(
'ReOpen').
'</a>';
856 if (in_array($action, array(
'consumeorproduce',
'consumeandproduceall',
'addconsumeline',
'addproduceline',
'editline'))) {
857 print
'<!-- Form to enter value for consumption/production -->';
858 print
'<form method="POST" action="'.dolBuildUrl($_SERVER[
"PHP_SELF"]).
'">';
859 print
'<input type="hidden" name="token" value="'.newToken().
'">';
860 print
'<input type="hidden" name="action" value="confirm_'.$action.
'">';
861 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
862 print
'<input type="hidden" name="id" value="'.$id.
'">';
865 if (in_array($action, array(
'consumeorproduce',
'consumeandproduceall'))) {
866 $defaultstockmovementlabel =
GETPOST(
'inventorylabel',
'alphanohtml') ?
GETPOST(
'inventorylabel',
'alphanohtml') : $langs->trans(
"ProductionForRef",
$object->
ref);
869 print
'<div class="center'.(in_array($action, array(
'consumeorproduce',
'consumeandproduceall')) ?
' formconsumeproduce' :
'').
'">';
870 print
'<div class="opacitymedium hideonsmartphone paddingbottom marginbottomonly">'.$langs->trans(
"ConfirmProductionDesc", $langs->transnoentitiesnoconv(
"Confirm")).
'<br></div>';
871 print
'<span class="paddingright">'.$langs->trans(
"InventoryCode").
':</span>';
872 print
'<span class="clearbothonsmartphone"></span>';
873 print
'<input type="text" class="minwidth125 maxwidth150" name="inventorycode" value="'.$defaultstockmovementcode.
'">';
874 print
'<span class="hideonsmartphone"> </span>';
875 print
'<span class="clearbothonsmartphone"></span>';
876 print
'<span class="paddingright">'.$langs->trans(
"MovementLabel").
':</span>';
877 print
'<span class="clearbothonsmartphone"></span>';
878 print
'<input type="text" class="minwidth300" name="inventorylabel" value="'.$defaultstockmovementlabel.
'"><br><br>';
879 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>';
880 print
'<input type="submit" class="button margintoponly" value="'.$langs->trans(
"Confirm").
'" name="confirm">';
882 print
'<input class="button margintoponly button-cancel" type="submit" value="'.$langs->trans(
"Cancel").
'" name="cancel">';
896 if (!empty(
$object->table_element_line)) {
903 $res = $bom->fetch(
$object->fk_bom);
905 $bom->calculateCosts();
906 $bomcost = $bom->unit_cost;
912 print
'<!-- Lines to consume -->'.
"\n";
913 print
'<div class="fichecenter">';
914 print
'<div class="fichehalfleft">';
915 print
'<div class="clearboth"></div>';
917 $url = $_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=addconsumeline&token='.
newToken();
918 $permissiontoaddaconsumeline = (
$object->status != $object::STATUS_PRODUCED &&
$object->status != $object::STATUS_CANCELED) ? 1 : -2;
919 $parameters = array(
'morecss' =>
'reposition');
921 if ($permissiontoaddaconsumeline == -2) {
922 $helpText = $langs->trans(
'MOIsClosed');
926 if ($action !=
'consumeorproduce' && $action !=
'consumeandproduceall') {
927 $newcardbutton =
dolGetButtonTitle($langs->trans(
'AddNewConsumeLines'), $helpText,
'fa fa-plus-circle size15x', $url,
'', $permissiontoaddaconsumeline, $parameters);
930 print
load_fiche_titre($langs->trans(
'Consumption'), $newcardbutton,
'', 0,
'',
'',
'');
932 print
'<div class="div-table-responsive-no-min">';
933 print
'<table class="noborder noshadow centpercent nobottom">';
935 print
'<!-- Line of title for products to consume -->'.
"\n";
936 print
'<tr class="liste_titre trheight5em">';
938 print
'<td>'.$langs->trans(
"Product").
'</td>';
940 print
'<td class="right">'.$langs->trans(
"Qty").
'</td>';
945 print
'<td class="right">'.$langs->trans(
"UnitCost").
'</td>';
948 print
'<td class="right classfortooltip" title="'.$langs->trans(
"QtyAlreadyConsumed").
'">';
949 print $langs->trans(
"QtyAlreadyConsumedShort");
953 if ($collapse || in_array($action, array(
'consumeorproduce',
'consumeandproduceall'))) {
954 print $langs->trans(
"Warehouse");
956 print
' '.$langs->trans(
"or").
' '.$langs->trans(
"Workstation");
959 if (in_array($action, array(
'consumeorproduce',
'consumeandproduceall'))) {
960 $listwarehouses = $tmpwarehouse->list_array(1);
961 if (count($listwarehouses) > 1) {
962 print
'<br>'.$form->selectarray(
'fk_default_warehouse', $listwarehouses, $fk_default_warehouse, $langs->trans(
"ForceTo"), 0, 0,
'', 0, 0, 0,
'',
'minwidth100 maxwidth200', 1);
963 } elseif (count($listwarehouses) == 1) {
964 print
'<br>'.$form->selectarray(
'fk_default_warehouse', $listwarehouses, $fk_default_warehouse, 0, 0, 0,
'', 0, 0, 0,
'',
'minwidth100 maxwidth200', 1);
972 print
'<td align="right">';
973 if ($collapse || in_array($action, array(
'consumeorproduce',
'consumeandproduceall'))) {
974 print $langs->trans(
"Stock");
981 if ($collapse || in_array($action, array(
'consumeorproduce',
'consumeandproduceall'))) {
982 print $langs->trans(
"Batch");
994 if (
$object->status == Mo::STATUS_DRAFT) {
999 if ($permissiontodelete) {
1005 if ($action ==
'addconsumeline') {
1006 print
'<!-- Add line to consume -->'.
"\n";
1007 print
'<tr class="liste_titre">';
1010 print $form->select_produits(0,
'productidtoadd',
'', 0, 0, -1, 2,
'', 1, array(), 0,
'1', 0,
'maxwidth150');
1013 print
'<td class="right"><input type="text" name="qtytoadd" value="1" class="width40 right"></td>';
1021 if ($permissiontoupdatecost &&
getDolGlobalString(
'MRP_SHOW_COST_FOR_CONSUMPTION')) {
1033 print
'<td colspan="'.$colspan.
'">';
1034 print
'<input type="submit" class="button buttongen button-add" name="addconsumelinebutton" value="'.$langs->trans(
"Add").
'">';
1035 print
'<input type="submit" class="button buttongen button-cancel" name="canceladdconsumelinebutton" value="'.$langs->trans(
"Cancel").
'">';
1040 if (
$object->status == Mo::STATUS_DRAFT) {
1044 if ($permissiontodelete) {
1050 if (is_object($objectline)) {
1051 $extrafields->fetch_name_optionals_label(
$object->table_element_line);
1052 $temps = $objectline->showOptionals($extrafields,
'edit', array(),
'',
'',
'1',
'line');
1053 if (!empty($temps)) {
1054 print
'<tr class="liste_titre"><td style="padding-top: 20px" colspan="9" id="extrafield_lines_area_edit" name="extrafield_lines_area_edit">';
1063 $bomcostupdated = 0;
1066 $nblinetoconsume = 0;
1067 foreach (
$object->lines as $line) {
1068 if ($line->role ==
'toconsume') {
1073 $nblinetoconsumecursor = 0;
1074 foreach (
$object->lines as $line) {
1075 if ($line->role ==
'toconsume') {
1076 $nblinetoconsumecursor++;
1079 $tmpproduct->fetch($line->fk_product);
1080 $linecost =
price2num($tmpproduct->pmp,
'MT');
1084 $costprice =
price2num((!empty($tmpproduct->cost_price)) ? $tmpproduct->cost_price : $tmpproduct->pmp);
1085 if (empty($costprice)) {
1086 require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.product.class.php';
1088 if ($productFournisseur->find_min_price_product_fournisseur($line->fk_product, $line->qty) > 0) {
1089 $costprice = $productFournisseur->fourn_unitprice;
1097 if ($useunit && $line->fk_unit > 0) {
1099 $qtyhourservice = 0;
1100 if (preg_match(
'/^(\d+)([a-z]+)$/', $tmpproduct->duration, $reg)) {
1103 $qtyhourforline = 0;
1104 if ($line->fk_unit) {
1110 if (
isModEnabled(
'workstation') && $line->fk_default_workstation > 0) {
1112 $workstation->fetch($line->fk_default_workstation);
1113 $linecost =
price2num($qtyhourforline * ($workstation->thm_operator_estimated + $workstation->thm_machine_estimated) /
$object->qty,
'MT');
1114 $bomcostupdated +=
price2num($qtyhourforline * ($workstation->thm_operator_estimated + $workstation->thm_machine_estimated) /
$object->qty,
'MU');
1115 } elseif ($qtyhourservice && $qtyhourforline) {
1116 $linecost =
price2num(($qtyhourforline / $qtyhourservice * $costprice) /
$object->qty,
'MT');
1117 $bomcostupdated +=
price2num(($qtyhourforline / $qtyhourservice * $costprice) /
$object->qty,
'MU');
1120 $bomcostupdated +=
price2num(($line->qty * $costprice) /
$object->qty,
'MU');
1124 $bomcostupdated +=
price2num(($line->qty * $costprice) /
$object->qty,
'MU');
1128 $bomcostupdated =
price2num($bomcostupdated,
'MU');
1129 $arrayoflines =
$object->fetchLinesLinked(
'consumed', $line->id);
1130 $alreadyconsumed = 0;
1131 foreach ($arrayoflines as $line2) {
1132 $alreadyconsumed += $line2[
'qty'];
1135 if ($action ==
'editline' && $lineid == $line->id) {
1136 $linecost =
price2num($tmpproduct->pmp,
'MT');
1138 $arrayoflines =
$object->fetchLinesLinked(
'consumed', $line->id);
1139 $alreadyconsumed = 0;
1140 if (is_array($arrayoflines) && !empty($arrayoflines)) {
1141 foreach ($arrayoflines as $line2) {
1142 $alreadyconsumed += $line2[
'qty'];
1145 $suffix =
'_' . $line->id;
1146 print
'<!-- Line to dispatch ' . $suffix .
' (line edited) -->' .
"\n";
1148 print
'<input id="qty_ordered' . $suffix .
'" type="hidden" value="' . $line->qty .
'">';
1150 print
'<input id="qty_dispatched' . $suffix .
'" type="hidden" value="' . $alreadyconsumed .
'">';
1152 print
'<input name="lineid" type="hidden" value="' . $line->id .
'">';
1155 print
'<td>' . $tmpproduct->getNomUrl(1);
1156 print
'<br><div class="opacitymedium small tdoverflowmax150" title="' .
dol_escape_htmltag($tmpproduct->label) .
'">' . $tmpproduct->label .
'</span>';
1160 print
'<td class="right nowraponall">';
1161 print
'<input class="width40 right" name="qty_lineProduce" value="'. $line->qty.
'">';
1165 print
'<td class="right nowraponall">';
1173 if ($permissiontoupdatecost &&
getDolGlobalString(
'MRP_SHOW_COST_FOR_CONSUMPTION')) {
1178 print
'<td class="right">';
1179 print
' ' .
price2num($alreadyconsumed,
'MS');
1185 print $formproduct->selectWarehouses($line->fk_warehouse,
'warehouse_lineProduce',
'warehouseopen', 1);
1187 print $formproduct->selectWorkstations($line->fk_default_workstation,
'workstation_lineProduce', 1);
1193 print
'<td class="nowraponall right">';
1194 if ($tmpproduct->isStockManaged()) {
1195 if ($tmpproduct->stock_reel < ($line->qty - $alreadyconsumed)) {
1196 print
img_warning($langs->trans(
'StockTooLow')).
' ';
1198 print
'<span class="left">'. $tmpproduct->stock_reel .
' </span>';
1208 print
'<td colspan="'.(3 + (
$object->status == Mo::STATUS_DRAFT ? 1 : 0) + ($permissiontodelete ? 1 : 0)).
'">';
1209 print
'<input type="submit" class="button buttongen button-add small nominwidth" name="save" value="' . $langs->trans(
"Save") .
'">';
1210 print
'<input type="submit" class="button buttongen button-cancel small nominwidth" name="cancel" value="' . $langs->trans(
"Cancel") .
'">';
1216 if (!empty($extrafields)) {
1217 $line->fetch_optionals();
1218 $temps = $line->showOptionals($extrafields,
'edit', array(),
'',
'',
'1',
'line');
1219 if (!empty($temps)) {
1221 print
'<tr><td colspan="'.$colspan.
'"><div style="padding-top: 20px" id="extrafield_lines_area_edit" name="extrafield_lines_area_edit">';
1223 print
'</div></td></tr>';
1227 $suffix =
'_' . $line->id;
1228 print
'<!-- Line to dispatch ' . $suffix .
' -->' .
"\n";
1230 print
'<input id="qty_ordered' . $suffix .
'" type="hidden" value="' . $line->qty .
'">';
1231 print
'<input id="qty_dispatched' . $suffix .
'" type="hidden" value="' . $alreadyconsumed .
'">';
1233 print
'<tr data-line-id="' . $line->id .
'">';
1236 print
'<td>' . $tmpproduct->getNomUrl(1);
1237 print
'<br><div class="opacitymedium small tdoverflowmax150" title="' .
dol_escape_htmltag($tmpproduct->label) .
'">' . $tmpproduct->label .
'</div>';
1241 print
'<td class="right nowraponall">';
1243 if ($line->qty_frozen) {
1244 $help = ($help ?
'<br>' :
'') .
'<strong>' . $langs->trans(
"QuantityFrozen") .
'</strong>: ' .
yn(1) .
' (' . $langs->trans(
"QuantityConsumedInvariable") .
')';
1245 print $form->textwithpicto(
'', $help, -1,
'lock') .
' ';
1247 if ($line->disable_stock_change) {
1248 $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")) .
')';
1249 print $form->textwithpicto(
'', $help, -1,
'help') .
' ';
1255 print
'<td class="right nowraponall">';
1263 if ($permissiontoupdatecost &&
getDolGlobalString(
'MRP_SHOW_COST_FOR_CONSUMPTION')) {
1264 print
'<td class="right nowraponall">';
1265 print
price($linecost);
1270 print
'<td class="right">';
1271 if ($alreadyconsumed) {
1273 print
'jQuery(document).ready(function() {
1274 jQuery("#expandtoproduce' . $line->id .
'").click(function() {
1275 console.log("Expand mrp_production line ' . $line->id .
'");
1276 jQuery(".expanddetail' . $line->id .
'").toggle();';
1277 if ($nblinetoconsume == $nblinetoconsumecursor) {
1278 print
'if (jQuery("#tablelines").hasClass("nobottom")) { jQuery("#tablelines").removeClass("nobottom"); } else { jQuery("#tablelines").addClass("nobottom"); }';
1284 if (empty(
$conf->use_javascript_ajax)) {
1285 print
'<a href="' . $_SERVER[
"PHP_SELF"] .
'?collapse=' . $collapse .
',' . $line->id .
'">';
1287 print
img_picto($langs->trans(
"ShowDetails"),
"chevron-down",
'id="expandtoproduce' . $line->id .
'"');
1288 if (empty(
$conf->use_javascript_ajax)) {
1292 if ($nblinetoconsume == $nblinetoconsumecursor) {
1293 print
'<script>jQuery("#tablelines").removeClass("nobottom");</script>';
1296 print
' ' .
price2num($alreadyconsumed,
'MS');
1300 print
'<td class="tdoverflowmax100">';
1301 if ($tmpproduct->isStockManaged()) {
1303 if (
getDolGlobalString(
'STOCK_CONSUMPTION_FROM_MANUFACTURING_WAREHOUSE') && $tmpwarehouse->id > 0) {
1304 print
img_picto(
'', $tmpwarehouse->picto) .
" " . $tmpwarehouse->label;
1306 if ($line->fk_warehouse > 0) {
1308 $warehouseline->fetch($line->fk_warehouse);
1309 print $warehouseline->getNomUrl(1);
1313 if (
isModEnabled(
'workstation') && $line->fk_default_workstation > 0) {
1315 $tmpworkstation->fetch($line->fk_default_workstation);
1316 print $tmpworkstation->getNomUrl(1);
1322 print
'<td class="nowraponall right">';
1324 if (!$line->disable_stock_change && $tmpproduct->stock_reel < ($line->qty - $alreadyconsumed)) {
1325 print
img_warning($langs->trans(
'StockTooLow')) .
' ';
1327 if (!
getDolGlobalString(
'STOCK_CONSUMPTION_FROM_MANUFACTURING_WAREHOUSE') || empty($tmpwarehouse->id)) {
1328 print
price2num($tmpproduct->stock_reel,
'MS');
1331 $tmpproduct->load_stock();
1332 $wh_stock = $tmpproduct->stock_warehouse[$tmpwarehouse->id];
1333 if (!empty($wh_stock)) {
1355 if (
$object->status == Mo::STATUS_DRAFT) {
1356 $href = $_SERVER[
"PHP_SELF"] .
'?id=' . ((int)
$object->id) .
'&action=editline&token=' .
newToken() .
'&lineid=' . ((int) $line->id);
1357 print
'<td class="center">';
1358 print
'<a class="reposition editfielda" href="' . $href .
'">';
1359 print
img_picto($langs->trans(
'TooltipEditAndRevertStockMovement'),
'edit');
1365 if ($permissiontodelete && empty($arrayoflines)) {
1366 $href = $_SERVER[
"PHP_SELF"] .
'?id=' . ((int)
$object->id) .
'&action=deleteline&token=' .
newToken() .
'&lineid=' . ((int) $line->id);
1367 print
'<td class="center">';
1368 print
'<a class="reposition" href="' . $href .
'">';
1369 print
img_picto($langs->trans(
'TooltipDeleteAndRevertStockMovement'),
'delete');
1377 if (!empty($extrafields)) {
1378 $line->fetch_optionals();
1379 $temps = $line->showOptionals($extrafields,
'view', array(),
'',
'',
'1',
'line');
1380 if (!empty($temps)) {
1382 print
'<tr><td colspan="'.$colspan.
'"><div id="extrafield_lines_area_'.$line->id.
'" name="extrafield_lines_area_'.$line->id.
'">';
1384 print
'</div></td></tr>';
1390 foreach ($arrayoflines as $line2) {
1391 print
'<tr class="expanddetail'.$line->id.
' hideobject opacitylow">';
1395 $tmpstockmovement->id = $line2[
'fk_stock_movement'];
1396 print
'<a href="'.DOL_URL_ROOT.
'/product/stock/movement_list.php?search_ref='.$tmpstockmovement->id.
'">'.
img_picto($langs->trans(
"StockMovement"),
'movement',
'class="paddingright"').
'</a>';
1407 if ($permissiontoupdatecost &&
getDolGlobalString(
'MRP_SHOW_COST_FOR_CONSUMPTION')) {
1412 print
'<td class="right">'.$line2[
'qty'].
'</td>';
1415 print
'<td class="tdoverflowmax150">';
1416 if ($line2[
'fk_warehouse'] > 0) {
1417 $result = $tmpwarehouse->fetch($line2[
'fk_warehouse']);
1419 print $tmpwarehouse->getNomUrl(1);
1432 if ($line2[
'batch'] !=
'') {
1433 $tmpbatch->fetch(0, $line2[
'fk_product'], $line2[
'batch']);
1434 print $tmpbatch->getNomUrl(1);
1446 if (
$object->status == Mo::STATUS_DRAFT) {
1447 $href = $_SERVER[
"PHP_SELF"] .
'?id=' . ((int)
$object->id) .
'&action=editline&token=' .
newToken() .
'&lineid=' . ((int) $line2[
'rowid']);
1448 print
'<td class="center">';
1449 print
'<a class="reposition" href="' . $href .
'">';
1450 print
img_picto($langs->trans(
'TooltipEditAndRevertStockMovement'),
'edit');
1456 if ($permissiontodelete) {
1457 $href = $_SERVER[
"PHP_SELF"].
'?id='.((int)
$object->id).
'&action=deleteline&token='.
newToken().
'&lineid='.((int) $line2[
'rowid']).
'&fk_movement='.((int) $line2[
'fk_stock_movement']);
1458 print
'<td class="center">';
1459 print
'<a class="reposition" href="'.$href.
'">';
1460 print
img_picto($langs->trans(
'TooltipDeleteAndRevertStockMovement'),
'delete');
1468 if (in_array($action, array(
'consumeorproduce',
'consumeandproduceall'))) {
1470 print
'<!-- Enter line to consume -->'.
"\n";
1472 print
'<tr data-max-qty="'.$maxQty.
'" name="batch_'.$line->id.
'_'.$i.
'">';
1474 print
'<td><span class="opacitymedium">'.$langs->trans(
"ToConsume").
'</span></td>';
1475 $preselected = (
GETPOSTISSET(
'qty-'.$line->id.
'-'.$i) ?
GETPOST(
'qty-'.$line->id.
'-'.$i) : max(0, $line->qty - $alreadyconsumed));
1476 if ($action ==
'consumeorproduce' && !
getDolGlobalString(
'MRP_AUTO_SET_REMAINING_QUANTITIES_TO_BE_CONSUMED') && !
GETPOSTISSET(
'qty-'.$line->id.
'-'.$i)) {
1481 if (
getDolGlobalString(
'MRP_NEVER_CONSUME_MORE_THAN_EXPECTED') && ($line->qty - $alreadyconsumed) <= 0) {
1482 $disable =
'disabled';
1486 print
'<input type="hidden" name="product-'.$line->id.
'-'.$i.
'" value="'.$line->fk_product.
'">';
1489 print
'<td class="right">';
1490 if ((
int) $tmpproduct->stockable_product > 0) {
1491 print
'<input type="text" class="width50 right" id="qtytoconsume-' . $line->id .
'-' . $i .
'" name="qty-' . $line->id .
'-' . $i .
'" value="' . $preselected .
'" ' . $disable .
'>';
1493 print
'<input type="hidden" id="qtytoconsume-' . $line->id .
'-' . $i .
'" name="qty-' . $line->id .
'-' . $i .
'" value="0">';
1494 print
'<span class="opacitymedium">' . $langs->trans(
"StockDisabled") .
'</span>';
1502 if ($permissiontoupdatecost &&
getDolGlobalString(
'MRP_SHOW_COST_FOR_CONSUMPTION')) {
1512 && ((
int) $tmpproduct->stockable_product > 0)) {
1513 if (empty($line->disable_stock_change)) {
1514 $preselected = (
GETPOSTISSET(
'idwarehouse-'.$line->id.
'-'.$i) ?
GETPOST(
'idwarehouse-'.$line->id.
'-'.$i) : ($tmpproduct->fk_default_warehouse > 0 ? $tmpproduct->fk_default_warehouse :
'ifone'));
1515 print $formproduct->selectWarehouses($preselected,
'idwarehouse-'.$line->id.
'-'.$i,
'', 1, 0, $line->fk_product,
'', 1, 0, array(),
'maxwidth200 csswarehouse_'.$line->id.
'_'.$i);
1517 print
'<span class="opacitymedium">'.$langs->trans(
"DisableStockChange").
'</span>';
1520 if ((
int) $tmpproduct->stockable_product > 0) {
1521 print
'<span class="opacitymedium">' . $langs->trans(
"StockDisabled") .
'</span>';
1523 print
'<span class="opacitymedium">' . $langs->trans(
"NoStockChangeOnServices") .
'</span>';
1535 print
'<td class="nowraponall">';
1536 if ($tmpproduct->status_batch) {
1537 $preselected = (
GETPOSTISSET(
'batch-'.$line->id.
'-'.$i) ?
GETPOST(
'batch-'.$line->id.
'-'.$i) :
'');
1538 print
'<input type="text" class="width75" name="batch-'.$line->id.
'-'.$i.
'" value="'.$preselected.
'" list="batch-'.$line->id.
'-'.$i.
'">';
1539 print $formproduct->selectLotDataList(
'batch-'.$line->id.
'-'.$i, 0, $line->fk_product, 0, array());
1546 print
'<td align="right" class="split">';
1547 print
' '.img_picto($langs->trans(
'AddStockLocationLine'),
'split',
'class="splitbutton" onClick="addDispatchLine('.((int) $line->id).
', \''.
dol_escape_js($type).
'\', \
'qtymissingconsume\', 1)"');
1551 print
'<td align="right" class="splitall">';
1552 if (($action ==
'consumeorproduce' || $action ==
'consumeandproduceall') && $tmpproduct->status_batch == 2) {
1553 print
img_picto($langs->trans(
'SplitAllQuantity'),
'split',
'class="splitbutton splitallbutton field-error-icon" data-max-qty="1" onClick="addDispatchLine('.$line->id.
', \'batch\', \'allmissingconsume\', 1)"');
1558 if (
$object->status == Mo::STATUS_DRAFT) {
1563 if ($permissiontodelete) {
1577 print
'<script type="text/javascript">
1578 $(document).ready(function () {
1579 $("select[name=fk_default_warehouse]").change(function() {
1580 var fk_default_warehouse = $("option:selected", this).val();
1581 $("select[name^=idwarehouse-]").val(fk_default_warehouse).change();
1586 if (in_array($action, array(
'consumeorproduce',
'consumeandproduceall')) &&
1588 print
'<script>$(document).ready(function () {
1589 $("#fk_default_warehouse").change();
1597 print
'<div class="fichehalfright">';
1598 print
'<div class="clearboth"></div>';
1600 $nblinetoproduce = 0;
1601 $atLeastOneEatBy =
false;
1602 $atLeastOneSellBy =
false;
1603 foreach (
$object->lines as $line) {
1604 if ($line->role ==
'toproduce') {
1606 $tmpproduct->fetch($line->fk_product);
1608 $tmpproduct->sell_or_eat_by_mandatory == $tmpproduct::SELL_OR_EAT_BY_MANDATORY_ID_EAT_BY
1609 || $tmpproduct->sell_or_eat_by_mandatory == $tmpproduct::SELL_OR_EAT_BY_MANDATORY_ID_SELL_AND_EAT
1611 $atLeastOneEatBy =
true;
1614 $tmpproduct->sell_or_eat_by_mandatory == $tmpproduct::SELL_OR_EAT_BY_MANDATORY_ID_SELL_BY
1615 || $tmpproduct->sell_or_eat_by_mandatory == $tmpproduct::SELL_OR_EAT_BY_MANDATORY_ID_SELL_AND_EAT
1617 $atLeastOneSellBy =
true;
1623 $newcardbutton =
'';
1624 $url = $_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=addproduceline&token='.
newToken();
1625 $permissiontoaddaproductline =
$object->status != $object::STATUS_PRODUCED &&
$object->status != $object::STATUS_CANCELED;
1626 $parameters = array(
'morecss' =>
'reposition');
1627 if ($action !=
'consumeorproduce' && $action !=
'consumeandproduceall') {
1628 if ($nblinetoproduce == 0 ||
$object->mrptype == 1) {
1629 $newcardbutton =
dolGetButtonTitle($langs->trans(
'AddNewProduceLines'),
'',
'fa fa-plus-circle size15x', $url,
'', (
int) $permissiontoaddaproductline, $parameters);
1633 print
load_fiche_titre($langs->trans(
'Production'), $newcardbutton,
'', 0,
'',
'');
1635 print
'<div class="div-table-responsive-no-min">';
1636 print
'<table id="tablelinestoproduce" class="noborder noshadow nobottom centpercent">';
1638 print
'<tr class="liste_titre trheight5em">';
1640 print
'<td>'.$langs->trans(
"Product").
'</td>';
1642 print
'<td class="right">'.$langs->trans(
"Qty").
'</td>';
1645 print
'<td class="right">'.$langs->trans(
"Unit").
'</td>';
1648 if ($permissiontoupdatecost) {
1649 if (empty($bomcostupdated)) {
1650 print
'<td class="right classfortooltip" title="'.$langs->trans(
"AmountUsedToUpdateWAP").
'">';
1651 print $langs->trans(
"UnitCost");
1654 print
'<td class="right classfortooltip" title="'.$langs->trans(
"AmountUsedToUpdateWAP").
'">';
1655 print $langs->trans(
"ManufacturingPrice");
1660 print
'<td class="right classfortooltip" title="'.$langs->trans(
"QtyAlreadyProduced").
'">';
1661 print $langs->trans(
"QtyAlreadyProducedShort");
1665 if ($collapse || in_array($action, array(
'consumeorproduce',
'consumeandproduceall'))) {
1666 print $langs->trans(
"Warehouse");
1673 if ($collapse || in_array($action, array(
'consumeorproduce',
'consumeandproduceall'))) {
1674 print $langs->trans(
"Batch");
1685 if ($atLeastOneEatBy) {
1686 print
'<td>'.$langs->trans(
"EatByDate").
'</td>';
1690 if ($atLeastOneSellBy) {
1691 print
'<td>'.$langs->trans(
"SellByDate").
'</td>';
1696 if ($permissiontodelete) {
1702 if ($action ==
'addproduceline') {
1703 print
'<!-- Add line to produce -->'.
"\n";
1704 print
'<tr class="liste_titre">';
1708 print $form->select_produits(0,
'productidtoadd',
'', 0, 0, -1, 2,
'', 1, array(), 0,
'1', 0,
'maxwidth300');
1711 print
'<td class="right"><input type="text" name="qtytoadd" value="1" class="width50 right"></td>';
1717 if ($permissiontoupdatecost) {
1721 print
'<td colspan="2">';
1722 print
'<input type="submit" class="button buttongen button-add" name="addproducelinebutton" value="'.$langs->trans(
"Add").
'">';
1723 print
'<input type="submit" class="button buttongen button-cancel" name="canceladdproducelinebutton" value="'.$langs->trans(
"Cancel").
'">';
1736 if ($permissiontodelete) {
1743 $nblinetoproduce = 0;
1744 foreach (
$object->lines as $line) {
1745 if ($line->role ==
'toproduce') {
1750 $nblinetoproducecursor = 0;
1751 foreach (
$object->lines as $line) {
1752 if ($line->role ==
'toproduce') {
1755 $nblinetoproducecursor++;
1758 $tmpproduct->fetch($line->fk_product);
1760 $arrayoflines =
$object->fetchLinesLinked(
'produced', $line->id);
1761 $alreadyproduced = 0;
1762 foreach ($arrayoflines as $line2) {
1763 $alreadyproduced += $line2[
'qty'];
1766 $suffix =
'_'.$line->id;
1767 print
'<!-- Line to dispatch '.$suffix.
' (toproduce) -->'.
"\n";
1769 print
'<input id="qty_ordered'.$suffix.
'" type="hidden" value="'.$line->qty.
'">';
1770 print
'<input id="qty_dispatched'.$suffix.
'" type="hidden" value="'.$alreadyproduced.
'">';
1774 print
'<td>'.$tmpproduct->getNomUrl(1);
1775 print
'<br><span class="opacitymedium small">'.$tmpproduct->label.
'</span>';
1778 print
'<td class="right">'.$line->qty.
'</td>';
1781 print
'<td class="right">'.measuringUnitString($line->fk_unit,
'',
null, 1).
'</td>';
1784 if ($permissiontoupdatecost) {
1786 $manufacturingcost = 0;
1787 $manufacturingcostsrc =
'';
1789 $manufacturingcost = $bomcostupdated;
1790 $manufacturingcostsrc = $langs->trans(
"CalculatedFromProductsToConsume");
1791 if (empty($manufacturingcost)) {
1792 $manufacturingcost = $bomcost;
1793 $manufacturingcostsrc = $langs->trans(
"ValueFromBom");
1795 if (empty($manufacturingcost)) {
1796 $manufacturingcost =
price2num($tmpproduct->cost_price,
'MU');
1797 $manufacturingcostsrc = $langs->trans(
"CostPrice");
1799 if (empty($manufacturingcost)) {
1800 $manufacturingcost =
price2num($tmpproduct->pmp,
'MU');
1801 $manufacturingcostsrc = $langs->trans(
"PMPValue");
1805 print
'<td class="right nowraponall" title="'.dol_escape_htmltag($manufacturingcostsrc).
'">';
1806 if ($manufacturingcost) {
1807 print
price($manufacturingcost);
1812 print
'<td class="right nowraponall">';
1813 if ($alreadyproduced) {
1815 print
'jQuery(document).ready(function() {
1816 jQuery("#expandtoproduce'.$line->id.
'").click(function() {
1817 console.log("Expand mrp_production line '.$line->id.
'");
1818 jQuery(".expanddetailtoproduce'.$line->id.
'").toggle();';
1819 if ($nblinetoproduce == $nblinetoproducecursor) {
1820 print
'if (jQuery("#tablelinestoproduce").hasClass("nobottom")) { jQuery("#tablelinestoproduce").removeClass("nobottom"); } else { jQuery("#tablelinestoproduce").addClass("nobottom"); }';
1826 if (empty(
$conf->use_javascript_ajax)) {
1827 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?collapse='.$collapse.
','.$line->id.
'">';
1829 print
img_picto($langs->trans(
"ShowDetails"),
"chevron-down",
'id="expandtoproduce'.$line->id.
'"');
1830 if (empty(
$conf->use_javascript_ajax)) {
1834 print
' '.$alreadyproduced;
1850 if ($permissiontodelete) {
1851 if ($line->origin_type ==
'free') {
1852 $href = $_SERVER[
"PHP_SELF"];
1853 $href .=
'?id='.$object->id;
1854 $href .=
'&action=deleteline';
1855 $href .=
'&token='.newToken();
1856 $href .=
'&lineid='.$line->id;
1857 print
'<td class="center">';
1858 print
'<a class="reposition" href="'.$href.
'">';
1859 print
img_picto($langs->trans(
'TooltipDeleteAndRevertStockMovement'),
"delete");
1869 foreach ($arrayoflines as $line2) {
1870 print
'<tr class="expanddetailtoproduce'.$line->id.
' hideobject opacitylow">';
1873 $tmpstockmovement->id = $line2[
'fk_stock_movement'];
1874 print
'<a href="'.DOL_URL_ROOT.
'/product/stock/movement_list.php?search_ref='.$tmpstockmovement->id.
'">'.
img_picto($langs->trans(
"StockMovement"),
'movement',
'class="paddingright"').
'</a>';
1884 if ($permissiontoupdatecost) {
1888 print
'<td class="right">'.$line2[
'qty'].
'</td>';
1890 print
'<td class="tdoverflowmax150">';
1891 if ($line2[
'fk_warehouse'] > 0) {
1892 $result = $tmpwarehouse->fetch($line2[
'fk_warehouse']);
1894 print $tmpwarehouse->getNomUrl(1);
1901 if ($line2[
'batch'] !=
'') {
1902 $tmpbatch->fetch(0, $line2[
'fk_product'], $line2[
'batch']);
1903 print $tmpbatch->getNomUrl(1);
1914 if ($permissiontodelete) {
1920 if (in_array($action, array(
'consumeorproduce',
'consumeandproduceall'))) {
1921 print
'<!-- Enter line to produce -->'.
"\n";
1923 print
'<tr data-max-qty="'.$maxQty.
'" name="batch_'.$line->id.
'_'.$i.
'">';
1925 print
'<td><span class="opacitymedium">'.$langs->trans(
"ToProduce").
'</span></td>';
1926 $preselected = (
GETPOSTISSET(
'qtytoproduce-'.$line->id.
'-'.$i) ?
GETPOST(
'qtytoproduce-'.$line->id.
'-'.$i) : max(0, $line->qty - $alreadyproduced));
1927 if ($action ==
'consumeorproduce' && !
GETPOSTISSET(
'qtytoproduce-'.$line->id.
'-'.$i)) {
1931 print
'<td class="right"><input type="text" class="width50 right" id="qtytoproduce-'.$line->id.
'-'.$i.
'" name="qtytoproduce-'.$line->id.
'-'.$i.
'" value="'.$preselected.
'"></td>';
1934 print
'<td class="right"></td>';
1937 if ($permissiontoupdatecost) {
1939 $manufacturingcost = 0;
1940 $manufacturingcostsrc =
'';
1942 $manufacturingcost = $bomcostupdated;
1943 $manufacturingcostsrc = $langs->trans(
"CalculatedFromProductsToConsume");
1944 if (empty($manufacturingcost)) {
1945 $manufacturingcost = $bomcost;
1946 $manufacturingcostsrc = $langs->trans(
"ValueFromBom");
1948 if (empty($manufacturingcost)) {
1949 $manufacturingcost =
price2num($tmpproduct->cost_price,
'MU');
1950 $manufacturingcostsrc = $langs->trans(
"CostPrice");
1952 if (empty($manufacturingcost)) {
1953 $manufacturingcost =
price2num($tmpproduct->pmp,
'MU');
1954 $manufacturingcostsrc = $langs->trans(
"PMPValue");
1959 $preselected = (
GETPOSTISSET(
'pricetoproduce-'.$line->id.
'-'.$i) ?
GETPOST(
'pricetoproduce-'.$line->id.
'-'.$i) : ($manufacturingcost ?
price($manufacturingcost) :
''));
1960 print
'<td class="right"><input type="text" class="width75 right" name="pricetoproduce-'.$line->id.
'-'.$i.
'" value="'.$preselected.
'"></td>';
1962 print
'<td><input type="hidden" class="width50 right" name="pricetoproduce-'.$line->id.
'-'.$i.
'" value="'.($manufacturingcost ? $manufacturingcost :
'').
'"></td>';
1970 $preselected = (
GETPOSTISSET(
'idwarehousetoproduce-'.$line->id.
'-'.$i) ?
GETPOST(
'idwarehousetoproduce-'.$line->id.
'-'.$i) : (
$object->fk_warehouse > 0 ?
$object->fk_warehouse :
'ifone'));
1971 print $formproduct->selectWarehouses($preselected,
'idwarehousetoproduce-'.$line->id.
'-'.$i,
'', 1, 0, $line->fk_product,
'', 1, 0, array(),
'maxwidth200 csswarehouse_'.$line->id.
'_'.$i);
1973 print
'<span class="opacitymedium">'.$langs->trans(
"NoStockChangeOnServices").
'</span>';
1979 if ($tmpproduct->status_batch) {
1980 $preselected = (
GETPOSTISSET(
'batchtoproduce-'.$line->id.
'-'.$i) ?
GETPOST(
'batchtoproduce-'.$line->id.
'-'.$i) :
'');
1981 print
'<input type="text" class="width75" name="batchtoproduce-'.$line->id.
'-'.$i.
'" value="'.$preselected.
'">';
1985 if ($tmpproduct->status_batch) {
1987 print
'<td align="right" class="split">';
1988 print
img_picto($langs->trans(
'AddStockLocationLine'),
'split',
'class="splitbutton" onClick="addDispatchLine('.$line->id.
', \''.$type.
'\', \
'qtymissing\')"');
1991 print
'<td align="right" class="splitall">';
1992 if (($action ==
'consumeorproduce' || $action ==
'consumeandproduceall') && $tmpproduct->status_batch == 2) {
1993 print
img_picto($langs->trans(
'SplitAllQuantity'),
'split',
'class="splitbutton splitallbutton field-error-icon" onClick="addDispatchLine('.$line->id.
', \'batch\', \'alltoproduce\')"');
2004 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) {
2005 print
'<td align="right">';
2006 $preselectedSellBy = (
GETPOSTISSET(
'sellby-' . $line->id .
'-' . $i) ?
GETPOSTDATE(
'sellby-' . $line->id .
'-' . $i) :
'');
2007 print $form->selectDate($preselectedSellBy,
'sellby-' . $line->id .
'-' . $i, 0, 0, 1,
'', 1, 0);
2010 if ($atLeastOneSellBy) {
2016 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) {
2017 print
'<td align="right">';
2018 $preselectedEatBy = (
GETPOSTISSET(
'eatby-' . $line->id .
'-' . $i) ?
GETPOSTDATE(
'eatby-' . $line->id .
'-' . $i) :
'');
2019 print $form->selectDate($preselectedEatBy,
'eatby-' . $line->id .
'-' . $i, 0, 0, 1,
'', 1, 0);
2022 if ($atLeastOneEatBy) {
2043 if (in_array($action, array(
'consumeorproduce',
'consumeandproduceall',
'addconsumeline'))) {
2047 <script
type=
"text/javascript" language=
"javascript">
2049 $(document).ready(
function() {
2051 updateselectbatchbywarehouse();
2053 updateselectwarehousebybatch();
2056 function updateselectbatchbywarehouse() {
2057 $(document).on(
'change',
"select[name*='idwarehouse']",
function () {
2058 console.log(
"We change warehouse so we update the list of possible batch number");
2060 var selectwarehouse = $(
this);
2062 var selectbatch_name = selectwarehouse.attr(
'name').replace(
'idwarehouse',
'batch');
2063 var selectbatch = $(
"datalist[id*='" + selectbatch_name +
"']");
2064 var selectedbatch = selectbatch.val();
2066 var product_element_name = selectwarehouse.attr(
'name').replace(
'idwarehouse',
'product');
2070 url:
"<?php echo DOL_URL_ROOT . '/mrp/ajax/interface.php'; ?>",
2072 action:
"updateselectbatchbywarehouse",
2073 permissiontoproduce: <?php echo $permissiontoproduce ?>,
2074 warehouse_id: $(
this).val(),
2075 token:
'<?php echo currentToken(); ?>',
2076 product_id: $(
"input[name='" + product_element_name +
"']").val()
2078 }).done(
function (data) {
2080 selectbatch.empty();
2082 if (typeof data ==
"object") {
2083 console.log(
"data is already type object, no need to parse it");
2085 console.log(
"data is type "+(typeof data));
2086 data = JSON.parse(data);
2089 selectbatch.append($(
'<option>', {
2093 $.each(data,
function (key, value) {
2095 if(selectwarehouse.val() == -1) {
2096 var label = key +
" (<?php echo $langs->trans('TotalStock') ?> : " + value +
")";
2098 var label = key +
" (<?php echo $langs->trans('Stock') ?> : " + value +
")";
2101 if(key === selectedbatch) {
2102 var option =
'<option value="'+key+
'" selected>'+ label +
'</option>';
2104 var option =
'<option value="'+key+
'">'+ label +
'</option>';
2107 selectbatch.append(option);
2113 function updateselectwarehousebybatch() {
2114 $(document).on(
'change',
'input[name*=batch]',
function(){
2115 console.log(
"We change batch so we update the list of possible warehouses");
2117 var selectbatch = $(
this);
2119 var selectwarehouse_name = selectbatch.attr(
'name').replace(
'batch',
'idwarehouse');
2120 var selectwarehouse = $(
"select[name*='" + selectwarehouse_name +
"']");
2121 var selectedwarehouse = selectwarehouse.val();
2123 if(selectedwarehouse != -1){
2127 var product_element_name = selectbatch.attr(
'name').replace(
'batch',
'product');
2131 url:
"<?php echo DOL_URL_ROOT . '/mrp/ajax/interface.php'; ?>",
2133 action:
"updateselectwarehousebybatch",
2134 permissiontoproduce: <?php echo $permissiontoproduce ?>,
2135 batch: $(
this).val(),
2136 token:
'<?php echo currentToken(); ?>',
2137 product_id: $(
"input[name='" + product_element_name +
"']").val()
2139 }).done(
function (data) {
2141 if (typeof data ==
"object") {
2142 console.log(
"data is already type object, no need to parse it");
2144 console.log(
"data is type "+(typeof data));
2145 data = JSON.parse(data);
2149 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.