recruitmentcandidature_agenda.php 10.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260
  1. <?php
  2. /* Copyright (C) 2017 Laurent Destailleur <eldy@users.sourceforge.net>
  3. * Copyright (C) ---Put here your own copyright and developer email---
  4. *
  5. * This program is free software; you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation; either version 3 of the License, or
  8. * (at your option) any later version.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with this program. If not, see <https://www.gnu.org/licenses/>.
  17. */
  18. /**
  19. * \file recruitmentcandidature_agenda.php
  20. * \ingroup recruitment
  21. * \brief Page of RecruitmentCandidature events
  22. */
  23. // Load Dolibarr environment
  24. require_once '../main.inc.php';
  25. require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
  26. require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
  27. require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
  28. require_once DOL_DOCUMENT_ROOT.'/recruitment/class/recruitmentcandidature.class.php';
  29. require_once DOL_DOCUMENT_ROOT.'/recruitment/lib/recruitment_recruitmentcandidature.lib.php';
  30. // Load translation files required by the page
  31. $langs->loadLangs(array("recruitment", "other"));
  32. // Get parameters
  33. $id = GETPOST('id', 'int');
  34. $ref = GETPOST('ref', 'alpha');
  35. $action = GETPOST('action', 'aZ09');
  36. $cancel = GETPOST('cancel', 'aZ09');
  37. $backtopage = GETPOST('backtopage', 'alpha');
  38. $socid = GETPOST('socid', 'int');
  39. $contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : str_replace('_', '', basename(dirname(__FILE__)).basename(__FILE__, '.php')); // To manage different context of search
  40. if (GETPOST('actioncode', 'array')) {
  41. $actioncode = GETPOST('actioncode', 'array', 3);
  42. if (!count($actioncode)) {
  43. $actioncode = '0';
  44. }
  45. } else {
  46. $actioncode = GETPOST("actioncode", "alpha", 3) ?GETPOST("actioncode", "alpha", 3) : (GETPOST("actioncode") == '0' ? '0' : getDolGlobalString('AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT'));
  47. }
  48. $search_rowid = GETPOST('search_rowid');
  49. $search_agenda_label = GETPOST('search_agenda_label');
  50. $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
  51. $sortfield = GETPOST('sortfield', 'aZ09comma');
  52. $sortorder = GETPOST('sortorder', 'aZ09comma');
  53. $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
  54. if (empty($page) || $page == -1) {
  55. $page = 0;
  56. } // If $page is not defined, or '' or -1
  57. $offset = $limit * $page;
  58. $pageprev = $page - 1;
  59. $pagenext = $page + 1;
  60. if (!$sortfield) {
  61. $sortfield = 'a.datep,a.id';
  62. }
  63. if (!$sortorder) {
  64. $sortorder = 'DESC,DESC';
  65. }
  66. // Initialize technical objects
  67. $object = new RecruitmentCandidature($db);
  68. $extrafields = new ExtraFields($db);
  69. $diroutputmassaction = $conf->recruitment->dir_output.'/temp/massgeneration/'.$user->id;
  70. $hookmanager->initHooks(array('recruitmentcandidatureagenda', 'globalcard')); // Note that conf->hooks_modules contains array
  71. // Fetch optionals attributes and labels
  72. $extrafields->fetch_name_optionals_label($object->table_element);
  73. // Load object
  74. include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once // Must be include, not include_once. Include fetch and fetch_thirdparty but not fetch_optionals
  75. if ($id > 0 || !empty($ref)) {
  76. $upload_dir = $conf->recruitment->multidir_output[!empty($object->entity) ? $object->entity : $conf->entity]."/".$object->id;
  77. }
  78. $permissiontoadd = $user->rights->recruitment->recruitmentjobposition->write; // Used by the include of actions_addupdatedelete.inc.php
  79. // Security check - Protection if external user
  80. //if ($user->socid > 0) accessforbidden();
  81. //if ($user->socid > 0) $socid = $user->socid;
  82. $isdraft = (($object->status == $object::STATUS_DRAFT) ? 1 : 0);
  83. $result = restrictedArea($user, 'recruitment', $object->id, 'recruitment_recruitmentcandidature', 'recruitmentjobposition', '', 'rowid', $isdraft);
  84. /*
  85. * Actions
  86. */
  87. $parameters = array('id'=>$id);
  88. $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
  89. if ($reshook < 0) {
  90. setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
  91. }
  92. if (empty($reshook)) {
  93. // Cancel
  94. if (GETPOST('cancel', 'alpha') && !empty($backtopage)) {
  95. header("Location: ".$backtopage);
  96. exit;
  97. }
  98. // Purge search criteria
  99. if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // All tests are required to be compatible with all browsers
  100. $actioncode = '';
  101. $search_agenda_label = '';
  102. }
  103. }
  104. /*
  105. * View
  106. */
  107. $form = new Form($db);
  108. if ($object->id > 0) {
  109. $title = $object->ref." - ".$langs->trans('Agenda');
  110. //if (!empty($conf->global->MAIN_HTML_TITLE) && preg_match('/thirdpartynameonly/',$conf->global->MAIN_HTML_TITLE) && $object->name) $title=$object->name." - ".$title;
  111. $help_url = 'Module_Agenda_En|DE:Modul_Terminplanung';
  112. llxHeader('', $title, $help_url);
  113. if (isModEnabled('notification')) {
  114. $langs->load("mails");
  115. }
  116. $head = recruitmentCandidaturePrepareHead($object);
  117. print dol_get_fiche_head($head, 'agenda', $langs->trans("RecruitmentCandidature"), -1, $object->picto);
  118. // Object card
  119. // ------------------------------------------------------------
  120. $linkback = '<a href="'.dol_buildpath('/recruitment/recruitmentcandidature_list.php', 1).'?restore_lastsearch_values=1'.(!empty($socid) ? '&socid='.$socid : '').'">'.$langs->trans("BackToList").'</a>';
  121. $morehtmlref = '<div class="refidno">';
  122. $morehtmlref.= $object->getFullName('', 1);
  123. /*
  124. // Ref customer
  125. $morehtmlref.=$form->editfieldkey("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', 0, 1);
  126. $morehtmlref.=$form->editfieldval("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', null, null, '', 1);
  127. // Thirdparty
  128. $morehtmlref.='<br>'.$langs->trans('ThirdParty') . ' : ' . (is_object($object->thirdparty) ? $object->thirdparty->getNomUrl(1) : '');
  129. */
  130. // Project
  131. /*if (isModEnabled('project'))
  132. {
  133. $langs->load("projects");
  134. $morehtmlref .= $langs->trans('Project') . ' ';
  135. if ($permissiontoadd)
  136. {
  137. if ($action != 'classify')
  138. //$morehtmlref.='<a class="editfielda" href="' . $_SERVER['PHP_SELF'] . '?action=classify&token='.newToken().'&id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a> : ';
  139. $morehtmlref .=' : ';
  140. if ($action == 'classify') {
  141. //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1);
  142. $morehtmlref .= '<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">';
  143. $morehtmlref .= '<input type="hidden" name="action" value="classin">';
  144. $morehtmlref .= '<input type="hidden" name="token" value="'.newToken().'">';
  145. $morehtmlref .= $formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1);
  146. $morehtmlref .= '<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">';
  147. $morehtmlref .= '</form>';
  148. } else {
  149. $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1, '', 'maxwidth300');
  150. }
  151. } else {
  152. if (!empty($object->fk_project)) {
  153. $proj = new Project($db);
  154. $proj->fetch($object->fk_project);
  155. $morehtmlref .= ': '.$proj->getNomUrl();
  156. } else {
  157. $morehtmlref .= '';
  158. }
  159. }
  160. }*/
  161. $morehtmlref .= '</div>';
  162. dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref);
  163. print '<div class="fichecenter">';
  164. print '<div class="underbanner clearboth"></div>';
  165. $object->info($object->id);
  166. dol_print_object_info($object, 1);
  167. print '</div>';
  168. print dol_get_fiche_end();
  169. // Actions buttons
  170. $objthirdparty = $object;
  171. $objcon = new stdClass();
  172. $out = '&origin='.$object->element.'@recruitment&originid='.$object->id;
  173. $permok = $user->rights->agenda->myactions->create;
  174. if ((!empty($objthirdparty->id) || !empty($objcon->id)) && $permok) {
  175. //$out.='<a href="'.DOL_URL_ROOT.'/comm/action/card.php?action=create';
  176. if (get_class($objthirdparty) == 'Societe') {
  177. $out .= '&amp;socid='.$objthirdparty->id;
  178. }
  179. $backtopageurl = urlencode($_SERVER['PHP_SELF'].'?id='.$objthirdparty->id);
  180. $out .= (!empty($objcon->id) ? '&amp;contactid='.$objcon->id : '').'&amp;backtopage='.$backtopageurl;
  181. //$out.=$langs->trans("AddAnAction").' ';
  182. //$out.=img_picto($langs->trans("AddAnAction"),'filenew');
  183. //$out.="</a>";
  184. }
  185. print '<div class="tabsAction">';
  186. if (isModEnabled('agenda')) {
  187. if (!empty($user->rights->agenda->myactions->create) || $user->hasRight('agenda', 'allactions', 'create')) {
  188. print '<a class="butAction" href="'.DOL_URL_ROOT.'/comm/action/card.php?action=create'.$out.'">'.$langs->trans("AddAction").'</a>';
  189. } else {
  190. print '<a class="butActionRefused classfortooltip" href="#">'.$langs->trans("AddAction").'</a>';
  191. }
  192. }
  193. print '</div>';
  194. if (isModEnabled('agenda') && (!empty($user->rights->agenda->myactions->read) || !empty($user->rights->agenda->allactions->read))) {
  195. $param = '&id='.$object->id.'&socid='.$socid;
  196. if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
  197. $param .= '&contextpage='.urlencode($contextpage);
  198. }
  199. if ($limit > 0 && $limit != $conf->liste_limit) {
  200. $param .= '&limit='.((int) $limit);
  201. }
  202. //print load_fiche_titre($langs->trans("ActionsOnRecruitmentJobPosition"), '', '');
  203. // List of all actions
  204. $filters = array();
  205. $filters['search_agenda_label'] = $search_agenda_label;
  206. $filters['search_rowid'] = $search_rowid;
  207. // TODO Replace this with same code than into list.php
  208. show_actions_done($conf, $langs, $db, $object, null, 0, $actioncode, '', $filters, $sortfield, $sortorder, 'recruitment');
  209. }
  210. }
  211. // End of page
  212. llxFooter();
  213. $db->close();