resource.lib.php 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. <?php
  2. /* Module to manage locations, buildings, floors and rooms into Dolibarr ERP/CRM
  3. * Copyright (C) 2013 Jean-François Ferry <jfefe@aternatik.fr>
  4. * Copyright (C) 2016 Gilles Poirier <glgpoirier@gmail.com>
  5. *
  6. * This program is free software: you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation, either version 3 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  18. */
  19. /**
  20. * \file htdocs/core/lib/resource.lib.php
  21. * \ingroup resource
  22. * \brief This file is library for resource module
  23. */
  24. /**
  25. * Prepare head for tabs
  26. *
  27. * @param Object $object Object
  28. * @return array Array of head entries
  29. */
  30. function resource_prepare_head($object)
  31. {
  32. global $langs, $conf, $user;
  33. $h = 0;
  34. $head = array();
  35. $head[$h][0] = dol_buildpath('/resource/card.php',1).'?id='.$object->id;
  36. $head[$h][1] = $langs->trans("ResourceCard");
  37. $head[$h][2] = 'resource';
  38. $h++;
  39. if (empty($conf->global->MAIN_DISABLE_CONTACTS_TAB))
  40. {
  41. $nbContact = count($object->liste_contact(-1,'internal')) + count($object->liste_contact(-1,'external'));
  42. $head[$h][0] = DOL_URL_ROOT.'/resource/contact.php?id='.$object->id;
  43. $head[$h][1] = $langs->trans('ContactsAddresses');
  44. if ($nbContact > 0) $head[$h][1].= ' <span class="badge">'.$nbContact.'</span>';
  45. $head[$h][2] = 'contact';
  46. $h++;
  47. }
  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:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to remove a tab
  52. complete_head_from_modules($conf,$langs,$object,$head,$h,'resource');
  53. if (empty($conf->global->MAIN_DISABLE_NOTES_TAB))
  54. {
  55. $nbNote = 0;
  56. if(!empty($object->note_private)) $nbNote++;
  57. if(!empty($object->note_public)) $nbNote++;
  58. $head[$h][0] = DOL_URL_ROOT.'/resource/note.php?id='.$object->id;
  59. $head[$h][1] = $langs->trans('Notes');
  60. if ($nbNote > 0) $head[$h][1].= ' <span class="badge">'.$nbNote.'</span>';
  61. $head[$h][2] = 'note';
  62. $h++;
  63. }
  64. require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
  65. $upload_dir = $conf->resource->dir_output . "/" . dol_sanitizeFileName($object->ref);
  66. $nbFiles = count(dol_dir_list($upload_dir,'files',0,'','(\.meta|_preview.*\.png)$'));
  67. $head[$h][0] = DOL_URL_ROOT.'/resource/document.php?id='.$object->id;
  68. $head[$h][1] = $langs->trans("Documents");
  69. if($nbFiles > 0) $head[$h][1].= ' <span class="badge">'.$nbFiles.'</span>';
  70. $head[$h][2] = 'documents';
  71. $h++;
  72. /*$head[$h][0] = DOL_URL_ROOT.'/resource/info.php?id='.$object->id;
  73. $head[$h][1] = $langs->trans('Info');
  74. $head[$h][2] = 'info';
  75. $h++;*/
  76. complete_head_from_modules($conf,$langs,$object,$head,$h,'resource', 'remove');
  77. return $head;
  78. }
  79. function resource_admin_prepare_head() {
  80. global $langs, $conf, $user;
  81. $h = 0;
  82. $head = array();
  83. $head[$h][0] = DOL_URL_ROOT.'/admin/resource.php';
  84. $head[$h][1] = $langs->trans("ResourceSetup");
  85. $head[$h][2] = 'general';
  86. $h++;
  87. // Show more tabs from modules
  88. // Entries must be declared in modules descriptor with line
  89. // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
  90. // $this->tabs = array('entity:-tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to remove a tab
  91. complete_head_from_modules($conf,$langs,null,$head,$h,'resource_admin');
  92. $head[$h][0] = DOL_URL_ROOT.'/admin/resource_extrafields.php';
  93. $head[$h][1] = $langs->trans("ExtraFields");
  94. $head[$h][2] = 'attributes';
  95. $h++;
  96. complete_head_from_modules($conf,$langs,null,$head,$h,'resource_admin','remove');
  97. return $head;
  98. }