delete: function(){
console.log('deleteLevel called');
+ if (this.model.attributes.reg_rate) {
+ alert('Please remove all rate entries below before deleting this level.');
+ return false;
+ }
+ if (glmSubmitRequired) {
+ alert('Please complete your other edit first.');
+ return false;
+ }
+
if (!confirm('Are you sure you want to delete this? ( *** need to check for rates *** )')) {
return false;
}
this.model.destroy({data: {
id: x,
option: 'delete'
- }, processData: true});
+ }});
this.remove();
},
},
edit: function(){
+ if (glmSubmitRequired) {
+ alert('Please complete your other edit first.');
+ return false;
+ }
console.log('edit called');
this.$('.class-display-template').hide();
this.$('.class-edit-template').show();
console.log( 'addRate Called');
+ if (glmSubmitRequired) {
+ alert('Please complete your other edit first.');
+ return false;
+ }
+
var reg_event = this.model.get('reg_event');
var reg_class = this.model.get('id');
var view = new app.Views.Admin.RegRate({
model: regRate,
});
- this.$el.append(view.render(true).el);
// Place rates inside the class-rate-container of the parent class
var rateContainer = this.$('.class-rate-container');
},
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) {
+ /*
+ * If addFlag is true then we know the call to this is to add a class
+ * and not to initialize existing rates. Note that addFLag may also
+ * be an object, which is why the explicit === below.
+ */
+ if (addFlag === true) {
+
console.log('New level created');
this.$('.class-display-template').hide();
this.$('.class-edit-template').show();
this.$('.class-name').focus();
this.newClass = true;
glmSubmitRequired += 1;
+
}
return this;
},
// Called when the view is first created
initialize: function(){
this.listenTo( this.model, 'change', this.render );
- this.listenTo( this.model.classes, 'add', this.addOne );
+/* this.listenTo( this.model.classes, 'add', this.addOne );
this.listenTo( this.model.classes, 'create', this.addOne );
this.listenTo( this.model.classes, 'reset', this.addAll );
+*/
},
events: {
addLevel: function(){
+ if (glmSubmitRequired) {
+ alert('Please complete your other edit first.');
+ return false;
+ }
+
console.log( 'addLevel Called' );
var regClass = new app.Models.Admin.RegClass({
add: function(){
-
+
console.log('add called');
var cName = this.$('.rate-name').val().trim();
-
+ var cStartDays = this.$('.rate-end-days').val().trim();
+ var cEndDays = this.$('.rate-start-days').val().trim();
+ var cBaseRate = this.$('.rate-base-rate').val().trim();
+ var cPerRegistrant = this.$('.rate-per-registrant').val().trim();
+ var cRegistrantCredits = this.$('.rate-registrant-credits').val().trim();
+
// Check for required data
if (cName == '') {
alert('The Level Name is Required!');
return;
}
- this.model.set({ name: cName });
+ this.model.set({
+ name: cName,
+ start_days: cStartDays,
+ end_days: cEndDays,
+ base_rate: cBaseRate,
+ per_registrant: cPerRegistrant,
+ registrant_credits: cRegistrantCredits
+ });
// Get parent for id to send to backend for new rate
var parentClass = this.model.get( 'parent' );
this.model.save({
wait: true,
option: 'add',
- name: cName
+ name: cName,
+ start_days: cStartDays,
+ end_days: cEndDays,
+ base_rate: cBaseRate,
+ per_registrant: cPerRegistrant,
+ registrant_credits: cRegistrantCredits
+
}).success(function(data){
if (data > 0) {
console.log('AJAX Rate Save Successful: ID = '+data);
});
glmSubmitRequired -= 1;
- console.log('New ID = '+newID);
},
delete: function() {
console.log('deleteRate called');
+
+ if (glmSubmitRequired) {
+ alert('Please complete your other edit first.');
+ return false;
+ }
// Remove rate here
var x = this.model.get('id');
this.model.destroy({data: {
id: x,
option: 'delete'
- }, processData: true});
+ }});
this.remove();
},
edit: function() {
+ if (glmSubmitRequired) {
+ alert('Please complete your other edit first.');
+ return false;
+ }
console.log('edit called');
this.$('.rate-display-template').hide();
this.$('.rate-edit-template').show();
this.$('.rate-name').focus();
glmSubmitRequired += 1;
+
},
update: function() {
console.log('update called');
var cName = this.$('.rate-name').val().trim();
- if (!this.model.save({ option: 'update', name: cName})) {
+ var cStartDays = this.$('.rate-start-days').val().trim();
+ var cEndDays = this.$('.rate-end-days').val().trim();
+ var cBaseRate = this.$('.rate-base-rate').val().trim();
+ var cPerRegistrant = this.$('.rate-per-registrant').val().trim();
+ var cRegistrantCredits = this.$('.rate-registrant-credits').val().trim();
+
+ if (!this.model.save({
+ option: 'update',
+ name: cName,
+ start_days: cStartDays,
+ end_days: cEndDays,
+ base_rate: cBaseRate,
+ per_registrant: cPerRegistrant,
+ registrant_credits: cRegistrantCredits
+ })) {
console.log('Rate Save Error');
} else {
console.log('Rate Save Successful');
},
render: function(addFlag){
+
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) {
+
+ /*
+ * If addFlag is true then we know the call to this is to add a rate
+ * and not to initialize existing rates. Note that addFLag may also
+ * be an object, which is why the explicit === below.
+ */
+ if (addFlag === true) {
+
// Setup to edit this for the first time
console.log('New rate created');
this.$('.rate-display-template').hide();
this.$('.rate-name').focus();
this.newRate = true;
glmSubmitRequired += 1;
+
}
return this;
}
delete: function(){
console.log('deleteLevel called');
+ if (this.model.attributes.reg_rate) {
+ alert('Please remove all rate entries below before deleting this level.');
+ return false;
+ }
+ if (glmSubmitRequired) {
+ alert('Please complete your other edit first.');
+ return false;
+ }
+
if (!confirm('Are you sure you want to delete this? ( *** need to check for rates *** )')) {
return false;
}
this.model.destroy({data: {
id: x,
option: 'delete'
- }, processData: true});
+ }});
this.remove();
},
},
edit: function(){
+ if (glmSubmitRequired) {
+ alert('Please complete your other edit first.');
+ return false;
+ }
console.log('edit called');
this.$('.class-display-template').hide();
this.$('.class-edit-template').show();
console.log( 'addRate Called');
+ if (glmSubmitRequired) {
+ alert('Please complete your other edit first.');
+ return false;
+ }
+
var reg_event = this.model.get('reg_event');
var reg_class = this.model.get('id');
var view = new app.Views.Admin.RegRate({
model: regRate,
});
- this.$el.append(view.render(true).el);
// Place rates inside the class-rate-container of the parent class
var rateContainer = this.$('.class-rate-container');
},
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) {
+ /*
+ * If addFlag is true then we know the call to this is to add a class
+ * and not to initialize existing rates. Note that addFLag may also
+ * be an object, which is why the explicit === below.
+ */
+ if (addFlag === true) {
+
console.log('New level created');
this.$('.class-display-template').hide();
this.$('.class-edit-template').show();
this.$('.class-name').focus();
this.newClass = true;
glmSubmitRequired += 1;
+
}
return this;
},
// Called when the view is first created
initialize: function(){
this.listenTo( this.model, 'change', this.render );
- this.listenTo( this.model.classes, 'add', this.addOne );
+/* this.listenTo( this.model.classes, 'add', this.addOne );
this.listenTo( this.model.classes, 'create', this.addOne );
this.listenTo( this.model.classes, 'reset', this.addAll );
+*/
},
events: {
addLevel: function(){
+ if (glmSubmitRequired) {
+ alert('Please complete your other edit first.');
+ return false;
+ }
+
console.log( 'addLevel Called' );
var regClass = new app.Models.Admin.RegClass({
add: function(){
-
+
console.log('add called');
var cName = this.$('.rate-name').val().trim();
-
+ var cStartDays = this.$('.rate-end-days').val().trim();
+ var cEndDays = this.$('.rate-start-days').val().trim();
+ var cBaseRate = this.$('.rate-base-rate').val().trim();
+ var cPerRegistrant = this.$('.rate-per-registrant').val().trim();
+ var cRegistrantCredits = this.$('.rate-registrant-credits').val().trim();
+
// Check for required data
if (cName == '') {
alert('The Level Name is Required!');
return;
}
- this.model.set({ name: cName });
+ this.model.set({
+ name: cName,
+ start_days: cStartDays,
+ end_days: cEndDays,
+ base_rate: cBaseRate,
+ per_registrant: cPerRegistrant,
+ registrant_credits: cRegistrantCredits
+ });
// Get parent for id to send to backend for new rate
var parentClass = this.model.get( 'parent' );
this.model.save({
wait: true,
option: 'add',
- name: cName
+ name: cName,
+ start_days: cStartDays,
+ end_days: cEndDays,
+ base_rate: cBaseRate,
+ per_registrant: cPerRegistrant,
+ registrant_credits: cRegistrantCredits
+
}).success(function(data){
if (data > 0) {
console.log('AJAX Rate Save Successful: ID = '+data);
});
glmSubmitRequired -= 1;
- console.log('New ID = '+newID);
},
delete: function() {
console.log('deleteRate called');
+
+ if (glmSubmitRequired) {
+ alert('Please complete your other edit first.');
+ return false;
+ }
// Remove rate here
var x = this.model.get('id');
this.model.destroy({data: {
id: x,
option: 'delete'
- }, processData: true});
+ }});
this.remove();
},
edit: function() {
+ if (glmSubmitRequired) {
+ alert('Please complete your other edit first.');
+ return false;
+ }
console.log('edit called');
this.$('.rate-display-template').hide();
this.$('.rate-edit-template').show();
this.$('.rate-name').focus();
glmSubmitRequired += 1;
+
},
update: function() {
console.log('update called');
var cName = this.$('.rate-name').val().trim();
- if (!this.model.save({ option: 'update', name: cName})) {
+ var cStartDays = this.$('.rate-start-days').val().trim();
+ var cEndDays = this.$('.rate-end-days').val().trim();
+ var cBaseRate = this.$('.rate-base-rate').val().trim();
+ var cPerRegistrant = this.$('.rate-per-registrant').val().trim();
+ var cRegistrantCredits = this.$('.rate-registrant-credits').val().trim();
+
+ if (!this.model.save({
+ option: 'update',
+ name: cName,
+ start_days: cStartDays,
+ end_days: cEndDays,
+ base_rate: cBaseRate,
+ per_registrant: cPerRegistrant,
+ registrant_credits: cRegistrantCredits
+ })) {
console.log('Rate Save Error');
} else {
console.log('Rate Save Successful');
},
render: function(addFlag){
+
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) {
+
+ /*
+ * If addFlag is true then we know the call to this is to add a rate
+ * and not to initialize existing rates. Note that addFLag may also
+ * be an object, which is why the explicit === below.
+ */
+ if (addFlag === true) {
+
// Setup to edit this for the first time
console.log('New rate created');
this.$('.rate-display-template').hide();
this.$('.rate-name').focus();
this.newRate = true;
glmSubmitRequired += 1;
+
}
return this;
}
array(
'reg_event' => $modelData['reg_event'],
'reg_class' => $modelData['reg_class'],
- 'name' => $modelData['name']
+ 'name' => $modelData['name'],
+ 'start_days' => $modelData['start_days'],
+ 'end_days' => $modelData['end_days']
),
array(
'%d',
'%d',
- '%s'
+ '%s',
+ '%d',
+ '%d'
)
);
$this->wpdb->update(
$this->table,
array(
- 'name' => $modelData['name']
+ 'name' => $modelData['name'],
+ 'start_days' => $modelData['start_days'],
+ 'end_days' => $modelData['end_days']
),
array('id' => $rateID),
array(
- '%s'
+ '%s',
+ '%d',
+ '%d'
),
array( '%d' )
);
----
-- Registration for a specific event
--- Has one or more reg_selected_rate records associated with it
+-- Has one or more reg_selected_rate records associated with it - *** Need to remove the account entry in this table ****
CREATE TABLE {prefix}reg_request_event (
id INT NOT NULL AUTO_INCREMENT,
- account INT NULL, -- Pointer to account (person submitting the registration)
reg_request INT NULL, -- Pointer to reg_request table
reg_event INT NULL, -- Pointer to reg_event
event_name TINYTEXT NULL, -- Name of Event so it will always be in the cart data
----
-- A particular reg_class selected
--- Has one or more reg_request_rate records associated with it
+-- Has one or more reg_request_rate records associated with it - *** Need to remove the account entry in this table ****
CREATE TABLE {prefix}reg_request_class (
id INT NOT NULL AUTO_INCREMENT,
- account INT NULL, -- Pointer to account (person submitting the registration)
reg_event INT NULL, -- Pointer to reg_event entry
event_name TINYTEXT NULL, -- Name of Event so it will always be in the cart data
reg_time INT NULL, -- Pointer to times table entry in Events add-on
----
-- A particular reg_rate selected
--- Has one or more reg_request_registrant records associated with it
+-- Has one or more reg_request_registrant records associated with it - *** Need to remove the account entry in this table ****
CREATE TABLE {prefix}reg_request_rate (
id INT NOT NULL AUTO_INCREMENT,
- account INT NULL, -- Pointer to account (person submitting the registration)
reg_event INT NULL, -- Pointer to reg_event entry
event_name TINYTEXT NULL, -- Name of Event so it will always be in the cart data
reg_time INT NULL, -- Pointer to times table entry in Events add-on
<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-delete button button-secondary glm-button-small">Delete</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 %><% } %>">
+ <b>Level Name:</b> <input class="class-name" type="text" name="name_<% if (id) { %><%- id %><% } else { %> new <% } %>" value="<% if (name) { %><%- name %><% } %>">
</div>
</div>
<b>Description:</b> <input class="class-descr" type="text" name="reg_descr_<% if (id) { %><%- id %><% } else { %> new <% } %>" size="90" value="<% if (descr) { %><%- descr %><% } %>">
</div>
<div class="glm-rate-label" style="margin-bottom: .5em;">
<h3><%= name %></h3>
+ <p>Start Days: <%= start_days %>, End Days: <%= start_days %>, Base: <%= base_rate %>. Per-Registrant: <%= per_registrant %>. Registrant Credits: <%= registrant_credits %></p>
</div>
</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</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 %><% } %>">
+ <table class="glm-admin-table">
+ <tr>
+ <th></th>
+ <td>
+ <p>
+ "Rates" are a schedule of what is paid to register for an event. Rates can change based on the number of days until the event.
+ For example, an earier registration may be less expensive than a last minute registration.
+ The start and end days for a rate must not overlap that of another rate for the same registration level.
+ The earliest "Start Days" determines the earliest date on which registration is available and the last "End Days" closest to the event determines the last date on which registration is available.
+ </p>
+ </td>
+ <tr>
+ <th style="white-space: nowrap;">Rate Name:</th>
+ <td><input class="rate-name glm-form-text-input" type="text" name="name_<% if (id) { %><%- id %><% } else { %> new <% } %>" value="<% if (name) { %><%- name %><% } %>"></td>
+ <tr>
+ <tr>
+ <th style="white-space: nowrap;">Start Days</th>
+ <td>
+ <input class="rate-start-days glm-form-text-input-veryshort" type="text" name="start_days_<% if (id) { %><%- id %><% } else { %> new <% } %>" value="<% if (start_days) { %><%- start_days %><% } %>">
+ Number of days before event that this rate starts. Must not overlap other rates.
+ </td>
+ </tr>
+ <tr>
+ <th style="white-space: nowrap;">End Days:</th>
+ <td>
+ <input class="rate-end-days glm-form-text-input-veryshort" type="text" name="end_days_<% if (id) { %><%- id %><% } else { %> new <% } %>" value="<% if (end_days) { %><%- end_days %><% } %>">
+ Number of days before event that this rate ends. Must not overlap other rates.
+ </td>
+ </tr>
+ <tr>
+ <th style="white-space: nowrap;">Cost:</th>
+ <td>
+ Base <input class="rate-base-rate glm-form-text-input-veryshort" type="text" name="base_rate_<% if (id) { %><%- id %><% } else { %> new <% } %>" value="<% if (base_rate) { %><%- base_rate %><% } %>">
+ Per-Registrant <input class="rate-per-registrant glm-form-text-input-veryshort" type="text" name="per_registrant_<% if (id) { %><%- id %><% } else { %> new <% } %>" value="<% if (per_registrant) { %><%- per_registrant %><% } %>">
+ Registrant Credits <input class="rate-registrant-credits glm-form-text-input-veryshort" type="text" name="registrant_credits_<% if (id) { %><%- id %><% } else { %> new <% } %>" value="<% if (registrant_credits) { %><%- registrant_credits %><% } %>">
+ <br>
+
+ </td>
+ </tr>
+ <b>
</div>
</div>
</div>
<div class="glm-reg-event-list" id="regApp">
</div>
+
+ <div style="border: 1px black solid; padding: .3em; background-color: white; margin-top: 4em;">
+ <h3>Things that need to be fixed</h3>
+ <ul>
+ <li>* Fields do not get focus when adding or editing.</li>
+ <li>* Need to complete edit on new entry before it's possible to delete.</li>
+ </ul>
+ </div>
+
{* Bootstrap the models needed on page load *}
{* Need to have RegEvent model created *}