168 lines
6.0 KiB
PHP
Executable File
168 lines
6.0 KiB
PHP
Executable File
<?php
|
|
|
|
if (!defined('BASEPATH'))
|
|
exit('No direct script access allowed');
|
|
|
|
class Generate_bill extends MX_Controller {
|
|
|
|
function __construct() {
|
|
parent::__construct();
|
|
$this->load->library('session');
|
|
$this->load->model('Generate_bill_model');
|
|
if (!$this->ion_auth->in_group(array('admin'))) {
|
|
if(!$this->ion_auth->coordinator_permission('generate_bill')){
|
|
redirect('home/permission');
|
|
}
|
|
}
|
|
}
|
|
function index($id = NULL){
|
|
//print_r($id);exit;
|
|
$data = array();
|
|
$id = $_POST['id'];
|
|
|
|
$this->load->model('Generate_bill_model');
|
|
$data['data'] = $this->Generate_bill_model->name_list();
|
|
//echo '<pre>'; print_r($data); echo '</pre>'; exit;
|
|
if($id){
|
|
//echo $id;exit;
|
|
$data['caregiver'] = $this->Generate_bill_model->caregiverInfo($id);
|
|
}
|
|
$data['tab']=1;
|
|
//echo '<pre>'; print_r($data['caregiver']); echo '</pre>'; exit;
|
|
$this->load->view('home/dashboard',$data); // just the header file
|
|
$this->load->view('add_new',$data);
|
|
$this->load->view('home/footer'); // just the header file
|
|
}
|
|
public function getList()
|
|
{
|
|
//print_r($data);die;
|
|
//$this->load->model('Generate_bill_model');
|
|
|
|
$requestData = $_REQUEST;
|
|
$start = $requestData['start'];
|
|
$limit = $requestData['length'];
|
|
|
|
$orderColumn=$requestData['order'][0]['column'];
|
|
$orderType=$requestData['order'][0]['dir'];
|
|
|
|
$search = $this->input->post('search')['value'];
|
|
|
|
if (!empty($search)) {
|
|
|
|
$data['name'] = $this->Generate_bill_model->getNameByLimitBySearch($limit, $start, $search,$orderColumn, $orderType);
|
|
}
|
|
else {
|
|
$data['name'] = $this->Generate_bill_model->getNameByLimit($limit, $start, $orderColumn, $orderType);
|
|
}
|
|
// echo '<pre>'; print_r($data); echo '</pre>';
|
|
//die;
|
|
$listCount = sizeof($data['name']);
|
|
|
|
foreach ($data['name'] as $data) {
|
|
//echo '<pre>'; print_r($data); echo '</pre>'; exit;
|
|
//$id = $data['id'];
|
|
|
|
|
|
$options1 = '<a class="btn btn-primary" title="' . lang('Generate Bill') .'" href="javascript:void(0);" onclick="billGenerateId('.$data['id'].')" ><i class="la la-edit"></i>' . lang('Generate Bill') .' </a>';
|
|
// $options1 = '<a class="btn btn-primary" title="' . lang('Generate Bill') .'" href="generate_bill/selectForBilling/'. $data['id'] .'" ><i class="la la-edit"></i>' . lang('Generate Bill') .' </a>';
|
|
static $slno = 1;
|
|
|
|
$info[] = array(
|
|
$slno,
|
|
$data['name'],
|
|
$data['billed_count'],
|
|
$data['unBilled_count'],
|
|
$options1
|
|
// // $switch,
|
|
// //$options1 . ' ' . $options2
|
|
);
|
|
$slno++;
|
|
}
|
|
|
|
$csrf_name = $this->security->get_csrf_token_name();
|
|
$csrf_hash = $this->security->get_csrf_hash();
|
|
if ($listCount > 0) {
|
|
$output = array(
|
|
"draw" => intval($requestData['draw']),
|
|
"recordsTotal" => count($this->Generate_bill_model->name_list()),
|
|
"recordsFiltered" => count($this->Generate_bill_model->name_list()),
|
|
"data" => $info
|
|
);
|
|
}
|
|
else {
|
|
$output = array(
|
|
// "draw" => 1,
|
|
"recordsTotal" => 0,
|
|
"recordsFiltered" => 0,
|
|
"data" => []
|
|
);
|
|
$output[$csrf_name] = $csrf_hash;
|
|
}
|
|
|
|
|
|
echo json_encode($output);
|
|
}
|
|
function selectForBilling(){
|
|
|
|
$data = array();
|
|
$id = $this->input->post('id');
|
|
|
|
if($id){
|
|
$data['caregiver'] = $this->Generate_bill_model->caregiverInfo($id);
|
|
// echo '<pre>'; print_r($data); echo '</pre>';die;
|
|
}
|
|
$data['tab']=2;
|
|
// echo '<pre>'; print_r($data); echo '</pre>';die;
|
|
$data['view_link'] =$this->load->view('caregiverDetails',$data,TRUE);
|
|
// echo '<pre>'; print_r($data); echo '</pre>';die;
|
|
//$data['html_view'] = $this->load->view($data['view_link'],'',TRUE);
|
|
echo json_encode($data);
|
|
|
|
}
|
|
function createBill(){
|
|
|
|
$data = array();
|
|
$id = $_POST['id'];
|
|
//print_r($id);exit;
|
|
$data['tab']=3;
|
|
$data['bill_units']=count($id);
|
|
$this->load->model('Generate_bill_model');
|
|
$data['payerTypes'] = $this->Generate_bill_model->getPayerType();
|
|
//echo '<pre>'; print_r($data); echo '</pre>'; die;
|
|
if($id){
|
|
$data['patient'] = $this->Generate_bill_model->getPatientInformation($id);
|
|
}
|
|
//echo '<pre>'; print_r($data); echo '</pre>'; die;
|
|
$data['view_link'] =$this->load->view('billDetails',$data,TRUE);
|
|
echo json_encode($data);
|
|
|
|
}
|
|
function storeBill(){
|
|
$post = $this->input->post();
|
|
// echo '<pre>'; print_r($post); echo '</pre>'; die;
|
|
$patient = $this->Generate_bill_model->getPatient($post['patient_id']);
|
|
//echo '<pre>'; print_r($patient); echo '</pre>'; die;
|
|
$this->load->model('Generate_bill_model');
|
|
$this->Generate_bill_model->saveBill($post);
|
|
if($patient->patient_email){
|
|
$name=$patient->first_name." ".$patient->last_name;
|
|
$from = array(
|
|
'name' => 'HMS Admin',
|
|
'email' => 'admin@hms.com'
|
|
);
|
|
$subject ='Bill has been generated';
|
|
$emaildata['emaildata'] = array(
|
|
'name' =>$name
|
|
);
|
|
$to = $patient->patient_email;
|
|
$message= $this->load->view('email_template_management/bill',$emaildata,TRUE);
|
|
send_email($from,$to,$subject,$message);
|
|
}
|
|
$this->session->set_flashdata('feedback', 'Inserted');
|
|
|
|
redirect('bills');
|
|
|
|
}
|
|
|
|
}
|