From 2bc06cf940a09fea32a8a57568aca33009b4b47e Mon Sep 17 00:00:00 2001 From: Djery-Tom Date: Mon, 20 Dec 2021 18:47:02 +0100 Subject: [PATCH] Add Agent login --- application/controllers/Agent.php | 190 ++++++++++++++++ application/controllers/Users.php | 4 + application/language/english/message_lang.php | 1 + application/language/french/message_lang.php | 1 + application/models/User_model.php | 5 +- .../pagination/HealthCareSheets_model.php | 16 +- application/views/admin_forgot_password.php | 2 +- application/views/admin_update_password.php | 2 +- application/views/generer_super.php | 2 +- application/views/gestion_admin.php | 4 +- application/views/gestion_networks.php | 2 +- ...ion_wallet_ilink_config_paying_network.php | 2 +- application/views/header_agent.php | 120 ++++++++++ .../agent/insurances_health_care_sheets.php | 206 ++++++++++++++++++ .../hyper/infos_health_care_sheet.php | 99 +++++---- .../nano_health/hyper/infos_insurance.php | 8 +- .../hyper/infos_insurance_subscription.php | 6 +- .../hyper/insurances_health_care_sheets.php | 6 +- 18 files changed, 612 insertions(+), 64 deletions(-) create mode 100755 application/controllers/Agent.php create mode 100755 application/views/header_agent.php create mode 100755 application/views/nano_health/agent/insurances_health_care_sheets.php diff --git a/application/controllers/Agent.php b/application/controllers/Agent.php new file mode 100755 index 00000000..04548ff9 --- /dev/null +++ b/application/controllers/Agent.php @@ -0,0 +1,190 @@ +load->model('wallet_model'); + $this->load->model('nano_credit_model'); + $this->load->model('Users_simple'); + $this->load->model('User_model'); + } + + public function index() + { + if ($this->isLogged()) { + + $data['active'] = "health_care_sheets"; + + $data['member_code'] = $this->session->userdata('member_code'); + $data['category'] = $this->session->userdata('category'); + $data['network'] = $this->session->userdata('network'); + $data['code_parrain'] = $this->session->userdata('parrain'); + $data['network_agent_id'] = $this->session->userdata('network_agent_id'); + + $startDate = $this->input->get('d'); + $endDate = $this->input->get('f'); + + $format = $this->session->userdata('site_lang') === 'french' ? 'd-m-Y' : 'Y-m-d'; + $data['startDate'] = $startDate ? date($format, strtotime($startDate)) : null; + $data['endDate'] = $endDate ? date($format, strtotime($endDate)) : null; + $endDate = Date('Y-m-d', strtotime($endDate . "+1 day")); + + $data['hasWallet'] = $this->wallet_model->getConfigWallet($this->session->userdata('network_id')); + $this->load->view('header_agent', $data); + $this->load->view('nano_health/hyper/insurances_health_care_sheets'); + $this->load->view('footer'); + } + } + + + // Wallet + public function wallet() + { + if (!$this->session->userdata('email')) { + $this->session->set_flashdata('error', 'log in first'); + + $data['alert'] = "ok"; + $data['message'] = "Login first!"; + $this->load->view('login', $data); + } else { + $id_network = $this->session->userdata('network_id'); + $data["commission"] = ""; + $data["principal"] = ""; + $data["transactions"] = ""; + $agent_id = $this->session->userdata('agent_id'); + $data['hasWallet'] = $this->wallet_model->getConfigWallet($this->session->userdata('network_id')); + + if ($this->input->get('history')) { + $this->historique($id_network, $this->input->get('d'), $this->input->get('f'), $this->session->userdata('member_code'), + $this->input->get('history')); + } else { + $context = new AutoContext(); + //Create wallet if it not exist + $res = $this->wallet_model->getWallet($agent_id); + if ($res == false) { + if ($data['hasWallet']) { + $this->user_model->addWallet($agent_id); + } + } + + $res = $this->wallet_model->getWallet($agent_id); + if ($res != null) { + $row = $res->first_row(); + $data["commission"] = Money::of(round($row->balance_com, 2), $this->session->userdata('currency_code'), $context)->formatTo('fr_FR'); + $data["principal"] = Money::of(round($row->balance_princ, 2), $this->session->userdata('currency_code'), $context)->formatTo('fr_FR'); + $agents_g = $this->user_model->getUsersGeolocatedForSup($this->session->userdata('member_code')); + $data['agents_g'] = $agents_g; + + //Fetch all transactions of any geolocated agent of the network + $data["transactions"] = array(); + if ($agents_g) { + foreach ($agents_g->result() as $row) { + $wallet = $this->wallet_model->getWallet($row->agent_id); + if ($wallet) { + if ($data['hasWallet']->first_row()->type == 'visa') { + $transactions = $this->user_model->getAgentTransactions($wallet->first_row()->wallet_id); + } else if ($data['hasWallet']->first_row()->type == 'ilink') { + $transactions = $this->user_model->getAgentiLinkTransactions($wallet->first_row()->wallet_id); + } + if ($transactions) { + foreach ($transactions->result() as $trans) { + $trans->agent_id = $row->agent_id; // Add agent id to transaction + array_push($data['transactions'], $trans); + } + } + } + } + } + } else { + $data["commission"] = "N/A"; + $data["principal"] = "N/A"; + $data["totalCommissionBanque"] = "N/A"; + $data["transactions"] = false; + } + + + $data['currency_code'] = $this->session->userdata('currency_code'); + $data['alert'] = ""; + $data['active'] = "wallet"; + $data['code_parrain'] = $this->session->userdata('code_parrain'); + $data['category'] = $this->session->userdata('category'); + $data['network'] = $this->session->userdata('network'); + $data['network_id'] = $id_network; + $data['villes'] = $this->user_model->getVilleByUserGeo($data['network'], $this->session->userdata('current_pays')); + $data['pays'] = $this->user_model->getAllGameCountries(); + $data['networks'] = $this->user_model->getActiveNetwork(); + $data['agentWalletInfos'] = $this->user_model->getInfosWalletAgentForHyper($id_network); +// $data['geolocated_user'] = $this->user_model->getSuperNameAndCodeForSup($this->session->userdata('member_code')); + $this->load->view('header_sup', $data); + if ($data['hasWallet']->first_row()->type == 'visa') + $this->load->view('gestion_wallet_sup'); + elseif ($data['hasWallet']->first_row()->type == 'ilink') + $this->load->view('gestion_wallet_sup_ilink'); + $this->load->view('footer'); + } + + } + } + + private function historique($network_id, $startDate, $endDate, $codeMembre, $type) + { + $data['configWallet'] = $this->wallet_model->getConfigWallet($network_id); + $format = $this->session->userdata('site_lang') === 'french' ? 'd-m-Y' : 'Y-m-d'; + $data['startDate'] = $startDate ? date($format, strtotime($startDate)) : null; + $data['endDate'] = $endDate ? date($format, strtotime($endDate)) : null; + $endDate = Date('Y-m-d', strtotime($endDate . "+1 day")); + if ($type == 'transaction') + $data['transactions'] = $this->user_model->getTransactionsSup($startDate, $endDate, $codeMembre); + else if ($type == 'transaction_ilink') + $data['transactions'] = $this->wallet_model->getIlinkTransactionsSup($startDate, $endDate, $codeMembre); + else if ($type == 'commission_transfer') + $data['transactions'] = $this->wallet_model->getCommissionTransfers($startDate, $endDate, $this->session->userdata('member_code')); + else if ($type == 'balance_statement') + $data['wallets'] = $this->user_model->getInfosWalletAgentForSuper($codeMembre); + + $data['active'] = "wallet"; + $data['alert'] = ""; + $data['network'] = $this->session->userdata('network'); + $data['villes'] = $this->user_model->getVilleByUserGeo($data['network'], $this->session->userdata('current_pays')); + $data['networks'] = $this->user_model->getActiveNetwork(); +// $data['superviseurs'] = $this->user_model->getSuperNameAndCodeForHyp($this->session->userdata('member_code')); + $data['hasWallet'] = $this->wallet_model->getConfigWallet($this->session->userdata('network_id')); + $data['country'] = $this->session->userdata('current_pays'); + $data['category'] = $this->session->userdata('category'); + $data['geolocated_user'] = $this->user_model->getSuperNameAndCodeForSup($this->session->userdata('member_code')); + $data['id_network'] = $this->session->userdata('network_id'); + + + $this->load->view('header_sup', $data); + if ($type == 'transaction') + $this->load->view('historique_transactions'); + else if ($type == 'transaction_ilink') + $this->load->view('historique_transactions_ilink'); + else if ($type == 'commission_transfer') + $this->load->view('historique_transferts_commission'); + else if ($type == 'balance_statement') + $this->load->view('config_wallet_ilink_hyp/etat_soldes'); + $this->load->view('footer'); + } + + private function isLogged() + { + if (!$this->session->userdata('email')) { + $this->session->set_flashdata('error', 'log in first'); + + $data['alert'] = "ok"; + $data['message'] = "Login first!"; + $this->load->view('login', $data); + return false; + } + return true; + } +} diff --git a/application/controllers/Users.php b/application/controllers/Users.php index 1e4a775d..737038ec 100755 --- a/application/controllers/Users.php +++ b/application/controllers/Users.php @@ -149,6 +149,10 @@ } else if ($data->category == $super) { $this->session->set_userdata('code_parrain', $data->code_parrain); redirect('Superviseur_dash'); + }else if($data->category == 'geolocated') { + $this->session->set_userdata('code_parrain', $data->code_parrain); + $this->session->set_userdata('network_agent_id', $data->network_agent_id); + redirect('Agent'); } } diff --git a/application/language/english/message_lang.php b/application/language/english/message_lang.php index 2aa00df6..d404ebfe 100755 --- a/application/language/english/message_lang.php +++ b/application/language/english/message_lang.php @@ -820,4 +820,5 @@ $lang['resubmit'] = "Resubmit"; $lang['subscription_resubmitted'] = "The subscription has been resubmitted"; $lang['insurance_part'] = "Insurance share"; $lang['insurance_part'] = "Insurance share"; +$lang['consultation_id'] = "Consulation ID"; ?> diff --git a/application/language/french/message_lang.php b/application/language/french/message_lang.php index bc451169..acffc4c0 100755 --- a/application/language/french/message_lang.php +++ b/application/language/french/message_lang.php @@ -831,4 +831,5 @@ $lang['resubmit'] = "Resoumettre"; $lang['subscription_resubmitted'] = "La souscription a été re-soumise"; $lang['insurance_part'] = "Part de l'assurance"; $lang['insurance_part'] = "Part de l'assurance"; +$lang['consultation_id'] = "ID de la consultation"; ?> diff --git a/application/models/User_model.php b/application/models/User_model.php index 081edb18..22a566c5 100755 --- a/application/models/User_model.php +++ b/application/models/User_model.php @@ -30,11 +30,14 @@ class User_model extends CI_Model $this->db->where("email",$id); $query=$this->db->get(); break; - case 2: //hyperviseur ou superviseur + case 2: //hyperviseur ou superviseur ou agent $query = $this->db->query("SELECT * FROM hyper_infos WHERE code_membre='".$id."'"); if($query->num_rows()==0){ $query = $this->db->query("SELECT * FROM super_infos WHERE category='super' AND code_membre='".$id."'"); } + if($query->num_rows()==0){ + $query = $this->db->query("SELECT * FROM agent_plus WHERE category='geolocated' AND code_membre='".$id."'"); + } break; } diff --git a/application/models/pagination/HealthCareSheets_model.php b/application/models/pagination/HealthCareSheets_model.php index a2310376..604cc689 100644 --- a/application/models/pagination/HealthCareSheets_model.php +++ b/application/models/pagination/HealthCareSheets_model.php @@ -37,7 +37,13 @@ class HealthCareSheets_model extends CI_Model public function countAll($postData) { $this->db->from($this->table); - $this->db->where('network_id', $postData['id_network']); + if(!empty($postData['id_network'])){ + $this->db->where('network_id', $postData['id_network']); + } + + if(!empty($postData['network_agent_id'])){ + $this->db->where('network_agent_id', $postData['network_agent_id']); + } return $this->db->count_all_results(); } @@ -60,7 +66,13 @@ class HealthCareSheets_model extends CI_Model { $this->db->from($this->table); - $this->db->where('network_id', $postData['id_network']); + if(!empty($postData['id_network'])){ + $this->db->where('network_id', $postData['id_network']); + } + + if(!empty($postData['network_agent_id'])){ + $this->db->where('network_agent_id', $postData['network_agent_id']); + } if (strlen($postData['startDate']) > 0 && strlen($postData['endDate']) > 0) { $this->db->where('created_at >=', date('Y-m-d', strtotime($postData['startDate']))); $this->db->where('created_at <', date('Y-m-d', strtotime($postData['endDate']. "+1 day"))); diff --git a/application/views/admin_forgot_password.php b/application/views/admin_forgot_password.php index ab3057f3..5460e6a9 100755 --- a/application/views/admin_forgot_password.php +++ b/application/views/admin_forgot_password.php @@ -46,7 +46,7 @@ -
+
diff --git a/application/views/admin_update_password.php b/application/views/admin_update_password.php index a93a7bc8..6ce5bbc9 100755 --- a/application/views/admin_update_password.php +++ b/application/views/admin_update_password.php @@ -49,7 +49,7 @@
-
+
diff --git a/application/views/generer_super.php b/application/views/generer_super.php index 832e99a0..719a1a74 100755 --- a/application/views/generer_super.php +++ b/application/views/generer_super.php @@ -53,7 +53,7 @@
-
+
diff --git a/application/views/gestion_admin.php b/application/views/gestion_admin.php index 9c94b8cd..07a2acaf 100755 --- a/application/views/gestion_admin.php +++ b/application/views/gestion_admin.php @@ -141,7 +141,7 @@
-

