backoffice/application/views/gestion_wallets.php

278 lines
9.9 KiB
PHP
Raw Normal View History

2021-10-05 06:34:11 +00:00
<link rel="stylesheet" href="<?= base_url('bower_components/datatables.net-bs/css/dataTables.bootstrap.min.css') ?>">
2020-04-17 15:28:27 +00:00
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-multiselect/0.9.15/css/bootstrap-multiselect.css">
2021-10-05 06:34:11 +00:00
<link rel="stylesheet" href="<?= base_url('bower_components/toastr/toastr.css') ?>">
2020-04-17 15:28:27 +00:00
<div class="content-wrapper">
<!-- Content Header (Page header) -->
<section class="content-header">
<h1>
2021-10-05 06:34:11 +00:00
<?= $this->lang->line('Gestion des wallets'); ?>
2020-04-17 15:28:27 +00:00
</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>
2021-10-05 06:34:11 +00:00
<?= $message; ?>
2020-04-17 15:28:27 +00:00
</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>
2021-10-05 06:34:11 +00:00
<?= $message; ?>
2020-04-17 15:28:27 +00:00
</div>
<?php
}
}
?>
</section>
<section class="content">
<div class="row">
<div class="col-xs-12">
<div class="box">
<div class="box-header">
2021-10-05 06:34:11 +00:00
<h3 class="box-title"><?= $this->lang->line('Réseaux activés'); ?></h3>
2020-04-17 15:28:27 +00:00
</div>
<div class="box-body" style="overflow-x:auto;">
2020-04-17 15:28:27 +00:00
<?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>
2021-10-05 06:34:11 +00:00
<th><?= $this->lang->line('Reseau'); ?></th>
<th><?= $this->lang->line('Pays'); ?></th>
2020-04-17 15:28:27 +00:00
<th align='center'> Wallet </th>
2021-10-05 06:34:11 +00:00
<th align='center'><?= $this->lang->line('Activer/Désactiver'); ?></th>
2020-04-17 15:28:27 +00:00
<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
2021-10-05 06:34:11 +00:00
if($row->enabled){
2020-04-17 15:28:27 +00:00
?>
<td><span class="label label-success"><?= mb_strtoupper(str_replace('_',' ',$row->type),'UTF-8') ?></span></td>
2021-10-05 06:34:11 +00:00
<td><button type="button" data-toggle="modal" data-target="#disableWallet" data-network-id="<?= $row->id ?>" data-country-id="<?= $row->country_id ?>"
class="btn btn-danger openModal"><?= $this->lang->line('Désactiver'); ?></button></td>
2020-04-17 15:28:27 +00:00
<?php
}else{
?>
2021-10-05 06:34:11 +00:00
<td><span class="label label-danger"><?= $this->lang->line('Inactif'); ?></span></td>
<td><button type="button" data-network-id="<?= $row->id ?>" data-country-id="<?= $row->country_id ?>"
data-toggle="modal" data-target="#enableWallet" class="btn btn-primary openModal" ><?= $this->lang->line('Activer'); ?></button></td>
2020-04-17 15:28:27 +00:00
<?php
}
?>
<td>
2021-10-05 06:34:11 +00:00
<a href="<?= current_url().($row->enabled ? '?id='.$row->id_network : '')?>" class="btn btn-primary btn-block" <?php if(!$row->enabled) echo "disabled"?> >
<b><?= $this->lang->line('Voir plus...'); ?></b>
2020-04-17 15:28:27 +00:00
</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="disableWallet" tabindex="-1" role="dialog" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
2021-10-05 06:34:11 +00:00
<h3 class="modal-title"><?= $this->lang->line('Suppression du wallet'); ?></h3>
2020-04-17 15:28:27 +00:00
</div>
<div class="modal-body">
<h4> Etes vous certain de vouloir ?</h4>
</div>
<div class="modal-footer">
2021-10-05 06:34:11 +00:00
<button type="button" class="btn btn-secondary" data-dismiss="modal"><?= $this->lang->line('Fermer'); ?></button>
<button type="button" class="btn btn-primary" id="disableWallet" > <?= $this->lang->line('Valider'); ?></button>
2020-04-17 15:28:27 +00:00
</div>
</div>
</div>
</div>
2020-06-01 11:21:06 +00:00
<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">
2021-10-05 06:34:11 +00:00
<h3 class="modal-title"><?= $this->lang->line('choose_wallet_type'); ?></h3>
2020-06-01 11:21:06 +00:00
</div>
<div class="modal-body">
<div class="login-box">
<div class="login-box-body">
<button type="button" class="btn btn-primary enableWallet" style="width: 100% ; margin-bottom: 15px" value="visa" data-dismiss="modal">VISA</button>
2020-06-23 06:41:44 +00:00
<button type="button" class="btn btn-primary enableWallet" value="ilink" style="width: 100%; margin-bottom: 15px" data-dismiss="modal">ILINK WORLD</button>
2021-10-05 06:34:11 +00:00
<button type="button" class="btn btn-primary enableWallet" value="ilink_sante" style="width: 100%; margin-bottom: 15px" data-dismiss="modal">ILINK SANTE</button>
2020-06-23 06:41:44 +00:00
<button type="button" class="btn btn-primary enableWallet" value="autre" style="width: 100%" data-dismiss="modal">AUTRE</button>
2020-06-01 11:21:06 +00:00
</div>
</div>
</div>
<div class="modal-footer">
2021-10-05 06:34:11 +00:00
<button type="button" class="btn btn-secondary" data-dismiss="modal"><?= $this->lang->line('Fermer'); ?></button>
2020-06-01 11:21:06 +00:00
</div>
</div>
</div>
</div>
2020-04-17 15:28:27 +00:00
<!-- <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 -->
2021-10-05 06:34:11 +00:00
<script src="<?= base_url('bower_components/jquery/dist/jquery.min.js') ?>"></script>
2020-04-17 15:28:27 +00:00
<!-- Bootstrap 3.3.7 -->
2021-10-05 06:34:11 +00:00
<script src="<?= base_url('bower_components/bootstrap/dist/js/bootstrap.min.js') ?>"></script>
2020-04-17 15:28:27 +00:00
<!-- DataTables -->
2021-10-05 06:34:11 +00:00
<script src="<?= base_url('bower_components/datatables.net/js/jquery.dataTables.min.js') ?>"></script>
<script src="<?= base_url('bower_components/datatables.net-bs/js/dataTables.bootstrap.min.js') ?>"></script>
2020-04-17 15:28:27 +00:00
<!-- Slimscroll -->
2021-10-05 06:34:11 +00:00
<script src="<?= base_url('bower_components/jquery-slimscroll/jquery.slimscroll.min.js') ?>"></script>
2020-04-17 15:28:27 +00:00
<!-- FastClick -->
2021-10-05 06:34:11 +00:00
<script src="<?= base_url('bower_components/fastclick/lib/fastclick.js') ?>"></script>
2020-04-17 15:28:27 +00:00
<!-- AdminLTE App -->
2021-10-05 06:34:11 +00:00
<script src="<?= base_url('dist/js/adminlte.min.js') ?>"></script>
2020-04-17 15:28:27 +00:00
<!-- AdminLTE for demo purposes -->
2021-10-05 06:34:11 +00:00
<script src="<?= base_url('dist/js/demo.js') ?>"></script>
<script src="<?= base_url('bower_components/toastr/toastr.js') ?>"></script>
2020-04-17 15:28:27 +00:00
<script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-multiselect/0.9.15/js/bootstrap-multiselect.js"></script>
2021-10-05 06:34:11 +00:00
<script src="<?= base_url('dist/js/sweetalert2.js') ?>"></script>
2020-04-17 15:28:27 +00:00
<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;
2021-10-05 06:34:11 +00:00
var country_id = null;
2020-04-17 15:28:27 +00:00
$(document).on("click", ".openModal", function () {
network_id = $(this).data('network-id');
2021-10-05 06:34:11 +00:00
country_id = $(this).data('country-id');
})
2020-04-17 15:28:27 +00:00
$(document).on("click", ".enableWallet", function () {
2020-06-01 11:21:06 +00:00
// const network_id = $(this).data('network-id');
const type = $(this).val();
$.ajax({
url : '<?= base_url('Gestion/config_wallet/create')?>',
type : 'POST',
dataType : 'json',
2021-10-05 06:34:11 +00:00
data: {"network_id": network_id , country_id : country_id , "type" : type},
success : function(data){
2021-10-05 06:34:11 +00:00
if(data==='403'){
toastr.error("<?= $this->lang->line('network_already_exist_in_country')?>" , "<?= $this->lang->line('request_error')?>");
}else if(data==='200'){
Swal.fire({
icon: 'success',
2021-10-05 06:34:11 +00:00
title: "<?= $this->lang->line('wallet_created')?>",
text: "<?= $this->lang->line('informations_updated')?>",
timer: 3000
}).then(()=>{
location.reload();
2020-05-01 09:30:08 +00:00
});
// alert("Les informations ont été mises à jour.") ? "" :
}else{
2021-10-05 06:34:11 +00:00
toastr.error("<?= $this->lang->line('error_message')?>" , "<?= $this->lang->line('request_error')?>");
}
},
error : function(resultat, statut, error){
console.log(resultat+" "+error );
2021-10-05 06:34:11 +00:00
toastr.error("<?= $this->lang->line('error_message')?>" , "<?= $this->lang->line('request_error')?>");
2020-04-17 15:28:27 +00:00
}
}).done(function () {
$.ajax({
url : '<?= base_url('Gestion/generateAllWallets')?>',
type : 'POST',
dataType : 'json',
2020-06-23 06:41:44 +00:00
data : {"network_id": network_id , "type" : type},
async : true ,
timeout : 0,
success : function () {
console.log("All wallets are generated");
}
});
});
2020-04-17 15:28:27 +00:00
});
2021-10-05 06:34:11 +00:00
$('#disableWallet').click(function(){
2020-04-17 15:28:27 +00:00
$.ajax({
url : '<?= base_url('Gestion/disable_config_wallet')?>',
2020-04-17 15:28:27 +00:00
type : 'POST',
dataType : 'json',
data: {"network_id": network_id },
success : function(data, statut){
2021-10-05 06:34:11 +00:00
if(data==='200'){
2020-04-17 15:28:27 +00:00
Swal.fire({
icon: 'success',
2021-10-05 06:34:11 +00:00
title: "<?= $this->lang->line('wallet_disabled')?>",
text: "<?= $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{
2021-10-05 06:34:11 +00:00
toastr.error("<?= $this->lang->line('error_message')?>" , "<?= $this->lang->line('request_error')?>");
2020-04-17 15:28:27 +00:00
}
},
error : function(resultat, statut, erreur){
console.log(resultat+" "+erreur);
2021-10-05 06:34:11 +00:00
toastr.error("<?= $this->lang->line('error_message')?>" , "<?= $this->lang->line('request_error')?>");
2020-04-17 15:28:27 +00:00
}
});
});
</script>