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]); if(sizeof($grid) > 0){ $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]); if(sizeof($grid) > 0){ $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"); } } } public function deleteAct(){ if($this->isLogged()) { if (isset($_POST)) { $this->db->delete('nh_acts', ['id' => $_POST['id']]); echo json_encode(['code' => 200 ]); } } } public function createValidatingDoctor() { if($this->isLogged()) { if (isset($_POST)) { $emailExist = $this->db->get_where('nh_validating_doctors', ['email' => $_POST['email']]); if ($emailExist->num_rows() == 0) { do { $token = bin2hex(openssl_random_pseudo_bytes(16)); $tokenExist = $this->db->get_where('nh_validating_doctors',['token' => $token]); } while ($tokenExist->num_rows() > 0); $_POST['token'] = $token; $query = $this->db->insert('nh_validating_doctors', $_POST); if ($query) { $link = base_url("Doctor_password/?token=" . $token); $this->load->library('email'); $this->email->from('noreply@ilink-app.com', 'iLink World'); $this->email->to($_POST['email']); $this->email->subject($this->lang->line("mail_title_validating_doctor")); $this->email->message($_POST['firstname'] . ' ' . $_POST['lastname'] . ' ' . $this->lang->line("mail_body_validating_doctor") . ' ' . $link); $this->email->send(); echo json_encode(['code' => 200]); } else { echo json_encode(['code' => 500, 'message' => $this->lang->line("Une erreur s'est produite")]); } } else { echo json_encode(['code'=> 419 , 'message' => $this->lang->line("L'email entré est déjà utilisé")]); } } } } public function updateValidatingDoctor() { if($this->isLogged()) { if (isset($_POST)) { $emailExist = $this->db->get_where('nh_validating_doctors', ['id !=' => $_POST['id'], 'email' => $_POST['email']]); if ($emailExist->num_rows() == 0) { $this->db->where('id',$_POST['id']); $this->db->update('nh_validating_doctors',$_POST); echo json_encode(['code' => 200]); }else{ echo json_encode(['code'=> 419 , 'message' => $this->lang->line("L'email entré est déjà utilisé")]); } } } } public function deleteValidatingDoctor(){ if($this->isLogged()) { if (isset($_POST)) { $this->db->delete('nh_validating_doctors', ['id' => $_POST['id']]); echo json_encode(['code' => 200]); } } } public function storeProviderClass(){ 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_provider_classes',$_POST); }else{ $this->db->insert('nh_provider_classes',$_POST); } echo json_encode(['code' => 200 ]); } } } public function deleteProviderClass(){ if($this->isLogged()) { if (isset($_POST)) { $this->db->delete('nh_provider_classes', ['id' => $_POST['id']]); echo json_encode(['code' => 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; } }