Subversion Repositories computer_asset_manager_v2

Rev

Rev 66 | Rev 72 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

<?php
   require_once( 'camp.class.php' );

   class Device extends Camp {
      protected static $dbStructure = array(
         'table' => array(
            'tableName' => 'device',
            'primaryKey' => 'device_id',
            'selectionDisplay' => 'name',
            'inactiveField' => 'removed',
            'fields' => array(
                  'id' => array (
                     'fieldname' => 'device_id',
                     'displayName' => 'ID',
                     'type' => 'int unsigned',
                     'nullable' => false,
                     'canEdit' => false
                  ),
                  'name' => array (
                     'fieldname' => 'name',
                     'displayName' => 'Name',
                     'type' => 'varchar',
                     'size' => 64,
                     'list' => true
                  ),
                  'uuid' => array (
                     'fieldname' => 'uuid',
                     'displayName' => 'UUID',
                     'type' => 'varchar',
                     'size' => 36,
                     'list' => false
                  ),
                  'serial' => array (
                     'fieldname' => 'serial',
                     'displayName' => 'Serial',
                     'type' => 'varchar',
                     'size' => 36,
                     'list' => false
                  ),
                  'created' => array (
                     'fieldname' => 'created',
                     'displayName' => 'Created',
                     'type' => 'date'
                  ),
                  'removed' => array(
                     'fieldname' => 'removed',
                     'displayName' => 'Removed',
                     'type' => 'date'
                  ),
                  'device_types' => array(
                     'fieldname' => 'device_types',
                     'displayName' => 'Device Type',
                     'type' => '1:M',
                     'linkageTable' => 'device_device_type',
                     'linkageColumn' => 'device_id',
                     'foreignTable' => 'device_type',
                     'foreignColumn' => 'device_type_id',
                     'foreignDisplayColumn' => 'name',
                     'displayView' => array (
                        'viewName' => 'device_device_types',
                        'myField' => 'device_id',
                        'displayField' => 'device_types'
                     )
                  ),
                  'parent' => array(
                     'displayQuery' => 'select b.device_id id, b.name display from device_device a join device b on (a.parent_id = b.device_id) where a.removed is null and a.device_id = ~~id~~',
                     'fieldname' => 'parent_id',
                     'class' => 'Device',
                     'displayName' => 'Parent',
                     'displayColumn' => 'name',
                     'type' => '1:1H',
                     'linkageTable' => 'device_device',
                     'linkageColumn' => 'device_id',
                     'foreignColumn' => 'parent_id',
                     'foreignTable' => 'device'
                  ),
                  'owner' => array(
                     'fieldname' => 'owner_id',
                     'class' => 'Owner',
                     'displayName' => 'Owner',
                     'displayColumn' => 'name',
                     'type' => '1:1H',
                     'linkageTable' => 'owner_device',
                     'linkageColumn' => 'device_id',
                     'foreignColumn' => 'owner_id',
                     'foreignTable' => 'owner'
                  ),
                  'location' => array(
                     'fieldname' => 'location_id',
                     'class' => 'Location',
                     'displayName' => 'Location',
                     'displayColumn' => 'name',
                     'type' => '1:1H',
                     'linkageTable' => 'location_device',
                     'linkageColumn' => 'device_id',
                     'foreignColumn' => 'location_id',
                     'foreignTable' => 'location'
                  ),
               ) // fields
            ), // table
            'view' => array(
               'viewName' => 'view_device_location_owner_type',
               'primaryKey' => 'device_id',
               'selectionDisplay' => 'device',
               'fields' => array(
                  'removed' => array( 
                     'fieldname' => 'device_removed'
                  )
               )
            ), // view
            /*
            'children' => array(
               'Device' => array(
                  'filter' => 'parent_id = ~~device_id~~',
                  'name' => 'Children',
                  'view' => array(
                     'name' => 'view_device_types',
                     'my field' => 'device_id',
                     'display field' => 'device_types'
                     ),
                  'noAdd' => true
                  )
            ) // children
            */
         ); // dbStructure

   } // class Device
?>