Guest User

Untitled

a guest
Jun 10th, 2018
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.30 KB | None | 0 0
  1. <?php
  2. class Client extends DataObjectDecorator{
  3. /**
  4. * agrega los campos extra en la tabla clientes
  5. */
  6. function extraDBFields() {
  7. return array(
  8. 'db' => array(
  9. //datos basicos
  10. 'Address' => 'Varchar(255)',
  11. 'City' => 'Varchar(255)',
  12. 'State' => 'Varchar(255)',
  13. 'ZIP' => 'Varchar(50)',
  14. 'Country' => 'Varchar(255)',
  15. 'Phone' => 'Varchar(50)',
  16. //datos en caso de emergencia
  17. 'EmergencyName' => 'Varchar(100)',
  18. 'EmergencyAddress' => 'Varchar(255)',
  19. 'EmergencyCity' => 'Varchar(255)',
  20. 'EmergencyState' => 'Varchar(255)',
  21. 'EmergencyZIP' => 'Varchar(50)',
  22. 'EmergencyCountry' => 'Varchar(255)',
  23. 'EmergencyPhone' => 'Varchar(50)',
  24. 'EmergencyEmail' => 'Varchar(255)',
  25. //datos personales
  26. 'Age' => 'Int(3)',
  27. 'Height' => 'Int(5)',
  28. 'Wheight' => 'Int(5)',
  29. 'Occupation' => 'Varchar(100)',
  30. 'PassportNumber' => 'Varchar(100)',
  31. 'Vegetarian' => 'Boolean',
  32. 'Allergies' => 'Boolean',
  33. 'IHaveAllergies' => 'Text',
  34. 'TakingMedication' => 'Boolean',
  35. 'MedicalHistory' => 'Text',
  36. 'OutDoorExperience' => 'Text',
  37. 'ClimbingExperience' => 'Text',
  38. 'FoundPatagonicasIn' => 'Text',
  39. 'MyOpinionOfPatagonicas' => 'Text'
  40. )
  41. );
  42. }
  43.  
  44. /**
  45. * muestra los campos en el cms
  46. */
  47. public function updateCMSFields(FieldSet &$fields) {
  48.  
  49. $fields->addFieldsToTab('Root.Basic Information',array(
  50. BasicFields()
  51. ));
  52. //datos en caso de emergencia
  53. $fields->addFieldsToTab('Root.In case of Emergency',array(
  54. EmergencyFields()
  55. ));
  56. //datos personales
  57. $fields->addFieldsToTab('Root.Personal Information',array(
  58. PersonalFields()
  59. ));
  60. }
  61. // 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>")) ;
  62.  
  63. /**
  64. * retorna los campos para los formularios de front
  65. * For orders made by existing members, this will be called on that memeber.
  66. * For new orders, this will be called on the singleton object.
  67. */
  68.  
  69. function BasicFields() {
  70. $fields = new FieldSet(
  71. new HeaderField('Basic Information', 3),
  72. new TextField('Address'),
  73. new TextField('City'),
  74. new TextField('State'),
  75. new TextField('ZIP'),
  76. new DropdownField('Country', 'Country', Geoip::getCountryDropDown(), self::findCountry()),
  77. new TextField('Phone')
  78. );
  79. return $fields;
  80. }
  81.  
  82. function EmergencyFields() {
  83. $fields = new FieldSet(
  84. new HeaderField('Contact this person in case of emergency', 3),
  85. new TextField('EmergencyName', 'Name'),
  86. new TextField('EmergencyAddress', 'Address'),
  87. new TextField('EmergencyCity', 'City'),
  88. new TextField('EmergencyState', 'State'),
  89. new TextField('EmergencyZIP', 'ZIP'),
  90. new DropdownField('EmergencyCountry', 'Country', Geoip::getCountryDropDown(), self::findCountry()),
  91. new TextField('EmergencyPhone', 'Phone'),
  92. new TextField('EmergencyEmail', 'Email')
  93. );
  94. return $fields;
  95. }
  96.  
  97. function PersonalFields() {
  98. $fields = new FieldSet(
  99. new HeaderField('Personal Information', 3),
  100. new TextField('Age'),
  101. new TextField('Height'),
  102. new TextField('Wheight'),
  103. new TextField('Occupation'),
  104. new TextField('PassportNumber','Passport Number'),
  105. new TextField('Vegetarian', 'Are you Vegetarian?'),
  106. new TextField('Allergies', 'Do you have any allergies?'),
  107. new TextareaField('IHaveAllergies','I you are allergic, please provide us information about it'),
  108. new TextField('TakingMedication','Are you taking medication?'),
  109. new TextareaField('MedicalHistory', 'Medical History'),
  110. new TextField('OutDoorExperience', 'Outdoor Experience'),
  111. new TextareaField('ClimbingExperience', 'Climbing Experience'),
  112. 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>"),
  113. new TextareaField('FoundPatagonicasIn', 'Where did you find us?')
  114. );
  115. return $fields;
  116. }
  117.  
  118. static function findCountry(){
  119. $member = Member::currentUser();
  120. if($member && $member->Country) {
  121. $country = $member->Country;
  122. } else {
  123. $country = Geoip::visitor_country();
  124. }
  125. return $country;
  126. }
  127. }
  128. ?>
Add Comment
Please, Sign In to add comment