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