Updating contact export to add new contact fileds.
authorSteve Sutton <steve@gaslightmedia.com>
Tue, 7 Aug 2018 15:31:38 +0000 (11:31 -0400)
committerSteve Sutton <steve@gaslightmedia.com>
Tue, 7 Aug 2018 15:31:38 +0000 (11:31 -0400)
Adding new contact fields for businesses.
Adding billing fields.
Add flag for billing only.

css/admin.css
models/admin/ajax/contactsListExport.php
views/admin/ajax/contactsListExport.html
views/admin/ajax/contactsListExportCsv.html
views/admin/contacts/index.html

index 00a743f..3bc0a6f 100644 (file)
@@ -154,9 +154,10 @@ input::placeholder {
 #glm-table-profile input[type=text] {
     background-color: #fff;
     /* border-bottom: 1px solid #ddd; */
-    border-width: 0 0 1px 0;
+    border-width: 1px;
     /* box-shadow: inset 0px 0px 4px 1px rgba(0,0,0,.07); */
-    box-shadow: inset 0px -1px 1px 1px rgba(0,0,0,.07);
+    /* box-shadow: inset 0px -1px 1px 1px rgba(0,0,0,.07); */
+    box-shadow: inset 0px 0px 1px 1px rgba(0, 0, 0, .07);
     color: #32373c;
     outline: 0;
     transition: 50ms border-color ease-in-out;
@@ -367,7 +368,7 @@ a.tooltip, a.tooltip_bottomleft, a.tooltip_left {
         float: right;
         top: 0px;
     }
-    
+
 }
 @media only screen and (max-width: 639px) {
     a.tooltip, a.tooltip_bottomleft, a.tooltip_left {
@@ -381,8 +382,8 @@ a.tooltip, a.tooltip_bottomleft, a.tooltip_left {
 /* CSS animation */
 
 @-webkit-keyframes fadeIn {
-    0% { 
-        opacity:0; 
+    0% {
+        opacity:0;
         transform: scale(0.6);
     }
 
index e27d2f8..fe1f90c 100644 (file)
@@ -96,33 +96,14 @@ class GlmMembersAdmin_ajax_contactsListExport extends GlmDataContacts
         $namesList      = false;
         $CFSelect       = false;
         $CFHeaders      = false;
+        $select         = array();
 
         // Check selected fields
-        $select = array(
-            'exportId'          => $this->checkFlag( 'exportId' ),
-            'exportFname'       => $this->checkFlag( 'exportFname' ),
-            'exportLname'       => $this->checkFlag( 'exportLname' ),
-            'exportAddr1'       => $this->checkFlag( 'exportAddr1' ),
-            'exportAddr2'       => $this->checkFlag( 'exportAddr2' ),
-            'exportCity'        => $this->checkFlag( 'exportCity' ),
-            'exportCounty'      => $this->checkFlag( 'exportCounty' ),
-            'exportState'       => $this->checkFlag( 'exportState' ),
-            'exportZip'         => $this->checkFlag( 'exportZip' ),
-            'exportCountry'     => $this->checkFlag( 'exportCountry' ),
-            'exportOrg'         => $this->checkFlag( 'exportOrg' ),
-            'exportTitle'       => $this->checkFlag( 'exportTitle' ),
-            'exportOfficePhone' => $this->checkFlag( 'exportOfficePhone' ),
-            'exportHomePhone'   => $this->checkFlag( 'exportHomePhone' ),
-            'exportMobilePhone' => $this->checkFlag( 'exportMobilePhone' ),
-            'exportAltPhone'    => $this->checkFlag( 'exportAltPhone' ),
-            'exportFax'         => $this->checkFlag( 'exportFax' ),
-            'exportEmail'       => $this->checkFlag( 'exportEmail' ),
-            'exportAltEmail'    => $this->checkFlag( 'exportAltEmail' ),
-            'exportMemberType'  => $this->checkFlag( 'exportMemberType' ),
-        );
-
-
-        // echo '<pre>$_REQUEST: ' . print_r( $_REQUEST, true ) . '</pre>';
+        if ( isset( $_REQUEST ) ) {
+            foreach ( $_REQUEST as $key => $var ) {
+                $select[$key] = $this->checkFlag( $key );
+            }
+        }
 
         // Check for selection of Custom Fields
         $fieldPluginActive = apply_filters( 'glm-members-customfields-active', false );
@@ -138,6 +119,35 @@ class GlmMembersAdmin_ajax_contactsListExport extends GlmDataContacts
             }
         }
 
+        // Check for selection of Billing Fields
+        $fieldBillingActive = apply_filters( 'glm-members-billing-enabled', false );
+        if ( $fieldBillingActive ) {
+            $billingFields = apply_filters( 'glm-member-db-billing-get-fields', false, 'glm-member-db-contacts' );
+            // echo '<pre>$billingFields: ' . print_r( $billingFields, true ) . '</pre>';
+            if ( $billingFields ) {
+                foreach ( $billingFields as $bfKey => $bfVal ) {
+                    if ( isset( $_REQUEST['exportBilling'][$bfKey] ) ) {
+                        $BFSelect[]  = $bfKey;
+                        $BFHeaders[] = $bfVal;
+                    }
+                }
+            }
+
+            // Check if there is a billing only filter
+            if ( isset( $_REQUEST['billing_only'] ) && $billing_only = filter_var( $_REQUEST['billing_only'], FILTER_VALIDATE_BOOLEAN ) ) {
+                $where .= " AND T.ref_dest IN (
+                    SELECT DISTINCT(ref_dest)
+                      FROM " . GLM_MEMBERS_BILLING_PLUGIN_DB_PREFIX . "accounts
+                ) ";
+            }
+
+        }
+
+
+        // echo '<pre>$BFSelect: ' . print_r( $BFSelect, true ) . '</pre>';
+        // echo '<pre>$BFHeaders: ' . print_r( $BFHeaders, true ) . '</pre>';
+        // exit;
+
         // Only return information records that are active
 
         // Check if there is a member_type filter
@@ -165,9 +175,6 @@ class GlmMembersAdmin_ajax_contactsListExport extends GlmDataContacts
         // Get a current list of contacts without paging
         $list = $this->getList( $where, false, 'lname, fname' );
 
-        // echo '<pre>$list: ' . print_r( $list, true ) . '</pre>';
-        // exit;
-
         // If we have list entries - even if it's an empty list
         $success     = true;
         $haveMembers = false;
@@ -210,9 +217,29 @@ class GlmMembersAdmin_ajax_contactsListExport extends GlmDataContacts
 
                 }
 
+                // If Billing Fields are selected.
+                if ( $BFSelect && !empty( $BFSelect ) ) {
+
+                    foreach ( $list as $k => $v ) {
+                        $billing_data = apply_filters( 'glm-member-db-billing-get-data', $v['ref_dest'] );
+                        foreach ( $BFSelect as $bf_val ) {
+                            switch( $bf_val ) {
+                            case 'renewal_date':
+                                $list[$k][$bf_val] = $billing_data[$bf_val] ? date( 'm/d/Y', strtotime( $billing_data[$bf_val] ) ): '';
+                                break;
+                            default:
+                                $list[$k][$bf_val] = $billing_data[$bf_val];
+                                break;
+                            }
+                        }
+                    }
+
+                }
+
             }
         }
 
