WIP for adding create invoice page
authorSteve Sutton <steve@gaslightmedia.com>
Mon, 4 Dec 2017 21:39:37 +0000 (16:39 -0500)
committerSteve Sutton <steve@gaslightmedia.com>
Mon, 4 Dec 2017 21:39:37 +0000 (16:39 -0500)
Working on the create invoice page.

classes/data/dataInvoiceTypes.php
classes/data/dataInvoices.php [new file with mode: 0644]
models/admin/billing/invoices.php
setup/databaseScripts/create_database_V0.0.1.sql
setup/validActions.php
views/admin/billing/editInvoice.html [new file with mode: 0644]
views/admin/billing/header.html
views/admin/billing/invoices.html [new file with mode: 0644]
views/admin/billing/subHeader.html [new file with mode: 0644]

index aaeef24..fed6141 100644 (file)
@@ -72,13 +72,6 @@ class GlmDataInvoiceTypes extends GlmDataAbstract
      * @access public
      */
     public $fields = false;
-    /**
-     * MemberInfo DB object
-     *
-     * @var $MemberInfo
-     * @access public
-     */
-    public $MemberInfo;
 
     /**
      * Constructor
@@ -129,7 +122,7 @@ class GlmDataInvoiceTypes extends GlmDataAbstract
                 'use'   => 'a',
             ),
 
-            // Parent - for adding, deleting and editing, has selection tabels
+            // Parent - for adding, deleting and editing, has selection tables
             'parent' => array(
                 'field' => 'parent',
                 'type' => 'pointer',
diff --git a/classes/data/dataInvoices.php b/classes/data/dataInvoices.php
new file mode 100644 (file)
index 0000000..3a0f8fb
--- /dev/null
@@ -0,0 +1,213 @@
+<?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 GlmDataInvoices 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 . 'invoices';
+
+        /*
+         * 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'
+            ),
+
+            // Anniversary Date For ref_dest
+            'amount_total' => array(
+                'field' => 'amount_total',
+                'type'  => 'text',
+                'use'   => 'a',
+            ),
+
+            // Balance
+            'balance' => array(
+                'field'   => 'balance',
+                'type'    => 'text',
+                'use'     => 'a',
+            ),
+
+            // Due date
+            'due_date' => array(
+                'field' => 'due_date',
+                'type'  => 'text',
+                'use'   => 'a',
+            ),
+
+            // paid
+            'paid' => array(
+                'field'   => 'paid',
+                'type'    => 'checkbox',
+                'default' => false,
+                'use'     => 'a',
+            ),
+
+            // Due date
+            'notes' => array(
+                'field' => 'notes',
+                'type'  => 'text',
+                'use'   => 'a',
+            ),
+
+            // Recurring
+            'recurring' => array(
+                'field'   => 'recurring',
+                'type'    => 'checkbox',
+                'default' => false,
+                'use'     => 'a',
+            ),
+
+            // Recurrence
+            'recurrence' => array(
+                'field' => 'recurrence',
+                '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;
+    }
+
+}
index 91d75c7..616324b 100644 (file)
@@ -14,9 +14,9 @@
  */
 
 // Load Contacts data class
-// require_once GLM_MEMBERS_TRANSACTIONS_PLUGIN_CLASS_PATH.'/data/dataTransactions.php';
+require_once GLM_MEMBERS_BILLING_PLUGIN_CLASS_PATH.'/data/dataInvoices.php';
 
