fichinter.lib.php 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. <?php
  2. /* Copyright (C) 2006-2007 Laurent Destailleur <eldy@users.sourceforge.net>
  3. * Copyright (C) 2007 Rodolphe Quiedeville <rodolphe@quiedeville.org>
  4. * Copyright (C) 2012 Regis Houssin <regis.houssin@capnetworks.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. * or see http://www.gnu.org/
  19. */
  20. /**
  21. * \file htdocs/core/lib/fichinter.lib.php
  22. * \brief Ensemble de fonctions de base pour le module fichinter
  23. * \ingroup fichinter
  24. */
  25. /**
  26. * Prepare array with list of tabs
  27. *
  28. * @param Object $object Object related to tabs
  29. * @return array Array of tabs to shoc
  30. */
  31. function fichinter_prepare_head($object)
  32. {
  33. global $langs, $conf, $user;
  34. $langs->load("fichinter");
  35. $h = 0;
  36. $head = array();
  37. $head[$h][0] = DOL_URL_ROOT.'/fichinter/fiche.php?id='.$object->id;
  38. $head[$h][1] = $langs->trans("Card");
  39. $head[$h][2] = 'card';
  40. $h++;
  41. if (empty($conf->global->MAIN_DISABLE_CONTACTS_TAB))
  42. {
  43. $head[$h][0] = DOL_URL_ROOT.'/fichinter/contact.php?id='.$object->id;
  44. $head[$h][1] = $langs->trans('InterventionContact');
  45. $head[$h][2] = 'contact';
  46. $h++;
  47. }
  48. if (! empty($conf->global->MAIN_USE_PREVIEW_TABS))
  49. {
  50. $head[$h][0] = DOL_URL_ROOT.'/fichinter/apercu.php?id='.$object->id;
  51. $head[$h][1] = $langs->trans('Preview');
  52. $head[$h][2] = 'preview';
  53. $h++;
  54. }
  55. // Show more tabs from modules
  56. // Entries must be declared in modules descriptor with line
  57. // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
  58. // $this->tabs = array('entity:-tabname); to remove a tab
  59. complete_head_from_modules($conf,$langs,$object,$head,$h,'intervention');
  60. if (empty($conf->global->MAIN_DISABLE_NOTES_TAB))
  61. {
  62. $nbNote = 0;
  63. if(!empty($object->note_private)) $nbNote++;
  64. if(!empty($object->note_public)) $nbNote++;
  65. $head[$h][0] = DOL_URL_ROOT.'/fichinter/note.php?id='.$object->id;
  66. $head[$h][1] = $langs->trans('Notes');
  67. if($nbNote > 0) $head[$h][1].= ' ('.$nbNote.')';
  68. $head[$h][2] = 'note';
  69. $h++;
  70. }
  71. require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
  72. $upload_dir = $conf->ficheinter->dir_output . "/" . dol_sanitizeFileName($object->ref);
  73. $nbFiles = count(dol_dir_list($upload_dir,'files',0,'','(\.meta|_preview\.png)$'));
  74. $head[$h][0] = DOL_URL_ROOT.'/fichinter/document.php?id='.$object->id;
  75. $head[$h][1] = $langs->trans("Documents");
  76. if($nbFiles > 0) $head[$h][1].= ' ('.$nbFiles.')';
  77. $head[$h][2] = 'documents';
  78. $h++;
  79. $head[$h][0] = DOL_URL_ROOT.'/fichinter/info.php?id='.$object->id;
  80. $head[$h][1] = $langs->trans('Info');
  81. $head[$h][2] = 'info';
  82. $h++;
  83. complete_head_from_modules($conf,$langs,$object,$head,$h,'intervention','remove');
  84. return $head;
  85. }
  86. /**
  87. * Return array head with list of tabs to view object informations.
  88. *
  89. * @return array head array with tabs
  90. */
  91. function fichinter_admin_prepare_head()
  92. {
  93. global $langs, $conf, $user;
  94. $h = 0;
  95. $head = array();
  96. $h = 0;
  97. $head[$h][0] = DOL_URL_ROOT."/admin/fichinter.php";
  98. $head[$h][1] = $langs->trans("Interventions");
  99. $head[$h][2] = 'ficheinter';
  100. $h++;
  101. // Show more tabs from modules
  102. // Entries must be declared in modules descriptor with line
  103. // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
  104. // $this->tabs = array('entity:-tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to remove a tab
  105. complete_head_from_modules($conf,$langs,null,$head,$h,'fichinter_admin');
  106. $head[$h][0] = DOL_URL_ROOT.'/fichinter/admin/fichinter_extrafields.php';
  107. $head[$h][1] = $langs->trans("ExtraFields");
  108. $head[$h][2] = 'attributes';
  109. $h++;
  110. complete_head_from_modules($conf,$langs,null,$head,$h,'fichinter_admin','remove');
  111. return $head;
  112. }