+
         // Compile template data
         $templateData = array(
             'select'         => $select,
@@ -234,6 +261,8 @@ class GlmMembersAdmin_ajax_contactsListExport extends GlmDataContacts
             'namesList'      => $namesList,
             'CFSelect'       => $CFSelect,
             'CFHeaders'      => $CFHeaders,
+            'BFSelect'       => $BFSelect,
+            'BFHeaders'      => $BFHeaders,
         );
 
         $view = 'admin/ajax/contactsListExport.html';
index 69d4072..de8e50d 100644 (file)
@@ -12,6 +12,8 @@
             <thead>
                 <tr>
                     {if $select.exportId}<th align="left">ID</th>{/if}
+                    {if $select.exportMailAddrType}<th align="left">Mailing Address Type</th>{/if}
+                    {if $select.exportMailLabel}<th align="left">Addressee Name</th>{/if}
                     {if $select.exportFname}<th align="left">First Name</th>{/if}
                     {if $select.exportLname}<th align="left">Last Name</th>{/if}
                     {if $select.exportAddr1}<th align="left">Address 1</th>{/if}
                     {if $select.exportState}<th align="left">State</th>{/if}
                     {if $select.exportZip}<th align="left">ZIP</th>{/if}
                     {if $select.exportCountry}<th align="left">Country</th>{/if}
