\EasyInvoice\Controllers\SettingsController::getTextInvoiceNumber(), 'invoice_date' => \EasyInvoice\Controllers\SettingsController::getTextInvoiceDate(), 'due_date' => \EasyInvoice\Controllers\SettingsController::getTextDueDate(), 'total_due' => \EasyInvoice\Controllers\SettingsController::getTextTotalDue(), // Quote specific 'quote_number' => \EasyInvoice\Controllers\SettingsController::getTextQuoteNumber(), 'quote_date' => \EasyInvoice\Controllers\SettingsController::getTextQuoteDate(), 'valid_until' => \EasyInvoice\Controllers\SettingsController::getTextValidUntil(), // Common labels 'to' => \EasyInvoice\Controllers\SettingsController::getTextTo(), 'service' => \EasyInvoice\Controllers\SettingsController::getTextService(), 'qty' => \EasyInvoice\Controllers\SettingsController::getTextQty(), 'rate_price' => \EasyInvoice\Controllers\SettingsController::getTextRatePrice(), 'adjust' => \EasyInvoice\Controllers\SettingsController::getTextAdjust(), 'sub_total' => \EasyInvoice\Controllers\SettingsController::getTextSubTotal(), 'total' => \EasyInvoice\Controllers\SettingsController::getTextTotal(), 'tax' => \EasyInvoice\Controllers\SettingsController::getTextTax(), 'discount' => \EasyInvoice\Controllers\SettingsController::getTextDiscount(), // Button labels 'print' => \EasyInvoice\Controllers\SettingsController::getTextPrint(), 'download_pdf' => \EasyInvoice\Controllers\SettingsController::getTextDownloadPdf(), 'send_email' => \EasyInvoice\Controllers\SettingsController::getTextSendEmail(), 'pay_now' => \EasyInvoice\Controllers\SettingsController::getTextPayNow(), 'accept_quote' => \EasyInvoice\Controllers\SettingsController::getTextAcceptQuote(), 'decline_quote' => \EasyInvoice\Controllers\SettingsController::getTextDeclineQuote(), 'decline_reason' => \EasyInvoice\Controllers\SettingsController::getTextDeclineReason(), ]; } /** * Get company information from settings * * @return array Company information */ public static function getCompanyInfo(): array { $info = [ 'name' => get_option('easy_invoice_company_name', 'Your Company Name'), 'address' => get_option('easy_invoice_company_address', ''), 'email' => get_option('easy_invoice_company_email', ''), 'phone' => get_option('easy_invoice_company_phone', ''), 'website' => get_option('easy_invoice_company_website', ''), 'logo' => get_option('easy_invoice_company_logo', ''), 'tax_number' => get_option('easy_invoice_tax_number', ''), ]; /** * Filter the resolved company info used by invoice/quote templates * and PDF generation. The White-Label addon hooks this to replace * the logo with its branded header image without forcing every * admin to also see the white-label logo on their settings page. * * @param array $info Resolved company info. */ return apply_filters('easy_invoice_template_company_info', $info); } /** * Get invoice specific text settings * * @return array Invoice text settings */ public static function getInvoiceTextSettings(): array { return [ 'invoice_number' => \EasyInvoice\Controllers\SettingsController::getTextInvoiceNumber(), 'invoice_date' => \EasyInvoice\Controllers\SettingsController::getTextInvoiceDate(), 'due_date' => \EasyInvoice\Controllers\SettingsController::getTextDueDate(), 'total_due' => \EasyInvoice\Controllers\SettingsController::getTextTotalDue(), 'to' => \EasyInvoice\Controllers\SettingsController::getTextTo(), 'service' => \EasyInvoice\Controllers\SettingsController::getTextService(), 'qty' => \EasyInvoice\Controllers\SettingsController::getTextQty(), 'rate_price' => \EasyInvoice\Controllers\SettingsController::getTextRatePrice(), 'adjust' => \EasyInvoice\Controllers\SettingsController::getTextAdjust(), 'sub_total' => \EasyInvoice\Controllers\SettingsController::getTextSubTotal(), 'total' => \EasyInvoice\Controllers\SettingsController::getTextTotal(), 'tax' => \EasyInvoice\Controllers\SettingsController::getTextTax(), 'discount' => \EasyInvoice\Controllers\SettingsController::getTextDiscount(), 'print' => \EasyInvoice\Controllers\SettingsController::getTextPrint(), 'download_pdf' => \EasyInvoice\Controllers\SettingsController::getTextDownloadPdf(), 'send_email' => \EasyInvoice\Controllers\SettingsController::getTextSendEmail(), 'pay_now' => \EasyInvoice\Controllers\SettingsController::getTextPayNow(), ]; } /** * Get quote specific text settings * * @return array Quote text settings */ public static function getQuoteTextSettings(): array { return [ 'quote_number' => \EasyInvoice\Controllers\SettingsController::getTextQuoteNumber(), 'quote_date' => \EasyInvoice\Controllers\SettingsController::getTextQuoteDate(), 'valid_until' => \EasyInvoice\Controllers\SettingsController::getTextValidUntil(), 'to' => \EasyInvoice\Controllers\SettingsController::getTextTo(), 'service' => \EasyInvoice\Controllers\SettingsController::getTextService(), 'qty' => \EasyInvoice\Controllers\SettingsController::getTextQty(), 'rate_price' => \EasyInvoice\Controllers\SettingsController::getTextRatePrice(), 'adjust' => \EasyInvoice\Controllers\SettingsController::getTextAdjust(), 'sub_total' => \EasyInvoice\Controllers\SettingsController::getTextSubTotal(), 'total' => \EasyInvoice\Controllers\SettingsController::getTextTotal(), 'tax' => \EasyInvoice\Controllers\SettingsController::getTextTax(), 'discount' => \EasyInvoice\Controllers\SettingsController::getTextDiscount(), 'print' => \EasyInvoice\Controllers\SettingsController::getTextPrint(), 'download_pdf' => \EasyInvoice\Controllers\SettingsController::getTextDownloadPdf(), 'send_email' => \EasyInvoice\Controllers\SettingsController::getTextSendEmail(), 'accept_quote' => \EasyInvoice\Controllers\SettingsController::getTextAcceptQuote(), 'decline_quote' => \EasyInvoice\Controllers\SettingsController::getTextDeclineQuote(), 'decline_reason' => \EasyInvoice\Controllers\SettingsController::getTextDeclineReason(), ]; } /** * Generate "From" section content for templates * * @param array $company_info Company information array * @param bool $show_label Whether to show the "From" label * @param string $style Style variant for the "From" section * @return string Generated HTML for "From" section */ public static function generateFromSection($company_info, $show_label = true, $style = 'default'): string { $output = ''; switch ($style) { case 'minimal': // Minimal style - includes company name and details $output .= '
'; $output .= '
' . esc_html($company_info['name']) . '
'; if ($company_info['address']) { $output .= '
' . nl2br(esc_html($company_info['address'])) . '
'; } if ($company_info['email']) { $output .= '
' . esc_html($company_info['email']) . '
'; } if ($company_info['phone']) { $output .= '
' . esc_html($company_info['phone']) . '
'; } if ($company_info['website']) { $output .= '
' . esc_html($company_info['website']) . '
'; } $output .= '
'; break; case 'details-only': // Details only style - excludes company name (for use with separate company-name div) $output .= '
'; if ($company_info['address']) { $output .= '
' . nl2br(esc_html($company_info['address'])) . '
'; } if ($company_info['email']) { $output .= '
' . esc_html($company_info['email']) . '
'; } if ($company_info['phone']) { $output .= '
' . esc_html($company_info['phone']) . '
'; } if ($company_info['website']) { $output .= '
' . esc_html($company_info['website']) . '
'; } $output .= '
'; break; case 'elegant': // Elegant style - subtle design $output .= '
'; if ($show_label) { $output .= '

