backoffice/application/views/gestion_wallets.php

334 lines
14 KiB
PHP
Raw Normal View History

2020-04-17 15:28:27 +00:00
<link rel="stylesheet" href="<?php echo base_url('bower_components/datatables.net-bs/css/dataTables.bootstrap.min.css') ?>">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-multiselect/0.9.15/css/bootstrap-multiselect.css">
<link rel="stylesheet" href="<?php echo base_url('bower_components/toastr/toastr.css') ?>">
<div class="content-wrapper">
<!-- Content Header (Page header) -->
<section class="content-header">
<h1>
<?php echo $this->lang->line('Gestion des wallets'); ?>
<input type="button" class="btn btn-primary pull-right" id="Bactiver" value="Activer/Désactiver le(s) réseau(x)" style="display: none;" />
</h1>
<?php
$site_url = base_url();
if($alert=="ok") {
if(!$success=="ok"){
?>
<div class='alert alert-danger alert-dismissible col-xs-6'>
<button type='button' class='close' data-dismiss='alert' aria-hidden='true'>×</button>
<h4><i class='icon fa fa-ban'></i> Erreur!</h4>
<?php echo $message; ?>
</div>
<?php
} else {
?>
<div class="alert alert-success alert-dismissible col-xs-6">
<button type="button" class="close" data-dismiss="alert" aria-hidden="true">&times;</button>
<h4><i class="icon fa fa-check"></i> Success!</h4>
<?php echo $message; ?>
</div>
<?php
}
}
?>
</section>
<section class="content">
<div class="row">
<div class="col-xs-12">
<div class="box">
<div class="box-header">
<h3 class="box-title"><?php echo $this->lang->line('Réseaux activés'); ?></h3>
</div>
<div class="box-body">
<?php
$sql2 = $networks;
if($sql2!=false){
$numrows=$sql2->num_rows();
$num = 0;
if ($numrows > 0) {
?>
<table id="validated" class="table table-bordered table-striped">
<thead>
<tr>
<th align='center'></th>
<th><?php echo $this->lang->line('Reseau'); ?></th>
<th><?php echo $this->lang->line('Pays'); ?></th>
<th align='center'> Wallet </th>
<th align='center'><?php echo $this->lang->line('Activer/Désactiver'); ?></th>
<th align='center'> Action </th>
</tr>
</thead>
<tbody>
<?php
foreach($sql2->result() as $row) {
$num ++;
//$member_code = randomString1(10);
echo "<tr>
<td align='center'>$num</td>
<td >$row->network</td>
<td>$row->country</td>";
?>
<?php
if($row->id_network){
?>
<td><span class="label label-success"><?php echo $this->lang->line('Actif'); ?></span></td>
<td><button type="button" data-toggle="modal" data-target="#disableWallet" data-network-id="<?php echo $row->id ?>" class="btn btn-danger openModal"><?php echo $this->lang->line('Désactiver'); ?></button></td>
<?php
}else{
?>
<td><span class="label label-danger"><?php echo $this->lang->line('Inactif'); ?></span></td>
<td><button type="button" data-toggle="modal" data-target="#enableWallet" data-network-id="<?php echo $row->id ?>" class="btn btn-primary openModal"><?php echo $this->lang->line('Activer'); ?></button></td>
<?php
}
?>
<td>
<a href="<?php echo current_url().($row->id_network ? '?id='.$row->id_network : '')?>" class="btn btn-primary btn-block" <?php if(!$row->id_network) echo "disabled"?> >
<b><?php echo $this->lang->line('Voir plus...'); ?></b>
</a>
</td>
<?php
}
?>
</tbody>
</table>
<?php
}
else {
echo $this->lang->line('Aucun réseau');
}
}else {
echo $this->lang->line('Aucun réseau');
}
?>
</div>
</div>
</div>
</div>
<div class="modal fade" id="enableWallet" tabindex="-1" role="dialog" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h3 class="modal-title"><?php echo $this->lang->line('Configuration du wallet'); ?></h3>
</div>
<div class="modal-body">
<form id="walletForm">
<div class="form-group">
2020-05-04 13:18:44 +00:00
<label for="taux_client_r" class="col-form-label"><?php echo $this->lang->line('Taux de commission client sur retrait').' (%)'; ?></label>
2020-04-17 15:28:27 +00:00
<input type="number" min="0" step=".01" required class="form-control" id="taux_client_r" name="taux_client_r" value="0">
</div>
<div class="form-group">
2020-05-04 13:18:44 +00:00
<label for="taux_sup_r" class="col-form-label"><?php echo $this->lang->line('Taux de commission agent géolocalisé sur retrait').' (%)'; ?></label>
2020-04-17 15:28:27 +00:00
<input type="number" min="0" step=".01" required class="form-control" name="taux_ag_r" id="taux_ag_r" value="0">
</div>
<div class="form-group">
<label for="email" class="col-form-label"><?php echo $this->lang->line('Taux de commission superviseur sur retrait').' (%)'; ?></label>
<input type="number" min="0" step=".01" required class="form-control" name="taux_sup_r" id="taux_sup_r" value="0">
</div>
<div class="form-group">
2020-05-04 13:18:44 +00:00
<label for="taux_bq_r" class="col-form-label"><?php echo $this->lang->line('Part de la banque sur le retrait').' (%)'; ?></label>
2020-04-17 15:28:27 +00:00
<input type="number" min="0" step=".01" required class="form-control" id="taux_bq_r" name="taux_bq_r" value="0">
</div>
<div class="form-group">
2020-05-04 13:18:44 +00:00
<label for="taux_client_d" class="col-form-label"><?php echo $this->lang->line('Taux de commission client sur dépot') .' (%)'; ?></label>
2020-04-17 15:28:27 +00:00
<input type="number" min="0" step=".01" required class="form-control" id="taux_client_d" name="taux_client_d" value="0">
</div>
<div class="form-group">
2020-05-04 13:18:44 +00:00
<label for="frais_d" class="col-form-label"><?php echo $this->lang->line('Frais minimun de la banque sur le dépot').' (FCFA)'; ?></label>
2020-04-17 15:28:27 +00:00
<input type="number" min="0" required class="form-control" id="frais_d" name="frais_d" value="0">
</div>
<div class="form-group">
2020-05-04 13:18:44 +00:00
<label for="taux_ag_d" class="col-form-label"><?php echo $this->lang->line('Taux de commission agent géolocalisé sur dépot').' (%)'; ?></label>
2020-04-17 15:28:27 +00:00
<input type="number" min="0" step=".01" required class="form-control" id="taux_ag_d" name="taux_ag_d" value="0">
</div>
<div class="form-group">
2020-05-04 13:18:44 +00:00
<label for="taux_sup_d" class="col-form-label"><?php echo $this->lang->line('Taux de commission superviseur sur dépot').' (%)'; ?></label>
2020-04-17 15:28:27 +00:00
<input type="number" min="0" step=".01" required class="form-control" id="taux_sup_d" name="taux_sup_d" value="0">
</div>
<div class="form-group">
2020-05-04 13:18:44 +00:00
<label for="taux_bq_d" class="col-form-label"><?php echo $this->lang->line('Part de la banque sur le dépot').' (%)'; ?></label>
2020-04-17 15:28:27 +00:00
<input type="number" min="0" step=".01" required class="form-control" name="taux_bq_d" id="taux_bq_d" value="0">
</div>
</form>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal"><?php echo $this->lang->line('Fermer'); ?></button>
<button type="button" class="btn btn-primary" id="addWallet" > <?php echo $this->lang->line('Valider'); ?></button>
</div>
</div>
</div>
</div>
<div class="modal fade" id="disableWallet" tabindex="-1" role="dialog" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h3 class="modal-title"><?php echo $this->lang->line('Suppression du wallet'); ?></h3>
</div>
<div class="modal-body">
<h4> Etes vous certain de vouloir ?</h4>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal"><?php echo $this->lang->line('Fermer'); ?></button>
<button type="button" class="btn btn-primary" id="deleteWallet" > <?php echo $this->lang->line('Valider'); ?></button>
</div>
</div>
</div>
</div>
<!-- <div class="alert alert-info alert-dismissible" aria-hidden="true">-->
<!-- <button type="button" class="close" data-dismiss="alert" aria-hidden="true">&times;</button>-->
<!-- <h4><i class="icon fa fa-info"></i>Info!</h4>-->
<!-- Data is Saved-->
<!-- </div>-->
</section>
</div>
<!-- jQuery 3 -->
<script src="<?php echo base_url('bower_components/jquery/dist/jquery.min.js') ?>"></script>
<!-- Bootstrap 3.3.7 -->
<script src="<?php echo base_url('bower_components/bootstrap/dist/js/bootstrap.min.js') ?>"></script>
<!-- DataTables -->
<script src="<?php echo base_url('bower_components/datatables.net/js/jquery.dataTables.min.js') ?>"></script>
<script src="<?php echo base_url('bower_components/datatables.net-bs/js/dataTables.bootstrap.min.js') ?>"></script>
<!-- Slimscroll -->
<script src="<?php echo base_url('bower_components/jquery-slimscroll/jquery.slimscroll.min.js') ?>"></script>
<!-- FastClick -->
<script src="<?php echo base_url('bower_components/fastclick/lib/fastclick.js') ?>"></script>
<!-- AdminLTE App -->
<script src="<?php echo base_url('dist/js/adminlte.min.js') ?>"></script>
<!-- AdminLTE for demo purposes -->
<script src="<?php echo base_url('dist/js/demo.js') ?>"></script>
<script src="<?php echo base_url('bower_components/toastr/toastr.js') ?>"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-multiselect/0.9.15/js/bootstrap-multiselect.js"></script>
<script src="<?php echo base_url('dist/js/sweetalert2.js') ?>"></script>
<script>
$(function() {
$('#validated').DataTable();
})
</script>
<script>
toastr.options.closeButton = true;
toastr.options.closeMethod = 'fadeOut';
toastr.options.closeDuration = 5000;
toastr.options.closeEasing = 'swing';
var network_id = null;
$(document).on("click", ".openModal", function () {
network_id = $(this).data('network-id');
});
$('#addWallet').click(function(){
if($('#walletForm')[0].checkValidity()) {
var taux_client_r = parseFloat($('#taux_client_r').val());
var taux_client_d = parseFloat($('#taux_client_d').val());
var taux_ag_r = parseFloat($('#taux_ag_r').val());
var taux_ag_d = parseFloat($('#taux_ag_d').val());
var taux_sup_r = parseFloat($('#taux_sup_r').val());
var taux_sup_d = parseFloat($('#taux_sup_d').val());
var taux_bq_d = parseFloat($('#taux_bq_d').val());
var taux_bq_r = parseFloat($('#taux_bq_r').val());
var frais_d =$('#frais_d').val();
var sommeRetrait = taux_ag_r + taux_sup_r +taux_bq_r ;
var sommeDepot = taux_ag_d + taux_sup_d + taux_bq_d ;
if((taux_ag_r + taux_sup_r) > 100){
2020-05-04 13:18:44 +00:00
toastr.error('<?php echo $this->lang->line('first_rule')?>', '<?php echo $this->lang->line('management_rule')?>');
2020-04-17 15:28:27 +00:00
}else if((taux_ag_d + taux_sup_d) > 100){
2020-05-04 13:18:44 +00:00
toastr.error('<?php echo $this->lang->line('second_rule')?>', '<?php echo $this->lang->line('management_rule')?>');
2020-04-17 15:28:27 +00:00
}else if(sommeRetrait >= taux_client_r){
2020-05-04 13:18:44 +00:00
toastr.error('<?php echo $this->lang->line('third_rule')?>', '<?php echo $this->lang->line('management_rule')?>')
2020-04-17 15:28:27 +00:00
}else if(sommeDepot >= 100){
2020-05-04 13:18:44 +00:00
toastr.error('<?php echo $this->lang->line('fourth_rule')?>', '<?php echo $this->lang->line('management_rule')?>');
2020-04-17 15:28:27 +00:00
}else{
$.ajax({
url : '<?php echo base_url('index.php/Gestion/config_wallet/create')?>',
type : 'POST',
dataType : 'json',
data: {"network_id": network_id ,"taux_client_r": taux_client_r, "taux_client_d": taux_client_d,"taux_ag_r": taux_ag_r, "taux_ag_d": taux_ag_d , "taux_sup_r": taux_sup_r , "taux_sup_d": taux_sup_d,
"taux_bq_r": taux_bq_r, "taux_bq_d":taux_bq_d, "frais_d": frais_d},
success : function(data){
if(data=='200'){
Swal.fire({
icon: 'success',
2020-05-04 13:18:44 +00:00
title: '<?php echo $this->lang->line('wallet_created')?>',
text:'<?php echo $this->lang->line('informations_updated')?>',
2020-04-17 15:28:27 +00:00
timer: 3000
}).then(()=>{
location.reload();
});
// alert("Les informations ont été mises à jour.") ? "" :
}else{
2020-05-04 13:18:44 +00:00
toastr.error("<?php echo $this->lang->line('error_message')?>" , '<?php echo $this->lang->line('request_error')?>');
2020-04-17 15:28:27 +00:00
}
},
error : function(resultat, statut, error){
console.log(resultat+" "+error );
}
}).done(function () {
2020-05-01 09:30:08 +00:00
$.ajax({
url : '<?php echo base_url('index.php/Gestion/generateAllWallets')?>',
type : 'POST',
dataType : 'json',
data : {"network_id": network_id},
async : true ,
timeout : 0,
success : function () {
console.log("All wallets are generated");
}
});
2020-04-17 15:28:27 +00:00
});
}
}else {
$('#walletForm')[0].reportValidity();
}
});
$('#deleteWallet').click(function(){
$.ajax({
url : '<?php echo base_url('index.php/Gestion/delete_config_wallet')?>',
type : 'POST',
dataType : 'json',
data: {"network_id": network_id },
success : function(data, statut){
if(data=='200'){
Swal.fire({
icon: 'success',
2020-05-04 13:18:44 +00:00
title: '<?php echo $this->lang->line('wallet_deleted')?>',
text:'<?php echo $this->lang->line('informations_updated')?>',
2020-04-17 15:28:27 +00:00
timer: 3000
}).then(()=>{
location.reload();
});
// alert("Les informations ont été mises à jour.") ? "" : location.reload();
}else{
2020-05-04 13:18:44 +00:00
toastr.error("<?php echo $this->lang->line('error_message')?>" , '<?php echo $this->lang->line('request_error')?>');
2020-04-17 15:28:27 +00:00
}
},
error : function(resultat, statut, erreur){
console.log(resultat+" "+erreur);
}
});
});
</script>