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