From: Steve Sutton Date: Tue, 23 Jul 2019 20:49:57 +0000 (-0400) Subject: Working on preview of notifications X-Git-Url: http://cvs2.gaslightmedia.com/gitweb/?a=commitdiff_plain;h=c4d1a0fd9bb3f86b9f76f87a76355def4b1acb95;p=WP-Plugins%2Fglm-member-db-billing.git Working on preview of notifications Also setup required fields for invoice type when editing. --- diff --git a/classes/notifications.php b/classes/notifications.php index 32bdaff..6c38217 100644 --- a/classes/notifications.php +++ b/classes/notifications.php @@ -69,21 +69,23 @@ class GlmNotifications * @access public * @return void */ - public function sendEmailNotification( $notification_id, $account_id, $data = null, $test = false ) + public function sendEmailNotification( $notification_id, $account_id, $data = null, $test = false, $test_data = false ) { // Support Class $BillingSupport = new GlmBillingSupport( $this->wpdb, $this->config ); - // get the Account - $account = $BillingSupport->getAccountById( $account_id ); - if ( !$account ) { - // If there's no account then return false. - return false; - } + if ( !$test ) { + // get the Account + $account = $BillingSupport->getAccountById( $account_id ); + if ( !$account ) { + // If there's no account then return false. + return false; + } - $currentAmount = false; - if ( $account['invoice_type'] ) { - $invTypeData = $BillingSupport->getInvoiceTypeById( $account['invoice_type'] ); - $currentAmount = $invTypeData['amount']; + $currentAmount = false; + if ( $account['invoice_type'] ) { + $invTypeData = $BillingSupport->getInvoiceTypeById( $account['invoice_type'] ); + $currentAmount = $invTypeData['amount']; + } } // get the Notification type @@ -124,68 +126,70 @@ class GlmNotifications require GLM_MEMBERS_PLUGIN_SETUP_PATH.'/standardTemplateParams.php'; $viewFile = 'admin/notifications/notification.html'; - // Get Contact Data - $contactData = apply_filters( 'glm-member-db-contacts-get-contact-data-by-refdest', $account['ref_dest'] ); - if ( !$contactData ) { - $contactData = array( - 'org' => '', - 'business_fname' => '', - 'business_lname' => '', - 'title' => '', - 'business_addr1' => '', - 'business_addr2' => '', - 'business_city' => '', - 'business_state' => array( 'value' => '' ), - 'business_zip' => '', - 'business_email' => '', - 'business_phone' => '', - 'office_phone' => '', - 'business_mobile' => '', - 'fax' => '', - ); - } + if ( !$test ) { + // Get Contact Data + $contactData = apply_filters( 'glm-member-db-contacts-get-contact-data-by-refdest', $account['ref_dest'] ); + if ( !$contactData ) { + $contactData = array( + 'org' => '', + 'business_fname' => '', + 'business_lname' => '', + 'title' => '', + 'business_addr1' => '', + 'business_addr2' => '', + 'business_city' => '', + 'business_state' => array( 'value' => '' ), + 'business_zip' => '', + 'business_email' => '', + 'business_phone' => '', + 'office_phone' => '', + 'business_mobile' => '', + 'fax' => '', + ); + } - $account_data = array( - 'account' => array( - 'name' => $account['ref_name'], - 'email' => $account['email'], - 'first_name' => $account['billing_fname'], - 'last_name' => $account['billing_lname'], - 'addr1' => $account['billing_addr1'], - 'addr2' => $account['billing_addr2'], - 'city' => $account['billing_city'], - 'state' => $account['billing_state'], - 'zip' => $account['billing_zip'], - 'phone' => $account['billing_phone'], - 'company' => $account['billing_company'], - 'position' => $account['billing_position'], - 'renewal_date' => isset( $account['renewal_date'] ) - ? date( 'm/d/Y', strtotime( $account['renewal_date'] ) ) - : '', - 'current_due' => $currentAmount, - ), - 'contact' => array( - 'company' => $contactData['org'], - 'fname' => $contactData['business_fname'], - 'lname' => $contactData['business_lname'], - 'position' => $contactData['title'], - 'addr1' => $contactData['business_addr1'], - 'addr2' => $contactData['business_addr2'], - 'city' => $contactData['business_city'], - 'state' => $contactData['business_state']['value'], - 'zip' => $contactData['business_zip'], - 'email' => $contactData['business_email'], - 'phone' => $contactData['business_phone'], - 'office_phone' => $contactData['office_phone'], - 'mobile_phone' => $contactData['business_mobile'], - 'fax' => $contactData['fax'], - ), - ); - if ( $this->config['settings']['billing_contact_name_enabled'] ) { - $account_data['account']['contact_name'] = $account['billing_contact_name']; - } else { - $account_data['account']['first_name'] = $account['billing_fname']; - $account_data['account']['last_name'] = $account['billing_lname']; + $account_data = array( + 'account' => array( + 'name' => $account['ref_name'], + 'email' => $account['email'], + 'first_name' => $account['billing_fname'], + 'last_name' => $account['billing_lname'], + 'addr1' => $account['billing_addr1'], + 'addr2' => $account['billing_addr2'], + 'city' => $account['billing_city'], + 'state' => $account['billing_state'], + 'zip' => $account['billing_zip'], + 'phone' => $account['billing_phone'], + 'company' => $account['billing_company'], + 'position' => $account['billing_position'], + 'renewal_date' => isset( $account['renewal_date'] ) + ? date( 'm/d/Y', strtotime( $account['renewal_date'] ) ) + : '', + 'current_due' => $currentAmount, + ), + 'contact' => array( + 'company' => $contactData['org'], + 'fname' => $contactData['business_fname'], + 'lname' => $contactData['business_lname'], + 'position' => $contactData['title'], + 'addr1' => $contactData['business_addr1'], + 'addr2' => $contactData['business_addr2'], + 'city' => $contactData['business_city'], + 'state' => $contactData['business_state']['value'], + 'zip' => $contactData['business_zip'], + 'email' => $contactData['business_email'], + 'phone' => $contactData['business_phone'], + 'office_phone' => $contactData['office_phone'], + 'mobile_phone' => $contactData['business_mobile'], + 'fax' => $contactData['fax'], + ), + ); + if ( $this->config['settings']['billing_contact_name_enabled'] ) { + $account_data['account']['contact_name'] = $account['billing_contact_name']; + } else { + $account_data['account']['first_name'] = $account['billing_fname']; + $account_data['account']['last_name'] = $account['billing_lname']; + } } // Merge any data passed into this method $account_data['data'] = $data; @@ -206,20 +210,22 @@ class GlmNotifications } $fileName = false; $attachments = false; - if ( isset( $data['type'] ) && $data['type'] == $this->config['transaction_numb']['Invoice'] && $this->config['settings']['invoice_pdf_enabled'] ) { - // Need to get the invoice and output to a file. - require_once GLM_MEMBERS_BILLING_PLUGIN_PATH . '/lib/GlmPDFInvoice.php'; - $fullInvoice = $BillingSupport->getFullInvoiceData( $data['type_id'] ); - $pdf = new GlmPDFInvoice( $this->config, 'LETTER', 'portrait' ); - $fileData = $pdf->createPdf( array( $fullInvoice ), 'file' ); - $origName = tempnam( '/tmp', 'PDF' ); - $fp = fopen( $origName, 'w' ); - fwrite( $fp, $fileData ); - fclose( $fp ); - $fileName = $origName.'.pdf'; - rename( $origName, $fileName ); - - $attachments = array( $fileName ); + if ( !$test ) { + if ( isset( $data['type'] ) && $data['type'] == $this->config['transaction_numb']['Invoice'] && $this->config['settings']['invoice_pdf_enabled'] ) { + // Need to get the invoice and output to a file. + require_once GLM_MEMBERS_BILLING_PLUGIN_PATH . '/lib/GlmPDFInvoice.php'; + $fullInvoice = $BillingSupport->getFullInvoiceData( $data['type_id'] ); + $pdf = new GlmPDFInvoice( $this->config, 'LETTER', 'portrait' ); + $fileData = $pdf->createPdf( array( $fullInvoice ), 'file' ); + $origName = tempnam( '/tmp', 'PDF' ); + $fp = fopen( $origName, 'w' ); + fwrite( $fp, $fileData ); + fclose( $fp ); + $fileName = $origName.'.pdf'; + rename( $origName, $fileName ); + + $attachments = array( $fileName ); + } } $smarty->templateAssign( 'invoice_html', $invoice_html ); @@ -228,7 +234,7 @@ class GlmNotifications $htmlMessage = $smarty->template->fetch( $viewFile ); if ( $test ) { - echo $htmlMessage; + return $htmlMessage; } else { // change the default wordpress from name when sending mail diff --git a/models/admin/billing/notifications.php b/models/admin/billing/notifications.php index aca1492..1467feb 100644 --- a/models/admin/billing/notifications.php +++ b/models/admin/billing/notifications.php @@ -15,6 +15,7 @@ // Load Member Types data abstract require_once GLM_MEMBERS_BILLING_PLUGIN_CLASS_PATH.'/data/dataNotificationTypes.php'; +require_once GLM_MEMBERS_BILLING_PLUGIN_CLASS_PATH.'/notifications.php'; /* * This class performs the work for the default action of the "Members" menu @@ -150,14 +151,18 @@ class GlmMembersAdmin_billing_notifications extends GlmDataNotificationTypes case 'preview': $view = 'preview'; - // Compile template data - $templateData = array( - 'id' => $id, + + $testData = array( + 'account' => array(), 'contact' => array( - 'fname' => 'Test', - 'lname' => 'Person', ) ); + $Notifications = new GlmNotifications( $this->wpdb, $this->config ); + $previewHtml = $Notifications->sendEmailNotification( $id, false, null, true, $testData ); + // Compile template data + $templateData = array( + 'previewHtml' => $previewHtml, + ); // Return status, suggested view, and data to controller return array( 'status' => $success, diff --git a/views/admin/billing/editInvoice.html b/views/admin/billing/editInvoice.html index be9d42c..67e3188 100644 --- a/views/admin/billing/editInvoice.html +++ b/views/admin/billing/editInvoice.html @@ -1,245 +1,297 @@ +{* Edit Invoice *} + +{* Header *} {include file='admin/billing/header.html'} -
- - {if $invoiceUpdated}Invoice Updated{/if} - {if $invoiceUpdateError}Invoice Update Error{/if} - {if $invoiceInsertError}Invoice Insert Error{/if} - {if $invoiceAdded}Invoice Added{/if} - -
-
- {if $invoice_id} - - - - - - - - - {else} - - {/if} -
-
-
- {if !$invoice_id} - - - - New Account - {/if} -
-
- - -
-
- - -
-
+{* Grid Start *} +{$ui = [ + 'nowrap' => false, + 'backgroundColor' => '', + 'sectionColor' => '' +]} +{include file='ui/f6/grid-start.html'} + +{* Set $data to $invoiceType *} +{* This is for using the UI elements *} +{$data = $invoices} + +{* Invoice Updated *} +{$ui = [ + 'label' => 'Invoice Updated', + 'active' => $invoiceUpdated, + 'type' => 'success' +]} +{include file='ui/f6/callout.html'} +{* Invoice Update Error *} +{$ui = [ + 'label' => 'Invoice Update Error', + 'active' => $invoiceUpdateError, + 'type' => 'alert' +]} +{include file='ui/f6/callout.html'} +{* Invoice Insert Error *} +{$ui = [ + 'label' => 'Invoice Insert Error', + 'active' => $invoiceInsertError, + 'type' => 'alert' +]} +{include file='ui/f6/callout.html'} +{* Invoice Added *} +{$ui = [ + 'label' => 'Invoice Added', + 'active' => $invoiceAdded, + 'type' => 'success' +]} +{include file='ui/f6/callout.html'} + +{* Form Start *} +{$ui = [ + 'id' => 'create-invoice-form', + 'action' => "{$thisUrl}?page={$thisPage}&glm_action=invoices", + 'method' => 'post', + 'file' => false +]} +{include file='ui/f6/form-start.html'} + +{if $invoice_id} + + + + + + + + +{else} + +{/if} + +
+ +
+ Invoice + +
+ +
+ + {if !$invoice_id} + + + New Account + {else} + {$invoices.fieldData.member_name} + {/if}
-
-
- -
-
-
-
- Total Amount:     - -
-
$0.00
-
+
+ + +
+
+ + +
+ +
+
+
+
+ Total Amount:     +
+
$0.00
-
-
- -
+ +
+
- -
- {* New Account Form - Dialog *} -
-

