diff --git a/application/controllers/Hyperviseur_dash.php b/application/controllers/Hyperviseur_dash.php index 97ae1f77..34e9915e 100755 --- a/application/controllers/Hyperviseur_dash.php +++ b/application/controllers/Hyperviseur_dash.php @@ -407,6 +407,9 @@ 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['payments'] = $this->nano_health_model->getInsurancePaymentTransactions($data['insurance']->id ?? null); + // Le montant payé de toutes les factures de l'assurance + $data['insurance_invoices_total_paid_amount'] = $this->nano_health_model->getInsuranceInvoiceTotalPaidAmount($data['insurance']->id ?? null) ?? 0; + $data['insurance_invoices_total_amount'] = $this->nano_health_model->getInsuranceInvoiceTotalAmount($data['insurance']->id ?? null) ?? 0; $data['invoices'] = $this->nano_health_model->getInsuranceInvoices($this->input->get('id')); $data['deletion_of_beneficiaries'] = $this->nano_health_model->getBeneficiariesDeletionHistory($data['insurance']->id ?? null); diff --git a/application/language/english/message_lang.php b/application/language/english/message_lang.php index 15e7d2c0..aac8f746 100755 --- a/application/language/english/message_lang.php +++ b/application/language/english/message_lang.php @@ -940,5 +940,6 @@ $lang['EXPIRED'] = 'EXPIRED'; $lang['SUSPENDED'] = "SUSPENDED"; $lang['billed_quantity'] = "Billed quantity"; $lang['ceiling'] = "Ceiling"; -$lang['note_config_wallet_agent_remove_cash'] = "The hypervisor's commission is the amount remaining in the client's commission once the agent's and supervisor's commissions are removed" +$lang['note_config_wallet_agent_remove_cash'] = "The hypervisor's commission is the amount remaining in the client's commission once the agent's and supervisor's commissions are removed"; +$lang['UNPAID'] = "Unpaid"; ?> diff --git a/application/language/french/message_lang.php b/application/language/french/message_lang.php index 705b5c2f..6750cde0 100755 --- a/application/language/french/message_lang.php +++ b/application/language/french/message_lang.php @@ -949,5 +949,6 @@ $lang['SUSPENDED'] = "SUSPENDU"; $lang['EXPIRED'] = 'EXPIRÉE'; $lang['billed_quantity'] = "Quantité facturée"; $lang['ceiling'] = "Plafond"; -$lang['note_config_wallet_agent_remove_cash'] = "La commission de l'hyperviseur est le montant restant de la commission client une fois qu'on a retiré les commissions de l'agent et du superviseur" +$lang['note_config_wallet_agent_remove_cash'] = "La commission de l'hyperviseur est le montant restant de la commission client une fois qu'on a retiré les commissions de l'agent et du superviseur"; +$lang['UNPAID'] = "Non Payée"; ?> diff --git a/application/models/Nano_health_model.php b/application/models/Nano_health_model.php index f3210cec..4b0de147 100644 --- a/application/models/Nano_health_model.php +++ b/application/models/Nano_health_model.php @@ -71,16 +71,29 @@ class Nano_health_model extends CI_Model } public function getInsuranceInvoices($insuredId , $state = null){ - $query = $this->db->select('i.* , is.insurance_subscription_id') + $query = $this->db->select('i.* , is.insurance_subscription_id, SUM(p.amount) as paid_amount') ->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') + ->join('nh_insurances_payments p', 'i.id = p.invoice_id','left') ->where('in.insured_id',$insuredId); if(!empty($state)){ $query =$query->where('i.state',$state); } - return $query->order_by('i.created_at','desc')->get(); + return $query->group_by('i.id')->order_by('i.created_at','desc')->get(); + } + public function getInsuranceInvoiceTotalPaidAmount($insuredId){ + return $this->db->select('SUM(p.amount) as total_paid_amount') + ->from('nh_insurances_invoices i')->join('nh_insurances in', 'in.id = i.insurance_id') + ->join('nh_insurances_payments p', 'i.id = p.invoice_id') + ->where('i.insurance_id',$insuredId)->group_by('i.id')->get()->row_array()['total_paid_amount']; + } + + public function getInsuranceInvoiceTotalAmount($insuredId){ + return $this->db->select('SUM(i.amount) as total_amount') + ->from('nh_insurances_invoices i')->join('nh_insurances in', 'in.id = i.insurance_id') + ->where('i.insurance_id',$insuredId)->group_by('i.id')->get()->row_array()['total_amount']; } public function getSubscriptionBeneficiaries($subscriptionId){ diff --git a/application/views/nano_health/hyper/infos_insurance.php b/application/views/nano_health/hyper/infos_insurance.php index 17c8bbb7..d809f60d 100755 --- a/application/views/nano_health/hyper/infos_insurance.php +++ b/application/views/nano_health/hyper/infos_insurance.php @@ -157,9 +157,8 @@ -
= $this->lang->line('remaining_amount') ?>
+