dolibarr 23.0.3
index.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2003-2004 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-2025 Charlene Benke <charlene@patas-monkey.com>
6 * Copyright (C) 2019 Nicolas ZABOURI <info@inovea-conseil.com>
7 * Copyright (C) 2024-2025 Frédéric France <frederic.france@free.fr>
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.'/core/class/html.formfile.class.php';
32require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
33require_once DOL_DOCUMENT_ROOT.'/core/class/notify.class.php';
34require_once DOL_DOCUMENT_ROOT.'/fichinter/class/fichinter.class.php';
35require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php';
36
45if (!$user->hasRight('ficheinter', 'lire')) {
47}
48
49// Load translation files required by the page
50$langs->load("interventions");
51
52// Initialize a technical object to manage hooks. Note that conf->hooks_modules contains array
53$hookmanager->initHooks(array('interventionindex'));
54
55
56// Security check
57$socid = GETPOSTINT('socid');
58if ($user->socid > 0) {
59 $action = '';
60 $socid = $user->socid;
61}
62
63// Load $resultboxes
64$resultboxes = FormOther::getBoxesArea($user, "20");
65
66$max = getDolGlobalInt('MAIN_SIZE_SHORTLIST_LIMIT', 5);
67
68
69/*
70 * View
71 */
72
73$fichinterstatic = new Fichinter($db);
74$companystatic = new Societe($db);
75$form = new Form($db);
76$formfile = new FormFile($db);
77
78$help_url = "EN:ModuleFichinters|FR:Module_Fiche_Interventions|ES:Módulo_FichaInterventiones";
79
80llxHeader("", $langs->trans("Interventions"), $help_url, '', 0, 0, '', '', '', 'mod-fichinter page-index');
81
82print load_fiche_titre($langs->trans("InterventionsArea"), '', 'intervention');
83
84print '<div class="fichecenter"><div class="fichethirdleft">';
85
86// Statistics
87
88$sql = "SELECT count(f.rowid), f.fk_statut";
89$sql .= " FROM ".MAIN_DB_PREFIX."societe as s";
90$sql .= ", ".MAIN_DB_PREFIX."fichinter as f";
91if (!$user->hasRight('societe', 'client', 'voir')) {
92 $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
93}
94$sql .= " WHERE f.entity IN (".getEntity('intervention').")";
95$sql .= " AND f.fk_soc = s.rowid";
96if ($user->socid) {
97 $sql .= ' AND f.fk_soc = '.((int) $user->socid);
98}
99if (!$user->hasRight('societe', 'client', 'voir')) {
100 $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
101}
102$sql .= " GROUP BY f.fk_statut";
103$resql = $db->query($sql);
104if ($resql) {
105 $num = $db->num_rows($resql);
106
107 $total = 0;
108 $totalinprocess = 0;
109 $dataseries = array();
110 $colorseries = array();
111 $vals = array();
112 $bool = false;
113 // -1=Canceled, 0=Draft, 1=Validated, 2=Accepted/On process, 3=Closed (Sent/Received, billed or not)
114 if ($num > 0) {
115 while ($row = $db->fetch_row($resql)) {
116 if (!isset($vals[$row[1]])) {
117 $vals[$row[1]] = 0;
118 }
119 $vals[$row[1]] += $row[0];
120 $totalinprocess += $row[0];
121
122 $total += $row[0];
123 }
124 }
125 $db->free($resql);
126
127 include DOL_DOCUMENT_ROOT.'/theme/'.$conf->theme.'/theme_vars.inc.php';
134 '
135 @phan-var-force string $badgeStatus0
136 @phan-var-force string $badgeStatus1
137 @phan-var-force string $badgeStatus2
138 @phan-var-force string $badgeStatus4
139 ';
140
141 print '<div class="div-table-responsive-no-min">';
142 print '<table class="noborder nohover centpercent">';
143 print '<tr class="liste_titre"><th colspan="2">'.$langs->trans("Statistics").' - '.$langs->trans("Interventions").'</th></tr>'."\n";
145 if (getDolGlobalString('FICHINTER_CLASSIFY_BILLED')) {
146 $listofstatus[] = Fichinter::STATUS_BILLED;
147 }
148
149 foreach ($listofstatus as $status) {
150 $dataseries[] = array($fichinterstatic->LibStatut($status, 1), (isset($vals[$status]) ? (int) $vals[$status] : 0));
151
152 if ($status == Fichinter::STATUS_DRAFT) {
153 $colorseries[$status] = '-'.$badgeStatus0;
154 }
155 if ($status == Fichinter::STATUS_VALIDATED) {
156 $colorseries[$status] = $badgeStatus1;
157 }
158 if ($status == Fichinter::STATUS_CLOSED) {
159 $colorseries[$status] = $badgeStatus2;
160 }
161 if ($status == Fichinter::STATUS_BILLED) {
162 $colorseries[$status] = $badgeStatus4;
163 }
164 }
165
166 if ($conf->use_javascript_ajax) {
167 print '<tr class="impair"><td class="center" colspan="2">';
168
169 include_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php';
170 $dolgraph = new DolGraph();
171 $dolgraph->SetData($dataseries);
172 $dolgraph->SetDataColor(array_values($colorseries));
173 $dolgraph->setShowLegend(2);
174 $dolgraph->setShowPercent(1);
175 $dolgraph->SetType(array('pie'));
176 $dolgraph->setHeight('200');
177 $dolgraph->draw('idgraphstatus');
178 print $dolgraph->show($total ? 0 : 1);
179
180 print '</td></tr>';
181 }
182 foreach ($listofstatus as $status) {
183 if (!$conf->use_javascript_ajax) {
184 print '<tr class="oddeven">';
185 print '<td>'.$fichinterstatic->LibStatut($status, 0).'</td>';
186 print '<td class="right"><a href="list.php?search_status='.$status.'">'.(isset($vals[$status]) ? $vals[$status] : 0).' ';
187 print $fichinterstatic->LibStatut($status, 3);
188 print '</a>';
189 print '</td>';
190 print "</tr>\n";
191 }
192 }
193 //if ($totalinprocess != $total)
194 //print '<tr class="liste_total"><td>'.$langs->trans("Total").' ('.$langs->trans("CustomersOrdersRunning").')</td><td class="right">'.$totalinprocess.'</td></tr>';
195 print '<tr class="liste_total"><td>'.$langs->trans("Total").'</td><td class="right">'.$total.'</td></tr>';
196 print "</table></div><br>";
197} else {
198 dol_print_error($db);
199}
200
201
202/*
203 * Draft interventions
204 */
205if (isModEnabled('intervention')) {
206 $sql = "SELECT f.rowid, f.ref, s.nom as name, s.rowid as socid";
207 $sql .= " FROM ".MAIN_DB_PREFIX."fichinter as f";
208 $sql .= ", ".MAIN_DB_PREFIX."societe as s";
209 if (!$user->hasRight('societe', 'client', 'voir')) {
210 $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
211 }
212 $sql .= " WHERE f.entity IN (".getEntity('intervention').")";
213 $sql .= " AND f.fk_soc = s.rowid";
214 $sql .= " AND f.fk_statut = 0";
215 if ($socid) {
216 $sql .= " AND f.fk_soc = ".((int) $socid);
217 }
218 if (!$user->hasRight('societe', 'client', 'voir')) {
219 $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
220 }
221
222 $resql = $db->query($sql);
223 if ($resql) {
224 print '<div class="div-table-responsive-no-min">';
225 print '<table class="noborder centpercent">';
226 print '<tr class="liste_titre">';
227 print '<th colspan="2">'.$langs->trans("DraftFichinter").'</th></tr>';
228 $langs->load("interventions");
229 $num = $db->num_rows($resql);
230 if ($num) {
231 $i = 0;
232 while ($i < $num) {
233 $obj = $db->fetch_object($resql);
234 $fichinterstatic->id = $obj->rowid;
235 $fichinterstatic->ref = $obj->ref;
236 print '<tr class="oddeven">';
237 print '<td class="nowrap">'.$fichinterstatic->getNomUrl(1).'</td>';
238 $companystatic->id = $obj->socid;
239 $companystatic->name = $obj->name;
240 print '<td>'.$companystatic->getNomUrl(1, 'customer').'</td>';
241 print '</tr>';
242 $i++;
243 }
244 }
245 print "</table></div><br>";
246 }
247}
248
249
250print '</div><div class="fichetwothirdright">';
251
252
253/*
254 * Last modified interventions
255 */
256
257$sql = "SELECT f.rowid, f.ref, f.fk_statut, f.date_valid as datec, f.tms as datem,";
258$sql .= " s.nom as name, s.rowid as socid";
259$sql .= " FROM ".MAIN_DB_PREFIX."fichinter as f,";
260$sql .= " ".MAIN_DB_PREFIX."societe as s";
261if (!$user->hasRight('societe', 'client', 'voir')) {
262 $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
263}
264$sql .= " WHERE f.entity IN (".getEntity('intervention').")";
265$sql .= " AND f.fk_soc = s.rowid";
266//$sql.= " AND c.fk_statut > 2";
267if ($socid) {
268 $sql .= " AND f.fk_soc = ".((int) $socid);
269}
270if (!$user->hasRight('societe', 'client', 'voir')) {
271 $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
272}
273$sql .= " ORDER BY f.tms DESC";
274$sql .= $db->plimit($max, 0);
275
276$resql = $db->query($sql);
277if ($resql) {
278 print '<div class="div-table-responsive-no-min">';
279 print '<table class="noborder centpercent">';
280 print '<tr class="liste_titre">';
281 print '<th colspan="4">'.$langs->trans("LastModifiedInterventions", $max).'</th></tr>';
282
283 $num = $db->num_rows($resql);
284 if ($num) {
285 $i = 0;
286 while ($i < $num) {
287 $obj = $db->fetch_object($resql);
288
289 print '<tr class="oddeven">';
290 print '<td width="20%" class="nowrap">';
291
292 $fichinterstatic->id = $obj->rowid;
293 $fichinterstatic->ref = $obj->ref;
294
295 print '<table class="nobordernopadding"><tr class="nocellnopadd">';
296 print '<td width="96" class="nobordernopadding nowrap">';
297 print $fichinterstatic->getNomUrl(1);
298 print '</td>';
299
300 print '<td width="16" class="nobordernopadding nowrap">';
301 print '&nbsp;';
302 print '</td>';
303
304 print '<td width="16" class="right nobordernopadding hideonsmartphone">';
305 $filename = dol_sanitizeFileName($obj->ref);
306 $filedir = $conf->ficheinter->dir_output.'/'.dol_sanitizeFileName($obj->ref);
307 $urlsource = $_SERVER['PHP_SELF'].'?id='.$obj->rowid;
308 print $formfile->getDocumentsLink($fichinterstatic->element, $filename, $filedir);
309 print '</td></tr></table>';
310
311 print '</td>';
312 $companystatic->id = $obj->socid;
313 $companystatic->name = $obj->name;
314 print '<td>'.$companystatic->getNomUrl(1, 'customer').'</td>';
315 print '<td>'.dol_print_date($db->jdate($obj->datem), 'day').'</td>';
316 print '<td class="right">'.$fichinterstatic->LibStatut($obj->fk_statut, 5).'</td>';
317 print '</tr>';
318 $i++;
319 }
320 }
321 print "</table></div><br>";
322} else {
323 dol_print_error($db);
324}
325
326
327/*
328 * interventions to process
329 */
330
331if (isModEnabled('intervention')) {
332 $sql = "SELECT f.rowid, f.ref, f.fk_statut, s.nom as name, s.rowid as socid";
333 $sql .= " FROM ".MAIN_DB_PREFIX."fichinter as f";
334 $sql .= ", ".MAIN_DB_PREFIX."societe as s";
335 if (!$user->hasRight('societe', 'client', 'voir')) {
336 $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
337 }
338 $sql .= " WHERE f.entity IN (".getEntity('intervention').")";
339 $sql .= " AND f.fk_soc = s.rowid";
340 $sql .= " AND f.fk_statut = 1";
341 if ($socid) {
342 $sql .= " AND f.fk_soc = ".((int) $socid);
343 }
344 if (!$user->hasRight('societe', 'client', 'voir')) {
345 $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
346 }
347 $sql .= " ORDER BY f.rowid DESC";
348
349 $resql = $db->query($sql);
350 if ($resql) {
351 $num = $db->num_rows($resql);
352
353 print '<div class="div-table-responsive-no-min">';
354 print '<table class="noborder centpercent">';
355 print '<tr class="liste_titre">';
356 print '<th colspan="3">'.$langs->trans("FichinterToProcess").' <a href="'.DOL_URL_ROOT.'/fichinter/list.php?search_status=1"><span class="badge">'.$num.'</span></a></th></tr>';
357
358 if ($num) {
359 $i = 0;
360 while ($i < $num) {
361 $obj = $db->fetch_object($resql);
362 print '<tr class="oddeven">';
363 print '<td class="nowrap" width="20%">';
364
365 $fichinterstatic->id = $obj->rowid;
366 $fichinterstatic->ref = $obj->ref;
367
368 print '<table class="nobordernopadding"><tr class="nocellnopadd">';
369 print '<td width="96" class="nobordernopadding nowrap">';
370 print $fichinterstatic->getNomUrl(1);
371 print '</td>';
372
373 print '<td width="16" class="nobordernopadding nowrap">';
374 print '&nbsp;';
375 print '</td>';
376
377 print '<td width="16" class="right nobordernopadding hideonsmartphone">';
378 $filename = dol_sanitizeFileName($obj->ref);
379 $filedir = $conf->ficheinter->dir_output.'/'.dol_sanitizeFileName($obj->ref);
380 $urlsource = $_SERVER['PHP_SELF'].'?id='.$obj->rowid;
381 print $formfile->getDocumentsLink($fichinterstatic->element, $filename, $filedir);
382 print '</td></tr></table>';
383
384 print '</td>';
385 $companystatic->id = $obj->socid;
386 $companystatic->name = $obj->name;
387 print '<td>'.$companystatic->getNomUrl(1, 'customer').'</td>';
388 print '<td class="right">'.$fichinterstatic->LibStatut($obj->fk_statut, 5).'</td>';
389 print '</tr>';
390 $i++;
391 }
392 }
393
394 print "</table></div><br>";
395 } else {
396 dol_print_error($db);
397 }
398}
399
400print '</div></div>';
401
402// boxes
403print '<div class="clearboth"></div>';
404print '<div class="fichecenter fichecenterbis">';
405
406$boxlist = '<div class="twocolumns">';
407
408$boxlist .= '<div class="firstcolumn fichehalfleft boxhalfleft" id="boxhalfleft">';
409
410$boxlist .= $resultboxes['boxlista'];
411$boxlist .= "</div>\n";
412
413$boxlist .= '<div class="secondcolumn fichehalfright boxhalfright" id="boxhalfright">';
414$boxlist .= $resultboxes['boxlistb'];
415$boxlist .= '</div>'."\n";
416
417$boxlist .= "</div>\n";
418
419print $boxlist;
420
421print '</div>';
422
423$parameters = array('user' => $user);
424$reshook = $hookmanager->executeHooks('dashboardInterventions', $parameters, $object); // Note that $action and $object may have been modified by hook
425
426llxFooter();
427
428$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.
const STATUS_BILLED
Billed.
const STATUS_DRAFT
Draft status.
const STATUS_VALIDATED
Validated status.
const STATUS_CLOSED
Closed.
Class to offer components to list and upload files.
Class to manage generation of HTML components Only common components must be here.
static getBoxesArea($user, $areacode)
Get array with HTML tabs with widgets/boxes of a particular area including personalized choices of us...
Class to manage third parties objects (customers, suppliers, prospects...)
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dol_sanitizeFileName($str, $newstr='_', $unaccent=1, $includequotes=0, $allowdash=0)
Clean a string to use it as a file name.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
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.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
isModEnabled($module)
Is Dolibarr module enabled.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.