Skip to content

Commit

Permalink
actualize from develop
Browse files Browse the repository at this point in the history
  • Loading branch information
Christophe Battarel committed Sep 5, 2019
1 parent 7c3e643 commit dff36c9
Showing 1 changed file with 114 additions and 30 deletions.
144 changes: 114 additions & 30 deletions htdocs/fourn/commande/dispatch.php
Expand Up @@ -246,7 +246,7 @@
// 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 ++;
Expand Down Expand Up @@ -283,7 +283,7 @@
// 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 ++;
Expand Down Expand Up @@ -418,13 +418,13 @@
print '<div class="fichecenter">';
print '<div class="underbanner clearboth"></div>';

print '<table class="border" width="100%">';
print '<table class="border tableforfield" width="100%">';

// Date
if ($object->methode_commande_id > 0) {
print '<tr><td class="titlefield">' . $langs->trans("Date") . '</td><td>';
if ($object->date_commande) {
print dol_print_date($object->date_commande, "dayhourtext") . "\n";
print dol_print_date($object->date_commande, "dayhour") . "\n";
}
print "</td></tr>";

Expand Down Expand Up @@ -454,12 +454,13 @@

// Line of orders
if ($object->statut <= CommandeFournisseur::STATUS_ACCEPTED || $object->statut >= CommandeFournisseur::STATUS_CANCELED) {
print '<span class="opacitymedium">'.$langs->trans("OrderStatusNotReadyToDispatch").'</span>';
print '<br><span class="opacitymedium">'.$langs->trans("OrderStatusNotReadyToDispatch").'</span>';
}

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);
Expand Down Expand Up @@ -500,11 +501,35 @@

$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";

Expand All @@ -514,23 +539,23 @@
$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 '<tr class="liste_titre">';

print '<td>' . $langs->trans("Description") . '</td>';
Expand All @@ -546,12 +571,24 @@
print '<td></td>';
print '<td></td>';
}
print '<td class="right">' . $langs->trans("SupplierRef") . '</td>';
//print '<td class="right">' . $langs->trans("SupplierRef") . '</td>';
print '<td class="right">' . $langs->trans("QtyOrdered") . '</td>';
print '<td class="right">' . $langs->trans("QtyDispatchedShort") . '</td>';
print '<td class="right">' . $langs->trans("QtyToDispatchShort") . '</td>';
print '<td width="32"></td>';
print '<td class="right">' . $langs->trans("Warehouse") . '</td>';
print '<td align="right">' . $langs->trans("Warehouse") . '</td>';

// 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 "</tr>\n";
}

Expand Down Expand Up @@ -618,7 +655,7 @@
$up_ht_disc = price2num($up_ht_disc * (100 - $objp->remise_percent) / 100, 'MU');

// Supplier ref
print '<td class="right">'.$objp->sref.'</td>';
//print '<td class="right">'.$objp->sref.'</td>';

// Qty ordered
print '<td class="right">' . $objp->qty . '</td>';
Expand All @@ -634,6 +671,23 @@
//print img_picto($langs->trans('AddDispatchBatchLine'), 'split.png', 'onClick="addDispatchLine(' . $i . ',\'' . $type . '\')"');
print '</td>'; // Dispatch column
print '<td></td>'; // 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 '</tr>';

print '<tr class="oddeven" name="' . $type . $suffix . '">';
Expand Down Expand Up @@ -674,10 +728,27 @@
//print img_picto($langs->trans('AddStockLocationLine'), 'split.png', 'onClick="addDispatchLine(' . $i . ',\'' . $type . '\')"');
print '</td>'; // Dispatch column
print '<td></td>'; // 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 '</tr>';

print '<tr class="oddeven" name="' . $type . $suffix . '">';
print '<td colspan="7">';
print '<td colspan="6">';
print '<input name="fk_commandefourndet' . $suffix . '" type="hidden" value="' . $objp->rowid . '">';
print '<input name="product' . $suffix . '" type="hidden" value="' . $objp->fk_product . '">';

Expand Down Expand Up @@ -725,6 +796,19 @@
}
print "</td>\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 "</tr>\n";
}
}
Expand All @@ -737,13 +821,12 @@

print "</table>\n";
print '</div>';
print "<br>\n";

if ($nbproduct)
{
$checkboxlabel = $langs->trans("CloseReceivedSupplierOrdersAutomatically", $langs->transnoentitiesnoconv('StatusOrderReceivedAll'));

print '<br><div class="center">';
print '<div class="center">';
$parameters = array();
$reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been
// modified by hook
Expand All @@ -760,7 +843,7 @@
}
empty($conf->reception->enabled)?$dispatchBt=$langs->trans("DispatchVerb"):$dispatchBt=$langs->trans("Receive");

print '<br><input type="submit" class="button" value="' . $dispatchBt. '"';
print '<br><input type="submit" class="button" name="dispatch" value="' . dol_escape_htmltag($dispatchBt). '"';
if (count($listwarehouses) <= 0)
print ' disabled';
print '>';
Expand All @@ -770,7 +853,8 @@

// Message if nothing to dispatch
if (! $nbproduct) {
if (empty($conf->global->SUPPLIER_ORDER_DISABLE_STOCK_DISPATCH_WHEN_TOTAL_REACHED))
print "<br>\n";
if (empty($conf->global->SUPPLIER_ORDER_DISABLE_STOCK_DISPATCH_WHEN_TOTAL_REACHED))
print '<div class="opacitymedium">'.$langs->trans("NoPredefinedProductToDispatch").'</div>'; // No predefined line at all
else
print '<div class="opacitymedium">'.$langs->trans("NoMorePredefinedProductToDispatch").'</div>'; // No predefined line that remain to be dispatched.
Expand Down

0 comments on commit dff36c9

Please sign in to comment.