public function save() { $record_id = $this -> input -> post('record_id'); //Check if we are in editing mode first; if so, retrieve the edited record. if not, create a new one! if (strlen($record_id) > 0) { $email = Emails::getEmail($record_id); } else { $email = new Emails(); } $div = $this -> session -> userdata('user_group'); //getting the session user group $div2 = $this -> session -> userdata('district_province_id'); if ($div == 1) { $national = "1"; $district = "0"; $provincial = "0"; } if ($div == 2) { $national = "1"; $district = "0"; $provincial = "0"; } if ($div == 3) { $national = "0"; $district = "0"; $provincial = $div2; } if ($div == 4) { $provincial = "0"; $national = "0"; $district = $div2; } $email -> email = $this -> input -> post("email"); $email -> provincial = $provincial; $email -> district = $district; $email -> national = $national; $email -> valid = "1"; $email -> stockout = $this -> input -> post("combo1"); $email -> consumption = $this -> input -> post("combo2"); $email -> coldchain = $this -> input -> post("combo3"); $email -> recepient = $this -> input -> post("rep"); $email -> number = $this -> input -> post("number"); $kenya=$country->country_code=trim($this->input->post("country_code")); $email->number=$kenya.$this->input->post("number"); $email -> save(); redirect("email_management"); }