Go to the documentation of this file.
28 require
'../main.inc.php';
29 require_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
30 require_once DOL_DOCUMENT_ROOT.
'/core/class/extrafields.class.php';
31 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formother.class.php';
34 $langs->load(
"categories");
37 $ref =
GETPOST(
'ref',
'alphanohtml');
38 $action = (
GETPOST(
'action',
'aZ09') ?
GETPOST(
'action',
'aZ09') :
'edit');
40 $cancel =
GETPOST(
'cancel',
'alpha');
41 $backtopage =
GETPOST(
'backtopage',
'alpha');
43 $socid = (int)
GETPOST(
'socid',
'int');
44 $label = (string)
GETPOST(
'label',
'alphanohtml');
45 $description = (string)
GETPOST(
'description',
'restricthtml');
46 $color = preg_replace(
'/[^0-9a-f#]/i',
'', (
string)
GETPOST(
'color',
'alphanohtml'));
47 $visible = (int)
GETPOST(
'visible',
'int');
48 $parent = (int)
GETPOST(
'parent',
'int');
59 $result = $object->fetch($id, $label);
64 $type = $object->type;
65 if (is_numeric($type)) {
66 $type = Categorie::$MAP_ID_TO_CODE[$type];
70 $extrafields->fetch_name_optionals_label($object->table_element);
73 $hookmanager->initHooks(array(
'categorycard'));
84 header(
"Location: ".$backtopage);
87 header(
'Location: '.DOL_URL_ROOT.
'/categories/viewcat.php?id='.$object->id.
'&type='.$type);
93 if ($action ==
'update' && $user->rights->categorie->creer) {
95 $object->label = $label;
97 $object->color = $color;
98 $object->socid = ($socid > 0 ? $socid : 0);
99 $object->visible = $visible;
100 $object->fk_parent = $parent != -1 ? $parent : 0;
102 if (empty($object->label)) {
105 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"Label")),
null,
'errors');
107 if (!$error && empty($object->error)) {
108 $ret = $extrafields->setOptionalsFromPost(
null, $object,
'@GETPOSTISSET');
113 if (!$error && $object->update($user) > 0) {
115 header(
"Location: ".$backtopage);
118 header(
'Location: '.DOL_URL_ROOT.
'/categories/viewcat.php?id='.$object->id.
'&type='.$type);
138 llxHeader(
"",
"", $langs->trans(
"Categories"));
146 print
'<form method="post" action="'.$_SERVER[
'PHP_SELF'].
'">';
147 print
'<input type="hidden" name="token" value="'.newToken().
'">';
148 print
'<input type="hidden" name="action" value="update">';
149 print
'<input type="hidden" name="id" value="'.$object->id.
'">';
150 print
'<input type="hidden" name="type" value="'.$type.
'">';
151 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
155 print
'<table class="border centpercent">';
158 print
'<tr><td class="titlefieldcreate fieldrequired">';
159 print $langs->trans(
"Ref").
'</td>';
160 print
'<td><input type="text" size="25" id="label" name ="label" value="'.$object->label.
'" />';
165 print
'<td>'.$langs->trans(
"Description").
'</td>';
167 require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
168 $doleditor =
new DolEditor(
'description', $object->description,
'', 200,
'dolibarr_notes',
'',
false,
true, $conf->fckeditor->enabled, ROWS_6,
'90%');
169 $doleditor->Create();
174 print
'<td>'.$langs->trans(
"Color").
'</td>';
176 print $formother->selectColor($object->color,
'color');
180 print
'<tr><td>'.$langs->trans(
"In").
'</td><td>';
181 print
img_picto(
'',
'category',
'class="pictofixedwidth"');
182 print
$form->select_all_categories($type, $object->fk_parent,
'parent', 64, $object->id);
186 $parameters = array();
187 $reshook = $hookmanager->executeHooks(
'formObjectOptions', $parameters, $object, $action);
188 print $hookmanager->resPrint;
189 if (empty($reshook)) {
190 print $object->showOptionals($extrafields,
'edit', $parameters);
199 print
'<div class="center"><input type="submit" class="button" name"submit" value="'.$langs->trans(
"Modify").
'"> <input type="submit" class="button button-cancel" name="cancel" value="'.$langs->trans(
"Cancel").
'"></div>';
ajax_combobox($htmlname, $events=array(), $minLengthToAutocomplete=0, $forcefocus=0, $widthTypeOfAutocomplete='resolve', $idforemptyvalue='-1')
Convert a html select field into an ajax combobox.
restrictedArea($user, $features, $objectid=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.
load_fiche_titre($titre, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
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='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
Class to manage categories.
dol_clone($object, $native=0)
Create a clone of instance of object (new instance with same value for properties) With native = 0: P...
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='')
Show tabs of a record.
dol_htmlcleanlastbr($stringtodecode)
This function remove all ending and br at end.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='')
Set event messages in dol_events session object.
if(!defined('NOREQUIRESOC')) if(!defined('NOREQUIRETRAN')) if(!defined('NOCSRFCHECK')) if(!defined('NOTOKENRENEWAL')) if(!defined('NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined('NOREQUIREAJAX')) llxHeader()
Empty header.
Class to manage a WYSIWYG editor.