File: //home/cafsindia/allyindian_com/backend/application/controllers/Refund_collection.php
<?php if ( ! defined('BASEPATH')) exit('No direct script is allowed');
require_once("Secure_Controller.php");
class Refund_collection extends Secure_Controller{
public function __construct(){
parent::__construct('refund_collection');
$this->load->model('Refund_collection_model');
$this->load->model('Email_model');
$this->load->model('Sms_model');
}
public function index(){
if(!$this->Appconfig->isAppvalid()){
redirect('config');
}
$data['table_headers']="";
$pack_data=$this->Refund_collection_model->get_packages();
$pack_info[""] = "---- Select Package ----";
foreach($pack_data as $row){
$pack_info[$this->xss_clean($row['package_id'])] = $this->xss_clean($row['package_title']."-".$row['package_title2']);
}
$data['package_info']=$pack_info;
$this->load->view('refund_collection/manage',$data);
}
public function get_pending_amt(){
$search_by = $this->input->post('search_by');
$search_text = $this->input->post('search_text');
$package_id = $this->input->post('package_id');
$result = $this->Refund_collection_model->get_pending_amt($search_by,$search_text,$package_id);
$tr_line = "";
$i = 1;
foreach ($result as $rslt){
$custfname = $rslt['custfname'];
$custlname = $rslt['custlname'];
$pnr = $rslt['pnrno'];
$bookorderid = $rslt['bookorderid'];
//$date = date("d-m-Y",strtotime($rslt['doj']));
$custid = $rslt['custid'];
$custmobile = $rslt['custmobile'];
$nopass = $rslt['nopass'];
$cancelid = $rslt['orderid'];
$type = $rslt['refundpaytype'];
$cancel_date = date("d-m-Y",strtotime($rslt['cancel_date']));
$url = site_url('refund_collection');
$refund_amt = $rslt['refundamt'];
$style = "style='padding: 3px 8px;margin-right: 4px;'";
$tr_line .= "<tr>
<td style='text-align:center;'>$i</td>
<td style='text-align:center;'>$pnr</td>
<td style='text-align:center;'>$bookorderid</td>
<td style='text-align:center;'>$cancelid</td>
<td style='text-align:center;'>$cancel_date</td>
<td style='text-align:center;'>$type</td>
<td style='text-align:center;'>$custid</td>
<td style='text-align:center;'>$custfname $custlname</td>
<td style='text-align:center;'>$custmobile</td>
<td style='text-align:center;'>$nopass</td>
<td style='text-align:center;'>$refund_amt</td>
<td style='text-align:center;'><a href='$url/get_update_refund/$cancelid' $style type='button' class='btn btn-info btn-sm'>Update Refund</a></td>
</tr>";
$i++;
}
echo "<table id='detail_list' class='table table-hover table-striped col-style'>
<thead>
<tr style='font-weight:bold;text-align:center !important;background:#d84f57;'>
<th style='text-align:center !important;'>SNo</th>
<th style='text-align:center !important;'>PNR No</th>
<th style='text-align:center !important;'>Invoice</th>
<th style='text-align:center !important;'>Cancel ID</th>
<th style='text-align:center !important;'>Cancel Date</th>
<th style='text-align:center !important;'>Pay Type</th>
<th style='text-align:center !important;'>Customer ID</th>
<th style='text-align:center !important;'>Customer Name</th>
<th style='text-align:center !important;'>Customer Mobile</th>
<th style='text-align:center !important;'>No. Of Passenger</th>
<th style='text-align:center !important;'>Refund Amount</th>
<th style='text-align:center !important;'>Refund Update</th>
</tr>
</thead>
<tbody id='due_amount'>
$tr_line
</tbody>
</table>";
}
public function get_update_refund($cancelid){
$data['refund_data'] = $this->Refund_collection_model->get_update_refund($cancelid);
$bank_info[""] = "--- Select Bank ---";
$bank_data = $this->Refund_collection_model->get_banks();
foreach($bank_data as $row){
$bank_info[$this->xss_clean($row['bank_name'])] = $row['bank_name'];
}
$data['bank_info'] = $bank_info;
$this->load->view('refund_collection/refund_form',$data);
}
public function refund_update($cancelid){
$custid = $this->input->post('custid');
$refund_amt = $this->input->post('refund_amt');
$insert_data = array(
'custid' => $this->input->post('custid'),
'paymentdate' => date('Y-m-d H:i:s'),
'orderid' => $this->input->post('cancel_id'),
'orderdate' => $this->input->post('orderdate'),
'paytype' => $this->input->post('trans_details'),
'bank' => $this->input->post('bank_name'),
'chno' => $this->input->post('cheque_no'),
'chdate' => $this->input->post('cheque_date'),
'settledon' => date('Y-m-d H:i:s'),
'amount' => $this->input->post('amount'),
'cancel_reason' => $this->input->post('cancel_reason'),
'cancel_remarks' => $this->input->post('remarks'),
'refund_percentage' => $this->input->post('refund_per'),
'settlestatus' => 1,
'custtype' => 1,
);
$payment_id = $this->Refund_collection_model->refund_update($custid,$insert_data,$refund_amt);
if($payment_id){
//Send Email
$this->send_email($payment_id);
$cust_data = $this->Sms_model->get_custmobile($custid);
$mobile = $cust_data->custmobile;
if($mobile){
$this->Sms_model->send_sms($payment_id,$mobile,"refund");
}
echo json_encode(array('success' => TRUE, 'message' => "Refund Update Successfully"));
}else{
echo json_encode(array('success' => FALSE, 'message' => "Try After Sometime..."));
}
}
public function send_email($payment_id){
$data = $this->Refund_collection_model->get_refund_details($payment_id);
foreach ($data as $rslt){
$custfname = $rslt['custfname'];
$custlname = $rslt['custlname'];
$custmobile = $rslt['custmobile'];
$custemail = $rslt['custemail'];
$order_id = $rslt['orderid'];
$amount = $rslt['amount'];
}
$content = "<div style='width: 750px; margin-left: auto; margin-right: auto; padding: 15px; background-color: #EEEEEE; border-radius: 3px; box-shadow: 0 2px 2px 0 rgba(0,0,0,0.14), 0 3px 1px -2px rgba(0,0,0,0.12), 0 1px 5px 0 rgba(0,0,0,0.2);'><h4 align='left'>Dear $custfname $custlname,</h4>
<p>Your Refund Payment of $amount Has Been Transfered Successfully...Your Cancel Order Number is $order_id... Thankyou.</p>
</div>";
$email_data = array(
'to_email' => $custemail,
'subject' => "SBLT Refund Payment for Order No $order_id",
'email_content' => $content,
'email_type' => "REFUND_PAYMENT",
);
$this->Email_model->send_phpmailer($email_data);
}
}
?>