ryxeo-glpi-git / front / software.licenses.php @ b67d8923
Historique | Voir | Annoter | Télécharger (5,97 ko)
1 |
<?php
|
---|---|
2 |
/*
|
3 |
* @version $Id: software.licenses.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 |
// Based on:
|
32 |
// IRMA, Information Resource-Management and Administration
|
33 |
// Christian Bauer
|
34 |
// ----------------------------------------------------------------------
|
35 |
// Original Author of file:
|
36 |
// Purpose of file:
|
37 |
// ----------------------------------------------------------------------
|
38 |
|
39 |
|
40 |
|
41 |
$NEEDED_ITEMS=array("computer","software","infocom","contract"); |
42 |
|
43 |
define('GLPI_ROOT', '..'); |
44 |
include (GLPI_ROOT . "/inc/includes.php"); |
45 |
|
46 |
if(!isset($_GET["lID"])) $_GET["lID"] = ""; |
47 |
if(!isset($_GET["sID"])) $_GET["sID"] = ""; |
48 |
if(!isset($_GET["withtemplate"])) $_GET["withtemplate"] = 0; |
49 |
|
50 |
$lic=new License; |
51 |
|
52 |
if (isset($_POST["add"])) |
53 |
{ |
54 |
checkRight("software","w"); |
55 |
|
56 |
if ($_POST["serial"]=="free"||$_POST["serial"]=="global"){ |
57 |
$number=1; |
58 |
}else {
|
59 |
$number=$_POST["number"]; |
60 |
} |
61 |
unset($_POST["number"]); |
62 |
|
63 |
for ($i=1;$i<=$number;$i++){ |
64 |
unset($lic->fields["ID"]); |
65 |
$lic->add($_POST); |
66 |
} |
67 |
|
68 |
logEvent($_POST["sID"], "software", 4, "inventory", $_SESSION["glpiname"]." added a license."); |
69 |
|
70 |
glpi_header($_SERVER['PHP_SELF']."?form=add&sID=".$_POST["sID"]); |
71 |
} |
72 |
else if (isset($_POST["update_stock_licenses"])||isset($_POST["update_stock_licenses_x"])){ |
73 |
checkRight("software","w"); |
74 |
|
75 |
foreach ($_POST as $key => $val){ |
76 |
if (ereg("stock_licenses_([0-9]+)",$key,$regs)){ |
77 |
if ($val!=$_POST["nb_licenses_".$regs[1]]){ |
78 |
updateNumberLicenses($regs[1],$_POST["nb_licenses_".$regs[1]],$val); |
79 |
} |
80 |
} |
81 |
} |
82 |
glpi_header($_SERVER['HTTP_REFERER']); |
83 |
|
84 |
} |
85 |
else if (isset($_POST["update_expire"])||isset($_POST["update_expire_x"])){ |
86 |
checkRight("software","w"); |
87 |
|
88 |
$lic=new License; |
89 |
$input["expire"]=$_POST["expire"]; |
90 |
|
91 |
foreach ($_POST as $key => $val){ |
92 |
if (ereg("license_([0-9]+)",$key,$ereg)){ |
93 |
$input["ID"]=$ereg[1]; |
94 |
$lic->update($input); |
95 |
} |
96 |
} |
97 |
glpi_header($_SERVER['HTTP_REFERER']); |
98 |
} |
99 |
else if (isset($_POST["update_buy"])||isset($_POST["update_buy_x"])){ |
100 |
checkRight("software","w"); |
101 |
|
102 |
$input["buy"]=$_POST["buy"]; |
103 |
|
104 |
foreach ($_POST as $key => $val){ |
105 |
if (ereg("license_([0-9]+)",$key,$ereg)){ |
106 |
$input["ID"]=$ereg[1]; |
107 |
$lic->update($input); |
108 |
} |
109 |
} |
110 |
glpi_header($_SERVER['HTTP_REFERER']); |
111 |
} |
112 |
else if (isset($_POST["move"])||isset($_POST["move"])){ |
113 |
if ($_POST["lID"]&&$lic->getFromDB($_POST["lID"])){ |
114 |
unset($lic->fields["ID"]); |
115 |
unset($lic->fields["comments"]); |
116 |
|
117 |
foreach ($_POST as $key => $val){ |
118 |
$lic=array(); |
119 |
if (ereg("license_([0-9]+)",$key,$ereg)){ |
120 |
$lic[]=$ereg[1]; |
121 |
} |
122 |
if (count($lic)){ |
123 |
moveLicensesToLicense($lic,$_POST["lID"]); |
124 |
} |
125 |
} |
126 |
} |
127 |
glpi_header($_SERVER['HTTP_REFERER']); |
128 |
} |
129 |
else if (isset($_POST["move_to_software"])||isset($_POST["move_to_software"])){ |
130 |
//print_r($_POST);
|
131 |
$soft=new Software; |
132 |
foreach ($_POST as $key => $val){ |
133 |
if (ereg("license_([0-9]+)",$key,$ereg)){ |
134 |
moveSimilarLicensesToSoftware($ereg[1],$_POST["sID"]); |
135 |
} |
136 |
} |
137 |
glpi_header($_SERVER['HTTP_REFERER']); |
138 |
} |
139 |
else if (isset($_POST["delete_similar_license"])){ |
140 |
checkRight("software","w"); |
141 |
|
142 |
foreach ($_POST as $key => $val){ |
143 |
if (ereg("license_([0-9]+)",$key,$ereg)){ |
144 |
deleteSimilarLicenses($ereg[1]); |
145 |
} |
146 |
} |
147 |
logEvent(0, "software", 4, "inventory", $_SESSION["glpiname"]." deleted licenses."); |
148 |
glpi_header($_SERVER['HTTP_REFERER']." "); |
149 |
} |
150 |
else if (isset($_POST["delete_license"])){ |
151 |
checkRight("software","w"); |
152 |
|
153 |
foreach ($_POST as $key => $val){ |
154 |
if (ereg("license_([0-9]+)",$key,$ereg)){ |
155 |
$lic->delete(array("ID"=>$ereg[1])); |
156 |
} |
157 |
} |
158 |
glpi_header($_SERVER['HTTP_REFERER']); |
159 |
} |
160 |
else if (isset($_POST["update"])){ |
161 |
checkRight("software","w"); |
162 |
|
163 |
$lic->update($_POST); |
164 |
logEvent(0, "software", 4, "inventory", $_SESSION["glpiname"]." update a license."); |
165 |
glpi_header($_SERVER['HTTP_REFERER']); |
166 |
} |
167 |
else if (isset($_GET["form"])){ |
168 |
checkRight("software","w"); |
169 |
|
170 |
commonHeader($LANG["Menu"][4],$_SERVER['PHP_SELF'],"inventory","software"); |
171 |
showLicenseForm($_SERVER['PHP_SELF'],$_GET['form'],$_GET["sID"],$_GET["lID"]); |
172 |
commonFooter(); |
173 |
} |
174 |
else if (isset($_GET["delete"])){ |
175 |
checkRight("software","w"); |
176 |
|
177 |
$lic->delete(array("ID"=>$_GET["ID"])); |
178 |
logEvent(0, "software", 4, "inventory", $_SESSION["glpiname"]." deleted a license."); |
179 |
glpi_header($_SERVER['HTTP_REFERER']." "); |
180 |
} |
181 |
else if (isset($_POST["install"])){ |
182 |
checkRight("software","w"); |
183 |
|
184 |
installSoftware($_POST["cID"],$_POST["licenseID"],$_POST["sID"]); |
185 |
logEvent($_POST["cID"], "computers", 5, "inventory", $_SESSION["glpiname"]." installed software."); |
186 |
glpi_header($_SERVER['HTTP_REFERER']); |
187 |
} |
188 |
else if (isset($_GET["uninstall"])){ |
189 |
checkRight("software","w"); |
190 |
|
191 |
uninstallSoftware($_GET["ID"]); |
192 |
logEvent($_GET["cID"], "computers", 5, "inventory", $_SESSION["glpiname"]." uninstalled software."); |
193 |
glpi_header($_SERVER['HTTP_REFERER']); |
194 |
} |
195 |
else if (isset($_GET["unglobalize"])&&isset($_GET["ID"])){ |
196 |
unglobalizeLicense($_GET["ID"]); |
197 |
logEvent($_GET["sID"], "software", 4, "inventory", $_SESSION["glpiname"]." ".$LANG["log"][60]); |
198 |
glpi_header($CFG_GLPI["root_doc"]."/front/software.form.php?ID=".$_GET["sID"]); |
199 |
} |
200 |
else if (isset($_GET["back"])){ |
201 |
glpi_header($_GET["back"]); |
202 |
} |
203 |
|
204 |
|
205 |
?>
|