holiday.lib.php 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. <?php
  2. /* Copyright (C) 2006-2011 Laurent Destailleur <eldy@users.sourceforge.net>
  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/holiday.lib.php
  20. * \brief Ensemble de fonctions de base pour les adherents
  21. */
  22. /**
  23. * Return array head with list of tabs to view object informations
  24. *
  25. * @param Object $object Holiday
  26. * @return array head
  27. */
  28. function holiday_prepare_head($object)
  29. {
  30. global $db, $langs, $conf, $user;
  31. $h = 0;
  32. $head = array();
  33. $head[$h][0] = DOL_URL_ROOT.'/holiday/card.php?id='.$object->id;
  34. $head[$h][1] = $langs->trans("Card");
  35. $head[$h][2] = 'card';
  36. $h++;
  37. // Attachments
  38. require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
  39. require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php';
  40. $upload_dir = $conf->holiday->multidir_output[$object->entity].'/'.dol_sanitizeFileName($object->ref);
  41. $nbFiles = count(dol_dir_list($upload_dir,'files',0,'','(\.meta|_preview.*\.png)$'));
  42. $nbLinks=Link::count($db, $object->element, $object->id);
  43. $head[$h][0] = DOL_URL_ROOT.'/holiday/document.php?id='.$object->id;
  44. $head[$h][1] = $langs->trans('Documents');
  45. if (($nbFiles+$nbLinks) > 0) $head[$h][1].= ' <span class="badge">'.($nbFiles+$nbLinks).'</span>';
  46. $head[$h][2] = 'documents';
  47. $h++;
  48. // Show more tabs from modules
  49. // Entries must be declared in modules descriptor with line
  50. // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
  51. // $this->tabs = array('entity:-tabname); to remove a tab
  52. complete_head_from_modules($conf,$langs,$object,$head,$h,'holiday');
  53. complete_head_from_modules($conf,$langs,$object,$head,$h,'holiday','remove');
  54. return $head;
  55. }