Quelques amliorations diverses sur gestion des xpditions
This commit is contained in:
parent
4db870e577
commit
7facc82362
@ -1035,7 +1035,7 @@ class Commande extends CommonObject
|
||||
*/
|
||||
function expedition_array($filtre_statut=-1)
|
||||
{
|
||||
$this->livraisons = array();
|
||||
$this->expeditions = array();
|
||||
$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.=' WHERE ed.fk_expedition = e.rowid AND ed.fk_commande_ligne = cd .rowid AND cd.fk_commande = c.rowid';
|
||||
@ -1059,14 +1059,14 @@ class Commande extends CommonObject
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Renvoie un tableau avec les expeditions par ligne
|
||||
*
|
||||
*/
|
||||
/**
|
||||
* Renvoie un tableau avec nombre de lignes d'expeditions
|
||||
*
|
||||
*/
|
||||
function nb_expedition()
|
||||
{
|
||||
$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);
|
||||
if ($result)
|
||||
@ -1076,7 +1076,7 @@ class Commande extends CommonObject
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* \brief Renvoie un tableau avec les livraisons par ligne
|
||||
* \param filtre_statut Filtre sur statut
|
||||
* \return int 0 si OK, <0 si KO
|
||||
@ -1107,11 +1107,48 @@ class Commande extends CommonObject
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Supprime une ligne de la commande
|
||||
* \param idligne Id de la ligne à supprimer
|
||||
* \return int >0 si ok, <0 si ko
|
||||
*/
|
||||
/**
|
||||
* \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
|
||||
* \param idligne Id de la ligne à supprimer
|
||||
* \return int >0 si ok, <0 si ko
|
||||
*/
|
||||
function delete_line($idligne)
|
||||
{
|
||||
if ($this->statut == 0)
|
||||
|
||||
@ -41,6 +41,7 @@ $langs->load("companies");
|
||||
$langs->load("bills");
|
||||
$langs->load('propal');
|
||||
$langs->load('deliveries');
|
||||
$langs->load('stocks');
|
||||
|
||||
$user->getrights('commande');
|
||||
$user->getrights('expedition');
|
||||
@ -300,7 +301,7 @@ if ($_GET["id"] > 0)
|
||||
|
||||
/**
|
||||
* 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%">';
|
||||
|
||||
@ -352,7 +353,7 @@ if ($_GET["id"] > 0)
|
||||
}
|
||||
else
|
||||
{
|
||||
print "<td>".stripslashes(nl2br($objp->description))."</td>\n";
|
||||
print "<td>".nl2br($objp->description)."</td>\n";
|
||||
}
|
||||
|
||||
print '<td align="center">'.$objp->qty.'</td>';
|
||||
@ -363,22 +364,20 @@ if ($_GET["id"] > 0)
|
||||
print '</td>';
|
||||
|
||||
$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_x;
|
||||
$reste_a_livrer_total = $reste_a_livrer_total + $reste_a_livrer[$objp->fk_product];
|
||||
print '<td align="center">';
|
||||
print $reste_a_livrer[$objp->fk_product];
|
||||
print '</td>';
|
||||
|
||||
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>';
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<td align="center">'.$product->stock_reel.'</td>';
|
||||
print ' '.img_warning($langs->trans("StockTooLow"));
|
||||
}
|
||||
print '</td>';
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -459,51 +458,6 @@ if ($_GET["id"] > 0)
|
||||
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é
|
||||
*/
|
||||
@ -534,13 +488,13 @@ if ($_GET["id"] > 0)
|
||||
print '<table class="liste" width="100%">';
|
||||
print '<tr class="liste_titre">';
|
||||
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)
|
||||
{
|
||||
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";
|
||||
|
||||
$var=True;
|
||||
@ -551,18 +505,6 @@ if ($_GET["id"] > 0)
|
||||
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>';
|
||||
|
||||
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.'&action=create_delivery">'.$langs->trans("CreateDeliveryOrder").'<a></td>';
|
||||
}
|
||||
}
|
||||
|
||||
if ($objp->fk_product > 0)
|
||||
{
|
||||
$product = new Product($db);
|
||||
@ -579,6 +521,19 @@ if ($_GET["id"] > 0)
|
||||
}
|
||||
print '<td align="center">'.$objp->qty_livre.'</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.'&action=create_delivery">'.$langs->trans("CreateDeliveryOrder").'<a></td>';
|
||||
}
|
||||
}
|
||||
print '</tr>';
|
||||
|
||||
$i++;
|
||||
}
|
||||
|
||||
|
||||
@ -586,6 +586,26 @@ class Expedition extends CommonObject
|
||||
}
|
||||
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];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -40,6 +40,7 @@ $langs->load("companies");
|
||||
$langs->load("bills");
|
||||
$langs->load('deliveries');
|
||||
$langs->load('orders');
|
||||
$langs->load('stocks');
|
||||
|
||||
$user->getrights('expedition');
|
||||
if (!$user->rights->expedition->lire)
|
||||
@ -60,6 +61,8 @@ if ($user->societe_id > 0)
|
||||
|
||||
if ($_POST["action"] == 'add')
|
||||
{
|
||||
// \todo Mettre id entrepot sur ligne detail expedition et non sur fiche expedition
|
||||
|
||||
$db->begin();
|
||||
|
||||
// Creation de l'objet expedition
|
||||
@ -125,7 +128,7 @@ if ($_POST["action"] == 'confirm_delete' && $_POST["confirm"] == 'yes')
|
||||
if ($user->rights->expedition->supprimer )
|
||||
{
|
||||
$expedition = new Expedition($db);
|
||||
$expedition->fectch($_GET["id"]);
|
||||
$expedition->fetch($_GET["id"]);
|
||||
$expedition->delete();
|
||||
Header("Location: liste.php");
|
||||
}
|
||||
@ -166,48 +169,51 @@ $html = new Form($db);
|
||||
if ($_GET["action"] == 'create')
|
||||
{
|
||||
|
||||
print_titre($langs->trans("CreateASending"));
|
||||
print_titre($langs->trans("CreateASending"));
|
||||
|
||||
if ($mesg)
|
||||
{
|
||||
print $mesg.'<br>';
|
||||
}
|
||||
|
||||
$commande = new Commande($db);
|
||||
$commande->expedition_array();
|
||||
|
||||
if ( $commande->fetch($_GET["commande_id"]))
|
||||
{
|
||||
$soc = new Societe($db);
|
||||
$soc->fetch($commande->socidp);
|
||||
$author = new User($db);
|
||||
$author->id = $commande->user_author_id;
|
||||
$author->fetch();
|
||||
|
||||
$entrepot = new Entrepot($db);
|
||||
if ($mesg)
|
||||
{
|
||||
print $mesg.'<br>';
|
||||
}
|
||||
|
||||
/*
|
||||
* Commande
|
||||
*/
|
||||
print '<form action="fiche.php" method="post">';
|
||||
print '<input type="hidden" name="action" value="add">';
|
||||
print '<input type="hidden" name="commande_id" value="'.$commande->id.'">';
|
||||
print '<input type="hidden" name="entrepot_id" value="'.$_GET["entrepot_id"].'">';
|
||||
$commande = new Commande($db);
|
||||
$commande->expedition_array();
|
||||
|
||||
print '<table class="border" width="100%">';
|
||||
if ( $commande->fetch($_GET["commande_id"]))
|
||||
{
|
||||
$soc = new Societe($db);
|
||||
$soc->fetch($commande->socidp);
|
||||
$author = new User($db);
|
||||
$author->id = $commande->user_author_id;
|
||||
$author->fetch();
|
||||
|
||||
// Ref commande
|
||||
print '<tr><td>'.$langs->trans("RefOrder").'</td><td colspan="3"><a href="'.DOL_URL_ROOT.'/commande/fiche.php?id='.$commande->id.'">'.img_object($langs->trans("ShowOrder"),'order').' '.$commande->ref.'</a></td>';
|
||||
print "</tr>\n";
|
||||
$entrepot = new Entrepot($db);
|
||||
|
||||
/*
|
||||
* Commande
|
||||
*/
|
||||
print '<form action="fiche.php" method="post">';
|
||||
print '<input type="hidden" name="action" value="add">';
|
||||
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 '<table class="border" width="100%">';
|
||||
|
||||
// Ref commande
|
||||
print '<tr><td>'.$langs->trans("RefOrder").'</td><td colspan="3"><a href="'.DOL_URL_ROOT.'/commande/fiche.php?id='.$commande->id.'">'.img_object($langs->trans("ShowOrder"),'order').' '.$commande->ref.'</a></td>';
|
||||
print "</tr>\n";
|
||||
|
||||
// Ref commande client
|
||||
print '<tr><td>';
|
||||
print '<table class="nobordernopadding" width="100%"><tr><td nowrap>';
|
||||
print '<table class="nobordernopadding" width="100%"><tr><td nowrap>';
|
||||
print $langs->trans('RefCustomerOrderShort').'</td><td align="left">';
|
||||
print '</td>';
|
||||
if ($_GET['action'] != 'refcdeclient' && $commande->brouillon) print '<td align="right"><a href="'.$_SERVER['PHP_SELF'].'?action=refcdeclient&id='.$commande->id.'">'.img_edit($langs->trans('Edit')).'</a></td>';
|
||||
print '</tr></table>';
|
||||
print '</td><td colspan="3">';
|
||||
print '</td>';
|
||||
if ($_GET['action'] != 'refcdeclient' && $commande->brouillon) print '<td align="right"><a href="'.$_SERVER['PHP_SELF'].'?action=refcdeclient&id='.$commande->id.'">'.img_edit($langs->trans('Edit')).'</a></td>';
|
||||
print '</tr></table>';
|
||||
print '</td><td colspan="3">';
|
||||
if ($user->rights->commande->creer && $_GET['action'] == 'refcdeclient')
|
||||
{
|
||||
print '<form action="fiche.php?id='.$id.'" method="post">';
|
||||
@ -222,143 +228,186 @@ if ($_GET["action"] == 'create')
|
||||
}
|
||||
print '</td>';
|
||||
print '</tr>';
|
||||
|
||||
// Société
|
||||
|
||||
// Sociét
|
||||
print '<tr><td>'.$langs->trans('Company').'</td>';
|
||||
print '<td colspan="3">'.$soc->getNomUrl(1).'</td>';
|
||||
print '</tr>';
|
||||
|
||||
|
||||
// Date
|
||||
print "<tr><td>".$langs->trans("Date")."</td>";
|
||||
print '<td colspan="3">'.dolibarr_print_date($commande->date,"%A %d %B %Y")."</td></tr>\n";
|
||||
|
||||
|
||||
|
||||
if ($conf->stock->enabled)
|
||||
{
|
||||
|
||||
// Entrepot (si forcé)
|
||||
if ($conf->stock->enabled && $_GET["entrepot_id"])
|
||||
{
|
||||
print '<tr><td>'.$langs->trans("Warehouse").'</td>';
|
||||
print '<td colspan="3">';
|
||||
$ents = $entrepot->list_array();
|
||||
print '<a href="'.DOL_URL_ROOT.'/product/stock/fiche.php?id='.$_GET["entrepot_id"].'">'.img_object($langs->trans("ShowWarehouse"),'stock').' '.$ents[$_GET["entrepot_id"]].'</a>';
|
||||
print '</td></tr>';
|
||||
}
|
||||
|
||||
|
||||
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>";
|
||||
|
||||
/*
|
||||
* Lignes de commandes
|
||||
*
|
||||
*/
|
||||
echo '<br><table class="noborder" width="100%">';
|
||||
|
||||
$lignes = $commande->fetch_lignes(1);
|
||||
|
||||
/* Lecture des expeditions déjà effectuées */
|
||||
$commande->expedition_array();
|
||||
|
||||
$num = sizeof($commande->lignes);
|
||||
$i = 0;
|
||||
|
||||
if ($num)
|
||||
{
|
||||
print '<tr class="liste_titre">';
|
||||
print '<td width="54%">'.$langs->trans("Description").'</td>';
|
||||
print '<td align="center">Quan. commandée</td>';
|
||||
print '<td align="center">Quan. livrée</td>';
|
||||
print '<td align="center">Quan. à livrer</td>';
|
||||
if ($conf->stock->enabled)
|
||||
{
|
||||
print '<td width="12%" align="center">'.$langs->trans("Stock").'</td>';
|
||||
}
|
||||
print "</tr>\n";
|
||||
|
||||
/*
|
||||
* Lignes de commandes
|
||||
*
|
||||
*/
|
||||
echo '<br><table class="noborder" width="100%">';
|
||||
|
||||
$lignes = $commande->fetch_lignes(1);
|
||||
|
||||
/* Lecture des expeditions déjà effectuées */
|
||||
$commande->expedition_array();
|
||||
|
||||
$num = sizeof($commande->lignes);
|
||||
$i = 0;
|
||||
|
||||
if ($num)
|
||||
{
|
||||
print '<tr class="liste_titre">';
|
||||
print '<td>'.$langs->trans("Description").'</td>';
|
||||
print '<td align="center">'.$langs->trans("QtyOrdered").'</td>';
|
||||
print '<td align="center">'.$langs->trans("QtyShipped").'</td>';
|
||||
print '<td align="center">'.$langs->trans("QtyToShip").'</td>';
|
||||
if ($conf->stock->enabled)
|
||||
{
|
||||
if ($_GET["entrepot_id"])
|
||||
{
|
||||
print '<td align="right">'.$langs->trans("Stock").'</td>';
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<td align="left">'.$langs->trans("Warehouse").'</td>';
|
||||
}
|
||||
}
|
||||
print "</tr>\n";
|
||||
}
|
||||
$var=true;
|
||||
while ($i < $num)
|
||||
{
|
||||
$ligne = $commande->lignes[$i];
|
||||
$var=!$var;
|
||||
print "<tr $bc[$var]>\n";
|
||||
if ($ligne->fk_product > 0)
|
||||
{
|
||||
$product = new Product($db);
|
||||
$product->fetch($ligne->fk_product);
|
||||
|
||||
print '<td>';
|
||||
print '<a href="'.DOL_URL_ROOT.'/product/fiche.php?id='.$ligne->fk_product.'">'.img_object($langs->trans("ShowProduct"),"product").' '.$product->ref.'</a> - '.$product->libelle;
|
||||
if ($ligne->description) print nl2br($ligne->description);
|
||||
print '</td>';
|
||||
}
|
||||
else
|
||||
{
|
||||
print "<td>".nl2br($ligne->description)."</td>\n";
|
||||
}
|
||||
|
||||
print '<td align="center">'.$ligne->qty.'</td>';
|
||||
|
||||
print '<td align="center">';
|
||||
$quantite_livree = $commande->expeditions[$ligne->fk_product];
|
||||
print $quantite_livree;;
|
||||
print '</td>';
|
||||
|
||||
$quantite_commandee = $ligne->qty;
|
||||
$quantite_a_livrer = $quantite_commandee - $quantite_livree;
|
||||
|
||||
if ($conf->stock->enabled)
|
||||
{
|
||||
$defaultqty=0;
|
||||
if ($_GET["entrepot_id"])
|
||||
{
|
||||
$stock = $product->stock_entrepot[$_GET["entrepot_id"]];
|
||||
$stock+=0; // Convertit en numérique
|
||||
$defaultqty=min($quantite_a_livrer, $stock);
|
||||
}
|
||||
|
||||
// Quantité à livrer
|
||||
print '<td align="center">';
|
||||
print '<input name="idl'.$i.'" type="hidden" value="'.$ligne->id.'">';
|
||||
print '<input name="qtyl'.$i.'" type="text" size="4" value="'.$defaultqty.'">';
|
||||
print '</td>';
|
||||
|
||||
// Stock
|
||||
if ($_GET["entrepot_id"])
|
||||
{
|
||||
print '<td align="right">'.$stock;
|
||||
if ($stock < $quantite_a_livrer)
|
||||
{
|
||||
print ' '.img_warning($langs->trans("StockTooLow"));
|
||||
}
|
||||
print '</td>';
|
||||
}
|
||||
else
|
||||
{
|
||||
$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
|
||||
{
|
||||
// Quantité à livrer
|
||||
print '<td align="center">';
|
||||
print '<input name="idl'.$i.'" type="hidden" value="'.$ligne->id.'">';
|
||||
print '<input name="qtyl'.$i.'" type="text" size="6" value="'.$quantite_a_livrer.'">';
|
||||
print '</td>';
|
||||
}
|
||||
|
||||
print "</tr>\n";
|
||||
|
||||
$i++;
|
||||
$var=!$var;
|
||||
}
|
||||
|
||||
/*
|
||||
*
|
||||
*/
|
||||
|
||||
print '<tr><td align="center" colspan="5"><br><input type="submit" class="button" value="'.$langs->trans("Create").'"></td></tr>';
|
||||
print "</table>";
|
||||
print '</form>';
|
||||
}
|
||||
$var=true;
|
||||
while ($i < $num)
|
||||
else
|
||||
{
|
||||
$ligne = $commande->lignes[$i];
|
||||
$var=!$var;
|
||||
print "<tr $bc[$var]>\n";
|
||||
if ($ligne->fk_product > 0)
|
||||
{
|
||||
$product = new Product($db);
|
||||
$product->fetch($ligne->fk_product);
|
||||
|
||||
print '<td>';
|
||||
print '<a href="'.DOL_URL_ROOT.'/product/fiche.php?id='.$ligne->fk_product.'">'.img_object($langs->trans("ShowProduct"),"product").' '.$product->ref.'</a> - '.$product->libelle;
|
||||
if ($ligne->description) print nl2br($ligne->description);
|
||||
print '</td>';
|
||||
}
|
||||
else
|
||||
{
|
||||
print "<td>".nl2br($ligne->description)."</td>\n";
|
||||
}
|
||||
|
||||
print '<td align="center">'.$ligne->qty.'</td>';
|
||||
/*
|
||||
*
|
||||
*/
|
||||
print '<td align="center">';
|
||||
$quantite_livree = $commande->expeditions[$ligne->fk_product];
|
||||
print $quantite_livree;;
|
||||
print '</td>';
|
||||
|
||||
$quantite_commandee = $ligne->qty;
|
||||
$quantite_a_livrer = $quantite_commandee - $quantite_livree;
|
||||
|
||||
if ($conf->stock->enabled)
|
||||
{
|
||||
$stock = $product->stock_entrepot[$_GET["entrepot_id"]];
|
||||
$stock+=0; // Convertit en numérique
|
||||
|
||||
// Quantité à livrer
|
||||
print '<td align="center">';
|
||||
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 '</td>';
|
||||
|
||||
// Stock
|
||||
if ($stock < $quantite_a_livrer)
|
||||
{
|
||||
print '<td align="center" class="alerte">'.$stock.'</td>';
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<td align="center">'.$stock.'</td>';
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Quantité à livrer
|
||||
print '<td align="center">';
|
||||
print '<input name="idl'.$i.'" type="hidden" value="'.$ligne->id.'">';
|
||||
print '<input name="qtyl'.$i.'" type="text" size="6" value="'.$quantite_a_livrer.'">';
|
||||
print '</td>';
|
||||
}
|
||||
|
||||
print "</tr>\n";
|
||||
|
||||
$i++;
|
||||
$var=!$var;
|
||||
}
|
||||
|
||||
/*
|
||||
*
|
||||
*/
|
||||
|
||||
print '<tr><td align="center" colspan="4"><br><input type="submit" class="button" value="'.$langs->trans("Create").'"></td></tr>';
|
||||
print "</table>";
|
||||
print '</form>';
|
||||
}
|
||||
else
|
||||
{
|
||||
dolibarr_print_error($db);
|
||||
}
|
||||
}
|
||||
dolibarr_print_error($db);
|
||||
}
|
||||
}
|
||||
else
|
||||
/* *************************************************************************** */
|
||||
/* */
|
||||
@ -430,7 +479,7 @@ else
|
||||
/*
|
||||
* 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 '<input type="hidden" name="action" value="setremise">';
|
||||
@ -461,6 +510,11 @@ else
|
||||
print '<tr><td>'.$langs->trans("Date").'</td>';
|
||||
print '<td colspan="3">'.dolibarr_print_date($expedition->date,"%A %d %B %Y")."</td>\n";
|
||||
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)
|
||||
{
|
||||
@ -480,9 +534,9 @@ else
|
||||
echo '<br><table class="noborder" width="100%">';
|
||||
|
||||
$sql = "SELECT cd.fk_product, cd.description, cd.rowid, cd.qty as qty_commande,";
|
||||
$sql .= " ed.qty as qty_livre";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."commandedet as cd , ".MAIN_DB_PREFIX."expeditiondet as ed";
|
||||
$sql .= " WHERE ed.fk_expedition = ".$expedition->id." AND cd.rowid = ed.fk_commande_ligne ";
|
||||
$sql .= " e.fk_statut, ed.qty as qty_livre";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."commandedet as cd , ".MAIN_DB_PREFIX."expeditiondet as ed, ".MAIN_DB_PREFIX."expedition as e";
|
||||
$sql .= " WHERE e.rowid = ".$expedition->id." AND e.rowid = ed.fk_expedition AND cd.rowid = ed.fk_commande_ligne";
|
||||
|
||||
$resql = $db->query($sql);
|
||||
|
||||
@ -494,7 +548,14 @@ else
|
||||
print '<tr class="liste_titre">';
|
||||
print '<td>'.$langs->trans("Products").'</td>';
|
||||
print '<td align="center">'.$langs->trans("QtyOrdered").'</td>';
|
||||
print '<td align="center">'.$langs->trans("QtyShipped").'</td>';
|
||||
if ($obj->fk_statut <= 1)
|
||||
{
|
||||
print '<td align="center">'.$langs->trans("QtyToShip").'</td>';
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<td align="center">'.$langs->trans("QtyShipped").'</td>';
|
||||
}
|
||||
print "</tr>\n";
|
||||
|
||||
$var=true;
|
||||
@ -578,13 +639,14 @@ else
|
||||
|
||||
$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;
|
||||
//$genallowed=1;
|
||||
//$delallowed=0;
|
||||
|
||||
$somethingshown=$html->show_documents('expedition',$expeditionref,$filedir,$urlsource,$genallowed,$delallowed,$expedition->modelpdf);
|
||||
|
||||
if ($genallowed && ! $somethingshown) $somethingshown=1;
|
||||
|
||||
/*
|
||||
* Déjà livre
|
||||
*/
|
||||
@ -608,14 +670,14 @@ else
|
||||
|
||||
if ($num)
|
||||
{
|
||||
print '<br>';
|
||||
if ($somethingshown) print '<br>';
|
||||
|
||||
print_titre($langs->trans("OtherSendingsForSameOrder"));
|
||||
print '<table class="liste" width="100%">';
|
||||
print '<tr class="liste_titre">';
|
||||
print '<td align="left">'.$langs->trans("Ref").'</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 "</tr>\n";
|
||||
|
||||
@ -632,13 +694,13 @@ else
|
||||
$product->fetch($objp->fk_product);
|
||||
|
||||
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;
|
||||
if ($objp->description) print nl2br($objp->description);
|
||||
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(dolibarr_trunc($objp->description,24));
|
||||
print '</td>';
|
||||
}
|
||||
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" nowrap="nowrap">'.dolibarr_print_date($objp->date_expedition).'</td>';
|
||||
@ -682,11 +744,12 @@ else
|
||||
print '</td><td valign="top" width="50%">';
|
||||
|
||||
|
||||
print_titre("Actions");
|
||||
/*
|
||||
* Liste des actions
|
||||
*
|
||||
*/
|
||||
print_titre("Actions");
|
||||
|
||||
$sql = "SELECT ".$db->pdate("a.datea")." as da, a.note";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."actioncomm as a";
|
||||
$sql .= " WHERE a.fk_soc = ".$commande->socidp." AND a.fk_action in (9,10)";
|
||||
|
||||
@ -2162,7 +2162,7 @@ class Form
|
||||
\param htmlname Nom de la zone select
|
||||
\param array Tableau de key+valeur
|
||||
\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 value_as_key 1 pour utiliser la valeur comme clé
|
||||
*/
|
||||
|
||||
@ -16,6 +16,7 @@ CreateSending=Create sending
|
||||
QtyOrdered=Qty ordered
|
||||
QtyShipped=Qty shipped
|
||||
QtyReceived=Qty received
|
||||
QtyToShip=Qty to ship
|
||||
KeepToShip=Keep to ship
|
||||
OtherSendingsForSameOrder=Other sendings already shipped
|
||||
SendingsToValidate=Sending to validate
|
||||
@ -24,4 +24,5 @@ Units=Units
|
||||
StockCorrection=Stock correction
|
||||
StockMovement=Transfer
|
||||
NumberOfUnit=Number of units
|
||||
TotalStock=Total in stock
|
||||
TotalStock=Total in stock
|
||||
StockTooLow=Stock too low
|
||||
@ -15,6 +15,7 @@ CreateASending=Cr
|
||||
CreateSending=Créer expedition
|
||||
QtyOrdered=Qté commandée
|
||||
QtyShipped=Qté expédiée
|
||||
QtyToShip=Qté à expédier
|
||||
QtyReceived=Qté reçue
|
||||
KeepToShip=Reste à expédier
|
||||
OtherSendingsForSameOrder=Autres expéditions déjà envoyés
|
||||
|
||||
@ -24,4 +24,5 @@ Units=Unit
|
||||
StockCorrection=Correction stock
|
||||
StockMovement=Transfert
|
||||
NumberOfUnit=Nombre de pièces
|
||||
TotalStock=Total en stock
|
||||
TotalStock=Total en stock
|
||||
StockTooLow=Stock insuffisant
|
||||
@ -769,150 +769,121 @@ class Product
|
||||
* \param ref Ref du produit/service à charger
|
||||
* \return int <0 si ko, >0 si ok
|
||||
*/
|
||||
function fetch($id='',$ref='')
|
||||
{
|
||||
global $langs;
|
||||
function fetch($id='',$ref='')
|
||||
{
|
||||
global $langs;
|
||||
global $conf;
|
||||
|
||||
|
||||
dolibarr_syslog("Product::fetch id=$id ref=$ref");
|
||||
|
||||
// Verification parametres
|
||||
if (! $id && ! $ref)
|
||||
{
|
||||
$this->error=$langs->trans('ErrorWrongParameters');
|
||||
|
||||
// Verification parametres
|
||||
if (! $id && ! $ref)
|
||||
{
|
||||
$this->error=$langs->trans('ErrorWrongParameters');
|
||||
dolibarr_print_error("Product::fetch ".$this->error);
|
||||
return -1;
|
||||
}
|
||||
|
||||
$sql = "SELECT rowid, ref, label, description, note, price, tva_tx, envente,";
|
||||
$sql.= " nbvente, fk_product_type, duration, seuil_stock_alerte";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."product";
|
||||
if ($id) $sql.= " WHERE rowid = '".$id."'";
|
||||
if ($ref) $sql.= " WHERE ref = '".addslashes($ref)."'";
|
||||
|
||||
$result = $this->db->query($sql) ;
|
||||
if ( $result )
|
||||
{
|
||||
$result = $this->db->fetch_array();
|
||||
|
||||
$this->id = $result["rowid"];
|
||||
$this->ref = $result["ref"];
|
||||
$this->libelle = stripslashes($result["label"]);
|
||||
$this->description = stripslashes($result["description"]);
|
||||
$this->note = stripslashes($result["note"]);
|
||||
$this->price = $result["price"];
|
||||
$this->tva_tx = $result["tva_tx"];
|
||||
$this->type = $result["fk_product_type"];
|
||||
$this->nbvente = $result["nbvente"];
|
||||
$this->status = $result["envente"];
|
||||
$this->duration = $result["duration"];
|
||||
$this->duration_value = substr($result["duration"],0,strlen($result["duration"])-1);
|
||||
$this->duration_unit = substr($result["duration"],-1);
|
||||
$this->seuil_stock_alerte = $result["seuil_stock_alerte"];
|
||||
|
||||
$this->label_url = '<a href="'.DOL_URL_ROOT.'/product/fiche.php?id='.$this->id.'">'.$this->libelle.'</a>';
|
||||
|
||||
if ($this->type == 0)
|
||||
{
|
||||
$this->isproduct = 1;
|
||||
$this->isservice = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->isproduct = 0;
|
||||
$this->isservice = 1;
|
||||
}
|
||||
|
||||
$this->db->free();
|
||||
return -1;
|
||||
}
|
||||
|
||||
$sql = "SELECT rowid, ref, label, description, note, price, tva_tx, envente,";
|
||||
$sql.= " nbvente, fk_product_type, duration, seuil_stock_alerte";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."product";
|
||||
if ($id) $sql.= " WHERE rowid = '".$id."'";
|
||||
if ($ref) $sql.= " WHERE ref = '".addslashes($ref)."'";
|
||||
|
||||
$result = $this->db->query($sql) ;
|
||||
if ( $result )
|
||||
{
|
||||
$result = $this->db->fetch_array();
|
||||
|
||||
$this->id = $result["rowid"];
|
||||
$this->ref = $result["ref"];
|
||||
$this->libelle = stripslashes($result["label"]);
|
||||
$this->description = stripslashes($result["description"]);
|
||||
$this->note = stripslashes($result["note"]);
|
||||
$this->price = $result["price"];
|
||||
$this->tva_tx = $result["tva_tx"];
|
||||
$this->type = $result["fk_product_type"];
|
||||
$this->nbvente = $result["nbvente"];
|
||||
$this->status = $result["envente"];
|
||||
$this->duration = $result["duration"];
|
||||
$this->duration_value = substr($result["duration"],0,strlen($result["duration"])-1);
|
||||
$this->duration_unit = substr($result["duration"],-1);
|
||||
$this->seuil_stock_alerte = $result["seuil_stock_alerte"];
|
||||
|
||||
$this->label_url = '<a href="'.DOL_URL_ROOT.'/product/fiche.php?id='.$this->id.'">'.$this->libelle.'</a>';
|
||||
|
||||
if ($this->type == 0)
|
||||
{
|
||||
$this->isproduct = 1;
|
||||
$this->isservice = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->isproduct = 0;
|
||||
$this->isservice = 1;
|
||||
}
|
||||
|
||||
$this->db->free();
|
||||
// multilangs
|
||||
if( $conf->global->MAIN_MULTILANGS) $this->getMultiLangs();
|
||||
|
||||
|
||||
|
||||
|
||||
// multiprix
|
||||
if($conf->global->PRODUIT_MULTIPRICES == 1)
|
||||
{
|
||||
if ($ref)
|
||||
if ($ref)
|
||||
{
|
||||
$sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."product ";
|
||||
$sql.= "WHERE ref = '".addslashes($ref)."'";
|
||||
$result = $this->db->query($sql) ;
|
||||
if ($result)
|
||||
{
|
||||
$sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."product ";
|
||||
$sql.= "WHERE ref = '".addslashes($ref)."'";
|
||||
$result = $this->db->query($sql) ;
|
||||
if ($result)
|
||||
{
|
||||
$result = $this->db->fetch_array();
|
||||
$prodid = $result["rowid"];
|
||||
}
|
||||
else
|
||||
{
|
||||
dolibarr_print_error($this->db);
|
||||
return -1;
|
||||
}
|
||||
$result = $this->db->fetch_array();
|
||||
$prodid = $result["rowid"];
|
||||
}
|
||||
$this -> multiprices[1] = $this->price;
|
||||
for($i=2;$i<=$conf->global->PRODUIT_MULTIPRICES_LIMIT;$i++)
|
||||
else
|
||||
{
|
||||
$sql= "SELECT price, tva_tx, envente ";
|
||||
$sql.= "FROM ".MAIN_DB_PREFIX."product_price ";
|
||||
$sql.= "where price_level=".$i." and ";
|
||||
if ($id) $sql.= "fk_product = '".$id."' ";
|
||||
if ($ref) $sql.= "fk_product = '".$prodid."' ";
|
||||
$sql.= "order by date_price DESC limit 1";
|
||||
$result = $this->db->query($sql) ;
|
||||
if ( $result )
|
||||
{
|
||||
$result = $this->db->fetch_array();
|
||||
if($result["price"] != "" && $result["price"] != "0.00")
|
||||
$this -> multiprices[$i]=$result["price"];
|
||||
else
|
||||
$this -> multiprices[$i]=$this->price;
|
||||
}
|
||||
else
|
||||
{
|
||||
dolibarr_print_error($this->db);
|
||||
return -1;
|
||||
}
|
||||
dolibarr_print_error($this->db);
|
||||
return -1;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$sql = "SELECT reel, fk_entrepot";
|
||||
$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];
|
||||
$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
|
||||
{
|
||||
dolibarr_print_error($this->db);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
$this -> multiprices[1] = $this->price;
|
||||
for($i=2;$i<=$conf->global->PRODUIT_MULTIPRICES_LIMIT;$i++)
|
||||
{
|
||||
$sql= "SELECT price, tva_tx, envente ";
|
||||
$sql.= "FROM ".MAIN_DB_PREFIX."product_price ";
|
||||
$sql.= "where price_level=".$i." and ";
|
||||
if ($id) $sql.= "fk_product = '".$id."' ";
|
||||
if ($ref) $sql.= "fk_product = '".$prodid."' ";
|
||||
$sql.= "order by date_price DESC limit 1";
|
||||
$result = $this->db->query($sql) ;
|
||||
if ( $result )
|
||||
{
|
||||
$result = $this->db->fetch_array();
|
||||
if($result["price"] != "" && $result["price"] != "0.00")
|
||||
$this -> multiprices[$i]=$result["price"];
|
||||
else
|
||||
$this -> multiprices[$i]=$this->price;
|
||||
}
|
||||
else
|
||||
{
|
||||
dolibarr_print_error($this->db);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$res=$this->load_stock();
|
||||
|
||||
return $res;
|
||||
}
|
||||
else
|
||||
{
|
||||
dolibarr_print_error($this->db);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
@ -1825,7 +1796,6 @@ function get_each_prod()
|
||||
* \param nbpiece nombre de pieces
|
||||
* \param mouvement 0 = ajout, 1 = suppression
|
||||
*/
|
||||
|
||||
function ajust_stock($user, $id_entrepot, $nbpiece, $mouvement)
|
||||
{
|
||||
$op[0] = "+" . trim($nbpiece);
|
||||
@ -1877,13 +1847,52 @@ 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++;
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Charge les informations relatives à un fournisseur
|
||||
* \param fournid id du fournisseur
|
||||
* \return int < 0 si erreur, > 0 si ok
|
||||
*/
|
||||
function fetch_fourn_data($fournid)
|
||||
$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
|
||||
* \param fournid id du fournisseur
|
||||
* \return int < 0 si erreur, > 0 si ok
|
||||
*/
|
||||
function fetch_fourn_data($fournid)
|
||||
{
|
||||
$sql = "SELECT rowid, ref_fourn";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."product_fournisseur ";
|
||||
|
||||
@ -18,7 +18,6 @@
|
||||
*
|
||||
* $Id$
|
||||
* $Source$
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
|
||||
Loading…
Reference in New Issue
Block a user