load->model('wallet_model'); $this->load->model('nano_health_model'); } public function updateConfigYearsPricesGrid(){ if($this->isLogged()) { if (isset($_POST)) { $configId = $_POST['config_id']; $grid = $_POST['grid'] ?? []; $this->db->delete('nh_years_prices_grid',['nh_network_config_id' => $configId]); $this->db->insert_batch('nh_years_prices_grid',$grid); echo json_encode("200"); } } } public function updateConfigMonthsPricesGrid(){ if($this->isLogged()) { if (isset($_POST)) { $configId = $_POST['config_id']; $grid = $_POST['grid'] ?? []; $this->db->delete('nh_months_prices_grid',['nh_network_config_id' => $configId]); $this->db->insert_batch('nh_months_prices_grid',$grid); echo json_encode("200"); } } } public function storeAct(){ if($this->isLogged()) { if (isset($_POST)) { $id = $_POST['id']; $_POST['nh_network_config_id'] = $_POST['config_id']; unset($_POST['config_id']); if(!empty($id)){ $this->db->where('id',$id); $this->db->update('nh_acts',$_POST); }else{ $this->db->insert('nh_acts',$_POST); } echo json_encode("200"); } } } private function isLogged() { if (!$this->session->userdata('email')) { $this->session->set_flashdata('error', 'log in first'); $data['alert'] = "ok"; $data['message'] = "Login first!"; $this->load->view('login', $data); return false; } return true; } }