--- /dev/null
+<?php
+
+/**
+ * Gaslight Media Members Database
+ * Members List Export by AJAX
+ *
+ * PHP version 5.5
+ *
+ * @category glmWordPressPlugin
+ * @entity glmMembersDatabase
+ * @author Chuck Scott <cscott@gaslightmedia.com>
+ * @license http://www.gaslightmedia.com Gaslightmedia
+ * @version 0.1
+ */
+require_once GLM_MEMBERS_PLUGIN_PATH . '/controllers/admin.php';
+/**
+ *
+ * This class exports the currently selected members list
+ * to a printable HTML file, to a CSV file, or otherwise.
+ */
+class GlmMembersAdmin_ajax_memberEdit extends glmMembersAdmin
+{
+
+ /**
+ * 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;
+
+ //parent::__construct(false, false);
+
+ }
+
+ /**
+ * 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;
+ $memberID = $_REQUEST['memberID'];
+ $editData = $this->controller( 'member', 'index', array("memberID" => $memberID), true, true);
+
+ $return = array(
+ "test" => $sql,
+ 'searchData' => $editData // Where our events list will go
+ );
+
+ header('Content-type:application/json;charset=utf-8', true);
+ echo json_encode($return);
+ wp_die();
+ }
+}
<div id="edit-screen" class="edit-screen sidenav"></div>
</div>
-<script type="module">
+<script>
jQuery(function($){
- window.Glma = {
- adminSearch: function(data){
+ var Glma = (function() {
+ var xhr = function(data, complete, success, type,error){
$.ajax({
dataType: "json",
- type : 'POST',
+ type : type,
url: '{$ajaxUrl}',
data: data,
- complete: $("#glm-admin-search-overlay").fadeOut('slow'),
- success: function(data) {
- console.log(data);
- $("#glm-admin-member-list").append(data.searchData);
- }
+ complete: complete,
+ success: success,
+ error: error
});
}
- };
+ return {
+ adminSearch: function(data){
+ xhr(
+ data,
+ $("#glm-admin-search-overlay").fadeOut('slow'),
+ function(data) {
+ $("#glm-admin-member-list").append(data.searchData);
+ },
+ "POST",
+ function(error) {
+ console.log(error);
+ },
+ );
+ },
+ memberEdit: function(data){
+ xhr(
+ data,
+ function(complete) {
+
+ },
+ function(success) {
+ console.log(success);
+ $(".edit-screen").html(success.searchData);
+ },
+ "POST",
+ function(error) {
+ console.log(error);
+ },
+ );
+ }
+ }
+ })();
/*
- * Init Materialize collapsible
- */
- jQuery(function($){
- $('.collapsible').collapsible();
- $('select').formSelect();
- $('.modal').modal();
- $(".side-nav").sidenav({
- inDuration : 500,
- outDuration : 500
- });
- })
+ * Init Materialize collapsible
+ */
+
+ $('.collapsible').collapsible();
+ $('select').formSelect();
+ $('.modal').modal();
+ $(".side-nav").sidenav({
+ inDuration : 500,
+ outDuration : 500
+ });
+
/*
* Text Search Autocomplete
jQuery(function($){
let searchResults = {};
let imageUrl = `{$glmPluginMediaUrl}/images`
- let data = {
+ let listData = {
action : 'glm_members_admin_ajax',
glm_action : 'glmTextSearch',
table : textSearchData.table,
$('input#'+textSearchData.slug+'-text').autoComplete({
minChars: 1,
source: function( request, response ) {
- data.query = request;
+ listData.query = request;
$.ajax({
dataType: "json",
type : 'POST',
url: '{$ajaxUrl}',
- data: data,
+ data: listData,
success: function(data) {
console.log(data.searchData);
if(data.searchData){
}
/*
- * Date Search Widget
- */
+ * Date Search Widget
+ */
function dateSearch(dateSearchData){
jQuery(function($){
});
}
- let data = {
+ let listData = {
action : 'glm_members_admin_ajax',
glm_action : 'adminSearch',
form_action : 'list',
// fields : textSearchData.fields,
// where : textSearchData.where
}
- window.Glma.adminSearch(data);
-
+ Glma.adminSearch(listData);
+
$(".glm-admin-search-field").on("change", function(){
- console.log( $(this) );
- window.Glma.adminSearch(data);
+ Glma.adminSearch(listData);
});
$('.edit-screen').sidenav({
- inDuration : 600,
- outDuration : 600
+ inDuration : 400,
+ outDuration : 400
});
$(document).on("click",".member-record", function(){
- console.log( $(this).data("id") );
+ var editData = {
+ action : 'glm_members_admin_ajax',
+ glm_action : 'memberEdit',
+ form_action : 'index',
+ view : "index",
+ option : 'index',
+ memberID : $(this).data('id')
+ }
+
+ Glma.memberEdit(editData);
+
M.Sidenav.getInstance($('.edit-screen')[0]).open();
})
});