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",
"products",
"stocks",
"receptions"));
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")) {
88if ($id > 0 || !empty($ref)) {
89 $result =
$object->fetch($id, $ref);
93 $result =
$object->fetch_thirdparty();
105 $origin_id =
$object->origin_object->id;
107 $objectsrc->fetch($origin_id);
111if (empty(
$conf->reception->enabled)) {
112 $permissiontoreceive = $user->hasRight(
'fournisseur',
'commande',
'receptionner');
113 $permissiontocontrol = ((!
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') && $user->hasRight(
'fournisseur',
'commande',
'receptionner')) || (
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') && $user->hasRight(
'fournisseur',
'commande_advance',
'check')));
115 $permissiontoreceive = $user->hasRight(
'reception',
'creer');
116 $permissiontocontrol = ((!
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') && $user->hasRight(
'reception',
'creer')) || (
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') && $user->hasRight(
'reception',
'reception_advance',
'validate')));
126$usercancreate = $user->hasRight(
'reception',
'creer');
127$permissiontoadd = $usercancreate;
134$parameters = array();
135$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
141if ($action ==
'updatelines' && $permissiontoreceive) {
148 foreach ($_POST as $key => $value) {
151 if (preg_match(
'/^product_.*([0-9]+)_([0-9]+)$/i', $key, $reg)) {
154 if (preg_match(
'/^product_([0-9]+)_([0-9]+)$/i', $key, $reg)) {
155 $modebatch =
"barcode";
156 } elseif (preg_match(
'/^product_batch_([0-9]+)_([0-9]+)$/i', $key, $reg)) {
157 $modebatch =
"batch";
161 if ($modebatch ==
"barcode") {
162 $prod =
"product_".$reg[1].
'_'.$reg[2];
164 $prod =
'product_batch_'.$reg[1].
'_'.$reg[2];
166 $qty =
"qty_".$reg[1].
'_'.$reg[2];
167 $ent =
"entrepot_".$reg[1].
'_'.$reg[2];
168 $pu =
"pu_".$reg[1].
'_'.$reg[2];
169 $fk_commandefourndet =
"fk_commandefourndet_".$reg[1].
'_'.$reg[2];
170 $idline =
GETPOSTINT(
"idline_".$reg[1].
'_'.$reg[2]);
174 if ($modebatch ==
"batch") {
175 $lot =
GETPOST(
'lot_number_'.$reg[1].
'_'.$reg[2]);
180 $saveprice =
'__invalidsavepricekey__';
183 $dto =
GETPOSTINT(
"dto_".$reg[1].
'_'.$reg[2]);
187 $saveprice =
"saveprice_".$reg[1].
'_'.$reg[2];
192 if (($modebatch ==
"batch" &&
GETPOST($qty) > 0) || ($modebatch ==
"barcode" &&
GETPOST($qty) != 0)) {
194 dol_syslog(
'No dispatch for line '.$key.
' as no warehouse was chosen.');
195 $text = $langs->transnoentities(
'Warehouse').
', '.$langs->transnoentities(
'Line').
' '.($numline);
196 setEventMessages($langs->trans(
'ErrorFieldRequired', $text),
null,
'errors');
202 $result = $supplierorderdispatch->fetch($idline);
204 setEventMessages($supplierorderdispatch->error, $supplierorderdispatch->errors,
'errors');
207 $qtystart = $supplierorderdispatch->qty;
209 $supplierorderdispatch->fk_entrepot =
GETPOSTINT($ent);
210 if ($modebatch ==
"batch") {
211 $supplierorderdispatch->eatby = $dDLUO;
212 $supplierorderdispatch->sellby = $dDLC;
215 $result = $supplierorderdispatch->update($user);
217 setEventMessages($supplierorderdispatch->error, $supplierorderdispatch->errors,
'errors');
261 $result = $objectsrc->dispatchProduct($user,
GETPOSTINT(
$prod),
GETPOSTFLOAT($qty),
GETPOSTINT($ent),
GETPOSTFLOAT($pu),
GETPOST(
'comment'), $dDLUO, $dDLC, $lot,
GETPOSTINT($fk_commandefourndet), 0,
$object->id);
268 if (!$error &&
getDolGlobalString(
'SUPPLIER_ORDER_CAN_UPDATE_BUYINGPRICE_DURING_RECEIPT')) {
276 if (GETPOSTISSET($saveprice)) {
278 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"product_fournisseur_price";
279 $sql .=
" SET unitprice='".price2num(
GETPOST($pu),
'MU').
"'";
280 $sql .=
", price=".price2num(
GETPOST($pu),
'MU').
"*quantity";
281 $sql .=
", remise_percent = ".((float) $dto);
282 $sql .=
" WHERE fk_soc=".((int)
$object->socid);
283 $sql .=
" AND fk_product=".(GETPOSTINT(
$prod));
285 $resql =
$db->query($sql);
300 header(
"Location: ".DOL_URL_ROOT.
'/reception/dispatch.php?id='.
$object->id);
317$title =
$object->ref.
" - ".$langs->trans(
'ReceptionDistribution');
318$help_url =
'EN:Module_Suppliers_Orders|FR:CommandeFournisseur|ES:Módulo_Pedidos_a_proveedores';
319$morejs = array(
'/fourn/js/lib_dispatch.js.php');
322llxHeader(
'', $title, $help_url,
'', 0, 0, $morejs,
'',
'',
'mod-reception page-card_dispatch');
324if ($id > 0 || !empty($ref)) {
329 $origin_id =
$object->origin_id;
336 $author->fetch(
$object->user_author_id);
340 $title = $langs->trans(
"SupplierOrder");
341 print
dol_get_fiche_head($head,
'dispatch', $langs->trans(
"Reception"), -1,
'dollyrevert');
347 if ($action ==
'ask_deleteline') {
348 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&lineid='.$lineid, $langs->trans(
'DeleteLine'), $langs->trans(
'ConfirmDeleteLine'),
'confirm_deleteline',
'', 0, 1);
352 $parameters = array(
'lineid' => $lineid);
354 $reshook = $hookmanager->executeHooks(
'formConfirm', $parameters, $object, $action);
355 if (empty($reshook)) {
356 $formconfirm .= $hookmanager->resPrint;
357 } elseif ($reshook > 0) {
358 $formconfirm = $hookmanager->resPrint;
365 $linkback =
'<a href="'.DOL_URL_ROOT.
'/reception/list.php?restore_lastsearch_values=1'.(!empty($socid) ?
'&socid='.$socid :
'').
'">'.$langs->trans(
"BackToList").
'</a>';
366 $morehtmlref =
'<div class="refidno">';
369 $morehtmlref .= $form->editfieldkey(
"RefSupplier",
'ref_supplier',
$object->ref_supplier, $object, $user->hasRight(
'reception',
'creer'),
'string',
'', 0, 1);
370 $morehtmlref .= $form->editfieldval(
"RefSupplier",
'ref_supplier',
$object->ref_supplier, $object, $user->hasRight(
'reception',
'creer'),
'string',
'',
null,
null,
'', 1);
373 $morehtmlref .=
'<br>'.$object->thirdparty->getNomUrl(1);
376 $langs->load(
"projects");
377 $morehtmlref .=
'<br>';
379 $morehtmlref .=
img_picto($langs->trans(
"Project"),
'project',
'class="pictofixedwidth"');
380 if ($action !=
'classify' && $permissiontoadd) {
381 $morehtmlref .=
'<a class="editfielda" href="'.dolBuildUrl($_SERVER[
'PHP_SELF'], [
'action' =>
'classify',
'id' =>
$object->id],
true).
'">'.
img_edit($langs->transnoentitiesnoconv(
'SetProject')).
'</a> ';
383 $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');
385 if (!empty($objectsrc) && !empty($objectsrc->fk_project)) {
387 $proj->fetch($objectsrc->fk_project);
388 $morehtmlref .= $proj->getNomUrl(1);
390 $morehtmlref .=
'<span class="opacitymedium"> - '.dol_escape_htmltag($proj->title).
'</span>';
395 $morehtmlref .=
'</div>';
397 dol_banner_tab($object,
'ref', $linkback, 1,
'ref',
'ref', $morehtmlref);
400 print
'<div class="fichecenter">';
401 print
'<div class="underbanner clearboth"></div>';
403 print
'<table class="border tableforfield" width="100%">';
408 print $langs->trans(
"RefOrder").
'</td>';
409 print
'<td colspan="3">';
410 print $objectsrc->getNomUrl(1,
'commande');
416 print $langs->trans(
"RefProposal").
'</td>';
417 print
'<td colspan="3">';
418 print $objectsrc->getNomUrl(1,
'reception');
422 if (($typeobject ==
'supplier_order' || $typeobject ==
'order_supplier') &&
$object->origin_object->id &&
isModEnabled(
"propal")) {
424 print $langs->trans(
"SupplierOrder").
'</td>';
425 print
'<td colspan="3">';
426 print $objectsrc->getNomUrl(1,
'reception');
432 print
'<tr><td class="titlefield">'.$langs->trans(
"DateCreation").
'</td>';
433 print
'<td colspan="3">'.dol_print_date(
$object->date_creation,
"dayhour",
"tzuserrel").
"</td>\n";
437 print
'<tr><td height="10">';
438 print
'<table class="nobordernopadding" width="100%"><tr><td>';
439 print $langs->trans(
'DateDeliveryPlanned');
441 print
'</tr></table>';
442 print
'</td><td colspan="2">';
448 print
'<br><br><center>';
449 print
'<a href="#" id="resetalltoexpected" class="marginrightonly paddingright marginleftonly paddingleft">'.img_picto(
"",
'autofill',
'class="pictofixedwidth"').$langs->trans(
"RestoreWithCurrentQtySaved").
'</a></td>';
451 print
'<a href="#" id="autoreset" class="marginrightonly paddingright marginleftonly paddingleft">'.img_picto(
"",
'eraser',
'class="pictofixedwidth"').$langs->trans(
"ClearQtys").
'</a></td>';
459 if (
$object->statut == Reception::STATUS_DRAFT || (
$object->statut == Reception::STATUS_VALIDATED && !
getDolGlobalString(
'STOCK_CALCULATE_ON_RECEPTION'))) {
460 require_once DOL_DOCUMENT_ROOT.
'/product/class/html.formproduct.class.php';
462 $formproduct->loadWarehouses();
464 $listwarehouses = $entrepot->list_array(1);
466 print
'<form method="post" action="'.dolBuildUrl($_SERVER[
"PHP_SELF"]).
'">';
468 print
'<input type="hidden" name="token" value="'.newToken().
'">';
469 print
'<input type="hidden" name="action" value="updatelines">';
470 print
'<input type="hidden" name="id" value="'.$object->id.
'">';
472 print
'<div class="div-table-responsive-no-min">';
473 print
'<table class="noborder centpercent">';
476 $products_dispatched = array();
477 $sql =
"SELECT l.rowid, cfd.fk_product, sum(cfd.qty) as qty";
478 $sql .=
" FROM ".MAIN_DB_PREFIX.
"receptiondet_batch as cfd";
479 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"receptiondet_batch as l on l.rowid = cfd.fk_elementdet";
480 $sql .=
" WHERE cfd.fk_reception = ".((int)
$object->id);
481 $sql .=
" GROUP BY l.rowid, cfd.fk_product";
483 $resql =
$db->query($sql);
485 $num =
$db->num_rows($resql);
490 $objd =
$db->fetch_object($resql);
491 $products_dispatched[$objd->rowid] =
price2num($objd->qty,
'MS');
500 $sql =
"SELECT l.rowid, l.fk_product, l.subprice, l.remise_percent, l.ref AS sref, l.qty as qty,";
501 $sql .=
" p.ref, p.label, p.tobatch, p.fk_default_warehouse";
503 $parameters = array();
504 $reshook = $hookmanager->executeHooks(
505 'printFieldListSelect',
513 $sql .= $hookmanager->resPrint;
514 $sql .=
" FROM ".MAIN_DB_PREFIX.
"commande_fournisseurdet as l";
515 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"product as p ON l.fk_product=p.rowid";
516 $sql .=
" WHERE l.fk_commande = ".((int) $objectsrc->id);
518 $sql .=
" AND l.product_type = 0";
521 $parameters = array();
522 $reshook = $hookmanager->executeHooks(
523 'printFieldListWhere',
531 $sql .= $hookmanager->resPrint;
534 $sql .=
" ORDER BY l.rang, p.ref, p.label";
536 $resql =
$db->query($sql);
538 $num =
$db->num_rows($resql);
542 print
'<tr class="liste_titre">';
544 print
'<td>'.$langs->trans(
"Description").
'</td>';
546 print
'<td class="dispatch_batch_number_title">'.$langs->trans(
"batch_number").
'</td>';
548 print
'<td class="dispatch_dlc_title">'.$langs->trans(
"SellByDate").
'</td>';
551 print
'<td class="dispatch_dluo_title">'.$langs->trans(
"EatByDate").
'</td>';
558 print
'<td class="right">'.$langs->trans(
"SupplierRef").
'</td>';
559 print
'<td class="right">'.$langs->trans(
"QtyOrdered").
'</td>';
560 if (
$object->status == Reception::STATUS_DRAFT) {
561 print
'<td class="right">'.$langs->trans(
"QtyToReceive");
563 print
'<td class="right">'.$langs->trans(
"QtyDispatchedShort").
'</td>';
565 print
'<td class="right">'.$langs->trans(
"Details");
566 print
'<td width="32"></td>';
570 print
'<td class="right">'.$langs->trans(
"Price").
'</td>';
571 print
'<td class="right">'.$langs->trans(
"ReductionShort").
' (%)</td>';
572 print
'<td class="right">'.$langs->trans(
"UpdatePrice").
'</td>';
576 print
'<td align="right">'.$langs->trans(
"Warehouse");
579 if (count($listwarehouses) > 1) {
580 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);
581 } elseif (count($listwarehouses) == 1) {
582 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);
588 $parameters = array();
589 $reshook = $hookmanager->executeHooks(
590 'printFieldListTitle',
598 print $hookmanager->resPrint;
606 $conf->cache[
'product'] = array();
610 $objp =
$db->fetch_object($resql);
613 if (!$objp->fk_product > 0) {
616 $alreadydispatched = isset($products_dispatched[$objp->rowid]) ? $products_dispatched[$objp->rowid] : 0;
617 $remaintodispatch =
price2num($objp->qty, 5);
618 if ($remaintodispatch < 0 && !
getDolGlobalString(
'SUPPLIER_ORDER_ALLOW_NEGATIVE_QTY_FOR_SUPPLIER_ORDER_RETURN')) {
619 $remaintodispatch = 0;
622 if ($remaintodispatch || !
getDolGlobalString(
'SUPPLIER_ORDER_DISABLE_STOCK_DISPATCH_WHEN_TOTAL_REACHED')) {
631 print
'<!-- Line to dispatch '.$suffix.
' -->'.
"\n";
633 print
'<input id="qty_ordered'.$suffix.
'" type="hidden" value="'.$objp->qty.
'">';
634 print
'<input id="qty_dispatched'.$suffix.
'" type="hidden" data-dispatched="'.((float) $alreadydispatched).
'" value="'.(float) $alreadydispatched.
'">';
635 print
'<tr class="oddeven">';
637 if (empty(
$conf->cache[
'product'][$objp->fk_product])) {
639 $tmpproduct->fetch($objp->fk_product);
640 $conf->cache[
'product'][$objp->fk_product] = $tmpproduct;
642 $tmpproduct =
$conf->cache[
'product'][$objp->fk_product];
645 $linktoprod = $tmpproduct->getNomUrl(1);
646 $linktoprod .=
' - '.$objp->label.
"\n";
649 if ($objp->tobatch) {
651 print
'<td class="tdoverflowmax200">';
654 print
'<td class="dispatch_batch_number"></td>';
656 print
'<td class="dispatch_dlc"></td>';
659 print
'<td class="dispatch_dluo"></td>';
663 print
'<td class="tdoverflowmax200">';
666 print
'<td class="dispatch_batch_number">';
667 print
'<span class="opacitymedium small">'.$form->textwithpicto($langs->transnoentitiesnoconv(
"NA"), $langs->transnoentitiesnoconv(
"ProductDoesNotUseBatchSerial")).
'</small>';
670 print
'<td class="dispatch_dlc"></td>';
673 print
'<td class="dispatch_dluo"></td>';
677 print
'<td colspan="4">';
683 $up_ht_disc = $objp->subprice;
684 if (!empty($objp->remise_percent) && !
getDolGlobalString(
'STOCK_EXCLUDE_DISCOUNT_FOR_PMP')) {
685 $up_ht_disc =
price2num($up_ht_disc * (100 - $objp->remise_percent) / 100,
'MU');
689 print
'<td class="right">'.$objp->sref.
'</td>';
692 print
'<td class="right">'.$objp->qty.
'</td>';
695 print
'<td class="right">'.$alreadydispatched.
'</td>';
697 print
'<td class="right">';
703 $sql =
"SELECT cfd.rowid, cfd.qty, cfd.fk_entrepot, cfd.batch, cfd.eatby, cfd.sellby, cfd.fk_product";
704 $sql .=
" FROM ".MAIN_DB_PREFIX.
"receptiondet_batch as cfd";
705 $sql .=
" WHERE cfd.fk_reception = ".((int)
$object->id);
706 $sql .=
" AND cfd.fk_element = ".((int) $objectsrc->id);
707 $sql .=
" AND cfd.fk_elementdet = ".(int) $objp->rowid;
710 $resultsql =
$db->query($sql);
713 $numd =
$db->num_rows($resultsql);
716 $suffix =
"_".$j.
"_".$i;
717 $objd =
$db->fetch_object($resultsql);
719 if (
isModEnabled(
'productbatch') && (!empty($objd->batch) || (is_null($objd->batch) && $tmpproduct->status_batch > 0))) {
725 'is_information_row' =>
true,
730 $reshook = $hookmanager->executeHooks(
731 'printFieldListValue',
739 print $hookmanager->resPrint;
743 print
'<!-- line for batch '.$numline.
' -->';
744 print
'<tr class="oddeven autoresettr" name="'.$type.$suffix.
'" data-remove="clear">';
746 print
'<input id="fk_commandefourndet'.$suffix.
'" name="fk_commandefourndet'.$suffix.
'" type="hidden" value="'.$objp->rowid.
'">';
747 print
'<input id="idline'.$suffix.
'" name="idline'.$suffix.
'" type="hidden" value="'.$objd->rowid.
'">';
748 print
'<input name="product_batch'.$suffix.
'" type="hidden" value="'.$objd->fk_product.
'">';
750 print
'<!-- This is a U.P. (may include discount or not depending on STOCK_EXCLUDE_DISCOUNT_FOR_PMP. will be used for PMP calculation) -->';
752 print $langs->trans(
"BuyingPrice").
': <input class="maxwidth75" name="pu'.$suffix.
'" type="text" value="'.
price2num($up_ht_disc,
'MU').
'">';
754 print
'<input class="maxwidth75" name="pu'.$suffix.
'" type="hidden" value="'.
price2num($up_ht_disc,
'MU').
'">';
760 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).
'">';
763 print
'<td class="nowraponall">';
765 print $form->selectDate($dlcdatesuffix,
'dlc'.$suffix, 0, 0, 1,
'');
769 print
'<td class="nowraponall">';
771 print $form->selectDate($dluodatesuffix,
'dluo'.$suffix, 0, 0, 1,
'');
774 print
'<td colspan="3"> </td>';
784 'is_information_row' =>
true,
789 $reshook = $hookmanager->executeHooks(
790 'printFieldListValue',
798 print $hookmanager->resPrint;
802 print
'<!-- line no batch '.$numline.
' -->';
803 print
'<tr class="oddeven autoresettr" name="'.$type.$suffix.
'" data-remove="clear">';
804 print
'<td colspan="'.$colspan.
'">';
805 print
'<input id="fk_commandefourndet'.$suffix.
'" name="fk_commandefourndet'.$suffix.
'" type="hidden" value="'.$objp->rowid.
'">';
806 print
'<input id="idline'.$suffix.
'" name="idline'.$suffix.
'" type="hidden" value="'.$objd->rowid.
'">';
807 print
'<input name="product'.$suffix.
'" type="hidden" value="'.$objd->fk_product.
'">';
809 print
'<!-- This is a up (may include discount or not depending on STOCK_EXCLUDE_DISCOUNT_FOR_PMP. will be used for PMP calculation) -->';
811 print $langs->trans(
"BuyingPrice").
': <input class="maxwidth75" name="pu'.$suffix.
'" type="text" value="'.
price2num($up_ht_disc,
'MU').
'">';
813 print
'<input class="maxwidth75" name="pu'.$suffix.
'" type="hidden" value="'.
price2num($up_ht_disc,
'MU').
'">';
819 print
'<td class="right nowraponall">';
820 print
'<a href="#" id="reset'.$suffix.
'" class="resetline">'.
img_picto($langs->trans(
"Reset"),
'eraser',
'class="pictofixedwidth opacitymedium"').
'</a>';
821 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.
'">';
824 if (
isModEnabled(
'productbatch') && $objp->tobatch > 0) {
826 print
img_picto($langs->trans(
'AddStockLocationLine'),
'split',
'class="splitbutton" '.($numd != $j + 1 ?
'style="display:none"' :
'').
' onClick="addDispatchLine('.$i.
', \''.$type.
'\')"');
829 print
img_picto($langs->trans(
'AddStockLocationLine'),
'split',
'class="splitbutton" '.($numd != $j + 1 ?
'style="display:none"' :
'').
' onClick="addDispatchLine('.$i.
', \''.$type.
'\')"');
837 print
'<td class="right">';
838 print
'<input id="pu'.$suffix.
'" name="pu'.$suffix.
'" type="text" size="8" value="'.
price((
GETPOST(
'pu'.$suffix) !=
'' ?
price2num(
GETPOST(
'pu'.$suffix)) : $up_ht_disc)).
'">';
842 print
'<td class="right">';
843 print
'<input id="dto'.$suffix.
'" name="dto'.$suffix.
'" type="text" size="8" value="'.(
GETPOST(
'dto'.$suffix) !=
'' ?
GETPOST(
'dto'.$suffix) :
'').
'">';
847 print
'<td class="center">';
848 print
'<input class="flat checkformerge" type="checkbox" name="saveprice'.$suffix.
'" value="'.(
GETPOST(
'saveprice'.$suffix) !=
'' ?
GETPOST(
'saveprice'.$suffix) :
'').
'">';
854 print
'<td class="right">';
855 if (count($listwarehouses) > 1) {
856 print $formproduct->selectWarehouses(
GETPOST(
"entrepot".$suffix) ?
GETPOST(
"entrepot".$suffix) : $objd->fk_entrepot,
"entrepot".$suffix,
'', 1, 0, $objp->fk_product,
'', 1, 0, array(),
'csswarehouse'.$suffix);
857 } elseif (count($listwarehouses) == 1) {
858 print $formproduct->selectWarehouses(
GETPOST(
"entrepot".$suffix) ?
GETPOST(
"entrepot".$suffix) : $objd->fk_entrepot,
"entrepot".$suffix,
'', 0, 0, $objp->fk_product,
'', 1, 0, array(),
'csswarehouse'.$suffix);
860 $langs->load(
"errors");
861 print $langs->trans(
"ErrorNoWarehouseDefined");
867 'is_information_row' =>
false,
872 $reshook = $hookmanager->executeHooks(
873 'printFieldListValue',
881 print $hookmanager->resPrint;
888 $suffix =
"_".$j.
"_".$i;
892 if (
isModEnabled(
'productbatch') && !empty($objp->tobatch)) {
898 'is_information_row' =>
true,
903 $reshook = $hookmanager->executeHooks(
904 'printFieldListValue',
912 print $hookmanager->resPrint;
916 print
'<!-- line for batch '.$numline.
' (not dispatched line yet for this order line) -->';
917 print
'<tr class="oddeven autoresettr" name="'.$type.$suffix.
'">';
919 print
'<input id="fk_commandefourndet'.$suffix.
'" name="fk_commandefourndet'.$suffix.
'" type="hidden" value="'.$objp->rowid.
'">';
920 print
'<input id="idline'.$suffix.
'" name="idline'.$suffix.
'" type="hidden" value="-1">';
921 print
'<input name="product_batch'.$suffix.
'" type="hidden" value="'.$objp->fk_product.
'">';
923 print
'<!-- This is a up (may include discount or not depending on STOCK_EXCLUDE_DISCOUNT_FOR_PMP. will be used for PMP calculation) -->';
925 print $langs->trans(
"BuyingPrice").
': <input class="maxwidth75" name="pu'.$suffix.
'" type="text" value="'.
price2num($up_ht_disc,
'MU').
'">';
927 print
'<input class="maxwidth75" name="pu'.$suffix.
'" type="hidden" value="'.
price2num($up_ht_disc,
'MU').
'">';
933 print
'<input type="text" class="inputlotnumber quatrevingtquinzepercent" id="lot_number'.$suffix.
'" name="lot_number'.$suffix.
'" value="'.
GETPOST(
'lot_number'.$suffix).
'">';
936 print
'<td class="nowraponall">';
938 print $form->selectDate($dlcdatesuffix,
'dlc'.$suffix, 0, 0, 1,
'');
942 print
'<td class="nowraponall">';
944 print $form->selectDate($dluodatesuffix,
'dluo'.$suffix, 0, 0, 1,
'');
947 print
'<td colspan="3"> </td>';
957 'is_information_row' =>
true,
962 $reshook = $hookmanager->executeHooks(
963 'printFieldListValue',
971 print $hookmanager->resPrint;
975 print
'<!-- line no batch '.$numline.
' (not dispatched line yet for this order line) -->';
976 print
'<tr class="oddeven autoresettr" name="'.$type.$suffix.
'" data-remove="clear">';
977 print
'<td colspan="'.$colspan.
'">';
978 print
'<input id="fk_commandefourndet'.$suffix.
'" name="fk_commandefourndet'.$suffix.
'" type="hidden" value="'.$objp->rowid.
'">';
979 print
'<input id="idline'.$suffix.
'" name="idline'.$suffix.
'" type="hidden" value="-1">';
980 print
'<input name="product'.$suffix.
'" type="hidden" value="'.$objp->fk_product.
'">';
982 print
'<!-- This is a up (may include discount or not depending on STOCK_EXCLUDE_DISCOUNT_FOR_PMP. will be used for PMP calculation) -->';
984 print $langs->trans(
"BuyingPrice").
': <input class="maxwidth75" name="pu'.$suffix.
'" data-type="text" value="'.
price2num($up_ht_disc,
'MU').
'">';
986 print
'<input class="maxwidth75" name="pu'.$suffix.
'" type="hidden" value="'.
price2num($up_ht_disc,
'MU').
'">';
992 print
'<td class="right">';
993 print
'<a href="#" id="reset'.$suffix.
'" class="resetline">'.
img_picto($langs->trans(
"Reset"),
'eraser',
'class="pictofixedwidth opacitymedium"').
'</a>';
994 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.
'">';
997 if (
isModEnabled(
'productbatch') && $objp->tobatch > 0) {
999 print
img_picto($langs->trans(
'AddStockLocationLine'),
'split',
'class="splitbutton" onClick="addDispatchLine('.$i.
', \''.$type.
'\')
"');
1002 print img_picto($langs->trans('AddStockLocationLine'), 'split', 'class="splitbutton
" onClick="addDispatchLine(
'.$i.', \
''.$type.
'\')
"');
1007 if (getDolGlobalString('SUPPLIER_ORDER_CAN_UPDATE_BUYINGPRICE_DURING_RECEIPT')) {
1008 if (!isModEnabled("multicurrency
") && empty($conf->dynamicprices->enabled)) {
1010 print '<td class="right
">';
1011 print '<input id="pu
'.$suffix.'" name="pu
'.$suffix.'" type="text
" size="8
" value="'.price((GETPOST('pu
'.$suffix) != '' ? price2num(GETPOST('pu
'.$suffix)) : $up_ht_disc)).'">';
1015 print '<td class="right
">';
1016 print '<input id="dto
'.$suffix.'" name="dto
'.$suffix.'" type="text
" size="8
" value="'.(GETPOST('dto
'.$suffix) != '' ? GETPOST('dto
'.$suffix) : '').'">';
1020 print '<td class="center
">';
1021 print '<input class="flat checkformerge
" type="checkbox
" name="saveprice
'.$suffix.'" value="'.(GETPOST('saveprice
'.$suffix) != '' ? GETPOST('saveprice
'.$suffix) : '').'">';
1027 print '<td class="right
">';
1028 if (count($listwarehouses) > 1) {
1029 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);
1030 } elseif (count($listwarehouses) == 1) {
1031 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);
1033 $langs->load("errors
");
1034 print $langs->trans("ErrorNoWarehouseDefined
");
1038 // Enable hooks to append additional columns
1039 $parameters = array(
1040 'is_information_row' => false, // this is a dispatch form row
1042 'suffix' => $suffix,
1045 $reshook = $hookmanager->executeHooks(
1046 'printFieldListValue',
1052 setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
1054 print $hookmanager->resPrint;
1063 dol_print_error($db);
1070 print '<div class="center
">';
1071 $parameters = array();
1072 $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been
1074 if (empty($reshook)) {
1075 /*$checkboxlabel = $langs->trans("CloseReceivedSupplierOrdersAutomatically
", $langs->transnoentitiesnoconv('StatusOrderReceivedAll'));
1077 if (empty($conf->reception->enabled)) {
1078 print $langs->trans("Comment").' : ';
1079 print '<input type="text
" class="minwidth400
" maxlength="128
" name="comment
" value="';
1080 print GETPOSTISSET("comment") ? GETPOST("comment") : $langs->trans("DispatchSupplierOrder", $object->ref);
1081 // print ' /
'.$object->ref_supplier; // Not yet available
1082 print '" class="flat
"><br>';
1084 print '<input type="checkbox
" checked="checked
" name="closeopenorder
"> '.$checkboxlabel;
1087 $dispatchBt = empty($conf->reception->enabled) ? $langs->trans("Receive
") : $langs->trans("CreateReception
");
1092 print '<input type="submit
" id="submitform
" class="button" name="dispatch
" value="'.$langs->trans("Save").'"';
1094 if (!$permissiontoreceive) {
1097 if (count($listwarehouses) <= 0) {
1109 // Message if nothing to dispatch
1112 if (!getDolGlobalString('SUPPLIER_ORDER_DISABLE_STOCK_DISPATCH_WHEN_TOTAL_REACHED')) {
1113 print '<div class="opacitymedium
">'.$langs->trans("NoPredefinedProductToDispatch
").'</div>'; // No predefined line at all
1115 print '<div class="opacitymedium
">'.$langs->trans("NoMorePredefinedProductToDispatch
").'</div>'; // No predefined line that remain to be dispatched.
1122 print dol_get_fiche_end();
1124 // traitement entrepot par défaut
1125 print '<script type="text/javascript
">
1126 $(document).ready(function () {
1127 $("select[
name=fk_default_warehouse]
").change(function() {
1128 var fk_default_warehouse = $("option:selected
", this).val();
1129 $("select[
name^=entrepot_]
").val(fk_default_warehouse).change();
1132 $("#autoreset
").click(function() {
1133 $(".autoresettr
").each(function(){
1134 id = $(this).attr("name");
1135 idtab = id.split("_
");
1136 if ($(this).data("remove") == "clear
"){
1137 console.log("We clear the
object to expected value
")
1138 $("#qty_
"+idtab[1]+"_
"+idtab[2]).val("");
1140 qtyexpected = $("#qty_
"+idtab[1]+"_
"+idtab[2]).data("expected
")
1141 console.log(qtyexpected);
1142 $("#qty_
"+idtab[1]+"_
"+idtab[2]).val(qtyexpected);
1143 qtydispatched = $("#qty_dispatched_0_
"+idtab[2]).data("dispatched
")
1144 $("#qty_dispatched_0_
"+idtab[2]).val(qtydispatched);
1147 console.log("We
remove the
object")
1149 $("tr[
name^=\
'"+idtab[0]+"_\'][name$=\'_"+idtab[2]+"\']:last .splitbutton").show();
1155 $("#resetalltoexpected").click(function(){
1156 $(".qtydispatchinput").each(function(){
1157 console.log("We reset to expected "+$(this).attr("id")+" qty to dispatch");
1158 $(this).val($(this).data("expected"));
1163 $(".resetline").click(function(e){
1165 id = $(this).attr("id");
1166 id = id.split("reset_");
1167 console.log("Reset trigger for id = qty_"+id[1]);
1168 $("#qty_"+id[1]).val("");
$id
Support class for third parties, contacts, members, users or resources.
if(! $sortfield) if(! $sortorder) $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_now($mode='gmt')
Return date for now.
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.
GETPOSTFLOAT($paramname, $rounding='', $option=2)
Return the value of a $_GET or $_POST supervariable, converted into float.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false, $decorate=0)
Output date in a string format according to outputlangs (or langs if not defined).
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
isModEnabled($module)
Is Dolibarr module enabled.
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.
multi select button
0 = Do not include form tag and submit button -1 = Do not include form tag but include submit button
treeview li table
No Email.
print $langs trans("Show") . '< td style="' . $timeColor . '" align="center"> s</td > badge status0 badge status4 badge status3 Error badge status8< td align="center">< span class="badge ' . $badge . '"></span ></td >< td align="center">< a href="#" class="button button-small" onclick="openLogModal(this)" data-req="' . dol_escape_htmltag($reqSafe) . '" data-res="' . dol_escape_htmltag($resSafe) . '" data-err="' . dol_escape_htmltag($errSafe) . '">< span class="fa fa-search-plus"></span ></a ></td ></tr >< tr >< td colspan="' . $colspan . '" class="opacitymedium"></td ></tr ></table ></div ></form > logModal none logModal none s a JSON string
buildzip.php
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.