End of day commit
authorSteve Sutton <steve@gaslightmedia.com>
Tue, 22 May 2018 20:34:33 +0000 (16:34 -0400)
committerSteve Sutton <steve@gaslightmedia.com>
Tue, 22 May 2018 20:34:33 +0000 (16:34 -0400)
I have the list view showing the leads.
 will need to add paging and alpha sorting
I added the jqueryui tabs
 have been working on the contacts and notes tabs.
 These are done using ajax calls.
 the edit is done by just a form submit.

29 files changed:
assets/cancel.png [new file with mode: 0755]
assets/goCompany.png [new file with mode: 0755]
assets/goContact.png [new file with mode: 0755]
assets/logo.png [new file with mode: 0644]
assets/new.png [new file with mode: 0755]
assets/newLead.png [new file with mode: 0755]
assets/tlSave.png [new file with mode: 0755]
assets/travelLeads.png [new file with mode: 0755]
assets/travelToList.png [new file with mode: 0755]
classes/data/dataContacts.php [new file with mode: 0644]
classes/data/dataLeads.php [new file with mode: 0644]
classes/data/dataNotes.php [new file with mode: 0644]
config/plugin.ini
css/admin.css.save [new file with mode: 0755]
index.php
models/admin/ajax/travelContacts.php [new file with mode: 0644]
models/admin/ajax/travelNotes.php [new file with mode: 0644]
models/admin/travel/index.php [new file with mode: 0644]
setup/adminMenus.php
setup/databaseScripts/create_database_V0.0.1.sql
setup/databaseScripts/dbVersions.php
setup/validActions.php
views/admin/ajax/contacts/list.html [new file with mode: 0644]
views/admin/ajax/notes/list.html [new file with mode: 0644]
views/admin/travel/edit.html [new file with mode: 0644]
views/admin/travel/footer.html [new file with mode: 0644]
views/admin/travel/header.html [new file with mode: 0644]
views/admin/travel/index.html [new file with mode: 0644]
views/admin/travel/searchForm.html [new file with mode: 0644]

