recruitmentjobposition_applications.php 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287
  1. <?php
  2. /* Copyright (C) 2017 Laurent Destailleur <eldy@users.sourceforge.net>
  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 recruitmentjobposition_applications.php
  19. * \ingroup recruitment
  20. * \brief Page to see/add applications of a job position
  21. */
  22. // Load Dolibarr environment
  23. require_once '../main.inc.php';
  24. require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
  25. require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
  26. require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php';
  27. require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
  28. require_once DOL_DOCUMENT_ROOT.'/recruitment/class/recruitmentjobposition.class.php';
  29. require_once DOL_DOCUMENT_ROOT.'/recruitment/lib/recruitment_recruitmentjobposition.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. $confirm = GETPOST('confirm', 'alpha');
  37. $cancel = GETPOST('cancel', 'aZ09');
  38. $contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'recruitmentjobpositioncard'; // To manage different context of search
  39. $backtopage = GETPOST('backtopage', 'alpha');
  40. $backtopageforcancel = GETPOST('backtopageforcancel', 'alpha');
  41. //$lineid = GETPOST('lineid', 'int');
  42. // Initialize technical objects
  43. $object = new RecruitmentJobPosition($db);
  44. $extrafields = new ExtraFields($db);
  45. $diroutputmassaction = $conf->recruitment->dir_output.'/temp/massgeneration/'.$user->id;
  46. $hookmanager->initHooks(array('recruitmentjobpositioncard', 'globalcard')); // Note that conf->hooks_modules contains array
  47. // Fetch optionals attributes and labels
  48. $extrafields->fetch_name_optionals_label($object->table_element);
  49. $search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_');
  50. // Initialize array of search criterias
  51. $search_all = GETPOST("search_all", 'alpha');
  52. $search = array();
  53. foreach ($object->fields as $key => $val) {
  54. if (GETPOST('search_'.$key, 'alpha')) {
  55. $search[$key] = GETPOST('search_'.$key, 'alpha');
  56. }
  57. }
  58. if (empty($action) && empty($id) && empty($ref)) {
  59. $action = 'view';
  60. }
  61. // Load object
  62. include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once.
  63. $permissiontoread = $user->hasRight('recruitment', 'recruitmentjobposition', 'read');
  64. $permissiontoadd = $user->hasRight('recruitment', 'recruitmentjobposition', 'write'); // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php
  65. $permissiontodelete = $user->hasRight('recruitment', 'recruitmentjobposition', 'delete') || ($permissiontoadd && isset($object->status) && $object->status == $object::STATUS_DRAFT);
  66. $permissionnote = $user->hasRight('recruitment', 'recruitmentjobposition', 'write'); // Used by the include of actions_setnotes.inc.php
  67. $permissiondellink = $user->hasRight('recruitment', 'recruitmentjobposition', 'write'); // Used by the include of actions_dellink.inc.php
  68. $upload_dir = $conf->recruitment->multidir_output[isset($object->entity) ? $object->entity : 1];
  69. // Security check - Protection if external user
  70. //if ($user->socid > 0) accessforbidden();
  71. //if ($user->socid > 0) $socid = $user->socid;
  72. $isdraft = (($object->status == $object::STATUS_DRAFT) ? 1 : 0);
  73. $result = restrictedArea($user, 'recruitment', $object->id, 'recruitment_recruitmentjobposition', 'recruitmentjobposition', '', 'rowid', $isdraft);
  74. /*
  75. * Actions
  76. */
  77. $parameters = array();
  78. $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
  79. if ($reshook < 0) {
  80. setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
  81. }
  82. if (empty($reshook)) {
  83. $error = 0;
  84. $backurlforlist = DOL_URL_ROOT.'/recruitment/recruitmentjobposition_list.php';
  85. if (empty($backtopage) || ($cancel && empty($id))) {
  86. if (empty($backtopage) || ($cancel && strpos($backtopage, '__ID__'))) {
  87. if (empty($id) && (($action != 'add' && $action != 'create') || $cancel)) {
  88. $backtopage = $backurlforlist;
  89. } else {
  90. $backtopage = DOL_URL_ROOT.'/recruitment/recruitmentjobposition_card.php?id='.($id > 0 ? $id : '__ID__');
  91. }
  92. }
  93. }
  94. $triggermodname = 'RECRUITMENT_RECRUITMENTJOBPOSITION_MODIFY'; // Name of trigger action code to execute when we modify record
  95. // Actions cancel, add, update, update_extras, confirm_validate, confirm_delete, confirm_deleteline, confirm_clone, confirm_close, confirm_setdraft, confirm_reopen
  96. include DOL_DOCUMENT_ROOT.'/core/actions_addupdatedelete.inc.php';
  97. // Actions when linking object each other
  98. include DOL_DOCUMENT_ROOT.'/core/actions_dellink.inc.php';
  99. // Actions when printing a doc from card
  100. include DOL_DOCUMENT_ROOT.'/core/actions_printing.inc.php';
  101. // Action to move up and down lines of object
  102. //include DOL_DOCUMENT_ROOT.'/core/actions_lineupdown.inc.php';
  103. // Action to build doc
  104. include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php';
  105. if ($action == 'set_thirdparty' && $permissiontoadd) {
  106. $object->setValueFrom('fk_soc', GETPOST('fk_soc', 'int'), '', '', 'date', '', $user, 'RECRUITMENTJOBPOSITION_MODIFY');
  107. }
  108. if ($action == 'classin' && $permissiontoadd) {
  109. $object->setProject(GETPOST('projectid', 'int'));
  110. }
  111. // Actions to send emails
  112. $triggersendname = 'RECRUITMENTJOBPOSITION_SENTBYMAIL';
  113. $autocopy = 'MAIN_MAIL_AUTOCOPY_RECRUITMENTJOBPOSITION_TO';
  114. $trackid = 'recruitmentjobposition'.$object->id;
  115. include DOL_DOCUMENT_ROOT.'/core/actions_sendmails.inc.php';
  116. }
  117. /*
  118. * View
  119. */
  120. $form = new Form($db);
  121. $formfile = new FormFile($db);
  122. $formproject = new FormProjets($db);
  123. $title = $langs->trans("JobPositionApplications");
  124. $help_url = '';
  125. llxHeader('', $title, $help_url);
  126. // Part to show record
  127. if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'create'))) {
  128. $res = $object->fetch_optionals();
  129. $head = recruitmentjobpositionPrepareHead($object);
  130. print dol_get_fiche_head($head, 'candidatures', $langs->trans("RecruitmentCandidatures"), -1, $object->picto);
  131. $formconfirm = '';
  132. // Confirmation to delete
  133. if ($action == 'delete') {
  134. $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('DeleteRecruitmentJobPosition'), $langs->trans('ConfirmDeleteObject'), 'confirm_delete', '', 0, 1);
  135. }
  136. // Confirmation to delete line
  137. if ($action == 'deleteline') {
  138. $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id.'&lineid='.$lineid, $langs->trans('DeleteLine'), $langs->trans('ConfirmDeleteLine'), 'confirm_deleteline', '', 0, 1);
  139. }
  140. // Clone confirmation
  141. if ($action == 'clone') {
  142. // Create an array for form
  143. $formquestion = array();
  144. $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ToClone'), $langs->trans('ConfirmCloneAsk', $object->ref), 'confirm_clone', $formquestion, 'yes', 1);
  145. }
  146. // Confirmation of action xxxx
  147. if ($action == 'xxx') {
  148. $formquestion = array();
  149. /*
  150. $forcecombo=0;
  151. if ($conf->browser->name == 'ie') $forcecombo = 1; // There is a bug in IE10 that make combo inside popup crazy
  152. $formquestion = array(
  153. // 'text' => $langs->trans("ConfirmClone"),
  154. // array('type' => 'checkbox', 'name' => 'clone_content', 'label' => $langs->trans("CloneMainAttributes"), 'value' => 1),
  155. // array('type' => 'checkbox', 'name' => 'update_prices', 'label' => $langs->trans("PuttingPricesUpToDate"), 'value' => 1),
  156. // array('type' => 'other', 'name' => 'idwarehouse', 'label' => $langs->trans("SelectWarehouseForStockDecrease"), 'value' => $formproduct->selectWarehouses(GETPOST('idwarehouse')?GETPOST('idwarehouse'):'ifone', 'idwarehouse', '', 1, 0, 0, '', 0, $forcecombo))
  157. );
  158. */
  159. $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('XXX'), $text, 'confirm_xxx', $formquestion, 0, 1, 220);
  160. }
  161. // Call Hook formConfirm
  162. $parameters = array('formConfirm' => $formconfirm, 'lineid' => $lineid);
  163. $reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
  164. if (empty($reshook)) {
  165. $formconfirm .= $hookmanager->resPrint;
  166. } elseif ($reshook > 0) {
  167. $formconfirm = $hookmanager->resPrint;
  168. }
  169. // Print form confirm
  170. print $formconfirm;
  171. // Object card
  172. // ------------------------------------------------------------
  173. $linkback = '<a href="'.dol_buildpath('/recruitment/recruitmentjobposition_list.php', 1).'?restore_lastsearch_values=1'.(!empty($socid) ? '&socid='.$socid : '').'">'.$langs->trans("BackToList").'</a>';
  174. $morehtmlref = '<div class="refidno">';
  175. /*
  176. // Ref customer
  177. $morehtmlref.=$form->editfieldkey("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', 0, 1);
  178. $morehtmlref.=$form->editfieldval("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', null, null, '', 1);
  179. // Thirdparty
  180. $morehtmlref.='<br>'.$langs->trans('ThirdParty') . ' : ' . (is_object($object->thirdparty) ? $object->thirdparty->getNomUrl(1) : '');
  181. */
  182. // Project
  183. if (isModEnabled('project')) {
  184. $langs->load("projects");
  185. $morehtmlref .= $langs->trans('Project').' ';
  186. if ($permissiontoadd) {
  187. if ($action != 'classify') {
  188. $morehtmlref .= '<a class="editfielda" href="'.$_SERVER['PHP_SELF'].'?action=classify&token='.newToken().'&id='.$object->id.'">'.img_edit($langs->transnoentitiesnoconv('SetProject')).'</a>';
  189. }
  190. $morehtmlref .= ' : ';
  191. if ($action == 'classify') {
  192. //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1);
  193. $morehtmlref .= '<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">';
  194. $morehtmlref .= '<input type="hidden" name="action" value="classin">';
  195. $morehtmlref .= '<input type="hidden" name="token" value="'.newToken().'">';
  196. $morehtmlref .= $formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1);
  197. $morehtmlref .= '<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">';
  198. $morehtmlref .= '</form>';
  199. } else {
  200. $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1, '', 'maxwidth300');
  201. }
  202. } else {
  203. if (!empty($object->fk_project)) {
  204. $proj = new Project($db);
  205. $proj->fetch($object->fk_project);
  206. $morehtmlref .= ': '.$proj->getNomUrl();
  207. } else {
  208. $morehtmlref .= '';
  209. }
  210. }
  211. }
  212. $morehtmlref .= '</div>';
  213. dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref);
  214. print '<div class="fichecenter">';
  215. print '<div class="fichehalfleft">';
  216. print '<div class="underbanner clearboth"></div>';
  217. print '<table class="border centpercent tableforfield">'."\n";
  218. // Common attributes
  219. $keyforbreak = 'description'; // We change column just after this field
  220. unset($object->fields['fk_project']); // Hide field already shown in banner
  221. //unset($object->fields['fk_soc']); // Hide field already shown in banner
  222. include DOL_DOCUMENT_ROOT.'/core/tpl/commonfields_view.tpl.php';
  223. // Other attributes. Fields from hook formObjectOptions and Extrafields.
  224. include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php';
  225. print '</table>';
  226. print '</div>';
  227. print '</div>';
  228. print '<div class="clearboth"></div>';
  229. print dol_get_fiche_end();
  230. print '<br>'.$langs->trans("FeatureNotYetAvailable");
  231. }
  232. // End of page
  233. llxFooter();
  234. $db->close();