PageRenderTime 50ms CodeModel.GetById 16ms RepoModel.GetById 1ms app.codeStats 0ms

/htdocs/compta/facture/note.php

https://github.com/zeert/dolibarr
PHP | 136 lines | 74 code | 30 blank | 32 comment | 14 complexity | 6de9352e30f30ebe4246cdd20c3684b0 MD5 | raw file
Possible License(s): LGPL-2.0
  1. <?php
  2. /* Copyright (C) 2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
  3. * Copyright (C) 2004-2008 Laurent Destailleur <eldy@users.sourceforge.net>
  4. * Copyright (C) 2005-2012 Regis Houssin <regis@dolibarr.fr>
  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 2 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 <http://www.gnu.org/licenses/>.
  18. */
  19. /**
  20. * \file htdocs/compta/facture/note.php
  21. * \ingroup facture
  22. * \brief Fiche de notes sur 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/invoice.lib.php');
  28. $langs->load("companies");
  29. $langs->load("bills");
  30. $id=(GETPOST('id','int')?GETPOST('id','int'):GETPOST('facid','int')); // For backward compatibility
  31. $ref=GETPOST('ref','alpha');
  32. $socid=GETPOST('socid','int');
  33. $action=GETPOST('action','alpha');
  34. // Security check
  35. $socid=0;
  36. if ($user->societe_id) $socid=$user->societe_id;
  37. $result=restrictedArea($user,'facture',$id,'');
  38. $object = new Facture($db);
  39. $object->fetch($id);
  40. /******************************************************************************/
  41. /* Actions */
  42. /******************************************************************************/
  43. if ($action == 'setnote_public' && $user->rights->facture->creer)
  44. {
  45. $object->fetch($id);
  46. $result=$object->update_note_public(dol_html_entity_decode(GETPOST('note_public'), ENT_QUOTES));
  47. if ($result < 0) dol_print_error($db,$object->error);
  48. }
  49. else if ($action == 'setnote' && $user->rights->facture->creer)
  50. {
  51. $object->fetch($id);
  52. $result=$object->update_note(dol_html_entity_decode(GETPOST('note'), ENT_QUOTES));
  53. if ($result < 0) dol_print_error($db,$object->error);
  54. }
  55. /******************************************************************************/
  56. /* Affichage fiche */
  57. /******************************************************************************/
  58. llxHeader();
  59. $form = new Form($db);
  60. if ($id > 0 || ! empty($ref))
  61. {
  62. $object = new Facture($db);
  63. $object->fetch($id,$ref);
  64. $soc = new Societe($db);
  65. $soc->fetch($object->socid);
  66. $head = facture_prepare_head($object);
  67. dol_fiche_head($head, 'note', $langs->trans("InvoiceCustomer"), 0, 'bill');
  68. print '<table class="border" width="100%">';
  69. $linkback = '<a href="'.DOL_URL_ROOT.'/compta/facture/list.php'.(! empty($socid)?'?socid='.$socid:'').'">'.$langs->trans("BackToList").'</a>';
  70. // Ref
  71. print '<tr><td width="25%">'.$langs->trans('Ref').'</td>';
  72. print '<td colspan="3">';
  73. $morehtmlref='';
  74. $discount=new DiscountAbsolute($db);
  75. $result=$discount->fetch(0,$object->id);
  76. if ($result > 0)
  77. {
  78. $morehtmlref=' ('.$langs->trans("CreditNoteConvertedIntoDiscount",$discount->getNomUrl(1,'discount')).')';
  79. }
  80. if ($result < 0)
  81. {
  82. dol_print_error('',$discount->error);
  83. }
  84. print $form->showrefnav($object, 'ref', $linkback, 1, 'facnumber', 'ref', $morehtmlref);
  85. print '</td></tr>';
  86. // Ref customer
  87. print '<tr><td width="20%">';
  88. print '<table class="nobordernopadding" width="100%"><tr><td>';
  89. print $langs->trans('RefCustomer');
  90. print '</td>';
  91. print '</tr></table>';
  92. print '</td>';
  93. print '<td colspan="5">';
  94. print $object->ref_client;
  95. print '</td></tr>';
  96. // Company
  97. print '<tr><td>'.$langs->trans("Company").'</td>';
  98. print '<td colspan="3">'.$soc->getNomUrl(1,'compta').'</td>';
  99. print "</table>";
  100. print '<br>';
  101. include(DOL_DOCUMENT_ROOT.'/core/tpl/notes.tpl.php');
  102. dol_fiche_end();
  103. }
  104. llxFooter();
  105. $db->close();
  106. ?>