forked from glpi-project/glpi
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfind_num.php
161 lines (144 loc) · 5.8 KB
/
find_num.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
<?php
/**
* ---------------------------------------------------------------------
* GLPI - Gestionnaire Libre de Parc Informatique
* Copyright (C) 2015-2018 Teclib' and contributors.
*
* http://glpi-project.org
*
* based on GLPI - Gestionnaire Libre de Parc Informatique
* Copyright (C) 2003-2014 by the INDEPNET Development Team.
*
* ---------------------------------------------------------------------
*
* LICENSE
*
* This file is part of GLPI.
*
* GLPI is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* GLPI is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GLPI. If not, see <http://www.gnu.org/licenses/>.
* ---------------------------------------------------------------------
*/
include ('../inc/includes.php');
if (!$CFG_GLPI["use_anonymous_helpdesk"]) {
exit();
}
// Send UTF8 Headers
header("Content-Type: text/html; charset=UTF-8");
echo "<!DOCTYPE html>\n";
echo "<html lang=\"{$CFG_GLPI["languages"][$_SESSION['glpilanguage']][3]}\">";
?>
<head>
<meta charset="utf-8">
<title>GLPI</title>
<?php
// Appel CSS
echo "<link rel='stylesheet' href='".$CFG_GLPI["root_doc"]."/css/styles.css' type='text/css' ".
"media='screen' >";
// Appel javascript
echo "<script type='text/javascript' src='".$CFG_GLPI["root_doc"]."/script.js'></script>";
?>
</head>
<body>
<script type="text/javascript">
function fillidfield(Type,Id) {
window.opener.document.forms["helpdeskform"].elements["items_id"].value = Id;
window.opener.document.forms["helpdeskform"].elements["itemtype"].value = Type;
window.close();
}
</script>
<?php
echo "<div class='center'>";
echo "<p class='b'>".__('Search the ID of your hardware')."</p>";
echo " <form name='form1' method='post' action='".$_SERVER['PHP_SELF']."'>";
echo "<table class='tab_cadre_fixe'>";
echo "<tr><th height='29'>".__('Enter the first letters (user, item name, serial or asset number)').
"</th></tr>";
echo "<tr><td class='tab_bg_1 center'>";
echo "<input name='NomContact' type='text' id='NomContact' >";
echo "<input type='hidden' name='send' value='1'>"; // bug IE ! La validation par enter ne fonctionne pas sans cette ligne incroyable mais vrai !
echo "<input type='submit' name='send' value='". _sx('button', 'Search')."'>";
echo "</td></tr></table>";
Html::closeForm();
echo "</div>";
if (isset($_POST["send"])) {
echo "<table class='tab_cadre_fixe'>";
echo " <tr class='tab_bg3'>";
echo " <td class='center b' width='30%'>".__('Alternate username')."</td>";
echo " <td class='center b' width='20%'>".__('Hardware type')."</td>";
echo " <td class='center b' width='30%'>"._n('Associated element', 'Associated elements', 2)."</td>";
echo " <td class='center b' width='5%'>".__('ID')."</td>";
echo " <td class='center b' width='10%'>".__('Serial number')."</td>";
echo " <td class='center b' width='10%'>".__('Inventory number')."</td>";
echo " </tr>";
$types = ['Computer' => __('Computer'),
'NetworkEquipment' => __('Network device'),
'Printer' => __('Printer'),
'Monitor' => __('Monitor'),
'Peripheral' => __('Device')];
foreach ($types as $type => $label) {
$iterator = $DB->request([
'SELECT' => ['name', 'id', 'contact', 'serial', 'otherserial'],
'FROM' => getTableForItemType($type),
'WHERE' => [
'is_template' => 0,
'is_deleted' => 0,
'OR' => [
'contact' => ['LIKE', '%' . $_POST['NomContact'] . '%'],
'name' => ['LIKE', '%' . $_POST['NomContact'] . '%'],
'serial' => ['LIKE', '%' . $_POST['NomContact'] . '%'],
'otherserial' => ['LIKE', '%' . $_POST['NomContact'] . '%'],
]
],
'ORDER' => ['name']
]);
while ($ligne = $iterator->next()) {
$Comp_num = $ligne['id'];
$Contact = $ligne['contact'];
$Computer = $ligne['name'];
$s1 = $ligne['serial'];
$s2 = $ligne['otherserial'];
echo " <tr class='tab_bg_1' onClick=\"fillidfield(".$type.",".$Comp_num.")\">";
echo "<td class='center'> $Contact </td>";
echo "<td class='center'> $label </td>";
echo "<td class='center b'> $Computer </td>";
echo "<td class='center'> $Comp_num </td>";
echo "<td class='center'> $s1 </td>";
echo "<td class='center'> $s2 </td>";
echo "<td class='center'>";
echo "</td></tr>";
}
}
$iterator = $DB->request([
'SELECT' => ['name', 'id'],
'FROM' => 'glpi_softwares',
'WHERE' => [
'is_template' => 0,
'is_deleted' => 0,
'name' => ['LIKE', "%{$_POST['NomContact']}%"]
],
'ORDER' => ['name']
]);
while ($ligne = $iterator->next()) {
$Comp_num = $ligne['id'];
$Computer = $ligne['name'];
echo " <tr class='tab_find' onClick=\"fillidfield('Software',".$Comp_num.")\">";
echo "<td class='center'> </td>";
echo "<td class='center'> "._n('Software', 'Software', 1)." </td>";
echo "<td class='center b'> $Computer </td>";
echo "<td class='center'> $Comp_num </td>";
echo "<td class='center'> </td></tr>";
}
echo "</table>";
}
echo '</body></html>';