From 4b836251188ba5d19b32b777be1e5709c419598d Mon Sep 17 00:00:00 2001 From: Steve Sutton Date: Fri, 1 Jun 2018 17:05:23 -0400 Subject: [PATCH] delete notes,contacts and referred by when deleting lead Need to delete extra data per lead. --- models/admin/travel/index.php | 18 ++++++++++++++++-- setup/adminTabs.php | 17 +++++++++++++++++ setup/validActions.php | 3 +++ 3 files changed, 36 insertions(+), 2 deletions(-) diff --git a/models/admin/travel/index.php b/models/admin/travel/index.php index 19cea0e..140cb73 100644 --- a/models/admin/travel/index.php +++ b/models/admin/travel/index.php @@ -198,10 +198,24 @@ class GlmMembersAdmin_travel_index extends GlmDataTravelLeads switch ( $option ) { case 'delete': - // echo '
$this->entryId: ' . print_r( $this->entryId, true ) . '
'; if ( $this->entryId ) { $return = $this->deleteEntry( $this->entryId, true, 'id' ); - // echo '
$return: ' . print_r( $return, true ) . '
'; + // Need to delete the notes, contacts and referredby also + $this->wpdb->delete( + GLM_MEMBERS_TRAVEL_PLUGIN_DB_PREFIX . 'lead_notes', + array( 'lead' => $this->entryId ), + array( '%d' ) + ); + $this->wpdb->delete( + GLM_MEMBERS_TRAVEL_PLUGIN_DB_PREFIX . 'lead_contacts', + array( 'lead' => $this->entryId ), + array( '%d' ) + ); + $this->wpdb->delete( + GLM_MEMBERS_TRAVEL_PLUGIN_DB_PREFIX . 'leads_referredby', + array( 'lead' => $this->entryId ), + array( '%d' ) + ); } $entry = $this->getList(); $view = 'index.html'; diff --git a/setup/adminTabs.php b/setup/adminTabs.php index 015bc89..46aa351 100644 --- a/setup/adminTabs.php +++ b/setup/adminTabs.php @@ -51,3 +51,20 @@ if (current_user_can('glm_members_members')) { ); } + +if ( current_user_can( 'glm_members_management' ) ) { + add_filter( + 'glm-member-db-add-tab-for-import', + function( $addOnTabs ){ + $newTabs = array( + array( + 'text' => 'Travel Leads', + 'menu' => 'import', + 'action' => 'travel', + ) + ); + $addOnTabs = array_merge( $addOnTabs, $newTabs ); + return $addOnTabs; + } + ); +} diff --git a/setup/validActions.php b/setup/validActions.php index cb55e47..abd089f 100644 --- a/setup/validActions.php +++ b/setup/validActions.php @@ -74,6 +74,9 @@ $glmMembersTravelAddOnValidActions = array( 'index' => GLM_MEMBERS_TRAVEL_PLUGIN_SLUG, 'members' => GLM_MEMBERS_TRAVEL_PLUGIN_SLUG, ), + 'import' =>array( + 'travel' => GLM_MEMBERS_TRAVEL_PLUGIN_SLUG, + ), ), 'frontActions' => array( ) -- 2.17.1