' . esc_html(\EasyInvoice\Controllers\SettingsController::getTextFrom()) . '

'; } $output .= '
'; $output .= '
' . esc_html($company_info['name']) . '
'; if ($company_info['address']) { $output .= '
' . nl2br(esc_html($company_info['address'])) . '
'; } if ($company_info['email']) { $output .= '
' . esc_html($company_info['email']) . '
'; } if ($company_info['phone']) { $output .= '
' . esc_html($company_info['phone']) . '
'; } if ($company_info['website']) { $output .= '
' . esc_html($company_info['website']) . '
'; } $output .= '
'; $output .= '
'; break; case 'modern': // Modern style - clean and bold $output .= '
'; if ($show_label) { $output .= '

' . esc_html(\EasyInvoice\Controllers\SettingsController::getTextFrom()) . ':

'; } $output .= '
'; $output .= '
' . esc_html($company_info['name']) . '
'; if ($company_info['address']) { $output .= nl2br(esc_html($company_info['address'])) . '
'; } if ($company_info['email']) { $output .= esc_html($company_info['email']) . '
'; } if ($company_info['phone']) { $output .= esc_html($company_info['phone']) . '
'; } if ($company_info['website']) { $output .= esc_html($company_info['website']); } $output .= '
'; $output .= '
'; break; case 'professional': // Professional style - structured layout $output .= '
'; if ($show_label) { $output .= '

