diff --git a/application/controllers/Hyperviseur_dash.php b/application/controllers/Hyperviseur_dash.php index 21db2a14..46923cd9 100755 --- a/application/controllers/Hyperviseur_dash.php +++ b/application/controllers/Hyperviseur_dash.php @@ -406,7 +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->getInsurancePaymentTransactions($this->input->get('id')); + $data['transactions'] = $this->nano_health_model->getInsuranceInvoices($this->input->get('id'), 'PAID'); $data['deletion_of_beneficiaries'] = $this->nano_health_model->getBeneficiariesDeletionHistory($data['insurance']->id ?? null); $this->load->view('header_hyp', $data); diff --git a/application/controllers/NanoHealthController.php b/application/controllers/NanoHealthController.php index 01d13012..47e3759e 100644 --- a/application/controllers/NanoHealthController.php +++ b/application/controllers/NanoHealthController.php @@ -17,18 +17,17 @@ class NanoHealthController extends CI_Controller $configId = $_POST['config_id']; $grid = $_POST['grid'] ?? []; - try{ - $this->db->trans_begin(); - $this->db->delete('nh_years_prices_grid',['nh_network_config_id' => $configId]); - if(sizeof($grid) > 0){ - $this->db->insert_batch('nh_years_prices_grid',$grid); - } + $this->db->trans_begin(); + $this->db->delete('nh_years_prices_grid',['nh_network_config_id' => $configId]); + if(sizeof($grid) > 0){ + $this->db->insert_batch('nh_years_prices_grid',$grid); + } + if ($this->db->trans_status() === FALSE) { + $this->db->trans_rollback(); + echo json_encode("500"); + } else { $this->db->trans_commit(); echo json_encode("200"); - }catch (Throwable $exception){ - $this->db->trans_rollback(); - var_dump($exception->getMessage()); - echo json_encode("500"); } } } @@ -47,27 +46,26 @@ class NanoHealthController extends CI_Controller } } - try{ - $this->db->trans_begin(); - foreach ($grid as $row){ - $n = $row['payment_period'] == 'DAILY' ? 22 : 1 ; - if($row['payment_period'] == 'ONE_TIME'){ - $row['payment_duration_months'] = null; - } - $row['number_of_fractions'] = $n * ($row['payment_duration_months'] ?? 1); - if(!empty($row['id'])){ - $this->db->where('id',$row['id']); - $this->db->update('nh_months_prices_grid', $row); - }else{ - $this->db->insert('nh_months_prices_grid',$row); - } + $this->db->trans_begin(); + foreach ($grid as $row){ + $n = $row['payment_period'] == 'DAILY' ? 22 : 1 ; + if($row['payment_period'] == 'ONE_TIME'){ + $row['payment_duration_months'] = null; } + $row['number_of_fractions'] = $n * ($row['payment_duration_months'] ?? 1); + if(!empty($row['id'])){ + $this->db->where('id',$row['id']); + $this->db->update('nh_months_prices_grid', $row); + }else{ + $this->db->insert('nh_months_prices_grid',$row); + } + } + if ($this->db->trans_status() === FALSE) { + $this->db->trans_rollback(); + echo json_encode("500"); + } else { $this->db->trans_commit(); echo json_encode("200"); - }catch (Throwable $exception){ - $this->db->trans_rollback(); - var_dump($exception->getMessage()); - echo json_encode("500"); } } } diff --git a/application/controllers/pagination/Insurances.php b/application/controllers/pagination/Insurances.php index c7f60728..2148ecbd 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, $row->start_at, $row->end_at, $row->created_at, + $bonus_amount, $this->lang->line($row->payment_period) , $row->start_at, $row->end_at, $row->created_at, ' '.$this->lang->line('Voir plus...').''); } diff --git a/application/models/Nano_health_model.php b/application/models/Nano_health_model.php index 87b52d2e..2fff4b86 100644 --- a/application/models/Nano_health_model.php +++ b/application/models/Nano_health_model.php @@ -45,7 +45,9 @@ class Nano_health_model extends CI_Model } public function getInfosInsuranceSubscriptionById($insuranceSubscriptionId){ - return $this->db->get_where('nh_infos_insurances_subscriptions',['insurance_subscription_id'=> $insuranceSubscriptionId])->first_row(); + return $this->db->select('s.*, pg.payment_period , pg.number_of_fractions') + ->from('nh_infos_insurances_subscriptions s')->join('nh_months_prices_grid pg', 'pg.id = s.months_grid_id') + ->where('s.insurance_subscription_id',$insuranceSubscriptionId)->get()->row(); } public function getNhValidatingAgentSubscriptionHistory($agentId , $state){ @@ -62,8 +64,17 @@ 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->get_where('nh_insurances_payments',['insured_id'=> $insuredId]); +// } + + public function getInsuranceInvoices($insuredId , $state){ + return $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(); + } public function getSubscriptionBeneficiaries($subscriptionId){ diff --git a/application/views/nano_health/hyper/gestion_wallet.php b/application/views/nano_health/hyper/gestion_wallet.php index 26ba685a..b23456e5 100755 --- a/application/views/nano_health/hyper/gestion_wallet.php +++ b/application/views/nano_health/hyper/gestion_wallet.php @@ -1381,7 +1381,8 @@ $careRequests = []; } select.each(function () { - $(this).parent("td").html($(this).find('option:selected').text()).attr("value",$(this).val()); + $(this).parent("td").html($(this).find('option:selected').text()) + .attr("value",$(this).val()).attr("name",$(this).attr('name')); }); }); // Edit row on edit button click diff --git a/application/views/nano_health/hyper/infos_insurance.php b/application/views/nano_health/hyper/infos_insurance.php index 58b699af..4f9d5e65 100755 --- a/application/views/nano_health/hyper/infos_insurance.php +++ b/application/views/nano_health/hyper/infos_insurance.php @@ -158,6 +158,32 @@ +
= $this->lang->line('payment_period') ?>
+= $this->lang->line('number_of_fractions') ?>
+= $this->lang->line('payment_period') ?>
+= $this->lang->line('number_of_fractions') ?>
+