hrm_skilldet.lib.php 3.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. <?php
  2. /* Copyright (C) 2021 Gauthier VERDOL <gauthier.verdol@atm-consulting.fr>
  3. * Copyright (C) 2021 Greg Rastklan <greg.rastklan@atm-consulting.fr>
  4. * Copyright (C) 2021 Jean-Pascal BOUDET <jean-pascal.boudet@atm-consulting.fr>
  5. * Copyright (C) 2021 Grégory BLEMAND <gregory.blemand@atm-consulting.fr>
  6. *
  7. * This program is free software: you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License as published by
  9. * the Free Software Foundation, either version 3 of the License, or
  10. * (at your option) any later version.
  11. *
  12. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this program. If not, see <https://www.gnu.org/licenses/>.
  19. */
  20. /**
  21. * \file lib/hrm_skilldet.lib.php
  22. * \ingroup hrm
  23. * \brief Library files with common functions for Skilldet
  24. */
  25. /**
  26. * Prepare array of tabs for Skilldet
  27. *
  28. * @param Skilldet $object Skilldet
  29. * @return array Array of tabs
  30. */
  31. function skilldetPrepareHead($object)
  32. {
  33. global $db, $langs, $conf;
  34. $langs->load("hrm");
  35. $h = 0;
  36. $head = array();
  37. $head[$h][0] = dol_buildpath("/hrm/skilldet_card.php", 1).'?id='.$object->id;
  38. $head[$h][1] = $langs->trans("Card");
  39. $head[$h][2] = 'card';
  40. $h++;
  41. if (isset($object->fields['note_public']) || isset($object->fields['note_private'])) {
  42. $nbNote = 0;
  43. if (!empty($object->note_private)) {
  44. $nbNote++;
  45. }
  46. if (!empty($object->note_public)) {
  47. $nbNote++;
  48. }
  49. $head[$h][0] = dol_buildpath('/hrm/skilldet_note.php', 1).'?id='.$object->id;
  50. $head[$h][1] = $langs->trans('Notes');
  51. if ($nbNote > 0) {
  52. $head[$h][1] .= (empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER) ? '<span class="badge marginleftonlyshort">'.$nbNote.'</span>' : '');
  53. }
  54. $head[$h][2] = 'note';
  55. $h++;
  56. }
  57. require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
  58. require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php';
  59. $upload_dir = $conf->hrm->dir_output."/skilldet/".dol_sanitizeFileName($object->ref);
  60. $nbFiles = count(dol_dir_list($upload_dir, 'files', 0, '', '(\.meta|_preview.*\.png)$'));
  61. $nbLinks = Link::count($db, $object->element, $object->id);
  62. $head[$h][0] = dol_buildpath("/hrm/skilldet_document.php", 1).'?id='.$object->id;
  63. $head[$h][1] = $langs->trans('Documents');
  64. if (($nbFiles + $nbLinks) > 0) {
  65. $head[$h][1] .= '<span class="badge marginleftonlyshort">'.($nbFiles + $nbLinks).'</span>';
  66. }
  67. $head[$h][2] = 'document';
  68. $h++;
  69. $head[$h][0] = dol_buildpath("/hrm/skilldet_agenda.php", 1).'?id='.$object->id;
  70. $head[$h][1] = $langs->trans("Events");
  71. $head[$h][2] = 'agenda';
  72. $h++;
  73. // Show more tabs from modules
  74. // Entries must be declared in modules descriptor with line
  75. //$this->tabs = array(
  76. // 'entity:+tabname:Title:@hrm:/hrm/mypage.php?id=__ID__'
  77. //); // to add new tab
  78. //$this->tabs = array(
  79. // 'entity:-tabname:Title:@hrm:/hrm/mypage.php?id=__ID__'
  80. //); // to remove a tab
  81. complete_head_from_modules($conf, $langs, $object, $head, $h, 'skilldet@hrm');
  82. complete_head_from_modules($conf, $langs, $object, $head, $h, 'skilldet@hrm', 'remove');
  83. return $head;
  84. }