dolibarr 25.0.0-alpha
index.php
1<?php
2/* Copyright (C) 2001-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
3 * Copyright (C) 2004-2015 Laurent Destailleur <eldy@users.sourceforge.net>
4 * Copyright (C) 2005-2012 Regis Houssin <regis.houssin@inodbox.com>
5 * Copyright (C) 2015 Jean-François Ferry <jfefe@aternatik.fr>
6 * Copyright (C) 2024-2025 Frédéric France <frederic.france@free.fr>
7 * Copyright (C) 2026 MDW <mdeweerd@users.noreply.github.com>
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 3 of the License, or
12 * (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program. If not, see <https://www.gnu.org/licenses/>.
21 */
22
29// Load Dolibarr environment
30require '../main.inc.php';
31require_once DOL_DOCUMENT_ROOT.'/recruitment/class/recruitmentjobposition.class.php';
32require_once DOL_DOCUMENT_ROOT.'/recruitment/class/recruitmentcandidature.class.php';
33require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
34
43// Load translation files required by the page
44$langs->loadLangs(array("recruitment", "boxes"));
45
46$action = GETPOST('action', 'aZ09');
47
48$NBMAX = getDolGlobalInt('MAIN_SIZE_SHORTLIST_LIMIT', 5);
49$max = getDolUserInt('MAIN_SIZE_SHORTLIST_LIMIT', getDolGlobalInt('MAIN_SIZE_SHORTLIST_LIMIT', 5));
50$now = dol_now();
51
52$socid = GETPOSTINT('socid');
53if (!empty($user->socid) && $user->socid > 0) {
54 $action = '';
55 $socid = $user->socid;
56}
57
58// Security check (enable the most restrictive one)
59//if ($user->socid > 0) accessforbidden();
60//if ($user->socid > 0) $socid = $user->socid;
61// if (! $user->hasRight('mymodule', 'myobject', 'read')) {
62// accessforbidden();
63// }
64restrictedArea($user, 'recruitment', 0, 'recruitment_recruitmentjobposition', 'recruitmentjobposition', '', 'rowid');
65
66
67/*
68 * Actions
69 */
70
71// None
72
73
74/*
75 * View
76 */
77
78$form = new Form($db);
79$formfile = new FormFile($db);
80$staticrecruitmentjobposition = new RecruitmentJobPosition($db);
81$staticrecruitmentcandidature = new RecruitmentCandidature($db);
82
83llxHeader("", $langs->trans("RecruitmentArea"));
84
85print load_fiche_titre($langs->trans("RecruitmentArea"), '', 'object_recruitmentjobposition');
86
87print '<div class="fichecenter"><div class="fichethirdleft">';
88
89
90/*
91 * Statistics
92 */
93
94if ($conf->use_javascript_ajax) {
95 $sql = "SELECT COUNT(t.rowid) as nb, status";
96 $sql .= " FROM ".MAIN_DB_PREFIX."recruitment_recruitmentjobposition as t";
97 $sql .= " GROUP BY t.status";
98 $sql .= " ORDER BY t.status ASC";
99 $resql = $db->query($sql);
100
110 include DOL_DOCUMENT_ROOT.'/theme/'.$conf->theme.'/theme_vars.inc.php';
111 if ($resql) {
112 $num = $db->num_rows($resql);
113 $i = 0;
114
115 $totalnb = 0;
116 $dataseries = array();
117 $colorseries = array();
118 $vals = array();
119
120
121 while ($i < $num) {
122 $obj = $db->fetch_object($resql);
123 if ($obj) {
124 $vals[$obj->status] = $obj->nb;
125
126 $totalnb += $obj->nb;
127 }
128 $i++;
129 }
130 $db->free($resql);
131
132 print '<div class="div-table-responsive-no-min">';
133 print '<table class="noborder nohover centpercent">';
134 print '<tr class="liste_titre"><th colspan="2">'.$langs->trans("Statistics").' - '.$langs->trans("JobPositions").'</th></tr>'."\n";
135 $listofstatus = array(0, 1, 3, 9);
136 foreach ($listofstatus as $status) {
137 $dataseries[] = array(dol_html_entity_decode($staticrecruitmentjobposition->LibStatut($status, 1), ENT_QUOTES | ENT_HTML5), (isset($vals[$status]) ? (int) $vals[$status] : 0));
139 $colorseries[$status] = '-'.$badgeStatus0;
140 }
142 $colorseries[$status] = $badgeStatus4;
143 }
145 $colorseries[$status] = $badgeStatus6;
146 }
148 $colorseries[$status] = $badgeStatus9;
149 }
150
151 if (empty($conf->use_javascript_ajax)) {
152 print '<tr class="oddeven">';
153 print '<td>'.$staticrecruitmentjobposition->LibStatut($status, 0).'</td>';
154 print '<td class="right"><a href="list.php?statut='.$status.'">'.(isset($vals[$status]) ? $vals[$status] : 0).'</a></td>';
155 print "</tr>\n";
156 }
157 }
158 print '<tr><td class="center" colspan="2">';
159
160 include_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php';
161 $dolgraph = new DolGraph();
162 $dolgraph->SetData($dataseries);
163 $dolgraph->SetDataColor(array_values($colorseries));
164 $dolgraph->setShowLegend(2);
165 $dolgraph->setShowPercent(1);
166 $dolgraph->SetType(array('pie'));
167 $dolgraph->SetHeight('200');
168 $dolgraph->draw('idgraphstatus');
169 print $dolgraph->show($totalnb ? 0 : 1);
170
171 print '</td></tr>';
172 print "</table>";
173 print "</div>";
174
175 print "<br>";
176 } else {
178 }
179
180 $sql = "SELECT COUNT(t.rowid) as nb, status";
181 $sql .= " FROM ".MAIN_DB_PREFIX."recruitment_recruitmentcandidature as t";
182 $sql .= " GROUP BY t.status";
183 $sql .= " ORDER BY t.status ASC";
184 $resql = $db->query($sql);
185
186 if ($resql) {
187 $num = $db->num_rows($resql);
188 $i = 0;
189
190 $totalnb = 0;
191 $dataseries = array();
192 $colorseries = array();
193 $vals = array();
194
195 while ($i < $num) {
196 $obj = $db->fetch_object($resql);
197 if ($obj) {
198 $vals[$obj->status] = $obj->nb;
199
200 $totalnb += $obj->nb;
201 }
202 $i++;
203 }
204 $db->free($resql);
205
206 print '<div class="div-table-responsive-no-min">';
207 print '<table class="noborder nohover centpercent">';
208 print '<tr class="liste_titre"><th colspan="2">'.$langs->trans("Statistics").' - '.$langs->trans("RecruitmentCandidatures").'</th></tr>'."\n";
209 $listofstatus = array(0, 1, 3, 5, 8, 9);
210 foreach ($listofstatus as $status) {
211 $dataseries[] = array(dol_html_entity_decode($staticrecruitmentcandidature->LibStatut($status, 1), ENT_QUOTES | ENT_HTML5), (isset($vals[$status]) ? (int) $vals[$status] : 0));
212 if ($status == RecruitmentCandidature::STATUS_DRAFT) {
213 $colorseries[$status] = '-'.$badgeStatus0;
214 }
215 if ($status == RecruitmentCandidature::STATUS_VALIDATED) {
216 $colorseries[$status] = $badgeStatus1;
217 }
218 if ($status == RecruitmentCandidature::STATUS_CONTRACT_PROPOSED) {
219 $colorseries[$status] = $badgeStatus4;
220 }
221 if ($status == RecruitmentCandidature::STATUS_CONTRACT_SIGNED) {
222 $colorseries[$status] = $badgeStatus5;
223 }
224 if ($status == RecruitmentCandidature::STATUS_REFUSED) {
225 $colorseries[$status] = $badgeStatus9;
226 }
227 if ($status == RecruitmentCandidature::STATUS_CANCELED) {
228 $colorseries[$status] = $badgeStatus9;
229 }
230
231 if (empty($conf->use_javascript_ajax)) {
232 print '<tr class="oddeven">';
233 print '<td>'.$staticrecruitmentcandidature->LibStatut($status, 0).'</td>';
234 print '<td class="right"><a href="list.php?statut='.$status.'">'.(isset($vals[$status]) ? $vals[$status] : 0).'</a></td>';
235 print "</tr>\n";
236 }
237 }
238 print '<tr><td class="center" colspan="2">';
239
240 include_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php';
241 $dolgraph = new DolGraph();
242 $dolgraph->SetData($dataseries);
243 $dolgraph->SetDataColor(array_values($colorseries));
244 $dolgraph->setShowLegend(2);
245 $dolgraph->setShowPercent(1);
246 $dolgraph->SetType(array('pie'));
247 $dolgraph->SetHeight('200');
248 $dolgraph->draw('idgraphstatuscandidature');
249 print $dolgraph->show($totalnb ? 0 : 1);
250
251 print '</td></tr>';
252 print "</table>";
253 print "</div>";
254
255 print "<br>";
256 } else {
258 }
259}
260
261print '<br>';
262
263/* BEGIN MODULEBUILDER DRAFT MYOBJECT
264// Draft MyObject
265if (isModEnabled('recruitment') && $user->rights->recruitment->read) {
266 $langs->load("orders");
267
268 $sql = "SELECT c.rowid, c.ref, c.ref_client, c.total_ht, c.total_tva, c.total_ttc, s.rowid as socid, s.nom as name, s.client, s.canvas";
269 $sql.= ", s.code_client";
270 $sql.= " FROM ".MAIN_DB_PREFIX."recruitment_recruitmentjobposition as c";
271 $sql.= ", ".MAIN_DB_PREFIX."societe as s";
272 if (! $user->rights->societe->client->voir && ! $socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
273 $sql.= " WHERE c.fk_soc = s.rowid";
274 $sql.= " AND c.fk_statut = 0";
275 $sql.= " AND c.entity IN (".getEntity('commande').")";
276 if (! $user->rights->societe->client->voir && ! $socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
277 if ($socid) $sql.= " AND c.fk_soc = ".((int) $socid);
278
279 $resql = $db->query($sql);
280 if ($resql)
281 {
282 $total = 0;
283 $num = $db->num_rows($resql);
284
285 print '<table class="noborder centpercent">';
286 print '<tr class="liste_titre">';
287 print '<th colspan="3">'.$langs->trans("DraftOrders").($num?'<span class="badge marginleftonlyshort">'.$num.'</span>':'').'</th></tr>';
288
289 $var = true;
290 if ($num > 0)
291 {
292 $i = 0;
293 while ($i < $num)
294 {
295
296 $obj = $db->fetch_object($resql);
297 print '<tr class="oddeven"><td class="nowrap">';
298 $orderstatic->id=$obj->rowid;
299 $orderstatic->ref=$obj->ref;
300 $orderstatic->ref_client=$obj->ref_client;
301 $orderstatic->total_ht = $obj->total_ht;
302 $orderstatic->total_tva = $obj->total_tva;
303 $orderstatic->total_ttc = $obj->total_ttc;
304 print $orderstatic->getNomUrl(1);
305 print '</td>';
306 print '<td class="nowrap">';
307 $companystatic->id=$obj->socid;
308 $companystatic->name=$obj->name;
309 $companystatic->client=$obj->client;
310 $companystatic->code_client = $obj->code_client;
311 $companystatic->code_fournisseur = $obj->code_fournisseur;
312 $companystatic->canvas=$obj->canvas;
313 print $companystatic->getNomUrl(1,'customer',16);
314 print '</td>';
315 print '<td class="right" class="nowrap">'.price($obj->total_ttc).'</td></tr>';
316 $i++;
317 $total += $obj->total_ttc;
318 }
319 if ($total>0)
320 {
321
322 print '<tr class="liste_total"><td>'.$langs->trans("Total").'</td><td colspan="2" class="right">'.price($total)."</td></tr>";
323 }
324 }
325 else
326 {
327
328 print '<tr class="oddeven"><td colspan="3" class="opacitymedium">'.$langs->trans("NoOrder").'</td></tr>';
329 }
330 print "</table><br>";
331
332 $db->free($resql);
333 }
334 else
335 {
336 dol_print_error($db);
337 }
338}
339END MODULEBUILDER DRAFT MYOBJECT */
340
341
342print '</div><div class="fichetwothirdright">';
343
344
345// Last modified job position
346if (isModEnabled('recruitment') && $user->hasRight('recruitment', 'recruitmentjobposition', 'read')) {
347 $sql = "SELECT s.rowid, s.ref, s.label, s.date_creation, s.tms, s.status, COUNT(rc.rowid) as nbapplications";
348 $sql .= " FROM ".MAIN_DB_PREFIX."recruitment_recruitmentjobposition as s";
349 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."recruitment_recruitmentcandidature as rc ON rc.fk_recruitmentjobposition = s.rowid";
350 if (isModEnabled('societe') && !$user->hasRight('societe', 'client', 'voir') && !$socid) {
351 $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
352 }
353 $sql .= " WHERE s.entity IN (".getEntity($staticrecruitmentjobposition->element).")";
354 if (isModEnabled('societe') && !$user->hasRight('societe', 'client', 'voir') && !$socid) {
355 $sql .= " AND s.fk_soc = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
356 }
357 if ($socid) {
358 $sql .= " AND s.fk_soc = ".((int) $socid);
359 }
360 $sql .= " GROUP BY s.rowid, s.ref, s.label, s.date_creation, s.tms, s.status";
361 $sql .= $db->order('s.tms', 'DESC');
362 $sql .= $db->plimit($max, 0);
363
364 $resql = $db->query($sql);
365 if ($resql) {
366 $num = $db->num_rows($resql);
367 $i = 0;
368
369 print '<div class="div-table-responsive-no-min">';
370 print '<table class="noborder centpercent">';
371 print '<tr class="liste_titre">';
372 print '<th colspan="2">';
373 print $langs->trans("BoxTitleLatestModifiedJobPositions", $max);
374 print '</th>';
375 print '<th class="right">';
376 print $langs->trans("Applications");
377 print '</th>';
378 print '<th class="right" colspan="2"><a href="'.DOL_URL_ROOT.'/recruitment/recruitmentjobposition_list.php?sortfield=t.tms&sortorder=DESC">'.$langs->trans("FullList").'</th>';
379 print '</tr>';
380 if ($num) {
381 while ($i < $num) {
382 $objp = $db->fetch_object($resql);
383 $staticrecruitmentjobposition->id = $objp->rowid;
384 $staticrecruitmentjobposition->ref = $objp->ref;
385 $staticrecruitmentjobposition->label = $objp->label;
386 $staticrecruitmentjobposition->status = $objp->status;
387 $staticrecruitmentjobposition->date_creation = $objp->date_creation;
388
389 print '<tr class="oddeven">';
390 print '<td class="nowrap">'.$staticrecruitmentjobposition->getNomUrl(1, '').'</td>';
391 print '<td class="right nowrap">';
392 print "</td>";
393 print '<td class="right">';
394 print $objp->nbapplications;
395 print '</td>';
396 print '<td class="right nowrap">'.dol_print_date($db->jdate($objp->tms), 'day')."</td>";
397 print '<td class="right nowrap" width="16">';
398 print $staticrecruitmentjobposition->getLibStatut(3);
399 print "</td>";
400 print '</tr>';
401 $i++;
402 }
403
404 $db->free($resql);
405 } else {
406 print '<tr class="oddeven"><td colspan="4"><span class="opacitymedium">'.$langs->trans("None").'</span></td></tr>';
407 }
408 print "</table>";
409 print "</div>";
410 print "<br>";
411 } else {
413 }
414}
415
416// Last modified job position
417if (isModEnabled('recruitment') && $user->hasRight('recruitment', 'recruitmentjobposition', 'read')) {
418 $sql = "SELECT rc.rowid, rc.ref, rc.email, rc.lastname, rc.firstname, rc.date_creation, rc.tms, rc.status";
419 $sql .= " FROM ".MAIN_DB_PREFIX."recruitment_recruitmentcandidature as rc";
420 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."recruitment_recruitmentjobposition as s ON rc.fk_recruitmentjobposition = s.rowid";
421 if (isModEnabled('societe') && !$user->hasRight('societe', 'client', 'voir') && !$socid) {
422 $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
423 }
424 $sql .= " WHERE rc.entity IN (".getEntity($staticrecruitmentjobposition->element).")";
425 if (isModEnabled('societe') && !$user->hasRight('societe', 'client', 'voir') && !$socid) {
426 $sql .= " AND s.fk_soc = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
427 }
428 if ($socid) {
429 $sql .= " AND s.fk_soc = ".((int) $socid);
430 }
431 $sql .= $db->order('rc.tms', 'DESC');
432 $sql .= $db->plimit($max, 0);
433
434 $resql = $db->query($sql);
435 if ($resql) {
436 $num = $db->num_rows($resql);
437 $i = 0;
438
439 print '<div class="div-table-responsive-no-min">';
440 print '<table class="noborder centpercent">';
441 print '<tr class="liste_titre">';
442 print '<th colspan="2">';
443 print $langs->trans("BoxTitleLatestModifiedCandidatures", $max);
444 print '</th>';
445 print '<th class="right" colspan="2"><a href="'.DOL_URL_ROOT.'/recruitment/recruitmentcandidature_list.php?sortfield=t.tms&sortorder=DESC">'.$langs->trans("FullList").'</th>';
446 print '</tr>';
447 if ($num) {
448 while ($i < $num) {
449 $objp = $db->fetch_object($resql);
450 $staticrecruitmentcandidature->id = $objp->rowid;
451 $staticrecruitmentcandidature->ref = $objp->ref;
452 $staticrecruitmentcandidature->email = $objp->email;
453 $staticrecruitmentcandidature->status = $objp->status;
454 $staticrecruitmentcandidature->date_creation = $objp->date_creation;
455 $staticrecruitmentcandidature->firstname = $objp->firstname;
456 $staticrecruitmentcandidature->lastname = $objp->lastname;
457
458 print '<tr class="oddeven">';
459 print '<td class="nowrap">'.$staticrecruitmentcandidature->getNomUrl(1, '').'</td>';
460 print '<td class="right nowrap">';
461 print "</td>";
462 print '<td class="right nowrap">'.dol_print_date($db->jdate($objp->tms), 'day')."</td>";
463 print '<td class="right nowrap" width="16">';
464 print $staticrecruitmentcandidature->getLibStatut(3);
465 print "</td>";
466 print '</tr>';
467 $i++;
468 }
469
470 $db->free($resql);
471 } else {
472 print '<tr class="oddeven"><td colspan="4"><span class="opacitymedium">'.$langs->trans("None").'</span></td></tr>';
473 }
474 print "</table>";
475 print "</div>";
476 print "<br>";
477 } else {
479 }
480}
481
482print '</div></div>';
483
484// End of page
485llxFooter();
486$db->close();
llxFooter($comment='', $zone='private', $disabledoutputofmessages=0)
Empty footer.
Definition wrapper.php:91
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
Definition wrapper.php:73
Class to build graphs.
Class to offer components to list and upload files.
Class to manage generation of HTML components Only common components must be here.
Class for RecruitmentCandidature.
Class for RecruitmentJobPosition.
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $conf
The main.inc.php has been included so the following variable are now defined:
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $db
API class for accounts.
dol_html_entity_decode($a, $b, $c='UTF-8', $keepsomeentities=0)
Replace html_entity_decode functions to manage errors.
dol_now($mode='gmt')
Return date for now.
getDolUserInt($key, $default=0, $tmpuser=null)
Return Dolibarr user constant int value.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0, $nodefault=0)
Return value of a param into GET or POST supervariable.
GETPOSTINT($paramname, $method=0, $nodefault=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='', $morecssonpicto='widthpictotitle')
Load a title with picto.
isModEnabled($module)
Is Dolibarr module enabled.
restrictedArea(User $user, $features, $object=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $isdraft=0, $mode=0)
Check permissions of a user to show a page and an object.