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 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 3 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <https://www.gnu.org/licenses/>.
17 */
18
25if (!defined('NOLOGIN')) {
26 define("NOLOGIN", 1); // This means this output page does not require to be logged.
27}
28if (!defined('NOCSRFCHECK')) {
29 define("NOCSRFCHECK", 1); // We accept to go on this page from external web site.
30}
31if (!defined('NOIPCHECK')) {
32 define('NOIPCHECK', '1'); // Do not check IP defined into conf $dolibarr_main_restrict_ip
33}
34if (!defined('NOBROWSERNOTIF')) {
35 define('NOBROWSERNOTIF', '1');
36}
37
38// Load Dolibarr environment
39require '../../main.inc.php';
40require_once DOL_DOCUMENT_ROOT.'/recruitment/class/recruitmentjobposition.class.php';
41require_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php';
42require_once DOL_DOCUMENT_ROOT.'/core/lib/security.lib.php';
43require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
44require_once DOL_DOCUMENT_ROOT.'/core/lib/payments.lib.php';
45
46// Load translation files required by the page
47$langs->loadLangs(array("companies", "other", "recruitment"));
48
49// Get parameters
50$action = GETPOST('action', 'aZ09');
51$cancel = GETPOST('cancel', 'alpha');
52$email = GETPOST('email', 'alpha');
53$backtopage = '';
54
55$ref = GETPOST('ref', 'alpha');
56
57if (GETPOST('btn_view')) {
58 unset($_SESSION['email_customer']);
59}
60if (isset($_SESSION['email_customer'])) {
61 $email = $_SESSION['email_customer'];
62}
63
65
66if (!$action) {
67 if (!$ref) {
68 print $langs->trans('ErrorBadParameters')." - ref missing";
69 exit;
70 } else {
71 $object->fetch('', $ref);
72 }
73}
74
75// Define $urlwithroot
76//$urlwithouturlroot=preg_replace('/'.preg_quote(DOL_URL_ROOT,'/').'$/i','',trim($dolibarr_main_url_root));
77//$urlwithroot=$urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file
78$urlwithroot = DOL_MAIN_URL_ROOT; // This is to use same domain name than current. For Paypal payment, we can use internal URL like localhost.
79
80// Security check
81if (empty($conf->recruitment->enabled)) {
82 httponly_accessforbidden('Module Recruitment not enabled');
83}
84
85
86/*
87 * Actions
88 */
89
90if ($cancel) {
91 if (!empty($backtopage)) {
92 header("Location: ".$backtopage);
93 exit;
94 }
95 $action = 'view';
96}
97
98if ($action == "view" || $action == "presend" || $action == "dosubmit") { // Test on permission not required here (anonymous action protected by mitigation of /public/... urls)
99 $error = 0;
100 $display_ticket = false;
101 if (!strlen($ref)) {
102 $error++;
103 array_push($object->errors, $langs->trans("ErrorFieldRequired", $langs->transnoentities("Ref")));
104 $action = '';
105 }
106 if (!strlen($email)) {
107 $error++;
108 array_push($object->errors, $langs->trans("ErrorFieldRequired", $langs->transnoentities("Email")));
109 $action = '';
110 } else {
111 if (!isValidEmail($email)) {
112 $error++;
113 array_push($object->errors, $langs->trans("ErrorEmailInvalid"));
114 $action = '';
115 }
116 }
117
118 if (!$error) {
119 $ret = $object->fetch('', $ref);
120 }
121
122 /*
123 if (!$error && $action == "dosubmit") // Test on permission not required here (anonymous action protected by mitigation of /public/... urls)
124 {
125 // Test MAIN_SECURITY_MAX_POST_ON_PUBLIC_PAGES_BY_IP_ADDRESS
126
127 // TODO Create job application
128
129
130
131 if (!$error)
132 {
133 $action = 'view';
134 }
135 }
136 */
137
138 if ($error || $errors) {
139 setEventMessages($object->error, $object->errors, 'errors');
140 if ($action == "dosubmit") { // Test on permission not required here
141 $action = 'presend';
142 } else {
143 $action = '';
144 }
145 }
146}
147
148// Actions to send emails (for ticket, we need to manage the addfile and removefile only)
149$triggersendname = 'CANDIDATURE_SENTBYMAIL';
150$paramname = 'id';
151$autocopy = 'MAIN_MAIL_AUTOCOPY_CANDIDATURE_TO'; // used to know the automatic BCC to add
152$trackid = 'recruitmentcandidature'.$object->id;
153include DOL_DOCUMENT_ROOT.'/core/actions_sendmails.inc.php';
154
155
156
157/*
158 * View
159 */
160
161$now = dol_now();
162
163$head = '';
164if (getDolGlobalString('MAIN_RECRUITMENT_CSS_URL')) {
165 $head = '<link rel="stylesheet" type="text/css" href="' . getDolGlobalString('MAIN_RECRUITMENT_CSS_URL').'?lang='.$langs->defaultlang.'">'."\n";
166}
167
168$conf->dol_hide_topmenu = 1;
169$conf->dol_hide_leftmenu = 1;
170
171if (!$conf->global->RECRUITMENT_ENABLE_PUBLIC_INTERFACE) {
172 $langs->load("errors");
173 print '<div class="error">'.$langs->trans('ErrorPublicInterfaceNotEnabled').'</div>';
174 $db->close();
175 exit();
176}
177
178$arrayofjs = array();
179$arrayofcss = array();
180
181$replacemainarea = (empty($conf->dol_hide_leftmenu) ? '<div>' : '').'<div>';
182llxHeader($head, $langs->trans("PositionToBeFilled"), '', '', 0, 0, '', '', '', 'onlinepaymentbody', $replacemainarea, 1, 1);
183
184
185print '<span id="dolpaymentspan"></span>'."\n";
186print '<div class="center">'."\n";
187print '<form id="dolpaymentform" class="center" name="paymentform" action="'.$_SERVER["PHP_SELF"].'" method="POST">'."\n";
188print '<input type="hidden" name="token" value="'.newToken().'">'."\n";
189print '<input type="hidden" name="action" value="dosubmit">'."\n";
190print '<input type="hidden" name="tag" value="'.GETPOST("tag", 'alpha').'">'."\n";
191print '<input type="hidden" name="suffix" value="'.GETPOST("suffix", 'alpha').'">'."\n";
192print '<input type="hidden" name="securekey" value="'.$SECUREKEY.'">'."\n";
193print '<input type="hidden" name="entity" value="'.$entity.'" />';
194print "\n";
195print '<!-- Form to view job -->'."\n";
196
197// 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)
198// Define logo and logosmall
199$logosmall = $mysoc->logo_small;
200$logo = $mysoc->logo;
201$paramlogo = 'ONLINE_RECRUITMENT_LOGO_'.$suffix;
202if (getDolGlobalString($paramlogo)) {
203 $logosmall = getDolGlobalString($paramlogo);
204} elseif (getDolGlobalString('ONLINE_RECRUITMENT_LOGO')) {
205 $logosmall = getDolGlobalString('ONLINE_RECRUITMENT_LOGO');
206}
207//print '<!-- Show logo (logosmall='.$logosmall.' logo='.$logo.') -->'."\n";
208// Define urllogo
209$urllogo = '';
210$urllogofull = '';
211if (!empty($logosmall) && is_readable($conf->mycompany->dir_output.'/logos/thumbs/'.$logosmall)) {
212 $urllogo = DOL_URL_ROOT.'/viewimage.php?modulepart=mycompany&amp;entity='.$conf->entity.'&amp;file='.urlencode('logos/thumbs/'.$logosmall);
213 $urllogofull = $dolibarr_main_url_root.'/viewimage.php?modulepart=mycompany&entity='.$conf->entity.'&file='.urlencode('logos/thumbs/'.$logosmall);
214} elseif (!empty($logo) && is_readable($conf->mycompany->dir_output.'/logos/'.$logo)) {
215 $urllogo = DOL_URL_ROOT.'/viewimage.php?modulepart=mycompany&amp;entity='.$conf->entity.'&amp;file='.urlencode('logos/'.$logo);
216 $urllogofull = $dolibarr_main_url_root.'/viewimage.php?modulepart=mycompany&entity='.$conf->entity.'&file='.urlencode('logos/'.$logo);
217}
218// Output html code for logo
219if ($urllogo) {
220 print '<div class="backgreypublicpayment">';
221 print '<div class="logopublicpayment">';
222 if (!empty($mysoc->url)) {
223 print '<a href="'.$mysoc->url.'" target="_blank" rel="noopener">';
224 }
225 print '<img id="dolpaymentlogo" src="'.$urllogofull.'">';
226 if (!empty($mysoc->url)) {
227 print '</a>';
228 }
229 print '</div>';
230 if (!getDolGlobalString('MAIN_HIDE_POWERED_BY')) {
231 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>';
232 }
233 print '</div>';
234}
235
236if (getDolGlobalString('RECRUITMENT_IMAGE_PUBLIC_INTERFACE')) {
237 print '<div class="backimagepublicrecruitment">';
238 print '<img id="idRECRUITMENT_IMAGE_PUBLIC_INTERFACE" src="' . getDolGlobalString('RECRUITMENT_IMAGE_PUBLIC_INTERFACE').'">';
239 print '</div>';
240}
241
242
243print '<table id="dolpaymenttable" summary="Job position offer" class="center">'."\n";
244
245// Output introduction text
246$text = '';
247if (getDolGlobalString('RECRUITMENT_NEWFORM_TEXT')) {
248 $reg = array();
249 if (preg_match('/^\‍((.*)\‍)$/', $conf->global->RECRUITMENT_NEWFORM_TEXT, $reg)) {
250 $text .= $langs->trans($reg[1])."<br>\n";
251 } else {
252 $text .= getDolGlobalString('RECRUITMENT_NEWFORM_TEXT') . "<br>\n";
253 }
254 $text = '<tr><td align="center"><br>'.$text.'<br></td></tr>'."\n";
255}
256if (empty($text)) {
257 $text .= '<tr><td class="textpublicpayment"><br>'.$langs->trans("JobOfferToBeFilled", $mysoc->name);
258 $text .= ' &nbsp; - &nbsp; <strong>'.$mysoc->name.'</strong>';
259 $text .= ' &nbsp; - &nbsp; <span class="nowraponall"><span class="fa fa-calendar secondary"></span> '.dol_print_date($object->date_creation).'</span>';
260 $text .= '</td></tr>'."\n";
261 $text .= '<tr><td class="textpublicpayment"><h1 class="paddingleft paddingright">'.$object->label.'</h1><br></td></tr>'."\n";
262}
263print $text;
264
265// Output payment summary form
266print '<tr><td class="left">';
267
268print '<div with="100%" id="tablepublicpayment">';
269print '<div class="opacitymedium">'.$langs->trans("ThisIsInformationOnJobPosition").' :</div>'."\n";
270
271$error = 0;
272$found = true;
273
274print '<br>';
275
276// Label
277print $langs->trans("Label").' : ';
278print '<b>'.dol_escape_htmltag($object->label).'</b><br>';
279
280// Date
281print $langs->trans("DateExpected").' : ';
282print '<b>';
283if ($object->date_planned > $now) {
284 print dol_print_date($object->date_planned, 'day');
285} else {
286 print $langs->trans("ASAP");
287}
288print '</b><br>';
289
290// Remuneration
291print $langs->trans("Remuneration").' : ';
292print '<b>';
293print dol_escape_htmltag($object->remuneration_suggested);
294print '</b><br>';
295
296// Contact
297$tmpuser = new User($db);
298$tmpuser->fetch($object->fk_user_recruiter);
299
300print $langs->trans("ContactForRecruitment").' : ';
301$emailforcontact = $object->email_recruiter;
302if (empty($emailforcontact)) {
303 $emailforcontact = $tmpuser->email;
304 if (empty($emailforcontact)) {
305 $emailforcontact = $mysoc->email;
306 }
307}
308print '<b class="wordbreak">';
309print $tmpuser->getFullName(-1);
310print ' &nbsp; '.dol_print_email($emailforcontact, 0, 0, 1, 0, 0, 'envelope');
311print '</b>';
312print '</b><br>';
313
315 print info_admin($langs->trans("JobClosedTextCandidateFound"), 0, 0, '0', 'warning');
316}
318 print info_admin($langs->trans("JobClosedTextCanceled"), 0, 0, '0', 'warning');
319}
320
321print '<br>';
322
323// Description
324
325$text = $object->description;
326print $text;
327print '<input type="hidden" name="ref" value="'.$object->ref.'">';
328
329print '</div>'."\n";
330print "\n";
331
332
333if ($action != 'dosubmit') {
334 if ($found && !$error) {
335 // We are in a management option and no error
336 } else {
337 dol_print_error_email('ERRORSUBMITAPPLICATION');
338 }
339} else {
340 // Print
341}
342
343print '</td></tr>'."\n";
344
345print '</table>'."\n";
346
347print '</form>'."\n";
348print '</div>'."\n";
349print '<br>';
350
351
352htmlPrintOnlineFooter($mysoc, $langs);
353
354llxFooter('', 'public');
355
356$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 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.
dol_now($mode='auto')
Return date for now.
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.
isValidEmail($address, $acceptsupervisorkey=0, $acceptuserkey=0)
Return true if email syntax is ok.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
info_admin($text, $infoonimgalt=0, $nodiv=0, $admin='1', $morecss='hideonsmartphone', $textfordropdown='', $picto='')
Show information in HTML for admin users or standard users.
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...
httponly_accessforbidden($message='1', $http_response_code=403, $stringalreadysanitized=0)
Show a message to say access is forbidden and stop program.