Quelques améliorations diverses sur gestion des éxpéditions

This commit is contained in:
Laurent Destailleur 2006-07-14 11:31:57 +00:00
parent 4db870e577
commit 7facc82362
11 changed files with 478 additions and 391 deletions

View File

@ -1035,7 +1035,7 @@ class Commande extends CommonObject
*/ */
function expedition_array($filtre_statut=-1) function expedition_array($filtre_statut=-1)
{ {
$this->livraisons = array(); $this->expeditions = array();
$sql = 'SELECT fk_product, sum(ed.qty)'; $sql = 'SELECT fk_product, sum(ed.qty)';
$sql.=' FROM '.MAIN_DB_PREFIX.'expeditiondet as ed, '.MAIN_DB_PREFIX.'expedition as e, '.MAIN_DB_PREFIX.'commande as c, '.MAIN_DB_PREFIX.'commandedet as cd'; $sql.=' FROM '.MAIN_DB_PREFIX.'expeditiondet as ed, '.MAIN_DB_PREFIX.'expedition as e, '.MAIN_DB_PREFIX.'commande as c, '.MAIN_DB_PREFIX.'commandedet as cd';
$sql.=' WHERE ed.fk_expedition = e.rowid AND ed.fk_commande_ligne = cd .rowid AND cd.fk_commande = c.rowid'; $sql.=' WHERE ed.fk_expedition = e.rowid AND ed.fk_commande_ligne = cd .rowid AND cd.fk_commande = c.rowid';
@ -1060,13 +1060,13 @@ class Commande extends CommonObject
} }
/** /**
* Renvoie un tableau avec les expeditions par ligne * Renvoie un tableau avec nombre de lignes d'expeditions
* *
*/ */
function nb_expedition() function nb_expedition()
{ {
$sql = 'SELECT count(*) FROM '.MAIN_DB_PREFIX.'expedition as e'; $sql = 'SELECT count(*) FROM '.MAIN_DB_PREFIX.'expedition as e';
$sql .=" WHERE e.fk_commande = $this->id"; $sql .=" WHERE e.fk_commande = ".$this->id;
$result = $this->db->query($sql); $result = $this->db->query($sql);
if ($result) if ($result)
@ -1107,6 +1107,43 @@ class Commande extends CommonObject
return 0; return 0;
} }
/**
* \brief Renvoie un tableau avec les stocks restant par produit
* \param filtre_statut Filtre sur statut
* \return int 0 si OK, <0 si KO
* \todo FONCTION NON FINIE A FINIR
*/
function stock_array($filtre_statut=-1)
{
$this->stocks = array();
// Tableau des id de produit de la commande
// Recherche total en stock pour chaque produit
if (sizeof($array_of_product))
{
$sql = "SELECT fk_product, sum(ps.reel)";
$sql.= " FROM ".MAIN_DB_PREFIX."product_stock as ps";
$sql.= " WHERE ps.fk_product in (".join(',',$array_of_product).")";
$sql.= ' GROUP BY fk_product ';
$result = $this->db->query($sql);
if ($result)
{
$num = $this->db->num_rows();
$i = 0;
while ($i < $num)
{
$row = $this->db->fetch_row( $i);
$this->stocks[$row[0]] = $row[1];
$i++;
}
$this->db->free();
}
}
return 0;
}
/** /**
* \brief Supprime une ligne de la commande * \brief Supprime une ligne de la commande
* \param idligne Id de la ligne à supprimer * \param idligne Id de la ligne à supprimer

View File

@ -41,6 +41,7 @@ $langs->load("companies");
$langs->load("bills"); $langs->load("bills");
$langs->load('propal'); $langs->load('propal');
$langs->load('deliveries'); $langs->load('deliveries');
$langs->load('stocks');
$user->getrights('commande'); $user->getrights('commande');
$user->getrights('expedition'); $user->getrights('expedition');
@ -300,7 +301,7 @@ if ($_GET["id"] > 0)
/** /**
* Lignes de commandes avec quantité livrées et reste à livrer * Lignes de commandes avec quantité livrées et reste à livrer
* * Les quantités livrées sont stockées dans $commande->expeditions[fk_product]
*/ */
echo '<table class="liste" width="100%">'; echo '<table class="liste" width="100%">';
@ -352,7 +353,7 @@ if ($_GET["id"] > 0)
} }
else else
{ {
print "<td>".stripslashes(nl2br($objp->description))."</td>\n"; print "<td>".nl2br($objp->description)."</td>\n";
} }
print '<td align="center">'.$objp->qty.'</td>'; print '<td align="center">'.$objp->qty.'</td>';
@ -363,22 +364,20 @@ if ($_GET["id"] > 0)
print '</td>'; print '</td>';
$reste_a_livrer[$objp->fk_product] = $objp->qty - $quantite_livree; $reste_a_livrer[$objp->fk_product] = $objp->qty - $quantite_livree;
$reste_a_livrer_x = $objp->qty - $quantite_livree; $reste_a_livrer_total = $reste_a_livrer_total + $reste_a_livrer[$objp->fk_product];
$reste_a_livrer_total = $reste_a_livrer_total + $reste_a_livrer_x;
print '<td align="center">'; print '<td align="center">';
print $reste_a_livrer[$objp->fk_product]; print $reste_a_livrer[$objp->fk_product];
print '</td>'; print '</td>';
if ($conf->stock->enabled) if ($conf->stock->enabled)
{ {
if ($product->stock_reel < $reste_a_livrer_x) print '<td align="center">';
print $product->stock_reel;
if ($product->stock_reel < $reste_a_livrer[$objp->fk_product])
{ {
print '<td align="center" class="alerte">'.$product->stock_reel.'</td>'; print ' '.img_warning($langs->trans("StockTooLow"));
}
else
{
print '<td align="center">'.$product->stock_reel.'</td>';
} }
print '</td>';
} }
else else
{ {
@ -459,51 +458,6 @@ if ($_GET["id"] > 0)
print "</form>\n"; print "</form>\n";
} }
/*
* Alerte de seuil
*/
if ($reste_a_livrer_total > 0 && $conf->stock->enabled)
{
print '<br><table class="liste" width="100%">';
foreach ($reste_a_livrer as $key => $value)
{
if ($value > 0)
{
$sql = "SELECT e.rowid as entrepot_id, e.label as entrepot, ps.reel, p.label, p.ref, p.rowid as fk_product";
$sql .= " FROM ".MAIN_DB_PREFIX."entrepot as e, ".MAIN_DB_PREFIX."product_stock as ps, ".MAIN_DB_PREFIX."product as p";
$sql .= " WHERE e.rowid = ps.fk_entrepot AND ps.fk_product = p.rowid AND ps.fk_product = $key";
$sql .= " AND e.statut = 1 AND reel < $value";
$resql = $db->query($sql);
if ($resql)
{
$num = $db->num_rows($resql);
$i = 0;
$var=True;
while ($i < $num)
{
$obja = $db->fetch_object($resql);
print "<tr $bc[$var]>";
print '<td width="30%">';
print '<a href="'.DOL_URL_ROOT.'/product/fiche.php?id='.$objp->fk_product.'">'.img_object($langs->trans("ShowProduct"),"product").' '.$obja->ref.'</a> - '.$obja->label;
print '<td><a href="'.DOL_URL_ROOT.'/product/stock/fiche.php?id='.$obja->entrepot_id.'">'.$obja->entrepot.'</td>';
print '<td><b>Stock : '.$obja->reel.'</b>' .img_warning($langs->trans("Alert")).'</td>';
print "</tr>\n";
$i++;
}
$db->free($resql);
}
else {
dolibarr_print_error($db);
}
}
}
print "</table>";
}
/* /*
* Déjà livré * Déjà livré
*/ */
@ -534,13 +488,13 @@ if ($_GET["id"] > 0)
print '<table class="liste" width="100%">'; print '<table class="liste" width="100%">';
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
print '<td align="left">'.$langs->trans("Sending").'</td>'; print '<td align="left">'.$langs->trans("Sending").'</td>';
print '<td>'.$langs->trans("Product").'</td>';
print '<td align="center">'.$langs->trans("QtyShipped").'</td>';
print '<td align="center">'.$langs->trans("Date").'</td>';
if ($conf->livraison->enabled) if ($conf->livraison->enabled)
{ {
print '<td>'.$langs->trans("DeliveryOrder").'</td>'; print '<td>'.$langs->trans("DeliveryOrder").'</td>';
} }
print '<td>'.$langs->trans("Description").'</td>';
print '<td align="center">'.$langs->trans("QtyShipped").'</td>';
print '<td align="center">'.$langs->trans("Date").'</td>';
print "</tr>\n"; print "</tr>\n";
$var=True; $var=True;
@ -551,18 +505,6 @@ if ($_GET["id"] > 0)
print "<tr $bc[$var]>"; print "<tr $bc[$var]>";
print '<td align="left"><a href="'.DOL_URL_ROOT.'/expedition/fiche.php?id='.$objp->expedition_id.'">'.img_object($langs->trans("ShowSending"),'sending').' '.$objp->ref.'<a></td>'; print '<td align="left"><a href="'.DOL_URL_ROOT.'/expedition/fiche.php?id='.$objp->expedition_id.'">'.img_object($langs->trans("ShowSending"),'sending').' '.$objp->ref.'<a></td>';
if ($conf->livraison->enabled)
{
if ($objp->livraison_id)
{
print '<td><a href="'.DOL_URL_ROOT.'/livraison/fiche.php?id='.$objp->livraison_id.'">'.img_object($langs->trans("ShowSending"),'generic').' '.$objp->livraison_ref.'<a></td>';
}
else
{
print '<td><a href="'.DOL_URL_ROOT.'/expedition/fiche.php?id='.$objp->expedition_id.'&amp;action=create_delivery">'.$langs->trans("CreateDeliveryOrder").'<a></td>';
}
}
if ($objp->fk_product > 0) if ($objp->fk_product > 0)
{ {
$product = new Product($db); $product = new Product($db);
@ -579,6 +521,19 @@ if ($_GET["id"] > 0)
} }
print '<td align="center">'.$objp->qty_livre.'</td>'; print '<td align="center">'.$objp->qty_livre.'</td>';
print '<td align="center">'.dolibarr_print_date($objp->date_expedition).'</td>'; print '<td align="center">'.dolibarr_print_date($objp->date_expedition).'</td>';
if ($conf->livraison->enabled)
{
if ($objp->livraison_id)
{
print '<td><a href="'.DOL_URL_ROOT.'/livraison/fiche.php?id='.$objp->livraison_id.'">'.img_object($langs->trans("ShowSending"),'generic').' '.$objp->livraison_ref.'<a></td>';
}
else
{
print '<td><a href="'.DOL_URL_ROOT.'/expedition/fiche.php?id='.$objp->expedition_id.'&amp;action=create_delivery">'.$langs->trans("CreateDeliveryOrder").'<a></td>';
}
}
print '</tr>';
$i++; $i++;
} }

