Skip to content

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Related to SS forum question
<?php
class Lodge extends PhysicalLocation {
public static $db = array(
'Name' => 'Varchar(255)',
);
public static $defaults = array(
// 'DefaultDuration' => 1,
);
public static $has_one = array(
'Destination' => 'Destination'
);
public static $has_many = array(
'Rooms' => 'Room'
);
// season information here
}
class Room extends DataObject {
public static $db = array(
'Name' => 'Varchar(255)',
);
public static $has_one = array(
'Lodge' => 'Lodge'
);
public static $searchable_fields = array(
"Name", "Lodge.ID", "Lodge.Destination.ID"
);
public static $summary_fields = array(
"Name", "Lodge.Name", "Lodge.Destination.Name"
);
}
class RoomAdmin extends ModelAdmin {
public static $managed_models = array('Room'); // Can manage multiple models
static $url_segment = 'roomadmin'; // Linked as /admin/products/
static $menu_title = 'Room rate admin';
}
class PhysicalLocation extends DataObject {
public static $db = array(
'Name' => 'Varchar(255)',
'ShortDesc' => 'Varchar(255)',
'Latitude' => 'Decimal(20,10)',
'Longitude' => 'Decimal(20,10)',
'City' => 'Varchar(255)',
'Country' => 'Varchar(255)',
'Address' => 'Varchar(255)',
);
// public function CurrentClass() {
// return
// }
public function getCurrentClass() {
return "".get_class($this);
}
public function init() {
$this->CurrentClassVal = get_class($this);
parent::init();
}
}
class Destination extends PhysicalLocation {
public static $db = array(
// 'Name' => 'Varchar(255)',
);
public static $has_many = array(
'DestinationItems' => 'ItineraryDestinationItem',
'Activities' => 'Activity'
);
static $default_country = 'MW';
public function getCMSFields() {
$fields = parent::getCMSFields();
$fields->addFieldToTab('Root.Main',new CountryDropdownField('Country', 'County'));
// remove the relation tab
$fields->removeByName("DestinationItems");
return $fields;
}
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.