dolibarr 25.0.0-alpha
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-2026 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';
38require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
39require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
40require_once DOL_DOCUMENT_ROOT.'/core/class/notify.class.php';
41require_once DOL_DOCUMENT_ROOT.'/fichinter/class/fichinter.class.php';
42require_once DOL_DOCUMENT_ROOT.'/core/lib/dashboard.lib.php';
43require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php';
44
45
46if (!$user->hasRight('ficheinter', 'lire')) {
48}
49
50// Load translation files required by the page
51$langs->load("interventions");
52
53// Initialize a technical object to manage hooks. Note that conf->hooks_modules contains array
54$hookmanager->initHooks(array('interventionindex'));
55
56
57// Security check
58$socid = GETPOSTINT('socid');
59if ($user->isExternalUser()) {
60 $action = '';
61 $socid = $user->isExternalUser();
62}
63
64// Load $resultboxes
65$resultboxes = FormOther::getBoxesArea($user, "20");
66
67$max = getDolUserInt('MAIN_SIZE_SHORTLIST_LIMIT', getDolGlobalInt('MAIN_SIZE_SHORTLIST_LIMIT', 5));
68
69
70/*
71 * View
72 */
73
74$fichinterstatic = new Fichinter($db);
75$companystatic = new Societe($db);
76$form = new Form($db);
77$formfile = new FormFile($db);
78
79$help_url = "EN:ModuleFichinters|FR:Module_Fiche_Interventions|ES:Módulo_FichaInterventiones";
80
81llxHeader("", $langs->trans("Interventions"), $help_url, '', 0, 0, '', '', '', 'mod-fichinter page-index');
82
83print load_fiche_titre($langs->trans("InterventionsArea"), '', 'intervention');
84
85print '<div class="fichecenter"><div class="fichethirdleft">';
86
87// Statistics
88
89$sql = "SELECT count(f.rowid), f.fk_statut";
90$sql .= " FROM ".MAIN_DB_PREFIX."societe as s";
91$sql .= ", ".MAIN_DB_PREFIX."fichinter as f";
92if (!$user->hasRight('societe', 'client', 'voir')) {
93 $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
94}
95$sql .= " WHERE f.entity IN (".getEntity('intervention').")";
96$sql .= " AND f.fk_soc = s.rowid";
97if ($user->socid) {
98 $sql .= ' AND f.fk_soc = '.((int) $user->socid);
99}
100if (!$user->hasRight('societe', 'client', 'voir')) {
101 $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
102}
103$sql .= " GROUP BY f.fk_statut";
104$resql = $db->query($sql);
105if ($resql) {
106 $vals = array();
107 while ($row = $db->fetch_row($resql)) {
108 if (!isset($vals[$row[1]])) {
109 $vals[$row[1]] = 0;
110 }
111 $vals[$row[1]] += $row[0];
112 }
113 $db->free($resql);
114
115 $colors = getThemeBadgeStatusColors();
116 $colorofstatus = array(
117 Fichinter::STATUS_DRAFT => '-'.$colors[0],
118 Fichinter::STATUS_VALIDATED => $colors[1],
119 Fichinter::STATUS_CLOSED => $colors[2],
120 Fichinter::STATUS_BILLED => $colors[4],
121 );
123 if (getDolGlobalString('FICHINTER_CLASSIFY_BILLED')) {
124 $listofstatus[] = Fichinter::STATUS_BILLED;
125 }
126 $series = array();
127 foreach ($listofstatus as $status) {
128 $series[] = array(
129 'label' => $fichinterstatic->LibStatut($status, 1),
130 'labelnojs' => $fichinterstatic->LibStatut($status, 0),
131 'nb' => (isset($vals[$status]) ? (int) $vals[$status] : 0),
132 'color' => $colorofstatus[$status],
133 'url' => 'list.php?search_status='.$status,
134 );
135 }
136 print getStatusPieChart($langs->trans("Statistics").' - '.$langs->trans("Interventions"), $series);
137} else {
138 dol_print_error($db);
139}
140
141
142/*
143 * Draft interventions
144 */
145if (isModEnabled('intervention')) {
146 $sql = "SELECT f.rowid, f.ref, s.nom as name, s.rowid as socid";
147 $sql .= " FROM ".MAIN_DB_PREFIX."fichinter as f";
148 $sql .= ", ".MAIN_DB_PREFIX."societe as s";
149 if (!$user->hasRight('societe', 'client', 'voir')) {
150 $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
151 }
152 $sql .= " WHERE f.entity IN (".getEntity('intervention').")";
153 $sql .= " AND f.fk_soc = s.rowid";
154 $sql .= " AND f.fk_statut = 0";
155 if ($socid) {
156 $sql .= " AND f.fk_soc = ".((int) $socid);
157 }
158 if (!$user->hasRight('societe', 'client', 'voir')) {
159 $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
160 }
161
162 $resql = $db->query($sql);
163 if ($resql) {
164 print '<div class="div-table-responsive-no-min">';
165 print '<table class="noborder centpercent">';
166 print '<tr class="liste_titre">';
167 print '<th colspan="2">'.$langs->trans("DraftFichinter").'</th></tr>';
168 $langs->load("interventions");
169 $num = $db->num_rows($resql);
170 if ($num) {
171 $i = 0;
172 while ($i < $num) {
173 $obj = $db->fetch_object($resql);
174 $fichinterstatic->id = $obj->rowid;
175 $fichinterstatic->ref = $obj->ref;
176 print '<tr class="oddeven">';
177 print '<td class="nowrap">'.$fichinterstatic->getNomUrl(1).'</td>';
178 $companystatic->id = $obj->socid;
179 $companystatic->name = $obj->name;
180 print '<td>'.$companystatic->getNomUrl(1, 'customer').'</td>';
181 print '</tr>';
182 $i++;
183 }
184 }
185 print "</table></div><br>";
186 }
187}
188
189
190print '</div><div class="fichetwothirdright">';
191
192
193/*
194 * Last modified interventions
195 */
196
197$sql = "SELECT f.rowid, f.ref, f.fk_statut, f.date_valid as datec, f.tms as datem,";
198$sql .= " s.nom as name, s.rowid as socid";
199$sql .= " FROM ".MAIN_DB_PREFIX."fichinter as f,";
200$sql .= " ".MAIN_DB_PREFIX."societe as s";
201if (!$user->hasRight('societe', 'client', 'voir')) {
202 $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
203}
204$sql .= " WHERE f.entity IN (".getEntity('intervention').")";
205$sql .= " AND f.fk_soc = s.rowid";
206//$sql.= " AND c.fk_statut > 2";
207if ($socid) {
208 $sql .= " AND f.fk_soc = ".((int) $socid);
209}
210if (!$user->hasRight('societe', 'client', 'voir')) {
211 $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
212}
213$sql .= " ORDER BY f.tms DESC";
214$sql .= $db->plimit($max, 0);
215
216$resql = $db->query($sql);
217if ($resql) {
218 print '<div class="div-table-responsive-no-min">';
219 print '<table class="noborder centpercent">';
220 print '<tr class="liste_titre">';
221 print '<th colspan="4">'.$langs->trans("LastModifiedInterventions", $max).'</th></tr>';
222
223 $num = $db->num_rows($resql);
224 if ($num) {
225 $i = 0;
226 while ($i < $num) {
227 $obj = $db->fetch_object($resql);
228
229 print '<tr class="oddeven">';
230 print '<td width="20%" class="nowrap">';
231
232 $fichinterstatic->id = $obj->rowid;
233 $fichinterstatic->ref = $obj->ref;
234
235 print '<table class="nobordernopadding"><tr class="nocellnopadd">';
236 print '<td width="96" class="nobordernopadding nowrap">';
237 print $fichinterstatic->getNomUrl(1);
238 print '</td>';
239
240 print '<td width="16" class="nobordernopadding nowrap">';
241 print '&nbsp;';
242 print '</td>';
243
244 print '<td width="16" class="right nobordernopadding hideonsmartphone">';
245 $filename = dol_sanitizeFileName($obj->ref);
246 $filedir = $conf->ficheinter->dir_output.'/'.dol_sanitizeFileName($obj->ref);
247 $urlsource = $_SERVER['PHP_SELF'].'?id='.$obj->rowid;
248 print $formfile->getDocumentsLink($fichinterstatic->element, $filename, $filedir);
249 print '</td></tr></table>';
250
251 print '</td>';
252 $companystatic->id = $obj->socid;
253 $companystatic->name = $obj->name;
254 print '<td>'.$companystatic->getNomUrl(1, 'customer').'</td>';
255 print '<td>'.dol_print_date($db->jdate($obj->datem), 'day').'</td>';
256 print '<td class="right">'.$fichinterstatic->LibStatut($obj->fk_statut, 5).'</td>';
257 print '</tr>';
258 $i++;
259 }
260 }
261 print "</table></div><br>";
262} else {
263 dol_print_error($db);
264}
265
266
267/*
268 * interventions to process
269 */
270
271if (isModEnabled('intervention')) {
272 $sql = "SELECT f.rowid, f.ref, f.fk_statut, s.nom as name, s.rowid as socid";
273 $sql .= " FROM ".MAIN_DB_PREFIX."fichinter as f";
274 $sql .= ", ".MAIN_DB_PREFIX."societe as s";
275 if (!$user->hasRight('societe', 'client', 'voir')) {
276 $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
277 }
278 $sql .= " WHERE f.entity IN (".getEntity('intervention').")";
279 $sql .= " AND f.fk_soc = s.rowid";
280 $sql .= " AND f.fk_statut = 1";
281 if ($socid) {
282 $sql .= " AND f.fk_soc = ".((int) $socid);
283 }
284 if (!$user->hasRight('societe', 'client', 'voir')) {
285 $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
286 }
287 $sql .= " ORDER BY f.rowid DESC";
288
289 $resql = $db->query($sql);
290 if ($resql) {
291 $num = $db->num_rows($resql);
292
293 print '<div class="div-table-responsive-no-min">';
294 print '<table class="noborder centpercent">';
295 print '<tr class="liste_titre">';
296 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>';
297
298 if ($num) {
299 $i = 0;
300 while ($i < $num) {
301 $obj = $db->fetch_object($resql);
302 print '<tr class="oddeven">';
303 print '<td class="nowrap" width="20%">';
304
305 $fichinterstatic->id = $obj->rowid;
306 $fichinterstatic->ref = $obj->ref;
307
308 print '<table class="nobordernopadding"><tr class="nocellnopadd">';
309 print '<td width="96" class="nobordernopadding nowrap">';
310 print $fichinterstatic->getNomUrl(1);
311 print '</td>';
312
313 print '<td width="16" class="nobordernopadding nowrap">';
314 print '&nbsp;';
315 print '</td>';
316
317 print '<td width="16" class="right nobordernopadding hideonsmartphone">';
318 $filename = dol_sanitizeFileName($obj->ref);
319 $filedir = $conf->ficheinter->dir_output.'/'.dol_sanitizeFileName($obj->ref);
320 $urlsource = $_SERVER['PHP_SELF'].'?id='.$obj->rowid;
321 print $formfile->getDocumentsLink($fichinterstatic->element, $filename, $filedir);
322 print '</td></tr></table>';
323
324 print '</td>';
325 $companystatic->id = $obj->socid;
326 $companystatic->name = $obj->name;
327 print '<td>'.$companystatic->getNomUrl(1, 'customer').'</td>';
328 print '<td class="right">'.$fichinterstatic->LibStatut($obj->fk_statut, 5).'</td>';
329 print '</tr>';
330 $i++;
331 }
332 }
333
334 print "</table></div><br>";
335 } else {
336 dol_print_error($db);
337 }
338}
339
340print '</div></div>';
341
342// boxes
343print '<div class="clearboth"></div>';
344print '<div class="fichecenter fichecenterbis">';
345
346$boxlist = '<div class="twocolumns">';
347
348$boxlist .= '<div class="firstcolumn fichehalfleft boxhalfleft" id="boxhalfleft">';
349
350$boxlist .= $resultboxes['boxlista'];
351$boxlist .= "</div>\n";
352
353$boxlist .= '<div class="secondcolumn fichehalfright boxhalfright" id="boxhalfright">';
354$boxlist .= $resultboxes['boxlistb'];
355$boxlist .= '</div>'."\n";
356
357$boxlist .= "</div>\n";
358
359print $boxlist;
360
361print '</div>';
362
363$parameters = array('user' => $user);
364$reshook = $hookmanager->executeHooks('dashboardInterventions', $parameters, $object); // Note that $action and $object may have been modified by hook
365
366llxFooter();
367
368$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
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...)
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.
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $conf
The main.inc.php has been included so the following variable are now defined:
getDolUserInt($key, $default=0, $tmpuser=null)
Return Dolibarr user constant int value.
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.
GETPOSTINT($paramname, $method=0, $nodefault=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
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.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.