diff --git a/htdocs/product.class.php b/htdocs/product.class.php index a98412fbdab..1d456f42b59 100644 --- a/htdocs/product.class.php +++ b/htdocs/product.class.php @@ -46,6 +46,9 @@ class Product var $description; //! Prix de vente var $price; + //! Base de prix (ttc ou ht) + var $price_base_type; + //! Tableau des prix multiples var $multiprices=array(); //! Taux de TVA var $tva_tx; @@ -707,9 +710,9 @@ class Product /** - * \brief Modifie le prix d'un produit/service - * \param id id du produit/service à modifier - * \param user utilisateur qui modifie le prix + \brief Modifie le prix d'un produit/service + \param id id du produit/service à modifier + \param user utilisateur qui modifie le prix */ function update_price($id, $user) { @@ -749,10 +752,24 @@ class Product { if (strlen(trim($this->price)) > 0 ) { + if ($this->price_base_type == 'TTC') + { + $price_ttc = $this->price; + $this->price = $this->price / (1 + ($this->tva_tx / 100)); + } + else + { + $price_ttc = $this->price * (1 + ($this->tva_tx / 100)); + } + + $sql = "UPDATE ".MAIN_DB_PREFIX."product "; $sql .= " SET price = " . price2num($this->price); - $sql .= " WHERE rowid = " . $id; + $sql .= " , price_base_type='".$this->price_base_type."'"; + $sql .= " , price_ttc='".$price_ttc."'"; + $sql .= " WHERE rowid = " . $id; + if ( $this->db->query($sql) ) { $this->_log_price($user); @@ -794,7 +811,7 @@ class Product return -1; } - $sql = "SELECT rowid, ref, label, description, note, price, tva_tx, envente,"; + $sql = "SELECT rowid, ref, label, description, note, price, price_ttc, price_base_type, tva_tx, envente,"; $sql.= " nbvente, fk_product_type, duration, seuil_stock_alerte,canvas,"; $sql.= " stock_commande, stock_loc, weight, weight_units"; $sql.= " FROM ".MAIN_DB_PREFIX."product"; @@ -812,6 +829,8 @@ class Product $this->description = stripslashes($result["description"]); $this->note = stripslashes($result["note"]); $this->price = $result["price"]; + $this->price_ttc = $result["price_ttc"]; + $this->price_base_type = $result["price_base_type"]; $this->tva_tx = $result["tva_tx"]; $this->type = $result["fk_product_type"]; $this->nbvente = $result["nbvente"]; diff --git a/htdocs/product/fiche.php b/htdocs/product/fiche.php index 8e08f46cab1..f53027f2782 100644 --- a/htdocs/product/fiche.php +++ b/htdocs/product/fiche.php @@ -4,6 +4,7 @@ * Copyright (C) 2005 Eric Seigne * Copyright (C) 2005-2006 Régis Houssin * Copyright (C) 2006 Andre Cianfarani + * Copyright (C) 2006 Auguria SARL * * 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 @@ -24,11 +25,11 @@ */ /** -* \file htdocs/product/fiche.php -* \ingroup product -* \brief Page de la fiche produit -* \version $Revision$ -*/ + * \file htdocs/product/fiche.php + * \ingroup product + * \brief Page de la fiche produit + * \version $Revision$ + */ require("./pre.inc.php"); require_once(DOL_DOCUMENT_ROOT."/lib/product.lib.php"); @@ -51,133 +52,133 @@ $types[1] = $langs->trans("Service"); */ if ($_GET["action"] == 'fastappro') { - $product = new Product($db); - $product->fetch($_GET["id"]); - $result = $product->fastappro($user); - Header("Location: fiche.php?id=".$_GET["id"]); - exit; + $product = new Product($db); + $product->fetch($_GET["id"]); + $result = $product->fastappro($user); + Header("Location: fiche.php?id=".$_GET["id"]); + exit; } // Action ajout d'un produit ou service if ($_POST["action"] == 'add' && $user->rights->produit->creer) { - if ($_POST["canvas"] <> '' && file_exists('canvas/product.'.$_POST["canvas"].'.class.php') ) + if ($_POST["canvas"] <> '' && file_exists('canvas/product.'.$_POST["canvas"].'.class.php') ) + { + $class = 'Product'.ucfirst($_POST["canvas"]); + include_once('canvas/product.'.$_POST["canvas"].'.class.php'); + $product = new $class($db); + } + else + { + $product = new Product($db); + } + + $product->ref = $_POST["ref"]; + $product->libelle = $_POST["libelle"]; + $product->price = $_POST["price"]; + $product->tva_tx = $_POST["tva_tx"]; + $product->type = $_POST["type"]; + $product->status = $_POST["statut"]; + $product->description = $_POST["desc"]; + $product->note = $_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->new_weight = $_POST["weight"]; + $product->new_weight_units = $_POST["weight_units"]; + // MultiPrix + if($conf->global->PRODUIT_MULTIPRICES == 1) + { + for($i=2;$i<=$conf->global->PRODUIT_MULTIPRICES_LIMIT;$i++) { - $class = 'Product'.ucfirst($_POST["canvas"]); - include_once('canvas/product.'.$_POST["canvas"].'.class.php'); - $product = new $class($db); - } - else - { - $product = new Product($db); - } - - $product->ref = $_POST["ref"]; - $product->libelle = $_POST["libelle"]; - $product->price = $_POST["price"]; - $product->tva_tx = $_POST["tva_tx"]; - $product->type = $_POST["type"]; - $product->status = $_POST["statut"]; - $product->description = $_POST["desc"]; - $product->note = $_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->new_weight = $_POST["weight"]; - $product->new_weight_units = $_POST["weight_units"]; - // MultiPrix - if($conf->global->PRODUIT_MULTIPRICES == 1) - { - for($i=2;$i<=$conf->global->PRODUIT_MULTIPRICES_LIMIT;$i++) - { - if($_POST["price_".$i]) - $product->multiprices["$i"]=ereg_replace(" ","",$_POST["price_".$i]); - else - $product->multiprices["$i"] = ""; - } - } - - if ( $value != $current_lang ) $e_product = $product; - - // Produit spécifique - // $_POST n'est pas utilise dans la classe Product - // mais dans des classes qui hérite de Product - $id = $product->Create($user, $_POST); - - if ($id > 0) - { - Header("Location: fiche.php?id=$id"); - exit; - } - else - { - $mesg='
'.$product->error.'
'; - $_GET["action"] = "create"; - $_GET["type"] = $_POST["type"]; + if($_POST["price_".$i]) + $product->multiprices["$i"]=ereg_replace(" ","",$_POST["price_".$i]); + else + $product->multiprices["$i"] = ""; } + } + + if ( $value != $current_lang ) $e_product = $product; + + // Produit spécifique + // $_POST n'est pas utilise dans la classe Product + // mais dans des classes qui hérite de Product + $id = $product->Create($user, $_POST); + + if ($id > 0) + { + Header("Location: fiche.php?id=$id"); + exit; + } + else + { + $mesg='
'.$product->error.'
'; + $_GET["action"] = "create"; + $_GET["type"] = $_POST["type"]; + } } // Action mise a jour d'un produit ou service if ($_POST["action"] == 'update' && -$_POST["cancel"] <> $langs->trans("Cancel") && -$user->rights->produit->creer) + $_POST["cancel"] <> $langs->trans("Cancel") && + $user->rights->produit->creer) { - $product = new Product($db); - if ($product->fetch($_POST["id"])) + $product = new Product($db); + if ($product->fetch($_POST["id"])) + { + $product->ref = $_POST["ref"]; + $product->libelle = $_POST["libelle"]; + if ( isset( $_POST["price"] ) ) + $product->price = $_POST["price"]; + $product->tva_tx = $_POST["tva_tx"]; + $product->description = $_POST["desc"]; + $product->note = $_POST["note"]; + $product->status = $_POST["statut"]; + $product->seuil_stock_alerte = $_POST["seuil_stock_alerte"]; + $product->stock_loc = $_POST["stock_loc"]; + $product->duration_value = $_POST["duration_value"]; + $product->duration_unit = $_POST["duration_unit"]; + $product->canvas = $_POST["canvas"]; + $product->new_weight = $_POST["weight"]; + $product->new_weight_units = $_POST["weight_units"]; + + if ($product->check()) { - $product->ref = $_POST["ref"]; - $product->libelle = $_POST["libelle"]; - if ( isset( $_POST["price"] ) ) - $product->price = $_POST["price"]; - $product->tva_tx = $_POST["tva_tx"]; - $product->description = $_POST["desc"]; - $product->note = $_POST["note"]; - $product->status = $_POST["statut"]; - $product->seuil_stock_alerte = $_POST["seuil_stock_alerte"]; - $product->stock_loc = $_POST["stock_loc"]; - $product->duration_value = $_POST["duration_value"]; - $product->duration_unit = $_POST["duration_unit"]; - $product->canvas = $_POST["canvas"]; - $product->new_weight = $_POST["weight"]; - $product->new_weight_units = $_POST["weight_units"]; - - if ($product->check()) - { - if ($product->update($product->id, $user) > 0) - { - $_GET["action"] = ''; - $_GET["id"] = $_POST["id"]; - } - else - { - $_GET["action"] = 'edit'; - $_GET["id"] = $_POST["id"]; - $mesg = $product->error; - } - } - else - { - $_GET["action"] = 'edit'; - $_GET["id"] = $_POST["id"]; - $mesg = $langs->trans("ErrorProductBadRefOrLabel"); - } - - - // Produit spécifique - if ($product->canvas <> '' && file_exists('canvas/product.'.$product->canvas.'.class.php') ) - { - $class = 'Product'.ucfirst($product->canvas); - include_once('canvas/product.'.$product->canvas.'.class.php'); - - $product = new $class($db); - if ($product->FetchCanvas($_POST["id"])) - { - $product->UpdateCanvas($_POST); - } - } + if ($product->update($product->id, $user) > 0) + { + $_GET["action"] = ''; + $_GET["id"] = $_POST["id"]; + } + else + { + $_GET["action"] = 'edit'; + $_GET["id"] = $_POST["id"]; + $mesg = $product->error; + } } + else + { + $_GET["action"] = 'edit'; + $_GET["id"] = $_POST["id"]; + $mesg = $langs->trans("ErrorProductBadRefOrLabel"); + } + + + // Produit spécifique + if ($product->canvas <> '' && file_exists('canvas/product.'.$product->canvas.'.class.php') ) + { + $class = 'Product'.ucfirst($product->canvas); + include_once('canvas/product.'.$product->canvas.'.class.php'); + + $product = new $class($db); + if ($product->FetchCanvas($_POST["id"])) + { + $product->UpdateCanvas($_POST); + } + } + } } // clone d'un produit @@ -396,136 +397,136 @@ $html = new Form($db); */ if ($_GET["action"] == 'create' && $user->rights->produit->creer) { - $product = new Product($db); - - if ($_error == 1) + $product = new Product($db); + + if ($_error == 1) + { + $product = $e_product; + } + + llxHeader("","",$langs->trans("CardProduct".$product->type)); + + if ($mesg) print "$mesg\n"; + + if ($_GET["canvas"] == '') + { + print '
'; + print ''; + print ''."\n"; + + if ($_GET["type"]==0) { $title=$langs->trans("NewProduct"); } + if ($_GET["type"]==1) { $title=$langs->trans("NewService"); } + print_fiche_titre($title); + + print ''; + print ''; + print ''; + print ''; - llxHeader("","",$langs->trans("CardProduct".$product->type)); - - if ($mesg) print "$mesg\n"; - - if ($_GET["canvas"] == '') + if($conf->global->PRODUIT_MULTIPRICES == 1) { - print ''; - print ''; - print ''."\n"; - - if ($_GET["type"]==0) { $title=$langs->trans("NewProduct"); } - if ($_GET["type"]==1) { $title=$langs->trans("NewService"); } - print_fiche_titre($title); - - print '
'.$langs->trans("Ref").''; + if ($_error == 1) { - $product = $e_product; + print $langs->trans("RefAlreadyExists"); } + print '
'.$langs->trans("Label").'
'; - print ''; - print ''; - print ''; - - if($conf->global->PRODUIT_MULTIPRICES == 1) - { - print ''; - for($i=2;$i<=$conf->global->PRODUIT_MULTIPRICES_LIMIT;$i++) - { - print ''; - } - } + print ''; + for($i=2;$i<=$conf->global->PRODUIT_MULTIPRICES_LIMIT;$i++) + { + print ''; + } + } // PRIX - else - { - print ''; - } - - print ''; - - print ''; - - if ($_GET["type"] == 0 && $conf->stock->enabled) - { - print ''; - } - else - { - print ''; - } - - // Description (utilisé dans facture, propale...) - print '"; - - if ($_GET["type"] == 1) - { - print ''; - } - else - { - // Le poids ne concerne que les produits et pas les services - print ''; - } - - // Note (invisible sur facture, propales...) - print '"; - - print ''; - print '
'.$langs->trans("Ref").''; - if ($_error == 1) - { - print $langs->trans("RefAlreadyExists"); - } - print '
'.$langs->trans("Label").'
'.$langs->trans("SellingPrice").' 1
'.$langs->trans("SellingPrice").' '.$i.'
'.$langs->trans("SellingPrice").' 1
'.$langs->trans("SellingPrice").' '.$i.'
'.$langs->trans("SellingPrice").'
'.$langs->trans("VATRate").''; - print $html->select_tva("tva_tx",$conf->defaulttx,$mysoc,''); - print '
'.$langs->trans("Status").''; - print ''; - print '
Seuil stock'; - print ''; - print '
'.$langs->trans("Description").''; - - if ($conf->fckeditor->enabled && $conf->global->FCKEDITOR_ENABLE_DETAILS) - { - require_once(DOL_DOCUMENT_ROOT."/lib/doleditor.class.php"); - $doleditor=new DolEditor('desc','',160,'dolibarr_notes','',false); - $doleditor->Create(); - } - else - { - print ''; - } - - print "
'.$langs->trans("Duration").'  '; - print ''.$langs->trans("Day").' '; - print ''.$langs->trans("Week").' '; - print ''.$langs->trans("Month").' '; - print ''.$langs->trans("Year").' '; - print '
'.$langs->trans("Weight").''; - print ''; - print $html->select_weight_units("weight_units"); - print '
'.$langs->trans("NoteNotVisibleOnBill").''; - if ($conf->fckeditor->enabled && $conf->global->FCKEDITOR_ENABLE_PRODUCTDESC) - { - require_once(DOL_DOCUMENT_ROOT."/lib/doleditor.class.php"); - $doleditor=new DolEditor('note','',200,'dolibarr_notes','',false); - $doleditor->Create(); - } - else - { - print ''; - } - print "
'; - print '
'; - } - else + else { - //RODO - $smarty->template_dir = DOL_DOCUMENT_ROOT.'/product/canvas/'.$_GET["canvas"].'/'; - $null = $html->load_tva("tva_tx",$conf->defaulttx,$mysoc,''); - $smarty->assign('tva_taux_value', $html->tva_taux_value); - $smarty->assign('tva_taux_libelle', $html->tva_taux_libelle); - $smarty->display($_GET["canvas"].'-create.tpl'); + print ''.$langs->trans("SellingPrice").''; } + + print ''.$langs->trans("VATRate").''; + print $html->select_tva("tva_tx",$conf->defaulttx,$mysoc,''); + print ''; + + print ''.$langs->trans("Status").''; + print ''; + print ''; + + if ($_GET["type"] == 0 && $conf->stock->enabled) + { + print 'Seuil stock'; + print ''; + print ''; + } + else + { + print ''; + } + + // Description (utilisé dans facture, propale...) + print ''.$langs->trans("Description").''; + + if ($conf->fckeditor->enabled && $conf->global->FCKEDITOR_ENABLE_DETAILS) + { + require_once(DOL_DOCUMENT_ROOT."/lib/doleditor.class.php"); + $doleditor=new DolEditor('desc','',160,'dolibarr_notes','',false); + $doleditor->Create(); + } + else + { + print ''; + } + + print ""; + + if ($_GET["type"] == 1) + { + print ''.$langs->trans("Duration").'  '; + print ''.$langs->trans("Day").' '; + print ''.$langs->trans("Week").' '; + print ''.$langs->trans("Month").' '; + print ''.$langs->trans("Year").' '; + print ''; + } + else + { + // Le poids ne concerne que les produits et pas les services + print ''.$langs->trans("Weight").''; + print ''; + print $html->select_weight_units("weight_units"); + print ''; + } + + // Note (invisible sur facture, propales...) + print ''.$langs->trans("NoteNotVisibleOnBill").''; + if ($conf->fckeditor->enabled && $conf->global->FCKEDITOR_ENABLE_PRODUCTDESC) + { + require_once(DOL_DOCUMENT_ROOT."/lib/doleditor.class.php"); + $doleditor=new DolEditor('note','',200,'dolibarr_notes','',false); + $doleditor->Create(); + } + else + { + print ''; + } + print ""; + + print ''; + print ''; + print ''; + } + else + { + //RODO + $smarty->template_dir = DOL_DOCUMENT_ROOT.'/product/canvas/'.$_GET["canvas"].'/'; + $null = $html->load_tva("tva_tx",$conf->defaulttx,$mysoc,''); + $smarty->assign('tva_taux_value', $html->tva_taux_value); + $smarty->assign('tva_taux_libelle', $html->tva_taux_libelle); + $smarty->display($_GET["canvas"].'-create.tpl'); + } } /** @@ -535,313 +536,320 @@ if ($_GET["action"] == 'create' && $user->rights->produit->creer) */ if ($_GET["id"] || $_GET["ref"]) { - $product = new Product($db); - - if ($_GET["ref"]) + $product = new Product($db); + + if ($_GET["ref"]) + { + $result = $product->fetch('',$_GET["ref"]); + $_GET["id"] = $product->id; + } + elseif ($_GET["id"]) + { + $result = $product->fetch($_GET["id"]); + } + + // Gestion des produits specifiques + if ($product->canvas <> '' && file_exists('canvas/product.'.$product->canvas.'.class.php') ) + { + $class = 'Product'.ucfirst($product->canvas); + include_once('canvas/product.'.$product->canvas.'.class.php'); + + $product = new $class($db); + + $result = $product->FetchCanvas($_GET["id"]); + + $smarty->template_dir = DOL_DOCUMENT_ROOT.'/product/canvas/'.$product->canvas.'/'; + + $product->assign_values($smarty); + } + else + { + $product->canvas = ''; + } + // END TODO RODO FINISH THIS PART + + llxHeader("","",$langs->trans("CardProduct".$product->type)); + + if ( $result ) + { + if ($_GET["action"] <> 'edit') { - $result = $product->fetch('',$_GET["ref"]); - $_GET["id"] = $product->id; + $head=product_prepare_head($product); + $titre=$langs->trans("CardProduct".$product->type); + dolibarr_fiche_head($head, 'card', $titre); + print "\n\n"; + // Confirmation de la suppression de la facture + if ($_GET["action"] == 'delete') + { + $html = new Form($db); + $html->form_confirm("fiche.php?id=".$product->id,$langs->trans("DeleteProduct"),$langs->trans("ConfirmDeleteProduct"),"confirm_delete"); + print "
\n"; + } + + print($mesg); + + $product->load_previous_next_ref(); + $previous_ref = $product->ref_previous?''.img_previous().'':''; + $next_ref = $product->ref_next?''.img_next().'':''; } - elseif ($_GET["id"]) + if ($_GET["action"] <> 'edit' && $product->canvas <> '') { - $result = $product->fetch($_GET["id"]); + /* + * 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"; } - - // Gestion des produits specifiques - if ($product->canvas <> '' && file_exists('canvas/product.'.$product->canvas.'.class.php') ) + + if ($_GET["action"] <> 'edit' && $product->canvas == '') { - $class = 'Product'.ucfirst($product->canvas); - include_once('canvas/product.'.$product->canvas.'.class.php'); - - $product = new $class($db); - - $result = $product->FetchCanvas($_GET["id"]); - - $smarty->template_dir = DOL_DOCUMENT_ROOT.'/product/canvas/'.$product->canvas.'/'; - - $product->assign_values($smarty); - } - else - { - $product->canvas = ''; - } - // END TODO RODO FINISH THIS PART - - llxHeader("","",$langs->trans("CardProduct".$product->type)); - - if ( $result ) - { - if ($_GET["action"] <> 'edit') + /* + * En mode visu + */ + print ''; + + // Reference + print ''; + + + $nblignes=6; + if ($product->type == 0 && $conf->stock->enabled) $nblignes++; + if ($product->type == 1) $nblignes++; + if ($product->is_photo_available($conf->produit->dir_output)) + { + // Photo + print ''; + } + print ''; + + // Libelle + print ''; + + // MultiPrix + if($conf->global->PRODUIT_MULTIPRICES == 1) + { + print ''; + print ''; + for($i=2;$i<=$conf->global->PRODUIT_MULTIPRICES_LIMIT;$i++) { - $head=product_prepare_head($product); - $titre=$langs->trans("CardProduct".$product->type); - dolibarr_fiche_head($head, 'card', $titre); - print "\n\n"; - // Confirmation de la suppression de la facture - if ($_GET["action"] == 'delete') - { - $html = new Form($db); - $html->form_confirm("fiche.php?id=".$product->id,$langs->trans("DeleteProduct"),$langs->trans("ConfirmDeleteProduct"),"confirm_delete"); - print "
\n"; - } - - print($mesg); - - $product->load_previous_next_ref(); - $previous_ref = $product->ref_previous?''.img_previous().'':''; - $next_ref = $product->ref_next?''.img_next().'':''; + print ''; + print ''; } - if ($_GET["action"] <> 'edit' && $product->canvas <> '') + } + // Prix + else + { + print ''; } - - if ($_GET["action"] <> 'edit' && $product->canvas == '') + else { - /* - * En mode visu - */ - print '
'.$langs->trans("Ref").''; + if ($previous_ref || $next_ref) print '
'; + print ''.$product->ref.''; + if ($previous_ref || $next_ref) print ''.$previous_ref.''.$next_ref.'
'; + print '
'; + $nbphoto=$product->show_photos($conf->produit->dir_output,1,1,0); + print '
'.$langs->trans("Label").''.$product->libelle.'
'.$langs->trans("SellingPrice").' 1'.price($product->price).'
'.$langs->trans("SellingPrice").' '.$i.''.price($product->multiprices["$i"]).'
'.$langs->trans("SellingPrice").''; + if ($product->price_base_type == 'TTC') { - /* - * 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"; + print price($product->price_ttc).' '.$langs->trans($product->price_base_type).'
'; - - // Reference - print ''; - - - $nblignes=6; - if ($product->type == 0 && $conf->stock->enabled) $nblignes++; - if ($product->type == 1) $nblignes++; - if ($product->is_photo_available($conf->produit->dir_output)) - { - // Photo - print ''; - } - print ''; - - // Libelle - print ''; - - // MultiPrix - if($conf->global->PRODUIT_MULTIPRICES == 1) - { - print ''; - print ''; - for($i=2;$i<=$conf->global->PRODUIT_MULTIPRICES_LIMIT;$i++) - { - print ''; - print ''; - } - } - // Prix - else - { - print ''; - print ''; - } - // Statut - print ''; - - // TVA - print ''; - - // Stock - if ($product->type == 0 && $conf->stock->enabled) - { - print ''; - if ($product->no_stock) - { - print "'; - } - - // Description - print ''; - - // Durée - if ($product->type == 1) - { - print ''; - } - else - { - print '\n"; - } - // Note - print ''; - print "
'.$langs->trans("Ref").''; - if ($previous_ref || $next_ref) print '
'; - print ''.$product->ref.''; - if ($previous_ref || $next_ref) print ''.$previous_ref.''.$next_ref.'
'; - print '
'; - $nbphoto=$product->show_photos($conf->produit->dir_output,1,1,0); - print '
'.$langs->trans("Label").''.$product->libelle.'
'.$langs->trans("SellingPrice").' 1'.price($product->price).'
'.$langs->trans("SellingPrice").' '.$i.''.price($product->multiprices["$i"]).'
'.$langs->trans("SellingPrice").''.price($product->price).'
'.$langs->trans("Status").''; - print $product->getLibStatut(2); - print '
'.$langs->trans("VATRate").''.$product->tva_tx.'%
'.$langs->trans("Stock").'".$langs->trans("NoStockDefined"); - } - else - { - if ($product->stock_reel <= $product->seuil_stock_alerte) - { - print ''.$product->stock_reel.' Seuil : '.$product->seuil_stock_alerte; - } - else - { - print "".$product->stock_reel; - } - } - print '
'.$langs->trans("Description").''.nl2br($product->description).'
'.$langs->trans("Duration").''.$product->duration_value.' '; - if ($product->duration_value > 1) - { - $dur=array("d"=>$langs->trans("Days"),"w"=>$langs->trans("Weeks"),"m"=>$langs->trans("Months"),"y"=>$langs->trans("Years")); - } - else { - $dur=array("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." ".weight_units_string($product->weight_units); - } - else - { - print ' '; - } - print "
'.$langs->trans("Note").''.nl2br($product->note).'
\n"; - print "\n\n"; + print price($product->price).' '.$langs->trans($product->price_base_type).''; } + } + // Statut + print ''.$langs->trans("Status").''; + print $product->getLibStatut(2); + print ''; + + // TVA + print ''.$langs->trans("VATRate").''.$product->tva_tx.'%'; + + // Stock + if ($product->type == 0 && $conf->stock->enabled) + { + print ''.$langs->trans("Stock").''; + if ($product->no_stock) + { + print "".$langs->trans("NoStockDefined"); + } + else + { + if ($product->stock_reel <= $product->seuil_stock_alerte) + { + print ''.$product->stock_reel.' Seuil : '.$product->seuil_stock_alerte; + } + else + { + print "".$product->stock_reel; + } + } + print ''; + } + + // Description + print ''.$langs->trans("Description").''.nl2br($product->description).''; + + // Durée + if ($product->type == 1) + { + print ''.$langs->trans("Duration").''.$product->duration_value.' '; + if ($product->duration_value > 1) + { + $dur=array("d"=>$langs->trans("Days"),"w"=>$langs->trans("Weeks"),"m"=>$langs->trans("Months"),"y"=>$langs->trans("Years")); + } + else { + $dur=array("d"=>$langs->trans("Day"),"w"=>$langs->trans("Week"),"m"=>$langs->trans("Month"),"y"=>$langs->trans("Year")); + } + print $langs->trans($dur[$product->duration_unit])." "; + + print ''; + } + else + { + print ''.$langs->trans("Weight").''; + if ($product->weight != '') + { + print $product->weight." ".weight_units_string($product->weight_units); + } + else + { + print ' '; + } + print "\n"; + } + // Note + print ''.$langs->trans("Note").''.nl2br($product->note).''; + print "\n"; + print "\n\n"; } - - /* - * Fiche en mode edition - */ - if ($_GET["action"] == 'edit' && $user->rights->produit->creer) + } + + /* + * Fiche en mode edition + */ + if ($_GET["action"] == 'edit' && $user->rights->produit->creer) + { + print_fiche_titre($langs->trans('Edit').' '.$types[$product->type].' : '.$product->ref, ""); + + if ($mesg) { + print '
'.$mesg.'

'; + } + + if ( $product->canvas == '') { - print_fiche_titre($langs->trans('Edit').' '.$types[$product->type].' : '.$product->ref, ""); + print "\n"; + print "
\n"; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; - if ($mesg) { - print '
'.$mesg.'

'; - } + print ''; + print ''; + if ($product->type == 0 && $conf->stock->enabled) + { + print "".''; + } + else + { + print ''; + } - if ( $product->canvas == '') - { - print "\n"; - print "\n"; - print ''; - print ''; - print ''; - print '
'.$langs->trans("Ref").'
'.$langs->trans("Label").'
'.$langs->trans("VATRate").''; + print $html->select_tva("tva_tx", $product->tva_tx, $mysoc, '', $product->tva_tx); + print '
'.$langs->trans("Status").''; + print '
Seuil stock'; + print ''; + print '
'; - print ''; - print ''; + // Description (utilisé dans facture, propale...) + print '"; + print "\n"; - print ''; - print ''; - if ($product->type == 0 && $conf->stock->enabled) - { - print "".''; - } - else - { - print ''; - } + if ($product->type == 1) + { + print '"; - print "\n"; + print ''; + } + else + { + // Le poids ne concerne que les produits et pas les services + print ''; + } - if ($product->type == 1) - { - print '"; - print ''; - } - else - { - // Le poids ne concerne que les produits et pas les services - print ''; - } - - // Note - print '"; - - print ''; - print '
'.$langs->trans("Ref").'
'.$langs->trans("Label").'
'.$langs->trans("Description").''; + print "\n"; + if ($conf->fckeditor->enabled && $conf->global->FCKEDITOR_ENABLE_DETAILS) + { + require_once(DOL_DOCUMENT_ROOT."/lib/doleditor.class.php"); + $doleditor=new DolEditor('desc',$product->description,160,'dolibarr_notes','',false); + $doleditor->Create(); + } + else + { + print '"; + } + print "
'.$langs->trans("VATRate").''; - print $html->select_tva("tva_tx", $product->tva_tx, $mysoc, '', $product->tva_tx); - print '
'.$langs->trans("Status").''; - print '
Seuil stock'; - print ''; - print '
'.$langs->trans("Duration").''; + print '  '; + print 'duration_unit=='d'?' checked':'').'>'.$langs->trans("Day"); + print '  '; + print 'duration_unit=='w'?' checked':'').'>'.$langs->trans("Week"); + print '  '; + print 'duration_unit=='m'?' checked':'').'>'.$langs->trans("Month"); + print '  '; + print 'duration_unit=='y'?' checked':'').'>'.$langs->trans("Year"); - // Description (utilisé dans facture, propale...) - print '
'.$langs->trans("Description").''; - print "\n"; - if ($conf->fckeditor->enabled && $conf->global->FCKEDITOR_ENABLE_DETAILS) - { - require_once(DOL_DOCUMENT_ROOT."/lib/doleditor.class.php"); - $doleditor=new DolEditor('desc',$product->description,160,'dolibarr_notes','',false); - $doleditor->Create(); - } - else - { - print '"; - } - print "
'.$langs->trans("Weight").''; + print ''; + print $html->select_weight_units("weight_units",$product->weight_units); + print '
'.$langs->trans("Duration").''; - print '  '; - print 'duration_unit=='d'?' checked':'').'>'.$langs->trans("Day"); - print '  '; - print 'duration_unit=='w'?' checked':'').'>'.$langs->trans("Week"); - print '  '; - print 'duration_unit=='m'?' checked':'').'>'.$langs->trans("Month"); - print '  '; - print 'duration_unit=='y'?' checked':'').'>'.$langs->trans("Year"); + // Note + print '
'.$langs->trans("NoteNotVisibleOnBill").''; + if ($conf->fckeditor->enabled && $conf->global->FCKEDITOR_ENABLE_PRODUCTDESC) + { + require_once(DOL_DOCUMENT_ROOT."/lib/doleditor.class.php"); + $doleditor=new DolEditor('note',$product->note,200,'dolibarr_notes','',false); + $doleditor->Create(); + } + else + { + print '"; + } + print "
'.$langs->trans("Weight").''; - print ''; - print $html->select_weight_units("weight_units",$product->weight_units); - print '
'.$langs->trans("NoteNotVisibleOnBill").''; - if ($conf->fckeditor->enabled && $conf->global->FCKEDITOR_ENABLE_PRODUCTDESC) - { - require_once(DOL_DOCUMENT_ROOT."/lib/doleditor.class.php"); - $doleditor=new DolEditor('note',$product->note,200,'dolibarr_notes','',false); - $doleditor->Create(); - } - else - { - print '"; - } - print "
 '; - print '
