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 22/** 23 * \file htdocs/admin/delais.php 24 * \brief Page to setup late delays 25 */ 26 27require '../main.inc.php'; 28require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; 29 30// Load translation files required by the page 31$langs->load("admin"); 32 33if (!$user->admin) accessforbidden(); 34 35$action = GETPOST('action', 'aZ09'); 36if (empty($action)) $action = 'edit'; 37 38// Define list of managed delays 39$modules = array( 40 'agenda' => array( 41 array( 42 'code' => 'MAIN_DELAY_ACTIONS_TODO', 43 'img' => 'action' 44 ) 45 ), 46 'projet' => array( 47 array( 48 'code' => 'MAIN_DELAY_PROJECT_TO_CLOSE', 49 'img' => 'project' 50 ), 51 array( 52 'code' => 'MAIN_DELAY_TASKS_TODO', 53 'img' => 'projecttask' 54 ) 55 ), 56 'propal' => array( 57 array( 58 'code' => 'MAIN_DELAY_PROPALS_TO_CLOSE', 59 'img' => 'propal' 60 ), 61 array( 62 'code' => 'MAIN_DELAY_PROPALS_TO_BILL', 63 'img' => 'propal' 64 ) 65 ), 66 'commande' => array( 67 array( 68 'code' => 'MAIN_DELAY_ORDERS_TO_PROCESS', 69 'img' => 'order' 70 ) 71 ), 72 'facture' => array( 73 array( 74 'code' => 'MAIN_DELAY_CUSTOMER_BILLS_UNPAYED', 75 'img' => 'bill' 76 ) 77 ), 78 'fournisseur' => array( 79 array( 80 'code' => 'MAIN_DELAY_SUPPLIER_ORDERS_TO_PROCESS', 81 'img' => 'order' 82 ), 83 array( 84 'code' => 'MAIN_DELAY_SUPPLIER_BILLS_TO_PAY', 85 'img' => 'bill' 86 ) 87 ), 88 'service' => array( 89 array( 90 'code' => 'MAIN_DELAY_NOT_ACTIVATED_SERVICES', 91 'img' => 'service' 92 ), 93 array( 94 'code' => 'MAIN_DELAY_RUNNING_SERVICES', 95 'img' => 'service' 96 ) 97 ), 98 'banque' => array( 99 array( 100 'code' => 'MAIN_DELAY_TRANSACTIONS_TO_CONCILIATE', 101 'img' => 'account' 102 ), 103 array( 104 'code' => 'MAIN_DELAY_CHEQUES_TO_DEPOSIT', 105 'img' => 'account' 106 ) 107 ), 108 'adherent' => array( 109 array( 110 'code' => 'MAIN_DELAY_MEMBERS', 111 'img' => 'user' 112 ) 113 ), 114 'expensereport' => array( 115 array( 116 'code' => 'MAIN_DELAY_EXPENSEREPORTS', 117 'img' => 'trip' 118 ), 119 /* TODO Enable this 120 array( 121 'code' => 'MAIN_DELAY_EXPENSEREPORTS_TO_PAY', 122 'img' => 'trip' 123 )*/ 124 ), 125 'holiday' => array( 126 array( 127 'code' => 'MAIN_DELAY_HOLIDAYS', 128 'img' => 'holiday' 129 ), 130 ), 131); 132 133$labelmeteo = array(0=>$langs->trans("No"), 1=>$langs->trans("Yes"), 2=>$langs->trans("OnMobileOnly")); 134 135if (!isset($conf->global->MAIN_DELAY_PROJECT_TO_CLOSE)) { 136 $conf->global->MAIN_DELAY_PROJECT_TO_CLOSE = 7; // Must be same value than into conf.class.php 137} 138if (!isset($conf->global->MAIN_DELAY_TASKS_TODO)) { 139 $conf->global->MAIN_DELAY_TASKS_TODO = 7; // Must be same value than into conf.class.php 140} 141if (!isset($conf->global->MAIN_DELAY_MEMBERS)) { 142 $conf->global->MAIN_DELAY_MEMBERS = 0; // Must be same value than into conf.class.php 143} 144if (!isset($conf->global->MAIN_DELAY_ACTIONS_TODO)) { 145 $conf->global->MAIN_DELAY_ACTIONS_TODO = 7; // Must be same value than into conf.class.php 146} 147if (!isset($conf->global->MAIN_DELAY_ORDERS_TO_PROCESS)) { 148 $conf->global->MAIN_DELAY_ORDERS_TO_PROCESS = 2; 149} 150if (!isset($conf->global->MAIN_DELAY_SUPPLIER_ORDERS_TO_PROCESS)) { 151 $conf->global->MAIN_DELAY_SUPPLIER_ORDERS_TO_PROCESS = 7; 152} 153if (!isset($conf->global->MAIN_DELAY_ORDERS_TO_PROCESS)) { 154 $conf->global->MAIN_DELAY_ORDERS_TO_PROCESS = 2; 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_ORDERS_TO_PROCESS)) { 160 $conf->global->MAIN_DELAY_ORDERS_TO_PROCESS = 2; 161} 162 163 164 165/* 166 * Actions 167 */ 168 169if ($action == 'update') 170{ 171 foreach ($modules as $module => $delays) 172 { 173 if (!empty($conf->$module->enabled)) 174 { 175 foreach ($delays as $delay) 176 { 177 if (GETPOST($delay['code']) != '') 178 { 179 dolibarr_set_const($db, $delay['code'], GETPOST($delay['code']), 'chaine', 0, '', $conf->entity); 180 } 181 } 182 } 183 } 184 185 dolibarr_set_const($db, "MAIN_DISABLE_METEO", $_POST["MAIN_DISABLE_METEO"], 'chaine', 0, '', $conf->entity); 186 dolibarr_set_const($db, "MAIN_USE_METEO_WITH_PERCENTAGE", GETPOST("MAIN_USE_METEO_WITH_PERCENTAGE"), 'chaine', 0, '', $conf->entity); 187 188 // For update value with percentage 189 $plus = ''; 190 if (!empty($conf->global->MAIN_USE_METEO_WITH_PERCENTAGE)) $plus = '_PERCENTAGE'; 191 // Update values 192 for ($i = 0; $i < 4; $i++) { 193 if (GETPOSTISSET('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); 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(); 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"; 215 216if ($action == 'edit') 217{ 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><td class="center" width="120px">'.$langs->trans("Value").'</td></tr>'; 224 225 foreach ($modules as $module => $delays) 226 { 227 if (!empty($conf->$module->enabled)) 228 { 229 foreach ($delays as $delay) 230 { 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">'; 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("Parameter").'</td><td class="center" width="120px">'.$langs->trans("Value").'</td></tr>'; 247 248 print '<tr class="oddeven">'; 249 print '<td>'.$langs->trans("MAIN_DISABLE_METEO").'</td><td class="center">'; 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="center" width="120px">'.$langs->trans("Value").'</td></tr>'; 261 262 foreach ($modules as $module => $delays) 263 { 264 if (!empty($conf->$module->enabled)) 265 { 266 foreach ($delays as $delay) 267 { 268 $value = (!empty($conf->global->{$delay['code']}) ? $conf->global->{$delay['code']}:0); 269 print '<tr class="oddeven">'; 270 print '<td width="20px">'.img_object('', $delay['img']).'</td>'; 271 print '<td>'.$langs->trans('Delays_'.$delay['code']).'</td>'; 272 print '<td class="right">'.$value.' '.$langs->trans("days").'</td></tr>'; 273 } 274 } 275 } 276 277 print '</table>'; 278 279 print '<br>'; 280 281 // Show if meteo is enabled 282 print '<table class="noborder centpercent">'; 283 print '<tr class="liste_titre"><td>'.$langs->trans("Parameter").'</td><td class="center" width="120px">'.$langs->trans("Value").'</td></tr>'; 284 285 print '<tr class="oddeven">'; 286 print '<td>'.$langs->trans("MAIN_DISABLE_METEO").'</td><td class="center">'; 287 print $labelmeteo[$conf->global->MAIN_DISABLE_METEO]; 288 print '</td></tr>'; 289 290 print '</table>'; 291} 292 293print '<br>'; 294 295 296if ($conf->global->MAIN_DISABLE_METEO != 1) { 297 // Show logo for weather 298 print '<span class="opacitymedium">'.$langs->trans("DescWeather").'</span> '; 299 300 if ($action == 'edit') { 301 $str_mode_std = $langs->trans('MeteoStdModEnabled').' : '.$langs->trans('MeteoUseMod', $langs->transnoentitiesnoconv('MeteoPercentageMod')); 302 $str_mode_percentage = $langs->trans('MeteoPercentageModEnabled').' : '.$langs->trans('MeteoUseMod', $langs->transnoentitiesnoconv('MeteoStdMod')); 303 if (empty($conf->global->MAIN_USE_METEO_WITH_PERCENTAGE)) $str_mode_enabled = $str_mode_std; 304 else $str_mode_enabled = $str_mode_percentage; 305 print '<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="'.$conf->global->MAIN_USE_METEO_WITH_PERCENTAGE.'" />'; 307 308 print '<br><br>'; 309 } else { 310 if (empty($conf->global->MAIN_USE_METEO_WITH_PERCENTAGE)) print $langs->trans('MeteoStdModEnabled'); 311 else print $langs->trans('MeteoPercentageModEnabled'); 312 print '<br><br>'; 313 } 314 315 $offset = 0; 316 $cursor = 10; // By default 317 //if (! empty($conf->global->MAIN_METEO_OFFSET)) $offset=$conf->global->MAIN_METEO_OFFSET; 318 //if (! empty($conf->global->MAIN_METEO_GAP)) $cursor=$conf->global->MAIN_METEO_GAP; 319 $level0 = $offset; if (!empty($conf->global->MAIN_METEO_LEVEL0)) $level0 = $conf->global->MAIN_METEO_LEVEL0; 320 $level1 = $offset + 1 * $cursor; if (!empty($conf->global->MAIN_METEO_LEVEL1)) $level1 = $conf->global->MAIN_METEO_LEVEL1; 321 $level2 = $offset + 2 * $cursor; if (!empty($conf->global->MAIN_METEO_LEVEL2)) $level2 = $conf->global->MAIN_METEO_LEVEL2; 322 $level3 = $offset + 3 * $cursor; if (!empty($conf->global->MAIN_METEO_LEVEL3)) $level3 = $conf->global->MAIN_METEO_LEVEL3; 323 $text = ''; $options = 'class="valignmiddle" height="60px"'; 324 325 326 if ($action == 'edit') { 327 print '<div id="standard" '.(empty($conf->global->MAIN_USE_METEO_WITH_PERCENTAGE) ? '' : 'style="display:none;"').'>'; 328 329 print '<div>'; 330 print '<div class="inline-block" style="padding-right: 20px">'; 331 print img_weather($text, 0, $options); 332 print ' <= <input type="text" size="2" name="MAIN_METEO_LEVEL0" value="'.$level0.'"/></td>'; 333 print '</div><div class="inline-block" style="padding-right: 20px">'; 334 print img_weather($text, 1, $options); 335 print ' <= <input type="text" size="2" name="MAIN_METEO_LEVEL1" value="'.$level1.'"/></td>'; 336 print '</div><div class="inline-block" style="padding-right: 20px">'; 337 print img_weather($text, 2, $options); 338 print ' <= <input type="text" size="2" name="MAIN_METEO_LEVEL2" value="'.$level2.'"/></td>'; 339 print '</div><div class="inline-block" style="padding-right: 20px">'; 340 print img_weather($text, 3, $options); 341 print ' <= <input type="text" size="2" name="MAIN_METEO_LEVEL3" value="'.$level3.'"/></td>'; 342 print '</div>'; 343 print '</div>'; 344 345 print '</div>'; 346 347 print '<div id="percentage" '.(empty($conf->global->MAIN_USE_METEO_WITH_PERCENTAGE) ? 'style="display:none;"' : '').'>'; 348 349 print '<div>'; 350 print '<div class="inline-block" style="padding-right: 20px">'; 351 print img_weather($text, 0, $options); 352 print ' <= <input type="text" size="2" name="MAIN_METEO_PERCENTAGE_LEVEL0" value="'.$conf->global->MAIN_METEO_PERCENTAGE_LEVEL0.'"/> %</td>'; 353 print '</div><div class="inline-block" style="padding-right: 20px">'; 354 print img_weather($text, 1, $options); 355 print ' <= <input type="text" size="2" name="MAIN_METEO_PERCENTAGE_LEVEL1" value="'.$conf->global->MAIN_METEO_PERCENTAGE_LEVEL1.'"/> %</td>'; 356 print '</div><div class="inline-block" style="padding-right: 20px">'; 357 print img_weather($text, 2, $options); 358 print ' <= <input type="text" size="2" name="MAIN_METEO_PERCENTAGE_LEVEL2" value="'.$conf->global->MAIN_METEO_PERCENTAGE_LEVEL2.'"/> %</td>'; 359 print '</div><div class="inline-block" style="padding-right: 20px">'; 360 print img_weather($text, 3, $options); 361 print ' <= <input type="text" size="2" name="MAIN_METEO_PERCENTAGE_LEVEL3" value="'.$conf->global->MAIN_METEO_PERCENTAGE_LEVEL3.'"/> %</td>'; 362 print '</div>'; 363 print '</div>'; 364 365 print '</div>'; 366 367 ?> 368 369 <script type="text/javascript"> 370 371 $(document).ready(function() { 372 373 $("#change_mode").click(function() { 374 var use_percent = $("#MAIN_USE_METEO_WITH_PERCENTAGE"); 375 var str_mode_std = "<?php print $str_mode_std; ?>"; 376 var str_mode_percentage = "<?php print $str_mode_percentage; ?>"; 377 378 if(use_percent.val() == 1) { 379 use_percent.val(0); 380 $("#standard").show(); 381 $("#percentage").hide(); 382 $(this).html(str_mode_std); 383 } else { 384 use_percent.val(1); 385 $("#standard").hide(); 386 $("#percentage").show(); 387 $(this).html(str_mode_percentage); 388 } 389 }); 390 391 }); 392 393 </script> 394 395 <?php 396 } else { 397 if (!empty($conf->global->MAIN_USE_METEO_WITH_PERCENTAGE)) { 398 print '<div>'; 399 print '<div class="inline-block" style="padding-right: 20px">'; 400 print img_weather($text, 0, $options); 401 print ' <= '.$conf->global->MAIN_METEO_PERCENTAGE_LEVEL0.' %</td>'; 402 print '</div><div class="inline-block" style="padding-right: 20px">'; 403 print img_weather($text, 1, $options); 404 print ' <= '.$conf->global->MAIN_METEO_PERCENTAGE_LEVEL1.' %</td>'; 405 print '</div><div class="inline-block" style="padding-right: 20px">'; 406 print img_weather($text, 2, $options); 407 print ' <= '.$conf->global->MAIN_METEO_PERCENTAGE_LEVEL2.' %</td>'; 408 print '</div><div class="inline-block" style="padding-right: 20px">'; 409 print img_weather($text, 3, $options); 410 print ' <= '.$conf->global->MAIN_METEO_PERCENTAGE_LEVEL3.' %</td>'; 411 print '</div><div class="inline-block" style="padding-right: 20px">'; 412 print img_weather($text, 4, $options); 413 print ' > '.$conf->global->MAIN_METEO_PERCENTAGE_LEVEL3.' %</td>'; 414 print '</div>'; 415 print '</div>'; 416 } else { 417 print '<div>'; 418 print '<div class="inline-block" style="padding-right: 20px">'; 419 print img_weather($text, 0, $options); 420 print ' <= '.$level0; 421 print '</div><div class="inline-block" style="padding-right: 20px">'; 422 print img_weather($text, 1, $options); 423 print ' <= '.$level1; 424 print '</div><div class="inline-block" style="padding-right: 20px">'; 425 print img_weather($text, 2, $options); 426 print ' <= '.$level2; 427 print '</div><div class="inline-block" style="padding-right: 20px">'; 428 print img_weather($text, 3, $options); 429 print ' <= '.$level3; 430 print '</div><div class="inline-block" style="padding-right: 20px">'; 431 print img_weather($text, 4, $options); 432 print ' > '.$level3; 433 print '</div>'; 434 print '</div>'; 435 } 436 } 437} 438 439 440if ($action == 'edit') { 441 print '<br><div class="center"><input type="submit" class="button button-save" value="'.$langs->trans("Save").'"></div>'; 442 print '<br></form>'; 443} else { 444 print '<br><div class="tabsAction">'; 445 print '<a class="butAction" href="delais.php?action=edit">'.$langs->trans("Modify").'</a></div>'; 446} 447 448// End of page 449llxFooter(); 450$db->close(); 451