Add history of deleted beneficiaries

This commit is contained in:
Djery-Tom 2022-02-04 17:52:51 +01:00
parent 674688b954
commit 082596b291
5 changed files with 190 additions and 2 deletions

View File

@ -407,6 +407,7 @@ class Hyperviseur_dash extends CI_Controller
$data['beneficiaries'] = $this->nano_health_model->getInsuranceBeneficiaries($data['insurance']->id ?? null);
$data['user'] = $this->db->get_where('user_infos',['user_id' => $data['insurance']->user_id ?? null])->first_row();
$data['transactions'] = $this->nano_health_model->getInsurancePaymentTransactions($this->input->get('id'));
$data['deletion_of_beneficiaries'] = $this->nano_health_model->getBeneficiariesDeletionHistory($data['insurance']->id ?? null);
$this->load->view('header_hyp', $data);
$this->load->view('nano_health/hyper/infos_insurance');

View File

@ -862,4 +862,7 @@ $lang['request_id'] = "Request ID";
$lang['export_request_list'] = "Export request list";
$lang['USED'] = "Used";
$lang['used_care_requests'] = "Used care requests";
$lang['beneficiaries_deletion_history'] = "Deletion history of beneficiaries";
$lang['deletion_date'] = "Date of deletion";
$lang['STOP_INSURANCE'] = "Stopping insurance";
?>

View File

@ -873,4 +873,7 @@ $lang['request_id'] = "ID de la demande";
$lang['export_request_list'] = "Exporter la liste des demandes";
$lang['USED'] = "Utilisée";
$lang['used_care_requests'] = "Demandes de soins utilisées";
$lang['beneficiaries_deletion_history'] = "Historique de suppression des ayants droit";
$lang['deletion_date'] = "Date de suppression";
$lang['STOP_INSURANCE'] = "Arrêt de l'assurance"
?>

View File

@ -150,4 +150,11 @@ class Nano_health_model extends CI_Model
}
return $query->count_all_results();
}
public function getBeneficiariesDeletionHistory($insuranceId){
return $this->db->select('b.* , i.deleted_at')
->from('nh_having_rights b')->join('nh_insurances_having_rights i', 'b.id = i.having_right_id')
->where('i.deleted_at IS NOT NULL')
->where('i.insurance_id',$insuranceId)->order_by('i.deleted_at','desc')->get();
}
}

View File

