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',
64 rodolico 52
                     'type' => '1:M',
59 rodolico 53
                  ),
54
                  'parent' => array(
55
                     'fieldname' => 'parent_id',
56
                     'class' => 'Device',
64 rodolico 57
                     'displayName' => 'Parent',
58
                     'displayColumn' => 'parent',
59
                     'type' => '1:1H',
60
                     'linkage_table' => 'device_device',
61
                     'linkage_column' => 'device_id',
62
                     'foreign_column' => 'parent_id',
63
                     'foreign_table' => 'device'
59 rodolico 64
                  ),
65
                  'owner' => array(
66
                     'fieldname' => 'owner_id',
67
                     'class' => 'Owner',
64 rodolico 68
                     'displayName' => 'Owner',
69
                     'displayColumn' => 'owner',
70
                     'type' => '1:1H',
71
                     'linkage_table' => 'owner_device',
72
                     'linkage_column' => 'device_id',
73
                     'foreign_column' => 'owner_id',
74
                     'foreign_table' => 'owner'
59 rodolico 75
                  ),
76
                  'location' => array(
64 rodolico 77
                     'fieldname' => 'location_id',
78
                     'class' => 'Location',
59 rodolico 79
                     'displayName' => 'Location',
64 rodolico 80
                     'displayColumn' => 'location',
81
                     'type' => '1:1H',
82
                     'linkage_table' => 'location_device',
83
                     'linkage_column' => 'device_id',
84
                     'foreign_column' => 'location_id',
85
                     'foreign_table' => 'location'
59 rodolico 86
                  ),
53 rodolico 87
               ) // fields
56 rodolico 88
            ), // table
89
            'view' => array(
90
               'viewName' => 'view_device_location_owner_type',
91
               'primaryKey' => 'device_id',
92
               'selectionDisplay' => 'device',
93
               'fields' => array(
94
                  'removed' => array( 
95
                     'fieldname' => 'device_removed'
96
                  )
97
               )
59 rodolico 98
            ), // view
99
            'children' => array(
64 rodolico 100
               'Device' => array(
101
                  'filter' => 'parent_id = ~~device_id~~',
102
                  'name' => 'Children'
103
                  )
59 rodolico 104
            ) // children
53 rodolico 105
         ); // dbStructure
63 rodolico 106
 
107
      /**
108
       * Allow device_types to be edited also
109
       */
110
      protected function editAdditionalFields() {
111
         global $dbConnection;
112
         if ( $_REQUEST['action'] == 'edit' ) {
113
            $query = sprintf("
114
               select 
115
                  concat( 'device_type-', device_type.device_type_id ) id,
116
                  name name,
117
                  not isnull(device_id) checked
118
               from 
119
                  device_type device_type 
120
                  left outer join (
121
                     select 
122
                        device_id,
123
                        device_type_id
124
                     from 
125
                        device_device_type
126
                     where device_id = %s
127
                  ) current using (device_type_id)
128
               order by name", $this->data[self::$dbStructure['table']['primaryKey']]) ;
129
            //print "<pre>" . print_r($this->data, true) . "</pre>"; die;
130
            //print "<pre>" . print_r($query, true) . "</pre>"; die;
131
            $html = $dbConnection->htmlCheckBoxes( array( 'query' => $query ) );
132
            //print "<pre>" . print_r($html, true) . "</pre>"; die;
133
            return "<td colspan='2'>$html</td>";
134
         } elseif ($_REQUEST['action'] == 'post' ) {
135
            return array();
136
         }
137
      }
53 rodolico 138
 
59 rodolico 139
   } // class Device
53 rodolico 140
?>