loan.lib.php 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. <?php
  2. /* Copyright (C) 2014-2016 Alexandre Spangaro <aspangaro@zendsi.com>
  3. * Copyright (C) 2015 Frederic France <frederic.france@free.fr>
  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. */
  18. /**
  19. * \file htdocs/core/lib/loan.lib.php
  20. * \ingroup loan
  21. * \brief Library for loan module
  22. */
  23. /**
  24. * Prepare array with list of tabs
  25. *
  26. * @param Object $object Object related to tabs
  27. * @return array Array of tabs to show
  28. */
  29. function loan_prepare_head($object)
  30. {
  31. global $db, $langs, $conf;
  32. $tab = 0;
  33. $head = array();
  34. $head[$tab][0] = DOL_URL_ROOT.'/loan/card.php?id='.$object->id;
  35. $head[$tab][1] = $langs->trans('Card');
  36. $head[$tab][2] = 'card';
  37. $tab++;
  38. // Show more tabs from modules
  39. // Entries must be declared in modules descriptor with line
  40. // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
  41. // $this->tabs = array('entity:-tabname); to remove a tab
  42. complete_head_from_modules($conf, $langs, $object, $head, $tab,'loan');
  43. require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
  44. require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php';
  45. $upload_dir = $conf->loan->dir_output . "/" . dol_sanitizeFileName($object->ref);
  46. $nbFiles = count(dol_dir_list($upload_dir,'files',0,'','(\.meta|_preview.*\.png)$'));
  47. $nbLinks=Link::count($db, $object->element, $object->id);
  48. $head[$tab][0] = DOL_URL_ROOT.'/loan/document.php?id='.$object->id;
  49. $head[$tab][1] = $langs->trans("Documents");
  50. if (($nbFiles+$nbLinks) > 0) $head[$tab][1].= ' <span class="badge">'.($nbFiles+$nbLinks).'</span>';
  51. $head[$tab][2] = 'documents';
  52. $tab++;
  53. if (empty($conf->global->MAIN_DISABLE_NOTES_TAB))
  54. {
  55. $nbNote = (empty($object->note_private)?0:1)+(empty($object->note_public)?0:1);
  56. $head[$tab][0] = DOL_URL_ROOT."/loan/note.php?id=".$object->id;
  57. $head[$tab][1] = $langs->trans("Notes");
  58. if($nbNote > 0) $head[$tab][1].= ' <span class="badge">'.$nbNote.'</span>';
  59. $head[$tab][2] = 'note';
  60. $tab++;
  61. }
  62. $head[$tab][0] = DOL_URL_ROOT.'/loan/info.php?id='.$object->id;
  63. $head[$tab][1] = $langs->trans("Info");
  64. $head[$tab][2] = 'info';
  65. $tab++;
  66. complete_head_from_modules($conf,$langs,$object,$head,$tab,'loan','remove');
  67. return $head;
  68. }