backoffice/application/views/include/recharge_account_modal.php

126 lines
4.9 KiB
PHP

<div class="modal fade" id="rechargeAccount" 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"><?= $this->lang->line('recharge_hypervisor_account'); ?></h3>
</div>
<div class="modal-body">
<?php if ($walletPassword != null) { ?>
<form id="rechargeAccountForm">
<div class="form-group">
<label for="montant" class="col-form-label"><?= $this->lang->line('Montant') ?></label>
<input type="text" required class="form-control" id="montant" name="montant" >
</div>
<!-- <div class="form-group">-->
<!-- <label for="password" class="col-form-label">--><?php //echo $this->lang->line('mot de passe') ?><!--</label>-->
<!-- <input type="password" required class="form-control" name="password" id="password">-->
<!-- </div>-->
<div class="form-group">
<label><?= $this->lang->line('mot de passe') ?></label>
<div class="input-group" id="show_hide_password">
<input class="form-control" name="password" id="password" type="password">
<div class="input-group-addon">
<a href=""><i class="fa fa-eye-slash" aria-hidden="true"></i></a>
</div>
</div>
</div>
<div class="clearfix">
<a href="#" id="resetPassword" class="pull-right forgot-password" data-wallet_password_id="<?= $walletPassword->id ?>" data-network="<?= $network ?>" data-country="<?= $country ?>"
data-email="<?= $walletPassword->email ?>">
<?= $this->lang->line('i_forgot_password') ?>
</a>
</div>
</form>
<?php }else{ ?>
<div class="text-center">
<h4> <?= $this->lang->line('no_wallet_password') ?></h4>
<a href="<?= base_url('Hyperviseur_dash/walletPassword') ?>" alt="" class="btn btn-primary"><?= $this->lang->line('click_here') ?></a>
</div>
<?php } ?>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal"><?= $this->lang->line('Fermer'); ?></button>
<?php if ($walletPassword != null) { ?>
<button type="button" class="btn btn-primary" data-wallet_id="<?= $wallet_id ?>" data-salt="<?= $walletPassword->salt ?>" data-encrypted_password="<?= $walletPassword->encrypted_password ?>" id="rechargeWallet" >
<?= $this->lang->line('recharge'); ?>
</button>
<?php }?>
</div>
</div>
</div>
</div>
<script src="https://cdn.jsdelivr.net/npm/autonumeric@4.5.4"></script>
<script>
$(function () {
$('#example1').DataTable();
anElement = new AutoNumeric('#montant', '', {digitGroupSeparator: ' ', decimalPlaces:'0', minimumValue : '1' , maximumValue: '99999999999999999999999999'});
$("#show_hide_password a").on('click', function(event) {
event.preventDefault();
if($('#show_hide_password input').attr("type") == "text"){
$('#show_hide_password input').attr('type', 'password');
$('#show_hide_password i').addClass( "fa-eye-slash" );
$('#show_hide_password i').removeClass( "fa-eye" );
}else if($('#show_hide_password input').attr("type") == "password"){
$('#show_hide_password input').attr('type', 'text');
$('#show_hide_password i').removeClass( "fa-eye-slash" );
$('#show_hide_password i').addClass( "fa-eye" );
}
});
$('#rechargeWallet').click(function () {
const wallet_id = $(this).data('wallet_id');
const salt = $(this).data('salt');
const encrypted_password = $(this).data('encrypted_password');
if ($('#rechargeAccountForm')[0].checkValidity()) {
const montant = anElement.getNumber(); //parseFloat($('#montant').val());
const password = $('#password').val();
$.ajax({
url: '<?= base_url('Hyperviseur_dash/recharge_wallet')?>',
type: 'POST',
dataType: 'json',
data: {
"wallet_id": wallet_id,
"montant": montant ,
"password": password,
"salt" : salt,
"encrypted_password" : encrypted_password
},
success: function (data) {
if(data=='200'){
Swal.fire({
icon: 'success',
title: "<?= $this->lang->line('account_recharged')?>",
text: "<?= $this->lang->line('informations_updated')?>",
timer: 3000
}).then(()=>{
location.reload();
});
// alert("Les informations ont été mises à jour.") ? "" :
}else if(data == '400'){
toastr.error("<?= $this->lang->line('incorrect_password')?>" , "<?= $this->lang->line('request_error')?>");
}else{
toastr.error("<?= $this->lang->line('error_message')?>" , "<?= $this->lang->line('request_error')?>");
}
},
error: function (resultat, statut, error) {
console.log(resultat + " " + error);
toastr.error("<?= $this->lang->line('error_message')?>" , "<?= $this->lang->line('request_error')?>");
}
});
} else {
$('#rechargeAccountForm')[0].reportValidity();
}
});
})
</script>