agenda.php 6.3 KB

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