Add account name search to account list page.
authorSteve Sutton <steve@gaslightmedia.com>
Fri, 16 Mar 2018 20:55:15 +0000 (16:55 -0400)
committerSteve Sutton <steve@gaslightmedia.com>
Fri, 16 Mar 2018 20:55:15 +0000 (16:55 -0400)
Can search by account name.

models/admin/billing/accounts.php
views/admin/billing/accounts.html

index 3cd9350..54a4f4d 100644 (file)
@@ -122,6 +122,8 @@ class GlmMembersAdmin_billing_accounts extends GlmDataAccounts
         $annFromDate         = '';
         $annToDate           = '';
         $totalAccounts       = false;
+        $allAccounts         = false;
+        $filterAccounts      = false;
 
         // Get any provided option
         if (isset($_REQUEST['option'])) {
@@ -287,6 +289,8 @@ class GlmMembersAdmin_billing_accounts extends GlmDataAccounts
         case 'list':
         default:
 
+            $allAccounts = $this->getSimpleAccountList();
+
             $where_params = array( 'true' );
 
             // Check for paging
@@ -366,6 +370,13 @@ class GlmMembersAdmin_billing_accounts extends GlmDataAccounts
                 $annTo_date = date( 'Y-m-d', strtotime( $annToDate ) );
                 $where_params[] = "T.anniversary_date <= '$annTo_date'";
             }
+            if ( isset( $_REQUEST['filterAccounts'] )
+                && $filterAccounts = filter_var( $_REQUEST['filterAccounts'], FILTER_VALIDATE_INT )
+            ) {
+                $accounts[$filterAccounts]['selected'] = true;
+                $where_params[] = "T.id = $filterAccounts";
+            }
+
 
             // Build the $where string from the $where_parts array.
             // By implode with AND.
@@ -435,6 +446,8 @@ class GlmMembersAdmin_billing_accounts extends GlmDataAccounts
             'annFromDate'         => $annFromDate,
             'annToDate'           => $annToDate,
             'totalAccounts'       => $totalAccounts,
+            'allAccounts'         => $allAccounts,
+            'filterAccounts'      => $filterAccounts,
         );
 
         // Return status, any suggested view, and any data to controller
index d2c727b..e8f9467 100644 (file)
                 <b>To Date: </b><input type="text" name="annToDate" value="{$annToDate}" class="glm-form-text-input-short glm-date-input">
             </span>
             <br>
+            <span class="glm-nowrap">
+                <b>Member Account:&nbsp;</b>
+                <input id="member-account" type="hidden" name="filterAccounts" value="{$filterAccounts}">
+                <input id="account_name" name="searchName" value="" />
+            </span>
+            <br>
             <span class="glm-nowrap">
                 <input type="submit" value="Submit">
             </span>
             dateFormat: 'mm/dd/yy'
         });
 
+        var availableAccounts = [
+        {foreach $allAccounts as $m}
+            { label: "{$m.ref_name|unescape:'html'|replace:'"':''}", value: "{$m.ref_name|unescape:'html'|replace:'"':''}", id: '{$m.id}' },
+        {/foreach}
+        ]
+
+        $('#account_name').autocomplete({
+            source: availableAccounts,
+            select: function( event, ui ){
+                $('#member-account').val( ui.item.id );
+            },
+        });
+
+        {if $filterAccounts}
+            {$selected = 0}
+            {foreach $accounts as $m}
+                {if $m.id == $filterAccounts}
+                    {$selected = $m.ref_name|unescape:'html'|replace:'"':''}
+                {/if}
+            {/foreach}
+            $('#account_name').autocomplete().val('{$selected}');
+        {/if}
+
     });
 </script>