index.php 11 KB

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