-                    {if $select.exportOrg}<th align="left">Org</th>{/if}
-                    {if $select.exportTitle}<th align="left">Title</th>{/if}
-                    {if $select.exportOfficePhone}<th align="left">Office Phone</th>{/if}
                     {if $select.exportHomePhone}<th align="left">Home Phone</th>{/if}
                     {if $select.exportMobilePhone}<th align="left">Mobile Phone</th>{/if}
                     {if $select.exportAltPhone}<th align="left">Alt Phone</th>{/if}
-                    {if $select.exportFax}<th align="left">Fax</th>{/if}
                     {if $select.exportEmail}<th align="left">E-Mail</th>{/if}
                     {if $select.exportAltEmail}<th align="left">Alt E-Mail</th>{/if}
                     {if $select.exportMemberType}<th align="left">Member Type</th>{/if}
+
+                    {if $select.exportOrg}<th align="left">Org</th>{/if}
+                    {if $select.exportBusFname}<th align="left">Business First Name</th>{/if}
+                    {if $select.exportBusLname}<th align="left">Business Last Name</th>{/if}
+                    {if $select.exportTitle}<th align="left">Title</th>{/if}
+                    {if $select.exportBusAddr1}<th align="left">Business Address 1</th>{/if}
+                    {if $select.exportBusAddr2}<th align="left">Business Address 2</th>{/if}
+                    {if $select.exportBusCity}<th align="left">Business City</th>{/if}
+                    {if $select.exportBusState}<th align="left">Business State</th>{/if}
+                    {if $select.exportBusZip}<th align="left">Business Zip</th>{/if}
+                    {if $select.exportBusCountry}<th align="left">Business Country</th>{/if}
+                    {if $select.exportBusEmail}<th align="left">Business Email</th>{/if}
+                    {if $select.exportOfficePhone}<th align="left">Office Phone</th>{/if}
+                    {if $select.exportFax}<th align="left">Fax</th>{/if}
+
                     {if $CFHeaders}{foreach $CFHeaders as $cHead}<th align="left">{$cHead}</th>{/foreach}{/if}
+                    {if $BFHeaders}{foreach $BFHeaders as $bHead}<th align="left">{$bHead}</th>{/foreach}{/if}
                 </tr>
             </thead>
             <tbody>
@@ -39,6 +53,8 @@
         {foreach $contacts as $m}
                 <tr>
                     {if $select.exportId}<td>{$m.id}</td>{/if}
+                    {if $select.exportMailAddrType}<td>{$m.mailing_address_type}</td>{/if}
+                    {if $select.exportMailLabel}<td>{$m.mailto_label}</td>{/if}
                     {if $select.exportFname}<td>{$m.fname}</td>{/if}
                     {if $select.exportLname}<td>{$m.lname}</td>{/if}
                     {if $select.exportAddr1}<td>{$m.addr1}</td>{/if}
                     {if $select.exportState}<td>{if $m.state}{$m.state.value}{/if}</td>{/if}
                     {if $select.exportZip}<td>{$m.zip}</td>{/if}
                     {if $select.exportCountry}<td>{if $m.country.value}{$m.country.value}{/if}</td>{/if}
-                    {if $select.exportOrg}<td>{$m.org}</td>{/if}
-                    {if $select.exportTitle}<td>{$m.title}</td>{/if}
-                    {if $select.exportOfficePhone}<td>{$m.office_phone}</td>{/if}
                     {if $select.exportHomePhone}<td>{$m.home_phone}</td>{/if}
                     {if $select.exportMobilePhone}<td>{$m.mobile_phone}</td>{/if}
                     {if $select.exportAltPhone}<td>{$m.alt_phone.value}</td>{/if}
-                    {if $select.exportFax}<td>{$m.fax}</td>{/if}
                     {if $select.exportEmail}<td>{$m.email}</td>{/if}
                     {if $select.exportAltEmail}<td>{$m.alt_email}</td>{/if}
                     {if $select.exportMemberType}<td>{$m.member_type}</td>{/if}
