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/Due_collection.php
<?php  if ( ! defined('BASEPATH')) exit('No direct script is allowed');
require_once("Secure_Controller.php");
class Due_collection extends Secure_Controller{	
	public function __construct(){
		parent::__construct('due_collection');
		$this->load->model('Due_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->Due_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('due_collection/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->Due_collection_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['ticketorderid'];
			$custmobile= $rslt['custmobile'];
			$nopass    = $rslt['nopass'];
			$paid      = $rslt['paid'];
			$cashdue   = $rslt['due_amount'];
			$ticketamt = $rslt['ticketamt'];
			$url       = site_url('Due_collection');
			$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;'>$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;'>$cashdue</td>
							<td style='text-align:center;'><a href='$url/get_ticket_data/$orderid' $style type='button' class='btn btn-info btn-sm'>Pay Due Amount</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;'>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;'>Due Amount</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){
	$bank_info[""] = "--- Select Bank ---";
	$bank_data = $this->Due_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;
	$data['ticket_data']    = $this->Due_collection_model->get_ticket_data($orderid);	
	$this->load->view('due_collection/due_form',$data);
}
public function get_due_data(){
	$orderid = $this->input->post('orderid');
	$due_data     = $this->Due_collection_model->get_due_data($orderid);
	
	$url = base_url();	
	$j = 1;	
	foreach ($due_data as $due_rslt){	
		$booked_orderid   = $due_rslt['booked_orderid'];
		$pnrno            = $due_rslt['pnrno'];
		$custfname        = $due_rslt['custfname'];
		$custlname        = $due_rslt['custlname'];
		$paid_by          = $due_rslt['paid_by'];
		$package_title    = $due_rslt['package_title'];
		$package_title2   = $due_rslt['package_title2'];
		$package_title3   = $due_rslt['package_title3'];
		$paid_by          = $due_rslt['paid_by'];
		$paid_date        = date("d-m-Y H:i:s",strtotime($due_rslt['paid_date']));
		$paid_amount      = $due_rslt['paid_amount'];
		$balance          = $due_rslt['balance'];
		$order_date       = date("d-M-Y",strtotime($due_rslt['orderdate']));
		$pack_date        = date("d-M-Y",strtotime($due_rslt['doj']));
		$order            = $due_rslt['orderdate'];
		$package_date     = $due_rslt['doj'];
		$nopass           = $due_rslt['nopass'];
		$boarding         = $due_rslt['boarding_name'];
		$dep_time         = $due_rslt['dep_time'];
		$finalamt         = $due_rslt['finalamt'];
		$paidamt          = $due_rslt['paidamt'];
		$balamt           = $due_rslt['balamt'];
		$pack_name        = $package_title." ".$package_title2." ".$package_title3;
		$due_line .= "<tr style='text-align: center;'><td>$j</td><td>$booked_orderid</td><td>$paid_by</td><td>$paid_date</td><td>$paid_amount</td><td>$balance</td></tr>";
		$j++;
	}
	if(!$due_line){
		$due_line = "<tr><td colspan='4'>Data Not Exist<td><tr>";
	}

	$due_table = "<div class='row' style='margin-bottom: 8px;'><button class='btn btn-danger btn-sm' style='float: right; padding: 0px; margin-right: 22px;' onclick=print_bill()>Print</button></div><div id='print_data' 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);'>
			<table style='width:100%;border-collapse: collapse;border-spacing: 0;border-color: #CCCCCC !important;border: 0px;text-align: center;font-size: 14px;line-height: 25px;background-color: #FFFFFF;' border='1' cellspacing='0' cellpadding='4'>
				<tr>
					<td style='width:25%'>
						<img class='lkbLoggo' style='margin-left: 30px;' id='logo' width='110' src='$url/images/logo.png' alt='sbltt'>
					</td>
					<td style='width:75%'>
						<table style='text-align: center; width: 100%;'>
							<tr>
								<td>
									<h3 style='color:#d3434d;margin:10px;font-size:21px;font-weight:bold;'>Sri Bhagiyalakshmi Tours and Travels</h3>
								</td>
							</tr>
							<tr>
								<td>
									Plot No.1310, 13th Main Road, Anna Nagar, 
								</td>
							</tr>
							<tr>
								<td>
									Opp : Anna Nagar West Depot, Chennai - 600040. 
								</td>
							</tr>
							<tr>
								<td>
									Phone : 044 - 4666 4666 / Mobile : 98416 99966
								</td>
							</tr>
							<tr>
								<td>
									Website : www.sblt.co.in / E-mail : tours@sblt.co.in
								</td>
							</tr>
						</table>
					</td>
				</tr>
			</table><table class='table' style='line-height: 25px;border: 0px;background-color: #EEEEEE;' border='1' cellspacing='0' cellpadding='4' >
				<tr>
					<td style='white-space: nowrap;'>Package Name</td>
					<td style='font-weight: bold;' colspan='3'>$pack_name</td>
					<td style='white-space: nowrap;'>Boarding Point	</td>
					<td style='font-weight: bold;' colspan='3'>$boarding</td>
				</tr>
				<tr>
					<td style='white-space: nowrap;'>PNR No</td>
					<td style='font-weight: bold;'>$pnrno</td>
					<td style='white-space: nowrap;'>Date of Journey</td>
					<td style='font-weight: bold;white-space: nowrap;'>$pack_date</td>
					<td style='white-space: nowrap;'>Booked Date</td>
					<td style='font-weight: bold;white-space: nowrap;'>$order_date</td>
				</tr>
				<tr>
					<td style='white-space: nowrap;border-bottom:0px;'>Ticket No</td>
					<td style='border-bottom:0px;font-weight: bold;'>$orderid</td>
					<td style='white-space: nowrap;border-bottom:0px;'>No of Passengers</td>
					<td style='border-bottom:0px;font-weight: bold;'>$j</td>
					<td style='white-space: nowrap;border-bottom:0px;'>Departure Time</td>
					<td style='border-bottom:0px;font-weight: bold;'>$dep_time</td>
				</tr>
				<tr>
				<td style='white-space: nowrap;border-bottom:0px;'>Name</td>
					<td style='border-bottom:0px;font-weight: bold;'>$custfname $custlname</td>
					<td style='white-space: nowrap;border-bottom:0px;'>Ticket Amount</td>
					<td style='border-bottom:0px;font-weight: bold;'>$finalamt</td>
					<td style='white-space: nowrap;border-bottom:0px;'>Advance</td>
					<td style='border-bottom:0px;font-weight: bold;'>$paidamt</td>
					<td style='white-space: nowrap;border-bottom:0px;'>Balance</td>
					<td style='border-bottom:0px;font-weight: bold;'>$balamt</td>
				</tr>
			</table><table class='table table-hover table-striped col-style' border='1' cellspacing='0' cellpadding='11'>
					<thead>
						<tr style='background-color:#828181;color: #FFFFFF;'>
							<th>Due Payment</th>
							<th>Ticket No</th>
							<th>Paid By</th>
							<th>Paid Date</th>
							<th>Paid Amount</th>
							<th>Balance Amount</th>
						</tr>
					</thead>
					<tbody>
						$due_line
					</tbody>
				</table></div>";
	if($due_data){
		echo json_encode(array('success'=>TRUE,'due_data' => $due_table));
	}else{
		$due_table = "<tr><td colspan='4'>No Due Payment Exist<td><tr>";
		echo json_encode(array('success'=>FALSE,'due_data' => $due_table));
	}
	
}
public function save_due(){
	$orderid = $this->input->post('orderid');
		$due_data = array(
			'booked_orderid'      => $this->input->post('orderid'),
			'paid_by'      => $this->input->post('paid_by'),
			'bank'         => $this->input->post('bank'),
			'cheque_no'    => $this->input->post('cheque_no'),
			'cheque_date'  => date("Y-m-d",strtotime($this->input->post('cheque_date'))),
			'paid_amount'  => $this->input->post('paid'),
			'balance'      => $this->input->post('bal'),
			'trans_charge' => $this->input->post('additional'),
			'tot_charges'  => $this->input->post('charges'),
			'paid_date'    => date("Y-m-d H:i:s")
		);		

	$due_id  = $this->Due_collection_model->update_due($due_data);
	if($due_id){
		//Send Email
			$this->send_email($due_id);
			$cust_data = $this->Due_collection_model->get_custmobile($orderid);
			$mobile = $cust_data->custmobile;
			if($mobile){
				$this->Sms_model->send_sms($due_id,$mobile,"due_paid");
			}
		echo json_encode(array('success'=>TRUE,'message' => 'Due Amount Updated Successfully', 'due' => $due));
	}else{
		echo json_encode(array('success'=>FALSE,'message' => 'Please Try After Sometime', 'due' => $due));
	}
	
}
public function send_email($due_id){
		$data = $this->Due_collection_model->get_due_details($due_id);
		foreach ($data as $rslt){	
			$custfname    = $rslt['custfname'];
			$custlname    = $rslt['custlname'];
			$custmobile   = $rslt['custmobile'];
			$custemail    = $rslt['custemail'];
			$pnr          = $rslt['pnrno'];
			$date         = date("d-m-Y",strtotime($rslt['doj']));			
			$order_id     = $rslt['bookorderid'];
			$paid_amount  = $rslt['paid_amount'];
			$balance      = $rslt['balance'];
		}
		$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 Due Payment of $paid_amount Has Been Recieved Successfully...Your Order Number is $order_id.Your Balance Amount $balance... Thankyou.</p>
		</div>";
		$email_data = array(				
						'to_email'       => $custemail,
						'subject'        => "SBLT Due Payment for Order No $order_id",
						'email_content'  => $content,
						'email_type'     => "DUE_PAYMENT",
					);
		$this->Email_model->send_phpmailer($email_data);

	}

}

?>