From 112d1080f66ca572d3fbb730064b79c356cb4ab0 Mon Sep 17 00:00:00 2001 From: Djery-Tom Date: Fri, 12 Nov 2021 06:09:33 +0100 Subject: [PATCH] Fix insurance subscription flow --- application/controllers/Hyperviseur_dash.php | 4 +-- .../pagination/InsuranceSubscription.php | 3 +- .../controllers/pagination/Insurances.php | 2 +- application/language/english/message_lang.php | 2 +- application/language/french/message_lang.php | 2 +- application/models/Nano_health_model.php | 12 ++++++++ .../InsuranceSubscription_model.php | 6 ++-- .../models/pagination/Insurances_model.php | 4 +-- .../nano_health/hyper/infos_insurance.php | 28 ------------------- .../nano_health/hyper/insurances_insured.php | 7 ++--- .../hyper/insurances_subscriptions.php | 3 +- 11 files changed, 28 insertions(+), 45 deletions(-) diff --git a/application/controllers/Hyperviseur_dash.php b/application/controllers/Hyperviseur_dash.php index e61d1614..577be581 100755 --- a/application/controllers/Hyperviseur_dash.php +++ b/application/controllers/Hyperviseur_dash.php @@ -381,7 +381,7 @@ class Hyperviseur_dash extends CI_Controller $data['active'] = "wallet_insured"; $data['insured_id'] = $this->input->get('id'); $data['insurance'] = $this->nano_health_model->getInfosInsuredById($this->input->get('id')); - $data['beneficiaries'] = $this->db->get_where('nh_insurances_having_rights',['insurance_subscription_id' => $data['insurance']->insurance_subscription_id ?? null]); + $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')); @@ -390,7 +390,7 @@ class Hyperviseur_dash extends CI_Controller }else{ $data['insurance_subscription_id'] = $this->input->get('id'); $data['subscription'] = $this->nano_health_model->getInfosInsuranceSubscriptionById($this->input->get('id')); - $data['beneficiaries'] = $this->db->get_where('nh_insurances_having_rights',['insurance_subscription_id' => $data['insurance_subscription_id']]); + $data['beneficiaries'] = $this->nano_health_model->getSubscriptionBeneficiaries($data['subscription']->id ?? null); $data['user'] = $this->db->get_where('user_infos',['user_id' => $data['subscription']->user_id ?? null])->first_row(); $this->load->view('header_hyp', $data); $this->load->view('nano_health/hyper/infos_insurance_subscription'); diff --git a/application/controllers/pagination/InsuranceSubscription.php b/application/controllers/pagination/InsuranceSubscription.php index 13e97fd4..e46bba72 100755 --- a/application/controllers/pagination/InsuranceSubscription.php +++ b/application/controllers/pagination/InsuranceSubscription.php @@ -57,11 +57,10 @@ class InsuranceSubscription extends CI_Controller $current_url = $_POST['currentURL']; foreach ($witData as $row) { $i++; - $bonus_amount = Money::of(round($row->total_bonus_amount, 2), $row->currency_code, $this->context)->formatTo('fr_FR'); $data[] = array($i,$row->insurance_subscription_id, $row->lastname, $row->phone, $row->number_of_months, $row->number_of_beneficiaries, - $bonus_amount, mb_strtoupper($this->lang->line($row->state) ,'UTF-8'), $row->created_at, + $bonus_amount, mb_strtoupper($this->lang->line($row->state) ,'UTF-8'), mb_strtoupper($this->lang->line($row->insurance_action), 'UTF-8') , $row->created_at, ' '.$this->lang->line('Voir plus...').''); } diff --git a/application/controllers/pagination/Insurances.php b/application/controllers/pagination/Insurances.php index c8b45328..39fe67ca 100755 --- a/application/controllers/pagination/Insurances.php +++ b/application/controllers/pagination/Insurances.php @@ -61,7 +61,7 @@ class Insurances extends CI_Controller $bonus_amount = Money::of(round($row->total_bonus_amount, 2), $row->currency_code, $this->context)->formatTo('fr_FR'); $data[] = array($row->insured_id , $row->lastname, $row->phone, $row->number_of_months, $row->number_of_beneficiaries, - $bonus_amount, mb_strtoupper($this->lang->line($row->state) ,'UTF-8'), $row->start_at, $row->end_at, $row->created_at, + $bonus_amount, $row->start_at, $row->end_at, $row->created_at, ' '.$this->lang->line('Voir plus...').''); } diff --git a/application/language/english/message_lang.php b/application/language/english/message_lang.php index c3cfb7c4..353ca42e 100755 --- a/application/language/english/message_lang.php +++ b/application/language/english/message_lang.php @@ -762,5 +762,5 @@ $lang['payment_transaction_history'] = "Payment transaction history"; $lang['reason'] = "Reason"; $lang['ADDITION_OF_BENEFICIARY'] = "Addition of beneficiary"; $lang['DELETION_OF_BENEFICIARY'] = "Deletion of beneficiary"; -$lang['ACTIVATION'] = "Activation"; +$lang['ACTIVATION'] = "Insurance activation"; ?> diff --git a/application/language/french/message_lang.php b/application/language/french/message_lang.php index aeeaea6a..349d23d9 100755 --- a/application/language/french/message_lang.php +++ b/application/language/french/message_lang.php @@ -773,5 +773,5 @@ $lang['payment_transaction_history'] = "Historique des transactions de paiements $lang['reason'] = "Motif"; $lang['ADDITION_OF_BENEFICIARY'] = "Ajout d'ayant droit"; $lang['DELETION_OF_BENEFICIARY'] = "Suppression d'ayant droit"; -$lang['ACTIVATION'] = "Activation"; +$lang['ACTIVATION'] = "Activation de l'assurance"; ?> diff --git a/application/models/Nano_health_model.php b/application/models/Nano_health_model.php index e3c0dec7..8defd436 100644 --- a/application/models/Nano_health_model.php +++ b/application/models/Nano_health_model.php @@ -64,4 +64,16 @@ class Nano_health_model extends CI_Model public function getInsurancePaymentTransactions($insuredId){ return $this->db->get_where('nh_insurances_payments',['insured_id'=> $insuredId]); } + + public function getSubscriptionBeneficiaries($subscriptionId){ + return $this->db->select('b.*') + ->from('nh_having_rights b')->join('nh_insurances_having_rights i', 'b.id = i.having_right_id') + ->where('i.insurance_subscription_id',$subscriptionId)->order_by('i.created_at','asc')->get(); + } + + public function getInsuranceBeneficiaries($insuranceId){ + return $this->db->select('b.*') + ->from('nh_having_rights b')->join('nh_insurances_having_rights i', 'b.id = i.having_right_id') + ->where('i.insurance_id',$insuranceId)->order_by('i.created_at','asc')->get(); + } } diff --git a/application/models/pagination/InsuranceSubscription_model.php b/application/models/pagination/InsuranceSubscription_model.php index 0c4dd087..23ce9e80 100644 --- a/application/models/pagination/InsuranceSubscription_model.php +++ b/application/models/pagination/InsuranceSubscription_model.php @@ -8,9 +8,11 @@ class InsuranceSubscription_model extends CI_Model // Set table name $this->table = 'nh_infos_insurances_subscriptions'; // Set orderable column fields - $this->column_order = array(null, 'insurance_subscription_id', 'lastname', 'phone', 'number_of_months', 'number_of_beneficiaries', 'bonus_amount', 'state','created_at', null); + $this->column_order = array(null, 'insurance_subscription_id', 'lastname', 'phone', 'number_of_months', 'number_of_beneficiaries', 'bonus_amount', 'state', + 'insurance_action','created_at', null); // Set searchable column fields - $this->column_search = array('insurance_subscription_id', 'lastname', 'phone', 'number_of_months', 'number_of_beneficiaries', 'bonus_amount', 'state','created_at'); + $this->column_search = array('insurance_subscription_id', 'lastname', 'phone', 'number_of_months', 'number_of_beneficiaries', 'bonus_amount', 'state', + 'insurance_action','created_at'); // Set default order $this->order = array('created_at' => 'desc'); } diff --git a/application/models/pagination/Insurances_model.php b/application/models/pagination/Insurances_model.php index 4785aada..9069c460 100644 --- a/application/models/pagination/Insurances_model.php +++ b/application/models/pagination/Insurances_model.php @@ -8,10 +8,10 @@ class Insurances_model extends CI_Model // Set table name $this->table = 'nh_infos_insurances'; // Set orderable column fields - $this->column_order = array('insured_id', 'lastname', 'phone', 'number_of_months', 'number_of_beneficiaries', 'bonus_amount', 'state', 'start_at', + $this->column_order = array('insured_id', 'lastname', 'phone', 'number_of_months', 'number_of_beneficiaries', 'bonus_amount', 'start_at', 'end_at','created_at', null); // Set searchable column fields - $this->column_search = array('insured_id', 'lastname', 'phone', 'number_of_months', 'number_of_beneficiaries', 'bonus_amount', 'state', 'start_at', + $this->column_search = array('insured_id', 'lastname', 'phone', 'number_of_months', 'number_of_beneficiaries', 'bonus_amount', 'start_at', 'end_at', 'created_at'); // Set default order $this->order = array('created_at' => 'desc'); diff --git a/application/views/nano_health/hyper/infos_insurance.php b/application/views/nano_health/hyper/infos_insurance.php index 9c2c2684..89435836 100755 --- a/application/views/nano_health/hyper/infos_insurance.php +++ b/application/views/nano_health/hyper/infos_insurance.php @@ -156,34 +156,6 @@ - -
-
-
-
-

