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 =
'MRP_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,
'MO_MODIFY');
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) {
179 if (in_array($action, array(
'confirm_consumeorproduce',
'confirm_consumeandproduceall')) && $permissiontoproduce) {
182 $labelmovement =
GETPOST(
'inventorylabel',
'alphanohtml');
183 $codemovement =
GETPOST(
'inventorycode',
'alphanohtml');
188 foreach ($object->lines as $line) {
189 if ($line->role ==
'toconsume') {
190 $tmpproduct =
new Product($db);
191 $tmpproduct->fetch($line->fk_product);
197 if ($qtytoprocess != 0) {
200 if (!(
GETPOST(
'idwarehouse-'.$line->id.
'-'.$i) > 0)) {
201 $langs->load(
"errors");
202 setEventMessages($langs->trans(
"ErrorFieldRequiredForProduct", $langs->transnoentitiesnoconv(
"Warehouse"), $tmpproduct->ref),
null,
'errors');
205 if ($tmpproduct->status_batch && (!
GETPOST(
'batch-'.$line->id.
'-'.$i))) {
206 $langs->load(
"errors");
207 setEventMessages($langs->trans(
"ErrorFieldRequiredForProduct", $langs->transnoentitiesnoconv(
"Batch"), $tmpproduct->ref),
null,
'errors');
213 if (!$error &&
GETPOST(
'idwarehouse-'.$line->id.
'-'.$i) > 0) {
215 $id_product_batch = 0;
216 $stockmove->setOrigin($object->element, $object->id);
218 if ($qtytoprocess >= 0) {
219 $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);
221 $idstockmove = $stockmove->reception($user, $line->fk_product,
GETPOST(
'idwarehouse-'.$line->id.
'-'.$i), $qtytoprocess, 0, $labelmovement,
dol_now(),
'',
'',
GETPOST(
'batch-'.$line->id.
'-'.$i), $id_product_batch, $codemovement);
223 if ($idstockmove < 0) {
231 $moline =
new MoLine($db);
232 $moline->fk_mo = $object->id;
233 $moline->position = $pos;
234 $moline->fk_product = $line->fk_product;
235 $moline->fk_warehouse =
GETPOST(
'idwarehouse-'.$line->id.
'-'.$i);
236 $moline->qty = $qtytoprocess;
237 $moline->batch =
GETPOST(
'batch-'.$line->id.
'-'.$i);
238 $moline->role =
'consumed';
239 $moline->fk_mrp_production = $line->id;
240 $moline->fk_stock_movement = $idstockmove;
241 $moline->fk_user_creat = $user->id;
243 $resultmoline = $moline->create($user);
244 if ($resultmoline <= 0) {
260 foreach ($object->lines as $line) {
261 if ($line->role ==
'toproduce') {
262 $tmpproduct =
new Product($db);
263 $tmpproduct->fetch($line->fk_product);
266 while (
GETPOSTISSET(
'qtytoproduce-'.$line->id.
'-'.$i)) {
268 $pricetoprocess =
GETPOST(
'pricetoproduce-'.$line->id.
'-'.$i) ?
price2num(
GETPOST(
'pricetoproduce-'.$line->id.
'-'.$i)) : 0;
270 if ($qtytoprocess != 0) {
272 if (
GETPOSTISSET(
'idwarehousetoproduce-'.$line->id.
'-'.$i)) {
273 if (!(
GETPOST(
'idwarehousetoproduce-'.$line->id.
'-'.$i) > 0)) {
274 $langs->load(
"errors");
275 setEventMessages($langs->trans(
"ErrorFieldRequiredForProduct", $langs->transnoentitiesnoconv(
"Warehouse"), $tmpproduct->ref),
null,
'errors');
278 if (!empty($conf->productbatch->enabled) && $tmpproduct->status_batch && (!
GETPOST(
'batchtoproduce-'.$line->id.
'-'.$i))) {
279 $langs->load(
"errors");
280 setEventMessages($langs->trans(
"ErrorFieldRequiredForProduct", $langs->transnoentitiesnoconv(
"Batch"), $tmpproduct->ref),
null,
'errors');
286 if (!$error &&
GETPOST(
'idwarehousetoproduce-'.$line->id.
'-'.$i) > 0) {
288 $id_product_batch = 0;
289 $stockmove->origin_type = $object->element;
290 $stockmove->origin_id = $object->id;
292 $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);
293 if ($idstockmove < 0) {
301 $moline =
new MoLine($db);
302 $moline->fk_mo = $object->id;
303 $moline->position = $pos;
304 $moline->fk_product = $line->fk_product;
305 $moline->fk_warehouse =
GETPOST(
'idwarehousetoproduce-'.$line->id.
'-'.$i);
306 $moline->qty = $qtytoprocess;
307 $moline->batch =
GETPOST(
'batchtoproduce-'.$line->id.
'-'.$i);
308 $moline->role =
'produced';
309 $moline->fk_mrp_production = $line->id;
310 $moline->fk_stock_movement = $idstockmove;
311 $moline->fk_user_creat = $user->id;
313 $resultmoline = $moline->create($user);
314 if ($resultmoline <= 0) {
329 $consumptioncomplete =
true;
330 $productioncomplete =
true;
332 if (
GETPOST(
'autoclose',
'int')) {
333 foreach ($object->lines as $line) {
334 if ($line->role ==
'toconsume') {
335 $arrayoflines = $object->fetchLinesLinked(
'consumed', $line->id);
336 $alreadyconsumed = 0;
337 foreach ($arrayoflines as $line2) {
338 $alreadyconsumed += $line2[
'qty'];
341 if ($alreadyconsumed < $line->qty) {
342 $consumptioncomplete =
false;
345 if ($line->role ==
'toproduce') {
346 $arrayoflines = $object->fetchLinesLinked(
'produced', $line->id);
347 $alreadyproduced = 0;
348 foreach ($arrayoflines as $line2) {
349 $alreadyproduced += $line2[
'qty'];
352 if ($alreadyproduced < $line->qty) {
353 $productioncomplete =
false;
358 $consumptioncomplete =
false;
359 $productioncomplete =
false;
363 dol_syslog(
"consumptioncomplete = ".$consumptioncomplete.
" productioncomplete = ".$productioncomplete);
365 if ($consumptioncomplete && $productioncomplete) {
366 $result = $object->setStatut($object::STATUS_PRODUCED, 0,
'',
'MRP_MO_PRODUCED');
368 $result = $object->setStatut($object::STATUS_INPROGRESS, 0,
'',
'MRP_MO_PRODUCED');
377 $action = str_replace(
'confirm_',
'', $action);
383 header(
"Location: ".$_SERVER[
"PHP_SELF"].
'?id='.$object->id);
389 if ($action ==
'confirm_produced' && $confirm ==
'yes' && $permissiontoadd) {
390 $result = $object->setStatut($object::STATUS_PRODUCED, 0,
'',
'MRP_MO_PRODUCED');
393 if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) {
394 $outputlangs = $langs;
396 if ($conf->global->MAIN_MULTILANGS && empty($newlang) &&
GETPOST(
'lang_id',
'aZ09')) {
397 $newlang =
GETPOST(
'lang_id',
'aZ09');
399 if ($conf->global->MAIN_MULTILANGS && empty($newlang)) {
400 $newlang = $object->thirdparty->default_lang;
402 if (!empty($newlang)) {
404 $outputlangs->setDefaultLang($newlang);
406 $model = $object->model_pdf;
407 $ret = $object->fetch($id);
409 $object->generateDocument($model, $outputlangs, 0, 0, 0);
430 $help_url =
'EN:Module_Manufacturing_Orders|FR:Module_Ordres_de_Fabrication';
431 llxHeader(
'', $langs->trans(
'Mo'),
$help_url,
'', 0, 0, array(
'/mrp/js/lib_dispatch.js.php'));
434 if ($object->id > 0 && (empty($action) || ($action !=
'edit' && $action !=
'create'))) {
435 $res = $object->fetch_thirdparty();
436 $res = $object->fetch_optionals();
440 print
dol_get_fiche_head($head,
'production', $langs->trans(
"ManufacturingOrder"), -1, $object->picto);
445 if ($action ==
'delete') {
446 $formconfirm =
$form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.$object->id, $langs->trans(
'DeleteMo'), $langs->trans(
'ConfirmDeleteMo'),
'confirm_delete',
'', 0, 1);
449 if ($action ==
'deleteline') {
450 $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);
453 if ($action ==
'clone') {
455 $formquestion = array();
456 $formconfirm =
$form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.$object->id, $langs->trans(
'ToClone'), $langs->trans(
'ConfirmCloneMo', $object->ref),
'confirm_clone', $formquestion,
'yes', 1);
460 if ($action ==
'validate') {
462 $ref = substr($object->ref, 1, 4);
463 if ($ref ==
'PROV') {
464 $object->fetch_product();
465 $numref = $object->getNextNumRef($object->fk_product);
467 $numref = $object->ref;
470 $text = $langs->trans(
'ConfirmValidateMo', $numref);
479 $formquestion = array();
480 if (!empty($conf->mrp->enabled)) {
482 require_once DOL_DOCUMENT_ROOT.
'/product/class/html.formproduct.class.php';
485 if ($conf->browser->name ==
'ie') {
488 $formquestion = array(
495 $formconfirm =
$form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.$object->id, $langs->trans(
'Validate'), $text,
'confirm_validate', $formquestion, 0, 1, 220);
499 $parameters = array(
'formConfirm' =>
$formconfirm,
'lineid' => $lineid);
500 $reshook = $hookmanager->executeHooks(
'formConfirm', $parameters, $object, $action);
501 if (empty($reshook)) {
503 } elseif ($reshook > 0) {
513 $linkback =
'<a href="'.DOL_URL_ROOT.
'/mrp/mo_list.php?restore_lastsearch_values=1'.(!empty($socid) ?
'&socid='.$socid :
'').
'">'.$langs->trans(
"BackToList").
'</a>';
515 $morehtmlref =
'<div class="refidno">';
521 $morehtmlref .= $langs->trans(
'ThirdParty').
' : '.(is_object($object->thirdparty) ? $object->thirdparty->getNomUrl(1) :
'');
523 if (!empty($conf->project->enabled)) {
524 $langs->load(
"projects");
525 $morehtmlref .=
'<br>'.$langs->trans(
'Project').
' ';
526 if ($permissiontoadd) {
527 if ($action !=
'classify') {
528 $morehtmlref .=
'<a class="editfielda" href="'.$_SERVER[
'PHP_SELF'].
'?action=classify&token='.
newToken().
'&id='.$object->id.
'">'.
img_edit($langs->transnoentitiesnoconv(
'SetProject')).
'</a> : ';
530 if ($action ==
'classify') {
532 $morehtmlref .=
'<form method="post" action="'.$_SERVER[
'PHP_SELF'].
'?id='.$object->id.
'">';
533 $morehtmlref .=
'<input type="hidden" name="action" value="classin">';
534 $morehtmlref .=
'<input type="hidden" name="token" value="'.newToken().
'">';
535 $morehtmlref .= $formproject->select_projects($object->fk_soc, $object->fk_project,
'projectid', 0, 0, 1, 0, 1, 0, 0,
'', 1);
536 $morehtmlref .=
'<input type="submit" class="button valignmiddle" value="'.$langs->trans(
"Modify").
'">';
537 $morehtmlref .=
'</form>';
539 $morehtmlref .=
$form->form_project($_SERVER[
'PHP_SELF'].
'?id='.$object->id, $object->fk_soc, $object->fk_project,
'none', 0, 0, 0, 1);
542 if (!empty($object->fk_project)) {
544 $proj->fetch($object->fk_project);
545 $morehtmlref .= $proj->getNomUrl();
551 $morehtmlref .=
'</div>';
554 dol_banner_tab($object,
'ref', $linkback, 1,
'ref',
'ref', $morehtmlref);
557 print
'<div class="fichecenter">';
558 print
'<div class="fichehalfleft">';
559 print
'<div class="underbanner clearboth"></div>';
560 print
'<table class="border centpercent tableforfield">'.
"\n";
563 $keyforbreak =
'fk_warehouse';
564 unset($object->fields[
'fk_project']);
565 unset($object->fields[
'fk_soc']);
566 include DOL_DOCUMENT_ROOT.
'/core/tpl/commonfields_view.tpl.php';
569 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_view.tpl.php';
575 print
'<div class="clearboth"></div>';
580 if (!in_array($action, array(
'consumeorproduce',
'consumeandproduceall'))) {
581 print
'<div class="tabsAction">';
583 $parameters = array();
585 $reshook = $hookmanager->executeHooks(
'addMoreActionsButtons', $parameters, $object, $action);
586 if (empty($reshook)) {
588 if ($object->status == $object::STATUS_DRAFT) {
589 if ($permissiontoadd) {
590 if (empty($object->table_element_line) || (is_array($object->lines) && count($object->lines) > 0)) {
591 print
'<a class="butAction" href="'.$_SERVER[
'PHP_SELF'].
'?id='.$object->id.
'&action=validate">'.$langs->trans(
"Validate").
'</a>';
593 $langs->load(
"errors");
594 print
'<a class="butActionRefused" href="" title="'.$langs->trans(
"ErrorAddAtLeastOneLineFirst").
'">'.$langs->trans(
"Validate").
'</a>';
600 if ($object->status == Mo::STATUS_VALIDATED || $object->status == Mo::STATUS_INPROGRESS) {
601 if ($permissiontoproduce) {
602 print
'<a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'&action=consumeorproduce">'.$langs->trans(
'ConsumeOrProduce').
'</a>';
604 print
'<a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans(
"NotEnoughPermissions").
'">'.$langs->trans(
'ConsumeOrProduce').
'</a>';
606 } elseif ($object->status == Mo::STATUS_DRAFT) {
607 print
'<a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans(
"ValidateBefore").
'">'.$langs->trans(
'ConsumeOrProduce').
'</a>';
611 if ($object->status == Mo::STATUS_VALIDATED || $object->status == Mo::STATUS_INPROGRESS) {
612 if ($permissiontoproduce) {
613 print
'<a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'&action=consumeandproduceall">'.$langs->trans(
'ConsumeAndProduceAll').
'</a>';
615 print
'<a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans(
"NotEnoughPermissions").
'">'.$langs->trans(
'ConsumeAndProduceAll').
'</a>';
617 } elseif ($object->status == Mo::STATUS_DRAFT) {
618 print
'<a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans(
"ValidateBefore").
'">'.$langs->trans(
'ConsumeAndProduceAll').
'</a>';
622 if ($permissiontoadd) {
623 if ($object->status == $object::STATUS_VALIDATED || $object->status == $object::STATUS_INPROGRESS) {
624 $arrayproduced = $object->fetchLinesLinked(
'produced', 0);
626 foreach ($arrayproduced as $lineproduced) {
627 $nbProduced += $lineproduced[
'qty'];
629 if ($nbProduced > 0) {
630 print
'<a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'&action=confirm_produced&confirm=yes">'.$langs->trans(
"Close").
'</a>'.
"\n";
632 print
'<a class="butActionRefused" href="#" title="'.$langs->trans(
"GoOnTabProductionToProduceFirst", $langs->transnoentitiesnoconv(
"Production")).
'">'.$langs->trans(
"Close").
'</a>'.
"\n";
635 print
'<a class="butActionDelete" href="'.$_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'&action=confirm_close&confirm=yes">'.$langs->trans(
"Cancel").
'</a>'.
"\n";
638 if ($object->status == $object::STATUS_CANCELED) {
639 print
'<a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'&action=confirm_reopen&confirm=yes">'.$langs->trans(
"Re-Open").
'</a>'.
"\n";
642 if ($object->status == $object::STATUS_PRODUCED) {
643 if ($permissiontoproduce) {
644 print
'<a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'&action=confirm_reopen">'.$langs->trans(
'ReOpen').
'</a>';
646 print
'<a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans(
"NotEnoughPermissions").
'">'.$langs->trans(
'ReOpen').
'</a>';
655 if (in_array($action, array(
'consumeorproduce',
'consumeandproduceall',
'addconsumeline',
'addproduceline'))) {
656 print
'<form method="POST" action="'.$_SERVER[
"PHP_SELF"].
'">';
657 print
'<input type="hidden" name="token" value="'.newToken().
'">';
658 print
'<input type="hidden" name="action" value="confirm_'.$action.
'">';
659 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
660 print
'<input type="hidden" name="id" value="'.$id.
'">';
663 if (in_array($action, array(
'consumeorproduce',
'consumeandproduceall'))) {
664 $defaultstockmovementlabel =
GETPOST(
'inventorylabel',
'alphanohtml') ?
GETPOST(
'inventorylabel',
'alphanohtml') : $langs->trans(
"ProductionForRef", $object->
ref);
667 print
'<div class="center'.(in_array($action, array(
'consumeorproduce',
'consumeandproduceall')) ?
' formconsumeproduce' :
'').
'">';
668 print
'<div class="opacitymedium hideonsmartphone paddingbottom">'.$langs->trans(
"ConfirmProductionDesc", $langs->transnoentitiesnoconv(
"Confirm")).
'<br></div>';
669 print
'<span class="fieldrequired">'.$langs->trans(
"InventoryCode").
':</span> <input type="text" class="minwidth200 maxwidth250" name="inventorycode" value="'.$defaultstockmovementcode.
'"> ';
670 print
'<span class="clearbothonsmartphone"></span>';
671 print $langs->trans(
"MovementLabel").
': <input type="text" class="minwidth300" name="inventorylabel" value="'.$defaultstockmovementlabel.
'"><br><br>';
672 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>';
673 print
'<input type="submit" class="button" value="'.$langs->trans(
"Confirm").
'" name="confirm">';
675 print
'<input class="button button-cancel" type="submit" value="'.$langs->trans(
"Cancel").
'" name="cancel">';
689 if (!empty($object->table_element_line)) {
691 $object->fetchLines();
694 if ($object->fk_bom > 0) {
696 $res = $bom->fetch($object->fk_bom);
698 $bom->calculateCosts();
699 $bomcost = $bom->unit_cost;
705 print
'<div class="fichecenter">';
706 print
'<div class="fichehalfleft">';
707 print
'<div class="clearboth"></div>';
709 $url = $_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'&action=addconsumeline&token='.
newToken();
710 $permissiontoaddaconsumeline = $object->status != $object::STATUS_PRODUCED && $object->status != $object::STATUS_CANCELED;
711 $parameters = array(
'morecss'=>
'reposition');
714 if ($action !=
'consumeorproduce' && $action !=
'consumeandproduceall') {
715 $newcardbutton =
dolGetButtonTitle($langs->trans(
'AddNewConsumeLines'),
'',
'fa fa-plus-circle size15x', $url,
'', $permissiontoaddaconsumeline, $parameters);
718 print
load_fiche_titre($langs->trans(
'Consumption'), $newcardbutton,
'', 0,
'',
'',
'');
720 print
'<div class="div-table-responsive-no-min">';
721 print
'<table class="noborder noshadow centpercent nobottom">';
723 print
'<tr class="liste_titre">';
724 print
'<td>'.$langs->trans(
"Product").
'</td>';
726 print
'<td class="right">'.$langs->trans(
"Qty").
'</td>';
728 if ($permissiontoupdatecost && !empty($conf->global->MRP_SHOW_COST_FOR_CONSUMPTION)) {
729 print
'<td class="right">'.$langs->trans(
"UnitCost").
'</td>';
732 print
'<td class="right">'.$langs->trans(
"QtyAlreadyConsumed").
'</td>';
735 if ($collapse || in_array($action, array(
'consumeorproduce',
'consumeandproduceall'))) {
736 print $langs->trans(
"Warehouse");
739 if (in_array($action, array(
'consumeorproduce',
'consumeandproduceall'))) {
740 $listwarehouses = $tmpwarehouse->list_array(1);
741 if (count($listwarehouses) > 1) {
742 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);
743 } elseif (count($listwarehouses) == 1) {
744 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);
751 print
'<td align="right">';
752 if ($collapse || in_array($action, array(
'consumeorproduce',
'consumeandproduceall'))) {
753 print $langs->trans(
"Stock");
760 if ($collapse || in_array($action, array(
'consumeorproduce',
'consumeandproduceall'))) {
761 print $langs->trans(
"Batch");
766 if ($permissiontodelete) {
771 if ($action ==
'addconsumeline') {
772 print
'<!-- Add line to consume -->'.
"\n";
773 print
'<tr class="liste_titre">';
775 print
$form->select_produits(
'',
'productidtoadd',
'', 0, 0, -1, 2,
'', 1, array(), 0,
'1', 0,
'maxwidth300');
778 print
'<td class="right"><input type="text" name="qtytoadd" value="1" class="width50 right"></td>';
780 if ($permissiontoupdatecost && !empty($conf->global->MRP_SHOW_COST_FOR_CONSUMPTION)) {
784 print
'<td colspan="2">';
786 print
'<input type="submit" class="button buttongen button-add" name="addconsumelinebutton" value="'.$langs->trans(
"Add").
'">';
787 print
'<input type="submit" class="button buttongen button-cancel" name="canceladdconsumelinebutton" value="'.$langs->trans(
"Cancel").
'">';
797 if ($permissiontodelete) {
807 if (!empty($object->lines)) {
808 $nblinetoconsume = 0;
809 foreach ($object->lines as $line) {
810 if ($line->role ==
'toconsume') {
815 $nblinetoconsumecursor = 0;
816 foreach ($object->lines as $line) {
817 if ($line->role ==
'toconsume') {
818 $nblinetoconsumecursor++;
820 $tmpproduct =
new Product($db);
821 $tmpproduct->fetch($line->fk_product);
822 $linecost =
price2num($tmpproduct->pmp,
'MT');
824 if ($object->qty > 0) {
826 $costprice =
price2num((!empty($tmpproduct->cost_price)) ? $tmpproduct->cost_price : $tmpproduct->pmp);
827 if (empty($costprice)) {
828 require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.product.class.php';
830 if ($productFournisseur->find_min_price_product_fournisseur($line->fk_product) > 0) {
831 $costprice = $productFournisseur->fourn_unitprice;
836 $linecost =
price2num(($line->qty * $costprice) / $object->qty,
'MT');
837 $bomcostupdated +=
price2num(($line->qty * $costprice) / $object->qty,
'MU');
840 $bomcostupdated =
price2num($bomcostupdated,
'MU');
841 $arrayoflines = $object->fetchLinesLinked(
'consumed', $line->id);
842 $alreadyconsumed = 0;
843 foreach ($arrayoflines as $line2) {
844 $alreadyconsumed += $line2[
'qty'];
847 $suffix =
'_'.$line->id;
848 print
'<!-- Line to dispatch '.$suffix.
' -->'.
"\n";
850 print
'<input id="qty_ordered'.$suffix.
'" type="hidden" value="'.$line->qty.
'">';
851 print
'<input id="qty_dispatched'.$suffix.
'" type="hidden" value="'.$alreadyconsumed.
'">';
855 print
'<td>'.$tmpproduct->getNomUrl(1);
856 print
'<br><span class="opacitymedium small">'.$tmpproduct->label.
'</span>';
859 print
'<td class="right nowraponall">';
861 if ($line->qty_frozen) {
862 $help .= ($help ?
'<br>' :
'').
'<strong>'.$langs->trans(
"QuantityFrozen").
'</strong>: '.
yn(1).
' ('.$langs->trans(
"QuantityConsumedInvariable").
')';
864 if ($line->disable_stock_change) {
865 $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")).
')';
868 print
$form->textwithpicto($line->qty, $help, -1);
874 if ($permissiontoupdatecost && !empty($conf->global->MRP_SHOW_COST_FOR_CONSUMPTION)) {
875 print
'<td class="right nowraponall">';
876 print
price($linecost);
880 print
'<td class="right">';
881 if ($alreadyconsumed) {
883 print
'jQuery(document).ready(function() {
884 jQuery("#expandtoproduce'.$line->id.
'").click(function() {
885 console.log("Expand mrp_production line '.$line->id.
'");
886 jQuery(".expanddetail'.$line->id.
'").toggle();';
887 if ($nblinetoconsume == $nblinetoconsumecursor) {
888 print
'if (jQuery("#tablelines").hasClass("nobottom")) { jQuery("#tablelines").removeClass("nobottom"); } else { jQuery("#tablelines").addClass("nobottom"); }';
894 if (empty($conf->use_javascript_ajax)) {
895 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?collapse='.$collapse.
','.$line->id.
'">';
897 print
img_picto($langs->trans(
"ShowDetails"),
"chevron-down",
'id="expandtoproduce'.$line->id.
'"');
898 if (empty($conf->use_javascript_ajax)) {
902 if ($nblinetoconsume == $nblinetoconsumecursor) {
903 print
'<script>jQuery("#tablelines").removeClass("nobottom");</script>';
906 print
' '.price2num($alreadyconsumed,
'MS');
913 print
'<td class="nowraponall right">';
914 if ($tmpproduct->stock_reel < ($line->qty - $alreadyconsumed)) {
915 print
img_warning($langs->trans(
'StockTooLow')).
' ';
917 print
price2num($tmpproduct->stock_reel,
'MS');
925 if ($permissiontodelete) {
926 $href = $_SERVER[
"PHP_SELF"].
'?id='.((int) $object->id).
'&action=deleteline&token='.
newToken().
'&lineid='.((int) $line->id);
927 print
'<td class="center">';
928 print
'<a class="reposition" href="'.$href.
'">';
929 print
img_picto($langs->trans(
'TooltipDeleteAndRevertStockMovement'),
'delete');
936 foreach ($arrayoflines as $line2) {
937 print
'<tr class="expanddetail'.$line->id.
' hideobject opacitylow">';
941 $tmpstockmovement->id = $line2[
'fk_stock_movement'];
942 print
'<a href="'.DOL_URL_ROOT.
'/product/stock/movement_list.php?search_ref='.$tmpstockmovement->id.
'">'.
img_picto($langs->trans(
"StockMovement"),
'movement',
'class="paddingright"').
'</a>';
950 print
'<td class="right">'.$line2[
'qty'].
'</td>';
953 if ($permissiontoupdatecost && !empty($conf->global->MRP_SHOW_COST_FOR_CONSUMPTION)) {
958 print
'<td class="tdoverflowmax150">';
959 if ($line2[
'fk_warehouse'] > 0) {
960 $result = $tmpwarehouse->fetch($line2[
'fk_warehouse']);
962 print $tmpwarehouse->getNomUrl(1);
975 if ($line2[
'batch'] !=
'') {
976 $tmpbatch->fetch(0, $line2[
'fk_product'], $line2[
'batch']);
977 print $tmpbatch->getNomUrl(1);
983 if ($permissiontodelete) {
984 $href = $_SERVER[
"PHP_SELF"].
'?id='.((int) $object->id).
'&action=deleteline&token='.
newToken().
'&lineid='.((int) $line->id).
'&fk_movement='.((int) $line2[
'fk_stock_movement']);
985 print
'<td class="center">';
986 print
'<a class="reposition" href="'.$href.
'">';
987 print
img_picto($langs->trans(
'TooltipDeleteAndRevertStockMovement'),
'delete');
995 if (in_array($action, array(
'consumeorproduce',
'consumeandproduceall'))) {
997 print
'<!-- Enter line to consume -->'.
"\n";
998 print
'<tr name="batch_'.$line->id.
'_'.$i.
'">';
1000 print
'<td><span class="opacitymedium">'.$langs->trans(
"ToConsume").
'</span></td>';
1001 $preselected = (
GETPOSTISSET(
'qty-'.$line->id.
'-'.$i) ?
GETPOST(
'qty-'.$line->id.
'-'.$i) : max(0, $line->qty - $alreadyconsumed));
1002 if ($action ==
'consumeorproduce' && !
GETPOSTISSET(
'qty-'.$line->id.
'-'.$i)) {
1007 if (!empty($conf->global->MRP_NEVER_CONSUME_MORE_THAN_EXPECTED) && ($line->qty - $alreadyconsumed) <= 0) {
1008 $disable =
'disabled';
1012 print
'<input type="hidden" name="product-'.$line->id.
'-'.$i.
'" value="'.$line->fk_product.
'">';
1015 print
'<td class="right"><input type="text" class="width50 right" id="qtytoconsume-'.$line->id.
'-'.$i.
'" name="qty-'.$line->id.
'-'.$i.
'" value="'.$preselected.
'" '.$disable.
'></td>';
1018 if ($permissiontoupdatecost && !empty($conf->global->MRP_SHOW_COST_FOR_CONSUMPTION)) {
1028 if (empty($line->disable_stock_change)) {
1029 $preselected = (
GETPOSTISSET(
'idwarehouse-'.$line->id.
'-'.$i) ?
GETPOST(
'idwarehouse-'.$line->id.
'-'.$i) : ($tmpproduct->fk_default_warehouse > 0 ? $tmpproduct->fk_default_warehouse :
'ifone'));
1030 print $formproduct->selectWarehouses($preselected,
'idwarehouse-'.$line->id.
'-'.$i,
'', 1, 0, $line->fk_product,
'', 1, 0,
null,
'maxwidth200 csswarehouse_'.$line->id.
'_'.$i);
1032 print
'<span class="opacitymedium">'.$langs->trans(
"DisableStockChange").
'</span>';
1035 print
'<span class="opacitymedium">'.$langs->trans(
"NoStockChangeOnServices").
'</span>';
1047 if ($tmpproduct->status_batch) {
1048 $preselected = (
GETPOSTISSET(
'batch-'.$line->id.
'-'.$i) ?
GETPOST(
'batch-'.$line->id.
'-'.$i) :
'');
1049 print
'<input type="text" class="width50" name="batch-'.$line->id.
'-'.$i.
'" value="'.$preselected.
'" list="batch-'.$line->id.
'-'.$i.
'">';
1050 print $formproduct->selectLotDataList(
'batch-'.$line->id.
'-'.$i, 0, $line->fk_product,
'',
'');
1053 print
' '.img_picto($langs->trans(
'AddStockLocationLine'),
'split.png',
'class="splitbutton" onClick="addDispatchLine('.((int) $line->id).
', \''.
dol_escape_js($type).
'\', \
'qtymissingconsume\')"');
1059 if ($permissiontodelete) {
1073 print
'<script type="text/javascript">
1074 $(document).ready(function () {
1075 $("select[name=fk_default_warehouse]").change(function() {
1076 var fk_default_warehouse = $("option:selected", this).val();
1077 $("select[name^=idwarehouse-]").val(fk_default_warehouse).change();
1086 print
'<div class="fichehalfright">';
1087 print
'<div class="clearboth"></div>';
1089 $nblinetoproduce = 0;
1090 foreach ($object->lines as $line) {
1091 if ($line->role ==
'toproduce') {
1096 $newcardbutton =
'';
1097 $url = $_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'&action=addproduceline&token='.
newToken();
1098 $permissiontoaddaproductline = $object->status != $object::STATUS_PRODUCED && $object->status != $object::STATUS_CANCELED;
1099 $parameters = array(
'morecss'=>
'reposition');
1100 if ($action !=
'consumeorproduce' && $action !=
'consumeandproduceall') {
1101 if ($nblinetoproduce == 0 || $object->mrptype == 1) {
1102 $newcardbutton =
dolGetButtonTitle($langs->trans(
'AddNewProduceLines'),
'',
'fa fa-plus-circle size15x', $url,
'', $permissiontoaddaproductline, $parameters);
1106 print
load_fiche_titre($langs->trans(
'Production'), $newcardbutton,
'', 0,
'',
'');
1108 print
'<div class="div-table-responsive-no-min">';
1109 print
'<table id="tablelinestoproduce" class="noborder noshadow nobottom centpercent">';
1111 print
'<tr class="liste_titre">';
1112 print
'<td>'.$langs->trans(
"Product").
'</td>';
1113 print
'<td class="right">'.$langs->trans(
"Qty").
'</td>';
1114 if ($permissiontoupdatecost) {
1115 if (empty($bomcostupdated)) {
1116 print
'<td class="right">'.$form->textwithpicto($langs->trans(
"UnitCost"), $langs->trans(
"AmountUsedToUpdateWAP")).
'</td>';
1118 print
'<td class="right">'.$form->textwithpicto($langs->trans(
"ManufacturingPrice"), $langs->trans(
"AmountUsedToUpdateWAP")).
'</td>';
1121 print
'<td class="right">'.$langs->trans(
"QtyAlreadyProduced").
'</td>';
1123 if ($collapse || in_array($action, array(
'consumeorproduce',
'consumeandproduceall'))) {
1124 print $langs->trans(
"Warehouse");
1129 if ($collapse || in_array($action, array(
'consumeorproduce',
'consumeandproduceall'))) {
1130 print $langs->trans(
"Batch");
1137 if ($action ==
'addproduceline') {
1138 print
'<!-- Add line to produce -->'.
"\n";
1139 print
'<tr class="liste_titre">';
1141 print
$form->select_produits(
'',
'productidtoadd',
'', 0, 0, -1, 2,
'', 1, array(), 0,
'1', 0,
'maxwidth300');
1144 print
'<td class="right"><input type="text" name="qtytoadd" value="1" class="width50 right"></td>';
1149 print
'<td colspan="2">';
1151 print
'<input type="submit" class="button buttongen button-add" name="addproducelinebutton" value="'.$langs->trans(
"Add").
'">';
1152 print
'<input type="submit" class="button buttongen button-cancel" name="canceladdproducelinebutton" value="'.$langs->trans(
"Cancel").
'">';
1159 if ($permissiontodelete) {
1165 if (!empty($object->lines)) {
1166 $nblinetoproduce = 0;
1167 foreach ($object->lines as $line) {
1168 if ($line->role ==
'toproduce') {
1173 $nblinetoproducecursor = 0;
1174 foreach ($object->lines as $line) {
1175 if ($line->role ==
'toproduce') {
1178 $nblinetoproducecursor++;
1180 $tmpproduct =
new Product($db);
1181 $tmpproduct->fetch($line->fk_product);
1183 $arrayoflines = $object->fetchLinesLinked(
'produced', $line->id);
1184 $alreadyproduced = 0;
1185 foreach ($arrayoflines as $line2) {
1186 $alreadyproduced += $line2[
'qty'];
1189 $suffix =
'_'.$line->id;
1190 print
'<!-- Line to dispatch '.$suffix.
' -->'.
"\n";
1192 print
'<input id="qty_ordered'.$suffix.
'" type="hidden" value="'.$line->qty.
'">';
1193 print
'<input id="qty_dispatched'.$suffix.
'" type="hidden" value="'.$alreadyproduced.
'">';
1196 print
'<td>'.$tmpproduct->getNomUrl(1);
1197 print
'<br><span class="opacitymedium small">'.$tmpproduct->label.
'</span>';
1199 print
'<td class="right">'.$line->qty.
'</td>';
1200 if ($permissiontoupdatecost) {
1202 $manufacturingcost = 0;
1203 $manufacturingcostsrc =
'';
1204 if ($object->mrptype == 0) {
1205 $manufacturingcost = $bomcostupdated;
1206 $manufacturingcostsrc = $langs->trans(
"CalculatedFromProductsToConsume");
1207 if (empty($manufacturingcost)) {
1208 $manufacturingcost = $bomcost;
1209 $manufacturingcostsrc = $langs->trans(
"ValueFromBom");
1211 if (empty($manufacturingcost)) {
1212 $manufacturingcost =
price2num($tmpproduct->cost_price,
'MU');
1213 $manufacturingcostsrc = $langs->trans(
"CostPrice");
1215 if (empty($manufacturingcost)) {
1216 $manufacturingcost =
price2num($tmpproduct->pmp,
'MU');
1217 $manufacturingcostsrc = $langs->trans(
"PMPValue");
1221 print
'<td class="right nowraponall" title="'.dol_escape_htmltag($manufacturingcostsrc).
'">';
1222 if ($manufacturingcost) {
1223 print
price($manufacturingcost);
1227 print
'<td class="right nowraponall">';
1228 if ($alreadyproduced) {
1230 print
'jQuery(document).ready(function() {
1231 jQuery("#expandtoproduce'.$line->id.
'").click(function() {
1232 console.log("Expand mrp_production line '.$line->id.
'");
1233 jQuery(".expanddetailtoproduce'.$line->id.
'").toggle();';
1234 if ($nblinetoproduce == $nblinetoproducecursor) {
1235 print
'if (jQuery("#tablelinestoproduce").hasClass("nobottom")) { jQuery("#tablelinestoproduce").removeClass("nobottom"); } else { jQuery("#tablelinestoproduce").addClass("nobottom"); }';
1241 if (empty($conf->use_javascript_ajax)) {
1242 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?collapse='.$collapse.
','.$line->id.
'">';
1244 print
img_picto($langs->trans(
"ShowDetails"),
"chevron-down",
'id="expandtoproduce'.$line->id.
'"');
1245 if (empty($conf->use_javascript_ajax)) {
1249 print
' '.$alreadyproduced;
1257 if ($permissiontodelete && $line->origin_type ==
'free') {
1258 $href = $_SERVER[
"PHP_SELF"];
1259 $href .=
'?id='.$object->id;
1260 $href .=
'&action=deleteline';
1261 $href .=
'&lineid='.$line->id;
1262 print
'<td class="center">';
1263 print
'<a class="reposition" href="'.$href.
'">';
1264 print
img_picto($langs->trans(
'TooltipDeleteAndRevertStockMovement'),
"delete");
1271 foreach ($arrayoflines as $line2) {
1272 print
'<tr class="expanddetailtoproduce'.$line->id.
' hideobject opacitylow">';
1274 $tmpstockmovement->id = $line2[
'fk_stock_movement'];
1275 print
'<a href="'.DOL_URL_ROOT.
'/product/stock/movement_list.php?search_ref='.$tmpstockmovement->id.
'">'.
img_picto($langs->trans(
"StockMovement"),
'movement',
'class="paddingright"').
'</a>';
1281 if ($permissiontoupdatecost) {
1285 print
'<td class="right">'.$line2[
'qty'].
'</td>';
1286 print
'<td class="tdoverflowmax150">';
1287 if ($line2[
'fk_warehouse'] > 0) {
1288 $result = $tmpwarehouse->fetch($line2[
'fk_warehouse']);
1290 print $tmpwarehouse->getNomUrl(1);
1296 if ($line2[
'batch'] !=
'') {
1297 $tmpbatch->fetch(0, $line2[
'fk_product'], $line2[
'batch']);
1298 print $tmpbatch->getNomUrl(1);
1306 if (in_array($action, array(
'consumeorproduce',
'consumeandproduceall'))) {
1307 print
'<!-- Enter line to produce -->'.
"\n";
1308 print
'<tr name="batch_'.$line->id.
'_'.$i.
'">';
1309 print
'<td><span class="opacitymedium">'.$langs->trans(
"ToProduce").
'</span></td>';
1310 $preselected = (
GETPOSTISSET(
'qtytoproduce-'.$line->id.
'-'.$i) ?
GETPOST(
'qtytoproduce-'.$line->id.
'-'.$i) : max(0, $line->qty - $alreadyproduced));
1311 if ($action ==
'consumeorproduce' && !
GETPOSTISSET(
'qtytoproduce-'.$line->id.
'-'.$i)) {
1314 print
'<td class="right"><input type="text" class="width50 right" id="qtytoproduce-'.$line->id.
'-'.$i.
'" name="qtytoproduce-'.$line->id.
'-'.$i.
'" value="'.$preselected.
'"></td>';
1315 if ($permissiontoupdatecost) {
1317 $manufacturingcost = 0;
1318 $manufacturingcostsrc =
'';
1319 if ($object->mrptype == 0) {
1320 $manufacturingcost = $bomcostupdated;
1321 $manufacturingcostsrc = $langs->trans(
"CalculatedFromProductsToConsume");
1322 if (empty($manufacturingcost)) {
1323 $manufacturingcost = $bomcost;
1324 $manufacturingcostsrc = $langs->trans(
"ValueFromBom");
1326 if (empty($manufacturingcost)) {
1327 $manufacturingcost =
price2num($tmpproduct->cost_price,
'MU');
1328 $manufacturingcostsrc = $langs->trans(
"CostPrice");
1330 if (empty($manufacturingcost)) {
1331 $manufacturingcost =
price2num($tmpproduct->pmp,
'MU');
1332 $manufacturingcostsrc = $langs->trans(
"PMPValue");
1337 $preselected = (
GETPOSTISSET(
'pricetoproduce-'.$line->id.
'-'.$i) ?
GETPOST(
'pricetoproduce-'.$line->id.
'-'.$i) : ($manufacturingcost ?
price($manufacturingcost) :
''));
1338 print
'<td class="right"><input type="text" class="width75 right" name="pricetoproduce-'.$line->id.
'-'.$i.
'" value="'.$preselected.
'"></td>';
1340 print
'<td><input type="hidden" class="width50 right" name="pricetoproduce-'.$line->id.
'-'.$i.
'" value="'.($manufacturingcost ? $manufacturingcost :
'').
'"></td>';
1346 $preselected = (
GETPOSTISSET(
'idwarehousetoproduce-'.$line->id.
'-'.$i) ?
GETPOST(
'idwarehousetoproduce-'.$line->id.
'-'.$i) : ($object->fk_warehouse > 0 ? $object->fk_warehouse :
'ifone'));
1347 print $formproduct->selectWarehouses($preselected,
'idwarehousetoproduce-'.$line->id.
'-'.$i,
'', 1, 0, $line->fk_product,
'', 1, 0,
null,
'maxwidth200 csswarehouse_'.$line->id.
'_'.$i);
1349 print
'<span class="opacitymedium">'.$langs->trans(
"NoStockChangeOnServices").
'</span>';
1354 if ($tmpproduct->status_batch) {
1355 $preselected = (
GETPOSTISSET(
'batchtoproduce-'.$line->id.
'-'.$i) ?
GETPOST(
'batchtoproduce-'.$line->id.
'-'.$i) :
'');
1356 print
'<input type="text" class="width50" name="batchtoproduce-'.$line->id.
'-'.$i.
'" value="'.$preselected.
'">';
1361 if ($tmpproduct->status_batch) {
1363 print
img_picto($langs->trans(
'AddStockLocationLine'),
'split.png',
'class="splitbutton" onClick="addDispatchLine('.$line->id.
', \''.$type.
'\', \
'qtymissing\')"');
1380 if (in_array($action, array(
'consumeorproduce',
'consumeandproduceall',
'addconsumeline'))) {