Fix conflict with same validAction ajax call as registrations.
authorSteve Sutton <steve@gaslightmedia.com>
Fri, 6 Apr 2018 15:03:53 +0000 (11:03 -0400)
committerSteve Sutton <steve@gaslightmedia.com>
Fri, 6 Apr 2018 15:03:53 +0000 (11:03 -0400)
Need to keep ajax admin call names unique.

models/admin/ajax/account.php [deleted file]
models/admin/ajax/billingAccount.php [new file with mode: 0644]
setup/validActions.php
views/admin/billing/editInvoice.html

diff --git a/models/admin/ajax/account.php b/models/admin/ajax/account.php
deleted file mode 100644 (file)
index c9347ed..0000000
+++ /dev/null
@@ -1,135 +0,0 @@
-<?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_BILLING_PLUGIN_CLASS_PATH . '/data/dataAccounts.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_account extends GlmDataAccounts
-{
-
-    /**
-     * 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;
-
-        $option = filter_var( $_REQUEST['option'], FILTER_SANITIZE_STRING );
-        trigger_error( print_r( $_REQUEST, E_USER_NOTICE ) );
-
-        switch ( $option ) {
-        case 'add':
-            $account = $this->insertEntry();
-            trigger_error( print_r( $account, E_USER_NOTICE ) );
-            if ( !$account['status'] ) {
-                $accountInsertError = true;
-                $return = $account;
-            } else {
-                // Get updated entry
-                $account = $this->getEntry( $account['fieldData']['id'] );
-                $accountAdded = true;
-                $return = array(
-                    'status'  => true,
-                    'account' => $account
-                );
-            }
-            break;
-        case 'list':
-            $accounts = $this->getList( '', 'ref_name', 'id,ref_name' );
-            $return = array();
-            foreach ( $accounts as $account ) {
-                $return[] = array(
-                    'id'   => $account['id'],
-                    'name' => htmlspecialchars_decode( $account['ref_name'] ),
-                    'ann'  => htmlspecialchars_decode( $account['next_anniversary_date'] )
-                );
-            }
-
-            break;
-        case 'listNonAccounts':
-            $nonAccountMembers = $this->wpdb->get_results(
-                "SELECT id,name
-                   FROM " . GLM_MEMBERS_PLUGIN_DB_PREFIX . "members
-                  WHERE id NOT IN (
-                        SELECT distinct ref_dest
-                          FROM " . GLM_MEMBERS_BILLING_PLUGIN_DB_PREFIX .  "accounts   )
-                ORDER BY name",
-                ARRAY_A
-            );
-            foreach ( $nonAccountMembers as $members ) {
-                $return[] = array(
-                    'id'   => $members['id'],
-                    'name' => htmlspecialchars_decode( $members['name'] ),
-                );
-            }
-            break;
-        }
-
-        header( 'Content-type:application/json;charset=utf-8', true );
-        echo json_encode( $return, true );
-        exit();
-    }
-}
diff --git a/models/admin/ajax/billingAccount.php b/models/admin/ajax/billingAccount.php
new file mode 100644 (file)
index 0000000..306d570
--- /dev/null
@@ -0,0 +1,135 @@
+<?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_BILLING_PLUGIN_CLASS_PATH . '/data/dataAccounts.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_billingAccount extends GlmDataAccounts
+{
+
+    /**
+     * 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;
+
+        $option = filter_var( $_REQUEST['option'], FILTER_SANITIZE_STRING );
+        trigger_error( print_r( $_REQUEST, E_USER_NOTICE ) );
+
+        switch ( $option ) {
+        case 'add':
+            $account = $this->insertEntry();
+            trigger_error( print_r( $account, E_USER_NOTICE ) );
+            if ( !$account['status'] ) {
+                $accountInsertError = true;
+                $return = $account;
+            } else {
+                // Get updated entry
+                $account = $this->getEntry( $account['fieldData']['id'] );
+                $accountAdded = true;
+                $return = array(
+                    'status'  => true,
+                    'account' => $account
+                );
+            }
+            break;
+        case 'list':
+            $accounts = $this->getList( '', 'ref_name', 'id,ref_name' );
+            $return = array();
+            foreach ( $accounts as $account ) {
+                $return[] = array(
+                    'id'   => $account['id'],
+                    'name' => htmlspecialchars_decode( $account['ref_name'] ),
+                    'ann'  => htmlspecialchars_decode( $account['next_anniversary_date'] )
+                );
+            }
+
+            break;
+        case 'listNonAccounts':
+            $nonAccountMembers = $this->wpdb->get_results(
+                "SELECT id,name
+                   FROM " . GLM_MEMBERS_PLUGIN_DB_PREFIX . "members
+                  WHERE id NOT IN (
+                        SELECT distinct ref_dest
+                          FROM " . GLM_MEMBERS_BILLING_PLUGIN_DB_PREFIX .  "accounts   )
+                ORDER BY name",
+                ARRAY_A
+            );
+            foreach ( $nonAccountMembers as $members ) {
+                $return[] = array(
+                    'id'   => $members['id'],
+                    'name' => htmlspecialchars_decode( $members['name'] ),
+                );
+            }
+            break;
+        }
+
+        header( 'Content-type:application/json;charset=utf-8', true );
+        echo json_encode( $return, true );
+        exit();
+    }
+}
index 7407416..d0b1626 100644 (file)
@@ -62,7 +62,7 @@ $glmMembersBillingAddOnValidActions = array(
         'ajax' => array(
             'setupQueue'         => GLM_MEMBERS_BILLING_PLUGIN_SLUG,
             'runQueue'           => GLM_MEMBERS_BILLING_PLUGIN_SLUG,
-            'account'            => GLM_MEMBERS_BILLING_PLUGIN_SLUG,
+            'billingAccount'     => GLM_MEMBERS_BILLING_PLUGIN_SLUG,
             'invoices'           => GLM_MEMBERS_BILLING_PLUGIN_SLUG,
             'invoiceTypes'       => GLM_MEMBERS_BILLING_PLUGIN_SLUG,
             'createNewInvoices'  => GLM_MEMBERS_BILLING_PLUGIN_SLUG,
index 99f4d6d..0be2545 100644 (file)
@@ -453,7 +453,7 @@ jQuery(document).ready(function($){
         if ( valid ) {
             // console.log( newAccountForm.serialize() );
             $.ajax({
-                url: '{$ajaxUrl}?action=glm_members_admin_ajax&glm_action=account&option=add',
+                url: '{$ajaxUrl}?action=glm_members_admin_ajax&glm_action=billingAccount&option=add',
                 cache: false,
                 type: 'POST',
                 data: newAccountForm.serialize(),
@@ -535,7 +535,7 @@ jQuery(document).ready(function($){
             url: '{$ajaxUrl}',
             cache: false,
             type: 'GET',
-            data: 'action=glm_members_admin_ajax&glm_action=account&option=list',
+            data: 'action=glm_members_admin_ajax&glm_action=billingAccount&option=list',
             encode: true,
             dataType: 'json'
         }).done(function(msg){
@@ -595,7 +595,7 @@ jQuery(document).ready(function($){
             url: '{$ajaxUrl}',
             cache: false,
             type: 'GET',
-            data: 'action=glm_members_admin_ajax&glm_action=account&option=listNonAccounts',
+            data: 'action=glm_members_admin_ajax&glm_action=billingAccount&option=listNonAccounts',
             encode: true,
             dataType: 'json'
         }).done(function(msg){