function save($object = '', $related_field = '') { if (!$this->exists()) { $o = new Estatetype(); $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); }
function getTypeByCatagory() { $cateId = $this->input->post('cateId'); $type = new Estatetype(); $type->where('estatecatalogue_id', $cateId); $type->order_by('position', 'asc'); $type->get(); $option = '<option value="">Chọn Loại nhà đất</option>'; foreach ($type as $row) { if ($row->id == $this->input->post('typeSelected')) { $option .= '<option selected="selected" value=' . $row->id . '>' . $row->name . '</option>'; } else { $option .= '<option value=' . $row->id . '>' . $row->name . '</option>'; } } echo $option; die; }
function updatePosition() { $positionList = $this->input->post('positionList'); $idList = $this->input->post('idList'); $estateareas = new Estatetype(); for ($i = 0; $i < count($idList); $i++) { $estateareas->where("id", $idList[$i]); $estateareas->get(); $estateareas->position = $positionList[$i]; $estateareas->save(); $estateareas->clear(); } redirect($_SERVER['HTTP_REFERER']); }