Implements invoices of health care sheet and add QR code on listadmin table

This commit is contained in:
Djery-Tom 2022-01-24 09:08:05 +01:00
parent ee88414d9e
commit 783001659a
18 changed files with 637 additions and 203 deletions

View File

@ -33,8 +33,8 @@ class Agent extends CI_Controller
$data['show_health_care_sheet_buttons'] = true;
if ($this->input->get('history')) {
$history = $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');
@ -49,7 +49,7 @@ class Agent extends CI_Controller
$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'));
$this->historique($this->input->get('d'), $this->input->get('f'), $this->input->get('history') , $data);
}
}else if($this->input->get('action')) {
@ -73,17 +73,7 @@ class Agent extends CI_Controller
}
$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');
$this->historique($this->input->get('d'), $this->input->get('f'), 'insurance-health_care_sheets' , $data);
}
}
}
@ -112,110 +102,30 @@ class Agent extends CI_Controller
} 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)
private function historique($startDate, $endDate,$type , $data)
{
$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');
if ($type == 'insurance-invoices')
$data['active'] = 'wallet_invoices';
else if ($type == 'insurance-health_care_sheets')
$data['active'] = 'wallet_health_care_sheets';
$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('header_agent', $data);
if ($type == 'insurance-invoices')
$this->load->view('nano_health/hyper/insurances_invoices');
else if ($type == 'insurance-health_care_sheets')
$this->load->view('nano_health/hyper/insurances_health_care_sheets');
$this->load->view('footer');
}

View File

