File: /home/cafsindia/allyindian_com/backend/dashboard/print_ticket.php
<?php
require ("../app/dbconnect.php");
$dbconnect = new dbconnect;
$db = $dbconnect->connect();
$url = "http://". $_SERVER['SERVER_NAME'];
$frm = $_POST['frm'];
if($frm === "print_ticket"){
if(isset($_POST['orderid'])){
$orderid = $_POST['orderid'];
}
if(isset($_POST['misc'])){
$misc = $_POST['misc'];
}
if(isset($_POST['status'])){
$status = $_POST['status'];
}
if($status === 'booked'){
$ticket_qry = mysql_query("SELECT *,sblttweb_ticketorder.packid,sblttweb_ticketorder.orderid,sblttweb_ticketorder.custid,sblttweb_ticketorder.pnrno,sblttweb_passlist.discount as discount,sblttweb_passlist.tariffamt as tariffamt,sblttweb_passlist.ticketamt as ticketamt,sblttweb_passlist.discountamt as discountamt,sblttweb_passlist.admin_discount as admin_discount,sblttweb_passlist.admin_discountamt as admin_discountamt,sblttweb_passlist.cashpaid as cashpaid,sblttweb_passlist.cashdue as cashdue,sblttweb_ticketorder.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 inner join sblttweb_boarding on boarding_id = sblttweb_ticketorder.boarding inner join sblttweb_boarding_point on sblttweb_boarding_point.board_point_id = sblttweb_boarding.board_point_id inner join sblttweb_customers on sblttweb_customers.custid = sblttweb_ticketorder.custid inner join sblttweb_pnrnogen on sblttweb_pnrnogen.pnrno = sblttweb_ticketorder.pnrno where ticketorderid = '$orderid' and (sblttweb_passlist.passstatus = '0' or sblttweb_passlist.passstatus = '2') and orderstat IN (1,2,4)");
$i = 1;
$j=0;
$tr_line = "";
$cashpaid = 0;
$tariffamt = 0;
$discountamt = 0;
$ticketamt = 0;
$admin_discountamt = 0;
$admin_totdiscount = 0;
$admin_disc = 0;
$cashdue = 0;
$admin_tr = "";
$disc_tr = "";
while($rslt = mysql_fetch_array($ticket_qry)){
$passid = $rslt['passid'];
$pnrno = $rslt['pnrno'];
$track_id = $rslt['track_id'];
$orderid = $rslt['orderid'];
if($track_id){
$orderid = $track_id;
}else{
$orderid = $rslt['orderid'];
}
$order_date = date("d-M-Y",strtotime($rslt['orderdate']));
$pack_date = date("d-M-Y",strtotime($rslt['doj']));
$order = $rslt['orderdate'];
$package_date = $rslt['doj'];
$nopass = $rslt['nopass'];
$boarding = $rslt['boarding_name'];
$dep_time = $rslt['dep_time'];
$custid = $rslt['custid'];
$custemail = $rslt['custemail'];
$package_title = $rslt['package_title'];
$package_title2 = $rslt['package_title2'];
$package_title3 = $rslt['package_title3'];
$cancelfee = $rslt['cancelfee'];
$servicetax = $rslt['servicetax'];
$passname = $rslt['passname'];
$passgender = $rslt['passgender'];
$passage = $rslt['passage'];
$seatno = $rslt['seatno'];
$passtripid = $rslt['passtripid'];
$packid = $rslt['packid'];
$paytype = $rslt['paytype'];
$cashpaid += $rslt['cashpaid'];
$cashdue += $rslt['cashdue'];
$discount = $rslt['discount'];
$admin_discount = $rslt['admin_discount'];
$admin_totdiscount += $rslt['admin_discount'];
//$tariffamt += $rslt['tariffamt'];
$discountamt += $rslt['discountamt'];
$tariffamt += $rslt['tariffamt'];
$admin_disc = $rslt['admin_discountamt'];
$admin_discountamt += $rslt['admin_discountamt'];
$ticketamt += $rslt['ticketamt'];
$passmobile = $rslt['passmobile'];
$pack_name = $package_title." ".$package_title2." ".$package_title3;
$tr_line .= "<tr>
<td>$i</td>
<td>$passname</td>
<td>$passgender</td>
<td>$passmobile</td>
<td>$passage</td>
<td>$seatno</td>
<td>$admin_discount</td>
<td>$admin_disc</td>
</tr>";
$i++;
$j++;
}
//$ticketamt = $ticketamt - $admin_discountamt;
//GST Calculations
if((int)$servicetax < 10){
$servicetax = "0".$servicetax;
}
$gst = "1.".$servicetax;
$act_amt = round(($ticketamt / $gst));
$tot_gst = round(($ticketamt - $act_amt));
$gst_split = round(($tot_gst / 2));
//echo "act_amt : $act_amt :: tot_gst : $tot_gst :: gst_split :: $gst_split";
//Get Cancel Fees Details
$cancel_qry = mysql_query("SELECT * from sblttweb_cancelfee where FIND_IN_SET(cancelfeeid, '$cancelfee')");
$fee_line = "";
while($cancelfee_data = mysql_fetch_array($cancel_qry)){
$cancelfeedetail = $cancelfee_data['cancelfeedetail'];
$cancelfees = $cancelfee_data['cancelfees'];
$fee_line .= "<li>If the Ticket Cancelled $cancelfeedetail then Cancel Fees will be $cancelfees % </li>";
}
if((int)$admin_discountamt > 0){
$admin_tr = "<tr>
<td style='text-align:right;font-weight:bold;' colspan='7'>SBLTT Discount Total</td>
<td style='text-align:right;font-weight:bold;'>$admin_discountamt</td>
</tr>";
}
if((int)$discountamt > 0){
$disc_tr = "<tr>
<td style='text-align:right;font-weight:bold;' colspan='7'>Package Discount</td>
<td style='text-align:right;font-weight:bold;'>$discount%</td>
</tr>
<tr>
<td style='text-align:right;font-weight:bold;' colspan='7'>Discount Total</td>
<td style='text-align:right;font-weight:bold;'>$discountamt</td>
</tr>";
}
$details = "<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; background-color: #FFFFFF;' border='1' cellspacing='0' cellpadding='4'>
<tr>
<td style='border-bottom:0px;border-right: 0px;'>
<div class='PrintOnly'>
<img id='logo' src='$url/backend/images/logo.png' alt='sbltt'>
</div>
</td>
<td style='border-bottom:0px;border-left: 0px;'>
<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 style='width:100%;border-collapse: collapse;border-spacing: 0;border-color: #CCCCCC !important;border: 0px;font-size: 14px;background-color:#FFFFFF;' 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;'>$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;'>$pack_date</td>
<td style='white-space: nowrap;'>Date of Booking</td>
<td style='font-weight: bold;'>$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>
</table>
<table style='width:100%;border-collapse: collapse;border-spacing: 0;border-color: #CCCCCC !important;border: 0px;text-align: center;font-size: 14px; background-color: #FFFFFF;' border='1' cellspacing='0' cellpadding='4'>
<thead>
<tr style='background-color:#828181;color: #000000;font-weight:bold;'>
<th class='sb_center'>SNo</th>
<th class='sb_center'>Passenger Name</th>
<th class='sb_center'>Gender</th>
<th class='sb_center'>Mobile</th>
<th class='sb_center'>Age</th>
<th class='sb_center'>Seat No</th>
<th class='sb_center'>Discount(%)</th>
<th class='sb_center'>Discount Amount</th>
</tr>
</thead>
<tbody>
$tr_line
<tr>
<td style='text-align:right;font-weight:bold;' colspan='7'>Payment Mode</td>
<td style='text-align:right;font-weight:bold;'>$paytype</td>
</tr>
<tr>
<td style='text-align:right;font-weight:bold;' colspan='7'>Total Package Amount</td>
<td style='text-align:right;font-weight:bold;'>$tariffamt</td>
</tr>
$disc_tr
$admin_tr
<tr>
<td style='text-align:right;font-weight:bold;' colspan='7'>Actual Ticket Amount</td>
<td style='text-align:right;font-weight:bold;'>$act_amt</td>
</tr>
<tr>
<td style='text-align:right;font-weight:bold;' colspan='7'>Total GST(%)</td>
<td style='text-align:right;font-weight:bold;'>$servicetax(%)</td>
</tr>
<tr>
<td style='text-align:right;font-weight:bold;' colspan='7'>CGST</td>
<td style='text-align:right;font-weight:bold;'>$gst_split</td>
</tr>
<tr>
<td style='text-align:right;font-weight:bold;' colspan='7'>SGST</td>
<td style='text-align:right;font-weight:bold;'>$gst_split</td>
</tr>
<tr>
<td style='text-align:right;font-weight:bold;' colspan='7'>Ticket Amount</td>
<td style='text-align:right;font-weight:bold;'>$ticketamt</td>
</tr>
<tr>
<td style='text-align:right;font-weight:bold;' colspan='7'>Amount Paid</td>
<td style='text-align:right;font-weight:bold;'>$cashpaid</td>
</tr>
<tr>
<td style='text-align:right;font-weight:bold;' colspan='7'>Balance Amount</td>
<td style='text-align:right;font-weight:bold;'>$cashdue</td>
</tr>
</tbody>
</table>
<p> For details, rules and terms & conditions of E-Ticketing services, please visit www.sblt.co.in </p>
<h4>Cancellation Policy:</h4>
<ul style='line-height: 30px;'>
<li> The tickets booked are cancelable. Kindly note that once cancelled the money is transferred back to the respective credit/debit card. </li>
$fee_line
<li> Please contact any of our executives for complete details or enter your ticket number on the print ticket tab to read the cancellation policy for your ticket.</li>
<li> The transaction charges or the home/courier delivery charges will not be refunded in the event of ticket cancellation. </li>
<li> In case a booking confirmation e-mail and sms gets delayed or fails because of technical reasons or as a result of incorrect e-mail ID / phone number provided by the user etc, a ticket will be considered 'booked' as long as the ticket shows up on the confirmation page of www.sblt.co.in </li>
<li> In case of any clarifications, please write to tours@sblt.co.in </li>
</ul>
</div>";
}else{
$ticket_qry = mysql_query("SELECT *,sblttweb_passlist.ticketamt as ticketamt,sblttweb_passlist.cashpaid as cashpaid,sblttweb_passlist.cashdue as cashdue,sblttweb_cancelorder.cancelfee from sblttweb_passlist inner join sblttweb_cancelorder on sblttweb_cancelorder.orderid = sblttweb_passlist.cancelorderid inner join sblttweb_package on sblttweb_package.package_id = sblttweb_cancelorder.packid inner join sblttweb_customers on sblttweb_customers.custid = sblttweb_cancelorder.custid where bookorderid = '$orderid' and sblttweb_passlist.passstatus = '1'");
$i = 1;
$j=0;
$tr_line = "";
$cashpaid = 0;
$tariffamt = 0;
$ticketamt = 0;
$cashdue = 0;
$admin_tr = "";
$disc_tr = "";
while($rslt = mysql_fetch_array($ticket_qry)){
$passid = $rslt['passid'];
$pnrno = $rslt['pnrno'];
$orderid = $rslt['bookorderid'];
$cancel_id = $rslt['orderid'];
$order_date = date("d-M-Y",strtotime($rslt['orderdate']));
$pack_date = date("d-M-Y",strtotime($rslt['doj']));
$cancel_date = date("d-M-Y",strtotime($rslt['cancel_date']));
$order = $rslt['orderdate'];
$package_date = $rslt['doj'];
$nopass = $rslt['nopass'];
$custid = $rslt['custid'];
$custemail = $rslt['custemail'];
$package_title = $rslt['package_title'];
$package_title2 = $rslt['package_title2'];
$package_title3 = $rslt['package_title3'];
$cancelfee = $rslt['cancelfee'];
$cancelamt = $rslt['cancelamt'];
$passname = $rslt['passname'];
$passgender = $rslt['passgender'];
$passage = $rslt['passage'];
$seatno = $rslt['seatno'];
$passtripid = $rslt['passtripid'];
$packid = $rslt['packid'];
$cashpaid = $rslt['cashpaid'];
$cashdue += $rslt['cashdue'];
$discount = $rslt['discount'];
//$tariffamt += $rslt['tariffamt'];
$tariffamt += $rslt['tariffamt'];
$ticketamt += $rslt['ticketamt'];
$passmobile = $rslt['passmobile'];
$pack_name = $package_title." ".$package_title2." ".$package_title3;
$refund = $cashpaid - $cancelamt;
$tr_line .= "<tr>
<td>$i</td>
<td>$passname</td>
<td>$passgender</td>
<td>$passmobile</td>
<td>$passage</td>
<td>$seatno</td>
<td>$cashpaid</td>
<td>$cancelfee</td>
<td>$cancelamt</td>
<td>$refund</td>
</tr>";
$i++;
$j++;
}
//Get Cancel Fees Details
$cancel_qry = mysql_query("SELECT * from sblttweb_cancelfee where FIND_IN_SET(cancelfeeid, '$cancelfee')");
$fee_line = "";
while($cancelfee_data = mysql_fetch_array($cancel_qry)){
$cancelfeedetail = $cancelfee_data['cancelfeedetail'];
$cancelfees = $cancelfee_data['cancelfees'];
$fee_line .= "<li>If the Ticket Cancelled $cancelfeedetail then Cancel Fees will be $cancelfees % </li>";
}
$details = "<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; background-color: #FFFFFF;' border='1' cellspacing='0' cellpadding='4'>
<tr>
<td style='border-bottom:0px;border-right: 0px;'>
<img id='logo' src='$url/backend/images/logo.png' alt='sbltt'>
</td>
<td style='border-bottom:0px;border-left: 0px;'>
<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 style='width:100%;border-collapse: collapse;border-spacing: 0;border-color: #CCCCCC !important;border: 0px;font-size: 14px;background-color:#FFFFFF;' 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;'>Cancel Id </td>
<td style='font-weight: bold;'>$cancel_id</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;'>$pack_date</td>
<td style='white-space: nowrap;'>Date of Booking</td>
<td style='font-weight: bold;'>$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;'>Cancelled Date</td>
<td style='border-bottom:0px;font-weight: bold;'>$cancel_date</td>
</tr>
</table>
<table style='width:100%;border-collapse: collapse;border-spacing: 0;border-color: #CCCCCC !important;border: 0px;text-align: center;font-size: 14px; background-color: #FFFFFF;' border='1' cellspacing='0' cellpadding='4'>
<thead>
<tr style='background-color:#828181;color: #FFFFFF;font-weight:bold;'>
<th class='sb_center'>SNo</th>
<th class='sb_center'>Passenger Name</th>
<th class='sb_center'>Gender</th>
<th class='sb_center'>Mobile</th>
<th class='sb_center'>Age</th>
<th class='sb_center'>Seat No</th>
<th class='sb_center'>Paid Amount</th>
<th class='sb_center'>Cancel(%)</th>
<th class='sb_center'>Cancellation Fees</th>
<th class='sb_center'>Refund</th>
</tr>
</thead>
<tbody>
$tr_line
</tbody>
</table>
<p> For details, rules and terms & conditions of E-Ticketing services, please visit www.sblt.co.in </p>
<h4>Cancellation Policy:</h4>
<ul style='line-height: 30px;'>
<li> The tickets booked are cancelable. Kindly note that once cancelled the money is transferred back to the respective credit/debit card. </li>
$fee_line
<li> Please contact any of our executives for complete details or enter your ticket number on the print ticket tab to read the cancellation policy for your ticket.</li>
<li> The transaction charges or the home/courier delivery charges will not be refunded in the event of ticket cancellation. </li>
<li> In case a booking confirmation e-mail and sms gets delayed or fails because of technical reasons or as a result of incorrect e-mail ID / phone number provided by the user etc, a ticket will be considered 'booked' as long as the ticket shows up on the confirmation page of www.sblt.co.in </li>
<li> In case of any clarifications, please write to tours@sblt.co.in </li>
</ul>
</div>";
}
if($misc === "email"){
//Send mail to customer
if(!empty($custemail)){
require('../customers/phpmailer/class.phpmailer.php');
$mail = new PHPMailer();
$mail->IsSMTP();
$mail->Host = "smtp.gmail.com"; // Your SMTP PArameter
$mail->Port = 587; // Your Outgoing Port
$mail->SMTPAuth = true; // This Must Be True
$mail->Username = "webadmin@sblt.co.in"; // Your Email Address
$mail->Password = "webadmin123"; // Your Password
$mail->SMTPSecure = 'tls'; // Check Your Server's Connections for TLS or SSL
$mail->From = 'tours@sblt.co.in';
$mail->FromName = 'tours@sblt.co.in';
$mail->AddAddress($custemail);
$mail->IsHTML(true);
$mail->Subject="Ticket Details for Order No $orderid";
$mail->Body=$details;
$mail=$mail->Send();
//End Send mail to customer
echo json_encode(array('status' => TRUE, 'success' =>"Mail sent Successfully"));
}else{
echo json_encode(array('status' => False, 'success' =>"Server Error!"));
}
}else{
echo $details;
}
}
?>
<style type="text/css">
@media print {
.PrintOnly { display:block; }
}
</style>