34require
'../main.inc.php';
35require_once DOL_DOCUMENT_ROOT.
'/core/modules/supplier_order/modules_commandefournisseur.php';
36require_once DOL_DOCUMENT_ROOT.
'/product/stock/class/entrepot.class.php';
37require_once DOL_DOCUMENT_ROOT.
'/core/lib/fourn.lib.php';
38require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.commande.class.php';
39require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.commande.dispatch.class.php';
40require_once DOL_DOCUMENT_ROOT.
'/product/class/html.formproduct.class.php';
41require_once DOL_DOCUMENT_ROOT.
'/product/stock/class/mouvementstock.class.php';
42require_once DOL_DOCUMENT_ROOT.
'/core/lib/reception.lib.php';
43require_once DOL_DOCUMENT_ROOT.
'/projet/class/project.class.php';
46$langs->loadLangs(array(
"bills",
"orders",
"sendings",
"companies",
"deliveries",
"products",
"stocks",
"receptions"));
48if (isModEnabled(
'productbatch')) {
49 $langs->load(
'productbatch');
55$lineid =
GETPOST(
'lineid',
'int');
56$action =
GETPOST(
'action',
'aZ09');
57$fk_default_warehouse =
GETPOST(
'fk_default_warehouse',
'int');
58$cancel =
GETPOST(
'cancel',
'alpha');
59$confirm =
GETPOST(
'confirm',
'alpha');
65 $socid = $user->socid;
68$hookmanager->initHooks(array(
'ordersupplierdispatch'));
72if (GETPOSTISSET(
"projectid")) {
73 $projectid =
GETPOST(
"projectid",
'int');
78if ($id > 0 || !empty($ref)) {
79 $result = $object->fetch($id, $ref);
83 $result = $object->fetch_thirdparty();
87 if (!empty($object->origin)) {
88 $origin = $object->origin;
90 $object->fetch_origin();
91 $typeobject = $object->origin;
93 if ($origin ==
'order_supplier' && $object->$typeobject->id && (isModEnabled(
"fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || isModEnabled(
"supplier_order"))) {
94 $origin_id = $object->$typeobject->id;
96 $objectsrc->fetch($object->$typeobject->id);
100if (empty($conf->reception->enabled)) {
101 $permissiontoreceive = $user->rights->fournisseur->commande->receptionner;
102 $permissiontocontrol = ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->fournisseur->commande->receptionner)) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->fournisseur->commande_advance->check)));
104 $permissiontoreceive = $user->rights->reception->creer;
105 $permissiontocontrol = ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->reception->creer)) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->reception->reception_advance->validate)));
111if (!isModEnabled(
'stock')) {
115$usercancreate = $user->hasRight(
'reception',
'creer');
116$permissiontoadd = $usercancreate;
123$parameters = array();
124$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
130if ($action ==
'updatelines' && $permissiontoreceive) {
137 foreach ($_POST as $key => $value) {
140 if (preg_match(
'/^product_.*([0-9]+)_([0-9]+)$/i', $key, $reg)) {
142 if (preg_match(
'/^product_([0-9]+)_([0-9]+)$/i', $key, $reg)) {
143 $modebatch =
"barcode";
144 } elseif (preg_match(
'/^product_batch_([0-9]+)_([0-9]+)$/i', $key, $reg)) {
145 $modebatch =
"batch";
149 if ($modebatch ==
"barcode") {
150 $prod =
"product_".$reg[1].
'_'.$reg[2];
152 $prod =
'product_batch_'.$reg[1].
'_'.$reg[2];
154 $qty =
"qty_".$reg[1].
'_'.$reg[2];
155 $ent =
"entrepot_".$reg[1].
'_'.$reg[2];
156 $pu =
"pu_".$reg[1].
'_'.$reg[2];
157 $fk_commandefourndet =
"fk_commandefourndet_".$reg[1].
'_'.$reg[2];
158 $idline =
GETPOST(
"idline_".$reg[1].
'_'.$reg[2]);
162 if ($modebatch ==
"batch") {
163 $lot =
GETPOST(
'lot_number_'.$reg[1].
'_'.$reg[2]);
164 $dDLUO =
dol_mktime(12, 0, 0,
GETPOST(
'dluo_'.$reg[1].
'_'.$reg[2].
'month',
'int'),
GETPOST(
'dluo_'.$reg[1].
'_'.$reg[2].
'day',
'int'),
GETPOST(
'dluo_'.$reg[1].
'_'.$reg[2].
'year',
'int'));
165 $dDLC =
dol_mktime(12, 0, 0,
GETPOST(
'dlc_'.$reg[1].
'_'.$reg[2].
'month',
'int'),
GETPOST(
'dlc_'.$reg[1].
'_'.$reg[2].
'day',
'int'),
GETPOST(
'dlc_'.$reg[1].
'_'.$reg[2].
'year',
'int'));
168 if (!empty($conf->global->SUPPLIER_ORDER_CAN_UPDATE_BUYINGPRICE_DURING_RECEIPT)) {
169 if (!isModEnabled(
"multicurrency") && empty($conf->dynamicprices->enabled)) {
170 $dto =
GETPOST(
"dto_".$reg[1].
'_'.$reg[2],
'int');
174 $saveprice =
"saveprice_".$reg[1].
'_'.$reg[2];
179 if (($modebatch ==
"batch" &&
GETPOST($qty) > 0) || ($modebatch ==
"barcode" &&
GETPOST($qty) != 0)) {
180 if (!(
GETPOST($ent,
'int') > 0)) {
181 dol_syslog(
'No dispatch for line '.$key.
' as no warehouse was chosen.');
182 $text = $langs->transnoentities(
'Warehouse').
', '.$langs->transnoentities(
'Line').
' '.($numline);
183 setEventMessages($langs->trans(
'ErrorFieldRequired', $text),
null,
'errors');
189 $result = $supplierorderdispatch->fetch($idline);
191 setEventMessages($supplierorderdispatch->error, $supplierorderdispatch->errors,
'errors');
194 $qtystart = $supplierorderdispatch->qty;
195 $supplierorderdispatch->qty =
GETPOST($qty);
196 $supplierorderdispatch->fk_entrepot =
GETPOST($ent,
'int');
197 if ($modebatch ==
"batch") {
198 $supplierorderdispatch->eatby = $dDLUO;
199 $supplierorderdispatch->sellby = $dDLC;
202 $result = $supplierorderdispatch->update($user);
204 setEventMessages($supplierorderdispatch->error, $supplierorderdispatch->errors,
'errors');
248 $result = $objectsrc->dispatchProduct($user,
GETPOST($prod,
'int'),
GETPOST($qty),
GETPOST($ent,
'int'),
GETPOST($pu),
GETPOST(
'comment'), $dDLUO, $dDLC, $lot,
GETPOST($fk_commandefourndet,
'int'), 0, $object->id);
255 if (!$error && !empty($conf->global->SUPPLIER_ORDER_CAN_UPDATE_BUYINGPRICE_DURING_RECEIPT)) {
256 if (!isModEnabled(
"multicurrency") && empty($conf->dynamicprices->enabled)) {
263 if (GETPOSTISSET($saveprice)) {
265 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"product_fournisseur_price";
266 $sql .=
" SET unitprice='".price2num(
GETPOST($pu),
'MU').
"'";
267 $sql .=
", price=".price2num(
GETPOST($pu),
'MU').
"*quantity";
268 $sql .=
", remise_percent = ".((float) $dto);
269 $sql .=
" WHERE fk_soc=".((int) $object->socid);
270 $sql .=
" AND fk_product=".((int)
GETPOST($prod,
'int'));
272 $resql = $db->query($sql);
287 header(
"Location: ".DOL_URL_ROOT.
'/reception/dispatch.php?id='.$object->id);
299$form =
new Form($db);
301$warehouse_static =
new Entrepot($db);
304$title = $object->ref.
" - ".$langs->trans(
'ReceptionDistribution');
305$help_url =
'EN:Module_Suppliers_Orders|FR:CommandeFournisseur|ES:Módulo_Pedidos_a_proveedores';
306$morejs = array(
'/fourn/js/lib_dispatch.js.php');
308llxHeader(
'', $title, $help_url,
'', 0, 0, $morejs);
310if ($id > 0 || !empty($ref)) {
311 if (!empty($object->origin) && $object->origin_id > 0) {
312 $object->origin =
'CommandeFournisseur';
313 $typeobject = $object->origin;
314 $origin = $object->origin;
315 $origin_id = $object->origin_id;
316 $object->fetch_origin();
319 $soc->fetch($object->socid);
321 $author =
new User($db);
322 $author->fetch($object->user_author_id);
326 $title = $langs->trans(
"SupplierOrder");
327 print
dol_get_fiche_head($head,
'dispatch', $langs->trans(
"Reception"), -1,
'dollyrevert');
333 if ($action ==
'ask_deleteline') {
334 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'&lineid='.$lineid, $langs->trans(
'DeleteLine'), $langs->trans(
'ConfirmDeleteLine'),
'confirm_deleteline',
'', 0, 1);
338 $parameters = array(
'lineid' => $lineid);
340 $reshook = $hookmanager->executeHooks(
'formConfirm', $parameters, $object, $action);
341 if (empty($reshook)) {
342 $formconfirm .= $hookmanager->resPrint;
343 } elseif ($reshook > 0) {
344 $formconfirm = $hookmanager->resPrint;
351 $linkback =
'<a href="'.DOL_URL_ROOT.
'/reception/list.php?restore_lastsearch_values=1'.(!empty($socid) ?
'&socid='.$socid :
'').
'">'.$langs->trans(
"BackToList").
'</a>';
352 $morehtmlref =
'<div class="refidno">';
355 $morehtmlref .= $form->editfieldkey(
"RefSupplier",
'ref_supplier', $object->ref_supplier, $object, $user->rights->reception->creer,
'string',
'', 0, 1);
356 $morehtmlref .= $form->editfieldval(
"RefSupplier",
'ref_supplier', $object->ref_supplier, $object, $user->rights->reception->creer,
'string',
'',
null,
null,
'', 1);
359 $morehtmlref .=
'<br>'.$object->thirdparty->getNomUrl(1);
361 if (isModEnabled(
'project')) {
362 $langs->load(
"projects");
363 $morehtmlref .=
'<br>';
365 $morehtmlref .=
img_picto($langs->trans(
"Project"),
'project',
'class="pictofixedwidth"');
366 if ($action !=
'classify' && $permissiontoadd) {
367 $morehtmlref .=
'<a class="editfielda" href="'.$_SERVER[
'PHP_SELF'].
'?action=classify&token='.newToken().
'&id='.$object->id.
'">'.
img_edit($langs->transnoentitiesnoconv(
'SetProject')).
'</a> ';
369 $morehtmlref .= $form->form_project($_SERVER[
'PHP_SELF'].
'?id='.$object->id, (empty($conf->global->PROJECT_CAN_ALWAYS_LINK_TO_ALL_SUPPLIERS) ? $object->socid : -1), $object->fk_project, ($action ==
'classify' ?
'projectid' :
'none'), 0, 0, 0, 1,
'',
'maxwidth300');
371 if (!empty($objectsrc) && !empty($objectsrc->fk_project)) {
373 $proj->fetch($objectsrc->fk_project);
374 $morehtmlref .= $proj->getNomUrl(1);
376 $morehtmlref .=
'<span class="opacitymedium"> - '.dol_escape_htmltag($proj->title).
'</span>';
381 $morehtmlref .=
'</div>';
383 dol_banner_tab($object,
'ref', $linkback, 1,
'ref',
'ref', $morehtmlref);
386 print
'<div class="fichecenter">';
387 print
'<div class="underbanner clearboth"></div>';
389 print
'<table class="border tableforfield" width="100%">';
392 if ($typeobject ==
'commande' && $object->$typeobject->id && isModEnabled(
'commande')) {
394 print $langs->trans(
"RefOrder").
'</td>';
395 print
'<td colspan="3">';
396 print $objectsrc->getNomUrl(1,
'commande');
400 if ($typeobject ==
'propal' && $object->$typeobject->id && isModEnabled(
"propal")) {
402 print $langs->trans(
"RefProposal").
'</td>';
403 print
'<td colspan="3">';
404 print $objectsrc->getNomUrl(1,
'reception');
408 if ($typeobject ==
'CommandeFournisseur' && $object->$typeobject->id && isModEnabled(
"propal")) {
410 print $langs->trans(
"SupplierOrder").
'</td>';
411 print
'<td colspan="3">';
412 print $objectsrc->getNomUrl(1,
'reception');
418 print
'<tr><td class="titlefield">'.$langs->trans(
"DateCreation").
'</td>';
419 print
'<td colspan="3">'.dol_print_date($object->date_creation,
"dayhour",
"tzuserrel").
"</td>\n";
423 print
'<tr><td height="10">';
424 print
'<table class="nobordernopadding" width="100%"><tr><td>';
425 print $langs->trans(
'DateDeliveryPlanned');
427 print
'</tr></table>';
428 print
'</td><td colspan="2">';
429 print $object->date_delivery ?
dol_print_date($object->date_delivery,
'dayhour') :
' ';
434 print
'<br><br><center>';
435 print
'<a href="#" id="resetalltoexpected" class="marginrightonly paddingright marginleftonly paddingleft">'.img_picto(
"",
'autofill',
'class="pictofixedwidth"').$langs->trans(
"RestoreWithCurrentQtySaved").
'</a></td>';
437 print
'<a href="#" id="autoreset" class="marginrightonly paddingright marginleftonly paddingleft">'.img_picto(
"",
'eraser',
'class="pictofixedwidth"').$langs->trans(
"ClearQtys").
'</a></td>';
443 if ($object->statut == Reception::STATUS_DRAFT || ($object->statut == Reception::STATUS_VALIDATED && empty($conf->global->STOCK_CALCULATE_ON_RECEPTION))) {
444 require_once DOL_DOCUMENT_ROOT.
'/product/class/html.formproduct.class.php';
446 $formproduct->loadWarehouses();
448 $listwarehouses = $entrepot->list_array(1);
450 print
'<form method="post" action="'.$_SERVER[
"PHP_SELF"].
'">';
452 print
'<input type="hidden" name="token" value="'.newToken().
'">';
453 print
'<input type="hidden" name="action" value="updatelines">';
454 print
'<input type="hidden" name="id" value="'.$object->id.
'">';
456 print
'<div class="div-table-responsive-no-min">';
457 print
'<table class="noborder centpercent">';
460 $products_dispatched = array();
461 $sql =
"SELECT l.rowid, cfd.fk_product, sum(cfd.qty) as qty";
462 $sql .=
" FROM ".MAIN_DB_PREFIX.
"commande_fournisseur_dispatch as cfd";
463 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"commande_fournisseurdet as l on l.rowid = cfd.fk_commandefourndet";
464 $sql .=
" WHERE cfd.fk_reception = ".((int) $object->id);
465 $sql .=
" GROUP BY l.rowid, cfd.fk_product";
467 $resql = $db->query($sql);
469 $num = $db->num_rows($resql);
474 $objd = $db->fetch_object($resql);
475 $products_dispatched[$objd->rowid] =
price2num($objd->qty,
'MS');
484 $sql =
"SELECT l.rowid, l.fk_product, l.subprice, l.remise_percent, l.ref AS sref, l.qty as qty,";
485 $sql .=
" p.ref, p.label, p.tobatch, p.fk_default_warehouse";
487 $parameters = array();
488 $reshook = $hookmanager->executeHooks(
489 'printFieldListSelect',
497 $sql .= $hookmanager->resPrint;
498 $sql .=
" FROM ".MAIN_DB_PREFIX.
"commande_fournisseurdet as l";
499 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"product as p ON l.fk_product=p.rowid";
500 $sql .=
" WHERE l.fk_commande = ".((int) $objectsrc->id);
501 if (empty($conf->global->STOCK_SUPPORTS_SERVICES)) {
502 $sql .=
" AND l.product_type = 0";
505 $parameters = array();
506 $reshook = $hookmanager->executeHooks(
507 'printFieldListWhere',
515 $sql .= $hookmanager->resPrint;
518 $sql .=
" ORDER BY l.rang, p.ref, p.label";
520 $resql = $db->query($sql);
522 $num = $db->num_rows($resql);
526 print
'<tr class="liste_titre">';
528 print
'<td>'.$langs->trans(
"Description").
'</td>';
529 if (isModEnabled(
'productbatch')) {
530 print
'<td class="dispatch_batch_number_title">'.$langs->trans(
"batch_number").
'</td>';
531 if (empty($conf->global->PRODUCT_DISABLE_SELLBY)) {
532 print
'<td class="dispatch_dlc_title">'.$langs->trans(
"SellByDate").
'</td>';
534 if (empty($conf->global->PRODUCT_DISABLE_EATBY)) {
535 print
'<td class="dispatch_dluo_title">'.$langs->trans(
"EatByDate").
'</td>';
542 print
'<td class="right">'.$langs->trans(
"SupplierRef").
'</td>';
543 print
'<td class="right">'.$langs->trans(
"QtyOrdered").
'</td>';
544 print
'<td class="right">'.$langs->trans(
"QtyDispatchedShort").
'</td>';
545 print
' <td class="right">'.$langs->trans(
"QtyToDispatchShort");
547 print
'<td width="32"></td>';
549 if (!empty($conf->global->SUPPLIER_ORDER_CAN_UPDATE_BUYINGPRICE_DURING_RECEIPT)) {
550 if (!isModEnabled(
"multicurrency") && empty($conf->dynamicprices->enabled)) {
551 print
'<td class="right">'.$langs->trans(
"Price").
'</td>';
552 print
'<td class="right">'.$langs->trans(
"ReductionShort").
' (%)</td>';
553 print
'<td class="right">'.$langs->trans(
"UpdatePrice").
'</td>';
557 print
'<td align="right">'.$langs->trans(
"Warehouse");
560 if (count($listwarehouses) > 1) {
561 print
'<br><span class="opacitymedium">'.$langs->trans(
"ForceTo").
'</span> '.$form->selectarray(
'fk_default_warehouse', $listwarehouses, $fk_default_warehouse, 1, 0, 0,
'', 0, 0, $disabled,
'',
'minwidth100 maxwidth300', 1);
562 } elseif (count($listwarehouses) == 1) {
563 print
'<br><span class="opacitymedium">'.$langs->trans(
"ForceTo").
'</span> '.$form->selectarray(
'fk_default_warehouse', $listwarehouses, $fk_default_warehouse, 0, 0, 0,
'', 0, 0, $disabled,
'',
'minwidth100 maxwidth300', 1);
569 $parameters = array();
570 $reshook = $hookmanager->executeHooks(
571 'printFieldListTitle',
579 print $hookmanager->resPrint;
588 $conf->cache[
'product'] = array();
592 $objp = $db->fetch_object($resql);
595 if (!$objp->fk_product > 0) {
598 $alreadydispatched = isset($products_dispatched[$objp->rowid])?$products_dispatched[$objp->rowid]:0;
599 $remaintodispatch =
price2num($objp->qty, 5);
600 if ($remaintodispatch < 0 && empty($conf->global->SUPPLIER_ORDER_ALLOW_NEGATIVE_QTY_FOR_SUPPLIER_ORDER_RETURN)) {
601 $remaintodispatch = 0;
604 if ($remaintodispatch || empty($conf->global->SUPPLIER_ORDER_DISABLE_STOCK_DISPATCH_WHEN_TOTAL_REACHED)) {
613 print
'<!-- Line to dispatch '.$suffix.
' -->'.
"\n";
615 print
'<input id="qty_ordered'.$suffix.
'" type="hidden" value="'.$objp->qty.
'">';
616 print
'<input id="qty_dispatched'.$suffix.
'" type="hidden" data-dispatched="'.((float) $alreadydispatched).
'" value="'.(float) $alreadydispatched.
'">';
617 print
'<tr class="oddeven">';
619 if (empty($conf->cache[
'product'][$objp->fk_product])) {
620 $tmpproduct =
new Product($db);
621 $tmpproduct->fetch($objp->fk_product);
622 $conf->cache[
'product'][$objp->fk_product] = $tmpproduct;
624 $tmpproduct = $conf->cache[
'product'][$objp->fk_product];
627 $linktoprod = $tmpproduct->getNomUrl(1);
628 $linktoprod .=
' - '.$objp->label.
"\n";
630 if (isModEnabled(
'productbatch')) {
631 if ($objp->tobatch) {
636 print
'<td class="dispatch_batch_number"></td>';
637 if (empty($conf->global->PRODUCT_DISABLE_SELLBY)) {
638 print
'<td class="dispatch_dlc"></td>';
640 if (empty($conf->global->PRODUCT_DISABLE_EATBY)) {
641 print
'<td class="dispatch_dluo"></td>';
648 print
'<td class="dispatch_batch_number">';
649 print
'<span class="opacitymedium small">'.$langs->trans(
"ProductDoesNotUseBatchSerial").
'</small>';
651 if (empty($conf->global->PRODUCT_DISABLE_SELLBY)) {
652 print
'<td class="dispatch_dlc"></td>';
654 if (empty($conf->global->PRODUCT_DISABLE_EATBY)) {
655 print
'<td class="dispatch_dluo"></td>';
659 print
'<td colspan="4">';
665 $up_ht_disc = $objp->subprice;
666 if (!empty($objp->remise_percent) && empty($conf->global->STOCK_EXCLUDE_DISCOUNT_FOR_PMP)) {
667 $up_ht_disc =
price2num($up_ht_disc * (100 - $objp->remise_percent) / 100,
'MU');
671 print
'<td class="right">'.$objp->sref.
'</td>';
674 print
'<td class="right">'.$objp->qty.
'</td>';
677 print
'<td class="right">'.$alreadydispatched.
'</td>';
679 print
'<td class="right">';
685 $sql =
"SELECT cfd.rowid, cfd.qty, cfd.fk_entrepot, cfd.batch, cfd.eatby, cfd.sellby, cfd.fk_product";
686 $sql .=
" FROM ".MAIN_DB_PREFIX.
"commande_fournisseur_dispatch as cfd";
687 $sql .=
" WHERE cfd.fk_reception = ".((int) $object->id);
688 $sql .=
" AND cfd.fk_commande = ".((int) $objectsrc->id);
689 $sql .=
" AND cfd.fk_commandefourndet = ".(int) $objp->rowid;
692 $resultsql = $db->query($sql);
695 $numd = $db->num_rows($resultsql);
698 $suffix =
"_".$j.
"_".$i;
699 $objd = $db->fetch_object($resultsql);
701 if (isModEnabled(
'productbatch') && !empty($objd->batch)) {
707 'is_information_row' =>
true,
712 $reshook = $hookmanager->executeHooks(
713 'printFieldListValue',
721 print $hookmanager->resPrint;
725 print
'<!-- line for batch '.$numline.
' -->';
726 print
'<tr class="oddeven autoresettr" name="'.$type.$suffix.
'" data-remove="clear">';
728 print
'<input id="fk_commandefourndet'.$suffix.
'" name="fk_commandefourndet'.$suffix.
'" type="hidden" value="'.$objp->rowid.
'">';
729 print
'<input id="idline'.$suffix.
'" name="idline'.$suffix.
'" type="hidden" value="'.$objd->rowid.
'">';
730 print
'<input name="product_batch'.$suffix.
'" type="hidden" value="'.$objd->fk_product.
'">';
732 print
'<!-- This is a U.P. (may include discount or not depending on STOCK_EXCLUDE_DISCOUNT_FOR_PMP. will be used for PMP calculation) -->';
733 if (!empty($conf->global->SUPPLIER_ORDER_EDIT_BUYINGPRICE_DURING_RECEIPT)) {
734 print $langs->trans(
"BuyingPrice").
': <input class="maxwidth75" name="pu'.$suffix.
'" type="text" value="'.
price2num($up_ht_disc,
'MU').
'">';
736 print
'<input class="maxwidth75" name="pu'.$suffix.
'" type="hidden" value="'.
price2num($up_ht_disc,
'MU').
'">';
742 print
'<input disabled="" type="text" class="inputlotnumber quatrevingtquinzepercent" id="lot_number'.$suffix.
'" name="lot_number'.$suffix.
'" value="'.$objd->batch.
'">';
744 if (empty($conf->global->PRODUCT_DISABLE_SELLBY)) {
745 print
'<td class="nowraponall">';
747 print $form->selectDate($dlcdatesuffix,
'dlc'.$suffix,
'',
'', 1,
'');
750 if (empty($conf->global->PRODUCT_DISABLE_EATBY)) {
751 print
'<td class="nowraponall">';
753 print $form->selectDate($dluodatesuffix,
'dluo'.$suffix,
'',
'', 1,
'');
756 print
'<td colspan="3"> </td>';
760 $colspan = (!empty($conf->global->PRODUCT_DISABLE_SELLBY)) ? --$colspan : $colspan;
761 $colspan = (!empty($conf->global->PRODUCT_DISABLE_EATBY)) ? --$colspan : $colspan;
766 'is_information_row' =>
true,
771 $reshook = $hookmanager->executeHooks(
772 'printFieldListValue',
780 print $hookmanager->resPrint;
784 print
'<!-- line no batch '.$numline.
' -->';
785 print
'<tr class="oddeven autoresettr" name="'.$type.$suffix.
'" data-remove="clear">';
786 print
'<td colspan="'.$colspan.
'">';
787 print
'<input id="fk_commandefourndet'.$suffix.
'" name="fk_commandefourndet'.$suffix.
'" type="hidden" value="'.$objp->rowid.
'">';
788 print
'<input id="idline'.$suffix.
'" name="idline'.$suffix.
'" type="hidden" value="'.$objd->rowid.
'">';
789 print
'<input name="product'.$suffix.
'" type="hidden" value="'.$objd->fk_product.
'">';
791 print
'<!-- This is a up (may include discount or not depending on STOCK_EXCLUDE_DISCOUNT_FOR_PMP. will be used for PMP calculation) -->';
792 if (!empty($conf->global->SUPPLIER_ORDER_EDIT_BUYINGPRICE_DURING_RECEIPT)) {
793 print $langs->trans(
"BuyingPrice").
': <input class="maxwidth75" name="pu'.$suffix.
'" type="text" value="'.
price2num($up_ht_disc,
'MU').
'">';
795 print
'<input class="maxwidth75" name="pu'.$suffix.
'" type="hidden" value="'.
price2num($up_ht_disc,
'MU').
'">';
801 print
'<td class="right">';
802 print
'<a href="#" id="reset'.$suffix.
'" class="resetline">'.
img_picto($langs->trans(
"Reset"),
'eraser',
'class="pictofixedwidth opacitymedium"').
'</a>';
803 print
'<input id="qty'.$suffix.
'" onchange="onChangeDispatchLineQty($(this))" name="qty'.$suffix.
'" data-type="'.$type.
'" data-index="'.$i.
'" class="width50 right qtydispatchinput" value="'.(GETPOSTISSET(
'qty'.$suffix) ?
GETPOST(
'qty'.$suffix,
'int') : $objd->qty).
'" data-expected="'.$objd->qty.
'">';
806 if (isModEnabled(
'productbatch') && $objp->tobatch > 0) {
808 print
img_picto($langs->trans(
'AddStockLocationLine'),
'split.png',
'class="splitbutton" '.($numd != $j+1 ?
'style="display:none"' :
'').
' onClick="addDispatchLine('.$i.
', \''.$type.
'\')"');
811 print
img_picto($langs->trans(
'AddStockLocationLine'),
'split.png',
'class="splitbutton" '.($numd != $j+1 ?
'style="display:none"' :
'').
' onClick="addDispatchLine('.$i.
', \''.$type.
'\')"');
816 if (!empty($conf->global->SUPPLIER_ORDER_CAN_UPDATE_BUYINGPRICE_DURING_RECEIPT)) {
817 if (!isModEnabled(
"multicurrency") && empty($conf->dynamicprices->enabled)) {
819 print
'<td class="right">';
820 print
'<input id="pu'.$suffix.
'" name="pu'.$suffix.
'" type="text" size="8" value="'.
price((
GETPOST(
'pu'.$suffix) !=
'' ?
price2num(
GETPOST(
'pu'.$suffix)) : $up_ht_disc)).
'">';
824 print
'<td class="right">';
825 print
'<input id="dto'.$suffix.
'" name="dto'.$suffix.
'" type="text" size="8" value="'.(
GETPOST(
'dto'.$suffix) !=
'' ?
GETPOST(
'dto'.$suffix) :
'').
'">';
829 print
'<td class="center">';
830 print
'<input class="flat checkformerge" type="checkbox" name="saveprice'.$suffix.
'" value="'.(
GETPOST(
'saveprice'.$suffix) !=
'' ?
GETPOST(
'saveprice'.$suffix) :
'').
'">';
836 print
'<td class="right">';
837 if (count($listwarehouses) > 1) {
838 print $formproduct->selectWarehouses(
GETPOST(
"entrepot".$suffix) ?
GETPOST(
"entrepot".$suffix) : $objd->fk_entrepot,
"entrepot".$suffix,
'', 1, 0, $objp->fk_product,
'', 1, 0, null,
'csswarehouse'.$suffix);
839 } elseif (count($listwarehouses) == 1) {
840 print $formproduct->selectWarehouses(
GETPOST(
"entrepot".$suffix) ?
GETPOST(
"entrepot".$suffix) : $objd->fk_entrepot,
"entrepot".$suffix,
'', 0, 0, $objp->fk_product,
'', 1, 0, null,
'csswarehouse'.$suffix);
842 $langs->load(
"errors");
843 print $langs->trans(
"ErrorNoWarehouseDefined");
849 'is_information_row' =>
false,
854 $reshook = $hookmanager->executeHooks(
855 'printFieldListValue',
863 print $hookmanager->resPrint;
870 $suffix =
"_".$j.
"_".$i;
874 if (isModEnabled(
'productbatch') && !empty($objp->tobatch)) {
880 'is_information_row' =>
true,
885 $reshook = $hookmanager->executeHooks(
886 'printFieldListValue',
894 print $hookmanager->resPrint;
898 print
'<!-- line for batch '.$numline.
' (not dispatched line yet for this order line) -->';
899 print
'<tr class="oddeven autoresettr" name="'.$type.$suffix.
'">';
901 print
'<input id="fk_commandefourndet'.$suffix.
'" name="fk_commandefourndet'.$suffix.
'" type="hidden" value="'.$objp->rowid.
'">';
902 print
'<input id="idline'.$suffix.
'" name="idline'.$suffix.
'" type="hidden" value="-1">';
903 print
'<input name="product_batch'.$suffix.
'" type="hidden" value="'.$objp->fk_product.
'">';
905 print
'<!-- This is a up (may include discount or not depending on STOCK_EXCLUDE_DISCOUNT_FOR_PMP. will be used for PMP calculation) -->';
906 if (!empty($conf->global->SUPPLIER_ORDER_EDIT_BUYINGPRICE_DURING_RECEIPT)) {
907 print $langs->trans(
"BuyingPrice").
': <input class="maxwidth75" name="pu'.$suffix.
'" type="text" value="'.
price2num($up_ht_disc,
'MU').
'">';
909 print
'<input class="maxwidth75" name="pu'.$suffix.
'" type="hidden" value="'.
price2num($up_ht_disc,
'MU').
'">';
915 print
'<input type="text" class="inputlotnumber quatrevingtquinzepercent" id="lot_number'.$suffix.
'" name="lot_number'.$suffix.
'" value="'.
GETPOST(
'lot_number'.$suffix).
'">';
917 if (empty($conf->global->PRODUCT_DISABLE_SELLBY)) {
918 print
'<td class="nowraponall">';
920 print $form->selectDate($dlcdatesuffix,
'dlc'.$suffix,
'',
'', 1,
'');
923 if (empty($conf->global->PRODUCT_DISABLE_EATBY)) {
924 print
'<td class="nowraponall">';
926 print $form->selectDate($dluodatesuffix,
'dluo'.$suffix,
'',
'', 1,
'');
929 print
'<td colspan="3"> </td>';
933 $colspan = (!empty($conf->global->PRODUCT_DISABLE_SELLBY)) ? --$colspan : $colspan;
934 $colspan = (!empty($conf->global->PRODUCT_DISABLE_EATBY)) ? --$colspan : $colspan;
939 'is_information_row' =>
true,
944 $reshook = $hookmanager->executeHooks(
945 'printFieldListValue',
953 print $hookmanager->resPrint;
957 print
'<!-- line no batch '.$numline.
' (not dispatched line yet for this order line) -->';
958 print
'<tr class="oddeven autoresettr" name="'.$type.$suffix.
'" data-remove="clear">';
959 print
'<td colspan="'.$colspan.
'">';
960 print
'<input id="fk_commandefourndet'.$suffix.
'" name="fk_commandefourndet'.$suffix.
'" type="hidden" value="'.$objp->rowid.
'">';
961 print
'<input id="idline'.$suffix.
'" name="idline'.$suffix.
'" type="hidden" value="-1">';
962 print
'<input name="product'.$suffix.
'" type="hidden" value="'.$objp->fk_product.
'">';
964 print
'<!-- This is a up (may include discount or not depending on STOCK_EXCLUDE_DISCOUNT_FOR_PMP. will be used for PMP calculation) -->';
965 if (!empty($conf->global->SUPPLIER_ORDER_EDIT_BUYINGPRICE_DURING_RECEIPT)) {
966 print $langs->trans(
"BuyingPrice").
': <input class="maxwidth75" name="pu'.$suffix.
'" data-type="text" value="'.
price2num($up_ht_disc,
'MU').
'">';
968 print
'<input class="maxwidth75" name="pu'.$suffix.
'" type="hidden" value="'.
price2num($up_ht_disc,
'MU').
'">';
974 print
'<td class="right">';
975 print
'<a href="#" id="reset'.$suffix.
'" class="resetline">'.
img_picto($langs->trans(
"Reset"),
'eraser',
'class="pictofixedwidth opacitymedium"').
'</a>';
976 print
'<input id="qty'.$suffix.
'" onchange="onChangeDispatchLineQty($(this))" name="qty'.$suffix.
'" data-index="'.$i.
'" data-type="text" class="width50 right qtydispatchinput" value="'.(GETPOSTISSET(
'qty'.$suffix) ?
GETPOST(
'qty'.$suffix,
'int') : (empty($conf->global->SUPPLIER_ORDER_DISPATCH_FORCE_QTY_INPUT_TO_ZERO) ? $remaintodispatch : 0)).
'" data-expected="'.$remaintodispatch.
'">';
979 if (isModEnabled(
'productbatch') && $objp->tobatch > 0) {
981 print
img_picto($langs->trans(
'AddStockLocationLine'),
'split.png',
'class="splitbutton" onClick="addDispatchLine('.$i.
', \''.$type.
'\')
"');
984 print img_picto($langs->trans('AddStockLocationLine'), 'split.png', 'class="splitbutton
" onClick="addDispatchLine(
'.$i.', \
''.$type.
'\')
"');
989 if (!empty($conf->global->SUPPLIER_ORDER_CAN_UPDATE_BUYINGPRICE_DURING_RECEIPT)) {
990 if (!isModEnabled("multicurrency
") && empty($conf->dynamicprices->enabled)) {
992 print '<td class="right
">';
993 print '<input id="pu
'.$suffix.'" name="pu
'.$suffix.'" type="text
" size="8
" value="'.price((GETPOST('pu
'.$suffix) != '' ? price2num(GETPOST('pu
'.$suffix)) : $up_ht_disc)).'">';
997 print '<td class="right
">';
998 print '<input id="dto
'.$suffix.'" name="dto
'.$suffix.'" type="text
" size="8
" value="'.(GETPOST('dto
'.$suffix) != '' ? GETPOST('dto
'.$suffix) : '').'">';
1002 print '<td class="center
">';
1003 print '<input class="flat checkformerge
" type="checkbox
" name="saveprice
'.$suffix.'" value="'.(GETPOST('saveprice
'.$suffix) != '' ? GETPOST('saveprice
'.$suffix) : '').'">';
1009 print '<td class="right
">';
1010 if (count($listwarehouses) > 1) {
1011 print $formproduct->selectWarehouses(GETPOST("entrepot
".$suffix) ?GETPOST("entrepot
".$suffix) : ($objp->fk_default_warehouse ? $objp->fk_default_warehouse : ''), "entrepot
".$suffix, '', 1, 0, $objp->fk_product, '', 1, 0, null, 'csswarehouse'.$suffix);
1012 } elseif (count($listwarehouses) == 1) {
1013 print $formproduct->selectWarehouses(GETPOST("entrepot
".$suffix) ?GETPOST("entrepot
".$suffix) : ($objp->fk_default_warehouse ? $objp->fk_default_warehouse : ''), "entrepot
".$suffix, '', 0, 0, $objp->fk_product, '', 1, 0, null, 'csswarehouse'.$suffix);
1015 $langs->load("errors
");
1016 print $langs->trans("ErrorNoWarehouseDefined
");
1020 // Enable hooks to append additional columns
1021 $parameters = array(
1022 'is_information_row' => false, // this is a dispatch form row
1024 'suffix' => $suffix,
1027 $reshook = $hookmanager->executeHooks(
1028 'printFieldListValue',
1034 setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
1036 print $hookmanager->resPrint;
1045 dol_print_error($db);
1052 print '<div class="center
">';
1053 $parameters = array();
1054 $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been
1056 if (empty($reshook)) {
1057 /*$checkboxlabel = $langs->trans("CloseReceivedSupplierOrdersAutomatically
", $langs->transnoentitiesnoconv('StatusOrderReceivedAll'));
1059 if (empty($conf->reception->enabled)) {
1060 print $langs->trans("Comment").' : ';
1061 print '<input type="text
" class="minwidth400
" maxlength="128
" name="comment
" value="';
1062 print GETPOSTISSET("comment") ? GETPOST("comment") : $langs->trans("DispatchSupplierOrder", $object->ref);
1063 // print ' /
'.$object->ref_supplier; // Not yet available
1064 print '" class="flat
"><br>';
1066 print '<input type="checkbox
" checked="checked
" name="closeopenorder
"> '.$checkboxlabel;
1069 $dispatchBt = empty($conf->reception->enabled) ? $langs->trans("Receive
") : $langs->trans("CreateReception
");
1074 print '<input type="submit
" id="submitform
" class="button" name="dispatch
" value="'.$langs->trans("Save").'"';
1076 if (!$permissiontoreceive) {
1079 if (count($listwarehouses) <= 0) {
1091 // Message if nothing to dispatch
1094 if (empty($conf->global->SUPPLIER_ORDER_DISABLE_STOCK_DISPATCH_WHEN_TOTAL_REACHED)) {
1095 print '<div class="opacitymedium
">'.$langs->trans("NoPredefinedProductToDispatch
").'</div>'; // No predefined line at all
1097 print '<div class="opacitymedium
">'.$langs->trans("NoMorePredefinedProductToDispatch
").'</div>'; // No predefined line that remain to be dispatched.
1104 print dol_get_fiche_end();
1106 // traitement entrepot par défaut
1107 print '<script type="text/javascript
">
1108 $(document).ready(function () {
1109 $("select[
name=fk_default_warehouse]
").change(function() {
1110 var fk_default_warehouse = $("option:selected
", this).val();
1111 $("select[
name^=entrepot_]
").val(fk_default_warehouse).change();
1114 $("#autoreset
").click(function() {
1115 $(".autoresettr
").each(function(){
1116 id = $(this).attr("name");
1117 idtab = id.split("_
");
1118 if ($(this).data("remove") == "clear
"){
1119 console.log("We clear the
object to expected value
")
1120 $("#qty_
"+idtab[1]+"_
"+idtab[2]).val("");
1122 qtyexpected = $("#qty_
"+idtab[1]+"_
"+idtab[2]).data("expected
")
1123 console.log(qtyexpected);
1124 $("#qty_
"+idtab[1]+"_
"+idtab[2]).val(qtyexpected);
1125 qtydispatched = $("#qty_dispatched_0_
"+idtab[2]).data("dispatched
")
1126 $("#qty_dispatched_0_
"+idtab[2]).val(qtydispatched);
1129 console.log("We
remove the
object")
1131 $("tr[
name^=\
'"+idtab[0]+"_\'][name$=\'_"+idtab[2]+"\']:last .splitbutton").show();
1137 $("#resetalltoexpected").click(function(){
1138 $(".qtydispatchinput").each(function(){
1139 console.log("We reset to expected "+$(this).attr("id")+" qty to dispatch");
1140 $(this).val($(this).data("expected"));
1145 $(".resetline").click(function(e){
1147 id = $(this).attr("id");
1148 id = id.split("reset_");
1149 console.log("Reset trigger for id = qty_"+id[1]);
1150 $("#qty_"+id[1]).val("");
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader()
Empty header.
Class to manage table commandefournisseurdispatch.
Class to manage predefined suppliers products.
Class to manage warehouses.
Class to manage products or services.
Class to manage projects.
Class to manage receptions.
Class to manage third parties objects (customers, suppliers, prospects...)
Class to manage Dolibarr users.
dol_stringtotime($string, $gm=1)
Convert a string date into a GM Timestamps date Warning: YYYY-MM-DDTHH:MM:SS+02:00 (RFC3339) is not s...
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.
dol_mktime($hour, $minute, $second, $month, $day, $year, $gm='auto', $check=1)
Return a timestamp date built from detailed informations (by default a local PHP server timestamp) Re...
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0)
Show tabs of a record.
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
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).
dol_now($mode='auto')
Return date for now.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0)
Set event messages in dol_events session object.
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.
ui dialog ui datepicker calendar ui widget content ui state ui datepicker calendar ui widget header ui state ui datepicker calendar ui button
0 = Do not include form tag and submit button -1 = Do not include form tag but include submit button
reception_prepare_head(Reception $object)
Prepare array with list of tabs.
$conf db name
Only used if Module[ID]Name translation string is not found.
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.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.