Middleware
2 years ago
BaseController.php
2 years ago
ChargeController.php
3 years ago
CustomerController.php
2 years ago
DownloadController.php
2 years ago
InvoiceController.php
1 year ago
LicenseController.php
2 years ago
OrderController.php
2 years ago
PaymentMethodController.php
2 years ago
SubscriptionController.php
2 years ago
UserController.php
3 years ago
InvoiceController.php
94 lines
| 1 | <?php |
| 2 | |
| 3 | namespace SureCartBlocks\Controllers; |
| 4 | |
| 5 | use SureCart\Models\Component; |
| 6 | use SureCart\Models\User; |
| 7 | |
| 8 | /** |
| 9 | * The invoice controller. |
| 10 | */ |
| 11 | class InvoiceController extends BaseController { |
| 12 | /** |
| 13 | * Preview. |
| 14 | */ |
| 15 | public function preview( $attributes = [] ) { |
| 16 | if ( ! is_user_logged_in() ) { |
| 17 | return; |
| 18 | } |
| 19 | |
| 20 | return wp_kses_post( |
| 21 | Component::tag( 'sc-invoices-list' ) |
| 22 | ->id( 'customer-invoices-preview' ) |
| 23 | ->with( |
| 24 | [ |
| 25 | 'allLink' => add_query_arg( |
| 26 | [ |
| 27 | 'tab' => $this->getTab(), |
| 28 | 'model' => 'invoice', |
| 29 | 'action' => 'index', |
| 30 | ] |
| 31 | ), |
| 32 | 'isCustomer' => User::current()->isCustomer(), |
| 33 | 'query' => apply_filters( |
| 34 | 'surecart/dashboard/invoice_list/query', |
| 35 | [ |
| 36 | 'customer_ids' => array_values( User::current()->customerIds() ), |
| 37 | 'status' => [ 'paid', 'open' ], |
| 38 | 'page' => 1, |
| 39 | 'per_page' => 5, |
| 40 | ] |
| 41 | ), |
| 42 | ] |
| 43 | )->render( $attributes['title'] ? "<span slot='heading'>" . $attributes['title'] . '</span>' : '' ) |
| 44 | ); |
| 45 | } |
| 46 | |
| 47 | /** |
| 48 | * Index. |
| 49 | */ |
| 50 | public function index() { |
| 51 | if ( ! is_user_logged_in() ) { |
| 52 | return; |
| 53 | } |
| 54 | ob_start(); |
| 55 | ?> |
| 56 | |
| 57 | <sc-spacing style="--spacing: var(--sc-spacing-large)"> |
| 58 | <sc-breadcrumbs> |
| 59 | <sc-breadcrumb href="<?php echo esc_url( add_query_arg( [ 'tab' => $this->getTab() ], remove_query_arg( array_keys( $_GET ) ) ) ); // phpcs:ignore WordPress.Security.NonceVerification.Recommended ?>"> |
| 60 | <?php esc_html_e( 'Dashboard', 'surecart' ); ?> |
| 61 | </sc-breadcrumb> |
| 62 | <sc-breadcrumb> |
| 63 | <?php esc_html_e( 'Invoices', 'surecart' ); ?> |
| 64 | </sc-breadcrumb> |
| 65 | </sc-breadcrumbs> |
| 66 | |
| 67 | <?php |
| 68 | echo wp_kses_post( |
| 69 | Component::tag( 'sc-invoices-list' ) |
| 70 | ->id( 'customer-invoices-index' ) |
| 71 | ->with( |
| 72 | [ |
| 73 | 'heading' => __( 'Invoices', 'surecart' ), |
| 74 | 'isCustomer' => User::current()->isCustomer(), |
| 75 | 'query' => apply_filters( |
| 76 | 'surecart/dashboard/invoice_list/query', |
| 77 | [ |
| 78 | 'customer_ids' => array_values( User::current()->customerIds() ), |
| 79 | 'status' => [ 'paid', 'open' ], |
| 80 | 'page' => 1, |
| 81 | 'per_page' => 10, |
| 82 | ] |
| 83 | ), |
| 84 | ] |
| 85 | )->render() |
| 86 | ); |
| 87 | ?> |
| 88 | </sc-spacing> |
| 89 | |
| 90 | <?php |
| 91 | return ob_get_clean(); |
| 92 | } |
| 93 | } |
| 94 |