From 67cc24548af6f16afc7d79d281f965d0aacd1344 Mon Sep 17 00:00:00 2001 From: DJERY-TOM Date: Tue, 17 Mar 2020 19:17:35 +0100 Subject: [PATCH] Fix error on listadmin --- application/controllers/Admin.php | 1088 +++++++++---------- application/controllers/Users.php | 568 +++++----- application/views/listeadmin.php | 1678 ++++++++++++++--------------- 3 files changed, 1667 insertions(+), 1667 deletions(-) diff --git a/application/controllers/Admin.php b/application/controllers/Admin.php index 0dafba54..9fc9ef1b 100644 --- a/application/controllers/Admin.php +++ b/application/controllers/Admin.php @@ -1,544 +1,544 @@ -load->model('user_model'); - - - } - - public function index() - { - - 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); - } else { - $this->load->view('admin_vue'); - } - } - - public function add() - { - if ($this->input->post('ad')) { - $nom = $this->input->post('nm'); - $phon = $this->input->post('password'); - - $data = array( - 'nom' => $nom, 'password' => MD5($phon), - ); - - $query = $this->db->insert('admintable', $data); - if ($query) { - echo "Ajout Reussie!"; - redirect('Admin'); - } else { - echo "Echec "; - redirect('Admin'); - } - } else { - echo "error db"; - redirect('Admin'); - } - } - - public function getAllUser_g(){ - @ini_set('display_errors', 'on'); - - if (!$this->session->userdata('email')) { - $this->session->set_flashdata('error', 'log in first'); - - $data['alert'] = "ok"; - $data['message'] = "Login first!"; - - - redirect('index.php', $data); - } - else { - - $ville = $this->session->userdata('current_ville'); - $hyper = $this->session->userdata('current_hyper'); - $pays = $this->session->userdata('current_pays'); - - $data['pays'] = $this->user_model->getAllCountries(); - $data['hyper'] = $this->user_model->getAllHyper($data['pays']->first_row()->id); - $data['ville'] = $this->user_model->getVilleNetworkByHyper($data['hyper']->first_row()->code_membre); - - $query = $this->user_model->getGeolocatedUsersForAdmin($pays,$hyper,$ville); - - - $position_hyper = $this->user_model->getPositionHyper($hyper); - - $data['positions'] = $this->user_model->adminGetAllpositions($pays,$hyper,$ville); - $data['active'] = "members"; - $data['map_title'] = $this->lang->line('Utilisateurs géolocalisés'); - $data['tab'] = $query; - $data['latitude'] = $position_hyper->first_row()->latitude; - $data['longitude'] = $position_hyper->first_row()->longitude; - $data['token'] = $this->session->userdata('token'); - $data['email'] = $this->session->userdata('email'); - $data['firstname'] = $this->session->userdata('firstname'); - $data['lastname'] = $this->session->userdata('lastname'); - $data['code_parrain'] = $this->session->userdata('code_parrain'); - $data['phone'] = $this->session->userdata('phone'); - $data['adresse'] = $this->session->userdata('adresse'); - $data['category'] = $this->session->userdata('category'); - $data['network'] = $this->session->userdata('network'); - $data['pays'] = $this->user_model->getAllCountries(); - $data['alert'] = ""; - $this->load->view('header', $data); - $this->load->view('listeadmin'); - $this->load->view('footer'); - } - - } - - public function getAllDemandes(){ - - 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); - } else { - - $ville = $this->session->userdata('current_ville'); - $hyper = $this->session->userdata('current_hyper'); - $pays = $this->session->userdata('current_pays'); - $name_ville = $this->db->query("SELECT name FROM towns WHERE id=".$ville)->first_row()->name; - $name_pays = $this->db->query("SELECT name FROM countries WHERE id=".$pays)->first_row()->name; - - $data['pays'] = $this->user_model->getAllCountries(); - $data['hyper'] = $this->user_model->getAllHyper($data['pays']->first_row()->id); - $data['ville'] = $this->user_model->getVilleNetworkByHyper($data['hyper']->first_row()->code_membre); - - $network = 'all'; - $data['active'] = "demandes"; - $data['type'] = 'crédits'; - $data['alert'] = ""; - $data['token'] = $this->session->userdata('token'); - $data['email'] = $this->session->userdata('email'); - $data['firstname'] = $this->session->userdata('firstname'); - $data['lastname'] = $this->session->userdata('lastname'); - $data['code_parrain'] = $this->session->userdata('code_parrain'); - $data['phone'] = $this->session->userdata('phone'); - $data['adresse'] = $this->session->userdata('adresse'); - $data['category'] = $this->session->userdata('category'); - $data['network'] = $this->session->userdata('network'); - $data['list'] = $this->user_model->adminGetDemandes($pays,$hyper,$name_ville); - $data['tab_fastDemande'] = $this->user_model->adminGetRangeASCDemandes($name_pays,$hyper,$name_ville); - $data['tab_slowDemande'] = $this->user_model->adminGetRangeDESCDemandes($name_pays,$hyper,$name_ville); - $data['temp_moyen'] = $this->user_model->adminGetTempsMoyen($name_pays,$hyper,$name_ville); - $data['pays'] = $this->user_model->getAllCountries(); - $this->load->view('header', $data); - $this->load->view('demande'); - $this->load->view('footer'); - } - } - - public function getHypByPays(){ - - if (!$this->session->userdata('email')) { - $this->session->set_flashdata('error', 'log in first'); - - $data['alert'] = "ok"; - $data['message'] = "Login first!"; - - - redirect('index.php', $data); - } - else { - - if($this->input->is_ajax_request()) - { - $ajaxhyp = $this->user_model->getAllHyper($this->input->post('pays')); - echo json_encode($ajaxhyp->result_array()); - } - - } - } - - public function getVilleByHyp(){ - - if (!$this->session->userdata('email')) { - $this->session->set_flashdata('error', 'log in first'); - - $data['alert'] = "ok"; - $data['message'] = "Login first!"; - - - redirect('index.php', $data); - } - else { - - if($this->input->is_ajax_request()) - { - $ajaxhyp = $this->user_model->getVilleNetworkByHyper($this->input->post('code')); - echo json_encode($ajaxhyp->result_array()); - } - - } - } - - public function filtreData(){ - - 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); - } else { - - if(isset($_POST)) - { - - $this->session->set_userdata('current_pays', $this->input->post('pays')); - $this->session->set_userdata('current_hyper', $this->input->post('hyper')); - $this->session->set_userdata('current_ville', $this->input->post('ville')); - - $pays_name = $this->db->query("SELECT name FROM countries WHERE id='".$this->input->post('pays')."'"); - $town_name = $this->db->query("SELECT name FROM towns WHERE id='".$this->input->post('ville')."'"); - - $infos_network = $this->db->query("SELECT name,phone FROM networks INNER JOIN networks_agents ON networks.id=networks_agents.network_id INNER JOIN codeGenerer ON networks_agents.codeGenerer_id=codeGenerer.id WHERE codeGenerer.code_membre='".$this->input->post('hyper')."'"); - $network = $infos_network->first_row()->name; - $contact_hyper = $infos_network->first_row()->phone; - $this->session->set_userdata('current_network', $network); - $this->session->set_userdata('current_contact_hyper', $contact_hyper); - - $this->session->set_userdata('name_current_pays',$pays_name->first_row()->name); - $this->session->set_userdata('name_current_ville',$town_name->first_row()->name); - - redirect('index.php/Admin_dash/index'); - } - } - } - - public function deleteUser(){ - - 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); - } else { - - if(isset($_POST)) - { - $code = $this->input->post('code'); - $cat = $this->input->post('cat'); - $id = $this->user_model->getIdAgentByMemberCode($code,$cat); - - if($id!=false){ - $delete_infos_agents = $this->user_model->deleteInfosGeolocatedUser($id); - if($delete_infos_agents){ - $delete_code = $this->user_model->deleteCodeAgent($code); - if($delete_code){ - echo json_encode("completed"); - }else{ - echo json_encode("Une erreur s'est produite à la mise à jour du numéro de téléphone"); - } - }else{ - echo json_encode("Une erreur s'est produite lors de la mise à jour des informations"); - } - }else{ - echo json_encode("Une erreur identifiant agent"); - } - - - - if($res){ - echo json_encode("completed"); - }else{ - echo json_encode("Une erreur s'est produite"); - } - } - } - } - - public function updateUser(){ - - 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); - } else { - - if(isset($_POST)) - { - $code = $this->input->post('code'); - $cat = $this->input->post('cat'); - $adresse = $this->input->post('adresse'); - $lastname = $this->input->post('nom'); - $email = $this->input->post('email'); - $phone = $this->input->post('contact'); - - $id = $this->user_model->getIdAgentByMemberCode($code,$cat); - - if($id!=false){ - $update_info = $this->user_model->updateGeolocatedUser($id,$adresse,$lastname,$email); - if($update_info){ - $res = $this->user_model->updatePhoneAgent($id,$phone); - if($res){ - echo json_encode("completed"); - }else{ - echo json_encode("Une erreur s'est produite à la mise à jour du numéro de téléphone"); - } - }else{ - echo json_encode("Une erreur s'est produite lors de la mise à jour des informations"); - } - }else{ - echo json_encode("Une erreur identifiant agent"); - } - } - } - } - - public function getGeolocatedUsersForAdministrator(){ - $ville = $this->session->userdata('current_ville'); - $hyper = $this->session->userdata('current_hyper'); - $pays = $this->session->userdata('current_pays'); - - $data['pays'] = $this->user_model->getAllCountries(); - $data['hyper'] = $this->user_model->getAllHyper($data['pays']->first_row()->id); - $data['ville'] = $this->user_model->getVilleNetworkByHyper($data['hyper']->first_row()->code_membre); - - $query = $this->user_model->getGeolocatedUsersForAdmin($pays,$hyper,$ville)->result(); - - echo json_encode($query); - } - - public function pagination_User_g(){ - - // @ini_set('display_errors', 'on'); - - if (!$this->session->userdata('email')) { - $this->session->set_flashdata('error', 'log in first'); - - $data['alert'] = "ok"; - $data['message'] = "Login first!"; - - - redirect('index.php', $data); - } - else { - - $ville = $this->session->userdata('current_ville'); - $hyper = $this->session->userdata('current_hyper'); - $pays = $this->session->userdata('current_pays'); - - $data['pays'] = $this->user_model->getAllCountries(); - $data['hyper'] = $this->user_model->getAllHyper($data['pays']->first_row()->id); - $data['ville'] = $this->user_model->getVilleNetworkByHyper($data['hyper']->first_row()->code_membre); - - $query = $this->user_model->getGeolocatedUsersForAdmin($pays,$hyper,$ville); - - - $position_hyper = $this->user_model->getPositionHyper($hyper); - - - $data['active'] = "members"; - $data['positions'] = $this->user_model->adminGetAllpositions($pays,$hyper,$ville); - $data['map_title'] = $this->lang->line('Utilisateurs géolocalisés'); - $data['tab'] = $query; - $data['latitude'] = $position_hyper->first_row()->latitude; - $data['longitude'] = $position_hyper->first_row()->longitude; - $data['token'] = $this->session->userdata('token'); - $data['email'] = $this->session->userdata('email'); - $data['firstname'] = $this->session->userdata('firstname'); - $data['lastname'] = $this->session->userdata('lastname'); - $data['code_parrain'] = $this->session->userdata('code_parrain'); - $data['phone'] = $this->session->userdata('phone'); - $data['adresse'] = $this->session->userdata('adresse'); - $data['category'] = $this->session->userdata('category'); - $data['network'] = $this->session->userdata('network'); - $data['pays'] = $this->user_model->getAllCountries(); - $data['alert'] = ""; - - // init params - $limit_per_page = 10; - $start_index = ($this->uri->segment(3)) ? $this->uri->segment(3) : 0; - $total_records = $this->user_model->get_total($pays,$hyper,$ville); - - if ($total_records > 0) - { - // get current page records - $data["tab"] = $this->user_model->get_current_page_records($limit_per_page, $start_index,$pays,$hyper,$ville); - //$data['positions'] = $this->user_model->get_current_page_records_positions($limit_per_page, $start_index,$pays,$hyper,$ville); - $config['base_url'] = base_url() . 'index.php/Admin/pagination_User_g'; - $config['total_rows'] = $total_records; - $config['per_page'] = $limit_per_page; - $config["uri_segment"] = 3; - - $this->load->library('pagination'); - $this->pagination->initialize($config); - - // build paging links - $data["links"] = $this->pagination->create_links(); - } - - $this->load->view('header', $data); - $this->load->view('listeadmin'); - $this->load->view('footer'); - } - - } - - public function get_progress_data(){ - @ini_set('display_errors', 'on'); - - if (!$this->session->userdata('email')) { - $this->session->set_flashdata('error', 'log in first'); - - $data['alert'] = "ok"; - $data['message'] = "Login first!"; - - - redirect('index.php', $data); - } - else { - - $ville = $this->session->userdata('current_ville'); - $hyper = $this->session->userdata('current_hyper'); - $pays = $this->session->userdata('current_pays'); - - $data['pays'] = $this->user_model->getAllCountries(); - $data['hyper'] = $this->user_model->getAllHyper($data['pays']->first_row()->id); - $data['ville'] = $this->user_model->getVilleNetworkByHyper($data['hyper']->first_row()->code_membre); - - //$query = $this->user_model->getGeolocatedUsersForAdmin($pays,$hyper,$ville); - - $total_records = $this->user_model->get_total($pays,$hyper,$ville); - $data['tab'][] = null; - $i = 0; - $start_index = 0; - $limit_per_page = 100; - while($i<=$total_records){ - $datas = $this->user_model->get_current_page_records($limit_per_page, $start_index,$pays,$hyper,$ville); - if($i==0){ - $data['tab'][] = $datas; - }else{ - $data['tab'][] = $datas; - } - $i = $i+$limit_per_page; - } - echo gettype($data['tab']->result()); - $position_hyper = $this->user_model->getPositionHyper($hyper); - - $data['positions'] = $this->user_model->adminGetAllpositions($pays,$hyper,$ville); - $data['active'] = "members"; - $data['map_title'] = $this->lang->line('Utilisateurs géolocalisés'); - //$data['tab'] = $query; - $data['latitude'] = $position_hyper->first_row()->latitude; - $data['longitude'] = $position_hyper->first_row()->longitude; - $data['token'] = $this->session->userdata('token'); - $data['email'] = $this->session->userdata('email'); - $data['firstname'] = $this->session->userdata('firstname'); - $data['lastname'] = $this->session->userdata('lastname'); - $data['code_parrain'] = $this->session->userdata('code_parrain'); - $data['phone'] = $this->session->userdata('phone'); - $data['adresse'] = $this->session->userdata('adresse'); - $data['category'] = $this->session->userdata('category'); - $data['network'] = $this->session->userdata('network'); - $data['pays'] = $this->user_model->getAllCountries(); - $data['alert'] = ""; - $this->load->view('header', $data); - $this->load->view('listeadmin'); - $this->load->view('footer'); - } - } - - public function initGetAllUser_g(){ - @ini_set('display_errors', 'on'); - - if (!$this->session->userdata('email')) { - $this->session->set_flashdata('error', 'log in first'); - - $data['alert'] = "ok"; - $data['message'] = "Login first!"; - - - redirect('index.php', $data); - } - else { - - $ville = $this->session->userdata('current_ville'); - $hyper = $this->session->userdata('current_hyper'); - $pays = $this->session->userdata('current_pays'); - - $data['pays'] = $this->user_model->getAllCountries(); - $data['hyper'] = $this->user_model->getAllHyper($data['pays']->first_row()->id); - $data['ville'] = $this->user_model->getVilleNetworkByHyper($data['hyper']->first_row()->code_membre); - - $query = $this->user_model->getGeolocatedUsersForAdmin($pays,$hyper,$ville); - $data['total_points'] = $this->user_model->getCoutGeolocatedUsersForAdmin($pays,$hyper,$ville); - - $position_hyper = $this->user_model->getPositionHyper($hyper); - - $data['positions'] = $this->user_model->adminGetAllpositions($pays,$hyper,$ville); - $data['active'] = "members"; - $data['map_title'] = $this->lang->line('Utilisateurs géolocalisés'); - $data['tab'] = $query; - $data['latitude'] = $position_hyper->first_row()->latitude; - $data['longitude'] = $position_hyper->first_row()->longitude; - $data['token'] = $this->session->userdata('token'); - $data['email'] = $this->session->userdata('email'); - $data['firstname'] = $this->session->userdata('firstname'); - $data['lastname'] = $this->session->userdata('lastname'); - $data['code_parrain'] = $this->session->userdata('code_parrain'); - $data['phone'] = $this->session->userdata('phone'); - $data['adresse'] = $this->session->userdata('adresse'); - $data['category'] = $this->session->userdata('category'); - $data['network'] = $this->session->userdata('network'); - $data['pays'] = $this->user_model->getAllCountries(); - $data['alert'] = ""; - $this->load->view('header', $data); - $this->load->view('listeadmin'); - $this->load->view('footer'); - } - - } - - public function progressRequestUser_g(){ - - if(!empty($_POST)) - { - - if($this->session->userdata('category')=='1' or $this->session->userdata('category')=='0'){ - - $ville = $this->session->userdata('current_ville'); - $hyper = $this->session->userdata('current_hyper'); - $pays = $this->session->userdata('current_pays'); - $query = $this->user_model->get_current_page_records(200,$this->input->post('start_at'),$pays,$hyper,$ville); - }elseif ($this->session->userdata('category')=='super') { - - $super = $this->session->userdata('member_code'); - $query = $this->user_model->get_current_page_records_super(200,$this->input->post('start_at'),$super); - }elseif ($this->session->userdata('category')=='hyper'){ - - $ville = $this->session->userdata('current_ville'); - $hyper = $this->session->userdata('member_code'); - $query = $this->user_model->get_current_page_records_hyper(200,$this->input->post('start_at'),$hyper,$ville); - } - echo json_encode($query->result()); - }else{ - echo json_encode('null'); - } - - } - -} +load->model('user_model'); + + + } + + public function index() + { + + 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); + } else { + $this->load->view('admin_vue'); + } + } + + public function add() + { + if ($this->input->post('ad')) { + $nom = $this->input->post('nm'); + $phon = $this->input->post('password'); + + $data = array( + 'nom' => $nom, 'password' => MD5($phon), + ); + + $query = $this->db->insert('admintable', $data); + if ($query) { + echo "Ajout Reussie!"; + redirect('Admin'); + } else { + echo "Echec "; + redirect('Admin'); + } + } else { + echo "error db"; + redirect('Admin'); + } + } + + public function getAllUser_g(){ + @ini_set('display_errors', 'on'); + + if (!$this->session->userdata('email')) { + $this->session->set_flashdata('error', 'log in first'); + + $data['alert'] = "ok"; + $data['message'] = "Login first!"; + + + redirect('index.php', $data); + } + else { + + $ville = $this->session->userdata('current_ville'); + $hyper = $this->session->userdata('current_hyper'); + $pays = $this->session->userdata('current_pays'); + + $data['pays'] = $this->user_model->getAllCountries(); + $data['hyper'] = $this->user_model->getAllHyper($data['pays']->first_row()->id); + $data['ville'] = $this->user_model->getVilleNetworkByHyper($data['hyper']->first_row()->code_membre); + + $query = $this->user_model->getGeolocatedUsersForAdmin($pays,$hyper,$ville); + + + $position_hyper = $this->user_model->getPositionHyper($hyper); + + $data['positions'] = $this->user_model->adminGetAllpositions($pays,$hyper,$ville); + $data['active'] = "members"; + $data['map_title'] = $this->lang->line('Utilisateurs géolocalisés'); + $data['tab'] = $query; + $data['latitude'] = $position_hyper->first_row()->latitude; + $data['longitude'] = $position_hyper->first_row()->longitude; + $data['token'] = $this->session->userdata('token'); + $data['email'] = $this->session->userdata('email'); + $data['firstname'] = $this->session->userdata('firstname'); + $data['lastname'] = $this->session->userdata('lastname'); + $data['code_parrain'] = $this->session->userdata('code_parrain'); + $data['phone'] = $this->session->userdata('phone'); + $data['adresse'] = $this->session->userdata('adresse'); + $data['category'] = $this->session->userdata('category'); + $data['network'] = $this->session->userdata('network'); + $data['pays'] = $this->user_model->getAllCountries(); + $data['alert'] = ""; + $this->load->view('header', $data); + $this->load->view('listeadmin'); + $this->load->view('footer'); + } + + } + + public function getAllDemandes(){ + + 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); + } else { + + $ville = $this->session->userdata('current_ville'); + $hyper = $this->session->userdata('current_hyper'); + $pays = $this->session->userdata('current_pays'); + $name_ville = $this->db->query("SELECT name FROM towns WHERE id=".$ville)->first_row()->name; + $name_pays = $this->db->query("SELECT name FROM countries WHERE id=".$pays)->first_row()->name; + + $data['pays'] = $this->user_model->getAllCountries(); + $data['hyper'] = $this->user_model->getAllHyper($data['pays']->first_row()->id); + $data['ville'] = $this->user_model->getVilleNetworkByHyper($data['hyper']->first_row()->code_membre); + + $network = 'all'; + $data['active'] = "demandes"; + $data['type'] = 'crédits'; + $data['alert'] = ""; + $data['token'] = $this->session->userdata('token'); + $data['email'] = $this->session->userdata('email'); + $data['firstname'] = $this->session->userdata('firstname'); + $data['lastname'] = $this->session->userdata('lastname'); + $data['code_parrain'] = $this->session->userdata('code_parrain'); + $data['phone'] = $this->session->userdata('phone'); + $data['adresse'] = $this->session->userdata('adresse'); + $data['category'] = $this->session->userdata('category'); + $data['network'] = $this->session->userdata('network'); + $data['list'] = $this->user_model->adminGetDemandes($pays,$hyper,$name_ville); + $data['tab_fastDemande'] = $this->user_model->adminGetRangeASCDemandes($name_pays,$hyper,$name_ville); + $data['tab_slowDemande'] = $this->user_model->adminGetRangeDESCDemandes($name_pays,$hyper,$name_ville); + $data['temp_moyen'] = $this->user_model->adminGetTempsMoyen($name_pays,$hyper,$name_ville); + $data['pays'] = $this->user_model->getAllCountries(); + $this->load->view('header', $data); + $this->load->view('demande'); + $this->load->view('footer'); + } + } + + public function getHypByPays(){ + + if (!$this->session->userdata('email')) { + $this->session->set_flashdata('error', 'log in first'); + + $data['alert'] = "ok"; + $data['message'] = "Login first!"; + + + redirect('index.php', $data); + } + else { + + if($this->input->is_ajax_request()) + { + $ajaxhyp = $this->user_model->getAllHyper($this->input->post('pays')); + echo json_encode($ajaxhyp->result_array()); + } + + } + } + + public function getVilleByHyp(){ + + if (!$this->session->userdata('email')) { + $this->session->set_flashdata('error', 'log in first'); + + $data['alert'] = "ok"; + $data['message'] = "Login first!"; + + + redirect('index.php', $data); + } + else { + + if($this->input->is_ajax_request()) + { + $ajaxhyp = $this->user_model->getVilleNetworkByHyper($this->input->post('code')); + echo json_encode($ajaxhyp->result_array()); + } + + } + } + + public function filtreData(){ + + 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); + } else { + + if(isset($_POST)) + { + + $this->session->set_userdata('current_pays', $this->input->post('pays')); + $this->session->set_userdata('current_hyper', $this->input->post('hyper')); + $this->session->set_userdata('current_ville', $this->input->post('ville')); + + $pays_name = $this->db->query("SELECT name FROM countries WHERE id='".$this->input->post('pays')."'"); + $town_name = $this->db->query("SELECT name FROM towns WHERE id='".$this->input->post('ville')."'"); + + $infos_network = $this->db->query("SELECT name,phone FROM networks INNER JOIN networks_agents ON networks.id=networks_agents.network_id INNER JOIN codeGenerer ON networks_agents.codeGenerer_id=codeGenerer.id WHERE codeGenerer.code_membre='".$this->input->post('hyper')."'"); + $network = $infos_network->first_row()->name; + $contact_hyper = $infos_network->first_row()->phone; + $this->session->set_userdata('current_network', $network); + $this->session->set_userdata('current_contact_hyper', $contact_hyper); + + $this->session->set_userdata('name_current_pays',$pays_name->first_row()->name); + $this->session->set_userdata('name_current_ville',$town_name->first_row()->name); + + redirect('index.php/Admin_dash/index'); + } + } + } + + public function deleteUser(){ + + 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); + } else { + + if(isset($_POST)) + { + $code = $this->input->post('code'); + $cat = $this->input->post('cat'); + $id = $this->user_model->getIdAgentByMemberCode($code,$cat); + + if($id!=false){ + $delete_infos_agents = $this->user_model->deleteInfosGeolocatedUser($id); + if($delete_infos_agents){ + $delete_code = $this->user_model->deleteCodeAgent($code); + if($delete_code){ + echo json_encode("completed"); + }else{ + echo json_encode("Une erreur s'est produite à la mise à jour du numéro de téléphone"); + } + }else{ + echo json_encode("Une erreur s'est produite lors de la mise à jour des informations"); + } + }else{ + echo json_encode("Une erreur identifiant agent"); + } + + + + if($res){ + echo json_encode("completed"); + }else{ + echo json_encode("Une erreur s'est produite"); + } + } + } + } + + public function updateUser(){ + + 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); + } else { + + if(isset($_POST)) + { + $code = $this->input->post('code'); + $cat = $this->input->post('cat'); + $adresse = $this->input->post('adresse'); + $lastname = $this->input->post('nom'); + $email = $this->input->post('email'); + $phone = $this->input->post('contact'); + + $id = $this->user_model->getIdAgentByMemberCode($code,$cat); + + if($id!=false){ + $update_info = $this->user_model->updateGeolocatedUser($id,$adresse,$lastname,$email); + if($update_info){ + $res = $this->user_model->updatePhoneAgent($id,$phone); + if($res){ + echo json_encode("completed"); + }else{ + echo json_encode("Une erreur s'est produite à la mise à jour du numéro de téléphone"); + } + }else{ + echo json_encode("Une erreur s'est produite lors de la mise à jour des informations"); + } + }else{ + echo json_encode("Une erreur identifiant agent"); + } + } + } + } + + public function getGeolocatedUsersForAdministrator(){ + $ville = $this->session->userdata('current_ville'); + $hyper = $this->session->userdata('current_hyper'); + $pays = $this->session->userdata('current_pays'); + + $data['pays'] = $this->user_model->getAllCountries(); + $data['hyper'] = $this->user_model->getAllHyper($data['pays']->first_row()->id); + $data['ville'] = $this->user_model->getVilleNetworkByHyper($data['hyper']->first_row()->code_membre); + + $query = $this->user_model->getGeolocatedUsersForAdmin($pays,$hyper,$ville)->result(); + + echo json_encode($query); + } + + public function pagination_User_g(){ + + // @ini_set('display_errors', 'on'); + + if (!$this->session->userdata('email')) { + $this->session->set_flashdata('error', 'log in first'); + + $data['alert'] = "ok"; + $data['message'] = "Login first!"; + + + redirect('index.php', $data); + } + else { + + $ville = $this->session->userdata('current_ville'); + $hyper = $this->session->userdata('current_hyper'); + $pays = $this->session->userdata('current_pays'); + + $data['pays'] = $this->user_model->getAllCountries(); + $data['hyper'] = $this->user_model->getAllHyper($data['pays']->first_row()->id); + $data['ville'] = $this->user_model->getVilleNetworkByHyper($data['hyper']->first_row()->code_membre); + + $query = $this->user_model->getGeolocatedUsersForAdmin($pays,$hyper,$ville); + + + $position_hyper = $this->user_model->getPositionHyper($hyper); + + + $data['active'] = "members"; + $data['positions'] = $this->user_model->adminGetAllpositions($pays,$hyper,$ville); + $data['map_title'] = $this->lang->line('Utilisateurs géolocalisés'); + $data['tab'] = $query; + $data['latitude'] = $position_hyper->first_row()->latitude; + $data['longitude'] = $position_hyper->first_row()->longitude; + $data['token'] = $this->session->userdata('token'); + $data['email'] = $this->session->userdata('email'); + $data['firstname'] = $this->session->userdata('firstname'); + $data['lastname'] = $this->session->userdata('lastname'); + $data['code_parrain'] = $this->session->userdata('code_parrain'); + $data['phone'] = $this->session->userdata('phone'); + $data['adresse'] = $this->session->userdata('adresse'); + $data['category'] = $this->session->userdata('category'); + $data['network'] = $this->session->userdata('network'); + $data['pays'] = $this->user_model->getAllCountries(); + $data['alert'] = ""; + + // init params + $limit_per_page = 10; + $start_index = ($this->uri->segment(3)) ? $this->uri->segment(3) : 0; + $total_records = $this->user_model->get_total($pays,$hyper,$ville); + + if ($total_records > 0) + { + // get current page records + $data["tab"] = $this->user_model->get_current_page_records($limit_per_page, $start_index,$pays,$hyper,$ville); + //$data['positions'] = $this->user_model->get_current_page_records_positions($limit_per_page, $start_index,$pays,$hyper,$ville); + $config['base_url'] = base_url() . 'index.php/Admin/pagination_User_g'; + $config['total_rows'] = $total_records; + $config['per_page'] = $limit_per_page; + $config["uri_segment"] = 3; + + $this->load->library('pagination'); + $this->pagination->initialize($config); + + // build paging links + $data["links"] = $this->pagination->create_links(); + } + + $this->load->view('header', $data); + $this->load->view('listeadmin'); + $this->load->view('footer'); + } + + } + + public function get_progress_data(){ + @ini_set('display_errors', 'on'); + + if (!$this->session->userdata('email')) { + $this->session->set_flashdata('error', 'log in first'); + + $data['alert'] = "ok"; + $data['message'] = "Login first!"; + + + redirect('index.php', $data); + } + else { + + $ville = $this->session->userdata('current_ville'); + $hyper = $this->session->userdata('current_hyper'); + $pays = $this->session->userdata('current_pays'); + + $data['pays'] = $this->user_model->getAllCountries(); + $data['hyper'] = $this->user_model->getAllHyper($data['pays']->first_row()->id); + $data['ville'] = $this->user_model->getVilleNetworkByHyper($data['hyper']->first_row()->code_membre); + + //$query = $this->user_model->getGeolocatedUsersForAdmin($pays,$hyper,$ville); + + $total_records = $this->user_model->get_total($pays,$hyper,$ville); + $data['tab'][] = null; + $i = 0; + $start_index = 0; + $limit_per_page = 100; + while($i<=$total_records){ + $datas = $this->user_model->get_current_page_records($limit_per_page, $start_index,$pays,$hyper,$ville); + if($i==0){ + $data['tab'][] = $datas; + }else{ + $data['tab'][] = $datas; + } + $i = $i+$limit_per_page; + } + echo gettype($data['tab']->result()); + $position_hyper = $this->user_model->getPositionHyper($hyper); + + $data['positions'] = $this->user_model->adminGetAllpositions($pays,$hyper,$ville); + $data['active'] = "members"; + $data['map_title'] = $this->lang->line('Utilisateurs géolocalisés'); + //$data['tab'] = $query; + $data['latitude'] = $position_hyper->first_row()->latitude; + $data['longitude'] = $position_hyper->first_row()->longitude; + $data['token'] = $this->session->userdata('token'); + $data['email'] = $this->session->userdata('email'); + $data['firstname'] = $this->session->userdata('firstname'); + $data['lastname'] = $this->session->userdata('lastname'); + $data['code_parrain'] = $this->session->userdata('code_parrain'); + $data['phone'] = $this->session->userdata('phone'); + $data['adresse'] = $this->session->userdata('adresse'); + $data['category'] = $this->session->userdata('category'); + $data['network'] = $this->session->userdata('network'); + $data['pays'] = $this->user_model->getAllCountries(); + $data['alert'] = ""; + $this->load->view('header', $data); + $this->load->view('listeadmin'); + $this->load->view('footer'); + } + } + + public function initGetAllUser_g(){ + @ini_set('display_errors', 'on'); + + if (!$this->session->userdata('email')) { + $this->session->set_flashdata('error', 'log in first'); + + $data['alert'] = "ok"; + $data['message'] = "Login first!"; + + + redirect('index.php', $data); + } + else { + + $ville = $this->session->userdata('current_ville'); + $hyper = $this->session->userdata('current_hyper'); + $pays = $this->session->userdata('current_pays'); + + $data['pays'] = $this->user_model->getAllCountries(); + $data['hyper'] = $this->user_model->getAllHyper($data['pays']->first_row()->id); + $data['ville'] = $this->user_model->getVilleNetworkByHyper($data['hyper']->first_row()->code_membre); + + $query = $this->user_model->getGeolocatedUsersForAdmin($pays,$hyper,$ville); + $data['total_points'] = $this->user_model->getCoutGeolocatedUsersForAdmin($pays,$hyper,$ville); + + $position_hyper = $this->user_model->getPositionHyper($hyper); + + $data['positions'] = $this->user_model->adminGetAllpositions($pays,$hyper,$ville); + $data['active'] = "members"; + $data['map_title'] = $this->lang->line('Utilisateurs géolocalisés'); + $data['tab'] = $query; + $data['latitude'] = $position_hyper->first_row()->latitude; + $data['longitude'] = $position_hyper->first_row()->longitude; + $data['token'] = $this->session->userdata('token'); + $data['email'] = $this->session->userdata('email'); + $data['firstname'] = $this->session->userdata('firstname'); + $data['lastname'] = $this->session->userdata('lastname'); + $data['code_parrain'] = $this->session->userdata('code_parrain'); + $data['phone'] = $this->session->userdata('phone'); + $data['adresse'] = $this->session->userdata('adresse'); + $data['category'] = $this->session->userdata('category'); + $data['network'] = $this->session->userdata('network'); + $data['pays'] = $this->user_model->getAllCountries(); + $data['alert'] = ""; + $this->load->view('header', $data); + $this->load->view('listeadmin'); + $this->load->view('footer'); + } + + } + + public function progressRequestUser_g(){ + + if(!empty($_POST)) + { + + if($this->session->userdata('category')=='1' or $this->session->userdata('category')=='0'){ + + $ville = $this->session->userdata('current_ville'); + $hyper = $this->session->userdata('current_hyper'); + $pays = $this->session->userdata('current_pays'); + $query = $this->user_model->get_current_page_records(200,$this->input->post('start_at'),$pays,$hyper,$ville); + }elseif ($this->session->userdata('category')=='super') { + + $super = $this->session->userdata('member_code'); + $query = $this->user_model->get_current_page_records_super(200,$this->input->post('start_at'),$super); + }elseif ($this->session->userdata('category')=='hyper'){ + + $ville = $this->session->userdata('current_ville'); + $hyper = $this->session->userdata('member_code'); + $query = $this->user_model->get_current_page_records_hyper(200,$this->input->post('start_at'),$hyper,$ville); + } + echo json_encode($query->result()); + }else{ + echo json_encode('null'); + } + + } + +} diff --git a/application/controllers/Users.php b/application/controllers/Users.php index 4ef8cada..941877d1 100644 --- a/application/controllers/Users.php +++ b/application/controllers/Users.php @@ -1,284 +1,284 @@ -load->model('user_model'); - } - - public function index() - { - - if (!$this->session->userdata('token')) { - - $this->session->set_flashdata('error', 'log in first'); - $data['alert'] = ''; - $this->load->view('login', $data); - - } else { - - $hyper = "hyper"; - $super = "super"; - $admin = "admin"; - - if ($this->session->userdata('category') == 0 or $this->session->userdata('category') == 1) { - - $data['active'] = "dash"; - $data['firstname'] = $this->session->userdata('firstname'); - $data['lastname'] = $this->session->userdata('lastname'); - $data['email'] = $this->session->userdata('email'); - $this->load->view('header', $data); - $this->load->view('admin_dash'); - $this->load->view('footer'); - - } else if ($this->session->userdata('category') == $hyper) { - - $data['active'] = "dash"; - $data['token'] = $this->session->userdata('token'); - $data['email'] = $this->session->userdata('email'); - $data['firstname'] = $this->session->userdata('firstname'); - $data['lastname'] = $this->session->userdata('lastname'); - $data['member_code'] = $this->session->userdata('member_code'); - $data['phone'] = $this->session->userdata('phone'); - $data['adresse'] = $this->session->userdata('adresse'); - $data['category'] = $this->session->userdata('category'); - $data['network'] = $this->session->userdata('network'); - $data['network_id'] = - $data['villes'] = $this->user_model->getVilleByUserGeo($data['network']); - $data['count_geo'] = $this->user_model->countUser("geolocated",$this->session->userdata('network')); - $data['count_sup'] = $this->user_model->countUser("super",$this->session->userdata('network')); - $this->load->view('header_hyp', $data); - $this->load->view('hyperviseur_dash'); - $this->load->view('footer'); - - } else if ($this->session->userdata('category') == $super) { - - $data['active'] = "dash"; - $this->load->view('header_sup', $data); - $this->load->view('superviseur_dash'); - $this->load->view('footer'); - } - - - } - - } - - public function login() - { - $user_login = array( - 'user_email' => $this->input->post('user_mail'), - 'user_password' => $this->input->post('user_password'), - 'user_role' => $this->input->post('user_role') - ); - - $data = $this->user_model->login_user($user_login['user_email'], $user_login['user_password'], $user_login['user_role']); - - if ($data) { - - $hyper = "hyper"; - $super = "super"; - - $this->session->set_userdata('token', $data->token); - $this->session->set_userdata('email', $data->email); - $this->session->set_userdata('firstname', $data->firstname); - $this->session->set_userdata('lastname', $data->lastname); - $this->session->set_userdata('adresse', $data->adresse); - - if($user_login['user_role']==1){ - $this->session->set_userdata('country', $data->country); - - $pays = $this->user_model->getAllCountries(); - $this->session->set_userdata('current_pays', $pays->first_row()->name); - - $hyper = $this->user_model->getAllHyper($this->session->userdata('current_pays')); - $this->session->set_userdata('current_hyper', $hyper->first_row()->code_membre); - - $ville = $this->user_model->getVilleNetworkByHyper($this->session->userdata('current_hyper')); - $this->session->set_userdata('current_ville', $ville->first_row()->ville); - - $this->session->set_userdata('category', $data->category); - - redirect('index.php/Admin_dash/filter'); - - }else{ - $this->session->set_userdata('member_code', $data->code_membre); - $this->session->set_userdata('longitude', $data->longitude); - $this->session->set_userdata('latitude', $data->latitude); - $this->session->set_userdata('phone', $data->phone); - $this->session->set_userdata('category', $data->category); - $this->session->set_userdata('network', $data->network); - $this->session->set_userdata('network_id', $data->network_id); - $this->session->set_userdata('current_pays', $data->country); - - if($data->category == $hyper) { - redirect('index.php/Hyperviseur_dash'); - } else if ($data->category == $super) { - $this->session->set_userdata('code_parrain', $data->code_parrain); - redirect('index.php/Superviseur_dash'); - } - } - - - } else { - $this->session->set_flashdata('error_msg', 'Error occured,Try again.'); - - $data['alert'] = "ok"; - $data['message'] = "L'identifiant " . $user_login['user_email'] . " ou le mot de passe sont incorrectes ou vérifiez votre grade!"; - - $this->load->view('login', $data); - - } - - } - - public function create_auth(){ - - $email = $this->input->post('user_email'); - - if($email!=null){ - - $this->load->model('Authentification_url_model'); - - if($this->User_model->email_check($this->input->post('user_email'))) - { - $id = $this->session->userdata('id'); - $tktToken = $this->generateToken($id); - $current_date = date('Y-m-d H:i:s'); - $expires = strtotime('+3 days', strtotime($current_date)); - $end_date = date('Y-m-d H:i:s', $expires); - $code_sms = str_pad(mt_rand(1,999999),6,'0',STR_PAD_LEFT); - - $auth = array( - 'email' => $this->input->post('user_email'), - 'contact' => $this->input->post('user_mobile'), - 'token' => $tktToken, - 'code_sms' => $code_sms, - 'create_at' => $current_date, - 'expire_at' => $end_date, - 'id_creator' => $id - ); - - $userId = $this->Authentification_url_model->save_auth($auth); - - $this->sendmail($userId,$this->input->post('email'),$this->input->post('name'),$tktToken,'register','Verify your email'); - redirect('user/login_view', 'refresh'); - } - else{ - $this->session->set_flashdata('msg', 'This email is already used, please try again with different account ...'); - redirect('users/register', 'refresh'); - } - - } - } - - public function register(){ - - $this->load->model('Authentification_url_model'); - - $current_date = date('Y-m-d H:i:s'); - $token = null; - $expiration_date = $this->Authentification_url_model->getExpireDate($token); - - if($expiration_date!=null){ - if($current_date < $expiration_date){ - //registration logic - } - else{ - $this->session->set_flashdata('error_msg', 'Error occured,Try again.'); - //$this->load->view("login.php"); - $data['alert'] = "ok"; - $data['message'] = "Sorry your authentification'url has already expired"; - - //redirect('Login', $data); - $this->load->view('register', $data); - } - } - else{ - $this->session->set_flashdata('error_msg', 'Error occured,Try again.'); - $data['alert'] = "ok"; - $data['message'] = "your authentification url is not recognized"; - $this->load->view('register', $data); - } - } - - public function generateToken($id){ - $static_str='IL'; - $currenttimeseconds = date("mdY_His"); - $token_id=$static_str.$id.$currenttimeseconds; - - return md5($token_id); - } - - public function logout() - { - $this->session->sess_destroy(); - $data['alert'] = 'You have been disconnected'; - //redirect('index.php/Users/index', $data); - $this->load->view('login', $data); - } - - public function forgot_password(){ - - $data['message'] = 'Les instructions vous seront envoyées par email.'; - $this->load->view('admin_forgot_password',$data); - } - - public function sendEmailInstructions(){ - - if(isset($_POST)) - { - $email = $this->input->post('email'); - $emailExist = $this->user_model->isEmailExist($email); - if($emailExist==true){ - $names = $this->db->query("SELECT firstname,lastname FROM admin WHERE email='".$email."'"); - $firstname = $names->first_row()->firstname; - $lastname = $names->first_row()->lastname; - $token_query = $this->db->query("SELECT token FROM admin WHERE email='".$email."'"); - $token = $token_query->first_row()->token; - - $link = "https://ilink-app.com/backofficebeta/index.php/Admin_password/?token=".$token; - $this->load->library('email'); - - $this->email->from('noreply@ilink-app.com', 'iLink World'); - $this->email->to($email); - - $this->email->subject("Instruction pour modification de mot de passe"); - $this->email->message($firstname.' '.$lastname.', veuillez suivre ce lien pour créer un nouveau mot de passe. '.$link); - - $this->email->send(); - }else{ - $data['message'] = 'Veuillez saisir votre email.'; - $this->load->view('admin_forgot_password',$data); - } - }else{ - $data['message'] = 'Cet email ne correspond à aucun utilisateur.'; - $this->load->view('admin_forgot_password',$data); - } - } - - public function redirect_tutorial(){ - if(isset($_POST)) - { - $profil = $this->input->post('profil'); - switch ($profil) { - case 1: - $data['profil'] = 1; - $this->load->view('flipbook',$data); - break; - case 2: - $data['profil'] = 2; - $this->load->view('select_tuto',$data); - break; - case 3: - $data['profil'] = 3; - $this->load->view('select_tuto',$data); - break; - } - } - - } - } -?> +load->model('user_model'); + } + + public function index() + { + + if (!$this->session->userdata('token')) { + + $this->session->set_flashdata('error', 'log in first'); + $data['alert'] = ''; + $this->load->view('login', $data); + + } else { + + $hyper = "hyper"; + $super = "super"; + $admin = "admin"; + + if ($this->session->userdata('category') == 0 or $this->session->userdata('category') == 1) { + + $data['active'] = "dash"; + $data['firstname'] = $this->session->userdata('firstname'); + $data['lastname'] = $this->session->userdata('lastname'); + $data['email'] = $this->session->userdata('email'); + $this->load->view('header', $data); + $this->load->view('admin_dash'); + $this->load->view('footer'); + + } else if ($this->session->userdata('category') == $hyper) { + + $data['active'] = "dash"; + $data['token'] = $this->session->userdata('token'); + $data['email'] = $this->session->userdata('email'); + $data['firstname'] = $this->session->userdata('firstname'); + $data['lastname'] = $this->session->userdata('lastname'); + $data['member_code'] = $this->session->userdata('member_code'); + $data['phone'] = $this->session->userdata('phone'); + $data['adresse'] = $this->session->userdata('adresse'); + $data['category'] = $this->session->userdata('category'); + $data['network'] = $this->session->userdata('network'); + $data['network_id'] = + $data['villes'] = $this->user_model->getVilleByUserGeo($data['network']); + $data['count_geo'] = $this->user_model->countUser("geolocated",$this->session->userdata('network')); + $data['count_sup'] = $this->user_model->countUser("super",$this->session->userdata('network')); + $this->load->view('header_hyp', $data); + $this->load->view('hyperviseur_dash'); + $this->load->view('footer'); + + } else if ($this->session->userdata('category') == $super) { + + $data['active'] = "dash"; + $this->load->view('header_sup', $data); + $this->load->view('superviseur_dash'); + $this->load->view('footer'); + } + + + } + + } + + public function login() + { + $user_login = array( + 'user_email' => $this->input->post('user_mail'), + 'user_password' => $this->input->post('user_password'), + 'user_role' => $this->input->post('user_role') + ); + + $data = $this->user_model->login_user($user_login['user_email'], $user_login['user_password'], $user_login['user_role']); + + if ($data) { + + $hyper = "hyper"; + $super = "super"; + + $this->session->set_userdata('token', $data->token); + $this->session->set_userdata('email', $data->email); + $this->session->set_userdata('firstname', $data->firstname); + $this->session->set_userdata('lastname', $data->lastname); + $this->session->set_userdata('adresse', $data->adresse); + + if($user_login['user_role']==1){ + $this->session->set_userdata('country', $data->country); + + $pays = $this->user_model->getAllCountries(); + $this->session->set_userdata('current_pays', $pays->first_row()->name); + + $hyper = $this->user_model->getAllHyper($this->session->userdata('current_pays')); + $this->session->set_userdata('current_hyper', $hyper->first_row()->code_membre); + + $ville = $this->user_model->getVilleNetworkByHyper($this->session->userdata('current_hyper')); + $this->session->set_userdata('current_ville', $ville->first_row()->ville); + + $this->session->set_userdata('category', $data->category); + + redirect('index.php/Admin_dash/filter'); + + }else{ + $this->session->set_userdata('member_code', $data->code_membre); + $this->session->set_userdata('longitude', $data->longitude); + $this->session->set_userdata('latitude', $data->latitude); + $this->session->set_userdata('phone', $data->phone); + $this->session->set_userdata('category', $data->category); + $this->session->set_userdata('network', $data->network); + $this->session->set_userdata('network_id', $data->network_id); + $this->session->set_userdata('current_pays', $data->country); + + if($data->category == $hyper) { + redirect('index.php/Hyperviseur_dash'); + } else if ($data->category == $super) { + $this->session->set_userdata('code_parrain', $data->code_parrain); + redirect('index.php/Superviseur_dash'); + } + } + + + } else { + $this->session->set_flashdata('error_msg', 'Error occured,Try again.'); + + $data['alert'] = "ok"; + $data['message'] = "L'identifiant " . $user_login['user_email'] . " ou le mot de passe sont incorrectes ou vérifiez votre grade!"; + + $this->load->view('login', $data); + + } + + } + + public function create_auth(){ + + $email = $this->input->post('user_email'); + + if($email!=null){ + + $this->load->model('Authentification_url_model'); + + if($this->User_model->email_check($this->input->post('user_email'))) + { + $id = $this->session->userdata('id'); + $tktToken = $this->generateToken($id); + $current_date = date('Y-m-d H:i:s'); + $expires = strtotime('+3 days', strtotime($current_date)); + $end_date = date('Y-m-d H:i:s', $expires); + $code_sms = str_pad(mt_rand(1,999999),6,'0',STR_PAD_LEFT); + + $auth = array( + 'email' => $this->input->post('user_email'), + 'contact' => $this->input->post('user_mobile'), + 'token' => $tktToken, + 'code_sms' => $code_sms, + 'create_at' => $current_date, + 'expire_at' => $end_date, + 'id_creator' => $id + ); + + $userId = $this->Authentification_url_model->save_auth($auth); + + $this->sendmail($userId,$this->input->post('email'),$this->input->post('name'),$tktToken,'register','Verify your email'); + redirect('user/login_view', 'refresh'); + } + else{ + $this->session->set_flashdata('msg', 'This email is already used, please try again with different account ...'); + redirect('users/register', 'refresh'); + } + + } + } + + public function register(){ + + $this->load->model('Authentification_url_model'); + + $current_date = date('Y-m-d H:i:s'); + $token = null; + $expiration_date = $this->Authentification_url_model->getExpireDate($token); + + if($expiration_date!=null){ + if($current_date < $expiration_date){ + //registration logic + } + else{ + $this->session->set_flashdata('error_msg', 'Error occured,Try again.'); + //$this->load->view("login.php"); + $data['alert'] = "ok"; + $data['message'] = "Sorry your authentification'url has already expired"; + + //redirect('Login', $data); + $this->load->view('register', $data); + } + } + else{ + $this->session->set_flashdata('error_msg', 'Error occured,Try again.'); + $data['alert'] = "ok"; + $data['message'] = "your authentification url is not recognized"; + $this->load->view('register', $data); + } + } + + public function generateToken($id){ + $static_str='IL'; + $currenttimeseconds = date("mdY_His"); + $token_id=$static_str.$id.$currenttimeseconds; + + return md5($token_id); + } + + public function logout() + { + $this->session->sess_destroy(); + $data['alert'] = 'You have been disconnected'; + //redirect('index.php/Users/index', $data); + $this->load->view('login', $data); + } + + public function forgot_password(){ + + $data['message'] = 'Les instructions vous seront envoyées par email.'; + $this->load->view('admin_forgot_password',$data); + } + + public function sendEmailInstructions(){ + + if(isset($_POST)) + { + $email = $this->input->post('email'); + $emailExist = $this->user_model->isEmailExist($email); + if($emailExist==true){ + $names = $this->db->query("SELECT firstname,lastname FROM admin WHERE email='".$email."'"); + $firstname = $names->first_row()->firstname; + $lastname = $names->first_row()->lastname; + $token_query = $this->db->query("SELECT token FROM admin WHERE email='".$email."'"); + $token = $token_query->first_row()->token; + + $link = "https://ilink-app.com/backofficebeta/index.php/Admin_password/?token=".$token; + $this->load->library('email'); + + $this->email->from('noreply@ilink-app.com', 'iLink World'); + $this->email->to($email); + + $this->email->subject("Instruction pour modification de mot de passe"); + $this->email->message($firstname.' '.$lastname.', veuillez suivre ce lien pour créer un nouveau mot de passe. '.$link); + + $this->email->send(); + }else{ + $data['message'] = 'Veuillez saisir votre email.'; + $this->load->view('admin_forgot_password',$data); + } + }else{ + $data['message'] = 'Cet email ne correspond à aucun utilisateur.'; + $this->load->view('admin_forgot_password',$data); + } + } + + public function redirect_tutorial(){ + if(isset($_POST)) + { + $profil = $this->input->post('profil'); + switch ($profil) { + case 1: + $data['profil'] = 1; + $this->load->view('flipbook',$data); + break; + case 2: + $data['profil'] = 2; + $this->load->view('select_tuto',$data); + break; + case 3: + $data['profil'] = 3; + $this->load->view('select_tuto',$data); + break; + } + } + + } + } +?> diff --git a/application/views/listeadmin.php b/application/views/listeadmin.php index dd9a034c..ff05cafb 100644 --- a/application/views/listeadmin.php +++ b/application/views/listeadmin.php @@ -1,839 +1,839 @@ - - - - -
- -
- - -
- -

Error!

- -
- - -
- -

Success!

- -
- - -

- lang->line('Carte des'); ?> - lang->line('zoom'); ?> -

-
-
-
- -
-
-
-
-
-

lang->line('Tous les'); ?> session->userdata('category')=='super'){ echo "(".$numberGeo." ".$this->lang->line('Restant').")";} ?>

