35require
'../main.inc.php';
36require_once DOL_DOCUMENT_ROOT.
'/core/modules/supplier_order/modules_commandefournisseur.php';
37require_once DOL_DOCUMENT_ROOT.
'/product/stock/class/entrepot.class.php';
38require_once DOL_DOCUMENT_ROOT.
'/core/lib/fourn.lib.php';
39require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.commande.class.php';
40require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.commande.dispatch.class.php';
41require_once DOL_DOCUMENT_ROOT.
'/product/class/html.formproduct.class.php';
42require_once DOL_DOCUMENT_ROOT.
'/product/stock/class/mouvementstock.class.php';
43require_once DOL_DOCUMENT_ROOT.
'/core/lib/reception.lib.php';
44require_once DOL_DOCUMENT_ROOT.
'/projet/class/project.class.php';
47$langs->loadLangs(array(
"bills",
"orders",
"sendings",
"companies",
"deliveries",
"products",
"stocks",
"receptions"));
49if (isModEnabled(
'productbatch')) {
50 $langs->load(
'productbatch');
57$action =
GETPOST(
'action',
'aZ09');
58$fk_default_warehouse =
GETPOSTINT(
'fk_default_warehouse');
59$cancel =
GETPOST(
'cancel',
'alpha');
60$confirm =
GETPOST(
'confirm',
'alpha');
66 $socid = $user->socid;
69$hookmanager->initHooks(array(
'ordersupplierdispatch'));
73if (GETPOSTISSET(
"projectid")) {
79if ($id > 0 || !empty($ref)) {
80 $result =
$object->fetch($id, $ref);
84 $result =
$object->fetch_thirdparty();
94 if ($origin ==
'order_supplier' &&
$object->origin_object->id && (isModEnabled(
"fournisseur") && !
getDolGlobalString(
'MAIN_USE_NEW_SUPPLIERMOD') || isModEnabled(
"supplier_order"))) {
95 $origin_id =
$object->origin_object->id;
97 $objectsrc->fetch($origin_id);
101if (empty($conf->reception->enabled)) {
102 $permissiontoreceive = $user->hasRight(
'fournisseur',
'commande',
'receptionner');
103 $permissiontocontrol = ((!
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') && $user->hasRight(
'fournisseur',
'commande',
'receptionner')) || (
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') && $user->hasRight(
'fournisseur',
'commande_advance',
'check')));
105 $permissiontoreceive = $user->hasRight(
'reception',
'creer');
106 $permissiontocontrol = ((!
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') && $user->hasRight(
'reception',
'creer')) || (
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') && $user->hasRight(
'reception',
'reception_advance',
'validate')));
112if (!isModEnabled(
'stock')) {
116$usercancreate = $user->hasRight(
'reception',
'creer');
117$permissiontoadd = $usercancreate;
124$parameters = array();
125$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
131if ($action ==
'updatelines' && $permissiontoreceive) {
138 foreach ($_POST as $key => $value) {
141 if (preg_match(
'/^product_.*([0-9]+)_([0-9]+)$/i', $key, $reg)) {
143 if (preg_match(
'/^product_([0-9]+)_([0-9]+)$/i', $key, $reg)) {
144 $modebatch =
"barcode";
145 } elseif (preg_match(
'/^product_batch_([0-9]+)_([0-9]+)$/i', $key, $reg)) {
146 $modebatch =
"batch";
150 if ($modebatch ==
"barcode") {
151 $prod =
"product_".$reg[1].
'_'.$reg[2];
153 $prod =
'product_batch_'.$reg[1].
'_'.$reg[2];
155 $qty =
"qty_".$reg[1].
'_'.$reg[2];
156 $ent =
"entrepot_".$reg[1].
'_'.$reg[2];
157 $pu =
"pu_".$reg[1].
'_'.$reg[2];
158 $fk_commandefourndet =
"fk_commandefourndet_".$reg[1].
'_'.$reg[2];
159 $idline =
GETPOST(
"idline_".$reg[1].
'_'.$reg[2]);
163 if ($modebatch ==
"batch") {
164 $lot =
GETPOST(
'lot_number_'.$reg[1].
'_'.$reg[2]);
170 if (!isModEnabled(
"multicurrency") && empty($conf->dynamicprices->enabled)) {
171 $dto =
GETPOSTINT(
"dto_".$reg[1].
'_'.$reg[2]);
175 $saveprice =
"saveprice_".$reg[1].
'_'.$reg[2];
180 if (($modebatch ==
"batch" &&
GETPOST($qty) > 0) || ($modebatch ==
"barcode" &&
GETPOST($qty) != 0)) {
182 dol_syslog(
'No dispatch for line '.$key.
' as no warehouse was chosen.');
183 $text = $langs->transnoentities(
'Warehouse').
', '.$langs->transnoentities(
'Line').
' '.($numline);
184 setEventMessages($langs->trans(
'ErrorFieldRequired', $text),
null,
'errors');
190 $result = $supplierorderdispatch->fetch($idline);
192 setEventMessages($supplierorderdispatch->error, $supplierorderdispatch->errors,
'errors');
195 $qtystart = $supplierorderdispatch->qty;
197 $supplierorderdispatch->fk_entrepot =
GETPOSTINT($ent);
198 if ($modebatch ==
"batch") {
199 $supplierorderdispatch->eatby = $dDLUO;
200 $supplierorderdispatch->sellby = $dDLC;
203 $result = $supplierorderdispatch->update($user);
205 setEventMessages($supplierorderdispatch->error, $supplierorderdispatch->errors,
'errors');
249 $result = $objectsrc->dispatchProduct($user,
GETPOSTINT($prod),
GETPOST($qty),
GETPOSTINT($ent),
GETPOST($pu),
GETPOST(
'comment'), $dDLUO, $dDLC, $lot,
GETPOSTINT($fk_commandefourndet), 0,
$object->id);
256 if (!$error &&
getDolGlobalString(
'SUPPLIER_ORDER_CAN_UPDATE_BUYINGPRICE_DURING_RECEIPT')) {
257 if (!isModEnabled(
"multicurrency") && empty($conf->dynamicprices->enabled)) {
264 if (GETPOSTISSET($saveprice)) {
266 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"product_fournisseur_price";
267 $sql .=
" SET unitprice='".price2num(
GETPOST($pu),
'MU').
"'";
268 $sql .=
", price=".price2num(
GETPOST($pu),
'MU').
"*quantity";
269 $sql .=
", remise_percent = ".((float) $dto);
270 $sql .=
" WHERE fk_soc=".((int)
$object->socid);
271 $sql .=
" AND fk_product=".(GETPOSTINT($prod));
273 $resql = $db->query($sql);
288 header(
"Location: ".DOL_URL_ROOT.
'/reception/dispatch.php?id='.
$object->id);
300$form =
new Form($db);
302$warehouse_static =
new Entrepot($db);
305$title =
$object->ref.
" - ".$langs->trans(
'ReceptionDistribution');
306$help_url =
'EN:Module_Suppliers_Orders|FR:CommandeFournisseur|ES:Módulo_Pedidos_a_proveedores';
307$morejs = array(
'/fourn/js/lib_dispatch.js.php');
310llxHeader(
'', $title, $help_url,
'', 0, 0, $morejs,
'',
'',
'mod-reception page-card_dispatch');
312if ($id > 0 || !empty($ref)) {
314 $object->origin =
'CommandeFournisseur';
317 $origin_id =
$object->origin_id;
323 $author =
new User($db);
324 $author->fetch(
$object->user_author_id);
328 $title = $langs->trans(
"SupplierOrder");
329 print
dol_get_fiche_head($head,
'dispatch', $langs->trans(
"Reception"), -1,
'dollyrevert');
335 if ($action ==
'ask_deleteline') {
336 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&lineid='.$lineid, $langs->trans(
'DeleteLine'), $langs->trans(
'ConfirmDeleteLine'),
'confirm_deleteline',
'', 0, 1);
340 $parameters = array(
'lineid' => $lineid);
342 $reshook = $hookmanager->executeHooks(
'formConfirm', $parameters, $object, $action);
343 if (empty($reshook)) {
344 $formconfirm .= $hookmanager->resPrint;
345 } elseif ($reshook > 0) {
346 $formconfirm = $hookmanager->resPrint;
353 $linkback =
'<a href="'.DOL_URL_ROOT.
'/reception/list.php?restore_lastsearch_values=1'.(!empty($socid) ?
'&socid='.$socid :
'').
'">'.$langs->trans(
"BackToList").
'</a>';
354 $morehtmlref =
'<div class="refidno">';
357 $morehtmlref .= $form->editfieldkey(
"RefSupplier",
'ref_supplier',
$object->ref_supplier, $object, $user->hasRight(
'reception',
'creer'),
'string',
'', 0, 1);
358 $morehtmlref .= $form->editfieldval(
"RefSupplier",
'ref_supplier',
$object->ref_supplier, $object, $user->hasRight(
'reception',
'creer'),
'string',
'',
null,
null,
'', 1);
361 $morehtmlref .=
'<br>'.$object->thirdparty->getNomUrl(1);
363 if (isModEnabled(
'project')) {
364 $langs->load(
"projects");
365 $morehtmlref .=
'<br>';
367 $morehtmlref .=
img_picto($langs->trans(
"Project"),
'project',
'class="pictofixedwidth"');
368 if ($action !=
'classify' && $permissiontoadd) {
369 $morehtmlref .=
'<a class="editfielda" href="'.$_SERVER[
'PHP_SELF'].
'?action=classify&token='.
newToken().
'&id='.
$object->id.
'">'.
img_edit($langs->transnoentitiesnoconv(
'SetProject')).
'</a> ';
371 $morehtmlref .= $form->form_project($_SERVER[
'PHP_SELF'].
'?id='.
$object->id, (!
getDolGlobalString(
'PROJECT_CAN_ALWAYS_LINK_TO_ALL_SUPPLIERS') ?
$object->socid : -1),
$object->fk_project, ($action ==
'classify' ?
'projectid' :
'none'), 0, 0, 0, 1,
'',
'maxwidth300');
373 if (!empty($objectsrc) && !empty($objectsrc->fk_project)) {
375 $proj->fetch($objectsrc->fk_project);
376 $morehtmlref .= $proj->getNomUrl(1);
378 $morehtmlref .=
'<span class="opacitymedium"> - '.dol_escape_htmltag($proj->title).
'</span>';
383 $morehtmlref .=
'</div>';
385 dol_banner_tab($object,
'ref', $linkback, 1,
'ref',
'ref', $morehtmlref);
388 print
'<div class="fichecenter">';
389 print
'<div class="underbanner clearboth"></div>';
391 print
'<table class="border tableforfield" width="100%">';
394 if ($typeobject ==
'commande' &&
$object->origin_object->id && isModEnabled(
'order')) {
396 print $langs->trans(
"RefOrder").
'</td>';
397 print
'<td colspan="3">';
398 print $objectsrc->getNomUrl(1,
'commande');
402 if ($typeobject ==
'propal' &&
$object->origin_object->id && isModEnabled(
"propal")) {
404 print $langs->trans(
"RefProposal").
'</td>';
405 print
'<td colspan="3">';
406 print $objectsrc->getNomUrl(1,
'reception');
410 if ($typeobject ==
'CommandeFournisseur' &&
$object->origin_object->id && isModEnabled(
"propal")) {
412 print $langs->trans(
"SupplierOrder").
'</td>';
413 print
'<td colspan="3">';
414 print $objectsrc->getNomUrl(1,
'reception');
420 print
'<tr><td class="titlefield">'.$langs->trans(
"DateCreation").
'</td>';
421 print
'<td colspan="3">'.dol_print_date(
$object->date_creation,
"dayhour",
"tzuserrel").
"</td>\n";
425 print
'<tr><td height="10">';
426 print
'<table class="nobordernopadding" width="100%"><tr><td>';
427 print $langs->trans(
'DateDeliveryPlanned');
429 print
'</tr></table>';
430 print
'</td><td colspan="2">';
436 print
'<br><br><center>';
437 print
'<a href="#" id="resetalltoexpected" class="marginrightonly paddingright marginleftonly paddingleft">'.img_picto(
"",
'autofill',
'class="pictofixedwidth"').$langs->trans(
"RestoreWithCurrentQtySaved").
'</a></td>';
439 print
'<a href="#" id="autoreset" class="marginrightonly paddingright marginleftonly paddingleft">'.img_picto(
"",
'eraser',
'class="pictofixedwidth"').$langs->trans(
"ClearQtys").
'</a></td>';
445 if (
$object->statut == Reception::STATUS_DRAFT || (
$object->statut == Reception::STATUS_VALIDATED && !
getDolGlobalString(
'STOCK_CALCULATE_ON_RECEPTION'))) {
446 require_once DOL_DOCUMENT_ROOT.
'/product/class/html.formproduct.class.php';
448 $formproduct->loadWarehouses();
450 $listwarehouses = $entrepot->list_array(1);
452 print
'<form method="post" action="'.$_SERVER[
"PHP_SELF"].
'">';
454 print
'<input type="hidden" name="token" value="'.newToken().
'">';
455 print
'<input type="hidden" name="action" value="updatelines">';
456 print
'<input type="hidden" name="id" value="'.$object->id.
'">';
458 print
'<div class="div-table-responsive-no-min">';
459 print
'<table class="noborder centpercent">';
462 $products_dispatched = array();
463 $sql =
"SELECT l.rowid, cfd.fk_product, sum(cfd.qty) as qty";
464 $sql .=
" FROM ".MAIN_DB_PREFIX.
"receptiondet_batch as cfd";
465 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"receptiondet_batch as l on l.rowid = cfd.fk_elementdet";
466 $sql .=
" WHERE cfd.fk_reception = ".((int)
$object->id);
467 $sql .=
" GROUP BY l.rowid, cfd.fk_product";
469 $resql = $db->query($sql);
471 $num = $db->num_rows($resql);
476 $objd = $db->fetch_object($resql);
477 $products_dispatched[$objd->rowid] =
price2num($objd->qty,
'MS');
486 $sql =
"SELECT l.rowid, l.fk_product, l.subprice, l.remise_percent, l.ref AS sref, l.qty as qty,";
487 $sql .=
" p.ref, p.label, p.tobatch, p.fk_default_warehouse";
489 $parameters = array();
490 $reshook = $hookmanager->executeHooks(
491 'printFieldListSelect',
499 $sql .= $hookmanager->resPrint;
500 $sql .=
" FROM ".MAIN_DB_PREFIX.
"commande_fournisseurdet as l";
501 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"product as p ON l.fk_product=p.rowid";
502 $sql .=
" WHERE l.fk_commande = ".((int) $objectsrc->id);
504 $sql .=
" AND l.product_type = 0";
507 $parameters = array();
508 $reshook = $hookmanager->executeHooks(
509 'printFieldListWhere',
517 $sql .= $hookmanager->resPrint;
520 $sql .=
" ORDER BY l.rang, p.ref, p.label";
522 $resql = $db->query($sql);
524 $num = $db->num_rows($resql);
528 print
'<tr class="liste_titre">';
530 print
'<td>'.$langs->trans(
"Description").
'</td>';
531 if (isModEnabled(
'productbatch')) {
532 print
'<td class="dispatch_batch_number_title">'.$langs->trans(
"batch_number").
'</td>';
534 print
'<td class="dispatch_dlc_title">'.$langs->trans(
"SellByDate").
'</td>';
537 print
'<td class="dispatch_dluo_title">'.$langs->trans(
"EatByDate").
'</td>';
544 print
'<td class="right">'.$langs->trans(
"SupplierRef").
'</td>';
545 print
'<td class="right">'.$langs->trans(
"QtyOrdered").
'</td>';
546 if (
$object->status == Reception::STATUS_DRAFT) {
547 print
'<td class="right">'.$langs->trans(
"QtyToReceive");
549 print
'<td class="right">'.$langs->trans(
"QtyDispatchedShort").
'</td>';
551 print
'<td class="right">'.$langs->trans(
"Details");
552 print
'<td width="32"></td>';
555 if (!isModEnabled(
"multicurrency") && empty($conf->dynamicprices->enabled)) {
556 print
'<td class="right">'.$langs->trans(
"Price").
'</td>';
557 print
'<td class="right">'.$langs->trans(
"ReductionShort").
' (%)</td>';
558 print
'<td class="right">'.$langs->trans(
"UpdatePrice").
'</td>';
562 print
'<td align="right">'.$langs->trans(
"Warehouse");
565 if (count($listwarehouses) > 1) {
566 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);
567 } elseif (count($listwarehouses) == 1) {
568 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);
574 $parameters = array();
575 $reshook = $hookmanager->executeHooks(
576 'printFieldListTitle',
584 print $hookmanager->resPrint;
593 $conf->cache[
'product'] = array();
597 $objp = $db->fetch_object($resql);
600 if (!$objp->fk_product > 0) {
603 $alreadydispatched = isset($products_dispatched[$objp->rowid]) ? $products_dispatched[$objp->rowid] : 0;
604 $remaintodispatch =
price2num($objp->qty, 5);
605 if ($remaintodispatch < 0 && !
getDolGlobalString(
'SUPPLIER_ORDER_ALLOW_NEGATIVE_QTY_FOR_SUPPLIER_ORDER_RETURN')) {
606 $remaintodispatch = 0;
609 if ($remaintodispatch || !
getDolGlobalString(
'SUPPLIER_ORDER_DISABLE_STOCK_DISPATCH_WHEN_TOTAL_REACHED')) {
618 print
'<!-- Line to dispatch '.$suffix.
' -->'.
"\n";
620 print
'<input id="qty_ordered'.$suffix.
'" type="hidden" value="'.$objp->qty.
'">';
621 print
'<input id="qty_dispatched'.$suffix.
'" type="hidden" data-dispatched="'.((float) $alreadydispatched).
'" value="'.(float) $alreadydispatched.
'">';
622 print
'<tr class="oddeven">';
624 if (empty($conf->cache[
'product'][$objp->fk_product])) {
625 $tmpproduct =
new Product($db);
626 $tmpproduct->fetch($objp->fk_product);
627 $conf->cache[
'product'][$objp->fk_product] = $tmpproduct;
629 $tmpproduct = $conf->cache[
'product'][$objp->fk_product];
632 $linktoprod = $tmpproduct->getNomUrl(1);
633 $linktoprod .=
' - '.$objp->label.
"\n";
635 if (isModEnabled(
'productbatch')) {
636 if ($objp->tobatch) {
641 print
'<td class="dispatch_batch_number"></td>';
643 print
'<td class="dispatch_dlc"></td>';
646 print
'<td class="dispatch_dluo"></td>';
653 print
'<td class="dispatch_batch_number">';
654 print
'<span class="opacitymedium small">'.$langs->trans(
"ProductDoesNotUseBatchSerial").
'</small>';
657 print
'<td class="dispatch_dlc"></td>';
660 print
'<td class="dispatch_dluo"></td>';
664 print
'<td colspan="4">';
670 $up_ht_disc = $objp->subprice;
671 if (!empty($objp->remise_percent) && !
getDolGlobalString(
'STOCK_EXCLUDE_DISCOUNT_FOR_PMP')) {
672 $up_ht_disc =
price2num($up_ht_disc * (100 - $objp->remise_percent) / 100,
'MU');
676 print
'<td class="right">'.$objp->sref.
'</td>';
679 print
'<td class="right">'.$objp->qty.
'</td>';
682 print
'<td class="right">'.$alreadydispatched.
'</td>';
684 print
'<td class="right">';
690 $sql =
"SELECT cfd.rowid, cfd.qty, cfd.fk_entrepot, cfd.batch, cfd.eatby, cfd.sellby, cfd.fk_product";
691 $sql .=
" FROM ".MAIN_DB_PREFIX.
"receptiondet_batch as cfd";
692 $sql .=
" WHERE cfd.fk_reception = ".((int)
$object->id);
693 $sql .=
" AND cfd.fk_element = ".((int) $objectsrc->id);
694 $sql .=
" AND cfd.fk_elementdet = ".(int) $objp->rowid;
697 $resultsql = $db->query($sql);
700 $numd = $db->num_rows($resultsql);
703 $suffix =
"_".$j.
"_".$i;
704 $objd = $db->fetch_object($resultsql);
706 if (isModEnabled(
'productbatch') && (!empty($objd->batch) || (is_null($objd->batch) && $tmpproduct->status_batch > 0))) {
712 'is_information_row' =>
true,
717 $reshook = $hookmanager->executeHooks(
718 'printFieldListValue',
726 print $hookmanager->resPrint;
730 print
'<!-- line for batch '.$numline.
' -->';
731 print
'<tr class="oddeven autoresettr" name="'.$type.$suffix.
'" data-remove="clear">';
733 print
'<input id="fk_commandefourndet'.$suffix.
'" name="fk_commandefourndet'.$suffix.
'" type="hidden" value="'.$objp->rowid.
'">';
734 print
'<input id="idline'.$suffix.
'" name="idline'.$suffix.
'" type="hidden" value="'.$objd->rowid.
'">';
735 print
'<input name="product_batch'.$suffix.
'" type="hidden" value="'.$objd->fk_product.
'">';
737 print
'<!-- This is a U.P. (may include discount or not depending on STOCK_EXCLUDE_DISCOUNT_FOR_PMP. will be used for PMP calculation) -->';
739 print $langs->trans(
"BuyingPrice").
': <input class="maxwidth75" name="pu'.$suffix.
'" type="text" value="'.
price2num($up_ht_disc,
'MU').
'">';
741 print
'<input class="maxwidth75" name="pu'.$suffix.
'" type="hidden" value="'.
price2num($up_ht_disc,
'MU').
'">';
747 print
'<input disabled="" type="text" class="inputlotnumber quatrevingtquinzepercent" id="lot_number'.$suffix.
'" name="lot_number'.$suffix.
'" value="'.(GETPOSTISSET(
'lot_number'.$suffix) ?
GETPOST(
'lot_number'.$suffix) : $objd->batch).
'">';
750 print
'<td class="nowraponall">';
752 print $form->selectDate($dlcdatesuffix,
'dlc'.$suffix, 0, 0, 1,
'');
756 print
'<td class="nowraponall">';
758 print $form->selectDate($dluodatesuffix,
'dluo'.$suffix, 0, 0, 1,
'');
761 print
'<td colspan="3"> </td>';
771 'is_information_row' =>
true,
776 $reshook = $hookmanager->executeHooks(
777 'printFieldListValue',
785 print $hookmanager->resPrint;
789 print
'<!-- line no batch '.$numline.
' -->';
790 print
'<tr class="oddeven autoresettr" name="'.$type.$suffix.
'" data-remove="clear">';
791 print
'<td colspan="'.$colspan.
'">';
792 print
'<input id="fk_commandefourndet'.$suffix.
'" name="fk_commandefourndet'.$suffix.
'" type="hidden" value="'.$objp->rowid.
'">';
793 print
'<input id="idline'.$suffix.
'" name="idline'.$suffix.
'" type="hidden" value="'.$objd->rowid.
'">';
794 print
'<input name="product'.$suffix.
'" type="hidden" value="'.$objd->fk_product.
'">';
796 print
'<!-- This is a up (may include discount or not depending on STOCK_EXCLUDE_DISCOUNT_FOR_PMP. will be used for PMP calculation) -->';
798 print $langs->trans(
"BuyingPrice").
': <input class="maxwidth75" name="pu'.$suffix.
'" type="text" value="'.
price2num($up_ht_disc,
'MU').
'">';
800 print
'<input class="maxwidth75" name="pu'.$suffix.
'" type="hidden" value="'.
price2num($up_ht_disc,
'MU').
'">';
806 print
'<td class="right">';
807 print
'<a href="#" id="reset'.$suffix.
'" class="resetline">'.
img_picto($langs->trans(
"Reset"),
'eraser',
'class="pictofixedwidth opacitymedium"').
'</a>';
808 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) ?
GETPOSTINT(
'qty'.$suffix) : $objd->qty).
'" data-expected="'.$objd->qty.
'">';
811 if (isModEnabled(
'productbatch') && $objp->tobatch > 0) {
813 print
img_picto($langs->trans(
'AddStockLocationLine'),
'split.png',
'class="splitbutton" '.($numd != $j + 1 ?
'style="display:none"' :
'').
' onClick="addDispatchLine('.$i.
', \''.$type.
'\')"');
816 print
img_picto($langs->trans(
'AddStockLocationLine'),
'split.png',
'class="splitbutton" '.($numd != $j + 1 ?
'style="display:none"' :
'').
' onClick="addDispatchLine('.$i.
', \''.$type.
'\')"');
822 if (!isModEnabled(
"multicurrency") && empty($conf->dynamicprices->enabled)) {
824 print
'<td class="right">';
825 print
'<input id="pu'.$suffix.
'" name="pu'.$suffix.
'" type="text" size="8" value="'.
price((
GETPOST(
'pu'.$suffix) !=
'' ?
price2num(
GETPOST(
'pu'.$suffix)) : $up_ht_disc)).
'">';
829 print
'<td class="right">';
830 print
'<input id="dto'.$suffix.
'" name="dto'.$suffix.
'" type="text" size="8" value="'.(
GETPOST(
'dto'.$suffix) !=
'' ?
GETPOST(
'dto'.$suffix) :
'').
'">';
834 print
'<td class="center">';
835 print
'<input class="flat checkformerge" type="checkbox" name="saveprice'.$suffix.
'" value="'.(
GETPOST(
'saveprice'.$suffix) !=
'' ?
GETPOST(
'saveprice'.$suffix) :
'').
'">';
841 print
'<td class="right">';
842 if (count($listwarehouses) > 1) {
843 print $formproduct->selectWarehouses(
GETPOST(
"entrepot".$suffix) ?
GETPOST(
"entrepot".$suffix) : $objd->fk_entrepot,
"entrepot".$suffix,
'', 1, 0, $objp->fk_product,
'', 1, 0, null,
'csswarehouse'.$suffix);
844 } elseif (count($listwarehouses) == 1) {
845 print $formproduct->selectWarehouses(
GETPOST(
"entrepot".$suffix) ?
GETPOST(
"entrepot".$suffix) : $objd->fk_entrepot,
"entrepot".$suffix,
'', 0, 0, $objp->fk_product,
'', 1, 0, null,
'csswarehouse'.$suffix);
847 $langs->load(
"errors");
848 print $langs->trans(
"ErrorNoWarehouseDefined");
854 'is_information_row' =>
false,
859 $reshook = $hookmanager->executeHooks(
860 'printFieldListValue',
868 print $hookmanager->resPrint;
875 $suffix =
"_".$j.
"_".$i;
879 if (isModEnabled(
'productbatch') && !empty($objp->tobatch)) {
885 'is_information_row' =>
true,
890 $reshook = $hookmanager->executeHooks(
891 'printFieldListValue',
899 print $hookmanager->resPrint;
903 print
'<!-- line for batch '.$numline.
' (not dispatched line yet for this order line) -->';
904 print
'<tr class="oddeven autoresettr" name="'.$type.$suffix.
'">';
906 print
'<input id="fk_commandefourndet'.$suffix.
'" name="fk_commandefourndet'.$suffix.
'" type="hidden" value="'.$objp->rowid.
'">';
907 print
'<input id="idline'.$suffix.
'" name="idline'.$suffix.
'" type="hidden" value="-1">';
908 print
'<input name="product_batch'.$suffix.
'" type="hidden" value="'.$objp->fk_product.
'">';
910 print
'<!-- This is a up (may include discount or not depending on STOCK_EXCLUDE_DISCOUNT_FOR_PMP. will be used for PMP calculation) -->';
912 print $langs->trans(
"BuyingPrice").
': <input class="maxwidth75" name="pu'.$suffix.
'" type="text" value="'.
price2num($up_ht_disc,
'MU').
'">';
914 print
'<input class="maxwidth75" name="pu'.$suffix.
'" type="hidden" value="'.
price2num($up_ht_disc,
'MU').
'">';
920 print
'<input type="text" class="inputlotnumber quatrevingtquinzepercent" id="lot_number'.$suffix.
'" name="lot_number'.$suffix.
'" value="'.
GETPOST(
'lot_number'.$suffix).
'">';
923 print
'<td class="nowraponall">';
925 print $form->selectDate($dlcdatesuffix,
'dlc'.$suffix, 0, 0, 1,
'');
929 print
'<td class="nowraponall">';
931 print $form->selectDate($dluodatesuffix,
'dluo'.$suffix, 0, 0, 1,
'');
934 print
'<td colspan="3"> </td>';
944 'is_information_row' =>
true,
949 $reshook = $hookmanager->executeHooks(
950 'printFieldListValue',
958 print $hookmanager->resPrint;
962 print
'<!-- line no batch '.$numline.
' (not dispatched line yet for this order line) -->';
963 print
'<tr class="oddeven autoresettr" name="'.$type.$suffix.
'" data-remove="clear">';
964 print
'<td colspan="'.$colspan.
'">';
965 print
'<input id="fk_commandefourndet'.$suffix.
'" name="fk_commandefourndet'.$suffix.
'" type="hidden" value="'.$objp->rowid.
'">';
966 print
'<input id="idline'.$suffix.
'" name="idline'.$suffix.
'" type="hidden" value="-1">';
967 print
'<input name="product'.$suffix.
'" type="hidden" value="'.$objp->fk_product.
'">';
969 print
'<!-- This is a up (may include discount or not depending on STOCK_EXCLUDE_DISCOUNT_FOR_PMP. will be used for PMP calculation) -->';
971 print $langs->trans(
"BuyingPrice").
': <input class="maxwidth75" name="pu'.$suffix.
'" data-type="text" value="'.
price2num($up_ht_disc,
'MU').
'">';
973 print
'<input class="maxwidth75" name="pu'.$suffix.
'" type="hidden" value="'.
price2num($up_ht_disc,
'MU').
'">';
979 print
'<td class="right">';
980 print
'<a href="#" id="reset'.$suffix.
'" class="resetline">'.
img_picto($langs->trans(
"Reset"),
'eraser',
'class="pictofixedwidth opacitymedium"').
'</a>';
981 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) ?
GETPOSTINT(
'qty'.$suffix) : (!
getDolGlobalString(
'SUPPLIER_ORDER_DISPATCH_FORCE_QTY_INPUT_TO_ZERO') ? $remaintodispatch : 0)).
'" data-expected="'.$remaintodispatch.
'">';
984 if (isModEnabled(
'productbatch') && $objp->tobatch > 0) {
986 print
img_picto($langs->trans(
'AddStockLocationLine'),
'split.png',
'class="splitbutton" onClick="addDispatchLine('.$i.
', \''.$type.
'\')
"');
989 print img_picto($langs->trans('AddStockLocationLine'), 'split.png', 'class="splitbutton
" onClick="addDispatchLine(
'.$i.', \
''.$type.
'\')
"');
994 if (getDolGlobalString('SUPPLIER_ORDER_CAN_UPDATE_BUYINGPRICE_DURING_RECEIPT')) {
995 if (!isModEnabled("multicurrency
") && empty($conf->dynamicprices->enabled)) {
997 print '<td class="right
">';
998 print '<input id="pu
'.$suffix.'" name="pu
'.$suffix.'" type="text
" size="8
" value="'.price((GETPOST('pu
'.$suffix) != '' ? price2num(GETPOST('pu
'.$suffix)) : $up_ht_disc)).'">';
1002 print '<td class="right
">';
1003 print '<input id="dto
'.$suffix.'" name="dto
'.$suffix.'" type="text
" size="8
" value="'.(GETPOST('dto
'.$suffix) != '' ? GETPOST('dto
'.$suffix) : '').'">';
1007 print '<td class="center
">';
1008 print '<input class="flat checkformerge
" type="checkbox
" name="saveprice
'.$suffix.'" value="'.(GETPOST('saveprice
'.$suffix) != '' ? GETPOST('saveprice
'.$suffix) : '').'">';
1014 print '<td class="right
">';
1015 if (count($listwarehouses) > 1) {
1016 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);
1017 } elseif (count($listwarehouses) == 1) {
1018 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);
1020 $langs->load("errors
");
1021 print $langs->trans("ErrorNoWarehouseDefined
");
1025 // Enable hooks to append additional columns
1026 $parameters = array(
1027 'is_information_row' => false, // this is a dispatch form row
1029 'suffix' => $suffix,
1032 $reshook = $hookmanager->executeHooks(
1033 'printFieldListValue',
1039 setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
1041 print $hookmanager->resPrint;
1050 dol_print_error($db);
1057 print '<div class="center
">';
1058 $parameters = array();
1059 $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been
1061 if (empty($reshook)) {
1062 /*$checkboxlabel = $langs->trans("CloseReceivedSupplierOrdersAutomatically
", $langs->transnoentitiesnoconv('StatusOrderReceivedAll'));
1064 if (empty($conf->reception->enabled)) {
1065 print $langs->trans("Comment").' : ';
1066 print '<input type="text
" class="minwidth400
" maxlength="128
" name="comment
" value="';
1067 print GETPOSTISSET("comment") ? GETPOST("comment") : $langs->trans("DispatchSupplierOrder", $object->ref);
1068 // print ' /
'.$object->ref_supplier; // Not yet available
1069 print '" class="flat
"><br>';
1071 print '<input type="checkbox
" checked="checked
" name="closeopenorder
"> '.$checkboxlabel;
1074 $dispatchBt = empty($conf->reception->enabled) ? $langs->trans("Receive
") : $langs->trans("CreateReception
");
1079 print '<input type="submit
" id="submitform
" class="button" name="dispatch
" value="'.$langs->trans("Save").'"';
1081 if (!$permissiontoreceive) {
1084 if (count($listwarehouses) <= 0) {
1096 // Message if nothing to dispatch
1099 if (!getDolGlobalString('SUPPLIER_ORDER_DISABLE_STOCK_DISPATCH_WHEN_TOTAL_REACHED')) {
1100 print '<div class="opacitymedium
">'.$langs->trans("NoPredefinedProductToDispatch
").'</div>'; // No predefined line at all
1102 print '<div class="opacitymedium
">'.$langs->trans("NoMorePredefinedProductToDispatch
").'</div>'; // No predefined line that remain to be dispatched.
1109 print dol_get_fiche_end();
1111 // traitement entrepot par défaut
1112 print '<script type="text/javascript
">
1113 $(document).ready(function () {
1114 $("select[
name=fk_default_warehouse]
").change(function() {
1115 var fk_default_warehouse = $("option:selected
", this).val();
1116 $("select[
name^=entrepot_]
").val(fk_default_warehouse).change();
1119 $("#autoreset
").click(function() {
1120 $(".autoresettr
").each(function(){
1121 id = $(this).attr("name");
1122 idtab = id.split("_
");
1123 if ($(this).data("remove") == "clear
"){
1124 console.log("We clear the
object to expected value
")
1125 $("#qty_
"+idtab[1]+"_
"+idtab[2]).val("");
1127 qtyexpected = $("#qty_
"+idtab[1]+"_
"+idtab[2]).data("expected
")
1128 console.log(qtyexpected);
1129 $("#qty_
"+idtab[1]+"_
"+idtab[2]).val(qtyexpected);
1130 qtydispatched = $("#qty_dispatched_0_
"+idtab[2]).data("dispatched
")
1131 $("#qty_dispatched_0_
"+idtab[2]).val(qtydispatched);
1134 console.log("We
remove the
object")
1136 $("tr[
name^=\
'"+idtab[0]+"_\'][name$=\'_"+idtab[2]+"\']:last .splitbutton").show();
1142 $("#resetalltoexpected").click(function(){
1143 $(".qtydispatchinput").each(function(){
1144 console.log("We reset to expected "+$(this).attr("id")+" qty to dispatch");
1145 $(this).val($(this).data("expected"));
1150 $(".resetline").click(function(e){
1152 id = $(this).attr("id");
1153 id = id.split("reset_");
1154 console.log("Reset trigger for id = qty_"+id[1]);
1155 $("#qty_"+id[1]).val("");
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
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 ReceptionLineBatch.
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_mktime($hour, $minute, $second, $month, $day, $year, $gm='auto', $check=1)
Return a timestamp date built from detailed information (by default a local PHP server timestamp) Rep...
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
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_now($mode='auto')
Return date for now.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
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.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0)
Set event messages in dol_events session object.
getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
img_edit($titlealt='default', $float=0, $other='')
Show logo edit/modify fiche.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
treeview li table
No Email.
ui state ui widget content ui state ui widget header ui state a 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.