Critical updates to Registrations System
authorChuck Scott <cscott@gaslightmedia.com>
Mon, 14 May 2018 13:22:50 +0000 (09:22 -0400)
committerChuck Scott <cscott@gaslightmedia.com>
Mon, 14 May 2018 13:22:50 +0000 (09:22 -0400)
Added time_specific to getSimpleRegEventsList() to have to reg events dashboard.
Added time_specific output to reg events dashboard list.
Fixed problem with reg event attendee totals after converting an event between time-specific and non-time-specific
Fixed problem with non-time-specific time entry not being created when switching even from time-specific to non-time-specific
Added AJAX process to display Authorize.net Verified Seal to avoid XXS complaint problem with Chrome.

classes/data/dataRegEvent.php
models/admin/ajax/getAuthorizeNetSeal.php [new file with mode: 0644]
models/admin/registrations/events_eventDashboard.php
models/admin/registrations/events_update.php
setup/validActions.php
views/admin/management/registrations.html
views/admin/registrations/eventsDashboard.html

index 4b3caf9..adc873c 100644 (file)
@@ -416,7 +416,7 @@ class GlmDataRegistrationsRegEvent extends GlmDataAbstract
         // If we're asked to get registrant counts
         if ($this->postProcAddRegistrantsCount) {
 
-            $counts = $this->getEventRegistrantCounts($result_data['id']);
+            $counts = $this->getEventRegistrantCounts($result_data['id'], $result_data['time_specific']);
 
             // If we have counts, add them to the result
             if ($counts && is_array($counts)) {
@@ -432,19 +432,36 @@ class GlmDataRegistrationsRegEvent extends GlmDataAbstract
      * Get registrant count summary for an event
      *
      * @param integer $eventId ID of the reg_event record
+     * @param boolean $time_specific Flag for time-specific event
      *
      * @return array Summary array of event counts
      *
      */
-    public function getEventRegistrantCounts($eventId = false)
+    public function getEventRegistrantCounts($eventId = false, $time_specific = false)
     {
 
+        if ($time_specific['value']) {
+trigger_error("**** Time SPecific",E_USER_NOTICE);
+            $sql = "
+                SELECT SUM(attendee_max) AS total, SUM(attendee_count) AS registered, SUM(attendees_pending) AS cartHold, SUM(attendees_available) AS curAvail
+                  FROM ".GLM_MEMBERS_REGISTRATIONS_PLUGIN_DB_PREFIX."reg_time
+                 WHERE active
+                   AND reg_event = $eventId
+                   AND non_time_specific = false
+            ";
+        } else {
+trigger_error("**** Not Time SPecific",E_USER_NOTICE);
+            $sql = "
+                SELECT SUM(attendee_max) AS total, SUM(attendee_count) AS registered, SUM(attendees_pending) AS cartHold, SUM(attendees_available) AS curAvail
+                  FROM ".GLM_MEMBERS_REGISTRATIONS_PLUGIN_DB_PREFIX."reg_time
+                 WHERE active
+                   AND reg_event = $eventId
+                   AND non_time_specific = true
+            ";
+        }
+
         // Get sum of all attendee counts
-        $countsData = $this->wpdb->get_row("
-               SELECT SUM(attendee_max) AS total, SUM(attendee_count) AS registered, SUM(attendees_pending) AS cartHold, SUM(attendees_available) AS curAvail
-               FROM ".GLM_MEMBERS_REGISTRATIONS_PLUGIN_DB_PREFIX."reg_time
-               WHERE reg_event = $eventId
-            ;", ARRAY_A);
+        $countsData = $this->wpdb->get_row($sql, ARRAY_A);
 
         $counts = array(
             'total'         => $countsData['total'],
@@ -475,7 +492,6 @@ class GlmDataRegistrationsRegEvent extends GlmDataAbstract
             'id' => $savedFields['id'],
             'event_name' => $savedFields['event_name'],
             'notify_email' => $savedFields['notify_email'],
-            'blabla' => 1,
             'descr' => $savedFields['descr'],
             'first_datetime' => $savedFields['first_datetime'],
             'last_datetime' => $savedFields['last_datetime']
@@ -642,6 +658,7 @@ class GlmDataRegistrationsRegEvent extends GlmDataAbstract
             'id' => $fSave['id'],
             'event' => $fSave['event'],
             'event_name' => $fSave['event_name'],
+            'time_specific' => $fSave['time_specific'],
             'first_datetime' => $fSave['first_datetime'],
             'last_datetime' => $fSave['last_datetime']
         );
diff --git a/models/admin/ajax/getAuthorizeNetSeal.php b/models/admin/ajax/getAuthorizeNetSeal.php
new file mode 100644 (file)
index 0000000..1b2451d
--- /dev/null
@@ -0,0 +1,83 @@
+<?php
+
+/**
+ * Gaslight Media Members Database
+ * Registration add-on admin AJAX Get Authorize.net Verified MErchqant Seal
+ *
+ * PHP version 5.5
+ *
+ * @category glmWordPressPlugin
+ * @package  glmMembersDatabase
+ * @author   Chuck Scott <cscott@gaslightmedia.com>
+ * @license  http://www.gaslightmedia.com Gaslightmedia
+ * @version  0.1
+ */
+
+class GlmMembersAdmin_ajax_getAuthorizeNetSeal
+{
+
+    /**
+     * 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);
+
+    }
+
+    /*
+     * Perform Model Action
+     *
+     * This model returns the correct code to display the Verified Merchant Seal for Authorize.net
+     *
+     * This is to avoid the XSS Auditor in Chrome
+     *
+     * @param $actionData
+     *
+     * Echos Seal Code
+     */
+    public function modelAction( $actionData = false )
+    {
+
+        $seal = $this->wpdb->get_var( "
+            SELECT reg_authorize_net_merchant_seal
+              FROM ".GLM_MEMBERS_REGISTRATIONS_PLUGIN_DB_PREFIX . "management
+             WHERE id = 1;
+        ");
+        echo html_entity_decode("<center>".$seal."<p>Click Seal to Test Verification.</p></center>");
+
+        wp_die();
+
+    }
+
+
+}
index 737d7ba..9431ba1 100644 (file)
@@ -62,5 +62,6 @@ if ($regEvent !== false) {
     }
 
 }
+// echo "<pre>".print_r($regEvent,1)."</pre>";
 
 $view = 'eventDashboard';
index bbb7453..13048a9 100644 (file)
  * @link     http://dev.gaslightmedia.com/
  */
 
+// Get the current reg event type to check for change
+$timeSpecific = $this->wpdb->get_var("
+    SELECT time_specific
+      FROM ".GLM_MEMBERS_REGISTRATIONS_PLUGIN_DB_PREFIX . "reg_event
+     WHERE id = $regEventID
+");
 
 // Try to update the reg event
 $regEvent = $this->updateEntry($regEventID);
@@ -20,6 +26,71 @@ $regEvent = $this->updateEntry($regEventID);
 // If there's some type of failure, flag that for the view file
 if ($regEvent['status']) {
     $regEventUpdated = true;
+
+    // Now check to see if the type has been changed from Time specific to Non-Time specific
+    if ($timeSpecific && !$regEvent['fieldData']['time_specific']['value']) {
+
+        // Changing to non-time=specific, so check if we need to create a time entry for that
+        $timeEntry = $this->wpdb->get_row("
+            SELECT id
+              FROM ".GLM_MEMBERS_REGISTRATIONS_PLUGIN_DB_PREFIX . "reg_time
+             WHERE reg_event = $regEventID
+               AND non_time_specific
+        ");
+
+        // If there isn't a non-time-specific time entry
+        if ($timeEntry === null) {
+
+            // Create that now
+            $this->wpdb->insert(
+                GLM_MEMBERS_REGISTRATIONS_PLUGIN_DB_PREFIX . 'reg_time',
+                array(
+                    'reg_event'             => $regEventID,
+                    'event_time'            => 0,
+                    'all_day'               => false,
+                    'attendees'             => true,
+                    'attendee_max'          => $regEvent['fieldData']['attendee_max'],
+                    'attendee_count'        => 0,
+                    'attendees_pending'     => 0,
+                    'attendees_available'   => $regEvent['fieldData']['attendee_max'],
+                    'total_base_charge'     => 0,
+                    'total_per_attendee'    => 0,
+                    'total_other'           => 0,
+                    'total_taxes'           => 0,
+                    'total_charges'         => 0,
+                    'total_discounts'       => 0,
+                    'total_payments'        => 0,
+                    'active'                => true,
+                    'non_time_specific'     => true
+                ),
+                array(
+                    '%d',
+                    '%d',
+                    '%d',
+                    '%d',
+                    '%d',
+                    '%d',
+                    '%d',
+                    '%d',
+                    '%f',
+                    '%f',
+                    '%f',
+                    '%f',
+                    '%f',
+                    '%f',
+                    '%f',
+                    '%d',
+                    '%d'
+                )
+            );
+
+            // Now get the event data again so it will have the new time entry
+            $regEvent = $this->editEntry($regEventID);
+
+        }
+    }
+
+
 } else {
     $regEventUpdateError = true;
 }
index 3443045..689fff3 100644 (file)
@@ -68,7 +68,8 @@ $glmMembersRegistrationsAddOnValidActions = array(
             'updateAvailability'        => GLM_MEMBERS_REGISTRATIONS_PLUGIN_SLUG,
             'registrantsListExport'     => GLM_MEMBERS_REGISTRATIONS_PLUGIN_SLUG,
             'setupEventRegQueue'        => GLM_MEMBERS_REGISTRATIONS_PLUGIN_SLUG,
-            'runEventRegQueue'          => GLM_MEMBERS_REGISTRATIONS_PLUGIN_SLUG
+            'runEventRegQueue'          => GLM_MEMBERS_REGISTRATIONS_PLUGIN_SLUG,
+            'getAuthorizeNetSeal'       => GLM_MEMBERS_REGISTRATIONS_PLUGIN_SLUG
         ),
         'registrations' => array(
             'index'                     => GLM_MEMBERS_REGISTRATIONS_PLUGIN_SLUG,
index 3b5db9c..58d2c54 100644 (file)
                         <tr class="authorize-net">
                             <th class="glm-nowrap-left-align{if $regSettings.fieldRequired.reg_authorize_net_merchant_seal} glm-required{/if}">Verified Merchant Seal HTML:</th>
                             <td {if $regSettings.fieldFail.reg_authorize_net_merchant_seal}class="glm-form-bad-input"{/if}>
-                                <div class="glm-left" style="width: 100px">
-                                    {$regSettings.fieldData.reg_authorize_net_merchant_seal|unescape}
-                                </div>
+                                {if $regSettings.fieldData.reg_authorize_net_merchant_seal != ''}<div><a id="verifiedAuthorizeNetMerchantSeal" class="button">Click to test Seal</a></div>{/if}
                                 <div style="max-width: 700px">
                                     This field is for HTML code that will display an authorized seal for the merchant's Authorized.net account.
                                     Once the correct HTML code is entered above, the seal should show to the left of this text. If that does not happen,
         $( document ).ready(function() {
             showSelectedCardProcessor();
         });
+
+        $('#verifiedAuthorizeNetMerchantSeal').on('click', function() {
+            var sealUrl = '{$ajaxUrl}?action=glm_members_admin_ajax&glm_action=getAuthorizeNetSeal';
+            window.open(sealUrl, '_blank', "width=300,height=200,menubar=no,scrollbars=no,location=no");
+            return false;
+        });
         
     });
 </script>
index ffc5e00..5a34b77 100644 (file)
@@ -44,6 +44,7 @@
             <tr>
                 <th>ID</th>
                 <th>{$terms.reg_term_event_cap} Name</th>
+                <th>Date Specific?</th>
                 <th>Maximum<br>{$terms.reg_term_attendee_plur_cap}</th>
                 <th>{$terms.reg_term_registered_cap}</th>
                 <th>Cart<br>Hold</th>
@@ -69,6 +70,7 @@
                 <td>
                    <a href="{$thisUrl}?page=glm-members-admin-menu-registrations-events&option=eventDashboard&regEventID={$r.id}">{$r.event_name}</a>
                 </td>
+                <td>{if $r.time_specific.value}Yes{/if}</td>
                 <td>{$r.total}</td>
                 <td>{$r.registered}</td>
                 <td>{$r.cartHold}</td>