Update for the csv download file.
authorSteve Sutton <steve@gaslightmedia.com>
Mon, 1 Aug 2016 13:41:10 +0000 (09:41 -0400)
committerSteve Sutton <steve@gaslightmedia.com>
Mon, 1 Aug 2016 13:41:10 +0000 (09:41 -0400)
Need to get email and the source name because these are reference ids.

index.php
models/admin/leads/index.php

index b0f992d..65587d6 100644 (file)
--- a/index.php
+++ b/index.php
@@ -3,7 +3,7 @@
  * Plugin Name: GLM Members Database Leads
  * Plugin URI: http://www.gaslightmedia.com/
  * Description: Gaslight Media Members Database.
- * Version: 1.0.0
+ * Version: 1.0.1
  * Author: Gaslight Media
  * Author URI: http://www.gaslightmedia.com/
  * License: GPL2
@@ -19,7 +19,7 @@
  * @package glmMembersDatabaseLeadsAddOn
  * @author Chuck Scott <cscott@gaslightmedia.com>
  * @license http://www.gaslightmedia.com Gaslightmedia
- * @version 1.0.0
+ * @version 1.0.1
  */
 
 /*
@@ -37,7 +37,7 @@
  *  so that we're sure the other add-ons see an up to date
  *  version from this plugin.
  */
-define('GLM_MEMBERS_LEADS_PLUGIN_VERSION', '1.0.0');
+define('GLM_MEMBERS_LEADS_PLUGIN_VERSION', '1.0.1');
 define('GLM_MEMBERS_LEADS_PLUGIN_DB_VERSION', '0.0.7');
 
 // This is the minimum version of the GLM Members DB plugin require for this plugin.
index a221772..c6fc35f 100644 (file)
@@ -324,9 +324,11 @@ class GlmMembersAdmin_leads_index extends GlmDataLeadEntry
                 switch ( $option ) {
                 case 'csv':
                     $sql = "
-                      SELECT T.*
-                        FROM " . GLM_MEMBERS_LEADS_PLUGIN_DB_PREFIX . "lead_entry T
+                      SELECT T.*,L.email
+                        FROM " . GLM_MEMBERS_LEADS_PLUGIN_DB_PREFIX . "lead_entry T,
+                             " . GLM_MEMBERS_LEADS_PLUGIN_DB_PREFIX . "leads L
                        WHERE $where
+                         AND T.lead_id = L.id
                     ORDER BY $order";
                     $leads = $this->wpdb->get_results( $sql, ARRAY_A );
                     break;
@@ -406,10 +408,18 @@ class GlmMembersAdmin_leads_index extends GlmDataLeadEntry
             if ( isset( $leads ) && is_array( $leads ) && !empty( $leads ) ) {
                 $lead_counter = 0;
                 foreach ( $leads as $entry_id => $lead ) {
+                    $source_name = $this->wpdb->get_var(
+                        $this->wpdb->prepare(
+                            "SELECT title
+                               FROM " . GLM_MEMBERS_LEADS_PLUGIN_DB_PREFIX . "sources
+                              WHERE id = %d",
+                            $lead['source_id']
+                        )
+                    );
                     $out = array(
                         'fname'          => $lead['fname'],
                         'lname'          => $lead['lname'],
-                        'email'          => $lead['lead_id']['name'],
+                        'email'          => $lead['email'],
                         'addr1'          => $lead['addr1'],
                         'addr2'          => $lead['addr2'],
                         'city'           => $lead['city'],
@@ -420,7 +430,7 @@ class GlmMembersAdmin_leads_index extends GlmDataLeadEntry
                         'phone2'         => $lead['phone2'],
                         'fax'            => $lead['fax'],
                         'date_submitted' => $lead['date_submitted'],
-                        'source'         => $lead['source_id']['name'],
+                        'source'         => $source_name,
                     );
                     // Add fields for group names
                     if ( $groups ) {