note.php 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  1. <?php
  2. /* Copyright (C) 2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
  3. * Copyright (C) 2004-2014 Laurent Destailleur <eldy@users.sourceforge.net>
  4. * Copyright (C) 2015 Frederic France <frederic.france@free.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 <https://www.gnu.org/licenses/>.
  18. */
  19. /**
  20. * \file htdocs/adherents/note.php
  21. * \ingroup member
  22. * \brief Tab for note of a member
  23. */
  24. // Load Dolibarr environment
  25. require '../main.inc.php';
  26. require_once DOL_DOCUMENT_ROOT.'/core/lib/member.lib.php';
  27. require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php';
  28. require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent_type.class.php';
  29. // Load translation files required by the page
  30. $langs->loadLangs(array("companies", "members", "bills"));
  31. // Get parameters
  32. $action = GETPOST('action', 'aZ09');
  33. $id = GETPOST('id', 'int');
  34. $ref = GETPOST('ref', 'alphanohtml');
  35. // Initialize objects
  36. $object = new Adherent($db);
  37. $result = $object->fetch($id);
  38. if ($result > 0) {
  39. $adht = new AdherentType($db);
  40. $result = $adht->fetch($object->typeid);
  41. }
  42. $permissionnote = $user->hasRight('adherent', 'creer'); // Used by the include of actions_setnotes.inc.php
  43. // Fetch object
  44. if ($id > 0 || !empty($ref)) {
  45. // Load member
  46. $result = $object->fetch($id, $ref);
  47. // Define variables to know what current user can do on users
  48. $canadduser = ($user->admin || $user->hasRight('user', 'user', 'creer'));
  49. // Define variables to know what current user can do on properties of user linked to edited member
  50. if ($object->user_id) {
  51. // $User is the user who edits, $object->user_id is the id of the related user in the edited member
  52. $caneditfielduser = ((($user->id == $object->user_id) && $user->hasRight('user', 'self', 'creer'))
  53. || (($user->id != $object->user_id) && $user->hasRight('user', 'user', 'creer')));
  54. $caneditpassworduser = ((($user->id == $object->user_id) && $user->hasRight('user', 'self', 'password'))
  55. || (($user->id != $object->user_id) && $user->hasRight('user', 'user', 'password')));
  56. }
  57. }
  58. // Define variables to determine what the current user can do on the members
  59. $canaddmember = $user->hasRight('adherent', 'creer');
  60. // Define variables to determine what the current user can do on the properties of a member
  61. if ($id) {
  62. $caneditfieldmember = $user->hasRight('adherent', 'creer');
  63. }
  64. $hookmanager->initHooks(array('membernote'));
  65. // Security check
  66. $result = restrictedArea($user, 'adherent', $object->id, '', '', 'socid', 'rowid', 0);
  67. /*
  68. * Actions
  69. */
  70. $parameters = array();
  71. $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
  72. if ($reshook < 0) {
  73. setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
  74. }
  75. if (empty($reshook)) {
  76. include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php'; // Must be include, not include_once
  77. }
  78. /*
  79. * View
  80. */
  81. $title = $langs->trans("Member")." - ".$langs->trans("Note");
  82. $help_url = "EN:Module_Foundations|FR:Module_Adh&eacute;rents|ES:M&oacute;dulo_Miembros|DE:Modul_Mitglieder";
  83. llxHeader("", $title, $help_url);
  84. $form = new Form($db);
  85. if ($id) {
  86. $head = member_prepare_head($object);
  87. print dol_get_fiche_head($head, 'note', $langs->trans("Member"), -1, 'user');
  88. print '<form method="POST" action="'.$_SERVER['PHP_SELF'].'">';
  89. print '<input type="hidden" name="token" value="'.newToken().'">';
  90. $linkback = '<a href="'.DOL_URL_ROOT.'/adherents/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
  91. $morehtmlref = '<a href="'.DOL_URL_ROOT.'/adherents/vcard.php?id='.$object->id.'" class="refid">';
  92. $morehtmlref .= img_picto($langs->trans("Download").' '.$langs->trans("VCard"), 'vcard.png', 'class="valignmiddle marginleftonly paddingrightonly"');
  93. $morehtmlref .= '</a>';
  94. dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'ref', $morehtmlref);
  95. print '<div class="fichecenter">';
  96. print '<div class="underbanner clearboth"></div>';
  97. print '<table class="border centpercent tableforfield">';
  98. // Login
  99. if (!getDolGlobalString('ADHERENT_LOGIN_NOT_REQUIRED')) {
  100. print '<tr><td class="titlefield">'.$langs->trans("Login").' / '.$langs->trans("Id").'</td><td class="valeur">'.dol_escape_htmltag($object->login).'</td></tr>';
  101. }
  102. // Type
  103. print '<tr><td>'.$langs->trans("Type").'</td>';
  104. print '<td class="valeur">'.$adht->getNomUrl(1)."</td></tr>\n";
  105. // Morphy
  106. print '<tr><td class="titlefield">'.$langs->trans("MemberNature").'</td>';
  107. print '<td class="valeur" >'.$object->getmorphylib('', 1).'</td>';
  108. print '</tr>';
  109. // Company
  110. print '<tr><td>'.$langs->trans("Company").'</td><td class="valeur">'.dol_escape_htmltag($object->company).'</td></tr>';
  111. // Civility
  112. print '<tr><td>'.$langs->trans("UserTitle").'</td><td class="valeur">'.$object->getCivilityLabel().'</td>';
  113. print '</tr>';
  114. print "</table>";
  115. print '</div>';
  116. $cssclass = 'titlefield';
  117. $permission = $user->hasRight('adherent', 'creer'); // Used by the include of notes.tpl.php
  118. include DOL_DOCUMENT_ROOT.'/core/tpl/notes.tpl.php';
  119. print dol_get_fiche_end();
  120. }
  121. // End of page
  122. llxFooter();
  123. $db->close();