| @@ -3,9 +3,13 @@ | ||
| 3 | 3 | * Minimal Template - Clean & Simple Design |
| 4 | 4 | * Minimal, clean, and simple invoice template |
| 5 | 5 | */ |
| 6 | 6 | |
| 7 | -$text_settings = \EasyInvoice\Helpers\TemplateTextHelper::getInvoiceTextSettings(); | |
| 7 | +if ( ! defined( 'ABSPATH' ) ) { | |
| 8 | + exit; | |
| 9 | +} | |
| 10 | +$text_settings = \EasyInvoice\Helpers\TemplateTextHelper::forDocument(\EasyInvoice\Helpers\TemplateTextHelper::getInvoiceTextSettings(), $invoice); | |
| 11 | +$ei_is_credit_note = \EasyInvoice\Helpers\TemplateTextHelper::isCreditNote($invoice); | |
| 8 | 12 | $company_info = \EasyInvoice\Helpers\TemplateTextHelper::getCompanyInfo(); |
| 9 | 13 | ?> |
| 10 | 14 | <style> |
| 11 | 15 | /* Minimal Template - Clean & Simple Design */ |
| @@ -262,9 +266,9 @@ | ||
| 262 | 266 | font-weight: 600; |
| 263 | 267 | color: var(--text-primary); |
| 264 | 268 | } |
| 265 | 269 | |
| 266 | -.template-minimal .invoice-grand-total { | |
| 270 | +.template-minimal .invoice-totals .invoice-grand-total { | |
| 267 | 271 | font-size: var(--font-size-lg); |
| 268 | 272 | font-weight: 700; |
| 269 | 273 | color: var(--text-primary); |
| 270 | 274 | border-top: 2px solid var(--border-color); |
| @@ -369,27 +373,63 @@ | ||
| 369 | 373 | .template-minimal .invoice-totals { |
| 370 | 374 | width: 100%; |
| 371 | 375 | } |
| 372 | 376 | } |
| 377 | + | |
| 378 | +/* Shared polish: numbers line up, numeric headings sit over their figures. */ | |
| 379 | +.template-minimal .invoice-items th + th { text-align: right; } | |
| 380 | +.template-minimal .invoice-items .item-quantity, | |
| 381 | +.template-minimal .invoice-items .item-price, | |
| 382 | +.template-minimal .invoice-items .item-adjust, | |
| 383 | +.template-minimal .invoice-items .item-total, | |
| 384 | +.template-minimal .invoice-total-value { font-variant-numeric: tabular-nums; white-space: nowrap; } | |
| 385 | +.template-minimal .meta-value { white-space: nowrap; } | |
| 386 | +.template-minimal .invoice-items .item-adjust { text-align: right; } | |
| 387 | +.template-minimal .client-contact { font-weight: 500; margin-bottom: 0.15em; } | |
| 388 | +.template-minimal .client-tax-number, | |
| 389 | +.template-minimal .company-tax-number { margin-top: 0.35em; } | |
| 390 | +.template-minimal .invoice-items .item-description { white-space: pre-line; } | |
| 391 | +.template-minimal .document-kind { display: block; font-size: 0.72rem; font-weight: 600; letter-spacing: 0.16em; text-transform: uppercase; color: var(--text-muted, #8a8a8a); font-family: var(--font-family-body, inherit); font-style: normal; margin-bottom: 0.3em; line-height: 1.2; } | |
| 392 | + | |
| 393 | +/* Minimal: hairlines only — no filled panels anywhere. */ | |
| 394 | +.template-minimal .invoice-header { margin-bottom: var(--spacing-8); padding-bottom: var(--spacing-6); border-bottom: 1px solid var(--border-color); } | |
| 395 | +.template-minimal .address-section { margin-bottom: var(--spacing-8); } | |
| 396 | +.template-minimal .address-block h2 { font-size: var(--font-size-xs); text-transform: uppercase; letter-spacing: 0.14em; color: var(--text-muted); font-weight: 600; margin-bottom: var(--spacing-2); } | |
| 397 | +.template-minimal .invoice-items { border: 0; margin-bottom: var(--spacing-6); } | |
| 398 | +.template-minimal .invoice-items th { background: transparent; color: var(--text-muted); font-size: var(--font-size-xs); text-transform: uppercase; letter-spacing: 0.12em; padding: var(--spacing-2) var(--spacing-3); border-bottom: 1px solid var(--text-primary); } | |
| 399 | +.template-minimal .invoice-items td { padding: var(--spacing-4) var(--spacing-3); } | |
| 400 | +.template-minimal .invoice-items th:first-child, .template-minimal .invoice-items td:first-child { padding-left: 0; } | |
| 401 | +.template-minimal .invoice-items th:last-child, .template-minimal .invoice-items td:last-child { padding-right: 0; } | |
| 402 | +.template-minimal .invoice-totals { background: transparent; border: 0; padding: 0; width: 320px; } | |
| 403 | +.template-minimal .invoice-total-row { padding: var(--spacing-2) 0; border-bottom: 1px solid var(--border-light); } | |
| 404 | +.template-minimal .invoice-totals .invoice-grand-total { border-top: 1px solid var(--text-primary); border-bottom: 0; margin-top: var(--spacing-1); padding-top: var(--spacing-3); font-size: var(--font-size-lg); } | |
| 405 | +.template-minimal .invoice-totals .invoice-grand-total .invoice-total-value { font-size: var(--font-size-xl); } | |
| 406 | +.template-minimal .invoice-notes, .template-minimal .invoice-terms { background: transparent; border: 0; border-top: 1px solid var(--border-light); border-radius: 0; padding: var(--spacing-5) 0 0; margin-top: var(--spacing-6); } | |
| 407 | +.template-minimal .invoice-notes h3, .template-minimal .invoice-terms h3 { font-size: var(--font-size-xs); text-transform: uppercase; letter-spacing: 0.14em; color: var(--text-muted); font-weight: 600; margin-bottom: var(--spacing-2); border: 0; padding: 0; } | |
| 408 | +.template-minimal .invoice-footer { background: transparent; border: 0; border-top: 1px solid var(--border-light); padding: var(--spacing-4) 0 0; margin-top: var(--spacing-8); color: var(--text-muted); font-size: var(--font-size-sm); } | |
| 409 | +.template-minimal .invoice-totals .invoice-paid-row .invoice-total-value { color: var(--success-color, #047857); } | |
| 410 | +.template-minimal .invoice-totals .invoice-balance-due { font-weight: 700; } | |
| 411 | +.template-minimal .invoice-totals .invoice-balance-due .invoice-total-label { color: inherit; font-weight: 700; } | |
| 412 | +.template-minimal .meta-amount-due .meta-value { font-weight: 700; font-size: 1.08em; } | |
| 373 | 413 | </style> |
| 374 | 414 | |
| 375 | 415 | <div class="template template-minimal"> |
| 376 | - <!-- Header --> | |
| 377 | 416 | <div class="invoice-header"> |
| 378 | 417 | <div class="company-info"> |
| 418 | + <?php if (!empty($company_info['logo'])): ?> | |
| 379 | 419 | <div class="company-logo"> |
| 380 | - <?php if (!empty($company_info['logo'])): ?> | |
| 381 | - <img src="<?php echo esc_url($company_info['logo']); ?>" alt="<?php echo esc_attr($company_info['name']); ?>" class="logo-image"> | |
| 382 | - <?php endif; ?> | |
| 420 | + <img src="<?php echo esc_url($company_info['logo']); ?>" alt="<?php echo esc_attr($company_info['name']); ?>" class="logo-image" onerror="this.parentNode.parentNode.removeChild(this.parentNode)"> | |
| 383 | 421 | </div> |
| 422 | + <?php endif; ?> | |
| 384 | 423 | <div class="company-name"><?php echo esc_html($company_info['name']); ?></div> |
| 385 | 424 | <div class="company-details"> |
| 386 | - <?php echo \EasyInvoice\Helpers\TemplateTextHelper::generateFromSection($company_info, false, 'details-only'); ?> | |
| 425 | + <?php echo wp_kses_post(\EasyInvoice\Helpers\TemplateTextHelper::generateFromSection($company_info, false, 'details-only')); ?> | |
| 387 | 426 | </div> |
| 388 | 427 | </div> |
| 389 | 428 | |
| 390 | 429 | <div class="invoice-meta"> |
| 391 | - <div class="invoice-title"><?php echo esc_html($invoice->getTitle() ?: __('Invoice', 'easy-invoice')); ?></div> | |
| 430 | + <?php $ei_kind = \EasyInvoice\Helpers\TemplateTextHelper::documentKind($invoice); $ei_title = trim((string) $invoice->getTitle()); ?> | |
| 431 | + <div class="invoice-title"><?php if ('' !== $ei_title && 0 !== strcasecmp($ei_title, $ei_kind)) : ?><span class="document-kind"><?php echo esc_html($ei_kind); ?></span><?php endif; ?><?php echo esc_html('' !== $ei_title ? $ei_title : $ei_kind); ?></div> | |
| 392 | 432 | <div class="meta-item"> |
| 393 | 433 | <span class="meta-label"><?php echo esc_html($text_settings['invoice_number']); ?></span> |
| 394 | 434 | <span class="meta-value"><?php echo esc_html($invoice->getNumber()); ?></span> |
| 395 | 435 | </div> |
| @@ -396,32 +436,44 @@ | ||
| 396 | 436 | <div class="meta-item"> |
| 397 | 437 | <span class="meta-label"><?php echo esc_html($text_settings['invoice_date']); ?></span> |
| 398 | 438 | <span class="meta-value"><?php echo esc_html(\EasyInvoice\Controllers\SettingsController::formatDate($invoice->getIssueDate())); ?></span> |
| 399 | 439 | </div> |
| 440 | + <?php if (empty($ei_is_credit_note)) : ?> | |
| 400 | 441 | <div class="meta-item"> |
| 401 | 442 | <span class="meta-label"><?php echo esc_html($text_settings['due_date']); ?></span> |
| 402 | 443 | <span class="meta-value"><?php echo esc_html(\EasyInvoice\Controllers\SettingsController::formatDate($invoice->getDueDate())); ?></span> |
| 403 | 444 | </div> |
| 445 | + <?php endif; ?> | |
| 446 | + <?php if (empty($ei_is_credit_note)) : ?> | |
| 447 | + <div class="meta-item meta-amount-due"> | |
| 448 | + <span class="meta-label"><?php echo esc_html($text_settings['total_due']); ?></span> | |
| 449 | + <span class="meta-value"><?php echo esc_html($formatter->format(\EasyInvoice\Helpers\TemplateTextHelper::amountDue($invoice))); ?></span> | |
| 450 | + </div> | |
| 451 | + <?php endif; ?> | |
| 404 | 452 | </div> |
| 405 | 453 | </div> |
| 406 | 454 | |
| 407 | - <!-- Address Section --> | |
| 455 | + <?php $ei_client_html = \EasyInvoice\Helpers\TemplateTextHelper::generateClientBlock($invoice); if ('' !== $ei_client_html) : ?> | |
| 408 | 456 | <div class="address-section"> |
| 409 | 457 | <div class="address-block"> |
| 410 | 458 | <h2><?php echo esc_html($text_settings['to']); ?></h2> |
| 411 | 459 | <div class="address-content"> |
| 412 | - <div class="client-name"><?php echo esc_html($invoice->getCustomerName()); ?></div> | |
| 413 | - <?php if ($invoice->getCustomerAddress()): ?> | |
| 414 | - <?php echo nl2br(esc_html($invoice->getCustomerAddress())); ?><br> | |
| 415 | - <?php endif; ?> | |
| 416 | - <?php if ($invoice->getCustomerEmail()): ?> | |
| 417 | - <?php echo esc_html($invoice->getCustomerEmail()); ?><br> | |
| 418 | - <?php endif; ?> | |
| 460 | + <?php echo wp_kses_post($ei_client_html); ?> | |
| 419 | 461 | </div> |
| 420 | 462 | </div> |
| 421 | 463 | </div> |
| 464 | + <?php endif; ?> | |
| 422 | 465 | |
| 423 | - <!-- Invoice Items --> | |
| 466 | + <?php | |
| 467 | + // The adjustment column appears only when at least one line uses it. | |
| 468 | + $ei_show_adjust = \EasyInvoice\Controllers\SettingsController::shouldShowInvoiceAdjustField(); | |
| 469 | + if ($ei_show_adjust) { | |
| 470 | + $ei_show_adjust = false; | |
| 471 | + foreach ($invoice->getItems() as $ei_item) { | |
| 472 | + if ((float) $ei_item->getAdjustPercentage() != 0.0) { $ei_show_adjust = true; break; } | |
| 473 | + } | |
| 474 | + } | |
| 475 | + ?> | |
| 424 | 476 | <table class="invoice-items"> |
| 425 | 477 | <thead> |
| 426 | 478 | <tr> |
| 427 | 479 | <th><?php echo esc_html($text_settings['service']); ?></th> |
| @@ -426,15 +478,18 @@ | ||
| 426 | 478 | <tr> |
| 427 | 479 | <th><?php echo esc_html($text_settings['service']); ?></th> |
| 428 | 480 | <th><?php echo esc_html($text_settings['qty']); ?></th> |
| 429 | 481 | <th><?php echo esc_html($text_settings['rate_price']); ?></th> |
| 430 | - <?php if (\EasyInvoice\Controllers\SettingsController::shouldShowQuoteAdjustField()): ?> | |
| 482 | + <?php if ($ei_show_adjust): ?> | |
| 431 | 483 | <th><?php echo esc_html($text_settings['adjust']); ?> (%)</th> |
| 432 | 484 | <?php endif; ?> |
| 433 | - <th><?php echo esc_html($text_settings['total']); ?></th> | |
| 485 | + <th><?php echo esc_html($text_settings['line_total'] ?? $text_settings['total']); ?></th> | |
| 434 | 486 | </tr> |
| 435 | 487 | </thead> |
| 436 | 488 | <tbody> |
| 489 | + <?php if (!$invoice->getItems()) : ?> | |
| 490 | + <tr class="no-items"><td colspan="<?php echo $ei_show_adjust ? 5 : 4; ?>" style="text-align:center;color:#9ca3af;padding:18px;"><?php esc_html_e('No items yet.', 'easy-invoice'); ?></td></tr> | |
| 491 | + <?php endif; ?> | |
| 437 | 492 | <?php foreach ($invoice->getItems() as $item): ?> |
| 438 | 493 | <tr> |
| 439 | 494 | <td class="item-name"> |
| 440 | 495 | <div class="item-title"><?php echo esc_html($item->getName()); ?></div> |
| @@ -441,11 +496,11 @@ | ||
| 441 | 496 | <?php if ($item->getDescription()): ?> |
| 442 | 497 | <div class="item-description"><?php echo esc_html($item->getDescription()); ?></div> |
| 443 | 498 | <?php endif; ?> |
| 444 | 499 | </td> |
| 445 | - <td class="item-quantity"><?php echo esc_html($item->getQuantity()); ?></td> | |
| 500 | + <td class="item-quantity"><?php echo esc_html($item->getQuantity() ?: '0'); ?></td> | |
| 446 | 501 | <td class="item-price"><?php echo esc_html($formatter->format($item->getPrice())); ?></td> |
| 447 | - <?php if (\EasyInvoice\Controllers\SettingsController::shouldShowQuoteAdjustField()): ?> | |
| 502 | + <?php if ($ei_show_adjust): ?> | |
| 448 | 503 | <td class="item-adjust"><?php |
| 449 | 504 | $adjust_percentage = $item->getAdjustPercentage(); |
| 450 | 505 | if ($adjust_percentage != 0) { |
| 451 | 506 | echo esc_html($adjust_percentage > 0 ? '+' : '') . esc_html($adjust_percentage) . '%'; |
| @@ -459,17 +514,15 @@ | ||
| 459 | 514 | <?php endforeach; ?> |
| 460 | 515 | </tbody> |
| 461 | 516 | </table> |
| 462 | 517 | |
| 463 | - <!-- Invoice Totals --> | |
| 464 | 518 | <div class="invoice-totals"> |
| 465 | - <?php echo \EasyInvoice\Helpers\TemplateTextHelper::generateTotalsSection($invoice, $text_settings, $formatter, 'invoice'); ?> | |
| 519 | + <?php echo wp_kses_post(\EasyInvoice\Helpers\TemplateTextHelper::generateTotalsSection($invoice, $text_settings, $formatter, 'invoice')); ?> | |
| 466 | 520 | </div> |
| 467 | 521 | |
| 468 | - <!-- Notes --> | |
| 469 | 522 | <?php if ($invoice->getNotes()): ?> |
| 470 | 523 | <div class="invoice-notes"> |
| 471 | - <h3><?php _e('Notes:', 'easy-invoice'); ?></h3> | |
| 524 | + <h3><?php esc_html_e('Notes', 'easy-invoice'); ?></h3> | |
| 472 | 525 | <div class="notes-content"> |
| 473 | 526 | <?php echo wp_kses_post($invoice->getNotes() ?: ''); ?> |
| 474 | 527 | </div> |
| 475 | 528 | </div> |
| @@ -474,15 +527,14 @@ | ||
| 474 | 527 | </div> |
| 475 | 528 | </div> |
| 476 | 529 | <?php endif; ?> |
| 477 | 530 | |
| 478 | - <!-- Terms and Conditions --> | |
| 479 | 531 | <?php |
| 480 | - $terms_conditions = $invoice->getTerms() ?: \EasyInvoice\Controllers\SettingsController::getInvoiceTermsConditions(); | |
| 532 | + $terms_conditions = empty($ei_is_credit_note) ? ($invoice->getTerms() ?: \EasyInvoice\Controllers\SettingsController::getInvoiceTermsConditions()) : ''; | |
| 481 | 533 | if ($terms_conditions): |
| 482 | 534 | ?> |
| 483 | 535 | <div class="invoice-terms"> |
| 484 | - <h3><?php _e('Terms & Conditions:', 'easy-invoice'); ?></h3> | |
| 536 | + <h3><?php esc_html_e('Terms & Conditions', 'easy-invoice'); ?></h3> | |
| 485 | 537 | <div class="terms-content"> |
| 486 | 538 | <?php echo wp_kses_post($terms_conditions); ?> |
| 487 | 539 | </div> |
| 488 | 540 | </div> |
| @@ -487,15 +539,23 @@ | ||
| 487 | 539 | </div> |
| 488 | 540 | </div> |
| 489 | 541 | <?php endif; ?> |
| 490 | 542 | |
| 491 | - <!-- Footer --> | |
| 543 | + <?php | |
| 544 | + /** | |
| 545 | + * Fires inside the document card, after notes and terms and before the | |
| 546 | + * footer text: attachments, the signature block, e-invoicing notes. Being | |
| 547 | + * inside the card, it is part of what "Download as PDF" captures. | |
| 548 | + * | |
| 549 | + * @param object $document The invoice model. | |
| 550 | + * @param string $type 'invoice'. | |
| 551 | + */ | |
| 552 | + do_action('easy_invoice_document_body_after', $invoice, 'invoice'); | |
| 553 | + | |
| 554 | + $ei_footer_text = \EasyInvoice\Helpers\TemplateTextHelper::footerText($invoice, 'invoice'); | |
| 555 | + if ('' !== trim(wp_strip_all_tags((string) $ei_footer_text))) : | |
| 556 | + ?> | |
| 492 | 557 | <div class="invoice-footer"> |
| 493 | - <?php | |
| 494 | - $invoice_footer_text = $invoice->getFooterText(); | |
| 495 | - if (!$invoice_footer_text) { | |
| 496 | - $invoice_footer_text = \EasyInvoice\Controllers\SettingsController::getInvoiceFooterText(); | |
| 497 | - } | |
| 498 | - ?> | |
| 499 | - <p><?php echo wp_kses_post($invoice_footer_text); ?></p> | |
| 558 | + <p><?php echo wp_kses_post($ei_footer_text); ?></p> | |
| 500 | 559 | </div> |
| 501 | -</div> | |
| 560 | + <?php endif; ?> | |
| 561 | +</div> | |