+
+                    {if $select.exportOrg}<td>{$m.org}</td>{/if}
+                    {if $select.exportBusFname}<td>{$m.business_fname}</td>{/if}
+                    {if $select.exportBusLname}<td>{$m.business_lname}</td>{/if}
+                    {if $select.exportTitle}<td>{$m.title}</td>{/if}
+
+                    {if $select.exportBusAddr1}<td>{$m.business_addr1}</td>{/if}
+                    {if $select.exportBusAddr2}<td>{$m.business_addr2}</td>{/if}
+                    {if $select.exportBusCity}<td>{$m.business_city}</td>{/if}
+                    {if $select.exportBusState}<td>{if $m.business_state}{$m.business_state.value}{/if}</td>{/if}
+                    {if $select.exportBusZip}<td>{$m.business_zip}</td>{/if}
+                    {if $select.exportBusCountry}<td>{if $m.business_country}{$m.business_country.value}{/if}</td>{/if}
+                    {if $select.exportBusEmail}<td>{$m.business_email}</td>{/if}
+                    {if $select.exportOfficePhone}<td>{$m.office_phone}</td>{/if}
+                    {if $select.exportFax}<td>{$m.fax}</td>{/if}
+
                     {if $CFHeaders}{foreach $CFHeaders as $cHead}<td>{$m[$cHead]}</td>{/foreach}{/if}
+                    {if $BFSelect}{foreach $BFSelect as $bValue}<td>{$m[$bValue]}</td>{/foreach}{/if}
 
                 </tr>
         {/foreach}
index b6cf197..451e6e2 100644 (file)
@@ -1,5 +1,7 @@
 {if $haveMembers}
 {if $select.exportId}"ID",{/if}
+{if $select.exportMailAddrType}"Mailing Address Type",{/if}
+{if $select.exportMailLabel}"Addressee Name",{/if}
 {if $select.exportFname}"First Name",{/if}
 {if $select.exportLname}"Last Name",{/if}
 {if $select.exportAddr1}"Address 1",{/if}
 {if $select.exportState}"State",{/if}
 {if $select.exportZip}"ZIP/Postal",{/if}
 {if $select.exportCountry}"Country",{/if}
-{if $select.exportOrg}"Org",{/if}
-{if $select.exportTitle}"Title",{/if}
-{if $select.exportOfficePhone}"Office Phone",{/if}
 {if $select.exportHomePhone}"Home Phone",{/if}
 {if $select.exportMobilePhone}"Mobile Phone",{/if}
 {if $select.exportAltPhone}"Alt Phone",{/if}
-{if $select.exportFax}"Fax",{/if}
 {if $select.exportEmail}"E-Mail",{/if}
 {if $select.exportAltEmail}"Alt E-Mail",{/if}
 {if $select.exportMemberType}"Member Type",{/if}
+{if $select.exportOrg}"Organization",{/if}
+{if $select.exportBusFname}"Business First Name",{/if}
+{if $select.exportBusLname}"Business Last Name",{/if}
+{if $select.exportTitle}"Title",{/if}
+{if $select.exportBusAddr1}"Business Address 1",{/if}
+{if $select.exportBusAddr2}"Business Address 2",{/if}
+{if $select.exportBusCity}"Business City",{/if}
+{if $select.exportBusState}"Business State",{/if}
+{if $select.exportBusZip}"Business Zip",{/if}
+{if $select.exportBusCountry}"Business Country",{/if}
+{if $select.exportBusEmail}"Business Email",{/if}
+{if $select.exportOfficePhone}"Office Phone",{/if}
+{if $select.exportFax}"Fax",{/if}
 {if $CFHeaders}{foreach $CFHeaders as $cHead}"{$cHead}",{/foreach}{/if}
+{if $BFHeaders}{foreach $BFHeaders as $bHead}"{$bHead}",{/foreach}{/if}
 
 {foreach $contacts as $m}
 {if $select.exportId}"{$m.id}",{/if}
+{if $select.exportMailAddrType}"{$m.mailing_address_type}",{/if}
+{if $select.exportMailLabel}"{$m.mailto_label}",{/if}
 {if $select.exportFname}"{$m.fname}",{/if}
 {if $select.exportLname}"{$m.lname}",{/if}
 {if $select.exportAddr1}"{$m.addr1}",{/if}
 {if $select.exportState}"{if $m.state}{$m.state.value}{/if}",{/if}
 {if $select.exportZip}"{$m.zip}",{/if}
 {if $select.exportCountry}"{if $m.country.value}{$m.country.value}{/if}",{/if}
-{if $select.exportOrg}"{$m.org}",{/if}
-{if $select.exportTitle}"{$m.title}",{/if}
-{if $select.exportOfficePhone}"{$m.office_phone}",{/if}
 {if $select.exportHomePhone}"{$m.home_phane}",{/if}
 {if $select.exportMobilePhone}"{$m.mobile_phone}",{/if}
 {if $select.exportAltPhone}"{$m.alt_phone}",{/if}
