delais.php 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462
  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. * \file htdocs/admin/delais.php
  23. * \brief Page to setup late delays
  24. */
  25. require '../main.inc.php';
  26. require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
  27. // Load translation files required by the page
  28. $langs->load("admin");
  29. if (!$user->admin) {
  30. accessforbidden();
  31. }
  32. $action = GETPOST('action', 'aZ09');
  33. if (empty($action)) {
  34. $action = 'edit';
  35. }
  36. // Define list of managed delays
  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' => 'projecttask'
  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. 'holiday' => array(
  124. array(
  125. 'code' => 'MAIN_DELAY_HOLIDAYS',
  126. 'img' => 'holiday'
  127. ),
  128. ),
  129. );
  130. $labelmeteo = array(0=>$langs->trans("No"), 1=>$langs->trans("Yes"), 2=>$langs->trans("OnMobileOnly"));
  131. if (!isset($conf->global->MAIN_DELAY_PROJECT_TO_CLOSE)) {
  132. $conf->global->MAIN_DELAY_PROJECT_TO_CLOSE = 7; // Must be same value than into conf.class.php
  133. }
  134. if (!isset($conf->global->MAIN_DELAY_TASKS_TODO)) {
  135. $conf->global->MAIN_DELAY_TASKS_TODO = 7; // Must be same value than into conf.class.php
  136. }
  137. if (!isset($conf->global->MAIN_DELAY_MEMBERS)) {
  138. $conf->global->MAIN_DELAY_MEMBERS = 0; // Must be same value than into conf.class.php
  139. }
  140. if (!isset($conf->global->MAIN_DELAY_ACTIONS_TODO)) {
  141. $conf->global->MAIN_DELAY_ACTIONS_TODO = 7; // Must be same value than into conf.class.php
  142. }
  143. if (!isset($conf->global->MAIN_DELAY_ORDERS_TO_PROCESS)) {
  144. $conf->global->MAIN_DELAY_ORDERS_TO_PROCESS = 2;
  145. }
  146. if (!isset($conf->global->MAIN_DELAY_SUPPLIER_ORDERS_TO_PROCESS)) {
  147. $conf->global->MAIN_DELAY_SUPPLIER_ORDERS_TO_PROCESS = 7;
  148. }
  149. if (!isset($conf->global->MAIN_DELAY_ORDERS_TO_PROCESS)) {
  150. $conf->global->MAIN_DELAY_ORDERS_TO_PROCESS = 2;
  151. }
  152. if (!isset($conf->global->MAIN_DELAY_ORDERS_TO_PROCESS)) {
  153. $conf->global->MAIN_DELAY_ORDERS_TO_PROCESS = 2;
  154. }
  155. if (!isset($conf->global->MAIN_DELAY_ORDERS_TO_PROCESS)) {
  156. $conf->global->MAIN_DELAY_ORDERS_TO_PROCESS = 2;
  157. }
  158. /*
  159. * Actions
  160. */
  161. if ($action == 'update') {
  162. foreach ($modules as $module => $delays) {
  163. if (!empty($conf->$module->enabled)) {
  164. foreach ($delays as $delay) {
  165. if (GETPOST($delay['code']) != '') {
  166. dolibarr_set_const($db, $delay['code'], GETPOST($delay['code']), 'chaine', 0, '', $conf->entity);
  167. }
  168. }
  169. }
  170. }
  171. dolibarr_set_const($db, "MAIN_DISABLE_METEO", GETPOST("MAIN_DISABLE_METEO"), 'chaine', 0, '', $conf->entity);
  172. dolibarr_set_const($db, "MAIN_USE_METEO_WITH_PERCENTAGE", GETPOST("MAIN_USE_METEO_WITH_PERCENTAGE"), 'chaine', 0, '', $conf->entity);
  173. // For update value with percentage
  174. $plus = '';
  175. if (!empty($conf->global->MAIN_USE_METEO_WITH_PERCENTAGE)) {
  176. $plus = '_PERCENTAGE';
  177. }
  178. // Update values
  179. for ($i = 0; $i < 4; $i++) {
  180. if (GETPOSTISSET('MAIN_METEO'.$plus.'_LEVEL'.$i)) {
  181. dolibarr_set_const($db, 'MAIN_METEO'.$plus.'_LEVEL'.$i, GETPOST('MAIN_METEO'.$plus.'_LEVEL'.$i, 'int'), 'chaine', 0, '', $conf->entity);
  182. }
  183. }
  184. setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
  185. $action = 'edit';
  186. }
  187. /*
  188. * View
  189. */
  190. $form = new Form($db);
  191. llxHeader();
  192. print load_fiche_titre($langs->trans("DelaysOfToleranceBeforeWarning"), '', 'title_setup');
  193. print '<span class="opacitymedium">'.$langs->transnoentities("DelaysOfToleranceDesc", img_warning('default', '', 'pictowarning nopaddingleft'));
  194. print " ".$langs->trans("OnlyActiveElementsAreShown", DOL_URL_ROOT.'/admin/modules.php')."</span><br>\n";
  195. print "<br>\n";
  196. if ($action == 'edit') {
  197. print '<form method="post" action="'.$_SERVER['PHP_SELF'].'" name="form_index">';
  198. print '<input type="hidden" name="token" value="'.newToken().'">';
  199. print '<input type="hidden" name="action" value="update">';
  200. print '<table class="noborder centpercent">';
  201. print '<tr class="liste_titre"><td colspan="2">'.$langs->trans("DelaysOfToleranceBeforeWarning").'</td>';
  202. print '<td class="right">'.$langs->trans("LateWarningAfter").'</td></tr>';
  203. foreach ($modules as $module => $delays) {
  204. if (!empty($conf->$module->enabled)) {
  205. foreach ($delays as $delay) {
  206. $value = (!empty($conf->global->{$delay['code']}) ? $conf->global->{$delay['code']}:0);
  207. print '<tr class="oddeven">';
  208. print '<td width="20px">'.img_object('', $delay['img']).'</td>';
  209. print '<td>'.$langs->trans('Delays_'.$delay['code']).'</td><td class="nowraponall right">';
  210. print '<input class="right maxwidth75" type="number" name="'.$delay['code'].'" value="'.$value.'"> '.$langs->trans("days").'</td></tr>';
  211. }
  212. }
  213. }
  214. print '</table>';
  215. print '<br>';
  216. // Show if meteo is enabled
  217. print '<table class="noborder centpercent">';
  218. print '<tr class="liste_titre"><td>'.$langs->trans("Option").'</td><td class="right">'.$langs->trans("Value").'</td></tr>';
  219. print '<tr class="oddeven">';
  220. print '<td>'.$langs->trans("MAIN_DISABLE_METEO").'</td><td class="right">';
  221. print $form->selectarray('MAIN_DISABLE_METEO', $labelmeteo, (empty($conf->global->MAIN_DISABLE_METEO) ? 0 : $conf->global->MAIN_DISABLE_METEO));
  222. print '</td></tr>';
  223. print '</table>';
  224. } else {
  225. /*
  226. * Show parameters
  227. */
  228. print '<table class="noborder centpercent">';
  229. print '<tr class="liste_titre"><td colspan="2">'.$langs->trans("DelaysOfToleranceBeforeWarning").'</td><td class="right">'.$langs->trans("Value").'</td></tr>';
  230. foreach ($modules as $module => $delays) {
  231. if (!empty($conf->$module->enabled)) {
  232. foreach ($delays as $delay) {
  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. print '</table>';
  242. print '<br>';
  243. // Show if meteo is enabled
  244. print '<table class="noborder centpercent">';
  245. print '<tr class="liste_titre"><td>'.$langs->trans("Option").'</td><td class="right">'.$langs->trans("Value").'</td></tr>';
  246. print '<tr class="oddeven">';
  247. print '<td>'.$langs->trans("MAIN_DISABLE_METEO").'</td><td class="center">';
  248. print $labelmeteo[$conf->global->MAIN_DISABLE_METEO];
  249. print '</td></tr>';
  250. print '</table>';
  251. }
  252. print '<br>';
  253. if (empty($conf->global->MAIN_DISABLE_METEO) || $conf->global->MAIN_DISABLE_METEO != 1) {
  254. // Show logo for weather
  255. print '<span class="opacitymedium">'.$langs->trans("DescWeather").'</span> ';
  256. if ($action == 'edit') {
  257. $str_mode_std = $langs->trans('MeteoStdModEnabled').' : '.$langs->trans('MeteoUseMod', $langs->transnoentitiesnoconv('MeteoPercentageMod'));
  258. $str_mode_percentage = $langs->trans('MeteoPercentageModEnabled').' : '.$langs->trans('MeteoUseMod', $langs->transnoentitiesnoconv('MeteoStdMod'));
  259. if (empty($conf->global->MAIN_USE_METEO_WITH_PERCENTAGE)) {
  260. $str_mode_enabled = $str_mode_std;
  261. } else {
  262. $str_mode_enabled = $str_mode_percentage;
  263. }
  264. print '<br><a href="#" onclick="return false;" id="change_mode">'.$str_mode_enabled.'</a>';
  265. print '<input type="hidden" id="MAIN_USE_METEO_WITH_PERCENTAGE" name="MAIN_USE_METEO_WITH_PERCENTAGE" value="'.(!empty($conf->global->MAIN_USE_METEO_WITH_PERCENTAGE) ? $conf->global->MAIN_USE_METEO_WITH_PERCENTAGE : '').'" />';
  266. print '<br><br>';
  267. } else {
  268. if (empty($conf->global->MAIN_USE_METEO_WITH_PERCENTAGE)) {
  269. print $langs->trans('MeteoStdModEnabled');
  270. } else {
  271. print $langs->trans('MeteoPercentageModEnabled');
  272. }
  273. print '<br><br>';
  274. }
  275. $offset = 0;
  276. $cursor = 10; // By default
  277. //if (! empty($conf->global->MAIN_METEO_OFFSET)) $offset=$conf->global->MAIN_METEO_OFFSET;
  278. //if (! empty($conf->global->MAIN_METEO_GAP)) $cursor=$conf->global->MAIN_METEO_GAP;
  279. $level0 = $offset; if (!empty($conf->global->MAIN_METEO_LEVEL0)) {
  280. $level0 = $conf->global->MAIN_METEO_LEVEL0;
  281. }
  282. $level1 = $offset + 1 * $cursor; if (!empty($conf->global->MAIN_METEO_LEVEL1)) {
  283. $level1 = $conf->global->MAIN_METEO_LEVEL1;
  284. }
  285. $level2 = $offset + 2 * $cursor; if (!empty($conf->global->MAIN_METEO_LEVEL2)) {
  286. $level2 = $conf->global->MAIN_METEO_LEVEL2;
  287. }
  288. $level3 = $offset + 3 * $cursor; if (!empty($conf->global->MAIN_METEO_LEVEL3)) {
  289. $level3 = $conf->global->MAIN_METEO_LEVEL3;
  290. }
  291. $text = ''; $options = 'class="valignmiddle" height="60px"';
  292. if ($action == 'edit') {
  293. print '<div id="standard" '.(empty($conf->global->MAIN_USE_METEO_WITH_PERCENTAGE) ? '' : 'style="display:none;"').'>';
  294. print '<div>';
  295. print '<div class="inline-block" style="padding-right: 20px">';
  296. print img_weather($text, 0, $options);
  297. print ' &lt;= <input type="text" size="2" name="MAIN_METEO_LEVEL0" value="'.$level0.'"/></td>';
  298. print '</div><div class="inline-block" style="padding-right: 20px">';
  299. print img_weather($text, 1, $options);
  300. print ' &lt;= <input type="text" size="2" name="MAIN_METEO_LEVEL1" value="'.$level1.'"/></td>';
  301. print '</div><div class="inline-block" style="padding-right: 20px">';
  302. print img_weather($text, 2, $options);
  303. print ' &lt;= <input type="text" size="2" name="MAIN_METEO_LEVEL2" value="'.$level2.'"/></td>';
  304. print '</div><div class="inline-block" style="padding-right: 20px">';
  305. print img_weather($text, 3, $options);
  306. print ' &lt;= <input type="text" size="2" name="MAIN_METEO_LEVEL3" value="'.$level3.'"/></td>';
  307. print '</div>';
  308. print '</div>';
  309. print '</div>';
  310. print '<div id="percentage" '.(empty($conf->global->MAIN_USE_METEO_WITH_PERCENTAGE) ? 'style="display:none;"' : '').'>';
  311. print '<div>';
  312. print '<div class="inline-block" style="padding-right: 20px">';
  313. print img_weather($text, 0, $options);
  314. print ' &lt;= <input type="text" size="2" name="MAIN_METEO_PERCENTAGE_LEVEL0" value="'.getDolGlobalString('MAIN_METEO_PERCENTAGE_LEVEL0').'"/>&nbsp;%</td>';
  315. print '</div><div class="inline-block" style="padding-right: 20px">';
  316. print img_weather($text, 1, $options);
  317. print ' &lt;= <input type="text" size="2" name="MAIN_METEO_PERCENTAGE_LEVEL1" value="'.getDolGlobalString('MAIN_METEO_PERCENTAGE_LEVEL1').'"/>&nbsp;%</td>';
  318. print '</div><div class="inline-block" style="padding-right: 20px">';
  319. print img_weather($text, 2, $options);
  320. print ' &lt;= <input type="text" size="2" name="MAIN_METEO_PERCENTAGE_LEVEL2" value="'.getDolGlobalString('MAIN_METEO_PERCENTAGE_LEVEL2').'"/>&nbsp;%</td>';
  321. print '</div><div class="inline-block" style="padding-right: 20px">';
  322. print img_weather($text, 3, $options);
  323. print ' &lt;= <input type="text" size="2" name="MAIN_METEO_PERCENTAGE_LEVEL3" value="'.getDolGlobalString('MAIN_METEO_PERCENTAGE_LEVEL3').'"/>&nbsp;%</td>';
  324. print '</div>';
  325. print '</div>';
  326. print '</div>';
  327. ?>
  328. <script type="text/javascript">
  329. $(document).ready(function() {
  330. $("#change_mode").click(function() {
  331. var use_percent = $("#MAIN_USE_METEO_WITH_PERCENTAGE");
  332. var str_mode_std = "<?php print $str_mode_std; ?>";
  333. var str_mode_percentage = "<?php print $str_mode_percentage; ?>";
  334. if(use_percent.val() == 1) {
  335. use_percent.val(0);
  336. $("#standard").show();
  337. $("#percentage").hide();
  338. $(this).html(str_mode_std);
  339. } else {
  340. use_percent.val(1);
  341. $("#standard").hide();
  342. $("#percentage").show();
  343. $(this).html(str_mode_percentage);
  344. }
  345. });
  346. });
  347. </script>
  348. <?php
  349. } else {
  350. if (!empty($conf->global->MAIN_USE_METEO_WITH_PERCENTAGE)) {
  351. print '<div>';
  352. print '<div class="inline-block" style="padding-right: 20px">';
  353. print img_weather($text, 0, $options);
  354. print ' &lt;= '.$conf->global->MAIN_METEO_PERCENTAGE_LEVEL0.'&nbsp;%</td>';
  355. print '</div><div class="inline-block" style="padding-right: 20px">';
  356. print img_weather($text, 1, $options);
  357. print ' &lt;= '.$conf->global->MAIN_METEO_PERCENTAGE_LEVEL1.'&nbsp;%</td>';
  358. print '</div><div class="inline-block" style="padding-right: 20px">';
  359. print img_weather($text, 2, $options);
  360. print ' &lt;= '.$conf->global->MAIN_METEO_PERCENTAGE_LEVEL2.'&nbsp;%</td>';
  361. print '</div><div class="inline-block" style="padding-right: 20px">';
  362. print img_weather($text, 3, $options);
  363. print ' &lt;= '.$conf->global->MAIN_METEO_PERCENTAGE_LEVEL3.'&nbsp;%</td>';
  364. print '</div><div class="inline-block" style="padding-right: 20px">';
  365. print img_weather($text, 4, $options);
  366. print ' &gt; '.$conf->global->MAIN_METEO_PERCENTAGE_LEVEL3.'&nbsp;%</td>';
  367. print '</div>';
  368. print '</div>';
  369. } else {
  370. print '<div>';
  371. print '<div class="inline-block" style="padding-right: 20px">';
  372. print img_weather($text, 0, $options);
  373. print ' &lt;= '.$level0;
  374. print '</div><div class="inline-block" style="padding-right: 20px">';
  375. print img_weather($text, 1, $options);
  376. print ' &lt;= '.$level1;
  377. print '</div><div class="inline-block" style="padding-right: 20px">';
  378. print img_weather($text, 2, $options);
  379. print ' &lt;= '.$level2;
  380. print '</div><div class="inline-block" style="padding-right: 20px">';
  381. print img_weather($text, 3, $options);
  382. print ' &lt;= '.$level3;
  383. print '</div><div class="inline-block" style="padding-right: 20px">';
  384. print img_weather($text, 4, $options);
  385. print ' &gt; '.$level3;
  386. print '</div>';
  387. print '</div>';
  388. }
  389. }
  390. }
  391. if ($action == 'edit') {
  392. print $form->buttonsSaveCancel("Save", '');
  393. print '</form>';
  394. } else {
  395. print '<br><br><div class="tabsAction">';
  396. print '<a class="butAction" href="delais.php?action=edit&token='.newToken().'">'.$langs->trans("Modify").'</a>';
  397. print '</div>';
  398. }
  399. // End of page
  400. llxFooter();
  401. $db->close();