lang->line('Créer un compte administrateur'); ?>

+

lang->line('Créer un compte administrateur'); ?>

@@ -183,7 +183,7 @@
-
+
diff --git a/application/views/gestion_networks.php b/application/views/gestion_networks.php index d1f79d3e..f24dd79e 100755 --- a/application/views/gestion_networks.php +++ b/application/views/gestion_networks.php @@ -62,7 +62,7 @@ lang->line('Statut'); ?> lang->line('Activer/Désactiver'); ?> lang->line('Modifier'); ?> - lang->line('Supprimer'); ?> + lang->line('Supprimer'); ?> diff --git a/application/views/gestion_wallet_ilink_config_paying_network.php b/application/views/gestion_wallet_ilink_config_paying_network.php index 278bb331..392d16dd 100755 --- a/application/views/gestion_wallet_ilink_config_paying_network.php +++ b/application/views/gestion_wallet_ilink_config_paying_network.php @@ -184,7 +184,7 @@ lang->line('Statut'); ?> lang->line('share_rate') ?> URL - Action + Action diff --git a/application/views/header_agent.php b/application/views/header_agent.php new file mode 100755 index 00000000..794d9bdb --- /dev/null +++ b/application/views/header_agent.php @@ -0,0 +1,120 @@ + + + + + + + iLink | Superviseur + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ + + + +
+ + diff --git a/application/views/nano_health/agent/insurances_health_care_sheets.php b/application/views/nano_health/agent/insurances_health_care_sheets.php new file mode 100755 index 00000000..7da2bdeb --- /dev/null +++ b/application/views/nano_health/agent/insurances_health_care_sheets.php @@ -0,0 +1,206 @@ + + + + + +
+ + +
+

