From: Steve Sutton Date: Fri, 7 Dec 2018 13:26:02 +0000 (-0500) Subject: Updating the billing account page for contact name field. X-Git-Url: http://cvs2.gaslightmedia.com/gitweb/?a=commitdiff_plain;h=580e872fc2eab22d128e62edf485ea1ac1979b78;p=WP-Plugins%2Fglm-member-db-billing.git Updating the billing account page for contact name field. Adding the contact name field into billing account edit page. Add to import contact name field. --- diff --git a/classes/data/dataAccounts.php b/classes/data/dataAccounts.php index 632baae..c1d7044 100644 --- a/classes/data/dataAccounts.php +++ b/classes/data/dataAccounts.php @@ -258,6 +258,14 @@ class GlmDataAccounts extends GlmDataAbstract 'required' => false, ), + // Billing First Name + 'billing_contact_name' => array( + 'field' => 'billing_contact_name', + 'type' => 'text', + 'use' => 'a', + 'required' => $billingFieldsRequired, + ), + // Billing First Name 'billing_fname' => array( 'field' => 'billing_fname', diff --git a/lib/GlmPDFInvoice.php b/lib/GlmPDFInvoice.php index 7ca115f..e12fa2e 100644 --- a/lib/GlmPDFInvoice.php +++ b/lib/GlmPDFInvoice.php @@ -116,7 +116,7 @@ class GlmPDFInvoice extends Cezpdf array( 'header' => '', 'value' => '' ), '', array( - 'fontSize' => 12, + 'fontSize' => $this->pdf_font_size, 'showHeadings' => 0, 'showLines' => 0, 'width' => 200, @@ -133,7 +133,7 @@ class GlmPDFInvoice extends Cezpdf $this->ezText( sprintf( "%s\n%s\n%s, %s %s", - $account['ref_name'], + ( $account['billing_contact_name'] ) ? $account['ref_name'] . "\n" . $account['billing_contact_name'] : $account['ref_name'], $account['billing_addr1'], $account['billing_city'], $account['billing_state'], @@ -141,7 +141,7 @@ class GlmPDFInvoice extends Cezpdf ), $this->pdf_font_size ); - $this->ezText( '', $this->pdf_font_size ); + // $this->ezText( '', $this->pdf_font_size ); $invoiceLineItems = array(); // Line Items (charges). @@ -227,7 +227,7 @@ class GlmPDFInvoice extends Cezpdf array( 'terms' => 'Payment Terms' ), '', array( - 'fontSize' => 12, + 'fontSize' => $this->pdf_font_size, 'showHeadings' => 1, 'showLines' => 4, 'width' => 530, @@ -297,7 +297,7 @@ class GlmPDFInvoice extends Cezpdf array( 'content' => 'barcode' ), '', array( - 'fontSize' => 12, + 'fontSize' => $this->pdf_font_size, 'showHeadings' => 0, 'showLines' => 0, 'width' => 250, @@ -317,7 +317,7 @@ class GlmPDFInvoice extends Cezpdf array( 'header' => 'Header', 'value' => 'Value' ), '', array( - 'fontSize' => 12, + 'fontSize' => $this->pdf_font_size, 'showHeadings' => 0, 'showLines' => 0, 'width' => 230, @@ -340,7 +340,7 @@ class GlmPDFInvoice extends Cezpdf array( 'header' => 'Header', 'value' => 'Value' ), '', array( - 'fontSize' => 12, + 'fontSize' => $this->pdf_font_size, 'showHeadings' => 0, 'showLines' => 0, 'width' => 230, @@ -361,7 +361,7 @@ class GlmPDFInvoice extends Cezpdf array( 'header' => 'Header', 'value' => 'Value' ), '', array( - 'fontSize' => 12, + 'fontSize' => $this->pdf_font_size, 'showHeadings' => 0, 'showLines' => 0, 'width' => 230, diff --git a/lib/GlmPDFLabel.php b/lib/GlmPDFLabel.php index dc5b02e..ca63c80 100644 --- a/lib/GlmPDFLabel.php +++ b/lib/GlmPDFLabel.php @@ -27,11 +27,12 @@ class GlmPDFLabel extends Cezpdf * @access public */ public $config; - public $pdf_top_y = 790; + public $pdf_top_y = 765; public $pdf_bottom_y = 30; - public $pdf_font_size = 12; + public $pdf_font_size = 11; public $pdf_header_font_1 = 24; public $color_white = array( 1, 1, 1 ); + public $label_width = 270; public function __construct( $config, $p, $o ) { // Save plugin configuration object @@ -48,48 +49,81 @@ class GlmPDFLabel extends Cezpdf */ public function createPdf( $invoices ) { - $this->setupPages(); + $addresses = array(); - $y = $this->pdf_top_y; - $this->ezSetY( $this->pdf_top_y ); + if ( $invoices ) { + $columnCount = 0; + $rowCount = 0; + foreach ( $invoices as $invData ) { + $account = $invData['account']; + $columnCount++; + if ( $columnCount % 2 == 0 ) { + $addresses[$rowCount][0]['col2'] = sprintf( + "%s\n%s\n%s, %s %s\n", + ''.$account['ref_name'].'', + $account['billing_addr1'], + $account['billing_city'], + $account['billing_state'], + $account['billing_zip'] + ); + $rowCount++; + $columnCount = 0; + } else { + $addresses[$rowCount][0]['col1'] = sprintf( + "%s\n%s\n%s, %s %s\n", + ''.$account['ref_name'].'', + $account['billing_addr1'], + $account['billing_city'], + $account['billing_state'], + $account['billing_zip'] + ); + } + } + } + + // echo '
$addresses: ' . print_r( $addresses, true ) . '
'; + // exit; + + $labelPages = array_chunk( $addresses, 10 ); + // echo '
$labelPages: ' . print_r( $labelPages, true ) . '
'; + // exit; - $counter = 0; - foreach ( $invoices as $fullInvoice ) { + $this->setupPages(); - $invoice = $fullInvoice['invoice']; - $account = $fullInvoice['account']; + $y = $this->pdf_top_y; - $counter++; - if ( $counter % 2 == 0 ) { - $y = $y += 45; + $pageData = array(); + $totalPages = count( $labelPages ); + for ( $pageIndex = 0; $pageIndex < $totalPages; $pageIndex++ ) { + $totalOnPage = count( $labelPages[$pageIndex] ); + $this->ezSetY( $y ); + for ( $rowIndex = 0; $rowIndex < $totalOnPage; $rowIndex++ ) { + if ( $rowIndex == 0 ) { + $y = $this->pdf_top_y; + } else { + $y -= 75; + } $this->ezSetY( $y ); - $option = array( - 'aleft' => 330, + $this->ezTable( + $labelPages[$pageIndex][$rowIndex], + array( 'col1' => '', 'col2' => '' ), + '', + array( + 'fontSize' => $this->pdf_font_size, + 'showHeadings' => 0, + 'showLines' => 0, + 'rowGap' => 2, + 'colGap' => 5, + 'cols' => array( + 'col1' => array( 'width' => $this->label_width + 15 ), + 'col2' => array( 'width' => $this->label_width ) + ) + ) ); - } else { - $y = $y -= 35; - $this->ezSetY( $y ); - $option = ''; } - - $y = $this->ezText( - sprintf( - "%s\n%s\n%s, %s %s", - $account['ref_name'], - $account['billing_addr1'], - $account['billing_city'], - $account['billing_state'], - $account['billing_zip'] - ), - 12, - $option - ); - if ( $y <= $this->pdf_bottom_y && $counter % 2 == 0 ) { + if ( $pageIndex < $totalPages - 1 ) { $this->ezNewPage(); - $y =$this->pdf_top_y; - $this->ezSetY( $y ); } - } // Output PDF diff --git a/models/admin/management/importAccounts.php b/models/admin/management/importAccounts.php index 9fedbb5..24b0764 100644 --- a/models/admin/management/importAccounts.php +++ b/models/admin/management/importAccounts.php @@ -261,21 +261,22 @@ foreach ( $members as $member ) { } $accountData = array( - 'ref_dest' => $newMemberId, - 'ref_name' => $refName, - 'invoice_type' => $paymentTypeId, - 'email' => $member['email'], - 'account_number' => $member['account_number'], - 'renewal_date' => '2018-07-01', - 'email_invoice' => $member['email_invoice'], - 'usmail_invoice' => $member['usmail_invoice'], - 'fax_invoice' => $member['fax_invoice'], - 'billing_company' => $member['member_name'], - 'billing_addr1' => $addr1, - 'billing_city' => $city, - 'billing_state' => $state, - 'billing_zip' => $zip, - 'billing_county' => $county, + 'ref_dest' => $newMemberId, + 'ref_name' => $refName, + 'invoice_type' => $paymentTypeId, + 'email' => $member['email'], + 'account_number' => $member['account_number'], + 'renewal_date' => '2018-07-01', + 'email_invoice' => $member['email_invoice'], + 'usmail_invoice' => $member['usmail_invoice'], + 'fax_invoice' => $member['fax_invoice'], + 'billing_company' => $member['member_name'], + 'billing_contact_name' => $member['billing_contact'], + 'billing_addr1' => $addr1, + 'billing_city' => $city, + 'billing_state' => $state, + 'billing_zip' => $zip, + 'billing_county' => $county, ); $accountDataFormat = array( '%d', // ref_dest @@ -288,6 +289,7 @@ foreach ( $members as $member ) { '%d', // usmail_invoice '%d', // fax_invoice '%s', // billing_company + '%s', // billing_contact_name '%s', // billing_addr1 '%s', // billing_city '%s', // billing_state diff --git a/views/admin/billing/editAccount.html b/views/admin/billing/editAccount.html index b64012c..93bb167 100644 --- a/views/admin/billing/editAccount.html +++ b/views/admin/billing/editAccount.html @@ -162,21 +162,31 @@ -
-
Billing First Name
-
- - {if $account.fieldFail.billing_fname}

{$account.fieldFail.billing_fname}

{/if}
+ {if $settings.billing_contact_name_enabled} +
+
Billing Contact Name
+
+ + {if $account.fieldFail.billing_contact_name}

{$account.fieldFail.billing_contact_name}

{/if}
+
+
+ {else} +
+
Billing First Name
+
+ + {if $account.fieldFail.billing_fname}

{$account.fieldFail.billing_fname}

{/if}
+
-
-
-
Billing Last Name
-
- - {if $account.fieldFail.billing_lname}

{$account.fieldFail.billing_lname}

{/if}
+
+
Billing Last Name
+
+ + {if $account.fieldFail.billing_lname}

{$account.fieldFail.billing_lname}

{/if}
+
-
+ {/if}
Billing Address 1