Файловый менеджер - Редактировать - /home/d46091/invoice.ecogenix.in/print_challan_invoice.php
Назад
<?php // print_invoice.php - Displays an invoice for printing require_once('includes/connection.php'); // Check if invoice ID is provided if (!isset($_GET['id']) || empty($_GET['id'])) { die("Invoice ID is required"); } $invoiceId = intval($_GET['id']); // Get invoice header $sql = "SELECT * FROM challan_invoices WHERE id = ?"; $stmt = $conn->prepare($sql); $stmt->bind_param("i", $invoiceId); $stmt->execute(); $result = $stmt->get_result(); if ($result->num_rows === 0) { die("Invoice not found"); } $invoice = $result->fetch_assoc(); // Get invoice items $sql = "SELECT * FROM challan_invoice_items WHERE invoice_id = ? ORDER BY id ASC"; $stmt = $conn->prepare($sql); $stmt->bind_param("i", $invoiceId); $stmt->execute(); $itemsResult = $stmt->get_result(); $items = []; while ($row = $itemsResult->fetch_assoc()) { $items[] = $row; } ?> <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Invoice #<?php echo htmlspecialchars($invoice['invoice_no']); ?></title> <style> body { font-family: "DejaVu Sans", Arial, Helvetica, sans-serif; margin: 0; padding: 20px; background-color: #fff; /* White background is better for print */ } .invoice-container { background-color: white; padding: 20px; border-radius: 5px; box-shadow: 0 0 10px rgba(0, 0, 0, 0.1); max-width: 800px; margin: 0 auto; } .invoice-header { text-align: center; margin-bottom: 20px; } .invoice-details { display: flex; margin-bottom: 20px; } .invoice-details .left { flex: 1; } .invoice-details .right { flex: 1; } .invoice-details table { width: 100%; border-collapse: collapse; } .invoice-details td { padding: 5px; border: 1px solid #ddd; } .invoice-items { margin-bottom: 20px; } .invoice-items table { width: 100%; border-collapse: collapse; } .invoice-items th, .invoice-items td { border: 1px solid #ddd; padding: 8px; text-align: left; } .invoice-items th { background-color: #f2f2f2; } .invoice-footer { margin-top: 20px; display: flex; justify-content: space-between; } .invoice-total { font-weight: bold; font-size: 18px; text-align: right; margin-top: 10px; } .print-button { text-align: center; margin-top: 20px; } .print-button button { padding: 10px 20px; background-color: #4CAF50; color: white; border: none; border-radius: 4px; cursor: pointer; font-size: 16px; } .print-button button:hover { background-color: #45a049; } @media print { .print-button { display: none; } body { background-color: white; padding: 0; } .invoice-container { box-shadow: none; padding: 0; } } </style> </head> <body> <div class="print-button"> <button onclick="window.print()">Print Invoice</button> <button onclick="window.location.href='view_invoices.php'">Back to Invoices</button> </div> <div class="invoice-container"> <div class="invoice-header"> <h1>BILL OF SUPPLY</h1> </div> <div class="invoice-details"> <table class="table table-bordered"> <tr> <td colspan="4" rowspan="2"> <strong><?php echo htmlspecialchars($invoice['consignor_name']); ?></strong><br> <?php echo nl2br(htmlspecialchars($invoice['consignor_address'])); ?><br> Pincode - <?php echo htmlspecialchars($invoice['consignor_pincode']); ?><br> Mob: <?php echo htmlspecialchars($invoice['consignor_phone']); ?> </td> <td><strong>Invoice No:</strong><br><?php echo htmlspecialchars($invoice['invoice_no']); ?></td> <td><strong>Dated:</strong><br><?php echo htmlspecialchars($invoice['invoice_date']); ?></td> </tr> <tr> <td><strong>Delivery Note:</strong><br><?php echo htmlspecialchars($invoice['delivery_note']); ?></td> <td><strong>Mode/Terms of Payment:</strong><br><?php echo htmlspecialchars($invoice['payment_terms']); ?></td> </tr> <tr> <td colspan="4" rowspan="2"> <p style="margin-top: -17px;"> <strong>Consignee (Ship to):</strong><br> <?php echo htmlspecialchars($invoice['consignee_name']); ?><br> <?php echo nl2br(htmlspecialchars($invoice['consignee_address'])); ?> </p> </td> <td><strong>Buyer's Order No:</strong><br><?php echo htmlspecialchars($invoice['buyer_order_no']); ?></td> <td><strong>Dated:</strong><br><?php echo htmlspecialchars($invoice['buyer_order_date']); ?></td> </tr> <tr> <td><strong>Reference No. & Date:</strong><br><?php echo htmlspecialchars($invoice['reference_no']); ?></td> <td><strong>Other References:</strong><br><?php echo htmlspecialchars($invoice['other_references']); ?></td> </tr> <tr> <td colspan="4" rowspan="3"> <p style="margin-top: -17px;"> <strong>Buyer (Bill to):</strong><br> <?php echo htmlspecialchars($invoice['buyer_name']); ?><br> <?php echo nl2br(htmlspecialchars($invoice['buyer_address'])); ?> </p> </td> <td><strong>Dispatch Doc No:</strong><br><?php echo htmlspecialchars($invoice['dispatch_doc_no']); ?></td> <td><strong>Delivery Note Date:</strong><br><?php echo htmlspecialchars($invoice['delivery_note_date']); ?></td> </tr> <tr> <td><strong>Dispatched through:</strong><br><?php echo htmlspecialchars($invoice['dispatched_through']); ?></td> <td><strong>Destination:</strong><br><?php echo htmlspecialchars($invoice['destination']); ?></td> </tr> </table> </div> <div class="invoice-items"> <?php // Loop over each item if you have only one row with CSV values foreach ($items as $item) { $challanNosArray = array_map('trim', explode(',', $item['challanNos'])); $vehicleNosArray = array_map('trim', explode(',', $item['vehicleNos'])); $datesArray = array_map('trim', explode(',', $item['dates'])); $weightsArray = array_map('trim', explode(',', $item['weight'])); $w_o_noArray = array_map('trim', explode(',', $item['w_o_no'])); $ratesArray = array_map('trim', explode(',', $item['rate'])); $sub_totalsArray = array_map('trim', explode(',', $item['sub_total'])); $count = max(count($challanNosArray), count($datesArray), count($weightsArray), count($w_o_noArray), count($ratesArray), count($sub_totalsArray), count($vehicleNosArray)); ?> <table border="1" cellpadding="8" cellspacing="0"> <thead> <tr> <th>Challan No</th> <th>Challan Date</th> <th>Vehicle No.</th> <th>Weight (Kg)</th> <th>Work Order No.</th> <th>Rate</th> <th>subTotal</th> </tr> </thead> <tbody> <?php for ($i = 0; $i < $count; $i++): ?> <tr> <td><?php echo htmlspecialchars($challanNosArray[$i] ?? ''); ?></td> <td><?php echo htmlspecialchars($datesArray[$i] ?? ''); ?></td> <td><?php echo htmlspecialchars($vehicleNosArray[$i] ?? ''); ?></td> <td><?php echo htmlspecialchars($weightsArray[$i] ?? ''); ?></td> <td><?php echo htmlspecialchars($w_o_noArray[$i] ?? ''); ?></td> <td><?php echo htmlspecialchars($ratesArray[$i] ?? ''); ?></td> <td><?php echo htmlspecialchars($sub_totalsArray[$i] ?? ''); ?></td> </tr> <?php endfor; ?> </tbody> <tfoot> <tr> <th colspan="3">Total</th> <td><?php echo htmlspecialchars($invoice['total_qty']); ?></td> <th></th> <td><?php echo htmlspecialchars($invoice['total_rate']); ?></td> <td><?php echo htmlspecialchars($invoice['total_amount']); ?></td> </tr> </tfoot> </table> <?php } ?> </div> <div> <!-- <p><strong>Remarks:</strong><br> <?php echo nl2br(htmlspecialchars($invoice['remarks'])); ?></p> --> <p><strong>Declaration:</strong><br> <?php echo nl2br(htmlspecialchars($invoice['declaration'])); ?></p> </div> <div class="invoice-footer"> <div class="left"> <!-- Any additional information can go here --> </div> <div class="right"> <p>for <?php echo htmlspecialchars($invoice['consignor_name']); ?></p> <br><br> <p>Authorised Signatory</p> </div> </div> </div> </body> </html>
| ver. 1.4 |
Github
|
.
| PHP 8.1.32 | Генерация страницы: 0 |
proxy
|
phpinfo
|
Настройка