@ -624,6 +624,8 @@ class Hyperviseur_dash extends CI_Controller
$this->load->view('nano_health/hyper/insurances_insured.php');
else if ($type == 'insurance-health_care_sheets')
$this->load->view('nano_health/hyper/insurances_health_care_sheets.php');
else if ($type == 'insurance-invoices')
$this->load->view('nano_health/hyper/insurances_invoices.php');
else
$this->load->view('historique_recharges');
$this->load->view('footer');
@ -1727,6 +1729,31 @@ class Hyperviseur_dash extends CI_Controller
$this->load->view('footer');
}
public function generateQRCode(){
if ($this->isLogged()) {
$url = WALLET_SERVICE_URL.'/qrcode/generate';
$data = http_build_query($_POST);
$ch = curl_init($url."?".$data);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "GET");
/* set the content type json */
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Content-Type:application/json',
'Authorization:'.WALLET_SERVICE_TOKEN,
'X-localization:'. $this->session->userdata('site_lang') == 'french' ? 'fr' : 'en'
));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
/* execute request */
$result = curl_exec($ch);
/* close cURL resource */
curl_close($ch);
if ($result) {
echo $result;
} else {
echo json_encode(['status' => 500]);
}
}
}
public function recherche()
{

View File

@ -482,6 +482,39 @@ class NanoHealthController extends CI_Controller
}
}
public function generateInvoice()
{
if($this->isLogged()) {
if (isset($_POST)) {
$url = NANO_SANTE_SERVICE_URL.'/generate-invoice';
$data = http_build_query($_POST);
// $getUrl = $url."?".$data;
$ch = curl_init($url."?".$data);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "GET");
/* set the content type json */
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Content-Type:application/json',
'Authorization:'.NANO_SANTE_SERVICE_TOKEN,
'X-localization:'. $this->session->userdata('site_lang') == 'french' ? 'fr' : 'en'
));
/* set return type json */
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
/* execute request */
$result = curl_exec($ch);
/* close cURL resource */
curl_close($ch);
if ($result) {
echo $result;
} else {
echo json_encode(['status' => 500]);
}
}
}
}
private function isLogged()
{
if (!$this->session->userdata('email')) {

View File

@ -33,19 +33,19 @@ class GeolocatedUsers extends CI_Controller
$data = array("<button class='btn btn-default btn-center openSupervisorModal' data-code_parrain='$row->code_parrain'>$code_parrain</button>",
$row->lastname,$row->adresse, $row->code_membre , $row->email, $row->phone , $row->provider_class ,$status);
// if($_POST['category'] == 'geolocated'){
// if($row->has_qr_code)
// array_push($data,"<a href='".WALLET_SERVICE_URL."/qrcodes/".$row->id.".pdf' class='btn btn-success btn-center' target='_blank'>".$this->lang->line('display')."</a>");
// else
// array_push($data,"<button class='btn btn-primary btn-center generateQRCode' data-id_agent='$row->id'>".$this->lang->line('generate')."</button>");
// }
if($_POST['category'] == 'geolocated'){
if($row->has_qr_code)
$data[] = "<a href='" . WALLET_SERVICE_URL . "/qrcodes/agents/" . $row->id . ".pdf' class='btn btn-success btn-center' target='_blank'>" . $this->lang->line('display') . "</a>";
else
$data[] = "<button class='btn btn-primary btn-center generateQRCode' data-id_agent='$row->id'>" . $this->lang->line('generate') . "</button>";
}
if ($this->session->userdata("category") == "0" or $this->session->userdata("category") == "hyper")
array_push($data, "<button data-toggle='modal' data-category='$row->category' data-lastname='$row->lastname' data-adresse='$row->adresse' data-network_agent_id='$row->network_agent_id' data-provider_class_id='$row->provider_class_id'
data-network='$row->network' data-member_code='$row->code_membre' data-email='$row->email' data-phone='$row->phone' class='open-modal modif btn btn-success' data-target='#editModal'><i class='fa fa-edit'></i></button>");
$data[] = "<button data-toggle='modal' data-category='$row->category' data-lastname='$row->lastname' data-adresse='$row->adresse' data-network_agent_id='$row->network_agent_id' data-provider_class_id='$row->provider_class_id'
data-network='$row->network' data-member_code='$row->code_membre' data-email='$row->email' data-phone='$row->phone' class='open-modal modif btn btn-success' data-target='#editModal'><i class='fa fa-edit'></i></button>";
array_push($list,$data);
$list[] = $data;
}

View File

@ -10,7 +10,7 @@ use Brick\Money\Money;
class Insurances extends CI_Controller
{
private $converter = null;
// private $converter = null;
private $context = null;
function __construct()
@ -40,7 +40,7 @@ class Insurances extends CI_Controller
$provider = new BaseCurrencyProvider($provider, $baseCurrency);
// this currency converter can now handle any currency pair
$this->converter = new CurrencyConverter($provider);
// $this->converter = new CurrencyConverter($provider);
$this->context = new AutoContext();
}

View File

@ -0,0 +1,75 @@
<?php
defined('BASEPATH') or exit('No direct script access allowed');
use Brick\Money\Context\AutoContext;
use Brick\Money\CurrencyConverter;
use Brick\Money\ExchangeRateProvider\BaseCurrencyProvider;
use Brick\Money\ExchangeRateProvider\PDOProvider;
use Brick\Money\ExchangeRateProvider\PDOProviderConfiguration;
use Brick\Money\Money;
class Invoices extends CI_Controller
{
private $context = null;
function __construct()
{
parent::__construct();
// Load member model
$this->load->model('pagination/Invoices_model', 'model');
// set to whatever your rates are relative to
$baseCurrency = 'USD';
// use your own credentials, or re-use your existing PDO connection
$pdo = new PDO('mysql:host=' . $this->db->hostname . ';dbname=' . $this->db->database, $this->db->username, $this->db->password);
$configuration = new PDOProviderConfiguration();
$configuration->tableName = 'exchange_rate';
$configuration->exchangeRateColumnName = 'exchange_rate';
$configuration->targetCurrencyColumnName = 'target_currency';
$configuration->sourceCurrencyCode = $baseCurrency;
// this provider loads exchange rates from your database
$provider = new PDOProvider($pdo, $configuration);
// this provider calculates exchange rates relative to the base currency
$provider = new BaseCurrencyProvider($provider, $baseCurrency);
// this currency converter can now handle any currency pair
$this->context = new AutoContext();
}
function getLists()
{
$data = $row = array();
// Fetch member's records
$witData = $this->model->getRows($_POST);
$i = $_POST['start'];
$current_url = $_POST['currentURL'];
foreach ($witData as $row) {
$amount = Money::of(round($row->amount, 2), $row->currency_code, $this->context)->formatTo('fr_FR');
$insured_amount = Money::of(round($row->insured_amount, 2), $row->currency_code, $this->context)->formatTo('fr_FR');
$insurer_amount = Money::of(round($row->insurer_amount, 2), $row->currency_code, $this->context)->formatTo('fr_FR');
$data[] = array($row->invoice_id , $row->institution_name , $amount , $insured_amount, $insurer_amount,
$row->period_start_at, $row->period_end_at, '<a href="'.$row->file_url.'" class="btn btn-primary" target="blank"> '.$this->lang->line('Voir plus...').'</a>');
}
$output = array(
"draw" => $_POST['draw'],
"recordsTotal" => $this->model->countAll($_POST),
"recordsFiltered" => $this->model->countFiltered($_POST),
"data" => $data,
);
// Output to JSON format
echo json_encode($output);
}
}

View File

@ -819,7 +819,6 @@ $lang['drugs_or_device'] = "Drug / Device";
$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";
$lang['new_care_sheet'] = "Enter a care sheet";
$lang['new_prestation'] = "New service";
@ -842,4 +841,16 @@ $lang['consultation_rule_1'] = "You must enter at least one benefit";
$lang['execution_updated'] = "Modified execution";
$lang['execution_rule_1'] = "You must enter at least one test or prescription";
$lang['execution_rule_2'] = "An execution concerns only either examinations or medical prescriptions";
$lang['INVOICE_ISSUED'] = "Invoice issued";
$lang['display'] = "Display";
$lang['qr_code_generated'] = "QR Code generated with success";
$lang['invoices'] = "Invoices";
$lang['manage_invoices'] = "Invoice management";
$lang['export_invoices_list'] = "Export invoice list";
$lang['total_amount'] = "Total Amount";
$lang['total_insured_part'] = "Total Insured Share";
$lang['total_insurance_part'] = "Total Insurance Share";
$lang['invoices_history'] = "Invoice history";
$lang['health_care_sheets_history'] = "History of health care sheets";
$lang['invoice_id'] = "Invoice ID";
?>

View File

@ -830,7 +830,6 @@ $lang['drugs_or_device'] = "Médicament / Appareillage";
$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";
$lang['new_care_sheet'] = "Saisir une feuille de soins";
$lang['new_prestation'] = "Nouvelle prestation";
@ -853,4 +852,16 @@ $lang['execution_updated'] = "Execution modifiée";
$lang['consultation_rule_1'] = "Vous devez saisir au moins une prestation";
$lang['execution_rule_1'] = "Vous devez saisir au moins un examen ou prescription";
$lang['execution_rule_2'] = "Une execution concerne uniquement soit les examens , soit les prescriptions médicales";
$lang['INVOICE_ISSUED'] = "Facture émise";
$lang['display'] = "Afficher";
$lang['qr_code_generated'] = "QR Code généré avec succes";
$lang['invoices'] = "Factures";
$lang['manage_invoices'] = "Gestion des factures";
$lang['export_invoices_list'] = "Exporter la liste des factures";
$lang['total_amount'] = "Total Montant";
$lang['total_insured_part'] = "Total Part de l'assuré";
$lang['total_insurance_part'] = "Total Part de assurance";
$lang['invoices_history'] = "Historique des factures";
$lang['health_care_sheets_history'] = "Historique des feuilles de soins";
$lang['invoice_id'] = "ID de la facture";
?>

View File

@ -9,7 +9,7 @@ class GeolocatedUsers_model extends CI_Model
// Set table name
$this->table = 'agent_plus';
// Set orderable column fields
$this->column_order = array('code_parrain','lastname', 'adresse', 'code_membre', 'email' , 'phone', 'active', 'provider_class',null);
$this->column_order = array('code_parrain','lastname', 'adresse', 'code_membre', 'email' , 'phone', 'active', 'provider_class',null, null);
// Set searchable column fields
$this->column_search = array('code_parrain','lastname', 'adresse', 'code_membre', 'email' , 'phone','provider_class');
// Set default order

View File

@ -0,0 +1,109 @@
<?php
defined('BASEPATH') or exit('No direct script access allowed');
class Invoices_model extends CI_Model
{
function __construct()
{
// Set table name
$this->table = 'nh_infos_invoices';
// Set orderable column fields
$this->column_order = array('invoice_id','institution_name','amount', 'insured_amount', 'insurer_amount', 'period_start_at', 'period_end_at', null);
// Set searchable column fields
$this->column_search = array('invoice_id','institution_name','amount', 'insured_amount', 'insurer_amount', 'period_start_at', 'period_end_at');
// Set default order
$this->order = array('created_at' => 'desc');
}
/*
* Fetch members data from the database
* @param $_POST filter data based on the posted parameters
*/
public function getRows($postData)
{
$this->_get_datatables_query($postData);
if ($postData['length'] != -1) {
$this->db->limit($postData['length'], $postData['start']);
}
$query = $this->db->get();
return $query->result();
}
/*
* Count all records
*/
public function countAll($postData)
{
$this->db->from($this->table);
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();
}
/*
* Count records based on the filter params
* @param $_POST filter data based on the posted parameters
*/
public function countFiltered($postData)
{
$this->_get_datatables_query($postData);
$query = $this->db->get();
return $query->num_rows();
}
/*
* Perform the SQL queries needed for an server-side processing requested
* @param $_POST filter data based on the posted parameters
*/
private function _get_datatables_query($postData)
{
$this->db->from($this->table);
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")));
}
$i = 0;
// loop searchable columns
foreach ($this->column_search as $item) {
// if datatable send POST for search
if ($postData['search']['value']) {
// first loop
if ($i === 0) {
// open bracket
$this->db->group_start();
$this->db->like($item, $postData['search']['value']);
} else {
$this->db->or_like($item, $postData['search']['value']);
}
// last loop
if (count($this->column_search) - 1 == $i) {
// close bracket
$this->db->group_end();
}
}
$i++;
}
if (isset($postData['order'])) {
$this->db->order_by($this->column_order[$postData['order']['0']['column']], $postData['order']['0']['dir']);
} else if (isset($this->order)) {
$order = $this->order;
$this->db->order_by(key($order), $order[key($order)]);
}
}
}

View File

@ -105,11 +105,18 @@
<?php if ($hasWallet) {
?>
<?php if ($hasWallet->first_row()->type == 'ilink_sante') { ?>
<li class="<?php if ($active == "health_care_sheets") {
<li class="<?php if ($active == "wallet_health_care_sheets") {
echo "active";
} ?>">
<a href="<?= base_url('Agent') ?>">
<i class="fa fa-money"></i> <span>Feuille de soins</span>
<a href="<?= base_url('Agent?history=insurance-health_care_sheets') ?>">
<i class="fa fa-money"></i>
<span><?php echo $this->lang->line('health_care_sheets'); ?></span>
</a>
</li>
<li class="<?php if ($active == "wallet_invoices") {echo "active";} ?>">
<a href="<?php echo base_url('Agent?history=insurance-invoices') ?>">
<i class="fa fa-file-text"></i>
<span><?php echo $this->lang->line('invoices'); ?></span>
</a>
</li>
<?php }?>

View File

@ -221,6 +221,12 @@
<span><?php echo $this->lang->line('health_care_sheets'); ?></span>
</a>
</li>
<li class="<?php if ($active == "wallet_invoices") {echo "active";} ?>">
<a href="<?php echo base_url('Hyperviseur_dash/wallet?history=insurance-invoices') ?>">
<i class="fa fa-file-text"></i>
<span><?php echo $this->lang->line('invoices'); ?></span>
</a>
</li>
<?php } ?>
<li class="<?php if ($active == "wallet_password") {
echo "active";

