dolibarr 19.0.3
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
147// Actions to send emails (for ticket, we need to manage the addfile and removefile only)
148$triggersendname = 'CANDIDATURE_SENTBYMAIL';
149$paramname = 'id';
150$autocopy = 'MAIN_MAIL_AUTOCOPY_CANDIDATURE_TO'; // used to know the automatic BCC to add
151$trackid = 'recruitmentcandidature'.$object->id;
152include DOL_DOCUMENT_ROOT.'/core/actions_sendmails.inc.php';
153
154
155
156/*
157 * View
158 */
159
160$now = dol_now();
161
162$head = '';
163if (getDolGlobalString('MAIN_RECRUITMENT_CSS_URL')) {
164 $head = '<link rel="stylesheet" type="text/css" href="' . getDolGlobalString('MAIN_RECRUITMENT_CSS_URL').'?lang='.$langs->defaultlang.'">'."\n";
165}
166
167$conf->dol_hide_topmenu = 1;
168$conf->dol_hide_leftmenu = 1;
169
170if (!$conf->global->RECRUITMENT_ENABLE_PUBLIC_INTERFACE) {
171 $langs->load("errors");
172 print '<div class="error">'.$langs->trans('ErrorPublicInterfaceNotEnabled').'</div>';
173 $db->close();
174 exit();
175}
176
177$arrayofjs = array();
178$arrayofcss = array();
179
180$replacemainarea = (empty($conf->dol_hide_leftmenu) ? '<div>' : '').'<div>';
181llxHeader($head, $langs->trans("PositionToBeFilled"), '', '', 0, 0, '', '', '', 'onlinepaymentbody', $replacemainarea, 1, 1);
182
183
184print '<span id="dolpaymentspan"></span>'."\n";
185print '<div class="center">'."\n";
186print '<form id="dolpaymentform" class="center" name="paymentform" action="'.$_SERVER["PHP_SELF"].'" method="POST">'."\n";
187print '<input type="hidden" name="token" value="'.newToken().'">'."\n";
188print '<input type="hidden" name="action" value="dosubmit">'."\n";
189print '<input type="hidden" name="tag" value="'.GETPOST("tag", 'alpha').'">'."\n";
190print '<input type="hidden" name="suffix" value="'.GETPOST("suffix", 'alpha').'">'."\n";
191print '<input type="hidden" name="securekey" value="'.$SECUREKEY.'">'."\n";
192print '<input type="hidden" name="entity" value="'.$entity.'" />';
193print "\n";
194print '<!-- Form to view job -->'."\n";
195
196// 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)
197// Define logo and logosmall
198$logosmall = $mysoc->logo_small;
199$logo = $mysoc->logo;
200$paramlogo = 'ONLINE_RECRUITMENT_LOGO_'.$suffix;
201if (!empty($conf->global->$paramlogo)) {
202 $logosmall = $conf->global->$paramlogo;
203} elseif (getDolGlobalString('ONLINE_RECRUITMENT_LOGO')) {
204 $logosmall = $conf->global->ONLINE_RECRUITMENT_LOGO;
205}
206//print '<!-- Show logo (logosmall='.$logosmall.' logo='.$logo.') -->'."\n";
207// Define urllogo
208$urllogo = '';
209$urllogofull = '';
210if (!empty($logosmall) && is_readable($conf->mycompany->dir_output.'/logos/thumbs/'.$logosmall)) {
211 $urllogo = DOL_URL_ROOT.'/viewimage.php?modulepart=mycompany&amp;entity='.$conf->entity.'&amp;file='.urlencode('logos/thumbs/'.$logosmall);
212 $urllogofull = $dolibarr_main_url_root.'/viewimage.php?modulepart=mycompany&entity='.$conf->entity.'&file='.urlencode('logos/thumbs/'.$logosmall);
213} elseif (!empty($logo) && is_readable($conf->mycompany->dir_output.'/logos/'.$logo)) {
214 $urllogo = DOL_URL_ROOT.'/viewimage.php?modulepart=mycompany&amp;entity='.$conf->entity.'&amp;file='.urlencode('logos/'.$logo);
215 $urllogofull = $dolibarr_main_url_root.'/viewimage.php?modulepart=mycompany&entity='.$conf->entity.'&file='.urlencode('logos/'.$logo);
216}
217// Output html code for logo
218if ($urllogo) {
219 print '<div class="backgreypublicpayment">';
220 print '<div class="logopublicpayment">';
221 if (!empty($mysoc->url)) {
222 print '<a href="'.$mysoc->url.'" target="_blank" rel="noopener">';
223 }
224 print '<img id="dolpaymentlogo" src="'.$urllogofull.'">';
225 if (!empty($mysoc->url)) {
226 print '</a>';
227 }
228 print '</div>';
229 if (!getDolGlobalString('MAIN_HIDE_POWERED_BY')) {
230 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>';
231 }
232 print '</div>';
233}
234
235if (getDolGlobalString('RECRUITMENT_IMAGE_PUBLIC_INTERFACE')) {
236 print '<div class="backimagepublicrecruitment">';
237 print '<img id="idRECRUITMENT_IMAGE_PUBLIC_INTERFACE" src="' . getDolGlobalString('RECRUITMENT_IMAGE_PUBLIC_INTERFACE').'">';
238 print '</div>';
239}
240
241
242print '<table id="dolpaymenttable" summary="Job position offer" class="center">'."\n";
243
244// Output introduction text
245$text = '';
246if (getDolGlobalString('RECRUITMENT_NEWFORM_TEXT')) {
247 $reg = array();
248 if (preg_match('/^\‍((.*)\‍)$/', $conf->global->RECRUITMENT_NEWFORM_TEXT, $reg)) {
249 $text .= $langs->trans($reg[1])."<br>\n";
250 } else {
251 $text .= getDolGlobalString('RECRUITMENT_NEWFORM_TEXT') . "<br>\n";
252 }
253 $text = '<tr><td align="center"><br>'.$text.'<br></td></tr>'."\n";
254}
255if (empty($text)) {
256 $text .= '<tr><td class="textpublicpayment"><br>'.$langs->trans("JobOfferToBeFilled", $mysoc->name);
257 $text .= ' &nbsp; - &nbsp; <strong>'.$mysoc->name.'</strong>';
258 $text .= ' &nbsp; - &nbsp; <span class="nowraponall"><span class="fa fa-calendar secondary"></span> '.dol_print_date($object->date_creation).'</span>';
259 $text .= '</td></tr>'."\n";
260 $text .= '<tr><td class="textpublicpayment"><h1 class="paddingleft paddingright">'.$object->label.'</h1><br></td></tr>'."\n";
261}
262print $text;
263
264// Output payment summary form
265print '<tr><td class="left">';
266
267print '<div with="100%" id="tablepublicpayment">';
268print '<div class="opacitymedium">'.$langs->trans("ThisIsInformationOnJobPosition").' :</div>'."\n";
269
270$error = 0;
271$found = true;
272
273print '<br>';
274
275// Label
276print $langs->trans("Label").' : ';
277print '<b>'.dol_escape_htmltag($object->label).'</b><br>';
278
279// Date
280print $langs->trans("DateExpected").' : ';
281print '<b>';
282if ($object->date_planned > $now) {
283 print dol_print_date($object->date_planned, 'day');
284} else {
285 print $langs->trans("ASAP");
286}
287print '</b><br>';
288
289// Remuneration
290print $langs->trans("Remuneration").' : ';
291print '<b>';
292print dol_escape_htmltag($object->remuneration_suggested);
293print '</b><br>';
294
295// Contact
296$tmpuser = new User($db);
297$tmpuser->fetch($object->fk_user_recruiter);
298
299print $langs->trans("ContactForRecruitment").' : ';
300$emailforcontact = $object->email_recruiter;
301if (empty($emailforcontact)) {
302 $emailforcontact = $tmpuser->email;
303 if (empty($emailforcontact)) {
304 $emailforcontact = $mysoc->email;
305 }
306}
307print '<b class="wordbreak">';
308print $tmpuser->getFullName(-1);
309print ' &nbsp; '.dol_print_email($emailforcontact, 0, 0, 1, 0, 0, 'envelope');
310print '</b>';
311print '</b><br>';
312
313if ($object->status == RecruitmentJobPosition::STATUS_RECRUITED) {
314 print info_admin($langs->trans("JobClosedTextCandidateFound"), 0, 0, 0, 'warning');
315}
316if ($object->status == RecruitmentJobPosition::STATUS_CANCELED) {
317 print info_admin($langs->trans("JobClosedTextCanceled"), 0, 0, 0, 'warning');
318}
319
320print '<br>';
321
322// Description
323
324$text = $object->description;
325print $text;
326print '<input type="hidden" name="ref" value="'.$object->ref.'">';
327
328print '</div>'."\n";
329print "\n";
330
331
332if ($action != 'dosubmit') {
333 if ($found && !$error) {
334 // We are in a management option and no error
335 } else {
336 dol_print_error_email('ERRORSUBMITAPPLICATION');
337 }
338} else {
339 // Print
340}
341
342print '</td></tr>'."\n";
343
344print '</table>'."\n";
345
346print '</form>'."\n";
347print '</div>'."\n";
348print '<br>';
349
350
351htmlPrintOnlineFooter($mysoc, $langs);
352
353llxFooter('', 'public');
354
355$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:55
llxFooter()
Empty footer.
Definition wrapper.php:69
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.
getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
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.