diff --git a/assets/cancel.png b/assets/cancel.png
new file mode 100755 (executable)
index 0000000..c149c2b
Binary files /dev/null and b/assets/cancel.png differ
diff --git a/assets/goCompany.png b/assets/goCompany.png
new file mode 100755 (executable)
index 0000000..79bf4ba
Binary files /dev/null and b/assets/goCompany.png differ
diff --git a/assets/goContact.png b/assets/goContact.png
new file mode 100755 (executable)
index 0000000..60a982d
Binary files /dev/null and b/assets/goContact.png differ
diff --git a/assets/logo.png b/assets/logo.png
new file mode 100644 (file)
index 0000000..ecab363
Binary files /dev/null and b/assets/logo.png differ
diff --git a/assets/new.png b/assets/new.png
new file mode 100755 (executable)
index 0000000..555b127
Binary files /dev/null and b/assets/new.png differ
diff --git a/assets/newLead.png b/assets/newLead.png
new file mode 100755 (executable)
index 0000000..184347f
Binary files /dev/null and b/assets/newLead.png differ
diff --git a/assets/tlSave.png b/assets/tlSave.png
new file mode 100755 (executable)
index 0000000..c4c1ec8
Binary files /dev/null and b/assets/tlSave.png differ
diff --git a/assets/travelLeads.png b/assets/travelLeads.png
new file mode 100755 (executable)
index 0000000..beb4ec1
Binary files /dev/null and b/assets/travelLeads.png differ
diff --git a/assets/travelToList.png b/assets/travelToList.png
new file mode 100755 (executable)
index 0000000..8f61849
Binary files /dev/null and b/assets/travelToList.png differ
diff --git a/classes/data/dataContacts.php b/classes/data/dataContacts.php
new file mode 100644 (file)
index 0000000..13d99fe
--- /dev/null
@@ -0,0 +1,181 @@
+<?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 GlmDataTravelContacts 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_TRAVEL_PLUGIN_DB_PREFIX . 'lead_contacts';
+
+        /*
+         * Table Data Fields
+         */
+
+        $this->fields = array(
+
+            'id' => array(
+                'field'     => 'id',
+                'type'      => 'integer',
+                'view_only' => true,
+                'use'       => 'a',
+            ),
+
+            'lead' => array(
+                'field'     => 'lead',
+                'type'      => 'pointer',
+                'p_table'   => GLM_MEMBERS_TRAVEL_PLUGIN_DB_PREFIX . 'leads',
+                'p_field'   => 'id',
+                'p_id'      => 'id',
+                'p_orderby' => 'lname,fname',
+                'required'  => true,
+                'use'       => 'a',
+            ),
+
+            'updated' => array(
+                'field'     => 'updated',
+                'type'      => 'datetime',
+                'required'  => true,
+                'use'       => 'a',
+            ),
+
+            'name' => array(
+                'field'     => 'name',
+                'type'      => 'text',
+                'required'  => false,
+                'use'       => 'a',
+            ),
+
+            'email' => array(
+                'field'     => 'email',
+                'type'      => 'text',
+                'required'  => false,
+                'unique'    => false,
+                'use'       => 'a',
+            ),
+
+            'phone' => array(
+                'field'     => 'phone',
+                'type'      => 'text',
+                'required'  => 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;
+    }
+
+}
diff --git a/classes/data/dataLeads.php b/classes/data/dataLeads.php
new file mode 100644 (file)
index 0000000..8aadd80
--- /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 GlmDataTravelLeads 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_TRAVEL_PLUGIN_DB_PREFIX . 'leads';
+
+        /*
+         * Table Data Fields
+         */
+
+        $this->fields = array(
+
+            'id' => array(
+                'field'     => 'id',
+                'type'      => 'integer',
+                'view_only' => true,
+                'use'       => 'a',
+            ),
+
+            'create_date' => array(
+                'field'     => 'create_date',
+                'type'      => 'date',
+                'required'  => true,
+                'use'       => 'a',
+            ),
+
+            'updated' => array(
+                'field'     => 'updated',
+                'type'      => 'datetime',
+                'required'  => true,
+                'use'       => 'a',
+            ),
+
+            'status' => array(
+                'field'     => 'status',
+                'type'      => 'list',
+                'list'      => $this->config['lead_status'],
+                'required'  => true,
+                'default'   => $this->config['lead_status_numb']['Inactive'],
+                'use'       => 'a'
+            ),
+
+            'fname' => array(
+                'field'     => 'fname',
+                'type'      => 'text',
+                'required'  => false,
+                'use'       => 'a',
+            ),
+
+            'lname' => array(
+                'field'     => 'lname',
+                'type'      => 'text',
+                'required'  => false,
+                'use'       => 'a',
+            ),
+
+            'email' => array(
+                'field'     => 'email',
+                'type'      => 'text',
+                'required'  => false,
+                'unique'    => false,
+                'use'       => 'a',
+            ),
+
+            'company' => array(
+                'field'     => 'company',
+                'type'      => 'text',
+                'required'  => false,
+                'use'       => 'a',
+            ),
+
+            'address' => array(
+                'field'     => 'address',
+                'type'      => 'text',
+                'required'  => false,
+                'use'       => 'a',
+            ),
+
+            'address2' => array(
+                'field'     => 'address2',
+                'type'      => 'text',
+                'required'  => false,
+                'use'       => 'a',
+            ),
+
+            'city' => array(
+                'field'     => 'city',
+                'type'      => 'text',
+                'required'  => false,
+                'use'       => 'a',
+            ),
+
+            'state' => array(
+                'field'     => 'state',
+                'type'      => 'list',
+                'list'      => $this->config['states'],
+                'default'   => 'MI',
+                'required'  => false,
+                'use'       => 'a',
+            ),
+
+            'zip' => array(
+                'field'     => 'zip',
+                'type'      => 'list',
+                'required'  => false,
+                'use'       => 'a',
+            ),
+
+            'phone' => array(
+                'field'     => 'phone',
+                'type'      => 'text',
+                'required'  => false,
+                'use'       => 'a',
+            ),
+
+            'fax' => array(
+                'field'     => 'fax',
+                'type'      => 'text',
+                'required'  => false,
+                'use'       => 'a',
+            ),
+
+            'website' => array(
+                'field'     => 'website',
+                'type'      => 'text',
+                'required'  => false,
+                'use'       => 'a',
+            ),
+
+            'mail_ok' => array(
+                'field'     => 'mail_ok',
+                'type'      => 'checkbox',
+                'required'  => false,
+                'use'       => 'a',
+            ),
+
+            // 'member_ok' => array(
+            //     'field'     => 'member_ok',
+            //     'type'      => 'checkbox',
+            //     'required'  => 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;
+    }
+
+}
diff --git a/classes/data/dataNotes.php b/classes/data/dataNotes.php
new file mode 100644 (file)
index 0000000..9fd55ed
--- /dev/null
@@ -0,0 +1,173 @@
+<?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 GlmDataTravelNotes 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_TRAVEL_PLUGIN_DB_PREFIX . 'lead_notes';
+
+        /*
+         * Table Data Fields
+         */
+
+        $this->fields = array(
+
+            'id' => array(
+                'field'     => 'id',
+                'type'      => 'integer',
+                'view_only' => true,
+                'use'       => 'a',
+            ),
+
+            'lead' => array(
+                'field'     => 'lead',
+                'type'      => 'pointer',
+                'p_table'   => GLM_MEMBERS_TRAVEL_PLUGIN_DB_PREFIX . 'leads',
+                'p_field'   => 'id',
+                'p_id'      => 'id',
+                'p_orderby' => 'lname,fname',
+                'required'  => true,
+                'use'       => 'a',
+            ),
+
+            'created' => array(
+                'field'     => 'created',
+                'type'      => 'date',
+                'required'  => true,
+                'use'       => 'a',
+            ),
+
+            'updated' => array(
+                'field'     => 'updated',
+                'type'      => 'datetime',
+                'required'  => true,
+                'use'       => 'a',
+            ),
+
+            'notes' => array(
+                'field'     => 'notes',
+                'type'      => 'text',
+                'required'  => 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 9222f7e..99b840b 100644 (file)
@@ -2,7 +2,13 @@
 ; Main Configuration File
 ; {descrName}
 ;
-; Place any static configuration parameters here.  
+; Place any static configuration parameters here.
 ;
 
 [common]
+
+lead_status[10] = 'Active'
+lead_status[20] = 'Inactive'
+
+lead_status_numb['Active'] = 10
+lead_status_numb['Inactive'] = 20
diff --git a/css/admin.css.save b/css/admin.css.save
new file mode 100755 (executable)
index 0000000..0cb8e47
--- /dev/null
@@ -0,0 +1,287 @@
+#travel-admin {
+       font-family: arial, sans-serif;
+       /* font-size: 13px !important; */
+       /* font-size: 1.3rem !important; */
+       margin: 0;
+       padding: 0;
+       padding-left: 40px;
+       background: url(http://www.circlemichigan.com/assets/logo.png) fixed no-repeat 1:w
+    15px 100px;
+       }
+#travel-admin a:link {
+       color: #28195e;
+       }
+#travel-admin a:visited {
+       color: #28195e;
+       }
+#travel-admin a:hover {
+       color: #000;
+       }
+#travel-admin a:active {
+       color: #28195e;
+       }
+
+/* Travel Leads style framework */
+#travel-admin .tlRounded {
+       border-radius: 5px;
+       -webkit-border-radius: 5px;
+       -moz-border-radius: 5px;
+       }
+#travel-admin .tlShadow {
+       -moz-box-shadow:inset 0 0 7px #fff,1px 1px 7px rgba(153, 153, 153, 0.2);
+       -webkit-box-shadow:inset 0 0 7px #fff,1px 1px 7px rgba(153, 153, 153, 0.2);
+       box-shadow:inset 0 0 7px #fff,1px 1px 7px rgba(153, 153, 153, 0.2);
+       }
+#travel-admin .tlBorder {
+       border: 1px solid #999;
+       }
+#travel-admin .tlTrans1 {
+       background: #fff;
+       background: rgba(255, 255, 255, .9);
+       }
+#travel-wrapper {
+       padding: 25px;
+       width: 720px;
+    min-height: 400px;
+       background: rgba(255, 255, 255, .7);
+       }
+       /* main page fieldsets */
+#fieldsets {
+       height: 1%;
+       overflow: hidden;
+       }
+#travel-admin fieldset {
+       display: block;
+       float: left;
+       margin-right: 20px;
+       height: 9em;
+    padding: 10px;
+       }
+#travel-admin fieldset:last-child {
+       margin-right: 0;
+       }
+#travel-admin fieldset p {
+       font-weight: bold;
+       font-family: Georgia, arial, sans-serif;
+       font-size: 16px;
+       font-size: 1.2rem;
+       margin: 0.5em 0;
+       }
+#findLeads div {
+       margin: 0 0 10px 0;
+       }
+#findLeads label {
+       width: 100px;
+       display: block;
+       float: left;
+       line-height: 30px;
+       }
+#travel-admin fieldset form input {
+       height: 28px;
+       padding: 0;
+       margin: 0;
+       border-width: 1px;
+       font-size: 14px;
+       font-size: 1.0rem;
+       display: block;
+       width: 99%;
+       }
+/* Buttons */
+#travel-admin .button {
+       width: 198px;
+       height: 30px;
+       text-indent: -9000px;
+       display: block;
+       cursor: pointer;
+       margin-top: 10px;
+       border-right: 1px solid #aaa;
+       border-bottom: 1px solid #aaa;
+       border-left: 1px solid #eee;
+       border-top: 1px solid #eee;
+       }
+#travel-admin .button:hover {
+       border-right: 1px solid #888;
+       border-bottom: 1px solid #888;
+       border-left:  1px solid #ccc;
+       border-top:  1px solid #ccc;
+       }
+/* Save Button */
+#travel-admin .tlSave {
+       float: right;
+       background-image: url(../assets/tlSave.png);
+       margin-right: 5px;
+       margin-top: -5px;
+       }
+#travel-admin fieldset form #leadCompanySearch {
+       background-image: url(../assets/goCompany.png);
+       }
+#travel-admin fieldset form  #leadContactSearch {
+       background-image: url(../assets/goContact.png);
+       }
+#travelToList {
+       background-image: url(../assets/travelToList.png);
+       }
+#newLead {
+       background-image: url(../assets/newLead.png);
+       }
+/* Pagination */
+
+#travel-admin .paging {
+       display: block;
+       }
+#travel-admin .paging,
+#travel-admin .business-first-letter {
+       clear: both;
+       margin: 1em 0;
+       padding: 1em 0 0 0;
+       height: 1%;
+       overflow: hidden;
+       margin-left: 2px;
+       }
+#travel-admin .business-first-letter  {
+       margin-bottom: 1em;
+       border-bottom: 1px dotted #369;
+       padding-bottom: 1em;
+       }
+#travel-admin .paging b,
+#travel-admin .business-first-letter a.curr {
+       padding: 0.2em 0.4em;
+       background: #eee;
+       border: 1px solid #9AAFE5;
+       margin-left: 0.2em;
+       display: block;
+       float: left;
+       }
+#travel-admin .paging a,
+#travel-admin .business-first-letter a {
+       margin-left: 0.2em;
+       color: #036;
+       padding: 0.2em 0.4em;
+       border: 1px solid #9AAFE5;
+       text-decoration: none;
+       background: white;
+       display: block;
+       float: left;
+       }
+#travel-admin .paging a:hover,
+#travel-admin .business-first-letter a:hover {
+       border: 1px solid #2e8d32;
+       background: #eee;
+       }
+/* Table Grid */
+#dataGrid {
+       margin: 0.5em 0 1em 0;
+       background: rgba(255, 255, 255, 0.0);
+       }
+#dataGrid, #dataGrid tr, #dataGrid th, #dataGrid td {
+       border: 1px solid #999;
+       border-collapse: collapse;
+       }
+#dataGrid th, #dataGrid td {
+       padding: 10px 20px;
+       }
+#dataGrid th {
+       background: #fff;
+       }
+#dataGrid tr:nth-child(even) {
+       background: rgba(231, 231, 231, .9);
+       }
+#dataGrid tr:nth-child(odd) {
+       background: rgba(248, 248, 248, .9);;
+       }
+#dataGrid tr:hover {
+       background: #fff;
+       cursor: pointer;
+       }
+#dataGrid a {
+       text-decoration: none;
+       color: black;
+       }
+#dataGrid th a {
+       text-decoration: underline;
+       font-family: Georgia, arial, sans-serif;
+       white-space: nowrap;
+       }
+/* Breadcrumbs */
+#breadcrumbs {
+       background: white;
+       color: #000;
+       padding: 10px 15px;
+       margin-bottom: 1em;
+       }
+#breadcrumbs i {
+       font-weight: bold;
+       font-style: normal;
+       }
+#lead-delete {
+       float: right;
+       margin-top: 10px;
+       }
+#lead-delete a {
+       margin: 5px;
+       background: red;
+       background: rgba(204, 0, 0, .4);
+       padding: 5px;
+       border: 1px solid #ccc;
+       border-radius: 5px;
+       color: white;
+       text-shadow: 1px 1px 1px #888;
+       text-decoration: none;
+       }
+#lead-delete a:hover {
+       background: red;
+       background: rgba(204, 0, 0, 1.0);
+}
+/* Overriding Form Framework */
+div.webform td {
+       font-size: 13px !important;
+       font-size: 1.3rem !important;
+       }
+div.webform table, div.webform td {
+       border: 1px solid #aaa !important;
+       }
+/* Overriding JqueryUI */
+#travel-admin .ui-state-highlight {
+       margin-bottom: .5em;
+       padding: 15px;
+       }
+#travel-admin .ui-state-highlight p {
+       margin: 0;
+       }
+#travel-admin .ui-icon {
+       float: left;
+       margin-right: .3em;
+       display: block;
+       }
+#tabs li a {
+       font-size: 13px;
+       font-size: 1.3rem;
+       }
+#travel-admin .tsLog {
+       margin: 10px 0;
+       border-top: 1px dotted #369;
+       border: 1px solid #eee;
+       height: 1%;
+       overflow: hidden;
+       }
+#travel-admin .tsLog h2 {
+       font-family: Georgia, arial, sans-serif;
+       font-size: 16px;
+       font-size: 1.6rem;
+       padding: 5px 10px;
+       background: #eee;
+       font-weight: normal;
+       margin: 0 0 1em 0 ;
+       }
+#travel-admin .tsLog p {
+       margin: 0 10px;
+       }
+#travel-admin .tlDelete {
+       display: block;
+       float: right;
+       width: 16px;
+       height: 16px;
+       background: url(assets/cancel.png) no-repeat;
+       text-indent: -9000px;
+       margin: 10px;
+       }
index c31475e..11455c0 100644 (file)
--- a/index.php
+++ b/index.php
@@ -150,16 +150,16 @@ if (is_file(GLM_MEMBERS_TRAVEL_PLUGIN_DB_SCRIPTS.'/dbVersions.php')) {
  *
  * Then add the data to the "config" array under "// Add this add-on to the add-ons array" below.
  */
-$glmMembersTravelDatabasePluginVersion = get_option('glmMembersDatabasePluginVersion');
+$glmMembersTravelDatabasePluginVersion = get_option('glmMembersTravelDbVersion');
 
 if ( $glmMembersTravelDatabasePluginVersion ) {
     // Management
-    $glmMembersTravelManagementSettings = $wpdb->get_row( "SELECT * FROM ".GLM_MEMBERS_TRAVEL_PLUGIN_DB_PREFIX."management WHERE id = 1", ARRAY_A );
-    unset($glmMembersTravelManagementSettings['id']);
+    // $glmMembersTravelManagementSettings = $wpdb->get_row( "SELECT * FROM ".GLM_MEMBERS_TRAVEL_PLUGIN_DB_PREFIX."management WHERE id = 1", ARRAY_A );
+    // unset($glmMembersTravelManagementSettings['id']);
 
     // Settings
-    $glmMembersTravelSettingsTerms = $wpdb->get_row( "SELECT * FROM ".GLM_MEMBERS_TRAVEL_PLUGIN_DB_PREFIX."settings_terms WHERE id = 1", ARRAY_A );
-    unset($glmMembersTravelSettingsTerms['id']);
+    // $glmMembersTravelSettingsTerms = $wpdb->get_row( "SELECT * FROM ".GLM_MEMBERS_TRAVEL_PLUGIN_DB_PREFIX."settings_terms WHERE id = 1", ARRAY_A );
+    // unset($glmMembersTravelSettingsTerms['id']);
 }
 
 
@@ -174,8 +174,8 @@ function glmMembersTravelRegisterAddOn($addOns) {
         'slug' => GLM_MEMBERS_TRAVEL_PLUGIN_SLUG,
         'actions' => $GLOBALS['glmMembersTravelAddOnValidActions'],
         'config' => array(
-           'settings' => $GLOBALS['glmMembersTravelManagementSettings'],
-           'terms' => $GLOBALS['glmMembersTravelSettingsTerms']
+           // 'settings' => $GLOBALS['glmMembersTravelManagementSettings'],
+           // 'terms' => $GLOBALS['glmMembersTravelSettingsTerms']
         ),
         'shortcodes' => $GLOBALS['glmMembersTravelShortcodes'],
         'shortcodesDescription' => $GLOBALS['glmMembersTravelShortcodesDescription']
diff --git a/models/admin/ajax/travelContacts.php b/models/admin/ajax/travelContacts.php
new file mode 100644 (file)
index 0000000..9bf197c
--- /dev/null
@@ -0,0 +1,108 @@
+<?php
+
+/**
+ * Gaslight Media Members Database
+ * PDF Output by admin-ajax
+ *
+ * PHP version 5.5
+ *
+ * @category glmWordPressPlugin
+ * @package  glmMembersDatabase
+ * @author   Chuck Scott <cscott@gaslightmedia.com>
+ * @license  http://www.gaslightmedia.com Gaslightmedia
+ * @version  0.1
+ */
+
+// Load Members data abstract
+require_once GLM_MEMBERS_TRAVEL_PLUGIN_CLASS_PATH . '/data/dataContacts.php';
+
+/**
+ * This class performs the work of handling images passed to it via
+ * an AJAX call that goes through the WorPress AJAX Handler.
+ *
+ */
+class GlmMembersAdmin_ajax_travelContacts extends GlmDataTravelContacts
+{
+
+    /**
+     * WordPress Database Object
+     *
+     * @var $wpdb
+     * @access public
+     */
+    public $wpdb;
+    /**
+     * Plugin Configuration Data
+     *
+     * @var $config
+     * @access public
+     */
+    public $config;
+
+    /*
+     * Constructor
+     *
+     * This constructor sets up this model. At this time that only includes
+     * storing away the WordPress data object.
+     *
+     * @return object Class object
+     *
+     */
+    public function __construct ($wpdb, $config)
+    {
+
+        // Save WordPress Database object
+        $this->wpdb = $wpdb;
+
+        // Save plugin configuration object
+        $this->config = $config;
+
+        // Run constructor for data class
+        parent::__construct(false, false);
+
+    }
+
+    /*
+     * Perform Model Action
+     *
+     * This model checks to see if the credentials passed in are correct.
+     *
+     * This model action does not return, it simply does it's work then calls die();
+     *
+     * @param $actionData
+     *
+     * Output JSON string as response and does not return
+     */
+    public function modelAction( $actionData = false )
+    {
+        $return  = false;
+        $success =  true;
+
+        $option = filter_var( $_REQUEST['option'], FILTER_SANITIZE_STRING );
+        trigger_error( print_r( $_REQUEST, E_USER_NOTICE ) );
+
+        switch ( $option ) {
+        case 'list':
+        default:
+            $lead_id = filter_var( $_REQUEST['lead_id'], FILTER_VALIDATE_INT );
+            $return  = $this->getList( "T.lead = $lead_id" );
+
+            $view = 'list.html';
+            break;
+        }
+
+        // Compile template data
+        $templateData = array(
+            'data' => $return,
+        );
+
+        // Return status, suggested view, and data to controller
+        return array(
+            'status'           => $success,
+            'menuItemRedirect' => false,
+            'modelRedirect'    => false,
+            'view'             => 'admin/ajax/contacts/'.$view,
+            'data'             => $templateData
+        );
+    }
+}
diff --git a/models/admin/ajax/travelNotes.php b/models/admin/ajax/travelNotes.php
new file mode 100644 (file)
index 0000000..693be80
--- /dev/null
@@ -0,0 +1,110 @@
+<?php
+
+/**
+ * Gaslight Media Members Database
+ * PDF Output by admin-ajax
+ *
+ * PHP version 5.5
+ *
+ * @category glmWordPressPlugin
+ * @package  glmMembersDatabase
+ * @author   Chuck Scott <cscott@gaslightmedia.com>
+ * @license  http://www.gaslightmedia.com Gaslightmedia
+ * @version  0.1
+ */
+
+// Load Members data abstract
+require_once GLM_MEMBERS_TRAVEL_PLUGIN_CLASS_PATH . '/data/dataNotes.php';
+
+/**
+ * This class performs the work of handling images passed to it via
+ * an AJAX call that goes through the WorPress AJAX Handler.
+ *
+ */
+class GlmMembersAdmin_ajax_travelNotes extends GlmDataTravelNotes
+{
+
+    /**
+     * WordPress Database Object
+     *
+     * @var $wpdb
+     * @access public
+     */
+    public $wpdb;
+    /**
+     * Plugin Configuration Data
+     *
+     * @var $config
+     * @access public
+     */
+    public $config;
+
+    /*
+     * Constructor
+     *
+     * This constructor sets up this model. At this time that only includes
+     * storing away the WordPress data object.
+     *
+     * @return object Class object
+     *
+     */
+    public function __construct ($wpdb, $config)
+    {
+
+        // Save WordPress Database object
+        $this->wpdb = $wpdb;
+
+        // Save plugin configuration object
+        $this->config = $config;
+
+        // Run constructor for data class
+        parent::__construct(false, false);
+
+    }
+
+    /*
+     * Perform Model Action
+     *
+     * This model checks to see if the credentials passed in are correct.
+     *
+     * This model action does not return, it simply does it's work then calls die();
+     *
+     * @param $actionData
+     *
+     * Output JSON string as response and does not return
+     */
+    public function modelAction( $actionData = false )
+    {
+        $return  = false;
+        $success =  true;
+
+        $option = isset($_REQUEST['option']) ? filter_var( $_REQUEST['option'], FILTER_SANITIZE_STRING ) : '';
+        trigger_error( print_r( $_REQUEST, E_USER_NOTICE ) );
+
+        switch ( $option ) {
+        case 'list':
+        default:
+            $lead_id = filter_var( $_REQUEST['lead_id'], FILTER_VALIDATE_INT );
+            $notes  = $this->getList( "T.lead = $lead_id" );
+
+            $view = 'list.html';
+            break;
+        }
+
+        // Compile template data
+        $templateData = array(
+            'lead_id'  => $lead_id,
+            'notes'    => $notes,
+            'editPage' => 'glm-members-admin-menu-glm-travel',
+        );
+
+        // Return status, suggested view, and data to controller
+        return array(
+            'status'           => $success,
+            'menuItemRedirect' => false,
+            'modelRedirect'    => false,
+            'view'             => 'admin/ajax/notes/'.$view,
+            'data'             => $templateData
+        );
+    }
+}
diff --git a/models/admin/travel/index.php b/models/admin/travel/index.php
new file mode 100644 (file)
index 0000000..819d733
--- /dev/null
@@ -0,0 +1,503 @@
+<?php
+/**
+ * Gaslight Media Member Leads Database
+ * Leads search, list, edit page
+ *
+ * PHP version 5.5
+ *
+ * @category glmWordPressPlugin
+ * @package  glmMembersDatabase
+ * @author   Chuck Scott <cscott@gaslightmedia.com>
+ * @license  http://www.gaslightmedia.com Gaslightmedia
+ * @release  index.php,v 1.0 2014/10/31 19:31:47 cscott Exp $
+ * @link     http://dev.gaslightmedia.com/
+ */
+
+// Load Leads data abstract
+require_once GLM_MEMBERS_TRAVEL_PLUGIN_CLASS_PATH.'/data/dataLeads.php';
+require_once GLM_MEMBERS_TRAVEL_PLUGIN_CLASS_PATH . '/data/dataContacts.php';
+require_once GLM_MEMBERS_TRAVEL_PLUGIN_CLASS_PATH . '/data/dataNotes.php';
+
+class GlmMembersAdmin_travel_index extends GlmDataTravelLeads
+{
+
+    /**
+     * WordPress Database Object
+     *
+     * @var $wpdb
+     * @access public
+     */
+    public $wpdb;
+    /**
+     * Plugin Configuration Data
+     *
+     * @var $config
+     * @access public
+     */
+    public $config;
+
+    public $entryId = false;
+    /*
+     * Constructor
+     *
+     * This contructor performs the work for this model. This model returns
+     * an array containing the following.
+     *
+     * 'status'
+     *
+     * True if successfull and false if there was a fatal failure.
+     *
+     * 'view'
+     *
+     * A suggested view name that the contoller should use instead of the
+     * default view for this model or false to indicate that the default view
+     * should be used.
+     *
+     * 'data'
+     *
+     * Data that the model is returning for use in merging with the view to
+     * produce output.
+     *
+     * @wpdb object WordPress database object
+     *
+     * @return array Array containing status, suggested view, and any data
+     */
+    public function __construct ($wpdb, $config)
+    {
+
+        // Save WordPress Database object
+        $this->wpdb = $wpdb;
+
+        // Save plugin configuration object
+        $this->config = $config;
+
+        /*
+         * Run constructor for the data class
+         *
+         * Note, the third parameter is a flag that indicates to the
+         * data class that it should flag a group of fields as 'view_only'.
+         */
+        parent::__construct(false, false, true);
+
+
+    }
+
+    public function modelAction($actionData = false)
+    {
+        $where               = ' true ';
+        $option              = false;
+        $user_can_edit_leads = false;
+        $wpUser              = $this->config['loggedInUser']['wpUser'];
+        $search_id           = false;
+        $numbDisplayed       = false;
+        $lastDisplayed       = false;
+        $paging              = true;
+        $prevStart           = false;
+        $nextStart           = false;
+        $start               = 1;
+        $limit               = 20;        // Set to the number of listings per page
+        $haveLeads           = false;
+        $leadCount           = 0;
+        $addingLead          = false;
+        $searching           = false;
+        $updating            = false;
+        $updating_error      = false;
+        $inserting           = false;
+        $inserting_error     = false;
+        $groups              = false;
+        $sources             = false;
+        $entry               = false;
+        $hasSearch           = false;
+
+        // Get any provided option
+        if ( isset( $_REQUEST['option'] ) ) {
+            $option = $_REQUEST['option'];
+        }
+
+        if ( isset( $_REQUEST['glm_action'] ) && $_REQUEST['glm_action'] === 'csvExport' ) {
+            $search = true;
+            $option = 'csv';
+        }
+
+        // Get entry ID if supplied
+        if (isset($_REQUEST['id'])) {
+
+            // Make sure it's numeric
+            $this->entryId = ( $_REQUEST['id'] - 0 );
+
+            if ( $this->entryId <= 0 ) {
+                $this->entryId = false;
+            }
+
+        }
+
+        // Check for a search being done.
+        if ( isset( $_REQUEST['search'] ) ) {
+            $search = filter_var( $_REQUEST['search'], FILTER_VALIDATE_BOOLEAN);
+        }
+        if ( isset( $_REQUEST['back'] ) ) {
+            $back = filter_var( $_REQUEST['back'], FILTER_VALIDATE_BOOLEAN);
+            if ( $back ) {
+                $searching = true;
+            }
+        }
+
+        if ( isset( $this->config['loggedInUser']['contactUser'] ) && empty( $this->config['loggedInUser']['contactUser'] ) ) {
+            $user_can_edit_leads = true;
+        }
+
+        if ( ( isset( $search ) && $search ) || isset( $search_params ) && $search_params ) {
+            if ( isset( $search ) && $search ) {
+                $searching = true;
+            }
+            // Filter the $_POST variables from the search form.
+            // Verify mm/dd/YYYY date format for the from and to dates.
+            if ( !isset( $search_params ) ) {
+                $search_params = filter_var_array(
+                    $_POST,
+                    array(
+                        'source_id' => FILTER_VALIDATE_INT,
+                        'company'   => FILTER_SANITIZE_STRING,
+                        'contact'   => FILTER_SANITIZE_STRING,
+                        'from_date' => array(
+                            'filter'  => FILTER_VALIDATE_REGEXP,
+                            'options' => array(
+                                'regexp' => '%([0-9]{2})/([0-9]{2})/([0-9]{4})%'
+                            )
+                        ),
+                        'to_date' => array(
+                            'filter'  => FILTER_VALIDATE_REGEXP,
+                            'options' => array(
+                                'regexp' => '%([0-9]{2})/([0-9]{2})/([0-9]{4})%'
+                            )
+                        ),
+                        'mail_ok'   => FILTER_VALIDATE_BOOLEAN,
+                        'member_ok' => FILTER_VALIDATE_BOOLEAN,
+                        'interests' => array(
+                            'filter' => FILTER_VALIDATE_BOOLEAN,
+                            'flags'  => FILTER_FORCE_ARRAY
+                        )
+                    )
+                );
+            }
+            // checking the booleans for empty or false
+            if ( isset( $_REQUEST['mail_ok'] ) && $_REQUEST['mail_ok'] === '0' ) {
+                $search_params['mail_ok'] = (int)0;
+            }
+            if ( isset( $_REQUEST['member_ok'] ) && $_REQUEST['member_ok'] === '0' ) {
+                $search_params['member_ok'] = (int)0;
+            }
+
+
+            // build the $where part
+            $where_parts = array();
+            if ( isset( $search_params['member_ok'] ) && $search_params['member_ok'] !== false ) {
+                $member_ok = ( $search_params['member_ok'] === true ) ? 'true' : 'false';
+                $where_parts[] = "T.lead_id IN (
+                    SELECT id
+                      FROM " . GLM_MEMBERS_LEADS_PLUGIN_DB_PREFIX . "leads
+                     WHERE member_ok = $member_ok)";
+            }
+            if ( isset( $search_params['mail_ok'] ) && $search_params['mail_ok'] !== false ) {
+                $mail_ok = ( $search_params['mail_ok'] === true ) ? 'true' : 'false';
+                $where_parts[] = "T.lead_id IN (
+                    SELECT id
+                      FROM " . GLM_MEMBERS_LEADS_PLUGIN_DB_PREFIX . "leads
+                     WHERE mail_ok = $mail_ok)";
+            }
+            if ( isset( $this->config['loggedInUser']['contactUser'] ) && !empty( $this->config['loggedInUser']['contactUser'] ) ) {
+                $where_parts[] = "T.lead_id IN (
+                    SELECT id
+                      FROM " . GLM_MEMBERS_LEADS_PLUGIN_DB_PREFIX . "leads
+                     WHERE member_ok = true)";
+            } else {
+                $user_can_edit_leads = true;
+            }
+            if ( $search_params['source_id'] ) {
+                $where_parts[] = "source_id = {$search_params['source_id']}";
+            }
+            if ( $search_params['company'] ) {
+                $where_parts[] = "org = '" . esc_sql( $search_params['company'] ) . "'";
+            }
+            if ( $search_params['contact'] ) {
+                // Search for name.
+                // Could be in these formats:
+                // fname lname
+                // lname, fname
+                // lname fname
+                // lname
+                // fname
+                $name_parts   = array();
+                $name_parts[] = "SOUNDEX(CONCAT_WS(' ', fname, lname)) = SOUNDEX( '" . esc_sql( $search_params['contact'] ) . "')";
+                $name_parts[] = "SOUNDEX(CONCAT_WS(' ', lname, fname)) = SOUNDEX( '" . esc_sql( $search_params['contact'] ) . "')";
+                $name_parts[] = "SOUNDEX(fname) = SOUNDEX( '" . esc_sql( $search_params['contact'] ) . "')";
+                $name_parts[] = "SOUNDEX(lname) = SOUNDEX( '" . esc_sql( $search_params['contact'] ) . "')";
+                $where_parts[]  = implode( ' OR ', $name_parts );
+            }
+            if ( $search_params['interests'] ) {
+                /*
+                 * Search for the interest.
+                 * Checks the tables for lead_interests.
+                 */
+                // $where_parts[] = " T.id IN (
+                //     SELECT lead_entry_id
+                //       FROM " . GLM_MEMBERS_LEADS_PLUGIN_DB_PREFIX . "lead_interests
+                //      WHERE interest_id IN ( " . implode( ", ", array_keys( $search_params['interests'] ) ) . " ) ) ";
+            }
+            if ( $search_params['from_date'] && $search_params['to_date'] ) {
+                /*
+                 * We get a date from the form in mm/dd/YYYY format.
+                 * Here in mysql we reformat the date using STR_TO_DATE function.
+                 */
+                $where_parts[] = "T.date_submitted BETWEEN STR_TO_DATE('{$search_params['from_date']}', '%m/%d/%Y') "
+                    . "AND STR_TO_DATE('{$search_params['to_date']}', '%m/%d/%Y')";
+            } else if ( $search_params['from_date'] ) {
+                $where_parts[] = "T.date_submitted >= STR_TO_DATE('{$search_params['from_date']}', '%m/%d/%Y')";
+            } else  if ( $search_params['to_date'] ) {
+                $where_parts[] = "T.date_submitted <= STR_TO_DATE('{$search_params['to_date']}', '%m/%d/%Y')";
+            }
+            if ( ( isset( $search ) && $search ) || $searching ) {
+                if ( isset( $where_parts ) && !empty( $where_parts ) ) {
+                    $where .= ' AND ' . implode( ' AND ', $where_parts );
+                }
+                $order = "T.lname, T.fname";
+
+                // Check if we're doing paging
+                if (isset($_REQUEST['pageSelect'])) {
+
+                    // If request is for Next
+                    if ( isset( $_REQUEST['pageSelect'][0] ) && $_REQUEST['pageSelect'][0] == 'N') {
+                        $newStart = $_REQUEST['nextStart'] - 0;
+
+                    // Otherwise it must be Previous
+                    } else {
+                        $newStart = $_REQUEST['prevStart'] - 0;
+                    }
+
+                    if ($newStart > 0) {
+                        $start = $newStart;
+                    }
+                }
+
+                // Get count of members listed
+                $leadCount = $this->getStats($where);
+
+                // If the number of members is less than a page, don't do paging
+                if ($leadCount <= $limit) {
+                    $paging = false;
+                }
+
+
+                switch ( $option ) {
+                case 'csv':
+                    // $sql = "
+                    //   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;
+                default:
+                    $listResult = $this->getSimpleEntriesList( $where, $order, true, 'id', $start, $limit );
+                    // Get paging results
+                    $numbDisplayed = $listResult['returned'];
+                    $lastDisplayed = $listResult['last'];
+                    if ($start == 1) {
+                        $prevStart = false;
+                    } else {
+                        $prevStart = $start - $limit;
+                        if ($start < 1) {
+                            $start = 1;
+                        }
+                    }
+                    if ($listResult['returned'] == $limit) {
+                        $nextStart = $start + $limit;
+                    }
+
+                    // since we're doing paging, we have to break out just the member data
+                    $leads = $listResult['list'];
+                    //echo '<pre>$leads: ' . print_r( $leads, true ) . '</pre>';
+                    //exit;
+                    unset($listResult);
+
+                    // If we have list entries - even if it's an empty list
+                    break;
+                }
+                $success   = true;
+                $haveLeads = false;
+                if ($leads !== false) {
+
+                    $success = true;
+
+                    // If we have any entries
+                    if (count($leads) > 0) {
+                        $haveLeads = true;
+                    }
+                }
+
+
+
+            } else {
+                $leads = false;
+            }
+        } else {
+            $leads = '';
+            $search_params = array(
+                'mail_ok'   => null,
+                'member_ok' => null,
+                'company'   => '',
+                'contact'   => '',
+                'from_date' => '',
+                'to_date'   => '',
+                'interests' => array(),
+            );
+        }
+
+        // Initialize the interests array
+        $interests = array();
+
+        // Initialize the grouped_interests array
+        $grouped_interests = array();
+
+        switch ( $option ) {
+        case 'addLog':
+            echo '<pre>$_REQUEST: ' . print_r( $_REQUEST, true ) . '</pre>';
+
+            $this->wpdb->insert(
+                GLM_MEMBERS_TRAVEL_PLUGIN_DB_PREFIX . 'lead_notes',
+                array(
+                    'lead'    => $this->entryId,
+                    'created' => date( 'Y-m-d' ),
+                    'updated' => date( 'Y-m-d' ),
+                    'notes'   => filter_var( $_REQUEST['new_log'], FILTER_SANITIZE_STRING )
+                ),
+                array(
+                    '%d',
+                    '%s',
+                    '%s',
+                    '%s'
+                )
+            );
+
+            $entry = $this->editEntry( $this->entryId );
+            $view = 'edit.html';
+            break;
+        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>';
+            }
+            $entry = $this->getList();
+            $view = 'index.html';
+            break;
+
+        case 'update':
+            $updating = true;
+            if ( $this->config['loggedInUser']['contactUser'] ) {
+                break;
+            }
+            $entry = $this->updateEntry( $this->entryId );
+            $view = 'index.html';
+
+            break;
+
+        case 'edit':
+            if ( $this->config['loggedInUser']['contactUser'] ) {
+                break;
+            }
+            // Get the record for this Entry.
+            $entry = $this->editEntry( $this->entryId );
+
+            // Use the edit view file.
+            $view = 'edit.html';
+
+            break;
+
+        case 'insert':
+            $inserting = true;
+
+            // Setup the create date and update date
+            $_REQUEST['create_date'] = date('Y-m-d');
+            $_REQUEST['updated'] = date('Y-m-d H:i');
+
+            $lead = $this->insertEntry();
+
+            // echo '<pre>$lead: ' . print_r( $lead, true ) . '</pre>';
+
+            if ( $lead['status'] ) {
+                // Then goto edit page.
+                $entry = $lead;
+
+            } else {
+                // There's an error.
+                $inserting_error = true;
+            }
+
+            $view = 'edit.html';
+            break;
+
+        case 'add':
+            if ( $this->config['loggedInUser']['contactUser'] ) {
+                break;
+            }
+            $entry = $this->newEntry();
+            $addingLead = true;
+
+            // Use the edit view file.
+            $view = 'edit.html';
+
+            break;
+
+        default:
+
+            $entry = $this->getList();
+
+            // echo '<pre>$entry: ' . print_r( $entry, true ) . '</pre>';
+
+            $view = 'index.html';
+
+            break;
+        }
+
+        // Enqueue the scripts for jqueryui
+        wp_enqueue_script( 'jquery-ui-tabs' );
+        wp_enqueue_style( 'jquery-ui-smoothness', 'https://code.jquery.com/ui/1.12.1/themes/smoothness/jquery-ui.min.css' );
+
+        // Common things to place into the $templateData array
+        $templateData = array(
+            'hasSearch'       => $hasSearch,
+            'lead'            => $entry,
+            'haveLeads'       => $haveLeads,
+            'leadCount'       => $leadCount,
+            'numbDisplayed'   => $numbDisplayed,
+            'lastDisplayed'   => $lastDisplayed,
+            'prevStart'       => $prevStart,
+            'nextStart'       => $nextStart,
+            'prev'            => ( isset( $_REQUEST['prevStart'] ) ? $_REQUEST['prevStart'] : ''),
+            'next'            => ( isset( $_REQUEST['nextStart'] ) ? $_REQUEST['nextStart'] : ''),
+            'pageSelect'      => ( isset( $_REQUEST['pageSelect'] ) ? $_REQUEST['pageSelect'] : ''),
+            'start'           => $start,
+            'limit'           => $limit,
+            'paging'          => $paging,
+            'searching'       => $searching,
+            'updating'        => $updating,
+            'updating_error'  => $updating_error,
+            'inserting'       => $inserting,
+            'inserting_error' => $inserting_error,
+        );
+
+
+        // Return status, any suggested view, and any data to controller
+        return array(
+            'status'        => true,
+            'modelRedirect' => false,
+            'view'          => 'admin/travel/' . $view,
+            'data'          => $templateData
+        );
+
+    }
+
+}
index d2decd2..793b4a4 100644 (file)
  *
  */
 
