Projet

Général

Profil

Paste
Statistiques
| Branche: | Révision:

ryxeo-glpi-git / ajax / dropdownFindNum.php @ b67d8923

Historique | Voir | Annoter | Télécharger (3,59 ko)

1
<?php
2
/*
3
 * @version $Id: dropdownFindNum.php 7882 2009-01-23 18:24:05Z 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:
33
// Purpose of file:
34
// ----------------------------------------------------------------------
35

    
36
define('GLPI_ROOT','..');
37
$AJAX_INCLUDE=1;
38
include (GLPI_ROOT . "/inc/includes.php");
39
header("Content-Type: text/html; charset=UTF-8");
40
header_nocache();
41

    
42
checkRight("create_ticket","1");
43

    
44
$where="";
45

    
46
if (isset($_POST["entity_restrict"])&&$_POST["entity_restrict"]>=0){
47
        $where.= "WHERE `".$_POST['table']."`.FK_entities='".$_POST["entity_restrict"]."'";
48
} else {
49
        $where.=getEntitiesRestrictRequest("WHERE",$_POST['table']);
50
}
51

    
52
if (empty($where)){
53
        $where="WHERE 1 ";
54
}
55
if (in_array($_POST['table'],$CFG_GLPI["deleted_tables"]))
56
        $where.=" AND deleted=0 ";
57
if (in_array($_POST['table'],$CFG_GLPI["template_tables"]))
58
        $where.=" AND is_template=0 ";                
59

    
60
if (strlen($_POST['searchText'])>0&&$_POST['searchText']!=$CFG_GLPI["ajax_wildcard"]){
61
        $search=makeTextSearch($_POST['searchText']);
62
        $WWHERE="";
63
        $FWHERE="";
64
        if ($_POST['table']!="glpi_software"){
65
                $WWHERE=" OR contact ".$search." OR serial ".$search." OR otherserial ".$search;
66
        } 
67
                 
68
        $where.=" AND (name ".$search." OR ID = '".$_POST['searchText']."' $WWHERE)";
69
}
70
//If software : filter to display only the softwares that are allowed to be visible in Helpdesk
71
if ($_POST['table']=="glpi_software"){
72
        $where.= " AND helpdesk_visible=1 ";
73
}
74
$NBMAX=$CFG_GLPI["dropdown_max"];
75
$LIMIT="LIMIT 0,$NBMAX";
76
if ($_POST['searchText']==$CFG_GLPI["ajax_wildcard"]) $LIMIT="";
77

    
78
$query = "SELECT * FROM `".$_POST['table']."` $where ORDER BY name $LIMIT";
79

    
80
$result = $DB->query($query);
81

    
82
echo "<select name=\"".$_POST['myname']."\" size='1'>";
83

    
84
if ($_POST['searchText']!=$CFG_GLPI["ajax_wildcard"]&&$DB->numrows($result)==$NBMAX)
85
echo "<option value=\"0\">--".$LANG["common"][11]."--</option>";
86

    
87
echo "<option value=\"0\">-----</option>";
88
if ($DB->numrows($result)) {
89
        while ($data = $DB->fetch_array($result)) {
90

    
91
                $output = $data['name'];
92
                if ($_POST['table']!="glpi_software"){
93
                        if (!empty($data['contact'])){
94
                                $output.=" - ".$data['contact'];
95
                        }
96
                        if (!empty($data['serial'])){
97
                                $output.=" - ".$data['serial'];
98
                        }
99
                        if (!empty($data['otherserial'])){
100
                                $output.=" - ".$data['otherserial'];
101
                        }
102
                }
103
                if (empty($output)||$CFG_GLPI["view_ID"]) $output.=" (".$data['ID'].")";
104
                echo "<option value=\"".$data['ID']."\" title=\"".cleanInputText($output)."\">".substr($output,0,$CFG_GLPI["dropdown_limit"])."</option>";
105
        }
106
}
107
echo "</select>";
108

    
109

    
110
?>        
Redmine Appliance - Powered by TurnKey Linux