updates for statements
authorSteve Sutton <steve@gaslightmedia.com>
Mon, 11 Dec 2017 21:39:30 +0000 (16:39 -0500)
committerSteve Sutton <steve@gaslightmedia.com>
Mon, 11 Dec 2017 21:39:30 +0000 (16:39 -0500)
Update the member statements for invoices and payments.
fix the db update script by naming it correctly.

12 files changed:
classes/billingSupport.php
classes/data/dataPayments.php [new file with mode: 0644]
models/admin/billing/payments.php [new file with mode: 0644]
models/admin/member/billing.php
setup/databaseScripts/update_database_V0.0.1.sql [deleted file]
setup/databaseScripts/update_database_V0.0.2.sql [new file with mode: 0644]
setup/validActions.php
views/admin/billing/editPayment.html [new file with mode: 0644]
views/admin/billing/header.html
views/admin/billing/paymentHeader.html [new file with mode: 0644]
views/admin/billing/payments.html [new file with mode: 0644]
views/admin/billing/statements.html

index 18abc6d..0189b11 100644 (file)
@@ -98,8 +98,8 @@ class GlmBillingSupport
      * @access public
      * @return void
      */
-    public function recordPayment( $invoice_id, $payment ) {
-        $this->recordTransaction( $this->config['transaction_numb']['Payment'], $invoice_id, null, $payment );
+    public function recordPayment( $payment_id, $account, $payment ) {
+        $this->recordTransaction( $this->config['transaction_numb']['Payment'], $payment_id, $account, null, $payment );
     }
 
     /**
@@ -164,6 +164,9 @@ class GlmBillingSupport
      */
     public function getStatements( $ref_dest )
     {
+        $balance_due = (float)0.00;
+        $invoice     = false;
+        $payment     = false;
         // First, need to get the Account id for this ref_dest
         $account_data = $this->getAccountByRefDest( $ref_dest );
 
@@ -182,9 +185,16 @@ class GlmBillingSupport
             $type = $transaction['type'];
             switch ( $type ){
             case $this->config['transaction_numb']['Invoice']:
-                $transaction['transaction_data'] = $this->getInvoiceById( $transaction['type_id'] );
+                $invoice = $this->getInvoiceById( $transaction['type_id'] );
+                $balance_due = $balance_due + $invoice['amount_total'];
+                // add to the $transaction array
+                $transaction['transaction_data'] = $invoice;
                 break;
             case $this->config['transaction_numb']['Payment']:
+                $payment = $this->getPaymentById( $transaction['type_id'] );
+                $balance_due = $balance_due - $payment['amount'];
+                // add to the $transaction array
+                $transaction['transaction_data'] = $payment;
                 break;
             }
         }
@@ -193,6 +203,7 @@ class GlmBillingSupport
         return array(
             'account_data' => $account_data,
             'transactions' => $transactions,
+            'balance_due'  => $balance_due,
         );
     }
 
@@ -236,7 +247,7 @@ class GlmBillingSupport
                 "SELECT *
                    FROM " . GLM_MEMBERS_BILLING_PLUGIN_DB_PREFIX . "transactions
                   WHERE account = %d
-                ORDER BY transaction_time DESC",
+                ORDER BY transaction_time ASC",
                 $account
             ),
             ARRAY_A
@@ -266,5 +277,26 @@ class GlmBillingSupport
         );
     }
 
+    /**
+     * getPaymentById
+     *
+     * Get the payment by it's id
+     *
+     * @param mixed $payment_id
+     * @access public
+     * @return void
+     */
+    public function getPaymentById( $payment_id )
+    {
+        return $this->wpdb->get_row(
+            $this->wpdb->prepare(
+                "SELECT *
+                   FROM " . GLM_MEMBERS_BILLING_PLUGIN_DB_PREFIX . "payments
+                  WHERE id = %d",
+                $payment_id
+            ),
+            ARRAY_A
+        );
+    }
 }
 
