agenda.php 6.6 KB

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