32require
'../main.inc.php';
33require_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
34require_once DOL_DOCUMENT_ROOT.
'/core/class/extrafields.class.php';
35require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formother.class.php';
38$langs->load(
"categories");
42if (!$user->hasRight(
'categorie',
'lire')) {
46$action =
GETPOST(
'action',
'alpha');
47$cancel =
GETPOST(
'cancel',
'alpha');
48$origin =
GETPOST(
'origin',
'alpha');
51$urlfrom =
GETPOST(
'urlfrom',
'alpha');
52$backtopage =
GETPOST(
'backtopage',
'alpha');
54$label = (string)
GETPOST(
'label',
'alphanohtml');
55$description = (string)
GETPOST(
'description',
'restricthtml');
56$color = preg_replace(
'/[^0-9a-f#]/i',
'', (
string)
GETPOST(
'color',
'alphanohtml'));
62 if ($type == Categorie::TYPE_PRODUCT) {
63 $idProdOrigin = $origin;
65 if ($type == Categorie::TYPE_SUPPLIER) {
66 $idSupplierOrigin = $origin;
68 if ($type == Categorie::TYPE_CUSTOMER) {
69 $idCompanyOrigin = $origin;
71 if ($type == Categorie::TYPE_MEMBER) {
72 $idMemberOrigin = $origin;
74 if ($type == Categorie::TYPE_CONTACT) {
75 $idContactOrigin = $origin;
77 if ($type == Categorie::TYPE_PROJECT) {
78 $idProjectOrigin = $origin;
82if ($catorigin && $type == Categorie::TYPE_PRODUCT) {
83 $idCatOrigin = $catorigin;
85if (!GETPOSTISSET(
'parent') && $catorigin) {
92$extrafields->fetch_name_optionals_label(
$object->table_element);
95$hookmanager->initHooks(array(
'categorycard'));
103$parameters = array(
'socid' => $socid,
'origin' => $origin,
'catorigin' => $catorigin,
'type' => $type,
'urlfrom' => $urlfrom,
'backtopage' => $backtopage,
'label' => $label,
'description' => $description,
'color' => $color,
'position' => $position,
'visible' => $visible,
'parent' => $parent);
105$reshook = $hookmanager->executeHooks(
'doActions', $parameters,
$object, $action);
110if (empty($reshook)) {
112 if ($action ==
'add' && $user->hasRight(
'categorie',
'creer')) {
116 header(
"Location: ".$urlfrom);
118 } elseif ($backtopage) {
119 header(
"Location: ".$backtopage);
121 } elseif ($idProdOrigin) {
122 header(
"Location: ".DOL_URL_ROOT.
'/categories/viewcat.php?id='.$idProdOrigin.
'&type='.$type);
124 } elseif ($idCompanyOrigin) {
125 header(
"Location: ".DOL_URL_ROOT.
'/categories/viewcat.php?id='.$idCompanyOrigin.
'&type='.$type);
127 } elseif ($idSupplierOrigin) {
128 header(
"Location: ".DOL_URL_ROOT.
'/categories/viewcat.php?id='.$idSupplierOrigin.
'&type='.$type);
130 } elseif ($idMemberOrigin) {
131 header(
"Location: ".DOL_URL_ROOT.
'/categories/viewcat.php?id='.$idMemberOrigin.
'&type='.$type);
133 } elseif ($idContactOrigin) {
134 header(
"Location: ".DOL_URL_ROOT.
'/categories/viewcat.php?id='.$idContactOrigin.
'&type='.$type);
136 } elseif ($idProjectOrigin) {
137 header(
"Location: ".DOL_URL_ROOT.
'/categories/viewcat.php?id='.$idProjectOrigin.
'&type='.$type);
140 header(
"Location: ".DOL_URL_ROOT.
'/categories/index.php?leftmenu=cat&type='.$type);
148 $object->socid = ($socid > 0 ? $socid : 0);
152 if ($parent !=
"-1") {
156 $ret = $extrafields->setOptionalsFromPost(
null,
$object);
163 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"Ref")),
null,
'errors');
169 $result =
$object->create($user);
171 $action =
'confirmed';
178 if (($action ==
'add' || $action ==
'confirmed') && $user->hasRight(
'categorie',
'creer')) {
180 if ($action ==
'confirmed') {
182 header(
"Location: ".$urlfrom);
184 } elseif ($backtopage) {
185 header(
"Location: ".$backtopage);
187 } elseif ($idProdOrigin) {
188 header(
"Location: ".DOL_URL_ROOT.
'/categories/viewcat.php?id='.$idProdOrigin.
'&type='.$type.
'&mesg='.urlencode($langs->trans(
"CatCreated")));
190 } elseif ($idCompanyOrigin) {
191 header(
"Location: ".DOL_URL_ROOT.
'/categories/viewcat.php?id='.$idCompanyOrigin.
'&type='.$type.
'&mesg='.urlencode($langs->trans(
"CatCreated")));
193 } elseif ($idSupplierOrigin) {
194 header(
"Location: ".DOL_URL_ROOT.
'/categories/viewcat.php?id='.$idSupplierOrigin.
'&type='.$type.
'&mesg='.urlencode($langs->trans(
"CatCreated")));
196 } elseif ($idMemberOrigin) {
197 header(
"Location: ".DOL_URL_ROOT.
'/categories/viewcat.php?id='.$idMemberOrigin.
'&type='.$type.
'&mesg='.urlencode($langs->trans(
"CatCreated")));
199 } elseif ($idContactOrigin) {
200 header(
"Location: ".DOL_URL_ROOT.
'/categories/viewcat.php?id='.$idContactOrigin.
'&type='.$type.
'&mesg='.urlencode($langs->trans(
"CatCreated")));
202 } elseif ($idProjectOrigin) {
203 header(
"Location: ".DOL_URL_ROOT.
'/categories/viewcat.php?id='.$idProjectOrigin.
'&type='.$type.
'&mesg='.urlencode($langs->trans(
"CatCreated")));
207 header(
"Location: ".DOL_URL_ROOT.
'/categories/viewcat.php?id='.$result.
'&type='.$type);
217$form =
new Form($db);
220$help_url =
'EN:Module_Categories|FR:Module_Catégories|DE:Modul_Kategorien';
222llxHeader(
"", $langs->trans(
"Categories"), $help_url);
224if ($user->hasRight(
'categorie',
'creer')) {
226 if ($action ==
'create' || $action ==
'add') {
229 print
'<form action="'.$_SERVER[
'PHP_SELF'].
'?type='.$type.
'" method="POST">';
230 print
'<input type="hidden" name="token" value="'.newToken().
'">';
231 print
'<input type="hidden" name="urlfrom" value="'.$urlfrom.
'">';
232 print
'<input type="hidden" name="action" value="add">';
233 print
'<input type="hidden" name="id" value="'.GETPOST(
'origin',
'alpha').
'">';
234 print
'<input type="hidden" name="type" value="'.$type.
'">';
235 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
237 print
'<input type="hidden" name="origin" value="'.$origin.
'">';
240 print
'<input type="hidden" name="catorigin" value="'.$catorigin.
'">';
247 print
'<table class="border centpercent">';
251 print
'<td class="titlefieldcreate fieldrequired">'.$langs->trans(
"Ref").
'</td><td><input id="label" class="minwidth100" name="label" value="'.
dol_escape_htmltag($label).
'">';
255 print
'<tr><td class="tdtop">'.$langs->trans(
"Description").
'</td><td>';
256 require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
257 $doleditor =
new DolEditor(
'description', $description,
'', 160,
'dolibarr_notes',
'',
false,
true, isModEnabled(
'fckeditor') &&
getDolGlobalInt(
'FCKEDITOR_ENABLE_SOCIETE'), ROWS_5,
'90%');
258 $doleditor->Create();
262 print
'<tr><td>'.$langs->trans(
"Color").
'</td><td>';
263 print $formother->selectColor($color,
'color');
268 print
'<td class="titlefieldcreate">'.$langs->trans(
"Position").
'</td><td><input id="position" type="number" class="minwidth50 maxwidth50" name="position" value="'.$position.
'">';
272 print
'<tr><td>'.$langs->trans(
"AddIn").
'</td><td>';
273 print
img_picto($langs->trans(
"ParentCategory"),
'category',
'class="pictofixedwidth"');
274 print $form->select_all_categories($type, $parent,
'parent');
278 $parameters = array();
279 $reshook = $hookmanager->executeHooks(
'formObjectOptions', $parameters,
$object, $action);
280 print $hookmanager->resPrint;
281 if (empty($reshook)) {
282 print
$object->showOptionals($extrafields,
'create', $parameters);
289 print
'<div class="center">';
290 print
'<input type="submit" class="button b" value="'.$langs->trans(
"CreateThisCat").
'" name="creation" />';
291 print
' ';
292 print
'<input type="submit" class="button button-cancel" value="'.$langs->trans(
"Cancel").
'" name="cancel" />';
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
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($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
Class to manage categories.
Class to manage a WYSIWYG editor.
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
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_get_fiche_end($notab=0)
Return tab footer of a card.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
dol_set_focus($selector)
Set focus onto field with selector (similar behaviour of 'autofocus' HTML5 tag)
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.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
Returns text escaped for inclusion in HTML alt or title or value tags, or into values of HTML input f...
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.