diff --git a/classes/data/dataPayments.php b/classes/data/dataPayments.php
new file mode 100644 (file)
index 0000000..5dfb432
--- /dev/null
@@ -0,0 +1,197 @@
+<?php
+/**
+ * GLM Member-DB WordPress Add-On Plugin
+ * Data Class Management
+ *
+ * PHP version 5.3
+ *
+ * @category Data
+ * @package  GLM Member-DB
+ * @author   Chuck Scott <cscott@gaslightmedia.com>
+ * @license  http://www.gaslightmedia.com Gaslightmedia
+ * @release  SVN: $Id: dataEvents.php,v 1.0 2011/01/25 19:31:47 cscott Exp $
+ */
+
+/**
+ * GlmDataBillingManagement class
+ *
+ * PHP version 5
+ *
+ * @category Data
+ * @package GLM Member DB
+ * @author  Chuck Scott <cscott@gaslightmedia.com>
+ * @license http://www.gaslightmedia.com Gaslightmedia
+ *          @release SVN: $Id: dataMembers.php,v 1.0 2011/01/25 19:31:47 cscott
+ *          Exp $
+ */
+class GlmDataPayments extends GlmDataAbstract
+{
+
+    /**
+     * WordPress Database Object
+     *
+     * @var $wpdb
+     * @access public
+     */
+    public $wpdb;
+    /**
+     * Plugin Configuration Data
+     *
+     * @var $config
+     * @access public
+     */
+    public $config;
+    /**
+     * Data Table Name
+     *
+     * @var $table
+     * @access public
+     */
+    public $table;
+    /**
+     * Field definitions
+     *
+     * 'type' is type of field as defined by the application
+     * text Regular text field
+     * pointer Pointer to an entry in another table
+     * 'filters' is the filter name for a particular filter ID in PHP filter
+     * functions
+     * See PHP filter_id()
+     *
+     * 'use' is when to use the field
+     * l = List
+     * g = Get
+     * n = New
+     * i = Insert
+     * e = Edit
+     * u = Update
+     * d = Delete
+     * a = All
+     *
+     * @var $ini
+     * @access public
+     */
+    public $fields = 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, $limitedEdit = false)
+    {
+
+        // 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;
+
+        }
+
+        /*
+         * Table Name
+         */
+        $this->table = GLM_MEMBERS_BILLING_PLUGIN_DB_PREFIX . 'payments';
+
+        /*
+         * Table Data Fields
+         */
+
+        $this->fields = array (
+
+            'id' => array (
+                'field'     => 'id',
+                'type'      => 'integer',
+                'view_only' => true,
+                'use'       => 'a',
+            ),
+
+            // Transaction time
+            'transaction_time' => array(
+                'field' => 'transaction_time',
+                'type'  => 'datetime',
+                'use'   => 'a',
+            ),
+
+            // Account ref to accounts table
+            'account' => array(
+                'field'      => 'account',
+                'type'       => 'pointer',
+                'p_table'    => GLM_MEMBERS_BILLING_PLUGIN_DB_PREFIX .  'accounts',
+                'p_field'    => 'ref_dest',
+                'p_orderby'  => 'ref_name',
+                'p_blank'    => true,
+                'force_list' => true,
+                'required'   => false,
+                'use'        => 'a'
+            ),
+
+            // Account ref to invoice table
+            'invoice' => array(
+                'field'      => 'invoice',
+                'type'       => 'pointer',
+                'p_table'    => GLM_MEMBERS_BILLING_PLUGIN_DB_PREFIX .  'invoices',
+                'p_field'    => 'id',
+                'p_orderby'  => 'transaction_time',
+                'p_blank'    => true,
+                'force_list' => true,
+                'required'   => false,
+                'use'        => 'a'
+            ),
+
+            // Amount Total
+            'amount' => array(
+                'field' => 'amount',
+                'type'  => 'text',
+                'use'   => 'a',
+            ),
+
+            // Payment Method
+            'payment_method' => array(
+                'field'   => 'payment_method',
+                'type'    => 'text',
+                'use'     => 'a',
+            ),
+
+            // Payment Data
+            'payment_data' => array(
+                'field'   => 'payment_data',
+                'type'    => 'text',
+                'use'     => 'a',
+            ),
+
+         );
+
+
+    }
+
+    /*
+     * Entry Post Processing Call-Back Method
+     *
+     * Perform post-processing for all result entries.
+     *
+     * In this case we're using it to append an array of category
+     * data to each member result and also sort by member name.
+     *
+     * @param array $r Array of field result data for a single entry
+     * @param string $a Action being performed (l, i, g, ...)
+     *
+     * @return object Class object
+     *
+     */
+    public function entryPostProcessing($r, $a)
+    {
+        return $r;
+    }
+
+
+}
diff --git a/models/admin/billing/payments.php b/models/admin/billing/payments.php
new file mode 100644 (file)
index 0000000..0eed3b2
--- /dev/null
@@ -0,0 +1,316 @@
+<?php
+/**
+ * Gaslight Media Members Database
+ * Admin Transactions List
+ *
+ * PHP version 5.5
+ *
+ * @category glmWordPressPlugin
+ * @package  glmMembersDatabase
+ * @author   Chuck Scott <cscott@gaslightmedia.com>
+ * @license  http://www.gaslightmedia.com Gaslightmedia
+ * @release  index.php,v 1.0 2014/10/31 19:31:47 cscott Exp $
+ * @link     http://dev.gaslightmedia.com/
+ */
+
+// Load Contacts data class
+require_once GLM_MEMBERS_BILLING_PLUGIN_CLASS_PATH . '/data/dataPayments.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_payments extends GlmDataPayments
+{
+
+    /**
+     * WordPress Database Object
+     *
+     * @var $wpdb
+     * @access public
+     */
+    public $wpdb;
+    /**
+     * Plugin Configuration Data
+     *
+     * @var $config
+     * @access public
+     */
+    public $config;
+    /**
+     * Transactions ID
+     *
+     * @var $invoice_id
+     * @access public
+     */
+    public $invoice_id = false;
+
+    /**
+     * Constructor
+     *
+     * This constructor performs the work for this model. This model returns
+     * an array containing the following.
+     *
+     * 'status'
+     *
+     * True if successful and false if there was a fatal failure.
+     *
+     * 'view'
+     *
+     * A suggested view name that the controller should use instead of the
+     * default view for this model or false to indicate that the default view
+     * should be used.
+     *
+     * 'data'
+     *
+     * Data that the model is returning for use in merging with the view to
+     * produce output.
+     *
+     * @wpdb object WordPress database object
+     *
+     * @return array Array containing status, suggested view, and any data
+     */
+    public function __construct ($wpdb, $config)
+    {
+
+        // Save WordPress Database object
+        $this->wpdb = $wpdb;
+
+        // Save plugin configuration object
+        $this->config = $config;
+
+        /*
+         * Run constructor for the Contacts data class
+         *
+         * Note, the third parameter is a flag that indicates to the Contacts
+         * data class that it should flag a group of fields as 'view_only'.
+         */
+        parent::__construct(false, false, true);
+
+    }
+
+    public function modelAction($actionData = false)
+    {
+
+        $option              = 'list';
+        $this->invoice_id    = false;
+        $havePayments        = false;
+        $invoiceUpdated      = false;
+        $invoiceUpdateError  = false;
+        $invoiceAdded        = false;
+        $invoiceAddError     = false;
+        $view                = 'payments';
+        $fromDate            = false;
+        $toDate              = false;
+        $filterArchived      = false;
+        $filterPending       = false;
+        $filterFeatured      = false;
+        $invoiceDeleted      = false;
+        $invoiceDeleteError  = false;
+        $invoiceInsertError  = false;
+        $numbDisplayed       = false;
+        $lastDisplayed       = false;
+        $paging              = true;
+        $prevStart           = false;
+        $nextStart           = false;
+        $start               = 1;
+        $limit               = 20;        // Set to the number of listings per page
+        $invTypes            = array();
+        $invoiceTypes        = false;
+        $invoiceTypeJSON     = '';
+        $accounts            = false;
+
+        // Get any provided option
+        if (isset($_REQUEST['option'])) {
+            $option = $_REQUEST['option'];
+        }
+
+        // Do selected option
+        switch ($option) {
+
+        case 'add':
+            $payments = $this->newEntry();
+            $view     = 'editPayment';
+            // Need to get the accounts
+            $Accounts = new GlmDataAccounts( $this->wpdb, $this->config );
+            $accounts = $Accounts->getList();
+            break;
+
+        case 'insert':
+            // Set transaction_time to current time.
+            $_REQUEST['transaction_time'] = date('Y-m-d H:i:s');
+            echo '<pre>' . print_r( $_REQUEST, true ) . '</pre>';
+            $payments = $this->insertEntry();
+            $this->payment_id = $payments['fieldData']['id'];
+            $BillingSupport = new GlmBillingSupport( $this->wpdb, $this->config );
+            $BillingSupport->recordPayment( $this->payment_id, $_REQUEST['account'], $payments['fieldData']['amount'] );
+            echo '<pre>$payments: ' . print_r( $payments, true ) . '</pre>';
+
+            $view = 'editPayment';
+            break;
+
+        case 'edit':
+            $payments = $this->editEntry($this->invoice_id);
+
+            // If we have a good payments
+            if ($payments['status']) {
+                $haveTransactions = true;
+            }
+
+            // If we're locked to a member as a contact user and the payments member doesn't equal the contact member
+            if ($lockedToMember && $payments['fieldData']['ref_dest_id'] != $lockedToMember) {
+                $haveTransactions = false;
+                $payments = false;
+            }
+
+            $view = 'editPayment';
+            break;
+
+        case 'update':
+
+            // Try to update this payments
+            $payments = $this->updateEntry($this->invoice_id);
+
+            // Check if that was successful
+            if ($payments['status']) {
+                $invoiceUpdated = true;
+
+                $payments = $this->editEntry($this->invoice_id);
+            } else {
+                $invoiceUpdateError = true;
+            }
+
+            $view = 'editPayment';
+
+            break;
+
+        case 'delete':
+            // Need to remove any line items for the invoice alse
+            // $payments = $this->deleteTransactions($this->invoice_id);
+
+            if ($payments) {
+                $invoiceDeleted = true;
+            } else {
+                $invoiceDeleteError = true;
+            }
+
+        case 'list':
+        default:
+
+            $where = 'true';
+
+            // Check for paging
+            if ( isset( $_REQUEST['pageSelect'] ) ) {
+                $_SESSION['search']['pageSelect'] = $_REQUEST['pageSelect'];
+            } else if ( isset( $_REQUEST['searched'] ) && !isset( $_REQUEST['pageSelect'] ) ) {
+                unset( $_SESSION['search']['pageSelect'] );
+            }
+            if ( isset( $_REQUEST['nextStart'] ) ) {
+                $_SESSION['search']['nextStart'] = $_REQUEST['nextStart'];
+            } else if ( isset( $_REQUEST['searched'] ) && !isset( $_REQUEST['nextStart'] ) ) {
+                unset( $_SESSION['search']['nextStart'] );
+            }
+            if ( isset( $_REQUEST['prevStart'] ) ) {
+                $_SESSION['search']['prevStart'] = $_REQUEST['prevStart'];
+            } else if ( isset( $_REQUEST['searched'] ) && !isset( $_REQUEST['prevStart'] ) ) {
+                unset( $_SESSION['search']['prevStart'] );
+            }
+
+            // Check if we're doing paging
+            if (isset($_REQUEST['pageSelect'])) {
+                // If request is for Next
+                if ($_REQUEST['pageSelect'][0] == 'N') {
+                    $newStart = $_REQUEST['nextStart'] - 0;
+
+                // Otherwise it must be Previous
+                } else {
+                    $newStart = $_REQUEST['prevStart'] - 0;
+                }
+
+                if ($newStart > 0) {
+                    $start = $newStart;
+                }
+            }
+
+            if( isset($_SESSION['search']['pageSelect']) ){
+                 // If request is for Next
+                if ($_SESSION['search']['pageSelect'][0] == 'N') {
+                    $newStart = $_SESSION['search']['nextStart'] - 0;
+
+                // Otherwise it must be Previous
+                } else {
+                    $newStart = $_SESSION['search']['prevStart'] - 0;
+                }
+                if ($newStart > 0) {
+                    $start = $newStart;
+                }
+            }
+
+            // Get the list of payments and determine number of payments in list
+            $orderBy = 'transaction_time asc';
+            $paymentsResult = $this->getList($where, $orderBy, true, 'id', $start, $limit);
+
+            // Get paging results
+            $numbDisplayed = $paymentsResult['returned'];
+            $lastDisplayed = $paymentsResult['last'];
+            if ($start == 1) {
+                $prevStart = false;
+            } else {
+                $prevStart = $start - $limit;
+                if ($start < 1) {
+                    $start = 1;
+                }
+            }
+            if ($paymentsResult['returned'] == $limit) {
+                $nextStart = $start + $limit;
+            }
+
+            // since we're doing paging, we have to break out just the payments data
+            $payments = $paymentsResult['list'];
+            if (count($payments)>0) {
+                $havePayments = true;
+            }
+            unset($paymentsResult);
+
+            // echo '<pre>$payments: ' . print_r( $payments, true ) . '</pre>';
+
+            break;
+
+        }
+
+
+        $templateData = array(
+            'option'              => $option,
+            'invoice_id'          => $this->invoice_id,
+            'payments'            => $payments,
+            'havePayments'        => $havePayments,
+            'invoiceUpdated'      => $invoiceUpdated,
+            'invoiceUpdateError'  => $invoiceUpdateError,
+            'invoiceAdded'        => $invoiceAdded,
+            'invoiceAddError'     => $invoiceAddError,
+            'invoiceInsertError'  => $invoiceInsertError,
+            // 'numbTransactions' => $numbTransactions,
+            'invoiceDeleted'      => $invoiceDeleted,
+            'invoiceDeleteError'  => $invoiceDeleteError,
+            'invoiceInvoiceError' => $invoiceDeleteError,
+            'numbDisplayed'       => $numbDisplayed,
+            'lastDisplayed'       => $lastDisplayed,
+            'paging'              => $paging,
+            'prevStart'           => $prevStart,
+            'nextStart'           => $nextStart,
+            'start'               => $start = 1,
+            'limit'               => $limit,
+            'invoiceTypeJSON'     => $invoiceTypeJSON,
+            'invoiceTypes'        => $invoiceTypes,
+            'accounts'            => $accounts,
+        );
+
+        // Return status, any suggested view, and any data to controller
+        return array(
+            'status'        => true,
+            'modelRedirect' => false,
+            'view'          => "admin/billing/$view.html",
+            'data'          => $templateData
+        );
+
+    }
+
+}
index 019fa7f..8bd7b1b 100644 (file)
@@ -111,6 +111,7 @@ class GlmMembersAdmin_member_billing // extends GlmDataBilling
         $accountInsertError = false;
         $transactions       = false;
         $account_data       = false;
