From 569316d3bd2bb63aaf013e64ef98fa6bdb9fc7c9 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 28 Jan 2009 09:00:29 +0000 Subject: [PATCH] Removed deprecated code --- htdocs/cashdesk/facturation_verif.php | 8 +- htdocs/commande/commande.class.php | 119 ++++++++------------ htdocs/facture.class.php | 3 + htdocs/fourn/fournisseur.commande.class.php | 5 +- htdocs/fourn/fournisseur.facture.class.php | 1 + htdocs/html.formactions.class.php | 10 +- htdocs/langs/en_US/other.lang | 4 +- htdocs/langs/fr_FR/other.lang | 4 +- htdocs/lib/functions.lib.php | 12 ++ htdocs/livraison/livraison.class.php | 1 + htdocs/product.class.php | 63 ++--------- htdocs/product/reassort.php | 4 +- mysql/migration/2.5.0-2.6.0.sql | 3 + mysql/tables/llx_product.sql | 2 - 14 files changed, 94 insertions(+), 145 deletions(-) diff --git a/htdocs/cashdesk/facturation_verif.php b/htdocs/cashdesk/facturation_verif.php index d70d8d4a576..54a3e1351f0 100644 --- a/htdocs/cashdesk/facturation_verif.php +++ b/htdocs/cashdesk/facturation_verif.php @@ -33,7 +33,7 @@ switch ( $_GET['action'] ) { // Recuperation des donnees en fonction de la source (liste d�roulante ou champ texte) ... if ( $_POST['hdnSource'] == 'LISTE' ) { - $res = $sql->query('SELECT fk_product, ref, stock_propale, stock_commande, price, reel, tva_tx + $res = $sql->query('SELECT fk_product, ref, price, reel, tva_tx FROM '.MAIN_DB_PREFIX.'product LEFT JOIN '.MAIN_DB_PREFIX.'product_stock ON '.MAIN_DB_PREFIX.'product.rowid = '.MAIN_DB_PREFIX.'product_stock.fk_product WHERE fk_product = '.$_POST['selProduit'].' @@ -41,7 +41,7 @@ switch ( $_GET['action'] ) { } else if ( $_POST['hdnSource'] == 'REF' ) { - $res = $sql->query('SELECT fk_product, ref, stock_propale, stock_commande, price, reel, tva_tx + $res = $sql->query('SELECT fk_product, ref, price, reel, tva_tx FROM '.MAIN_DB_PREFIX.'product LEFT JOIN '.MAIN_DB_PREFIX.'product_stock ON '.MAIN_DB_PREFIX.'product.rowid = '.MAIN_DB_PREFIX.'product_stock.fk_product WHERE ref = \''.$_POST['txtRef'].'\' @@ -64,11 +64,11 @@ switch ( $_GET['action'] ) { $obj_facturation->id( $tab['fk_product'] ); $obj_facturation->ref( $tab['ref'] ); - $obj_facturation->stock( $tab['reel'] - $tab['stock_propale'] - $tab['stock_commande'] ); + $obj_facturation->stock( $tab['reel']); $obj_facturation->prix( $tab['price'] ); $obj_facturation->tva( $tab['tva_tx'] ); - // Definition du filtre pour n'afficher que le produit concern� + // Definition du filtre pour n'afficher que le produit concerne if ( $_POST['hdnSource'] == 'LISTE' ) { $filtre = $tab['ref']; diff --git a/htdocs/commande/commande.class.php b/htdocs/commande/commande.class.php index 5e683650250..cc6ba0fd356 100644 --- a/htdocs/commande/commande.class.php +++ b/htdocs/commande/commande.class.php @@ -252,7 +252,7 @@ class Commande extends CommonObject if (eregi('^\(PROV', $this->ref)) { // On renomme repertoire facture ($this->ref = ancienne ref, $numfa = nouvelle ref) - // afin de ne pas perdre les fichiers attachés + // afin de ne pas perdre les fichiers attach�s $comref = sanitizeFileName($this->ref); $snum = sanitizeFileName($num); $dirsource = $conf->commande->dir_output.'/'.$comref; @@ -1241,8 +1241,6 @@ class Commande extends CommonObject $product = new Product($this->db); $product->id = $obj->fk_product; - $result=$product->ajust_stock_commande($obj->qty, 1); - // Supprime ligne $ligne = new CommandeLigne($this->db); $ligne->id = $idligne; @@ -1645,69 +1643,59 @@ class Commande extends CommonObject $subprice = $pu; $remise = 0; if ($remise_percent > 0) - { - $remise = round(($pu * $remise_percent / 100),2); - $price = ($pu - $remise); - } - $price = price2num($price); - $subprice = price2num($subprice); + { + $remise = round(($pu * $remise_percent / 100),2); + $price = ($pu - $remise); + } + $price = price2num($price); + $subprice = price2num($subprice); - $LigneOld = new CommandeLigne($this->db); - $LigneOld->fetch($rowid); + $LigneOld = new CommandeLigne($this->db); + $LigneOld->fetch($rowid); - // Mise a jour ligne en base - $sql = "UPDATE ".MAIN_DB_PREFIX."commandedet SET"; - $sql.= " description='".addslashes($desc)."'"; - $sql.= ",price='".price2num($price)."'"; - $sql.= ",subprice='".price2num($subprice)."'"; - $sql.= ",remise='".price2num($remise)."'"; - $sql.= ",remise_percent='".price2num($remise_percent)."'"; - $sql.= ",tva_tx='".price2num($txtva)."'"; - $sql.= ",qty='".price2num($qty)."'"; - //if ($date_end) { $sql.= ",date_start='$date_end'"; } - //else { $sql.=',date_start=null'; } - //if ($date_end) { $sql.= ",date_end='$date_end'"; } - //else { $sql.=',date_end=null'; } - $sql.= ",info_bits='".$info_bits."'"; - $sql.= ",total_ht='".price2num($total_ht)."'"; - $sql.= ",total_tva='".price2num($total_tva)."'"; - $sql.= ",total_ttc='".price2num($total_ttc)."'"; + // Mise a jour ligne en base + $sql = "UPDATE ".MAIN_DB_PREFIX."commandedet SET"; + $sql.= " description='".addslashes($desc)."'"; + $sql.= ",price='".price2num($price)."'"; + $sql.= ",subprice='".price2num($subprice)."'"; + $sql.= ",remise='".price2num($remise)."'"; + $sql.= ",remise_percent='".price2num($remise_percent)."'"; + $sql.= ",tva_tx='".price2num($txtva)."'"; + $sql.= ",qty='".price2num($qty)."'"; + //if ($date_end) { $sql.= ",date_start='$date_end'"; } + //else { $sql.=',date_start=null'; } + //if ($date_end) { $sql.= ",date_end='$date_end'"; } + //else { $sql.=',date_end=null'; } + $sql.= ",info_bits='".$info_bits."'"; + $sql.= ",total_ht='".price2num($total_ht)."'"; + $sql.= ",total_tva='".price2num($total_tva)."'"; + $sql.= ",total_ttc='".price2num($total_ttc)."'"; - // Added by Matelli (See http://matelli.fr/showcases/patchs-dolibarr/add-dates-in-order-lines.html) - // Save the start and end date in the database - if ($date_start) { $sql.= ",date_start='".$date_start."'"; } - else { $sql.=',date_start=null'; } - if ($date_end) { $sql.= ",date_end='".$date_end."'"; } - else { $sql.=',date_end=null'; } + // Added by Matelli (See http://matelli.fr/showcases/patchs-dolibarr/add-dates-in-order-lines.html) + // Save the start and end date in the database + if ($date_start) { $sql.= ",date_start='".$date_start."'"; } + else { $sql.=',date_start=null'; } + if ($date_end) { $sql.= ",date_end='".$date_end."'"; } + else { $sql.=',date_end=null'; } - $sql.= " WHERE rowid = ".$rowid; + $sql.= " WHERE rowid = ".$rowid; - $result = $this->db->query($sql); - if ($result > 0) - { - // Mise a jour info denormalisees au niveau facture - $this->update_price(); + $result = $this->db->query($sql); + if ($result > 0) + { + // Mise a jour info denormalisees + $this->update_price(); - if ($LigneOld->qty <> $qty && $LigneOld->produit_id) - { - $delta = $qty - $LigneOld->qty; - $op = ($delta > 0) ? 0 : 1; - - $product = new Product($this->db); - $product->id = $LigneOld->produit_id; - $product->ajust_stock_commande(abs($delta), $op); - } - - $this->db->commit(); - return $result; - } - else - { - $this->error=$this->db->error(); - $this->db->rollback(); - return -1; - } + $this->db->commit(); + return $result; + } + else + { + $this->error=$this->db->error(); + $this->db->rollback(); + return -1; + } } else { @@ -2274,9 +2262,9 @@ class CommandeLigne } /** - * \brief Insere l'objet ligne de commande en base - * \param notrigger 1 ne declenche pas les triggers, 0 sinon - * \return int <0 si ko, >0 si ok + * \brief Insere l'objet ligne de commande en base + * \param notrigger 1 ne declenche pas les triggers, 0 sinon + * \return int <0 si ko, >0 si ok */ function insert($notrigger=0) { @@ -2342,13 +2330,6 @@ class CommandeLigne else { $sql.='null'; } $sql.= ')'; - if ($this->fk_product) - { - $product = new Product($this->db); - $product->id = $this->fk_product; - $product->ajust_stock_commande($this->qty, 0); - } - dolibarr_syslog("CommandeLigne::insert sql=$sql"); $resql=$this->db->query($sql); if ($resql) diff --git a/htdocs/facture.class.php b/htdocs/facture.class.php index ebaa27931ff..68f1bf00aa6 100644 --- a/htdocs/facture.class.php +++ b/htdocs/facture.class.php @@ -1337,6 +1337,7 @@ class Facture extends CommonObject { require_once(DOL_DOCUMENT_ROOT."/product/stock/mouvementstock.class.php"); + // Loop on each line for ($i = 0 ; $i < sizeof($this->lignes) ; $i++) { if ($this->lignes[$i]->fk_product && $this->lignes[$i]->product_type == 0) @@ -1344,6 +1345,7 @@ class Facture extends CommonObject $mouvP = new MouvementStock($this->db); // We decrease stock for product $entrepot_id = "1"; // TODO ajouter possibilité de choisir l'entrepot + // TODO Add price of product in method or '' to update PMP $result=$mouvP->livraison($user, $this->lignes[$i]->fk_product, $entrepot_id, $this->lignes[$i]->qty); } } @@ -1409,6 +1411,7 @@ class Facture extends CommonObject $mouvP = new MouvementStock($this->db); // We decrease stock for product $entrepot_id = "1"; // TODO ajouter possibilité de choisir l'entrepot + // TODO Add price of product in method or '' to update PMP $result=$mouvP->reception($user, $this->lignes[$i]->fk_product, $entrepot_id, $this->lignes[$i]->qty); } } diff --git a/htdocs/fourn/fournisseur.commande.class.php b/htdocs/fourn/fournisseur.commande.class.php index b01e88bba28..1806ae34e2c 100644 --- a/htdocs/fourn/fournisseur.commande.class.php +++ b/htdocs/fourn/fournisseur.commande.class.php @@ -527,6 +527,7 @@ class CommandeFournisseur extends Commande $mouvP = new MouvementStock($this->db); // We decrement stock of product (and sub-products) $entrepot_id = "1"; //Todo: ajouter possibilite de choisir l'entrepot + // TODO Add price of product in method or '' to update PMP $result=$mouvP->reception($user, $this->lignes[$i]->fk_product, $entrepot_id, $this->lignes[$i]->qty); if ($result < 0) { $error++; } } @@ -915,10 +916,8 @@ class CommandeFournisseur extends Commande // Si module stock g�r� et que expedition faite depuis un entrepot if (!$error && $conf->stock->enabled && $entrepot) { - /* - * Enregistrement d'un mouvement de stock pour chaque produit de l'expedition - */ $mouv = new MouvementStock($this->db); + // TODO Add price of product in method or '' to update PMP $result=$mouv->reception($user, $product, $entrepot, $qty, $price); if ($result < 0) { diff --git a/htdocs/fourn/fournisseur.facture.class.php b/htdocs/fourn/fournisseur.facture.class.php index fb0260f1409..9051c50efd3 100644 --- a/htdocs/fourn/fournisseur.facture.class.php +++ b/htdocs/fourn/fournisseur.facture.class.php @@ -423,6 +423,7 @@ class FactureFournisseur extends Facture $mouvP = new MouvementStock($this->db); // We increase stock for product $entrepot_id = "1"; // TODO ajouter possibilité de choisir l'entrepot + // TODO Add price of product in method or '' to update PMP $result=$mouvP->reception($user, $this->lignes[$i]->fk_product, $entrepot_id, $this->lignes[$i]->qty); if ($result < 0) { $error++; } } diff --git a/htdocs/html.formactions.class.php b/htdocs/html.formactions.class.php index 16457a369dd..b62e4baf434 100644 --- a/htdocs/html.formactions.class.php +++ b/htdocs/html.formactions.class.php @@ -18,14 +18,14 @@ /** \file htdocs/html.formactions.class.php - \brief Fichier de la classe des fonctions prédéfinie de composants html actions + \brief Fichier de la classe des fonctions pr�d�finie de composants html actions \version $Id$ */ /** \class FormActions - \brief Classe permettant la génération de composants html actions + \brief Classe permettant la g�n�ration de composants html actions */ class FormActions { @@ -35,7 +35,7 @@ class FormActions /** * \brief Constructeur - * \param DB handler d'accès base de donnée + * \param DB handler d'acc�s base de donn�e */ function FormActions($DB) { @@ -131,7 +131,7 @@ class FormActions print ''; print ''.img_object($langs->trans('ShowTask'),'task').' '.$objp->id.''; print ''.dolibarr_print_date($objp->da,'day').''; - print ''.dolibarr_trunc($objp->label,32).''; + print ''.dolibarr_trunc($objp->label,32).''; print ''.$objp->login.''; print ''; $i++; @@ -151,7 +151,7 @@ class FormActions /** * \brief Retourne la liste des types de comptes financiers - * \param selected Type pré-sélectionné + * \param selected Type pr�-s�lectionn� * \param htmlname Nom champ formulaire */ function select_type_actions($selected='',$htmlname='actioncode') diff --git a/htdocs/langs/en_US/other.lang b/htdocs/langs/en_US/other.lang index deb7ab23cc3..086bbbead5f 100644 --- a/htdocs/langs/en_US/other.lang +++ b/htdocs/langs/en_US/other.lang @@ -88,8 +88,8 @@ EnableGDLibraryDesc=Install or enable GD library with your PHP for use this opti EnablePhpAVModuleDesc=You need to install a module compatible with your anti-virus. (Clamav : php4-clamavlib ou php5-clamavlib) ProfIdShortDesc=Prof Id %s is an information depending on third party country.
For example, for country %s, it's code %s. DolibarrDemo=Dolibarr ERP/CRM demo -StatsByNumberOfUnits=Statistics in number of units -StatsByNumberOfEntities=Statistics in number of entities +StatsByNumberOfUnits=Statistics in number of products/services units +StatsByNumberOfEntities=Statistics in number of referring entities NumberOfProposals=Number of proposals on last 12 month NumberOfCustomerOrders=Number of customer orders on last 12 month NumberOfCustomerInvoices=Number of customer invoices on last 12 month diff --git a/htdocs/langs/fr_FR/other.lang b/htdocs/langs/fr_FR/other.lang index 9c30141ecff..c60d0a0a0aa 100644 --- a/htdocs/langs/fr_FR/other.lang +++ b/htdocs/langs/fr_FR/other.lang @@ -88,8 +88,8 @@ EnableGDLibraryDesc=Vous devez activer ou installer la librairie GD avec votre P EnablePhpAVModuleDesc=Vous devez installer un module PHP compatible avec votre anti-virus. (Clamav : php4-clamavlib ou php5-clamavlib) ProfIdShortDesc=Id prof. %s est une information qui dépend du pays du tiers.
Par exemple, pour le pays %s, il s'agit du code %s. DolibarrDemo=Démo de Dolibarr ERP/CRM -StatsByNumberOfUnits=Statistiques en nombre d'unités -StatsByNumberOfEntities=Statistiques en nombre d'entités +StatsByNumberOfUnits=Statistiques en nombre d'unités du produit/service +StatsByNumberOfEntities=Statistiques en nombre d'entités référentes NumberOfProposals=Nombre de propal sur les 12 derniers mois NumberOfCustomerOrders=Nombre de commande clients sur les 12 derniers mois NumberOfCustomerInvoices=Nombre de facture clients sur les 12 derniers mois diff --git a/htdocs/lib/functions.lib.php b/htdocs/lib/functions.lib.php index 306cff14a52..ca207514a2b 100644 --- a/htdocs/lib/functions.lib.php +++ b/htdocs/lib/functions.lib.php @@ -158,6 +158,18 @@ function dol_escape_js($stringtoescape) } +/** + * \brief Returns text escaped for inclusion in javascript code + * \param $stringtoescape String to escape + * \return string Escaped string + */ +function dol_escape_htmltag($stringtoescape) +{ + // escape quotes and backslashes, newlines, etc. + return strtr($stringtoescape, array('"'=>'',"\r"=>'\\r',"\n"=>'\\n')); +} + + /* For backward compatiblity */ function dolibarr_syslog($message, $level=LOG_INFO) { diff --git a/htdocs/livraison/livraison.class.php b/htdocs/livraison/livraison.class.php index 73bf220665f..db55703c940 100644 --- a/htdocs/livraison/livraison.class.php +++ b/htdocs/livraison/livraison.class.php @@ -399,6 +399,7 @@ class Livraison extends CommonObject $obj = $this->db->fetch_object($resql); $mouvS = new MouvementStock($this->db); + // TODO Add price of product in method or '' to update PMP $result=$mouvS->livraison($user, $obj->fk_product, $this->entrepot_id, $obj->qty); if ($result < 0) { diff --git a/htdocs/product.class.php b/htdocs/product.class.php index 2b6598bbc91..2141e08dece 100644 --- a/htdocs/product.class.php +++ b/htdocs/product.class.php @@ -901,7 +901,7 @@ class Product extends CommonObject $sql = "SELECT rowid, ref, label, description, note, price, price_ttc,"; $sql.= " price_min, price_min_ttc, price_base_type, tva_tx, envente,"; $sql.= " fk_product_type, duration, seuil_stock_alerte,canvas,"; - $sql.= " stock_commande, stock_loc, weight, weight_units, volume, volume_units, barcode, fk_barcode_type, finished"; + $sql.= " stock_loc, weight, weight_units, volume, volume_units, barcode, fk_barcode_type, finished"; $sql.= " FROM ".MAIN_DB_PREFIX."product"; if ($id) $sql.= " WHERE rowid = '".$id."'"; if ($ref) $sql.= " WHERE ref = '".addslashes($ref)."'"; @@ -939,7 +939,7 @@ class Product extends CommonObject $this->barcode = $result["barcode"]; $this->barcode_type = $result["fk_barcode_type"]; - $this->stock_in_command = $result["stock_commande"]; + $this->stock_in_command = 0; // TODO $this->label_url = ''.$this->libelle.''; @@ -2196,11 +2196,12 @@ class Product extends CommonObject } /** - * \brief Augmente ou r�duit la valeur de stock pour le produit - * \param user utilisateur qui demande l'ajustement - * \param id_entrepot id de l'entrepot - * \param nbpiece nombre de pieces - * \param mouvement 0 = ajout, 1 = suppression + * \brief Augmente ou reduit la valeur de stock pour le produit + * \param user utilisateur qui demande l'ajustement + * \param id_entrepot id de l'entrepot + * \param nbpiece nombre de pieces + * \param mouvement 0 = ajout, 1 = suppression + * \remarks Called by correct_stock */ function ajust_stock($user, $id_entrepot, $nbpiece, $mouvement) { @@ -2242,54 +2243,6 @@ class Product extends CommonObject } } - /** - * \brief Augmente ou r�duit le nombre de piece en commande a expedier - * \param nbpiece nombre de pieces - * \param mouvement 0 = ajout, 1 = suppression - * \return int < 0 si erreur, > 0 si ok - */ - function ajust_stock_commande($nbpiece, $mouvement) - { - $op[0] = "+" . trim($nbpiece); - $op[1] = "-" . trim($nbpiece); - - if ($this->db->begin()) - { - $sql = "UPDATE ".MAIN_DB_PREFIX."product "; - $sql .= " SET stock_commande = stock_commande ".$op[$mouvement]; - $sql .= " WHERE rowid = '".$this->id ."';"; - - if ($this->db->query($sql) ) - { - - $this->load_subproduct(); - - for ($i = 0 ; $i < sizeof($this->subproducts_id) ; $i++) - { - $product = new Product($this->db); - $product->id = $this->subproducts_id[$i]; - $product->ajust_stock_commande($nbpiece, $mouvement); - } - - $this->db->commit(); - return 1; - } - else - { - dolibarr_print_error($this->db); - $this->db->rollback(); - return -2; - } - } - else - { - dolibarr_print_error($this->db); - $this->db->rollback(); - return -3; - } - } - - /** * \brief Charge les informations en stock du produit * \return int < 0 si erreur, > 0 si ok diff --git a/htdocs/product/reassort.php b/htdocs/product/reassort.php index b3ac1485514..554d14ace56 100644 --- a/htdocs/product/reassort.php +++ b/htdocs/product/reassort.php @@ -74,9 +74,7 @@ $title=$langs->trans("ProductsAndServices"); $sql = 'SELECT p.rowid, p.ref, p.label, p.price, p.fk_product_type, '.$db->pdate('p.tms').' as datem,'; $sql.= ' p.duration, p.envente as statut, p.seuil_stock_alerte,'; -$sql.= ' p.stock_commande,'; -$sql.= ' SUM(s.reel) as stock_physique,'; -$sql.= ' (SUM(s.reel) - p.stock_commande) as stock_theorique'; //Todo: Il faudra additionner les commandes fournisseurs +$sql.= ' SUM(s.reel) as stock_physique'; $sql.= ' FROM '.MAIN_DB_PREFIX.'product_stock as s,'; $sql.= ' '.MAIN_DB_PREFIX.'product as p'; if ($catid || ($conf->categorie->enabled && ! $user->rights->categorie->voir)) diff --git a/mysql/migration/2.5.0-2.6.0.sql b/mysql/migration/2.5.0-2.6.0.sql index 2c6ec83932f..a1a37696a38 100644 --- a/mysql/migration/2.5.0-2.6.0.sql +++ b/mysql/migration/2.5.0-2.6.0.sql @@ -34,3 +34,6 @@ ALTER TABLE llx_mailing_cibles add column other varchar(255) NULL; ALTER TABLE llx_mailing_cibles ADD INDEX idx_mailing_cibles_email (email); +ALTER TABLE llx_product drop column stock_propale; +ALTER TABLE llx_product drop column stock_commande; + diff --git a/mysql/tables/llx_product.sql b/mysql/tables/llx_product.sql index 69206c6efa6..c24b065dda7 100644 --- a/mysql/tables/llx_product.sql +++ b/mysql/tables/llx_product.sql @@ -38,8 +38,6 @@ create table llx_product envente tinyint DEFAULT 1, fk_product_type integer DEFAULT 0, duration varchar(6), - stock_propale integer DEFAULT 0, - stock_commande integer DEFAULT 0, seuil_stock_alerte integer DEFAULT 0, stock_loc varchar(10), -- emplacement dans le stock barcode varchar(255) DEFAULT NULL,