-{if $select.exportFax}"{$m.fax}",{/if}
 {if $select.exportEmail}"{$m.email}",{/if}
 {if $select.exportAltEmail}"{$m.alt_email}",{/if}
 {if $select.exportMemberType}"{$m.member_type}",{/if}
+{if $select.exportOrg}"{$m.org}",{/if}
+{if $select.exportBusFname}"{$m.business_fname}",{/if}
+{if $select.exportBusLname}"{$m.business_lname}",{/if}
+{if $select.exportTitle}"{$m.title}",{/if}
+{if $select.exportBusAddr1}"{$m.business_addr1}",{/if}
+{if $select.exportBusAddr2}"{$m.business_addr2}",{/if}
+{if $select.exportBusCity}"{$m.business_city}",{/if}
+{if $select.exportBusState}"{if $m.business_state}{$m.business_state.value}{/if}",{/if}
+{if $select.exportBusZip}"{$m.business_zip}",{/if}
+{if $select.exportBusCountry}"{if $m.business_country}{$m.business_country.value}{/if}",{/if}
+{if $select.exportBusEmail}"{$m.business_email}",{/if}
+{if $select.exportOfficePhone}"{$m.office_phone}",{/if}
+{if $select.exportFax}"{$m.fax}",{/if}
 {if $CFHeaders}{foreach $CFHeaders as $cHead}"{$m[$cHead]}",{/foreach}{/if}
+{if $BFSelect}{foreach $BFSelect as $bValue}"{$m[$bValue]}",{/foreach}{/if}
 
 {/foreach}
 {else}No Contacts Selected{/if}
index 59c34dc..f4b0940 100644 (file)
@@ -1,3 +1,7 @@
+<style>
+.export-label {
+}
+</style>
 <div id="glm-admin-contact-wrapper">
 {if $fromMemberMenu}
     {include file='admin/member/header.html'}
@@ -92,6 +96,7 @@
     </form>
 
     {* BEGIN: Export Form *}
+    {if !$fromMemberMenu && !$loggedInMember}
     <div id="exportContactsDialog" class="glm-dialog-box" title="Export Contacts">
         <form id="exportForm" action="{$ajaxUrl}" method="post" enctype="multipart/form-data">
             <input type="hidden" name="action" value="glm_members_admin_ajax">
                         </select>
                     </td>
                 </tr>
+                {if apply_filters( 'glm-members-billing-enabled', false )}
+                <tr>
+                    <th>Only Billing Accounts: </th>
+                    <td>
+                        <input type="checkbox" name="billing_only"><br>
+                    </td>
+                </tr>
+                {/if}
                 <tr>
                     <th>Fields to Export: </th>
                     <td>
+                        <a id="selectAllExportFields" class="button button-secondary button-small">Check All</a>
+                        <a id="unselectAllExportFields" class="button button-secondary button-small">Uncheck All</a>
+                    </td>
+                </tr>
+                <tr>
+                    <td colspan="2">
                         <table padding="3">
                             <tr>
