document.php 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204
  1. <?php
  2. /* Copyright (C) 2002-2007 Rodolphe Quiedeville <rodolphe@quiedeville.org>
  3. * Copyright (C) 2004-2010 Laurent Destailleur <eldy@users.sourceforge.net>
  4. * Copyright (C) 2005-2012 Regis Houssin <regis.houssin@inodbox.com>
  5. * Copyright (C) 2010 Juanjo Menent <jmenent@2byte.es>
  6. * Copyright (C) 2013 Cédric Salvador <csalvador@gpcsolutions.fr>
  7. *
  8. * This program is free software; you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License as published by
  10. * the Free Software Foundation; either version 3 of the License, or
  11. * (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program. If not, see <https://www.gnu.org/licenses/>.
  20. */
  21. /**
  22. * \file htdocs/adherents/document.php
  23. * \brief Tab for documents linked to third party
  24. * \ingroup societe
  25. */
  26. // Load Dolibarr environment
  27. require '../main.inc.php';
  28. require_once DOL_DOCUMENT_ROOT.'/core/lib/member.lib.php';
  29. require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
  30. require_once DOL_DOCUMENT_ROOT.'/core/lib/images.lib.php';
  31. require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
  32. require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php';
  33. require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent_type.class.php';
  34. // Load translation files required by the page
  35. $langs->loadLangs(array("companies", "members", "other"));
  36. $id = GETPOSTISSET('id') ? GETPOST('id', 'int') : GETPOST('rowid', 'int');
  37. $ref = GETPOST('ref', 'alphanohtml');
  38. $action = GETPOST('action', 'aZ09');
  39. $confirm = GETPOST('confirm', 'alpha');
  40. // Get parameters
  41. $limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit;
  42. $sortfield = GETPOST('sortfield', 'aZ09comma');
  43. $sortorder = GETPOST('sortorder', 'aZ09comma');
  44. $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
  45. if (empty($page) || $page == -1) {
  46. $page = 0;
  47. } // If $page is not defined, or '' or -1
  48. $offset = $limit * $page;
  49. $pageprev = $page - 1;
  50. $pagenext = $page + 1;
  51. if (!$sortorder) {
  52. $sortorder = "ASC";
  53. }
  54. if (!$sortfield) {
  55. $sortfield = "name";
  56. }
  57. $object = new Adherent($db);
  58. $membert = new AdherentType($db);
  59. $result = $object->fetch($id, $ref);
  60. if ($result < 0) {
  61. dol_print_error($db);
  62. exit;
  63. }
  64. $upload_dir = $conf->adherent->dir_output."/".get_exdir(0, 0, 0, 1, $object, 'member');
  65. // Fetch object
  66. if ($id > 0 || !empty($ref)) {
  67. // Load member
  68. $result = $object->fetch($id, $ref);
  69. // Define variables to know what current user can do on users
  70. $canadduser = ($user->admin || $user->hasRight('user', 'user', 'creer'));
  71. // Define variables to know what current user can do on properties of user linked to edited member
  72. if ($object->user_id) {
  73. // $User is the user who edits, $object->user_id is the id of the related user in the edited member
  74. $caneditfielduser = ((($user->id == $object->user_id) && $user->hasRight('user', 'self', 'creer'))
  75. || (($user->id != $object->user_id) && $user->hasRight('user', 'user', 'creer')));
  76. $caneditpassworduser = ((($user->id == $object->user_id) && $user->hasRight('user', 'self', 'password'))
  77. || (($user->id != $object->user_id) && $user->hasRight('user', 'user', 'password')));
  78. }
  79. }
  80. // Define variables to determine what the current user can do on the members
  81. $canaddmember = $user->hasRight('adherent', 'creer');
  82. // Define variables to determine what the current user can do on the properties of a member
  83. if ($id) {
  84. $caneditfieldmember = $user->hasRight('adherent', 'creer');
  85. }
  86. $permissiontoadd = $canaddmember;
  87. // Security check
  88. $result = restrictedArea($user, 'adherent', $object->id, '', '', 'socid', 'rowid', 0);
  89. /*
  90. * Actions
  91. */
  92. include DOL_DOCUMENT_ROOT.'/core/actions_linkedfiles.inc.php';
  93. /*
  94. * View
  95. */
  96. $form = new Form($db);
  97. $title = $langs->trans("Member")." - ".$langs->trans("Documents");
  98. $help_url = "EN:Module_Foundations|FR:Module_Adh&eacute;rents|ES:M&oacute;dulo_Miembros|DE:Modul_Mitglieder";
  99. llxHeader("", $title, $help_url);
  100. if ($id > 0) {
  101. $result = $membert->fetch($object->typeid);
  102. if ($result > 0) {
  103. // Build file list
  104. $filearray = dol_dir_list($upload_dir, "files", 0, '', '(\.meta|_preview.*\.png)$', $sortfield, (strtolower($sortorder) == 'desc' ?SORT_DESC:SORT_ASC), 1);
  105. $totalsize = 0;
  106. foreach ($filearray as $key => $file) {
  107. $totalsize += $file['size'];
  108. }
  109. if (isModEnabled('notification')) {
  110. $langs->load("mails");
  111. }
  112. $head = member_prepare_head($object);
  113. print dol_get_fiche_head($head, 'document', $langs->trans("Member"), -1, 'user');
  114. $linkback = '<a href="'.DOL_URL_ROOT.'/adherents/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
  115. $morehtmlref = '<a href="'.DOL_URL_ROOT.'/adherents/vcard.php?id='.$object->id.'" class="refid">';
  116. $morehtmlref .= img_picto($langs->trans("Download").' '.$langs->trans("VCard"), 'vcard.png', 'class="valignmiddle marginleftonly paddingrightonly"');
  117. $morehtmlref .= '</a>';
  118. dol_banner_tab($object, 'rowid', $linkback, 1, 'rowid', 'ref', $morehtmlref);
  119. print '<div class="fichecenter">';
  120. print '<div class="underbanner clearboth"></div>';
  121. print '<table class="border tableforfield centpercent">';
  122. $linkback = '<a href="'.DOL_URL_ROOT.'/adherents/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
  123. // Login
  124. if (!getDolGlobalString('ADHERENT_LOGIN_NOT_REQUIRED')) {
  125. print '<tr><td class="titlefield">'.$langs->trans("Login").' / '.$langs->trans("Id").'</td><td class="valeur">'.dol_escape_htmltag($object->login).'</td></tr>';
  126. }
  127. // Type
  128. print '<tr><td>'.$langs->trans("Type").'</td>';
  129. print '<td class="valeur">'.$membert->getNomUrl(1)."</td></tr>\n";
  130. // Morphy
  131. print '<tr><td class="titlefield">'.$langs->trans("MemberNature").'</td>';
  132. print '<td class="valeur" >'.$object->getmorphylib('', 1).'</td>';
  133. print '</tr>';
  134. // Company
  135. print '<tr><td>'.$langs->trans("Company").'</td><td class="valeur">'.dol_escape_htmltag($object->company).'</td></tr>';
  136. // Civility
  137. print '<tr><td>'.$langs->trans("UserTitle").'</td><td class="valeur">'.$object->getCivilityLabel().'&nbsp;</td>';
  138. print '</tr>';
  139. // Number of Attached Files
  140. print '<tr><td>'.$langs->trans("NbOfAttachedFiles").'</td><td colspan="3">'.count($filearray).'</td></tr>';
  141. //Total Size Of Attached Files
  142. print '<tr><td>'.$langs->trans("TotalSizeOfAttachedFiles").'</td><td colspan="3">'.dol_print_size($totalsize, 1, 1).'</td></tr>';
  143. print '</table>';
  144. print '</div>';
  145. print dol_get_fiche_end();
  146. $modulepart = 'member';
  147. $permissiontoadd = $user->hasRight('adherent', 'creer');
  148. $permtoedit = $user->hasRight('adherent', 'creer');
  149. $param = '&id='.$object->id;
  150. include DOL_DOCUMENT_ROOT.'/core/tpl/document_actions_post_headers.tpl.php';
  151. print "<br><br>";
  152. } else {
  153. dol_print_error($db);
  154. }
  155. } else {
  156. $langs->load("errors");
  157. print $langs->trans("ErrorRecordNotFound");
  158. }
  159. // End of page
  160. llxFooter();
  161. $db->close();