| @@ -3,8 +3,11 @@ | ||
| 3 | 3 | * Legacy Quote Template |
| 4 | 4 | * Clean, minimalist design with traditional business layout |
| 5 | 5 | */ |
| 6 | 6 | |
| 7 | +if ( ! defined( 'ABSPATH' ) ) { | |
| 8 | + exit; | |
| 9 | +} | |
| 7 | 10 | $text_settings = \EasyInvoice\Helpers\TemplateTextHelper::getQuoteTextSettings(); |
| 8 | 11 | $company_info = \EasyInvoice\Helpers\TemplateTextHelper::getCompanyInfo(); |
| 9 | 12 | // Ensure a formatter is available for currency formatting |
| 10 | 13 | if (!isset($formatter) || !$formatter) { |
| @@ -263,9 +266,9 @@ | ||
| 263 | 266 | font-size: 14px; |
| 264 | 267 | font-weight: 500; |
| 265 | 268 | } |
| 266 | 269 | |
| 267 | -.template-legacy .quote-grand-total { | |
| 270 | +.template-legacy .quote-totals .quote-grand-total { | |
| 268 | 271 | background: #f8f9fa; |
| 269 | 272 | border-top: 1px solid #dddddd; |
| 270 | 273 | margin-top: 0; |
| 271 | 274 | padding-top: 14px; |
| @@ -271,9 +274,9 @@ | ||
| 271 | 274 | padding-top: 14px; |
| 272 | 275 | } |
| 273 | 276 | |
| 274 | 277 | .template-legacy .quote-grand-total .quote-total-label, |
| 275 | -.template-legacy .quote-grand-total .quote-total-value { | |
| 278 | +.template-legacy .quote-totals .quote-grand-total .quote-total-value { | |
| 276 | 279 | font-weight: 700; |
| 277 | 280 | font-size: 16px; |
| 278 | 281 | color: #000000; |
| 279 | 282 | } |
| @@ -318,27 +321,52 @@ | ||
| 318 | 321 | .template-legacy .footer-company { |
| 319 | 322 | color: #9ca3af; |
| 320 | 323 | font-size: 13px; |
| 321 | 324 | } |
| 325 | + | |
| 326 | +/* Shared polish: numbers line up, numeric headings sit over their figures. */ | |
| 327 | +.template-legacy .quote-items th + th { text-align: right; } | |
| 328 | +.template-legacy .quote-items .item-quantity, | |
| 329 | +.template-legacy .quote-items .item-price, | |
| 330 | +.template-legacy .quote-items .item-adjust, | |
| 331 | +.template-legacy .quote-items .item-total, | |
| 332 | +.template-legacy .quote-total-value { font-variant-numeric: tabular-nums; white-space: nowrap; } | |
| 333 | +.template-legacy .meta-value { white-space: nowrap; } | |
| 334 | +.template-legacy .quote-items .item-adjust { text-align: right; } | |
| 335 | +.template-legacy .client-contact { font-weight: 500; margin-bottom: 0.15em; } | |
| 336 | +.template-legacy .client-tax-number, | |
| 337 | +.template-legacy .company-tax-number { margin-top: 0.35em; } | |
| 338 | +.template-legacy .quote-items .item-description { white-space: pre-line; } | |
| 339 | +.template-legacy .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; } | |
| 340 | + | |
| 341 | +/* Legacy: keeps its ruled grid, with softer rules and the same type size as the other designs. */ | |
| 342 | +.template-legacy .quote-items th, .template-legacy .quote-items td { border-color: #e5e7eb !important; } | |
| 343 | +.template-legacy .quote-items th { background: #f9fafb; font-size: 12px; letter-spacing: 0.08em; color: #374151; } | |
| 344 | +.template-legacy .quote-meta, .template-legacy .meta-item { border-color: #e5e7eb !important; } | |
| 345 | +.template-legacy .company-name { color: #111827; } | |
| 346 | +.template-legacy .address-block h2 { font-size: 12px; letter-spacing: 0.12em; color: #6b7280; text-transform: uppercase; } | |
| 347 | +.template-legacy .terms-section, .template-legacy .description-section { background: transparent; border: 0; border-top: 1px solid #e5e7eb; border-radius: 0; padding: 16px 0 0; } | |
| 348 | +.template-legacy .terms-section h3 { font-size: 12px; letter-spacing: 0.12em; color: #6b7280; } | |
| 349 | +.template-legacy .quote-header { margin-bottom: 24px; } | |
| 322 | 350 | </style> |
| 323 | 351 | |
| 324 | 352 | <div class="template-legacy"> |
| 325 | - <!-- Header Section --> | |
| 326 | 353 | <div class="quote-header"> |
| 327 | 354 | <div class="company-info"> |
| 355 | + <?php if (!empty($company_info['logo'])): ?> | |
| 328 | 356 | <div class="company-logo"> |
| 329 | - <?php if (!empty($company_info['logo'])): ?> | |
| 330 | - <img src="<?php echo esc_url($company_info['logo']); ?>" alt="<?php echo esc_attr($company_info['name']); ?>" class="logo-image"> | |
| 331 | - <?php endif; ?> | |
| 357 | + <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)"> | |
| 332 | 358 | </div> |
| 359 | + <?php endif; ?> | |
| 333 | 360 | <div class="company-name"><?php echo esc_html($company_info['name']); ?></div> |
| 334 | 361 | <div class="company-details"> |
| 335 | - <?php echo \EasyInvoice\Helpers\TemplateTextHelper::generateFromSection($company_info, false, 'details-only'); ?> | |
| 362 | + <?php echo wp_kses_post(\EasyInvoice\Helpers\TemplateTextHelper::generateFromSection($company_info, false, 'details-only')); ?> | |
| 336 | 363 | </div> |
| 337 | 364 | </div> |
| 338 | 365 | |
| 339 | 366 | <div class="quote-title-section"> |
| 340 | - <div class="quote-title"><?php echo esc_html($quote->getTitle() ?: __('Quote', 'easy-invoice')); ?></div> | |
| 367 | + <?php $ei_kind = \EasyInvoice\Controllers\SettingsController::getTextQuote(); $ei_title = trim((string) $quote->getTitle()); ?> | |
| 368 | + <div class="quote-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> | |
| 341 | 369 | <div class="quote-meta"> |
| 342 | 370 | <div class="meta-item"> |
| 343 | 371 | <span class="meta-label"><?php echo esc_html($text_settings['quote_number']); ?></span> |
| 344 | 372 | <span class="meta-value"><?php echo esc_html($quote->getNumber()); ?></span> |
| @@ -358,25 +386,19 @@ | ||
| 358 | 386 | </div> |
| 359 | 387 | </div> |
| 360 | 388 | </div> |
| 361 | 389 | |
| 362 | - <!-- Address Section --> | |
| 390 | + <?php $ei_client_html = \EasyInvoice\Helpers\TemplateTextHelper::generateClientBlock($quote); if ('' !== $ei_client_html) : ?> | |
| 363 | 391 | <div class="address-section"> |
| 364 | 392 | <div class="address-block"> |
| 365 | 393 | <h2><?php echo esc_html($text_settings['to']); ?></h2> |
| 366 | 394 | <div class="address-content"> |
| 367 | - <div class="client-name"><?php echo esc_html($quote->getCustomerName()); ?></div> | |
| 368 | - <?php if ($quote->getCustomerAddress()): ?> | |
| 369 | - <?php echo nl2br(esc_html($quote->getCustomerAddress())); ?><br> | |
| 370 | - <?php endif; ?> | |
| 371 | - <?php if ($quote->getCustomerEmail()): ?> | |
| 372 | - <?php echo esc_html($quote->getCustomerEmail()); ?><br> | |
| 373 | - <?php endif; ?> | |
| 395 | + <?php echo wp_kses_post($ei_client_html); ?> | |
| 374 | 396 | </div> |
| 375 | 397 | </div> |
| 376 | 398 | </div> |
| 399 | + <?php endif; ?> | |
| 377 | 400 | |
| 378 | - <!-- Description Section --> | |
| 379 | 401 | <?php if ($quote->getDescription()): ?> |
| 380 | 402 | <div class="description-section"> |
| 381 | 403 | <div class="description-content"><?php echo wp_kses_post($quote->getDescription()); ?></div> |
| 382 | 404 | </div> |
| @@ -381,9 +403,18 @@ | ||
| 381 | 403 | <div class="description-content"><?php echo wp_kses_post($quote->getDescription()); ?></div> |
| 382 | 404 | </div> |
| 383 | 405 | <?php endif; ?> |
| 384 | 406 | |
| 385 | - <!-- Quote Items --> | |
| 407 | + <?php | |
| 408 | + // The adjustment column appears only when at least one line uses it. | |
| 409 | + $ei_show_adjust = \EasyInvoice\Controllers\SettingsController::shouldShowQuoteAdjustField(); | |
| 410 | + if ($ei_show_adjust) { | |
| 411 | + $ei_show_adjust = false; | |
| 412 | + foreach ($quote->getItems() as $ei_item) { | |
| 413 | + if ((float) $ei_item->getAdjustPercentage() != 0.0) { $ei_show_adjust = true; break; } | |
| 414 | + } | |
| 415 | + } | |
| 416 | + ?> | |
| 386 | 417 | <table class="quote-items"> |
| 387 | 418 | <thead> |
| 388 | 419 | <tr> |
| 389 | 420 | <th><?php echo esc_html($text_settings['service']); ?></th> |
| @@ -388,15 +419,18 @@ | ||
| 388 | 419 | <tr> |
| 389 | 420 | <th><?php echo esc_html($text_settings['service']); ?></th> |
| 390 | 421 | <th><?php echo esc_html($text_settings['qty']); ?></th> |
| 391 | 422 | <th><?php echo esc_html($text_settings['rate_price']); ?></th> |
| 392 | - <?php if (\EasyInvoice\Controllers\SettingsController::shouldShowQuoteAdjustField()): ?> | |
| 423 | + <?php if ($ei_show_adjust): ?> | |
| 393 | 424 | <th><?php echo esc_html($text_settings['adjust']); ?> (%)</th> |
| 394 | 425 | <?php endif; ?> |
| 395 | - <th><?php echo esc_html($text_settings['total']); ?></th> | |
| 426 | + <th><?php echo esc_html($text_settings['line_total'] ?? $text_settings['total']); ?></th> | |
| 396 | 427 | </tr> |
| 397 | 428 | </thead> |
| 398 | 429 | <tbody> |
| 430 | + <?php if (!$quote->getItems()) : ?> | |
| 431 | + <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> | |
| 432 | + <?php endif; ?> | |
| 399 | 433 | <?php foreach ($quote->getItems() as $item): ?> |
| 400 | 434 | <tr> |
| 401 | 435 | <td class="item-name"> |
| 402 | 436 | <div class="item-title"><?php echo esc_html($item->getName()); ?></div> |
| @@ -405,9 +439,9 @@ | ||
| 405 | 439 | <?php endif; ?> |
| 406 | 440 | </td> |
| 407 | 441 | <td class="item-quantity"><?php echo esc_html($item->getQuantity() ?: '0'); ?></td> |
| 408 | 442 | <td class="item-price"><?php echo esc_html($formatter->format($item->getPrice())); ?></td> |
| 409 | - <?php if (\EasyInvoice\Controllers\SettingsController::shouldShowQuoteAdjustField()): ?> | |
| 443 | + <?php if ($ei_show_adjust): ?> | |
| 410 | 444 | <td class="item-adjust"><?php |
| 411 | 445 | $adjust_percentage = $item->getAdjustPercentage(); |
| 412 | 446 | if ($adjust_percentage != 0) { |
| 413 | 447 | echo esc_html($adjust_percentage > 0 ? '+' : '') . esc_html($adjust_percentage) . '%'; |
| @@ -421,20 +455,18 @@ | ||
| 421 | 455 | <?php endforeach; ?> |
| 422 | 456 | </tbody> |
| 423 | 457 | </table> |
| 424 | 458 | |
| 425 | - <!-- Quote Totals --> | |
| 426 | 459 | <div class="quote-totals"> |
| 427 | - <?php echo \EasyInvoice\Helpers\TemplateTextHelper::generateTotalsSection($quote, $text_settings, $formatter, 'quote'); ?> | |
| 460 | + <?php echo wp_kses_post(\EasyInvoice\Helpers\TemplateTextHelper::generateTotalsSection($quote, $text_settings, $formatter, 'quote')); ?> | |
| 428 | 461 | </div> |
| 429 | 462 | |
| 430 | - <!-- Terms Section --> | |
| 431 | 463 | <?php |
| 432 | 464 | $terms_conditions = $quote->getTerms() ?: \EasyInvoice\Controllers\SettingsController::getQuoteTermsConditions(); |
| 433 | 465 | if ($terms_conditions): |
| 434 | 466 | ?> |
| 435 | 467 | <div class="terms-section"> |
| 436 | - <h3>Terms & Conditions</h3> | |
| 468 | + <h3><?php esc_html_e('Terms & Conditions', 'easy-invoice'); ?></h3> | |
| 437 | 469 | <div class="terms-content"> |
| 438 | 470 | <?php echo wp_kses_post($terms_conditions); ?> |
| 439 | 471 | </div> |
| 440 | 472 | </div> |
| @@ -439,12 +471,23 @@ | ||
| 439 | 471 | </div> |
| 440 | 472 | </div> |
| 441 | 473 | <?php endif; ?> |
| 442 | 474 | |
| 443 | - <!-- Footer --> | |
| 475 | + <?php | |
| 476 | + /** | |
| 477 | + * Fires inside the document card, after notes and terms and before the | |
| 478 | + * footer text: attachments, the signature block, e-invoicing notes. Being | |
| 479 | + * inside the card, it is part of what "Download as PDF" captures. | |
| 480 | + * | |
| 481 | + * @param object $document The quote model. | |
| 482 | + * @param string $type 'quote'. | |
| 483 | + */ | |
| 484 | + do_action('easy_invoice_document_body_after', $quote, 'quote'); | |
| 485 | + | |
| 486 | + $ei_footer_text = \EasyInvoice\Helpers\TemplateTextHelper::footerText($quote, 'quote'); | |
| 487 | + if ('' !== trim(wp_strip_all_tags((string) $ei_footer_text))) : | |
| 488 | + ?> | |
| 444 | 489 | <div class="quote-footer"> |
| 445 | - <p>This quote is valid for 30 days from the date of issue.</p> | |
| 446 | - <div class="footer-company"> | |
| 447 | - Thanks for choosing <?php echo esc_html($company_info['name']); ?> | <?php echo esc_html($company_info['email'] ?? '[email protected]'); ?> | |
| 448 | - </div> | |
| 490 | + <p><?php echo wp_kses_post($ei_footer_text); ?></p> | |
| 449 | 491 | </div> |
| 492 | + <?php endif; ?> | |
| 450 | 493 | </div> |