View File

@ -586,6 +586,26 @@ class Expedition extends CommonObject
} }
return $this->lignes; return $this->lignes;
} }
/**
* \brief Retourne le libellé du statut d'un entrepot (ouvert, fermé)
* \return string Libellé
*/
function getLibStatut()
{
return $this->LibStatut($this->statut);
}
/**
* \brief Renvoi le libellé d'un statut donné
* \param statut id statut
* \return string Libellé
*/
function LibStatut($statut)
{
return $this->statuts[$statut];
}
} }

View File

@ -40,6 +40,7 @@ $langs->load("companies");
$langs->load("bills"); $langs->load("bills");
$langs->load('deliveries'); $langs->load('deliveries');
$langs->load('orders'); $langs->load('orders');
$langs->load('stocks');
$user->getrights('expedition'); $user->getrights('expedition');
if (!$user->rights->expedition->lire) if (!$user->rights->expedition->lire)
@ -60,6 +61,8 @@ if ($user->societe_id > 0)
if ($_POST["action"] == 'add') if ($_POST["action"] == 'add')
{ {
// \todo Mettre id entrepot sur ligne detail expedition et non sur fiche expedition
$db->begin(); $db->begin();
// Creation de l'objet expedition // Creation de l'objet expedition
@ -125,7 +128,7 @@ if ($_POST["action"] == 'confirm_delete' && $_POST["confirm"] == 'yes')
if ($user->rights->expedition->supprimer ) if ($user->rights->expedition->supprimer )
{ {
$expedition = new Expedition($db); $expedition = new Expedition($db);
$expedition->fectch($_GET["id"]); $expedition->fetch($_GET["id"]);
$expedition->delete(); $expedition->delete();
Header("Location: liste.php"); Header("Location: liste.php");
} }
@ -192,7 +195,10 @@ if ($_GET["action"] == 'create')
print '<form action="fiche.php" method="post">'; print '<form action="fiche.php" method="post">';
print '<input type="hidden" name="action" value="add">'; print '<input type="hidden" name="action" value="add">';
print '<input type="hidden" name="commande_id" value="'.$commande->id.'">'; print '<input type="hidden" name="commande_id" value="'.$commande->id.'">';
if ($_GET["entrepot_id"])
{
print '<input type="hidden" name="entrepot_id" value="'.$_GET["entrepot_id"].'">'; print '<input type="hidden" name="entrepot_id" value="'.$_GET["entrepot_id"].'">';
}
print '<table class="border" width="100%">'; print '<table class="border" width="100%">';
@ -223,7 +229,7 @@ if ($_GET["action"] == 'create')
print '</td>'; print '</td>';
print '</tr>'; print '</tr>';
// Société // Sociét
print '<tr><td>'.$langs->trans('Company').'</td>'; print '<tr><td>'.$langs->trans('Company').'</td>';
print '<td colspan="3">'.$soc->getNomUrl(1).'</td>'; print '<td colspan="3">'.$soc->getNomUrl(1).'</td>';
print '</tr>'; print '</tr>';
@ -232,9 +238,8 @@ if ($_GET["action"] == 'create')
print "<tr><td>".$langs->trans("Date")."</td>"; print "<tr><td>".$langs->trans("Date")."</td>";
print '<td colspan="3">'.dolibarr_print_date($commande->date,"%A %d %B %Y")."</td></tr>\n"; print '<td colspan="3">'.dolibarr_print_date($commande->date,"%A %d %B %Y")."</td></tr>\n";
// Entrepot (si forcé)
if ($conf->stock->enabled && $_GET["entrepot_id"])
if ($conf->stock->enabled)
{ {
print '<tr><td>'.$langs->trans("Warehouse").'</td>'; print '<tr><td>'.$langs->trans("Warehouse").'</td>';
print '<td colspan="3">'; print '<td colspan="3">';
@ -245,7 +250,7 @@ if ($_GET["action"] == 'create')
if ($commande->note) if ($commande->note)
{ {
print '<tr><td colspan="3">Note : '.nl2br($commande->note)."</td></tr>"; print '<tr><td colspan="3">'.$langs->trans("NotePrivate").': '.nl2br($commande->note)."</td></tr>";
} }
print "</table>"; print "</table>";
@ -267,13 +272,20 @@ if ($_GET["action"] == 'create')
if ($num) if ($num)
{ {
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
print '<td width="54%">'.$langs->trans("Description").'</td>'; print '<td>'.$langs->trans("Description").'</td>';
print '<td align="center">Quan. commandée</td>'; print '<td align="center">'.$langs->trans("QtyOrdered").'</td>';
print '<td align="center">Quan. livrée</td>'; print '<td align="center">'.$langs->trans("QtyShipped").'</td>';
print '<td align="center">Quan. à livrer</td>'; print '<td align="center">'.$langs->trans("QtyToShip").'</td>';
if ($conf->stock->enabled) if ($conf->stock->enabled)
{ {
print '<td width="12%" align="center">'.$langs->trans("Stock").'</td>'; if ($_GET["entrepot_id"])
{
print '<td align="right">'.$langs->trans("Stock").'</td>';
}
else
{
print '<td align="left">'.$langs->trans("Warehouse").'</td>';
}
} }
print "</tr>\n"; print "</tr>\n";
} }
@ -299,9 +311,7 @@ if ($_GET["action"] == 'create')
} }
print '<td align="center">'.$ligne->qty.'</td>'; print '<td align="center">'.$ligne->qty.'</td>';
/*
*
*/
print '<td align="center">'; print '<td align="center">';
$quantite_livree = $commande->expeditions[$ligne->fk_product]; $quantite_livree = $commande->expeditions[$ligne->fk_product];
print $quantite_livree;; print $quantite_livree;;
@ -311,24 +321,63 @@ if ($_GET["action"] == 'create')
$quantite_a_livrer = $quantite_commandee - $quantite_livree; $quantite_a_livrer = $quantite_commandee - $quantite_livree;
if ($conf->stock->enabled) if ($conf->stock->enabled)
{
$defaultqty=0;
if ($_GET["entrepot_id"])
{ {
$stock = $product->stock_entrepot[$_GET["entrepot_id"]]; $stock = $product->stock_entrepot[$_GET["entrepot_id"]];
$stock+=0; // Convertit en numérique $stock+=0; // Convertit en numérique
$defaultqty=min($quantite_a_livrer, $stock);
}
// Quantité à livrer // Quantité à livrer
print '<td align="center">'; print '<td align="center">';
print '<input name="idl'.$i.'" type="hidden" value="'.$ligne->id.'">'; print '<input name="idl'.$i.'" type="hidden" value="'.$ligne->id.'">';
print '<input name="qtyl'.$i.'" type="text" size="6" value="'.min($quantite_a_livrer, $stock).'">'; print '<input name="qtyl'.$i.'" type="text" size="4" value="'.$defaultqty.'">';
print '</td>'; print '</td>';
// Stock // Stock
if ($_GET["entrepot_id"])
{
print '<td align="right">'.$stock;
if ($stock < $quantite_a_livrer) if ($stock < $quantite_a_livrer)
{ {
print '<td align="center" class="alerte">'.$stock.'</td>'; print ' '.img_warning($langs->trans("StockTooLow"));
}
print '</td>';
} }
else else
{ {
print '<td align="center">'.$stock.'</td>'; $array=array();
$sql = "SELECT e.rowid, e.label, ps.reel";
$sql.= " FROM ".MAIN_DB_PREFIX."product_stock as ps, ".MAIN_DB_PREFIX."entrepot as e";
$sql.= " WHERE ps.fk_entrepot = e.rowid AND fk_product = '".$product->id."'";
$result = $db->query($sql) ;
if ($result)
{
$num = $db->num_rows($result);
$i=0;
if ($num > 0)
{
while ($i < $num)
{
$obj = $db->fetch_object($result);
$array[$obj->rowid] = $obj->label.' ('.$obj->reel.')';
$i++;
}
}
$db->free($result);
}
else
{
$this->error=$db->error();
return -1;
}
print '<td align="left">';
$html->select_array('warehouse'.$i,$array,'',1,0,0);
print '</td>';
} }
} }
else else
@ -350,7 +399,7 @@ if ($_GET["action"] == 'create')
* *
*/ */
print '<tr><td align="center" colspan="4"><br><input type="submit" class="button" value="'.$langs->trans("Create").'"></td></tr>'; print '<tr><td align="center" colspan="5"><br><input type="submit" class="button" value="'.$langs->trans("Create").'"></td></tr>';
print "</table>"; print "</table>";
print '</form>'; print '</form>';
} }
@ -430,7 +479,7 @@ else
/* /*
* Commande * Commande
*/ */
if ($commande->brouillon == 1 && $user->rights->commande->creer) if ($commande->brouillon && $user->rights->commande->creer)
{ {
print '<form action="fiche.php?id='.$expedition->id.'" method="post">'; print '<form action="fiche.php?id='.$expedition->id.'" method="post">';
print '<input type="hidden" name="action" value="setremise">'; print '<input type="hidden" name="action" value="setremise">';
@ -462,6 +511,11 @@ else
print '<td colspan="3">'.dolibarr_print_date($expedition->date,"%A %d %B %Y")."</td>\n"; print '<td colspan="3">'.dolibarr_print_date($expedition->date,"%A %d %B %Y")."</td>\n";
print '</tr>'; print '</tr>';
// Statut
print '<tr><td>'.$langs->trans("Status").'</td>';
print '<td colspan="3">'.$expedition->getLibStatut()."</td>\n";
print '</tr>';
if (!$conf->expedition->enabled && $conf->stock->enabled) if (!$conf->expedition->enabled && $conf->stock->enabled)
{ {
// Entrepot // Entrepot
@ -480,9 +534,9 @@ else
echo '<br><table class="noborder" width="100%">'; echo '<br><table class="noborder" width="100%">';
$sql = "SELECT cd.fk_product, cd.description, cd.rowid, cd.qty as qty_commande,"; $sql = "SELECT cd.fk_product, cd.description, cd.rowid, cd.qty as qty_commande,";
$sql .= " ed.qty as qty_livre"; $sql .= " e.fk_statut, ed.qty as qty_livre";
$sql .= " FROM ".MAIN_DB_PREFIX."commandedet as cd , ".MAIN_DB_PREFIX."expeditiondet as ed"; $sql .= " FROM ".MAIN_DB_PREFIX."commandedet as cd , ".MAIN_DB_PREFIX."expeditiondet as ed, ".MAIN_DB_PREFIX."expedition as e";
$sql .= " WHERE ed.fk_expedition = ".$expedition->id." AND cd.rowid = ed.fk_commande_ligne "; $sql .= " WHERE e.rowid = ".$expedition->id." AND e.rowid = ed.fk_expedition AND cd.rowid = ed.fk_commande_ligne";
$resql = $db->query($sql); $resql = $db->query($sql);
@ -494,7 +548,14 @@ else
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
print '<td>'.$langs->trans("Products").'</td>'; print '<td>'.$langs->trans("Products").'</td>';
print '<td align="center">'.$langs->trans("QtyOrdered").'</td>'; print '<td align="center">'.$langs->trans("QtyOrdered").'</td>';
if ($obj->fk_statut <= 1)
{
print '<td align="center">'.$langs->trans("QtyToShip").'</td>';
}
else
{
print '<td align="center">'.$langs->trans("QtyShipped").'</td>'; print '<td align="center">'.$langs->trans("QtyShipped").'</td>';
}
print "</tr>\n"; print "</tr>\n";
$var=true; $var=true;
@ -578,12 +639,13 @@ else
$urlsource = $_SERVER["PHP_SELF"]."?id=".$expedition->id; $urlsource = $_SERVER["PHP_SELF"]."?id=".$expedition->id;
$genallowed=$user->rights->expedition->creer; $genallowed=$user->rights->expedition->creer && ($expedition->statut > 0);
$delallowed=$user->rights->expedition->supprimer; $delallowed=$user->rights->expedition->supprimer;
//$genallowed=1; //$genallowed=1;
//$delallowed=0; //$delallowed=0;
$somethingshown=$html->show_documents('expedition',$expeditionref,$filedir,$urlsource,$genallowed,$delallowed,$expedition->modelpdf); $somethingshown=$html->show_documents('expedition',$expeditionref,$filedir,$urlsource,$genallowed,$delallowed,$expedition->modelpdf);
if ($genallowed && ! $somethingshown) $somethingshown=1;
/* /*
* Déjà livre * Déjà livre
@ -608,14 +670,14 @@ else
if ($num) if ($num)
{ {
print '<br>'; if ($somethingshown) print '<br>';
print_titre($langs->trans("OtherSendingsForSameOrder")); print_titre($langs->trans("OtherSendingsForSameOrder"));
print '<table class="liste" width="100%">'; print '<table class="liste" width="100%">';
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
print '<td align="left">'.$langs->trans("Ref").'</td>'; print '<td align="left">'.$langs->trans("Ref").'</td>';
print '<td>'.$langs->trans("Description").'</td>'; print '<td>'.$langs->trans("Description").'</td>';
print '<td align="center">'.$langs->trans("QtyShipped").'</td>'; print '<td align="center">'.$langs->trans("Qty").'</td>';
print '<td align="center">'.$langs->trans("Date").'</td>'; print '<td align="center">'.$langs->trans("Date").'</td>';
print "</tr>\n"; print "</tr>\n";
@ -632,13 +694,13 @@ else
$product->fetch($objp->fk_product); $product->fetch($objp->fk_product);
print '<td>'; print '<td>';
print '<a href="'.DOL_URL_ROOT.'/product/fiche.php?id='.$objp->fk_product.'">'.img_object($langs->trans("ShowProduct"),"product").' '.$product->ref.'</a> - '.$product->libelle; print '<a href="'.DOL_URL_ROOT.'/product/fiche.php?id='.$objp->fk_product.'">'.img_object($langs->trans("ShowProduct"),"product").' '.$product->ref.'</a> - '.dolibarr_trunc($product->libelle,20);
if ($objp->description) print nl2br($objp->description); if ($objp->description) print nl2br(dolibarr_trunc($objp->description,24));
print '</td>'; print '</td>';
} }
else else
{ {
print "<td>".stripslashes(nl2br($objp->description))."</td>\n"; print "<td>".nl2br(dolibarr_trunc($objp->description,24))."</td>\n";
} }
print '<td align="center">'.$objp->qty_livre.'</td>'; print '<td align="center">'.$objp->qty_livre.'</td>';
print '<td align="center" nowrap="nowrap">'.dolibarr_print_date($objp->date_expedition).'</td>'; print '<td align="center" nowrap="nowrap">'.dolibarr_print_date($objp->date_expedition).'</td>';
@ -682,11 +744,12 @@ else
print '</td><td valign="top" width="50%">'; print '</td><td valign="top" width="50%">';
print_titre("Actions");
/* /*
* Liste des actions * Liste des actions
* *
*/ */
print_titre("Actions");
$sql = "SELECT ".$db->pdate("a.datea")." as da, a.note"; $sql = "SELECT ".$db->pdate("a.datea")." as da, a.note";
$sql .= " FROM ".MAIN_DB_PREFIX."actioncomm as a"; $sql .= " FROM ".MAIN_DB_PREFIX."actioncomm as a";
$sql .= " WHERE a.fk_soc = ".$commande->socidp." AND a.fk_action in (9,10)"; $sql .= " WHERE a.fk_soc = ".$commande->socidp." AND a.fk_action in (9,10)";

View File

@ -2162,7 +2162,7 @@ class Form
\param htmlname Nom de la zone select \param htmlname Nom de la zone select
\param array Tableau de key+valeur \param array Tableau de key+valeur
\param id Key pré-sélectionnée \param id Key pré-sélectionnée
\param show_empty 1 si il faut ajouter une valeur " " dans la liste, 0 sinon \param show_empty 1 si il faut ajouter une valeur vide dans la liste, 0 sinon
\param key_in_label 1 pour afficher la key dans la valeur "[key] value" \param key_in_label 1 pour afficher la key dans la valeur "[key] value"
\param value_as_key 1 pour utiliser la valeur comme clé \param value_as_key 1 pour utiliser la valeur comme clé
*/ */

View File

@ -16,6 +16,7 @@ CreateSending=Create sending
QtyOrdered=Qty ordered QtyOrdered=Qty ordered
QtyShipped=Qty shipped QtyShipped=Qty shipped
QtyReceived=Qty received QtyReceived=Qty received
QtyToShip=Qty to ship
KeepToShip=Keep to ship KeepToShip=Keep to ship
OtherSendingsForSameOrder=Other sendings already shipped OtherSendingsForSameOrder=Other sendings already shipped
SendingsToValidate=Sending to validate SendingsToValidate=Sending to validate

View File

@ -25,3 +25,4 @@ StockCorrection=Stock correction
StockMovement=Transfer StockMovement=Transfer
NumberOfUnit=Number of units NumberOfUnit=Number of units
TotalStock=Total in stock TotalStock=Total in stock
StockTooLow=Stock too low

View File

@ -15,6 +15,7 @@ CreateASending=Cr
CreateSending=Créer expedition CreateSending=Créer expedition
QtyOrdered=Qté commandée QtyOrdered=Qté commandée
QtyShipped=Qté expédiée QtyShipped=Qté expédiée
QtyToShip=Qté à expédier
QtyReceived=Qté reçue QtyReceived=Qté reçue
KeepToShip=Reste à expédier KeepToShip=Reste à expédier
OtherSendingsForSameOrder=Autres expéditions déjà envoyés OtherSendingsForSameOrder=Autres expéditions déjà envoyés

View File

@ -25,3 +25,4 @@ StockCorrection=Correction stock
StockMovement=Transfert StockMovement=Transfert
NumberOfUnit=Nombre de pièces NumberOfUnit=Nombre de pièces
TotalStock=Total en stock TotalStock=Total en stock
StockTooLow=Stock insuffisant

View File

@ -874,38 +874,9 @@ class Product
} }
$sql = "SELECT reel, fk_entrepot"; $res=$this->load_stock();
$sql .= " FROM ".MAIN_DB_PREFIX."product_stock WHERE fk_product = '".$this->id."'";
$result = $this->db->query($sql) ;
if ($result)
{
$num = $this->db->num_rows($result);
$i=0;
if ($num > 0)
{
while ($i < $num )
{
$row = $this->db->fetch_row($result);
$this->stock_entrepot[$row[1]] = $row[0];
$this->stock_reel = $this->stock_reel + $row[0]; return $res;
$i++;
}
$this->no_stock = 0;
}
else
{
$this->no_stock = 1;
}
$this->db->free($result);
return 1;
}
else
{
$this->error=$this->db->error();
return -2;
}
} }
else else
{ {
@ -1825,7 +1796,6 @@ function get_each_prod()
* \param nbpiece nombre de pieces * \param nbpiece nombre de pieces
* \param mouvement 0 = ajout, 1 = suppression * \param mouvement 0 = ajout, 1 = suppression
*/ */
function ajust_stock($user, $id_entrepot, $nbpiece, $mouvement) function ajust_stock($user, $id_entrepot, $nbpiece, $mouvement)
{ {
$op[0] = "+" . trim($nbpiece); $op[0] = "+" . trim($nbpiece);
@ -1877,6 +1847,45 @@ function get_each_prod()
} }
} }
/**
* \brief Charge les informations en stock du produit
* \return int < 0 si erreur, > 0 si ok
*/
function load_stock()
{
$sql = "SELECT reel, fk_entrepot";
$sql.= " FROM ".MAIN_DB_PREFIX."product_stock";
$sql.= " WHERE fk_product = '".$this->id."'";
$result = $this->db->query($sql) ;
if ($result)
{
$num = $this->db->num_rows($result);
$i=0;
if ($num > 0)
{
while ($i < $num )
{
$row = $this->db->fetch_row($result);
$this->stock_entrepot[$row[1]] = $row[0];
$this->stock_reel = $this->stock_reel + $row[0];
$i++;
}
$this->no_stock = 0;
}
else
{
$this->no_stock = 1;
}
$this->db->free($result);
return 1;
}
else
{
$this->error=$this->db->error();
return -1;
}
}
/** /**
* \brief Charge les informations relatives à un fournisseur * \brief Charge les informations relatives à un fournisseur

View File

@ -18,7 +18,6 @@
* *
* $Id$ * $Id$
* $Source$ * $Source$
*
*/ */
/** /**