* Copyright (C) 2007 Rodolphe Quiedeville * Copyright (C) 2010-2012 Destailleur Laurent * Copyright (C) 2014 Henry Florian * * 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 3 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, see . * or see http://www.gnu.org/ */ /** * \file htdocs/product/traduction.php * \ingroup product * \brief Page de traduction des produits */ require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/product.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formadmin.class.php'; $langs->load("products"); $langs->load("languages"); $id = GETPOST('id', 'int'); $ref = GETPOST('ref', 'alpha'); $action=GETPOST('action','alpha'); $cancel=GETPOST('cancel','alpha'); // Security check $fieldvalue = (! empty($id) ? $id : (! empty($ref) ? $ref : '')); $fieldtype = (! empty($ref) ? 'ref' : 'rowid'); if ($user->societe_id) $socid=$user->societe_id; $result=restrictedArea($user,'produit|service',$fieldvalue,'product&product','','',$fieldtype); /* * Actions */ // retour a l'affichage des traduction si annulation if ($cancel == $langs->trans("Cancel")) { $action = ''; } if ($action == 'delete' && GETPOST('langtodelete','alpha')) { $product = new Product($db); $product->fetch($id); $product->delMultiLangs(GETPOST('langtodelete','alpha')); } // Add translation if ($action == 'vadd' && $cancel != $langs->trans("Cancel") && ($user->rights->produit->creer || $user->rights->service->creer)) { $product = new Product($db); $product->fetch($id); $current_lang = $langs->getDefaultLang(); // update de l'objet if ( $_POST["forcelangprod"] == $current_lang ) { $product->label = $_POST["libelle"]; $product->description = dol_htmlcleanlastbr($_POST["desc"]); $product->note = dol_htmlcleanlastbr($_POST["note"]); } else { $product->multilangs[$_POST["forcelangprod"]]["label"] = $_POST["libelle"]; $product->multilangs[$_POST["forcelangprod"]]["description"] = dol_htmlcleanlastbr($_POST["desc"]); $product->multilangs[$_POST["forcelangprod"]]["note"] = dol_htmlcleanlastbr($_POST["note"]); } // sauvegarde en base if ( $product->setMultiLangs() > 0 ) { $action = ''; } else { $action = 'add'; setEventMessage($product->error,'errors'); } } // Edit translation if ($action == 'vedit' && $cancel != $langs->trans("Cancel") && ($user->rights->produit->creer || $user->rights->service->creer)) { $product = new Product($db); $product->fetch($id); $current_lang = $langs->getDefaultLang(); foreach ( $product->multilangs as $key => $value ) // enregistrement des nouvelles valeurs dans l'objet { if ( $key == $current_lang ) { $product->label = $_POST["libelle-".$key]; $product->description = dol_htmlcleanlastbr($_POST["desc-".$key]); $product->note = dol_htmlcleanlastbr($_POST["note-".$key]); } else { $product->multilangs[$key]["label"] = $_POST["libelle-".$key]; $product->multilangs[$key]["description"] = dol_htmlcleanlastbr($_POST["desc-".$key]); $product->multilangs[$key]["note"] = dol_htmlcleanlastbr($_POST["note-".$key]); } } if ( $product->setMultiLangs() > 0 ) { $action = ''; } else { $action = 'edit'; setEventMessage($product->error,'errors'); } } // Delete translation if ($action == 'vdelete' && $cancel != $langs->trans("Cancel") && ($user->rights->produit->creer || $user->rights->service->creer)) { $product = new Product($db); $product->fetch($id); $langtodelete=GETPOST('langdel','alpha'); if ( $product->delMultiLangs($langtodelete) > 0 ) { $action = ''; } else { $action = 'edit'; setEventMessage($product->error,'errors'); } } $product = new Product($db); $result = $product->fetch($id,$ref); /* * View */ llxHeader("","",$langs->trans("Translation")); $form = new Form($db); $formadmin=new FormAdmin($db); $head=product_prepare_head($product); $titre=$langs->trans("CardProduct".$product->type); $picto=($product->type==Product::TYPE_SERVICE?'service':'product'); dol_fiche_head($head, 'translation', $titre, 0, $picto); print ''; // Reference print ''; print ''; print ''; print '
'.$langs->trans("Ref").''; print $form->showrefnav($product,'ref','',1,'ref'); print '
'; if ($action == 'edit') { //WYSIWYG Editor require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; print '
'; print ''; print ''; print ''; if (! empty($product->multilangs)) { foreach ($product->multilangs as $key => $value) { print "
".$langs->trans('Language_'.$key)." :
"; print ''; print ''; print ''; print ''; print ''; print '
'.$langs->trans('Label').'
'.$langs->trans('Description').''; $doleditor = new DolEditor("desc-$key", $product->multilangs[$key]["description"], '', 160, 'dolibarr_notes', '', false, true, $conf->global->FCKEDITOR_ENABLE_PRODUCTDESC, 3, 80); $doleditor->Create(); print '
'.$langs->trans('Note').''; $doleditor = new DolEditor("note-$key", $product->multilangs[$key]["note"], '', 160, 'dolibarr_notes', '', false, true, $conf->global->FCKEDITOR_ENABLE_PRODUCTDESC, 3, 80); $doleditor->Create(); print '
'.$langs->trans("Delete").'
'; } } print '
'; print ''; print '     '; print ''; print '
'; print '
'; } else { $cnt_trans = 0; if (! empty($product->multilangs)) { foreach ($product->multilangs as $key => $value) { $cnt_trans++; $s=picto_from_langcode($key); print "
".($s?$s.' ':'')." ".$langs->trans('Language_'.$key).": ".''.img_delete('', '')."
"; print ''; print ''; print ''; print ''; print '
'.$langs->trans('Label').''.$product->multilangs[$key]["label"].'
'.$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 ($action == '') if ($user->rights->produit->creer || $user->rights->service->creer) { print ''.$langs->trans("Add").''; print ''.$langs->trans("Update").''; } print "\n
\n"; /* * Form to add a new translation */ if ($action == 'add' && ($user->rights->produit->creer || $user->rights->service->creer)) { //WYSIWYG Editor require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; print '
'; print '
'; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print '
'.$langs->trans('Language').''; print $formadmin->select_language('','forcelangprod',0,$product->multilangs,1); print '
'.$langs->trans('Label').'
'.$langs->trans('Description').''; $doleditor = new DolEditor('desc', '', '', 160, 'dolibarr_notes', '', false, true, $conf->global->FCKEDITOR_ENABLE_PRODUCTDESC, 3, 80); $doleditor->Create(); print '
'.$langs->trans('Note').''; $doleditor = new DolEditor('note', '', '', 160, 'dolibarr_notes', '', false, true, $conf->global->FCKEDITOR_ENABLE_PRODUCTDESC, 3, 80); $doleditor->Create(); print '
'; print '
'; print ''; print '     '; print ''; print '
'; print '
'; print '
'; } llxFooter(); $db->close();