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');
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);
167 include DOL_DOCUMENT_ROOT.
'/core/actions_addupdatedelete.inc.php';
170 include DOL_DOCUMENT_ROOT.
'/core/actions_dellink.inc.php';
173 include DOL_DOCUMENT_ROOT.
'/core/actions_printing.inc.php';
176 $triggersendname =
'MO_SENTBYMAIL';
177 $autocopy =
'MAIN_MAIL_AUTOCOPY_MO_TO';
178 $trackid =
'mo'.$object->id;
179 include DOL_DOCUMENT_ROOT.
'/core/actions_sendmails.inc.php';
184 if ($action ==
'set_thirdparty' && $permissiontoadd) {
185 $object->setValueFrom(
'fk_soc',
GETPOSTINT(
'fk_soc'),
'',
null,
'date',
'', $user, $triggermodname);
187 if ($action ==
'classin' && $permissiontoadd) {
191 if ($action ==
'confirm_reopen' && $permissiontoadd) {
192 $result =
$object->setStatut($object::STATUS_INPROGRESS, 0,
'',
'MRP_REOPEN');
195 if (($action ==
'confirm_addconsumeline' &&
GETPOST(
'addconsumelinebutton') && $permissiontoadd)
196 || ($action ==
'confirm_addproduceline' &&
GETPOST(
'addproducelinebutton') && $permissiontoadd)) {
197 $moline =
new MoLine($db);
202 $moline->fk_product =
GETPOSTINT(
'productidtoadd');
203 if (
GETPOST(
'addconsumelinebutton')) {
204 $moline->role =
'toconsume';
206 $moline->role =
'toproduce';
208 $moline->origin_type =
'free';
209 $moline->position = 0;
212 if (!empty($moline->fk_product)) {
213 $tmpproduct =
new Product($db);
214 $tmpproduct->fetch($moline->fk_product);
216 $moline->fk_default_workstation = $tmpproduct->fk_default_workstation;
217 $moline->disable_stock_change = 1;
218 if ($tmpproduct->duration_unit) {
219 $moline->qty = $tmpproduct->duration_value;
220 include_once DOL_DOCUMENT_ROOT.
'/core/class/cunits.class.php';
221 $cunits =
new CUnits($db);
222 $res = $cunits->fetch(0,
'', $tmpproduct->duration_unit,
'time');
224 $moline->fk_unit = $cunits->id;
228 $moline->disable_stock_change = 0;
230 $moline->fk_unit = $tmpproduct->fk_unit;
235 $extralabelsline = $extrafields->fetch_name_optionals_label(
$object->table_element_line);
236 $array_options = $extrafields->getOptionalsFromPost(
$object->table_element_line);
238 if (is_array($extralabelsline)) {
240 foreach ($extralabelsline as $key => $value) {
241 unset($_POST[
"options_".$key]);
244 if (is_array($array_options) && count($array_options) > 0) {
245 $moline->array_options = $array_options;
248 $resultline = $moline->create($user, 0);
249 if ($resultline <= 0) {
256 header(
"Location: ".$_SERVER[
"PHP_SELF"].
'?id='.
$object->id);
260 if (in_array($action, array(
'confirm_consumeorproduce',
'confirm_consumeandproduceall')) && $permissiontoproduce) {
263 $labelmovement =
GETPOST(
'inventorylabel',
'alphanohtml');
264 $codemovement =
GETPOST(
'inventorycode',
'alphanohtml');
269 foreach (
$object->lines as $line) {
270 if ($line->role ==
'toconsume') {
271 $tmpproduct =
new Product($db);
272 $tmpproduct->fetch($line->fk_product);
275 while (GETPOSTISSET(
'qty-'.$line->id.
'-'.$i)) {
278 if ($qtytoprocess != 0) {
280 if (GETPOSTISSET(
'idwarehouse-'.$line->id.
'-'.$i)) {
281 if (!(
GETPOST(
'idwarehouse-'.$line->id.
'-'.$i) > 0)) {
282 $langs->load(
"errors");
283 setEventMessages($langs->trans(
"ErrorFieldRequiredForProduct", $langs->transnoentitiesnoconv(
"Warehouse"), $tmpproduct->ref),
null,
'errors');
286 if ($tmpproduct->status_batch && (!
GETPOST(
'batch-'.$line->id.
'-'.$i))) {
287 $langs->load(
"errors");
288 setEventMessages($langs->trans(
"ErrorFieldRequiredForProduct", $langs->transnoentitiesnoconv(
"Batch"), $tmpproduct->ref),
null,
'errors');
294 if (!$error &&
GETPOST(
'idwarehouse-'.$line->id.
'-'.$i) > 0) {
296 $id_product_batch = 0;
298 $stockmove->context[
'mrp_role'] =
'toconsume';
300 if ($qtytoprocess >= 0) {
301 $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);
303 $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);
305 if ($idstockmove < 0) {
313 $moline =
new MoLine($db);
315 $moline->position = $pos;
316 $moline->fk_product = $line->fk_product;
317 $moline->fk_warehouse =
GETPOSTINT(
'idwarehouse-'.$line->id.
'-'.$i);
318 $moline->qty = $qtytoprocess;
319 $moline->batch =
GETPOST(
'batch-'.$line->id.
'-'.$i);
320 $moline->role =
'consumed';
321 $moline->fk_mrp_production = $line->id;
322 $moline->fk_stock_movement = $idstockmove == 0 ? null : $idstockmove;
323 $moline->fk_user_creat = $user->id;
325 $resultmoline = $moline->create($user);
326 if ($resultmoline <= 0) {
343 foreach (
$object->lines as $line) {
344 if ($line->role ==
'toproduce') {
345 $tmpproduct =
new Product($db);
346 $tmpproduct->fetch($line->fk_product);
349 while (GETPOSTISSET(
'qtytoproduce-'.$line->id.
'-'.$i)) {
350 $qtytoprocess = (float)
price2num(
GETPOST(
'qtytoproduce-'.$line->id.
'-'.$i));
351 $pricetoprocess =
GETPOST(
'pricetoproduce-'.$line->id.
'-'.$i) ?
price2num(
GETPOST(
'pricetoproduce-'.$line->id.
'-'.$i)) : 0;
353 if ($qtytoprocess != 0) {
355 if (GETPOSTISSET(
'idwarehousetoproduce-'.$line->id.
'-'.$i)) {
356 if (!(
GETPOST(
'idwarehousetoproduce-'.$line->id.
'-'.$i) > 0)) {
357 $langs->load(
"errors");
358 setEventMessages($langs->trans(
"ErrorFieldRequiredForProduct", $langs->transnoentitiesnoconv(
"Warehouse"), $tmpproduct->ref),
null,
'errors');
361 if (isModEnabled(
'productbatch') && $tmpproduct->status_batch && (!
GETPOST(
'batchtoproduce-'.$line->id.
'-'.$i))) {
362 $langs->load(
"errors");
363 setEventMessages($langs->trans(
"ErrorFieldRequiredForProduct", $langs->transnoentitiesnoconv(
"Batch"), $tmpproduct->ref),
null,
'errors');
369 if (!$error &&
GETPOST(
'idwarehousetoproduce-'.$line->id.
'-'.$i) > 0) {
371 $id_product_batch = 0;
372 $stockmove->origin_type =
$object->element;
373 $stockmove->origin_id =
$object->id;
374 $stockmove->context[
'mrp_role'] =
'toproduce';
376 $idstockmove = $stockmove->reception($user, $line->fk_product,
GETPOSTINT(
'idwarehousetoproduce-'.$line->id.
'-'.$i), $qtytoprocess, $pricetoprocess, $labelmovement,
'',
'',
GETPOST(
'batchtoproduce-'.$line->id.
'-'.$i),
dol_now(), $id_product_batch, $codemovement);
377 if ($idstockmove < 0) {
385 $moline =
new MoLine($db);
387 $moline->position = $pos;
388 $moline->fk_product = $line->fk_product;
389 $moline->fk_warehouse =
GETPOSTINT(
'idwarehousetoproduce-'.$line->id.
'-'.$i);
390 $moline->qty = $qtytoprocess;
391 $moline->batch =
GETPOST(
'batchtoproduce-'.$line->id.
'-'.$i);
392 $moline->role =
'produced';
393 $moline->fk_mrp_production = $line->id;
394 $moline->fk_stock_movement = $idstockmove;
395 $moline->fk_user_creat = $user->id;
397 $resultmoline = $moline->create($user);
398 if ($resultmoline <= 0) {
413 $consumptioncomplete =
true;
414 $productioncomplete =
true;
417 foreach (
$object->lines as $line) {
418 $tmpproduct =
new Product($db);
419 $tmpproduct->fetch($line->fk_product);
420 if ((
int) $tmpproduct->stockable_product > 0) {
421 if ($line->role ==
'toconsume') {
422 $arrayoflines =
$object->fetchLinesLinked(
'consumed', $line->id);
423 $alreadyconsumed = 0;
424 foreach ($arrayoflines as $line2) {
425 $alreadyconsumed += $line2[
'qty'];
428 if ($alreadyconsumed < $line->qty) {
429 $consumptioncomplete =
false;
432 if ($line->role ==
'toproduce') {
433 $arrayoflines =
$object->fetchLinesLinked(
'produced', $line->id);
434 $alreadyproduced = 0;
435 foreach ($arrayoflines as $line2) {
436 $alreadyproduced += $line2[
'qty'];
439 if ($alreadyproduced < $line->qty) {
440 $productioncomplete =
false;
446 $consumptioncomplete =
false;
447 $productioncomplete =
false;
451 dol_syslog(
"consumptioncomplete = ".json_encode($consumptioncomplete).
" productioncomplete = ".json_encode($productioncomplete));
452 if ($consumptioncomplete && $productioncomplete) {
453 $result =
$object->setStatut($object::STATUS_PRODUCED, 0,
'',
'MRP_MO_PRODUCED');
455 $result =
$object->setStatut($object::STATUS_INPROGRESS, 0,
'',
'MRP_MO_PRODUCED');
464 $action = str_replace(
'confirm_',
'', $action);
470 header(
"Location: ".$_SERVER[
"PHP_SELF"].
'?id='.
$object->id);
476 if ($action ==
'confirm_produced' && $confirm ==
'yes' && $permissiontoadd) {
477 $result =
$object->setStatut($object::STATUS_PRODUCED, 0,
'',
'MRP_MO_PRODUCED');
481 $outputlangs = $langs;
484 $newlang =
GETPOST(
'lang_id',
'aZ09');
487 $newlang =
$object->thirdparty->default_lang;
489 if (!empty($newlang)) {
491 $outputlangs->setDefaultLang($newlang);
496 $object->generateDocument($model, $outputlangs, 0, 0, 0);
503 if ($action ==
'confirm_editline' && $permissiontoadd) {
504 $moline =
new MoLine($db);
507 $extrafields->fetch_name_optionals_label($moline->element);
508 foreach ($extrafields->attributes[$moline->table_element][
'label'] as $key => $label) {
509 $value =
GETPOST(
'options_'.$key,
'alphanohtml');
510 $moline->array_options[
"options_".$key] = $value;
513 if (GETPOSTISSET(
'warehouse_lineProduce')) {
514 $moline->fk_warehouse = (
GETPOSTINT(
'warehouse_lineProduce') > 0 ?
GETPOSTINT(
'warehouse_lineProduce') : 0);
516 if (GETPOSTISSET(
'workstation_lineProduce')) {
517 $moline->fk_default_workstation = (
GETPOSTINT(
'workstation_lineProduce') > 0 ?
GETPOSTINT(
'workstation_lineProduce') : 0);
520 $res = $moline->update($user);
524 header(
"Location: ".$_SERVER[
"PHP_SELF"].
'?id='.
$object->id);
527 header(
"Location: ".$_SERVER[
"PHP_SELF"].
'?id='.
$object->id);
539$form =
new Form($db);
546$title = $langs->trans(
'Mo');
547$help_url =
'EN:Module_Manufacturing_Orders|FR:Module_Ordres_de_Fabrication|DE:Modul_Fertigungsauftrag';
548$morejs = array(
'/mrp/js/lib_dispatch.js.php');
549llxHeader(
'', $title, $help_url,
'', 0, 0, $morejs,
'',
'',
'mod-mrp page-card_production');
554if (
$object->id > 0 && (empty($action) || ($action !=
'edit' && $action !=
'create'))) {
555 $res =
$object->fetch_thirdparty();
556 $res =
$object->fetch_optionals();
559 $tmpwarehouse->fetch(
$object->fk_warehouse);
560 $fk_default_warehouse =
$object->fk_warehouse;
570 if ($action ==
'delete') {
571 $formquestion = array(
573 'label' => $langs->trans(
'MoCancelConsumedAndProducedLines'),
574 'name' =>
'alsoCancelConsumedAndProducedLines',
575 'type' =>
'checkbox',
579 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'DeleteMo'), $langs->trans(
'ConfirmDeleteMo'),
'confirm_delete', $formquestion, 0, 1);
582 if ($action ==
'deleteline') {
583 $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);
586 if ($action ==
'clone') {
588 $formquestion = array();
589 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'ToClone'), $langs->trans(
'ConfirmCloneMo',
$object->ref),
'confirm_clone', $formquestion,
'yes', 1);
593 if ($action ==
'validate') {
595 $ref = substr(
$object->ref, 1, 4);
596 if ($ref ==
'PROV') {
603 $text = $langs->trans(
'ConfirmValidateMo', $numref);
612 $formquestion = array();
613 if (isModEnabled(
'mrp')) {
615 require_once DOL_DOCUMENT_ROOT.
'/product/class/html.formproduct.class.php';
618 if (
$conf->browser->name ==
'ie') {
621 $formquestion = array(
628 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'Validate'), $text,
'confirm_validate', $formquestion, 0, 1, 220);
632 if ($action ==
'cancel') {
633 $formquestion = array(
635 'label' => $langs->trans(
'MoCancelConsumedAndProducedLines'),
636 'name' =>
'alsoCancelConsumedAndProducedLines',
637 'type' =>
'checkbox',
638 'value' => !
getDolGlobalString(
'MO_ALSO_CANCEL_CONSUMED_AND_PRODUCED_LINES_BY_DEFAULT') ? 0 : 1
641 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"] .
'?id=' .
$object->id, $langs->trans(
'CancelMo'), $langs->trans(
'ConfirmCancelMo'),
'confirm_cancel', $formquestion, 0, 1);
645 $parameters = array(
'formConfirm' => $formconfirm,
'lineid' => $lineid);
646 $reshook = $hookmanager->executeHooks(
'formConfirm', $parameters, $object, $action);
647 if (empty($reshook)) {
648 $formconfirm .= $hookmanager->resPrint;
649 } elseif ($reshook > 0) {
650 $formconfirm = $hookmanager->resPrint;
659 $linkback =
'<a href="'.DOL_URL_ROOT.
'/mrp/mo_list.php?restore_lastsearch_values=1'.(!empty($socid) ?
'&socid='.$socid :
'').
'">'.$langs->trans(
"BackToList").
'</a>';
661 $morehtmlref =
'<div class="refidno">';
670 if (is_object(
$object->thirdparty)) {
671 $morehtmlref .=
$object->thirdparty->getNomUrl(1,
'customer');
673 $morehtmlref .=
' (<a href="'.DOL_URL_ROOT.
'/commande/list.php?socid='.
$object->thirdparty->id.
'&search_societe='.urlencode(
$object->thirdparty->name).
'">'.$langs->trans(
"OtherOrders").
'</a>)';
678 if (isModEnabled(
'project')) {
679 $langs->load(
"projects");
680 if (is_object(
$object->thirdparty)) {
681 $morehtmlref .=
'<br>';
683 if ($permissiontoadd) {
684 $morehtmlref .=
img_picto($langs->trans(
"Project"),
'project',
'class="pictofixedwidth"');
685 if ($action !=
'classify') {
686 $morehtmlref .=
'<a class="editfielda" href="'.$_SERVER[
'PHP_SELF'].
'?action=classify&token='.
newToken().
'&id='.
$object->id.
'">'.
img_edit($langs->transnoentitiesnoconv(
'SetProject')).
'</a> ';
688 $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');
690 if (!empty(
$object->fk_project)) {
692 $proj->fetch(
$object->fk_project);
693 $morehtmlref .= $proj->getNomUrl(1);
695 $morehtmlref .=
'<span class="opacitymedium"> - '.dol_escape_htmltag($proj->title).
'</span>';
700 $morehtmlref .=
'</div>';
703 dol_banner_tab($object,
'ref', $linkback, 1,
'ref',
'ref', $morehtmlref);
706 print
'<div class="fichecenter">';
707 print
'<div class="fichehalfleft">';
708 print
'<div class="underbanner clearboth"></div>';
709 print
'<table class="border centpercent tableforfield">'.
"\n";
712 $keyforbreak =
'fk_warehouse';
713 unset(
$object->fields[
'fk_project']);
714 unset(
$object->fields[
'fk_soc']);
715 include DOL_DOCUMENT_ROOT.
'/core/tpl/commonfields_view.tpl.php';
718 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_view.tpl.php';
724 print
'<div class="clearboth"></div>';
729 if (!in_array($action, array(
'consumeorproduce',
'consumeandproduceall'))) {
730 print
'<div class="tabsAction">';
732 $parameters = array();
734 $reshook = $hookmanager->executeHooks(
'addMoreActionsButtons', $parameters, $object, $action);
735 if (empty($reshook)) {
737 if (
$object->status == $object::STATUS_DRAFT) {
738 if ($permissiontoadd) {
740 print
'<a class="butAction" href="'.$_SERVER[
'PHP_SELF'].
'?id='.
$object->id.
'&action=validate&token='.$newToken.
'">'.$langs->trans(
"Validate").
'</a>';
742 $langs->load(
"errors");
743 print
'<a class="butActionRefused" href="" title="'.$langs->trans(
"ErrorAddAtLeastOneLineFirst").
'">'.$langs->trans(
"Validate").
'</a>';
749 if (
$object->status == Mo::STATUS_VALIDATED ||
$object->status == Mo::STATUS_INPROGRESS) {
750 if ($permissiontoproduce) {
751 print
'<a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=consumeorproduce&token='.$newToken.
'">'.$langs->trans(
'ConsumeOrProduce').
'</a>';
753 print
'<a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans(
"NotEnoughPermissions").
'">'.$langs->trans(
'ConsumeOrProduce').
'</a>';
755 } elseif (
$object->status == Mo::STATUS_DRAFT) {
756 print
'<a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans(
"ValidateBefore").
'">'.$langs->trans(
'ConsumeOrProduce').
'</a>';
760 if (
$object->status == Mo::STATUS_VALIDATED ||
$object->status == Mo::STATUS_INPROGRESS) {
761 if ($permissiontoproduce) {
762 print
'<a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=consumeandproduceall&token='.$newToken.
'">'.$langs->trans(
'ConsumeAndProduceAll').
'</a>';
764 print
'<a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans(
"NotEnoughPermissions").
'">'.$langs->trans(
'ConsumeAndProduceAll').
'</a>';
766 } elseif (
$object->status == Mo::STATUS_DRAFT) {
767 print
'<a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans(
"ValidateBefore").
'">'.$langs->trans(
'ConsumeAndProduceAll').
'</a>';
771 if ($permissiontoadd) {
772 if (
$object->status == $object::STATUS_VALIDATED ||
$object->status == $object::STATUS_INPROGRESS) {
773 $arrayproduced =
$object->fetchLinesLinked(
'produced', 0);
775 foreach ($arrayproduced as $lineproduced) {
776 $nbProduced += $lineproduced[
'qty'];
778 if ($nbProduced > 0) {
779 print
'<a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=confirm_produced&confirm=yes&token='.$newToken.
'">'.$langs->trans(
"Close").
'</a>'.
"\n";
781 print
'<a class="butActionRefused" href="#" title="'.$langs->trans(
"GoOnTabProductionToProduceFirst", $langs->transnoentitiesnoconv(
"Production")).
'">'.$langs->trans(
"Close").
'</a>'.
"\n";
784 print
'<a class="butActionDelete" href="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=cancel&token='.$newToken.
'">'.$langs->trans(
"Cancel").
'</a>'.
"\n";
787 if (
$object->status == $object::STATUS_CANCELED) {
788 print
'<a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=confirm_reopen&confirm=yes&token='.$newToken.
'">'.$langs->trans(
"ReOpen").
'</a>'.
"\n";
791 if (
$object->status == $object::STATUS_PRODUCED) {
792 if ($permissiontoproduce) {
793 print
'<a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=confirm_reopen&token='.$newToken.
'">'.$langs->trans(
'ReOpen').
'</a>';
795 print
'<a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans(
"NotEnoughPermissions").
'">'.$langs->trans(
'ReOpen').
'</a>';
804 if (in_array($action, array(
'consumeorproduce',
'consumeandproduceall',
'addconsumeline',
'addproduceline',
'editline'))) {
805 print
'<form method="POST" action="'.$_SERVER[
"PHP_SELF"].
'">';
806 print
'<input type="hidden" name="token" value="'.newToken().
'">';
807 print
'<input type="hidden" name="action" value="confirm_'.$action.
'">';
808 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
809 print
'<input type="hidden" name="id" value="'.$id.
'">';
812 if (in_array($action, array(
'consumeorproduce',
'consumeandproduceall'))) {
813 $defaultstockmovementlabel =
GETPOST(
'inventorylabel',
'alphanohtml') ?
GETPOST(
'inventorylabel',
'alphanohtml') : $langs->trans(
"ProductionForRef",
$object->
ref);
816 print
'<div class="center'.(in_array($action, array(
'consumeorproduce',
'consumeandproduceall')) ?
' formconsumeproduce' :
'').
'">';
817 print
'<div class="opacitymedium hideonsmartphone paddingbottom">'.$langs->trans(
"ConfirmProductionDesc", $langs->transnoentitiesnoconv(
"Confirm")).
'<br></div>';
818 print
'<span class="fieldrequired">'.$langs->trans(
"InventoryCode").
':</span> <input type="text" class="minwidth150 maxwidth200" name="inventorycode" value="'.$defaultstockmovementcode.
'"> ';
819 print
'<span class="clearbothonsmartphone"></span>';
820 print $langs->trans(
"MovementLabel").
': <input type="text" class="minwidth300" name="inventorylabel" value="'.$defaultstockmovementlabel.
'"><br><br>';
821 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>';
822 print
'<input type="submit" class="button" value="'.$langs->trans(
"Confirm").
'" name="confirm">';
824 print
'<input class="button button-cancel" type="submit" value="'.$langs->trans(
"Cancel").
'" name="cancel">';
838 if (!empty(
$object->table_element_line)) {
845 $res = $bom->fetch(
$object->fk_bom);
847 $bom->calculateCosts();
848 $bomcost = $bom->unit_cost;
854 print
'<!-- Lines to consume -->'.
"\n";
855 print
'<div class="fichecenter">';
856 print
'<div class="fichehalfleft">';
857 print
'<div class="clearboth"></div>';
859 $url = $_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=addconsumeline&token='.
newToken();
860 $permissiontoaddaconsumeline = (
$object->status != $object::STATUS_PRODUCED &&
$object->status != $object::STATUS_CANCELED) ? 1 : -2;
861 $parameters = array(
'morecss' =>
'reposition');
863 if ($permissiontoaddaconsumeline == -2) {
864 $helpText = $langs->trans(
'MOIsClosed');
868 if ($action !=
'consumeorproduce' && $action !=
'consumeandproduceall') {
869 $newcardbutton =
dolGetButtonTitle($langs->trans(
'AddNewConsumeLines'), $helpText,
'fa fa-plus-circle size15x', $url,
'', $permissiontoaddaconsumeline, $parameters);
872 print
load_fiche_titre($langs->trans(
'Consumption'), $newcardbutton,
'', 0,
'',
'',
'');
874 print
'<div class="div-table-responsive-no-min">';
875 print
'<table class="noborder noshadow centpercent nobottom">';
877 print
'<!-- Line of title for products to consume -->'.
"\n";
878 print
'<tr class="liste_titre trheight5em">';
880 print
'<td>'.$langs->trans(
"Product").
'</td>';
882 print
'<td class="right">'.$langs->trans(
"Qty").
'</td>';
887 print
'<td class="right">'.$langs->trans(
"UnitCost").
'</td>';
890 print
'<td class="right classfortooltip" title="'.$langs->trans(
"QtyAlreadyConsumed").
'">';
891 print $langs->trans(
"QtyAlreadyConsumedShort");
895 if ($collapse || in_array($action, array(
'consumeorproduce',
'consumeandproduceall'))) {
896 print $langs->trans(
"Warehouse");
897 if (isModEnabled(
'workstation')) {
898 print
' '.$langs->trans(
"or").
' '.$langs->trans(
"Workstation");
901 if (in_array($action, array(
'consumeorproduce',
'consumeandproduceall'))) {
902 $listwarehouses = $tmpwarehouse->list_array(1);
903 if (count($listwarehouses) > 1) {
904 print
'<br>'.$form->selectarray(
'fk_default_warehouse', $listwarehouses, $fk_default_warehouse, $langs->trans(
"ForceTo"), 0, 0,
'', 0, 0, 0,
'',
'minwidth100 maxwidth200', 1);
905 } elseif (count($listwarehouses) == 1) {
906 print
'<br>'.$form->selectarray(
'fk_default_warehouse', $listwarehouses, $fk_default_warehouse, 0, 0, 0,
'', 0, 0, 0,
'',
'minwidth100 maxwidth200', 1);
912 if (isModEnabled(
'stock')) {
914 print
'<td align="right">';
915 if ($collapse || in_array($action, array(
'consumeorproduce',
'consumeandproduceall'))) {
916 print $langs->trans(
"Stock");
921 if (isModEnabled(
'productbatch')) {
923 if ($collapse || in_array($action, array(
'consumeorproduce',
'consumeandproduceall'))) {
924 print $langs->trans(
"Batch");
936 if (
$object->status == Mo::STATUS_DRAFT) {
941 if ($permissiontodelete) {
947 if ($action ==
'addconsumeline') {
948 print
'<!-- Add line to consume -->'.
"\n";
949 print
'<tr class="liste_titre">';
952 print $form->select_produits(0,
'productidtoadd',
'', 0, 0, -1, 2,
'', 1, array(), 0,
'1', 0,
'maxwidth150');
955 print
'<td class="right"><input type="text" name="qtytoadd" value="1" class="width40 right"></td>';
968 if (isModEnabled(
'stock')) {
971 if (isModEnabled(
'productbatch')) {
975 print
'<td colspan="'.$colspan.
'">';
976 print
'<input type="submit" class="button buttongen button-add" name="addconsumelinebutton" value="'.$langs->trans(
"Add").
'">';
977 print
'<input type="submit" class="button buttongen button-cancel" name="canceladdconsumelinebutton" value="'.$langs->trans(
"Cancel").
'">';
982 if (
$object->status == Mo::STATUS_DRAFT) {
986 if ($permissiontodelete) {
992 if (is_object($objectline)) {
993 $extrafields->fetch_name_optionals_label(
$object->table_element_line);
994 $temps = $objectline->showOptionals($extrafields,
'edit', array(),
'',
'',
'1',
'line');
995 if (!empty($temps)) {
996 print
'<tr class="liste_titre"><td style="padding-top: 20px" colspan="9" id="extrafield_lines_area_edit" name="extrafield_lines_area_edit">';
1005 $bomcostupdated = 0;
1008 $nblinetoconsume = 0;
1009 foreach (
$object->lines as $line) {
1010 if ($line->role ==
'toconsume') {
1015 $nblinetoconsumecursor = 0;
1016 foreach (
$object->lines as $line) {
1017 if ($line->role ==
'toconsume') {
1018 $nblinetoconsumecursor++;
1020 $tmpproduct =
new Product($db);
1021 $tmpproduct->fetch($line->fk_product);
1022 $linecost =
price2num($tmpproduct->pmp,
'MT');
1026 $costprice =
price2num((!empty($tmpproduct->cost_price)) ? $tmpproduct->cost_price : $tmpproduct->pmp);
1027 if (empty($costprice)) {
1028 require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.product.class.php';
1030 if ($productFournisseur->find_min_price_product_fournisseur($line->fk_product, $line->qty) > 0) {
1031 $costprice = $productFournisseur->fourn_unitprice;
1039 if ($useunit && $line->fk_unit > 0) {
1041 $qtyhourservice = 0;
1042 if (preg_match(
'/^(\d+)([a-z]+)$/', $tmpproduct->duration, $reg)) {
1045 $qtyhourforline = 0;
1046 if ($line->fk_unit) {
1051 if ($qtyhourservice && $qtyhourforline) {
1052 $linecost =
price2num(($qtyhourforline / $qtyhourservice * $costprice) /
$object->qty,
'MT');
1053 $bomcostupdated +=
price2num(($qtyhourforline / $qtyhourservice * $costprice) /
$object->qty,
'MU');
1056 $bomcostupdated +=
price2num(($line->qty * $costprice) /
$object->qty,
'MU');
1060 $bomcostupdated +=
price2num(($line->qty * $costprice) /
$object->qty,
'MU');
1064 $bomcostupdated =
price2num($bomcostupdated,
'MU');
1065 $arrayoflines =
$object->fetchLinesLinked(
'consumed', $line->id);
1066 $alreadyconsumed = 0;
1067 foreach ($arrayoflines as $line2) {
1068 $alreadyconsumed += $line2[
'qty'];
1071 if ($action ==
'editline' && $lineid == $line->id) {
1072 $linecost =
price2num($tmpproduct->pmp,
'MT');
1074 $arrayoflines =
$object->fetchLinesLinked(
'consumed', $line->id);
1075 $alreadyconsumed = 0;
1076 if (is_array($arrayoflines) && !empty($arrayoflines)) {
1077 foreach ($arrayoflines as $line2) {
1078 $alreadyconsumed += $line2[
'qty'];
1081 $suffix =
'_' . $line->id;
1082 print
'<!-- Line to dispatch ' . $suffix .
' (line edited) -->' .
"\n";
1084 print
'<input id="qty_ordered' . $suffix .
'" type="hidden" value="' . $line->qty .
'">';
1086 print
'<input id="qty_dispatched' . $suffix .
'" type="hidden" value="' . $alreadyconsumed .
'">';
1088 print
'<input name="lineid" type="hidden" value="' . $line->id .
'">';
1091 print
'<td>' . $tmpproduct->getNomUrl(1);
1092 print
'<br><div class="opacitymedium small tdoverflowmax150" title="' .
dol_escape_htmltag($tmpproduct->label) .
'">' . $tmpproduct->label .
'</span>';
1096 print
'<td class="right nowraponall">';
1097 print
'<input class="width40 right" name="qty_lineProduce" value="'. $line->qty.
'">';
1101 print
'<td class="right nowraponall">';
1109 if ($permissiontoupdatecost &&
getDolGlobalString(
'MRP_SHOW_COST_FOR_CONSUMPTION')) {
1114 print
'<td class="right">';
1115 print
' ' .
price2num($alreadyconsumed,
'MS');
1121 print $formproduct->selectWarehouses($line->fk_warehouse,
'warehouse_lineProduce',
'warehouseopen', 1);
1122 } elseif (isModEnabled(
'workstation')) {
1123 print $formproduct->selectWorkstations($line->fk_default_workstation,
'workstation_lineProduce', 1);
1128 if (isModEnabled(
'stock')) {
1129 print
'<td class="nowraponall right">';
1130 if ($tmpproduct->isStockManaged()) {
1131 if ($tmpproduct->stock_reel < ($line->qty - $alreadyconsumed)) {
1132 print
img_warning($langs->trans(
'StockTooLow')).
' ';
1134 print
'<span class="left">'. $tmpproduct->stock_reel .
' </span>';
1140 if (isModEnabled(
'productbatch')) {
1144 print
'<td colspan="'.(3 + (
$object->status == Mo::STATUS_DRAFT ? 1 : 0) + ($permissiontodelete ? 1 : 0)).
'">';
1145 print
'<input type="submit" class="button buttongen button-add small nominwidth" name="save" value="' . $langs->trans(
"Save") .
'">';
1146 print
'<input type="submit" class="button buttongen button-cancel small nominwidth" name="cancel" value="' . $langs->trans(
"Cancel") .
'">';
1152 if (!empty($extrafields)) {
1153 $line->fetch_optionals();
1154 $temps = $line->showOptionals($extrafields,
'edit', array(),
'',
'',
'1',
'line');
1155 if (!empty($temps)) {
1157 print
'<tr><td colspan="'.$colspan.
'"><div style="padding-top: 20px" id="extrafield_lines_area_edit" name="extrafield_lines_area_edit">';
1159 print
'</div></td></tr>';
1163 $suffix =
'_' . $line->id;
1164 print
'<!-- Line to dispatch ' . $suffix .
' -->' .
"\n";
1166 print
'<input id="qty_ordered' . $suffix .
'" type="hidden" value="' . $line->qty .
'">';
1167 print
'<input id="qty_dispatched' . $suffix .
'" type="hidden" value="' . $alreadyconsumed .
'">';
1169 print
'<tr data-line-id="' . $line->id .
'">';
1172 print
'<td>' . $tmpproduct->getNomUrl(1);
1173 print
'<br><div class="opacitymedium small tdoverflowmax150" title="' .
dol_escape_htmltag($tmpproduct->label) .
'">' . $tmpproduct->label .
'</div>';
1177 print
'<td class="right nowraponall">';
1179 if ($line->qty_frozen) {
1180 $help = ($help ?
'<br>' :
'') .
'<strong>' . $langs->trans(
"QuantityFrozen") .
'</strong>: ' .
yn(1) .
' (' . $langs->trans(
"QuantityConsumedInvariable") .
')';
1181 print $form->textwithpicto(
'', $help, -1,
'lock') .
' ';
1183 if ($line->disable_stock_change) {
1184 $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")) .
')';
1185 print $form->textwithpicto(
'', $help, -1,
'help') .
' ';
1191 print
'<td class="right nowraponall">';
1199 if ($permissiontoupdatecost &&
getDolGlobalString(
'MRP_SHOW_COST_FOR_CONSUMPTION')) {
1200 print
'<td class="right nowraponall">';
1201 print
price($linecost);
1206 print
'<td class="right">';
1207 if ($alreadyconsumed) {
1209 print
'jQuery(document).ready(function() {
1210 jQuery("#expandtoproduce' . $line->id .
'").click(function() {
1211 console.log("Expand mrp_production line ' . $line->id .
'");
1212 jQuery(".expanddetail' . $line->id .
'").toggle();';
1213 if ($nblinetoconsume == $nblinetoconsumecursor) {
1214 print
'if (jQuery("#tablelines").hasClass("nobottom")) { jQuery("#tablelines").removeClass("nobottom"); } else { jQuery("#tablelines").addClass("nobottom"); }';
1220 if (empty(
$conf->use_javascript_ajax)) {
1221 print
'<a href="' . $_SERVER[
"PHP_SELF"] .
'?collapse=' . $collapse .
',' . $line->id .
'">';
1223 print
img_picto($langs->trans(
"ShowDetails"),
"chevron-down",
'id="expandtoproduce' . $line->id .
'"');
1224 if (empty(
$conf->use_javascript_ajax)) {
1228 if ($nblinetoconsume == $nblinetoconsumecursor) {
1229 print
'<script>jQuery("#tablelines").removeClass("nobottom");</script>';
1232 print
' ' .
price2num($alreadyconsumed,
'MS');
1236 print
'<td class="tdoverflowmax100">';
1237 if ($tmpproduct->isStockManaged()) {
1239 if (
getDolGlobalString(
'STOCK_CONSUMPTION_FROM_MANUFACTURING_WAREHOUSE') && $tmpwarehouse->id > 0) {
1240 print
img_picto(
'', $tmpwarehouse->picto) .
" " . $tmpwarehouse->label;
1242 if ($line->fk_warehouse > 0) {
1243 $warehouseline =
new Entrepot($db);
1244 $warehouseline->fetch($line->fk_warehouse);
1245 print $warehouseline->getNomUrl(1);
1249 if (isModEnabled(
'workstation') && $line->fk_default_workstation > 0) {
1251 $tmpworkstation->fetch($line->fk_default_workstation);
1252 print $tmpworkstation->getNomUrl(1);
1257 if (isModEnabled(
'stock')) {
1258 print
'<td class="nowraponall right">';
1260 if (!$line->disable_stock_change && $tmpproduct->stock_reel < ($line->qty - $alreadyconsumed)) {
1261 print
img_warning($langs->trans(
'StockTooLow')) .
' ';
1263 if (!
getDolGlobalString(
'STOCK_CONSUMPTION_FROM_MANUFACTURING_WAREHOUSE') || empty($tmpwarehouse->id)) {
1264 print
price2num($tmpproduct->stock_reel,
'MS');
1267 $tmpproduct->load_stock();
1268 $wh_stock = $tmpproduct->stock_warehouse[$tmpwarehouse->id];
1269 if (!empty($wh_stock)) {
1280 if (isModEnabled(
'productbatch')) {
1291 if (
$object->status == Mo::STATUS_DRAFT) {
1292 $href = $_SERVER[
"PHP_SELF"] .
'?id=' . ((int)
$object->id) .
'&action=editline&token=' .
newToken() .
'&lineid=' . ((int) $line->id);
1293 print
'<td class="center">';
1294 print
'<a class="reposition editfielda" href="' . $href .
'">';
1295 print
img_picto($langs->trans(
'TooltipEditAndRevertStockMovement'),
'edit');
1301 if ($permissiontodelete && empty($arrayoflines)) {
1302 $href = $_SERVER[
"PHP_SELF"] .
'?id=' . ((int)
$object->id) .
'&action=deleteline&token=' .
newToken() .
'&lineid=' . ((int) $line->id);
1303 print
'<td class="center">';
1304 print
'<a class="reposition" href="' . $href .
'">';
1305 print
img_picto($langs->trans(
'TooltipDeleteAndRevertStockMovement'),
'delete');
1313 if (!empty($extrafields)) {
1314 $line->fetch_optionals();
1315 $temps = $line->showOptionals($extrafields,
'view', array(),
'',
'',
'1',
'line');
1316 if (!empty($temps)) {
1318 print
'<tr><td colspan="'.$colspan.
'"><div id="extrafield_lines_area_'.$line->id.
'" name="extrafield_lines_area_'.$line->id.
'">';
1320 print
'</div></td></tr>';
1326 foreach ($arrayoflines as $line2) {
1327 print
'<tr class="expanddetail'.$line->id.
' hideobject opacitylow">';
1331 $tmpstockmovement->id = $line2[
'fk_stock_movement'];
1332 print
'<a href="'.DOL_URL_ROOT.
'/product/stock/movement_list.php?search_ref='.$tmpstockmovement->id.
'">'.
img_picto($langs->trans(
"StockMovement"),
'movement',
'class="paddingright"').
'</a>';
1343 if ($permissiontoupdatecost &&
getDolGlobalString(
'MRP_SHOW_COST_FOR_CONSUMPTION')) {
1348 print
'<td class="right">'.$line2[
'qty'].
'</td>';
1351 print
'<td class="tdoverflowmax150">';
1352 if ($line2[
'fk_warehouse'] > 0) {
1353 $result = $tmpwarehouse->fetch($line2[
'fk_warehouse']);
1355 print $tmpwarehouse->getNomUrl(1);
1361 if (isModEnabled(
'stock')) {
1366 if (isModEnabled(
'productbatch')) {
1368 if ($line2[
'batch'] !=
'') {
1369 $tmpbatch->fetch(0, $line2[
'fk_product'], $line2[
'batch']);
1370 print $tmpbatch->getNomUrl(1);
1382 if (
$object->status == Mo::STATUS_DRAFT) {
1383 $href = $_SERVER[
"PHP_SELF"] .
'?id=' . ((int)
$object->id) .
'&action=editline&token=' .
newToken() .
'&lineid=' . ((int) $line2[
'rowid']);
1384 print
'<td class="center">';
1385 print
'<a class="reposition" href="' . $href .
'">';
1386 print
img_picto($langs->trans(
'TooltipEditAndRevertStockMovement'),
'edit');
1392 if ($permissiontodelete) {
1393 $href = $_SERVER[
"PHP_SELF"].
'?id='.((int)
$object->id).
'&action=deleteline&token='.
newToken().
'&lineid='.((int) $line2[
'rowid']).
'&fk_movement='.((int) $line2[
'fk_stock_movement']);
1394 print
'<td class="center">';
1395 print
'<a class="reposition" href="'.$href.
'">';
1396 print
img_picto($langs->trans(
'TooltipDeleteAndRevertStockMovement'),
'delete');
1404 if (in_array($action, array(
'consumeorproduce',
'consumeandproduceall'))) {
1406 print
'<!-- Enter line to consume -->'.
"\n";
1408 print
'<tr data-max-qty="'.$maxQty.
'" name="batch_'.$line->id.
'_'.$i.
'">';
1410 print
'<td><span class="opacitymedium">'.$langs->trans(
"ToConsume").
'</span></td>';
1411 $preselected = (GETPOSTISSET(
'qty-'.$line->id.
'-'.$i) ?
GETPOST(
'qty-'.$line->id.
'-'.$i) : max(0, $line->qty - $alreadyconsumed));
1412 if ($action ==
'consumeorproduce' && !
getDolGlobalString(
'MRP_AUTO_SET_REMAINING_QUANTITIES_TO_BE_CONSUMED') && !GETPOSTISSET(
'qty-'.$line->id.
'-'.$i)) {
1417 if (
getDolGlobalString(
'MRP_NEVER_CONSUME_MORE_THAN_EXPECTED') && ($line->qty - $alreadyconsumed) <= 0) {
1418 $disable =
'disabled';
1422 print
'<input type="hidden" name="product-'.$line->id.
'-'.$i.
'" value="'.$line->fk_product.
'">';
1425 print
'<td class="right">';
1426 if ((
int) $tmpproduct->stockable_product > 0) {
1427 print
'<input type="text" class="width50 right" id="qtytoconsume-' . $line->id .
'-' . $i .
'" name="qty-' . $line->id .
'-' . $i .
'" value="' . $preselected .
'" ' . $disable .
'>';
1429 print
'<input type="hidden" id="qtytoconsume-' . $line->id .
'-' . $i .
'" name="qty-' . $line->id .
'-' . $i .
'" value="0">';
1430 print
'<span class="opacitymedium">' . $langs->trans(
"StockDisabled") .
'</span>';
1438 if ($permissiontoupdatecost &&
getDolGlobalString(
'MRP_SHOW_COST_FOR_CONSUMPTION')) {
1448 && ((
int) $tmpproduct->stockable_product > 0)) {
1449 if (empty($line->disable_stock_change)) {
1450 $preselected = (GETPOSTISSET(
'idwarehouse-'.$line->id.
'-'.$i) ?
GETPOST(
'idwarehouse-'.$line->id.
'-'.$i) : ($tmpproduct->fk_default_warehouse > 0 ? $tmpproduct->fk_default_warehouse :
'ifone'));
1451 print $formproduct->selectWarehouses($preselected,
'idwarehouse-'.$line->id.
'-'.$i,
'', 1, 0, $line->fk_product,
'', 1, 0, array(),
'maxwidth200 csswarehouse_'.$line->id.
'_'.$i);
1453 print
'<span class="opacitymedium">'.$langs->trans(
"DisableStockChange").
'</span>';
1456 if ((
int) $tmpproduct->stockable_product > 0) {
1457 print
'<span class="opacitymedium">' . $langs->trans(
"StockDisabled") .
'</span>';
1459 print
'<span class="opacitymedium">' . $langs->trans(
"NoStockChangeOnServices") .
'</span>';
1465 if (isModEnabled(
'stock')) {
1470 if (isModEnabled(
'productbatch')) {
1471 print
'<td class="nowraponall">';
1472 if ($tmpproduct->status_batch) {
1473 $preselected = (GETPOSTISSET(
'batch-'.$line->id.
'-'.$i) ?
GETPOST(
'batch-'.$line->id.
'-'.$i) :
'');
1474 print
'<input type="text" class="width75" name="batch-'.$line->id.
'-'.$i.
'" value="'.$preselected.
'" list="batch-'.$line->id.
'-'.$i.
'">';
1475 print $formproduct->selectLotDataList(
'batch-'.$line->id.
'-'.$i, 0, $line->fk_product, 0, array());
1482 print
'<td align="right" class="split">';
1483 print
' '.img_picto($langs->trans(
'AddStockLocationLine'),
'split.png',
'class="splitbutton" onClick="addDispatchLine('.((int) $line->id).
', \''.
dol_escape_js($type).
'\', \
'qtymissingconsume\')"');
1487 print
'<td align="right" class="splitall">';
1488 if (($action ==
'consumeorproduce' || $action ==
'consumeandproduceall') && $tmpproduct->status_batch == 2) {
1489 print
img_picto($langs->trans(
'SplitAllQuantity'),
'split.png',
'class="splitbutton splitallbutton field-error-icon" data-max-qty="1" onClick="addDispatchLine('.$line->id.
', \'batch\', \'allmissingconsume\')"');
1494 if (
$object->status == Mo::STATUS_DRAFT) {
1499 if ($permissiontodelete) {
1513 print
'<script type="text/javascript">
1514 $(document).ready(function () {
1515 $("select[name=fk_default_warehouse]").change(function() {
1516 var fk_default_warehouse = $("option:selected", this).val();
1517 $("select[name^=idwarehouse-]").val(fk_default_warehouse).change();
1522 if (in_array($action, array(
'consumeorproduce',
'consumeandproduceall')) &&
1524 print
'<script>$(document).ready(function () {
1525 $("#fk_default_warehouse").change();
1533 print
'<div class="fichehalfright">';
1534 print
'<div class="clearboth"></div>';
1536 $nblinetoproduce = 0;
1537 foreach (
$object->lines as $line) {
1538 if ($line->role ==
'toproduce') {
1543 $newcardbutton =
'';
1544 $url = $_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=addproduceline&token='.
newToken();
1545 $permissiontoaddaproductline =
$object->status != $object::STATUS_PRODUCED &&
$object->status != $object::STATUS_CANCELED;
1546 $parameters = array(
'morecss' =>
'reposition');
1547 if ($action !=
'consumeorproduce' && $action !=
'consumeandproduceall') {
1548 if ($nblinetoproduce == 0 ||
$object->mrptype == 1) {
1549 $newcardbutton =
dolGetButtonTitle($langs->trans(
'AddNewProduceLines'),
'',
'fa fa-plus-circle size15x', $url,
'', (
int) $permissiontoaddaproductline, $parameters);
1553 print
load_fiche_titre($langs->trans(
'Production'), $newcardbutton,
'', 0,
'',
'');
1555 print
'<div class="div-table-responsive-no-min">';
1556 print
'<table id="tablelinestoproduce" class="noborder noshadow nobottom centpercent">';
1558 print
'<tr class="liste_titre trheight5em">';
1560 print
'<td>'.$langs->trans(
"Product").
'</td>';
1562 print
'<td class="right">'.$langs->trans(
"Qty").
'</td>';
1565 print
'<td class="right">'.$langs->trans(
"Unit").
'</td>';
1568 if ($permissiontoupdatecost) {
1569 if (empty($bomcostupdated)) {
1570 print
'<td class="right classfortooltip" title="'.$langs->trans(
"AmountUsedToUpdateWAP").
'">';
1571 print $langs->trans(
"UnitCost");
1574 print
'<td class="right classfortooltip" title="'.$langs->trans(
"AmountUsedToUpdateWAP").
'">';
1575 print $langs->trans(
"ManufacturingPrice");
1580 print
'<td class="right classfortooltip" title="'.$langs->trans(
"QtyAlreadyProduced").
'">';
1581 print $langs->trans(
"QtyAlreadyProducedShort");
1585 if ($collapse || in_array($action, array(
'consumeorproduce',
'consumeandproduceall'))) {
1586 print $langs->trans(
"Warehouse");
1591 if (isModEnabled(
'productbatch')) {
1593 if ($collapse || in_array($action, array(
'consumeorproduce',
'consumeandproduceall'))) {
1594 print $langs->trans(
"Batch");
1606 if ($permissiontodelete) {
1612 if ($action ==
'addproduceline') {
1613 print
'<!-- Add line to produce -->'.
"\n";
1614 print
'<tr class="liste_titre">';
1618 print $form->select_produits(0,
'productidtoadd',
'', 0, 0, -1, 2,
'', 1, array(), 0,
'1', 0,
'maxwidth300');
1621 print
'<td class="right"><input type="text" name="qtytoadd" value="1" class="width50 right"></td>';
1627 if ($permissiontoupdatecost) {
1631 print
'<td colspan="2">';
1632 print
'<input type="submit" class="button buttongen button-add" name="addproducelinebutton" value="'.$langs->trans(
"Add").
'">';
1633 print
'<input type="submit" class="button buttongen button-cancel" name="canceladdproducelinebutton" value="'.$langs->trans(
"Cancel").
'">';
1636 if (isModEnabled(
'productbatch')) {
1646 if ($permissiontodelete) {
1653 $nblinetoproduce = 0;
1654 foreach (
$object->lines as $line) {
1655 if ($line->role ==
'toproduce') {
1660 $nblinetoproducecursor = 0;
1661 foreach (
$object->lines as $line) {
1662 if ($line->role ==
'toproduce') {
1665 $nblinetoproducecursor++;
1667 $tmpproduct =
new Product($db);
1668 $tmpproduct->fetch($line->fk_product);
1670 $arrayoflines =
$object->fetchLinesLinked(
'produced', $line->id);
1671 $alreadyproduced = 0;
1672 foreach ($arrayoflines as $line2) {
1673 $alreadyproduced += $line2[
'qty'];
1676 $suffix =
'_'.$line->id;
1677 print
'<!-- Line to dispatch '.$suffix.
' (toproduce) -->'.
"\n";
1679 print
'<input id="qty_ordered'.$suffix.
'" type="hidden" value="'.$line->qty.
'">';
1680 print
'<input id="qty_dispatched'.$suffix.
'" type="hidden" value="'.$alreadyproduced.
'">';
1684 print
'<td>'.$tmpproduct->getNomUrl(1);
1685 print
'<br><span class="opacitymedium small">'.$tmpproduct->label.
'</span>';
1688 print
'<td class="right">'.$line->qty.
'</td>';
1691 print
'<td class="right">'.measuringUnitString($line->fk_unit,
'',
null, 1).
'</td>';
1694 if ($permissiontoupdatecost) {
1696 $manufacturingcost = 0;
1697 $manufacturingcostsrc =
'';
1699 $manufacturingcost = $bomcostupdated;
1700 $manufacturingcostsrc = $langs->trans(
"CalculatedFromProductsToConsume");
1701 if (empty($manufacturingcost)) {
1702 $manufacturingcost = $bomcost;
1703 $manufacturingcostsrc = $langs->trans(
"ValueFromBom");
1705 if (empty($manufacturingcost)) {
1706 $manufacturingcost =
price2num($tmpproduct->cost_price,
'MU');
1707 $manufacturingcostsrc = $langs->trans(
"CostPrice");
1709 if (empty($manufacturingcost)) {
1710 $manufacturingcost =
price2num($tmpproduct->pmp,
'MU');
1711 $manufacturingcostsrc = $langs->trans(
"PMPValue");
1715 print
'<td class="right nowraponall" title="'.dol_escape_htmltag($manufacturingcostsrc).
'">';
1716 if ($manufacturingcost) {
1717 print
price($manufacturingcost);
1722 print
'<td class="right nowraponall">';
1723 if ($alreadyproduced) {
1725 print
'jQuery(document).ready(function() {
1726 jQuery("#expandtoproduce'.$line->id.
'").click(function() {
1727 console.log("Expand mrp_production line '.$line->id.
'");
1728 jQuery(".expanddetailtoproduce'.$line->id.
'").toggle();';
1729 if ($nblinetoproduce == $nblinetoproducecursor) {
1730 print
'if (jQuery("#tablelinestoproduce").hasClass("nobottom")) { jQuery("#tablelinestoproduce").removeClass("nobottom"); } else { jQuery("#tablelinestoproduce").addClass("nobottom"); }';
1736 if (empty(
$conf->use_javascript_ajax)) {
1737 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?collapse='.$collapse.
','.$line->id.
'">';
1739 print
img_picto($langs->trans(
"ShowDetails"),
"chevron-down",
'id="expandtoproduce'.$line->id.
'"');
1740 if (empty(
$conf->use_javascript_ajax)) {
1744 print
' '.$alreadyproduced;
1750 if (isModEnabled(
'productbatch')) {
1760 if ($permissiontodelete) {
1761 if ($line->origin_type ==
'free') {
1762 $href = $_SERVER[
"PHP_SELF"];
1763 $href .=
'?id='.$object->id;
1764 $href .=
'&action=deleteline';
1765 $href .=
'&token='.newToken();
1766 $href .=
'&lineid='.$line->id;
1767 print
'<td class="center">';
1768 print
'<a class="reposition" href="'.$href.
'">';
1769 print
img_picto($langs->trans(
'TooltipDeleteAndRevertStockMovement'),
"delete");
1779 foreach ($arrayoflines as $line2) {
1780 print
'<tr class="expanddetailtoproduce'.$line->id.
' hideobject opacitylow">';
1783 $tmpstockmovement->id = $line2[
'fk_stock_movement'];
1784 print
'<a href="'.DOL_URL_ROOT.
'/product/stock/movement_list.php?search_ref='.$tmpstockmovement->id.
'">'.
img_picto($langs->trans(
"StockMovement"),
'movement',
'class="paddingright"').
'</a>';
1794 if ($permissiontoupdatecost) {
1798 print
'<td class="right">'.$line2[
'qty'].
'</td>';
1800 print
'<td class="tdoverflowmax150">';
1801 if ($line2[
'fk_warehouse'] > 0) {
1802 $result = $tmpwarehouse->fetch($line2[
'fk_warehouse']);
1804 print $tmpwarehouse->getNomUrl(1);
1809 if (isModEnabled(
'productbatch')) {
1811 if ($line2[
'batch'] !=
'') {
1812 $tmpbatch->fetch(0, $line2[
'fk_product'], $line2[
'batch']);
1813 print $tmpbatch->getNomUrl(1);
1824 if ($permissiontodelete) {
1830 if (in_array($action, array(
'consumeorproduce',
'consumeandproduceall'))) {
1831 print
'<!-- Enter line to produce -->'.
"\n";
1833 print
'<tr data-max-qty="'.$maxQty.
'" name="batch_'.$line->id.
'_'.$i.
'">';
1835 print
'<td><span class="opacitymedium">'.$langs->trans(
"ToProduce").
'</span></td>';
1836 $preselected = (GETPOSTISSET(
'qtytoproduce-'.$line->id.
'-'.$i) ?
GETPOST(
'qtytoproduce-'.$line->id.
'-'.$i) : max(0, $line->qty - $alreadyproduced));
1837 if ($action ==
'consumeorproduce' && !GETPOSTISSET(
'qtytoproduce-'.$line->id.
'-'.$i)) {
1841 print
'<td class="right"><input type="text" class="width50 right" id="qtytoproduce-'.$line->id.
'-'.$i.
'" name="qtytoproduce-'.$line->id.
'-'.$i.
'" value="'.$preselected.
'"></td>';
1844 print
'<td class="right"></td>';
1847 if ($permissiontoupdatecost) {
1849 $manufacturingcost = 0;
1850 $manufacturingcostsrc =
'';
1852 $manufacturingcost = $bomcostupdated;
1853 $manufacturingcostsrc = $langs->trans(
"CalculatedFromProductsToConsume");
1854 if (empty($manufacturingcost)) {
1855 $manufacturingcost = $bomcost;
1856 $manufacturingcostsrc = $langs->trans(
"ValueFromBom");
1858 if (empty($manufacturingcost)) {
1859 $manufacturingcost =
price2num($tmpproduct->cost_price,
'MU');
1860 $manufacturingcostsrc = $langs->trans(
"CostPrice");
1862 if (empty($manufacturingcost)) {
1863 $manufacturingcost =
price2num($tmpproduct->pmp,
'MU');
1864 $manufacturingcostsrc = $langs->trans(
"PMPValue");
1869 $preselected = (GETPOSTISSET(
'pricetoproduce-'.$line->id.
'-'.$i) ?
GETPOST(
'pricetoproduce-'.$line->id.
'-'.$i) : ($manufacturingcost ?
price($manufacturingcost) :
''));
1870 print
'<td class="right"><input type="text" class="width75 right" name="pricetoproduce-'.$line->id.
'-'.$i.
'" value="'.$preselected.
'"></td>';
1872 print
'<td><input type="hidden" class="width50 right" name="pricetoproduce-'.$line->id.
'-'.$i.
'" value="'.($manufacturingcost ? $manufacturingcost :
'').
'"></td>';
1880 $preselected = (GETPOSTISSET(
'idwarehousetoproduce-'.$line->id.
'-'.$i) ?
GETPOST(
'idwarehousetoproduce-'.$line->id.
'-'.$i) : (
$object->fk_warehouse > 0 ?
$object->fk_warehouse :
'ifone'));
1881 print $formproduct->selectWarehouses($preselected,
'idwarehousetoproduce-'.$line->id.
'-'.$i,
'', 1, 0, $line->fk_product,
'', 1, 0, array(),
'maxwidth200 csswarehouse_'.$line->id.
'_'.$i);
1883 print
'<span class="opacitymedium">'.$langs->trans(
"NoStockChangeOnServices").
'</span>';
1887 if (isModEnabled(
'productbatch')) {
1889 if ($tmpproduct->status_batch) {
1890 $preselected = (GETPOSTISSET(
'batchtoproduce-'.$line->id.
'-'.$i) ?
GETPOST(
'batchtoproduce-'.$line->id.
'-'.$i) :
'');
1891 print
'<input type="text" class="width75" name="batchtoproduce-'.$line->id.
'-'.$i.
'" value="'.$preselected.
'">';
1895 if ($tmpproduct->status_batch) {
1897 print
'<td align="right" class="split">';
1898 print
img_picto($langs->trans(
'AddStockLocationLine'),
'split.png',
'class="splitbutton" onClick="addDispatchLine('.$line->id.
', \''.$type.
'\', \
'qtymissing\')"');
1901 print
'<td align="right" class="splitall">';
1902 if (($action ==
'consumeorproduce' || $action ==
'consumeandproduceall') && $tmpproduct->status_batch == 2) {
1903 print
img_picto($langs->trans(
'SplitAllQuantity'),
'split.png',
'class="splitbutton splitallbutton field-error-icon" onClick="addDispatchLine('.$line->id.
', \'batch\', \'alltoproduce\')"');
1929 if (in_array($action, array(
'consumeorproduce',
'consumeandproduceall',
'addconsumeline'))) {
1933 <script
type=
"text/javascript" language=
"javascript">
1935 $(document).ready(
function() {
1937 updateselectbatchbywarehouse();
1939 updateselectwarehousebybatch();
1942 function updateselectbatchbywarehouse() {
1943 $(document).on(
'change',
"select[name*='idwarehouse']",
function () {
1944 console.log(
"We change warehouse so we update the list of possible batch number");
1946 var selectwarehouse = $(
this);
1948 var selectbatch_name = selectwarehouse.attr(
'name').replace(
'idwarehouse',
'batch');
1949 var selectbatch = $(
"datalist[id*='" + selectbatch_name +
"']");
1950 var selectedbatch = selectbatch.val();
1952 var product_element_name = selectwarehouse.attr(
'name').replace(
'idwarehouse',
'product');
1956 url:
"<?php echo DOL_URL_ROOT . '/mrp/ajax/interface.php'; ?>",
1958 action:
"updateselectbatchbywarehouse",
1959 permissiontoproduce: <?php echo $permissiontoproduce ?>,
1960 warehouse_id: $(
this).val(),
1961 token:
'<?php echo currentToken(); ?>',
1962 product_id: $(
"input[name='" + product_element_name +
"']").val()
1964 }).done(
function (data) {
1966 selectbatch.empty();
1968 if (typeof data ==
"object") {
1969 console.log(
"data is already type object, no need to parse it");
1971 console.log(
"data is type "+(typeof data));
1972 data = JSON.parse(data);
1975 selectbatch.append($(
'<option>', {
1979 $.each(data,
function (key, value) {
1981 if(selectwarehouse.val() == -1) {
1982 var label = key +
" (<?php echo $langs->trans('TotalStock') ?> : " + value +
")";
1984 var label = key +
" (<?php echo $langs->trans('Stock') ?> : " + value +
")";
1987 if(key === selectedbatch) {
1988 var option =
'<option value="'+key+
'" selected>'+ label +
'</option>';
1990 var option =
'<option value="'+key+
'">'+ label +
'</option>';
1993 selectbatch.append(option);
1999 function updateselectwarehousebybatch() {
2000 $(document).on(
'change',
'input[name*=batch]',
function(){
2001 console.log(
"We change batch so we update the list of possible warehouses");
2003 var selectbatch = $(
this);
2005 var selectwarehouse_name = selectbatch.attr(
'name').replace(
'batch',
'idwarehouse');
2006 var selectwarehouse = $(
"select[name*='" + selectwarehouse_name +
"']");
2007 var selectedwarehouse = selectwarehouse.val();
2009 if(selectedwarehouse != -1){
2013 var product_element_name = selectbatch.attr(
'name').replace(
'batch',
'product');
2017 url:
"<?php echo DOL_URL_ROOT . '/mrp/ajax/interface.php'; ?>",
2019 action:
"updateselectwarehousebybatch",
2020 permissiontoproduce: <?php echo $permissiontoproduce ?>,
2021 batch: $(
this).val(),
2022 token:
'<?php echo currentToken(); ?>',
2023 product_id: $(
"input[name='" + product_element_name +
"']").val()
2025 }).done(
function (data) {
2027 if (typeof data ==
"object") {
2028 console.log(
"data is already type object, no need to parse it");
2030 console.log(
"data is type "+(typeof data));
2031 data = JSON.parse(data);
2035 selectwarehouse.val(data).change();
$id
Support class for third parties, contacts, members, users or resources.
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $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.
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
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.
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.
dol_now($mode='auto')
Return date for now.
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.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
newToken()
Return the value of token currently saved into session with name 'newtoken'.
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.
GETPOSTFLOAT($paramname, $rounding='')
Return the value of a $_GET or $_POST supervariable, converted into float.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
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...
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
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
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.