delais.php 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302
  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@capnetworks.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. /**
  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. $langs->load("admin");
  28. if (! $user->admin) accessforbidden();
  29. $action=GETPOST('action','alpha');
  30. $modules=array(
  31. 'agenda' => array(
  32. array(
  33. 'code' => 'MAIN_DELAY_ACTIONS_TODO',
  34. 'img' => 'action'
  35. )
  36. ),
  37. 'projet' => array(
  38. array(
  39. 'code' => 'MAIN_DELAY_PROJECT_TO_CLOSE',
  40. 'img' => 'project'
  41. ),
  42. array(
  43. 'code' => 'MAIN_DELAY_TASKS_TODO',
  44. 'img' => 'task'
  45. )
  46. ),
  47. 'propal' => array(
  48. array(
  49. 'code' => 'MAIN_DELAY_PROPALS_TO_CLOSE',
  50. 'img' => 'propal'
  51. ),
  52. array(
  53. 'code' => 'MAIN_DELAY_PROPALS_TO_BILL',
  54. 'img' => 'propal'
  55. )
  56. ),
  57. 'commande' => array(
  58. array(
  59. 'code' => 'MAIN_DELAY_ORDERS_TO_PROCESS',
  60. 'img' => 'order'
  61. )
  62. ),
  63. 'facture' => array(
  64. array(
  65. 'code' => 'MAIN_DELAY_CUSTOMER_BILLS_UNPAYED',
  66. 'img' => 'bill'
  67. )
  68. ),
  69. 'fournisseur' => array(
  70. array(
  71. 'code' => 'MAIN_DELAY_SUPPLIER_ORDERS_TO_PROCESS',
  72. 'img' => 'order'
  73. ),
  74. array(
  75. 'code' => 'MAIN_DELAY_SUPPLIER_BILLS_TO_PAY',
  76. 'img' => 'bill'
  77. )
  78. ),
  79. 'service' => array(
  80. array(
  81. 'code' => 'MAIN_DELAY_NOT_ACTIVATED_SERVICES',
  82. 'img' => 'service'
  83. ),
  84. array(
  85. 'code' => 'MAIN_DELAY_RUNNING_SERVICES',
  86. 'img' => 'service'
  87. )
  88. ),
  89. 'banque' => array(
  90. array(
  91. 'code' => 'MAIN_DELAY_TRANSACTIONS_TO_CONCILIATE',
  92. 'img' => 'account'
  93. ),
  94. array(
  95. 'code' => 'MAIN_DELAY_CHEQUES_TO_DEPOSIT',
  96. 'img' => 'account'
  97. )
  98. ),
  99. 'adherent' => array(
  100. array(
  101. 'code' => 'MAIN_DELAY_MEMBERS',
  102. 'img' => 'user'
  103. )
  104. ),
  105. 'expensereport' => array(
  106. array(
  107. 'code' => 'MAIN_DELAY_EXPENSEREPORTS',
  108. 'img' => 'trip'
  109. ),
  110. /* TODO Enable this
  111. array(
  112. 'code' => 'MAIN_DELAY_EXPENSEREPORTS_TO_PAY',
  113. 'img' => 'trip'
  114. )*/
  115. ),
  116. );
  117. if ($action == 'update')
  118. {
  119. foreach($modules as $module => $delays)
  120. {
  121. if (! empty($conf->$module->enabled))
  122. {
  123. foreach($delays as $delay)
  124. {
  125. if (GETPOST($delay['code']) != '')
  126. {
  127. dolibarr_set_const($db, $delay['code'], GETPOST($delay['code']), 'chaine', 0, '', $conf->entity);
  128. }
  129. }
  130. }
  131. }
  132. dolibarr_set_const($db, "MAIN_DISABLE_METEO",$_POST["MAIN_DISABLE_METEO"],'chaine',0,'',$conf->entity);
  133. }
  134. /*
  135. * View
  136. */
  137. $form = new Form($db);
  138. llxHeader();
  139. print load_fiche_titre($langs->trans("DelaysOfToleranceBeforeWarning"),'','title_setup');
  140. print $langs->transnoentities("DelaysOfToleranceDesc",img_warning());
  141. print " ".$langs->trans("OnlyActiveElementsAreShown",DOL_URL_ROOT.'/admin/modules.php')."<br>\n";
  142. print "<br>\n";
  143. $countrynotdefined='<font class="error">'.$langs->trans("ErrorSetACountryFirst").' ('.$langs->trans("SeeAbove").')</font>';
  144. if ($action == 'edit')
  145. {
  146. print '<form method="post" action="'.$_SERVER['PHP_SELF'].'" name="form_index">';
  147. print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
  148. print '<input type="hidden" name="action" value="update">';
  149. $var=true;
  150. print '<table class="noborder" width="100%">';
  151. print '<tr class="liste_titre"><td colspan="2">'.$langs->trans("DelaysOfToleranceBeforeWarning").'</td><td width="120px">'.$langs->trans("Value").'</td></tr>';
  152. foreach($modules as $module => $delays)
  153. {
  154. if (! empty($conf->$module->enabled))
  155. {
  156. foreach($delays as $delay)
  157. {
  158. $value=(! empty($conf->global->{$delay['code']})?$conf->global->{$delay['code']}:0);
  159. print '<tr class="oddeven">';
  160. print '<td width="20px">'.img_object('',$delay['img']).'</td>';
  161. print '<td>'.$langs->trans('Delays_'.$delay['code']).'</td><td>';
  162. print '<input size="5" name="'.$delay['code'].'" value="'.$value.'"> '.$langs->trans("days").'</td></tr>';
  163. }
  164. }
  165. }
  166. print '</table>';
  167. print '<br>';
  168. // Show if meteo is enabled
  169. print '<table class="noborder" width="100%">';
  170. print '<tr class="liste_titre"><td>'.$langs->trans("Parameter").'</td><td width="120px">'.$langs->trans("Value").'</td></tr>';
  171. $var=false;
  172. print '<tr class="oddeven">';
  173. print '<td>'.$langs->trans("MAIN_DISABLE_METEO").'</td><td>' .$form->selectyesno('MAIN_DISABLE_METEO',(empty($conf->global->MAIN_DISABLE_METEO)?0:1),1) . '</td></tr>';
  174. print '</table>';
  175. print '<br>';
  176. print '<br><div class="center"><input type="submit" class="button" value="'.$langs->trans("Save").'"></div>';
  177. print '<br>';
  178. print '</form>';
  179. }
  180. else
  181. {
  182. /*
  183. * Affichage des parametres
  184. */
  185. print '<table class="noborder" width="100%">';
  186. print '<tr class="liste_titre"><td colspan="2">'.$langs->trans("DelaysOfToleranceBeforeWarning").'</td><td width="120px">'.$langs->trans("Value").'</td></tr>';
  187. $var=true;
  188. foreach($modules as $module => $delays)
  189. {
  190. if (! empty($conf->$module->enabled))
  191. {
  192. foreach($delays as $delay)
  193. {
  194. $value=(! empty($conf->global->{$delay['code']})?$conf->global->{$delay['code']}:0);
  195. print '<tr class="oddeven">';
  196. print '<td width="20px">'.img_object('',$delay['img']).'</td>';
  197. print '<td>'.$langs->trans('Delays_'.$delay['code']).'</td>';
  198. print '<td>'.$value.' '.$langs->trans("days").'</td></tr>';
  199. }
  200. }
  201. }
  202. print '</table>';
  203. print '<br>';
  204. // Show if meteo is enabled
  205. print '<table class="noborder" width="100%">';
  206. print '<tr class="liste_titre"><td>'.$langs->trans("Parameter").'</td><td width="120px">'.$langs->trans("Value").'</td></tr>';
  207. $var=false;
  208. print '<tr class="oddeven">';
  209. print '<td>'.$langs->trans("MAIN_DISABLE_METEO").'</td><td>' . yn($conf->global->MAIN_DISABLE_METEO) . '</td></tr>';
  210. print '</table>';
  211. print '<br>';
  212. // Boutons d'action
  213. print '<div class="tabsAction">';
  214. print '<a class="butAction" href="delais.php?action=edit">'.$langs->trans("Modify").'</a>';
  215. print '</div>';
  216. }
  217. print '<br>';
  218. // Show logo for weather
  219. print $langs->trans("DescWeather").'<br>';
  220. $offset=0;
  221. $cursor=10; // By default
  222. //if (! empty($conf->global->MAIN_METEO_OFFSET)) $offset=$conf->global->MAIN_METEO_OFFSET;
  223. //if (! empty($conf->global->MAIN_METEO_GAP)) $cursor=$conf->global->MAIN_METEO_GAP;
  224. $level0=$offset; if (! empty($conf->global->MAIN_METEO_LEVEL0)) $level0=$conf->global->MAIN_METEO_LEVEL0;
  225. $level1=$offset+1*$cursor; if (! empty($conf->global->MAIN_METEO_LEVEL1)) $level1=$conf->global->MAIN_METEO_LEVEL1;
  226. $level2=$offset+2*$cursor; if (! empty($conf->global->MAIN_METEO_LEVEL2)) $level2=$conf->global->MAIN_METEO_LEVEL2;
  227. $level3=$offset+3*$cursor; if (! empty($conf->global->MAIN_METEO_LEVEL3)) $level3=$conf->global->MAIN_METEO_LEVEL3;
  228. $text=''; $options='height="60px"';
  229. print '<table>';
  230. print '<tr>';
  231. print '<td>';
  232. print img_weather($text,'weather-clear.png',$options);
  233. print '</td><td>= '.$level0.'</td>';
  234. print '<td> &nbsp; &nbsp; &nbsp; &nbsp; </td>';
  235. print '<td>';
  236. print img_weather($text,'weather-few-clouds.png',$options);
  237. print '</td><td>&lt;= '.$level1.'</td>';
  238. print '<td> &nbsp; &nbsp; &nbsp; &nbsp; </td>';
  239. print '<td>';
  240. print img_weather($text,'weather-clouds.png',$options);
  241. print '</td><td>&lt;= '.$level2.'</td>';
  242. print '</tr>';
  243. print '<tr><td>';
  244. print img_weather($text,'weather-many-clouds.png',$options);
  245. print '</td><td>&lt;= '.$level3.'</td>';
  246. print '<td> &nbsp; &nbsp; &nbsp; &nbsp; </td>';
  247. print '<td>';
  248. print img_weather($text,'weather-storm.png',$options);
  249. print '</td><td>&gt; '.$level3.'</td>';
  250. print '<td> &nbsp; &nbsp; &nbsp; &nbsp; </td>';
  251. print '<td> &nbsp; &nbsp; &nbsp; &nbsp; </td>';
  252. print '<td> &nbsp; &nbsp; &nbsp; &nbsp; </td>';
  253. print '</tr>';
  254. print '</table>';
  255. llxFooter();
  256. $db->close();