'; - print '
'; - print "\n"; - } - else - { - $null = $html->load_tva("tva_tx",$conf->defaulttx,$mysoc,''); - $smarty->assign('tva_taux_value', $html->tva_taux_value); - $smarty->assign('tva_taux_libelle', $html->tva_taux_libelle); - $smarty->display($product->canvas.'-edit.tpl'); - } + print ' '; + print ''; + print ''; + print ''; + print "\n"; } + else + { + $null = $html->load_tva("tva_tx",$conf->defaulttx,$mysoc,''); + $smarty->assign('tva_taux_value', $html->tva_taux_value); + $smarty->assign('tva_taux_libelle', $html->tva_taux_libelle); + $smarty->display($product->canvas.'-edit.tpl'); + } + } } @@ -855,34 +863,34 @@ print "\n
\n"; if ($_GET["action"] == '') { - if ( $user->rights->produit->creer) - { - print ''.$langs->trans("Edit").''; + if ( $user->rights->produit->creer) + { + print ''.$langs->trans("Edit").''; - print ''.$langs->trans("CreateCopy").''; - } + print ''.$langs->trans("CreateCopy").''; + } - /* - if ($product->type == 0 && $user->rights->commande->creer) - { - $langs->load('orders'); - print ''; - print $langs->trans("CreateCustomerOrder").''; - } + /* + if ($product->type == 0 && $user->rights->commande->creer) + { + $langs->load('orders'); + print ''; + print $langs->trans("CreateCustomerOrder").''; + } - if ($product->type == 0 && $user->rights->fournisseur->commande->creer) - { - $langs->load('orders'); - print ''; - print $langs->trans("CreateSupplierOrder").''; - } - */ + if ($product->type == 0 && $user->rights->fournisseur->commande->creer) + { + $langs->load('orders'); + print ''; + print $langs->trans("CreateSupplierOrder").''; + } + */ - $product_is_used = $product->verif_prod_use($product->id); - if ($user->rights->produit->supprimer && ! $product_is_used) - { - print ''.$langs->trans("Delete").''; - } + $product_is_used = $product->verif_prod_use($product->id); + if ($user->rights->produit->supprimer && ! $product_is_used) + { + print ''.$langs->trans("Delete").''; + } } @@ -891,370 +899,370 @@ print "\n

