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.
'&search_societe='.urlencode(
$object->thirdparty->name).
'">'.$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) {
1111 if ($qtyhourservice && $qtyhourforline) {
1112 $linecost =
price2num(($qtyhourforline / $qtyhourservice * $costprice) /
$object->qty,
'MT');
1113 $bomcostupdated +=
price2num(($qtyhourforline / $qtyhourservice * $costprice) /
$object->qty,
'MU');
1116 $bomcostupdated +=
price2num(($line->qty * $costprice) /
$object->qty,
'MU');
1120 $bomcostupdated +=
price2num(($line->qty * $costprice) /
$object->qty,
'MU');
1124 $bomcostupdated =
price2num($bomcostupdated,
'MU');
1125 $arrayoflines =
$object->fetchLinesLinked(
'consumed', $line->id);
1126 $alreadyconsumed = 0;
1127 foreach ($arrayoflines as $line2) {
1128 $alreadyconsumed += $line2[
'qty'];
1131 if ($action ==
'editline' && $lineid == $line->id) {
1132 $linecost =
price2num($tmpproduct->pmp,
'MT');
1134 $arrayoflines =
$object->fetchLinesLinked(
'consumed', $line->id);
1135 $alreadyconsumed = 0;
1136 if (is_array($arrayoflines) && !empty($arrayoflines)) {
1137 foreach ($arrayoflines as $line2) {
1138 $alreadyconsumed += $line2[
'qty'];
1141 $suffix =
'_' . $line->id;
1142 print
'<!-- Line to dispatch ' . $suffix .
' (line edited) -->' .
"\n";
1144 print
'<input id="qty_ordered' . $suffix .
'" type="hidden" value="' . $line->qty .
'">';
1146 print
'<input id="qty_dispatched' . $suffix .
'" type="hidden" value="' . $alreadyconsumed .
'">';
1148 print
'<input name="lineid" type="hidden" value="' . $line->id .
'">';
1151 print
'<td>' . $tmpproduct->getNomUrl(1);
1152 print
'<br><div class="opacitymedium small tdoverflowmax150" title="' .
dol_escape_htmltag($tmpproduct->label) .
'">' . $tmpproduct->label .
'</span>';
1156 print
'<td class="right nowraponall">';
1157 print
'<input class="width40 right" name="qty_lineProduce" value="'. $line->qty.
'">';
1161 print
'<td class="right nowraponall">';
1169 if ($permissiontoupdatecost &&
getDolGlobalString(
'MRP_SHOW_COST_FOR_CONSUMPTION')) {
1174 print
'<td class="right">';
1175 print
' ' .
price2num($alreadyconsumed,
'MS');
1181 print $formproduct->selectWarehouses($line->fk_warehouse,
'warehouse_lineProduce',
'warehouseopen', 1);
1183 print $formproduct->selectWorkstations($line->fk_default_workstation,
'workstation_lineProduce', 1);
1189 print
'<td class="nowraponall right">';
1190 if ($tmpproduct->isStockManaged()) {
1191 if ($tmpproduct->stock_reel < ($line->qty - $alreadyconsumed)) {
1192 print
img_warning($langs->trans(
'StockTooLow')).
' ';
1194 print
'<span class="left">'. $tmpproduct->stock_reel .
' </span>';
1204 print
'<td colspan="'.(3 + (
$object->status == Mo::STATUS_DRAFT ? 1 : 0) + ($permissiontodelete ? 1 : 0)).
'">';
1205 print
'<input type="submit" class="button buttongen button-add small nominwidth" name="save" value="' . $langs->trans(
"Save") .
'">';
1206 print
'<input type="submit" class="button buttongen button-cancel small nominwidth" name="cancel" value="' . $langs->trans(
"Cancel") .
'">';
1212 if (!empty($extrafields)) {
1213 $line->fetch_optionals();
1214 $temps = $line->showOptionals($extrafields,
'edit', array(),
'',
'',
'1',
'line');
1215 if (!empty($temps)) {
1217 print
'<tr><td colspan="'.$colspan.
'"><div style="padding-top: 20px" id="extrafield_lines_area_edit" name="extrafield_lines_area_edit">';
1219 print
'</div></td></tr>';
1223 $suffix =
'_' . $line->id;
1224 print
'<!-- Line to dispatch ' . $suffix .
' -->' .
"\n";
1226 print
'<input id="qty_ordered' . $suffix .
'" type="hidden" value="' . $line->qty .
'">';
1227 print
'<input id="qty_dispatched' . $suffix .
'" type="hidden" value="' . $alreadyconsumed .
'">';
1229 print
'<tr data-line-id="' . $line->id .
'">';
1232 print
'<td>' . $tmpproduct->getNomUrl(1);
1233 print
'<br><div class="opacitymedium small tdoverflowmax150" title="' .
dol_escape_htmltag($tmpproduct->label) .
'">' . $tmpproduct->label .
'</div>';
1237 print
'<td class="right nowraponall">';
1239 if ($line->qty_frozen) {
1240 $help = ($help ?
'<br>' :
'') .
'<strong>' . $langs->trans(
"QuantityFrozen") .
'</strong>: ' .
yn(1) .
' (' . $langs->trans(
"QuantityConsumedInvariable") .
')';
1241 print $form->textwithpicto(
'', $help, -1,
'lock') .
' ';
1243 if ($line->disable_stock_change) {
1244 $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")) .
')';
1245 print $form->textwithpicto(
'', $help, -1,
'help') .
' ';
1251 print
'<td class="right nowraponall">';
1259 if ($permissiontoupdatecost &&
getDolGlobalString(
'MRP_SHOW_COST_FOR_CONSUMPTION')) {
1260 print
'<td class="right nowraponall">';
1261 print
price($linecost);
1266 print
'<td class="right">';
1267 if ($alreadyconsumed) {
1269 print
'jQuery(document).ready(function() {
1270 jQuery("#expandtoproduce' . $line->id .
'").click(function() {
1271 console.log("Expand mrp_production line ' . $line->id .
'");
1272 jQuery(".expanddetail' . $line->id .
'").toggle();';
1273 if ($nblinetoconsume == $nblinetoconsumecursor) {
1274 print
'if (jQuery("#tablelines").hasClass("nobottom")) { jQuery("#tablelines").removeClass("nobottom"); } else { jQuery("#tablelines").addClass("nobottom"); }';
1280 if (empty($conf->use_javascript_ajax)) {
1281 print
'<a href="' . $_SERVER[
"PHP_SELF"] .
'?collapse=' . $collapse .
',' . $line->id .
'">';
1283 print
img_picto($langs->trans(
"ShowDetails"),
"chevron-down",
'id="expandtoproduce' . $line->id .
'"');
1284 if (empty($conf->use_javascript_ajax)) {
1288 if ($nblinetoconsume == $nblinetoconsumecursor) {
1289 print
'<script>jQuery("#tablelines").removeClass("nobottom");</script>';
1292 print
' ' .
price2num($alreadyconsumed,
'MS');
1296 print
'<td class="tdoverflowmax100">';
1297 if ($tmpproduct->isStockManaged()) {
1299 if (
getDolGlobalString(
'STOCK_CONSUMPTION_FROM_MANUFACTURING_WAREHOUSE') && $tmpwarehouse->id > 0) {
1300 print
img_picto(
'', $tmpwarehouse->picto) .
" " . $tmpwarehouse->label;
1302 if ($line->fk_warehouse > 0) {
1303 $warehouseline =
new Entrepot($db);
1304 $warehouseline->fetch($line->fk_warehouse);
1305 print $warehouseline->getNomUrl(1);
1309 if (
isModEnabled(
'workstation') && $line->fk_default_workstation > 0) {
1311 $tmpworkstation->fetch($line->fk_default_workstation);
1312 print $tmpworkstation->getNomUrl(1);
1318 print
'<td class="nowraponall right">';
1320 if (!$line->disable_stock_change && $tmpproduct->stock_reel < ($line->qty - $alreadyconsumed)) {
1321 print
img_warning($langs->trans(
'StockTooLow')) .
' ';
1323 if (!
getDolGlobalString(
'STOCK_CONSUMPTION_FROM_MANUFACTURING_WAREHOUSE') || empty($tmpwarehouse->id)) {
1324 print
price2num($tmpproduct->stock_reel,
'MS');
1327 $tmpproduct->load_stock();
1328 $wh_stock = $tmpproduct->stock_warehouse[$tmpwarehouse->id];
1329 if (!empty($wh_stock)) {
1351 if (
$object->status == Mo::STATUS_DRAFT) {
1352 $href = $_SERVER[
"PHP_SELF"] .
'?id=' . ((int)
$object->id) .
'&action=editline&token=' .
newToken() .
'&lineid=' . ((int) $line->id);
1353 print
'<td class="center">';
1354 print
'<a class="reposition editfielda" href="' . $href .
'">';
1355 print
img_picto($langs->trans(
'TooltipEditAndRevertStockMovement'),
'edit');
1361 if ($permissiontodelete && empty($arrayoflines)) {
1362 $href = $_SERVER[
"PHP_SELF"] .
'?id=' . ((int)
$object->id) .
'&action=deleteline&token=' .
newToken() .
'&lineid=' . ((int) $line->id);
1363 print
'<td class="center">';
1364 print
'<a class="reposition" href="' . $href .
'">';
1365 print
img_picto($langs->trans(
'TooltipDeleteAndRevertStockMovement'),
'delete');
1373 if (!empty($extrafields)) {
1374 $line->fetch_optionals();
1375 $temps = $line->showOptionals($extrafields,
'view', array(),
'',
'',
'1',
'line');
1376 if (!empty($temps)) {
1378 print
'<tr><td colspan="'.$colspan.
'"><div id="extrafield_lines_area_'.$line->id.
'" name="extrafield_lines_area_'.$line->id.
'">';
1380 print
'</div></td></tr>';
1386 foreach ($arrayoflines as $line2) {
1387 print
'<tr class="expanddetail'.$line->id.
' hideobject opacitylow">';
1391 $tmpstockmovement->id = $line2[
'fk_stock_movement'];
1392 print
'<a href="'.DOL_URL_ROOT.
'/product/stock/movement_list.php?search_ref='.$tmpstockmovement->id.
'">'.
img_picto($langs->trans(
"StockMovement"),
'movement',
'class="paddingright"').
'</a>';
1403 if ($permissiontoupdatecost &&
getDolGlobalString(
'MRP_SHOW_COST_FOR_CONSUMPTION')) {
1408 print
'<td class="right">'.$line2[
'qty'].
'</td>';
1411 print
'<td class="tdoverflowmax150">';
1412 if ($line2[
'fk_warehouse'] > 0) {
1413 $result = $tmpwarehouse->fetch($line2[
'fk_warehouse']);
1415 print $tmpwarehouse->getNomUrl(1);
1428 if ($line2[
'batch'] !=
'') {
1429 $tmpbatch->fetch(0, $line2[
'fk_product'], $line2[
'batch']);
1430 print $tmpbatch->getNomUrl(1);
1442 if (
$object->status == Mo::STATUS_DRAFT) {
1443 $href = $_SERVER[
"PHP_SELF"] .
'?id=' . ((int)
$object->id) .
'&action=editline&token=' .
newToken() .
'&lineid=' . ((int) $line2[
'rowid']);
1444 print
'<td class="center">';
1445 print
'<a class="reposition" href="' . $href .
'">';
1446 print
img_picto($langs->trans(
'TooltipEditAndRevertStockMovement'),
'edit');
1452 if ($permissiontodelete) {
1453 $href = $_SERVER[
"PHP_SELF"].
'?id='.((int)
$object->id).
'&action=deleteline&token='.
newToken().
'&lineid='.((int) $line2[
'rowid']).
'&fk_movement='.((int) $line2[
'fk_stock_movement']);
1454 print
'<td class="center">';
1455 print
'<a class="reposition" href="'.$href.
'">';
1456 print
img_picto($langs->trans(
'TooltipDeleteAndRevertStockMovement'),
'delete');
1464 if (in_array($action, array(
'consumeorproduce',
'consumeandproduceall'))) {
1466 print
'<!-- Enter line to consume -->'.
"\n";
1468 print
'<tr data-max-qty="'.$maxQty.
'" name="batch_'.$line->id.
'_'.$i.
'">';
1470 print
'<td><span class="opacitymedium">'.$langs->trans(
"ToConsume").
'</span></td>';
1471 $preselected = (GETPOSTISSET(
'qty-'.$line->id.
'-'.$i) ?
GETPOST(
'qty-'.$line->id.
'-'.$i) : max(0, $line->qty - $alreadyconsumed));
1472 if ($action ==
'consumeorproduce' && !
getDolGlobalString(
'MRP_AUTO_SET_REMAINING_QUANTITIES_TO_BE_CONSUMED') && !GETPOSTISSET(
'qty-'.$line->id.
'-'.$i)) {
1477 if (
getDolGlobalString(
'MRP_NEVER_CONSUME_MORE_THAN_EXPECTED') && ($line->qty - $alreadyconsumed) <= 0) {
1478 $disable =
'disabled';
1482 print
'<input type="hidden" name="product-'.$line->id.
'-'.$i.
'" value="'.$line->fk_product.
'">';
1485 print
'<td class="right">';
1486 if ((
int) $tmpproduct->stockable_product > 0) {
1487 print
'<input type="text" class="width50 right" id="qtytoconsume-' . $line->id .
'-' . $i .
'" name="qty-' . $line->id .
'-' . $i .
'" value="' . $preselected .
'" ' . $disable .
'>';
1489 print
'<input type="hidden" id="qtytoconsume-' . $line->id .
'-' . $i .
'" name="qty-' . $line->id .
'-' . $i .
'" value="0">';
1490 print
'<span class="opacitymedium">' . $langs->trans(
"StockDisabled") .
'</span>';
1498 if ($permissiontoupdatecost &&
getDolGlobalString(
'MRP_SHOW_COST_FOR_CONSUMPTION')) {
1508 && ((
int) $tmpproduct->stockable_product > 0)) {
1509 if (empty($line->disable_stock_change)) {
1510 $preselected = (GETPOSTISSET(
'idwarehouse-'.$line->id.
'-'.$i) ?
GETPOST(
'idwarehouse-'.$line->id.
'-'.$i) : ($tmpproduct->fk_default_warehouse > 0 ? $tmpproduct->fk_default_warehouse :
'ifone'));
1511 print $formproduct->selectWarehouses($preselected,
'idwarehouse-'.$line->id.
'-'.$i,
'', 1, 0, $line->fk_product,
'', 1, 0, array(),
'maxwidth200 csswarehouse_'.$line->id.
'_'.$i);
1513 print
'<span class="opacitymedium">'.$langs->trans(
"DisableStockChange").
'</span>';
1516 if ((
int) $tmpproduct->stockable_product > 0) {
1517 print
'<span class="opacitymedium">' . $langs->trans(
"StockDisabled") .
'</span>';
1519 print
'<span class="opacitymedium">' . $langs->trans(
"NoStockChangeOnServices") .
'</span>';
1531 print
'<td class="nowraponall">';
1532 if ($tmpproduct->status_batch) {
1533 $preselected = (GETPOSTISSET(
'batch-'.$line->id.
'-'.$i) ?
GETPOST(
'batch-'.$line->id.
'-'.$i) :
'');
1534 print
'<input type="text" class="width75" name="batch-'.$line->id.
'-'.$i.
'" value="'.$preselected.
'" list="batch-'.$line->id.
'-'.$i.
'">';
1535 print $formproduct->selectLotDataList(
'batch-'.$line->id.
'-'.$i, 0, $line->fk_product, 0, array());
1542 print
'<td align="right" class="split">';
1543 print
' '.img_picto($langs->trans(
'AddStockLocationLine'),
'split',
'class="splitbutton" onClick="addDispatchLine('.((int) $line->id).
', \''.
dol_escape_js($type).
'\', \
'qtymissingconsume\')"');
1547 print
'<td align="right" class="splitall">';
1548 if (($action ==
'consumeorproduce' || $action ==
'consumeandproduceall') && $tmpproduct->status_batch == 2) {
1549 print
img_picto($langs->trans(
'SplitAllQuantity'),
'split',
'class="splitbutton splitallbutton field-error-icon" data-max-qty="1" onClick="addDispatchLine('.$line->id.
', \'batch\', \'allmissingconsume\')"');
1554 if (
$object->status == Mo::STATUS_DRAFT) {
1559 if ($permissiontodelete) {
1573 print
'<script type="text/javascript">
1574 $(document).ready(function () {
1575 $("select[name=fk_default_warehouse]").change(function() {
1576 var fk_default_warehouse = $("option:selected", this).val();
1577 $("select[name^=idwarehouse-]").val(fk_default_warehouse).change();
1582 if (in_array($action, array(
'consumeorproduce',
'consumeandproduceall')) &&
1584 print
'<script>$(document).ready(function () {
1585 $("#fk_default_warehouse").change();
1593 print
'<div class="fichehalfright">';
1594 print
'<div class="clearboth"></div>';
1596 $nblinetoproduce = 0;
1597 $atLeastOneEatBy =
false;
1598 $atLeastOneSellBy =
false;
1599 foreach (
$object->lines as $line) {
1600 if ($line->role ==
'toproduce') {
1601 $tmpproduct =
new Product($db);
1602 $tmpproduct->fetch($line->fk_product);
1604 $tmpproduct->sell_or_eat_by_mandatory == $tmpproduct::SELL_OR_EAT_BY_MANDATORY_ID_EAT_BY
1605 || $tmpproduct->sell_or_eat_by_mandatory == $tmpproduct::SELL_OR_EAT_BY_MANDATORY_ID_SELL_AND_EAT
1607 $atLeastOneEatBy =
true;
1610 $tmpproduct->sell_or_eat_by_mandatory == $tmpproduct::SELL_OR_EAT_BY_MANDATORY_ID_SELL_BY
1611 || $tmpproduct->sell_or_eat_by_mandatory == $tmpproduct::SELL_OR_EAT_BY_MANDATORY_ID_SELL_AND_EAT
1613 $atLeastOneSellBy =
true;
1619 $newcardbutton =
'';
1620 $url = $_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=addproduceline&token='.
newToken();
1621 $permissiontoaddaproductline =
$object->status != $object::STATUS_PRODUCED &&
$object->status != $object::STATUS_CANCELED;
1622 $parameters = array(
'morecss' =>
'reposition');
1623 if ($action !=
'consumeorproduce' && $action !=
'consumeandproduceall') {
1624 if ($nblinetoproduce == 0 ||
$object->mrptype == 1) {
1625 $newcardbutton =
dolGetButtonTitle($langs->trans(
'AddNewProduceLines'),
'',
'fa fa-plus-circle size15x', $url,
'', (
int) $permissiontoaddaproductline, $parameters);
1629 print
load_fiche_titre($langs->trans(
'Production'), $newcardbutton,
'', 0,
'',
'');
1631 print
'<div class="div-table-responsive-no-min">';
1632 print
'<table id="tablelinestoproduce" class="noborder noshadow nobottom centpercent">';
1634 print
'<tr class="liste_titre trheight5em">';
1636 print
'<td>'.$langs->trans(
"Product").
'</td>';
1638 print
'<td class="right">'.$langs->trans(
"Qty").
'</td>';
1641 print
'<td class="right">'.$langs->trans(
"Unit").
'</td>';
1644 if ($permissiontoupdatecost) {
1645 if (empty($bomcostupdated)) {
1646 print
'<td class="right classfortooltip" title="'.$langs->trans(
"AmountUsedToUpdateWAP").
'">';
1647 print $langs->trans(
"UnitCost");
1650 print
'<td class="right classfortooltip" title="'.$langs->trans(
"AmountUsedToUpdateWAP").
'">';
1651 print $langs->trans(
"ManufacturingPrice");
1656 print
'<td class="right classfortooltip" title="'.$langs->trans(
"QtyAlreadyProduced").
'">';
1657 print $langs->trans(
"QtyAlreadyProducedShort");
1661 if ($collapse || in_array($action, array(
'consumeorproduce',
'consumeandproduceall'))) {
1662 print $langs->trans(
"Warehouse");
1669 if ($collapse || in_array($action, array(
'consumeorproduce',
'consumeandproduceall'))) {
1670 print $langs->trans(
"Batch");
1681 if ($atLeastOneEatBy) {
1682 print
'<td>'.$langs->trans(
"EatByDate").
'</td>';
1686 if ($atLeastOneSellBy) {
1687 print
'<td>'.$langs->trans(
"SellByDate").
'</td>';
1692 if ($permissiontodelete) {
1698 if ($action ==
'addproduceline') {
1699 print
'<!-- Add line to produce -->'.
"\n";
1700 print
'<tr class="liste_titre">';
1704 print $form->select_produits(0,
'productidtoadd',
'', 0, 0, -1, 2,
'', 1, array(), 0,
'1', 0,
'maxwidth300');
1707 print
'<td class="right"><input type="text" name="qtytoadd" value="1" class="width50 right"></td>';
1713 if ($permissiontoupdatecost) {
1717 print
'<td colspan="2">';
1718 print
'<input type="submit" class="button buttongen button-add" name="addproducelinebutton" value="'.$langs->trans(
"Add").
'">';
1719 print
'<input type="submit" class="button buttongen button-cancel" name="canceladdproducelinebutton" value="'.$langs->trans(
"Cancel").
'">';
1732 if ($permissiontodelete) {
1739 $nblinetoproduce = 0;
1740 foreach (
$object->lines as $line) {
1741 if ($line->role ==
'toproduce') {
1746 $nblinetoproducecursor = 0;
1747 foreach (
$object->lines as $line) {
1748 if ($line->role ==
'toproduce') {
1751 $nblinetoproducecursor++;
1753 $tmpproduct =
new Product($db);
1754 $tmpproduct->fetch($line->fk_product);
1756 $arrayoflines =
$object->fetchLinesLinked(
'produced', $line->id);
1757 $alreadyproduced = 0;
1758 foreach ($arrayoflines as $line2) {
1759 $alreadyproduced += $line2[
'qty'];
1762 $suffix =
'_'.$line->id;
1763 print
'<!-- Line to dispatch '.$suffix.
' (toproduce) -->'.
"\n";
1765 print
'<input id="qty_ordered'.$suffix.
'" type="hidden" value="'.$line->qty.
'">';
1766 print
'<input id="qty_dispatched'.$suffix.
'" type="hidden" value="'.$alreadyproduced.
'">';
1770 print
'<td>'.$tmpproduct->getNomUrl(1);
1771 print
'<br><span class="opacitymedium small">'.$tmpproduct->label.
'</span>';
1774 print
'<td class="right">'.$line->qty.
'</td>';
1777 print
'<td class="right">'.measuringUnitString($line->fk_unit,
'',
null, 1).
'</td>';
1780 if ($permissiontoupdatecost) {
1782 $manufacturingcost = 0;
1783 $manufacturingcostsrc =
'';
1785 $manufacturingcost = $bomcostupdated;
1786 $manufacturingcostsrc = $langs->trans(
"CalculatedFromProductsToConsume");
1787 if (empty($manufacturingcost)) {
1788 $manufacturingcost = $bomcost;
1789 $manufacturingcostsrc = $langs->trans(
"ValueFromBom");
1791 if (empty($manufacturingcost)) {
1792 $manufacturingcost =
price2num($tmpproduct->cost_price,
'MU');
1793 $manufacturingcostsrc = $langs->trans(
"CostPrice");
1795 if (empty($manufacturingcost)) {
1796 $manufacturingcost =
price2num($tmpproduct->pmp,
'MU');
1797 $manufacturingcostsrc = $langs->trans(
"PMPValue");
1801 print
'<td class="right nowraponall" title="'.dol_escape_htmltag($manufacturingcostsrc).
'">';
1802 if ($manufacturingcost) {
1803 print
price($manufacturingcost);
1808 print
'<td class="right nowraponall">';
1809 if ($alreadyproduced) {
1811 print
'jQuery(document).ready(function() {
1812 jQuery("#expandtoproduce'.$line->id.
'").click(function() {
1813 console.log("Expand mrp_production line '.$line->id.
'");
1814 jQuery(".expanddetailtoproduce'.$line->id.
'").toggle();';
1815 if ($nblinetoproduce == $nblinetoproducecursor) {
1816 print
'if (jQuery("#tablelinestoproduce").hasClass("nobottom")) { jQuery("#tablelinestoproduce").removeClass("nobottom"); } else { jQuery("#tablelinestoproduce").addClass("nobottom"); }';
1822 if (empty($conf->use_javascript_ajax)) {
1823 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?collapse='.$collapse.
','.$line->id.
'">';
1825 print
img_picto($langs->trans(
"ShowDetails"),
"chevron-down",
'id="expandtoproduce'.$line->id.
'"');
1826 if (empty($conf->use_javascript_ajax)) {
1830 print
' '.$alreadyproduced;
1846 if ($permissiontodelete) {
1847 if ($line->origin_type ==
'free') {
1848 $href = $_SERVER[
"PHP_SELF"];
1849 $href .=
'?id='.$object->id;
1850 $href .=
'&action=deleteline';
1851 $href .=
'&token='.newToken();
1852 $href .=
'&lineid='.$line->id;
1853 print
'<td class="center">';
1854 print
'<a class="reposition" href="'.$href.
'">';
1855 print
img_picto($langs->trans(
'TooltipDeleteAndRevertStockMovement'),
"delete");
1865 foreach ($arrayoflines as $line2) {
1866 print
'<tr class="expanddetailtoproduce'.$line->id.
' hideobject opacitylow">';
1869 $tmpstockmovement->id = $line2[
'fk_stock_movement'];
1870 print
'<a href="'.DOL_URL_ROOT.
'/product/stock/movement_list.php?search_ref='.$tmpstockmovement->id.
'">'.
img_picto($langs->trans(
"StockMovement"),
'movement',
'class="paddingright"').
'</a>';
1880 if ($permissiontoupdatecost) {
1884 print
'<td class="right">'.$line2[
'qty'].
'</td>';
1886 print
'<td class="tdoverflowmax150">';
1887 if ($line2[
'fk_warehouse'] > 0) {
1888 $result = $tmpwarehouse->fetch($line2[
'fk_warehouse']);
1890 print $tmpwarehouse->getNomUrl(1);
1897 if ($line2[
'batch'] !=
'') {
1898 $tmpbatch->fetch(0, $line2[
'fk_product'], $line2[
'batch']);
1899 print $tmpbatch->getNomUrl(1);
1910 if ($permissiontodelete) {
1916 if (in_array($action, array(
'consumeorproduce',
'consumeandproduceall'))) {
1917 print
'<!-- Enter line to produce -->'.
"\n";
1919 print
'<tr data-max-qty="'.$maxQty.
'" name="batch_'.$line->id.
'_'.$i.
'">';
1921 print
'<td><span class="opacitymedium">'.$langs->trans(
"ToProduce").
'</span></td>';
1922 $preselected = (GETPOSTISSET(
'qtytoproduce-'.$line->id.
'-'.$i) ?
GETPOST(
'qtytoproduce-'.$line->id.
'-'.$i) : max(0, $line->qty - $alreadyproduced));
1923 if ($action ==
'consumeorproduce' && !GETPOSTISSET(
'qtytoproduce-'.$line->id.
'-'.$i)) {
1927 print
'<td class="right"><input type="text" class="width50 right" id="qtytoproduce-'.$line->id.
'-'.$i.
'" name="qtytoproduce-'.$line->id.
'-'.$i.
'" value="'.$preselected.
'"></td>';
1930 print
'<td class="right"></td>';
1933 if ($permissiontoupdatecost) {
1935 $manufacturingcost = 0;
1936 $manufacturingcostsrc =
'';
1938 $manufacturingcost = $bomcostupdated;
1939 $manufacturingcostsrc = $langs->trans(
"CalculatedFromProductsToConsume");
1940 if (empty($manufacturingcost)) {
1941 $manufacturingcost = $bomcost;
1942 $manufacturingcostsrc = $langs->trans(
"ValueFromBom");
1944 if (empty($manufacturingcost)) {
1945 $manufacturingcost =
price2num($tmpproduct->cost_price,
'MU');
1946 $manufacturingcostsrc = $langs->trans(
"CostPrice");
1948 if (empty($manufacturingcost)) {
1949 $manufacturingcost =
price2num($tmpproduct->pmp,
'MU');
1950 $manufacturingcostsrc = $langs->trans(
"PMPValue");
1955 $preselected = (GETPOSTISSET(
'pricetoproduce-'.$line->id.
'-'.$i) ?
GETPOST(
'pricetoproduce-'.$line->id.
'-'.$i) : ($manufacturingcost ?
price($manufacturingcost) :
''));
1956 print
'<td class="right"><input type="text" class="width75 right" name="pricetoproduce-'.$line->id.
'-'.$i.
'" value="'.$preselected.
'"></td>';
1958 print
'<td><input type="hidden" class="width50 right" name="pricetoproduce-'.$line->id.
'-'.$i.
'" value="'.($manufacturingcost ? $manufacturingcost :
'').
'"></td>';
1966 $preselected = (GETPOSTISSET(
'idwarehousetoproduce-'.$line->id.
'-'.$i) ?
GETPOST(
'idwarehousetoproduce-'.$line->id.
'-'.$i) : (
$object->fk_warehouse > 0 ?
$object->fk_warehouse :
'ifone'));
1967 print $formproduct->selectWarehouses($preselected,
'idwarehousetoproduce-'.$line->id.
'-'.$i,
'', 1, 0, $line->fk_product,
'', 1, 0, array(),
'maxwidth200 csswarehouse_'.$line->id.
'_'.$i);
1969 print
'<span class="opacitymedium">'.$langs->trans(
"NoStockChangeOnServices").
'</span>';
1975 if ($tmpproduct->status_batch) {
1976 $preselected = (GETPOSTISSET(
'batchtoproduce-'.$line->id.
'-'.$i) ?
GETPOST(
'batchtoproduce-'.$line->id.
'-'.$i) :
'');
1977 print
'<input type="text" class="width75" name="batchtoproduce-'.$line->id.
'-'.$i.
'" value="'.$preselected.
'">';
1981 if ($tmpproduct->status_batch) {
1983 print
'<td align="right" class="split">';
1984 print
img_picto($langs->trans(
'AddStockLocationLine'),
'split',
'class="splitbutton" onClick="addDispatchLine('.$line->id.
', \''.$type.
'\', \
'qtymissing\')"');
1987 print
'<td align="right" class="splitall">';
1988 if (($action ==
'consumeorproduce' || $action ==
'consumeandproduceall') && $tmpproduct->status_batch == 2) {
1989 print
img_picto($langs->trans(
'SplitAllQuantity'),
'split',
'class="splitbutton splitallbutton field-error-icon" onClick="addDispatchLine('.$line->id.
', \'batch\', \'alltoproduce\')"');
2000 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) {
2001 print
'<td align="right">';
2002 $preselectedSellBy = (GETPOSTISSET(
'sellby-' . $line->id .
'-' . $i) ?
GETPOSTDATE(
'sellby-' . $line->id .
'-' . $i) :
'');
2003 print $form->selectDate($preselectedSellBy,
'sellby-' . $line->id .
'-' . $i, 0, 0, 1,
'', 1, 0);
2006 if ($atLeastOneSellBy) {
2012 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) {
2013 print
'<td align="right">';
2014 $preselectedEatBy = (GETPOSTISSET(
'eatby-' . $line->id .
'-' . $i) ?
GETPOSTDATE(
'eatby-' . $line->id .
'-' . $i) :
'');
2015 print $form->selectDate($preselectedEatBy,
'eatby-' . $line->id .
'-' . $i, 0, 0, 1,
'', 1, 0);
2018 if ($atLeastOneEatBy) {
2039 if (in_array($action, array(
'consumeorproduce',
'consumeandproduceall',
'addconsumeline'))) {
2043 <script
type=
"text/javascript" language=
"javascript">
2045 $(document).ready(
function() {
2047 updateselectbatchbywarehouse();
2049 updateselectwarehousebybatch();
2052 function updateselectbatchbywarehouse() {
2053 $(document).on(
'change',
"select[name*='idwarehouse']",
function () {
2054 console.log(
"We change warehouse so we update the list of possible batch number");
2056 var selectwarehouse = $(
this);
2058 var selectbatch_name = selectwarehouse.attr(
'name').replace(
'idwarehouse',
'batch');
2059 var selectbatch = $(
"datalist[id*='" + selectbatch_name +
"']");
2060 var selectedbatch = selectbatch.val();
2062 var product_element_name = selectwarehouse.attr(
'name').replace(
'idwarehouse',
'product');
2066 url:
"<?php echo DOL_URL_ROOT . '/mrp/ajax/interface.php'; ?>",
2068 action:
"updateselectbatchbywarehouse",
2069 permissiontoproduce: <?php echo $permissiontoproduce ?>,
2070 warehouse_id: $(
this).val(),
2071 token:
'<?php echo currentToken(); ?>',
2072 product_id: $(
"input[name='" + product_element_name +
"']").val()
2074 }).done(
function (data) {
2076 selectbatch.empty();
2078 if (typeof data ==
"object") {
2079 console.log(
"data is already type object, no need to parse it");
2081 console.log(
"data is type "+(typeof data));
2082 data = JSON.parse(data);
2085 selectbatch.append($(
'<option>', {
2089 $.each(data,
function (key, value) {
2091 if(selectwarehouse.val() == -1) {
2092 var label = key +
" (<?php echo $langs->trans('TotalStock') ?> : " + value +
")";
2094 var label = key +
" (<?php echo $langs->trans('Stock') ?> : " + value +
")";
2097 if(key === selectedbatch) {
2098 var option =
'<option value="'+key+
'" selected>'+ label +
'</option>';
2100 var option =
'<option value="'+key+
'">'+ label +
'</option>';
2103 selectbatch.append(option);
2109 function updateselectwarehousebybatch() {
2110 $(document).on(
'change',
'input[name*=batch]',
function(){
2111 console.log(
"We change batch so we update the list of possible warehouses");
2113 var selectbatch = $(
this);
2115 var selectwarehouse_name = selectbatch.attr(
'name').replace(
'batch',
'idwarehouse');
2116 var selectwarehouse = $(
"select[name*='" + selectwarehouse_name +
"']");
2117 var selectedwarehouse = selectwarehouse.val();
2119 if(selectedwarehouse != -1){
2123 var product_element_name = selectbatch.attr(
'name').replace(
'batch',
'product');
2127 url:
"<?php echo DOL_URL_ROOT . '/mrp/ajax/interface.php'; ?>",
2129 action:
"updateselectwarehousebybatch",
2130 permissiontoproduce: <?php echo $permissiontoproduce ?>,
2131 batch: $(
this).val(),
2132 token:
'<?php echo currentToken(); ?>',
2133 product_id: $(
"input[name='" + product_element_name +
"']").val()
2135 }).done(
function (data) {
2137 if (typeof data ==
"object") {
2138 console.log(
"data is already type object, no need to parse it");
2140 console.log(
"data is type "+(typeof data));
2141 data = JSON.parse(data);
2145 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.