dolibarr 21.0.0-beta
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 ),
103 'service' => array(
104 array(
105 'code' => 'MAIN_DELAY_NOT_ACTIVATED_SERVICES',
106 'img' => 'service'
107 ),
108 array(
109 'code' => 'MAIN_DELAY_RUNNING_SERVICES',
110 'img' => 'service'
111 )
112 ),
113 'banque' => array(
114 array(
115 'code' => 'MAIN_DELAY_TRANSACTIONS_TO_CONCILIATE',
116 'img' => 'account'
117 ),
118 array(
119 'code' => 'MAIN_DELAY_CHEQUES_TO_DEPOSIT',
120 'img' => 'account'
121 )
122 ),
123 'adherent' => array(
124 array(
125 'code' => 'MAIN_DELAY_MEMBERS',
126 'img' => 'user'
127 )
128 ),
129 'expensereport' => array(
130 array(
131 'code' => 'MAIN_DELAY_EXPENSEREPORTS',
132 'img' => 'trip'
133 ),
134 /* TODO Enable this
135 array(
136 'code' => 'MAIN_DELAY_EXPENSEREPORTS_TO_PAY',
137 'img' => 'trip'
138 )*/
139 ),
140 'holiday' => array(
141 array(
142 'code' => 'MAIN_DELAY_HOLIDAYS',
143 'img' => 'holiday'
144 ),
145 ),
146);
147
148$labelmeteo = array(0 => $langs->trans("No"), 1 => $langs->trans("Yes"), 2 => $langs->trans("OnMobileOnly"));
149
150if (!isset($conf->global->MAIN_DELAY_MEMBERS)) {
151 $conf->global->MAIN_DELAY_MEMBERS = 0; // Must be same value than into conf.class.php
152}
153if (!isset($conf->global->MAIN_DELAY_ACTIONS_TODO)) {
154 $conf->global->MAIN_DELAY_ACTIONS_TODO = 7; // Must be same value than into conf.class.php
155}
156if (!isset($conf->global->MAIN_DELAY_ORDERS_TO_PROCESS)) {
157 $conf->global->MAIN_DELAY_ORDERS_TO_PROCESS = 2;
158}
159if (!isset($conf->global->MAIN_DELAY_SUPPLIER_ORDERS_TO_PROCESS)) {
160 $conf->global->MAIN_DELAY_SUPPLIER_ORDERS_TO_PROCESS = 7;
161}
162if (!isset($conf->global->MAIN_DELAY_ORDERS_TO_PROCESS)) {
163 $conf->global->MAIN_DELAY_ORDERS_TO_PROCESS = 2;
164}
165if (!isset($conf->global->MAIN_DELAY_ORDERS_TO_PROCESS)) {
166 $conf->global->MAIN_DELAY_ORDERS_TO_PROCESS = 2;
167}
168if (!isset($conf->global->MAIN_DELAY_ORDERS_TO_PROCESS)) {
169 $conf->global->MAIN_DELAY_ORDERS_TO_PROCESS = 2;
170}
171
172
173
174/*
175 * Actions
176 */
177
178if ($action == 'update') {
179 foreach ($modules as $module => $delays) {
180 if (isModEnabled($module)) {
181 foreach ($delays as $delay) {
182 if (GETPOST($delay['code']) != '') {
183 dolibarr_set_const($db, $delay['code'], GETPOST($delay['code']), 'chaine', 0, '', $conf->entity);
184 }
185 }
186 }
187 }
188
189 dolibarr_set_const($db, "MAIN_DISABLE_METEO", GETPOST("MAIN_DISABLE_METEO"), 'chaine', 0, '', $conf->entity);
190 dolibarr_set_const($db, "MAIN_USE_METEO_WITH_PERCENTAGE", GETPOST("MAIN_USE_METEO_WITH_PERCENTAGE"), 'chaine', 0, '', $conf->entity);
191
192 // For update value with percentage
193 $plus = '';
194 if (getDolGlobalString('MAIN_USE_METEO_WITH_PERCENTAGE')) {
195 $plus = '_PERCENTAGE';
196 }
197 // Update values
198 for ($i = 0; $i < 4; $i++) {
199 if (GETPOSTISSET('MAIN_METEO'.$plus.'_LEVEL'.$i)) {
200 dolibarr_set_const($db, 'MAIN_METEO'.$plus.'_LEVEL'.$i, GETPOSTINT('MAIN_METEO'.$plus.'_LEVEL'.$i), 'chaine', 0, '', $conf->entity);
201 }
202 }
203
204 setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
205
206 $action = 'edit';
207}
208
209
210/*
211 * View
212 */
213
214$form = new Form($db);
215
216llxHeader('', '', '', '', 0, 0, '', '', '', 'mod-admin page-delais');
217
218print load_fiche_titre($langs->trans("DelaysOfToleranceBeforeWarning"), '', 'title_setup');
219
220print '<span class="opacitymedium">'.$langs->transnoentities("DelaysOfToleranceDesc", img_warning('default', '', 'pictowarning nopaddingleft'));
221print " ".$langs->trans("OnlyActiveElementsAreShown", DOL_URL_ROOT.'/admin/modules.php')."</span><br>\n";
222print "<br>\n";
223print "<br>\n";
224
225if ($action == 'edit') {
226 print '<form method="post" action="'.$_SERVER['PHP_SELF'].'" name="form_index">';
227 print '<input type="hidden" name="token" value="'.newToken().'">';
228 print '<input type="hidden" name="action" value="update">';
229
230 print '<table class="noborder centpercent">';
231 print '<tr class="liste_titre"><td colspan="2">'.$langs->trans("DelaysOfToleranceBeforeWarning").'</td>';
232 print '<td class="right">'.$langs->trans("LateWarningAfter").'</td></tr>';
233
234 foreach ($modules as $module => $delays) {
235 if (isModEnabled($module)) {
236 foreach ($delays as $delay) {
237 $value = getDolGlobalInt($delay['code']);
238 print '<tr class="oddeven">';
239 print '<td width="20px">' . img_object('', $delay['img']) . '</td>';
240 print '<td>' . $langs->trans('Delays_' . $delay['code']) . '</td><td class="nowraponall right">';
241 print '<input class="right maxwidth75" type="number" name="' . $delay['code'] . '" value="' . $value . '"> ' . $langs->trans("days") . '</td></tr>';
242 }
243 }
244 }
245
246 print '</table>';
247
248 print '<br>';
249
250 // Show if meteo is enabled
251 print '<table class="noborder centpercent">';
252 print '<tr class="liste_titre"><td>'.$langs->trans("Option").'</td><td class="right">'.$langs->trans("Value").'</td></tr>';
253
254 print '<tr class="oddeven">';
255 print '<td>'.$langs->trans("MAIN_DISABLE_METEO").'</td><td class="right">';
256 print $form->selectarray('MAIN_DISABLE_METEO', $labelmeteo, (!getDolGlobalString('MAIN_DISABLE_METEO') ? 0 : $conf->global->MAIN_DISABLE_METEO));
257 print '</td></tr>';
258
259 print '</table>';
260} else {
261 /*
262 * Show parameters
263 */
264
265 print '<table class="noborder centpercent">';
266 print '<tr class="liste_titre"><td colspan="2">'.$langs->trans("DelaysOfToleranceBeforeWarning").'</td><td class="right">'.$langs->trans("Value").'</td></tr>';
267
268 foreach ($modules as $module => $delays) {
269 if (isModEnabled($module)) {
270 foreach ($delays as $delay) {
271 $value = getDolGlobalInt($delay['code']);
272 print '<tr class="oddeven">';
273 print '<td width="20px">' . img_object('', $delay['img']) . '</td>';
274 print '<td>' . $langs->trans('Delays_' . $delay['code']) . '</td>';
275 print '<td class="right">' . $value . ' ' . $langs->trans("days") . '</td></tr>';
276 }
277 }
278 }
279
280 print '</table>';
281
282 print '<br>';
283
284 // Show if meteo is enabled
285 print '<table class="noborder centpercent">';
286 print '<tr class="liste_titre"><td>'.$langs->trans("Option").'</td><td class="right">'.$langs->trans("Value").'</td></tr>';
287
288 print '<tr class="oddeven">';
289 print '<td>'.$langs->trans("MAIN_DISABLE_METEO").'</td><td class="center">';
290 print $labelmeteo[getDolGlobalInt('MAIN_DISABLE_METEO')];
291 print '</td></tr>';
292
293 print '</table>';
294}
295
296print '<br>';
297
298
299$str_mode_std = null;
300$str_mode_percentage = null;
301
302if (!getDolGlobalString('MAIN_DISABLE_METEO') || getDolGlobalInt('MAIN_DISABLE_METEO') != 1) {
303 // Show logo for weather
304 print '<span class="opacitymedium">'.$langs->trans("DescWeather").'</span> ';
305
306 if ($action == 'edit') {
307 $str_mode_std = $langs->trans('MeteoStdModEnabled').' : '.$langs->trans('MeteoUseMod', $langs->transnoentitiesnoconv('MeteoPercentageMod'));
308 $str_mode_percentage = $langs->trans('MeteoPercentageModEnabled').' : '.$langs->trans('MeteoUseMod', $langs->transnoentitiesnoconv('MeteoStdMod'));
309 if (!getDolGlobalString('MAIN_USE_METEO_WITH_PERCENTAGE')) {
310 $str_mode_enabled = $str_mode_std;
311 } else {
312 $str_mode_enabled = $str_mode_percentage;
313 }
314 print '<br><a href="#" onclick="return false;" id="change_mode">'.$str_mode_enabled.'</a>';
315 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 : '').'" />';
316
317 print '<br><br>';
318 } else {
319 if (!getDolGlobalString('MAIN_USE_METEO_WITH_PERCENTAGE')) {
320 print $langs->trans('MeteoStdModEnabled');
321 } else {
322 print $langs->trans('MeteoPercentageModEnabled');
323 }
324 print '<br><br>';
325 }
326
327 $offset = 0;
328 $cursor = 10; // By default
329 //if (!empty($conf->global->MAIN_METEO_OFFSET)) $offset=$conf->global->MAIN_METEO_OFFSET;
330 //if (!empty($conf->global->MAIN_METEO_GAP)) $cursor=$conf->global->MAIN_METEO_GAP;
331 $level0 = $offset;
332 if (getDolGlobalString('MAIN_METEO_LEVEL0')) {
333 $level0 = getDolGlobalString('MAIN_METEO_LEVEL0');
334 }
335 $level1 = $offset + $cursor;
336 if (getDolGlobalString('MAIN_METEO_LEVEL1')) {
337 $level1 = getDolGlobalString('MAIN_METEO_LEVEL1');
338 }
339 $level2 = $offset + 2 * $cursor;
340 if (getDolGlobalString('MAIN_METEO_LEVEL2')) {
341 $level2 = getDolGlobalString('MAIN_METEO_LEVEL2');
342 }
343 $level3 = $offset + 3 * $cursor;
344 if (getDolGlobalString('MAIN_METEO_LEVEL3')) {
345 $level3 = getDolGlobalString('MAIN_METEO_LEVEL3');
346 }
347 $text = '';
348 $options = 'class="valignmiddle" height="60px"';
349
350
351 if ($action == 'edit') {
352 print '<div id="standard" '.(!getDolGlobalString('MAIN_USE_METEO_WITH_PERCENTAGE') ? '' : 'style="display:none;"').'>';
353
354 print '<div>';
355 print '<div class="inline-block" style="padding-right: 20px">';
356 print img_weather($text, 0, $options);
357 print ' &lt;= <input type="text" size="2" name="MAIN_METEO_LEVEL0" value="'.$level0.'"/></td>';
358 print '</div><div class="inline-block" style="padding-right: 20px">';
359 print img_weather($text, 1, $options);
360 print ' &lt;= <input type="text" size="2" name="MAIN_METEO_LEVEL1" value="'.$level1.'"/></td>';
361 print '</div><div class="inline-block" style="padding-right: 20px">';
362 print img_weather($text, 2, $options);
363 print ' &lt;= <input type="text" size="2" name="MAIN_METEO_LEVEL2" value="'.$level2.'"/></td>';
364 print '</div><div class="inline-block" style="padding-right: 20px">';
365 print img_weather($text, 3, $options);
366 print ' &lt;= <input type="text" size="2" name="MAIN_METEO_LEVEL3" value="'.$level3.'"/></td>';
367 print '</div>';
368 print '</div>';
369
370 print '</div>';
371
372 print '<div id="percentage" '.(!getDolGlobalString('MAIN_USE_METEO_WITH_PERCENTAGE') ? 'style="display:none;"' : '').'>';
373
374 print '<div>';
375 print '<div class="inline-block" style="padding-right: 20px">';
376 print img_weather($text, 0, $options);
377 print ' &lt;= <input type="text" size="2" name="MAIN_METEO_PERCENTAGE_LEVEL0" value="'.getDolGlobalString('MAIN_METEO_PERCENTAGE_LEVEL0').'"/>&nbsp;%</td>';
378 print '</div><div class="inline-block" style="padding-right: 20px">';
379 print img_weather($text, 1, $options);
380 print ' &lt;= <input type="text" size="2" name="MAIN_METEO_PERCENTAGE_LEVEL1" value="'.getDolGlobalString('MAIN_METEO_PERCENTAGE_LEVEL1').'"/>&nbsp;%</td>';
381 print '</div><div class="inline-block" style="padding-right: 20px">';
382 print img_weather($text, 2, $options);
383 print ' &lt;= <input type="text" size="2" name="MAIN_METEO_PERCENTAGE_LEVEL2" value="'.getDolGlobalString('MAIN_METEO_PERCENTAGE_LEVEL2').'"/>&nbsp;%</td>';
384 print '</div><div class="inline-block" style="padding-right: 20px">';
385 print img_weather($text, 3, $options);
386 print ' &lt;= <input type="text" size="2" name="MAIN_METEO_PERCENTAGE_LEVEL3" value="'.getDolGlobalString('MAIN_METEO_PERCENTAGE_LEVEL3').'"/>&nbsp;%</td>';
387 print '</div>';
388 print '</div>';
389
390 print '</div>'; ?>
391
392 <script type="text/javascript">
393
394 $(document).ready(function() {
395
396 $("#change_mode").click(function() {
397 var use_percent = $("#MAIN_USE_METEO_WITH_PERCENTAGE");
398 var str_mode_std = "<?php print $str_mode_std; ?>";
399 var str_mode_percentage = "<?php print $str_mode_percentage; ?>";
400
401 if(use_percent.val() == 1) {
402 use_percent.val(0);
403 $("#standard").show();
404 $("#percentage").hide();
405 $(this).html(str_mode_std);
406 } else {
407 use_percent.val(1);
408 $("#standard").hide();
409 $("#percentage").show();
410 $(this).html(str_mode_percentage);
411 }
412 });
413
414 });
415
416 </script>
417
418 <?php
419 } else {
420 if (getDolGlobalString('MAIN_USE_METEO_WITH_PERCENTAGE')) {
421 print '<div>';
422 print '<div class="inline-block" style="padding-right: 20px">';
423 print img_weather($text, 0, $options);
424 print ' &lt;= ' . getDolGlobalString('MAIN_METEO_PERCENTAGE_LEVEL0').'&nbsp;%</td>';
425 print '</div><div class="inline-block" style="padding-right: 20px">';
426 print img_weather($text, 1, $options);
427 print ' &lt;= ' . getDolGlobalString('MAIN_METEO_PERCENTAGE_LEVEL1').'&nbsp;%</td>';
428 print '</div><div class="inline-block" style="padding-right: 20px">';
429 print img_weather($text, 2, $options);
430 print ' &lt;= ' . getDolGlobalString('MAIN_METEO_PERCENTAGE_LEVEL2').'&nbsp;%</td>';
431 print '</div><div class="inline-block" style="padding-right: 20px">';
432 print img_weather($text, 3, $options);
433 print ' &lt;= ' . getDolGlobalString('MAIN_METEO_PERCENTAGE_LEVEL3').'&nbsp;%</td>';
434 print '</div><div class="inline-block" style="padding-right: 20px">';
435 print img_weather($text, 4, $options);
436 print ' &gt; ' . getDolGlobalString('MAIN_METEO_PERCENTAGE_LEVEL3').'&nbsp;%</td>';
437 print '</div>';
438 print '</div>';
439 } else {
440 print '<div>';
441 print '<div class="inline-block" style="padding-right: 20px">';
442 print img_weather($text, 0, $options);
443 print ' &lt;= '.$level0;
444 print '</div><div class="inline-block" style="padding-right: 20px">';
445 print img_weather($text, 1, $options);
446 print ' &lt;= '.$level1;
447 print '</div><div class="inline-block" style="padding-right: 20px">';
448 print img_weather($text, 2, $options);
449 print ' &lt;= '.$level2;
450 print '</div><div class="inline-block" style="padding-right: 20px">';
451 print img_weather($text, 3, $options);
452 print ' &lt;= '.$level3;
453 print '</div><div class="inline-block" style="padding-right: 20px">';
454 print img_weather($text, 4, $options);
455 print ' &gt; '.$level3;
456 print '</div>';
457 print '</div>';
458 }
459 }
460}
461
462
463if ($action == 'edit') {
464 print $form->buttonsSaveCancel("Save", '');
465 print '</form>';
466} else {
467 print '<br><br><div class="tabsAction">';
468 print '<a class="butAction reposition" href="delais.php?action=edit&token='.newToken().'">'.$langs->trans("Modify").'</a>';
469 print '</div>';
470}
471
472// End of page
473llxFooter();
474$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:71
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.
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:/i', $dolibarr_main_db_pass)||!empty($dolibarr_main_db_encrypted_pass)) $conf db type
Definition repair.php:149
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.