/protected/models/School.php

https://bitbucket.org/atnanahidiw/mcf6 · PHP · 238 lines · 150 code · 11 blank · 77 comment · 0 complexity · d9eac4542459045e44c52085063208e4 MD5 · raw file

  1. <?php
  2. /**
  3. * This is the model class for table "contestant_school".
  4. *
  5. * The followings are the available columns in table 'contestant_school':
  6. * @property integer $contestant_id
  7. * @property string $contestant_team_name
  8. * @property string $contestant_email
  9. * @property string $contestant_first_photo
  10. * @property string $contestant_first_id_f
  11. * @property string $contestant_first_id_b
  12. * @property string $contestant_first_name
  13. * @property string $contestant_first_address
  14. * @property string $contestant_first_phone
  15. * @property string $contestant_second_photo
  16. * @property string $contestant_second_id_f
  17. * @property string $contestant_second_id_b
  18. * @property string $contestant_second_name
  19. * @property string $contestant_second_address
  20. * @property string $contestant_second_phone
  21. * @property string $contestant_third_photo
  22. * @property string $contestant_third_id_f
  23. * @property string $contestant_third_id_b
  24. * @property string $contestant_third_name
  25. * @property string $contestant_third_address
  26. * @property string $contestant_third_phone
  27. * @property string $contestant_supervisor_name
  28. * @property string $contestant_supervisor_nik
  29. * @property string $contestant_supervisor_address
  30. * @property string $contestant_supervisor_email
  31. * @property string $contestant_supervisor_phone
  32. * @property string $contestant_school_name
  33. * @property string $contestant_school_address
  34. * @property string $contestant_school_phone
  35. * @property integer $province
  36. *
  37. *
  38. * The followings are the available model relations:
  39. * @property Contestant $contestant
  40. */
  41. class School extends CActiveRecord
  42. {
  43. /**
  44. * Returns the static model of the specified AR class.
  45. * @param string $className active record class name.
  46. * @return School the static model class
  47. */
  48. public static function model($className=__CLASS__)
  49. {
  50. return parent::model($className);
  51. }
  52. /**
  53. * @return string the associated database table name
  54. */
  55. public function tableName()
  56. {
  57. return 'contestant_school';
  58. }
  59. /**
  60. * @return array validation rules for model attributes.
  61. */
  62. public function rules()
  63. {
  64. // NOTE: you should only define rules for those attributes that
  65. // will receive user inputs.
  66. return array(
  67. array('contestant_email', 'unique', 'message'=>'{attribute} sudah terdaftar'),
  68. array('contestant_team_name, contestant_school_phone, contestant_first_phone, contestant_email, contestant_first_name, contestant_school_name, province', 'required', 'message'=>'{attribute} tidak boleh kosong'),
  69. array('contestant_team_name, contestant_email, contestant_first_name, contestant_second_name, contestant_third_name, contestant_school_name', 'length', 'max'=>50),
  70. array('contestant_id, contestant_team_name, contestant_email, contestant_first_photo, contestant_first_id_f, contestant_first_id_b, contestant_first_name, contestant_first_address, contestant_first_phone, contestant_second_photo, contestant_second_id_f, contestant_second_id_b, contestant_second_name, contestant_second_address, contestant_second_phone, contestant_third_photo, contestant_third_id_f, contestant_third_id_b, contestant_third_name, contestant_third_address, contestant_third_phone, contestant_supervisor_name, contestant_supervisor_nik, contestant_supervisor_address, contestant_supervisor_email, contestant_supervisor_phone, contestant_school_name, contestant_school_address, contestant_school_phone, province', 'safe'),
  71. //type validation
  72. array('contestant_first_phone, contestant_second_phone, contestant_third_phone, contestant_supervisor_phone, contestant_school_phone', 'length', 'max'=>15),
  73. array('contestant_email, contestant_supervisor_email','email'),
  74. array('contestant_first_phone, contestant_second_phone, contestant_third_phone, contestant_supervisor_phone, contestant_school_phone','numerical'),
  75. // The following rule is used by search().
  76. // Please remove those attributes that should not be searched.
  77. array('contestant_id, contestant_team_name, contestant_email, contestant_first_photo, contestant_first_id_f, contestant_first_id_b, contestant_first_name, contestant_first_address, contestant_first_phone, contestant_second_photo, contestant_second_id_f, contestant_second_id_b, contestant_second_name, contestant_second_address, contestant_second_phone, contestant_third_photo, contestant_third_id_f, contestant_third_id_b, contestant_third_name, contestant_third_address, contestant_third_phone, contestant_supervisor_name, contestant_supervisor_nik, contestant_supervisor_address, contestant_supervisor_email, contestant_supervisor_phone, contestant_school_name, contestant_school_address, contestant_school_phone', 'safe', 'on'=>'search'),
  78. //array('contestant_first_photo, contestant_first_id_f, contestant_first_id_b, contestant_second_photo, contestant_second_id_f, contestant_second_id_b, contestant_third_photo, contestant_third_id_f, contestant_third_id_b', 'application.components.imageValidation'),
  79. );
  80. }
  81. /**
  82. * @return array relational rules.
  83. */
  84. public function relations()
  85. {
  86. // NOTE: you may need to adjust the relation name and the related
  87. // class name for the relations automatically generated below.
  88. return array(
  89. 'contestant' => array(self::BELONGS_TO, 'Contestant', 'contestant_id'),
  90. );
  91. }
  92. /**
  93. * @return array customized attribute labels (name=>label)
  94. */
  95. public function attributeLabels()
  96. {
  97. return array(
  98. 'contestant_team_name' => 'Nama Tim',
  99. 'contestant_email' => 'Email',
  100. 'contestant_first_name' => 'Nama Anggota #1',
  101. 'contestant_first_address' => 'Alamat Anggota #1',
  102. 'contestant_first_phone' => 'Nomor Kontak Anggota #1',
  103. 'contestant_first_photo' => 'Pasfoto Peserta #1',
  104. 'contestant_first_id_f' => 'Foto Kartu Identitas Peserta #1 (depan)',
  105. 'contestant_first_id_b' => 'Foto Kartu Identitas Peserta #1 (belakang)',
  106. 'contestant_second_name' => 'Nama Anggota #2',
  107. 'contestant_second_address' => 'Alamat Anggota #2',
  108. 'contestant_second_phone' => 'Nomor Kontak Anggota #2',
  109. 'contestant_second_photo' => 'Pasfoto Peserta #2',
  110. 'contestant_second_id_f' => 'Foto Kartu Identitas Peserta #2 (depan)',
  111. 'contestant_second_id_b' => 'Foto Kartu Identitas Peserta #2 (belakang)',
  112. 'contestant_third_name' => 'Nama Anggota #3',
  113. 'contestant_third_address' => 'Alamat Anggota #3',
  114. 'contestant_third_phone' => 'Nomor Kontak Anggota #3',
  115. 'contestant_third_photo' => 'Pasfoto Peserta #3',
  116. 'contestant_third_id_f' => 'Foto Kartu Identitas Peserta #3 (depan)',
  117. 'contestant_third_id_b' => 'Foto Kartu Identitas Peserta #3 (belakang)',
  118. 'contestant_supervisor_name' => 'Nama Supervisor',
  119. 'contestant_supervisor_nik' => 'NIK Supervisor',
  120. 'contestant_supervisor_address' => 'Alamat Supervisor',
  121. 'contestant_supervisor_email' => 'Email Supervisor',
  122. 'contestant_supervisor_phone' => 'Nomor Kontak Supervisor',
  123. 'contestant_school_name' => 'Nama Sekolah',
  124. 'contestant_school_address' => 'Alamat Sekolah',
  125. 'contestant_school_phone' => 'Nomor Kontak Sekolah',
  126. 'province' => 'Provinsi Asal Sekolah',
  127. );
  128. }
  129. /**
  130. * Retrieves a list of models based on the current search/filter conditions.
  131. * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
  132. */
  133. public function search()
  134. {
  135. // Warning: Please modify the following code to remove attributes that
  136. // should not be searched.
  137. $criteria=new CDbCriteria;
  138. $criteria->compare('contestant_id',$this->contestant_id);
  139. $criteria->compare('contestant_team_name',$this->contestant_team_name,true);
  140. $criteria->compare('contestant_phone',$this->contestant_phone,true);
  141. $criteria->compare('contestant_email',$this->contestant_email,true);
  142. $criteria->compare('contestant_first_name',$this->contestant_first_name,true);
  143. $criteria->compare('contestant_second_name',$this->contestant_second_name,true);
  144. $criteria->compare('contestant_third_name',$this->contestant_third_name,true);
  145. $criteria->compare('contestant_school_name',$this->contestant_school_name,true);
  146. return new CActiveDataProvider($this, array(
  147. 'criteria'=>$criteria,
  148. ));
  149. }
  150. /**
  151. * fill the default value of School
  152. */
  153. public function fill()
  154. {
  155. $this->contestant_team_name = '';
  156. $this->contestant_email = '';
  157. $this->contestant_first_name = '';
  158. $this->contestant_first_address = '';
  159. $this->contestant_first_phone = '';
  160. $this->contestant_first_photo = '';
  161. $this->contestant_first_id_f = '';
  162. $this->contestant_first_id_b = '';
  163. $this->contestant_second_name = '';
  164. $this->contestant_second_address = '';
  165. $this->contestant_second_phone = '';
  166. $this->contestant_second_photo = '';
  167. $this->contestant_second_id_f = '';
  168. $this->contestant_second_id_b = '';
  169. $this->contestant_third_name = '';
  170. $this->contestant_third_address = '';
  171. $this->contestant_third_phone = '';
  172. $this->contestant_third_photo = '';
  173. $this->contestant_third_id_f = '';
  174. $this->contestant_third_id_b = '';
  175. $this->contestant_supervisor_name = '';
  176. $this->contestant_supervisor_nik = '';
  177. $this->contestant_supervisor_address = '';
  178. $this->contestant_supervisor_email = '';
  179. $this->contestant_supervisor_phone = '';
  180. $this->contestant_school_name = '';
  181. $this->contestant_school_address = '';
  182. $this->contestant_school_phone = '';
  183. $this->province = 0;
  184. }
  185. /**
  186. * Return an array contain the cde table for province's codes
  187. * @return array "province code table"
  188. */
  189. public static function get_all_province_code()
  190. {
  191. return array(
  192. 1 => 'Aceh',
  193. 2 => 'Sumatera Utara',
  194. 3 => 'Sumatera Barat',
  195. 4 => 'Riau',
  196. 5 => 'Kepulauan Riau',
  197. 6 => 'Jambi',
  198. 7 => 'Sumatera Selatan',
  199. 8 => 'Kepulauan Bangka Belitung',
  200. 9 => 'Bengkulu',
  201. 10 => 'Lampung',
  202. 11 => 'DKI Jakarta',
  203. 12 => 'Jawa Barat',
  204. 13 => 'Banten',
  205. 14 => 'Jawa Tengah',
  206. 15 => 'DI Yogyakarta',
  207. 16 => 'Jawa Timur',
  208. 17 => 'Bali',
  209. 18 => 'Nusa Tenggara Barat',
  210. 19 => 'Nusa Tenggara Timur',
  211. 20 => 'Kalimantan Barat',
  212. 21 => 'Kalimantan Tengah',
  213. 22 => 'Kalimantan Selatan',
  214. 23 => 'Kalimantan Timur, Kalimantan Utara',
  215. 24 => 'Sulawesi Utara',
  216. 25 => 'Gorontalo',
  217. 26 => 'Sulawesi Tengah',
  218. 27 => 'Sulawesi Selatan',
  219. 28 => 'Sulawesi Barat',
  220. 29 => 'Sulawesi Tenggara',
  221. 30 => 'Maluku',
  222. 31 => 'Maluku Utara',
  223. 32 => 'Papua',
  224. 33 => 'Papua Barat',
  225. );
  226. }
  227. }