WIP for leads sub menu
authorSteve Sutton <steve@gaslightmedia.com>
Fri, 8 Jul 2016 21:01:06 +0000 (17:01 -0400)
committerSteve Sutton <steve@gaslightmedia.com>
Fri, 8 Jul 2016 21:01:06 +0000 (17:01 -0400)
Working on the member leads data abstract classes for leads and lead_entry.
building the page which will be the search for leads.
testing getting the lead entries first to output into a table for the leads.

classes/data/dataInterests.php
classes/data/dataLeadEntry.php [new file with mode: 0644]
classes/data/dataLeads.php
models/admin/leads/index.php
views/admin/leads/index.html

index c107adf..640e37a 100644 (file)
@@ -123,7 +123,6 @@ class GlmDataInterests extends GlmDataAbstract
                 'use'      => 'a',
             ),
 
-            // Parent - for adding, deleting and editing, has selection Tables
             'group_id' => array(
                 'field'      => 'group_id',
                 'type'       => 'pointer',
diff --git a/classes/data/dataLeadEntry.php b/classes/data/dataLeadEntry.php
new file mode 100644 (file)
index 0000000..428f2fa
--- /dev/null
@@ -0,0 +1,265 @@
+<?php
+/**
+ * GLM Member-DB WordPress Add-On Plugin
+ * Data Class Leads
+ *
+ * PHP version 5.3
+ *
+ * @category Data
+ * @package  GLM Member-DB
+ * @author   Chuck Scott <cscott@gaslightmedia.com>
+ * @license  http://www.gaslightmedia.com Gaslightmedia
+ * @release  SVN: $Id: dataLeads.php,v 1.0 2011/01/25 19:31:47 cscott Exp $
+ */
+
+/**
+ * GlmDataLeads class
+ *
+ * PHP version 5
+ *
+ * @category Data
+ * @package GLM Member DB
+ * @author  Chuck Scott <cscott@gaslightmedia.com>
+ * @license http://www.gaslightmedia.com Gaslightmedia
+ *          @release SVN: $Id: dataMembers.php,v 1.0 2011/01/25 19:31:47 cscott
+ *          Exp $
+ */
+class GlmDataLeadEntry extends GlmDataAbstract
+{
+
+    /**
+     * WordPress Database Object
+     *
+     * @var $wpdb
+     * @access public
+     */
+    public $wpdb;
+    /**
+     * Plugin Configuration Data
+     *
+     * @var $config
+     * @access public
+     */
+    public $config;
+    /**
+     * Data Table Name
+     *
+     * @var $table
+     * @access public
+     */
+    public $table;
+    /**
+     * Field definitions
+     *
+     * 'type' is type of field as defined by the application
+     * text Regular text field
+     * pointer Pointer to an entry in another table
+     * 'filters' is the filter name for a particular filter ID in PHP filter
+     * functions
+     * See PHP filter_id()
+     *
+     * 'use' is when to use the field
+     * l = List
+     * g = Get
+     * n = New
+     * i = Insert
+     * e = Edit
+     * u = Update
+     * d = Delete
+     * a = All
+     *
+     * @var $ini
+     * @access public
+     */
+    public $fields = false;
+
+    /**
+     * Constructor
+     *
+     * @param object $d database connection
+     * @param array $config Configuration array
+     * @param bool $limitedEdit Flag to say indicate limited edit requested
+     *
+     * @return void
+     * @access public
+     */
+    public function __construct($wpdb, $config, $limitedEdit = false)
+    {
+
+        // If this class is not being extended along with existing $wpdb and $config
+        if (!$this->wpdb) {
+
+            // Save WordPress Database object
+            $this->wpdb = $wpdb;
+
+            // Save plugin configuration object
+            $this->config = $config;
+
+        }
+
+        /*
+         * Table Name
+         */
+        $this->table = GLM_MEMBERS_LEADS_PLUGIN_DB_PREFIX . 'lead_entry';
+
+        /*
+         * Table Data Fields
+         */
+
+        $this->fields = array(
+
+            'id' => array(
+                'field'     => 'id',
+                'type'      => 'integer',
+                'view_only' => true,
+                'use'       => 'a',
+            ),
+
+            'lead_id' => array(
+                'field'      => 'lead_id',
+                'type'       => 'pointer',
+                'p_table'    => GLM_MEMBERS_LEADS_PLUGIN_DB_PREFIX . 'leads',
+                'p_field'    => 'email',
+                'p_orderby'  => 'email',
+                'p_blank'    => true,
+                'force_list' => true,
+                'required'   => true,
+                'use'        => 'a'
+            ),
+
+            'fname' => array(
+                'field'     => 'fname',
+                'type'      => 'text',
+                'required'  => false,
+                'unique'    => false,
+                'use'       => 'a',
+            ),
+
+            'lname' => array(
+                'field'     => 'lname',
+                'type'      => 'text',
+                'required'  => false,
+                'unique'    => false,
+                'use'       => 'a',
+            ),
+
+            'org' => array(
+                'field'     => 'org',
+                'type'      => 'text',
+                'required'  => false,
+                'unique'    => false,
+                'use'       => 'a',
+            ),
+
+            'addr1' => array(
+                'field'     => 'addr1',
+                'type'      => 'text',
+                'required'  => false,
+                'unique'    => false,
+                'use'       => 'a',
+            ),
+
+            'addr2' => array(
+                'field'     => 'addr2',
+                'type'      => 'text',
+                'required'  => false,
+                'unique'    => false,
+                'use'       => 'a',
+            ),
+
+            'city' => array(
+                'field'     => 'city',
+                'type'      => 'text',
+                'required'  => false,
+                'unique'    => false,
+                'use'       => 'a',
+            ),
+
+            'state' => array(
+                'field'     => 'state',
+                'type'      => 'text',
+                'required'  => false,
+                'unique'    => false,
+                'use'       => 'a',
+            ),
+
+            'zip' => array(
+                'field'     => 'zip',
+                'type'      => 'text',
+                'required'  => false,
+                'unique'    => false,
+                'use'       => 'a',
+            ),
+
+            'country' => array(
+                'field'     => 'country',
+                'type'      => 'text',
+                'required'  => false,
+                'unique'    => false,
+                'use'       => 'a',
+            ),
+
+            'phone' => array(
+                'field'     => 'phone',
+                'type'      => 'text',
+                'required'  => false,
+                'unique'    => false,
+                'use'       => 'a',
+            ),
+
+            'phone2' => array(
+                'field'     => 'phone2',
+                'type'      => 'text',
+                'required'  => false,
+                'unique'    => false,
+                'use'       => 'a',
+            ),
+
+            'fax' => array(
+                'field'     => 'fax',
+                'type'      => 'text',
+                'required'  => false,
+                'unique'    => false,
+                'use'       => 'a',
+            ),
+
+            'date_submitted' => array(
+                'field'     => 'date_submitted',
+                'type'      => 'text',
+                'required'  => false,
+                'unique'    => false,
+                'use'       => 'a',
+            ),
+
+            'user_trace_info' => array(
+                'field'     => 'user_trace_info',
+                'type'      => 'text',
+                'required'  => false,
+                'unique'    => false,
+                'use'       => 'a',
+            ),
+
+         );
+
+    }
+
+    /*
+     * Entry Post Processing Call-Back Method
+     *
+     * Perform post-processing for all result entries.
+     *
+     * In this case we're using it to append an array of category
+     * data to each member result and also sort by member name.
+     *
+     * @param array $r Array of field result data for a single entry
+     * @param string $a Action being performed (l, i, g, ...)
+     *
+     * @return object Class object
+     *
+     */
+    public function entryPostProcessing($r, $a)
+    {
+        return $r;
+    }
+
+}
index 82d4677..30ccda3 100644 (file)
@@ -106,16 +106,22 @@ class GlmDataLeads extends GlmDataAbstract
          * Table Data Fields
          */
 
-        $this->fields = array (
+        $this->fields = array(
 
-            'id' => array (
+            'id' => array(
                 'field'     => 'id',
                 'type'      => 'integer',
                 'view_only' => true,
-                'use'       => 'a'
-            )
-
-/* MORE STUFF GOES HERE */
+                'use'       => 'a',
+            ),
+
+            'email' => array(
+                'field'     => 'email',
+                'type'      => 'text',
+                'required'  => true,
+                'unique'    => true,
+                'use'       => 'a',
+            ),
 
          );
 
index 6a1739a..fb6847d 100644 (file)
  */
 
 // Load Leads data abstract
-require_once(GLM_MEMBERS_LEADS_PLUGIN_CLASS_PATH.'/data/dataLeads.php');
+require_once(GLM_MEMBERS_LEADS_PLUGIN_CLASS_PATH.'/data/dataLeadEntry.php');
+require_once GLM_MEMBERS_LEADS_PLUGIN_CLASS_PATH.'/data/dataInterests.php';
+require_once GLM_MEMBERS_LEADS_PLUGIN_CLASS_PATH.'/data/dataInterestGroups.php';
 
-class GlmMembersAdmin_leads_index extends GlmDataLeads
+class GlmMembersAdmin_leads_index extends GlmDataLeadEntry
 {
 
     /**
@@ -82,8 +84,31 @@ class GlmMembersAdmin_leads_index extends GlmDataLeads
     public function modelAction($actionData = false)
     {
 
+        if ( isset( $search ) && $search ) {
+            $leads = $this->getList();
+        } else {
+            $leads = '';
+        }
+        $leads = $this->getList();
+
+        $groupData = new GlmDataInterestGroups( $this->wpdb, $this->config );
+        $groups    = $groupData->getList();
+
+        $grouped_interests = array();
+
+        if ( $groups ) {
+            foreach ( $groups as $group ) {
+                $intData   = new GlmDataInterests( $this->wpdb, $this->config );
+                $grouped_interests[$group['title']] = $intData->getList(
+                    "group_id = " . $group['id'],
+                    'title'
+                );
+            }
+        }
+        echo '<pre>$grouped_interests: ' . print_r($grouped_interests, true) . '</pre>';
         // Compile template data
         $templateData = array(
+            'leads' => $leads,
         );
 
         // Return status, any suggested view, and any data to controller
index 1309ea5..c2148df 100644 (file)
@@ -1,6 +1,27 @@
 {include file='admin/leads/header.html'}
 
-<H1>ADMIN LEADS VIEW STUFF GOES HERE</H1>
+<form>
+    <label>Company</label><br>
+    <input type="text" name="company"><br>
+    <label>Contact</label><br>
+    <input type="text" name="contact"><br>
+    <input type="submit" value="Search">
+</form>
 
-    
-{include file='admin/footer.html'}
\ No newline at end of file
+{if $leads}
+    <table class="glm-admin-table">
+        <tr>
+            <th>Company</th>
+            <th>Contact</th>
+            <th>Submitted</th>
+        </tr>
+        {foreach $leads as $lead}
+        <tr>
+            <td> {$lead.org} </td>
+            <td> {$lead.fname} {$lead.lname} </td>
+            <td> {$lead.date_submitted} </td>
+        </tr>
+       {/foreach}
+    </table>
+{/if}
+{include file='admin/footer.html'}