| 1 |
<?php |
| 2 |
/** |
| 3 |
* Plain rendering used when no design template can be found. |
| 4 |
* |
| 5 |
* Receives: $document, $document_type, $formatter, $invoice, $quote |
| 6 |
* |
| 7 |
* @package Easy_Invoice |
| 8 |
* @subpackage Templates |
| 9 |
*/ |
| 10 |
|
| 11 |
if ( ! defined( 'ABSPATH' ) ) { |
| 12 |
exit; |
| 13 |
} |
| 14 |
|
| 15 |
$is_quote = ( 'quote' === $document_type ); |
| 16 |
$status = (string) $document->getStatus() ?: 'draft'; |
| 17 |
$show_adjust = \EasyInvoice\Controllers\SettingsController::shouldShowQuoteAdjustField(); |
| 18 |
$second_date = $is_quote ? $document->getExpiryDate() : $document->getDueDate(); |
| 19 |
$second_label = $is_quote ? __( 'Valid until', 'easy-invoice' ) : __( 'Due', 'easy-invoice' ); |
| 20 |
?> |
| 21 |
<div class="ei-fallback"> |
| 22 |
<div class="ei-fallback__notice"> |
| 23 |
<?php |
| 24 |
printf( |
| 25 |
/* translators: %s: design name. */ |
| 26 |
esc_html__( 'The design "%s" is not installed; showing the document plainly.', 'easy-invoice' ), |
| 27 |
esc_html( (string) $document->getTemplate() ) |
| 28 |
); |
| 29 |
?> |
| 30 |
</div> |
| 31 |
|
| 32 |
<header class="ei-fallback__header"> |
| 33 |
<h1> |
| 34 |
<?php echo esc_html( $document->getTitle() ?: ( $is_quote ? __( 'Quote', 'easy-invoice' ) : __( 'Invoice', 'easy-invoice' ) ) ); ?> |
| 35 |
<span class="ei-fallback__status status-<?php echo esc_attr( $status ); ?>"><?php echo esc_html( ucfirst( $status ) ); ?></span> |
| 36 |
</h1> |
| 37 |
<div> |
| 38 |
<?php echo esc_html( (string) $document->getNumber() ); ?> |
| 39 |
• <?php echo esc_html( \EasyInvoice\Controllers\SettingsController::formatDate( (string) $document->getIssueDate() ) ); ?> |
| 40 |
<?php if ( $second_date ) : ?> |
| 41 |
• <?php echo esc_html( $second_label ); ?> <?php echo esc_html( \EasyInvoice\Controllers\SettingsController::formatDate( (string) $second_date ) ); ?> |
| 42 |
<?php endif; ?> |
| 43 |
</div> |
| 44 |
<?php if ( $document->getCustomerName() ) : ?> |
| 45 |
<address> |
| 46 |
<strong><?php echo esc_html( (string) $document->getCustomerName() ); ?></strong><br> |
| 47 |
<?php echo esc_html( (string) $document->getCustomerEmail() ); ?><br> |
| 48 |
<?php echo nl2br( esc_html( (string) $document->getCustomerAddress() ) ); ?> |
| 49 |
</address> |
| 50 |
<?php endif; ?> |
| 51 |
</header> |
| 52 |
|
| 53 |
<?php if ( $document->getNotes() ) : ?> |
| 54 |
<p class="ei-fallback__notes"><?php echo nl2br( esc_html( (string) $document->getNotes() ) ); ?></p> |
| 55 |
<?php endif; ?> |
| 56 |
|
| 57 |
<table class="ei-fallback__items"> |
| 58 |
<thead> |
| 59 |
<tr> |
| 60 |
<th><?php esc_html_e( 'Item', 'easy-invoice' ); ?></th> |
| 61 |
<th><?php esc_html_e( 'Description', 'easy-invoice' ); ?></th> |
| 62 |
<th><?php esc_html_e( 'Qty', 'easy-invoice' ); ?></th> |
| 63 |
<th><?php esc_html_e( 'Unit Price', 'easy-invoice' ); ?></th> |
| 64 |
<?php if ( $show_adjust ) : ?><th><?php esc_html_e( 'Adjust (%)', 'easy-invoice' ); ?></th><?php endif; ?> |
| 65 |
<th><?php esc_html_e( 'Total', 'easy-invoice' ); ?></th> |
| 66 |
</tr> |
| 67 |
</thead> |
| 68 |
<tbody> |
| 69 |
<?php foreach ( (array) $document->getItems() as $item ) : ?> |
| 70 |
<tr> |
| 71 |
<td><?php echo esc_html( (string) $item->getName() ); ?></td> |
| 72 |
<td><?php echo esc_html( (string) $item->getDescription() ); ?></td> |
| 73 |
<td><?php echo esc_html( (string) $item->getQuantity() ); ?></td> |
| 74 |
<td><?php echo esc_html( $formatter->format( $item->getPrice() ) ); ?></td> |
| 75 |
<?php if ( $show_adjust ) : ?> |
| 76 |
<td> |
| 77 |
<?php |
| 78 |
$adjust = (float) $item->getAdjustPercentage(); |
| 79 |
echo 0.0 !== $adjust ? esc_html( ( $adjust > 0 ? '+' : '' ) . $adjust . '%' ) : '—'; |
| 80 |
?> |
| 81 |
</td> |
| 82 |
<?php endif; ?> |
| 83 |
<td><?php echo esc_html( $formatter->format( $item->getAmount() ) ); ?></td> |
| 84 |
</tr> |
| 85 |
<?php endforeach; ?> |
| 86 |
</tbody> |
| 87 |
</table> |
| 88 |
|
| 89 |
<div class="ei-fallback__summary"> |
| 90 |
<div><strong><?php esc_html_e( 'Subtotal', 'easy-invoice' ); ?>:</strong> <?php echo esc_html( $formatter->format( $document->getSubtotal() ) ); ?></div> |
| 91 |
<?php if ( (float) $document->getDiscountAmount() > 0 ) : ?> |
| 92 |
<div><strong><?php esc_html_e( 'Discount', 'easy-invoice' ); ?>:</strong> -<?php echo esc_html( $formatter->format( $document->getDiscountAmount() ) ); ?></div> |
| 93 |
<?php endif; ?> |
| 94 |
<?php if ( (float) $document->getTaxAmount() > 0 ) : ?> |
| 95 |
<div><strong><?php esc_html_e( 'Tax', 'easy-invoice' ); ?>:</strong> <?php echo esc_html( $formatter->format( $document->getTaxAmount() ) ); ?></div> |
| 96 |
<?php endif; ?> |
| 97 |
<?php do_action( $is_quote ? 'easy_invoice_quote_totals_after_tax' : 'easy_invoice_invoice_totals_after_tax', $document ); ?> |
| 98 |
<div class="ei-fallback__total"><strong><?php esc_html_e( 'Total', 'easy-invoice' ); ?>:</strong> <?php echo esc_html( $formatter->format( $document->getTotal() ) ); ?></div> |
| 99 |
</div> |
| 100 |
</div> |
| 101 |
|