delete notes,contacts and referred by when deleting lead
authorSteve Sutton <steve@gaslightmedia.com>
Fri, 1 Jun 2018 21:05:23 +0000 (17:05 -0400)
committerSteve Sutton <steve@gaslightmedia.com>
Fri, 1 Jun 2018 21:05:23 +0000 (17:05 -0400)
Need to delete extra data per lead.

models/admin/travel/index.php
setup/adminTabs.php
setup/validActions.php

index 19cea0e..140cb73 100644 (file)
@@ -198,10 +198,24 @@ class GlmMembersAdmin_travel_index extends GlmDataTravelLeads
 
         switch ( $option ) {
         case 'delete':
-            // echo '<pre>$this->entryId: ' . print_r( $this->entryId, true ) . '</pre>';
             if ( $this->entryId ) {
                 $return = $this->deleteEntry( $this->entryId, true, 'id' );
-                // echo '<pre>$return: ' . print_r( $return, true ) . '</pre>';
+                // 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';
index 015bc89..46aa351 100644 (file)
@@ -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;
+        }
+    );
+}
index cb55e47..abd089f 100644 (file)
@@ -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(
     )