231 lines
9.7 KiB
PHP
Executable File
231 lines
9.7 KiB
PHP
Executable File
<?php
|
|
|
|
use Brick\Money\Context\AutoContext;
|
|
use Brick\Money\Money;
|
|
|
|
defined('BASEPATH') or exit('No direct script access allowed');
|
|
|
|
class Agent extends CI_Controller
|
|
{
|
|
|
|
public function __construct()
|
|
{
|
|
parent::__construct();
|
|
$this->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');
|
|
$data['network_id'] = $data['id_network'] = $this->session->userdata('network_id');
|
|
$data['hasWallet'] = $this->wallet_model->getConfigWallet($data['network_id']);
|
|
$data['show_health_care_sheet_buttons'] = true;
|
|
|
|
if ($this->input->get('history')) {
|
|
if($this->input->get('id') !== null){
|
|
$history = $this->input->get('history');
|
|
if($history == 'insurance-health_care_sheets'){
|
|
$data['active'] = "health_care_sheets";
|
|
$data['health_care_sheet_id'] = $this->input->get('id');
|
|
$data['health_care_sheet'] = $this->nano_health_model->getInfosHealthCareSheetById($this->input->get('id'));
|
|
$data['performances'] = $this->nano_health_model->getHealthCareSheetPerformances($data['health_care_sheet']->id ?? null);
|
|
$data['exams'] = $this->nano_health_model->getHealthCareSheetExams($data['health_care_sheet']->id ?? null);
|
|
$data['prescriptions'] = $this->nano_health_model->getHealthCareSheetPrescriptions($data['health_care_sheet']->id ?? null);
|
|
|
|
$this->load->view('header_agent', $data);
|
|
$this->load->view('nano_health/hyper/infos_health_care_sheet');
|
|
}
|
|
$this->load->view('footer');
|
|
return;
|
|
}else{
|
|
// $this->historique($id_network, $this->input->get('d'), $this->input->get('f'), $this->input->get('history'), $this->input->get('parrainId'));
|
|
}
|
|
}else if($this->input->get('action')) {
|
|
|
|
$action = $this->input->get('action');
|
|
$nh_config = $this->nano_health_model->getConfig($data['network_id']);
|
|
$data['nh_config'] = $nh_config ? $nh_config->first_row() : null ;
|
|
$data['config_id'] = $data['nh_config'] ? $data['nh_config']->id : null ;
|
|
$data['acts'] = $this->nano_health_model->getConfigActs($data['config_id']);
|
|
$data['provider_classes'] = $this->nano_health_model->getProviderClasses($data['config_id']);
|
|
$data['drugs_and_devices'] = $this->nano_health_model->getDrugAndDevices($data['network_id']);
|
|
|
|
$this->load->view('header_agent', $data);
|
|
if($action == 'new_consultation'){
|
|
$this->load->view('nano_health/agent/health_care_sheet_consultation_form');
|
|
} else {
|
|
$this->load->view('nano_health/agent/health_care_sheet_execution_form');
|
|
}
|
|
$this->load->view('footer');
|
|
}else{
|
|
$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"));
|
|
|
|
$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;
|
|
}
|
|
}
|