30require
'../main.inc.php';
31require_once DOL_DOCUMENT_ROOT.
'/core/lib/categories.lib.php';
32require_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
33require_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
34require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formadmin.class.php';
35require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formother.class.php';
38$langs->loadLangs(array(
'categories',
'languages'));
41$label =
GETPOST(
'label',
'alpha');
42$action =
GETPOST(
'action',
'aZ09');
43$cancel =
GETPOST(
'cancel',
'alpha');
44$langtodelete =
GETPOST(
'langtodelete',
'alpha');
46if ($id ==
'' && $label ==
'') {
52$result =
$object->fetch($id, $label);
59if (is_numeric($type)) {
60 $type = Categorie::$MAP_ID_TO_CODE[$type];
66$permissiontoadd = $user->hasRight(
'categorie',
'creer');
76if ($cancel == $langs->trans(
"Cancel")) {
81if ($action ==
'delete' && $langtodelete && $user->hasRight(
'categorie',
'creer')) {
82 $res =
$object->delMultiLangs($langtodelete, $user);
86 unset(
$object->multilangs[$langtodelete]);
93if ($action ==
'vadd' && $cancel != $langs->trans(
"Cancel") && $permissiontoadd) {
95 $current_lang = $langs->getDefaultLang();
98 $forcelangprod =
GETPOST(
'forcelangprod',
'alpha');
99 $libelle =
GETPOST(
'libelle',
'alpha');
100 $desc =
GETPOST(
'desc',
'restricthtml');
102 if (empty($forcelangprod)) {
104 $object->errors[] = $langs->trans(
'ErrorFieldRequired', $langs->transnoentitiesnoconv(
'Translation'));
108 if (empty($libelle)) {
110 $object->errors[] = $langs->trans(
'Language_'.$forcelangprod).
' : '.$langs->trans(
'ErrorFieldRequired', $langs->transnoentitiesnoconv(
'Label'));
115 if ($forcelangprod == $current_lang) {
119 $object->multilangs[$forcelangprod][
"label"] = $libelle;
124 $res =
$object->setMultiLangs($user);
140if ($action ==
'vedit' && $cancel != $langs->trans(
"Cancel") && $permissiontoadd) {
142 $current_lang = $langs->getDefaultLang();
144 foreach (
$object->multilangs as $key => $value) {
145 $libelle =
GETPOST(
'libelle-'.$key,
'alpha');
146 $desc =
GETPOST(
'desc-'.$key,
'restricthtml');
148 if (empty($libelle)) {
150 $object->errors[] = $langs->trans(
'Language_'.$key).
' : '.$langs->trans(
'ErrorFieldRequired', $langs->transnoentitiesnoconv(
'Label'));
153 if ($key == $current_lang) {
157 $object->multilangs[$key][
"label"] = $libelle;
163 $res =
$object->setMultiLangs($user);
182$form =
new Form($db);
186llxHeader(
"",
"", $langs->trans(
"Translation"));
188$title = Categorie::$MAP_TYPE_TITLE_AREA[$type];
194if (!empty(
$object->multilangs)) {
195 foreach (
$object->multilangs as $key => $value) {
202$backtolist = (
GETPOST(
'backtolist') ?
GETPOST(
'backtolist') : DOL_URL_ROOT.
'/categories/index.php?leftmenu=cat&type='.urlencode($type));
203$linkback =
'<a href="'.dol_sanitizeUrl($backtolist).
'">'.$langs->trans(
"BackToList").
'</a>';
206$morehtmlref =
'<br><div class="refidno"><a href="'.DOL_URL_ROOT.
'/categories/index.php?leftmenu=cat&type='.$type.
'">'.$langs->trans(
"Root").
'</a> >> ';
207$ways =
$object->print_all_ways(
" >> ",
'', 1);
208foreach ($ways as $way) {
209 $morehtmlref .= $way.
"<br>\n";
211$morehtmlref .=
'</div>';
213dol_banner_tab($object,
'label', $linkback, ($user->socid ? 0 : 1),
'label',
'label', $morehtmlref,
'&type='.$type, 0,
'',
'', 1);
217print
'<div class="fichecenter">';
218print
'<div class="underbanner clearboth"></div>';
220print
'<table class="border centpercent tableforfield">';
223print
'<tr><td class="titlefield notopnoleft">';
224print $langs->trans(
"Description").
'</td><td>';
229print
'<tr><td class="notopnoleft">';
230print $langs->trans(
"Color").
'</td><td>';
231print $formother->showColor(
$object->color);
245print
"\n<div class=\"tabsAction\">\n";
248 if ($user->hasRight(
'produit',
'creer') || $user->hasRight(
'service',
'creer')) {
249 print
'<a class="butAction" href="'.$_SERVER[
'PHP_SELF'].
'?action=add&token='.
newToken().
'&id='.
$object->id.
'&type='.$type.
'">'.$langs->trans(
'Add').
'</a>';
250 if ($cnt_trans > 0) {
251 print
'<a class="butAction" href="'.$_SERVER[
'PHP_SELF'].
'?action=edit&token='.
newToken().
'&id='.
$object->id.
'&type='.$type.
'">'.$langs->trans(
'Update').
'</a>';
260if ($action ==
'edit') {
262 require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
264 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
265 print
'<input type="hidden" name="token" value="'.newToken().
'">';
266 print
'<input type="hidden" name="action" value="vedit">';
267 print
'<input type="hidden" name="id" value="'.$object->id.
'">';
268 print
'<input type="hidden" name="type" value="'.$type.
'">';
270 if (!empty(
$object->multilangs)) {
271 foreach (
$object->multilangs as $key => $value) {
272 print
"<br><b><u>".$langs->trans(
'Language_'.$key).
" :</u></b><br>";
273 print
'<table class="border centpercent">';
276 $libelle = (
GETPOST(
'libelle-'.$key,
'alpha') ?
GETPOST(
'libelle-'.$key,
'alpha') : (
$object->multilangs[$key][
'label'] ??
''));
277 print
'<tr><td class="titlefield fieldrequired">'.$langs->trans(
'Label').
'</td><td><input name="libelle-'.$key.
'" size="40" value="'.$libelle.
'"></td></tr>';
280 $desc = (
GETPOST(
'desc-'.$key) ?
GETPOST(
'desc-'.$key) : (
$object->multilangs[$key][
'description'] ??
''));
281 print
'<tr><td class="tdtop">'.$langs->trans(
'Description').
'</td><td>';
282 $doleditor =
new DolEditor(
"desc-$key", $desc,
'', 160,
'dolibarr_notes',
'',
false,
true, isModEnabled(
'fckeditor') &&
getDolGlobalInt(
'FCKEDITOR_ENABLE_SOCIETE'), ROWS_3,
'90%');
283 $doleditor->Create();
293 print $form->buttonsSaveCancel();
296} elseif ($action !=
'add') {
298 print
'<div class="underbanner clearboth"></div>';
301 if (!empty(
$object->multilangs)) {
302 foreach (
$object->multilangs as $key => $value) {
304 print
'<table class="border centpercent">';
305 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>';
306 print
'<tr><td class="titlefield">'.$langs->trans(
'Label').
'</td><td>'.(
$object->multilangs[$key][
"label"] ??
'').
'</td></tr>';
307 print
'<tr><td>'.$langs->trans(
'Description').
'</td><td>'.(
$object->multilangs[$key][
"description"] ??
'').
'</td></tr>';
309 print
'<tr><td>'.$langs->trans(
'Other').
' ('.$langs->trans(
"NotYetAvailable").
')</td><td>'.(
$object->multilangs[$key][
"other"] ??
'').
'</td></tr>';
314 if (!$cnt_trans && $action !=
'add') {
315 print
'<div class="opacitymedium">'.$langs->trans(
'NoTranslation').
'</div>';
324if ($action ==
'add' && ($user->hasRight(
'produit',
'creer') || $user->hasRight(
'service',
'creer'))) {
326 require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
329 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="post">';
330 print
'<input type="hidden" name="token" value="'.newToken().
'">';
331 print
'<input type="hidden" name="action" value="vadd">';
332 print
'<input type="hidden" name="id" value="'.$id.
'">';
333 print
'<input type="hidden" name="type" value="'.$type.
'">';
335 print
'<table class="border centpercent">';
336 print
'<tr><td class="titlefield fieldrequired">'.$langs->trans(
'Translation').
'</td><td>';
337 print $formadmin->select_language(
GETPOST(
'forcelangprod',
'alpha'),
'forcelangprod', 0,
$object->multilangs);
339 print
'<tr><td class="fieldrequired">'.$langs->trans(
'Label').
'</td>';
340 print
'<td><input name="libelle" class="minwidth200 maxwidth300" value="'.GETPOST(
'libelle',
'alpha').
'"></td></tr>';
341 print
'<tr><td>'.$langs->trans(
'Description').
'</td><td>';
342 $doleditor =
new DolEditor(
'desc',
GETPOST(
'desc',
'restricthtml'),
'', 160,
'dolibarr_notes',
'',
false,
true, isModEnabled(
'fckeditor') &&
getDolGlobalInt(
'FCKEDITOR_ENABLE_SOCIETE'), ROWS_3,
'90%');
343 $doleditor->Create();
349 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.