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