Add payments and invoices to infos of insurance
This commit is contained in:
parent
ea2ce38a13
commit
f195609da4
|
@ -406,8 +406,8 @@ class Hyperviseur_dash extends CI_Controller
|
|||
$data['insurance'] = $this->nano_health_model->getInfosInsuredById($this->input->get('id'));
|
||||
$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['transactions'] = $this->nano_health_model->getInsuranceInvoices($this->input->get('id'), 'PAID');
|
||||
$data['payments'] = $this->nano_health_model->getInsurancePaymentTransactions($data['insurance']->id ?? null);
|
||||
$data['invoices'] = $this->nano_health_model->getInsuranceInvoices($this->input->get('id'));
|
||||
$data['deletion_of_beneficiaries'] = $this->nano_health_model->getBeneficiariesDeletionHistory($data['insurance']->id ?? null);
|
||||
|
||||
$this->load->view('header_hyp', $data);
|
||||
|
|
|
@ -64,16 +64,22 @@ class Nano_health_model extends CI_Model
|
|||
return $this->db->get_where('nh_infos_insurances',['insured_id'=> $insuredId])->first_row();
|
||||
}
|
||||
|
||||
// public function getInsurancePaymentTransactions($insuredId){
|
||||
// return $this->db->get_where('nh_insurances_payments',['insured_id'=> $insuredId]);
|
||||
// }
|
||||
public function getInsurancePaymentTransactions($insuredId){
|
||||
return $this->db->select('p.* , in.invoice_id')
|
||||
->from('nh_insurances_payments p')->join('nh_insurances_invoices in', 'in.id = p.invoice_id')
|
||||
->where('in.insurance_id',$insuredId)->order_by('p.created_at','desc')->get();
|
||||
}
|
||||
|
||||
public function getInsuranceInvoices($insuredId , $state){
|
||||
return $this->db->select('i.* , is.insurance_subscription_id')
|
||||
public function getInsuranceInvoices($insuredId , $state = null){
|
||||
$query = $this->db->select('i.* , is.insurance_subscription_id')
|
||||
->from('nh_insurances_invoices i')->join('nh_insurances in', 'in.id = i.insurance_id')
|
||||
->join('nh_insurances_subscriptions is', 'is.id = i.subscription_id','left')
|
||||
->where('i.state',$state)
|
||||
->where('in.insured_id',$insuredId)->order_by('i.created_at','desc')->get();
|
||||
->where('in.insured_id',$insuredId);
|
||||
if(!empty($state)){
|
||||
$query =$query->where('i.state',$state);
|
||||
}
|
||||
|
||||
return $query->order_by('i.created_at','desc')->get();
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -323,23 +323,24 @@
|
|||
|
||||
<div class="box box-default">
|
||||
<div class="box-header with-border">
|
||||
<h3 class="box-title"><?= $this->lang->line('payment_transaction_history') ?></h3>
|
||||
<h3 class="box-title"><?= $this->lang->line('invoices_history') ?></h3>
|
||||
</div>
|
||||
<div class="box-body" style="overflow-x:auto;">
|
||||
<table id="transactions" class="table table-bordered table-hover">
|
||||
<table id="invoices" class="table table-bordered table-hover">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>#</th>
|
||||
<th>ID</th>
|
||||
<th><?= $this->lang->line('souscription_id'); ?></th>
|
||||
<th><?= $this->lang->line('Montant'); ?></th>
|
||||
<th><?= $this->lang->line('reason'); ?></th>
|
||||
<th><?= $this->lang->line('state'); ?></th>
|
||||
<th>Date</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php
|
||||
if (isset($transactions)) {
|
||||
foreach ($transactions->result() as $i => $row) {
|
||||
if (isset($invoices)) {
|
||||
foreach ($invoices->result() as $i => $row) {
|
||||
$amount = Money::of(round($row->amount, 2), $insurance->currency_code, $this->context)->formatTo('fr_FR');
|
||||
|
||||
echo "<tr>
|
||||
|
@ -347,6 +348,43 @@
|
|||
<td>" . $row->insurance_subscription_id . "</td>
|
||||
<td>" . $amount . "</td>
|
||||
<td>" . $this->lang->line($row->reason). "</td>
|
||||
<td>" . $this->lang->line($row->state). "</td>
|
||||
<td>" . $row->created_at. "</td>";
|
||||
?>
|
||||
</tr>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
?>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="box box-default">
|
||||
<div class="box-header with-border">
|
||||
<h3 class="box-title"><?= $this->lang->line('payment_transaction_history') ?></h3>
|
||||
</div>
|
||||
<div class="box-body" style="overflow-x:auto;">
|
||||
<table id="payments" class="table table-bordered table-hover">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>ID</th>
|
||||
<th><?= $this->lang->line('invoice_id'); ?></th>
|
||||
<th><?= $this->lang->line('Montant'); ?></th>
|
||||
<th>Date</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php
|
||||
if (isset($payments)) {
|
||||
foreach ($payments->result() as $i => $row) {
|
||||
$amount = Money::of(round($row->amount, 2), $insurance->currency_code, $this->context)->formatTo('fr_FR');
|
||||
|
||||
echo "<tr>
|
||||
<td>" . $row->payment_id . "</td>
|
||||
<td>" . $row->invoice_id . "</td>
|
||||
<td>" . $amount . "</td>
|
||||
<td>" . $row->created_at. "</td>";
|
||||
?>
|
||||
</tr>
|
||||
|
@ -625,11 +663,22 @@
|
|||
}
|
||||
);
|
||||
|
||||
$('#transactions').DataTable(
|
||||
$('#invoices').DataTable(
|
||||
{
|
||||
order: [[1, 'asc']],
|
||||
"columnDefs": [{
|
||||
"targets": [4],
|
||||
"targets": [5],
|
||||
// "orderable": false,
|
||||
render: $.fn.dataTable.render.moment('YYYY-MM-DD HH:mm:ss', 'D MMMM YYYY HH:mm:ss', format)
|
||||
}],
|
||||
}
|
||||
);
|
||||
|
||||
$('#payments').DataTable(
|
||||
{
|
||||
order: [[1, 'asc']],
|
||||
"columnDefs": [{
|
||||
"targets": [3],
|
||||
// "orderable": false,
|
||||
render: $.fn.dataTable.render.moment('YYYY-MM-DD HH:mm:ss', 'D MMMM YYYY HH:mm:ss', format)
|
||||
}],
|
||||
|
|
Loading…
Reference in New Issue