+ lang->line('manage_health_care_sheets') ?> + + +

+
+
+
+
+
+ +
+ lang->line('Période') ?> + + + + + Format : session->userdata('site_lang') === 'french' ? 'Jour - Mois - Année ' : 'Year - Month - Day' ?> +
+
+
+ + +
+
+
+
+
+

lang->line('export_health_care_sheets_list') ?>

+
+ +
+
+
+ + + + + + + + + + + + + + + + + +
lang->line('health_care_sheet_id') ?>Typelang->line('insured_id') ?>lang->line('patient_lastname') ?>lang->line('patient_situation') ?>lang->line('institution_name') ?>lang->line('practitioner_lastname') ?>lang->line('care_condition') ?>lang->line('state') ?>DateAction
+
+
+
+
+
+ + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/application/views/nano_health/hyper/infos_health_care_sheet.php b/application/views/nano_health/hyper/infos_health_care_sheet.php index 0f5a1ce5..785e2b0e 100755 --- a/application/views/nano_health/hyper/infos_health_care_sheet.php +++ b/application/views/nano_health/hyper/infos_health_care_sheet.php @@ -74,28 +74,34 @@ - Patient + Patient lang->line('insured_id'); ?> - insured_id ?> + insured_id ?> lang->line('patient_lastname'); ?> - patient_lastname ; ?> + patient_lastname ; ?> lang->line('patient_firstname')?> - patient_firstname ?> + patient_firstname ?> lang->line('patient_situation')?> - lang->line($health_care_sheet->patient_situation) ?> + lang->line($health_care_sheet->patient_situation) ?> + type == 'EXECUTION') { ?> + + lang->line('consultation_id')?> + prescription_health_care_sheet_id ?> + +
@@ -114,28 +120,28 @@ lang->line('institution_name'); ?> - institution_name ?> + institution_name ?> lang->line('institution_code'); ?> - institution_code ?> + institution_code ?> lang->line('practitioner_lastname'); ?> - practitioner_lastname ; ?> + practitioner_lastname ; ?> lang->line('practitioner_firstname')?> - practitioner_firstname ?> + practitioner_firstname ?> Classification - practitioner_provider_class ?> + practitioner_provider_class ?> lang->line('care_condition')?> - lang->line($health_care_sheet->care_condition) ?> + lang->line($health_care_sheet->care_condition) ?> accident_date)){ ?> @@ -187,33 +193,34 @@
-
-
-

lang->line('performances') ?>

-
-
- - - - - - - - - - - - - - result() as $i => $row) { - $amount = Money::of(round($row->amount, 2), $health_care_sheet->currency_code, $this->context)->formatTo('fr_FR'); - $moderator_ticket = Money::of(round($row->moderator_ticket, 2), $health_care_sheet->currency_code, $this->context)->formatTo('fr_FR'); - $insurance_amount = Money::of(round($row->insurance_amount, 2), $health_care_sheet->currency_code, $this->context)->formatTo('fr_FR'); - $home_visit_fees = isset($row->home_visit_fees) ? Money::of(round($row->home_visit_fees, 2), $health_care_sheet->currency_code, $this->context)->formatTo('fr_FR') : ''; + type != 'EXECUTION') { ?> +
+
+

lang->line('performances') ?>

+
+
+
#lang->line('act_code'); ?>lang->line('Montant'); ?>lang->line('moderator_ticket'); ?>lang->line('insurance_amount'); ?>lang->line('home_visit_fees'); ?>Date
+ + + + + + + + + + + + + result() as $i => $row) { + $amount = Money::of(round($row->amount, 2), $health_care_sheet->currency_code, $this->context)->formatTo('fr_FR'); + $moderator_ticket = Money::of(round($row->moderator_ticket, 2), $health_care_sheet->currency_code, $this->context)->formatTo('fr_FR'); + $insurance_amount = Money::of(round($row->insurance_amount, 2), $health_care_sheet->currency_code, $this->context)->formatTo('fr_FR'); + $home_visit_fees = isset($row->home_visit_fees) ? Money::of(round($row->home_visit_fees, 2), $health_care_sheet->currency_code, $this->context)->formatTo('fr_FR') : ''; - echo " + echo " @@ -221,16 +228,18 @@ "; - ?> - - + + - -
#lang->line('act_code'); ?>lang->line('Montant'); ?>lang->line('moderator_ticket'); ?>lang->line('insurance_amount'); ?>lang->line('home_visit_fees'); ?>Date
" . ($i+1) . " " . $row->act_code . " " . $amount . "" . $insurance_amount . " ".$home_visit_fees." " . $row->created_at. "
+ ?> + + +
-
+ + num_rows() > 0 ) { ?>
diff --git a/application/views/nano_health/hyper/infos_insurance.php b/application/views/nano_health/hyper/infos_insurance.php index 89435836..e48e1715 100755 --- a/application/views/nano_health/hyper/infos_insurance.php +++ b/application/views/nano_health/hyper/infos_insurance.php @@ -73,21 +73,21 @@ lang->line('insured_id'); ?> - + lang->line('Nom'); ?> - lastname ?? '' . $user->firstname ?? ''; ?> + lastname ?? '' . $user->firstname ?? ''; ?> lang->line('Adresse')?> - adresse ?> + adresse ?> lang->line('Contact')?> - phone." | ".$user->email ?> + phone." | ".$user->email ?> diff --git a/application/views/nano_health/hyper/infos_insurance_subscription.php b/application/views/nano_health/hyper/infos_insurance_subscription.php index a5205eb3..62f272b2 100755 --- a/application/views/nano_health/hyper/infos_insurance_subscription.php +++ b/application/views/nano_health/hyper/infos_insurance_subscription.php @@ -91,16 +91,16 @@ lang->line('Nom'); ?> - lastname ?? '' . $user->firstname ?? ''; ?> + lastname ?? '' . $user->firstname ?? ''; ?> lang->line('Adresse')?> - adresse ?> + adresse ?> lang->line('Contact')?> - phone." | ".$user->email ?> + phone." | ".$user->email ?> diff --git a/application/views/nano_health/hyper/insurances_health_care_sheets.php b/application/views/nano_health/hyper/insurances_health_care_sheets.php index 9099c792..dd02673f 100755 --- a/application/views/nano_health/hyper/insurances_health_care_sheets.php +++ b/application/views/nano_health/hyper/insurances_health_care_sheets.php @@ -128,7 +128,8 @@ "data":{ "startDate" : "", "endDate" : "", - "id_network" : "", + "id_network" : "", + "network_agent_id" : "", "currentURL" : "" }, "type": "POST" @@ -175,7 +176,8 @@ $(function () { const lang = $('#picker').data('lang'); const category = $('#picker').data('category'); - const id_network = ""; + const id_network = ""; + const ne = "" $('input[name="daterange"]').daterangepicker({ opens: 'left', autoUpdateInput: false,