-                                <td colspan="2"><a id="selectAllExportFields">Check All</a> / <a id="unselectAllExportFields">Uncheck All</a></td>
-                            </tr>
-                            <tr>
-                            <td class="exportFieldsTd">
-                                <input type="checkbox" name="exportId"> Contact ID<br>
-                                <input type="checkbox" name="exportFname" checked> First Name<br>
-                                <input type="checkbox" name="exportLname" checked> Last Name<br>
-                                <input type="checkbox" name="exportAddr1" checked> Address 1<br>
-                                <input type="checkbox" name="exportAddr2" checked> Address 2<br>
-                                <input type="checkbox" name="exportCity" checked> City<br>
-                                <input type="checkbox" name="exportCounty" checked> County<br>
-                                <input type="checkbox" name="exportState" checked> State<br>
-                                <input type="checkbox" name="exportZip" checked> ZIP<br>
-                                <input type="checkbox" name="exportCountry" checked> Country<br>
-                            </td>
-                            <td class="exportFieldsTd">
-                                <input type="checkbox" name="exportOrg" checked> Organization<br>
-                                <input type="checkbox" name="exportTitle" checked> Title/Position<br>
-                                <input type="checkbox" name="exportOfficePhone" checked> Office Phone<br>
-                                <input type="checkbox" name="exportHomePhone" checked> Home Phone<br>
-                                <input type="checkbox" name="exportMobilePhone" checked> Mobile Phone<br>
-                                <input type="checkbox" name="exportAltPhone" checked> Alt Phone<br>
-                                <input type="checkbox" name="exportFax" checked> Fax Phone<br>
-                                <input type="checkbox" name="exportEmail" checked> Email<br>
-                                <input type="checkbox" name="exportAltEmail" checked> Alt Email<br>
-                                <input type="checkbox" name="exportMemberType" checked> Member Type<br>
-                            </td>
+                                <td class="exportFieldsTd" width="30%">
+                                    <label class="export-label"> <input type="checkbox" name="exportId" checked> Contact ID<br> </label>
+                                    <label class="export-label"> <input type="checkbox" name="exportMailAddrType" checked> Mailing Address Type<br> </label>
+                                    <label class="export-label"> <input type="checkbox" name="exportMailLabel" checked> Addressee Name<br> </label>
+                                    <label class="export-label"> <input type="checkbox" name="exportFname" checked> First Name<br> </label>
+                                    <label class="export-label"> <input type="checkbox" name="exportFname" checked> First Name<br> </label>
+                                    <label class="export-label"> <input type="checkbox" name="exportLname" checked> Last Name<br> </label>
+                                    <label class="export-label"> <input type="checkbox" name="exportAddr1" checked> Address 1<br> </label>
+                                    <label class="export-label"> <input type="checkbox" name="exportAddr2" checked> Address 2<br> </label>
+                                    <label class="export-label"> <input type="checkbox" name="exportCity" checked> City<br> </label>
+                                    <label class="export-label"> <input type="checkbox" name="exportCounty" checked> County<br> </label>
+                                    <label class="export-label"> <input type="checkbox" name="exportState" checked> State<br> </label>
+                                </td>
+                                <td class="exportFieldsTd" width="30%">
+                                    <label class="export-label"> <input type="checkbox" name="exportZip" checked> ZIP<br> </label>
+                                    <label class="export-label"> <input type="checkbox" name="exportCountry" checked> Country<br> </label>
+                                    <label class="export-label"> <input type="checkbox" name="exportHomePhone" checked> Home Phone<br> </label>
+                                    <label class="export-label"> <input type="checkbox" name="exportMobilePhone" checked> Mobile Phone<br> </label>
+                                    <label class="export-label"> <input type="checkbox" name="exportAltPhone" checked> Alt Phone<br> </label>
+                                    <label class="export-label"> <input type="checkbox" name="exportEmail" checked> Email<br> </label>
+                                    <label class="export-label"> <input type="checkbox" name="exportAltEmail" checked> Alt Email<br> </label>
+                                    <label class="export-label"> <input type="checkbox" name="exportMemberType" checked> Member Type<br> </label>
+                                    <label class="export-label"> <input type="checkbox" name="exportOrg" checked> Organization<br> </label>
+                                    <label class="export-label"> <input type="checkbox" name="exportBusFname" checked> Business First Name<br> </label>
+                                    <label class="export-label"> <input type="checkbox" name="exportBusLname" checked> Business Last Name<br> </label>
+                                </td>
+                                <td class="exportFieldsTd" width="30%">
+                                    <label class="export-label"> <input type="checkbox" name="exportTitle" checked> Title/Position<br> </label>
+                                    <label class="export-label"> <input type="checkbox" name="exportBusAddr1" checked> Business Address 1<br> </label>
+                                    <label class="export-label"> <input type="checkbox" name="exportBusAddr2" checked> Business Address 2<br> </label>
+                                    <label class="export-label"> <input type="checkbox" name="exportBusCity" checked> Business City<br> </label>
+                                    <label class="export-label"> <input type="checkbox" name="exportBusState" checked> Business State<br> </label>
+                                    <label class="export-label"> <input type="checkbox" name="exportBusZip" checked> Business ZIP<br> </label>
+                                    <label class="export-label"> <input type="checkbox" name="exportBusCountry" checked> Business Country<br> </label>
+                                    <label class="export-label"> <input type="checkbox" name="exportBusEmail" checked> Business Email<br> </label>
+                                    <label class="export-label"> <input type="checkbox" name="exportOfficePhone" checked> Office Phone<br> </label>
+                                    <label class="export-label"> <input type="checkbox" name="exportFax" checked> Business Fax<br> </label>
+                                </td>
                             </tr>
                         </table>
                     </td>
                 <tr>
                     <th>Custom Fields</th>
                     <td>
