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/dashboard/customer_details.php
<?php
require ("../app/dbconnect.php");
	$dbconnect = new dbconnect;
	$db = $dbconnect->connect();
	$frm = $_POST['frm'];
	if($frm === "get_customer_info"){
		$custid  = $_POST['custid'];
		$orderid = $_POST['orderid'];
		//$packid  = $_POST['orderid'];
		$otripid = $_POST['otripid'];
		$doj     = date('Y-m-d', strtotime($_POST['doj']));		

		$passanger_info = mysql_query("SELECT passname,passgender,passage,passmobile,passstatus from sblttweb_passlist inner join sblttweb_ticketorder on sblttweb_ticketorder.orderid=sblttweb_passlist.ticketorderid inner join sblttweb_package on sblttweb_package.package_id = sblttweb_ticketorder.packid where sblttweb_ticketorder.custid = '$custid' and orderstat IN (1,2,4)");
		$tr_line = "";
		$count = 0;
		while($passanger_rslt = mysql_fetch_array($passanger_info)){
		$count++;
		$passname       = $passanger_rslt['passname'];
		$passgender     = $passanger_rslt['passgender'];
		$passage        = $passanger_rslt['passage'];
		$passmobile     = $passanger_rslt['passmobile'];
		$passstatus     = $passanger_rslt['passstatus'];
		if($passstatus === "0"){
			$passstatus = "<span style='color:orange'>Due Pending</span>";
		}else
		if($passstatus === "1"){
			$passstatus = "<span style='color:red'>Cancelled</span>";
		}else
		if($passstatus === "2"){
			$passstatus = "<span style='color:green'>Booked</span>";
		}else
		if($passstatus === "3"){
			$passstatus = "Payment Failure";
		}
		$tr_line  .= "<tr>
						<td style='text-align:center !important;'>$count</td>
						<td>$passname</td>
						<td>$passgender</td>
						<td>$passage</td>
						<td>$passmobile</td>
						<td>$passstatus</td>
					</tr>";
		}
		echo "<table id='detail_list' class='table table-bordered col-style'>
			<thead>
				<tr>
					<th>Sl.No</th>
					<th>Passenger Name</th>
					<th>Gender</th>
					<th>Age</th>	
					<th>Mobile</th>
					<th>Status</th>	
				</tr>
			</thead>
			<tbody>$tr_line</tbody>
		</table>";	
	}else
	if($frm === "get_passenger_info"){
		$custid  = $_POST['custid'];
		$tripid  = $_POST['tripid'];	
		$doj     = date("Y-m-d",strtotime($_POST['doj']));
		$qry = "";
		if($custid){
			$qry = "sblttweb_ticketorder.custid = '$custid'";
		}	
		if($tripid){
			$qry = "sblttweb_passlist.passtripid = '$tripid'";
		}	
		$passanger_info = mysql_query("SELECT passname,passgender,passage,passmobile,passstatus,sblttweb_passlist.ticketamt,sblttweb_passlist.discountamt,admin_discountamt,cashpaid,cashdue,doj,package_title,package_title2,package_title3,sblttweb_passlist.pnrno,ticketorderid,seatno,paytype from sblttweb_passlist inner join sblttweb_ticketorder on sblttweb_ticketorder.orderid=sblttweb_passlist.ticketorderid inner join sblttweb_package on sblttweb_package.package_id = sblttweb_ticketorder.packid where $qry and sblttweb_ticketorder.doj = '$doj' and (passstatus = '0' or passstatus = '2') and orderstat IN (1,2,4)");
		$tr_line = "";
		$count = 0;
		while($passanger_rslt = mysql_fetch_array($passanger_info)){
		$count++;
		$passname          = $passanger_rslt['passname'];
		$passgender        = $passanger_rslt['passgender'];
		$passage           = $passanger_rslt['passage'];
		$passmobile        = $passanger_rslt['passmobile'];
		$passstatus        = $passanger_rslt['passstatus'];
		$ticketamt         = $passanger_rslt['ticketamt'];
		$discountamt       = $passanger_rslt['discountamt'];
		$admin_discountamt = $passanger_rslt['admin_discountamt'];
		$cashpaid          = $passanger_rslt['cashpaid'];
		$cashdue           = $passanger_rslt['cashdue'];
		$pnrno             = $passanger_rslt['pnrno'];
		$ticketorderid     = $passanger_rslt['ticketorderid'];
		$seatno            = $passanger_rslt['seatno'];
		$paytype           = $passanger_rslt['paytype'];
		$doj               = date('Y-m-d', strtotime($passanger_rslt['doj']));
		$package_title     = $passanger_rslt['package_title'];
		$package_title2    = $passanger_rslt['package_title2'];
		$package_title3    = $passanger_rslt['package_title3'];
		$package_name      = $package_title." ".$package_title2." ".$package_title3;
		if($passstatus === "0"){
			$passstatus = "<span style='color:orange'>Due Payment</span>";			
		}else
		if($passstatus === "1"){
			$passstatus = "<span style='color:red'>Cancelled</span>";
		}else
		if($passstatus === "2"){
			$passstatus = "<span style='color:green'>Booked</span>";
		}else
		if($passstatus === "3"){
			$passstatus = "Payment Failure";
		}
		$tr_line  .= "<tr>
						<td style='text-align:center !important;'>$count</td>
						<td>$doj</td>
						<td>$package_name</td>
						<td>$seatno</td>
						<td>$passname</td>
						<td>$passgender</td>
						<td>$passage</td>
						<td>$passmobile</td>
						<td>$pnrno</td>
						<td>$ticketorderid</td>						
						<td>$ticketamt</td>
						<td>$discountamt</td>
						<td>$admin_discountamt</td>
						<td>$cashpaid</td>
						<td>$cashdue</td>
						<td>$paytype</td>
						<td>$passstatus</td>						
					</tr>";
		}
		echo "<table id='detail_list' class='table table-bordered col-style'>
			<thead>
				<tr>
					<th>Sl.No</th>
					<th>Package Date</th>
					<th>Package Name</th>
					<th>Seat No</th>
					<th>Passenger Name</th>
					<th>Gender</th>
					<th>Age</th>	
					<th>Mobile</th>
					<th>PNR No</th>
					<th>Ticket No</th>						
					<th>Total</th>
					<th>Discount</th>
					<th>Admin Discount</th>
					<th>Paid</th>	
					<th>Balance</th>
					<th>Paid By</th>
					<th>Status</th>	
				</tr>
			</thead>
			<tbody>$tr_line</tbody>
		</table>";	
	}else
	if($frm === "get_sales_info"){		
		$start_date      = $_POST['start_date'];
		$end_date        = $_POST['end_date'];
		$packid          = $_POST['packid'];
		$doj             = $_POST['doj'];
		$otripid         = $_POST['otripid'];
		$order_id        = $_POST['order_id'];
		$doj         = date('Y-m-d', strtotime($_POST['doj']));		
		$type        = $_POST['type'];
		if($type === "1"){
			$sales_info = mysql_query("SELECT ticketorderid,IFNULL((sblttweb_passlist.tariffamt),0) as tariff_amt,IFNULL((sblttweb_passlist.ticketamt),0) as ticket_amt,IFNULL((sblttweb_passlist.discountamt),0) as discount_amt,IFNULL((cashpaid),0) as paid_amt,IFNULL((cashdue),0) as bal_amt,IFNULL((irumudi_amount),0) as irumudi_amount,sblttweb_ticketorder.paytype from sblttweb_passlist INNER JOIN sblttweb_vehicletrips on sblttweb_vehicletrips.tripid = sblttweb_passlist.passtripid inner join sblttweb_ticketorder on sblttweb_ticketorder.orderid = sblttweb_passlist.ticketorderid inner join sblttweb_package on sblttweb_package.package_id = sblttweb_vehicletrips.trippackid left join sblttweb_irumudi on sblttweb_irumudi.order_id = sblttweb_ticketorder.orderid where sblttweb_passlist.passtripid = '$otripid' and DATE_FORMAT(sblttweb_passlist.passdate, '%Y-%m-%d') BETWEEN '$start_date' AND '$end_date' and (passstatus = '0' or passstatus = '2') and orderstat IN (1,2,4) order by passid desc");	
		$tr_line = "";
		$count = 0;
		$tot_tariff_amt   = 0;
		$tot_discount_amt = 0;
		$tot_ticket_amt   = 0;
		$tot_paid_amt     = 0;
		$tot_bal_amt      = 0;
		$tot_irumudi_amount = 0;
		while($sales_rslt = mysql_fetch_array($sales_info)){
		$count++;
		$orderid        = $sales_rslt['ticketorderid'];
		$tariff_amt     = $sales_rslt['tariff_amt'];
		$ticket_amt     = $sales_rslt['ticket_amt'];
		$discount_amt   = $sales_rslt['discount_amt'];
		$irumudi_amount = $sales_rslt['irumudi_amount'];
		$paid_amt       = $sales_rslt['paid_amt'];
		$bal_amt        = $sales_rslt['bal_amt'];
		$paytype        = $sales_rslt['paytype'];

		$tot_tariff_amt   += (int)$tariff_amt;
		$tot_discount_amt += (int)$discount_amt;
		$tot_ticket_amt   += (int)$ticket_amt;
		$tot_paid_amt     += (int)$paid_amt;
		$tot_bal_amt      += (int)$bal_amt;
		$tot_irumudi_amount += (int)$irumudi_amount;
		
		$tr_line  .= "<tr>
						<td style='text-align:center !important;'>$count</td>
						<td>$orderid</td>						
						<td>$tariff_amt</td>						
						<td>$discount_amt</td>
						<td>$ticket_amt</td>
						<td>$paid_amt</td>
						<td>$bal_amt</td>
						<td>$irumudi_amount</td>
						<td>$paytype</td>
					</tr>";
		}
		$tr_line  .= "<tr style='font-weight:bold;'>
						<td ></td>
						<td style='text-align:center !important;font-weight:bold;'>Total Amount</td>
						<td>$tot_tariff_amt</td>
						<td>$tot_discount_amt</td>
						<td>$tot_ticket_amt</td>
						<td>$tot_paid_amt</td>
						<td>$tot_bal_amt</td>
						<td>$tot_irumudi_amount</td>
						<td ></td>
					</tr>";
		
		echo "<table id='detail_list' class='table table-bordered col-style'>
			<thead>
				<tr>
					<th>Sl.No</th>
					<th>Booked Ticket No</th>
					<th>Tariff Amount</th>
					<th>Discount Amount</th>
					<th>Ticket Amount</th>		
					<th>Paid Amount</th>	
					<th>Due Amount</th>
					<th>Other Amount</th>
					<th>Pay Type</th>
				</tr>
			</thead>
			<tbody>$tr_line</tbody>
		</table>";		
		}else{	
			$sales_info = mysql_query("SELECT sblttweb_cancelorder.orderid as cancel_id,ticketorderid,IFNULL((sblttweb_passlist.tariffamt),0) as tariff_amt,IFNULL((sblttweb_passlist.ticketamt),0) as ticket_amt,IFNULL((sblttweb_passlist.discountamt),0) as discount_amt,IFNULL((sblttweb_passlist.cashpaid),0) as paid_amt,IFNULL((sblttweb_passlist.cashdue),0) as bal_amt,sblttweb_cancelorder.cancelamt,sblttweb_cancelorder.refundamt,refundstatus from sblttweb_cancelorder INNER JOIN sblttweb_passlist on sblttweb_passlist.cancelorderid = orderid INNER JOIN sblttweb_vehicletrips on sblttweb_vehicletrips.tripid = sblttweb_passlist.passtripid inner join sblttweb_package on sblttweb_package.package_id = sblttweb_vehicletrips.trippackid where sblttweb_passlist.passtripid = '$otripid' and DATE_FORMAT(sblttweb_passlist.passdate, '%Y-%m-%d') BETWEEN '$start_date' AND '$end_date' and (passstatus = '0' or passstatus = '2') group by sblttweb_cancelorder.orderid order by passid desc");
		$tr_line = "";
		$count = 0;
		$tot_tariff_amt   = 0;
		$tot_discount_amt = 0;
		$tot_ticket_amt   = 0;
		$tot_paid_amt     = 0;
		$tot_bal_amt      = 0;
		$tot_cancelamt    = 0;
		$tot_refundamt    = 0;
		$tot_amount       = 0;
		$paid_amt         = 0;
		$bal_amt          = 0;
		while($sales_rslt = mysql_fetch_array($sales_info)){
		$count++;
		$cancel_id      = $sales_rslt['cancel_id'];
		$orderid        = $sales_rslt['ticketorderid'];		
		$cancelamt      = $sales_rslt['cancelamt'];
		$ticket_amt     = $sales_rslt['ticket_amt'];
		$refundamt      = $sales_rslt['refundamt'];
		$paid_amt       = $sales_rslt['paid_amt'];
		$bal_amt        = $sales_rslt['bal_amt'];
		//$paytype        = $sales_rslt['paytype'];
		$refundstatus   = $sales_rslt['refundstatus'];
		if($refundstatus === "1"){
			$refundstatus = "<span style='color:green;'>Processed</span>";
		}else{
			$refundstatus = "<span style='color:red;'>Not Processed</span>";
		}
		$tot_ticket_amt   += (int)$ticket_amt;
		$tot_paid_amt     += (int)$paid_amt;
		$tot_bal_amt      += (int)$bal_amt;
		$tot_cancelamt    += (int)$cancelamt;
		$tot_refundamt    += (int)$refundamt;
		
		$tr_line  .= "<tr>
						<td style='text-align:center !important;'>$count</td>
						<td>$cancel_id</td>
						<td>$orderid</td>		
						<td>$ticket_amt</td>
						<td>$paid_amt</td>
						<td>$bal_amt</td>
						<td>$cancelamt</td>
						<td>$refundamt</td>
						<td>$refundstatus</td>
					</tr>";
		}
		$tr_line  .= "<tr style='font-weight:bold;'>
						<td ></td>
						<td ></td>
						<td style='text-align:center !important;font-weight:bold;'>Total Amount</td>
						<td>$tot_ticket_amt</td>
						<td>$tot_paid_amt</td>
						<td>$tot_bal_amt</td>
						<td>$tot_cancelamt</td>
						<td>$tot_refundamt</td>
						<td ></td>
					</tr>";
		
		echo "<table id='detail_list' class='table table-bordered col-style'>
			<thead>
				<tr>
					<th>Sl.No</th>
					<th>Cancel Order No</th>
					<th>Ticket No</th>
					<th>Ticket Amount</th>		
					<th>Paid Amount</th>	
					<th>Due Amount</th>
					<th>Cancel Amount</th>
					<th>Refund Amount</th>
					<th>Refund Status</th>
				</tr>
			</thead>
			<tbody>$tr_line</tbody>
		</table>";			
		}					
	}else
	if($frm === "get_ticket_info"){		
		$packid          = $_POST['package_id'];
		$date            = $_POST['date'];
		$tripid          = $_POST['tripid'];
		$type            = $_POST['type'];		
		$trip_date       = date("d-m-Y",strtotime($_POST['date']));
		$qry = "";
		$can_join = "";
		$select   = "";
		if($type === "booked"){
			$qry = "and (passstatus = '0' or passstatus = '2')";
		}else{
			$qry = "and passstatus = '1'";
			$can_join = "inner join sblttweb_cancelorder on sblttweb_cancelorder.orderid = sblttweb_passlist.cancelorderid";
			$select = ",refundstatus";
		}		
		$ticket_info = mysql_query("SELECT sblttweb_customers.custid,custemail,custfname,custlname,custmobile,ticketorderid,IFNULL(sum(sblttweb_passlist.tariffamt),0) as tariff_amt,IFNULL(sum(sblttweb_passlist.ticketamt),0) as ticket_amt,IFNULL((sblttweb_passlist.discountamt),0) as discount_amt,IFNULL(sum(sblttweb_passlist.cashpaid),0) as paid_amt,IFNULL(sum(sblttweb_passlist.cashdue),0) as bal_amt,count(passid) as ticket_count,sblttweb_passlist.pnrno,passtripid $select from sblttweb_passlist inner join sblttweb_ticketorder on sblttweb_ticketorder.orderid = sblttweb_passlist.ticketorderid inner join sblttweb_customers on sblttweb_customers.custid = sblttweb_ticketorder.custid $can_join  where sblttweb_passlist.passtripid = '$tripid' and sblttweb_ticketorder.packid = '$packid' and sblttweb_ticketorder.doj = '$date' $qry and orderstat IN (1,2,4) GROUP BY sblttweb_ticketorder.orderid");
		$tr_line = "";
		$count = 0;
		$tot_tariff_amt   = 0;
		$tot_discount_amt = 0;
		$tot_ticket_amt   = 0;
		$tot_paid_amt     = 0;
		$tot_bal_amt      = 0;
		
		while($ticket_rslt = mysql_fetch_array($ticket_info)){
		$count++;
		$custid         = $ticket_rslt['custid'];
		$custemail      = $ticket_rslt['custemail'];
		$orderid        = $ticket_rslt['ticketorderid'];
		$tariff_amt     = $ticket_rslt['tariff_amt'];
		$ticket_amt     = $ticket_rslt['ticket_amt'];
		$discount_amt   = $ticket_rslt['discount_amt'];
		$pnrno          = $ticket_rslt['pnrno'];
		$paid_amt       = $ticket_rslt['paid_amt'];
		$bal_amt        = $ticket_rslt['bal_amt'];
		$custfname      = $ticket_rslt['custfname'];
		$custlname      = $ticket_rslt['custlname'];
		$custmobile     = $ticket_rslt['custmobile'];	
		$passtripid     = $ticket_rslt['passtripid'];
		$ticket_count   = $ticket_rslt['ticket_count'];
			
		if($type === "cancelled"){
			$refundstatus   = $ticket_rslt['refundstatus'];
			if($refundstatus === "1"){
				$refund_btn     = "<button style='color:#df1212;border: none;background: #FFFFFF;' data-toggle='tooltip' title='Refund Print' onclick=print_refund($orderid)><i class='fa fa-anchor fa-2x' aria-hidden='true'></i></button>";
			}else{
				$refund_btn = "<span style='color:red'>Refund Not Proccessed</span>";
			}
			
		}
		$name = $custfname."".$custlname;
		$tot_tariff_amt   += (int)$tariff_amt;
		$tot_discount_amt += (int)$discount_amt;
		$tot_ticket_amt   += (int)$ticket_amt;
		$tot_paid_amt     += (int)$paid_amt;
		$tot_bal_amt      += (int)$bal_amt;
		$td_line = "";
		if($type === "booked"){
			$td_line = "<td><button style='margin-right: 5px;color:#df1212;    border: none;background: #FFFFFF;' data-toggle='tooltip' title='Print' onclick=print_ticket($orderid,'print','booked')> <i  class='fa fa-print fa-2x' aria-hidden='true'></i></button><button style='margin-right: 5px;color:#df1212;border: none;background: #FFFFFF;' data-toggle='tooltip' title='Send Mail' onclick=print_ticket($orderid,'email','booked')><i class='fa fa-envelope fa-2x' aria-hidden='true'></i></button><button style='color:#df1212;border: none;background: #FFFFFF;' data-toggle='tooltip' title='Irumudi' onclick=irumudi_update('$orderid','$custid','$trip_date','$packid',$passtripid)><i class='fa fa-superpowers fa-2x' aria-hidden='true'></i></button></td>";
		}else{
			$td_line = "<td><button style='margin-right: 5px;color:#df1212;    border: none;background: #FFFFFF;' data-toggle='tooltip' title='Print' onclick=print_ticket($orderid,'print','cancelled')> <i  class='fa fa-print fa-2x' aria-hidden='true'></i></button><button style='margin-right: 5px;color:#df1212;border: none;background: #FFFFFF;' data-toggle='tooltip' title='Send Mail' onclick=print_ticket($orderid,'email','cancelled')><i class='fa fa-envelope fa-2x' aria-hidden='true'></i></button>$refund_btn</td>";
		}

		$tr_line  .= "<tr>
						<td style='text-align:center !important;'>$count</td>
						<td>$orderid</td>
						<td>$pnrno</td>
						<td>$name</td>						
						<td>$custmobile</td>
						<td style='cursor:pointer;' onclick=get_passenger_info('$custid',$passtripid,'$trip_date')>$ticket_count</td>
						<td>$ticket_amt</td>
						<td>$paid_amt</td>
						<td>$bal_amt</td>
						$td_line
					</tr>";
		}		
		echo "<button class='btn btn-info btn-sm cls' id='back_to' style = 'display:none;'>Back</button><div id='ticket_info'><table id='ticket_tbl' class='table table-bordered col-style'>
			<thead>
				<tr>
					<th>Sl.No</th>
					<th>Order No</th>
					<th>PNR</th>
					<th>Customer Name</th>
					<th>Mobile</th>
					<th>Tickets</th>
					<th>Ticket Amount</th>		
					<th>Paid Amount</th>	
					<th>Due Amount</th>
					<th>Print Cancel Ticket / Refund </th>
				</tr>
			</thead>
			<tbody>$tr_line</tbody>
		</table></div><div id='irumudi_info'></div>";
	}
