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