+                        <table padding="3">
+                            <tr>
+                                <td colspan="2" width="50%">
+                                    <a id="selectAllCfExportFields" class="button button-secondary button-small">Check All</a>
+                                    <a id="unselectAllCfExportFields" class="button button-secondary button-small">Uncheck All</a>
+                                </td>
+                            </tr>
+                            <tr>
+                            <td class="exportFieldsCfTd">
+
                     {$customFields = apply_filters('glm-member-db-fields-get-members-fields', false, 'glm-member-db-contacts')}
+                    {$cfCount = $customFields|count}
+                    {$cfHalf = $cfCount / 2}
+                    {$cfSplit = false}
                     {if $customFields}
                         {foreach $customFields as $cf}
-                            <input type="checkbox" name="exportCF[{$cf.id}]" checked> {$cf.field_name} <br>
+                        <label class="export-label"> <input type="checkbox" name="exportCF[{$cf.id}]" checked> {$cf.field_name} </label> <br>
+                            {if $cf@iteration > $cfHalf && !$cfSplit}
+                            </td>
+                            <td class="exportFieldsCfTd">
+                                {$cfSplit = true}
+                            {/if}
                         {/foreach}
                     {/if}
+
+                            </td>
+                            </tr>
+                        </table>
+                    </td>
+                </tr>
+                {/if}
+                {* Billing Fields Part *}
+                {if apply_filters( 'glm-members-billing-enabled', false )}
+                <tr>
+                    <th>Billing Fields</th>
+                    <td>
+                        <table padding="3">
+                            <tr>
+                                <td colspan="2" width="50%">
+                                    <a id="selectAllBfExportFields" class="button button-secondary button-small">Check All</a>
+                                    <a id="unselectAllBfExportFields" class="button button-secondary button-small">Uncheck All</a>
+                                </td>
+                            </tr>
+                            <tr>
+                            <td class="exportFieldsBfTd">
+                        {$billingFields = apply_filters('glm-member-db-billing-get-fields', false)}
+                        {$bfCount = $billingFields|count}
+                        {$bfHalf = $bfCount / 2}
+                        {$bfSplit = false}
+                        {if $billingFields}
+                            {foreach $billingFields as $bKey => $bVal}
+                            <label class="export-label"> <input type="checkbox" name="exportBilling[{$bKey}]" checked> {$bVal} <br> </label>
+                            {if $bVal@iteration > $bfHalf && !$bfSplit}
+                            </td>
+                            <td class="exportFieldsBfTd">
+                                {$bfSplit = true}
+                            {/if}
+                            {/foreach}
+                        {/if}
+                            </td>
+                            </tr>
+                        </table>
                     </td>
                 </tr>
                 {/if}
             <input type="submit" value="Export" class="button button-primary">
         </form>
     </div>
-</div>
+    {/if}
     {* END: Export Form *}
+</div>
 
     <script type="text/javascript">
         jQuery(document).ready(function($) {
                  }
              });
 
+            // Select all/none for main fields.
             $('#selectAllExportFields').click(function(){
                 $('.exportFieldsTd input[type="checkbox"]').each(function(){
                     $(this).prop('checked', true);
                 });
             });
 
+            // Select all/none for custom fields.
+            $('#selectAllCfExportFields').click(function(){
+                $('.exportFieldsCfTd input[type="checkbox"]').each(function(){
+                    $(this).prop('checked', true);
+                });
+            });
+            $('#unselectAllCfExportFields').click(function(){
+                $('.exportFieldsCfTd input[type="checkbox"]').each(function(){
+                    $(this).prop('checked', false);
+                });
+            });
+
+            // Select all/none for Billing fields.
+            $('#selectAllBfExportFields').click(function(){
+                $('.exportFieldsBfTd input[type="checkbox"]').each(function(){
+                    $(this).prop('checked', true);
+                });
+            });
+            $('#unselectAllBfExportFields').click(function(){
+                $('.exportFieldsBfTd input[type="checkbox"]').each(function(){
+                    $(this).prop('checked', false);
+                });
+            });
+
             // Export Contacts
             $("#exportContactsDialog").dialog({
                 autoOpen: false,