diff --git a/htdocs/fourn/commande/dispatch.php b/htdocs/fourn/commande/dispatch.php index a97ea89b31a..ea51bcdb4d7 100644 --- a/htdocs/fourn/commande/dispatch.php +++ b/htdocs/fourn/commande/dispatch.php @@ -246,7 +246,7 @@ if ($action == 'dispatch' && $user->rights->fournisseur->commande->receptionner) // We ask to move a qty if (GETPOST($qty) != 0) { if (! (GETPOST($ent, 'int') > 0)) { - dol_syslog('No dispatch for line ' . $key . ' as no warehouse choosed'); + dol_syslog('No dispatch for line ' . $key . ' as no warehouse was chosen.'); $text = $langs->transnoentities('Warehouse') . ', ' . $langs->transnoentities('Line') . ' ' . ($numline); setEventMessages($langs->trans('ErrorFieldRequired', $text), null, 'errors'); $error ++; @@ -283,7 +283,7 @@ if ($action == 'dispatch' && $user->rights->fournisseur->commande->receptionner) // We ask to move a qty if (GETPOST($qty) > 0) { if (! (GETPOST($ent, 'int') > 0)) { - dol_syslog('No dispatch for line ' . $key . ' as no warehouse choosed'); + dol_syslog('No dispatch for line ' . $key . ' as no warehouse was chosen.'); $text = $langs->transnoentities('Warehouse') . ', ' . $langs->transnoentities('Line') . ' ' . ($numline) . '-' . ($reg[1] + 1); setEventMessages($langs->trans('ErrorFieldRequired', $text), null, 'errors'); $error ++; @@ -418,13 +418,13 @@ if ($id > 0 || ! empty($ref)) { print '
'; print '
'; - print ''; + print '
'; // Date if ($object->methode_commande_id > 0) { print '"; @@ -454,12 +454,13 @@ if ($id > 0 || ! empty($ref)) { // Line of orders if ($object->statut <= CommandeFournisseur::STATUS_ACCEPTED || $object->statut >= CommandeFournisseur::STATUS_CANCELED) { - print ''.$langs->trans("OrderStatusNotReadyToDispatch").''; + print '
'.$langs->trans("OrderStatusNotReadyToDispatch").''; } if ($object->statut == CommandeFournisseur::STATUS_ORDERSENT || $object->statut == CommandeFournisseur::STATUS_RECEIVED_PARTIALLY - || $object->statut == CommandeFournisseur::STATUS_RECEIVED_COMPLETELY) { + || $object->statut == CommandeFournisseur::STATUS_RECEIVED_COMPLETELY) + { require_once DOL_DOCUMENT_ROOT.'/product/class/html.formproduct.class.php'; $formproduct = new FormProduct($db); @@ -500,11 +501,35 @@ if ($id > 0 || ! empty($ref)) { $sql = "SELECT l.rowid, l.fk_product, l.subprice, l.remise_percent, l.ref AS sref, SUM(l.qty) as qty,"; $sql .= " p.ref, p.label, p.tobatch, p.fk_default_warehouse"; + + // Enable hooks to alter the SQL query (SELECT) + $parameters = array(); + $reshook = $hookmanager->executeHooks( + 'printFieldListSelect', + $parameters, + $object, + $action + ); + if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + $sql .= $hookmanager->resPrint; + $sql .= " FROM " . MAIN_DB_PREFIX . "commande_fournisseurdet as l"; $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "product as p ON l.fk_product=p.rowid"; $sql .= " WHERE l.fk_commande = " . $object->id; if (empty($conf->global->STOCK_SUPPORTS_SERVICES)) $sql .= " AND l.product_type = 0"; + + // Enable hooks to alter the SQL query (WHERE) + $parameters = array(); + $reshook = $hookmanager->executeHooks( + 'printFieldListWhere', + $parameters, + $object, + $action + ); + if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + $sql .= $hookmanager->resPrint; + $sql .= " GROUP BY p.ref, p.label, p.tobatch, l.rowid, l.fk_product, l.subprice, l.remise_percent, p.fk_default_warehouse"; // Calculation of amount dispatched is done per fk_product so we must group by fk_product $sql .= " ORDER BY p.ref, p.label"; @@ -514,23 +539,23 @@ if ($id > 0 || ! empty($ref)) { $i = 0; if ($num) { - $entrepot = new Entrepot($db); - $listwarehouses=$entrepot->list_array(1); + $entrepot = new Entrepot($db); + $listwarehouses=$entrepot->list_array(1); + // entrepot par défaut + print $langs->trans("Warehouse").' : '; + if (count($listwarehouses)>1) + { + print $form->selectarray('fk_default_warehouse', $listwarehouses, $fk_default_warehouse, 1, 0, 0, '', 0, 0, $disabled); + } + elseif (count($listwarehouses)==1) + { + print $form->selectarray('fk_default_warehouse', $listwarehouses, $fk_default_warehouse, 0, 0, 0, '', 0, 0, $disabled); + } + else + { + print $langs->trans("NoWarehouseDefined"); + } - // entrepot par défaut - print $langs->trans("Warehouse").' : '; - if (count($listwarehouses)>1) - { - print $form->selectarray('fk_default_warehouse', $listwarehouses, $fk_default_warehouse, 1, 0, 0, '', 0, 0, $disabled); - } - elseif (count($listwarehouses)==1) - { - print $form->selectarray('fk_default_warehouse', $listwarehouses, $fk_default_warehouse, 0, 0, 0, '', 0, 0, $disabled); - } - else - { - print $langs->trans("NoWarehouseDefined"); - } print ''; print ''; @@ -546,12 +571,24 @@ if ($id > 0 || ! empty($ref)) { print ''; print ''; } - print ''; + //print ''; print ''; print ''; print ''; print ''; - print ''; + print ''; + + // Enable hooks to append additional columns + $parameters = array(); + $reshook = $hookmanager->executeHooks( + 'printFieldListTitle', + $parameters, + $object, + $action + ); + if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + print $hookmanager->resPrint; + print "\n"; } @@ -618,7 +655,7 @@ if ($id > 0 || ! empty($ref)) { $up_ht_disc = price2num($up_ht_disc * (100 - $objp->remise_percent) / 100, 'MU'); // Supplier ref - print ''; + //print ''; // Qty ordered print ''; @@ -634,6 +671,23 @@ if ($id > 0 || ! empty($ref)) { //print img_picto($langs->trans('AddDispatchBatchLine'), 'split.png', 'onClick="addDispatchLine(' . $i . ',\'' . $type . '\')"'); print ''; // Dispatch column print ''; // Warehouse column + + // Enable hooks to append additional columns + $parameters = array( + 'is_information_row' => true, // allows hook to distinguish between the + // rows with information and the rows with + // dispatch form input + 'objp' => $objp + ); + $reshook = $hookmanager->executeHooks( + 'printFieldListValue', + $parameters, + $object, + $action + ); + if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + print $hookmanager->resPrint; + print ''; print ''; @@ -674,10 +728,27 @@ if ($id > 0 || ! empty($ref)) { //print img_picto($langs->trans('AddStockLocationLine'), 'split.png', 'onClick="addDispatchLine(' . $i . ',\'' . $type . '\')"'); print ''; // Dispatch column print ''; // Warehouse column + + // Enable hooks to append additional columns + $parameters = array( + 'is_information_row' => true, // allows hook to distinguish between the + // rows with information and the rows with + // dispatch form input + 'objp' => $objp + ); + $reshook = $hookmanager->executeHooks( + 'printFieldListValue', + $parameters, + $object, + $action + ); + if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + print $hookmanager->resPrint; + print ''; print ''; - print '\n"; + // Enable hooks to append additional columns + $parameters = array( + 'is_information_row' => false // this is a dispatch form row + ); + $reshook = $hookmanager->executeHooks( + 'printFieldListValue', + $parameters, + $object, + $action + ); + if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + print $hookmanager->resPrint; + print "\n"; } } @@ -737,13 +821,12 @@ if ($id > 0 || ! empty($ref)) { print "
' . $langs->trans("Date") . ''; if ($object->date_commande) { - print dol_print_date($object->date_commande, "dayhourtext") . "\n"; + print dol_print_date($object->date_commande, "dayhour") . "\n"; } print "
' . $langs->trans("Description") . '' . $langs->trans("SupplierRef") . '' . $langs->trans("SupplierRef") . '' . $langs->trans("QtyOrdered") . '' . $langs->trans("QtyDispatchedShort") . '' . $langs->trans("QtyToDispatchShort") . '' . $langs->trans("Warehouse") . '' . $langs->trans("Warehouse") . '
'.$objp->sref.''.$objp->sref.'' . $objp->qty . '
'; + print ''; print ''; print ''; @@ -725,6 +796,19 @@ if ($id > 0 || ! empty($ref)) { } print "
\n"; print '
'; - print "
\n"; if ($nbproduct) { $checkboxlabel = $langs->trans("CloseReceivedSupplierOrdersAutomatically", $langs->transnoentitiesnoconv('StatusOrderReceivedAll')); - print '
'; + print '
'; $parameters = array(); $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been // modified by hook @@ -760,7 +843,7 @@ if ($id > 0 || ! empty($ref)) { } empty($conf->reception->enabled)?$dispatchBt=$langs->trans("DispatchVerb"):$dispatchBt=$langs->trans("Receive"); - print '
'; @@ -770,7 +853,8 @@ if ($id > 0 || ! empty($ref)) { // Message if nothing to dispatch if (! $nbproduct) { - if (empty($conf->global->SUPPLIER_ORDER_DISABLE_STOCK_DISPATCH_WHEN_TOTAL_REACHED)) + print "
\n"; + if (empty($conf->global->SUPPLIER_ORDER_DISABLE_STOCK_DISPATCH_WHEN_TOTAL_REACHED)) print '
'.$langs->trans("NoPredefinedProductToDispatch").'
'; // No predefined line at all else print '
'.$langs->trans("NoMorePredefinedProductToDispatch").'
'; // No predefined line that remain to be dispatched.