PageRenderTime 64ms CodeModel.GetById 15ms RepoModel.GetById 0ms app.codeStats 0ms

/htdocs/don/note.php

http://github.com/Dolibarr/dolibarr
PHP | 149 lines | 87 code | 27 blank | 35 comment | 21 complexity | 0ec18586faae7f52b21a1b2a77366aa1 MD5 | raw file
Possible License(s): GPL-2.0, AGPL-3.0, LGPL-2.0, CC-BY-SA-4.0, BSD-3-Clause, MPL-2.0-no-copyleft-exception, LGPL-3.0, GPL-3.0, LGPL-2.1, MIT
  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. require '../main.inc.php';
  27. require_once DOL_DOCUMENT_ROOT.'/don/class/don.class.php';
  28. require_once DOL_DOCUMENT_ROOT.'/core/lib/donation.lib.php';
  29. require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
  30. if (!empty($conf->projet->enabled)) {
  31. require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php';
  32. require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
  33. }
  34. // Load translation files required by the page
  35. $langs->loadLangs(array("companies", "bills", "donations"));
  36. $id = (GETPOST('id', 'int') ?GETPOST('id', 'int') : GETPOST('facid', 'int')); // For backward compatibility
  37. $ref = GETPOST('ref', 'alpha');
  38. $action = GETPOST('action', 'aZ09');
  39. $projectid = (GETPOST('projectid') ? GETPOST('projectid', 'int') : 0);
  40. // Security check
  41. $socid = 0;
  42. if ($user->socid) {
  43. $socid = $user->socid;
  44. }
  45. $hookmanager->initHooks(array('donnote'));
  46. $result = restrictedArea($user, 'don', $id, '');
  47. $object = new Don($db);
  48. $object->fetch($id);
  49. $permissionnote = $user->rights->don->creer; // Used by the include of actions_setnotes.inc.php
  50. /*
  51. * Actions
  52. */
  53. $reshook = $hookmanager->executeHooks('doActions', array(), $object, $action); // Note that $action and $object may have been modified by some hooks
  54. if ($reshook < 0) {
  55. setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
  56. }
  57. if (empty($reshook)) {
  58. include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php'; // Must be include, not include_once
  59. }
  60. if ($action == 'classin' && $user->rights->don->creer) {
  61. $object->fetch($id);
  62. $object->setProject($projectid);
  63. }
  64. /*
  65. * View
  66. */
  67. $title = $langs->trans('Donation')." - ".$langs->trans('Notes');
  68. $help_url = 'EN:Module_Donations|FR:Module_Dons|ES:M&oacute;dulo_Donaciones|DE:Modul_Spenden';
  69. llxHeader('', $title, $help_url);
  70. $form = new Form($db);
  71. if (!empty($conf->projet->enabled)) {
  72. $formproject = new FormProjets($db);
  73. }
  74. if ($id > 0 || !empty($ref)) {
  75. $object = new Don($db);
  76. $object->fetch($id, $ref);
  77. $head = donation_prepare_head($object);
  78. print dol_get_fiche_head($head, 'note', $langs->trans("Donation"), -1, 'donation');
  79. $linkback = '<a href="'.DOL_URL_ROOT.'/don/list.php'.(!empty($socid) ? '?socid='.$socid : '').'">'.$langs->trans("BackToList").'</a>';
  80. $morehtmlref = '<div class="refidno">';
  81. // Project
  82. if (!empty($conf->projet->enabled)) {
  83. $langs->load("projects");
  84. $morehtmlref .= $langs->trans('Project').' ';
  85. if ($user->rights->don->creer) {
  86. if ($action != 'classify') {
  87. // $morehtmlref.='<a class="editfielda" href="' . $_SERVER['PHP_SELF'] . '?action=classify&token='.newToken().'&id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a> : ';
  88. }
  89. if ($action == 'classify') {
  90. //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1);
  91. $morehtmlref .= '<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">';
  92. $morehtmlref .= '<input type="hidden" name="action" value="classin">';
  93. $morehtmlref .= '<input type="hidden" name="token" value="'.newToken().'">';
  94. $morehtmlref .= $formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1);
  95. $morehtmlref .= '<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">';
  96. $morehtmlref .= '</form>';
  97. } else {
  98. $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1);
  99. }
  100. } else {
  101. if (!empty($object->fk_project)) {
  102. $proj = new Project($db);
  103. $proj->fetch($object->fk_project);
  104. $morehtmlref .= ' : '.$proj->getNomUrl(1);
  105. if ($proj->title) {
  106. $morehtmlref .= ' - '.$proj->title;
  107. }
  108. } else {
  109. $morehtmlref .= '';
  110. }
  111. }
  112. }
  113. $morehtmlref .= '</div>';
  114. dol_banner_tab($object, 'rowid', $linkback, 1, 'rowid', 'ref', $morehtmlref);
  115. print '<div class="fichecenter">';
  116. print '<div class="underbanner clearboth"></div>';
  117. $cssclass = "titlefield";
  118. include DOL_DOCUMENT_ROOT.'/core/tpl/notes.tpl.php';
  119. print dol_get_fiche_end();
  120. }
  121. llxFooter();
  122. $db->close();