\n"; if ($_GET["id"] && $_GET["action"] == '' && $product->status) { - $propal = New Propal($db); + $propal = New Propal($db); - print ''; + print '
'; - // Propals - if($conf->propal->enabled && $user->rights->propale->creer) + // Propals + if($conf->propal->enabled && $user->rights->propale->creer) + { + $langs->load("propal"); + + print ''; + + if ($user->rights->commercial->client->voir) { - $langs->load("propal"); - - print ''; - - if ($user->rights->commercial->client->voir) - { - print ''; - } - else - { - print ''; - } - - print ''; - - // Liste de "Mes propals" - print ''; - - if ($user->rights->commercial->client->voir) - { - // Liste de "Other propals" - print ''; - } - - print ''; + print ''; + } + else + { + print ''; } - $commande = New Commande($db); + print ''; + // Liste de "Mes propals" + print ''; - - if ($user->rights->commercial->client->voir) + $var=true; + $num = $db->num_rows($result); + print '
'; + print_titre($langs->trans("AddToMyProposals")) . '
'; - print_titre($langs->trans("AddToMyProposals")) . ''; - print_titre($langs->trans("AddToOtherProposals")) . ' 
'; - - $sql = "SELECT s.nom, s.idp, p.rowid as propalid, p.ref,".$db->pdate("p.datep")." as dp"; - $sql .= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."propal as p"; - $sql .=" WHERE p.fk_soc = s.idp AND p.fk_statut = 0 AND p.fk_user_author = ".$user->id; - $sql .= " ORDER BY p.datec DESC, tms DESC"; - - $result=$db->query($sql); - if ($result) - { - $var=true; - $num = $db->num_rows($result); - print ''; - if ($num) - { - $i = 0; - while ($i < $num) - { - $objp = $db->fetch_object($result); - $var=!$var; - print ''; - print ""; - print "\n"; - print "\n"; - print "\n"; - print ''; - print ''; - print ''; - $i++; - } - } - else { - print ""; - } - print "
"; - print ''; - print "propalid\">".img_object($langs->trans("ShowPropal"),"propal")." ".$objp->ref."idp\">".dolibarr_trunc($objp->nom,18)."".dolibarr_print_date($objp->dp,"%d %b")."'; - print ''.$langs->trans("ReductionShort"); - print '%'; - print " ".$product->stock_proposition; - print ''; - print ''; - print '
"; - print $langs->trans("NoOpenedPropals"); - print "
"; - $db->free($result); - } - - print '
'; - - $var=true; - $otherprop = $propal->liste_array(1, ' <> '.$user->id); - print ''; - - if (is_array($otherprop) && sizeof($otherprop)) - { - $var=!$var; - print ''; - print ''; - print ''; - print ''; - } - else - { - print "'; - } - print '
'; - print ''; - print $langs->trans("OtherPropals").''; - $html->select_array("propalid", $otherprop); - print '
'.$langs->trans("Qty"); - print ''.$langs->trans("ReductionShort"); - print '%'; - print ''; - print ''; - print '
"; - print $langs->trans("NoOtherOpenedPropals"); - print '
'; - - print '
'; + print_titre($langs->trans("AddToOtherProposals")) . ' 
'; - // Commande - if($conf->commande->enabled && $user->rights->commande->creer) + $sql = "SELECT s.nom, s.idp, p.rowid as propalid, p.ref,".$db->pdate("p.datep")." as dp"; + $sql .= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."propal as p"; + $sql .=" WHERE p.fk_soc = s.idp AND p.fk_statut = 0 AND p.fk_user_author = ".$user->id; + $sql .= " ORDER BY p.datec DESC, tms DESC"; + + $result=$db->query($sql); + if ($result) { - $langs->load("orders"); - - print '
'; - print_titre($langs->trans("AddToMyOrders")) . '
'; + if ($num) + { + $i = 0; + while ($i < $num) { - print ''; + $objp = $db->fetch_object($result); + $var=!$var; + print ''; + print ""; + print "\n"; + print "\n"; + print "\n"; + print ''; + print ''; + print ''; + $i++; } - else - { - print ''; - } - - print ''; - - // Liste de "Mes commandes" - print ''; - - if ($user->rights->commercial->client->voir) - { - // Liste de "Other orders" - print ''; - - print ''; + } + else { + print ""; + } + print "
'; - print_titre($langs->trans("AddToOtherOrders")) . '
"; + print ''; + print "propalid\">".img_object($langs->trans("ShowPropal"),"propal")." ".$objp->ref."idp\">".dolibarr_trunc($objp->nom,18)."".dolibarr_print_date($objp->dp,"%d %b")."'; + print ''.$langs->trans("ReductionShort"); + print '%'; + print " ".$product->stock_proposition; + print ''; + print ''; + print '
'; - $sql = "SELECT s.nom, s.idp, c.rowid as commandeid, c.ref,".$db->pdate("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.idp AND c.fk_statut = 0 AND c.fk_user_author = ".$user->id; - $sql .= " ORDER BY c.date_creation DESC"; - - $result=$db->query($sql); - if ($result) - { - $num = $db->num_rows($result); - $var=true; - print ''; - if ($num) - { - $i = 0; - while ($i < $num) - { - $objc = $db->fetch_object($result); - $var=!$var; - print ''; - print ""; - print "\n"; - print "\n"; - print "\n"; - print ''; - print ''; - print ''; - $i++; - } - } - else - { - print "'; - } - print "
"; - print ''; - print "commandeid\">".img_object($langs->trans("ShowOrder"),"order")." ".$objc->ref."idp\">".dolibarr_trunc($objc->nom,18)."".dolibarr_print_date($objc->dc,"%d %b")."'; - print ''.$langs->trans("ReductionShort"); - print '%'; - print " ".$product->stock_proposition; - print ''; - print ''; - print '
"; - print $langs->trans("NoOpenedOrders"); - print '
"; - $db->free($result); - } - - print '
'; - - $var=true; - $othercom = $commande->liste_array(1, ' <> '.$user->id); - print ''; - if (is_array($othercom) && sizeof($othercom)) - { - $var=!$var; - print ''; - print ''; - print ''; - print ''; - } - else - { - print "'; - } - print '
'; - print ''; - print $langs->trans("OtherOrders").''; - $html->select_array("commandeid", $othercom); - print '
'.$langs->trans("Qty"); - print ''.$langs->trans("ReductionShort"); - print '%'; - print ''; - print ''; - print '
"; - print $langs->trans("NoOtherOpenedOrders"); - print '
'; - } - print '
"; + print $langs->trans("NoOpenedPropals"); + print "
"; + $db->free($result); } - // Factures - if($conf->facture->enabled && $user->rights->facture->creer) + print ''; + + if ($user->rights->commercial->client->voir) { + // Liste de "Other propals" + print ''; + + $var=true; + $otherprop = $propal->liste_array(1, ' <> '.$user->id); + print ''; + + if (is_array($otherprop) && sizeof($otherprop)) + { + $var=!$var; + print ''; + print ''; + print ''; + print ''; + } + else + { + print "'; + } + print '
'; + print ''; + print $langs->trans("OtherPropals").''; + $html->select_array("propalid", $otherprop); + print '
'.$langs->trans("Qty"); + print ''.$langs->trans("ReductionShort"); + print '%'; + print ''; + print ''; + print '
"; + print $langs->trans("NoOtherOpenedPropals"); + print '
'; + + print ''; + } + + print ''; + } + + $commande = New Commande($db); - print ''; - print_titre($langs->trans("AddToMyBills")); + // Commande + if($conf->commande->enabled && $user->rights->commande->creer) + { + $langs->load("orders"); - if ($user->rights->commercial->client->voir) + print ''; + print_titre($langs->trans("AddToMyOrders")) . ''; + + if ($user->rights->commercial->client->voir) + { + print ''; + print_titre($langs->trans("AddToOtherOrders")) . ''; + } + else + { + print ''; + } + + print ''; + + // Liste de "Mes commandes" + print ''; + $sql = "SELECT s.nom, s.idp, c.rowid as commandeid, c.ref,".$db->pdate("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.idp AND c.fk_statut = 0 AND c.fk_user_author = ".$user->id; + $sql .= " ORDER BY c.date_creation DESC"; + + $result=$db->query($sql); + if ($result) + { + $num = $db->num_rows($result); + $var=true; + print ''; + if ($num) + { + $i = 0; + while ($i < $num) { - print ''; - } - - print ''; - - // Liste de Mes factures - print ''; - - if ($user->rights->commercial->client->voir) - { - print '"; + print "\n"; + print "\n"; + print "\n"; + print ''; + print ''; + print ''; + $i++; } + } + else + { + print "'; + } + print "
'; - print_titre($langs->trans("AddToOtherBills")); - } - else - { - print '
'; - $sql = "SELECT s.nom, s.idp, f.rowid as factureid, f.facnumber,".$db->pdate("f.datef")." as df"; - $sql .= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."facture as f"; - $sql .=" WHERE f.fk_soc = s.idp AND f.fk_statut = 0 AND f.fk_user_author = ".$user->id; - $sql .= " ORDER BY f.datec DESC, f.rowid DESC"; - - $result=$db->query($sql); - if ($result) - { - $num = $db->num_rows($result); - $var=true; - print ''; - if ($num) - { - $i = 0; - while ($i < $num) - { - $objp = $db->fetch_object($result); - $var=!$var; - print ''; - print ""; - print "\n"; - print "\n"; - print "\n"; - print ''; - print ''; - print ''; - $i++; - } - } - else { - print "'; - } - print "
"; - print ''; - print "factureid\">".img_object($langs->trans("ShowBills"),"bill")." ".$objp->facnumber."idp\">".dolibarr_trunc($objp->nom,18)."".dolibarr_print_date($objp->df,"%d %b")."'; - print ''.$langs->trans("ReductionShort"); - print '%'; - print ''; - print ''; - print '
"; - print $langs->trans("NoDraftBills"); - print '
"; - $db->free($result); - } - else - { - dolibarr_print_error($db); - } - - print '
'; - - // Liste de Autres factures - $var=true; - - $sql = "SELECT s.nom, s.idp, f.rowid as factureid, f.facnumber,".$db->pdate("f.datef")." as df"; - $sql .= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."facture as f"; - $sql .=" WHERE f.fk_soc = s.idp AND f.fk_statut = 0 AND f.fk_user_author <> ".$user->id; - $sql .= " ORDER BY f.datec DESC, f.rowid DESC"; - - $result=$db->query($sql); - if ($result) - { - $num = $db->num_rows($result); - $var=true; - print ''; - if ($num) { - $i = 0; - while ($i < $num) - { - $objp = $db->fetch_object($result); - - $var=!$var; - print ''; - print ""; - print "\n"; - print "\n"; - print ""; - print ''; - print ''; - print ''; - $i++; - } - } - else { - print "'; - } - print "
factureid\">$objp->facnumberidp\">$objp->nom".$langs->trans("Qty"); - print ''; - print "'; - print ''.$langs->trans("ReductionShort"); - print '%'; - print ''; - print ''; - print '
"; - print $langs->trans("NoOtherDraftBills"); - print '
"; - $db->free($result); - } - else - { - dolibarr_print_error($db); - } + $objc = $db->fetch_object($result); + $var=!$var; + print '
'; + print "
"; + print ''; + print "commandeid\">".img_object($langs->trans("ShowOrder"),"order")." ".$objc->ref."idp\">".dolibarr_trunc($objc->nom,18)."".dolibarr_print_date($objc->dc,"%d %b")."'; + print ''.$langs->trans("ReductionShort"); + print '%'; + print " ".$product->stock_proposition; + print ''; + print ''; + print '
"; + print $langs->trans("NoOpenedOrders"); + print '
"; + $db->free($result); + } + print ''; + + if ($user->rights->commercial->client->voir) + { + // Liste de "Other orders" + print ''; + + $var=true; + $othercom = $commande->liste_array(1, ' <> '.$user->id); + print ''; + if (is_array($othercom) && sizeof($othercom)) + { + $var=!$var; + print ''; + print ''; + print ''; + print ''; + } + else + { + print "'; + } + print '
'; + print ''; + print $langs->trans("OtherOrders").''; + $html->select_array("commandeid", $othercom); + print '
'.$langs->trans("Qty"); + print ''.$langs->trans("ReductionShort"); + print '%'; + print ''; + print ''; + print '
"; + print $langs->trans("NoOtherOpenedOrders"); + print '
'; + } + print ''; + + print ''; + } + + // Factures + if($conf->facture->enabled && $user->rights->facture->creer) + { + + + print ''; + print_titre($langs->trans("AddToMyBills")); + + if ($user->rights->commercial->client->voir) + { + print ''; + print_titre($langs->trans("AddToOtherBills")); + } + else + { + print ''; + } + + print ''; + + // Liste de Mes factures + print ''; + $sql = "SELECT s.nom, s.idp, f.rowid as factureid, f.facnumber,".$db->pdate("f.datef")." as df"; + $sql .= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."facture as f"; + $sql .=" WHERE f.fk_soc = s.idp AND f.fk_statut = 0 AND f.fk_user_author = ".$user->id; + $sql .= " ORDER BY f.datec DESC, f.rowid DESC"; + + $result=$db->query($sql); + if ($result) + { + $num = $db->num_rows($result); + $var=true; + print ''; + if ($num) + { + $i = 0; + while ($i < $num) + { + $objp = $db->fetch_object($result); + $var=!$var; + print ''; + print ""; + print "\n"; + print "\n"; + print "\n"; + print ''; + print ''; + print ''; + $i++; + } + } + else { + print "'; + } + print "
"; + print ''; + print "factureid\">".img_object($langs->trans("ShowBills"),"bill")." ".$objp->facnumber."idp\">".dolibarr_trunc($objp->nom,18)."".dolibarr_print_date($objp->df,"%d %b")."'; + print ''.$langs->trans("ReductionShort"); + print '%'; + print ''; + print ''; + print '
"; + print $langs->trans("NoDraftBills"); + print '
"; + $db->free($result); + } + else + { + dolibarr_print_error($db); + } + + print ''; + + if ($user->rights->commercial->client->voir) + { + print ''; + + // Liste de Autres factures + $var=true; + + $sql = "SELECT s.nom, s.idp, f.rowid as factureid, f.facnumber,".$db->pdate("f.datef")." as df"; + $sql .= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."facture as f"; + $sql .=" WHERE f.fk_soc = s.idp AND f.fk_statut = 0 AND f.fk_user_author <> ".$user->id; + $sql .= " ORDER BY f.datec DESC, f.rowid DESC"; + + $result=$db->query($sql); + if ($result) + { + $num = $db->num_rows($result); + $var=true; + print ''; + if ($num) { + $i = 0; + while ($i < $num) + { + $objp = $db->fetch_object($result); + + $var=!$var; + print ''; + print ""; + print "\n"; + print "\n"; + print ""; + print ''; + print ''; + print ''; + $i++; + } + } + else { + print "'; + } + print "
factureid\">$objp->facnumberidp\">$objp->nom".$langs->trans("Qty"); + print ''; + print "'; + print ''.$langs->trans("ReductionShort"); + print '%'; + print ''; + print ''; + print '
"; + print $langs->trans("NoOtherDraftBills"); print '
"; + $db->free($result); + } + else + { + dolibarr_print_error($db); + } } - print ''; + print ''; + } - print '
'; + print ''; + + print '
'; } diff --git a/htdocs/product/price.php b/htdocs/product/price.php index 150f8fbe3a7..b0bb74a7990 100644 --- a/htdocs/product/price.php +++ b/htdocs/product/price.php @@ -24,10 +24,10 @@ */ /** - \file htdocs/product/price.php - \ingroup product - \brief Page de la fiche produit - \version $Revision$ + \file htdocs/product/price.php + \ingroup product + \brief Page de la fiche produit + \version $Revision$ */ require("./pre.inc.php"); @@ -55,22 +55,23 @@ if ($_POST["action"] == 'update_price' && $_POST["cancel"] <> $langs->trans("Cancel") && $user->rights->produit->creer) { $product = new Product($db); - + $result = $product->fetch($_GET["id"]); $product->price = ereg_replace(" ","",$_POST["price"]); - // MultiPrix - if($conf->global->PRODUIT_MULTIPRICES == 1) + $product->price_base_type = $_POST["price_base_type"]; + // MultiPrix + if($conf->global->PRODUIT_MULTIPRICES == 1) + { + for($i=2;$i<=$conf->global->PRODUIT_MULTIPRICES_LIMIT;$i++) { - for($i=2;$i<=$conf->global->PRODUIT_MULTIPRICES_LIMIT;$i++) - { - if($_POST["price_".$i]) - $product->multiprices["$i"]=ereg_replace(" ","",$_POST["price_".$i]); - else - $product->multiprices["$i"] = ""; - } + if($_POST["price_".$i]) + $product->multiprices["$i"]=ereg_replace(" ","",$_POST["price_".$i]); + else + $product->multiprices["$i"] = ""; } - + } + if ( $product->update_price($product->id, $user) > 0 ) { $_GET["action"] = ''; @@ -122,16 +123,27 @@ print ''; // MultiPrix if($conf->global->PRODUIT_MULTIPRICES == 1) { - print ''.$langs->trans("SellingPrice").' 1'.price($product->price).''; - for($i=2;$i<=$conf->global->PRODUIT_MULTIPRICES_LIMIT;$i++) - { - print ''.$langs->trans("SellingPrice").' '.$i.''.price($product->multiprices["$i"]).''; - print ''; - } + print ''.$langs->trans("SellingPrice").' 1'.price($product->price).''; + for($i=2;$i<=$conf->global->PRODUIT_MULTIPRICES_LIMIT;$i++) + { + print ''.$langs->trans("SellingPrice").' '.$i.''.price($product->multiprices["$i"]).''; + print ''; + } } // Prix else - print ''.$langs->trans("SellingPrice").''.price($product->price).''; +{ + print ''.$langs->trans("SellingPrice").''; + if ($product->price_base_type == 'TTC') + { + print price($product->price_ttc).' '.$langs->trans($product->price_base_type).''; + } + else + { + print price($product->price).' '.$langs->trans($product->price_base_type).''; + } +} + // Statut print ''.$langs->trans("Status").''; print $product->getLibStatut(2); @@ -174,30 +186,46 @@ if ($_GET["action"] == 'edit_price' && $user->rights->produit->creer) print ''; print ''; if($conf->global->PRODUIT_MULTIPRICES == 1) - print ''; + { + print ''; + } else - print ''; + { + print ''; + if ($product->price_base_type == 'TTC') + { + print ''; + } print ''; print '
'.$langs->trans('SellingPrice').' 1
'.$langs->trans('SellingPrice').' 1
'.$langs->trans('SellingPrice').'
'.$langs->trans('SellingPrice').''; + print ''; + } + else + { + print ''; + print ''; + } + print '
 '; print '