-class GlmMembersAdmin_billing_list // extends GlmDataTransactions
+class GlmMembersAdmin_billing_invoices extends GlmDataInvoices
 {
 
     /**
@@ -81,198 +81,106 @@ class GlmMembersAdmin_billing_list // extends GlmDataTransactions
          * 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);
+        parent::__construct(false, false, true);
 
     }
 
     public function modelAction($actionData = false)
     {
 
-        $currentTab              = 'glm-table-descr';
-        $lockedToMember          = false;
-        $isModerated             = false;
-        $numbTransactions        = 0;
-        $option                  = 'list';
-        $transactions            = false;
-        $haveTransactions        = false;
-        $transactions            = false;
-        $haveTransactions        = false;
-        $this->transactionID     = false;
-        $transactionsUpdated     = false;
-        $transactionsUpdateError = false;
-        $transactionsAdded       = false;
-        $transactionsAddError    = false;
-        $view                    = 'list';
-        $fromDate                = false;
-        $toDate                  = false;
-        $filterArchived          = false;
-        $filterPending           = false;
-        $filterFeatured          = false;
-        $transactionsDeleted     = false;
-        $transactionsDeleteError = false;
-        $memberID                = false;
-        $haveMember              = false;
-        $memberName              = false;
-        $memberData              = false;
-        $numbDisplayed           = false;
-        $lastDisplayed           = false;
-        $paging                  = true;
-        $prevStart               = false;
-        $nextStart               = false;
-        $start                   = 1;
-        $limit                   = 20;        // Set to the number of listings per page
-        $namesList               = false;
-
-        // Check if there's a logged in user who is locked to their own entity
-        $lockedToMember = apply_filters('glm_members_locked_to_member_id', false);
-        if ($lockedToMember) {
-            $isModerated = apply_filters('glm_user_is_moderated', $lockedToMember);
-            $memberID = $lockedToMember;
-            $this->fields['admin_name']['required']  = true;
-            $this->fields['admin_email']['required'] = true;
-            $this->fields['admin_phone']['required'] = true;
-
-            // Check for Member Menu Use
-        } elseif (defined('GLM_TRANSACTIONS_MEMBER_MENU')) {
-
-            // Try to get member ID
-            $memberID = (isset($_REQUEST['member']) ? $_REQUEST['member'] : 0);
-
-            // If there's no valid member ID, we can't continue
-            if ($memberID == 0) {
-                return array(
-                    'status'           => false,
-                    'menuItemRedirect' => 'error',
-                    'modelRedirect'    => 'index',
-                    'view'             => 'admin/error/index.html',
-                    'data'             => array(
-                        'reason' => 'No member ID was provided.'
-                    )
-                );
-            }
-        }
-
-        // If not a valid member ID
-        if ($memberID > 0) {
-
-            // Get base member information
-            require_once GLM_MEMBERS_PLUGIN_CLASS_PATH.'/data/dataMembers.php';
-            $Member     = new GlmDataMembers($this->wpdb, $this->config);
-            $memberData = $Member->getEntry($memberID);
-
-            if (!$memberData) {
-                return array(
-                    'status'           => false,
-                    'menuItemRedirect' => 'error',
-                    'modelRedirect'    => 'index',
-                    'view'             => 'admin/error/index.html',
-                    'data'             => array(
-                        'reason' => 'No member data found for provided member ID.'
-                    )
-                );
-            } else{
-                $haveMember = true;
-                $memberName = $memberData['name'];
-            }
-
-        }
+        $option              = 'list';
+        $this->transactionID = false;
+        $haveInvoices        = false;
+        $invoiceUpdated      = false;
+        $invoiceUpdateError  = false;
+        $invoiceAdded        = false;
+        $invoiceAddError     = false;
+        $view                = 'invoices';
+        $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
 
         // Get any provided option
         if (isset($_REQUEST['option'])) {
             $option = $_REQUEST['option'];
         }
 
-        // See if there's a currentTab in $_REQUEST array
-        if ( isset( $_REQUEST['currentTab'] ) && $_REQUEST['currentTab'] ) {
-            $currentTab = filter_var( $_REQUEST['currentTab'], FILTER_SANITIZE_STRING );
-        }
-
-        // Get transactions ID if supplied
-        if (isset($_REQUEST['transactions'])) {
-
-            // Make sure it's numeric
-            $this->transactionID = ($_REQUEST['transactions'] - 0);
-
-            if ($this->transactionID <= 0) {
-                $this->transactionID = false;
-            }
-
-        }
-
         // Do selected option
         switch ($option) {
 
         case 'add':
-            $transactions = $this->newEntry();
-            $view = 'edit';
+            $invoices = $this->newEntry();
+            $view     = 'editInvoice';
             break;
 
         case 'insert':
-            $transactions = $this->insertEntry();
-            $this->transactionID = $transactions['fieldData']['id'];
-            $view = 'edit';
+            $invoices = $this->insertEntry();
+            $this->transactionID = $invoices['fieldData']['id'];
+            $view = 'editInvoice';
             break;
 
         case 'edit':
-            $transactions = $this->editEntry($this->transactionID);
+            $invoices = $this->editEntry($this->transactionID);
 
-            // If we have a good transactions
-            if ($transactions['status']) {
+            // If we have a good invoices
+            if ($invoices['status']) {
                 $haveTransactions = true;
             }
 
-            // If we're locked to a member as a contact user and the transactions member doesn't equal the contact member
-            if ($lockedToMember && $transactions['fieldData']['ref_dest_id'] != $lockedToMember) {
+            // If we're locked to a member as a contact user and the invoices member doesn't equal the contact member
+            if ($lockedToMember && $invoices['fieldData']['ref_dest_id'] != $lockedToMember) {
                 $haveTransactions = false;
-                $transactions = false;
+                $invoices = false;
             }
 
-            $view = 'edit';
+            $view = 'editInvoice';
             break;
 
         case 'update':
 
-            // Try to update this transactions
-            $transactions = $this->updateEntry($this->transactionID);
+            // Try to update this invoices
+            $invoices = $this->updateEntry($this->transactionID);
 
             // Check if that was successful
-            if ($transactions['status']) {
-                $transactionsUpdated = true;
+            if ($invoices['status']) {
+                $invoiceUpdated = true;
 
-                $transactions = $this->editEntry($this->transactionID);
+                $invoices = $this->editEntry($this->transactionID);
             } else {
-                $transactionsUpdateError = true;
+                $invoiceUpdateError = true;
             }
 
-            $view = 'edit';
+            $view = 'editInvoice';
 
             break;
 
         case 'delete':
 
-            $transactions = $this->deleteTransactions($this->transactionID);
+            $invoices = $this->deleteTransactions($this->transactionID);
 
-            if ($transactions) {
-                $transactionsDeleted = true;
+            if ($invoices) {
+                $invoiceDeleted = true;
             } else {
-                $transactionsDeleteError = true;
+                $invoiceDeleteError = true;
             }
 
-            case 'list':
+        case 'list':
         default:
 
             $where = 'true';
 
-            // If we have a back request then go through the PHP_SESSION
-            // and extract them into the REQUEST array.
-            if ( isset( $_REQUEST['back'] ) && filter_var( $_REQUEST['back'], FILTER_VALIDATE_BOOLEAN ) ) {
-                if ( isset( $_SESSION['search'] ) && is_array( $_SESSION['search'] ) ) {
-                    foreach ( $_SESSION['search'] as $varName => $sessValue ) {
-                        $_REQUEST[$varName] = $sessValue;
-                    }
-                }
-            }
-
             // Check for paging
             if ( isset( $_REQUEST['pageSelect'] ) ) {
                 $_SESSION['search']['pageSelect'] = $_REQUEST['pageSelect'];
@@ -290,97 +198,6 @@ class GlmMembersAdmin_billing_list // extends GlmDataTransactions
                 unset( $_SESSION['search']['prevStart'] );
             }
 
-            // Check for Archived filter
-            if (isset($_REQUEST['filterArchived']) && $_REQUEST['filterArchived'] == 'on') {
-                $filterArchived = true;
-                $_SESSION['search']['archived'] = true;
-                $where .= " AND status = " . $this->config['status_numb']['Archived'];
-            } else if ( isset( $_REQUEST['searched'] ) && !isset( $_REQUEST['filterArchived'] ) ) {
-                unset( $_SESSION['search']['archived'] );
-            }
-
-            // Check for Pending filter
-            if (isset($_REQUEST['filterPending']) && $_REQUEST['filterPending'] == 'on') {
-                $filterPending = true;
-                $_SESSION['search']['pending'] = true;
-                $where .= " AND status = " . $this->config['status_numb']['Pending'];
-            } else if ( isset( $_REQUEST['searched'] ) && !isset( $_REQUEST['filterPending'] ) ) {
-                unset( $_SESSION['search']['pending'] );
-            }
-
-            // Check if we have a Text Search string
-            if (isset($_REQUEST['textSearch']) && trim($_REQUEST['textSearch']) != '') {
-                $textSearch = trim($_REQUEST['textSearch']);
-                $where .= " AND name LIKE '%$textSearch%'";
-                $_SESSION['search']['textSearch'] = $textSearch;
-            } else if ( isset( $_REQUEST['searched'] ) && trim($_REQUEST['textSearch']) == '' ) {
-                unset( $_SESSION['search']['textSearch'] );
-            }
-
-
-            // If we have a From date
-            $dateWhere = '';
-            if (isset($_REQUEST['fromDate']) && trim($_REQUEST['fromDate']) != '') {
-                $fromDate = date('m/d/Y', strtotime($_REQUEST['fromDate']));
-                $fromMYSQL = date('Y-m-d', strtotime($fromDate));
-                $dateWhere = " end_time >= '$fromMYSQL' ";
-                $_SESSION['search']['fromDate'] = $fromDate;
-            } else if ( !isset( $_REQUEST['searched'] ) ) {
-                $fromDate = date('m/d/Y');
-                $fromMYSQL = date('Y-m-d', strtotime($fromDate));
-                $dateWhere = " end_time >= '$fromMYSQL' ";
-            } else if ( isset( $_REQUEST['searched'] ) && trim($_REQUEST['fromDate']) == '' ) {
-                unset( $_SESSION['search']['fromDate'] );
-            }
-
-            // If we have a to Date
-            if (isset($_REQUEST['toDate']) && trim($_REQUEST['toDate']) != '') {
-
-                $toDate = date('m/d/Y', strtotime($_REQUEST['toDate']));
-                $toMYSQL = date('Y-m-d', strtotime($toDate." +1 day"));
-
-                // If we have a from date then we need Parens and AND
-                if ($dateWhere != '') {
-                    $dateWhere = "( ".$dateWhere." AND start_time <= '$toMYSQL' )";
-
-                // Otherwise we don't
-                } else {
-                    $dateWhere = " start_time <= '$toMYSQL' ";
-                }
-                $_SESSION['search']['toDate'] = $toDate;
-            } else if ( isset( $_REQUEST['searched'] ) && trim($_REQUEST['toDate']) == '' ) {
-                unset( $_SESSION['search']['toDate'] );
-            }
-
-            // If we have from and to dates, do search for those inclusive
-            if ($dateWhere != '') {
-                $where .= "
-                    AND id in (
-                        SELECT DISTINCT(transactions)
-                          FROM ".GLM_MEMBERS_TRANSACTIONS_PLUGIN_DB_PREFIX."times
-                         WHERE $dateWhere
-                           AND active
-                    )
-                ";
-            }
-
-            // Check if the list is for a specific member
-            if (defined('GLM_TRANSACTIONS_MEMBER_MENU') || $memberID) {
-                $where .= " AND ref_dest = $memberID";
-                $_SESSION['search']['memberID'] = $memberID;
-            }
-
-            // Get the total number of transactions listed
-            $numbTransactions = $this->getStats($where);
-
-            // If the number of transactions is less than a page, don't do paging
-            if ($numbTransactions <= $limit) {
-                $paging = false;
-            }
-
-            // Get full list of names matching this where clause for search box
-            $namesList = $this->getIdName($where);
-
             // Check if we're doing paging
             if (isset($_REQUEST['pageSelect'])) {
                 // If request is for Next
@@ -411,14 +228,13 @@ class GlmMembersAdmin_billing_list // extends GlmDataTransactions
                 }
             }
 
-            // Get the list of transactions and determine number of transactions in list
-            $orderBy = 'name';
-            // $orderBy = "(select min(start_time) FROM " . GLM_MEMBERS_BILLING_PLUGIN_DB_PREFIX . "times WHERE T.id = transactions),name";
-            $transactionsResult = $this->getList($where, $orderBy, true, 'id', $start, $limit);
+            // Get the list of invoices and determine number of invoices in list
+            $orderBy = 'transaction_time desc';
+            $invoicesResult = $this->getList($where, $orderBy, true, 'id', $start, $limit);
 
             // Get paging results
-            $numbDisplayed = $transactionsResult['returned'];
-            $lastDisplayed = $transactionsResult['last'];
+            $numbDisplayed = $invoicesResult['returned'];
+            $lastDisplayed = $invoicesResult['last'];
             if ($start == 1) {
                 $prevStart = false;
             } else {
@@ -427,58 +243,40 @@ class GlmMembersAdmin_billing_list // extends GlmDataTransactions
                     $start = 1;
                 }
             }
-            if ($transactionsResult['returned'] == $limit) {
+            if ($invoicesResult['returned'] == $limit) {
                 $nextStart = $start + $limit;
             }
 
-            // since we're doing paging, we have to break out just the transactions data
-            $transactions = $transactionsResult['list'];
-            if (count($transactions)>0) {
-                $haveTransactions = true;
+            // since we're doing paging, we have to break out just the invoices data
+            $invoices = $invoicesResult['list'];
+            if (count($invoices)>0) {
+                $haveInvoices = true;
             }
-            unset($transactionsResult);
+            unset($invoicesResult);
 
             break;
 
         }
 
         $templateData = array(
-            'enable_members'          => $enable_members,
-            'lockedToMember'          => $lockedToMember,
-            'isModerated'             => $isModerated,
-            'option'                  => $option,
-            'transactions'            => $transactions,
-            'haveTransactions'        => $haveTransactions,
-            'transactions'            => $transactions,
-            'haveTransactions'        => $haveTransactions,
-            'transactionID'           => $this->transactionID,
-            'transactionsUpdated'     => $transactionsUpdated,
-            'transactionsUpdateError' => $transactionsUpdateError,
-            'transactionsAdded'       => $transactionsAdded,
-            'transactionsAddError'    => $transactionsAddError,
-            'numbTransactions'        => $numbTransactions,
-            'categories'              => $categories,
-            'amenities'               => $amenities,
-            'fromDate'                => $fromDate,
-            'toDate'                  => $toDate,
-            'filterArchived'          => $filterArchived,
-            'filterPending'           => $filterPending,
-            'filterFeatured'          => $filterFeatured,
-            'transactionsDeleted'     => $transactionsDeleted,
-            'transactionsDeleteError' => $transactionsDeleteError,
-            'memberID'                => $memberID,
-            'haveMember'              => $haveMember,
-            'memberName'              => $memberName,
-            'memberData'              => $memberData,
-            'numbDisplayed'           => $numbDisplayed,
-            'lastDisplayed'           => $lastDisplayed,
-            'paging'                  => $paging,
-            'prevStart'               => $prevStart,
-            'nextStart'               => $nextStart,
-            'start'                   => $start = 1,
-            'limit'                   => $limit,
-            'namesList'               => $namesList,
-            'currentTab'              => $currentTab
+            'option'              => $option,
+            'invoices'            => $invoices,
+            'haveInvoices'        => $haveInvoices,
+            'invoiceUpdated'      => $invoiceUpdated,
+            'invoiceUpdateError'  => $invoiceUpdateError,
+            'invoiceAdded'        => $invoiceAdded,
+            'invoiceAddError'     => $invoiceAddError,
+            // 'numbTransactions' => $numbTransactions,
+            'invoiceDeleted'      => $invoiceDeleted,
+            'invoiceDeleteError'  => $invoiceDeleteError,
+            'invoiceInvoiceError' => $invoiceDeleteError,
+            'numbDisplayed'       => $numbDisplayed,
+            'lastDisplayed'       => $lastDisplayed,
+            'paging'              => $paging,
+            'prevStart'           => $prevStart,
+            'nextStart'           => $nextStart,
+            'start'               => $start = 1,
+            'limit'               => $limit,
         );
 
         // Return status, any suggested view, and any data to controller
index d647608..82a1761 100644 (file)
@@ -13,6 +13,7 @@
 CREATE TABLE {prefix}accounts (
     id INT NOT NULL AUTO_INCREMENT,
     ref_dest INT NOT NULL,                                 -- reference to member id
+    ref_name TINYTEXT NOT NULL,                            -- Name of reference member
     anniversary_date DATE NOT NULL,                        -- anniversary date - used for main invoice generation
     payment_data TEXT NULL,                                -- stored payment data
     email TINYTEXT NULL,                                   -- billing email
index 7d6bb65..378389d 100644 (file)
@@ -65,8 +65,9 @@ $glmMembersBillingAddOnValidActions = array(
             'notificationTypes' => GLM_MEMBERS_BILLING_PLUGIN_SLUG,
         ),
         'billing' => array(
-            'index' => GLM_MEMBERS_BILLING_PLUGIN_SLUG,
-            'list'  => GLM_MEMBERS_BILLING_PLUGIN_SLUG,
+            'index'    => GLM_MEMBERS_BILLING_PLUGIN_SLUG,
+            'list'     => GLM_MEMBERS_BILLING_PLUGIN_SLUG,
+            'invoices' => GLM_MEMBERS_BILLING_PLUGIN_SLUG,
         ),
     ),
     'frontActions' => array(
diff --git a/views/admin/billing/editInvoice.html b/views/admin/billing/editInvoice.html
new file mode 100644 (file)
index 0000000..97cc79a
--- /dev/null
@@ -0,0 +1,45 @@
+{include file='admin/billing/header.html'}
+
+{include file='admin/billing/subHeader.html'}
+
+{if $invoiceUpdated}<span class="glm-notice glm-flash-updated">Notification Updated</span>{/if}
+{if $invoiceUpdateError}<span class="glm-notice glm-flash-updated">Notification Update Error</span>{/if}
+{if $invoiceInsertError}<span class="glm-notice glm-flash-updated">Notification Insert Error</span>{/if}
+{if $invoiceAdded}<span class="glm-notice glm-flash-updated">Notification Added</span>{/if}
+
+<form action="{$thisUrl}?page={$thisPage}&glm_action=invoices" method="post">
+    {if $invoice_id}
+        <input type="hidden" name="option" value="update">
+        <input type="hidden" name="id" value="{$invoice_id}">
+    {else}
+        <input type="hidden" name="option" value="insert">
+    {/if}
+    <div class="glm-row">
+        <div class="glm-columns glm-small-6">
+            <div class="glm-row">
+                <div class="glm-columns glm-small-12"> Line One </div>
+            </div>
+
+
+            <div class="glm-row">
+                <div class="glm-columns glm-small-9"> Total Amount: </div>
+                <div class="glm-columns glm-small-3"> $0.00 </div>
+            </div>
+
+            <input class="button button-primary" type="submit" value="{if $invoice_id}Update{else}Add{/if} Invoice">
+        </div>
+    </div>
+
+</form>
+
+<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 1e4acda..a2b5e4b 100644 (file)
@@ -1,8 +1,8 @@
 <div class="wrap">
     <h2>Billing</h2>
     <h2 class="nav-tab-wrapper">
-        <a href="{$thisUrl}?page=glm-members-admin-mune-billing&glm_action=index" 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==list} nav-tab-active{/if}">Invoices</a>
+        <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>
     </h2>
     <div id="glm-admin-content-container">
 
diff --git a/views/admin/billing/invoices.html b/views/admin/billing/invoices.html
new file mode 100644 (file)
index 0000000..24ae3cb
--- /dev/null
@@ -0,0 +1,57 @@
+{include file='admin/billing/header.html'}
+
+{include file='admin/billing/subHeader.html'}
+
+
+<h2>Invoices</h2>
+
+<table class="wp-list-table widefat fixed posts glm-admin-table">
+    <thead>
+        <tr>
+            <th>ID</th>
+            <th>InvoiceType</th>
+            <th>Amount</th>
+            <th>Recurring</th>
+            <th>Recurrence</th>
+            <th>&nbsp;</th>
+        </tr>
+    </thead>
+    <tbody>
+        {if $haveInvoices}
+            {assign var="i" value="0"}
+            {foreach $invoiceTypes as $t}
+                {if $i++ is odd by 1}
+                    <tr>
+                {else}
+                    <tr class="alternate">
+                {/if}
+                    <td>{$t.id}</td>
+                    <td>
+                        <div{if $t.parent.value} class="glm-indent"{/if}>
+                            <a class="editInvoiceType"
+                                data-invoice-id="{$t.id}"
+                            >{$t.name}</a>
+                        </div>
+                    </td>
+                    <td>{$t.amount}</td>
+                    <td>{if $t.recurring.value}Yes{else}No{/if}</td>
+                    <td>{if $t.recurrence}{$recurrenceTypes[$t.recurrence]}{/if}</td>
+                    <td>
+                        <div class="deleteInvoiceTypeButton button button-secondary glm-button-small glm-right"
+                            data-invoiceTypeID="{$t.id}">Delete</div>
+                    </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'}
diff --git a/views/admin/billing/subHeader.html b/views/admin/billing/subHeader.html
new file mode 100644 (file)
index 0000000..9aa65cb
--- /dev/null
@@ -0,0 +1,4 @@
+<h2 class="nav-tab-wrapper" style="margin-bottom: 1em;">
+    <a href="{$thisUrl}?page=glm-members-admin-menu-billing&glm_action=invoices" class="nav-tab{if $thisAction==invoices} nav-tab-active{/if}">Search Invoices</a>
+    <a href="{$thisUrl}?page=glm-members-admin-menu-billing&glm_action=invoices&option=add" class="nav-tab">Create Invoice</a>
+</h2>