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');
43 if ($id ==
'' && $label ==
'') {
52 $result = $object->fetch($id, $label);
57 $type = $object->type;
58 if (is_numeric($type)) {
59 $type = Categorie::$MAP_ID_TO_CODE[$type];
68 if ($cancel == $langs->trans(
"Cancel")) {
74 if ($action ==
'vadd' &&
75 $cancel != $langs->trans(
"Cancel") &&
76 ($user->rights->categorie->creer)) {
78 $current_lang = $langs->getDefaultLang();
81 $forcelangprod =
GETPOST(
'forcelangprod',
'alpha');
82 $libelle =
GETPOST(
'libelle',
'alpha');
83 $desc =
GETPOST(
'desc',
'restricthtml');
85 if (empty($forcelangprod)) {
87 $object->errors[] = $langs->trans(
'ErrorFieldRequired', $langs->transnoentitiesnoconv(
'Translation'));
91 if (empty($libelle)) {
93 $object->errors[] = $langs->trans(
'Language_'.$forcelangprod).
' : '.$langs->trans(
'ErrorFieldRequired', $langs->transnoentitiesnoconv(
'Label'));
98 if ($forcelangprod == $current_lang) {
99 $object->label = $libelle;
102 $object->multilangs[$forcelangprod][
"label"] = $libelle;
107 $res = $object->setMultiLangs($user);
123 if ($action ==
'vedit' &&
124 $cancel != $langs->trans(
"Cancel") &&
125 ($user->rights->categorie->creer)) {
127 $current_lang = $langs->getDefaultLang();
129 foreach ($object->multilangs as $key => $value) {
130 $libelle =
GETPOST(
'libelle-'.$key,
'alpha');
133 if (empty($libelle)) {
135 $object->errors[] = $langs->trans(
'Language_'.$key).
' : '.$langs->trans(
'ErrorFieldRequired', $langs->transnoentitiesnoconv(
'Label'));
138 if ($key == $current_lang) {
139 $object->label = $libelle;
142 $object->multilangs[$key][
"label"] = $libelle;
148 $res = $object->setMultiLangs($user);
171 llxHeader(
"",
"", $langs->trans(
"Translation"));
173 $title = Categorie::$MAP_TYPE_TITLE_AREA[$type];
179 if (!empty($object->multilangs)) {
180 foreach ($object->multilangs as $key => $value) {
185 print
dol_get_fiche_head($head,
'translation', $langs->trans($title), -1,
'category');
187 $backtolist = (
GETPOST(
'backtolist') ?
GETPOST(
'backtolist') : DOL_URL_ROOT.
'/categories/index.php?leftmenu=cat&type='.urlencode($type));
188 $linkback =
'<a href="'.dol_sanitizeUrl($backtolist).
'">'.$langs->trans(
"BackToList").
'</a>';
189 $object->next_prev_filter =
' type = '.$object->type;
190 $object->ref = $object->label;
191 $morehtmlref =
'<br><div class="refidno"><a href="'.DOL_URL_ROOT.
'/categories/index.php?leftmenu=cat&type='.$type.
'">'.$langs->trans(
"Root").
'</a> >> ';
192 $ways = $object->print_all_ways(
" >> ",
'', 1);
193 foreach ($ways as $way) {
194 $morehtmlref .= $way.
"<br>\n";
196 $morehtmlref .=
'</div>';
198 dol_banner_tab($object,
'label', $linkback, ($user->socid ? 0 : 1),
'label',
'label', $morehtmlref,
'&type='.$type, 0,
'',
'', 1);
202 print
'<div class="fichecenter">';
203 print
'<div class="underbanner clearboth"></div>';
205 print
'<table class="border centpercent tableforfield">';
208 print
'<tr><td class="titlefield notopnoleft">';
209 print $langs->trans(
"Description").
'</td><td>';
214 print
'<tr><td class="notopnoleft">';
215 print $langs->trans(
"Color").
'</td><td>';
216 print $formother->showColor($object->color);
230 print
"\n<div class=\"tabsAction\">\n";
233 if ($user->rights->produit->creer || $user->rights->service->creer) {
234 print
'<a class="butAction" href="'.$_SERVER[
'PHP_SELF'].
'?action=add&token='.
newToken().
'&id='.$object->id.
'&type='.$type.
'">'.$langs->trans(
'Add').
'</a>';
235 if ($cnt_trans > 0) {
236 print
'<a class="butAction" href="'.$_SERVER[
'PHP_SELF'].
'?action=edit&token='.
newToken().
'&id='.$object->id.
'&type='.$type.
'">'.$langs->trans(
'Update').
'</a>';
245 if ($action ==
'edit') {
247 require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
249 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
250 print
'<input type="hidden" name="token" value="'.newToken().
'">';
251 print
'<input type="hidden" name="action" value="vedit">';
252 print
'<input type="hidden" name="id" value="'.$object->id.
'">';
253 print
'<input type="hidden" name="type" value="'.$type.
'">';
255 if (!empty($object->multilangs)) {
256 foreach ($object->multilangs as $key => $value) {
257 print
"<br><b><u>".$langs->trans(
'Language_'.$key).
" :</u></b><br>";
258 print
'<table class="border centpercent">';
261 $libelle = (
GETPOST(
'libelle-'.$key,
'alpha') ?
GETPOST(
'libelle-'.$key,
'alpha') : $object->multilangs[$key][
'label']);
262 print
'<tr><td class="titlefield fieldrequired">'.$langs->trans(
'Label').
'</td><td><input name="libelle-'.$key.
'" size="40" value="'.$libelle.
'"></td></tr>';
264 $desc = (
GETPOST(
'desc-'.$key) ?
GETPOST(
'desc-'.$key) : $object->multilangs[$key][
'description']);
265 print
'<tr><td class="tdtop">'.$langs->trans(
'Description').
'</td><td>';
266 $doleditor =
new DolEditor(
"desc-$key", $desc,
'', 160,
'dolibarr_notes',
'',
false,
true,
getDolGlobalInt(
'FCKEDITOR_ENABLE_PRODUCTDESC'), ROWS_3,
'90%');
267 $doleditor->Create();
277 print
$form->buttonsSaveCancel();
280 } elseif ($action !=
'add') {
282 print
'<div class="underbanner clearboth"></div>';
285 if (!empty($object->multilangs)) {
286 foreach ($object->multilangs as $key => $value) {
288 print
'<table class="border centpercent">';
289 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>';
290 print
'<tr><td class="titlefield">'.$langs->trans(
'Label').
'</td><td>'.$object->multilangs[$key][
"label"].
'</td></tr>';
291 print
'<tr><td>'.$langs->trans(
'Description').
'</td><td>'.$object->multilangs[$key][
"description"].
'</td></tr>';
292 if (!empty($conf->global->CATEGORY_USE_OTHER_FIELD_IN_TRANSLATION)) {
293 print
'<tr><td>'.$langs->trans(
'Other').
' ('.$langs->trans(
"NotUsed").
')</td><td>'.$object->multilangs[$key][
"other"].
'</td></tr>';
298 if (!$cnt_trans && $action !=
'add') {
299 print
'<div class="opacitymedium">'.$langs->trans(
'NoTranslation').
'</div>';
308 if ($action ==
'add' && ($user->rights->produit->creer || $user->rights->service->creer)) {
310 require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
313 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="post">';
314 print
'<input type="hidden" name="token" value="'.newToken().
'">';
315 print
'<input type="hidden" name="action" value="vadd">';
316 print
'<input type="hidden" name="id" value="'.$id.
'">';
317 print
'<input type="hidden" name="type" value="'.$type.
'">';
319 print
'<table class="border centpercent">';
320 print
'<tr><td class="titlefield fieldrequired">'.$langs->trans(
'Translation').
'</td><td>';
321 print $formadmin->select_language(
GETPOST(
'forcelangprod',
'alpha'),
'forcelangprod', 0, $object->multilangs);
323 print
'<tr><td class="fieldrequired">'.$langs->trans(
'Label').
'</td>';
324 print
'<td><input name="libelle" class="minwidth200 maxwidth300" value="'.GETPOST(
'libelle',
'alpha').
'"></td></tr>';
325 print
'<tr><td>'.$langs->trans(
'Description').
'</td><td>';
326 $doleditor =
new DolEditor(
'desc',
GETPOST(
'desc',
'restricthtml'),
'', 160,
'dolibarr_notes',
'',
false,
true,
getDolGlobalInt(
'FCKEDITOR_ENABLE_PRODUCTDESC'), ROWS_3,
'90%');
327 $doleditor->Create();
333 print
$form->buttonsSaveCancel();