backoffice/application/views/config_wallet_ilink_hyp/user_wallet_cash.php

626 lines
21 KiB
PHP
Executable File
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<link rel="stylesheet"
href="<?php echo base_url('bower_components/bootstrap-datepicker/dist/css/bootstrap-datepicker.min.css') ?>">
<link rel="stylesheet" href="<?php echo base_url('bower_components/bootstrap-daterangepicker/daterangepicker.css') ?>">
<link rel="stylesheet"
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') ?>">
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto|Varela+Round|Open+Sans">
<link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<style type="text/css">
.table-wrapper {
width: 700px;
margin: 30px auto;
background: #fff;
padding: 20px;
box-shadow: 0 1px 1px rgba(0, 0, 0, .05);
}
.table-title {
padding-bottom: 10px;
margin: 0 0 10px;
}
.table-title h2 {
margin: 6px 0 0;
font-size: 22px;
}
.table-title .add-new {
float: right;
height: 30px;
font-weight: bold;
font-size: 12px;
text-shadow: none;
min-width: 100px;
border-radius: 50px;
line-height: 13px;
}
.table-title .add-new i {
margin-right: 4px;
}
table.table {
table-layout: fixed;
}
table.table tr th, table.table tr td {
border-color: #e9e9e9;
}
table.table th i {
font-size: 13px;
margin: 0 5px;
cursor: pointer;
}
table.table th:last-child {
width: 100px;
}
table.table td a {
cursor: pointer;
display: inline-block;
margin: 0 5px;
min-width: 24px;
}
table.table td a.add {
color: #27C46B;
}
table.table td a.edit {
color: #FFC107;
}
table.table td a.delete {
color: #E34724;
}
table.table td i {
font-size: 19px;
}
table.table td a.add i {
font-size: 24px;
margin-right: -1px;
position: relative;
top: 3px;
}
table.table .form-control {
height: 32px;
line-height: 32px;
box-shadow: none;
border-radius: 2px;
}
/*table.table .form-control.error {*/
/* border-color: #f50000;*/
/*}*/
.error {
border-color: #f50000;
}
table.table td .add {
display: none;
}
</style>
<?php
use Brick\Money\Context\CustomContext;
use Brick\Money\Money;
$context = new \Brick\Money\Context\AutoContext();
$fmt = new NumberFormatter('fr_FR', NumberFormatter::DECIMAL);
?>
<div class="content-wrapper">
<!-- Content Header (Page header) -->
<section class="content-header">
<h1>
<?php echo $this->lang->line('config_user').' - '.$this->lang->line('config_ilink_user_wallet_cash'); ?>
</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-lg-12">
<div class="margin">
<button type="button" class="btn btn-primary" data-toggle="modal" data-target="#modal-update"
style="width: 100%"><?php echo $this->lang->line('Modifier la configuration') ?></button>
</div>
</div>
</div>
<div class="row centered">
<div class="col-lg-6 col-xs-12">
<div class="box">
<div class="box-header">
<h3 class="box-title"><?php echo $this->lang->line('rate_com_user_wallet_cash_international'); ?></h3>
</div>
<!-- /.box-header -->
<div class="box-body table-responsive" style="overflow-x:auto;">
<table class="table table-hover">
<tbody>
<tr>
<th>Min</th>
<th>Max</th>
<th>Taux (%)</th>
</tr>
<?php
if ($plr_user_wallet_cash != false) {
foreach ($plr_user_wallet_cash->result() as $row) {
echo "<tr>
<td>" . $fmt->format($row->min) . "</td>
<td>" . $fmt->format($row->max) . "</td>
<td>" . $row->taux . "</td>" . '
</tr>';
}
}
?>
</tbody>
</table>
</div>
<!-- /.box-body -->
</div>
</div>
<div class="col-lg-6 col-xs-12">
<div class="box">
<div class="box-header">
<h3 class="box-title"><?php echo $this->lang->line('rate_com_user_wallet_cash_national'); ?></h3>
</div>
<!-- /.box-header -->
<div class="box-body table-responsive" style="overflow-x:auto;">
<table class="table table-hover">
<tbody>
<tr>
<th>Min</th>
<th>Max</th>
<th>Taux (%)</th>
</tr>
<?php
if ($plr_user_wallet_cash_national != false) {
foreach ($plr_user_wallet_cash_national->result() as $row) {
echo "<tr>
<td>" . $fmt->format($row->min) . "</td>
<td>" . $fmt->format($row->max) . "</td>
<td>" . $row->taux . "</td>" . '
</tr>';
}
}
?>
</tbody>
</table>
</div>
<!-- /.box-body -->
</div>
</div>
</div>
<div class="callout callout-info">
<p>Note</p>
<h4><?php echo $this->lang->line('config_ilink_note') ?></h4>
</div>
<div class="row">
<div class="modal fade" id="modal-update">
<div class="modal-dialog" style="max-width: 1200px; width: 100%;">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
<h3 class="modal-title"><?php echo $this->lang->line('Configuration du wallet'); ?></h3>
</div>
<div class="modal-body">
<form id="walletForm">
<div class="row">
<div class="col-lg-6">
<div class="form-group" style="overflow-x:auto;">
<div class="table-title">
<div class="row">
<div class="col-sm-8">
<label for="nom"
class="col-form-label"><?php echo $this->lang->line('rate_com_user_wallet_cash_international'); ?></label>
</div>
<div class="col-sm-4">
<button type="button" class="btn btn-info add-new new2"><i
class="fa fa-plus"></i> <?php echo $this->lang->line('new_level'); ?>
</button>
</div>
</div>
</div>
<table id="user_wallet_cash" class="table table-bordered">
<thead>
<tr>
<th>Min</th>
<th>Max</th>
<th><?php echo $this->lang->line('rate'); ?> (%)</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
<?php
if ($plr_user_wallet_cash != false) {
foreach ($plr_user_wallet_cash->result() as $row) {
echo "<tr>
<td>" . $row->min . "</td>
<td>" . $row->max . "</td>
<td>" . $row->taux . "</td>" . '
<td>
<a class="add add2" title="Add" data-toggle="tooltip"><i class="material-icons">&#xE03B;</i></a>
<a class="edit edit2" title="Edit" data-toggle="tooltip"><i class="material-icons">&#xE254;</i></a>
<a class="delete delete2" title="Delete" data-toggle="tooltip"><i class="material-icons">&#xE872;</i></a>
</td>
</tr>';
}
}
?>
</tbody>
</table>
</div>
</div>
<div class="col-lg-6">
<div class="form-group" style="overflow-x:auto;">
<div class="table-title">
<div class="row">
<div class="col-sm-8">
<label for="nom"
class="col-form-label"><?php echo $this->lang->line('rate_com_user_wallet_cash_national'); ?></label>
</div>
<div class="col-sm-4">
<button type="button" class="btn btn-info add-new new8"><i
class="fa fa-plus"></i> <?php echo $this->lang->line('new_level'); ?>
</button>
</div>
</div>
</div>
<table id="user_wallet_cash_national" class="table table-bordered">
<thead>
<tr>
<th>Min</th>
<th>Max</th>
<th><?php echo $this->lang->line('rate'); ?> (%)</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
<?php
if ($plr_user_wallet_cash_national != false) {
foreach ($plr_user_wallet_cash_national->result() as $row) {
echo "<tr>
<td>" . $row->min . "</td>
<td>" . $row->max . "</td>
<td>" . $row->taux . "</td>" . '
<td>
<a class="add add8" title="Add" data-toggle="tooltip"><i class="material-icons">&#xE03B;</i></a>
<a class="edit edit8" title="Edit" data-toggle="tooltip"><i class="material-icons">&#xE254;</i></a>
<a class="delete delete8" title="Delete" data-toggle="tooltip"><i class="material-icons">&#xE872;</i></a>
</td>
</tr>';
}
}
?>
</tbody>
</table>
</div>
</div>
</div>
</form>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default pull-left"
data-dismiss="modal"><?php echo $this->lang->line('Fermer'); ?></button>
<button type="button" id="updateWallet" data-network-id="<?= $network_id ?>"
data-id-config="<?= $idConfig ?>"
class="btn btn-primary"><?php echo $this->lang->line('save'); ?></button>
</div>
</div>
</div>
</div>
</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/moment/min/moment.min.js') ?>"></script>
<script src="<?php echo base_url('bower_components/bootstrap-daterangepicker/daterangepicker.js') ?>"></script>
<script src="<?php echo base_url('bower_components/bootstrap-datepicker/dist/js/bootstrap-datepicker.min.js') ?>"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datetimepicker/4.17.47/js/bootstrap-datetimepicker.min.js"></script>
<!-- ChartJS -->
<script src="<?php echo base_url('bower_components/chart.js/Chart.js') ?>"></script>
<script src="<?php echo base_url('bower_components/toastr/toastr.js') ?>"></script>
<script src="<?php echo base_url('dist/js/sweetalert2.js') ?>"></script>
<script>
toastr.options.closeButton = true;
toastr.options.closeMethod = 'fadeOut';
toastr.options.closeDuration = 5000;
toastr.options.closeEasing = 'swing';
$('#updateWallet').click(function () {
const network_id = $(this).data('network-id');
const id_config = $(this).data('id-config');
if ($('#walletForm')[0].checkValidity()) {
// Paliers
var plr_user_wallet_cash = [];
var plr_user_wallet_cash_national = [];
$('#user_wallet_cash tr').has('td').each(function () {
var arrayItem = {};
$('td', $(this)).each(function (index, item) {
if (index < 3)
arrayItem[index] = parseFloat($(item).html());
});
plr_user_wallet_cash.push(arrayItem);
});
$('#user_wallet_cash_national tr').has('td').each(function () {
var arrayItem = {};
$('td', $(this)).each(function (index, item) {
if (index < 3)
arrayItem[index] = parseFloat($(item).html());
});
plr_user_wallet_cash_national.push(arrayItem);
});
$.ajax({
url: '<?php echo base_url('index.php/Gestion/config_wallet/update')?>',
type: 'POST',
dataType: 'json',
data: {
"type": "ilink",
"config": "user_wallet_cash",
"network_id": network_id, "id_config": id_config,
"plr_user_wallet_cash": plr_user_wallet_cash,
"plr_user_wallet_cash_national": plr_user_wallet_cash_national
},
success: function (data) {
if (data == '200') {
Swal.fire({
icon: 'success',
title: "<?php echo $this->lang->line('wallet_update')?>",
text: "<?php echo $this->lang->line('informations_updated')?>",
timer: 3000
}).then(() => {
location.reload();
});
// alert("Les informations ont été mises à jour.") ? "" :
} else {
toastr.error("<?php echo $this->lang->line('error_message')?>", "<?php echo $this->lang->line('request_error')?>");
}
},
error: function (resultat, statut, error) {
console.log(resultat + " " + error);
toastr.error("<?php echo $this->lang->line('error_message')?>", "<?php echo $this->lang->line('request_error')?>");
}
});
} else {
$('#walletForm')[0].reportValidity();
}
});
</script>
<script type="text/javascript">
// Paliers scripts
$(document).ready(function () {
$('[data-toggle="tooltip"]').tooltip();
// Table 2
var actions2 = $("#user_wallet_cash td:last-child").html();
// Append table with add row form on add new button click
$(".new2").click(function () {
if (!actions2) {
actions2 = '<a class="add add2" title="Add" data-toggle="tooltip"><i class="material-icons">&#xE03B;</i></a>\n' +
' <a class="edit edit2" title="Edit" data-toggle="tooltip"><i class="material-icons">&#xE254;</i></a>\n' +
' <a class="delete delete2" title="Delete" data-toggle="tooltip"><i class="material-icons">&#xE872;</i></a>';
}
$(this).attr("disabled", "disabled");
var index = $("#user_wallet_cash tbody tr:last-child").index();
var row = '<tr>' +
'<td><input type="number" required min="0" class="form-control" name="min" id="min"></td>' +
'<td><input type="number" required class="form-control" name="max" id="max"></td>' +
'<td><input type="number" required class="form-control" name="taux" id="taux"></td>' +
'<td> ' + actions2 + '</td>' +
'</tr>';
$("#user_wallet_cash").append(row);
$("#user_wallet_cash tbody tr").eq(index + 1).find(".add, .edit").toggle();
$('[data-toggle="tooltip"]').tooltip();
});
// Add row on add button click
$(document).on("click", ".add2", function () {
var empty = false;
var input = $(this).parents("tr").find('input[type="number"]');
var min = parseFloat($(this).parents("tr").find('input[id="min"]').first().val());
var max = parseFloat($(this).parents("tr").find('input[id="max"]').first().val());
input.each(function () {
if ($(this).attr('id') == 'min') {
if (min >= max) {
$(this).addClass("error");
$(this)[0].reportValidity();
empty = true;
} else {
$(this).removeClass("error");
}
} else if ($(this).attr('id') == 'max') {
if (max <= min) {
$(this).addClass("error");
$(this)[0].reportValidity();
empty = true;
} else {
$(this).removeClass("error");
}
} else {
if (!$(this)[0].checkValidity()) {
$(this).addClass("error");
$(this)[0].reportValidity();
empty = true;
} else {
$(this).removeClass("error");
}
}
});
$(this).parents("tr").find(".error").first().focus();
if (!empty) {
input.each(function () {
$(this).parent("td").html($(this).val());
});
$(this).parents("tr").find(".add, .edit").toggle();
$(".new2").removeAttr("disabled");
}
});
// Edit row on edit button click
$(document).on("click", ".edit2", function () {
$(this).parents("tr").find("td:not(:last-child)").each(function (index) {
if (index == 0)
$(this).html('<input type="number" required class="form-control" min="0" id="min" value="' + $(this).text() + '">');
if (index == 1)
$(this).html('<input type="number" required class="form-control" id="max" value="' + $(this).text() + '">');
if (index == 2)
$(this).html('<input type="number" required class="form-control" min="0" value="' + $(this).text() + '">');
});
$(this).parents("tr").find(".add, .edit").toggle();
$(".new2").attr("disabled", "disabled");
});
// Delete row on delete button click
$(document).on("click", ".delete2", function () {
$(this).parents("tr").remove();
$(".new2").removeAttr("disabled");
});
// Table 8
var actions8 = $("#user_wallet_cash_national td:last-child").html();
// Append table with add row form on add new button click
$(".new8").click(function () {
if (!actions8) {
actions8 = '<a class="add add8" title="Add" data-toggle="tooltip"><i class="material-icons">&#xE08B;</i></a>\n' +
' <a class="edit edit8" title="Edit" data-toggle="tooltip"><i class="material-icons">&#xE254;</i></a>\n' +
' <a class="delete delete8" title="Delete" data-toggle="tooltip"><i class="material-icons">&#xE882;</i></a>';
}
$(this).attr("disabled", "disabled");
var index = $("#user_wallet_cash_national tbody tr:last-child").index();
var row = '<tr>' +
'<td><input type="number" required min="0" class="form-control" name="min" id="min"></td>' +
'<td><input type="number" required class="form-control" name="max" id="max"></td>' +
'<td><input type="number" required class="form-control" name="taux" id="taux"></td>' +
'<td> ' + actions8 + '</td>' +
'</tr>';
$("#user_wallet_cash_national").append(row);
$("#user_wallet_cash_national tbody tr").eq(index + 1).find(".add, .edit").toggle();
$('[data-toggle="tooltip"]').tooltip();
});
// Add row on add button click
$(document).on("click", ".add8", function () {
var empty = false;
var input = $(this).parents("tr").find('input[type="number"]');
var min = parseFloat($(this).parents("tr").find('input[id="min"]').first().val());
var max = parseFloat($(this).parents("tr").find('input[id="max"]').first().val());
input.each(function () {
if ($(this).attr('id') == 'min') {
if (min >= max) {
$(this).addClass("error");
$(this)[0].reportValidity();
empty = true;
} else {
$(this).removeClass("error");
}
} else if ($(this).attr('id') == 'max') {
if (max <= min) {
$(this).addClass("error");
$(this)[0].reportValidity();
empty = true;
} else {
$(this).removeClass("error");
}
} else {
if (!$(this)[0].checkValidity()) {
$(this).addClass("error");
$(this)[0].reportValidity();
empty = true;
} else {
$(this).removeClass("error");
}
}
});
$(this).parents("tr").find(".error").first().focus();
if (!empty) {
input.each(function () {
$(this).parent("td").html($(this).val());
});
$(this).parents("tr").find(".add, .edit").toggle();
$(".new8").removeAttr("disabled");
}
});
// Edit row on edit button click
$(document).on("click", ".edit8", function () {
$(this).parents("tr").find("td:not(:last-child)").each(function (index) {
if (index == 0)
$(this).html('<input type="number" required class="form-control" min="0" id="min" value="' + $(this).text() + '">');
if (index == 1)
$(this).html('<input type="number" required class="form-control" id="max" value="' + $(this).text() + '">');
if (index == 2)
$(this).html('<input type="number" required class="form-control" min="0" value="' + $(this).text() + '">');
});
$(this).parents("tr").find(".add, .edit").toggle();
$(".new8").attr("disabled", "disabled");
});
// Delete row on delete button click
$(document).on("click", ".delete8", function () {
$(this).parents("tr").remove();
$(".new8").removeAttr("disabled");
});
});
</script>