-
- -
- - db->select('*'); - $this->db->from('users'); - $this->db->where('network',$network); - $this->db->where('code_parrain', $code_parrain);*/ - - $result=$tab; - if($result!=false){ - - $numrows=$result->num_rows(); - $num = 0; - if ($numrows > 0) { - - ?> - - - - - - - - - - - - - - session->userdata("category")=="0" or $this->session->userdata("category")=="1"){ - echo ""; - } - ?> - - - - - - result() as $row) { - $num++; - $code_parrain = $row->code_parrain; - if($row->code_parrain==$this->session->userdata('member_code')){ - $code_parrain = $this->lang->line("Vous"); - } - echo " - "; - if (isset($row->sup_code_membre)){ - echo " - "; - }else{ - echo ""; - } - $statut = $this->lang->line('Non'); - if($row->active==1){ - $statut = $this->lang->line('Oui'); - } - echo " - - - - - - - - "; - if($this->session->userdata('category')=="0" or $this->session->userdata('category')=="1"){ - echo ""; - } - echo ""; - } - - ?> - - - - - - - - - - - - - - - session->userdata("category")=="0" or $this->session->userdata("category")=="1"){ - echo ""; - } - ?> - - -
lang->line('Catégorie'); ?>lang->line('Parrain'); ?>lang->line('Nom'); ?>lang->line('Adresse'); ?>lang->line('Reseau'); ?>lang->line('code membre'); ?>lang->line('Solde'); ?>lang->line('Email'); ?>lang->line('Contact'); ?>lang->line('Active'); ?>".$this->lang->line('Modifier')."
$row->childcat - - - $code_parrain$row->lastname$row->adresse $row->network$row->member_code$row->solde$row->email$row->phone$statut - -
lang->line('Catégorie'); ?>lang->line('Parrain'); ?>lang->line('Nom'); ?>lang->line('Adresse'); ?>lang->line('Reseau'); ?>lang->line('code membre'); ?>lang->line('Solde'); ?>lang->line('Email'); ?>lang->line('Contact'); ?>lang->line('Active'); ?>".$this->lang->line('Modifier')."
- lang->line('Aucun utilisateur trouvé'); - } - }else{ - echo $this->lang->line('Aucun utilisateur trouvé'); - } - - - //echo $links; - $this->db->close(); - - ?> - - - - - - -
- -
- - - -
- -
-
- Loading -

