salaries.lib.php 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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. {
  28. global $db, $langs, $conf;
  29. $h = 0;
  30. $head = array();
  31. $head[$h][0] = DOL_URL_ROOT.'/compta/salaries/card.php?id='.$object->id;
  32. $head[$h][1] = $langs->trans("Card");
  33. $head[$h][2] = 'card';
  34. $h++;
  35. // Show more tabs from modules
  36. // Entries must be declared in modules descriptor with line
  37. // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
  38. // $this->tabs = array('entity:-tabname); to remove a tab
  39. complete_head_from_modules($conf,$langs,$object,$head,$h,'salaries');
  40. require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
  41. require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php';
  42. $upload_dir = $conf->salaries->dir_output . "/" . dol_sanitizeFileName($object->ref);
  43. $nbFiles = count(dol_dir_list($upload_dir,'files',0,'','(\.meta|_preview.*\.png)$'));
  44. $nbLinks=Link::count($db, $object->element, $object->id);
  45. $head[$h][0] = DOL_URL_ROOT.'/compta/salaries/document.php?id='.$object->id;
  46. $head[$h][1] = $langs->trans('Documents');
  47. if (($nbFiles+$nbLinks) > 0) $head[$h][1].= ' <span class="badge">'.($nbFiles+$nbLinks).'</span>';
  48. $head[$h][2] = 'documents';
  49. $h++;
  50. $head[$h][0] = DOL_URL_ROOT.'/compta/salaries/info.php?id='.$object->id;
  51. $head[$h][1] = $langs->trans("Info");
  52. $head[$h][2] = 'info';
  53. $h++;
  54. complete_head_from_modules($conf,$langs,$object,$head,$h,'salaries', 'remove');
  55. return $head;
  56. }