* Copyright (C) 2007 Rodolphe Quiedeville * Copyright (C) 2010-2016 Destailleur Laurent * Copyright (C) 2015 Raphaƫl Doursenaud * * 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/categories.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formadmin.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; $langs->load("categories"); $langs->load("languages"); $id = GETPOST('id', 'int'); $ref = GETPOST('ref', 'alpha'); $action = GETPOST('action','alpha'); $cancel = GETPOST('cancel','alpha'); $type = GETPOST('type','aZ09'); if (is_numeric($type)) $type=Categorie::$MAP_ID_TO_CODE[$type]; // For backward compatibility // Security check $fieldvalue = (! empty($id) ? $id : (! empty($ref) ? $ref : '')); $fieldtype = (! empty($ref) ? 'ref' : 'rowid'); if ($id == "") { dol_print_error('','Missing parameter id'); exit(); } // Security check $result = restrictedArea($user, 'categorie', $id, '&category'); $object = new Categorie($db); /* * Actions */ // retour a l'affichage des traduction si annulation if ($cancel == $langs->trans("Cancel")) { $action = ''; } // Validation de l'ajout if ($action == 'vadd' && $cancel != $langs->trans("Cancel") && ($user->rights->categorie->creer )) { $object->fetch($id); $current_lang = $langs->getDefaultLang(); // update de l'objet if ( $_POST["forcelangprod"] == $current_lang ) { $object->label = $_POST["libelle"]; $object->description = dol_htmlcleanlastbr($_POST["desc"]); } else { $object->multilangs[$_POST["forcelangprod"]]["label"] = $_POST["libelle"]; $object->multilangs[$_POST["forcelangprod"]]["description"] = dol_htmlcleanlastbr($_POST["desc"]); } // sauvegarde en base if ( $object->setMultiLangs($user) > 0 ) { $action = ''; } else { $action = 'add'; setEventMessages($object->error, $object->errors, 'errors'); } } // Validation de l'edition if ($action == 'vedit' && $cancel != $langs->trans("Cancel") && ($user->rights->categorie->creer)) { $object->fetch($id); $current_lang = $langs->getDefaultLang(); foreach ( $object->multilangs as $key => $value ) // enregistrement des nouvelles valeurs dans l'objet { if ( $key == $current_lang ) { $object->label = $_POST["libelle-".$key]; $object->description = dol_htmlcleanlastbr($_POST["desc-".$key]); } else { $object->multilangs[$key]["label"] = $_POST["libelle-".$key]; $object->multilangs[$key]["description"] = dol_htmlcleanlastbr($_POST["desc-".$key]); } } if ( $object->setMultiLangs($user) > 0 ) { $action = ''; } else { $action = 'edit'; setEventMessages($object->error, $object->errors, 'errors'); } } $result = $object->fetch($id,$ref); /* * View */ llxHeader("","",$langs->trans("Translation")); $form = new Form($db); $formadmin=new FormAdmin($db); $formother = new FormOther($db); if ($type == Categorie::TYPE_PRODUCT) $title=$langs->trans("ProductsCategoryShort"); elseif ($type == Categorie::TYPE_SUPPLIER) $title=$langs->trans("SuppliersCategoryShort"); elseif ($type == Categorie::TYPE_CUSTOMER) $title=$langs->trans("CustomersCategoryShort"); elseif ($type == Categorie::TYPE_MEMBER) $title=$langs->trans("MembersCategoryShort"); elseif ($type == Categorie::TYPE_CONTACT) $title=$langs->trans("ContactCategoriesShort"); elseif ($type == Categorie::TYPE_ACCOUNT) $title=$langs->trans("AccountsCategoriesShort"); elseif ($type == Categorie::TYPE_PROJECT) $title=$langs->trans("ProjectsCategoriesShort"); elseif ($type == Categorie::TYPE_USER) $title=$langs->trans("UsersCategoriesShort"); else $title=$langs->trans("Category"); $head = categories_prepare_head($object,$type); // Calculate $cnt_trans $cnt_trans = 0; if (! empty($object->multilangs)) { foreach ($object->multilangs as $key => $value) { $cnt_trans++; } } dol_fiche_head($head, 'translation', $title, -1, 'category'); $linkback = ''.$langs->trans("BackToList").''; $object->ref = $object->label; $morehtmlref='
'.$langs->trans("Root").' >> '; $ways = $object->print_all_ways(" >> ", '', 1); foreach ($ways as $way) { $morehtmlref.=$way."
\n"; } $morehtmlref.='
'; dol_banner_tab($object, 'ref', $linkback, ($user->societe_id?0:1), 'ref', 'ref', $morehtmlref, '', 0, '', '', 1); print '
'; print '
'; print '
'; print ''; // Description print ''; // Color print ''; print '
'; print $langs->trans("Description").''; print dol_htmlentitiesbr($object->description); print '
'; print $langs->trans("Color").''; print $formother->showColor($object->color); print '
'; print '
'; dol_fiche_end(); /* ************************************************************************** */ /* */ /* Barre d'action */ /* */ /* ************************************************************************** */ print "\n
\n"; if ($action == '') { if ($user->rights->produit->creer || $user->rights->service->creer) { print ''.$langs->trans("Add").''; if ($cnt_trans > 0) print ''.$langs->trans("Update").''; } } print "\n
\n"; if ($action == 'edit') { //WYSIWYG Editor require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; print '
'; print ''; print ''; print ''; if (! empty($object->multilangs)) { foreach ($object->multilangs as $key => $value) { print "
".$langs->trans('Language_'.$key)." :
"; print ''; print ''; print ''; print ''; print '
'.$langs->trans('Label').'
'.$langs->trans('Description').''; $doleditor = new DolEditor("desc-$key", $object->multilangs[$key]["description"], '', 160, 'dolibarr_notes', '', false, true, $conf->global->FCKEDITOR_ENABLE_PRODUCTDESC, ROWS_3,'90%'); $doleditor->Create(); print '
'; } } print '
'; print '
'; print ''; print '     '; print ''; print '
'; print '
'; } else if ($action != 'add') { if ($cnt_trans) print '
'; if (! empty($object->multilangs)) { foreach ($object->multilangs as $key => $value) { $s=picto_from_langcode($key); print ''; print ''; print ''; print ''; if (! empty($conf->global->CATEGORY_USE_OTHER_FIELD_IN_TRANSLATION)) { print ''; } print '
'.($s?$s.' ':'')." ".$langs->trans('Language_'.$key).": ".''.img_delete('', '').'
'.$langs->trans('Label').''.$object->multilangs[$key]["label"].'
'.$langs->trans('Description').''.$object->multilangs[$key]["description"].'
'.$langs->trans('Other').' ('.$langs->trans("NotUsed").')'.$object->multilangs[$key]["other"].'
'; } } if (! $cnt_trans && $action != 'add') print '
'. $langs->trans('NoTranslation').'
'; } /* * 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 '
'.$langs->trans('Translation').''; print $formadmin->select_language('','forcelangprod',0,$object->multilangs); print '
'.$langs->trans('Label').'
'.$langs->trans('Description').''; $doleditor = new DolEditor('desc', '', '', 160, 'dolibarr_notes', '', false, true, $conf->global->FCKEDITOR_ENABLE_PRODUCTDESC, ROWS_3,'90%'); $doleditor->Create(); print '
'; print '
'; print ''; print '     '; print ''; print '
'; print '
'; print '
'; } llxFooter(); $db->close();