From f17804d4a998301ff1a561ba46a0a039faffc4d8 Mon Sep 17 00:00:00 2001 From: Steve Sutton Date: Tue, 7 Aug 2018 11:31:38 -0400 Subject: [PATCH] Updating contact export to add new contact fileds. Adding new contact fields for businesses. Adding billing fields. Add flag for billing only. --- css/admin.css | 11 +- models/admin/ajax/contactsListExport.php | 85 ++++++---- views/admin/ajax/contactsListExport.html | 45 +++++- views/admin/ajax/contactsListExportCsv.html | 40 ++++- views/admin/contacts/index.html | 170 ++++++++++++++++---- 5 files changed, 273 insertions(+), 78 deletions(-) diff --git a/css/admin.css b/css/admin.css index 00a743f..3bc0a6f 100644 --- a/css/admin.css +++ b/css/admin.css @@ -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); } diff --git a/models/admin/ajax/contactsListExport.php b/models/admin/ajax/contactsListExport.php index e27d2f8..fe1f90c 100644 --- a/models/admin/ajax/contactsListExport.php +++ b/models/admin/ajax/contactsListExport.php @@ -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 '
$_REQUEST: ' . print_r( $_REQUEST, true ) . '
'; + 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 '
$billingFields: ' . print_r( $billingFields, true ) . '
'; + 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 '
$BFSelect: ' . print_r( $BFSelect, true ) . '
'; + // echo '
$BFHeaders: ' . print_r( $BFHeaders, true ) . '
'; + // 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 '
$list: ' . print_r( $list, true ) . '
'; - // 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'; diff --git a/views/admin/ajax/contactsListExport.html b/views/admin/ajax/contactsListExport.html index 69d4072..de8e50d 100644 --- a/views/admin/ajax/contactsListExport.html +++ b/views/admin/ajax/contactsListExport.html @@ -12,6 +12,8 @@ {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} @@ -21,17 +23,29 @@ {if $select.exportState}State{/if} {if $select.exportZip}ZIP{/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}Org{/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} @@ -39,6 +53,8 @@ {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} @@ -48,17 +64,30 @@ {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_phone}{/if} {if $select.exportMobilePhone}{$m.mobile_phone}{/if} {if $select.exportAltPhone}{$m.alt_phone.value}{/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} diff --git a/views/admin/ajax/contactsListExportCsv.html b/views/admin/ajax/contactsListExportCsv.html index b6cf197..451e6e2 100644 --- a/views/admin/ajax/contactsListExportCsv.html +++ b/views/admin/ajax/contactsListExportCsv.html @@ -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} @@ -9,20 +11,32 @@ {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} @@ -32,17 +46,27 @@ {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} diff --git a/views/admin/contacts/index.html b/views/admin/contacts/index.html index 59c34dc..f4b0940 100644 --- a/views/admin/contacts/index.html +++ b/views/admin/contacts/index.html @@ -1,3 +1,7 @@ +
{if $fromMemberMenu} {include file='admin/member/header.html'} @@ -92,6 +96,7 @@ {* BEGIN: Export Form *} + {if !$fromMemberMenu && !$loggedInMember}
@@ -114,38 +119,63 @@ + {if apply_filters( 'glm-members-billing-enabled', false )} + + Only Billing Accounts: + +
+ + + {/if} Fields to Export: + Check All + Uncheck All + + + + - - - - - + + +
Check All / Uncheck All
- Contact ID
- First Name
- Last Name
- Address 1
- Address 2
- City
- County
- State
- ZIP
- Country
-
- Organization
- Title/Position
- Office Phone
- Home Phone
- Mobile Phone
- Alt Phone
- Fax Phone
- Email
- Alt Email
- Member Type
-
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
@@ -155,12 +185,68 @@ Custom Fields + + + + + + + + +
+ Check All + Uncheck All +
+ {$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} - {$cf.field_name}
+
+ {if $cf@iteration > $cfHalf && !$cfSplit} +
+ {$cfSplit = true} + {/if} {/foreach} {/if} + +
+ + + {/if} + {* Billing Fields Part *} + {if apply_filters( 'glm-members-billing-enabled', false )} + + Billing Fields + + + + + + + + + +
+ Check All + Uncheck All +
+ {$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} + + {if $bVal@iteration > $bfHalf && !$bfSplit} + + {$bfSplit = true} + {/if} + {/foreach} + {/if} +
{/if} @@ -176,8 +262,9 @@
-
+ {/if} {* END: Export Form *} +