* Copyright (C) 2007 Rodolphe Quiedeville * * 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."/lib/product.lib.php"); require_once(DOL_DOCUMENT_ROOT."/product.class.php"); $langs->load("products"); $langs->load("bills"); if (!$user->rights->produit->lire) accessforbidden(); /* * 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(); // 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->setMultiLangs() > 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 { $product->multilangs[$key]["libelle"] = $_POST["libelle-".$key]; $product->multilangs[$key]["description"] = $_POST["desc-".$key]; $product->multilangs[$key]["note"] = $_POST["note-".$key]; } } if ( $product->setMultiLangs() > 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"]); /* * Affichage */ llxHeader("","",$langs->trans("Translation")); $html = new Form($db); $head=product_prepare_head($product, $user); $titre=$langs->trans("CardProduct".$product->type); dolibarr_fiche_head($head, 'translation', $titre); print ''; // Reference print ''; print ''; print ''; print '
'.$langs->trans("Ref").''; print $html->showrefnav($product,'ref','',1,'ref'); print '
'; if ($_GET["action"] == 'edit') { print '
'; print ''; print ''; foreach ( $product->multilangs as $key => $value) { print "
$key :
"; print ''; print ''; print ''; print ''; print ''; print '
'.$langs->trans('Label').'
'.$langs->trans('Description').''; if ($conf->fckeditor->enabled && $conf->global->FCKEDITOR_ENABLE_PRODUCTDESC) { require_once(DOL_DOCUMENT_ROOT."/lib/doleditor.class.php"); $doleditor=new DolEditor('desc-'.$key.'',$product->multilangs[$key]["description"],160,'dolibarr_notes','',false); $doleditor->Create(); } else { print ''; } print '
'.$langs->trans('Note').''; if ($conf->fckeditor->enabled && $conf->global->FCKEDITOR_ENABLE_PRODUCTDESC) { require_once(DOL_DOCUMENT_ROOT."/lib/doleditor.class.php"); $doleditor=new DolEditor('note-'.$key.'',$product->multilangs[$key]["note"],160,'dolibarr_notes','',false); $doleditor->Create(); } else { print ''; } print '
'; } print '
'; print ''; print '
 '; print '
'; print '
'; } else { $cnt_trans = 0; foreach ( $product->multilangs as $key => $value) { $cnt_trans++; print "
$key :
"; print ''; print ''; print ''; print ''; print '
'.$langs->trans('Label').''.$product->multilangs[$key]["libelle"].'
'.$langs->trans('Description').''.$product->multilangs[$key]["description"].'
'.$langs->trans('Note').''.$product->multilangs[$key]["note"].'
'; } if ( !$cnt_trans ) print '
'. $langs->trans('NoTranslation'); } print "\n"; /* ************************************************************************** */ /* */ /* Barre d'action */ /* */ /* ************************************************************************** */ print "\n
\n"; if ($_GET["action"] == '') if ($user->rights->produit->modifier || $user->rights->produit->creer) { print ''.$langs->trans("Update").''; print ''.$langs->trans("Add").''; } 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 '
'; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print '
'.$langs->trans('Translation').''.$select.'
'.$langs->trans('Label').'
'.$langs->trans('Description').'
'.$langs->trans('Note').'
'; print '
'; print ''; print '
 '; print '
'; print '
'; } llxFooter('$Date$ - $Revision$'); ?>