info.php 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  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. require_once DOL_DOCUMENT_ROOT . '/custom/bbus/class/bbticketcounter.class.php';
  34. // Load translation files required by the page
  35. $langs->loadLangs(array('companies', 'bills'));
  36. $id = GETPOST("facid", "int");
  37. $ref = GETPOST("ref", 'alpha');
  38. $Bbticketcounter = new Bbticketcounter();
  39. $object = new Facture($db);
  40. $extrafields = new ExtraFields($db);
  41. // Fetch optionals attributes and labels
  42. $extrafields->fetch_name_optionals_label($object->table_element);
  43. // Load object
  44. if ($id > 0 || !empty($ref)) {
  45. $ret = $object->fetch($id, $ref, '', '', (!empty($conf->global->INVOICE_USE_SITUATION) ? $conf->global->INVOICE_USE_SITUATION : 0));
  46. }
  47. // Security check
  48. if ($user->socid) {
  49. $socid = $user->socid;
  50. }
  51. $isdraft = (($object->statut == Facture::STATUS_DRAFT) ? 1 : 0);
  52. $result = restrictedArea($user, 'facture', $object->id, '', '', 'fk_soc', 'rowid', $isdraft);
  53. $usercancreate = $user->hasRight("facture", "creer");
  54. /*
  55. * View
  56. */
  57. $form = new Form($db);
  58. $title = $object->ref." - ".$langs->trans('Info');
  59. $help_url = "EN:Customers_Invoices|FR:Factures_Clients|ES:Facturas_a_clientes";
  60. llxHeader('', $title, $help_url);
  61. if (empty($object->id)) {
  62. $langs->load('errors');
  63. echo '<div class="error">'.$langs->trans("ErrorRecordNotFound").'</div>';
  64. llxFooter();
  65. exit;
  66. }
  67. $object->fetch_thirdparty();
  68. $object->info($object->id);
  69. $head = facture_prepare_head($object);
  70. print dol_get_fiche_head($head, 'info', $langs->trans("InvoiceCustomer"), -1, 'bill');
  71. print '<input type="hidden" id="printedTicketsNumber" name="printedticketsnumber" value="' . $Bbticketcounter->numberOfPrintedTickets . '">';
  72. $totalpaid = $object->getSommePaiement();
  73. // Invoice content
  74. $linkback = '<a href="'.DOL_URL_ROOT.'/compta/facture/list.php?restore_lastsearch_values=1'.(!empty($socid) ? '&socid='.$socid : '').'">'.$langs->trans("BackToList").'</a>';
  75. $morehtmlref = '<div class="refidno">';
  76. // Ref customer
  77. $morehtmlref .= $form->editfieldkey("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', 0, 1);
  78. $morehtmlref .= $form->editfieldval("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', null, null, '', 1);
  79. // Thirdparty
  80. $morehtmlref .= '<br>'.$object->thirdparty->getNomUrl(1, 'customer');
  81. // Project
  82. if (isModEnabled('project')) {
  83. $langs->load("projects");
  84. $morehtmlref .= '<br>';
  85. if (0) {
  86. $morehtmlref .= img_picto($langs->trans("Project"), 'project', 'class="pictofixedwidth"');
  87. if ($action != 'classify') {
  88. $morehtmlref .= '<a class="editfielda" href="'.$_SERVER['PHP_SELF'].'?action=classify&token='.newToken().'&id='.$object->id.'">'.img_edit($langs->transnoentitiesnoconv('SetProject')).'</a> ';
  89. }
  90. $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, ($action == 'classify' ? 'projectid' : 'none'), 0, 0, 0, 1, '', 'maxwidth300');
  91. } else {
  92. if (!empty($object->fk_project)) {
  93. $proj = new Project($db);
  94. $proj->fetch($object->fk_project);
  95. $morehtmlref .= $proj->getNomUrl(1);
  96. if ($proj->title) {
  97. $morehtmlref .= '<span class="opacitymedium"> - '.dol_escape_htmltag($proj->title).'</span>';
  98. }
  99. }
  100. }
  101. }
  102. $morehtmlref .= '</div>';
  103. $object->totalpaid = $totalpaid; // To give a chance to dol_banner_tab to use already paid amount to show correct status
  104. dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref, '', 0);
  105. print '<div class="fichecenter">';
  106. print '<div class="underbanner clearboth"></div>';
  107. print '<br>';
  108. print '<table class="centpercent"><tr><td>';
  109. dol_print_object_info($object);
  110. print '</td></tr></table>';
  111. print '</div>';
  112. print dol_get_fiche_end();
  113. // End of page
  114. llxFooter();
  115. $db->close();
  116. ?>
  117. <link rel="stylesheet" type="text/css" href="/custom/bbus/views/bbus.css">
  118. <script src="/custom/bbus/js/bbus.js"></script>;