info.php 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. <?php
  2. /* Copyright (C) 2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
  3. * Copyright (C) 2004-2005 Laurent Destailleur <eldy@users.sourceforge.net>
  4. * Copyright (C) 2017 Ferran Marcet <fmarcet@2byte.es>
  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/compta/facture/info.php
  21. * \ingroup facture
  22. * \brief Page des informations d'une facture
  23. */
  24. // Load Dolibarr environment
  25. require '../../main.inc.php';
  26. require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
  27. require_once DOL_DOCUMENT_ROOT.'/core/class/discount.class.php';
  28. require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
  29. require_once DOL_DOCUMENT_ROOT.'/core/lib/invoice.lib.php';
  30. if (isModEnabled('project')) {
  31. include_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
  32. }
  33. // Load translation files required by the page
  34. $langs->loadLangs(array('companies', 'bills'));
  35. $id = GETPOST("facid", "int");
  36. $ref = GETPOST("ref", 'alpha');
  37. $object = new Facture($db);
  38. $extrafields = new ExtraFields($db);
  39. // Fetch optionals attributes and labels
  40. $extrafields->fetch_name_optionals_label($object->table_element);
  41. // Load object
  42. if ($id > 0 || !empty($ref)) {
  43. $ret = $object->fetch($id, $ref, '', '', (!empty($conf->global->INVOICE_USE_SITUATION) ? $conf->global->INVOICE_USE_SITUATION : 0));
  44. }
  45. // Security check
  46. if ($user->socid) {
  47. $socid = $user->socid;
  48. }
  49. $isdraft = (($object->statut == Facture::STATUS_DRAFT) ? 1 : 0);
  50. $result = restrictedArea($user, 'facture', $object->id, '', '', 'fk_soc', 'rowid', $isdraft);
  51. $usercancreate = $user->hasRight("facture", "creer");
  52. /*
  53. * View
  54. */
  55. $form = new Form($db);
  56. $title = $object->ref." - ".$langs->trans('Info');
  57. $help_url = "EN:Customers_Invoices|FR:Factures_Clients|ES:Facturas_a_clientes";
  58. llxHeader('', $title, $help_url);
  59. if (empty($object->id)) {
  60. $langs->load('errors');
  61. echo '<div class="error">'.$langs->trans("ErrorRecordNotFound").'</div>';
  62. llxFooter();
  63. exit;
  64. }
  65. $object->fetch_thirdparty();
  66. $object->info($object->id);
  67. $head = facture_prepare_head($object);
  68. print dol_get_fiche_head($head, 'info', $langs->trans("InvoiceCustomer"), -1, 'bill');
  69. $totalpaid = $object->getSommePaiement();
  70. // Invoice content
  71. $linkback = '<a href="'.DOL_URL_ROOT.'/compta/facture/list.php?restore_lastsearch_values=1'.(!empty($socid) ? '&socid='.$socid : '').'">'.$langs->trans("BackToList").'</a>';
  72. $morehtmlref = '<div class="refidno">';
  73. // Ref customer
  74. $morehtmlref .= $form->editfieldkey("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', 0, 1);
  75. $morehtmlref .= $form->editfieldval("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', null, null, '', 1);
  76. // Thirdparty
  77. $morehtmlref .= '<br>'.$object->thirdparty->getNomUrl(1, 'customer');
  78. // Project
  79. if (isModEnabled('project')) {
  80. $langs->load("projects");
  81. $morehtmlref .= '<br>';
  82. if (0) {
  83. $morehtmlref .= img_picto($langs->trans("Project"), 'project', 'class="pictofixedwidth"');
  84. if ($action != 'classify') {
  85. $morehtmlref .= '<a class="editfielda" href="'.$_SERVER['PHP_SELF'].'?action=classify&token='.newToken().'&id='.$object->id.'">'.img_edit($langs->transnoentitiesnoconv('SetProject')).'</a> ';
  86. }
  87. $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, ($action == 'classify' ? 'projectid' : 'none'), 0, 0, 0, 1, '', 'maxwidth300');
  88. } else {
  89. if (!empty($object->fk_project)) {
  90. $proj = new Project($db);
  91. $proj->fetch($object->fk_project);
  92. $morehtmlref .= $proj->getNomUrl(1);
  93. if ($proj->title) {
  94. $morehtmlref .= '<span class="opacitymedium"> - '.dol_escape_htmltag($proj->title).'</span>';
  95. }
  96. }
  97. }
  98. }
  99. $morehtmlref .= '</div>';
  100. $object->totalpaid = $totalpaid; // To give a chance to dol_banner_tab to use already paid amount to show correct status
  101. dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref, '', 0);
  102. print '<div class="fichecenter">';
  103. print '<div class="underbanner clearboth"></div>';
  104. print '<br>';
  105. print '<table class="centpercent"><tr><td>';
  106. dol_print_object_info($object);
  107. print '</td></tr></table>';
  108. print '</div>';
  109. print dol_get_fiche_end();
  110. // End of page
  111. llxFooter();
  112. $db->close();