View File

@ -151,9 +151,9 @@ $fmt = new NumberFormatter('fr_FR', NumberFormatter::DECIMAL);
<tr>
<th><?php echo $this->lang->line('act_code'); ?> </th>
<th><?php echo $this->lang->line('Montant'); ?></th>
<th><?= $this->lang->line('home_visit_fees'); ?></th>
<th><?= $this->lang->line('moderator_ticket'); ?></th>
<th><?= $this->lang->line('insurance_amount'); ?></th>
<th><?= $this->lang->line('home_visit_fees'); ?></th>
<th>Actions</th>
</tr>
</thead>
@ -364,7 +364,7 @@ $fmt = new NumberFormatter('fr_FR', NumberFormatter::DECIMAL);
arrayItem['act_id'] = $(item).attr('value');
if (index === 1)
arrayItem['amount'] = parseFloat($(item).html());
if (index === 4)
if (index === 2)
arrayItem['home_visit_fees'] = parseFloat($(item).html()) || null;
});
prestations.push(arrayItem);
@ -460,36 +460,40 @@ $fmt = new NumberFormatter('fr_FR', NumberFormatter::DECIMAL);
}
function calculatePrestationsAmount(){
$('#amount').on('input', function () {
var amount = parseFloat($(this).val());
var care_condition = $('#sheet-form').find('select[name="care_condition"]').val();
if(isNaN(amount)){
$('#moderator-ticket').val('');
$('#insurance-amount').val('');
}else{
$.ajax({
url: '<?php echo base_url('NanoHealthController/calculateHealthCareSheetPerformancesAmount')?>',
type: 'POST',
dataType: 'json',
data: {
"network_id" : "<?= $network_id ?>", "amount": amount, "care_condition": care_condition
},
success: function (data) {
if(data.status === 200){
$('#moderator-ticket').val(data.response.moderator_ticket);
$('#insurance-amount').val(data.response.insurance_amount);
}else{
toastr.error(data.error , "<?= $this->lang->line('request_error')?>");
}
},
error: function (resultat, statut, error) {
console.log(resultat + " " + error);
toastr.error("<?php echo $this->lang->line('error_message')?>", "<?php echo $this->lang->line('request_error')?>");
}
});
}
$('#amount').on('input',fetchPrestationsAmount)
$('#fees').on('input',fetchPrestationsAmount)
}
})
function fetchPrestationsAmount(){
var amount = parseFloat($("#amount").val());
var fees = parseFloat($("#fees").val());
fees = isNaN(fees) ? 0 : fees;
var care_condition = $('#sheet-form').find('select[name="care_condition"]').val();
if(isNaN(amount + fees)){
$('#moderator-ticket').val('');
$('#insurance-amount').val('');
}else{
$.ajax({
url: '<?php echo base_url('NanoHealthController/calculateHealthCareSheetPerformancesAmount')?>',
type: 'POST',
dataType: 'json',
data: {
"network_id" : "<?= $network_id ?>", "amount": (amount + fees), "care_condition": care_condition
},
success: function (data) {
if(data.status === 200){
$('#moderator-ticket').val(data.response.moderator_ticket);
$('#insurance-amount').val(data.response.insurance_amount);
}else{
toastr.error(data.error , "<?= $this->lang->line('request_error')?>");
}
},
error: function (resultat, statut, error) {
console.log(resultat + " " + error);
toastr.error("<?php echo $this->lang->line('error_message')?>", "<?php echo $this->lang->line('request_error')?>");
}
});
}
}
$('[data-toggle="tooltip"]').tooltip();
@ -511,9 +515,10 @@ $fmt = new NumberFormatter('fr_FR', NumberFormatter::DECIMAL);
'</select>' +
'</td>' +
'<td><input type="number" required class="form-control" name="amount" min="0" id="amount"></td>' +
'<td><input type="number" class="form-control" name="home_visit_fees" min="0" id="fees"></td>' +
'<td><input class="form-control" name="moderator_ticket" disabled id="moderator-ticket"></td>' +
'<td><input class="form-control" name="insurance_amount" disabled id="insurance-amount"></td>' +
'<td><input type="number" class="form-control" name="home_visit_fees" min="0"></td>' +
'<td> ' + actions1 + '</td>' +
'</tr>';
$("#prestations").append(row);
@ -559,11 +564,12 @@ $fmt = new NumberFormatter('fr_FR', NumberFormatter::DECIMAL);
if (index == 1)
$(this).html('<input type="number" required class="form-control" name="amount" min="0" id="amount" value="' + $(this).text() + '">');
if (index == 2)
$(this).html('<input class="form-control" name="moderator_ticket" disabled id="moderator-ticket" value="' + $(this).text() + '">');
if (index == 3)
$(this).html('<input class="form-control" name="insurance_amount" disabled id="insurance-amount" value="' + $(this).text() + '">');
if (index == 4)
$(this).html('<input type="number" class="form-control" name="home_visit_fees" min="0" value="' + $(this).text() + '">');
if (index == 3)
$(this).html('<input class="form-control" name="moderator_ticket" disabled id="moderator-ticket" value="' + $(this).text() + '">');
if (index == 4)
$(this).html('<input class="form-control" name="insurance_amount" disabled id="insurance-amount" value="' + $(this).text() + '">');
});
$(this).parents("tr").find(".add, .edit").toggle();
$(".new1").attr("disabled", "disabled");