?>
<div id="htmldata"></div>
<script type="text/javascript">
function print_ticket(orderid,misc,status){
	frm = "print_ticket";
	 $.ajax({
      type: "POST",
      url: "dashboard/print_ticket.php",
      data: {frm:frm,misc:misc,orderid:orderid,status:status},
      success: function(data){
      	// $('#htmldata').html(data);
      	// $('#htmldata').hide();
      	// $('#logo').attr('src', 'customers/asset/images/sbltt_batch.png');      
      	if(misc === "print"){
			var divToPrint=document.getElementById("htmldata");
			newWin= window.open("");
			newWin.document.write(data);
			newWin.print();
			newWin.close();     
      	}else{
      		alert();
      	}	               	
      },
  });
}	
function print_refund(orderid){
	frm = "print_refund";
	 $.ajax({
      type: "POST",
      url: "dashboard/chart_call.php",
      data: {frm:frm,orderid:orderid},
      success: function(data){    
		var divToPrint=document.getElementById("print_data");
		newWin= window.open("");
		newWin.document.write(data);
		newWin.print();
		newWin.close();                    	
      },
  });
}

</script>
<style>
<?php
if($frm !== "get_passenger_info"){
?>
#lead_model_body .btn-default {
    color: #ffffff !important;
    background: #D8343F;
    padding: 1px 6px !important;
    font-size: 12px !important;
    border:none;
}
.form-group {
    padding: 5px;
    width: 15.3%;
    margin-bottom: 15px;
    margin-right: 15px;
}
<?php }
?>
</style>