dolibarr  9.0.0
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 <http://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) accessforbidden();
34 
35 $action=GETPOST('action','alpha');
36 
37 $modules=array(
38  'agenda' => array(
39  array(
40  'code' => 'MAIN_DELAY_ACTIONS_TODO',
41  'img' => 'action'
42  )
43  ),
44  'projet' => array(
45  array(
46  'code' => 'MAIN_DELAY_PROJECT_TO_CLOSE',
47  'img' => 'project'
48  ),
49  array(
50  'code' => 'MAIN_DELAY_TASKS_TODO',
51  'img' => 'task'
52  )
53  ),
54  'propal' => array(
55  array(
56  'code' => 'MAIN_DELAY_PROPALS_TO_CLOSE',
57  'img' => 'propal'
58  ),
59  array(
60  'code' => 'MAIN_DELAY_PROPALS_TO_BILL',
61  'img' => 'propal'
62  )
63  ),
64  'commande' => array(
65  array(
66  'code' => 'MAIN_DELAY_ORDERS_TO_PROCESS',
67  'img' => 'order'
68  )
69  ),
70  'facture' => array(
71  array(
72  'code' => 'MAIN_DELAY_CUSTOMER_BILLS_UNPAYED',
73  'img' => 'bill'
74  )
75  ),
76  'fournisseur' => array(
77  array(
78  'code' => 'MAIN_DELAY_SUPPLIER_ORDERS_TO_PROCESS',
79  'img' => 'order'
80  ),
81  array(
82  'code' => 'MAIN_DELAY_SUPPLIER_BILLS_TO_PAY',
83  'img' => 'bill'
84  )
85  ),
86  'service' => array(
87  array(
88  'code' => 'MAIN_DELAY_NOT_ACTIVATED_SERVICES',
89  'img' => 'service'
90  ),
91  array(
92  'code' => 'MAIN_DELAY_RUNNING_SERVICES',
93  'img' => 'service'
94  )
95  ),
96  'banque' => array(
97  array(
98  'code' => 'MAIN_DELAY_TRANSACTIONS_TO_CONCILIATE',
99  'img' => 'account'
100  ),
101  array(
102  'code' => 'MAIN_DELAY_CHEQUES_TO_DEPOSIT',
103  'img' => 'account'
104  )
105  ),
106  'adherent' => array(
107  array(
108  'code' => 'MAIN_DELAY_MEMBERS',
109  'img' => 'user'
110  )
111  ),
112  'expensereport' => array(
113  array(
114  'code' => 'MAIN_DELAY_EXPENSEREPORTS',
115  'img' => 'trip'
116  ),
117  /* TODO Enable this
118  array(
119  'code' => 'MAIN_DELAY_EXPENSEREPORTS_TO_PAY',
120  'img' => 'trip'
121  )*/
122  ),
123 );
124 
125 $labelmeteo = array(0=>$langs->trans("No"), 1=>$langs->trans("Yes"), 2=>$langs->trans("OnMobileOnly"));
126 
127 
128 /*
129  * Actions
130  */
131 
132 if ($action == 'update')
133 {
134  foreach($modules as $module => $delays)
135  {
136  if (! empty($conf->$module->enabled))
137  {
138  foreach($delays as $delay)
139  {
140  if (GETPOST($delay['code']) != '')
141  {
142  dolibarr_set_const($db, $delay['code'], GETPOST($delay['code']), 'chaine', 0, '', $conf->entity);
143  }
144  }
145  }
146  }
147 
148  dolibarr_set_const($db, "MAIN_DISABLE_METEO",$_POST["MAIN_DISABLE_METEO"],'chaine',0,'',$conf->entity);
149  dolibarr_set_const($db, "MAIN_USE_METEO_WITH_PERCENTAGE",GETPOST("MAIN_USE_METEO_WITH_PERCENTAGE"),'chaine',0,'',$conf->entity);
150 
151  // For update value with percentage
152  $plus='';
153  if(!empty($conf->global->MAIN_USE_METEO_WITH_PERCENTAGE)) $plus = '_PERCENTAGE';
154  // Update values
155  for($i=0; $i<4; $i++) {
156  if(isset($_POST['MAIN_METEO'.$plus.'_LEVEL'.$i])) dolibarr_set_const($db, 'MAIN_METEO'.$plus.'_LEVEL'.$i, GETPOST('MAIN_METEO'.$plus.'_LEVEL'.$i, 'int'),'chaine',0,'',$conf->entity);
157  }
158 }
159 
160 
161 /*
162  * View
163  */
164 
165 $form = new Form($db);
166 
167 llxHeader();
168 
169 print load_fiche_titre($langs->trans("DelaysOfToleranceBeforeWarning"),'','title_setup');
170 
171 print $langs->transnoentities("DelaysOfToleranceDesc",img_warning());
172 print " ".$langs->trans("OnlyActiveElementsAreShown",DOL_URL_ROOT.'/admin/modules.php')."<br>\n";
173 print "<br>\n";
174 
175 $countrynotdefined='<font class="error">'.$langs->trans("ErrorSetACountryFirst").' ('.$langs->trans("SeeAbove").')</font>';
176 
177 if ($action == 'edit')
178 {
179  print '<form method="post" action="'.$_SERVER['PHP_SELF'].'" name="form_index">';
180  print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
181  print '<input type="hidden" name="action" value="update">';
182 
183  print '<table class="noborder" width="100%">';
184  print '<tr class="liste_titre"><td colspan="2">'.$langs->trans("DelaysOfToleranceBeforeWarning").'</td><td class="center" width="120px">'.$langs->trans("Value").'</td></tr>';
185 
186  foreach($modules as $module => $delays)
187  {
188  if (! empty($conf->$module->enabled))
189  {
190  foreach($delays as $delay)
191  {
192 
193  $value=(! empty($conf->global->{$delay['code']})?$conf->global->{$delay['code']}:0);
194  print '<tr class="oddeven">';
195  print '<td width="20px">'.img_object('',$delay['img']).'</td>';
196  print '<td>'.$langs->trans('Delays_'.$delay['code']).'</td><td>';
197  print '<input class="right maxwidth75" type="number" name="'.$delay['code'].'" value="'.$value.'"> '.$langs->trans("days").'</td></tr>';
198  }
199  }
200  }
201 
202  print '</table>';
203 
204  print '<br>';
205 
206  // Show if meteo is enabled
207  print '<table class="noborder" width="100%">';
208  print '<tr class="liste_titre"><td>'.$langs->trans("Parameter").'</td><td class="center" width="120px">'.$langs->trans("Value").'</td></tr>';
209 
210  print '<tr class="oddeven">';
211  print '<td>'.$langs->trans("MAIN_DISABLE_METEO").'</td><td class="center">';
212  print $form->selectarray('MAIN_DISABLE_METEO', $labelmeteo, (empty($conf->global->MAIN_DISABLE_METEO)?0:$conf->global->MAIN_DISABLE_METEO));
213  print '</td></tr>';
214 
215  print '</table>';
216 }
217 else
218 {
219  /*
220  * Affichage des parametres
221  */
222 
223  print '<table class="noborder" width="100%">';
224  print '<tr class="liste_titre"><td colspan="2">'.$langs->trans("DelaysOfToleranceBeforeWarning").'</td><td class="center" width="120px">'.$langs->trans("Value").'</td></tr>';
225 
226  foreach($modules as $module => $delays)
227  {
228  if (! empty($conf->$module->enabled))
229  {
230  foreach($delays as $delay)
231  {
232 
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>';
237  print '<td class="right">'.$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" width="100%">';
248  print '<tr class="liste_titre"><td>'.$langs->trans("Parameter").'</td><td class="center" width="120px">'.$langs->trans("Value").'</td></tr>';
249 
250  print '<tr class="oddeven">';
251  print '<td>'.$langs->trans("MAIN_DISABLE_METEO").'</td><td class="center">';
252  print $labelmeteo[$conf->global->MAIN_DISABLE_METEO];
253  print '</td></tr>';
254 
255  print '</table>';
256 }
257 
258 print '<br>';
259 
260 // Show logo for weather
261 print $langs->trans("DescWeather").'<br>';
262 
263 if($action == 'edit') {
264 
265  $str_mode_std = $langs->trans('MeteoStdModEnabled').' : '.$langs->trans('MeteoUseMod', $langs->trans('MeteoPercentageMod'));
266  $str_mode_percentage = $langs->trans('MeteoPercentageModEnabled').' : '.$langs->trans('MeteoUseMod', $langs->trans('MeteoStdMod'));
267  if(empty($conf->global->MAIN_USE_METEO_WITH_PERCENTAGE)) $str_mode_enabled = $str_mode_std;
268  else $str_mode_enabled = $str_mode_percentage;
269  print '<a href="#" onclick="return false;" id="change_mode">'.$str_mode_enabled.'</a>';
270  print '<input type="hidden" id="MAIN_USE_METEO_WITH_PERCENTAGE" name="MAIN_USE_METEO_WITH_PERCENTAGE" value="'.$conf->global->MAIN_USE_METEO_WITH_PERCENTAGE.'" />';
271 
272  print '<br><br>';
273 } else {
274  if(empty($conf->global->MAIN_USE_METEO_WITH_PERCENTAGE)) print $langs->trans('MeteoStdModEnabled');
275  else print $langs->trans('MeteoPercentageModEnabled');
276  print '<br><br>';
277 }
278 
279 $offset=0;
280 $cursor=10; // By default
281 //if (! empty($conf->global->MAIN_METEO_OFFSET)) $offset=$conf->global->MAIN_METEO_OFFSET;
282 //if (! empty($conf->global->MAIN_METEO_GAP)) $cursor=$conf->global->MAIN_METEO_GAP;
283 $level0=$offset; if (! empty($conf->global->MAIN_METEO_LEVEL0)) $level0=$conf->global->MAIN_METEO_LEVEL0;
284 $level1=$offset+1*$cursor; if (! empty($conf->global->MAIN_METEO_LEVEL1)) $level1=$conf->global->MAIN_METEO_LEVEL1;
285 $level2=$offset+2*$cursor; if (! empty($conf->global->MAIN_METEO_LEVEL2)) $level2=$conf->global->MAIN_METEO_LEVEL2;
286 $level3=$offset+3*$cursor; if (! empty($conf->global->MAIN_METEO_LEVEL3)) $level3=$conf->global->MAIN_METEO_LEVEL3;
287 $text=''; $options='class="valignmiddle" height="60px"';
288 
289 
290 if ($action == 'edit') {
291 
292 
293  print '<div id="standard" '.(empty($conf->global->MAIN_USE_METEO_WITH_PERCENTAGE) ? '' : 'style="display:none;"').'>';
294 
295  print '<div>';
296  print '<div class="inline-block" style="padding-right: 20px">';
297  print img_weather($text,'weather-clear.png', $options);
298  print '= <input type="text" size="2" name="MAIN_METEO_LEVEL0" value="'.$level0.'"/></td>';
299  print '</div><div class="inline-block" style="padding-right: 20px">';
300  print img_weather($text,'weather-few-clouds.png',$options);
301  print '&lt;= <input type="text" size="2" name="MAIN_METEO_LEVEL1" value="'.$level1.'"/></td>';
302  print '</div><div class="inline-block" style="padding-right: 20px">';
303  print img_weather($text,'weather-clouds.png',$options);
304  print '&lt;= <input type="text" size="2" name="MAIN_METEO_LEVEL2" value="'.$level2.'"/></td>';
305  print '</div><div class="inline-block" style="padding-right: 20px">';
306  print img_weather($text,'weather-many-clouds.png',$options);
307  print '&lt;= <input type="text" size="2" name="MAIN_METEO_LEVEL3" value="'.$level3.'"/></td>';
308  print '</div>';
309  print '</div>';
310 
311  print '</div>';
312 
313  print '<div id="percentage" '.(empty($conf->global->MAIN_USE_METEO_WITH_PERCENTAGE) ? 'style="display:none;"' : '').'>';
314 
315  print '<div>';
316  print '<div class="inline-block" style="padding-right: 20px">';
317  print img_weather($text,'weather-clear.png',$options);
318  print '= <input type="text" size="2" name="MAIN_METEO_PERCENTAGE_LEVEL0" value="'.$conf->global->MAIN_METEO_PERCENTAGE_LEVEL0.'"/>&nbsp;%</td>';
319  print '</div><div class="inline-block" style="padding-right: 20px">';
320  print img_weather($text,'weather-few-clouds.png',$options);
321  print '&lt;= <input type="text" size="2" name="MAIN_METEO_PERCENTAGE_LEVEL1" value="'.$conf->global->MAIN_METEO_PERCENTAGE_LEVEL1.'"/>&nbsp;%</td>';
322  print '</div><div class="inline-block" style="padding-right: 20px">';
323  print img_weather($text,'weather-clouds.png',$options);
324  print '&lt;= <input type="text" size="2" name="MAIN_METEO_PERCENTAGE_LEVEL2" value="'.$conf->global->MAIN_METEO_PERCENTAGE_LEVEL2.'"/>&nbsp;%</td>';
325  print '</div><div class="inline-block" style="padding-right: 20px">';
326  print img_weather($text,'weather-many-clouds.png',$options);
327  print '&lt;= <input type="text" size="2" name="MAIN_METEO_PERCENTAGE_LEVEL3" value="'.$conf->global->MAIN_METEO_PERCENTAGE_LEVEL3.'"/>&nbsp;%</td>';
328  print '</div>';
329  print '</div>';
330 
331  print '</div>';
332 
333  ?>
334 
335  <script type="text/javascript">
336 
337  $(document).ready(function() {
338 
339  $("#change_mode").click(function() {
340  var use_percent = $("#MAIN_USE_METEO_WITH_PERCENTAGE");
341  var str_mode_std = "<?php print $str_mode_std; ?>";
342  var str_mode_percentage = "<?php print $str_mode_percentage; ?>";
343 
344  if(use_percent.val() == 1) {
345  use_percent.val(0);
346  $("#standard").show();
347  $("#percentage").hide();
348  $(this).html(str_mode_std);
349  } else {
350  use_percent.val(1);
351  $("#standard").hide();
352  $("#percentage").show();
353  $(this).html(str_mode_percentage);
354  }
355  });
356 
357  });
358 
359  </script>
360 
361  <?php
362 } else {
363 
364  if(!empty($conf->global->MAIN_USE_METEO_WITH_PERCENTAGE)) {
365 
366  print '<div>';
367  print '<div class="inline-block" style="padding-right: 20px">';
368  print img_weather($text,'weather-clear.png',$options);
369  print '= '.$conf->global->MAIN_METEO_PERCENTAGE_LEVEL0.'&nbsp;%</td>';
370  print '</div><div class="inline-block" style="padding-right: 20px">';
371  print img_weather($text,'weather-few-clouds.png',$options);
372  print '&lt;= '.$conf->global->MAIN_METEO_PERCENTAGE_LEVEL1.'&nbsp;%</td>';
373  print '</div><div class="inline-block" style="padding-right: 20px">';
374  print img_weather($text,'weather-clouds.png',$options);
375  print '&lt;= '.$conf->global->MAIN_METEO_PERCENTAGE_LEVEL2.'&nbsp;%</td>';
376  print '</div><div class="inline-block" style="padding-right: 20px">';
377  print img_weather($text,'weather-many-clouds.png',$options);
378  print '&lt;= '.$conf->global->MAIN_METEO_PERCENTAGE_LEVEL3.'&nbsp;%</td>';
379  print '</div><div class="inline-block" style="padding-right: 20px">';
380  print img_weather($text,'weather-storm.png',$options);
381  print '&gt; '.$conf->global->MAIN_METEO_PERCENTAGE_LEVEL3.'&nbsp;%</td>';
382  print '</div>';
383  print '</div>';
384  } else {
385 
386  print '<div>';
387  print '<div class="inline-block" style="padding-right: 20px">';
388  print img_weather($text,'weather-clear.png',$options);
389  print '= '.$level0;
390  print '</div><div class="inline-block" style="padding-right: 20px">';
391  print img_weather($text,'weather-few-clouds.png',$options);
392  print '&lt;= '.$level1;
393  print '</div><div class="inline-block" style="padding-right: 20px">';
394  print img_weather($text,'weather-clouds.png',$options);
395  print '&lt;= '.$level2;
396  print '</div><div class="inline-block" style="padding-right: 20px">';
397  print img_weather($text,'weather-many-clouds.png',$options);
398  print '&lt;= '.$level3;
399  print '</div><div class="inline-block" style="padding-right: 20px">';
400  print img_weather($text,'weather-storm.png',$options);
401  print '&gt; '.$level3;
402  print '</div>';
403  print '</div>';
404  }
405 }
406 
407 print '</div>';
408 
409 if($action == 'edit') {
410 
411  print '<br><div class="center"><input type="submit" class="button" value="'.$langs->trans("Save").'"></div>';
412  print '<br></form>';
413 } else {
414 
415  // Boutons d'action
416  print '<br><div class="tabsAction">';
417  print '<a class="butAction" href="delais.php?action=edit">'.$langs->trans("Modify").'</a></div>';
418 }
419 
420 // End of page
421 llxFooter();
422 $db->close();
img_warning($titlealt='default', $moreatt='')
Show warning logo.
llxFooter()
Empty footer.
Definition: wrapper.php:56
load_fiche_titre($titre, $morehtmlright='', $picto='title_generic.png', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
GETPOST($paramname, $check='none', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
print
Draft customers invoices.
Definition: index.php:91
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:510
img_weather($titlealt, $picto, $moreatt='', $pictoisfullpath=0)
Show weather picto.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0)
Show a message to say access is forbidden and stop program Calling this function terminate execution ...
Class to manage generation of HTML components Only common components must be here.
type
Definition: viewcat.php:284
llxHeader()
Empty header.
Definition: wrapper.php:44