' . esc_html(\EasyInvoice\Controllers\SettingsController::getTextFrom()) . ':

'; } $output .= '
'; $output .= '
' . esc_html($company_info['name']) . '
'; if ($company_info['address']) { $output .= nl2br(esc_html($company_info['address'])) . '
'; } if ($company_info['email']) { $output .= esc_html($company_info['email']) . '
'; } if ($company_info['phone']) { $output .= esc_html($company_info['phone']) . '
'; } if ($company_info['website']) { $output .= esc_html($company_info['website']); } $output .= '
'; $output .= '
'; break; case 'creative': // Creative style - artistic design $output .= '
'; if ($show_label) { $output .= '

' . esc_html(\EasyInvoice\Controllers\SettingsController::getTextFrom()) . '

'; } $output .= '
'; $output .= '
' . esc_html($company_info['name']) . '
'; if ($company_info['address']) { $output .= nl2br(esc_html($company_info['address'])) . '
'; } if ($company_info['email']) { $output .= esc_html($company_info['email']) . '
'; } if ($company_info['phone']) { $output .= esc_html($company_info['phone']) . '
'; } if ($company_info['website']) { $output .= esc_html($company_info['website']); } $output .= '
'; $output .= '
'; break; default: // Default style - standard layout $output .= '
'; if ($show_label) { $output .= '

' . esc_html(\EasyInvoice\Controllers\SettingsController::getTextFrom()) . ':

'; } $output .= '
'; $output .= '
' . esc_html($company_info['name']) . '
'; if ($company_info['address']) { $output .= nl2br(esc_html($company_info['address'])) . '
'; } if ($company_info['email']) { $output .= esc_html($company_info['email']) . '
'; } if ($company_info['phone']) { $output .= esc_html($company_info['phone']) . '
'; } if ($company_info['website']) { $output .= esc_html($company_info['website']); } $output .= '
'; $output .= '
'; break; } return $output; } /** * Generate totals section for invoice/quote templates * * @param mixed $document Invoice or Quote object * @param array $text_settings Text settings array * @param mixed $formatter Formatter object * @param string $type 'invoice' or 'quote' * @return string Generated HTML for totals section */ public static function generateTotalsSection($document, array $text_settings, $formatter, string $type = 'invoice'): string { $output = ''; // Subtotal $output .= '
'; $output .= '' . esc_html($text_settings['sub_total']) . ':'; $output .= '' . esc_html($formatter->format($document->getSubtotal())) . ''; $output .= '
'; // Discount (if any) if ($document->getDiscountAmount() > 0) { $output .= '
'; $output .= '' . esc_html($text_settings['discount']); if ($document->getDiscountType() === 'percentage') { $output .= ' (' . esc_html($document->getDiscountValue()) . '%)'; } $output .= ':'; $output .= '-' . esc_html($formatter->format($document->getDiscountAmount())) . ''; $output .= '
'; } // Tax (if any) if ($document->getTaxAmount() > 0) { $output .= '
'; $output .= '' . esc_html(easy_invoice_get_tax_name()); $output .= ' (' . esc_html($document->getTaxRate()) . '%):'; $output .= '' . esc_html($formatter->format($document->getTaxAmount())) . ''; $output .= '
'; } // Allow plugins to add content if ($type === 'invoice') { do_action('easy_invoice_invoice_totals_after_tax', $document); do_action('easy_invoice_invoice_totals_after_discount', $document); } else { do_action('easy_invoice_quote_totals_after_tax', $document); do_action('easy_invoice_quote_totals_after_discount', $document); } // Grand Total $output .= '
'; $output .= '' . esc_html($text_settings['total']) . ':'; $output .= '' . esc_html($formatter->format($document->getTotal())) . ''; $output .= '
'; return $output; } }