expensereport.lib.php 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  1. <?php
  2. /* Copyright (C) 2011 Regis Houssin <regis.houssin@capnetworks.com>
  3. *
  4. * This program is free software; you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License as published by
  6. * the Free Software Foundation; either version 3 of the License, or
  7. * (at your option) any later version.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  16. * or see http://www.gnu.org/
  17. */
  18. /**
  19. * \file htdocs/core/lib/expensereport.lib.php
  20. * \brief Functions for module expensereport
  21. */
  22. /**
  23. * Prepare array with list of tabs
  24. *
  25. * @param Object $object Object related to tabs
  26. * @return array Array of tabs to show
  27. */
  28. function expensereport_prepare_head($object)
  29. {
  30. global $db, $langs, $conf;
  31. $h = 0;
  32. $head = array();
  33. $head[$h][0] = DOL_URL_ROOT . '/expensereport/card.php?id=' . $object->id;
  34. $head[$h][1] = $langs->trans("Card");
  35. $head[$h][2] = 'card';
  36. $h++;
  37. // Show more tabs from modules
  38. // Entries must be declared in modules descriptor with line
  39. // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
  40. // $this->tabs = array('entity:-tabname); to remove a tab
  41. complete_head_from_modules($conf,$langs,$object,$head,$h,'expensereport');
  42. require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
  43. require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php';
  44. $upload_dir = $conf->expensereport->dir_output . "/" . dol_sanitizeFileName($object->ref);
  45. $nbFiles = count(dol_dir_list($upload_dir,'files',0,'','(\.meta|_preview.*\.png)$'));
  46. $nbLinks=Link::count($db, $object->element, $object->id);
  47. $head[$h][0] = DOL_URL_ROOT.'/expensereport/document.php?id='.$object->id;
  48. $head[$h][1] = $langs->trans('Documents');
  49. if (($nbFiles+$nbLinks) > 0) $head[$h][1].= ' <span class="badge">'.($nbFiles+$nbLinks).'</span>';
  50. $head[$h][2] = 'documents';
  51. $h++;
  52. if (empty($conf->global->MAIN_DISABLE_NOTES_TAB))
  53. {
  54. $nbNote = 0;
  55. if(!empty($object->note_private)) $nbNote++;
  56. if(!empty($object->note_public)) $nbNote++;
  57. $head[$h][0] = DOL_URL_ROOT.'/expensereport/note.php?id='.$object->id;
  58. $head[$h][1] = $langs->trans('Notes');
  59. if ($nbNote > 0) $head[$h][1].= ' <span class="badge">'.$nbNote.'</span>';
  60. $head[$h][2] = 'note';
  61. $h++;
  62. }
  63. $head[$h][0] = DOL_URL_ROOT . '/expensereport/info.php?id=' . $object->id;
  64. $head[$h][1] = $langs->trans("Info");
  65. $head[$h][2] = 'info';
  66. $h++;
  67. complete_head_from_modules($conf,$langs,$object,$head,$h,'expensereport','remove');
  68. return $head;
  69. }
  70. /**
  71. * Returns an array with the tabs for the "Expense report payment" section
  72. * It loads tabs from modules looking for the entity payment
  73. *
  74. * @param Paiement $object Current payment object
  75. * @return array Tabs for the payment section
  76. */
  77. function payment_expensereport_prepare_head(PaymentExpenseReport $object) {
  78. global $langs, $conf;
  79. $h = 0;
  80. $head = array();
  81. $head[$h][0] = DOL_URL_ROOT.'/expensereport/payment/card.php?id='.$object->id;
  82. $head[$h][1] = $langs->trans("Card");
  83. $head[$h][2] = 'payment';
  84. $h++;
  85. // Show more tabs from modules
  86. // Entries must be declared in modules descriptor with line
  87. // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
  88. // $this->tabs = array('entity:-tabname); to remove a tab
  89. complete_head_from_modules($conf,$langs,$object,$head,$h,'payment_expensereport');
  90. $head[$h][0] = DOL_URL_ROOT.'/expensereport/payment/info.php?id='.$object->id;
  91. $head[$h][1] = $langs->trans("Info");
  92. $head[$h][2] = 'info';
  93. $h++;
  94. complete_head_from_modules($conf,$langs,$object,$head,$h,'payment_expensereport', 'remove');
  95. return $head;
  96. }
  97. /**
  98. * Return array head with list of tabs to view object informations.
  99. *
  100. * @return array head array with tabs
  101. */
  102. function expensereport_admin_prepare_head()
  103. {
  104. global $langs, $conf, $user;
  105. $h = 0;
  106. $head = array();
  107. $h = 0;
  108. $head[$h][0] = DOL_URL_ROOT."/admin/expensereport.php";
  109. $head[$h][1] = $langs->trans("ExpenseReports");
  110. $head[$h][2] = 'expensereport';
  111. $h++;
  112. // Show more tabs from modules
  113. // Entries must be declared in modules descriptor with line
  114. // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
  115. // $this->tabs = array('entity:-tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to remove a tab
  116. complete_head_from_modules($conf,$langs,null,$head,$h,'expensereport_admin');
  117. $head[$h][0] = DOL_URL_ROOT.'/admin/expensereport_extrafields.php';
  118. $head[$h][1] = $langs->trans("ExtraFields");
  119. $head[$h][2] = 'attributes';
  120. $h++;
  121. /*
  122. $head[$h][0] = DOL_URL_ROOT.'/fichinter/admin/fichinterdet_extrafields.php';
  123. $head[$h][1] = $langs->trans("ExtraFieldsLines");
  124. $head[$h][2] = 'attributesdet';
  125. $h++;
  126. */
  127. complete_head_from_modules($conf,$langs,null,$head,$h,'expensereport_admin','remove');
  128. return $head;
  129. }