28 require
'../main.inc.php';
29 require_once DOL_DOCUMENT_ROOT.
'/core/lib/categories.lib.php';
30 require_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
31 require_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
32 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formadmin.class.php';
33 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formother.class.php';
36 $langs->loadLangs(array(
'categories',
'languages'));
39 $label =
GETPOST(
'label',
'alpha');
40 $action =
GETPOST(
'action',
'aZ09');
41 $cancel =
GETPOST(
'cancel',
'alpha');
42 $type =
GETPOST(
'type',
'aZ09');
44 if ($id ==
'' && $label ==
'')
54 $result = $object->fetch($id, $label, $type);
58 $object->fetch_optionals();
63 if (is_numeric($type)) $type = Categorie::$MAP_ID_TO_CODE[$type];
71 if ($cancel == $langs->trans(
"Cancel"))
78 if ($action ==
'vadd' &&
79 $cancel != $langs->trans(
"Cancel") &&
80 ($user->rights->categorie->creer))
83 $current_lang = $langs->getDefaultLang();
86 $forcelangprod =
GETPOST(
'forcelangprod',
'alpha');
87 $libelle =
GETPOST(
'libelle',
'alpha');
88 $desc =
GETPOST(
'desc',
'restricthtml');
90 if (empty($forcelangprod)) {
92 $object->errors[] = $langs->trans(
'ErrorFieldRequired', $langs->transnoentitiesnoconv(
'Translation'));
96 if (empty($libelle)) {
98 $object->errors[] = $langs->trans(
'Language_'.$forcelangprod).
' : '.$langs->trans(
'ErrorFieldRequired', $langs->transnoentitiesnoconv(
'Label'));
103 if ($forcelangprod == $current_lang) {
104 $object->label = $libelle;
107 $object->multilangs[$forcelangprod][
"label"] = $libelle;
112 $res = $object->setMultiLangs($user);
113 if ($res < 0) $error++;
126 if ($action ==
'vedit' &&
127 $cancel != $langs->trans(
"Cancel") &&
128 ($user->rights->categorie->creer))
131 $current_lang = $langs->getDefaultLang();
133 foreach ($object->multilangs as $key => $value)
135 $libelle =
GETPOST(
'libelle-'.$key,
'alpha');
138 if (empty($libelle)) {
140 $object->errors[] = $langs->trans(
'Language_'.$key).
' : '.$langs->trans(
'ErrorFieldRequired', $langs->transnoentitiesnoconv(
'Label'));
143 if ($key == $current_lang) {
144 $object->label = $libelle;
147 $object->multilangs[$key][
"label"] = $libelle;
153 $res = $object->setMultiLangs($user);
154 if ($res < 0) $error++;
170 $form =
new Form($db);
174 llxHeader(
"",
"", $langs->trans(
"Translation"));
176 $title = Categorie::$MAP_TYPE_TITLE_AREA[$type];
182 if (!empty($object->multilangs))
184 foreach ($object->multilangs as $key => $value)
192 $linkback =
'<a href="'.DOL_URL_ROOT.
'/categories/index.php?leftmenu=cat&type='.$type.
'">'.$langs->trans(
"BackToList").
'</a>';
193 $object->next_prev_filter =
' type = '.$object->type;
194 $object->ref = $object->label;
195 $morehtmlref =
'<br><div class="refidno"><a href="'.DOL_URL_ROOT.
'/categories/index.php?leftmenu=cat&type='.$type.
'">'.$langs->trans(
"Root").
'</a> >> ';
196 $ways = $object->print_all_ways(
" >> ",
'', 1);
197 foreach ($ways as $way) {
198 $morehtmlref .= $way.
"<br>\n";
200 $morehtmlref .=
'</div>';
202 dol_banner_tab($object,
'label', $linkback, ($user->socid ? 0 : 1),
'label',
'label', $morehtmlref,
'&type='.$type, 0,
'',
'', 1);
206 print '<div class="fichecenter">';
207 print '<div class="underbanner clearboth"></div>';
209 print '<table class="border centpercent tableforfield">';
212 print '<tr><td class="titlefield notopnoleft">';
213 print $langs->trans(
"Description").
'</td><td>';
218 print '<tr><td class="notopnoleft">';
219 print $langs->trans(
"Color").
'</td><td>';
220 print $formother->showColor($object->color);
237 print "\n<div class=\"tabsAction\">\n";
241 if ($user->rights->produit->creer || $user->rights->service->creer)
243 print '<a class="butAction" href="'.$_SERVER[
'PHP_SELF'].
'?action=add&id='.$object->id.
'&type='.$type.
'">'.$langs->trans(
'Add').
'</a>';
244 if ($cnt_trans > 0)
print '<a class="butAction" href="'.$_SERVER[
'PHP_SELF'].
'?action=edit&id='.$object->id.
'&type='.$type.
'">'.$langs->trans(
'Update').
'</a>';
252 if ($action ==
'edit')
255 require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
257 print '<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
258 print '<input type="hidden" name="token" value="'.newToken().
'">';
259 print '<input type="hidden" name="action" value="vedit">';
260 print '<input type="hidden" name="id" value="'.$object->id.
'">';
261 print '<input type="hidden" name="type" value="'.$type.
'">';
263 if (!empty($object->multilangs))
265 foreach ($object->multilangs as $key => $value)
267 print "<br><b><u>".$langs->trans(
'Language_'.$key).
" :</u></b><br>";
268 print '<table class="border centpercent">';
271 $libelle = (
GETPOST(
'libelle-'.$key,
'alpha') ?
GETPOST(
'libelle-'.$key,
'alpha') : $object->multilangs[$key][
'label']);
272 print '<tr><td class="titlefield fieldrequired">'.$langs->trans(
'Label').
'</td><td><input name="libelle-'.$key.
'" size="40" value="'.$libelle.
'"></td></tr>';
274 $desc = (
GETPOST(
'desc-'.$key) ?
GETPOST(
'desc-'.$key) : $object->multilangs[$key][
'description']);
275 print '<tr><td class="tdtop">'.$langs->trans(
'Description').
'</td><td>';
276 $doleditor =
new DolEditor(
"desc-$key", $desc,
'', 160,
'dolibarr_notes',
'',
false,
true, $conf->global->FCKEDITOR_ENABLE_PRODUCTDESC, ROWS_3,
'90%');
277 $doleditor->Create();
287 print '<div class="center">';
288 print '<input type="submit" class="button button-save" value="'.$langs->trans(
"Save").
'">';
289 print ' ';
290 print '<input type="submit" class="button button-cancel" name="cancel" value="'.$langs->trans(
"Cancel").
'">';
294 } elseif ($action !=
'add')
296 if ($cnt_trans)
print '<div class="underbanner clearboth"></div>';
298 if (!empty($object->multilangs))
300 foreach ($object->multilangs as $key => $value)
303 print '<table class="border centpercent">';
304 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>';
305 print '<tr><td class="titlefield">'.$langs->trans(
'Label').
'</td><td>'.$object->multilangs[$key][
"label"].
'</td></tr>';
306 print '<tr><td>'.$langs->trans(
'Description').
'</td><td>'.$object->multilangs[$key][
"description"].
'</td></tr>';
307 if (!empty($conf->global->CATEGORY_USE_OTHER_FIELD_IN_TRANSLATION))
309 print '<tr><td>'.$langs->trans(
'Other').
' ('.$langs->trans(
"NotUsed").
')</td><td>'.$object->multilangs[$key][
"other"].
'</td></tr>';
314 if (!$cnt_trans && $action !=
'add')
print '<div class="opacitymedium">'.$langs->trans(
'NoTranslation').
'</div>';
322 if ($action ==
'add' && ($user->rights->produit->creer || $user->rights->service->creer))
325 require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
328 print '<form action="'.$_SERVER[
"PHP_SELF"].
'" method="post">';
329 print '<input type="hidden" name="token" value="'.newToken().
'">';
330 print '<input type="hidden" name="action" value="vadd">';
331 print '<input type="hidden" name="id" value="'.$id.
'">';
332 print '<input type="hidden" name="type" value="'.$type.
'">';
334 print '<table class="border centpercent">';
335 print '<tr><td class="titlefield fieldrequired">'.$langs->trans(
'Translation').
'</td><td>';
336 print $formadmin->select_language(
GETPOST(
'forcelangprod',
'alpha'),
'forcelangprod', 0, $object->multilangs);
338 print '<tr><td class="fieldrequired">'.$langs->trans(
'Label').
'</td>';
339 print '<td><input name="libelle" class="minwidth200 maxwidth300" value="'.GETPOST(
'libelle',
'alpha').
'"></td></tr>';
340 print '<tr><td>'.$langs->trans(
'Description').
'</td><td>';
341 $doleditor =
new DolEditor(
'desc',
GETPOST(
'desc',
'restricthtml'),
'', 160,
'dolibarr_notes',
'',
false,
true, $conf->global->FCKEDITOR_ENABLE_PRODUCTDESC, ROWS_3,
'90%');
342 $doleditor->Create();
348 print '<div class="center">';
349 print '<input type="submit" class="button button-save" value="'.$langs->trans(
"Save").
'">';
350 print ' ';
351 print '<input type="submit" class="button button-cancel" name="cancel" value="'.$langs->trans(
"Cancel").
'">';
GETPOST($paramname, $check= 'alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
categories_prepare_head(Categorie $object, $type)
Prepare array with list of tabs.
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...
setEventMessages($mesg, $mesgs, $style= 'mesgs', $messagekey= '')
Set event messages in dol_events session object.
Class to manage categories.
restrictedArea($user, $features, $objectid=0, $tableandshare= '', $feature2= '', $dbt_keyfield= 'fk_soc', $dbt_select= 'rowid', $isdraft=0)
Check permissions of a user to show a page and an object.
dol_get_fiche_head($links=array(), $active= '', $title= '', $notab=0, $picto= '', $pictoisfullpath=0, $morehtmlright= '', $morecss= '', $limittoshow=0, $moretabssuffix= '')
Show tabs of a record.
print
Draft customers invoices.
dol_htmlcleanlastbr($stringtodecode)
This function remove all ending and br at end.
dol_print_error($db= '', $error= '', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
newToken()
Return the value of token currently saved into session with name 'newtoken'.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
Class to manage a WYSIWYG editor.
dol_banner_tab($object, $paramid, $morehtml= '', $shownav=1, $fieldid= 'rowid', $fieldref= 'ref', $morehtmlref= '', $moreparam= '', $nodbprefix=0, $morehtmlleft= '', $morehtmlstatus= '', $onlybanner=0, $morehtmlright= '')
Show tab footer of a card.
img_delete($titlealt= 'default', $other= 'class="pictodelete"', $morecss= '')
Show delete logo.
picto_from_langcode($codelang, $moreatt= '')
Return img flag of country for a language code or country code.