Work on add registrant to more than one time slot.
authorSteve Sutton <steve@gaslightmedia.com>
Tue, 7 Nov 2017 14:06:51 +0000 (09:06 -0500)
committerSteve Sutton <steve@gaslightmedia.com>
Tue, 7 Nov 2017 14:06:51 +0000 (09:06 -0500)
Now can add a registrant to more than one time slot.
Also setting up comparator function for the times and the registrant
collections. This will keep them sorted.

js/adminRegApp.js
js/collections/admin/regRates.js
js/collections/front/regRequestRegistrants.js
js/collections/front/regTimes.js
js/frontRegApp.js
js/views/front/regClass.js
models/admin/ajax/regFront/registrant.php

index 39f7f88..4a41417 100644 (file)
@@ -97,7 +97,7 @@ app.Collections.Admin.RegRates = Backbone.Collection.extend({
         if ( r1 > r2  ) {
             return -1;
         } else if ( r1 == r2 ) {
-            return 0
+            return 0;
         } else {
             return 1;
         }
index 52fc1ec..da3bbf6 100644 (file)
@@ -10,7 +10,7 @@ app.Collections.Admin.RegRates = Backbone.Collection.extend({
         if ( r1 > r2  ) {
             return -1;
         } else if ( r1 == r2 ) {
-            return 0
+            return 0;
         } else {
             return 1;
         }
index 2e4e218..1485022 100644 (file)
@@ -1,6 +1,13 @@
 app.Collections.Front.RegRequestRegistrants = Backbone.Collection.extend({
     model: app.Models.Front.RegRequestRegistrant,
-
     url: ajaxUrl+'&glm_action=regFront&collection=registrant=',
-
+    comparator: function(reg1, reg2){
+        if ( reg1.get('lname') < reg2.get('lname') ) {
+            return -1;
+        } else if ( reg1.get('lname') == reg2.get('lname') ) {
+            return 0;
+        } else {
+            return 1;
+        }
+    },
 });
index 3ef9dab..93dd379 100644 (file)
@@ -3,6 +3,16 @@
 // reg time collection
 app.Collections.Front.RegTimes = Backbone.Collection.extend({
     model: app.Models.Front.RegTime,
-
     url: ajaxUrl+'&glm_action=regFront&collection=regTime=',
+    comparator: function(regTime1, regTime2){
+        var time1 = regTime1.get('start_datetime');
+        var time2 = regTime2.get('start_datetime');
+        if ( time1.timestamp < time2.timestamp ) {
+            return -1;
+        } else if ( time1.timestamp == time2.timestamp ) {
+            return 0;
+        } else {
+            return 1;
+        }
+    },
 });
index 3e7c602..2fffb04 100644 (file)
@@ -373,9 +373,16 @@ app.Collections.Front.RegRates = Backbone.Collection.extend({
 
 app.Collections.Front.RegRequestRegistrants = Backbone.Collection.extend({
     model: app.Models.Front.RegRequestRegistrant,
-
     url: ajaxUrl+'&glm_action=regFront&collection=registrant=',
-
+    comparator: function(reg1, reg2){
+        if ( reg1.get('lname') < reg2.get('lname') ) {
+            return -1;
+        } else if ( reg1.get('lname') == reg2.get('lname') ) {
+            return 0;
+        } else {
+            return 1;
+        }
+    },
 });
 
 // js/collections/regTimes.js
@@ -383,8 +390,18 @@ app.Collections.Front.RegRequestRegistrants = Backbone.Collection.extend({
 // reg time collection
 app.Collections.Front.RegTimes = Backbone.Collection.extend({
     model: app.Models.Front.RegTime,
-
     url: ajaxUrl+'&glm_action=regFront&collection=regTime=',
+    comparator: function(regTime1, regTime2){
+        var time1 = regTime1.get('start_datetime');
+        var time2 = regTime2.get('start_datetime');
+        if ( time1.timestamp < time2.timestamp ) {
+            return -1;
+        } else if ( time1.timestamp == time2.timestamp ) {
+            return 0;
+        } else {
+            return 1;
+        }
+    },
 });
 
 // js/views/account.js
@@ -504,6 +521,7 @@ app.Views.Front.RegClass = Backbone.View.extend({
         this.$el.html( this.template( this.model.toJSON() ) );
         // Go through the RegTimes Collection and render those
         // var view = this.model.
+        // this.model.regTimes.sort();
         var view = this.model.regTimes.map(function(item){
             return (new app.Views.Front.RegTime({ model: item })).render().el;
         });
index 34f1ab9..7a8bd04 100644 (file)
@@ -55,6 +55,7 @@ app.Views.Front.RegClass = Backbone.View.extend({
         this.$el.html( this.template( this.model.toJSON() ) );
         // Go through the RegTimes Collection and render those
         // var view = this.model.
+        // this.model.regTimes.sort();
         var view = this.model.regTimes.map(function(item){
             return (new app.Views.Front.RegTime({ model: item })).render().el;
         });
index 469af88..6f6d75c 100644 (file)
@@ -399,11 +399,13 @@ class GlmMembersAdmin_registrations_ajax_registrant extends GlmDataRegistrations
                       WHERE reg_request = %d
                         AND account = %d
                         AND reg_request_event = %d
-                        AND reg_request_class = %d",
+                        AND reg_request_class = %d
+                        AND reg_time = %d",
                     $modelData['reg_request'],
                     $accountId,
                     $regRequestEventId,
-                    $regRequestClassId
+                    $regRequestClassId,
+                    $modelData['reg_time']
                 )
             );
         }