dolibarr 21.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 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 = getDolGlobalString('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
100 if ($resql) {
101 $num = $db->num_rows($resql);
102 $i = 0;
103
104 $totalnb = 0;
105 $dataseries = array();
106 $colorseries = array();
107 $vals = array();
108
109 include DOL_DOCUMENT_ROOT.'/theme/'.$conf->theme.'/theme_vars.inc.php';
110
111 while ($i < $num) {
112 $obj = $db->fetch_object($resql);
113 if ($obj) {
114 $vals[$obj->status] = $obj->nb;
115
116 $totalnb += $obj->nb;
117 }
118 $i++;
119 }
120 $db->free($resql);
121
122 print '<div class="div-table-responsive-no-min">';
123 print '<table class="noborder nohover centpercent">';
124 print '<tr class="liste_titre"><th colspan="2">'.$langs->trans("Statistics").' - '.$langs->trans("JobPositions").'</th></tr>'."\n";
125 $listofstatus = array(0, 1, 3, 9);
126 foreach ($listofstatus as $status) {
127 $dataseries[] = array(dol_html_entity_decode($staticrecruitmentjobposition->LibStatut($status, 1), ENT_QUOTES | ENT_HTML5), (isset($vals[$status]) ? (int) $vals[$status] : 0));
129 $colorseries[$status] = '-'.$badgeStatus0;
130 }
132 $colorseries[$status] = $badgeStatus4;
133 }
135 $colorseries[$status] = $badgeStatus6;
136 }
138 $colorseries[$status] = $badgeStatus9;
139 }
140
141 if (empty($conf->use_javascript_ajax)) {
142 print '<tr class="oddeven">';
143 print '<td>'.$staticrecruitmentjobposition->LibStatut($status, 0).'</td>';
144 print '<td class="right"><a href="list.php?statut='.$status.'">'.(isset($vals[$status]) ? $vals[$status] : 0).'</a></td>';
145 print "</tr>\n";
146 }
147 }
148 if ($conf->use_javascript_ajax) {
149 print '<tr><td class="center" colspan="2">';
150
151 include_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php';
152 $dolgraph = new DolGraph();
153 $dolgraph->SetData($dataseries);
154 $dolgraph->SetDataColor(array_values($colorseries));
155 $dolgraph->setShowLegend(2);
156 $dolgraph->setShowPercent(1);
157 $dolgraph->SetType(array('pie'));
158 $dolgraph->SetHeight('200');
159 $dolgraph->draw('idgraphstatus');
160 print $dolgraph->show($totalnb ? 0 : 1);
161
162 print '</td></tr>';
163 }
164 print "</table>";
165 print "</div>";
166
167 print "<br>";
168 } else {
169 dol_print_error($db);
170 }
171
172 $sql = "SELECT COUNT(t.rowid) as nb, status";
173 $sql .= " FROM ".MAIN_DB_PREFIX."recruitment_recruitmentcandidature as t";
174 $sql .= " GROUP BY t.status";
175 $sql .= " ORDER BY t.status ASC";
176 $resql = $db->query($sql);
177
178 if ($resql) {
179 $num = $db->num_rows($resql);
180 $i = 0;
181
182 $totalnb = 0;
183 $dataseries = array();
184 $colorseries = array();
185 $vals = array();
186
187 include DOL_DOCUMENT_ROOT.'/theme/'.$conf->theme.'/theme_vars.inc.php';
188
189 while ($i < $num) {
190 $obj = $db->fetch_object($resql);
191 if ($obj) {
192 $vals[$obj->status] = $obj->nb;
193
194 $totalnb += $obj->nb;
195 }
196 $i++;
197 }
198 $db->free($resql);
199
200 print '<div class="div-table-responsive-no-min">';
201 print '<table class="noborder nohover centpercent">';
202 print '<tr class="liste_titre"><th colspan="2">'.$langs->trans("Statistics").' - '.$langs->trans("RecruitmentCandidatures").'</th></tr>'."\n";
203 $listofstatus = array(0, 1, 3, 5, 8, 9);
204 foreach ($listofstatus as $status) {
205 $dataseries[] = array(dol_html_entity_decode($staticrecruitmentcandidature->LibStatut($status, 1), ENT_QUOTES | ENT_HTML5), (isset($vals[$status]) ? (int) $vals[$status] : 0));
206 if ($status == RecruitmentCandidature::STATUS_DRAFT) {
207 $colorseries[$status] = '-'.$badgeStatus0;
208 }
209 if ($status == RecruitmentCandidature::STATUS_VALIDATED) {
210 $colorseries[$status] = $badgeStatus1;
211 }
212 if ($status == RecruitmentCandidature::STATUS_CONTRACT_PROPOSED) {
213 $colorseries[$status] = $badgeStatus4;
214 }
215 if ($status == RecruitmentCandidature::STATUS_CONTRACT_SIGNED) {
216 $colorseries[$status] = $badgeStatus5;
217 }
218 if ($status == RecruitmentCandidature::STATUS_REFUSED) {
219 $colorseries[$status] = $badgeStatus9;
220 }
221 if ($status == RecruitmentCandidature::STATUS_CANCELED) {
222 $colorseries[$status] = $badgeStatus9;
223 }
224
225 if (empty($conf->use_javascript_ajax)) {
226 print '<tr class="oddeven">';
227 print '<td>'.$staticrecruitmentcandidature->LibStatut($status, 0).'</td>';
228 print '<td class="right"><a href="list.php?statut='.$status.'">'.(isset($vals[$status]) ? $vals[$status] : 0).'</a></td>';
229 print "</tr>\n";
230 }
231 }
232 if ($conf->use_javascript_ajax) {
233 print '<tr><td class="center" colspan="2">';
234
235 include_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php';
236 $dolgraph = new DolGraph();
237 $dolgraph->SetData($dataseries);
238 $dolgraph->SetDataColor(array_values($colorseries));
239 $dolgraph->setShowLegend(2);
240 $dolgraph->setShowPercent(1);
241 $dolgraph->SetType(array('pie'));
242 $dolgraph->SetHeight('200');
243 $dolgraph->draw('idgraphstatuscandidature');
244 print $dolgraph->show($totalnb ? 0 : 1);
245
246 print '</td></tr>';
247 }
248 print "</table>";
249 print "</div>";
250
251 print "<br>";
252 } else {
253 dol_print_error($db);
254 }
255}
256
257print '<br>';
258
259/* BEGIN MODULEBUILDER DRAFT MYOBJECT
260// Draft MyObject
261if (isModEnabled('recruitment') && $user->rights->recruitment->read)
262{
263 $langs->load("orders");
264
265 $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";
266 $sql.= ", s.code_client";
267 $sql.= " FROM ".MAIN_DB_PREFIX."recruitment_recruitmentjobposition as c";
268 $sql.= ", ".MAIN_DB_PREFIX."societe as s";
269 if (! $user->rights->societe->client->voir && ! $socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
270 $sql.= " WHERE c.fk_soc = s.rowid";
271 $sql.= " AND c.fk_statut = 0";
272 $sql.= " AND c.entity IN (".getEntity('commande').")";
273 if (! $user->rights->societe->client->voir && ! $socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
274 if ($socid) $sql.= " AND c.fk_soc = ".((int) $socid);
275
276 $resql = $db->query($sql);
277 if ($resql)
278 {
279 $total = 0;
280 $num = $db->num_rows($resql);
281
282 print '<table class="noborder centpercent">';
283 print '<tr class="liste_titre">';
284 print '<th colspan="3">'.$langs->trans("DraftOrders").($num?'<span class="badge marginleftonlyshort">'.$num.'</span>':'').'</th></tr>';
285
286 $var = true;
287 if ($num > 0)
288 {
289 $i = 0;
290 while ($i < $num)
291 {
292
293 $obj = $db->fetch_object($resql);
294 print '<tr class="oddeven"><td class="nowrap">';
295 $orderstatic->id=$obj->rowid;
296 $orderstatic->ref=$obj->ref;
297 $orderstatic->ref_client=$obj->ref_client;
298 $orderstatic->total_ht = $obj->total_ht;
299 $orderstatic->total_tva = $obj->total_tva;
300 $orderstatic->total_ttc = $obj->total_ttc;
301 print $orderstatic->getNomUrl(1);
302 print '</td>';
303 print '<td class="nowrap">';
304 $companystatic->id=$obj->socid;
305 $companystatic->name=$obj->name;
306 $companystatic->client=$obj->client;
307 $companystatic->code_client = $obj->code_client;
308 $companystatic->code_fournisseur = $obj->code_fournisseur;
309 $companystatic->canvas=$obj->canvas;
310 print $companystatic->getNomUrl(1,'customer',16);
311 print '</td>';
312 print '<td class="right" class="nowrap">'.price($obj->total_ttc).'</td></tr>';
313 $i++;
314 $total += $obj->total_ttc;
315 }
316 if ($total>0)
317 {
318
319 print '<tr class="liste_total"><td>'.$langs->trans("Total").'</td><td colspan="2" class="right">'.price($total)."</td></tr>";
320 }
321 }
322 else
323 {
324
325 print '<tr class="oddeven"><td colspan="3" class="opacitymedium">'.$langs->trans("NoOrder").'</td></tr>';
326 }
327 print "</table><br>";
328
329 $db->free($resql);
330 }
331 else
332 {
333 dol_print_error($db);
334 }
335}
336END MODULEBUILDER DRAFT MYOBJECT */
337
338
339print '</div><div class="fichetwothirdright">';
340
341
342// Last modified job position
343if (isModEnabled('recruitment') && $user->hasRight('recruitment', 'recruitmentjobposition', 'read')) {
344 $sql = "SELECT s.rowid, s.ref, s.label, s.date_creation, s.tms, s.status, COUNT(rc.rowid) as nbapplications";
345 $sql .= " FROM ".MAIN_DB_PREFIX."recruitment_recruitmentjobposition as s";
346 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."recruitment_recruitmentcandidature as rc ON rc.fk_recruitmentjobposition = s.rowid";
347 if (isModEnabled('societe') && !$user->hasRight('societe', 'client', 'voir') && !$socid) {
348 $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
349 }
350 $sql .= " WHERE s.entity IN (".getEntity($staticrecruitmentjobposition->element).")";
351 if (isModEnabled('societe') && !$user->hasRight('societe', 'client', 'voir') && !$socid) {
352 $sql .= " AND s.fk_soc = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
353 }
354 if ($socid) {
355 $sql .= " AND s.fk_soc = $socid";
356 }
357 $sql .= " GROUP BY s.rowid, s.ref, s.label, s.date_creation, s.tms, s.status";
358 $sql .= $db->order('s.tms', 'DESC');
359 $sql .= $db->plimit($max, 0);
360
361 $resql = $db->query($sql);
362 if ($resql) {
363 $num = $db->num_rows($resql);
364 $i = 0;
365
366 print '<div class="div-table-responsive-no-min">';
367 print '<table class="noborder centpercent">';
368 print '<tr class="liste_titre">';
369 print '<th colspan="2">';
370 print $langs->trans("BoxTitleLatestModifiedJobPositions", $max);
371 print '</th>';
372 print '<th class="right">';
373 print $langs->trans("Applications");
374 print '</th>';
375 print '<th class="right" colspan="2"><a href="'.DOL_URL_ROOT.'/recruitment/recruitmentjobposition_list.php?sortfield=t.tms&sortorder=DESC">'.$langs->trans("FullList").'</th>';
376 print '</tr>';
377 if ($num) {
378 while ($i < $num) {
379 $objp = $db->fetch_object($resql);
380 $staticrecruitmentjobposition->id = $objp->rowid;
381 $staticrecruitmentjobposition->ref = $objp->ref;
382 $staticrecruitmentjobposition->label = $objp->label;
383 $staticrecruitmentjobposition->status = $objp->status;
384 $staticrecruitmentjobposition->date_creation = $objp->date_creation;
385
386 print '<tr class="oddeven">';
387 print '<td class="nowrap">'.$staticrecruitmentjobposition->getNomUrl(1, '').'</td>';
388 print '<td class="right nowrap">';
389 print "</td>";
390 print '<td class="right">';
391 print $objp->nbapplications;
392 print '</td>';
393 print '<td class="right nowrap">'.dol_print_date($db->jdate($objp->tms), 'day')."</td>";
394 print '<td class="right nowrap" width="16">';
395 print $staticrecruitmentjobposition->getLibStatut(3);
396 print "</td>";
397 print '</tr>';
398 $i++;
399 }
400
401 $db->free($resql);
402 } else {
403 print '<tr class="oddeven"><td colspan="4"><span class="opacitymedium">'.$langs->trans("None").'</span></td></tr>';
404 }
405 print "</table>";
406 print "</div>";
407 print "<br>";
408 } else {
409 dol_print_error($db);
410 }
411}
412
413// Last modified job position
414if (isModEnabled('recruitment') && $user->hasRight('recruitment', 'recruitmentjobposition', 'read')) {
415 $sql = "SELECT rc.rowid, rc.ref, rc.email, rc.lastname, rc.firstname, rc.date_creation, rc.tms, rc.status";
416 $sql .= " FROM ".MAIN_DB_PREFIX."recruitment_recruitmentcandidature as rc";
417 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."recruitment_recruitmentjobposition as s ON rc.fk_recruitmentjobposition = s.rowid";
418 if (isModEnabled('societe') && !$user->hasRight('societe', 'client', 'voir') && !$socid) {
419 $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
420 }
421 $sql .= " WHERE rc.entity IN (".getEntity($staticrecruitmentjobposition->element).")";
422 if (isModEnabled('societe') && !$user->hasRight('societe', 'client', 'voir') && !$socid) {
423 $sql .= " AND s.fk_soc = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
424 }
425 if ($socid) {
426 $sql .= " AND s.fk_soc = $socid";
427 }
428 $sql .= $db->order('rc.tms', 'DESC');
429 $sql .= $db->plimit($max, 0);
430
431 $resql = $db->query($sql);
432 if ($resql) {
433 $num = $db->num_rows($resql);
434 $i = 0;
435
436 print '<div class="div-table-responsive-no-min">';
437 print '<table class="noborder centpercent">';
438 print '<tr class="liste_titre">';
439 print '<th colspan="2">';
440 print $langs->trans("BoxTitleLatestModifiedCandidatures", $max);
441 print '</th>';
442 print '<th class="right" colspan="2"><a href="'.DOL_URL_ROOT.'/recruitment/recruitmentcandidature_list.php?sortfield=t.tms&sortorder=DESC">'.$langs->trans("FullList").'</th>';
443 print '</tr>';
444 if ($num) {
445 while ($i < $num) {
446 $objp = $db->fetch_object($resql);
447 $staticrecruitmentcandidature->id = $objp->rowid;
448 $staticrecruitmentcandidature->ref = $objp->ref;
449 $staticrecruitmentcandidature->email = $objp->email;
450 $staticrecruitmentcandidature->status = $objp->status;
451 $staticrecruitmentcandidature->date_creation = $objp->date_creation;
452 $staticrecruitmentcandidature->firstname = $objp->firstname;
453 $staticrecruitmentcandidature->lastname = $objp->lastname;
454
455 print '<tr class="oddeven">';
456 print '<td class="nowrap">'.$staticrecruitmentcandidature->getNomUrl(1, '').'</td>';
457 print '<td class="right nowrap">';
458 print "</td>";
459 print '<td class="right nowrap">'.dol_print_date($db->jdate($objp->tms), 'day')."</td>";
460 print '<td class="right nowrap" width="16">';
461 print $staticrecruitmentcandidature->getLibStatut(3);
462 print "</td>";
463 print '</tr>';
464 $i++;
465 }
466
467 $db->free($resql);
468 } else {
469 print '<tr class="oddeven"><td colspan="4"><span class="opacitymedium">'.$langs->trans("None").'</span></td></tr>';
470 }
471 print "</table>";
472 print "</div>";
473 print "<br>";
474 } else {
475 dol_print_error($db);
476 }
477}
478
479print '</div></div>';
480
481// End of page
482llxFooter();
483$db->close();
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:71
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.
llxFooter()
Footer empty.
Definition document.php:107
dol_html_entity_decode($a, $b, $c='UTF-8', $keepsomeentities=0)
Replace html_entity_decode functions to manage errors.
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dol_now($mode='auto')
Return date for now.
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...
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
Definition member.php:79
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.