MMCT TEAM
Server IP : 162.214.80.37  /  Your IP : 216.73.216.83
Web Server : Apache
System : Linux sh013.webhostingservices.com 4.19.286-203.ELK.el7.x86_64 #1 SMP Wed Jun 14 04:33:55 CDT 2023 x86_64
User : imyrqtmy ( 2189)
PHP Version : 8.2.18
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON
Directory (0755) :  /home2/imyrqtmy/public_html/Quickex/builty/vendor/

[  Home  ][  C0mmand  ][  Upload File  ]

Current File : /home2/imyrqtmy/public_html/Quickex/builty/vendor/generate_pdf copy.php
<?php
require_once('tcpdf/tcpdf.php');
include("inc/config.php"); // Database connection

// Get ID from URL
$id = isset($_GET['id']) ? intval($_GET['id']) : 0;

// Fetch data from the `builties` table
$query = "SELECT * FROM builties WHERE id = '$id'";
$result = mysqli_query($conn, $query);
$data = mysqli_fetch_assoc($result);


$origin = $data['origin'] ?? 'N/A';
$destination = $data['destination'] ?? 'N/A';
$origin_address = $data['origin_address'] ?? 'N/A';
$origin_gst = $data['origin_gst'] ?? 'N/A';
$origin_phone = $data['origin_phone'] ?? 'N/A';
$origin_eway = $data['origin_eway'] ?? 'N/A';
$grno = $data['grno'] ?? 'N/A';
$qacl = $data['qacl'] ?? 'N/A';
$transport_by = $data['transport_by'] ?? 'N/A';
$booking_date = $data['booking_date'] ?? 'N/A';
$booking_time = $data['booking_time'] ?? 'N/A';
$destination_address = $data['destination_address'] ?? 'N/A';
$destination_gst = $data['destination_gst'] ?? 'N/A';
$destination_phone = $data['destination_phone'] ?? 'N/A';
$destination_eway = $data['destination_eway'] ?? 'N/A';
$pkg_total = $data['pkg_total'] ?? 'N/A';
$pkg_type = $data['pkg_type'] ?? 'N/A';
$party_invoice = $data['party_invoice'] ?? 'N/A';
$saidtocontent = $data['saidtocontent'] ?? 'N/A';
$quantity = $data['quantity'] ?? 'N/A';
$gross_weight = $data['gross_weight'] ?? 'N/A';
$charge_weight = $data['charge_weight'] ?? 'N/A';
$amount = $data['amount'] ?? 'N/A';
$consignee = $data['consignee'] ?? 'N/A';
$consignor = $data['consignor'] ?? 'N/A';
$freight_rate = $data['freight_rate'] ?? 'N/A';
$freight_amount = $data['freight_amount'] ?? 'N/A';
$cod_rate = $data['cod_rate'] ?? 'N/A';
$cod_amount = $data['cod_amount'] ?? 'N/A';
$fov_rate = $data['fov_rate'] ?? 'N/A';
$fov_amount = $data['fov_amount'] ?? 'N/A';
$doc_rate = $data['doc_rate'] ?? 'N/A';
$doc_amount = $data['doc_amount'] ?? 'N/A';
$cartage_rate = $data['cartage_rate'] ?? 'N/A';
$cartage_amount = $data['cartage_amount'] ?? 'N/A';
$labour_rate = $data['labour_rate'] ?? 'N/A';
$labour_amount = $data['labour_amount'] ?? 'N/A';
$octroi_rate = $data['octroi_rate'] ?? 'N/A';
$octroi_amount = $data['octroi_amount'] ?? 'N/A';
$other_rate = $data['other_rate'] ?? 'N/A';
$other_amount = $data['other_amount'] ?? 'N/A';
$gst_rate = $data['gst_rate'] ?? 'N/A';
$gst_amount = $data['gst_amount'] ?? 'N/A';
$total_amount = $data['total_amount'] ?? 'N/A';
$delivery_detail = $data['delivery_detail'] ?? 'N/A';
$delivery_time = $data['delivery_time'] ?? 'N/A';
$ttb_origin = $data['ttb_origin'] ?? 'N/A';
$to_pay = $data['to_pay'] ?? 'N/A';
$paid = $data['paid'] ?? 'N/A';


