+ Cancel transaction

This commit is contained in:
Djery-Tom 2020-06-08 19:54:36 +01:00
parent 60a1f1149d
commit 14d096a559
7 changed files with 483 additions and 305 deletions

View File

@ -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");
}
}
}
}
} }

View File

@ -1,12 +1,12 @@
<?php <?php
defined('BASEPATH') OR exit('No direct script access allowed'); defined('BASEPATH') or exit('No direct script access allowed');
/** /**
* Created by PhpStorm. * Created by PhpStorm.
* User: Hanry Nzale * User: Hanry Nzale
* Date: 03/08/2018 * Date: 03/08/2018
* Time: 02:03 * Time: 02:03
*/ */
class Hyperviseur_dash extends CI_Controller class Hyperviseur_dash extends CI_Controller
{ {
public function _contruct() public function _contruct()
@ -60,7 +60,8 @@ class Hyperviseur_dash extends CI_Controller
} }
} }
public function getAllUser_g(){ public function getAllUser_g()
{
if (!$this->session->userdata('email')) { if (!$this->session->userdata('email')) {
$this->session->set_flashdata('error', 'log in first'); $this->session->set_flashdata('error', 'log in first');
@ -69,11 +70,9 @@ class Hyperviseur_dash extends CI_Controller
$data['message'] = "Login first!"; $data['message'] = "Login first!";
redirect('index.php', $data); redirect('index.php', $data);
} } else {
else {
if($this->input->post('ville')) if ($this->input->post('ville')) {
{
$this->session->set_userdata('current_ville', $this->input->post('ville')); $this->session->set_userdata('current_ville', $this->input->post('ville'));
} }
@ -105,7 +104,8 @@ class Hyperviseur_dash extends CI_Controller
} }
public function getAllSupervisor(){ public function getAllSupervisor()
{
if (!$this->session->userdata('email')) { if (!$this->session->userdata('email')) {
$this->session->set_flashdata('error', 'log in first'); $this->session->set_flashdata('error', 'log in first');
@ -115,8 +115,7 @@ class Hyperviseur_dash extends CI_Controller
redirect('index.php', $data); redirect('index.php', $data);
} } else {
else {
/*$this->db->select('*'); /*$this->db->select('*');
$this->db->from('users'); $this->db->from('users');
@ -159,7 +158,8 @@ class Hyperviseur_dash extends CI_Controller
} }
} }
public function getAllSupervisorPositions(){ public function getAllSupervisorPositions()
{
if (!$this->session->userdata('email')) { if (!$this->session->userdata('email')) {
$this->session->set_flashdata('error', 'log in first'); $this->session->set_flashdata('error', 'log in first');
@ -168,8 +168,7 @@ class Hyperviseur_dash extends CI_Controller
redirect('index.php', $data); redirect('index.php', $data);
} } else {
else {
$network = $this->session->userdata('network'); $network = $this->session->userdata('network');
$category = 'super'; $category = 'super';
@ -180,7 +179,8 @@ class Hyperviseur_dash extends CI_Controller
} }
} }
public function getDemandes(){ public function getDemandes()
{
if (!$this->session->userdata('email')) { if (!$this->session->userdata('email')) {
$this->session->set_flashdata('error', 'log in first'); $this->session->set_flashdata('error', 'log in first');
@ -188,8 +188,7 @@ class Hyperviseur_dash extends CI_Controller
$data['message'] = "Login first!"; $data['message'] = "Login first!";
$this->load->view('login', $data); $this->load->view('login', $data);
} else { } else {
if($this->input->get("u") !== null) if ($this->input->get("u") !== null) {
{
$super = $this->input->get("u"); $super = $this->input->get("u");
$this->session->set_userdata("current_super_demande", $super); $this->session->set_userdata("current_super_demande", $super);
@ -237,7 +236,8 @@ class Hyperviseur_dash extends CI_Controller
} }
} }
public function addvilles(){ public function addvilles()
{
$id = 1; $id = 1;
$date = "2018-08-29"; $date = "2018-08-29";
for ($i = 1; $i <= 267; $i++) { for ($i = 1; $i <= 267; $i++) {
@ -255,7 +255,8 @@ class Hyperviseur_dash extends CI_Controller
} }
} }
public function getDemandesAd(){ public function getDemandesAd()
{
if (!$this->session->userdata('email')) { if (!$this->session->userdata('email')) {
$this->session->set_flashdata('error', 'log in first'); $this->session->set_flashdata('error', 'log in first');
@ -297,7 +298,8 @@ class Hyperviseur_dash extends CI_Controller
} }
// Wallet // Wallet
public function wallet(){ public function wallet()
{
if (!$this->session->userdata('email')) { if (!$this->session->userdata('email')) {
$this->session->set_flashdata('error', 'log in first'); $this->session->set_flashdata('error', 'log in first');
@ -480,7 +482,8 @@ class Hyperviseur_dash extends CI_Controller
$this->load->view('footer'); $this->load->view('footer');
} }
public function walletPassword(){ public function walletPassword()
{
if ($this->isLogged()) { if ($this->isLogged()) {
$data['active'] = "wallet_password"; $data['active'] = "wallet_password";
$data['alert'] = ""; $data['alert'] = "";
@ -502,7 +505,8 @@ class Hyperviseur_dash extends CI_Controller
} }
} }
public function generate_wallet_password(){ public function generate_wallet_password()
{
if ($this->isLogged()) { if ($this->isLogged()) {
if (isset($_POST)) { if (isset($_POST)) {
$network_id = isset($_POST['network_id']) ? $_POST['network_id'] : null; $network_id = isset($_POST['network_id']) ? $_POST['network_id'] : null;
@ -544,7 +548,8 @@ class Hyperviseur_dash extends CI_Controller
} }
} }
private function generate_string($length = 10){ private function generate_string($length = 10)
{
$chars = 'abcdefghjkmnpqrstuvwxyz' . $chars = 'abcdefghjkmnpqrstuvwxyz' .
'23456789'; '23456789';
@ -557,7 +562,8 @@ class Hyperviseur_dash extends CI_Controller
return $str; return $str;
} }
private function hashSSHA($password) { private function hashSSHA($password)
{
$salt = sha1(rand()); $salt = sha1(rand());
$salt = substr($salt, 0, 10); $salt = substr($salt, 0, 10);
$encrypted = base64_encode(sha1($password . $salt, true) . $salt); $encrypted = base64_encode(sha1($password . $salt, true) . $salt);
@ -565,7 +571,8 @@ class Hyperviseur_dash extends CI_Controller
return $hash; return $hash;
} }
public function resetWalletPassword(){ public function resetWalletPassword()
{
if ($this->isLogged()) { if ($this->isLogged()) {
if (isset($_POST)) { if (isset($_POST)) {
$email = $_POST['email']; $email = $_POST['email'];
@ -602,7 +609,8 @@ class Hyperviseur_dash extends CI_Controller
} }
} }
public function recharge_wallet(){ public function recharge_wallet()
{
if ($this->isLogged()) { if ($this->isLogged()) {
if (isset($_POST)) { if (isset($_POST)) {
$password = $_POST['password']; $password = $_POST['password'];
@ -627,7 +635,8 @@ class Hyperviseur_dash extends CI_Controller
} }
} }
public function calculator(){ public function calculator()
{
if ($this->isLogged()) { if ($this->isLogged()) {
$data['active'] = "calculator"; $data['active'] = "calculator";
$data['alert'] = ""; $data['alert'] = "";
@ -643,7 +652,7 @@ class Hyperviseur_dash extends CI_Controller
$data['country'] = $this->session->userdata('current_pays'); $data['country'] = $this->session->userdata('current_pays');
$data['network_id'] = $this->session->userdata('network_id'); $data['network_id'] = $this->session->userdata('network_id');
$data['countries'] = $this->user_model->getWalletsCountries(); $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_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_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_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_agent_cash_cash'] = $this->user_model->getPalierConfigWallet("agent_cash_cash", $data['idConfig']);
@ -661,9 +670,26 @@ class Hyperviseur_dash extends CI_Controller
$this->load->view('footer'); $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 { class Operation
{
public $name; public $name;
public $id; public $id;

View File

@ -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['amount_country_of_destination'] = 'Montant du pays de destination';
$lang['no_operation'] = 'Aucune opération'; $lang['no_operation'] = 'Aucune opération';
$lang['agent_name'] = 'Nom de l\'agent'; $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'; $lang['op1'] = 'Envoi de wallet à wallet';
?> ?>

View File

@ -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;
}
}
} }

View File

@ -1,7 +1,7 @@
<!-- DataTables --> <!-- DataTables -->
<link rel="stylesheet" <link rel="stylesheet"
href="<?php echo base_url('bower_components/datatables.net-bs/css/dataTables.bootstrap.min.css') ?>"> href="<?php echo base_url('bower_components/datatables.net-bs/css/dataTables.bootstrap.min.css') ?>">
<link rel="stylesheet" href="<?php echo base_url('bower_components/toastr/toastr.css') ?>">
<div class="content-wrapper"> <div class="content-wrapper">
<?php <?php
@ -730,6 +730,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>";
?> ?>
</thead> </thead>
@ -766,7 +767,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\" id=\"cancel\" class=\"btn btn-danger btn-block\" <?php if($row->statut == 1) echo \"disabled\"?>
<b>".$this->lang->line('cancel')."</b>
</button>
</td>
</tr>"; </tr>";
} }
@ -972,6 +977,8 @@
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/daterangepicker/daterangepicker.min.js"></script> <script type="text/javascript" src="https://cdn.jsdelivr.net/npm/daterangepicker/daterangepicker.min.js"></script>
<script type="text/javascript" src="https://cdn.datatables.net/plug-ins/1.10.19/sorting/datetime-moment.js"></script> <script type="text/javascript" src="https://cdn.datatables.net/plug-ins/1.10.19/sorting/datetime-moment.js"></script>
<script type="text/javascript" src="https://cdn.datatables.net/plug-ins/1.10.20/dataRender/datetime.js"></script> <script type="text/javascript" src="https://cdn.datatables.net/plug-ins/1.10.20/dataRender/datetime.js"></script>
<script src="<?php echo base_url('dist/js/sweetalert2.js') ?>"></script>
<script src="<?php echo base_url('bower_components/toastr/toastr.js') ?>"></script>
<script> <script>
$(function () { $(function () {
@ -1207,3 +1214,35 @@
}); });
}); });
</script> </script>
<script>
$(document).on("click", "#cancel", function () {
const id_demand = $(this).data('id-demand');
$.ajax({
url : '<?php echo base_url('index.php/Hyperviseur_dash/cancelCreditRequest')?>',
type : 'POST',
data: {"id_demand": id_demand},
async:true,
success : function(data){
console.log('rep',data);
if(data == 200){
Swal.fire({
icon: 'success',
title: "<?php echo $this->lang->line('canceled_credit_request')?>",
text: "<?php echo $this->lang->line('informations_updated')?>",
timer: 3000
}).then(()=>{
location.reload();
});
// alert("Les informations ont été mises à jour.") ? "" : location.reload();
}else{
toastr.error("<?php echo $this->lang->line('error_message')?>" , "<?php echo $this->lang->line('request_error')?>");
}
},
error : function(resultat, statut, erreur){
console.log(resultat+" "+erreur);
toastr.error("<?php echo $this->lang->line('error_message')?>" , "<?php echo $this->lang->line('request_error')?>");
}
});
});
</script>

View File

@ -247,7 +247,6 @@
data: {"network_id": network_id }, data: {"network_id": network_id },
success : function(data, statut){ success : function(data, statut){
if(data=='200'){ if(data=='200'){
Swal.fire({ Swal.fire({
icon: 'success', icon: 'success',
title: "<?php echo $this->lang->line('wallet_deleted')?>", title: "<?php echo $this->lang->line('wallet_deleted')?>",

View File

@ -2,6 +2,7 @@
<link rel="stylesheet" <link rel="stylesheet"
href="<?php echo base_url('bower_components/datatables.net-bs/css/dataTables.bootstrap.min.css') ?>"> href="<?php echo base_url('bower_components/datatables.net-bs/css/dataTables.bootstrap.min.css') ?>">
<link rel="stylesheet" type="text/css" href="https://cdn.jsdelivr.net/npm/daterangepicker/daterangepicker.css"/> <link rel="stylesheet" type="text/css" href="https://cdn.jsdelivr.net/npm/daterangepicker/daterangepicker.css"/>
<link rel="stylesheet" href="<?php echo base_url('bower_components/toastr/toastr.css') ?>">
<div class="content-wrapper"> <div class="content-wrapper">
<?php <?php
@ -99,6 +100,7 @@
<th><?php echo $this->lang->line('Commission de l\'agent') ?></th> <th><?php echo $this->lang->line('Commission de l\'agent') ?></th>
<th><?php echo $this->lang->line('agent_name') ?></th> <th><?php echo $this->lang->line('agent_name') ?></th>
<th align='center'>Date</th> <th align='center'>Date</th>
<th align='center'>Action</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
@ -129,9 +131,16 @@
<td>".$fmt->format( $row->commission_sup)."</td> <td>".$fmt->format( $row->commission_sup)."</td>
<td>".$fmt->format( $row->commission_ag)."</td> <td>".$fmt->format( $row->commission_ag)."</td>
<td>".$row->agent."</td> <td>".$row->agent."</td>
<td>".toLocateDate($row->date_created,$this->session->userdata('timezone'))."</td> <td>".toLocateDate($row->date_created,$this->session->userdata('timezone'))."</td>";
</tr>"; ?>
<td>
<button data-id-transaction="<?= $row->id ?>" id="cancel" class="btn btn-danger btn-block" <?php if($row->canceled) echo "disabled"?> >
<b><?php echo $this->lang->line('cancel')?></b>
</button>
</td>
</tr>
<?php
} }
?> ?>
</tbody> </tbody>
@ -175,6 +184,8 @@
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/daterangepicker/daterangepicker.min.js"></script> <script type="text/javascript" src="https://cdn.jsdelivr.net/npm/daterangepicker/daterangepicker.min.js"></script>
<script type="text/javascript" src="https://cdn.datatables.net/plug-ins/1.10.19/sorting/datetime-moment.js"></script> <script type="text/javascript" src="https://cdn.datatables.net/plug-ins/1.10.19/sorting/datetime-moment.js"></script>
<script type="text/javascript" src="https://cdn.datatables.net/plug-ins/1.10.20/dataRender/datetime.js"></script> <script type="text/javascript" src="https://cdn.datatables.net/plug-ins/1.10.20/dataRender/datetime.js"></script>
<script src="<?php echo base_url('dist/js/sweetalert2.js') ?>"></script>
<script src="<?php echo base_url('bower_components/toastr/toastr.js') ?>"></script>
<script> <script>
@ -227,4 +238,35 @@
}); });
</script> </script>
<script>
$(document).on("click", "#cancel", function () {
const id_transaction = $(this).data('id-transaction');
$.ajax({
url : '<?php echo base_url('index.php/Gestion/cancelTransation')?>',
type : 'POST',
dataType : 'json',
data: {"id_transaction": id_transaction},
async:true,
success : function(data){
if(data){
Swal.fire({
icon: 'success',
title: "<?php echo $this->lang->line('canceled_transaction')?>",
text: "<?php echo $this->lang->line('informations_updated')?>",
timer: 3000
}).then(()=>{
location.reload();
});
// alert("Les informations ont été mises à jour.") ? "" : location.reload();
}else{
toastr.error("<?php echo $this->lang->line('error_message')?>" , "<?php echo $this->lang->line('request_error')?>");
}
},
error : function(resultat, statut, erreur){
console.log(resultat+" "+erreur);
toastr.error("<?php echo $this->lang->line('error_message')?>" , "<?php echo $this->lang->line('request_error')?>");
}
});
});
</script>