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. require '../main.inc.php';
  27. require_once DOL_DOCUMENT_ROOT.'/core/lib/member.lib.php';
  28. require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
  29. require_once DOL_DOCUMENT_ROOT.'/core/lib/images.lib.php';
  30. require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
  31. require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.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", "other"));
  35. $id = GETPOSTISSET('id') ? GETPOST('id', 'int') : GETPOST('rowid', 'int');
  36. $ref = GETPOST('ref', 'alphanohtml');
  37. $action = GETPOST('action', 'aZ09');
  38. $confirm = GETPOST('confirm', 'alpha');
  39. // Get parameters
  40. $limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit;
  41. $sortfield = GETPOST('sortfield', 'aZ09comma');
  42. $sortorder = GETPOST('sortorder', 'aZ09comma');
  43. $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
  44. if (empty($page) || $page == -1) {
  45. $page = 0;
  46. } // If $page is not defined, or '' or -1
  47. $offset = $limit * $page;
  48. $pageprev = $page - 1;
  49. $pagenext = $page + 1;
  50. if (!$sortorder) {
  51. $sortorder = "ASC";
  52. }
  53. if (!$sortfield) {
  54. $sortfield = "name";
  55. }
  56. $object = new Adherent($db);
  57. $membert = new AdherentType($db);
  58. $result = $object->fetch($id, $ref);
  59. if ($result < 0) {
  60. dol_print_error($db);
  61. exit;
  62. }
  63. $upload_dir = $conf->adherent->dir_output."/".get_exdir(0, 0, 0, 1, $object, 'member');
  64. // Fetch object
  65. if ($id > 0 || !empty($ref)) {
  66. // Load member
  67. $result = $object->fetch($id, $ref);
  68. // Define variables to know what current user can do on users
  69. $canadduser = ($user->admin || $user->rights->user->user->creer);
  70. // Define variables to know what current user can do on properties of user linked to edited member
  71. if ($object->user_id) {
  72. // $User is the user who edits, $object->user_id is the id of the related user in the edited member
  73. $caneditfielduser = ((($user->id == $object->user_id) && $user->rights->user->self->creer)
  74. || (($user->id != $object->user_id) && $user->rights->user->user->creer));
  75. $caneditpassworduser = ((($user->id == $object->user_id) && $user->rights->user->self->password)
  76. || (($user->id != $object->user_id) && $user->rights->user->user->password));
  77. }
  78. }
  79. // Define variables to determine what the current user can do on the members
  80. $canaddmember = $user->rights->adherent->creer;
  81. // Define variables to determine what the current user can do on the properties of a member
  82. if ($id) {
  83. $caneditfieldmember = $user->rights->adherent->creer;
  84. }
  85. $permissiontoadd = $canaddmember;
  86. // Security check
  87. $result = restrictedArea($user, 'adherent', $object->id, '', '', 'socid', 'rowid', 0);
  88. /*
  89. * Actions
  90. */
  91. include DOL_DOCUMENT_ROOT.'/core/actions_linkedfiles.inc.php';
  92. /*
  93. * View
  94. */
  95. $form = new Form($db);
  96. $title = $langs->trans("Member")." - ".$langs->trans("Documents");
  97. $help_url = "EN:Module_Foundations|FR:Module_Adh&eacute;rents|ES:M&oacute;dulo_Miembros|DE:Modul_Mitglieder";
  98. llxHeader("", $title, $help_url);
  99. if ($id > 0) {
  100. $result = $membert->fetch($object->typeid);
  101. if ($result > 0) {
  102. // Build file list
  103. $filearray = dol_dir_list($upload_dir, "files", 0, '', '(\.meta|_preview.*\.png)$', $sortfield, (strtolower($sortorder) == 'desc' ?SORT_DESC:SORT_ASC), 1);
  104. $totalsize = 0;
  105. foreach ($filearray as $key => $file) {
  106. $totalsize += $file['size'];
  107. }
  108. if (!empty($conf->notification->enabled)) {
  109. $langs->load("mails");
  110. }
  111. $head = member_prepare_head($object);
  112. print dol_get_fiche_head($head, 'document', $langs->trans("Member"), -1, 'user');
  113. $linkback = '<a href="'.DOL_URL_ROOT.'/adherents/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
  114. $morehtmlref = '<a href="'.DOL_URL_ROOT.'/adherents/vcard.php?id='.$object->id.'" class="refid">';
  115. $morehtmlref .= img_picto($langs->trans("Download").' '.$langs->trans("VCard"), 'vcard.png', 'class="valignmiddle marginleftonly paddingrightonly"');
  116. $morehtmlref .= '</a>';
  117. dol_banner_tab($object, 'rowid', $linkback, 1, 'rowid', 'ref', $morehtmlref);
  118. print '<div class="fichecenter">';
  119. print '<div class="underbanner clearboth"></div>';
  120. print '<table class="border tableforfield centpercent">';
  121. $linkback = '<a href="'.DOL_URL_ROOT.'/adherents/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
  122. // Login
  123. if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED)) {
  124. print '<tr><td class="titlefield">'.$langs->trans("Login").' / '.$langs->trans("Id").'</td><td class="valeur">'.dol_escape_htmltag($object->login).'</td></tr>';
  125. }
  126. // Type
  127. print '<tr><td>'.$langs->trans("Type").'</td><td class="valeur">'.$membert->getNomUrl(1)."</td></tr>\n";
  128. // Morphy
  129. print '<tr><td class="titlefield">'.$langs->trans("MemberNature").'</td><td class="valeur" >'.$object->getmorphylib().'</td>';
  130. /*print '<td rowspan="'.$rowspan.'" class="center" valign="middle" width="25%">';
  131. print $form->showphoto('memberphoto',$object);
  132. print '</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->rights->adherent->creer;
  148. $permtoedit = $user->rights->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();