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 &&
$object->status == $object::STATUS_PRODUCED) {
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);
261 if (in_array($action, array(
'confirm_consumeorproduce',
'confirm_consumeandproduceall')) &&
$object->status != $object::STATUS_VALIDATED &&
$object->status != $object::STATUS_INPROGRESS) {
262 $langs->load(
"errors");
267 if (in_array($action, array(
'confirm_consumeorproduce',
'confirm_consumeandproduceall')) && $permissiontoproduce) {
270 $labelmovement =
GETPOST(
'inventorylabel',
'alphanohtml');
271 $codemovement =
GETPOST(
'inventorycode',
'alphanohtml');
276 foreach (
$object->lines as $line) {
277 if ($line->role ==
'toconsume') {
278 $tmpproduct =
new Product($db);
279 $tmpproduct->fetch($line->fk_product);
282 while (GETPOSTISSET(
'qty-'.$line->id.
'-'.$i)) {
285 if ($qtytoprocess != 0) {
287 if (GETPOSTISSET(
'idwarehouse-'.$line->id.
'-'.$i)) {
288 if (!(
GETPOST(
'idwarehouse-'.$line->id.
'-'.$i) > 0)) {
289 $langs->load(
"errors");
290 setEventMessages($langs->trans(
"ErrorFieldRequiredForProduct", $langs->transnoentitiesnoconv(
"Warehouse"), $tmpproduct->ref),
null,
'errors');
293 if (isModEnabled(
'productbatch') && $tmpproduct->status_batch && (!
GETPOST(
'batch-'.$line->id.
'-'.$i))) {
294 $langs->load(
"errors");
295 setEventMessages($langs->trans(
"ErrorFieldRequiredForProduct", $langs->transnoentitiesnoconv(
"Batch"), $tmpproduct->ref),
null,
'errors');
301 if (!$error &&
GETPOST(
'idwarehouse-'.$line->id.
'-'.$i) > 0) {
303 $id_product_batch = 0;
305 $stockmove->context[
'mrp_role'] =
'toconsume';
307 if ($qtytoprocess >= 0) {
308 $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);
310 $idstockmove = $stockmove->reception($user, $line->fk_product,
GETPOSTINT(
'idwarehouse-'.$line->id.
'-'.$i), $qtytoprocess * -1, 0, $labelmovement,
'',
'',
GETPOST(
'batch-'.$line->id.
'-'.$i),
dol_now(), $id_product_batch, $codemovement);
312 if ($idstockmove < 0) {
320 $moline =
new MoLine($db);
322 $moline->position = $pos;
323 $moline->fk_product = $line->fk_product;
324 $moline->fk_warehouse =
GETPOSTINT(
'idwarehouse-'.$line->id.
'-'.$i);
325 $moline->qty = $qtytoprocess;
326 $moline->batch =
GETPOST(
'batch-'.$line->id.
'-'.$i);
327 $moline->role =
'consumed';
328 $moline->fk_mrp_production = $line->id;
329 $moline->fk_stock_movement = $idstockmove == 0 ? null : $idstockmove;
330 $moline->fk_user_creat = $user->id;
332 $resultmoline = $moline->create($user);
333 if ($resultmoline <= 0) {
350 foreach (
$object->lines as $line) {
351 if ($line->role ==
'toproduce') {
352 $tmpproduct =
new Product($db);
353 $tmpproduct->fetch($line->fk_product);
356 while (GETPOSTISSET(
'qtytoproduce-'.$line->id.
'-'.$i)) {
357 $qtytoprocess = (float)
price2num(
GETPOST(
'qtytoproduce-'.$line->id.
'-'.$i));
358 $pricetoprocess =
GETPOST(
'pricetoproduce-'.$line->id.
'-'.$i) ?
price2num(
GETPOST(
'pricetoproduce-'.$line->id.
'-'.$i)) : 0;
360 if ($qtytoprocess != 0) {
362 if (GETPOSTISSET(
'idwarehousetoproduce-'.$line->id.
'-'.$i)) {
363 if (!(
GETPOST(
'idwarehousetoproduce-'.$line->id.
'-'.$i) > 0)) {
364 $langs->load(
"errors");
365 setEventMessages($langs->trans(
"ErrorFieldRequiredForProduct", $langs->transnoentitiesnoconv(
"Warehouse"), $tmpproduct->ref),
null,
'errors');
368 if (isModEnabled(
'productbatch') && $tmpproduct->status_batch && (!
GETPOST(
'batchtoproduce-'.$line->id.
'-'.$i))) {
369 $langs->load(
"errors");
370 setEventMessages($langs->trans(
"ErrorFieldRequiredForProduct", $langs->transnoentitiesnoconv(
"Batch"), $tmpproduct->ref),
null,
'errors');
376 if (!$error &&
GETPOST(
'idwarehousetoproduce-'.$line->id.
'-'.$i) > 0) {
378 $id_product_batch = 0;
379 $stockmove->origin_type =
$object->element;
380 $stockmove->origin_id =
$object->id;
381 $stockmove->context[
'mrp_role'] =
'toproduce';
383 $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);
384 if ($idstockmove < 0) {
392 $moline =
new MoLine($db);
394 $moline->position = $pos;
395 $moline->fk_product = $line->fk_product;
396 $moline->fk_warehouse =
GETPOSTINT(
'idwarehousetoproduce-'.$line->id.
'-'.$i);
397 $moline->qty = $qtytoprocess;
398 $moline->batch =
GETPOST(
'batchtoproduce-'.$line->id.
'-'.$i);
399 $moline->role =
'produced';
400 $moline->fk_mrp_production = $line->id;
401 $moline->fk_stock_movement = $idstockmove;
402 $moline->fk_user_creat = $user->id;
404 $resultmoline = $moline->create($user);
405 if ($resultmoline <= 0) {
420 $consumptioncomplete =
true;
421 $productioncomplete =
true;
424 foreach (
$object->lines as $line) {
425 $tmpproduct =
new Product($db);
426 $tmpproduct->fetch($line->fk_product);
427 if ((
int) $tmpproduct->stockable_product > 0) {
428 if ($line->role ==
'toconsume') {
429 $arrayoflines =
$object->fetchLinesLinked(
'consumed', $line->id);
430 $alreadyconsumed = 0;
431 foreach ($arrayoflines as $line2) {
432 $alreadyconsumed += $line2[
'qty'];
435 if ($alreadyconsumed < $line->qty) {
436 $consumptioncomplete =
false;
439 if ($line->role ==
'toproduce') {
440 $arrayoflines =
$object->fetchLinesLinked(
'produced', $line->id);
441 $alreadyproduced = 0;
442 foreach ($arrayoflines as $line2) {
443 $alreadyproduced += $line2[
'qty'];
446 if ($alreadyproduced < $line->qty) {
447 $productioncomplete =
false;
453 $consumptioncomplete =
false;
454 $productioncomplete =
false;
458 dol_syslog(
"consumptioncomplete = ".json_encode($consumptioncomplete).
" productioncomplete = ".json_encode($productioncomplete));
459 if ($consumptioncomplete && $productioncomplete) {
460 $result =
$object->setStatut($object::STATUS_PRODUCED, 0,
'',
'MRP_MO_PRODUCED');
462 $result =
$object->setStatut($object::STATUS_INPROGRESS, 0,
'',
'MRP_MO_PRODUCED');
471 $action = str_replace(
'confirm_',
'', $action);
477 header(
"Location: ".$_SERVER[
"PHP_SELF"].
'?id='.
$object->id);
483 if ($action ==
'confirm_produced' && $confirm ==
'yes' && $permissiontoadd) {
484 $result =
$object->setStatut($object::STATUS_PRODUCED, 0,
'',
'MRP_MO_PRODUCED');
488 $outputlangs = $langs;
491 $newlang =
GETPOST(
'lang_id',
'aZ09');
494 $newlang =
$object->thirdparty->default_lang;
496 if (!empty($newlang)) {
498 $outputlangs->setDefaultLang($newlang);
503 $object->generateDocument($model, $outputlangs, 0, 0, 0);
510 if ($action ==
'confirm_editline' && $permissiontoadd && !in_array(
$object->status, array($object::STATUS_PRODUCED, $object::STATUS_CANCELED))) {
511 $moline =
new MoLine($db);
512 $result = $moline->fetch(
GETPOSTINT(
'lineid'));
513 if ($result > 0 && $moline->fk_mo !=
$object->id) {
516 if ($result > 0 && in_array($moline->role, array(
'consumed',
'produced'))) {
520 $extrafields->fetch_name_optionals_label($moline->element);
521 foreach ($extrafields->attributes[$moline->table_element][
'label'] as $key => $label) {
522 $value =
GETPOST(
'options_'.$key,
'alphanohtml');
523 $moline->array_options[
"options_".$key] = $value;
526 if (GETPOSTISSET(
'warehouse_lineProduce')) {
527 $moline->fk_warehouse = (
GETPOSTINT(
'warehouse_lineProduce') > 0 ?
GETPOSTINT(
'warehouse_lineProduce') : 0);
529 if (GETPOSTISSET(
'workstation_lineProduce')) {
530 $moline->fk_default_workstation = (
GETPOSTINT(
'workstation_lineProduce') > 0 ?
GETPOSTINT(
'workstation_lineProduce') : 0);
533 $res = $moline->update($user);
537 header(
"Location: ".$_SERVER[
"PHP_SELF"].
'?id='.
$object->id);
540 header(
"Location: ".$_SERVER[
"PHP_SELF"].
'?id='.
$object->id);
552$form =
new Form($db);
559$title = $langs->trans(
'Mo');
560$help_url =
'EN:Module_Manufacturing_Orders|FR:Module_Ordres_de_Fabrication|DE:Modul_Fertigungsauftrag';
561$morejs = array(
'/mrp/js/lib_dispatch.js.php');
562llxHeader(
'', $title, $help_url,
'', 0, 0, $morejs,
'',
'',
'mod-mrp page-card_production');
567if (
$object->id > 0 && (empty($action) || ($action !=
'edit' && $action !=
'create'))) {
568 $res =
$object->fetch_thirdparty();
569 $res =
$object->fetch_optionals();
572 $tmpwarehouse->fetch(
$object->fk_warehouse);
573 $fk_default_warehouse =
$object->fk_warehouse;
583 if ($action ==
'delete') {
584 $formquestion = array(
586 'label' => $langs->trans(
'MoCancelConsumedAndProducedLines'),
587 'name' =>
'alsoCancelConsumedAndProducedLines',
588 'type' =>
'checkbox',
592 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'DeleteMo'), $langs->trans(
'ConfirmDeleteMo'),
'confirm_delete', $formquestion, 0, 1);
595 if ($action ==
'deleteline') {
596 $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);
599 if ($action ==
'clone') {
601 $formquestion = array();
602 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'ToClone'), $langs->trans(
'ConfirmCloneMo',
$object->ref),
'confirm_clone', $formquestion,
'yes', 1);
606 if ($action ==
'validate') {
608 $ref = substr(
$object->ref, 1, 4);
609 if ($ref ==
'PROV') {
616 $text = $langs->trans(
'ConfirmValidateMo', $numref);
625 $formquestion = array();
626 if (isModEnabled(
'mrp')) {
628 require_once DOL_DOCUMENT_ROOT.
'/product/class/html.formproduct.class.php';
631 if (
$conf->browser->name ==
'ie') {
634 $formquestion = array(
641 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'Validate'), $text,
'confirm_validate', $formquestion, 0, 1, 220);
645 if ($action ==
'cancel') {
646 $formquestion = array(
648 'label' => $langs->trans(
'MoCancelConsumedAndProducedLines'),
649 'name' =>
'alsoCancelConsumedAndProducedLines',
650 'type' =>
'checkbox',
651 'value' => !
getDolGlobalString(
'MO_ALSO_CANCEL_CONSUMED_AND_PRODUCED_LINES_BY_DEFAULT') ? 0 : 1
654 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"] .
'?id=' .
$object->id, $langs->trans(
'CancelMo'), $langs->trans(
'ConfirmCancelMo'),
'confirm_cancel', $formquestion, 0, 1);
658 $parameters = array(
'formConfirm' => $formconfirm,
'lineid' => $lineid);
659 $reshook = $hookmanager->executeHooks(
'formConfirm', $parameters, $object, $action);
660 if (empty($reshook)) {
661 $formconfirm .= $hookmanager->resPrint;
662 } elseif ($reshook > 0) {
663 $formconfirm = $hookmanager->resPrint;
672 $linkback =
'<a href="'.DOL_URL_ROOT.
'/mrp/mo_list.php?restore_lastsearch_values=1'.(!empty($socid) ?
'&socid='.$socid :
'').
'">'.$langs->trans(
"BackToList").
'</a>';
674 $morehtmlref =
'<div class="refidno">';
683 if (is_object(
$object->thirdparty)) {
684 $morehtmlref .=
$object->thirdparty->getNomUrl(1,
'customer');
686 $morehtmlref .=
' (<a href="'.DOL_URL_ROOT.
'/commande/list.php?socid='.
$object->thirdparty->id.
'">'.$langs->trans(
"OtherOrders").
'</a>)';
691 if (isModEnabled(
'project')) {
692 $langs->load(
"projects");
693 if (is_object(
$object->thirdparty)) {
694 $morehtmlref .=
'<br>';
696 if ($permissiontoadd) {
697 $morehtmlref .=
img_picto($langs->trans(
"Project"),
'project',
'class="pictofixedwidth"');
698 if ($action !=
'classify') {
699 $morehtmlref .=
'<a class="editfielda" href="'.$_SERVER[
'PHP_SELF'].
'?action=classify&token='.
newToken().
'&id='.
$object->id.
'">'.
img_edit($langs->transnoentitiesnoconv(
'SetProject')).
'</a> ';
701 $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');
703 if (!empty(
$object->fk_project)) {
705 $proj->fetch(
$object->fk_project);
706 $morehtmlref .= $proj->getNomUrl(1);
708 $morehtmlref .=
'<span class="opacitymedium"> - '.dol_escape_htmltag($proj->title).
'</span>';
713 $morehtmlref .=
'</div>';
716 dol_banner_tab($object,
'ref', $linkback, 1,
'ref',
'ref', $morehtmlref);
719 print
'<div class="fichecenter">';
720 print
'<div class="fichehalfleft">';
721 print
'<div class="underbanner clearboth"></div>';
722 print
'<table class="border centpercent tableforfield">'.
"\n";
725 $keyforbreak =
'fk_warehouse';
726 unset(
$object->fields[
'fk_project']);
727 unset(
$object->fields[
'fk_soc']);
728 include DOL_DOCUMENT_ROOT.
'/core/tpl/commonfields_view.tpl.php';
731 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_view.tpl.php';
737 print
'<div class="clearboth"></div>';
742 if (!in_array($action, array(
'consumeorproduce',
'consumeandproduceall'))) {
743 print
'<div class="tabsAction">';
745 $parameters = array();
747 $reshook = $hookmanager->executeHooks(
'addMoreActionsButtons', $parameters, $object, $action);
748 if (empty($reshook)) {
750 if (
$object->status == $object::STATUS_DRAFT) {
751 if ($permissiontoadd) {
753 print
'<a class="butAction" href="'.$_SERVER[
'PHP_SELF'].
'?id='.
$object->id.
'&action=validate&token='.$newToken.
'">'.$langs->trans(
"Validate").
'</a>';
755 $langs->load(
"errors");
756 print
'<a class="butActionRefused" href="" title="'.$langs->trans(
"ErrorAddAtLeastOneLineFirst").
'">'.$langs->trans(
"Validate").
'</a>';
762 if (
$object->status == Mo::STATUS_VALIDATED ||
$object->status == Mo::STATUS_INPROGRESS) {
763 if ($permissiontoproduce) {
764 print
'<a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=consumeorproduce&token='.$newToken.
'">'.$langs->trans(
'ConsumeOrProduce').
'</a>';
766 print
'<a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans(
"NotEnoughPermissions").
'">'.$langs->trans(
'ConsumeOrProduce').
'</a>';
768 } elseif (
$object->status == Mo::STATUS_DRAFT) {
769 print
'<a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans(
"ValidateBefore").
'">'.$langs->trans(
'ConsumeOrProduce').
'</a>';
773 if (
$object->status == Mo::STATUS_VALIDATED ||
$object->status == Mo::STATUS_INPROGRESS) {
774 if ($permissiontoproduce) {
775 print
'<a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=consumeandproduceall&token='.$newToken.
'">'.$langs->trans(
'ConsumeAndProduceAll').
'</a>';
777 print
'<a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans(
"NotEnoughPermissions").
'">'.$langs->trans(
'ConsumeAndProduceAll').
'</a>';
779 } elseif (
$object->status == Mo::STATUS_DRAFT) {
780 print
'<a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans(
"ValidateBefore").
'">'.$langs->trans(
'ConsumeAndProduceAll').
'</a>';
784 if ($permissiontoadd) {
785 if (
$object->status == $object::STATUS_VALIDATED ||
$object->status == $object::STATUS_INPROGRESS) {
786 $arrayproduced =
$object->fetchLinesLinked(
'produced', 0);
788 foreach ($arrayproduced as $lineproduced) {
789 $nbProduced += $lineproduced[
'qty'];
791 if ($nbProduced > 0) {
792 print
'<a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=confirm_produced&confirm=yes&token='.$newToken.
'">'.$langs->trans(
"Close").
'</a>'.
"\n";
794 print
'<a class="butActionRefused" href="#" title="'.$langs->trans(
"GoOnTabProductionToProduceFirst", $langs->transnoentitiesnoconv(
"Production")).
'">'.$langs->trans(
"Close").
'</a>'.
"\n";
797 print
'<a class="butActionDelete" href="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=cancel&token='.$newToken.
'">'.$langs->trans(
"Cancel").
'</a>'.
"\n";
800 if (
$object->status == $object::STATUS_CANCELED) {
801 print
'<a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=confirm_reopen&confirm=yes&token='.$newToken.
'">'.$langs->trans(
"ReOpen").
'</a>'.
"\n";
804 if (
$object->status == $object::STATUS_PRODUCED) {
805 if ($permissiontoproduce) {
806 print
'<a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=confirm_reopen&token='.$newToken.
'">'.$langs->trans(
'ReOpen').
'</a>';
808 print
'<a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans(
"NotEnoughPermissions").
'">'.$langs->trans(
'ReOpen').
'</a>';
817 if (in_array($action, array(
'consumeorproduce',
'consumeandproduceall',
'addconsumeline',
'addproduceline',
'editline'))) {
818 print
'<form method="POST" action="'.$_SERVER[
"PHP_SELF"].
'">';
819 print
'<input type="hidden" name="token" value="'.newToken().
'">';
820 print
'<input type="hidden" name="action" value="confirm_'.$action.
'">';
821 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
822 print
'<input type="hidden" name="id" value="'.$id.
'">';
825 if (in_array($action, array(
'consumeorproduce',
'consumeandproduceall'))) {
826 $defaultstockmovementlabel =
GETPOST(
'inventorylabel',
'alphanohtml') ?
GETPOST(
'inventorylabel',
'alphanohtml') : $langs->trans(
"ProductionForRef",
$object->
ref);
829 print
'<div class="center'.(in_array($action, array(
'consumeorproduce',
'consumeandproduceall')) ?
' formconsumeproduce' :
'').
'">';
830 print
'<div class="opacitymedium hideonsmartphone paddingbottom">'.$langs->trans(
"ConfirmProductionDesc", $langs->transnoentitiesnoconv(
"Confirm")).
'<br></div>';
831 print
'<span class="fieldrequired">'.$langs->trans(
"InventoryCode").
':</span> <input type="text" class="minwidth150 maxwidth200" name="inventorycode" value="'.$defaultstockmovementcode.
'"> ';
832 print
'<span class="clearbothonsmartphone"></span>';
833 print $langs->trans(
"MovementLabel").
': <input type="text" class="minwidth300" name="inventorylabel" value="'.$defaultstockmovementlabel.
'"><br><br>';
834 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>';
835 print
'<input type="submit" class="button" value="'.$langs->trans(
"Confirm").
'" name="confirm">';
837 print
'<input class="button button-cancel" type="submit" value="'.$langs->trans(
"Cancel").
'" name="cancel">';
851 if (!empty(
$object->table_element_line)) {
858 $res = $bom->fetch(
$object->fk_bom);
860 $bom->calculateCosts();
861 $bomcost = $bom->unit_cost;
867 print
'<!-- Lines to consume -->'.
"\n";
868 print
'<div class="fichecenter">';
869 print
'<div class="fichehalfleft">';
870 print
'<div class="clearboth"></div>';
872 $url = $_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=addconsumeline&token='.
newToken();
873 $permissiontoaddaconsumeline = (
$object->status != $object::STATUS_PRODUCED &&
$object->status != $object::STATUS_CANCELED) ? 1 : -2;
874 $parameters = array(
'morecss' =>
'reposition');
876 if ($permissiontoaddaconsumeline == -2) {
877 $helpText = $langs->trans(
'MOIsClosed');
881 if ($action !=
'consumeorproduce' && $action !=
'consumeandproduceall') {
882 $newcardbutton =
dolGetButtonTitle($langs->trans(
'AddNewConsumeLines'), $helpText,
'fa fa-plus-circle size15x', $url,
'', $permissiontoaddaconsumeline, $parameters);
885 print
load_fiche_titre($langs->trans(
'Consumption'), $newcardbutton,
'', 0,
'',
'',
'');
887 print
'<div class="div-table-responsive-no-min">';
888 print
'<table class="noborder noshadow centpercent nobottom">';
890 print
'<!-- Line of title for products to consume -->'.
"\n";
891 print
'<tr class="liste_titre trheight5em">';
893 print
'<td>'.$langs->trans(
"Product").
'</td>';
895 print
'<td class="right">'.$langs->trans(
"Qty").
'</td>';
900 print
'<td class="right">'.$langs->trans(
"UnitCost").
'</td>';
903 print
'<td class="right classfortooltip" title="'.$langs->trans(
"QtyAlreadyConsumed").
'">';
904 print $langs->trans(
"QtyAlreadyConsumedShort");
908 if ($collapse || in_array($action, array(
'consumeorproduce',
'consumeandproduceall'))) {
909 print $langs->trans(
"Warehouse");
910 if (isModEnabled(
'workstation')) {
911 print
' '.$langs->trans(
"or").
' '.$langs->trans(
"Workstation");
914 if (in_array($action, array(
'consumeorproduce',
'consumeandproduceall'))) {
915 $listwarehouses = $tmpwarehouse->list_array(1);
916 if (count($listwarehouses) > 1) {
917 print
'<br>'.$form->selectarray(
'fk_default_warehouse', $listwarehouses, $fk_default_warehouse, $langs->trans(
"ForceTo"), 0, 0,
'', 0, 0, 0,
'',
'minwidth100 maxwidth200', 1);
918 } elseif (count($listwarehouses) == 1) {
919 print
'<br>'.$form->selectarray(
'fk_default_warehouse', $listwarehouses, $fk_default_warehouse, 0, 0, 0,
'', 0, 0, 0,
'',
'minwidth100 maxwidth200', 1);
925 if (isModEnabled(
'stock')) {
927 print
'<td align="right">';
928 if ($collapse || in_array($action, array(
'consumeorproduce',
'consumeandproduceall'))) {
929 print $langs->trans(
"Stock");
934 if (isModEnabled(
'productbatch')) {
936 if ($collapse || in_array($action, array(
'consumeorproduce',
'consumeandproduceall'))) {
937 print $langs->trans(
"Batch");
949 if (
$object->status == Mo::STATUS_DRAFT) {
954 if ($permissiontodelete) {
960 if ($action ==
'addconsumeline') {
961 print
'<!-- Add line to consume -->'.
"\n";
962 print
'<tr class="liste_titre">';
965 print $form->select_produits(0,
'productidtoadd',
'', 0, 0, -1, 2,
'', 1, array(), 0,
'1', 0,
'maxwidth150');
968 print
'<td class="right"><input type="text" name="qtytoadd" value="1" class="width40 right"></td>';
981 if (isModEnabled(
'stock')) {
984 if (isModEnabled(
'productbatch')) {
988 print
'<td colspan="'.$colspan.
'">';
989 print
'<input type="submit" class="button buttongen button-add" name="addconsumelinebutton" value="'.$langs->trans(
"Add").
'">';
990 print
'<input type="submit" class="button buttongen button-cancel" name="canceladdconsumelinebutton" value="'.$langs->trans(
"Cancel").
'">';
995 if (
$object->status == Mo::STATUS_DRAFT) {
999 if ($permissiontodelete) {
1005 if (is_object($objectline)) {
1006 $extrafields->fetch_name_optionals_label(
$object->table_element_line);
1007 $temps = $objectline->showOptionals($extrafields,
'edit', array(),
'',
'',
'1',
'line');
1008 if (!empty($temps)) {
1009 print
'<tr class="liste_titre"><td style="padding-top: 20px" colspan="9" id="extrafield_lines_area_edit" name="extrafield_lines_area_edit">';
1018 $bomcostupdated = 0;
1021 $nblinetoconsume = 0;
1022 foreach (
$object->lines as $line) {
1023 if ($line->role ==
'toconsume') {
1028 $nblinetoconsumecursor = 0;
1029 foreach (
$object->lines as $line) {
1030 if ($line->role ==
'toconsume') {
1031 $nblinetoconsumecursor++;
1033 $tmpproduct =
new Product($db);
1034 $tmpproduct->fetch($line->fk_product);
1035 $linecost =
price2num($tmpproduct->pmp,
'MT');
1039 $costprice =
price2num((!empty($tmpproduct->cost_price)) ? $tmpproduct->cost_price : $tmpproduct->pmp);
1040 if (empty($costprice)) {
1041 require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.product.class.php';
1043 if ($productFournisseur->find_min_price_product_fournisseur($line->fk_product, $line->qty) > 0) {
1044 $costprice = $productFournisseur->fourn_unitprice;
1052 if ($useunit && $line->fk_unit > 0) {
1054 $qtyhourservice = 0;
1055 if (preg_match(
'/^(\d+)([a-z]+)$/', $tmpproduct->duration, $reg)) {
1058 $qtyhourforline = 0;
1059 if ($line->fk_unit) {
1065 if (isModEnabled(
'workstation') && $line->fk_default_workstation > 0) {
1067 $workstation->fetch($line->fk_default_workstation);
1068 $linecost =
price2num($qtyhourforline * ($workstation->thm_operator_estimated + $workstation->thm_machine_estimated) /
$object->qty,
'MT');
1069 $bomcostupdated +=
price2num($qtyhourforline * ($workstation->thm_operator_estimated + $workstation->thm_machine_estimated) /
$object->qty,
'MU');
1070 } elseif ($qtyhourservice && $qtyhourforline) {
1071 $linecost =
price2num(($qtyhourforline / $qtyhourservice * $costprice) /
$object->qty,
'MT');
1072 $bomcostupdated +=
price2num(($qtyhourforline / $qtyhourservice * $costprice) /
$object->qty,
'MU');
1075 $bomcostupdated +=
price2num(($line->qty * $costprice) /
$object->qty,
'MU');
1079 $bomcostupdated +=
price2num(($line->qty * $costprice) /
$object->qty,
'MU');
1083 $bomcostupdated =
price2num($bomcostupdated,
'MU');
1084 $arrayoflines =
$object->fetchLinesLinked(
'consumed', $line->id);
1085 $alreadyconsumed = 0;
1086 foreach ($arrayoflines as $line2) {
1087 $alreadyconsumed += $line2[
'qty'];
1090 if ($action ==
'editline' && $lineid == $line->id) {
1091 $linecost =
price2num($tmpproduct->pmp,
'MT');
1093 $arrayoflines =
$object->fetchLinesLinked(
'consumed', $line->id);
1094 $alreadyconsumed = 0;
1095 if (is_array($arrayoflines) && !empty($arrayoflines)) {
1096 foreach ($arrayoflines as $line2) {
1097 $alreadyconsumed += $line2[
'qty'];
1100 $suffix =
'_' . $line->id;
1101 print
'<!-- Line to dispatch ' . $suffix .
' (line edited) -->' .
"\n";
1103 print
'<input id="qty_ordered' . $suffix .
'" type="hidden" value="' . $line->qty .
'">';
1105 print
'<input id="qty_dispatched' . $suffix .
'" type="hidden" value="' . $alreadyconsumed .
'">';
1107 print
'<input name="lineid" type="hidden" value="' . $line->id .
'">';
1110 print
'<td>' . $tmpproduct->getNomUrl(1);
1111 print
'<br><div class="opacitymedium small tdoverflowmax150" title="' .
dol_escape_htmltag($tmpproduct->label) .
'">' . $tmpproduct->label .
'</span>';
1115 print
'<td class="right nowraponall">';
1116 print
'<input class="width40 right" name="qty_lineProduce" value="'. $line->qty.
'">';
1120 print
'<td class="right nowraponall">';
1128 if ($permissiontoupdatecost &&
getDolGlobalString(
'MRP_SHOW_COST_FOR_CONSUMPTION')) {
1133 print
'<td class="right">';
1134 print
' ' .
price2num($alreadyconsumed,
'MS');
1140 print $formproduct->selectWarehouses($line->fk_warehouse,
'warehouse_lineProduce',
'warehouseopen', 1);
1141 } elseif (isModEnabled(
'workstation')) {
1142 print $formproduct->selectWorkstations($line->fk_default_workstation,
'workstation_lineProduce', 1);
1147 if (isModEnabled(
'stock')) {
1148 print
'<td class="nowraponall right">';
1149 if ($tmpproduct->isStockManaged()) {
1150 if ($tmpproduct->stock_reel < ($line->qty - $alreadyconsumed)) {
1151 print
img_warning($langs->trans(
'StockTooLow')).
' ';
1153 print
'<span class="left">'. $tmpproduct->stock_reel .
' </span>';
1159 if (isModEnabled(
'productbatch')) {
1163 print
'<td colspan="'.(3 + (
$object->status == Mo::STATUS_DRAFT ? 1 : 0) + ($permissiontodelete ? 1 : 0)).
'">';
1164 print
'<input type="submit" class="button buttongen button-add small nominwidth" name="save" value="' . $langs->trans(
"Save") .
'">';
1165 print
'<input type="submit" class="button buttongen button-cancel small nominwidth" name="cancel" value="' . $langs->trans(
"Cancel") .
'">';
1171 if (!empty($extrafields)) {
1172 $line->fetch_optionals();
1173 $temps = $line->showOptionals($extrafields,
'edit', array(),
'',
'',
'1',
'line');
1174 if (!empty($temps)) {
1176 print
'<tr><td colspan="'.$colspan.
'"><div style="padding-top: 20px" id="extrafield_lines_area_edit" name="extrafield_lines_area_edit">';
1178 print
'</div></td></tr>';
1182 $suffix =
'_' . $line->id;
1183 print
'<!-- Line to dispatch ' . $suffix .
' -->' .
"\n";
1185 print
'<input id="qty_ordered' . $suffix .
'" type="hidden" value="' . $line->qty .
'">';
1186 print
'<input id="qty_dispatched' . $suffix .
'" type="hidden" value="' . $alreadyconsumed .
'">';
1188 print
'<tr data-line-id="' . $line->id .
'">';
1191 print
'<td>' . $tmpproduct->getNomUrl(1);
1192 print
'<br><div class="opacitymedium small tdoverflowmax150" title="' .
dol_escape_htmltag($tmpproduct->label) .
'">' . $tmpproduct->label .
'</div>';
1196 print
'<td class="right nowraponall">';
1198 if ($line->qty_frozen) {
1199 $help = ($help ?
'<br>' :
'') .
'<strong>' . $langs->trans(
"QuantityFrozen") .
'</strong>: ' .
yn(1) .
' (' . $langs->trans(
"QuantityConsumedInvariable") .
')';
1200 print $form->textwithpicto(
'', $help, -1,
'lock') .
' ';
1202 if ($line->disable_stock_change) {
1203 $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")) .
')';
1204 print $form->textwithpicto(
'', $help, -1,
'help') .
' ';
1210 print
'<td class="right nowraponall">';
1218 if ($permissiontoupdatecost &&
getDolGlobalString(
'MRP_SHOW_COST_FOR_CONSUMPTION')) {
1219 print
'<td class="right nowraponall">';
1220 print
price($linecost);
1225 print
'<td class="right">';
1226 if ($alreadyconsumed) {
1228 print
'jQuery(document).ready(function() {
1229 jQuery("#expandtoproduce' . $line->id .
'").click(function() {
1230 console.log("Expand mrp_production line ' . $line->id .
'");
1231 jQuery(".expanddetail' . $line->id .
'").toggle();';
1232 if ($nblinetoconsume == $nblinetoconsumecursor) {
1233 print
'if (jQuery("#tablelines").hasClass("nobottom")) { jQuery("#tablelines").removeClass("nobottom"); } else { jQuery("#tablelines").addClass("nobottom"); }';
1239 if (empty(
$conf->use_javascript_ajax)) {
1240 print
'<a href="' . $_SERVER[
"PHP_SELF"] .
'?collapse=' . $collapse .
',' . $line->id .
'">';
1242 print
img_picto($langs->trans(
"ShowDetails"),
"chevron-down",
'id="expandtoproduce' . $line->id .
'"');
1243 if (empty(
$conf->use_javascript_ajax)) {
1247 if ($nblinetoconsume == $nblinetoconsumecursor) {
1248 print
'<script>jQuery("#tablelines").removeClass("nobottom");</script>';
1251 print
' ' .
price2num($alreadyconsumed,
'MS');
1255 print
'<td class="tdoverflowmax100">';
1256 if ($tmpproduct->isStockManaged()) {
1258 if (
getDolGlobalString(
'STOCK_CONSUMPTION_FROM_MANUFACTURING_WAREHOUSE') && $tmpwarehouse->id > 0) {
1259 print
img_picto(
'', $tmpwarehouse->picto) .
" " . $tmpwarehouse->label;
1261 if ($line->fk_warehouse > 0) {
1262 $warehouseline =
new Entrepot($db);
1263 $warehouseline->fetch($line->fk_warehouse);
1264 print $warehouseline->getNomUrl(1);
1268 if (isModEnabled(
'workstation') && $line->fk_default_workstation > 0) {
1270 $tmpworkstation->fetch($line->fk_default_workstation);
1271 print $tmpworkstation->getNomUrl(1);
1276 if (isModEnabled(
'stock')) {
1277 print
'<td class="nowraponall right">';
1279 if (!$line->disable_stock_change && $tmpproduct->stock_reel < ($line->qty - $alreadyconsumed)) {
1280 print
img_warning($langs->trans(
'StockTooLow')) .
' ';
1282 if (!
getDolGlobalString(
'STOCK_CONSUMPTION_FROM_MANUFACTURING_WAREHOUSE') || empty($tmpwarehouse->id)) {
1283 print
price2num($tmpproduct->stock_reel,
'MS');
1286 $tmpproduct->load_stock();
1287 $wh_stock = $tmpproduct->stock_warehouse[$tmpwarehouse->id];
1288 if (!empty($wh_stock)) {
1299 if (isModEnabled(
'productbatch')) {
1310 if (
$object->status == Mo::STATUS_DRAFT) {
1311 $href = $_SERVER[
"PHP_SELF"] .
'?id=' . ((int)
$object->id) .
'&action=editline&token=' .
newToken() .
'&lineid=' . ((int) $line->id);
1312 print
'<td class="center">';
1313 print
'<a class="reposition editfielda" href="' . $href .
'">';
1314 print
img_picto($langs->trans(
'TooltipEditAndRevertStockMovement'),
'edit');
1320 if ($permissiontodelete && empty($arrayoflines)) {
1321 $href = $_SERVER[
"PHP_SELF"] .
'?id=' . ((int)
$object->id) .
'&action=deleteline&token=' .
newToken() .
'&lineid=' . ((int) $line->id);
1322 print
'<td class="center">';
1323 print
'<a class="reposition" href="' . $href .
'">';
1324 print
img_picto($langs->trans(
'TooltipDeleteAndRevertStockMovement'),
'delete');
1332 if (!empty($extrafields)) {
1333 $line->fetch_optionals();
1334 $temps = $line->showOptionals($extrafields,
'view', array(),
'',
'',
'1',
'line');
1335 if (!empty($temps)) {
1337 print
'<tr><td colspan="'.$colspan.
'"><div id="extrafield_lines_area_'.$line->id.
'" name="extrafield_lines_area_'.$line->id.
'">';
1339 print
'</div></td></tr>';
1345 foreach ($arrayoflines as $line2) {
1346 print
'<tr class="expanddetail'.$line->id.
' hideobject opacitylow">';
1350 $tmpstockmovement->id = $line2[
'fk_stock_movement'];
1351 print
'<a href="'.DOL_URL_ROOT.
'/product/stock/movement_list.php?search_ref='.$tmpstockmovement->id.
'">'.
img_picto($langs->trans(
"StockMovement"),
'movement',
'class="paddingright"').
'</a>';
1362 if ($permissiontoupdatecost &&
getDolGlobalString(
'MRP_SHOW_COST_FOR_CONSUMPTION')) {
1367 print
'<td class="right">'.$line2[
'qty'].
'</td>';
1370 print
'<td class="tdoverflowmax150">';
1371 if ($line2[
'fk_warehouse'] > 0) {
1372 $result = $tmpwarehouse->fetch($line2[
'fk_warehouse']);
1374 print $tmpwarehouse->getNomUrl(1);
1380 if (isModEnabled(
'stock')) {
1385 if (isModEnabled(
'productbatch')) {
1387 if ($line2[
'batch'] !=
'') {
1388 $tmpbatch->fetch(0, $line2[
'fk_product'], $line2[
'batch']);
1389 print $tmpbatch->getNomUrl(1);
1401 if (
$object->status == Mo::STATUS_DRAFT) {
1402 $href = $_SERVER[
"PHP_SELF"] .
'?id=' . ((int)
$object->id) .
'&action=editline&token=' .
newToken() .
'&lineid=' . ((int) $line2[
'rowid']);
1403 print
'<td class="center">';
1404 print
'<a class="reposition" href="' . $href .
'">';
1405 print
img_picto($langs->trans(
'TooltipEditAndRevertStockMovement'),
'edit');
1411 if ($permissiontodelete) {
1412 $href = $_SERVER[
"PHP_SELF"].
'?id='.((int)
$object->id).
'&action=deleteline&token='.
newToken().
'&lineid='.((int) $line2[
'rowid']).
'&fk_movement='.((int) $line2[
'fk_stock_movement']);
1413 print
'<td class="center">';
1414 print
'<a class="reposition" href="'.$href.
'">';
1415 print
img_picto($langs->trans(
'TooltipDeleteAndRevertStockMovement'),
'delete');
1423 if (in_array($action, array(
'consumeorproduce',
'consumeandproduceall'))) {
1425 print
'<!-- Enter line to consume -->'.
"\n";
1427 print
'<tr data-max-qty="'.$maxQty.
'" name="batch_'.$line->id.
'_'.$i.
'">';
1429 print
'<td><span class="opacitymedium">'.$langs->trans(
"ToConsume").
'</span></td>';
1430 $preselected = (GETPOSTISSET(
'qty-'.$line->id.
'-'.$i) ?
GETPOST(
'qty-'.$line->id.
'-'.$i) : max(0, $line->qty - $alreadyconsumed));
1431 if ($action ==
'consumeorproduce' && !
getDolGlobalString(
'MRP_AUTO_SET_REMAINING_QUANTITIES_TO_BE_CONSUMED') && !GETPOSTISSET(
'qty-'.$line->id.
'-'.$i)) {
1436 if (
getDolGlobalString(
'MRP_NEVER_CONSUME_MORE_THAN_EXPECTED') && ($line->qty - $alreadyconsumed) <= 0) {
1437 $disable =
'disabled';
1441 print
'<input type="hidden" name="product-'.$line->id.
'-'.$i.
'" value="'.$line->fk_product.
'">';
1444 print
'<td class="right">';
1445 if ((
int) $tmpproduct->stockable_product > 0) {
1446 print
'<input type="text" class="width50 right" id="qtytoconsume-' . $line->id .
'-' . $i .
'" name="qty-' . $line->id .
'-' . $i .
'" value="' . $preselected .
'" ' . $disable .
'>';
1448 print
'<input type="hidden" id="qtytoconsume-' . $line->id .
'-' . $i .
'" name="qty-' . $line->id .
'-' . $i .
'" value="0">';
1449 print
'<span class="opacitymedium">' . $langs->trans(
"StockDisabled") .
'</span>';
1457 if ($permissiontoupdatecost &&
getDolGlobalString(
'MRP_SHOW_COST_FOR_CONSUMPTION')) {
1467 && ((
int) $tmpproduct->stockable_product > 0)) {
1468 if (empty($line->disable_stock_change)) {
1469 $preselected = (GETPOSTISSET(
'idwarehouse-'.$line->id.
'-'.$i) ?
GETPOST(
'idwarehouse-'.$line->id.
'-'.$i) : ($tmpproduct->fk_default_warehouse > 0 ? $tmpproduct->fk_default_warehouse :
'ifone'));
1470 print $formproduct->selectWarehouses($preselected,
'idwarehouse-'.$line->id.
'-'.$i,
'', 1, 0, $line->fk_product,
'', 1, 0, array(),
'maxwidth200 csswarehouse_'.$line->id.
'_'.$i);
1472 print
'<span class="opacitymedium">'.$langs->trans(
"DisableStockChange").
'</span>';
1475 if ((
int) $tmpproduct->stockable_product > 0) {
1476 print
'<span class="opacitymedium">' . $langs->trans(
"StockDisabled") .
'</span>';
1478 print
'<span class="opacitymedium">' . $langs->trans(
"NoStockChangeOnServices") .
'</span>';
1484 if (isModEnabled(
'stock')) {
1489 if (isModEnabled(
'productbatch')) {
1490 print
'<td class="nowraponall">';
1491 if ($tmpproduct->status_batch) {
1492 $preselected = (GETPOSTISSET(
'batch-'.$line->id.
'-'.$i) ?
GETPOST(
'batch-'.$line->id.
'-'.$i) :
'');
1493 print
'<input type="text" class="width75" name="batch-'.$line->id.
'-'.$i.
'" value="'.$preselected.
'" list="batch-'.$line->id.
'-'.$i.
'">';
1494 print $formproduct->selectLotDataList(
'batch-'.$line->id.
'-'.$i, 0, $line->fk_product, 0, array());
1501 print
'<td align="right" class="split">';
1502 print
' '.img_picto($langs->trans(
'AddStockLocationLine'),
'split.png',
'class="splitbutton" onClick="addDispatchLine('.((int) $line->id).
', \''.
dol_escape_js($type).
'\', \
'qtymissingconsume\')"');
1506 print
'<td align="right" class="splitall">';
1507 if (($action ==
'consumeorproduce' || $action ==
'consumeandproduceall') && $tmpproduct->status_batch == 2) {
1508 print
img_picto($langs->trans(
'SplitAllQuantity'),
'split.png',
'class="splitbutton splitallbutton field-error-icon" data-max-qty="1" onClick="addDispatchLine('.$line->id.
', \'batch\', \'allmissingconsume\')"');
1513 if (
$object->status == Mo::STATUS_DRAFT) {
1518 if ($permissiontodelete) {
1532 print
'<script type="text/javascript">
1533 $(document).ready(function () {
1534 $("select[name=fk_default_warehouse]").change(function() {
1535 var fk_default_warehouse = $("option:selected", this).val();
1536 $("select[name^=idwarehouse-]").val(fk_default_warehouse).change();
1541 if (in_array($action, array(
'consumeorproduce',
'consumeandproduceall')) &&
1543 print
'<script>$(document).ready(function () {
1544 $("#fk_default_warehouse").change();
1552 print
'<div class="fichehalfright">';
1553 print
'<div class="clearboth"></div>';
1555 $nblinetoproduce = 0;
1556 foreach (
$object->lines as $line) {
1557 if ($line->role ==
'toproduce') {
1562 $newcardbutton =
'';
1563 $url = $_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=addproduceline&token='.
newToken();
1564 $permissiontoaddaproductline =
$object->status != $object::STATUS_PRODUCED &&
$object->status != $object::STATUS_CANCELED;
1565 $parameters = array(
'morecss' =>
'reposition');
1566 if ($action !=
'consumeorproduce' && $action !=
'consumeandproduceall') {
1567 if ($nblinetoproduce == 0 ||
$object->mrptype == 1) {
1568 $newcardbutton =
dolGetButtonTitle($langs->trans(
'AddNewProduceLines'),
'',
'fa fa-plus-circle size15x', $url,
'', (
int) $permissiontoaddaproductline, $parameters);
1572 print
load_fiche_titre($langs->trans(
'Production'), $newcardbutton,
'', 0,
'',
'');
1574 print
'<div class="div-table-responsive-no-min">';
1575 print
'<table id="tablelinestoproduce" class="noborder noshadow nobottom centpercent">';
1577 print
'<tr class="liste_titre trheight5em">';
1579 print
'<td>'.$langs->trans(
"Product").
'</td>';
1581 print
'<td class="right">'.$langs->trans(
"Qty").
'</td>';
1584 print
'<td class="right">'.$langs->trans(
"Unit").
'</td>';
1587 if ($permissiontoupdatecost) {
1588 if (empty($bomcostupdated)) {
1589 print
'<td class="right classfortooltip" title="'.$langs->trans(
"AmountUsedToUpdateWAP").
'">';
1590 print $langs->trans(
"UnitCost");
1593 print
'<td class="right classfortooltip" title="'.$langs->trans(
"AmountUsedToUpdateWAP").
'">';
1594 print $langs->trans(
"ManufacturingPrice");
1599 print
'<td class="right classfortooltip" title="'.$langs->trans(
"QtyAlreadyProduced").
'">';
1600 print $langs->trans(
"QtyAlreadyProducedShort");
1604 if ($collapse || in_array($action, array(
'consumeorproduce',
'consumeandproduceall'))) {
1605 print $langs->trans(
"Warehouse");
1610 if (isModEnabled(
'productbatch')) {
1612 if ($collapse || in_array($action, array(
'consumeorproduce',
'consumeandproduceall'))) {
1613 print $langs->trans(
"Batch");
1625 if ($permissiontodelete) {
1631 if ($action ==
'addproduceline') {
1632 print
'<!-- Add line to produce -->'.
"\n";
1633 print
'<tr class="liste_titre">';
1637 print $form->select_produits(0,
'productidtoadd',
'', 0, 0, -1, 2,
'', 1, array(), 0,
'1', 0,
'maxwidth300');
1640 print
'<td class="right"><input type="text" name="qtytoadd" value="1" class="width50 right"></td>';
1646 if ($permissiontoupdatecost) {
1650 print
'<td colspan="2">';
1651 print
'<input type="submit" class="button buttongen button-add" name="addproducelinebutton" value="'.$langs->trans(
"Add").
'">';
1652 print
'<input type="submit" class="button buttongen button-cancel" name="canceladdproducelinebutton" value="'.$langs->trans(
"Cancel").
'">';
1655 if (isModEnabled(
'productbatch')) {
1665 if ($permissiontodelete) {
1672 $nblinetoproduce = 0;
1673 foreach (
$object->lines as $line) {
1674 if ($line->role ==
'toproduce') {
1679 $nblinetoproducecursor = 0;
1680 foreach (
$object->lines as $line) {
1681 if ($line->role ==
'toproduce') {
1684 $nblinetoproducecursor++;
1686 $tmpproduct =
new Product($db);
1687 $tmpproduct->fetch($line->fk_product);
1689 $arrayoflines =
$object->fetchLinesLinked(
'produced', $line->id);
1690 $alreadyproduced = 0;
1691 foreach ($arrayoflines as $line2) {
1692 $alreadyproduced += $line2[
'qty'];
1695 $suffix =
'_'.$line->id;
1696 print
'<!-- Line to dispatch '.$suffix.
' (toproduce) -->'.
"\n";
1698 print
'<input id="qty_ordered'.$suffix.
'" type="hidden" value="'.$line->qty.
'">';
1699 print
'<input id="qty_dispatched'.$suffix.
'" type="hidden" value="'.$alreadyproduced.
'">';
1703 print
'<td>'.$tmpproduct->getNomUrl(1);
1704 print
'<br><span class="opacitymedium small">'.$tmpproduct->label.
'</span>';
1707 print
'<td class="right">'.$line->qty.
'</td>';
1710 print
'<td class="right">'.measuringUnitString($line->fk_unit,
'',
null, 1).
'</td>';
1713 if ($permissiontoupdatecost) {
1715 $manufacturingcost = 0;
1716 $manufacturingcostsrc =
'';
1718 $manufacturingcost = $bomcostupdated;
1719 $manufacturingcostsrc = $langs->trans(
"CalculatedFromProductsToConsume");
1720 if (empty($manufacturingcost)) {
1721 $manufacturingcost = $bomcost;
1722 $manufacturingcostsrc = $langs->trans(
"ValueFromBom");
1724 if (empty($manufacturingcost)) {
1725 $manufacturingcost =
price2num($tmpproduct->cost_price,
'MU');
1726 $manufacturingcostsrc = $langs->trans(
"CostPrice");
1728 if (empty($manufacturingcost)) {
1729 $manufacturingcost =
price2num($tmpproduct->pmp,
'MU');
1730 $manufacturingcostsrc = $langs->trans(
"PMPValue");
1734 print
'<td class="right nowraponall" title="'.dol_escape_htmltag($manufacturingcostsrc).
'">';
1735 if ($manufacturingcost) {
1736 print
price($manufacturingcost);
1741 print
'<td class="right nowraponall">';
1742 if ($alreadyproduced) {
1744 print
'jQuery(document).ready(function() {
1745 jQuery("#expandtoproduce'.$line->id.
'").click(function() {
1746 console.log("Expand mrp_production line '.$line->id.
'");
1747 jQuery(".expanddetailtoproduce'.$line->id.
'").toggle();';
1748 if ($nblinetoproduce == $nblinetoproducecursor) {
1749 print
'if (jQuery("#tablelinestoproduce").hasClass("nobottom")) { jQuery("#tablelinestoproduce").removeClass("nobottom"); } else { jQuery("#tablelinestoproduce").addClass("nobottom"); }';
1755 if (empty(
$conf->use_javascript_ajax)) {
1756 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?collapse='.$collapse.
','.$line->id.
'">';
1758 print
img_picto($langs->trans(
"ShowDetails"),
"chevron-down",
'id="expandtoproduce'.$line->id.
'"');
1759 if (empty(
$conf->use_javascript_ajax)) {
1763 print
' '.$alreadyproduced;
1769 if (isModEnabled(
'productbatch')) {
1779 if ($permissiontodelete) {
1780 if ($line->origin_type ==
'free' && empty($arrayoflines)) {
1781 $href = $_SERVER[
"PHP_SELF"];
1782 $href .=
'?id='.$object->id;
1783 $href .=
'&action=deleteline';
1784 $href .=
'&token='.newToken();
1785 $href .=
'&lineid='.$line->id;
1786 print
'<td class="center">';
1787 print
'<a class="reposition" href="'.$href.
'">';
1788 print
img_picto($langs->trans(
'TooltipDeleteAndRevertStockMovement'),
"delete");
1798 foreach ($arrayoflines as $line2) {
1799 print
'<tr class="expanddetailtoproduce'.$line->id.
' hideobject opacitylow">';
1802 $tmpstockmovement->id = $line2[
'fk_stock_movement'];
1803 print
'<a href="'.DOL_URL_ROOT.
'/product/stock/movement_list.php?search_ref='.$tmpstockmovement->id.
'">'.
img_picto($langs->trans(
"StockMovement"),
'movement',
'class="paddingright"').
'</a>';
1813 if ($permissiontoupdatecost) {
1817 print
'<td class="right">'.$line2[
'qty'].
'</td>';
1819 print
'<td class="tdoverflowmax150">';
1820 if ($line2[
'fk_warehouse'] > 0) {
1821 $result = $tmpwarehouse->fetch($line2[
'fk_warehouse']);
1823 print $tmpwarehouse->getNomUrl(1);
1828 if (isModEnabled(
'productbatch')) {
1830 if ($line2[
'batch'] !=
'') {
1831 $tmpbatch->fetch(0, $line2[
'fk_product'], $line2[
'batch']);
1832 print $tmpbatch->getNomUrl(1);
1843 if ($permissiontodelete) {
1849 if (in_array($action, array(
'consumeorproduce',
'consumeandproduceall'))) {
1850 print
'<!-- Enter line to produce -->'.
"\n";
1852 print
'<tr data-max-qty="'.$maxQty.
'" name="batch_'.$line->id.
'_'.$i.
'">';
1854 print
'<td><span class="opacitymedium">'.$langs->trans(
"ToProduce").
'</span></td>';
1855 $preselected = (GETPOSTISSET(
'qtytoproduce-'.$line->id.
'-'.$i) ?
GETPOST(
'qtytoproduce-'.$line->id.
'-'.$i) : max(0, $line->qty - $alreadyproduced));
1856 if ($action ==
'consumeorproduce' && !GETPOSTISSET(
'qtytoproduce-'.$line->id.
'-'.$i)) {
1860 print
'<td class="right"><input type="text" class="width50 right" id="qtytoproduce-'.$line->id.
'-'.$i.
'" name="qtytoproduce-'.$line->id.
'-'.$i.
'" value="'.$preselected.
'"></td>';
1863 print
'<td class="right"></td>';
1866 if ($permissiontoupdatecost) {
1868 $manufacturingcost = 0;
1869 $manufacturingcostsrc =
'';
1871 $manufacturingcost = $bomcostupdated;
1872 $manufacturingcostsrc = $langs->trans(
"CalculatedFromProductsToConsume");
1873 if (empty($manufacturingcost)) {
1874 $manufacturingcost = $bomcost;
1875 $manufacturingcostsrc = $langs->trans(
"ValueFromBom");
1877 if (empty($manufacturingcost)) {
1878 $manufacturingcost =
price2num($tmpproduct->cost_price,
'MU');
1879 $manufacturingcostsrc = $langs->trans(
"CostPrice");
1881 if (empty($manufacturingcost)) {
1882 $manufacturingcost =
price2num($tmpproduct->pmp,
'MU');
1883 $manufacturingcostsrc = $langs->trans(
"PMPValue");
1888 $preselected = (GETPOSTISSET(
'pricetoproduce-'.$line->id.
'-'.$i) ?
GETPOST(
'pricetoproduce-'.$line->id.
'-'.$i) : ($manufacturingcost ?
price($manufacturingcost) :
''));
1889 print
'<td class="right"><input type="text" class="width75 right" name="pricetoproduce-'.$line->id.
'-'.$i.
'" value="'.$preselected.
'"></td>';
1891 print
'<td><input type="hidden" class="width50 right" name="pricetoproduce-'.$line->id.
'-'.$i.
'" value="'.($manufacturingcost ? $manufacturingcost :
'').
'"></td>';
1899 $preselected = (GETPOSTISSET(
'idwarehousetoproduce-'.$line->id.
'-'.$i) ?
GETPOST(
'idwarehousetoproduce-'.$line->id.
'-'.$i) : (
$object->fk_warehouse > 0 ?
$object->fk_warehouse :
'ifone'));
1900 print $formproduct->selectWarehouses($preselected,
'idwarehousetoproduce-'.$line->id.
'-'.$i,
'', 1, 0, $line->fk_product,
'', 1, 0, array(),
'maxwidth200 csswarehouse_'.$line->id.
'_'.$i);
1902 print
'<span class="opacitymedium">'.$langs->trans(
"NoStockChangeOnServices").
'</span>';
1906 if (isModEnabled(
'productbatch')) {
1908 if ($tmpproduct->status_batch) {
1909 $preselected = (GETPOSTISSET(
'batchtoproduce-'.$line->id.
'-'.$i) ?
GETPOST(
'batchtoproduce-'.$line->id.
'-'.$i) :
'');
1910 print
'<input type="text" class="width75" name="batchtoproduce-'.$line->id.
'-'.$i.
'" value="'.$preselected.
'">';
1914 if ($tmpproduct->status_batch) {
1916 print
'<td align="right" class="split">';
1917 print
img_picto($langs->trans(
'AddStockLocationLine'),
'split.png',
'class="splitbutton" onClick="addDispatchLine('.$line->id.
', \''.$type.
'\', \
'qtymissing\')"');
1920 print
'<td align="right" class="splitall">';
1921 if (($action ==
'consumeorproduce' || $action ==
'consumeandproduceall') && $tmpproduct->status_batch == 2) {
1922 print
img_picto($langs->trans(
'SplitAllQuantity'),
'split.png',
'class="splitbutton splitallbutton field-error-icon" onClick="addDispatchLine('.$line->id.
', \'batch\', \'alltoproduce\')"');
1948 if (in_array($action, array(
'consumeorproduce',
'consumeandproduceall',
'addconsumeline'))) {
1952 <script
type=
"text/javascript" language=
"javascript">
1954 $(document).ready(
function() {
1956 updateselectbatchbywarehouse();
1958 updateselectwarehousebybatch();
1961 function updateselectbatchbywarehouse() {
1962 $(document).on(
'change',
"select[name*='idwarehouse']",
function () {
1963 console.log(
"We change warehouse so we update the list of possible batch number");
1965 var selectwarehouse = $(
this);
1967 var selectbatch_name = selectwarehouse.attr(
'name').replace(
'idwarehouse',
'batch');
1968 var selectbatch = $(
"datalist[id*='" + selectbatch_name +
"']");
1969 var selectedbatch = selectbatch.val();
1971 var product_element_name = selectwarehouse.attr(
'name').replace(
'idwarehouse',
'product');
1975 url:
"<?php echo DOL_URL_ROOT . '/mrp/ajax/interface.php'; ?>",
1977 action:
"updateselectbatchbywarehouse",
1978 permissiontoproduce: <?php echo $permissiontoproduce ?>,
1979 warehouse_id: $(
this).val(),
1980 token:
'<?php echo currentToken(); ?>',
1981 product_id: $(
"input[name='" + product_element_name +
"']").val()
1983 }).done(
function (data) {
1985 selectbatch.empty();
1987 if (typeof data ==
"object") {
1988 console.log(
"data is already type object, no need to parse it");
1990 console.log(
"data is type "+(typeof data));
1991 data = JSON.parse(data);
1994 selectbatch.append($(
'<option>', {
1998 $.each(data,
function (key, value) {
2000 if(selectwarehouse.val() == -1) {
2001 var label = key +
" (<?php echo $langs->trans('TotalStock') ?> : " + value +
")";
2003 var label = key +
" (<?php echo $langs->trans('Stock') ?> : " + value +
")";
2006 if(key === selectedbatch) {
2007 var option =
'<option value="'+key+
'" selected>'+ label +
'</option>';
2009 var option =
'<option value="'+key+
'">'+ label +
'</option>';
2012 selectbatch.append(option);
2018 function updateselectwarehousebybatch() {
2019 $(document).on(
'change',
'input[name*=batch]',
function(){
2020 console.log(
"We change batch so we update the list of possible warehouses");
2022 var selectbatch = $(
this);
2024 var selectwarehouse_name = selectbatch.attr(
'name').replace(
'batch',
'idwarehouse');
2025 var selectwarehouse = $(
"select[name*='" + selectwarehouse_name +
"']");
2026 var selectedwarehouse = selectwarehouse.val();
2028 if(selectedwarehouse != -1){
2032 var product_element_name = selectbatch.attr(
'name').replace(
'batch',
'product');
2036 url:
"<?php echo DOL_URL_ROOT . '/mrp/ajax/interface.php'; ?>",
2038 action:
"updateselectwarehousebybatch",
2039 permissiontoproduce: <?php echo $permissiontoproduce ?>,
2040 batch: $(
this).val(),
2041 token:
'<?php echo currentToken(); ?>',
2042 product_id: $(
"input[name='" + product_element_name +
"']").val()
2044 }).done(
function (data) {
2046 if (typeof data ==
"object") {
2047 console.log(
"data is already type object, no need to parse it");
2049 console.log(
"data is type "+(typeof data));
2050 data = JSON.parse(data);
2054 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.