34require
'../main.inc.php';
35require_once DOL_DOCUMENT_ROOT.
'/core/modules/supplier_order/modules_commandefournisseur.php';
36require_once DOL_DOCUMENT_ROOT.
'/product/stock/class/entrepot.class.php';
37require_once DOL_DOCUMENT_ROOT.
'/core/lib/fourn.lib.php';
38require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.commande.class.php';
39require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.commande.dispatch.class.php';
40require_once DOL_DOCUMENT_ROOT.
'/product/class/html.formproduct.class.php';
41require_once DOL_DOCUMENT_ROOT.
'/product/stock/class/mouvementstock.class.php';
42require_once DOL_DOCUMENT_ROOT.
'/core/lib/reception.lib.php';
43require_once DOL_DOCUMENT_ROOT.
'/projet/class/project.class.php';
46$langs->loadLangs(array(
"bills",
"orders",
"sendings",
"companies",
"deliveries",
"products",
"stocks",
"receptions"));
48if (isModEnabled(
'productbatch')) {
49 $langs->load(
'productbatch');
55$lineid =
GETPOST(
'lineid',
'int');
56$action =
GETPOST(
'action',
'aZ09');
57$fk_default_warehouse =
GETPOST(
'fk_default_warehouse',
'int');
58$cancel =
GETPOST(
'cancel',
'alpha');
59$confirm =
GETPOST(
'confirm',
'alpha');
65 $socid = $user->socid;
68$hookmanager->initHooks(array(
'ordersupplierdispatch'));
72if (GETPOSTISSET(
"projectid")) {
73 $projectid =
GETPOST(
"projectid",
'int');
78if ($id > 0 || !empty($ref)) {
79 $result = $object->fetch($id, $ref);
83 $result = $object->fetch_thirdparty();
87 if (!empty($object->origin)) {
88 $origin = $object->origin;
90 $object->fetch_origin();
91 $typeobject = $object->origin;
93 if ($origin ==
'order_supplier' && $object->$typeobject->id && (isModEnabled(
"fournisseur") && !
getDolGlobalString(
'MAIN_USE_NEW_SUPPLIERMOD') || isModEnabled(
"supplier_order"))) {
94 $origin_id = $object->$typeobject->id;
96 $objectsrc->fetch($object->$typeobject->id);
100if (empty($conf->reception->enabled)) {
101 $permissiontoreceive = $user->rights->fournisseur->commande->receptionner;
102 $permissiontocontrol = ((!
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') && !empty($user->rights->fournisseur->commande->receptionner)) || (
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') && !empty($user->rights->fournisseur->commande_advance->check)));
104 $permissiontoreceive = $user->rights->reception->creer;
105 $permissiontocontrol = ((!
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') && !empty($user->rights->reception->creer)) || (
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') && !empty($user->rights->reception->reception_advance->validate)));
111if (!isModEnabled(
'stock')) {
115$usercancreate = $user->hasRight(
'reception',
'creer');
116$permissiontoadd = $usercancreate;
123$parameters = array();
124$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
130if ($action ==
'updatelines' && $permissiontoreceive) {
137 foreach ($_POST as $key => $value) {
140 if (preg_match(
'/^product_.*([0-9]+)_([0-9]+)$/i', $key, $reg)) {
142 if (preg_match(
'/^product_([0-9]+)_([0-9]+)$/i', $key, $reg)) {
143 $modebatch =
"barcode";
144 } elseif (preg_match(
'/^product_batch_([0-9]+)_([0-9]+)$/i', $key, $reg)) {
145 $modebatch =
"batch";
149 if ($modebatch ==
"barcode") {
150 $prod =
"product_".$reg[1].
'_'.$reg[2];
152 $prod =
'product_batch_'.$reg[1].
'_'.$reg[2];
154 $qty =
"qty_".$reg[1].
'_'.$reg[2];
155 $ent =
"entrepot_".$reg[1].
'_'.$reg[2];
156 $pu =
"pu_".$reg[1].
'_'.$reg[2];
157 $fk_commandefourndet =
"fk_commandefourndet_".$reg[1].
'_'.$reg[2];
158 $idline =
GETPOST(
"idline_".$reg[1].
'_'.$reg[2]);
162 if ($modebatch ==
"batch") {
163 $lot =
GETPOST(
'lot_number_'.$reg[1].
'_'.$reg[2]);
164 $dDLUO =
dol_mktime(12, 0, 0,
GETPOST(
'dluo_'.$reg[1].
'_'.$reg[2].
'month',
'int'),
GETPOST(
'dluo_'.$reg[1].
'_'.$reg[2].
'day',
'int'),
GETPOST(
'dluo_'.$reg[1].
'_'.$reg[2].
'year',
'int'));
165 $dDLC =
dol_mktime(12, 0, 0,
GETPOST(
'dlc_'.$reg[1].
'_'.$reg[2].
'month',
'int'),
GETPOST(
'dlc_'.$reg[1].
'_'.$reg[2].
'day',
'int'),
GETPOST(
'dlc_'.$reg[1].
'_'.$reg[2].
'year',
'int'));
169 if (!isModEnabled(
"multicurrency") && empty($conf->dynamicprices->enabled)) {
170 $dto =
GETPOST(
"dto_".$reg[1].
'_'.$reg[2],
'int');
174 $saveprice =
"saveprice_".$reg[1].
'_'.$reg[2];
179 if (($modebatch ==
"batch" &&
GETPOST($qty) > 0) || ($modebatch ==
"barcode" &&
GETPOST($qty) != 0)) {
180 if (!(
GETPOST($ent,
'int') > 0)) {
181 dol_syslog(
'No dispatch for line '.$key.
' as no warehouse was chosen.');
182 $text = $langs->transnoentities(
'Warehouse').
', '.$langs->transnoentities(
'Line').
' '.($numline);
183 setEventMessages($langs->trans(
'ErrorFieldRequired', $text),
null,
'errors');
189 $result = $supplierorderdispatch->fetch($idline);
191 setEventMessages($supplierorderdispatch->error, $supplierorderdispatch->errors,
'errors');
194 $qtystart = $supplierorderdispatch->qty;
195 $supplierorderdispatch->qty =
GETPOST($qty);
196 $supplierorderdispatch->fk_entrepot =
GETPOST($ent,
'int');
197 if ($modebatch ==
"batch") {
198 $supplierorderdispatch->eatby = $dDLUO;
199 $supplierorderdispatch->sellby = $dDLC;
202 $result = $supplierorderdispatch->update($user);
204 setEventMessages($supplierorderdispatch->error, $supplierorderdispatch->errors,
'errors');
248 $result = $objectsrc->dispatchProduct($user,
GETPOST($prod,
'int'),
GETPOST($qty),
GETPOST($ent,
'int'),
GETPOST($pu),
GETPOST(
'comment'), $dDLUO, $dDLC, $lot,
GETPOST($fk_commandefourndet,
'int'), 0, $object->id);
255 if (!$error &&
getDolGlobalString(
'SUPPLIER_ORDER_CAN_UPDATE_BUYINGPRICE_DURING_RECEIPT')) {
256 if (!isModEnabled(
"multicurrency") && empty($conf->dynamicprices->enabled)) {
263 if (GETPOSTISSET($saveprice)) {
265 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"product_fournisseur_price";
266 $sql .=
" SET unitprice='".price2num(
GETPOST($pu),
'MU').
"'";
267 $sql .=
", price=".price2num(
GETPOST($pu),
'MU').
"*quantity";
268 $sql .=
", remise_percent = ".((float) $dto);
269 $sql .=
" WHERE fk_soc=".((int) $object->socid);
270 $sql .=
" AND fk_product=".((int)
GETPOST($prod,
'int'));
272 $resql = $db->query($sql);
287 header(
"Location: ".DOL_URL_ROOT.
'/reception/dispatch.php?id='.$object->id);
299$form =
new Form($db);
301$warehouse_static =
new Entrepot($db);
304$title = $object->ref.
" - ".$langs->trans(
'ReceptionDistribution');
305$help_url =
'EN:Module_Suppliers_Orders|FR:CommandeFournisseur|ES:Módulo_Pedidos_a_proveedores';
306$morejs = array(
'/fourn/js/lib_dispatch.js.php');
308llxHeader(
'', $title, $help_url,
'', 0, 0, $morejs);
310if ($id > 0 || !empty($ref)) {
311 if (!empty($object->origin) && $object->origin_id > 0) {
312 $object->origin =
'CommandeFournisseur';
313 $typeobject = $object->origin;
314 $origin = $object->origin;
315 $origin_id = $object->origin_id;
316 $object->fetch_origin();
319 $soc->fetch($object->socid);
321 $author =
new User($db);
322 $author->fetch($object->user_author_id);
326 $title = $langs->trans(
"SupplierOrder");
327 print
dol_get_fiche_head($head,
'dispatch', $langs->trans(
"Reception"), -1,
'dollyrevert');
333 if ($action ==
'ask_deleteline') {
334 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'&lineid='.$lineid, $langs->trans(
'DeleteLine'), $langs->trans(
'ConfirmDeleteLine'),
'confirm_deleteline',
'', 0, 1);
338 $parameters = array(
'lineid' => $lineid);
340 $reshook = $hookmanager->executeHooks(
'formConfirm', $parameters, $object, $action);
341 if (empty($reshook)) {
342 $formconfirm .= $hookmanager->resPrint;
343 } elseif ($reshook > 0) {
344 $formconfirm = $hookmanager->resPrint;
351 $linkback =
'<a href="'.DOL_URL_ROOT.
'/reception/list.php?restore_lastsearch_values=1'.(!empty($socid) ?
'&socid='.$socid :
'').
'">'.$langs->trans(
"BackToList").
'</a>';
352 $morehtmlref =
'<div class="refidno">';
355 $morehtmlref .= $form->editfieldkey(
"RefSupplier",
'ref_supplier', $object->ref_supplier, $object, $user->hasRight(
'reception',
'creer'),
'string',
'', 0, 1);
356 $morehtmlref .= $form->editfieldval(
"RefSupplier",
'ref_supplier', $object->ref_supplier, $object, $user->hasRight(
'reception',
'creer'),
'string',
'',
null,
null,
'', 1);
359 $morehtmlref .=
'<br>'.$object->thirdparty->getNomUrl(1);
361 if (isModEnabled(
'project')) {
362 $langs->load(
"projects");
363 $morehtmlref .=
'<br>';
365 $morehtmlref .=
img_picto($langs->trans(
"Project"),
'project',
'class="pictofixedwidth"');
366 if ($action !=
'classify' && $permissiontoadd) {
367 $morehtmlref .=
'<a class="editfielda" href="'.$_SERVER[
'PHP_SELF'].
'?action=classify&token='.newToken().
'&id='.$object->id.
'">'.
img_edit($langs->transnoentitiesnoconv(
'SetProject')).
'</a> ';
369 $morehtmlref .= $form->form_project($_SERVER[
'PHP_SELF'].
'?id='.$object->id, (!
getDolGlobalString(
'PROJECT_CAN_ALWAYS_LINK_TO_ALL_SUPPLIERS') ? $object->socid : -1), $object->fk_project, ($action ==
'classify' ?
'projectid' :
'none'), 0, 0, 0, 1,
'',
'maxwidth300');
371 if (!empty($objectsrc) && !empty($objectsrc->fk_project)) {
373 $proj->fetch($objectsrc->fk_project);
374 $morehtmlref .= $proj->getNomUrl(1);
376 $morehtmlref .=
'<span class="opacitymedium"> - '.dol_escape_htmltag($proj->title).
'</span>';
381 $morehtmlref .=
'</div>';
383 dol_banner_tab($object,
'ref', $linkback, 1,
'ref',
'ref', $morehtmlref);
386 print
'<div class="fichecenter">';
387 print
'<div class="underbanner clearboth"></div>';
389 print
'<table class="border tableforfield" width="100%">';
392 if ($typeobject ==
'commande' && $object->$typeobject->id && isModEnabled(
'commande')) {
394 print $langs->trans(
"RefOrder").
'</td>';
395 print
'<td colspan="3">';
396 print $objectsrc->getNomUrl(1,
'commande');
400 if ($typeobject ==
'propal' && $object->$typeobject->id && isModEnabled(
"propal")) {
402 print $langs->trans(
"RefProposal").
'</td>';
403 print
'<td colspan="3">';
404 print $objectsrc->getNomUrl(1,
'reception');
408 if ($typeobject ==
'CommandeFournisseur' && $object->$typeobject->id && isModEnabled(
"propal")) {
410 print $langs->trans(
"SupplierOrder").
'</td>';
411 print
'<td colspan="3">';
412 print $objectsrc->getNomUrl(1,
'reception');
418 print
'<tr><td class="titlefield">'.$langs->trans(
"DateCreation").
'</td>';
419 print
'<td colspan="3">'.dol_print_date($object->date_creation,
"dayhour",
"tzuserrel").
"</td>\n";
423 print
'<tr><td height="10">';
424 print
'<table class="nobordernopadding" width="100%"><tr><td>';
425 print $langs->trans(
'DateDeliveryPlanned');
427 print
'</tr></table>';
428 print
'</td><td colspan="2">';
429 print $object->date_delivery ?
dol_print_date($object->date_delivery,
'dayhour') :
' ';
434 print
'<br><br><center>';
435 print
'<a href="#" id="resetalltoexpected" class="marginrightonly paddingright marginleftonly paddingleft">'.img_picto(
"",
'autofill',
'class="pictofixedwidth"').$langs->trans(
"RestoreWithCurrentQtySaved").
'</a></td>';
437 print
'<a href="#" id="autoreset" class="marginrightonly paddingright marginleftonly paddingleft">'.img_picto(
"",
'eraser',
'class="pictofixedwidth"').$langs->trans(
"ClearQtys").
'</a></td>';
443 if ($object->statut == Reception::STATUS_DRAFT || ($object->statut == Reception::STATUS_VALIDATED && !
getDolGlobalString(
'STOCK_CALCULATE_ON_RECEPTION'))) {
444 require_once DOL_DOCUMENT_ROOT.
'/product/class/html.formproduct.class.php';
446 $formproduct->loadWarehouses();
448 $listwarehouses = $entrepot->list_array(1);
450 print
'<form method="post" action="'.$_SERVER[
"PHP_SELF"].
'">';
452 print
'<input type="hidden" name="token" value="'.newToken().
'">';
453 print
'<input type="hidden" name="action" value="updatelines">';
454 print
'<input type="hidden" name="id" value="'.$object->id.
'">';
456 print
'<div class="div-table-responsive-no-min">';
457 print
'<table class="noborder centpercent">';
460 $products_dispatched = array();
461 $sql =
"SELECT l.rowid, cfd.fk_product, sum(cfd.qty) as qty";
462 $sql .=
" FROM ".MAIN_DB_PREFIX.
"commande_fournisseur_dispatch as cfd";
463 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"commande_fournisseurdet as l on l.rowid = cfd.fk_commandefourndet";
464 $sql .=
" WHERE cfd.fk_reception = ".((int) $object->id);
465 $sql .=
" GROUP BY l.rowid, cfd.fk_product";
467 $resql = $db->query($sql);
469 $num = $db->num_rows($resql);
474 $objd = $db->fetch_object($resql);
475 $products_dispatched[$objd->rowid] =
price2num($objd->qty,
'MS');
484 $sql =
"SELECT l.rowid, l.fk_product, l.subprice, l.remise_percent, l.ref AS sref, l.qty as qty,";
485 $sql .=
" p.ref, p.label, p.tobatch, p.fk_default_warehouse";
487 $parameters = array();
488 $reshook = $hookmanager->executeHooks(
489 'printFieldListSelect',
497 $sql .= $hookmanager->resPrint;
498 $sql .=
" FROM ".MAIN_DB_PREFIX.
"commande_fournisseurdet as l";
499 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"product as p ON l.fk_product=p.rowid";
500 $sql .=
" WHERE l.fk_commande = ".((int) $objectsrc->id);
502 $sql .=
" AND l.product_type = 0";
505 $parameters = array();
506 $reshook = $hookmanager->executeHooks(
507 'printFieldListWhere',
515 $sql .= $hookmanager->resPrint;
518 $sql .=
" ORDER BY l.rang, p.ref, p.label";
520 $resql = $db->query($sql);
522 $num = $db->num_rows($resql);
526 print
'<tr class="liste_titre">';
528 print
'<td>'.$langs->trans(
"Description").
'</td>';
529 if (isModEnabled(
'productbatch')) {
530 print
'<td class="dispatch_batch_number_title">'.$langs->trans(
"batch_number").
'</td>';
532 print
'<td class="dispatch_dlc_title">'.$langs->trans(
"SellByDate").
'</td>';
535 print
'<td class="dispatch_dluo_title">'.$langs->trans(
"EatByDate").
'</td>';
542 print
'<td class="right">'.$langs->trans(
"SupplierRef").
'</td>';
543 print
'<td class="right">'.$langs->trans(
"QtyOrdered").
'</td>';
544 if ($object->status == Reception::STATUS_DRAFT) {
545 print
'<td class="right">'.$langs->trans(
"QtyToReceive");
547 print
'<td class="right">'.$langs->trans(
"QtyDispatchedShort").
'</td>';
549 print
'<td class="right">'.$langs->trans(
"Details");
550 print
'<td width="32"></td>';
553 if (!isModEnabled(
"multicurrency") && empty($conf->dynamicprices->enabled)) {
554 print
'<td class="right">'.$langs->trans(
"Price").
'</td>';
555 print
'<td class="right">'.$langs->trans(
"ReductionShort").
' (%)</td>';
556 print
'<td class="right">'.$langs->trans(
"UpdatePrice").
'</td>';
560 print
'<td align="right">'.$langs->trans(
"Warehouse");
563 if (count($listwarehouses) > 1) {
564 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);
565 } elseif (count($listwarehouses) == 1) {
566 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);
572 $parameters = array();
573 $reshook = $hookmanager->executeHooks(
574 'printFieldListTitle',
582 print $hookmanager->resPrint;
591 $conf->cache[
'product'] = array();
595 $objp = $db->fetch_object($resql);
598 if (!$objp->fk_product > 0) {
601 $alreadydispatched = isset($products_dispatched[$objp->rowid]) ? $products_dispatched[$objp->rowid] : 0;
602 $remaintodispatch =
price2num($objp->qty, 5);
603 if ($remaintodispatch < 0 && !
getDolGlobalString(
'SUPPLIER_ORDER_ALLOW_NEGATIVE_QTY_FOR_SUPPLIER_ORDER_RETURN')) {
604 $remaintodispatch = 0;
607 if ($remaintodispatch || !
getDolGlobalString(
'SUPPLIER_ORDER_DISABLE_STOCK_DISPATCH_WHEN_TOTAL_REACHED')) {
616 print
'<!-- Line to dispatch '.$suffix.
' -->'.
"\n";
618 print
'<input id="qty_ordered'.$suffix.
'" type="hidden" value="'.$objp->qty.
'">';
619 print
'<input id="qty_dispatched'.$suffix.
'" type="hidden" data-dispatched="'.((float) $alreadydispatched).
'" value="'.(float) $alreadydispatched.
'">';
620 print
'<tr class="oddeven">';
622 if (empty($conf->cache[
'product'][$objp->fk_product])) {
623 $tmpproduct =
new Product($db);
624 $tmpproduct->fetch($objp->fk_product);
625 $conf->cache[
'product'][$objp->fk_product] = $tmpproduct;
627 $tmpproduct = $conf->cache[
'product'][$objp->fk_product];
630 $linktoprod = $tmpproduct->getNomUrl(1);
631 $linktoprod .=
' - '.$objp->label.
"\n";
633 if (isModEnabled(
'productbatch')) {
634 if ($objp->tobatch) {
639 print
'<td class="dispatch_batch_number"></td>';
641 print
'<td class="dispatch_dlc"></td>';
644 print
'<td class="dispatch_dluo"></td>';
651 print
'<td class="dispatch_batch_number">';
652 print
'<span class="opacitymedium small">'.$langs->trans(
"ProductDoesNotUseBatchSerial").
'</small>';
655 print
'<td class="dispatch_dlc"></td>';
658 print
'<td class="dispatch_dluo"></td>';
662 print
'<td colspan="4">';
668 $up_ht_disc = $objp->subprice;
669 if (!empty($objp->remise_percent) && !
getDolGlobalString(
'STOCK_EXCLUDE_DISCOUNT_FOR_PMP')) {
670 $up_ht_disc =
price2num($up_ht_disc * (100 - $objp->remise_percent) / 100,
'MU');
674 print
'<td class="right">'.$objp->sref.
'</td>';
677 print
'<td class="right">'.$objp->qty.
'</td>';
680 print
'<td class="right">'.$alreadydispatched.
'</td>';
682 print
'<td class="right">';
688 $sql =
"SELECT cfd.rowid, cfd.qty, cfd.fk_entrepot, cfd.batch, cfd.eatby, cfd.sellby, cfd.fk_product";
689 $sql .=
" FROM ".MAIN_DB_PREFIX.
"commande_fournisseur_dispatch as cfd";
690 $sql .=
" WHERE cfd.fk_reception = ".((int) $object->id);
691 $sql .=
" AND cfd.fk_commande = ".((int) $objectsrc->id);
692 $sql .=
" AND cfd.fk_commandefourndet = ".(int) $objp->rowid;
695 $resultsql = $db->query($sql);
698 $numd = $db->num_rows($resultsql);
701 $suffix =
"_".$j.
"_".$i;
702 $objd = $db->fetch_object($resultsql);
704 if (isModEnabled(
'productbatch') && (!empty($objd->batch) || (is_null($objd->batch) && $tmpproduct->status_batch > 0))) {
710 'is_information_row' =>
true,
715 $reshook = $hookmanager->executeHooks(
716 'printFieldListValue',
724 print $hookmanager->resPrint;
728 print
'<!-- line for batch '.$numline.
' -->';
729 print
'<tr class="oddeven autoresettr" name="'.$type.$suffix.
'" data-remove="clear">';
731 print
'<input id="fk_commandefourndet'.$suffix.
'" name="fk_commandefourndet'.$suffix.
'" type="hidden" value="'.$objp->rowid.
'">';
732 print
'<input id="idline'.$suffix.
'" name="idline'.$suffix.
'" type="hidden" value="'.$objd->rowid.
'">';
733 print
'<input name="product_batch'.$suffix.
'" type="hidden" value="'.$objd->fk_product.
'">';
735 print
'<!-- This is a U.P. (may include discount or not depending on STOCK_EXCLUDE_DISCOUNT_FOR_PMP. will be used for PMP calculation) -->';
737 print $langs->trans(
"BuyingPrice").
': <input class="maxwidth75" name="pu'.$suffix.
'" type="text" value="'.
price2num($up_ht_disc,
'MU').
'">';
739 print
'<input class="maxwidth75" name="pu'.$suffix.
'" type="hidden" value="'.
price2num($up_ht_disc,
'MU').
'">';
745 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).
'">';
748 print
'<td class="nowraponall">';
750 print $form->selectDate($dlcdatesuffix,
'dlc'.$suffix,
'',
'', 1,
'');
754 print
'<td class="nowraponall">';
756 print $form->selectDate($dluodatesuffix,
'dluo'.$suffix,
'',
'', 1,
'');
759 print
'<td colspan="3"> </td>';
769 'is_information_row' =>
true,
774 $reshook = $hookmanager->executeHooks(
775 'printFieldListValue',
783 print $hookmanager->resPrint;
787 print
'<!-- line no batch '.$numline.
' -->';
788 print
'<tr class="oddeven autoresettr" name="'.$type.$suffix.
'" data-remove="clear">';
789 print
'<td colspan="'.$colspan.
'">';
790 print
'<input id="fk_commandefourndet'.$suffix.
'" name="fk_commandefourndet'.$suffix.
'" type="hidden" value="'.$objp->rowid.
'">';
791 print
'<input id="idline'.$suffix.
'" name="idline'.$suffix.
'" type="hidden" value="'.$objd->rowid.
'">';
792 print
'<input name="product'.$suffix.
'" type="hidden" value="'.$objd->fk_product.
'">';
794 print
'<!-- This is a up (may include discount or not depending on STOCK_EXCLUDE_DISCOUNT_FOR_PMP. will be used for PMP calculation) -->';
796 print $langs->trans(
"BuyingPrice").
': <input class="maxwidth75" name="pu'.$suffix.
'" type="text" value="'.
price2num($up_ht_disc,
'MU').
'">';
798 print
'<input class="maxwidth75" name="pu'.$suffix.
'" type="hidden" value="'.
price2num($up_ht_disc,
'MU').
'">';
804 print
'<td class="right">';
805 print
'<a href="#" id="reset'.$suffix.
'" class="resetline">'.
img_picto($langs->trans(
"Reset"),
'eraser',
'class="pictofixedwidth opacitymedium"').
'</a>';
806 print
'<input id="qty'.$suffix.
'" onchange="onChangeDispatchLineQty($(this))" name="qty'.$suffix.
'" data-type="'.$type.
'" data-index="'.$i.
'" class="width50 right qtydispatchinput" value="'.(GETPOSTISSET(
'qty'.$suffix) ?
GETPOST(
'qty'.$suffix,
'int') : $objd->qty).
'" data-expected="'.$objd->qty.
'">';
809 if (isModEnabled(
'productbatch') && $objp->tobatch > 0) {
811 print
img_picto($langs->trans(
'AddStockLocationLine'),
'split.png',
'class="splitbutton" '.($numd != $j+1 ?
'style="display:none"' :
'').
' onClick="addDispatchLine('.$i.
', \''.$type.
'\')"');
814 print
img_picto($langs->trans(
'AddStockLocationLine'),
'split.png',
'class="splitbutton" '.($numd != $j+1 ?
'style="display:none"' :
'').
' onClick="addDispatchLine('.$i.
', \''.$type.
'\')"');
820 if (!isModEnabled(
"multicurrency") && empty($conf->dynamicprices->enabled)) {
822 print
'<td class="right">';
823 print
'<input id="pu'.$suffix.
'" name="pu'.$suffix.
'" type="text" size="8" value="'.
price((
GETPOST(
'pu'.$suffix) !=
'' ?
price2num(
GETPOST(
'pu'.$suffix)) : $up_ht_disc)).
'">';
827 print
'<td class="right">';
828 print
'<input id="dto'.$suffix.
'" name="dto'.$suffix.
'" type="text" size="8" value="'.(
GETPOST(
'dto'.$suffix) !=
'' ?
GETPOST(
'dto'.$suffix) :
'').
'">';
832 print
'<td class="center">';
833 print
'<input class="flat checkformerge" type="checkbox" name="saveprice'.$suffix.
'" value="'.(
GETPOST(
'saveprice'.$suffix) !=
'' ?
GETPOST(
'saveprice'.$suffix) :
'').
'">';
839 print
'<td class="right">';
840 if (count($listwarehouses) > 1) {
841 print $formproduct->selectWarehouses(
GETPOST(
"entrepot".$suffix) ?
GETPOST(
"entrepot".$suffix) : $objd->fk_entrepot,
"entrepot".$suffix,
'', 1, 0, $objp->fk_product,
'', 1, 0, null,
'csswarehouse'.$suffix);
842 } elseif (count($listwarehouses) == 1) {
843 print $formproduct->selectWarehouses(
GETPOST(
"entrepot".$suffix) ?
GETPOST(
"entrepot".$suffix) : $objd->fk_entrepot,
"entrepot".$suffix,
'', 0, 0, $objp->fk_product,
'', 1, 0, null,
'csswarehouse'.$suffix);
845 $langs->load(
"errors");
846 print $langs->trans(
"ErrorNoWarehouseDefined");
852 'is_information_row' =>
false,
857 $reshook = $hookmanager->executeHooks(
858 'printFieldListValue',
866 print $hookmanager->resPrint;
873 $suffix =
"_".$j.
"_".$i;
877 if (isModEnabled(
'productbatch') && !empty($objp->tobatch)) {
883 'is_information_row' =>
true,
888 $reshook = $hookmanager->executeHooks(
889 'printFieldListValue',
897 print $hookmanager->resPrint;
901 print
'<!-- line for batch '.$numline.
' (not dispatched line yet for this order line) -->';
902 print
'<tr class="oddeven autoresettr" name="'.$type.$suffix.
'">';
904 print
'<input id="fk_commandefourndet'.$suffix.
'" name="fk_commandefourndet'.$suffix.
'" type="hidden" value="'.$objp->rowid.
'">';
905 print
'<input id="idline'.$suffix.
'" name="idline'.$suffix.
'" type="hidden" value="-1">';
906 print
'<input name="product_batch'.$suffix.
'" type="hidden" value="'.$objp->fk_product.
'">';
908 print
'<!-- This is a up (may include discount or not depending on STOCK_EXCLUDE_DISCOUNT_FOR_PMP. will be used for PMP calculation) -->';
910 print $langs->trans(
"BuyingPrice").
': <input class="maxwidth75" name="pu'.$suffix.
'" type="text" value="'.
price2num($up_ht_disc,
'MU').
'">';
912 print
'<input class="maxwidth75" name="pu'.$suffix.
'" type="hidden" value="'.
price2num($up_ht_disc,
'MU').
'">';
918 print
'<input type="text" class="inputlotnumber quatrevingtquinzepercent" id="lot_number'.$suffix.
'" name="lot_number'.$suffix.
'" value="'.
GETPOST(
'lot_number'.$suffix).
'">';
921 print
'<td class="nowraponall">';
923 print $form->selectDate($dlcdatesuffix,
'dlc'.$suffix,
'',
'', 1,
'');
927 print
'<td class="nowraponall">';
929 print $form->selectDate($dluodatesuffix,
'dluo'.$suffix,
'',
'', 1,
'');
932 print
'<td colspan="3"> </td>';
942 'is_information_row' =>
true,
947 $reshook = $hookmanager->executeHooks(
948 'printFieldListValue',
956 print $hookmanager->resPrint;
960 print
'<!-- line no batch '.$numline.
' (not dispatched line yet for this order line) -->';
961 print
'<tr class="oddeven autoresettr" name="'.$type.$suffix.
'" data-remove="clear">';
962 print
'<td colspan="'.$colspan.
'">';
963 print
'<input id="fk_commandefourndet'.$suffix.
'" name="fk_commandefourndet'.$suffix.
'" type="hidden" value="'.$objp->rowid.
'">';
964 print
'<input id="idline'.$suffix.
'" name="idline'.$suffix.
'" type="hidden" value="-1">';
965 print
'<input name="product'.$suffix.
'" type="hidden" value="'.$objp->fk_product.
'">';
967 print
'<!-- This is a up (may include discount or not depending on STOCK_EXCLUDE_DISCOUNT_FOR_PMP. will be used for PMP calculation) -->';
969 print $langs->trans(
"BuyingPrice").
': <input class="maxwidth75" name="pu'.$suffix.
'" data-type="text" value="'.
price2num($up_ht_disc,
'MU').
'">';
971 print
'<input class="maxwidth75" name="pu'.$suffix.
'" type="hidden" value="'.
price2num($up_ht_disc,
'MU').
'">';
977 print
'<td class="right">';
978 print
'<a href="#" id="reset'.$suffix.
'" class="resetline">'.
img_picto($langs->trans(
"Reset"),
'eraser',
'class="pictofixedwidth opacitymedium"').
'</a>';
979 print
'<input id="qty'.$suffix.
'" onchange="onChangeDispatchLineQty($(this))" name="qty'.$suffix.
'" data-index="'.$i.
'" data-type="text" class="width50 right qtydispatchinput" value="'.(GETPOSTISSET(
'qty'.$suffix) ?
GETPOST(
'qty'.$suffix,
'int') : (!
getDolGlobalString(
'SUPPLIER_ORDER_DISPATCH_FORCE_QTY_INPUT_TO_ZERO') ? $remaintodispatch : 0)).
'" data-expected="'.$remaintodispatch.
'">';
982 if (isModEnabled(
'productbatch') && $objp->tobatch > 0) {
984 print
img_picto($langs->trans(
'AddStockLocationLine'),
'split.png',
'class="splitbutton" onClick="addDispatchLine('.$i.
', \''.$type.
'\')
"');
987 print img_picto($langs->trans('AddStockLocationLine'), 'split.png', 'class="splitbutton
" onClick="addDispatchLine(
'.$i.', \
''.$type.
'\')
"');
992 if (getDolGlobalString('SUPPLIER_ORDER_CAN_UPDATE_BUYINGPRICE_DURING_RECEIPT')) {
993 if (!isModEnabled("multicurrency
") && empty($conf->dynamicprices->enabled)) {
995 print '<td class="right
">';
996 print '<input id="pu
'.$suffix.'" name="pu
'.$suffix.'" type="text
" size="8
" value="'.price((GETPOST('pu
'.$suffix) != '' ? price2num(GETPOST('pu
'.$suffix)) : $up_ht_disc)).'">';
1000 print '<td class="right
">';
1001 print '<input id="dto
'.$suffix.'" name="dto
'.$suffix.'" type="text
" size="8
" value="'.(GETPOST('dto
'.$suffix) != '' ? GETPOST('dto
'.$suffix) : '').'">';
1005 print '<td class="center
">';
1006 print '<input class="flat checkformerge
" type="checkbox
" name="saveprice
'.$suffix.'" value="'.(GETPOST('saveprice
'.$suffix) != '' ? GETPOST('saveprice
'.$suffix) : '').'">';
1012 print '<td class="right
">';
1013 if (count($listwarehouses) > 1) {
1014 print $formproduct->selectWarehouses(GETPOST("entrepot
".$suffix) ? GETPOST("entrepot
".$suffix) : ($objp->fk_default_warehouse ? $objp->fk_default_warehouse : ''), "entrepot
".$suffix, '', 1, 0, $objp->fk_product, '', 1, 0, null, 'csswarehouse'.$suffix);
1015 } elseif (count($listwarehouses) == 1) {
1016 print $formproduct->selectWarehouses(GETPOST("entrepot
".$suffix) ? GETPOST("entrepot
".$suffix) : ($objp->fk_default_warehouse ? $objp->fk_default_warehouse : ''), "entrepot
".$suffix, '', 0, 0, $objp->fk_product, '', 1, 0, null, 'csswarehouse'.$suffix);
1018 $langs->load("errors
");
1019 print $langs->trans("ErrorNoWarehouseDefined
");
1023 // Enable hooks to append additional columns
1024 $parameters = array(
1025 'is_information_row' => false, // this is a dispatch form row
1027 'suffix' => $suffix,
1030 $reshook = $hookmanager->executeHooks(
1031 'printFieldListValue',
1037 setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
1039 print $hookmanager->resPrint;
1048 dol_print_error($db);
1055 print '<div class="center
">';
1056 $parameters = array();
1057 $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been
1059 if (empty($reshook)) {
1060 /*$checkboxlabel = $langs->trans("CloseReceivedSupplierOrdersAutomatically
", $langs->transnoentitiesnoconv('StatusOrderReceivedAll'));
1062 if (empty($conf->reception->enabled)) {
1063 print $langs->trans("Comment").' : ';
1064 print '<input type="text
" class="minwidth400
" maxlength="128
" name="comment
" value="';
1065 print GETPOSTISSET("comment") ? GETPOST("comment") : $langs->trans("DispatchSupplierOrder", $object->ref);
1066 // print ' /
'.$object->ref_supplier; // Not yet available
1067 print '" class="flat
"><br>';
1069 print '<input type="checkbox
" checked="checked
" name="closeopenorder
"> '.$checkboxlabel;
1072 $dispatchBt = empty($conf->reception->enabled) ? $langs->trans("Receive
") : $langs->trans("CreateReception
");
1077 print '<input type="submit
" id="submitform
" class="button" name="dispatch
" value="'.$langs->trans("Save").'"';
1079 if (!$permissiontoreceive) {
1082 if (count($listwarehouses) <= 0) {
1094 // Message if nothing to dispatch
1097 if (!getDolGlobalString('SUPPLIER_ORDER_DISABLE_STOCK_DISPATCH_WHEN_TOTAL_REACHED')) {
1098 print '<div class="opacitymedium
">'.$langs->trans("NoPredefinedProductToDispatch
").'</div>'; // No predefined line at all
1100 print '<div class="opacitymedium
">'.$langs->trans("NoMorePredefinedProductToDispatch
").'</div>'; // No predefined line that remain to be dispatched.
1107 print dol_get_fiche_end();
1109 // traitement entrepot par défaut
1110 print '<script type="text/javascript
">
1111 $(document).ready(function () {
1112 $("select[
name=fk_default_warehouse]
").change(function() {
1113 var fk_default_warehouse = $("option:selected
", this).val();
1114 $("select[
name^=entrepot_]
").val(fk_default_warehouse).change();
1117 $("#autoreset
").click(function() {
1118 $(".autoresettr
").each(function(){
1119 id = $(this).attr("name");
1120 idtab = id.split("_
");
1121 if ($(this).data("remove") == "clear
"){
1122 console.log("We clear the
object to expected value
")
1123 $("#qty_
"+idtab[1]+"_
"+idtab[2]).val("");
1125 qtyexpected = $("#qty_
"+idtab[1]+"_
"+idtab[2]).data("expected
")
1126 console.log(qtyexpected);
1127 $("#qty_
"+idtab[1]+"_
"+idtab[2]).val(qtyexpected);
1128 qtydispatched = $("#qty_dispatched_0_
"+idtab[2]).data("dispatched
")
1129 $("#qty_dispatched_0_
"+idtab[2]).val(qtydispatched);
1132 console.log("We
remove the
object")
1134 $("tr[
name^=\
'"+idtab[0]+"_\'][name$=\'_"+idtab[2]+"\']:last .splitbutton").show();
1140 $("#resetalltoexpected").click(function(){
1141 $(".qtydispatchinput").each(function(){
1142 console.log("We reset to expected "+$(this).attr("id")+" qty to dispatch");
1143 $(this).val($(this).data("expected"));
1148 $(".resetline").click(function(e){
1150 id = $(this).attr("id");
1151 id = id.split("reset_");
1152 console.log("Reset trigger for id = qty_"+id[1]);
1153 $("#qty_"+id[1]).val("");
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader()
Empty header.
Class to manage table commandefournisseurdispatch.
Class to manage predefined suppliers products.
Class to manage warehouses.
Class to manage products or services.
Class to manage projects.
Class to manage receptions.
Class to manage third parties objects (customers, suppliers, prospects...)
Class to manage Dolibarr users.
dol_stringtotime($string, $gm=1)
Convert a string date into a GM Timestamps date Warning: YYYY-MM-DDTHH:MM:SS+02:00 (RFC3339) is not s...
dol_banner_tab($object, $paramid, $morehtml='', $shownav=1, $fieldid='rowid', $fieldref='ref', $morehtmlref='', $moreparam='', $nodbprefix=0, $morehtmlleft='', $morehtmlstatus='', $onlybanner=0, $morehtmlright='')
Show tab footer of a card.
dol_mktime($hour, $minute, $second, $month, $day, $year, $gm='auto', $check=1)
Return a timestamp date built from detailed informations (by default a local PHP server timestamp) Re...
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0)
Show tabs of a record.
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
price($amount, $form=0, $outlangs='', $trunc=1, $rounding=-1, $forcerounding=-1, $currency_code='')
Function to format a value into an amount for visual output Function used into PDF and HTML pages.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs='', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
dol_now($mode='auto')
Return date for now.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0)
Set event messages in dol_events session object.
getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
img_edit($titlealt='default', $float=0, $other='')
Show logo editer/modifier fiche.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
ui dialog ui datepicker calendar ui widget content ui state ui datepicker calendar ui widget header ui state ui datepicker calendar ui button
0 = Do not include form tag and submit button -1 = Do not include form tag but include submit button
reception_prepare_head(Reception $object)
Prepare array with list of tabs.
$conf db name
Only used if Module[ID]Name translation string is not found.
restrictedArea(User $user, $features, $object=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $isdraft=0, $mode=0)
Check permissions of a user to show a page and an object.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.