+        $balance_due        = false;
 
         // For lockedToMember.
         $lockedToMember = false;
@@ -226,7 +227,9 @@ class GlmMembersAdmin_member_billing // extends GlmDataBilling
             if ( $statements ) {
                 $transactions = $statements['transactions'];
                 $account_data = $statements['account_data'];
+                $balance_due  = $statements['balance_due'];
             }
+            // echo '<pre>$statements: ' . print_r( $statements, true ) . '</pre>';
 
 
             break;
@@ -252,6 +255,7 @@ class GlmMembersAdmin_member_billing // extends GlmDataBilling
             'accountInsertError' => $accountInsertError,
             'transactions'       => $transactions,
             'account_data'       => $account_data,
+            'balance_due'        => $balance_due,
             'transaction_types'  => $this->config['transaction_type'],
         );
 
diff --git a/setup/databaseScripts/update_database_V0.0.1.sql b/setup/databaseScripts/update_database_V0.0.1.sql
deleted file mode 100644 (file)
index ed54969..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
--- Gaslight Media Billing Database
--- File Created: 12/07/2017
--- Database Version: 0.0.2
---
--- To permit each query below to be executed separately,
--- all queries must be separeted by a line with four dashes
-
--- Add new field for payments table
-ALTER TABLE {prefix}payments ADD invoice INT NOT NULL; -- ref to invoice table
diff --git a/setup/databaseScripts/update_database_V0.0.2.sql b/setup/databaseScripts/update_database_V0.0.2.sql
new file mode 100644 (file)
index 0000000..ed54969
--- /dev/null
@@ -0,0 +1,9 @@
+-- Gaslight Media Billing Database
+-- File Created: 12/07/2017
+-- Database Version: 0.0.2
+--
+-- To permit each query below to be executed separately,
+-- all queries must be separeted by a line with four dashes
+
+-- Add new field for payments table
+ALTER TABLE {prefix}payments ADD invoice INT NOT NULL; -- ref to invoice table
index 0198097..67cf729 100644 (file)
@@ -68,6 +68,7 @@ $glmMembersBillingAddOnValidActions = array(
             'index'    => GLM_MEMBERS_BILLING_PLUGIN_SLUG,
             'list'     => GLM_MEMBERS_BILLING_PLUGIN_SLUG,
             'invoices' => GLM_MEMBERS_BILLING_PLUGIN_SLUG,
+            'payments' => GLM_MEMBERS_BILLING_PLUGIN_SLUG,
         ),
         'member' => array(
             'billing' => GLM_MEMBERS_BILLING_PLUGIN_SLUG,
diff --git a/views/admin/billing/editPayment.html b/views/admin/billing/editPayment.html
new file mode 100644 (file)
index 0000000..ecfdb85
--- /dev/null
@@ -0,0 +1,78 @@
+{include file='admin/billing/header.html'}
+
+{include file='admin/billing/paymentHeader.html'}
+
+{if $paymentUpdated}<span class="glm-notice glm-flash-updated">Notification Updated</span>{/if}
+{if $paymentUpdateError}<span class="glm-notice glm-flash-updated">Notification Update Error</span>{/if}
+{if $paymentInsertError}<span class="glm-notice glm-flash-updated">Notification Insert Error</span>{/if}
+{if $paymentAdded}<span class="glm-notice glm-flash-updated">Notification Added</span>{/if}
+
+<div id="billing-payment-form">
+    <form action="{$thisUrl}?page={$thisPage}&glm_action=payments" method="post">
+        {if $payment_id}
+            <input type="hidden" name="option" value="update">
+            <input type="hidden" name="id" value="{$payment_id}">
+        {else}
+            <input type="hidden" name="option" value="insert">
+        {/if}
+        <div class="glm-row">
+            <div class="glm-columns glm-small-12 glm-large-8">
+
+                <div class="glm-row">
+                    <div class="glm-columns glm-small-12 glm-large-3 glm-required">
+                        Member Account
+                    </div>
+                    <div class="glm-columns glm-small-12 glm-large-9">
+                        <select name="account" required>
+                            <option value="">Select an Account</option>
+                            {foreach $accounts as $account}
+                                <option value="{$account.id}">{$account.ref_name}</option>
+                            {/foreach}
+                        </select>
+                    </div>
+                </div>
+                <div class="glm-row">
+                    <div class="glm-columns glm-small-12 glm-large-3 glm-required">
+                        Invoice Number
+                    </div>
+                    <div class="glm-columns glm-small-12 glm-large-9">
+                        <input type="text" name="invoice" required>
+                    </div>
+                </div>
+                <div class="glm-row">
+                    <div class="glm-columns glm-small-12 glm-large-3 glm-required">
+                        Amount
+                    </div>
+                    <div class="glm-columns glm-small-12 glm-large-9">
+                        <input type="text" name="amount" required>
+                    </div>
+                </div>
+                <div class="glm-row">
+                    <div class="glm-columns glm-small-12 glm-large-3">
+                        Notes
+                    </div>
+                    <div class="glm-columns glm-small-12 glm-large-9">
+                        <textarea name="notes"></textarea>
+                    </div>
+                </div>
+
+            </div>
+        </div>
+        <div class="glm-row">
+            <div class="glm-columns glm-small-12 glm-large-8">
+                <input class="button button-primary" type="submit" value="{if $payment_id}Save{else}Create{/if} Payment">
+            </div>
+        </div>
+    </form>
+</div>
+
+<script>
+jQuery(document).ready(function($){
+
+    // Flash certain elements for a short time after display
+    $(".glm-flash-updated").fadeOut(500).fadeIn(500).fadeOut(500).fadeIn(500).fadeOut(500).fadeIn(500).fadeOut(500).fadeIn(500).fadeOut(500);
+
+});
+</script>
+
+{include file='admin/footer.html'}
index a2b5e4b..31289e7 100644 (file)
@@ -3,6 +3,7 @@
     <h2 class="nav-tab-wrapper">
         <a href="{$thisUrl}?page=glm-members-admin-menu-billing" class="nav-tab{if $thisAction==index} nav-tab-active{/if}">Dashboard</a>
         <a href="{$thisUrl}?page=glm-members-admin-menu-billing&glm_action=invoices" class="nav-tab{if $thisAction==invoices} nav-tab-active{/if}">Invoices</a>
+        <a href="{$thisUrl}?page=glm-members-admin-menu-billing&glm_action=payments" class="nav-tab{if $thisAction==payments} nav-tab-active{/if}">Payments</a>
     </h2>
     <div id="glm-admin-content-container">
 
diff --git a/views/admin/billing/paymentHeader.html b/views/admin/billing/paymentHeader.html
new file mode 100644 (file)
index 0000000..8d6fe7b
--- /dev/null
@@ -0,0 +1,6 @@
+<h2 class="nav-tab-wrapper" style="margin-bottom: 1em;">
+    <a href="{$thisUrl}?page=glm-members-admin-menu-billing&glm_action=payments"
+        class="nav-tab{if $option == 'list'} nav-tab-active{/if}">Search Payments</a>
+    <a href="{$thisUrl}?page=glm-members-admin-menu-billing&glm_action=payments&option=add"
+        class="nav-tab{if $option == 'add' || $option == 'edit'} nav-tab-active{/if}">Make a Payment</a>
+</h2>
diff --git a/views/admin/billing/payments.html b/views/admin/billing/payments.html
new file mode 100644 (file)
index 0000000..1e5c82f
--- /dev/null
@@ -0,0 +1,46 @@
+{include file='admin/billing/header.html'}
+
+{include file='admin/billing/paymentHeader.html'}
+
+
+<h2>Payments</h2>
+
+<table class="wp-list-table widefat fixed posts glm-admin-table">
+    <thead>
+        <tr>
+            <th>ID</th>
+            <th>Member Name</th>
+            <th>Time</th>
+            <th>Due Date</th>
+            <th>Balance</th>
+        </tr>
+    </thead>
+    <tbody>
+        {if $haveInvoices}
+            {assign var="i" value="0"}
+            {foreach $invoices as $t}
+                {if $i++ is odd by 1}
+                    <tr>
+                {else}
+                    <tr class="alternate">
+                {/if}
+                    <td> {$t.id} </td>
+                    <td> {$t.member_name} </td>
+                    <td> {$t.transaction_time.datetime} </td>
+                    <td> {$t.due_date.date} </td>
+                    <td> {$t.balance} </td>
+                </tr>
+            {/foreach}
+        {else}
+            <tr class="alternate"><td colspan="2">(no Invoice Types listed)</td></tr>
+        {/if}
+    </tbody>
+</table>
+
+<script type="text/javascript">
+    jQuery(document).ready(function($) {
+
+    });
+</script>
+
+{include file='admin/footer.html'}
index 218cef7..ec9e808 100644 (file)
                 <th>Due Date</th>
                 <th>Type</th>
                 <th>Amount</th>
-                <th>Balance</th>
             </tr>
         </thead>
         <tbody>
         {$alt = 0}
-        {$total_due = 0.00}
-        {$total_balance = 0.00}
         {foreach $transactions as $transaction}
             <tr{if $alt % 2 == 0} class="alternate"{/if}>
-                <td>{$transaction.transaction_data.transaction_time|date_format:"%D"}</td>
-                <td>{$transaction.transaction_data.due_date|date_format:"%D"}</td>
-                <td>{$transaction_types[$transaction.type]}</td>
-                <td>{$transaction.transaction_data.amount_total}</td>
-                <td>{$transaction.transaction_data.balance}</td>
+                {if $transaction.type == '10'}
+                    <td>{$transaction.transaction_data.transaction_time|date_format:"%D"}</td>
+                    <td>{$transaction.transaction_data.due_date|date_format:"%D"}</td>
+                    <td>{$transaction_types[$transaction.type]}</td>
+                    <td>${$transaction.transaction_data.amount_total}</td>
+                {elseif $transaction.type == '20'}
+                    <td>{$transaction.transaction_data.transaction_time|date_format:"%D"}</td>
+                    <td></td>
+                    <td>{$transaction_types[$transaction.type]}</td>
+                    <td>${$transaction.transaction_data.amount}</td>
+                {/if}
             </tr>
             {$alt = $alt + 1}
-            {$total_due = $total_due + $transaction.transaction_data.amount_total}
-            {$total_balance = $total_balance + $transaction.transaction_data.balance}
         {/foreach}
-        <tr>
-            <td></td>
+        <tr{if $alt % 2 == 0} class="alternate"{/if}>
             <td></td>
             <td></td>
             <td>Balance Due</td>
-            <td>{$total_balance|string_format:"%.2f"}</td>
+            <td>${$balance_due|string_format:"%.2f"}</td>
         </tr>
         </tbody>
     </table>