member.lib.php 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268
  1. <?php
  2. /* Copyright (C) 2006-2015 Laurent Destailleur <eldy@users.sourceforge.net>
  3. * Copyright (C) 2015-2016 Alexandre Spangaro <aspangaro.dolibarr@gmail.com>
  4. * Copyright (C) 2015 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr>
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation; either version 3 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  18. * or see http://www.gnu.org/
  19. */
  20. /**
  21. * \file htdocs/core/lib/member.lib.php
  22. * \brief Functions for module members
  23. */
  24. /**
  25. * Return array head with list of tabs to view object informations
  26. *
  27. * @param Adherent $object Member
  28. * @return array head
  29. */
  30. function member_prepare_head(Adherent $object)
  31. {
  32. global $db, $langs, $conf, $user;
  33. $h = 0;
  34. $head = array();
  35. $head[$h][0] = DOL_URL_ROOT.'/adherents/card.php?rowid='.$object->id;
  36. $head[$h][1] = $langs->trans("Card");
  37. $head[$h][2] = 'general';
  38. $h++;
  39. if (! empty($conf->ldap->enabled) && ! empty($conf->global->LDAP_MEMBER_ACTIVE))
  40. {
  41. $langs->load("ldap");
  42. $head[$h][0] = DOL_URL_ROOT.'/adherents/ldap.php?id='.$object->id;
  43. $head[$h][1] = $langs->trans("LDAPCard");
  44. $head[$h][2] = 'ldap';
  45. $h++;
  46. }
  47. if (! empty($user->rights->adherent->cotisation->lire))
  48. {
  49. $head[$h][0] = DOL_URL_ROOT.'/adherents/subscription.php?rowid='.$object->id;
  50. $head[$h][1] = $langs->trans("Subscriptions");
  51. $head[$h][2] = 'subscription';
  52. $h++;
  53. }
  54. // Show more tabs from modules
  55. // Entries must be declared in modules descriptor with line
  56. // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
  57. // $this->tabs = array('entity:-tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to remove a tab
  58. complete_head_from_modules($conf,$langs,$object,$head,$h,'member');
  59. $nbNote = 0;
  60. if(!empty($object->note)) $nbNote++;
  61. if(!empty($object->note_private)) $nbNote++;
  62. if(!empty($object->note_public)) $nbNote++;
  63. $head[$h][0] = DOL_URL_ROOT.'/adherents/note.php?id='.$object->id;
  64. $head[$h][1] = $langs->trans("Note");
  65. $head[$h][2] = 'note';
  66. if ($nbNote > 0) $head[$h][1].= ' <span class="badge">'.$nbNote.'</span>';
  67. $h++;
  68. // Attachments
  69. require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
  70. require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php';
  71. $upload_dir = $conf->adherent->multidir_output[$object->entity].'/'.get_exdir(0,0,0,1,$object,'member');
  72. $nbFiles = count(dol_dir_list($upload_dir,'files',0,'','(\.meta|_preview.*\.png)$'));
  73. $nbLinks=Link::count($db, $object->element, $object->id);
  74. $head[$h][0] = DOL_URL_ROOT.'/adherents/document.php?id='.$object->id;
  75. $head[$h][1] = $langs->trans('Documents');
  76. if (($nbFiles+$nbLinks) > 0) $head[$h][1].= ' <span class="badge">'.($nbFiles+$nbLinks).'</span>';
  77. $head[$h][2] = 'document';
  78. $h++;
  79. // Show agenda tab
  80. if (! empty($conf->agenda->enabled))
  81. {
  82. $head[$h][0] = DOL_URL_ROOT."/adherents/agenda.php?id=".$object->id;
  83. $head[$h][1] = $langs->trans("Events");
  84. if (! empty($conf->agenda->enabled) && (!empty($user->rights->agenda->myactions->read) || !empty($user->rights->agenda->allactions->read) ))
  85. {
  86. $head[$h][1].= '/';
  87. $head[$h][1].= $langs->trans("Agenda");
  88. }
  89. $head[$h][2] = 'agenda';
  90. $h++;
  91. }
  92. complete_head_from_modules($conf,$langs,$object,$head,$h,'member','remove');
  93. return $head;
  94. }
  95. /**
  96. * Return array head with list of tabs to view object informations
  97. *
  98. * @param AdherentType $object Member
  99. * @return array head
  100. */
  101. function member_type_prepare_head(AdherentType $object)
  102. {
  103. global $langs, $conf, $user;
  104. $h=0;
  105. $head = array();
  106. $head[$h][0] = DOL_URL_ROOT.'/adherents/type.php?rowid='.$object->id;
  107. $head[$h][1] = $langs->trans("Card");
  108. $head[$h][2] = 'card';
  109. $h++;
  110. // Show more tabs from modules
  111. // Entries must be declared in modules descriptor with line
  112. // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
  113. // $this->tabs = array('entity:-tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to remove a tab
  114. complete_head_from_modules($conf,$langs,$object,$head,$h,'membertype');
  115. complete_head_from_modules($conf,$langs,$object,$head,$h,'membertype','remove');
  116. return $head;
  117. }
  118. /**
  119. * Return array head with list of tabs to view object informations
  120. *
  121. * @return array head
  122. */
  123. function member_admin_prepare_head()
  124. {
  125. global $langs, $conf, $user;
  126. $h = 0;
  127. $head = array();
  128. $head[$h][0] = DOL_URL_ROOT.'/adherents/admin/adherent.php';
  129. $head[$h][1] = $langs->trans("Miscellaneous");
  130. $head[$h][2] = 'general';
  131. $h++;
  132. // Show more tabs from modules
  133. // Entries must be declared in modules descriptor with line
  134. // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
  135. // $this->tabs = array('entity:-tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to remove a tab
  136. complete_head_from_modules($conf,$langs,'',$head,$h,'member_admin');
  137. $head[$h][0] = DOL_URL_ROOT.'/adherents/admin/adherent_extrafields.php';
  138. $head[$h][1] = $langs->trans("ExtraFieldsMember");
  139. $head[$h][2] = 'attributes';
  140. $h++;
  141. $head[$h][0] = DOL_URL_ROOT.'/adherents/admin/adherent_type_extrafields.php';
  142. $head[$h][1] = $langs->trans("ExtraFieldsMemberType");
  143. $head[$h][2] = 'attributes_type';
  144. $h++;
  145. $head[$h][0] = DOL_URL_ROOT.'/adherents/admin/public.php';
  146. $head[$h][1] = $langs->trans("BlankSubscriptionForm");
  147. $head[$h][2] = 'public';
  148. $h++;
  149. complete_head_from_modules($conf,$langs,'',$head,$h,'member_admin','remove');
  150. return $head;
  151. }
  152. /**
  153. * Return array head with list of tabs to view object stats informations
  154. *
  155. * @param Adherent $object Member or null
  156. * @return array head
  157. */
  158. function member_stats_prepare_head($object)
  159. {
  160. global $langs, $conf, $user;
  161. $h = 0;
  162. $head = array();
  163. $head[$h][0] = DOL_URL_ROOT.'/adherents/stats/index.php';
  164. $head[$h][1] = $langs->trans("Subscriptions");
  165. $head[$h][2] = 'statssubscription';
  166. $h++;
  167. $head[$h][0] = DOL_URL_ROOT.'/adherents/stats/geo.php?mode=memberbycountry';
  168. $head[$h][1] = $langs->trans("Country");
  169. $head[$h][2] = 'statscountry';
  170. $h++;
  171. $head[$h][0] = DOL_URL_ROOT.'/adherents/stats/geo.php?mode=memberbyregion';
  172. $head[$h][1] = $langs->trans("Region");
  173. $head[$h][2] = 'statsregion';
  174. $h++;
  175. $head[$h][0] = DOL_URL_ROOT.'/adherents/stats/geo.php?mode=memberbystate';
  176. $head[$h][1] = $langs->trans("State");
  177. $head[$h][2] = 'statsstate';
  178. $h++;
  179. $head[$h][0] = DOL_URL_ROOT.'/adherents/stats/geo.php?mode=memberbytown';
  180. $head[$h][1] = $langs->trans('Town');
  181. $head[$h][2] = 'statstown';
  182. $h++;
  183. $head[$h][0] = DOL_URL_ROOT.'/adherents/stats/byproperties.php';
  184. $head[$h][1] = $langs->trans('ByProperties');
  185. $head[$h][2] = 'statsbyproperties';
  186. $h++;
  187. // Show more tabs from modules
  188. // Entries must be declared in modules descriptor with line
  189. // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
  190. // $this->tabs = array('entity:-tabname); to remove a tab
  191. complete_head_from_modules($conf,$langs,$object,$head,$h,'member_stats');
  192. complete_head_from_modules($conf,$langs,$object,$head,$h,'member_stats','remove');
  193. return $head;
  194. }
  195. /**
  196. * Return array head with list of tabs to view object informations
  197. *
  198. * @param Subscription $object Subscription
  199. * @return array head
  200. */
  201. function subscription_prepare_head(Subscription $object)
  202. {
  203. global $db, $langs, $conf, $user;
  204. $h = 0;
  205. $head = array();
  206. $head[$h][0] = DOL_URL_ROOT.'/adherents/subscription/card.php?rowid='.$object->id;
  207. $head[$h][1] = $langs->trans("Card");
  208. $head[$h][2] = 'general';
  209. $h++;
  210. $head[$h][0] = DOL_URL_ROOT.'/adherents/subscription/info.php?rowid='.$object->id;
  211. $head[$h][1] = $langs->trans("Info");
  212. $head[$h][2] = 'info';
  213. $h++;
  214. // Show more tabs from modules
  215. // Entries must be declared in modules descriptor with line
  216. // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
  217. // $this->tabs = array('entity:-tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to remove a tab
  218. complete_head_from_modules($conf,$langs,$object,$head,$h,'subscription');
  219. complete_head_from_modules($conf,$langs,$object,$head,$h,'subscription','remove');
  220. return $head;
  221. }