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'));
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);
137 setEventMessages($hookmanager->error, $hookmanager->errors,
'errors');
141if ($action ==
'updatelines' && $permissiontoreceive && !(
$object->status == Reception::STATUS_DRAFT || (
$object->status == Reception::STATUS_VALIDATED && !
getDolGlobalString(
'STOCK_CALCULATE_ON_RECEPTION')))) {
142 setEventMessages($langs->trans(
'StatusOfRefMustBe',
$object->ref, $langs->transnoentitiesnoconv(
'StatusReceptionDraftShort')),
null,
'errors');
147if ($action ==
'updatelines' && $permissiontoreceive) {
154 foreach ($_POST as $key => $value) {
157 if (preg_match(
'/^product_.*([0-9]+)_([0-9]+)$/i', $key, $reg)) {
160 if (preg_match(
'/^product_([0-9]+)_([0-9]+)$/i', $key, $reg)) {
161 $modebatch =
"barcode";
162 } elseif (preg_match(
'/^product_batch_([0-9]+)_([0-9]+)$/i', $key, $reg)) {
163 $modebatch =
"batch";
167 if ($modebatch ==
"barcode") {
168 $prod =
"product_".$reg[1].
'_'.$reg[2];
170 $prod =
'product_batch_'.$reg[1].
'_'.$reg[2];
172 $qty =
"qty_".$reg[1].
'_'.$reg[2];
173 $ent =
"entrepot_".$reg[1].
'_'.$reg[2];
174 $pu =
"pu_".$reg[1].
'_'.$reg[2];
175 $fk_commandefourndet =
"fk_commandefourndet_".$reg[1].
'_'.$reg[2];
176 $idline =
GETPOSTINT(
"idline_".$reg[1].
'_'.$reg[2]);
180 if ($modebatch ==
"batch") {
181 $lot =
GETPOST(
'lot_number_'.$reg[1].
'_'.$reg[2]);
186 $saveprice =
'__invalidsavepricekey__';
189 $dto =
GETPOSTINT(
"dto_".$reg[1].
'_'.$reg[2]);
193 $saveprice =
"saveprice_".$reg[1].
'_'.$reg[2];
198 if (($modebatch ==
"batch" &&
GETPOST($qty) > 0) || ($modebatch ==
"barcode" &&
GETPOST($qty) != 0)) {
200 dol_syslog(
'No dispatch for line '.$key.
' as no warehouse was chosen.');
201 $text = $langs->transnoentities(
'Warehouse').
', '.$langs->transnoentities(
'Line').
' '.($numline);
202 setEventMessages($langs->trans(
'ErrorFieldRequired', $text),
null,
'errors');
208 $result = $supplierorderdispatch->fetch($idline);
209 if ($result > 0 && (
int) $supplierorderdispatch->fk_reception !== (
int)
$object->id) {
211 $supplierorderdispatch->error = $langs->trans(
'ErrorRecordNotFound');
215 setEventMessages($supplierorderdispatch->error, $supplierorderdispatch->errors,
'errors');
218 $qtystart = $supplierorderdispatch->qty;
220 $supplierorderdispatch->fk_entrepot =
GETPOSTINT($ent);
221 if ($modebatch ==
"batch") {
222 $supplierorderdispatch->eatby = $dDLUO;
223 $supplierorderdispatch->sellby = $dDLC;
226 $result = $supplierorderdispatch->update($user);
228 setEventMessages($supplierorderdispatch->error, $supplierorderdispatch->errors,
'errors');
272 $result = $objectsrc->dispatchProduct($user,
GETPOSTINT($prod),
GETPOSTFLOAT($qty),
GETPOSTINT($ent),
GETPOSTFLOAT($pu),
GETPOST(
'comment'), $dDLUO, $dDLC, $lot,
GETPOSTINT($fk_commandefourndet), 0,
$object->id);
274 setEventMessages($objectsrc->error, $objectsrc->errors,
'errors');
279 if (!$error &&
getDolGlobalString(
'SUPPLIER_ORDER_CAN_UPDATE_BUYINGPRICE_DURING_RECEIPT')) {
289 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"product_fournisseur_price";
290 $sql .=
" SET unitprice='".price2num(
GETPOST($pu),
'MU').
"'";
291 $sql .=
", price=".price2num(
GETPOST($pu),
'MU').
"*quantity";
292 $sql .=
", remise_percent = ".((float) $dto);
293 $sql .=
" WHERE fk_soc=".((int)
$object->socid);
294 $sql .=
" AND fk_product=".(GETPOSTINT($prod));
296 $resql = $db->query($sql);
306 setEventMessages($langs->trans(
"Error"), $errors,
'errors');
309 setEventMessages($langs->trans(
"ReceptionUpdated"),
null);
311 header(
"Location: ".DOL_URL_ROOT.
'/reception/dispatch.php?id='.
$object->id);
323$form =
new Form($db);
325$warehouse_static =
new Entrepot($db);
328$title =
$object->ref.
" - ".$langs->trans(
'ReceptionDistribution');
329$help_url =
'EN:Module_Suppliers_Orders|FR:CommandeFournisseur|ES:Módulo_Pedidos_a_proveedores';
330$morejs = array(
'/fourn/js/lib_dispatch.js.php');
333llxHeader(
'', $title, $help_url,
'', 0, 0, $morejs,
'',
'',
'mod-reception page-card_dispatch');
335if ($id > 0 || !empty($ref)) {
340 $origin_id =
$object->origin_id;
346 $author =
new User($db);
347 $author->fetch(
$object->user_author_id);
351 $title = $langs->trans(
"SupplierOrder");
352 print
dol_get_fiche_head($head,
'dispatch', $langs->trans(
"Reception"), -1,
'dollyrevert');
358 if ($action ==
'ask_deleteline') {
359 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&lineid='.$lineid, $langs->trans(
'DeleteLine'), $langs->trans(
'ConfirmDeleteLine'),
'confirm_deleteline',
'', 0, 1);
363 $parameters = array(
'lineid' => $lineid);
365 $reshook = $hookmanager->executeHooks(
'formConfirm', $parameters, $object, $action);
366 if (empty($reshook)) {
367 $formconfirm .= $hookmanager->resPrint;
368 } elseif ($reshook > 0) {
369 $formconfirm = $hookmanager->resPrint;
376 $linkback =
'<a href="'.DOL_URL_ROOT.
'/reception/list.php?restore_lastsearch_values=1'.(!empty($socid) ?
'&socid='.$socid :
'').
'">'.$langs->trans(
"BackToList").
'</a>';
377 $morehtmlref =
'<div class="refidno">';
380 $morehtmlref .= $form->editfieldkey(
"RefSupplier",
'ref_supplier',
$object->ref_supplier, $object, $user->hasRight(
'reception',
'creer'),
'string',
'', 0, 1);
381 $morehtmlref .= $form->editfieldval(
"RefSupplier",
'ref_supplier',
$object->ref_supplier, $object, $user->hasRight(
'reception',
'creer'),
'string',
'',
null,
null,
'', 1);
384 $morehtmlref .=
'<br>'.$object->thirdparty->getNomUrl(1);
387 $langs->load(
"projects");
388 $morehtmlref .=
'<br>';
390 $morehtmlref .= img_picto($langs->trans(
"Project"),
'project',
'class="pictofixedwidth"');
391 if ($action !=
'classify' && $permissiontoadd) {
392 $morehtmlref .=
'<a class="editfielda" href="'.dolBuildUrl($_SERVER[
'PHP_SELF'], [
'action' =>
'classify',
'id' =>
$object->id],
true).
'">'.img_edit($langs->transnoentitiesnoconv(
'SetProject')).
'</a> ';
394 $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');
396 if (!empty($objectsrc) && !empty($objectsrc->fk_project)) {
398 $proj->fetch((
int) $objectsrc->fk_project);
399 $morehtmlref .= $proj->getNomUrl(1);
401 $morehtmlref .=
'<span class="opacitymedium"> - '.dol_escape_htmltag($proj->title).
'</span>';
406 $morehtmlref .=
'</div>';
408 dol_banner_tab($object,
'ref', $linkback, 1,
'ref',
'ref', $morehtmlref);
411 print
'<div class="fichecenter">';
412 print
'<div class="underbanner clearboth"></div>';
414 print
'<table class="border tableforfield" width="100%">';
419 print $langs->trans(
"RefOrder").
'</td>';
420 print
'<td colspan="3">';
421 print $objectsrc->getNomUrl(1,
'commande');
427 print $langs->trans(
"RefProposal").
'</td>';
428 print
'<td colspan="3">';
429 print $objectsrc->getNomUrl(1,
'reception');
433 if (($typeobject ==
'supplier_order' || $typeobject ==
'order_supplier') &&
$object->origin_object->id &&
isModEnabled(
"propal")) {
435 print $langs->trans(
"SupplierOrder").
'</td>';
436 print
'<td colspan="3">';
437 print $objectsrc->getNomUrl(1,
'reception');
443 print
'<tr><td class="titlefield">'.$langs->trans(
"DateCreation").
'</td>';
444 print
'<td colspan="3">'.dol_print_date(
$object->date_creation,
"dayhour",
"tzuserrel").
"</td>\n";
448 print
'<tr><td height="10">';
449 print
'<table class="nobordernopadding" width="100%"><tr><td>';
450 print $langs->trans(
'DateDeliveryPlanned');
452 print
'</tr></table>';
453 print
'</td><td colspan="2">';
459 print
'<br><br><center>';
460 print
'<a href="#" id="resetalltoexpected" class="marginrightonly paddingright marginleftonly paddingleft">'.img_picto(
"",
'autofill',
'class="pictofixedwidth"').$langs->trans(
"RestoreWithCurrentQtySaved").
'</a></td>';
462 print
'<a href="#" id="autoreset" class="marginrightonly paddingright marginleftonly paddingleft">'.img_picto(
"",
'eraser',
'class="pictofixedwidth"').$langs->trans(
"ClearQtys").
'</a></td>';
470 if (
$object->statut == Reception::STATUS_DRAFT || (
$object->statut == Reception::STATUS_VALIDATED && !
getDolGlobalString(
'STOCK_CALCULATE_ON_RECEPTION'))) {
471 require_once DOL_DOCUMENT_ROOT.
'/product/class/html.formproduct.class.php';
473 $formproduct->loadWarehouses();
475 $listwarehouses = $entrepot->list_array(1);
477 print
'<form method="post" action="'.dolBuildUrl($_SERVER[
"PHP_SELF"]).
'">';
479 print
'<input type="hidden" name="token" value="'.newToken().
'">';
480 print
'<input type="hidden" name="action" value="updatelines">';
481 print
'<input type="hidden" name="id" value="'.$object->id.
'">';
483 print
'<div class="div-table-responsive-no-min">';
484 print
'<table class="noborder centpercent">';
487 $products_dispatched = array();
488 $sql =
"SELECT l.rowid, cfd.fk_product, sum(cfd.qty) as qty";
489 $sql .=
" FROM ".MAIN_DB_PREFIX.
"receptiondet_batch as cfd";
490 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"receptiondet_batch as l on l.rowid = cfd.fk_elementdet";
491 $sql .=
" WHERE cfd.fk_reception = ".((int)
$object->id);
492 $sql .=
" GROUP BY l.rowid, cfd.fk_product";
494 $resql = $db->query($sql);
496 $num = $db->num_rows($resql);
501 $objd = $db->fetch_object($resql);
502 $products_dispatched[$objd->rowid] =
price2num($objd->qty,
'MS');
511 $sql =
"SELECT l.rowid, l.fk_product, l.subprice, l.remise_percent, l.ref AS sref, l.qty as qty,";
512 $sql .=
" p.ref, p.label, p.tobatch, p.fk_default_warehouse";
514 $parameters = array();
515 $reshook = $hookmanager->executeHooks(
516 'printFieldListSelect',
522 setEventMessages($hookmanager->error, $hookmanager->errors,
'errors');
524 $sql .= $hookmanager->resPrint;
525 $sql .=
" FROM ".MAIN_DB_PREFIX.
"commande_fournisseurdet as l";
526 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"product as p ON l.fk_product=p.rowid";
527 $sql .=
" WHERE l.fk_commande = ".((int) $objectsrc->id);
529 $sql .=
" AND l.product_type = 0";
532 $parameters = array();
533 $reshook = $hookmanager->executeHooks(
534 'printFieldListWhere',
540 setEventMessages($hookmanager->error, $hookmanager->errors,
'errors');
542 $sql .= $hookmanager->resPrint;
545 $sql .=
" ORDER BY l.rang, p.ref, p.label";
547 $resql = $db->query($sql);
549 $num = $db->num_rows($resql);
553 print
'<tr class="liste_titre">';
555 print
'<td>'.$langs->trans(
"Description").
'</td>';
557 print
'<td class="dispatch_batch_number_title">'.$langs->trans(
"batch_number").
'</td>';
559 print
'<td class="dispatch_dlc_title">'.$langs->trans(
"SellByDate").
'</td>';
562 print
'<td class="dispatch_dluo_title">'.$langs->trans(
"EatByDate").
'</td>';
569 print
'<td class="right">'.$langs->trans(
"SupplierRef").
'</td>';
570 print
'<td class="right">'.$langs->trans(
"QtyOrdered").
'</td>';
571 if (
$object->status == Reception::STATUS_DRAFT) {
572 print
'<td class="right">'.$langs->trans(
"QtyToReceive");
574 print
'<td class="right">'.$langs->trans(
"QtyDispatchedShort").
'</td>';
576 print
'<td class="right">'.$langs->trans(
"Details");
577 print
'<td width="32"></td>';
581 print
'<td class="right">'.$langs->trans(
"Price").
'</td>';
582 print
'<td class="right">'.$langs->trans(
"ReductionShort").
' (%)</td>';
583 print
'<td class="right">'.$langs->trans(
"UpdatePrice").
'</td>';
587 print
'<td align="right">'.$langs->trans(
"Warehouse");
590 if (count($listwarehouses) > 1) {
591 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);
592 } elseif (count($listwarehouses) == 1) {
593 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);
599 $parameters = array();
600 $reshook = $hookmanager->executeHooks(
601 'printFieldListTitle',
607 setEventMessages($hookmanager->error, $hookmanager->errors,
'errors');
609 print $hookmanager->resPrint;
617 $conf->cache[
'product'] = array();
621 $objp = $db->fetch_object($resql);
624 if (!$objp->fk_product > 0) {
627 $alreadydispatched = isset($products_dispatched[$objp->rowid]) ? $products_dispatched[$objp->rowid] : 0;
628 $remaintodispatch =
price2num($objp->qty, 5);
629 if ($remaintodispatch < 0 && !
getDolGlobalString(
'SUPPLIER_ORDER_ALLOW_NEGATIVE_QTY_FOR_SUPPLIER_ORDER_RETURN')) {
630 $remaintodispatch = 0;
633 if ($remaintodispatch || !
getDolGlobalString(
'SUPPLIER_ORDER_DISABLE_STOCK_DISPATCH_WHEN_TOTAL_REACHED')) {
642 print
'<!-- Line to dispatch '.$suffix.
' -->'.
"\n";
644 print
'<input id="qty_ordered'.$suffix.
'" type="hidden" value="'.$objp->qty.
'">';
645 print
'<input id="qty_dispatched'.$suffix.
'" type="hidden" data-dispatched="'.((float) $alreadydispatched).
'" value="'.(float) $alreadydispatched.
'">';
646 print
'<tr class="oddeven">';
648 if (empty(
$conf->cache[
'product'][$objp->fk_product])) {
649 $tmpproduct =
new Product($db);
650 $tmpproduct->fetch($objp->fk_product);
651 $conf->cache[
'product'][$objp->fk_product] = $tmpproduct;
653 $tmpproduct =
$conf->cache[
'product'][$objp->fk_product];
656 $linktoprod = $tmpproduct->getNomUrl(1);
657 $linktoprod .=
' - '.$objp->label.
"\n";
660 if ($objp->tobatch) {
662 print
'<td class="tdoverflowmax200">';
665 print
'<td class="dispatch_batch_number"></td>';
667 print
'<td class="dispatch_dlc"></td>';
670 print
'<td class="dispatch_dluo"></td>';
674 print
'<td class="tdoverflowmax200">';
677 print
'<td class="dispatch_batch_number">';
678 print
'<span class="opacitymedium small">'.$form->textwithpicto($langs->transnoentitiesnoconv(
"NA"), $langs->transnoentitiesnoconv(
"ProductDoesNotUseBatchSerial")).
'</small>';
681 print
'<td class="dispatch_dlc"></td>';
684 print
'<td class="dispatch_dluo"></td>';
688 print
'<td colspan="4">';
694 $up_ht_disc = $objp->subprice;
695 if (!empty($objp->remise_percent) && !
getDolGlobalString(
'STOCK_EXCLUDE_DISCOUNT_FOR_PMP')) {
696 $up_ht_disc =
price2num($up_ht_disc * (100 - $objp->remise_percent) / 100,
'MU');
700 print
'<td class="right">'.$objp->sref.
'</td>';
703 print
'<td class="right">'.$objp->qty.
'</td>';
706 print
'<td class="right">'.$alreadydispatched.
'</td>';
708 print
'<td class="right">';
714 $sql =
"SELECT cfd.rowid, cfd.qty, cfd.fk_entrepot, cfd.batch, cfd.eatby, cfd.sellby, cfd.fk_product";
715 $sql .=
" FROM ".MAIN_DB_PREFIX.
"receptiondet_batch as cfd";
716 $sql .=
" WHERE cfd.fk_reception = ".((int)
$object->id);
717 $sql .=
" AND cfd.fk_element = ".((int) $objectsrc->id);
718 $sql .=
" AND cfd.fk_elementdet = ".(int) $objp->rowid;
721 $resultsql = $db->query($sql);
724 $numd = $db->num_rows($resultsql);
727 $suffix =
"_".$j.
"_".$i;
728 $objd = $db->fetch_object($resultsql);
730 if (
isModEnabled(
'productbatch') && (!empty($objd->batch) || (is_null($objd->batch) && $tmpproduct->status_batch > 0))) {
736 'is_information_row' =>
true,
741 $reshook = $hookmanager->executeHooks(
742 'printFieldListValue',
748 setEventMessages($hookmanager->error, $hookmanager->errors,
'errors');
750 print $hookmanager->resPrint;
754 print
'<!-- line for batch '.$numline.
' -->';
755 print
'<tr class="oddeven autoresettr" name="'.$type.$suffix.
'" data-remove="clear">';
757 print
'<input id="fk_commandefourndet'.$suffix.
'" name="fk_commandefourndet'.$suffix.
'" type="hidden" value="'.$objp->rowid.
'">';
758 print
'<input id="idline'.$suffix.
'" name="idline'.$suffix.
'" type="hidden" value="'.$objd->rowid.
'">';
759 print
'<input name="product_batch'.$suffix.
'" type="hidden" value="'.$objd->fk_product.
'">';
761 print
'<!-- This is a U.P. (may include discount or not depending on STOCK_EXCLUDE_DISCOUNT_FOR_PMP. will be used for PMP calculation) -->';
763 print $langs->trans(
"BuyingPrice").
': <input class="maxwidth75" name="pu'.$suffix.
'" type="text" value="'.
price2num($up_ht_disc,
'MU').
'">';
765 print
'<input class="maxwidth75" name="pu'.$suffix.
'" type="hidden" value="'.
price2num($up_ht_disc,
'MU').
'">';
771 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).
'">';
774 print
'<td class="nowraponall">';
776 print $form->selectDate($dlcdatesuffix,
'dlc'.$suffix, 0, 0, 1,
'');
780 print
'<td class="nowraponall">';
782 print $form->selectDate($dluodatesuffix,
'dluo'.$suffix, 0, 0, 1,
'');
785 print
'<td colspan="3"> </td>';
795 'is_information_row' =>
true,
800 $reshook = $hookmanager->executeHooks(
801 'printFieldListValue',
807 setEventMessages($hookmanager->error, $hookmanager->errors,
'errors');
809 print $hookmanager->resPrint;
813 print
'<!-- line no batch '.$numline.
' -->';
814 print
'<tr class="oddeven autoresettr" name="'.$type.$suffix.
'" data-remove="clear">';
815 print
'<td colspan="'.$colspan.
'">';
816 print
'<input id="fk_commandefourndet'.$suffix.
'" name="fk_commandefourndet'.$suffix.
'" type="hidden" value="'.$objp->rowid.
'">';
817 print
'<input id="idline'.$suffix.
'" name="idline'.$suffix.
'" type="hidden" value="'.$objd->rowid.
'">';
818 print
'<input name="product'.$suffix.
'" type="hidden" value="'.$objd->fk_product.
'">';
820 print
'<!-- This is a up (may include discount or not depending on STOCK_EXCLUDE_DISCOUNT_FOR_PMP. will be used for PMP calculation) -->';
822 print $langs->trans(
"BuyingPrice").
': <input class="maxwidth75" name="pu'.$suffix.
'" type="text" value="'.
price2num($up_ht_disc,
'MU').
'">';
824 print
'<input class="maxwidth75" name="pu'.$suffix.
'" type="hidden" value="'.
price2num($up_ht_disc,
'MU').
'">';
830 print
'<td class="right nowraponall">';
831 print
'<a href="#" id="reset'.$suffix.
'" class="resetline">'.img_picto($langs->trans(
"Reset"),
'eraser',
'class="pictofixedwidth opacitymedium"').
'</a>';
832 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.
'">';
835 if (
isModEnabled(
'productbatch') && $objp->tobatch > 0) {
837 print img_picto($langs->trans(
'AddStockLocationLine'),
'split',
'class="splitbutton" '.($numd != $j + 1 ?
'style="display:none"' :
'').
' onClick="addDispatchLine('.$i.
', \''.$type.
'\')"');
838 if ($objp->tobatch == 2) {
840 print img_picto($langs->trans(
'EnterMultipleSerialNumbers'),
'barcode',
'class="splitbutton marginleftonly" '.($numd != $j + 1 ?
'style="display:none"' :
'').
' onClick="addDispatchLinesFromSerialList('.$i.
', \''.$type.
'\')"');
844 print img_picto($langs->trans(
'AddStockLocationLine'),
'split',
'class="splitbutton" '.($numd != $j + 1 ?
'style="display:none"' :
'').
' onClick="addDispatchLine('.$i.
', \''.$type.
'\')"');
852 print
'<td class="right">';
853 print
'<input id="pu'.$suffix.
'" name="pu'.$suffix.
'" type="text" size="8" value="'.
price((
GETPOST(
'pu'.$suffix) !=
'' ?
price2num(
GETPOST(
'pu'.$suffix)) : $up_ht_disc)).
'">';
857 print
'<td class="right">';
858 print
'<input id="dto'.$suffix.
'" name="dto'.$suffix.
'" type="text" size="8" value="'.(
GETPOST(
'dto'.$suffix) !=
'' ?
GETPOST(
'dto'.$suffix) :
'').
'">';
862 print
'<td class="center">';
863 print
'<input class="flat checkformerge" type="checkbox" name="saveprice'.$suffix.
'" value="'.(
GETPOST(
'saveprice'.$suffix) !=
'' ?
GETPOST(
'saveprice'.$suffix) :
'').
'">';
869 print
'<td class="right">';
870 if (count($listwarehouses) > 1) {
871 print $formproduct->selectWarehouses(
GETPOST(
"entrepot".$suffix) ?
GETPOST(
"entrepot".$suffix) : $objd->fk_entrepot,
"entrepot".$suffix,
'', 1, 0, $objp->fk_product,
'', 1, 0, array(),
'csswarehouse'.$suffix);
872 } elseif (count($listwarehouses) == 1) {
873 print $formproduct->selectWarehouses(
GETPOST(
"entrepot".$suffix) ?
GETPOST(
"entrepot".$suffix) : $objd->fk_entrepot,
"entrepot".$suffix,
'', 0, 0, $objp->fk_product,
'', 1, 0, array(),
'csswarehouse'.$suffix);
875 $langs->load(
"errors");
876 print $langs->trans(
"ErrorNoWarehouseDefined");
882 'is_information_row' =>
false,
887 $reshook = $hookmanager->executeHooks(
888 'printFieldListValue',
894 setEventMessages($hookmanager->error, $hookmanager->errors,
'errors');
896 print $hookmanager->resPrint;
903 $suffix =
"_".$j.
"_".$i;
907 if (
isModEnabled(
'productbatch') && !empty($objp->tobatch)) {
913 'is_information_row' =>
true,
918 $reshook = $hookmanager->executeHooks(
919 'printFieldListValue',
925 setEventMessages($hookmanager->error, $hookmanager->errors,
'errors');
927 print $hookmanager->resPrint;
931 print
'<!-- line for batch '.$numline.
' (not dispatched line yet for this order line) -->';
932 print
'<tr class="oddeven autoresettr" name="'.$type.$suffix.
'">';
934 print
'<input id="fk_commandefourndet'.$suffix.
'" name="fk_commandefourndet'.$suffix.
'" type="hidden" value="'.$objp->rowid.
'">';
935 print
'<input id="idline'.$suffix.
'" name="idline'.$suffix.
'" type="hidden" value="-1">';
936 print
'<input name="product_batch'.$suffix.
'" type="hidden" value="'.$objp->fk_product.
'">';
938 print
'<!-- This is a up (may include discount or not depending on STOCK_EXCLUDE_DISCOUNT_FOR_PMP. will be used for PMP calculation) -->';
940 print $langs->trans(
"BuyingPrice").
': <input class="maxwidth75" name="pu'.$suffix.
'" type="text" value="'.
price2num($up_ht_disc,
'MU').
'">';
942 print
'<input class="maxwidth75" name="pu'.$suffix.
'" type="hidden" value="'.
price2num($up_ht_disc,
'MU').
'">';
948 print
'<input type="text" class="inputlotnumber quatrevingtquinzepercent" id="lot_number'.$suffix.
'" name="lot_number'.$suffix.
'" value="'.
GETPOST(
'lot_number'.$suffix).
'">';
951 print
'<td class="nowraponall">';
953 print $form->selectDate($dlcdatesuffix,
'dlc'.$suffix, 0, 0, 1,
'');
957 print
'<td class="nowraponall">';
959 print $form->selectDate($dluodatesuffix,
'dluo'.$suffix, 0, 0, 1,
'');
962 print
'<td colspan="3"> </td>';
972 'is_information_row' =>
true,
977 $reshook = $hookmanager->executeHooks(
978 'printFieldListValue',
984 setEventMessages($hookmanager->error, $hookmanager->errors,
'errors');
986 print $hookmanager->resPrint;
990 print
'<!-- line no batch '.$numline.
' (not dispatched line yet for this order line) -->';
991 print
'<tr class="oddeven autoresettr" name="'.$type.$suffix.
'" data-remove="clear">';
992 print
'<td colspan="'.$colspan.
'">';
993 print
'<input id="fk_commandefourndet'.$suffix.
'" name="fk_commandefourndet'.$suffix.
'" type="hidden" value="'.$objp->rowid.
'">';
994 print
'<input id="idline'.$suffix.
'" name="idline'.$suffix.
'" type="hidden" value="-1">';
995 print
'<input name="product'.$suffix.
'" type="hidden" value="'.$objp->fk_product.
'">';
997 print
'<!-- This is a up (may include discount or not depending on STOCK_EXCLUDE_DISCOUNT_FOR_PMP. will be used for PMP calculation) -->';
999 print $langs->trans(
"BuyingPrice").
': <input class="maxwidth75" name="pu'.$suffix.
'" data-type="text" value="'.
price2num($up_ht_disc,
'MU').
'">';
1001 print
'<input class="maxwidth75" name="pu'.$suffix.
'" type="hidden" value="'.
price2num($up_ht_disc,
'MU').
'">';
1007 print
'<td class="right">';
1008 print
'<a href="#" id="reset'.$suffix.
'" class="resetline">'.img_picto($langs->trans(
"Reset"),
'eraser',
'class="pictofixedwidth opacitymedium"').
'</a>';
1009 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.
'">';
1012 if (
isModEnabled(
'productbatch') && $objp->tobatch > 0) {
1014 print img_picto($langs->trans(
'AddStockLocationLine'),
'split',
'class="splitbutton" onClick="addDispatchLine('.$i.
', \''.$type.
'\')
"');
1015 if ($objp->tobatch == 2) {
1016 // Product managed with unique serial numbers: allow to enter several serial numbers at once (one line per serial)
1017 print img_picto($langs->trans('EnterMultipleSerialNumbers'), 'barcode', 'class="splitbutton marginleftonly
" onClick="addDispatchLinesFromSerialList(
'.$i.', \
''.$type.
'\')
"');
1021 print img_picto($langs->trans('AddStockLocationLine'), 'split', 'class="splitbutton
" onClick="addDispatchLine(
'.$i.', \
''.$type.
'\')
"');
1026 if (getDolGlobalString('SUPPLIER_ORDER_CAN_UPDATE_BUYINGPRICE_DURING_RECEIPT')) {
1027 if (!isModEnabled("multicurrency
") && empty($conf->dynamicprices->enabled)) {
1029 print '<td class="right
">';
1030 print '<input id="pu
'.$suffix.'" name="pu
'.$suffix.'" type="text
" size="8
" value="'.price((GETPOST('pu
'.$suffix) != '' ? price2num(GETPOST('pu
'.$suffix)) : $up_ht_disc)).'">';
1034 print '<td class="right
">';
1035 print '<input id="dto
'.$suffix.'" name="dto
'.$suffix.'" type="text
" size="8
" value="'.(GETPOST('dto
'.$suffix) != '' ? GETPOST('dto
'.$suffix) : '').'">';
1039 print '<td class="center
">';
1040 print '<input class="flat checkformerge
" type="checkbox
" name="saveprice
'.$suffix.'" value="'.(GETPOST('saveprice
'.$suffix) != '' ? GETPOST('saveprice
'.$suffix) : '').'">';
1046 print '<td class="right
">';
1047 if (count($listwarehouses) > 1) {
1048 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);
1049 } elseif (count($listwarehouses) == 1) {
1050 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);
1052 $langs->load("errors
");
1053 print $langs->trans("ErrorNoWarehouseDefined
");
1057 // Enable hooks to append additional columns
1058 $parameters = array(
1059 'is_information_row' => false, // this is a dispatch form row
1061 'suffix' => $suffix,
1064 $reshook = $hookmanager->executeHooks(
1065 'printFieldListValue',
1071 setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
1073 print $hookmanager->resPrint;
1082 dol_print_error($db);
1089 print '<div class="center
">';
1090 $parameters = array();
1091 $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been
1093 if (empty($reshook)) {
1094 /*$checkboxlabel = $langs->trans("CloseReceivedSupplierOrdersAutomatically
", $langs->transnoentitiesnoconv('StatusOrderReceivedAll'));
1096 if (empty($conf->reception->enabled)) {
1097 print $langs->trans("Comment").' : ';
1098 print '<input type="text
" class="minwidth400
" maxlength="128
" name="comment
" value="';
1099 print GETPOSTISSET("comment") ? GETPOST("comment") : $langs->trans("DispatchSupplierOrder", $object->ref);
1100 // print ' /
'.$object->ref_supplier; // Not yet available
1101 print '" class="flat
"><br>';
1103 print '<input type="checkbox
" checked="checked
" name="closeopenorder
"> '.$checkboxlabel;
1106 $dispatchBt = empty($conf->reception->enabled) ? $langs->trans("Receive
") : $langs->trans("CreateReception
");
1111 print '<input type="submit
" id="submitform
" class="button" name="dispatch
" value="'.$langs->trans("Save").'"';
1113 if (!$permissiontoreceive) {
1116 if (count($listwarehouses) <= 0) {
1128 // Message if nothing to dispatch
1131 if (!getDolGlobalString('SUPPLIER_ORDER_DISABLE_STOCK_DISPATCH_WHEN_TOTAL_REACHED')) {
1132 print '<div class="opacitymedium
">'.$langs->trans("NoPredefinedProductToDispatch
").'</div>'; // No predefined line at all
1134 print '<div class="opacitymedium
">'.$langs->trans("NoMorePredefinedProductToDispatch
").'</div>'; // No predefined line that remain to be dispatched.
1141 print dol_get_fiche_end();
1143 // Handling of the default warehouse
1144 print '<script type="text/javascript
">
1145 $(document).ready(function () {
1146 $("select[
name=fk_default_warehouse]
").change(function() {
1147 var fk_default_warehouse = $("option:selected
", this).val();
1148 $("select[
name^=entrepot_]
").val(fk_default_warehouse).change();
1151 $("#autoreset
").click(function() {
1152 $(".autoresettr
").each(function(){
1153 id = $(this).attr("name");
1154 idtab = id.split("_
");
1155 if ($(this).data("remove") == "clear
"){
1156 console.log("We clear the
object to expected value
")
1157 $("#qty_
"+idtab[1]+"_
"+idtab[2]).val("");
1159 qtyexpected = $("#qty_
"+idtab[1]+"_
"+idtab[2]).data("expected
")
1160 console.log(qtyexpected);
1161 $("#qty_
"+idtab[1]+"_
"+idtab[2]).val(qtyexpected);
1162 qtydispatched = $("#qty_dispatched_0_
"+idtab[2]).data("dispatched
")
1163 $("#qty_dispatched_0_
"+idtab[2]).val(qtydispatched);
1166 console.log("We
remove the
object")
1168 $("tr[
name^=\
'"+idtab[0]+"_\'][name$=\'_"+idtab[2]+"\']:last .splitbutton").show();
1174 $("#resetalltoexpected").click(function(){
1175 $(".qtydispatchinput").each(function(){
1176 console.log("We reset to expected "+$(this).attr("id")+" qty to dispatch");
1177 $(this).val($(this).data("expected"));
1182 $(".resetline").click(function(e){
1184 id = $(this).attr("id");
1185 id = id.split("reset_");
1186 console.log("Reset trigger for id = qty_"+id[1]);
1187 $("#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.
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $conf
The main.inc.php has been included so the following variable are now defined:
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, $processnotimeasnoon=0)
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...
price2num($amount, $rounding='', $option=0, $currencycode='')
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.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0, $nodefault=0)
Return value of a param into GET or POST supervariable.
GETPOSTFLOAT($paramname, $rounding='', $option=2)
Return the value of a $_GET or $_POST supervariable, converted into float.
GETPOSTINT($paramname, $method=0, $nodefault=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
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).
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
isModEnabled($module)
Is Dolibarr module enabled.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
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.
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, $nodie=0, $mode='')
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.
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.