Update header row
authorSteve Sutton <steve@gaslightmedia.com>
Fri, 13 Oct 2017 21:10:06 +0000 (17:10 -0400)
committerSteve Sutton <steve@gaslightmedia.com>
Fri, 13 Oct 2017 21:10:06 +0000 (17:10 -0400)
Move login register and forgot into separate pages.

18 files changed:
css/front.css
js/frontRegApp.js
js/views/front/app.js
js/views/front/regClass.js
models/admin/ajax/account.php
models/front/registrations/cart.php
models/front/registrations/forgot.php [new file with mode: 0644]
models/front/registrations/index.php
models/front/registrations/list.php
models/front/registrations/login.php [new file with mode: 0644]
models/front/registrations/register.php [new file with mode: 0644]
models/front/registrations/registration.php
views/front/registrations/forgot.html [new file with mode: 0644]
views/front/registrations/header.html
views/front/registrations/list.html
views/front/registrations/login.html
views/front/registrations/register.html [new file with mode: 0644]
views/front/registrations/registration.html

index 7e1e659..8f4d0af 100644 (file)
@@ -1,3 +1,4 @@
+/* Event Registration Edit Page */
 .glm-reg-event-list {
     width: 100%;
     padding: 0;
 label.registrant-label {
     width: 80%;
 }
-div.glm-reg-login {
-    background-color: white;
-    border: solid 1px black;
-    padding: 2rem;
-    width: 30rem;
-    position: absolute;
-    top: 10vh;
-    left: 10vw;
-}
-div.glm-reg-login h4 {
-    color: black;
-}
-div.glm-reg-register {
-    background-color: white;
-    border: solid 1px black;
-    padding: 2rem;
-    width: 30rem;
-    position: absolute;
-    top: 10vh;
-    left: 10vw;
-    z-index: 999;
-}
-div.glm-reg-register div {
-    clear: both;
-}
-div.glm-reg-register input {
-    width: 48% !important;
-    margin-right: 5px;
-    float: left;
-}
-div.glm-reg-register input.error {
-    border: 2px solid red !important;
-}
+
 .reg-class-detail {
     /* display: none; */
 }
@@ -251,3 +220,57 @@ div.glm-reg-register input.error {
 .glm-registrant-edit {
     cursor: pointer;
 }
+
+/* Login Page */
+div.glm-reg-login {
+    background-color: white;
+    border: solid 1px black;
+    padding: 2rem;
+    width: 30rem;
+}
+div.glm-reg-login h4 {
+    color: black;
+}
+.accountLogin {
+    padding: .5rem 1rem;
+}
+.forgotLogin {
+    float: right;
+}
+div.glm-reg-forgot {
+    background-color: white;
+    border: solid 1px black;
+    padding: 2rem;
+    width: 30rem;
+}
+div.glm-reg-forgot h4 {
+    color: black;
+}
+/* New register account form */
+div.glm-reg-register {
+    background-color: white;
+    border: solid 1px black;
+    padding: 2rem;
+    width: 30rem;
+}
+div.glm-reg-register div {
+    clear: both;
+}
+div.glm-reg-register input {
+    width: 48% !important;
+    margin-right: 5px;
+    float: left;
+}
+div.glm-reg-register input.error {
+    border: 2px solid red !important;
+}
+div.glm-reg-register div {
+    position: relative;
+}
+span.glm-error {
+    position: absolute;
+    bottom: -56px;
+    left: 0px;
+    color: red;
+    font-size: 10px;
+}
index 8d2da7b..6699f4f 100644 (file)
@@ -486,22 +486,22 @@ app.Views.Front.App = Backbone.View.extend({
     render: function(){
         // Check to see if there's a login
         if ( loginAccount ) {
-            jQuery('#appLogin').hide();
+            // jQuery('#appLogin').hide();
             jQuery('#register').hide();
-            this.accountView = new app.Views.Front.Account({ model: loginAccount });
-            this.$el.append( this.accountView.render().el );
+            // this.accountView = new app.Views.Front.Account({ model: loginAccount });
+            // this.$el.append( this.accountView.render().el );
         }
         this.$el.append( this.event.render().el );
         return this;
     },
 
     events: {
-        'click #appLogin': 'login',
+        // 'click #appLogin': 'login',
         'click #glm-reg-cart-continue': 'continue',
-        'click #accountLogin': 'loginToAccount',
-        'click #accountRegister': 'registerNewAccount',
-        'click #accountLogout': 'logout',
-        'click #register': 'register',
+        // 'click #accountLogin': 'loginToAccount',
+        // 'click #accountRegister': 'registerNewAccount',
+        // 'click #accountLogout': 'logout',
+        // 'click #register': 'register',
     },
 
     continue: function(){
@@ -514,31 +514,31 @@ app.Views.Front.App = Backbone.View.extend({
         // Need to update the cart
     },
 
-    logout: function(){
-        // Send data to Logout
-        jQuery.ajax({
-            context: this,
-            url: appAccountUrl,
-            dataType: 'json',
-            data: 'option=logout'
-        })
-        .done(function( msg ){
-            // Here we can update.
-            loginAccount = '';
-            this.accountView.remove();
-            this.render();
-            this.event.model.classes.map(function(item){
-                item.set({ loggedIn: false });
-            });
-            jQuery('#appLogin').show();
-            // Need to reload the page now
-            window.location.href = thisPageUrl;
-        })
-        .fail(function(msg){
-            console.log('Fail:');
-            console.log( msg );
-        });
-    },
+    // logout: function(){
+    //     // Send data to Logout
+    //     jQuery.ajax({
+    //         context: this,
+    //         url: appAccountUrl,
+    //         dataType: 'json',
+    //         data: 'option=logout'
+    //     })
+    //     .done(function( msg ){
+    //         // Here we can update.
+    //         loginAccount = '';
+    //         this.accountView.remove();
+    //         this.render();
+    //         this.event.model.classes.map(function(item){
+    //             item.set({ loggedIn: false });
+    //         });
+    //         jQuery('#appLogin').show();
+    //         // Need to reload the page now
+    //         window.location.href = thisPageUrl;
+    //     })
+    //     .fail(function(msg){
+    //         console.log('Fail:');
+    //         console.log( msg );
+    //     });
+    // },
 
     loginToAccount: function(){
         this.$userInput = jQuery('.login');
@@ -632,19 +632,19 @@ app.Views.Front.App = Backbone.View.extend({
         });
     },
 
-    login: function(){
-        this.loginModel = new app.Models.Front.Login();
-        this.loginView  = new app.Views.Front.Login({ model: this.loginModel });
-        this.$el.append( this.loginView.render().el );
-        jQuery('#accountHeader').hide();
-    },
+    // login: function(){
+    //     this.loginModel = new app.Models.Front.Login();
+    //     this.loginView  = new app.Views.Front.Login({ model: this.loginModel });
+    //     this.$el.append( this.loginView.render().el );
+    //     jQuery('#accountHeader').hide();
+    // },
 
-    register: function(){
-        this.registerModel = new app.Models.Front.Register();
-        this.registerView  = new app.Views.Front.Register({ model: this.registerModel });
-        this.$el.append( this.registerView.render().el );
-        jQuery('#accountHeader').hide();
-    },
+    // register: function(){
+    //     this.registerModel = new app.Models.Front.Register();
+    //     this.registerView  = new app.Views.Front.Register({ model: this.registerModel });
+    //     this.$el.append( this.registerView.render().el );
+    //     jQuery('#accountHeader').hide();
+    // },
 
 });
 
@@ -746,8 +746,9 @@ app.Views.Front.RegClass = Backbone.View.extend({
                 // If the model is already there then don't add
                 var findById = this.model.registrants.where({account: accountId});
                 if ( findById.length === 0 ) {
-                    this.model.registrants.create({
-                        option: 'add',
+                    console.log( findById.length );
+                    // create the regRequestRegistrant for the account
+                    registrant = new app.Models.Front.RegRequestRegistrant({
                         account: accountId,
                         reg_request: regRequest.id,
                         reg_event: this.model.get( 'reg_event' ),
@@ -757,6 +758,13 @@ app.Views.Front.RegClass = Backbone.View.extend({
                         fname: loginAccount.get('fname'),
                         lname: loginAccount.get('lname')
                     });
+                    // this.newRegAccount     = new app.Models.Front.RegRequestRegistrant();
+                    this.newRegAccountView = new app.Views.Front.RegistrantForm({model: registrant});
+                    this.$el.append( this.newRegAccountView.render().el );
+                    if ( app.timeSpecific ) {
+                        app.calendar = app.initFullCalendar( true, false );
+                        // console.log('called app.initFullCalendar()');
+                    }
                 }
             }
         }
index b7d1317..8fb67dc 100644 (file)
@@ -17,22 +17,22 @@ app.Views.Front.App = Backbone.View.extend({
     render: function(){
         // Check to see if there's a login
         if ( loginAccount ) {
-            jQuery('#appLogin').hide();
+            // jQuery('#appLogin').hide();
             jQuery('#register').hide();
-            this.accountView = new app.Views.Front.Account({ model: loginAccount });
-            this.$el.append( this.accountView.render().el );
+            // this.accountView = new app.Views.Front.Account({ model: loginAccount });
+            // this.$el.append( this.accountView.render().el );
         }
         this.$el.append( this.event.render().el );
         return this;
     },
 
     events: {
-        'click #appLogin': 'login',
+        // 'click #appLogin': 'login',
         'click #glm-reg-cart-continue': 'continue',
-        'click #accountLogin': 'loginToAccount',
-        'click #accountRegister': 'registerNewAccount',
-        'click #accountLogout': 'logout',
-        'click #register': 'register',
+        // 'click #accountLogin': 'loginToAccount',
+        // 'click #accountRegister': 'registerNewAccount',
+        // 'click #accountLogout': 'logout',
+        // 'click #register': 'register',
     },
 
     continue: function(){
@@ -45,31 +45,31 @@ app.Views.Front.App = Backbone.View.extend({
         // Need to update the cart
     },
 
-    logout: function(){
-        // Send data to Logout
-        jQuery.ajax({
-            context: this,
-            url: appAccountUrl,
-            dataType: 'json',
-            data: 'option=logout'
-        })
-        .done(function( msg ){
-            // Here we can update.
-            loginAccount = '';
-            this.accountView.remove();
-            this.render();
-            this.event.model.classes.map(function(item){
-                item.set({ loggedIn: false });
-            });
-            jQuery('#appLogin').show();
-            // Need to reload the page now
-            window.location.href = thisPageUrl;
-        })
-        .fail(function(msg){
-            console.log('Fail:');
-            console.log( msg );
-        });
-    },
+    // logout: function(){
+    //     // Send data to Logout
+    //     jQuery.ajax({
+    //         context: this,
+    //         url: appAccountUrl,
+    //         dataType: 'json',
+    //         data: 'option=logout'
+    //     })
+    //     .done(function( msg ){
+    //         // Here we can update.
+    //         loginAccount = '';
+    //         this.accountView.remove();
+    //         this.render();
+    //         this.event.model.classes.map(function(item){
+    //             item.set({ loggedIn: false });
+    //         });
+    //         jQuery('#appLogin').show();
+    //         // Need to reload the page now
+    //         window.location.href = thisPageUrl;
+    //     })
+    //     .fail(function(msg){
+    //         console.log('Fail:');
+    //         console.log( msg );
+    //     });
+    // },
 
     loginToAccount: function(){
         this.$userInput = jQuery('.login');
@@ -163,18 +163,18 @@ app.Views.Front.App = Backbone.View.extend({
         });
     },
 
-    login: function(){
-        this.loginModel = new app.Models.Front.Login();
-        this.loginView  = new app.Views.Front.Login({ model: this.loginModel });
-        this.$el.append( this.loginView.render().el );
-        jQuery('#accountHeader').hide();
-    },
+    // login: function(){
+    //     this.loginModel = new app.Models.Front.Login();
+    //     this.loginView  = new app.Views.Front.Login({ model: this.loginModel });
+    //     this.$el.append( this.loginView.render().el );
+    //     jQuery('#accountHeader').hide();
+    // },
 
-    register: function(){
-        this.registerModel = new app.Models.Front.Register();
-        this.registerView  = new app.Views.Front.Register({ model: this.registerModel });
-        this.$el.append( this.registerView.render().el );
-        jQuery('#accountHeader').hide();
-    },
+    // register: function(){
+    //     this.registerModel = new app.Models.Front.Register();
+    //     this.registerView  = new app.Views.Front.Register({ model: this.registerModel });
+    //     this.$el.append( this.registerView.render().el );
+    //     jQuery('#accountHeader').hide();
+    // },
 
 });
index 9fab5f5..0f15aa6 100644 (file)
@@ -56,8 +56,9 @@ app.Views.Front.RegClass = Backbone.View.extend({
                 // If the model is already there then don't add
                 var findById = this.model.registrants.where({account: accountId});
                 if ( findById.length === 0 ) {
-                    this.model.registrants.create({
-                        option: 'add',
+                    console.log( findById.length );
+                    // create the regRequestRegistrant for the account
+                    registrant = new app.Models.Front.RegRequestRegistrant({
                         account: accountId,
                         reg_request: regRequest.id,
                         reg_event: this.model.get( 'reg_event' ),
@@ -67,6 +68,13 @@ app.Views.Front.RegClass = Backbone.View.extend({
                         fname: loginAccount.get('fname'),
                         lname: loginAccount.get('lname')
                     });
+                    // this.newRegAccount     = new app.Models.Front.RegRequestRegistrant();
+                    this.newRegAccountView = new app.Views.Front.RegistrantForm({model: registrant});
+                    this.$el.append( this.newRegAccountView.render().el );
+                    if ( app.timeSpecific ) {
+                        app.calendar = app.initFullCalendar( true, false );
+                        // console.log('called app.initFullCalendar()');
+                    }
                 }
             }
         }
index 09053fe..3d22c61 100644 (file)
@@ -182,6 +182,7 @@ class GlmMembersAdmin_ajax_account extends GlmDataRegistrationsAccount
             }
 
             break;
+
         case 'logout':
             unset(
                 $_SESSION['LoginAccount'],
@@ -189,6 +190,7 @@ class GlmMembersAdmin_ajax_account extends GlmDataRegistrationsAccount
             );
             $return = array( 'valid' => false );
             break;
+
         case 'login':
             $username = filter_var( $_REQUEST['username'], FILTER_SANITIZE_STRING );
             $password = filter_var( $_REQUEST['password'], FILTER_SANITIZE_STRING );
index 0fb52ea..fe81c5f 100644 (file)
@@ -151,7 +151,8 @@ class GlmMembersFront_registrations_cart extends GlmRegCartSupport
             'cartId'        => $cartId,
             'haveCart'      => $haveCart,
             'cart'          => $this->cart,
-            'regUrl'        => GLM_MEMBERS_REGISTRATIONS_SITE_BASE_URL.$this->config['settings']['canonical_reg_page'].'/'
+            'regUrl'        => GLM_MEMBERS_REGISTRATIONS_SITE_BASE_URL.$this->config['settings']['canonical_reg_page'].'/',
+            'loggedIn'      => ( isset( $_SESSION['LoginAccount'] ) ) ? $_SESSION['LoginAccount']: false,
         );
 
 //echo "<pre>".print_r($templateData,1)."</pre>";
diff --git a/models/front/registrations/forgot.php b/models/front/registrations/forgot.php
new file mode 100644 (file)
index 0000000..b4fd885
--- /dev/null
@@ -0,0 +1,69 @@
+<?php
+ require_once GLM_MEMBERS_REGISTRATIONS_PLUGIN_CLASS_PATH.'/data/dataRegEvent.php';
+
+ class GlmMembersFront_registrations_forgot
+{
+    /**
+    * WordPress Database Object
+    *
+    * @var $wpdb
+    * @access public
+    */
+    public $wpdb;
+    /**
+    * Plugin Configuration Data
+    *
+    * @var $config
+    * @access public
+    */
+    public $config;
+
+    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    = 'forgot';
+        $message = '';
+
+        // Check for $option
+        $option = ( isset( $_REQUEST['option'] ) ) ? filter_var( $_REQUEST['option'], FILTER_SANITIZE_STRING) : null;
+        switch ( $option ) {
+        case 'submit':
+            echo '<pre>$_REQUEST: ' . print_r( $_REQUEST, true ) . '</pre>';
+            break;
+        default:
+            break;
+        }
+
+        // Compile template data
+        $templateData = array(
+            'message'  => $message,
+            'regUrl'   => GLM_MEMBERS_REGISTRATIONS_SITE_BASE_URL.$this->config['settings']['canonical_reg_page'].'/',
+            'loggedIn' => ( isset( $_SESSION['LoginAccount'] ) ) ? $_SESSION['LoginAccount']: false,
+        );
+             // Return status, any suggested view, and any data to controller
+        return array(
+            'status'        => true,
+            'modelRedirect' => false,
+            'view'          => 'front/registrations/' . $view . '.html',
+            'data'          => $templateData
+        );
+
+    }
+ }
index 3a5e84e..2f98255 100644 (file)
@@ -88,7 +88,17 @@ class GlmMembersFront_registrations_index
         }
 
         // Make sure the specified page is valid or default to "list"
-        if (!in_array($page, array('list', 'registration', 'cart', 'checkout', 'summary', 'login', 'account'))) {
+        if (!in_array($page, array(
+                'list',
+                'registration',
+                'cart',
+                'checkout',
+                'summary',
+                'login',
+                'account',
+                'forgot',
+                'register',
+            ))) {
             $page = 'list';
         }
 
index da1f705..19de3b2 100644 (file)
             'nextStart'         => $nextStart,
             'start'             => $start,
             'limit'             => $limit,
+            'regUrl'            => GLM_MEMBERS_REGISTRATIONS_SITE_BASE_URL.$this->config['settings']['canonical_reg_page'].'/',
+            'loggedIn'          => ( isset( $_SESSION['LoginAccount'] ) ) ? $_SESSION['LoginAccount']: false,
         );
+
              // Return status, any suggested view, and any data to controller
         return array(
             'status'        => true,
diff --git a/models/front/registrations/login.php b/models/front/registrations/login.php
new file mode 100644 (file)
index 0000000..3a72794
--- /dev/null
@@ -0,0 +1,103 @@
+<?php
+ require_once GLM_MEMBERS_REGISTRATIONS_PLUGIN_CLASS_PATH.'/data/dataRegEvent.php';
+
+ class GlmMembersFront_registrations_login
+{
+    /**
+    * WordPress Database Object
+    *
+    * @var $wpdb
+    * @access public
+    */
+    public $wpdb;
+    /**
+    * Plugin Configuration Data
+    *
+    * @var $config
+    * @access public
+    */
+    public $config;
+
+    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    = 'login';
+        $message = '';
+
+        // Check for $option
+        $option = ( isset( $_REQUEST['option'] ) ) ? filter_var( $_REQUEST['option'], FILTER_SANITIZE_STRING) : null;
+        switch ( $option ) {
+        case 'logout':
+            unset(
+                $_SESSION['LoginAccount'],
+                $_SESSION['glm_reg_cart_id']
+            );
+            wp_redirect( GLM_MEMBERS_REGISTRATIONS_SITE_BASE_URL.$this->config['settings']['canonical_reg_page'].'/' );
+            break;
+        case 'submit':
+            // check for password and email match
+            $username = filter_var( $_REQUEST['username'], FILTER_SANITIZE_STRING );
+            $password = filter_var( $_REQUEST['password'], FILTER_SANITIZE_STRING );
+            // Check accounts for ones that match
+            $returnData = $this->wpdb->get_row(
+                $this->wpdb->prepare(
+                    "SELECT id,password,fname,lname
+                       FROM " . GLM_MEMBERS_REGISTRATIONS_PLUGIN_DB_PREFIX .  "account
+                      WHERE email = %s
+                        AND active = true",
+                    $username
+                ),
+                ARRAY_A
+            );
+            $returnPassword = $returnData['password'];
+            $returnId       = $returnData['id'];
+            if ( $returnPassword == crypt( $password, $returnPassword ) ) {
+                // Add the user to the php session
+                $_SESSION['LoginAccount'] = array(
+                    'id'    => $returnId,
+                    'email' => $username,
+                    'fname' => $returnData['fname'],
+                    'lname' => $returnData['lname'],
+                );
+                wp_redirect( GLM_MEMBERS_REGISTRATIONS_SITE_BASE_URL.$this->config['settings']['canonical_reg_page'].'/' );
+            } else {
+                $message = 'Login Fail!';
+            }
+            break;
+        default:
+            break;
+        }
+
+        // Compile template data
+        $templateData = array(
+            'message'  => $message,
+            'regUrl'   => GLM_MEMBERS_REGISTRATIONS_SITE_BASE_URL.$this->config['settings']['canonical_reg_page'].'/',
+            'loggedIn' => ( isset( $_SESSION['LoginAccount'] ) ) ? $_SESSION['LoginAccount']: false,
+        );
+             // Return status, any suggested view, and any data to controller
+        return array(
+            'status'        => true,
+            'modelRedirect' => false,
+            'view'          => 'front/registrations/' . $view . '.html',
+            'data'          => $templateData
+        );
+
+    }
+ }
diff --git a/models/front/registrations/register.php b/models/front/registrations/register.php
new file mode 100644 (file)
index 0000000..625aa9a
--- /dev/null
@@ -0,0 +1,144 @@
+<?php
+ require_once GLM_MEMBERS_REGISTRATIONS_PLUGIN_CLASS_PATH.'/data/dataRegEvent.php';
+
+ class GlmMembersFront_registrations_register
+{
+    /**
+    * WordPress Database Object
+    *
+    * @var $wpdb
+    * @access public
+    */
+    public $wpdb;
+    /**
+    * Plugin Configuration Data
+    *
+    * @var $config
+    * @access public
+    */
+    public $config;
+
+    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       = 'register';
+        $emailError = '';
+        // Create dummy reg array
+        $reg = array(
+            'fname'   => '',
+            'lname'   => '',
+            'addr1'   => '',
+            'addr2'   => '',
+            'city'    => '',
+            'state'   => '',
+            'zip'     => '',
+            'country' => '',
+        );
+
+        // Check for $option
+        $option = ( isset( $_REQUEST['option'] ) ) ? filter_var( $_REQUEST['option'], FILTER_SANITIZE_STRING) : null;
+
+        switch ( $option ) {
+        case 'submit':
+            $email    = filter_var( $_REQUEST['email'], FILTER_VALIDATE_EMAIL );
+            $password = filter_var( $_REQUEST['password'], FILTER_SANITIZE_STRING );
+            $fname    = filter_var( $_REQUEST['fname'], FILTER_SANITIZE_STRING );
+            $lname    = filter_var( $_REQUEST['lname'], FILTER_SANITIZE_STRING );
+            $addr1    = filter_var( $_REQUEST['addr1'], FILTER_SANITIZE_STRING );
+            $addr2    = filter_var( $_REQUEST['addr2'], FILTER_SANITIZE_STRING );
+            $city     = filter_var( $_REQUEST['city'], FILTER_SANITIZE_STRING );
+            $state    = filter_var( $_REQUEST['state'], FILTER_SANITIZE_STRING );
+            $zip      = filter_var( $_REQUEST['zip'], FILTER_SANITIZE_STRING );
+            $country  = filter_var( $_REQUEST['country'], FILTER_SANITIZE_STRING );
+            if ( $email ) {
+                $accountId = $this->wpdb->get_var(
+                    $this->wpdb->prepare(
+                        "SELECT id
+                          FROM " . GLM_MEMBERS_REGISTRATIONS_PLUGIN_DB_PREFIX . "account
+                         WHERE email = %s",
+                        $email
+                    )
+                );
+                if ( $accountId ) {
+                    // Already an account with that email address
+                    $emailError = 'Already an account with that email address!';
+                    $reg = array(
+                        'fname'   => $fname,
+                        'lname'   => $lname,
+                        'addr1'   => $addr1,
+                        'addr2'   => $addr2,
+                        'city'    => $city,
+                        'state'   => $state,
+                        'zip'     => $zip,
+                        'country' => $country,
+                    );
+                    break;
+                }
+                // If they reach here then create a new account record
+                $this->wpdb->insert(
+                    GLM_MEMBERS_REGISTRATIONS_PLUGIN_DB_PREFIX . 'account',
+                    array(
+                        'date_created' => date('Y-m-d'),
+                        'active'       => 1,
+                        'email'        => $email,
+                        'password'     => crypt( $password ),
+                        'fname'        => $fname,
+                        'lname'        => $lname,
+                        'addr1'        => $addr1,
+                        'addr2'        => $addr2,
+                        'city'         => $city,
+                        'state'        => $state,
+                        'zip'          => $zip,
+                        'country'      => $country,
+                    ),
+                    '%s'
+                );
+                $accountId = $this->wpdb->insert_id;
+                // Add the user to the php session
+                $_SESSION['LoginAccount'] = array(
+                    'id'    => $accountId,
+                    'email' => $email,
+                    'fname' => $fname,
+                    'lname' => $lname,
+                );
+                wp_redirect( GLM_MEMBERS_REGISTRATIONS_SITE_BASE_URL.$this->config['settings']['canonical_reg_page'].'/' );
+            }
+            break;
+        default:
+            break;
+        }
+
+        // Compile template data
+        $templateData = array(
+            'reg'        => $reg,
+            'emailError' => $emailError,
+            'regUrl'     => GLM_MEMBERS_REGISTRATIONS_SITE_BASE_URL.$this->config['settings']['canonical_reg_page'].'/',
+            'loggedIn'   => ( isset( $_SESSION['LoginAccount'] ) ) ? $_SESSION['LoginAccount']: false,
+        );
+             // Return status, any suggested view, and any data to controller
+        return array(
+            'status'        => true,
+            'modelRedirect' => false,
+            'view'          => 'front/registrations/' . $view . '.html',
+            'data'          => $templateData
+        );
+
+    }
+ }
index 8d02298..86dfca2 100644 (file)
             // Need to refresh the page
 
         }
+        // echo '<pre>$cart: ' . print_r( $cart, true ) . '</pre>';
 
         // If we have a good cart, convert to JSON for view
         if ($haveCart) {
             'loginAccount'      => $loginAccount,
             'termsJSON'         => $termsJSON,
             'regJSON'           => json_encode( $registrants, JSON_NUMERIC_CHECK ),
+            'regUrl'            => GLM_MEMBERS_REGISTRATIONS_SITE_BASE_URL.$this->config['settings']['canonical_reg_page'].'/',
+            'loggedIn'          => ( isset( $_SESSION['LoginAccount'] ) ) ? $_SESSION['LoginAccount']: false,
         );
              // Return status, any suggested view, and any data to controller
         return array(
diff --git a/views/front/registrations/forgot.html b/views/front/registrations/forgot.html
new file mode 100644 (file)
index 0000000..35d7ad7
--- /dev/null
@@ -0,0 +1,13 @@
+{include file='front/registrations/header.html'}
+<form action="{$regUrl}?page=forgot" method="post">
+    <input type="hidden" name="option" value="submit">
+    <input type="hidden" name="page" value="forgot">
+    <div class="glm-reg-forgot">
+        <h4>Forgot Password</h4>
+        {if $message}
+            <span style="color: red;">{$message}</span>
+        {/if}
+        <input class="login" placeholder="Email Address" type="email" name="username" value="">
+        <input type="submit" class="accountLogin" value="Reset Password">
+    </div>
+</form>
index a8254b8..c39a2d2 100644 (file)
@@ -1,3 +1,12 @@
+<div id="accountHeader">
+    {if $loggedIn}
+        Logged in as {$loggedIn.fname} {$loggedIn.lname}
+        <a href="{$regUrl}?page=login&option=logout">Logout</a>
+    {else}
+        <a id="appLogin" href="{$regUrl}?page=login">Login</a>
+        <a id="register" href="{$regUrl}?page=register">Register</a>
+    {/if}
+</div>
 <div>
     <a href="{$regUrl}">Register for Another Event</a> (should be a button)
 </div>
index adde015..8542400 100644 (file)
@@ -1,3 +1,4 @@
+{include file='front/registrations/header.html'}
 <div class="glm-reg-event-list">
     {foreach $regEvents as $event}
     <div class="glm-reg-event-item clearfix">
index e69de29..9732584 100644 (file)
@@ -0,0 +1,15 @@
+{include file='front/registrations/header.html'}
+<form action="{$regUrl}?page=login" method="post">
+    <input type="hidden" name="option" value="submit">
+    <input type="hidden" name="page" value="login">
+    <div class="glm-reg-login">
+        <h4>Login</h4>
+        {if $message}
+            <span style="color: red;">{$message}</span>
+        {/if}
+        <input class="login" placeholder="Email Address" type="email" name="username" value="">
+        <input class="password" placeholder="Password" type="password" name="password" value="">
+        <input type="submit" class="accountLogin" value="Login">
+        <a class="forgotLogin" href="{$regUrl}?page=forgot">Forgot Password</a>
+    </div>
+</form>
diff --git a/views/front/registrations/register.html b/views/front/registrations/register.html
new file mode 100644 (file)
index 0000000..eb662e5
--- /dev/null
@@ -0,0 +1,39 @@
+{include file='front/registrations/header.html'}
+<form action="{$regUrl}?page=register" method="post">
+    <input type="hidden" name="option" value="submit">
+    <input type="hidden" name="page" value="register">
+    <div class="glm-reg-register">
+
+        <h3>Register New Account</h3>
+        <div>
+            {$terms.reg_term_contact_information}
+        </div>
+        <div>
+            <input type="email" class="account_email" placeholder="*Email Address" name="email" value="" required>
+            {if $emailError}
+            <span class="glm-error">{$emailError}</span>
+                {/if}
+            <input type="password" class="account_password" placeholder="*Password" name="password" value="" required>
+        </div>
+        <div>
+            <input class="account_fname" placeholder="*First Name" name="fname" value="{$reg.fname}" required>
+            <input class="account_lname" placeholder="*Last Name" name="lname" value="{$reg.lname}" required>
+        </div>
+        <div>
+            <input class="account_addr1" placeholder="Address 1" name="addr1" value="{$reg.addr1}" required>
+            <input class="account_addr2" placeholder="Address 2" name="addr2" value="{$reg.addr2}">
+        </div>
+        <div>
+            <input class="account_city" placeholder="City" name="city" value="{$reg.city}" required>
+            <input class="account_state" placeholder="State" name="state" value="{$reg.state}" required>
+        </div>
+        <div>
+            <input class="account_zip" placeholder="Zip/Postal Code" name="zip" value="{$reg.zip}" required>
+            <input class="account_country" placeholder="Country" name="country" value="{$reg.country}">
+        </div>
+        <div>
+            <input type="submit" id="accountRegister" value="Register">
+        </div>
+
+    </div>
+</form>
index cab13d0..12940fe 100644 (file)
@@ -98,9 +98,6 @@
     </div>
     <div class="reg-class-detail">
         <div><%- descr %></div>
-        <div>Current Rate: <%= reg_rate_name %></div>
-        <div>Base Price: <%= reg_rate_base_price %></div>
-        <div>Per {/literal}{$terms.reg_term_attendee_cap}{literal}: <%= reg_rate_per_reg %></div>
         <% if ( loggedIn ) { %>
             <button class="glm-add-account tiny">Add Me</button>
         <% } %>
             {/literal}{$terms.reg_term_contact_information}{literal}
         </div>
         <div>
-            <input class="add_reg_fname" placeholder="First Name">
-            <input class="add_reg_lname" placeholder="Last Name">
+            <input class="add_reg_fname" placeholder="First Name" value="<%- fname %>">
+            <input class="add_reg_lname" placeholder="Last Name" value="<%- lname %>">
         </div>
         <div>
             <input class="add_reg_email" placeholder="Email Address" value="<%- email %>">
             (Email is optional)
         </div>
         <div>
-            <input class="add_reg_addr1" placeholder="Address 1">
-            <input class="add_reg_addr2" placeholder="Address 2">
+            <input class="add_reg_addr1" placeholder="Address 1" value="<%- addr1 %>">
+            <input class="add_reg_addr2" placeholder="Address 2" value="<%- addr2 %>">
         </div>
         <div>
-            <input class="add_reg_city" placeholder="City">
-            <input class="add_reg_state" placeholder="State">
+            <input class="add_reg_city" placeholder="City" value="<%- city %>">
+            <input class="add_reg_state" placeholder="State" value="<%- state %>">
         </div>
         <div>
-            <input class="add_reg_zip" placeholder="Zip/Postal Code">
-            <input class="add_reg_country" placeholder="Country">
+            <input class="add_reg_zip" placeholder="Zip/Postal Code" value="<%- zip %>">
+            <input class="add_reg_country" placeholder="Country" value="<%- country %>">
         </div>
         {/literal}{if $regEvent.time_specific.value}
             <div>
                 <input class="reg_lname" placeholder="Last Name" value="<%- lname %>">
             </div>
             <div>
-                <input class="reg_email" placeholder="Email Address" value="<%- email %>" disabled>
+                <input class="reg_email" placeholder="Email Address" value="<%- email %>"<% if ( email ) { %> disabled <% } %>>
                 (Email is optional)
             </div>
             <div>
 {/literal}
 <div class="glm-reg-event-list" id="regApp">
     <h1>{$terms.reg_term_registrations_name}</h1>
-    <div id="accountHeader">
-        <a id="appLogin">Login</a>
-        <a id="register">Register</a>
-    </div>
+    {include file='front/registrations/header.html'}
 </div>
 {* Bootstrap the models needed on page load *}
 {* Need to have RegEvent model created *}