Update for front end field
authorSteve Sutton <steve@gaslightmedia.com>
Fri, 10 Aug 2018 15:40:11 +0000 (11:40 -0400)
committerSteve Sutton <steve@gaslightmedia.com>
Fri, 10 Aug 2018 15:40:11 +0000 (11:40 -0400)
Needed a way to get billing status to the front end migcsa.

setup/commonHooks.php
views/admin/billing/statements.html

index 95b351b..6dc155d 100644 (file)
  * Check the member account and return the status.
  * (Pending, Expired, Active, Archived)
  */
-add_filter( 'glm-billing-get-account-status', function( $content, $account_id ){
+add_filter( 'glm-billing-get-account-status', function( $content, $account_id, $use_ref_dest = false ){
     global $config;
     if ( isset( $account_id ) && $account_id = filter_var( $account_id, FILTER_VALIDATE_INT ) ) {
+        $field_to_check = $use_ref_dest ? 'ref_dest' : 'id';
         // fetch the account
         $account = $this->wpdb->get_row(
             $this->wpdb->prepare(
                 "SELECT *
                    FROM "  . GLM_MEMBERS_BILLING_PLUGIN_DB_PREFIX . "accounts
-                  WHERE id = %d",
+                  WHERE $field_to_check = %d",
                 $account_id
             ),
             ARRAY_A
@@ -90,7 +91,7 @@ add_filter( 'glm-billing-get-account-status', function( $content, $account_id ){
 
     }
 
-},10, 2 );
+},10, 3 );
 
 add_filter( 'glm-billing-account-has-renewal', function( $content, $account_id ){
     // see if there's already a renewal invoice (not paid)
index 5b6416d..4dc70f5 100644 (file)
@@ -5,7 +5,7 @@
     {include file='admin/billing/header.html'}
 {/if}
 
-    <table class="glm-admin-table wp-list-table widefat">
+    <table class="glm-admin-table wp-list-table striped">
         <thead>
             <tr>
                 <th style="width:50px;">ID</th>
                 {* Invoices *}
                 {if $transaction.type == '10'}
                     <tr{if $alt % 2 == 0} class="alternate"{/if}>
-                        <td>{$transaction.transaction_data.id}</td>
-                        <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>
+                        <td class="glm-shrink">{$transaction.transaction_data.id}</td>
+                        <td class="glm-shrink">{$transaction.transaction_data.transaction_time|date_format:"%D"}</td>
+                        <td class="glm-shrink">{$transaction.transaction_data.due_date|date_format:"%D"}</td>
+                        <td class="glm-shrink">{$transaction_types[$transaction.type]}</td>
+                        <td class="glm-shrink">
                             {foreach $transaction.line_items as $item}
                                 {$item.name} {if $item.recurring && $item.recurrence_string}( {$item.recurrence_string} ){/if}<br>
                             {/foreach}
                         </td>
-                        <td>${$transaction.transaction_data.amount_total}</td>
-                        <td>${$transaction.transaction_data.balance}</td>
-                        <td>{if $transaction.transaction_data.paid}&nbsp;{else}<a href="{$thisUrl}?page={$thisPage}&glm_action=billing&option=makepayment&member={$memberID}">Pay Invoice</a>{/if}</td>
-                        <td> <a href="{$thisUrl}?page={$thisPage}&glm_action=billing&option=view&member={$memberID}&id={$transaction.type_id}">View</a> </td>
+                        <td class="glm-shrink">${$transaction.transaction_data.amount_total}</td>
+                        <td class="glm-shrink">${$transaction.transaction_data.balance}</td>
+                        <td class="glm-shrink">{if $transaction.transaction_data.paid}&nbsp;{else}<a href="{$thisUrl}?page={$thisPage}&glm_action=billing&option=makepayment&member={$memberID}">Pay Invoice</a>{/if}</td>
+                        <td class="glm-shrink"> <a href="{$thisUrl}?page={$thisPage}&glm_action=billing&option=view&member={$memberID}&id={$transaction.type_id}">View</a> </td>
                     </tr>
                 {* Payments *}
                 {elseif $transaction.type == '20'}
                     <tr{if $alt % 2 == 0} class="alternate"{/if}>
-                        <td>{$transaction.transaction_data.id}</td>
-                        <td>{$transaction.transaction_data.transaction_time|date_format:"%D"}</td>
-                        <td>&nbsp;</td>
-                        <td>{$transaction_types[$transaction.type]}</td>
-                        <td>&nbsp;</td>
-                        <td>${$transaction.transaction_data.amount}</td>
-                        <td>&nbsp;</td>
-                        <td>&nbsp;</td>
-                        <td>&nbsp;</td>
+                        <td class="glm-shrink">{$transaction.transaction_data.id}</td>
+                        <td class="glm-shrink">{$transaction.transaction_data.transaction_time|date_format:"%D"}</td>
+                        <td class="glm-shrink">&nbsp;</td>
+                        <td class="glm-shrink">{$transaction_types[$transaction.type]}</td>
+                        <td class="glm-shrink">&nbsp;</td>
+                        <td class="glm-shrink">${$transaction.transaction_data.amount}</td>
+                        <td class="glm-shrink">&nbsp;</td>
+                        <td class="glm-shrink">&nbsp;</td>
+                        <td class="glm-shrink">&nbsp;</td>
                     </tr>
                 {/if}
             {$alt = $alt + 1}