Example #1
0
 function save($object = '', $related_field = '')
 {
     if (!$this->exists()) {
         $o = new Estatedistrict();
         $o->select_max('position');
         $o->get();
         if (count($o->all) != 0) {
             $max = $o->position + 1;
             $this->position = $max;
         } else {
             $this->postion = 1;
         }
     }
     return parent::save($object, $related_field);
 }
Example #2
0
 function getDistrict()
 {
     $provincesId = $this->input->post('provincesId');
     $districts = new Estatedistrict();
     $districts->where('estatecity_id', $provincesId);
     $districts->order_by('position', 'asc');
     $districts->get();
     $option = '<option value="">Chọn Quận/Huyện</option>';
     foreach ($districts as $row) {
         if ($row->id == $this->input->post('districtSelected')) {
             $option .= '<option selected="selected" value=' . $row->id . '>' . $row->name . '</option>';
         } else {
             $option .= '<option value=' . $row->id . '>' . $row->name . '</option>';
         }
     }
     echo $option;
     die;
 }