notification.php 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. <?php
  2. /* Copyright (C) 2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
  3. * Copyright (C) 2005-2011 Laurent Destailleur <eldy@users.sourceforge.org>
  4. *
  5. * This program is free software; you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation; either version 2 of the License, or
  8. * (at your option) any later version.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  17. */
  18. /**
  19. * \file htdocs/admin/notification.php
  20. * \ingroup notification
  21. * \brief Page to setup notification module
  22. */
  23. require("../main.inc.php");
  24. require_once(DOL_DOCUMENT_ROOT."/lib/admin.lib.php");
  25. require_once(DOL_DOCUMENT_ROOT."/includes/triggers/interface_modNotification_Notification.class.php");
  26. $langs->load("admin");
  27. // Security check
  28. if (!$user->admin)
  29. accessforbidden();
  30. /*
  31. * Actions
  32. */
  33. if ($_POST["action"] == 'setvalue' && $user->admin)
  34. {
  35. $result=dolibarr_set_const($db, "NOTIFICATION_EMAIL_FROM",$_POST["email_from"],'chaine',0,'',$conf->entity);
  36. if ($result >= 0)
  37. {
  38. $mesg='<div class="ok">'.$langs->trans("Success").'</div>';
  39. }
  40. else
  41. {
  42. dol_print_error($db);
  43. }
  44. }
  45. /*
  46. * View
  47. */
  48. llxHeader();
  49. $linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php">'.$langs->trans("BackToModuleList").'</a>';
  50. print_fiche_titre($langs->trans("NotificationSetup"),$linkback,'setup');
  51. print $langs->trans("NotificationsDesc").'<br><br>';
  52. if ($mesg) print $mesg.'<br>';
  53. print '<form method="post" action="'.$_SERVER["PHP_SELF"].'">';
  54. print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
  55. print '<input type="hidden" name="action" value="setvalue">';
  56. $var=true;
  57. print '<table class="noborder" width="100%">';
  58. print '<tr class="liste_titre">';
  59. print '<td>'.$langs->trans("Parameter").'</td>';
  60. print '<td>'.$langs->trans("Value").'</td>';
  61. print "</tr>\n";
  62. $var=!$var;
  63. print '<tr '.$bc[$var].'><td>';
  64. print $langs->trans("NotificationEMailFrom").'</td><td>';
  65. print '<input size="32" type="text" name="email_from" value="'.$conf->global->NOTIFICATION_EMAIL_FROM.'">';
  66. print '</td></tr>';
  67. print '</table>';
  68. print '<br>';
  69. print '<center><input type="submit" class="button" value="'.$langs->trans("Modify").'"></center>';
  70. print '</form>';
  71. print '<br>';
  72. print_fiche_titre($langs->trans("ListOfAvailableNotifications"),'','');
  73. print '<table class="noborder" width="100%">';
  74. print '<tr class="liste_titre">';
  75. print '<td>'.$langs->trans("Module").'</td>';
  76. print '<td>'.$langs->trans("Code").'</td>';
  77. print '<td>'.$langs->trans("Label").'</td>';
  78. print "</tr>\n";
  79. // Load array of available notifications
  80. $notificationtrigger=new InterfaceNotification($db);
  81. $listofnotifiedevents=$notificationtrigger->getListOfManagedEvents();
  82. foreach($listofnotifiedevents as $notifiedevent)
  83. {
  84. $var=!$var;
  85. $label=$langs->trans("Notify_".$notifiedevent['code'])!=$langs->trans("Notify_".$notifiedevent['code'])?$langs->trans("Notify_".$notifiedevent['code']):$notifiedevent['label'];
  86. print '<tr '.$bc[$var].'>';
  87. print '<td>'.$notifiedevent['elementtype'].'</td>';
  88. print '<td>'.$notifiedevent['code'].'</td>';
  89. print '<td>'.$label.'</td>';
  90. print '</tr>';
  91. }
  92. print '</table>';
  93. $db->close();
  94. llxFooter();
  95. ?>