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