@ -163,7 +163,7 @@
<h3 class="box-title"><?= $this->lang->line('beneficiaries') ?></h3>
</div>
<div class="box-body" style="overflow-x:auto;">
<table id="example1" class="table table-bordered table-hover">
<table id="beneficiaries" class="table table-bordered table-hover">
<thead>
<tr>
<th>#</th>
@ -322,6 +322,134 @@
</div>
</div>
<div class="box box-primary">
<div class="box-header with-border">
<h3 class="box-title"><?= $this->lang->line('beneficiaries_deletion_history') ?></h3>
</div>
<div class="box-body" style="overflow-x:auto;">
<table id="deleted-beneficiaries" class="table table-bordered table-hover">
<thead>
<tr>
<th>#</th>
<th><?= $this->lang->line('Nom'); ?></th>
<th><?= $this->lang->line('gender'); ?></th>
<th><?= $this->lang->line('birth_date'); ?></th>
<th>Affiliation</th>
<th><?= $this->lang->line('bonus_amount'); ?></th>
<th><?= $this->lang->line('deletion_date'); ?></th>
<th>Images</th>
</tr>
</thead>
<tbody>
<?php
if (isset($deletion_of_beneficiaries)) {
foreach ($deletion_of_beneficiaries->result() as $i => $row) {
$bonus_amount = Money::of(round($row->bonus_amount, 2), $insurance->currency_code, $this->context)->formatTo('fr_FR');
echo "<tr>
<td>" . ($i+1) . "</td>
<td>" . $row->lastname.' '.$row->firstname . "</td>
<td>" . $row->gender . "</td>
<td>" . $row->birthdate . "</td>
<td>".$this->lang->line($row->affiliation)."</td>
<td>".$bonus_amount."</td>
<td>" . $row->deleted_at. "</td>";
?>
<td>
<button class="btn btn-primary" data-target="<?= '#images-modal'.$i ?>" data-toggle="modal">
<?= $this->lang->line('show'); ?>
</button>
</td>
</tr>
<div class="modal fade" id="<?= 'images-modal'.$i ?>">
<div class="modal-dialog modal-lg">
<div class="modal-content">
<div class="modal-header">
<h3 class="modal-title">Images des documents</h3>
</div>
<div class="modal-body">
<?php if($row->affiliation == 'CHILD') {
$birthdate_proof_doc = NANO_SANTE_SERVICE_URL . '/insurances-subscriptions-docs/'.$row->birthdate_proof_doc;
$birthdate_proof_doc_file = @fopen($birthdate_proof_doc ,'r');
$justice_doc = NANO_SANTE_SERVICE_URL . '/insurances-subscriptions-docs/'.$row->justice_doc;
$justice_doc_file = @fopen($justice_doc ,'r');
?>
<div class="row" style="margin-top: 10px">
<div class="col-sm-6 text-center">
<label><?= $this->lang->line('birthdate_proof_doc') ?></label>
<img src="<?= $birthdate_proof_doc_file ? $birthdate_proof_doc : base_url('images/broken.png') ?>"
alt="document_front" style="width: 100%;"/>
</div>
<div class="col-sm-6 text-center">
<label><?= $this->lang->line('justice_doc') ?></label>
<img src="<?= $justice_doc_file ? $justice_doc : base_url('images/broken.png')?>"
alt="document_back" style="width: 100%;"/>
</div>
</div>
<?php } else {
$marriage_certificate_doc = NANO_SANTE_SERVICE_URL . '/insurances-subscriptions-docs/'.$row->marriage_certificate_doc;
$marriage_certificate_doc_file = @fopen($marriage_certificate_doc,'r');
$id_document_front = NANO_SANTE_SERVICE_URL . '/insurances-subscriptions-docs/'.$row->id_document_front;
$id_document_front_file = @fopen($id_document_front ,'r');
$id_document_back = NANO_SANTE_SERVICE_URL . '/insurances-subscriptions-docs/'.$row->id_document_back;
$id_document_back_file = @fopen($id_document_front ,'r');
?>
<div class="row text-center" style="justify-content: center; display: flex;">
<div class="col-sm-6">
<label><?= $this->lang->line('marriage_certificate_doc') ?></label>
<div>
<img src="<?= $marriage_certificate_doc_file ? $marriage_certificate_doc : base_url('images/broken.png') ?>"
alt="user_image" width="100%"/>
</div>
</div>
</div>
<div class="row" style="margin-top: 10px">
<div class="col-sm-6 text-center">
<label><?= $this->lang->line('id_document_image_front') ?></label>
<img src="<?= $id_document_front_file ? $id_document_front : base_url('images/broken.png') ?>"
alt="document_front" style="width: 100%;"/>
</div>
<div class="col-sm-6 text-center">
<label><?= $this->lang->line('id_document_image_back') ?></label>
<img src="<?= $id_document_back_file ? $id_document_back : base_url('images/broken.png')?>"
alt="document_back" style="width: 100%;"/>
</div>
</div>
<?php } ?>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal"><?php echo $this->lang->line('Fermer'); ?></button>
</div>
</div>
</div>
</div>
<?php
}
}
?>
</tbody>
</table>
</div>
</div>
</section>
</div>
@ -373,7 +501,7 @@
const format = "<?=$this->session->userdata('site_lang')?>" === 'french' ? 'fr' : 'en';
moment.updateLocale(moment.locale(format), {invalidDate: ""}); // Blank text when is invalid date
$('#example1').DataTable(
$('#beneficiaries').DataTable(
{
order: [[1, 'asc']],
dom: 'Bfrtip',
@ -414,6 +542,52 @@
}
);
$('#deleted-beneficiaries').DataTable(
{
order: [[1, 'asc']],
dom: 'Bfrtip',
"columnDefs": [{
"targets": [6],
// "orderable": false,
render: $.fn.dataTable.render.moment( 'YYYY-MM-DD HH:mm:ss' , 'D MMMM YYYY HH:mm:ss', format)
}],
"buttons": [
'pageLength',
{
"extend": 'excelHtml5',
title: "<?= $this->lang->line('beneficiaries_deletion_history') . ' :: ' . $this->lang->line('subscription_detail') . ' - ' . $insured_id?>",
// exportOptions: {
// columns: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17]
// },
customizeData: function (data) {
for (var i = 0; i < data.body.length; i++) {
for (var j = 0; j < data.body[i].length; j++) {
// data.body[i][j] = '\u200C' + data.body[i][j];
if ([5].includes(j)) {
// Get the value and strip the non numeric characters
// var value = $(this).text();
value = data.body[i][j].replace(',', ".")
data.body[i][j] = Number(value.replace(/[^0-9\.-]+/g, ""));
}
}
}
},
},
{
extend: 'csvHtml5',
title: "<?= $this->lang->line('beneficiaries_deletion_history') . ' :: ' . $this->lang->line('subscription_detail') . ' - ' . $insured_id?>",
},
{
extend: 'pdfHtml5',
orientation: 'landscape',
pageSize: 'LEGAL',
title: "<?= $this->lang->line('beneficiaries_deletion_history') . ' :: ' . $this->lang->line('subscription_detail') . ' - ' . $insured_id?>",
},
// 'colvis'
]
}
);
$('#transactions').DataTable(
{
order: [[1, 'asc']],