Fix Create Invoice page
authorSteve Sutton <steve@gaslightmedia.com>
Thu, 14 Mar 2019 12:37:24 +0000 (08:37 -0400)
committerSteve Sutton <steve@gaslightmedia.com>
Thu, 14 Mar 2019 12:37:24 +0000 (08:37 -0400)
Worked on fixing the add new account part of the page.

models/admin/ajax/billingAccount.php
models/admin/billing/invoices.php
views/admin/billing/editInvoice.html

index 306d570..d620844 100644 (file)
@@ -83,7 +83,7 @@ class GlmMembersAdmin_ajax_billingAccount extends GlmDataAccounts
         switch ( $option ) {
         case 'add':
             $account = $this->insertEntry();
-            trigger_error( print_r( $account, E_USER_NOTICE ) );
+            trigger_error( print_r( $account['fieldFail'], E_USER_NOTICE ) );
             if ( !$account['status'] ) {
                 $accountInsertError = true;
                 $return = $account;
index f2a2ff4..cda9c6f 100644 (file)
@@ -225,6 +225,7 @@ class GlmMembersAdmin_billing_invoices extends GlmDataInvoices
                   WHERE id NOT IN (
                         SELECT distinct ref_dest
                           FROM " . GLM_MEMBERS_BILLING_PLUGIN_DB_PREFIX .  "accounts   )
+                   AND access != 90
                 ORDER BY name",
                 ARRAY_A
             );
index fba1b41..2454340 100644 (file)
                     <input type="text" name="email" value="">
                 </td>
             </tr>
-            <tr>
-                <th class="glm-required" align="right">Billing First Name</th>
-                <td>
-                    <input type="text" name="billing_fname" value="">
-                </td>
-            </tr>
-            <tr>
-                <th class="glm-required" align="right">Billing Last Name</th>
-                <td>
-                    <input type="text" name="billing_lname" value="">
-                </td>
-            </tr>
+            {if $settings.billing_contact_name_enabled}
+                <tr>
+                    <th class="glm-required" align="right">Billing Contact Name</th>
+                    <td>
+                        <input type="text" name="billing_contact_name" value="">
+                    </td>
+                </tr>
+            {else}
+                <tr>
+                    <th class="glm-required" align="right">Billing First Name</th>
+                    <td>
+                        <input type="text" name="billing_fname" value="">
+                    </td>
+                </tr>
+                <tr>
+                    <th class="glm-required" align="right">Billing Last Name</th>
+                    <td>
+                        <input type="text" name="billing_lname" value="">
+                    </td>
+                </tr>
+            {/if}
             <tr>
                 <th class="glm-required" align="right">Billing Address 1</th>
                 <td>
                     <input type="text" name="billing_city" value="">
                 </td>
             </tr>
+            {if $settings.billing_county_enabled}
+                <tr>
+                    <th class="glm-required" align="right">Billing State</th>
+                    <td>
+                        <select name="billing_county">
+                            <option value=""></option>
+                            {foreach $billingAccount.fieldData.billing_county.list as $s}
+                                <option value="{$s.value}">
+                                    {$s.name}
+                                </option>
+                            {/foreach}
+                        </select>
+                    </td>
+                </tr>
+            {else}
+                <input type="hidden" name="billing_county" value="{$account.fieldData.billing_county.value}">
+            {/if}
             <tr>
                 <th class="glm-required" align="right">Billing State</th>
                 <td>
@@ -292,11 +318,16 @@ jQuery(document).ready(function($){
         anniversary_date  = $( 'input[name="anniversary_date"' ),
         renewal_date      = $( 'input[name="renewal_date"' ),
         email             = $( 'input[name="email"' ),
-        billing_fname     = $( 'input[name="billing_fname"' ),
-        billing_lname     = $( 'input[name="billing_lname"' ),
+        {if $settings.billing_contact_name_enabled}
+            billing_contact_name     = $( 'input[name="billing_contact_name"' ),
+        {else}
+            billing_fname     = $( 'input[name="billing_fname"' ),
+            billing_lname     = $( 'input[name="billing_lname"' ),
+        {/if}
         billing_addr1     = $( 'input[name="billing_addr1"' ),
         billing_addr2     = $( 'input[name="billing_addr2"' ),
         billing_city      = $( 'input[name="billing_city"' ),
+        {if $settings.billing_county_enabled} billing_county = $( 'select[name="billing_county"' ), {else} billing_county = $( 'input[name="billing_county"' ), {/if}
         billing_state     = $( 'select[name="billing_state"' ),
         billing_zip       = $( 'input[name="billing_zip"' ),
         billing_phone     = $( 'input[name="billing_phone"' ),
@@ -308,7 +339,8 @@ jQuery(document).ready(function($){
         customTips        = $( '.validateCustomTips' ),
         allAccountFields  = $( [] ).add( ref_name ) .add( anniversary_date ) .add( renewal_date )
             .add( email ) .add( billing_addr1 ) .add( billing_addr2 ) .add( billing_city )
-            .add( billing_state ) .add( billing_zip ) .add( billing_fname ) .add( billing_lname )
+            .add( billing_state ) .add( billing_zip ) .add(billing_county)
+            {if $settings.billing_contact_name_enabled}.add( billing_contact_name ){else}.add( billing_fname ).add( billing_lname ){/if}
             .add( billing_phone ) ,        // Array holding the form fields - add line_item form
         allCustomFields   = $([]).add( customFieldName ).add( customFieldAmount ).add( customFieldParent ),
         invoiceTypeJSON   = $.parseJSON( '{$invoiceTypeJSON}' ); // Json object with all of the invoices types
@@ -479,7 +511,7 @@ jQuery(document).ready(function($){
                 dataType: 'json'
             }).done(function( msg ){
                 if ( msg.status === true ) {
-                    // console.log( 'account: ', msg.account );
+                    console.log( 'account: ', msg.account );
                     // TODO: check these function as they don't seem to work!
                     // Reload the account select
                     updateBillingAccountList( msg.account );
@@ -574,7 +606,7 @@ jQuery(document).ready(function($){
                 { source: availableAccountMembers }
             );
             // Here we change the value of the Billing Account field.
-            $('#glm_member_accounts').val( selectedAccount.ref_dest.name );
+            $('#glm_member_accounts').val( selectedAccount.ref_name );
             $('#glm_member_accounts_hidden').val( selectedAccount.id );
             $('#invoice_due_date').val( selectedAccount.next_anniversary_date );
         });