From 5fdc6f13527d32c7e37a57a6c0b54e0f86831fe9 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Thu, 22 Jun 2006 15:14:18 +0000 Subject: [PATCH] bugfix --- htdocs/commande/commande.class.php | 6 ++++-- htdocs/commande/fiche.php | 3 +++ htdocs/includes/modules/commande/pdf_einstein.modules.php | 4 ++-- htdocs/lib/functions.inc.php | 8 ++++---- 4 files changed, 13 insertions(+), 8 deletions(-) diff --git a/htdocs/commande/commande.class.php b/htdocs/commande/commande.class.php index 0435e5c403e..1103758bceb 100644 --- a/htdocs/commande/commande.class.php +++ b/htdocs/commande/commande.class.php @@ -449,7 +449,7 @@ class Commande extends CommonObject * par l'appelant par la methode get_default_tva(societe_vendeuse,societe_acheteuse,taux_produit) * et le desc doit deja avoir la bonne valeur (a l'appelant de gerer le multilangue) */ - function addline($commandeid, $desc, $pu, $qty, $txtva, $fk_product=0, $remise_percent=0) + function addline($commandeid, $libelle, $desc, $pu, $qty, $txtva, $fk_product=0, $remise_percent=0) { dolibarr_syslog("Commande.class.php::addline this->id=$this->id, $commandeid, $desc, $pu, $qty, $txtva, $fk_product, $remise_percent"); include_once(DOL_DOCUMENT_ROOT.'/lib/price.lib.php'); @@ -503,6 +503,7 @@ class Commande extends CommonObject $ligne=new CommandeLigne($this->db); $ligne->fk_commande=$commandeid; + $ligne->libelle=$libelle; $ligne->desc=$desc; $ligne->price=$price; $ligne->qty=$qty; @@ -1934,11 +1935,12 @@ class CommandeLigne // Insertion dans base de la ligne $sql = 'INSERT INTO '.MAIN_DB_PREFIX.'commandedet'; - $sql.= ' (fk_commande, description, price, qty, tva_tx,'; + $sql.= ' (fk_commande, label, description, price, qty, tva_tx,'; $sql.= ' fk_product, remise_percent, subprice, remise, fk_remise_except, '; $sql.= ' rang, coef,'; $sql.= ' info_bits, total_ht, total_tva, total_ttc)'; $sql.= " VALUES (".$this->fk_commande.","; + $sql.= " '".addslashes($this->libelle)."',"; $sql.= " '".addslashes($this->desc)."',"; $sql.= " '".price2num($this->price)."',"; $sql.= " '".price2num($this->qty)."',"; diff --git a/htdocs/commande/fiche.php b/htdocs/commande/fiche.php index d969221eb8b..36e10bf409e 100644 --- a/htdocs/commande/fiche.php +++ b/htdocs/commande/fiche.php @@ -221,6 +221,8 @@ if ($_POST['action'] == 'addligne' && $user->rights->commande->creer) $prod = new Product($db, $_POST['idprod']); $prod->fetch($_POST['idprod']); + $libelle = $prod->libelle; + // multiprix if ($conf->global->PRODUIT_MULTIPRICES == 1) { @@ -250,6 +252,7 @@ if ($_POST['action'] == 'addligne' && $user->rights->commande->creer) $commande->addline( $_POST['id'], + $libelle, $desc, $pu, $_POST['qty'], diff --git a/htdocs/includes/modules/commande/pdf_einstein.modules.php b/htdocs/includes/modules/commande/pdf_einstein.modules.php index 562b3724d94..2ccc9a159cd 100644 --- a/htdocs/includes/modules/commande/pdf_einstein.modules.php +++ b/htdocs/includes/modules/commande/pdf_einstein.modules.php @@ -206,11 +206,11 @@ class pdf_einstein extends ModelePDFCommandes $libelleproduitservice.=$com->lignes[$i]->desc; } // Si ligne associée à un code produit - if ($com->lignes[$i]->product_id) + if ($com->lignes[$i]->fk_product) { $prodser = new Product($this->db); - $prodser->fetch($com->lignes[$i]->product_id); + $prodser->fetch($com->lignes[$i]->fk_product); if ($prodser->ref) { $libelleproduitservice=$langs->trans("Product")." ".$prodser->ref." - ".$libelleproduitservice; diff --git a/htdocs/lib/functions.inc.php b/htdocs/lib/functions.inc.php index 81c48f945b6..b29ec77ecd3 100644 --- a/htdocs/lib/functions.inc.php +++ b/htdocs/lib/functions.inc.php @@ -1722,14 +1722,14 @@ function get_default_tva($societe_vendeuse, $societe_acheteuse, $taux_produit) { dolibarr_syslog("get_default_tva vendeur_assujeti=$societe_vendeuse->tva_assuj pays_vendeur=$societe_vendeuse->pays_id, pays_acheteur=$societe_acheteuse->pays_id, taux_produit=$taux_produit"); - if (!is_object($societe_vendeuse)) - return 0; + if (!is_object($societe_vendeuse)) return 0; + // Si vendeur non assujeti à TVA (tva_assuj vaut 0/1 ou franchise/reel) if (is_numeric($societe_vendeuse->tva_assuj) && ! $societe_vendeuse->tva_assuj) return 0; if (! is_numeric($societe_vendeuse->tva_assuj) && $societe_vendeuse->tva_assuj=='franchise') return 0; // Si le (pays vendeur = pays acheteur) alors la TVA par défaut=TVA du produit vendu. Fin de règle. - if (($societe_vendeuse->pays_id == $societe_acheteuse->pays_id) && $societe_acheteuse->tva_assuj == 1) + if (is_object($societe_acheteuse) && ($societe_vendeuse->pays_id == $societe_acheteuse->pays_id) && $societe_acheteuse->tva_assuj == 1) { return $taux_produit; } @@ -1738,7 +1738,7 @@ function get_default_tva($societe_vendeuse, $societe_acheteuse, $taux_produit) // Non géré // Si vendeur et acheteur dans Communauté européenne et bien vendu autre que transport neuf alors la TVA par défaut=TVA du produit vendu. Fin de règle. - if (($societe_vendeuse->isInEEC() && $societe_acheteuse->isInEEC()) && $societe_acheteuse->tva_assuj == 1) + if (is_object($societe_acheteuse) && ($societe_vendeuse->isInEEC() && $societe_acheteuse->isInEEC()) && $societe_acheteuse->tva_assuj == 1) { return $taux_produit; }