* required

-
- - -
-
-
- - -
-
- - -
-
- - -
-
- - -
-
- - -
- {if $settings.billing_contact_name_enabled} -
- - -
- {else} -
- - -
-
- - -
- {/if} +
+ {* Form End *} + {include file='ui/f6/form-end.html'} +
+
+{* New Account Form - Dialog *} +
+

* required

+ + + +
+
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+ {if $settings.billing_contact_name_enabled}
- - + +
+ {else}
- - + +
- - + +
- {if $settings.billing_county_enabled} -
- - -
- {else} - - {/if} + {/if} + +
+ + +
+
+ + +
+
+ + +
+ {if $settings.billing_county_enabled}
- - - {foreach $billingAccount.fieldData.billing_state.list as $s} + {foreach $billingAccount.fieldData.billing_county.list as $s} {/foreach}
-
- - -
-
- - -
- + {else} + + {/if} +
+ +
-
- -
- {* Enter a Line Item Form - jQueryUI dialog *} -
-

* Required!

-
- - -
-
-
- - -
-
-

-
-
- -
- - % -
-
+
+ + +
+
+ +
+
- -
- {* Add new Invoice Type (Custom Line Item) Form *} -
-

* Required!

- - - - - - - - - - - - - -
Parent - + +
+
+
+ + -
Line Item Name
Amount
Numbers only (999.99)
-
- +
+
+

+
+
+ +
+ + % +
+
+
+
+ +
+{* Add new Invoice Type (Custom Line Item) Form *} +
+

* Required!

+ + + + + + + + + + + + + +
Parent + +
Line Item Name
Amount
Numbers only (999.99)
+ +{* Grid End *} +{include file='ui/f6/grid-end.html'} + + diff --git a/views/admin/billing/editInvoiceType.html b/views/admin/billing/editInvoiceType.html index d8e2c51..b970fc7 100644 --- a/views/admin/billing/editInvoiceType.html +++ b/views/admin/billing/editInvoiceType.html @@ -212,24 +212,19 @@