Projet

Général

Profil

Paste
Statistiques
| Branche: | Révision:

ryxeo-glpi-git / inc / state.function.php @ b67d8923

Historique | Voir | Annoter | Télécharger (4,01 ko)

1
<?php
2
/*
3
 * @version $Id: state.function.php 7763 2009-01-06 18:44:50Z moyo $
4
 -------------------------------------------------------------------------
5
 GLPI - Gestionnaire Libre de Parc Informatique
6
 Copyright (C) 2003-2009 by the INDEPNET Development Team.
7

8
 http://indepnet.net/   http://glpi-project.org
9
 -------------------------------------------------------------------------
10

11
 LICENSE
12

13
 This file is part of GLPI.
14

15
 GLPI is free software; you can redistribute it and/or modify
16
 it under the terms of the GNU General Public License as published by
17
 the Free Software Foundation; either version 2 of the License, or
18
 (at your option) any later version.
19

20
 GLPI is distributed in the hope that it will be useful,
21
 but WITHOUT ANY WARRANTY; without even the implied warranty of
22
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
23
 GNU General Public License for more details.
24

25
 You should have received a copy of the GNU General Public License
26
 along with GLPI; if not, write to the Free Software
27
 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
28
 --------------------------------------------------------------------------
29
 */
30

    
31
// ----------------------------------------------------------------------
32
// Original Author of file: Julien Dombre
33
// Purpose of file:
34
// ----------------------------------------------------------------------
35

    
36
if (!defined('GLPI_ROOT')){
37
        die("Sorry. You can't access directly to this file");
38
        }
39

    
40
// FUNCTIONS State
41

    
42

    
43
function showStateSummary($target){
44
        global $DB,$LANG,$CFG_GLPI,$LINK_ID_TABLE;
45

    
46

    
47
        $state_type=$CFG_GLPI["state_types"];
48

    
49
        $states=array();
50
        foreach ($state_type as $key=>$type){
51
                if (!haveTypeRight($type,"r")) {
52
                        unset($state_type[$key]);
53
                } else {
54
                        $query= "SELECT state, COUNT(*) AS CPT FROM ".$LINK_ID_TABLE[$type]." ".
55
                                getEntitiesRestrictRequest("WHERE",$LINK_ID_TABLE[$type])." AND deleted=0 AND is_template=0 GROUP BY state";
56
                        if ($result = $DB->query($query)) {
57
                                if ($DB->numrows($result)>0){
58
                                        while ($data=$DB->fetch_array($result)){
59
                                                $states[$data["state"]][$type]=$data["CPT"];
60
                                        }
61
                                }
62
                        }
63
                }
64
        }
65

    
66
        if (count($states)){
67
                // Produce headline
68
                echo "<div class='center'><table  class='tab_cadrehov'><tr>";
69
        
70
                // Type                        
71
                echo "<th>";
72
                echo $LANG["state"][0]."</th>";
73
        
74
                $ci=new CommonItem;
75
                foreach ($state_type as $type){
76
                        $ci->setType($type);
77
                        echo "<th>".$ci->getType()."</th>";
78
                        $total[$type]=0;
79
                }
80
                echo "<th>".$LANG["common"][33]."</th>";
81
                echo "</tr>";
82
                $query="SELECT * FROM glpi_dropdown_state ORDER BY name";
83
                $result = $DB->query($query);
84
                
85
                // No state 
86
                $tot=0; 
87
                echo "<tr class='tab_bg_2'><td class='center'>&nbsp;</td>"; 
88
                foreach ($state_type as $type){ 
89
                        echo "<td class='center'>"; 
90

    
91
                        if (isset($states[0][$type])) { 
92
                                echo $states[0][$type]; 
93
                                $total[$type]+=$states[0][$type]; 
94
                                $tot+=$states[0][$type]; 
95
                        } else {
96
                                echo "&nbsp;"; 
97
                        }
98
                        echo "</td>"; 
99
                } 
100
                echo "<td class='center'><strong>$tot</strong></td></tr>"; 
101

    
102
                while ($data=$DB->fetch_array($result)){
103
                        $tot=0;
104
                        echo "<tr class='tab_bg_2'><td class='center'><strong><a href='".$CFG_GLPI['root_doc']."/front/state.php?reset_before=1&amp;contains[0]=".$data["name"]."&amp;field[0]=31&amp;sort=1&amp;start=0'>".$data["name"]."</a></strong></td>";
105
        
106
                        foreach ($state_type as $type){
107
                                echo "<td class='center'>";
108
        
109
                                if (isset($states[$data["ID"]][$type])) {
110
                                        echo $states[$data["ID"]][$type];
111
                                        $total[$type]+=$states[$data["ID"]][$type];
112
                                        $tot+=$states[$data["ID"]][$type];
113
                                }
114
                                else echo "&nbsp;";
115
                                echo "</td>";
116
                        }
117
                        echo "<td class='center'><strong>$tot</strong></td>";
118
                        echo "</tr>";
119
                }
120
                echo "<tr class='tab_bg_2'><td class='center'><strong>".$LANG["common"][33]."</strong></td>";
121
                $tot=0;
122
                foreach ($state_type as $type){
123
                        echo "<td class='center'><strong>".$total[$type]."</strong></td>";
124
                        $tot+=$total[$type];
125
                }
126
                echo "<td class='center'><strong>".$tot."</strong></td>";
127
                echo "</tr>";
128
                echo "</table></div>";
129

    
130
        }else {
131
                echo "<div class='center'><strong>".$LANG["state"][7]."</strong></div>";
132
        }
133

    
134

    
135
}
136

    
137
?>
Redmine Appliance - Powered by TurnKey Linux