index.php 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307
  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. $SECUREKEY = GETPOST("securekey");
  46. $entity = GETPOST('entity', 'int') ? GETPOST('entity', 'int') : $conf->entity;
  47. $backtopage = '';
  48. $suffix = "";
  49. // Load variable for pagination
  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 < 0 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha')) {
  55. $page = 0;
  56. } // If $page is not defined, or '' or -1 or if we click on clear filters
  57. $offset = $limit * $page;
  58. $pageprev = $page - 1;
  59. $pagenext = $page + 1;
  60. if (GETPOST('btn_view')) {
  61. unset($_SESSION['email_customer']);
  62. }
  63. if (isset($_SESSION['email_customer'])) {
  64. $email = $_SESSION['email_customer'];
  65. }
  66. $object = new RecruitmentJobPosition($db);
  67. // Define $urlwithroot
  68. //$urlwithouturlroot=preg_replace('/'.preg_quote(DOL_URL_ROOT,'/').'$/i','',trim($dolibarr_main_url_root));
  69. //$urlwithroot=$urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file
  70. $urlwithroot = DOL_MAIN_URL_ROOT; // This is to use same domain name than current. For Paypal payment, we can use internal URL like localhost.
  71. // Security check
  72. if (empty($conf->recruitment->enabled)) {
  73. httponly_accessforbidden('Module Recruitment not enabled');
  74. }
  75. /*
  76. * Actions
  77. */
  78. // None
  79. /*
  80. * View
  81. */
  82. $head = '';
  83. if (!empty($conf->global->MAIN_RECRUITMENT_CSS_URL)) {
  84. $head = '<link rel="stylesheet" type="text/css" href="'.$conf->global->MAIN_RECRUITMENT_CSS_URL.'?lang='.$langs->defaultlang.'">'."\n";
  85. }
  86. $conf->dol_hide_topmenu = 1;
  87. $conf->dol_hide_leftmenu = 1;
  88. if (!$conf->global->RECRUITMENT_ENABLE_PUBLIC_INTERFACE) {
  89. $langs->load("errors");
  90. print '<div class="error">'.$langs->trans('ErrorPublicInterfaceNotEnabled').'</div>';
  91. $db->close();
  92. exit();
  93. }
  94. $arrayofjs = array();
  95. $arrayofcss = array();
  96. $replacemainarea = (empty($conf->dol_hide_leftmenu) ? '<div>' : '').'<div>';
  97. llxHeader($head, $langs->trans("PositionToBeFilled"), '', '', 0, 0, '', '', '', 'onlinepaymentbody', $replacemainarea, 1, 1);
  98. print '<span id="dolpaymentspan"></span>'."\n";
  99. print '<div class="center">'."\n";
  100. print '<form id="dolpaymentform" class="center" name="paymentform" action="'.$_SERVER["PHP_SELF"].'" method="POST">'."\n";
  101. print '<input type="hidden" name="token" value="'.newToken().'">'."\n";
  102. print '<input type="hidden" name="action" value="dosign">'."\n";
  103. print '<input type="hidden" name="tag" value="'.GETPOST("tag", 'alpha').'">'."\n";
  104. print '<input type="hidden" name="suffix" value="'.GETPOST("suffix", 'alpha').'">'."\n";
  105. print '<input type="hidden" name="securekey" value="'.$SECUREKEY.'">'."\n";
  106. print '<input type="hidden" name="entity" value="'.$entity.'" />';
  107. print "\n";
  108. print '<!-- Form to view jobs -->'."\n";
  109. // 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)
  110. // Define logo and logosmall
  111. $logosmall = $mysoc->logo_small;
  112. $logo = $mysoc->logo;
  113. $paramlogo = 'ONLINE_RECRUITMENT_LOGO_'.$suffix;
  114. if (!empty($conf->global->$paramlogo)) {
  115. $logosmall = $conf->global->$paramlogo;
  116. } elseif (!empty($conf->global->ONLINE_RECRUITMENT_LOGO)) {
  117. $logosmall = $conf->global->ONLINE_RECRUITMENT_LOGO_;
  118. }
  119. //print '<!-- Show logo (logosmall='.$logosmall.' logo='.$logo.') -->'."\n";
  120. // Define urllogo
  121. $urllogo = '';
  122. $urllogofull = '';
  123. if (!empty($logosmall) && is_readable($conf->mycompany->dir_output.'/logos/thumbs/'.$logosmall)) {
  124. $urllogo = DOL_URL_ROOT.'/viewimage.php?modulepart=mycompany&amp;entity='.$conf->entity.'&amp;file='.urlencode('logos/thumbs/'.$logosmall);
  125. $urllogofull = $dolibarr_main_url_root.'/viewimage.php?modulepart=mycompany&entity='.$conf->entity.'&file='.urlencode('logos/thumbs/'.$logosmall);
  126. } elseif (!empty($logo) && is_readable($conf->mycompany->dir_output.'/logos/'.$logo)) {
  127. $urllogo = DOL_URL_ROOT.'/viewimage.php?modulepart=mycompany&amp;entity='.$conf->entity.'&amp;file='.urlencode('logos/'.$logo);
  128. $urllogofull = $dolibarr_main_url_root.'/viewimage.php?modulepart=mycompany&entity='.$conf->entity.'&file='.urlencode('logos/'.$logo);
  129. }
  130. // Output html code for logo
  131. if ($urllogo) {
  132. print '<div class="backgreypublicpayment">';
  133. print '<div class="logopublicpayment">';
  134. print '<img id="dolpaymentlogo" src="'.$urllogo.'">';
  135. print '</div>';
  136. if (empty($conf->global->MAIN_HIDE_POWERED_BY)) {
  137. 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>';
  138. }
  139. print '</div>';
  140. }
  141. if (!empty($conf->global->RECRUITMENT_IMAGE_PUBLIC_INTERFACE)) {
  142. print '<div class="backimagepublicrecruitment">';
  143. print '<img id="idPROJECT_IMAGE_PUBLIC_SUGGEST_BOOTH" src="'.$conf->global->RECRUITMENT_IMAGE_PUBLIC_INTERFACE.'">';
  144. print '</div>';
  145. }
  146. $results = $object->fetchAll($sortfield, $sortorder, 0, 0, array('status' => 1));
  147. if (is_array($results)) {
  148. if (empty($results)) {
  149. print '<br>';
  150. print $langs->trans("NoPositionOpen");
  151. } else {
  152. print '<br><br><br>';
  153. print '<span class="opacitymedium">'.$langs->trans("WeAreRecruiting").'</span>';
  154. print '<br><br><br>';
  155. print '<br class="hideonsmartphone">';
  156. foreach ($results as $job) {
  157. $object = $job;
  158. print '<table id="dolpaymenttable" summary="Job position offer" class="center">'."\n";
  159. // Output introduction text
  160. $text = '';
  161. if (!empty($conf->global->RECRUITMENT_NEWFORM_TEXT)) {
  162. $reg = array();
  163. if (preg_match('/^\((.*)\)$/', $conf->global->RECRUITMENT_NEWFORM_TEXT, $reg)) {
  164. $text .= $langs->trans($reg[1])."<br>\n";
  165. } else {
  166. $text .= $conf->global->RECRUITMENT_NEWFORM_TEXT."<br>\n";
  167. }
  168. $text = '<tr><td align="center"><br>'.$text.'<br></td></tr>'."\n";
  169. }
  170. if (empty($text)) {
  171. $text .= '<tr><td class="textpublicpayment"><br>'.$langs->trans("JobOfferToBeFilled", $mysoc->name);
  172. $text .= ' &nbsp; - &nbsp; <strong>'.$mysoc->name.'</strong>';
  173. $text .= ' &nbsp; - &nbsp; <span class="nowraponall"><span class="fa fa-calendar secondary"></span> '.dol_print_date($object->date_creation).'</span>';
  174. $text .= '</td></tr>'."\n";
  175. $text .= '<tr><td class="textpublicpayment"><h1 class="paddingleft paddingright">'.$object->label.'</h1></td></tr>'."\n";
  176. }
  177. print $text;
  178. // Output payment summary form
  179. print '<tr><td class="left">';
  180. print '<div with="100%" id="tablepublicpayment">';
  181. print '<div class="opacitymedium">'.$langs->trans("ThisIsInformationOnJobPosition").' :</div>'."\n";
  182. $error = 0;
  183. $found = true;
  184. print '<br>';
  185. // Label
  186. print $langs->trans("Label").' : ';
  187. print '<b>'.dol_escape_htmltag($object->label).'</b><br>';
  188. // Date
  189. print $langs->trans("DateExpected").' : ';
  190. print '<b>';
  191. if ($object->date_planned > $now) {
  192. print dol_print_date($object->date_planned, 'day');
  193. } else {
  194. print $langs->trans("ASAP");
  195. }
  196. print '</b><br>';
  197. // Remuneration
  198. print $langs->trans("Remuneration").' : ';
  199. print '<b>';
  200. print dol_escape_htmltag($object->remuneration_suggested);
  201. print '</b><br>';
  202. // Contact
  203. $tmpuser = new User($db);
  204. $tmpuser->fetch($object->fk_user_recruiter);
  205. print $langs->trans("ContactForRecruitment").' : ';
  206. $emailforcontact = $object->email_recruiter;
  207. if (empty($emailforcontact)) {
  208. $emailforcontact = $tmpuser->email;
  209. if (empty($emailforcontact)) {
  210. $emailforcontact = $mysoc->email;
  211. }
  212. }
  213. print '<b class="wordbreak">';
  214. print $tmpuser->getFullName(-1);
  215. print ' &nbsp; '.dol_print_email($emailforcontact, 0, 0, 1, 0, 0, 'envelope');
  216. print '</b>';
  217. print '</b><br>';
  218. if ($object->status == RecruitmentJobPosition::STATUS_RECRUITED) {
  219. print info_admin($langs->trans("JobClosedTextCandidateFound"), 0, 0, 0, 'warning');
  220. }
  221. if ($object->status == RecruitmentJobPosition::STATUS_CANCELED) {
  222. print info_admin($langs->trans("JobClosedTextCanceled"), 0, 0, 0, 'warning');
  223. }
  224. print '<br>';
  225. // Description
  226. $text = $object->description;
  227. print $text;
  228. print '<input type="hidden" name="ref" value="'.$object->ref.'">';
  229. print '</div>'."\n";
  230. print "\n";
  231. if ($action != 'dosubmit') {
  232. if ($found && !$error) {
  233. // We are in a management option and no error
  234. } else {
  235. dol_print_error_email('ERRORSUBMITAPPLICATION');
  236. }
  237. } else {
  238. // Print
  239. }
  240. print '</td></tr>'."\n";
  241. print '</table>'."\n";
  242. print '<br><br class="hideonsmartphone"><br class="hideonsmartphone"><br class="hideonsmartphone">'."\n";
  243. }
  244. }
  245. } else {
  246. dol_print_error($db, $object->error, $object->errors);
  247. }
  248. print '</form>'."\n";
  249. print '</div>'."\n";
  250. print '<br>';
  251. htmlPrintOnlinePaymentFooter($mysoc, $langs);
  252. llxFooter('', 'public');
  253. $db->close();