Created
September 6, 2019 07:48
-
-
Save yratof/36cc57583dc8d548f5b34198e59b95fe to your computer and use it in GitHub Desktop.
Get the date of the last payment on a gravity PDF invoice
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Used within a PDF template | |
// [...] | |
$invoice_date = date( $date_format, strtotime( $form_data['misc']['date_time'] ) ); | |
// Fetch last payment date in database | |
global $wpdb; | |
$last_payment_date = $wpdb->get_var( $wpdb->prepare( "SELECT date_created FROM {$wpdb->prefix}gf_addon_payment_transaction WHERE lead_id=%d ORDER BY date_created DESC", $entry['id'] ) ); | |
$formatted_last_payment_date = date( $date_format, strtotime( $last_payment_date ) ); | |
$invoice_date = $invoice_date; | |
if ( $last_payment_date > $form_data['misc']['date_time'] ) { | |
$invoice_date = $formatted_last_payment_date; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment