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';
55$langs->loadLangs(array(
"bills",
"orders",
"sendings",
"companies",
"deliveries",
"products",
"stocks",
"receptions"));
57if (isModEnabled(
'productbatch')) {
58 $langs->load(
'productbatch');
65$action =
GETPOST(
'action',
'aZ09');
66$fk_default_warehouse =
GETPOSTINT(
'fk_default_warehouse');
67$cancel =
GETPOST(
'cancel',
'alpha');
68$confirm =
GETPOST(
'confirm',
'alpha');
74 $socid = $user->socid;
77$hookmanager->initHooks(array(
'ordersupplierdispatch'));
81if (GETPOSTISSET(
"projectid")) {
87if ($id > 0 || !empty($ref)) {
88 $result =
$object->fetch($id, $ref);
92 $result =
$object->fetch_thirdparty();
102 if ($origin ==
'order_supplier' &&
$object->origin_object->id && (isModEnabled(
"fournisseur") && !
getDolGlobalString(
'MAIN_USE_NEW_SUPPLIERMOD') || isModEnabled(
"supplier_order"))) {
103 $origin_id =
$object->origin_object->id;
105 $objectsrc->fetch($origin_id);
109if (empty(
$conf->reception->enabled)) {
110 $permissiontoreceive = $user->hasRight(
'fournisseur',
'commande',
'receptionner');
111 $permissiontocontrol = ((!
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') && $user->hasRight(
'fournisseur',
'commande',
'receptionner')) || (
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') && $user->hasRight(
'fournisseur',
'commande_advance',
'check')));
113 $permissiontoreceive = $user->hasRight(
'reception',
'creer');
114 $permissiontocontrol = ((!
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') && $user->hasRight(
'reception',
'creer')) || (
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') && $user->hasRight(
'reception',
'reception_advance',
'validate')));
120if (!isModEnabled(
'stock')) {
124$usercancreate = $user->hasRight(
'reception',
'creer');
125$permissiontoadd = $usercancreate;
132$parameters = array();
133$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
139if ($action ==
'updatelines' && $permissiontoreceive) {
146 foreach ($_POST as $key => $value) {
149 if (preg_match(
'/^product_.*([0-9]+)_([0-9]+)$/i', $key, $reg)) {
152 if (preg_match(
'/^product_([0-9]+)_([0-9]+)$/i', $key, $reg)) {
153 $modebatch =
"barcode";
154 } elseif (preg_match(
'/^product_batch_([0-9]+)_([0-9]+)$/i', $key, $reg)) {
155 $modebatch =
"batch";
159 if ($modebatch ==
"barcode") {
160 $prod =
"product_".$reg[1].
'_'.$reg[2];
162 $prod =
'product_batch_'.$reg[1].
'_'.$reg[2];
164 $qty =
"qty_".$reg[1].
'_'.$reg[2];
165 $ent =
"entrepot_".$reg[1].
'_'.$reg[2];
166 $pu =
"pu_".$reg[1].
'_'.$reg[2];
167 $fk_commandefourndet =
"fk_commandefourndet_".$reg[1].
'_'.$reg[2];
168 $idline =
GETPOSTINT(
"idline_".$reg[1].
'_'.$reg[2]);
172 if ($modebatch ==
"batch") {
173 $lot =
GETPOST(
'lot_number_'.$reg[1].
'_'.$reg[2]);
178 $saveprice =
'__invalidsavepricekey__';
180 if (!isModEnabled(
"multicurrency") && empty(
$conf->dynamicprices->enabled)) {
181 $dto =
GETPOSTINT(
"dto_".$reg[1].
'_'.$reg[2]);
185 $saveprice =
"saveprice_".$reg[1].
'_'.$reg[2];
190 if (($modebatch ==
"batch" &&
GETPOST($qty) > 0) || ($modebatch ==
"barcode" &&
GETPOST($qty) != 0)) {
192 dol_syslog(
'No dispatch for line '.$key.
' as no warehouse was chosen.');
193 $text = $langs->transnoentities(
'Warehouse').
', '.$langs->transnoentities(
'Line').
' '.($numline);
194 setEventMessages($langs->trans(
'ErrorFieldRequired', $text),
null,
'errors');
200 $result = $supplierorderdispatch->fetch($idline);
202 setEventMessages($supplierorderdispatch->error, $supplierorderdispatch->errors,
'errors');
205 $qtystart = $supplierorderdispatch->qty;
207 $supplierorderdispatch->fk_entrepot =
GETPOSTINT($ent);
208 if ($modebatch ==
"batch") {
209 $supplierorderdispatch->eatby = $dDLUO;
210 $supplierorderdispatch->sellby = $dDLC;
213 $result = $supplierorderdispatch->update($user);
215 setEventMessages($supplierorderdispatch->error, $supplierorderdispatch->errors,
'errors');
259 $result = $objectsrc->dispatchProduct($user,
GETPOSTINT($prod),
GETPOSTFLOAT($qty),
GETPOSTINT($ent),
GETPOSTFLOAT($pu),
GETPOST(
'comment'), $dDLUO, $dDLC, $lot,
GETPOSTINT($fk_commandefourndet), 0,
$object->id);
266 if (!$error &&
getDolGlobalString(
'SUPPLIER_ORDER_CAN_UPDATE_BUYINGPRICE_DURING_RECEIPT')) {
267 if (!isModEnabled(
"multicurrency") && empty(
$conf->dynamicprices->enabled)) {
274 if (GETPOSTISSET($saveprice)) {
276 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"product_fournisseur_price";
277 $sql .=
" SET unitprice='".price2num(
GETPOST($pu),
'MU').
"'";
278 $sql .=
", price=".price2num(
GETPOST($pu),
'MU').
"*quantity";
279 $sql .=
", remise_percent = ".((float) $dto);
280 $sql .=
" WHERE fk_soc=".((int)
$object->socid);
281 $sql .=
" AND fk_product=".(GETPOSTINT($prod));
283 $resql = $db->query($sql);
298 header(
"Location: ".DOL_URL_ROOT.
'/reception/dispatch.php?id='.
$object->id);
310$form =
new Form($db);
312$warehouse_static =
new Entrepot($db);
315$title =
$object->ref.
" - ".$langs->trans(
'ReceptionDistribution');
316$help_url =
'EN:Module_Suppliers_Orders|FR:CommandeFournisseur|ES:Módulo_Pedidos_a_proveedores';
317$morejs = array(
'/fourn/js/lib_dispatch.js.php');
320llxHeader(
'', $title, $help_url,
'', 0, 0, $morejs,
'',
'',
'mod-reception page-card_dispatch');
322if ($id > 0 || !empty($ref)) {
325 $object->origin =
'CommandeFournisseur';
328 $origin_id =
$object->origin_id;
334 $author =
new User($db);
335 $author->fetch(
$object->user_author_id);
339 $title = $langs->trans(
"SupplierOrder");
340 print
dol_get_fiche_head($head,
'dispatch', $langs->trans(
"Reception"), -1,
'dollyrevert');
346 if ($action ==
'ask_deleteline') {
347 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&lineid='.$lineid, $langs->trans(
'DeleteLine'), $langs->trans(
'ConfirmDeleteLine'),
'confirm_deleteline',
'', 0, 1);
351 $parameters = array(
'lineid' => $lineid);
353 $reshook = $hookmanager->executeHooks(
'formConfirm', $parameters, $object, $action);
354 if (empty($reshook)) {
355 $formconfirm .= $hookmanager->resPrint;
356 } elseif ($reshook > 0) {
357 $formconfirm = $hookmanager->resPrint;
364 $linkback =
'<a href="'.DOL_URL_ROOT.
'/reception/list.php?restore_lastsearch_values=1'.(!empty($socid) ?
'&socid='.$socid :
'').
'">'.$langs->trans(
"BackToList").
'</a>';
365 $morehtmlref =
'<div class="refidno">';
368 $morehtmlref .= $form->editfieldkey(
"RefSupplier",
'ref_supplier',
$object->ref_supplier, $object, $user->hasRight(
'reception',
'creer'),
'string',
'', 0, 1);
369 $morehtmlref .= $form->editfieldval(
"RefSupplier",
'ref_supplier',
$object->ref_supplier, $object, $user->hasRight(
'reception',
'creer'),
'string',
'',
null,
null,
'', 1);
372 $morehtmlref .=
'<br>'.$object->thirdparty->getNomUrl(1);
374 if (isModEnabled(
'project')) {
375 $langs->load(
"projects");
376 $morehtmlref .=
'<br>';
378 $morehtmlref .=
img_picto($langs->trans(
"Project"),
'project',
'class="pictofixedwidth"');
379 if ($action !=
'classify' && $permissiontoadd) {
380 $morehtmlref .=
'<a class="editfielda" href="'.$_SERVER[
'PHP_SELF'].
'?action=classify&token='.
newToken().
'&id='.
$object->id.
'">'.
img_edit($langs->transnoentitiesnoconv(
'SetProject')).
'</a> ';
382 $morehtmlref .= $form->form_project($_SERVER[
'PHP_SELF'].
'?id='.
$object->id, (!
getDolGlobalString(
'PROJECT_CAN_ALWAYS_LINK_TO_ALL_SUPPLIERS') ?
$object->socid : -1), (string)
$object->fk_project, ($action ==
'classify' ?
'projectid' :
'none'), 0, 0, 0, 1,
'',
'maxwidth300');
384 if (!empty($objectsrc) && !empty($objectsrc->fk_project)) {
386 $proj->fetch($objectsrc->fk_project);
387 $morehtmlref .= $proj->getNomUrl(1);
389 $morehtmlref .=
'<span class="opacitymedium"> - '.dol_escape_htmltag($proj->title).
'</span>';
394 $morehtmlref .=
'</div>';
396 dol_banner_tab($object,
'ref', $linkback, 1,
'ref',
'ref', $morehtmlref);
399 print
'<div class="fichecenter">';
400 print
'<div class="underbanner clearboth"></div>';
402 print
'<table class="border tableforfield" width="100%">';
405 if ($typeobject ==
'commande' &&
$object->origin_object->id && isModEnabled(
'order')) {
407 print $langs->trans(
"RefOrder").
'</td>';
408 print
'<td colspan="3">';
409 print $objectsrc->getNomUrl(1,
'commande');
413 if ($typeobject ==
'propal' &&
$object->origin_object->id && isModEnabled(
"propal")) {
415 print $langs->trans(
"RefProposal").
'</td>';
416 print
'<td colspan="3">';
417 print $objectsrc->getNomUrl(1,
'reception');
421 if ($typeobject ==
'CommandeFournisseur' &&
$object->origin_object->id && isModEnabled(
"propal")) {
423 print $langs->trans(
"SupplierOrder").
'</td>';
424 print
'<td colspan="3">';
425 print $objectsrc->getNomUrl(1,
'reception');
431 print
'<tr><td class="titlefield">'.$langs->trans(
"DateCreation").
'</td>';
432 print
'<td colspan="3">'.dol_print_date(
$object->date_creation,
"dayhour",
"tzuserrel").
"</td>\n";
436 print
'<tr><td height="10">';
437 print
'<table class="nobordernopadding" width="100%"><tr><td>';
438 print $langs->trans(
'DateDeliveryPlanned');
440 print
'</tr></table>';
441 print
'</td><td colspan="2">';
447 print
'<br><br><center>';
448 print
'<a href="#" id="resetalltoexpected" class="marginrightonly paddingright marginleftonly paddingleft">'.img_picto(
"",
'autofill',
'class="pictofixedwidth"').$langs->trans(
"RestoreWithCurrentQtySaved").
'</a></td>';
450 print
'<a href="#" id="autoreset" class="marginrightonly paddingright marginleftonly paddingleft">'.img_picto(
"",
'eraser',
'class="pictofixedwidth"').$langs->trans(
"ClearQtys").
'</a></td>';
458 if (
$object->statut == Reception::STATUS_DRAFT || (
$object->statut == Reception::STATUS_VALIDATED && !
getDolGlobalString(
'STOCK_CALCULATE_ON_RECEPTION'))) {
459 require_once DOL_DOCUMENT_ROOT.
'/product/class/html.formproduct.class.php';
461 $formproduct->loadWarehouses();
463 $listwarehouses = $entrepot->list_array(1);
465 print
'<form method="post" action="'.$_SERVER[
"PHP_SELF"].
'">';
467 print
'<input type="hidden" name="token" value="'.newToken().
'">';
468 print
'<input type="hidden" name="action" value="updatelines">';
469 print
'<input type="hidden" name="id" value="'.$object->id.
'">';
471 print
'<div class="div-table-responsive-no-min">';
472 print
'<table class="noborder centpercent">';
475 $products_dispatched = array();
476 $sql =
"SELECT l.rowid, cfd.fk_product, sum(cfd.qty) as qty";
477 $sql .=
" FROM ".MAIN_DB_PREFIX.
"receptiondet_batch as cfd";
478 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"receptiondet_batch as l on l.rowid = cfd.fk_elementdet";
479 $sql .=
" WHERE cfd.fk_reception = ".((int)
$object->id);
480 $sql .=
" GROUP BY l.rowid, cfd.fk_product";
482 $resql = $db->query($sql);
484 $num = $db->num_rows($resql);
489 $objd = $db->fetch_object($resql);
490 $products_dispatched[$objd->rowid] =
price2num($objd->qty,
'MS');
499 $sql =
"SELECT l.rowid, l.fk_product, l.subprice, l.remise_percent, l.ref AS sref, l.qty as qty,";
500 $sql .=
" p.ref, p.label, p.tobatch, p.fk_default_warehouse";
502 $parameters = array();
503 $reshook = $hookmanager->executeHooks(
504 'printFieldListSelect',
512 $sql .= $hookmanager->resPrint;
513 $sql .=
" FROM ".MAIN_DB_PREFIX.
"commande_fournisseurdet as l";
514 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"product as p ON l.fk_product=p.rowid";
515 $sql .=
" WHERE l.fk_commande = ".((int) $objectsrc->id);
517 $sql .=
" AND l.product_type = 0";
520 $parameters = array();
521 $reshook = $hookmanager->executeHooks(
522 'printFieldListWhere',
530 $sql .= $hookmanager->resPrint;
533 $sql .=
" ORDER BY l.rang, p.ref, p.label";
535 $resql = $db->query($sql);
537 $num = $db->num_rows($resql);
541 print
'<tr class="liste_titre">';
543 print
'<td>'.$langs->trans(
"Description").
'</td>';
544 if (isModEnabled(
'productbatch')) {
545 print
'<td class="dispatch_batch_number_title">'.$langs->trans(
"batch_number").
'</td>';
547 print
'<td class="dispatch_dlc_title">'.$langs->trans(
"SellByDate").
'</td>';
550 print
'<td class="dispatch_dluo_title">'.$langs->trans(
"EatByDate").
'</td>';
557 print
'<td class="right">'.$langs->trans(
"SupplierRef").
'</td>';
558 print
'<td class="right">'.$langs->trans(
"QtyOrdered").
'</td>';
559 if (
$object->status == Reception::STATUS_DRAFT) {
560 print
'<td class="right">'.$langs->trans(
"QtyToReceive");
562 print
'<td class="right">'.$langs->trans(
"QtyDispatchedShort").
'</td>';
564 print
'<td class="right">'.$langs->trans(
"Details");
565 print
'<td width="32"></td>';
568 if (!isModEnabled(
"multicurrency") && empty(
$conf->dynamicprices->enabled)) {
569 print
'<td class="right">'.$langs->trans(
"Price").
'</td>';
570 print
'<td class="right">'.$langs->trans(
"ReductionShort").
' (%)</td>';
571 print
'<td class="right">'.$langs->trans(
"UpdatePrice").
'</td>';
575 print
'<td align="right">'.$langs->trans(
"Warehouse");
578 if (count($listwarehouses) > 1) {
579 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);
580 } elseif (count($listwarehouses) == 1) {
581 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);
587 $parameters = array();
588 $reshook = $hookmanager->executeHooks(
589 'printFieldListTitle',
597 print $hookmanager->resPrint;
605 $conf->cache[
'product'] = array();
609 $objp = $db->fetch_object($resql);
612 if (!$objp->fk_product > 0) {
615 $alreadydispatched = isset($products_dispatched[$objp->rowid]) ? $products_dispatched[$objp->rowid] : 0;
616 $remaintodispatch =
price2num($objp->qty, 5);
617 if ($remaintodispatch < 0 && !
getDolGlobalString(
'SUPPLIER_ORDER_ALLOW_NEGATIVE_QTY_FOR_SUPPLIER_ORDER_RETURN')) {
618 $remaintodispatch = 0;
621 if ($remaintodispatch || !
getDolGlobalString(
'SUPPLIER_ORDER_DISABLE_STOCK_DISPATCH_WHEN_TOTAL_REACHED')) {
630 print
'<!-- Line to dispatch '.$suffix.
' -->'.
"\n";
632 print
'<input id="qty_ordered'.$suffix.
'" type="hidden" value="'.$objp->qty.
'">';
633 print
'<input id="qty_dispatched'.$suffix.
'" type="hidden" data-dispatched="'.((float) $alreadydispatched).
'" value="'.(float) $alreadydispatched.
'">';
634 print
'<tr class="oddeven">';
636 if (empty(
$conf->cache[
'product'][$objp->fk_product])) {
637 $tmpproduct =
new Product($db);
638 $tmpproduct->fetch($objp->fk_product);
639 $conf->cache[
'product'][$objp->fk_product] = $tmpproduct;
641 $tmpproduct =
$conf->cache[
'product'][$objp->fk_product];
644 $linktoprod = $tmpproduct->getNomUrl(1);
645 $linktoprod .=
' - '.$objp->label.
"\n";
647 if (isModEnabled(
'productbatch')) {
648 if ($objp->tobatch) {
653 print
'<td class="dispatch_batch_number"></td>';
655 print
'<td class="dispatch_dlc"></td>';
658 print
'<td class="dispatch_dluo"></td>';
665 print
'<td class="dispatch_batch_number">';
666 print
'<span class="opacitymedium small">'.$langs->trans(
"ProductDoesNotUseBatchSerial").
'</small>';
669 print
'<td class="dispatch_dlc"></td>';
672 print
'<td class="dispatch_dluo"></td>';
676 print
'<td colspan="4">';
682 $up_ht_disc = $objp->subprice;
683 if (!empty($objp->remise_percent) && !
getDolGlobalString(
'STOCK_EXCLUDE_DISCOUNT_FOR_PMP')) {
684 $up_ht_disc =
price2num($up_ht_disc * (100 - $objp->remise_percent) / 100,
'MU');
688 print
'<td class="right">'.$objp->sref.
'</td>';
691 print
'<td class="right">'.$objp->qty.
'</td>';
694 print
'<td class="right">'.$alreadydispatched.
'</td>';
696 print
'<td class="right">';
702 $sql =
"SELECT cfd.rowid, cfd.qty, cfd.fk_entrepot, cfd.batch, cfd.eatby, cfd.sellby, cfd.fk_product";
703 $sql .=
" FROM ".MAIN_DB_PREFIX.
"receptiondet_batch as cfd";
704 $sql .=
" WHERE cfd.fk_reception = ".((int)
$object->id);
705 $sql .=
" AND cfd.fk_element = ".((int) $objectsrc->id);
706 $sql .=
" AND cfd.fk_elementdet = ".(int) $objp->rowid;
709 $resultsql = $db->query($sql);
712 $numd = $db->num_rows($resultsql);
715 $suffix =
"_".$j.
"_".$i;
716 $objd = $db->fetch_object($resultsql);
718 if (isModEnabled(
'productbatch') && (!empty($objd->batch) || (is_null($objd->batch) && $tmpproduct->status_batch > 0))) {
724 'is_information_row' =>
true,
729 $reshook = $hookmanager->executeHooks(
730 'printFieldListValue',
738 print $hookmanager->resPrint;
742 print
'<!-- line for batch '.$numline.
' -->';
743 print
'<tr class="oddeven autoresettr" name="'.$type.$suffix.
'" data-remove="clear">';
745 print
'<input id="fk_commandefourndet'.$suffix.
'" name="fk_commandefourndet'.$suffix.
'" type="hidden" value="'.$objp->rowid.
'">';
746 print
'<input id="idline'.$suffix.
'" name="idline'.$suffix.
'" type="hidden" value="'.$objd->rowid.
'">';
747 print
'<input name="product_batch'.$suffix.
'" type="hidden" value="'.$objd->fk_product.
'">';
749 print
'<!-- This is a U.P. (may include discount or not depending on STOCK_EXCLUDE_DISCOUNT_FOR_PMP. will be used for PMP calculation) -->';
751 print $langs->trans(
"BuyingPrice").
': <input class="maxwidth75" name="pu'.$suffix.
'" type="text" value="'.
price2num($up_ht_disc,
'MU').
'">';
753 print
'<input class="maxwidth75" name="pu'.$suffix.
'" type="hidden" value="'.
price2num($up_ht_disc,
'MU').
'">';
759 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).
'">';
762 print
'<td class="nowraponall">';
764 print $form->selectDate($dlcdatesuffix,
'dlc'.$suffix, 0, 0, 1,
'');
768 print
'<td class="nowraponall">';
770 print $form->selectDate($dluodatesuffix,
'dluo'.$suffix, 0, 0, 1,
'');
773 print
'<td colspan="3"> </td>';
783 'is_information_row' =>
true,
788 $reshook = $hookmanager->executeHooks(
789 'printFieldListValue',
797 print $hookmanager->resPrint;
801 print
'<!-- line no batch '.$numline.
' -->';
802 print
'<tr class="oddeven autoresettr" name="'.$type.$suffix.
'" data-remove="clear">';
803 print
'<td colspan="'.$colspan.
'">';
804 print
'<input id="fk_commandefourndet'.$suffix.
'" name="fk_commandefourndet'.$suffix.
'" type="hidden" value="'.$objp->rowid.
'">';
805 print
'<input id="idline'.$suffix.
'" name="idline'.$suffix.
'" type="hidden" value="'.$objd->rowid.
'">';
806 print
'<input name="product'.$suffix.
'" type="hidden" value="'.$objd->fk_product.
'">';
808 print
'<!-- This is a up (may include discount or not depending on STOCK_EXCLUDE_DISCOUNT_FOR_PMP. will be used for PMP calculation) -->';
810 print $langs->trans(
"BuyingPrice").
': <input class="maxwidth75" name="pu'.$suffix.
'" type="text" value="'.
price2num($up_ht_disc,
'MU').
'">';
812 print
'<input class="maxwidth75" name="pu'.$suffix.
'" type="hidden" value="'.
price2num($up_ht_disc,
'MU').
'">';
818 print
'<td class="right">';
819 print
'<a href="#" id="reset'.$suffix.
'" class="resetline">'.
img_picto($langs->trans(
"Reset"),
'eraser',
'class="pictofixedwidth opacitymedium"').
'</a>';
820 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.
'">';
823 if (isModEnabled(
'productbatch') && $objp->tobatch > 0) {
825 print
img_picto($langs->trans(
'AddStockLocationLine'),
'split.png',
'class="splitbutton" '.($numd != $j + 1 ?
'style="display:none"' :
'').
' onClick="addDispatchLine('.$i.
', \''.$type.
'\')"');
828 print
img_picto($langs->trans(
'AddStockLocationLine'),
'split.png',
'class="splitbutton" '.($numd != $j + 1 ?
'style="display:none"' :
'').
' onClick="addDispatchLine('.$i.
', \''.$type.
'\')"');
834 if (!isModEnabled(
"multicurrency") && empty(
$conf->dynamicprices->enabled)) {
836 print
'<td class="right">';
837 print
'<input id="pu'.$suffix.
'" name="pu'.$suffix.
'" type="text" size="8" value="'.
price((
GETPOST(
'pu'.$suffix) !=
'' ?
price2num(
GETPOST(
'pu'.$suffix)) : $up_ht_disc)).
'">';
841 print
'<td class="right">';
842 print
'<input id="dto'.$suffix.
'" name="dto'.$suffix.
'" type="text" size="8" value="'.(
GETPOST(
'dto'.$suffix) !=
'' ?
GETPOST(
'dto'.$suffix) :
'').
'">';
846 print
'<td class="center">';
847 print
'<input class="flat checkformerge" type="checkbox" name="saveprice'.$suffix.
'" value="'.(
GETPOST(
'saveprice'.$suffix) !=
'' ?
GETPOST(
'saveprice'.$suffix) :
'').
'">';
853 print
'<td class="right">';
854 if (count($listwarehouses) > 1) {
855 print $formproduct->selectWarehouses(
GETPOST(
"entrepot".$suffix) ?
GETPOST(
"entrepot".$suffix) : $objd->fk_entrepot,
"entrepot".$suffix,
'', 1, 0, $objp->fk_product,
'', 1, 0, array(),
'csswarehouse'.$suffix);
856 } elseif (count($listwarehouses) == 1) {
857 print $formproduct->selectWarehouses(
GETPOST(
"entrepot".$suffix) ?
GETPOST(
"entrepot".$suffix) : $objd->fk_entrepot,
"entrepot".$suffix,
'', 0, 0, $objp->fk_product,
'', 1, 0, array(),
'csswarehouse'.$suffix);
859 $langs->load(
"errors");
860 print $langs->trans(
"ErrorNoWarehouseDefined");
866 'is_information_row' =>
false,
871 $reshook = $hookmanager->executeHooks(
872 'printFieldListValue',
880 print $hookmanager->resPrint;
887 $suffix =
"_".$j.
"_".$i;
891 if (isModEnabled(
'productbatch') && !empty($objp->tobatch)) {
897 'is_information_row' =>
true,
902 $reshook = $hookmanager->executeHooks(
903 'printFieldListValue',
911 print $hookmanager->resPrint;
915 print
'<!-- line for batch '.$numline.
' (not dispatched line yet for this order line) -->';
916 print
'<tr class="oddeven autoresettr" name="'.$type.$suffix.
'">';
918 print
'<input id="fk_commandefourndet'.$suffix.
'" name="fk_commandefourndet'.$suffix.
'" type="hidden" value="'.$objp->rowid.
'">';
919 print
'<input id="idline'.$suffix.
'" name="idline'.$suffix.
'" type="hidden" value="-1">';
920 print
'<input name="product_batch'.$suffix.
'" type="hidden" value="'.$objp->fk_product.
'">';
922 print
'<!-- This is a up (may include discount or not depending on STOCK_EXCLUDE_DISCOUNT_FOR_PMP. will be used for PMP calculation) -->';
924 print $langs->trans(
"BuyingPrice").
': <input class="maxwidth75" name="pu'.$suffix.
'" type="text" value="'.
price2num($up_ht_disc,
'MU').
'">';
926 print
'<input class="maxwidth75" name="pu'.$suffix.
'" type="hidden" value="'.
price2num($up_ht_disc,
'MU').
'">';
932 print
'<input type="text" class="inputlotnumber quatrevingtquinzepercent" id="lot_number'.$suffix.
'" name="lot_number'.$suffix.
'" value="'.
GETPOST(
'lot_number'.$suffix).
'">';
935 print
'<td class="nowraponall">';
937 print $form->selectDate($dlcdatesuffix,
'dlc'.$suffix, 0, 0, 1,
'');
941 print
'<td class="nowraponall">';
943 print $form->selectDate($dluodatesuffix,
'dluo'.$suffix, 0, 0, 1,
'');
946 print
'<td colspan="3"> </td>';
956 'is_information_row' =>
true,
961 $reshook = $hookmanager->executeHooks(
962 'printFieldListValue',
970 print $hookmanager->resPrint;
974 print
'<!-- line no batch '.$numline.
' (not dispatched line yet for this order line) -->';
975 print
'<tr class="oddeven autoresettr" name="'.$type.$suffix.
'" data-remove="clear">';
976 print
'<td colspan="'.$colspan.
'">';
977 print
'<input id="fk_commandefourndet'.$suffix.
'" name="fk_commandefourndet'.$suffix.
'" type="hidden" value="'.$objp->rowid.
'">';
978 print
'<input id="idline'.$suffix.
'" name="idline'.$suffix.
'" type="hidden" value="-1">';
979 print
'<input name="product'.$suffix.
'" type="hidden" value="'.$objp->fk_product.
'">';
981 print
'<!-- This is a up (may include discount or not depending on STOCK_EXCLUDE_DISCOUNT_FOR_PMP. will be used for PMP calculation) -->';
983 print $langs->trans(
"BuyingPrice").
': <input class="maxwidth75" name="pu'.$suffix.
'" data-type="text" value="'.
price2num($up_ht_disc,
'MU').
'">';
985 print
'<input class="maxwidth75" name="pu'.$suffix.
'" type="hidden" value="'.
price2num($up_ht_disc,
'MU').
'">';
991 print
'<td class="right">';
992 print
'<a href="#" id="reset'.$suffix.
'" class="resetline">'.
img_picto($langs->trans(
"Reset"),
'eraser',
'class="pictofixedwidth opacitymedium"').
'</a>';
993 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.
'">';
996 if (isModEnabled(
'productbatch') && $objp->tobatch > 0) {
998 print
img_picto($langs->trans(
'AddStockLocationLine'),
'split.png',
'class="splitbutton" onClick="addDispatchLine('.$i.
', \''.$type.
'\')
"');
1001 print img_picto($langs->trans('AddStockLocationLine'), 'split.png', 'class="splitbutton
" onClick="addDispatchLine(
'.$i.', \
''.$type.
'\')
"');
1006 if (getDolGlobalString('SUPPLIER_ORDER_CAN_UPDATE_BUYINGPRICE_DURING_RECEIPT')) {
1007 if (!isModEnabled("multicurrency
") && empty($conf->dynamicprices->enabled)) {
1009 print '<td class="right
">';
1010 print '<input id="pu
'.$suffix.'" name="pu
'.$suffix.'" type="text
" size="8
" value="'.price((GETPOST('pu
'.$suffix) != '' ? price2num(GETPOST('pu
'.$suffix)) : $up_ht_disc)).'">';
1014 print '<td class="right
">';
1015 print '<input id="dto
'.$suffix.'" name="dto
'.$suffix.'" type="text
" size="8
" value="'.(GETPOST('dto
'.$suffix) != '' ? GETPOST('dto
'.$suffix) : '').'">';
1019 print '<td class="center
">';
1020 print '<input class="flat checkformerge
" type="checkbox
" name="saveprice
'.$suffix.'" value="'.(GETPOST('saveprice
'.$suffix) != '' ? GETPOST('saveprice
'.$suffix) : '').'">';
1026 print '<td class="right
">';
1027 if (count($listwarehouses) > 1) {
1028 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, array(), 'csswarehouse'.$suffix);
1029 } elseif (count($listwarehouses) == 1) {
1030 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, array(), 'csswarehouse'.$suffix);
1032 $langs->load("errors
");
1033 print $langs->trans("ErrorNoWarehouseDefined
");
1037 // Enable hooks to append additional columns
1038 $parameters = array(
1039 'is_information_row' => false, // this is a dispatch form row
1041 'suffix' => $suffix,
1044 $reshook = $hookmanager->executeHooks(
1045 'printFieldListValue',
1051 setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
1053 print $hookmanager->resPrint;
1062 dol_print_error($db);
1069 print '<div class="center
">';
1070 $parameters = array();
1071 $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been
1073 if (empty($reshook)) {
1074 /*$checkboxlabel = $langs->trans("CloseReceivedSupplierOrdersAutomatically
", $langs->transnoentitiesnoconv('StatusOrderReceivedAll'));
1076 if (empty($conf->reception->enabled)) {
1077 print $langs->trans("Comment").' : ';
1078 print '<input type="text
" class="minwidth400
" maxlength="128
" name="comment
" value="';
1079 print GETPOSTISSET("comment") ? GETPOST("comment") : $langs->trans("DispatchSupplierOrder", $object->ref);
1080 // print ' /
'.$object->ref_supplier; // Not yet available
1081 print '" class="flat
"><br>';
1083 print '<input type="checkbox
" checked="checked
" name="closeopenorder
"> '.$checkboxlabel;
1086 $dispatchBt = empty($conf->reception->enabled) ? $langs->trans("Receive
") : $langs->trans("CreateReception
");
1091 print '<input type="submit
" id="submitform
" class="button" name="dispatch
" value="'.$langs->trans("Save").'"';
1093 if (!$permissiontoreceive) {
1096 if (count($listwarehouses) <= 0) {
1108 // Message if nothing to dispatch
1111 if (!getDolGlobalString('SUPPLIER_ORDER_DISABLE_STOCK_DISPATCH_WHEN_TOTAL_REACHED')) {
1112 print '<div class="opacitymedium
">'.$langs->trans("NoPredefinedProductToDispatch
").'</div>'; // No predefined line at all
1114 print '<div class="opacitymedium
">'.$langs->trans("NoMorePredefinedProductToDispatch
").'</div>'; // No predefined line that remain to be dispatched.
1121 print dol_get_fiche_end();
1123 // traitement entrepot par défaut
1124 print '<script type="text/javascript
">
1125 $(document).ready(function () {
1126 $("select[
name=fk_default_warehouse]
").change(function() {
1127 var fk_default_warehouse = $("option:selected
", this).val();
1128 $("select[
name^=entrepot_]
").val(fk_default_warehouse).change();
1131 $("#autoreset
").click(function() {
1132 $(".autoresettr
").each(function(){
1133 id = $(this).attr("name");
1134 idtab = id.split("_
");
1135 if ($(this).data("remove") == "clear
"){
1136 console.log("We clear the
object to expected value
")
1137 $("#qty_
"+idtab[1]+"_
"+idtab[2]).val("");
1139 qtyexpected = $("#qty_
"+idtab[1]+"_
"+idtab[2]).data("expected
")
1140 console.log(qtyexpected);
1141 $("#qty_
"+idtab[1]+"_
"+idtab[2]).val(qtyexpected);
1142 qtydispatched = $("#qty_dispatched_0_
"+idtab[2]).data("dispatched
")
1143 $("#qty_dispatched_0_
"+idtab[2]).val(qtydispatched);
1146 console.log("We
remove the
object")
1148 $("tr[
name^=\
'"+idtab[0]+"_\'][name$=\'_"+idtab[2]+"\']:last .splitbutton").show();
1154 $("#resetalltoexpected").click(function(){
1155 $(".qtydispatchinput").each(function(){
1156 console.log("We reset to expected "+$(this).attr("id")+" qty to dispatch");
1157 $(this).val($(this).data("expected"));
1162 $(".resetline").click(function(e){
1164 id = $(this).attr("id");
1165 id = id.split("reset_");
1166 console.log("Reset trigger for id = qty_"+id[1]);
1167 $("#qty_"+id[1]).val("");
$id
Support class for third parties, contacts, members, users or resources.
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
llxFooter($comment='', $zone='private', $disabledoutputofmessages=0)
Empty footer.
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
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...
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2, $allowothertags=array())
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, $morecssdiv='')
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.
GETPOSTFLOAT($paramname, $rounding='')
Return the value of a $_GET or $_POST supervariable, converted into float.
getDolGlobalString($key, $default='')
Return a 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
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
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.