26 require
'../main.inc.php';
28 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formcompany.class.php';
29 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
30 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formprojet.class.php';
31 require_once DOL_DOCUMENT_ROOT.
'/projet/class/project.class.php';
32 require_once DOL_DOCUMENT_ROOT.
'/product/class/product.class.php';
33 require_once DOL_DOCUMENT_ROOT.
'/product/class/html.formproduct.class.php';
34 require_once DOL_DOCUMENT_ROOT.
'/product/stock/class/entrepot.class.php';
35 require_once DOL_DOCUMENT_ROOT.
'/product/stock/class/productlot.class.php';
36 require_once DOL_DOCUMENT_ROOT.
'/product/stock/class/mouvementstock.class.php';
42 $langs->loadLangs(array(
"mrp",
"stocks",
"other",
"product",
"productbatch"));
47 $action =
GETPOST(
'action',
'aZ09');
48 $confirm =
GETPOST(
'confirm',
'alpha');
49 $cancel =
GETPOST(
'cancel',
'aZ09');
50 $contextpage =
GETPOST(
'contextpage',
'aZ') ?
GETPOST(
'contextpage',
'aZ') :
'mocard';
51 $backtopage =
GETPOST(
'backtopage',
'alpha');
52 $lineid =
GETPOST(
'lineid',
'int');
53 $fk_movement =
GETPOST(
'fk_movement',
'int');
54 $fk_default_warehouse =
GETPOST(
'fk_default_warehouse',
'int');
56 $collapse =
GETPOST(
'collapse',
'aZ09comma');
59 $object =
new Mo($db);
61 $diroutputmassaction = $conf->mrp->dir_output.
'/temp/massgeneration/'.$user->id;
62 $hookmanager->initHooks(array(
'mocard',
'globalcard'));
65 $extrafields->fetch_name_optionals_label($object->table_element);
67 $search_array_options = $extrafields->getOptionalsFromPost($object->table_element,
'',
'search_');
70 $search_all =
GETPOST(
"search_all",
'alpha');
72 foreach ($object->fields as $key => $val) {
73 if (
GETPOST(
'search_'.$key,
'alpha')) {
74 $search[$key] =
GETPOST(
'search_'.$key,
'alpha');
78 if (empty($action) && empty($id) && empty($ref)) {
83 include DOL_DOCUMENT_ROOT.
'/core/actions_fetchobject.inc.php';
88 $isdraft = (($object->status == $object::STATUS_DRAFT) ? 1 : 0);
89 $result =
restrictedArea($user,
'mrp', $object->id,
'mrp_mo',
'',
'fk_soc',
'rowid', $isdraft);
91 $permissionnote = $user->rights->mrp->write;
92 $permissiondellink = $user->rights->mrp->write;
93 $permissiontoadd = $user->rights->mrp->write;
94 $permissiontodelete = $user->rights->mrp->delete || ($permissiontoadd && isset($object->status) && $object->status == $object::STATUS_DRAFT);
95 $upload_dir = $conf->mrp->multidir_output[isset($object->entity) ? $object->entity : 1];
97 $permissiontoproduce = $permissiontoadd;
98 $permissiontoupdatecost = $user->rights->bom->read;
105 $parameters = array();
106 $reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
111 if (empty($reshook)) {
116 if (empty($backtopage) || ($cancel && empty($id))) {
118 if (empty($id) && (($action !=
'add' && $action !=
'create') || $cancel)) {
119 $backtopage = $backurlforlist;
121 $backtopage = DOL_URL_ROOT.
'/mrp/mo_production.php?id='.($id > 0 ? $id :
'__ID__');
124 $triggermodname =
'MO_MODIFY';
127 include DOL_DOCUMENT_ROOT.
'/core/actions_addupdatedelete.inc.php';
130 include DOL_DOCUMENT_ROOT.
'/core/actions_dellink.inc.php';
133 include DOL_DOCUMENT_ROOT.
'/core/actions_printing.inc.php';
136 $triggersendname =
'MO_SENTBYMAIL';
137 $autocopy =
'MAIN_MAIL_AUTOCOPY_MO_TO';
138 $trackid =
'mo'.$object->id;
139 include DOL_DOCUMENT_ROOT.
'/core/actions_sendmails.inc.php';
144 if ($action ==
'set_thirdparty' && $permissiontoadd) {
145 $object->setValueFrom(
'fk_soc',
GETPOST(
'fk_soc',
'int'),
'',
'',
'date',
'', $user, $triggermodname);
147 if ($action ==
'classin' && $permissiontoadd) {
148 $object->setProject(
GETPOST(
'projectid',
'int'));
151 if ($action ==
'confirm_reopen' && $permissiontoadd) {
152 $result = $object->setStatut($object::STATUS_INPROGRESS, 0,
'',
'MRP_REOPEN');
155 if (($action ==
'confirm_addconsumeline' &&
GETPOST(
'addconsumelinebutton') && $permissiontoadd)
156 || ($action ==
'confirm_addproduceline' &&
GETPOST(
'addproducelinebutton') && $permissiontoadd)) {
157 $moline =
new MoLine($db);
160 $moline->fk_mo = $object->id;
161 $moline->qty =
GETPOST(
'qtytoadd',
'int'); ;
162 $moline->fk_product =
GETPOST(
'productidtoadd',
'int');
163 if (
GETPOST(
'addconsumelinebutton')) {
164 $moline->role =
'toconsume';
166 $moline->role =
'toproduce';
168 $moline->origin_type =
'free';
169 $moline->position = 0;
172 $tmpproduct =
new Product($db);
173 $tmpproduct->fetch($moline->fk_product);
176 $resultline = $moline->create($user,
false);
177 if ($resultline <= 0) {
184 header(
"Location: ".$_SERVER[
"PHP_SELF"].
'?id='.$object->id);
187 if (in_array($action, array(
'confirm_consumeorproduce',
'confirm_consumeandproduceall')) && $permissiontoproduce) {
190 $labelmovement =
GETPOST(
'inventorylabel',
'alphanohtml');
191 $codemovement =
GETPOST(
'inventorycode',
'alphanohtml');
196 foreach ($object->lines as $line) {
197 if ($line->role ==
'toconsume') {
198 $tmpproduct =
new Product($db);
199 $tmpproduct->fetch($line->fk_product);
205 if ($qtytoprocess != 0) {
208 if (!(
GETPOST(
'idwarehouse-'.$line->id.
'-'.$i) > 0)) {
209 $langs->load(
"errors");
210 setEventMessages($langs->trans(
"ErrorFieldRequiredForProduct", $langs->transnoentitiesnoconv(
"Warehouse"), $tmpproduct->ref),
null,
'errors');
213 if ($tmpproduct->status_batch && (!
GETPOST(
'batch-'.$line->id.
'-'.$i))) {
214 $langs->load(
"errors");
215 setEventMessages($langs->trans(
"ErrorFieldRequiredForProduct", $langs->transnoentitiesnoconv(
"Batch"), $tmpproduct->ref),
null,
'errors');
221 if (!$error &&
GETPOST(
'idwarehouse-'.$line->id.
'-'.$i) > 0) {
223 $id_product_batch = 0;
224 $stockmove->setOrigin($object->element, $object->id);
226 if ($qtytoprocess >= 0) {
227 $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);
229 $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);
231 if ($idstockmove < 0) {
239 $moline =
new MoLine($db);
240 $moline->fk_mo = $object->id;
241 $moline->position = $pos;
242 $moline->fk_product = $line->fk_product;
243 $moline->fk_warehouse =
GETPOST(
'idwarehouse-'.$line->id.
'-'.$i);
244 $moline->qty = $qtytoprocess;
245 $moline->batch =
GETPOST(
'batch-'.$line->id.
'-'.$i);
246 $moline->role =
'consumed';
247 $moline->fk_mrp_production = $line->id;
248 $moline->fk_stock_movement = $idstockmove == 0 ? null : $idstockmove;
249 $moline->fk_user_creat = $user->id;
251 $resultmoline = $moline->create($user);
252 if ($resultmoline <= 0) {
269 foreach ($object->lines as $line) {
270 if ($line->role ==
'toproduce') {
271 $tmpproduct =
new Product($db);
272 $tmpproduct->fetch($line->fk_product);
275 while (
GETPOSTISSET(
'qtytoproduce-'.$line->id.
'-'.$i)) {
277 $pricetoprocess =
GETPOST(
'pricetoproduce-'.$line->id.
'-'.$i) ?
price2num(
GETPOST(
'pricetoproduce-'.$line->id.
'-'.$i)) : 0;
279 if ($qtytoprocess != 0) {
281 if (
GETPOSTISSET(
'idwarehousetoproduce-'.$line->id.
'-'.$i)) {
282 if (!(
GETPOST(
'idwarehousetoproduce-'.$line->id.
'-'.$i) > 0)) {
283 $langs->load(
"errors");
284 setEventMessages($langs->trans(
"ErrorFieldRequiredForProduct", $langs->transnoentitiesnoconv(
"Warehouse"), $tmpproduct->ref),
null,
'errors');
287 if (
isModEnabled(
'productbatch') && $tmpproduct->status_batch && (!
GETPOST(
'batchtoproduce-'.$line->id.
'-'.$i))) {
288 $langs->load(
"errors");
289 setEventMessages($langs->trans(
"ErrorFieldRequiredForProduct", $langs->transnoentitiesnoconv(
"Batch"), $tmpproduct->ref),
null,
'errors');
295 if (!$error &&
GETPOST(
'idwarehousetoproduce-'.$line->id.
'-'.$i) > 0) {
297 $id_product_batch = 0;
298 $stockmove->origin_type = $object->element;
299 $stockmove->origin_id = $object->id;
301 $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);
302 if ($idstockmove < 0) {
310 $moline =
new MoLine($db);
311 $moline->fk_mo = $object->id;
312 $moline->position = $pos;
313 $moline->fk_product = $line->fk_product;
314 $moline->fk_warehouse =
GETPOST(
'idwarehousetoproduce-'.$line->id.
'-'.$i);
315 $moline->qty = $qtytoprocess;
316 $moline->batch =
GETPOST(
'batchtoproduce-'.$line->id.
'-'.$i);
317 $moline->role =
'produced';
318 $moline->fk_mrp_production = $line->id;
319 $moline->fk_stock_movement = $idstockmove;
320 $moline->fk_user_creat = $user->id;
322 $resultmoline = $moline->create($user);
323 if ($resultmoline <= 0) {
338 $consumptioncomplete =
true;
339 $productioncomplete =
true;
341 if (
GETPOST(
'autoclose',
'int')) {
342 foreach ($object->lines as $line) {
343 if ($line->role ==
'toconsume') {
344 $arrayoflines = $object->fetchLinesLinked(
'consumed', $line->id);
345 $alreadyconsumed = 0;
346 foreach ($arrayoflines as $line2) {
347 $alreadyconsumed += $line2[
'qty'];
350 if ($alreadyconsumed < $line->qty) {
351 $consumptioncomplete =
false;
354 if ($line->role ==
'toproduce') {
355 $arrayoflines = $object->fetchLinesLinked(
'produced', $line->id);
356 $alreadyproduced = 0;
357 foreach ($arrayoflines as $line2) {
358 $alreadyproduced += $line2[
'qty'];
361 if ($alreadyproduced < $line->qty) {
362 $productioncomplete =
false;
367 $consumptioncomplete =
false;
368 $productioncomplete =
false;
372 dol_syslog(
"consumptioncomplete = ".$consumptioncomplete.
" productioncomplete = ".$productioncomplete);
374 if ($consumptioncomplete && $productioncomplete) {
375 $result = $object->setStatut($object::STATUS_PRODUCED, 0,
'',
'MRP_MO_PRODUCED');
377 $result = $object->setStatut($object::STATUS_INPROGRESS, 0,
'',
'MRP_MO_PRODUCED');
386 $action = str_replace(
'confirm_',
'', $action);
392 header(
"Location: ".$_SERVER[
"PHP_SELF"].
'?id='.$object->id);
398 if ($action ==
'confirm_produced' && $confirm ==
'yes' && $permissiontoadd) {
399 $result = $object->setStatut($object::STATUS_PRODUCED, 0,
'',
'MRP_MO_PRODUCED');
402 if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) {
403 $outputlangs = $langs;
406 $newlang =
GETPOST(
'lang_id',
'aZ09');
409 $newlang = $object->thirdparty->default_lang;
411 if (!empty($newlang)) {
413 $outputlangs->setDefaultLang($newlang);
415 $model = $object->model_pdf;
416 $ret = $object->fetch($id);
418 $object->generateDocument($model, $outputlangs, 0, 0, 0);
439 $help_url =
'EN:Module_Manufacturing_Orders|FR:Module_Ordres_de_Fabrication';
440 llxHeader(
'', $langs->trans(
'Mo'),
$help_url,
'', 0, 0, array(
'/mrp/js/lib_dispatch.js.php'));
445 if ($object->id > 0 && (empty($action) || ($action !=
'edit' && $action !=
'create'))) {
446 $res = $object->fetch_thirdparty();
447 $res = $object->fetch_optionals();
451 print
dol_get_fiche_head($head,
'production', $langs->trans(
"ManufacturingOrder"), -1, $object->picto);
456 if ($action ==
'delete') {
457 $formconfirm =
$form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.$object->id, $langs->trans(
'DeleteMo'), $langs->trans(
'ConfirmDeleteMo'),
'confirm_delete',
'', 0, 1);
460 if ($action ==
'deleteline') {
461 $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);
464 if ($action ==
'clone') {
466 $formquestion = array();
467 $formconfirm =
$form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.$object->id, $langs->trans(
'ToClone'), $langs->trans(
'ConfirmCloneMo', $object->ref),
'confirm_clone', $formquestion,
'yes', 1);
471 if ($action ==
'validate') {
473 $ref = substr($object->ref, 1, 4);
474 if ($ref ==
'PROV') {
475 $object->fetch_product();
476 $numref = $object->getNextNumRef($object->fk_product);
478 $numref = $object->ref;
481 $text = $langs->trans(
'ConfirmValidateMo', $numref);
490 $formquestion = array();
493 require_once DOL_DOCUMENT_ROOT.
'/product/class/html.formproduct.class.php';
496 if ($conf->browser->name ==
'ie') {
499 $formquestion = array(
506 $formconfirm =
$form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.$object->id, $langs->trans(
'Validate'), $text,
'confirm_validate', $formquestion, 0, 1, 220);
510 $parameters = array(
'formConfirm' =>
$formconfirm,
'lineid' => $lineid);
511 $reshook = $hookmanager->executeHooks(
'formConfirm', $parameters, $object, $action);
512 if (empty($reshook)) {
514 } elseif ($reshook > 0) {
524 $linkback =
'<a href="'.DOL_URL_ROOT.
'/mrp/mo_list.php?restore_lastsearch_values=1'.(!empty($socid) ?
'&socid='.$socid :
'').
'">'.$langs->trans(
"BackToList").
'</a>';
526 $morehtmlref =
'<div class="refidno">';
532 if (is_object($object->thirdparty)) {
533 $morehtmlref .= $object->thirdparty->getNomUrl(1,
'customer');
534 if (empty($conf->global->MAIN_DISABLE_OTHER_LINK) && $object->thirdparty->id > 0) {
535 $morehtmlref .=
' (<a href="'.DOL_URL_ROOT.
'/commande/list.php?socid='.$object->thirdparty->id.
'&search_societe='.urlencode($object->thirdparty->name).
'">'.$langs->trans(
"OtherOrders").
'</a>)';
540 $langs->load(
"projects");
541 if (is_object($object->thirdparty)) {
542 $morehtmlref .=
'<br>';
544 if ($permissiontoadd) {
545 $morehtmlref .=
img_picto($langs->trans(
"Project"),
'project',
'class="pictofixedwidth"');
546 if ($action !=
'classify') {
547 $morehtmlref .=
'<a class="editfielda" href="'.$_SERVER[
'PHP_SELF'].
'?action=classify&token='.
newToken().
'&id='.$object->id.
'">'.
img_edit($langs->transnoentitiesnoconv(
'SetProject')).
'</a> ';
549 $morehtmlref .=
$form->form_project($_SERVER[
'PHP_SELF'].
'?id='.$object->id, $object->socid, $object->fk_project, ($action ==
'classify' ?
'projectid' :
'none'), 0, 0, 0, 1,
'',
'maxwidth300');
551 if (!empty($object->fk_project)) {
553 $proj->fetch($object->fk_project);
554 $morehtmlref .= $proj->getNomUrl(1);
556 $morehtmlref .=
'<span class="opacitymedium"> - '.dol_escape_htmltag($proj->title).
'</span>';
561 $morehtmlref .=
'</div>';
564 dol_banner_tab($object,
'ref', $linkback, 1,
'ref',
'ref', $morehtmlref);
567 print
'<div class="fichecenter">';
568 print
'<div class="fichehalfleft">';
569 print
'<div class="underbanner clearboth"></div>';
570 print
'<table class="border centpercent tableforfield">'.
"\n";
573 $keyforbreak =
'fk_warehouse';
574 unset($object->fields[
'fk_project']);
575 unset($object->fields[
'fk_soc']);
576 include DOL_DOCUMENT_ROOT.
'/core/tpl/commonfields_view.tpl.php';
579 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_view.tpl.php';
585 print
'<div class="clearboth"></div>';
590 if (!in_array($action, array(
'consumeorproduce',
'consumeandproduceall'))) {
591 print
'<div class="tabsAction">';
593 $parameters = array();
595 $reshook = $hookmanager->executeHooks(
'addMoreActionsButtons', $parameters, $object, $action);
596 if (empty($reshook)) {
598 if ($object->status == $object::STATUS_DRAFT) {
599 if ($permissiontoadd) {
600 if (empty($object->table_element_line) || (is_array($object->lines) && count($object->lines) > 0)) {
601 print
'<a class="butAction" href="'.$_SERVER[
'PHP_SELF'].
'?id='.$object->id.
'&action=validate&token='.$newToken.
'">'.$langs->trans(
"Validate").
'</a>';
603 $langs->load(
"errors");
604 print
'<a class="butActionRefused" href="" title="'.$langs->trans(
"ErrorAddAtLeastOneLineFirst").
'">'.$langs->trans(
"Validate").
'</a>';
610 if ($object->status == Mo::STATUS_VALIDATED || $object->status == Mo::STATUS_INPROGRESS) {
611 if ($permissiontoproduce) {
612 print
'<a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'&action=consumeorproduce&token='.$newToken.
'">'.$langs->trans(
'ConsumeOrProduce').
'</a>';
614 print
'<a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans(
"NotEnoughPermissions").
'">'.$langs->trans(
'ConsumeOrProduce').
'</a>';
616 } elseif ($object->status == Mo::STATUS_DRAFT) {
617 print
'<a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans(
"ValidateBefore").
'">'.$langs->trans(
'ConsumeOrProduce').
'</a>';
621 if ($object->status == Mo::STATUS_VALIDATED || $object->status == Mo::STATUS_INPROGRESS) {
622 if ($permissiontoproduce) {
623 print
'<a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'&action=consumeandproduceall&token='.$newToken.
'">'.$langs->trans(
'ConsumeAndProduceAll').
'</a>';
625 print
'<a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans(
"NotEnoughPermissions").
'">'.$langs->trans(
'ConsumeAndProduceAll').
'</a>';
627 } elseif ($object->status == Mo::STATUS_DRAFT) {
628 print
'<a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans(
"ValidateBefore").
'">'.$langs->trans(
'ConsumeAndProduceAll').
'</a>';
632 if ($permissiontoadd) {
633 if ($object->status == $object::STATUS_VALIDATED || $object->status == $object::STATUS_INPROGRESS) {
634 $arrayproduced = $object->fetchLinesLinked(
'produced', 0);
636 foreach ($arrayproduced as $lineproduced) {
637 $nbProduced += $lineproduced[
'qty'];
639 if ($nbProduced > 0) {
640 print
'<a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'&action=confirm_produced&confirm=yes&token='.$newToken.
'">'.$langs->trans(
"Close").
'</a>'.
"\n";
642 print
'<a class="butActionRefused" href="#" title="'.$langs->trans(
"GoOnTabProductionToProduceFirst", $langs->transnoentitiesnoconv(
"Production")).
'">'.$langs->trans(
"Close").
'</a>'.
"\n";
645 print
'<a class="butActionDelete" href="'.$_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'&action=confirm_close&confirm=yes&token='.$newToken.
'">'.$langs->trans(
"Cancel").
'</a>'.
"\n";
648 if ($object->status == $object::STATUS_CANCELED) {
649 print
'<a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'&action=confirm_reopen&confirm=yes&token='.$newToken.
'">'.$langs->trans(
"Re-Open").
'</a>'.
"\n";
652 if ($object->status == $object::STATUS_PRODUCED) {
653 if ($permissiontoproduce) {
654 print
'<a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'&action=confirm_reopen&token='.$newToken.
'">'.$langs->trans(
'ReOpen').
'</a>';
656 print
'<a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans(
"NotEnoughPermissions").
'">'.$langs->trans(
'ReOpen').
'</a>';
665 if (in_array($action, array(
'consumeorproduce',
'consumeandproduceall',
'addconsumeline',
'addproduceline'))) {
666 print
'<form method="POST" action="'.$_SERVER[
"PHP_SELF"].
'">';
667 print
'<input type="hidden" name="token" value="'.newToken().
'">';
668 print
'<input type="hidden" name="action" value="confirm_'.$action.
'">';
669 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
670 print
'<input type="hidden" name="id" value="'.$id.
'">';
673 if (in_array($action, array(
'consumeorproduce',
'consumeandproduceall'))) {
674 $defaultstockmovementlabel =
GETPOST(
'inventorylabel',
'alphanohtml') ?
GETPOST(
'inventorylabel',
'alphanohtml') : $langs->trans(
"ProductionForRef", $object->
ref);
677 print
'<div class="center'.(in_array($action, array(
'consumeorproduce',
'consumeandproduceall')) ?
' formconsumeproduce' :
'').
'">';
678 print
'<div class="opacitymedium hideonsmartphone paddingbottom">'.$langs->trans(
"ConfirmProductionDesc", $langs->transnoentitiesnoconv(
"Confirm")).
'<br></div>';
679 print
'<span class="fieldrequired">'.$langs->trans(
"InventoryCode").
':</span> <input type="text" class="minwidth200 maxwidth250" name="inventorycode" value="'.$defaultstockmovementcode.
'"> ';
680 print
'<span class="clearbothonsmartphone"></span>';
681 print $langs->trans(
"MovementLabel").
': <input type="text" class="minwidth300" name="inventorylabel" value="'.$defaultstockmovementlabel.
'"><br><br>';
682 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>';
683 print
'<input type="submit" class="button" value="'.$langs->trans(
"Confirm").
'" name="confirm">';
685 print
'<input class="button button-cancel" type="submit" value="'.$langs->trans(
"Cancel").
'" name="cancel">';
699 if (!empty($object->table_element_line)) {
701 $object->fetchLines();
704 if ($object->fk_bom > 0) {
706 $res = $bom->fetch($object->fk_bom);
708 $bom->calculateCosts();
709 $bomcost = $bom->unit_cost;
715 print
'<div class="fichecenter">';
716 print
'<div class="fichehalfleft">';
717 print
'<div class="clearboth"></div>';
719 $url = $_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'&action=addconsumeline&token='.
newToken();
720 $permissiontoaddaconsumeline = $object->status != $object::STATUS_PRODUCED && $object->status != $object::STATUS_CANCELED;
721 $parameters = array(
'morecss'=>
'reposition');
724 if ($action !=
'consumeorproduce' && $action !=
'consumeandproduceall') {
725 $newcardbutton =
dolGetButtonTitle($langs->trans(
'AddNewConsumeLines'),
'',
'fa fa-plus-circle size15x', $url,
'', $permissiontoaddaconsumeline, $parameters);
728 print
load_fiche_titre($langs->trans(
'Consumption'), $newcardbutton,
'', 0,
'',
'',
'');
730 print
'<div class="div-table-responsive-no-min">';
731 print
'<table class="noborder noshadow centpercent nobottom">';
733 print
'<tr class="liste_titre">';
734 print
'<td>'.$langs->trans(
"Product").
'</td>';
736 print
'<td class="right">'.$langs->trans(
"Qty").
'</td>';
738 if ($permissiontoupdatecost && !empty($conf->global->MRP_SHOW_COST_FOR_CONSUMPTION)) {
739 print
'<td class="right">'.$langs->trans(
"UnitCost").
'</td>';
742 print
'<td class="right">'.$langs->trans(
"QtyAlreadyConsumed").
'</td>';
745 if ($collapse || in_array($action, array(
'consumeorproduce',
'consumeandproduceall'))) {
746 print $langs->trans(
"Warehouse");
749 if (in_array($action, array(
'consumeorproduce',
'consumeandproduceall'))) {
750 $listwarehouses = $tmpwarehouse->list_array(1);
751 if (count($listwarehouses) > 1) {
752 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);
753 } elseif (count($listwarehouses) == 1) {
754 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);
761 print
'<td align="right">';
762 if ($collapse || in_array($action, array(
'consumeorproduce',
'consumeandproduceall'))) {
763 print $langs->trans(
"Stock");
770 if ($collapse || in_array($action, array(
'consumeorproduce',
'consumeandproduceall'))) {
771 print $langs->trans(
"Batch");
776 if ($permissiontodelete) {
788 if ($action ==
'addconsumeline') {
789 print
'<!-- Add line to consume -->'.
"\n";
790 print
'<tr class="liste_titre">';
792 print
$form->select_produits(
'',
'productidtoadd',
'', 0, 0, -1, 2,
'', 1, array(), 0,
'1', 0,
'maxwidth300');
795 print
'<td class="right"><input type="text" name="qtytoadd" value="1" class="width50 right"></td>';
797 if ($permissiontoupdatecost && !empty($conf->global->MRP_SHOW_COST_FOR_CONSUMPTION)) {
801 print
'<td colspan="2">';
803 print
'<input type="submit" class="button buttongen button-add" name="addconsumelinebutton" value="'.$langs->trans(
"Add").
'">';
804 print
'<input type="submit" class="button buttongen button-cancel" name="canceladdconsumelinebutton" value="'.$langs->trans(
"Cancel").
'">';
814 if ($permissiontodelete) {
828 if (!empty($object->lines)) {
829 $nblinetoconsume = 0;
830 foreach ($object->lines as $line) {
831 if ($line->role ==
'toconsume') {
836 $nblinetoconsumecursor = 0;
837 foreach ($object->lines as $line) {
838 if ($line->role ==
'toconsume') {
839 $nblinetoconsumecursor++;
841 $tmpproduct =
new Product($db);
842 $tmpproduct->fetch($line->fk_product);
843 $linecost =
price2num($tmpproduct->pmp,
'MT');
845 if ($object->qty > 0) {
847 $costprice =
price2num((!empty($tmpproduct->cost_price)) ? $tmpproduct->cost_price : $tmpproduct->pmp);
848 if (empty($costprice)) {
849 require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.product.class.php';
851 if ($productFournisseur->find_min_price_product_fournisseur($line->fk_product) > 0) {
852 $costprice = $productFournisseur->fourn_unitprice;
857 $linecost =
price2num(($line->qty * $costprice) / $object->qty,
'MT');
858 $bomcostupdated +=
price2num(($line->qty * $costprice) / $object->qty,
'MU');
861 $bomcostupdated =
price2num($bomcostupdated,
'MU');
862 $arrayoflines = $object->fetchLinesLinked(
'consumed', $line->id);
863 $alreadyconsumed = 0;
864 foreach ($arrayoflines as $line2) {
865 $alreadyconsumed += $line2[
'qty'];
868 $suffix =
'_'.$line->id;
869 print
'<!-- Line to dispatch '.$suffix.
' -->'.
"\n";
871 print
'<input id="qty_ordered'.$suffix.
'" type="hidden" value="'.$line->qty.
'">';
872 print
'<input id="qty_dispatched'.$suffix.
'" type="hidden" value="'.$alreadyconsumed.
'">';
874 print
'<tr data-line-id="'.$line->id.
'">';
876 print
'<td>'.$tmpproduct->getNomUrl(1);
877 print
'<br><span class="opacitymedium small">'.$tmpproduct->label.
'</span>';
880 print
'<td class="right nowraponall">';
881 $help =
''; $picto =
'help';
882 if ($line->qty_frozen) {
883 $help = ($help ?
'<br>' :
'').
'<strong>'.$langs->trans(
"QuantityFrozen").
'</strong>: '.
yn(1).
' ('.$langs->trans(
"QuantityConsumedInvariable").
')';
884 print
$form->textwithpicto(
'', $help, -1,
'lock').
' ';
886 if ($line->disable_stock_change) {
887 $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")).
')';
888 print
$form->textwithpicto(
'', $help, -1,
'help').
' ';
893 if ($permissiontoupdatecost && !empty($conf->global->MRP_SHOW_COST_FOR_CONSUMPTION)) {
894 print
'<td class="right nowraponall">';
895 print
price($linecost);
899 print
'<td class="right">';
900 if ($alreadyconsumed) {
902 print
'jQuery(document).ready(function() {
903 jQuery("#expandtoproduce'.$line->id.
'").click(function() {
904 console.log("Expand mrp_production line '.$line->id.
'");
905 jQuery(".expanddetail'.$line->id.
'").toggle();';
906 if ($nblinetoconsume == $nblinetoconsumecursor) {
907 print
'if (jQuery("#tablelines").hasClass("nobottom")) { jQuery("#tablelines").removeClass("nobottom"); } else { jQuery("#tablelines").addClass("nobottom"); }';
913 if (empty($conf->use_javascript_ajax)) {
914 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?collapse='.$collapse.
','.$line->id.
'">';
916 print
img_picto($langs->trans(
"ShowDetails"),
"chevron-down",
'id="expandtoproduce'.$line->id.
'"');
917 if (empty($conf->use_javascript_ajax)) {
921 if ($nblinetoconsume == $nblinetoconsumecursor) {
922 print
'<script>jQuery("#tablelines").removeClass("nobottom");</script>';
925 print
' '.price2num($alreadyconsumed,
'MS');
932 print
'<td class="nowraponall right">';
933 if (empty($conf->global->STOCK_SUPPORTS_SERVICES) && $tmpproduct->type != PRODUCT::TYPE_SERVICE) {
934 if (!$line->disable_stock_change && $tmpproduct->stock_reel < ($line->qty - $alreadyconsumed)) {
935 print
img_warning($langs->trans(
'StockTooLow')) .
' ';
937 print
price2num($tmpproduct->stock_reel,
'MS');
953 if ($permissiontodelete) {
954 $href = $_SERVER[
"PHP_SELF"].
'?id='.((int) $object->id).
'&action=deleteline&token='.
newToken().
'&lineid='.((int) $line->id);
955 print
'<td class="center">';
956 print
'<a class="reposition" href="'.$href.
'">';
957 print
img_picto($langs->trans(
'TooltipDeleteAndRevertStockMovement'),
'delete');
965 foreach ($arrayoflines as $line2) {
966 print
'<tr class="expanddetail'.$line->id.
' hideobject opacitylow">';
970 $tmpstockmovement->id = $line2[
'fk_stock_movement'];
971 print
'<a href="'.DOL_URL_ROOT.
'/product/stock/movement_list.php?search_ref='.$tmpstockmovement->id.
'">'.
img_picto($langs->trans(
"StockMovement"),
'movement',
'class="paddingright"').
'</a>';
979 print
'<td class="right">'.$line2[
'qty'].
'</td>';
982 if ($permissiontoupdatecost && !empty($conf->global->MRP_SHOW_COST_FOR_CONSUMPTION)) {
987 print
'<td class="tdoverflowmax150">';
988 if ($line2[
'fk_warehouse'] > 0) {
989 $result = $tmpwarehouse->fetch($line2[
'fk_warehouse']);
991 print $tmpwarehouse->getNomUrl(1);
1004 if ($line2[
'batch'] !=
'') {
1005 $tmpbatch->fetch(0, $line2[
'fk_product'], $line2[
'batch']);
1006 print $tmpbatch->getNomUrl(1);
1018 if ($permissiontodelete) {
1019 $href = $_SERVER[
"PHP_SELF"].
'?id='.((int) $object->id).
'&action=deleteline&token='.
newToken().
'&lineid='.((int) $line2[
'rowid']).
'&fk_movement='.((int) $line2[
'fk_stock_movement']);
1020 print
'<td class="center">';
1021 print
'<a class="reposition" href="'.$href.
'">';
1022 print
img_picto($langs->trans(
'TooltipDeleteAndRevertStockMovement'),
'delete');
1030 if (in_array($action, array(
'consumeorproduce',
'consumeandproduceall'))) {
1032 print
'<!-- Enter line to consume -->'.
"\n";
1034 print
'<tr data-max-qty="'.$maxQty.
'" name="batch_'.$line->id.
'_'.$i.
'">';
1036 print
'<td><span class="opacitymedium">'.$langs->trans(
"ToConsume").
'</span></td>';
1037 $preselected = (
GETPOSTISSET(
'qty-'.$line->id.
'-'.$i) ?
GETPOST(
'qty-'.$line->id.
'-'.$i) : max(0, $line->qty - $alreadyconsumed));
1038 if ($action ==
'consumeorproduce' && !
GETPOSTISSET(
'qty-'.$line->id.
'-'.$i)) {
1043 if (!empty($conf->global->MRP_NEVER_CONSUME_MORE_THAN_EXPECTED) && ($line->qty - $alreadyconsumed) <= 0) {
1044 $disable =
'disabled';
1048 print
'<input type="hidden" name="product-'.$line->id.
'-'.$i.
'" value="'.$line->fk_product.
'">';
1051 print
'<td class="right"><input type="text" class="width50 right" id="qtytoconsume-'.$line->id.
'-'.$i.
'" name="qty-'.$line->id.
'-'.$i.
'" value="'.$preselected.
'" '.$disable.
'></td>';
1054 if ($permissiontoupdatecost && !empty($conf->global->MRP_SHOW_COST_FOR_CONSUMPTION)) {
1064 if (empty($line->disable_stock_change)) {
1065 $preselected = (
GETPOSTISSET(
'idwarehouse-'.$line->id.
'-'.$i) ?
GETPOST(
'idwarehouse-'.$line->id.
'-'.$i) : ($tmpproduct->fk_default_warehouse > 0 ? $tmpproduct->fk_default_warehouse :
'ifone'));
1066 print $formproduct->selectWarehouses($preselected,
'idwarehouse-'.$line->id.
'-'.$i,
'', 1, 0, $line->fk_product,
'', 1, 0,
null,
'maxwidth200 csswarehouse_'.$line->id.
'_'.$i);
1068 print
'<span class="opacitymedium">'.$langs->trans(
"DisableStockChange").
'</span>';
1071 print
'<span class="opacitymedium">'.$langs->trans(
"NoStockChangeOnServices").
'</span>';
1082 print
'<td class="nowraponall">';
1083 if ($tmpproduct->status_batch) {
1084 $preselected = (
GETPOSTISSET(
'batch-'.$line->id.
'-'.$i) ?
GETPOST(
'batch-'.$line->id.
'-'.$i) :
'');
1085 print
'<input type="text" class="width50" name="batch-'.$line->id.
'-'.$i.
'" value="'.$preselected.
'" list="batch-'.$line->id.
'-'.$i.
'">';
1086 print $formproduct->selectLotDataList(
'batch-'.$line->id.
'-'.$i, 0, $line->fk_product,
'',
'');
1093 print
'<td align="right" class="split">';
1094 print
' '.img_picto($langs->trans(
'AddStockLocationLine'),
'split.png',
'class="splitbutton" onClick="addDispatchLine('.((int) $line->id).
', \''.
dol_escape_js($type).
'\', \
'qtymissingconsume\')"');
1098 print
'<td align="right" class="splitall">';
1099 if (($action ==
'consumeorproduce' || $action ==
'consumeandproduceall') && $tmpproduct->status_batch == 2) {
1100 print
img_picto($langs->trans(
'SplitAllQuantity'),
'split.png',
'class="splitbutton splitallbutton field-error-icon" data-max-qty="1" onClick="addDispatchLine('.$line->id.
', \'batch\', \'allmissingconsume\')"');
1105 if ($permissiontodelete) {
1119 print
'<script type="text/javascript">
1120 $(document).ready(function () {
1121 $("select[name=fk_default_warehouse]").change(function() {
1122 var fk_default_warehouse = $("option:selected", this).val();
1123 $("select[name^=idwarehouse-]").val(fk_default_warehouse).change();
1132 print
'<div class="fichehalfright">';
1133 print
'<div class="clearboth"></div>';
1135 $nblinetoproduce = 0;
1136 foreach ($object->lines as $line) {
1137 if ($line->role ==
'toproduce') {
1142 $newcardbutton =
'';
1143 $url = $_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'&action=addproduceline&token='.
newToken();
1144 $permissiontoaddaproductline = $object->status != $object::STATUS_PRODUCED && $object->status != $object::STATUS_CANCELED;
1145 $parameters = array(
'morecss'=>
'reposition');
1146 if ($action !=
'consumeorproduce' && $action !=
'consumeandproduceall') {
1147 if ($nblinetoproduce == 0 || $object->mrptype == 1) {
1148 $newcardbutton =
dolGetButtonTitle($langs->trans(
'AddNewProduceLines'),
'',
'fa fa-plus-circle size15x', $url,
'', $permissiontoaddaproductline, $parameters);
1152 print
load_fiche_titre($langs->trans(
'Production'), $newcardbutton,
'', 0,
'',
'');
1154 print
'<div class="div-table-responsive-no-min">';
1155 print
'<table id="tablelinestoproduce" class="noborder noshadow nobottom centpercent">';
1157 print
'<tr class="liste_titre">';
1159 print
'<td>'.$langs->trans(
"Product").
'</td>';
1161 print
'<td class="right">'.$langs->trans(
"Qty").
'</td>';
1163 if ($permissiontoupdatecost) {
1164 if (empty($bomcostupdated)) {
1165 print
'<td class="right">'.$form->textwithpicto($langs->trans(
"UnitCost"), $langs->trans(
"AmountUsedToUpdateWAP")).
'</td>';
1167 print
'<td class="right">'.$form->textwithpicto($langs->trans(
"ManufacturingPrice"), $langs->trans(
"AmountUsedToUpdateWAP")).
'</td>';
1171 print
'<td class="right">'.$langs->trans(
"QtyAlreadyProduced").
'</td>';
1174 if ($collapse || in_array($action, array(
'consumeorproduce',
'consumeandproduceall'))) {
1175 print $langs->trans(
"Warehouse");
1182 if ($collapse || in_array($action, array(
'consumeorproduce',
'consumeandproduceall'))) {
1183 print $langs->trans(
"Batch");
1195 if ($permissiontodelete) {
1201 if ($action ==
'addproduceline') {
1202 print
'<!-- Add line to produce -->'.
"\n";
1203 print
'<tr class="liste_titre">';
1207 print
$form->select_produits(
'',
'productidtoadd',
'', 0, 0, -1, 2,
'', 1, array(), 0,
'1', 0,
'maxwidth300');
1210 print
'<td class="right"><input type="text" name="qtytoadd" value="1" class="width50 right"></td>';
1212 if ($permissiontoupdatecost) {
1216 print
'<td colspan="2">';
1217 print
'<input type="submit" class="button buttongen button-add" name="addproducelinebutton" value="'.$langs->trans(
"Add").
'">';
1218 print
'<input type="submit" class="button buttongen button-cancel" name="canceladdproducelinebutton" value="'.$langs->trans(
"Cancel").
'">';
1231 if ($permissiontodelete) {
1237 if (!empty($object->lines)) {
1238 $nblinetoproduce = 0;
1239 foreach ($object->lines as $line) {
1240 if ($line->role ==
'toproduce') {
1245 $nblinetoproducecursor = 0;
1246 foreach ($object->lines as $line) {
1247 if ($line->role ==
'toproduce') {
1250 $nblinetoproducecursor++;
1252 $tmpproduct =
new Product($db);
1253 $tmpproduct->fetch($line->fk_product);
1255 $arrayoflines = $object->fetchLinesLinked(
'produced', $line->id);
1256 $alreadyproduced = 0;
1257 foreach ($arrayoflines as $line2) {
1258 $alreadyproduced += $line2[
'qty'];
1261 $suffix =
'_'.$line->id;
1262 print
'<!-- Line to dispatch '.$suffix.
' -->'.
"\n";
1264 print
'<input id="qty_ordered'.$suffix.
'" type="hidden" value="'.$line->qty.
'">';
1265 print
'<input id="qty_dispatched'.$suffix.
'" type="hidden" value="'.$alreadyproduced.
'">';
1269 print
'<td>'.$tmpproduct->getNomUrl(1);
1270 print
'<br><span class="opacitymedium small">'.$tmpproduct->label.
'</span>';
1273 print
'<td class="right">'.$line->qty.
'</td>';
1275 if ($permissiontoupdatecost) {
1277 $manufacturingcost = 0;
1278 $manufacturingcostsrc =
'';
1279 if ($object->mrptype == 0) {
1280 $manufacturingcost = $bomcostupdated;
1281 $manufacturingcostsrc = $langs->trans(
"CalculatedFromProductsToConsume");
1282 if (empty($manufacturingcost)) {
1283 $manufacturingcost = $bomcost;
1284 $manufacturingcostsrc = $langs->trans(
"ValueFromBom");
1286 if (empty($manufacturingcost)) {
1287 $manufacturingcost =
price2num($tmpproduct->cost_price,
'MU');
1288 $manufacturingcostsrc = $langs->trans(
"CostPrice");
1290 if (empty($manufacturingcost)) {
1291 $manufacturingcost =
price2num($tmpproduct->pmp,
'MU');
1292 $manufacturingcostsrc = $langs->trans(
"PMPValue");
1296 print
'<td class="right nowraponall" title="'.dol_escape_htmltag($manufacturingcostsrc).
'">';
1297 if ($manufacturingcost) {
1298 print
price($manufacturingcost);
1303 print
'<td class="right nowraponall">';
1304 if ($alreadyproduced) {
1306 print
'jQuery(document).ready(function() {
1307 jQuery("#expandtoproduce'.$line->id.
'").click(function() {
1308 console.log("Expand mrp_production line '.$line->id.
'");
1309 jQuery(".expanddetailtoproduce'.$line->id.
'").toggle();';
1310 if ($nblinetoproduce == $nblinetoproducecursor) {
1311 print
'if (jQuery("#tablelinestoproduce").hasClass("nobottom")) { jQuery("#tablelinestoproduce").removeClass("nobottom"); } else { jQuery("#tablelinestoproduce").addClass("nobottom"); }';
1317 if (empty($conf->use_javascript_ajax)) {
1318 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?collapse='.$collapse.
','.$line->id.
'">';
1320 print
img_picto($langs->trans(
"ShowDetails"),
"chevron-down",
'id="expandtoproduce'.$line->id.
'"');
1321 if (empty($conf->use_javascript_ajax)) {
1325 print
' '.$alreadyproduced;
1341 if ($permissiontodelete) {
1342 if ($line->origin_type ==
'free') {
1343 $href = $_SERVER[
"PHP_SELF"];
1344 $href .=
'?id='.$object->id;
1345 $href .=
'&action=deleteline';
1346 $href .=
'&lineid='.$line->id;
1347 print
'<td class="center">';
1348 print
'<a class="reposition" href="'.$href.
'">';
1349 print
img_picto($langs->trans(
'TooltipDeleteAndRevertStockMovement'),
"delete");
1359 foreach ($arrayoflines as $line2) {
1360 print
'<tr class="expanddetailtoproduce'.$line->id.
' hideobject opacitylow">';
1363 $tmpstockmovement->id = $line2[
'fk_stock_movement'];
1364 print
'<a href="'.DOL_URL_ROOT.
'/product/stock/movement_list.php?search_ref='.$tmpstockmovement->id.
'">'.
img_picto($langs->trans(
"StockMovement"),
'movement',
'class="paddingright"').
'</a>';
1370 if ($permissiontoupdatecost) {
1374 print
'<td class="right">'.$line2[
'qty'].
'</td>';
1376 print
'<td class="tdoverflowmax150">';
1377 if ($line2[
'fk_warehouse'] > 0) {
1378 $result = $tmpwarehouse->fetch($line2[
'fk_warehouse']);
1380 print $tmpwarehouse->getNomUrl(1);
1387 if ($line2[
'batch'] !=
'') {
1388 $tmpbatch->fetch(0, $line2[
'fk_product'], $line2[
'batch']);
1389 print $tmpbatch->getNomUrl(1);
1400 if ($permissiontodelete) {
1406 if (in_array($action, array(
'consumeorproduce',
'consumeandproduceall'))) {
1407 print
'<!-- Enter line to produce -->'.
"\n";
1409 print
'<tr data-max-qty="'.$maxQty.
'" name="batch_'.$line->id.
'_'.$i.
'">';
1411 print
'<td><span class="opacitymedium">'.$langs->trans(
"ToProduce").
'</span></td>';
1412 $preselected = (
GETPOSTISSET(
'qtytoproduce-'.$line->id.
'-'.$i) ?
GETPOST(
'qtytoproduce-'.$line->id.
'-'.$i) : max(0, $line->qty - $alreadyproduced));
1413 if ($action ==
'consumeorproduce' && !
GETPOSTISSET(
'qtytoproduce-'.$line->id.
'-'.$i)) {
1417 print
'<td class="right"><input type="text" class="width50 right" id="qtytoproduce-'.$line->id.
'-'.$i.
'" name="qtytoproduce-'.$line->id.
'-'.$i.
'" value="'.$preselected.
'"></td>';
1419 if ($permissiontoupdatecost) {
1421 $manufacturingcost = 0;
1422 $manufacturingcostsrc =
'';
1423 if ($object->mrptype == 0) {
1424 $manufacturingcost = $bomcostupdated;
1425 $manufacturingcostsrc = $langs->trans(
"CalculatedFromProductsToConsume");
1426 if (empty($manufacturingcost)) {
1427 $manufacturingcost = $bomcost;
1428 $manufacturingcostsrc = $langs->trans(
"ValueFromBom");
1430 if (empty($manufacturingcost)) {
1431 $manufacturingcost =
price2num($tmpproduct->cost_price,
'MU');
1432 $manufacturingcostsrc = $langs->trans(
"CostPrice");
1434 if (empty($manufacturingcost)) {
1435 $manufacturingcost =
price2num($tmpproduct->pmp,
'MU');
1436 $manufacturingcostsrc = $langs->trans(
"PMPValue");
1441 $preselected = (
GETPOSTISSET(
'pricetoproduce-'.$line->id.
'-'.$i) ?
GETPOST(
'pricetoproduce-'.$line->id.
'-'.$i) : ($manufacturingcost ?
price($manufacturingcost) :
''));
1442 print
'<td class="right"><input type="text" class="width75 right" name="pricetoproduce-'.$line->id.
'-'.$i.
'" value="'.$preselected.
'"></td>';
1444 print
'<td><input type="hidden" class="width50 right" name="pricetoproduce-'.$line->id.
'-'.$i.
'" value="'.($manufacturingcost ? $manufacturingcost :
'').
'"></td>';
1452 $preselected = (
GETPOSTISSET(
'idwarehousetoproduce-'.$line->id.
'-'.$i) ?
GETPOST(
'idwarehousetoproduce-'.$line->id.
'-'.$i) : ($object->fk_warehouse > 0 ? $object->fk_warehouse :
'ifone'));
1453 print $formproduct->selectWarehouses($preselected,
'idwarehousetoproduce-'.$line->id.
'-'.$i,
'', 1, 0, $line->fk_product,
'', 1, 0,
null,
'maxwidth200 csswarehouse_'.$line->id.
'_'.$i);
1455 print
'<span class="opacitymedium">'.$langs->trans(
"NoStockChangeOnServices").
'</span>';
1461 if ($tmpproduct->status_batch) {
1462 $preselected = (
GETPOSTISSET(
'batchtoproduce-'.$line->id.
'-'.$i) ?
GETPOST(
'batchtoproduce-'.$line->id.
'-'.$i) :
'');
1463 print
'<input type="text" class="width50" name="batchtoproduce-'.$line->id.
'-'.$i.
'" value="'.$preselected.
'">';
1467 if ($tmpproduct->status_batch) {
1469 print
'<td align="right" class="split">';
1470 print
img_picto($langs->trans(
'AddStockLocationLine'),
'split.png',
'class="splitbutton" onClick="addDispatchLine('.$line->id.
', \''.$type.
'\', \
'qtymissing\')"');
1473 print
'<td align="right" class="splitall">';
1474 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\')"');
1499 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.