if (!$data) {
    die("No data found for this ID.");
}

// Define copy names
$copies = ["ACCOUNTS COPY", "CONSIGNEE COPY", "CONSIGNOR COPY", "POD COPY"];

// Create new PDF document
$pdf = new TCPDF('P', 'mm', 'A4', true, 'UTF-8', false);
$pdf->SetMargins(5, 5, 5); // Reduced margins
$pdf->SetAutoPageBreak(TRUE, 5); // Minimized bottom margin
$pdf->SetFont('helvetica', '', 9); // Slightly smaller font for compact layout

foreach ($copies as $copy) {
    $pdf->AddPage(); // Ensure each copy starts on a new page

  // Company Header
$companyLogo = 'dist/images/logo.jpeg';
$makeInIndiaLogo = 'dist/images/logo.jpeg';
$companyName = "Quickex Airways & Cargo Logistics";
$companyAddress = "Plot No. A-66, Sector F1, Near Gayatri Public School, Agra-7";
$companyPhone = "+91 12345 67890";
$companyGST = "GSTIN: 12ABCDE3456F7Z8";

// Header HTML
$html = '
<table width="100%">
    <tr>
        <td width="18%" align="left"><img src="'.$companyLogo.'" width="60"></td>
        <td width="64%" align="center">
            <h2 style="font-size:10px;">'.$companyName.'</h2>
            <p style="font-size:9px;">'.$companyAddress.'<br>
            Phone: '.$companyPhone.' | '.$companyGST.'</p>
        </td>
        <td width="18%" align="right"><img src="'.$makeInIndiaLogo.'" width="60"></td>
    </tr>
</table>
<hr>';

// Invoice Details (Optimized)
$html .= '
<table border="1" cellpadding="3" width="100%">
<tr>
    <td width="20%" align="center" style="font-size:10px; color:red;">
        <strong>Love Earth <br> or <br> Leave Earth</strong>
    </td>
    <td width="25%" align="center">
        <strong>Origin:</strong> '.$origin.' <br>
        <strong>Destination:</strong> '.$destination.'
    </td>
    <td width="55%">
        <table border="1" cellpadding="3" width="100%">
            <tr><td width="50%"><strong>GR No:</strong></td><td>'.$grno.'</td></tr>
            <tr><td><strong>Booking Date:</strong></td><td>'.$booking_date.'</td></tr>
            <tr><td><strong>Mode:</strong></td><td>'.$transport_by.'</td></tr>
            <tr><td><strong>QACL:</strong></td><td>'.$qacl.'</td></tr>
            <tr><td><strong>Booking Time:</strong></td><td>'.$booking_time.'</td></tr>
        </table>
    </td>
</tr>
</table>';

// Consignor & Consignee
$html .= '<table border="1" cellspacing="0" cellpadding="3">
    <tr>
        <td width="50%">
            <strong>Consignor:</strong>'.$consignor.'<br>
            <strong>Address:</strong> '.$origin_address.'<br>
            <strong>GST No:</strong> '.$origin_gst.'<br>
            <strong>Phone No:</strong> '.$origin_phone.'<br>
            <strong>E-Way Bill No:</strong> '.$origin_eway.'
        </td>
        <td width="50%">
            <strong>Consignee:</strong> '.$consignee.'<br>
            <strong>Address:</strong> '.$destination_address.'<br>
            <strong>GST No:</strong> '.$destination_gst.'<br>
            <strong>Phone No:</strong> '.$destination_phone.'<br>
            <strong>E-Way Bill No:</strong> '.$destination_eway.'
        </td>
    </tr>
</table>';

// Package Details
$html .= '<h3>Package Details</h3>
<table border="1" cellpadding="3">
     <tr>
        <td><strong>No. of Pkgs:</strong></td>
        <td><strong>Type of Packing:</strong></td>
        <td><strong>Party Invoice No:</strong></td>
        <td><strong>Said to Contents:</strong></td>
        <td><strong>Qty:</strong></td>
        <td><strong>Gross Weight:</strong></td>
        <td><strong>Charged Weight:</strong></td>
         <td><strong>Amount:</strong></td>
    </tr>
    <tr>
        <td> '.$pkg_total.'</td>
        <td> '.$pkg_type.'</td>
        <td> '.$party_invoice.'</td>
        <td> '.$saidtocontent.'</td>
        <td> '.$quantity.'</td>
        <td> '.$gross_weight.'</td>
        <td> '.$charge_weight.'</td> <!-- Assuming Charged Weight is the same as Gross Weight -->
        <td> '.$amount.'</td>
    </tr>
</table>';

// Charges & Delivery Details
$html .= '<h3>Charges & Delivery Details</h3>
<table border="1" cellpadding="3" width="100%">
    <tr>
        <td width="50%" valign="top">
            <strong>Delivery Details: '.$delivery_detail.'</strong><br>
            <strong>Time: '.$delivery_time.'</strong><br>
            <strong>Receiver’s Signature:</strong>
        </td>
        <td width="50%" valign="top">
            <table border="1" cellpadding="3" width="100%">
               <tr>
                    <td><strong>Particulars</strong></td>
                    <td><strong>Rate</strong></td>
                    <td><strong>Amount</strong></td>
                </tr>
                <tr><td>Freight</td><td>'.$freight_rate.'</td><td>'.$freight_amount.'</td></tr>
             
                <tr><td>C.O.D</td><td>'.$cod_rate.'</td><td>'.$cod_amount.'</td></tr>
                <tr><td>F.O.V</td><td>'.$fov_rate.'</td><td>'.$fov_amount.'</td></tr>
                 <tr><td>Doc Charges</td><td>'.$doc_rate.'</td><td>'.$doc_amount.'</td></tr>
                <tr><td>Cartage</td><td>'.$cartage_rate.'</td><td>'.$cartage_amount.'</td></tr>
                <tr><td>Labour Handling</td><td>'.$labour_rate.'</td><td>'.$labour_amount.'</td></tr>
                <tr><td>Octoroi</td><td>'.$octroi_rate.'</td><td>'.$octroi_amount.'</td></tr>
                <tr><td>Any Other Charges</td><td>'.$other_rate.'</td><td>'.$other_amount.'</td></tr>
                <tr><td>GST</td><td>'.$gst_rate.'</td><td>'.$gst_amount.'</td></tr>
                <tr><td><strong>Total</strong></td><td>-</td><td><strong>'.$total_amount.'</strong></td></tr>
            </table>
        </td>
    </tr>
</table>';

$html .= '<table border="1" cellpadding="5" width="100%">
    <tr>
        <td width="33%" align="center" valign="top">
            <table border width="100%">
                <tr><td align="left"><strong>TTB at Origin</strong></td></tr>
                <tr><td align="left"><strong>To Pay</strong></td></tr>
                <tr><td align="left"><strong>Paid</strong></td></tr>
            </table>
        </td>
        <td width="33%" align="center" valign="middle">
            <strong>Consignor Signature</strong>
        </td>

        <td width="34%" align="center" valign="top">
            <table border width="100%">
                <tr><td align="left"><strong>Rs in Words:</strong></td></tr>
                <tr><td align="left"><strong>For:</strong></td></tr>
                <tr><td align="left"><strong>Signature</strong></td></tr>
            </table>
        </td>
      
    </tr>
</table>

    <hr>
    <h3 align="center">'.$copy.'</h3>'; // Copy type as heading




// Terms & Conditions
$html .= '<h3>Terms and Conditions</h3>
<p>1. Not liable for leakage, shortage, or breakage.</p>
<p>2. Billing based on volumetric or actual weight.</p>
<p>3. Complaints must be raised within 10 days.</p>
<p align="right"><strong>For Quickex Airways</strong></p>';
    // Write content to PDF
    $pdf->writeHTML($html, true, false, true, false, '');

    // Footer (Page number and Copy Type)
    $pdf->SetY(-15);
    $pdf->SetFont('helvetica', 'I', 9);
    $pdf->Cell(0, 10, $copy . " | Page " . $pdf->getAliasNumPage() . " of " . $pdf->getAliasNbPages(), 0, 0, 'C');
}

// Output single PDF with all copies
$pdf->Output('logistics_invoice.pdf', 'I');
?>

MMCT - 2023