Working on pay invoice part
authorSteve Sutton <steve@gaslightmedia.com>
Fri, 26 Jul 2019 20:04:32 +0000 (16:04 -0400)
committerSteve Sutton <steve@gaslightmedia.com>
Fri, 26 Jul 2019 20:04:32 +0000 (16:04 -0400)
Also updated the invoice type table so it closes open tr when going out
of the table.
Removed billing from setting and management sections.

models/admin/billing/invoices.php
models/admin/member/billing.php
setup/adminTabs.php
views/admin/billing/editPayment.html
views/admin/billing/invoiceTypes.html
views/admin/billing/invoices.html
views/admin/billing/makePaymentAjax.html
views/admin/billing/memberBillingSubHeader.html

index a520add..0b150ed 100644 (file)
@@ -162,6 +162,7 @@ class GlmMembersAdmin_billing_invoices extends GlmDataInvoices
 
         // Special case for option 'send_invoice'
         if ( $option == 'send_invoice' ) {
+            // trigger_error( 'A hit on invoices.php for option send_invoice', E_USER_NOTICE );
             $BillingSupport = new GlmBillingSupport( $this->wpdb, $this->config );
 
             $invoice_id = false;
index e38c064..37ba373 100644 (file)
@@ -200,7 +200,10 @@ class GlmMembersAdmin_member_billing // extends GlmDataBilling
                 $this->memberID
             )
         );
