dolibarr  18.0.0-alpha
delais.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (C) 2001-2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
3  * Copyright (C) 2004-2010 Laurent Destailleur <eldy@users.sourceforge.net>
4  * Copyright (C) 2005 Simon Tosser <simon@kornog-computing.com>
5  * Copyright (C) 2005-2012 Regis Houssin <regis.houssin@inodbox.com>
6  * Copyright (C) 2016 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr>
7  * Copyright (C) 2022 Frédéric France <frederic.france@netlogic.fr>
8  *
9  * This program is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 3 of the License, or
12  * (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program. If not, see <https://www.gnu.org/licenses/>.
21  */
22 
28 // Load Dolibarr environment
29 require '../main.inc.php';
30 require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
31 
32 // Load translation files required by the page
33 $langs->load("admin");
34 
35 if (!$user->admin) {
37 }
38 
39 $action = GETPOST('action', 'aZ09');
40 if (empty($action)) {
41  $action = 'edit';
42 }
43 
44 // Define list of managed delays
45 $modules = array(
46  'agenda' => array(
47  array(
48  'code' => 'MAIN_DELAY_ACTIONS_TODO',
49  'img' => 'action'
50  )
51  ),
52  'projet' => array(
53  array(
54  'code' => 'MAIN_DELAY_PROJECT_TO_CLOSE',
55  'img' => 'project'
56  ),
57  array(
58  'code' => 'MAIN_DELAY_TASKS_TODO',
59  'img' => 'projecttask'
60  )
61  ),
62  'propal' => array(
63  array(
64  'code' => 'MAIN_DELAY_PROPALS_TO_CLOSE',
65  'img' => 'propal'
66  ),
67  array(
68  'code' => 'MAIN_DELAY_PROPALS_TO_BILL',
69  'img' => 'propal'
70  )
71  ),
72  'commande' => array(
73  array(
74  'code' => 'MAIN_DELAY_ORDERS_TO_PROCESS',
75  'img' => 'order'
76  )
77  ),
78  'facture' => array(
79  array(
80  'code' => 'MAIN_DELAY_CUSTOMER_BILLS_UNPAYED',
81  'img' => 'bill'
82  )
83  ),
84  'fournisseur' => array(
85  array(
86  'code' => 'MAIN_DELAY_SUPPLIER_ORDERS_TO_PROCESS',
87  'img' => 'order'
88  ),
89  array(
90  'code' => 'MAIN_DELAY_SUPPLIER_BILLS_TO_PAY',
91  'img' => 'bill'
92  )
93  ),
94  'service' => array(
95  array(
96  'code' => 'MAIN_DELAY_NOT_ACTIVATED_SERVICES',
97  'img' => 'service'
98  ),
99  array(
100  'code' => 'MAIN_DELAY_RUNNING_SERVICES',
101  'img' => 'service'
102  )
103  ),
104  'banque' => array(
105  array(
106  'code' => 'MAIN_DELAY_TRANSACTIONS_TO_CONCILIATE',
107  'img' => 'account'
108  ),
109  array(
110  'code' => 'MAIN_DELAY_CHEQUES_TO_DEPOSIT',
111  'img' => 'account'
112  )
113  ),
114  'adherent' => array(
115  array(
116  'code' => 'MAIN_DELAY_MEMBERS',
117  'img' => 'user'
118  )
119  ),
120  'expensereport' => array(
121  array(
122  'code' => 'MAIN_DELAY_EXPENSEREPORTS',
123  'img' => 'trip'
124  ),
125  /* TODO Enable this
126  array(
127  'code' => 'MAIN_DELAY_EXPENSEREPORTS_TO_PAY',
128  'img' => 'trip'
129  )*/
130  ),
131  'holiday' => array(
132  array(
133  'code' => 'MAIN_DELAY_HOLIDAYS',
134  'img' => 'holiday'
135  ),
136  ),
137 );
138 
139 $labelmeteo = array(0=>$langs->trans("No"), 1=>$langs->trans("Yes"), 2=>$langs->trans("OnMobileOnly"));
140 
141 if (!isset($conf->global->MAIN_DELAY_PROJECT_TO_CLOSE)) {
142  $conf->global->MAIN_DELAY_PROJECT_TO_CLOSE = 7; // Must be same value than into conf.class.php
143 }
144 if (!isset($conf->global->MAIN_DELAY_TASKS_TODO)) {
145  $conf->global->MAIN_DELAY_TASKS_TODO = 7; // Must be same value than into conf.class.php
146 }
147 if (!isset($conf->global->MAIN_DELAY_MEMBERS)) {
148  $conf->global->MAIN_DELAY_MEMBERS = 0; // Must be same value than into conf.class.php
149 }
150 if (!isset($conf->global->MAIN_DELAY_ACTIONS_TODO)) {
151  $conf->global->MAIN_DELAY_ACTIONS_TODO = 7; // Must be same value than into conf.class.php
152 }
153 if (!isset($conf->global->MAIN_DELAY_ORDERS_TO_PROCESS)) {
154  $conf->global->MAIN_DELAY_ORDERS_TO_PROCESS = 2;
155 }
156 if (!isset($conf->global->MAIN_DELAY_SUPPLIER_ORDERS_TO_PROCESS)) {
157  $conf->global->MAIN_DELAY_SUPPLIER_ORDERS_TO_PROCESS = 7;
158 }
159 if (!isset($conf->global->MAIN_DELAY_ORDERS_TO_PROCESS)) {
160  $conf->global->MAIN_DELAY_ORDERS_TO_PROCESS = 2;
161 }
162 if (!isset($conf->global->MAIN_DELAY_ORDERS_TO_PROCESS)) {
163  $conf->global->MAIN_DELAY_ORDERS_TO_PROCESS = 2;
164 }
165 if (!isset($conf->global->MAIN_DELAY_ORDERS_TO_PROCESS)) {
166  $conf->global->MAIN_DELAY_ORDERS_TO_PROCESS = 2;
167 }
168 
169 
170 
171 /*
172  * Actions
173  */
174 
175 if ($action == 'update') {
176  foreach ($modules as $module => $delays) {
177  if (isModEnabled($module)) {
178  foreach ($delays as $delay) {
179  if (GETPOST($delay['code']) != '') {
180  dolibarr_set_const($db, $delay['code'], GETPOST($delay['code']), 'chaine', 0, '', $conf->entity);
181  }
182  }
183  }
184  }
185 
186  dolibarr_set_const($db, "MAIN_DISABLE_METEO", GETPOST("MAIN_DISABLE_METEO"), 'chaine', 0, '', $conf->entity);
187  dolibarr_set_const($db, "MAIN_USE_METEO_WITH_PERCENTAGE", GETPOST("MAIN_USE_METEO_WITH_PERCENTAGE"), 'chaine', 0, '', $conf->entity);
188 
189  // For update value with percentage
190  $plus = '';
191  if (!empty($conf->global->MAIN_USE_METEO_WITH_PERCENTAGE)) {
192  $plus = '_PERCENTAGE';
193  }
194  // Update values
195  for ($i = 0; $i < 4; $i++) {
196  if (GETPOSTISSET('MAIN_METEO'.$plus.'_LEVEL'.$i)) {
197  dolibarr_set_const($db, 'MAIN_METEO'.$plus.'_LEVEL'.$i, GETPOST('MAIN_METEO'.$plus.'_LEVEL'.$i, 'int'), 'chaine', 0, '', $conf->entity);
198  }
199  }
200 
201  setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
202 
203  $action = 'edit';
204 }
205 
206 
207 /*
208  * View
209  */
210 
211 $form = new Form($db);
212 
213 llxHeader();
214 
215 print load_fiche_titre($langs->trans("DelaysOfToleranceBeforeWarning"), '', 'title_setup');
216 
217 print '<span class="opacitymedium">'.$langs->transnoentities("DelaysOfToleranceDesc", img_warning('default', '', 'pictowarning nopaddingleft'));
218 print " ".$langs->trans("OnlyActiveElementsAreShown", DOL_URL_ROOT.'/admin/modules.php')."</span><br>\n";
219 print "<br>\n";
220 
221 if ($action == 'edit') {
222  print '<form method="post" action="'.$_SERVER['PHP_SELF'].'" name="form_index">';
223  print '<input type="hidden" name="token" value="'.newToken().'">';
224  print '<input type="hidden" name="action" value="update">';
225 
226  print '<table class="noborder centpercent">';
227  print '<tr class="liste_titre"><td colspan="2">'.$langs->trans("DelaysOfToleranceBeforeWarning").'</td>';
228  print '<td class="right">'.$langs->trans("LateWarningAfter").'</td></tr>';
229 
230  foreach ($modules as $module => $delays) {
231  if (isModEnabled($module)) {
232  foreach ($delays as $delay) {
233  $value = (!empty($conf->global->{$delay['code']}) ? $conf->global->{$delay['code']} : 0);
234  print '<tr class="oddeven">';
235  print '<td width="20px">' . img_object('', $delay['img']) . '</td>';
236  print '<td>' . $langs->trans('Delays_' . $delay['code']) . '</td><td class="nowraponall right">';
237  print '<input class="right maxwidth75" type="number" name="' . $delay['code'] . '" value="' . $value . '"> ' . $langs->trans("days") . '</td></tr>';
238  }
239  }
240  }
241 
242  print '</table>';
243 
244  print '<br>';
245 
246  // Show if meteo is enabled
247  print '<table class="noborder centpercent">';
248  print '<tr class="liste_titre"><td>'.$langs->trans("Option").'</td><td class="right">'.$langs->trans("Value").'</td></tr>';
249 
250  print '<tr class="oddeven">';
251  print '<td>'.$langs->trans("MAIN_DISABLE_METEO").'</td><td class="right">';
252  print $form->selectarray('MAIN_DISABLE_METEO', $labelmeteo, (empty($conf->global->MAIN_DISABLE_METEO) ? 0 : $conf->global->MAIN_DISABLE_METEO));
253  print '</td></tr>';
254 
255  print '</table>';
256 } else {
257  /*
258  * Show parameters
259  */
260 
261  print '<table class="noborder centpercent">';
262  print '<tr class="liste_titre"><td colspan="2">'.$langs->trans("DelaysOfToleranceBeforeWarning").'</td><td class="right">'.$langs->trans("Value").'</td></tr>';
263 
264  foreach ($modules as $module => $delays) {
265  if (isModEnabled($module)) {
266  foreach ($delays as $delay) {
267  $value = (!empty($conf->global->{$delay['code']}) ? $conf->global->{$delay['code']} : 0);
268  print '<tr class="oddeven">';
269  print '<td width="20px">' . img_object('', $delay['img']) . '</td>';
270  print '<td>' . $langs->trans('Delays_' . $delay['code']) . '</td>';
271  print '<td class="right">' . $value . ' ' . $langs->trans("days") . '</td></tr>';
272  }
273  }
274  }
275 
276  print '</table>';
277 
278  print '<br>';
279 
280  // Show if meteo is enabled
281  print '<table class="noborder centpercent">';
282  print '<tr class="liste_titre"><td>'.$langs->trans("Option").'</td><td class="right">'.$langs->trans("Value").'</td></tr>';
283 
284  print '<tr class="oddeven">';
285  print '<td>'.$langs->trans("MAIN_DISABLE_METEO").'</td><td class="center">';
286  print $labelmeteo[$conf->global->MAIN_DISABLE_METEO];
287  print '</td></tr>';
288 
289  print '</table>';
290 }
291 
292 print '<br>';
293 
294 
295 if (empty($conf->global->MAIN_DISABLE_METEO) || $conf->global->MAIN_DISABLE_METEO != 1) {
296  // Show logo for weather
297  print '<span class="opacitymedium">'.$langs->trans("DescWeather").'</span> ';
298 
299  if ($action == 'edit') {
300  $str_mode_std = $langs->trans('MeteoStdModEnabled').' : '.$langs->trans('MeteoUseMod', $langs->transnoentitiesnoconv('MeteoPercentageMod'));
301  $str_mode_percentage = $langs->trans('MeteoPercentageModEnabled').' : '.$langs->trans('MeteoUseMod', $langs->transnoentitiesnoconv('MeteoStdMod'));
302  if (empty($conf->global->MAIN_USE_METEO_WITH_PERCENTAGE)) {
303  $str_mode_enabled = $str_mode_std;
304  } else {
305  $str_mode_enabled = $str_mode_percentage;
306  }
307  print '<br><a href="#" onclick="return false;" id="change_mode">'.$str_mode_enabled.'</a>';
308  print '<input type="hidden" id="MAIN_USE_METEO_WITH_PERCENTAGE" name="MAIN_USE_METEO_WITH_PERCENTAGE" value="'.(!empty($conf->global->MAIN_USE_METEO_WITH_PERCENTAGE) ? $conf->global->MAIN_USE_METEO_WITH_PERCENTAGE : '').'" />';
309 
310  print '<br><br>';
311  } else {
312  if (empty($conf->global->MAIN_USE_METEO_WITH_PERCENTAGE)) {
313  print $langs->trans('MeteoStdModEnabled');
314  } else {
315  print $langs->trans('MeteoPercentageModEnabled');
316  }
317  print '<br><br>';
318  }
319 
320  $offset = 0;
321  $cursor = 10; // By default
322  //if (!empty($conf->global->MAIN_METEO_OFFSET)) $offset=$conf->global->MAIN_METEO_OFFSET;
323  //if (!empty($conf->global->MAIN_METEO_GAP)) $cursor=$conf->global->MAIN_METEO_GAP;
324  $level0 = $offset;
325  if (!empty($conf->global->MAIN_METEO_LEVEL0)) {
326  $level0 = $conf->global->MAIN_METEO_LEVEL0;
327  }
328  $level1 = $offset + $cursor;
329  if (!empty($conf->global->MAIN_METEO_LEVEL1)) {
330  $level1 = $conf->global->MAIN_METEO_LEVEL1;
331  }
332  $level2 = $offset + 2 * $cursor;
333  if (!empty($conf->global->MAIN_METEO_LEVEL2)) {
334  $level2 = $conf->global->MAIN_METEO_LEVEL2;
335  }
336  $level3 = $offset + 3 * $cursor;
337  if (!empty($conf->global->MAIN_METEO_LEVEL3)) {
338  $level3 = $conf->global->MAIN_METEO_LEVEL3;
339  }
340  $text = ''; $options = 'class="valignmiddle" height="60px"';
341 
342 
343  if ($action == 'edit') {
344  print '<div id="standard" '.(empty($conf->global->MAIN_USE_METEO_WITH_PERCENTAGE) ? '' : 'style="display:none;"').'>';
345 
346  print '<div>';
347  print '<div class="inline-block" style="padding-right: 20px">';
348  print img_weather($text, 0, $options);
349  print ' &lt;= <input type="text" size="2" name="MAIN_METEO_LEVEL0" value="'.$level0.'"/></td>';
350  print '</div><div class="inline-block" style="padding-right: 20px">';
351  print img_weather($text, 1, $options);
352  print ' &lt;= <input type="text" size="2" name="MAIN_METEO_LEVEL1" value="'.$level1.'"/></td>';
353  print '</div><div class="inline-block" style="padding-right: 20px">';
354  print img_weather($text, 2, $options);
355  print ' &lt;= <input type="text" size="2" name="MAIN_METEO_LEVEL2" value="'.$level2.'"/></td>';
356  print '</div><div class="inline-block" style="padding-right: 20px">';
357  print img_weather($text, 3, $options);
358  print ' &lt;= <input type="text" size="2" name="MAIN_METEO_LEVEL3" value="'.$level3.'"/></td>';
359  print '</div>';
360  print '</div>';
361 
362  print '</div>';
363 
364  print '<div id="percentage" '.(empty($conf->global->MAIN_USE_METEO_WITH_PERCENTAGE) ? 'style="display:none;"' : '').'>';
365 
366  print '<div>';
367  print '<div class="inline-block" style="padding-right: 20px">';
368  print img_weather($text, 0, $options);
369  print ' &lt;= <input type="text" size="2" name="MAIN_METEO_PERCENTAGE_LEVEL0" value="'.getDolGlobalString('MAIN_METEO_PERCENTAGE_LEVEL0').'"/>&nbsp;%</td>';
370  print '</div><div class="inline-block" style="padding-right: 20px">';
371  print img_weather($text, 1, $options);
372  print ' &lt;= <input type="text" size="2" name="MAIN_METEO_PERCENTAGE_LEVEL1" value="'.getDolGlobalString('MAIN_METEO_PERCENTAGE_LEVEL1').'"/>&nbsp;%</td>';
373  print '</div><div class="inline-block" style="padding-right: 20px">';
374  print img_weather($text, 2, $options);
375  print ' &lt;= <input type="text" size="2" name="MAIN_METEO_PERCENTAGE_LEVEL2" value="'.getDolGlobalString('MAIN_METEO_PERCENTAGE_LEVEL2').'"/>&nbsp;%</td>';
376  print '</div><div class="inline-block" style="padding-right: 20px">';
377  print img_weather($text, 3, $options);
378  print ' &lt;= <input type="text" size="2" name="MAIN_METEO_PERCENTAGE_LEVEL3" value="'.getDolGlobalString('MAIN_METEO_PERCENTAGE_LEVEL3').'"/>&nbsp;%</td>';
379  print '</div>';
380  print '</div>';
381 
382  print '</div>';
383 
384  ?>
385 
386  <script type="text/javascript">
387 
388  $(document).ready(function() {
389 
390  $("#change_mode").click(function() {
391  var use_percent = $("#MAIN_USE_METEO_WITH_PERCENTAGE");
392  var str_mode_std = "<?php print $str_mode_std; ?>";
393  var str_mode_percentage = "<?php print $str_mode_percentage; ?>";
394 
395  if(use_percent.val() == 1) {
396  use_percent.val(0);
397  $("#standard").show();
398  $("#percentage").hide();
399  $(this).html(str_mode_std);
400  } else {
401  use_percent.val(1);
402  $("#standard").hide();
403  $("#percentage").show();
404  $(this).html(str_mode_percentage);
405  }
406  });
407 
408  });
409 
410  </script>
411 
412  <?php
413  } else {
414  if (!empty($conf->global->MAIN_USE_METEO_WITH_PERCENTAGE)) {
415  print '<div>';
416  print '<div class="inline-block" style="padding-right: 20px">';
417  print img_weather($text, 0, $options);
418  print ' &lt;= '.$conf->global->MAIN_METEO_PERCENTAGE_LEVEL0.'&nbsp;%</td>';
419  print '</div><div class="inline-block" style="padding-right: 20px">';
420  print img_weather($text, 1, $options);
421  print ' &lt;= '.$conf->global->MAIN_METEO_PERCENTAGE_LEVEL1.'&nbsp;%</td>';
422  print '</div><div class="inline-block" style="padding-right: 20px">';
423  print img_weather($text, 2, $options);
424  print ' &lt;= '.$conf->global->MAIN_METEO_PERCENTAGE_LEVEL2.'&nbsp;%</td>';
425  print '</div><div class="inline-block" style="padding-right: 20px">';
426  print img_weather($text, 3, $options);
427  print ' &lt;= '.$conf->global->MAIN_METEO_PERCENTAGE_LEVEL3.'&nbsp;%</td>';
428  print '</div><div class="inline-block" style="padding-right: 20px">';
429  print img_weather($text, 4, $options);
430  print ' &gt; '.$conf->global->MAIN_METEO_PERCENTAGE_LEVEL3.'&nbsp;%</td>';
431  print '</div>';
432  print '</div>';
433  } else {
434  print '<div>';
435  print '<div class="inline-block" style="padding-right: 20px">';
436  print img_weather($text, 0, $options);
437  print ' &lt;= '.$level0;
438  print '</div><div class="inline-block" style="padding-right: 20px">';
439  print img_weather($text, 1, $options);
440  print ' &lt;= '.$level1;
441  print '</div><div class="inline-block" style="padding-right: 20px">';
442  print img_weather($text, 2, $options);
443  print ' &lt;= '.$level2;
444  print '</div><div class="inline-block" style="padding-right: 20px">';
445  print img_weather($text, 3, $options);
446  print ' &lt;= '.$level3;
447  print '</div><div class="inline-block" style="padding-right: 20px">';
448  print img_weather($text, 4, $options);
449  print ' &gt; '.$level3;
450  print '</div>';
451  print '</div>';
452  }
453  }
454 }
455 
456 
457 if ($action == 'edit') {
458  print $form->buttonsSaveCancel("Save", '');
459  print '</form>';
460 } else {
461  print '<br><br><div class="tabsAction">';
462  print '<a class="butAction reposition" href="delais.php?action=edit&token='.newToken().'">'.$langs->trans("Modify").'</a>';
463  print '</div>';
464 }
465 
466 // End of page
467 llxFooter();
468 $db->close();
llxFooter
llxFooter()
Empty footer.
Definition: wrapper.php:70
load_fiche_titre
load_fiche_titre($titre, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
Definition: functions.lib.php:5363
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:530
img_warning
img_warning($titlealt='default', $moreatt='', $morecss='pictowarning')
Show warning logo.
Definition: functions.lib.php:4671
$form
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
Definition: card.php:143
llxHeader
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
isModEnabled
isModEnabled($module)
Is Dolibarr module enabled.
Definition: functions.lib.php:147
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:633
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:431
img_weather
img_weather($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $morecss='')
Show weather picto.
Definition: functions.lib.php:4381
Form
Class to manage generation of HTML components Only common components must be here.
Definition: html.form.class.php:52
img_object
img_object($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0)
Show a picto called object_picto (generic function)
Definition: functions.lib.php:4361
setEventMessages
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='')
Set event messages in dol_events session object.
Definition: functions.lib.php:8509
accessforbidden
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.
Definition: security.lib.php:1106
type
if(preg_match('/crypted:/i', $dolibarr_main_db_pass)||!empty($dolibarr_main_db_encrypted_pass)) $conf db type
Definition: repair.php:119