View File

@ -151,9 +151,9 @@ $fmt = new NumberFormatter('fr_FR', NumberFormatter::DECIMAL);
<tr>
<th><?php echo $this->lang->line('act_code'); ?> </th>
<th><?php echo $this->lang->line('Montant'); ?></th>
<th><?= $this->lang->line('home_visit_fees'); ?></th>
<th><?= $this->lang->line('moderator_ticket'); ?></th>
<th><?= $this->lang->line('insurance_amount'); ?></th>
<th><?= $this->lang->line('home_visit_fees'); ?></th>
<th>Actions</th>
</tr>
</thead>
@ -415,9 +415,9 @@ $fmt = new NumberFormatter('fr_FR', NumberFormatter::DECIMAL);
$('#prestations').append('<tr>' +
'<td id="'+it.id+'" act_id="'+it.act.id+'">'+(it.act.name|| '')+'</td>' +
'<td>'+(parseFloat(it.amount) || '')+'</td>' +
'<td>'+(parseFloat(it.home_visit_fees) || '')+'</td>' +
'<td>'+(it.moderator_ticket_formatted || '')+'</td>' +
'<td>'+(it.insurance_amount_formatted || '')+'</td>' +
'<td>'+(parseFloat(it.home_visit_fees) || '')+'</td>' +
'<td>'+actions1+'</td>' +
'</tr>')
});
@ -481,7 +481,7 @@ $fmt = new NumberFormatter('fr_FR', NumberFormatter::DECIMAL);
}
if (index === 1)
arrayItem['amount'] = parseFloat($(item).html());
if (index === 4)
if (index === 2)
arrayItem['home_visit_fees'] = parseFloat($(item).html()) || null;
});
prestations.push(arrayItem);
@ -587,36 +587,40 @@ $fmt = new NumberFormatter('fr_FR', NumberFormatter::DECIMAL);
}
function calculatePrestationsAmount(){
$('#amount').on('input', function () {
var amount = parseFloat($(this).val());
var care_condition = $('#sheet-form').find('select[name="care_condition"]').val();
if(isNaN(amount)){
$('#moderator-ticket').val('');
$('#insurance-amount').val('');
}else{
$.ajax({
url: '<?php echo base_url('NanoHealthController/calculateHealthCareSheetPerformancesAmount')?>',
type: 'POST',
dataType: 'json',
data: {
"network_id" : "<?= $network_id ?>", "amount": amount, "care_condition": care_condition
},
success: function (data) {
if(data.status === 200){
$('#moderator-ticket').val(data.response.moderator_ticket);
$('#insurance-amount').val(data.response.insurance_amount);
}else{
toastr.error(data.error , "<?= $this->lang->line('request_error')?>");
}
},
error: function (resultat, statut, error) {
console.log(resultat + " " + error);
toastr.error("<?php echo $this->lang->line('error_message')?>", "<?php echo $this->lang->line('request_error')?>");
}
});
}
$('#amount').on('input',fetchPrestationsAmount)
$('#fees').on('input',fetchPrestationsAmount)
}
})
function fetchPrestationsAmount(){
var amount = parseFloat($("#amount").val());
var fees = parseFloat($("#fees").val());
fees = isNaN(fees) ? 0 : fees;
var care_condition = $('#sheet-form').find('select[name="care_condition"]').val();
if(isNaN(amount + fees)){
$('#moderator-ticket').val('');
$('#insurance-amount').val('');
}else{
$.ajax({
url: '<?php echo base_url('NanoHealthController/calculateHealthCareSheetPerformancesAmount')?>',
type: 'POST',
dataType: 'json',
data: {
"network_id" : "<?= $network_id ?>", "amount": (amount + fees), "care_condition": care_condition
},
success: function (data) {
if(data.status === 200){
$('#moderator-ticket').val(data.response.moderator_ticket);
$('#insurance-amount').val(data.response.insurance_amount);
}else{
toastr.error(data.error , "<?= $this->lang->line('request_error')?>");
}
},
error: function (resultat, statut, error) {
console.log(resultat + " " + error);
toastr.error("<?php echo $this->lang->line('error_message')?>", "<?php echo $this->lang->line('request_error')?>");
}
});
}
}
$('[data-toggle="tooltip"]').tooltip();
@ -638,9 +642,9 @@ $fmt = new NumberFormatter('fr_FR', NumberFormatter::DECIMAL);
'</select>' +
'</td>' +
'<td><input type="number" required class="form-control" name="amount" min="0" id="amount"></td>' +
'<td><input type="number" class="form-control" name="home_visit_fees" id="fees" min="0"></td>' +
'<td><input class="form-control" name="moderator_ticket" disabled id="moderator-ticket"></td>' +
'<td><input class="form-control" name="insurance_amount" disabled id="insurance-amount"></td>' +
'<td><input type="number" class="form-control" name="home_visit_fees" min="0"></td>' +
'<td> ' + actions1 + '</td>' +
'</tr>';
$("#prestations").append(row);
@ -692,11 +696,12 @@ $fmt = new NumberFormatter('fr_FR', NumberFormatter::DECIMAL);
if (index === 1)
$(this).html('<input type="number" required class="form-control" name="amount" min="0" id="amount" value="' + $(this).text() + '">');
if (index === 2)
$(this).html('<input class="form-control" name="moderator_ticket" disabled id="moderator-ticket" value="' + $(this).text() + '">');
$(this).html('<input type="number" class="form-control" name="home_visit_fees" id="fees" min="0" value="' + $(this).text() + '">');
if (index === 3)
$(this).html('<input class="form-control" name="insurance_amount" disabled id="insurance-amount" value="' + $(this).text() + '">');
$(this).html('<input class="form-control" name="moderator_ticket" disabled id="moderator-ticket" value="' + $(this).text() + '">');
if (index === 4)
$(this).html('<input type="number" class="form-control" name="home_visit_fees" min="0" value="' + $(this).text() + '">');
$(this).html('<input class="form-control" name="insurance_amount" disabled id="insurance-amount" value="' + $(this).text() + '">');
});
$(this).parents("tr").find(".add, .edit").toggle();
$(".new1").attr("disabled", "disabled");

