note.php 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. <?php
  2. /* Copyright (C) 2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
  3. * Copyright (C) 2004-2008 Laurent Destailleur <eldy@users.sourceforge.net>
  4. * Copyright (C) 2005-2012 Regis Houssin <regis.houssin@inodbox.com>
  5. * Copyright (C) 2013 Florian Henry <florian.henry@open-concept.pro>
  6. * Copyright (C) 2016 Alexandre Spangaro <aspangaro@open-dsi.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/don/note.php
  23. * \ingroup donations
  24. * \brief Page to show a donation notes
  25. */
  26. // Load Dolibarr environment
  27. require '../main.inc.php';
  28. require_once DOL_DOCUMENT_ROOT.'/don/class/don.class.php';
  29. require_once DOL_DOCUMENT_ROOT.'/core/lib/donation.lib.php';
  30. require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
  31. if (isModEnabled('project')) {
  32. require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php';
  33. require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
  34. }
  35. // Load translation files required by the page
  36. $langs->loadLangs(array('companies', 'bills', 'donations'));
  37. $id = (GETPOST('id', 'int') ? GETPOST('id', 'int') : GETPOST('facid', 'int')); // For backward compatibility
  38. $ref = GETPOST('ref', 'alpha');
  39. $action = GETPOST('action', 'aZ09');
  40. $projectid = (GETPOST('projectid') ? GETPOST('projectid', 'int') : 0);
  41. $hookmanager->initHooks(array('donnote'));
  42. $object = new Don($db);
  43. if ($id > 0 || $ref) {
  44. $object->fetch($id, $ref);
  45. }
  46. // Security check
  47. $socid = 0;
  48. if ($user->socid) {
  49. $socid = $user->socid;
  50. }
  51. $result = restrictedArea($user, 'don', $object->id, '');
  52. $permissionnote = $user->rights->don->creer; // Used by the include of actions_setnotes.inc.php
  53. /*
  54. * Actions
  55. */
  56. $reshook = $hookmanager->executeHooks('doActions', array(), $object, $action); // Note that $action and $object may have been modified by some hooks
  57. if ($reshook < 0) {
  58. setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
  59. }
  60. if (empty($reshook)) {
  61. include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php'; // Must be include, not include_once
  62. }
  63. if ($action == 'classin' && $user->hasRight('don', 'creer')) {
  64. $object->fetch($id);
  65. $object->setProject($projectid);
  66. }
  67. /*
  68. * View
  69. */
  70. $title = $langs->trans('Donation')." - ".$langs->trans('Notes');
  71. $help_url = 'EN:Module_Donations|FR:Module_Dons|ES:M&oacute;dulo_Donaciones|DE:Modul_Spenden';
  72. llxHeader('', $title, $help_url);
  73. $form = new Form($db);
  74. if (isModEnabled('project')) {
  75. $formproject = new FormProjets($db);
  76. }
  77. if ($id > 0 || !empty($ref)) {
  78. $object = new Don($db);
  79. $object->fetch($id, $ref);
  80. $head = donation_prepare_head($object);
  81. print dol_get_fiche_head($head, 'note', $langs->trans("Donation"), -1, 'donation');
  82. $linkback = '<a href="'.DOL_URL_ROOT.'/don/list.php'.(!empty($socid) ? '?socid='.$socid : '').'">'.$langs->trans("BackToList").'</a>';
  83. $morehtmlref = '<div class="refidno">';
  84. // Project
  85. if (isModEnabled('project')) {
  86. $langs->load("projects");
  87. $morehtmlref .= $langs->trans('Project').' ';
  88. if ($user->hasRight('don', 'creer')) {
  89. if ($action != 'classify') {
  90. // $morehtmlref.='<a class="editfielda" href="' . $_SERVER['PHP_SELF'] . '?action=classify&token='.newToken().'&id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a> : ';
  91. }
  92. if ($action == 'classify') {
  93. //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1);
  94. $morehtmlref .= '<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">';
  95. $morehtmlref .= '<input type="hidden" name="action" value="classin">';
  96. $morehtmlref .= '<input type="hidden" name="token" value="'.newToken().'">';
  97. $morehtmlref .= $formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1);
  98. $morehtmlref .= '<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">';
  99. $morehtmlref .= '</form>';
  100. } else {
  101. $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1, '', 'maxwidth300');
  102. }
  103. } else {
  104. if (!empty($object->fk_project)) {
  105. $proj = new Project($db);
  106. $proj->fetch($object->fk_project);
  107. $morehtmlref .= ' : '.$proj->getNomUrl(1);
  108. if ($proj->title) {
  109. $morehtmlref .= ' - '.$proj->title;
  110. }
  111. } else {
  112. $morehtmlref .= '';
  113. }
  114. }
  115. }
  116. $morehtmlref .= '</div>';
  117. dol_banner_tab($object, 'rowid', $linkback, 1, 'rowid', 'ref', $morehtmlref);
  118. print '<div class="fichecenter">';
  119. print '<div class="underbanner clearboth"></div>';
  120. $cssclass = "titlefield";
  121. include DOL_DOCUMENT_ROOT.'/core/tpl/notes.tpl.php';
  122. print dol_get_fiche_end();
  123. }
  124. llxFooter();
  125. $db->close();