Add payment_period_days to customers openings accounts configuration

This commit is contained in:
Djery-Tom 2022-12-19 17:03:39 +01:00
parent 9384d0842f
commit 322160a631
6 changed files with 133 additions and 84 deletions

View File

@ -90,7 +90,7 @@ class OpeningAccountAgent extends CI_Controller
public function treatRequest($request_id) public function treatRequest($request_id)
{ {
echo makeRequest('user-service', 'PUT','/customers_accounts_requests/'.$request_id.'/treat', $_POST); echo makeRequest('user-service', 'PUT','/customers_accounts_requests/'.$request_id, $_POST);
} }
private function isLogged() private function isLogged()

View File

@ -1049,4 +1049,6 @@ $lang['debit_card_type'] = "Debit card type";
$lang['opening_account_request_accepted'] = "Customer account opening request accepted"; $lang['opening_account_request_accepted'] = "Customer account opening request accepted";
$lang['opening_account_request_rejected'] = "The request to open an account has been rejected"; $lang['opening_account_request_rejected'] = "The request to open an account has been rejected";
$lang['opening_account_request_more_information'] = "The request to open an account has been rejected"; $lang['opening_account_request_more_information'] = "The request to open an account has been rejected";
$lang['payment_period_days'] = "Payment period (in days)";
$lang['required_payment_period_days'] = "Payment period is required"
?> ?>

View File

@ -1057,4 +1057,6 @@ $lang['debit_card_type'] = "Type de carte de débit";
$lang['opening_account_request_accepted'] = "La demande d'ouverture de compte client été acceptée"; $lang['opening_account_request_accepted'] = "La demande d'ouverture de compte client été acceptée";
$lang['opening_account_request_rejected'] = "La demande d'ouverture de compte client été rejetée"; $lang['opening_account_request_rejected'] = "La demande d'ouverture de compte client été rejetée";
$lang['opening_account_request_more_information'] = "La demande d'ouverture de compte client en attente de complement d'informations"; $lang['opening_account_request_more_information'] = "La demande d'ouverture de compte client en attente de complement d'informations";
$lang['payment_period_days'] = "Délai de paiement (en jours)";
$lang['required_payment_period_days'] = "Délai de paiement est obligatoire"
?> ?>

View File

@ -70,6 +70,8 @@
$this->converter = new CurrencyConverter($provider); $this->converter = new CurrencyConverter($provider);
$this->context = new AutoContext(); $this->context = new AutoContext();
$fmt = new NumberFormatter('fr_FR', NumberFormatter::DECIMAL); $fmt = new NumberFormatter('fr_FR', NumberFormatter::DECIMAL);
$context = new AutoContext();
?> ?>
</section> </section>
@ -100,8 +102,25 @@
</div> </div>
</div> </div>
<?php if(in_array($request->status, ['REJECTED','MORE_INFORMATION'])) { ?> <?php if(!empty($request->opening_amount)) { ?>
<div class="col-lg-4 col-xs-6"> <div class="col-lg-4 col-xs-6">
<div class="small-box bg-blue-active">
<div class="inner">
<h3 style="white-space: pre-wrap; font-size: 1.9em;"><?= Money::of(round($request->opening_amount, 2), $request->currency_code ?? 'XAF', $context)->formatTo('fr_FR') ?> </h3>
<p><?= $this->lang->line('opening_amount') ?></p>
</div>
<div class="icon">
<i class="fa fa-money"></i>
</div>
</div>
</div>
<?php } ?>
</div>
<?php if(in_array($request->status, ['REJECTED','MORE_INFORMATION'])) { ?>
<div class="row">
<div class="col-lg-12">
<div class="small-box bg-blue-active"> <div class="small-box bg-blue-active">
<div class="inner"> <div class="inner">
<p style="white-space: pre-wrap;"><?= $request->reject_reason ?> </p> <p style="white-space: pre-wrap;"><?= $request->reject_reason ?> </p>
@ -112,10 +131,8 @@
</div> </div>
</div> </div>
</div> </div>
<?php
}
?>
</div> </div>
<?php } ?>
<!-- Personal details --> <!-- Personal details -->
<div class="box box-success"> <div class="box box-success">

View File

@ -54,7 +54,7 @@
<th align='center'><?=$this->lang->line('request_id')?></th> <th align='center'><?=$this->lang->line('request_id')?></th>
<th>Type</th> <th>Type</th>
<th><?= $this->lang->line('Nom') ?></th> <th><?= $this->lang->line('Nom') ?></th>
<th><?= $this->lang->line('Nom') ?></th> <th><?= $this->lang->line('Prénom') ?></th>
<th><?= $this->lang->line('Contact') ?></th> <th><?= $this->lang->line('Contact') ?></th>
<th><?= $this->lang->line('state') ?></th> <th><?= $this->lang->line('state') ?></th>
<th>Date </th> <th>Date </th>

View File

