FIX Several problems into shipment management with lot enabled

This commit is contained in:
Laurent Destailleur 2016-11-14 14:34:15 +01:00
parent ecbe719f23
commit 62e0d4ec3f
6 changed files with 69 additions and 35 deletions

View File

@ -2493,13 +2493,13 @@ if ($action == 'create' && $user->rights->commande->creer)
if ($object->statut > Commande::STATUS_DRAFT && $object->statut < Commande::STATUS_CLOSED && $object->getNbOfProductsLines() > 0) {
if (($conf->expedition_bon->enabled && $user->rights->expedition->creer) || ($conf->livraison_bon->enabled && $user->rights->expedition->livraison->creer)) {
if ($user->rights->expedition->creer) {
print '<div class="inline-block divButAction"><a class="butAction" href="' . DOL_URL_ROOT . '/expedition/shipment.php?id=' . $object->id . '">' . $langs->trans('ShipProduct') . '</a></div>';
print '<div class="inline-block divButAction"><a class="butAction" href="' . DOL_URL_ROOT . '/expedition/shipment.php?id=' . $object->id . '">' . $langs->trans('CreateShipment') . '</a></div>';
} else {
print '<div class="inline-block divButAction"><a class="butActionRefused" href="#" title="' . dol_escape_htmltag($langs->trans("NotAllowed")) . '">' . $langs->trans('ShipProduct') . '</a></div>';
print '<div class="inline-block divButAction"><a class="butActionRefused" href="#" title="' . dol_escape_htmltag($langs->trans("NotAllowed")) . '">' . $langs->trans('CreateShipment') . '</a></div>';
}
} else {
$langs->load("errors");
print '<div class="inline-block divButAction"><a class="butActionRefused" href="#" title="' . dol_escape_htmltag($langs->trans("ErrorModuleSetupNotComplete")) . '">' . $langs->trans('ShipProduct') . '</a></div>';
print '<div class="inline-block divButAction"><a class="butActionRefused" href="#" title="' . dol_escape_htmltag($langs->trans("ErrorModuleSetupNotComplete")) . '">' . $langs->trans('CreateShipment') . '</a></div>';
}
}
}

View File

