From: Steve Sutton Date: Tue, 19 Mar 2019 20:43:38 +0000 (-0400) Subject: Invoice updates X-Git-Url: http://cvs2.gaslightmedia.com/gitweb/?a=commitdiff_plain;h=3b87554e03f68f5eacee6609ff980134d356e345;p=WP-Plugins%2Fglm-member-db-billing.git Invoice updates Setting up the pdf invoice with the new settings and terms for invoices. --- diff --git a/classes/data/dataAccounts.php b/classes/data/dataAccounts.php index ea2ae3e..86eddc2 100644 --- a/classes/data/dataAccounts.php +++ b/classes/data/dataAccounts.php @@ -119,6 +119,9 @@ class GlmDataAccounts extends GlmDataAbstract $billingContactNameRequired = false; $billingFieldsRequired = $this->config['settings']['billing_fields_required']; $billingContactNameEnabled = $this->config['settings']['billing_contact_name_enabled']; + $billingAccountEnabled = $this->config['settings']['account_number_enabled']; + $billingAccountRequired = $this->config['settings']['account_number_required']; + $billingAccountUnique = $this->config['settings']['account_number_unique']; if ( $billingFieldsRequired && $billingContactNameEnabled ) { $billingContactNameRequired = true; } else if ( $billingFieldsRequired && !$billingContactNameEnabled ) { @@ -186,8 +189,8 @@ class GlmDataAccounts extends GlmDataAbstract 'field' => 'account_number', 'type' => 'text', 'use' => 'a', - 'required' => true, - 'unique' => true, + 'required' => (bool)$billingAccountRequired, + 'unique' => (bool)$billingAccountUnique, ), // Invoice Delivery Methods diff --git a/index.php b/index.php index ecd8ef8..a490a00 100644 --- a/index.php +++ b/index.php @@ -151,6 +151,9 @@ if ( $glmMembersDatabasePluginVersion ) { $glmMembersBillingManagement = $wpdb->get_row( "SELECT * FROM ".GLM_MEMBERS_BILLING_PLUGIN_DB_PREFIX."management WHERE id = 1", ARRAY_A ); unset($glmMembersBillingManagement['id']); + + $glmMembersBillingTerms = $wpdb->get_row( "SELECT * FROM ".GLM_MEMBERS_BILLING_PLUGIN_DB_PREFIX."settings_terms WHERE id = 1", ARRAY_A ); + unset($glmMembersBillingTerms['id']); } function glmMembersBillingRegisterAddOn($addOns) { @@ -163,8 +166,9 @@ function glmMembersBillingRegisterAddOn($addOns) { 'slug' => GLM_MEMBERS_BILLING_PLUGIN_SLUG, 'actions' => $GLOBALS['glmMembersBillingAddOnValidActions'], 'config' => array( - 'settings' => $GLOBALS['glmMembersBillingSettings'], + 'settings' => $GLOBALS['glmMembersBillingSettings'], 'billing_settings' => $GLOBALS['glmMembersBillingManagement'], + 'billing_terms' => $GLOBALS['glmMembersBillingTerms'], ), 'shortcodes' => $GLOBALS['glmMembersBillingShortcodes'], 'shortcodesDescription' => $GLOBALS['glmMembersBillingShortcodesDescription'] diff --git a/lib/GlmPDFInvoice.php b/lib/GlmPDFInvoice.php index b59b33f..ed29876 100644 --- a/lib/GlmPDFInvoice.php +++ b/lib/GlmPDFInvoice.php @@ -68,6 +68,12 @@ class GlmPDFInvoice extends Cezpdf */ public function createPdf( $invoices, $outputStyle = 'stream' ) { + // $config = $this->config; + // echo '
$config: ' . print_r( $config, true ) . '
'; + // exit; + $accountNumberLabel = $this->config['billing_terms']['account_number']; + $showAccountNumber = $this->config['settings']['invoice_show_account_number']; + $showInvoiceNumber = $this->config['settings']['invoice_show_invoice_number']; $this->setupPages(); $totalPdfs = count( $invoices ); @@ -107,10 +113,19 @@ class GlmPDFInvoice extends Cezpdf $this->ezSetY( $companyNameSaveY ); // Add the Date of invoice and the member account number using ezTable. - $invoiceData = array( - array( 'header' => 'Date:', 'value' => date( 'm/d/Y', strtotime( $invoice['due_date'] ) ), 'headerFill' => $this->color_white, 'valueFill' => $this->color_white ), - array( 'header' => 'Member Billing #:', 'value' => $account['account_number'], 'headerFill' => $this->color_white, 'valueFill' => $this->color_white ) + $invoiceData[] = array( + 'header' => 'Date:', 'value' => date( 'm/d/Y', strtotime( $invoice['due_date'] ) ), 'headerFill' => $this->color_white, 'valueFill' => $this->color_white ); + if ( $showAccountNumber ) { + $invoiceData[] = array( + 'header' => $accountNumberLabel . ':', 'value' => $account['account_number'], 'headerFill' => $this->color_white, 'valueFill' => $this->color_white + ); + } + if ( $showInvoiceNumber ) { + $invoiceData[] = array( + 'header' => 'Invoice #:', 'value' => $invoice['id'], 'headerFill' => $this->color_white, 'valueFill' => $this->color_white + ); + } $this->ezTable( $invoiceData, array( 'header' => '', 'value' => '' ), @@ -356,9 +371,12 @@ class GlmPDFInvoice extends Cezpdf $newY = $this->ezText( '', $this->pdf_font_size ); $newY = $this->addText( 375, $newY, 14, 'NO PAYMENT REQUIRED' ); } - $paymentForm3 = array( - array( 'header' => 'Member Billing #:', 'value' => $account['account_number'] ), - ); + if ( $showAccountNumber ) { + $paymentForm3[] = array( 'header' => ''.$accountNumberLabel . ':', 'value' => $account['account_number'] ); + } + if ( $showInvoiceNumber ) { + $paymentForm3[] = array( 'header' => 'Invoice #:', 'value' => $invoice['id'], 'headerFill' => $this->color_white, 'valueFill' => $this->color_white ); + } $this->ezTable( $paymentForm3, array( 'header' => 'Header', 'value' => 'Value' ), diff --git a/views/admin/billing/editAccount.html b/views/admin/billing/editAccount.html index 108ed62..559c4ae 100644 --- a/views/admin/billing/editAccount.html +++ b/views/admin/billing/editAccount.html @@ -30,6 +30,7 @@ {if $accountID} {/if} + {if !$settings.account_number_enabled}{/if}
Account Information @@ -43,14 +44,15 @@ {if !$lockedToMember} - -
-
Account Number
-
- - {if $account.fieldFail.account_number}

{$account.fieldFail.account_number}

{/if}
+ {if $settings.account_number_enabled} +
+
Account Number
+
+ + {if $account.fieldFail.account_number}

{$account.fieldFail.account_number}

{/if}
+
-
+ {/if} {if !$settings.member_types_enabled}