29require
'../main.inc.php';
39require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formcompany.class.php';
40require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
41require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formprojet.class.php';
42require_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
43require_once DOL_DOCUMENT_ROOT.
'/projet/class/project.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.
'/bom/class/bom.class.php';
47require_once DOL_DOCUMENT_ROOT.
'/bom/lib/bom.lib.php';
50 require_once DOL_DOCUMENT_ROOT.
'/workstation/class/workstation.class.php';
54$langs->loadLangs(array(
'mrp',
'other'));
60$action =
GETPOST(
'action',
'aZ09');
61$confirm =
GETPOST(
'confirm',
'alpha');
63$contextpage =
GETPOST(
'contextpage',
'aZ') ?
GETPOST(
'contextpage',
'aZ') :
'mocard';
64$backtopage =
GETPOST(
'backtopage',
'alpha');
65$backtopageforcancel =
GETPOST(
'backtopageforcancel',
'alpha');
66$TBomLineId =
GETPOST(
'bomlineid',
'array:int');
74$diroutputmassaction =
$conf->mrp->dir_output.
'/temp/massgeneration/'.$user->id;
75$hookmanager->initHooks(array(
'mocard',
'globalcard'));
78$extrafields->fetch_name_optionals_label(
$object->table_element);
80$search_array_options = $extrafields->getOptionalsFromPost(
$object->table_element,
'',
'search_');
83$search_all =
GETPOST(
"search_all",
'alpha');
85foreach (
$object->fields as $key => $val) {
86 if (
GETPOST(
'search_'.$key,
'alpha')) {
87 $search[$key] =
GETPOST(
'search_'.$key,
'alpha');
91if (empty($action) && empty($id) && empty($ref)) {
96include DOL_DOCUMENT_ROOT.
'/core/actions_fetchobject.inc.php';
101 if ($action !=
'add') {
103 $_POST[
'fk_product'] = $objectbom->fk_product;
104 $_POST[
'qty'] = $objectbom->qty;
105 $_POST[
'mrptype'] = $objectbom->bomtype;
106 $_POST[
'fk_warehouse'] = $objectbom->fk_warehouse;
107 $_POST[
'note_private'] = $objectbom->note_private;
114$isdraft = ((
$object->status == $object::STATUS_DRAFT) ? 1 : 0);
118$permissionnote = $user->hasRight(
'mrp',
'write');
119$permissiondellink = $user->hasRight(
'mrp',
'write');
120$permissiontoadd = $user->hasRight(
'mrp',
'write');
121$permissiontodelete = $user->hasRight(
'mrp',
'delete') || ($permissiontoadd && isset(
$object->status) &&
$object->status == $object::STATUS_DRAFT);
129$parameters = array();
130$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
135if (empty($reshook)) {
142 if (empty($backtopage) || ($cancel && empty($id))) {
143 if (empty($backtopage) || ($cancel && strpos($backtopage,
'__ID__'))) {
144 if (empty($id) && (($action !=
'add' && $action !=
'create') || $cancel)) {
145 $backtopage = $backurlforlist;
147 $backtopage = DOL_URL_ROOT.
'/mrp/mo_card.php?id='.(
$id > 0 ?
$id :
'__ID__');
151 if ($cancel && !empty($backtopageforcancel)) {
152 $backtopage = $backtopageforcancel;
154 $triggermodname =
'MO_MODIFY';
157 if ($action ==
'add' && empty($id) && !empty($TBomLineId) && $permissiontoadd) {
162 $object->noFlattenBomLineIds = array_map(
'intval', $TBomLineId);
163 include DOL_DOCUMENT_ROOT.
'/core/actions_addupdatedelete.inc.php';
170 foreach ($TBomLineId as $id_bom_line) {
173 $objectbomchildline->fetch((
int) $id_bom_line);
179 $filter =
'(fk_mo:=:'.((int) $mo_parent->id).
') AND (origin_id:=:'.((int) $id_bom_line).
") AND (origin_type:=:'bomline')";
180 $TMoLines = $moline->fetchAll(
'DESC',
'rowid', 1, 0, $filter);
182 if (empty($TMoLines)) {
186 foreach ($TMoLines as $tmpmoline) {
187 $_POST[
'fk_bom'] = $objectbomchildline->fk_bom_child;
188 $_POST[
'fk_parent_line'] = $tmpmoline->id;
189 $_POST[
'qty'] = $tmpmoline->qty;
190 $_POST[
'fk_product'] = $tmpmoline->fk_product;
193 include DOL_DOCUMENT_ROOT.
'/core/actions_addupdatedelete.inc.php';
195 $res =
$object->add_object_linked(
'mo', $mo_parent->id);
198 header(
"Location: ".
dol_buildpath(
'/mrp/mo_card.php?id='.((
int) $mo_parent->id), 1));
200 } elseif ($action ==
'confirm_cancel' && $confirm ==
'yes' && !empty($permissiontoadd)) {
201 $also_cancel_consumed_and_produced_lines = (
GETPOST(
'alsoCancelConsumedAndProducedLines',
'alpha') ? 1 : 0);
202 $result =
$object->cancel($user, 0, (
bool) $also_cancel_consumed_and_produced_lines);
210 } elseif ($action ==
'confirm_delete' && $confirm ==
'yes' && !empty($permissiontodelete)) {
211 $also_cancel_consumed_and_produced_lines = (
GETPOST(
'alsoCancelConsumedAndProducedLines',
'alpha') ? 1 : 0);
212 $result =
$object->delete($user, 0, (
bool) $also_cancel_consumed_and_produced_lines);
214 header(
"Location: " . $backurlforlist);
220 } elseif ($action ==
'settags' &&
isModEnabled(
'category') && $permissiontoadd) {
227 if ($action ==
'confirm_delete' && !empty($permissiontodelete)) {
229 dol_print_error(
null,
'Error, object must be fetched before being deleted');
234 $deleteChilds =
GETPOST(
'deletechilds',
'aZ');
239 if ($deleteChilds ===
'on') {
240 $TMoChildren =
$object->getAllMoChilds();
242 foreach ($TMoChildren as $id => $childObject) {
243 if ($childObject->delete($user) == -1) {
245 if (!empty($childObject->errors)) {
255 $result =
$object->delete($user);
260 if ($deleteChilds ===
'on') {
264 if (empty($noback)) {
265 header(
"Location: " . $backurlforlist);
293 if ($action ==
'setqty' && $permissiontoadd &&
$object->status == Mo::STATUS_DRAFT) {
307 foreach (
$object->lines as $line) {
308 if ($line->role ===
'toproduce'
309 && (
int) $line->fk_product === (
int)
$object->fk_product
310 && empty($line->qty_frozen)
311 && (
float) $line->qty != (
float)
$object->qty) {
312 $line->qty = (float)
$object->qty;
313 $line->update($user);
321 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->trans(
"Qty")),
null,
'errors');
323 header(
"Location: ".$_SERVER[
"PHP_SELF"].
"?id=".
$object->id);
328 include DOL_DOCUMENT_ROOT.
'/core/actions_addupdatedelete.inc.php';
331 include DOL_DOCUMENT_ROOT.
'/core/actions_dellink.inc.php';
334 include DOL_DOCUMENT_ROOT.
'/core/actions_printing.inc.php';
337 include DOL_DOCUMENT_ROOT.
'/core/actions_builddoc.inc.php';
339 if ($action ==
'set_thirdparty' && $permissiontoadd) {
340 $object->setValueFrom(
'fk_soc',
GETPOSTINT(
'fk_soc'),
'',
null,
'date',
'', $user, $triggermodname);
342 if ($action ==
'classin' && $permissiontoadd) {
347 $triggersendname =
'MO_SENTBYMAIL';
348 $autocopy =
'MAIN_MAIL_AUTOCOPY_MO_TO';
349 $trackid =
'mo'.$object->id;
350 include DOL_DOCUMENT_ROOT.
'/core/actions_sendmails.inc.php';
356 if ($action ==
'confirm_produced' && $confirm ==
'yes' && $permissiontoadd) {
357 $result =
$object->setStatut($object::STATUS_PRODUCED, 0,
'',
'MRP_MO_PRODUCED');
361 $outputlangs = $langs;
364 $newlang =
GETPOST(
'lang_id',
'aZ09');
367 $newlang =
$object->thirdparty->default_lang;
369 if (!empty($newlang)) {
371 $outputlangs->setDefaultLang($newlang);
376 $object->generateDocument($model, $outputlangs, 0, 0, 0);
395$title = $langs->trans(
'ManufacturingOrder').
" - ".$langs->trans(
"Card");
396$help_url =
'EN:Module_Manufacturing_Orders|FR:Module_Ordres_de_Fabrication|DE:Modul_Fertigungsauftrag';
398llxHeader(
'', $title, $help_url,
'', 0, 0,
'',
'',
'',
'mod-mrp page-card');
402if ($action ==
'create') {
405 $titlelist = $langs->trans(
"ToConsume");
406 if ($objectbom->bomtype == 1) {
407 $titlelist = $langs->trans(
"ToObtain");
411 print
load_fiche_titre($langs->trans(
"NewObject", $langs->transnoentitiesnoconv(
"Mo")),
'',
'mrp');
413 print
'<form method="POST" action="'.dolBuildUrl($_SERVER[
"PHP_SELF"]).
'">';
414 print
'<input type="hidden" name="token" value="'.newToken().
'">';
415 print
'<input type="hidden" name="action" value="add">';
417 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
419 if ($backtopageforcancel) {
420 print
'<input type="hidden" name="backtopageforcancel" value="'.$backtopageforcancel.
'">';
425 print
'<table class="border centpercent tableforfieldcreate">'.
"\n";
428 include DOL_DOCUMENT_ROOT.
'/core/tpl/commonfields_add.tpl.php';
431 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_add.tpl.php';
435 print
'<tr><td>'.$langs->trans(
"Categories").
'</td><td>';
436 print $form->selectCategories(Categorie::TYPE_MO,
'categories', $object);
440 print
'</table>'.
"\n";
446 $(document).ready(
function () {
447 jQuery(
'#fk_bom').change(
function() {
448 console.log(
'We change value of BOM with BOM of id '+jQuery(
'#fk_bom').val());
449 if (jQuery(
'#fk_bom').val() > 0)
452 window.location.href =
'<?php echo $_SERVER["PHP_SELF"] ?>?action=create&token=<?php echo newToken(); ?>&fk_bom='+jQuery(
'#fk_bom').val();
481 else if (jQuery(
'#fk_bom').val() < 0) {
483 console.log(jQuery(
'#fk_product').val());
484 window.location.href =
'<?php echo $_SERVER["PHP_SELF"] ?>?action=create&token=<?php echo newToken(); ?>&qty='+jQuery(
'#qty').val()+
'&mrptype='+jQuery(
'#mrptype').val()+
'&fk_product='+jQuery(
'#fk_product').val()+
'&label='+jQuery(
'#label').val()+
'&fk_project='+jQuery(
'#fk_project').val()+
'&fk_warehouse='+jQuery(
'#fk_warehouse').val();
502 print $form->buttonsSaveCancel(
"Create");
504 if ($objectbom->id > 0) {
507 print
'<!-- list of product/services to consume -->'.
"\n";
508 print
'<div class="div-table-responsive-no-min">';
509 print
'<table class="noborder centpercent">';
511 $arrayOfMoLines = array();
512 foreach ($objectbom->lines as $key => $val) {
514 $moLine->id = $objectbom->lines[$key]->id;
515 $moLine->position = $objectbom->lines[$key]->position;
516 $moLine->fk_product = $objectbom->lines[$key]->fk_product;
517 $moLine->fk_unit = $objectbom->lines[$key]->fk_unit;
518 $moLine->qty = $objectbom->lines[$key]->qty;
519 $moLine->qty_frozen = $objectbom->lines[$key]->qty_frozen;
520 $moLine->disable_stock_change = $objectbom->lines[$key]->disable_stock_change;
521 $moLine->fk_bom_child = $objectbom->lines[$key]->fk_bom_child;
523 $arrayOfMoLines[] = $moLine;
525 $object->lines = $arrayOfMoLines;
526 $object->mrptype = $objectbom->bomtype;
529 $object->printOriginLinesList(
'', array());
539if (($id || $ref) && $action ==
'edit') {
542 print
'<form method="POST" action="'.dolBuildUrl($_SERVER[
"PHP_SELF"]).
'">';
543 print
'<input type="hidden" name="token" value="'.newToken().
'">';
544 print
'<input type="hidden" name="action" value="update">';
545 print
'<input type="hidden" name="id" value="'.$object->id.
'">';
547 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
549 if ($backtopageforcancel) {
550 print
'<input type="hidden" name="backtopageforcancel" value="'.$backtopageforcancel.
'">';
555 $object->fields[
'fk_bom'][
'disabled'] = 1;
557 print
'<table class="border centpercent tableforfieldedit">'.
"\n";
560 include DOL_DOCUMENT_ROOT.
'/core/tpl/commonfields_edit.tpl.php';
563 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_edit.tpl.php';
567 print
'<tr><td>'.$langs->trans(
"Categories").
'</td><td>';
568 print $form->selectCategories(Categorie::TYPE_MO,
'categories', $object);
576 print $form->buttonsSaveCancel();
582if (
$object->id > 0 && (empty($action) || ($action !=
'edit' && $action !=
'create'))) {
583 $res =
$object->fetch_thirdparty();
587 print
dol_get_fiche_head($head,
'card', $langs->trans(
"ManufacturingOrder"), -1,
$object->picto, 0,
'',
'', 0,
'', 1);
592 if ($action ==
'delete') {
593 $numberofmochilds = count(
$object->getAllMoChilds());
595 if ($numberofmochilds > 0) {
596 $label = $langs->trans(
"DeleteMoChild",
'('.strval($numberofmochilds).
')');
598 $label = $langs->trans(
"DeleteMoChild");
601 $formquestion = array(
602 array(
'type' =>
'checkbox',
'name' =>
'deletechilds',
'label' => $label,
'value' => 0),
604 'label' => $langs->trans(
'MoCancelConsumedAndProducedLines'),
605 'name' =>
'alsoCancelConsumedAndProducedLines',
606 'type' =>
'checkbox',
607 'value' => !
getDolGlobalString(
'MO_ALSO_CANCEL_CONSUMED_AND_PRODUCED_LINES_BY_DEFAULT') ? 0 : 1
610 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'DeleteMo'), $langs->trans(
'ConfirmDeleteMo'),
'confirm_delete', $formquestion, 0, 1);
613 if ($action ==
'deleteline') {
614 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&lineid='.$lineid, $langs->trans(
'DeleteLine'), $langs->trans(
'ConfirmDeleteLine'),
'confirm_deleteline',
'', 0, 1);
618 if ($action ==
'reload') {
619 $object->createProduction($user, 0);
623 if ($action ==
'validate') {
625 $ref = substr(
$object->ref, 1, 4);
626 if ($ref ==
'PROV') {
633 $text = $langs->trans(
'ConfirmValidateMo', $numref);
642 $formquestion = array();
645 require_once DOL_DOCUMENT_ROOT.
'/product/class/html.formproduct.class.php';
648 if (
$conf->browser->name ==
'ie') {
651 $formquestion = array(
658 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'Validate'), $text,
'confirm_validate', $formquestion, 0, 1, 220);
662 if ($action ==
'cancel') {
663 $formquestion = array(
665 'label' => $langs->trans(
'MoCancelConsumedAndProducedLines'),
666 'name' =>
'alsoCancelConsumedAndProducedLines',
667 'type' =>
'checkbox',
671 $formconfirm = $form->formconfirm(
dolBuildUrl($_SERVER[
"PHP_SELF"], [
'id' =>
$object->id]), $langs->trans(
'CancelMo'), $langs->trans(
'ConfirmCancelMo'),
'confirm_cancel', $formquestion, 0, 1);
675 if ($action ==
'clone') {
677 $formquestion = array();
678 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'ToClone'), $langs->trans(
'ConfirmCloneMo',
$object->ref),
'confirm_clone', $formquestion,
'yes', 1);
682 $parameters = array(
'formConfirm' => $formconfirm,
'lineid' => $lineid);
683 $reshook = $hookmanager->executeHooks(
'formConfirm', $parameters, $object, $action);
684 if (empty($reshook)) {
685 $formconfirm .= $hookmanager->resPrint;
686 } elseif ($reshook > 0) {
687 $formconfirm = $hookmanager->resPrint;
696 $linkback =
'<a href="'.dol_buildpath(
'/mrp/mo_list.php', 1).
'?restore_lastsearch_values=1'.(!empty($socid) ?
'&socid='.$socid :
'').
'">'.$langs->trans(
"BackToList").
'</a>';
698 $morehtmlref =
'<div class="refidno">';
704 if (is_object(
$object->thirdparty)) {
705 $morehtmlref .=
$object->thirdparty->getNomUrl(1,
'customer');
707 $morehtmlref .=
' (<a href="'.DOL_URL_ROOT.
'/commande/list.php?socid='.
$object->thirdparty->id.
'">'.$langs->trans(
"OtherOrders").
'</a>)';
712 $langs->load(
"projects");
713 if (is_object(
$object->thirdparty)) {
714 $morehtmlref .=
'<br>';
716 if ($permissiontoadd) {
717 $morehtmlref .=
img_picto($langs->trans(
"Project"),
'project',
'class="pictofixedwidth"');
718 if ($action !=
'classify') {
719 $morehtmlref .=
'<a class="editfielda" href="'.dolBuildUrl($_SERVER[
'PHP_SELF'], [
'action' =>
'classify',
'id' =>
$object->id],
true).
'">'.
img_edit($langs->transnoentitiesnoconv(
'SetProject')).
'</a> ';
721 $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');
723 if (!empty(
$object->fk_project)) {
725 $proj->fetch(
$object->fk_project);
726 $morehtmlref .= $proj->getNomUrl(1);
728 $morehtmlref .=
'<span class="opacitymedium"> - '.dol_escape_htmltag($proj->title).
'</span>';
733 $morehtmlref .=
'</div>';
736 dol_banner_tab($object,
'ref', $linkback, 1,
'ref',
'ref', $morehtmlref);
739 print
'<div class="fichecenter">';
740 print
'<div class="fichehalfleft">';
741 print
'<div class="underbanner clearboth"></div>';
742 print
'<table class="border centpercent tableforfield">'.
"\n";
745 $mo_parent =
$object->getMoParent();
746 if (is_object($mo_parent)) {
747 print
'<tr class="field_fk_mo_parent">';
748 print
'<td class="titlefield fieldname_fk_mo_parent">' . $langs->trans(
'ParentMo') .
'</td>';
749 print
'<td class="valuefield fieldname_fk_mo_parent">' .$mo_parent->getNomUrl(1).
'</td>';
754 $keyforbreak =
'fk_warehouse';
755 unset(
$object->fields[
'fk_project']);
756 unset(
$object->fields[
'fk_soc']);
762 if (
$object->status == Mo::STATUS_DRAFT && $permissiontoadd && isset(
$object->fields[
'qty'])) {
763 $object->fields[
'qty'][
'alwayseditable'] = 1;
764 if ($action ==
'editqty') {
765 $object->fields[
'qty'][
'type'] =
'numeric';
769 include DOL_DOCUMENT_ROOT.
'/core/tpl/commonfields_view.tpl.php';
774 print
'<table class="nobordernopadding centpercent"><tr><td>';
775 print $langs->trans(
"Categories");
776 print
'<td><td class="right">';
777 if ($permissiontoadd) {
778 print
'<a class="editfielda" href="' . DOL_URL_ROOT .
'/mrp/mo_card.php?id=' .
$object->id .
'&action=edittags&token=' .
newToken() .
'">' .
img_edit() .
'</a>';
782 print
'</td></tr></table>';
785 if ($action ==
'edittags') {
786 print
'<form method="POST" action="' . $_SERVER[
'PHP_SELF'] .
'?id=' .
$object->id .
'">';
787 print
'<input type="hidden" name="action" value="settags">';
788 print
'<input type="hidden" name="token" value="' .
newToken() .
'">';
789 print $form->selectCategories(Categorie::TYPE_MO,
'categories', $object);
790 print
'<input type="submit" class="button valignmiddle smallpaddingimp" value="' . $langs->trans(
"Modify") .
'">';
793 print $form->showCategories(
$object->id, Categorie::TYPE_MO, 1);
799 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_view.tpl.php';
805 print
'<div class="clearboth"></div>';
814 if (!empty(
$object->table_element_line)) {
819 print
' <form name="addproduct" id="addproduct" action="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.(($action !=
'editline') ?
'' :
'#line_'.
GETPOSTINT(
'lineid')).
'" method="POST">
820 <input type="hidden" name="token" value="' .
newToken().
'">
821 <input type="hidden" name="action" value="' . (($action !=
'editline') ?
'addline' :
'updateline').
'">
822 <input type="hidden" name="mode" value="">
823 <input type="hidden" name="page_y" value="">
824 <input type="hidden" name="id" value="' .
$object->id.
'">
832 print
'<div class="div-table-responsive-no-min">';
833 print
'<table id="tablelines" class="noborder noshadow" width="100%">';
835 print
'<tr class="liste_titre">';
836 print
'<td class="liste_titre">'.$langs->trans(
"Summary").
'</td>';
840 print
'<tr class="oddeven">';
841 print
'<td>'.$langs->trans(
"ProductsToConsume").
'</td>';
845 foreach (
$object->lines as $line) {
846 if ($line->role ==
'toconsume') {
851 $tmpproduct->fetch($line->fk_product);
852 print $tmpproduct->getNomUrl(1);
860 print
'<tr class="oddeven">';
861 print
'<td>'.$langs->trans(
"ProductsToProduce").
'</td>';
865 foreach (
$object->lines as $line) {
866 if ($line->role ==
'toproduce') {
871 $tmpproduct->fetch($line->fk_product);
872 print $tmpproduct->getNomUrl(1);
890 if ($action !=
'presend' && $action !=
'editline') {
891 print
'<div class="tabsAction">'.
"\n";
892 $parameters = array();
893 $reshook = $hookmanager->executeHooks(
'addMoreActionsButtons', $parameters, $object, $action);
898 if (empty($reshook)) {
905 if (
$object->status == $object::STATUS_VALIDATED) {
906 if ($permissiontoadd) {
908 print
'<a class="butAction" href="'.$_SERVER[
'PHP_SELF'].
'?id='.
$object->id.
'&action=confirm_setdraft&confirm=yes&token='.
newToken().
'">'.$langs->trans(
"SetToDraft").
'</a>';
913 if (
$object->status == $object::STATUS_DRAFT) {
914 if ($permissiontoadd) {
915 print
'<a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=edit&token='.
newToken().
'">'.$langs->trans(
"Modify").
'</a>'.
"\n";
917 print
'<a class="butActionRefused classfortooltip" href="#" title="'.dolPrintHTMLForAttribute($langs->trans(
"NotEnoughPermissions")).
'">'.$langs->trans(
'Modify').
'</a>'.
"\n";
922 if (
$object->status == $object::STATUS_DRAFT &&
$object->fk_bom > 0) {
923 if ($permissiontoadd) {
924 print
'<a class="butAction" href="'.$_SERVER[
'PHP_SELF'].
'?id='.
$object->id.
'&action=reload&token='.
newToken().
'" title="'.
dolPrintHTMLForAttribute($langs->trans(
"ReInitializeHelp")).
'">'.$langs->trans(
"ReInitialize").
'</a>';
926 print
'<a class="butActionRefused classfortooltip" href="#" title="'.dolPrintHTMLForAttribute($langs->trans(
"ReInitializeHelp").
'<br>'.$langs->trans(
"NotEnoughPermissions")).
'">'.$langs->trans(
'ReInitialize').
'</a>'.
"\n";
931 if (
$object->status == $object::STATUS_DRAFT) {
932 if ($permissiontoadd) {
934 print
'<a class="butAction" href="'.$_SERVER[
'PHP_SELF'].
'?id='.
$object->id.
'&action=validate&token='.
newToken().
'">'.$langs->trans(
"Validate").
'</a>';
936 $langs->load(
"errors");
937 print
'<a class="butActionRefused" href="" title="'.$langs->trans(
"ErrorAddAtLeastOneLineFirst").
'">'.$langs->trans(
"Validate").
'</a>';
943 if ($permissiontoadd) {
944 print
dolGetButtonAction($langs->trans(
"ToClone"),
'',
'clone', $_SERVER[
'PHP_SELF'].
'?id='.
$object->id.(!empty(
$object->socid) ?
'&socid='.$object->socid :
"").
'&action=clone&token='.
newToken().
'&object=mo',
'clone', $permissiontoadd);
948 if ($permissiontoadd) {
949 if (
$object->status == $object::STATUS_VALIDATED ||
$object->status == $object::STATUS_INPROGRESS) {
950 $arrayproduced =
$object->fetchLinesLinked(
'produced', 0);
952 foreach ($arrayproduced as $lineproduced) {
953 $nbProduced += $lineproduced[
'qty'];
955 if ($nbProduced > 0) {
956 print
'<a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=confirm_produced&confirm=yes&token='.
newToken().
'">'.$langs->trans(
"Close").
'</a>'.
"\n";
958 print
'<a class="butActionRefused" href="#" title="'.$langs->trans(
"GoOnTabProductionToProduceFirst", $langs->transnoentitiesnoconv(
"Production")).
'">'.$langs->trans(
"Close").
'</a>'.
"\n";
961 print
'<a class="butActionDelete" href="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=cancel&token='.
newToken().
'">'.$langs->trans(
"Cancel").
'</a>'.
"\n";
964 if (
$object->status == $object::STATUS_PRODUCED ||
$object->status == $object::STATUS_CANCELED) {
965 print
'<a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=confirm_reopen&confirm=yes&token='.
newToken().
'">'.$langs->trans(
"ReOpen").
'</a>'.
"\n";
970 print
dolGetButtonAction($langs->trans(
"Delete"),
'',
'delete', $_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=delete&token='.
newToken(),
'delete', $permissiontodelete);
977 if (
GETPOST(
'modelselected')) {
981 if ($action !=
'presend') {
982 print
'<div class="fichecenter"><div class="fichehalfleft">';
983 print
'<a name="builddoc"></a>';
987 $relativepath = $objref.
'/'.$objref.
'.pdf';
988 $filedir =
$conf->mrp->dir_output.
'/'.$objref;
989 $urlsource = $_SERVER[
"PHP_SELF"].
"?id=".
$object->id;
990 $genallowed = $user->hasRight(
'mrp',
'read');
991 $delallowed = $user->hasRight(
"mrp",
"creer");
992 print $formfile->showdocuments(
'mrp:mo', $objref, $filedir, $urlsource, $genallowed, $delallowed,
$object->model_pdf, 1, 0, 0, 28, 0,
'',
'',
'',
$mysoc->default_lang,
'', $object);
995 $tmparray = $form->showLinkToObjectBlock($object, array(), array(
'mo'), 1);
996 $linktoelem = $tmparray[
'linktoelem'];
997 $htmltoenteralink = $tmparray[
'htmltoenteralink'];
998 print $htmltoenteralink;
1000 $somethingshown = $form->showLinkedObjectBlock($object, $linktoelem, array());
1003 print
'</div><div class="fichehalfright">';
1007 $morehtmlcenter =
dolGetButtonTitle($langs->trans(
'SeeAll'),
'',
'fa fa-bars imgforviewmode', DOL_URL_ROOT.
'/mrp/mo_agenda.php?id='.
$object->id);
1010 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formactions.class.php';
1012 $somethingshown = $formactions->showactions($object,
$object->element, $socid, 1,
'', $MAXEVENT,
'', $morehtmlcenter);
1014 print
'</div></div>';
1018 if (
GETPOST(
'modelselected')) {
1019 $action =
'presend';
1024 $defaulttopic =
'InformationMessage';
1025 $diroutput =
$conf->mrp->dir_output;
1026 $trackid =
'mo'.$object->id;
1028 include DOL_DOCUMENT_ROOT.
'/core/tpl/card_presend.tpl.php';
$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.
mrpCollapseBomManagement()
Manage collapse bom display.
Class to manage products or services.
Class to manage projects.
Class to manage translations.
dolBuildUrl($url, $params=[], $addtoken=false, $anchor='')
Return path of url.
dol_sanitizeFileName($str, $newstr='_', $unaccent=1, $includequotes=0, $allowdash=0)
Clean a string to use it as a file name.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
newToken()
Return the value of token currently saved into session with name 'newtoken'.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0, $nodefault=0)
Return value of a param into GET or POST supervariable.
GETPOSTFLOAT($paramname, $rounding='', $option=2)
Return the value of a $_GET or $_POST supervariable, converted into float.
GETPOSTINT($paramname, $method=0, $nodefault=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
isModEnabled($module)
Is Dolibarr module enabled.
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)
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.
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.
dolGetButtonAction($label, $text='', $actionType='default', $url='', $id='', $userRight=1, $params=array())
Function dolGetButtonAction.
dolPrintHTMLForAttribute($s, $escapeonlyhtmltags=0, $allowothertags=array())
Return a string ready to be output into an HTML attribute (alt, title, data-html, ....
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='', $morecssonpicto='widthpictotitle')
Load a title with picto.
img_edit($titlealt='default', $float=0, $other='')
Show logo edit/modify fiche.
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
moPrepareHead($object)
Prepare array of tabs for Mo.
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.