From: Steve Sutton Date: Sun, 10 Dec 2017 18:09:08 +0000 (-0500) Subject: Setup the member statement model view and setup support class. X-Git-Tag: v1.0.0^2~201 X-Git-Url: http://cvs2.gaslightmedia.com/gitweb/?a=commitdiff_plain;h=012a228498daa6533b3786bdf3d9c0f54020c720;p=WP-Plugins%2Fglm-member-db-billing.git Setup the member statement model view and setup support class. Setting up support class. Created methods to record invoice and payment transactions. --- diff --git a/classes/billingSupport.php b/classes/billingSupport.php new file mode 100644 index 0000000..cf76888 --- /dev/null +++ b/classes/billingSupport.php @@ -0,0 +1,100 @@ + + * @license http://www.gaslightmedia.com Gaslightmedia + * @release registratiosnSupport.php,v 1.0 2014/10/31 19:31:47 cscott Exp $ + * @link http://dev.gaslightmedia.com/ + */ + + +// Load required data classes for billing +require_once GLM_MEMBERS_BILLING_PLUGIN_CLASS_PATH . '/data/dataAccounts.php'; +require_once GLM_MEMBERS_BILLING_PLUGIN_CLASS_PATH . '/data/dataInvoices.php'; +require_once GLM_MEMBERS_BILLING_PLUGIN_CLASS_PATH . '/data/dataInvoiceTypes.php'; +require_once GLM_MEMBERS_BILLING_PLUGIN_CLASS_PATH . '/data/dataNotificationTypes.php'; + +class GlmBillingSupport +{ + + /** + * WordPress Database Object + * + * @var $wpdb + * @access public + */ + public $wpdb; + /** + * Plugin Configuration Data + * + * @var $config + * @access public + */ + public $config; + /** + * Billing Request Cart + * + * $var $cart + * @access public + */ + public $cart = false; + + /** + * Constructor + * + * @param object $d database connection + * @param array $config Configuration array + * @param bool $limitedEdit Flag to say indicate limited edit requested + * + * @return void + * @access public + */ + public function __construct($wpdb, $config) + { + + // If this class is not being extended along with existing $wpdb and $config + if (!$this->wpdb) { + + // Save WordPress Database object + $this->wpdb = $wpdb; + + // Save plugin configuration object + $this->config = $config; + + } + + } + + public function recordInvoice( $invoice_id, $total ) + { + $this->recordTransaction( $this->config['transaction_numb']['Invoice'], $invoice_id, $total, null ); + } + + public function recordPayment( $invoice_id, $payment ) { + $this->recordTransaction( $this->config['transaction_numb']['Payment'], $invoice_id, null, $payment ); + } + + public function recordTransaction( $type, $type_id, $current_invoice_total = null, $current_payment_total = null ) + { + $current_invoice_total = ( $current_invoice_total == null ) ? '0.00': $current_invoice_total; + $current_payment_total = ( $current_payment_total == null ) ? '0.00': $current_payment_total; + $this->wpdb->insert( + GLM_MEMBERS_BILLING_PLUGIN_DB_PREFIX . 'transactions', + array( + 'type' => $type, + 'type_id' => $type_id, + 'transaction_time' => date('Y-m-d H:i;s'), + 'current_invoice_total' => $current_invoice_total, + 'current_payment_total' => $current_payment_total, + ), + array() + ); + } + +} diff --git a/config/plugin.ini b/config/plugin.ini index 4c5d9f7..eae86b3 100644 --- a/config/plugin.ini +++ b/config/plugin.ini @@ -13,6 +13,11 @@ transaction_type[20] = "Payment" transaction_type[30] = "Adjustment" transaction_type[40] = "Comment" +transaction_numb['Invoice'] = 10; +transaction_numb['Payment'] = 20; +transaction_numb['Adjustment'] = 30; +transaction_numb['Comment'] = 40; + ; Payment Methods payment_method[10] = "Check" payment_method[20] = "Credit Card" diff --git a/models/admin/billing/invoices.php b/models/admin/billing/invoices.php index ccaf14e..968c74e 100644 --- a/models/admin/billing/invoices.php +++ b/models/admin/billing/invoices.php @@ -14,9 +14,10 @@ */ // Load Contacts data class -require_once GLM_MEMBERS_BILLING_PLUGIN_CLASS_PATH.'/data/dataInvoices.php'; -require_once GLM_MEMBERS_BILLING_PLUGIN_CLASS_PATH.'/data/dataInvoiceTypes.php'; -require_once GLM_MEMBERS_BILLING_PLUGIN_CLASS_PATH.'/data/dataAccounts.php'; +require_once GLM_MEMBERS_BILLING_PLUGIN_CLASS_PATH . '/data/dataInvoices.php'; +require_once GLM_MEMBERS_BILLING_PLUGIN_CLASS_PATH . '/data/dataInvoiceTypes.php'; +require_once GLM_MEMBERS_BILLING_PLUGIN_CLASS_PATH . '/data/dataAccounts.php'; +require_once GLM_MEMBERS_BILLING_PLUGIN_CLASS_PATH . '/billingSupport.php'; class GlmMembersAdmin_billing_invoices extends GlmDataInvoices { @@ -182,7 +183,11 @@ class GlmMembersAdmin_billing_invoices extends GlmDataInvoices } } } - $this->generateInvoiceTotal( $this->invoice_id ); + $totals = $this->generateInvoiceTotal( $this->invoice_id ); + // Now we have a total for the invoice we can record the transaction + $BillingSupport = new GlmBillingSupport( $this->wpdb, $this->config ); + $BillingSupport->recordInvoice( $this->invoice_id, $totals['amount_total'] ); + $view = 'editInvoice'; $InvoiceTypesObj = new GlmDataInvoiceTypes( $this->wpdb, $this->config ); $invoiceTypes = $InvoiceTypesObj->getList(); diff --git a/models/admin/member/billing.php b/models/admin/member/billing.php index 897c86e..7799289 100644 --- a/models/admin/member/billing.php +++ b/models/admin/member/billing.php @@ -13,6 +13,7 @@ * @link http://dev.gaslightmedia.com/ */ define('GLM_MEMBERS_BILLING_MEMBER_MENU', true); +require_once GLM_MEMBERS_BILLING_PLUGIN_CLASS_PATH.'/data/dataInvoices.php'; // Load Billing data abstract // require_once GLM_MEMBERS_BILLING_PLUGIN_CLASS_PATH.'/data/dataBilling.php'; @@ -213,6 +214,13 @@ class GlmMembersAdmin_member_billing // extends GlmDataBilling $view = 'editAccount'; break; case 'list': + // Get the list of invoices for this member + echo '
$this->memberID: ' . print_r( $this->memberID, true) . '
'; + // echo '
$memberData: ' . print_r( $memberData, true) . '
'; + $Invoices = new GlmDataInvoices( $this->wpdb, $this->config ); + // $where = "T." + // $invoices = $Invoices->getList($where); + break; } diff --git a/setup/validActions.php b/setup/validActions.php index 8b65c5f..0198097 100644 --- a/setup/validActions.php +++ b/setup/validActions.php @@ -71,7 +71,7 @@ $glmMembersBillingAddOnValidActions = array( ), 'member' => array( 'billing' => GLM_MEMBERS_BILLING_PLUGIN_SLUG, - 'index' => GLM_MEMBERS_BILLING_PLUGIN_SLUG, + // 'index' => GLM_MEMBERS_BILLING_PLUGIN_SLUG, ), ), 'frontActions' => array( diff --git a/views/admin/billing/billing.html b/views/admin/billing/billing.html new file mode 100644 index 0000000..0f74edc --- /dev/null +++ b/views/admin/billing/billing.html @@ -0,0 +1,19 @@ +{if $fromMemberMenu} + {include file='admin/member/header.html'} + {include file='admin/billing/memberBillingSubHeader.html'} +{else} + {include file='admin/billing/header.html'} +{/if} + + + + + +
+
+ + + +
Number of Pending Invoices Listed: replace me
+ +{include file='admin/footer.html'}