invoice.lib.php 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. <?php
  2. /* Copyright (C) 2005-2012 Laurent Destailleur <eldy@users.sourceforge.net>
  3. * Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com>
  4. * Copyright (C) 2013 Florian Henry <florian.henry@open-concept.pro>
  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 <http://www.gnu.org/licenses/>.
  18. * or see http://www.gnu.org/
  19. */
  20. /**
  21. * \file htdocs/core/lib/invoice.lib.php
  22. * \brief Functions used by invoice module
  23. * \ingroup invoice
  24. */
  25. /**
  26. * Initialize the array of tabs for customer invoice
  27. *
  28. * @param Facture $object Invoice object
  29. * @return array Array of head tabs
  30. */
  31. function facture_prepare_head($object)
  32. {
  33. global $langs, $conf;
  34. $h = 0;
  35. $head = array();
  36. $head[$h][0] = DOL_URL_ROOT.'/compta/facture.php?facid='.$object->id;
  37. $head[$h][1] = $langs->trans('CardBill');
  38. $head[$h][2] = 'compta';
  39. $h++;
  40. if (empty($conf->global->MAIN_DISABLE_CONTACTS_TAB))
  41. {
  42. $head[$h][0] = DOL_URL_ROOT.'/compta/facture/contact.php?facid='.$object->id;
  43. $head[$h][1] = $langs->trans('ContactsAddresses');
  44. $head[$h][2] = 'contact';
  45. $h++;
  46. }
  47. if (! empty($conf->global->MAIN_USE_PREVIEW_TABS))
  48. {
  49. $head[$h][0] = DOL_URL_ROOT.'/compta/facture/apercu.php?facid='.$object->id;
  50. $head[$h][1] = $langs->trans('Preview');
  51. $head[$h][2] = 'preview';
  52. $h++;
  53. }
  54. //if ($fac->mode_reglement_code == 'PRE')
  55. if (! empty($conf->prelevement->enabled))
  56. {
  57. $head[$h][0] = DOL_URL_ROOT.'/compta/facture/prelevement.php?facid='.$object->id;
  58. $head[$h][1] = $langs->trans('StandingOrders');
  59. $head[$h][2] = 'standingorders';
  60. $h++;
  61. }
  62. // Show more tabs from modules
  63. // Entries must be declared in modules descriptor with line
  64. // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
  65. // $this->tabs = array('entity:-tabname); to remove a tab
  66. complete_head_from_modules($conf,$langs,$object,$head,$h,'invoice');
  67. if (empty($conf->global->MAIN_DISABLE_NOTES_TAB))
  68. {
  69. $nbNote = 0;
  70. if(!empty($object->note_private)) $nbNote++;
  71. if(!empty($object->note_public)) $nbNote++;
  72. $head[$h][0] = DOL_URL_ROOT.'/compta/facture/note.php?facid='.$object->id;
  73. $head[$h][1] = $langs->trans('Notes');
  74. if($nbNote > 0) $head[$h][1].= ' ('.$nbNote.')';
  75. $head[$h][2] = 'note';
  76. $h++;
  77. }
  78. require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
  79. $upload_dir = $conf->facture->dir_output . "/" . dol_sanitizeFileName($object->ref);
  80. $nbFiles = count(dol_dir_list($upload_dir,'files',0,'','(\.meta|_preview\.png)$'));
  81. $head[$h][0] = DOL_URL_ROOT.'/compta/facture/document.php?facid='.$object->id;
  82. $head[$h][1] = $langs->trans('Documents');
  83. if($nbFiles > 0) $head[$h][1].= ' ('.$nbFiles.')';
  84. $head[$h][2] = 'documents';
  85. $h++;
  86. $head[$h][0] = DOL_URL_ROOT.'/compta/facture/info.php?facid='.$object->id;
  87. $head[$h][1] = $langs->trans('Info');
  88. $head[$h][2] = 'info';
  89. $h++;
  90. complete_head_from_modules($conf,$langs,$object,$head,$h,'invoice','remove');
  91. return $head;
  92. }
  93. /**
  94. * Return array head with list of tabs to view object informations.
  95. *
  96. * @param Object $object Invoice
  97. * @return array head array with tabs
  98. */
  99. function invoice_admin_prepare_head($object)
  100. {
  101. global $langs, $conf, $user;
  102. $h = 0;
  103. $head = array();
  104. $head[$h][0] = DOL_URL_ROOT.'/admin/facture.php';
  105. $head[$h][1] = $langs->trans("Miscellaneous");
  106. $head[$h][2] = 'general';
  107. $h++;
  108. // Show more tabs from modules
  109. // Entries must be declared in modules descriptor with line
  110. // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
  111. // $this->tabs = array('entity:-tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to remove a tab
  112. complete_head_from_modules($conf,$langs,$object,$head,$h,'invoice_admin');
  113. $head[$h][0] = DOL_URL_ROOT.'/compta/facture/admin/facture_cust_extrafields.php';
  114. $head[$h][1] = $langs->trans("ExtraFieldsCustomerInvoices");
  115. $head[$h][2] = 'attributes';
  116. $h++;
  117. $head[$h][0] = DOL_URL_ROOT.'/compta/facture/admin/facturedet_cust_extrafields.php';
  118. $head[$h][1] = $langs->trans("ExtraFieldsLines");
  119. $head[$h][2] = 'attributeslines';
  120. $h++;
  121. complete_head_from_modules($conf,$langs,$object,$head,$h,'invoice_admin','remove');
  122. return $head;
  123. }