Using basic event Amenities template for payment code settings page.
Note: the payment_ref_type is not recognised as the page will warn.
Also not sure yet what to use instead of 'name'. Data Abstract has
a comment of "Name of field" by field 'Amount'?
'use' => 'a'
),
- // Field description / explantion
+ // Field description / explanation
'descr' => array (
'field' => 'descr',
'type' => 'text',
--- /dev/null
+<?php
+
+/**
+ * Gaslight Media Members Database
+ * Admin Registration Payment Codes
+ *
+ * PHP version 5.5
+ *
+ * @category glmWordPressPlugin
+ * @package glmMembersDatabase
+ * @author Chuck Scott <cscott@gaslightmedia.com>
+ * @license http://www.gaslightmedia.com Gaslightmedia
+ * @version 0.1
+ */
+
+// Load Amenities data abstract
+require_once GLM_MEMBERS_REGISTRATIONS_PLUGIN_CLASS_PATH.'/data/dataPaymentCode.php';
+
+/*
+ * This class performs the work for the default action of the "Members" menu
+ * option, which is to display the members dashboard.
+ *
+ */
+class GlmMembersAdmin_settings_registrationsPaymentCode extends GlmDataRegistrationsPaymentCode
+{
+
+ /**
+ * WordPress Database Object
+ *
+ * @var $wpdb
+ * @access public
+ */
+ public $wpdb;
+ /**
+ * Plugin Settings 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 );
+
+ }
+
+ /*
+ * Perform Model Action
+ *
+ * This method does the work for this model and returns any resulting data
+ *
+ * @return array Status and data array
+ *
+ * 'status'
+ *
+ * True if successfull and false if there was a fatal failure.
+ *
+ * 'menuItemRedirect'
+ *
+ * If not false, provides a menu item the controller should
+ * execute after this one. Normally if this is used, there would also be a
+ * modelRedirect value supplied as well.
+ *
+ * 'modelRedirect'
+ *
+ * If not false, provides an action the controller should execute after
+ * this one.
+ *
+ * 'view'
+ *
+ * A suggested view name that the contoller should use instead of the
+ * default view for this model or false to indicate that the default view
+ * should be used.
+ *
+ * 'data'
+ *
+ * Data that the model is returning for use in merging with the view to
+ * produce output.
+ *
+ */
+ public function modelAction ( $actionData = false )
+ {
+ $success = true;
+ $havePaymentCode = false;
+ $payment_codes = false;
+ $error = false;
+ $option2 = '';
+ $newPaymentCode = $this->newEntry();
+ $enable_members = $this->config['settings']['enable_members'];
+
+ // Check if a category ID is supplied
+ $id = 0;
+ if ( isset( $_REQUEST['id'] ) ) {
+ $id = $_REQUEST['id'] - 0;
+ }
+ // If there's an action option
+ if ( isset( $_REQUEST['option'] ) ) {
+ switch( $_REQUEST['option'] ) {
+ case 'addNew':
+ $return = $this->insertEntry();
+ $id = $return['fieldData']['id'];
+ break;
+
+ case 'update':
+ if ( $id > 0 ) {
+ $this->updateEntry( $id );
+ }
+ break;
+
+ case 'delete':
+ if ( $id > 0 ) {
+ $this->deleteEntry( $id, true );
+ }
+ break;
+
+ default:
+ $option2 = false;
+ break;
+
+ }
+ }
+ if ( isset( $_REQUEST['option2'] ) ) {
+ $option2 = $_REQUEST['option2'];
+ }
+ // Get a current list of payment_codes
+ $payment_codes = $this->getList();
+
+ if ( GLM_MEMBERS_PLUGIN_ADMIN_DEBUG_VERBOSE ) {
+ glmMembersAdmin::addNotice( $payment_codes, 'DataBlock', 'Payment Code Data' );
+ }
+ // If we have list entries - even if it's an empty list
+ $success = true;
+ $havePaymentCode = false;
+ if ( $payment_codes !== false ) {
+
+ $success = true;
+
+ // If we have any entries
+ if ( count( $payment_codes ) > 0 ) {
+ $havePaymentCode = true;
+ }
+ }
+ // If we had a fatal error, redirect to the error page
+ if ($error) {
+ return array(
+ 'status' => $success,
+ 'menuItemRedirect' => 'error',
+ 'modelRedirect' => 'index',
+ 'view' => 'admin/error/index.html',
+ 'data' => false,
+ );
+ }
+
+ if (GLM_MEMBERS_PLUGIN_ADMIN_DEBUG_VERBOSE) {
+ glmMembersAdmin::addNotice( $payment_codes, 'DataBlock', 'Payment Code Data' );
+ }
+ // Compile template data
+ $templateData = array(
+ 'enable_members' => $enable_members,
+ 'havePaymentCode' => $havePaymentCode,
+ 'payment_codes' => $payment_codes,
+ 'groups' => null,
+ 'option2' => $option2,
+ 'newPaymentCode' => $newPaymentCode,
+ );
+
+ // Return status, suggested view, and data to controller
+ return array(
+ 'status' => $success,
+ 'menuItemRedirect' => false,
+ 'modelRedirect' => false,
+ 'view' => 'admin/settings/registrationsPaymentCode.html',
+ 'data' => $templateData,
+ );
+
+ }
+
+
+}
);
}
+
+ add_filter('glm-member-db-add-tab-for-settings',
+ function($addOnTabs) {
+ $newTabs = array(
+ array(
+ 'text' => 'Registrations',
+ 'menu' => 'settings',
+ 'action' => 'registrationsPaymentCode'
+ ),
+
+ );
+ $addOnTabs = array_merge($addOnTabs, $newTabs);
+ return $addOnTabs;
+ }
+ );
}
\ No newline at end of file
'registrations' => GLM_MEMBERS_REGISTRATIONS_PLUGIN_SLUG,
'regterms' => GLM_MEMBERS_REGISTRATIONS_PLUGIN_SLUG,
),
+ 'settings' => array(
+ 'registrationsPaymentCode' => GLM_MEMBERS_REGISTRATIONS_PLUGIN_SLUG,
+ ),
),
'frontActions' => array(
)
+++ /dev/null
-<h2 class="nav-tab-wrapper" style="margin-bottom: 1em;">
-
- <input type="hidden" name="glm_action" value="general">
-
-
- <a id="glm-settings" data-show-table="glm-table-general" href="{$thisUrl}?page=glm-members-admin-menu-management&glm_action=registrations"
- class="glm-settings-tab nav-tab{if $option2=='registrations'} nav-tab-active{/if}">
- General
- </a>
-
- <a id="glm-settings" data-show-table="glm-table-terms" href="{$thisUrl}?page=glm-members-admin-menu-management&glm_action=regterms"
- class="glm-settings-tab nav-tab{if $option2=='regterms' }{/if}">
- Terms
- </a>
-
- <a id="glm-settings" data-show-table="glm-table-payment-codes" href="{$thisUrl}?page=glm-members-admin-menu-management&glm_action=regpaymentcodes"
- class="glm-settings-tab nav-tab{if $option2=='regpaymentcodes' }{/if}">
- Payment Codes
- </a>
-
-</h2>
-<h3>Registrations Payment Codes</h3>
-
- <form action="{$thisUrl}?page={$thisPage}" method="post" enctype="multipart/form-data">
- <input type="hidden" name="glm_action" value="regpaymentcodes">
- <input type="hidden" name="option" value="submit">
-
- <table class="glm-admin-table">
-
- <!-- Admin Menus -->
-
- <tr><td colspan="2"><h2>Admin Menu and Tab Names</h2></td></tr>
-
- <tr>
- <th>Registration:</th>
- <td>
- <table class="glm-admin-table">
- <tr>
- <th>Code Type:</th>
- <td>
- <select id="default-state" data-id="code_type" class="location-address" name="code_type">
- <option value=""></option>
- {foreach from=$paymentCodeSettings.fieldData.code_type.list item=v}
- <option value="{$v.value}"{if $v.default} selected="selected"{/if}>
- {$v.name}
- </option>
- {/foreach}
- </select>
- </td>
- </tr>
- <tr>
- <th>Ref Type:</th>
- <td>
- <select id="default-state" data-id="ref_type" class="location-address" name="ref_type">
- <option value=""></option>
- {foreach from=$paymentCodeSettings.fieldData.ref_type.list item=v}
- <option value="{$v.value}"{if $v.default} selected="selected"{/if}>
- {$v.name}
- </option>
- {/foreach}
- </select>
- </td>
- </tr>
- <tr>
- <th {if $paymentCodeSettings.fieldRequired.code}class="glm-required"{/if}>Payment Code:</th>
- <td {if $paymentCodeSettings.fieldFail.code}class="glm-form-bad-input"{/if}>
- <input type="text" name="code" value="{$paymentCodeSettings.fieldData.code}" class="glm-form-text-input-medium">
- {if $paymentCodeSettings.fieldFail.code}<p>{$paymentCodeSettings.fieldFail.code}</p>{/if}
- </td>
- </tr>
- <tr>
- <th {if $paymentCodeSettings.fieldRequired.amount}class="glm-required"{/if}>Name of Field / Prompt:</th>
- <td {if $paymentCodeSettings.fieldFail.amount}class="glm-form-bad-input"{/if}>
- <input type="text" name="amount" value="{$paymentCodeSettings.fieldData.amount}" class="glm-form-text-input-medium">
- {if $paymentCodeSettings.fieldFail.amount}<p>{$paymentCodeSettings.fieldFail.amount}</p>{/if}
- </td>
- </tr>
- <tr>
- <th {if $paymentCodeSettings.fieldRequired.descr}class="glm-required"{/if}>Field Description / Explanation:</th>
- <td {if $paymentCodeSettings.fieldFail.descr}class="glm-form-bad-input"{/if}>
- <input type="text" name="descr" value="{$paymentCodeSettings.fieldData.descr}" class="glm-form-text-input-medium">
- {if $paymentCodeSettings.fieldFail.descr}<p>{$paymentCodeSettings.fieldFail.descr}</p>{/if}
- </td>
- </tr>
-
- </table>
- <input type="submit" value="Update Settings" class="button button-primary">
- </form>
-{include file='admin/footer.html'}
--- /dev/null
+{include file='admin/settings/header.html'}
+
+<h2 class="nav-tab-wrapper" style="margin-bottom: 1em;">
+ <a id="glm-payment-codes-list" data-show-table="glm-table-registrations-payment-code" class="glm-settings-tab nav-tab nav-tab-active">Registration Payment Codes List</a>
+</h2>
+
+<table id="glm-table-registrations-payment-code" class="glm-admin-table glm-settings-table{if $option2!=''} glm-hidden{/if}" style="width: 90%;">
+ <tr><td colspan="2">
+ <!-- Add Registration Payment Code Button and Dialog Box -->
+ <div id="newPaymentCodeButton" class="button button-primary glm-right">Add Payment Code</div>
+ <div id="newPaymentCodeDialog" class="glm-dialog-box" title="Enter a New Payment Code">
+ <form action="{$thisUrl}?page={$thisPage}" method="post" enctype="multipart/form-data">
+ <input type="hidden" name="glm_action" value="registrationsPaymentCode">
+ <input type="hidden" name="option" value="addNew">
+
+ <!-- This is only temporary until we reinstate the "Used With" selection below -->
+ <table class="glm-admin-table">
+ <tr>
+ <th class="glm-required">Payment Code Name:</th>
+ <td>
+ <input type="text" name="name" class="glm-form-text-input">
+ </td>
+ </tr>
+ </table>
+ <p><span class="glm-required">*</span> Required</p>
+ <a id="newPaymentCodeCancel" class="button button-primary glm-right">Cancel</a>
+ <input type="submit" value="Add new Payment Code" class="button button-primary">
+
+ </form>
+ </div>
+
+ <!-- Delete Registration Payment Code Button -->
+ <div id="deletePaymentCodeDialog" class="glm-dialog-box" title="Delete Payment Code">
+ <center>
+ <p>Are you sure you want to delete this Payment Code?</p>
+ <p><div id="deletePaymentCodeConfirm" class="button button-primary">Yes, delete this Payment Code</div></p>
+ <p><div id="deletePaymentCodeCancel" class="button button-primary">Cancel</div></p>
+ </center>
+ </div>
+
+ <!-- Edit Registration Payment Code Dialog Box -->
+ <div id="editPaymentCodeDialog" class="glm-dialog-box" title="Edit this Payment Code">
+ <form action="{$thisUrl}?page={$thisPage}" method="post" enctype="multipart/form-data">
+ <input type="hidden" name="glm_action" value="registrationsPaymentCode">
+ <input type="hidden" name="option" value="update">
+ <input id="editPaymentCodeID" type="hidden" name="id" value="">
+
+ <!-- This is only temporary until we reinstate the "Used With" selection below -->
+ <table class="glm-admin-table">
+ <tr>
+ <th class="glm-required">Payment Code Name:</th>
+ <td>
+ <input id="editPaymentCodeName" type="text" name="name" class="glm-form-text-input">
+ </td>
+ </tr>
+ </table>
+ <p><span class="glm-required">*</span> Required</p>
+ <a id="editPaymentCodeCancel" class="button button-primary glm-right">Cancel</a>
+ <input type="submit" value="Update this Payment Code">
+
+ </form>
+ </div>
+
+
+ <h2 style="clear:both;">Registration Payment Codes</h2>
+
+ <table class="wp-list-table wideFat fixed posts glm-admin-table" style="width: 90%;">
+ <thead>
+ <tr>
+ <th>Payment Code</th>
+ <th> </th>
+ </tr>
+ </thead>
+ <tbody>
+ {if $havePaymentCode}
+ {assign var="i" value="0"}
+ {foreach $payment_codes as $p}
+ {if $i++ is odd by 1}
+ <tr>
+ {else}
+ <tr class="alternate">
+ {/if}
+ <td>
+ <a class="editPaymentCode" data-amenityID="{$p.id}" data-amenityUsesValue="{$p.uses_value.value}">{$p.name}</a>
+ </td>
+ <td>
+ <div class="deletePaymentCodeButton button button-secondary glm-button-small glm-right" data-amenityID="{$p.id}">Delete</div>
+ </td>
+ </tr>
+ {/foreach}
+ {else}
+ <tr class="alternate"><td colspan="2">(no payment codes listed)</td></tr>
+ {/if}
+ </tbody>
+ </table>
+ </tr>
+</table>
+
+<script type="text/javascript">
+ jQuery(document).ready(function($) {
+
+ $("#newPaymentCodeDialog").dialog({
+ autoOpen: false,
+ minWidth: 400,
+ dialogClass: "glm-dialog-no-close"
+ });
+ $("#editPaymentCodeDialog").dialog({
+ autoOpen: false,
+ minWidth: 400,
+ dialogClass: "glm-dialog-no-close"
+ });
+ $("#deletePaymentCodeDialog").dialog({
+ autoOpen: false,
+ minWidth: 400,
+ dialogClass: "glm-dialog-no-close"
+ });
+
+ $('#newPaymentCodeButton').click( function() {
+ $("#newPaymentCodeDialog").dialog("open");
+ });
+ $('.editPaymentCode').click( function() {
+ var amenityID = $(this).attr('data-amenityID');
+ var amenityName = $(this).text();
+ var amenityUsesValue = parseInt($(this).attr('data-amenityUsesValue'));
+ var amenityDescr = $('#editPaymentCodeDescr_' + amenityID).html();
+ var amenityShortDescr = $('#editPaymentCodeShortDescr_' + amenityID).html();
+ $('#editPaymentCodeID').val(amenityID);
+ $('#editPaymentCodeName').val(amenityName.trim());
+ $('#editPaymentCodeUsesValue').prop('checked', amenityUsesValue);
+ $('.amenityGroup').each(function(){
+ $(this).prop('checked', false);
+ });
+ $('.amenitySearch').each(function(){
+ $(this).prop('checked', false);
+ });
+ $("#editPaymentCodeDialog").dialog("open");
+ });
+ $('#editPaymentCodeCancel').click( function() {
+ $("#editPaymentCodeDialog").dialog("close");
+ });
+ $('#newPaymentCodeCancel').click( function() {
+ $("#newPaymentCodeDialog").dialog("close");
+ });
+
+ var id = false;
+ $('.deletePaymentCodeButton').click( function() {
+ id = $(this).attr('data-amenityID');
+ $("#deletePaymentCodeDialog").dialog("open");
+ });
+ $('#deletePaymentCodeConfirm').click( function() {
+ $("#deletePaymentCodeDialog").dialog("close");
+ window.location.href = "{$thisUrl}?page={$thisPage}&glm_action=eventAmenities&option=delete&id=" + id;
+ });
+ $('#deletePaymentCodeCancel').click( function() {
+ $("#deletePaymentCodeDialog").dialog("close");
+ });
+
+ /*
+ * Edit area tabs
+ */
+ $('.glm-settings-tab').click( function() {
+
+ // Clear tabl highlights and hide all tables
+ $('.glm-settings-tab').removeClass('nav-tab-active');
+ $('.glm-settings-table').addClass('glm-hidden');
+
+ // Highlight selected tab
+ $(this).addClass('nav-tab-active');
+
+ // Show selected table
+ var table = $(this).attr('data-show-table');
+ $('#' + table).removeClass('glm-hidden');
+
+ });
+
+ });
+</script>
+
+{include file='admin/footer.html'}
\ No newline at end of file