dolibarr 21.0.0-alpha
view.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2020 Laurent Destailleur <eldy@users.sourceforge.net>
3 * Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
4 * Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 3 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <https://www.gnu.org/licenses/>.
18 */
19
26if (!defined('NOLOGIN')) {
27 define("NOLOGIN", 1); // This means this output page does not require to be logged.
28}
29if (!defined('NOCSRFCHECK')) {
30 define("NOCSRFCHECK", 1); // We accept to go on this page from external web site.
31}
32if (!defined('NOIPCHECK')) {
33 define('NOIPCHECK', '1'); // Do not check IP defined into conf $dolibarr_main_restrict_ip
34}
35if (!defined('NOBROWSERNOTIF')) {
36 define('NOBROWSERNOTIF', '1');
37}
38
39// Load Dolibarr environment
40require '../../main.inc.php';
41require_once DOL_DOCUMENT_ROOT.'/recruitment/class/recruitmentjobposition.class.php';
42require_once DOL_DOCUMENT_ROOT.'/recruitment/class/recruitmentcandidature.class.php';
43require_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php';
44require_once DOL_DOCUMENT_ROOT.'/core/lib/security.lib.php';
45require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
46require_once DOL_DOCUMENT_ROOT.'/core/lib/payments.lib.php';
47require_once DOL_DOCUMENT_ROOT . '/core/lib/public.lib.php';
48
49// Load translation files required by the page
50$langs->loadLangs(array("companies", "other", "recruitment"));
51
52// Get parameters
53$action = GETPOST('action', 'aZ09');
54$cancel = GETPOST('cancel', 'alpha');
55$email = GETPOST('email', 'alpha');
56$firstname = GETPOST('firstname', 'alpha');
57$lastname = GETPOST('lastname', 'alpha');
58$birthday = GETPOST('birthday', 'alpha');
59$phone = GETPOST('phone', 'alpha');
60$message = GETPOST('message', 'alpha');
61$requestedremuneration = GETPOST('requestedremuneration', 'alpha');
62
63$ref = GETPOST('ref', 'alpha');
64
65if (GETPOST('btn_view')) {
66 unset($_SESSION['email_customer']);
67}
68if (isset($_SESSION['email_customer'])) {
69 $email = $_SESSION['email_customer'];
70}
71
73
74if (!$ref) {
75 print $langs->trans('ErrorBadParameters')." - ref missing";
76 exit;
77}
78
79
80// Define $urlwithroot
81//$urlwithouturlroot=preg_replace('/'.preg_quote(DOL_URL_ROOT,'/').'$/i','',trim($dolibarr_main_url_root));
82//$urlwithroot=$urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file
83$urlwithroot = DOL_MAIN_URL_ROOT; // This is to use same domain name than current. For Paypal payment, we can use internal URL like localhost.
84$backtopage = $urlwithroot.'/public/recruitment/index.php';
85
86// Security check
87if (!isModEnabled("recruitment")) {
88 httponly_accessforbidden('Module Recruitment not enabled');
89}
90
91$object->fetch(0, $ref);
92$user->loadDefaultValues();
93$errmsg = "";
94
95/*
96 * Actions
97 */
98
99if ($cancel) {
100 if (!empty($backtopage)) {
101 header("Location: ".$backtopage);
102 exit;
103 }
104}
105
106if ($action == "dosubmit") { // Test on permission not required here (anonymous action protected by mitigation of /public/... urls)
107 $error = 0;
108 $db->begin();
109 if (!strlen($ref)) {
110 $error++;
111 array_push($object->errors, $langs->trans("ErrorFieldRequired", $langs->transnoentities("Ref")));
112 $action = 'view';
113 }
114 if (!strlen($email)) {
115 $error++;
116 array_push($object->errors, $langs->trans("ErrorFieldRequired", $langs->transnoentities("Email")));
117 $action = 'view';
118 } else {
119 if (!isValidEmail($email)) {
120 $error++;
121 array_push($object->errors, $langs->trans("ErrorEmailInvalid"));
122 $action = 'view';
123 }
124 }
125 if (!strlen($lastname)) {
126 $error++;
127 array_push($object->errors, $langs->trans("ErrorFieldRequired", $langs->transnoentities("Lastname")));
128 $action = 'view';
129 }
130
131 if (!$error) {
132 $sql = "SELECT rrc.rowid FROM ".MAIN_DB_PREFIX."recruitment_recruitmentcandidature as rrc";
133 $sql .= " WHERE rrc.email = '". $db->escape($email)."'";
134 $sql .= " AND rrc.entity = ". getEntity($object->element, 0);
135 $resql = $db->query($sql);
136 if ($resql) {
137 $num = $db->num_rows($resql);
138 if ($num > 0) {
139 $error++;
140 setEventMessages($langs->trans("ErrorRecruitmmentCandidatureAlreadyExists", $email), null, 'errors');
141 }
142 } else {
143 dol_print_error($db);
144 $error++;
145 }
146 }
147
148 if (!$error) { // Test on permission not required here (anonymous action protected by mitigation of /public/... urls)
149 $candidature = new RecruitmentCandidature($db);
150
151 $candidature->firstname = GETPOST('firstname', 'alpha');
152 $candidature->lastname = GETPOST('lastname', 'alpha');
153 $candidature->email = GETPOST('email', 'alpha');
154 $candidature->phone = GETPOST('phone', 'alpha');
155 $candidature->date_birth = GETPOST('birthday', 'alpha');
156 $candidature->requestedremuneration = GETPOST('requestedremuneration', 'alpha');
157 $candidature->description = GETPOST('message', 'alpha');
158 $candidature->fk_recruitmentjobposition = $object->id;
159
160 $candidature->ip = getUserRemoteIP();
161
162 // Test MAIN_SECURITY_MAX_POST_ON_PUBLIC_PAGES_BY_IP_ADDRESS
163 $nb_post_max = getDolGlobalInt("MAIN_SECURITY_MAX_POST_ON_PUBLIC_PAGES_BY_IP_ADDRESS", 200);
164
165 if (checkNbPostsForASpeceificIp($candidature, $nb_post_max) <= 0) {
166 $error++;
167 $errmsg .= implode('<br>', $candidature->errors);
168 }
169 if (!$error) {
170 $result = $candidature->create($user);
171 if ($result <= 0) {
172 $error++;
173 $errmsg .= implode('<br>', $candidature->errors);
174 }
175 }
176 if (!$error) {
177 $candidature->validate($user);
178 if ($result <= 0) {
179 $error++;
180 $errmsg .= implode('<br>', $candidature->errors);
181 }
182 }
183 }
184
185 if (!$error) {
186 $db->commit();
187 setEventMessages($langs->trans("RecruitmentCandidatureSaved"), null);
188 header("Location: " . $backtopage);
189 exit;
190 } else {
191 $db->rollback();
192 $action = "view";
193 }
194}
195
196// Actions to send emails (for ticket, we need to manage the addfile and removefile only)
197$triggersendname = 'CANDIDATURE_SENTBYMAIL';
198$paramname = 'id';
199$autocopy = 'MAIN_MAIL_AUTOCOPY_CANDIDATURE_TO'; // used to know the automatic BCC to add
200$trackid = 'recruitmentcandidature'.$object->id;
201include DOL_DOCUMENT_ROOT.'/core/actions_sendmails.inc.php';
202
203
204
205/*
206 * View
207 */
208
209$form = new Form($db);
210$now = dol_now();
211
212$head = '';
213if (getDolGlobalString('MAIN_RECRUITMENT_CSS_URL')) {
214 $head = '<link rel="stylesheet" type="text/css" href="' . getDolGlobalString('MAIN_RECRUITMENT_CSS_URL').'?lang='.$langs->defaultlang.'">'."\n";
215}
216
217$conf->dol_hide_topmenu = 1;
218$conf->dol_hide_leftmenu = 1;
219
220if (!$conf->global->RECRUITMENT_ENABLE_PUBLIC_INTERFACE) {
221 $langs->load("errors");
222 print '<div class="error">'.$langs->trans('ErrorPublicInterfaceNotEnabled').'</div>';
223 $db->close();
224 exit();
225}
226
227$arrayofjs = array();
228$arrayofcss = array();
229
230$replacemainarea = (empty($conf->dol_hide_leftmenu) ? '<div>' : '').'<div>';
231llxHeader($head, $langs->trans("PositionToBeFilled"), '', '', 0, 0, '', '', '', 'onlinepaymentbody', $replacemainarea, 1, 1);
232dol_htmloutput_errors($errmsg);
233
234print '<span id="dolpaymentspan"></span>'."\n";
235print '<div class="center">'."\n";
236print '<form id="dolpaymentform" class="center" name="paymentform" action="'.$_SERVER["PHP_SELF"].'" method="POST">'."\n";
237print '<input type="hidden" name="token" value="'.newToken().'">'."\n";
238print '<input type="hidden" name="action" value="dosubmit">'."\n";
239print '<input type="hidden" name="tag" value="'.GETPOST("tag", 'alpha').'">'."\n";
240print '<input type="hidden" name="suffix" value="'.GETPOST("suffix", 'alpha').'">'."\n";
241print '<input type="hidden" name="securekey" value="'.$SECUREKEY.'">'."\n";
242print '<input type="hidden" name="entity" value="'.$entity.'" />';
243print "\n";
244print '<!-- Form to view job -->'."\n";
245
246// 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)
247// Define logo and logosmall
248$logosmall = $mysoc->logo_small;
249$logo = $mysoc->logo;
250$paramlogo = 'ONLINE_RECRUITMENT_LOGO_'.$suffix;
251if (getDolGlobalString($paramlogo)) {
252 $logosmall = getDolGlobalString($paramlogo);
253} elseif (getDolGlobalString('ONLINE_RECRUITMENT_LOGO')) {
254 $logosmall = getDolGlobalString('ONLINE_RECRUITMENT_LOGO');
255}
256//print '<!-- Show logo (logosmall='.$logosmall.' logo='.$logo.') -->'."\n";
257// Define urllogo
258$urllogo = '';
259$urllogofull = '';
260if (!empty($logosmall) && is_readable($conf->mycompany->dir_output.'/logos/thumbs/'.$logosmall)) {
261 $urllogo = DOL_URL_ROOT.'/viewimage.php?modulepart=mycompany&amp;entity='.$conf->entity.'&amp;file='.urlencode('logos/thumbs/'.$logosmall);
262 $urllogofull = $dolibarr_main_url_root.'/viewimage.php?modulepart=mycompany&entity='.$conf->entity.'&file='.urlencode('logos/thumbs/'.$logosmall);
263} elseif (!empty($logo) && is_readable($conf->mycompany->dir_output.'/logos/'.$logo)) {
264 $urllogo = DOL_URL_ROOT.'/viewimage.php?modulepart=mycompany&amp;entity='.$conf->entity.'&amp;file='.urlencode('logos/'.$logo);
265 $urllogofull = $dolibarr_main_url_root.'/viewimage.php?modulepart=mycompany&entity='.$conf->entity.'&file='.urlencode('logos/'.$logo);
266}
267// Output html code for logo
268if ($urllogo) {
269 print '<div class="backgreypublicpayment">';
270 print '<div class="logopublicpayment">';
271 if (!empty($mysoc->url)) {
272 print '<a href="'.$mysoc->url.'" target="_blank" rel="noopener">';
273 }
274 print '<img id="dolpaymentlogo" src="'.$urllogofull.'">';
275 if (!empty($mysoc->url)) {
276 print '</a>';
277 }
278 print '</div>';
279 if (!getDolGlobalString('MAIN_HIDE_POWERED_BY')) {
280 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>';
281 }
282 print '</div>';
283}
284
285if (getDolGlobalString('RECRUITMENT_IMAGE_PUBLIC_INTERFACE')) {
286 print '<div class="backimagepublicrecruitment">';
287 print '<img id="idRECRUITMENT_IMAGE_PUBLIC_INTERFACE" src="' . getDolGlobalString('RECRUITMENT_IMAGE_PUBLIC_INTERFACE').'">';
288 print '</div>';
289}
290
291
292print '<table id="dolpaymenttable" summary="Job position offer" class="center">'."\n";
293
294// Output introduction text
295$text = '';
296if (getDolGlobalString('RECRUITMENT_NEWFORM_TEXT')) {
297 $reg = array();
298 if (preg_match('/^\‍((.*)\‍)$/', $conf->global->RECRUITMENT_NEWFORM_TEXT, $reg)) {
299 $text .= $langs->trans($reg[1])."<br>\n";
300 } else {
301 $text .= getDolGlobalString('RECRUITMENT_NEWFORM_TEXT') . "<br>\n";
302 }
303 $text = '<tr><td align="center"><br>'.$text.'<br></td></tr>'."\n";
304}
305if (empty($text)) {
306 $text .= '<tr><td class="textpublicpayment" colspan=2><br>'.$langs->trans("JobOfferToBeFilled", $mysoc->name);
307 $text .= ' &nbsp; - &nbsp; <strong>'.$mysoc->name.'</strong>';
308 $text .= ' &nbsp; - &nbsp; <span class="nowraponall"><span class="fa fa-calendar secondary"></span> '.dol_print_date($object->date_creation).'</span>';
309 $text .= '</td></tr>'."\n";
310 $text .= '<tr><td class="textpublicpayment" colspan=2><h1 class="paddingleft paddingright">'.$object->label.'</h1><br></td></tr>'."\n";
311}
312print $text;
313
314// Output payment summary form
315print '<tr><td class="left" colspan=2>';
316
317print '<div with="100%" id="tablepublicpayment">';
318print '<div class="opacitymedium">'.$langs->trans("ThisIsInformationOnJobPosition").' :</div>'."\n";
319
320$error = 0;
321$found = true;
322
323print '<br>';
324
325// Label
326print $langs->trans("Label").' : ';
327print '<b>'.dol_escape_htmltag($object->label).'</b><br>';
328
329// Date
330print $langs->trans("DateExpected").' : ';
331print '<b>';
332if ($object->date_planned > $now) {
333 print dol_print_date($object->date_planned, 'day');
334} else {
335 print $langs->trans("ASAP");
336}
337print '</b><br>';
338
339// Remuneration
340print $langs->trans("Remuneration").' : ';
341print '<b>';
342print dol_escape_htmltag($object->remuneration_suggested);
343print '</b><br>';
344
345// Contact
346$tmpuser = new User($db);
347$tmpuser->fetch($object->fk_user_recruiter);
348
349print $langs->trans("ContactForRecruitment").' : ';
350$emailforcontact = $object->email_recruiter;
351if (empty($emailforcontact)) {
352 $emailforcontact = $tmpuser->email;
353 if (empty($emailforcontact)) {
354 $emailforcontact = $mysoc->email;
355 }
356}
357print '<b class="wordbreak">';
358print $tmpuser->getFullName(-1);
359print ' &nbsp; '.dol_print_email($emailforcontact, 0, 0, 1, 0, 0, 'envelope');
360print '</b>';
361print '</b><br>';
362
364 print info_admin($langs->trans("JobClosedTextCandidateFound"), 0, 0, '0', 'warning');
365}
367 print info_admin($langs->trans("JobClosedTextCanceled"), 0, 0, '0', 'warning');
368}
369
370print '<br>';
371
372// Description
373
374$text = $object->description;
375print $text;
376print '<input type="hidden" name="ref" value="'.$object->ref.'">';
377
378print '</div>'."\n";
379print "\n";
380
381
382if ($action != 'dosubmit') {
383 if ($found && !$error) {
384 // We are in a management option and no error
385 print '</td></tr>'."\n";
386 print '<tr><td class="titlefieldcreate fieldrequired left">'.$langs->trans("Lastname").'</td><td class="left">';
387 print '<input type="text" class="flat minwidth400 --success" name="lastname" maxlength="128" value="'.$lastname.'">';
388 print '</td></tr>'."\n";
389
390 print '<tr><td class="titlefieldcreate left">'.$langs->trans("Firstname").'</td><td class="left">';
391 print '<input type="text" class="flat minwidth400 --success" name="firstname" maxlength="128" value="'.$firstname.'">';
392 print '</td></tr>'."\n";
393
394 print '<tr><td class="titlefieldcreate fieldrequired left">'.$langs->trans("Email").'</td><td class="left">';
395 print img_picto("", "email").'<input type="text" class="flat minwidth100 --success" name="email" value="'.$email.'">';
396 print '</td></tr>'."\n";
397
398 print '<tr><td class="titlefieldcreate left">'.$langs->trans("Phone").'</td><td class="left">';
399 print img_picto("", "phone").'<input type="text" class="flat minwidth100 --success" name="phone" value="'.$phone.'">';
400 print '</td></tr>'."\n";
401
402 print '<tr><td class="titlefieldcreate left minwidth300">'.$langs->trans("DateOfBirth").'</td><td class="left">';
403 print $form->selectDate($birthday, 'birthday', 0, 0, 1, "", 1, 0);
404 print '</td></tr>'."\n";
405
406 print '<tr><td class="titlefieldcreate left">'.$langs->trans("RequestedRemuneration").'</td><td class="left">';
407 print '<input type="text" class="flat minwidth100 --success" name="requestedremuneration" value="'.$requestedremuneration.'">';
408 print '</td></tr>'."\n";
409
410 print '<tr><td class="titlefieldcreate left">'.$langs->trans("Message").'</td><td class="left">';
411 print '<textarea class="flat quatrevingtpercent" rows="'.ROWS_5.'" name="message">'.$message.'</textarea>';
412 print '</td></tr>'."\n";
413
414 print '<tr><td colspan=2>';
415 print $form->buttonsSaveCancel('Submit', 'Cancel');
416 print '</td></tr>'."\n";
417 } else {
418 dol_print_error_email('ERRORSUBMITAPPLICATION');
419 }
420} else {
421 // Print
422}
423
424print '</td></tr>'."\n";
425
426print '</table>'."\n";
427
428print '</form>'."\n";
429print '</div>'."\n";
430print '<br>';
431
432
433htmlPrintOnlineFooter($mysoc, $langs);
434
435llxFooter('', 'public');
436
437$db->close();
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
Definition card.php:58
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
Definition wrapper.php:70
Class to manage generation of HTML components Only common components must be here.
Class for RecruitmentCandidature.
Class for RecruitmentJobPosition.
Class to manage Dolibarr users.
htmlPrintOnlineFooter($fromcompany, $langs, $addformmessage=0, $suffix='', $object=null)
Show footer of company in HTML pages.
llxFooter()
Footer empty.
Definition document.php:107
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
dol_now($mode='auto')
Return date for now.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dol_print_error_email($prefixcode, $errormessage='', $errormessages=array(), $morecss='error', $email='')
Show a public email and error code to contact if technical error.
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
isValidEmail($address, $acceptsupervisorkey=0, $acceptuserkey=0)
Return true if email syntax is ok.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
getUserRemoteIP()
Return the IP of remote user.
info_admin($text, $infoonimgalt=0, $nodiv=0, $admin='1', $morecss='hideonsmartphone', $textfordropdown='', $picto='')
Show information in HTML for admin users or standard users.
dol_htmloutput_errors($mesgstring='', $mesgarray=array(), $keepembedded=0)
Print formatted error messages to output (Used to show messages on html output).
getEntity($element, $shared=1, $currentobject=null)
Get list of entity id to use.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
Returns text escaped for inclusion in HTML alt or title or value tags, or into values of HTML input f...
checkNbPostsForASpeceificIp($object, $nb_post_max)
Check if the object exceeded the number of posts for a specific ip in the same week.
httponly_accessforbidden($message='1', $http_response_code=403, $stringalreadysanitized=0)
Show a message to say access is forbidden and stop program.