dolibarr 18.0.6
setup.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2004-2017 Laurent Destailleur <eldy@users.sourceforge.net>
3 * Copyright (C) 2018 Nicolas ZABOURI <info@inovea-conseil.com>
4 *
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <https://www.gnu.org/licenses/>.
17 */
18
25// Load Dolibarr environment
26require '../../main.inc.php';
27require_once DOL_DOCUMENT_ROOT."/core/lib/admin.lib.php";
28require_once DOL_DOCUMENT_ROOT.'/datapolicy/lib/datapolicy.lib.php';
29
30// Translations
31$langs->loadLangs(array('admin', 'companies', 'members', 'datapolicy'));
32
33// Parameters
34$action = GETPOST('action', 'aZ09');
35$backtopage = GETPOST('backtopage', 'alpha');
36
37$arrayofparameters = array();
38$arrayofparameters['ThirdParty'] = array(
39 'DATAPOLICY_TIERS_CLIENT'=>array('css'=>'minwidth200', 'picto'=>img_picto('', 'company', 'class="pictofixedwidth"')),
40 'DATAPOLICY_TIERS_PROSPECT'=>array('css'=>'minwidth200', 'picto'=>img_picto('', 'company', 'class="pictofixedwidth"')),
41 'DATAPOLICY_TIERS_PROSPECT_CLIENT'=>array('css'=>'minwidth200', 'picto'=>img_picto('', 'company', 'class="pictofixedwidth"')),
42 'DATAPOLICY_TIERS_NIPROSPECT_NICLIENT'=>array('css'=>'minwidth200', 'picto'=>img_picto('', 'company', 'class="pictofixedwidth"')),
43 'DATAPOLICY_TIERS_FOURNISSEUR'=>array('css'=>'minwidth200', 'picto'=>img_picto('', 'supplier', 'class="pictofixedwidth"')),
44);
45if (!empty($conf->global->DATAPOLICY_USE_SPECIFIC_DELAY_FOR_CONTACT)) {
46 $arrayofparameters['Contact'] = array(
47 'DATAPOLICY_CONTACT_CLIENT'=>array('css'=>'minwidth200', 'picto'=>img_picto('', 'contact', 'class="pictofixedwidth"')),
48 'DATAPOLICY_CONTACT_PROSPECT'=>array('css'=>'minwidth200', 'picto'=>img_picto('', 'contact', 'class="pictofixedwidth"')),
49 'DATAPOLICY_CONTACT_PROSPECT_CLIENT'=>array('css'=>'minwidth200', 'picto'=>img_picto('', 'contact', 'class="pictofixedwidth"')),
50 'DATAPOLICY_CONTACT_NIPROSPECT_NICLIENT'=>array('css'=>'minwidth200', 'picto'=>img_picto('', 'contact', 'class="pictofixedwidth"')),
51 'DATAPOLICY_CONTACT_FOURNISSEUR'=>array('css'=>'minwidth200', 'picto'=>img_picto('', 'contact', 'class="pictofixedwidth"')),
52 );
53}
54if (isModEnabled('adherent')) {
55 $arrayofparameters['Member'] = array(
56 'DATAPOLICY_ADHERENT'=>array('css'=>'minwidth200', 'picto'=>img_picto('', 'member', 'class="pictofixedwidth"')),
57 );
58}
59
60$valTab = array(
61 '' => $langs->trans('Never'),
62 '6' => $langs->trans('NB_MONTHS', 6),
63 '12' => $langs->trans('ONE_YEAR'),
64 '24' => $langs->trans('NB_YEARS', 2),
65 '36' => $langs->trans('NB_YEARS', 3),
66 '48' => $langs->trans('NB_YEARS', 4),
67 '60' => $langs->trans('NB_YEARS', 5),
68 '120' => $langs->trans('NB_YEARS', 10),
69 '180' => $langs->trans('NB_YEARS', 15),
70 '240' => $langs->trans('NB_YEARS', 20),
71);
72
73// Security
74if (!isModEnabled("datapolicy")) {
76}
77if (!$user->admin) {
79}
80
81
82/*
83 * Actions
84 */
85
86foreach ($arrayofparameters as $title => $tab) {
87 foreach ($tab as $key => $val) {
88 // Modify constant only if key was posted (avoid resetting key to the null value)
89 if (GETPOSTISSET($key)) {
90 if (preg_match('/category:/', $val['type'])) {
91 if (GETPOST($key, 'int') == '-1') {
92 $val_const = '';
93 } else {
94 $val_const = GETPOST($key, 'int');
95 }
96 } else {
97 $val_const = GETPOST($key, 'alpha');
98 }
99
100 $result = dolibarr_set_const($db, $key, $val_const, 'chaine', 0, '', $conf->entity);
101 if ($result < 0) {
102 $error++;
103 break;
104 }
105 }
106 }
107}
108
109
110
111/*
112 * View
113 */
114
115$page_name = "datapolicySetup";
116llxHeader('', $langs->trans($page_name));
117
118// Subheader
119$linkback = '<a href="'.($backtopage ? $backtopage : DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1').'">'.$langs->trans("BackToModuleList").'</a>';
120
121print load_fiche_titre($langs->trans($page_name), $linkback, 'generic');
122
123// Configuration header
125print dol_get_fiche_head($head, 'settings', '', -1, '');
126
127// Setup page goes here
128echo '<span class="opacitymedium">'.$langs->trans("datapolicySetupPage").'</span><br><br>';
129
130
131if ($action == 'edit') {
132 print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';
133 print '<input type="hidden" name="token" value="'.newToken().'">';
134 print '<input type="hidden" name="action" value="update">';
135
136 print '<table class="noborder centpercent">';
137 print '<tr class="liste_titre"><td class="titlefield">'.$langs->trans("Parameter").'</td><td>'.$langs->trans("Value").'</td></tr>';
138
139 foreach ($arrayofparameters as $title => $tab) {
140 print '<tr class="trforbreak"><td class="titlefield trforbreak" colspan="2">'.$langs->trans($title).'</td></tr>';
141 foreach ($tab as $key => $val) {
142 print '<tr class="oddeven"><td>';
143 print $val['picto'];
144 print $form->textwithpicto($langs->trans($key), $langs->trans('DATAPOLICY_Tooltip_SETUP'));
145 print '</td><td>';
146 print '<select name="'.$key.'" class="flat '.(empty($val['css']) ? 'minwidth200' : $val['css']).'">';
147 foreach ($valTab as $key1 => $val1) {
148 print '<option value="'.$key1.'" '.($conf->global->$key == $key1 ? 'selected="selected"' : '').'>';
149 print $val1;
150 print '</option>';
151 }
152 print '</select>';
153 print '</td></tr>';
154 }
155 }
156
157 print '</table>';
158
159 print '<br><div class="center">';
160 print '<input class="button button-save" type="submit" value="'.$langs->trans("Save").'">';
161 print '</div>';
162
163 print '</form>';
164 print '<br>';
165} else {
166 print '<table class="noborder centpercent">';
167 print '<tr class="liste_titre"><td class="titlefield">'.$langs->trans("Parameter").'</td><td>'.$langs->trans("Value").'</td></tr>';
168
169 foreach ($arrayofparameters as $title => $tab) {
170 print '<tr class="trforbreak"><td class="titlefield trforbreak" colspan="2">'.$langs->trans($title).'</td></tr>';
171 foreach ($tab as $key => $val) {
172 print '<tr class="oddeven"><td>';
173 print $val['picto'];
174 print $form->textwithpicto($langs->trans($key), $langs->trans('DATAPOLICY_Tooltip_SETUP'));
175 print '</td><td>'.($conf->global->$key == '' ? $langs->trans('None') : $valTab[$conf->global->$key]).'</td></tr>';
176 }
177 }
178
179 print '</table>';
180
181 print '<div class="tabsAction">';
182 print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=edit&token='.newToken().'">'.$langs->trans("Modify").'</a>';
183 print '</div>';
184}
185
186
187// Page end
188print dol_get_fiche_end();
189
190llxFooter();
191$db->close();
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).
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader()
Empty header.
Definition wrapper.php:56
llxFooter()
Empty footer.
Definition wrapper.php:70
datapolicyAdminPrepareHead()
Prepare admin pages header.
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_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)
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.