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');
72$objectbom =
new BOM($db);
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);
132 setEventMessages($hookmanager->error, $hookmanager->errors,
'errors');
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';
167 $moline =
new MoLine($db);
168 $objectbomchildline =
new BOMLine($db);
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);
213 $result =
$object->delete($user, 0, (
bool) $also_cancel_consumed_and_produced_lines);
215 header(
"Location: " . $backurlforlist);
221 } elseif ($action ==
'settags' &&
isModEnabled(
'category') && $permissiontoadd) {
228 if ($action ==
'confirm_delete' && !empty($permissiontodelete)) {
230 dol_print_error(
null,
'Error, object must be fetched before being deleted');
235 $deleteChilds =
GETPOST(
'deletechilds',
'aZ');
240 if ($deleteChilds ===
'on') {
241 $TMoChildren =
$object->getAllMoChilds();
243 foreach ($TMoChildren as $id => $childObject) {
244 if ($childObject->delete($user) == -1) {
246 if (!empty($childObject->errors)) {
247 setEventMessages(
null, $childObject->errors,
'errors');
249 setEventMessages($childObject->error,
null,
'errors');
257 $result =
$object->delete($user);
260 setEventMessages(
"RecordDeleted",
null,
'mesgs');
262 if ($deleteChilds ===
'on') {
263 setEventMessages(
"MoChildsDeleted",
null,
'mesgs');
266 if (empty($noback)) {
267 header(
"Location: " . $backurlforlist);
273 setEventMessages(
null,
$object->errors,
'errors');
275 setEventMessages(
$object->error,
null,
'errors');
295 if ($action ==
'setqty' && $permissiontoadd &&
$object->status == Mo::STATUS_DRAFT) {
309 foreach (
$object->lines as $line) {
310 if ($line->role ===
'toproduce'
311 && (
int) $line->fk_product === (
int)
$object->fk_product
312 && empty($line->qty_frozen)
313 && (
float) $line->qty != (
float)
$object->qty) {
314 $line->qty = (float)
$object->qty;
315 $resultline = $line->update($user);
316 if ($resultline < 0) {
317 setEventMessages($line->error, $line->errors,
'errors');
321 setEventMessages($langs->trans(
"RecordSaved"),
null,
'mesgs');
326 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->trans(
"Qty")),
null,
'errors');
328 header(
"Location: ".$_SERVER[
"PHP_SELF"].
"?id=".
$object->id);
333 include DOL_DOCUMENT_ROOT.
'/core/actions_addupdatedelete.inc.php';
336 include DOL_DOCUMENT_ROOT.
'/core/actions_dellink.inc.php';
339 include DOL_DOCUMENT_ROOT.
'/core/actions_printing.inc.php';
342 include DOL_DOCUMENT_ROOT.
'/core/actions_builddoc.inc.php';
344 if ($action ==
'set_thirdparty' && $permissiontoadd) {
345 $object->setValueFrom(
'fk_soc',
GETPOSTINT(
'fk_soc'),
'',
null,
'date',
'', $user, $triggermodname);
347 if ($action ==
'classin' && $permissiontoadd) {
352 $triggersendname =
'MO_SENTBYMAIL';
353 $autocopy =
'MAIN_MAIL_AUTOCOPY_MO_TO';
354 $trackid =
'mo'.$object->id;
355 include DOL_DOCUMENT_ROOT.
'/core/actions_sendmails.inc.php';
361 if ($action ==
'confirm_produced' && $confirm ==
'yes' && $permissiontoadd) {
362 $result =
$object->setStatut($object::STATUS_PRODUCED, 0,
'',
'MRP_MO_PRODUCED');
366 $outputlangs = $langs;
369 $newlang =
GETPOST(
'lang_id',
'aZ09');
372 $newlang =
$object->thirdparty->default_lang;
374 if (!empty($newlang)) {
376 $outputlangs->setDefaultLang($newlang);
381 $object->generateDocument($model, $outputlangs, 0, 0, 0);
396$form =
new Form($db);
400$title = $langs->trans(
'ManufacturingOrder').
" - ".$langs->trans(
"Card");
401$help_url =
'EN:Module_Manufacturing_Orders|FR:Module_Ordres_de_Fabrication|DE:Modul_Fertigungsauftrag';
403llxHeader(
'', $title, $help_url,
'', 0, 0,
'',
'',
'',
'mod-mrp page-card');
407if ($action ==
'create') {
410 $titlelist = $langs->trans(
"ToConsume");
411 if ($objectbom->bomtype == 1) {
412 $titlelist = $langs->trans(
"ToObtain");
416 print
load_fiche_titre($langs->trans(
"NewObject", $langs->transnoentitiesnoconv(
"Mo")),
'',
'mrp');
418 print
'<form method="POST" action="'.dolBuildUrl($_SERVER[
"PHP_SELF"]).
'">';
419 print
'<input type="hidden" name="token" value="'.newToken().
'">';
420 print
'<input type="hidden" name="action" value="add">';
422 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
424 if ($backtopageforcancel) {
425 print
'<input type="hidden" name="backtopageforcancel" value="'.$backtopageforcancel.
'">';
430 print
'<table class="border centpercent tableforfieldcreate">'.
"\n";
433 include DOL_DOCUMENT_ROOT.
'/core/tpl/commonfields_add.tpl.php';
436 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_add.tpl.php';
440 print
'<tr><td>'.$langs->trans(
"Categories").
'</td><td>';
441 print $form->selectCategories(Categorie::TYPE_MO,
'categories', $object);
445 print
'</table>'.
"\n";
451 $(document).ready(
function () {
452 jQuery(
'#fk_bom').change(
function() {
453 console.log(
'We change value of BOM with BOM of id '+jQuery(
'#fk_bom').val());
454 if (jQuery(
'#fk_bom').val() > 0)
457 window.location.href =
'<?php echo $_SERVER["PHP_SELF"] ?>?action=create&token=<?php echo newToken(); ?>&fk_bom='+jQuery(
'#fk_bom').val();
486 else if (jQuery(
'#fk_bom').val() < 0) {
488 console.log(jQuery(
'#fk_product').val());
489 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();
507 print $form->buttonsSaveCancel(
"Create");
509 if ($objectbom->id > 0) {
512 print
'<!-- list of product/services to consume -->'.
"\n";
513 print
'<div class="div-table-responsive-no-min">';
514 print
'<table class="noborder centpercent">';
516 $arrayOfMoLines = array();
517 foreach ($objectbom->lines as $key => $val) {
518 $moLine =
new MoLine($db);
519 $moLine->id = $objectbom->lines[$key]->id;
520 $moLine->position = $objectbom->lines[$key]->position;
521 $moLine->fk_product = $objectbom->lines[$key]->fk_product;
522 $moLine->fk_unit = $objectbom->lines[$key]->fk_unit;
523 $moLine->qty = $objectbom->lines[$key]->qty;
524 $moLine->qty_frozen = $objectbom->lines[$key]->qty_frozen;
525 $moLine->disable_stock_change = $objectbom->lines[$key]->disable_stock_change;
526 $moLine->fk_bom_child = $objectbom->lines[$key]->fk_bom_child;
528 $arrayOfMoLines[] = $moLine;
530 $object->lines = $arrayOfMoLines;
531 $object->mrptype = $objectbom->bomtype;
534 $object->printOriginLinesList(
'', array());
544if (($id || $ref) && $action ==
'edit') {
547 print
'<form method="POST" action="'.dolBuildUrl($_SERVER[
"PHP_SELF"]).
'">';
548 print
'<input type="hidden" name="token" value="'.newToken().
'">';
549 print
'<input type="hidden" name="action" value="update">';
550 print
'<input type="hidden" name="id" value="'.$object->id.
'">';
552 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
554 if ($backtopageforcancel) {
555 print
'<input type="hidden" name="backtopageforcancel" value="'.$backtopageforcancel.
'">';
560 $object->fields[
'fk_bom'][
'disabled'] = 1;
562 print
'<table class="border centpercent tableforfieldedit">'.
"\n";
565 include DOL_DOCUMENT_ROOT.
'/core/tpl/commonfields_edit.tpl.php';
568 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_edit.tpl.php';
572 print
'<tr><td>'.$langs->trans(
"Categories").
'</td><td>';
573 print $form->selectCategories(Categorie::TYPE_MO,
'categories', $object);
581 print $form->buttonsSaveCancel();
587if (
$object->id > 0 && (empty($action) || ($action !=
'edit' && $action !=
'create'))) {
588 $res =
$object->fetch_thirdparty();
592 print
dol_get_fiche_head($head,
'card', $langs->trans(
"ManufacturingOrder"), -1,
$object->picto, 0,
'',
'', 0,
'', 1);
597 if ($action ==
'delete') {
598 $numberofmochilds = count(
$object->getAllMoChilds());
600 if ($numberofmochilds > 0) {
601 $label = $langs->trans(
"DeleteMoChild",
'('.strval($numberofmochilds).
')');
603 $label = $langs->trans(
"DeleteMoChild");
606 $formquestion = array(
607 array(
'type' =>
'checkbox',
'name' =>
'deletechilds',
'label' => $label,
'value' => 0),
609 'label' => $langs->trans(
'MoCancelConsumedAndProducedLines'),
610 'name' =>
'alsoCancelConsumedAndProducedLines',
611 'type' =>
'checkbox',
612 'value' => !
getDolGlobalString(
'MO_ALSO_CANCEL_CONSUMED_AND_PRODUCED_LINES_BY_DEFAULT') ? 0 : 1
615 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'DeleteMo'), $langs->trans(
'ConfirmDeleteMo'),
'confirm_delete', $formquestion, 0, 1);
618 if ($action ==
'deleteline') {
619 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&lineid='.$lineid, $langs->trans(
'DeleteLine'), $langs->trans(
'ConfirmDeleteLine'),
'confirm_deleteline',
'', 0, 1);
623 if ($action ==
'reload') {
624 $object->createProduction($user, 0);
628 if ($action ==
'validate') {
630 $ref = substr(
$object->ref, 1, 4);
631 if ($ref ==
'PROV') {
635 $numref = (string)
$object->ref;
638 $text = $langs->trans(
'ConfirmValidateMo', $numref);
647 $formquestion = array();
650 require_once DOL_DOCUMENT_ROOT.
'/product/class/html.formproduct.class.php';
653 if (
$conf->browser->name ==
'ie') {
656 $formquestion = array(
663 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'Validate'), $text,
'confirm_validate', $formquestion, 0, 1, 220);
667 if ($action ==
'cancel') {
668 $formquestion = array(
670 'label' => $langs->trans(
'MoCancelConsumedAndProducedLines'),
671 'name' =>
'alsoCancelConsumedAndProducedLines',
672 'type' =>
'checkbox',
676 $formconfirm = $form->formconfirm(
dolBuildUrl($_SERVER[
"PHP_SELF"], [
'id' =>
$object->id]), $langs->trans(
'CancelMo'), $langs->trans(
'ConfirmCancelMo'),
'confirm_cancel', $formquestion, 0, 1);
680 if ($action ==
'clone') {
682 $formquestion = array();
683 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'ToClone'), $langs->trans(
'ConfirmCloneMo',
$object->ref),
'confirm_clone', $formquestion,
'yes', 1);
687 $parameters = array(
'formConfirm' => $formconfirm,
'lineid' => $lineid);
688 $reshook = $hookmanager->executeHooks(
'formConfirm', $parameters, $object, $action);
689 if (empty($reshook)) {
690 $formconfirm .= $hookmanager->resPrint;
691 } elseif ($reshook > 0) {
692 $formconfirm = $hookmanager->resPrint;
701 $linkback =
'<a href="'.dol_buildpath(
'/mrp/mo_list.php', 1).
'?restore_lastsearch_values=1'.(!empty($socid) ?
'&socid='.$socid :
'').
'">'.$langs->trans(
"BackToList").
'</a>';
703 $morehtmlref =
'<div class="refidno">';
709 if (is_object(
$object->thirdparty)) {
710 $morehtmlref .=
$object->thirdparty->getNomUrl(1,
'customer');
712 $morehtmlref .=
' (<a href="'.DOL_URL_ROOT.
'/commande/list.php?socid='.
$object->thirdparty->id.
'">'.$langs->trans(
"OtherOrders").
'</a>)';
717 $langs->load(
"projects");
718 if (is_object(
$object->thirdparty)) {
719 $morehtmlref .=
'<br>';
721 if ($permissiontoadd) {
722 $morehtmlref .= img_picto($langs->trans(
"Project"),
'project',
'class="pictofixedwidth"');
723 if ($action !=
'classify') {
724 $morehtmlref .=
'<a class="editfielda" href="'.dolBuildUrl($_SERVER[
'PHP_SELF'], [
'action' =>
'classify',
'id' =>
$object->id],
true).
'">'.img_edit($langs->transnoentitiesnoconv(
'SetProject')).
'</a> ';
726 $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');
728 if (!empty(
$object->fk_project)) {
730 $proj->fetch(
$object->fk_project);
731 $morehtmlref .= $proj->getNomUrl(1);
733 $morehtmlref .=
'<span class="opacitymedium"> - '.dol_escape_htmltag($proj->title).
'</span>';
738 $morehtmlref .=
'</div>';
741 dol_banner_tab($object,
'ref', $linkback, 1,
'ref',
'ref', $morehtmlref);
744 print
'<div class="fichecenter">';
745 print
'<div class="fichehalfleft">';
746 print
'<div class="underbanner clearboth"></div>';
747 print
'<table class="border centpercent tableforfield">'.
"\n";
750 $mo_parent =
$object->getMoParent();
751 if (is_object($mo_parent)) {
752 print
'<tr class="field_fk_mo_parent">';
753 print
'<td class="titlefield fieldname_fk_mo_parent">' . $langs->trans(
'ParentMo') .
'</td>';
754 print
'<td class="valuefield fieldname_fk_mo_parent">' .$mo_parent->getNomUrl(1).
'</td>';
759 $keyforbreak =
'fk_warehouse';
760 unset(
$object->fields[
'fk_project']);
761 unset(
$object->fields[
'fk_soc']);
767 if (
$object->status == Mo::STATUS_DRAFT && $permissiontoadd && isset(
$object->fields[
'qty'])) {
768 $object->fields[
'qty'][
'alwayseditable'] = 1;
769 if ($action ==
'editqty') {
770 $object->fields[
'qty'][
'type'] =
'numeric';
774 include DOL_DOCUMENT_ROOT.
'/core/tpl/commonfields_view.tpl.php';
779 print
'<table class="nobordernopadding centpercent"><tr><td>';
780 print $langs->trans(
"Categories");
781 print
'<td><td class="right">';
782 if ($permissiontoadd) {
783 print
'<a class="editfielda" href="' . DOL_URL_ROOT .
'/mrp/mo_card.php?id=' .
$object->id .
'&action=edittags&token=' .
newToken() .
'">' . img_edit() .
'</a>';
787 print
'</td></tr></table>';
790 if ($action ==
'edittags') {
791 print
'<form method="POST" action="' . $_SERVER[
'PHP_SELF'] .
'?id=' .
$object->id .
'">';
792 print
'<input type="hidden" name="action" value="settags">';
793 print
'<input type="hidden" name="token" value="' .
newToken() .
'">';
794 print $form->selectCategories(Categorie::TYPE_MO,
'categories', $object);
795 print
'<input type="submit" class="button valignmiddle smallpaddingimp" value="' . $langs->trans(
"Modify") .
'">';
798 print $form->showCategories(
$object->id, Categorie::TYPE_MO, 1);
804 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_view.tpl.php';
810 print
'<div class="clearboth"></div>';
819 if (!empty(
$object->table_element_line)) {
824 print
' <form name="addproduct" id="addproduct" action="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.(($action !=
'editline') ?
'' :
'#line_'.
GETPOSTINT(
'lineid')).
'" method="POST">
825 <input type="hidden" name="token" value="' .
newToken().
'">
826 <input type="hidden" name="action" value="' . (($action !=
'editline') ?
'addline' :
'updateline').
'">
827 <input type="hidden" name="mode" value="">
828 <input type="hidden" name="page_y" value="">
829 <input type="hidden" name="id" value="' .
$object->id.
'">
837 print
'<div class="div-table-responsive-no-min">';
838 print
'<table id="tablelines" class="noborder noshadow" width="100%">';
840 print
'<tr class="liste_titre">';
841 print
'<td class="liste_titre">'.$langs->trans(
"Summary").
'</td>';
845 print
'<tr class="oddeven">';
846 print
'<td>'.$langs->trans(
"ProductsToConsume").
'</td>';
850 foreach (
$object->lines as $line) {
851 if ($line->role ==
'toconsume') {
855 $tmpproduct =
new Product($db);
856 $tmpproduct->fetch($line->fk_product);
857 print $tmpproduct->getNomUrl(1);
865 print
'<tr class="oddeven">';
866 print
'<td>'.$langs->trans(
"ProductsToProduce").
'</td>';
870 foreach (
$object->lines as $line) {
871 if ($line->role ==
'toproduce') {
875 $tmpproduct =
new Product($db);
876 $tmpproduct->fetch($line->fk_product);
877 print $tmpproduct->getNomUrl(1);
895 if ($action !=
'presend' && $action !=
'editline') {
896 print
'<div class="tabsAction">'.
"\n";
897 $parameters = array();
898 $reshook = $hookmanager->executeHooks(
'addMoreActionsButtons', $parameters, $object, $action);
900 setEventMessages($hookmanager->error, $hookmanager->errors,
'errors');
903 if (empty($reshook)) {
910 if (
$object->status == $object::STATUS_VALIDATED) {
911 if ($permissiontoadd) {
913 print
'<a class="butAction" href="'.$_SERVER[
'PHP_SELF'].
'?id='.
$object->id.
'&action=confirm_setdraft&confirm=yes&token='.
newToken().
'">'.$langs->trans(
"SetToDraft").
'</a>';
918 if (
$object->status == $object::STATUS_DRAFT) {
919 if ($permissiontoadd) {
920 print
'<a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=edit&token='.
newToken().
'">'.$langs->trans(
"Modify").
'</a>'.
"\n";
922 print
'<a class="butActionRefused classfortooltip" href="#" title="'.dolPrintHTMLForAttribute($langs->trans(
"NotEnoughPermissions")).
'">'.$langs->trans(
'Modify').
'</a>'.
"\n";
927 if (
$object->status == $object::STATUS_DRAFT &&
$object->fk_bom > 0) {
928 if ($permissiontoadd) {
929 print
'<a class="butAction" href="'.$_SERVER[
'PHP_SELF'].
'?id='.
$object->id.
'&action=reload&token='.
newToken().
'" title="'.dolPrintHTMLForAttribute($langs->trans(
"ReInitializeHelp")).
'">'.$langs->trans(
"ReInitialize").
'</a>';
931 print
'<a class="butActionRefused classfortooltip" href="#" title="'.dolPrintHTMLForAttribute($langs->trans(
"ReInitializeHelp").
'<br>'.$langs->trans(
"NotEnoughPermissions")).
'">'.$langs->trans(
'ReInitialize').
'</a>'.
"\n";
936 if (
$object->status == $object::STATUS_DRAFT) {
937 if ($permissiontoadd) {
939 print
'<a class="butAction" href="'.$_SERVER[
'PHP_SELF'].
'?id='.
$object->id.
'&action=validate&token='.
newToken().
'">'.$langs->trans(
"Validate").
'</a>';
941 $langs->load(
"errors");
942 print
'<a class="butActionRefused" href="" title="'.$langs->trans(
"ErrorAddAtLeastOneLineFirst").
'">'.$langs->trans(
"Validate").
'</a>';
948 if ($permissiontoadd) {
949 print dolGetButtonAction($langs->trans(
"ToClone"), $langs->trans(
"ToClone"),
'clone', $_SERVER[
'PHP_SELF'].
'?id='.
$object->id.(!empty(
$object->socid) ?
'&socid='.$object->socid :
"").
'&action=clone&token='.
newToken().
'&object=mo',
'clone', $permissiontoadd, array(
'attr' => array(
'class' =>
'reposition'))).
"\n";
953 if ($permissiontoadd) {
954 if (
$object->status == $object::STATUS_VALIDATED ||
$object->status == $object::STATUS_INPROGRESS) {
955 $arrayproduced =
$object->fetchLinesLinked(
'produced', 0);
957 foreach ($arrayproduced as $lineproduced) {
958 $nbProduced += $lineproduced[
'qty'];
960 if ($nbProduced > 0) {
961 print
'<a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=confirm_produced&confirm=yes&token='.
newToken().
'">'.$langs->trans(
"Close").
'</a>'.
"\n";
963 print
'<a class="butActionRefused" href="#" title="'.$langs->trans(
"GoOnTabProductionToProduceFirst", $langs->transnoentitiesnoconv(
"Production")).
'">'.$langs->trans(
"Close").
'</a>'.
"\n";
966 print
'<a class="butActionDelete" href="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=cancel&token='.
newToken().
'">'.$langs->trans(
"Cancel").
'</a>'.
"\n";
969 if (
$object->status == $object::STATUS_PRODUCED ||
$object->status == $object::STATUS_CANCELED) {
970 print
'<a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=confirm_reopen&confirm=yes&token='.
newToken().
'">'.$langs->trans(
"ReOpen").
'</a>'.
"\n";
975 print dolGetButtonAction($langs->trans(
"Delete"), $langs->trans(
"Delete"),
'delete', $_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=delete&token='.
newToken(),
'delete', $permissiontodelete, array(
'attr' => array(
'class' =>
'reposition'))).
"\n";
982 if (
GETPOST(
'modelselected')) {
986 if ($action !=
'presend') {
987 print
'<div class="fichecenter"><div class="fichehalfleft">';
988 print
'<a name="builddoc"></a>';
992 $relativepath = $objref.
'/'.$objref.
'.pdf';
993 $filedir =
$conf->mrp->dir_output.
'/'.$objref;
994 $urlsource = $_SERVER[
"PHP_SELF"].
"?id=".
$object->id;
995 $genallowed = $user->hasRight(
'mrp',
'read');
996 $delallowed = $user->hasRight(
"mrp",
"creer");
997 print $formfile->showdocuments(
'mrp:mo', $objref, $filedir, $urlsource, $genallowed, $delallowed,
$object->model_pdf, 1, 0, 0, 28, 0,
'',
'',
'',
$mysoc->default_lang,
'', $object);
1000 $tmparray = $form->showLinkToObjectBlock($object, array(), array(
'mo'), 1);
1001 $linktoelem = $tmparray[
'linktoelem'];
1002 $htmltoenteralink = $tmparray[
'htmltoenteralink'];
1003 print $htmltoenteralink;
1005 $somethingshown = $form->showLinkedObjectBlock($object, $linktoelem, array());
1008 print
'</div><div class="fichehalfright">';
1012 $morehtmlcenter =
dolGetButtonTitle($langs->trans(
'SeeAll'),
'',
'fa fa-bars imgforviewmode', DOL_URL_ROOT.
'/mrp/mo_agenda.php?id='.
$object->id);
1015 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formactions.class.php';
1017 $somethingshown = $formactions->showactions($object,
$object->element, $socid, 1,
'', $MAXEVENT,
'', $morehtmlcenter);
1019 print
'</div></div>';
1023 if (
GETPOST(
'modelselected')) {
1024 $action =
'presend';
1029 $defaulttopic =
'InformationMessage';
1030 $diroutput =
$conf->mrp->dir_output;
1031 $trackid =
'mo'.$object->id;
1033 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.
dol_clone($srcobject, $native=2)
Create a clone of instance of object (new instance with same value for each properties) With native =...
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
isModEnabled($module)
Is Dolibarr module enabled.
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.
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='', $morecssonpicto='widthpictotitle')
Load a title with picto.
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, $nodie=0, $mode='')
Check permissions of a user to show a page and an object.