reg_rate_base_price: '',
reg_rate_per_reg: '',
reg_count: 0,
+ loggedIn: false,
},
initialize: function(){
template: _.template( jQuery('#eventReg-registrant-add').html() ),
events: {
- 'click .add-new-registrant': 'addNew',
+ //'click .add-new-registrant': 'addNew',
},
initialize: function(){
},
render: function(){
- console.log( loginAccount );
if ( loginAccount === '' ) {
- console.log( 'hide called for .glm-add-account' );
this.$('.glm-add-account').hide();
}
this.model.set({ reg_count: this.model.registrants.length });
'click .addRegistrant': 'newEntry',
'click .glm-add-account': 'addAccount',
'click .glm-add-new-account': 'addNewAccount',
+ 'click .add-new-registrant': 'addNew',
},
addAccount: function(){
}
}
},
+ addNew: function(){
+ console.log( 'called addNew in regClass view' );
+ var fname = this.$('.reg_fname').val().trim();
+ var lname = this.$('.reg_lname').val().trim();
+ var email = this.$('.reg_email').val().trim();
+ console.log( 'email: ' + email + ' fname: ' + fname + ' lname: ' + lname );
+ var regRequest = cart.get( 'request' );
+ this.model.registrants.create({
+ option: 'add',
+ reg_request: regRequest.id,
+ reg_event: this.model.get( 'reg_event' ),
+ reg_class: this.model.get( 'id' ),
+ reg_rate: this.model.get( 'reg_rate_id' ),
+ email: email,
+ });
+ this.newRegAccount.destroy();
+ this.newRegAccountView.remove();
+ },
addNewAccount: function(){
- console.log( 'Add New Account Called' )
+ console.log( 'Add New Account Called' );
+ // Create the new Registrant View
+ this.newRegAccount = new app.Models.Front.RegRequestRegistrant();
+ this.newRegAccountView = new app.Views.Front.NewRegistrant({model: this.newRegAccount});
+ this.$el.append( this.newRegAccountView.render().el );
},
toggleClassOpen: function(){
reg_rate_base_price: '',
reg_rate_per_reg: '',
reg_count: 0,
+ loggedIn: false,
},
initialize: function(){
template: _.template( jQuery('#eventReg-registrant-add').html() ),
events: {
- 'click .add-new-registrant': 'addNew',
+ //'click .add-new-registrant': 'addNew',
},
initialize: function(){
},
render: function(){
- console.log( loginAccount );
if ( loginAccount === '' ) {
- console.log( 'hide called for .glm-add-account' );
this.$('.glm-add-account').hide();
}
this.model.set({ reg_count: this.model.registrants.length });
'click .addRegistrant': 'newEntry',
'click .glm-add-account': 'addAccount',
'click .glm-add-new-account': 'addNewAccount',
+ 'click .add-new-registrant': 'addNew',
},
addAccount: function(){
}
}
},
+ addNew: function(){
+ console.log( 'called addNew in regClass view' );
+ var fname = this.$('.reg_fname').val().trim();
+ var lname = this.$('.reg_lname').val().trim();
+ var email = this.$('.reg_email').val().trim();
+ console.log( 'email: ' + email + ' fname: ' + fname + ' lname: ' + lname );
+ var regRequest = cart.get( 'request' );
+ this.model.registrants.create({
+ option: 'add',
+ reg_request: regRequest.id,
+ reg_event: this.model.get( 'reg_event' ),
+ reg_class: this.model.get( 'id' ),
+ reg_rate: this.model.get( 'reg_rate_id' ),
+ email: email,
+ });
+ this.newRegAccount.destroy();
+ this.newRegAccountView.remove();
+ },
addNewAccount: function(){
- console.log( 'Add New Account Called' )
+ console.log( 'Add New Account Called' );
+ // Create the new Registrant View
+ this.newRegAccount = new app.Models.Front.RegRequestRegistrant();
+ this.newRegAccountView = new app.Views.Front.NewRegistrant({model: this.newRegAccount});
+ this.$el.append( this.newRegAccountView.render().el );
},
toggleClassOpen: function(){
$haveRequests = false;
$registered = false;
$haveRegistered = false;
-
+
// Get any provided option
if (isset($_REQUEST['option'])) {
$option = $_REQUEST['option'];
$accountID = ($_REQUEST['accountID'] - 0);
} else {
-
+
// Try to get saved
$accountID = get_option('glmMembersDatabaseRegistrationsAccountID');
-
+
}
-
+
if (!$accountID || $accountID <= 0) {
$accountID = false;
}
-
+
switch ( $option ) {
case 'add':
-
+
$account = $this->newEntry();
$view = 'accountEdit';
-
+
break;
case 'insert':
-
+
$account = $this->insertEntry();
if ( $account['status'] ) {
$accountAdded = true;
}
$view = 'accountEdit';
-
+
break;
case 'update':
-
+
$account = $this->updateEntry( $accountID );
if ( $account['status'] ) {
break;
case 'delete':
-
+
echo "*** NEED TO CHECK IF IT'S SAVE TO DELETE THIS ACCOUNT ***";
-
+
// $oldAccount = $this->deleteEntry( $accountID, true );
-
+
$view = 'accountsDashboard';
-
+
break;
-
+
case 'accountDashboard':
-
+
// Load registration request and registration registrant data classes
require_once GLM_MEMBERS_REGISTRATIONS_PLUGIN_CLASS_PATH.'/data/dataRegRequest.php';
$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);
-
+
// Get account base data
$account = $this->getEntry($accountID);
if ($account) {
-
+
$haveAccount = true;
-
+
// Get any registrations submitted
$requests = $RegRequest->getList("T.account = $accountID");
if (is_array($requests) && count($requests) > 0) {
$haveRequests = true;
}
-
+
// Get any events registered
$registered = $RegRequestRegistrant->getList("T.account = $accountID");
if (is_array($registered) && count($registered) > 0) {
$haveRegistered = true;
}
-
+
}
-
+
$view = 'accountDashboard';
-
+
break;
-
+
case 'edit':
-
+
$account = $this->editEntry( $accountID );
if ( $account['status'] ) {
-
+
$haveAccount = true;
$view = 'accountEdit';
-
- }
-
+
+ }
+
break;
-
+
default:
case 'dashboard';
$option = 'dashboard';
$where = 'true';
-
+
// Check if we're doing paging
if (isset($_REQUEST['pageSelect'])) {
$namesList = $this->getIdName( $where );
unset( $accountsResult );
- $view = 'accountsDashboard';
-
+ $view = 'accountsDashboard';
+
break;
-
+
}
-
+
// If we have a valid account ID, save that for future use
if ($accountID > 0) {
update_option('glmMembersDatabaseRegistrationsAccountID', $accountID);
}
-
+
// Compile template data
$templateData = array(
'hasAccounts' => $hasAccounts,
$scripts = array(
//'backbone-local' => 'js/lib/backbone.localStorage.min.js',
- 'regApp' => 'js/frontRegApp.js',
+ 'regApp' => 'js/frontRegApp.js',
);
foreach ( $scripts as $scriptName => $scriptPath ) {
wp_register_script(
//echo '<pre>$rates: ' . print_r( $rates, true ) . '</pre>';
if ( isset( $rates ) && is_array( $rates ) ) {
foreach ( $rates as $rate ) {
+ $rClass['loggedIn'] = ( isset($_SESSION['LoginAccount']) ) ? true : false;
$rClass['reg_rate_id'] = $rate['id'];
$rClass['reg_rate_name'] = $rate['name'];
$rClass['reg_rate_base_price'] = $rate['base_rate'];
<div>
<p><%= descr %></p>
<% if ( attendee_max > 0 ) { %>
- <p>Maximum Registrants: <%- attendee_max %></p>
+ <p>Maximum Registrants: <%- attendee_max %></p>
<% } %>
<p><%= terms %></p>
</div>
<div>Current Rate: <%= reg_rate_name %></div>
<div>Base Price: <%= reg_rate_base_price %></div>
<div>Per Registrant: <%= reg_rate_per_reg %></div>
- <button class="glm-add-account tiny">Add Me</button>
+ <% if ( loggedIn ) { %>
+ <button class="glm-add-account tiny">Add Me</button>
+ <% } %>
<button class="glm-add-new-account tiny">Add New</button>
<div class="registrant-add clearfix glm-hidden">
<input type="text" class="addFname" placeholder="First Name">
<div>
<input class="reg_fname" placeholder="First Name">
<input class="reg_lname" placeholder="Last Name">
- <input class="reg_email" value="<%- email %>" disabled>
+ <input class="reg_email" placeholder="Email Address" value="<%- email %>">
<input class="add-new-registrant" value="Add Registrant" type="submit">
</div>
</script>
var loginAccount = '';
jQuery(function($){
{if $loginAccount }
- loginAccount = new app.Models.Front.Account( {$loginAccount} );
+ loginAccount = new app.Models.Front.Account( {$loginAccount} );
{else}
- loginAccount = '';
+ loginAccount = '';
{/if}
cart = new app.Models.Front.Cart( {$regCartJSON} );
cart.setRequest( {$regRequestJSON} );