recruitment_recruitmentcandidature.lib.php 3.5 KB

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