Projet

Général

Profil

Paste
Statistiques
| Branche: | Révision:

ryxeo-glpi-git / htdocs / ajax / dropdownNetpoint.php @ 1c14bcc4

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

1 1c14bcc4 Eric Seigne
<?php
2
/*
3
 * @version $Id: dropdownNetpoint.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
// Direct access to file
37
if(ereg("dropdownNetpoint.php",$_SERVER['PHP_SELF'])){
38
        define('GLPI_ROOT','..');
39
        $AJAX_INCLUDE=1;
40
        include (GLPI_ROOT."/inc/includes.php");
41
        header("Content-Type: text/html; charset=UTF-8");
42
        header_nocache();
43
};
44
45
if (!defined('GLPI_ROOT')){
46
        die("Can not acces directly to this file");
47
        }
48
49
checkLoginUser();
50
51
// Make a select box with preselected values
52
if (!isset($_POST["limit"])) $_POST["limit"]=$CFG_GLPI["dropdown_limit"];
53
54
        if (strlen($_POST['searchText'])>0&&$_POST['searchText']!=$CFG_GLPI["ajax_wildcard"]){
55
                $where=" WHERE (glpi_dropdown_netpoint.name ".makeTextSearch($_POST['searchText'])." OR glpi_dropdown_locations.completename ".makeTextSearch($_POST['searchText']).")";
56
        } else {
57
                $where=" WHERE 1 ";                
58
        }
59
60
        $NBMAX=$CFG_GLPI["dropdown_max"];
61
        $LIMIT="LIMIT 0,$NBMAX";
62
        if ($_POST['searchText']==$CFG_GLPI["ajax_wildcard"]) $LIMIT="";
63
64
        if (!(isset($_POST["devtype"]) && $_POST["devtype"]!=NETWORKING_TYPE && isset($_POST["location"]) && $_POST["location"]>0)) {
65
                if (isset($_POST["entity_restrict"])&&$_POST["entity_restrict"]>=0){
66
                        $where.= " AND glpi_dropdown_netpoint.FK_entities='".$_POST["entity_restrict"]."'";
67
                } else {
68
                        $where.=getEntitiesRestrictRequest(" AND ","glpi_dropdown_locations");
69
                }
70
        }
71
72
        $query = "SELECT glpi_dropdown_netpoint.comments as comments, glpi_dropdown_netpoint.ID as ID, glpi_dropdown_netpoint.name as netpname, glpi_dropdown_locations.completename as loc FROM glpi_dropdown_netpoint";
73
        $query .= " LEFT JOIN glpi_dropdown_locations ON (glpi_dropdown_netpoint.location = glpi_dropdown_locations.ID)";
74
75
        if (isset($_POST["devtype"]) && $_POST["devtype"]>0){
76
                $query .= " LEFT JOIN glpi_networking_ports ON (glpi_dropdown_netpoint.ID = glpi_networking_ports.netpoint";
77
        
78
                if ($_POST["devtype"]==NETWORKING_TYPE){
79
                        $query .= " AND  glpi_networking_ports.device_type =" . NETWORKING_TYPE .")";
80
                }
81
                else {
82
                        $query .= " AND  glpi_networking_ports.device_type !=" . NETWORKING_TYPE .")";
83
84
                        if (isset($_POST["location"]) && $_POST["location"]>=0){
85
                                $where.=" AND glpi_dropdown_netpoint.location='".$_POST["location"]."' ";
86
                        }
87
                }
88
                $where.=" AND glpi_networking_ports.netpoint IS NULL ";
89
90
        } else        if (isset($_POST["location"]) && $_POST["location"]>=0){
91
                $where.=" AND glpi_dropdown_netpoint.location='".$_POST["location"]."' ";
92
        }
93
94
        $query .= $where . " ORDER BY glpi_dropdown_locations.completename, glpi_dropdown_netpoint.name $LIMIT"; 
95
96
        //logInFile("debug","SQL:".$query."\n\n");
97
        $result = $DB->query($query);
98
99
        echo "<select id='dropdown_".$_POST["myname"].$_POST["rand"]."' name=\"".$_POST['myname']."\" size='1'>";
100
101
        if ($_POST['searchText']!=$CFG_GLPI["ajax_wildcard"]&&$DB->numrows($result)==$NBMAX)
102
                echo "<option value=\"0\">--".$LANG["common"][11]."--</option>";
103
        else echo "<option value=\"0\">-----</option>";
104
105
        $output=getDropdownName('glpi_dropdown_netpoint',$_POST['value']);
106
        if (!empty($output)&&$output!="&nbsp;")
107
                echo "<option selected value='".$_POST['value']."'>".$output."</option>";
108
109
110
        if ($DB->numrows($result)) {
111
                while ($data =$DB->fetch_array($result)) {
112
                        $output = $data['netpname'];
113
                        $loc=$data['loc'];
114
                        $ID = $data['ID'];
115
                        $addcomment="";
116
                        if (isset($data["comments"])) $addcomment=" - ".$data["comments"];
117
                        echo "<option value=\"$ID\" title=\"".cleanInputText($output.$addcomment)."\"";
118
                        //if ($ID==$_POST['value']) echo " selected ";
119
                        echo ">".$output." ($loc)</option>";
120
                }
121
        }
122
        echo "</select>";
123
124
if (isset($_POST["comments"])&&$_POST["comments"]){
125
        $params=array('value'=>'__VALUE__','table'=>"glpi_dropdown_netpoint");
126
        ajaxUpdateItemOnSelectEvent("dropdown_".$_POST["myname"].$_POST["rand"],"comments_".$_POST["myname"].$_POST["rand"],$CFG_GLPI["root_doc"]."/ajax/comments.php",$params,false);
127
}
128
129
?>
Redmine Appliance - Powered by TurnKey Linux