'; print ''; // MultiPrix - if($conf->global->PRODUIT_MULTIPRICES == 1) + if($conf->global->PRODUIT_MULTIPRICES == 1) + { + for($i=2;$i<=$conf->global->PRODUIT_MULTIPRICES_LIMIT;$i++) { - for($i=2;$i<=$conf->global->PRODUIT_MULTIPRICES_LIMIT;$i++) - { - print '
'; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print '
'.$langs->trans("SellingPrice").' '.$i.'
 '; - print '
'; - print '
'; - } + print '
'; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print '
'.$langs->trans("SellingPrice").' '.$i.'
 '; + print '
'; + print '
'; } + } + } @@ -205,27 +233,23 @@ if ($_GET["action"] == 'edit_price' && $user->rights->produit->creer) $sql = "SELECT p.rowid, p.price, "; if($conf->global->PRODUIT_MULTIPRICES == 1) { - $sql .= "p.price_level, "; - $sql .= $db->pdate("p.date_price")." as dp, u.rowid as user_id, u.login"; - $sql .= " FROM ".MAIN_DB_PREFIX."product_price as p, llx_user as u"; - $sql .= " WHERE fk_product = ".$product->id; - $sql .= " AND p.fk_user_author = u.rowid "; - $sql .= " ORDER BY p.price_level ASC "; - $sql .= ",p.date_price DESC "; + $sql .= "p.price_level, "; + $sql .= $db->pdate("p.date_price")." as dp, u.rowid as user_id, u.login"; + $sql .= " FROM ".MAIN_DB_PREFIX."product_price as p, llx_user as u"; + $sql .= " WHERE fk_product = ".$product->id; + $sql .= " AND p.fk_user_author = u.rowid "; + $sql .= " ORDER BY p.price_level ASC "; + $sql .= ",p.date_price DESC "; } else { - $sql .= $db->pdate("p.date_price")." as dp, u.rowid as user_id, u.login"; - $sql .= " FROM ".MAIN_DB_PREFIX."product_price as p, llx_user as u"; - $sql .= " WHERE fk_product = ".$product->id; - $sql .= " AND p.fk_user_author = u.rowid "; - $sql .= " ORDER BY p.date_price DESC "; + $sql .= $db->pdate("p.date_price")." as dp, u.rowid as user_id, u.login"; + $sql .= " FROM ".MAIN_DB_PREFIX."product_price as p, llx_user as u"; + $sql .= " WHERE fk_product = ".$product->id; + $sql .= " AND p.fk_user_author = u.rowid "; + $sql .= " ORDER BY p.date_price DESC "; } - - - - - + $sql .= $db->plimit(); $result = $db->query($sql) ;