Updating search forms for billing
authorSteve Sutton <steve@gaslightmedia.com>
Thu, 1 Aug 2019 16:55:01 +0000 (12:55 -0400)
committerSteve Sutton <steve@gaslightmedia.com>
Thu, 1 Aug 2019 16:55:01 +0000 (12:55 -0400)
Setting up type date for date searches.

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

index 97d2808..935af71 100644 (file)
@@ -302,23 +302,6 @@ class GlmMembersAdmin_billing_accounts extends GlmDataAccounts
             $where_params = array( 'true' );
             $sub_where_parts = array();
 
-            // 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
@@ -335,23 +318,10 @@ class GlmMembersAdmin_billing_accounts extends GlmDataAccounts
                 }
             }
 
-            // 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 any search parameters.
             $reg_options = array(
                 'options' => array(
-                    'regexp' => '%[0-9]{2}/[0-9]{2}/[0-9]{4}%'
+                    'regexp' => '%[0-9]{4}-[0-9]{2}-[0-9]{2}%'
                 )
             );
             // When searching
@@ -425,6 +395,7 @@ class GlmMembersAdmin_billing_accounts extends GlmDataAccounts
             // By implode with AND.
             $where = implode( ' AND ', $where_params );
 
+            // echo '<pre>$_REQUEST: ' . print_r( $_REQUEST, true ) . '</pre>';
             // echo '<pre>$where: ' . print_r( $where, true ) . '</pre>';
 
             // Get the list of accounts and determine number of accounts in list
