3 files
VehicleAdmim.php
<?php
class VehicleAdmin extends ModelAdmin{
static $managed_models = array ('Vehicle');
static $url_segment = "trucks";
static $menu_title = "Trucks";
}
?>
Vechicle.php
<?php
class Vehicle extends DataObject
{
static $db = array(
"Stockcode"=>"Varchar(64)",
"Category"=>"Enum('Truck,Trailer','Truck')",
"Type"=>"Varchar(64)",
"Make"=>"Varchar(64)",
"Model"=>"Varchar(64)",
"Year"=>"Int",
"Colour"=>"Varchar(32)",
"Vin"=>"Varchar(64)",
"Engine"=>"Varchar(64)",
"Horsepower"=>"Int",
"Transmission"=>"Varchar(64)",
"Wheelbase"=>"Varchar(64)",
"Speedo"=>"Varchar(32)",
"Tare"=>"Varchar(32)",
"Gvwrating"=>"Varchar(64)",
"Gcwrating"=>"Varchar(64)",
"Regnum"=>"Varchar(64)",
"Regexpiry"=>"Varchar(64)",
"Additional"=>"Varchar(255)",
"Price"=>"Currency",
"Cofexpiry"=>"Varchar(64)",
"Axelconfig"=>"Varchar(64)",
"Rearaxels"=>"Varchar(64)",
"Suspension"=>"Varchar(64)",
"Towingeye"=>"Varchar(64)",
"Hubometer"=>"Varchar(64)",
"Roaduserkms"=>"Varchar(64)",
"Deck"=>"Varchar(64)",
"Drawbeamcert"=>"Varchar(64)",
"Chassismod"=>"Varchar(64)",
"Anchorage"=>"Varchar(64)",
"Nzhbc"=>"Varchar(64)",
"Kingpincert"=>"Varchar(64)",
"Fifthwheel"=>"Varchar(64)",
"Twistlocks"=>"Varchar(32)",
"Tyreinfo"=>"Varchar(64)",
"Tyrefront1"=>"Varchar(32)",
"Tyrefront2"=>"Varchar(32)",
"Tyrefront3"=>"Varchar(32)",
"Tyrefront4"=>"Varchar(32)",
"Tyrerear1"=>"Varchar(32)",
"Tyrerear2"=>"Varchar(32)",
"Tyrerear3"=>"Varchar(32)",
"Tyrerear4"=>"Varchar(32)",
"Condition"=>"Enum('New,Used','New')",
"Description"=>"Varchar(127)",
);
static $field_labels = array(
"StockCode"=>"Stock Code",
"Vin"=>"Vin Number",
"Engine"=>"Engine Type",
"Horsepower"=>"Engine Horsepower",
"Speedo"=>"Speedo Reading",
"Tare"=>"Tare Weight",
"Gvwrating"=>"GVW Rating",
"Gcwrating"=>"GCW Rating",
"Regnum"=>"Registration Number",
"Regexpiry"=>"Registration Expiry",
"Additional"=>"Addition Information",
"Cofexpiry"=>"COF Expiry",
"Axelconfig"=>"Axel Configuration",
"Rearaxels"=>"Rear Axels",
"Suspension"=>"Rear Suspension",
"Towingeye"=>"Towing Eye Size",
"Roaduserkms"=>"Road User Kms",
"Deck"=>"Deck Type & Length",
"Drawbeamcert"=>"Drawbeam Cert Expiry",
"Chassismod"=>"Chassis Mod Expiry",
"Anchorage"=>"Load Anchorge Expiry",
"Nzhbc"=>"NZHBC Compliance",
"Kingpincert"=>"Kingpin Cert Expiry",
"Fifthwheel"=>"5th Wheel Mount Cert",
"Twistlocks"=>"Twist Locks Fitted/Cert",
"Tyreinfo"=>"Tyre Information",
"Tyrefront1"=>"Front 1",
"Tyrefront2"=>"Front 2",
"Tyrefront3"=>"Front 3",
"Tyrefront4"=>"Front 4",
"Tyrerear1"=>"Rear 1",
"Tyrerear2"=>"Rear 2",
"Tyrerear3"=>"Rear 3",
"Tyrerear4"=>"Rear 4"
);
static $has_one = array();
static $has_many = array (
'Photos' => 'Photo'
);
public function getCMSFields()
{
$f = parent::getCMSFields();
$manager = new ImageDataObjectManager(
$this, // Controller
'Photos', // Source name
'Photo', // Source class
'PhotoPic', // File name on DataObject
array(
'PhotoHeading' => 'Photo Heading',
'PhotoText' => 'Photo Copy'
), // Headings
'getCMSFields_forPopup' // Detail fields (function name or FieldSet object)
// Filter clause '`GalleryPageID` = '.$this->ID.''
// Sort clause
// Join clause
);
$manager->setAddTitle("Image");
//$f->addFieldToTab("Root.Content",$manager);
return $f;
}
static $searchable_fields = array("Stockcode","Make","Model","Type");
static $summary_fields = array("Stockcode","Make","Model","Type");
}
Photo,php
<?php
class Photo extends DataObject{
static $db = array(
'PhotoHeading' =>'Text',
'PhotoText' =>'Text'
);
static $has_one = array(
'PhotoPic' => 'Image',
'Vehicle' => 'Vehicle'
);
}
?>