diff --git a/htdocs/adherents/traduction.php b/htdocs/adherents/traduction.php new file mode 100644 index 00000000000..23ed3775735 --- /dev/null +++ b/htdocs/adherents/traduction.php @@ -0,0 +1,323 @@ + + * 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/member.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent_type.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formadmin.class.php'; + +// Load translation files required by the page +$langs->loadLangs(array('members', 'languages')); + +$id = GETPOST('rowid', 'int'); +$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; +// Security check +$result=restrictedArea($user, 'adherent', $id, 'adherent_type'); + + +/* + * Actions + */ + +// retour a l'affichage des traduction si annulation +if ($cancel == $langs->trans("Cancel")) +{ + $action = ''; +} + +if ($action == 'delete' && GETPOST('langtodelete', 'alpha')) +{ + $object = new AdherentType($db); + $object->fetch($id); + $object->delMultiLangs(GETPOST('langtodelete', 'alpha'), $user); +} + +// Add translation +if ($action == 'vadd' && $cancel != $langs->trans("Cancel") && $user->rights->adherent->configurer) +{ + $object = new AdherentType($db); + $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"]); + $object->other = dol_htmlcleanlastbr($_POST["other"]); + } + else + { + $object->multilangs[$_POST["forcelangprod"]]["label"] = $_POST["libelle"]; + $object->multilangs[$_POST["forcelangprod"]]["description"] = dol_htmlcleanlastbr($_POST["desc"]); + $object->multilangs[$_POST["forcelangprod"]]["other"] = dol_htmlcleanlastbr($_POST["other"]); + } + + // sauvegarde en base + if ( $object->setMultiLangs($user) > 0 ) + { + $action = ''; + } + else + { + $action = 'add'; + setEventMessages($object->error, $object->errors, 'errors'); + } +} + +// Edit translation +if ($action == 'vedit' && $cancel != $langs->trans("Cancel") && $user->rights->adherent->configurer) +{ + $object = new AdherentType($db); + $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]); + $object->other = dol_htmlcleanlastbr($_POST["other-".$key]); + } + else + { + $object->multilangs[$key]["label"] = $_POST["libelle-".$key]; + $object->multilangs[$key]["description"] = dol_htmlcleanlastbr($_POST["desc-".$key]); + $object->multilangs[$key]["other"] = dol_htmlcleanlastbr($_POST["other-".$key]); + } + } + + if ( $object->setMultiLangs($user) > 0 ) + { + $action = ''; + } + else + { + $action = 'edit'; + setEventMessages($object->error, $object->errors, 'errors'); + } +} + +// Delete translation +if ($action == 'vdelete' && $cancel != $langs->trans("Cancel") && $user->rights->adherent->configurer) +{ + $object = new AdherentType($db); + $object->fetch($id); + $langtodelete=GETPOST('langdel', 'alpha'); + + + if ( $object->delMultiLangs($langtodelete, $user) > 0 ) + { + $action = ''; + } + else + { + $action = 'edit'; + setEventMessages($object->error, $object->errors, 'errors'); + } +} + +$object = new AdherentType($db); +$result = $object->fetch($id); + + +/* + * View + */ + +$title = $langs->trans('MemberTypeCard'); +$helpurl = ''; +$shortlabel = dol_trunc($object->label, 16); + +$title = $langs->trans('MemberType')." ". $shortlabel ." - ".$langs->trans('Translation'); +$helpurl='EN:Module_Services_En|FR:Module_Services|ES:Módulo_Servicios'; + +llxHeader('', $title, $helpurl); + +$form = new Form($db); +$formadmin=new FormAdmin($db); + +$head = member_type_prepare_head($object); +$titre=$langs->trans("MemberType".$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', $titre, 0, 'group'); + +$linkback = ''.$langs->trans("BackToList").''; + +dol_banner_tab($object, 'rowid', $linkback); + +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) + { + $s=picto_from_langcode($key); + print "
".($s?$s.' ':'')." ".$langs->trans('Language_'.$key).": ".''.img_delete('', 'class="valigntextbottom"')."
"; + + print '
'; + 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 '
'; +} +elseif ($action != 'add') +{ + if (! empty($object->multilangs)) + { + foreach ($object->multilangs as $key => $value) + { + $s=picto_from_langcode($key); + print ($s?$s.' ':'')." ".$langs->trans('Language_'.$key).": ".''.img_delete('', 'class="valigntextbottom"').''; + + print '
'; + print '
'; + print ''; + print ''; + print ''; + print '
'.$langs->trans('Label').''.$object->multilangs[$key]["label"].'
'.$langs->trans('Description').''.$object->multilangs[$key]["description"].'
'; + print '
'; + } + } + if (! $cnt_trans && $action != 'add') print '
'. $langs->trans('NoTranslation').'
'; +} + + + +/* + * Form to add a new translation + */ + +if ($action == 'add' && $user->rights->adherent->configurer) +{ + //WYSIWYG Editor + require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; + + print '
'; + print '
'; + print ''; + print ''; + print ''; + + dol_fiche_head(); + + print ''; + print ''; + print ''; + print ''; + + print '
'.$langs->trans('Language').''; + print $formadmin->select_language('', 'forcelangprod', 0, $object->multilangs, 1); + 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 '
'; + + dol_fiche_end(); + + print '
'; + print ''; + print '     '; + print ''; + print '
'; + + print '
'; + + print '
'; +} + +// End of page +llxFooter(); +$db->close();