%PDF- <> %âãÏÓ endobj 2 0 obj <> endobj 3 0 obj <>/ExtGState<>/ProcSet[/PDF/Text/ImageB/ImageC/ImageI] >>/Annots[ 28 0 R 29 0 R] /MediaBox[ 0 0 595.5 842.25] /Contents 4 0 R/Group<>/Tabs/S>> endobj ºaâÚÎΞ-ÌE1ÍØÄ÷{òò2ÿ ÛÖ^ÔÀá TÎ{¦?§®¥kuµùÕ5sLOšuY>endobj 2 0 obj<>endobj 2 0 obj<>endobj 2 0 obj<>endobj 2 0 obj<> endobj 2 0 obj<>endobj 2 0 obj<>es 3 0 R>> endobj 2 0 obj<> ox[ 0.000000 0.000000 609.600000 935.600000]/Fi endobj 3 0 obj<> endobj 7 1 obj<>/ProcSet[/PDF/Text/ImageB/ImageC/ImageI]>>/Subtype/Form>> stream
<?php defined('BASEPATH') OR exit('No direct script access allowed'); Class Booking extends CI_Controller { function __construct(){ parent::__construct(); $this->load->model(array('Home_Model')); $userData = $this->session->userdata('user_data'); //print_r($userData); //print_r($_POST['oid']); die; if($userData->id==''){ $odr = $_POST['oid']>0 ? $_POST['oid'] : $_POST['ORDERID']; $validate = $this->Home_Model->getSingleRecord('tbl_user_registration', '*', array('conf_order_id'=>$odr)); $details = $this->Home_Model->getSingleObjRecord('sh_registrations_otp', '*', array('id'=>$validate['user_id'])); $this->load->library('session'); $this->session->set_userdata('user_data',$details); $userData = $this->session->userdata('user_data'); } } /* * Function : index * * */ public function index() { $data = array(); $header = array(); $userData = $this->session->userdata('user_data'); $data['userInfo'] = $userData; //$data['userData'] = $this->Home_Model->getAllRecords('tbl_user_registration', '*', array('user_id'=>$userData->id)); $header['title'] = 'Confirm Your Details - COVID19 Vaccination Online Portal'; $this->load->view('_parts/header', $header); $this->load->view('payment-confirmation',$data); $this->load->view('_parts/footer'); } /* * Function : corporatebooking * * */ public function corporatebooking($id='') { $data = array(); $header = array(); $userData = $this->session->userdata('user_data'); $data['userInfo'] = $userData; $data['userData'] = $this->Home_Model->getSingleRecord('tbl_user_registration', '*', array('user_id'=>$userData->id)); $data['testArray'] = $this->Home_Model->getAllRecords('tbl_test_master', '*', array('status'=>'1')); $data['slotArray'] = $this->Home_Model->getAllRecords('tbl_slot_master', '*', array('status'=>'1')); // Get Total Company Employee count $data['totalEmployee'] = $this->Home_Model->getAllRecords('tbl_user_registration', '*', array('user_id'=>$userData->id, 'vaccination_status'=>'1')); $header['title'] = 'Confirm Your Details - COVID19 Vaccination Online Portal'; $this->load->view('_parts/header', $header); $this->load->view('corporate-payment',$data); $this->load->view('_parts/footer'); } /* * Function : confirmation * * */ public function confirmation($id='') { $data = array(); $header = array(); $record_num = end($this->uri->segment_array()); $uid = base64_decode($record_num); $userData = $this->session->userdata('user_data'); $data['userInfo'] = $userData; if($uid==''){ redirect('dashboard'); } $data['userData'] = $this->Home_Model->getSingleRecord('tbl_user_registration', '*', array('id'=>$uid)); $data['bookingData'] = $bookingData = $this->Home_Model->getSingleRecord('tbl_booking_confirmation', '*', array('user_id'=>$uid,'status'=>'1')); $data['testData'] = $this->Home_Model->getSingleRecord('tbl_test_master', '*', array('id'=>$bookingData['test_id'])); // Get Test List $data['testArray'] = $this->Home_Model->getAllRecords('tbl_test_master', '*', array('status'=>'1')); $data['slotArray'] = $this->Home_Model->getAllRecords('tbl_slot_master', '*', array('status'=>'1')); $header['title'] = 'Confirm & Pay Now - COVID19 Vaccination'; $this->load->view('_parts/header', $header); $this->load->view('booking-confirmation',$data); $this->load->view('_parts/footer'); } /* * Function : validatecorporatebooking */ public function validatecorporatebooking() { $data = array(); $header = array(); if($_POST){ $this->form_validation->set_rules('test_name','Test Name','required'); $this->form_validation->set_rules('test_slot','Slot Name','required'); $this->form_validation->set_rules('total_employee','Total Employee','required'); $this->form_validation->set_rules('slot_date','Slot Date','required'); //$this->form_validation->set_rules('payment_method','Payment Method','required'); if($this->form_validation->run()) { $test_name = $this->input->post('test_name'); $test_slot = $this->input->post('test_slot'); $slot_date = $this->input->post('slot_date'); $total_employee = $this->input->post('total_employee'); $uid = $this->input->post('uid'); $bid = $this->input->post('bid'); //Upload Certificate $current_date = strtotime($curDate); if($current_date>=strtotime($slot_date)){ $this->session->set_flashdata('error', 'Slot date should be greater than current date.'); redirect('booking/corporatebooking'); } // Get Booking slot & date available or not $bookingConf = $this->Home_Model->getSingleRecord('tbl_booking_confirmation', 'id', array('status<>'=>'4', 'slot_id'=>$test_slot,'slot_date'=>strtotime($slot_date),'status>'=>'3')); $time = substr(time(), 6,4); $order_digit = $this->generateRandomNumber(4); $order_id = $order_digit.date('dmY').$time; $data=array( 'order_id'=>$order_id, 'user_id'=>$uid, 'test_id'=>$test_name, 'slot_id'=>$test_slot, 'slot_date'=>strtotime($slot_date), 'total_employee'=>$total_employee, 'is_deleted'=>'0' ); //print_r($data); die; //if(empty($bookingConf)) { //print_r($data); die; if($_POST['bid']>0) { $data['modifiedon'] = date('y-m-d H:i:s'); $response = $this->Home_Model->updateinfo($tbl_name='tbl_booking_confirmation',$data,'id',$bid); redirect('booking/paynow/'.base64_encode($bid)); } else { //$record = $this->Home_Model->getAllRecords($tbl_name='tbl_booking_confirmation', '*', array('test_id'=>$test_name,'user_id'=>$uid,'status<='=>'3')); $record = ''; if(empty($record)){ $data['createdon'] = date('y-m-d H:i:s'); $response = $this->Home_Model->saveinfo($tbl_name='tbl_booking_confirmation',$data); redirect('booking/corporatepaynow/'.base64_encode($response)); } else { redirect('booking/corporatebooking/'.base64_encode($uid).'?msg=failed'); } } /*} else { $data['msg'] = 'This Slot & Date is not available. Please select another slot.'; $this->load->view('_parts/header'); $this->load->view('payment-confirmation',$data); $this->load->view('_parts/footer'); }*/ } else { redirect('booking/corporatebooking/'.base64_encode($uid).'?msg=failed'); } } else { $this->load->view('_parts/header'); $this->load->view('corporatebooking',$data); $this->load->view('_parts/footer'); } } /* * Function : validatebooking */ public function validatebooking() { $data = array(); $header = array(); if($_POST){ $this->form_validation->set_rules('test_name','Test Name','required'); $this->form_validation->set_rules('test_slot','Slot Name','required'); $this->form_validation->set_rules('slot_date','Slot Date','required'); //$this->form_validation->set_rules('payment_method','Payment Method','required'); if($this->form_validation->run()) { $does_type = $this->input->post('does_type'); $test_name = $this->input->post('test_name'); $test_slot = $this->input->post('test_slot'); $slot_date = $this->input->post('slot_date'); $address = $this->input->post('address'); $pincode = $this->input->post('pincode'); $uid = $this->input->post('uid'); $bid = $this->input->post('bid'); //Upload Certificate $dose_certificate = $this->uploadDocuments(); $does_date = date('Y-m-d',strtotime($this->input->post('does_date'))); $current_date = strtotime(date('Y-m-d')); if($current_date>strtotime($slot_date)){ $this->session->set_flashdata('error', 'Slot date should be greater than current date.'); redirect('booking/confirmation/'.base64_encode($uid)); } // Get Booking slot & date available or not $bookingConf = $this->Home_Model->getSingleRecord('tbl_booking_confirmation', 'id', array('status<>'=>'4', 'slot_id'=>$test_slot,'slot_date'=>strtotime($slot_date),'status>'=>'3')); $time = substr(time(), 6,4); $order_digit = $this->generateRandomNumber(4); $order_id = date('Ymd').$order_digit.$time; $data=array( 'order_id'=>$order_id, 'does_type'=>$does_type, 'does_date'=>$does_date, 'dose_certificate'=>$dose_certificate, 'user_id'=>$uid, 'test_id'=>$test_name, 'slot_id'=>$test_slot, 'slot_date'=>strtotime($slot_date), 'address'=>$address, 'pincode'=>$pincode, 'is_deleted'=>'0' ); //print_r($data); die; //if(empty($bookingConf)) { //print_r($data); die; if($_POST['bid']>0) { $data['modifiedon'] = date('y-m-d H:i:s'); $response = $this->Home_Model->updateinfo($tbl_name='tbl_booking_confirmation',$data,'id',$bid); redirect('booking/paynow/'.base64_encode($bid)); } else { //$record = $this->Home_Model->getAllRecords($tbl_name='tbl_booking_confirmation', '*', array('test_id'=>$test_name,'user_id'=>$uid,'status<='=>'3')); $record = ''; if(empty($record)){ $data['createdon'] = date('y-m-d H:i:s'); $response = $this->Home_Model->saveinfo($tbl_name='tbl_booking_confirmation',$data); redirect('booking/paynow/'.base64_encode($response)); } else { redirect('booking/payment-confirmation/'.base64_encode($uid).'?msg=failed'); } } /*} else { $data['msg'] = 'This Slot & Date is not available. Please select another slot.'; $this->load->view('_parts/header'); $this->load->view('payment-confirmation',$data); $this->load->view('_parts/footer'); }*/ } else { redirect('booking/payment-confirmation/'.base64_encode($uid).'?msg=failed'); } } else { $this->load->view('_parts/header'); $this->load->view('payment-confirmation',$data); $this->load->view('_parts/footer'); } } /* * Function : uploadDocuments * Description : Upload the user Documents */ private function uploadDocuments() { $config['upload_path'] = './attachments/documents/'; $config['allowed_types'] = 'gif|jpg|png|jpeg|JPG|PNG|JPEG|PDF|pdf|SVG|svg|avi|mp4|3gp|mpeg|mpg|mov|mp3|flv|wmv'; $this->load->library('upload', $config); $this->upload->initialize($config); if (!$this->upload->do_upload('photo_proof')) { log_message('error', 'Image Upload Error: ' . $this->upload->display_errors()); } $img = $this->upload->data(); return $img['file_name']; } public function getpricedetails() { $test_id = $this->input->post('test_id'); $yourTest = ''; if($test_id>0){ $testDetails = $this->Home_Model->getSingleRecord('tbl_test_master', '*', array('id'=>$test_id)); $yourTest = $testDetails['title'].' - Rs. '.$testDetails['price']; } header('Content-type: application/json'); echo json_encode($yourTest); exit; } /* * Function : corporatepaynow * */ public function corporatepaynow() { $data = array(); $record_num = end($this->uri->segment_array()); $booking_id = base64_decode($record_num); $userData = $this->session->userdata('user_data'); $data['userInfo'] = $userData; if($booking_id==''){ redirect('dashboard'); } $data['userData'] = $userData = $this->Home_Model->getAllbookingRecords($booking_id); $order_id = $userData['order_id']; $resp = $this->Home_Model->getSingleRecord('tbl_order_master', '*', array('order_id'=>$order_id,'status'=>'1')); if($resp) { redirect('order/'.base64_encode($order_id)); } $data['testData'] = $this->Home_Model->getSingleRecord('tbl_test_master', '*', array('id'=>$userData['test_id'],'status'=>'1')); $data['slotData'] = $this->Home_Model->getSingleRecord('tbl_slot_master', '*', array('id'=>$userData['slot_id'],'status'=>'1')); $data['orderData'] = $this->Home_Model->getSingleRecord('tbl_booking_confirmation', '*', array('order_id'=>$order_id)); // Get Vaccine List $header['title'] = 'Pay Now - COVID19 Vaccination Online Portal'; $this->load->view('_parts/header', $header); $this->load->view('company-paynow',$data); $this->load->view('_parts/footer'); } /* * Function : paynow * */ public function paynow() { $data = array(); $record_num = end($this->uri->segment_array()); $booking_id = base64_decode($record_num); $userData = $this->session->userdata('user_data'); $data['userInfo'] = $userData; if($booking_id==''){ redirect('dashboard'); } $data['userData'] = $userData = $this->Home_Model->getAllbookingRecords($booking_id); $order_id = $userData['order_id']; $resp = $this->Home_Model->getSingleRecord('tbl_order_master', '*', array('order_id'=>$order_id,'status'=>'1')); if($resp) { redirect('order/'.base64_encode($order_id)); } $data['testData'] = $this->Home_Model->getSingleRecord('tbl_test_master', '*', array('id'=>$userData['test_id'],'status'=>'1')); $data['slotData'] = $this->Home_Model->getSingleRecord('tbl_slot_master', '*', array('id'=>$userData['slot_id'],'status'=>'1')); $data['orderData'] = $this->Home_Model->getSingleRecord('tbl_booking_confirmation', '*', array('order_id'=>$order_id)); // Get Vaccine List $header['title'] = 'Pay Now - COVID19 Vaccination Online Portal'; $this->load->view('_parts/header', $header); $this->load->view('booking-paynow',$data); $this->load->view('_parts/footer'); } /* * Function : generateRandomNumber */ function generateRandomNumber($length = 5) { $number = '1234567890'; $numberLength = strlen($number); $randomNumber = ''; for ($i = 0; $i < $length; $i++) { $randomNumber .= $number[rand(0, $numberLength - 1)]; } return $randomNumber; } /* * Function : confirmcompanypaynow */ public function confirmcompanypaynow() { $payment_method = $this->input->post('payment_method'); if($payment_method=='COD') { $this->codpayment($_POST); } else { $this->onlinecompanypayment($_POST); } } /* * Function : confirmpaynow */ public function confirmpaynow() { $payment_method = $this->input->post('payment_method'); if($payment_method=='COD') { $this->codpayment($_POST); } else { $this->Onlinepayment($_POST); } } /* * Function : codpayment */ public function codpayment($post) { $userData = $this->session->userdata('user_data'); $booking_id = $post['bid']; // Get User Details $userData = $this->Home_Model->getAllbookingRecords($booking_id); $data = array(); $data['order_id'] = $userData['order_id']; $data['booking_confirmation_id'] = $userData['bid']; $data['transaction_id'] = 'COD'; $data['reg_id'] = $userData['id']; $data['user_id'] = $userData['user_id']; $data['slot_id'] = $userData['slot_id']; $data['status'] = '3'; $data['test_id'] = $userData['test_id']; $data['token_number'] = date('Ymd',strtotime($userData['slot_date'])).'03'.$userData['slot_id'].$userData['test_id']; $data['ip_address'] = get_client_ip(); $data['payment_method'] = $post['payment_method']; $data['test_details'] = serialize(array('test_name'=>$userData['title'], 'test_id'=>$userData['test_id'], 'test_price'=>$userData['price'])); // Save data in order master $this->Home_Model->saveinfo('tbl_order_master', $data); // Change Test Table Status $orderStatus = array(); $orderStatus['status'] = '4'; $this->Home_Model->updateinfo('tbl_booking_confirmation', $orderStatus ,'id',$userData['bid']); // Change booking Confirmation table status $regStatus = array(); $regStatus['status'] = '4'; $this->Home_Model->updateinfo('tbl_user_registration', $regStatus ,'id',$userData['id']); // Send Confirmation SMS to registered Mobile Number $mobile_number = '8920976831';// $userData['contact_number']; $full_name = $userData['full_name']; $sms_content = 'Dear '.$full_name.', here is your personal COVID19 Vaccination booking order id '.$userData['order_id'].'. You can share this Order id with the time of hospital visit.'; if($mobile_number!='') { //send_sms($mobile_number,$sms_content); } redirect('order/'.base64_encode($userData['order_id'])); } /* * Function : onlinecompanypayment */ public function onlinecompanypayment($post) { $userData = $this->session->userdata('user_data'); $booking_id = $post['bid']; // Get User Details $userData = $this->Home_Model->getAllbookingRecords($booking_id); $post['billing_name'] = $userData['full_name']; $post['billing_address'] = $userData['address']; $post['billing_city'] = ''; $post['billing_state']= ''; $post['billing_zip']= $userData['pincode']; $post['billing_country']= 'India'; $post['billing_tel']= $userData['contact_number']; $post['billing_email']= $userData['email_id']; $post['merchant_param4'] = $post['merchant_param4'].' - '.$post['merchant_param2']; $post['merchant_param2'] = $userData['contact_number']; $post['merchant_param3'] = $userData['email_id']; $post['merchant_param5'] = $post['order_id']; $success = $this->Home_Model->updateinfo('tbl_booking_confirmation',array('status'=>'2','modifiedon'=>date('Y-m-d H:i:s')),'order_id',$post['order_id']); //print_r($post); die; if($success){ $data['post'] = $post; $this->load->view('icici/icicimpcompanyRequestHandler',$data); die; } else{ echo '<script>alert("Unable to submit your request. Kindly try again later.");</script>'; } exit(); } /* * Function : generate_random */ function generate_random(){ return rand(111111, 999999); //return '232524'; } /* * Function : onlinepayment */ public function onlinepayment($post) { $userData = $this->session->userdata('user_data'); $booking_id = $post['bid']; // Get User Details $userData = $this->Home_Model->getAllbookingRecords($booking_id); $customer_id = count($userData).''.$this->generate_random(); $post['billing_name'] = $userData['full_name']; $post['billing_address'] = $userData['address']; $post['billing_city'] = ''; $post['billing_state']= ''; $post['billing_zip']= $userData['pincode']; $post['billing_country']= 'India'; $post['billing_tel']= $userData['contact_number']; $post['billing_email']= $userData['email_id']; $post['merchant_param4'] = $post['merchant_param4'].' - '.$post['merchant_param2']; $post['merchant_param2'] = $userData['contact_number']; $post['merchant_param3'] = $userData['email_id']; $post['merchant_param5'] = $post['order_id']; $post['customer_id'] = $customer_id; $success = $this->Home_Model->updateinfo('tbl_booking_confirmation',array('status'=>'2','modifiedon'=>date('Y-m-d H:i:s')),'order_id',$post['order_id']); //print_r($post); die; if($success){ $data['post'] = $post; if($post['payment_method']=='paytm'){ $TXN_AMOUNT = $post['amount']; $this->goToPayTm($post['order_id'], $customer_id, $TXN_AMOUNT); } else { $this->load->view('icici/icicimpRequestHandler',$data); } die; } else{ echo '<script>alert("Unable to submit your request. Kindly try again later.");</script>'; } exit(); } /* * Function : handle_response * */ public function handle_response(){ $data = array(); $header = array(); date_default_timezone_set('Asia/Kolkata'); $currentTime = date( 'd-m-Y h:i:s A', time()); // Save Payment Transaction details $order_status=''; $bank_ref_num=''; $tracking_num=''; $order_id=''; $order_id = $_POST['oid']; $response = array(); $order_status = $_POST['status']; $data['order_status']=$order_status; $status = ''; if(($order_status=='APPROVED')) { $status = '4'; } else if(($order_status=='DECLINED')) { $status = '5'; } else if(($response['order_status']=='Failure' || $order_status=='FAILED')){ $status = '6'; } else { $status = '3'; } $header['title'] = "Payment $order_status | Covid-19 Vaccination"; $update_data = array(); $update_data = array( 'order_status'=> $order_status, 'amount'=> $_POST['chargetotal'], 'order_date'=> $_POST['txndatetime'], 'status'=> $status, 'bank_ref_number' => $_POST['endpointTransactionId'], 'payment_tracking_number' => $_POST['ipgTransactionId'], 'modifiedon' => date('Y-m-d H:i:s'), 'payment_failure_msg' => $_POST['fail_reason'] ); //print_r($_POST); //die; $success = $this->Home_Model->updateinfo('tbl_booking_confirmation',$update_data,'order_id',$order_id); $insertArray = array(); // Save Payment Transaction Details $insertArray = array( 'order_id'=>$order_id, 'txndate_processed'=>$_POST['txndate_processed'], 'timezone'=>$_POST['timezone'], 'ccbin'=>$_POST['ccbin'], 'response_key'=>$_POST['response_hash'], 'transaction_id'=>$_POST['ipgTransactionId'], 'bank_ref_no'=>$_POST['endpointTransactionId'], 'order_status'=>$_POST['status'], 'failure_message'=>$_POST['fail_reason'], 'payment_method'=>$_POST['paymentMethod'], 'card_name'=>$_POST['cardnumber'], 'transaction_status'=>$_POST['status'], 'status_message'=>$_POST['status_message'], 'currency'=>$_POST['currency'], 'hash_algorithm'=>$_POST['hash_algorithm'], 'expmonth'=>$_POST['expmonth'], 'processor_response_code'=>$_POST['processor_response_code'], 'transaction_amount'=>$_POST['chargetotal'], 'merchant_param1'=> $_POST['txndatetime'], 'txntype'=>$_POST['txntype'], 'ccbrand'=>$_POST['ccbrand'], 'bname'=>$_POST['bname'], 'installments_interest'=>$_POST['installments_interest'], 'response_code_3dsecure'=>$_POST['response_code_3dsecure'], 'approval_code'=>$_POST['approval_code'], 'terminal_id'=>$_POST['terminal_id'], 'expyear'=>$_POST['expyear'], 'transaction_date'=>$_POST['txndatetime'], 'scheme_transaction_id'=>$_POST['schemeTransactionId'], 'ip_address'=>$this->get_client_ip(), 'response_code'=>$_POST['fail_rc'], 'tdate'=>$_POST['tdate'], 'bin_country'=>$_POST['cccountry'] ); $query = $this->Home_Model->getSingleRecord('tbl_booking_confirmation', '*', array('order_id'=>$order_id)); $data['response'] = $query; $userData = $this->Home_Model->getSingleRecord('tbl_user_registration', '*', array('id'=>$query['user_id'])); $data['userData'] = $userData; //print_r($query); die; $data['response']['billing_name'] = $query['full_name']; $data['response']['billing_tel'] = $query['contact_number']; $data['response']['billing_email'] = $query['email_id']; $data['response']['billing_address'] = $query['address']; $data['response']['billing_city'] = ''; $data['response']['billing_state'] = ''; $data['response']['billing_zip'] = $query['pincode']; $data['response']['billing_country'] = 'India'; $data['response']['order_id'] = $order_id; $data['response']['merchant_param4'] = $query['order_status']; $data['response']['bank_ref_no'] = $query['bank_ref_number']; $data['response']['currency'] = 'INR'; $data['response']['amount'] = $query['amount']; $data['response']['trans_date'] = $query['order_date']; $data['response']['PaymentFailureMsg'] = $query['payment_failure_msg']; $results = array(); $results = $this->Home_Model->getSingleRecord('tbl_payment_transactions','*',array('order_id'=>$order_id)); $data['results'] = $results; if(empty($results['order_id'])) { $this->Home_Model->saveinfo('tbl_payment_transactions', $insertArray); $data['results'] = $insertArray; // Save Order dta $this->saveOrderStatus($data); /***************/ $update_data_row = array(); $update_data_row['conf_order_id'] = $order_id; if(($order_status=='APPROVED')) { $update_data_row['vaccination_status'] = '2'; $update_data_row['status'] = '4'; $update_data_row['order_status'] = $order_status; // Send Confirmation Email after payment Approval $this->sendUserEmail($userData,$_POST,$query); } /******** new code****/ else if(($order_status=='DECLINED')) { $update_data_row['vaccination_status'] = '1'; $update_data_row['status'] = '3'; $update_data_row['order_status'] = $order_status; } /**************** END *********/ else if(($response['order_status']=='Failure')){ $update_data_row['vaccination_status'] = '1'; $update_data_row['status'] = '3'; $update_data_row['order_status'] = $order_status; } else { $update_data_row['vaccination_status'] = '1'; $update_data_row['status'] = '3'; $update_data_row['order_status'] = $order_status; } $this->Home_Model->updatePaymentinfo('tbl_user_registration',$update_data_row,array('user_id'=>$userData['user_id'],'id'=>$userData['id'])); // Set Session Data //$details = $this->Home_Model->getSingleObjRecord('sh_registrations_otp', '*', array('id'=>$userData['user_id'])); //$this->session->set_userdata('user_data',$details); } $this->load->view('_parts/header',$header); $this->load->view('icici/icicimpResponseHandler',$data); $this->load->view('_parts/footer'); } /* * Function : codpayment */ public function saveOrderStatus($post) { $data = array(); $header = array(); $userData = $post['response']; $userRegData = $post['userData']; $usersavedData = $this->session->userdata('user_data'); // Get Test Details tbl_booking_confirmation $testDetails = getTestDetails($userData['test_id']); // Get Booking Confirmation ID $orbookingData = $this->Home_Model->getSingleRecord('tbl_booking_confirmation', '*', array('order_id'=>$userData['order_id'])); $data['order_id'] = $userData['order_id']; $data['booking_confirmation_id'] = $orbookingData['id']; //$userData['bid']; $data['transaction_id'] = $userData['payment_tracking_number']; $data['reg_id'] = $userRegData['id']; $data['user_id'] = $userData['user_id']; $data['slot_id'] = $userData['slot_id']; $data['status'] = $userData['status']; $data['test_id'] = $userData['test_id']; $data['token_number'] = date('Ymd',strtotime($userData['slot_date'])).'03'.$userData['slot_id'].$userData['test_id']; $data['ip_address'] = get_client_ip(); $data['payment_method'] = $userData['payment_method']; $data['test_details'] = serialize(array('test_name'=>$testDetails[0]->title, 'test_id'=>$userData->test_id, 'test_price'=>$testDetails[0]->price)); // Save data in order master $this->Home_Model->saveinfo('tbl_order_master', $data); // Send Confirmation SMS to registered Mobile Number $mobile_number = '8920976831';// $userData['contact_number']; $full_name = $userData['full_name']; $sms_content = 'Dear '.$full_name.', here is your personal COVID19 Vaccination booking order id '.$userData['order_id'].'. You can share this Order id with the time of hospital visit.'; if($mobile_number!='') { //send_sms($mobile_number,$sms_content); } return true; } /* * Get Client IP Address */ function get_client_ip() { $ipaddress = ''; if (isset($_SERVER['HTTP_CLIENT_IP'])) $ipaddress = $_SERVER['HTTP_CLIENT_IP']; else if(isset($_SERVER['HTTP_X_FORWARDED_FOR'])) $ipaddress = $_SERVER['HTTP_X_FORWARDED_FOR']; else if(isset($_SERVER['HTTP_X_FORWARDED'])) $ipaddress = $_SERVER['HTTP_X_FORWARDED']; else if(isset($_SERVER['HTTP_FORWARDED_FOR'])) $ipaddress = $_SERVER['HTTP_FORWARDED_FOR']; else if(isset($_SERVER['HTTP_FORWARDED'])) $ipaddress = $_SERVER['HTTP_FORWARDED']; else if(isset($_SERVER['REMOTE_ADDR'])) $ipaddress = $_SERVER['REMOTE_ADDR']; else $ipaddress = 'UNKNOWN'; return $ipaddress; } /* * Function : alreadypay * */ public function alreadypay() { $data = array(); $header = array(); $header['title'] = 'Upload Corporate Payment Details'; $usersavedData = $this->session->userdata('user_data'); $profile_data = $this->session->userdata('profile_data'); if($_POST){ $this->form_validation->set_rules('transaction_id','Transaction Number','required'); if($this->form_validation->run()) { $transaction_id = $this->input->post('transaction_id'); $photo_proof = $this->uploadDocuments(); $time = substr(time(), 6,4); $order_digit = $this->generateRandomNumber(4); $order_id = date('Ymd').$order_digit.$time; $params = array(); $params['order_id'] = $order_id; $params['transaction_id'] = $transaction_id; $params['user_id'] = $profile_data['id']; $params['status'] = '4'; $params['ip_address'] = get_client_ip(); $params['payment_method'] = 'Online'; // Save data in order master $resp = $this->Home_Model->saveinfo('tbl_order_master', $params); if($resp){ $this->session->set_flashdata('success', 'Corporate payment details updated successfully.'); redirect('companydashboard'); } } } $this->load->view('_parts/header',$header); $this->load->view('alreadypay',$data); $this->load->view('_parts/footer'); } /* * Function : Paytm Payment * */ public function goToPayTm($ORDER_ID, $CUST_ID, $TXN_AMOUNT) { header("Pragma: no-cache"); header("Cache-Control: no-cache"); header("Expires: 0"); // following files need to be included $checkSum = ""; $paramList = array(); //$TXN_AMOUNT = '1.0'; // Create an array having all required parameters for creating checksum. $paramList["MID"] = PAYTM_MERCHANT_MID; $paramList["ORDER_ID"] = $ORDER_ID; $paramList["CUST_ID"] = $CUST_ID; $paramList["INDUSTRY_TYPE_ID"] = PAYTM_INDUSTRY; $paramList["CHANNEL_ID"] = PAYTM_CHANNEL_ID; $paramList["TXN_AMOUNT"] = trim($TXN_AMOUNT); $paramList["WEBSITE"] = PAYTM_MERCHANT_WEBSITE; $paramList["CALLBACK_URL"] = base_url()."booking/paymentconfirmation?resp=".base64_encode($ORDER_ID); //print_r($paramList);die; //Here checksum string will return by getChecksumFromArray() function. $checkSum = $this->getChecksumFromArray($paramList,PAYTM_MERCHANT_KEY); echo "<html> <head> <title>Merchant Check Out Page</title> </head> <body> <center><h1>Please do not refresh this page...</h1></center> <form method='post' action='".PAYTM_TXN_URL."' name='f1'> <table border='1'> <tbody>"; foreach($paramList as $name => $value) { echo '<input type="hidden" name="' . $name .'" value="' . $value . '">'; } echo "<input type='hidden' name='CHECKSUMHASH' value='". $checkSum . "'> </tbody> </table> <script type='text/javascript'> document.f1.submit(); </script> </body> </html>"; exit(); //return $checkSum; } /* Checksum Functions Starts*/ private function getChecksumFromArray($arrayList, $key, $sort=1) { if ($sort != 0) { ksort($arrayList); } $str = $this->getArray2Str($arrayList); $salt = $this->generateSalt_e(4); $finalString = $str . "|" . $salt; $hash = hash("sha256", $finalString); $hashString = $hash . $salt; $checksum = $this->encrypt_e($hashString, $key); return $checksum; } function getArray2Str($arrayList) { $findme = 'REFUND'; $findmepipe = '|'; $paramStr = ""; $flag = 1; foreach ($arrayList as $key => $value) { $pos = strpos($value, $findme); $pospipe = strpos($value, $findmepipe); if ($pos !== false || $pospipe !== false) { continue; } if ($flag) { $paramStr .= $this->checkString_e($value); $flag = 0; } else { $paramStr .= "|" . $this->checkString_e($value); } } return $paramStr; } function checkString_e($value) { if ($value == 'null') $value = ''; return $value; } function generateSalt_e($length) { $random = ""; srand((double) microtime() * 1000000); $data = "AbcDE123IJKLMN67QRSTUVWXYZ"; $data .= "aBCdefghijklmn123opq45rs67tuv89wxyz"; $data .= "0FGH45OP89"; for ($i = 0; $i < $length; $i++) { $random .= substr($data, (rand() % (strlen($data))), 1); } return $random; } function encrypt_e($input, $ky) { $key = html_entity_decode($ky); $iv = "@@@@&&&&####$$$$"; $data = openssl_encrypt ( $input , "AES-128-CBC" , $key, 0, $iv ); return $data; } /* * Function : Paymentconfirmation * * */ public function Paymentconfirmation() { $data = $this->input->post(); // Get User Details $getRecord = $this->Home_Model->getSingleRecord('tbl_payment_transactions', '*', array('transaction_id'=>$data['TXNID'])); $order_id = base64_decode($_GET['resp']); $userData = $this->session->userdata('user_data'); //print_r($userData); die; if(empty($getRecord)) { $order_status = $data['STATUS']; if(($order_status=='TXN_SUCCESS')) { $status = '4'; } else { $status = '3'; } $TXNDATE = date('Y-m-d H:i:s'); $order_id = $data['ORDERID']; $update_data = array(); $update_data = array( 'order_status'=> $order_status, 'amount'=> $data['TXNAMOUNT'], 'order_date'=> $TXNDATE, 'status'=> $status, 'bank_ref_number' => $data['MID'], 'payment_tracking_number' => $data['BANKTXNID'], 'modifiedon' => date('Y-m-d H:i:s'), 'payment_failure_msg' => $data['RESPMSG'] ); //print_r($update_data); //die; $success = $this->Home_Model->updateinfo('tbl_booking_confirmation',$update_data,'order_id',$order_id); // Get booking Details $bookingRecord = $this->Home_Model->getSingleRecord('tbl_booking_confirmation', '*', array('order_id'=>$order_id)); $user_id = $bookingRecord['user_id']; // Add records to transaction table $params = array('order_id'=>$order_id, 'bank_ref_no'=>$data['MID'], 'transaction_id'=>$data['TXNID'], 'transaction_amount'=>$data['TXNAMOUNT'], 'payment_mode'=> 'Online/Paytm', 'currency'=>$data['CURRENCY'], 'transaction_date'=>$TXNDATE, 'transaction_status'=>$data['STATUS'], 'response_code'=>$data['RESPCODE'], 'response_msg'=>$data['RESPMSG'], 'gateway_name'=>'Paytm', 'bank_transaction_id'=>$data['BANKTXNID'], 'bank_name'=>$data['BANKNAME'], 'checksumhash'=>$data['CHECKSUMHASH'], 'ip_address'=>get_client_ip(), 'status'=>'1', 'is_deleted'=>'0'); $this->Home_Model->saveinfo('tbl_payment_transactions', $params); // Remove It $params['order_id'] = $order_id; // Change leads table status $dataArray = array(); $status = '1'; $order_status = 'Failed'; if($data['STATUS']=='TXN_SUCCESS') { $order_status = 'Approved'; $OPstatus = '4'; } else { $order_status = $data['STATUS']; $OPstatus = '6'; } $userProfile = $this->Home_Model->getSingleRecord('tbl_user_registration', '*', array('id'=>$user_id)); // Save Order details // Get Test Details tbl_booking_confirmation $testDetails = getTestDetails($bookingRecord['test_id']); $oparams = array(); $orbookingData = $this->Home_Model->getSingleRecord('tbl_booking_confirmation', '*', array('order_id'=>$order_id)); $oparams['order_id'] = $order_id; $oparams['booking_confirmation_id'] = $orbookingData['id']; //$userData['bid']; $oparams['transaction_id'] = $data['TXNID']; $oparams['reg_id'] = $userProfile['id']; $oparams['user_id'] = $userProfile['user_id']; $oparams['slot_id'] = $bookingRecord['slot_id']; $oparams['status'] = $OPstatus; $oparams['test_id'] = $bookingRecord['test_id']; $oparams['token_number'] = date('Ymd',strtotime($bookingRecord['slot_date'])).'03'.$bookingRecord['slot_id'].$bookingRecord['test_id']; $oparams['ip_address'] = get_client_ip(); $oparams['payment_method'] = 'Paytm'; $oparams['test_details'] = serialize(array('test_name'=>$testDetails[0]->title, 'test_id'=>$bookingRecord['test_id'], 'test_price'=>$testDetails[0]->price)); // Save data in order master $this->Home_Model->saveinfo('tbl_order_master', $oparams); // if success then send email $update_data_row = array(); $update_data_row['conf_order_id'] = $order_id; if($data['STATUS']=='TXN_SUCCESS'){ $update_data_row['vaccination_status'] = '2'; $update_data_row['status'] = '4'; $update_data_row['order_status'] = $order_status; } else { $update_data_row['vaccination_status'] = '1'; $update_data_row['status'] = '3'; $update_data_row['order_status'] = $order_status; } // Update Status $this->Home_Model->updatePaymentinfo('tbl_user_registration',$update_data_row,array('id'=>$user_id)); } //echo $order_id; $data['bookingData'] = $bookingData = $this->Home_Model->getSingleRecord('tbl_booking_confirmation', '*', array('order_id'=>$order_id)); $data['userData'] = $userData = $this->Home_Model->getSingleRecord('tbl_user_registration', '*', array('conf_order_id'=>$order_id)); $response = $this->Home_Model->getSingleRecord('tbl_payment_transactions', '', array('order_id'=>$order_id,'status'=>'1')); // Create Response Array $nResponseArray = array(); $nResponseArray['order_id'] = $response['order_id']; $nResponseArray['oid'] = $response['order_id']; $nResponseArray['payment_tracking_number'] = $response['transaction_id']; $nResponseArray['amount'] = $response['transaction_amount']; $nResponseArray['chargetotal'] = $response['transaction_amount']; $nResponseArray['trans_date'] = $response['transaction_date']; $nResponseArray['order_status'] = $userData['order_status']; $nResponseArray['test_id'] = $bookingData['test_id']; $nResponseArray['slot_id'] = $bookingData['slot_id']; $nResponseArray['slot_date'] = $bookingData['slot_date']; $nResponseArray['ipgTransactionId'] = $response['transaction_id']; $nResponseArray['endpointTransactionId'] = $response['mid']; $nResponseArray['bank_ref_no'] = $response['bank_ref_no']; $nResponseArray['txndatetime'] = $response['transaction_date']; $nResponseArray['status'] = $response['transaction_status']; $nResponseArray['endpointTransactionId'] = $response['bank_ref_no']; $data['response'] = $nResponseArray; //print_r($data['bookingData']); die; if($userData['email_status']==0) { // Send Confirmation Email after payment Approval $this->sendUserEmail($userData,$nResponseArray,$bookingData); // Chnage Email Status $this->Home_Model->updatePaymentinfo('tbl_user_registration',array('email_status'=>'1'),array('id'=>$userData['id'])); } // Set Session Data $details = $this->Home_Model->getSingleObjRecord('sh_registrations_otp', '*', array('id'=>$userData['user_id'])); $this->session->set_userdata('user_data',$details); $header['title'] = 'Covid 19 Vaccination Payment Confirmation - Sharda Hospital'; $this->load->view('_parts/header',$header); $this->load->view('icici/icicimpResponseHandler',$data); $this->load->view('_parts/footer'); } /* * Function : sendUserEmail * */ public function sendUserEmail($userData,$results,$query) { //Get User Details $full_name = $userData['full_name']; $full_name = trim($full_name); $toemail = $userData['email_id']; $subject = 'Sharda Covid-19 Vaccination Appointment Details'; $message = $this->cowinTemplate($userData,$results,$query); if($toemail<>'') { $this->Home_Model->sendSMTPCommonEmail($toemail, $subject, $message); } return true; } /* * Function : cowinTemplate * */ public function cowinTemplate($userData,$results,$query) { $slotArray = getSlotDetails($query['slot_id']); $testDetails = getTestDetails($query['test_id']); $does = $query['does_type']=='2' ? '2nd Does' : '1st Does'; $template = ''; $template = ' <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <title>Sharda Covid-19 Vaccination Appointment Details - Sharda Hospital</title> </head> <body> <table style="width:600px; margin:0px auto;" cellpadding="0" border="0" cellspacing="0"> <tr> <td colspan="2"> <a href="https://shardahospital.org/cowin"><img src="https://shardahospital.org/cowin/assests/imgs/cowin-banner-sharda.jpg" width="100%" /></a> </td> </tr> <tr> <td colspan="2" style="font-family:Tahoma, Geneva, sans-serif; padding:20px 20px 20px 20px; border-right:1px solid #ccc;border-left:1px solid #ccc;"> <p style="font-size:18px; font-family:Tahoma, Geneva, sans-serif; color:#444;">Dear '.$userData["full_name"].',</p> <p style="font-size:14px; font-family:Tahoma, Geneva, sans-serif; color:#444;padding-top:20px;">Sharda Covid-19 vaccination appointment details as follows...</p> <br/> <p style="font-size:16px; font-family:Tahoma, Geneva, sans-serif; color:#444;padding-top:5px;">Transaction Detail</p> <table border="1" bordercolor="#ddd" cellpadding="10" cellspacing="0" id="emailContainer" style="font-size:12px; width:100%;"> <tr> <th align="left" style="color:#222; background:#FAFAFA;">Transaction ID</th> <td align="left" valign="top">'.$results["ipgTransactionId"].'</td> </tr> <tr> <th align="left" style="color:#222; background:#FAFAFA;">Token No.</th> <td align="left" valign="top">'.$results["oid"].'</td> </tr> <tr> <th align="left" style="color:#222; background:#FAFAFA;">Transaction Date</th> <td align="left" valign="top">'.$results["txndatetime"].'</td> </tr> <tr> <th align="left" style="color:#222; background:#FAFAFA;">Bank Reference Number</th> <td align="left" valign="top">'.$results["endpointTransactionId"].'</td> </tr> <tr> <th align="left" style="color:#222; background:#FAFAFA;">Amount</th> <td align="left" valign="top">Rs.'.$results["chargetotal"].'</td> </tr> <tr> <th align="left" style="color:#222; background:#FAFAFA;">Payment Status</th> <td align="left" valign="top">'.$results["status"].' '.$results["fail_reason"].'</td> </tr> </table> <p style="font-size:16px; font-family:Tahoma, Geneva, sans-serif; color:#444;padding-top:5px;">Registration & Vaccination Detail</p> <table border="1" bordercolor="#ddd" cellpadding="10" cellspacing="0" id="emailContainer" style="font-size:12px;width:100%;"> <tr> <th align="left" style="color:#222; background:#FAFAFA;">Name</th> <td align="left" valign="top">'.$userData["full_name"].'</td> </tr> <tr> <th align="left" style="color:#222; background:#FAFAFA;">Phone</th> <td align="left" valign="top">'.$userData["contact_number"].'</td> </tr> <tr> <th align="left" style="color:#222; background:#FAFAFA;">Address</th> <td align="left" valign="top">'.$userData["address"].'</td> </tr> <tr> <th align="left" style="color:#222; background:#FAFAFA;">Appointment For </th> <td align="left" valign="top">'.$does.'</td> </tr> <tr> <th align="left" style="color:#222; background:#FAFAFA;">Vaccine</th> <td align="left" valign="top">'.$testDetails[0]->title.'</td> </tr> <tr> <th align="left" style="color:#222; background:#FAFAFA;">Appointment Date</th> <td align="left" valign="top">'.date('d M Y',$query['slot_date']).'</td> <tr> </tr> <th align="left" style="color:#222; background:#FAFAFA;">Slot Time </th> <td align="left" valign="top">'.$slotArray[0]->title.'</td> </tr> </table> <br/><br/> <p style="padding:0; margin:0px;font-size:12px; font-family:Tahoma, Geneva, sans-serif; color:#444; font-style:italic;">Note: if you have any issue wirte us at info@shardahospital.org.</p><br /> </td> </tr> <tr bgcolor="#220038"></tr> <tr bgcolor="#220038"> <td colspan="2"> <table width="100%"> <tr> <td align="center" colspan="2" valign="middle" style="padding:30px 10px 30px 10px; "> <a href="https://www.shardahospital.org" style="color:#fff; font-size:16px; font-family:Tahoma, Geneva, sans-serif; text-decoration:none; padding:2px 0; line-height:20px;">www.shardahospital.org</a> </td> </tr> </table> </td> </tr> </table> </body> </html>'; return $template; } }