diff --git a/application/controllers/Gestion.php b/application/controllers/Gestion.php index db73a35f..e0060c44 100755 --- a/application/controllers/Gestion.php +++ b/application/controllers/Gestion.php @@ -1879,5 +1879,43 @@ class Gestion extends CI_Controller } } + public function cancelTransation() + { + if($this->isLogged()) { + if (isset($_POST)) { + $id_transacton = $_POST['id_transaction']; + + /* API URL */ + $url = 'http://localhost:8081/transactions/'.$id_transacton; + + /* Init cURL resource */ + $ch = curl_init($url); + + curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "DELETE"); + + /* set the content type json */ + curl_setopt($ch, CURLOPT_HTTPHEADER, array( + 'Content-Type:application/json', + 'Authorization: yhSTSSqIO1uSE1icu09edPOeSFGxIDjo' + )); + + /* set return type json */ + curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); + + /* execute request */ + $result = curl_exec($ch); + + /* close cURL resource */ + curl_close($ch); + + if ($result) { + echo json_encode("200"); + } else { + echo json_encode("500"); + } + } + } + } + } diff --git a/application/controllers/Hyperviseur_dash.php b/application/controllers/Hyperviseur_dash.php index a1ba6eba..d5415b3b 100755 --- a/application/controllers/Hyperviseur_dash.php +++ b/application/controllers/Hyperviseur_dash.php @@ -1,211 +1,210 @@ load->model('user_model'); - date_default_timezone_set ($this->session->userdata('timezone')); - } + public function _contruct() + { + parent::_contruct(); + $this->load->model('user_model'); + date_default_timezone_set($this->session->userdata('timezone')); + } - public function index() - { + public function index() + { - if (!$this->session->userdata('email')) { - $this->session->set_flashdata('error', 'log in first'); + if (!$this->session->userdata('email')) { + $this->session->set_flashdata('error', 'log in first'); - $data['alert'] = "ok"; - $data['message'] = "Login first!"; + $data['alert'] = "ok"; + $data['message'] = "Login first!"; - redirect('index.php', $data); - } else { - $count_d_traite = $this->user_model->getCountDemandeByStatut($this->session->userdata('member_code'),1); - $count_d_no_traite = $this->user_model->getCountDemandeByStatut($this->session->userdata('member_code'),0); - $count_d = $this->user_model->getCountDemande($this->session->userdata('member_code')); + redirect('index.php', $data); + } else { + $count_d_traite = $this->user_model->getCountDemandeByStatut($this->session->userdata('member_code'), 1); + $count_d_no_traite = $this->user_model->getCountDemandeByStatut($this->session->userdata('member_code'), 0); + $count_d = $this->user_model->getCountDemande($this->session->userdata('member_code')); - $data['active'] = "dash"; - $data['list_geolocated_users'] = $this->user_model->getAllGeolocatedUsersForHyp($this->session->userdata('member_code')); - $data['listdem'] = $this->user_model->getDemandes($this->session->userdata('member_code')); - $data['allGeo'] = $this->user_model->getAllUserGeoForHyp($this->session->userdata('member_code')); - $data['allDem'] = $this->user_model->getDemandes($this->session->userdata('member_code')); - $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['superviseurs'] = $this->user_model->getSuperNameAndCodeForHyp($this->session->userdata('member_code')); - $data['villes'] = $this->user_model->getVilleByUserGeo($data['network'],$this->session->userdata('current_pays')); - $data['count_geo'] = $this->user_model->countUserGeoForHyp($this->session->userdata('member_code')); - $data['count_sup'] = $this->user_model->countUser("super",'all',$this->session->userdata('member_code')); - $data['count_d_traite'] = $count_d_traite; - $data['count_d_no_traite'] = $count_d_no_traite; - $data['count_d_users'] = $count_d; - $data['networks'] = $this->user_model->getNetworkByHyp($this->session->userdata('member_code')); - $data['hasWallet'] = $this->user_model->getConfigWallet($this->session->userdata('network_id')); - $this->load->view('header_hyp', $data); - $this->load->view('hyperviseur_dash'); - $this->load->view('footer'); - } - } - - public function getAllUser_g(){ - - 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->post('ville')) - { - $this->session->set_userdata('current_ville', $this->input->post('ville')); - } - - $data['active'] = "geolocated"; - $data['total_points'] = $this->user_model->getCoutGeolocatedUsersForHyper($this->session->userdata('member_code'),$this->session->userdata('current_ville')); - $data['map_title'] = $this->lang->line('utilisateurs géolocalisés à')." ".$this->session->userdata('current_ville'); - $data['tab'] = $this->user_model->getUsersGeolocatedByVilleForHyp($this->session->userdata('current_ville'),$this->session->userdata('member_code')); - $data['positions'] = $this->user_model->getUsersGeolocatedPositionByVilleForHyp($this->session->userdata('current_ville'),$this->session->userdata('member_code')); - $data['latitude'] = $this->session->userdata('latitude'); - $data['longitude'] = $this->session->userdata('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['superviseurs'] = $this->user_model->getSuperNameAndCodeForHyp($this->session->userdata('member_code')); - $data['villes'] = $this->user_model->getVilleByUserGeo($data['network'],$this->session->userdata('current_pays')); - $data['networks'] = $this->user_model->getNetworkByHyp($this->session->userdata('member_code')); - $data['alert'] = ""; + $data['active'] = "dash"; + $data['list_geolocated_users'] = $this->user_model->getAllGeolocatedUsersForHyp($this->session->userdata('member_code')); + $data['listdem'] = $this->user_model->getDemandes($this->session->userdata('member_code')); + $data['allGeo'] = $this->user_model->getAllUserGeoForHyp($this->session->userdata('member_code')); + $data['allDem'] = $this->user_model->getDemandes($this->session->userdata('member_code')); + $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['superviseurs'] = $this->user_model->getSuperNameAndCodeForHyp($this->session->userdata('member_code')); + $data['villes'] = $this->user_model->getVilleByUserGeo($data['network'], $this->session->userdata('current_pays')); + $data['count_geo'] = $this->user_model->countUserGeoForHyp($this->session->userdata('member_code')); + $data['count_sup'] = $this->user_model->countUser("super", 'all', $this->session->userdata('member_code')); + $data['count_d_traite'] = $count_d_traite; + $data['count_d_no_traite'] = $count_d_no_traite; + $data['count_d_users'] = $count_d; + $data['networks'] = $this->user_model->getNetworkByHyp($this->session->userdata('member_code')); $data['hasWallet'] = $this->user_model->getConfigWallet($this->session->userdata('network_id')); $this->load->view('header_hyp', $data); - $this->load->view('listeadmin'); - $this->load->view('footer'); - } + $this->load->view('hyperviseur_dash'); + $this->load->view('footer'); + } + } - } + public function getAllUser_g() + { - public function getAllSupervisor(){ + if (!$this->session->userdata('email')) { + $this->session->set_flashdata('error', 'log in first'); - if (!$this->session->userdata('email')) { - $this->session->set_flashdata('error', 'log in first'); + $data['alert'] = "ok"; + $data['message'] = "Login first!"; - $data['alert'] = "ok"; - $data['message'] = "Login first!"; + redirect('index.php', $data); + } else { + if ($this->input->post('ville')) { + $this->session->set_userdata('current_ville', $this->input->post('ville')); + } - redirect('index.php', $data); - } - else { - - /*$this->db->select('*'); - $this->db->from('users'); - $this->db->where('category','super'); - $this->db->where('network',$this->session->userdata('network')); - $this->db->where('code_parrain',$this->session->userdata('code_parrain'));*/ - $query = $this->user_model->getSupervisorsForHyp($this->session->userdata('member_code')); - - $network = $this->session->userdata('network'); - $category = 'super'; - $position = $this->user_model->getAllpositions($network,$category,$this->session->userdata('member_code')); - if($position!=null){ - //var_dump($position); - //echo json_encode($position); - } - $data['total_points'] = $this->user_model->getCoutSuperForHyper($this->session->userdata('member_code')); - $data['positions'] = $position; - $data['active'] = "super"; - $data['map_title'] = $this->lang->line('Superviseurs'); - $data['tab'] = $query; - $data['latitude'] = $this->session->userdata('latitude'); - $data['longitude'] = $this->session->userdata('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['villes'] = $this->user_model->getVilleByUserGeo($data['network'],$this->session->userdata('current_pays')); - $data['superviseurs'] = $this->user_model->getSuperNameAndCodeForHyp($this->session->userdata('member_code')); - $data['networks'] = $this->user_model->getNetworkByHyp($this->session->userdata('member_code')); - $data['alert'] = ""; + $data['active'] = "geolocated"; + $data['total_points'] = $this->user_model->getCoutGeolocatedUsersForHyper($this->session->userdata('member_code'), $this->session->userdata('current_ville')); + $data['map_title'] = $this->lang->line('utilisateurs géolocalisés à') . " " . $this->session->userdata('current_ville'); + $data['tab'] = $this->user_model->getUsersGeolocatedByVilleForHyp($this->session->userdata('current_ville'), $this->session->userdata('member_code')); + $data['positions'] = $this->user_model->getUsersGeolocatedPositionByVilleForHyp($this->session->userdata('current_ville'), $this->session->userdata('member_code')); + $data['latitude'] = $this->session->userdata('latitude'); + $data['longitude'] = $this->session->userdata('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['superviseurs'] = $this->user_model->getSuperNameAndCodeForHyp($this->session->userdata('member_code')); + $data['villes'] = $this->user_model->getVilleByUserGeo($data['network'], $this->session->userdata('current_pays')); + $data['networks'] = $this->user_model->getNetworkByHyp($this->session->userdata('member_code')); + $data['alert'] = ""; $data['hasWallet'] = $this->user_model->getConfigWallet($this->session->userdata('network_id')); $this->load->view('header_hyp', $data); - $this->load->view('listeadmin'); - $this->load->view('footer'); - } - } + $this->load->view('listeadmin'); + $this->load->view('footer'); + } - public function getAllSupervisorPositions(){ - if (!$this->session->userdata('email')) { - $this->session->set_flashdata('error', 'log in first'); + } - $data['alert'] = "ok"; - $data['message'] = "Login first!"; + public function getAllSupervisor() + { + + 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 { - $network = $this->session->userdata('network'); - $category = 'super'; + redirect('index.php', $data); + } else { - $position = $this->user_model->getAllpositions($network,$category,$this->session->userdata('member_code')); - if($position!=null){ - return $position; - } - } - } + /*$this->db->select('*'); + $this->db->from('users'); + $this->db->where('category','super'); + $this->db->where('network',$this->session->userdata('network')); + $this->db->where('code_parrain',$this->session->userdata('code_parrain'));*/ + $query = $this->user_model->getSupervisorsForHyp($this->session->userdata('member_code')); - public function getDemandes(){ + $network = $this->session->userdata('network'); + $category = 'super'; + $position = $this->user_model->getAllpositions($network, $category, $this->session->userdata('member_code')); + if ($position != null) { + //var_dump($position); + //echo json_encode($position); + } + $data['total_points'] = $this->user_model->getCoutSuperForHyper($this->session->userdata('member_code')); + $data['positions'] = $position; + $data['active'] = "super"; + $data['map_title'] = $this->lang->line('Superviseurs'); + $data['tab'] = $query; + $data['latitude'] = $this->session->userdata('latitude'); + $data['longitude'] = $this->session->userdata('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['villes'] = $this->user_model->getVilleByUserGeo($data['network'], $this->session->userdata('current_pays')); + $data['superviseurs'] = $this->user_model->getSuperNameAndCodeForHyp($this->session->userdata('member_code')); + $data['networks'] = $this->user_model->getNetworkByHyp($this->session->userdata('member_code')); + $data['alert'] = ""; + $data['hasWallet'] = $this->user_model->getConfigWallet($this->session->userdata('network_id')); + $this->load->view('header_hyp', $data); + $this->load->view('listeadmin'); + $this->load->view('footer'); + } + } - 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($this->input->get("u") !== null) - { + public function getAllSupervisorPositions() + { + 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 { + $network = $this->session->userdata('network'); + $category = 'super'; + + $position = $this->user_model->getAllpositions($network, $category, $this->session->userdata('member_code')); + if ($position != null) { + return $position; + } + } + } + + public function getDemandes() + { + + 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 ($this->input->get("u") !== null) { $super = $this->input->get("u"); $this->session->set_userdata("current_super_demande", $super); - $debut =""; + $debut = ""; $fin = ""; - if($this->input->get("d") !== null){ + if ($this->input->get("d") !== null) { $debut = $this->input->get("d"); $fin = $this->input->get("f"); - }else{ + } else { $fin = date('Y-m-d'); $debut = Date('Y-m-d', strtotime("-5 days")); } - $format = $this->session->userdata('site_lang') === 'french' ? 'd-m-Y' : 'Y-m-d' ; - $data['debut'] = $debut ? date($format, strtotime($debut)) : null ; - $data['fin'] = $fin ?date($format, strtotime($fin)): null ; - $fin = Date('Y-m-d', strtotime($fin."+1 day")); + $format = $this->session->userdata('site_lang') === 'french' ? 'd-m-Y' : 'Y-m-d'; + $data['debut'] = $debut ? date($format, strtotime($debut)) : null; + $data['fin'] = $fin ? date($format, strtotime($fin)) : null; + $fin = Date('Y-m-d', strtotime($fin . "+1 day")); $ville = $this->session->userdata('ville'); $data['active'] = "demandes"; @@ -221,12 +220,12 @@ class Hyperviseur_dash extends CI_Controller $data['adresse'] = $this->session->userdata('adresse'); $data['category'] = $this->session->userdata('category'); $data['network'] = $this->session->userdata('network'); - $data['villes'] = $this->user_model->getVilleByUserGeo($data['network'],$this->session->userdata('current_pays')); + $data['villes'] = $this->user_model->getVilleByUserGeo($data['network'], $this->session->userdata('current_pays')); $data['superviseurs'] = $this->user_model->getSuperNameAndCodeForHyp($this->session->userdata('member_code')); - $data['tab_fastDemande'] = $this->user_model->getRangeASCDemandesByNetwork($debut,$fin,$this->session->userdata('member_code'),$this->session->userdata('current_demande_ville'),$super); - $data['tab_slowDemande'] = $this->user_model->getRangeDESCDemandesByNetwork($debut,$fin,$this->session->userdata('member_code'),$this->session->userdata('current_demande_ville'),$super); - $data['list'] = $this->user_model->getDemandesBySuper($this->session->userdata('member_code'),$super); - $data['temp_moyen'] = $this->user_model->getTempsMoyenByVille($this->session->userdata('member_code'),$super,$this->session->userdata('network')); + $data['tab_fastDemande'] = $this->user_model->getRangeASCDemandesByNetwork($debut, $fin, $this->session->userdata('member_code'), $this->session->userdata('current_demande_ville'), $super); + $data['tab_slowDemande'] = $this->user_model->getRangeDESCDemandesByNetwork($debut, $fin, $this->session->userdata('member_code'), $this->session->userdata('current_demande_ville'), $super); + $data['list'] = $this->user_model->getDemandesBySuper($this->session->userdata('member_code'), $super); + $data['temp_moyen'] = $this->user_model->getTempsMoyenByVille($this->session->userdata('member_code'), $super, $this->session->userdata('network')); $data['networks'] = $this->user_model->getNetworkByHyp($this->session->userdata('member_code')); $data['hasWallet'] = $this->user_model->getConfigWallet($this->session->userdata('network_id')); $data['nameOfcurentGeolocatedUser'] = $this->user_model->nameOfCurrentGeolocatedUser_forSuper($super); @@ -235,83 +234,86 @@ class Hyperviseur_dash extends CI_Controller $this->load->view('footer'); } } - } + } - public function addvilles(){ - $id = 1; - $date = "2018-08-29"; - for ($i = 1; $i <= 267; $i++) { - $newdate = date("Y-m-d", strtotime($date." + 1 day + 1 hour")); - $data = array( - 'dateAjout' => $date, - 'dateModif' => $newdate, - ); + public function addvilles() + { + $id = 1; + $date = "2018-08-29"; + for ($i = 1; $i <= 267; $i++) { + $newdate = date("Y-m-d", strtotime($date . " + 1 day + 1 hour")); + $data = array( + 'dateAjout' => $date, + 'dateModif' => $newdate, + ); - $newdate = date("Y-m-d", strtotime($date." + 1 day + 3 hour")); - $date = $newdate; + $newdate = date("Y-m-d", strtotime($date . " + 1 day + 3 hour")); + $date = $newdate; - $this->db->update('demande_superviseur', $data); - } - } + $this->db->update('demande_superviseur', $data); + } + } - public function getDemandesAd(){ + public function getDemandesAd() + { - 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 { - $network = $this->session->userdata('network'); + 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 { + $network = $this->session->userdata('network'); $debut = $this->input->get("d"); $fin = $this->input->get("f"); - $format = $this->session->userdata('site_lang') === 'french' ? 'd-m-Y' : 'Y-m-d' ; - $data['debut'] = $debut ? date($format, strtotime($debut)) : null ; - $data['fin'] = $fin ?date($format, strtotime($fin)): null ; + $format = $this->session->userdata('site_lang') === 'french' ? 'd-m-Y' : 'Y-m-d'; + $data['debut'] = $debut ? date($format, strtotime($debut)) : null; + $data['fin'] = $fin ? date($format, strtotime($fin)) : null; $data['demand_type'] = 'adhesion'; - $data['active'] = "demandesAd"; - $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['tab_fastDemande'] = $this->user_model->getRangeASCDemandesAd($debut, $fin ,$this->session->userdata('member_code')); - $data['tab_slowDemande'] = $this->user_model->getRangeDESCDemandesAd($debut, $fin ,$this->session->userdata('member_code')); - $data['temp_moyen'] = $this->user_model->getTempsMoyenAd($debut, $fin ,$this->session->userdata('member_code')); - $data['list'] = $this->user_model->getDemandesAdForSuper($debut, $fin , $this->session->userdata('member_code')); - $data['villes'] = $this->user_model->getVilleByUserGeo($data['network'],$this->session->userdata('current_pays')); - $data['superviseurs'] = $this->user_model->getSuperNameAndCodeForHyp($this->session->userdata('member_code')); - $data['networks'] = $this->user_model->getNetworkByHyp($this->session->userdata('member_code')); - $data['type'] = $this->lang->line('Adhésion'); + $data['active'] = "demandesAd"; + $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['tab_fastDemande'] = $this->user_model->getRangeASCDemandesAd($debut, $fin, $this->session->userdata('member_code')); + $data['tab_slowDemande'] = $this->user_model->getRangeDESCDemandesAd($debut, $fin, $this->session->userdata('member_code')); + $data['temp_moyen'] = $this->user_model->getTempsMoyenAd($debut, $fin, $this->session->userdata('member_code')); + $data['list'] = $this->user_model->getDemandesAdForSuper($debut, $fin, $this->session->userdata('member_code')); + $data['villes'] = $this->user_model->getVilleByUserGeo($data['network'], $this->session->userdata('current_pays')); + $data['superviseurs'] = $this->user_model->getSuperNameAndCodeForHyp($this->session->userdata('member_code')); + $data['networks'] = $this->user_model->getNetworkByHyp($this->session->userdata('member_code')); + $data['type'] = $this->lang->line('Adhésion'); $data['hasWallet'] = $this->user_model->getConfigWallet($this->session->userdata('network_id')); $this->load->view('header_hyp', $data); - $this->load->view('demande_adhesion'); - $this->load->view('footer'); - } - } + $this->load->view('demande_adhesion'); + $this->load->view('footer'); + } + } - // Wallet - public function wallet(){ - if (!$this->session->userdata('email')) { - $this->session->set_flashdata('error', 'log in first'); + // Wallet + public function wallet() + { + 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 { + $data['alert'] = "ok"; + $data['message'] = "Login first!"; + $this->load->view('login', $data); + } else { $id_network = $this->session->userdata('network_id'); $data['hasWallet'] = $this->user_model->getConfigWallet($this->session->userdata('network_id')); if ($data['hasWallet']) { - if($this->input->get('history')){ - $this->historique($id_network,$this->input->get('d'),$this->input->get('f'),$this->input->get('history')); - }else { + if ($this->input->get('history')) { + $this->historique($id_network, $this->input->get('d'), $this->input->get('f'), $this->input->get('history')); + } else { $data["commission"] = ""; $data["principal"] = ""; @@ -321,7 +323,7 @@ class Hyperviseur_dash extends CI_Controller $taux = $data['hasWallet']->first_row(); $data['idConfig'] = $taux->id; - if ($data['hasWallet']->first_row()->type == 'visa'){ + if ($data['hasWallet']->first_row()->type == 'visa') { $data['taux_client_r'] = $taux->taux_com_client_retrait; $data['taux_client_d'] = $taux->taux_com_client_depot; $data['taux_ag_r'] = $taux->taux_com_ag_retrait; @@ -331,11 +333,11 @@ class Hyperviseur_dash extends CI_Controller $data['taux_bq_d'] = $taux->part_banque_depot; $data['taux_bq_r'] = $taux->part_banque_retrait; $data['frais_d'] = $taux->frais_min_banque_depot; - } elseif ($data['hasWallet']->first_row()->type == 'ilink'){ - $data['plr_user_wallet_wallet'] = $this->user_model->getPalierConfigWallet("user_wallet_wallet" , $data['idConfig']); - $data['plr_user_wallet_cash'] = $this->user_model->getPalierConfigWallet("user_wallet_cash" , $data['idConfig']); - $data['plr_agent_depot_wallet'] = $this->user_model->getPalierConfigWallet("agent_depot_wallet" , $data['idConfig']); - $data['plr_agent_cash_cash'] = $this->user_model->getPalierConfigWallet("agent_cash_cash" , $data['idConfig']); + } elseif ($data['hasWallet']->first_row()->type == 'ilink') { + $data['plr_user_wallet_wallet'] = $this->user_model->getPalierConfigWallet("user_wallet_wallet", $data['idConfig']); + $data['plr_user_wallet_cash'] = $this->user_model->getPalierConfigWallet("user_wallet_cash", $data['idConfig']); + $data['plr_agent_depot_wallet'] = $this->user_model->getPalierConfigWallet("agent_depot_wallet", $data['idConfig']); + $data['plr_agent_cash_cash'] = $this->user_model->getPalierConfigWallet("agent_cash_cash", $data['idConfig']); $data['u_w_w_min'] = $taux->taux_com_user_wallet_wallet_min; $data['u_w_w_max'] = $taux->taux_com_user_wallet_wallet_max; $data['taux_u_w_w'] = $taux->taux_com_user_wallet_wallet; @@ -429,10 +431,10 @@ class Hyperviseur_dash extends CI_Controller elseif ($data['hasWallet']->first_row()->type == 'ilink') $this->load->view('gestion_wallet_ilink_hyp'); $this->load->view('footer'); + } } - } - } - } + } + } private function isLogged() { @@ -447,17 +449,17 @@ class Hyperviseur_dash extends CI_Controller return true; } - private function historique($network_id ,$startDate ,$endDate, $type) + private function historique($network_id, $startDate, $endDate, $type) { $data['configWallet'] = $this->user_model->getConfigWallet($network_id); - $format = $this->session->userdata('site_lang') === 'french' ? 'd-m-Y' : 'Y-m-d' ; - $data['startDate'] = $startDate ? date($format, strtotime($startDate)) : null ; - $data['endDate'] = $endDate ?date($format, strtotime($endDate)): null ; - $endDate = Date('Y-m-d', strtotime($endDate."+1 day")); - if($type == 'transaction') - $data['transactions'] = $this->user_model->getTransactions($startDate , $endDate ,$network_id); + $format = $this->session->userdata('site_lang') === 'french' ? 'd-m-Y' : 'Y-m-d'; + $data['startDate'] = $startDate ? date($format, strtotime($startDate)) : null; + $data['endDate'] = $endDate ? date($format, strtotime($endDate)) : null; + $endDate = Date('Y-m-d', strtotime($endDate . "+1 day")); + if ($type == 'transaction') + $data['transactions'] = $this->user_model->getTransactions($startDate, $endDate, $network_id); else - $data['transactions'] = $this->user_model->getRecharges($startDate , $endDate ,$network_id); + $data['transactions'] = $this->user_model->getRecharges($startDate, $endDate, $network_id); $data['active'] = "wallet"; $data['alert'] = ""; @@ -469,19 +471,20 @@ class Hyperviseur_dash extends CI_Controller $data['networks'] = $this->user_model->getActiveNetwork(); $data['superviseurs'] = $this->user_model->getSuperNameAndCodeForHyp($this->session->userdata('member_code')); $data['hasWallet'] = $this->user_model->getConfigWallet($this->session->userdata('network_id')); - $data['country'] = $this->session->userdata('current_pays'); + $data['country'] = $this->session->userdata('current_pays'); $data['category'] = $this->session->userdata('category'); $this->load->view('header_hyp', $data); - if($type == 'transaction') + if ($type == 'transaction') $this->load->view('historique_transactions'); else $this->load->view('historique_recharges'); $this->load->view('footer'); } - public function walletPassword(){ - if($this->isLogged()){ + public function walletPassword() + { + if ($this->isLogged()) { $data['active'] = "wallet_password"; $data['alert'] = ""; $data['firstname'] = $this->session->userdata('firstname'); @@ -492,7 +495,7 @@ class Hyperviseur_dash extends CI_Controller $data['networks'] = $this->user_model->getActiveNetwork(); $data['superviseurs'] = $this->user_model->getSuperNameAndCodeForHyp($this->session->userdata('member_code')); $data['hasWallet'] = $this->user_model->getConfigWallet($this->session->userdata('network_id')); - $data['country'] = $this->session->userdata('current_pays'); + $data['country'] = $this->session->userdata('current_pays'); $data['network_id'] = $this->session->userdata('network_id'); $res = $this->user_model->getWalletPassword($this->session->userdata('network_id')); $data['walletPassword'] = $res ? $res->first_row() : null; @@ -502,33 +505,34 @@ class Hyperviseur_dash extends CI_Controller } } - public function generate_wallet_password(){ - if($this->isLogged()){ + public function generate_wallet_password() + { + if ($this->isLogged()) { if (isset($_POST)) { $network_id = isset($_POST['network_id']) ? $_POST['network_id'] : null; $email = $_POST['email']; // $size = $_POST['size']; - $wallet_password_id = isset($_POST['wallet_password_id']) ? $_POST['wallet_password_id'] : null ; + $wallet_password_id = isset($_POST['wallet_password_id']) ? $_POST['wallet_password_id'] : null; $network = $_POST['network']; $country = $_POST['country']; $password = $this->generate_string(); - $hash = $this->hashSSHA($password); - $encrypted_password = $hash['encrypted'] ; - $salt = $hash['salt'] ; + $hash = $this->hashSSHA($password); + $encrypted_password = $hash['encrypted']; + $salt = $hash['salt']; $this->load->library('email'); $this->email->from('noreply@ilink-app.com', 'iLink World'); $this->email->to($email); - $this->email->subject($this->lang->line('wallet_password').' '.$network . ' - '.$country); - $this->email->message($this->lang->line('mot de passe').' : '.$password); + $this->email->subject($this->lang->line('wallet_password') . ' ' . $network . ' - ' . $country); + $this->email->message($this->lang->line('mot de passe') . ' : ' . $password); if ($this->email->send()) { - if($wallet_password_id == null) - $this->user_model->addWalletPassword($network_id,$encrypted_password,$salt,$email); + if ($wallet_password_id == null) + $this->user_model->addWalletPassword($network_id, $encrypted_password, $salt, $email); else - $this->user_model->updateWalletPassword($wallet_password_id,$encrypted_password,$salt,$email); + $this->user_model->updateWalletPassword($wallet_password_id, $encrypted_password, $salt, $email); $res = true; } else { // show_error($this->email->print_debugger()); @@ -544,20 +548,22 @@ class Hyperviseur_dash extends CI_Controller } } - private function generate_string($length = 10){ - $chars = 'abcdefghjkmnpqrstuvwxyz'. + private function generate_string($length = 10) + { + $chars = 'abcdefghjkmnpqrstuvwxyz' . '23456789'; $str = ''; $max = strlen($chars) - 1; - for ($i=0; $i < $length; $i++) + for ($i = 0; $i < $length; $i++) $str .= $chars[mt_rand(0, $max)]; return $str; } - private function hashSSHA($password) { + private function hashSSHA($password) + { $salt = sha1(rand()); $salt = substr($salt, 0, 10); $encrypted = base64_encode(sha1($password . $salt, true) . $salt); @@ -565,28 +571,29 @@ class Hyperviseur_dash extends CI_Controller return $hash; } - public function resetWalletPassword(){ - if($this->isLogged()){ + public function resetWalletPassword() + { + if ($this->isLogged()) { if (isset($_POST)) { $email = $_POST['email']; - $wallet_password_id = isset($_POST['wallet_password_id']) ? $_POST['wallet_password_id'] : null ; + $wallet_password_id = isset($_POST['wallet_password_id']) ? $_POST['wallet_password_id'] : null; $network = $_POST['network']; $country = $_POST['country']; $password = $this->generate_string(); - $hash = $this->hashSSHA($password); - $encrypted_password = $hash['encrypted'] ; - $salt = $hash['salt'] ; + $hash = $this->hashSSHA($password); + $encrypted_password = $hash['encrypted']; + $salt = $hash['salt']; $this->load->library('email'); $this->email->from('noreply@ilink-app.com', 'iLink World'); $this->email->to($email); - $this->email->subject($this->lang->line('reset_wallet_password').' '.$network . ' - '.$country); - $this->email->message($this->lang->line('mot de passe').' : '.$password); + $this->email->subject($this->lang->line('reset_wallet_password') . ' ' . $network . ' - ' . $country); + $this->email->message($this->lang->line('mot de passe') . ' : ' . $password); if ($this->email->send()) { - $this->user_model->updateWalletPassword($wallet_password_id,$encrypted_password,$salt,$email); + $this->user_model->updateWalletPassword($wallet_password_id, $encrypted_password, $salt, $email); $res = true; } else { // show_error($this->email->print_debugger()); @@ -602,22 +609,23 @@ class Hyperviseur_dash extends CI_Controller } } - public function recharge_wallet(){ - if($this->isLogged()){ + public function recharge_wallet() + { + if ($this->isLogged()) { if (isset($_POST)) { $password = $_POST['password']; $wallet_id = $_POST['wallet_id']; - $salt = $_POST['salt'] ; + $salt = $_POST['salt']; $encrypted_password = $_POST['encrypted_password']; $montant = $_POST['montant']; $hash = base64_encode(sha1($password . $salt, true) . $salt); - if($encrypted_password == $hash){ - $this->user_model->updateWalletBalance($montant,$wallet_id); - $res = $this->user_model->addWalletRecharge($montant,$wallet_id); - $code = $res ? '200' : '500' ; - }else{ + if ($encrypted_password == $hash) { + $this->user_model->updateWalletBalance($montant, $wallet_id); + $res = $this->user_model->addWalletRecharge($montant, $wallet_id); + $code = $res ? '200' : '500'; + } else { $code = '400'; } @@ -627,8 +635,9 @@ class Hyperviseur_dash extends CI_Controller } } - public function calculator(){ - if($this->isLogged()){ + public function calculator() + { + if ($this->isLogged()) { $data['active'] = "calculator"; $data['alert'] = ""; $data['firstname'] = $this->session->userdata('firstname'); @@ -640,16 +649,16 @@ class Hyperviseur_dash extends CI_Controller $data['superviseurs'] = $this->user_model->getSuperNameAndCodeForHyp($this->session->userdata('member_code')); $data['hasWallet'] = $this->user_model->getConfigWallet($this->session->userdata('network_id')); $data['idConfig'] = $data['hasWallet']->first_row()->id; - $data['country'] = $this->session->userdata('current_pays'); + $data['country'] = $this->session->userdata('current_pays'); $data['network_id'] = $this->session->userdata('network_id'); $data['countries'] = $this->user_model->getWalletsCountries(); - $data['plr_user_wallet_wallet'] = $this->user_model->getPalierConfigWallet("user_wallet_wallet" , $data['idConfig'])->result(); - $data['plr_user_wallet_cash'] = $this->user_model->getPalierConfigWallet("user_wallet_cash" , $data['idConfig']); - $data['plr_agent_depot_wallet'] = $this->user_model->getPalierConfigWallet("agent_depot_wallet" , $data['idConfig']); - $data['plr_agent_cash_cash'] = $this->user_model->getPalierConfigWallet("agent_cash_cash" , $data['idConfig']); + $data['plr_user_wallet_wallet'] = $this->user_model->getPalierConfigWallet("user_wallet_wallet", $data['idConfig']); + $data['plr_user_wallet_cash'] = $this->user_model->getPalierConfigWallet("user_wallet_cash", $data['idConfig']); + $data['plr_agent_depot_wallet'] = $this->user_model->getPalierConfigWallet("agent_depot_wallet", $data['idConfig']); + $data['plr_agent_cash_cash'] = $this->user_model->getPalierConfigWallet("agent_cash_cash", $data['idConfig']); $operations = [ - new Operation(1,$this->lang->line('op1')), - new Operation(2,"Retrait d'argent") + new Operation(1, $this->lang->line('op1')), + new Operation(2, "Retrait d'argent") ]; $data['operations'] = $operations; // if (isset($_POST)) { @@ -661,13 +670,30 @@ class Hyperviseur_dash extends CI_Controller $this->load->view('footer'); } } + + public function cancelCreditRequest() + { + if ($this->isLogged()) { + if (isset($_POST)) { + $id_demand = $_POST['id_demand']; + $res = $this->user_model->cancelCreditRequest($id_demand); + + if ($res) { + echo json_encode("200"); + } else { + echo json_encode("500"); + } + } + } + } } -class Operation { - public $name ; +class Operation +{ + public $name; public $id; - public function __construct($id , $name) + public function __construct($id, $name) { $this->name = $name; $this->id = $id; diff --git a/application/language/french/message_lang.php b/application/language/french/message_lang.php index 4b5537a5..2e71955c 100755 --- a/application/language/french/message_lang.php +++ b/application/language/french/message_lang.php @@ -366,5 +366,8 @@ $lang['amount_departure_country'] = 'Montant du pays de départ'; $lang['amount_country_of_destination'] = 'Montant du pays de destination'; $lang['no_operation'] = 'Aucune opération'; $lang['agent_name'] = 'Nom de l\'agent'; +$lang['cancel'] = 'Annuler'; +$lang['canceled_transaction'] = 'Transaction annulée'; +$lang['canceled_credit_request'] = 'Demande de crédit annulée'; $lang['op1'] = 'Envoi de wallet à wallet'; ?> diff --git a/application/models/User_model.php b/application/models/User_model.php index 8d3a0ed9..42582286 100755 --- a/application/models/User_model.php +++ b/application/models/User_model.php @@ -2333,4 +2333,35 @@ class User_model extends CI_Model } } + public function cancelCreditRequest($id_demand){ + $sql = "SELECT * FROM `info_demandeCredits` WHERE `demande_id` = ?;"; + $query = $this->db->query($sql , array($id_demand)); + if($query->num_rows()>0){ + $demand = $query->first_row(); + $sql = "SELECT * FROM `wallet_agent` WHERE `codeMembre` = ?;"; + $query = $this->db->query($sql , array($demand->codeMembre)); + $query2 = $this->db->query($sql , array($demand->codeParrain)); + $result = $query->num_rows()>0; + if($result){ + $result =$query2->num_rows()>0; + if($result){ + $sql = "UPDATE wallets SET balance_princ = ? WHERE (`id` = ?);"; + $montant = $demand->montant; + $montantAgent = $query->first_row()->balance_princ - $montant; + $montantParrain = $query->first_row()->balance_princ + $montant; + + $this->db->query($sql , $montantAgent , $query->first_row()->wallet_id ); + $this->db->query($sql , $montantParrain , $query2->first_row()->wallet_id); + + $sql = "UPDATE `demandeCredits` SET `status` = '2' WHERE (`id` = ?);"; + $this->db->query($sql , $demand->demande_id); + return true; + } + } + return false; + }else{ + return false; + } + } + } diff --git a/application/views/demande_credit.php b/application/views/demande_credit.php index cfbb5d7d..7c55b734 100755 --- a/application/views/demande_credit.php +++ b/application/views/demande_credit.php @@ -1,7 +1,7 @@ - +