Adding Billing tab and setup name for custom fields from option.
authorSteve Sutton <steve@gaslightmedia.com>
Fri, 27 Jul 2018 19:10:23 +0000 (15:10 -0400)
committerSteve Sutton <steve@gaslightmedia.com>
Fri, 27 Jul 2018 19:10:23 +0000 (15:10 -0400)
Name of custom fields is from wp option.
Setting up the billing section.

models/admin/contacts/index.php
views/admin/contacts/edit.html

index 0b15688..fa127b7 100644 (file)
@@ -140,6 +140,7 @@ class GlmMembersAdmin_contacts_index extends GlmDataContacts
         $customFieldResults       = false;
         $member_types             = false;
         $contactUpdateError       = false;
+        $billingFieldResults      = false;
 
         $where = '';
 
@@ -453,7 +454,9 @@ class GlmMembersAdmin_contacts_index extends GlmDataContacts
 
                 if ($contactInfo['status']) {
                     $contactInfo = $this->editEntry(($_REQUEST['id']-0));
+                    // Apply Filter to save the custom field data
                     $customFieldResults = apply_filters( 'glm-member-db-save-custom-fields', $_REQUEST['id']-0 );
+                    // Deal with Custom field errors
                     if(is_array($customFieldResults)){
                         $contactUpdated = false;
                         $contactUpdateError = true;
@@ -461,6 +464,10 @@ class GlmMembersAdmin_contacts_index extends GlmDataContacts
                         $contactUpdated = true;
                         $contactUpdateError = false;
                     }
+                    // Apply Filter to save billing data
+                    if ( $this->memberID ) {
+                        $billingFieldResults = apply_filters( 'glm-members-billing-contact-save-data', $this->memberID );
+                    }
 
                     // Get the wordpress user ID
                     $wpUser = get_user_by('email', $contactInfo['fieldData']['email']);
@@ -786,6 +793,7 @@ class GlmMembersAdmin_contacts_index extends GlmDataContacts
             'member_types'             => $member_types,
             'contactUpdateError'       => $contactUpdateError,
             'errorMessage'             => false,
+            'billingFieldResults'      => $billingFieldResults,
         );
 
         // Return status, any suggested view, and any data to controller
index 5d9fae1..f97a4df 100644 (file)
         <div id="glm-contact-account-profile-toggle" class="glm-contact-content-toggle selected">Account Profile</div>
         <div id="glm-contact-account-profile-container" class="glm-admin-form-section glm-contact-content-data">
             <div id="glm-contact-account-profile"></div>
-                
+
                 <table class="glm-admin-table glm-admin-table-inner">
         <!--            <table class="glm-admin-table glm-shrink">-->
                     <tr>
                             <th>
                                 Contact For
                             </th>
-                            
+
                             <td>
                                 {$memberData.name}
                 {else}
                             <input type="file" name="image_new">
                             {if $contactInfo.fieldFail.image}<p>{$contactInfo.fieldFail.image}</p>{/if}
                         </td>
-                    </tr>                        
+                    </tr>
                     <tr>
                         <th>Management/Access to</th>
                         <td id="accessToMemberSelection" class="glm-item-container">
                 </div>
             </div>
             <div id="glm-contact-company-info-toggle" class="glm-contact-content-toggle">
-                <h3>Organization/Company Information</h3>                
+                <h3>Organization/Company Information</h3>
             </div>
             <div id="glm-contact-company-info-container" class="glm-admin-form-section glm-contact-content-data">
                 <div id="glm-contact-company-info">
                 </div>
             </div>
 
+            {if apply_filters( 'glm-members-billing-enabled', false )}
+                <div id="glm-contact-billing-fields-toggle" class="glm-contact-content-toggle">
+                    <h3>Billing Info</h3>
+                </div>
+                <div id="glm-contact-billing-fields-container" class="glm-admin-form-section glm-contact-content-data">
+                    {apply_filters( 'glm-members-billing-contact-form', '', $contactInfo.fieldData.ref_dest )}
+                </div>
+            {/if}
+
             <div id="glm-contact-custom-fields-toggle" class="glm-contact-content-toggle">
-                <h3>Custom Fields</h3>
+                <h3>{apply_filters( 'glm-members-billing-contact-tab-name', '' )}</h3>
             </div>
             <div id="glm-contact-custom-fields-container" class="glm-admin-form-section glm-contact-content-data">
                 <div id="glm-table-custom-fields" class="glm-admin-table glm-table glm-contact-info-table">
                 </div>
             </div>
             <div id="glm-contact-notes-toggle" class="glm-contact-content-toggle">
-                <h3>Notes</h3>                
+                <h3>Notes</h3>
             </div>
             <div id="glm-contact-notes-container" class="glm-admin-form-section glm-contact-content-data">
                 <div id="glm-contact-notes">
                     <table class="glm-admin-table glm-admin-table-inner">
 
                         <tr>
-                            <td {if $contactInfo.fieldFail.notes}class="glm-form-bad-input"{/if}>    
+                            <td {if $contactInfo.fieldFail.notes}class="glm-form-bad-input"{/if}>
                                 <textarea name="notes" value="{$contactInfo.fieldData.notes}" class="" placeholder="Test">{if $contactInfo.fieldData.notes}{$contactInfo.fieldData.notes}{/if}</textarea>
                                 {if $contactInfo.fieldFail.notes}<p>{$contactInfo.fieldFail.notes}</p>{/if}
                             </td>