DMD Solution
2467 Faye Rd. Suite 4 Jacksonville, Florida 32226
https://dmdsol.com/
Website Order Invoice
Invoice Number INV-000002
Invoice Date 08/31/2025
Due Date 08/31/2025
Service Qty Rate Adjust (%) Total
Software Development
Development cost
1 $150.00 $150.00
Banner Design
Homepage Banner for the website
1 $30.00 $30.00
Sub Total:$180.00
Total:$180.00

Terms & Conditions:

Payment is due within 30 days from date of invoice
`; // Write the content to the new window printWindow.document.write(printHTML); printWindow.document.close(); // Wait for content to load, then print printWindow.onload = function() { setTimeout(function() { printWindow.print(); printWindow.close(); }, 500); }; } function downloadInvoicePdf(invoiceId) { // Show loading state const button = event.target; const originalText = button.innerHTML; button.innerHTML = 'Generating PDF...'; button.disabled = true; try { // Use the unified PDF generator if (typeof DocumentPdfGenerator !== 'undefined') { const pdfGenerator = new DocumentPdfGenerator('invoice'); pdfGenerator.generatePDF(); } else { // Fallback if PDF generator not available if (typeof EasyInvoiceToast !== 'undefined') { EasyInvoiceToast.error('PDF generator not available'); } else { alert('PDF generator not available'); } } } catch (error) { console.error('PDF generation error:', error); if (typeof EasyInvoiceToast !== 'undefined') { EasyInvoiceToast.error('Error generating PDF'); } else { alert('Error generating PDF'); } } // Reset button state setTimeout(function() { button.innerHTML = originalText; button.disabled = false; }, 1000); } function sendInvoiceEmail(invoiceId) { // Show loading state const button = event.target; const originalText = button.innerHTML; button.innerHTML = 'Sending...'; button.disabled = true; // Make AJAX request jQuery.ajax({ url: 'https://dmdsol.com/wp-admin/admin-ajax.php', type: 'POST', data: { action: 'easy_invoice_send_invoice_email', invoice_id: invoiceId, nonce: 'c5970677e0' }, success: function(response) { if (response.success) { if (typeof EasyInvoiceToast !== 'undefined') { EasyInvoiceToast.success('Invoice sent successfully'); } else { alert('Invoice sent successfully'); } } else { if (typeof EasyInvoiceToast !== 'undefined') { EasyInvoiceToast.error(response.data || 'Error sending invoice'); } else { alert(response.data || 'Error sending invoice'); } } }, error: function() { if (typeof EasyInvoiceToast !== 'undefined') { EasyInvoiceToast.error('Network error occurred'); } else { alert('Network error occurred'); } }, complete: function() { // Reset button state button.innerHTML = originalText; button.disabled = false; } }); } // Modal System and Event Listeners document.addEventListener('DOMContentLoaded', function() { const invoiceId = '8203'; // Utility: Show loading spinner in a button function setButtonLoading(btn, loadingText) { btn.disabled = true; btn.innerHTML = ` ${loadingText}`; } function resetButtonLoading(btn, originalText) { btn.disabled = false; btn.innerHTML = originalText; } // Send Email Button const emailButton = document.querySelector('.send-email-button'); if (emailButton) { emailButton.addEventListener('click', function() { const message = 'Send this invoice via email?\n\nThis will send the invoice to the client\'s email address.'; showConfirmationModal( 'Send Email', message, 'Send Email', 'Cancel', 'primary', function(modal, confirmBtn, originalText) { handleSendEmail(invoiceId, confirmBtn, originalText); } ); }); } // Custom Modal System function showConfirmationModal(title, message, confirmText, cancelText, confirmType, onConfirm) { // Remove existing modal if any const existingModal = document.querySelector('.ei-modal-overlay'); if (existingModal) { existingModal.remove(); } // Create modal overlay const overlay = document.createElement('div'); overlay.className = 'ei-modal-overlay'; // Create modal content const modal = document.createElement('div'); modal.className = 'ei-modal'; const confirmBtnClass = confirmType === 'danger' ? 'ei-modal-btn-danger' : 'ei-modal-btn-primary'; const iconClass = confirmType === 'danger' ? 'danger' : 'info'; const icon = confirmType === 'danger' ? '' : ''; modal.innerHTML = `
${icon}

${title}

