2020-04-17 15:28:27 +00:00
|
|
|
<?php
|
2020-06-08 18:54:36 +00:00
|
|
|
defined('BASEPATH') or exit('No direct script access allowed');
|
|
|
|
|
2020-04-17 15:28:27 +00:00
|
|
|
/**
|
|
|
|
* Created by PhpStorm.
|
|
|
|
* User: Hanry Nzale
|
|
|
|
* Date: 03/08/2018
|
|
|
|
* Time: 02:03
|
|
|
|
*/
|
|
|
|
class Hyperviseur_dash extends CI_Controller
|
|
|
|
{
|
2020-06-08 18:54:36 +00:00
|
|
|
public function _contruct()
|
|
|
|
{
|
|
|
|
parent::_contruct();
|
|
|
|
$this->load->model('user_model');
|
|
|
|
date_default_timezone_set($this->session->userdata('timezone'));
|
|
|
|
}
|
|
|
|
|
|
|
|
public function index()
|
|
|
|
{
|
|
|
|
|
|
|
|
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 {
|
|
|
|
$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'] = "";
|
2020-04-17 15:28:27 +00:00
|
|
|
$data['hasWallet'] = $this->user_model->getConfigWallet($this->session->userdata('network_id'));
|
|
|
|
$this->load->view('header_hyp', $data);
|
2020-06-08 18:54:36 +00:00
|
|
|
$this->load->view('listeadmin');
|
|
|
|
$this->load->view('footer');
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
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 {
|
|
|
|
|
|
|
|
/*$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'] = "";
|
2020-04-17 15:28:27 +00:00
|
|
|
$data['hasWallet'] = $this->user_model->getConfigWallet($this->session->userdata('network_id'));
|
|
|
|
$this->load->view('header_hyp', $data);
|
2020-06-08 18:54:36 +00:00
|
|
|
$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!";
|
|
|
|
|
|
|
|
|
|
|
|
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) {
|
2020-04-28 22:23:15 +00:00
|
|
|
$super = $this->input->get("u");
|
|
|
|
$this->session->set_userdata("current_super_demande", $super);
|
2020-04-24 10:40:34 +00:00
|
|
|
|
2020-06-08 18:54:36 +00:00
|
|
|
$debut = "";
|
2020-04-24 10:40:34 +00:00
|
|
|
$fin = "";
|
2020-06-08 18:54:36 +00:00
|
|
|
if ($this->input->get("d") !== null) {
|
2020-04-24 10:40:34 +00:00
|
|
|
$debut = $this->input->get("d");
|
|
|
|
$fin = $this->input->get("f");
|
2020-06-08 18:54:36 +00:00
|
|
|
} else {
|
2020-04-28 22:23:15 +00:00
|
|
|
$fin = date('Y-m-d');
|
|
|
|
$debut = Date('Y-m-d', strtotime("-5 days"));
|
2020-04-24 10:40:34 +00:00
|
|
|
}
|
2020-06-08 18:54:36 +00:00
|
|
|
$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"));
|
2020-04-24 10:40:34 +00:00
|
|
|
|
|
|
|
$ville = $this->session->userdata('ville');
|
|
|
|
$data['active'] = "demandes";
|
|
|
|
$data['type'] = $this->lang->line('crédits');
|
2020-04-28 22:23:15 +00:00
|
|
|
$data['demand_type'] = 'credit';
|
2020-04-24 10:40:34 +00:00
|
|
|
$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');
|
2020-06-08 18:54:36 +00:00
|
|
|
$data['villes'] = $this->user_model->getVilleByUserGeo($data['network'], $this->session->userdata('current_pays'));
|
2020-04-24 10:40:34 +00:00
|
|
|
$data['superviseurs'] = $this->user_model->getSuperNameAndCodeForHyp($this->session->userdata('member_code'));
|
2020-06-08 18:54:36 +00:00
|
|
|
$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'));
|
2020-04-24 10:40:34 +00:00
|
|
|
$data['networks'] = $this->user_model->getNetworkByHyp($this->session->userdata('member_code'));
|
2020-04-17 15:28:27 +00:00
|
|
|
$data['hasWallet'] = $this->user_model->getConfigWallet($this->session->userdata('network_id'));
|
2020-05-06 06:36:54 +00:00
|
|
|
$data['nameOfcurentGeolocatedUser'] = $this->user_model->nameOfCurrentGeolocatedUser_forSuper($super);
|
2020-04-17 15:28:27 +00:00
|
|
|
$this->load->view('header_hyp', $data);
|
2020-05-02 10:49:34 +00:00
|
|
|
$this->load->view('demande_credit');
|
2020-04-24 10:40:34 +00:00
|
|
|
$this->load->view('footer');
|
|
|
|
}
|
|
|
|
}
|
2020-06-08 18:54:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
$this->db->update('demande_superviseur', $data);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
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');
|
2020-04-28 22:23:15 +00:00
|
|
|
$debut = $this->input->get("d");
|
|
|
|
$fin = $this->input->get("f");
|
2020-06-08 18:54:36 +00:00
|
|
|
$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;
|
2020-04-28 22:23:15 +00:00
|
|
|
$data['demand_type'] = 'adhesion';
|
2020-06-08 18:54:36 +00:00
|
|
|
$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');
|
2020-04-17 15:28:27 +00:00
|
|
|
$data['hasWallet'] = $this->user_model->getConfigWallet($this->session->userdata('network_id'));
|
|
|
|
$this->load->view('header_hyp', $data);
|
2020-06-08 18:54:36 +00:00
|
|
|
$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');
|
|
|
|
|
|
|
|
$data['alert'] = "ok";
|
|
|
|
$data['message'] = "Login first!";
|
|
|
|
$this->load->view('login', $data);
|
|
|
|
} else {
|
2020-05-05 08:25:12 +00:00
|
|
|
$id_network = $this->session->userdata('network_id');
|
2020-06-01 11:21:06 +00:00
|
|
|
$data['hasWallet'] = $this->user_model->getConfigWallet($this->session->userdata('network_id'));
|
|
|
|
if ($data['hasWallet']) {
|
|
|
|
|
2020-06-08 18:54:36 +00:00
|
|
|
if ($this->input->get('history')) {
|
|
|
|
$this->historique($id_network, $this->input->get('d'), $this->input->get('f'), $this->input->get('history'));
|
|
|
|
} else {
|
2020-06-01 11:21:06 +00:00
|
|
|
|
|
|
|
$data["commission"] = "";
|
|
|
|
$data["principal"] = "";
|
|
|
|
$data["transactions"] = "";
|
|
|
|
$agent_id = $this->session->userdata('agent_id');
|
|
|
|
|
2020-04-17 15:28:27 +00:00
|
|
|
|
2020-05-05 08:25:12 +00:00
|
|
|
$taux = $data['hasWallet']->first_row();
|
2020-06-01 11:21:06 +00:00
|
|
|
$data['idConfig'] = $taux->id;
|
2020-06-08 18:54:36 +00:00
|
|
|
if ($data['hasWallet']->first_row()->type == 'visa') {
|
2020-06-01 11:21:06 +00:00
|
|
|
$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;
|
|
|
|
$data['taux_ag_d'] = $taux->taux_com_ag_depot;
|
|
|
|
$data['taux_sup_r'] = $taux->taux_com_sup_retrait;
|
|
|
|
$data['taux_sup_d'] = $taux->taux_com_sup_depot;
|
|
|
|
$data['taux_bq_d'] = $taux->part_banque_depot;
|
|
|
|
$data['taux_bq_r'] = $taux->part_banque_retrait;
|
|
|
|
$data['frais_d'] = $taux->frais_min_banque_depot;
|
2020-06-08 18:54:36 +00:00
|
|
|
} elseif ($data['hasWallet']->first_row()->type == 'ilink') {
|
2020-06-13 14:47:09 +00:00
|
|
|
$data['plr_user_wallet_wallet'] = $this->user_model->getPalierConfigWallet("user_wallet_wallet_international", $data['idConfig']);
|
|
|
|
$data['plr_user_wallet_cash'] = $this->user_model->getPalierConfigWallet("user_wallet_cash_international", $data['idConfig']);
|
|
|
|
$data['plr_agent_depot_wallet_ilink'] = $this->user_model->getPalierConfigWallet("agent_depot_wallet_ilink_international" , $data['idConfig']);
|
|
|
|
$data['plr_agent_depot_autre_wallet'] = $this->user_model->getPalierConfigWallet("agent_depot_autre_wallet_international" , $data['idConfig']);
|
|
|
|
$data['plr_agent_cash_cash'] = $this->user_model->getPalierConfigWallet("agent_cash_cash_international", $data['idConfig']);
|
|
|
|
|
|
|
|
$data['plr_user_wallet_wallet_national'] = $this->user_model->getPalierConfigWallet("user_wallet_wallet_national", $data['idConfig']);
|
|
|
|
$data['plr_user_wallet_cash_national'] = $this->user_model->getPalierConfigWallet("user_wallet_cash_national", $data['idConfig']);
|
|
|
|
$data['plr_agent_depot_wallet_ilink_national'] = $this->user_model->getPalierConfigWallet("agent_depot_wallet_ilink_national" , $data['idConfig']);
|
|
|
|
$data['plr_agent_depot_autre_wallet_national'] = $this->user_model->getPalierConfigWallet("agent_depot_autre_wallet_national" , $data['idConfig']);
|
|
|
|
$data['plr_agent_cash_cash_national'] = $this->user_model->getPalierConfigWallet("agent_cash_cash_national", $data['idConfig']);
|
|
|
|
|
2020-06-10 14:20:30 +00:00
|
|
|
$data['taxes'] = $this->user_model->getTaxes($data['idConfig']);
|
2020-06-13 14:47:09 +00:00
|
|
|
|
2020-06-01 11:21:06 +00:00
|
|
|
$data['taux_u_w_cart'] = $taux->taux_com_user_wallet_carte;
|
|
|
|
$data['taux_u_c_w'] = $taux->taux_com_user_carte_wallet;
|
|
|
|
$data['taux_u_c_c'] = $taux->taux_com_user_carte_cash;
|
|
|
|
$data['taux_ag_d_c_c'] = $taux->taux_com_wallet_ag_envoi_cash_carte;
|
|
|
|
$data['taux_ag_cart_c'] = $taux->taux_com_wallet_ag_carte_cash;
|
|
|
|
$data['taux_ag_cash_c'] = $taux->taux_com_wallet_ag_depot_carte;
|
|
|
|
$data['taux_ag_s_c'] = $taux->taux_com_ag_envoi_cash;
|
|
|
|
$data['taux_sup_s_c'] = $taux->taux_com_sup_envoi_cash;
|
|
|
|
$data['taux_hyp_s_c'] = $taux->taux_com_hyp_envoi_cash;
|
|
|
|
$data['taux_ag_r_c'] = $taux->taux_com_ag_retrait_cash;
|
|
|
|
$data['taux_sup_r_c'] = $taux->taux_com_sup_retrait_cash;
|
|
|
|
$data['taux_hyp_r_c'] = $taux->taux_com_hyp_retrait_cash;
|
|
|
|
$data['taux_ag_d_c'] = $taux->taux_com_ag_depot_cash_carte;
|
|
|
|
$data['taux_sup_d_c'] = $taux->taux_com_sup_depot_cash_carte;
|
|
|
|
$data['taux_hyp_d_c'] = $taux->taux_com_hyp_depot_cash_carte;
|
|
|
|
$data['taux_bq_d_c'] = $taux->taux_com_banque_depot_cash_carte;
|
|
|
|
$data['taux_ag_r_cart'] = $taux->taux_com_ag_retrait_carte_cash;
|
|
|
|
$data['taux_sup_r_cart'] = $taux->taux_com_sup_retrait_carte_cash;
|
|
|
|
$data['taux_hyp_r_cart'] = $taux->taux_com_hyp_retrait_carte_cash;
|
|
|
|
$data['taux_bq_r_cart'] = $taux->taux_com_banque_retrait_carte_cash;
|
2020-06-18 09:07:18 +00:00
|
|
|
$data['taux_hyp_r_cart_ilink'] = $taux->taux_com_hyp_retrait_carte_cash_ilink;
|
|
|
|
$data['taux_bq_r_cart_ilink'] = $taux->taux_com_banque_retrait_carte_cash_ilink;
|
2020-06-01 11:21:06 +00:00
|
|
|
}
|
2020-05-05 08:25:12 +00:00
|
|
|
|
|
|
|
//Create wallet if it not exist
|
|
|
|
$res = $this->user_model->getWallet($agent_id);
|
|
|
|
if ($res == false) {
|
|
|
|
$this->user_model->addWallet($agent_id);
|
|
|
|
$res = $this->user_model->getWallet($agent_id);
|
2020-04-19 08:51:28 +00:00
|
|
|
}
|
|
|
|
|
2020-04-17 15:28:27 +00:00
|
|
|
$row = $res->first_row();
|
2020-05-05 08:25:12 +00:00
|
|
|
$data["commission"] = $row->balance_com;
|
2020-04-17 15:28:27 +00:00
|
|
|
$data["principal"] = $row->balance_princ;
|
2020-05-05 08:25:12 +00:00
|
|
|
$data['wallet_id'] = $row->wallet_id;
|
|
|
|
$agents_g = $this->user_model->getAllGeolocatedUsersForHyp($this->session->userdata('member_code'));
|
2020-04-17 15:28:27 +00:00
|
|
|
|
2020-05-05 08:25:12 +00:00
|
|
|
//Fetch all transactions of any geolocated agent of the network
|
2020-04-17 15:28:27 +00:00
|
|
|
$data["transactions"] = array();
|
2020-04-19 08:51:28 +00:00
|
|
|
$totalCommissionBanque = 0;
|
2020-05-05 08:25:12 +00:00
|
|
|
if ($agents_g) {
|
|
|
|
foreach ($agents_g->result() as $row) {
|
|
|
|
$wallet = $this->user_model->getWallet($row->agent_id);
|
|
|
|
if ($wallet) {
|
2020-04-17 15:28:27 +00:00
|
|
|
$transactions = $this->user_model->getAgentTransactions($wallet->first_row()->wallet_id);
|
2020-05-05 08:25:12 +00:00
|
|
|
if ($transactions) {
|
|
|
|
foreach ($transactions->result() as $trans) {
|
2020-04-19 08:51:28 +00:00
|
|
|
$totalCommissionBanque += $trans->commission_banque;
|
2020-05-05 08:25:12 +00:00
|
|
|
$trans->code_parrain = $row->code_parrain; // Add code parrain to transaction
|
|
|
|
array_push($data['transactions'], $trans);
|
2020-04-17 15:28:27 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2020-04-19 08:51:28 +00:00
|
|
|
$data["totalCommissionBanque"] = $totalCommissionBanque;
|
2020-05-05 08:25:12 +00:00
|
|
|
|
2020-06-01 11:21:06 +00:00
|
|
|
$res = $this->user_model->getWalletPassword($id_network);
|
|
|
|
$data['walletPassword'] = $res ? $res->first_row() : null;
|
|
|
|
$data['alert'] = "";
|
|
|
|
$data['active'] = "wallet";
|
|
|
|
$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['network_id'] = $id_network;
|
|
|
|
$data['country'] = $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['pays'] = $this->user_model->getAllGameCountries();
|
|
|
|
$data['networks'] = $this->user_model->getActiveNetwork();
|
|
|
|
$data['agentWalletInfos'] = $this->user_model->getInfosWalletAgentForHyper($id_network);
|
|
|
|
$this->load->view('header_hyp', $data);
|
2020-06-05 16:53:04 +00:00
|
|
|
if ($data['hasWallet']->first_row()->type == 'visa')
|
2020-06-01 11:21:06 +00:00
|
|
|
$this->load->view('gestion_wallet_hyp');
|
|
|
|
elseif ($data['hasWallet']->first_row()->type == 'ilink')
|
|
|
|
$this->load->view('gestion_wallet_ilink_hyp');
|
|
|
|
$this->load->view('footer');
|
2020-06-08 18:54:36 +00:00
|
|
|
}
|
2020-06-01 11:21:06 +00:00
|
|
|
}
|
2020-06-08 18:54:36 +00:00
|
|
|
}
|
|
|
|
}
|
2020-05-05 08:25:12 +00:00
|
|
|
|
|
|
|
private function isLogged()
|
|
|
|
{
|
|
|
|
if (!$this->session->userdata('email')) {
|
|
|
|
$this->session->set_flashdata('error', 'log in first');
|
|
|
|
|
|
|
|
$data['alert'] = "ok";
|
|
|
|
$data['message'] = "Login first!";
|
|
|
|
$this->load->view('login', $data);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2020-06-08 18:54:36 +00:00
|
|
|
private function historique($network_id, $startDate, $endDate, $type)
|
2020-05-05 08:25:12 +00:00
|
|
|
{
|
2020-06-01 11:21:06 +00:00
|
|
|
$data['configWallet'] = $this->user_model->getConfigWallet($network_id);
|
2020-06-08 18:54:36 +00:00
|
|
|
$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);
|
2020-05-05 08:25:12 +00:00
|
|
|
else
|
2020-06-08 18:54:36 +00:00
|
|
|
$data['transactions'] = $this->user_model->getRecharges($startDate, $endDate, $network_id);
|
2020-05-05 08:25:12 +00:00
|
|
|
|
|
|
|
$data['active'] = "wallet";
|
|
|
|
$data['alert'] = "";
|
|
|
|
$data['firstname'] = $this->session->userdata('firstname');
|
|
|
|
$data['lastname'] = $this->session->userdata('lastname');
|
|
|
|
$data['email'] = $this->session->userdata('email');
|
|
|
|
$data['network'] = $this->session->userdata('network');
|
|
|
|
$data['villes'] = $this->user_model->getVilleByUserGeo($data['network'], $this->session->userdata('current_pays'));
|
|
|
|
$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'));
|
2020-06-08 18:54:36 +00:00
|
|
|
$data['country'] = $this->session->userdata('current_pays');
|
2020-05-05 08:25:12 +00:00
|
|
|
$data['category'] = $this->session->userdata('category');
|
|
|
|
|
|
|
|
$this->load->view('header_hyp', $data);
|
2020-06-08 18:54:36 +00:00
|
|
|
if ($type == 'transaction')
|
2020-05-05 08:25:12 +00:00
|
|
|
$this->load->view('historique_transactions');
|
|
|
|
else
|
|
|
|
$this->load->view('historique_recharges');
|
|
|
|
$this->load->view('footer');
|
|
|
|
}
|
|
|
|
|
2020-06-08 18:54:36 +00:00
|
|
|
public function walletPassword()
|
|
|
|
{
|
|
|
|
if ($this->isLogged()) {
|
2020-05-05 08:25:12 +00:00
|
|
|
$data['active'] = "wallet_password";
|
|
|
|
$data['alert'] = "";
|
|
|
|
$data['firstname'] = $this->session->userdata('firstname');
|
|
|
|
$data['lastname'] = $this->session->userdata('lastname');
|
|
|
|
$data['email'] = $this->session->userdata('email');
|
|
|
|
$data['network'] = $this->session->userdata('network');
|
|
|
|
$data['villes'] = $this->user_model->getVilleByUserGeo($data['network'], $this->session->userdata('current_pays'));
|
|
|
|
$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'));
|
2020-06-08 18:54:36 +00:00
|
|
|
$data['country'] = $this->session->userdata('current_pays');
|
2020-05-05 08:25:12 +00:00
|
|
|
$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;
|
|
|
|
$this->load->view('header_hyp', $data);
|
|
|
|
$this->load->view('wallet_password');
|
|
|
|
$this->load->view('footer');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-06-08 18:54:36 +00:00
|
|
|
public function generate_wallet_password()
|
|
|
|
{
|
|
|
|
if ($this->isLogged()) {
|
2020-05-05 08:25:12 +00:00
|
|
|
if (isset($_POST)) {
|
|
|
|
$network_id = isset($_POST['network_id']) ? $_POST['network_id'] : null;
|
|
|
|
$email = $_POST['email'];
|
|
|
|
// $size = $_POST['size'];
|
2020-06-08 18:54:36 +00:00
|
|
|
$wallet_password_id = isset($_POST['wallet_password_id']) ? $_POST['wallet_password_id'] : null;
|
2020-05-05 08:25:12 +00:00
|
|
|
$network = $_POST['network'];
|
|
|
|
$country = $_POST['country'];
|
|
|
|
|
|
|
|
$password = $this->generate_string();
|
2020-06-08 18:54:36 +00:00
|
|
|
$hash = $this->hashSSHA($password);
|
|
|
|
$encrypted_password = $hash['encrypted'];
|
|
|
|
$salt = $hash['salt'];
|
2020-05-05 08:25:12 +00:00
|
|
|
|
|
|
|
$this->load->library('email');
|
|
|
|
$this->email->from('noreply@ilink-app.com', 'iLink World');
|
|
|
|
$this->email->to($email);
|
|
|
|
|
2020-06-08 18:54:36 +00:00
|
|
|
$this->email->subject($this->lang->line('wallet_password') . ' ' . $network . ' - ' . $country);
|
|
|
|
$this->email->message($this->lang->line('mot de passe') . ' : ' . $password);
|
2020-05-05 08:25:12 +00:00
|
|
|
|
|
|
|
if ($this->email->send()) {
|
2020-06-08 18:54:36 +00:00
|
|
|
if ($wallet_password_id == null)
|
|
|
|
$this->user_model->addWalletPassword($network_id, $encrypted_password, $salt, $email);
|
2020-05-05 08:25:12 +00:00
|
|
|
else
|
2020-06-08 18:54:36 +00:00
|
|
|
$this->user_model->updateWalletPassword($wallet_password_id, $encrypted_password, $salt, $email);
|
2020-05-05 08:25:12 +00:00
|
|
|
$res = true;
|
|
|
|
} else {
|
|
|
|
// show_error($this->email->print_debugger());
|
|
|
|
$res = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($res) {
|
|
|
|
echo json_encode("200");
|
|
|
|
} else {
|
|
|
|
echo json_encode("500");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-06-08 18:54:36 +00:00
|
|
|
private function generate_string($length = 10)
|
|
|
|
{
|
|
|
|
$chars = 'abcdefghjkmnpqrstuvwxyz' .
|
2020-05-05 08:25:12 +00:00
|
|
|
'23456789';
|
|
|
|
|
|
|
|
$str = '';
|
|
|
|
$max = strlen($chars) - 1;
|
|
|
|
|
2020-06-08 18:54:36 +00:00
|
|
|
for ($i = 0; $i < $length; $i++)
|
2020-05-05 08:25:12 +00:00
|
|
|
$str .= $chars[mt_rand(0, $max)];
|
|
|
|
|
|
|
|
return $str;
|
|
|
|
}
|
|
|
|
|
2020-06-08 18:54:36 +00:00
|
|
|
private function hashSSHA($password)
|
|
|
|
{
|
2020-05-05 08:25:12 +00:00
|
|
|
$salt = sha1(rand());
|
|
|
|
$salt = substr($salt, 0, 10);
|
|
|
|
$encrypted = base64_encode(sha1($password . $salt, true) . $salt);
|
|
|
|
$hash = array("salt" => $salt, "encrypted" => $encrypted);
|
|
|
|
return $hash;
|
|
|
|
}
|
|
|
|
|
2020-06-08 18:54:36 +00:00
|
|
|
public function resetWalletPassword()
|
|
|
|
{
|
|
|
|
if ($this->isLogged()) {
|
2020-05-05 08:25:12 +00:00
|
|
|
if (isset($_POST)) {
|
|
|
|
$email = $_POST['email'];
|
2020-06-08 18:54:36 +00:00
|
|
|
$wallet_password_id = isset($_POST['wallet_password_id']) ? $_POST['wallet_password_id'] : null;
|
2020-05-05 08:25:12 +00:00
|
|
|
$network = $_POST['network'];
|
|
|
|
$country = $_POST['country'];
|
|
|
|
|
|
|
|
$password = $this->generate_string();
|
2020-06-08 18:54:36 +00:00
|
|
|
$hash = $this->hashSSHA($password);
|
|
|
|
$encrypted_password = $hash['encrypted'];
|
|
|
|
$salt = $hash['salt'];
|
2020-05-05 08:25:12 +00:00
|
|
|
|
|
|
|
$this->load->library('email');
|
|
|
|
$this->email->from('noreply@ilink-app.com', 'iLink World');
|
|
|
|
$this->email->to($email);
|
|
|
|
|
2020-06-08 18:54:36 +00:00
|
|
|
$this->email->subject($this->lang->line('reset_wallet_password') . ' ' . $network . ' - ' . $country);
|
|
|
|
$this->email->message($this->lang->line('mot de passe') . ' : ' . $password);
|
2020-05-05 08:25:12 +00:00
|
|
|
|
|
|
|
if ($this->email->send()) {
|
2020-06-08 18:54:36 +00:00
|
|
|
$this->user_model->updateWalletPassword($wallet_password_id, $encrypted_password, $salt, $email);
|
2020-05-05 08:25:12 +00:00
|
|
|
$res = true;
|
|
|
|
} else {
|
|
|
|
// show_error($this->email->print_debugger());
|
|
|
|
$res = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($res) {
|
|
|
|
echo json_encode("200");
|
|
|
|
} else {
|
|
|
|
echo json_encode("500");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-06-08 18:54:36 +00:00
|
|
|
public function recharge_wallet()
|
|
|
|
{
|
|
|
|
if ($this->isLogged()) {
|
2020-05-05 08:25:12 +00:00
|
|
|
if (isset($_POST)) {
|
|
|
|
$password = $_POST['password'];
|
|
|
|
$wallet_id = $_POST['wallet_id'];
|
2020-06-08 18:54:36 +00:00
|
|
|
$salt = $_POST['salt'];
|
2020-05-05 08:25:12 +00:00
|
|
|
$encrypted_password = $_POST['encrypted_password'];
|
|
|
|
$montant = $_POST['montant'];
|
|
|
|
|
|
|
|
$hash = base64_encode(sha1($password . $salt, true) . $salt);
|
|
|
|
|
2020-06-08 18:54:36 +00:00
|
|
|
if ($encrypted_password == $hash) {
|
|
|
|
$this->user_model->updateWalletBalance($montant, $wallet_id);
|
|
|
|
$res = $this->user_model->addWalletRecharge($montant, $wallet_id);
|
|
|
|
$code = $res ? '200' : '500';
|
|
|
|
} else {
|
2020-05-05 08:25:12 +00:00
|
|
|
$code = '400';
|
|
|
|
}
|
|
|
|
|
|
|
|
echo json_encode($code);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-06-08 18:54:36 +00:00
|
|
|
public function calculator()
|
|
|
|
{
|
|
|
|
if ($this->isLogged()) {
|
2020-06-05 16:53:04 +00:00
|
|
|
$data['active'] = "calculator";
|
|
|
|
$data['alert'] = "";
|
|
|
|
$data['firstname'] = $this->session->userdata('firstname');
|
|
|
|
$data['lastname'] = $this->session->userdata('lastname');
|
|
|
|
$data['email'] = $this->session->userdata('email');
|
|
|
|
$data['network'] = $this->session->userdata('network');
|
|
|
|
$data['villes'] = $this->user_model->getVilleByUserGeo($data['network'], $this->session->userdata('current_pays'));
|
|
|
|
$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['idConfig'] = $data['hasWallet']->first_row()->id;
|
2020-06-08 18:54:36 +00:00
|
|
|
$data['country'] = $this->session->userdata('current_pays');
|
2020-06-05 16:53:04 +00:00
|
|
|
$data['network_id'] = $this->session->userdata('network_id');
|
|
|
|
$data['countries'] = $this->user_model->getWalletsCountries();
|
2020-06-18 09:07:18 +00:00
|
|
|
$showResult = false;
|
|
|
|
$frais = 0;
|
|
|
|
$taxe = 0;
|
|
|
|
$config = $data['hasWallet']->first_row();
|
|
|
|
|
|
|
|
//Simulateur
|
|
|
|
$com_ag = $this->session->userdata('com_ag') ? $this->session->userdata('com_ag') : 0 ;
|
|
|
|
$com_sup = $this->session->userdata('com_sup') ? $this->session->userdata('com_sup') : 0 ;
|
|
|
|
$com_hyp = $this->session->userdata('com_hyp') ? $this->session->userdata('com_hyp') : 0 ;
|
|
|
|
$com_bq = $this->session->userdata('com_bq') ? $this->session->userdata('com_bq') : 0 ;
|
|
|
|
// $frais_retrait = $this->session->userdata('frais_retrait') ? $this->session->userdata('frais_retrait') : 0 ;
|
|
|
|
|
|
|
|
if (isset($_POST)) {
|
|
|
|
$operation = $this->input->post('operation');
|
|
|
|
$montant = $this->input->post('montant');
|
|
|
|
$init_country = $this->input->post('init_country');
|
|
|
|
$final_country = $this->input->post('final_country');
|
|
|
|
$save = $this->input->post('save');
|
|
|
|
$code = $this->input->post('code');
|
|
|
|
|
|
|
|
|
|
|
|
$taxes = $this->user_model->getTaxes($data['idConfig']);
|
|
|
|
|
|
|
|
$plr_user_wallet_wallet = $this->user_model->getPalierConfigWallet("user_wallet_wallet_international", $data['idConfig']);
|
|
|
|
$plr_user_wallet_cash = $this->user_model->getPalierConfigWallet("user_wallet_cash_international", $data['idConfig']);
|
|
|
|
$plr_agent_depot_wallet_ilink = $this->user_model->getPalierConfigWallet("agent_depot_wallet_ilink_international" , $data['idConfig']);
|
|
|
|
$plr_agent_depot_autre_wallet = $this->user_model->getPalierConfigWallet("agent_depot_autre_wallet_international" , $data['idConfig']);
|
|
|
|
$plr_agent_cash_cash = $this->user_model->getPalierConfigWallet("agent_cash_cash_international", $data['idConfig']);
|
|
|
|
|
|
|
|
$plr_user_wallet_wallet_national= $this->user_model->getPalierConfigWallet("user_wallet_wallet_national", $data['idConfig']);
|
|
|
|
$plr_user_wallet_cash_national = $this->user_model->getPalierConfigWallet("user_wallet_cash_national", $data['idConfig']);
|
|
|
|
$plr_agent_depot_wallet_ilink_national = $this->user_model->getPalierConfigWallet("agent_depot_wallet_ilink_national" , $data['idConfig']);
|
|
|
|
$plr_agent_depot_autre_wallet_national = $this->user_model->getPalierConfigWallet("agent_depot_autre_wallet_national" , $data['idConfig']);
|
|
|
|
$plr_agent_cash_cash_national = $this->user_model->getPalierConfigWallet("agent_cash_cash_national", $data['idConfig']);
|
|
|
|
|
|
|
|
$plr_user_wallet_wallet = $plr_user_wallet_wallet ? $plr_user_wallet_wallet->result() : [];
|
|
|
|
$plr_user_wallet_cash = $plr_user_wallet_cash ? $plr_user_wallet_cash->result() : [];
|
|
|
|
$plr_agent_depot_wallet_ilink = $plr_agent_depot_wallet_ilink ? $plr_agent_depot_wallet_ilink->result() : [];
|
|
|
|
$plr_agent_depot_autre_wallet = $plr_agent_depot_autre_wallet ? $plr_agent_depot_autre_wallet->result() : [];
|
|
|
|
$plr_agent_cash_cash = $plr_agent_cash_cash ? $plr_agent_cash_cash->result() : [];
|
|
|
|
|
|
|
|
$plr_user_wallet_wallet_national = $plr_user_wallet_wallet_national ? $plr_user_wallet_wallet_national->result() : [];
|
|
|
|
$plr_user_wallet_cash_national = $plr_user_wallet_cash_national ? $plr_user_wallet_cash_national->result() : [];
|
|
|
|
$plr_agent_depot_wallet_ilink_national = $plr_agent_depot_wallet_ilink_national ? $plr_agent_depot_wallet_ilink_national->result() : [];
|
|
|
|
$plr_agent_depot_autre_wallet_national = $plr_agent_depot_autre_wallet_national ? $plr_agent_depot_autre_wallet_national->result() : [];
|
|
|
|
$plr_agent_cash_cash_national = $plr_agent_cash_cash_national ? $plr_agent_cash_cash_national->result() : [];
|
|
|
|
|
|
|
|
$taxes = $taxes ? $taxes->result() : [];
|
|
|
|
$taxesNationales = array_filter($taxes, function ($tax) {
|
|
|
|
return $tax->destination == 'national';
|
|
|
|
});
|
|
|
|
|
|
|
|
$taxesInternationales = array_filter($taxes, function ($tax) {
|
|
|
|
return $tax->destination == 'international';
|
|
|
|
});
|
|
|
|
|
|
|
|
if (isset($save)) {
|
|
|
|
$showResult = true;
|
|
|
|
switch ($operation) {
|
|
|
|
case 1: //Envoi wallet à wallet
|
|
|
|
$frais = ($init_country != $final_country) ? $this->calculateFees1($plr_user_wallet_wallet, $montant) : $this->calculateFees1($plr_user_wallet_wallet_national, $montant);
|
|
|
|
$taxe = ($init_country != $final_country) ? $this->calculateTax($taxesInternationales , $frais) : $this->calculateTax($taxesNationales ,$frais);
|
|
|
|
|
|
|
|
$com_hyp += $frais ;
|
|
|
|
$this->session->set_userdata('com_hyp',$com_hyp);
|
|
|
|
break;
|
|
|
|
case 2: //Envoi de wallet à carte
|
|
|
|
$frais = $montant * $config->taux_com_user_wallet_carte / 100;
|
|
|
|
// $taxe = ($init_country != $final_country) ? $this->calculateTax($taxesInternationales , $frais) : $this->calculateTax($taxesNationales ,$frais);
|
|
|
|
|
|
|
|
$com_hyp += $frais ;
|
|
|
|
$this->session->set_userdata('com_hyp',$com_hyp);
|
|
|
|
break;
|
|
|
|
case 3: //Envoi de wallet à cash
|
|
|
|
$frais = ($init_country != $final_country) ? $this->calculateFees1($plr_user_wallet_cash, $montant) : $this->calculateFees1($plr_user_wallet_cash_national, $montant);
|
|
|
|
$taxe = ($init_country != $final_country) ? $this->calculateTax($taxesInternationales , $frais) : $this->calculateTax($taxesNationales ,$frais);
|
|
|
|
|
|
|
|
$com_hyp += $frais ;
|
|
|
|
$this->session->set_userdata('com_hyp',$com_hyp);
|
|
|
|
// $this->session->set_userdata('frais_retrait',$frais);
|
|
|
|
$code = $this->random_string();
|
|
|
|
$data['message_code'] = ''.$code;
|
|
|
|
$this->user_model->insertSimulateur($frais,$montant-$frais-$taxe,$code);
|
|
|
|
break;
|
|
|
|
case 4: //Envoi de wallet à banque
|
|
|
|
// Non disponible
|
|
|
|
//Pas de taxes
|
|
|
|
break;
|
|
|
|
// case 5: //Envoi de carte à wallet
|
|
|
|
// $frais =$montant * $config->taux_com_user_carte_wallet / 100;
|
|
|
|
//// $taxe = ($init_country != $final_country) ? $this->calculateTax($taxesInternationales , $frais) : $this->calculateTax($taxesNationales ,$frais);
|
|
|
|
// break;
|
|
|
|
// case 6: //Envoi de carte à cash
|
|
|
|
// $frais =$montant * $config->taux_com_user_carte_cash / 100;
|
|
|
|
//// $taxe = ($init_country != $final_country) ? $this->calculateTax($taxesInternationales , $frais) : $this->calculateTax($taxesNationales ,$frais);
|
|
|
|
// break;
|
|
|
|
case 9: // Retrait de wallet en cash
|
|
|
|
$frais = ($init_country != $final_country) ? $this->calculateFees1($plr_user_wallet_cash, $montant) : $this->calculateFees1($plr_user_wallet_cash_national, $montant);
|
|
|
|
$taxe = ($init_country != $final_country) ? $this->calculateTax($taxesInternationales , $frais) : $this->calculateTax($taxesNationales ,$frais);
|
|
|
|
|
|
|
|
$com_hyp += $frais ;
|
|
|
|
$this->session->set_userdata('com_hyp',$com_hyp);
|
|
|
|
$code = $this->random_string();
|
|
|
|
$data['message_code'] = ''.$code;
|
|
|
|
$this->user_model->insertSimulateur($frais,$montant-$frais-$taxe,$code);
|
|
|
|
break;
|
|
|
|
case 10: //Retrait de carte vers wallet
|
|
|
|
$frais = $montant * $config->taux_com_user_carte_wallet / 100;
|
|
|
|
|
|
|
|
$com_hyp += $frais * $config->taux_com_hyp_retrait_carte_cash_ilink / 100 ;
|
|
|
|
$com_bq += $frais * $config->taux_com_banque_retrait_carte_cash_ilink / 100 ;
|
|
|
|
$this->session->set_userdata('com_hyp',$com_hyp);$this->session->set_userdata('com_bq',$com_bq);
|
|
|
|
break;
|
|
|
|
case 11: // Retrait de carte vers cash
|
|
|
|
$frais = $montant * $config->taux_com_user_carte_cash / 100;
|
|
|
|
|
|
|
|
$com_hyp += $frais * $config->taux_com_hyp_retrait_carte_cash_ilink / 100 ;
|
|
|
|
$com_bq += $frais * $config->taux_com_banque_retrait_carte_cash_ilink / 100 ;
|
|
|
|
$this->session->set_userdata('com_hyp',$com_hyp);$this->session->set_userdata('com_bq',$com_bq);
|
|
|
|
$code = $this->random_string();
|
|
|
|
$data['message_code'] = ''.$code;
|
|
|
|
$this->user_model->insertSimulateur($frais * $config->taux_com_hyp_retrait_carte_cash / 100,$montant-$frais-$taxe,$code);
|
|
|
|
break;
|
|
|
|
case 12: // Agent - Retrait en cash
|
|
|
|
// empty
|
|
|
|
//Sauvegarder les frais lors de chaque operation d'envoi
|
|
|
|
if(isset($code)){
|
|
|
|
$simulateur = $this->user_model->getSimulateur($code);
|
|
|
|
if($simulateur){
|
|
|
|
$part_ag = $simulateur->first_row()->com_hyp * $config->taux_com_ag_retrait_cash/ 100 ;
|
|
|
|
$part_sup = $simulateur->first_row()->com_hyp * $config->taux_com_sup_retrait_cash/ 100;
|
|
|
|
$com_ag += $part_ag;
|
|
|
|
$com_sup += $part_sup ;
|
|
|
|
$com_hyp -= ($part_ag + $part_sup);
|
|
|
|
$this->session->set_userdata('com_ag',$com_ag);$this->session->set_userdata('com_sup',$com_sup);
|
|
|
|
$this->session->set_userdata('com_hyp',$com_hyp);
|
|
|
|
}else{
|
|
|
|
$data['error_simulateur'] = 'Code de retrait incorrect';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
case 13: // Agent - Retrait de la carte vers cash
|
|
|
|
$frais = $montant * $config->taux_com_wallet_ag_carte_cash / 100;
|
|
|
|
|
|
|
|
$com_ag += $frais * $config->taux_com_ag_retrait_carte_cash/ 100 ;
|
|
|
|
$com_sup += $frais * $config->taux_com_sup_retrait_carte_cash / 100 ;
|
|
|
|
$com_hyp += $frais * $config->taux_com_hyp_retrait_carte_cash / 100 ;
|
|
|
|
$com_bq += $frais * $config->taux_com_banque_retrait_carte_cash / 100 ;
|
|
|
|
$this->session->set_userdata('com_ag',$com_ag);$this->session->set_userdata('com_sup',$com_sup);
|
|
|
|
$this->session->set_userdata('com_hyp',$com_hyp);$this->session->set_userdata('com_bq',$com_bq);
|
|
|
|
break;
|
|
|
|
case 14: // Agent - Envoi de cash vers wallet iLink
|
|
|
|
$frais = ($init_country != $final_country) ? $this->calculateFees1($plr_agent_depot_wallet_ilink, $montant) : $this->calculateFees1($plr_agent_depot_wallet_ilink_national, $montant);
|
|
|
|
$taxe = ($init_country != $final_country) ? $this->calculateTax($taxesInternationales , $frais) : $this->calculateTax($taxesNationales ,$frais);
|
|
|
|
$com_ag += $frais * $config->taux_com_ag_envoi_cash / 100 ;
|
|
|
|
$com_sup += $frais * $config->taux_com_sup_envoi_cash / 100 ;
|
|
|
|
$com_hyp += $frais * $config->taux_com_hyp_envoi_cash / 100 ;
|
|
|
|
$this->session->set_userdata('com_ag',$com_ag);$this->session->set_userdata('com_sup',$com_sup);
|
|
|
|
$this->session->set_userdata('com_hyp',$com_hyp);
|
|
|
|
break;
|
|
|
|
case 15: // Agent - Envoi de cash vers autre wallet
|
|
|
|
$frais = ($init_country != $final_country) ? $this->calculateFees1($plr_agent_depot_autre_wallet, $montant) : $this->calculateFees1($plr_agent_depot_autre_wallet_national, $montant);
|
|
|
|
$taxe = ($init_country != $final_country) ? $this->calculateTax($taxesInternationales , $frais) : $this->calculateTax($taxesNationales ,$frais);
|
|
|
|
$com_ag += $frais * $config->taux_com_ag_envoi_cash / 100 ;
|
|
|
|
$com_sup += $frais * $config->taux_com_sup_envoi_cash / 100 ;
|
|
|
|
$com_hyp += $frais * $config->taux_com_hyp_envoi_cash / 100 ;
|
|
|
|
$this->session->set_userdata('com_ag',$com_ag);$this->session->set_userdata('com_sup',$com_sup);
|
|
|
|
$this->session->set_userdata('com_hyp',$com_hyp);
|
|
|
|
break;
|
|
|
|
case 16: // Agent - Envoi de cash vers une carte visa
|
|
|
|
$frais = $montant * $config->taux_com_wallet_ag_envoi_cash_carte / 100;
|
|
|
|
$com_ag += $frais * $config->taux_com_ag_depot_cash_carte/ 100 ;
|
|
|
|
$com_sup += $frais * $config->taux_com_sup_depot_cash_carte / 100 ;
|
|
|
|
$com_hyp += $frais * $config->taux_com_hyp_depot_cash_carte / 100 ;
|
|
|
|
$com_bq += $frais * $config->taux_com_banque_depot_cash_carte / 100 ;
|
|
|
|
$this->session->set_userdata('com_ag',$com_ag);$this->session->set_userdata('com_sup',$com_sup);
|
|
|
|
$this->session->set_userdata('com_hyp',$com_hyp);$this->session->set_userdata('com_bq',$com_bq);
|
|
|
|
break;
|
|
|
|
case 17: // Agent - Envoi de cash vers cash
|
|
|
|
$frais = ($init_country != $final_country) ? $this->calculateFees1($plr_agent_cash_cash, $montant) : $this->calculateFees1($plr_agent_cash_cash_national, $montant);
|
|
|
|
$taxe = ($init_country != $final_country) ? $this->calculateTax($taxesInternationales , $frais) : $this->calculateTax($taxesNationales ,$frais);
|
|
|
|
$com_ag += $frais * $config->taux_com_ag_envoi_cash / 100 ;
|
|
|
|
$com_sup += $frais * $config->taux_com_sup_envoi_cash / 100 ;
|
|
|
|
$com_hyp += $frais * $config->taux_com_hyp_envoi_cash / 100 ;
|
|
|
|
$this->session->set_userdata('com_ag',$com_ag);$this->session->set_userdata('com_sup',$com_sup);
|
|
|
|
$this->session->set_userdata('com_hyp',$com_hyp);
|
|
|
|
$code = $this->random_string();
|
|
|
|
$data['message_code'] = ''.$code;
|
|
|
|
$this->user_model->insertSimulateur($frais,$montant-$frais-$taxe,$code);
|
|
|
|
break;
|
|
|
|
case 18: // Agent - Envoi de cash vers banque
|
|
|
|
// Indisponible
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
$data['showResult'] = $showResult;
|
|
|
|
$data['frais'] = $frais;
|
|
|
|
$data['taxe'] = $taxe;
|
|
|
|
|
|
|
|
$data['operation'] = $operation;
|
|
|
|
$data['init_country'] = $init_country;
|
|
|
|
$data['final_country'] = $final_country;
|
|
|
|
|
|
|
|
$data['com_ag'] = $com_ag;
|
|
|
|
$data['com_sup'] = $com_sup;
|
|
|
|
$data['com_hyp'] = $com_hyp;
|
|
|
|
$data['com_bq'] = $com_bq;
|
|
|
|
|
2020-06-05 16:53:04 +00:00
|
|
|
$operations = [
|
2020-06-08 18:54:36 +00:00
|
|
|
new Operation(1, $this->lang->line('op1')),
|
2020-06-10 14:20:30 +00:00
|
|
|
new Operation(2, $this->lang->line('op2')),
|
|
|
|
new Operation(3, $this->lang->line('op3')),
|
2020-06-13 14:47:09 +00:00
|
|
|
new Operation(4, $this->lang->line('op4')),
|
|
|
|
// new Operation(5, $this->lang->line('op5')),
|
|
|
|
// new Operation(6, $this->lang->line('op6')),
|
2020-06-10 14:20:30 +00:00
|
|
|
// new Operation(7, $this->lang->line('op7')),
|
|
|
|
// new Operation(8, $this->lang->line('op8')),
|
|
|
|
new Operation(9, $this->lang->line('op9')),
|
|
|
|
new Operation(10, $this->lang->line('op10')),
|
|
|
|
new Operation(11, $this->lang->line('op11')),
|
2020-06-13 14:47:09 +00:00
|
|
|
new Operation(12, $this->lang->line('op12')),
|
|
|
|
new Operation(13, $this->lang->line('op13')),
|
|
|
|
new Operation(14, $this->lang->line('op14')),
|
|
|
|
new Operation(15, $this->lang->line('op15')),
|
|
|
|
new Operation(16, $this->lang->line('op16')),
|
|
|
|
new Operation(17, $this->lang->line('op17')),
|
|
|
|
new Operation(18, $this->lang->line('op18')),
|
2020-06-05 16:53:04 +00:00
|
|
|
];
|
|
|
|
$data['operations'] = $operations;
|
|
|
|
// if (isset($_POST)) {
|
|
|
|
// $data['montant'] = isset($_POST['montant']) ? $_POST['montant'] : 0 ;
|
|
|
|
// }
|
|
|
|
$data['montant'] = $this->input->post('montant');
|
|
|
|
$this->load->view('header_hyp', $data);
|
|
|
|
$this->load->view('calculator');
|
|
|
|
$this->load->view('footer');
|
|
|
|
}
|
|
|
|
}
|
2020-06-18 09:07:18 +00:00
|
|
|
|
|
|
|
//Calcul des frais internationaux
|
|
|
|
function calculateFees1(array $paliers, $montant)
|
|
|
|
{
|
|
|
|
$size = sizeof($paliers);
|
|
|
|
$min = $paliers[0]->min;
|
|
|
|
$max = $size > 0 ? $paliers[$size - 1]->max : 0;
|
|
|
|
$palier = null;
|
|
|
|
foreach ($paliers as $p) {
|
|
|
|
if ($montant >= $p->min && $montant <= $p->max) {
|
|
|
|
$palier = $p;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($palier) {
|
|
|
|
return (($palier->min + $palier->max) / 2 * $palier->taux / 100);
|
|
|
|
} else {
|
|
|
|
if ($montant < $min)
|
|
|
|
return $min * $paliers[0]->taux / 100;
|
|
|
|
else if ($montant > $max)
|
|
|
|
return $max * $paliers[$size - 1]->taux / 100;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//Calcul des frais nationaux
|
|
|
|
function calculateFees2($min, $max, $taux, $montant)
|
|
|
|
{
|
|
|
|
if ($montant < $min)
|
|
|
|
return $min * $taux / 100;
|
|
|
|
else if ($montant > $max)
|
|
|
|
return $max * $taux / 100;
|
|
|
|
else
|
|
|
|
return $montant * $taux / 100;
|
|
|
|
}
|
|
|
|
|
|
|
|
//Calcul des taxes
|
|
|
|
function calculateTax(array $taxes, $frais)
|
|
|
|
{
|
|
|
|
$sommeTaux = 0;
|
|
|
|
$sommeFixe = 0;
|
|
|
|
foreach ($taxes as $tax) {
|
|
|
|
if ($tax->type == '%')
|
|
|
|
$sommeTaux += $tax->valeur;
|
|
|
|
|
|
|
|
if ($tax->type == 'fixe')
|
|
|
|
$sommeFixe += $tax->valeur;
|
|
|
|
}
|
|
|
|
return ($frais * $sommeTaux / 100) + $sommeFixe;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function random_string()
|
|
|
|
{
|
|
|
|
$character_set_array = array();
|
|
|
|
$character_set_array[] = array('count' => 7, 'characters' => 'abcdefghjkmnpqrstuvwxyz');
|
|
|
|
$character_set_array[] = array('count' => 1, 'characters' => '23456789');
|
|
|
|
$temp_array = array();
|
|
|
|
foreach ($character_set_array as $character_set) {
|
|
|
|
for ($i = 0; $i < $character_set['count']; $i++) {
|
|
|
|
$temp_array[] = $character_set['characters'][rand(0, strlen($character_set['characters']) - 1)];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
shuffle($temp_array);
|
|
|
|
return implode('', $temp_array);
|
|
|
|
}
|
2020-06-05 16:53:04 +00:00
|
|
|
}
|
|
|
|
|
2020-06-08 18:54:36 +00:00
|
|
|
class Operation
|
|
|
|
{
|
|
|
|
public $name;
|
2020-06-05 16:53:04 +00:00
|
|
|
public $id;
|
|
|
|
|
2020-06-08 18:54:36 +00:00
|
|
|
public function __construct($id, $name)
|
2020-06-05 16:53:04 +00:00
|
|
|
{
|
|
|
|
$this->name = $name;
|
|
|
|
$this->id = $id;
|
|
|
|
}
|
2020-04-17 15:28:27 +00:00
|
|
|
}
|