dolibarr  16.0.5
categorie.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (C) 2008-2011 Laurent Destailleur <eldy@users.sourceforge.net>
3  * Copyright (C) 2013 Florian Henry <florian.henry@open-concept.pro>
4  * Copyright (C) 2015 Juanjo Menent <jmenent@2byte.es>
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 3 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program. If not, see <https://www.gnu.org/licenses/>.
18  */
19 
26 require '../../main.inc.php';
27 require_once DOL_DOCUMENT_ROOT.'/core/lib/categories.lib.php';
28 
29 
30 if (!$user->admin) {
32 }
33 
34 // Load translation files required by the page
35 $langs->loadLangs(array("categories", "admin"));
36 
37 $action = GETPOST('action', 'aZ09');
38 
39 /*
40  * Actions
41  */
42 
43 $reg = array();
44 if (preg_match('/set_([a-z0-9_\-]+)/i', $action, $reg)) {
45  $code = $reg[1];
46  if (dolibarr_set_const($db, $code, 1, 'chaine', 0, '', $conf->entity) > 0) {
47  header("Location: ".$_SERVER["PHP_SELF"]);
48  exit;
49  } else {
50  setEventMessages($db->lasterror(), null, 'errors');
51  }
52 }
53 
54 if (preg_match('/del_([a-z0-9_\-]+)/i', $action, $reg)) {
55  $code = $reg[1];
56  if (dolibarr_del_const($db, $code, $conf->entity) > 0) {
57  header("Location: ".$_SERVER["PHP_SELF"]);
58  exit;
59  } else {
60  setEventMessages($db->lasterror(), null, 'errors');
61  }
62 }
63 
64 
65 
66 /*
67  * View
68  */
69 
70 $help_url = 'EN:Module Categories|FR:Module Catégories|ES:Módulo Categorías';
71 $linkback = '<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>';
72 
73 llxHeader('', $langs->trans("Categories"), $help_url);
74 
75 $linkback = '<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>';
76 print load_fiche_titre($langs->trans("CategoriesSetup"), $linkback, 'title_setup');
77 
78 
80 
81 print dol_get_fiche_head($head, 'setup', $langs->trans("Categories"), -1, 'category');
82 
83 
84 print '<table class="noborder centpercent">';
85 print '<tr class="liste_titre">';
86 print '<td>'.$langs->trans("Description").'</td>';
87 print '<td align="center" width="20">&nbsp;</td>';
88 print '<td align="center" width="100">'.$langs->trans("Value").'</td>'."\n";
89 print '</tr>';
90 
91 $form = new Form($db);
92 
93 // Mail required for members
94 
95 print '<tr class="oddeven">';
96 print '<td>'.$langs->trans("CategorieRecursiv").'</td>';
97 print '<td align="center" width="20">'.$form->textwithpicto('', $langs->trans("CategorieRecursivHelp"), 1, 'help').'</td>';
98 
99 print '<td align="center" width="100">';
100 if ($conf->use_javascript_ajax) {
101  print ajax_constantonoff('CATEGORIE_RECURSIV_ADD');
102 } else {
103  if (empty($conf->global->CATEGORIE_RECURSIV_ADD)) {
104  print '<a href="'.$_SERVER['PHP_SELF'].'?action=set_CATEGORIE_RECURSIV_ADD&token='.newToken().'">'.img_picto($langs->trans("Disabled"), 'off').'</a>';
105  } else {
106  print '<a href="'.$_SERVER['PHP_SELF'].'?action=del_CATEGORIE_RECURSIV_ADD&token='.newToken().'">'.img_picto($langs->trans("Enabled"), 'on').'</a>';
107  }
108 }
109 print '</td></tr>';
110 
111 print '</table>';
112 
113 // End of page
114 llxFooter();
115 $db->close();
llxFooter
llxFooter()
Empty footer.
Definition: wrapper.php:73
dolibarr_del_const
dolibarr_del_const($db, $name, $entity=1)
Delete a constant.
Definition: admin.lib.php:552
load_fiche_titre
load_fiche_titre($titre, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
Definition: functions.lib.php:5204
GETPOST
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
Definition: functions.lib.php:484
$form
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
Definition: card.php:142
$help_url
if(GETPOST('button_removefilter_x', 'alpha')||GETPOST('button_removefilter.x', 'alpha')||GETPOST('button_removefilter', 'alpha')) if(GETPOST('button_search_x', 'alpha')||GETPOST('button_search.x', 'alpha')||GETPOST('button_search', 'alpha')) if($action=="save" &&empty($cancel)) $help_url
View.
Definition: agenda.php:116
img_picto
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
Definition: functions.lib.php:3880
categoriesadmin_prepare_head
categoriesadmin_prepare_head()
Prepare array with list of tabs.
Definition: categories.lib.php:81
ajax_constantonoff
ajax_constantonoff($code, $input=array(), $entity=null, $revertonoff=0, $strict=0, $forcereload=0, $marginleftonlyshort=2, $forcenoajax=0, $setzeroinsteadofdel=0, $suffix='', $mode='')
On/off button for constant.
Definition: ajax.lib.php:573
dol_get_fiche_head
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='')
Show tabs of a record.
Definition: functions.lib.php:1822
newToken
newToken()
Return the value of token currently saved into session with name 'newtoken'.
Definition: functions.lib.php:10878
dolibarr_set_const
dolibarr_set_const($db, $name, $value, $type='chaine', $visible=0, $note='', $entity=1)
Insert a parameter (key,value) into database (delete old key then insert it again).
Definition: admin.lib.php:627
Form
Class to manage generation of HTML components Only common components must be here.
Definition: html.form.class.php:52
setEventMessages
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='')
Set event messages in dol_events session object.
Definition: functions.lib.php:8137
accessforbidden
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program Calling this function terminate execution ...
Definition: security.lib.php:933
llxHeader
if(!defined('NOREQUIRESOC')) if(!defined('NOREQUIRETRAN')) if(!defined('NOCSRFCHECK')) if(!defined('NOTOKENRENEWAL')) if(!defined('NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined('NOREQUIREAJAX')) llxHeader()
Empty header.
Definition: wrapper.php:59