MOON
Server: Apache
System: Linux nserver.cafsindia.com 4.18.0-553.104.1.lve.el8.x86_64 #1 SMP Tue Feb 10 20:07:30 UTC 2026 x86_64
User: cafsindia (1002)
PHP: 8.2.30
Disabled: NONE
Upload Files
File: /home/cafsindia/allyindian_com/backend/application/controllers/Cancel_ticket.php
<?php  if ( ! defined('BASEPATH')) exit('No direct script is allowed');
require_once("Secure_Controller.php");
class Cancel_ticket extends Secure_Controller
{	
	public function __construct(){
		parent::__construct('cancel_ticket');
		$this->load->model('Cancel_ticket_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->Cancel_ticket_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('cancel_ticket/manage',$data);
	}
	public function get_trip_data(){
		$search_by   = $this->input->post('search_by');
		$search_text = $this->input->post('search_text');
		$package     = $this->input->post('package');
		$result      = $this->Cancel_ticket_model->get_package_data($search_by,$search_text,$package);
		$tr_line = "";
		$i = 1;
		foreach ($result as $rslt){	
			$custfname = $rslt['custfname'];
			$custlname = $rslt['custlname'];
			$pnr       = $rslt['pnrno'];
			$date      = date("d-m-Y",strtotime($rslt['doj']));
			$custid    = $rslt['custid'];
			$orderid   = $rslt['orderid'];
			$custmobile= $rslt['custmobile'];
			$nopass    = $rslt['nopass'];
			$url       = site_url('cancel_ticket');
			$style     = "style='padding: 3px 8px;margin-right: 4px;'";
			$today     = date('Y-m-d');
			if($today > $rslt['doj']){
	 			$btn ="<span style='color:red'>Journey Day Completed</span>";
	 		}else{
	 			$btn = "<a href='$url/get_ticket_data/$orderid' $style type='button' class='btn btn-info btn-sm'>Show Tickets</a>";
	 		}
			$tr_line .= "<tr>
							<td style='text-align:center;'>$i</td>	
							<td style='text-align:center;'>$pnr</td>
							<td style='text-align:center;'>$date</td>
							<td style='text-align:center;'>$custid</td>
							<td style='text-align:center;'>$orderid</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;'>$btn</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;'>Package Date</th>
                  <th style='text-align:center !important;'>Customer ID</th>
                  <th style='text-align:center !important;'>Invoice No</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;'>Booked Seats</th>
                  <th style='text-align:center !important;'>Operations</th>
                </tr>       
              </thead>
              <tbody id='package_data'>
              $tr_line
              </tbody>
            </table>";
	}	
	public function get_ticket_data($orderid){
		$data['ticket_data']    = $this->Cancel_ticket_model->get_ticket_data($orderid);
		$data['discount_data']  = $this->Cancel_ticket_model->get_discount_data();
		$this->load->view('cancel_ticket/cancel_form',$data);
	}
	public function cancel_pass_ticket(){
			$custid      = $this->input->post('custid');
			$orderid     = $this->input->post('orderid');
			$cancel_data = array(
				'pass_id'    => $this->input->post('passid'),
				'bookorderid'=> $this->input->post('orderid'),
				'orderdate'  => $this->input->post('orderdate'),
				'pnrno'      => $this->input->post('pnrno'),
				'packid'     => $this->input->post('packid'),
				'doj'        => $this->input->post('pack_date'),
				'custid'     => $this->input->post('custid'),
				'nopass'     => 1,
				'ticketamt'  => $this->input->post('ticketamt'),
				'cancelfee'  => $this->input->post('can'),
				'cancelamt'  => $this->input->post('fees'),
				'refundamt'  => $this->input->post('refund'),
				'cashpaid'   => $this->input->post('paid'),
				'cancel_date' => date('Y-m-d h:i:s')
			);			
			$passid       = $this->input->post('passid');
		$ticket_data = $this->Cancel_ticket_model->cancel_pass_ticket($passid,$cancel_data);
		if($ticket_data){
			//Send Email
			$this->send_email($passid);
			$cust_data = $this->Sms_model->get_custmobile($custid);
			$mobile = $cust_data->custmobile;
			if($mobile){
				$this->Sms_model->send_sms($orderid,$mobile,"cancelled");
			}
			
			echo json_encode(array('message' => 'Your Ticket Cancelled Successfully', 'ticket_data' => $ticket_data));			
		}else{
			echo json_encode(array('message' => 'Your Ticket Cancelled Successfully', 'ticket_data' => $ticket_data));
		}
		
	}
	public function send_email($passid){
		$data = $this->Cancel_ticket_model->get_cancel_details($passid);
		foreach ($data as $rslt){	
			$custfname = $rslt['custfname'];
			$custlname = $rslt['custlname'];
			$pnr       = $rslt['pnrno'];
			$date      = date("d-m-Y",strtotime($rslt['doj']));
			$cancel_id = $rslt['orderid'];
			$custmobile= $rslt['custmobile'];
			$custemail = $rslt['custemail'];
			$order_id  = $rslt['bookorderid'];
			$refundamt = $rslt['refundamt'];
		}
		$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 Ticket Has Been Cancelled Successfully...Cancel Order Number is $cancel_id.Your Refund Amount Will Be Processed Within 7 Working Days... Thankyou.</p>
		</div>";
		$email_data = array(				
						'to_email'       => $custemail,
						'subject'        => "SBLT Booking Cancelled for Order No $order_id",
						'email_content'  => $content,
						'email_type'     => "BOOKING_CANCELLED",
					);
		$this->Email_model->send_phpmailer($email_data);

	}

}

?>