@ -33,6 +33,7 @@
<th>Description</th> <th>Description</th>
<th>Parent</th> <th>Parent</th>
<th><?= $this->lang->line('opening_amount'); ?></th> <th><?= $this->lang->line('opening_amount'); ?></th>
<th><?= $this->lang->line('payment_period_days'); ?></th>
<th>Action</th> <th>Action</th>
</tr> </tr>
</thead> </thead>
@ -44,9 +45,10 @@
<td><?=$row->description?></td> <td><?=$row->description?></td>
<td><?=$row->parent?></td> <td><?=$row->parent?></td>
<td><?= empty($row->opening_amount) ? '' : Money::of(round($row->opening_amount, 2), $currency_code ?? 'XAF', $context)->formatTo('fr_FR')?></td> <td><?= empty($row->opening_amount) ? '' : Money::of(round($row->opening_amount, 2), $currency_code ?? 'XAF', $context)->formatTo('fr_FR')?></td>
<td><?= $row->opening_amount_payment_period_days?></td>
<td> <td>
<button class="btn btn-success edit" data-id="<?=$row->id?>" data-name="<?=$row->name?>" data-description="<?=$row->description?>" <button class="btn btn-success edit" data-id="<?=$row->id?>" data-name="<?=$row->name?>" data-description="<?=$row->description?>"
data-parent_id="<?=$row->parent_id?>" data-opening_amount="<?=$row->opening_amount?>"> data-parent_id="<?=$row->parent_id?>" data-opening_amount="<?=$row->opening_amount?>" data-opening_amount_payment_period_days="<?=$row->opening_amount_payment_period_days?>">
<i class="fa fa-edit"></i> <i class="fa fa-edit"></i>
</button> </button>
<button data-toggle="modal" class="btn btn-danger delete-doc" data-id="<?=$row->id?>" > <button data-toggle="modal" class="btn btn-danger delete-doc" data-id="<?=$row->id?>" >
@ -79,6 +81,10 @@
<label for="opening_amount"><?= $this->lang->line('opening_amount'); ?></label> <label for="opening_amount"><?= $this->lang->line('opening_amount'); ?></label>
<input type="number" value="" class="form-control input-lg" name="opening_amount" id="opening_amount"> <input type="number" value="" class="form-control input-lg" name="opening_amount" id="opening_amount">
</div> </div>
<div class="form-group">
<label for="opening_amount_payment_period_days_u"><?= $this->lang->line('payment_period_days'); ?></label>
<input type="number" value="" class="form-control input-lg" name="opening_amount_payment_period_days" id="opening_amount_payment_period_days_u">
</div>
<div class="form-group"> <div class="form-group">
<label class="col-form-label">Parent</label> <label class="col-form-label">Parent</label>
<select class="form-control input-lg" name="parent_id" > <select class="form-control input-lg" name="parent_id" >
@ -108,7 +114,7 @@
<h4 class="modal-title"><?= $this->lang->line('Mettre à jour des informations'); ?></h4> <h4 class="modal-title"><?= $this->lang->line('Mettre à jour des informations'); ?></h4>
</div> </div>
<div class="modal-body"> <div class="modal-body">
<form id="update-form" method="post" class="bottom-75 center-block"> <form id="update-form" class="bottom-75 center-block">
<div class="form-group"> <div class="form-group">
<label for="name_u"><?= $this->lang->line('Nom'); ?></label> <label for="name_u"><?= $this->lang->line('Nom'); ?></label>
<input type="text" class="form-control input-lg" name="name" id="name_u" required> <input type="text" class="form-control input-lg" name="name" id="name_u" required>
@ -121,6 +127,10 @@
<label for="opening_amount_u"><?= $this->lang->line('opening_amount'); ?></label> <label for="opening_amount_u"><?= $this->lang->line('opening_amount'); ?></label>
<input type="number" value="" class="form-control input-lg" name="opening_amount" id="opening_amount_u"> <input type="number" value="" class="form-control input-lg" name="opening_amount" id="opening_amount_u">
</div> </div>
<div class="form-group">
<label for="opening_amount_payment_period_days_u"><?= $this->lang->line('payment_period_days'); ?></label>
<input type="number" value="" class="form-control input-lg" name="opening_amount_payment_period_days" id="opening_amount_payment_period_days_u">
</div>
<div class="form-group"> <div class="form-group">
<label class="col-form-label">Parent</label> <label class="col-form-label">Parent</label>
<select class="form-control input-lg" name="parent_id" ></select> <select class="form-control input-lg" name="parent_id" ></select>
@ -150,8 +160,9 @@
</table> </table>
</div> </div>
<div class="form-group"> <div class="form-group">
<input id="btn-update" type="submit" <button type="submit" class="btn btn-primary">
value="<?= $this->lang->line('save'); ?>" class="btn btn-primary"> <?= $this->lang->line('save'); ?>
</button>
<button type="button" class="btn btn-default pull-right" <button type="button" class="btn btn-default pull-right"
data-dismiss="modal"><?= $this->lang->line('Fermer'); ?></button> data-dismiss="modal"><?= $this->lang->line('Fermer'); ?></button>
</div> </div>
@ -274,6 +285,7 @@
$("#update-form input[name='name']").val($(this).data('name')); $("#update-form input[name='name']").val($(this).data('name'));
$("#update-form textarea[name='description']").val($(this).data('description')); $("#update-form textarea[name='description']").val($(this).data('description'));
$("#update-form input[name='opening_amount']").val($(this).data('opening_amount')); $("#update-form input[name='opening_amount']").val($(this).data('opening_amount'));
$("#update-form input[name='opening_amount_payment_period_days']").val($(this).data('opening_amount_payment_period_days'));
$("#update-form select[name='parent_id']").empty().append("<option value='0'>"+ "<?this->lang->line('no_parent')?>" + "</option>"); $("#update-form select[name='parent_id']").empty().append("<option value='0'>"+ "<?this->lang->line('no_parent')?>" + "</option>");
$.each(types, function (j, it) { $.each(types, function (j, it) {
@ -306,6 +318,13 @@
}); });
$("#update-form").submit(function () { $("#update-form").submit(function () {
let openingAmount = $("input[name=opening_amount]",this).val();
let paymentPeriod = $("input[name=opening_amount_payment_period_days]",this).val();
if (openingAmount && !paymentPeriod){
toastr.warning("<?= $this->lang->line('required_payment_period_days')?>" , "<?= $this->lang->line('request_error')?>");
}else {
// Paliers // Paliers
var documents = []; var documents = [];
@ -328,6 +347,7 @@
name: $("input[name=name]",this).val(), name: $("input[name=name]",this).val(),
description: $("textarea[name=description]",this).val(), description: $("textarea[name=description]",this).val(),
opening_amount: $("input[name=opening_amount]",this).val(), opening_amount: $("input[name=opening_amount]",this).val(),
opening_amount_payment_period_days: $("input[name=opening_amount_payment_period_days]", this).val(),
parent_id : $("select[name=parent_id]",this).val(), parent_id : $("select[name=parent_id]",this).val(),
documents: documents documents: documents
}, },
@ -351,42 +371,50 @@
toastr.error("<?= $this->lang->line('error_message')?>" , "<?= $this->lang->line('request_error')?>"); toastr.error("<?= $this->lang->line('error_message')?>" , "<?= $this->lang->line('request_error')?>");
} }
}); });
}
event.preventDefault(); event.preventDefault();
}); });
$("#create-form").submit(function (event) { $("#create-form").submit(function (event) {
let openingAmount = $("input[name=opening_amount]",this).val();
let paymentPeriod = $("input[name=opening_amount_payment_period_days]",this).val();
if (openingAmount && !paymentPeriod){
toastr.warning("<?= $this->lang->line('required_payment_period_days')?>" , "<?= $this->lang->line('request_error')?>");
}else {
$.ajax({ $.ajax({
url: '<?= base_url('Hyperviseur_dash/storeCustomerAccountType')?>', url: '<?= base_url('Hyperviseur_dash/storeCustomerAccountType')?>',
type: 'post', type: 'post',
data: { data: {
network_id : networkId, network_id: networkId,
name: $("input[name=name]",this).val(), name: $("input[name=name]", this).val(),
description: $("textarea[name=description]",this).val(), description: $("textarea[name=description]", this).val(),
opening_amount: $("input[name=opening_amount]",this).val(), opening_amount: $("input[name=opening_amount]", this).val(),
parent_id : $("select[name=parent_id]",this).val() opening_amount_payment_period_days: $("input[name=opening_amount_payment_period_days]", this).val(),
parent_id: $("select[name=parent_id]", this).val()
}, },
dataType: 'json', dataType: 'json',
success: function (data) { success: function (data) {
if(data.code === 200){ if (data.code === 200) {
Swal.fire({ Swal.fire({
icon: 'success', icon: 'success',
title: "<?= $this->lang->line('customer_account_type_created')?>", title: "<?= $this->lang->line('customer_account_type_created')?>",
text:"<?= $this->lang->line('informations_updated')?>", text: "<?= $this->lang->line('informations_updated')?>",
timer: 3000 timer: 3000
}).then(()=>{ }).then(() => {
location.reload(); location.reload();
}); });
}else{ } else {
toastr.error(data.message , "<?= $this->lang->line('request_error')?>"); toastr.error(data.message, "<?= $this->lang->line('request_error')?>");
} }
}, },
error: function (resultat, statut, error) { error: function (resultat, statut, error) {
console.log(resultat + " " + error); console.log(resultat + " " + error);
toastr.error("<?= $this->lang->line('error_message')?>" , "<?= $this->lang->line('request_error')?>"); toastr.error("<?= $this->lang->line('error_message')?>", "<?= $this->lang->line('request_error')?>");
} }
}); });
}
event.preventDefault(); event.preventDefault();
}); });