--- /dev/null
+<?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
+ */
+
+require_once GLM_MEMBERS_REGISTRATIONS_PLUGIN_PATH . '/models/front/registrations/cartLinkWidget.php';
+/**
+ * Steve Note...
+ *
+ * You can get to this using the following URL.
+ *
+ * {host}/wp-admin/admin-ajax.php?action=glm_members_admin_ajax&glm_action=login
+ *
+ * You should be able to do this as POST or GET and should be able to add and read additional parameters.
+ * I added a "mystuff" parameter to the URL above and it does output from the code in the
+ * modelAction() function below.
+ *
+ * To add another model under models/admin/ajax all you need to do is create it and add it to the
+ * setup/validActions.php file.
+ *
+ */
+
+/**
+ * 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_cartLinkWidget extends GlmMembersFront_registrations_cartLinkWidget
+{
+
+ /**
+ * 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 data class
+ // parent::__construct(false, false);
+
+ }
+
+}
-{if $haveCart}
-<a href="{$cartUrl}">
- <div id="registrations-cart-link-widget" style="width: 80px; height: 75px; padding: 5px; background-color: #ffffff; border: 1px black solid; position: relative">
- <img src="{$assetUrl}/registrationBlue.svg" width="50" style="position: absolute; z-index: 1;">
- <div style="font-size: .5em; line-height: 1.1em; position: absolute; left: 14px; top: 63px; z-index: 2; font-style: italic;">REGISTRATION</div>
- <div style="font-size: .5em; line-height: 1.1em; position: absolute; left: 22px; top: 44px; z-index: 2;">
- {$numb_events} Event{if $numb_events == 0 || $numb_events > 1}s{/if}<br>
- {$numb_registrants} Registrant{if $numb_registrants == 0 || $numb_registrants > 1}s{/if}
+<div id="glm-reg-widget">
+ {if $haveCart}
+ <a href="{$cartUrl}">
+ <div id="registrations-cart-link-widget" style="width: 80px; height: 75px; padding: 5px; background-color: #ffffff; border: 1px black solid; position: relative">
+ <img src="{$assetUrl}/registrationBlue.svg" width="50" style="position: absolute; z-index: 1;">
+ <div style="font-size: .5em; line-height: 1.1em; position: absolute; left: 14px; top: 63px; z-index: 2; font-style: italic;">REGISTRATION</div>
+ <div style="font-size: .5em; line-height: 1.1em; position: absolute; left: 22px; top: 44px; z-index: 2;">
+ {$numb_events} Event{if $numb_events == 0 || $numb_events > 1}s{/if}<br>
+ {$numb_registrants} Registrant{if $numb_registrants == 0 || $numb_registrants > 1}s{/if}
+ </div>
+ </div>
+ </a>
+ {else}
+ <div id="registrations-cart-link-widget" style="width: 80px; height: 75px; padding: 5px; background-color: #f0f0f0; border: 1px black solid; position: relative">
+ <img src="{$assetUrl}/registrationBlack.svg" width="50" style="position: absolute; z-index: 2;">
+ <div style="font-size: .5em; line-height: 1.1em; position: absolute; left: 14px; top: 65px; z-index: 2; font-style: italic;">REGISTRATION</div>
+ <div style="font-size: .5em; line-height: 1.1em; position: absolute; left: 25px; top: 42px; z-index: 2;">
+ Cart<br>Empty
+ </div>
</div>
- </div>
-</a>
-{else}
-
- <div id="registrations-cart-link-widget" style="width: 80px; height: 75px; padding: 5px; background-color: #f0f0f0; border: 1px black solid; position: relative">
- <img src="{$assetUrl}/registrationBlack.svg" width="50" style="position: absolute; z-index: 2;">
- <div style="font-size: .5em; line-height: 1.1em; position: absolute; left: 14px; top: 65px; z-index: 2; font-style: italic;">REGISTRATION</div>
- <div style="font-size: .5em; line-height: 1.1em; position: absolute; left: 25px; top: 42px; z-index: 2;">
- Cart<br>Empty
- </div>
- </div>
-
-{/if}
-{if $haveOtherRequests}
-<a id='glm-cart-select-action' href="" onClick="return false;">
- <div id="registrations-cart-link-widget-requests" style="width: 80px; height: 1em; padding: 1px; background-color: #ffffff; border: 1px black solid; position: relative">
- <div style="font-size: .55em; line-height: 1.1em; position: absolute; left:3px; top: 3px; z-index: 2;">
- Select other Carts
+ {/if}
+ {if $haveOtherRequests}
+ <a id='glm-cart-select-action' href="" onClick="return false;">
+ <div id="registrations-cart-link-widget-requests" style="width: 80px; height: 1em; padding: 1px; background-color: #ffffff; border: 1px black solid; position: relative">
+ <div style="font-size: .55em; line-height: 1.1em; position: absolute; left:3px; top: 3px; z-index: 2;">
+ Select other Carts
+ </div>
+ </div>
+ </a>
+ <div id="glm-cart-select-dialog" title="Pending Registration Requests (carts)" class="glm-hidden" style="width: 100%">
+ <center>
+ <table>
+ <thead>
+ <tr><th>ID</th><th style="white-space: nowrap;">Date created</th><th style="white-space: nowrap;">Date last updated</th><th>Selected</th></tr>
+ </thead>
+ <tbody>
+ {foreach $regRequests as $rr}
+ <tr>
+ <td>
+ <a href="{$cartUrl}&cartId={$rr.id}">{$rr.id}</a>
+ </td>
+ <td style="white-space: nowrap;">{$rr.date_created.datetime}</td>
+ <td style="white-space: nowrap;">{$rr.last_update.datetime}</td>
+ <td>
+ {if $rr.id == $id}
+ Yes
+ {/if}
+ </td>
+ </tr>
+ {/foreach}
+ </tbody>
+ </table>
+ </center>
</div>
- </div>
-</a>
-<div id="glm-cart-select-dialog" title="Pending Registration Requests (carts)" class="glm-hidden" style="width: 100%">
- <center>
- <table>
- <thead>
- <tr><th>ID</th><th style="white-space: nowrap;">Date created</th><th style="white-space: nowrap;">Date last updated</th><th>Selected</th></tr>
- </thead>
- <tbody>
- {foreach $regRequests as $rr}
- <tr>
- <td>
- <a href="{$cartUrl}&cartId={$rr.id}">{$rr.id}</a>
- </td>
- <td style="white-space: nowrap;">{$rr.date_created.datetime}</td>
- <td style="white-space: nowrap;">{$rr.last_update.datetime}</td>
- <td>
- {if $rr.id == $id}
- Yes
- {/if}
- </td>
- </tr>
- {/foreach}
- </tbody>
- </table>
- </center>
-</div>
+ {/if}
+</div>
<script type="text/javascript">
- jQuery(document).ready(function($) {
+var glmWidget = {
+ updateWidget: function(){
+ // Make an ajax call and update the widget contents
+ jQuery.ajax({
+ context: this,
+ url: '{$ajaxUrl}',
+ data: { action: 'glm_members_admin_ajax', glm_action: 'cartLinkWidget' },
+ })
+ .done(function(html){
+ console.log('Call successfull');
+ jQuery('#glm-reg-widget').replaceWith(html)
+ })
+ .fail();
+ },
+};
- pendDialog = $("#glm-cart-select-action").click(function () {
- $("#glm-cart-select-dialog").dialog({
- autoOpen: true,
- resizable: false,
- modal: true,
- width: 500,
- closeText: "hide",
- buttons: {
- "Cancel": function () {
- $(this).dialog("close");
- }
- }
- });
+jQuery(document).ready(function($) {
+ pendDialog = $("#glm-cart-select-action").click(function () {
+ $("#glm-cart-select-dialog").dialog({
+ autoOpen: true,
+ resizable: false,
+ modal: true,
+ width: 500,
+ closeText: "hide",
+ buttons: {
+ "Cancel": function () {
+ $(this).dialog("close");
+ }
+ }
});
-
});
+});
</script>
-{/if}
-
-