-        $account_status = apply_filters( 'glm-billing-get-account-status', '', $accountID );
+
+        if ( $accountID ) {
+            $account_status = apply_filters( 'glm-billing-get-account-status', '', $accountID );
+        }
 
         switch ( $option ) {
         case 'createInvoice':
@@ -1007,21 +1010,28 @@ class GlmMembersAdmin_member_billing // extends GlmDataBilling
 
         case 'list':
             $view = 'statements';
-            require_once GLM_MEMBERS_BILLING_PLUGIN_CLASS_PATH . '/data/dataAccounts.php';
-            $account = $Accounts->editEntry( $accountID );
-            if ( isset( $_REQUEST['all'] ) && $all = filter_var( $_REQUEST['all'], FILTER_VALIDATE_BOOLEAN ) ) {
-                $allStatements = true;
+            if ( $accountID ) {
+                require_once GLM_MEMBERS_BILLING_PLUGIN_CLASS_PATH . '/data/dataAccounts.php';
+                $account = $Accounts->editEntry( $accountID );
+                if ( isset( $_REQUEST['all'] ) && $all = filter_var( $_REQUEST['all'], FILTER_VALIDATE_BOOLEAN ) ) {
+                    $allStatements = true;
+                }
             }
             break;
-        }
-
-        // Get the list of invoices for this member.
-        $statements = $BillingSupport->getStatementsByRefDest( $this->memberID, $allStatements );
-        if ( $statements ) {
-            $transactions      = $statements['transactions'];
-            $account_data      = $statements['account_data'];
-            $balance_due       = $statements['balance_due'];
-            $hasBillingAccount = true;
+        } // End of Switch $option
+
+        // Get member statements if the member has a billing account.
+        if ( $accountID ) {
+            // Get the list of invoices for this member.
+            $statements = $BillingSupport->getStatementsByRefDest( $this->memberID, $allStatements );
+            if ( $statements ) {
+                $transactions      = $statements['transactions'];
+                $account_data      = $statements['account_data'];
+                $balance_due       = $statements['balance_due'];
+                $hasBillingAccount = true;
+            }
+        } else {
+            $statements = false;
         }
 
         // Compile template data
index a90ccdb..0517ef3 100644 (file)
  */
 if ( current_user_can( 'glm_members_members' ) ) {
 
-    add_filter('glm-member-db-add-tab-for-management',
-        function($addOnTabs) {
-            $newTabs = array(
-                array(
-                    'text'   => 'Billing',
-                    'menu'   => 'management',
-                    'action' => 'billing'
-                )
-            );
-            $addOnTabs = array_merge($addOnTabs, $newTabs);
-            return $addOnTabs;
-        }
-    );
+    // add_filter('glm-member-db-add-tab-for-management',
+    //     function($addOnTabs) {
+    //         $newTabs = array(
+    //             array(
+    //                 'text'   => 'Billing',
+    //                 'menu'   => 'management',
+    //                 'action' => 'billing'
+    //             )
+    //         );
+    //         $addOnTabs = array_merge($addOnTabs, $newTabs);
+    //         return $addOnTabs;
+    //     }
+    // );
 
-    add_filter( 'glm-member-db-add-tab-for-settings',
-        function( $addOnTabs ) {
-            $newTabs = array(
-                array(
-                    'text'   => 'Billing',
-                    'menu'   => 'settings',
-                    'action' => 'billing',
-                )
-            );
-            $addOnTabs = array_merge( $addOnTabs, $newTabs );
-            return $addOnTabs;
-        }
-    );
+    // add_filter( 'glm-member-db-add-tab-for-settings',
+    //     function( $addOnTabs ) {
+    //         $newTabs = array(
+    //             array(
+    //                 'text'   => 'Billing',
+    //                 'menu'   => 'settings',
+    //                 'action' => 'billing',
+    //             )
+    //         );
+    //         $addOnTabs = array_merge( $addOnTabs, $newTabs );
+    //         return $addOnTabs;
+    //     }
+    // );
 
-    add_filter( 'glm-member-db-add-tab-for-billing',
-        function( $addOnTabs ){
-            $newTabs = array(
-                array(
-                    'text'   => 'Invoices',
-                    'menu'   => 'billing',
-                    'action' => 'billing',
-                    'option' => 'list',
-                )
-            );
-        }
-    );
+    // add_filter( 'glm-member-db-add-tab-for-billing',
+    //     function( $addOnTabs ){
+    //         $newTabs = array(
+    //             array(
+    //                 'text'   => 'Invoices',
+    //                 'menu'   => 'billing',
+    //                 'action' => 'billing',
+    //                 'option' => 'list',
+    //             )
+    //         );
+    //     }
+    // );
 
     add_filter(
         'glm-member-db-add-tab-for-member',
index 024ff92..6eb2457 100644 (file)
+{* Payment Form *}
+
+{* Header *}
 {include file='admin/billing/header.html'}
 
-<div class="callout grid-container">
+{* Grid Start *}
+{$ui = [
+    'nowrap'          => false,
+    'backgroundColor' => '',
+    'sectionColor'    => ''
+]}
+{include file='ui/f6/grid-start.html'}
+
+{* Payment Updated *}
+{$ui = [
+    'label'  => 'Payment Updated',
+    'active' => $paymentUpdated,
+    'type'   => 'success'
+]}
+{include file='ui/f6/callout.html'}
+
+{* Payment Update Error *}
+{$ui = [
+    'label'  => 'Payment Update Error',
+    'active' => $paymentUpdateError,
+    'type'   => 'alert'
+]}
+{include file='ui/f6/callout.html'}
+
+{* Payment Added *}
+{$ui = [
+    'label'  => 'Payment Added',
+    'active' => $paymentAdded,
+    'type'   => 'success'
+]}
+{include file='ui/f6/callout.html'}
+
+{* Payment Insert Error *}
+{$ui = [
+    'label'  => 'Payment Insert Error',
+    'active' => $paymentInsertError,
+    'type'   => 'alert'
+]}
+{include file='ui/f6/callout.html'}
+
+<div id="billing-payment-form" class="glm-billing-form">
+    {* Form Start *}
+    {$ui = [
+        'id'               => 'billing-payment-form',
+        'action'           => "{$thisUrl}?page={$thisPage}&glm_action=payments",
+        'method'           => 'post',
+        'file'             => false,
+        'validate'         => true,
+        'validateFocusMsg' => true
+    ]}
+    {include file='ui/f6/form-start.html'}
 
-    {if $paymentUpdated}<span class="glm-notice glm-flash-updated">Payment Updated</span>{/if}
-    {if $paymentUpdateError}<span class="glm-notice glm-flash-updated">Payment Update Error</span>{/if}
-    {if $paymentInsertError}<span class="glm-notice glm-flash-updated">Payment Insert Error</span>{/if}
-    {if $paymentAdded}<span class="glm-notice glm-flash-updated">Payment Added</span>{/if}
+    <fieldset class="fieldset cell small-12">
+        <legend>Payment</legend>
+
+        <div class="grid-x grid-margin-x">
+
+            <input type="hidden" id="total_payment_amount" name="amount" value="0" />
 
-    <div id="billing-payment-form" class="glm-billing-form">
-        <form action="{$thisUrl}?page={$thisPage}&glm_action=payments" method="post">
-            <input type="hidden" id="total_payment_amount" name="amount" />
             {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-billing-field">
-                <div class="glm-billing-label glm-required">
-                    Lookup Member Invoices By Account
-                </div>
-                <div class="glm-billing-input">
-                    <input id="member-account" name="account" type="hidden" name="filterAccounts" />
-                    <input id="account_name" name="member_account" />
-                </div>
-            </div>
-            <div class="glm-billing-field">
-                <div class="glm-billing-label glm-required">
-                    Select Invoices
-                </div>
-                <div class="glm-billing-input" id="glm-payment-invoices">
-                </div>
-            </div>
-            <div class="glm-billing-field">
-                <div class="glm-billing-label glm-required">
-                    Amount
-                </div>
-                <div class="glm-billing-input">
-                    <div id="total_amount">$0.00</div>
+
+            {* Lookup Member Invoices By Account *}
+            <div class="cell small-12 glm-f6-ui-field">
+                <div class="grid-x grid-margin-x">
+                    <div class="cell small-12">
+                        <label class="glm-required">Lookup Member Invoices By Account</label>
+                    </div>
+                    <div class="cell small-12">
+                        <input id="member-account" name="account" type="hidden" name="filterAccounts" />
+                        <input id="account_name" type="text" name="member_account" required />
+                    </div>
+                    <div class="cell small-12">
+                        <span id="account_name_ErrorText" class="form-error glm-f6-ui-field-error-text" data-form-error-for="account_name">Member is Required</span>
+                    </div>
                 </div>
             </div>
-            <div class="glm-billing-field">
-                <div class="glm-billing-label">
-                    Payment Method
-                </div>
-                <div class="glm-billing-input">
-                    <input name="payment_method" />
+
+            {* Select Invoices *}
+            <div class="cell small-12 glm-f6-ui-field">
+                <div class="grid-x grid-margin-x">
+                    <div class="cell small-12">
+                        <label class="glm-required">Select Invoices</label>
+                    </div>
+                    <div class="cell small-12">
+                        <div id="glm-payment-invoices"></div>
+                    </div>
                 </div>
             </div>
-            <div class="glm-billing-field">
-                <div class="glm-billing-label">
-                    Payment Notes
-                </div>
-                <div class="glm-billing-input">
-                    <input name="payment_data" />
+
+            {* Amount *}
+            <div class="cell small-12 glm-f6-ui-field">
+                <div class="grid-x grid-margin-x">
+                    <div class="cell small-12">
+                        <label>Amount</label>
+                    </div>
+                    <div class="cell small-12">
+                        <div id="total_amount">$0.00</div>
+                    </div>
                 </div>
             </div>
 
-            <input class="button button-primary" type="submit" value="{if $payment_id}Save{else}Create{/if} Payment">
-        </form>
-    </div>
-
-    <script>
-    jQuery(document).ready(function($){
-
-        var availableAccounts = [
-        {foreach $accounts as $m}
-            { label: "{$m.ref_name|unescape:'html'|replace:'"':''}", value: "{$m.ref_name|unescape:'html'|replace:'"':''}", id: '{$m.id}' },
-        {/foreach}
-        ]
-
-        function updateInvoiceList( invoices ) {
-            // Clear the invoices
-            $('#glm-payment-invoices').html('');
-            for ( var i = 0; i < invoices.length; i++ ) {
-                var invoice = invoices[i];
-                var rowHtml = '<label>' +
-                '<input type="checkbox" class="glm-invoice-item" name="invoices[' + invoices[i].id + ']" data-amount="' + invoices[i].balance + '" />';
-                rowHtml += '$' + invoices[i].balance;
-                for ( index = 0; index < invoice.line_items.length; ++index ) {
-                    var line_item = invoice.line_items[index];
-                    rowHtml += ' ' + line_item.name;
-                    if ( line_item.recurring ) {
-                       rowHtml += ' ( ' + line_item.recurrence_string + ' )';
-                    }
-                }
-                rowHtml += '</label><br />';
-                $('#glm-payment-invoices').append( rowHtml );
-            }
+            {* Payment Method *}
+            {$ui = [
+                'value'       => '',
+                'field'       => 'payment_method',
+                'label'       => 'Payment Method',
+                'required'    => false,
+                'errorText'   => 'Payment Method is Required',
+                'dataError'   => ''
+            ]}
+            {include file='ui/f6/text.html'}
+
+            {* Payment Notes *}
+            {$ui = [
+                'value'       => '',
+                'field'       => 'payment_data',
+                'label'       => 'Payment Notes',
+                'required'    => false,
+                'errorText'   => 'Payment Notes is Required',
+                'dataError'   => ''
+            ]}
+            {include file='ui/f6/text.html'}
+
+            {* Submit Button *}
+            {$ui = [
+                'class'  => 'primary',
+                'label'  => 'Save',
+                'submit' => true,
+                'id'     => '',
+                'cancel' => false
+            ]}
+            {include file='ui/f6/submit.html'}
+
+        </div>
+    </fieldset>
+
+    {* Form End *}
+    {include file='ui/f6/form-end.html'}
+</div>
+
+{* Grid End *}
+{include file='ui/f6/grid-end.html'}
+
+<script>
+jQuery(document).ready(function($){
+
+    var availableAccounts = [
+    {foreach $accounts as $m}
+        { label: "{$m.ref_name|unescape:'html'|replace:'"':''}", value: "{$m.ref_name|unescape:'html'|replace:'"':''}", id: '{$m.id}' },
+    {/foreach}
+    ]
+
+    $('#billing-payment-form')
+    .on('formvalid.zf.abide', function(ev, frm){
+        var totalAmount = $('#total_payment_amount').val();
+        console.log('Total Amount: ', totalAmount);
+        if ( parseInt( totalAmount ) > 0 ) {
+            return true;
+        } else {
+            ev.preventDefault();
+            return false;
+        }
+    })
+    .on('submit', function(ev){
+        //ev.preventDefault();
+        var totalAmount = $('#total_payment_amount').val();
+        if ( totalAmount && parseInt( totalAmount ) > 0 ) {
+            return true;
+        } else {
+            alert('You must select at least one Invoice');
+            ev.preventDefault();
+            return false;
         }
+        //console.log('Trapping form submit');
+    });
 
-        function getPageTotal(){
-            // Caclulate the total for this page.
-            var page_total = parseFloat( '0.00' );
-            $('.glm-invoice-item').each(function(){
-                var isChecked = $(this).prop('checked');
-                if ( isChecked ) {
-                    page_total = page_total + parseFloat( $(this).data('amount') );
+    function updateInvoiceList( invoices ) {
+        // Clear the invoices
+        $('#glm-payment-invoices').html('');
+        for ( var i = 0; i < invoices.length; i++ ) {
+            var invoice = invoices[i];
+            var rowHtml = '<label>' +
+            '<input type="checkbox" required class="glm-invoice-item" name="invoices[' + invoices[i].id + ']" data-amount="' + invoices[i].balance + '" />';
+            rowHtml += '$' + invoices[i].balance;
+            for ( index = 0; index < invoice.line_items.length; ++index ) {
+                var line_item = invoice.line_items[index];
+                rowHtml += ' ' + line_item.name;
+                if ( line_item.recurring ) {
+                   rowHtml += ' ( ' + line_item.recurrence_string + ' )';
                 }
-            });
-            $('#total_amount').html( '$' + page_total );
-            $('#total_payment_amount').val( page_total );
+            }
+            rowHtml += '</label><br />';
+            $('#glm-payment-invoices').append( rowHtml );
         }
+    }
 
-        $('#glm-payment-invoices').on( 'click', '.glm-invoice-item', function(){
-            getPageTotal();
-        });
-
-        // Setup autocomplete
-        $('#account_name').autocomplete({
-            source: availableAccounts,
-            select: function( event, ui ){
-                $('#member-account').val( ui.item.id );
-                $.ajax({
-                    url: '{$ajaxUrl}',
-                    cache: false,
-                    data: {
-                        action: 'glm_members_admin_ajax',
-                        glm_action: 'invoices',
-                        account: ui.item.id
-                    },
-                    success: function( results ) {
-                        updateInvoiceList( results );
-                    },
-                });
-            },
-            change: function( event, ui) {
-                if( ui.item == null ) {
-                    $('#member-account').val( '' );
-                    $('#glm-payment-invoices').html('');
-                    getPageTotal();
-                }
-            },
+    function getPageTotal(){
+        // Caclulate the total for this page.
+        var page_total = parseFloat( '0.00' );
+        $('.glm-invoice-item').each(function(){
+            var isChecked = $(this).prop('checked');
+            if ( isChecked ) {
+                page_total = page_total + parseFloat( $(this).data('amount') );
+            }
         });
+        $('#total_amount').html( '$' + page_total );
+        $('#total_payment_amount').val( page_total );
+    }
 
-        // 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);
+    $('#glm-payment-invoices').on( 'click', '.glm-invoice-item', function(){
+        getPageTotal();
+    });
 
+    // Setup autocomplete
+    $('#account_name').autocomplete({
+        source: availableAccounts,
+        select: function( event, ui ){
+            $('#member-account').val( ui.item.id );
+            $.ajax({
+                url: '{$ajaxUrl}',
+                cache: false,
+                data: {
+                    action: 'glm_members_admin_ajax',
+                    glm_action: 'invoices',
+                    account: ui.item.id
+                },
+                success: function( results ) {
+                    updateInvoiceList( results );
+                },
+            });
+        },
+        change: function( event, ui) {
+            if( ui.item == null ) {
+                $('#member-account').val( '' );
+                $('#glm-payment-invoices').html('');
+                getPageTotal();
+            }
+        },
     });
-    </script>
 
-</div>
+    // 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>
+
+{* FGooter *}
 {include file='admin/billing/footer.html'}
index c8c2b13..838223a 100644 (file)
@@ -15,7 +15,7 @@
             <p><div id="deleteInvoiceTypeCancel" class="button button-primary">Cancel</div></p>
         </div>
     </div>
-    <table class="stack hover">
+    <table class="stack hover glm-admin-table-inner">
         <thead>
             <tr>
                 <th style="width: 50px;">ID</th>
index 17c8ffd..5a20fe5 100644 (file)
                             {else}
                                 <a class="send-invoice-link" href="#"
                                     id="send-invoice-{$t.id}"
+                                    data-id="{$t.id}"
                                     data-member="{$t.member_id}"
                                     data-account="{$t.account.value}"
                                     data-member_name="{$t.member_name}"
     <form id="invoice-form" action="{$thisUrl}?page={$thisPage}" method="post">
         <input type="hidden" name="glm_action" value="invoices" />
         <input type="hidden" name="option" value="send_invoice" />
-        <input type="hidden" id="invoice_id" name="invoice_id" value="" />
+        <input type="hidden" id="send_invoice_id" name="invoice_id" value="" />
         <input type="hidden" id="member_id" name="member_id" value="" />
         <input type="hidden" id="account_id" name="account_id" value="" />
         Send an invoice to <span id="member_name"></span><br>
             $('#glmLoading').hide();
         };
 
+
+        // Pay Invoice link
+        $('.pay-invoice').on('click', function(e){
+            e.preventDefault();
+            var member        = $(this).data('member');
+            var $modalPayment = $('#glmBillingPayment');
+            $.ajax({
+                url: '{$ajaxUrl}?action=glm_members_admin_ajax&glm_action=ajaxBillingInfo&option=makepayment&member=' + member,
+                cache: false,
+                beforeSend: startAjax,
+                complete: completeAjax,
+            }).done(function(resp){
+                $modalPayment.html(resp).foundation('open').trigger('resizeme.zp.reveal');
+            });
+            return false;
+        });
+
         $('.make-a-payment').on('click', function(e){
             e.preventDefault();
             var member = $(this).data('member');
             var account_id  = $(this).data( 'account' );
             var member_name = $(this).data( 'member_name' );
 
-            $('#invoice_id').val( invoice_id );
+            $('#send_invoice_id').val( invoice_id );
             $('#member_id').val( member_id );
             $('#account_id').val( account_id );
             $('#member_name').html( '<b>' + member_name + '</b>' );
index d14ba6b..f5c6266 100644 (file)
         {/foreach}
     {/if}
 
+    {* Form Start *}
+    {$ui = [
+        'id'               => 'billingPaymentForm',
+        'action'           => "{$ajaxUrl}?action    = glm_members_admin_ajax",
+        'method'           => 'post',
+        'file'             => false,
+        'validate'         => true,
+        'validateFocusMsg' => true
+    ]}
+    {include file='ui/f6/form-start.html'}
 
-    <form id="billingPaymentForm" action="{$ajaxUrl}?action=glm_members_admin_ajax" method="post" data-abide novalidate>
-        {* <form {if $billing_settings.proc_methods == 4} id="nonce-form"{else} id="PaymentForm"{/if} action="{$thisUrl}?page={$thisPage}&glm_action=billing&option=makePayment" method="post"> *}
-        <input type="hidden" name="page" value="{$thisPage}" />
-        <input type="hidden" name="glm_action" value="ajaxBillingInfo" />
-        <input type="hidden" name="option" value="createPayment" />
-        <input type="hidden" name="member" value="{$memberID}" />
-        <input type="hidden" name="account_id" value="{$account.fieldData.id}" />
-        <input type="hidden" name="amount" value="" id="total_amount" />
+    {* <form {if $billing_settings.proc_methods == 4} id="nonce-form"{else} id="PaymentForm"{/if} action="{$thisUrl}?page={$thisPage}&glm_action=billing&option=makePayment" method="post"> *}
+    <input type="hidden" name="page" value="{$thisPage}" />
+    <input type="hidden" name="glm_action" value="ajaxBillingInfo" />
+    <input type="hidden" name="option" value="createPayment" />
+    <input type="hidden" name="member" value="{$memberID}" />
+    <input type="hidden" name="account_id" value="{$account.fieldData.id}" />
+    <input type="hidden" name="amount" value="" id="total_amount" />
 
 
-        {include file='ui/f6/errorCallout.html'}
-            <!-- Call for billing section -->
+    {include file='ui/f6/errorCallout.html'}
+        <!-- Call for billing section -->
 
-        {if $invoices}
-            <h2>Payment Information</h2>
+    {if $invoices}
+        <h2>Payment Information</h2>
 
-            <div class="glm-billing-field">
-                <div class="glm-billing-label glm-required"> Select Invoice </div>
-                <div class="glm-billing-input">
-                    {if $invoices}
-                        {foreach $invoices as $invoice}
-                            <label>
-                                <input type="checkbox" name="invoices[]" data-amount="{$invoice.balance}" value="{$invoice.id}" checked />
-                                {foreach $invoice.line_items as $line_items}
-                                    {$line_items.name}
-                                {/foreach}
-                                ${$invoice.balance} Due {$invoice.due_date.date}
-                            </label>
-                        {/foreach}
-                    {/if}
+        <fieldset class="fieldset cell smal-12">
+            <legend>Invoices</legend>
+
+            {* Select Invoice *}
+            <div class="cell small-12 glm-f6-ui-field">
+                <div class="grid-x grid-margin-x">
+                    <div class="cell small-12">
+                        <label class="glm-required">Select Invoice</label>
+                    </div>
+                    <div class="cell small-12">
+                        {if $invoices}
+                            {foreach $invoices as $invoice}
+                                <label>
+                                    <input type="checkbox" name="invoices[]" data-amount="{$invoice.balance}" value="{$invoice.id}" checked />
+                                    {foreach $invoice.line_items as $line_items}
+                                        {$line_items.name}
+                                    {/foreach}
+                                    ${$invoice.balance} Due {$invoice.due_date.date}
+                                </label>
+                            {/foreach}
+                        {/if}
+                    </div>
                 </div>
             </div>
 
+            {* Amount *}
+            <div class="cell small-12 glm-f6-ui-field">
+                <div class="grid-x grid-margin-x">
+                    <div class="cell small-12">
+                        <label class="glm-required">Amount</label>
+                    </div>
+                    <div class="cell small-12">
+                        <div id="total_amount_display"></div>
+                    </div>
+                </div>
+            </div>
+
+        </fieldset>
+
+        <fieldset class="fieldset cell small-12">
+            <legend>Billing Information</legend>
+
+            {* Set the $data to account data abstract object *}
+            {$data = $account}
+
+            {if $settings.billing_contact_name_enabled}
+                {* Billing Contact Name *}
+                {$ui = [
+                    'value'       => $data.fieldData.billing_contact_name,
+                    'field'       => 'billing_contact_name',
+                    'label'       => 'Billing Contact Name',
+                    'required'    => $data.fieldRequired.billing_contact_name,
+                    'errorText'   => 'Billing Contact Name is Required',
+                    'dataError'   => $data.fieldFail.billing_contact_name
+                ]}
+                {include file='ui/f6/text.html'}
+            {else}
+                {* First Name *}
+                {$ui = [
+                    'value'       => $data.fieldData.billing_fname,
+                    'field'       => 'billing_fname',
+                    'label'       => 'First Name',
+                    'required'    => $data.fieldRequired.billing_fname,
+                    'errorText'   => 'First Name is Required',
+                    'dataError'   => $data.fieldFail.billing_fname
+                ]}
+                {include file='ui/f6/text.html'}
+
+                {* Last Name *}
+                {$ui = [
+                    'value'       => $data.fieldData.billing_lname,
+                    'field'       => 'billing_lname',
+                    'label'       => 'Last Name',
+                    'required'    => $data.fieldRequired.billing_lname,
+                    'errorText'   => 'Last Name is Required',
+                    'dataError'   => $data.fieldFail.billing_lname
+                ]}
+                {include file='ui/f6/text.html'}
+            {/if}
+
+            {* Address *}
+            {$ui = [
+                'value'       => $data.fieldData.billing_addr1,
+                'field'       => 'billing_addr1',
+                'label'       => 'Address',
+                'required'    => $data.fieldRequired.billing_addr1,
+                'errorText'   => 'Address is Required',
+                'dataError'   => $data.fieldFail.billing_addr1
+            ]}
+            {include file='ui/f6/text.html'}
+
+            {* City *}
+            {$ui = [
+                'value'       => $data.fieldData.billing_city,
+                'field'       => 'billing_city',
+                'label'       => 'City',
+                'required'    => $data.fieldRequired.billing_city,
+                'errorText'   => 'City is Required',
+                'dataError'   => $data.fieldFail.billing_city
+            ]}
+            {include file='ui/f6/text.html'}
+
+            {* State / Province *}
+            {$ui = [
+                'value'     => $data.fieldData.billing_state.value,
+                'field'     => 'billing_state',
+                'label'     => 'State / Province',
+                'list'      => $data.fieldData.billing_state.list,
+                'l_label'   => 'name',
+                'l_value'   => 'value',
+                'l_blank'   => true,
+                'required'  => $data.fieldRequired.billing_state,
+                'errorText' => 'State / Province is Required',
+                'dataError' => $data.fieldFail.billing_state
+            ]}
+            {include file='ui/f6/select.html'}
+
+            {* Zip *}
+            {$ui = [
+                'value'       => $data.fieldData.billing_zip,
+                'field'       => 'billing_zip',
+                'label'       => 'Zip',
+                'required'    => $data.fieldRequired.billing_zip,
+                'errorText'   => 'Zip is Required',
+                'dataError'   => $data.fieldFail.billing_zip
+            ]}
+            {include file='ui/f6/text.html'}
+
+            {* Email Address *}
+            {$ui = [
+                'value'       => $data.fieldData.email,
+                'field'       => 'billing_email',
+                'label'       => 'Email Address',
+                'required'    => $data.fieldRequired.email,
+                'errorText'   => 'Billing Email is Required',
+                'dataError'   => $data.fieldFail.email
+            ]}
+            {include file='ui/f6/text.html'}
+
+        </fieldset>
+
+        <fieldset class="fieldset cell small-12">
+            <legend>Payment Information</legend>
+
+            {* TODO: Check $billing_settings.payment_methods *}
+            {if !$lockedToMember}
             <div class="glm-billing-field">
-                <div class="glm-billing-label glm-required"> Amount </div>
+                <div class="glm-billing-label">
+                    Select Payment Option
+                </div>
                 <div class="glm-billing-input">
-                    <div id="total_amount_display"></div>
+                    {if in_array( 'Credit Card', $management.payment_methods.names)}
+                    <label> <input class="payment_option" type="radio" name="payment_option" value="pay_by_credit_card" checked> Pay by Credit Card </label>
+                    {/if}
+                    {if in_array( 'Check', $management.payment_methods.names)}
+                    <label> <input class="payment_option" type="radio" name="payment_option" value="pay_by_check"> Pay by Check </label>
+                    {/if}
+                    {if in_array( 'Mark Paid', $management.payment_methods.names)}
+                    <label> <input class="payment_option" type="radio" name="payment_option" value="mark_paid"> Mark Paid </label>
+                    {/if}
                 </div>
             </div>
+            {/if}
+
+            {if isset( $account.fieldData.payment_profile_card ) && $account.fieldData.payment_profile_card}
+                <div class="glm-billing-field glm-billing-credit">
+                    <div class="glm-billing-input">
+                        <label>
+                            <input id="glm-billing-use-saved-card" type="checkbox" name="use_saved_cc_profile">
+                            <strong>Use the saved credit card ending in {$account.fieldData.payment_profile_card}</strong>
+                        </label>
+                    </div>
+                </div>
+            {/if}
 
-            {* Include the Payment Form template *}
-            {* Only if payments types are setup *}
-            {include file='common/billing/paymentForm.html'}
+            {* Name on Card *}
+            {$ui = [
+                'value'       => $smarty.request.cc_name|default:'',
+                'field'       => 'cc_name',
+                'label'       => 'Name on Card',
+                'required'    => true,
+                'errorText'   => 'Name on Card is Required',
+                'dataError'   => ''
+            ]}
+            {include file='ui/f6/text.html'}
 
-            <button class="button button-primary" type="submit" {if $billing_settings.proc_methods == 4} onclick="onGetCardNonce(event)"{/if}>Make Payment</button>
+            {* Card Type *}
+            {$ui = [
+                'value'     => $smarty.request.cc_type|default:'',
+                'field'     => 'cc_type',
+                'label'     => 'Card Type',
+                'list'      => $management.cc_accepts.names,
+                'l_blank'   => true,
+                'required'  => true,
+                'errorText' => 'Card Type is Required',
+                'dataError' => ''
+            ]}
+            {include file='ui/f6/select.html'}
 
-            <button class="button glm-right" data-close aria-label="Cancel" type="button">
-                <span>Cancel</span>
-            </button>
+        </fieldset>
 
+        {* Include the Payment Form template *}
+        {* Only if payments types are setup *}
+        {* include file='common/billing/paymentForm.html' *}
 
-            {include file='ui/f6/errorCallout.html'}
+        <button class="button button-primary" type="submit" {if $billing_settings.proc_methods == 4} onclick="onGetCardNonce(event)"{/if}>Make Payment</button>
 
-        {else}
-            You don't have any unpaid invoices!
-        {/if}
+        <button class="button glm-right" data-close aria-label="Cancel" type="button">
+            <span>Cancel</span>
+        </button>
+
+
+        {include file='ui/f6/errorCallout.html'}
+
+    {else}
+        You don't have any unpaid invoices!
+    {/if}
 
-    </form>
+    {* Form End *}
+    {include file='ui/f6/form-end.html'}
 </div>
 
 <script>
index d06f1e7..fbce332 100644 (file)
             <li>
                 <a href="{$thisUrl}?page=glm-members-admin-menu-member&glm_action=billing&member={$memberID}&option=account" class="">Billing Info</a>
             </li>
-            <li>
-                <a href="{$thisUrl}?page=glm-members-admin-menu-member&glm_action=billing&member={$memberID}&all=1" class="">All Statements</a>
-            </li>
-            {if ($account_status == 'Pending' || $account_status == 'Expired') && !apply_filters('glm-billing-account-has-renewal', true, $accountID )}
-                <li>
-                    <a href="{$thisUrl}?page=glm-members-admin-menu-member&glm_action=billing&member={$memberID}&option=renew" class="">Membership Renewal</a>
-                </li>
-            {/if}
-            {if isset( $billing_settings.uptravel_payment_form ) && $billing_settings.uptravel_payment_form && $accountID}
-                {$hasInvoice = apply_filters('glm-billing-account-has-invoice', false, $accountID )}
+            {if !empty($accountID)}
                 <li>
-                    {if $hasInvoice}
-                        <a href="{$thisUrl}?page=glm-members-admin-menu-member&glm_action=billing&member={$memberID}&option=makepaymentadjustment">Make A Payment</a>
-                    {else}
-                        <a href="{$thisUrl}?page=glm-members-admin-menu-member&glm_action=billing&member={$memberID}&option=createInvoice">Create Invoice</a>
-                    {/if}
-                </li>
-            {else}
-                <li>
-                    <a href="{$thisUrl}?page=glm-members-admin-menu-member&glm_action=billing&member={$memberID}&option=makepayment" class="">Pay Invoices</a>
+                    <a href="{$thisUrl}?page=glm-members-admin-menu-member&glm_action=billing&member={$memberID}&all=1" class="">All Statements</a>
                 </li>
+                {if ($account_status == 'Pending' || $account_status == 'Expired') && !apply_filters('glm-billing-account-has-renewal', true, $accountID )}
+                    <li>
+                        <a href="{$thisUrl}?page=glm-members-admin-menu-member&glm_action=billing&member={$memberID}&option=renew" class="">Membership Renewal</a>
+                    </li>
+                {/if}
+                {if isset( $billing_settings.uptravel_payment_form ) && $billing_settings.uptravel_payment_form && $accountID}
+                    {$hasInvoice = apply_filters('glm-billing-account-has-invoice', false, $accountID )}
+                    <li>
+                        {if $hasInvoice}
+                            <a href="{$thisUrl}?page=glm-members-admin-menu-member&glm_action=billing&member={$memberID}&option=makepaymentadjustment">Make A Payment</a>
+                        {else}
+                            <a href="{$thisUrl}?page=glm-members-admin-menu-member&glm_action=billing&member={$memberID}&option=createInvoice">Create Invoice</a>
+                        {/if}
+                    </li>
+                {else}
+                    <li>
+                        <a href="{$thisUrl}?page=glm-members-admin-menu-member&glm_action=billing&member={$memberID}&option=makepayment" class="">Pay Invoices</a>
+                    </li>
+                {/if}
             {/if}
-            {* Testing Email Notifications
-            <li>
-                <a href="{$thisUrl}?page=glm-members-admin-menu-member&glm_action=billing&member={$memberID}&option=testNotice" class="">Test Notices</a>
-            </li>
-            *}
         </ul>
     </div>
 </div>