dolibarr  16.0.5
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 require '../../main.inc.php';
26 require_once DOL_DOCUMENT_ROOT."/core/lib/admin.lib.php";
27 require_once '../lib/datapolicy.lib.php';
28 
29 // Translations
30 $langs->loadLangs(array('admin', 'companies', 'members', 'datapolicy@datapolicy'));
31 
32 // Parameters
33 $action = GETPOST('action', 'aZ09');
34 $backtopage = GETPOST('backtopage', 'alpha');
35 
36 $arrayofparameters = array();
37 $arrayofparameters['ThirdParty'] = array(
38  'DATAPOLICY_TIERS_CLIENT'=>array('css'=>'minwidth200', 'picto'=>img_picto('', 'company', 'class="pictofixedwidth"')),
39  'DATAPOLICY_TIERS_PROSPECT'=>array('css'=>'minwidth200', 'picto'=>img_picto('', 'company', 'class="pictofixedwidth"')),
40  'DATAPOLICY_TIERS_PROSPECT_CLIENT'=>array('css'=>'minwidth200', 'picto'=>img_picto('', 'company', 'class="pictofixedwidth"')),
41  'DATAPOLICY_TIERS_NIPROSPECT_NICLIENT'=>array('css'=>'minwidth200', 'picto'=>img_picto('', 'company', 'class="pictofixedwidth"')),
42  'DATAPOLICY_TIERS_FOURNISSEUR'=>array('css'=>'minwidth200', 'picto'=>img_picto('', 'supplier', 'class="pictofixedwidth"')),
43 );
44 if (!empty($conf->global->DATAPOLICY_USE_SPECIFIC_DELAY_FOR_CONTACT)) {
45  $arrayofparameters['Contact'] = array(
46  'DATAPOLICY_CONTACT_CLIENT'=>array('css'=>'minwidth200', 'picto'=>img_picto('', 'contact', 'class="pictofixedwidth"')),
47  'DATAPOLICY_CONTACT_PROSPECT'=>array('css'=>'minwidth200', 'picto'=>img_picto('', 'contact', 'class="pictofixedwidth"')),
48  'DATAPOLICY_CONTACT_PROSPECT_CLIENT'=>array('css'=>'minwidth200', 'picto'=>img_picto('', 'contact', 'class="pictofixedwidth"')),
49  'DATAPOLICY_CONTACT_NIPROSPECT_NICLIENT'=>array('css'=>'minwidth200', 'picto'=>img_picto('', 'contact', 'class="pictofixedwidth"')),
50  'DATAPOLICY_CONTACT_FOURNISSEUR'=>array('css'=>'minwidth200', 'picto'=>img_picto('', 'contact', 'class="pictofixedwidth"')),
51  );
52 }
53 if (!empty($conf->adherent->enabled)) {
54  $arrayofparameters['Member'] = array(
55  'DATAPOLICY_ADHERENT'=>array('css'=>'minwidth200', 'picto'=>img_picto('', 'member', 'class="pictofixedwidth"')),
56  );
57 }
58 
59 $valTab = array(
60  '' => $langs->trans('Never'),
61  '6' => $langs->trans('NB_MONTHS', 6),
62  '12' => $langs->trans('ONE_YEAR'),
63  '24' => $langs->trans('NB_YEARS', 2),
64  '36' => $langs->trans('NB_YEARS', 3),
65  '48' => $langs->trans('NB_YEARS', 4),
66  '60' => $langs->trans('NB_YEARS', 5),
67  '120' => $langs->trans('NB_YEARS', 10),
68  '180' => $langs->trans('NB_YEARS', 15),
69  '240' => $langs->trans('NB_YEARS', 20),
70 );
71 
72 // Access control
73 if (!$user->admin) {
75 }
76 
77 
78 /*
79  * Actions
80  */
81 
82 foreach ($arrayofparameters as $title => $tab) {
83  foreach ($tab as $key => $val) {
84  // Modify constant only if key was posted (avoid resetting key to the null value)
85  if (GETPOSTISSET($key)) {
86  if (preg_match('/category:/', $val['type'])) {
87  if (GETPOST($key, 'int') == '-1') {
88  $val_const = '';
89  } else {
90  $val_const = GETPOST($key, 'int');
91  }
92  } else {
93  $val_const = GETPOST($key, 'alpha');
94  }
95 
96  $result = dolibarr_set_const($db, $key, $val_const, 'chaine', 0, '', $conf->entity);
97  if ($result < 0) {
98  $error++;
99  break;
100  }
101  }
102  }
103 }
104 
105 
106 
107 /*
108  * View
109  */
110 
111 $page_name = "datapolicySetup";
112 llxHeader('', $langs->trans($page_name));
113 
114 // Subheader
115 $linkback = '<a href="'.($backtopage ? $backtopage : DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1').'">'.$langs->trans("BackToModuleList").'</a>';
116 
117 print load_fiche_titre($langs->trans($page_name), $linkback, 'generic');
118 
119 // Configuration header
121 print dol_get_fiche_head($head, 'settings', '', -1, '');
122 
123 // Setup page goes here
124 echo '<span class="opacitymedium">'.$langs->trans("datapolicySetupPage").'</span><br><br>';
125 
126 
127 if ($action == 'edit') {
128  print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';
129  print '<input type="hidden" name="token" value="'.newToken().'">';
130  print '<input type="hidden" name="action" value="update">';
131 
132  print '<table class="noborder centpercent">';
133  print '<tr class="liste_titre"><td class="titlefield">'.$langs->trans("Parameter").'</td><td>'.$langs->trans("Value").'</td></tr>';
134 
135  foreach ($arrayofparameters as $title => $tab) {
136  print '<tr class="trforbreak"><td class="titlefield trforbreak" colspan="2">'.$langs->trans($title).'</td></tr>';
137  foreach ($tab as $key => $val) {
138  print '<tr class="oddeven"><td>';
139  print $val['picto'];
140  print $form->textwithpicto($langs->trans($key), $langs->trans($key.'Tooltip'));
141  print '</td><td>';
142  print '<select name="'.$key.'" class="flat '.(empty($val['css']) ? 'minwidth200' : $val['css']).'">';
143  foreach ($valTab as $key1 => $val1) {
144  print '<option value="'.$key1.'" '.($conf->global->$key == $key1 ? 'selected="selected"' : '').'>';
145  print $val1;
146  print '</option>';
147  }
148  print '</select>';
149  print '</td></tr>';
150  }
151  }
152 
153  print '</table>';
154 
155  print '<br><div class="center">';
156  print '<input class="button button-save" type="submit" value="'.$langs->trans("Save").'">';
157  print '</div>';
158 
159  print '</form>';
160  print '<br>';
161 } else {
162  print '<table class="noborder centpercent">';
163  print '<tr class="liste_titre"><td class="titlefield">'.$langs->trans("Parameter").'</td><td>'.$langs->trans("Value").'</td></tr>';
164 
165  foreach ($arrayofparameters as $title => $tab) {
166  print '<tr class="trforbreak"><td class="titlefield trforbreak" colspan="2">'.$langs->trans($title).'</td></tr>';
167  foreach ($tab as $key => $val) {
168  print '<tr class="oddeven"><td>';
169  print $val['picto'];
170  print $form->textwithpicto($langs->trans($key), $langs->trans('DATAPOLICY_Tooltip_SETUP'));
171  print '</td><td>'.($conf->global->$key == '' ? $langs->trans('None') : $valTab[$conf->global->$key]).'</td></tr>';
172  }
173  }
174 
175  print '</table>';
176 
177  print '<div class="tabsAction">';
178  print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=edit&token='.newToken().'">'.$langs->trans("Modify").'</a>';
179  print '</div>';
180 }
181 
182 
183 // Page end
184 print dol_get_fiche_end();
185 
186 llxFooter();
187 $db->close();
llxFooter
llxFooter()
Empty footer.
Definition: wrapper.php:73
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
datapolicyAdminPrepareHead
datapolicyAdminPrepareHead()
Prepare admin pages header.
Definition: datapolicy.lib.php:30
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
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
dol_get_fiche_end
dol_get_fiche_end($notab=0)
Return tab footer of a card.
Definition: functions.lib.php:2018
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
GETPOSTISSET
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form.
Definition: functions.lib.php:386
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