29require
'../main.inc.php';
30require_once DOL_DOCUMENT_ROOT.
'/core/lib/categories.lib.php';
31require_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
32require_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
33require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formadmin.class.php';
34require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formother.class.php';
37$langs->loadLangs(array(
'categories',
'languages'));
40$label =
GETPOST(
'label',
'alpha');
41$action =
GETPOST(
'action',
'aZ09');
42$cancel =
GETPOST(
'cancel',
'alpha');
44if ($id ==
'' && $label ==
'') {
50$result =
$object->fetch($id, $label);
57if (is_numeric($type)) {
58 $type = Categorie::$MAP_ID_TO_CODE[$type];
64$permissiontoadd = $user->hasRight(
'categorie',
'creer');
74if ($cancel == $langs->trans(
"Cancel")) {
80if ($action ==
'vadd' && $cancel != $langs->trans(
"Cancel") && $permissiontoadd) {
82 $current_lang = $langs->getDefaultLang();
85 $forcelangprod =
GETPOST(
'forcelangprod',
'alpha');
86 $libelle =
GETPOST(
'libelle',
'alpha');
87 $desc =
GETPOST(
'desc',
'restricthtml');
89 if (empty($forcelangprod)) {
91 $object->errors[] = $langs->trans(
'ErrorFieldRequired', $langs->transnoentitiesnoconv(
'Translation'));
95 if (empty($libelle)) {
97 $object->errors[] = $langs->trans(
'Language_'.$forcelangprod).
' : '.$langs->trans(
'ErrorFieldRequired', $langs->transnoentitiesnoconv(
'Label'));
102 if ($forcelangprod == $current_lang) {
106 $object->multilangs[$forcelangprod][
"label"] = $libelle;
111 $res =
$object->setMultiLangs($user);
127if ($action ==
'vedit' && $cancel != $langs->trans(
"Cancel") && $permissiontoadd) {
129 $current_lang = $langs->getDefaultLang();
131 foreach (
$object->multilangs as $key => $value) {
132 $libelle =
GETPOST(
'libelle-'.$key,
'alpha');
133 $desc =
GETPOST(
'desc-'.$key,
'restricthtml');
135 if (empty($libelle)) {
137 $object->errors[] = $langs->trans(
'Language_'.$key).
' : '.$langs->trans(
'ErrorFieldRequired', $langs->transnoentitiesnoconv(
'Label'));
140 if ($key == $current_lang) {
144 $object->multilangs[$key][
"label"] = $libelle;
150 $res =
$object->setMultiLangs($user);
169$form =
new Form($db);
173llxHeader(
"",
"", $langs->trans(
"Translation"));
175$title = Categorie::$MAP_TYPE_TITLE_AREA[$type];
181if (!empty(
$object->multilangs)) {
182 foreach (
$object->multilangs as $key => $value) {
189$backtolist = (
GETPOST(
'backtolist') ?
GETPOST(
'backtolist') : DOL_URL_ROOT.
'/categories/index.php?leftmenu=cat&type='.urlencode($type));
190$linkback =
'<a href="'.dol_sanitizeUrl($backtolist).
'">'.$langs->trans(
"BackToList").
'</a>';
193$morehtmlref =
'<br><div class="refidno"><a href="'.DOL_URL_ROOT.
'/categories/index.php?leftmenu=cat&type='.$type.
'">'.$langs->trans(
"Root").
'</a> >> ';
194$ways =
$object->print_all_ways(
" >> ",
'', 1);
195foreach ($ways as $way) {
196 $morehtmlref .= $way.
"<br>\n";
198$morehtmlref .=
'</div>';
200dol_banner_tab($object,
'label', $linkback, ($user->socid ? 0 : 1),
'label',
'label', $morehtmlref,
'&type='.$type, 0,
'',
'', 1);
204print
'<div class="fichecenter">';
205print
'<div class="underbanner clearboth"></div>';
207print
'<table class="border centpercent tableforfield">';
210print
'<tr><td class="titlefield notopnoleft">';
211print $langs->trans(
"Description").
'</td><td>';
216print
'<tr><td class="notopnoleft">';
217print $langs->trans(
"Color").
'</td><td>';
218print $formother->showColor(
$object->color);
232print
"\n<div class=\"tabsAction\">\n";
235 if ($user->hasRight(
'produit',
'creer') || $user->hasRight(
'service',
'creer')) {
236 print
'<a class="butAction" href="'.$_SERVER[
'PHP_SELF'].
'?action=add&token='.
newToken().
'&id='.
$object->id.
'&type='.$type.
'">'.$langs->trans(
'Add').
'</a>';
237 if ($cnt_trans > 0) {
238 print
'<a class="butAction" href="'.$_SERVER[
'PHP_SELF'].
'?action=edit&token='.
newToken().
'&id='.
$object->id.
'&type='.$type.
'">'.$langs->trans(
'Update').
'</a>';
247if ($action ==
'edit') {
249 require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
251 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
252 print
'<input type="hidden" name="token" value="'.newToken().
'">';
253 print
'<input type="hidden" name="action" value="vedit">';
254 print
'<input type="hidden" name="id" value="'.$object->id.
'">';
255 print
'<input type="hidden" name="type" value="'.$type.
'">';
257 if (!empty(
$object->multilangs)) {
258 foreach (
$object->multilangs as $key => $value) {
259 print
"<br><b><u>".$langs->trans(
'Language_'.$key).
" :</u></b><br>";
260 print
'<table class="border centpercent">';
263 $libelle = (
GETPOST(
'libelle-'.$key,
'alpha') ?
GETPOST(
'libelle-'.$key,
'alpha') : (
$object->multilangs[$key][
'label'] ??
''));
264 print
'<tr><td class="titlefield fieldrequired">'.$langs->trans(
'Label').
'</td><td><input name="libelle-'.$key.
'" size="40" value="'.$libelle.
'"></td></tr>';
267 $desc = (
GETPOST(
'desc-'.$key) ?
GETPOST(
'desc-'.$key) : (
$object->multilangs[$key][
'description'] ??
''));
268 print
'<tr><td class="tdtop">'.$langs->trans(
'Description').
'</td><td>';
269 $doleditor =
new DolEditor(
"desc-$key", $desc,
'', 160,
'dolibarr_notes',
'',
false,
true, isModEnabled(
'fckeditor') &&
getDolGlobalInt(
'FCKEDITOR_ENABLE_SOCIETE'), ROWS_3,
'90%');
270 $doleditor->Create();
280 print $form->buttonsSaveCancel();
283} elseif ($action !=
'add') {
285 print
'<div class="underbanner clearboth"></div>';
288 if (!empty(
$object->multilangs)) {
289 foreach (
$object->multilangs as $key => $value) {
291 print
'<table class="border centpercent">';
292 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>';
293 print
'<tr><td class="titlefield">'.$langs->trans(
'Label').
'</td><td>'.(
$object->multilangs[$key][
"label"] ??
'').
'</td></tr>';
294 print
'<tr><td>'.$langs->trans(
'Description').
'</td><td>'.(
$object->multilangs[$key][
"description"] ??
'').
'</td></tr>';
296 print
'<tr><td>'.$langs->trans(
'Other').
' ('.$langs->trans(
"NotYetAvailable").
')</td><td>'.(
$object->multilangs[$key][
"other"] ??
'').
'</td></tr>';
301 if (!$cnt_trans && $action !=
'add') {
302 print
'<div class="opacitymedium">'.$langs->trans(
'NoTranslation').
'</div>';
311if ($action ==
'add' && ($user->hasRight(
'produit',
'creer') || $user->hasRight(
'service',
'creer'))) {
313 require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
316 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="post">';
317 print
'<input type="hidden" name="token" value="'.newToken().
'">';
318 print
'<input type="hidden" name="action" value="vadd">';
319 print
'<input type="hidden" name="id" value="'.$id.
'">';
320 print
'<input type="hidden" name="type" value="'.$type.
'">';
322 print
'<table class="border centpercent">';
323 print
'<tr><td class="titlefield fieldrequired">'.$langs->trans(
'Translation').
'</td><td>';
324 print $formadmin->select_language(
GETPOST(
'forcelangprod',
'alpha'),
'forcelangprod', 0,
$object->multilangs);
326 print
'<tr><td class="fieldrequired">'.$langs->trans(
'Label').
'</td>';
327 print
'<td><input name="libelle" class="minwidth200 maxwidth300" value="'.GETPOST(
'libelle',
'alpha').
'"></td></tr>';
328 print
'<tr><td>'.$langs->trans(
'Description').
'</td><td>';
329 $doleditor =
new DolEditor(
'desc',
GETPOST(
'desc',
'restricthtml'),
'', 160,
'dolibarr_notes',
'',
false,
true, isModEnabled(
'fckeditor') &&
getDolGlobalInt(
'FCKEDITOR_ENABLE_SOCIETE'), ROWS_3,
'90%');
330 $doleditor->Create();
336 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()
Empty header.
categories_prepare_head(Categorie $object, $type)
Prepare array with list of tabs.
Class to manage categories.
Class to manage a WYSIWYG editor.
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.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0)
Set event messages in dol_events session object.
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 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.