document.php 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  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 = GETPOST('id', 'int');
  36. $action = GETPOST('action', 'alpha');
  37. $confirm = GETPOST('confirm', 'alpha');
  38. // Security check
  39. $result = restrictedArea($user, 'adherent', $id);
  40. // Get parameters
  41. $sortfield = GETPOST("sortfield", 'alpha');
  42. $sortorder = GETPOST("sortorder", 'alpha');
  43. $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
  44. if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
  45. $offset = $conf->liste_limit * $page;
  46. $pageprev = $page - 1;
  47. $pagenext = $page + 1;
  48. if (!$sortorder) $sortorder = "ASC";
  49. if (!$sortfield) $sortfield = "name";
  50. $form = new Form($db);
  51. $object = new Adherent($db);
  52. $membert = new AdherentType($db);
  53. $result = $object->fetch($id);
  54. if ($result < 0)
  55. {
  56. dol_print_error($db);
  57. exit;
  58. }
  59. $upload_dir = $conf->adherent->dir_output."/".get_exdir(0, 0, 0, 1, $object, 'member');
  60. /*
  61. * Actions
  62. */
  63. include_once DOL_DOCUMENT_ROOT.'/core/actions_linkedfiles.inc.php';
  64. /*
  65. * View
  66. */
  67. $form = new Form($db);
  68. $title = $langs->trans("Member")." - ".$langs->trans("Documents");
  69. $helpurl = "EN:Module_Foundations|FR:Module_Adh&eacute;rents|ES:M&oacute;dulo_Miembros";
  70. llxHeader("", $title, $helpurl);
  71. if ($id > 0)
  72. {
  73. $result = $membert->fetch($object->typeid);
  74. if ($result > 0)
  75. {
  76. // Build file list
  77. $filearray = dol_dir_list($upload_dir, "files", 0, '', '(\.meta|_preview.*\.png)$', $sortfield, (strtolower($sortorder) == 'desc' ?SORT_DESC:SORT_ASC), 1);
  78. $totalsize = 0;
  79. foreach ($filearray as $key => $file)
  80. {
  81. $totalsize += $file['size'];
  82. }
  83. if (!empty($conf->notification->enabled))
  84. $langs->load("mails");
  85. $head = member_prepare_head($object);
  86. dol_fiche_head($head, 'document', $langs->trans("Member"), -1, 'user');
  87. $linkback = '<a href="'.DOL_URL_ROOT.'/adherents/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
  88. dol_banner_tab($object, 'rowid', $linkback);
  89. print '<div class="fichecenter">';
  90. print '<div class="underbanner clearboth"></div>';
  91. print '<table class="border tableforfield centpercent">';
  92. $linkback = '<a href="'.DOL_URL_ROOT.'/adherents/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
  93. // Login
  94. if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED))
  95. {
  96. print '<tr><td class="titlefield">'.$langs->trans("Login").' / '.$langs->trans("Id").'</td><td class="valeur">'.$object->login.'&nbsp;</td></tr>';
  97. }
  98. // Type
  99. print '<tr><td>'.$langs->trans("Type").'</td><td class="valeur">'.$membert->getNomUrl(1)."</td></tr>\n";
  100. // Morphy
  101. print '<tr><td class="titlefield">'.$langs->trans("MemberNature").'</td><td class="valeur" >'.$object->getmorphylib().'</td>';
  102. /*print '<td rowspan="'.$rowspan.'" class="center" valign="middle" width="25%">';
  103. print $form->showphoto('memberphoto',$object);
  104. print '</td>';*/
  105. print '</tr>';
  106. // Company
  107. print '<tr><td>'.$langs->trans("Company").'</td><td class="valeur">'.$object->company.'</td></tr>';
  108. // Civility
  109. print '<tr><td>'.$langs->trans("UserTitle").'</td><td class="valeur">'.$object->getCivilityLabel().'&nbsp;</td>';
  110. print '</tr>';
  111. // Number of Attached Files
  112. print '<tr><td>'.$langs->trans("NbOfAttachedFiles").'</td><td colspan="3">'.count($filearray).'</td></tr>';
  113. //Total Size Of Attached Files
  114. print '<tr><td>'.$langs->trans("TotalSizeOfAttachedFiles").'</td><td colspan="3">'.dol_print_size($totalsize, 1, 1).'</td></tr>';
  115. print '</table>';
  116. print '</div>';
  117. dol_fiche_end();
  118. $modulepart = 'member';
  119. $permission = $user->rights->adherent->creer;
  120. $permtoedit = $user->rights->adherent->creer;
  121. $param = '&id='.$object->id;
  122. include_once DOL_DOCUMENT_ROOT.'/core/tpl/document_actions_post_headers.tpl.php';
  123. print "<br><br>";
  124. }
  125. else
  126. {
  127. dol_print_error($db);
  128. }
  129. }
  130. else
  131. {
  132. $langs->load("errors");
  133. print $langs->trans("ErrorRecordNotFound");
  134. }
  135. // End of page
  136. llxFooter();
  137. $db->close();