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