public
Last active

Related to SS forum question

  • Download Gist
gistfile1.php
PHP
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101
<?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;
}
}
?>

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.