From a353297207b3a1b98b1e9edbc562c0930b22402c Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 30 Jan 2007 01:20:16 +0000 Subject: [PATCH] =?UTF-8?q?Ajout=20patch=20qui=20transforme=20les=20propri?= =?UTF-8?q?=E9t=E9s=20par=20indice=20de=20tableau=20en=20propri=E9t=E9s=20?= =?UTF-8?q?de=20classe=20d'objets=20Correction=20du=20taux=20de=20tva=20pa?= =?UTF-8?q?r=20d=E9faut=20lors=20de=20creation=20d'un=20facture=20fourniss?= =?UTF-8?q?eur?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- htdocs/fourn/facture/fiche.php | 64 ++++----- htdocs/fourn/fournisseur.commande.class.php | 2 +- htdocs/fourn/fournisseur.facture.class.php | 31 +++-- htdocs/fourn/product/categorie.php | 3 - htdocs/fourn/product/fiche.php | 31 +++-- htdocs/fourn/product/index.php | 15 +- htdocs/fourn/product/photos.php | 7 +- htdocs/html.form.class.php | 146 ++++++++++---------- 8 files changed, 147 insertions(+), 152 deletions(-) diff --git a/htdocs/fourn/facture/fiche.php b/htdocs/fourn/facture/fiche.php index 6faa1b2bfff..d0edc9b02cf 100644 --- a/htdocs/fourn/facture/fiche.php +++ b/htdocs/fourn/facture/fiche.php @@ -366,10 +366,10 @@ if ($_GET['action'] == 'create' or $_GET['action'] == 'copy') { if ($_GET['action'] == 'copy') { - $value_label = $fac_ori->lignes[$i-1][0]; - $value_pu = $fac_ori->lignes[$i-1][1]; - $value_tauxtva = $fac_ori->lignes[$i-1][2]; - $value_qty = $fac_ori->lignes[$i-1][3]; + $value_label = $fac_ori->lignes[$i-1]->description; + $value_pu = $fac_ori->lignes[$i-1]->pu_ht; + $value_tauxtva = $fac_ori->lignes[$i-1]->tva_taux; + $value_qty = $fac_ori->lignes[$i-1]->qty; } else { @@ -491,17 +491,17 @@ else { $var=!$var; // Ligne en modification - if ($_GET['etat'] == '0' && $_GET['ligne_id'] == $fac->lignes[$i][7]) + if ($_GET['etat'] == '0' && $_GET['ligne_id'] == $fac->lignes[$i]->rowid) { - print '
'; - print ''; - print ''; - print ''; + print ''; + print ''; + print ''; + print ''; print ' '; - print ''; - print ''; + print ''; + print ''; print ''; - $html->select_tva('tauxtva',$fac->lignes[$i][2],$societe,$mysoc); + $html->select_tva('tauxtva',$fac->lignes[$i]->tva_taux,$societe,$mysoc); print ''; print ''; print ''; @@ -512,22 +512,22 @@ else } else // Affichage simple de la ligne { - print ''.$fac->lignes[$i][0].''; - print ''.price($fac->lignes[$i][1]).''; - print ''.price($fac->lignes[$i][1] * (1+($fac->lignes[$i][2]/100))).''; - print ''.$fac->lignes[$i][3].''; - print ''.price($fac->lignes[$i][4]).''; - print ''.$fac->lignes[$i][2].''; - print ''.price($fac->lignes[$i][5]).''; - print ''.price($fac->lignes[$i][6]).''; - print ''.img_edit().''; + print ''.$fac->lignes[$i]->description.''; + print ''.price($fac->lignes[$i]->pu_ht).''; + print ''.price($fac->lignes[$i]->pu_ht * (1+($fac->lignes[$i]->tva_taux/100))).''; + print ''.$fac->lignes[$i]->qty.''; + print ''.price($fac->lignes[$i]->total_ht).''; + print ''.$fac->lignes[$i]->tva_taux.''; + print ''.price($fac->lignes[$i]->tva).''; + print ''.price($fac->lignes[$i]->total_ttc).''; + print ''.img_edit().''; if ($conf->global->PRODUIT_CONFIRM_DELETE_LINE) { - print ''.img_delete().''; + print ''.img_delete().''; } else { - print ''.img_delete().''; + print ''.img_delete().''; } print ''; } @@ -750,16 +750,16 @@ else print ''; print ''; - //print ''.img_object($langs->trans("ShowProduct"),'product').' '; - print $fac->lignes[$i][0]; - //print ''; + print ''.img_object($langs->trans("ShowProduct"),'product').' '; + print $fac->lignes[$i]->description; + print ''; print ''; - print ''.price($fac->lignes[$i][1]).''; - print ''.$fac->lignes[$i][3].''; - print ''.price($fac->lignes[$i][4]).''; - print ''.$fac->lignes[$i][2].' %'; - print ''.price($fac->lignes[$i][5]).''; - print ''.price($fac->lignes[$i][6]).''; + print ''.price($fac->lignes[$i]->pu_ht).''; + print ''.$fac->lignes[$i]->qty.''; + print ''.price($fac->lignes[$i]->total_ht).''; + print ''.$fac->lignes[$i]->tva_taux.' %'; + print ''.price($fac->lignes[$i]->tva).''; + print ''.price($fac->lignes[$i]->total_ttc).''; print ''; } print ''; diff --git a/htdocs/fourn/fournisseur.commande.class.php b/htdocs/fourn/fournisseur.commande.class.php index 70d2858c6d3..fb16c5e8e50 100644 --- a/htdocs/fourn/fournisseur.commande.class.php +++ b/htdocs/fourn/fournisseur.commande.class.php @@ -113,7 +113,7 @@ class CommandeFournisseur extends Commande $this->lignes = array(); $sql = 'SELECT l.fk_product, l.description, l.price, l.qty, l.rowid, l.tva_tx, l.remise_percent, l.subprice,'; - $sql.= ' p.label, p.description as product_desc, p.ref, p.fk_product_type, p.rowid as prodid'; + $sql.= ' p.label, p.description as product_desc, p.ref, p.rowid as prodid'; $sql.= ' FROM '.MAIN_DB_PREFIX.'commande_fournisseurdet as l'; $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON l.fk_product=p.rowid'; $sql.= ' WHERE l.fk_commande = '.$this->id; diff --git a/htdocs/fourn/fournisseur.facture.class.php b/htdocs/fourn/fournisseur.facture.class.php index 94ceaaa74c0..40af8a8446b 100644 --- a/htdocs/fourn/fournisseur.facture.class.php +++ b/htdocs/fourn/fournisseur.facture.class.php @@ -122,10 +122,10 @@ class FactureFournisseur extends Facture { $idligne = $this->db->last_insert_id(MAIN_DB_PREFIX.'facture_fourn_det'); $this->updateline($idligne, - $this->lignes[$i][0], - $this->lignes[$i][1], - $this->lignes[$i][2], - $this->lignes[$i][3]); + $this->lignes[$i]->description, + $this->lignes[$i]->pu_ht, + $this->lignes[$i]->tva_taux, + $this->lignes[$i]->qty); } } // Mise à jour prix @@ -206,7 +206,7 @@ class FactureFournisseur extends Facture /* * Lignes */ - $sql = 'SELECT rowid, description, pu_ht, qty, tva_taux, tva, total_ht, total_ttc'; + $sql = 'SELECT rowid, description, pu_ht, qty, tva_taux, tva, total_ht, total_ttc, fk_product'; $sql .= ' FROM '.MAIN_DB_PREFIX.'facture_fourn_det'; $sql .= ' WHERE fk_facture_fourn='.$this->id; $resql_rows = $this->db->query($sql); @@ -219,15 +219,15 @@ class FactureFournisseur extends Facture while ($i < $num_rows) { $obj = $this->db->fetch_object($resql_rows); - $this->lignes[$i][0] = $obj->description; - $this->lignes[$i][1] = $obj->pu_ht; - $this->lignes[$i][2] = $obj->tva_taux; - $this->lignes[$i][3] = $obj->qty; - $this->lignes[$i][4] = $obj->total_ht; - $this->lignes[$i][5] = $obj->tva; - $this->lignes[$i][6] = $obj->total_ttc; - $this->lignes[$i][7] = $obj->rowid; - $this->lignes[$i][8] = $obj->total_tva; + $this->lignes[$i]->description = $obj->description; + $this->lignes[$i]->pu_ht = $obj->pu_ht; + $this->lignes[$i]->tva_taux = $obj->tva_taux; + $this->lignes[$i]->qty = $obj->qty; + $this->lignes[$i]->total_ht = $obj->total_ht; + $this->lignes[$i]->tva = $obj->tva; + $this->lignes[$i]->total_ttc = $obj->total_ttc; + $this->lignes[$i]->rowid = $obj->rowid; + $this->lignes[$i]->total_tva = $obj->total_tva; $i++; } } @@ -347,8 +347,9 @@ class FactureFournisseur extends Facture * \param pu prix unitaire * \param tauxtva taux de tva * \param qty quantité + * \param idproduct id produit */ - function addline($desc, $pu, $tauxtva, $qty, $idproduct) + function addline($desc, $pu, $tauxtva, $qty, $idproduct=0) { $sql = 'INSERT INTO '.MAIN_DB_PREFIX.'facture_fourn_det (fk_facture_fourn)'; $sql .= ' VALUES ('.$this->id.');'; diff --git a/htdocs/fourn/product/categorie.php b/htdocs/fourn/product/categorie.php index d326793b0a7..1e8fd9b3a62 100644 --- a/htdocs/fourn/product/categorie.php +++ b/htdocs/fourn/product/categorie.php @@ -28,9 +28,6 @@ $mesg = ''; if (!$user->rights->produit->lire) accessforbidden(); -$types[0] = $langs->trans("Product"); -$types[1] = $langs->trans("Service"); - /* * Creation de l'objet produit correspondant à l'id */ diff --git a/htdocs/fourn/product/fiche.php b/htdocs/fourn/product/fiche.php index eb05cf75281..ca045e6a2bb 100644 --- a/htdocs/fourn/product/fiche.php +++ b/htdocs/fourn/product/fiche.php @@ -40,9 +40,6 @@ $mesg = ''; if (!$user->rights->produit->lire) accessforbidden(); -$types[0] = $langs->trans("Product"); -$types[1] = $langs->trans("Service"); - /* * */ @@ -221,7 +218,7 @@ if ($_GET["action"] == 'create' && $user->rights->produit->creer) print ''."\n"; print ''."\n"; - if ($_GET["type"]==0) { $title=$langs->trans("NewProduct"); } + if ($_GET["type"]!=1) { $title=$langs->trans("NewProduct"); } if ($_GET["type"]==1) { $title=$langs->trans("NewService"); } print_fiche_titre($title); @@ -251,7 +248,7 @@ if ($_GET["action"] == 'create' && $user->rights->produit->creer) print ''; print ''.$langs->trans("Label").''; - if ($_GET["type"] == 0 && $conf->stock->enabled) + if ($_GET["type"] != 1 && $conf->stock->enabled) { print "".'Seuil stock'; print ''; @@ -308,7 +305,7 @@ else $hselected = $h; $h++; - if($product->type == 0) + if($product->isproduct()) { if ($conf->stock->enabled) { @@ -368,8 +365,8 @@ else print ''.$langs->trans("SellingPrice").''.price($product->price).''; $nblignefour=2; - if ($product->type == 0 && $conf->stock->enabled) $nblignefour++; - if ($product->type == 1) $nblignefour++; + if ($product->isproduct() && $conf->stock->enabled) $nblignefour++; + if ($product->isservice()) $nblignefour++; print ''; $product->show_photos($conf->produit->dir_output,1,1,0); @@ -379,7 +376,7 @@ else print ''.$langs->trans("Description").''.nl2br($product->description).''; // Stock - if ($product->type == 0 && $conf->stock->enabled) + if ($product->isproduct() && $conf->stock->enabled) { print ''.$langs->trans("Stock").''; if ($product->no_stock) @@ -401,7 +398,7 @@ else } // Duration - if ($product->type == 1) + if ($product->isservice()) { print ''.$langs->trans("Duration").''.$product->duration_value.' '; @@ -512,7 +509,11 @@ else if (($_GET["action"] == 'edit' || $_GET["action"] == 're-edit') && $user->rights->produit->creer) { - print_fiche_titre('Edition de la fiche '.$types[$product->type].' : '.$product->ref, ""); + if ($product->isservice()) { + print_fiche_titre($langs->trans('Edit').' '.$langs->trans('Service').' : '.$product->ref, ""); + } else { + print_fiche_titre($langs->trans('Edit').' '.$langs->trans('Product').' : '.$product->ref, ""); + } if ($mesg) { print '
'.$mesg.'

'; @@ -526,7 +527,7 @@ else print ''.$langs->trans("Label").''; - if ($product->type == 0 && $conf->stock->enabled) + if ($product->isproduct() && $conf->stock->enabled) { print "".'Seuil stock'; print ''; @@ -541,7 +542,7 @@ else print $product->description; print ""; - if ($product->type == 1) + if ($product->isservice()) { print ''.$langs->trans("Duration").''; print '  '; @@ -580,14 +581,14 @@ else print ''.$langs->trans("Edit").''; } - if ($product->type == 0 && $conf->stock->enabled) + if ($product->isproduct() && $conf->stock->enabled) { print ''.$langs->trans("CorrectStock").''; } print ''.$langs->trans("AddSupplier").''; - if ($product->type == 0 && $user->rights->commande->creer) + if ($product->isproduct() && $user->rights->commande->creer) { $langs->load('orders'); print ''; diff --git a/htdocs/fourn/product/index.php b/htdocs/fourn/product/index.php index 28d831024b7..397c042cf29 100644 --- a/htdocs/fourn/product/index.php +++ b/htdocs/fourn/product/index.php @@ -96,11 +96,11 @@ print ''; /* - * Derniers produits/services en vente + * Derniers produits en vente */ -$sql = "SELECT p.rowid, p.label, p.price, p.ref, p.fk_product_type"; +$sql = "SELECT p.rowid, p.label, p.price, p.ref, p.type"; $sql .= " FROM ".MAIN_DB_PREFIX."product as p "; -$sql .= " WHERE p.fk_product_type=0"; +$sql .= " WHERE p.fk_product_type <> 1"; $sql .= " ORDER BY p.datec DESC "; $sql .= $db->plimit(15 ,0); @@ -112,9 +112,6 @@ if ($resql) $i = 0; - $typeprodser[0]=$langs->trans("Product"); - $typeprodser[1]=$langs->trans("Service"); - if ($num > 0) { print ''; @@ -132,8 +129,10 @@ if ($resql) else print img_object($langs->trans("ShowProduct"),"product"); print "rowid\">$objp->ref\n"; print ""; - print ""; - print "\n"; + print "\n"; $i++; } $db->free($resql); diff --git a/htdocs/fourn/product/photos.php b/htdocs/fourn/product/photos.php index 20e237f8a1e..b878e7aa5c3 100644 --- a/htdocs/fourn/product/photos.php +++ b/htdocs/fourn/product/photos.php @@ -35,9 +35,6 @@ require_once(DOL_DOCUMENT_ROOT."/product.class.php"); if (!$user->rights->produit->lire) accessforbidden(); -$types[0] = $langs->trans("Product"); -$types[1] = $langs->trans("Service"); - /* * */ @@ -118,7 +115,7 @@ if ($_GET["id"]) * Ajouter une photo * */ - if ($_GET["action"] == 'ajout_photo' && $user->rights->produit->creer && $product->isproduct && $conf->upload) + if ($_GET["action"] == 'ajout_photo' && $user->rights->produit->creer && $product->isproduct() && $conf->upload) { print_titre($langs->trans("AddPhoto")); @@ -202,7 +199,7 @@ if ($_GET["id"]) if ($_GET["action"] == '') { - if ( $user->rights->produit->creer && $product->isproduct && $conf->upload) + if ( $user->rights->produit->creer && $product->isproduct() && $conf->upload) { print ''; print $langs->trans("AddPhoto").''; diff --git a/htdocs/html.form.class.php b/htdocs/html.form.class.php index 3b6d914d68e..c90c2f2c280 100644 --- a/htdocs/html.form.class.php +++ b/htdocs/html.form.class.php @@ -2014,81 +2014,81 @@ class Form * Sinon la TVA proposée par défaut=0. Fin de règle. */ function select_tva($name='tauxtva', $defaulttx='', $societe_vendeuse='', $societe_acheteuse='', $taux_produit='') - { - global $langs,$conf,$mysoc; + { + global $langs,$conf,$mysoc; - //print $societe_vendeuse."-".$societe_acheteuse; - if (is_object($societe_vendeuse) && ! $societe_vendeuse->pays_code) - { - if ($societe_vendeuse->id == $mysoc->id) - { - print ''.$langs->trans("ErrorYourCountryIsNotDefined").''; - } - else - { - print ''.$langs->trans("ErrorSupplierCountryIsNotDefined").''; - } - return; - } - - if (is_object($societe_vendeuse->pays_code)) - { - $code_pays=$societe_vendeuse->pays_code; + //print $societe_vendeuse."-".$societe_acheteuse; + if (is_object($societe_vendeuse) && ! $societe_vendeuse->pays_code) + { + if ($societe_vendeuse->id == $mysoc->id) + { + print ''.$langs->trans("ErrorYourCountryIsNotDefined").''; + } + else + { + print ''.$langs->trans("ErrorSupplierCountryIsNotDefined").''; + } + return; + } + + if (is_object($societe_vendeuse)) + { + $code_pays=$societe_vendeuse->pays_code; + } + else + { + $code_pays=$mysoc->pays_code; // Pour compatibilite ascendente + } + + // Recherche liste des codes TVA du pays vendeur + $sql = "SELECT t.taux,t.recuperableonly"; + $sql .= " FROM ".MAIN_DB_PREFIX."c_tva as t, ".MAIN_DB_PREFIX."c_pays as p"; + $sql .= " WHERE t.fk_pays = p.rowid AND p.code = '".$code_pays."'"; + $sql .= " AND t.active = 1"; + $sql .= " ORDER BY t.taux ASC, t.recuperableonly ASC"; + + $resql=$this->db->query($sql); + if ($resql) + { + $num = $this->db->num_rows($resql); + for ($i = 0; $i < $num; $i++) + { + $obj = $this->db->fetch_object($resql); + $txtva[ $i ] = $obj->taux; + $libtva[ $i ] = $obj->taux.'%'.($obj->recuperableonly ? ' *':''); + } + } + else + { + print ''.$langs->trans("ErrorNoVATRateDefinedForSellerCountry").''; + } + + // Définition du taux à présélectionner + if ($defaulttx == '') $defaulttx=get_default_tva($societe_vendeuse,$societe_acheteuse,$taux_produit); + // Si taux par defaut n'a pu etre trouvé, on prend dernier. + // Comme ils sont triés par ordre croissant, dernier = plus élevé = taux courant + if ($defaulttx == '') $defaulttx = $txtva[sizeof($txtva)-1]; + + $nbdetaux = sizeof($txtva); + + print ''; } - else - { - $code_pays=$mysoc->pays_code; // Pour compatibilite ascendente - } - - // Recherche liste des codes TVA du pays vendeur - $sql = "SELECT t.taux,t.recuperableonly"; - $sql .= " FROM ".MAIN_DB_PREFIX."c_tva as t, ".MAIN_DB_PREFIX."c_pays as p"; - $sql .= " WHERE t.fk_pays = p.rowid AND p.code = '".$code_pays."'"; - $sql .= " AND t.active = 1"; - $sql .= " ORDER BY t.taux ASC, t.recuperableonly ASC"; - - $resql=$this->db->query($sql); - if ($resql) - { - $num = $this->db->num_rows($resql); - for ($i = 0; $i < $num; $i++) - { - $obj = $this->db->fetch_object($resql); - $txtva[ $i ] = $obj->taux; - $libtva[ $i ] = $obj->taux.'%'.($obj->recuperableonly ? ' *':''); - } - } - else - { - print ''.$langs->trans("ErrorNoVATRateDefinedForSellerCountry").''; - } - - // Définition du taux à présélectionner - if ($defaulttx == '') $defaulttx=get_default_tva($societe_vendeuse,$societe_acheteuse,$taux_produit); - // Si taux par defaut n'a pu etre trouvé, on prend dernier. - // Comme ils sont triés par ordre croissant, dernier = plus élevé = taux courant - if ($defaulttx == '') $defaulttx = $txtva[sizeof($txtva)-1]; - - $nbdetaux = sizeof($txtva); - - print ''; - }
$objp->label".$typeprodser[$objp->fk_product_type]."
"; + if ($objp->fk_product_type==1) print $langs->trans('ShowService'); + else print $langs->trans('ShowProduct'); + print "