info.php 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  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. require '../../main.inc.php';
  25. require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
  26. require_once DOL_DOCUMENT_ROOT.'/core/class/discount.class.php';
  27. require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
  28. require_once DOL_DOCUMENT_ROOT.'/core/lib/invoice.lib.php';
  29. if (!empty($conf->projet->enabled)) {
  30. include_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
  31. }
  32. // Load translation files required by the page
  33. $langs->loadLangs(array('companies', 'bills'));
  34. $id = GETPOST("facid", "int");
  35. $ref = GETPOST("ref", 'alpha');
  36. $object = new Facture($db);
  37. $extrafields = new ExtraFields($db);
  38. // Fetch optionals attributes and labels
  39. $extrafields->fetch_name_optionals_label($object->table_element);
  40. // Load object
  41. if ($id > 0 || !empty($ref)) {
  42. $ret = $object->fetch($id, $ref, '', '', (!empty($conf->global->INVOICE_USE_SITUATION) ? $conf->global->INVOICE_USE_SITUATION : 0));
  43. }
  44. // Security check
  45. $fieldid = (!empty($ref) ? 'ref' : 'rowid');
  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', $fieldid, $isdraft);
  51. /*
  52. * View
  53. */
  54. $form = new Form($db);
  55. $title = $langs->trans('InvoiceCustomer')." - ".$langs->trans('Info');
  56. $help_url = "EN:Customers_Invoices|FR:Factures_Clients|ES:Facturas_a_clientes";
  57. llxHeader('', $title, $help_url);
  58. if (empty($object->id)) {
  59. $langs->load('errors');
  60. echo '<div class="error">'.$langs->trans("ErrorRecordNotFound").'</div>';
  61. llxFooter();
  62. exit;
  63. }
  64. $object->fetch_thirdparty();
  65. $object->info($object->id);
  66. $head = facture_prepare_head($object);
  67. print dol_get_fiche_head($head, 'info', $langs->trans("InvoiceCustomer"), -1, 'bill');
  68. $totalpaid = $object->getSommePaiement();
  69. // Invoice content
  70. $linkback = '<a href="'.DOL_URL_ROOT.'/compta/facture/list.php?restore_lastsearch_values=1'.(!empty($socid) ? '&socid='.$socid : '').'">'.$langs->trans("BackToList").'</a>';
  71. $morehtmlref = '<div class="refidno">';
  72. // Ref customer
  73. $morehtmlref .= $form->editfieldkey("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', 0, 1);
  74. $morehtmlref .= $form->editfieldval("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', null, null, '', 1);
  75. // Thirdparty
  76. $morehtmlref .= '<br>'.$langs->trans('ThirdParty').' : '.$object->thirdparty->getNomUrl(1, 'customer');
  77. // Project
  78. if (!empty($conf->projet->enabled)) {
  79. $langs->load("projects");
  80. $morehtmlref .= '<br>'.$langs->trans('Project').' ';
  81. if ($user->rights->facture->creer) {
  82. if ($action != 'classify') {
  83. //$morehtmlref.='<a class="editfielda" href="' . $_SERVER['PHP_SELF'] . '?action=classify&token='.newToken().'&id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a> : ';
  84. $morehtmlref .= ' : ';
  85. }
  86. if ($action == 'classify') {
  87. //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1);
  88. $morehtmlref .= '<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">';
  89. $morehtmlref .= '<input type="hidden" name="action" value="classin">';
  90. $morehtmlref .= '<input type="hidden" name="token" value="'.newToken().'">';
  91. $morehtmlref .= $formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1);
  92. $morehtmlref .= '<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">';
  93. $morehtmlref .= '</form>';
  94. } else {
  95. $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1);
  96. }
  97. } else {
  98. if (!empty($object->fk_project)) {
  99. $proj = new Project($db);
  100. $proj->fetch($object->fk_project);
  101. $morehtmlref .= ' : '.$proj->getNomUrl(1);
  102. if ($proj->title) {
  103. $morehtmlref .= ' - '.$proj->title;
  104. }
  105. } else {
  106. $morehtmlref .= '';
  107. }
  108. }
  109. }
  110. $morehtmlref .= '</div>';
  111. $object->totalpaid = $totalpaid; // To give a chance to dol_banner_tab to use already paid amount to show correct status
  112. dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref, '', 0);
  113. print '<div class="fichecenter">';
  114. print '<div class="underbanner clearboth"></div>';
  115. print '<br>';
  116. print '<table class="centpercent"><tr><td>';
  117. dol_print_object_info($object);
  118. print '</td></tr></table>';
  119. print '</div>';
  120. print dol_get_fiche_end();
  121. // End of page
  122. llxFooter();
  123. $db->close();