29 require
'../main.inc.php';
30 require_once DOL_DOCUMENT_ROOT.
'/core/lib/categories.lib.php';
31 require_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
32 require_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
33 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formadmin.class.php';
34 require_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');
44 if ($id ==
'' && $label ==
'') {
53 $result = $object->fetch($id, $label);
58 $type = $object->type;
59 if (is_numeric($type)) {
60 $type = Categorie::$MAP_ID_TO_CODE[$type];
71 if ($cancel == $langs->trans(
"Cancel")) {
77 if ($action ==
'vadd' &&
78 $cancel != $langs->trans(
"Cancel") &&
79 ($user->rights->categorie->creer)) {
81 $current_lang = $langs->getDefaultLang();
84 $forcelangprod =
GETPOST(
'forcelangprod',
'alpha');
85 $libelle =
GETPOST(
'libelle',
'alpha');
86 $desc =
GETPOST(
'desc',
'restricthtml');
88 if (empty($forcelangprod)) {
90 $object->errors[] = $langs->trans(
'ErrorFieldRequired', $langs->transnoentitiesnoconv(
'Translation'));
94 if (empty($libelle)) {
96 $object->errors[] = $langs->trans(
'Language_'.$forcelangprod).
' : '.$langs->trans(
'ErrorFieldRequired', $langs->transnoentitiesnoconv(
'Label'));
101 if ($forcelangprod == $current_lang) {
102 $object->label = $libelle;
105 $object->multilangs[$forcelangprod][
"label"] = $libelle;
110 $res = $object->setMultiLangs($user);
126 if ($action ==
'vedit' &&
127 $cancel != $langs->trans(
"Cancel") &&
128 ($user->rights->categorie->creer)) {
130 $current_lang = $langs->getDefaultLang();
132 foreach ($object->multilangs as $key => $value) {
133 $libelle =
GETPOST(
'libelle-'.$key,
'alpha');
136 if (empty($libelle)) {
138 $object->errors[] = $langs->trans(
'Language_'.$key).
' : '.$langs->trans(
'ErrorFieldRequired', $langs->transnoentitiesnoconv(
'Label'));
141 if ($key == $current_lang) {
142 $object->label = $libelle;
145 $object->multilangs[$key][
"label"] = $libelle;
151 $res = $object->setMultiLangs($user);
174 llxHeader(
"",
"", $langs->trans(
"Translation"));
176 $title = Categorie::$MAP_TYPE_TITLE_AREA[$type];
182 if (!empty($object->multilangs)) {
183 foreach ($object->multilangs as $key => $value) {
188 print
dol_get_fiche_head($head,
'translation', $langs->trans($title), -1,
'category');
190 $backtolist = (
GETPOST(
'backtolist') ?
GETPOST(
'backtolist') : DOL_URL_ROOT.
'/categories/index.php?leftmenu=cat&type='.urlencode($type));
191 $linkback =
'<a href="'.dol_sanitizeUrl($backtolist).
'">'.$langs->trans(
"BackToList").
'</a>';
192 $object->next_prev_filter =
' type = '.$object->type;
193 $object->ref = $object->label;
194 $morehtmlref =
'<br><div class="refidno"><a href="'.DOL_URL_ROOT.
'/categories/index.php?leftmenu=cat&type='.$type.
'">'.$langs->trans(
"Root").
'</a> >> ';
195 $ways = $object->print_all_ways(
" >> ",
'', 1);
196 foreach ($ways as $way) {
197 $morehtmlref .= $way.
"<br>\n";
199 $morehtmlref .=
'</div>';
201 dol_banner_tab($object,
'label', $linkback, ($user->socid ? 0 : 1),
'label',
'label', $morehtmlref,
'&type='.$type, 0,
'',
'', 1);
205 print
'<div class="fichecenter">';
206 print
'<div class="underbanner clearboth"></div>';
208 print
'<table class="border centpercent tableforfield">';
211 print
'<tr><td class="titlefield notopnoleft">';
212 print $langs->trans(
"Description").
'</td><td>';
217 print
'<tr><td class="notopnoleft">';
218 print $langs->trans(
"Color").
'</td><td>';
219 print $formother->showColor($object->color);
233 print
"\n<div class=\"tabsAction\">\n";
236 if ($user->hasRight(
'produit',
'creer') || $user->hasRight(
'service',
'creer')) {
237 print
'<a class="butAction" href="'.$_SERVER[
'PHP_SELF'].
'?action=add&token='.
newToken().
'&id='.$object->id.
'&type='.$type.
'">'.$langs->trans(
'Add').
'</a>';
238 if ($cnt_trans > 0) {
239 print
'<a class="butAction" href="'.$_SERVER[
'PHP_SELF'].
'?action=edit&token='.
newToken().
'&id='.$object->id.
'&type='.$type.
'">'.$langs->trans(
'Update').
'</a>';
248 if ($action ==
'edit') {
250 require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
252 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
253 print
'<input type="hidden" name="token" value="'.newToken().
'">';
254 print
'<input type="hidden" name="action" value="vedit">';
255 print
'<input type="hidden" name="id" value="'.$object->id.
'">';
256 print
'<input type="hidden" name="type" value="'.$type.
'">';
258 if (!empty($object->multilangs)) {
259 foreach ($object->multilangs as $key => $value) {
260 print
"<br><b><u>".$langs->trans(
'Language_'.$key).
" :</u></b><br>";
261 print
'<table class="border centpercent">';
264 $libelle = (
GETPOST(
'libelle-'.$key,
'alpha') ?
GETPOST(
'libelle-'.$key,
'alpha') : $object->multilangs[$key][
'label']);
265 print
'<tr><td class="titlefield fieldrequired">'.$langs->trans(
'Label').
'</td><td><input name="libelle-'.$key.
'" size="40" value="'.$libelle.
'"></td></tr>';
268 $desc = (
GETPOST(
'desc-'.$key) ?
GETPOST(
'desc-'.$key) : $object->multilangs[$key][
'description']);
269 print
'<tr><td class="tdtop">'.$langs->trans(
'Description').
'</td><td>';
270 $doleditor =
new DolEditor(
"desc-$key", $desc,
'', 160,
'dolibarr_notes',
'',
false,
true,
getDolGlobalInt(
'FCKEDITOR_ENABLE_SOCIETE'), ROWS_3,
'90%');
271 $doleditor->Create();
281 print
$form->buttonsSaveCancel();
284 } elseif ($action !=
'add') {
286 print
'<div class="underbanner clearboth"></div>';
289 if (!empty($object->multilangs)) {
290 foreach ($object->multilangs as $key => $value) {
292 print
'<table class="border centpercent">';
293 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>';
294 print
'<tr><td class="titlefield">'.$langs->trans(
'Label').
'</td><td>'.$object->multilangs[$key][
"label"].
'</td></tr>';
295 print
'<tr><td>'.$langs->trans(
'Description').
'</td><td>'.$object->multilangs[$key][
"description"].
'</td></tr>';
296 if (!empty($conf->global->CATEGORY_USE_OTHER_FIELD_IN_TRANSLATION)) {
297 print
'<tr><td>'.$langs->trans(
'Other').
' ('.$langs->trans(
"NotUsed").
')</td><td>'.$object->multilangs[$key][
"other"].
'</td></tr>';
302 if (!$cnt_trans && $action !=
'add') {
303 print
'<div class="opacitymedium">'.$langs->trans(
'NoTranslation').
'</div>';
312 if ($action ==
'add' && ($user->hasRight(
'produit',
'creer') || $user->hasRight(
'service',
'creer'))) {
314 require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
317 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="post">';
318 print
'<input type="hidden" name="token" value="'.newToken().
'">';
319 print
'<input type="hidden" name="action" value="vadd">';
320 print
'<input type="hidden" name="id" value="'.$id.
'">';
321 print
'<input type="hidden" name="type" value="'.$type.
'">';
323 print
'<table class="border centpercent">';
324 print
'<tr><td class="titlefield fieldrequired">'.$langs->trans(
'Translation').
'</td><td>';
325 print $formadmin->select_language(
GETPOST(
'forcelangprod',
'alpha'),
'forcelangprod', 0, $object->multilangs);
327 print
'<tr><td class="fieldrequired">'.$langs->trans(
'Label').
'</td>';
328 print
'<td><input name="libelle" class="minwidth200 maxwidth300" value="'.GETPOST(
'libelle',
'alpha').
'"></td></tr>';
329 print
'<tr><td>'.$langs->trans(
'Description').
'</td><td>';
330 $doleditor =
new DolEditor(
'desc',
GETPOST(
'desc',
'restricthtml'),
'', 160,
'dolibarr_notes',
'',
false,
true,
getDolGlobalInt(
'FCKEDITOR_ENABLE_SOCIETE'), ROWS_3,
'90%');
331 $doleditor->Create();
337 print
$form->buttonsSaveCancel();