+// Add Travel leads sub-menu for GLM Members Members (admins)
+add_submenu_page(
+    'glm-members-admin-menu-members',
+    'Travel Leads',
+    'Travel Leads',
+    'glm_members_members',
+    'glm-members-admin-menu-glm-travel',
+    function(){$this->controller('travel');}
+);
+
+// If a contact is logged in (ownEntity isn't false), add Contact Profile menu item
+if ( isset( $this->config['loggedInUser']['contactUser'] ) && $this->config['loggedInUser']['contactUser'] ) {
+    // Check for the option GLM_MEMBERS_LEADS_PLUGIN_MEMBER_ACCESS_OPTION
+    // $memberCanAccessLeads = get_option( GLM_MEMBERS_LEADS_PLUGIN_MEMBER_ACCESS_OPTION );
+    // if ( $memberCanAccessLeads ) {
+        add_submenu_page(
+            $mainMenuSlug,
+            'Leads',
+            'Leads',
+            'glm_members_edit_my_entity',
+            'glm-members-admin-menu-travel-index',
+            function() {$this->controller('travel');}
+        );
+    // }
+}
index 1fc8b5a..a4cf815 100644 (file)
@@ -14,8 +14,10 @@ CREATE TABLE {prefix}leads (
     id INT NOT NULL AUTO_INCREMENT,
     status INT NOT NULL DEFAULT 0,      -- Lead Status (active, inactive)
     create_date DATE NOT NULL,          -- Date contact was created
+    updated DATETIME NOT NULL,          -- Updated Timestamp
     fname TEXT NULL,                    -- First Name
     lname TEXT NULL,                    -- Last Name
+    email TINYTEXT NULL,                -- Email
     company TEXT NULL,                  -- Company Name
     address TEXT NULL,                  -- Address
     address2 TEXT NULL,                 -- Address 2
@@ -57,10 +59,11 @@ CREATE TABLE {prefix}referredby (
 ----
 
 -- Lead Notes
-CREATE TABLE {prefix}lead_notes
+CREATE TABLE {prefix}lead_notes (
     id INT NOT NULL AUTO_INCREMENT,
     lead INT NOT NULL,                  -- Reference to lead table
     created DATETIME NOT NULL,          -- Created Timestamp
+    updated DATETIME NOT NULL,          -- Updated Timestamp
     notes TEXT,                         -- Note Entry
     PRIMARY KEY (id),
     INDEX(lead)
@@ -72,25 +75,10 @@ CREATE TABLE {prefix}lead_notes
 CREATE TABLE {prefix}lead_contacts (
     id INT NOT NULL AUTO_INCREMENT,
     lead INT NOT NULL,                  -- Reference to lead table
+    updated DATETIME NOT NULL,          -- Updated Timestamp
     name TINYTEXT,                      -- Name of Contact
     email TINYTEXT,                     -- Email of Contact
     phone TINYTEXT,                     -- Phone of Contact
     PRIMARY KEY (id),
     INDEX(lead)
 );
-
-----
-
--- Management
-CREATE TABLE {prefix}management (
-    id INT NOT NULL AUTO_INCREMENT,
-    PRIMARY KEY (id)
-);
-
-----
-
--- settings_terms
-CREATE TABLE {prefix}settings_terms (
-    id INT NOT NULL AUTO_INCREMENT,
-    PRIMARY KEY (id)
-);
index f271145..1a972c5 100644 (file)
@@ -25,7 +25,7 @@
  * again and the proper number of tables that should
  * exist with that version.
  */
-$glmMembersDbVersions = array(
+$glmMembersTravelDbVersions = array(
     '0.0.1' => array('version' => '0.0.1', 'tables' => 5, 'date' => '05/18/18'),
 );
 
index f132376..89159c2 100644 (file)
 
 $glmMembersTravelAddOnValidActions = array(
     'adminActions' => array(
+        'ajax' => array(
+            'travelContacts' => GLM_MEMBERS_TRAVEL_PLUGIN_SLUG,
+            'travelInterest' => GLM_MEMBERS_TRAVEL_PLUGIN_SLUG,
+            'travelNotes'    => GLM_MEMBERS_TRAVEL_PLUGIN_SLUG,
+        ),
+        'travel' => array(
+            'index' => GLM_MEMBERS_TRAVEL_PLUGIN_SLUG,
+        )
     ),
     'frontActions' => array(
     )
 );
 
-?>
\ No newline at end of file
+?>
diff --git a/views/admin/ajax/contacts/list.html b/views/admin/ajax/contacts/list.html
new file mode 100644 (file)
index 0000000..5a3487a
--- /dev/null
@@ -0,0 +1,16 @@
+
+<form action="{$ajaxUrl}">
+    <fieldset>
+        <legend>Add New Contact</legend>
+        <label>
+            Name <input type="text" name="name" value="">
+        </label>
+        <label>
+            Phone <input type="tel" name="phone" value="">
+        </label>
+        <label>
+            Email <input type="email" name="email" value="">
+        </label>
+        <input class="button" type="submit" value="Add Contact" >
+    </fieldset>
+</form>
diff --git a/views/admin/ajax/notes/list.html b/views/admin/ajax/notes/list.html
new file mode 100644 (file)
index 0000000..78c2420
--- /dev/null
@@ -0,0 +1,14 @@
+<form id="addLog" action="{$adminUrl}?page={$editPage}">
+    <input type="hidden" name="glm_action" value="index" />
+    <input type="hidden" name="id" value="{$lead_id}" />
+    <input type="hidden" name="page" value="{$editPage}" />
+    <input type="hidden" name="option" value="addLog" />
+    <textarea name="new_log"></textarea>
+    <input type="submit" class="button" value="New Note Entry" />
+</form>
+
+{foreach $notes as $n}
+    <div>
+        {$n.notes}
+    </div>
+{/foreach}
diff --git a/views/admin/travel/edit.html b/views/admin/travel/edit.html
new file mode 100644 (file)
index 0000000..d788d19
--- /dev/null
@@ -0,0 +1,177 @@
+{include file='admin/travel/header.html'}
+
+<h2>Lead</h2>
+{if isset($lead.fieldData) && isset($lead.fieldData.id)}
+<div id="lead-delete">
+    <a
+        class="button"
+        onclick="return confirm('This will delete this lead and cannot be undone. Are You Sure?');"
+        href="{$thisUrl}?page={$thisPage}&glm_action=index&option=delete&id={$lead.fieldData.id}">Delete Contact</a>
+</div>
+{/if}
+
+<div id="tabs" style="max-width: 600px;">
+
+    <ul>
+        <li><a href="#tabs-1">Lead</a></li>
+        {if isset($lead.fieldData) && isset($lead.fieldData.id)}
+            <li><a href="{$ajaxUrl}?action=glm_members_admin_ajax&glm_action=travelContacts&lead_id={$lead.fieldData.id}">Contacts</a></li>
+            <li><a href="{$ajaxUrl}?action=glm_members_admin_ajax&glm_action=travelInterests&lead_id={$lead.fieldData.id}">Interest</a></li>
+            <li><a href="{$ajaxUrl}?action=glm_members_admin_ajax&glm_action=travelNotes&lead_id={$lead.fieldData.id}">Notes</a></li>
+        {/if}
+    </ul>
+
+    <div id="tabs-1">
+        <form action="{$thisUrl}?page={$thisPage}" method="post">
+            <input type="hidden" name="page" value="{$thisPage}" />
+            <input type="hidden" name="glm_action" value="index" />
+            {if isset($lead.fieldData) && isset($lead.fieldData.id)}
+                <input type="hidden" name="option" value="update" />
+                <input type="hidden" name="id" value="{$lead.fieldData.id}" />
+            {else}
+                <input type="hidden" name="option" value="insert" />
+            {/if}
+
+            <table id="glm-table-desc" class="glm-admin-table glm-event-table">
+
+                <tr>
+                    <td {if $lead.fieldRequired.status}class="glm-required"{/if}>Status:</td>
+                    <td {if $lead.fieldFail.status}class="glm-form-bad-input" data-tabid="glm-travel-status"{/if}>
+                        <select name="status">
+                        {foreach from=$lead.fieldData.status.list item=v}
+                            <option value="{$v.value}"{if $v.default} selected{/if}>{$v.name}</option>
+                        {/foreach}
+                        </select>
+                        {if $lead.fieldFail.status}<p>{$lead.fieldFail.status}</p>{/if}
+                    </td>
+                </tr>
+
+                <tr>
+                    <td {if $lead.fieldRequired.company}class="glm-required"{/if}>Company:</td>
+                    <td {if $lead.fieldFail.company}class="glm-form-bad-input" data-tabid="glm-travel-company"{/if}>
+                        <input type="text" name="company" value="{$lead.fieldData.company}" class="glm-form-text-input">
+                        {if $lead.fieldFail.company}<p>{$lead.fieldFail.company}</p>{/if}
+                    </td>
+                </tr>
+
+                <tr>
+                    <td {if $lead.fieldRequired.fname}class="glm-required"{/if}>First Name:</td>
+                    <td {if $lead.fieldFail.fname}class="glm-form-bad-input" data-tabid="glm-travel-fname"{/if}>
+                        <input type="text" name="fname" value="{$lead.fieldData.fname}" class="glm-form-text-input">
+                        {if $lead.fieldFail.fname}<p>{$lead.fieldFail.fname}</p>{/if}
+                    </td>
+                </tr>
+
+                <tr>
+                    <td {if $lead.fieldRequired.lname}class="glm-required"{/if}>Last Name:</td>
+                    <td {if $lead.fieldFail.lname}class="glm-form-bad-input" data-tabid="glm-travel-lname"{/if}>
+                        <input type="text" name="lname" value="{$lead.fieldData.lname}" class="glm-form-text-input">
+                        {if $lead.fieldFail.lname}<p>{$lead.fieldFail.lname}</p>{/if}
+                    </td>
+                </tr>
+
+                <tr>
+                    <td {if $lead.fieldRequired.address}class="glm-required"{/if}>Address:</td>
+                    <td {if $lead.fieldFail.address}class="glm-form-bad-input" data-tabid="glm-travel-address"{/if}>
+                        <input type="text" name="address" value="{$lead.fieldData.address}" class="glm-form-text-input">
+                        {if $lead.fieldFail.address}<p>{$lead.fieldFail.address}</p>{/if}
+                    </td>
+                </tr>
+
+                <tr>
+                    <td {if $lead.fieldRequired.address2}class="glm-required"{/if}>Address 2:</td>
+                    <td {if $lead.fieldFail.address2}class="glm-form-bad-input" data-tabid="glm-travel-address2"{/if}>
+                        <input type="text" name="address2" value="{$lead.fieldData.address2}" class="glm-form-text-input">
+                        {if $lead.fieldFail.address2}<p>{$lead.fieldFail.address2}</p>{/if}
+                    </td>
+                </tr>
+
+                <tr>
+                    <td {if $lead.fieldRequired.city}class="glm-required"{/if}>City:</td>
+                    <td {if $lead.fieldFail.city}class="glm-form-bad-input" data-tabid="glm-travel-city"{/if}>
+                        <input type="text" name="city" value="{$lead.fieldData.city}" class="glm-form-text-input">
+                        {if $lead.fieldFail.city}<p>{$lead.fieldFail.city}</p>{/if}
+                    </td>
+                </tr>
+
+                <tr>
+                    <td {if $lead.fieldRequired.state}class="glm-required"{/if}>State/Province:</td>
+                    <td {if $lead.fieldFail.state}class="glm-form-bad-input" data-tabid="glm-travel-state"{/if}>
+                        <select name="state">
+                        {foreach from=$lead.fieldData.state.list item=v}
+                            <option value="{$v.value}"{if $v.default} selected{/if}>{$v.name}</option>
+                        {/foreach}
+                        </select>
+                        {if $lead.fieldFail.state}<p>{$lead.fieldFail.state}</p>{/if}
+                    </td>
+                </tr>
+
+                <tr>
+                    <td {if $lead.fieldRequired.zip}class="glm-required"{/if}>ZIP/Postal Code:</td>
+                    <td {if $lead.fieldFail.zip}class="glm-form-bad-input" data-tabid="glm-travel-zip"{/if}>
+                        <input type="text" name="zip" value="{$lead.fieldData.zip}" class="glm-form-text-input">
+                        {if $lead.fieldFail.zip}<p>{$lead.fieldFail.zip}</p>{/if}
+                    </td>
+                </tr>
+
+                <tr>
+                    <td {if $lead.fieldRequired.email}class="glm-required"{/if}>Email:</td>
+                    <td {if $lead.fieldFail.email}class="glm-form-bad-input" data-tabid="glm-travel-email"{/if}>
+                        <input type="text" name="email" value="{$lead.fieldData.email}" class="glm-form-text-input">
+                        {if $lead.fieldFail.email}<p>{$lead.fieldFail.email}</p>{/if}
+                    </td>
+                </tr>
+
+                <tr>
+                    <td {if $lead.fieldRequired.phone}class="glm-required"{/if}>Phone:</td>
+                    <td {if $lead.fieldFail.phone}class="glm-form-bad-input" data-tabid="glm-travel-phone"{/if}>
+                        <input type="text" name="phone" value="{$lead.fieldData.phone}" class="glm-form-text-input">
+                        {if $lead.fieldFail.phone}<p>{$lead.fieldFail.phone}</p>{/if}
+                    </td>
+                </tr>
+
+                <tr>
+                    <td {if $lead.fieldRequired.fax}class="glm-required"{/if}>Fax:</td>
+                    <td {if $lead.fieldFail.fax}class="glm-form-bad-input" data-tabid="glm-travel-fax"{/if}>
+                        <input type="text" name="fax" value="{$lead.fieldData.fax}" class="glm-form-text-input">
+                        {if $lead.fieldFail.fax}<p>{$lead.fieldFail.fax}</p>{/if}
+                    </td>
+                </tr>
+
+                <tr>
+                    <td {if $lead.fieldRequired.website}class="glm-required"{/if}>Website:</td>
+                    <td {if $lead.fieldFail.website}class="glm-form-bad-input" data-tabid="glm-travel-website"{/if}>
+                        <input type="text" name="website" value="{$lead.fieldData.website}" class="glm-form-text-input">
+                        {if $lead.fieldFail.website}<p>{$lead.fieldFail.website}</p>{/if}
+                    </td>
+                </tr>
+
+                <tr>
+                    <td colspan="2">
+                        <input class="button" type="submit" value="Save" >
+                    </td>
+                </tr>
+
+            </table>
+
+        </form>
+    </div>
+
+</div>
+
+<script>
+    jQuery( function($) {
+        $('#tabs').tabs({
+            ajaxOptions: {
+                cache: false,
+                error: function( xhr, status, index, anchor ) {
+                    $( anchor.hash ).html(
+                        "Couldn't load this tab. We'll try to fix this as soon as possible."
+                    );
+                }
+            }
+        });
+    });
+</script>
+
+{include file='admin/travel/footer.html'}
diff --git a/views/admin/travel/footer.html b/views/admin/travel/footer.html
new file mode 100644 (file)
index 0000000..ebc6381
--- /dev/null
@@ -0,0 +1,2 @@
+    </div>
+</div>
diff --git a/views/admin/travel/header.html b/views/admin/travel/header.html
new file mode 100644 (file)
index 0000000..201b1e2
--- /dev/null
@@ -0,0 +1,3 @@
+<div id="wrap">
+    <h1>Travel Leads</h1>
+    <div id="glm-admin-content-container" style="max-width: 1200px;">
diff --git a/views/admin/travel/index.html b/views/admin/travel/index.html
new file mode 100644 (file)
index 0000000..e746ccf
--- /dev/null
@@ -0,0 +1,31 @@
+{include file='admin/travel/header.html'}
+
+{include file='admin/travel/searchForm.html'}
+
+
+<table class="wp-list-table widefat fixed posts glm-admin-table">
+    <thead>
+        <tr>
+            <th>Edit</th>
+            <th>Company</th>
+            <th>First Name</th>
+            <th>Last Name</th>
+            <th>Updated</th>
+            <th>Status</th>
+        </tr>
+    </thead>
+    <tbody>
+        {foreach $lead as $e}
+        <tr>
+            <td> <a href="{$thisUrl}?page={$thisPage}&glm_action=index&option=edit&id={$e.id}">Edit</a></td>
+            <td> {$e.company} </td>
+            <td> {$e.fname} </td>
+            <td> {$e.lname} </td>
+            <td> {$e.updated.datetime} </td>
+            <td> {$e.status.name} </td>
+        </tr>
+        {/foreach}
+    </tbody>
+</table>
+
+{include file='admin/travel/footer.html'}
diff --git a/views/admin/travel/searchForm.html b/views/admin/travel/searchForm.html
new file mode 100644 (file)
index 0000000..cbfd15d
--- /dev/null
@@ -0,0 +1,30 @@
+{if $hasSearch}
+<div id="breadcrumbs" class="tlShadow tlBorder tlRounded tlTrans1">
+       <a href="leads.php">Home</a> &gt; Search Result
+</div>
+{/if}
+       <div id="fieldsets">
+<fieldset id="findCompany" class="tlRounded tlShadow tlBorder tlTrans1">
+       <p>Find Company</p>
+       <form name="companyForm" id="">
+               <div>
+                       <input id="company" name="companySearch">
+                       <input type="submit" value="Go" id="leadCompanySearch" class="button">
+               </div>
+       </form>
+</fieldset>
+<fieldset class="tlRounded tlShadow tlBorder tlTrans1">
+       <p>Find Contact</p>
+       <form name="contactForm">
+               <div>
+                       <input id="contact" name="contact">
+                       <input type="submit" value="Go" id="leadContactSearch" class="button">
+               </div>
+       </form>
+</fieldset>
+<fieldset class="tlRounded tlShadow tlBorder tlTrans1">
+       <p>Quick Links</p>
+       <a href="{$thisUrl}?page={$thisPage}&glm_action=index&option=add" id="newLead" class="button">New Lead</a>
+</fieldset>
+</div><!-- /#fieldsets -->
+