* Copyright (C) 2024 Frédéric France * Copyright (C) 2024 MDW * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ /** * \file htdocs/public/recruitment/view.php * \ingroup recruitment * \brief Public file to show on job */ if (!defined('NOLOGIN')) { define("NOLOGIN", 1); // This means this output page does not require to be logged. } if (!defined('NOCSRFCHECK')) { define("NOCSRFCHECK", 1); // We accept to go on this page from external web site. } if (!defined('NOIPCHECK')) { define('NOIPCHECK', '1'); // Do not check IP defined into conf $dolibarr_main_restrict_ip } if (!defined('NOBROWSERNOTIF')) { define('NOBROWSERNOTIF', '1'); } // Load Dolibarr environment require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/recruitment/class/recruitmentjobposition.class.php'; require_once DOL_DOCUMENT_ROOT.'/recruitment/class/recruitmentcandidature.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/security.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/payments.lib.php'; require_once DOL_DOCUMENT_ROOT . '/core/lib/public.lib.php'; /** * @var Conf $conf * @var DoliDB $db * @var HookManager $hookmanager * @var Societe $mysoc * @var Translate $langs */ // Load translation files required by the page $langs->loadLangs(array("companies", "other", "recruitment")); // Get parameters $action = GETPOST('action', 'aZ09'); $cancel = GETPOST('cancel', 'alpha'); $email = GETPOST('email', 'alpha'); $firstname = GETPOST('firstname', 'alpha'); $lastname = GETPOST('lastname', 'alpha'); $birthday = GETPOST('birthday', 'alpha'); $phone = GETPOST('phone', 'alpha'); $message = GETPOST('message', 'alpha'); $requestedremuneration = GETPOST('requestedremuneration', 'alpha'); $ref = GETPOST('ref', 'alpha'); if (GETPOST('btn_view')) { unset($_SESSION['email_customer']); } if (isset($_SESSION['email_customer'])) { $email = $_SESSION['email_customer']; } $object = new RecruitmentJobPosition($db); if (!$ref) { print $langs->trans('ErrorBadParameters')." - ref missing"; exit; } // Define $urlwithroot //$urlwithouturlroot=preg_replace('/'.preg_quote(DOL_URL_ROOT,'/').'$/i','',trim($dolibarr_main_url_root)); //$urlwithroot=$urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file $urlwithroot = DOL_MAIN_URL_ROOT; // This is to use same domain name than current. For Paypal payment, we can use internal URL like localhost. $backtopage = $urlwithroot.'/public/recruitment/index.php'; // Security check if (!isModEnabled("recruitment")) { httponly_accessforbidden('Module Recruitment not enabled'); } $object->fetch(0, $ref); $user->loadDefaultValues(); $errmsg = ""; /* * Actions */ if ($cancel) { if (!empty($backtopage)) { header("Location: ".$backtopage); exit; } } if ($action == "dosubmit") { // Test on permission not required here (anonymous action protected by mitigation of /public/... urls) $error = 0; $db->begin(); if (!strlen($ref)) { $error++; array_push($object->errors, $langs->trans("ErrorFieldRequired", $langs->transnoentities("Ref"))); $action = 'view'; } if (!strlen($email)) { $error++; array_push($object->errors, $langs->trans("ErrorFieldRequired", $langs->transnoentities("Email"))); $action = 'view'; } else { if (!isValidEmail($email)) { $error++; array_push($object->errors, $langs->trans("ErrorEmailInvalid")); $action = 'view'; } } if (!strlen($lastname)) { $error++; array_push($object->errors, $langs->trans("ErrorFieldRequired", $langs->transnoentities("Lastname"))); $action = 'view'; } if (!$error) { $sql = "SELECT rrc.rowid FROM ".MAIN_DB_PREFIX."recruitment_recruitmentcandidature as rrc"; $sql .= " WHERE rrc.email = '". $db->escape($email)."'"; $sql .= " AND rrc.entity IN (". getEntity($object->element, 0).")"; $resql = $db->query($sql); if ($resql) { $num = $db->num_rows($resql); if ($num > 0) { $error++; setEventMessages($langs->trans("ErrorRecruitmmentCandidatureAlreadyExists", $email), null, 'errors'); } } else { dol_print_error($db); $error++; } } if (!$error) { // Test on permission not required here (anonymous action protected by mitigation of /public/... urls) $candidature = new RecruitmentCandidature($db); $candidature->firstname = GETPOST('firstname', 'alpha'); $candidature->lastname = GETPOST('lastname', 'alpha'); $candidature->email = GETPOST('email', 'alpha'); $candidature->phone = GETPOST('phone', 'alpha'); $candidature->date_birth = GETPOST('birthday', 'alpha'); $candidature->requestedremuneration = GETPOST('requestedremuneration', 'alpha'); $candidature->description = GETPOST('message', 'alpha'); $candidature->fk_recruitmentjobposition = $object->id; $candidature->ip = getUserRemoteIP(); // Test MAIN_SECURITY_MAX_POST_ON_PUBLIC_PAGES_BY_IP_ADDRESS $nb_post_max = getDolGlobalInt("MAIN_SECURITY_MAX_POST_ON_PUBLIC_PAGES_BY_IP_ADDRESS", 200); if (checkNbPostsForASpeceificIp($candidature, $nb_post_max) <= 0) { $error++; $errmsg .= implode('
', $candidature->errors); } if (!$error) { $result = $candidature->create($user); if ($result <= 0) { $error++; $errmsg .= implode('
', $candidature->errors); } } if (!$error) { $candidature->validate($user); if ($result <= 0) { $error++; $errmsg .= implode('
', $candidature->errors); } } } if (!$error) { $db->commit(); setEventMessages($langs->trans("RecruitmentCandidatureSaved"), null); header("Location: " . $backtopage); exit; } else { $db->rollback(); $action = "view"; } } // Actions to send emails (for ticket, we need to manage the addfile and removefile only) $triggersendname = 'CANDIDATURE_SENTBYMAIL'; $paramname = 'id'; $autocopy = 'MAIN_MAIL_AUTOCOPY_CANDIDATURE_TO'; // used to know the automatic BCC to add $trackid = 'recruitmentcandidature'.$object->id; include DOL_DOCUMENT_ROOT.'/core/actions_sendmails.inc.php'; /* * View */ $form = new Form($db); $now = dol_now(); $head = ''; if (getDolGlobalString('MAIN_RECRUITMENT_CSS_URL')) { $head = ''."\n"; } $conf->dol_hide_topmenu = 1; $conf->dol_hide_leftmenu = 1; if (!$conf->global->RECRUITMENT_ENABLE_PUBLIC_INTERFACE) { $langs->load("errors"); print '
'.$langs->trans('ErrorPublicInterfaceNotEnabled').'
'; $db->close(); exit(); } $arrayofjs = array(); $arrayofcss = array(); $replacemainarea = (empty($conf->dol_hide_leftmenu) ? '
' : '').'
'; llxHeader($head, $langs->trans("PositionToBeFilled"), '', '', 0, 0, '', '', '', 'onlinepaymentbody', $replacemainarea, 1, 1); dol_htmloutput_errors($errmsg); print ''."\n"; print '
'."\n"; print '
'."\n"; print ''."\n"; print ''."\n"; print ''."\n"; print ''."\n"; print ''."\n"; print ''; print "\n"; print ''."\n"; // 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) // Define logo and logosmall $logosmall = $mysoc->logo_small; $logo = $mysoc->logo; $paramlogo = 'ONLINE_RECRUITMENT_LOGO_'.$suffix; if (getDolGlobalString($paramlogo)) { $logosmall = getDolGlobalString($paramlogo); } elseif (getDolGlobalString('ONLINE_RECRUITMENT_LOGO')) { $logosmall = getDolGlobalString('ONLINE_RECRUITMENT_LOGO'); } //print ''."\n"; // Define urllogo $urllogo = ''; $urllogofull = ''; if (!empty($logosmall) && is_readable($conf->mycompany->dir_output.'/logos/thumbs/'.$logosmall)) { $urllogo = DOL_URL_ROOT.'/viewimage.php?modulepart=mycompany&entity='.$conf->entity.'&file='.urlencode('logos/thumbs/'.$logosmall); $urllogofull = $dolibarr_main_url_root.'/viewimage.php?modulepart=mycompany&entity='.$conf->entity.'&file='.urlencode('logos/thumbs/'.$logosmall); } elseif (!empty($logo) && is_readable($conf->mycompany->dir_output.'/logos/'.$logo)) { $urllogo = DOL_URL_ROOT.'/viewimage.php?modulepart=mycompany&entity='.$conf->entity.'&file='.urlencode('logos/'.$logo); $urllogofull = $dolibarr_main_url_root.'/viewimage.php?modulepart=mycompany&entity='.$conf->entity.'&file='.urlencode('logos/'.$logo); } // Output html code for logo if ($urllogo) { print '
'; print '
'; if (!empty($mysoc->url)) { print ''; } print ''; if (!empty($mysoc->url)) { print ''; } print '
'; if (!getDolGlobalString('MAIN_HIDE_POWERED_BY')) { print ''; } print '
'; } if (getDolGlobalString('RECRUITMENT_IMAGE_PUBLIC_INTERFACE')) { print '
'; print ''; print '
'; } print ''."\n"; // Output introduction text $text = ''; if (getDolGlobalString('RECRUITMENT_NEWFORM_TEXT')) { $reg = array(); if (preg_match('/^\((.*)\)$/', $conf->global->RECRUITMENT_NEWFORM_TEXT, $reg)) { $text .= $langs->trans($reg[1])."
\n"; } else { $text .= getDolGlobalString('RECRUITMENT_NEWFORM_TEXT') . "
\n"; } $text = ''."\n"; } if (empty($text)) { $text .= ''."\n"; $text .= ''."\n"; } print $text; // Output payment summary form print ''."\n"; print ''."\n"; print ''."\n"; print ''."\n"; print ''."\n"; print ''."\n"; print ''."\n"; print ''."\n"; print ''."\n"; } else { dol_print_error_email('ERRORSUBMITAPPLICATION'); } } else { // Print } print ''."\n"; print '

'.$text.'

'.$langs->trans("JobOfferToBeFilled", $mysoc->name); $text .= '   -   '.$mysoc->name.''; $text .= '   -   '.dol_print_date($object->date_creation).''; $text .= '

'.$object->label.'


'; print '
'; print '
'.$langs->trans("ThisIsInformationOnJobPosition").' :
'."\n"; $error = 0; $found = true; print '
'; // Label print $langs->trans("Label").' : '; print ''.dol_escape_htmltag($object->label).'
'; // Date print $langs->trans("DateExpected").' : '; print ''; if ($object->date_planned > $now) { print dol_print_date($object->date_planned, 'day'); } else { print $langs->trans("ASAP"); } print '
'; // Remuneration print $langs->trans("Remuneration").' : '; print ''; print dol_escape_htmltag($object->remuneration_suggested); print '
'; // Contact $tmpuser = new User($db); $tmpuser->fetch($object->fk_user_recruiter); print $langs->trans("ContactForRecruitment").' : '; $emailforcontact = $object->email_recruiter; if (empty($emailforcontact)) { $emailforcontact = $tmpuser->email; if (empty($emailforcontact)) { $emailforcontact = $mysoc->email; } } print ''; print $tmpuser->getFullName(-1); print '   '.dol_print_email($emailforcontact, 0, 0, 1, 0, 0, 'envelope'); print ''; print '
'; if ($object->status == RecruitmentJobPosition::STATUS_RECRUITED) { print info_admin($langs->trans("JobClosedTextCandidateFound"), 0, 0, '0', 'warning'); } if ($object->status == RecruitmentJobPosition::STATUS_CANCELED) { print info_admin($langs->trans("JobClosedTextCanceled"), 0, 0, '0', 'warning'); } print '
'; // Description $text = $object->description; print $text; print ''; print '
'."\n"; print "\n"; if ($action != 'dosubmit') { if ($found && !$error) { // We are in a management option and no error print '
'.$langs->trans("Lastname").''; print ''; print '
'.$langs->trans("Firstname").''; print ''; print '
'.$langs->trans("Email").''; print img_picto("", "email").''; print '
'.$langs->trans("Phone").''; print img_picto("", "phone").''; print '
'.$langs->trans("DateOfBirth").''; print $form->selectDate($birthday, 'birthday', 0, 0, 1, "", 1, 0); print '
'.$langs->trans("RequestedRemuneration").''; print ''; print '
'.$langs->trans("Message").''; print ''; print '
'; print $form->buttonsSaveCancel('Submit', 'Cancel'); print '
'."\n"; print '
'."\n"; print '
'."\n"; print '
'; htmlPrintOnlineFooter($mysoc, $langs); llxFooter('', 'public'); $db->close();