Rev 63 | Rev 65 | 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' => '1:M',
),
'parent' => array(
'fieldname' => 'parent_id',
'class' => 'Device',
'displayName' => 'Parent',
'displayColumn' => 'parent',
'type' => '1:1H',
'linkage_table' => 'device_device',
'linkage_column' => 'device_id',
'foreign_column' => 'parent_id',
'foreign_table' => 'device'
),
'owner' => array(
'fieldname' => 'owner_id',
'class' => 'Owner',
'displayName' => 'Owner',
'displayColumn' => 'owner',
'type' => '1:1H',
'linkage_table' => 'owner_device',
'linkage_column' => 'device_id',
'foreign_column' => 'owner_id',
'foreign_table' => 'owner'
),
'location' => array(
'fieldname' => 'location_id',
'class' => 'Location',
'displayName' => 'Location',
'displayColumn' => 'location',
'type' => '1:1H',
'linkage_table' => 'location_device',
'linkage_column' => 'device_id',
'foreign_column' => 'location_id',
'foreign_table' => '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'
)
) // 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
?>