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