lang->line($insurance->state)?>

-

lang->line('Statut') ?>

-
-
- -
-
-
- - state == 'ADDITION_OF_BENEFICIARY') {?> -
-
-
-

remaining_amount, 2), $insurance->currency_code, $this->context)->formatTo('fr_FR') ?>

-

lang->line('remaining_amount') ?>

-
-
- -
-
-
- -
diff --git a/application/views/nano_health/hyper/insurances_insured.php b/application/views/nano_health/hyper/insurances_insured.php index b88c22e5..90179c44 100755 --- a/application/views/nano_health/hyper/insurances_insured.php +++ b/application/views/nano_health/hyper/insurances_insured.php @@ -44,9 +44,7 @@

lang->line('export_insured_list') ?>

@@ -60,7 +58,6 @@ lang->line('number_of_months') ?> lang->line('number_of_beneficiaries') ?> lang->line('bonus_amount') ?> - lang->line('state') ?> lang->line('start_at') ?> lang->line('end_at') ?> lang->line('subscription_date') ?> @@ -137,7 +134,7 @@ }, "aaSorting": [[8, "desc"]], "columnDefs": [{ - "targets": [7,8,9], + "targets": [6,7,8], // "orderable": false, render: $.fn.dataTable.render.moment('YYYY-MM-DD HH:mm:ss', 'D MMMM YYYY HH:mm:ss', format) }], diff --git a/application/views/nano_health/hyper/insurances_subscriptions.php b/application/views/nano_health/hyper/insurances_subscriptions.php index c05533f2..170b01ba 100755 --- a/application/views/nano_health/hyper/insurances_subscriptions.php +++ b/application/views/nano_health/hyper/insurances_subscriptions.php @@ -58,6 +58,7 @@ lang->line('number_of_beneficiaries') ?> lang->line('bonus_amount') ?> lang->line('state') ?> + lang->line('reason') ?> Date Action @@ -132,7 +133,7 @@ }, "aaSorting": [[8, "desc"]], "columnDefs": [{ - "targets": [8], + "targets": [9], // "orderable": false, render: $.fn.dataTable.render.moment('YYYY-MM-DD HH:mm:ss', 'D MMMM YYYY HH:mm:ss', format) }],