Skip to content
This repository has been archived by the owner on Nov 8, 2023. It is now read-only.

Display invoice date in invoices table #18

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

aparnascodex
Copy link

@aparnascodex aparnascodex commented Mar 24, 2023

Closes #16

Added new column 'Display Invoice Date' only in Invoice table. There is dependent PR in main plugin. We need to merge that before checking this request.

@@ -150,6 +160,12 @@ public function get_columns() {
if ( ! isset( WPO_WCPDF()->settings->debug_settings['calculate_document_numbers'] ) ) {
unset( $columns['calculated_number'] );
}

if( ! isset( $_GET['table_name'] ) ||
( isset( $_GET['table_name'] ) && 'wp_wcpdf_invoice_number' === $_GET['table_name'] )
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new column is only displayed for the invoice number store for the current year, but not for past years.

Since v2.11.0, we handle the number stores separated by year (introduced in PR#164). For instance, for a shop that is generating invoices since 2021, you could have these tables in your database:

  1. wp_wcpdf_invoice_number: Current year
  2. wp_wcpdf_invoice_number_2022: Invoice numbers from 2022
  3. wp_wcpdf_invoice_number_2021: Invoice numbers from 2021

Therefore, instead of checking for the exact value, you should check if the wp_wcpdf_invoice_number part is present on the $_GET['table_name'].

@@ -150,6 +160,12 @@ public function get_columns() {
if ( ! isset( WPO_WCPDF()->settings->debug_settings['calculate_document_numbers'] ) ) {
unset( $columns['calculated_number'] );
}

if( ! isset( $_GET['table_name'] ) ||
( isset( $_GET['table_name'] ) && 'wp_wcpdf_invoice_number' === $_GET['table_name'] )
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think for readable purposes, this line should be moved to :164, that is, the whole condition in a single line. Also, remember to add a space after the if statement.

if( ! isset( $_GET['table_name'] ) ||
( isset( $_GET['table_name'] ) && 'wp_wcpdf_invoice_number' === $_GET['table_name'] )
) {
$columns['date_display'] = __( 'Display Invoice Date', 'woocommerce-pdf-ips-number-tools' );
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You have two spaces after the assignment operator.

@@ -121,6 +122,15 @@ public function column_default( $item, $column_name ) {
$value = '<strong>' . __('Unknown', 'woocommerce-pdf-ips-number-tools') .'</strong>';
}
break;
case 'date_display' :
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a remark, not related with this PR, for those interested: When you select No for the Display invoice date option:

image

The invoice date is selected by default:

image

@@ -72,6 +72,7 @@ public function search_box( $text, $input_id ) {
<?php
}


Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems that you added this extra line by accident.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add 'Display invoice date' option
2 participants