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