PageRenderTime 43ms CodeModel.GetById 17ms RepoModel.GetById 1ms app.codeStats 0ms

/htdocs/admin/agenda.php

https://github.com/asterix14/dolibarr
PHP | 168 lines | 106 code | 31 blank | 31 comment | 21 complexity | f3a7e6057a1f95a71b36f0da874d923d MD5 | raw file
Possible License(s): LGPL-2.0
  1. <?php
  2. /* Copyright (C) 2008-2010 Laurent Destailleur <eldy@users.sourceforge.net>
  3. * Copyright (C) 2011 Regis Houssin <regis@dolibarr.fr>
  4. * Copyright (C) 2011 Juanjo Menent <jmenent@2byte.es>
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation; either version 2 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  18. */
  19. /**
  20. * \file htdocs/admin/agenda.php
  21. * \ingroup agenda
  22. * \brief Autocreate actions for agenda module setup page
  23. */
  24. require("../main.inc.php");
  25. require_once(DOL_DOCUMENT_ROOT."/core/lib/admin.lib.php");
  26. require_once(DOL_DOCUMENT_ROOT."/core/lib/agenda.lib.php");
  27. if (!$user->admin)
  28. accessforbidden();
  29. $langs->load("admin");
  30. $langs->load("other");
  31. $action=$_POST["action"];
  32. // Get list of triggers available
  33. $sql = "SELECT a.rowid, a.code, a.label, a.elementtype";
  34. $sql.= " FROM ".MAIN_DB_PREFIX."c_action_trigger as a";
  35. $sql.= " ORDER BY a.rang ASC";
  36. $resql=$db->query($sql);
  37. if ($resql)
  38. {
  39. $num = $db->num_rows($resql);
  40. $i = 0;
  41. while ($i < $num)
  42. {
  43. $obj = $db->fetch_object($resql);
  44. $triggers[$i]['rowid'] = $obj->rowid;
  45. $triggers[$i]['code'] = $obj->code;
  46. $triggers[$i]['element'] = $obj->elementtype;
  47. $triggers[$i]['label'] = ($langs->trans("Notify_".$obj->code)!="Notify_".$obj->code?$langs->trans("Notify_".$obj->code):$obj->label);
  48. $i++;
  49. }
  50. $db->free($resql);
  51. }
  52. else
  53. {
  54. dol_print_error($db);
  55. }
  56. /*
  57. * Actions
  58. */
  59. if ($action == "save" && empty($_POST["cancel"]))
  60. {
  61. $i=0;
  62. $db->begin();
  63. foreach ($triggers as $trigger)
  64. {
  65. $param='MAIN_AGENDA_ACTIONAUTO_'.$trigger['code'];
  66. //print "param=".$param." - ".$_POST[$param];
  67. if (! empty($_POST[$param])) $res = dolibarr_set_const($db,$param,$_POST[$param],'chaine',0,'',$conf->entity);
  68. else $res = dolibarr_del_const($db,$param,$conf->entity);
  69. if (! $res > 0) $error++;
  70. }
  71. if (! $error)
  72. {
  73. $db->commit();
  74. $mesg = "<font class=\"ok\">".$langs->trans("SetupSaved")."</font>";
  75. }
  76. else
  77. {
  78. $db->rollback();
  79. $mesg = "<font class=\"error\">".$langs->trans("Error")."</font>";
  80. }
  81. }
  82. /**
  83. * Affichage du formulaire de saisie
  84. */
  85. llxHeader();
  86. $linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php">'.$langs->trans("BackToModuleList").'</a>';
  87. print_fiche_titre($langs->trans("AgendaSetup"),$linkback,'setup');
  88. print "<br>\n";
  89. print $langs->trans("AgendaAutoActionDesc")."<br>\n";
  90. print "<br>\n";
  91. $head=agenda_prepare_head();
  92. dol_fiche_head($head, 'autoactions', $langs->trans("Agenda"));
  93. print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
  94. print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
  95. print '<input type="hidden" name="action" value="save">';
  96. $var=true;
  97. print '<table class="noborder" width="100%">';
  98. print '<tr class="liste_titre">';
  99. print '<td colspan="2">'.$langs->trans("ActionsEvents").'</td>';
  100. print '<td><a href="'.$_SERVER["PHP_SELF"].'?action=selectall">'.$langs->trans("All").'</a>/<a href="'.$_SERVER["PHP_SELF"].'?action=selectnone">'.$langs->trans("None").'</a>';
  101. print '</tr>'."\n";
  102. if (! empty($triggers))
  103. {
  104. foreach ($triggers as $trigger)
  105. {
  106. $module = $trigger['element'];
  107. if ($module == 'order_supplier' || $module == 'invoice_supplier') $module = 'fournisseur';
  108. if ($module == 'shipping') $module = 'expedition_bon';
  109. if ($module == 'member') $module = 'adherent';
  110. //print 'module='.$module.'<br>';
  111. if ($conf->$module->enabled)
  112. {
  113. $var=!$var;
  114. print '<tr '.$bc[$var].'>';
  115. print '<td>'.$trigger['code'].'</td>';
  116. print '<td>'.$trigger['label'].'</td>';
  117. print '<td align="right" width="40">';
  118. $key='MAIN_AGENDA_ACTIONAUTO_'.$trigger['code'];
  119. $value=$conf->global->$key;
  120. print '<input '.$bc[$var].' type="checkbox" name="'.$key.'" value="1"'.((($_GET["action"]=='selectall'||$value) && $_GET["action"]!="selectnone")?' checked="checked"':'').'>';
  121. print '</td></tr>'."\n";
  122. }
  123. }
  124. }
  125. print '</table>';
  126. print '<br><center>';
  127. print '<input type="submit" name="save" class="button" value="'.$langs->trans("Save").'">';
  128. print ' &nbsp; &nbsp; ';
  129. print '<input type="submit" name="cancel" class="button" value="'.$langs->trans("Cancel").'">';
  130. print "</center>";
  131. print "</form>\n";
  132. print '</div>';
  133. print "<br>";
  134. dol_htmloutput_mesg($mesg);
  135. $db->close();
  136. llxFooter();
  137. ?>