View File

@ -230,9 +230,9 @@
<th>#</th>
<th><?= $this->lang->line('act_code'); ?></th>
<th><?= $this->lang->line('Montant'); ?></th>
<th><?= $this->lang->line('home_visit_fees'); ?></th>
<th><?= $this->lang->line('moderator_ticket'); ?></th>
<th><?= $this->lang->line('insurance_amount'); ?></th>
<th><?= $this->lang->line('home_visit_fees'); ?></th>
<th>Date</th>
</tr>
</thead>
@ -249,9 +249,9 @@
<td>" . ($i+1) . "</td>
<td>" . $row->act_code . "</td>
<td>" . $amount . "</td>
<td>".$home_visit_fees."</td>
<td>" . $moderator_ticket . "</td>
<td>" . $insurance_amount . "</td>
<td>".$home_visit_fees."</td>
<td>" . $row->created_at. "</td>";
?>
</tr>

View File

@ -57,6 +57,9 @@
<button class="btn btn-primary" id="update-execution">
<?= $this->lang->line('update_execution'); ?>
</button>
<button class="btn btn-danger" id="generate-invoice">
Generer la facture
</button>
<?php } ?>
</div>
</div>
@ -192,17 +195,17 @@
'pageLength',
{
"extend": 'excelHtml5',
title: "<?= $this->lang->line('subscriptions_history') ?>",
title: "<?= $this->lang->line('health_care_sheets_history') ?>",
},
{
extend: 'csvHtml5',
title: "<?= $this->lang->line('subscriptions_history') ?>",
title: "<?= $this->lang->line('health_care_sheets_history') ?>",
},
{
extend: 'pdfHtml5',
orientation: 'landscape',
pageSize: 'LEGAL',
title: "<?= $this->lang->line('subscriptions_history') ?>",
title: "<?= $this->lang->line('health_care_sheets_history') ?>",
trim: false,
"action": newexportaction
},
@ -281,6 +284,33 @@
$('#modal').modal('show');
})
$('#generate-invoice').click(function () {
$.ajax({
url: '<?= base_url('NanoHealthController/generateInvoice')?>',
type: 'POST',
dataType: 'json',
data: { network_agent_id : "<?= $network_agent_id ?? null ?>"},
success: function (data) {
if(data.status === 200){
Swal.fire({
icon: 'success',
title: "La facture a été générée",
text:"<?= $this->lang->line('informations_updated')?>",
timer: 3000
}).then(()=>{
location.reload();
});
}else{
toastr.error(data.error , "<?= $this->lang->line('request_error')?>");
}
},
error: function (resultat, statut, error) {
console.log(resultat + " " + error);
toastr.error("<?= $this->lang->line('error_message')?>", "<?= $this->lang->line('request_error')?>");
}
});
})
$('#check-insured').click(function () {
if ($('#search-form')[0].checkValidity()) {
let option = $('#search-form').find('select[name="option"]').val();

View File

@ -0,0 +1,204 @@
<!-- DataTables -->
<link rel="stylesheet"
href="<?= base_url('bower_components/datatables.net-bs/css/dataTables.bootstrap.min.css') ?>">
<link rel="stylesheet" type="text/css" href="https://cdn.jsdelivr.net/npm/daterangepicker/daterangepicker.css"/>
<link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/buttons/1.6.2/css/buttons.dataTables.min.css">
<link rel="stylesheet" href="<?= base_url('bower_components/toastr/toastr.css') ?>">
<div class="content-wrapper">
<?php
?>
<!-- Content Header (Page header) -->
<section class="content-header">
<h1>
<?= $this->lang->line('manage_invoices') ?>
<!-- <input type="button" class="btn btn-primary pull-right" id="Bactiver"-->
<!-- value="Activer/Désactiver le(s) réseau(x)" />-->
</h1>
</section>
<section class="content">
<div class="row">
<div class="col-md-4 col-sm-6 col-xs-12">
<div class="info-box">
<span class="info-box-icon bg-aqua"><i class="ion ion-android-time"></i></span>
<div class="info-box-content">
<span class="info-box-text"><?= $this->lang->line('Période') ?> </span>
<span class="info-box-number">
<input id="picker"
style="background: #fff; cursor: pointer; padding: 1px 1px; border: 1px solid #ccc; width: 100%"
data-category="<?= isset($category) ? $category : null ?>"
type="text" name="daterange"
data-lang="<?= $this->session->userdata('site_lang') ?>"
value="<?= ($startDate != null & $endDate != null) ? $startDate . ' - ' . $endDate : '' ?>"/>
</span>
<span> Format : <?= $this->session->userdata('site_lang') === 'french' ? 'Jour - Mois - Année ' : 'Year - Month - Day' ?> </span>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-xs-12">
<div class="box">
<div class="box-header">
<h3 class="box-title"><?= $this->lang->line('export_invoices_list') ?></h3>
<div class="box-tools">
</div>
</div>
<div class="box-body" style="overflow-x:auto;">
<table id="invoices" class="table table-bordered table-striped">
<thead>
<tr>
<th align='center'><?= $this->lang->line('invoice_id') ?></th>
<th>Emetteur</th>
<th><?= $this->lang->line('total_amount') ?></th>
<th><?= $this->lang->line('total_insured_part') ?></th>
<th><?= $this->lang->line('total_insurance_part') ?></th>
<th>Date debut</th>
<th>Date fin</th>
<th align='center'>Action</th>
</tr>
</thead>
</table>
</div>
</div>
</div>
</div>
</section>
</div>
<!-- jQuery 3 -->
<script src="<?= base_url('bower_components/jquery/dist/jquery.min.js') ?>"></script>
<!-- Bootstrap 3.3.7 -->
<script src="<?= base_url('bower_components/bootstrap/dist/js/bootstrap.min.js') ?>"></script>
<!-- DataTables -->
<script src="<?= base_url('bower_components/datatables.net/js/jquery.dataTables.min.js') ?>"></script>
<script src="<?= base_url('bower_components/datatables.net-bs/js/dataTables.bootstrap.min.js') ?>"></script>
<!-- SlimScroll -->
<script src="<?= base_url('bower_components/jquery-slimscroll/jquery.slimscroll.min.js') ?>"></script>
<!-- FastClick -->
<script src="<?= base_url('bower_components/fastclick/lib/fastclick.js') ?>"></script>
<!-- AdminLTE App -->
<script src="<?= base_url('dist/js/adminlte.min.js') ?>"></script>
<!-- AdminLTE for demo purposes -->
<script src="<?= base_url('dist/js/demo.js') ?>"></script>
<script type="text/javascript" src="https://cdn.jsdelivr.net/momentjs/latest/moment-with-locales.min.js"></script>
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/daterangepicker/daterangepicker.min.js"></script>
<script type="text/javascript" src="https://cdn.datatables.net/plug-ins/1.10.19/sorting/datetime-moment.js"></script>
<script type="text/javascript" src="https://cdn.datatables.net/plug-ins/1.10.20/dataRender/datetime.js"></script>
<script type="text/javascript" src="https://cdn.datatables.net/buttons/1.6.2/js/dataTables.buttons.min.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jszip/3.1.3/jszip.min.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.1.53/pdfmake.min.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.1.53/vfs_fonts.js"></script>
<script type="text/javascript" src="https://cdn.datatables.net/buttons/1.6.2/js/buttons.html5.min.js"></script>
<script type="text/javascript" src="https://cdn.datatables.net/buttons/1.6.2/js/buttons.print.min.js"></script>
<script type="text/javascript" src="https://cdn.datatables.net/buttons/1.6.2/js/buttons.colVis.min.js"></script>
<script src="<?= base_url('dist/js/sweetalert2.js') ?>"></script>
<script src="<?= base_url('bower_components/toastr/toastr.js') ?>"></script>
<script>
$(function () {
const lang = $('#picker').data('lang');
const format = lang === 'french' ? 'fr' : 'en';
moment.updateLocale(moment.locale(format), {invalidDate: ""}); // Blank text when is invalid date
var table = $('#invoices').DataTable({
// Processing indicator
"processing": true,
"language": {
"processing": "<?= $this->lang->line('loading') ?>",
"emptyTable" : "<?= $this->lang->line('no_insured') ?>"
},
// DataTables server-side processing mode
"serverSide": true,
// Initial no order.
"order": [],
// Load data from an Ajax source
"ajax": {
"url": "<?= base_url('pagination/Invoices/getLists'); ?>",
"data":{
"startDate" : "<?= $startDate?>",
"endDate" : "<?= $endDate?>",
"id_network" : "<?= $id_network ?? null ?>",
"network_agent_id" : "<?= $network_agent_id ?? null ?>",
"currentURL" : "<?= current_url()?>"
},
"type": "POST"
},
"aaSorting": [[6, "desc"]],
"columnDefs": [{
"targets": [5,6],
// "orderable": false,
render: $.fn.dataTable.render.moment('YYYY-MM-DD', 'D MMMM YYYY', format)
}],
dom: 'Bfrtip',
"buttons": [
'pageLength',
{
"extend": 'excelHtml5',
title: "<?= $this->lang->line('invoices_history') ?>",
},
{
extend: 'csvHtml5',
title: "<?= $this->lang->line('invoices_history') ?>",
},
{
extend: 'pdfHtml5',
orientation: 'landscape',
pageSize: 'LEGAL',
title: "<?= $this->lang->line('invoices_history') ?>",
trim: false,
"action": newexportaction
},
// 'colvis'
]
});
table.buttons().container()
.appendTo('#example_wrapper .col-sm-6:eq(0)');
});
</script>
<script type="text/javascript">
var startDate;
var endDate;
$(function () {
const lang = $('#picker').data('lang');
const category = $('#picker').data('category');
const id_network = "<?= $id_network ?? null ?>";
const ne = "<?=$network_agent_id ?? null ?>"
$('input[name="daterange"]').daterangepicker({
opens: 'left',
autoUpdateInput: false,
locale: {
format: lang === 'french' ? 'DD-MM-YYYY' : 'YYYY-MM-DD',
cancelLabel: 'Clear'
}
}, function (start, end, label) {
const debut = start.format('YYYY-MM-DD');
const fin = end.format('YYYY-MM-DD');
if(category)
window.location = "<?= current_url()?>" + "?history=insurance-invoices" + "&d=" + debut + "&f=" + fin;
else
window.location = "<?= current_url()?>" + "?id="+id_network+"&history=insurance-invoices" + "&d=" + debut + "&f=" + fin;
});
$('input[name="daterange"]').on('cancel.daterangepicker', function(ev, picker) {
//do something, like clearing an input
$('#daterange').val('');
if(category)
window.location = "<?= current_url()?>" + "?history=insurance-invoices";
else
window.location = "<?= current_url()?>" + "?id="+id_network+"&history=insurance-invoices";
});
});
</script>

View File

@ -85,7 +85,7 @@
<th><?= $this->lang->line('provider_class'); ?></th>
<th><?= $this->lang->line('Active'); ?></th>
<?php if($category == 'geolocated') { ?>
<!-- <th>QR Code</th>-->
<th>QR Code</th>
<?php } ?>
<?php if ($this->session->userdata("category") == "0" or $this->session->userdata("category") == "hyper") {
echo "<th> Action </th>";
@ -419,10 +419,11 @@
$.ajax({
url: '<?= base_url('index.php/Hyperviseur_dash/generateQRCode')?>',
type: 'POST',
data: {id_agent: id_agent},
data: {'user_id': id_agent , 'type' : 'agent'},
dataType: 'json',
success: function (data) {
data = JSON.parse(data)
console.log('status',data.status)
console.log('respon',data.response)
if(data.status === 200){
Swal.fire({
icon: 'success',
@ -433,11 +434,10 @@
location.reload();
});
}else{
toastr.error("<?= $this->lang->line('error_message')?>", "<?= $this->lang->line('request_error')?>");
toastr.error(data.error , "<?= $this->lang->line('request_error')?>");
}
},
error: function (error) {
console.log(error.responseText);
toastr.error("<?= $this->lang->line('error_message')?>", "<?= $this->lang->line('request_error')?>");
}
});