forked from PluginsOCSInventory-NG/officepack
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ms_officepack.php
166 lines (128 loc) · 5.6 KB
/
ms_officepack.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
162
163
164
165
166
<?php
//====================================================================================
// OCS INVENTORY REPORTS
// Copyleft Erwan GOALOU 2010 (erwan(at)ocsinventory-ng(pt)org)
// Web: http://www.ocsinventory-ng.org
//
// This code is open source and may be copied and modified as long as the source
// code is always made freely available.
// Please refer to the General Public Licence http://www.gnu.org/ or Licence.txt
//====================================================================================
if(AJAX){
parse_str($protectedPost['ocs']['0'], $params);
$protectedPost+=$params;
ob_start();
$ajax = true;
}
else{
$ajax=false;
}
// Remove old office licenses ( More than 3 months )
$date = date("Y-m-d H:i:s", mktime(0, 0, 0, date('m') - 2, date('d'), date('Y')));
$query_old_infos = "SELECT o.ID FROM hardware h
INNER JOIN officepack o ON h.id = o.hardware_id
WHERE h.LASTDATE <= '$date' ";
$old_infos = mysql2_query_secure($query_old_infos, $_SESSION['OCS']["readServer"]);
$old_infos_array = array();
while ($row = mysqli_fetch_object($old_infos)) {
$old_infos_array[] = $row->ID;
}
$list_old_info = implode(",", $old_infos_array);
// If list is not empty remove old entries
if($list_old_info != ""){
$remove_old_query = "DELETE FROM officepack WHERE ID IN( $list_old_info ) ;";
mysql2_query_secure($remove_old_query, $_SESSION['OCS']["readServer"]);
}
// Start display page
printEnTete("Office Key Manager");
$form_name="officekey";
$data_on = array(
"1" => "Licenses number by version",
"2" => "Licenses by administrative data"
);
if(!isset($protectedPost['onglet'])){
$protectedPost['onglet'] = 1;
}
$table_name=$form_name;
$tab_options=$protectedPost;
$tab_options['form_name']=$form_name;
$tab_options['table_name']=$table_name;
echo open_form($form_name);
if(!isset($protectedGet['value'])){
onglet($data_on, $form_name, "onglet", 2);
if($protectedPost['onglet'] == 1){
$sql = "SELECT OFFICEVERSION,COUNT(*) as NUMBER FROM `officepack`GROUP BY OFFICEVERSION";
$list_fields=array(
'Office Version' => 'OFFICEVERSION',
'Number' => 'NUMBER',
);
// Create link to see al machines
$tab_options['LIEN_LBL']['Number']="index.php?".PAG_INDEX."=officepack&value=";
$tab_options['LIEN_CHAMP']['Number']="OFFICEVERSION";
$list_col_cant_del=$list_fields;
$default_fields= $list_fields;
ajaxtab_entete_fixe($list_fields,$default_fields,$tab_options,$list_col_cant_del);
}else{
// select account info for sorting
$account_info_list_sql = "Select ID, COMMENT from accountinfo_config WHERE ACCOUNT_TYPE = 'COMPUTERS'";
$account_info_list = mysql2_query_secure($account_info_list_sql, $_SESSION['OCS']["readServer"]);
echo "<p>Accountinfo : <select name='accountinfo' onchange='this.form.submit();'>";
while ($row = mysqli_fetch_object($account_info_list)) {
$id = $row->ID;
$str = $row->COMMENT;
if(isset($protectedPost['accountinfo']) && $protectedPost['accountinfo'] == $row->ID){
echo "<option value='$id' selected>$str</option> ";
}else{
echo "<option value='$id'>$str</option> ";
}
}
echo "</select></p>";
// Select which office version we want to see
$sql_office = "SELECT OFFICEVERSION FROM `officepack`GROUP BY OFFICEVERSION";
$result = mysql2_query_secure($sql_office, $_SESSION['OCS']["readServer"]);
echo "<p>Office version : <select name='officeversion' onchange='this.form.submit();'>";
while ($row = mysqli_fetch_object($result)) {
$officeversion = $row->OFFICEVERSION;
if(isset($protectedPost['officeversion']) && $protectedPost['officeversion'] == $row->OFFICEVERSION){
echo "<option value='$officeversion' selected>$officeversion</option> ";
}else{
echo "<option value='$officeversion'>$officeversion</option> ";
}
}
echo "</select></p>";
if( isset($protectedPost['accountinfo']) && isset($protectedPost['officeversion'])){
$fields = "fields_".$protectedPost['accountinfo'];
if($protectedPost['accountinfo']){
$fields = "TAG";
}
$office = $protectedPost['officeversion'];
$sql = "SELECT a.".$fields." as ACC , COUNT(".$fields.") as ACCNB FROM `accountinfo` as a INNER JOIN officepack as o ON a.hardware_id = o.hardware_id WHERE o.officeversion = '".$office."' GROUP BY ".$fields."";
$list_fields=array(
'Accountinfo' => "ACC",
'Licenses number' => 'ACCNB',
);
$list_col_cant_del=$list_fields;
$default_fields= $list_fields;
ajaxtab_entete_fixe($list_fields,$default_fields,$tab_options,$list_col_cant_del);
}
}
}else{
$version = $protectedGet['value'];
$sql = "SELECT h.NAME, h.USERID, h.DESCRIPTION, o.OFFICEKEY FROM hardware h INNER JOIN officepack o ON h.ID = o.HARDWARE_ID where o.OFFICEVERSION = '$version' ";
$list_fields=array(
'Name' => 'h.NAME',
'User' => 'h.USERID',
'Description' => 'h.DESCRIPTION',
'Office Key' => 'o.OFFICEKEY',
);
$default_fields = $list_fields;
$list_col_cant_del = $list_fields;
ajaxtab_entete_fixe($list_fields,$default_fields,$tab_options,$list_col_cant_del);
}
echo close_form();
if ($ajax){
ob_end_clean();
tab_req($list_fields,$default_fields,$list_col_cant_del,$sql,$tab_options);
ob_start();
}
?>