salaries.lib.php 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. <?php
  2. /**
  3. * Copyright (C) 2015 Charlie BENKE <charlie@patas-monkey.com>
  4. *
  5. * This program is free software; you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation; either version 3 of the License, or
  8. * (at your option) any later version.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  17. * or see http://www.gnu.org/
  18. */
  19. /**
  20. * Returns an array with the tabs for the "salaries" section
  21. * It loads tabs from modules looking for the entity salaries
  22. *
  23. * @param Paiement $object Current salaries object
  24. * @return array Tabs for the salaries section
  25. */
  26. function salaries_prepare_head($object) {
  27. global $db, $langs, $conf;
  28. $h = 0;
  29. $head = array();
  30. $head[$h][0] = DOL_URL_ROOT.'/compta/salaries/card.php?id='.$object->id;
  31. $head[$h][1] = $langs->trans("Card");
  32. $head[$h][2] = 'card';
  33. $h++;
  34. // Show more tabs from modules
  35. // Entries must be declared in modules descriptor with line
  36. // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
  37. // $this->tabs = array('entity:-tabname); to remove a tab
  38. complete_head_from_modules($conf,$langs,$object,$head,$h,'salaries');
  39. require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
  40. require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php';
  41. $upload_dir = $conf->salaries->dir_output . "/" . dol_sanitizeFileName($object->ref);
  42. $nbFiles = count(dol_dir_list($upload_dir,'files',0,'','(\.meta|_preview.*\.png)$'));
  43. $nbLinks=Link::count($db, $object->element, $object->id);
  44. $head[$h][0] = DOL_URL_ROOT.'/compta/salaries/document.php?id='.$object->id;
  45. $head[$h][1] = $langs->trans('Documents');
  46. if (($nbFiles+$nbLinks) > 0) $head[$h][1].= ' <span class="badge">'.($nbFiles+$nbLinks).'</span>';
  47. $head[$h][2] = 'documents';
  48. $h++;
  49. $head[$h][0] = DOL_URL_ROOT.'/compta/salaries/info.php?id='.$object->id;
  50. $head[$h][1] = $langs->trans("Info");
  51. $head[$h][2] = 'info';
  52. $h++;
  53. complete_head_from_modules($conf,$langs,$object,$head,$h,'salaries', 'remove');
  54. return $head;
  55. }