Chargement

-

100/

-
-
-
- -
-
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + +
+ +
+ + +
+ +

Error!

+ +
+ + +
+ +

Success!

+ +
+ + +

+ lang->line('Carte des'); ?> + lang->line('zoom'); ?> +

+
+
+
+ +
+
+
+
+
+

lang->line('Tous les'); ?> session->userdata('category')=='super'){ echo "(".$numberGeo." ".$this->lang->line('Restant').")";} ?>

+
+ +
+ + db->select('*'); + $this->db->from('users'); + $this->db->where('network',$network); + $this->db->where('code_parrain', $code_parrain);*/ + + $result=$tab; + if($result!=false){ + + $numrows=$result->num_rows(); + $num = 0; + if ($numrows > 0) { + + ?> + + + + + + + + + + + + + + session->userdata("category")=="0" or $this->session->userdata("category")=="1"){ + echo ""; + } + ?> + + + + + + result() as $row) { + $num++; + $code_parrain = $row->code_parrain; + if($row->code_parrain==$this->session->userdata('member_code')){ + $code_parrain = $this->lang->line("Vous"); + } + echo " + "; + if (isset($row->sup_code_membre)){ + echo " + "; + }else{ + echo ""; + } + $statut = $this->lang->line('Non'); + if($row->active==1){ + $statut = $this->lang->line('Oui'); + } + echo " + + + + + + + + "; + if($this->session->userdata('category')=="0" or $this->session->userdata('category')=="1"){ + echo ""; + } + echo ""; + } + + ?> + + + + + + + + + + + + + + + session->userdata("category")=="0" or $this->session->userdata("category")=="1"){ + echo ""; + } + ?> + + +
lang->line('Catégorie'); ?>lang->line('Parrain'); ?>lang->line('Nom'); ?>lang->line('Adresse'); ?>lang->line('Reseau'); ?>lang->line('code membre'); ?>lang->line('Solde'); ?>lang->line('Email'); ?>lang->line('Contact'); ?>lang->line('Active'); ?>".$this->lang->line('Modifier')."
$row->childcat + + + $code_parrain$row->lastname$row->adresse $row->network$row->member_code0$row->email$row->phone$statut + +
lang->line('Catégorie'); ?>lang->line('Parrain'); ?>lang->line('Nom'); ?>lang->line('Adresse'); ?>lang->line('Reseau'); ?>lang->line('code membre'); ?>lang->line('Solde'); ?>lang->line('Email'); ?>lang->line('Contact'); ?>lang->line('Active'); ?>".$this->lang->line('Modifier')."
+ lang->line('Aucun utilisateur trouvé'); + } + }else{ + echo $this->lang->line('Aucun utilisateur trouvé'); + } + + + //echo $links; + $this->db->close(); + + ?> + + + + + + +
+ +
+ + + +
+ +
+
+ Loading +

Chargement

+

100/

+
+
+
+ +
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +