diff --git a/include/class_glpi.inc b/include/class_glpi.inc
index 08f94fad60494d4841abe2b01bd17f99e1bce7c6..162e0fed6eab5f97e5e5e4e9d4fd7c1300d13381 100644 (file)
--- a/include/class_glpi.inc
+++ b/include/class_glpi.inc
*/
function updateSystemType($name,$id)
{
-
if($this->is_connected){
$tmp = $this->query("SELECT * FROM glpi_type_computers WHERE ID=".$id.";");
if(isset($tmp[0])){
{
if($this->is_connected){
$ret = array();
- $tmp = $this->query("SELECT * FROM glpi_enterprises;");
+ $tmp = $this->query("SELECT * FROM glpi_enterprises ORDER BY name;");
foreach($tmp as $t){
$ret[$t['ID']]=$t['name'];
}
+
return($ret);
}else{
echo "not connected";
/* Operating systems
Returns all OSs
*/
- function getOSTypes()
+ function getOSTypes($keys = false)
{
if($this->is_connected){
$ret = array();
- $tmp=($this->query("SELECT * FROM glpi_dropdown_os;"));
+ $tmp=($this->query("SELECT * FROM glpi_dropdown_os ORDER by name;"));
- foreach($tmp as $t){
- $ret[$t['ID']]=$t['name'];
+ if($keys){
+ foreach($tmp as $t){
+ $ret[$t['name']]=$t['ID'];
+ }
+ }else{
+ foreach($tmp as $t){
+ $ret[$t['ID']]=$t['name'];
+ }
}
-
return($ret);
-
+
}else{
echo "not connected";
return(false);
*/
function updateOS($name,$id)
{
-
if($this->is_connected){
$tmp = $this->query("SELECT * FROM glpi_dropdown_os WHERE ID=".$id.";");
if(isset($tmp[0])){
/* Printer functions
*/
+ /* is printer type used ?
+ */
+ function is_printerTypeUsed($id)
+ {
+ if($this->is_connected){
+ $qry = "SELECT * FROM glpi_printers WHERE type=".$id.";";
+ $res = $this->query( $qry);
+ $ret =array();
+ foreach($res as $entry){
+ $ret[$entry['ID']] = $entry['name'];
+ }
+ return($ret);
+ }else{
+ echo "not connected";
+ return(false);
+ }
+ }
/* This functions checks if the selected computer/network
device is already available in the db
{
if($this->is_connected){
$ret = array();
- $tmp = ($this->query("SELECT * FROM glpi_type_printers;"));
+ $tmp = ($this->query("SELECT * FROM glpi_type_printers ORDER BY name; "));
foreach($tmp as $t){
$ret[$t['ID']]=$t['name'];
}
/* Cartridges
*/
-
/* return all assigned cartridges */
function getUsedCartridges($printerID)
{
}
}
+ function is_cartridgeTypeUsed($id){
+ if($this->is_connected){
+ $qry = "SELECT p.ID,p.name as name FROM glpi_cartridges as c,glpi_printers as p WHERE p.ID=c.FK_glpi_printers AND c.FK_glpi_cartridges_type=".$id.";";
+ $res = $this->query($qry);
+ $ret =array();
+ foreach($res as $entry){
+ $ret[$entry['ID']] = $entry['name'];
+ }
+ return($ret);
+ }else{
+ echo "not connected";
+ return(false);
+ }
+ }
+
function getCartridgeTypeInformations($id = "all"){
if($this->is_connected){
$ret = array();
}
+
+ /* check if given manufacturer ID ist still in use.
+ The problem is, that nearly every table uses manufacturers ....
+ */
+ function is_manufacturerUsed($id)
+ {
+ if($this->is_connected){
+ $tables = array();
+ foreach($this->deviceMappingGOsaGlpi as $entry => $table){
+ $tables[] = $entry;
+ }
+ $tables[] ="glpi_computers";
+ $tables[] ="glpi_cartridges_type";
+ $ret = array();
+ $i = 3;
+ foreach($tables as $tbl){
+ if($i <= 0 ) continue;
+ $qry = "SELECT * FROM ".$tbl." WHERE FK_glpi_enterprise = ".$id.";";
+ $res = $this->query($qry);
+ foreach($res as $entry){
+ if($i <= 0 ) continue;
+ if(isset($entry['designation'])){
+ $entry['name'] = $entry['designation'];
+ }
+ $i --;
+ $ret[] = $entry['name'];
+ }
+ }
+ return($ret);
+ }else{
+ echo "not connected";
+ return(false);
+ }
+ }
+
/* Manufacturer
Updates already existing manufacturer
*/