diff --git a/htdocs/includes/modules/modProduct.class.php b/htdocs/includes/modules/modProduct.class.php
index fa910441846..e950bdc3199 100644
--- a/htdocs/includes/modules/modProduct.class.php
+++ b/htdocs/includes/modules/modProduct.class.php
@@ -73,7 +73,7 @@ class modProduct extends DolibarrModules
// Config pages
$this->config_page_url = array("produit.php@product");
- $this->langfiles = array("product@products","companies","stocks","bills");
+ $this->langfiles = array("products@product","companies","stocks","bills");
// Constants
$this->const = array();
diff --git a/htdocs/lib/functions.lib.php b/htdocs/lib/functions.lib.php
index 8edea500ad4..54062ea18e8 100644
--- a/htdocs/lib/functions.lib.php
+++ b/htdocs/lib/functions.lib.php
@@ -2028,6 +2028,38 @@ function print_titre($titre)
print '
'.$titre.'
';
}
+/**
+ * \brief Load a title with picto
+ * \param titre Title to show
+ * \param mesg Added message to show on right
+ * \param picto Icon to use before title (should be a 32x32 transparent png file)
+ * \param pictoisfullpath 1=Icon name is a full absolute url of image
+ * \param id To force an id on html objects
+ */
+function load_fiche_titre($titre, $mesg='', $picto='title.png', $pictoisfullpath=0, $id='')
+{
+ global $conf;
+
+ $return='';
+
+ if ($picto == 'setup') $picto='title.png';
+ if (empty($conf->browser->firefox) && $picto=='title.png') $picto='title.gif';
+
+ $return.= "\n";
+ $return.= '';
+ if (empty($conf->browser->phone) && $picto && $titre) $return.= ''.img_picto('',$picto, 'id="pictotitle"', $pictoisfullpath).' ';
+ $return.= '';
+ $return.= ''.$titre.'
';
+ $return.= ' ';
+ if (strlen($mesg))
+ {
+ $return.= ''.$mesg.' ';
+ }
+ $return.= '
'."\n";
+
+ return $return;
+}
+
/**
* \brief Show a title with picto
* \param titre Title to show
@@ -2038,22 +2070,7 @@ function print_titre($titre)
*/
function print_fiche_titre($titre, $mesg='', $picto='title.png', $pictoisfullpath=0, $id='')
{
- global $conf;
-
- if ($picto == 'setup') $picto='title.png';
- if (empty($conf->browser->firefox) && $picto=='title.png') $picto='title.gif';
-
- print "\n";
- print '';
- if (empty($conf->browser->phone) && $picto && $titre) print ''.img_picto('',$picto, 'id="pictotitle"', $pictoisfullpath).' ';
- print '';
- print ''.$titre.'
';
- print ' ';
- if (strlen($mesg))
- {
- print ''.$mesg.' ';
- }
- print '
'."\n";
+ print load_fiche_titre($titre, $mesg, $picto, $pictoisfullpath, $id);
}
/**
diff --git a/htdocs/product/admin/produit.php b/htdocs/product/admin/produit.php
index 3600244f139..51017df9376 100644
--- a/htdocs/product/admin/produit.php
+++ b/htdocs/product/admin/produit.php
@@ -33,7 +33,7 @@ require_once(DOL_DOCUMENT_ROOT."/includes/barcode/html.formbarcode.class.php");
$langs->load("admin");
$langs->load("propal");
-$langs->load("product@products");
+$langs->load("products@product");
// Security check
if (!$user->admin)
diff --git a/htdocs/product/barcode.php b/htdocs/product/barcode.php
index aaeb552907c..55cad97a848 100644
--- a/htdocs/product/barcode.php
+++ b/htdocs/product/barcode.php
@@ -30,7 +30,7 @@ require_once(DOL_DOCUMENT_ROOT."/lib/product.lib.php");
require_once(DOL_DOCUMENT_ROOT."/product/class/product.class.php");
require_once(DOL_DOCUMENT_ROOT."/includes/barcode/html.formbarcode.class.php");
-$langs->load("product@products");
+$langs->load("products@product");
$langs->load("bills");
// Security check
diff --git a/htdocs/product/canvas/default/product.default.class.php b/htdocs/product/canvas/default/product.default.class.php
index 9827b4eb018..814dc618460 100644
--- a/htdocs/product/canvas/default/product.default.class.php
+++ b/htdocs/product/canvas/default/product.default.class.php
@@ -77,7 +77,7 @@ class ProductDefault extends Product
*/
function assign_values($action='')
{
- global $conf,$html;
+ global $conf,$langs,$html;
// Ref
$this->tpl['showrefnav'] = $html->showrefnav($this,'ref','',1,'ref');
@@ -86,6 +86,11 @@ class ProductDefault extends Product
// Statut
$this->tpl['status'] = $this->getLibStatut(2);
+ if ($action == 'create')
+ {
+ $this->tpl['cardTitle'] = load_fiche_titre($langs->trans("NewProduct"));
+ }
+
if ($action == 'view')
{
$this->tpl['nblignes'] = 4;
diff --git a/htdocs/product/canvas/default/tpl/create.tpl.php b/htdocs/product/canvas/default/tpl/create.tpl.php
index 95f96f603e1..eba87afce1f 100644
--- a/htdocs/product/canvas/default/tpl/create.tpl.php
+++ b/htdocs/product/canvas/default/tpl/create.tpl.php
@@ -26,9 +26,7 @@
-
- else $title=$langs->trans("NewProduct");
- print_fiche_titre($title);
+tpl['cardTitle']; ?>
diff --git a/htdocs/product/document.php b/htdocs/product/document.php
index 22d30adc614..2d8ec82a02f 100755
--- a/htdocs/product/document.php
+++ b/htdocs/product/document.php
@@ -34,7 +34,7 @@ require_once(DOL_DOCUMENT_ROOT."/lib/files.lib.php");
require_once(DOL_DOCUMENT_ROOT."/html.formfile.class.php");
$langs->load("other");
-$langs->load("product@products");
+$langs->load("products@product");
$action=empty($_GET['action']) ? (empty($_POST['action']) ? '' : $_POST['action']) : $_GET['action'];
diff --git a/htdocs/product/fiche.php b/htdocs/product/fiche.php
index ed211a33305..88b9176764a 100644
--- a/htdocs/product/fiche.php
+++ b/htdocs/product/fiche.php
@@ -40,7 +40,7 @@ require_once(DOL_DOCUMENT_ROOT."/commande/class/commande.class.php");
$langs->load("bills");
$langs->load("other");
$langs->load("stocks");
-$langs->load("product@products");
+$langs->load("products@product");
// Security check
if (isset($_GET["id"]) || isset($_GET["ref"]))
@@ -120,19 +120,23 @@ if ($_POST["action"] == 'add' && ($user->rights->produit->creer || $user->rights
$error++;
}
+ if (!empty($_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
+ {
+ $mesg=''.$langs->trans('ErrorFieldRequired',$langs->transnoentities('Ref')).'
';
+ $_GET["action"] = "create";
+ $_GET["canvas"] = $product->canvas;
+ $_GET["type"] = $_POST["type"];
+ $error++;
+ }
+
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"];
@@ -620,7 +624,7 @@ $formproduct = new FormProduct($db);
*/
if ($_GET["action"] == 'create' && ($user->rights->produit->creer || $user->rights->service->creer))
{
- if ($_GET["canvas"] <> '' && file_exists(DOL_DOCUMENT_ROOT.'/product/canvas/'.$_GET["canvas"].'/product.'.$_GET["canvas"].'.class.php'))
+ if (!empty($_GET["canvas"]) && file_exists(DOL_DOCUMENT_ROOT.'/product/canvas/'.$_GET["canvas"].'/product.'.$_GET["canvas"].'.class.php'))
{
if (! isset($product))
{
@@ -632,8 +636,6 @@ if ($_GET["action"] == 'create' && ($user->rights->produit->creer || $user->righ
$product = new $classname($db,0,$user);
}
- $product->assign_smarty_values($smarty, 'create');
-
if ($_error == 1)
{
$product = $e_product;
@@ -654,15 +656,18 @@ if ($_GET["action"] == 'create' && ($user->rights->produit->creer || $user->righ
if ($mesg) print $mesg."\n";
- if ($_GET["canvas"] <> '' && file_exists(DOL_DOCUMENT_ROOT.'/product/canvas/'.$_GET["canvas"].'/product.'.$_GET["canvas"].'.class.php'))
+ if (!empty($_GET["canvas"]) && file_exists(DOL_DOCUMENT_ROOT.'/product/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/';
+ $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');
+ //$smarty->assign('tva_taux_value', $tvaarray['value']);
+ //$smarty->assign('tva_taux_libelle', $tvaarray['label']);
+
+ $product->assign_values('create');
+
+ include($template_dir.'create.tpl.php');
}
else
{
diff --git a/htdocs/product/fournisseurs.php b/htdocs/product/fournisseurs.php
index 6d70af7c646..0dbc8e0b188 100644
--- a/htdocs/product/fournisseurs.php
+++ b/htdocs/product/fournisseurs.php
@@ -31,7 +31,7 @@ require_once(DOL_DOCUMENT_ROOT."/lib/product.lib.php");
require_once(DOL_DOCUMENT_ROOT."/comm/propal/class/propal.class.php");
require_once DOL_DOCUMENT_ROOT."/fourn/class/fournisseur.product.class.php";
-$langs->load("product@products");
+$langs->load("products@product");
$langs->load("suppliers");
$langs->load("bills");
diff --git a/htdocs/product/index.php b/htdocs/product/index.php
index a9215cfde37..c4f36f7b0d1 100644
--- a/htdocs/product/index.php
+++ b/htdocs/product/index.php
@@ -39,7 +39,7 @@ else $result=restrictedArea($user,'produit|service',$id,'service','','',$fieldid
$product_static = new Product($db);
-$langs->load("product@products");
+$langs->load("products@product");
/*
diff --git a/htdocs/product/liste.php b/htdocs/product/liste.php
index 597ece8f7f5..1d21e348b76 100644
--- a/htdocs/product/liste.php
+++ b/htdocs/product/liste.php
@@ -30,7 +30,7 @@ require_once(DOL_DOCUMENT_ROOT.'/product/class/product.class.php');
require_once(DOL_DOCUMENT_ROOT."/html.formother.class.php");
if ($conf->categorie->enabled) require_once(DOL_DOCUMENT_ROOT."/categories/class/categorie.class.php");
-$langs->load("product@products");
+$langs->load("products@product");
$type=trim(isset($_GET["type"])?$_GET["type"]:$_POST["type"]);
diff --git a/htdocs/product/photos.php b/htdocs/product/photos.php
index 63f2e1bf14b..1de7a2d575f 100644
--- a/htdocs/product/photos.php
+++ b/htdocs/product/photos.php
@@ -31,7 +31,7 @@ require_once(DOL_DOCUMENT_ROOT."/lib/product.lib.php");
require_once(DOL_DOCUMENT_ROOT."/product/class/product.class.php");
require_once(DOL_DOCUMENT_ROOT."/html.formfile.class.php");
-$langs->load("product@products");
+$langs->load("products@product");
$langs->load("bills");
// Security check
diff --git a/htdocs/product/price.php b/htdocs/product/price.php
index e69cf4099f7..2baf1f955c0 100644
--- a/htdocs/product/price.php
+++ b/htdocs/product/price.php
@@ -31,7 +31,7 @@ require("../main.inc.php");
require_once(DOL_DOCUMENT_ROOT."/lib/product.lib.php");
require_once(DOL_DOCUMENT_ROOT."/product/class/product.class.php");
-$langs->load("product@products");
+$langs->load("products@product");
$langs->load("bills");
// Security check
diff --git a/htdocs/product/reassort.php b/htdocs/product/reassort.php
index efc0c0b5dc5..3b7e5525313 100644
--- a/htdocs/product/reassort.php
+++ b/htdocs/product/reassort.php
@@ -29,7 +29,7 @@ require("../main.inc.php");
require_once(DOL_DOCUMENT_ROOT.'/product/class/product.class.php');
require_once(DOL_DOCUMENT_ROOT."/categories/class/categorie.class.php");
-$langs->load("product@products");
+$langs->load("products@product");
$langs->load("stocks");
// Security check
diff --git a/htdocs/product/traduction.php b/htdocs/product/traduction.php
index f753db4d577..cff40daccb3 100644
--- a/htdocs/product/traduction.php
+++ b/htdocs/product/traduction.php
@@ -32,7 +32,7 @@ require_once(DOL_DOCUMENT_ROOT."/lib/functions2.lib.php");
require_once(DOL_DOCUMENT_ROOT."/product/class/product.class.php");
require_once(DOL_DOCUMENT_ROOT."/html.formadmin.class.php");
-$langs->load("product@products");
+$langs->load("products@product");
$langs->load("languages");
// Security check