From f8a7bccb3fd265786125008af7c5ecb2db594653 Mon Sep 17 00:00:00 2001 From: Remco Tolsma <869674+remcotolsma@users.noreply.github.com> Date: Tue, 30 Jan 2024 14:27:12 +0100 Subject: [PATCH] Import project invoices section from orbis-4 theme. --- classes/Theme.php | 21 +++++++ templates/project-invoices.php | 110 +++++++++++++++++++++++++++++++++ 2 files changed, 131 insertions(+) create mode 100644 templates/project-invoices.php diff --git a/classes/Theme.php b/classes/Theme.php index 46bbba5..2ecc472 100644 --- a/classes/Theme.php +++ b/classes/Theme.php @@ -18,6 +18,8 @@ public function __construct( $plugin ) { $this->plugin = $plugin; \add_filter( 'post_class', [ $this, 'post_class' ] ); + + \add_filter( 'orbis_project_sections', [ $this, 'project_sections' ] ); } /** @@ -34,4 +36,23 @@ public function post_class( $classes ) { return $classes; } + + /** + * Project sections. + * + * @param array $sections Sections. + * @return array + */ + public function project_sections( $sections ) { + $sections[] = [ + 'id' => 'invoices', + 'slug' => __( 'invoices', 'orbis-projects' ), + 'name' => __( 'Invoices', 'orbis-projects' ), + 'callback' => function () { + include __DIR__ . '/../templates/project-invoices.php'; + }, + ]; + + return $sections; + } } diff --git a/templates/project-invoices.php b/templates/project-invoices.php new file mode 100644 index 0000000..2dcdbb7 --- /dev/null +++ b/templates/project-invoices.php @@ -0,0 +1,110 @@ +get_invoices(); + +if ( $invoices && $invoices[0]->id ) : ?> + +
+ + + + + + + + + + + + + + amount; + $hours_total += $invoice->seconds; + ?> + + + + + + + + + + + + + + + + + +
+ create_date ), 'd-m-Y' ) ); ?> + + amount, 'EUR' ); + echo esc_html( $amount->format_i18n() ); + ?> + + seconds ) { + echo esc_html( orbis_time( $invoice->seconds ) ); + } + ?> + + invoice_number ); + + if ( ! empty( $invoice_link ) ) { + printf( + '%s', + esc_attr( $invoice_link ), + esc_html( $invoice->invoice_number ) + ); + } else { + echo esc_html( $invoice->invoice_number ); + } + + if ( get_post_meta( $post->ID, '_orbis_project_invoice_number', true ) === $invoice->invoice_number ) { + printf( + ' ', + esc_html__( 'This is the final invoice.', 'orbis-projects' ) + ); + } + ?> + + display_name ); ?> +
+ + + + format_i18n() ); + ?> + + + +
+
+ + + + + +
+

+ +

+
+ +