~ocsinventory-server/ocsinventory-server/stable-1.03

« back to all changes in this revision

Viewing changes to ocsreports/ipdiscover_admin_type.php

  • Committer: serpent
  • Date: 2009-09-03 09:32:02 UTC
  • Revision ID: serpent@snakebase2-20090903093202-1ryusexrrvs9zqow
Removed ocsreports from ocsinventory-server project

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
<?php
2
 
/*
3
 
 * Created on 7 mai 2009
4
 
 *
5
 
 * To change the template for this generated file go to
6
 
 * Window - Preferences - PHPeclipse - PHP - Code Templates
7
 
 */
8
 
require ('fichierConf.class.php');
9
 
$form_name='admin_type';
10
 
$ban_head='no';
11
 
$no_error='YES';
12
 
require_once("header.php");
13
 
if (!($_SESSION["lvluser"] == SADMIN or $_SESSION['TRUE_LVL'] == SADMIN))
14
 
        die("FORBIDDEN");
15
 
echo "<br><br><br>";    
16
 
echo "<form name='".$form_name."' id='".$form_name."' action='' method='post'>";
17
 
 
18
 
if (isset($_POST['SUP_PROF']) and $_POST['SUP_PROF'] != ''){
19
 
        $del_type=mysql_real_escape_string($_POST['SUP_PROF']);
20
 
        $sql="delete from devicetype where id='".$del_type."'";
21
 
        mysql_query($sql, $_SESSION["writeServer"]) or die(mysql_error($_SESSION["writeServer"]));      
22
 
        $tab_options['CACHE']='RESET';  
23
 
        
24
 
}
25
 
 
26
 
if (isset($_POST['Valid_modif_x'])){
27
 
        $new_type=mysql_real_escape_string($_POST['TYPE_NAME']);
28
 
        if (trim($new_type) == ''){
29
 
                $ERROR=$l->g(936);              
30
 
        }else{
31
 
                $sql="select ID from devicetype where NAME = '".$new_type."'";
32
 
                $res = mysql_query($sql, $_SESSION["readServer"] );
33
 
                $row=mysql_fetch_object($res);
34
 
                if (isset($row->ID))
35
 
                $ERROR=$l->g(937);      
36
 
        }
37
 
        if (isset($ERROR)){
38
 
                echo "<font color=red><b>".$ERROR."</b></font>";
39
 
                $_POST['ADD_TYPE']="VALID";
40
 
        }
41
 
        else{
42
 
                $sql="insert into devicetype (NAME) VALUES ('".$new_type."')";
43
 
                mysql_query($sql, $_SESSION["writeServer"]) or die(mysql_error($_SESSION["writeServer"]));      
44
 
                $tab_options['CACHE']='RESET';  
45
 
        }
46
 
}
47
 
 
48
 
 
49
 
 
50
 
 
51
 
 
52
 
if (isset($_POST['ADD_TYPE'])){
53
 
        $tab_typ_champ[0]['DEFAULT_VALUE']=$_POST['TYPE_NAME'];
54
 
        $tab_typ_champ[0]['INPUT_NAME']="TYPE_NAME";
55
 
        $tab_typ_champ[0]['CONFIG']['SIZE']=60;
56
 
        $tab_typ_champ[0]['CONFIG']['MAXLENGTH']=255;
57
 
        $tab_typ_champ[0]['INPUT_TYPE']=0;
58
 
        $tab_name[0]=$l->g(938).": ";
59
 
        $tab_hidden['pcparpage']=$_POST["pcparpage"];
60
 
        tab_modif_values($tab_name,$tab_typ_champ,$tab_hidden,$title,$comment="");      
61
 
}else{
62
 
 
63
 
 
64
 
 
65
 
 
66
 
//if( $_SESSION["lvluser"]!=LADMIN && $_SESSION["lvluser"]!=SADMIN  )
67
 
//      die("FORBIDDEN");
68
 
$sql="select ID,NAME from devicetype";
69
 
$list_fields= array('ID' => 'ID',
70
 
                                        $l->g(49)=>'NAME',
71
 
                                        'SUP'=>'ID');
72
 
//$list_fields['SUP']='ID';     
73
 
$default_fields=$list_fields;
74
 
$list_col_cant_del=$list_fields;
75
 
if (!(isset($_POST["pcparpage"])))
76
 
         $_POST["pcparpage"]=5;
77
 
$result_exist=tab_req($table_name,$list_fields,$default_fields,$list_col_cant_del,$sql,$form_name,80,$tab_options); 
78
 
 
79
 
echo "<input type = submit value='".$l->g(307)."' name='ADD_TYPE'>";    
80
 
}
81
 
echo "</form>";
82
 
        
83
 
require_once($_SESSION['FOOTER_HTML']);
84
 
?>