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) {
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);
300 if (in_array($action, array(
'confirm_consumeorproduce',
'confirm_consumeandproduceall')) && $permissiontoproduce) {
303 $labelmovement =
GETPOST(
'inventorylabel',
'alphanohtml');
304 $codemovement =
GETPOST(
'inventorycode',
'alphanohtml');
309 foreach (
$object->lines as $line) {
310 if ($line->role ==
'toconsume') {
311 $tmpproduct =
new Product($db);
312 $tmpproduct->fetch($line->fk_product);
315 while (GETPOSTISSET(
'qty-'.$line->id.
'-'.$i)) {
318 if ($qtytoprocess != 0) {
320 if (GETPOSTISSET(
'idwarehouse-'.$line->id.
'-'.$i)) {
321 if (!(
GETPOST(
'idwarehouse-'.$line->id.
'-'.$i) > 0)) {
322 $langs->load(
"errors");
323 setEventMessages($langs->trans(
"ErrorFieldRequiredForProduct", $langs->transnoentitiesnoconv(
"Warehouse"), $tmpproduct->ref),
null,
'errors');
326 if ($tmpproduct->status_batch && (!
GETPOST(
'batch-'.$line->id.
'-'.$i))) {
327 $langs->load(
"errors");
328 setEventMessages($langs->trans(
"ErrorFieldRequiredForProduct", $langs->transnoentitiesnoconv(
"Batch"), $tmpproduct->ref),
null,
'errors');
334 if (!$error &&
GETPOST(
'idwarehouse-'.$line->id.
'-'.$i) > 0) {
336 $id_product_batch = 0;
338 $stockmove->context[
'mrp_role'] =
'toconsume';
340 if ($qtytoprocess >= 0) {
341 $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);
343 $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);
345 if ($idstockmove < 0) {
353 $moline =
new MoLine($db);
355 $moline->position = $pos;
356 $moline->fk_product = $line->fk_product;
357 $moline->fk_warehouse =
GETPOSTINT(
'idwarehouse-'.$line->id.
'-'.$i);
358 $moline->qty = $qtytoprocess;
359 $moline->batch =
GETPOST(
'batch-'.$line->id.
'-'.$i);
360 $moline->role =
'consumed';
361 $moline->fk_mrp_production = $line->id;
362 $moline->fk_stock_movement = $idstockmove == 0 ? null : $idstockmove;
363 $moline->fk_user_creat = $user->id;
365 $resultmoline = $moline->create($user);
366 if ($resultmoline <= 0) {
383 foreach (
$object->lines as $line) {
384 if ($line->role ==
'toproduce') {
385 $tmpproduct =
new Product($db);
386 $tmpproduct->fetch($line->fk_product);
389 while (GETPOSTISSET(
'qtytoproduce-'.$line->id.
'-'.$i)) {
390 $qtytoprocess = (float)
price2num(
GETPOST(
'qtytoproduce-'.$line->id.
'-'.$i));
391 $pricetoprocess =
GETPOST(
'pricetoproduce-'.$line->id.
'-'.$i) ?
price2num(
GETPOST(
'pricetoproduce-'.$line->id.
'-'.$i)) : 0;
393 if ($qtytoprocess != 0) {
395 if (GETPOSTISSET(
'idwarehousetoproduce-'.$line->id.
'-'.$i)) {
396 if (!(
GETPOST(
'idwarehousetoproduce-'.$line->id.
'-'.$i) > 0)) {
397 $langs->load(
"errors");
398 setEventMessages($langs->trans(
"ErrorFieldRequiredForProduct", $langs->transnoentitiesnoconv(
"Warehouse"), $tmpproduct->ref),
null,
'errors');
401 if (
isModEnabled(
'productbatch') && $tmpproduct->status_batch && (!
GETPOST(
'batchtoproduce-'.$line->id.
'-'.$i))) {
402 $langs->load(
"errors");
403 setEventMessages($langs->trans(
"ErrorFieldRequiredForProduct", $langs->transnoentitiesnoconv(
"Batch"), $tmpproduct->ref),
null,
'errors');
409 if (!$error &&
GETPOST(
'idwarehousetoproduce-'.$line->id.
'-'.$i) > 0) {
411 $id_product_batch = 0;
412 $stockmove->origin_type =
$object->element;
413 $stockmove->origin_id =
$object->id;
414 $stockmove->context[
'mrp_role'] =
'toproduce';
416 $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);
417 if ($idstockmove < 0) {
425 $moline =
new MoLine($db);
427 $moline->position = $pos;
428 $moline->fk_product = $line->fk_product;
429 $moline->fk_warehouse =
GETPOSTINT(
'idwarehousetoproduce-'.$line->id.
'-'.$i);
430 $moline->qty = $qtytoprocess;
431 $moline->batch =
GETPOST(
'batchtoproduce-'.$line->id.
'-'.$i);
432 $moline->role =
'produced';
433 $moline->fk_mrp_production = $line->id;
434 $moline->fk_stock_movement = (($idstockmove == 0) ?
null : $idstockmove);
435 $moline->fk_user_creat = $user->id;
437 $resultmoline = $moline->create($user);
438 if ($resultmoline <= 0) {
453 $consumptioncomplete =
true;
454 $productioncomplete =
true;
457 foreach (
$object->lines as $line) {
458 $tmpproduct =
new Product($db);
459 $tmpproduct->fetch($line->fk_product);
460 if ((
int) $tmpproduct->stockable_product > 0) {
461 if ($line->role ==
'toconsume') {
462 $arrayoflines =
$object->fetchLinesLinked(
'consumed', $line->id);
463 $alreadyconsumed = 0;
464 foreach ($arrayoflines as $line2) {
465 $alreadyconsumed += $line2[
'qty'];
468 if ($alreadyconsumed < $line->qty) {
469 $consumptioncomplete =
false;
472 if ($line->role ==
'toproduce') {
473 $arrayoflines =
$object->fetchLinesLinked(
'produced', $line->id);
474 $alreadyproduced = 0;
475 foreach ($arrayoflines as $line2) {
476 $alreadyproduced += $line2[
'qty'];
479 if ($alreadyproduced < $line->qty) {
480 $productioncomplete =
false;
486 $consumptioncomplete =
false;
487 $productioncomplete =
false;
491 dol_syslog(
"consumptioncomplete = ".json_encode($consumptioncomplete).
" productioncomplete = ".json_encode($productioncomplete));
492 if ($consumptioncomplete && $productioncomplete) {
493 $result =
$object->setStatut($object::STATUS_PRODUCED, 0,
'',
'MRP_MO_PRODUCED');
495 $result =
$object->setStatut($object::STATUS_INPROGRESS, 0,
'',
'MRP_MO_PRODUCED');
504 $action = str_replace(
'confirm_',
'', $action);
510 header(
"Location: ".$_SERVER[
"PHP_SELF"].
'?id='.
$object->id);
516 if ($action ==
'confirm_produced' && $confirm ==
'yes' && $permissiontoadd) {
517 $result =
$object->setStatut($object::STATUS_PRODUCED, 0,
'',
'MRP_MO_PRODUCED');
521 $outputlangs = $langs;
524 $newlang =
GETPOST(
'lang_id',
'aZ09');
527 $newlang =
$object->thirdparty->default_lang;
529 if (!empty($newlang)) {
531 $outputlangs->setDefaultLang($newlang);
536 $object->generateDocument($model, $outputlangs, 0, 0, 0);
543 if ($action ==
'confirm_editline' && $permissiontoadd) {
544 $moline =
new MoLine($db);
547 $extrafields->fetch_name_optionals_label($moline->table_element);
548 if (!empty($extrafields->attributes[$moline->table_element][
'label'])) {
549 foreach ($extrafields->attributes[$moline->table_element][
'label'] as $key => $label) {
550 $value =
GETPOST(
'options_'.$key,
'alphanohtml');
551 $moline->array_options[
"options_".$key] = $value;
555 if (GETPOSTISSET(
'warehouse_lineProduce')) {
556 $moline->fk_warehouse = (
GETPOSTINT(
'warehouse_lineProduce') > 0 ?
GETPOSTINT(
'warehouse_lineProduce') : 0);
558 if (GETPOSTISSET(
'workstation_lineProduce')) {
559 $moline->fk_default_workstation = (
GETPOSTINT(
'workstation_lineProduce') > 0 ?
GETPOSTINT(
'workstation_lineProduce') : 0);
562 $res = $moline->update($user);
566 header(
"Location: ".$_SERVER[
"PHP_SELF"].
'?id='.
$object->id);
569 header(
"Location: ".$_SERVER[
"PHP_SELF"].
'?id='.
$object->id);
581$form =
new Form($db);
588$title = $langs->trans(
'Mo');
589$help_url =
'EN:Module_Manufacturing_Orders|FR:Module_Ordres_de_Fabrication|DE:Modul_Fertigungsauftrag';
590$morejs = array(
'/mrp/js/lib_dispatch.js.php');
591llxHeader(
'', $title, $help_url,
'', 0, 0, $morejs,
'',
'',
'mod-mrp page-card_production');
596if (
$object->id > 0 && (empty($action) || ($action !=
'edit' && $action !=
'create' && $action !=
'reload'))) {
597 $res =
$object->fetch_thirdparty();
598 $res =
$object->fetch_optionals();
601 $tmpwarehouse->fetch((
int)
$object->fk_warehouse);
602 $fk_default_warehouse = (int)
$object->fk_warehouse;
612 if ($action ==
'delete') {
613 $formquestion = array(
615 'label' => $langs->trans(
'MoCancelConsumedAndProducedLines'),
616 'name' =>
'alsoCancelConsumedAndProducedLines',
617 'type' =>
'checkbox',
621 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'DeleteMo'), $langs->trans(
'ConfirmDeleteMo'),
'confirm_delete', $formquestion, 0, 1);
624 if ($action ==
'deleteline') {
625 $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);
628 if ($action ==
'clone') {
630 $formquestion = array();
631 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'ToClone'), $langs->trans(
'ConfirmCloneMo',
$object->ref),
'confirm_clone', $formquestion,
'yes', 1);
635 if ($action ==
'validate') {
637 $ref = substr(
$object->ref, 1, 4);
638 if ($ref ==
'PROV') {
642 $numref = (string)
$object->ref;
645 $text = $langs->trans(
'ConfirmValidateMo', $numref);
654 $formquestion = array();
657 require_once DOL_DOCUMENT_ROOT.
'/product/class/html.formproduct.class.php';
660 if ($conf->browser->name ==
'ie') {
663 $formquestion = array(
670 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'Validate'), $text,
'confirm_validate', $formquestion, 0, 1, 220);
674 if ($action ==
'cancel') {
675 $formquestion = array(
677 'label' => $langs->trans(
'MoCancelConsumedAndProducedLines'),
678 'name' =>
'alsoCancelConsumedAndProducedLines',
679 'type' =>
'checkbox',
680 'value' => !
getDolGlobalString(
'MO_ALSO_CANCEL_CONSUMED_AND_PRODUCED_LINES_BY_DEFAULT') ? 0 : 1
683 $formconfirm = $form->formconfirm(
dolBuildUrl($_SERVER[
"PHP_SELF"], [
'id' =>
$object->id]), $langs->trans(
'CancelMo'), $langs->trans(
'ConfirmCancelMo'),
'confirm_cancel', $formquestion, 0, 1);
687 $parameters = array(
'formConfirm' => $formconfirm,
'lineid' => $lineid);
688 $reshook = $hookmanager->executeHooks(
'formConfirm', $parameters, $object, $action);
689 if (empty($reshook)) {
690 $formconfirm .= $hookmanager->resPrint;
691 } elseif ($reshook > 0) {
692 $formconfirm = $hookmanager->resPrint;
701 $linkback =
'<a href="'.DOL_URL_ROOT.
'/mrp/mo_list.php?restore_lastsearch_values=1'.(!empty($socid) ?
'&socid='.$socid :
'').
'">'.$langs->trans(
"BackToList").
'</a>';
703 $morehtmlref =
'<div class="refidno">';
712 if (is_object(
$object->thirdparty)) {
713 $morehtmlref .=
$object->thirdparty->getNomUrl(1,
'customer');
715 $morehtmlref .=
' (<a href="'.DOL_URL_ROOT.
'/commande/list.php?socid='.
$object->thirdparty->id.
'">'.$langs->trans(
"OtherOrders").
'</a>)';
721 $langs->load(
"projects");
722 if (is_object(
$object->thirdparty)) {
723 $morehtmlref .=
'<br>';
725 if ($permissiontoadd) {
726 $morehtmlref .=
img_picto($langs->trans(
"Project"),
'project',
'class="pictofixedwidth"');
727 if ($action !=
'classify') {
728 $morehtmlref .=
'<a class="editfielda" href="'.dolBuildUrl($_SERVER[
'PHP_SELF'], [
'action' =>
'classify',
'id' =>
$object->id],
true).
'">'.
img_edit($langs->transnoentitiesnoconv(
'SetProject')).
'</a> ';
730 $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');
732 if (!empty(
$object->fk_project)) {
734 $proj->fetch(
$object->fk_project);
735 $morehtmlref .= $proj->getNomUrl(1);
737 $morehtmlref .=
'<span class="opacitymedium"> - '.dol_escape_htmltag($proj->title).
'</span>';
742 $morehtmlref .=
'</div>';
745 dol_banner_tab($object,
'ref', $linkback, 1,
'ref',
'ref', $morehtmlref);
748 print
'<div class="fichecenter">';
749 print
'<div class="fichehalfleft">';
750 print
'<div class="underbanner clearboth"></div>';
751 print
'<table class="border centpercent tableforfield">'.
"\n";
754 $keyforbreak =
'fk_warehouse';
755 unset(
$object->fields[
'fk_project']);
756 unset(
$object->fields[
'fk_soc']);
762 if (
$object->status == Mo::STATUS_DRAFT && $permissiontoadd && isset(
$object->fields[
'qty'])) {
763 $object->fields[
'qty'][
'alwayseditable'] = 1;
764 if ($action ==
'editqty') {
765 $object->fields[
'qty'][
'type'] =
'numeric';
769 include DOL_DOCUMENT_ROOT.
'/core/tpl/commonfields_view.tpl.php';
772 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_view.tpl.php';
778 print
'<div class="clearboth"></div>';
783 if (!in_array($action, array(
'consumeorproduce',
'consumeandproduceall'))) {
784 print
'<div class="tabsAction">';
786 $parameters = array();
788 $reshook = $hookmanager->executeHooks(
'addMoreActionsButtons', $parameters, $object, $action);
789 if (empty($reshook)) {
791 if (
$object->status == $object::STATUS_DRAFT) {
792 if ($permissiontoadd) {
794 print
'<a class="butAction" href="'.$_SERVER[
'PHP_SELF'].
'?id='.
$object->id.
'&action=validate&token='.$newToken.
'">'.$langs->trans(
"Validate").
'</a>';
796 $langs->load(
"errors");
797 print
'<a class="butActionRefused" href="" title="'.$langs->trans(
"ErrorAddAtLeastOneLineFirst").
'">'.$langs->trans(
"Validate").
'</a>';
803 if (
$object->status == Mo::STATUS_VALIDATED ||
$object->status == Mo::STATUS_INPROGRESS) {
804 if ($permissiontoproduce) {
805 print
'<a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=consumeorproduce&token='.$newToken.
'">'.$langs->trans(
'ConsumeOrProduce').
'</a>';
807 print
'<a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans(
"NotEnoughPermissions").
'">'.$langs->trans(
'ConsumeOrProduce').
'</a>';
809 } elseif (
$object->status == Mo::STATUS_DRAFT) {
810 print
'<a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans(
"ValidateBefore").
'">'.$langs->trans(
'ConsumeOrProduce').
'</a>';
814 if (
$object->status == Mo::STATUS_VALIDATED ||
$object->status == Mo::STATUS_INPROGRESS) {
815 if ($permissiontoproduce) {
816 print
'<a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=consumeandproduceall&token='.$newToken.
'">'.$langs->trans(
'ConsumeAndProduceAll').
'</a>';
818 print
'<a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans(
"NotEnoughPermissions").
'">'.$langs->trans(
'ConsumeAndProduceAll').
'</a>';
820 } elseif (
$object->status == Mo::STATUS_DRAFT) {
821 print
'<a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans(
"ValidateBefore").
'">'.$langs->trans(
'ConsumeAndProduceAll').
'</a>';
825 if ($permissiontoadd) {
826 if (
$object->status == $object::STATUS_VALIDATED ||
$object->status == $object::STATUS_INPROGRESS) {
827 $arrayproduced =
$object->fetchLinesLinked(
'produced', 0);
829 foreach ($arrayproduced as $lineproduced) {
830 $nbProduced += $lineproduced[
'qty'];
832 if ($nbProduced > 0) {
833 print
'<a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=confirm_produced&confirm=yes&token='.$newToken.
'">'.$langs->trans(
"Close").
'</a>'.
"\n";
835 print
'<a class="butActionRefused" href="#" title="'.$langs->trans(
"GoOnTabProductionToProduceFirst", $langs->transnoentitiesnoconv(
"Production")).
'">'.$langs->trans(
"Close").
'</a>'.
"\n";
838 print
'<a class="butActionDelete" href="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=cancel&token='.$newToken.
'">'.$langs->trans(
"Cancel").
'</a>'.
"\n";
841 if (
$object->status == $object::STATUS_CANCELED) {
842 print
'<a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=confirm_reopen&confirm=yes&token='.$newToken.
'">'.$langs->trans(
"ReOpen").
'</a>'.
"\n";
845 if (
$object->status == $object::STATUS_PRODUCED) {
846 if ($permissiontoproduce) {
847 print
'<a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=confirm_reopen&token='.$newToken.
'">'.$langs->trans(
'ReOpen').
'</a>';
849 print
'<a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans(
"NotEnoughPermissions").
'">'.$langs->trans(
'ReOpen').
'</a>';
858 if (in_array($action, array(
'consumeorproduce',
'consumeandproduceall',
'addconsumeline',
'addproduceline',
'editline'))) {
859 print
'<!-- Form to enter value for consumption/production -->';
860 print
'<form method="POST" action="'.dolBuildUrl($_SERVER[
"PHP_SELF"]).
'">';
861 print
'<input type="hidden" name="token" value="'.newToken().
'">';
862 print
'<input type="hidden" name="action" value="confirm_'.$action.
'">';
863 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
864 print
'<input type="hidden" name="id" value="'.$id.
'">';
867 if (in_array($action, array(
'consumeorproduce',
'consumeandproduceall'))) {
868 $defaultstockmovementlabel =
GETPOST(
'inventorylabel',
'alphanohtml') ?
GETPOST(
'inventorylabel',
'alphanohtml') : $langs->trans(
"ProductionForRef",
$object->
ref);
871 print
'<div class="center'.(in_array($action, array(
'consumeorproduce',
'consumeandproduceall')) ?
' formconsumeproduce' :
'').
'">';
872 print
'<div class="opacitymedium hideonsmartphone paddingbottom marginbottomonly">'.$langs->trans(
"ConfirmProductionDesc", $langs->transnoentitiesnoconv(
"Confirm")).
'<br></div>';
873 print
'<span class="paddingright">'.$langs->trans(
"InventoryCode").
':</span>';
874 print
'<span class="clearbothonsmartphone"></span>';
875 print
'<input type="text" class="minwidth125 maxwidth150" name="inventorycode" value="'.$defaultstockmovementcode.
'">';
876 print
'<span class="hideonsmartphone"> </span>';
877 print
'<span class="clearbothonsmartphone"></span>';
878 print
'<span class="paddingright">'.$langs->trans(
"MovementLabel").
':</span>';
879 print
'<span class="clearbothonsmartphone"></span>';
880 print
'<input type="text" class="minwidth300" name="inventorylabel" value="'.$defaultstockmovementlabel.
'"><br><br>';
881 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>';
882 print
'<input type="submit" class="button margintoponly" value="'.$langs->trans(
"Confirm").
'" name="confirm">';
884 print
'<input class="button margintoponly button-cancel" type="submit" value="'.$langs->trans(
"Cancel").
'" name="cancel">';
898 if (!empty(
$object->table_element_line)) {
905 $res = $bom->fetch(
$object->fk_bom);
907 $bom->calculateCosts();
908 $bomcost = $bom->unit_cost;
914 print
'<!-- Lines to consume -->'.
"\n";
915 print
'<div class="fichecenter">';
916 print
'<div class="fichehalfleft">';
917 print
'<div class="clearboth"></div>';
919 $url = $_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=addconsumeline&token='.
newToken();
920 $permissiontoaddaconsumeline = (
$object->status != $object::STATUS_PRODUCED &&
$object->status != $object::STATUS_CANCELED) ? 1 : -2;
921 $parameters = array(
'morecss' =>
'reposition');
923 if ($permissiontoaddaconsumeline == -2) {
924 $helpText = $langs->trans(
'MOIsClosed');
928 if ($action !=
'consumeorproduce' && $action !=
'consumeandproduceall') {
929 $newcardbutton =
dolGetButtonTitle($langs->trans(
'AddNewConsumeLines'), $helpText,
'fa fa-plus-circle size15x', $url,
'', $permissiontoaddaconsumeline, $parameters);
932 print
load_fiche_titre($langs->trans(
'Consumption'), $newcardbutton,
'', 0,
'',
'',
'');
934 print
'<div class="div-table-responsive-no-min">';
935 print
'<table class="noborder noshadow centpercent nobottom">';
937 print
'<!-- Line of title for products to consume -->'.
"\n";
938 print
'<tr class="liste_titre trheight5em">';
940 print
'<td>'.$langs->trans(
"Product").
'</td>';
942 print
'<td class="right">'.$langs->trans(
"Qty").
'</td>';
947 print
'<td class="right">'.$langs->trans(
"UnitCost").
'</td>';
950 print
'<td class="right classfortooltip" title="'.$langs->trans(
"QtyAlreadyConsumed").
'">';
951 print $langs->trans(
"QtyAlreadyConsumedShort");
955 if ($collapse || in_array($action, array(
'consumeorproduce',
'consumeandproduceall'))) {
956 print $langs->trans(
"Warehouse");
958 print
' '.$langs->trans(
"or").
' '.$langs->trans(
"Workstation");
961 if (in_array($action, array(
'consumeorproduce',
'consumeandproduceall'))) {
962 $listwarehouses = $tmpwarehouse->list_array(1);
963 if (count($listwarehouses) > 1) {
964 print
'<br>'.$form->selectarray(
'fk_default_warehouse', $listwarehouses, $fk_default_warehouse, $langs->trans(
"ForceTo"), 0, 0,
'', 0, 0, 0,
'',
'minwidth100 maxwidth200', 1);
965 } elseif (count($listwarehouses) == 1) {
966 print
'<br>'.$form->selectarray(
'fk_default_warehouse', $listwarehouses, $fk_default_warehouse, 0, 0, 0,
'', 0, 0, 0,
'',
'minwidth100 maxwidth200', 1);
974 print
'<td align="right">';
975 if ($collapse || in_array($action, array(
'consumeorproduce',
'consumeandproduceall'))) {
976 print $langs->trans(
"Stock");
983 if ($collapse || in_array($action, array(
'consumeorproduce',
'consumeandproduceall'))) {
984 print $langs->trans(
"Batch");
996 if (
$object->status == Mo::STATUS_DRAFT) {
1001 if ($permissiontodelete) {
1007 if ($action ==
'addconsumeline') {
1008 print
'<!-- Add line to consume -->'.
"\n";
1009 print
'<tr class="liste_titre">';
1012 print $form->select_produits(0,
'productidtoadd',
'', 0, 0, -1, 2,
'', 1, array(), 0,
'1', 0,
'maxwidth150');
1015 print
'<td class="right"><input type="text" name="qtytoadd" value="1" class="width40 right"></td>';
1023 if ($permissiontoupdatecost &&
getDolGlobalString(
'MRP_SHOW_COST_FOR_CONSUMPTION')) {
1035 print
'<td colspan="'.$colspan.
'">';
1036 print
'<input type="submit" class="button buttongen button-add" name="addconsumelinebutton" value="'.$langs->trans(
"Add").
'">';
1037 print
'<input type="submit" class="button buttongen button-cancel" name="canceladdconsumelinebutton" value="'.$langs->trans(
"Cancel").
'">';
1042 if (
$object->status == Mo::STATUS_DRAFT) {
1046 if ($permissiontodelete) {
1052 if (is_object($objectline)) {
1053 $extrafields->fetch_name_optionals_label(
$object->table_element_line);
1054 $temps = $objectline->showOptionals($extrafields,
'edit', array(),
'',
'',
'1',
'line');
1055 if (!empty($temps)) {
1056 print
'<tr class="liste_titre"><td style="padding-top: 20px" colspan="9" id="extrafield_lines_area_edit" name="extrafield_lines_area_edit">';
1065 $bomcostupdated = 0;
1068 $nblinetoconsume = 0;
1069 foreach (
$object->lines as $line) {
1070 if ($line->role ==
'toconsume') {
1075 $nblinetoconsumecursor = 0;
1076 foreach (
$object->lines as $line) {
1077 if ($line->role ==
'toconsume') {
1078 $nblinetoconsumecursor++;
1080 $tmpproduct =
new Product($db);
1081 $tmpproduct->fetch($line->fk_product);
1082 $linecost =
price2num($tmpproduct->pmp,
'MT');
1086 $costprice =
price2num((!empty($tmpproduct->cost_price)) ? $tmpproduct->cost_price : $tmpproduct->pmp);
1087 if (empty($costprice)) {
1088 require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.product.class.php';
1090 if ($productFournisseur->find_min_price_product_fournisseur($line->fk_product, $line->qty) > 0) {
1091 $costprice = $productFournisseur->fourn_unitprice;
1099 if ($useunit && $line->fk_unit > 0) {
1101 $qtyhourservice = 0;
1102 if (preg_match(
'/^(\d+)([a-z]+)$/', $tmpproduct->duration, $reg)) {
1105 $qtyhourforline = 0;
1106 if ($line->fk_unit) {
1112 if (
isModEnabled(
'workstation') && $line->fk_default_workstation > 0) {
1114 $workstation->fetch($line->fk_default_workstation);
1115 $linecost =
price2num($qtyhourforline * ($workstation->thm_operator_estimated + $workstation->thm_machine_estimated) /
$object->qty,
'MT');
1116 $bomcostupdated +=
price2num($qtyhourforline * ($workstation->thm_operator_estimated + $workstation->thm_machine_estimated) /
$object->qty,
'MU');
1117 } elseif ($qtyhourservice && $qtyhourforline) {
1118 $linecost =
price2num(($qtyhourforline / $qtyhourservice * $costprice) /
$object->qty,
'MT');
1119 $bomcostupdated +=
price2num(($qtyhourforline / $qtyhourservice * $costprice) /
$object->qty,
'MU');
1122 $bomcostupdated +=
price2num(($line->qty * $costprice) /
$object->qty,
'MU');
1126 $bomcostupdated +=
price2num(($line->qty * $costprice) /
$object->qty,
'MU');
1130 $bomcostupdated =
price2num($bomcostupdated,
'MU');
1131 $arrayoflines =
$object->fetchLinesLinked(
'consumed', $line->id);
1132 $alreadyconsumed = 0;
1133 foreach ($arrayoflines as $line2) {
1134 $alreadyconsumed += $line2[
'qty'];
1137 if ($action ==
'editline' && $lineid == $line->id) {
1138 $linecost =
price2num($tmpproduct->pmp,
'MT');
1140 $arrayoflines =
$object->fetchLinesLinked(
'consumed', $line->id);
1141 $alreadyconsumed = 0;
1142 if (is_array($arrayoflines) && !empty($arrayoflines)) {
1143 foreach ($arrayoflines as $line2) {
1144 $alreadyconsumed += $line2[
'qty'];
1147 $suffix =
'_' . $line->id;
1148 print
'<!-- Line to dispatch ' . $suffix .
' (line edited) -->' .
"\n";
1150 print
'<input id="qty_ordered' . $suffix .
'" type="hidden" value="' . $line->qty .
'">';
1152 print
'<input id="qty_dispatched' . $suffix .
'" type="hidden" value="' . $alreadyconsumed .
'">';
1154 print
'<input name="lineid" type="hidden" value="' . $line->id .
'">';
1157 print
'<td>' . $tmpproduct->getNomUrl(1);
1158 print
'<br><div class="opacitymedium small tdoverflowmax150" title="' .
dol_escape_htmltag($tmpproduct->label) .
'">' . $tmpproduct->label .
'</span>';
1162 print
'<td class="right nowraponall">';
1163 print
'<input class="width40 right" name="qty_lineProduce" value="'. $line->qty.
'">';
1167 print
'<td class="right nowraponall">';
1175 if ($permissiontoupdatecost &&
getDolGlobalString(
'MRP_SHOW_COST_FOR_CONSUMPTION')) {
1180 print
'<td class="right">';
1181 print
' ' .
price2num($alreadyconsumed,
'MS');
1187 print $formproduct->selectWarehouses($line->fk_warehouse,
'warehouse_lineProduce',
'warehouseopen', 1);
1189 print $formproduct->selectWorkstations($line->fk_default_workstation,
'workstation_lineProduce', 1);
1195 print
'<td class="nowraponall right">';
1196 if ($tmpproduct->isStockManaged()) {
1197 if ($tmpproduct->stock_reel < ($line->qty - $alreadyconsumed)) {
1198 print
img_warning($langs->trans(
'StockTooLow')).
' ';
1200 print
'<span class="left">'. $tmpproduct->stock_reel .
' </span>';
1210 print
'<td colspan="'.(3 + (
$object->status == Mo::STATUS_DRAFT ? 1 : 0) + ($permissiontodelete ? 1 : 0)).
'">';
1211 print
'<input type="submit" class="button buttongen button-add small nominwidth" name="save" value="' . $langs->trans(
"Save") .
'">';
1212 print
'<input type="submit" class="button buttongen button-cancel small nominwidth" name="cancel" value="' . $langs->trans(
"Cancel") .
'">';
1218 if (!empty($extrafields)) {
1219 $line->fetch_optionals();
1220 $temps = $line->showOptionals($extrafields,
'edit', array(),
'',
'',
'1',
'line');
1221 if (!empty($temps)) {
1223 print
'<tr><td colspan="'.$colspan.
'"><div style="padding-top: 20px" id="extrafield_lines_area_edit" name="extrafield_lines_area_edit">';
1225 print
'</div></td></tr>';
1229 $suffix =
'_' . $line->id;
1230 print
'<!-- Line to dispatch ' . $suffix .
' -->' .
"\n";
1232 print
'<input id="qty_ordered' . $suffix .
'" type="hidden" value="' . $line->qty .
'">';
1233 print
'<input id="qty_dispatched' . $suffix .
'" type="hidden" value="' . $alreadyconsumed .
'">';
1235 print
'<tr data-line-id="' . $line->id .
'">';
1238 print
'<td>' . $tmpproduct->getNomUrl(1);
1239 print
'<br><div class="opacitymedium small tdoverflowmax150" title="' .
dol_escape_htmltag($tmpproduct->label) .
'">' . $tmpproduct->label .
'</div>';
1243 print
'<td class="right nowraponall">';
1245 if ($line->qty_frozen) {
1246 $help = ($help ?
'<br>' :
'') .
'<strong>' . $langs->trans(
"QuantityFrozen") .
'</strong>: ' .
yn(1) .
' (' . $langs->trans(
"QuantityConsumedInvariable") .
')';
1247 print $form->textwithpicto(
'', $help, -1,
'lock') .
' ';
1249 if ($line->disable_stock_change) {
1250 $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")) .
')';
1251 print $form->textwithpicto(
'', $help, -1,
'help') .
' ';
1257 print
'<td class="right nowraponall">';
1265 if ($permissiontoupdatecost &&
getDolGlobalString(
'MRP_SHOW_COST_FOR_CONSUMPTION')) {
1266 print
'<td class="right nowraponall">';
1267 print
price($linecost);
1272 print
'<td class="right">';
1273 if ($alreadyconsumed) {
1275 print
'jQuery(document).ready(function() {
1276 jQuery("#expandtoproduce' . $line->id .
'").click(function() {
1277 console.log("Expand mrp_production line ' . $line->id .
'");
1278 jQuery(".expanddetail' . $line->id .
'").toggle();';
1279 if ($nblinetoconsume == $nblinetoconsumecursor) {
1280 print
'if (jQuery("#tablelines").hasClass("nobottom")) { jQuery("#tablelines").removeClass("nobottom"); } else { jQuery("#tablelines").addClass("nobottom"); }';
1286 if (empty($conf->use_javascript_ajax)) {
1287 print
'<a href="' . $_SERVER[
"PHP_SELF"] .
'?collapse=' . $collapse .
',' . $line->id .
'">';
1289 print
img_picto($langs->trans(
"ShowDetails"),
"chevron-down",
'id="expandtoproduce' . $line->id .
'"');
1290 if (empty($conf->use_javascript_ajax)) {
1294 if ($nblinetoconsume == $nblinetoconsumecursor) {
1295 print
'<script>jQuery("#tablelines").removeClass("nobottom");</script>';
1298 print
' ' .
price2num($alreadyconsumed,
'MS');
1302 print
'<td class="tdoverflowmax100">';
1303 if ($tmpproduct->isStockManaged()) {
1305 if (
getDolGlobalString(
'STOCK_CONSUMPTION_FROM_MANUFACTURING_WAREHOUSE') && $tmpwarehouse->id > 0) {
1306 print
img_picto(
'', $tmpwarehouse->picto) .
" " . $tmpwarehouse->label;
1308 if ($line->fk_warehouse > 0) {
1309 $warehouseline =
new Entrepot($db);
1310 $warehouseline->fetch($line->fk_warehouse);
1311 print $warehouseline->getNomUrl(1);
1315 if (
isModEnabled(
'workstation') && $line->fk_default_workstation > 0) {
1317 $tmpworkstation->fetch($line->fk_default_workstation);
1318 print $tmpworkstation->getNomUrl(1);
1324 print
'<td class="nowraponall right">';
1326 if (!$line->disable_stock_change && $tmpproduct->stock_reel < ($line->qty - $alreadyconsumed)) {
1327 print
img_warning($langs->trans(
'StockTooLow')) .
' ';
1329 if (!
getDolGlobalString(
'STOCK_CONSUMPTION_FROM_MANUFACTURING_WAREHOUSE') || empty($tmpwarehouse->id)) {
1330 print
price2num($tmpproduct->stock_reel,
'MS');
1333 $tmpproduct->load_stock();
1334 $wh_stock = $tmpproduct->stock_warehouse[$tmpwarehouse->id];
1335 if (!empty($wh_stock)) {
1357 if (
$object->status == Mo::STATUS_DRAFT) {
1358 $href = $_SERVER[
"PHP_SELF"] .
'?id=' . ((int)
$object->id) .
'&action=editline&token=' .
newToken() .
'&lineid=' . ((int) $line->id);
1359 print
'<td class="center">';
1360 print
'<a class="reposition editfielda" href="' . $href .
'">';
1361 print
img_picto($langs->trans(
'TooltipEditAndRevertStockMovement'),
'edit');
1367 if ($permissiontodelete && empty($arrayoflines)) {
1368 $href = $_SERVER[
"PHP_SELF"] .
'?id=' . ((int)
$object->id) .
'&action=deleteline&token=' .
newToken() .
'&lineid=' . ((int) $line->id);
1369 print
'<td class="center">';
1370 print
'<a class="reposition" href="' . $href .
'">';
1371 print
img_picto($langs->trans(
'TooltipDeleteAndRevertStockMovement'),
'delete');
1379 if (!empty($extrafields)) {
1380 $line->fetch_optionals();
1381 $temps = $line->showOptionals($extrafields,
'view', array(),
'',
'',
'1',
'line');
1382 if (!empty($temps)) {
1384 print
'<tr><td colspan="'.$colspan.
'"><div id="extrafield_lines_area_'.$line->id.
'" name="extrafield_lines_area_'.$line->id.
'">';
1386 print
'</div></td></tr>';
1392 foreach ($arrayoflines as $line2) {
1393 print
'<tr class="expanddetail'.$line->id.
' hideobject opacitylow">';
1397 $tmpstockmovement->id = $line2[
'fk_stock_movement'];
1398 print
'<a href="'.DOL_URL_ROOT.
'/product/stock/movement_list.php?search_ref='.$tmpstockmovement->id.
'">'.
img_picto($langs->trans(
"StockMovement"),
'movement',
'class="paddingright"').
'</a>';
1409 if ($permissiontoupdatecost &&
getDolGlobalString(
'MRP_SHOW_COST_FOR_CONSUMPTION')) {
1414 print
'<td class="right">'.$line2[
'qty'].
'</td>';
1417 print
'<td class="tdoverflowmax150">';
1418 if ($line2[
'fk_warehouse'] > 0) {
1419 $result = $tmpwarehouse->fetch($line2[
'fk_warehouse']);
1421 print $tmpwarehouse->getNomUrl(1);
1434 if ($line2[
'batch'] !=
'') {
1435 $tmpbatch->fetch(0, $line2[
'fk_product'], $line2[
'batch']);
1436 print $tmpbatch->getNomUrl(1);
1448 if (
$object->status == Mo::STATUS_DRAFT) {
1449 $href = $_SERVER[
"PHP_SELF"] .
'?id=' . ((int)
$object->id) .
'&action=editline&token=' .
newToken() .
'&lineid=' . ((int) $line2[
'rowid']);
1450 print
'<td class="center">';
1451 print
'<a class="reposition" href="' . $href .
'">';
1452 print
img_picto($langs->trans(
'TooltipEditAndRevertStockMovement'),
'edit');
1458 if ($permissiontodelete) {
1459 $href = $_SERVER[
"PHP_SELF"].
'?id='.((int)
$object->id).
'&action=deleteline&token='.
newToken().
'&lineid='.((int) $line2[
'rowid']).
'&fk_movement='.((int) $line2[
'fk_stock_movement']);
1460 print
'<td class="center">';
1461 print
'<a class="reposition" href="'.$href.
'">';
1462 print
img_picto($langs->trans(
'TooltipDeleteAndRevertStockMovement'),
'delete');
1470 if (in_array($action, array(
'consumeorproduce',
'consumeandproduceall'))) {
1472 print
'<!-- Enter line to consume -->'.
"\n";
1474 print
'<tr data-max-qty="'.$maxQty.
'" name="batch_'.$line->id.
'_'.$i.
'">';
1476 print
'<td><span class="opacitymedium">'.$langs->trans(
"ToConsume").
'</span></td>';
1477 $preselected = (GETPOSTISSET(
'qty-'.$line->id.
'-'.$i) ?
GETPOST(
'qty-'.$line->id.
'-'.$i) : max(0, $line->qty - $alreadyconsumed));
1478 if ($action ==
'consumeorproduce' && !
getDolGlobalString(
'MRP_AUTO_SET_REMAINING_QUANTITIES_TO_BE_CONSUMED') && !GETPOSTISSET(
'qty-'.$line->id.
'-'.$i)) {
1483 if (
getDolGlobalString(
'MRP_NEVER_CONSUME_MORE_THAN_EXPECTED') && ($line->qty - $alreadyconsumed) <= 0) {
1484 $disable =
'disabled';
1488 print
'<input type="hidden" name="product-'.$line->id.
'-'.$i.
'" value="'.$line->fk_product.
'">';
1491 print
'<td class="right">';
1492 if ((
int) $tmpproduct->stockable_product > 0) {
1493 print
'<input type="text" class="width50 right" id="qtytoconsume-' . $line->id .
'-' . $i .
'" name="qty-' . $line->id .
'-' . $i .
'" value="' . $preselected .
'" ' . $disable .
'>';
1495 print
'<input type="hidden" id="qtytoconsume-' . $line->id .
'-' . $i .
'" name="qty-' . $line->id .
'-' . $i .
'" value="0">';
1496 print
'<span class="opacitymedium">' . $langs->trans(
"StockDisabled") .
'</span>';
1504 if ($permissiontoupdatecost &&
getDolGlobalString(
'MRP_SHOW_COST_FOR_CONSUMPTION')) {
1514 && ((
int) $tmpproduct->stockable_product > 0)) {
1515 if (empty($line->disable_stock_change)) {
1516 $preselected = (GETPOSTISSET(
'idwarehouse-'.$line->id.
'-'.$i) ?
GETPOST(
'idwarehouse-'.$line->id.
'-'.$i) : ($tmpproduct->fk_default_warehouse > 0 ? $tmpproduct->fk_default_warehouse :
'ifone'));
1517 print $formproduct->selectWarehouses($preselected,
'idwarehouse-'.$line->id.
'-'.$i,
'', 1, 0, $line->fk_product,
'', 1, 0, array(),
'maxwidth200 csswarehouse_'.$line->id.
'_'.$i);
1519 print
'<span class="opacitymedium">'.$langs->trans(
"DisableStockChange").
'</span>';
1522 if ((
int) $tmpproduct->stockable_product > 0) {
1523 print
'<span class="opacitymedium">' . $langs->trans(
"StockDisabled") .
'</span>';
1525 print
'<span class="opacitymedium">' . $langs->trans(
"NoStockChangeOnServices") .
'</span>';
1537 print
'<td class="nowraponall">';
1538 if ($tmpproduct->status_batch) {
1539 $preselected = (GETPOSTISSET(
'batch-'.$line->id.
'-'.$i) ?
GETPOST(
'batch-'.$line->id.
'-'.$i) :
'');
1540 print
'<input type="text" class="width75" name="batch-'.$line->id.
'-'.$i.
'" value="'.$preselected.
'" list="batch-'.$line->id.
'-'.$i.
'">';
1541 print $formproduct->selectLotDataList(
'batch-'.$line->id.
'-'.$i, 0, $line->fk_product, 0, array());
1548 print
'<td align="right" class="split">';
1549 print
' '.img_picto($langs->trans(
'AddStockLocationLine'),
'split',
'class="splitbutton" onClick="addDispatchLine('.((int) $line->id).
', \''.
dol_escape_js($type).
'\', \
'qtymissingconsume\', 1)"');
1553 print
'<td align="right" class="splitall">';
1554 if (($action ==
'consumeorproduce' || $action ==
'consumeandproduceall') && $tmpproduct->status_batch == 2) {
1555 print
img_picto($langs->trans(
'SplitAllQuantity'),
'split',
'class="splitbutton splitallbutton field-error-icon" data-max-qty="1" onClick="addDispatchLine('.$line->id.
', \'batch\', \'allmissingconsume\', 1)"');
1560 if (
$object->status == Mo::STATUS_DRAFT) {
1565 if ($permissiontodelete) {
1579 print
'<script type="text/javascript">
1580 $(document).ready(function () {
1581 $("select[name=fk_default_warehouse]").change(function() {
1582 var fk_default_warehouse = $("option:selected", this).val();
1583 $("select[name^=idwarehouse-]").val(fk_default_warehouse).change();
1588 if (in_array($action, array(
'consumeorproduce',
'consumeandproduceall')) &&
1590 print
'<script>$(document).ready(function () {
1591 $("#fk_default_warehouse").change();
1599 print
'<div class="fichehalfright">';
1600 print
'<div class="clearboth"></div>';
1602 $nblinetoproduce = 0;
1603 $atLeastOneEatBy =
false;
1604 $atLeastOneSellBy =
false;
1605 foreach (
$object->lines as $line) {
1606 if ($line->role ==
'toproduce') {
1607 $tmpproduct =
new Product($db);
1608 $tmpproduct->fetch($line->fk_product);
1610 $tmpproduct->sell_or_eat_by_mandatory == $tmpproduct::SELL_OR_EAT_BY_MANDATORY_ID_EAT_BY
1611 || $tmpproduct->sell_or_eat_by_mandatory == $tmpproduct::SELL_OR_EAT_BY_MANDATORY_ID_SELL_AND_EAT
1613 $atLeastOneEatBy =
true;
1616 $tmpproduct->sell_or_eat_by_mandatory == $tmpproduct::SELL_OR_EAT_BY_MANDATORY_ID_SELL_BY
1617 || $tmpproduct->sell_or_eat_by_mandatory == $tmpproduct::SELL_OR_EAT_BY_MANDATORY_ID_SELL_AND_EAT
1619 $atLeastOneSellBy =
true;
1625 $newcardbutton =
'';
1626 $url = $_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=addproduceline&token='.
newToken();
1627 $permissiontoaddaproductline =
$object->status != $object::STATUS_PRODUCED &&
$object->status != $object::STATUS_CANCELED;
1628 $parameters = array(
'morecss' =>
'reposition');
1629 if ($action !=
'consumeorproduce' && $action !=
'consumeandproduceall') {
1630 if ($nblinetoproduce == 0 ||
$object->mrptype == 1) {
1631 $newcardbutton =
dolGetButtonTitle($langs->trans(
'AddNewProduceLines'),
'',
'fa fa-plus-circle size15x', $url,
'', (
int) $permissiontoaddaproductline, $parameters);
1635 print
load_fiche_titre($langs->trans(
'Production'), $newcardbutton,
'', 0,
'',
'');
1637 print
'<div class="div-table-responsive-no-min">';
1638 print
'<table id="tablelinestoproduce" class="noborder noshadow nobottom centpercent">';
1640 print
'<tr class="liste_titre trheight5em">';
1642 print
'<td>'.$langs->trans(
"Product").
'</td>';
1644 print
'<td class="right">'.$langs->trans(
"Qty").
'</td>';
1647 print
'<td class="right">'.$langs->trans(
"Unit").
'</td>';
1650 if ($permissiontoupdatecost) {
1651 if (empty($bomcostupdated)) {
1652 print
'<td class="right classfortooltip" title="'.$langs->trans(
"AmountUsedToUpdateWAP").
'">';
1653 print $langs->trans(
"UnitCost");
1656 print
'<td class="right classfortooltip" title="'.$langs->trans(
"AmountUsedToUpdateWAP").
'">';
1657 print $langs->trans(
"ManufacturingPrice");
1662 print
'<td class="right classfortooltip" title="'.$langs->trans(
"QtyAlreadyProduced").
'">';
1663 print $langs->trans(
"QtyAlreadyProducedShort");
1667 if ($collapse || in_array($action, array(
'consumeorproduce',
'consumeandproduceall'))) {
1668 print $langs->trans(
"Warehouse");
1675 if ($collapse || in_array($action, array(
'consumeorproduce',
'consumeandproduceall'))) {
1676 print $langs->trans(
"Batch");
1687 if ($atLeastOneEatBy) {
1688 print
'<td>'.$langs->trans(
"EatByDate").
'</td>';
1692 if ($atLeastOneSellBy) {
1693 print
'<td>'.$langs->trans(
"SellByDate").
'</td>';
1698 if ($permissiontodelete) {
1704 if ($action ==
'addproduceline') {
1705 print
'<!-- Add line to produce -->'.
"\n";
1706 print
'<tr class="liste_titre">';
1710 print $form->select_produits(0,
'productidtoadd',
'', 0, 0, -1, 2,
'', 1, array(), 0,
'1', 0,
'maxwidth300');
1713 print
'<td class="right"><input type="text" name="qtytoadd" value="1" class="width50 right"></td>';
1719 if ($permissiontoupdatecost) {
1723 print
'<td colspan="2">';
1724 print
'<input type="submit" class="button buttongen button-add" name="addproducelinebutton" value="'.$langs->trans(
"Add").
'">';
1725 print
'<input type="submit" class="button buttongen button-cancel" name="canceladdproducelinebutton" value="'.$langs->trans(
"Cancel").
'">';
1738 if ($permissiontodelete) {
1745 $nblinetoproduce = 0;
1746 foreach (
$object->lines as $line) {
1747 if ($line->role ==
'toproduce') {
1752 $nblinetoproducecursor = 0;
1753 foreach (
$object->lines as $line) {
1754 if ($line->role ==
'toproduce') {
1757 $nblinetoproducecursor++;
1759 $tmpproduct =
new Product($db);
1760 $tmpproduct->fetch($line->fk_product);
1762 $arrayoflines =
$object->fetchLinesLinked(
'produced', $line->id);
1763 $alreadyproduced = 0;
1764 foreach ($arrayoflines as $line2) {
1765 $alreadyproduced += $line2[
'qty'];
1768 $suffix =
'_'.$line->id;
1769 print
'<!-- Line to dispatch '.$suffix.
' (toproduce) -->'.
"\n";
1771 print
'<input id="qty_ordered'.$suffix.
'" type="hidden" value="'.$line->qty.
'">';
1772 print
'<input id="qty_dispatched'.$suffix.
'" type="hidden" value="'.$alreadyproduced.
'">';
1776 print
'<td>'.$tmpproduct->getNomUrl(1);
1777 print
'<br><span class="opacitymedium small">'.$tmpproduct->label.
'</span>';
1780 print
'<td class="right">'.$line->qty.
'</td>';
1783 print
'<td class="right">'.measuringUnitString($line->fk_unit,
'',
null, 1).
'</td>';
1786 if ($permissiontoupdatecost) {
1788 $manufacturingcost = 0;
1789 $manufacturingcostsrc =
'';
1791 $manufacturingcost = $bomcostupdated;
1792 $manufacturingcostsrc = $langs->trans(
"CalculatedFromProductsToConsume");
1793 if (empty($manufacturingcost)) {
1794 $manufacturingcost = $bomcost;
1795 $manufacturingcostsrc = $langs->trans(
"ValueFromBom");
1797 if (empty($manufacturingcost)) {
1798 $manufacturingcost =
price2num($tmpproduct->cost_price,
'MU');
1799 $manufacturingcostsrc = $langs->trans(
"CostPrice");
1801 if (empty($manufacturingcost)) {
1802 $manufacturingcost =
price2num($tmpproduct->pmp,
'MU');
1803 $manufacturingcostsrc = $langs->trans(
"PMPValue");
1807 print
'<td class="right nowraponall" title="'.dol_escape_htmltag($manufacturingcostsrc).
'">';
1808 if ($manufacturingcost) {
1809 print
price($manufacturingcost);
1814 print
'<td class="right nowraponall">';
1815 if ($alreadyproduced) {
1817 print
'jQuery(document).ready(function() {
1818 jQuery("#expandtoproduce'.$line->id.
'").click(function() {
1819 console.log("Expand mrp_production line '.$line->id.
'");
1820 jQuery(".expanddetailtoproduce'.$line->id.
'").toggle();';
1821 if ($nblinetoproduce == $nblinetoproducecursor) {
1822 print
'if (jQuery("#tablelinestoproduce").hasClass("nobottom")) { jQuery("#tablelinestoproduce").removeClass("nobottom"); } else { jQuery("#tablelinestoproduce").addClass("nobottom"); }';
1828 if (empty($conf->use_javascript_ajax)) {
1829 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?collapse='.$collapse.
','.$line->id.
'">';
1831 print
img_picto($langs->trans(
"ShowDetails"),
"chevron-down",
'id="expandtoproduce'.$line->id.
'"');
1832 if (empty($conf->use_javascript_ajax)) {
1836 print
' '.$alreadyproduced;
1852 if ($permissiontodelete) {
1853 if ($line->origin_type ==
'free') {
1854 $href = $_SERVER[
"PHP_SELF"];
1855 $href .=
'?id='.$object->id;
1856 $href .=
'&action=deleteline';
1857 $href .=
'&token='.newToken();
1858 $href .=
'&lineid='.$line->id;
1859 print
'<td class="center">';
1860 print
'<a class="reposition" href="'.$href.
'">';
1861 print
img_picto($langs->trans(
'TooltipDeleteAndRevertStockMovement'),
"delete");
1871 foreach ($arrayoflines as $line2) {
1872 print
'<tr class="expanddetailtoproduce'.$line->id.
' hideobject opacitylow">';
1875 $tmpstockmovement->id = $line2[
'fk_stock_movement'];
1876 print
'<a href="'.DOL_URL_ROOT.
'/product/stock/movement_list.php?search_ref='.$tmpstockmovement->id.
'">'.
img_picto($langs->trans(
"StockMovement"),
'movement',
'class="paddingright"').
'</a>';
1886 if ($permissiontoupdatecost) {
1890 print
'<td class="right">'.$line2[
'qty'].
'</td>';
1892 print
'<td class="tdoverflowmax150">';
1893 if ($line2[
'fk_warehouse'] > 0) {
1894 $result = $tmpwarehouse->fetch($line2[
'fk_warehouse']);
1896 print $tmpwarehouse->getNomUrl(1);
1903 if ($line2[
'batch'] !=
'') {
1904 $tmpbatch->fetch(0, $line2[
'fk_product'], $line2[
'batch']);
1905 print $tmpbatch->getNomUrl(1);
1916 if ($permissiontodelete) {
1922 if (in_array($action, array(
'consumeorproduce',
'consumeandproduceall'))) {
1923 print
'<!-- Enter line to produce -->'.
"\n";
1925 print
'<tr data-max-qty="'.$maxQty.
'" name="batch_'.$line->id.
'_'.$i.
'">';
1927 print
'<td><span class="opacitymedium">'.$langs->trans(
"ToProduce").
'</span></td>';
1928 $preselected = (GETPOSTISSET(
'qtytoproduce-'.$line->id.
'-'.$i) ?
GETPOST(
'qtytoproduce-'.$line->id.
'-'.$i) : max(0, $line->qty - $alreadyproduced));
1929 if ($action ==
'consumeorproduce' && !GETPOSTISSET(
'qtytoproduce-'.$line->id.
'-'.$i)) {
1933 print
'<td class="right"><input type="text" class="width50 right" id="qtytoproduce-'.$line->id.
'-'.$i.
'" name="qtytoproduce-'.$line->id.
'-'.$i.
'" value="'.$preselected.
'"></td>';
1936 print
'<td class="right"></td>';
1939 if ($permissiontoupdatecost) {
1941 $manufacturingcost = 0;
1942 $manufacturingcostsrc =
'';
1944 $manufacturingcost = $bomcostupdated;
1945 $manufacturingcostsrc = $langs->trans(
"CalculatedFromProductsToConsume");
1946 if (empty($manufacturingcost)) {
1947 $manufacturingcost = $bomcost;
1948 $manufacturingcostsrc = $langs->trans(
"ValueFromBom");
1950 if (empty($manufacturingcost)) {
1951 $manufacturingcost =
price2num($tmpproduct->cost_price,
'MU');
1952 $manufacturingcostsrc = $langs->trans(
"CostPrice");
1954 if (empty($manufacturingcost)) {
1955 $manufacturingcost =
price2num($tmpproduct->pmp,
'MU');
1956 $manufacturingcostsrc = $langs->trans(
"PMPValue");
1961 $preselected = (GETPOSTISSET(
'pricetoproduce-'.$line->id.
'-'.$i) ?
GETPOST(
'pricetoproduce-'.$line->id.
'-'.$i) : ($manufacturingcost ?
price($manufacturingcost) :
''));
1962 print
'<td class="right"><input type="text" class="width75 right" name="pricetoproduce-'.$line->id.
'-'.$i.
'" value="'.$preselected.
'"></td>';
1964 print
'<td><input type="hidden" class="width50 right" name="pricetoproduce-'.$line->id.
'-'.$i.
'" value="'.($manufacturingcost ? $manufacturingcost :
'').
'"></td>';
1972 $preselected = (GETPOSTISSET(
'idwarehousetoproduce-'.$line->id.
'-'.$i) ?
GETPOST(
'idwarehousetoproduce-'.$line->id.
'-'.$i) : (
$object->fk_warehouse > 0 ?
$object->fk_warehouse :
'ifone'));
1973 print $formproduct->selectWarehouses($preselected,
'idwarehousetoproduce-'.$line->id.
'-'.$i,
'', 1, 0, $line->fk_product,
'', 1, 0, array(),
'maxwidth200 csswarehouse_'.$line->id.
'_'.$i);
1975 print
'<span class="opacitymedium">'.$langs->trans(
"NoStockChangeOnServices").
'</span>';
1981 if ($tmpproduct->status_batch) {
1982 $preselected = (GETPOSTISSET(
'batchtoproduce-'.$line->id.
'-'.$i) ?
GETPOST(
'batchtoproduce-'.$line->id.
'-'.$i) :
'');
1983 print
'<input type="text" class="width75" name="batchtoproduce-'.$line->id.
'-'.$i.
'" value="'.$preselected.
'">';
1987 if ($tmpproduct->status_batch) {
1989 print
'<td align="right" class="split">';
1990 print
img_picto($langs->trans(
'AddStockLocationLine'),
'split',
'class="splitbutton" onClick="addDispatchLine('.$line->id.
', \''.$type.
'\', \
'qtymissing\')"');
1993 print
'<td align="right" class="splitall">';
1994 if (($action ==
'consumeorproduce' || $action ==
'consumeandproduceall') && $tmpproduct->status_batch == 2) {
1995 print
img_picto($langs->trans(
'SplitAllQuantity'),
'split',
'class="splitbutton splitallbutton field-error-icon" onClick="addDispatchLine('.$line->id.
', \'batch\', \'alltoproduce\')"');
2006 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) {
2007 print
'<td align="right">';
2008 $preselectedSellBy = (GETPOSTISSET(
'sellby-' . $line->id .
'-' . $i) ?
GETPOSTDATE(
'sellby-' . $line->id .
'-' . $i) :
'');
2009 print $form->selectDate($preselectedSellBy,
'sellby-' . $line->id .
'-' . $i, 0, 0, 1,
'', 1, 0);
2012 if ($atLeastOneSellBy) {
2018 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) {
2019 print
'<td align="right">';
2020 $preselectedEatBy = (GETPOSTISSET(
'eatby-' . $line->id .
'-' . $i) ?
GETPOSTDATE(
'eatby-' . $line->id .
'-' . $i) :
'');
2021 print $form->selectDate($preselectedEatBy,
'eatby-' . $line->id .
'-' . $i, 0, 0, 1,
'', 1, 0);
2024 if ($atLeastOneEatBy) {
2045 if (in_array($action, array(
'consumeorproduce',
'consumeandproduceall',
'addconsumeline'))) {
2049 <script
type=
"text/javascript" language=
"javascript">
2051 $(document).ready(
function() {
2053 updateselectbatchbywarehouse();
2055 updateselectwarehousebybatch();
2058 function updateselectbatchbywarehouse() {
2059 $(document).on(
'change',
"select[name*='idwarehouse']",
function () {
2060 console.log(
"We change warehouse so we update the list of possible batch number");
2062 var selectwarehouse = $(
this);
2064 var selectbatch_name = selectwarehouse.attr(
'name').replace(
'idwarehouse',
'batch');
2065 var selectbatch = $(
"datalist[id*='" + selectbatch_name +
"']");
2066 var selectedbatch = selectbatch.val();
2068 var product_element_name = selectwarehouse.attr(
'name').replace(
'idwarehouse',
'product');
2072 url:
"<?php echo DOL_URL_ROOT . '/mrp/ajax/interface.php'; ?>",
2074 action:
"updateselectbatchbywarehouse",
2075 permissiontoproduce: <?php echo $permissiontoproduce ?>,
2076 warehouse_id: $(
this).val(),
2077 token:
'<?php echo currentToken(); ?>',
2078 product_id: $(
"input[name='" + product_element_name +
"']").val()
2080 }).done(
function (data) {
2082 selectbatch.empty();
2084 if (typeof data ==
"object") {
2085 console.log(
"data is already type object, no need to parse it");
2087 console.log(
"data is type "+(typeof data));
2088 data = JSON.parse(data);
2091 selectbatch.append($(
'<option>', {
2095 $.each(data,
function (key, value) {
2097 if(selectwarehouse.val() == -1) {
2098 var label = key +
" (<?php echo $langs->trans('TotalStock') ?> : " + value +
")";
2100 var label = key +
" (<?php echo $langs->trans('Stock') ?> : " + value +
")";
2103 if(key === selectedbatch) {
2104 var option =
'<option value="'+key+
'" selected>'+ label +
'</option>';
2106 var option =
'<option value="'+key+
'">'+ label +
'</option>';
2109 selectbatch.append(option);
2115 function updateselectwarehousebybatch() {
2116 $(document).on(
'change',
'input[name*=batch]',
function(){
2117 console.log(
"We change batch so we update the list of possible warehouses");
2119 var selectbatch = $(
this);
2121 var selectwarehouse_name = selectbatch.attr(
'name').replace(
'batch',
'idwarehouse');
2122 var selectwarehouse = $(
"select[name*='" + selectwarehouse_name +
"']");
2123 var selectedwarehouse = selectwarehouse.val();
2125 if(selectedwarehouse != -1){
2129 var product_element_name = selectbatch.attr(
'name').replace(
'batch',
'product');
2133 url:
"<?php echo DOL_URL_ROOT . '/mrp/ajax/interface.php'; ?>",
2135 action:
"updateselectwarehousebybatch",
2136 permissiontoproduce: <?php echo $permissiontoproduce ?>,
2137 batch: $(
this).val(),
2138 token:
'<?php echo currentToken(); ?>',
2139 product_id: $(
"input[name='" + product_element_name +
"']").val()
2141 }).done(
function (data) {
2143 if (typeof data ==
"object") {
2144 console.log(
"data is already type object, no need to parse it");
2146 console.log(
"data is type "+(typeof data));
2147 data = JSON.parse(data);
2151 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.