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-2026 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';
34require_once DOL_DOCUMENT_ROOT.'/core/lib/dashboard.lib.php';
35
44// Load translation files required by the page
45$langs->loadLangs(array("recruitment", "boxes"));
46
47$action = GETPOST('action', 'aZ09');
48
49$NBMAX = getDolGlobalInt('MAIN_SIZE_SHORTLIST_LIMIT', 5);
50$max = getDolUserInt('MAIN_SIZE_SHORTLIST_LIMIT', getDolGlobalInt('MAIN_SIZE_SHORTLIST_LIMIT', 5));
51$now = dol_now();
52
53$socid = GETPOSTINT('socid');
54if (!empty($user->socid) && $user->socid > 0) {
55 $action = '';
56 $socid = $user->socid;
57}
58
59// Security check (enable the most restrictive one)
60//if ($user->socid > 0) accessforbidden();
61//if ($user->socid > 0) $socid = $user->socid;
62// if (! $user->hasRight('mymodule', 'myobject', 'read')) {
63// accessforbidden();
64// }
65restrictedArea($user, 'recruitment', 0, 'recruitment_recruitmentjobposition', 'recruitmentjobposition', '', 'rowid');
66
67
68/*
69 * Actions
70 */
71
72// None
73
74
75/*
76 * View
77 */
78
79$form = new Form($db);
80$formfile = new FormFile($db);
81$staticrecruitmentjobposition = new RecruitmentJobPosition($db);
82$staticrecruitmentcandidature = new RecruitmentCandidature($db);
83
84llxHeader("", $langs->trans("RecruitmentArea"));
85
86print load_fiche_titre($langs->trans("RecruitmentArea"), '', 'object_recruitmentjobposition');
87
88print '<div class="fichecenter"><div class="fichethirdleft">';
89
90
91/*
92 * Statistics
93 */
94
96
97$sql = "SELECT COUNT(t.rowid) as nb, status";
98$sql .= " FROM ".MAIN_DB_PREFIX."recruitment_recruitmentjobposition as t";
99$sql .= " WHERE t.entity IN (".getEntity('recruitmentjobposition').")";
100$sql .= " GROUP BY t.status";
101$sql .= " ORDER BY t.status ASC";
102$resql = $db->query($sql);
103if ($resql) {
104 $vals = array();
105 while ($obj = $db->fetch_object($resql)) {
106 $vals[$obj->status] = $obj->nb;
107 }
108 $db->free($resql);
109
110 $colorofstatus = array(
111 RecruitmentJobPosition::STATUS_DRAFT => '-'.$colors[0],
115 );
116 $series = array();
117 foreach (array(0, 1, 3, 9) as $status) {
118 $series[] = array(
119 'label' => dol_html_entity_decode($staticrecruitmentjobposition->LibStatut($status, 1), ENT_QUOTES | ENT_HTML5),
120 'labelnojs' => $staticrecruitmentjobposition->LibStatut($status, 0),
121 'nb' => (isset($vals[$status]) ? (int) $vals[$status] : 0),
122 'color' => $colorofstatus[$status],
123 'url' => 'recruitmentjobposition_list.php?search_status='.$status,
124 );
125 }
126 print getStatusPieChart($langs->trans("Statistics").' - '.$langs->trans("JobPositions"), $series, array('total' => false));
127} else {
128 dol_print_error($db);
129}
130
131$sql = "SELECT COUNT(t.rowid) as nb, status";
132$sql .= " FROM ".MAIN_DB_PREFIX."recruitment_recruitmentcandidature as t";
133$sql .= " WHERE t.entity IN (".getEntity('recruitmentcandidature').")";
134$sql .= " GROUP BY t.status";
135$sql .= " ORDER BY t.status ASC";
136$resql = $db->query($sql);
137if ($resql) {
138 $vals = array();
139 while ($obj = $db->fetch_object($resql)) {
140 $vals[$obj->status] = $obj->nb;
141 }
142 $db->free($resql);
143
144 $colorofstatus = array(
145 RecruitmentCandidature::STATUS_DRAFT => '-'.$colors[0],
146 RecruitmentCandidature::STATUS_VALIDATED => $colors[1],
147 RecruitmentCandidature::STATUS_CONTRACT_PROPOSED => $colors[4],
148 RecruitmentCandidature::STATUS_CONTRACT_SIGNED => $colors[5],
149 RecruitmentCandidature::STATUS_REFUSED => $colors[9],
150 RecruitmentCandidature::STATUS_CANCELED => $colors[9],
151 );
152 $series = array();
153 foreach (array(0, 1, 3, 5, 8, 9) as $status) {
154 $series[] = array(
155 'label' => dol_html_entity_decode($staticrecruitmentcandidature->LibStatut($status, 1), ENT_QUOTES | ENT_HTML5),
156 'labelnojs' => $staticrecruitmentcandidature->LibStatut($status, 0),
157 'nb' => (isset($vals[$status]) ? (int) $vals[$status] : 0),
158 'color' => $colorofstatus[$status],
159 'url' => 'recruitmentcandidature_list.php?search_status='.$status,
160 );
161 }
162 print getStatusPieChart($langs->trans("Statistics").' - '.$langs->trans("RecruitmentCandidatures"), $series, array('graphid' => 'idgraphstatuscandidature', 'total' => false));
163} else {
164 dol_print_error($db);
165}
166
167print '<br>';
168
169/* BEGIN MODULEBUILDER DRAFT MYOBJECT
170// Draft MyObject
171if (isModEnabled('recruitment') && $user->rights->recruitment->read) {
172 $langs->load("orders");
173
174 $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";
175 $sql.= ", s.code_client";
176 $sql.= " FROM ".MAIN_DB_PREFIX."recruitment_recruitmentjobposition as c";
177 $sql.= ", ".MAIN_DB_PREFIX."societe as s";
178 if (! $user->rights->societe->client->voir && ! $socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
179 $sql.= " WHERE c.fk_soc = s.rowid";
180 $sql.= " AND c.fk_statut = 0";
181 $sql.= " AND c.entity IN (".getEntity('commande').")";
182 if (! $user->rights->societe->client->voir && ! $socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
183 if ($socid) $sql.= " AND c.fk_soc = ".((int) $socid);
184
185 $resql = $db->query($sql);
186 if ($resql)
187 {
188 $total = 0;
189 $num = $db->num_rows($resql);
190
191 print '<table class="noborder centpercent">';
192 print '<tr class="liste_titre">';
193 print '<th colspan="3">'.$langs->trans("DraftOrders").($num?'<span class="badge marginleftonlyshort">'.$num.'</span>':'').'</th></tr>';
194
195 $var = true;
196 if ($num > 0)
197 {
198 $i = 0;
199 while ($i < $num)
200 {
201
202 $obj = $db->fetch_object($resql);
203 print '<tr class="oddeven"><td class="nowrap">';
204 $orderstatic->id=$obj->rowid;
205 $orderstatic->ref=$obj->ref;
206 $orderstatic->ref_client=$obj->ref_client;
207 $orderstatic->total_ht = $obj->total_ht;
208 $orderstatic->total_tva = $obj->total_tva;
209 $orderstatic->total_ttc = $obj->total_ttc;
210 print $orderstatic->getNomUrl(1);
211 print '</td>';
212 print '<td class="nowrap">';
213 $companystatic->id=$obj->socid;
214 $companystatic->name=$obj->name;
215 $companystatic->client=$obj->client;
216 $companystatic->code_client = $obj->code_client;
217 $companystatic->code_fournisseur = $obj->code_fournisseur;
218 $companystatic->canvas=$obj->canvas;
219 print $companystatic->getNomUrl(1,'customer',16);
220 print '</td>';
221 print '<td class="right" class="nowrap">'.price($obj->total_ttc).'</td></tr>';
222 $i++;
223 $total += $obj->total_ttc;
224 }
225 if ($total>0)
226 {
227
228 print '<tr class="liste_total"><td>'.$langs->trans("Total").'</td><td colspan="2" class="right">'.price($total)."</td></tr>";
229 }
230 }
231 else
232 {
233
234 print '<tr class="oddeven"><td colspan="3" class="opacitymedium">'.$langs->trans("NoOrder").'</td></tr>';
235 }
236 print "</table><br>";
237
238 $db->free($resql);
239 }
240 else
241 {
242 dol_print_error($db);
243 }
244}
245END MODULEBUILDER DRAFT MYOBJECT */
246
247
248print '</div><div class="fichetwothirdright">';
249
250
251// Last modified job position
252if (isModEnabled('recruitment') && $user->hasRight('recruitment', 'recruitmentjobposition', 'read')) {
253 $sql = "SELECT s.rowid, s.ref, s.label, s.date_creation, s.tms, s.status, COUNT(rc.rowid) as nbapplications";
254 $sql .= " FROM ".MAIN_DB_PREFIX."recruitment_recruitmentjobposition as s";
255 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."recruitment_recruitmentcandidature as rc ON rc.fk_recruitmentjobposition = s.rowid";
256 if (isModEnabled('societe') && !$user->hasRight('societe', 'client', 'voir') && !$socid) {
257 $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
258 }
259 $sql .= " WHERE s.entity IN (".getEntity($staticrecruitmentjobposition->element).")";
260 if (isModEnabled('societe') && !$user->hasRight('societe', 'client', 'voir') && !$socid) {
261 $sql .= " AND s.fk_soc = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
262 }
263 if ($socid) {
264 $sql .= " AND s.fk_soc = ".((int) $socid);
265 }
266 $sql .= " GROUP BY s.rowid, s.ref, s.label, s.date_creation, s.tms, s.status";
267 $sql .= $db->order('s.tms', 'DESC');
268 $sql .= $db->plimit($max, 0);
269
270 $resql = $db->query($sql);
271 if ($resql) {
272 $num = $db->num_rows($resql);
273 $i = 0;
274
275 print '<div class="div-table-responsive-no-min">';
276 print '<table class="noborder centpercent">';
277 print '<tr class="liste_titre">';
278 print '<th colspan="2">';
279 print $langs->trans("BoxTitleLatestModifiedJobPositions", $max);
280 print '</th>';
281 print '<th class="right">';
282 print $langs->trans("Applications");
283 print '</th>';
284 print '<th class="right" colspan="2"><a href="'.DOL_URL_ROOT.'/recruitment/recruitmentjobposition_list.php?sortfield=t.tms&sortorder=DESC">'.$langs->trans("FullList").'</th>';
285 print '</tr>';
286 if ($num) {
287 while ($i < $num) {
288 $objp = $db->fetch_object($resql);
289 $staticrecruitmentjobposition->id = $objp->rowid;
290 $staticrecruitmentjobposition->ref = $objp->ref;
291 $staticrecruitmentjobposition->label = $objp->label;
292 $staticrecruitmentjobposition->status = $objp->status;
293 $staticrecruitmentjobposition->date_creation = $objp->date_creation;
294
295 print '<tr class="oddeven">';
296 print '<td class="nowrap">'.$staticrecruitmentjobposition->getNomUrl(1, '').'</td>';
297 print '<td class="right nowrap">';
298 print "</td>";
299 print '<td class="right">';
300 print $objp->nbapplications;
301 print '</td>';
302 print '<td class="right nowrap">'.dol_print_date($db->jdate($objp->tms), 'day')."</td>";
303 print '<td class="right nowrap" width="16">';
304 print $staticrecruitmentjobposition->getLibStatut(3);
305 print "</td>";
306 print '</tr>';
307 $i++;
308 }
309
310 $db->free($resql);
311 } else {
312 print '<tr class="oddeven"><td colspan="4"><span class="opacitymedium">'.$langs->trans("None").'</span></td></tr>';
313 }
314 print "</table>";
315 print "</div>";
316 print "<br>";
317 } else {
318 dol_print_error($db);
319 }
320}
321
322// Last modified job position
323if (isModEnabled('recruitment') && $user->hasRight('recruitment', 'recruitmentjobposition', 'read')) {
324 $sql = "SELECT rc.rowid, rc.ref, rc.email, rc.lastname, rc.firstname, rc.date_creation, rc.tms, rc.status";
325 $sql .= " FROM ".MAIN_DB_PREFIX."recruitment_recruitmentcandidature as rc";
326 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."recruitment_recruitmentjobposition as s ON rc.fk_recruitmentjobposition = s.rowid";
327 if (isModEnabled('societe') && !$user->hasRight('societe', 'client', 'voir') && !$socid) {
328 $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
329 }
330 $sql .= " WHERE rc.entity IN (".getEntity($staticrecruitmentjobposition->element).")";
331 if (isModEnabled('societe') && !$user->hasRight('societe', 'client', 'voir') && !$socid) {
332 $sql .= " AND s.fk_soc = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
333 }
334 if ($socid) {
335 $sql .= " AND s.fk_soc = ".((int) $socid);
336 }
337 $sql .= $db->order('rc.tms', 'DESC');
338 $sql .= $db->plimit($max, 0);
339
340 $resql = $db->query($sql);
341 if ($resql) {
342 $num = $db->num_rows($resql);
343 $i = 0;
344
345 print '<div class="div-table-responsive-no-min">';
346 print '<table class="noborder centpercent">';
347 print '<tr class="liste_titre">';
348 print '<th colspan="2">';
349 print $langs->trans("BoxTitleLatestModifiedCandidatures", $max);
350 print '</th>';
351 print '<th class="right" colspan="2"><a href="'.DOL_URL_ROOT.'/recruitment/recruitmentcandidature_list.php?sortfield=t.tms&sortorder=DESC">'.$langs->trans("FullList").'</th>';
352 print '</tr>';
353 if ($num) {
354 while ($i < $num) {
355 $objp = $db->fetch_object($resql);
356 $staticrecruitmentcandidature->id = $objp->rowid;
357 $staticrecruitmentcandidature->ref = $objp->ref;
358 $staticrecruitmentcandidature->email = $objp->email;
359 $staticrecruitmentcandidature->status = $objp->status;
360 $staticrecruitmentcandidature->date_creation = $objp->date_creation;
361 $staticrecruitmentcandidature->firstname = $objp->firstname;
362 $staticrecruitmentcandidature->lastname = $objp->lastname;
363
364 print '<tr class="oddeven">';
365 print '<td class="nowrap">'.$staticrecruitmentcandidature->getNomUrl(1, '').'</td>';
366 print '<td class="right nowrap">';
367 print "</td>";
368 print '<td class="right nowrap">'.dol_print_date($db->jdate($objp->tms), 'day')."</td>";
369 print '<td class="right nowrap" width="16">';
370 print $staticrecruitmentcandidature->getLibStatut(3);
371 print "</td>";
372 print '</tr>';
373 $i++;
374 }
375
376 $db->free($resql);
377 } else {
378 print '<tr class="oddeven"><td colspan="4"><span class="opacitymedium">'.$langs->trans("None").'</span></td></tr>';
379 }
380 print "</table>";
381 print "</div>";
382 print "<br>";
383 } else {
384 dol_print_error($db);
385 }
386}
387
388print '</div></div>';
389
390// End of page
391llxFooter();
392$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 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.
getThemeBadgeStatusColors()
Return the colors of status badges defined by the current theme (theme_vars.inc.php)
getStatusPieChart($title, $series, $options=array())
Return the HTML table with a pie chart of values by status, as shown on the home page of a module.
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.
isModEnabled($module)
Is Dolibarr module enabled.
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='', $morecssonpicto='widthpictotitle')
Load a title with picto.
restrictedArea(User $user, $features, $object=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $isdraft=0, $nodie=0, $mode='')
Check permissions of a user to show a page and an object.