Setup the member statement model view and setup support class.
authorSteve Sutton <ssutton@gmail.com>
Sun, 10 Dec 2017 18:09:08 +0000 (13:09 -0500)
committerSteve Sutton <ssutton@gmail.com>
Sun, 10 Dec 2017 18:09:08 +0000 (13:09 -0500)
Setting up support class.
Created methods to record invoice and payment transactions.

classes/billingSupport.php [new file with mode: 0644]
config/plugin.ini
models/admin/billing/invoices.php
models/admin/member/billing.php
setup/validActions.php
views/admin/billing/billing.html [new file with mode: 0644]

diff --git a/classes/billingSupport.php b/classes/billingSupport.php
new file mode 100644 (file)
index 0000000..cf76888
--- /dev/null
@@ -0,0 +1,100 @@
+<?php
+/**
+ * Gaslight Media Associate
+ * Billings Plugin support class
+ *
+ * PHP version 5.5
+ *
+ * @category glmWordPressPlugin
+ * @package  glmMembersDatabase
+ * @author   Chuck Scott <cscott@gaslightmedia.com>
+ * @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()
+        );
+    }
+
+}
index 4c5d9f7..eae86b3 100644 (file)
@@ -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"
index ccaf14e..968c74e 100644 (file)
  */
 
 // 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();
index 897c86e..7799289 100644 (file)
@@ -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 '<pre>$this->memberID: ' . print_r( $this->memberID, true) . '</pre>';
+            // echo '<pre>$memberData: ' . print_r( $memberData, true) . '</pre>';
+            $Invoices = new GlmDataInvoices( $this->wpdb, $this->config );
+            // $where = "T."
+            // $invoices = $Invoices->getList($where);
+
             break;
         }
 
index 8b65c5f..0198097 100644 (file)
@@ -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 (file)
index 0000000..0f74edc
--- /dev/null
@@ -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}
+
+    <table class="glm-admin-table">
+        <tr>
+            <td colspan="2" align="">
+            </td>
+        </tr>
+    </table>
+
+    <table class="glm-admin-table">
+        <tr><th>Number of Pending Invoices Listed: </th><td> replace me </td></tr>
+    </table>
+
+{include file='admin/footer.html'}