agenda.php 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190
  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', 'aZ09comma');
  38. $sortorder = GETPOST('sortorder', 'aZ09comma');
  39. $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
  40. if (empty($page) || $page == -1) {
  41. $page = 0;
  42. } // If $page is not defined, or '' or -1
  43. $offset = $limit * $page;
  44. $pageprev = $page - 1;
  45. $pagenext = $page + 1;
  46. if (!$sortfield) {
  47. $sortfield = 'a.datep,a.id';
  48. }
  49. if (!$sortorder) {
  50. $sortorder = 'DESC';
  51. }
  52. if (GETPOST('actioncode', 'array')) {
  53. $actioncode = GETPOST('actioncode', 'array', 3);
  54. if (!count($actioncode)) {
  55. $actioncode = '0';
  56. }
  57. } else {
  58. $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));
  59. }
  60. $search_agenda_label = GETPOST('search_agenda_label');
  61. // Security check
  62. $result = restrictedArea($user, 'adherent', $id);
  63. $object = new Adherent($db);
  64. $result = $object->fetch($id);
  65. if ($result > 0) {
  66. $object->fetch_thirdparty();
  67. $adht = new AdherentType($db);
  68. $result = $adht->fetch($object->typeid);
  69. }
  70. /*
  71. * Actions
  72. */
  73. $parameters = array('id'=>$id, 'objcanvas'=>$objcanvas);
  74. $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
  75. if ($reshook < 0) {
  76. setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
  77. }
  78. if (empty($reshook)) {
  79. // Cancel
  80. if (GETPOST('cancel', 'alpha') && !empty($backtopage)) {
  81. header("Location: ".$backtopage);
  82. exit;
  83. }
  84. // Purge search criteria
  85. 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
  86. $actioncode = '';
  87. $search_agenda_label = '';
  88. }
  89. }
  90. /*
  91. * View
  92. */
  93. $contactstatic = new Contact($db);
  94. $form = new Form($db);
  95. /*
  96. * Customer and/or supplier category sheet
  97. */
  98. if ($object->id > 0) {
  99. require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
  100. require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php';
  101. $langs->load("companies");
  102. $title = $langs->trans("Member")." - ".$langs->trans("Agenda");
  103. $help_url = "EN:Module_Foundations|FR:Module_Adh&eacute;rents|ES:M&oacute;dulo_Miembros|DE:Modul_Mitglieder";
  104. llxHeader("", $title, $help_url);
  105. if (!empty($conf->notification->enabled)) {
  106. $langs->load("mails");
  107. }
  108. $head = member_prepare_head($object);
  109. print dol_get_fiche_head($head, 'agenda', $langs->trans("Member"), -1, 'user');
  110. $linkback = '<a href="'.DOL_URL_ROOT.'/adherents/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
  111. $morehtmlref = '<a href="'.DOL_URL_ROOT.'/adherents/vcard.php?id='.$object->id.'" class="refid">';
  112. $morehtmlref .= img_picto($langs->trans("Download").' '.$langs->trans("VCard"), 'vcard.png', 'class="valignmiddle marginleftonly paddingrightonly"');
  113. $morehtmlref .= '</a>';
  114. dol_banner_tab($object, 'rowid', $linkback, 1, 'rowid', 'ref', $morehtmlref);
  115. print '<div class="fichecenter">';
  116. print '<div class="underbanner clearboth"></div>';
  117. $object->info($id);
  118. dol_print_object_info($object, 1);
  119. print '</div>';
  120. print dol_get_fiche_end();
  121. //print '<div class="tabsAction">';
  122. //print '</div>';
  123. $newcardbutton = '';
  124. if (!empty($conf->agenda->enabled)) {
  125. $newcardbutton .= dolGetButtonTitle($langs->trans('AddAction'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/comm/action/card.php?action=create&backtopage=1&origin=member&originid='.$id);
  126. }
  127. if (!empty($conf->agenda->enabled) && (!empty($user->rights->agenda->myactions->read) || !empty($user->rights->agenda->allactions->read))) {
  128. print '<br>';
  129. $param = '&id='.$id;
  130. if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
  131. $param .= '&contextpage='.$contextpage;
  132. }
  133. if ($limit > 0 && $limit != $conf->liste_limit) {
  134. $param .= '&limit='.$limit;
  135. }
  136. print_barre_liste($langs->trans("ActionsOnMember"), 0, $_SERVER["PHP_SELF"], '', $sortfield, $sortorder, '', 0, -1, '', '', $newcardbutton, '', 0, 1, 1);
  137. // List of all actions
  138. $filters = array();
  139. $filters['search_agenda_label'] = $search_agenda_label;
  140. // TODO Replace this with same code than into list.php
  141. show_actions_done($conf, $langs, $db, $object, null, 0, $actioncode, '', $filters, $sortfield, $sortorder);
  142. }
  143. }
  144. // End of page
  145. llxFooter();
  146. $db->close();