+ Cancel Credit Request
This commit is contained in:
parent
14d096a559
commit
68ffad6bf1
|
@ -677,7 +677,6 @@ class Hyperviseur_dash extends CI_Controller
|
||||||
if (isset($_POST)) {
|
if (isset($_POST)) {
|
||||||
$id_demand = $_POST['id_demand'];
|
$id_demand = $_POST['id_demand'];
|
||||||
$res = $this->user_model->cancelCreditRequest($id_demand);
|
$res = $this->user_model->cancelCreditRequest($id_demand);
|
||||||
|
|
||||||
if ($res) {
|
if ($res) {
|
||||||
echo json_encode("200");
|
echo json_encode("200");
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -218,67 +218,98 @@ class Superviseur_dash extends CI_Controller
|
||||||
$agent_id = $this->session->userdata('agent_id');
|
$agent_id = $this->session->userdata('agent_id');
|
||||||
$data['hasWallet'] = $this->user_model->getConfigWallet($this->session->userdata('network_id'));
|
$data['hasWallet'] = $this->user_model->getConfigWallet($this->session->userdata('network_id'));
|
||||||
|
|
||||||
//Create wallet if it not exist
|
if ($this->input->get('history')) {
|
||||||
$res = $this->user_model->getWallet($agent_id );
|
$this->historique($id_network, $this->input->get('d'), $this->input->get('f'), $this->session->userdata('member_code'));
|
||||||
if($res == false){
|
} else {
|
||||||
if($data['hasWallet']){
|
//Create wallet if it not exist
|
||||||
$this->user_model->addWallet($agent_id );
|
$res = $this->user_model->getWallet($agent_id );
|
||||||
|
if($res == false){
|
||||||
|
if($data['hasWallet']){
|
||||||
|
$this->user_model->addWallet($agent_id );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
$res = $this->user_model->getWallet($agent_id);
|
$res = $this->user_model->getWallet($agent_id);
|
||||||
if ($res!=null){
|
if ($res!=null){
|
||||||
$row = $res->first_row();
|
$row = $res->first_row();
|
||||||
$data["commission"] = $row->balance_com;
|
$data["commission"] = $row->balance_com;
|
||||||
$data["principal"] = $row->balance_princ;
|
$data["principal"] = $row->balance_princ;
|
||||||
$agents_g = $this->user_model->getUsersGeolocatedForSup($this->session->userdata('member_code'));
|
$agents_g = $this->user_model->getUsersGeolocatedForSup($this->session->userdata('member_code'));
|
||||||
$data['agents_g'] = $agents_g;
|
$data['agents_g'] = $agents_g;
|
||||||
|
|
||||||
//Fetch all transactions of any geolocated agent of the network
|
//Fetch all transactions of any geolocated agent of the network
|
||||||
$data["transactions"] = array();
|
$data["transactions"] = array();
|
||||||
if($agents_g){
|
if($agents_g){
|
||||||
foreach($agents_g->result() AS $row){
|
foreach($agents_g->result() AS $row){
|
||||||
$wallet = $this->user_model->getWallet($row->agent_id);
|
$wallet = $this->user_model->getWallet($row->agent_id);
|
||||||
if($wallet){
|
if($wallet){
|
||||||
$transactions = $this->user_model->getAgentTransactions($wallet->first_row()->wallet_id);
|
$transactions = $this->user_model->getAgentTransactions($wallet->first_row()->wallet_id);
|
||||||
if($transactions){
|
if($transactions){
|
||||||
foreach($transactions->result() AS $trans){
|
foreach($transactions->result() AS $trans){
|
||||||
$trans->agent_id = $row->agent_id ; // Add agent id to transaction
|
$trans->agent_id = $row->agent_id ; // Add agent id to transaction
|
||||||
array_push( $data['transactions'], $trans);
|
array_push( $data['transactions'], $trans);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}else{
|
||||||
|
$data["commission"] = "N/A";
|
||||||
|
$data["principal"] = "N/A";
|
||||||
|
$data["totalCommissionBanque"] = "N/A";
|
||||||
|
$data["transactions"] = false;
|
||||||
}
|
}
|
||||||
}else{
|
|
||||||
$data["commission"] = "N/A";
|
|
||||||
$data["principal"] = "N/A";
|
$data['alert'] = "";
|
||||||
$data["totalCommissionBanque"] = "N/A";
|
$data['active'] = "wallet";
|
||||||
$data["transactions"] = false;
|
$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['villes'] = $this->user_model->getVilleByUserGeo($data['network'],$this->session->userdata('current_pays'));
|
||||||
|
$data['pays'] = $this->user_model->getAllGameCountries();
|
||||||
|
$data['networks'] = $this->user_model->getActiveNetwork();
|
||||||
|
$data['agentWalletInfos'] = $this->user_model->getInfosWalletAgentForHyper($id_network);
|
||||||
|
$data['geolocated_user'] = $this->user_model->getSuperNameAndCodeForSup($this->session->userdata('member_code'));
|
||||||
|
$this->load->view('header_sup',$data);
|
||||||
|
$this->load->view('gestion_wallet_sup');
|
||||||
|
$this->load->view('footer');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
$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['villes'] = $this->user_model->getVilleByUserGeo($data['network'],$this->session->userdata('current_pays'));
|
|
||||||
$data['pays'] = $this->user_model->getAllGameCountries();
|
|
||||||
$data['networks'] = $this->user_model->getActiveNetwork();
|
|
||||||
$data['agentWalletInfos'] = $this->user_model->getInfosWalletAgentForHyper($id_network);
|
|
||||||
$data['geolocated_user'] = $this->user_model->getSuperNameAndCodeForSup($this->session->userdata('member_code'));
|
|
||||||
$this->load->view('header_sup',$data);
|
|
||||||
$this->load->view('gestion_wallet_sup');
|
|
||||||
$this->load->view('footer');
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function historique($network_id, $startDate, $endDate, $codeMembre)
|
||||||
|
{
|
||||||
|
$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"));
|
||||||
|
$data['transactions'] = $this->user_model->getTransactionsSup($startDate, $endDate, $codeMembre);
|
||||||
|
|
||||||
|
$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'));
|
||||||
|
$data['country'] = $this->session->userdata('current_pays');
|
||||||
|
$data['category'] = $this->session->userdata('category');
|
||||||
|
|
||||||
|
$this->load->view('header_sup', $data);
|
||||||
|
$this->load->view('historique_transactions');
|
||||||
|
$this->load->view('footer');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1883,6 +1883,18 @@ class User_model extends CI_Model
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getTransactionsSup($debut , $fin , $codeMembre){
|
||||||
|
$chain = $debut ? " AND date_created BETWEEN '".$debut."' AND '".$fin."'" : "";
|
||||||
|
$query = $this->db->query("SELECT *
|
||||||
|
FROM infos_transaction
|
||||||
|
WHERE `codeParrain`='".$codeMembre."'".$chain);
|
||||||
|
if($query->num_rows()>0){
|
||||||
|
return $query;
|
||||||
|
}else{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public function getInfosWalletAgentForHyper($id_network){
|
public function getInfosWalletAgentForHyper($id_network){
|
||||||
$query = $this->db->query("SELECT *
|
$query = $this->db->query("SELECT *
|
||||||
FROM wallet_agent
|
FROM wallet_agent
|
||||||
|
@ -2348,13 +2360,13 @@ class User_model extends CI_Model
|
||||||
$sql = "UPDATE wallets SET balance_princ = ? WHERE (`id` = ?);";
|
$sql = "UPDATE wallets SET balance_princ = ? WHERE (`id` = ?);";
|
||||||
$montant = $demand->montant;
|
$montant = $demand->montant;
|
||||||
$montantAgent = $query->first_row()->balance_princ - $montant;
|
$montantAgent = $query->first_row()->balance_princ - $montant;
|
||||||
$montantParrain = $query->first_row()->balance_princ + $montant;
|
$montantParrain = $query2->first_row()->balance_princ + $montant;
|
||||||
|
|
||||||
$this->db->query($sql , $montantAgent , $query->first_row()->wallet_id );
|
$this->db->query($sql , array($montantAgent , $query->first_row()->wallet_id ));
|
||||||
$this->db->query($sql , $montantParrain , $query2->first_row()->wallet_id);
|
$this->db->query($sql , array($montantParrain , $query2->first_row()->wallet_id));
|
||||||
|
|
||||||
$sql = "UPDATE `demandeCredits` SET `status` = '2' WHERE (`id` = ?);";
|
$sql = "UPDATE `demandeCredits` SET `status` = '2' WHERE (`id` = ?);";
|
||||||
$this->db->query($sql , $demand->demande_id);
|
$this->db->query($sql , array($demand->demande_id));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,6 +15,11 @@ extract($_POST);
|
||||||
$showResult = false;
|
$showResult = false;
|
||||||
$frais = 0;
|
$frais = 0;
|
||||||
$config = $hasWallet->first_row();
|
$config = $hasWallet->first_row();
|
||||||
|
$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 = $plr_agent_depot_wallet ? $plr_agent_depot_wallet->result() : [];
|
||||||
|
$plr_agent_cash_cash = $plr_agent_cash_cash ? $plr_agent_cash_cash->result() : [];
|
||||||
|
|
||||||
if(isset($save))
|
if(isset($save))
|
||||||
{
|
{
|
||||||
$showResult = true;
|
$showResult = true;
|
||||||
|
@ -41,12 +46,12 @@ function calculateFees1(array $paliers , $montant){
|
||||||
}
|
}
|
||||||
|
|
||||||
if($palier){
|
if($palier){
|
||||||
return (($palier->min * $palier->taux /100 ) + ($palier->max * $palier->taux /100 ))/2;
|
return (($palier->min + $palier->max)/2 * $palier->taux /100 );
|
||||||
}else{
|
}else{
|
||||||
if($montant < $min)
|
if($montant < $min)
|
||||||
return $min* $paliers[0]->taux /100;
|
return $min* $paliers[0]->taux /100;
|
||||||
else if ($montant > $max)
|
else if ($montant > $max)
|
||||||
return $max* $paliers[$size-1]->taux /100;
|
return $max*$paliers[$size-1]->taux /100;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -213,6 +213,7 @@
|
||||||
<th>" . $this->lang->line('Date de traitement') . "</th>
|
<th>" . $this->lang->line('Date de traitement') . "</th>
|
||||||
<th>" . $this->lang->line('Statut') . "</th>
|
<th>" . $this->lang->line('Statut') . "</th>
|
||||||
<th>" . $this->lang->line('Délai de traitement') . "</th>
|
<th>" . $this->lang->line('Délai de traitement') . "</th>
|
||||||
|
<th>Action</th>
|
||||||
</tr>";
|
</tr>";
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
@ -227,8 +228,10 @@
|
||||||
foreach ($result->result() as $row) {
|
foreach ($result->result() as $row) {
|
||||||
$num++;
|
$num++;
|
||||||
$etat = $this->lang->line("Non traitée");
|
$etat = $this->lang->line("Non traitée");
|
||||||
|
$disabled ="disabled";
|
||||||
if ($row->statut == 1) {
|
if ($row->statut == 1) {
|
||||||
$etat = $this->lang->line("Acceptée");
|
$etat = $this->lang->line("Acceptée");
|
||||||
|
$disabled="";
|
||||||
} else if ($row->statut == 2) {
|
} else if ($row->statut == 2) {
|
||||||
$etat = $this->lang->line("Annulée");
|
$etat = $this->lang->line("Annulée");
|
||||||
}
|
}
|
||||||
|
@ -248,7 +251,11 @@
|
||||||
<td > ".toLocateDate($row->dateModif,$this->session->userdata('timezone'))."</td>
|
<td > ".toLocateDate($row->dateModif,$this->session->userdata('timezone'))."</td>
|
||||||
<td>$etat</td>
|
<td>$etat</td>
|
||||||
<td>" . traitementTemps($row->temps, $row->dateAjout) . "</td>
|
<td>" . traitementTemps($row->temps, $row->dateAjout) . "</td>
|
||||||
|
<td>
|
||||||
|
<button data-id-demand=\"$row->demande_id\" class=\"btn btn-danger btn-block cancelBtn\"".$disabled ."
|
||||||
|
<b>".$this->lang->line('cancel')."</b>
|
||||||
|
</button>
|
||||||
|
</td>
|
||||||
</tr>";
|
</tr>";
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -743,8 +750,10 @@
|
||||||
foreach ($result->result() as $row) {
|
foreach ($result->result() as $row) {
|
||||||
$num++;
|
$num++;
|
||||||
$etat = $this->lang->line("Non traitée");
|
$etat = $this->lang->line("Non traitée");
|
||||||
|
$disabled="disabled";
|
||||||
if ($row->statut == 1) {
|
if ($row->statut == 1) {
|
||||||
$etat = $this->lang->line("Acceptée");
|
$etat = $this->lang->line("Acceptée");
|
||||||
|
$disabled = "";
|
||||||
} else if ($row->statut == 2) {
|
} else if ($row->statut == 2) {
|
||||||
$etat = $this->lang->line("Annulée");
|
$etat = $this->lang->line("Annulée");
|
||||||
}
|
}
|
||||||
|
@ -766,9 +775,9 @@
|
||||||
<td>".toLocateDate($row->dateAjout,$this->session->userdata('timezone'))."</td>
|
<td>".toLocateDate($row->dateAjout,$this->session->userdata('timezone'))."</td>
|
||||||
<td> ".toLocateDate($row->dateModif,$this->session->userdata('timezone'))."</td>
|
<td> ".toLocateDate($row->dateModif,$this->session->userdata('timezone'))."</td>
|
||||||
<td>$etat</td>
|
<td>$etat</td>
|
||||||
<td>" . traitementTemps($row->temps, $row->dateAjout) . "</td>
|
<td>" . traitementTemps($row->temps, $row->dateAjout) . "</td>1
|
||||||
<td>
|
<td>
|
||||||
<button data-id-demand=\"$row->demande_id\" id=\"cancel\" class=\"btn btn-danger btn-block\" <?php if($row->statut == 1) echo \"disabled\"?>
|
<button data-id-demand=\"$row->demande_id\" class=\"btn btn-danger btn-block cancelBtn\"".$disabled ."
|
||||||
<b>".$this->lang->line('cancel')."</b>
|
<b>".$this->lang->line('cancel')."</b>
|
||||||
</button>
|
</button>
|
||||||
</td>
|
</td>
|
||||||
|
@ -1215,23 +1224,23 @@
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
<script>
|
<script>
|
||||||
$(document).on("click", "#cancel", function () {
|
$(document).on("click", ".cancelBtn", function () {
|
||||||
const id_demand = $(this).data('id-demand');
|
const id_demand = $(this).data('id-demand');
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url : '<?php echo base_url('index.php/Hyperviseur_dash/cancelCreditRequest')?>',
|
url : '<?php echo base_url('index.php/Hyperviseur_dash/cancelCreditRequest')?>',
|
||||||
type : 'POST',
|
type : 'POST',
|
||||||
|
dataType : 'json',
|
||||||
data: {"id_demand": id_demand},
|
data: {"id_demand": id_demand},
|
||||||
async:true,
|
async:true,
|
||||||
success : function(data){
|
success : function(data){
|
||||||
console.log('rep',data);
|
if(data=='200'){
|
||||||
if(data == 200){
|
|
||||||
Swal.fire({
|
Swal.fire({
|
||||||
icon: 'success',
|
icon: 'success',
|
||||||
title: "<?php echo $this->lang->line('canceled_credit_request')?>",
|
title: "<?php echo $this->lang->line('canceled_credit_request')?>",
|
||||||
text: "<?php echo $this->lang->line('informations_updated')?>",
|
text: "<?php echo $this->lang->line('informations_updated')?>",
|
||||||
timer: 3000
|
timer: 3000
|
||||||
}).then(()=>{
|
}).then(()=>{
|
||||||
location.reload();
|
location.reload();
|
||||||
});
|
});
|
||||||
// alert("Les informations ont été mises à jour.") ? "" : location.reload();
|
// alert("Les informations ont été mises à jour.") ? "" : location.reload();
|
||||||
}else{
|
}else{
|
||||||
|
|
|
@ -201,6 +201,11 @@ $fmt = new NumberFormatter( 'fr_FR', NumberFormatter::DECIMAL );
|
||||||
<div class="box box-success">
|
<div class="box box-success">
|
||||||
<div class="box-header with-border">
|
<div class="box-header with-border">
|
||||||
<h3 class="box-title"><?php echo $this->lang->line('Historique des 12 derniers mois'); ?></h3>
|
<h3 class="box-title"><?php echo $this->lang->line('Historique des 12 derniers mois'); ?></h3>
|
||||||
|
<div class="box-tools">
|
||||||
|
<a class="btn btn-primary" href="<?php echo current_url().($network_id ? '?history=transaction' : '')?>">
|
||||||
|
<?php echo $this->lang->line('transactions_historic'); ?>
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="box-body">
|
<div class="box-body">
|
||||||
<div class="chart" id="chart">
|
<div class="chart" id="chart">
|
||||||
|
|
Loading…
Reference in New Issue