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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
<?php
class Client extends DataObjectDecorator{
  /**
  * extra data fields for Member
  */
  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'
      )
    );
  } 

  /**
  * shows the cms fields
  */    
  public function updateCMSFields(FieldSet &$fields) {      
    $fields->removeFieldsFromTab('Root.Main',array(
      'FirstName','Surname','Email','Website'
    ));

    //basic fields    
    $fields->addFieldsToTab('Root.BasicInformation',$this->BasicFields());
    //in case of emergency fields
    $fields->addFieldsToTab('Root.InCaseOfEmergency',$this->EmergencyFields());
    //personal fields        
    $fields->addFieldsToTab('Root.PersonalInformation',$this->PersonalFields());  
  }

  /**
   * return fields for different tabs in the cms and for different 
   * and shorter front forms
   */
  function BasicFields() {
    $fields = new FieldSet(
      new HeaderField('Basic Information', 3), 
      new TextField("FirstName", "First name"),
      new TextField("Surname"),
      new TextField("Email", "Email address"),
      new TextField("Website"),            
      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 OptionsetField('Vegetarian', 'Are you Vegetarian?',array("0" => "no","1" => "yes"),"0"),      
      new OptionsetField('Allergies', 'Do you have any allergies?',array("0" => "no","1" => "yes"),"0"),      
      new TextareaField('IHaveAllergies','I you are allergic, please provide us information about it'),
      new OptionsetField('TakingMedication','Are you taking medication?',array("0" => "no","1" => "yes"),"0"),
      new TextareaField('MedicalHistory', 'Medical History'),                                                     
      new TextareaField('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;
  }                                  
}
?>