backoffice/application/views/nano_credit/config_nano_credit.php

808 lines
27 KiB
PHP
Raw Normal View History

2020-08-27 09:37:45 +00:00
<link rel="stylesheet"
2022-04-18 11:39:19 +00:00
href="<?= base_url('bower_components/bootstrap-datepicker/dist/css/bootstrap-datepicker.min.css') ?>">
<link rel="stylesheet" href="<?= base_url('bower_components/bootstrap-daterangepicker/daterangepicker.css') ?>">
2020-08-27 09:37:45 +00:00
<link rel="stylesheet"
2022-04-18 11:39:19 +00:00
href="<?= base_url('bower_components/datatables.net-bs/css/dataTables.bootstrap.min.css') ?>">
<link rel="stylesheet" href="<?= base_url('bower_components/toastr/toastr.css') ?>">
<link rel="stylesheet" href="<?= base_url('bower_components/google-material-icons/google-material-icons.min.css') ?>">
2020-08-27 09:37:45 +00:00
<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\Money;
$context = new \Brick\Money\Context\AutoContext();
?>
<div class="content-wrapper">
<!-- Content Header (Page header) -->
<section class="content-header">
<h1>
2022-04-18 11:39:19 +00:00
<?= $this->lang->line('edit_nano_credit') . ' - ' . $network . ' - ' . $country; ?>
2020-08-27 09:37:45 +00:00
</h1>
<?php
2020-08-27 09:37:45 +00:00
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>
2022-04-18 11:39:19 +00:00
<?= $message; ?>
2020-08-27 09:37:45 +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>
2022-04-18 11:39:19 +00:00
<?= $message; ?>
2020-08-27 09:37:45 +00:00
</div>
<?php
}
}
?>
</section>
<section class="content">
2020-09-09 07:27:25 +00:00
<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"
2022-04-18 11:39:19 +00:00
style="width: 100%"><?= $this->lang->line('modify_sharing_rates') ?></button>
2020-09-09 07:27:25 +00:00
</div>
</div>
</div>
2020-08-27 09:37:45 +00:00
<div class="row">
<div class="col-lg-6">
<div class="margin">
<button type="button" class="btn btn-success" data-toggle="modal" data-target="#modal-rates"
2022-04-18 11:39:19 +00:00
style="width: 100%"><?= $this->lang->line('change_interest_rates') ?></button>
2020-08-27 09:37:45 +00:00
</div>
</div>
<div class="col-lg-6">
<div class="margin">
<button type="button" class="btn btn-info" data-toggle="modal" data-target="#modal-tax"
2022-04-18 11:39:19 +00:00
style="width: 100%"><?= $this->lang->line('edit_tax') ?></button>
2020-08-27 09:37:45 +00:00
</div>
</div>
</div>
2020-09-09 07:27:25 +00:00
<div class="row">
<!--Taux commission sur le nano credit-->
<div class="col-lg-4 col-xs-6">
<div class="small-box bg-red">
<div class="inner">
2022-04-18 11:39:19 +00:00
<h3><?= $taux_ag_nano_credit; ?><sup style="font-size: 20px">%</sup></h3>
<p><?= $this->lang->line('nano_credit_rate_com_agent') ?> </p>
2020-09-09 07:27:25 +00:00
</div>
<div class="icon">
<i class="ion ion-android-arrow-up"></i>
</div>
</div>
</div>
<div class="col-lg-4 col-xs-6">
<div class="small-box bg-red">
<div class="inner">
2022-04-18 11:39:19 +00:00
<h3><?= $taux_sup_nano_credit; ?><sup style="font-size: 20px">%</sup></h3>
<p><?= $this->lang->line('nano_credit_rate_com_sup') ?> </p>
2020-09-09 07:27:25 +00:00
</div>
<div class="icon">
<i class="ion ion-android-arrow-up"></i>
</div>
</div>
</div>
<div class="col-lg-4 col-xs-6">
<div class="small-box bg-red">
<div class="inner">
2022-04-18 11:39:19 +00:00
<h3><?= $taux_hyp_nano_credit; ?><sup style="font-size: 20px">%</sup></h3>
<p><?= $this->lang->line('nano_credit_rate_com_hyp') ?> </p>
2020-09-09 07:27:25 +00:00
</div>
<div class="icon">
<i class="ion ion-android-arrow-up"></i>
</div>
</div>
</div>
</div>
2020-08-27 09:37:45 +00:00
<div class="row centered">
<div class="col-lg-3 col-lg-offset-2 col-xs-12">
<div class="box">
<div class="box-header">
2022-04-18 11:39:19 +00:00
<h3 class="box-title"><?= $this->lang->line('nano_credit_interest_rates'); ?></h3>
2020-08-27 09:37:45 +00:00
</div>
<div class="box-body table-responsive" style="overflow-x:auto;">
<table class="table table-hover">
<thead>
<tr>
2022-04-18 11:39:19 +00:00
<th><?= $this->lang->line('interest_rates_period'); ?> </th>
<th><?= $this->lang->line('rate') . ' (%)'; ?> </th>
2020-08-27 09:37:45 +00:00
</tr>
</thead>
<tbody>
<?php
if ($rates != false) {
foreach ($rates->result() as $row) {
echo "<tr>
<td>" . $row->duree_mois . "</td>
<td>" . $row->taux . "</td>" . '
</tr>';
}
}
?>
</tbody>
</table>
</div>
</div>
</div>
<div class="col-lg-4 col-xs-12">
<div class="box">
<div class="box-header">
2022-04-18 11:39:19 +00:00
<h3 class="box-title"><?= $this->lang->line('transaction_nano_credit'); ?></h3>
2020-08-27 09:37:45 +00:00
</div>
<div class="box-body table-responsive" style="overflow-x:auto;">
<table class="table table-hover">
<thead>
<tr>
2022-04-18 11:39:19 +00:00
<th><?= $this->lang->line('Nom'); ?> </th>
2020-08-27 09:37:45 +00:00
<th>Type</th>
<th>Valeur</th>
</tr>
</thead>
<tbody>
<?php
if ($taxes != false) {
foreach ($taxes->result() as $row) {
echo "<tr>
<td>" . $row->nom . "</td>
<td>" . $row->type . "</td>
<td>" . $row->valeur . "</td>" . '
</tr>';
}
}
?>
</tbody>
</table>
</div>
</div>
</div>
</div>
<div class="modal fade" id="modal-rates">
<div class="modal-dialog">
<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>
2022-04-18 11:39:19 +00:00
<h3 class="modal-title"><?= $this->lang->line('change_interest_rates'); ?></h3>
2020-08-27 09:37:45 +00:00
</div>
<div class="modal-body">
<form id="ratesForm">
<div class="row">
<div class="col-lg-12">
<div class="form-group">
<div class="table-title">
<div class="row">
<div class="col-sm-8">
<label for="nom"
2022-04-18 11:39:19 +00:00
class="col-form-label"><?= $this->lang->line('nano_credit_interest_rates'); ?></label>
2020-08-27 09:37:45 +00:00
</div>
<div class="col-sm-4">
<button type="button" class="btn btn-info add-new new5"><i
2022-04-18 11:39:19 +00:00
class="fa fa-plus"></i> <?= $this->lang->line('new_rate'); ?>
2020-08-27 09:37:45 +00:00
</button>
</div>
</div>
</div>
<table id="rates" class="table table-bordered">
<thead>
<tr>
2022-04-18 11:39:19 +00:00
<th><?= $this->lang->line('interest_rates_period'); ?></th>
<th><?= $this->lang->line('rate') . ' (%)'; ?></th>
2020-08-27 09:37:45 +00:00
<th>Actions</th>
</tr>
</thead>
<tbody>
<?php
if ($rates != false) {
foreach ($rates->result() as $row) {
echo "<tr>
<td>" . $row->duree_mois . "</td>
<td>" . $row->taux . "</td>" . '
<td>
<a class="add add5" title="Add" data-toggle="tooltip"><i class="material-icons">&#xE03B;</i></a>
<a class="edit edit5" title="Edit" data-toggle="tooltip"><i class="material-icons">&#xE254;</i></a>
<a class="delete delete5" 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"
2022-04-18 11:39:19 +00:00
data-dismiss="modal"><?= $this->lang->line('Fermer'); ?></button>
2020-08-27 09:37:45 +00:00
<button type="button" id="saveRates" data-network-id="<?= $network_id ?>"
data-id-config="<?= $idConfig ?>"
2022-04-18 11:39:19 +00:00
class="btn btn-primary"><?= $this->lang->line('save'); ?></button>
2020-08-27 09:37:45 +00:00
</div>
</div>
</div>
</div>
<div class="modal fade" id="modal-tax">
<div class="modal-dialog">
<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>
2022-04-18 11:39:19 +00:00
<h3 class="modal-title"><?= $this->lang->line('edit_tax'); ?></h3>
2020-08-27 09:37:45 +00:00
</div>
<div class="modal-body">
<form id="taxForm">
<div class="form-group" style="overflow-x:auto;">
<div class="table-title">
<div class="row">
<div class="col-sm-8">
<label for="nom"
2022-04-18 11:39:19 +00:00
class="col-form-label"><?= $this->lang->line('transaction_nano_credit'); ?></label>
2020-08-27 09:37:45 +00:00
</div>
<div class="col-sm-4">
<button type="button" class="btn btn-info add-new new51"><i
2022-04-18 11:39:19 +00:00
class="fa fa-plus"></i> <?= $this->lang->line('new_tax'); ?>
2020-08-27 09:37:45 +00:00
</button>
</div>
</div>
</div>
<table id="nano_credit_taxes" class="table table-bordered">
<thead>
<tr>
2022-04-18 11:39:19 +00:00
<th><?= $this->lang->line('Nom'); ?> </th>
2020-08-27 09:37:45 +00:00
<th>Type</th>
<th>Valeur</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
<?php
if ($taxes != false) {
foreach ($taxes->result() as $row) {
echo "<tr>
<td>" . $row->nom . "</td>
<td>" . $row->type . "</td>
<td>" . $row->valeur . "</td>" . '
<td>
<a class="add add51" title="Add" data-toggle="tooltip"><i class="material-icons">&#xE03B;</i></a>
<a class="edit edit51" title="Edit" data-toggle="tooltip"><i class="material-icons">&#xE254;</i></a>
<a class="delete delete51" title="Delete" data-toggle="tooltip"><i class="material-icons">&#xE872;</i></a>
</td>
</tr>';
}
}
// ?>
</tbody>
</table>
</div>
</form>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default pull-left"
2022-04-18 11:39:19 +00:00
data-dismiss="modal"><?= $this->lang->line('Fermer'); ?></button>
2020-08-27 09:37:45 +00:00
<button type="button" id="saveTaxes" data-network-id="<?= $network_id ?>"
data-id-config="<?= $idConfig ?>"
2022-04-18 11:39:19 +00:00
class="btn btn-primary"><?= $this->lang->line('save'); ?></button>
2020-08-27 09:37:45 +00:00
</div>
</div>
</div>
</div>
2020-09-09 07:27:25 +00:00
<div class="modal fade" id="modal-update">
<div class="modal-dialog">
<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>
2022-04-18 11:39:19 +00:00
<h3 class="modal-title"><?= $this->lang->line('nano_credit_configuration'); ?></h3>
2020-09-09 07:27:25 +00:00
</div>
<div class="modal-body">
<form id="walletForm">
<div class="form-group">
<label for="taux_ag_nano_credit"
2022-04-18 11:39:19 +00:00
class="col-form-label"><?= $this->lang->line('nano_credit_rate_com_agent') . ' (%)'; ?></label>
2020-09-09 07:27:25 +00:00
<input type="number" min="0" step=".01" required class="form-control"
name="taux_ag_nano_credit" id="taux_ag_nano_credit" value="<?= $taux_ag_nano_credit ?>">
</div>
<div class="form-group">
<label for="taux_sup_nano_credit"
2022-04-18 11:39:19 +00:00
class="col-form-label"><?= $this->lang->line('nano_credit_rate_com_sup') . ' (%)'; ?></label>
2020-09-09 07:27:25 +00:00
<input type="number" min="0" step=".01" required class="form-control"
name="taux_sup_nano_credit" id="taux_sup_nano_credit" value="<?= $taux_sup_nano_credit ?>">
</div>
<div class="form-group">
<label for="taux_hyp_nano_credit"
2022-04-18 11:39:19 +00:00
class="col-form-label"><?= $this->lang->line('nano_credit_rate_com_hyp') . ' (%)'; ?></label>
2020-09-09 07:27:25 +00:00
<input type="number" min="0" step=".01" required class="form-control"
name="taux_hyp_nano_credit" id="taux_hyp_nano_credit" value="<?= $taux_hyp_nano_credit ?>">
</div>
</form>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default pull-left"
2022-04-18 11:39:19 +00:00
data-dismiss="modal"><?= $this->lang->line('Fermer'); ?></button>
2020-09-09 07:27:25 +00:00
<button type="button" id="updateWallet" data-network-id="<?= $network_id ?>"
data-id-config="<?= $idConfig ?>"
2022-04-18 11:39:19 +00:00
class="btn btn-primary"><?= $this->lang->line('save'); ?></button>
2020-09-09 07:27:25 +00:00
</div>
</div>
</div>
</div>
2020-08-27 09:37:45 +00:00
</section>
</div>
<!-- jQuery 3 -->
2022-04-18 11:39:19 +00:00
<script src="<?= base_url('bower_components/jquery/dist/jquery.min.js') ?>"></script>
2020-08-27 09:37:45 +00:00
<!-- Bootstrap 3.3.7 -->
2022-04-18 11:39:19 +00:00
<script src="<?= base_url('bower_components/bootstrap/dist/js/bootstrap.min.js') ?>"></script>
2020-08-27 09:37:45 +00:00
<!-- DataTables -->
2022-04-18 11:39:19 +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-08-27 09:37:45 +00:00
<!-- Slimscroll -->
2022-04-18 11:39:19 +00:00
<script src="<?= base_url('bower_components/jquery-slimscroll/jquery.slimscroll.min.js') ?>"></script>
2020-08-27 09:37:45 +00:00
<!-- FastClick -->
2022-04-18 11:39:19 +00:00
<script src="<?= base_url('bower_components/fastclick/lib/fastclick.js') ?>"></script>
2020-08-27 09:37:45 +00:00
<!-- AdminLTE App -->
2022-04-18 11:39:19 +00:00
<script src="<?= base_url('dist/js/adminlte.min.js') ?>"></script>
2020-08-27 09:37:45 +00:00
<!-- AdminLTE for demo purposes -->
2022-04-18 11:39:19 +00:00
<script src="<?= base_url('dist/js/demo.js') ?>"></script>
2020-08-27 09:37:45 +00:00
2022-04-18 11:39:19 +00:00
<script src="<?= base_url('bower_components/moment/min/moment.min.js') ?>"></script>
<script src="<?= base_url('bower_components/bootstrap-daterangepicker/daterangepicker.js') ?>"></script>
<script src="<?= base_url('bower_components/bootstrap-datepicker/dist/js/bootstrap-datepicker.min.js') ?>"></script>
2020-08-27 09:37:45 +00:00
<script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datetimepicker/4.17.47/js/bootstrap-datetimepicker.min.js"></script>
<!-- ChartJS -->
2022-04-18 11:39:19 +00:00
<script src="<?= base_url('bower_components/chart.js/Chart.js') ?>"></script>
<script src="<?= base_url('bower_components/toastr/toastr.js') ?>"></script>
<script src="<?= base_url('dist/js/sweetalert2.js') ?>"></script>
2020-08-27 09:37:45 +00:00
<script type="text/javascript" src="https://cdn.jsdelivr.net/momentjs/latest/moment-with-locales.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.20/dataRender/datetime.js"></script>
<script type="text/javascript" src="https://cdn.datatables.net/buttons/1.6.2/js/dataTables.buttons.min.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jszip/3.1.3/jszip.min.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.1.53/pdfmake.min.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.1.53/vfs_fonts.js"></script>
<script type="text/javascript" src="https://cdn.datatables.net/buttons/1.6.2/js/buttons.html5.min.js"></script>
<script type="text/javascript" src="https://cdn.datatables.net/buttons/1.6.2/js/buttons.print.min.js"></script>
<script type="text/javascript" src="https://cdn.datatables.net/buttons/1.6.2/js/buttons.colVis.min.js"></script>
<script>
toastr.options.closeButton = true;
toastr.options.closeMethod = 'fadeOut';
toastr.options.closeDuration = 5000;
toastr.options.closeEasing = 'swing';
2020-09-09 07:27:25 +00:00
2020-08-27 09:37:45 +00:00
$('#saveRates').click(function () {
const network_id = $(this).data('network-id');
const id_config = $(this).data('id-config');
// Paliers
var rates = [];
$('#rates tr').has('td').each(function () {
var arrayItem = {};
$('td', $(this)).each(function (index, item) {
if (index < 2) {
if (index == 1)
arrayItem[index] = parseFloat($(item).html());
arrayItem[index] = parseInt($(item).html());
}
});
rates.push(arrayItem);
});
if ($('#ratesForm')[0].checkValidity()) {
console.log(rates)
$.ajax({
2022-04-18 11:39:19 +00:00
url: '<?= base_url('Hyperviseur_dash/saveNanoCreditRates')?>',
2020-08-27 09:37:45 +00:00
type: 'POST',
dataType: 'json',
data: {
"id_config": id_config,
"rates": rates,
},
success: function (data) {
if (data == '200') {
Swal.fire({
icon: 'success',
2022-04-18 11:39:19 +00:00
title: "<?= $this->lang->line('nano_credit_update')?>",
text: "<?= $this->lang->line('informations_updated')?>",
2020-08-27 09:37:45 +00:00
timer: 3000
}).then(() => {
location.reload();
});
} else {
2022-04-18 11:39:19 +00:00
toastr.error("<?= $this->lang->line('error_message')?>", "<?= $this->lang->line('request_error')?>");
2020-08-27 09:37:45 +00:00
}
},
error: function (resultat, statut, error) {
console.log(resultat + " " + error);
2022-04-18 11:39:19 +00:00
toastr.error("<?= $this->lang->line('error_message')?>", "<?= $this->lang->line('request_error')?>");
2020-08-27 09:37:45 +00:00
}
});
} else {
$('#ratesForm')[0].reportValidity();
}
});
$('#saveTaxes').click(function () {
const network_id = $(this).data('network-id');
const id_config = $(this).data('id-config');
// Paliers
var taxes = [];
$('#nano_credit_taxes tr').has('td').each(function () {
var arrayItem = {};
$('td', $(this)).each(function (index, item) {
if (index < 3) {
if (index == 2)
arrayItem[index] = parseFloat($(item).html());
arrayItem[index] = $(item).html();
}
});
taxes.push(arrayItem);
});
if ($('#taxForm')[0].checkValidity()) {
$.ajax({
2022-04-18 11:39:19 +00:00
url: '<?= base_url('Gestion/saveTaxes')?>',
2020-08-27 09:37:45 +00:00
type: 'POST',
dataType: 'json',
data: {
"categorie": 'nano_credit', "id_config": id_config,
"taxes": taxes,
},
success: function (data) {
if (data == '200') {
Swal.fire({
icon: 'success',
2022-04-18 11:39:19 +00:00
title: "<?= $this->lang->line('nano_credit_update')?>",
text: "<?= $this->lang->line('informations_updated')?>",
2020-08-27 09:37:45 +00:00
timer: 3000
}).then(() => {
location.reload();
});
} else {
2022-04-18 11:39:19 +00:00
toastr.error("<?= $this->lang->line('error_message')?>", "<?= $this->lang->line('request_error')?>");
2020-08-27 09:37:45 +00:00
}
},
error: function (resultat, statut, error) {
console.log(resultat + " " + error);
2022-04-18 11:39:19 +00:00
toastr.error("<?= $this->lang->line('error_message')?>", "<?= $this->lang->line('request_error')?>");
2020-08-27 09:37:45 +00:00
}
});
} else {
$('#taxForm')[0].reportValidity();
}
});
2020-09-09 07:27:25 +00:00
$('#updateWallet').click(function () {
const taux_ag = parseFloat($('#taux_ag_nano_credit').val());
const taux_sup = parseFloat($('#taux_sup_nano_credit').val());
const taux_hyp = parseFloat($('#taux_hyp_nano_credit').val());
const id_network = $(this).data('network-id');
// const id_config = $(this).data('id-config');
// total répartition commission réseau retrait carte-cash chez agent (retrait)
const total4 = parseFloat($('#taux_ag_nano_credit').val()) + parseFloat($('#taux_sup_nano_credit').val()) + parseFloat($('#taux_hyp_nano_credit').val());
if (total4 != 100) {
2022-04-18 11:39:19 +00:00
toastr.error("<?= $this->lang->line('nano_credit_rule')?>", "<?= $this->lang->line('management_rule')?>");
2020-09-09 07:27:25 +00:00
}else {
if ($('#walletForm')[0].checkValidity()) {
$.ajax({
2022-04-18 11:39:19 +00:00
url: '<?= base_url('Hyperviseur_dash/saveNanoCreditSharedRates')?>',
2020-09-09 07:27:25 +00:00
type: 'POST',
dataType: 'json',
data: {
"taux_sup": taux_sup, "taux_hyp": taux_hyp,
"taux_ag": taux_ag,
"id_network": id_network
},
success: function (data) {
if (data == '200') {
Swal.fire({
icon: 'success',
2022-04-18 11:39:19 +00:00
title: "<?= $this->lang->line('nano_credit_update')?>",
text: "<?= $this->lang->line('informations_updated')?>",
2020-09-09 07:27:25 +00:00
timer: 3000
}).then(() => {
location.reload();
});
// alert("Les informations ont été mises à jour.") ? "" :
} else {
2022-04-18 11:39:19 +00:00
toastr.error("<?= $this->lang->line('error_message')?>", "<?= $this->lang->line('request_error')?>");
2020-09-09 07:27:25 +00:00
}
},
error: function (resultat, statut, error) {
console.log(resultat + " " + error);
2022-04-18 11:39:19 +00:00
toastr.error("<?= $this->lang->line('error_message')?>", "<?= $this->lang->line('request_error')?>");
2020-09-09 07:27:25 +00:00
}
});
} else {
$('#walletForm')[0].reportValidity();
}
}
});
2020-08-27 09:37:45 +00:00
</script>
<script>
// Interets nano credits
$(document).ready(function () {
$('[data-toggle="tooltip"]').tooltip();
var actions5 = $("#rates td:last-child").html();
// Append table with add row form on add new button click
$(".new5").click(function () {
if (!actions5) {
actions5 = '<a class="add add5" title="Add" data-toggle="tooltip"><i class="material-icons">&#xE03B;</i></a>\n' +
' <a class="edit edit5" title="Edit" data-toggle="tooltip"><i class="material-icons">&#xE254;</i></a>\n' +
' <a class="delete delete5" title="Delete" data-toggle="tooltip"><i class="material-icons">&#xE872;</i></a>';
}
$(this).attr("disabled", "disabled");
var index = $("#rates tbody tr:last-child").index();
var row = "<tr> <td><input type='number' min='1' required class='form-control' name='time' id='time'></td> " +
"<td><input type='number' required class='form-control' name='rate' id='rate'></td>" +
"<td>" + actions5 + "</td>" +
"</tr>";
$("#rates").append(row);
$("#rates tbody tr").eq(index + 1).find(".add, .edit").toggle();
$('[data-toggle="tooltip"]').tooltip();
});
// Add row on add button click
$(document).on("click", ".add5", function () {
var empty = false;
var input = $(this).parents("tr").find('input');
var select = $(this).parents("tr").find('select');
input.each(function () {
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) {
select.each(function () {
$(this).parent("td").html($(this).val());
});
input.each(function () {
$(this).parent("td").html($(this).val());
});
$(this).parents("tr").find(".add, .edit").toggle();
$(".new5").removeAttr("disabled");
}
});
// Edit row on edit button click
$(document).on("click", ".edit5", function () {
$(this).parents("tr").find("td:not(:last-child)").each(function (index) {
if (index == 0)
$(this).html('<input type="number" required class="form-control" value="' + $(this).text() + '">');
if (index == 1)
$(this).html('<input type="number" required class="form-control" value="' + $(this).text() + '">');
});
$(this).parents("tr").find(".add, .edit").toggle();
$(".new5").attr("disabled", "disabled");
});
// Delete row on delete button click
$(document).on("click", ".delete5", function () {
$(this).parents("tr").remove();
$(".new5").removeAttr("disabled");
});
});
</script>
<script>
// Taxes nano credit
$(document).ready(function () {
$('[data-toggle="tooltip"]').tooltip();
var actions51 = $("#nano_credit_taxes td:last-child").html();
// Append table with add row form on add new button click
$(".new51").click(function () {
if (!actions51) {
actions51 = '<a class="add add51" title="Add" data-toggle="tooltip"><i class="material-icons">&#xE03B;</i></a>\n' +
' <a class="edit edit51" title="Edit" data-toggle="tooltip"><i class="material-icons">&#xE2514;</i></a>\n' +
' <a class="delete delete51" title="Delete" data-toggle="tooltip"><i class="material-icons">&#xE872;</i></a>';
}
$(this).attr("disabled", "disabled");
var index = $("#nano_credit_taxes tbody tr:last-child").index();
var row = "<tr> <td><input type='text' required class='form-control' name='nom' id='nom'></td> " +
"<td> <select class='form-control' id='type' required> <option value='%'> % </option> <option value='fixe'> fixe </option> </select> </td> " +
"<td><input type='number' required class='form-control' step='any' min='0' name='valeur' id='valeur'></td>" +
2020-08-27 09:37:45 +00:00
"<td>" + actions51 + "</td>" +
"</tr>";
$("#nano_credit_taxes").append(row);
$("#nano_credit_taxes tbody tr").eq(index + 1).find(".add, .edit").toggle();
$('[data-toggle="tooltip"]').tooltip();
});
// Add row on add button click
$(document).on("click", ".add51", function () {
var empty = false;
var input = $(this).parents("tr").find('input');
var select = $(this).parents("tr").find('select');
input.each(function () {
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) {
select.each(function () {
$(this).parent("td").html($(this).val());
});
input.each(function () {
$(this).parent("td").html($(this).val());
});
$(this).parents("tr").find(".add, .edit").toggle();
$(".new51").removeAttr("disabled");
}
});
// Edit row on edit button click
$(document).on("click", ".edit51", function () {
$(this).parents("tr").find("td:not(:last-child)").each(function (index) {
if (index == 0)
$(this).html('<input type="text" required class="form-control" value="' + $(this).text() + '">');
if (index == 1)
$(this).html("<select class='form-control' id='type' required> <option value='%' > % </option> <option value='fixe'> fixe </option> </select>");
if (index == 2)
$(this).html('<input type="number" required class="form-control" step="any" min="0" value="' + $(this).text() + '">');
2020-08-27 09:37:45 +00:00
});
$(this).parents("tr").find(".add, .edit").toggle();
$(".new51").attr("disabled", "disabled");
});
// Delete row on delete button click
$(document).on("click", ".delete51", function () {
$(this).parents("tr").remove();
$(".new51").removeAttr("disabled");
});
});
</script>
<!-- Page script -->
<!--<script src="--><?php //echo base_url('dist/js/custom.js') ?><!--"></script>-->