index 0b150ed..124d7e9 100644 (file)
@@ -626,7 +626,7 @@ class GlmMembersAdmin_billing_invoices extends GlmDataInvoices
             // Get any search parameters.
             $reg_options = array(
                 'options' => array(
-                    'regexp' => '%[0-9]{2}/[0-9]{2}/[0-9]{4}%'
+                    'regexp' => '%[0-9]{4}-[0-9]{2}-[0-9]{2}%'
                 )
             );
             if ( isset( $_REQUEST['fromDate'] )
index f86f894..16ce7e7 100644 (file)
@@ -2,9 +2,9 @@
 jQuery(document).ready(function($) {
 
     // Date Input
-    $('.glm-date-input').datepicker({
-        dateFormat: 'mm/dd/yy'
-    });
+    //$('.glm-date-input').datepicker({
+    //    dateFormat: 'mm/dd/yy'
+    //});
 
     // Setup for the modal box
     $('#exportAccountDialog').dialog( {
@@ -36,7 +36,7 @@ jQuery(document).ready(function($) {
     ]
 
     // Setup autocomplete for both inputs
-    $('#account_name').autocomplete({
+    $('#searchName').autocomplete({
         source: availableAccounts,
         select: function( event, ui ){
             $('#member-account').val( ui.item.id );
@@ -68,7 +68,7 @@ jQuery(document).ready(function($) {
                 {$selected = $m.ref_name|unescape:'html'|replace:'"':''}
             {/if}
         {/foreach}
-        $('#account_name').autocomplete().val('{$selected}');
+        $('#searchName').autocomplete().val('{$selected}');
     {/if}
 
 });
@@ -95,34 +95,100 @@ jQuery(document).ready(function($) {
         <div class="grid-x grid-margin-x">
 
             <div class="cell small-12 medium-3">
-                <label>Member Account:</label>
-                <input id="member-account" type="hidden" name="filterAccounts" value="{$filterAccounts}" />
-                <input id="account_name" type="text" name="searchName" value="{if $searchName}{$searchName}{/if}" />
+                <div class="grid-x grid-margin-x">
+
+                    {* Used for autocomplete *}
+                    <input id="member-account" type="hidden" name="filterAccounts" value="{$filterAccounts|default:''}" />
+
+                    {* Member Account *}
+                    {$ui = [
+                        'value'       => $searchName|default:'',
+                        'field'       => 'searchName',
+                        'label'       => 'Member Account',
+                        'required'    => false,
+                        'errorText'   => 'Member Account is Required',
+                        'dataError'   => ''
+                    ]}
+                    {include file='ui/f6/text.html'}
+
+                </div>
             </div>
 
             <div class="cell small-12 medium-3">
-                <label>From Date: </label>
-                <input type="text" name="fromDate" value="{$fromDate}" class="glm-date-input" />
+                <div class="grid-x grid-margin-x">
+                    {* From Date *}
+                    {$ui = [
+                        'value'       => $fromDate|default:'',
+                        'field'       => 'fromDate',
+                        'label'       => 'From Date',
+                        'required'    => false,
+                        'errorText'   => 'From Date is Required',
+                        'dataError'   => ''
+                    ]}
+                    {include file='ui/f6/date.html'}
+                </div>
             </div>
 
             <div class="cell small-12 medium-3">
-                <label>To Date: </label>
-                <input type="text" name="toDate" value="{$toDate}" class="glm-date-input" />
+                <div class="grid-x grid-margin-x">
+                    {* To Date *}
+                    {$ui = [
+                        'value'       => $toDate|default:'',
+                        'field'       => 'toDate',
+                        'label'       => 'To Date',
+                        'required'    => false,
+                        'errorText'   => 'To Date is Required',
+                        'dataError'   => ''
+                    ]}
+                    {include file='ui/f6/date.html'}
+                </div>
             </div>
 
             <div class="cell small-12 medium-3">
-                <label>
-                    <input id="filterActive" name="filterActive" value="1" {if $filterActive}checked{/if} type="checkbox" /> Show Active
-                </label>
-                <label>
-                    <input id="filterPending" name="filterPending" value="1" {if $filterPending}checked{/if} type="checkbox" /> Show Pending
-                </label>
-                <label>
-                    <input id="filterOverdue" name="filterOverdue" value="1" {if $filterOverdue}checked{/if} type="checkbox" /> Show Overdue
-                </label>
-                <label>
-                    <input id="filterExpired" name="filterExpired" value="1" {if $filterExpired}checked{/if} type="checkbox" /> Show Expired
-                </label>
+                {* Show Active *}
+                {$ui = [
+                    'value'     => $filterActive|default:'',
+                    'field'     => 'filterActive',
+                    'label'     => 'Show Active',
+                    'required'  => false,
+                    'errorText' => 'Show Active is Required',
+                    'dataError' => ''
+                ]}
+                {include file='ui/f6/checkbox.html'}
+
+                {* Show Pending *}
+                {$ui = [
+                    'value'     => $filterPending|default:'',
+                    'field'     => 'filterPending',
+                    'label'     => 'Show Pending',
+                    'required'  => false,
+                    'errorText' => 'Show Pending is Required',
+                    'dataError' => ''
+                ]}
+                {include file='ui/f6/checkbox.html'}
+
+                {* Show Overdue *}
+                {$ui = [
+                    'value'     => $filterOverdue|default:'',
+                    'field'     => 'filterOverdue',
+                    'label'     => 'Show Overdue',
+                    'required'  => false,
+                    'errorText' => 'Show Overdue is Required',
+                    'dataError' => ''
+                ]}
+                {include file='ui/f6/checkbox.html'}
+
+                {* Show Expired *}
+                {$ui = [
+                    'value'     => $filterExpired|default:'',
+                    'field'     => 'filterExpired',
+                    'label'     => 'Show Expired',
+                    'required'  => false,
+                    'errorText' => 'Show Expired is Required',
+                    'dataError' => ''
+                ]}
+                {include file='ui/f6/checkbox.html'}
+
             </div>
         </div>
         <div class="billing-search-form-submit">
index 5a20fe5..1ee10ab 100644 (file)
     <div class="grid-container full">
         <div class="grid-x grid-padding-x">
             <div class="cell small-12 medium-4">
-                <label>From Date: </label>
-                <input type="text" name="fromDate" value="{$fromDate}" class="glm-form-text-input-short glm-date-input">
-                <label>To Date: </label>
-                <input type="text" name="toDate" value="{$toDate}" class="glm-form-text-input-short glm-date-input">
+                <div class="grid-x grid-padding-x">
+                    {* From Date *}
+                    {$ui = [
+                        'value'       => $fromDate|default:'',
+                        'field'       => 'fromDate',
+                        'label'       => 'From Date',
+                        'required'    => false,
+                        'errorText'   => 'From Date is Required',
+                        'dataError'   => ''
+                    ]}
+                    {include file='ui/f6/date.html'}
+
+                    {* To Date *}
+                    {$ui = [
+                        'value'       => $toDate|default:'',
+                        'field'       => 'toDate',
+                        'label'       => 'To Date',
+                        'required'    => false,
+                        'errorText'   => 'To Date is Required',
+                        'dataError'   => ''
+                    ]}
+                    {include file='ui/f6/date.html'}
+                </div>
             </div>
             <div class="cell small-12 medium-4">
-                <label>Member Account:&nbsp;</label>
-                <input id="member-account" type="hidden" name="filterAccounts" value="{$filterAccounts}">
-                <input id="account_name" type="text" name="searchName" value="{if !empty($smarty.request.searchName)}{$smarty.request.searchName}{/if}" />
-                <label>Invoice #:&nbsp;</label>
-                <input id="member-invoice-id" type="hidden" name="filterInvoice" value="{$filterInvoices|default:''}">
-                <input id="invoiceId" type="text" name="searchInvoice" value="" />
+                <div class="grid-x grid-margin-x">
+
+                    {* Used for autocomplete *}
+                    <input id="member-account" type="hidden" name="filterAccounts" value="{$filterAccounts|default:''}">
+
+                    {* Member Account *}
+                    {$ui = [
+                        'value'       => $smarty.request.searchName|default:'',
+                        'field'       => 'searchName',
+                        'label'       => 'Member Account',
+                        'required'    => false,
+                        'errorText'   => 'Member Account is Required',
+                        'dataError'   => ''
+                    ]}
+                    {include file='ui/f6/text.html'}
+
+                    {* Used for autocomplete *}
+                    <input id="member-invoice-id" type="hidden" name="filterInvoice" value="{$filterInvoices|default:''}">
+
+                    {* Invoice # *}
+                    {$ui = [
+                        'value'       => $smarty.request.searchInvoice|default:'',
+                        'field'       => 'searchInvoice',
+                        'label'       => 'Invoice #',
+                        'required'    => false,
+                        'errorText'   => 'Invoice # is Required',
+                        'dataError'   => ''
+                    ]}
+                    {include file='ui/f6/text.html'}
+                </div>
             </div>
             <div class="cell small-12 medium-4">
-                <label>
-                    <input type="checkbox" name="filterUnpaid"{if !empty($smarty.request.filterUnpaid) && $smarty.request.filterUnpaid} checked{/if}>
-                    Show only Unpaid Invoices
-                </label>
+                <div class="grid-x grid-margin-x">
+                    {* Show only Unpaid Invoices *}
+                    {$ui = [
+                        'value'     => $smarty.request.filterUnpaid|default:'',
+                        'field'     => 'filterUnpaid',
+                        'label'     => 'Show only Unpaid Invoices',
+                        'required'  => false,
+                        'errorText' => 'Show only Unpaid Invoices is Required',
+                        'dataError' => ''
+                    ]}
+                    {include file='ui/f6/checkbox.html'}
+                </div>
             </div>
             <div class="billing-search-form-submit">
                 <input type="submit" class="button primary" value="Submit">
         });
 
         // Date Input
-        $('.glm-date-input').datepicker({
-            dateFormat: 'mm/dd/yy'
-        });
+        //$('.glm-date-input').datepicker({
+        //    dateFormat: 'mm/dd/yy'
+        //});
 
         var availableAccounts = [
         {foreach $accounts as $m}
         ]
 
         {* accounts for the search *}
-        $('#account_name').autocomplete({
+        $('#searchName').autocomplete({
             source: availableAccounts,
             select: function( event, ui ){
                 $('#member-account').val( ui.item.id );
             { label: "{$m.id} ( {$m.member_name|unescape:'html'|replace:'"':''} )", value: "{$m.id|unescape:'html'|replace:'"':''}", id: '{$m.id}' },
         {/foreach}
         ]
-        $('#invoiceId').autocomplete({
+        $('#searchInvoice').autocomplete({
             source: availableInvoices,
             select: function( event, ui ){
                 $('#member-invoice-id').val( ui.item.id );
-                $('#invoiceId').val( ui.item.id );
+                $('#searchInvoice').val( ui.item.id );
                 $('#searchForm').submit();
             },
             change: function( event, ui) {
                     {$selected = $m.ref_name|unescape:'html'|replace:'"':''}
                 {/if}
             {/foreach}
-            $('#account_name').autocomplete().val('{$selected}');
+            $('#searchName').autocomplete().val('{$selected}');
         {/if}
 
         // Flash certain elements for a short time after display