FIX affichage ligne reception

This commit is contained in:
atm-quentin 2018-10-08 12:15:17 +02:00
parent 815353ec36
commit 095d851e79
4 changed files with 101 additions and 141 deletions

View File

@ -25,6 +25,7 @@ OrdersToBill=Commandes clients à délivrer
OrdersInProcess=Commandes clients en traitement
OrdersToProcess=Commandes clients à traiter
SuppliersOrdersToProcess=Commandes fournisseurs à traiter
SuppliersOrdersInProcess=Commandes fournisseurs en traitement
StatusOrderCanceledShort=Annulée
StatusOrderDraftShort=Brouillon
StatusOrderValidatedShort=Validée

View File

@ -1939,7 +1939,7 @@ else if ($id || $ref)
$sql.= " AND ed.fk_reception = e.rowid";
//if ($filter) $sql.= $filter;
$sql.= " ORDER BY obj.fk_product";
print $sql;exit;
dol_syslog("get list of reception lines", LOG_DEBUG);
$resql = $db->query($sql);
if ($resql)
@ -1953,7 +1953,7 @@ else if ($id || $ref)
if ($obj)
{
// $obj->rowid is rowid in $origin."det" table
$alreadysent[$obj->rowid][$obj->receptionline_id]=array('reception_ref'=>$obj->reception_ref, 'reception_id'=>$obj->reception_id, 'warehouse'=>$obj->fk_entrepot, 'qty_shipped'=>$obj->qty_shipped, 'date_valid'=>$obj->date_valid, 'date_delivery'=>$obj->date_delivery);
$alreadysent[$obj->rowid][$obj->receptionline_id]=array('reception_ref'=>$obj->reception_ref, 'reception_id'=>$obj->reception_id, 'warehouse'=>$obj->fk_entrepot, 'qty_shipped'=>$obj->qty, 'date_valid'=>$obj->date_valid, 'date_delivery'=>$obj->date_delivery);
}
$i++;
}
@ -1981,26 +1981,27 @@ else if ($id || $ref)
{
$prod = new Product($db);
$prod->fetch($lines[$i]->fk_product);
$label = ( ! empty($prod->multilangs[$outputlangs->defaultlang]["label"])) ? $prod->multilangs[$outputlangs->defaultlang]["label"] : $lines[$i]->product_label;
$label = ( ! empty($prod->multilangs[$outputlangs->defaultlang]["label"])) ? $prod->multilangs[$outputlangs->defaultlang]["label"] : $lines[$i]->product->product_label;
}
else
$label = (! empty($lines[$i]->label)?$lines[$i]->label:$lines[$i]->product_label);
$label = (! empty($lines[$i]->product->label)?$lines[$i]->product->label:$lines[$i]->product->product_label);
print '<td>';
// Show product and description
$product_static->type=$lines[$i]->fk_product_type;
$product_static->id=$lines[$i]->fk_product;
$product_static->ref=$lines[$i]->ref;
$product_static->status_batch=$lines[$i]->product_tobatch;
$product_static->type=$lines[$i]->product->fk_product_type;
$product_static->id=$lines[$i]->product->fk_product;
$product_static->ref=$lines[$i]->product->ref;
$product_static->status_batch=$lines[$i]->product->product_tobatch;
$text=$product_static->getNomUrl(1);
$text.= ' - '.$label;
$description=(! empty($conf->global->PRODUIT_DESC_IN_FORM)?'':dol_htmlentitiesbr($lines[$i]->description));
$description=(! empty($conf->global->PRODUIT_DESC_IN_FORM)?'':dol_htmlentitiesbr($lines[$i]->product->description));
print $form->textwithtooltip($text,$description,3,'','',$i);
print_date_range($lines[$i]->date_start,$lines[$i]->date_end);
if (! empty($conf->global->PRODUIT_DESC_IN_FORM))
{
print (! empty($lines[$i]->description) && $lines[$i]->description!=$lines[$i]->product)?'<br>'.dol_htmlentitiesbr($lines[$i]->description):'';
print (! empty($lines[$i]->product->description) && $lines[$i]->description!=$lines[$i]->product->description)?'<br>'.dol_htmlentitiesbr($lines[$i]->description):'';
}
print "</td>\n";
}
@ -2030,7 +2031,7 @@ else if ($id || $ref)
print '<td align="center" class="nowrap">';
foreach ($alreadysent as $key => $val)
{
if ($lines[$i]->fk_origin_line == $key)
if ($lines[$i]->fk_commandefourndet == $key)
{
$j = 0;
foreach($val as $receptionline_id=> $receptionline_var)
@ -2042,6 +2043,7 @@ else if ($id || $ref)
$reception_static->fetch($receptionline_var['reception_id']);
print $reception_static->getNomUrl(1);
print ' - '.$receptionline_var['qty_shipped'];
$htmltext=$langs->trans("DateValidation").' : '.(empty($receptionline_var['date_valid'])?$langs->trans("Draft"):dol_print_date($receptionline_var['date_valid'], 'dayhour'));
if (! empty($conf->stock->enabled) && $receptionline_var['warehouse'] > 0)
{
@ -2059,72 +2061,24 @@ else if ($id || $ref)
{
// edit mode
print '<td colspan="'.$editColspan.'" align="center"><table class="nobordernopadding">';
if (is_array($lines[$i]->detail_batch) && count($lines[$i]->detail_batch) > 0)
{
print '<!-- case edit 1 -->';
$line = new CommandeFournisseurDispatch($db);
foreach ($lines[$i]->detail_batch as $detail_batch)
{
print '<tr>';
// Qty to ship or shipped
print '<td>' . '<input name="qtyl'.$detail_batch->fk_receptiondet.'_'.$detail_batch->id.'" id="qtyl'.$line_id.'_'.$detail_batch->id.'" type="text" size="4" value="'.$detail_batch->dluo_qty.'">' . '</td>';
// Batch number managment
if ($lines[$i]->entrepot_id == 0)
{
// only show lot numbers from src warehouse when reception from multiple warehouses
$line->fetch($detail_batch->fk_receptiondet);
}
print '<td>' . $formproduct->selectLotStock($detail_batch->fk_origin_stock, 'batchl'.$detail_batch->fk_receptiondet.'_'.$detail_batch->fk_origin_stock, '', 1, 0, $lines[$i]->fk_product, $line->entrepot_id). '</td>';
print '</tr>';
}
// add a 0 qty lot row to be able to add a lot
print '<tr>';
// Qty to ship or shipped
print '<td>' . '<input name="qtyl'.$line_id.'_0" id="qtyl'.$line_id.'_0" type="text" size="4" value="0">' . '</td>';
// Batch number managment
print '<td>' . $formproduct->selectLotStock('', 'batchl'.$line_id.'_0', '', 1, 0, $lines[$i]->fk_product). '</td>';
print '</tr>';
}
else if (! empty($conf->stock->enabled))
if (! empty($conf->stock->enabled))
{
if ($lines[$i]->fk_product > 0)
{
if ($lines[$i]->entrepot_id > 0)
{
print '<!-- case edit 2 -->';
print '<!-- case edit 1 -->';
print '<tr>';
// Qty to ship or shipped
print '<td>' . '<input name="qtyl'.$line_id.'" id="qtyl'.$line_id.'" type="text" size="4" value="'.$lines[$i]->qty_shipped.'">' . '</td>';
// Warehouse source
print '<td>' . $formproduct->selectWarehouses($lines[$i]->entrepot_id, 'entl'.$line_id, '', 1, 0, $lines[$i]->fk_product, '', 1). '</td>';
// Batch number managment
print '<td> - ' . $langs->trans("NA") . '</td>';
//@TODO Batch number managment
if($conf->productbatch->enabled)print '<td> - ' . $langs->trans("NA") . '</td>';
print '</tr>';
}
else if (count($lines[$i]->details_entrepot) > 1)
{
print '<!-- case edit 3 -->';
foreach ($lines[$i]->details_entrepot as $detail_entrepot)
{
print '<tr>';
// Qty to ship or shipped
print '<td>' . '<input name="qtyl'.$detail_entrepot->line_id.'" id="qtyl'.$detail_entrepot->line_id.'" type="text" size="4" value="'.$detail_entrepot->qty_shipped.'">' . '</td>';
// Warehouse source
print '<td>' . $formproduct->selectWarehouses($detail_entrepot->entrepot_id, 'entl'.$detail_entrepot->line_id, '', 1, 0, $lines[$i]->fk_product, '', 1) . '</td>';
// Batch number managment
print '<td> - ' . $langs->trans("NA") . '</td>';
print '</tr>';
}
}
else
{
print '<!-- case edit 4 -->';
print '<tr><td colspan="3">'.$langs->trans("NotEnoughStock").'</td></tr>';
}
}
else
{
print '<!-- case edit 5 -->';
print '<!-- case edit 2 -->';
print '<tr>';
// Qty to ship or shipped
print '<td>' . '<input name="qtyl'.$line_id.'" id="qtyl'.$line_id.'" type="text" size="4" value="'.$lines[$i]->qty_shipped.'">' . '</td>';
@ -2140,16 +2094,16 @@ else if ($id || $ref)
else
{
// Qty to ship or shipped
print '<td align="center">'.$lines[$i]->qty_shipped.'</td>';
print '<td align="center">'.$lines[$i]->qty.'</td>';
// Warehouse source
if (! empty($conf->stock->enabled))
{
print '<td align="left">';
if ($lines[$i]->entrepot_id > 0)
if ($lines[$i]->fk_entrepot > 0)
{
$entrepot = new Entrepot($db);
$entrepot->fetch($lines[$i]->entrepot_id);
$entrepot->fetch($lines[$i]->fk_entrepot);
print $entrepot->getNomUrl(1);
}
else if (count($lines[$i]->details_entrepot) > 1)
@ -2172,21 +2126,20 @@ else if ($id || $ref)
// Batch number managment
if (! empty($conf->productbatch->enabled))
{
if (isset($lines[$i]->detail_batch))
if (isset($lines[$i]->batch))
{
print '<!-- Detail of lot -->';
print '<td>';
if ($lines[$i]->product_tobatch)
$detail ='';
if ($lines[$i]->product->status_batch)
{
$detail = '';
foreach ($lines[$i]->detail_batch as $dbatch)
{
$detail.= $langs->trans("Batch").': '.$dbatch->batch;
$detail.= ' - '.$langs->trans("SellByDate").': '.dol_print_date($dbatch->sellby,"day");
$detail.= ' - '.$langs->trans("EatByDate").': '.dol_print_date($dbatch->eatby,"day");
$detail.= ' - '.$langs->trans("Qty").': '.$dbatch->dluo_qty;
$detail.= $langs->trans("Batch").': '.$lines[$i]->batch;
$detail.= ' - '.$langs->trans("SellByDate").': '.dol_print_date($lines[$i]->sellby,"day");
$detail.= ' - '.$langs->trans("EatByDate").': '.dol_print_date($lines[$i]->eatby,"day");
$detail.= '<br>';
}
print $form->textwithtooltip(img_picto('', 'object_barcode').' '.$langs->trans("DetailBatchNumber"),$detail);
}
else
@ -2202,13 +2155,13 @@ else if ($id || $ref)
// Weight
print '<td align="center">';
if ($lines[$i]->fk_product_type == Product::TYPE_PRODUCT) print $lines[$i]->weight*$lines[$i]->qty_shipped.' '.measuring_units_string($lines[$i]->weight_units,"weight");
if ($lines[$i]->fk_product_type == Product::TYPE_PRODUCT) print $lines[$i]->product->weight*$lines[$i]->qty.' '.measuring_units_string($lines[$i]->product->weight_units,"weight");
else print '&nbsp;';
print '</td>';
// Volume
print '<td align="center">';
if ($lines[$i]->fk_product_type == Product::TYPE_PRODUCT) print $lines[$i]->volume*$lines[$i]->qty_shipped.' '.measuring_units_string($lines[$i]->volume_units,"volume");
if ($lines[$i]->fk_product_type == Product::TYPE_PRODUCT) print $lines[$i]->product->volume*$lines[$i]->qty.' '.measuring_units_string($lines[$i]->product->volume_units,"volume");
else print '&nbsp;';
print '</td>';

View File

@ -1190,7 +1190,7 @@ class Reception extends CommonObject
function fetch_lines()
{
global $db;
dol_include_once('/fourn/class/fournisseur.commande.dispatch.class.php');
$sql = 'SELECT rowid FROM '.MAIN_DB_PREFIX.'commande_fournisseur_dispatch WHERE fk_reception='.$this->id;
$resql = $db->query($sql);
if(!empty($resql)){
@ -1199,7 +1199,14 @@ class Reception extends CommonObject
$line = new CommandeFournisseurDispatch($db);
$line->fetch($obj->rowid);
$line->fetch_product();
$sql_qtyasked = 'SELECT qty FROM llx_commande_fournisseurdet WHERE rowid='.$line->fk_commandefourndet;
$resql_qtyasked = $db->query($sql_qtyasked);
if(!empty($resql_qtyasked)){
$obj = $db->fetch_object($resql_qtyasked);
$line->qty_asked = $obj->qty;
}else {
$line->qty_asked = 0;
}
$this->lines[]=$line;
}
@ -1464,7 +1471,7 @@ class Reception extends CommonObject
$i=0;
$sql = "SELECT em.rowid, em.code, em.libelle, em.description, em.tracking, em.active";
$sql.= " FROM ".MAIN_DB_PREFIX."c_reception_mode as em";
$sql.= " FROM ".MAIN_DB_PREFIX."c_shipment_mode as em";
if ($id!='') $sql.= " WHERE em.rowid=".$id;
$resql = $this->db->query($sql);
@ -1495,13 +1502,13 @@ class Reception extends CommonObject
{
if ($id=='')
{
$sql = "INSERT INTO ".MAIN_DB_PREFIX."c_reception_mode (code, libelle, description, tracking)";
$sql = "INSERT INTO ".MAIN_DB_PREFIX."c_shipment_mode (code, libelle, description, tracking)";
$sql.=" VALUES ('".$this->update['code']."','".$this->update['libelle']."','".$this->update['description']."','".$this->update['tracking']."')";
$resql = $this->db->query($sql);
}
else
{
$sql = "UPDATE ".MAIN_DB_PREFIX."c_reception_mode SET";
$sql = "UPDATE ".MAIN_DB_PREFIX."c_shipment_mode SET";
$sql.= " code='".$this->db->escape($this->update['code'])."'";
$sql.= ",libelle='".$this->db->escape($this->update['libelle'])."'";
$sql.= ",description='".$this->db->escape($this->update['description'])."'";
@ -1521,7 +1528,7 @@ class Reception extends CommonObject
*/
function activ_delivery_method($id)
{
$sql = 'UPDATE '.MAIN_DB_PREFIX.'c_reception_mode SET active=1';
$sql = 'UPDATE '.MAIN_DB_PREFIX.'c_shipment_mode SET active=1';
$sql.= ' WHERE rowid='.$id;
$resql = $this->db->query($sql);
@ -1537,7 +1544,7 @@ class Reception extends CommonObject
*/
function disable_delivery_method($id)
{
$sql = 'UPDATE '.MAIN_DB_PREFIX.'c_reception_mode SET active=0';
$sql = 'UPDATE '.MAIN_DB_PREFIX.'c_shipment_mode SET active=0';
$sql.= ' WHERE rowid='.$id;
$resql = $this->db->query($sql);
@ -1556,7 +1563,7 @@ class Reception extends CommonObject
if (! empty($this->shipping_method_id))
{
$sql = "SELECT em.code, em.tracking";
$sql.= " FROM ".MAIN_DB_PREFIX."c_reception_mode as em";
$sql.= " FROM ".MAIN_DB_PREFIX."c_shipment_mode as em";
$sql.= " WHERE em.rowid = ".$this->shipping_method_id;
$resql = $this->db->query($sql);

View File

@ -18,30 +18,30 @@
*/
/**
* \file htdocs/expedition/index.php
* \ingroup expedition
* \brief Home page of shipping area.
* \file htdocs/reception/index.php
* \ingroup reception
* \brief Home page of reception area.
*/
require '../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php';
require_once DOL_DOCUMENT_ROOT.'/expedition/class/expedition.class.php';
require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php';
require_once DOL_DOCUMENT_ROOT.'/reception/class/reception.class.php';
$langs->load("orders");
$langs->load("sendings");
$langs->load("receptions");
/*
* View
*/
$orderstatic=new Commande($db);
$orderstatic=new CommandeFournisseur($db);
$companystatic=new Societe($db);
$shipment=new Expedition($db);
$reception=new Reception($db);
$helpurl='EN:Module_Shipments|FR:Module_Exp&eacute;ditions|ES:M&oacute;dulo_Expediciones';
llxHeader('',$langs->trans("Shipment"),$helpurl);
$helpurl='EN:Module_Receptions|FR:Module_Receptions|ES:M&oacute;dulo_Receptiones';
llxHeader('',$langs->trans("Reception"),$helpurl);
print load_fiche_titre($langs->trans("SendingsArea"));
print load_fiche_titre($langs->trans("ReceptionsArea"));
print '<div class="fichecenter"><div class="fichethirdleft">';
@ -54,21 +54,21 @@ if (! empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS)) // This is usele
print '<table class="noborder nohover" width="100%">';
print '<tr class="liste_titre"><td colspan="3">'.$langs->trans("Search").'</td></tr>';
print '<tr class="oddeven"><td>';
print $langs->trans("Shipment").':</td><td><input type="text" class="flat" name="sall" size="18"></td><td><input type="submit" value="'.$langs->trans("Search").'" class="button"></td></tr>';
print $langs->trans("Reception").':</td><td><input type="text" class="flat" name="sall" size="18"></td><td><input type="submit" value="'.$langs->trans("Search").'" class="button"></td></tr>';
print "</table></form><br>\n";
}
/*
* Shipments to validate
* Receptions to validate
*/
$clause = " WHERE ";
$sql = "SELECT e.rowid, e.ref, e.ref_customer,";
$sql = "SELECT e.rowid, e.ref, e.ref_supplier,";
$sql.= " s.nom as name, s.rowid as socid,";
$sql.= " c.ref as commande_ref, c.rowid as commande_id";
$sql.= " FROM ".MAIN_DB_PREFIX."expedition as e";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."element_element as el ON e.rowid = el.fk_target AND el.targettype = 'shipping'";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."commande as c ON el.fk_source = c.rowid";
$sql.= " c.ref as commande_fournisseur_ref, c.rowid as commande_fournisseur_id";
$sql.= " FROM ".MAIN_DB_PREFIX."reception as e";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."element_element as el ON e.rowid = el.fk_target AND el.targettype = 'reception'";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."commande_fournisseur as c ON el.fk_source = c.rowid";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = e.fk_soc";
if (!$user->rights->societe->client->voir && !$socid)
{
@ -77,7 +77,7 @@ if (!$user->rights->societe->client->voir && !$socid)
$clause = " AND ";
}
$sql.= $clause." e.fk_statut = 0";
$sql.= " AND e.entity IN (".getEntity('expedition').")";
$sql.= " AND e.entity IN (".getEntity('reception').")";
if ($socid) $sql.= " AND c.fk_soc = ".$socid;
$resql=$db->query($sql);
@ -88,24 +88,24 @@ if ($resql)
{
print '<table class="noborder" width="100%">';
print '<tr class="liste_titre">';
print '<th colspan="3">'.$langs->trans("SendingsToValidate").'</th></tr>';
print '<th colspan="3">'.$langs->trans("ReceptionsToValidate").'</th></tr>';
$i = 0;
while ($i < $num)
{
$obj = $db->fetch_object($resql);
$shipment->id=$obj->rowid;
$shipment->ref=$obj->ref;
$shipment->ref_customer=$obj->ref_customer;
$reception->id=$obj->rowid;
$reception->ref=$obj->ref;
$reception->ref_supplier=$obj->ref_supplier;
print '<tr class="oddeven"><td class="nowrap">';
print $shipment->getNomUrl(1);
print $reception->getNomUrl(1);
print "</td>";
print '<td>';
print '<a href="'.DOL_URL_ROOT.'/comm/card.php?socid='.$obj->socid.'">'.$obj->name.'</a>';
print '</td>';
print '<td>';
if ($obj->commande_id) print '<a href="'.DOL_URL_ROOT.'/commande/card.php?id='.$obj->commande_id.'">'.$obj->commande_ref.'</a>';
if ($obj->commande_fournisseur_id) print '<a href="'.DOL_URL_ROOT.'/commande_fournisseur/card.php?id='.$obj->commande_fournisseur_id.'">'.$obj->commande_fournisseur_ref.'</a>';
print '</td></tr>';
$i++;
}
@ -115,19 +115,18 @@ if ($resql)
/*
* Commandes a traiter
* CommandeFournisseurs a traiter
*/
$sql = "SELECT c.rowid, c.ref, c.ref_client as ref_customer, c.fk_statut, s.nom as name, s.rowid as socid";
$sql.= " FROM ".MAIN_DB_PREFIX."commande as c,";
$sql = "SELECT c.rowid, c.ref, c.ref_supplier as ref_supplier, c.fk_statut, s.nom as name, s.rowid as socid";
$sql.= " FROM ".MAIN_DB_PREFIX."commande_fournisseur as c,";
$sql.= " ".MAIN_DB_PREFIX."societe as s";
if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
$sql.= " WHERE c.fk_soc = s.rowid";
$sql.= " AND c.entity = ".$conf->entity;
$sql.= " AND c.fk_statut = 1";
$sql.= " AND c.fk_statut = 2";//Approuvé
if ($socid) $sql.= " AND c.fk_soc = ".$socid;
if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
$sql.= " ORDER BY c.rowid ASC";
$resql=$db->query($sql);
if ($resql)
{
@ -139,14 +138,14 @@ if ($resql)
$i = 0;
print '<table class="noborder" width="100%">';
print '<tr class="liste_titre">';
print '<th colspan="3">'.$langs->trans("OrdersToProcess").'</th></tr>';
print '<th colspan="3">'.$langs->trans("SuppliersOrdersToProcess").'</th></tr>';
while ($i < $num)
{
$obj = $db->fetch_object($resql);
$orderstatic->id=$obj->rowid;
$orderstatic->ref=$obj->ref;
$orderstatic->ref_customer=$obj->ref_customer;
$orderstatic->ref_supplier=$obj->ref_supplier;
$orderstatic->statut=$obj->fk_statut;
$orderstatic->facturee=0;
@ -176,15 +175,15 @@ print '</div><div class="fichetwothirdright"><div class="ficheaddleft">';
/*
* Commandes en traitement
* CommandeFournisseurs en traitement
*/
$sql = "SELECT c.rowid, c.ref, c.ref_client as ref_customer, c.fk_statut as status, c.facture as billed, s.nom as name, s.rowid as socid";
$sql.= " FROM ".MAIN_DB_PREFIX."commande as c,";
$sql = "SELECT c.rowid, c.ref, c.ref_supplier as ref_supplier, c.fk_statut as status, c.billed as billed, s.nom as name, s.rowid as socid";
$sql.= " FROM ".MAIN_DB_PREFIX."commande_fournisseur as c,";
$sql.= " ".MAIN_DB_PREFIX."societe as s";
if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
$sql.= " WHERE c.fk_soc = s.rowid";
$sql.= " AND c.entity = ".$conf->entity;
$sql.= " AND c.fk_statut = 2";
$sql.= " AND c.fk_statut IN (3,4)";
if ($socid) $sql.= " AND c.fk_soc = ".$socid;
if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
@ -199,14 +198,14 @@ if ( $resql )
$i = 0;
print '<table class="noborder" width="100%">';
print '<tr class="liste_titre">';
print '<th colspan="3">'.$langs->trans("OrdersInProcess").'</th></tr>';
print '<th colspan="3">'.$langs->trans("SuppliersOrdersInProcess").'</th></tr>';
while ($i < $num)
{
$obj = $db->fetch_object($resql);
$orderstatic->id=$obj->rowid;
$orderstatic->ref=$obj->ref;
$orderstatic->ref_customer=$obj->ref_customer;
$orderstatic->ref_supplier=$obj->ref_supplier;
$orderstatic->statut=$obj->status;
$orderstatic->facturee=$obj->billed;
@ -232,17 +231,17 @@ else dol_print_error($db);
/*
* Last shipments
* Last receptions
*/
$sql = "SELECT e.rowid, e.ref, e.ref_customer,";
$sql = "SELECT e.rowid, e.ref, e.ref_supplier,";
$sql.= " s.nom as name, s.rowid as socid,";
$sql.= " c.ref as commande_ref, c.rowid as commande_id";
$sql.= " FROM ".MAIN_DB_PREFIX."expedition as e";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."element_element as el ON e.rowid = el.fk_target AND el.targettype = 'shipping' AND el.sourcetype IN ('commande')";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."commande as c ON el.fk_source = c.rowid AND el.sourcetype IN ('commande') AND el.targettype = 'shipping'";
$sql.= " c.ref as commande_fournisseur_ref, c.rowid as commande_fournisseur_id";
$sql.= " FROM ".MAIN_DB_PREFIX."reception as e";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."element_element as el ON e.rowid = el.fk_target AND el.targettype = 'reception' AND el.sourcetype IN ('commande_fournisseur')";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."commande_fournisseur as c ON el.fk_source = c.rowid AND el.sourcetype IN ('commande_fournisseur') AND el.targettype = 'reception'";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = e.fk_soc";
if (! $user->rights->societe->client->voir && ! $socid) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON e.fk_soc = sc.fk_soc";
$sql.= " WHERE e.entity IN (".getEntity('expedition').")";
$sql.= " WHERE e.entity IN (".getEntity('reception').")";
if (! $user->rights->societe->client->voir && ! $socid) $sql.= " AND sc.fk_user = " .$user->id;
$sql.= " AND e.fk_statut = 1";
if ($socid) $sql.= " AND c.fk_soc = ".$socid;
@ -258,24 +257,24 @@ if ($resql)
$i = 0;
print '<table class="noborder" width="100%">';
print '<tr class="liste_titre">';
print '<th colspan="3">'.$langs->trans("LastSendings", $num).'</th></tr>';
print '<th colspan="3">'.$langs->trans("LastReceptions", $num).'</th></tr>';
while ($i < $num)
{
$obj = $db->fetch_object($resql);
$shipment->id=$obj->rowid;
$shipment->ref=$obj->ref;
$shipment->ref_customer=$obj->ref_customer;
$reception->id=$obj->rowid;
$reception->ref=$obj->ref;
$reception->ref_supplier=$obj->ref_supplier;
print '<tr class="oddeven"><td>';
print $shipment->getNomUrl(1);
print $reception->getNomUrl(1);
print '</td>';
print '<td><a href="'.DOL_URL_ROOT.'/comm/card.php?socid='.$obj->socid.'">'.img_object($langs->trans("ShowCompany"),"company").' '.$obj->name.'</a></td>';
print '<td>';
if ($obj->commande_id > 0)
if ($obj->commande_fournisseur_id > 0)
{
$orderstatic->id=$obj->commande_id;
$orderstatic->ref=$obj->commande_ref;
$orderstatic->id=$obj->commande_fournisseur_id;
$orderstatic->ref=$obj->commande_fournisseur_ref;
print $orderstatic->getNomUrl(1);
}
else print '&nbsp;';