From 8d8cf0cd218930680d2e354606aa96510d1428e9 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 17 Aug 2010 08:20:12 +0000 Subject: [PATCH] Fix: Lost permission --- htdocs/includes/modules/modProduct.class.php | 200 +++++ htdocs/includes/modules/modService.class.php | 10 +- htdocs/product/fiche.php | 838 +++++++++---------- 3 files changed, 583 insertions(+), 465 deletions(-) create mode 100644 htdocs/includes/modules/modProduct.class.php diff --git a/htdocs/includes/modules/modProduct.class.php b/htdocs/includes/modules/modProduct.class.php new file mode 100644 index 00000000000..bb4901e838d --- /dev/null +++ b/htdocs/includes/modules/modProduct.class.php @@ -0,0 +1,200 @@ + + * Copyright (C) 2004-2010 Laurent Destailleur + * Copyright (C) 2004 Sebastien Di Cintio + * Copyright (C) 2004 Benoit Mortier + * Copyright (C) 2005-2009 Regis Houssin + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +/** + * \defgroup produit Module products + * \brief Module pour gerer le suivi de produits predefinis + * \version $Id$ + */ + +/** + * \file htdocs/includes/modules/modProduct.class.php + * \ingroup produit + * \brief Fichier de description et activation du module Produit + */ + +include_once(DOL_DOCUMENT_ROOT ."/includes/modules/DolibarrModules.class.php"); + + +/** + * \class modProduct + * \brief Classe de description et activation du module Produit + */ +class modProduct extends DolibarrModules +{ + /** + * \brief Constructeur. Definit les noms, constantes et boites + * \param DB handler d'acces base + */ + function modProduct($DB) + { + global $conf; + + $this->db = $DB; + $this->numero = 50; + + $this->family = "products"; + // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module) + $this->name = preg_replace('/^mod/i','',get_class($this)); + $this->description = "Gestion des produits"; + + // Possible values for version are: 'development', 'experimental', 'dolibarr' or version + $this->version = 'dolibarr'; + + $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); + $this->special = 0; + $this->picto='product'; + + // Data directories to create when module is enabled + $this->dirs = array("/product/temp"); + + // Dependencies + $this->depends = array(); + $this->requiredby = array("modStock","modBarcode"); + + // Config pages + $this->config_page_url = array("produit.php@product"); + $this->langfiles = array("products","companies","stocks","bills"); + + // Constants + $this->const = array(); + $r=0; + + $this->const[$r][0] = "MAIN_SEARCHFORM_PRODUITSERVICE"; + $this->const[$r][1] = "yesno"; + $this->const[$r][2] = "1"; + $this->const[$r][3] = "Affichage formulaire de recherche des Produits et Services dans la barre de gauche"; + $this->const[$r][4] = 0; + $this->const[$r][5] = 'allentities'; + $r++; + + // Boxes + $this->boxes = array(); + $this->boxes[0][1] = "box_produits.php"; + + // Permissions + $this->rights = array(); + $this->rights_class = 'produit'; + $r=0; + + $this->rights[$r][0] = 31; // id de la permission + $this->rights[$r][1] = 'Lire les produits'; // libelle de la permission + $this->rights[$r][2] = 'r'; // type de la permission (deprecie a ce jour) + $this->rights[$r][3] = 1; // La permission est-elle une permission par defaut + $this->rights[$r][4] = 'lire'; + $r++; + + $this->rights[$r][0] = 32; // id de la permission + $this->rights[$r][1] = 'Creer/modifier les produits'; // libelle de la permission + $this->rights[$r][2] = 'w'; // type de la permission (deprecie a ce jour) + $this->rights[$r][3] = 0; // La permission est-elle une permission par defaut + $this->rights[$r][4] = 'creer'; + $r++; + + $this->rights[$r][0] = 34; // id de la permission + $this->rights[$r][1] = 'Supprimer les produits'; // libelle de la permission + $this->rights[$r][2] = 'd'; // type de la permission (deprecie a ce jour) + $this->rights[$r][3] = 0; // La permission est-elle une permission par defaut + $this->rights[$r][4] = 'supprimer'; + $r++; + + $this->rights[$r][0] = 36; // id de la permission + $this->rights[$r][1] = 'Voir/gérer les produits cachés'; // libelle de la permission + $this->rights[$r][2] = 'r'; // type de la permission (deprecated) + $this->rights[$r][3] = 1; // La permission est-elle une permission par defaut + $this->rights[$r][4] = 'hidden'; + $r++; + + $this->rights[$r][0] = 38; // Must be same permission than in service module + $this->rights[$r][1] = 'Exporter les produits'; + $this->rights[$r][2] = 'r'; + $this->rights[$r][3] = 0; + $this->rights[$r][4] = 'export'; + $r++; + + + // Exports + //-------- + $r=0; + + $r++; + $this->export_code[$r]=$this->rights_class.'_'.$r; + $this->export_label[$r]="Products"; // Translation key (used only if key ExportDataset_xxx_z not found) + $this->export_permission[$r]=array(array("produit","export")); + $this->export_fields_array[$r]=array('p.rowid'=>"Id",'p.ref'=>"Ref",'p.label'=>"Label",'p.description'=>"Description",'p.accountancy_code_sell'=>"ProductAccountancySellCode",'p.accountancy_code_buy'=>"ProductAccountancyBuyCode",'p.note'=>"Note",'p.length'=>"Length",'p.surface'=>"Surface",'p.volume'=>"Volume",'p.weight'=>"Weight",'p.price_base_type'=>"PriceBase",'p.price'=>"UnitPriceHT",'p.price_ttc'=>"UnitPriceTTC",'p.tva_tx'=>'VATRate','p.envente'=>"OnSell",'p.datec'=>'DateCreation','p.tms'=>'DateModification'); + if (! empty($conf->stock->enabled)) $this->export_fields_array[$r]=array_merge ($this->export_fields_array[$r],array('p.stock'=>'Stock','p.pmp'=>'PMPValue')); + if (! empty($conf->barcode->enabled)) $this->export_fields_array[$r]=array_merge ($this->export_fields_array[$r],array('p.barcode'=>'Barcode')); + $this->export_entities_array[$r]=array('p.rowid'=>"product",'p.ref'=>"product",'p.label'=>"product",'p.description'=>"product",'p.accountancy_code_sell'=>'product','p.accountancy_code_sell'=>'product','p.note'=>"product",'p.length'=>"product",'p.surface'=>"product",'p.volume'=>"product",'p.weight'=>"product",'p.price_base_type'=>"product",'p.price'=>"product",'p.price_ttc'=>"product",'p.tva_tx'=>"product",'p.envente'=>"product",'p.datec'=>"product",'p.tms'=>"product"); + if (! empty($conf->stock->enabled)) $this->export_entities_array[$r]=array_merge ($this->export_entities_array[$r],array('p.stock'=>'product','p.pmp'=>'product')); + if (! empty($conf->barcode->enabled)) $this->export_entities_array[$r]=array_merge ($this->export_entities_array[$r],array('p.barcode'=>'product')); + $this->export_alias_array[$r]=array('p.rowid'=>"id",'p.ref'=>"ref",'p.label'=>"label",'p.description'=>"description",'p.accountancy_code_sell'=>'accountancy_code_sell','p.accountancy_code_buy'=>'accountancy_code_buy','p.note'=>"note",'p.length'=>"length",'p.surface'=>"area",'p.volume'=>"volume",'p.weight'=>"weight",'p.price_base_type'=>'pricebase','p.price'=>"priceht",'p.price_ttc'=>"pricettc",'p.tva_tx'=>'vat','p.envente'=>"onsell",'p.datec'=>'datecreation','p.tms'=>'datemodification'); + if (! empty($conf->stock->enabled)) $this->export_alias_array[$r]=array_merge ($this->export_alias_array[$r],array('p.stock'=>'stock','p.pmp'=>'pmp')); + if (! empty($conf->barcode->enabled)) $this->export_alias_array[$r]=array_merge ($this->export_alias_array[$r],array('p.barcode'=>'barcode')); + + $this->export_sql_start[$r]='SELECT DISTINCT '; + $this->export_sql_end[$r] =' FROM '.MAIN_DB_PREFIX.'product as p'; + $this->export_sql_end[$r] .=' WHERE p.fk_product_type = 0 AND p.entity = '.$conf->entity; + + + // Imports + //-------- + $r=0; + + $r++; + $this->import_code[$r]=$this->rights_class.'_'.$r; + $this->import_label[$r]="Products"; // Translation key + $this->import_icon[$r]='product'; + $this->import_tables_array[$r]=array('p'=>MAIN_DB_PREFIX.'product'); + $this->import_tables_creator_array[$r]=array('p'=>'fk_user_author'); // Fields to store import user id + $this->import_fields_array[$r]=array('p.ref'=>"Ref*",'p.label'=>"Label*",'p.description'=>"Description",'p.note'=>"Note",'p.price'=>"SellingPriceHT",'p.price_ttc'=>"SellingPriceTTC",'p.tva_tx'=>'VAT','p.envente'=>"OnSell*",'p.fk_product_type'=>"Type*",'p.finished'=>'Nature','p.duration'=>"Duration",'p.weight'=>"Weight",'p.volume'=>"Volume",'p.datec'=>'DateCreation*'); + $this->import_entities_array[$r]=array(); // We define here only fields that use another picto + $this->import_regex_array[$r]=array('p.ref'=>'[^ ]','p.envente'=>'^[0|1]','p.fk_product_type'=>'^[0|1]','p.datec'=>'^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]$'); + $this->import_examplevalues_array[$r]=array('p.ref'=>"PR123456",'p.label'=>"My product",'p.description'=>"This is a description example for record",'p.note'=>"Some note",'p.price'=>"100",'p.price_ttc'=>"110",'p.tva_tx'=>'10','p.envente'=>"0 or 1",'p.fk_product_type'=>"0 for product, 1 for service",'p.finished'=>'','p.duration'=>"1y",'p.datec'=>'2008-12-31'); + } + + + /** + * \brief Fonction appelee lors de l'activation du module. Insere en base les constantes, boites, permissions du module. + * Definit egalement les repertoires de donnees a creer pour ce module. + */ + function init() + { + // Permissions + $this->remove(); + + $sql = array(); + + return $this->_init($sql); + } + + /** + * \brief Fonction appelee lors de la desactivation d'un module. + * Supprime de la base les constantes, boites et permissions du module. + */ + function remove() + { + $sql = array(); + + return $this->_remove($sql); + } +} +?> diff --git a/htdocs/includes/modules/modService.class.php b/htdocs/includes/modules/modService.class.php index da4a54b977c..7ec52a14415 100644 --- a/htdocs/includes/modules/modService.class.php +++ b/htdocs/includes/modules/modService.class.php @@ -73,7 +73,7 @@ class modService extends DolibarrModules $this->requiredby = array("modContrat"); // Config pages - $this->config_page_url = array("produit.php"); + $this->config_page_url = array("produit.php@product"); $this->langfiles = array("products","companies","bills"); // Constants @@ -88,26 +88,26 @@ class modService extends DolibarrModules $this->rights_class = 'service'; $r=0; - $r++; $this->rights[$r][0] = 531; // id de la permission $this->rights[$r][1] = 'Lire les services'; // libelle de la permission $this->rights[$r][2] = 'r'; // type de la permission (deprecie a ce jour) $this->rights[$r][3] = 1; // La permission est-elle une permission par defaut $this->rights[$r][4] = 'lire'; + $r++; - $r++; $this->rights[$r][0] = 532; // id de la permission $this->rights[$r][1] = 'Creer/modifier les services'; // libelle de la permission $this->rights[$r][2] = 'w'; // type de la permission (deprecie a ce jour) $this->rights[$r][3] = 0; // La permission est-elle une permission par defaut $this->rights[$r][4] = 'creer'; + $r++; - $r++; $this->rights[$r][0] = 534; // id de la permission $this->rights[$r][1] = 'Supprimer les services'; // libelle de la permission $this->rights[$r][2] = 'd'; // type de la permission (deprecie a ce jour) $this->rights[$r][3] = 0; // La permission est-elle une permission par defaut $this->rights[$r][4] = 'supprimer'; + $r++; $this->rights[$r][0] = 536; // id de la permission $this->rights[$r][1] = 'Voir/gérer les services cachés'; // libelle de la permission @@ -116,12 +116,12 @@ class modService extends DolibarrModules $this->rights[$r][4] = 'hidden'; $r++; - $r++; $this->rights[$r][0] = 538; // Must be same permission than in product module $this->rights[$r][1] = 'Exporter les services'; $this->rights[$r][2] = 'r'; $this->rights[$r][3] = 0; $this->rights[$r][4] = 'export'; + $r++; // Exports diff --git a/htdocs/product/fiche.php b/htdocs/product/fiche.php index 62f01e95141..a55ec11c734 100644 --- a/htdocs/product/fiche.php +++ b/htdocs/product/fiche.php @@ -30,16 +30,18 @@ */ require("../main.inc.php"); -require_once(DOL_DOCUMENT_ROOT."/product/html.formproduct.class.php"); +require_once(DOL_DOCUMENT_ROOT."/core/class/canvas.class.php"); +require_once(DOL_DOCUMENT_ROOT."/product/class/product.class.php"); +require_once(DOL_DOCUMENT_ROOT."/product/class/html.formproduct.class.php"); require_once(DOL_DOCUMENT_ROOT."/lib/product.lib.php"); -require_once(DOL_DOCUMENT_ROOT."/comm/propal/propal.class.php"); -require_once(DOL_DOCUMENT_ROOT."/compta/facture/facture.class.php"); -require_once(DOL_DOCUMENT_ROOT."/product/product.class.php"); -require_once(DOL_DOCUMENT_ROOT."/commande/commande.class.php"); +if ($conf->propal->enabled) require_once(DOL_DOCUMENT_ROOT."/comm/propal/class/propal.class.php"); +if ($conf->facture->enabled) require_once(DOL_DOCUMENT_ROOT."/compta/facture/class/facture.class.php"); +if ($conf->commande->enabled) require_once(DOL_DOCUMENT_ROOT."/commande/class/commande.class.php"); -$langs->load("bills"); +$langs->load("products"); $langs->load("other"); -$langs->load("stocks"); +if ($conf->stock->enabled) $langs->load("stocks"); +if ($conf->facture->enabled) $langs->load("bills"); // Security check if (isset($_GET["id"]) || isset($_GET["ref"])) @@ -50,6 +52,13 @@ $fieldid = isset($_GET["ref"])?'ref':'rowid'; $socid=$user->societe_id?$user->societe_id:0; $result=restrictedArea($user,'produit|service',$id,'product','','',$fieldid); +// For canvas usage +if (empty($_GET["canvas"])) +{ + $_GET["canvas"] = 'default@product'; + if ($_GET["type"] == 1) $_GET["canvas"] = 'service@product'; +} + $mesg = ''; @@ -106,32 +115,32 @@ if ($_POST["action"] == 'add' && ($user->rights->produit->creer || $user->rights { $mesg='
'.$langs->trans('ErrorFieldRequired',$langs->transnoentities('Label')).'
'; $_GET["action"] = "create"; - $_GET["canvas"] = $product->canvas; - $_GET["type"] = $_POST["type"]; + $_GET["canvas"] = $_POST["canvas"]; + $_GET["type"] = $_POST["type"]; $error++; } if (empty($_POST["ref"])) { $mesg='
'.$langs->trans('ErrorFieldRequired',$langs->transnoentities('Ref')).'
'; $_GET["action"] = "create"; - $_GET["canvas"] = $product->canvas; - $_GET["type"] = $_POST["type"]; + $_GET["canvas"] = $_POST["canvas"]; + $_GET["type"] = $_POST["type"]; $error++; } + $product=new Product($db); + + $usecanvas=$_POST["canvas"]; + if (empty($conf->global->MAIN_USE_CANVAS)) $usecanvas=0; + + if (! empty($usecanvas)) // Overwrite product here + { + $canvas = new Canvas($db,$user); + $product = $canvas->load_canvas('product',$_POST["canvas"]); + } + if (! $error) { - if ($_POST["canvas"] <> '' && file_exists('canvas/'.$_POST["canvas"].'/product.'.$_POST["canvas"].'.class.php') ) - { - $classname = 'Product'.ucfirst($_POST["canvas"]); - include_once('canvas/'.$_POST["canvas"].'/product.'.$_POST["canvas"].'.class.php'); - $product = new $classname($db); - } - else - { - $product = new Product($db); - } - $product->ref = $_POST["ref"]; $product->libelle = $_POST["libelle"]; $product->price_base_type = $_POST["price_base_type"]; @@ -140,29 +149,29 @@ if ($_POST["action"] == 'add' && ($user->rights->produit->creer || $user->rights if ($product->price_base_type == 'TTC') $product->price_min_ttc = $_POST["price_min"]; else $product->price_min = $_POST["price_min"]; $product->tva_tx = $_POST["tva_tx"]; - + // local taxes. - $product->localtax1_tx = get_localtax($product->tva_tx,1); - $product->localtax2_tx = get_localtax($product->tva_tx,2); - - $product->type = $_POST["type"]; - $product->status = $_POST["statut"]; - $product->description = dol_htmlcleanlastbr($_POST["desc"]); - $product->note = dol_htmlcleanlastbr($_POST["note"]); - $product->duration_value = $_POST["duration_value"]; - $product->duration_unit = $_POST["duration_unit"]; - $product->seuil_stock_alerte = $_POST["seuil_stock_alerte"]; - $product->canvas = $_POST["canvas"]; - $product->weight = $_POST["weight"]; - $product->weight_units = $_POST["weight_units"]; - $product->length = $_POST["size"]; - $product->length_units = $_POST["size_units"]; - $product->surface = $_POST["surface"]; - $product->surface_units = $_POST["surface_units"]; - $product->volume = $_POST["volume"]; - $product->volume_units = $_POST["volume_units"]; - $product->finished = $_POST["finished"]; - $product->hidden = $_POST["hidden"]=='yes'?1:0; + $product->localtax1_tx = get_localtax($product->tva_tx,1); + $product->localtax2_tx = get_localtax($product->tva_tx,2); + + $product->type = $_POST["type"]; + $product->status = $_POST["statut"]; + $product->description = dol_htmlcleanlastbr($_POST["desc"]); + $product->note = dol_htmlcleanlastbr($_POST["note"]); + $product->duration_value = $_POST["duration_value"]; + $product->duration_unit = $_POST["duration_unit"]; + $product->seuil_stock_alerte = $_POST["seuil_stock_alerte"]?$_POST["seuil_stock_alerte"]:0; + $product->canvas = $_POST["canvas"]; + $product->weight = $_POST["weight"]; + $product->weight_units = $_POST["weight_units"]; + $product->length = $_POST["size"]; + $product->length_units = $_POST["size_units"]; + $product->surface = $_POST["surface"]; + $product->surface_units = $_POST["surface_units"]; + $product->volume = $_POST["volume"]; + $product->volume_units = $_POST["volume_units"]; + $product->finished = $_POST["finished"]; + $product->hidden = $_POST["hidden"]=='yes'?1:0; // MultiPrix if($conf->global->PRODUIT_MULTIPRICES) @@ -181,8 +190,6 @@ if ($_POST["action"] == 'add' && ($user->rights->produit->creer || $user->rights } } - if ( $value != $current_lang ) $e_product = $product; - $id = $product->create($user); if ($id > 0) @@ -209,7 +216,17 @@ if ($_POST["action"] == 'update' && ($user->rights->produit->creer || $user->rig } else { - $product = new Product($db); + $product=new Product($db); + + $usecanvas=$_POST["canvas"]; + if (empty($conf->global->MAIN_USE_CANVAS)) $usecanvas=0; + + if (! empty($usecanvas)) // Overwrite product here + { + $canvas = new Canvas($db,$user); + $product = $canvas->load_canvas('product',$_POST["canvas"]); + } + if ($product->fetch($_POST["id"])) { $product->ref = $_POST["ref"]; @@ -252,19 +269,6 @@ if ($_POST["action"] == 'update' && ($user->rights->produit->creer || $user->rig $_GET["id"] = $_POST["id"]; $mesg = $langs->trans("ErrorProductBadRefOrLabel"); } - - // Specific product - if ($product->canvas <> '' && file_exists('canvas/'.$product->canvas.'/product.'.$product->canvas.'.class.php') ) - { - $classname = 'Product'.ucfirst($product->canvas); - include_once('canvas/'.$product->canvas.'/product.'.$product->canvas.'.class.php'); - - $product = new $classname($db); - if ($product->FetchCanvas($_POST["id"])) - { - $product->UpdateCanvas($_POST); - } - } } } } @@ -359,7 +363,7 @@ if ($_REQUEST['action'] == 'confirm_delete' && $_REQUEST['confirm'] == 'yes' && */ if ($_POST["action"] == 'addinpropal') { - $propal = New Propal($db); + $propal = new Propal($db); $result=$propal->fetch($_POST["propalid"]); if ($result <= 0) { @@ -384,23 +388,22 @@ if ($_POST["action"] == 'addinpropal') } $desc = $prod->description; - $tva_tx = get_default_tva($mysoc,$soc,$prod->tva_tx); - $price_base_type = 'HT'; + $tva_tx = get_default_tva($mysoc, $soc, $prod->id); + $localtax1_tx= get_localtax($tva_tx, 1, $soc); + $localtax2_tx= get_localtax($tva_tx, 2, $soc); - // multiprix + $pu_ht = $prod->price; + $pu_ttc = $prod->price_ttc; + $price_base_type = $prod->price_base_type; + + // If multiprice if ($conf->global->PRODUIT_MULTIPRICES && $soc->price_level) { $pu_ht = $prod->multiprices[$soc->price_level]; $pu_ttc = $prod->multiprices_ttc[$soc->price_level]; $price_base_type = $prod->multiprices_base_type[$soc->price_level]; } - else - { - $pu_ht = $prod->price; - $pu_ttc = $prod->price_ttc; - $price_base_type = $prod->price_base_type; - } // On reevalue prix selon taux tva car taux tva transaction peut etre different // de ceux du produit par defaut (par exemple si pays different entre vendeur et acheteur). @@ -421,6 +424,8 @@ if ($_POST["action"] == 'addinpropal') $pu_ht, $_POST["qty"], $tva_tx, + $localtax1_tx, // localtax1 + $localtax2_tx, // localtax2 $prod->id, $_POST["remise_percent"], $price_base_type, @@ -428,7 +433,7 @@ if ($_POST["action"] == 'addinpropal') ); if ($result > 0) { - Header("Location: ".DOL_URL_ROOT."/comm/propal.php?propalid=".$propal->id); + Header("Location: ".DOL_URL_ROOT."/comm/propal.php?id=".$propal->id); return; } @@ -465,21 +470,23 @@ if ($_POST["action"] == 'addincommande') } $desc = $prod->description; - $tva_tx = get_default_tva($mysoc,$soc,$prod->tva_tx); - // multiprix - if ($conf->global->PRODUIT_MULTIPRICES && $soc->price_level) - { - $pu_ht = $prod->multiprices[$soc->price_level]; - $pu_ttc = $prod->multiprices_ttc[$soc->price_level]; - $price_base_type = $prod->multiprices_base_type[$soc->price_level]; - } - else - { - $pu_ht = $prod->price; - $pu_ttc = $prod->price_ttc; - $price_base_type = $prod->price_base_type; - } + $tva_tx = get_default_tva($mysoc, $soc, $prod->id); + $localtax1_tx= get_localtax($tva_tx, 1, $soc); + $localtax2_tx= get_localtax($tva_tx, 2, $soc); + + + $pu_ht = $prod->price; + $pu_ttc = $prod->price_ttc; + $price_base_type = $prod->price_base_type; + + // If multiprice + if ($conf->global->PRODUIT_MULTIPRICES && $soc->price_level) + { + $pu_ht = $prod->multiprices[$soc->price_level]; + $pu_ttc = $prod->multiprices_ttc[$soc->price_level]; + $price_base_type = $prod->multiprices_base_type[$soc->price_level]; + } // On reevalue prix selon taux tva car taux tva transaction peut etre different // de ceux du produit par defaut (par exemple si pays different entre vendeur et acheteur). @@ -500,6 +507,8 @@ if ($_POST["action"] == 'addincommande') $pu_ht, $_POST["qty"], $tva_tx, + $localtax1_tx, // localtax1 + $localtax2_tx, // localtax2 $prod->id, $_POST["remise_percent"], '', @@ -545,21 +554,22 @@ if ($_POST["action"] == 'addinfacture' && $user->rights->facture->creer) } $desc = $prod->description; - $tva_tx = get_default_tva($mysoc,$soc,$prod->tva_tx); - // multiprix - if ($conf->global->PRODUIT_MULTIPRICES && $soc->price_level) - { - $pu_ht = $prod->multiprices[$soc->price_level]; - $pu_ttc = $prod->multiprices_ttc[$soc->price_level]; - $price_base_type = $prod->multiprices_base_type[$soc->price_level]; - } - else - { - $pu_ht = $prod->price; - $pu_ttc = $prod->price_ttc; - $price_base_type = $prod->price_base_type; - } + $tva_tx = get_default_tva($mysoc, $soc, $prod->id); + $localtax1_tx= get_localtax($tva_tx, 1, $soc); + $localtax2_tx= get_localtax($tva_tx, 2, $soc); + + $pu_ht = $prod->price; + $pu_ttc = $prod->price_ttc; + $price_base_type = $prod->price_base_type; + + // If multiprice + if ($conf->global->PRODUIT_MULTIPRICES && $soc->price_level) + { + $pu_ht = $prod->multiprices[$soc->price_level]; + $pu_ttc = $prod->multiprices_ttc[$soc->price_level]; + $price_base_type = $prod->multiprices_base_type[$soc->price_level]; + } // On reevalue prix selon taux tva car taux tva transaction peut etre different // de ceux du produit par defaut (par exemple si pays different entre vendeur et acheteur). @@ -580,6 +590,8 @@ if ($_POST["action"] == 'addinfacture' && $user->rights->facture->creer) $pu_ht, $_POST["qty"], $tva_tx, + $localtax1_tx, + $localtax2_tx, $prod->id, $_POST["remise_percent"], '', @@ -601,7 +613,7 @@ if ($_POST["action"] == 'addinfacture' && $user->rights->facture->creer) if ($_POST["cancel"] == $langs->trans("Cancel")) { $action = ''; - Header("Location: fiche.php?id=".$_POST["id"]); + Header("Location: ".$_SERVER["PHP_SELF"]."?id=".$_POST["id"]); exit; } @@ -619,51 +631,16 @@ $formproduct = new FormProduct($db); */ if ($_GET["action"] == 'create' && ($user->rights->produit->creer || $user->rights->service->creer)) { - if ($_GET["canvas"] <> '' && file_exists('canvas/'.$_GET["canvas"].'/product.'.$_GET["canvas"].'.class.php')) - { - if (! isset($product)) - { - $filecanvas = DOL_DOCUMENT_ROOT.'/product/canvas/'.$_GET["canvas"].'/product.'.$_GET["canvas"].'.class.php'; - $classname = 'Product'.ucfirst($_GET["canvas"]); - - include_once($filecanvas); - - $product = new $classname($db,0,$user); - } - - $product->assign_smarty_values($smarty, 'create'); - - if ($_error == 1) - { - $product = $e_product; - } - } - $helpurl=''; - if (isset($_GET["type"]) && $_GET["type"] == 0) - { - $helpurl='EN:Module_Products|FR:Module_Produits|ES:Módulo_Productos'; - } - if (isset($_GET["type"]) && $_GET["type"] == 1) - { - $helpurl='EN:Module_Services_En|FR:Module_Services|ES:Módulo_Servicios'; - } + if (isset($_GET["type"]) && $_GET["type"] == 0) $helpurl='EN:Module_Products|FR:Module_Produits|ES:Módulo_Productos'; + if (isset($_GET["type"]) && $_GET["type"] == 1) $helpurl='EN:Module_Services_En|FR:Module_Services|ES:Módulo_Servicios'; - llxHeader("",$helpurl,$langs->trans("CardProduct".$product->type)); + llxHeader('',$langs->trans("CardProduct".$_GET["type"]),$helpurl); - if ($mesg) print $mesg."\n"; + $usecanvas=$_GET["canvas"]; + if (empty($conf->global->MAIN_USE_CANVAS)) $usecanvas=0; - if ($_GET["canvas"] <> '' && file_exists('canvas/'.$_GET["canvas"].'/product.'.$_GET["canvas"].'.class.php')) - { - // On assigne les valeurs meme en creation car elles sont definies si - // on revient en erreur - $smarty->template_dir = DOL_DOCUMENT_ROOT.'/product/canvas/'.$_GET["canvas"].'/tpl/'; - $tvaarray = load_tva($db,"tva_tx",$conf->defaulttx,$mysoc,''); - $smarty->assign('tva_taux_value', $tvaarray['value']); - $smarty->assign('tva_taux_libelle', $tvaarray['label']); - $smarty->display($_GET["canvas"].'-create.tpl'); - } - else + if (empty($usecanvas)) { print '
'; print ''; @@ -674,6 +651,8 @@ if ($_GET["action"] == 'create' && ($user->rights->produit->creer || $user->righ else $title=$langs->trans("NewProduct"); print_fiche_titre($title); + if ($mesg) print $mesg."\n"; + print ''; print ''; print '
'.$langs->trans("Ref").''; @@ -835,235 +814,64 @@ if ($_GET["action"] == 'create' && ($user->rights->produit->creer || $user->righ print ''; } + else + { + $canvas = new Canvas($db,$user); + $product = $canvas->load_canvas('product',$_GET["canvas"]); + + $canvas->assign_values('create'); + $canvas->display_canvas(); + } } /** - * - * Fiche produit - * + * Product card */ + if ($_GET["id"] || $_GET["ref"]) { - $product = new Product($db); + $product=new Product($db); - if ($_GET["ref"]) + // TODO en attendant d'inclure le nom du canvas dans les liens + $productstatic = new Product($db); + $result = $productstatic->getCanvas($_GET["id"],$_GET["ref"]); + $usecanvas=$productstatic->canvas; + if (empty($conf->global->MAIN_USE_CANVAS)) $usecanvas=0; + + if (empty($usecanvas)) { - $result = $product->fetch('',$_GET["ref"]); - $_GET["id"] = $product->id; + $product->fetch($_GET["id"],$_GET["ref"]); } - elseif ($_GET["id"]) + else // Gestion des produits specifiques { - $result = $product->fetch($_GET["id"]); + $canvas = new Canvas($db,$user); + + $product = $canvas->load_canvas('product',$productstatic->canvas); + if (! $product) dol_print_error('','Faled to load canvas product-'.$productstatic->canvas); + + $canvas->fetch($productstatic->id,'',$_GET["action"]); } - // Gestion des produits specifiques - if ($product->canvas <> '' && file_exists('canvas/'.$product->canvas.'/product.'.$product->canvas.'.class.php') ) - { - $classname = 'Product'.ucfirst($product->canvas); - include_once('canvas/'.$product->canvas.'/product.'.$product->canvas.'.class.php'); - $product = new $classname($db); - - $result = $product->fetchCanvas($_GET["id"],'',$_GET["action"]); - - $smarty->template_dir = DOL_DOCUMENT_ROOT.'/product/canvas/'.$product->canvas.'/tpl/'; - - $product->assign_smarty_values($smarty,$_GET["action"]); - } - - - llxHeader("","",$langs->trans("CardProduct".$product->type)); - - if ( $result ) - { - if ($_GET["action"] <> 'edit') - { - $head=product_prepare_head($product, $user); - $titre=$langs->trans("CardProduct".$product->type); - $picto=($product->type==1?'service':'product'); - dol_fiche_head($head, 'card', $titre, 0, $picto); - print "\n\n"; - // Confirmation de la suppression de la facture - if ($_GET["action"] == 'delete') - { - $ret=$html->form_confirm("fiche.php?id=".$product->id,$langs->trans("DeleteProduct"),$langs->trans("ConfirmDeleteProduct"),"confirm_delete",'',0,2); - if ($ret == 'html') print '
'; - } - - print($mesg); - } - if ($_GET["action"] <> 'edit' && $product->canvas <> '') - { - /* - * Smarty en mode visu - */ - $smarty->assign('fiche_cursor_prev',$previous_ref); - $smarty->assign('fiche_cursor_next',$next_ref); - - // Photo - //$nbphoto=$product->show_photos($conf->produit->dir_output,1,1,0); - - $smarty->display($product->canvas.'-view.tpl'); - - print "\n\n"; - } - - if ($_GET["action"] <> 'edit' && $product->canvas == '') - { - // En mode visu - print ''; - - // Ref - print ''; - - print ''; - - // Label - print ''; - - $nblignes=4; - if ($product->is_photo_available($conf->produit->dir_output)) - { - // Photo - print ''; - } - - print ''; - - // Accountancy buy code - print ''; - - // Accountancy sell code - print ''; - - // Statut - print ''; - - // Description - print ''; - - // Nature - if($product->type!=1) - { - print ''; - } - - if ($product->isservice()) - { - // Duration - print ''; - } - else - { - // Weight - print '\n"; - // Length - print '\n"; - // Surface - print '\n"; - // Volume - print '\n"; - } - - // Hidden - if ((! $product->isservice() && $user->rights->produit->hidden) - || ($product->isservice() && $user->rights->service->hidden)) - { - print '\n"; - } - else - { - print ''; - } - - // Note - print ''; - - print "
'.$langs->trans("Ref").''; - print $html->showrefnav($product,'ref','',1,'ref'); - print '
'.$langs->trans("Label").''.$product->libelle.''; - $nbphoto=$product->show_photos($conf->produit->dir_output,1,1,0,0,0,80); - print '
'.$html->editfieldkey("ProductAccountancyBuyCode",'productaccountancycodesell',$product->accountancy_code_sell,'id',$product->id,$user->rights->produit->creer).''; - print $html->editfieldval("ProductAccountancyBuyCode",'productaccountancycodesell',$product->accountancy_code_sell,'id',$product->id,$user->rights->produit->creer); - print '
'.$html->editfieldkey("ProductAccountancySellCode",'productaccountancycodebuy',$product->accountancy_code_buy,'id',$product->id,$user->rights->produit->creer).''; - print $html->editfieldval("ProductAccountancySellCode",'productaccountancycodebuy',$product->accountancy_code_buy,'id',$product->id,$user->rights->produit->creer); - print '
'.$langs->trans("Status").''; - print $product->getLibStatut(2); - print '
'.$langs->trans("Description").''.nl2br($product->description).'
'.$langs->trans("Nature").''; - print $product->getLibFinished(); - print '
'.$langs->trans("Duration").''.$product->duration_value.' '; - if ($product->duration_value > 1) - { - $dur=array("h"=>$langs->trans("Hours"),"d"=>$langs->trans("Days"),"w"=>$langs->trans("Weeks"),"m"=>$langs->trans("Months"),"y"=>$langs->trans("Years")); - } - else if ($product->duration_value > 0) - { - $dur=array("h"=>$langs->trans("Hour"),"d"=>$langs->trans("Day"),"w"=>$langs->trans("Week"),"m"=>$langs->trans("Month"),"y"=>$langs->trans("Year")); - } - print $langs->trans($dur[$product->duration_unit])." "; - - print '
'.$langs->trans("Weight").''; - if ($product->weight != '') - { - print $product->weight." ".measuring_units_string($product->weight_units,"weight"); - } - else - { - print ' '; - } - print "
'.$langs->trans("Length").''; - if ($product->length != '') - { - print $product->length." ".measuring_units_string($product->length_units,"size"); - } - else - { - print ' '; - } - print "
'.$langs->trans("Surface").''; - if ($product->surface != '') - { - print $product->surface." ".measuring_units_string($product->surface_units,"surface"); - } - else - { - print ' '; - } - print "
'.$langs->trans("Volume").''; - if ($product->volume != '') - { - print $product->volume." ".measuring_units_string($product->volume_units,"volume"); - } - else - { - print ' '; - } - print "
'.$langs->trans("Hidden").''; - print yn($product->hidden); - print "
'.$langs->trans("Hidden").''; - print yn("No"); - print '
'.$langs->trans("Note").''.nl2br($product->note).'
\n"; - print "\n\n"; - } - } + llxHeader('',$langs->trans("CardProduct".$product->type)); /* * Fiche en mode edition */ if ($_GET["action"] == 'edit' && ($user->rights->produit->creer || $user->rights->service->creer)) { - if ($product->isservice()) { - print_fiche_titre($langs->trans('Modify').' '.$langs->trans('Service').' : '.$product->ref, ""); - } else { - print_fiche_titre($langs->trans('Modify').' '.$langs->trans('Product').' : '.$product->ref, ""); - } - - if ($mesg) { - print '
'.$mesg.'

'; - } - - if ( $product->canvas == '') + if (empty($usecanvas)) { - print "\n"; + if ($product->isservice()) { + print_fiche_titre($langs->trans('Modify').' '.$langs->trans('Service').' : '.$product->ref, ""); + } else { + print_fiche_titre($langs->trans('Modify').' '.$langs->trans('Product').' : '.$product->ref, ""); + } + + if ($mesg) { + print '
'.$mesg.'

'; + } + + // Main official, simple, and not duplicated code print "
\n"; print ''; print ''; @@ -1206,16 +1014,175 @@ if ($_GET["id"] || $_GET["ref"]) print ''; print '
'; - print "\n"; } else { - $tvaarray = load_tva($db,"tva_tx",$conf->defaulttx,$mysoc,'',''); - $smarty->assign('tva_taux_value', $tvaarray['value']); - $smarty->assign('tva_taux_libelle', $tvaarray['label']); - $smarty->display($product->canvas.'-edit.tpl'); + $canvas->assign_values('edit'); + $canvas->display_canvas(); } } + /* + * Fiche en mode visu + */ + else + { + $head=product_prepare_head($product, $user); + $titre=$langs->trans("CardProduct".$product->type); + $picto=($product->type==1?'service':'product'); + dol_fiche_head($head, 'card', $titre, 0, $picto); + + // Confirmation de la suppression de la facture + if ($_GET["action"] == 'delete') + { + $ret=$html->form_confirm("fiche.php?id=".$product->id,$langs->trans("DeleteProduct"),$langs->trans("ConfirmDeleteProduct"),"confirm_delete",'',0,2); + if ($ret == 'html') print '
'; + } + + if (empty($usecanvas)) + { + // En mode visu + print ''; + + // Ref + print ''; + + print ''; + + // Label + print ''; + + $nblignes=4; + if ($product->is_photo_available($conf->product->dir_output)) + { + // Photo + print ''; + } + + print ''; + + // Accountancy buy code + print ''; + + // Accountancy sell code + print ''; + + // Statut + print ''; + + // Description + print ''; + + // Nature + if($product->type!=1) + { + print ''; + } + + if ($product->isservice()) + { + // Duration + print ''; + } + else + { + // Weight + print '\n"; + // Length + print '\n"; + // Surface + print '\n"; + // Volume + print '\n"; + } + + // Hidden + if ((! $product->isservice() && $user->rights->produit->hidden) + || ($product->isservice() && $user->rights->service->hidden)) + { + print '\n"; + } + else + { + print ''; + } + + // Note + print ''; + + print "
'.$langs->trans("Ref").''; + print $html->showrefnav($product,'ref','',1,'ref'); + print '
'.$langs->trans("Label").''.$product->libelle.''; + print $product->show_photos($conf->product->dir_output,1,1,0,0,0,80); + print '
'.$html->editfieldkey("ProductAccountancyBuyCode",'productaccountancycodesell',$product->accountancy_code_sell,'id',$product->id,$user->rights->produit->creer).''; + print $html->editfieldval("ProductAccountancyBuyCode",'productaccountancycodesell',$product->accountancy_code_sell,'id',$product->id,$user->rights->produit->creer); + print '
'.$html->editfieldkey("ProductAccountancySellCode",'productaccountancycodebuy',$product->accountancy_code_buy,'id',$product->id,$user->rights->produit->creer).''; + print $html->editfieldval("ProductAccountancySellCode",'productaccountancycodebuy',$product->accountancy_code_buy,'id',$product->id,$user->rights->produit->creer); + print '
'.$langs->trans("Status").''; + print $product->getLibStatut(2); + print '
'.$langs->trans("Description").''.nl2br($product->description).'
'.$langs->trans("Nature").''; + print $product->getLibFinished(); + print '
'.$langs->trans("Duration").''.$product->duration_value.' '; + if ($product->duration_value > 1) + { + $dur=array("h"=>$langs->trans("Hours"),"d"=>$langs->trans("Days"),"w"=>$langs->trans("Weeks"),"m"=>$langs->trans("Months"),"y"=>$langs->trans("Years")); + } + else if ($product->duration_value > 0) + { + $dur=array("h"=>$langs->trans("Hour"),"d"=>$langs->trans("Day"),"w"=>$langs->trans("Week"),"m"=>$langs->trans("Month"),"y"=>$langs->trans("Year")); + } + print $langs->trans($dur[$product->duration_unit])." "; + + print '
'.$langs->trans("Weight").''; + if ($product->weight != '') + { + print $product->weight." ".measuring_units_string($product->weight_units,"weight"); + } + else + { + print ' '; + } + print "
'.$langs->trans("Length").''; + if ($product->length != '') + { + print $product->length." ".measuring_units_string($product->length_units,"size"); + } + else + { + print ' '; + } + print "
'.$langs->trans("Surface").''; + if ($product->surface != '') + { + print $product->surface." ".measuring_units_string($product->surface_units,"surface"); + } + else + { + print ' '; + } + print "
'.$langs->trans("Volume").''; + if ($product->volume != '') + { + print $product->volume." ".measuring_units_string($product->volume_units,"volume"); + } + else + { + print ' '; + } + print "
'.$langs->trans("Hidden").''; + print yn($product->hidden); + print "
'.$langs->trans("Hidden").''; + print yn("No"); + print '
'.$langs->trans("Note").''.nl2br($product->note).'
\n"; + } + else + { + $canvas->assign_values('view'); + $canvas->display_canvas(); + } + + dol_fiche_end(); + } + } else if (!$_GET["action"] == 'create') { @@ -1253,18 +1220,19 @@ if ($_GET["action"] == '') if ($user->rights->produit->creer || $user->rights->service->creer) { if ($product->no_button_edit <> 1) - print ''.$langs->trans("Modify").''; + print 'id.'">'.$langs->trans("Modify").''; if ($product->no_button_copy <> 1) - print ''.$langs->trans("ToClone").''; + print 'id.'">'.$langs->trans("ToClone").''; } $product_is_used = $product->verif_prod_use($product->id); - if ($user->rights->produit->supprimer) + if (($product->type == 0 && $user->rights->produit->supprimer) + || ($product->type == 1 && $user->rights->service->supprimer)) { if (! $product_is_used && $product->no_button_delete <> 1) { - print ''.$langs->trans("Delete").''; + print 'id.'">'.$langs->trans("Delete").''; } else { @@ -1284,36 +1252,36 @@ print "\n
\n"; * All the "Add to" areas */ -if ($_GET["id"] && $_GET["action"] == '' && $product->status) +if ($product->id && $_GET["action"] == '' && $product->status) { - $propal = New Propal($db); - print ''; // Propals if($conf->propal->enabled && $user->rights->propale->creer) { + $propal = new Propal($db); + $langs->load("propal"); - print ''; if ($user->rights->societe->client->voir) { - print ''; } else { - print ''; + print ''; } print ''; // Liste de "Mes propals" - print 'rights->societe->client->voir?' width="50%"':'').' valign="top">'; - $sql = "SELECT s.nom, s.rowid as socid, p.rowid as propalid, p.ref,".$db->pdate("p.datep")." as dp"; + $sql = "SELECT s.nom, s.rowid as socid, p.rowid as propalid, p.ref, p.datep as dp"; $sql.= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."propal as p"; $sql.= " WHERE p.fk_soc = s.rowid"; $sql.= " AND p.entity = ".$conf->entity; @@ -1334,12 +1302,12 @@ if ($_GET["id"] && $_GET["action"] == '' && $product->status) { $objp = $db->fetch_object($result); $var=!$var; - print '
'; + print ''; print ''; print ''; - print "
"; - print "\n"; + print ""; + print '\n"; print "\n"; print "\n"; print '
'; + print '
'; print $langs->trans("AddToMyProposals") . ''; + print ''; print $langs->trans("AddToOtherProposals").'  
'; + print '
"; - print "propalid."\">".img_object($langs->trans("ShowPropal"),"propal")." ".$objp->ref."
'; + print "propalid."\">".img_object($langs->trans("ShowPropal"),"propal")." ".$objp->ref."socid."\">".dol_trunc($objp->nom,18)."".dol_print_date($objp->dp,"%d %b")."'; @@ -1371,8 +1339,8 @@ if ($_GET["id"] && $_GET["action"] == '' && $product->status) print ''; $var=true; - $otherprop = $propal->liste_array(1, ' <> '.$user->id); - print ''; + $otherprop = $propal->liste_array(1,1,1); + print ''; print ''; print ''; if (is_array($otherprop) && sizeof($otherprop)) @@ -1405,33 +1373,32 @@ if ($_GET["id"] && $_GET["action"] == '' && $product->status) print ''; } - $commande = New Commande($db); - - // Commande if($conf->commande->enabled && $user->rights->commande->creer) { + $commande = new Commande($db); + $langs->load("orders"); - print ''; if ($user->rights->societe->client->voir) { - print ''; } else { - print ''; + print ''; } print ''; // Liste de "Mes commandes" - print 'rights->societe->client->voir?' width="50%"':'').' valign="top">'; - $sql = "SELECT s.nom, s.rowid as socid, c.rowid as commandeid, c.ref,".$db->pdate("c.date_commande")." as dc"; + $sql = "SELECT s.nom, s.rowid as socid, c.rowid as commandeid, c.ref, c.date_commande as dc"; $sql.= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."commande as c"; $sql.= " WHERE c.fk_soc = s.rowid"; $sql.= " AND c.entity = ".$conf->entity; @@ -1452,14 +1419,14 @@ if ($_GET["id"] && $_GET["action"] == '' && $product->status) { $objc = $db->fetch_object($result); $var=!$var; - print ''; + print ''; print ''; print ''; - print ""; - print ""; + print '\n"; print "\n"; - print "\n"; + print "\n"; print ''; } - print ''; print ''; } // Factures - if($conf->facture->enabled && $user->rights->facture->creer) + if ($conf->facture->enabled && $user->rights->facture->creer) { - print ''; if ($user->rights->societe->client->voir) { - print ''; } else { - print ''; + print ''; } print ''; // Liste de Mes factures - print 'rights->societe->client->voir?' width="50%"':'').' valign="top">'; - $sql = "SELECT s.nom, s.rowid as socid, f.rowid as factureid, f.facnumber,".$db->pdate("f.datef")." as df"; + $sql = "SELECT s.nom, s.rowid as socid, f.rowid as factureid, f.facnumber, f.datef as df"; $sql.= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."facture as f"; $sql.= " WHERE f.fk_soc = s.rowid"; $sql.= " AND f.entity = ".$conf->entity; @@ -1565,14 +1533,14 @@ if ($_GET["id"] && $_GET["action"] == '' && $product->status) { $objp = $db->fetch_object($result); $var=!$var; - print '
'; + print ''; print ''; print ''; print "
"; print "\n"; print "\n"; - print "\n"; + print "\n"; print '
'; + print '
'; print $langs->trans("AddToMyOrders").''; + print ''; print $langs->trans("AddToOtherOrders").'  
'; + print '
"; + print "
'; print "commandeid."\">".img_object($langs->trans("ShowOrder"),"order")." ".$objc->ref."socid."\">".dol_trunc($objc->nom,18)."".dol_print_date($objc->dc,"%d %b")."".dol_print_date($db->jdate($objc->dc),"%d %b")."'; print ''.$langs->trans("ReductionShort"); print '%'; @@ -1490,8 +1457,8 @@ if ($_GET["id"] && $_GET["action"] == '' && $product->status) print ''; $var=true; - $othercom = $commande->liste_array(1, ' <> '.$user->id); - print ''; + $othercom = $commande->liste_array(1, $user); + print ''; print ''; print ''; if (is_array($othercom) && sizeof($othercom)) @@ -1517,34 +1484,35 @@ if ($_GET["id"] && $_GET["action"] == '' && $product->status) } print '
'; print ''; + + print '
'; + print '
'; print $langs->trans("AddToMyBills").''; + print ''; print $langs->trans("AddToOtherBills").'  
'; + print '
"; print "factureid."\">".img_object($langs->trans("ShowBills"),"bill")." ".$objp->facnumber."socid."\">".dol_trunc($objp->nom,18)."".dol_print_date($objp->df,"%d %b")."".dol_print_date($db->jdate($objp->df),"%d %b")."'; print ''.$langs->trans("ReductionShort"); print '%'; @@ -1601,12 +1569,14 @@ if ($_GET["id"] && $_GET["action"] == '' && $product->status) if ($user->rights->societe->client->voir) { + $facture = new Facture($db); + print ''; - // Liste de Autres factures + // Liste de Autres factures $var=true; - $sql = "SELECT s.nom, s.rowid as socid, f.rowid as factureid, f.facnumber,".$db->pdate("f.datef")." as df"; + $sql = "SELECT s.nom, s.rowid as socid, f.rowid as factureid, f.facnumber, f.datef as df"; $sql.= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."facture as f"; $sql.= " WHERE f.fk_soc = s.rowid"; $sql.= " AND f.entity = ".$conf->entity; @@ -1620,17 +1590,18 @@ if ($_GET["id"] && $_GET["action"] == '' && $product->status) $num = $db->num_rows($result); $var=true; print ''; - if ($num) { + if ($num) + { $i = 0; while ($i < $num) { $objp = $db->fetch_object($result); $var=!$var; - print ''; + print ''; print ''; print ''; - print ""; + print ""; print "\n"; print "\n"; print "'; @@ -1658,9 +1630,11 @@ if ($_GET["id"] && $_GET["action"] == '' && $product->status) { dol_print_error($db); } + + print ''; } - print ''; + print ''; } print '
factureid."\">$objp->facnumbersocid."\">".dol_trunc($objp->nom,24)."".$langs->trans("Qty"); @@ -1646,7 +1617,8 @@ if ($_GET["id"] && $_GET["action"] == '' && $product->status) $i++; } } - else { + else + { print "
"; print $langs->trans("NoOtherDraftBills"); print '
'; @@ -1674,60 +1648,4 @@ $db->close(); llxFooter('$Date$ - $Revision$'); - -/** - * \brief Load tva_taux_value and tva_taux_libelle array - * \remarks Ne sert que pour smarty - * \ TODO deplacer dans une classe - */ -function load_tva($db,$name='tauxtva', $defaulttx='', $societe_vendeuse='', $societe_acheteuse='', $taux_produit='') -{ - global $langs,$conf,$mysoc; - - $retarray=array(); - - if (is_object($societe_vendeuse->pays_code)) - { - $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=$db->query($sql); - if ($resql) - { - $num = $db->num_rows($resql); - for ($i = 0; $i < $num; $i++) - { - $obj = $db->fetch_object($resql); - $txtva[ $i ] = $obj->taux; - $libtva[ $i ] = $obj->taux.'%'.($obj->recuperableonly ? ' *':''); - } - } - - // Definition du taux a pre-selectionner - if ($defaulttx == '') $defaulttx=get_default_tva($societe_vendeuse,$societe_acheteuse,$taux_produit); - // Si taux par defaut n'a pu etre trouve, on prend dernier. - // Comme ils sont tries par ordre croissant, dernier = plus eleve = taux courant - if ($defaulttx == '') $defaulttx = $txtva[sizeof($txtva)-1]; - - $nbdetaux = sizeof($txtva); - - for ($i = 0 ; $i < $nbdetaux ; $i++) - { - $retarray['value'][$i] = $txtva[$i]; - $retarray['label'][$i] = $libtva[$i]; - } - - return $retarray; -} ?>