29require
'../main.inc.php';
30require_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
31require_once DOL_DOCUMENT_ROOT.
'/core/class/extrafields.class.php';
32require_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);
67if (is_numeric($type)) {
68 $type = Categorie::$MAP_ID_TO_CODE[$type];
72$extrafields->fetch_name_optionals_label($object->table_element);
75$hookmanager->initHooks(array(
'categorycard'));
83$parameters = array(
'id' => $id,
'ref' => $ref,
'cancel'=> $cancel,
'backtopage' => $backtopage,
'socid' => $socid,
'label' => $label,
'description' => $description,
'color' => $color,
'visible' => $visible,
'parent' => $parent);
85$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
93 header(
"Location: ".$backtopage);
96 header(
'Location: '.DOL_URL_ROOT.
'/categories/viewcat.php?id='.$object->id.
'&type='.$type);
102 if ($action ==
'update' && $user->hasRight(
'categorie',
'creer')) {
103 $object->oldcopy =
dol_clone($object, 2);
105 $object->label = $label;
107 $object->color = $color;
108 $object->socid = ($socid > 0 ? $socid : 0);
109 $object->visible = $visible;
110 $object->fk_parent = $parent != -1 ? $parent : 0;
112 if (empty($object->label)) {
115 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"Label")),
null,
'errors');
117 if (!$error && empty($object->error)) {
118 $ret = $extrafields->setOptionalsFromPost(
null, $object,
'@GETPOSTISSET');
123 if (!$error && $object->update($user) > 0) {
125 header(
"Location: ".$backtopage);
128 header(
'Location: '.DOL_URL_ROOT.
'/categories/viewcat.php?id='.$object->id.
'&type='.$type);
145$form =
new Form($db);
148llxHeader(
"",
"", $langs->trans(
"Categories"));
156print
'<form method="post" action="'.$_SERVER[
'PHP_SELF'].
'">';
157print
'<input type="hidden" name="token" value="'.newToken().
'">';
158print
'<input type="hidden" name="action" value="update">';
159print
'<input type="hidden" name="id" value="'.$object->id.
'">';
160print
'<input type="hidden" name="type" value="'.$type.
'">';
161print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
165print
'<table class="border centpercent">';
168print
'<tr><td class="titlefieldcreate fieldrequired">';
169print $langs->trans(
"Ref").
'</td>';
170print
'<td><input type="text" size="25" id="label" name ="label" value="'.$object->label.
'" />';
175print
'<td>'.$langs->trans(
"Description").
'</td>';
177require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
178$doleditor =
new DolEditor(
'description', $object->description,
'', 200,
'dolibarr_notes',
'',
false,
true, isModEnabled(
'fckeditor'), ROWS_6,
'90%');
184print
'<td>'.$langs->trans(
"Color").
'</td>';
186print $formother->selectColor($object->color,
'color');
190print
'<tr><td>'.$langs->trans(
"In").
'</td><td>';
191print
img_picto(
'',
'category',
'class="pictofixedwidth"');
192print $form->select_all_categories($type, $object->fk_parent,
'parent', 64, $object->id);
196$parameters = array();
197$reshook = $hookmanager->executeHooks(
'formObjectOptions', $parameters, $object, $action);
198print $hookmanager->resPrint;
199if (empty($reshook)) {
200 print $object->showOptionals($extrafields,
'edit', $parameters);
209print
'<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.
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='', $dragdropfile=0)
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.
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.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0)
Set event messages in dol_events session object.
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.