hrm_job.lib.php 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  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_job.lib.php
  22. * \ingroup hrm
  23. * \brief Library files with common functions for Job
  24. */
  25. /**
  26. * Prepare array of tabs for Job
  27. *
  28. * @param Job $object Job
  29. * @return array Array of tabs
  30. */
  31. function jobPrepareHead($object)
  32. {
  33. global $db, $langs, $conf;
  34. $langs->load("hrm");
  35. $h = 0;
  36. $head = array();
  37. $head[$h][0] = DOL_URL_ROOT."/hrm/job_card.php?id=".$object->id;
  38. $head[$h][1] = $langs->trans("JobCard");
  39. $head[$h][2] = 'job_card';
  40. $h++;
  41. $head[$h][0] = DOL_URL_ROOT."/hrm/skill_tab.php?id=".$object->id.'&objecttype=job';
  42. $head[$h][1] = $langs->trans("RequiredSkills");
  43. $head[$h][2] = 'skill_tab';
  44. $h++;
  45. $head[$h][0] = DOL_URL_ROOT."/hrm/position.php?fk_job=".$object->id;
  46. $head[$h][1] = $langs->trans("EmployeesInThisPosition");
  47. $head[$h][2] = 'position';
  48. $h++;
  49. if (isset($object->fields['note_public']) || isset($object->fields['note_private'])) {
  50. $nbNote = 0;
  51. if (!empty($object->note_private)) {
  52. $nbNote++;
  53. }
  54. if (!empty($object->note_public)) {
  55. $nbNote++;
  56. }
  57. $head[$h][0] = dol_buildpath('/hrm/job_note.php', 1).'?id='.$object->id;
  58. $head[$h][1] = $langs->trans('Notes');
  59. if ($nbNote > 0) {
  60. $head[$h][1] .= (empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER) ? '<span class="badge marginleftonlyshort">'.$nbNote.'</span>' : '');
  61. }
  62. $head[$h][2] = 'note';
  63. $h++;
  64. }
  65. require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
  66. require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php';
  67. $upload_dir = $conf->hrm->dir_output."/job/".dol_sanitizeFileName($object->label);
  68. $nbFiles = count(dol_dir_list($upload_dir, 'files', 0, '', '(\.meta|_preview.*\.png)$'));
  69. $nbLinks = Link::count($db, $object->element, $object->id);
  70. $head[$h][0] = dol_buildpath("/hrm/job_document.php", 1).'?id='.$object->id;
  71. $head[$h][1] = $langs->trans('Documents');
  72. if (($nbFiles + $nbLinks) > 0) {
  73. $head[$h][1] .= '<span class="badge marginleftonlyshort">'.($nbFiles + $nbLinks).'</span>';
  74. }
  75. $head[$h][2] = 'document';
  76. $h++;
  77. $head[$h][0] = dol_buildpath("/hrm/job_agenda.php", 1).'?id='.$object->id;
  78. $head[$h][1] = $langs->trans("Events");
  79. $head[$h][2] = 'agenda';
  80. $h++;
  81. // Show more tabs from modules
  82. // Entries must be declared in modules descriptor with line
  83. //$this->tabs = array(
  84. // 'entity:+tabname:Title:@hrm:/hrm/mypage.php?id=__ID__'
  85. //); // to add new tab
  86. //$this->tabs = array(
  87. // 'entity:-tabname:Title:@hrm:/hrm/mypage.php?id=__ID__'
  88. //); // to remove a tab
  89. complete_head_from_modules($conf, $langs, $object, $head, $h, 'job@hrm');
  90. complete_head_from_modules($conf, $langs, $object, $head, $h, 'job@hrm', 'remove');
  91. return $head;
  92. }