+ Fix regulations limits

This commit is contained in:
Djery-Tom 2020-10-05 17:46:35 +01:00
parent 1ef09b3298
commit 36ce2e3ac0
7 changed files with 103 additions and 50 deletions

View File

@ -2260,14 +2260,21 @@ class Gestion extends CI_Controller
if (isset($_POST)) {
$country_id = $_POST['country_id'];
$max_day = $_POST['max_day'];
$max_week = $_POST['max_week'];
$max_month = $_POST['max_month'];
$max_day_national = $_POST['max_day_national'];
$max_week_national = $_POST['max_week_national'];
$max_month_national = $_POST['max_month_national'];
$max_day_international = $_POST['max_day_international'];
$max_week_international = $_POST['max_week_international'];
$max_month_international = $_POST['max_month_international'];
$limits = $this->wallet_model->getRegulationsLimits($country_id);
if($limits){
$this->wallet_model->updateRegulationsLimits($country_id,$max_day,$max_week,$max_month);
$this->wallet_model->updateRegulationsLimits($country_id,$max_day_national,$max_week_national,$max_month_national,
$max_day_international,$max_week_international,$max_month_international);
}else{
$this->wallet_model->insertRegulationsLimits($country_id,$max_day,$max_week,$max_month);
$this->wallet_model->insertRegulationsLimits($country_id,$max_day_national,$max_week_national,$max_month_national,
$max_day_international,$max_week_international,$max_month_international);
}
$res = true;
if ($res) {

View File

@ -503,4 +503,7 @@ $lang['regulations_updated'] = 'Regulatory limits updated';
$lang['refunded_amount'] = "Amount refunded";
$lang['remains_to_be_reimbursed'] = "Remainder to reimburse";
$lang['end_date'] = "End date";
$lang['cash_withdrawal'] = "Withdrawal in cash";
$lang['validation_date'] = "Date of validation";
$lang['repayment_date'] = "Repayment date";
?>

View File

@ -515,4 +515,7 @@ $lang['regulations_updated'] = 'Limites réglementaires mis à jour';
$lang['refunded_amount'] = "Montant remboursé";
$lang['remains_to_be_reimbursed'] = "Reste à rembourser";
$lang['end_date'] = "Date de fin";
$lang['cash_withdrawal'] = "Retrait en cash";
$lang['validation_date'] = "Date de la validation";
$lang['repayment_date'] = "Date de remboursement";
?>

View File

@ -829,7 +829,8 @@ class Wallet_model extends CI_Model
// Gestion reglementaire
public function getRegulationsCountries(){
$query = $this->db->query("SELECT distinct cc.id , cc.name as country , cc.currency_code, r.id_country, r.montant_max_jour, r.montant_max_hebdo, r.montant_max_mensuel FROM networks n
$query = $this->db->query("SELECT distinct cc.id , cc.name as country , cc.currency_code, r.id_country, r.montant_max_jour_national, r.montant_max_hebdo_national, r.montant_max_mensuel_national,
r.montant_max_jour_international, r.montant_max_hebdo_international, r.montant_max_mensuel_international FROM networks n
INNER JOIN countries_currencies cc ON n.country_id= cc.id INNER JOIN configWallet cw ON cw.id_network = n.id LEFT JOIN regulations r ON r.id_country = cc.id;");
if ($query->num_rows() > 0) {
return $query;
@ -847,15 +848,17 @@ INNER JOIN countries_currencies cc ON n.country_id= cc.id INNER JOIN configWalle
}
}
public function insertRegulationsLimits($id_country, $max_day , $max_week , $max_month){
$sql = "INSERT INTO `regulations` (`id_country`, `montant_max_jour`, `montant_max_hebdo`, `montant_max_mensuel`) VALUES (?,?, ?, ?);";
$query = $this->db->query($sql , array($id_country,$max_day,$max_week,$max_month));
public function insertRegulationsLimits($id_country, $max_day_national , $max_week_national , $max_month_national, $max_day_international , $max_week_international , $max_month_international){
$sql = "INSERT INTO `regulations` (`id_country`, `montant_max_jour_national`, `montant_max_hebdo_national`, `montant_max_mensuel_national`,
`montant_max_jour_international`, `montant_max_hebdo_international`, `montant_max_mensuel_international`) VALUES (?,?, ?, ?,?,?,?);";
$query = $this->db->query($sql , array($id_country,$max_day_national,$max_week_national,$max_month_national,$max_day_international,$max_week_international,$max_month_international));
return $query;
}
public function updateRegulationsLimits($id_country, $max_day , $max_week , $max_month){
$sql = "UPDATE `regulations` SET `montant_max_jour` = ? , `montant_max_hebdo` = ? , `montant_max_mensuel` = ? WHERE (`id_country` = ?);";
$query = $this->db->query($sql , array($max_day,$max_week,$max_month,$id_country));
public function updateRegulationsLimits($id_country, $max_day_national , $max_week_national , $max_month_national, $max_day_international , $max_week_international , $max_month_international){
$sql = "UPDATE `regulations` SET `montant_max_jour_national` = ? , `montant_max_hebdo_national` = ? , `montant_max_mensuel_national` = ?,
`montant_max_jour_international` = ? , `montant_max_hebdo_international` = ? , `montant_max_mensuel_international` = ? WHERE (`id_country` = ?);";
$query = $this->db->query($sql , array($max_day_national,$max_week_national,$max_month_national,$max_day_international,$max_week_international,$max_month_international,$id_country));
return $query;
}
}

View File

@ -65,9 +65,12 @@ $context = new \Brick\Money\Context\AutoContext();
<tr>
<th align='center'></th>
<th><?php echo $this->lang->line('Pays'); ?></th>
<th align='center'><?php echo $this->lang->line('max_amount_per_day'); ?></th>
<th align='center'><?php echo $this->lang->line('max_amount_per_week'); ?></th>
<th align='center'><?php echo $this->lang->line('max_amount_per_month'); ?></th>
<th align='center'><?php echo $this->lang->line('max_amount_per_day').' national'; ?></th>
<th align='center'><?php echo $this->lang->line('max_amount_per_week').' national'; ?></th>
<th align='center'><?php echo $this->lang->line('max_amount_per_month').' national'; ?></th>
<th align='center'><?php echo $this->lang->line('max_amount_per_day').' international'; ?></th>
<th align='center'><?php echo $this->lang->line('max_amount_per_week').' international'; ?></th>
<th align='center'><?php echo $this->lang->line('max_amount_per_month').' international'; ?></th>
<th align='center'> Action </th>
</tr>
</thead>
@ -82,10 +85,13 @@ $context = new \Brick\Money\Context\AutoContext();
?>
<?php
?>
<td> <?php if($row->id_country) echo Money::of(round($row->montant_max_jour, 2), $row->currency_code, $context)->formatTo('fr_FR') ?></td>
<td><?php if($row->id_country) echo Money::of(round($row->montant_max_hebdo, 2), $row->currency_code, $context)->formatTo('fr_FR') ?></td>
<td><?php if($row->id_country) echo Money::of(round($row->montant_max_mensuel, 2), $row->currency_code, $context)->formatTo('fr_FR'); ?></td>
<?php
<td> <?php if($row->id_country) echo Money::of(round($row->montant_max_jour_national, 2), $row->currency_code, $context)->formatTo('fr_FR') ?></td>
<td><?php if($row->id_country) echo Money::of(round($row->montant_max_hebdo_national, 2), $row->currency_code, $context)->formatTo('fr_FR') ?></td>
<td><?php if($row->id_country) echo Money::of(round($row->montant_max_mensuel_national, 2), $row->currency_code, $context)->formatTo('fr_FR'); ?></td>
<td> <?php if($row->id_country) echo Money::of(round($row->montant_max_jour_international, 2), $row->currency_code, $context)->formatTo('fr_FR') ?></td>
<td><?php if($row->id_country) echo Money::of(round($row->montant_max_hebdo_international, 2), $row->currency_code, $context)->formatTo('fr_FR') ?></td>
<td><?php if($row->id_country) echo Money::of(round($row->montant_max_mensuel_international, 2), $row->currency_code, $context)->formatTo('fr_FR'); ?></td>
<?php
?>
<td>
@ -97,32 +103,55 @@ $context = new \Brick\Money\Context\AutoContext();
</td>
<div class="modal fade" id="<?='configureLimits'.$num?>" tabindex="-1" role="dialog" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-dialog modal-lg" role="document">
<div class="modal-content">
<div class="modal-header">
<h3 class="modal-title"><?php echo $this->lang->line('define_the_limits'); ?></h3>
</div>
<div class="modal-body">
<form id="<?='limitsForm'.$num?>">
<div class="form-group">
<label for="rate"
class="col-form-label"><?= $this->lang->line('max_amount_per_day') ?></label>
<input type="number" min="0" step=".01" required class="form-control"
name="max_day" id="<?='max_day'.$num?>" value="<?=$row->montant_max_jour?>">
</div>
<div class="form-group">
<label for="url"
class="col-form-label"><?= $this->lang->line('max_amount_per_week') ?></label>
<input type="number" min="0" step=".01" required class="form-control" value="<?=$row->montant_max_hebdo?>"
id="<?='max_week'.$num?>" name="max_week">
</div>
<form id="<?='limitsForm'.$num?>" class="row">
<div class="col-lg-6 col-md-6">
<div class="form-group">
<label for="rate"
class="col-form-label"><?= $this->lang->line('max_amount_per_day').' national' ?></label>
<input type="number" min="0" step=".01" required class="form-control"
name="max_day_national" id="<?='max_day_national'.$num?>" value="<?=$row->montant_max_jour_national?>">
</div>
<div class="form-group">
<label for="url"
class="col-form-label"><?= $this->lang->line('max_amount_per_week').' national' ?></label>
<input type="number" min="0" step=".01" required class="form-control" value="<?=$row->montant_max_hebdo_national?>"
id="<?='max_week_national'.$num?>" name="max_week_national">
</div>
<div class="form-group">
<label for="url"
class="col-form-label"><?= $this->lang->line('max_amount_per_month') ?></label>
<input type="number" min="0" step=".01" required class="form-control" value="<?=$row->montant_max_mensuel?>"
id="<?='max_month'.$num?>" name="max_month">
</div>
<div class="form-group">
<label for="url"
class="col-form-label"><?= $this->lang->line('max_amount_per_month').' national' ?></label>
<input type="number" min="0" step=".01" required class="form-control" value="<?=$row->montant_max_mensuel_national?>"
id="<?='max_month_national'.$num?>" name="max_month_national">
</div>
</div>
<div class="col-lg-6 col-md-6">
<div class="form-group">
<label for="rate"
class="col-form-label"><?= $this->lang->line('max_amount_per_day').' international' ?></label>
<input type="number" min="0" step=".01" required class="form-control"
name="max_day_international" id="<?='max_day_international'.$num?>" value="<?=$row->montant_max_jour_international?>">
</div>
<div class="form-group">
<label for="url"
class="col-form-label"><?= $this->lang->line('max_amount_per_week').' international' ?></label>
<input type="number" min="0" step=".01" required class="form-control" value="<?=$row->montant_max_hebdo_international?>"
id="<?='max_week_international'.$num?>" name="max_week_international">
</div>
<div class="form-group">
<label for="url"
class="col-form-label"><?= $this->lang->line('max_amount_per_month').' international' ?></label>
<input type="number" min="0" step=".01" required class="form-control" value="<?=$row->montant_max_mensuel_international?>"
id="<?='max_month_international'.$num?>" name="max_month_international">
</div>
</div>
</form>
</div>
<div class="modal-footer">
@ -203,14 +232,22 @@ $context = new \Brick\Money\Context\AutoContext();
$(document).on("click", ".setLimits", function () {
if ($('#limitsForm'+num)[0].checkValidity()) {
const max_day = parseFloat($('#max_day'+num).val());
const max_week = parseFloat($('#max_week'+num).val());
const max_month = parseFloat($('#max_month'+num).val());
const max_day_national = parseFloat($('#max_day_national'+num).val());
const max_week_national = parseFloat($('#max_week_national'+num).val());
const max_month_national = parseFloat($('#max_month_national'+num).val());
const max_day_international = parseFloat($('#max_day_international'+num).val());
const max_week_international = parseFloat($('#max_week_international'+num).val());
const max_month_international = parseFloat($('#max_month_international'+num).val());
$.ajax({
url: '<?php echo base_url('index.php/Gestion/setRegulationsLimits')?>',
type: 'POST',
dataType: 'json',
data: {"country_id": country_id, "max_day": max_day, "max_week": max_week,"max_month" : max_month},
data: {"country_id": country_id,
"max_day_national": max_day_national, "max_week_national": max_week_national,"max_month_national" : max_month_national,
"max_day_international": max_day_international, "max_week_international": max_week_international,"max_month_international" : max_month_international
},
success: function (data) {
if (data == '200') {
Swal.fire({

View File

@ -135,9 +135,9 @@
<th><?php echo $this->lang->line('tax') ?></th>
<th><?php echo $this->lang->line('agent_name') ?></th>
<th><?php echo $this->lang->line('issuer_id') ?></th>
<th>Retrait en cash</th>
<th>Date de la demande</th>
<th>Date de remboursement</th>
<th><?php echo $this->lang->line('cash_withdrawal') ?></th>
<th><?php echo $this->lang->line('validation_date') ?></th>
<th><?php echo $this->lang->line('repayment_date') ?></th>
<th align='center'><?php echo $this->lang->line('created_date') ?></th>
</tr>
</thead>
@ -159,7 +159,7 @@
$retrait = "";
echo "<tr>
<td align='center' >$row->id_demande</td>
<td>" . strtoupper($row->etat) . "</td>
<td>" . str_replace('_',' ',$row->etat) . "</td>
<td>" . strtoupper($row->type_caution) . "</td>
<td>" . strtoupper($row->duree_mois) . "</td>
<td>" . Money::of(round($row->montant_rembourse, 2), $currency_code, $context)->formatTo('fr_FR') . "</td>
@ -169,7 +169,7 @@
<td>" . $row->agent . "</td>
<td>" . $emetteur . "</td>
<td>" . $retrait . "</td>
<td>" . toLocateDate($row->date_demande, $this->session->userdata('timezone')) . "</td>
<td>" . toLocateDate($row->date_validation, $this->session->userdata('timezone')) . "</td>
<td>" . toLocateDate($row->date_remboursement, $this->session->userdata('timezone')) . "</td>
<td>" . toLocateDate($row->date_creation, $this->session->userdata('timezone')) . "</td>";
?>

View File

@ -151,12 +151,12 @@
$moneyNet = Money::of(round($row->montant, 2), $currency_code, $context);
echo "<tr>
<td align='center' >$row->id_epargne</td>
<td>" . strtoupper($row->etat) . "</td>
<td>" . str_replace('_',' ',$row->etat) . "</td>
<td>" . strtoupper($row->duree_mois) . "</td>
<td>" . $moneyNet->formatTo('fr_FR') . "</td>
<td>" . Money::of(round($row->interet, 2), $currency_code, $context)->formatTo('fr_FR') . "</td>
<td>" . Money::of(round($row->taxe, 2), $currency_code, $context)->formatTo('fr_FR') . "</td>
<td>" . $emetteur . "</td>
<td>" . $emetteur. "</td>
<td>" . toLocateDate($row->date_creation, $this->session->userdata('timezone')) . "</td>
<td>" . toLocateDate($row->date_cassation, $this->session->userdata('timezone')) . "</td>
<td>" . toLocateDate($row->date_fin, $this->session->userdata('timezone')) . "</td>";