25 require
'../main.inc.php';
27 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formcompany.class.php';
28 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
29 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formprojet.class.php';
30 require_once DOL_DOCUMENT_ROOT.
'/projet/class/project.class.php';
31 require_once DOL_DOCUMENT_ROOT.
'/product/class/product.class.php';
32 require_once DOL_DOCUMENT_ROOT.
'/product/class/html.formproduct.class.php';
33 require_once DOL_DOCUMENT_ROOT.
'/product/stock/class/entrepot.class.php';
34 require_once DOL_DOCUMENT_ROOT.
'/product/stock/class/productlot.class.php';
35 require_once DOL_DOCUMENT_ROOT.
'/product/stock/class/mouvementstock.class.php';
41 $langs->loadLangs(array(
"mrp",
"stocks",
"other",
"product",
"productbatch"));
46 $action =
GETPOST(
'action',
'aZ09');
47 $confirm =
GETPOST(
'confirm',
'alpha');
48 $cancel =
GETPOST(
'cancel',
'aZ09');
49 $contextpage =
GETPOST(
'contextpage',
'aZ') ?
GETPOST(
'contextpage',
'aZ') :
'mocard';
50 $backtopage =
GETPOST(
'backtopage',
'alpha');
51 $lineid =
GETPOST(
'lineid',
'int');
52 $fk_movement =
GETPOST(
'fk_movement',
'int');
53 $fk_default_warehouse =
GETPOST(
'fk_default_warehouse',
'int');
55 $collapse =
GETPOST(
'collapse',
'aZ09comma');
58 $object =
new Mo($db);
60 $diroutputmassaction = $conf->mrp->dir_output.
'/temp/massgeneration/'.$user->id;
61 $hookmanager->initHooks(array(
'mocard',
'globalcard'));
64 $extrafields->fetch_name_optionals_label($object->table_element);
66 $search_array_options = $extrafields->getOptionalsFromPost($object->table_element,
'',
'search_');
69 $search_all =
GETPOST(
"search_all",
'alpha');
71 foreach ($object->fields as $key => $val) {
72 if (
GETPOST(
'search_'.$key,
'alpha')) {
73 $search[$key] =
GETPOST(
'search_'.$key,
'alpha');
77 if (empty($action) && empty($id) && empty($ref)) {
82 include DOL_DOCUMENT_ROOT.
'/core/actions_fetchobject.inc.php';
87 $isdraft = (($object->status == $object::STATUS_DRAFT) ? 1 : 0);
88 $result =
restrictedArea($user,
'mrp', $object->id,
'mrp_mo',
'',
'fk_soc',
'rowid', $isdraft);
90 $permissionnote = $user->rights->mrp->write;
91 $permissiondellink = $user->rights->mrp->write;
92 $permissiontoadd = $user->rights->mrp->write;
93 $permissiontodelete = $user->rights->mrp->delete || ($permissiontoadd && isset($object->status) && $object->status == $object::STATUS_DRAFT);
94 $upload_dir = $conf->mrp->multidir_output[isset($object->entity) ? $object->entity : 1];
96 $permissiontoproduce = $permissiontoadd;
97 $permissiontoupdatecost = $user->rights->bom->read;
104 $parameters = array();
105 $reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
110 if (empty($reshook)) {
115 if (empty($backtopage) || ($cancel && empty($id))) {
117 if (empty($id) && (($action !=
'add' && $action !=
'create') || $cancel)) {
118 $backtopage = $backurlforlist;
120 $backtopage = DOL_URL_ROOT.
'/mrp/mo_production.php?id='.($id > 0 ? $id :
'__ID__');
123 $triggermodname =
'MO_MODIFY';
126 include DOL_DOCUMENT_ROOT.
'/core/actions_addupdatedelete.inc.php';
129 include DOL_DOCUMENT_ROOT.
'/core/actions_dellink.inc.php';
132 include DOL_DOCUMENT_ROOT.
'/core/actions_printing.inc.php';
135 $triggersendname =
'MO_SENTBYMAIL';
136 $autocopy =
'MAIN_MAIL_AUTOCOPY_MO_TO';
137 $trackid =
'mo'.$object->id;
138 include DOL_DOCUMENT_ROOT.
'/core/actions_sendmails.inc.php';
143 if ($action ==
'set_thirdparty' && $permissiontoadd) {
144 $object->setValueFrom(
'fk_soc',
GETPOST(
'fk_soc',
'int'),
'',
'',
'date',
'', $user, $triggermodname);
146 if ($action ==
'classin' && $permissiontoadd) {
147 $object->setProject(
GETPOST(
'projectid',
'int'));
150 if ($action ==
'confirm_reopen' && $permissiontoadd) {
151 $result = $object->setStatut($object::STATUS_INPROGRESS, 0,
'',
'MRP_REOPEN');
154 if (($action ==
'confirm_addconsumeline' &&
GETPOST(
'addconsumelinebutton') && $permissiontoadd)
155 || ($action ==
'confirm_addproduceline' &&
GETPOST(
'addproducelinebutton') && $permissiontoadd)) {
156 $moline =
new MoLine($db);
159 $moline->fk_mo = $object->id;
160 $moline->qty =
GETPOST(
'qtytoadd',
'int');
161 $moline->fk_product =
GETPOST(
'productidtoadd',
'int');
162 if (
GETPOST(
'addconsumelinebutton')) {
163 $moline->role =
'toconsume';
165 $moline->role =
'toproduce';
167 $moline->origin_type =
'free';
168 $moline->position = 0;
170 $resultline = $moline->create($user,
false);
171 if ($resultline <= 0) {
178 header(
"Location: ".$_SERVER[
"PHP_SELF"].
'?id='.$object->id);
181 if (in_array($action, array(
'confirm_consumeorproduce',
'confirm_consumeandproduceall')) && $permissiontoproduce) {
184 $labelmovement =
GETPOST(
'inventorylabel',
'alphanohtml');
185 $codemovement =
GETPOST(
'inventorycode',
'alphanohtml');
190 foreach ($object->lines as $line) {
191 if ($line->role ==
'toconsume') {
192 $tmpproduct =
new Product($db);
193 $tmpproduct->fetch($line->fk_product);
199 if ($qtytoprocess != 0) {
202 if (!(
GETPOST(
'idwarehouse-'.$line->id.
'-'.$i) > 0)) {
203 $langs->load(
"errors");
204 setEventMessages($langs->trans(
"ErrorFieldRequiredForProduct", $langs->transnoentitiesnoconv(
"Warehouse"), $tmpproduct->ref),
null,
'errors');
207 if ($tmpproduct->status_batch && (!
GETPOST(
'batch-'.$line->id.
'-'.$i))) {
208 $langs->load(
"errors");
209 setEventMessages($langs->trans(
"ErrorFieldRequiredForProduct", $langs->transnoentitiesnoconv(
"Batch"), $tmpproduct->ref),
null,
'errors');
215 if (!$error &&
GETPOST(
'idwarehouse-'.$line->id.
'-'.$i) > 0) {
217 $id_product_batch = 0;
218 $stockmove->setOrigin($object->element, $object->id);
220 if ($qtytoprocess >= 0) {
221 $idstockmove = $stockmove->livraison($user, $line->fk_product,
GETPOST(
'idwarehouse-'.$line->id.
'-'.$i), $qtytoprocess, 0, $labelmovement,
dol_now(),
'',
'',
GETPOST(
'batch-'.$line->id.
'-'.$i), $id_product_batch, $codemovement);
223 $idstockmove = $stockmove->reception($user, $line->fk_product,
GETPOST(
'idwarehouse-'.$line->id.
'-'.$i), $qtytoprocess * -1, 0, $labelmovement,
dol_now(),
'',
'',
GETPOST(
'batch-'.$line->id.
'-'.$i), $id_product_batch, $codemovement);
225 if ($idstockmove < 0) {
233 $moline =
new MoLine($db);
234 $moline->fk_mo = $object->id;
235 $moline->position = $pos;
236 $moline->fk_product = $line->fk_product;
237 $moline->fk_warehouse =
GETPOST(
'idwarehouse-'.$line->id.
'-'.$i);
238 $moline->qty = $qtytoprocess;
239 $moline->batch =
GETPOST(
'batch-'.$line->id.
'-'.$i);
240 $moline->role =
'consumed';
241 $moline->fk_mrp_production = $line->id;
242 $moline->fk_stock_movement = $idstockmove;
243 $moline->fk_user_creat = $user->id;
245 $resultmoline = $moline->create($user);
246 if ($resultmoline <= 0) {
263 foreach ($object->lines as $line) {
264 if ($line->role ==
'toproduce') {
265 $tmpproduct =
new Product($db);
266 $tmpproduct->fetch($line->fk_product);
269 while (
GETPOSTISSET(
'qtytoproduce-'.$line->id.
'-'.$i)) {
271 $pricetoprocess =
GETPOST(
'pricetoproduce-'.$line->id.
'-'.$i) ?
price2num(
GETPOST(
'pricetoproduce-'.$line->id.
'-'.$i)) : 0;
273 if ($qtytoprocess != 0) {
275 if (
GETPOSTISSET(
'idwarehousetoproduce-'.$line->id.
'-'.$i)) {
276 if (!(
GETPOST(
'idwarehousetoproduce-'.$line->id.
'-'.$i) > 0)) {
277 $langs->load(
"errors");
278 setEventMessages($langs->trans(
"ErrorFieldRequiredForProduct", $langs->transnoentitiesnoconv(
"Warehouse"), $tmpproduct->ref),
null,
'errors');
281 if (
isModEnabled(
'productbatch') && $tmpproduct->status_batch && (!
GETPOST(
'batchtoproduce-'.$line->id.
'-'.$i))) {
282 $langs->load(
"errors");
283 setEventMessages($langs->trans(
"ErrorFieldRequiredForProduct", $langs->transnoentitiesnoconv(
"Batch"), $tmpproduct->ref),
null,
'errors');
289 if (!$error &&
GETPOST(
'idwarehousetoproduce-'.$line->id.
'-'.$i) > 0) {
291 $id_product_batch = 0;
292 $stockmove->origin_type = $object->element;
293 $stockmove->origin_id = $object->id;
295 $idstockmove = $stockmove->reception($user, $line->fk_product,
GETPOST(
'idwarehousetoproduce-'.$line->id.
'-'.$i), $qtytoprocess, $pricetoprocess, $labelmovement,
'',
'',
GETPOST(
'batchtoproduce-'.$line->id.
'-'.$i),
dol_now(), $id_product_batch, $codemovement);
296 if ($idstockmove < 0) {
304 $moline =
new MoLine($db);
305 $moline->fk_mo = $object->id;
306 $moline->position = $pos;
307 $moline->fk_product = $line->fk_product;
308 $moline->fk_warehouse =
GETPOST(
'idwarehousetoproduce-'.$line->id.
'-'.$i);
309 $moline->qty = $qtytoprocess;
310 $moline->batch =
GETPOST(
'batchtoproduce-'.$line->id.
'-'.$i);
311 $moline->role =
'produced';
312 $moline->fk_mrp_production = $line->id;
313 $moline->fk_stock_movement = $idstockmove;
314 $moline->fk_user_creat = $user->id;
316 $resultmoline = $moline->create($user);
317 if ($resultmoline <= 0) {
332 $consumptioncomplete =
true;
333 $productioncomplete =
true;
335 if (
GETPOST(
'autoclose',
'int')) {
336 foreach ($object->lines as $line) {
337 if ($line->role ==
'toconsume') {
338 $arrayoflines = $object->fetchLinesLinked(
'consumed', $line->id);
339 $alreadyconsumed = 0;
340 foreach ($arrayoflines as $line2) {
341 $alreadyconsumed += $line2[
'qty'];
344 if ($alreadyconsumed < $line->qty) {
345 $consumptioncomplete =
false;
348 if ($line->role ==
'toproduce') {
349 $arrayoflines = $object->fetchLinesLinked(
'produced', $line->id);
350 $alreadyproduced = 0;
351 foreach ($arrayoflines as $line2) {
352 $alreadyproduced += $line2[
'qty'];
355 if ($alreadyproduced < $line->qty) {
356 $productioncomplete =
false;
361 $consumptioncomplete =
false;
362 $productioncomplete =
false;
366 dol_syslog(
"consumptioncomplete = ".$consumptioncomplete.
" productioncomplete = ".$productioncomplete);
368 if ($consumptioncomplete && $productioncomplete) {
369 $result = $object->setStatut($object::STATUS_PRODUCED, 0,
'',
'MRP_MO_PRODUCED');
371 $result = $object->setStatut($object::STATUS_INPROGRESS, 0,
'',
'MRP_MO_PRODUCED');
380 $action = str_replace(
'confirm_',
'', $action);
386 header(
"Location: ".$_SERVER[
"PHP_SELF"].
'?id='.$object->id);
392 if ($action ==
'confirm_produced' && $confirm ==
'yes' && $permissiontoadd) {
393 $result = $object->setStatut($object::STATUS_PRODUCED, 0,
'',
'MRP_MO_PRODUCED');
396 if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) {
397 $outputlangs = $langs;
400 $newlang =
GETPOST(
'lang_id',
'aZ09');
403 $newlang = $object->thirdparty->default_lang;
405 if (!empty($newlang)) {
407 $outputlangs->setDefaultLang($newlang);
409 $model = $object->model_pdf;
410 $ret = $object->fetch($id);
412 $object->generateDocument($model, $outputlangs, 0, 0, 0);
433 $help_url =
'EN:Module_Manufacturing_Orders|FR:Module_Ordres_de_Fabrication';
434 llxHeader(
'', $langs->trans(
'Mo'),
$help_url,
'', 0, 0, array(
'/mrp/js/lib_dispatch.js.php'));
439 if ($object->id > 0 && (empty($action) || ($action !=
'edit' && $action !=
'create'))) {
440 $res = $object->fetch_thirdparty();
441 $res = $object->fetch_optionals();
445 print
dol_get_fiche_head($head,
'production', $langs->trans(
"ManufacturingOrder"), -1, $object->picto);
450 if ($action ==
'delete') {
451 $formconfirm =
$form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.$object->id, $langs->trans(
'DeleteMo'), $langs->trans(
'ConfirmDeleteMo'),
'confirm_delete',
'', 0, 1);
454 if ($action ==
'deleteline') {
455 $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);
458 if ($action ==
'clone') {
460 $formquestion = array();
461 $formconfirm =
$form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.$object->id, $langs->trans(
'ToClone'), $langs->trans(
'ConfirmCloneMo', $object->ref),
'confirm_clone', $formquestion,
'yes', 1);
465 if ($action ==
'validate') {
467 $ref = substr($object->ref, 1, 4);
468 if ($ref ==
'PROV') {
469 $object->fetch_product();
470 $numref = $object->getNextNumRef($object->fk_product);
472 $numref = $object->ref;
475 $text = $langs->trans(
'ConfirmValidateMo', $numref);
484 $formquestion = array();
487 require_once DOL_DOCUMENT_ROOT.
'/product/class/html.formproduct.class.php';
490 if ($conf->browser->name ==
'ie') {
493 $formquestion = array(
500 $formconfirm =
$form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.$object->id, $langs->trans(
'Validate'), $text,
'confirm_validate', $formquestion, 0, 1, 220);
504 $parameters = array(
'formConfirm' =>
$formconfirm,
'lineid' => $lineid);
505 $reshook = $hookmanager->executeHooks(
'formConfirm', $parameters, $object, $action);
506 if (empty($reshook)) {
508 } elseif ($reshook > 0) {
518 $linkback =
'<a href="'.DOL_URL_ROOT.
'/mrp/mo_list.php?restore_lastsearch_values=1'.(!empty($socid) ?
'&socid='.$socid :
'').
'">'.$langs->trans(
"BackToList").
'</a>';
520 $morehtmlref =
'<div class="refidno">';
526 if (is_object($object->thirdparty)) {
527 $morehtmlref .= $object->thirdparty->getNomUrl(1,
'customer');
528 if (empty($conf->global->MAIN_DISABLE_OTHER_LINK) && $object->thirdparty->id > 0) {
529 $morehtmlref .=
' (<a href="'.DOL_URL_ROOT.
'/commande/list.php?socid='.$object->thirdparty->id.
'&search_societe='.urlencode($object->thirdparty->name).
'">'.$langs->trans(
"OtherOrders").
'</a>)';
534 $langs->load(
"projects");
535 if (is_object($object->thirdparty)) {
536 $morehtmlref .=
'<br>';
538 if ($permissiontoadd) {
539 $morehtmlref .=
img_picto($langs->trans(
"Project"),
'project',
'class="pictofixedwidth"');
540 if ($action !=
'classify') {
541 $morehtmlref .=
'<a class="editfielda" href="'.$_SERVER[
'PHP_SELF'].
'?action=classify&token='.
newToken().
'&id='.$object->id.
'">'.
img_edit($langs->transnoentitiesnoconv(
'SetProject')).
'</a> ';
543 $morehtmlref .=
$form->form_project($_SERVER[
'PHP_SELF'].
'?id='.$object->id, $object->socid, $object->fk_project, ($action ==
'classify' ?
'projectid' :
'none'), 0, ($action ==
'classify' ? 1 : 0), 0, 1,
'');
545 if (!empty($object->fk_project)) {
547 $proj->fetch($object->fk_project);
548 $morehtmlref .= $proj->getNomUrl(1);
550 $morehtmlref .=
'<span class="opacitymedium"> - '.dol_escape_htmltag($proj->title).
'</span>';
555 $morehtmlref .=
'</div>';
558 dol_banner_tab($object,
'ref', $linkback, 1,
'ref',
'ref', $morehtmlref);
561 print
'<div class="fichecenter">';
562 print
'<div class="fichehalfleft">';
563 print
'<div class="underbanner clearboth"></div>';
564 print
'<table class="border centpercent tableforfield">'.
"\n";
567 $keyforbreak =
'fk_warehouse';
568 unset($object->fields[
'fk_project']);
569 unset($object->fields[
'fk_soc']);
570 include DOL_DOCUMENT_ROOT.
'/core/tpl/commonfields_view.tpl.php';
573 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_view.tpl.php';
579 print
'<div class="clearboth"></div>';
584 if (!in_array($action, array(
'consumeorproduce',
'consumeandproduceall'))) {
585 print
'<div class="tabsAction">';
587 $parameters = array();
589 $reshook = $hookmanager->executeHooks(
'addMoreActionsButtons', $parameters, $object, $action);
590 if (empty($reshook)) {
592 if ($object->status == $object::STATUS_DRAFT) {
593 if ($permissiontoadd) {
594 if (empty($object->table_element_line) || (is_array($object->lines) && count($object->lines) > 0)) {
595 print
'<a class="butAction" href="'.$_SERVER[
'PHP_SELF'].
'?id='.$object->id.
'&action=validate&token='.$newToken.
'">'.$langs->trans(
"Validate").
'</a>';
597 $langs->load(
"errors");
598 print
'<a class="butActionRefused" href="" title="'.$langs->trans(
"ErrorAddAtLeastOneLineFirst").
'">'.$langs->trans(
"Validate").
'</a>';
604 if ($object->status == Mo::STATUS_VALIDATED || $object->status == Mo::STATUS_INPROGRESS) {
605 if ($permissiontoproduce) {
606 print
'<a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'&action=consumeorproduce&token='.$newToken.
'">'.$langs->trans(
'ConsumeOrProduce').
'</a>';
608 print
'<a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans(
"NotEnoughPermissions").
'">'.$langs->trans(
'ConsumeOrProduce').
'</a>';
610 } elseif ($object->status == Mo::STATUS_DRAFT) {
611 print
'<a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans(
"ValidateBefore").
'">'.$langs->trans(
'ConsumeOrProduce').
'</a>';
615 if ($object->status == Mo::STATUS_VALIDATED || $object->status == Mo::STATUS_INPROGRESS) {
616 if ($permissiontoproduce) {
617 print
'<a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'&action=consumeandproduceall&token='.$newToken.
'">'.$langs->trans(
'ConsumeAndProduceAll').
'</a>';
619 print
'<a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans(
"NotEnoughPermissions").
'">'.$langs->trans(
'ConsumeAndProduceAll').
'</a>';
621 } elseif ($object->status == Mo::STATUS_DRAFT) {
622 print
'<a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans(
"ValidateBefore").
'">'.$langs->trans(
'ConsumeAndProduceAll').
'</a>';
626 if ($permissiontoadd) {
627 if ($object->status == $object::STATUS_VALIDATED || $object->status == $object::STATUS_INPROGRESS) {
628 $arrayproduced = $object->fetchLinesLinked(
'produced', 0);
630 foreach ($arrayproduced as $lineproduced) {
631 $nbProduced += $lineproduced[
'qty'];
633 if ($nbProduced > 0) {
634 print
'<a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'&action=confirm_produced&confirm=yes&token='.$newToken.
'">'.$langs->trans(
"Close").
'</a>'.
"\n";
636 print
'<a class="butActionRefused" href="#" title="'.$langs->trans(
"GoOnTabProductionToProduceFirst", $langs->transnoentitiesnoconv(
"Production")).
'">'.$langs->trans(
"Close").
'</a>'.
"\n";
639 print
'<a class="butActionDelete" href="'.$_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'&action=confirm_close&confirm=yes&token='.$newToken.
'">'.$langs->trans(
"Cancel").
'</a>'.
"\n";
642 if ($object->status == $object::STATUS_CANCELED) {
643 print
'<a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'&action=confirm_reopen&confirm=yes&token='.$newToken.
'">'.$langs->trans(
"Re-Open").
'</a>'.
"\n";
646 if ($object->status == $object::STATUS_PRODUCED) {
647 if ($permissiontoproduce) {
648 print
'<a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'&action=confirm_reopen&token='.$newToken.
'">'.$langs->trans(
'ReOpen').
'</a>';
650 print
'<a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans(
"NotEnoughPermissions").
'">'.$langs->trans(
'ReOpen').
'</a>';
659 if (in_array($action, array(
'consumeorproduce',
'consumeandproduceall',
'addconsumeline',
'addproduceline'))) {
660 print
'<form method="POST" action="'.$_SERVER[
"PHP_SELF"].
'">';
661 print
'<input type="hidden" name="token" value="'.newToken().
'">';
662 print
'<input type="hidden" name="action" value="confirm_'.$action.
'">';
663 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
664 print
'<input type="hidden" name="id" value="'.$id.
'">';
667 if (in_array($action, array(
'consumeorproduce',
'consumeandproduceall'))) {
668 $defaultstockmovementlabel =
GETPOST(
'inventorylabel',
'alphanohtml') ?
GETPOST(
'inventorylabel',
'alphanohtml') : $langs->trans(
"ProductionForRef", $object->
ref);
671 print
'<div class="center'.(in_array($action, array(
'consumeorproduce',
'consumeandproduceall')) ?
' formconsumeproduce' :
'').
'">';
672 print
'<div class="opacitymedium hideonsmartphone paddingbottom">'.$langs->trans(
"ConfirmProductionDesc", $langs->transnoentitiesnoconv(
"Confirm")).
'<br></div>';
673 print
'<span class="fieldrequired">'.$langs->trans(
"InventoryCode").
':</span> <input type="text" class="minwidth200 maxwidth250" name="inventorycode" value="'.$defaultstockmovementcode.
'"> ';
674 print
'<span class="clearbothonsmartphone"></span>';
675 print $langs->trans(
"MovementLabel").
': <input type="text" class="minwidth300" name="inventorylabel" value="'.$defaultstockmovementlabel.
'"><br><br>';
676 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>';
677 print
'<input type="submit" class="button" value="'.$langs->trans(
"Confirm").
'" name="confirm">';
679 print
'<input class="button button-cancel" type="submit" value="'.$langs->trans(
"Cancel").
'" name="cancel">';
693 if (!empty($object->table_element_line)) {
695 $object->fetchLines();
698 if ($object->fk_bom > 0) {
700 $res = $bom->fetch($object->fk_bom);
702 $bom->calculateCosts();
703 $bomcost = $bom->unit_cost;
709 print
'<div class="fichecenter">';
710 print
'<div class="fichehalfleft">';
711 print
'<div class="clearboth"></div>';
713 $url = $_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'&action=addconsumeline&token='.
newToken();
714 $permissiontoaddaconsumeline = $object->status != $object::STATUS_PRODUCED && $object->status != $object::STATUS_CANCELED;
715 $parameters = array(
'morecss'=>
'reposition');
718 if ($action !=
'consumeorproduce' && $action !=
'consumeandproduceall') {
719 $newcardbutton =
dolGetButtonTitle($langs->trans(
'AddNewConsumeLines'),
'',
'fa fa-plus-circle size15x', $url,
'', $permissiontoaddaconsumeline, $parameters);
722 print
load_fiche_titre($langs->trans(
'Consumption'), $newcardbutton,
'', 0,
'',
'',
'');
724 print
'<div class="div-table-responsive-no-min">';
725 print
'<table class="noborder noshadow centpercent nobottom">';
727 print
'<tr class="liste_titre">';
728 print
'<td>'.$langs->trans(
"Product").
'</td>';
730 print
'<td class="right">'.$langs->trans(
"Qty").
'</td>';
732 if ($permissiontoupdatecost && !empty($conf->global->MRP_SHOW_COST_FOR_CONSUMPTION)) {
733 print
'<td class="right">'.$langs->trans(
"UnitCost").
'</td>';
736 print
'<td class="right">'.$langs->trans(
"QtyAlreadyConsumed").
'</td>';
739 if ($collapse || in_array($action, array(
'consumeorproduce',
'consumeandproduceall'))) {
740 print $langs->trans(
"Warehouse");
743 if (in_array($action, array(
'consumeorproduce',
'consumeandproduceall'))) {
744 $listwarehouses = $tmpwarehouse->list_array(1);
745 if (count($listwarehouses) > 1) {
746 print
'<br><span class="opacitymedium">' . $langs->trans(
"ForceTo") .
'</span> ' .
$form->selectarray(
'fk_default_warehouse', $listwarehouses, $fk_default_warehouse, 1, 0, 0,
'', 0, 0, 0,
'',
'minwidth100 maxwidth300', 1);
747 } elseif (count($listwarehouses) == 1) {
748 print
'<br><span class="opacitymedium">' . $langs->trans(
"ForceTo") .
'</span> ' .
$form->selectarray(
'fk_default_warehouse', $listwarehouses, $fk_default_warehouse, 0, 0, 0,
'', 0, 0, 0,
'',
'minwidth100 maxwidth300', 1);
755 print
'<td align="right">';
756 if ($collapse || in_array($action, array(
'consumeorproduce',
'consumeandproduceall'))) {
757 print $langs->trans(
"Stock");
764 if ($collapse || in_array($action, array(
'consumeorproduce',
'consumeandproduceall'))) {
765 print $langs->trans(
"Batch");
770 if ($permissiontodelete) {
782 if ($action ==
'addconsumeline') {
783 print
'<!-- Add line to consume -->'.
"\n";
784 print
'<tr class="liste_titre">';
786 print
$form->select_produits(
'',
'productidtoadd',
'', 0, 0, -1, 2,
'', 1, array(), 0,
'1', 0,
'maxwidth300');
789 print
'<td class="right"><input type="text" name="qtytoadd" value="1" class="width50 right"></td>';
791 if ($permissiontoupdatecost && !empty($conf->global->MRP_SHOW_COST_FOR_CONSUMPTION)) {
795 print
'<td colspan="2">';
797 print
'<input type="submit" class="button buttongen button-add" name="addconsumelinebutton" value="'.$langs->trans(
"Add").
'">';
798 print
'<input type="submit" class="button buttongen button-cancel" name="canceladdconsumelinebutton" value="'.$langs->trans(
"Cancel").
'">';
808 if ($permissiontodelete) {
822 if (!empty($object->lines)) {
823 $nblinetoconsume = 0;
824 foreach ($object->lines as $line) {
825 if ($line->role ==
'toconsume') {
830 $nblinetoconsumecursor = 0;
831 foreach ($object->lines as $line) {
832 if ($line->role ==
'toconsume') {
833 $nblinetoconsumecursor++;
835 $tmpproduct =
new Product($db);
836 $tmpproduct->fetch($line->fk_product);
837 $linecost =
price2num($tmpproduct->pmp,
'MT');
839 if ($object->qty > 0) {
841 $costprice =
price2num((!empty($tmpproduct->cost_price)) ? $tmpproduct->cost_price : $tmpproduct->pmp);
842 if (empty($costprice)) {
843 require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.product.class.php';
845 if ($productFournisseur->find_min_price_product_fournisseur($line->fk_product) > 0) {
846 $costprice = $productFournisseur->fourn_unitprice;
851 $linecost =
price2num(($line->qty * $costprice) / $object->qty,
'MT');
852 $bomcostupdated +=
price2num(($line->qty * $costprice) / $object->qty,
'MU');
855 $bomcostupdated =
price2num($bomcostupdated,
'MU');
856 $arrayoflines = $object->fetchLinesLinked(
'consumed', $line->id);
857 $alreadyconsumed = 0;
858 foreach ($arrayoflines as $line2) {
859 $alreadyconsumed += $line2[
'qty'];
862 $suffix =
'_'.$line->id;
863 print
'<!-- Line to dispatch '.$suffix.
' -->'.
"\n";
865 print
'<input id="qty_ordered'.$suffix.
'" type="hidden" value="'.$line->qty.
'">';
866 print
'<input id="qty_dispatched'.$suffix.
'" type="hidden" value="'.$alreadyconsumed.
'">';
868 print
'<tr data-line-id="'.$line->id.
'">';
870 print
'<td>'.$tmpproduct->getNomUrl(1);
871 print
'<br><span class="opacitymedium small">'.$tmpproduct->label.
'</span>';
874 print
'<td class="right nowraponall">';
875 $help =
''; $picto =
'help';
876 if ($line->qty_frozen) {
877 $help = ($help ?
'<br>' :
'').
'<strong>'.$langs->trans(
"QuantityFrozen").
'</strong>: '.
yn(1).
' ('.$langs->trans(
"QuantityConsumedInvariable").
')';
878 print
$form->textwithpicto(
'', $help, -1,
'lock').
' ';
880 if ($line->disable_stock_change) {
881 $help = ($help ?
'<br>' :
'').
'<strong>'.$langs->trans(
"DisableStockChange").
'</strong>: '.
yn(1).
' ('.(($tmpproduct->type ==
Product::TYPE_SERVICE && empty($conf->global->STOCK_SUPPORTS_SERVICES)) ? $langs->trans(
"NoStockChangeOnServices") : $langs->trans(
"DisableStockChangeHelp")).
')';
882 print
$form->textwithpicto(
'', $help, -1,
'help').
' ';
887 if ($permissiontoupdatecost && !empty($conf->global->MRP_SHOW_COST_FOR_CONSUMPTION)) {
888 print
'<td class="right nowraponall">';
889 print
price($linecost);
893 print
'<td class="right">';
894 if ($alreadyconsumed) {
896 print
'jQuery(document).ready(function() {
897 jQuery("#expandtoproduce'.$line->id.
'").click(function() {
898 console.log("Expand mrp_production line '.$line->id.
'");
899 jQuery(".expanddetail'.$line->id.
'").toggle();';
900 if ($nblinetoconsume == $nblinetoconsumecursor) {
901 print
'if (jQuery("#tablelines").hasClass("nobottom")) { jQuery("#tablelines").removeClass("nobottom"); } else { jQuery("#tablelines").addClass("nobottom"); }';
907 if (empty($conf->use_javascript_ajax)) {
908 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?collapse='.$collapse.
','.$line->id.
'">';
910 print
img_picto($langs->trans(
"ShowDetails"),
"chevron-down",
'id="expandtoproduce'.$line->id.
'"');
911 if (empty($conf->use_javascript_ajax)) {
915 if ($nblinetoconsume == $nblinetoconsumecursor) {
916 print
'<script>jQuery("#tablelines").removeClass("nobottom");</script>';
919 print
' '.price2num($alreadyconsumed,
'MS');
926 print
'<td class="nowraponall right">';
927 if ($tmpproduct->stock_reel < ($line->qty - $alreadyconsumed)) {
928 print
img_warning($langs->trans(
'StockTooLow')).
' ';
930 print
price2num($tmpproduct->stock_reel,
'MS');
938 if ($permissiontodelete) {
939 $href = $_SERVER[
"PHP_SELF"].
'?id='.((int) $object->id).
'&action=deleteline&token='.
newToken().
'&lineid='.((int) $line->id);
940 print
'<td class="center">';
941 print
'<a class="reposition" href="'.$href.
'">';
942 print
img_picto($langs->trans(
'TooltipDeleteAndRevertStockMovement'),
'delete');
956 foreach ($arrayoflines as $line2) {
957 print
'<tr class="expanddetail'.$line->id.
' hideobject opacitylow">';
961 $tmpstockmovement->id = $line2[
'fk_stock_movement'];
962 print
'<a href="'.DOL_URL_ROOT.
'/product/stock/movement_list.php?search_ref='.$tmpstockmovement->id.
'">'.
img_picto($langs->trans(
"StockMovement"),
'movement',
'class="paddingright"').
'</a>';
970 print
'<td class="right">'.$line2[
'qty'].
'</td>';
973 if ($permissiontoupdatecost && !empty($conf->global->MRP_SHOW_COST_FOR_CONSUMPTION)) {
978 print
'<td class="tdoverflowmax150">';
979 if ($line2[
'fk_warehouse'] > 0) {
980 $result = $tmpwarehouse->fetch($line2[
'fk_warehouse']);
982 print $tmpwarehouse->getNomUrl(1);
995 if ($line2[
'batch'] !=
'') {
996 $tmpbatch->fetch(0, $line2[
'fk_product'], $line2[
'batch']);
997 print $tmpbatch->getNomUrl(1);
1003 if ($permissiontodelete) {
1004 $href = $_SERVER[
"PHP_SELF"].
'?id='.((int) $object->id).
'&action=deleteline&token='.
newToken().
'&lineid='.((int) $line->id).
'&fk_movement='.((int) $line2[
'fk_stock_movement']);
1005 print
'<td class="center">';
1006 print
'<a class="reposition" href="'.$href.
'">';
1007 print
img_picto($langs->trans(
'TooltipDeleteAndRevertStockMovement'),
'delete');
1015 if (in_array($action, array(
'consumeorproduce',
'consumeandproduceall'))) {
1017 print
'<!-- Enter line to consume -->'.
"\n";
1019 print
'<tr data-max-qty="'.$maxQty.
'" name="batch_'.$line->id.
'_'.$i.
'">';
1021 print
'<td><span class="opacitymedium">'.$langs->trans(
"ToConsume").
'</span></td>';
1022 $preselected = (
GETPOSTISSET(
'qty-'.$line->id.
'-'.$i) ?
GETPOST(
'qty-'.$line->id.
'-'.$i) : max(0, $line->qty - $alreadyconsumed));
1023 if ($action ==
'consumeorproduce' && !
GETPOSTISSET(
'qty-'.$line->id.
'-'.$i)) {
1028 if (!empty($conf->global->MRP_NEVER_CONSUME_MORE_THAN_EXPECTED) && ($line->qty - $alreadyconsumed) <= 0) {
1029 $disable =
'disabled';
1033 print
'<input type="hidden" name="product-'.$line->id.
'-'.$i.
'" value="'.$line->fk_product.
'">';
1036 print
'<td class="right"><input type="text" class="width50 right" id="qtytoconsume-'.$line->id.
'-'.$i.
'" name="qty-'.$line->id.
'-'.$i.
'" value="'.$preselected.
'" '.$disable.
'></td>';
1039 if ($permissiontoupdatecost && !empty($conf->global->MRP_SHOW_COST_FOR_CONSUMPTION)) {
1049 if (empty($line->disable_stock_change)) {
1050 $preselected = (
GETPOSTISSET(
'idwarehouse-'.$line->id.
'-'.$i) ?
GETPOST(
'idwarehouse-'.$line->id.
'-'.$i) : ($tmpproduct->fk_default_warehouse > 0 ? $tmpproduct->fk_default_warehouse :
'ifone'));
1051 print $formproduct->selectWarehouses($preselected,
'idwarehouse-'.$line->id.
'-'.$i,
'', 1, 0, $line->fk_product,
'', 1, 0,
null,
'maxwidth200 csswarehouse_'.$line->id.
'_'.$i);
1053 print
'<span class="opacitymedium">'.$langs->trans(
"DisableStockChange").
'</span>';
1056 print
'<span class="opacitymedium">'.$langs->trans(
"NoStockChangeOnServices").
'</span>';
1068 if ($tmpproduct->status_batch) {
1069 $preselected = (
GETPOSTISSET(
'batch-'.$line->id.
'-'.$i) ?
GETPOST(
'batch-'.$line->id.
'-'.$i) :
'');
1070 print
'<input type="text" class="width50" name="batch-'.$line->id.
'-'.$i.
'" value="'.$preselected.
'" list="batch-'.$line->id.
'-'.$i.
'">';
1071 print $formproduct->selectLotDataList(
'batch-'.$line->id.
'-'.$i, 0, $line->fk_product,
'',
'');
1074 print
'<td align="right" class="split">';
1075 print
' '.img_picto($langs->trans(
'AddStockLocationLine'),
'split.png',
'class="splitbutton" onClick="addDispatchLine('.((int) $line->id).
', \''.
dol_escape_js($type).
'\', \
'qtymissingconsume\')"');
1077 print
'<td align="right" class="splitall">';
1078 if (($action ==
'consumeorproduce' || $action ==
'consumeandproduceall') && $tmpproduct->status_batch == 2) print
img_picto($langs->trans(
'SplitAllQuantity'),
'split.png',
'class="splitbutton splitallbutton field-error-icon" data-max-qty="1" onClick="addDispatchLine('.$line->id.
', \'batch\', \'allmissingconsume\')"');
1085 if ($permissiontodelete) {
1099 print
'<script type="text/javascript">
1100 $(document).ready(function () {
1101 $("select[name=fk_default_warehouse]").change(function() {
1102 var fk_default_warehouse = $("option:selected", this).val();
1103 $("select[name^=idwarehouse-]").val(fk_default_warehouse).change();
1112 print
'<div class="fichehalfright">';
1113 print
'<div class="clearboth"></div>';
1115 $nblinetoproduce = 0;
1116 foreach ($object->lines as $line) {
1117 if ($line->role ==
'toproduce') {
1122 $newcardbutton =
'';
1123 $url = $_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'&action=addproduceline&token='.
newToken();
1124 $permissiontoaddaproductline = $object->status != $object::STATUS_PRODUCED && $object->status != $object::STATUS_CANCELED;
1125 $parameters = array(
'morecss'=>
'reposition');
1126 if ($action !=
'consumeorproduce' && $action !=
'consumeandproduceall') {
1127 if ($nblinetoproduce == 0 || $object->mrptype == 1) {
1128 $newcardbutton =
dolGetButtonTitle($langs->trans(
'AddNewProduceLines'),
'',
'fa fa-plus-circle size15x', $url,
'', $permissiontoaddaproductline, $parameters);
1132 print
load_fiche_titre($langs->trans(
'Production'), $newcardbutton,
'', 0,
'',
'');
1134 print
'<div class="div-table-responsive-no-min">';
1135 print
'<table id="tablelinestoproduce" class="noborder noshadow nobottom centpercent">';
1137 print
'<tr class="liste_titre">';
1138 print
'<td>'.$langs->trans(
"Product").
'</td>';
1139 print
'<td class="right">'.$langs->trans(
"Qty").
'</td>';
1140 if ($permissiontoupdatecost) {
1141 if (empty($bomcostupdated)) {
1142 print
'<td class="right">'.$form->textwithpicto($langs->trans(
"UnitCost"), $langs->trans(
"AmountUsedToUpdateWAP")).
'</td>';
1144 print
'<td class="right">'.$form->textwithpicto($langs->trans(
"ManufacturingPrice"), $langs->trans(
"AmountUsedToUpdateWAP")).
'</td>';
1147 print
'<td class="right">'.$langs->trans(
"QtyAlreadyProduced").
'</td>';
1149 if ($collapse || in_array($action, array(
'consumeorproduce',
'consumeandproduceall'))) {
1150 print $langs->trans(
"Warehouse");
1155 if ($collapse || in_array($action, array(
'consumeorproduce',
'consumeandproduceall'))) {
1156 print $langs->trans(
"Batch");
1169 if ($action ==
'addproduceline') {
1170 print
'<!-- Add line to produce -->'.
"\n";
1171 print
'<tr class="liste_titre">';
1173 print
$form->select_produits(
'',
'productidtoadd',
'', 0, 0, -1, 2,
'', 1, array(), 0,
'1', 0,
'maxwidth300');
1176 print
'<td class="right"><input type="text" name="qtytoadd" value="1" class="width50 right"></td>';
1181 print
'<td colspan="2">';
1183 print
'<input type="submit" class="button buttongen button-add" name="addproducelinebutton" value="'.$langs->trans(
"Add").
'">';
1184 print
'<input type="submit" class="button buttongen button-cancel" name="canceladdproducelinebutton" value="'.$langs->trans(
"Cancel").
'">';
1191 if ($permissiontodelete) {
1197 if (!empty($object->lines)) {
1198 $nblinetoproduce = 0;
1199 foreach ($object->lines as $line) {
1200 if ($line->role ==
'toproduce') {
1205 $nblinetoproducecursor = 0;
1206 foreach ($object->lines as $line) {
1207 if ($line->role ==
'toproduce') {
1210 $nblinetoproducecursor++;
1212 $tmpproduct =
new Product($db);
1213 $tmpproduct->fetch($line->fk_product);
1215 $arrayoflines = $object->fetchLinesLinked(
'produced', $line->id);
1216 $alreadyproduced = 0;
1217 foreach ($arrayoflines as $line2) {
1218 $alreadyproduced += $line2[
'qty'];
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="'.$alreadyproduced.
'">';
1228 print
'<td>'.$tmpproduct->getNomUrl(1);
1229 print
'<br><span class="opacitymedium small">'.$tmpproduct->label.
'</span>';
1231 print
'<td class="right">'.$line->qty.
'</td>';
1232 if ($permissiontoupdatecost) {
1234 $manufacturingcost = 0;
1235 $manufacturingcostsrc =
'';
1236 if ($object->mrptype == 0) {
1237 $manufacturingcost = $bomcostupdated;
1238 $manufacturingcostsrc = $langs->trans(
"CalculatedFromProductsToConsume");
1239 if (empty($manufacturingcost)) {
1240 $manufacturingcost = $bomcost;
1241 $manufacturingcostsrc = $langs->trans(
"ValueFromBom");
1243 if (empty($manufacturingcost)) {
1244 $manufacturingcost =
price2num($tmpproduct->cost_price,
'MU');
1245 $manufacturingcostsrc = $langs->trans(
"CostPrice");
1247 if (empty($manufacturingcost)) {
1248 $manufacturingcost =
price2num($tmpproduct->pmp,
'MU');
1249 $manufacturingcostsrc = $langs->trans(
"PMPValue");
1253 print
'<td class="right nowraponall" title="'.dol_escape_htmltag($manufacturingcostsrc).
'">';
1254 if ($manufacturingcost) {
1255 print
price($manufacturingcost);
1259 print
'<td class="right nowraponall">';
1260 if ($alreadyproduced) {
1262 print
'jQuery(document).ready(function() {
1263 jQuery("#expandtoproduce'.$line->id.
'").click(function() {
1264 console.log("Expand mrp_production line '.$line->id.
'");
1265 jQuery(".expanddetailtoproduce'.$line->id.
'").toggle();';
1266 if ($nblinetoproduce == $nblinetoproducecursor) {
1267 print
'if (jQuery("#tablelinestoproduce").hasClass("nobottom")) { jQuery("#tablelinestoproduce").removeClass("nobottom"); } else { jQuery("#tablelinestoproduce").addClass("nobottom"); }';
1273 if (empty($conf->use_javascript_ajax)) {
1274 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?collapse='.$collapse.
','.$line->id.
'">';
1276 print
img_picto($langs->trans(
"ShowDetails"),
"chevron-down",
'id="expandtoproduce'.$line->id.
'"');
1277 if (empty($conf->use_javascript_ajax)) {
1281 print
' '.$alreadyproduced;
1289 if ($permissiontodelete && $line->origin_type ==
'free') {
1290 $href = $_SERVER[
"PHP_SELF"];
1291 $href .=
'?id='.$object->id;
1292 $href .=
'&action=deleteline';
1293 $href .=
'&lineid='.$line->id;
1294 print
'<td class="center">';
1295 print
'<a class="reposition" href="'.$href.
'">';
1296 print
img_picto($langs->trans(
'TooltipDeleteAndRevertStockMovement'),
"delete");
1303 foreach ($arrayoflines as $line2) {
1304 print
'<tr class="expanddetailtoproduce'.$line->id.
' hideobject opacitylow">';
1306 $tmpstockmovement->id = $line2[
'fk_stock_movement'];
1307 print
'<a href="'.DOL_URL_ROOT.
'/product/stock/movement_list.php?search_ref='.$tmpstockmovement->id.
'">'.
img_picto($langs->trans(
"StockMovement"),
'movement',
'class="paddingright"').
'</a>';
1313 if ($permissiontoupdatecost) {
1317 print
'<td class="right">'.$line2[
'qty'].
'</td>';
1318 print
'<td class="tdoverflowmax150">';
1319 if ($line2[
'fk_warehouse'] > 0) {
1320 $result = $tmpwarehouse->fetch($line2[
'fk_warehouse']);
1322 print $tmpwarehouse->getNomUrl(1);
1328 if ($line2[
'batch'] !=
'') {
1329 $tmpbatch->fetch(0, $line2[
'fk_product'], $line2[
'batch']);
1330 print $tmpbatch->getNomUrl(1);
1344 if (in_array($action, array(
'consumeorproduce',
'consumeandproduceall'))) {
1345 print
'<!-- Enter line to produce -->'.
"\n";
1347 print
'<tr data-max-qty="'.$maxQty.
'" name="batch_'.$line->id.
'_'.$i.
'">';
1348 print
'<td><span class="opacitymedium">'.$langs->trans(
"ToProduce").
'</span></td>';
1349 $preselected = (
GETPOSTISSET(
'qtytoproduce-'.$line->id.
'-'.$i) ?
GETPOST(
'qtytoproduce-'.$line->id.
'-'.$i) : max(0, $line->qty - $alreadyproduced));
1350 if ($action ==
'consumeorproduce' && !
GETPOSTISSET(
'qtytoproduce-'.$line->id.
'-'.$i)) {
1353 print
'<td class="right"><input type="text" class="width50 right" id="qtytoproduce-'.$line->id.
'-'.$i.
'" name="qtytoproduce-'.$line->id.
'-'.$i.
'" value="'.$preselected.
'"></td>';
1354 if ($permissiontoupdatecost) {
1356 $manufacturingcost = 0;
1357 $manufacturingcostsrc =
'';
1358 if ($object->mrptype == 0) {
1359 $manufacturingcost = $bomcostupdated;
1360 $manufacturingcostsrc = $langs->trans(
"CalculatedFromProductsToConsume");
1361 if (empty($manufacturingcost)) {
1362 $manufacturingcost = $bomcost;
1363 $manufacturingcostsrc = $langs->trans(
"ValueFromBom");
1365 if (empty($manufacturingcost)) {
1366 $manufacturingcost =
price2num($tmpproduct->cost_price,
'MU');
1367 $manufacturingcostsrc = $langs->trans(
"CostPrice");
1369 if (empty($manufacturingcost)) {
1370 $manufacturingcost =
price2num($tmpproduct->pmp,
'MU');
1371 $manufacturingcostsrc = $langs->trans(
"PMPValue");
1376 $preselected = (
GETPOSTISSET(
'pricetoproduce-'.$line->id.
'-'.$i) ?
GETPOST(
'pricetoproduce-'.$line->id.
'-'.$i) : ($manufacturingcost ?
price($manufacturingcost) :
''));
1377 print
'<td class="right"><input type="text" class="width75 right" name="pricetoproduce-'.$line->id.
'-'.$i.
'" value="'.$preselected.
'"></td>';
1379 print
'<td><input type="hidden" class="width50 right" name="pricetoproduce-'.$line->id.
'-'.$i.
'" value="'.($manufacturingcost ? $manufacturingcost :
'').
'"></td>';
1385 $preselected = (
GETPOSTISSET(
'idwarehousetoproduce-'.$line->id.
'-'.$i) ?
GETPOST(
'idwarehousetoproduce-'.$line->id.
'-'.$i) : ($object->fk_warehouse > 0 ? $object->fk_warehouse :
'ifone'));
1386 print $formproduct->selectWarehouses($preselected,
'idwarehousetoproduce-'.$line->id.
'-'.$i,
'', 1, 0, $line->fk_product,
'', 1, 0,
null,
'maxwidth200 csswarehouse_'.$line->id.
'_'.$i);
1388 print
'<span class="opacitymedium">'.$langs->trans(
"NoStockChangeOnServices").
'</span>';
1393 if ($tmpproduct->status_batch) {
1394 $preselected = (
GETPOSTISSET(
'batchtoproduce-'.$line->id.
'-'.$i) ?
GETPOST(
'batchtoproduce-'.$line->id.
'-'.$i) :
'');
1395 print
'<input type="text" class="width50" name="batchtoproduce-'.$line->id.
'-'.$i.
'" value="'.$preselected.
'">';
1400 if ($tmpproduct->status_batch) {
1402 print
'<td align="right" class="split">';
1403 print
img_picto($langs->trans(
'AddStockLocationLine'),
'split.png',
'class="splitbutton" onClick="addDispatchLine('.$line->id.
', \''.$type.
'\', \
'qtymissing\')"');
1406 print
'<td align="right" class="splitall">';
1407 if (($action ==
'consumeorproduce' || $action ==
'consumeandproduceall') && $tmpproduct->status_batch == 2) print
img_picto($langs->trans(
'SplitAllQuantity'),
'split.png',
'class="splitbutton splitallbutton field-error-icon" onClick="addDispatchLine('.$line->id.
', \'batch\', \'alltoproduce\')"');
1425 if (in_array($action, array(
'consumeorproduce',
'consumeandproduceall',
'addconsumeline'))) {
if(GETPOST('button_removefilter_x', 'alpha')||GETPOST('button_removefilter.x', 'alpha')||GETPOST('button_removefilter', 'alpha')) if(GETPOST('button_search_x', 'alpha')||GETPOST('button_search.x', 'alpha')||GETPOST('button_search', 'alpha')) if($action=="save" &&empty($cancel)) $help_url
View.
if(!defined('NOREQUIRESOC')) if(!defined('NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined('NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined('NOREQUIREAJAX')) llxHeader()
Empty header.
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.
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
dol_banner_tab($object, $paramid, $morehtml='', $shownav=1, $fieldid='rowid', $fieldref='ref', $morehtmlref='', $moreparam='', $nodbprefix=0, $morehtmlleft='', $morehtmlstatus='', $onlybanner=0, $morehtmlright='')
Show tab footer of a card.
load_fiche_titre($titre, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='')
Show tabs of a record.
img_warning($titlealt='default', $moreatt='', $morecss='pictowarning')
Show warning logo.
yn($yesno, $case=1, $color=0)
Return yes or no in current language.
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
dolGetButtonTitle($label, $helpText='', $iconClass='fa fa-file', $url='', $id='', $status=1, $params=array())
Function dolGetButtonTitle : this kind of buttons are used in title in list.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='')
Set event messages in dol_events session object.
price($amount, $form=0, $outlangs='', $trunc=1, $rounding=-1, $forcerounding=-1, $currency_code='')
Function to format a value into an amount for visual output Function used into PDF and HTML pages.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs='', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
if(!function_exists('dol_getprefix')) dol_include_once($relpath, $classname='')
Make an include_once using default root and alternate root if it fails.
dol_now($mode='auto')
Return date for now.
getDolGlobalInt($key, $default=0)
Return dolibarr global constant int value.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
dol_escape_js($stringtoescape, $mode=0, $noescapebackslashn=0)
Returns text escaped for inclusion into javascript code.
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)
Return value of a param into GET or POST supervariable.
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form.
isModEnabled($module)
Is Dolibarr module enabled.
img_edit($titlealt='default', $float=0, $other='')
Show logo editer/modifier fiche.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
$formconfirm
if ($action == 'delbookkeepingyear') {
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.