From 7facc823624565ee400d8704f4ee593d17c31382 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 14 Jul 2006 11:31:57 +0000 Subject: [PATCH] =?UTF-8?q?Quelques=20am=E9liorations=20diverses=20sur=20g?= =?UTF-8?q?estion=20des=20=E9xp=E9ditions?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- htdocs/commande/commande.class.php | 61 +++- htdocs/expedition/commande.php | 95 ++---- htdocs/expedition/expedition.class.php | 20 ++ htdocs/expedition/fiche.php | 395 ++++++++++++++---------- htdocs/html.form.class.php | 2 +- htdocs/langs/en_US/sendings.lang | 1 + htdocs/langs/en_US/stocks.lang | 3 +- htdocs/langs/fr_FR/sendings.lang | 1 + htdocs/langs/fr_FR/stocks.lang | 3 +- htdocs/product.class.php | 287 ++++++++--------- htdocs/product/stock/entrepot.class.php | 1 - 11 files changed, 478 insertions(+), 391 deletions(-) diff --git a/htdocs/commande/commande.class.php b/htdocs/commande/commande.class.php index 78fff6d1856..ed922726d01 100644 --- a/htdocs/commande/commande.class.php +++ b/htdocs/commande/commande.class.php @@ -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) diff --git a/htdocs/expedition/commande.php b/htdocs/expedition/commande.php index bd9169b2ac2..b6a91c14ee4 100644 --- a/htdocs/expedition/commande.php +++ b/htdocs/expedition/commande.php @@ -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 ''; @@ -352,7 +353,7 @@ if ($_GET["id"] > 0) } else { - print "\n"; + print "\n"; } print ''; @@ -363,22 +364,20 @@ if ($_GET["id"] > 0) print ''; $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 ''; if ($conf->stock->enabled) { - if ($product->stock_reel < $reste_a_livrer_x) + print ''; - } - else - { - print ''; + print ' '.img_warning($langs->trans("StockTooLow")); } + print ''; } else { @@ -459,51 +458,6 @@ if ($_GET["id"] > 0) print "\n"; } - - /* - * Alerte de seuil - */ - if ($reste_a_livrer_total > 0 && $conf->stock->enabled) - { - print '
".stripslashes(nl2br($objp->description))."".nl2br($objp->description)."'.$objp->qty.''; print $reste_a_livrer[$objp->fk_product]; print ''; + print $product->stock_reel; + if ($product->stock_reel < $reste_a_livrer[$objp->fk_product]) { - print ''.$product->stock_reel.''.$product->stock_reel.'
'; - 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 ""; - print ''; - print ''; - print "\n"; - $i++; - } - $db->free($resql); - } - else { - dolibarr_print_error($db); - } - - } - } - print "
'; - print ''.img_object($langs->trans("ShowProduct"),"product").' '.$obja->ref.' - '.$obja->label; - print ''.$obja->entrepot.'Stock : '.$obja->reel.'' .img_warning($langs->trans("Alert")).'
"; - } - /* * Déjà livré */ @@ -534,13 +488,13 @@ if ($_GET["id"] > 0) print ''; print ''; print ''; + print ''; + print ''; + print ''; if ($conf->livraison->enabled) { print ''; } - print ''; - print ''; - print ''; print "\n"; $var=True; @@ -551,18 +505,6 @@ if ($_GET["id"] > 0) print ""; print ''; - if ($conf->livraison->enabled) - { - if ($objp->livraison_id) - { - print ''; - } - else - { - print ''; - } - } - if ($objp->fk_product > 0) { $product = new Product($db); @@ -579,6 +521,19 @@ if ($_GET["id"] > 0) } print ''; print ''; + if ($conf->livraison->enabled) + { + if ($objp->livraison_id) + { + print ''; + } + else + { + print ''; + } + } + print ''; + $i++; } diff --git a/htdocs/expedition/expedition.class.php b/htdocs/expedition/expedition.class.php index ce2b1551f94..3f9852da39a 100644 --- a/htdocs/expedition/expedition.class.php +++ b/htdocs/expedition/expedition.class.php @@ -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]; + } + } diff --git a/htdocs/expedition/fiche.php b/htdocs/expedition/fiche.php index bbbb6afc1a5..7bbdfa4c171 100644 --- a/htdocs/expedition/fiche.php +++ b/htdocs/expedition/fiche.php @@ -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.'
'; - } - - $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.'
'; + } - /* - * Commande - */ - print ''; - print ''; - print ''; - print ''; + $commande = new Commande($db); + $commande->expedition_array(); - print '
'.$langs->trans("Sending").''.$langs->trans("Product").''.$langs->trans("QtyShipped").''.$langs->trans("Date").''.$langs->trans("DeliveryOrder").''.$langs->trans("Description").''.$langs->trans("QtyShipped").''.$langs->trans("Date").'
'.img_object($langs->trans("ShowSending"),'sending').' '.$objp->ref.''.img_object($langs->trans("ShowSending"),'generic').' '.$objp->livraison_ref.''.$langs->trans("CreateDeliveryOrder").''.$objp->qty_livre.''.dolibarr_print_date($objp->date_expedition).''.img_object($langs->trans("ShowSending"),'generic').' '.$objp->livraison_ref.''.$langs->trans("CreateDeliveryOrder").'
'; + 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 ''; - print "\n"; + $entrepot = new Entrepot($db); + + /* + * Commande + */ + print ''; + print ''; + print ''; + if ($_GET["entrepot_id"]) + { + print ''; + } + + print '
'.$langs->trans("RefOrder").''.img_object($langs->trans("ShowOrder"),'order').' '.$commande->ref.'
'; + + // Ref commande + print ''; + print "\n"; // Ref commande client print ''; print ''; - - // Société + + // Sociét print ''; print ''; print ''; - + // Date print ""; print '\n"; - - - - if ($conf->stock->enabled) - { + + // Entrepot (si forcé) + if ($conf->stock->enabled && $_GET["entrepot_id"]) + { print ''; print ''; } - + if ($commande->note) { - print '"; + print '"; } print "
'.$langs->trans("RefOrder").''.img_object($langs->trans("ShowOrder"),'order').' '.$commande->ref.'
'; - print ''; + if ($_GET['action'] != 'refcdeclient' && $commande->brouillon) print ''; + print '
'; + print ''; - if ($_GET['action'] != 'refcdeclient' && $commande->brouillon) print ''; - print '
'; print $langs->trans('RefCustomerOrderShort').''; - print ''.img_edit($langs->trans('Edit')).'
'; - print '
'; + print ''.img_edit($langs->trans('Edit')).'
'; + print '
'; if ($user->rights->commande->creer && $_GET['action'] == 'refcdeclient') { print ''; @@ -222,143 +228,186 @@ if ($_GET["action"] == 'create') } print '
'.$langs->trans('Company').''.$soc->getNomUrl(1).'
".$langs->trans("Date")."'.dolibarr_print_date($commande->date,"%A %d %B %Y")."
'.$langs->trans("Warehouse").''; $ents = $entrepot->list_array(); print ''.img_object($langs->trans("ShowWarehouse"),'stock').' '.$ents[$_GET["entrepot_id"]].''; print '
Note : '.nl2br($commande->note)."
'.$langs->trans("NotePrivate").': '.nl2br($commande->note)."
"; - - /* - * Lignes de commandes - * - */ - echo '
'; - - $lignes = $commande->fetch_lignes(1); - - /* Lecture des expeditions déjà effectuées */ - $commande->expedition_array(); - - $num = sizeof($commande->lignes); - $i = 0; - - if ($num) - { - print ''; - print ''; - print ''; - print ''; - print ''; - if ($conf->stock->enabled) - { - print ''; - } - print "\n"; + + /* + * Lignes de commandes + * + */ + echo '
'.$langs->trans("Description").'Quan. commandéeQuan. livréeQuan. à livrer'.$langs->trans("Stock").'
'; + + $lignes = $commande->fetch_lignes(1); + + /* Lecture des expeditions déjà effectuées */ + $commande->expedition_array(); + + $num = sizeof($commande->lignes); + $i = 0; + + if ($num) + { + print ''; + print ''; + print ''; + print ''; + print ''; + if ($conf->stock->enabled) + { + if ($_GET["entrepot_id"]) + { + print ''; + } + else + { + print ''; + } + } + print "\n"; + } + $var=true; + while ($i < $num) + { + $ligne = $commande->lignes[$i]; + $var=!$var; + print "\n"; + if ($ligne->fk_product > 0) + { + $product = new Product($db); + $product->fetch($ligne->fk_product); + + print ''; + } + else + { + print "\n"; + } + + print ''; + + print ''; + + $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 ''; + + // Stock + if ($_GET["entrepot_id"]) + { + print ''; + } + 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 ''; + } + } + else + { + // Quantité à livrer + print ''; + } + + print "\n"; + + $i++; + $var=!$var; + } + + /* + * + */ + + print ''; + print "
'.$langs->trans("Description").''.$langs->trans("QtyOrdered").''.$langs->trans("QtyShipped").''.$langs->trans("QtyToShip").''.$langs->trans("Stock").''.$langs->trans("Warehouse").'
'; + print ''.img_object($langs->trans("ShowProduct"),"product").' '.$product->ref.' - '.$product->libelle; + if ($ligne->description) print nl2br($ligne->description); + print '".nl2br($ligne->description)."'.$ligne->qty.''; + $quantite_livree = $commande->expeditions[$ligne->fk_product]; + print $quantite_livree;; + print ''; + print ''; + print ''; + print ''.$stock; + if ($stock < $quantite_a_livrer) + { + print ' '.img_warning($langs->trans("StockTooLow")); + } + print ''; + $html->select_array('warehouse'.$i,$array,'',1,0,0); + print ''; + print ''; + print ''; + print '

"; + print ''; } - $var=true; - while ($i < $num) + else { - $ligne = $commande->lignes[$i]; - $var=!$var; - print "\n"; - if ($ligne->fk_product > 0) - { - $product = new Product($db); - $product->fetch($ligne->fk_product); - - print ''; - print ''.img_object($langs->trans("ShowProduct"),"product").' '.$product->ref.' - '.$product->libelle; - if ($ligne->description) print nl2br($ligne->description); - print ''; - } - else - { - print "".nl2br($ligne->description)."\n"; - } - - print ''.$ligne->qty.''; - /* - * - */ - print ''; - $quantite_livree = $commande->expeditions[$ligne->fk_product]; - print $quantite_livree;; - print ''; - - $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 ''; - print ''; - print ''; - print ''; - - // Stock - if ($stock < $quantite_a_livrer) - { - print ''.$stock.''; - } - else - { - print ''.$stock.''; - } - } - else - { - // Quantité à livrer - print ''; - print ''; - print ''; - print ''; - } - - print "\n"; - - $i++; - $var=!$var; - } - - /* - * - */ - - print '
'; - print ""; - print ''; - } - 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 '
'; print ''; @@ -461,6 +510,11 @@ else print ''.$langs->trans("Date").''; print ''.dolibarr_print_date($expedition->date,"%A %d %B %Y")."\n"; print ''; + + // Statut + print ''.$langs->trans("Status").''; + print ''.$expedition->getLibStatut()."\n"; + print ''; if (!$conf->expedition->enabled && $conf->stock->enabled) { @@ -480,9 +534,9 @@ else echo '
'; $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 ''; print ''; print ''; - print ''; + if ($obj->fk_statut <= 1) + { + print ''; + } + else + { + print ''; + } print "\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 '
'; + if ($somethingshown) print '
'; print_titre($langs->trans("OtherSendingsForSameOrder")); print '
'.$langs->trans("Products").''.$langs->trans("QtyOrdered").''.$langs->trans("QtyShipped").''.$langs->trans("QtyToShip").''.$langs->trans("QtyShipped").'
'; print ''; print ''; print ''; - print ''; + print ''; print ''; print "\n"; @@ -632,13 +694,13 @@ else $product->fetch($objp->fk_product); print ''; } else { - print "\n"; + print "\n"; } print ''; print ''; @@ -682,11 +744,12 @@ else print '
'.$langs->trans("Ref").''.$langs->trans("Description").''.$langs->trans("QtyShipped").''.$langs->trans("Qty").''.$langs->trans("Date").'
'; - print ''.img_object($langs->trans("ShowProduct"),"product").' '.$product->ref.' - '.$product->libelle; - if ($objp->description) print nl2br($objp->description); + print ''.img_object($langs->trans("ShowProduct"),"product").' '.$product->ref.' - '.dolibarr_trunc($product->libelle,20); + if ($objp->description) print nl2br(dolibarr_trunc($objp->description,24)); print '".stripslashes(nl2br($objp->description))."".nl2br(dolibarr_trunc($objp->description,24))."'.$objp->qty_livre.''.dolibarr_print_date($objp->date_expedition).''; - 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)"; diff --git a/htdocs/html.form.class.php b/htdocs/html.form.class.php index d3dbe36f70e..4311295542d 100644 --- a/htdocs/html.form.class.php +++ b/htdocs/html.form.class.php @@ -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é */ diff --git a/htdocs/langs/en_US/sendings.lang b/htdocs/langs/en_US/sendings.lang index 857b11742c8..65a61c2e4ac 100644 --- a/htdocs/langs/en_US/sendings.lang +++ b/htdocs/langs/en_US/sendings.lang @@ -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 \ No newline at end of file diff --git a/htdocs/langs/en_US/stocks.lang b/htdocs/langs/en_US/stocks.lang index 44f6641cfdc..a6290718ccb 100644 --- a/htdocs/langs/en_US/stocks.lang +++ b/htdocs/langs/en_US/stocks.lang @@ -24,4 +24,5 @@ Units=Units StockCorrection=Stock correction StockMovement=Transfer NumberOfUnit=Number of units -TotalStock=Total in stock \ No newline at end of file +TotalStock=Total in stock +StockTooLow=Stock too low \ No newline at end of file diff --git a/htdocs/langs/fr_FR/sendings.lang b/htdocs/langs/fr_FR/sendings.lang index 7823b85142a..c8157f89ddb 100644 --- a/htdocs/langs/fr_FR/sendings.lang +++ b/htdocs/langs/fr_FR/sendings.lang @@ -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 diff --git a/htdocs/langs/fr_FR/stocks.lang b/htdocs/langs/fr_FR/stocks.lang index da55bc7103b..66bb8a9ceb5 100644 --- a/htdocs/langs/fr_FR/stocks.lang +++ b/htdocs/langs/fr_FR/stocks.lang @@ -24,4 +24,5 @@ Units=Unit StockCorrection=Correction stock StockMovement=Transfert NumberOfUnit=Nombre de pièces -TotalStock=Total en stock \ No newline at end of file +TotalStock=Total en stock +StockTooLow=Stock insuffisant \ No newline at end of file diff --git a/htdocs/product.class.php b/htdocs/product.class.php index 641454833b4..1f693d1527f 100644 --- a/htdocs/product.class.php +++ b/htdocs/product.class.php @@ -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 = ''.$this->libelle.''; - - 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 = ''.$this->libelle.''; + + 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 "; diff --git a/htdocs/product/stock/entrepot.class.php b/htdocs/product/stock/entrepot.class.php index 16e2546c403..2f2042cb041 100644 --- a/htdocs/product/stock/entrepot.class.php +++ b/htdocs/product/stock/entrepot.class.php @@ -18,7 +18,6 @@ * * $Id$ * $Source$ - * */ /**