Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class Client extends DataObjectDecorator{
- /**
- * agrega los campos extra en la tabla clientes
- */
- function extraDBFields() {
- return array(
- 'db' => array(
- //datos basicos
- 'Address' => 'Varchar(255)',
- 'City' => 'Varchar(255)',
- 'State' => 'Varchar(255)',
- 'ZIP' => 'Varchar(50)',
- 'Country' => 'Varchar(255)',
- 'Phone' => 'Varchar(50)',
- //datos en caso de emergencia
- 'EmergencyName' => 'Varchar(100)',
- 'EmergencyAddress' => 'Varchar(255)',
- 'EmergencyCity' => 'Varchar(255)',
- 'EmergencyState' => 'Varchar(255)',
- 'EmergencyZIP' => 'Varchar(50)',
- 'EmergencyCountry' => 'Varchar(255)',
- 'EmergencyPhone' => 'Varchar(50)',
- 'EmergencyEmail' => 'Varchar(255)',
- //datos personales
- 'Age' => 'Int(3)',
- 'Height' => 'Int(5)',
- 'Wheight' => 'Int(5)',
- 'Occupation' => 'Varchar(100)',
- 'PassportNumber' => 'Varchar(100)',
- 'Vegetarian' => 'Boolean',
- 'Allergies' => 'Boolean',
- 'IHaveAllergies' => 'Text',
- 'TakingMedication' => 'Boolean',
- 'MedicalHistory' => 'Text',
- 'OutDoorExperience' => 'Text',
- 'ClimbingExperience' => 'Text',
- 'FoundPatagonicasIn' => 'Text',
- 'MyOpinionOfPatagonicas' => 'Text'
- )
- );
- }
- /**
- * muestra los campos en el cms
- */
- public function updateCMSFields(FieldSet &$fields) {
- $fields->addFieldsToTab('Root.Basic Information',array(
- BasicFields()
- ));
- //datos en caso de emergencia
- $fields->addFieldsToTab('Root.In case of Emergency',array(
- EmergencyFields()
- ));
- //datos personales
- $fields->addFieldsToTab('Root.Personal Information',array(
- PersonalFields()
- ));
- }
- // new LiteralField("ClimbingExperienceTip","<p class='tip'> (Peak, Route, Date) - Please complete this if you are signing up for a mountaineering or skiing expedition. Send a separate email if necessary.</p>")) ;
- /**
- * retorna los campos para los formularios de front
- * For orders made by existing members, this will be called on that memeber.
- * For new orders, this will be called on the singleton object.
- */
- function BasicFields() {
- $fields = new FieldSet(
- new HeaderField('Basic Information', 3),
- new TextField('Address'),
- new TextField('City'),
- new TextField('State'),
- new TextField('ZIP'),
- new DropdownField('Country', 'Country', Geoip::getCountryDropDown(), self::findCountry()),
- new TextField('Phone')
- );
- return $fields;
- }
- function EmergencyFields() {
- $fields = new FieldSet(
- new HeaderField('Contact this person in case of emergency', 3),
- new TextField('EmergencyName', 'Name'),
- new TextField('EmergencyAddress', 'Address'),
- new TextField('EmergencyCity', 'City'),
- new TextField('EmergencyState', 'State'),
- new TextField('EmergencyZIP', 'ZIP'),
- new DropdownField('EmergencyCountry', 'Country', Geoip::getCountryDropDown(), self::findCountry()),
- new TextField('EmergencyPhone', 'Phone'),
- new TextField('EmergencyEmail', 'Email')
- );
- return $fields;
- }
- function PersonalFields() {
- $fields = new FieldSet(
- new HeaderField('Personal Information', 3),
- new TextField('Age'),
- new TextField('Height'),
- new TextField('Wheight'),
- new TextField('Occupation'),
- new TextField('PassportNumber','Passport Number'),
- new TextField('Vegetarian', 'Are you Vegetarian?'),
- new TextField('Allergies', 'Do you have any allergies?'),
- new TextareaField('IHaveAllergies','I you are allergic, please provide us information about it'),
- new TextField('TakingMedication','Are you taking medication?'),
- new TextareaField('MedicalHistory', 'Medical History'),
- new TextField('OutDoorExperience', 'Outdoor Experience'),
- new TextareaField('ClimbingExperience', 'Climbing Experience'),
- new LiteralField("ClimbingExperienceTip","<p class='tip'> (Peak, Route, Date) - Please complete this if you are signing up for a mountaineering or skiing expedition. Send a separate email if necessary.</p>"),
- new TextareaField('FoundPatagonicasIn', 'Where did you find us?')
- );
- return $fields;
- }
- static function findCountry(){
- $member = Member::currentUser();
- if($member && $member->Country) {
- $country = $member->Country;
- } else {
- $country = Geoip::visitor_country();
- }
- return $country;
- }
- }
- ?>
Add Comment
Please, Sign In to add comment