diff --git a/htdocs/product.class.php b/htdocs/product.class.php
index 76d94fae21f..508b0425f26 100644
--- a/htdocs/product.class.php
+++ b/htdocs/product.class.php
@@ -290,6 +290,8 @@ class Product
}
+ // on ne sauvegarde pas des champs vides
+ if ( $this->multilangs["$value"]["libelle"] || $this->multilangs["$value"]["description"] || $this->multilangs["$value"]["note"] )
if (!$this->db->query($sqlU)) // si aucun champ n'est mis a jour
if (!$this->db->query($sqlI)) return -1;
}
@@ -300,10 +302,17 @@ class Product
/**
* \ brief Charge toutes les traductions du produit
*/
- function getMultiLangs()
+ function getMultiLangs($langue='')
{
global $langs;
- $current_lang = $langs->getDefaultLang();
+ $langs_available = $langs->get_available_languages();
+
+ if ( $langue != '')
+ foreach ($langs_available as $value)
+ if ( $value == $langue ) $current_lang = $value; // si $langue est une valeur correcte
+
+ if ( !$current_lang )
+ $current_lang = $langs->getDefaultLang(); // sinon on choisi la langue par defaut
$sql = "SELECT lang, label, description, note";
$sql.= " FROM ".MAIN_DB_PREFIX."product_det";
@@ -325,7 +334,6 @@ class Product
$this->note = $obj->note;
}
}
- }
else
{
$this->error=$langs->trans("Error")." : ".$this->db->error()." - ".$sql;
diff --git a/htdocs/product/fiche.php b/htdocs/product/fiche.php
index 5cb2650a3c0..c090fa7e7ca 100644
--- a/htdocs/product/fiche.php
+++ b/htdocs/product/fiche.php
@@ -89,30 +89,7 @@ if ($_POST["action"] == 'add' && $user->rights->produit->creer)
}
if ( $value != $current_lang )
-
- // MultiLangs
- if($conf->global->PRODUIT_MULTILANGS == 1)
- {
- $langs_available=$langs->get_available_languages();
- $current_lang = $langs->getDefaultLang();
-
- foreach ($langs_available as $value)
- {
- if ($value == $current_lang)
- {
- $product->multilangs["$value"]["libelle"] = $product->libelle;
- $product->multilangs["$value"]["description"] = $product->description;
- $product->multilangs["$value"]["note"] = $product->note;
- }
- else
- {
- $product->multilangs["$value"]["libelle"] = stripslashes($_POST["libelle-".$value]);
- $product->multilangs["$value"]["description"] = stripslashes($_POST["desc-".$value]);
- $product->multilangs["$value"]["note"] = stripslashes($_POST["note-".$value]);
- }
- }
- }
-
+
$e_product = $product;
$id = $product->create($user);
@@ -153,29 +130,6 @@ if ($_POST["action"] == 'update' &&
$product->duration_value = $_POST["duration_value"];
$product->duration_unit = $_POST["duration_unit"];
- // MultiLangs
- if($conf->global->PRODUIT_MULTILANGS == 1)
- {
- $langs_available=$langs->get_available_languages();
- $current_lang = $langs->getDefaultLang();
-
- foreach ($langs_available as $value)
- {
- if ($value == $current_lang)
- {
- $product->multilangs["$value"]["libelle"] = $product->libelle;
- $product->multilangs["$value"]["description"] = $product->description;
- $product->multilangs["$value"]["note"] = $product->note;
- }
- else
- {
- $product->multilangs["$value"]["libelle"] = stripslashes($_POST["libelle-".$value]);
- $product->multilangs["$value"]["description"] = stripslashes($_POST["desc-".$value]);
- $product->multilangs["$value"]["note"] = stripslashes($_POST["note-".$value]);
- }
- }
- }
-
if ($product->check())
{
if ($product->update($product->id, $user) > 0)
@@ -428,24 +382,6 @@ if ($_GET["action"] == 'create' && $user->rights->produit->creer)
print '";
- // Gestion multilingue
- if($conf->global->PRODUIT_MULTILANGS == 1)
- {
- print '
';
print '';
@@ -519,6 +455,14 @@ if ($_GET["id"] || $_GET["ref"])
$h++;
}
}
+
+ // Multilangs
+ if($conf->global->PRODUIT_MULTILANGS == 1)
+ {
+ $head[$h][0] = DOL_URL_ROOT."/product/traduction.php?id=".$product->id;
+ $head[$h][1] = $langs->trans("Translation");
+ $h++;
+ }
if ($conf->fournisseur->enabled)
{
@@ -660,23 +604,6 @@ if ($_GET["id"] || $_GET["ref"])
// Note
print '| '.$langs->trans("Note").' | '.nl2br($product->note).' |
';
- // Multilangs
- if ($conf->global->PRODUIT_MULTILANGS == 1)
- {
- print "\n";
- print '';
- $langs_available=$langs->get_available_languages();
- $current_lang = $langs->getDefaultLang();
- foreach ($langs_available as $value)
- if ( $value != $current_lang )
- {
- print '| '.$value.' | ';
- print ''.$langs->trans("Label").' | '.$product->multilangs[$value]['libelle'].' |
';
- print '| '.$langs->trans("Description").' | '.$product->multilangs[$value]['description'].' |
';
- print '| '.$langs->trans("Note").' | '.$product->multilangs[$value]['note'].' |
';
- }
- }
-
print "
\n";
print "\n";
@@ -756,25 +683,6 @@ if ($_GET["id"] || $_GET["ref"])
print '";
-
- // Gestion multilingue
- if($conf->global->PRODUIT_MULTILANGS == 1)
- {
- print '';
diff --git a/htdocs/product/traduction.php b/htdocs/product/traduction.php
new file mode 100644
index 00000000000..0f05ef14ef6
--- /dev/null
+++ b/htdocs/product/traduction.php
@@ -0,0 +1,341 @@
+
+*
+* 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.
+* or see http://www.gnu.org/
+*
+* $Id$
+* $Source$
+*/
+
+/**
+ \file htdocs/product/traduction.php
+ \ingroup product
+ \brief Page de traduction des produits
+ \version $Revision$
+*/
+
+require("./pre.inc.php");
+require_once(DOL_DOCUMENT_ROOT."/product.class.php");
+
+$langs->load("products");
+$langs->load("bills");
+
+$user->getrights('produit');
+
+if (!$user->rights->produit->lire)
+accessforbidden();
+
+
+$types[0] = $langs->trans("Product");
+$types[1] = $langs->trans("Service");
+
+
+/*
+ * Actions
+ */
+
+// retour a l'affichage des traduction si annulation
+if ($_POST["cancel"] == $langs->trans("Cancel"))
+{
+ $_GET["action"] = '';
+}
+
+// Validation de l'ajout
+if ($_POST["action"] == 'vadd' &&
+ $_POST["cancel"] != $langs->trans("Cancel") &&
+ $user->rights->produit->creer)
+{
+ $product = new Product($db);
+ $product->fetch($_POST["id"]);
+ $current_lang = $langs->getDefaultLang();
+
+ print $_POST["lang"].'
';
+ // update de l'objet
+ if ( $_POST["lang"] == $current_lang )
+ {
+ $product->libelle = $_POST["libelle"];
+ $product->description = $_POST["desc"];
+ $product->note = $_POST["note"];
+ }
+ else
+ {
+ $product->multilangs[$_POST["lang"]]["libelle"] = $_POST["libelle"];
+ $product->multilangs[$_POST["lang"]]["description"] = $_POST["desc"];
+ $product->multilangs[$_POST["lang"]]["note"] = $_POST["note"];
+ }
+
+ // sauvegarde en base
+ if ( $product->update($product->id, $user) > 0 )
+ {
+ $_GET["action"] = '';
+ $mesg = 'Fiche mise à jour';
+ }
+ else
+ {
+ $_GET["action"] = 'add';
+ $mesg = 'Fiche non mise à jour !' . "
" . $product->mesg_error;
+ }
+}
+
+// Validation de l'edition
+if ($_POST["action"] == 'vedit' &&
+ $_POST["cancel"] != $langs->trans("Cancel") &&
+ $user->rights->produit->creer)
+{
+ $product = new Product($db);
+ $product->fetch($_POST["id"]);
+ $current_lang = $langs->getDefaultLang();
+
+ foreach ( $product->multilangs as $key => &$value ) // enregistrement des nouvelles valeurs dans l'objet
+ {
+ if ( $key == $current_lang )
+ {
+ $product->libelle = $_POST["libelle-".$key];
+ $product->description = $_POST["desc-".$key];
+ $product->note = $_POST["note-".$key];
+ }
+ else
+ {
+ $value["libelle"] = $_POST["libelle-".$key];
+ $value["description"] = $_POST["desc-".$key];
+ $value["note"] = $_POST["note-".$key];
+ }
+ }
+
+ if ( $product->update($product->id, $user) > 0 )
+ {
+ $_GET["action"] = '';
+ $mesg = 'Fiche mise à jour';
+ }
+ else
+ {
+ $_GET["action"] = 'edit';
+ $mesg = 'Fiche non mise à jour !' . "
" . $product->mesg_error;
+ }
+}
+
+$product = new Product($db);
+if ($_GET["ref"]) $result = $product->fetch('',$_GET["ref"]);
+if ($_GET["id"]) $result = $product->fetch($_GET["id"]);
+
+/*
+ * Définition des onglets
+ */
+$h=0;
+
+$head[$h][0] = DOL_URL_ROOT."/product/fiche.php?id=".$product->id;
+$head[$h][1] = $langs->trans("Card");
+$h++;
+
+$head[$h][0] = DOL_URL_ROOT."/product/price.php?id=".$product->id;
+$head[$h][1] = $langs->trans("Price");
+$h++;
+
+//affichage onglet catégorie
+if ($conf->categorie->enabled)
+{
+ $head[$h][0] = DOL_URL_ROOT."/product/categorie.php?id=".$product->id;
+ $head[$h][1] = $langs->trans('Categories');
+ $h++;
+}
+
+if($product->type == 0)
+{
+ if ($user->rights->barcode->lire)
+ {
+ if ($conf->barcode->enabled)
+ {
+ $head[$h][0] = DOL_URL_ROOT."/product/barcode.php?id=".$product->id;
+ $head[$h][1] = $langs->trans("BarCode");
+ $h++;
+ }
+ }
+}
+
+$head[$h][0] = DOL_URL_ROOT."/product/photos.php?id=".$product->id;
+$head[$h][1] = $langs->trans("Photos");
+$h++;
+
+if($product->type == 0)
+{
+ if ($conf->stock->enabled)
+ {
+ $head[$h][0] = DOL_URL_ROOT."/product/stock/product.php?id=".$product->id;
+ $head[$h][1] = $langs->trans("Stock");
+ $h++;
+ }
+}
+
+// Multilangs
+if($conf->global->PRODUIT_MULTILANGS == 1)
+{
+ $head[$h][0] = DOL_URL_ROOT."/product/traduction.php?id=".$product->id;
+ $head[$h][1] = $langs->trans("Translation");
+ $hselected=$h;
+ $h++;
+}
+
+if ($conf->fournisseur->enabled) {
+ $head[$h][0] = DOL_URL_ROOT."/product/fournisseurs.php?id=".$product->id;
+ $head[$h][1] = $langs->trans("Suppliers");
+ $h++;
+}
+
+$head[$h][0] = DOL_URL_ROOT."/product/stats/fiche.php?id=".$product->id;
+$head[$h][1] = $langs->trans("Statistics");
+$h++;
+
+// sousproduits
+if($conf->global->PRODUIT_SOUSPRODUITS == 1)
+{
+ $head[$h][0] = DOL_URL_ROOT."/product/sousproduits.php?id=".$product->id;
+ $head[$h][1] = $langs->trans('AssociatedProducts');
+ $h++;
+}
+
+$head[$h][0] = DOL_URL_ROOT."/product/stats/facture.php?id=".$product->id;
+$head[$h][1] = $langs->trans("Referers");
+$h++;
+
+$head[$h][0] = DOL_URL_ROOT.'/product/document.php?id='.$product->id;
+$head[$h][1] = $langs->trans('Documents');
+$h++;
+
+/*
+ * Affichage
+ */
+
+llxHeader("","",$langs->trans("Translation"));
+
+$titre=$langs->trans("CardProduct".$product->type);
+
+if ( $_GET["action"] != 'edit') dolibarr_fiche_head($head, $hselected, $titre);
+
+print '';
+
+// Reference
+print '';
+print '| '.$langs->trans("Ref").' | ';
+if ($_GET["action"] != 'edit')
+{
+ $product->load_previous_next_ref();
+ $previous_ref = $product->ref_previous?''.img_previous().'':'';
+ $next_ref = $product->ref_next?''.img_next().'':'';
+ if ($previous_ref || $next_ref) print '| ';
+ print ''.$product->ref.'';
+ if ($previous_ref || $next_ref) print ' | '.$previous_ref.' | '.$next_ref.' | ';
+}
+else
+{
+ print ''.$product->ref.'';
+}
+print ' | ';
+print '
';
+print '
';
+
+if ($_GET["action"] == 'edit')
+{
+ print '';
+
+}
+else
+{
+ foreach ( $product->multilangs as $key => $value)
+ {
+ print "
$key :
";
+ print '';
+ print '| '.$langs->trans('Label').' | '.$product->multilangs[$key]["libelle"].' |
';
+ print '| '.$langs->trans('Description').' | '.$product->multilangs[$key]["description"].' |
';
+ print '| '.$langs->trans('Note').' | '.$product->multilangs[$key]["note"].' |
';
+ print '';
+ print '
';
+ }
+}
+
+print "\n";
+
+/* ************************************************************************** */
+/* */
+/* Barre d'action */
+/* */
+/* ************************************************************************** */
+
+print "\n\n";
+
+
+/*
+ * Formulaire d'ajout de traduction
+ */
+if ($_GET["action"] == 'add' || $user->rights->produit->modifier)
+{
+ $langs_available = $langs->get_available_languages();
+ $current_lang = $langs->getDefaultLang();
+
+ // on construit la liste des traduction qui n'existe pas déjà
+ $select = '';
+
+ print '';
+
+
+}
+llxFooter('$Date$ - $Revision$');
+?>