view.php 11 KB

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