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;
74$objectline =
new MoLine($db);
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);
124 setEventMessages($hookmanager->error, $hookmanager->errors,
'errors');
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);
155 $result =
$object->delete($user, 0, (
bool) $also_cancel_consumed_and_produced_lines);
157 header(
"Location: " . $backurlforlist);
171 if ($action ==
'setqty' && $permissiontoadd &&
$object->status == Mo::STATUS_DRAFT) {
185 foreach (
$object->lines as $line) {
186 if ($line->role ===
'toproduce'
187 && (
int) $line->fk_product === (
int)
$object->fk_product
188 && empty($line->qty_frozen)
189 && (
float) $line->qty != (
float)
$object->qty) {
190 $line->qty = (float)
$object->qty;
191 $line->update($user);
194 setEventMessages($langs->trans(
"RecordSaved"),
null,
'mesgs');
199 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->trans(
"Qty")),
null,
'errors');
201 header(
"Location: ".$_SERVER[
"PHP_SELF"].
"?id=".
$object->id);
206 include DOL_DOCUMENT_ROOT.
'/core/actions_addupdatedelete.inc.php';
209 include DOL_DOCUMENT_ROOT.
'/core/actions_dellink.inc.php';
212 include DOL_DOCUMENT_ROOT.
'/core/actions_printing.inc.php';
215 $triggersendname =
'MO_SENTBYMAIL';
216 $autocopy =
'MAIN_MAIL_AUTOCOPY_MO_TO';
217 $trackid =
'mo'.$object->id;
218 include DOL_DOCUMENT_ROOT.
'/core/actions_sendmails.inc.php';
223 if ($action ==
'set_thirdparty' && $permissiontoadd) {
224 $object->setValueFrom(
'fk_soc',
GETPOSTINT(
'fk_soc'),
'',
null,
'date',
'', $user, $triggermodname);
226 if ($action ==
'classin' && $permissiontoadd) {
230 if ($action ==
'confirm_reopen' && $permissiontoadd) {
231 $result =
$object->setStatut($object::STATUS_INPROGRESS, 0,
'',
'MRP_REOPEN');
234 if (($action ==
'confirm_addconsumeline' &&
GETPOST(
'addconsumelinebutton') && $permissiontoadd)
235 || ($action ==
'confirm_addproduceline' &&
GETPOST(
'addproducelinebutton') && $permissiontoadd)) {
236 $moline =
new MoLine($db);
241 $moline->fk_product =
GETPOSTINT(
'productidtoadd');
242 if (
GETPOST(
'addconsumelinebutton')) {
243 $moline->role =
'toconsume';
245 $moline->role =
'toproduce';
247 $moline->origin_type =
'free';
248 $moline->position = 0;
251 if (!empty($moline->fk_product)) {
252 $tmpproduct =
new Product($db);
253 $tmpproduct->fetch($moline->fk_product);
255 $moline->fk_default_workstation = $tmpproduct->fk_default_workstation;
256 $moline->disable_stock_change = 1;
257 if ($tmpproduct->duration_unit) {
258 $moline->qty = $tmpproduct->duration_value;
259 include_once DOL_DOCUMENT_ROOT.
'/core/class/cunits.class.php';
260 $cunits =
new CUnits($db);
261 $res = $cunits->fetch(0,
'', $tmpproduct->duration_unit,
'time');
263 $moline->fk_unit = $cunits->id;
267 $moline->disable_stock_change = 0;
269 $moline->fk_unit = $tmpproduct->fk_unit;
274 $extralabelsline = $extrafields->fetch_name_optionals_label(
$object->table_element_line);
275 $array_options = $extrafields->getOptionalsFromPost(
$object->table_element_line);
277 if (is_array($extralabelsline)) {
279 foreach ($extralabelsline as $key => $value) {
280 unset($_POST[
"options_".$key]);
283 if (is_array($array_options) && count($array_options) > 0) {
284 $moline->array_options = $array_options;
287 $resultline = $moline->create($user, 0);
288 if ($resultline <= 0) {
290 setEventMessages($moline->error, $moline->errors,
'errors');
295 header(
"Location: ".$_SERVER[
"PHP_SELF"].
'?id='.
$object->id);
299 if (in_array($action, array(
'confirm_consumeorproduce',
'confirm_consumeandproduceall')) && $permissiontoproduce) {
302 $labelmovement =
GETPOST(
'inventorylabel',
'alphanohtml');
303 $codemovement =
GETPOST(
'inventorycode',
'alphanohtml');
308 foreach (
$object->lines as $line) {
309 if ($line->role ==
'toconsume') {
310 $tmpproduct =
new Product($db);
311 $tmpproduct->fetch($line->fk_product);
317 if ($qtytoprocess != 0) {
320 if (!(
GETPOST(
'idwarehouse-'.$line->id.
'-'.$i) > 0)) {
321 $langs->load(
"errors");
322 setEventMessages($langs->trans(
"ErrorFieldRequiredForProduct", $langs->transnoentitiesnoconv(
"Warehouse"), (
string) $tmpproduct->ref),
null,
'errors');
325 if ($tmpproduct->status_batch && (!
GETPOST(
'batch-'.$line->id.
'-'.$i))) {
326 $langs->load(
"errors");
327 setEventMessages($langs->trans(
"ErrorFieldRequiredForProduct", $langs->transnoentitiesnoconv(
"Batch"), (
string) $tmpproduct->ref),
null,
'errors');
333 if (!$error &&
GETPOST(
'idwarehouse-'.$line->id.
'-'.$i) > 0) {
335 $id_product_batch = 0;
337 $stockmove->context[
'mrp_role'] =
'toconsume';
339 if ($qtytoprocess >= 0) {
340 $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);
342 $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);
344 if ($idstockmove < 0) {
346 setEventMessages($stockmove->error, $stockmove->errors,
'errors');
352 $moline =
new MoLine($db);
354 $moline->position = $pos;
355 $moline->fk_product = $line->fk_product;
356 $moline->fk_warehouse =
GETPOSTINT(
'idwarehouse-'.$line->id.
'-'.$i);
357 $moline->qty = $qtytoprocess;
358 $moline->batch =
GETPOST(
'batch-'.$line->id.
'-'.$i);
359 $moline->role =
'consumed';
360 $moline->fk_mrp_production = $line->id;
361 $moline->fk_stock_movement = $idstockmove == 0 ? null : $idstockmove;
362 $moline->fk_user_creat = $user->id;
364 $resultmoline = $moline->create($user);
365 if ($resultmoline <= 0) {
367 setEventMessages($moline->error, $moline->errors,
'errors');
382 foreach (
$object->lines as $line) {
383 if ($line->role ==
'toproduce') {
384 $tmpproduct =
new Product($db);
385 $tmpproduct->fetch($line->fk_product);
388 while (
GETPOSTISSET(
'qtytoproduce-'.$line->id.
'-'.$i)) {
389 $qtytoprocess = (float)
price2num(
GETPOST(
'qtytoproduce-'.$line->id.
'-'.$i));
390 $pricetoprocess =
GETPOST(
'pricetoproduce-'.$line->id.
'-'.$i) ?
price2num(
GETPOST(
'pricetoproduce-'.$line->id.
'-'.$i)) : 0;
392 if ($qtytoprocess != 0) {
394 if (
GETPOSTISSET(
'idwarehousetoproduce-'.$line->id.
'-'.$i)) {
395 if (!(
GETPOST(
'idwarehousetoproduce-'.$line->id.
'-'.$i) > 0)) {
396 $langs->load(
"errors");
397 setEventMessages($langs->trans(
"ErrorFieldRequiredForProduct", $langs->transnoentitiesnoconv(
"Warehouse"), $tmpproduct->ref),
null,
'errors');
400 if (
isModEnabled(
'productbatch') && $tmpproduct->status_batch && (!
GETPOST(
'batchtoproduce-'.$line->id.
'-'.$i))) {
401 $langs->load(
"errors");
402 setEventMessages($langs->trans(
"ErrorFieldRequiredForProduct", $langs->transnoentitiesnoconv(
"Batch"), $tmpproduct->ref),
null,
'errors');
408 if (!$error &&
GETPOST(
'idwarehousetoproduce-'.$line->id.
'-'.$i) > 0) {
410 $id_product_batch = 0;
411 $stockmove->origin_type =
$object->element;
412 $stockmove->origin_id =
$object->id;
413 $stockmove->context[
'mrp_role'] =
'toproduce';
415 $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);
416 if ($idstockmove < 0) {
418 setEventMessages($stockmove->error, $stockmove->errors,
'errors');
424 $moline =
new MoLine($db);
426 $moline->position = $pos;
427 $moline->fk_product = $line->fk_product;
428 $moline->fk_warehouse =
GETPOSTINT(
'idwarehousetoproduce-'.$line->id.
'-'.$i);
429 $moline->qty = $qtytoprocess;
430 $moline->batch =
GETPOST(
'batchtoproduce-'.$line->id.
'-'.$i);
431 $moline->role =
'produced';
432 $moline->fk_mrp_production = $line->id;
433 $moline->fk_stock_movement = (($idstockmove == 0) ?
null : $idstockmove);
434 $moline->fk_user_creat = $user->id;
436 $resultmoline = $moline->create($user);
437 if ($resultmoline <= 0) {
439 setEventMessages($moline->error, $moline->errors,
'errors');
452 $consumptioncomplete =
true;
453 $productioncomplete =
true;
456 foreach (
$object->lines as $line) {
457 $tmpproduct =
new Product($db);
458 $tmpproduct->fetch($line->fk_product);
459 if ((
int) $tmpproduct->stockable_product > 0) {
460 if ($line->role ==
'toconsume') {
461 $arrayoflines =
$object->fetchLinesLinked(
'consumed', $line->id);
462 $alreadyconsumed = 0;
463 foreach ($arrayoflines as $line2) {
464 $alreadyconsumed += $line2[
'qty'];
467 if ($alreadyconsumed < $line->qty) {
468 $consumptioncomplete =
false;
471 if ($line->role ==
'toproduce') {
472 $arrayoflines =
$object->fetchLinesLinked(
'produced', $line->id);
473 $alreadyproduced = 0;
474 foreach ($arrayoflines as $line2) {
475 $alreadyproduced += $line2[
'qty'];
478 if ($alreadyproduced < $line->qty) {
479 $productioncomplete =
false;
485 $consumptioncomplete =
false;
486 $productioncomplete =
false;
490 dol_syslog(
"consumptioncomplete = ".json_encode($consumptioncomplete).
" productioncomplete = ".json_encode($productioncomplete));
491 if ($consumptioncomplete && $productioncomplete) {
492 $result =
$object->setStatut($object::STATUS_PRODUCED, 0,
'',
'MRP_MO_PRODUCED');
494 $result =
$object->setStatut($object::STATUS_INPROGRESS, 0,
'',
'MRP_MO_PRODUCED');
503 $action = str_replace(
'confirm_',
'', $action);
509 header(
"Location: ".$_SERVER[
"PHP_SELF"].
'?id='.
$object->id);
515 if ($action ==
'confirm_produced' && $confirm ==
'yes' && $permissiontoadd) {
516 $result =
$object->setStatut($object::STATUS_PRODUCED, 0,
'',
'MRP_MO_PRODUCED');
520 $outputlangs = $langs;
523 $newlang =
GETPOST(
'lang_id',
'aZ09');
526 $newlang =
$object->thirdparty->default_lang;
528 if (!empty($newlang)) {
530 $outputlangs->setDefaultLang($newlang);
535 $object->generateDocument($model, $outputlangs, 0, 0, 0);
542 if ($action ==
'confirm_editline' && $permissiontoadd) {
543 $moline =
new MoLine($db);
546 $extrafields->fetch_name_optionals_label($moline->table_element);
547 if (!empty($extrafields->attributes[$moline->table_element][
'label'])) {
548 foreach ($extrafields->attributes[$moline->table_element][
'label'] as $key => $label) {
549 $value =
GETPOST(
'options_'.$key,
'alphanohtml');
550 $moline->array_options[
"options_".$key] = $value;
555 $moline->fk_warehouse = (
GETPOSTINT(
'warehouse_lineProduce') > 0 ?
GETPOSTINT(
'warehouse_lineProduce') : 0);
558 $moline->fk_default_workstation = (
GETPOSTINT(
'workstation_lineProduce') > 0 ?
GETPOSTINT(
'workstation_lineProduce') : 0);
561 $res = $moline->update($user);
564 setEventMessages($moline->error, $moline->errors,
'errors');
565 header(
"Location: ".$_SERVER[
"PHP_SELF"].
'?id='.
$object->id);
568 header(
"Location: ".$_SERVER[
"PHP_SELF"].
'?id='.
$object->id);
580$form =
new Form($db);
587$title = $langs->trans(
'Mo');
588$help_url =
'EN:Module_Manufacturing_Orders|FR:Module_Ordres_de_Fabrication|DE:Modul_Fertigungsauftrag';
589$morejs = array(
'/mrp/js/lib_dispatch.js.php');
590llxHeader(
'', $title, $help_url,
'', 0, 0, $morejs,
'',
'',
'mod-mrp page-card_production');
595if (
$object->id > 0 && (empty($action) || ($action !=
'edit' && $action !=
'create' && $action !=
'reload'))) {
596 $res =
$object->fetch_thirdparty();
597 $res =
$object->fetch_optionals();
600 $tmpwarehouse->fetch((
int)
$object->fk_warehouse);
601 $fk_default_warehouse = (int)
$object->fk_warehouse;
611 if ($action ==
'delete') {
612 $formquestion = array(
614 'label' => $langs->trans(
'MoCancelConsumedAndProducedLines'),
615 'name' =>
'alsoCancelConsumedAndProducedLines',
616 'type' =>
'checkbox',
620 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'DeleteMo'), $langs->trans(
'ConfirmDeleteMo'),
'confirm_delete', $formquestion, 0, 1);
623 if ($action ==
'deleteline') {
624 $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);
627 if ($action ==
'clone') {
629 $formquestion = array();
630 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'ToClone'), $langs->trans(
'ConfirmCloneMo',
$object->ref),
'confirm_clone', $formquestion,
'yes', 1);
634 if ($action ==
'validate') {
636 $ref = substr(
$object->ref, 1, 4);
637 if ($ref ==
'PROV') {
641 $numref = (string)
$object->ref;
644 $text = $langs->trans(
'ConfirmValidateMo', $numref);
653 $formquestion = array();
656 require_once DOL_DOCUMENT_ROOT.
'/product/class/html.formproduct.class.php';
659 if (
$conf->browser->name ==
'ie') {
662 $formquestion = array(
669 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'Validate'), $text,
'confirm_validate', $formquestion, 0, 1, 220);
673 if ($action ==
'cancel') {
674 $formquestion = array(
676 'label' => $langs->trans(
'MoCancelConsumedAndProducedLines'),
677 'name' =>
'alsoCancelConsumedAndProducedLines',
678 'type' =>
'checkbox',
679 'value' => !
getDolGlobalString(
'MO_ALSO_CANCEL_CONSUMED_AND_PRODUCED_LINES_BY_DEFAULT') ? 0 : 1
682 $formconfirm = $form->formconfirm(
dolBuildUrl($_SERVER[
"PHP_SELF"], [
'id' =>
$object->id]), $langs->trans(
'CancelMo'), $langs->trans(
'ConfirmCancelMo'),
'confirm_cancel', $formquestion, 0, 1);
686 $parameters = array(
'formConfirm' => $formconfirm,
'lineid' => $lineid);
687 $reshook = $hookmanager->executeHooks(
'formConfirm', $parameters, $object, $action);
688 if (empty($reshook)) {
689 $formconfirm .= $hookmanager->resPrint;
690 } elseif ($reshook > 0) {
691 $formconfirm = $hookmanager->resPrint;
700 $linkback =
'<a href="'.DOL_URL_ROOT.
'/mrp/mo_list.php?restore_lastsearch_values=1'.(!empty($socid) ?
'&socid='.$socid :
'').
'">'.$langs->trans(
"BackToList").
'</a>';
702 $morehtmlref =
'<div class="refidno">';
711 if (is_object(
$object->thirdparty)) {
712 $morehtmlref .=
$object->thirdparty->getNomUrl(1,
'customer');
714 $morehtmlref .=
' (<a href="'.DOL_URL_ROOT.
'/commande/list.php?socid='.
$object->thirdparty->id.
'">'.$langs->trans(
"OtherOrders").
'</a>)';
720 $langs->load(
"projects");
721 if (is_object(
$object->thirdparty)) {
722 $morehtmlref .=
'<br>';
724 if ($permissiontoadd) {
725 $morehtmlref .= img_picto($langs->trans(
"Project"),
'project',
'class="pictofixedwidth"');
726 if ($action !=
'classify') {
727 $morehtmlref .=
'<a class="editfielda" href="'.dolBuildUrl($_SERVER[
'PHP_SELF'], [
'action' =>
'classify',
'id' =>
$object->id],
true).
'">'.img_edit($langs->transnoentitiesnoconv(
'SetProject')).
'</a> ';
729 $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');
731 if (!empty(
$object->fk_project)) {
733 $proj->fetch(
$object->fk_project);
734 $morehtmlref .= $proj->getNomUrl(1);
736 $morehtmlref .=
'<span class="opacitymedium"> - '.dol_escape_htmltag($proj->title).
'</span>';
741 $morehtmlref .=
'</div>';
744 dol_banner_tab($object,
'ref', $linkback, 1,
'ref',
'ref', $morehtmlref);
747 print
'<div class="fichecenter">';
748 print
'<div class="fichehalfleft">';
749 print
'<div class="underbanner clearboth"></div>';
750 print
'<table class="border centpercent tableforfield">'.
"\n";
753 $keyforbreak =
'fk_warehouse';
754 unset(
$object->fields[
'fk_project']);
755 unset(
$object->fields[
'fk_soc']);
761 if (
$object->status == Mo::STATUS_DRAFT && $permissiontoadd && isset(
$object->fields[
'qty'])) {
762 $object->fields[
'qty'][
'alwayseditable'] = 1;
763 if ($action ==
'editqty') {
764 $object->fields[
'qty'][
'type'] =
'numeric';
768 include DOL_DOCUMENT_ROOT.
'/core/tpl/commonfields_view.tpl.php';
771 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_view.tpl.php';
777 print
'<div class="clearboth"></div>';
782 if (!in_array($action, array(
'consumeorproduce',
'consumeandproduceall',
'editline'))) {
783 print
'<div class="tabsAction">';
785 $parameters = array();
787 $reshook = $hookmanager->executeHooks(
'addMoreActionsButtons', $parameters, $object, $action);
788 if (empty($reshook)) {
790 if (
$object->status == $object::STATUS_DRAFT) {
791 if ($permissiontoadd) {
793 print
'<a class="butAction" href="'.$_SERVER[
'PHP_SELF'].
'?id='.
$object->id.
'&action=validate&token='.$newToken.
'">'.$langs->trans(
"Validate").
'</a>';
795 $langs->load(
"errors");
796 print
'<a class="butActionRefused" href="" title="'.$langs->trans(
"ErrorAddAtLeastOneLineFirst").
'">'.$langs->trans(
"Validate").
'</a>';
802 if (
$object->status == Mo::STATUS_VALIDATED ||
$object->status == Mo::STATUS_INPROGRESS) {
803 if ($permissiontoproduce) {
804 print
'<a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=consumeorproduce&token='.$newToken.
'">'.$langs->trans(
'ConsumeOrProduce').
'</a>';
806 print
'<a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans(
"NotEnoughPermissions").
'">'.$langs->trans(
'ConsumeOrProduce').
'</a>';
808 } elseif (
$object->status == Mo::STATUS_DRAFT) {
809 print
'<a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans(
"ValidateBefore").
'">'.$langs->trans(
'ConsumeOrProduce').
'</a>';
813 if (
$object->status == Mo::STATUS_VALIDATED ||
$object->status == Mo::STATUS_INPROGRESS) {
814 if ($permissiontoproduce) {
815 print
'<a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=consumeandproduceall&token='.$newToken.
'">'.$langs->trans(
'ConsumeAndProduceAll').
'</a>';
817 print
'<a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans(
"NotEnoughPermissions").
'">'.$langs->trans(
'ConsumeAndProduceAll').
'</a>';
819 } elseif (
$object->status == Mo::STATUS_DRAFT) {
820 print
'<a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans(
"ValidateBefore").
'">'.$langs->trans(
'ConsumeAndProduceAll').
'</a>';
824 if ($permissiontoadd) {
825 if (
$object->status == $object::STATUS_VALIDATED ||
$object->status == $object::STATUS_INPROGRESS) {
826 $arrayproduced =
$object->fetchLinesLinked(
'produced', 0);
828 foreach ($arrayproduced as $lineproduced) {
829 $nbProduced += $lineproduced[
'qty'];
831 if ($nbProduced > 0) {
832 print
'<a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=confirm_produced&confirm=yes&token='.$newToken.
'">'.$langs->trans(
"Close").
'</a>'.
"\n";
834 print
'<a class="butActionRefused" href="#" title="'.$langs->trans(
"GoOnTabProductionToProduceFirst", $langs->transnoentitiesnoconv(
"Production")).
'">'.$langs->trans(
"Close").
'</a>'.
"\n";
837 print
'<a class="butActionDelete" href="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=cancel&token='.$newToken.
'">'.$langs->trans(
"Cancel").
'</a>'.
"\n";
840 if (
$object->status == $object::STATUS_CANCELED) {
841 print
'<a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=confirm_reopen&confirm=yes&token='.$newToken.
'">'.$langs->trans(
"ReOpen").
'</a>'.
"\n";
844 if (
$object->status == $object::STATUS_PRODUCED) {
845 if ($permissiontoproduce) {
846 print
'<a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=confirm_reopen&token='.$newToken.
'">'.$langs->trans(
'ReOpen').
'</a>';
848 print
'<a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans(
"NotEnoughPermissions").
'">'.$langs->trans(
'ReOpen').
'</a>';
857 if (in_array($action, array(
'consumeorproduce',
'consumeandproduceall',
'addconsumeline',
'addproduceline',
'editline'))) {
858 print
'<!-- Form to enter value for consumption/production -->';
859 print
'<form method="POST" action="'.dolBuildUrl($_SERVER[
"PHP_SELF"]).
'">';
860 print
'<input type="hidden" name="token" value="'.newToken().
'">';
861 print
'<input type="hidden" name="action" value="confirm_'.$action.
'">';
862 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
863 print
'<input type="hidden" name="id" value="'.$id.
'">';
866 if (in_array($action, array(
'consumeorproduce',
'consumeandproduceall'))) {
867 $defaultstockmovementlabel =
GETPOST(
'inventorylabel',
'alphanohtml') ?
GETPOST(
'inventorylabel',
'alphanohtml') : $langs->trans(
"ProductionForRef",
$object->
ref);
870 print
'<div class="center'.(in_array($action, array(
'consumeorproduce',
'consumeandproduceall')) ?
' formconsumeproduce' :
'').
'">';
871 print
'<div class="opacitymedium hideonsmartphone paddingbottom marginbottomonly">'.$langs->trans(
"ConfirmProductionDesc", $langs->transnoentitiesnoconv(
"Confirm")).
'<br></div>';
872 print
'<span class="paddingright">'.$langs->trans(
"InventoryCode").
':</span>';
873 print
'<span class="clearbothonsmartphone"></span>';
874 print
'<input type="text" class="minwidth125 maxwidth150" name="inventorycode" value="'.$defaultstockmovementcode.
'">';
875 print
'<span class="hideonsmartphone"> </span>';
876 print
'<span class="clearbothonsmartphone"></span>';
877 print
'<span class="paddingright">'.$langs->trans(
"MovementLabel").
':</span>';
878 print
'<span class="clearbothonsmartphone"></span>';
879 print
'<input type="text" class="minwidth300" name="inventorylabel" value="'.$defaultstockmovementlabel.
'"><br><br>';
880 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>';
881 print
'<input type="submit" class="button margintoponly" value="'.$langs->trans(
"Confirm").
'" name="confirm">';
883 print
'<input class="button margintoponly button-cancel" type="submit" value="'.$langs->trans(
"Cancel").
'" name="cancel">';
897 if (!empty(
$object->table_element_line)) {
904 $res = $bom->fetch(
$object->fk_bom);
906 $bom->calculateCosts();
907 $bomcost = $bom->unit_cost;
913 print
'<!-- Lines to consume -->'.
"\n";
914 print
'<div class="fichecenter">';
915 print
'<div class="fichehalfleft">';
916 print
'<div class="clearboth"></div>';
918 $url = $_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=addconsumeline&token='.
newToken();
919 $permissiontoaddaconsumeline = (
$object->status != $object::STATUS_PRODUCED &&
$object->status != $object::STATUS_CANCELED) ? 1 : -2;
920 $parameters = array(
'morecss' =>
'reposition');
922 if ($permissiontoaddaconsumeline == -2) {
923 $helpText = $langs->trans(
'MOIsClosed');
927 if ($action !=
'consumeorproduce' && $action !=
'consumeandproduceall') {
928 $newcardbutton =
dolGetButtonTitle($langs->trans(
'AddNewConsumeLines'), $helpText,
'fa fa-plus-circle size15x', $url,
'', $permissiontoaddaconsumeline, $parameters);
931 print
load_fiche_titre($langs->trans(
'Consumption'), $newcardbutton,
'', 0,
'',
'',
'');
933 print
'<div class="div-table-responsive-no-min">';
934 print
'<table class="noborder noshadow centpercent nobottom">';
936 print
'<!-- Line of title for products to consume -->'.
"\n";
937 print
'<tr class="liste_titre trheight5em">';
939 print
'<td>'.$langs->trans(
"Product").
'</td>';
941 print
'<td class="right">'.$langs->trans(
"Qty").
'</td>';
946 print
'<td class="right">'.$langs->trans(
"UnitCost").
'</td>';
949 print
'<td class="right classfortooltip" title="'.$langs->trans(
"QtyAlreadyConsumed").
'">';
950 print $langs->trans(
"QtyAlreadyConsumedShort");
954 if ($collapse || in_array($action, array(
'consumeorproduce',
'consumeandproduceall'))) {
955 print $langs->trans(
"Warehouse");
957 print
' '.$langs->trans(
"or").
' '.$langs->trans(
"Workstation");
960 if (in_array($action, array(
'consumeorproduce',
'consumeandproduceall'))) {
961 $listwarehouses = $tmpwarehouse->list_array(1);
962 if (count($listwarehouses) > 1) {
963 print
'<br>'.$form->selectarray(
'fk_default_warehouse', $listwarehouses, $fk_default_warehouse, $langs->trans(
"ForceTo"), 0, 0,
'', 0, 0, 0,
'',
'minwidth100 maxwidth200', 1);
964 } elseif (count($listwarehouses) == 1) {
965 print
'<br>'.$form->selectarray(
'fk_default_warehouse', $listwarehouses, $fk_default_warehouse, 0, 0, 0,
'', 0, 0, 0,
'',
'minwidth100 maxwidth200', 1);
973 print
'<td align="right">';
974 if ($collapse || in_array($action, array(
'consumeorproduce',
'consumeandproduceall'))) {
975 print $langs->trans(
"Stock");
982 if ($collapse || in_array($action, array(
'consumeorproduce',
'consumeandproduceall'))) {
983 print $langs->trans(
"Batch");
995 if (
$object->status == Mo::STATUS_DRAFT) {
1000 if ($permissiontodelete) {
1006 if ($action ==
'addconsumeline') {
1007 print
'<!-- Add line to consume -->'.
"\n";
1008 print
'<tr class="liste_titre">';
1011 print $form->select_produits(0,
'productidtoadd',
'', 0, 0, -1, 2,
'', 1, array(), 0,
'1', 0,
'maxwidth150');
1014 print
'<td class="right"><input type="text" name="qtytoadd" value="1" class="width40 right"></td>';
1022 if ($permissiontoupdatecost &&
getDolGlobalString(
'MRP_SHOW_COST_FOR_CONSUMPTION')) {
1034 print
'<td colspan="'.$colspan.
'">';
1035 print
'<input type="submit" class="button buttongen button-add" name="addconsumelinebutton" value="'.$langs->trans(
"Add").
'">';
1036 print
'<input type="submit" class="button buttongen button-cancel" name="canceladdconsumelinebutton" value="'.$langs->trans(
"Cancel").
'">';
1041 if (
$object->status == Mo::STATUS_DRAFT) {
1045 if ($permissiontodelete) {
1051 if (is_object($objectline)) {
1052 $extrafields->fetch_name_optionals_label(
$object->table_element_line);
1053 $temps = $objectline->showOptionals($extrafields,
'edit', array(),
'',
'',
'1',
'line');
1054 if (!empty($temps)) {
1055 print
'<tr class="liste_titre"><td style="padding-top: 20px" colspan="9" id="extrafield_lines_area_edit" name="extrafield_lines_area_edit">';
1064 $bomcostupdated = 0;
1067 $nblinetoconsume = 0;
1068 foreach (
$object->lines as $line) {
1069 if ($line->role ==
'toconsume') {
1074 $nblinetoconsumecursor = 0;
1075 foreach (
$object->lines as $line) {
1076 if ($line->role ==
'toconsume') {
1077 $nblinetoconsumecursor++;
1079 $tmpproduct =
new Product($db);
1080 $tmpproduct->fetch($line->fk_product);
1081 $linecost =
price2num($tmpproduct->pmp,
'MT');
1085 $costprice =
price2num((!empty($tmpproduct->cost_price)) ? $tmpproduct->cost_price : $tmpproduct->pmp);
1086 if (empty($costprice)) {
1087 require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.product.class.php';
1089 if ($productFournisseur->find_min_price_product_fournisseur($line->fk_product, $line->qty) > 0) {
1090 $costprice = $productFournisseur->fourn_unitprice;
1098 if ($useunit && $line->fk_unit > 0) {
1100 $qtyhourservice = 0;
1101 if (preg_match(
'/^(\d+)([a-z]+)$/', $tmpproduct->duration, $reg)) {
1104 $qtyhourforline = 0;
1105 if ($line->fk_unit) {
1111 if (
isModEnabled(
'workstation') && $line->fk_default_workstation > 0) {
1113 $workstation->fetch($line->fk_default_workstation);
1114 $linecost =
price2num($qtyhourforline * ($workstation->thm_operator_estimated + $workstation->thm_machine_estimated) /
$object->qty,
'MT');
1115 $bomcostupdated +=
price2num($qtyhourforline * ($workstation->thm_operator_estimated + $workstation->thm_machine_estimated) /
$object->qty,
'MU');
1116 } elseif ($qtyhourservice && $qtyhourforline) {
1117 $linecost =
price2num(($qtyhourforline / $qtyhourservice * $costprice) /
$object->qty,
'MT');
1118 $bomcostupdated +=
price2num(($qtyhourforline / $qtyhourservice * $costprice) /
$object->qty,
'MU');
1121 $bomcostupdated +=
price2num(($line->qty * $costprice) /
$object->qty,
'MU');
1125 $bomcostupdated +=
price2num(($line->qty * $costprice) /
$object->qty,
'MU');
1129 $bomcostupdated =
price2num($bomcostupdated,
'MU');
1130 $arrayoflines =
$object->fetchLinesLinked(
'consumed', $line->id);
1131 $alreadyconsumed = 0;
1132 foreach ($arrayoflines as $line2) {
1133 $alreadyconsumed += $line2[
'qty'];
1136 if ($action ==
'editline' && $lineid == $line->id) {
1137 $linecost =
price2num($tmpproduct->pmp,
'MT');
1139 $arrayoflines =
$object->fetchLinesLinked(
'consumed', $line->id);
1140 $alreadyconsumed = 0;
1141 if (is_array($arrayoflines) && !empty($arrayoflines)) {
1142 foreach ($arrayoflines as $line2) {
1143 $alreadyconsumed += $line2[
'qty'];
1146 $suffix =
'_' . $line->id;
1147 print
'<!-- Line to dispatch ' . $suffix .
' (line edited) -->' .
"\n";
1149 print
'<input id="qty_ordered' . $suffix .
'" type="hidden" value="' . $line->qty .
'">';
1151 print
'<input id="qty_dispatched' . $suffix .
'" type="hidden" value="' . $alreadyconsumed .
'">';
1153 print
'<input name="lineid" type="hidden" value="' . $line->id .
'">';
1156 print
'<td>' . $tmpproduct->getNomUrl(1);
1157 print
'<br><div class="opacitymedium small tdoverflowmax150" title="' .
dol_escape_htmltag($tmpproduct->label) .
'">' . $tmpproduct->label .
'</span>';
1161 print
'<td class="right nowraponall">';
1162 print
'<input class="width40 right" name="qty_lineProduce" value="'. $line->qty.
'">';
1166 print
'<td class="right nowraponall">';
1174 if ($permissiontoupdatecost &&
getDolGlobalString(
'MRP_SHOW_COST_FOR_CONSUMPTION')) {
1179 print
'<td class="right">';
1180 print
' ' .
price2num($alreadyconsumed,
'MS');
1186 print $formproduct->selectWarehouses($line->fk_warehouse,
'warehouse_lineProduce',
'warehouseopen', 1);
1188 print $formproduct->selectWorkstations($line->fk_default_workstation,
'workstation_lineProduce', 1);
1194 print
'<td class="nowraponall right">';
1195 if ($tmpproduct->isStockManaged()) {
1196 if ($tmpproduct->stock_reel < ($line->qty - $alreadyconsumed)) {
1197 print img_warning($langs->trans(
'StockTooLow')).
' ';
1199 print
'<span class="left">'. $tmpproduct->stock_reel .
' </span>';
1209 print
'<td colspan="'.(3 + (
$object->status == Mo::STATUS_DRAFT ? 1 : 0) + ($permissiontodelete ? 1 : 0)).
'">';
1210 print
'<input type="submit" class="button buttongen button-add small nominwidth" name="save" value="' . $langs->trans(
"Save") .
'">';
1211 print
'<input type="submit" class="button buttongen button-cancel small nominwidth" name="cancel" value="' . $langs->trans(
"Cancel") .
'">';
1217 if (!empty($extrafields)) {
1218 $line->fetch_optionals();
1219 $temps = $line->showOptionals($extrafields,
'edit', array(),
'',
'',
'1',
'line');
1220 if (!empty($temps)) {
1222 print
'<tr><td colspan="'.$colspan.
'"><div style="padding-top: 20px" id="extrafield_lines_area_edit" name="extrafield_lines_area_edit">';
1224 print
'</div></td></tr>';
1228 $suffix =
'_' . $line->id;
1229 print
'<!-- Line to dispatch ' . $suffix .
' -->' .
"\n";
1231 print
'<input id="qty_ordered' . $suffix .
'" type="hidden" value="' . $line->qty .
'">';
1232 print
'<input id="qty_dispatched' . $suffix .
'" type="hidden" value="' . $alreadyconsumed .
'">';
1234 print
'<tr data-line-id="' . $line->id .
'">';
1237 print
'<td>' . $tmpproduct->getNomUrl(1);
1238 print
'<br><div class="opacitymedium small tdoverflowmax150" title="' .
dol_escape_htmltag($tmpproduct->label) .
'">' . $tmpproduct->label .
'</div>';
1242 print
'<td class="right nowraponall">';
1244 if ($line->qty_frozen) {
1245 $help = ($help ?
'<br>' :
'') .
'<strong>' . $langs->trans(
"QuantityFrozen") .
'</strong>: ' . yn(1) .
' (' . $langs->trans(
"QuantityConsumedInvariable") .
')';
1246 print $form->textwithpicto(
'', $help, -1,
'lock') .
' ';
1248 if ($line->disable_stock_change) {
1249 $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")) .
')';
1250 print $form->textwithpicto(
'', $help, -1,
'help') .
' ';
1256 print
'<td class="right nowraponall">';
1264 if ($permissiontoupdatecost &&
getDolGlobalString(
'MRP_SHOW_COST_FOR_CONSUMPTION')) {
1265 print
'<td class="right nowraponall">';
1266 print
price($linecost);
1271 print
'<td class="right">';
1272 if ($alreadyconsumed) {
1274 print
'jQuery(document).ready(function() {
1275 jQuery("#expandtoproduce' . $line->id .
'").click(function() {
1276 console.log("Expand mrp_production line ' . $line->id .
'");
1277 jQuery(".expanddetail' . $line->id .
'").toggle();';
1278 if ($nblinetoconsume == $nblinetoconsumecursor) {
1279 print
'if (jQuery("#tablelines").hasClass("nobottom")) { jQuery("#tablelines").removeClass("nobottom"); } else { jQuery("#tablelines").addClass("nobottom"); }';
1285 if (empty(
$conf->use_javascript_ajax)) {
1286 print
'<a href="' . $_SERVER[
"PHP_SELF"] .
'?collapse=' . $collapse .
',' . $line->id .
'">';
1288 print img_picto($langs->trans(
"ShowDetails"),
"chevron-down",
'id="expandtoproduce' . $line->id .
'"');
1289 if (empty(
$conf->use_javascript_ajax)) {
1293 if ($nblinetoconsume == $nblinetoconsumecursor) {
1294 print
'<script>jQuery("#tablelines").removeClass("nobottom");</script>';
1297 print
' ' .
price2num($alreadyconsumed,
'MS');
1301 print
'<td class="tdoverflowmax100">';
1302 if ($tmpproduct->isStockManaged()) {
1304 if (
getDolGlobalString(
'STOCK_CONSUMPTION_FROM_MANUFACTURING_WAREHOUSE') && $tmpwarehouse->id > 0) {
1305 print img_picto(
'', $tmpwarehouse->picto) .
" " . $tmpwarehouse->label;
1307 if ($line->fk_warehouse > 0) {
1308 $warehouseline =
new Entrepot($db);
1309 $warehouseline->fetch($line->fk_warehouse);
1310 print $warehouseline->getNomUrl(1);
1314 if (
isModEnabled(
'workstation') && $line->fk_default_workstation > 0) {
1316 $tmpworkstation->fetch($line->fk_default_workstation);
1317 print $tmpworkstation->getNomUrl(1);
1323 print
'<td class="nowraponall right">';
1325 if (!$line->disable_stock_change && $tmpproduct->stock_reel < ($line->qty - $alreadyconsumed)) {
1326 print img_warning($langs->trans(
'StockTooLow')) .
' ';
1328 if (!
getDolGlobalString(
'STOCK_CONSUMPTION_FROM_MANUFACTURING_WAREHOUSE') || empty($tmpwarehouse->id)) {
1329 print
price2num($tmpproduct->stock_reel,
'MS');
1332 $tmpproduct->load_stock();
1333 $wh_stock = $tmpproduct->stock_warehouse[$tmpwarehouse->id];
1334 if (!empty($wh_stock)) {
1356 if (
$object->status == Mo::STATUS_DRAFT) {
1357 $href = $_SERVER[
"PHP_SELF"] .
'?id=' . ((int)
$object->id) .
'&action=editline&token=' .
newToken() .
'&lineid=' . ((int) $line->id);
1358 print
'<td class="center">';
1359 print
'<a class="reposition editfielda" href="' . $href .
'">';
1360 print img_picto($langs->trans(
'TooltipEditAndRevertStockMovement'),
'edit');
1366 if ($permissiontodelete && empty($arrayoflines)) {
1367 $href = $_SERVER[
"PHP_SELF"] .
'?id=' . ((int)
$object->id) .
'&action=deleteline&token=' .
newToken() .
'&lineid=' . ((int) $line->id);
1368 print
'<td class="center">';
1369 print
'<a class="reposition" href="' . $href .
'">';
1370 print img_picto($langs->trans(
'TooltipDeleteAndRevertStockMovement'),
'delete');
1378 if (!empty($extrafields)) {
1379 $line->fetch_optionals();
1380 $temps = $line->showOptionals($extrafields,
'view', array(),
'',
'',
'1',
'line');
1381 if (!empty($temps)) {
1383 print
'<tr><td colspan="'.$colspan.
'"><div id="extrafield_lines_area_'.$line->id.
'" name="extrafield_lines_area_'.$line->id.
'">';
1385 print
'</div></td></tr>';
1391 foreach ($arrayoflines as $line2) {
1392 print
'<tr class="expanddetail'.$line->id.
' hideobject opacitylow">';
1396 $tmpstockmovement->id = $line2[
'fk_stock_movement'];
1397 print
'<a href="'.DOL_URL_ROOT.
'/product/stock/movement_list.php?search_ref='.$tmpstockmovement->id.
'">'.img_picto($langs->trans(
"StockMovement"),
'movement',
'class="paddingright"').
'</a>';
1408 if ($permissiontoupdatecost &&
getDolGlobalString(
'MRP_SHOW_COST_FOR_CONSUMPTION')) {
1413 print
'<td class="right">'.$line2[
'qty'].
'</td>';
1416 print
'<td class="tdoverflowmax150">';
1417 if ($line2[
'fk_warehouse'] > 0) {
1418 $result = $tmpwarehouse->fetch($line2[
'fk_warehouse']);
1420 print $tmpwarehouse->getNomUrl(1);
1433 if ($line2[
'batch'] !=
'') {
1434 $tmpbatch->fetch(0, $line2[
'fk_product'], $line2[
'batch']);
1435 print $tmpbatch->getNomUrl(1);
1447 if (
$object->status == Mo::STATUS_DRAFT) {
1448 $href = $_SERVER[
"PHP_SELF"] .
'?id=' . ((int)
$object->id) .
'&action=editline&token=' .
newToken() .
'&lineid=' . ((int) $line2[
'rowid']);
1449 print
'<td class="center">';
1450 print
'<a class="reposition" href="' . $href .
'">';
1451 print img_picto($langs->trans(
'TooltipEditAndRevertStockMovement'),
'edit');
1457 if ($permissiontodelete) {
1458 $href = $_SERVER[
"PHP_SELF"].
'?id='.((int)
$object->id).
'&action=deleteline&token='.
newToken().
'&lineid='.((int) $line2[
'rowid']).
'&fk_movement='.((int) $line2[
'fk_stock_movement']);
1459 print
'<td class="center">';
1460 print
'<a class="reposition" href="'.$href.
'">';
1461 print img_picto($langs->trans(
'TooltipDeleteAndRevertStockMovement'),
'delete');
1469 if (in_array($action, array(
'consumeorproduce',
'consumeandproduceall'))) {
1471 print
'<!-- Enter line to consume -->'.
"\n";
1473 print
'<tr data-max-qty="'.$maxQty.
'" name="batch_'.$line->id.
'_'.$i.
'">';
1475 print
'<td><span class="opacitymedium">'.$langs->trans(
"ToConsume").
'</span></td>';
1476 $preselected = (
GETPOSTISSET(
'qty-'.$line->id.
'-'.$i) ?
GETPOST(
'qty-'.$line->id.
'-'.$i) : max(0, $line->qty - $alreadyconsumed));
1477 if ($action ==
'consumeorproduce' && !
getDolGlobalString(
'MRP_AUTO_SET_REMAINING_QUANTITIES_TO_BE_CONSUMED') && !
GETPOSTISSET(
'qty-'.$line->id.
'-'.$i)) {
1482 if (
getDolGlobalString(
'MRP_NEVER_CONSUME_MORE_THAN_EXPECTED') && ($line->qty - $alreadyconsumed) <= 0) {
1483 $disable =
'disabled';
1487 print
'<input type="hidden" name="product-'.$line->id.
'-'.$i.
'" value="'.$line->fk_product.
'">';
1490 print
'<td class="right">';
1491 if ((
int) $tmpproduct->stockable_product > 0) {
1492 print
'<input type="text" class="width50 right" id="qtytoconsume-' . $line->id .
'-' . $i .
'" name="qty-' . $line->id .
'-' . $i .
'" value="' . $preselected .
'" ' . $disable .
'>';
1494 print
'<input type="hidden" id="qtytoconsume-' . $line->id .
'-' . $i .
'" name="qty-' . $line->id .
'-' . $i .
'" value="0">';
1495 print
'<span class="opacitymedium">' . $langs->trans(
"StockDisabled") .
'</span>';
1503 if ($permissiontoupdatecost &&
getDolGlobalString(
'MRP_SHOW_COST_FOR_CONSUMPTION')) {
1513 && ((
int) $tmpproduct->stockable_product > 0)) {
1514 if (empty($line->disable_stock_change)) {
1515 $preselected = (
GETPOSTISSET(
'idwarehouse-'.$line->id.
'-'.$i) ?
GETPOST(
'idwarehouse-'.$line->id.
'-'.$i) : ($tmpproduct->fk_default_warehouse > 0 ? $tmpproduct->fk_default_warehouse :
'ifone'));
1516 print $formproduct->selectWarehouses($preselected,
'idwarehouse-'.$line->id.
'-'.$i,
'', 1, 0, $line->fk_product,
'', 1, 0, array(),
'maxwidth200 csswarehouse_'.$line->id.
'_'.$i);
1518 print
'<span class="opacitymedium">'.$langs->trans(
"DisableStockChange").
'</span>';
1521 if ((
int) $tmpproduct->stockable_product > 0) {
1522 print
'<span class="opacitymedium">' . $langs->trans(
"StockDisabled") .
'</span>';
1524 print
'<span class="opacitymedium">' . $langs->trans(
"NoStockChangeOnServices") .
'</span>';
1536 print
'<td class="nowraponall">';
1537 if ($tmpproduct->status_batch) {
1538 $preselected = (
GETPOSTISSET(
'batch-'.$line->id.
'-'.$i) ?
GETPOST(
'batch-'.$line->id.
'-'.$i) :
'');
1539 print
'<input type="text" class="width75" name="batch-'.$line->id.
'-'.$i.
'" value="'.$preselected.
'" list="batch-'.$line->id.
'-'.$i.
'">';
1540 print $formproduct->selectLotDataList(
'batch-'.$line->id.
'-'.$i, 0, $line->fk_product, 0, array());
1547 print
'<td align="right" class="split">';
1548 print
' '.img_picto($langs->trans(
'AddStockLocationLine'),
'split',
'class="splitbutton" onClick="addDispatchLine('.((int) $line->id).
', \''.
dol_escape_js($type).
'\', \
'qtymissingconsume\', 1)"');
1552 print
'<td align="right" class="splitall">';
1553 if (($action ==
'consumeorproduce' || $action ==
'consumeandproduceall') && $tmpproduct->status_batch == 2) {
1554 print img_picto($langs->trans(
'SplitAllQuantity'),
'split',
'class="splitbutton splitallbutton field-error-icon" data-max-qty="1" onClick="addDispatchLine('.$line->id.
', \'batch\', \'allmissingconsume\', 1)"');
1559 if (
$object->status == Mo::STATUS_DRAFT) {
1564 if ($permissiontodelete) {
1578 print
'<script type="text/javascript">
1579 $(document).ready(function () {
1580 $("select[name=fk_default_warehouse]").change(function() {
1581 var fk_default_warehouse = $("option:selected", this).val();
1582 $("select[name^=idwarehouse-]").val(fk_default_warehouse).change();
1587 if (in_array($action, array(
'consumeorproduce',
'consumeandproduceall')) &&
1589 print
'<script>$(document).ready(function () {
1590 $("#fk_default_warehouse").change();
1598 print
'<div class="fichehalfright">';
1599 print
'<div class="clearboth"></div>';
1601 $nblinetoproduce = 0;
1602 $atLeastOneEatBy =
false;
1603 $atLeastOneSellBy =
false;
1604 foreach (
$object->lines as $line) {
1605 if ($line->role ==
'toproduce') {
1606 $tmpproduct =
new Product($db);
1607 $tmpproduct->fetch($line->fk_product);
1609 $tmpproduct->sell_or_eat_by_mandatory == $tmpproduct::SELL_OR_EAT_BY_MANDATORY_ID_EAT_BY
1610 || $tmpproduct->sell_or_eat_by_mandatory == $tmpproduct::SELL_OR_EAT_BY_MANDATORY_ID_SELL_AND_EAT
1612 $atLeastOneEatBy =
true;
1615 $tmpproduct->sell_or_eat_by_mandatory == $tmpproduct::SELL_OR_EAT_BY_MANDATORY_ID_SELL_BY
1616 || $tmpproduct->sell_or_eat_by_mandatory == $tmpproduct::SELL_OR_EAT_BY_MANDATORY_ID_SELL_AND_EAT
1618 $atLeastOneSellBy =
true;
1624 $newcardbutton =
'';
1625 $url = $_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=addproduceline&token='.
newToken();
1626 $permissiontoaddaproductline =
$object->status != $object::STATUS_PRODUCED &&
$object->status != $object::STATUS_CANCELED;
1627 $parameters = array(
'morecss' =>
'reposition');
1628 if ($action !=
'consumeorproduce' && $action !=
'consumeandproduceall') {
1629 if ($nblinetoproduce == 0 ||
$object->mrptype == 1) {
1630 $newcardbutton =
dolGetButtonTitle($langs->trans(
'AddNewProduceLines'),
'',
'fa fa-plus-circle size15x', $url,
'', (
int) $permissiontoaddaproductline, $parameters);
1634 print
load_fiche_titre($langs->trans(
'Production'), $newcardbutton,
'', 0,
'',
'');
1636 print
'<div class="div-table-responsive-no-min">';
1637 print
'<table id="tablelinestoproduce" class="noborder noshadow nobottom centpercent">';
1639 print
'<tr class="liste_titre trheight5em">';
1641 print
'<td>'.$langs->trans(
"Product").
'</td>';
1643 print
'<td class="right">'.$langs->trans(
"Qty").
'</td>';
1646 print
'<td class="right">'.$langs->trans(
"Unit").
'</td>';
1649 if ($permissiontoupdatecost) {
1650 if (empty($bomcostupdated)) {
1651 print
'<td class="right classfortooltip" title="'.$langs->trans(
"AmountUsedToUpdateWAP").
'">';
1652 print $langs->trans(
"UnitCost");
1655 print
'<td class="right classfortooltip" title="'.$langs->trans(
"AmountUsedToUpdateWAP").
'">';
1656 print $langs->trans(
"ManufacturingPrice");
1661 print
'<td class="right classfortooltip" title="'.$langs->trans(
"QtyAlreadyProduced").
'">';
1662 print $langs->trans(
"QtyAlreadyProducedShort");
1666 if ($collapse || in_array($action, array(
'consumeorproduce',
'consumeandproduceall'))) {
1667 print $langs->trans(
"Warehouse");
1674 if ($collapse || in_array($action, array(
'consumeorproduce',
'consumeandproduceall'))) {
1675 print $langs->trans(
"Batch");
1686 if ($atLeastOneEatBy) {
1687 print
'<td>'.$langs->trans(
"EatByDate").
'</td>';
1691 if ($atLeastOneSellBy) {
1692 print
'<td>'.$langs->trans(
"SellByDate").
'</td>';
1697 if ($permissiontodelete) {
1703 if ($action ==
'addproduceline') {
1704 print
'<!-- Add line to produce -->'.
"\n";
1705 print
'<tr class="liste_titre">';
1709 print $form->select_produits(0,
'productidtoadd',
'', 0, 0, -1, 2,
'', 1, array(), 0,
'1', 0,
'maxwidth300');
1712 print
'<td class="right"><input type="text" name="qtytoadd" value="1" class="width50 right"></td>';
1718 if ($permissiontoupdatecost) {
1722 print
'<td colspan="2">';
1723 print
'<input type="submit" class="button buttongen button-add" name="addproducelinebutton" value="'.$langs->trans(
"Add").
'">';
1724 print
'<input type="submit" class="button buttongen button-cancel" name="canceladdproducelinebutton" value="'.$langs->trans(
"Cancel").
'">';
1737 if ($permissiontodelete) {
1744 $nblinetoproduce = 0;
1745 foreach (
$object->lines as $line) {
1746 if ($line->role ==
'toproduce') {
1751 $nblinetoproducecursor = 0;
1752 foreach (
$object->lines as $line) {
1753 if ($line->role ==
'toproduce') {
1756 $nblinetoproducecursor++;
1758 $tmpproduct =
new Product($db);
1759 $tmpproduct->fetch($line->fk_product);
1761 $arrayoflines =
$object->fetchLinesLinked(
'produced', $line->id);
1762 $alreadyproduced = 0;
1763 foreach ($arrayoflines as $line2) {
1764 $alreadyproduced += $line2[
'qty'];
1767 $suffix =
'_'.$line->id;
1768 print
'<!-- Line to dispatch '.$suffix.
' (toproduce) -->'.
"\n";
1770 print
'<input id="qty_ordered'.$suffix.
'" type="hidden" value="'.$line->qty.
'">';
1771 print
'<input id="qty_dispatched'.$suffix.
'" type="hidden" value="'.$alreadyproduced.
'">';
1775 print
'<td>'.$tmpproduct->getNomUrl(1);
1776 print
'<br><span class="opacitymedium small">'.$tmpproduct->label.
'</span>';
1779 print
'<td class="right">'.$line->qty.
'</td>';
1782 print
'<td class="right">'.measuringUnitString($line->fk_unit,
'',
null, 1).
'</td>';
1785 if ($permissiontoupdatecost) {
1787 $manufacturingcost = 0;
1788 $manufacturingcostsrc =
'';
1790 $manufacturingcost = $bomcostupdated;
1791 $manufacturingcostsrc = $langs->trans(
"CalculatedFromProductsToConsume");
1792 if (empty($manufacturingcost)) {
1793 $manufacturingcost = $bomcost;
1794 $manufacturingcostsrc = $langs->trans(
"ValueFromBom");
1796 if (empty($manufacturingcost)) {
1797 $manufacturingcost =
price2num($tmpproduct->cost_price,
'MU');
1798 $manufacturingcostsrc = $langs->trans(
"CostPrice");
1800 if (empty($manufacturingcost)) {
1801 $manufacturingcost =
price2num($tmpproduct->pmp,
'MU');
1802 $manufacturingcostsrc = $langs->trans(
"PMPValue");
1806 print
'<td class="right nowraponall" title="'.dol_escape_htmltag($manufacturingcostsrc).
'">';
1807 if ($manufacturingcost) {
1808 print
price($manufacturingcost);
1813 print
'<td class="right nowraponall">';
1814 if ($alreadyproduced) {
1816 print
'jQuery(document).ready(function() {
1817 jQuery("#expandtoproduce'.$line->id.
'").click(function() {
1818 console.log("Expand mrp_production line '.$line->id.
'");
1819 jQuery(".expanddetailtoproduce'.$line->id.
'").toggle();';
1820 if ($nblinetoproduce == $nblinetoproducecursor) {
1821 print
'if (jQuery("#tablelinestoproduce").hasClass("nobottom")) { jQuery("#tablelinestoproduce").removeClass("nobottom"); } else { jQuery("#tablelinestoproduce").addClass("nobottom"); }';
1827 if (empty(
$conf->use_javascript_ajax)) {
1828 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?collapse='.$collapse.
','.$line->id.
'">';
1830 print img_picto($langs->trans(
"ShowDetails"),
"chevron-down",
'id="expandtoproduce'.$line->id.
'"');
1831 if (empty(
$conf->use_javascript_ajax)) {
1835 print
' '.$alreadyproduced;
1851 if ($permissiontodelete) {
1852 if ($line->origin_type ==
'free') {
1853 $href = $_SERVER[
"PHP_SELF"];
1854 $href .=
'?id='.$object->id;
1855 $href .=
'&action=deleteline';
1856 $href .=
'&token='.newToken();
1857 $href .=
'&lineid='.$line->id;
1858 print
'<td class="center">';
1859 print
'<a class="reposition" href="'.$href.
'">';
1860 print img_picto($langs->trans(
'TooltipDeleteAndRevertStockMovement'),
"delete");
1870 foreach ($arrayoflines as $line2) {
1871 print
'<tr class="expanddetailtoproduce'.$line->id.
' hideobject opacitylow">';
1874 $tmpstockmovement->id = $line2[
'fk_stock_movement'];
1875 print
'<a href="'.DOL_URL_ROOT.
'/product/stock/movement_list.php?search_ref='.$tmpstockmovement->id.
'">'.img_picto($langs->trans(
"StockMovement"),
'movement',
'class="paddingright"').
'</a>';
1885 if ($permissiontoupdatecost) {
1889 print
'<td class="right">'.$line2[
'qty'].
'</td>';
1891 print
'<td class="tdoverflowmax150">';
1892 if ($line2[
'fk_warehouse'] > 0) {
1893 $result = $tmpwarehouse->fetch($line2[
'fk_warehouse']);
1895 print $tmpwarehouse->getNomUrl(1);
1902 if ($line2[
'batch'] !=
'') {
1903 $tmpbatch->fetch(0, $line2[
'fk_product'], $line2[
'batch']);
1904 print $tmpbatch->getNomUrl(1);
1915 if ($permissiontodelete) {
1921 if (in_array($action, array(
'consumeorproduce',
'consumeandproduceall'))) {
1922 print
'<!-- Enter line to produce -->'.
"\n";
1924 print
'<tr data-max-qty="'.$maxQty.
'" name="batch_'.$line->id.
'_'.$i.
'">';
1926 print
'<td><span class="opacitymedium">'.$langs->trans(
"ToProduce").
'</span></td>';
1927 $preselected = (
GETPOSTISSET(
'qtytoproduce-'.$line->id.
'-'.$i) ?
GETPOST(
'qtytoproduce-'.$line->id.
'-'.$i) : max(0, $line->qty - $alreadyproduced));
1928 if ($action ==
'consumeorproduce' && !
GETPOSTISSET(
'qtytoproduce-'.$line->id.
'-'.$i)) {
1932 print
'<td class="right"><input type="text" class="width50 right" id="qtytoproduce-'.$line->id.
'-'.$i.
'" name="qtytoproduce-'.$line->id.
'-'.$i.
'" value="'.$preselected.
'"></td>';
1935 print
'<td class="right"></td>';
1938 if ($permissiontoupdatecost) {
1940 $manufacturingcost = 0;
1941 $manufacturingcostsrc =
'';
1943 $manufacturingcost = $bomcostupdated;
1944 $manufacturingcostsrc = $langs->trans(
"CalculatedFromProductsToConsume");
1945 if (empty($manufacturingcost)) {
1946 $manufacturingcost = $bomcost;
1947 $manufacturingcostsrc = $langs->trans(
"ValueFromBom");
1949 if (empty($manufacturingcost)) {
1950 $manufacturingcost =
price2num($tmpproduct->cost_price,
'MU');
1951 $manufacturingcostsrc = $langs->trans(
"CostPrice");
1953 if (empty($manufacturingcost)) {
1954 $manufacturingcost =
price2num($tmpproduct->pmp,
'MU');
1955 $manufacturingcostsrc = $langs->trans(
"PMPValue");
1960 $preselected = (
GETPOSTISSET(
'pricetoproduce-'.$line->id.
'-'.$i) ?
GETPOST(
'pricetoproduce-'.$line->id.
'-'.$i) : ($manufacturingcost ?
price($manufacturingcost) :
''));
1961 print
'<td class="right"><input type="text" class="width75 right" name="pricetoproduce-'.$line->id.
'-'.$i.
'" value="'.$preselected.
'"></td>';
1963 print
'<td><input type="hidden" class="width50 right" name="pricetoproduce-'.$line->id.
'-'.$i.
'" value="'.($manufacturingcost ? $manufacturingcost :
'').
'"></td>';
1971 $preselected = (
GETPOSTISSET(
'idwarehousetoproduce-'.$line->id.
'-'.$i) ?
GETPOST(
'idwarehousetoproduce-'.$line->id.
'-'.$i) : (
$object->fk_warehouse > 0 ?
$object->fk_warehouse :
'ifone'));
1972 print $formproduct->selectWarehouses($preselected,
'idwarehousetoproduce-'.$line->id.
'-'.$i,
'', 1, 0, $line->fk_product,
'', 1, 0, array(),
'maxwidth200 csswarehouse_'.$line->id.
'_'.$i);
1974 print
'<span class="opacitymedium">'.$langs->trans(
"NoStockChangeOnServices").
'</span>';
1980 if ($tmpproduct->status_batch) {
1981 $preselected = (
GETPOSTISSET(
'batchtoproduce-'.$line->id.
'-'.$i) ?
GETPOST(
'batchtoproduce-'.$line->id.
'-'.$i) :
'');
1982 print
'<input type="text" class="width75" name="batchtoproduce-'.$line->id.
'-'.$i.
'" value="'.$preselected.
'">';
1986 if ($tmpproduct->status_batch) {
1988 print
'<td align="right" class="split">';
1989 print img_picto($langs->trans(
'AddStockLocationLine'),
'split',
'class="splitbutton" onClick="addDispatchLine('.$line->id.
', \''.$type.
'\', \
'qtymissing\')"');
1992 print
'<td align="right" class="splitall">';
1993 if (($action ==
'consumeorproduce' || $action ==
'consumeandproduceall') && $tmpproduct->status_batch == 2) {
1994 print img_picto($langs->trans(
'SplitAllQuantity'),
'split',
'class="splitbutton splitallbutton field-error-icon" onClick="addDispatchLine('.$line->id.
', \'batch\', \'alltoproduce\')"');
2005 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) {
2006 print
'<td align="right">';
2007 $preselectedSellBy = (
GETPOSTISSET(
'sellby-' . $line->id .
'-' . $i) ?
GETPOSTDATE(
'sellby-' . $line->id .
'-' . $i) :
'');
2008 print $form->selectDate($preselectedSellBy,
'sellby-' . $line->id .
'-' . $i, 0, 0, 1,
'', 1, 0);
2011 if ($atLeastOneSellBy) {
2017 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) {
2018 print
'<td align="right">';
2019 $preselectedEatBy = (
GETPOSTISSET(
'eatby-' . $line->id .
'-' . $i) ?
GETPOSTDATE(
'eatby-' . $line->id .
'-' . $i) :
'');
2020 print $form->selectDate($preselectedEatBy,
'eatby-' . $line->id .
'-' . $i, 0, 0, 1,
'', 1, 0);
2023 if ($atLeastOneEatBy) {
2044 if (in_array($action, array(
'consumeorproduce',
'consumeandproduceall',
'addconsumeline'))) {
2048 <script
type=
"text/javascript">
2050 $(document).ready(
function() {
2052 updateselectbatchbywarehouse();
2054 updateselectwarehousebybatch();
2057 function updateselectbatchbywarehouse() {
2058 $(document).on(
'change',
"select[name*='idwarehouse']",
function () {
2059 console.log(
"We change warehouse so we update the list of possible batch number");
2061 var selectwarehouse = $(
this);
2063 var selectbatch_name = selectwarehouse.attr(
'name').replace(
'idwarehouse',
'batch');
2064 var selectbatch = $(
"datalist[id*='" + selectbatch_name +
"']");
2065 var selectedbatch = selectbatch.val();
2067 var product_element_name = selectwarehouse.attr(
'name').replace(
'idwarehouse',
'product');
2071 url:
"<?php echo DOL_URL_ROOT . '/mrp/ajax/interface.php'; ?>",
2073 action:
"updateselectbatchbywarehouse",
2074 permissiontoproduce: <?php echo $permissiontoproduce ?>,
2075 warehouse_id: $(
this).val(),
2076 token:
'<?php echo currentToken(); ?>',
2077 product_id: $(
"input[name='" + product_element_name +
"']").val()
2079 }).done(
function (data) {
2081 selectbatch.empty();
2083 if (typeof data ==
"object") {
2084 console.log(
"data is already type object, no need to parse it");
2086 console.log(
"data is type "+(typeof data));
2087 data = JSON.parse(data);
2090 selectbatch.append($(
'<option>', {
2094 $.each(data,
function (key, value) {
2096 if(selectwarehouse.val() == -1) {
2097 var label = key +
" (<?php echo $langs->trans('TotalStock') ?> : " + value +
")";
2099 var label = key +
" (<?php echo $langs->trans('Stock') ?> : " + value +
")";
2102 if(key === selectedbatch) {
2103 var option =
'<option value="'+key+
'" selected>'+ label +
'</option>';
2105 var option =
'<option value="'+key+
'">'+ label +
'</option>';
2108 selectbatch.append(option);
2114 function updateselectwarehousebybatch() {
2115 $(document).on(
'change',
'input[name*=batch]',
function(){
2116 console.log(
"We change batch so we update the list of possible warehouses");
2118 var selectbatch = $(
this);
2120 var selectwarehouse_name = selectbatch.attr(
'name').replace(
'batch',
'idwarehouse');
2121 var selectwarehouse = $(
"select[name*='" + selectwarehouse_name +
"']");
2122 var selectedwarehouse = selectwarehouse.val();
2124 if(selectedwarehouse != -1){
2128 var product_element_name = selectbatch.attr(
'name').replace(
'batch',
'product');
2132 url:
"<?php echo DOL_URL_ROOT . '/mrp/ajax/interface.php'; ?>",
2134 action:
"updateselectwarehousebybatch",
2135 permissiontoproduce: <?php echo $permissiontoproduce ?>,
2136 batch: $(
this).val(),
2137 token:
'<?php echo currentToken(); ?>',
2138 product_id: $(
"input[name='" + product_element_name +
"']").val()
2140 }).done(
function (data) {
2142 if (typeof data ==
"object") {
2143 console.log(
"data is already type object, no need to parse it");
2145 console.log(
"data is type "+(typeof data));
2146 data = JSON.parse(data);
2150 selectwarehouse.val(data).change();
$id
Support class for third parties, contacts, members, users or resources.
if(! $sortfield) if(! $sortorder) $object
$propal type
'integer', 'integer:ObjectClass:PathToClass[:AddCreateButtonOrNot[:Filter[:Sortfield]]]',...
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.
GETPOSTDATE($prefix, $hourTime='', $gm='auto', $saverestore='')
Helper function that combines values of a dolibarr DatePicker (such as Form\selectDate) for year,...
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
dolBuildUrl($url, $params=[], $addtoken=false, $anchor='')
Return path of url.
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.
GETPOSTINT($paramname, $method=0, $nodefault=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dol_clone($srcobject, $native=2)
Create a clone of instance of object (new instance with same value for each properties) With native =...
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).
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.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
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.
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.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='', $morecssonpicto='widthpictotitle')
Load a title with picto.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
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.
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.