31require
'../main.inc.php';
40require_once DOL_DOCUMENT_ROOT.
'/bom/class/bom.class.php';
41require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formcompany.class.php';
42require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
43require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formprojet.class.php';
44require_once DOL_DOCUMENT_ROOT.
'/mrp/class/mo.class.php';
45require_once DOL_DOCUMENT_ROOT.
'/mrp/lib/mrp_mo.lib.php';
46require_once DOL_DOCUMENT_ROOT.
'/projet/class/project.class.php';
47require_once DOL_DOCUMENT_ROOT.
'/product/class/product.class.php';
48require_once DOL_DOCUMENT_ROOT.
'/product/class/html.formproduct.class.php';
49require_once DOL_DOCUMENT_ROOT.
'/product/stock/class/entrepot.class.php';
50require_once DOL_DOCUMENT_ROOT.
'/product/stock/class/productlot.class.php';
51require_once DOL_DOCUMENT_ROOT.
'/product/stock/class/mouvementstock.class.php';
52require_once DOL_DOCUMENT_ROOT.
'/workstation/class/workstation.class.php';
55$langs->loadLangs(array(
"mrp",
"stocks",
"other",
"product",
"productbatch"));
60$action =
GETPOST(
'action',
'aZ09');
61$confirm =
GETPOST(
'confirm',
'alpha');
63$contextpage =
GETPOST(
'contextpage',
'aZ') ?
GETPOST(
'contextpage',
'aZ') :
'mocard';
64$backtopage =
GETPOST(
'backtopage',
'alpha');
67$fk_default_warehouse =
GETPOSTINT(
'fk_default_warehouse');
69$collapse =
GETPOST(
'collapse',
'aZ09comma');
73$diroutputmassaction =
$conf->mrp->dir_output.
'/temp/massgeneration/'.$user->id;
76$hookmanager->initHooks(array(
'moproduction',
'globalcard'));
79$extrafields->fetch_name_optionals_label(
$object->table_element);
81$search_array_options = $extrafields->getOptionalsFromPost(
$object->table_element,
'',
'search_');
84$search_all =
GETPOST(
"search_all",
'alpha');
86foreach (
$object->fields as $key => $val) {
87 if (
GETPOST(
'search_'.$key,
'alpha')) {
88 $search[$key] =
GETPOST(
'search_'.$key,
'alpha');
92if (empty($action) && empty($id) && empty($ref)) {
97include DOL_DOCUMENT_ROOT.
'/core/actions_fetchobject.inc.php';
102$isdraft = ((
$object->status == $object::STATUS_DRAFT) ? 1 : 0);
106$permissionnote = $user->hasRight(
'mrp',
'write');
107$permissiondellink = $user->hasRight(
'mrp',
'write');
108$permissiontoadd = $user->hasRight(
'mrp',
'write');
109$permissiontodelete = $user->hasRight(
'mrp',
'delete') || ($permissiontoadd && isset(
$object->status) &&
$object->status == $object::STATUS_DRAFT);
111$permissiontoproduce = $permissiontoadd;
112$permissiontoupdatecost = $user->hasRight(
'bom',
'read');
121$parameters = array();
122$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
127if (empty($reshook)) {
130 $backurlforlist = DOL_URL_ROOT.
'/mrp/mo_list.php';
132 if (empty($backtopage) || ($cancel && empty($id))) {
134 if (empty($id) && (($action !=
'add' && $action !=
'create') || $cancel)) {
135 $backtopage = $backurlforlist;
137 $backtopage = DOL_URL_ROOT.
'/mrp/mo_production.php?id='.(
$id > 0 ?
$id :
'__ID__');
140 $triggermodname =
'MO_MODIFY';
142 if ($action ==
'confirm_cancel' && $confirm ==
'yes' && !empty($permissiontoadd)) {
143 $also_cancel_consumed_and_produced_lines = (
GETPOST(
'alsoCancelConsumedAndProducedLines',
'alpha') ? 1 : 0);
144 $result =
$object->cancel($user, 0, (
bool) $also_cancel_consumed_and_produced_lines);
146 header(
"Location: " . DOL_URL_ROOT.
'/mrp/mo_card.php?id=' .
$object->id);
152 } elseif ($action ==
'confirm_delete' && $confirm ==
'yes' && !empty($permissiontodelete)) {
153 $also_cancel_consumed_and_produced_lines = (
GETPOST(
'alsoCancelConsumedAndProducedLines',
'alpha') ? 1 : 0);
154 $result =
$object->delete($user, 0, (
bool) $also_cancel_consumed_and_produced_lines);
156 header(
"Location: " . $backurlforlist);
170 if ($action ==
'setqty' && $permissiontoadd &&
$object->status == Mo::STATUS_DRAFT) {
184 foreach (
$object->lines as $line) {
185 if ($line->role ===
'toproduce'
186 && (
int) $line->fk_product === (
int)
$object->fk_product
187 && empty($line->qty_frozen)
188 && (
float) $line->qty != (
float)
$object->qty) {
189 $line->qty = (float)
$object->qty;
190 $line->update($user);
198 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->trans(
"Qty")),
null,
'errors');
200 header(
"Location: ".$_SERVER[
"PHP_SELF"].
"?id=".
$object->id);
205 include DOL_DOCUMENT_ROOT.
'/core/actions_addupdatedelete.inc.php';
208 include DOL_DOCUMENT_ROOT.
'/core/actions_dellink.inc.php';
211 include DOL_DOCUMENT_ROOT.
'/core/actions_printing.inc.php';
214 $triggersendname =
'MO_SENTBYMAIL';
215 $autocopy =
'MAIN_MAIL_AUTOCOPY_MO_TO';
216 $trackid =
'mo'.$object->id;
217 include DOL_DOCUMENT_ROOT.
'/core/actions_sendmails.inc.php';
222 if ($action ==
'set_thirdparty' && $permissiontoadd) {
223 $object->setValueFrom(
'fk_soc',
GETPOSTINT(
'fk_soc'),
'',
null,
'date',
'', $user, $triggermodname);
225 if ($action ==
'classin' && $permissiontoadd) {
229 if ($action ==
'confirm_reopen' && $permissiontoadd) {
230 $result =
$object->setStatut($object::STATUS_INPROGRESS, 0,
'',
'MRP_REOPEN');
233 if (($action ==
'confirm_addconsumeline' &&
GETPOST(
'addconsumelinebutton') && $permissiontoadd)
234 || ($action ==
'confirm_addproduceline' &&
GETPOST(
'addproducelinebutton') && $permissiontoadd)) {
240 $moline->fk_product =
GETPOSTINT(
'productidtoadd');
241 if (
GETPOST(
'addconsumelinebutton')) {
242 $moline->role =
'toconsume';
244 $moline->role =
'toproduce';
246 $moline->origin_type =
'free';
247 $moline->position = 0;
250 if (!empty($moline->fk_product)) {
252 $tmpproduct->fetch($moline->fk_product);
254 $moline->fk_default_workstation = $tmpproduct->fk_default_workstation;
255 $moline->disable_stock_change = 1;
256 if ($tmpproduct->duration_unit) {
257 $moline->qty = $tmpproduct->duration_value;
258 include_once DOL_DOCUMENT_ROOT.
'/core/class/cunits.class.php';
260 $res = $cunits->fetch(0,
'', $tmpproduct->duration_unit,
'time');
262 $moline->fk_unit = $cunits->id;
266 $moline->disable_stock_change = 0;
268 $moline->fk_unit = $tmpproduct->fk_unit;
273 $extralabelsline = $extrafields->fetch_name_optionals_label(
$object->table_element_line);
274 $array_options = $extrafields->getOptionalsFromPost(
$object->table_element_line);
276 if (is_array($extralabelsline)) {
278 foreach ($extralabelsline as $key => $value) {
279 unset($_POST[
"options_".$key]);
282 if (is_array($array_options) && count($array_options) > 0) {
283 $moline->array_options = $array_options;
286 $resultline = $moline->create($user, 0);
287 if ($resultline <= 0) {
294 header(
"Location: ".$_SERVER[
"PHP_SELF"].
'?id='.
$object->id);
298 if (in_array($action, array(
'confirm_consumeorproduce',
'confirm_consumeandproduceall')) && $permissiontoproduce) {
301 $labelmovement =
GETPOST(
'inventorylabel',
'alphanohtml');
302 $codemovement =
GETPOST(
'inventorycode',
'alphanohtml');
307 foreach (
$object->lines as $line) {
308 if ($line->role ==
'toconsume') {
310 $tmpproduct->fetch($line->fk_product);
313 while (GETPOSTISSET(
'qty-'.$line->id.
'-'.$i)) {
316 if ($qtytoprocess != 0) {
318 if (GETPOSTISSET(
'idwarehouse-'.$line->id.
'-'.$i)) {
319 if (!(
GETPOST(
'idwarehouse-'.$line->id.
'-'.$i) > 0)) {
320 $langs->load(
"errors");
321 setEventMessages($langs->trans(
"ErrorFieldRequiredForProduct", $langs->transnoentitiesnoconv(
"Warehouse"), (
string) $tmpproduct->ref),
null,
'errors');
324 if ($tmpproduct->status_batch && (!
GETPOST(
'batch-'.$line->id.
'-'.$i))) {
325 $langs->load(
"errors");
326 setEventMessages($langs->trans(
"ErrorFieldRequiredForProduct", $langs->transnoentitiesnoconv(
"Batch"), (
string) $tmpproduct->ref),
null,
'errors');
332 if (!$error &&
GETPOST(
'idwarehouse-'.$line->id.
'-'.$i) > 0) {
334 $id_product_batch = 0;
336 $stockmove->context[
'mrp_role'] =
'toconsume';
338 if ($qtytoprocess >= 0) {
339 $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);
341 $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);
343 if ($idstockmove < 0) {
353 $moline->position = $pos;
354 $moline->fk_product = $line->fk_product;
355 $moline->fk_warehouse =
GETPOSTINT(
'idwarehouse-'.$line->id.
'-'.$i);
356 $moline->qty = $qtytoprocess;
357 $moline->batch =
GETPOST(
'batch-'.$line->id.
'-'.$i);
358 $moline->role =
'consumed';
359 $moline->fk_mrp_production = $line->id;
360 $moline->fk_stock_movement = $idstockmove == 0 ? null : $idstockmove;
361 $moline->fk_user_creat = $user->id;
363 $resultmoline = $moline->create($user);
364 if ($resultmoline <= 0) {
381 foreach (
$object->lines as $line) {
382 if ($line->role ==
'toproduce') {
384 $tmpproduct->fetch($line->fk_product);
387 while (GETPOSTISSET(
'qtytoproduce-'.$line->id.
'-'.$i)) {
388 $qtytoprocess = (float)
price2num(
GETPOST(
'qtytoproduce-'.$line->id.
'-'.$i));
389 $pricetoprocess =
GETPOST(
'pricetoproduce-'.$line->id.
'-'.$i) ?
price2num(
GETPOST(
'pricetoproduce-'.$line->id.
'-'.$i)) : 0;
391 if ($qtytoprocess != 0) {
393 if (GETPOSTISSET(
'idwarehousetoproduce-'.$line->id.
'-'.$i)) {
394 if (!(
GETPOST(
'idwarehousetoproduce-'.$line->id.
'-'.$i) > 0)) {
395 $langs->load(
"errors");
396 setEventMessages($langs->trans(
"ErrorFieldRequiredForProduct", $langs->transnoentitiesnoconv(
"Warehouse"), $tmpproduct->ref),
null,
'errors');
399 if (
isModEnabled(
'productbatch') && $tmpproduct->status_batch && (!
GETPOST(
'batchtoproduce-'.$line->id.
'-'.$i))) {
400 $langs->load(
"errors");
401 setEventMessages($langs->trans(
"ErrorFieldRequiredForProduct", $langs->transnoentitiesnoconv(
"Batch"), $tmpproduct->ref),
null,
'errors');
407 if (!$error &&
GETPOST(
'idwarehousetoproduce-'.$line->id.
'-'.$i) > 0) {
409 $id_product_batch = 0;
410 $stockmove->origin_type =
$object->element;
411 $stockmove->origin_id =
$object->id;
412 $stockmove->context[
'mrp_role'] =
'toproduce';
414 $idstockmove = $stockmove->reception($user, $line->fk_product,
GETPOSTINT(
'idwarehousetoproduce-'.$line->id.
'-'.$i), $qtytoprocess, $pricetoprocess, $labelmovement,
GETPOSTDATE(
'eatby-'.$line->id.
'-'.$i),
GETPOSTDATE(
'sellby-'.$line->id.
'-'.$i),
GETPOST(
'batchtoproduce-'.$line->id.
'-'.$i),
dol_now(), $id_product_batch, $codemovement);
415 if ($idstockmove < 0) {
425 $moline->position = $pos;
426 $moline->fk_product = $line->fk_product;
427 $moline->fk_warehouse =
GETPOSTINT(
'idwarehousetoproduce-'.$line->id.
'-'.$i);
428 $moline->qty = $qtytoprocess;
429 $moline->batch =
GETPOST(
'batchtoproduce-'.$line->id.
'-'.$i);
430 $moline->role =
'produced';
431 $moline->fk_mrp_production = $line->id;
432 $moline->fk_stock_movement = (($idstockmove == 0) ?
null : $idstockmove);
433 $moline->fk_user_creat = $user->id;
435 $resultmoline = $moline->create($user);
436 if ($resultmoline <= 0) {
451 $consumptioncomplete =
true;
452 $productioncomplete =
true;
455 foreach (
$object->lines as $line) {
457 $tmpproduct->fetch($line->fk_product);
458 if ((
int) $tmpproduct->stockable_product > 0) {
459 if ($line->role ==
'toconsume') {
460 $arrayoflines =
$object->fetchLinesLinked(
'consumed', $line->id);
461 $alreadyconsumed = 0;
462 foreach ($arrayoflines as $line2) {
463 $alreadyconsumed += $line2[
'qty'];
466 if ($alreadyconsumed < $line->qty) {
467 $consumptioncomplete =
false;
470 if ($line->role ==
'toproduce') {
471 $arrayoflines =
$object->fetchLinesLinked(
'produced', $line->id);
472 $alreadyproduced = 0;
473 foreach ($arrayoflines as $line2) {
474 $alreadyproduced += $line2[
'qty'];
477 if ($alreadyproduced < $line->qty) {
478 $productioncomplete =
false;
484 $consumptioncomplete =
false;
485 $productioncomplete =
false;
489 dol_syslog(
"consumptioncomplete = ".json_encode($consumptioncomplete).
" productioncomplete = ".json_encode($productioncomplete));
490 if ($consumptioncomplete && $productioncomplete) {
491 $result =
$object->setStatut($object::STATUS_PRODUCED, 0,
'',
'MRP_MO_PRODUCED');
493 $result =
$object->setStatut($object::STATUS_INPROGRESS, 0,
'',
'MRP_MO_PRODUCED');
502 $action = str_replace(
'confirm_',
'', $action);
508 header(
"Location: ".$_SERVER[
"PHP_SELF"].
'?id='.
$object->id);
514 if ($action ==
'confirm_produced' && $confirm ==
'yes' && $permissiontoadd) {
515 $result =
$object->setStatut($object::STATUS_PRODUCED, 0,
'',
'MRP_MO_PRODUCED');
519 $outputlangs = $langs;
522 $newlang =
GETPOST(
'lang_id',
'aZ09');
525 $newlang =
$object->thirdparty->default_lang;
527 if (!empty($newlang)) {
529 $outputlangs->setDefaultLang($newlang);
534 $object->generateDocument($model, $outputlangs, 0, 0, 0);
541 if ($action ==
'confirm_editline' && $permissiontoadd) {
545 $extrafields->fetch_name_optionals_label($moline->table_element);
546 if (!empty($extrafields->attributes[$moline->table_element][
'label'])) {
547 foreach ($extrafields->attributes[$moline->table_element][
'label'] as $key => $label) {
548 $value =
GETPOST(
'options_'.$key,
'alphanohtml');
549 $moline->array_options[
"options_".$key] = $value;
553 if (GETPOSTISSET(
'warehouse_lineProduce')) {
554 $moline->fk_warehouse = (
GETPOSTINT(
'warehouse_lineProduce') > 0 ?
GETPOSTINT(
'warehouse_lineProduce') : 0);
556 if (GETPOSTISSET(
'workstation_lineProduce')) {
557 $moline->fk_default_workstation = (
GETPOSTINT(
'workstation_lineProduce') > 0 ?
GETPOSTINT(
'workstation_lineProduce') : 0);
560 $res = $moline->update($user);
564 header(
"Location: ".$_SERVER[
"PHP_SELF"].
'?id='.
$object->id);
567 header(
"Location: ".$_SERVER[
"PHP_SELF"].
'?id='.
$object->id);
586$title = $langs->trans(
'Mo');
587$help_url =
'EN:Module_Manufacturing_Orders|FR:Module_Ordres_de_Fabrication|DE:Modul_Fertigungsauftrag';
588$morejs = array(
'/mrp/js/lib_dispatch.js.php');
589llxHeader(
'', $title, $help_url,
'', 0, 0, $morejs,
'',
'',
'mod-mrp page-card_production');
591$newToken = newToken();
594if (
$object->id > 0 && (empty($action) || ($action !=
'edit' && $action !=
'create' && $action !=
'reload'))) {
595 $res =
$object->fetch_thirdparty();
596 $res =
$object->fetch_optionals();
599 $tmpwarehouse->fetch((
int)
$object->fk_warehouse);
600 $fk_default_warehouse = (int)
$object->fk_warehouse;
610 if ($action ==
'delete') {
611 $formquestion = array(
613 'label' => $langs->trans(
'MoCancelConsumedAndProducedLines'),
614 'name' =>
'alsoCancelConsumedAndProducedLines',
615 'type' =>
'checkbox',
619 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'DeleteMo'), $langs->trans(
'ConfirmDeleteMo'),
'confirm_delete', $formquestion, 0, 1);
622 if ($action ==
'deleteline') {
623 $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);
626 if ($action ==
'clone') {
628 $formquestion = array();
629 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'ToClone'), $langs->trans(
'ConfirmCloneMo',
$object->ref),
'confirm_clone', $formquestion,
'yes', 1);
633 if ($action ==
'validate') {
635 $ref = substr(
$object->ref, 1, 4);
636 if ($ref ==
'PROV') {
643 $text = $langs->trans(
'ConfirmValidateMo', $numref);
652 $formquestion = array();
655 require_once DOL_DOCUMENT_ROOT.
'/product/class/html.formproduct.class.php';
658 if (
$conf->browser->name ==
'ie') {
661 $formquestion = array(
668 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'Validate'), $text,
'confirm_validate', $formquestion, 0, 1, 220);
672 if ($action ==
'cancel') {
673 $formquestion = array(
675 'label' => $langs->trans(
'MoCancelConsumedAndProducedLines'),
676 'name' =>
'alsoCancelConsumedAndProducedLines',
677 'type' =>
'checkbox',
678 'value' => !
getDolGlobalString(
'MO_ALSO_CANCEL_CONSUMED_AND_PRODUCED_LINES_BY_DEFAULT') ? 0 : 1
681 $formconfirm = $form->formconfirm(
dolBuildUrl($_SERVER[
"PHP_SELF"], [
'id' =>
$object->id]), $langs->trans(
'CancelMo'), $langs->trans(
'ConfirmCancelMo'),
'confirm_cancel', $formquestion, 0, 1);
685 $parameters = array(
'formConfirm' => $formconfirm,
'lineid' => $lineid);
686 $reshook = $hookmanager->executeHooks(
'formConfirm', $parameters, $object, $action);
687 if (empty($reshook)) {
688 $formconfirm .= $hookmanager->resPrint;
689 } elseif ($reshook > 0) {
690 $formconfirm = $hookmanager->resPrint;
699 $linkback =
'<a href="'.DOL_URL_ROOT.
'/mrp/mo_list.php?restore_lastsearch_values=1'.(!empty($socid) ?
'&socid='.$socid :
'').
'">'.$langs->trans(
"BackToList").
'</a>';
701 $morehtmlref =
'<div class="refidno">';
710 if (is_object(
$object->thirdparty)) {
711 $morehtmlref .=
$object->thirdparty->getNomUrl(1,
'customer');
713 $morehtmlref .=
' (<a href="'.DOL_URL_ROOT.
'/commande/list.php?socid='.
$object->thirdparty->id.
'&search_societe='.urlencode(
$object->thirdparty->name).
'">'.$langs->trans(
"OtherOrders").
'</a>)';
719 $langs->load(
"projects");
720 if (is_object(
$object->thirdparty)) {
721 $morehtmlref .=
'<br>';
723 if ($permissiontoadd) {
724 $morehtmlref .=
img_picto($langs->trans(
"Project"),
'project',
'class="pictofixedwidth"');
725 if ($action !=
'classify') {
726 $morehtmlref .=
'<a class="editfielda" href="'.dolBuildUrl($_SERVER[
'PHP_SELF'], [
'action' =>
'classify',
'id' =>
$object->id],
true).
'">'.
img_edit($langs->transnoentitiesnoconv(
'SetProject')).
'</a> ';
728 $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');
730 if (!empty(
$object->fk_project)) {
732 $proj->fetch(
$object->fk_project);
733 $morehtmlref .= $proj->getNomUrl(1);
735 $morehtmlref .=
'<span class="opacitymedium"> - '.dol_escape_htmltag($proj->title).
'</span>';
740 $morehtmlref .=
'</div>';
743 dol_banner_tab($object,
'ref', $linkback, 1,
'ref',
'ref', $morehtmlref);
746 print
'<div class="fichecenter">';
747 print
'<div class="fichehalfleft">';
748 print
'<div class="underbanner clearboth"></div>';
749 print
'<table class="border centpercent tableforfield">'.
"\n";
752 $keyforbreak =
'fk_warehouse';
753 unset(
$object->fields[
'fk_project']);
754 unset(
$object->fields[
'fk_soc']);
760 if (
$object->status == Mo::STATUS_DRAFT && $permissiontoadd && isset(
$object->fields[
'qty'])) {
761 $object->fields[
'qty'][
'alwayseditable'] = 1;
762 if ($action ==
'editqty') {
763 $object->fields[
'qty'][
'type'] =
'numeric';
767 include DOL_DOCUMENT_ROOT.
'/core/tpl/commonfields_view.tpl.php';
770 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_view.tpl.php';
776 print
'<div class="clearboth"></div>';
781 if (!in_array($action, array(
'consumeorproduce',
'consumeandproduceall'))) {
782 print
'<div class="tabsAction">';
784 $parameters = array();
786 $reshook = $hookmanager->executeHooks(
'addMoreActionsButtons', $parameters, $object, $action);
787 if (empty($reshook)) {
789 if (
$object->status == $object::STATUS_DRAFT) {
790 if ($permissiontoadd) {
792 print
'<a class="butAction" href="'.$_SERVER[
'PHP_SELF'].
'?id='.
$object->id.
'&action=validate&token='.$newToken.
'">'.$langs->trans(
"Validate").
'</a>';
794 $langs->load(
"errors");
795 print
'<a class="butActionRefused" href="" title="'.$langs->trans(
"ErrorAddAtLeastOneLineFirst").
'">'.$langs->trans(
"Validate").
'</a>';
801 if (
$object->status == Mo::STATUS_VALIDATED ||
$object->status == Mo::STATUS_INPROGRESS) {
802 if ($permissiontoproduce) {
803 print
'<a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=consumeorproduce&token='.$newToken.
'">'.$langs->trans(
'ConsumeOrProduce').
'</a>';
805 print
'<a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans(
"NotEnoughPermissions").
'">'.$langs->trans(
'ConsumeOrProduce').
'</a>';
807 } elseif (
$object->status == Mo::STATUS_DRAFT) {
808 print
'<a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans(
"ValidateBefore").
'">'.$langs->trans(
'ConsumeOrProduce').
'</a>';
812 if (
$object->status == Mo::STATUS_VALIDATED ||
$object->status == Mo::STATUS_INPROGRESS) {
813 if ($permissiontoproduce) {
814 print
'<a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=consumeandproduceall&token='.$newToken.
'">'.$langs->trans(
'ConsumeAndProduceAll').
'</a>';
816 print
'<a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans(
"NotEnoughPermissions").
'">'.$langs->trans(
'ConsumeAndProduceAll').
'</a>';
818 } elseif (
$object->status == Mo::STATUS_DRAFT) {
819 print
'<a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans(
"ValidateBefore").
'">'.$langs->trans(
'ConsumeAndProduceAll').
'</a>';
823 if ($permissiontoadd) {
824 if (
$object->status == $object::STATUS_VALIDATED ||
$object->status == $object::STATUS_INPROGRESS) {
825 $arrayproduced =
$object->fetchLinesLinked(
'produced', 0);
827 foreach ($arrayproduced as $lineproduced) {
828 $nbProduced += $lineproduced[
'qty'];
830 if ($nbProduced > 0) {
831 print
'<a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=confirm_produced&confirm=yes&token='.$newToken.
'">'.$langs->trans(
"Close").
'</a>'.
"\n";
833 print
'<a class="butActionRefused" href="#" title="'.$langs->trans(
"GoOnTabProductionToProduceFirst", $langs->transnoentitiesnoconv(
"Production")).
'">'.$langs->trans(
"Close").
'</a>'.
"\n";
836 print
'<a class="butActionDelete" href="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=cancel&token='.$newToken.
'">'.$langs->trans(
"Cancel").
'</a>'.
"\n";
839 if (
$object->status == $object::STATUS_CANCELED) {
840 print
'<a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=confirm_reopen&confirm=yes&token='.$newToken.
'">'.$langs->trans(
"ReOpen").
'</a>'.
"\n";
843 if (
$object->status == $object::STATUS_PRODUCED) {
844 if ($permissiontoproduce) {
845 print
'<a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=confirm_reopen&token='.$newToken.
'">'.$langs->trans(
'ReOpen').
'</a>';
847 print
'<a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans(
"NotEnoughPermissions").
'">'.$langs->trans(
'ReOpen').
'</a>';
856 if (in_array($action, array(
'consumeorproduce',
'consumeandproduceall',
'addconsumeline',
'addproduceline',
'editline'))) {
857 print
'<!-- Form to enter value for consumption/production -->';
858 print
'<form method="POST" action="'.dolBuildUrl($_SERVER[
"PHP_SELF"]).
'">';
859 print
'<input type="hidden" name="token" value="'.newToken().
'">';
860 print
'<input type="hidden" name="action" value="confirm_'.$action.
'">';
861 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
862 print
'<input type="hidden" name="id" value="'.$id.
'">';
865 if (in_array($action, array(
'consumeorproduce',
'consumeandproduceall'))) {
866 $defaultstockmovementlabel =
GETPOST(
'inventorylabel',
'alphanohtml') ?
GETPOST(
'inventorylabel',
'alphanohtml') : $langs->trans(
"ProductionForRef",
$object->
ref);
869 print
'<div class="center'.(in_array($action, array(
'consumeorproduce',
'consumeandproduceall')) ?
' formconsumeproduce' :
'').
'">';
870 print
'<div class="opacitymedium hideonsmartphone paddingbottom marginbottomonly">'.$langs->trans(
"ConfirmProductionDesc", $langs->transnoentitiesnoconv(
"Confirm")).
'<br></div>';
871 print
'<span class="paddingright">'.$langs->trans(
"InventoryCode").
':</span>';
872 print
'<span class="clearbothonsmartphone"></span>';
873 print
'<input type="text" class="minwidth125 maxwidth150" name="inventorycode" value="'.$defaultstockmovementcode.
'">';
874 print
'<span class="hideonsmartphone"> </span>';
875 print
'<span class="clearbothonsmartphone"></span>';
876 print
'<span class="paddingright">'.$langs->trans(
"MovementLabel").
':</span>';
877 print
'<span class="clearbothonsmartphone"></span>';
878 print
'<input type="text" class="minwidth300" name="inventorylabel" value="'.$defaultstockmovementlabel.
'"><br><br>';
879 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>';
880 print
'<input type="submit" class="button margintoponly" value="'.$langs->trans(
"Confirm").
'" name="confirm">';
882 print
'<input class="button margintoponly button-cancel" type="submit" value="'.$langs->trans(
"Cancel").
'" name="cancel">';
896 if (!empty(
$object->table_element_line)) {
903 $res = $bom->fetch(
$object->fk_bom);
905 $bom->calculateCosts();
906 $bomcost = $bom->unit_cost;
912 print
'<!-- Lines to consume -->'.
"\n";
913 print
'<div class="fichecenter">';
914 print
'<div class="fichehalfleft">';
915 print
'<div class="clearboth"></div>';
917 $url = $_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=addconsumeline&token='.newToken();
918 $permissiontoaddaconsumeline = (
$object->status != $object::STATUS_PRODUCED &&
$object->status != $object::STATUS_CANCELED) ? 1 : -2;
919 $parameters = array(
'morecss' =>
'reposition');
921 if ($permissiontoaddaconsumeline == -2) {
922 $helpText = $langs->trans(
'MOIsClosed');
926 if ($action !=
'consumeorproduce' && $action !=
'consumeandproduceall') {
927 $newcardbutton = dolGetButtonTitle($langs->trans(
'AddNewConsumeLines'), $helpText,
'fa fa-plus-circle size15x', $url,
'', $permissiontoaddaconsumeline, $parameters);
930 print
load_fiche_titre($langs->trans(
'Consumption'), $newcardbutton,
'', 0,
'',
'',
'');
932 print
'<div class="div-table-responsive-no-min">';
933 print
'<table class="noborder noshadow centpercent nobottom">';
935 print
'<!-- Line of title for products to consume -->'.
"\n";
936 print
'<tr class="liste_titre trheight5em">';
938 print
'<td>'.$langs->trans(
"Product").
'</td>';
940 print
'<td class="right">'.$langs->trans(
"Qty").
'</td>';
945 print
'<td class="right">'.$langs->trans(
"UnitCost").
'</td>';
948 print
'<td class="right classfortooltip" title="'.$langs->trans(
"QtyAlreadyConsumed").
'">';
949 print $langs->trans(
"QtyAlreadyConsumedShort");
953 if ($collapse || in_array($action, array(
'consumeorproduce',
'consumeandproduceall'))) {
954 print $langs->trans(
"Warehouse");
956 print
' '.$langs->trans(
"or").
' '.$langs->trans(
"Workstation");
959 if (in_array($action, array(
'consumeorproduce',
'consumeandproduceall'))) {
960 $listwarehouses = $tmpwarehouse->list_array(1);
961 if (count($listwarehouses) > 1) {
962 print
'<br>'.$form->selectarray(
'fk_default_warehouse', $listwarehouses, $fk_default_warehouse, $langs->trans(
"ForceTo"), 0, 0,
'', 0, 0, 0,
'',
'minwidth100 maxwidth200', 1);
963 } elseif (count($listwarehouses) == 1) {
964 print
'<br>'.$form->selectarray(
'fk_default_warehouse', $listwarehouses, $fk_default_warehouse, 0, 0, 0,
'', 0, 0, 0,
'',
'minwidth100 maxwidth200', 1);
972 print
'<td align="right">';
973 if ($collapse || in_array($action, array(
'consumeorproduce',
'consumeandproduceall'))) {
974 print $langs->trans(
"Stock");
981 if ($collapse || in_array($action, array(
'consumeorproduce',
'consumeandproduceall'))) {
982 print $langs->trans(
"Batch");
994 if (
$object->status == Mo::STATUS_DRAFT) {
999 if ($permissiontodelete) {
1005 if ($action ==
'addconsumeline') {
1006 print
'<!-- Add line to consume -->'.
"\n";
1007 print
'<tr class="liste_titre">';
1010 print $form->select_produits(0,
'productidtoadd',
'', 0, 0, -1, 2,
'', 1, array(), 0,
'1', 0,
'maxwidth150');
1013 print
'<td class="right"><input type="text" name="qtytoadd" value="1" class="width40 right"></td>';
1021 if ($permissiontoupdatecost &&
getDolGlobalString(
'MRP_SHOW_COST_FOR_CONSUMPTION')) {
1033 print
'<td colspan="'.$colspan.
'">';
1034 print
'<input type="submit" class="button buttongen button-add" name="addconsumelinebutton" value="'.$langs->trans(
"Add").
'">';
1035 print
'<input type="submit" class="button buttongen button-cancel" name="canceladdconsumelinebutton" value="'.$langs->trans(
"Cancel").
'">';
1040 if (
$object->status == Mo::STATUS_DRAFT) {
1044 if ($permissiontodelete) {
1050 if (is_object($objectline)) {
1051 $extrafields->fetch_name_optionals_label(
$object->table_element_line);
1052 $temps = $objectline->showOptionals($extrafields,
'edit', array(),
'',
'',
'1',
'line');
1053 if (!empty($temps)) {
1054 print
'<tr class="liste_titre"><td style="padding-top: 20px" colspan="9" id="extrafield_lines_area_edit" name="extrafield_lines_area_edit">';
1063 $bomcostupdated = 0;
1066 $nblinetoconsume = 0;
1067 foreach (
$object->lines as $line) {
1068 if ($line->role ==
'toconsume') {
1073 $nblinetoconsumecursor = 0;
1074 foreach (
$object->lines as $line) {
1075 if ($line->role ==
'toconsume') {
1076 $nblinetoconsumecursor++;
1079 $tmpproduct->fetch($line->fk_product);
1080 $linecost =
price2num($tmpproduct->pmp,
'MT');
1084 $costprice =
price2num((!empty($tmpproduct->cost_price)) ? $tmpproduct->cost_price : $tmpproduct->pmp);
1085 if (empty($costprice)) {
1086 require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.product.class.php';
1088 if ($productFournisseur->find_min_price_product_fournisseur($line->fk_product, $line->qty) > 0) {
1089 $costprice = $productFournisseur->fourn_unitprice;
1097 if ($useunit && $line->fk_unit > 0) {
1099 $qtyhourservice = 0;
1100 if (preg_match(
'/^(\d+)([a-z]+)$/', $tmpproduct->duration, $reg)) {
1103 $qtyhourforline = 0;
1104 if ($line->fk_unit) {
1109 if ($qtyhourservice && $qtyhourforline) {
1110 $linecost =
price2num(($qtyhourforline / $qtyhourservice * $costprice) /
$object->qty,
'MT');
1111 $bomcostupdated +=
price2num(($qtyhourforline / $qtyhourservice * $costprice) /
$object->qty,
'MU');
1114 $bomcostupdated +=
price2num(($line->qty * $costprice) /
$object->qty,
'MU');
1118 $bomcostupdated +=
price2num(($line->qty * $costprice) /
$object->qty,
'MU');
1122 $bomcostupdated =
price2num($bomcostupdated,
'MU');
1123 $arrayoflines =
$object->fetchLinesLinked(
'consumed', $line->id);
1124 $alreadyconsumed = 0;
1125 foreach ($arrayoflines as $line2) {
1126 $alreadyconsumed += $line2[
'qty'];
1129 if ($action ==
'editline' && $lineid == $line->id) {
1130 $linecost =
price2num($tmpproduct->pmp,
'MT');
1132 $arrayoflines =
$object->fetchLinesLinked(
'consumed', $line->id);
1133 $alreadyconsumed = 0;
1134 if (is_array($arrayoflines) && !empty($arrayoflines)) {
1135 foreach ($arrayoflines as $line2) {
1136 $alreadyconsumed += $line2[
'qty'];
1139 $suffix =
'_' . $line->id;
1140 print
'<!-- Line to dispatch ' . $suffix .
' (line edited) -->' .
"\n";
1142 print
'<input id="qty_ordered' . $suffix .
'" type="hidden" value="' . $line->qty .
'">';
1144 print
'<input id="qty_dispatched' . $suffix .
'" type="hidden" value="' . $alreadyconsumed .
'">';
1146 print
'<input name="lineid" type="hidden" value="' . $line->id .
'">';
1149 print
'<td>' . $tmpproduct->getNomUrl(1);
1150 print
'<br><div class="opacitymedium small tdoverflowmax150" title="' .
dol_escape_htmltag($tmpproduct->label) .
'">' . $tmpproduct->label .
'</span>';
1154 print
'<td class="right nowraponall">';
1155 print
'<input class="width40 right" name="qty_lineProduce" value="'. $line->qty.
'">';
1159 print
'<td class="right nowraponall">';
1167 if ($permissiontoupdatecost &&
getDolGlobalString(
'MRP_SHOW_COST_FOR_CONSUMPTION')) {
1172 print
'<td class="right">';
1173 print
' ' .
price2num($alreadyconsumed,
'MS');
1179 print $formproduct->selectWarehouses($line->fk_warehouse,
'warehouse_lineProduce',
'warehouseopen', 1);
1181 print $formproduct->selectWorkstations($line->fk_default_workstation,
'workstation_lineProduce', 1);
1187 print
'<td class="nowraponall right">';
1188 if ($tmpproduct->isStockManaged()) {
1189 if ($tmpproduct->stock_reel < ($line->qty - $alreadyconsumed)) {
1190 print
img_warning($langs->trans(
'StockTooLow')).
' ';
1192 print
'<span class="left">'. $tmpproduct->stock_reel .
' </span>';
1202 print
'<td colspan="'.(3 + (
$object->status == Mo::STATUS_DRAFT ? 1 : 0) + ($permissiontodelete ? 1 : 0)).
'">';
1203 print
'<input type="submit" class="button buttongen button-add small nominwidth" name="save" value="' . $langs->trans(
"Save") .
'">';
1204 print
'<input type="submit" class="button buttongen button-cancel small nominwidth" name="cancel" value="' . $langs->trans(
"Cancel") .
'">';
1210 if (!empty($extrafields)) {
1211 $line->fetch_optionals();
1212 $temps = $line->showOptionals($extrafields,
'edit', array(),
'',
'',
'1',
'line');
1213 if (!empty($temps)) {
1215 print
'<tr><td colspan="'.$colspan.
'"><div style="padding-top: 20px" id="extrafield_lines_area_edit" name="extrafield_lines_area_edit">';
1217 print
'</div></td></tr>';
1221 $suffix =
'_' . $line->id;
1222 print
'<!-- Line to dispatch ' . $suffix .
' -->' .
"\n";
1224 print
'<input id="qty_ordered' . $suffix .
'" type="hidden" value="' . $line->qty .
'">';
1225 print
'<input id="qty_dispatched' . $suffix .
'" type="hidden" value="' . $alreadyconsumed .
'">';
1227 print
'<tr data-line-id="' . $line->id .
'">';
1230 print
'<td>' . $tmpproduct->getNomUrl(1);
1231 print
'<br><div class="opacitymedium small tdoverflowmax150" title="' .
dol_escape_htmltag($tmpproduct->label) .
'">' . $tmpproduct->label .
'</div>';
1235 print
'<td class="right nowraponall">';
1237 if ($line->qty_frozen) {
1238 $help = ($help ?
'<br>' :
'') .
'<strong>' . $langs->trans(
"QuantityFrozen") .
'</strong>: ' .
yn(1) .
' (' . $langs->trans(
"QuantityConsumedInvariable") .
')';
1239 print $form->textwithpicto(
'', $help, -1,
'lock') .
' ';
1241 if ($line->disable_stock_change) {
1242 $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")) .
')';
1243 print $form->textwithpicto(
'', $help, -1,
'help') .
' ';
1249 print
'<td class="right nowraponall">';
1257 if ($permissiontoupdatecost &&
getDolGlobalString(
'MRP_SHOW_COST_FOR_CONSUMPTION')) {
1258 print
'<td class="right nowraponall">';
1259 print
price($linecost);
1264 print
'<td class="right">';
1265 if ($alreadyconsumed) {
1267 print
'jQuery(document).ready(function() {
1268 jQuery("#expandtoproduce' . $line->id .
'").click(function() {
1269 console.log("Expand mrp_production line ' . $line->id .
'");
1270 jQuery(".expanddetail' . $line->id .
'").toggle();';
1271 if ($nblinetoconsume == $nblinetoconsumecursor) {
1272 print
'if (jQuery("#tablelines").hasClass("nobottom")) { jQuery("#tablelines").removeClass("nobottom"); } else { jQuery("#tablelines").addClass("nobottom"); }';
1278 if (empty(
$conf->use_javascript_ajax)) {
1279 print
'<a href="' . $_SERVER[
"PHP_SELF"] .
'?collapse=' . $collapse .
',' . $line->id .
'">';
1281 print
img_picto($langs->trans(
"ShowDetails"),
"chevron-down",
'id="expandtoproduce' . $line->id .
'"');
1282 if (empty(
$conf->use_javascript_ajax)) {
1286 if ($nblinetoconsume == $nblinetoconsumecursor) {
1287 print
'<script>jQuery("#tablelines").removeClass("nobottom");</script>';
1290 print
' ' .
price2num($alreadyconsumed,
'MS');
1294 print
'<td class="tdoverflowmax100">';
1295 if ($tmpproduct->isStockManaged()) {
1297 if (
getDolGlobalString(
'STOCK_CONSUMPTION_FROM_MANUFACTURING_WAREHOUSE') && $tmpwarehouse->id > 0) {
1298 print
img_picto(
'', $tmpwarehouse->picto) .
" " . $tmpwarehouse->label;
1300 if ($line->fk_warehouse > 0) {
1302 $warehouseline->fetch($line->fk_warehouse);
1303 print $warehouseline->getNomUrl(1);
1307 if (
isModEnabled(
'workstation') && $line->fk_default_workstation > 0) {
1309 $tmpworkstation->fetch($line->fk_default_workstation);
1310 print $tmpworkstation->getNomUrl(1);
1316 print
'<td class="nowraponall right">';
1318 if (!$line->disable_stock_change && $tmpproduct->stock_reel < ($line->qty - $alreadyconsumed)) {
1319 print
img_warning($langs->trans(
'StockTooLow')) .
' ';
1321 if (!
getDolGlobalString(
'STOCK_CONSUMPTION_FROM_MANUFACTURING_WAREHOUSE') || empty($tmpwarehouse->id)) {
1322 print
price2num($tmpproduct->stock_reel,
'MS');
1325 $tmpproduct->load_stock();
1326 $wh_stock = $tmpproduct->stock_warehouse[$tmpwarehouse->id];
1327 if (!empty($wh_stock)) {
1349 if (
$object->status == Mo::STATUS_DRAFT) {
1350 $href = $_SERVER[
"PHP_SELF"] .
'?id=' . ((int)
$object->id) .
'&action=editline&token=' . newToken() .
'&lineid=' . ((int) $line->id);
1351 print
'<td class="center">';
1352 print
'<a class="reposition editfielda" href="' . $href .
'">';
1353 print
img_picto($langs->trans(
'TooltipEditAndRevertStockMovement'),
'edit');
1359 if ($permissiontodelete && empty($arrayoflines)) {
1360 $href = $_SERVER[
"PHP_SELF"] .
'?id=' . ((int)
$object->id) .
'&action=deleteline&token=' . newToken() .
'&lineid=' . ((int) $line->id);
1361 print
'<td class="center">';
1362 print
'<a class="reposition" href="' . $href .
'">';
1363 print
img_picto($langs->trans(
'TooltipDeleteAndRevertStockMovement'),
'delete');
1371 if (!empty($extrafields)) {
1372 $line->fetch_optionals();
1373 $temps = $line->showOptionals($extrafields,
'view', array(),
'',
'',
'1',
'line');
1374 if (!empty($temps)) {
1376 print
'<tr><td colspan="'.$colspan.
'"><div id="extrafield_lines_area_'.$line->id.
'" name="extrafield_lines_area_'.$line->id.
'">';
1378 print
'</div></td></tr>';
1384 foreach ($arrayoflines as $line2) {
1385 print
'<tr class="expanddetail'.$line->id.
' hideobject opacitylow">';
1389 $tmpstockmovement->id = $line2[
'fk_stock_movement'];
1390 print
'<a href="'.DOL_URL_ROOT.
'/product/stock/movement_list.php?search_ref='.$tmpstockmovement->id.
'">'.
img_picto($langs->trans(
"StockMovement"),
'movement',
'class="paddingright"').
'</a>';
1401 if ($permissiontoupdatecost &&
getDolGlobalString(
'MRP_SHOW_COST_FOR_CONSUMPTION')) {
1406 print
'<td class="right">'.$line2[
'qty'].
'</td>';
1409 print
'<td class="tdoverflowmax150">';
1410 if ($line2[
'fk_warehouse'] > 0) {
1411 $result = $tmpwarehouse->fetch($line2[
'fk_warehouse']);
1413 print $tmpwarehouse->getNomUrl(1);
1426 if ($line2[
'batch'] !=
'') {
1427 $tmpbatch->fetch(0, $line2[
'fk_product'], $line2[
'batch']);
1428 print $tmpbatch->getNomUrl(1);
1440 if (
$object->status == Mo::STATUS_DRAFT) {
1441 $href = $_SERVER[
"PHP_SELF"] .
'?id=' . ((int)
$object->id) .
'&action=editline&token=' . newToken() .
'&lineid=' . ((int) $line2[
'rowid']);
1442 print
'<td class="center">';
1443 print
'<a class="reposition" href="' . $href .
'">';
1444 print
img_picto($langs->trans(
'TooltipEditAndRevertStockMovement'),
'edit');
1450 if ($permissiontodelete) {
1451 $href = $_SERVER[
"PHP_SELF"].
'?id='.((int)
$object->id).
'&action=deleteline&token='.newToken().
'&lineid='.((int) $line2[
'rowid']).
'&fk_movement='.((int) $line2[
'fk_stock_movement']);
1452 print
'<td class="center">';
1453 print
'<a class="reposition" href="'.$href.
'">';
1454 print
img_picto($langs->trans(
'TooltipDeleteAndRevertStockMovement'),
'delete');
1462 if (in_array($action, array(
'consumeorproduce',
'consumeandproduceall'))) {
1464 print
'<!-- Enter line to consume -->'.
"\n";
1466 print
'<tr data-max-qty="'.$maxQty.
'" name="batch_'.$line->id.
'_'.$i.
'">';
1468 print
'<td><span class="opacitymedium">'.$langs->trans(
"ToConsume").
'</span></td>';
1469 $preselected = (GETPOSTISSET(
'qty-'.$line->id.
'-'.$i) ?
GETPOST(
'qty-'.$line->id.
'-'.$i) : max(0, $line->qty - $alreadyconsumed));
1470 if ($action ==
'consumeorproduce' && !
getDolGlobalString(
'MRP_AUTO_SET_REMAINING_QUANTITIES_TO_BE_CONSUMED') && !GETPOSTISSET(
'qty-'.$line->id.
'-'.$i)) {
1475 if (
getDolGlobalString(
'MRP_NEVER_CONSUME_MORE_THAN_EXPECTED') && ($line->qty - $alreadyconsumed) <= 0) {
1476 $disable =
'disabled';
1480 print
'<input type="hidden" name="product-'.$line->id.
'-'.$i.
'" value="'.$line->fk_product.
'">';
1483 print
'<td class="right">';
1484 if ((
int) $tmpproduct->stockable_product > 0) {
1485 print
'<input type="text" class="width50 right" id="qtytoconsume-' . $line->id .
'-' . $i .
'" name="qty-' . $line->id .
'-' . $i .
'" value="' . $preselected .
'" ' . $disable .
'>';
1487 print
'<input type="hidden" id="qtytoconsume-' . $line->id .
'-' . $i .
'" name="qty-' . $line->id .
'-' . $i .
'" value="0">';
1488 print
'<span class="opacitymedium">' . $langs->trans(
"StockDisabled") .
'</span>';
1496 if ($permissiontoupdatecost &&
getDolGlobalString(
'MRP_SHOW_COST_FOR_CONSUMPTION')) {
1506 && ((
int) $tmpproduct->stockable_product > 0)) {
1507 if (empty($line->disable_stock_change)) {
1508 $preselected = (GETPOSTISSET(
'idwarehouse-'.$line->id.
'-'.$i) ?
GETPOST(
'idwarehouse-'.$line->id.
'-'.$i) : ($tmpproduct->fk_default_warehouse > 0 ? $tmpproduct->fk_default_warehouse :
'ifone'));
1509 print $formproduct->selectWarehouses($preselected,
'idwarehouse-'.$line->id.
'-'.$i,
'', 1, 0, $line->fk_product,
'', 1, 0, array(),
'maxwidth200 csswarehouse_'.$line->id.
'_'.$i);
1511 print
'<span class="opacitymedium">'.$langs->trans(
"DisableStockChange").
'</span>';
1514 if ((
int) $tmpproduct->stockable_product > 0) {
1515 print
'<span class="opacitymedium">' . $langs->trans(
"StockDisabled") .
'</span>';
1517 print
'<span class="opacitymedium">' . $langs->trans(
"NoStockChangeOnServices") .
'</span>';
1529 print
'<td class="nowraponall">';
1530 if ($tmpproduct->status_batch) {
1531 $preselected = (GETPOSTISSET(
'batch-'.$line->id.
'-'.$i) ?
GETPOST(
'batch-'.$line->id.
'-'.$i) :
'');
1532 print
'<input type="text" class="width75" name="batch-'.$line->id.
'-'.$i.
'" value="'.$preselected.
'" list="batch-'.$line->id.
'-'.$i.
'">';
1533 print $formproduct->selectLotDataList(
'batch-'.$line->id.
'-'.$i, 0, $line->fk_product, 0, array());
1540 print
'<td align="right" class="split">';
1541 print
' '.img_picto($langs->trans(
'AddStockLocationLine'),
'split',
'class="splitbutton" onClick="addDispatchLine('.((int) $line->id).
', \''.
dol_escape_js($type).
'\', \
'qtymissingconsume\')"');
1545 print
'<td align="right" class="splitall">';
1546 if (($action ==
'consumeorproduce' || $action ==
'consumeandproduceall') && $tmpproduct->status_batch == 2) {
1547 print
img_picto($langs->trans(
'SplitAllQuantity'),
'split',
'class="splitbutton splitallbutton field-error-icon" data-max-qty="1" onClick="addDispatchLine('.$line->id.
', \'batch\', \'allmissingconsume\')"');
1552 if (
$object->status == Mo::STATUS_DRAFT) {
1557 if ($permissiontodelete) {
1571 print
'<script type="text/javascript">
1572 $(document).ready(function () {
1573 $("select[name=fk_default_warehouse]").change(function() {
1574 var fk_default_warehouse = $("option:selected", this).val();
1575 $("select[name^=idwarehouse-]").val(fk_default_warehouse).change();
1580 if (in_array($action, array(
'consumeorproduce',
'consumeandproduceall')) &&
1582 print
'<script>$(document).ready(function () {
1583 $("#fk_default_warehouse").change();
1591 print
'<div class="fichehalfright">';
1592 print
'<div class="clearboth"></div>';
1594 $nblinetoproduce = 0;
1595 $atLeastOneEatBy =
false;
1596 $atLeastOneSellBy =
false;
1597 foreach (
$object->lines as $line) {
1598 if ($line->role ==
'toproduce') {
1600 $tmpproduct->fetch($line->fk_product);
1602 $tmpproduct->sell_or_eat_by_mandatory == $tmpproduct::SELL_OR_EAT_BY_MANDATORY_ID_EAT_BY
1603 || $tmpproduct->sell_or_eat_by_mandatory == $tmpproduct::SELL_OR_EAT_BY_MANDATORY_ID_SELL_AND_EAT
1605 $atLeastOneEatBy =
true;
1608 $tmpproduct->sell_or_eat_by_mandatory == $tmpproduct::SELL_OR_EAT_BY_MANDATORY_ID_SELL_BY
1609 || $tmpproduct->sell_or_eat_by_mandatory == $tmpproduct::SELL_OR_EAT_BY_MANDATORY_ID_SELL_AND_EAT
1611 $atLeastOneSellBy =
true;
1617 $newcardbutton =
'';
1618 $url = $_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=addproduceline&token='.newToken();
1619 $permissiontoaddaproductline =
$object->status != $object::STATUS_PRODUCED &&
$object->status != $object::STATUS_CANCELED;
1620 $parameters = array(
'morecss' =>
'reposition');
1621 if ($action !=
'consumeorproduce' && $action !=
'consumeandproduceall') {
1622 if ($nblinetoproduce == 0 ||
$object->mrptype == 1) {
1623 $newcardbutton = dolGetButtonTitle($langs->trans(
'AddNewProduceLines'),
'',
'fa fa-plus-circle size15x', $url,
'', (
int) $permissiontoaddaproductline, $parameters);
1627 print
load_fiche_titre($langs->trans(
'Production'), $newcardbutton,
'', 0,
'',
'');
1629 print
'<div class="div-table-responsive-no-min">';
1630 print
'<table id="tablelinestoproduce" class="noborder noshadow nobottom centpercent">';
1632 print
'<tr class="liste_titre trheight5em">';
1634 print
'<td>'.$langs->trans(
"Product").
'</td>';
1636 print
'<td class="right">'.$langs->trans(
"Qty").
'</td>';
1639 print
'<td class="right">'.$langs->trans(
"Unit").
'</td>';
1642 if ($permissiontoupdatecost) {
1643 if (empty($bomcostupdated)) {
1644 print
'<td class="right classfortooltip" title="'.$langs->trans(
"AmountUsedToUpdateWAP").
'">';
1645 print $langs->trans(
"UnitCost");
1648 print
'<td class="right classfortooltip" title="'.$langs->trans(
"AmountUsedToUpdateWAP").
'">';
1649 print $langs->trans(
"ManufacturingPrice");
1654 print
'<td class="right classfortooltip" title="'.$langs->trans(
"QtyAlreadyProduced").
'">';
1655 print $langs->trans(
"QtyAlreadyProducedShort");
1659 if ($collapse || in_array($action, array(
'consumeorproduce',
'consumeandproduceall'))) {
1660 print $langs->trans(
"Warehouse");
1667 if ($collapse || in_array($action, array(
'consumeorproduce',
'consumeandproduceall'))) {
1668 print $langs->trans(
"Batch");
1679 if ($atLeastOneEatBy) {
1680 print
'<td>'.$langs->trans(
"EatByDate").
'</td>';
1684 if ($atLeastOneSellBy) {
1685 print
'<td>'.$langs->trans(
"SellByDate").
'</td>';
1690 if ($permissiontodelete) {
1696 if ($action ==
'addproduceline') {
1697 print
'<!-- Add line to produce -->'.
"\n";
1698 print
'<tr class="liste_titre">';
1702 print $form->select_produits(0,
'productidtoadd',
'', 0, 0, -1, 2,
'', 1, array(), 0,
'1', 0,
'maxwidth300');
1705 print
'<td class="right"><input type="text" name="qtytoadd" value="1" class="width50 right"></td>';
1711 if ($permissiontoupdatecost) {
1715 print
'<td colspan="2">';
1716 print
'<input type="submit" class="button buttongen button-add" name="addproducelinebutton" value="'.$langs->trans(
"Add").
'">';
1717 print
'<input type="submit" class="button buttongen button-cancel" name="canceladdproducelinebutton" value="'.$langs->trans(
"Cancel").
'">';
1730 if ($permissiontodelete) {
1737 $nblinetoproduce = 0;
1738 foreach (
$object->lines as $line) {
1739 if ($line->role ==
'toproduce') {
1744 $nblinetoproducecursor = 0;
1745 foreach (
$object->lines as $line) {
1746 if ($line->role ==
'toproduce') {
1749 $nblinetoproducecursor++;
1752 $tmpproduct->fetch($line->fk_product);
1754 $arrayoflines =
$object->fetchLinesLinked(
'produced', $line->id);
1755 $alreadyproduced = 0;
1756 foreach ($arrayoflines as $line2) {
1757 $alreadyproduced += $line2[
'qty'];
1760 $suffix =
'_'.$line->id;
1761 print
'<!-- Line to dispatch '.$suffix.
' (toproduce) -->'.
"\n";
1763 print
'<input id="qty_ordered'.$suffix.
'" type="hidden" value="'.$line->qty.
'">';
1764 print
'<input id="qty_dispatched'.$suffix.
'" type="hidden" value="'.$alreadyproduced.
'">';
1768 print
'<td>'.$tmpproduct->getNomUrl(1);
1769 print
'<br><span class="opacitymedium small">'.$tmpproduct->label.
'</span>';
1772 print
'<td class="right">'.$line->qty.
'</td>';
1775 print
'<td class="right">'.measuringUnitString($line->fk_unit,
'',
null, 1).
'</td>';
1778 if ($permissiontoupdatecost) {
1780 $manufacturingcost = 0;
1781 $manufacturingcostsrc =
'';
1783 $manufacturingcost = $bomcostupdated;
1784 $manufacturingcostsrc = $langs->trans(
"CalculatedFromProductsToConsume");
1785 if (empty($manufacturingcost)) {
1786 $manufacturingcost = $bomcost;
1787 $manufacturingcostsrc = $langs->trans(
"ValueFromBom");
1789 if (empty($manufacturingcost)) {
1790 $manufacturingcost =
price2num($tmpproduct->cost_price,
'MU');
1791 $manufacturingcostsrc = $langs->trans(
"CostPrice");
1793 if (empty($manufacturingcost)) {
1794 $manufacturingcost =
price2num($tmpproduct->pmp,
'MU');
1795 $manufacturingcostsrc = $langs->trans(
"PMPValue");
1799 print
'<td class="right nowraponall" title="'.dol_escape_htmltag($manufacturingcostsrc).
'">';
1800 if ($manufacturingcost) {
1801 print
price($manufacturingcost);
1806 print
'<td class="right nowraponall">';
1807 if ($alreadyproduced) {
1809 print
'jQuery(document).ready(function() {
1810 jQuery("#expandtoproduce'.$line->id.
'").click(function() {
1811 console.log("Expand mrp_production line '.$line->id.
'");
1812 jQuery(".expanddetailtoproduce'.$line->id.
'").toggle();';
1813 if ($nblinetoproduce == $nblinetoproducecursor) {
1814 print
'if (jQuery("#tablelinestoproduce").hasClass("nobottom")) { jQuery("#tablelinestoproduce").removeClass("nobottom"); } else { jQuery("#tablelinestoproduce").addClass("nobottom"); }';
1820 if (empty(
$conf->use_javascript_ajax)) {
1821 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?collapse='.$collapse.
','.$line->id.
'">';
1823 print
img_picto($langs->trans(
"ShowDetails"),
"chevron-down",
'id="expandtoproduce'.$line->id.
'"');
1824 if (empty(
$conf->use_javascript_ajax)) {
1828 print
' '.$alreadyproduced;
1844 if ($permissiontodelete) {
1845 if ($line->origin_type ==
'free') {
1846 $href = $_SERVER[
"PHP_SELF"];
1847 $href .=
'?id='.$object->id;
1848 $href .=
'&action=deleteline';
1849 $href .=
'&token='.newToken();
1850 $href .=
'&lineid='.$line->id;
1851 print
'<td class="center">';
1852 print
'<a class="reposition" href="'.$href.
'">';
1853 print
img_picto($langs->trans(
'TooltipDeleteAndRevertStockMovement'),
"delete");
1863 foreach ($arrayoflines as $line2) {
1864 print
'<tr class="expanddetailtoproduce'.$line->id.
' hideobject opacitylow">';
1867 $tmpstockmovement->id = $line2[
'fk_stock_movement'];
1868 print
'<a href="'.DOL_URL_ROOT.
'/product/stock/movement_list.php?search_ref='.$tmpstockmovement->id.
'">'.
img_picto($langs->trans(
"StockMovement"),
'movement',
'class="paddingright"').
'</a>';
1878 if ($permissiontoupdatecost) {
1882 print
'<td class="right">'.$line2[
'qty'].
'</td>';
1884 print
'<td class="tdoverflowmax150">';
1885 if ($line2[
'fk_warehouse'] > 0) {
1886 $result = $tmpwarehouse->fetch($line2[
'fk_warehouse']);
1888 print $tmpwarehouse->getNomUrl(1);
1895 if ($line2[
'batch'] !=
'') {
1896 $tmpbatch->fetch(0, $line2[
'fk_product'], $line2[
'batch']);
1897 print $tmpbatch->getNomUrl(1);
1908 if ($permissiontodelete) {
1914 if (in_array($action, array(
'consumeorproduce',
'consumeandproduceall'))) {
1915 print
'<!-- Enter line to produce -->'.
"\n";
1917 print
'<tr data-max-qty="'.$maxQty.
'" name="batch_'.$line->id.
'_'.$i.
'">';
1919 print
'<td><span class="opacitymedium">'.$langs->trans(
"ToProduce").
'</span></td>';
1920 $preselected = (GETPOSTISSET(
'qtytoproduce-'.$line->id.
'-'.$i) ?
GETPOST(
'qtytoproduce-'.$line->id.
'-'.$i) : max(0, $line->qty - $alreadyproduced));
1921 if ($action ==
'consumeorproduce' && !GETPOSTISSET(
'qtytoproduce-'.$line->id.
'-'.$i)) {
1925 print
'<td class="right"><input type="text" class="width50 right" id="qtytoproduce-'.$line->id.
'-'.$i.
'" name="qtytoproduce-'.$line->id.
'-'.$i.
'" value="'.$preselected.
'"></td>';
1928 print
'<td class="right"></td>';
1931 if ($permissiontoupdatecost) {
1933 $manufacturingcost = 0;
1934 $manufacturingcostsrc =
'';
1936 $manufacturingcost = $bomcostupdated;
1937 $manufacturingcostsrc = $langs->trans(
"CalculatedFromProductsToConsume");
1938 if (empty($manufacturingcost)) {
1939 $manufacturingcost = $bomcost;
1940 $manufacturingcostsrc = $langs->trans(
"ValueFromBom");
1942 if (empty($manufacturingcost)) {
1943 $manufacturingcost =
price2num($tmpproduct->cost_price,
'MU');
1944 $manufacturingcostsrc = $langs->trans(
"CostPrice");
1946 if (empty($manufacturingcost)) {
1947 $manufacturingcost =
price2num($tmpproduct->pmp,
'MU');
1948 $manufacturingcostsrc = $langs->trans(
"PMPValue");
1953 $preselected = (GETPOSTISSET(
'pricetoproduce-'.$line->id.
'-'.$i) ?
GETPOST(
'pricetoproduce-'.$line->id.
'-'.$i) : ($manufacturingcost ?
price($manufacturingcost) :
''));
1954 print
'<td class="right"><input type="text" class="width75 right" name="pricetoproduce-'.$line->id.
'-'.$i.
'" value="'.$preselected.
'"></td>';
1956 print
'<td><input type="hidden" class="width50 right" name="pricetoproduce-'.$line->id.
'-'.$i.
'" value="'.($manufacturingcost ? $manufacturingcost :
'').
'"></td>';
1964 $preselected = (GETPOSTISSET(
'idwarehousetoproduce-'.$line->id.
'-'.$i) ?
GETPOST(
'idwarehousetoproduce-'.$line->id.
'-'.$i) : (
$object->fk_warehouse > 0 ?
$object->fk_warehouse :
'ifone'));
1965 print $formproduct->selectWarehouses($preselected,
'idwarehousetoproduce-'.$line->id.
'-'.$i,
'', 1, 0, $line->fk_product,
'', 1, 0, array(),
'maxwidth200 csswarehouse_'.$line->id.
'_'.$i);
1967 print
'<span class="opacitymedium">'.$langs->trans(
"NoStockChangeOnServices").
'</span>';
1973 if ($tmpproduct->status_batch) {
1974 $preselected = (GETPOSTISSET(
'batchtoproduce-'.$line->id.
'-'.$i) ?
GETPOST(
'batchtoproduce-'.$line->id.
'-'.$i) :
'');
1975 print
'<input type="text" class="width75" name="batchtoproduce-'.$line->id.
'-'.$i.
'" value="'.$preselected.
'">';
1979 if ($tmpproduct->status_batch) {
1981 print
'<td align="right" class="split">';
1982 print
img_picto($langs->trans(
'AddStockLocationLine'),
'split',
'class="splitbutton" onClick="addDispatchLine('.$line->id.
', \''.$type.
'\', \
'qtymissing\')"');
1985 print
'<td align="right" class="splitall">';
1986 if (($action ==
'consumeorproduce' || $action ==
'consumeandproduceall') && $tmpproduct->status_batch == 2) {
1987 print
img_picto($langs->trans(
'SplitAllQuantity'),
'split',
'class="splitbutton splitallbutton field-error-icon" onClick="addDispatchLine('.$line->id.
', \'batch\', \'alltoproduce\')"');
1998 if ($tmpproduct->sell_or_eat_by_mandatory == $tmpproduct::SELL_OR_EAT_BY_MANDATORY_ID_SELL_BY || $tmpproduct->sell_or_eat_by_mandatory == $tmpproduct::SELL_OR_EAT_BY_MANDATORY_ID_SELL_AND_EAT) {
1999 print
'<td align="right">';
2000 $preselectedSellBy = (GETPOSTISSET(
'sellby-' . $line->id .
'-' . $i) ?
GETPOSTDATE(
'sellby-' . $line->id .
'-' . $i) :
'');
2001 print $form->selectDate($preselectedSellBy,
'sellby-' . $line->id .
'-' . $i, 0, 0, 1,
'', 1, 0);
2004 if ($atLeastOneSellBy) {
2010 if ($tmpproduct->sell_or_eat_by_mandatory == $tmpproduct::SELL_OR_EAT_BY_MANDATORY_ID_EAT_BY || $tmpproduct->sell_or_eat_by_mandatory == $tmpproduct::SELL_OR_EAT_BY_MANDATORY_ID_SELL_AND_EAT) {
2011 print
'<td align="right">';
2012 $preselectedEatBy = (GETPOSTISSET(
'eatby-' . $line->id .
'-' . $i) ?
GETPOSTDATE(
'eatby-' . $line->id .
'-' . $i) :
'');
2013 print $form->selectDate($preselectedEatBy,
'eatby-' . $line->id .
'-' . $i, 0, 0, 1,
'', 1, 0);
2016 if ($atLeastOneEatBy) {
2037 if (in_array($action, array(
'consumeorproduce',
'consumeandproduceall',
'addconsumeline'))) {
2041 <script
type=
"text/javascript" language=
"javascript">
2043 $(document).ready(
function() {
2045 updateselectbatchbywarehouse();
2047 updateselectwarehousebybatch();
2050 function updateselectbatchbywarehouse() {
2051 $(document).on(
'change',
"select[name*='idwarehouse']",
function () {
2052 console.log(
"We change warehouse so we update the list of possible batch number");
2054 var selectwarehouse = $(
this);
2056 var selectbatch_name = selectwarehouse.attr(
'name').replace(
'idwarehouse',
'batch');
2057 var selectbatch = $(
"datalist[id*='" + selectbatch_name +
"']");
2058 var selectedbatch = selectbatch.val();
2060 var product_element_name = selectwarehouse.attr(
'name').replace(
'idwarehouse',
'product');
2064 url:
"<?php echo DOL_URL_ROOT . '/mrp/ajax/interface.php'; ?>",
2066 action:
"updateselectbatchbywarehouse",
2067 permissiontoproduce: <?php echo $permissiontoproduce ?>,
2068 warehouse_id: $(
this).val(),
2069 token:
'<?php echo currentToken(); ?>',
2070 product_id: $(
"input[name='" + product_element_name +
"']").val()
2072 }).done(
function (data) {
2074 selectbatch.empty();
2076 if (typeof data ==
"object") {
2077 console.log(
"data is already type object, no need to parse it");
2079 console.log(
"data is type "+(typeof data));
2080 data = JSON.parse(data);
2083 selectbatch.append($(
'<option>', {
2087 $.each(data,
function (key, value) {
2089 if(selectwarehouse.val() == -1) {
2090 var label = key +
" (<?php echo $langs->trans('TotalStock') ?> : " + value +
")";
2092 var label = key +
" (<?php echo $langs->trans('Stock') ?> : " + value +
")";
2095 if(key === selectedbatch) {
2096 var option =
'<option value="'+key+
'" selected>'+ label +
'</option>';
2098 var option =
'<option value="'+key+
'">'+ label +
'</option>';
2101 selectbatch.append(option);
2107 function updateselectwarehousebybatch() {
2108 $(document).on(
'change',
'input[name*=batch]',
function(){
2109 console.log(
"We change batch so we update the list of possible warehouses");
2111 var selectbatch = $(
this);
2113 var selectwarehouse_name = selectbatch.attr(
'name').replace(
'batch',
'idwarehouse');
2114 var selectwarehouse = $(
"select[name*='" + selectwarehouse_name +
"']");
2115 var selectedwarehouse = selectwarehouse.val();
2117 if(selectedwarehouse != -1){
2121 var product_element_name = selectbatch.attr(
'name').replace(
'batch',
'product');
2125 url:
"<?php echo DOL_URL_ROOT . '/mrp/ajax/interface.php'; ?>",
2127 action:
"updateselectwarehousebybatch",
2128 permissiontoproduce: <?php echo $permissiontoproduce ?>,
2129 batch: $(
this).val(),
2130 token:
'<?php echo currentToken(); ?>',
2131 product_id: $(
"input[name='" + product_element_name +
"']").val()
2133 }).done(
function (data) {
2135 if (typeof data ==
"object") {
2136 console.log(
"data is already type object, no need to parse it");
2138 console.log(
"data is type "+(typeof data));
2139 data = JSON.parse(data);
2143 selectwarehouse.val(data).change();
$id
Support class for third parties, contacts, members, users or resources.
if(! $sortfield) if(! $sortorder) $object
llxFooter($comment='', $zone='private', $disabledoutputofmessages=0)
Empty footer.
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
Class of dictionary type of thirdparty (used by imports)
Class to manage warehouses.
Class to manage stock movements.
Class to manage predefined suppliers products.
Class to manage products or services.
const TYPE_PRODUCT
Regular product.
const TYPE_SERVICE
Service.
Class with list of lots and properties.
Class to manage projects.
Class to manage translations.
convertDurationtoHour($duration_value, $duration_unit)
Convert duration to hour.
dol_now($mode='gmt')
Return date for now.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
GETPOSTDATE($prefix, $hourTime='', $gm='auto', $saverestore='')
Helper function that combines values of a dolibarr DatePicker (such as Form\selectDate) for year,...
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2, $allowothertags=array())
Show picto whatever it's its name (generic function)
img_warning($titlealt='default', $moreatt='', $morecss='pictowarning')
Show warning logo.
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
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 '.
dolBuildUrl($url, $params=[], $addtoken=false, $anchor='')
Return path of url.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
price($amount, $form=0, $outlangs='', $trunc=1, $rounding=-1, $forcerounding=-1, $currency_code='')
Function to format a value into an amount for visual output Function used into PDF and HTML pages.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
dol_escape_js($stringtoescape, $mode=0, $noescapebackslashn=0)
Returns text escaped for inclusion into JavaScript code.
GETPOSTFLOAT($paramname, $rounding='', $option=2)
Return the value of a $_GET or $_POST supervariable, converted into float.
yn($yesno, $format=1, $color=0)
Return yes or no in current language.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false, $decorate=0)
Output date in a string format according to outputlangs (or langs if not defined).
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='', $morecssonpicto='widthpictotitle')
Load a title with picto.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
isModEnabled($module)
Is Dolibarr module enabled.
img_edit($titlealt='default', $float=0, $other='')
Show logo edit/modify fiche.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
Returns text escaped for inclusion in HTML alt or title or value tags, or into values of HTML input f...
print $langs trans("Show") . '< td style="' . $timeColor . '" align="center"> s</td > badge status0 badge status4 badge status3 Error badge status8< td align="center">< span class="badge ' . $badge . '"></span ></td >< td align="center">< a href="#" class="button button-small" onclick="openLogModal(this)" data-req="' . dol_escape_htmltag($reqSafe) . '" data-res="' . dol_escape_htmltag($resSafe) . '" data-err="' . dol_escape_htmltag($errSafe) . '">< span class="fa fa-search-plus"></span ></a ></td ></tr >< tr >< td colspan="' . $colspan . '" class="opacitymedium"></td ></tr ></table ></div ></form > logModal none logModal none s a JSON string
buildzip.php
moPrepareHead($object)
Prepare array of tabs for Mo.
measuringUnitString($unitid, $measuring_style='', $unitscale=null, $use_short_label=0, $outputlangs=null)
Return translation label of a unit key.
if(preg_match('/(crypted|dolcrypt):/i', $dolibarr_main_db_pass)||!empty($dolibarr_main_db_encrypted_pass)) $conf db type
'integer', 'integer:ObjectClass:PathToClass[:AddCreateButtonOrNot[:Filter[:Sortfield]]]',...
restrictedArea(User $user, $features, $object=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $isdraft=0, $mode=0)
Check permissions of a user to show a page and an object.