31require
'../main.inc.php';
32require_once DOL_DOCUMENT_ROOT.
'/core/lib/categories.lib.php';
33require_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
34require_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
35require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formadmin.class.php';
36require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formother.class.php';
47$langs->loadLangs(array(
'categories',
'languages'));
50$label =
GETPOST(
'label',
'alpha');
51$action =
GETPOST(
'action',
'aZ09');
52$cancel =
GETPOST(
'cancel',
'alpha');
53$langtodelete =
GETPOST(
'langtodelete',
'alpha');
55if ($id ==
'' && $label ==
'') {
61$result =
$object->fetch($id, $label);
68if (is_numeric($type)) {
69 $type = Categorie::$MAP_ID_TO_CODE[(int) $type];
75$permissiontoadd = $user->hasRight(
'categorie',
'creer');
85if ($cancel == $langs->trans(
"Cancel")) {
90if ($action ==
'delete' && $langtodelete && $user->hasRight(
'categorie',
'creer')) {
91 $res =
$object->delMultiLangs($langtodelete, $user);
95 unset(
$object->multilangs[$langtodelete]);
102if ($action ==
'vadd' && $cancel != $langs->trans(
"Cancel") && $permissiontoadd) {
104 $current_lang = $langs->getDefaultLang();
107 $forcelangprod =
GETPOST(
'forcelangprod',
'alpha');
108 $libelle =
GETPOST(
'libelle',
'alpha');
109 $desc =
GETPOST(
'desc',
'restricthtml');
111 if (empty($forcelangprod)) {
113 $object->errors[] = $langs->trans(
'ErrorFieldRequired', $langs->transnoentitiesnoconv(
'Translation'));
117 if (empty($libelle)) {
119 $object->errors[] = $langs->trans(
'Language_'.$forcelangprod).
' : '.$langs->trans(
'ErrorFieldRequired', $langs->transnoentitiesnoconv(
'Label'));
124 if ($forcelangprod == $current_lang) {
128 $object->multilangs[$forcelangprod][
"label"] = $libelle;
133 $res =
$object->setMultiLangs($user);
149if ($action ==
'vedit' && $cancel != $langs->trans(
"Cancel") && $permissiontoadd) {
151 $current_lang = $langs->getDefaultLang();
153 foreach (
$object->multilangs as $key => $value) {
154 $libelle =
GETPOST(
'libelle-'.$key,
'alpha');
155 $desc =
GETPOST(
'desc-'.$key,
'restricthtml');
157 if (empty($libelle)) {
159 $object->errors[] = $langs->trans(
'Language_'.$key).
' : '.$langs->trans(
'ErrorFieldRequired', $langs->transnoentitiesnoconv(
'Label'));
162 if ($key == $current_lang) {
166 $object->multilangs[$key][
"label"] = $libelle;
172 $res =
$object->setMultiLangs($user);
191$form =
new Form($db);
195llxHeader(
"",
"", $langs->trans(
"Translation"));
197$title = Categorie::$MAP_TYPE_TITLE_AREA[$type];
203if (!empty(
$object->multilangs)) {
204 foreach (
$object->multilangs as $key => $value) {
211$backtolist = (
GETPOST(
'backtolist') ?
GETPOST(
'backtolist') : DOL_URL_ROOT.
'/categories/index.php?leftmenu=cat&type='.urlencode($type));
212$linkback =
'<a href="'.dol_sanitizeUrl($backtolist).
'">'.$langs->trans(
"BackToList").
'</a>';
215$morehtmlref =
'<br><div class="refidno"><a href="'.DOL_URL_ROOT.
'/categories/index.php?leftmenu=cat&type='.$type.
'">'.$langs->trans(
"Root").
'</a> >> ';
216$ways =
$object->print_all_ways(
" >> ",
'', 1);
217foreach ($ways as $way) {
218 $morehtmlref .= $way.
"<br>\n";
220$morehtmlref .=
'</div>';
222dol_banner_tab($object,
'label', $linkback, ($user->socid ? 0 : 1),
'label',
'label', $morehtmlref,
'&type='.$type, 0,
'',
'', 1);
226print
'<div class="fichecenter">';
227print
'<div class="underbanner clearboth"></div>';
229print
'<table class="border centpercent tableforfield">';
232print
'<tr><td class="titlefield notopnoleft">';
233print $langs->trans(
"Description").
'</td><td>';
238print
'<tr><td class="notopnoleft">';
239print $langs->trans(
"Color").
'</td><td>';
240print $formother->showColor(
$object->color);
254print
"\n<div class=\"tabsAction\">\n";
257 if ($user->hasRight(
'produit',
'creer') || $user->hasRight(
'service',
'creer')) {
258 print
'<a class="butAction" href="'.$_SERVER[
'PHP_SELF'].
'?action=add&token='.
newToken().
'&id='.
$object->id.
'&type='.$type.
'">'.$langs->trans(
'Add').
'</a>';
259 if ($cnt_trans > 0) {
260 print
'<a class="butAction" href="'.$_SERVER[
'PHP_SELF'].
'?action=edit&token='.
newToken().
'&id='.
$object->id.
'&type='.$type.
'">'.$langs->trans(
'Update').
'</a>';
269if ($action ==
'edit') {
271 require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
273 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
274 print
'<input type="hidden" name="token" value="'.newToken().
'">';
275 print
'<input type="hidden" name="action" value="vedit">';
276 print
'<input type="hidden" name="id" value="'.$object->id.
'">';
277 print
'<input type="hidden" name="type" value="'.$type.
'">';
279 if (!empty(
$object->multilangs)) {
280 foreach (
$object->multilangs as $key => $value) {
281 print
"<br><b><u>".$langs->trans(
'Language_'.$key).
" :</u></b><br>";
282 print
'<table class="border centpercent">';
285 $libelle = (
GETPOST(
'libelle-'.$key,
'alpha') ?
GETPOST(
'libelle-'.$key,
'alpha') : (
$object->multilangs[$key][
'label'] ??
''));
286 print
'<tr><td class="titlefield fieldrequired">'.$langs->trans(
'Label').
'</td><td><input name="libelle-'.$key.
'" size="40" value="'.$libelle.
'"></td></tr>';
289 $desc = (
GETPOST(
'desc-'.$key) ?
GETPOST(
'desc-'.$key) : (
$object->multilangs[$key][
'description'] ??
''));
290 print
'<tr><td class="tdtop">'.$langs->trans(
'Description').
'</td><td>';
291 $doleditor =
new DolEditor(
"desc-$key", $desc,
'', 160,
'dolibarr_notes',
'',
false,
true, isModEnabled(
'fckeditor') &&
getDolGlobalInt(
'FCKEDITOR_ENABLE_SOCIETE'), ROWS_3,
'90%');
292 $doleditor->Create();
302 print $form->buttonsSaveCancel();
305} elseif ($action !=
'add') {
307 print
'<div class="underbanner clearboth"></div>';
310 if (!empty(
$object->multilangs)) {
311 foreach (
$object->multilangs as $key => $value) {
313 print
'<table class="border centpercent">';
314 print
'<tr class="liste_titre"><td colspan="2">'.($s ? $s.
' ' :
'').
" <b>".$langs->trans(
'Language_'.$key).
":</b> ".
'<a href="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=delete&token='.
newToken().
'&langtodelete='.$key.
'&type='.$type.
'">'.
img_delete(
'',
'').
'</a></td></tr>';
315 print
'<tr><td class="titlefield">'.$langs->trans(
'Label').
'</td><td>'.(
$object->multilangs[$key][
"label"] ??
'').
'</td></tr>';
316 print
'<tr><td>'.$langs->trans(
'Description').
'</td><td>'.(
$object->multilangs[$key][
"description"] ??
'').
'</td></tr>';
318 print
'<tr><td>'.$langs->trans(
'Other').
' ('.$langs->trans(
"NotYetAvailable").
')</td><td>'.(
$object->multilangs[$key][
"other"] ??
'').
'</td></tr>';
323 if (!$cnt_trans && $action !=
'add') {
324 print
'<div class="opacitymedium">'.$langs->trans(
'NoTranslation').
'</div>';
333if ($action ==
'add' && ($user->hasRight(
'produit',
'creer') || $user->hasRight(
'service',
'creer'))) {
335 require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
338 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="post">';
339 print
'<input type="hidden" name="token" value="'.newToken().
'">';
340 print
'<input type="hidden" name="action" value="vadd">';
341 print
'<input type="hidden" name="id" value="'.$id.
'">';
342 print
'<input type="hidden" name="type" value="'.$type.
'">';
344 print
'<table class="border centpercent">';
345 print
'<tr><td class="titlefield fieldrequired">'.$langs->trans(
'Translation').
'</td><td>';
346 print $formadmin->select_language(
GETPOST(
'forcelangprod',
'alpha'),
'forcelangprod', 0,
$object->multilangs);
348 print
'<tr><td class="fieldrequired">'.$langs->trans(
'Label').
'</td>';
349 print
'<td><input name="libelle" class="minwidth200 maxwidth300" value="'.GETPOST(
'libelle',
'alpha').
'"></td></tr>';
350 print
'<tr><td>'.$langs->trans(
'Description').
'</td><td>';
351 $doleditor =
new DolEditor(
'desc',
GETPOST(
'desc',
'restricthtml'),
'', 160,
'dolibarr_notes',
'',
false,
true, isModEnabled(
'fckeditor') &&
getDolGlobalInt(
'FCKEDITOR_ENABLE_SOCIETE'), ROWS_3,
'90%');
352 $doleditor->Create();
358 print $form->buttonsSaveCancel();
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
categories_prepare_head(Categorie $object, $type)
Prepare array with list of tabs.
Class to manage categories.
Class to manage a WYSIWYG editor.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
picto_from_langcode($codelang, $moreatt='', $notitlealt=0)
Return img flag of country for a language code or country code.
img_delete($titlealt='default', $other='class="pictodelete"', $morecss='')
Show delete logo.
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0)
Show tabs of a record.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
newToken()
Return the value of token currently saved into session with name 'newtoken'.
dol_htmlcleanlastbr($stringtodecode)
This function remove all ending and br at end.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
dol_htmlentitiesbr($stringtoencode, $nl2brmode=0, $pagecodefrom='UTF-8', $removelasteolbr=1)
This function is called to encode a string into a HTML string but differs from htmlentities because a...
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
restrictedArea(User $user, $features, $object=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $isdraft=0, $mode=0)
Check permissions of a user to show a page and an object.