Subversion Repositories computer_asset_manager_v2

Rev

Rev 59 | Rev 64 | 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',
            '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' => 'calculated',
                  ),
                  'parent' => array(
                     'fieldname' => 'parent',
                     'displayName' => 'Parent',
                     'type' => 'calculated',
                     'link' => 'parent_id',
                  ),
                  'parent_id' => array(
                     'fieldname' => 'parent_id',
                     'class' => 'Device',
                     'display' => false,
                     'type' => 'calculated',
                  ),
                  'owner' => array(
                     'fieldname' => 'owner',
                     'displayName' => 'Owner',
                     'type' => 'calculated',
                     'link' => 'owner_id',
                  ),
                  'owner_id' => array(
                     'fieldname' => 'owner_id',
                     'class' => 'Owner',
                     'display' => false,
                     'type' => 'calculated',
                  ),
                  'location' => array(
                     'fieldname' => 'location',
                     'displayName' => 'Location',
                     'type' => 'calculated',
                     'link' => 'location_id',
                  ),
                  'location_id' => array(
                     'fieldname' => 'location_id',
                     'class' => 'Location',
                     'display' => false,
                     'type' => 'calculated',
                  )
               ) // 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(
            ) // children
         ); // dbStructure
         
      /**
       * Allow device_types to be edited also
       */
      protected function editAdditionalFields() {
         global $dbConnection;
         if ( $_REQUEST['action'] == 'edit' ) {
            $query = sprintf("
               select 
                  concat( 'device_type-', device_type.device_type_id ) id,
                  name name,
                  not isnull(device_id) checked
               from 
                  device_type device_type 
                  left outer join (
                     select 
                        device_id,
                        device_type_id
                     from 
                        device_device_type
                     where device_id = %s
                  ) current using (device_type_id)
               order by name", $this->data[self::$dbStructure['table']['primaryKey']]) ;
            //print "<pre>" . print_r($this->data, true) . "</pre>"; die;
            //print "<pre>" . print_r($query, true) . "</pre>"; die;
            $html = $dbConnection->htmlCheckBoxes( array( 'query' => $query ) );
            //print "<pre>" . print_r($html, true) . "</pre>"; die;
            return "<td colspan='2'>$html</td>";
         } elseif ($_REQUEST['action'] == 'post' ) {
            return array();
         }
      }

   } // class Device
?>