dolibarr  9.0.0
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 Charlie Benke <charlie@patas-monkey.com>
6 
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 <http://www.gnu.org/licenses/>.
20  */
21 
28 require '../main.inc.php';
29 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
30 require_once DOL_DOCUMENT_ROOT .'/core/class/notify.class.php';
31 require_once DOL_DOCUMENT_ROOT .'/fichinter/class/fichinter.class.php';
32 
33 if (!$user->rights->ficheinter->lire) accessforbidden();
34 
35 // Load translation files required by the page
36 $langs->load("interventions");
37 
38 // Security check
39 $socid=GETPOST('socid','int');
40 if ($user->societe_id > 0)
41 {
42  $action = '';
43  $socid = $user->societe_id;
44 }
45 
46 
47 
48 /*
49  * View
50  */
51 
52 $fichinterstatic=new Fichinter($db);
53 $form = new Form($db);
54 $formfile = new FormFile($db);
55 $help_url="EN:ModuleFichinters|FR:Module_Fiche_Interventions|ES:Módulo_FichaInterventiones";
56 
57 llxHeader("",$langs->trans("Interventions"),$help_url);
58 
59 print load_fiche_titre($langs->trans("InterventionsArea"));
60 
61 print '<div class="fichecenter"><div class="fichethirdleft">';
62 
63 if (! empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS)) // This is useless due to the global search combo
64 {
65  // Search ficheinter
66  $var=false;
67  print '<table class="noborder nohover" width="100%">';
68  print '<form method="post" action="'.DOL_URL_ROOT.'/fichinter/list.php">';
69  print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
70  print '<tr class="liste_titre"><td colspan="3">'.$langs->trans("Search").'</td></tr>';
71  print '<tr class="oddeven"><td>';
72  print $langs->trans("Intervention").':</td><td><input type="text" class="flat" name="sall" size="18"></td><td><input type="submit" value="'.$langs->trans("Search").'" class="button"></td></tr>';
73  print "</form></table><br>\n";
74 }
75 
76 
77 /*
78  * Statistics
79  */
80 
81 $sql = "SELECT count(f.rowid), f.fk_statut";
82 $sql.= " FROM ".MAIN_DB_PREFIX."societe as s";
83 $sql.= ", ".MAIN_DB_PREFIX."fichinter as f";
84 if (! $user->rights->societe->client->voir && ! $socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
85 $sql.= " WHERE f.entity IN (".getEntity('intervention').")";
86 $sql.= " AND f.fk_soc = s.rowid";
87 if ($user->societe_id) $sql.=' AND f.fk_soc = '.$user->societe_id;
88 if (! $user->rights->societe->client->voir && ! $socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
89 $sql.= " GROUP BY f.fk_statut";
90 $resql = $db->query($sql);
91 if ($resql)
92 {
93  $num = $db->num_rows($resql);
94  $i = 0;
95 
96  $total=0;
97  $totalinprocess=0;
98  $dataseries=array();
99  $vals=array();
100  $bool=false;
101  // -1=Canceled, 0=Draft, 1=Validated, 2=Accepted/On process, 3=Closed (Sent/Received, billed or not)
102  while ($i < $num)
103  {
104  $row = $db->fetch_row($resql);
105  if ($row)
106  {
107  //if ($row[1]!=-1 && ($row[1]!=3 || $row[2]!=1))
108  {
109  $bool=(! empty($row[2])?true:false);
110  if (! isset($vals[$row[1].$bool])) $vals[$row[1].$bool]=0;
111  $vals[$row[1].$bool]+=$row[0];
112  $totalinprocess+=$row[0];
113  }
114  $total+=$row[0];
115  }
116  $i++;
117  }
118  $db->free($resql);
119  print '<table class="noborder nohover" width="100%">';
120  print '<tr class="liste_titre"><th colspan="2">'.$langs->trans("Statistics").' - '.$langs->trans("Interventions").'</th></tr>'."\n";
121  $listofstatus=array(0,1,2);
122  $bool=false;
123  foreach ($listofstatus as $status)
124  {
125  $dataseries[]=array($fichinterstatic->LibStatut($status,$bool,1), (isset($vals[$status.$bool])?(int) $vals[$status.$bool]:0));
126  if ($status==3 && ! $bool) $bool=true;
127  else $bool=false;
128  }
129  if ($conf->use_javascript_ajax)
130  {
131  print '<tr class="impair"><td align="center" colspan="2">';
132 
133  include_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php';
134  $dolgraph = new DolGraph();
135  $dolgraph->SetData($dataseries);
136  $dolgraph->setShowLegend(1);
137  $dolgraph->setShowPercent(1);
138  $dolgraph->SetType(array('pie'));
139  $dolgraph->setWidth('100%');
140  $dolgraph->draw('idgraphstatus');
141  print $dolgraph->show($total?0:1);
142  $data=array('series'=>$dataseries);
143 
144  print '</td></tr>';
145  }
146  $bool=false;
147  foreach ($listofstatus as $status)
148  {
149  if (! $conf->use_javascript_ajax)
150  {
151  print '<tr class="oddeven">';
152  print '<td>'.$fichinterstatic->LibStatut($status,$bool,0).'</td>';
153  print '<td align="right"><a href="list.php?viewstatut='.$status.'">'.(isset($vals[$status.$bool])?$vals[$status.$bool]:0).' ';
154  print $fichinterstatic->LibStatut($status,$bool,3);
155  print '</a>';
156  print '</td>';
157  print "</tr>\n";
158  if ($status==3 && ! $bool) $bool=true;
159  else $bool=false;
160  }
161  }
162  //if ($totalinprocess != $total)
163  //print '<tr class="liste_total"><td>'.$langs->trans("Total").' ('.$langs->trans("CustomersOrdersRunning").')</td><td align="right">'.$totalinprocess.'</td></tr>';
164  print '<tr class="liste_total"><td>'.$langs->trans("Total").'</td><td align="right">'.$total.'</td></tr>';
165  print "</table><br>";
166 }
167 else
168 {
169  dol_print_error($db);
170 }
171 
172 
173 /*
174  * Draft orders
175  */
176 if (! empty($conf->ficheinter->enabled))
177 {
178  $sql = "SELECT f.rowid, f.ref, s.nom as name, s.rowid as socid";
179  $sql.= " FROM ".MAIN_DB_PREFIX."fichinter as f";
180  $sql.= ", ".MAIN_DB_PREFIX."societe as s";
181  if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
182  $sql.= " WHERE f.entity IN (".getEntity('intervention').")";
183  $sql.= " AND f.fk_soc = s.rowid";
184  $sql.= " AND f.fk_statut = 0";
185  if ($socid) $sql.= " AND f.fk_soc = ".$socid;
186  if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
187 
188  $resql=$db->query($sql);
189  if ($resql)
190  {
191  print '<table class="noborder" width="100%">';
192  print '<tr class="liste_titre">';
193  print '<th colspan="2">'.$langs->trans("DraftFichinter").'</th></tr>';
194  $langs->load("fichinter");
195  $num = $db->num_rows($resql);
196  if ($num)
197  {
198  $i = 0;
199  while ($i < $num)
200  {
201  $obj = $db->fetch_object($resql);
202  print '<tr class="oddeven">';
203  print '<td class="nowrap">';
204  print "<a href=\"card.php?id=".$obj->rowid."\">".img_object($langs->trans("ShowFichinter"),"intervention").' '.$obj->ref."</a></td>";
205  print '<td><a href="'.DOL_URL_ROOT.'/comm/card.php?socid='.$obj->socid.'">'.img_object($langs->trans("ShowCompany"),"company").' '.dol_trunc($obj->name,24).'</a></td></tr>';
206  $i++;
207  }
208  }
209  print "</table><br>";
210  }
211 }
212 
213 
214 print '</div><div class="fichetwothirdright"><div class="ficheaddleft">';
215 
216 
217 $max=5;
218 
219 /*
220  * Last modified interventions
221  */
222 
223 $sql = "SELECT f.rowid, f.ref, f.fk_statut, f.date_valid as datec, f.tms as datem,";
224 $sql.= " s.nom as name, s.rowid as socid";
225 $sql.= " FROM ".MAIN_DB_PREFIX."fichinter as f,";
226 $sql.= " ".MAIN_DB_PREFIX."societe as s";
227 if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
228 $sql.= " WHERE f.entity IN (".getEntity('intervention').")";
229 $sql.= " AND f.fk_soc = s.rowid";
230 //$sql.= " AND c.fk_statut > 2";
231 if ($socid) $sql .= " AND f.fk_soc = ".$socid;
232 if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
233 $sql.= " ORDER BY f.tms DESC";
234 $sql.= $db->plimit($max, 0);
235 
236 $resql=$db->query($sql);
237 if ($resql)
238 {
239  print '<table class="noborder" width="100%">';
240  print '<tr class="liste_titre">';
241  print '<th colspan="4">'.$langs->trans("LastModifiedInterventions",$max).'</th></tr>';
242 
243  $num = $db->num_rows($resql);
244  if ($num)
245  {
246  $i = 0;
247  while ($i < $num)
248  {
249  $obj = $db->fetch_object($resql);
250 
251  print '<tr class="oddeven">';
252  print '<td width="20%" class="nowrap">';
253 
254  $fichinterstatic->id=$obj->rowid;
255  $fichinterstatic->ref=$obj->ref;
256 
257  print '<table class="nobordernopadding"><tr class="nocellnopadd">';
258  print '<td width="96" class="nobordernopadding nowrap">';
259  print $fichinterstatic->getNomUrl(1);
260  print '</td>';
261 
262  print '<td width="16" class="nobordernopadding nowrap">';
263  print '&nbsp;';
264  print '</td>';
265 
266  print '<td width="16" align="right" class="nobordernopadding hideonsmartphone">';
267  $filename=dol_sanitizeFileName($obj->ref);
268  $filedir=$conf->commande->dir_output . '/' . dol_sanitizeFileName($obj->ref);
269  $urlsource=$_SERVER['PHP_SELF'].'?id='.$obj->rowid;
270  print $formfile->getDocumentsLink($fichinterstatic->element, $filename, $filedir);
271  print '</td></tr></table>';
272 
273  print '</td>';
274 
275  print '<td><a href="'.DOL_URL_ROOT.'/comm/card.php?socid='.$obj->socid.'">'.img_object($langs->trans("ShowCompany"),"company").' '.$obj->name.'</a></td>';
276  print '<td>'.dol_print_date($db->jdate($obj->datem),'day').'</td>';
277  print '<td align="right">'.$fichinterstatic->LibStatut($obj->fk_statut,5).'</td>';
278  print '</tr>';
279  $i++;
280  }
281  }
282  print "</table><br>";
283 }
284 else dol_print_error($db);
285 
286 
287 /*
288  * interventions to process
289  */
290 
291 if (! empty($conf->ficheinter->enabled))
292 {
293  $sql = "SELECT f.rowid, f.ref, f.fk_statut, s.nom as name, s.rowid as socid";
294  $sql.=" FROM ".MAIN_DB_PREFIX."fichinter as f";
295  $sql.= ", ".MAIN_DB_PREFIX."societe as s";
296  if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
297  $sql.= " WHERE f.entity IN (".getEntity('intervention').")";
298  $sql.= " AND f.fk_soc = s.rowid";
299  $sql.= " AND f.fk_statut = 1";
300  if ($socid) $sql.= " AND f.fk_soc = ".$socid;
301  if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
302  $sql.= " ORDER BY f.rowid DESC";
303 
304  $resql=$db->query($sql);
305  if ($resql)
306  {
307  $num = $db->num_rows($resql);
308 
309  print '<table class="noborder" width="100%">';
310  print '<tr class="liste_titre">';
311  print '<th colspan="3">'.$langs->trans("FichinterToProcess").' <a href="'.DOL_URL_ROOT.'/fichinter/list.php?viewstatut=1"><span class="badge">'.$num.'</span></a></th></tr>';
312 
313  if ($num)
314  {
315  $i = 0;
316  while ($i < $num)
317  {
318  $obj = $db->fetch_object($resql);
319  print '<tr class="oddeven">';
320  print '<td class="nowrap" width="20%">';
321 
322  $fichinterstatic->id=$obj->rowid;
323  $fichinterstatic->ref=$obj->ref;
324 
325  print '<table class="nobordernopadding"><tr class="nocellnopadd">';
326  print '<td width="96" class="nobordernopadding nowrap">';
327  print $fichinterstatic->getNomUrl(1);
328  print '</td>';
329 
330  print '<td width="16" class="nobordernopadding nowrap">';
331  print '&nbsp;';
332  print '</td>';
333 
334  print '<td width="16" align="right" class="nobordernopadding hideonsmartphone">';
335  $filename=dol_sanitizeFileName($obj->ref);
336  $filedir=$conf->commande->dir_output . '/' . dol_sanitizeFileName($obj->ref);
337  $urlsource=$_SERVER['PHP_SELF'].'?id='.$obj->rowid;
338  print $formfile->getDocumentsLink($fichinterstatic->element, $filename, $filedir);
339  print '</td></tr></table>';
340 
341  print '</td>';
342 
343  print '<td><a href="'.DOL_URL_ROOT.'/comm/card.php?socid='.$obj->socid.'">'.img_object($langs->trans("ShowCompany"),"company").' '.dol_trunc($obj->name,24).'</a></td>';
344 
345  print '<td align="right">'.$fichinterstatic->LibStatut($obj->fk_statut,5).'</td>';
346 
347  print '</tr>';
348  $i++;
349  }
350  }
351 
352  print "</table><br>";
353  }
354  else dol_print_error($db);
355 }
356 
357 print '</div></div></div>';
358 
359 
360 llxFooter();
361 
362 $db->close();
llxFooter()
Footer empty.
Definition: index.php:44
load_fiche_titre($titre, $morehtmlright='', $picto='title_generic.png', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
GETPOST($paramname, $check='none', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
print
Draft customers invoices.
Definition: index.php:91
dol_trunc($string, $size=40, $trunc='right', $stringencoding='UTF-8', $nodot=0, $display=0)
Truncate a string to a particular length adding &#39;...&#39; if string larger than length.
if(! empty($conf->facture->enabled) && $user->rights->facture->lire) if(! empty($conf->fournisseur->enabled) && $user->rights->fournisseur->facture->lire) if(! empty($conf->don->enabled) && $user->rights->societe->lire) if(! empty($conf->tax->enabled) && $user->rights->tax->charges->lire) if(! empty($conf->facture->enabled) &&! empty($conf->commande->enabled) && $user->rights->commande->lire &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) if(! empty($conf->facture->enabled) && $user->rights->facture->lire) if(! empty($conf->fournisseur->enabled) && $user->rights->fournisseur->facture->lire) $resql
Social contributions to pay.
Definition: index.php:1053
dol_sanitizeFileName($str, $newstr='_', $unaccent=1)
Clean a string to use it as a file name.
Class to manage interventions.
dol_print_error($db='', $error='', $errors=null)
Affiche message erreur system avec toutes les informations pour faciliter le diagnostic et la remonte...
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0)
Show a message to say access is forbidden and stop program Calling this function terminate execution ...
Class to manage generation of HTML components Only common components must be here.
llxHeader()
Header empty.
Definition: index.php:36
Class to offer components to list and upload files.
Class to build graphs.
img_object($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0)
Show a picto called object_picto (generic function)