1function WaitListCollection() { 2 3 this.collection = []; 4 this.item_types = null; 5 this.store_id = null; 6} 7 8function WaitListCollection(store_id) { 9 10 this.store_id = store_id; 11 this.collection = []; 12 this.item_types = null; 13} 14 15WaitListCollection.prototype = { 16 17 collection: null, 18 19 getAll: function(callback) { 20 21 var that = this; 22 $.blockUI({}); 23 $.getJSON("/api/waitlist/WaitListApi.php?storeid="+this.store_id) 24 .done(function( data ) { 25 26 that.setCollections(data.lists); 27 callback(that.collection, that.item_types); 28 }).fail(function() { 29 $.unblockUI(); 30 }) 31 .always(function() { 32 $.unblockUI(); 33 });; 34 }, 35 36 getAllContactsView: function(callback) { 37 38 var that = this; 39 $.blockUI({}); 40 $.getJSON("/api/waitlist/WaitListApi.php?storeid="+this.store_id + "&contacts=1") 41 .done(function( data ) { 42 43 that.setCollections(data.lists); 44 callback(that.collection); 45 }).fail(function() { 46 $.unblockUI(); 47 }) 48 .always(function() { 49 $.unblockUI(); 50 });; 51 }, 52 53 isClassesEnabled: function () { 54 return !!window.knobby && window.knobby.module_classes; 55 }, 56 57 isRespectClassesSettingInAllPlacesEnabled: function () { 58 return !!window.knobby && window.knobby.module_respect_classes_setting_in_all_places; 59 }, 60 61 setCollections: function(lists) { 62 63 var that = this; 64 that.collection = []; 65 that.item_types = [{id:0, name:"All Types"}]; 66 67 if(lists.event_lists !== undefined && (!this.isRespectClassesSettingInAllPlacesEnabled() || this.isClassesEnabled())) { 68 69 that.setCollection(that, lists.event_lists); 70 that.item_types.push({id:1, name:"Class"}); 71 } 72 73 if(lists.pslr_lists !== undefined) { 74 75 that.setCollection(that, lists.pslr_lists); 76 that.item_types.push({id:1, name:"Product"}); 77 } 78 79 if(lists.contacts !== undefined) { 80 81 that.setContactsViewCollection(that, lists.contacts); 82 } 83 }, 84 85 setCollection: function(that, lists) { 86 87 for(var i = 0; i < lists.length; i++) 88 { 89 var row = lists[i]; 90 var wait_list = new WaitList(); 91 angular.extend(wait_list, row); 92 for(var j = 0; j < wait_list.contacts.length; j++) { 93 94 var contact = wait_list.contacts[j]; 95 var wait_list_contact = new WaitListContact(); 96 angular.extend(wait_list_contact, contact); 97 wait_list.contacts[j] = wait_list_contact; 98 } 99 that.collection.push(wait_list); 100 } 101 }, 102 103 setContactsViewCollection: function(that, lists) { 104 105 for(var i = 0; i < lists.length; i++) 106 { 107 var row = lists[i]; 108 var contact = new WaitListContact(); 109 angular.extend(contact, row); 110 for(var j = 0; j < contact.waitlists.length; j++) { 111 112 var wailist = contact.waitlists[j]; 113 var wait_list = new WaitList(); 114 angular.extend(wait_list, wailist); 115 contact.waitlists[j] = wait_list; 116 } 117 that.collection.push(contact); 118 } 119 }, 120 121 getExistingContactInfoByEmail: function(item_id, email, callback) { 122 123 $.getJSON("/public/api/waitlist.service.php?storeid="+this.store_id+"&findbyemail="+email+"&itemid="+item_id) 124 .done(function( data ) { 125 126 callback(data.contact_data); 127 }).fail(function() { 128 }) 129 .always(function() { 130 }); 131 } 132} 133 134function WaitList() { 135 136 var that = this; 137 that.wait_list_id = null; 138 that.store_id = null; 139 that.store_location_id = null; 140 that.item_id = null; 141 that.status_id = null; 142 that.item_type_id = null; 143 that.item_type = null; 144 that.title = null; 145 that.contacts = []; 146} 147 148WaitList.prototype = { 149 150 wait_list_id: null, 151 store_id: null, 152 store_location_id: null, 153 item_id: null, 154 status_id: null, 155 item_type_id: null, 156 item_type: null, 157 title: null, 158 contacts: [], 159 160 save: function(callback) { 161 if (window.knobby && window.knobby['module_improved_waitlist']) { 162 var waitListData = {}; 163 164 waitListData.item_id = parseInt(this.item_id); 165 waitListData.item_type = 'event'; 166 waitListData.store_id = this.store_id; 167 waitListData.store_location_id = this.store_location_id; 168 waitListData.quantity = this.contacts[0].quantity; 169 waitListData.first_name = this.contacts[0].first_name; 170 waitListData.last_name = this.contacts[0].last_name; 171 waitListData.email = this.contacts[0].email; 172 waitListData.mobile_phone = this.contacts[0].mobile_phone; 173 waitListData.store_location_id = parseInt(this.contacts[0].store_location_id); 174 175 axios.post('/api/waitlist-item', JSON.stringify(waitListData), { 176 headers: { 177 'Content-Type': 'application/json', 178 'Authorization': 'Bearer ' + window.cartJWT, 179 } 180 }).catch(function (error) { 181 if (error.response && error.response.data) { 182 handleJsonFail(error.response.data.responseText); 183 } 184 185 throw error; 186 }).then(function (response) { 187 if (typeof callback !== 'undefined') { 188 if (typeof response.data.confirmOptInEmailSent !== undefined && 189 response.data.confirmOptInEmailSent === true) { 190 confirmationEmailSentPopupOpen(); 191 } 192 193 callback(response.data); 194 } 195 }); 196 } else { 197 $.post("/public/api/waitlist.service.php?storeid="+this.store_id, JSON.stringify(this), function(response) { 198 199 callback(response); 200 }); 201 } 202 }, 203 204 getNumberOfContacts: function() { 205 206 return this.contacts.length; 207 }, 208 209 getQuantity: function() { 210 211 var qty = 0; 212 for(var i = 0; i < this.contacts.length; i++) { 213 214 if(this.contacts[i].quantity !== null) { 215 216 qty += parseFloat(this.contacts[i].quantity); 217 } 218 } 219 return qty; 220 } 221}; 222 223function WaitListContact() { 224 225 wait_list_contact_rel_id = null; 226 wait_list_id = null; 227 store_id = null; 228 store_location_id = null; 229 pos_customer_id = null; 230 first_name = null; 231 last_name = null; 232 phone = null; 233 email = null; 234 quantity = null; 235 wait_list_status_id = null; 236 waitlist = []; 237} 238 239WaitListContact.prototype = { 240 241 wait_list_contact_rel_id: null, 242 wait_list_id: null, 243 store_id: null, 244 store_location_id: null, 245 pos_customer_id: null, 246 first_name: null, 247 last_name: null, 248 phone: null, 249 email: null, 250 quantity: null, 251 wait_list_status_id: null, 252 waitlists: [], 253 254 getFullName: function() { 255 256 return this.first_name + " " + this.last_name; 257 }, 258 259 getWaitlistsQuantity: function() { 260 261 var qty = 0; 262 for(var i = 0; i < this.waitlists.length; i++) { 263 264 if(this.waitlists[i].quantity !== null) { 265 266 qty += parseFloat(this.waitlists[i].quantity); 267 } 268 } 269 return qty; 270 }, 271 272 remove: function(callback) { 273 274 $.post("/api/waitlist/WaitListApi.php?storeid="+this.store_id+"&delcont="+this.wait_list_contact_rel_id, JSON.stringify(this), function(response) { 275 276 callback(); 277 }); 278 }, 279 280 deleteByCustomerIdAndWaitListId: function(waitlist_id, callback) { 281 282 $.post("/api/waitlist/WaitListApi.php?storeid="+this.store_id+"&delcust="+this.pos_customer_id + "&wid=" + waitlist_id, JSON.stringify(this), function(response) { 283 284 callback(); 285 }); 286 } 287};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.