29 require
'../main.inc.php';
30 require_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
31 require_once DOL_DOCUMENT_ROOT.
'/core/class/extrafields.class.php';
32 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formother.class.php';
35 $langs->load(
"categories");
38 $ref =
GETPOST(
'ref',
'alphanohtml');
39 $action = (
GETPOST(
'action',
'aZ09') ?
GETPOST(
'action',
'aZ09') :
'edit');
41 $cancel =
GETPOST(
'cancel',
'alpha');
42 $backtopage =
GETPOST(
'backtopage',
'alpha');
44 $socid = (int)
GETPOST(
'socid',
'int');
45 $label = (string)
GETPOST(
'label',
'alphanohtml');
46 $description = (string)
GETPOST(
'description',
'restricthtml');
47 $color = preg_replace(
'/[^0-9a-f#]/i',
'', (
string)
GETPOST(
'color',
'alphanohtml'));
48 $visible = (int)
GETPOST(
'visible',
'int');
49 $parent = (int)
GETPOST(
'parent',
'int');
60 $result = $object->fetch($id, $label);
65 $type = $object->type;
66 if (is_numeric($type)) {
67 $type = Categorie::$MAP_ID_TO_CODE[$type];
71 $extrafields->fetch_name_optionals_label($object->table_element);
74 $hookmanager->initHooks(array(
'categorycard'));
85 header(
"Location: ".$backtopage);
88 header(
'Location: '.DOL_URL_ROOT.
'/categories/viewcat.php?id='.$object->id.
'&type='.$type);
94 if ($action ==
'update' && $user->rights->categorie->creer) {
96 $object->label = $label;
98 $object->color = $color;
99 $object->socid = ($socid > 0 ? $socid : 0);
100 $object->visible = $visible;
101 $object->fk_parent = $parent != -1 ? $parent : 0;
103 if (empty($object->label)) {
106 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"Label")),
null,
'errors');
108 if (!$error && empty($object->error)) {
109 $ret = $extrafields->setOptionalsFromPost(
null, $object,
'@GETPOSTISSET');
114 if (!$error && $object->update($user) > 0) {
116 header(
"Location: ".$backtopage);
119 header(
'Location: '.DOL_URL_ROOT.
'/categories/viewcat.php?id='.$object->id.
'&type='.$type);
139 llxHeader(
"",
"", $langs->trans(
"Categories"));
147 print
'<form method="post" action="'.$_SERVER[
'PHP_SELF'].
'">';
148 print
'<input type="hidden" name="token" value="'.newToken().
'">';
149 print
'<input type="hidden" name="action" value="update">';
150 print
'<input type="hidden" name="id" value="'.$object->id.
'">';
151 print
'<input type="hidden" name="type" value="'.$type.
'">';
152 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
156 print
'<table class="border centpercent">';
159 print
'<tr><td class="titlefieldcreate fieldrequired">';
160 print $langs->trans(
"Ref").
'</td>';
161 print
'<td><input type="text" size="25" id="label" name ="label" value="'.$object->label.
'" />';
166 print
'<td>'.$langs->trans(
"Description").
'</td>';
168 require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
169 $doleditor =
new DolEditor(
'description', $object->description,
'', 200,
'dolibarr_notes',
'',
false,
true, $conf->fckeditor->enabled, ROWS_6,
'90%');
170 $doleditor->Create();
175 print
'<td>'.$langs->trans(
"Color").
'</td>';
177 print $formother->selectColor($object->color,
'color');
181 print
'<tr><td>'.$langs->trans(
"In").
'</td><td>';
182 print
img_picto(
'',
'category',
'class="pictofixedwidth"');
183 print
$form->select_all_categories($type, $object->fk_parent,
'parent', 64, $object->id);
187 $parameters = array();
188 $reshook = $hookmanager->executeHooks(
'formObjectOptions', $parameters, $object, $action);
189 print $hookmanager->resPrint;
190 if (empty($reshook)) {
191 print $object->showOptionals($extrafields,
'edit', $parameters);
200 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', $morecss='')
Convert a html select field into an ajax combobox.
if(!defined('NOREQUIRESOC')) if(!defined('NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined('NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined('NOREQUIREAJAX')) llxHeader()
Empty header.
Class to manage categories.
Class to manage a WYSIWYG editor.
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
load_fiche_titre($titre, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='')
Show tabs of a record.
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
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.
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_clone($object, $native=0)
Create a clone of instance of object (new instance with same value for each properties) With native =...
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.
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.