# easy-invoice/2.3.4/templates/invoices/preview.php

Easy Invoice – Invoice Generator, PDF Quotes &amp; Payments, version 2.3.4. 293 lines.

- Page: https://pluginprobe.com/plugins/easy-invoice/2.3.4/code/templates/invoices/preview.php
- Raw: https://pluginprobe.com/plugins/easy-invoice/2.3.4/raw/templates/invoices/preview.php
- Modified: 2026-05-21T08:29:24+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/easy-invoice/2.3.4/code/templates/invoices/preview.php#L10-L20`.

```php
<?php
/**
 * Invoice Preview Template
 *
 * @package     EasyInvoice
 * @since       1.0.0
 */

// Get invoice data
$invoice_id = isset($_GET['invoice_id']) ? (int) $_GET['invoice_id'] : 0;
$invoice = $invoice ?? null;

if ($invoice_id <= 0 || !$invoice) {
    wp_die(__('Invoice not found.', 'easy-invoice'));
}

// Initialize formatter for currency formatting
$formatter = $invoice ? new \EasyInvoice\Helpers\InvoiceFormatter($invoice) : null;

// Get the current template (default to 'standard')
$current_template = $invoice && method_exists($invoice, 'getTemplate') ? $invoice->getTemplate() : 'standard';
if (empty($current_template)) {
    $current_template = 'standard';
}

// Get company information from settings
    $company_name = get_option('easy_invoice_company_name', __('Your Company Name', 'easy-invoice'));
    $company_address = get_option('easy_invoice_company_address', __('Your Company Address', 'easy-invoice'));
$company_email = get_option('easy_invoice_company_email', 'info@yourcompany.com');
$company_phone = get_option('easy_invoice_company_phone', '+1 (555) 123-4567');
$company_website = get_option('easy_invoice_company_website', 'www.yourcompany.com');

?>
<!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 $invoice ? esc_html($invoice->getNumber()) : 'Unknown'; ?></title>

    <script src="https://cdnjs.cloudflare.com/ajax/libs/jspdf/2.5.1/jspdf.umd.min.js"></script>

    <style>
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }

        body {
            font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
            line-height: 1.6;
            color: #333;
            background: #f8f9fa;
        }

        .invoice-container {
            max-width: 800px;
            margin: 20px auto;
            background: white;
            box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
            border-radius: 8px;
            overflow: hidden;
        }

        .invoice-header {
            background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
            color: white;
            padding: 30px;
            text-align: center;
        }

        .invoice-header h1 {
            font-size: 2.5rem;
            font-weight: 300;
            margin-bottom: 10px;
        }

        .invoice-header .invoice-number {
            font-size: 1.2rem;
            opacity: 0.9;
        }

        .invoice-content {
            padding: 40px;
        }

        .company-info {
            display: flex;
            justify-content: space-between;
            margin-bottom: 40px;
            padding-bottom: 20px;
            border-bottom: 2px solid #e9ecef;
        }

        .company-details h2 {
            color: #495057;
            font-size: 1.5rem;
            margin-bottom: 10px;
        }

        .company-details p {
            color: #6c757d;
            margin-bottom: 5px;
        }

        .client-info h3 {
            color: #495057;
            font-size: 1.2rem;
            margin-bottom: 10px;
        }

        .client-info p {
            color: #6c757d;
            margin-bottom: 5px;
        }

        .invoice-details {
            margin-bottom: 30px;
        }

        .invoice-details table {
            width: 100%;
            border-collapse: collapse;
        }

        .invoice-details th,
        .invoice-details td {
            padding: 8px;
            text-align: left;
            border-bottom: 1px solid #e9ecef;
        }

        .invoice-details th {
            background-color: #f8f9fa;
            font-weight: 600;
            color: #495057;
        }

        .items-table {
            width: 100%;
            border-collapse: collapse;
            margin-bottom: 30px;
        }

        .items-table th,
        .items-table td {
            padding: 12px 8px;
            text-align: left;
            border-bottom: 1px solid #e9ecef;
        }

        .items-table th {
            background-color: #f8f9fa;
            font-weight: 600;
            color: #495057;
        }

        .item-name {
            font-weight: 500;
            color: #495057;
        }

        .item-description {
            font-size: 0.9rem;
            color: #6c757d;
            margin-top: 4px;
        }

        .amount {
            font-weight: 600;
            color: #495057;
        }

        .totals-section {
            margin-bottom: 30px;
        }

        .totals-table {
            width: 100%;
            max-width: 300px;
            margin-left: auto;
        }

        .total-row {
            display: flex;
            justify-content: space-between;
            padding: 8px 0;
            border-bottom: 1px solid #e9ecef;
        }

        .total-row:last-child {
            border-bottom: 2px solid #495057;
            font-weight: 600;
            font-size: 1.1rem;
        }

        .notes-section {
            margin-bottom: 30px;
        }

        .notes-section h3 {
            color: #495057;
            font-size: 1.2rem;
            margin-bottom: 10px;
        }

        .notes-section p {
            color: #6c757d;
            line-height: 1.6;
        }

        .invoice-footer {
            background-color: #f8f9fa;
            padding: 20px;
            text-align: center;
            color: #6c757d;
        }

        .invoice-footer p {
            margin-bottom: 5px;
        }

        /* Print styles */
        @media print {
            body {
                background: white;
            }

            .invoice-container {
                box-shadow: none;
                margin: 0;
            }
        }
    </style>
</head>
<body>
    <div class="invoice-container">
        <?php
        // Dynamically load the selected template
        $template_file = EASY_INVOICE_PLUGIN_DIR . 'templates/invoice-templates/' . $current_template . '.php';
        if (file_exists($template_file)) {
            include_once $template_file;
        } else {
            // Fallback to standard template if selected template doesn't exist
            $template_file = EASY_INVOICE_PLUGIN_DIR . 'templates/invoice-templates/standard.php';
            if (file_exists($template_file)) {
                include_once $template_file;
            } else {
                // Show error if no template is available
                echo '<div style="padding: 40px; text-align: center;">';
                echo '<h2>Template Error</h2>';
                echo '<p>The selected template "' . esc_html($current_template) . '" could not be loaded.</p>';
                echo '</div>';
            }
        }
        ?>
    </div>

    <script>
    // Invoice data for PDF generation
    window.invoiceData = <?php
        $invoice_data = $invoice ? \EasyInvoice\Includes\Helpers\PdfHelper::getInvoiceDataForPdf($invoice) : [];
        if ($invoice) {
        $invoice_data['status'] = $invoice->getStatus();
        }
        echo json_encode($invoice_data);
    ?>;

    // Global function for downloading PDF
    function downloadInvoicePdf(invoiceId) {
        try {
            if (typeof InvoicePdfGenerator !== 'undefined') {
                // Use the new PDF generator that captures HTML directly
                const pdfGenerator = new InvoicePdfGenerator();
                pdfGenerator.generatePDF();

                // Show success message after a short delay
                setTimeout(function() {
                    alert('<?php _e('PDF generated successfully', 'easy-invoice'); ?>');
                }, 2000);
            } else {
                alert('Error: PDF generator not available');
            }
        } catch (error) {
            console.error('PDF generation error:', error);
            alert('<?php _e('Error generating PDF', 'easy-invoice'); ?>');
        }
    }
    </script>
</body>
</html>

```
