*
* 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.'/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';
// 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');
$backtopage = '';
$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 (!$action) {
if (!$ref) {
print $langs->trans('ErrorBadParameters')." - ref missing";
exit;
} else {
$object->fetch('', $ref);
}
}
// 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.
// Security check
if (empty($conf->recruitment->enabled)) {
httponly_accessforbidden('Module Recruitment not enabled');
}
/*
* Actions
*/
if ($cancel) {
if (!empty($backtopage)) {
header("Location: ".$backtopage);
exit;
}
$action = 'view';
}
if ($action == "view" || $action == "presend" || $action == "dosubmit") {
$error = 0;
$display_ticket = false;
if (!strlen($ref)) {
$error++;
array_push($object->errors, $langs->trans("ErrorFieldRequired", $langs->transnoentities("Ref")));
$action = '';
}
if (!strlen($email)) {
$error++;
array_push($object->errors, $langs->trans("ErrorFieldRequired", $langs->transnoentities("Email")));
$action = '';
} else {
if (!isValidEmail($email)) {
$error++;
array_push($object->errors, $langs->trans("ErrorEmailInvalid"));
$action = '';
}
}
if (!$error) {
$ret = $object->fetch('', $ref);
}
/*
if (!$error && $action == "dosubmit")
{
// Test MAIN_SECURITY_MAX_POST_ON_PUBLIC_PAGES_BY_IP_ADDRESS
// TODO Create job application
if (!$error)
{
$action = 'view';
}
}
*/
if ($error || $errors) {
setEventMessages($object->error, $object->errors, 'errors');
if ($action == "dosubmit") {
$action = 'presend';
} else {
$action = '';
}
}
}
//var_dump($action);
//$object->doActions($action);
// 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
*/
$now = dol_now();
$head = '';
if (!empty($conf->global->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 '