agenda.php 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198
  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' : (empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT) ? '' : $conf->global->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. // Security check
  68. $result = restrictedArea($user, 'adherent', $id);
  69. // Initialize technical objects
  70. $object = new Adherent($db);
  71. $result = $object->fetch($id);
  72. if ($result > 0) {
  73. $object->fetch_thirdparty();
  74. $adht = new AdherentType($db);
  75. $result = $adht->fetch($object->typeid);
  76. }
  77. /*
  78. * Actions
  79. */
  80. $parameters = array('id'=>$id, 'objcanvas'=>$objcanvas);
  81. $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
  82. if ($reshook < 0) {
  83. setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
  84. }
  85. if (empty($reshook)) {
  86. // Cancel
  87. if (GETPOST('cancel', 'alpha') && !empty($backtopage)) {
  88. header("Location: ".$backtopage);
  89. exit;
  90. }
  91. // Purge search criteria
  92. 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
  93. $actioncode = '';
  94. $search_rowid = '';
  95. $search_agenda_label = '';
  96. }
  97. }
  98. /*
  99. * View
  100. */
  101. $contactstatic = new Contact($db);
  102. $form = new Form($db);
  103. if ($object->id > 0) {
  104. require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
  105. require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php';
  106. $langs->load("companies");
  107. $title = $langs->trans("Member")." - ".$langs->trans("Agenda");
  108. $help_url = "EN:Module_Foundations|FR:Module_Adh&eacute;rents|ES:M&oacute;dulo_Miembros|DE:Modul_Mitglieder";
  109. llxHeader("", $title, $help_url);
  110. if (isModEnabled('notification')) {
  111. $langs->load("mails");
  112. }
  113. $head = member_prepare_head($object);
  114. print dol_get_fiche_head($head, 'agenda', $langs->trans("Member"), -1, 'user');
  115. $linkback = '<a href="'.DOL_URL_ROOT.'/adherents/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
  116. $morehtmlref = '<a href="'.DOL_URL_ROOT.'/adherents/vcard.php?id='.$object->id.'" class="refid">';
  117. $morehtmlref .= img_picto($langs->trans("Download").' '.$langs->trans("VCard"), 'vcard.png', 'class="valignmiddle marginleftonly paddingrightonly"');
  118. $morehtmlref .= '</a>';
  119. dol_banner_tab($object, 'rowid', $linkback, 1, 'rowid', 'ref', $morehtmlref);
  120. print '<div class="fichecenter">';
  121. print '<div class="underbanner clearboth"></div>';
  122. $object->info($id);
  123. dol_print_object_info($object, 1);
  124. print '</div>';
  125. print dol_get_fiche_end();
  126. //print '<div class="tabsAction">';
  127. //print '</div>';
  128. $newcardbutton = '';
  129. if (isModEnabled('agenda')) {
  130. $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);
  131. }
  132. if (isModEnabled('agenda') && (!empty($user->rights->agenda->myactions->read) || !empty($user->rights->agenda->allactions->read))) {
  133. print '<br>';
  134. $param = '&id='.$id;
  135. if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
  136. $param .= '&contextpage='.$contextpage;
  137. }
  138. if ($limit > 0 && $limit != $conf->liste_limit) {
  139. $param .= '&limit='.$limit;
  140. }
  141. print_barre_liste($langs->trans("ActionsOnMember"), 0, $_SERVER["PHP_SELF"], '', $sortfield, $sortorder, '', 0, -1, '', '', $newcardbutton, '', 0, 1, 1);
  142. // List of all actions
  143. $filters = array();
  144. $filters['search_agenda_label'] = $search_agenda_label;
  145. $filters['search_rowid'] = $search_rowid;
  146. // TODO Replace this with same code than into list.php
  147. show_actions_done($conf, $langs, $db, $object, null, 0, $actioncode, '', $filters, $sortfield, $sortorder);
  148. }
  149. }
  150. // End of page
  151. llxFooter();
  152. $db->close();