dolibarr 21.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-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
33// Load translation files required by the page
34$langs->load("admin");
35
36if (!$user->admin) {
38}
39
40$action = GETPOST('action', 'aZ09');
41if (empty($action)) {
42 $action = 'edit';
43}
44
45// Define list of managed delays
46$modules = array(
47 'agenda' => array(
48 array(
49 'code' => 'MAIN_DELAY_ACTIONS_TODO',
50 'img' => 'action'
51 )
52 ),
53 'projet' => array(
54 array(
55 'code' => 'MAIN_DELAY_PROJECT_TO_CLOSE',
56 'img' => 'project'
57 ),
58 array(
59 'code' => 'MAIN_DELAY_TASKS_TODO',
60 'img' => 'projecttask'
61 )
62 ),
63 'propal' => array(
64 array(
65 'code' => 'MAIN_DELAY_PROPALS_TO_CLOSE',
66 'img' => 'propal'
67 ),
68 array(
69 'code' => 'MAIN_DELAY_PROPALS_TO_BILL',
70 'img' => 'propal'
71 )
72 ),
73 'commande' => array(
74 array(
75 'code' => 'MAIN_DELAY_ORDERS_TO_PROCESS',
76 'img' => 'order'
77 )
78 ),
79 'facture' => array(
80 array(
81 'code' => 'MAIN_DELAY_CUSTOMER_BILLS_UNPAYED',
82 'img' => 'bill'
83 )
84 ),
85 'fournisseur' => array(
86 array(
87 'code' => 'MAIN_DELAY_SUPPLIER_ORDERS_TO_PROCESS',
88 'img' => 'order'
89 ),
90 array(
91 'code' => 'MAIN_DELAY_SUPPLIER_BILLS_TO_PAY',
92 'img' => 'bill'
93 )
94 ),
95 'service' => array(
96 array(
97 'code' => 'MAIN_DELAY_NOT_ACTIVATED_SERVICES',
98 'img' => 'service'
99 ),
100 array(
101 'code' => 'MAIN_DELAY_RUNNING_SERVICES',
102 'img' => 'service'
103 )
104 ),
105 'banque' => array(
106 array(
107 'code' => 'MAIN_DELAY_TRANSACTIONS_TO_CONCILIATE',
108 'img' => 'account'
109 ),
110 array(
111 'code' => 'MAIN_DELAY_CHEQUES_TO_DEPOSIT',
112 'img' => 'account'
113 )
114 ),
115 'adherent' => array(
116 array(
117 'code' => 'MAIN_DELAY_MEMBERS',
118 'img' => 'user'
119 )
120 ),
121 'expensereport' => array(
122 array(
123 'code' => 'MAIN_DELAY_EXPENSEREPORTS',
124 'img' => 'trip'
125 ),
126 /* TODO Enable this
127 array(
128 'code' => 'MAIN_DELAY_EXPENSEREPORTS_TO_PAY',
129 'img' => 'trip'
130 )*/
131 ),
132 'holiday' => array(
133 array(
134 'code' => 'MAIN_DELAY_HOLIDAYS',
135 'img' => 'holiday'
136 ),
137 ),
138);
139
140$labelmeteo = array(0 => $langs->trans("No"), 1 => $langs->trans("Yes"), 2 => $langs->trans("OnMobileOnly"));
141
142if (!isset($conf->global->MAIN_DELAY_MEMBERS)) {
143 $conf->global->MAIN_DELAY_MEMBERS = 0; // Must be same value than into conf.class.php
144}
145if (!isset($conf->global->MAIN_DELAY_ACTIONS_TODO)) {
146 $conf->global->MAIN_DELAY_ACTIONS_TODO = 7; // Must be same value than into conf.class.php
147}
148if (!isset($conf->global->MAIN_DELAY_ORDERS_TO_PROCESS)) {
149 $conf->global->MAIN_DELAY_ORDERS_TO_PROCESS = 2;
150}
151if (!isset($conf->global->MAIN_DELAY_SUPPLIER_ORDERS_TO_PROCESS)) {
152 $conf->global->MAIN_DELAY_SUPPLIER_ORDERS_TO_PROCESS = 7;
153}
154if (!isset($conf->global->MAIN_DELAY_ORDERS_TO_PROCESS)) {
155 $conf->global->MAIN_DELAY_ORDERS_TO_PROCESS = 2;
156}
157if (!isset($conf->global->MAIN_DELAY_ORDERS_TO_PROCESS)) {
158 $conf->global->MAIN_DELAY_ORDERS_TO_PROCESS = 2;
159}
160if (!isset($conf->global->MAIN_DELAY_ORDERS_TO_PROCESS)) {
161 $conf->global->MAIN_DELAY_ORDERS_TO_PROCESS = 2;
162}
163
164
165
166/*
167 * Actions
168 */
169
170if ($action == 'update') {
171 foreach ($modules as $module => $delays) {
172 if (isModEnabled($module)) {
173 foreach ($delays as $delay) {
174 if (GETPOST($delay['code']) != '') {
175 dolibarr_set_const($db, $delay['code'], GETPOST($delay['code']), 'chaine', 0, '', $conf->entity);
176 }
177 }
178 }
179 }
180
181 dolibarr_set_const($db, "MAIN_DISABLE_METEO", GETPOST("MAIN_DISABLE_METEO"), 'chaine', 0, '', $conf->entity);
182 dolibarr_set_const($db, "MAIN_USE_METEO_WITH_PERCENTAGE", GETPOST("MAIN_USE_METEO_WITH_PERCENTAGE"), 'chaine', 0, '', $conf->entity);
183
184 // For update value with percentage
185 $plus = '';
186 if (getDolGlobalString('MAIN_USE_METEO_WITH_PERCENTAGE')) {
187 $plus = '_PERCENTAGE';
188 }
189 // Update values
190 for ($i = 0; $i < 4; $i++) {
191 if (GETPOSTISSET('MAIN_METEO'.$plus.'_LEVEL'.$i)) {
192 dolibarr_set_const($db, 'MAIN_METEO'.$plus.'_LEVEL'.$i, GETPOSTINT('MAIN_METEO'.$plus.'_LEVEL'.$i), 'chaine', 0, '', $conf->entity);
193 }
194 }
195
196 setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
197
198 $action = 'edit';
199}
200
201
202/*
203 * View
204 */
205
206$form = new Form($db);
207
208llxHeader('', '', '', '', 0, 0, '', '', '', 'mod-admin page-delais');
209
210print load_fiche_titre($langs->trans("DelaysOfToleranceBeforeWarning"), '', 'title_setup');
211
212print '<span class="opacitymedium">'.$langs->transnoentities("DelaysOfToleranceDesc", img_warning('default', '', 'pictowarning nopaddingleft'));
213print " ".$langs->trans("OnlyActiveElementsAreShown", DOL_URL_ROOT.'/admin/modules.php')."</span><br>\n";
214print "<br>\n";
215print "<br>\n";
216
217if ($action == 'edit') {
218 print '<form method="post" action="'.$_SERVER['PHP_SELF'].'" name="form_index">';
219 print '<input type="hidden" name="token" value="'.newToken().'">';
220 print '<input type="hidden" name="action" value="update">';
221
222 print '<table class="noborder centpercent">';
223 print '<tr class="liste_titre"><td colspan="2">'.$langs->trans("DelaysOfToleranceBeforeWarning").'</td>';
224 print '<td class="right">'.$langs->trans("LateWarningAfter").'</td></tr>';
225
226 foreach ($modules as $module => $delays) {
227 if (isModEnabled($module)) {
228 foreach ($delays as $delay) {
229 $value = getDolGlobalInt($delay['code']);
230 print '<tr class="oddeven">';
231 print '<td width="20px">' . img_object('', $delay['img']) . '</td>';
232 print '<td>' . $langs->trans('Delays_' . $delay['code']) . '</td><td class="nowraponall right">';
233 print '<input class="right maxwidth75" type="number" name="' . $delay['code'] . '" value="' . $value . '"> ' . $langs->trans("days") . '</td></tr>';
234 }
235 }
236 }
237
238 print '</table>';
239
240 print '<br>';
241
242 // Show if meteo is enabled
243 print '<table class="noborder centpercent">';
244 print '<tr class="liste_titre"><td>'.$langs->trans("Option").'</td><td class="right">'.$langs->trans("Value").'</td></tr>';
245
246 print '<tr class="oddeven">';
247 print '<td>'.$langs->trans("MAIN_DISABLE_METEO").'</td><td class="right">';
248 print $form->selectarray('MAIN_DISABLE_METEO', $labelmeteo, (!getDolGlobalString('MAIN_DISABLE_METEO') ? 0 : $conf->global->MAIN_DISABLE_METEO));
249 print '</td></tr>';
250
251 print '</table>';
252} else {
253 /*
254 * Show parameters
255 */
256
257 print '<table class="noborder centpercent">';
258 print '<tr class="liste_titre"><td colspan="2">'.$langs->trans("DelaysOfToleranceBeforeWarning").'</td><td class="right">'.$langs->trans("Value").'</td></tr>';
259
260 foreach ($modules as $module => $delays) {
261 if (isModEnabled($module)) {
262 foreach ($delays as $delay) {
263 $value = getDolGlobalInt($delay['code']);
264 print '<tr class="oddeven">';
265 print '<td width="20px">' . img_object('', $delay['img']) . '</td>';
266 print '<td>' . $langs->trans('Delays_' . $delay['code']) . '</td>';
267 print '<td class="right">' . $value . ' ' . $langs->trans("days") . '</td></tr>';
268 }
269 }
270 }
271
272 print '</table>';
273
274 print '<br>';
275
276 // Show if meteo is enabled
277 print '<table class="noborder centpercent">';
278 print '<tr class="liste_titre"><td>'.$langs->trans("Option").'</td><td class="right">'.$langs->trans("Value").'</td></tr>';
279
280 print '<tr class="oddeven">';
281 print '<td>'.$langs->trans("MAIN_DISABLE_METEO").'</td><td class="center">';
282 print $labelmeteo[getDolGlobalInt('MAIN_DISABLE_METEO')];
283 print '</td></tr>';
284
285 print '</table>';
286}
287
288print '<br>';
289
290
291$str_mode_std = null;
292$str_mode_percentage = null;
293
294if (!getDolGlobalString('MAIN_DISABLE_METEO') || getDolGlobalInt('MAIN_DISABLE_METEO') != 1) {
295 // Show logo for weather
296 print '<span class="opacitymedium">'.$langs->trans("DescWeather").'</span> ';
297
298 if ($action == 'edit') {
299 $str_mode_std = $langs->trans('MeteoStdModEnabled').' : '.$langs->trans('MeteoUseMod', $langs->transnoentitiesnoconv('MeteoPercentageMod'));
300 $str_mode_percentage = $langs->trans('MeteoPercentageModEnabled').' : '.$langs->trans('MeteoUseMod', $langs->transnoentitiesnoconv('MeteoStdMod'));
301 if (!getDolGlobalString('MAIN_USE_METEO_WITH_PERCENTAGE')) {
302 $str_mode_enabled = $str_mode_std;
303 } else {
304 $str_mode_enabled = $str_mode_percentage;
305 }
306 print '<br><a href="#" onclick="return false;" id="change_mode">'.$str_mode_enabled.'</a>';
307 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 : '').'" />';
308
309 print '<br><br>';
310 } else {
311 if (!getDolGlobalString('MAIN_USE_METEO_WITH_PERCENTAGE')) {
312 print $langs->trans('MeteoStdModEnabled');
313 } else {
314 print $langs->trans('MeteoPercentageModEnabled');
315 }
316 print '<br><br>';
317 }
318
319 $offset = 0;
320 $cursor = 10; // By default
321 //if (!empty($conf->global->MAIN_METEO_OFFSET)) $offset=$conf->global->MAIN_METEO_OFFSET;
322 //if (!empty($conf->global->MAIN_METEO_GAP)) $cursor=$conf->global->MAIN_METEO_GAP;
323 $level0 = $offset;
324 if (getDolGlobalString('MAIN_METEO_LEVEL0')) {
325 $level0 = getDolGlobalString('MAIN_METEO_LEVEL0');
326 }
327 $level1 = $offset + $cursor;
328 if (getDolGlobalString('MAIN_METEO_LEVEL1')) {
329 $level1 = getDolGlobalString('MAIN_METEO_LEVEL1');
330 }
331 $level2 = $offset + 2 * $cursor;
332 if (getDolGlobalString('MAIN_METEO_LEVEL2')) {
333 $level2 = getDolGlobalString('MAIN_METEO_LEVEL2');
334 }
335 $level3 = $offset + 3 * $cursor;
336 if (getDolGlobalString('MAIN_METEO_LEVEL3')) {
337 $level3 = getDolGlobalString('MAIN_METEO_LEVEL3');
338 }
339 $text = '';
340 $options = 'class="valignmiddle" height="60px"';
341
342
343 if ($action == 'edit') {
344 print '<div id="standard" '.(!getDolGlobalString('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" '.(!getDolGlobalString('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 <script type="text/javascript">
385
386 $(document).ready(function() {
387
388 $("#change_mode").click(function() {
389 var use_percent = $("#MAIN_USE_METEO_WITH_PERCENTAGE");
390 var str_mode_std = "<?php print $str_mode_std; ?>";
391 var str_mode_percentage = "<?php print $str_mode_percentage; ?>";
392
393 if(use_percent.val() == 1) {
394 use_percent.val(0);
395 $("#standard").show();
396 $("#percentage").hide();
397 $(this).html(str_mode_std);
398 } else {
399 use_percent.val(1);
400 $("#standard").hide();
401 $("#percentage").show();
402 $(this).html(str_mode_percentage);
403 }
404 });
405
406 });
407
408 </script>
409
410 <?php
411 } else {
412 if (getDolGlobalString('MAIN_USE_METEO_WITH_PERCENTAGE')) {
413 print '<div>';
414 print '<div class="inline-block" style="padding-right: 20px">';
415 print img_weather($text, 0, $options);
416 print ' &lt;= ' . getDolGlobalString('MAIN_METEO_PERCENTAGE_LEVEL0').'&nbsp;%</td>';
417 print '</div><div class="inline-block" style="padding-right: 20px">';
418 print img_weather($text, 1, $options);
419 print ' &lt;= ' . getDolGlobalString('MAIN_METEO_PERCENTAGE_LEVEL1').'&nbsp;%</td>';
420 print '</div><div class="inline-block" style="padding-right: 20px">';
421 print img_weather($text, 2, $options);
422 print ' &lt;= ' . getDolGlobalString('MAIN_METEO_PERCENTAGE_LEVEL2').'&nbsp;%</td>';
423 print '</div><div class="inline-block" style="padding-right: 20px">';
424 print img_weather($text, 3, $options);
425 print ' &lt;= ' . getDolGlobalString('MAIN_METEO_PERCENTAGE_LEVEL3').'&nbsp;%</td>';
426 print '</div><div class="inline-block" style="padding-right: 20px">';
427 print img_weather($text, 4, $options);
428 print ' &gt; ' . getDolGlobalString('MAIN_METEO_PERCENTAGE_LEVEL3').'&nbsp;%</td>';
429 print '</div>';
430 print '</div>';
431 } else {
432 print '<div>';
433 print '<div class="inline-block" style="padding-right: 20px">';
434 print img_weather($text, 0, $options);
435 print ' &lt;= '.$level0;
436 print '</div><div class="inline-block" style="padding-right: 20px">';
437 print img_weather($text, 1, $options);
438 print ' &lt;= '.$level1;
439 print '</div><div class="inline-block" style="padding-right: 20px">';
440 print img_weather($text, 2, $options);
441 print ' &lt;= '.$level2;
442 print '</div><div class="inline-block" style="padding-right: 20px">';
443 print img_weather($text, 3, $options);
444 print ' &lt;= '.$level3;
445 print '</div><div class="inline-block" style="padding-right: 20px">';
446 print img_weather($text, 4, $options);
447 print ' &gt; '.$level3;
448 print '</div>';
449 print '</div>';
450 }
451 }
452}
453
454
455if ($action == 'edit') {
456 print $form->buttonsSaveCancel("Save", '');
457 print '</form>';
458} else {
459 print '<br><br><div class="tabsAction">';
460 print '<a class="butAction reposition" href="delais.php?action=edit&token='.newToken().'">'.$langs->trans("Modify").'</a>';
461 print '</div>';
462}
463
464// End of page
465llxFooter();
466$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($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
Definition wrapper.php:70
Class to manage generation of HTML components Only common components must be here.
llxFooter()
Footer empty.
Definition document.php:107
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.
img_object($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0)
Show a picto called object_picto (generic function)
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.
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.
if(preg_match('/crypted:/i', $dolibarr_main_db_pass)||!empty($dolibarr_main_db_encrypted_pass)) $conf db type
Definition repair.php:137
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.