info.php 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. <?php
  2. /* Copyright (C) 2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
  3. * Copyright (C) 2004-2006 Laurent Destailleur <eldy@users.sourceforge.net>
  4. * Copyright (C) 2005-2009 Regis Houssin <regis.houssin@inodbox.com>
  5. * Copyright (C) 2016 Alexandre Spangaro <aspangaro@open-dsi.fr>
  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/fourn/facture/info.php
  23. * \ingroup facture, fournisseur
  24. * \brief Page des informations d'une facture fournisseur
  25. */
  26. require '../../main.inc.php';
  27. require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.class.php';
  28. require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php';
  29. require_once DOL_DOCUMENT_ROOT.'/core/lib/fourn.lib.php';
  30. require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
  31. if (!empty($conf->projet->enabled)) {
  32. require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
  33. }
  34. $langs->loadLangs(array("companies", "bills"));
  35. $id = GETPOST("facid", 'int') ?GETPOST("facid", 'int') : GETPOST("id", 'int');
  36. $ref = GETPOST("ref", 'alpha');
  37. // Security check
  38. if ($user->socid) {
  39. $socid = $user->socid;
  40. }
  41. $result = restrictedArea($user, 'fournisseur', $id, 'facture_fourn', 'facture');
  42. $hookmanager->initHooks(array('invoicesuppliercardinfo'));
  43. $object = new FactureFournisseur($db);
  44. /*
  45. * View
  46. */
  47. $form = new Form($db);
  48. $title = $langs->trans('SupplierInvoice')." - ".$langs->trans('Info');
  49. $helpurl = "EN:Module_Suppliers_Invoices|FR:Module_Fournisseurs_Factures|ES:Módulo_Facturas_de_proveedores";
  50. llxHeader('', $title, $helpurl);
  51. $object->fetch($id, $ref);
  52. $object->fetch_thirdparty();
  53. $object->info($object->id);
  54. $alreadypaid = $object->getSommePaiement();
  55. $head = facturefourn_prepare_head($object);
  56. $titre = $langs->trans('SupplierInvoice');
  57. print dol_get_fiche_head($head, 'info', $langs->trans('SupplierInvoice'), -1, 'supplier_invoice');
  58. $linkback = '<a href="'.DOL_URL_ROOT.'/fourn/facture/list.php?restore_lastsearch_values=1'.(!empty($socid) ? '&socid='.$socid : '').'">'.$langs->trans("BackToList").'</a>';
  59. $morehtmlref = '<div class="refidno">';
  60. // Ref supplier
  61. $morehtmlref .= $form->editfieldkey("RefSupplier", 'ref_supplier', $object->ref_supplier, $object, 0, 'string', '', 0, 1);
  62. $morehtmlref .= $form->editfieldval("RefSupplier", 'ref_supplier', $object->ref_supplier, $object, 0, 'string', '', null, null, '', 1);
  63. // Thirdparty
  64. $morehtmlref .= '<br>'.$langs->trans('ThirdParty').' : '.$object->thirdparty->getNomUrl(1);
  65. if (empty($conf->global->MAIN_DISABLE_OTHER_LINK) && $object->thirdparty->id > 0) {
  66. $morehtmlref .= ' (<a href="'.DOL_URL_ROOT.'/fourn/facture/list.php?socid='.$object->thirdparty->id.'&search_company='.urlencode($object->thirdparty->name).'">'.$langs->trans("OtherBills").'</a>)';
  67. }
  68. // Project
  69. if (!empty($conf->projet->enabled)) {
  70. $langs->load("projects");
  71. $morehtmlref .= '<br>'.$langs->trans('Project').' ';
  72. if ($user->rights->facture->creer) {
  73. if ($action != 'classify') {
  74. //$morehtmlref.='<a class="editfielda" href="' . $_SERVER['PHP_SELF'] . '?action=classify&token='.newToken().'&id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a> : ';
  75. $morehtmlref .= ' : ';
  76. }
  77. if ($action == 'classify') {
  78. //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1);
  79. $morehtmlref .= '<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">';
  80. $morehtmlref .= '<input type="hidden" name="action" value="classin">';
  81. $morehtmlref .= '<input type="hidden" name="token" value="'.newToken().'">';
  82. $morehtmlref .= $formproject->select_projects($object->thirdparty->id, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1);
  83. $morehtmlref .= '<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">';
  84. $morehtmlref .= '</form>';
  85. } else {
  86. $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->thirdparty->id, $object->fk_project, 'none', 0, 0, 0, 1);
  87. }
  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 .= ' - '.$proj->title;
  95. }
  96. } else {
  97. $morehtmlref .= '';
  98. }
  99. }
  100. }
  101. $morehtmlref .= '</div>';
  102. $object->totalpaid = $alreadypaid; // To give a chance to dol_banner_tab to use already paid amount to show correct status
  103. dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref, '', 0);
  104. print '<div class="fichecenter">';
  105. print '<div class="underbanner clearboth"></div>';
  106. print '<br>';
  107. print '<table width="100%"><tr><td>';
  108. dol_print_object_info($object);
  109. print '</td></tr></table>';
  110. print '</div>';
  111. // End of page
  112. llxFooter();
  113. $db->close();