31require
'../main.inc.php';
32require_once DOL_DOCUMENT_ROOT.
'/bom/class/bom.class.php';
33require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formcompany.class.php';
34require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
35require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formprojet.class.php';
36require_once DOL_DOCUMENT_ROOT.
'/mrp/class/mo.class.php';
37require_once DOL_DOCUMENT_ROOT.
'/mrp/lib/mrp_mo.lib.php';
38require_once DOL_DOCUMENT_ROOT.
'/projet/class/project.class.php';
39require_once DOL_DOCUMENT_ROOT.
'/product/class/product.class.php';
40require_once DOL_DOCUMENT_ROOT.
'/product/class/html.formproduct.class.php';
41require_once DOL_DOCUMENT_ROOT.
'/product/stock/class/entrepot.class.php';
42require_once DOL_DOCUMENT_ROOT.
'/product/stock/class/productlot.class.php';
43require_once DOL_DOCUMENT_ROOT.
'/product/stock/class/mouvementstock.class.php';
44require_once DOL_DOCUMENT_ROOT.
'/workstation/class/workstation.class.php';
56$langs->loadLangs(array(
"mrp",
"stocks",
"other",
"product",
"productbatch"));
61$action =
GETPOST(
'action',
'aZ09');
62$confirm =
GETPOST(
'confirm',
'alpha');
64$contextpage =
GETPOST(
'contextpage',
'aZ') ?
GETPOST(
'contextpage',
'aZ') :
'mocard';
65$backtopage =
GETPOST(
'backtopage',
'alpha');
68$fk_default_warehouse =
GETPOSTINT(
'fk_default_warehouse');
70$collapse =
GETPOST(
'collapse',
'aZ09comma');
75$diroutputmassaction = $conf->mrp->dir_output.
'/temp/massgeneration/'.$user->id;
76$objectline =
new MoLine($db);
78$hookmanager->initHooks(array(
'moproduction',
'globalcard'));
81$extrafields->fetch_name_optionals_label(
$object->table_element);
83$search_array_options = $extrafields->getOptionalsFromPost(
$object->table_element,
'',
'search_');
86$search_all =
GETPOST(
"search_all",
'alpha');
88foreach (
$object->fields as $key => $val) {
89 if (
GETPOST(
'search_'.$key,
'alpha')) {
90 $search[$key] =
GETPOST(
'search_'.$key,
'alpha');
94if (empty($action) && empty($id) && empty($ref)) {
99include DOL_DOCUMENT_ROOT.
'/core/actions_fetchobject.inc.php';
104$isdraft = ((
$object->status == $object::STATUS_DRAFT) ? 1 : 0);
108$permissionnote = $user->hasRight(
'mrp',
'write');
109$permissiondellink = $user->hasRight(
'mrp',
'write');
110$permissiontoadd = $user->hasRight(
'mrp',
'write');
111$permissiontodelete = $user->hasRight(
'mrp',
'delete') || ($permissiontoadd && isset(
$object->status) &&
$object->status == $object::STATUS_DRAFT);
113$permissiontoproduce = $permissiontoadd;
114$permissiontoupdatecost = $user->hasRight(
'bom',
'read');
116$upload_dir = $conf->mrp->multidir_output[isset(
$object->entity) ?
$object->entity : 1];
123$parameters = array();
124$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
129if (empty($reshook)) {
132 $backurlforlist = DOL_URL_ROOT.
'/mrp/mo_list.php';
134 if (empty($backtopage) || ($cancel && empty($id))) {
136 if (empty($id) && (($action !=
'add' && $action !=
'create') || $cancel)) {
137 $backtopage = $backurlforlist;
139 $backtopage = DOL_URL_ROOT.
'/mrp/mo_production.php?id='.(
$id > 0 ?
$id :
'__ID__');
142 $triggermodname =
'MO_MODIFY';
144 if ($action ==
'confirm_cancel' && $confirm ==
'yes' && !empty($permissiontoadd)) {
145 $also_cancel_consumed_and_produced_lines = (
GETPOST(
'alsoCancelConsumedAndProducedLines',
'alpha') ? 1 : 0);
146 $result =
$object->cancel($user, 0, (
bool) $also_cancel_consumed_and_produced_lines);
148 header(
"Location: " . DOL_URL_ROOT.
'/mrp/mo_card.php?id=' .
$object->id);
154 } elseif ($action ==
'confirm_delete' && $confirm ==
'yes' && !empty($permissiontodelete)) {
155 $also_cancel_consumed_and_produced_lines = (
GETPOST(
'alsoCancelConsumedAndProducedLines',
'alpha') ? 1 : 0);
156 $result =
$object->delete($user, 0, (
bool) $also_cancel_consumed_and_produced_lines);
158 header(
"Location: " . $backurlforlist);
172 if ($action ==
'setqty' && $permissiontoadd &&
$object->status == Mo::STATUS_DRAFT) {
186 foreach (
$object->lines as $line) {
187 if ($line->role ===
'toproduce'
188 && (
int) $line->fk_product === (
int)
$object->fk_product
189 && empty($line->qty_frozen)
190 && (
float) $line->qty != (
float)
$object->qty) {
191 $line->qty = (float)
$object->qty;
192 $line->update($user);
200 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->trans(
"Qty")),
null,
'errors');
202 header(
"Location: ".$_SERVER[
"PHP_SELF"].
"?id=".
$object->id);
207 include DOL_DOCUMENT_ROOT.
'/core/actions_addupdatedelete.inc.php';
210 include DOL_DOCUMENT_ROOT.
'/core/actions_dellink.inc.php';
213 include DOL_DOCUMENT_ROOT.
'/core/actions_printing.inc.php';
216 $triggersendname =
'MO_SENTBYMAIL';
217 $autocopy =
'MAIN_MAIL_AUTOCOPY_MO_TO';
218 $trackid =
'mo'.$object->id;
219 include DOL_DOCUMENT_ROOT.
'/core/actions_sendmails.inc.php';
224 if ($action ==
'set_thirdparty' && $permissiontoadd) {
225 $object->setValueFrom(
'fk_soc',
GETPOSTINT(
'fk_soc'),
'',
null,
'date',
'', $user, $triggermodname);
227 if ($action ==
'classin' && $permissiontoadd) {
231 if ($action ==
'confirm_reopen' && $permissiontoadd &&
$object->status == $object::STATUS_PRODUCED) {
232 $result =
$object->setStatut($object::STATUS_INPROGRESS, 0,
'',
'MRP_REOPEN');
235 if (($action ==
'confirm_addconsumeline' &&
GETPOST(
'addconsumelinebutton') && $permissiontoadd)
236 || ($action ==
'confirm_addproduceline' &&
GETPOST(
'addproducelinebutton') && $permissiontoadd)) {
237 $moline =
new MoLine($db);
242 $moline->fk_product =
GETPOSTINT(
'productidtoadd');
243 if (
GETPOST(
'addconsumelinebutton')) {
244 $moline->role =
'toconsume';
246 $moline->role =
'toproduce';
248 $moline->origin_type =
'free';
249 $moline->position = 0;
252 if (!empty($moline->fk_product)) {
253 $tmpproduct =
new Product($db);
254 $tmpproduct->fetch($moline->fk_product);
256 $moline->fk_default_workstation = $tmpproduct->fk_default_workstation;
257 $moline->disable_stock_change = 1;
258 if ($tmpproduct->duration_unit) {
259 $moline->qty = $tmpproduct->duration_value;
260 include_once DOL_DOCUMENT_ROOT.
'/core/class/cunits.class.php';
261 $cunits =
new CUnits($db);
262 $res = $cunits->fetch(0,
'', $tmpproduct->duration_unit,
'time');
264 $moline->fk_unit = $cunits->id;
268 $moline->disable_stock_change = 0;
270 $moline->fk_unit = $tmpproduct->fk_unit;
275 $extralabelsline = $extrafields->fetch_name_optionals_label(
$object->table_element_line);
276 $array_options = $extrafields->getOptionalsFromPost(
$object->table_element_line);
278 if (is_array($extralabelsline)) {
280 foreach ($extralabelsline as $key => $value) {
281 unset($_POST[
"options_".$key]);
284 if (is_array($array_options) && count($array_options) > 0) {
285 $moline->array_options = $array_options;
288 $resultline = $moline->create($user, 0);
289 if ($resultline <= 0) {
296 header(
"Location: ".$_SERVER[
"PHP_SELF"].
'?id='.
$object->id);
301 if (in_array($action, array(
'confirm_consumeorproduce',
'confirm_consumeandproduceall')) &&
$object->status != $object::STATUS_VALIDATED &&
$object->status != $object::STATUS_INPROGRESS) {
302 $langs->load(
"errors");
307 if (in_array($action, array(
'confirm_consumeorproduce',
'confirm_consumeandproduceall')) && $permissiontoproduce) {
310 $labelmovement =
GETPOST(
'inventorylabel',
'alphanohtml');
311 $codemovement =
GETPOST(
'inventorycode',
'alphanohtml');
316 foreach (
$object->lines as $line) {
317 if ($line->role ==
'toconsume') {
318 $tmpproduct =
new Product($db);
319 $tmpproduct->fetch($line->fk_product);
322 while (GETPOSTISSET(
'qty-'.$line->id.
'-'.$i)) {
325 if ($qtytoprocess != 0) {
327 if (GETPOSTISSET(
'idwarehouse-'.$line->id.
'-'.$i)) {
328 if (!(
GETPOST(
'idwarehouse-'.$line->id.
'-'.$i) > 0)) {
329 $langs->load(
"errors");
330 setEventMessages($langs->trans(
"ErrorFieldRequiredForProduct", $langs->transnoentitiesnoconv(
"Warehouse"), $tmpproduct->ref),
null,
'errors');
333 if (
isModEnabled(
'productbatch') && $tmpproduct->status_batch && (!
GETPOST(
'batch-'.$line->id.
'-'.$i))) {
334 $langs->load(
"errors");
335 setEventMessages($langs->trans(
"ErrorFieldRequiredForProduct", $langs->transnoentitiesnoconv(
"Batch"), $tmpproduct->ref),
null,
'errors');
341 if (!$error &&
GETPOST(
'idwarehouse-'.$line->id.
'-'.$i) > 0) {
343 $id_product_batch = 0;
345 $stockmove->context[
'mrp_role'] =
'toconsume';
347 if ($qtytoprocess >= 0) {
348 $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);
350 $idstockmove = $stockmove->reception($user, $line->fk_product,
GETPOSTINT(
'idwarehouse-'.$line->id.
'-'.$i), $qtytoprocess * -1, 0, $labelmovement,
'',
'',
GETPOST(
'batch-'.$line->id.
'-'.$i),
dol_now(), $id_product_batch, $codemovement);
352 if ($idstockmove < 0) {
360 $moline =
new MoLine($db);
362 $moline->position = $pos;
363 $moline->fk_product = $line->fk_product;
364 $moline->fk_warehouse =
GETPOSTINT(
'idwarehouse-'.$line->id.
'-'.$i);
365 $moline->qty = $qtytoprocess;
366 $moline->batch =
GETPOST(
'batch-'.$line->id.
'-'.$i);
367 $moline->role =
'consumed';
368 $moline->fk_mrp_production = $line->id;
369 $moline->fk_stock_movement = $idstockmove == 0 ? null : $idstockmove;
370 $moline->fk_user_creat = $user->id;
372 $resultmoline = $moline->create($user);
373 if ($resultmoline <= 0) {
390 foreach (
$object->lines as $line) {
391 if ($line->role ==
'toproduce') {
392 $tmpproduct =
new Product($db);
393 $tmpproduct->fetch($line->fk_product);
396 while (GETPOSTISSET(
'qtytoproduce-'.$line->id.
'-'.$i)) {
397 $qtytoprocess = (float)
price2num(
GETPOST(
'qtytoproduce-'.$line->id.
'-'.$i));
398 $pricetoprocess =
GETPOST(
'pricetoproduce-'.$line->id.
'-'.$i) ?
price2num(
GETPOST(
'pricetoproduce-'.$line->id.
'-'.$i)) : 0;
400 if ($qtytoprocess != 0) {
402 if (GETPOSTISSET(
'idwarehousetoproduce-'.$line->id.
'-'.$i)) {
403 if (!(
GETPOST(
'idwarehousetoproduce-'.$line->id.
'-'.$i) > 0)) {
404 $langs->load(
"errors");
405 setEventMessages($langs->trans(
"ErrorFieldRequiredForProduct", $langs->transnoentitiesnoconv(
"Warehouse"), $tmpproduct->ref),
null,
'errors');
408 if (
isModEnabled(
'productbatch') && $tmpproduct->status_batch && (!
GETPOST(
'batchtoproduce-'.$line->id.
'-'.$i))) {
409 $langs->load(
"errors");
410 setEventMessages($langs->trans(
"ErrorFieldRequiredForProduct", $langs->transnoentitiesnoconv(
"Batch"), $tmpproduct->ref),
null,
'errors');
416 if (!$error &&
GETPOST(
'idwarehousetoproduce-'.$line->id.
'-'.$i) > 0) {
418 $id_product_batch = 0;
419 $stockmove->origin_type =
$object->element;
420 $stockmove->origin_id =
$object->id;
421 $stockmove->context[
'mrp_role'] =
'toproduce';
423 $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);
424 if ($idstockmove < 0) {
432 $moline =
new MoLine($db);
434 $moline->position = $pos;
435 $moline->fk_product = $line->fk_product;
436 $moline->fk_warehouse =
GETPOSTINT(
'idwarehousetoproduce-'.$line->id.
'-'.$i);
437 $moline->qty = $qtytoprocess;
438 $moline->batch =
GETPOST(
'batchtoproduce-'.$line->id.
'-'.$i);
439 $moline->role =
'produced';
440 $moline->fk_mrp_production = $line->id;
441 $moline->fk_stock_movement = (($idstockmove == 0) ?
null : $idstockmove);
442 $moline->fk_user_creat = $user->id;
444 $resultmoline = $moline->create($user);
445 if ($resultmoline <= 0) {
460 $consumptioncomplete =
true;
461 $productioncomplete =
true;
464 foreach (
$object->lines as $line) {
465 $tmpproduct =
new Product($db);
466 $tmpproduct->fetch($line->fk_product);
467 if ((
int) $tmpproduct->stockable_product > 0) {
468 if ($line->role ==
'toconsume') {
469 $arrayoflines =
$object->fetchLinesLinked(
'consumed', $line->id);
470 $alreadyconsumed = 0;
471 foreach ($arrayoflines as $line2) {
472 $alreadyconsumed += $line2[
'qty'];
475 if ($alreadyconsumed < $line->qty) {
476 $consumptioncomplete =
false;
479 if ($line->role ==
'toproduce') {
480 $arrayoflines =
$object->fetchLinesLinked(
'produced', $line->id);
481 $alreadyproduced = 0;
482 foreach ($arrayoflines as $line2) {
483 $alreadyproduced += $line2[
'qty'];
486 if ($alreadyproduced < $line->qty) {
487 $productioncomplete =
false;
493 $consumptioncomplete =
false;
494 $productioncomplete =
false;
498 dol_syslog(
"consumptioncomplete = ".json_encode($consumptioncomplete).
" productioncomplete = ".json_encode($productioncomplete));
499 if ($consumptioncomplete && $productioncomplete) {
500 $result =
$object->setStatut($object::STATUS_PRODUCED, 0,
'',
'MRP_MO_PRODUCED');
502 $result =
$object->setStatut($object::STATUS_INPROGRESS, 0,
'',
'MRP_MO_PRODUCED');
511 $action = str_replace(
'confirm_',
'', $action);
517 header(
"Location: ".$_SERVER[
"PHP_SELF"].
'?id='.
$object->id);
523 if ($action ==
'confirm_produced' && $confirm ==
'yes' && $permissiontoadd) {
524 $result =
$object->setStatut($object::STATUS_PRODUCED, 0,
'',
'MRP_MO_PRODUCED');
528 $outputlangs = $langs;
531 $newlang =
GETPOST(
'lang_id',
'aZ09');
534 $newlang =
$object->thirdparty->default_lang;
536 if (!empty($newlang)) {
538 $outputlangs->setDefaultLang($newlang);
543 $object->generateDocument($model, $outputlangs, 0, 0, 0);
550 if ($action ==
'confirm_editline' && $permissiontoadd && !in_array(
$object->status, array($object::STATUS_PRODUCED, $object::STATUS_CANCELED))) {
551 $moline =
new MoLine($db);
552 $result = $moline->fetch(
GETPOSTINT(
'lineid'));
553 if ($result > 0 && $moline->fk_mo !=
$object->id) {
556 if ($result > 0 && in_array($moline->role, array(
'consumed',
'produced'))) {
560 $extrafields->fetch_name_optionals_label($moline->table_element);
561 if (!empty($extrafields->attributes[$moline->table_element][
'label'])) {
562 foreach ($extrafields->attributes[$moline->table_element][
'label'] as $key => $label) {
563 $value =
GETPOST(
'options_'.$key,
'alphanohtml');
564 $moline->array_options[
"options_".$key] = $value;
568 if (GETPOSTISSET(
'warehouse_lineProduce')) {
569 $moline->fk_warehouse = (
GETPOSTINT(
'warehouse_lineProduce') > 0 ?
GETPOSTINT(
'warehouse_lineProduce') : 0);
571 if (GETPOSTISSET(
'workstation_lineProduce')) {
572 $moline->fk_default_workstation = (
GETPOSTINT(
'workstation_lineProduce') > 0 ?
GETPOSTINT(
'workstation_lineProduce') : 0);
575 $res = $moline->update($user);
579 header(
"Location: ".$_SERVER[
"PHP_SELF"].
'?id='.
$object->id);
582 header(
"Location: ".$_SERVER[
"PHP_SELF"].
'?id='.
$object->id);
594$form =
new Form($db);
601$title = $langs->trans(
'Mo');
602$help_url =
'EN:Module_Manufacturing_Orders|FR:Module_Ordres_de_Fabrication|DE:Modul_Fertigungsauftrag';
603$morejs = array(
'/mrp/js/lib_dispatch.js.php');
604llxHeader(
'', $title, $help_url,
'', 0, 0, $morejs,
'',
'',
'mod-mrp page-card_production');
609if (
$object->id > 0 && (empty($action) || ($action !=
'edit' && $action !=
'create' && $action !=
'reload'))) {
610 $res =
$object->fetch_thirdparty();
611 $res =
$object->fetch_optionals();
614 $tmpwarehouse->fetch((
int)
$object->fk_warehouse);
615 $fk_default_warehouse = (int)
$object->fk_warehouse;
625 if ($action ==
'delete') {
626 $formquestion = array(
628 'label' => $langs->trans(
'MoCancelConsumedAndProducedLines'),
629 'name' =>
'alsoCancelConsumedAndProducedLines',
630 'type' =>
'checkbox',
634 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'DeleteMo'), $langs->trans(
'ConfirmDeleteMo'),
'confirm_delete', $formquestion, 0, 1);
637 if ($action ==
'deleteline') {
638 $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);
641 if ($action ==
'clone') {
643 $formquestion = array();
644 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'ToClone'), $langs->trans(
'ConfirmCloneMo',
$object->ref),
'confirm_clone', $formquestion,
'yes', 1);
648 if ($action ==
'validate') {
650 $ref = substr(
$object->ref, 1, 4);
651 if ($ref ==
'PROV') {
655 $numref = (string)
$object->ref;
658 $text = $langs->trans(
'ConfirmValidateMo', $numref);
667 $formquestion = array();
670 require_once DOL_DOCUMENT_ROOT.
'/product/class/html.formproduct.class.php';
673 if ($conf->browser->name ==
'ie') {
676 $formquestion = array(
683 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'Validate'), $text,
'confirm_validate', $formquestion, 0, 1, 220);
687 if ($action ==
'cancel') {
688 $formquestion = array(
690 'label' => $langs->trans(
'MoCancelConsumedAndProducedLines'),
691 'name' =>
'alsoCancelConsumedAndProducedLines',
692 'type' =>
'checkbox',
693 'value' => !
getDolGlobalString(
'MO_ALSO_CANCEL_CONSUMED_AND_PRODUCED_LINES_BY_DEFAULT') ? 0 : 1
696 $formconfirm = $form->formconfirm(
dolBuildUrl($_SERVER[
"PHP_SELF"], [
'id' =>
$object->id]), $langs->trans(
'CancelMo'), $langs->trans(
'ConfirmCancelMo'),
'confirm_cancel', $formquestion, 0, 1);
700 $parameters = array(
'formConfirm' => $formconfirm,
'lineid' => $lineid);
701 $reshook = $hookmanager->executeHooks(
'formConfirm', $parameters, $object, $action);
702 if (empty($reshook)) {
703 $formconfirm .= $hookmanager->resPrint;
704 } elseif ($reshook > 0) {
705 $formconfirm = $hookmanager->resPrint;
714 $linkback =
'<a href="'.DOL_URL_ROOT.
'/mrp/mo_list.php?restore_lastsearch_values=1'.(!empty($socid) ?
'&socid='.$socid :
'').
'">'.$langs->trans(
"BackToList").
'</a>';
716 $morehtmlref =
'<div class="refidno">';
725 if (is_object(
$object->thirdparty)) {
726 $morehtmlref .=
$object->thirdparty->getNomUrl(1,
'customer');
728 $morehtmlref .=
' (<a href="'.DOL_URL_ROOT.
'/commande/list.php?socid='.
$object->thirdparty->id.
'">'.$langs->trans(
"OtherOrders").
'</a>)';
734 $langs->load(
"projects");
735 if (is_object(
$object->thirdparty)) {
736 $morehtmlref .=
'<br>';
738 if ($permissiontoadd) {
739 $morehtmlref .=
img_picto($langs->trans(
"Project"),
'project',
'class="pictofixedwidth"');
740 if ($action !=
'classify') {
741 $morehtmlref .=
'<a class="editfielda" href="'.dolBuildUrl($_SERVER[
'PHP_SELF'], [
'action' =>
'classify',
'id' =>
$object->id],
true).
'">'.
img_edit($langs->transnoentitiesnoconv(
'SetProject')).
'</a> ';
743 $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');
745 if (!empty(
$object->fk_project)) {
747 $proj->fetch(
$object->fk_project);
748 $morehtmlref .= $proj->getNomUrl(1);
750 $morehtmlref .=
'<span class="opacitymedium"> - '.dol_escape_htmltag($proj->title).
'</span>';
755 $morehtmlref .=
'</div>';
758 dol_banner_tab($object,
'ref', $linkback, 1,
'ref',
'ref', $morehtmlref);
761 print
'<div class="fichecenter">';
762 print
'<div class="fichehalfleft">';
763 print
'<div class="underbanner clearboth"></div>';
764 print
'<table class="border centpercent tableforfield">'.
"\n";
767 $keyforbreak =
'fk_warehouse';
768 unset(
$object->fields[
'fk_project']);
769 unset(
$object->fields[
'fk_soc']);
775 if (
$object->status == Mo::STATUS_DRAFT && $permissiontoadd && isset(
$object->fields[
'qty'])) {
776 $object->fields[
'qty'][
'alwayseditable'] = 1;
777 if ($action ==
'editqty') {
778 $object->fields[
'qty'][
'type'] =
'numeric';
782 include DOL_DOCUMENT_ROOT.
'/core/tpl/commonfields_view.tpl.php';
785 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_view.tpl.php';
791 print
'<div class="clearboth"></div>';
796 if (!in_array($action, array(
'consumeorproduce',
'consumeandproduceall'))) {
797 print
'<div class="tabsAction">';
799 $parameters = array();
801 $reshook = $hookmanager->executeHooks(
'addMoreActionsButtons', $parameters, $object, $action);
802 if (empty($reshook)) {
804 if (
$object->status == $object::STATUS_DRAFT) {
805 if ($permissiontoadd) {
807 print
'<a class="butAction" href="'.$_SERVER[
'PHP_SELF'].
'?id='.
$object->id.
'&action=validate&token='.$newToken.
'">'.$langs->trans(
"Validate").
'</a>';
809 $langs->load(
"errors");
810 print
'<a class="butActionRefused" href="" title="'.$langs->trans(
"ErrorAddAtLeastOneLineFirst").
'">'.$langs->trans(
"Validate").
'</a>';
816 if (
$object->status == Mo::STATUS_VALIDATED ||
$object->status == Mo::STATUS_INPROGRESS) {
817 if ($permissiontoproduce) {
818 print
'<a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=consumeorproduce&token='.$newToken.
'">'.$langs->trans(
'ConsumeOrProduce').
'</a>';
820 print
'<a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans(
"NotEnoughPermissions").
'">'.$langs->trans(
'ConsumeOrProduce').
'</a>';
822 } elseif (
$object->status == Mo::STATUS_DRAFT) {
823 print
'<a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans(
"ValidateBefore").
'">'.$langs->trans(
'ConsumeOrProduce').
'</a>';
827 if (
$object->status == Mo::STATUS_VALIDATED ||
$object->status == Mo::STATUS_INPROGRESS) {
828 if ($permissiontoproduce) {
829 print
'<a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=consumeandproduceall&token='.$newToken.
'">'.$langs->trans(
'ConsumeAndProduceAll').
'</a>';
831 print
'<a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans(
"NotEnoughPermissions").
'">'.$langs->trans(
'ConsumeAndProduceAll').
'</a>';
833 } elseif (
$object->status == Mo::STATUS_DRAFT) {
834 print
'<a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans(
"ValidateBefore").
'">'.$langs->trans(
'ConsumeAndProduceAll').
'</a>';
838 if ($permissiontoadd) {
839 if (
$object->status == $object::STATUS_VALIDATED ||
$object->status == $object::STATUS_INPROGRESS) {
840 $arrayproduced =
$object->fetchLinesLinked(
'produced', 0);
842 foreach ($arrayproduced as $lineproduced) {
843 $nbProduced += $lineproduced[
'qty'];
845 if ($nbProduced > 0) {
846 print
'<a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=confirm_produced&confirm=yes&token='.$newToken.
'">'.$langs->trans(
"Close").
'</a>'.
"\n";
848 print
'<a class="butActionRefused" href="#" title="'.$langs->trans(
"GoOnTabProductionToProduceFirst", $langs->transnoentitiesnoconv(
"Production")).
'">'.$langs->trans(
"Close").
'</a>'.
"\n";
851 print
'<a class="butActionDelete" href="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=cancel&token='.$newToken.
'">'.$langs->trans(
"Cancel").
'</a>'.
"\n";
854 if (
$object->status == $object::STATUS_CANCELED) {
855 print
'<a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=confirm_reopen&confirm=yes&token='.$newToken.
'">'.$langs->trans(
"ReOpen").
'</a>'.
"\n";
858 if (
$object->status == $object::STATUS_PRODUCED) {
859 if ($permissiontoproduce) {
860 print
'<a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=confirm_reopen&token='.$newToken.
'">'.$langs->trans(
'ReOpen').
'</a>';
862 print
'<a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans(
"NotEnoughPermissions").
'">'.$langs->trans(
'ReOpen').
'</a>';
871 if (in_array($action, array(
'consumeorproduce',
'consumeandproduceall',
'addconsumeline',
'addproduceline',
'editline'))) {
872 print
'<!-- Form to enter value for consumption/production -->';
873 print
'<form method="POST" action="'.dolBuildUrl($_SERVER[
"PHP_SELF"]).
'">';
874 print
'<input type="hidden" name="token" value="'.newToken().
'">';
875 print
'<input type="hidden" name="action" value="confirm_'.$action.
'">';
876 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
877 print
'<input type="hidden" name="id" value="'.$id.
'">';
880 if (in_array($action, array(
'consumeorproduce',
'consumeandproduceall'))) {
881 $defaultstockmovementlabel =
GETPOST(
'inventorylabel',
'alphanohtml') ?
GETPOST(
'inventorylabel',
'alphanohtml') : $langs->trans(
"ProductionForRef",
$object->
ref);
884 print
'<div class="center'.(in_array($action, array(
'consumeorproduce',
'consumeandproduceall')) ?
' formconsumeproduce' :
'').
'">';
885 print
'<div class="opacitymedium hideonsmartphone paddingbottom marginbottomonly">'.$langs->trans(
"ConfirmProductionDesc", $langs->transnoentitiesnoconv(
"Confirm")).
'<br></div>';
886 print
'<span class="paddingright">'.$langs->trans(
"InventoryCode").
':</span>';
887 print
'<span class="clearbothonsmartphone"></span>';
888 print
'<input type="text" class="minwidth125 maxwidth150" name="inventorycode" value="'.$defaultstockmovementcode.
'">';
889 print
'<span class="hideonsmartphone"> </span>';
890 print
'<span class="clearbothonsmartphone"></span>';
891 print
'<span class="paddingright">'.$langs->trans(
"MovementLabel").
':</span>';
892 print
'<span class="clearbothonsmartphone"></span>';
893 print
'<input type="text" class="minwidth300" name="inventorylabel" value="'.$defaultstockmovementlabel.
'"><br><br>';
894 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>';
895 print
'<input type="submit" class="button margintoponly" value="'.$langs->trans(
"Confirm").
'" name="confirm">';
897 print
'<input class="button margintoponly button-cancel" type="submit" value="'.$langs->trans(
"Cancel").
'" name="cancel">';
911 if (!empty(
$object->table_element_line)) {
918 $res = $bom->fetch(
$object->fk_bom);
920 $bom->calculateCosts();
921 $bomcost = $bom->unit_cost;
927 print
'<!-- Lines to consume -->'.
"\n";
928 print
'<div class="fichecenter">';
929 print
'<div class="fichehalfleft">';
930 print
'<div class="clearboth"></div>';
932 $url = $_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=addconsumeline&token='.
newToken();
933 $permissiontoaddaconsumeline = (
$object->status != $object::STATUS_PRODUCED &&
$object->status != $object::STATUS_CANCELED) ? 1 : -2;
934 $parameters = array(
'morecss' =>
'reposition');
936 if ($permissiontoaddaconsumeline == -2) {
937 $helpText = $langs->trans(
'MOIsClosed');
941 if ($action !=
'consumeorproduce' && $action !=
'consumeandproduceall') {
942 $newcardbutton =
dolGetButtonTitle($langs->trans(
'AddNewConsumeLines'), $helpText,
'fa fa-plus-circle size15x', $url,
'', $permissiontoaddaconsumeline, $parameters);
945 print
load_fiche_titre($langs->trans(
'Consumption'), $newcardbutton,
'', 0,
'',
'',
'');
947 print
'<div class="div-table-responsive-no-min">';
948 print
'<table class="noborder noshadow centpercent nobottom">';
950 print
'<!-- Line of title for products to consume -->'.
"\n";
951 print
'<tr class="liste_titre trheight5em">';
953 print
'<td>'.$langs->trans(
"Product").
'</td>';
955 print
'<td class="right">'.$langs->trans(
"Qty").
'</td>';
960 print
'<td class="right">'.$langs->trans(
"UnitCost").
'</td>';
963 print
'<td class="right classfortooltip" title="'.$langs->trans(
"QtyAlreadyConsumed").
'">';
964 print $langs->trans(
"QtyAlreadyConsumedShort");
968 if ($collapse || in_array($action, array(
'consumeorproduce',
'consumeandproduceall'))) {
969 print $langs->trans(
"Warehouse");
971 print
' '.$langs->trans(
"or").
' '.$langs->trans(
"Workstation");
974 if (in_array($action, array(
'consumeorproduce',
'consumeandproduceall'))) {
975 $listwarehouses = $tmpwarehouse->list_array(1);
976 if (count($listwarehouses) > 1) {
977 print
'<br>'.$form->selectarray(
'fk_default_warehouse', $listwarehouses, $fk_default_warehouse, $langs->trans(
"ForceTo"), 0, 0,
'', 0, 0, 0,
'',
'minwidth100 maxwidth200', 1);
978 } elseif (count($listwarehouses) == 1) {
979 print
'<br>'.$form->selectarray(
'fk_default_warehouse', $listwarehouses, $fk_default_warehouse, 0, 0, 0,
'', 0, 0, 0,
'',
'minwidth100 maxwidth200', 1);
987 print
'<td align="right">';
988 if ($collapse || in_array($action, array(
'consumeorproduce',
'consumeandproduceall'))) {
989 print $langs->trans(
"Stock");
996 if ($collapse || in_array($action, array(
'consumeorproduce',
'consumeandproduceall'))) {
997 print $langs->trans(
"Batch");
1009 if (
$object->status == Mo::STATUS_DRAFT) {
1014 if ($permissiontodelete) {
1020 if ($action ==
'addconsumeline') {
1021 print
'<!-- Add line to consume -->'.
"\n";
1022 print
'<tr class="liste_titre">';
1025 print $form->select_produits(0,
'productidtoadd',
'', 0, 0, -1, 2,
'', 1, array(), 0,
'1', 0,
'maxwidth150');
1028 print
'<td class="right"><input type="text" name="qtytoadd" value="1" class="width40 right"></td>';
1036 if ($permissiontoupdatecost &&
getDolGlobalString(
'MRP_SHOW_COST_FOR_CONSUMPTION')) {
1048 print
'<td colspan="'.$colspan.
'">';
1049 print
'<input type="submit" class="button buttongen button-add" name="addconsumelinebutton" value="'.$langs->trans(
"Add").
'">';
1050 print
'<input type="submit" class="button buttongen button-cancel" name="canceladdconsumelinebutton" value="'.$langs->trans(
"Cancel").
'">';
1055 if (
$object->status == Mo::STATUS_DRAFT) {
1059 if ($permissiontodelete) {
1065 if (is_object($objectline)) {
1066 $extrafields->fetch_name_optionals_label(
$object->table_element_line);
1067 $temps = $objectline->showOptionals($extrafields,
'edit', array(),
'',
'',
'1',
'line');
1068 if (!empty($temps)) {
1069 print
'<tr class="liste_titre"><td style="padding-top: 20px" colspan="9" id="extrafield_lines_area_edit" name="extrafield_lines_area_edit">';
1078 $bomcostupdated = 0;
1081 $nblinetoconsume = 0;
1082 foreach (
$object->lines as $line) {
1083 if ($line->role ==
'toconsume') {
1088 $nblinetoconsumecursor = 0;
1089 foreach (
$object->lines as $line) {
1090 if ($line->role ==
'toconsume') {
1091 $nblinetoconsumecursor++;
1093 $tmpproduct =
new Product($db);
1094 $tmpproduct->fetch($line->fk_product);
1095 $linecost =
price2num($tmpproduct->pmp,
'MT');
1099 $costprice =
price2num((!empty($tmpproduct->cost_price)) ? $tmpproduct->cost_price : $tmpproduct->pmp);
1100 if (empty($costprice)) {
1101 require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.product.class.php';
1103 if ($productFournisseur->find_min_price_product_fournisseur($line->fk_product, $line->qty) > 0) {
1104 $costprice = $productFournisseur->fourn_unitprice;
1112 if ($useunit && $line->fk_unit > 0) {
1114 $qtyhourservice = 0;
1115 if (preg_match(
'/^(\d+)([a-z]+)$/', $tmpproduct->duration, $reg)) {
1118 $qtyhourforline = 0;
1119 if ($line->fk_unit) {
1125 if (
isModEnabled(
'workstation') && $line->fk_default_workstation > 0) {
1127 $workstation->fetch($line->fk_default_workstation);
1128 $linecost =
price2num($qtyhourforline * ($workstation->thm_operator_estimated + $workstation->thm_machine_estimated) /
$object->qty,
'MT');
1129 $bomcostupdated +=
price2num($qtyhourforline * ($workstation->thm_operator_estimated + $workstation->thm_machine_estimated) /
$object->qty,
'MU');
1130 } elseif ($qtyhourservice && $qtyhourforline) {
1131 $linecost =
price2num(($qtyhourforline / $qtyhourservice * $costprice) /
$object->qty,
'MT');
1132 $bomcostupdated +=
price2num(($qtyhourforline / $qtyhourservice * $costprice) /
$object->qty,
'MU');
1135 $bomcostupdated +=
price2num(($line->qty * $costprice) /
$object->qty,
'MU');
1139 $bomcostupdated +=
price2num(($line->qty * $costprice) /
$object->qty,
'MU');
1143 $bomcostupdated =
price2num($bomcostupdated,
'MU');
1144 $arrayoflines =
$object->fetchLinesLinked(
'consumed', $line->id);
1145 $alreadyconsumed = 0;
1146 foreach ($arrayoflines as $line2) {
1147 $alreadyconsumed += $line2[
'qty'];
1150 if ($action ==
'editline' && $lineid == $line->id) {
1151 $linecost =
price2num($tmpproduct->pmp,
'MT');
1153 $arrayoflines =
$object->fetchLinesLinked(
'consumed', $line->id);
1154 $alreadyconsumed = 0;
1155 if (is_array($arrayoflines) && !empty($arrayoflines)) {
1156 foreach ($arrayoflines as $line2) {
1157 $alreadyconsumed += $line2[
'qty'];
1160 $suffix =
'_' . $line->id;
1161 print
'<!-- Line to dispatch ' . $suffix .
' (line edited) -->' .
"\n";
1163 print
'<input id="qty_ordered' . $suffix .
'" type="hidden" value="' . $line->qty .
'">';
1165 print
'<input id="qty_dispatched' . $suffix .
'" type="hidden" value="' . $alreadyconsumed .
'">';
1167 print
'<input name="lineid" type="hidden" value="' . $line->id .
'">';
1170 print
'<td>' . $tmpproduct->getNomUrl(1);
1171 print
'<br><div class="opacitymedium small tdoverflowmax150" title="' .
dol_escape_htmltag($tmpproduct->label) .
'">' . $tmpproduct->label .
'</span>';
1175 print
'<td class="right nowraponall">';
1176 print
'<input class="width40 right" name="qty_lineProduce" value="'. $line->qty.
'">';
1180 print
'<td class="right nowraponall">';
1188 if ($permissiontoupdatecost &&
getDolGlobalString(
'MRP_SHOW_COST_FOR_CONSUMPTION')) {
1193 print
'<td class="right">';
1194 print
' ' .
price2num($alreadyconsumed,
'MS');
1200 print $formproduct->selectWarehouses($line->fk_warehouse,
'warehouse_lineProduce',
'warehouseopen', 1);
1202 print $formproduct->selectWorkstations($line->fk_default_workstation,
'workstation_lineProduce', 1);
1208 print
'<td class="nowraponall right">';
1209 if ($tmpproduct->isStockManaged()) {
1210 if ($tmpproduct->stock_reel < ($line->qty - $alreadyconsumed)) {
1211 print
img_warning($langs->trans(
'StockTooLow')).
' ';
1213 print
'<span class="left">'. $tmpproduct->stock_reel .
' </span>';
1223 print
'<td colspan="'.(3 + (
$object->status == Mo::STATUS_DRAFT ? 1 : 0) + ($permissiontodelete ? 1 : 0)).
'">';
1224 print
'<input type="submit" class="button buttongen button-add small nominwidth" name="save" value="' . $langs->trans(
"Save") .
'">';
1225 print
'<input type="submit" class="button buttongen button-cancel small nominwidth" name="cancel" value="' . $langs->trans(
"Cancel") .
'">';
1231 if (!empty($extrafields)) {
1232 $line->fetch_optionals();
1233 $temps = $line->showOptionals($extrafields,
'edit', array(),
'',
'',
'1',
'line');
1234 if (!empty($temps)) {
1236 print
'<tr><td colspan="'.$colspan.
'"><div style="padding-top: 20px" id="extrafield_lines_area_edit" name="extrafield_lines_area_edit">';
1238 print
'</div></td></tr>';
1242 $suffix =
'_' . $line->id;
1243 print
'<!-- Line to dispatch ' . $suffix .
' -->' .
"\n";
1245 print
'<input id="qty_ordered' . $suffix .
'" type="hidden" value="' . $line->qty .
'">';
1246 print
'<input id="qty_dispatched' . $suffix .
'" type="hidden" value="' . $alreadyconsumed .
'">';
1248 print
'<tr data-line-id="' . $line->id .
'">';
1251 print
'<td>' . $tmpproduct->getNomUrl(1);
1252 print
'<br><div class="opacitymedium small tdoverflowmax150" title="' .
dol_escape_htmltag($tmpproduct->label) .
'">' . $tmpproduct->label .
'</div>';
1256 print
'<td class="right nowraponall">';
1258 if ($line->qty_frozen) {
1259 $help = ($help ?
'<br>' :
'') .
'<strong>' . $langs->trans(
"QuantityFrozen") .
'</strong>: ' .
yn(1) .
' (' . $langs->trans(
"QuantityConsumedInvariable") .
')';
1260 print $form->textwithpicto(
'', $help, -1,
'lock') .
' ';
1262 if ($line->disable_stock_change) {
1263 $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")) .
')';
1264 print $form->textwithpicto(
'', $help, -1,
'help') .
' ';
1270 print
'<td class="right nowraponall">';
1278 if ($permissiontoupdatecost &&
getDolGlobalString(
'MRP_SHOW_COST_FOR_CONSUMPTION')) {
1279 print
'<td class="right nowraponall">';
1280 print
price($linecost);
1285 print
'<td class="right">';
1286 if ($alreadyconsumed) {
1288 print
'jQuery(document).ready(function() {
1289 jQuery("#expandtoproduce' . $line->id .
'").click(function() {
1290 console.log("Expand mrp_production line ' . $line->id .
'");
1291 jQuery(".expanddetail' . $line->id .
'").toggle();';
1292 if ($nblinetoconsume == $nblinetoconsumecursor) {
1293 print
'if (jQuery("#tablelines").hasClass("nobottom")) { jQuery("#tablelines").removeClass("nobottom"); } else { jQuery("#tablelines").addClass("nobottom"); }';
1299 if (empty($conf->use_javascript_ajax)) {
1300 print
'<a href="' . $_SERVER[
"PHP_SELF"] .
'?collapse=' . $collapse .
',' . $line->id .
'">';
1302 print
img_picto($langs->trans(
"ShowDetails"),
"chevron-down",
'id="expandtoproduce' . $line->id .
'"');
1303 if (empty($conf->use_javascript_ajax)) {
1307 if ($nblinetoconsume == $nblinetoconsumecursor) {
1308 print
'<script>jQuery("#tablelines").removeClass("nobottom");</script>';
1311 print
' ' .
price2num($alreadyconsumed,
'MS');
1315 print
'<td class="tdoverflowmax100">';
1316 if ($tmpproduct->isStockManaged()) {
1318 if (
getDolGlobalString(
'STOCK_CONSUMPTION_FROM_MANUFACTURING_WAREHOUSE') && $tmpwarehouse->id > 0) {
1319 print
img_picto(
'', $tmpwarehouse->picto) .
" " . $tmpwarehouse->label;
1321 if ($line->fk_warehouse > 0) {
1322 $warehouseline =
new Entrepot($db);
1323 $warehouseline->fetch($line->fk_warehouse);
1324 print $warehouseline->getNomUrl(1);
1328 if (
isModEnabled(
'workstation') && $line->fk_default_workstation > 0) {
1330 $tmpworkstation->fetch($line->fk_default_workstation);
1331 print $tmpworkstation->getNomUrl(1);
1337 print
'<td class="nowraponall right">';
1339 if (!$line->disable_stock_change && $tmpproduct->stock_reel < ($line->qty - $alreadyconsumed)) {
1340 print
img_warning($langs->trans(
'StockTooLow')) .
' ';
1342 if (!
getDolGlobalString(
'STOCK_CONSUMPTION_FROM_MANUFACTURING_WAREHOUSE') || empty($tmpwarehouse->id)) {
1343 print
price2num($tmpproduct->stock_reel,
'MS');
1346 $tmpproduct->load_stock();
1347 $wh_stock = $tmpproduct->stock_warehouse[$tmpwarehouse->id];
1348 if (!empty($wh_stock)) {
1370 if (
$object->status == Mo::STATUS_DRAFT) {
1371 $href = $_SERVER[
"PHP_SELF"] .
'?id=' . ((int)
$object->id) .
'&action=editline&token=' .
newToken() .
'&lineid=' . ((int) $line->id);
1372 print
'<td class="center">';
1373 print
'<a class="reposition editfielda" href="' . $href .
'">';
1374 print
img_picto($langs->trans(
'TooltipEditAndRevertStockMovement'),
'edit');
1380 if ($permissiontodelete && empty($arrayoflines)) {
1381 $href = $_SERVER[
"PHP_SELF"] .
'?id=' . ((int)
$object->id) .
'&action=deleteline&token=' .
newToken() .
'&lineid=' . ((int) $line->id);
1382 print
'<td class="center">';
1383 print
'<a class="reposition" href="' . $href .
'">';
1384 print
img_picto($langs->trans(
'TooltipDeleteAndRevertStockMovement'),
'delete');
1392 if (!empty($extrafields)) {
1393 $line->fetch_optionals();
1394 $temps = $line->showOptionals($extrafields,
'view', array(),
'',
'',
'1',
'line');
1395 if (!empty($temps)) {
1397 print
'<tr><td colspan="'.$colspan.
'"><div id="extrafield_lines_area_'.$line->id.
'" name="extrafield_lines_area_'.$line->id.
'">';
1399 print
'</div></td></tr>';
1405 foreach ($arrayoflines as $line2) {
1406 print
'<tr class="expanddetail'.$line->id.
' hideobject opacitylow">';
1410 $tmpstockmovement->id = $line2[
'fk_stock_movement'];
1411 print
'<a href="'.DOL_URL_ROOT.
'/product/stock/movement_list.php?search_ref='.$tmpstockmovement->id.
'">'.
img_picto($langs->trans(
"StockMovement"),
'movement',
'class="paddingright"').
'</a>';
1422 if ($permissiontoupdatecost &&
getDolGlobalString(
'MRP_SHOW_COST_FOR_CONSUMPTION')) {
1427 print
'<td class="right">'.$line2[
'qty'].
'</td>';
1430 print
'<td class="tdoverflowmax150">';
1431 if ($line2[
'fk_warehouse'] > 0) {
1432 $result = $tmpwarehouse->fetch($line2[
'fk_warehouse']);
1434 print $tmpwarehouse->getNomUrl(1);
1447 if ($line2[
'batch'] !=
'') {
1448 $tmpbatch->fetch(0, $line2[
'fk_product'], $line2[
'batch']);
1449 print $tmpbatch->getNomUrl(1);
1461 if (
$object->status == Mo::STATUS_DRAFT) {
1462 $href = $_SERVER[
"PHP_SELF"] .
'?id=' . ((int)
$object->id) .
'&action=editline&token=' .
newToken() .
'&lineid=' . ((int) $line2[
'rowid']);
1463 print
'<td class="center">';
1464 print
'<a class="reposition" href="' . $href .
'">';
1465 print
img_picto($langs->trans(
'TooltipEditAndRevertStockMovement'),
'edit');
1471 if ($permissiontodelete) {
1472 $href = $_SERVER[
"PHP_SELF"].
'?id='.((int)
$object->id).
'&action=deleteline&token='.
newToken().
'&lineid='.((int) $line2[
'rowid']).
'&fk_movement='.((int) $line2[
'fk_stock_movement']);
1473 print
'<td class="center">';
1474 print
'<a class="reposition" href="'.$href.
'">';
1475 print
img_picto($langs->trans(
'TooltipDeleteAndRevertStockMovement'),
'delete');
1483 if (in_array($action, array(
'consumeorproduce',
'consumeandproduceall'))) {
1485 print
'<!-- Enter line to consume -->'.
"\n";
1487 print
'<tr data-max-qty="'.$maxQty.
'" name="batch_'.$line->id.
'_'.$i.
'">';
1489 print
'<td><span class="opacitymedium">'.$langs->trans(
"ToConsume").
'</span></td>';
1490 $preselected = (GETPOSTISSET(
'qty-'.$line->id.
'-'.$i) ?
GETPOST(
'qty-'.$line->id.
'-'.$i) : max(0, $line->qty - $alreadyconsumed));
1491 if ($action ==
'consumeorproduce' && !
getDolGlobalString(
'MRP_AUTO_SET_REMAINING_QUANTITIES_TO_BE_CONSUMED') && !GETPOSTISSET(
'qty-'.$line->id.
'-'.$i)) {
1496 if (
getDolGlobalString(
'MRP_NEVER_CONSUME_MORE_THAN_EXPECTED') && ($line->qty - $alreadyconsumed) <= 0) {
1497 $disable =
'disabled';
1501 print
'<input type="hidden" name="product-'.$line->id.
'-'.$i.
'" value="'.$line->fk_product.
'">';
1504 print
'<td class="right">';
1505 if ((
int) $tmpproduct->stockable_product > 0) {
1506 print
'<input type="text" class="width50 right" id="qtytoconsume-' . $line->id .
'-' . $i .
'" name="qty-' . $line->id .
'-' . $i .
'" value="' . $preselected .
'" ' . $disable .
'>';
1508 print
'<input type="hidden" id="qtytoconsume-' . $line->id .
'-' . $i .
'" name="qty-' . $line->id .
'-' . $i .
'" value="0">';
1509 print
'<span class="opacitymedium">' . $langs->trans(
"StockDisabled") .
'</span>';
1517 if ($permissiontoupdatecost &&
getDolGlobalString(
'MRP_SHOW_COST_FOR_CONSUMPTION')) {
1527 && ((
int) $tmpproduct->stockable_product > 0)) {
1528 if (empty($line->disable_stock_change)) {
1529 $preselected = (GETPOSTISSET(
'idwarehouse-'.$line->id.
'-'.$i) ?
GETPOST(
'idwarehouse-'.$line->id.
'-'.$i) : ($tmpproduct->fk_default_warehouse > 0 ? $tmpproduct->fk_default_warehouse :
'ifone'));
1530 print $formproduct->selectWarehouses($preselected,
'idwarehouse-'.$line->id.
'-'.$i,
'', 1, 0, $line->fk_product,
'', 1, 0, array(),
'maxwidth200 csswarehouse_'.$line->id.
'_'.$i);
1532 print
'<span class="opacitymedium">'.$langs->trans(
"DisableStockChange").
'</span>';
1535 if ((
int) $tmpproduct->stockable_product > 0) {
1536 print
'<span class="opacitymedium">' . $langs->trans(
"StockDisabled") .
'</span>';
1538 print
'<span class="opacitymedium">' . $langs->trans(
"NoStockChangeOnServices") .
'</span>';
1550 print
'<td class="nowraponall">';
1551 if ($tmpproduct->status_batch) {
1552 $preselected = (GETPOSTISSET(
'batch-'.$line->id.
'-'.$i) ?
GETPOST(
'batch-'.$line->id.
'-'.$i) :
'');
1553 print
'<input type="text" class="width75" name="batch-'.$line->id.
'-'.$i.
'" value="'.$preselected.
'" list="batch-'.$line->id.
'-'.$i.
'">';
1554 print $formproduct->selectLotDataList(
'batch-'.$line->id.
'-'.$i, 0, $line->fk_product, 0, array());
1561 print
'<td align="right" class="split">';
1562 print
' '.img_picto($langs->trans(
'AddStockLocationLine'),
'split',
'class="splitbutton" onClick="addDispatchLine('.((int) $line->id).
', \''.
dol_escape_js($type).
'\', \
'qtymissingconsume\', 1)"');
1566 print
'<td align="right" class="splitall">';
1567 if (($action ==
'consumeorproduce' || $action ==
'consumeandproduceall') && $tmpproduct->status_batch == 2) {
1568 print
img_picto($langs->trans(
'SplitAllQuantity'),
'split',
'class="splitbutton splitallbutton field-error-icon" data-max-qty="1" onClick="addDispatchLine('.$line->id.
', \'batch\', \'allmissingconsume\', 1)"');
1573 if (
$object->status == Mo::STATUS_DRAFT) {
1578 if ($permissiontodelete) {
1592 print
'<script type="text/javascript">
1593 $(document).ready(function () {
1594 $("select[name=fk_default_warehouse]").change(function() {
1595 var fk_default_warehouse = $("option:selected", this).val();
1596 $("select[name^=idwarehouse-]").val(fk_default_warehouse).change();
1601 if (in_array($action, array(
'consumeorproduce',
'consumeandproduceall')) &&
1603 print
'<script>$(document).ready(function () {
1604 $("#fk_default_warehouse").change();
1612 print
'<div class="fichehalfright">';
1613 print
'<div class="clearboth"></div>';
1615 $nblinetoproduce = 0;
1616 $atLeastOneEatBy =
false;
1617 $atLeastOneSellBy =
false;
1618 foreach (
$object->lines as $line) {
1619 if ($line->role ==
'toproduce') {
1620 $tmpproduct =
new Product($db);
1621 $tmpproduct->fetch($line->fk_product);
1623 $tmpproduct->sell_or_eat_by_mandatory == $tmpproduct::SELL_OR_EAT_BY_MANDATORY_ID_EAT_BY
1624 || $tmpproduct->sell_or_eat_by_mandatory == $tmpproduct::SELL_OR_EAT_BY_MANDATORY_ID_SELL_AND_EAT
1626 $atLeastOneEatBy =
true;
1629 $tmpproduct->sell_or_eat_by_mandatory == $tmpproduct::SELL_OR_EAT_BY_MANDATORY_ID_SELL_BY
1630 || $tmpproduct->sell_or_eat_by_mandatory == $tmpproduct::SELL_OR_EAT_BY_MANDATORY_ID_SELL_AND_EAT
1632 $atLeastOneSellBy =
true;
1638 $newcardbutton =
'';
1639 $url = $_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=addproduceline&token='.
newToken();
1640 $permissiontoaddaproductline =
$object->status != $object::STATUS_PRODUCED &&
$object->status != $object::STATUS_CANCELED;
1641 $parameters = array(
'morecss' =>
'reposition');
1642 if ($action !=
'consumeorproduce' && $action !=
'consumeandproduceall') {
1643 if ($nblinetoproduce == 0 ||
$object->mrptype == 1) {
1644 $newcardbutton =
dolGetButtonTitle($langs->trans(
'AddNewProduceLines'),
'',
'fa fa-plus-circle size15x', $url,
'', (
int) $permissiontoaddaproductline, $parameters);
1648 print
load_fiche_titre($langs->trans(
'Production'), $newcardbutton,
'', 0,
'',
'');
1650 print
'<div class="div-table-responsive-no-min">';
1651 print
'<table id="tablelinestoproduce" class="noborder noshadow nobottom centpercent">';
1653 print
'<tr class="liste_titre trheight5em">';
1655 print
'<td>'.$langs->trans(
"Product").
'</td>';
1657 print
'<td class="right">'.$langs->trans(
"Qty").
'</td>';
1660 print
'<td class="right">'.$langs->trans(
"Unit").
'</td>';
1663 if ($permissiontoupdatecost) {
1664 if (empty($bomcostupdated)) {
1665 print
'<td class="right classfortooltip" title="'.$langs->trans(
"AmountUsedToUpdateWAP").
'">';
1666 print $langs->trans(
"UnitCost");
1669 print
'<td class="right classfortooltip" title="'.$langs->trans(
"AmountUsedToUpdateWAP").
'">';
1670 print $langs->trans(
"ManufacturingPrice");
1675 print
'<td class="right classfortooltip" title="'.$langs->trans(
"QtyAlreadyProduced").
'">';
1676 print $langs->trans(
"QtyAlreadyProducedShort");
1680 if ($collapse || in_array($action, array(
'consumeorproduce',
'consumeandproduceall'))) {
1681 print $langs->trans(
"Warehouse");
1688 if ($collapse || in_array($action, array(
'consumeorproduce',
'consumeandproduceall'))) {
1689 print $langs->trans(
"Batch");
1700 if ($atLeastOneEatBy) {
1701 print
'<td>'.$langs->trans(
"EatByDate").
'</td>';
1705 if ($atLeastOneSellBy) {
1706 print
'<td>'.$langs->trans(
"SellByDate").
'</td>';
1711 if ($permissiontodelete) {
1717 if ($action ==
'addproduceline') {
1718 print
'<!-- Add line to produce -->'.
"\n";
1719 print
'<tr class="liste_titre">';
1723 print $form->select_produits(0,
'productidtoadd',
'', 0, 0, -1, 2,
'', 1, array(), 0,
'1', 0,
'maxwidth300');
1726 print
'<td class="right"><input type="text" name="qtytoadd" value="1" class="width50 right"></td>';
1732 if ($permissiontoupdatecost) {
1736 print
'<td colspan="2">';
1737 print
'<input type="submit" class="button buttongen button-add" name="addproducelinebutton" value="'.$langs->trans(
"Add").
'">';
1738 print
'<input type="submit" class="button buttongen button-cancel" name="canceladdproducelinebutton" value="'.$langs->trans(
"Cancel").
'">';
1751 if ($permissiontodelete) {
1758 $nblinetoproduce = 0;
1759 foreach (
$object->lines as $line) {
1760 if ($line->role ==
'toproduce') {
1765 $nblinetoproducecursor = 0;
1766 foreach (
$object->lines as $line) {
1767 if ($line->role ==
'toproduce') {
1770 $nblinetoproducecursor++;
1772 $tmpproduct =
new Product($db);
1773 $tmpproduct->fetch($line->fk_product);
1775 $arrayoflines =
$object->fetchLinesLinked(
'produced', $line->id);
1776 $alreadyproduced = 0;
1777 foreach ($arrayoflines as $line2) {
1778 $alreadyproduced += $line2[
'qty'];
1781 $suffix =
'_'.$line->id;
1782 print
'<!-- Line to dispatch '.$suffix.
' (toproduce) -->'.
"\n";
1784 print
'<input id="qty_ordered'.$suffix.
'" type="hidden" value="'.$line->qty.
'">';
1785 print
'<input id="qty_dispatched'.$suffix.
'" type="hidden" value="'.$alreadyproduced.
'">';
1789 print
'<td>'.$tmpproduct->getNomUrl(1);
1790 print
'<br><span class="opacitymedium small">'.$tmpproduct->label.
'</span>';
1793 print
'<td class="right">'.$line->qty.
'</td>';
1796 print
'<td class="right">'.measuringUnitString($line->fk_unit,
'',
null, 1).
'</td>';
1799 if ($permissiontoupdatecost) {
1801 $manufacturingcost = 0;
1802 $manufacturingcostsrc =
'';
1804 $manufacturingcost = $bomcostupdated;
1805 $manufacturingcostsrc = $langs->trans(
"CalculatedFromProductsToConsume");
1806 if (empty($manufacturingcost)) {
1807 $manufacturingcost = $bomcost;
1808 $manufacturingcostsrc = $langs->trans(
"ValueFromBom");
1810 if (empty($manufacturingcost)) {
1811 $manufacturingcost =
price2num($tmpproduct->cost_price,
'MU');
1812 $manufacturingcostsrc = $langs->trans(
"CostPrice");
1814 if (empty($manufacturingcost)) {
1815 $manufacturingcost =
price2num($tmpproduct->pmp,
'MU');
1816 $manufacturingcostsrc = $langs->trans(
"PMPValue");
1820 print
'<td class="right nowraponall" title="'.dol_escape_htmltag($manufacturingcostsrc).
'">';
1821 if ($manufacturingcost) {
1822 print
price($manufacturingcost);
1827 print
'<td class="right nowraponall">';
1828 if ($alreadyproduced) {
1830 print
'jQuery(document).ready(function() {
1831 jQuery("#expandtoproduce'.$line->id.
'").click(function() {
1832 console.log("Expand mrp_production line '.$line->id.
'");
1833 jQuery(".expanddetailtoproduce'.$line->id.
'").toggle();';
1834 if ($nblinetoproduce == $nblinetoproducecursor) {
1835 print
'if (jQuery("#tablelinestoproduce").hasClass("nobottom")) { jQuery("#tablelinestoproduce").removeClass("nobottom"); } else { jQuery("#tablelinestoproduce").addClass("nobottom"); }';
1841 if (empty($conf->use_javascript_ajax)) {
1842 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?collapse='.$collapse.
','.$line->id.
'">';
1844 print
img_picto($langs->trans(
"ShowDetails"),
"chevron-down",
'id="expandtoproduce'.$line->id.
'"');
1845 if (empty($conf->use_javascript_ajax)) {
1849 print
' '.$alreadyproduced;
1865 if ($permissiontodelete) {
1866 if ($line->origin_type ==
'free' && empty($arrayoflines)) {
1867 $href = $_SERVER[
"PHP_SELF"];
1868 $href .=
'?id='.$object->id;
1869 $href .=
'&action=deleteline';
1870 $href .=
'&token='.newToken();
1871 $href .=
'&lineid='.$line->id;
1872 print
'<td class="center">';
1873 print
'<a class="reposition" href="'.$href.
'">';
1874 print
img_picto($langs->trans(
'TooltipDeleteAndRevertStockMovement'),
"delete");
1884 foreach ($arrayoflines as $line2) {
1885 print
'<tr class="expanddetailtoproduce'.$line->id.
' hideobject opacitylow">';
1888 $tmpstockmovement->id = $line2[
'fk_stock_movement'];
1889 print
'<a href="'.DOL_URL_ROOT.
'/product/stock/movement_list.php?search_ref='.$tmpstockmovement->id.
'">'.
img_picto($langs->trans(
"StockMovement"),
'movement',
'class="paddingright"').
'</a>';
1899 if ($permissiontoupdatecost) {
1903 print
'<td class="right">'.$line2[
'qty'].
'</td>';
1905 print
'<td class="tdoverflowmax150">';
1906 if ($line2[
'fk_warehouse'] > 0) {
1907 $result = $tmpwarehouse->fetch($line2[
'fk_warehouse']);
1909 print $tmpwarehouse->getNomUrl(1);
1916 if ($line2[
'batch'] !=
'') {
1917 $tmpbatch->fetch(0, $line2[
'fk_product'], $line2[
'batch']);
1918 print $tmpbatch->getNomUrl(1);
1929 if ($permissiontodelete) {
1935 if (in_array($action, array(
'consumeorproduce',
'consumeandproduceall'))) {
1936 print
'<!-- Enter line to produce -->'.
"\n";
1938 print
'<tr data-max-qty="'.$maxQty.
'" name="batch_'.$line->id.
'_'.$i.
'">';
1940 print
'<td><span class="opacitymedium">'.$langs->trans(
"ToProduce").
'</span></td>';
1941 $preselected = (GETPOSTISSET(
'qtytoproduce-'.$line->id.
'-'.$i) ?
GETPOST(
'qtytoproduce-'.$line->id.
'-'.$i) : max(0, $line->qty - $alreadyproduced));
1942 if ($action ==
'consumeorproduce' && !GETPOSTISSET(
'qtytoproduce-'.$line->id.
'-'.$i)) {
1946 print
'<td class="right"><input type="text" class="width50 right" id="qtytoproduce-'.$line->id.
'-'.$i.
'" name="qtytoproduce-'.$line->id.
'-'.$i.
'" value="'.$preselected.
'"></td>';
1949 print
'<td class="right"></td>';
1952 if ($permissiontoupdatecost) {
1954 $manufacturingcost = 0;
1955 $manufacturingcostsrc =
'';
1957 $manufacturingcost = $bomcostupdated;
1958 $manufacturingcostsrc = $langs->trans(
"CalculatedFromProductsToConsume");
1959 if (empty($manufacturingcost)) {
1960 $manufacturingcost = $bomcost;
1961 $manufacturingcostsrc = $langs->trans(
"ValueFromBom");
1963 if (empty($manufacturingcost)) {
1964 $manufacturingcost =
price2num($tmpproduct->cost_price,
'MU');
1965 $manufacturingcostsrc = $langs->trans(
"CostPrice");
1967 if (empty($manufacturingcost)) {
1968 $manufacturingcost =
price2num($tmpproduct->pmp,
'MU');
1969 $manufacturingcostsrc = $langs->trans(
"PMPValue");
1974 $preselected = (GETPOSTISSET(
'pricetoproduce-'.$line->id.
'-'.$i) ?
GETPOST(
'pricetoproduce-'.$line->id.
'-'.$i) : ($manufacturingcost ?
price($manufacturingcost) :
''));
1975 print
'<td class="right"><input type="text" class="width75 right" name="pricetoproduce-'.$line->id.
'-'.$i.
'" value="'.$preselected.
'"></td>';
1977 print
'<td><input type="hidden" class="width50 right" name="pricetoproduce-'.$line->id.
'-'.$i.
'" value="'.($manufacturingcost ? $manufacturingcost :
'').
'"></td>';
1985 $preselected = (GETPOSTISSET(
'idwarehousetoproduce-'.$line->id.
'-'.$i) ?
GETPOST(
'idwarehousetoproduce-'.$line->id.
'-'.$i) : (
$object->fk_warehouse > 0 ?
$object->fk_warehouse :
'ifone'));
1986 print $formproduct->selectWarehouses($preselected,
'idwarehousetoproduce-'.$line->id.
'-'.$i,
'', 1, 0, $line->fk_product,
'', 1, 0, array(),
'maxwidth200 csswarehouse_'.$line->id.
'_'.$i);
1988 print
'<span class="opacitymedium">'.$langs->trans(
"NoStockChangeOnServices").
'</span>';
1994 if ($tmpproduct->status_batch) {
1995 $preselected = (GETPOSTISSET(
'batchtoproduce-'.$line->id.
'-'.$i) ?
GETPOST(
'batchtoproduce-'.$line->id.
'-'.$i) :
'');
1996 print
'<input type="text" class="width75" name="batchtoproduce-'.$line->id.
'-'.$i.
'" value="'.$preselected.
'">';
2000 if ($tmpproduct->status_batch) {
2002 print
'<td align="right" class="split">';
2003 print
img_picto($langs->trans(
'AddStockLocationLine'),
'split',
'class="splitbutton" onClick="addDispatchLine('.$line->id.
', \''.$type.
'\', \
'qtymissing\')"');
2006 print
'<td align="right" class="splitall">';
2007 if (($action ==
'consumeorproduce' || $action ==
'consumeandproduceall') && $tmpproduct->status_batch == 2) {
2008 print
img_picto($langs->trans(
'SplitAllQuantity'),
'split',
'class="splitbutton splitallbutton field-error-icon" onClick="addDispatchLine('.$line->id.
', \'batch\', \'alltoproduce\')"');
2019 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) {
2020 print
'<td align="right">';
2021 $preselectedSellBy = (GETPOSTISSET(
'sellby-' . $line->id .
'-' . $i) ?
GETPOSTDATE(
'sellby-' . $line->id .
'-' . $i) :
'');
2022 print $form->selectDate($preselectedSellBy,
'sellby-' . $line->id .
'-' . $i, 0, 0, 1,
'', 1, 0);
2025 if ($atLeastOneSellBy) {
2031 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) {
2032 print
'<td align="right">';
2033 $preselectedEatBy = (GETPOSTISSET(
'eatby-' . $line->id .
'-' . $i) ?
GETPOSTDATE(
'eatby-' . $line->id .
'-' . $i) :
'');
2034 print $form->selectDate($preselectedEatBy,
'eatby-' . $line->id .
'-' . $i, 0, 0, 1,
'', 1, 0);
2037 if ($atLeastOneEatBy) {
2058 if (in_array($action, array(
'consumeorproduce',
'consumeandproduceall',
'addconsumeline'))) {
2062 <script
type=
"text/javascript" language=
"javascript">
2064 $(document).ready(
function() {
2066 updateselectbatchbywarehouse();
2068 updateselectwarehousebybatch();
2071 function updateselectbatchbywarehouse() {
2072 $(document).on(
'change',
"select[name*='idwarehouse']",
function () {
2073 console.log(
"We change warehouse so we update the list of possible batch number");
2075 var selectwarehouse = $(
this);
2077 var selectbatch_name = selectwarehouse.attr(
'name').replace(
'idwarehouse',
'batch');
2078 var selectbatch = $(
"datalist[id*='" + selectbatch_name +
"']");
2079 var selectedbatch = selectbatch.val();
2081 var product_element_name = selectwarehouse.attr(
'name').replace(
'idwarehouse',
'product');
2085 url:
"<?php echo DOL_URL_ROOT . '/mrp/ajax/interface.php'; ?>",
2087 action:
"updateselectbatchbywarehouse",
2088 permissiontoproduce: <?php echo $permissiontoproduce ?>,
2089 warehouse_id: $(
this).val(),
2090 token:
'<?php echo currentToken(); ?>',
2091 product_id: $(
"input[name='" + product_element_name +
"']").val()
2093 }).done(
function (data) {
2095 selectbatch.empty();
2097 if (typeof data ==
"object") {
2098 console.log(
"data is already type object, no need to parse it");
2100 console.log(
"data is type "+(typeof data));
2101 data = JSON.parse(data);
2104 selectbatch.append($(
'<option>', {
2108 $.each(data,
function (key, value) {
2110 if(selectwarehouse.val() == -1) {
2111 var label = key +
" (<?php echo $langs->trans('TotalStock') ?> : " + value +
")";
2113 var label = key +
" (<?php echo $langs->trans('Stock') ?> : " + value +
")";
2116 if(key === selectedbatch) {
2117 var option =
'<option value="'+key+
'" selected>'+ label +
'</option>';
2119 var option =
'<option value="'+key+
'">'+ label +
'</option>';
2122 selectbatch.append(option);
2128 function updateselectwarehousebybatch() {
2129 $(document).on(
'change',
'input[name*=batch]',
function(){
2130 console.log(
"We change batch so we update the list of possible warehouses");
2132 var selectbatch = $(
this);
2134 var selectwarehouse_name = selectbatch.attr(
'name').replace(
'batch',
'idwarehouse');
2135 var selectwarehouse = $(
"select[name*='" + selectwarehouse_name +
"']");
2136 var selectedwarehouse = selectwarehouse.val();
2138 if(selectedwarehouse != -1){
2142 var product_element_name = selectbatch.attr(
'name').replace(
'batch',
'product');
2146 url:
"<?php echo DOL_URL_ROOT . '/mrp/ajax/interface.php'; ?>",
2148 action:
"updateselectwarehousebybatch",
2149 permissiontoproduce: <?php echo $permissiontoproduce ?>,
2150 batch: $(
this).val(),
2151 token:
'<?php echo currentToken(); ?>',
2152 product_id: $(
"input[name='" + product_element_name +
"']").val()
2154 }).done(
function (data) {
2156 if (typeof data ==
"object") {
2157 console.log(
"data is already type object, no need to parse it");
2159 console.log(
"data is type "+(typeof data));
2160 data = JSON.parse(data);
2164 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.
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dolBuildUrl($url, $params=[], $addtoken=false)
Return path of url.
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.
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'.
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.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
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.
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...
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, $mode=0)
Check permissions of a user to show a page and an object.