Subversion Repositories computer_asset_manager_v2

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
53 rodolico 1
<?php
2
   require_once( 'camp.class.php' );
3
 
4
   class Device extends Camp {
5
      protected static $dbStructure = array(
6
         'table' => array(
7
            'tableName' => 'device',
8
            'primaryKey' => 'device_id',
9
            'selectionDisplay' => 'name',
10
            'fields' => array(
56 rodolico 11
                  'id' => array (
12
                     'fieldname' => 'device_id',
53 rodolico 13
                     'displayName' => 'ID',
14
                     'type' => 'int unsigned',
63 rodolico 15
                     'nullable' => false,
16
                     'canEdit' => false
53 rodolico 17
                  ),
18
                  'name' => array (
56 rodolico 19
                     'fieldname' => 'name',
20
                     'displayName' => 'Name',
53 rodolico 21
                     'type' => 'varchar',
22
                     'size' => 64,
23
                     'list' => true
24
                  ),
25
                  'uuid' => array (
56 rodolico 26
                     'fieldname' => 'uuid',
53 rodolico 27
                     'displayName' => 'UUID',
28
                     'type' => 'varchar',
29
                     'size' => 36,
30
                     'list' => false
31
                  ),
32
                  'serial' => array (
56 rodolico 33
                     'fieldname' => 'serial',
34
                     'displayName' => 'Serial',
53 rodolico 35
                     'type' => 'varchar',
36
                     'size' => 36,
37
                     'list' => false
38
                  ),
39
                  'created' => array (
56 rodolico 40
                     'fieldname' => 'created',
53 rodolico 41
                     'displayName' => 'Created',
42
                     'type' => 'date'
43
                  ),
44
                  'removed' => array(
56 rodolico 45
                     'fieldname' => 'removed',
53 rodolico 46
                     'displayName' => 'Removed',
47
                     'type' => 'date'
59 rodolico 48
                  ),
49
                  'device_types' => array(
50
                     'fieldname' => 'device_types',
51
                     'displayName' => 'Device Type',
52
                     'type' => 'calculated',
53
                  ),
54
                  'parent' => array(
55
                     'fieldname' => 'parent',
56
                     'displayName' => 'Parent',
57
                     'type' => 'calculated',
63 rodolico 58
                     'link' => 'parent_id',
59 rodolico 59
                  ),
60
                  'parent_id' => array(
61
                     'fieldname' => 'parent_id',
62
                     'class' => 'Device',
63
                     'display' => false,
64
                     'type' => 'calculated',
65
                  ),
66
                  'owner' => array(
67
                     'fieldname' => 'owner',
68
                     'displayName' => 'Owner',
69
                     'type' => 'calculated',
63 rodolico 70
                     'link' => 'owner_id',
59 rodolico 71
                  ),
72
                  'owner_id' => array(
73
                     'fieldname' => 'owner_id',
74
                     'class' => 'Owner',
75
                     'display' => false,
76
                     'type' => 'calculated',
77
                  ),
78
                  'location' => array(
79
                     'fieldname' => 'location',
80
                     'displayName' => 'Location',
81
                     'type' => 'calculated',
63 rodolico 82
                     'link' => 'location_id',
59 rodolico 83
                  ),
84
                  'location_id' => array(
85
                     'fieldname' => 'location_id',
86
                     'class' => 'Location',
87
                     'display' => false,
88
                     'type' => 'calculated',
53 rodolico 89
                  )
90
               ) // fields
56 rodolico 91
            ), // table
92
            'view' => array(
93
               'viewName' => 'view_device_location_owner_type',
94
               'primaryKey' => 'device_id',
95
               'selectionDisplay' => 'device',
96
               'fields' => array(
97
                  'removed' => array( 
98
                     'fieldname' => 'device_removed'
99
                  )
100
               )
59 rodolico 101
            ), // view
102
            'children' => array(
103
            ) // children
53 rodolico 104
         ); // dbStructure
63 rodolico 105
 
106
      /**
107
       * Allow device_types to be edited also
108
       */
109
      protected function editAdditionalFields() {
110
         global $dbConnection;
111
         if ( $_REQUEST['action'] == 'edit' ) {
112
            $query = sprintf("
113
               select 
114
                  concat( 'device_type-', device_type.device_type_id ) id,
115
                  name name,
116
                  not isnull(device_id) checked
117
               from 
118
                  device_type device_type 
119
                  left outer join (
120
                     select 
121
                        device_id,
122
                        device_type_id
123
                     from 
124
                        device_device_type
125
                     where device_id = %s
126
                  ) current using (device_type_id)
127
               order by name", $this->data[self::$dbStructure['table']['primaryKey']]) ;
128
            //print "<pre>" . print_r($this->data, true) . "</pre>"; die;
129
            //print "<pre>" . print_r($query, true) . "</pre>"; die;
130
            $html = $dbConnection->htmlCheckBoxes( array( 'query' => $query ) );
131
            //print "<pre>" . print_r($html, true) . "</pre>"; die;
132
            return "<td colspan='2'>$html</td>";
133
         } elseif ($_REQUEST['action'] == 'post' ) {
134
            return array();
135
         }
136
      }
53 rodolico 137
 
59 rodolico 138
   } // class Device
53 rodolico 139
?>