dolibarr  16.0.5
index.php
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 $backtopage = '';
51 
52 // Load variable for pagination
53 $limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit;
54 $sortfield = GETPOST('sortfield', 'aZ09comma');
55 $sortorder = GETPOST('sortorder', 'aZ09comma');
56 $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
57 if (empty($page) || $page < 0 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha')) {
58  $page = 0;
59 } // If $page is not defined, or '' or -1 or if we click on clear filters
60 $offset = $limit * $page;
61 $pageprev = $page - 1;
62 $pagenext = $page + 1;
63 
64 if (GETPOST('btn_view')) {
65  unset($_SESSION['email_customer']);
66 }
67 if (isset($_SESSION['email_customer'])) {
68  $email = $_SESSION['email_customer'];
69 }
70 
71 $object = new RecruitmentJobPosition($db);
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 // None
89 
90 
91 /*
92  * View
93  */
94 
95 $head = '';
96 if (!empty($conf->global->MAIN_RECRUITMENT_CSS_URL)) {
97  $head = '<link rel="stylesheet" type="text/css" href="'.$conf->global->MAIN_RECRUITMENT_CSS_URL.'?lang='.$langs->defaultlang.'">'."\n";
98 }
99 
100 $conf->dol_hide_topmenu = 1;
101 $conf->dol_hide_leftmenu = 1;
102 
103 if (!$conf->global->RECRUITMENT_ENABLE_PUBLIC_INTERFACE) {
104  $langs->load("errors");
105  print '<div class="error">'.$langs->trans('ErrorPublicInterfaceNotEnabled').'</div>';
106  $db->close();
107  exit();
108 }
109 
110 $arrayofjs = array();
111 $arrayofcss = array();
112 
113 $replacemainarea = (empty($conf->dol_hide_leftmenu) ? '<div>' : '').'<div>';
114 llxHeader($head, $langs->trans("PositionToBeFilled"), '', '', 0, 0, '', '', '', 'onlinepaymentbody', $replacemainarea, 1, 1);
115 
116 
117 print '<span id="dolpaymentspan"></span>'."\n";
118 print '<div class="center">'."\n";
119 print '<form id="dolpaymentform" class="center" name="paymentform" action="'.$_SERVER["PHP_SELF"].'" method="POST">'."\n";
120 print '<input type="hidden" name="token" value="'.newToken().'">'."\n";
121 print '<input type="hidden" name="action" value="dosign">'."\n";
122 print '<input type="hidden" name="tag" value="'.GETPOST("tag", 'alpha').'">'."\n";
123 print '<input type="hidden" name="suffix" value="'.GETPOST("suffix", 'alpha').'">'."\n";
124 print '<input type="hidden" name="securekey" value="'.$SECUREKEY.'">'."\n";
125 print '<input type="hidden" name="entity" value="'.$entity.'" />';
126 print "\n";
127 print '<!-- Form to view jobs -->'."\n";
128 
129 // 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)
130 // Define logo and logosmall
131 $logosmall = $mysoc->logo_small;
132 $logo = $mysoc->logo;
133 $paramlogo = 'ONLINE_RECRUITMENT_LOGO_'.$suffix;
134 if (!empty($conf->global->$paramlogo)) {
135  $logosmall = $conf->global->$paramlogo;
136 } elseif (!empty($conf->global->ONLINE_RECRUITMENT_LOGO)) {
137  $logosmall = $conf->global->ONLINE_RECRUITMENT_LOGO_;
138 }
139 //print '<!-- Show logo (logosmall='.$logosmall.' logo='.$logo.') -->'."\n";
140 // Define urllogo
141 $urllogo = '';
142 $urllogofull = '';
143 if (!empty($logosmall) && is_readable($conf->mycompany->dir_output.'/logos/thumbs/'.$logosmall)) {
144  $urllogo = DOL_URL_ROOT.'/viewimage.php?modulepart=mycompany&amp;entity='.$conf->entity.'&amp;file='.urlencode('logos/thumbs/'.$logosmall);
145  $urllogofull = $dolibarr_main_url_root.'/viewimage.php?modulepart=mycompany&entity='.$conf->entity.'&file='.urlencode('logos/thumbs/'.$logosmall);
146 } elseif (!empty($logo) && is_readable($conf->mycompany->dir_output.'/logos/'.$logo)) {
147  $urllogo = DOL_URL_ROOT.'/viewimage.php?modulepart=mycompany&amp;entity='.$conf->entity.'&amp;file='.urlencode('logos/'.$logo);
148  $urllogofull = $dolibarr_main_url_root.'/viewimage.php?modulepart=mycompany&entity='.$conf->entity.'&file='.urlencode('logos/'.$logo);
149 }
150 // Output html code for logo
151 if ($urllogo) {
152  print '<div class="backgreypublicpayment">';
153  print '<div class="logopublicpayment">';
154  print '<img id="dolpaymentlogo" src="'.$urllogo.'">';
155  print '</div>';
156  if (empty($conf->global->MAIN_HIDE_POWERED_BY)) {
157  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>';
158  }
159  print '</div>';
160 }
161 
162 if (!empty($conf->global->RECRUITMENT_IMAGE_PUBLIC_INTERFACE)) {
163  print '<div class="backimagepublicrecruitment">';
164  print '<img id="idPROJECT_IMAGE_PUBLIC_SUGGEST_BOOTH" src="'.$conf->global->RECRUITMENT_IMAGE_PUBLIC_INTERFACE.'">';
165  print '</div>';
166 }
167 
168 
169 $results = $object->fetchAll($sortfield, $sortorder, 0, 0, array('status' => 1));
170 
171 if (is_array($results)) {
172  if (empty($results)) {
173  print '<br>';
174  print $langs->trans("NoPositionOpen");
175  } else {
176  print '<br><br><br>';
177  print '<span class="opacitymedium">'.$langs->trans("WeAreRecruiting").'</span>';
178  print '<br><br><br>';
179  print '<br class="hideonsmartphone">';
180 
181  foreach ($results as $job) {
182  $object = $job;
183 
184  print '<table id="dolpaymenttable" summary="Job position offer" class="center">'."\n";
185 
186  // Output introduction text
187  $text = '';
188  if (!empty($conf->global->RECRUITMENT_NEWFORM_TEXT)) {
189  $reg = array();
190  if (preg_match('/^\((.*)\)$/', $conf->global->RECRUITMENT_NEWFORM_TEXT, $reg)) {
191  $text .= $langs->trans($reg[1])."<br>\n";
192  } else {
193  $text .= $conf->global->RECRUITMENT_NEWFORM_TEXT."<br>\n";
194  }
195  $text = '<tr><td align="center"><br>'.$text.'<br></td></tr>'."\n";
196  }
197  if (empty($text)) {
198  $text .= '<tr><td class="textpublicpayment"><br>'.$langs->trans("JobOfferToBeFilled", $mysoc->name);
199  $text .= ' &nbsp; - &nbsp; <strong>'.$mysoc->name.'</strong>';
200  $text .= ' &nbsp; - &nbsp; <span class="nowraponall"><span class="fa fa-calendar secondary"></span> '.dol_print_date($object->date_creation).'</span>';
201  $text .= '</td></tr>'."\n";
202  $text .= '<tr><td class="textpublicpayment"><h1 class="paddingleft paddingright">'.$object->label.'</h1></td></tr>'."\n";
203  }
204  print $text;
205 
206  // Output payment summary form
207  print '<tr><td class="left">';
208 
209  print '<div with="100%" id="tablepublicpayment">';
210  print '<div class="opacitymedium">'.$langs->trans("ThisIsInformationOnJobPosition").' :</div>'."\n";
211 
212  $error = 0;
213  $found = true;
214 
215  print '<br>';
216 
217  // Label
218  print $langs->trans("Label").' : ';
219  print '<b>'.dol_escape_htmltag($object->label).'</b><br>';
220 
221  // Date
222  print $langs->trans("DateExpected").' : ';
223  print '<b>';
224  if ($object->date_planned > $now) {
225  print dol_print_date($object->date_planned, 'day');
226  } else {
227  print $langs->trans("ASAP");
228  }
229  print '</b><br>';
230 
231  // Remuneration
232  print $langs->trans("Remuneration").' : ';
233  print '<b>';
234  print dol_escape_htmltag($object->remuneration_suggested);
235  print '</b><br>';
236 
237  // Contact
238  $tmpuser = new User($db);
239  $tmpuser->fetch($object->fk_user_recruiter);
240 
241  print $langs->trans("ContactForRecruitment").' : ';
242  $emailforcontact = $object->email_recruiter;
243  if (empty($emailforcontact)) {
244  $emailforcontact = $tmpuser->email;
245  if (empty($emailforcontact)) {
246  $emailforcontact = $mysoc->email;
247  }
248  }
249  print '<b class="wordbreak">';
250  print $tmpuser->getFullName(-1);
251  print ' &nbsp; '.dol_print_email($emailforcontact, 0, 0, 1, 0, 0, 'envelope');
252  print '</b>';
253  print '</b><br>';
254 
255  if ($object->status == RecruitmentJobPosition::STATUS_RECRUITED) {
256  print info_admin($langs->trans("JobClosedTextCandidateFound"), 0, 0, 0, 'warning');
257  }
258  if ($object->status == RecruitmentJobPosition::STATUS_CANCELED) {
259  print info_admin($langs->trans("JobClosedTextCanceled"), 0, 0, 0, 'warning');
260  }
261 
262  print '<br>';
263 
264  // Description
265 
266  $text = $object->description;
267  print $text;
268  print '<input type="hidden" name="ref" value="'.$object->ref.'">';
269 
270  print '</div>'."\n";
271  print "\n";
272 
273 
274  if ($action != 'dosubmit') {
275  if ($found && !$error) {
276  // We are in a management option and no error
277  } else {
278  dol_print_error_email('ERRORSUBMITAPPLICATION');
279  }
280  } else {
281  // Print
282  }
283 
284  print '</td></tr>'."\n";
285 
286  print '</table>'."\n";
287 
288  print '<br><br class="hideonsmartphone"><br class="hideonsmartphone"><br class="hideonsmartphone">'."\n";
289  }
290  }
291 } else {
292  dol_print_error($db, $object->error, $object->errors);
293 }
294 
295 print '</form>'."\n";
296 print '</div>'."\n";
297 print '<br>';
298 
299 
300 htmlPrintOnlinePaymentFooter($mysoc, $langs);
301 
302 llxFooter('', 'public');
303 
304 $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
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
dol_print_error
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
Definition: functions.lib.php:4844
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
llxFooter
llxFooter()
Footer empty.
Definition: index.php:71
llxHeader
if(!defined('NOTOKENRENEWAL')) if(!defined('NOLOGIN')) if(!defined('NOCSRFCHECK')) if(!defined('NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined('NOREQUIREAJAX')) if(!defined('NOIPCHECK')) if(!defined('NOBROWSERNOTIF')) llxHeader()
Header empty.
Definition: index.php:63
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
GETPOSTISSET
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form.
Definition: functions.lib.php:386
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