view.php 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357
  1. <?php
  2. /* Copyright (C) 2020 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 htdocs/public/recruitment/view.php
  19. * \ingroup recruitment
  20. * \brief Public file to show on job
  21. */
  22. if (!defined('NOLOGIN')) {
  23. define("NOLOGIN", 1); // This means this output page does not require to be logged.
  24. }
  25. if (!defined('NOCSRFCHECK')) {
  26. define("NOCSRFCHECK", 1); // We accept to go on this page from external web site.
  27. }
  28. if (!defined('NOIPCHECK')) {
  29. define('NOIPCHECK', '1'); // Do not check IP defined into conf $dolibarr_main_restrict_ip
  30. }
  31. if (!defined('NOBROWSERNOTIF')) {
  32. define('NOBROWSERNOTIF', '1');
  33. }
  34. // Load Dolibarr environment
  35. require '../../main.inc.php';
  36. require_once DOL_DOCUMENT_ROOT.'/recruitment/class/recruitmentjobposition.class.php';
  37. require_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php';
  38. require_once DOL_DOCUMENT_ROOT.'/core/lib/security.lib.php';
  39. require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
  40. require_once DOL_DOCUMENT_ROOT.'/core/lib/payments.lib.php';
  41. // Load translation files required by the page
  42. $langs->loadLangs(array("companies", "other", "recruitment"));
  43. // Get parameters
  44. $action = GETPOST('action', 'aZ09');
  45. $cancel = GETPOST('cancel', 'alpha');
  46. $email = GETPOST('email', 'alpha');
  47. $backtopage = '';
  48. $ref = GETPOST('ref', 'alpha');
  49. if (GETPOST('btn_view')) {
  50. unset($_SESSION['email_customer']);
  51. }
  52. if (isset($_SESSION['email_customer'])) {
  53. $email = $_SESSION['email_customer'];
  54. }
  55. $object = new RecruitmentJobPosition($db);
  56. if (!$action) {
  57. if (!$ref) {
  58. print $langs->trans('ErrorBadParameters')." - ref missing";
  59. exit;
  60. } else {
  61. $object->fetch('', $ref);
  62. }
  63. }
  64. // Define $urlwithroot
  65. //$urlwithouturlroot=preg_replace('/'.preg_quote(DOL_URL_ROOT,'/').'$/i','',trim($dolibarr_main_url_root));
  66. //$urlwithroot=$urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file
  67. $urlwithroot = DOL_MAIN_URL_ROOT; // This is to use same domain name than current. For Paypal payment, we can use internal URL like localhost.
  68. // Security check
  69. if (empty($conf->recruitment->enabled)) {
  70. httponly_accessforbidden('Module Recruitment not enabled');
  71. }
  72. /*
  73. * Actions
  74. */
  75. if ($cancel) {
  76. if (!empty($backtopage)) {
  77. header("Location: ".$backtopage);
  78. exit;
  79. }
  80. $action = 'view';
  81. }
  82. if ($action == "view" || $action == "presend" || $action == "dosubmit") {
  83. $error = 0;
  84. $display_ticket = false;
  85. if (!strlen($ref)) {
  86. $error++;
  87. array_push($object->errors, $langs->trans("ErrorFieldRequired", $langs->transnoentities("Ref")));
  88. $action = '';
  89. }
  90. if (!strlen($email)) {
  91. $error++;
  92. array_push($object->errors, $langs->trans("ErrorFieldRequired", $langs->transnoentities("Email")));
  93. $action = '';
  94. } else {
  95. if (!isValidEmail($email)) {
  96. $error++;
  97. array_push($object->errors, $langs->trans("ErrorEmailInvalid"));
  98. $action = '';
  99. }
  100. }
  101. if (!$error) {
  102. $ret = $object->fetch('', $ref);
  103. }
  104. /*
  105. if (!$error && $action == "dosubmit")
  106. {
  107. // Test MAIN_SECURITY_MAX_POST_ON_PUBLIC_PAGES_BY_IP_ADDRESS
  108. // TODO Create job application
  109. if (!$error)
  110. {
  111. $action = 'view';
  112. }
  113. }
  114. */
  115. if ($error || $errors) {
  116. setEventMessages($object->error, $object->errors, 'errors');
  117. if ($action == "dosubmit") {
  118. $action = 'presend';
  119. } else {
  120. $action = '';
  121. }
  122. }
  123. }
  124. //var_dump($action);
  125. //$object->doActions($action);
  126. // Actions to send emails (for ticket, we need to manage the addfile and removefile only)
  127. $triggersendname = 'CANDIDATURE_SENTBYMAIL';
  128. $paramname = 'id';
  129. $autocopy = 'MAIN_MAIL_AUTOCOPY_CANDIDATURE_TO'; // used to know the automatic BCC to add
  130. $trackid = 'recruitmentcandidature'.$object->id;
  131. include DOL_DOCUMENT_ROOT.'/core/actions_sendmails.inc.php';
  132. /*
  133. * View
  134. */
  135. $now = dol_now();
  136. $head = '';
  137. if (!empty($conf->global->MAIN_RECRUITMENT_CSS_URL)) {
  138. $head = '<link rel="stylesheet" type="text/css" href="'.$conf->global->MAIN_RECRUITMENT_CSS_URL.'?lang='.$langs->defaultlang.'">'."\n";
  139. }
  140. $conf->dol_hide_topmenu = 1;
  141. $conf->dol_hide_leftmenu = 1;
  142. if (!$conf->global->RECRUITMENT_ENABLE_PUBLIC_INTERFACE) {
  143. $langs->load("errors");
  144. print '<div class="error">'.$langs->trans('ErrorPublicInterfaceNotEnabled').'</div>';
  145. $db->close();
  146. exit();
  147. }
  148. $arrayofjs = array();
  149. $arrayofcss = array();
  150. $replacemainarea = (empty($conf->dol_hide_leftmenu) ? '<div>' : '').'<div>';
  151. llxHeader($head, $langs->trans("PositionToBeFilled"), '', '', 0, 0, '', '', '', 'onlinepaymentbody', $replacemainarea, 1, 1);
  152. print '<span id="dolpaymentspan"></span>'."\n";
  153. print '<div class="center">'."\n";
  154. print '<form id="dolpaymentform" class="center" name="paymentform" action="'.$_SERVER["PHP_SELF"].'" method="POST">'."\n";
  155. print '<input type="hidden" name="token" value="'.newToken().'">'."\n";
  156. print '<input type="hidden" name="action" value="dosubmit">'."\n";
  157. print '<input type="hidden" name="tag" value="'.GETPOST("tag", 'alpha').'">'."\n";
  158. print '<input type="hidden" name="suffix" value="'.GETPOST("suffix", 'alpha').'">'."\n";
  159. print '<input type="hidden" name="securekey" value="'.$SECUREKEY.'">'."\n";
  160. print '<input type="hidden" name="entity" value="'.$entity.'" />';
  161. print "\n";
  162. print '<!-- Form to view job -->'."\n";
  163. // Show logo (search order: logo defined by ONLINE_SIGN_LOGO_suffix, then ONLINE_SIGN_LOGO_, then small company logo, large company logo, theme logo, common logo)
  164. // Define logo and logosmall
  165. $logosmall = $mysoc->logo_small;
  166. $logo = $mysoc->logo;
  167. $paramlogo = 'ONLINE_RECRUITMENT_LOGO_'.$suffix;
  168. if (!empty($conf->global->$paramlogo)) {
  169. $logosmall = $conf->global->$paramlogo;
  170. } elseif (!empty($conf->global->ONLINE_RECRUITMENT_LOGO)) {
  171. $logosmall = $conf->global->ONLINE_RECRUITMENT_LOGO;
  172. }
  173. //print '<!-- Show logo (logosmall='.$logosmall.' logo='.$logo.') -->'."\n";
  174. // Define urllogo
  175. $urllogo = '';
  176. $urllogofull = '';
  177. if (!empty($logosmall) && is_readable($conf->mycompany->dir_output.'/logos/thumbs/'.$logosmall)) {
  178. $urllogo = DOL_URL_ROOT.'/viewimage.php?modulepart=mycompany&amp;entity='.$conf->entity.'&amp;file='.urlencode('logos/thumbs/'.$logosmall);
  179. $urllogofull = $dolibarr_main_url_root.'/viewimage.php?modulepart=mycompany&entity='.$conf->entity.'&file='.urlencode('logos/thumbs/'.$logosmall);
  180. } elseif (!empty($logo) && is_readable($conf->mycompany->dir_output.'/logos/'.$logo)) {
  181. $urllogo = DOL_URL_ROOT.'/viewimage.php?modulepart=mycompany&amp;entity='.$conf->entity.'&amp;file='.urlencode('logos/'.$logo);
  182. $urllogofull = $dolibarr_main_url_root.'/viewimage.php?modulepart=mycompany&entity='.$conf->entity.'&file='.urlencode('logos/'.$logo);
  183. }
  184. // Output html code for logo
  185. if ($urllogo) {
  186. print '<div class="backgreypublicpayment">';
  187. print '<div class="logopublicpayment">';
  188. if (!empty($mysoc->url)) {
  189. print '<a href="'.$mysoc->url.'" target="_blank" rel="noopener">';
  190. }
  191. print '<img id="dolpaymentlogo" src="'.$urllogofull.'">';
  192. if (!empty($mysoc->url)) {
  193. print '</a>';
  194. }
  195. print '</div>';
  196. if (empty($conf->global->MAIN_HIDE_POWERED_BY)) {
  197. print '<div class="poweredbypublicpayment opacitymedium right"><a class="poweredbyhref" href="https://www.dolibarr.org?utm_medium=website&utm_source=poweredby" target="dolibarr" rel="noopener">'.$langs->trans("PoweredBy").'<br><img class="poweredbyimg" src="'.DOL_URL_ROOT.'/theme/dolibarr_logo.svg" width="80px"></a></div>';
  198. }
  199. print '</div>';
  200. }
  201. if (!empty($conf->global->RECRUITMENT_IMAGE_PUBLIC_INTERFACE)) {
  202. print '<div class="backimagepublicrecruitment">';
  203. print '<img id="idRECRUITMENT_IMAGE_PUBLIC_INTERFACE" src="'.$conf->global->RECRUITMENT_IMAGE_PUBLIC_INTERFACE.'">';
  204. print '</div>';
  205. }
  206. print '<table id="dolpaymenttable" summary="Job position offer" class="center">'."\n";
  207. // Output introduction text
  208. $text = '';
  209. if (!empty($conf->global->RECRUITMENT_NEWFORM_TEXT)) {
  210. $reg = array();
  211. if (preg_match('/^\((.*)\)$/', $conf->global->RECRUITMENT_NEWFORM_TEXT, $reg)) {
  212. $text .= $langs->trans($reg[1])."<br>\n";
  213. } else {
  214. $text .= $conf->global->RECRUITMENT_NEWFORM_TEXT."<br>\n";
  215. }
  216. $text = '<tr><td align="center"><br>'.$text.'<br></td></tr>'."\n";
  217. }
  218. if (empty($text)) {
  219. $text .= '<tr><td class="textpublicpayment"><br>'.$langs->trans("JobOfferToBeFilled", $mysoc->name);
  220. $text .= ' &nbsp; - &nbsp; <strong>'.$mysoc->name.'</strong>';
  221. $text .= ' &nbsp; - &nbsp; <span class="nowraponall"><span class="fa fa-calendar secondary"></span> '.dol_print_date($object->date_creation).'</span>';
  222. $text .= '</td></tr>'."\n";
  223. $text .= '<tr><td class="textpublicpayment"><h1 class="paddingleft paddingright">'.$object->label.'</h1><br></td></tr>'."\n";
  224. }
  225. print $text;
  226. // Output payment summary form
  227. print '<tr><td class="left">';
  228. print '<div with="100%" id="tablepublicpayment">';
  229. print '<div class="opacitymedium">'.$langs->trans("ThisIsInformationOnJobPosition").' :</div>'."\n";
  230. $error = 0;
  231. $found = true;
  232. print '<br>';
  233. // Label
  234. print $langs->trans("Label").' : ';
  235. print '<b>'.dol_escape_htmltag($object->label).'</b><br>';
  236. // Date
  237. print $langs->trans("DateExpected").' : ';
  238. print '<b>';
  239. if ($object->date_planned > $now) {
  240. print dol_print_date($object->date_planned, 'day');
  241. } else {
  242. print $langs->trans("ASAP");
  243. }
  244. print '</b><br>';
  245. // Remuneration
  246. print $langs->trans("Remuneration").' : ';
  247. print '<b>';
  248. print dol_escape_htmltag($object->remuneration_suggested);
  249. print '</b><br>';
  250. // Contact
  251. $tmpuser = new User($db);
  252. $tmpuser->fetch($object->fk_user_recruiter);
  253. print $langs->trans("ContactForRecruitment").' : ';
  254. $emailforcontact = $object->email_recruiter;
  255. if (empty($emailforcontact)) {
  256. $emailforcontact = $tmpuser->email;
  257. if (empty($emailforcontact)) {
  258. $emailforcontact = $mysoc->email;
  259. }
  260. }
  261. print '<b class="wordbreak">';
  262. print $tmpuser->getFullName(-1);
  263. print ' &nbsp; '.dol_print_email($emailforcontact, 0, 0, 1, 0, 0, 'envelope');
  264. print '</b>';
  265. print '</b><br>';
  266. if ($object->status == RecruitmentJobPosition::STATUS_RECRUITED) {
  267. print info_admin($langs->trans("JobClosedTextCandidateFound"), 0, 0, 0, 'warning');
  268. }
  269. if ($object->status == RecruitmentJobPosition::STATUS_CANCELED) {
  270. print info_admin($langs->trans("JobClosedTextCanceled"), 0, 0, 0, 'warning');
  271. }
  272. print '<br>';
  273. // Description
  274. $text = $object->description;
  275. print $text;
  276. print '<input type="hidden" name="ref" value="'.$object->ref.'">';
  277. print '</div>'."\n";
  278. print "\n";
  279. if ($action != 'dosubmit') {
  280. if ($found && !$error) {
  281. // We are in a management option and no error
  282. } else {
  283. dol_print_error_email('ERRORSUBMITAPPLICATION');
  284. }
  285. } else {
  286. // Print
  287. }
  288. print '</td></tr>'."\n";
  289. print '</table>'."\n";
  290. print '</form>'."\n";
  291. print '</div>'."\n";
  292. print '<br>';
  293. htmlPrintOnlinePaymentFooter($mysoc, $langs);
  294. llxFooter('', 'public');
  295. $db->close();