agenda_reminder.php 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253
  1. <?php
  2. /* Copyright (C) 2017 Laurent Destailleur <eldy@users.sourceforge.net>
  3. *
  4. * This program is free software; you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License as published by
  6. * the Free Software Foundation; either version 3 of the License, or
  7. * (at your option) any later version.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with this program. If not, see <https://www.gnu.org/licenses/>.
  16. */
  17. /**
  18. * \file htdocs/admin/agenda_reminder.php
  19. * \ingroup agenda
  20. * \brief Page to setup agenda reminder options
  21. */
  22. require '../main.inc.php';
  23. require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
  24. require_once DOL_DOCUMENT_ROOT.'/core/lib/agenda.lib.php';
  25. require_once DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php';
  26. if (!$user->admin)
  27. accessforbidden();
  28. // Load translation files required by the page
  29. $langs->loadLangs(array("admin", "other", "agenda"));
  30. $action = GETPOST('action', 'alpha');
  31. $value = GETPOST('value', 'alpha');
  32. $param = GETPOST('param', 'alpha');
  33. $cancel = GETPOST('cancel', 'alpha');
  34. $scandir = GETPOST('scandir', 'alpha');
  35. $type = 'action';
  36. /*
  37. * Actions
  38. */
  39. include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php';
  40. if (preg_match('/set_([a-z0-9_\-]+)/i', $action, $reg))
  41. {
  42. $code = $reg[1];
  43. $value = (GETPOST($code, 'alpha') ? GETPOST($code, 'alpha') : 1);
  44. if (dolibarr_set_const($db, $code, $value, 'chaine', 0, '', $conf->entity) > 0)
  45. {
  46. Header("Location: ".$_SERVER["PHP_SELF"]);
  47. exit;
  48. }
  49. else
  50. {
  51. dol_print_error($db);
  52. }
  53. }
  54. if (preg_match('/del_([a-z0-9_\-]+)/i', $action, $reg))
  55. {
  56. $code = $reg[1];
  57. if (dolibarr_del_const($db, $code, $conf->entity) > 0)
  58. {
  59. Header("Location: ".$_SERVER["PHP_SELF"]);
  60. exit;
  61. }
  62. else
  63. {
  64. dol_print_error($db);
  65. }
  66. }
  67. if ($action == 'set')
  68. {
  69. dolibarr_set_const($db, 'AGENDA_USE_EVENT_TYPE_DEFAULT', GETPOST('AGENDA_USE_EVENT_TYPE_DEFAULT'), 'chaine', 0, '', $conf->entity);
  70. dolibarr_set_const($db, 'AGENDA_DEFAULT_FILTER_TYPE', GETPOST('AGENDA_DEFAULT_FILTER_TYPE'), 'chaine', 0, '', $conf->entity);
  71. dolibarr_set_const($db, 'AGENDA_DEFAULT_FILTER_STATUS', GETPOST('AGENDA_DEFAULT_FILTER_STATUS'), 'chaine', 0, '', $conf->entity);
  72. dolibarr_set_const($db, 'AGENDA_DEFAULT_VIEW', GETPOST('AGENDA_DEFAULT_VIEW'), 'chaine', 0, '', $conf->entity);
  73. }
  74. elseif ($action == 'specimen') // For orders
  75. {
  76. $modele = GETPOST('module', 'alpha');
  77. $commande = new CommandeFournisseur($db);
  78. $commande->initAsSpecimen();
  79. $commande->thirdparty = $specimenthirdparty;
  80. // Search template files
  81. $file = ''; $classname = ''; $filefound = 0;
  82. $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']);
  83. foreach ($dirmodels as $reldir)
  84. {
  85. $file = dol_buildpath($reldir."core/modules/action/doc/pdf_".$modele.".modules.php", 0);
  86. if (file_exists($file))
  87. {
  88. $filefound = 1;
  89. $classname = "pdf_".$modele;
  90. break;
  91. }
  92. }
  93. if ($filefound)
  94. {
  95. require_once $file;
  96. $module = new $classname($db, $commande);
  97. if ($module->write_file($commande, $langs) > 0)
  98. {
  99. header("Location: ".DOL_URL_ROOT."/document.php?modulepart=action&file=SPECIMEN.pdf");
  100. return;
  101. }
  102. else
  103. {
  104. setEventMessages($module->error, $module->errors, 'errors');
  105. dol_syslog($module->error, LOG_ERR);
  106. }
  107. }
  108. else
  109. {
  110. setEventMessages($langs->trans("ErrorModuleNotFound"), null, 'errors');
  111. dol_syslog($langs->trans("ErrorModuleNotFound"), LOG_ERR);
  112. }
  113. }
  114. // Activate a model
  115. elseif ($action == 'setmodel')
  116. {
  117. //print "sssd".$value;
  118. $ret = addDocumentModel($value, $type, $label, $scandir);
  119. }
  120. elseif ($action == 'del')
  121. {
  122. $ret = delDocumentModel($value, $type);
  123. if ($ret > 0)
  124. {
  125. if ($conf->global->ACTION_EVENT_ADDON_PDF == "$value") dolibarr_del_const($db, 'ACTION_EVENT_ADDON_PDF', $conf->entity);
  126. }
  127. }
  128. // Set default model
  129. elseif ($action == 'setdoc')
  130. {
  131. if (dolibarr_set_const($db, "ACTION_EVENT_ADDON_PDF", $value, 'chaine', 0, '', $conf->entity))
  132. {
  133. // The constant that has been read in front of the new set
  134. // is therefore passed through a variable to have a coherent display
  135. $conf->global->ACTION_EVENT_ADDON_PDF = $value;
  136. }
  137. // On active le modele
  138. $ret = delDocumentModel($value, $type);
  139. if ($ret > 0)
  140. {
  141. $ret = addDocumentModel($value, $type, $label, $scandir);
  142. }
  143. }
  144. /**
  145. * View
  146. */
  147. $formactions = new FormActions($db);
  148. $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']);
  149. llxHeader();
  150. $linkback = '<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>';
  151. print load_fiche_titre($langs->trans("AgendaSetup"), $linkback, 'title_setup');
  152. $head = agenda_prepare_head();
  153. dol_fiche_head($head, 'reminders', $langs->trans("Agenda"), -1, 'action');
  154. print '<form action="'.$_SERVER["PHP_SELF"].'" name="agenda">';
  155. print '<input type="hidden" name="token" value="'.newToken().'">';
  156. print '<input type="hidden" name="action" value="set">';
  157. print '<table class="noborder allwidth">'."\n";
  158. print '<tr class="liste_titre">'."\n";
  159. print '<td>'.$langs->trans("Parameters").'</td>'."\n";
  160. print '<td class="center">&nbsp;</td>'."\n";
  161. print '<td class="right">'.$langs->trans("Value").'</td>'."\n";
  162. print '</tr>'."\n";
  163. // AGENDA REMINDER EMAIL
  164. if ($conf->global->MAIN_FEATURES_LEVEL == 2)
  165. {
  166. print '<tr class="oddeven">'."\n";
  167. print '<td>'.$langs->trans('AGENDA_REMINDER_EMAIL', $langs->transnoentities("Module2300Name")).'</td>'."\n";
  168. print '<td class="center">&nbsp;</td>'."\n";
  169. print '<td class="right">'."\n";
  170. if (empty($conf->global->AGENDA_REMINDER_EMAIL)) {
  171. print '<a href="'.$_SERVER['PHP_SELF'].'?action=set_AGENDA_REMINDER_EMAIL">'.img_picto($langs->trans('Disabled'), 'switch_off').'</a>';
  172. print '</td></tr>'."\n";
  173. } else {
  174. print '<a href="'.$_SERVER['PHP_SELF'].'?action=del_AGENDA_REMINDER_EMAIL">'.img_picto($langs->trans('Enabled'), 'switch_on').'</a>';
  175. print '</td></tr>'."\n";
  176. }
  177. }
  178. // AGENDA REMINDER BROWSER
  179. if ($conf->global->MAIN_FEATURES_LEVEL == 2)
  180. {
  181. print '<tr class="oddeven">'."\n";
  182. print '<td>'.$langs->trans('AGENDA_REMINDER_BROWSER').'</td>'."\n";
  183. print '<td class="center">&nbsp;</td>'."\n";
  184. print '<td class="right">'."\n";
  185. if (empty($conf->global->AGENDA_REMINDER_BROWSER)) {
  186. print '<a href="'.$_SERVER['PHP_SELF'].'?action=set_AGENDA_REMINDER_BROWSER">'.img_picto($langs->trans('Disabled'), 'switch_off').'</a>';
  187. print '</td></tr>'."\n";
  188. } else {
  189. print '<a href="'.$_SERVER['PHP_SELF'].'?action=del_AGENDA_REMINDER_BROWSER">'.img_picto($langs->trans('Enabled'), 'switch_on').'</a>';
  190. print '</td></tr>'."\n";
  191. print '<tr class="oddeven">'."\n";
  192. print '<td>'.$langs->trans('AGENDA_REMINDER_BROWSER_SOUND').'</td>'."\n";
  193. print '<td class="center">&nbsp;</td>'."\n";
  194. print '<td class="right">'."\n";
  195. if (empty($conf->global->AGENDA_REMINDER_BROWSER_SOUND)) {
  196. print '<a href="'.$_SERVER['PHP_SELF'].'?action=set_AGENDA_REMINDER_BROWSER_SOUND">'.img_picto($langs->trans('Disabled'), 'switch_off').'</a>';
  197. } else {
  198. print '<a href="'.$_SERVER['PHP_SELF'].'?action=del_AGENDA_REMINDER_BROWSER_SOUND">'.img_picto($langs->trans('Enabled'), 'switch_on').'</a>';
  199. }
  200. print '</td></tr>'."\n";
  201. }
  202. }
  203. print '</table>';
  204. dol_fiche_end();
  205. print '<div class="center"><input class="button" type="submit" name="save" value="'.dol_escape_htmltag($langs->trans("Save")).'"></div>';
  206. print '</form>';
  207. print "<br>";
  208. // End of page
  209. llxFooter();
  210. $db->close();