adding ajax action for search filtering between brands and manufacturers
authorAnthony Talarico <talarico@gaslightmedia.com>
Tue, 11 Apr 2017 18:07:25 +0000 (14:07 -0400)
committerAnthony Talarico <talarico@gaslightmedia.com>
Tue, 11 Apr 2017 18:07:25 +0000 (14:07 -0400)
no logic yet, test content commented out currently.

models/admin/ajax/filterSearch.php [new file with mode: 0644]
setup/validActions.php
views/front/fields/list.html

diff --git a/models/admin/ajax/filterSearch.php b/models/admin/ajax/filterSearch.php
new file mode 100644 (file)
index 0000000..18fb75a
--- /dev/null
@@ -0,0 +1,119 @@
+<?php
+
+/**
+ * Gaslight Media Members Database
+ * Get events for a monty for AJAX call
+ *
+ * PHP version 5.5
+ *
+ * @category glmWordPressPlugin
+ * @package  glmMembersDatabase
+ * @author   Chuck Scott <cscott@gaslightmedia.com>
+ * @license  http://www.gaslightmedia.com Gaslightmedia
+ * @version  0.1
+ */
+
+// Load Event Times data abstract
+require_once GLM_MEMBERS_PLUGIN_CLASS_PATH .'/data/dataCategories.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_filterSearch extends GlmDataCategories
+{
+
+    /**
+     * WordPress Database Object
+     *
+     * @var $wpdb
+     * @access public
+     */
+    public $wpdb;
+    /**
+     * Plugin Configuration Data
+     *
+     * @var $config
+     * @access public
+     */
+    public $config;
+
+    /*
+     * Constructor
+     *
+     * This contructor 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 members data class
+        parent::__construct(false, false);
+
+    }
+        /**
+     * getModelEventsData
+     *
+     * Return the array of events.
+     *
+     * @param integer $categoryId Id of the category for filtering events (optional)
+     * @param integer $limit      Number of events to return (optional)
+     * @param integer $memberID Member ID if filtering by member
+     *
+     * @access public
+     * @return array events
+     */
+
+
+    /*
+     * Perform Model Action
+     *
+     * This modelAction takes an AJAX image upload and stores the image in the
+     * media/images directory of the plugin.
+     *
+     * This model action does not return, it simply does it's work then calls die();
+     *
+     * @param $actionData
+     *
+     * Echos JSON string as response and does not return
+     */
+    public function modelAction ($actionData = false)
+    {
+
+        global $wpdb;
+//        
+//        $category_ids    = $_REQUEST['cat_ids'];
+//        $category_names = $_REQUEST['cat_names'];
+//        
+//        // get cat ids by name
+//        foreach($category_names as $cat_name){
+//            $sql = 'SELECT id FROM ' . GLM_MEMBERS_PLUGIN_DB_PREFIX . "categories WHERE name = '$cat_name';";
+//            $cat_id = $wpdb->get_var($sql); 
+//            
+//            // get the 
+//        }
+//        
+//        
+//        $categories = $this->getListSortedParentChild();
+//        $categories = $categories[$category_id];
+        $return = array(
+//            'manufacturers'    => $category_ids, 
+//            'brands'           => $cat_id
+        );
+
+        header('Content-type:application/json;charset=utf-8', true);
+        echo json_encode($return);
+        wp_die();
+    }
+}
index 5e68202..33ebbae 100644 (file)
@@ -62,6 +62,9 @@ $glmMembersFieldsAddOnValidActions = array(
         'memberinfo' => array(
             'fields' => GLM_MEMBERS_FIELDS_PLUGIN_SLUG,
         ),
+        'ajax' => array(
+          'filterSearch' => GLM_MEMBERS_FIELDS_PLUGIN_SLUG,
+        ),
         'management' => array(
             'fields' => GLM_MEMBERS_FIELDS_PLUGIN_SLUG,
         ),
index e617edf..083107b 100644 (file)
@@ -1,6 +1,5 @@
 {foreach $field_values as $key=>$value}
     {if $value.slash === true}
-     
         <div class="glm-row field-container slash-price {if $key === 'red-hot-deal' && $value.data === 'Yes'} red-hot {/if}">
     {else}
         <div class="glm-row field-container {if $key === 'red-hot-deal' && $value.data === 'Yes'} red-hot {/if}">