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