@ -172,9 +172,9 @@ function show_list_sending_receive($origin,$origin_id,$filter='')
$expedition=new Expedition($db);
$warehousestatic=new Entrepot($db);
$sql = "SELECT obj.rowid, obj.fk_product, obj.label, obj.description, obj.product_type as fk_product_type, obj.qty as qty_asked, obj.date_start, obj.date_end";
$sql.= ", ed.qty as qty_shipped, ed.fk_expedition as expedition_id, ed.fk_origin_line, ed.fk_entrepot as warehouse_id";
$sql.= ", e.rowid as sendingid, e.ref as exp_ref, e.date_creation, e.date_delivery, e.date_expedition,";
$sql = "SELECT obj.rowid, obj.fk_product, obj.label, obj.description, obj.product_type as fk_product_type, obj.qty as qty_asked, obj.date_start, obj.date_end,";
$sql.= " ed.rowid as edrowid, ed.qty as qty_shipped, ed.fk_expedition as expedition_id, ed.fk_origin_line, ed.fk_entrepot as warehouse_id,";
$sql.= " e.rowid as sendingid, e.ref as exp_ref, e.date_creation, e.date_delivery, e.date_expedition,";
//if ($conf->livraison_bon->enabled) $sql .= " l.rowid as livraison_id, l.ref as livraison_ref, l.date_delivery, ld.qty as qty_received,";
$sql.= ' p.label as product_label, p.ref, p.fk_product_type, p.rowid as prodid, p.tobatch as product_tobatch,';
$sql.= ' p.description as product_desc';
@ -183,6 +183,7 @@ function show_list_sending_receive($origin,$origin_id,$filter='')
$sql.= ", ".MAIN_DB_PREFIX.$origin."det as obj";
//if ($conf->livraison_bon->enabled) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."livraison as l ON l.fk_expedition = e.rowid LEFT JOIN ".MAIN_DB_PREFIX."livraisondet as ld ON ld.fk_livraison = l.rowid AND obj.rowid = ld.fk_origin_line";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON obj.fk_product = p.rowid";
//TODO Add link to expeditiondet_batch
$sql.= " WHERE e.entity IN (".getEntity('expedition', 1).")";
$sql.= " AND obj.fk_".$origin." = ".$origin_id;
$sql.= " AND obj.rowid = ed.fk_origin_line";
@ -210,11 +211,17 @@ function show_list_sending_receive($origin,$origin_id,$filter='')
print '<td align="left">'.$langs->trans("Description").'</td>';
print '<td align="center">'.$langs->trans("DateCreation").'</td>';
print '<td align="center">'.$langs->trans("DateDeliveryPlanned").'</td>';
print '<td align="center">'.$langs->trans("QtyShipped").'</td>';
print '<td align="center">'.$langs->trans("QtyPreparedOrShipped").'</td>';
if (! empty($conf->stock->enabled))
{
print '<td>'.$langs->trans("Warehouse").'</td>';
}
/*TODO Add link to expeditiondet_batch
if (! empty($conf->productbatch->enabled))
{
print '<td>';
print '</td>';
}*/
if (! empty($conf->livraison_bon->enabled))
{
print '<td>'.$langs->trans("DeliveryOrder").'</td>';
@ -231,7 +238,9 @@ function show_list_sending_receive($origin,$origin_id,$filter='')
print "<tr ".$bc[$var].">";
// Sending id
print '<td align="left" class="nowrap"><a href="'.DOL_URL_ROOT.'/expedition/card.php?id='.$objp->expedition_id.'">'.img_object($langs->trans("ShowSending"),'sending').' '.$objp->exp_ref.'<a></td>';
print '<td align="left" class="nowrap">';
print '<a href="'.DOL_URL_ROOT.'/expedition/card.php?id='.$objp->expedition_id.'">'.img_object($langs->trans("ShowSending"),'sending').' '.$objp->exp_ref.'<a>';
print '</td>';
// Description
if ($objp->fk_product > 0)
@ -328,6 +337,34 @@ function show_list_sending_receive($origin,$origin_id,$filter='')
print '</td>';
}
// Batch number managment
/*TODO Add link to expeditiondet_batch
if (! empty($conf->productbatch->enabled))
{
var_dump($objp->edrowid);
$lines[$i]->detail_batch
if (isset($lines[$i]->detail_batch))
{
print '<td>';
if ($lines[$i]->product_tobatch)
{
$detail = '';
foreach ($lines[$i]->detail_batch as $dbatch)
{
$detail.= $langs->trans("DetailBatchFormat",$dbatch->batch,dol_print_date($dbatch->eatby,"day"),dol_print_date($dbatch->sellby,"day"),$dbatch->dluo_qty).'<br/>';
}
print $form->textwithtooltip(img_picto('', 'object_barcode').' '.$langs->trans("DetailBatchNumber"),$detail);
}
else
{
print $langs->trans("NA");
}
print '</td>';
} else {
print '<td></td>';
}
}*/
// Informations on receipt
if (! empty($conf->livraison_bon->enabled))
{

View File

@ -613,7 +613,7 @@ $warehousestatic = new Entrepot($db);
if ($action == 'create2')
{
print load_fiche_titre($langs->trans("CreateASending")).'<br>';
print load_fiche_titre($langs->trans("CreateShipment")).'<br>';
print $langs->trans("ShipmentCreationIsDoneFromOrder");
$action=''; $id=''; $ref='';
}
@ -623,7 +623,7 @@ if ($action == 'create')
{
$expe = new Expedition($db);
print load_fiche_titre($langs->trans("CreateASending"));
print load_fiche_titre($langs->trans("CreateShipment"));
if (! $origin)
{
setEventMessages($langs->trans("ErrorBadParameters"), null, 'errors');
@ -1715,7 +1715,7 @@ else if ($id || $ref)
//if ($filter) $sql.= $filter;
$sql.= " ORDER BY obj.fk_product";
dol_syslog("show_list_sending_receive", LOG_DEBUG);
dol_syslog("get list of shipment lines", LOG_DEBUG);
$resql = $db->query($sql);
if ($resql)
{

View File

@ -695,7 +695,7 @@ if ($id > 0 || ! empty($ref))
{
if ($user->rights->expedition->creer)
{
print '<a class="butAction" href="'.DOL_URL_ROOT.'/expedition/card.php?action=create&amp;origin=commande&amp;object_id='.$id.'">'.$langs->trans("NewSending").'</a>';
print '<a class="butAction" href="'.DOL_URL_ROOT.'/expedition/card.php?action=create&amp;origin=commande&amp;object_id='.$id.'">'.$langs->trans("CreateShipment").'</a>';
if ($toBeShippedTotal <= 0)
{
print ' '.img_warning($langs->trans("WarningNoQtyLeftToSend"));
@ -703,7 +703,7 @@ if ($id > 0 || ! empty($ref))
}
else
{
print '<a class="butActionRefused" href="#">'.$langs->trans("NewSending").'</a>';
print '<a class="butActionRefused" href="#">'.$langs->trans("CreateShipment").'</a>';
}
}
print "</div>";
@ -721,42 +721,46 @@ if ($id > 0 || ! empty($ref))
{
if ($user->rights->expedition->creer)
{
print load_fiche_titre($langs->trans("NewSending"));
//print load_fiche_titre($langs->trans("CreateShipment"));
print '<div class="tabsAction">';
print '<form method="GET" action="'.DOL_URL_ROOT.'/expedition/card.php">';
print '<input type="hidden" name="action" value="create">';
//print '<input type="hidden" name="id" value="'.$commande->id.'">';
print '<input type="hidden" name="shipping_method_id" value="'.$commande->shipping_method_id.'">';
print '<input type="hidden" name="origin" value="commande">';
print '<input type="hidden" name="origin_id" value="'.$commande->id.'">';
print '<table class="border" width="100%">';
//print '<table class="border" width="100%">';
$langs->load("stocks");
print '<tr>';
//print '<tr>';
if (! empty($conf->stock->enabled))
{
print '<td>'.$langs->trans("WarehouseSource").'</td>';
print '<td>';
//print '<td>';
print $langs->trans("WarehouseSource");
//print '</td>';
//print '<td>';
print $formproduct->selectWarehouses(! empty($commande->warehouse_id)?$commande->warehouse_id:-1, 'entrepot_id', '', 1, 0, 0, '', 0, 0, array(), 'minwidth200');
if (count($formproduct->cache_warehouses) <= 0)
{
print ' &nbsp; '.$langs->trans("WarehouseSourceNotDefined").' <a href="'.DOL_URL_ROOT.'/product/stock/card.php?action=create">'.$langs->trans("AddOne").'</a>';
}
print '</td>';
//print '</td>';
}
print '<td align="center">';
print '<input type="submit" class="button" named="save" value="'.$langs->trans("NewSending").'">';
//print '<td align="center">';
print '<input type="submit" class="butAction" named="save" value="'.$langs->trans("CreateShipment").'">';
if ($toBeShippedTotal <= 0)
{
print ' '.img_warning($langs->trans("WarningNoQtyLeftToSend"));
}
print '</td></tr>';
//print '</td></tr>';
print "</table>";
//print "</table>";
print "</form>\n";
print '<br>';
print '</div>';
$somethingshown=1;
@ -764,7 +768,7 @@ if ($id > 0 || ! empty($ref))
else
{
print '<div class="tabsAction">';
print '<a class="butActionRefused" href="#">'.$langs->trans("NewSending").'</a>';
print '<a class="butActionRefused" href="#">'.$langs->trans("CreateShipment").'</a>';
print '</div>';
}
}

View File

@ -16,8 +16,9 @@ NbOfSendings=Number of shipments
NumberOfShipmentsByMonth=Number of shipments by month
SendingCard=Shipment card
NewSending=New shipment
CreateASending=Create a shipment
CreateShipment=Create shipment
QtyShipped=Qty shipped
QtyPreparedOrShipped=Qty prepared or shipped
QtyToShip=Qty to ship
QtyReceived=Qty received
QtyInOtherShipments=Qty in other shipments

View File

@ -750,14 +750,6 @@ else
// Rien a droite
print '</td></tr></table>';
// List of existing shipment and delivery receipts
/*if ($expedition->origin_id)
{
print '<br>';
//show_list_sending_receive($expedition->origin,$expedition->origin_id," AND e.rowid <> ".$expedition->id);
show_list_sending_receive($expedition->origin,$expedition->origin_id);
}*/
}
else
{