info.php 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. <?php
  2. /* Copyright (C) 2014-2023 Alexandre Spangaro <aspangaro@easya.solutions>
  3. * Copyright (C) 2017 Ferran Marcet <fmarcet@2byte.es>
  4. *
  5. * This program is free software; you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation; either version 3 of the License, or
  8. * (at your option) any later version.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with this program. If not, see <https://www.gnu.org/licenses/>.
  17. */
  18. /**
  19. * \file htdocs/loan/info.php
  20. * \ingroup loan
  21. * \brief Page with info about loan
  22. */
  23. // Load Dolibarr environment
  24. require '../main.inc.php';
  25. require_once DOL_DOCUMENT_ROOT.'/loan/class/loan.class.php';
  26. require_once DOL_DOCUMENT_ROOT.'/core/lib/loan.lib.php';
  27. require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
  28. if (isModEnabled('project')) {
  29. require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
  30. }
  31. // Load translation files required by the page
  32. $langs->loadLangs(array("compta", "bills", "loan"));
  33. $id = GETPOST('id', 'int');
  34. $action = GETPOST('action', 'aZ09');
  35. // Security check
  36. $socid = GETPOST('socid', 'int');
  37. if ($user->socid) {
  38. $socid = $user->socid;
  39. }
  40. $result = restrictedArea($user, 'loan', $id, '', '');
  41. /*
  42. * View
  43. */
  44. $form = new Form($db);
  45. $title = $langs->trans("Loan").' - '.$langs->trans("Info");
  46. $help_url = 'EN:Module_Loan|FR:Module_Emprunt';
  47. llxHeader("", $title, $help_url);
  48. $object = new Loan($db);
  49. $object->fetch($id);
  50. $object->info($id);
  51. $head = loan_prepare_head($object);
  52. print dol_get_fiche_head($head, 'info', $langs->trans("Loan"), -1, 'money-bill-alt');
  53. $morehtmlref = '<div class="refidno">';
  54. // Ref loan
  55. $morehtmlref .= $form->editfieldkey("Label", 'label', $object->label, $object, 0, 'string', '', 0, 1);
  56. $morehtmlref .= $form->editfieldval("Label", 'label', $object->label, $object, 0, 'string', '', null, null, '', 1);
  57. // Project
  58. if (isModEnabled('project')) {
  59. $langs->load("projects");
  60. $morehtmlref .= '<br>'.$langs->trans('Project').' : ';
  61. if ($user->hasRight('loan', 'write')) {
  62. //if ($action != 'classify')
  63. // $morehtmlref .= '<a class="editfielda" href="' . $_SERVER['PHP_SELF'] . '?action=classify&token='.newToken().'&id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a> : ';
  64. if ($action == 'classify') {
  65. // $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1);
  66. $morehtmlref .= '<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">';
  67. $morehtmlref .= '<input type="hidden" name="action" value="classin">';
  68. $morehtmlref .= '<input type="hidden" name="token" value="'.newToken().'">';
  69. $morehtmlref .= $formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1);
  70. $morehtmlref .= '<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">';
  71. $morehtmlref .= '</form>';
  72. } else {
  73. $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1, '', 'maxwidth300');
  74. }
  75. } else {
  76. if (!empty($object->fk_project)) {
  77. $proj = new Project($db);
  78. $proj->fetch($object->fk_project);
  79. $morehtmlref .= ' : '.$proj->getNomUrl(1);
  80. if ($proj->title) {
  81. $morehtmlref .= ' - '.$proj->title;
  82. }
  83. } else {
  84. $morehtmlref .= '';
  85. }
  86. }
  87. }
  88. $morehtmlref .= '</div>';
  89. $linkback = '<a href="'.DOL_URL_ROOT.'/loan/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
  90. dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'ref', $morehtmlref, '', 0, '', $morehtmlright);
  91. print '<div class="fichecenter">';
  92. print '<div class="underbanner clearboth"></div>';
  93. print '<br>';
  94. print '<table width="100%"><tr><td>';
  95. dol_print_object_info($object);
  96. print '</td></tr></table>';
  97. print '</div>';
  98. // End of page
  99. llxFooter();
  100. $db->close();