agenda.php 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  1. <?php
  2. /* Copyright (C) 2001-2007 Rodolphe Quiedeville <rodolphe@quiedeville.org>
  3. * Copyright (C) 2005 Brice Davoleau <brice.davoleau@gmail.com>
  4. * Copyright (C) 2005-2009 Regis Houssin <regis.houssin@inodbox.com>
  5. * Copyright (C) 2006-2011 Laurent Destailleur <eldy@users.sourceforge.net>
  6. * Copyright (C) 2007 Patrick Raguin <patrick.raguin@gmail.com>
  7. * Copyright (C) 2010 Juanjo Menent <jmenent@2byte.es>
  8. *
  9. * This program is free software; you can redistribute it and/or modify
  10. * it under the terms of the GNU General Public License as published by
  11. * the Free Software Foundation; either version 3 of the License, or
  12. * (at your option) any later version.
  13. *
  14. * This program is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. * GNU General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU General Public License
  20. * along with this program. If not, see <https://www.gnu.org/licenses/>.
  21. */
  22. /**
  23. * \file htdocs/adherents/agenda.php
  24. * \ingroup member
  25. * \brief Page of members events
  26. */
  27. require '../main.inc.php';
  28. require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
  29. require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php';
  30. require_once DOL_DOCUMENT_ROOT.'/core/lib/member.lib.php';
  31. require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
  32. require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent_type.class.php';
  33. // Load translation files required by the page
  34. $langs->loadLangs(array("companies", "members"));
  35. $id = GETPOST('id', 'int') ?GETPOST('id', 'int') : GETPOST('rowid', 'int');
  36. $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
  37. $sortfield = GETPOST("sortfield", 'alpha');
  38. $sortorder = GETPOST("sortorder", 'alpha');
  39. $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
  40. if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
  41. $offset = $limit * $page;
  42. $pageprev = $page - 1;
  43. $pagenext = $page + 1;
  44. if (!$sortfield) $sortfield = 'a.datep,a.id';
  45. if (!$sortorder) $sortorder = 'DESC';
  46. if (GETPOST('actioncode', 'array'))
  47. {
  48. $actioncode = GETPOST('actioncode', 'array', 3);
  49. if (!count($actioncode)) $actioncode = '0';
  50. }
  51. else
  52. {
  53. $actioncode = GETPOST("actioncode", "alpha", 3) ?GETPOST("actioncode", "alpha", 3) : (GETPOST("actioncode") == '0' ? '0' : (empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT) ? '' : $conf->global->AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT));
  54. }
  55. $search_agenda_label = GETPOST('search_agenda_label');
  56. // Security check
  57. $result = restrictedArea($user, 'adherent', $id);
  58. $object = new Adherent($db);
  59. $result = $object->fetch($id);
  60. if ($result > 0)
  61. {
  62. $object->fetch_thirdparty();
  63. $adht = new AdherentType($db);
  64. $result = $adht->fetch($object->typeid);
  65. }
  66. /*
  67. * Actions
  68. */
  69. $parameters = array('id'=>$id, 'objcanvas'=>$objcanvas);
  70. $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
  71. if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
  72. if (empty($reshook))
  73. {
  74. // Cancel
  75. if (GETPOST('cancel', 'alpha') && !empty($backtopage))
  76. {
  77. header("Location: ".$backtopage);
  78. exit;
  79. }
  80. // Purge search criteria
  81. if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // All test are required to be compatible with all browsers
  82. {
  83. $actioncode = '';
  84. $search_agenda_label = '';
  85. }
  86. }
  87. /*
  88. * View
  89. */
  90. $contactstatic = new Contact($db);
  91. $form = new Form($db);
  92. /*
  93. * Customer and/or supplier category sheet
  94. */
  95. if ($object->id > 0)
  96. {
  97. require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
  98. require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php';
  99. $langs->load("companies");
  100. $title = $langs->trans("Member")." - ".$langs->trans("Agenda");
  101. $helpurl = "EN:Module_Foundations|FR:Module_Adh&eacute;rents|ES:M&oacute;dulo_Miembros";
  102. llxHeader("", $title, $helpurl);
  103. if (!empty($conf->notification->enabled)) $langs->load("mails");
  104. $head = member_prepare_head($object);
  105. dol_fiche_head($head, 'agenda', $langs->trans("Member"), -1, 'user');
  106. $linkback = '<a href="'.DOL_URL_ROOT.'/adherents/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
  107. dol_banner_tab($object, 'rowid', $linkback);
  108. print '<div class="fichecenter">';
  109. print '<div class="underbanner clearboth"></div>';
  110. $object->info($id);
  111. dol_print_object_info($object, 1);
  112. print '</div>';
  113. dol_fiche_end();
  114. //print '<div class="tabsAction">';
  115. //print '</div>';
  116. $newcardbutton = '';
  117. if (!empty($conf->agenda->enabled))
  118. {
  119. $newcardbutton .= dolGetButtonTitle($langs->trans('AddAction'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/comm/action/card.php?action=create&backtopage=1&origin=member&originid='.$id);
  120. }
  121. if (!empty($conf->agenda->enabled) && (!empty($user->rights->agenda->myactions->read) || !empty($user->rights->agenda->allactions->read)))
  122. {
  123. print '<br>';
  124. $param = '&id='.$id;
  125. if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.$contextpage;
  126. if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.$limit;
  127. print_barre_liste($langs->trans("ActionsOnMember"), 0, $_SERVER["PHP_SELF"], '', $sortfield, $sortorder, '', 0, -1, '', '', $newcardbutton, '', 0, 1, 1);
  128. // List of all actions
  129. $filters = array();
  130. $filters['search_agenda_label'] = $search_agenda_label;
  131. // TODO Replace this with same code than into list.php
  132. show_actions_done($conf, $langs, $db, $object, null, 0, $actioncode, '', $filters, $sortfield, $sortorder);
  133. }
  134. }
  135. // End of page
  136. llxFooter();
  137. $db->close();