Have admin reg events levels and rates displaying, adding, editing, saving, and storing
Still some glitches in that page.
this.rates = new app.Collections.Admin.RegRates;
},
- url: ajaxUrl+'&glm_action=regAdmin&collection=regClasses'
+ url: ajaxUrl+'&glm_action=regAdmin&collection=regClasses',
+
+ setRates: function(regRates){
+ this.rates.set(regRates);
+ }
});
},
setClasses: function( regClasses ){
- this.classes.reset( regClasses );
+ this.classes.set( regClasses );
}
});
app.Collections.Admin.RegRates = Backbone.Collection.extend({
model: app.Models.Admin.RegRate,
url: ajaxUrl+'&glm_action=regAdmin&collection=regRates'
-});
-
+});
+
// js/views/app.js
Backbone.emulateJSON = true;
Backbone.emulateHTTP = true;
initialize: function(){
this.listenTo( this.model, 'change', this.render );
+
+ // Use the reg rates sent as an attribute to the class to create the rates models
+ this.model.setRates(this.model.attributes.reg_rate);
return this;
},
delete: function(){
console.log('deleteLevel called');
-
+
+ if (!confirm('Are you sure you want to delete this? ( *** need to check for rates *** )')) {
+ return false;
+ }
+
// Remove class here
var x = this.model.get('id');
this.model.destroy({data: {
render: function(addFlag){
this.$el.html( this.template( this.model.toJSON() ) );
+ var rateView = this.model.rates.map(function(item){
+ return (new app.Views.Admin.RegRate({ model: item })).render().el;
+ });
+ var rateContainer = this.$('.class-rate-container');
+ rateContainer.append(rateView);
+
// If addFlag set then we know the call to this is to add a class and not to initialize existing classes
if (addFlag == true) {
console.log('New level created');
events: {
'click #class-add': 'addLevel',
- },
+ },
- addLevel: function(){
+ addLevel: function(){
console.log( 'addLevel Called' );
});
this.$el.append(view.render(true).el);
},
-
+
render: function(){
this.$el.html( this.template( this.model.toJSON() ) );
var view = regEvent.classes.map(function(item){
alert('There was a problem communicating with the AJAX server.');
});
+ glmSubmitRequired -= 1;
console.log('New ID = '+newID);
- glmSubmitRequired -= 1;
-
},
delete: function() {
update: function() {
console.log('update called');
var cName = this.$('.rate-name').val().trim();
- if (!this.model.save({ option: 'update', name: cName, descr: cDescr })) {
+ if (!this.model.save({ option: 'update', name: cName})) {
console.log('Rate Save Error');
} else {
console.log('Rate Save Successful');
}
this.$('.rate-display-template').show();
this.$('.rate-edit-template').hide();
- glmSubmitRequired -= 1;
+ glmSubmitRequired -= 1;
},
this.$el.html( this.template( this.model.toJSON() ) );
// If addFlag set then we know the call to this is to add a class and not to initialize existing classes
if (addFlag) {
+ // Setup to edit this for the first time
console.log('New rate created');
this.$('.rate-display-template').hide();
this.$('.rate-edit-template').show();
app.Collections.Admin.RegRates = Backbone.Collection.extend({
model: app.Models.Admin.RegRate,
url: ajaxUrl+'&glm_action=regAdmin&collection=regRates'
-});
+});
+
\ No newline at end of file
this.rates = new app.Collections.Admin.RegRates;
},
- url: ajaxUrl+'&glm_action=regAdmin&collection=regClasses'
+ url: ajaxUrl+'&glm_action=regAdmin&collection=regClasses',
+
+ setRates: function(regRates){
+ this.rates.set(regRates);
+ }
});
},
setClasses: function( regClasses ){
- this.classes.reset( regClasses );
+ this.classes.set( regClasses );
}
});
initialize: function(){
this.listenTo( this.model, 'change', this.render );
+
+ // Use the reg rates sent as an attribute to the class to create the rates models
+ this.model.setRates(this.model.attributes.reg_rate);
return this;
},
delete: function(){
console.log('deleteLevel called');
-
+
+ if (!confirm('Are you sure you want to delete this? ( *** need to check for rates *** )')) {
+ return false;
+ }
+
// Remove class here
var x = this.model.get('id');
this.model.destroy({data: {
render: function(addFlag){
this.$el.html( this.template( this.model.toJSON() ) );
+ var rateView = this.model.rates.map(function(item){
+ return (new app.Views.Admin.RegRate({ model: item })).render().el;
+ });
+ var rateContainer = this.$('.class-rate-container');
+ rateContainer.append(rateView);
+
// If addFlag set then we know the call to this is to add a class and not to initialize existing classes
if (addFlag == true) {
console.log('New level created');
events: {
'click #class-add': 'addLevel',
- },
+ },
- addLevel: function(){
+ addLevel: function(){
console.log( 'addLevel Called' );
});
this.$el.append(view.render(true).el);
},
-
+
render: function(){
this.$el.html( this.template( this.model.toJSON() ) );
var view = regEvent.classes.map(function(item){
alert('There was a problem communicating with the AJAX server.');
});
+ glmSubmitRequired -= 1;
console.log('New ID = '+newID);
- glmSubmitRequired -= 1;
-
},
delete: function() {
update: function() {
console.log('update called');
var cName = this.$('.rate-name').val().trim();
- if (!this.model.save({ option: 'update', name: cName, descr: cDescr })) {
+ if (!this.model.save({ option: 'update', name: cName})) {
console.log('Rate Save Error');
} else {
console.log('Rate Save Successful');
}
this.$('.rate-display-template').show();
this.$('.rate-edit-template').hide();
- glmSubmitRequired -= 1;
+ glmSubmitRequired -= 1;
},
this.$el.html( this.template( this.model.toJSON() ) );
// If addFlag set then we know the call to this is to add a class and not to initialize existing classes
if (addFlag) {
+ // Setup to edit this for the first time
console.log('New rate created');
this.$('.rate-display-template').hide();
this.$('.rate-edit-template').show();
// Load registration request and registration registrant data classes
require_once GLM_MEMBERS_REGISTRATIONS_PLUGIN_CLASS_PATH.'/data/dataRegRequest.php';
- $RegRequest = new GlmDataRegistrationsRequest($this->wpdb, $this->config);
+ $RegRequest = new GlmDataRegistrationsRegRequest($this->wpdb, $this->config);
require_once GLM_MEMBERS_REGISTRATIONS_PLUGIN_CLASS_PATH.'/data/dataRegRequestRegistrant.php';
$RegRequestRegistrant = new GlmDataRegistrationsRequestRegistrant($this->wpdb, $this->config);
// Separate Event, Classes, and Times and send those as separate JSONs
$regClassesJSON = json_encode($regEvent['reg_class']);
$regTimesJSON = json_encode($regEvent['reg_time']);
+// echo "<pre>".print_r($regEvent['reg_class'],1)."</pre>";
// Get rid of class and time arrays so we just have the event data
unset($regEvent['reg_class']);
--- /dev/null
+<?php
+/**
+ * Gaslight Media Members Database
+ * Admin Registrations Reports
+ *
+ * PHP version 5.5
+ *
+ * @category glmWordPressPlugin
+ * @package glmMembersDatabase
+ * @author Chuck Scott <cscott@gaslightmedia.com>
+ * @license http://www.gaslightmedia.com Gaslightmedia
+ * @release index.php,v 1.0 2014/10/31 19:31:47 cscott Exp $
+ * @link http://dev.gaslightmedia.com/
+ */
+
+class GlmMembersAdmin_registrations_reports
+{
+
+ /**
+ * WordPress Database Object
+ *
+ * @var $wpdb
+ * @access public
+ */
+ public $wpdb;
+ /**
+ * Plugin Configuration Data
+ *
+ * @var $config
+ * @access public
+ */
+ public $config;
+ /**
+ * Registrations Event ID
+ *
+ * @var $eventID
+ * @access public
+ */
+ public $accountID = false;
+
+ /**
+ * Constructor
+ *
+ * This contructor performs the work for this model. This model returns
+ * an array containing the following.
+ *
+ * 'status'
+ *
+ * True if successfull and false if there was a fatal failure.
+ *
+ * '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.
+ *
+ * @wpdb object WordPress database object
+ *
+ * @return array Array containing status, suggested view, and any data
+ */
+ public function __construct ($wpdb, $config)
+ {
+
+ // Save WordPress Database object
+ $this->wpdb = $wpdb;
+
+ // Save plugin configuration object
+ $this->config = $config;
+
+ /*
+ * Run constructor for the REgistrations data class
+ *
+ * Note, the third parameter is a flag that indicates to the Contacts
+ * data class that it should flag a group of fields as 'view_only'.
+ */
+// parent::__construct(false, false, true);
+
+ }
+
+ public function modelAction($actionData = false)
+ {
+ $view = 'reports';
+ $reason = array();
+
+ // Compile template data
+ $templateData = array(
+ 'reason' => $reason
+ );
+
+ // Return status, any suggested view, and any data to controller
+ return array(
+ 'status' => true,
+ 'modelRedirect' => false,
+ 'view' => 'admin/registrations/' . $view . '.html',
+ 'data' => $templateData
+ );
+
+ }
+
+
+}
// Load Registration Requests data abstract
require_once GLM_MEMBERS_REGISTRATIONS_PLUGIN_CLASS_PATH.'/data/dataRegRequest.php';
-class GlmMembersAdmin_registrations_requests extends GlmDataRegistrationsRequest
+class GlmMembersAdmin_registrations_requests extends GlmDataRegistrationsRegRequest
{
/**
'glm-members-admin-menu-registrations-accounts',
function() {$this->controller('registrations', 'accounts');}
);
+add_submenu_page(
+ 'glm-members-admin-menu-members',
+ 'Registration Reports',
+ ' Reports',
+ 'glm_members_members',
+ 'glm-members-admin-menu-registrations-reports',
+ function() {$this->controller('registrations', 'reports');}
+ );
'index' => GLM_MEMBERS_REGISTRATIONS_PLUGIN_SLUG,
'events' => GLM_MEMBERS_REGISTRATIONS_PLUGIN_SLUG,
'requests' => GLM_MEMBERS_REGISTRATIONS_PLUGIN_SLUG,
- 'accounts' => GLM_MEMBERS_REGISTRATIONS_PLUGIN_SLUG
+ 'accounts' => GLM_MEMBERS_REGISTRATIONS_PLUGIN_SLUG,
+ 'reports' => GLM_MEMBERS_REGISTRATIONS_PLUGIN_SLUG
),
'management' => array(
'registrations' => GLM_MEMBERS_REGISTRATIONS_PLUGIN_SLUG,
<div class="glm-class-header">
<div class="glm-right">
<a class="class-edit button button-secondary glm-button-small">Edit</a>
- <a class="class-add-rate button button-secondary glm-button-small">Add Reg Rate</a>
- <a class="class-delete button button-secondary glm-button-small">Delete Level</a>
+ <a class="class-delete button button-secondary glm-button-small">Delete</a>
+ <a class="class-add-rate button button-secondary glm-button-small">Add Rate</a>
</div>
<div class="glm-class-label">
<h3><%= name %></h3>
<div class="glm-right">
<a class="class-update button glm-button-small-highlighted">Update</a>
<a class="class-add button glm-button-small-highlighted" style="display: none;">Add</a>
- <a class="class-add-rate button button-secondary glm-button-small" style="display: none;">Add Reg Rate</a>
- <a class="class-delete button button-secondary glm-button-small">Delete Level</a>
</div>
<div class="glm-class-label" style="padding-bottom: .3em;">
<b>Level Name:</b> <input class="class-name" type="text" name="class_name_<% if (id) { %><%- id %><% } else { %> new <% } %>" value="<% if (name) { %><%- name %><% } %>">
<a class="rate-edit button button-secondary glm-button-small">Edit</a>
<a class="rate-delete button button-secondary glm-button-small">Delete Rate</a>
</div>
- <div class="glm-rate-label">
+ <div class="glm-rate-label" style="margin-bottom: .5em;">
<h3><%= name %></h3>
</div>
</div>
<div class="glm-right">
<a class="rate-update button glm-button-small-highlighted">Update</a>
<a class="rate-add button glm-button-small-highlighted" style="display: none;">Add</a>
- <a class="rate-delete button button-secondary glm-button-small">Delete Rate</a>
</div>
<div class="glm-rate-label" style="padding-bottom: .3em;">
<b>Rate Name:</b> <input class="rate-name" type="text" name="rate_name_<% if (id) { %><%- id %><% } else { %> new <% } %>" value="<% if (name) { %><%- name %><% } %>">
<tbody>
{if $haveRegEvents}
{assign var="i" value="0"}
- {foreach $regEvents as $r}z
+ {foreach $regEvents as $r}
{if $i++ is odd by 1}
<tr>
{else}
--- /dev/null
+
+<h1>Reports</h1>
+
+<p>Move along now, nothing to see here.</p>
+
+{include file='admin/footer.html'}
+