note.php 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  1. <?php
  2. /* Copyright (C) 2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
  3. * Copyright (C) 2004-2016 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) 2017 Ferran Marcet <fmarcet@2byte.es>
  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/compta/facture/note.php
  23. * \ingroup facture
  24. * \brief Fiche de notes sur une facture
  25. */
  26. // Load Dolibarr environment
  27. require '../../main.inc.php';
  28. require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
  29. require_once DOL_DOCUMENT_ROOT.'/core/class/discount.class.php';
  30. require_once DOL_DOCUMENT_ROOT.'/core/lib/invoice.lib.php';
  31. if (isModEnabled('project')) {
  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'));
  36. $id = (GETPOST('id', 'int') ?GETPOST('id', 'int') : GETPOST('facid', 'int')); // For backward compatibility
  37. $ref = GETPOST('ref', 'alpha');
  38. $socid = GETPOST('socid', 'int');
  39. $action = GETPOST('action', 'aZ09');
  40. $object = new Facture($db);
  41. // Load object
  42. if ($id > 0 || !empty($ref)) {
  43. $object->fetch($id, $ref, '', '', (getDolGlobalString('INVOICE_USE_SITUATION') ? $conf->global->INVOICE_USE_SITUATION : 0));
  44. }
  45. $permissionnote = $user->hasRight('facture', 'creer'); // Used by the include of actions_setnotes.inc.php
  46. // Security check
  47. $socid = 0;
  48. if ($user->socid) {
  49. $socid = $user->socid;
  50. }
  51. $hookmanager->initHooks(array('invoicenote'));
  52. $result = restrictedArea($user, 'facture', $id, '');
  53. $usercancreate = $user->hasRight("facture", "creer");
  54. /*
  55. * Actions
  56. */
  57. $reshook = $hookmanager->executeHooks('doActions', array(), $object, $action); // Note that $action and $object may have been modified by some hooks
  58. if ($reshook < 0) {
  59. setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
  60. }
  61. if (empty($reshook)) {
  62. include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php'; // Must be include, not include_once
  63. }
  64. /*
  65. * View
  66. */
  67. $form = new Form($db);
  68. if (empty($object->id)) {
  69. $title = $object->ref." - ".$langs->trans('Notes');
  70. } else {
  71. $title = $langs->trans('Notes');
  72. }
  73. $helpurl = "EN:Customers_Invoices|FR:Factures_Clients|ES:Facturas_a_clientes";
  74. llxHeader('', $title, $helpurl);
  75. if (empty($object->id)) {
  76. $langs->load('errors');
  77. echo '<div class="error">'.$langs->trans("ErrorRecordNotFound").'</div>';
  78. llxFooter();
  79. exit;
  80. }
  81. if ($id > 0 || !empty($ref)) {
  82. $object = new Facture($db);
  83. $object->fetch($id, $ref);
  84. $object->fetch_thirdparty();
  85. $head = facture_prepare_head($object);
  86. $totalpaid = $object->getSommePaiement();
  87. print dol_get_fiche_head($head, 'note', $langs->trans("InvoiceCustomer"), -1, 'bill');
  88. // Invoice content
  89. $linkback = '<a href="'.DOL_URL_ROOT.'/compta/facture/list.php?restore_lastsearch_values=1'.(!empty($socid) ? '&socid='.$socid : '').'">'.$langs->trans("BackToList").'</a>';
  90. $morehtmlref = '<div class="refidno">';
  91. // Ref customer
  92. $morehtmlref .= $form->editfieldkey("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', 0, 1);
  93. $morehtmlref .= $form->editfieldval("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', null, null, '', 1);
  94. // Thirdparty
  95. $morehtmlref .= '<br>'.$object->thirdparty->getNomUrl(1, 'customer');
  96. // Project
  97. if (isModEnabled('project')) {
  98. $langs->load("projects");
  99. $morehtmlref .= '<br>';
  100. if (0) {
  101. $morehtmlref .= img_picto($langs->trans("Project"), 'project', 'class="pictofixedwidth"');
  102. if ($action != 'classify') {
  103. $morehtmlref .= '<a class="editfielda" href="'.$_SERVER['PHP_SELF'].'?action=classify&token='.newToken().'&id='.$object->id.'">'.img_edit($langs->transnoentitiesnoconv('SetProject')).'</a> ';
  104. }
  105. $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, ($action == 'classify' ? 'projectid' : 'none'), 0, 0, 0, 1, '', 'maxwidth300');
  106. } else {
  107. if (!empty($object->fk_project)) {
  108. $proj = new Project($db);
  109. $proj->fetch($object->fk_project);
  110. $morehtmlref .= $proj->getNomUrl(1);
  111. if ($proj->title) {
  112. $morehtmlref .= '<span class="opacitymedium"> - '.dol_escape_htmltag($proj->title).'</span>';
  113. }
  114. }
  115. }
  116. }
  117. $morehtmlref .= '</div>';
  118. $object->totalpaid = $totalpaid; // To give a chance to dol_banner_tab to use already paid amount to show correct status
  119. dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref, '', 0);
  120. print '<div class="fichecenter">';
  121. print '<div class="underbanner clearboth"></div>';
  122. $cssclass = "titlefield";
  123. include DOL_DOCUMENT_ROOT.'/core/tpl/notes.tpl.php';
  124. print dol_get_fiche_end();
  125. }
  126. // End of page
  127. llxFooter();
  128. $db->close();