salaries.lib.php 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. <?php
  2. /**
  3. * Copyright (C) 2015 Charlie BENKE <charlie@patas-monkey.com>
  4. * Copyright (C) 2019 Alexandre Spangaro <aspangaro@open-dsi.fr>
  5. * Copyright (C) 2021 Gauthier VERDOL <gauthier.verdol@atm-consulting.fr>
  6. *
  7. * This program is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License as published by
  9. * the Free Software Foundation; either version 3 of the License, or
  10. * (at your option) any later version.
  11. *
  12. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this program. If not, see <https://www.gnu.org/licenses/>.
  19. * or see https://www.gnu.org/
  20. */
  21. /**
  22. * Returns an array with the tabs for the "salaries" section
  23. * It loads tabs from modules looking for the entity salaries
  24. *
  25. * @param Paiement $object Current salaries object
  26. * @return array Tabs for the salaries section
  27. */
  28. function salaries_prepare_head($object)
  29. {
  30. global $db, $langs, $conf;
  31. $h = 0;
  32. $head = array();
  33. $head[$h][0] = DOL_URL_ROOT.'/salaries/card.php?id='.$object->id;
  34. $head[$h][1] = $langs->trans("Salary");
  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, 'salaries');
  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->salaries->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.'/salaries/document.php?id='.$object->id;
  48. $head[$h][1] = $langs->trans('Documents');
  49. if (($nbFiles + $nbLinks) > 0) {
  50. $head[$h][1] .= '<span class="badge marginleftonlyshort">'.($nbFiles + $nbLinks).'</span>';
  51. }
  52. $head[$h][2] = 'documents';
  53. $h++;
  54. $head[$h][0] = DOL_URL_ROOT.'/salaries/info.php?id='.$object->id;
  55. $head[$h][1] = $langs->trans("Info");
  56. $head[$h][2] = 'info';
  57. $h++;
  58. complete_head_from_modules($conf, $langs, $object, $head, $h, 'salaries', 'remove');
  59. return $head;
  60. }
  61. /**
  62. * Return array head with list of tabs to view object informations
  63. *
  64. * @return array head
  65. */
  66. function salaries_admin_prepare_head()
  67. {
  68. global $langs, $conf, $user;
  69. $h = 0;
  70. $head = array();
  71. $head[$h][0] = DOL_URL_ROOT.'/salaries/admin/salaries.php';
  72. $head[$h][1] = $langs->trans("Miscellaneous");
  73. $head[$h][2] = 'general';
  74. $h++;
  75. // Show more tabs from modules
  76. // Entries must be declared in modules descriptor with line
  77. // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
  78. // $this->tabs = array('entity:-tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to remove a tab
  79. complete_head_from_modules($conf, $langs, null, $head, $h, 'salaries_admin');
  80. $head[$h][0] = DOL_URL_ROOT.'/salaries/admin/salaries_extrafields.php';
  81. $head[$h][1] = $langs->trans("ExtraFieldsSalaries");
  82. $head[$h][2] = 'attributes';
  83. $h++;
  84. complete_head_from_modules($conf, $langs, null, $head, $h, 'salaries_admin', 'remove');
  85. return $head;
  86. }