﻿window.PrintHandler = {
    print: function ()

{
    const printWindow = window.open('', '', 'height=600,width=800');
    const invoiceContent = document.querySelector('.invoice-container').outerHTML;
    printWindow .document.write(` <!DOCTYPE html> <html lang="ar" dir="rtl"> <head> <meta charset="utf-8"> <title>طباعة الفاتورة</title> <style> body {
                        font-family: Arial, sans-serif;
                        margin: 0;
                        padding: 20px;
                    } .invoice-container {
                        width: 100%;
                        max-width: 100%;
                    } .invoice-items {
                        width: 100%;
                        border-collapse: collapse;
                        margin-bottom: 20px;
                    } .invoice-items th, .invoice-items td {
                        border: 1px solid #000;
                        padding: 8px;
                        text-align: right;
                    } .invoice-items th {
                        background-color: #f0f0f0;
                    } .header {
                        text-align: center;
                        margin-bottom: 20px;
                    } .invoice-info {
                        display: flex;
                        justify-content: space-between;
                        margin-bottom: 20px;
                    } .customer-info {
                        margin-bottom: 20px;
                    } .invoice-summary {
                        margin-bottom: 20px;
                    } .payment-info {
                        margin-top: 20px;
                    } @media print {
                        body {
                            -webkit-print-color-adjust: exact !important;
                            print-color-adjust: exact !important;
                        }
                        @page {
                            size: A4;
                            margin: 1cm;
                        }
                    } </style> </head> <body> ${invoiceContent} <script> setTimeout(function() {
                        window.print();
                        window.onafterprint = function() {
                            window.close();
                        }
                    }, 500);
    </script> </body> </html> `);
    printWindow .document.close();
}

}
;
