34 require
'../main.inc.php';
35 require_once DOL_DOCUMENT_ROOT.
'/core/modules/supplier_order/modules_commandefournisseur.php';
36 require_once DOL_DOCUMENT_ROOT.
'/product/stock/class/entrepot.class.php';
37 require_once DOL_DOCUMENT_ROOT.
'/core/lib/fourn.lib.php';
38 require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.commande.class.php';
39 require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.commande.dispatch.class.php';
40 require_once DOL_DOCUMENT_ROOT.
'/product/class/html.formproduct.class.php';
41 require_once DOL_DOCUMENT_ROOT.
'/product/stock/class/mouvementstock.class.php';
42 require_once DOL_DOCUMENT_ROOT.
'/core/lib/reception.lib.php';
46 require_once DOL_DOCUMENT_ROOT.
'/projet/class/project.class.php';
50 $langs->loadLangs(array(
"bills",
"orders",
"sendings",
"companies",
"deliveries",
"products",
"stocks",
"receptions"));
53 $langs->load(
'productbatch');
59 $lineid =
GETPOST(
'lineid',
'int');
60 $action =
GETPOST(
'action',
'aZ09');
61 $fk_default_warehouse =
GETPOST(
'fk_default_warehouse',
'int');
62 $cancel =
GETPOST(
'cancel',
'alpha');
63 $confirm =
GETPOST(
'confirm',
'alpha');
66 $socid = $user->socid;
69 $hookmanager->initHooks(array(
'ordersupplierdispatch'));
74 $projectid =
GETPOST(
"projectid",
'int');
79 if ($id > 0 || !empty($ref)) {
80 $result = $object->fetch($id, $ref);
84 $result = $object->fetch_thirdparty();
88 if (!empty($object->origin)) {
89 $origin = $object->origin;
91 $object->fetch_origin();
92 $typeobject = $object->origin;
94 if ($origin ==
'order_supplier' && $object->$typeobject->id && (
isModEnabled(
"fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) ||
isModEnabled(
"supplier_order"))) {
95 $origin_id = $object->$typeobject->id;
97 $objectsrc->fetch($object->$typeobject->id);
101 if (empty($conf->reception->enabled)) {
102 $permissiontoreceive = $user->rights->fournisseur->commande->receptionner;
103 $permissiontocontrol = ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->fournisseur->commande->receptionner)) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->fournisseur->commande_advance->check)));
105 $permissiontoreceive = $user->rights->reception->creer;
106 $permissiontocontrol = ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->reception->creer)) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->reception->reception_advance->validate)));
110 $result =
restrictedArea($user,
'fournisseur', $object,
'reception');
116 $usercancreate = $user->hasRight(
'reception',
'creer');
117 $permissiontoadd = $usercancreate;
124 $parameters = array();
125 $reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
131 if ($action ==
'updatelines' && $permissiontoreceive) {
138 foreach ($_POST as $key => $value) {
141 if (preg_match(
'/^product_.*([0-9]+)_([0-9]+)$/i', $key, $reg)) {
143 if (preg_match(
'/^product_([0-9]+)_([0-9]+)$/i', $key, $reg)) {
144 $modebatch =
"barcode";
145 } elseif (preg_match(
'/^product_batch_([0-9]+)_([0-9]+)$/i', $key, $reg)) {
146 $modebatch =
"batch";
150 if ($modebatch ==
"barcode") {
151 $prod =
"product_".$reg[1].
'_'.$reg[2];
153 $prod =
'product_batch_'.$reg[1].
'_'.$reg[2];
155 $qty =
"qty_".$reg[1].
'_'.$reg[2];
156 $ent =
"entrepot_".$reg[1].
'_'.$reg[2];
157 $pu =
"pu_".$reg[1].
'_'.$reg[2];
158 $fk_commandefourndet =
"fk_commandefourndet_".$reg[1].
'_'.$reg[2];
159 $idline =
GETPOST(
"idline_".$reg[1].
'_'.$reg[2]);
163 if ($modebatch ==
"batch") {
164 $lot =
GETPOST(
'lot_number_'.$reg[1].
'_'.$reg[2]);
165 $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'));
166 $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 (!empty($conf->global->SUPPLIER_ORDER_CAN_UPDATE_BUYINGPRICE_DURING_RECEIPT)) {
170 if (!
isModEnabled(
"multicurrency") && empty($conf->dynamicprices->enabled)) {
171 $dto =
GETPOST(
"dto_".$reg[1].
'_'.$reg[2],
'int');
175 $saveprice =
"saveprice_".$reg[1].
'_'.$reg[2];
180 if (($modebatch ==
"batch" &&
GETPOST($qty) > 0) || ($modebatch ==
"barcode" &&
GETPOST($qty) != 0)) {
181 if (!(
GETPOST($ent,
'int') > 0)) {
182 dol_syslog(
'No dispatch for line '.$key.
' as no warehouse was chosen.');
183 $text = $langs->transnoentities(
'Warehouse').
', '.$langs->transnoentities(
'Line').
' '.($numline);
184 setEventMessages($langs->trans(
'ErrorFieldRequired', $text),
null,
'errors');
190 $result = $supplierorderdispatch->fetch($idline);
192 setEventMessages($supplierorderdispatch->error, $supplierorderdispatch->errors,
'errors');
195 $qtystart = $supplierorderdispatch->qty;
196 $supplierorderdispatch->qty =
GETPOST($qty);
197 $supplierorderdispatch->fk_entrepot =
GETPOST($ent,
'int');
198 if ($modebatch ==
"batch") {
199 $supplierorderdispatch->eatby = $dDLUO;
200 $supplierorderdispatch->sellby = $dDLC;
203 $result = $supplierorderdispatch->update($user);
205 setEventMessages($supplierorderdispatch->error, $supplierorderdispatch->errors,
'errors');
210 if (!$error &&
GETPOST($ent,
'int') > 0 &&
isModEnabled(
'stock') && !empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER)) {
212 $product =
GETPOST($prod,
'int');
213 $entrepot =
GETPOST($ent,
'int');
214 $qtymouv =
GETPOST($qty) - $qtystart;
222 if ($modebatch ==
"batch") {
225 $batch = $supplierorderdispatch->batch;
229 $mouv->origin = $objectsrc;
230 $mouv->setOrigin($objectsrc->element, $objectsrc->id);
233 if (!empty($conf->global->SUPPLIER_ORDER_ALLOW_NEGATIVE_QTY_FOR_SUPPLIER_ORDER_RETURN) && $qtymouv < 0) {
234 $result = $mouv->livraison($user, $product, $entrepot, $qtymouv*(-1), $price, $comment, $now, $eatby, $sellby, $batch, 0, $inventorycode);
236 $result = $mouv->reception($user, $product, $entrepot, $qtymouv, $price, $comment, $eatby, $sellby, $batch,
'', 0, $inventorycode);
247 $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);
254 if (!$error && !empty($conf->global->SUPPLIER_ORDER_CAN_UPDATE_BUYINGPRICE_DURING_RECEIPT)) {
255 if (!
isModEnabled(
"multicurrency") && empty($conf->dynamicprices->enabled)) {
264 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"product_fournisseur_price";
265 $sql .=
" SET unitprice='".price2num(
GETPOST($pu),
'MU').
"'";
266 $sql .=
", price=".price2num(
GETPOST($pu),
'MU').
"*quantity";
267 $sql .=
", remise_percent = ".((float) $dto);
268 $sql .=
" WHERE fk_soc=".((int) $object->socid);
269 $sql .=
" AND fk_product=".((int)
GETPOST($prod,
'int'));
271 $resql = $db->query(
$sql);
297 $warehouse_static =
new Entrepot($db);
300 $title = $object->ref.
" - ".$langs->trans(
'ReceptionDistribution');
301 $help_url =
'EN:Module_Suppliers_Orders|FR:CommandeFournisseur|ES:Módulo_Pedidos_a_proveedores';
302 $morejs = array(
'/fourn/js/lib_dispatch.js.php');
306 if ($id > 0 || !empty($ref)) {
307 if (!empty($object->origin) && $object->origin_id > 0) {
308 $object->origin =
'CommandeFournisseur';
309 $typeobject = $object->origin;
310 $origin = $object->origin;
311 $origin_id = $object->origin_id;
312 $object->fetch_origin();
315 $soc->fetch($object->socid);
317 $author =
new User($db);
318 $author->fetch($object->user_author_id);
322 $title = $langs->trans(
"SupplierOrder");
323 print
dol_get_fiche_head($head,
'dispatch', $langs->trans(
"Reception"), -1,
'dollyrevert');
329 if ($action ==
'ask_deleteline') {
330 $formconfirm =
$form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'&lineid='.$lineid, $langs->trans(
'DeleteLine'), $langs->trans(
'ConfirmDeleteLine'),
'confirm_deleteline',
'', 0, 1);
334 $parameters = array(
'lineid' => $lineid);
336 $reshook = $hookmanager->executeHooks(
'formConfirm', $parameters, $object, $action);
337 if (empty($reshook)) {
339 } elseif ($reshook > 0) {
347 $linkback =
'<a href="'.DOL_URL_ROOT.
'/reception/list.php?restore_lastsearch_values=1'.(!empty($socid) ?
'&socid='.$socid :
'').
'">'.$langs->trans(
"BackToList").
'</a>';
348 $morehtmlref =
'<div class="refidno">';
351 $morehtmlref .=
$form->editfieldkey(
"RefSupplier",
'ref_supplier', $object->ref_supplier, $object, $user->rights->reception->creer,
'string',
'', 0, 1);
352 $morehtmlref .=
$form->editfieldval(
"RefSupplier",
'ref_supplier', $object->ref_supplier, $object, $user->rights->reception->creer,
'string',
'',
null,
null,
'', 1);
355 $morehtmlref .=
'<br>'.$object->thirdparty->getNomUrl(1);
358 $langs->load(
"projects");
359 $morehtmlref .=
'<br>';
361 $morehtmlref .=
img_picto($langs->trans(
"Project"),
'project',
'class="pictofixedwidth"');
362 if ($action !=
'classify' && $permissiontoadd) {
363 $morehtmlref .=
'<a class="editfielda" href="'.$_SERVER[
'PHP_SELF'].
'?action=classify&token='.
newToken().
'&id='.$object->id.
'">'.
img_edit($langs->transnoentitiesnoconv(
'SetProject')).
'</a> ';
365 $morehtmlref .=
$form->form_project($_SERVER[
'PHP_SELF'].
'?id='.$object->id, (empty($conf->global->PROJECT_CAN_ALWAYS_LINK_TO_ALL_SUPPLIERS) ? $object->socid : -1), $object->fk_project, ($action ==
'classify' ?
'projectid' :
'none'), 0, 0, 0, 1,
'',
'maxwidth300');
367 if (!empty($objectsrc) && !empty($objectsrc->fk_project)) {
369 $proj->fetch($objectsrc->fk_project);
370 $morehtmlref .= $proj->getNomUrl(1);
372 $morehtmlref .=
'<span class="opacitymedium"> - '.dol_escape_htmltag($proj->title).
'</span>';
377 $morehtmlref .=
'</div>';
379 dol_banner_tab($object,
'ref', $linkback, 1,
'ref',
'ref', $morehtmlref);
382 print
'<div class="fichecenter">';
383 print
'<div class="underbanner clearboth"></div>';
385 print
'<table class="border tableforfield" width="100%">';
388 if ($typeobject ==
'commande' && $object->$typeobject->id &&
isModEnabled(
'commande')) {
390 print $langs->trans(
"RefOrder").
'</td>';
391 print
'<td colspan="3">';
392 print $objectsrc->getNomUrl(1,
'commande');
396 if ($typeobject ==
'propal' && $object->$typeobject->id &&
isModEnabled(
"propal")) {
398 print $langs->trans(
"RefProposal").
'</td>';
399 print
'<td colspan="3">';
400 print $objectsrc->getNomUrl(1,
'reception');
404 if ($typeobject ==
'CommandeFournisseur' && $object->$typeobject->id &&
isModEnabled(
"propal")) {
406 print $langs->trans(
"SupplierOrder").
'</td>';
407 print
'<td colspan="3">';
408 print $objectsrc->getNomUrl(1,
'reception');
414 print
'<tr><td class="titlefield">'.$langs->trans(
"DateCreation").
'</td>';
415 print
'<td colspan="3">'.dol_print_date($object->date_creation,
"dayhour",
"tzuserrel").
"</td>\n";
419 print
'<tr><td height="10">';
420 print
'<table class="nobordernopadding" width="100%"><tr><td>';
421 print $langs->trans(
'DateDeliveryPlanned');
423 print
'</tr></table>';
424 print
'</td><td colspan="2">';
425 print $object->date_delivery ?
dol_print_date($object->date_delivery,
'dayhour') :
' ';
430 print
'<br><center>';
431 print
'<a href="#" id="resetalltoexpected" class="marginrightonly paddingright marginleftonly paddingleft">'.img_picto(
"",
'autofill',
'class="pictofixedwidth"').$langs->trans(
"RestoreWithCurrentQtySaved").
'</a></td>';
433 print
'<a href="#" id="autoreset" class="marginrightonly paddingright marginleftonly paddingleft">'.img_picto(
"",
'eraser',
'class="pictofixedwidth"').$langs->trans(
"ClearQtys").
'</a></td>';
439 if ($object->statut == Reception::STATUS_DRAFT) {
440 require_once DOL_DOCUMENT_ROOT.
'/product/class/html.formproduct.class.php';
442 $formproduct->loadWarehouses();
444 $listwarehouses = $entrepot->list_array(1);
447 print
'<form method="post" action="'.$_SERVER[
"PHP_SELF"].
'">';
449 print
'<input type="hidden" name="token" value="'.newToken().
'">';
450 print
'<input type="hidden" name="action" value="updatelines">';
451 print
'<input type="hidden" name="id" value="'.$object->id.
'">';
453 print
'<div class="div-table-responsive-no-min">';
454 print
'<table class="noborder centpercent">';
457 $products_dispatched = array();
458 $sql =
"SELECT l.rowid, cfd.fk_product, sum(cfd.qty) as qty";
459 $sql .=
" FROM ".MAIN_DB_PREFIX.
"commande_fournisseur_dispatch as cfd";
460 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"commande_fournisseurdet as l on l.rowid = cfd.fk_commandefourndet";
461 $sql .=
" WHERE cfd.fk_reception = ".((int) $object->id);
462 $sql .=
" GROUP BY l.rowid, cfd.fk_product";
464 $resql = $db->query(
$sql);
466 $num = $db->num_rows($resql);
471 $objd = $db->fetch_object($resql);
472 $products_dispatched[$objd->rowid] =
price2num($objd->qty,
'MS');
481 $sql =
"SELECT l.rowid, l.fk_product, l.subprice, l.remise_percent, l.ref AS sref, l.qty as qty,";
482 $sql .=
" p.ref, p.label, p.tobatch, p.fk_default_warehouse";
484 $parameters = array();
485 $reshook = $hookmanager->executeHooks(
486 'printFieldListSelect',
494 $sql .= $hookmanager->resPrint;
495 $sql .=
" FROM ".MAIN_DB_PREFIX.
"commande_fournisseurdet as l";
496 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"product as p ON l.fk_product=p.rowid";
497 $sql .=
" WHERE l.fk_commande = ".((int) $objectsrc->id);
498 if (empty($conf->global->STOCK_SUPPORTS_SERVICES)) {
499 $sql .=
" AND l.product_type = 0";
502 $parameters = array();
503 $reshook = $hookmanager->executeHooks(
504 'printFieldListWhere',
512 $sql .= $hookmanager->resPrint;
515 $sql .=
" ORDER BY l.rang, p.ref, p.label";
517 $resql = $db->query(
$sql);
519 $num = $db->num_rows($resql);
523 print
'<tr class="liste_titre">';
525 print
'<td>'.$langs->trans(
"Description").
'</td>';
527 print
'<td class="dispatch_batch_number_title">'.$langs->trans(
"batch_number").
'</td>';
528 if (empty($conf->global->PRODUCT_DISABLE_SELLBY)) {
529 print
'<td class="dispatch_dlc_title">'.$langs->trans(
"SellByDate").
'</td>';
531 if (empty($conf->global->PRODUCT_DISABLE_EATBY)) {
532 print
'<td class="dispatch_dluo_title">'.$langs->trans(
"EatByDate").
'</td>';
539 print
'<td class="right">'.$langs->trans(
"SupplierRef").
'</td>';
540 print
'<td class="right">'.$langs->trans(
"QtyOrdered").
'</td>';
541 print
'<td class="right">'.$langs->trans(
"QtyDispatchedShort").
'</td>';
542 print
' <td class="right">'.$langs->trans(
"QtyToDispatchShort");
544 print
'<td width="32"></td>';
546 if (!empty($conf->global->SUPPLIER_ORDER_CAN_UPDATE_BUYINGPRICE_DURING_RECEIPT)) {
547 if (!
isModEnabled(
"multicurrency") && empty($conf->dynamicprices->enabled)) {
548 print
'<td class="right">'.$langs->trans(
"Price").
'</td>';
549 print
'<td class="right">'.$langs->trans(
"ReductionShort").
' (%)</td>';
550 print
'<td class="right">'.$langs->trans(
"UpdatePrice").
'</td>';
554 print
'<td align="right">'.$langs->trans(
"Warehouse");
557 if (count($listwarehouses) > 1) {
558 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);
559 } elseif (count($listwarehouses) == 1) {
560 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);
566 $parameters = array();
567 $reshook = $hookmanager->executeHooks(
568 'printFieldListTitle',
576 print $hookmanager->resPrint;
585 $conf->cache[
'product'] = array();
589 $objp = $db->fetch_object($resql);
592 if (!$objp->fk_product > 0) {
595 $alreadydispatched = isset($products_dispatched[$objp->rowid])?$products_dispatched[$objp->rowid]:0;
596 $remaintodispatch =
price2num($objp->qty, 5);
597 if ($remaintodispatch < 0 && empty($conf->global->SUPPLIER_ORDER_ALLOW_NEGATIVE_QTY_FOR_SUPPLIER_ORDER_RETURN)) {
598 $remaintodispatch = 0;
601 if ($remaintodispatch || empty($conf->global->SUPPLIER_ORDER_DISABLE_STOCK_DISPATCH_WHEN_TOTAL_REACHED)) {
610 print
'<!-- Line to dispatch '.$suffix.
' -->'.
"\n";
612 print
'<input id="qty_ordered'.$suffix.
'" type="hidden" value="'.$objp->qty.
'">';
613 print
'<input id="qty_dispatched'.$suffix.
'" type="hidden" data-dispatched="'.((
float) $alreadydispatched).
'" value="'.(
float) $alreadydispatched.
'">';
614 print
'<tr class="oddeven">';
616 if (empty($conf->cache[
'product'][$objp->fk_product])) {
617 $tmpproduct =
new Product($db);
618 $tmpproduct->fetch($objp->fk_product);
619 $conf->cache[
'product'][$objp->fk_product] = $tmpproduct;
621 $tmpproduct = $conf->cache[
'product'][$objp->fk_product];
624 $linktoprod = $tmpproduct->getNomUrl(1);
625 $linktoprod .=
' - '.$objp->label.
"\n";
628 if ($objp->tobatch) {
633 print
'<td class="dispatch_batch_number"></td>';
634 if (empty($conf->global->PRODUCT_DISABLE_SELLBY)) {
635 print
'<td class="dispatch_dlc"></td>';
637 if (empty($conf->global->PRODUCT_DISABLE_EATBY)) {
638 print
'<td class="dispatch_dluo"></td>';
645 print
'<td class="dispatch_batch_number">';
646 print
'<span class="opacitymedium small">'.$langs->trans(
"ProductDoesNotUseBatchSerial").
'</small>';
648 if (empty($conf->global->PRODUCT_DISABLE_SELLBY)) {
649 print
'<td class="dispatch_dlc"></td>';
651 if (empty($conf->global->PRODUCT_DISABLE_EATBY)) {
652 print
'<td class="dispatch_dluo"></td>';
656 print
'<td colspan="4">';
662 $up_ht_disc = $objp->subprice;
663 if (!empty($objp->remise_percent) && empty($conf->global->STOCK_EXCLUDE_DISCOUNT_FOR_PMP)) {
664 $up_ht_disc =
price2num($up_ht_disc * (100 - $objp->remise_percent) / 100,
'MU');
668 print
'<td class="right">'.$objp->sref.
'</td>';
671 print
'<td class="right">'.$objp->qty.
'</td>';
674 print
'<td class="right">'.$alreadydispatched.
'</td>';
676 print
'<td class="right">';
682 $sql =
"SELECT cfd.rowid, cfd.qty, cfd.fk_entrepot, cfd.batch, cfd.eatby, cfd.sellby, cfd.fk_product";
683 $sql .=
" FROM ".MAIN_DB_PREFIX.
"commande_fournisseur_dispatch as cfd";
684 $sql .=
" WHERE cfd.fk_reception = ".((int) $object->id);
685 $sql .=
" AND cfd.fk_commande = ".((int) $objectsrc->id);
686 $sql .=
" AND cfd.fk_commandefourndet = ".(int) $objp->rowid;
689 $resultsql = $db->query(
$sql);
692 $numd = $db->num_rows($resultsql);
695 $suffix =
"_".$j.
"_".$i;
696 $objd = $db->fetch_object($resultsql);
698 if (
isModEnabled(
'productbatch') && !empty($objd->batch)) {
704 'is_information_row' =>
true,
709 $reshook = $hookmanager->executeHooks(
710 'printFieldListValue',
718 print $hookmanager->resPrint;
722 print
'<!-- line for batch '.$numline.
' -->';
723 print
'<tr class="oddeven autoresettr" name="'.$type.$suffix.
'" data-remove="clear">';
725 print
'<input id="fk_commandefourndet'.$suffix.
'" name="fk_commandefourndet'.$suffix.
'" type="hidden" value="'.$objp->rowid.
'">';
726 print
'<input id="idline'.$suffix.
'" name="idline'.$suffix.
'" type="hidden" value="'.$objd->rowid.
'">';
727 print
'<input name="product_batch'.$suffix.
'" type="hidden" value="'.$objd->fk_product.
'">';
729 print
'<!-- This is a U.P. (may include discount or not depending on STOCK_EXCLUDE_DISCOUNT_FOR_PMP. will be used for PMP calculation) -->';
730 if (!empty($conf->global->SUPPLIER_ORDER_EDIT_BUYINGPRICE_DURING_RECEIPT)) {
731 print $langs->trans(
"BuyingPrice").
': <input class="maxwidth75" name="pu'.$suffix.
'" type="text" value="'.
price2num($up_ht_disc,
'MU').
'">';
733 print
'<input class="maxwidth75" name="pu'.$suffix.
'" type="hidden" value="'.
price2num($up_ht_disc,
'MU').
'">';
739 print
'<input disabled="" type="text" class="inputlotnumber quatrevingtquinzepercent" id="lot_number'.$suffix.
'" name="lot_number'.$suffix.
'" value="'.$objd->batch.
'">';
741 if (empty($conf->global->PRODUCT_DISABLE_SELLBY)) {
742 print
'<td class="nowraponall">';
744 print
$form->selectDate($dlcdatesuffix,
'dlc'.$suffix,
'',
'', 1,
'');
747 if (empty($conf->global->PRODUCT_DISABLE_EATBY)) {
748 print
'<td class="nowraponall">';
750 print
$form->selectDate($dluodatesuffix,
'dluo'.$suffix,
'',
'', 1,
'');
753 print
'<td colspan="3"> </td>';
757 $colspan = (!empty($conf->global->PRODUCT_DISABLE_SELLBY)) ? --$colspan : $colspan;
758 $colspan = (!empty($conf->global->PRODUCT_DISABLE_EATBY)) ? --$colspan : $colspan;
763 'is_information_row' =>
true,
768 $reshook = $hookmanager->executeHooks(
769 'printFieldListValue',
777 print $hookmanager->resPrint;
781 print
'<!-- line no batch '.$numline.
' -->';
782 print
'<tr class="oddeven autoresettr" name="'.$type.$suffix.
'" data-remove="clear">';
783 print
'<td colspan="'.$colspan.
'">';
784 print
'<input id="fk_commandefourndet'.$suffix.
'" name="fk_commandefourndet'.$suffix.
'" type="hidden" value="'.$objp->rowid.
'">';
785 print
'<input id="idline'.$suffix.
'" name="idline'.$suffix.
'" type="hidden" value="'.$objd->rowid.
'">';
786 print
'<input name="product'.$suffix.
'" type="hidden" value="'.$objd->fk_product.
'">';
788 print
'<!-- This is a up (may include discount or not depending on STOCK_EXCLUDE_DISCOUNT_FOR_PMP. will be used for PMP calculation) -->';
789 if (!empty($conf->global->SUPPLIER_ORDER_EDIT_BUYINGPRICE_DURING_RECEIPT)) {
790 print $langs->trans(
"BuyingPrice").
': <input class="maxwidth75" name="pu'.$suffix.
'" type="text" value="'.
price2num($up_ht_disc,
'MU').
'">';
792 print
'<input class="maxwidth75" name="pu'.$suffix.
'" type="hidden" value="'.
price2num($up_ht_disc,
'MU').
'">';
798 print
'<td class="right">';
799 print
'<a href="#" id="reset'.$suffix.
'" class="resetline">'.
img_picto($langs->trans(
"Reset"),
'eraser',
'class="pictofixedwidth opacitymedium"').
'</a>';
800 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.
'">';
803 if (
isModEnabled(
'productbatch') && $objp->tobatch > 0) {
805 print
img_picto($langs->trans(
'AddStockLocationLine'),
'split.png',
'class="splitbutton" '.($numd != $j+1 ?
'style="display:none"' :
'').
' onClick="addDispatchLine('.$i.
', \''.$type.
'\')
"');
808 print img_picto($langs->trans('AddStockLocationLine'), 'split.png', 'class="splitbutton
" '.($numd != $j+1 ? 'style="display:none
"' : '').' onClick="addDispatchLine(
'.$i.', \
''.$type.
'\')
"');
813 if (!empty($conf->global->SUPPLIER_ORDER_CAN_UPDATE_BUYINGPRICE_DURING_RECEIPT)) {
814 if (!isModEnabled("multicurrency
") && empty($conf->dynamicprices->enabled)) {
816 print '<td class="right
">';
817 print '<input id="pu
'.$suffix.'" name="pu
'.$suffix.'" type="text
" size="8
" value="'.price((GETPOST('pu
'.$suffix) != '' ? price2num(GETPOST('pu
'.$suffix)) : $up_ht_disc)).'">';
821 print '<td class="right
">';
822 print '<input id="dto
'.$suffix.'" name="dto
'.$suffix.'" type="text
" size="8
" value="'.(GETPOST('dto
'.$suffix) != '' ? GETPOST('dto
'.$suffix) : '').'">';
826 print '<td class="center
">';
827 print '<input class="flat checkformerge
" type="checkbox
" name="saveprice
'.$suffix.'" value="'.(GETPOST('saveprice
'.$suffix) != '' ? GETPOST('saveprice
'.$suffix) : '').'">';
833 print '<td class="right
">';
834 if (count($listwarehouses) > 1) {
835 print $formproduct->selectWarehouses(GETPOST("entrepot
".$suffix) ?GETPOST("entrepot
".$suffix) : $objd->fk_entrepot, "entrepot
".$suffix, '', 1, 0, $objp->fk_product, '', 1, 0, null, 'csswarehouse'.$suffix);
836 } elseif (count($listwarehouses) == 1) {
837 print $formproduct->selectWarehouses(GETPOST("entrepot
".$suffix) ?GETPOST("entrepot
".$suffix) : $objd->fk_entrepot, "entrepot
".$suffix, '', 0, 0, $objp->fk_product, '', 1, 0, null, 'csswarehouse'.$suffix);
839 $langs->load("errors
");
840 print $langs->trans("ErrorNoWarehouseDefined
");
844 // Enable hooks to append additional columns
846 'is_information_row' => false, // this is a dispatch form row
851 $reshook = $hookmanager->executeHooks(
852 'printFieldListValue',
858 setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
860 print $hookmanager->resPrint;
867 $suffix = "_
".$j."_
".$i;
871 if (isModEnabled('productbatch') && !empty($objp->tobatch)) {
874 // Enable hooks to append additional columns
876 // allows hook to distinguish between the rows with information and the rows with dispatch form input
877 'is_information_row' => true,
882 $reshook = $hookmanager->executeHooks(
883 'printFieldListValue',
889 setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
891 print $hookmanager->resPrint;
895 print '<!-- line for batch '.$numline.' (not dispatched line yet for this order line) -->';
896 print '<tr class="oddeven autoresettr
" name="'.$type.$suffix.'">';
898 print '<input id="fk_commandefourndet
'.$suffix.'" name="fk_commandefourndet
'.$suffix.'" type="hidden
" value="'.$objp->rowid.'">';
899 print '<input id="idline
'.$suffix.'" name="idline
'.$suffix.'" type="hidden
" value="-1
">';
900 print '<input name="product_batch
'.$suffix.'" type="hidden
" value="'.$objp->fk_product.'">';
902 print '<!-- This is a up (may include discount or not depending on STOCK_EXCLUDE_DISCOUNT_FOR_PMP. will be used for PMP calculation) -->';
903 if (!empty($conf->global->SUPPLIER_ORDER_EDIT_BUYINGPRICE_DURING_RECEIPT)) { // Not tested !
904 print $langs->trans("BuyingPrice
").': <input class="maxwidth75
" name="pu
'.$suffix.'" type="text
" value="'.price2num($up_ht_disc, 'MU
').'">';
906 print '<input class="maxwidth75
" name="pu
'.$suffix.'" type="hidden
" value="'.price2num($up_ht_disc, 'MU
').'">';
912 print '<input type="text
" class="inputlotnumber quatrevingtquinzepercent
" id="lot_number
'.$suffix.'" name="lot_number
'.$suffix.'" value="'.GETPOST('lot_number
'.$suffix).'">';
914 if (empty($conf->global->PRODUCT_DISABLE_SELLBY)) {
915 print '<td class="nowraponall
">';
916 $dlcdatesuffix = dol_mktime(0, 0, 0, GETPOST('dlc'.$suffix.'month'), GETPOST('dlc'.$suffix.'day'), GETPOST('dlc'.$suffix.'year'));
917 print $form->selectDate($dlcdatesuffix, 'dlc'.$suffix, '', '', 1, '');
920 if (empty($conf->global->PRODUCT_DISABLE_EATBY)) {
921 print '<td class="nowraponall
">';
922 $dluodatesuffix = dol_mktime(0, 0, 0, GETPOST('dluo'.$suffix.'month'), GETPOST('dluo'.$suffix.'day'), GETPOST('dluo'.$suffix.'year'));
923 print $form->selectDate($dluodatesuffix, 'dluo'.$suffix, '', '', 1, '');
926 print '<td colspan="3
"> </td>'; // Supplier ref + Qty ordered + qty already dispatched
930 $colspan = (!empty($conf->global->PRODUCT_DISABLE_SELLBY)) ? --$colspan : $colspan;
931 $colspan = (!empty($conf->global->PRODUCT_DISABLE_EATBY)) ? --$colspan : $colspan;
933 // Enable hooks to append additional columns
935 // allows hook to distinguish between the rows with information and the rows with dispatch form input
936 'is_information_row' => true,
941 $reshook = $hookmanager->executeHooks(
942 'printFieldListValue',
948 setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
950 print $hookmanager->resPrint;
954 print '<!-- line no batch '.$numline.' (not dispatched line yet for this order line) -->';
955 print '<tr class="oddeven autoresettr
" name="'.$type.$suffix.'" data-remove="clear
">';
956 print '<td colspan="'.$colspan.'">';
957 print '<input id="fk_commandefourndet
'.$suffix.'" name="fk_commandefourndet
'.$suffix.'" type="hidden
" value="'.$objp->rowid.'">';
958 print '<input id="idline
'.$suffix.'" name="idline
'.$suffix.'" type="hidden
" value="-1
">';
959 print '<input name="product
'.$suffix.'" type="hidden
" value="'.$objp->fk_product.'">';
961 print '<!-- This is a up (may include discount or not depending on STOCK_EXCLUDE_DISCOUNT_FOR_PMP. will be used for PMP calculation) -->';
962 if (!empty($conf->global->SUPPLIER_ORDER_EDIT_BUYINGPRICE_DURING_RECEIPT)) { // Not tested !
963 print $langs->trans("BuyingPrice
").': <input class="maxwidth75
" name="pu
'.$suffix.'" data-type="text
" value="'.price2num($up_ht_disc, 'MU
').'">';
965 print '<input class="maxwidth75
" name="pu
'.$suffix.'" type="hidden
" value="'.price2num($up_ht_disc, 'MU
').'">';
971 print '<td class="right
">';
972 print '<a href="#
" id="reset
'.$suffix.'" class="resetline
">'.img_picto($langs->trans("Reset
"), 'eraser', 'class="pictofixedwidth opacitymedium
"').'</a>';
973 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') : (empty($conf->global->SUPPLIER_ORDER_DISPATCH_FORCE_QTY_INPUT_TO_ZERO) ? $remaintodispatch : 0)).'" data-expected="'.$remaintodispatch.'">';
976 if (isModEnabled('productbatch') && $objp->tobatch > 0) {
978 print img_picto($langs->trans('AddStockLocationLine'), 'split.png', 'class="splitbutton
" onClick="addDispatchLine(
'.$i.', \
''.$type.
'\')
"');
981 print img_picto($langs->trans('AddStockLocationLine'), 'split.png', 'class="splitbutton
" onClick="addDispatchLine(
'.$i.', \
''.$type.
'\')
"');
986 if (!empty($conf->global->SUPPLIER_ORDER_CAN_UPDATE_BUYINGPRICE_DURING_RECEIPT)) {
987 if (!isModEnabled("multicurrency
") && empty($conf->dynamicprices->enabled)) {
989 print '<td class="right
">';
990 print '<input id="pu
'.$suffix.'" name="pu
'.$suffix.'" type="text
" size="8
" value="'.price((GETPOST('pu
'.$suffix) != '' ? price2num(GETPOST('pu
'.$suffix)) : $up_ht_disc)).'">';
994 print '<td class="right
">';
995 print '<input id="dto
'.$suffix.'" name="dto
'.$suffix.'" type="text
" size="8
" value="'.(GETPOST('dto
'.$suffix) != '' ? GETPOST('dto
'.$suffix) : '').'">';
999 print '<td class="center
">';
1000 print '<input class="flat checkformerge
" type="checkbox
" name="saveprice
'.$suffix.'" value="'.(GETPOST('saveprice
'.$suffix) != '' ? GETPOST('saveprice
'.$suffix) : '').'">';
1006 print '<td class="right
">';
1007 if (count($listwarehouses) > 1) {
1008 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);
1009 } elseif (count($listwarehouses) == 1) {
1010 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);
1012 $langs->load("errors
");
1013 print $langs->trans("ErrorNoWarehouseDefined
");
1017 // Enable hooks to append additional columns
1018 $parameters = array(
1019 'is_information_row' => false, // this is a dispatch form row
1021 'suffix' => $suffix,
1024 $reshook = $hookmanager->executeHooks(
1025 'printFieldListValue',
1031 setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
1033 print $hookmanager->resPrint;
1042 dol_print_error($db);
1049 $checkboxlabel = $langs->trans("CloseReceivedSupplierOrdersAutomatically
", $langs->transnoentitiesnoconv('StatusOrderReceivedAll'));
1051 print '<div class="center
">';
1052 $parameters = array();
1053 $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been
1055 if (empty($reshook)) {
1056 if (empty($conf->reception->enabled)) {
1057 print $langs->trans("Comment").' : ';
1058 print '<input type="text
" class="minwidth400
" maxlength="128
" name="comment
" value="';
1059 print GETPOSTISSET("comment") ? GETPOST("comment") : $langs->trans("DispatchSupplierOrder", $object->ref);
1060 // print ' /
'.$object->ref_supplier; // Not yet available
1061 print '" class="flat
"><br>';
1063 print '<input type="checkbox
" checked="checked
" name="closeopenorder
"> '.$checkboxlabel;
1066 $dispatchBt = empty($conf->reception->enabled) ? $langs->trans("Receive
") : $langs->trans("CreateReception
");
1069 print '<input type="submit
" id="submitform
" class="button" name="dispatch
" value="'.$langs->trans("Save").'"';
1071 if (!$permissiontoreceive) {
1074 if (count($listwarehouses) <= 0) {
1086 // Message if nothing to dispatch
1089 if (empty($conf->global->SUPPLIER_ORDER_DISABLE_STOCK_DISPATCH_WHEN_TOTAL_REACHED)) {
1090 print '<div class="opacitymedium
">'.$langs->trans("NoPredefinedProductToDispatch
").'</div>'; // No predefined line at all
1092 print '<div class="opacitymedium
">'.$langs->trans("NoMorePredefinedProductToDispatch
").'</div>'; // No predefined line that remain to be dispatched.
1099 print dol_get_fiche_end();
1101 // traitement entrepot par défaut
1102 print '<script type="text/javascript
">
1103 $(document).ready(function () {
1104 $("select[
name=fk_default_warehouse]
").change(function() {
1105 var fk_default_warehouse = $("option:selected
", this).val();
1106 $("select[
name^=entrepot_]
").val(fk_default_warehouse).change();
1109 $("#autoreset
").click(function() {
1110 $(".autoresettr
").each(function(){
1111 id = $(this).attr("name");
1112 idtab = id.split("_
");
1113 if ($(this).data("remove") == "clear
"){
1114 console.log("We clear the
object to expected value
")
1115 $("#qty_
"+idtab[1]+"_
"+idtab[2]).val("");
1117 qtyexpected = $("#qty_
"+idtab[1]+"_
"+idtab[2]).data("expected
")
1118 console.log(qtyexpected);
1119 $("#qty_
"+idtab[1]+"_
"+idtab[2]).val(qtyexpected);
1120 qtydispatched = $("#qty_dispatched_0_
"+idtab[2]).data("dispatched
")
1121 $("#qty_dispatched_0_
"+idtab[2]).val(qtydispatched);
1124 console.log("We
remove the
object")
1126 $("tr[
name^=\
'"+idtab[0]+"_\'][name$=\'_"+idtab[2]+"\']:last .splitbutton").show();
1132 $("#resetalltoexpected").click(function(){
1133 $(".qtydispatchinput").each(function(){
1134 console.log("We reset to expected "+$(this).attr("id")+" qty to dispatch");
1135 $(this).val($(this).data("expected"));
1140 $(".resetline").click(function(){
1141 id = $(this).attr("id");
1142 id = id.split("reset_");
1143 console.log("Reset trigger for id = qty_"+id[1]);
1144 $("#qty_"+id[1]).val("");
if(GETPOST('button_removefilter_x', 'alpha')||GETPOST('button_removefilter.x', 'alpha')||GETPOST('button_removefilter', 'alpha')) if(GETPOST('button_search_x', 'alpha')||GETPOST('button_search.x', 'alpha')||GETPOST('button_search', 'alpha')) if($action=="save" &&empty($cancel)) $help_url
View.
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 stock movements.
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.
if(isModEnabled('facture') && $user->hasRight('facture', 'lire')) if((isModEnabled('fournisseur') &&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->hasRight("fournisseur", "facture", "lire"))||(isModEnabled('supplier_invoice') && $user->hasRight("supplier_invoice", "lire"))) if(isModEnabled('don') && $user->hasRight('don', 'lire')) if(isModEnabled('tax') &&!empty($user->rights->tax->charges->lire)) if(isModEnabled('facture') &&isModEnabled('commande') && $user->hasRight("commande", "lire") &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) $sql
Social contributions to pay.
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
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 '.
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)
newToken()
Return the value of token currently saved into session with name 'newtoken'.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0)
Set event messages in dol_events session object.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form.
isModEnabled($module)
Is Dolibarr module enabled.
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.
if(!defined( 'CSRFCHECK_WITH_TOKEN'))
$formconfirm
if ($action == 'delbookkeepingyear') {
table tableforfield button
0 = Do not include form tag and submit button -1 = Do not include form tag but include submit button
div float
Buy price without taxes.
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.