${message}
`; overlay.appendChild(modal); document.body.appendChild(overlay); // Show modal with animation setTimeout(() => { overlay.classList.add('show'); modal.classList.add('show'); }, 10); // Handle button clicks const confirmBtn = modal.querySelector('#modal-confirm'); const cancelBtn = modal.querySelector('#modal-cancel'); confirmBtn.addEventListener('click', function() { const originalText = confirmBtn.innerHTML; setButtonLoading(confirmBtn, confirmBtn.textContent.trim()); onConfirm(modal, confirmBtn, originalText); }); cancelBtn.addEventListener('click', function() { hideModal(overlay); }); // Handle overlay click to close overlay.addEventListener('click', function(e) { if (e.target === overlay) { hideModal(overlay); } }); // Handle escape key const handleEscape = function(e) { if (e.key === 'Escape') { hideModal(overlay); document.removeEventListener('keydown', handleEscape); } }; document.addEventListener('keydown', handleEscape); // Focus on confirm button setTimeout(() => { confirmBtn.focus(); }, 100); } function hideModal(overlay) { const modal = overlay.querySelector('.ei-modal'); modal.classList.remove('show'); overlay.classList.remove('show'); setTimeout(() => { if (overlay.parentNode) { overlay.remove(); } }, 300); } // Show message in modal (used for AJAX responses) function showModalMessage(type, message, onClose) { // Remove existing modal if any const existingModal = document.querySelector('.ei-modal-overlay'); if (existingModal) { existingModal.remove(); } // Create modal overlay const overlay = document.createElement('div'); overlay.className = 'ei-modal-overlay'; // Create modal content const modal = document.createElement('div'); modal.className = 'ei-modal'; const iconClass = type === 'success' ? 'info' : 'danger'; const icon = type === 'success' ? '' : ''; modal.innerHTML = `
${icon}

${type === 'success' ? 'Success' : 'Error'}

${message}
`; overlay.appendChild(modal); document.body.appendChild(overlay); setTimeout(() => { overlay.classList.add('show'); modal.classList.add('show'); }, 10); const closeBtn = modal.querySelector('#modal-close'); closeBtn.addEventListener('click', function() { hideModal(overlay); if (onClose) onClose(); }); overlay.addEventListener('click', function(e) { if (e.target === overlay) { hideModal(overlay); if (onClose) onClose(); } }); const handleEscape = function(e) { if (e.key === 'Escape') { hideModal(overlay); document.removeEventListener('keydown', handleEscape); if (onClose) onClose(); } }; document.addEventListener('keydown', handleEscape); setTimeout(() => { closeBtn.focus(); }, 100); } // Show loading state in modal function showModalLoading(message) { // Remove existing modal if any const existingModal = document.querySelector('.ei-modal-overlay'); if (existingModal) { existingModal.remove(); } // Create modal overlay const overlay = document.createElement('div'); overlay.className = 'ei-modal-overlay'; // Create modal content const modal = document.createElement('div'); modal.className = 'ei-modal'; modal.innerHTML = `

Please wait...

${message}
`; overlay.appendChild(modal); document.body.appendChild(overlay); setTimeout(() => { overlay.classList.add('show'); modal.classList.add('show'); }, 10); } // Handle Send Email function handleSendEmail(invoiceId, confirmBtn, originalText) { showModalLoading('Sending email...'); jQuery.ajax({ url: 'https://dmdsol.com/wp-admin/admin-ajax.php', type: 'POST', data: { action: 'easy_invoice_send_invoice_email', invoice_id: invoiceId, nonce: '7e490f5372' }, success: function(response) { if (response.success) { var msg = (response && response.data && (response.data.message || (response.data.toast && response.data.toast.message))) || 'Email sent successfully'; showModalMessage('success', msg); } else { // Handle both response.data.message and response.data (direct string) var msg = ''; if (response && response.data) { if (response.data.message) { msg = response.data.message; } else if (typeof response.data === 'string') { msg = response.data; } else if (response.data.toast && response.data.toast.message) { msg = response.data.toast.message; } } msg = msg || 'Error sending email'; resetButtonLoading(confirmBtn, originalText); showModalMessage('error', msg); } }, error: function() { resetButtonLoading(confirmBtn, originalText); showModalMessage('error', 'Error connecting to server'); } }); } });