info.php 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  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. // Load Dolibarr environment
  27. require '../../main.inc.php';
  28. require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.class.php';
  29. require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php';
  30. require_once DOL_DOCUMENT_ROOT.'/core/lib/fourn.lib.php';
  31. require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
  32. if (isModEnabled('project')) {
  33. require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
  34. }
  35. $langs->loadLangs(array("companies", "bills"));
  36. $id = GETPOST("facid", 'int') ?GETPOST("facid", 'int') : GETPOST("id", 'int');
  37. $ref = GETPOST("ref", 'alpha');
  38. // Security check
  39. if ($user->socid) {
  40. $socid = $user->socid;
  41. }
  42. $result = restrictedArea($user, 'fournisseur', $id, 'facture_fourn', 'facture');
  43. $hookmanager->initHooks(array('invoicesuppliercardinfo'));
  44. $object = new FactureFournisseur($db);
  45. $usercancreate = ($user->rights->fournisseur->facture->creer || $user->rights->supplier_invoice->creer);
  46. $permissiontoadd = $usercancreate;
  47. /*
  48. * View
  49. */
  50. $form = new Form($db);
  51. $object->fetch($id, $ref);
  52. $object->fetch_thirdparty();
  53. $object->info($object->id);
  54. $alreadypaid = $object->getSommePaiement();
  55. $title = $object->ref." - ".$langs->trans('Info');
  56. $helpurl = "EN:Module_Suppliers_Invoices|FR:Module_Fournisseurs_Factures|ES:Módulo_Facturas_de_proveedores";
  57. llxHeader('', $title, $helpurl);
  58. $head = facturefourn_prepare_head($object);
  59. $titre = $langs->trans('SupplierInvoice');
  60. print dol_get_fiche_head($head, 'info', $langs->trans('SupplierInvoice'), -1, 'supplier_invoice');
  61. $linkback = '<a href="'.DOL_URL_ROOT.'/fourn/facture/list.php?restore_lastsearch_values=1'.(!empty($socid) ? '&socid='.$socid : '').'">'.$langs->trans("BackToList").'</a>';
  62. $morehtmlref = '<div class="refidno">';
  63. // Ref supplier
  64. $morehtmlref .= $form->editfieldkey("RefSupplier", 'ref_supplier', $object->ref_supplier, $object, 0, 'string', '', 0, 1);
  65. $morehtmlref .= $form->editfieldval("RefSupplier", 'ref_supplier', $object->ref_supplier, $object, 0, 'string', '', null, null, '', 1);
  66. // Thirdparty
  67. $morehtmlref .= '<br>'.$object->thirdparty->getNomUrl(1);
  68. if (empty($conf->global->MAIN_DISABLE_OTHER_LINK) && $object->thirdparty->id > 0) {
  69. $morehtmlref .= ' (<a href="'.DOL_URL_ROOT.'/fourn/facture/list.php?socid='.$object->thirdparty->id.'&search_company='.urlencode($object->thirdparty->name).'">'.$langs->trans("OtherBills").'</a>)';
  70. }
  71. // Project
  72. if (isModEnabled('project')) {
  73. $langs->load("projects");
  74. $morehtmlref .= '<br>';
  75. if (0) {
  76. $morehtmlref .= img_picto($langs->trans("Project"), 'project', 'class="pictofixedwidth"');
  77. if ($action != 'classify') {
  78. $morehtmlref .= '<a class="editfielda" href="'.$_SERVER['PHP_SELF'].'?action=classify&token='.newToken().'&id='.$object->id.'">'.img_edit($langs->transnoentitiesnoconv('SetProject')).'</a> ';
  79. }
  80. $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, (empty($conf->global->PROJECT_CAN_ALWAYS_LINK_TO_ALL_SUPPLIERS) ? $object->socid : -1), $object->fk_project, ($action == 'classify' ? 'projectid' : 'none'), 0, 0, 0, 1, '', 'maxwidth300');
  81. } else {
  82. if (!empty($object->fk_project)) {
  83. $proj = new Project($db);
  84. $proj->fetch($object->fk_project);
  85. $morehtmlref .= $proj->getNomUrl(1);
  86. if ($proj->title) {
  87. $morehtmlref .= '<span class="opacitymedium"> - '.dol_escape_htmltag($proj->title).'</span>';
  88. }
  89. }
  90. }
  91. }
  92. $morehtmlref .= '</div>';
  93. $object->totalpaid = $alreadypaid; // To give a chance to dol_banner_tab to use already paid amount to show correct status
  94. dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref, '', 0);
  95. print '<div class="fichecenter">';
  96. print '<div class="underbanner clearboth"></div>';
  97. print '<br>';
  98. print '<table width="100%"><tr><td>';
  99. dol_print_object_info($object);
  100. print '</td></tr></table>';
  101. print '</div>';
  102. // End of page
  103. llxFooter();
  104. $db->close();