1(function (app) { 2 'use strict'; 3 4 app.controller('RSVPRegistrationCtrl', RSVPRegistrationCtrl); 5 6 RSVPRegistrationCtrl.$inject = ["$rootScope", "$scope", "$location", "$filter","$routeParams", "$uibModal", "rsvpEventService", "notificationService"]; 7 8 function RSVPRegistrationCtrl($rootScope, $scope, $location, $filter, $routeParams, $uibModal, rsvpEventService, notificationService) { 9 $scope.registrationTemplate = null; 10 $scope.eventInfo; 11 $scope.ChkValid = false; 12 $scope.ChkTitle = ""; 13 $scope.isRadioBotton = false; 14 var state = { 15 new: 'new', 16 error: 'error', 17 preview: 'preview', 18 attendee: 'attendee', 19 datevalidation: 'datevalidation', 20 success: 'success' 21 }; 22 $scope.isDOBRequired = false; 23 $scope.isValidAge = false; 24 $scope.CustomStyle = {}; 25 26 var templateView = { 27 classic: 'Classic', 28 standard: 'Standard' 29 }; 30 var registration = { 31 ID: 0, 32 FirstName: '', 33 LastName: '', 34 Company: '', 35 Address1: '', 36 Address2: '', 37 City: '', 38 State: '', 39 Zip: '', 40 Phone: '', 41 Email: '', 42 DateOfBirth: '', 43 DateCreated: '', 44 EventId: null, 45 CreatedById: null, 46 TemplateRegistrationData: '' 47 }; 48 49 // For now hardcoded, it'll populate from JSON settings 50 //$scope.templateView = templateView.classic; 51 52 $scope.stateView = $routeParams.preview || state.new; 53 54 $scope.calculateAge = function calculateAge(birthday) { // birthday is a date 55 if (birthday != undefined && birthday != null) { 56 var ageDifMs = Date.now() - birthday.getTime(); 57 var ageDate = new Date(ageDifMs); // miliseconds from epoch 58 return Math.abs(ageDate.getUTCFullYear() - 1970); 59 } else { 60 return null; 61 } 62 }; 63 64 $scope.dateOptions = { 65 showWeeks: false 66 } 67 68 function addKeyValue(obj, key, data) { 69 obj[key] = data; 70 } 71 $scope.popupDate = { 72 opened: false 73 }; 74 75 $scope.openDate = function () { 76 $scope.popupDate.opened = true; 77 }; 78 79 function generateTemplate() { 80 if ($routeParams.uniqueURL.trim() !== '') { 81 grabRegistrationTemplate(); 82 } else { 83 notificationService.displayError("Event registration url looks wrong, Please check and try again!"); 84 if (!$scope.$$phase) 85 $scope.apply(); 86 $scope.stateView = state.error; 87 $scope.stateMessage = 'Event registration url looks wrong, Please check and try again!'; 88 } 89 }; 90 91 function grabRegistrationTemplate() { 92 rsvpEventService.getUniqueURL($routeParams.uniqueURL).then(function (response) { 93 94 $scope.eventregurl = $routeParams.uniqueURL; 95 if (response === '') 96 { 97 notificationService.displayError("Event registration url looks bad format, Please check and try again!"); 98 if (!$scope.$$phase) 99 $scope.apply(); 100 $scope.stateView = state.error; 101 $scope.stateMessage = 'Event registration url looks bad format, Please check and try again!'; 102 return; 103 } 104 105 $scope.eventInfo = response; 106 107 if ($scope.eventInfo.TemplateType == templateView.classic) { 108 if (!$scope.$$phase) 109 $scope.apply(); 110 $scope.templateView = templateView.classic; 111 } 112 else { 113 $scope.templateView = templateView.standard; 114 } 115 116 if ($scope.eventInfo.TemplateType == templateView.classic) { 117 var img = "/files/rsvpevents/" + $scope.eventInfo.HeaderImage; 118 $scope.CustomStyle = { 119 'background-image': 'url(' + img + ')', 120 'background-repeat': 'no-repeat', 121 'background-size': 'cover' 122 }; 123 124 //$scope.CustomStyle2 = { 125 // 'background-color': $scope.eventInfo.PageBgColor, 126 // 'font-family': $scope.eventInfo.PageFontFamily 127 //}; 128 129 //$scope.CustomStyle3 = { 130 // 'color': $scope.eventInfo.PageTextColor 131 //}; 132 } 133 else { 134 //$scope.CustomStyle2 = { 135 // 'background-color': $scope.eventInfo.PageBgColor, 136 // 'font-family': $scope.eventInfo.PageFontFamily 137 //}; 138 //$scope.CustomStyle3 = { 139 // 'color': $scope.eventInfo.PageTextColor 140 //}; 141 } 142 143 var EventStartOn = ''; 144 var EventEndOn = ''; 145 var TimeZone = 'EST'; 146 147 //USWD-456 148 //if ($scope.eventInfo.IsRecurring) { 149 150 // var fromDate = $scope.eventInfo.FromDate; 151 152 // var fdatetime = fromDate.split(/[ ,]+/); 153 // var frdate = fdatetime[0];
154 // var fdate = frdate.split("/")[1]; 155 // var fmonth = frdate.split("/")[0]; 156 // var fyear = frdate.split("/")[2]; 157 // EventStartOn = fyear + '-' + fmonth + '-' + fdate; 158 // var ftime = fromDate.split(" ")[1]; 159 // var ftime1 = fromDate.split(" ")[2]; 160 161 // var fromTime = ftime + ftime1; 162 // $scope.EventStartTime = fromTime; 163 164 // var toDate = $scope.eventInfo.ToDate; 165 166 // var tdatetime = toDate.split(/[ ,]+/); 167 // var todate = tdatetime[0]; 168 // var tdate = todate.split("/")[1]; 169 // var tmonth = todate.split("/")[0]; 170 // var tyear = todate.split("/")[2]; 171 // EventEndOn = tyear + '-' + tmonth + '-' + tdate; 172 // var ttime = toDate.split(" ")[1]; 173 // var ttime1 = toDate.split(" ")[2]; 174 175 // var toTime = ttime + ttime1; 176 // $scope.EventEndTime = toTime; 177 178 179 //} 180 //else { 181 // var startDate = $scope.eventInfo.StartDateTime; 182 183 // var datetime = startDate.split(/[ ,]+/); 184 // var date = datetime[0]; 185 // var sdate = date.split("/")[1]; 186 // var smonth = date.split("/")[0]; 187 // var syear = date.split("/")[2]; 188 // EventStartOn = syear + '-' + smonth + '-' + sdate; 189 // var time = startDate.split(" ")[1]; 190 // var time1 = startDate.split(" ")[2]; 191 192 // var startTime = time + time1; 193 // $scope.EventStartTime = startTime; 194 195 // var endDate = $scope.eventInfo.EndDateTime; 196 197 // var edatetime = endDate.split(/[ ,]+/); 198 // var enddate = edatetime[0]; 199 // var edate = enddate.split("/")[1]; 200 // var emonth = enddate.split("/")[0]; 201 // var eyear = enddate.split("/")[2]; 202 // EventEndOn = eyear + '-' + emonth + '-' + edate; 203 // var etime = endDate.split(" ")[1]; 204 // var etime1 = endDate.split(" ")[2]; 205 206 // var endTime = etime + etime1; 207 // $scope.EventEndTime = endTime; 208 //} 209 210 var startDate = $scope.eventInfo.StartDateTime; 211 212 var datetime = startDate.split(/[ ,]+/); 213 var date = datetime[0]; 214 var sdate = date.split("/")[1]; 215 var smonth = date.split("/")[0]; 216 var syear = date.split("/")[2]; 217 EventStartOn = syear + '-' + smonth + '-' + sdate; 218 var time = startDate.split(" ")[1]; 219 var time1 = startDate.split(" ")[2]; 220 221 var startTime = time + time1; 222 $scope.EventStartTime = startTime; 223 $scope.TimeZone = $scope.eventInfo.TimeZone 224 225 var endDate = $scope.eventInfo.EndDateTime; 226 227 var edatetime = endDate.split(/[ ,]+/); 228 var enddate = edatetime[0]; 229 var edate = enddate.split("/")[1]; 230 var emonth = enddate.split("/")[0]; 231 var eyear = enddate.split("/")[2]; 232 EventEndOn = eyear + '-' + emonth + '-' + edate; 233 var etime = endDate.split(" ")[1]; 234 var etime1 = endDate.split(" ")[2]; 235 236 var endTime = etime + etime1; 237 $scope.EventEndTime = endTime; 238 239 $scope.EventStartOn = ($filter('date')(EventStartOn, "EEEE, MMMM dd")); 240 $scope.EventEndOn = ($filter('date')(EventEndOn, "EEEE, MMMM dd")); 241 $scope.TimeZone = $scope.eventInfo.TimeZone.match(/\b([A-Z])/g).join(''); 242 243 if ($scope.stateView !== 'preview') { 244 if ($scope.eventInfo.IsEventCompleted) { 245 246 notificationService.displayError("This event is now completed. Thank y
246ou!."); 247 if (!$scope.$$phase) 248 $scope.apply(); 249 $scope.stateView = state.datevalidation; 250 $scope.stateMessage = '<h2>MH Event is completed!</h2><br/><p>' + $scope.eventInfo.EventCompleteNotificationMessage + '<br/><b>For any inquiries please email:<b> <a href="mailto:' + $scope.eventInfo.EnquiryEmail + '">' + $scope.eventInfo.EnquiryEmail + '<\a></p>'; 251 return; 252 253 } 254 if ($scope.eventInfo.Status == 3) { 255 256 notificationService.displayError("This event is not active now or closed for registration. Thank you!."); 257 if (!$scope.$$phase) 258 $scope.apply(); 259 $scope.stateView = state.datevalidation; 260 $scope.stateMessage = '<h2>This event is not active !</h2><br/><p>This event is not active now or closed for registration! Thanks for showing your interest.<br/><b>For any inquiries please email:<b> <a href="mailto:' + $scope.eventInfo.EnquiryEmail + '">' + $scope.eventInfo.EnquiryEmail + ' <\a></p>'; 261 return; 262 263 } 264 265 if ($scope.eventInfo.IsOpenForRegistration == false) { 266 267 notificationService.displayError("This event is not open for registration. Please try again later."); 268 if (!$scope.$$phase) 269 $scope.apply(); 270 $scope.stateView = state.datevalidation; 271 $scope.stateMessage = '<h2>MH Event is not started!</h2><br/><p>MH Event is not started! Thanks for showing your interest.<br/><b>For any inquiries please email:<b> <a href="mailto:' + $scope.eventInfo.EnquiryEmail + '">' + $scope.eventInfo.EnquiryEmail + ' <\a></p>'; 272 return; 273 274 } 275 276 if ($scope.eventInfo.IsCloseForRegistration) { 277 278 notificationService.displayError("This event is now closed for registration. Thank you!."); 279 if (!$scope.$$phase) 280 $scope.apply(); 281 $scope.stateView = state.datevalidation; 282 $scope.stateMessage = '<h2>MH Event is closed!</h2><br/><p>MH Event is closed! Thanks for showing your interest.<br/><b>For any inquiries please email:<b> <a href="mailto:' + $scope.eventInfo.EnquiryEmail + '">' + $scope.eventInfo.EnquiryEmail + '<\a></p>'; 283 return; 284 285 } 286 287 } 288 289 if ($scope.eventInfo.Status == 2 || $scope.stateView == state.preview ) //Published || Preview || add attendee mode 290 { 291 var eventSettings = JSON.parse(response.RegistrationTemplate); 292 293 eventSettings.fields = $filter('filter')(eventSettings.fields, function (value) { 294 return value.fieldType != '0'; 295 }); 296 297 eventSettings.fields = $filter('orderBy')(eventSettings.fields, function (item) { return eventSettings.fields.indexOf(item.orderId); }); 298 299 //Prepare the event Registration Template 300 $scope.registrationTemplate = { 301 name: 'registrationTemplate', 302 fields: (eventSettings.fields || []) 303 }; 304 305 if ($scope.eventInfo.TemplateType == templateView.classic) { 306 if (!$scope.$$phase) 307 $scope.apply(); 308 $scope.templateView = templateView.classic; 309 } 310 else { 311 $scope.templateView = templateView.standard; 312 } 313 } 314 else { // Draft & Closed 315 if (!$scope.$$phase) 316 $scope.apply(); 317 var message = ''; 318 $scope.stateView = state.error; 319 switch ($scope.eventInfo.Status) { 320 case 1: // Draft 321 message = '<span>' + $scope.eventInfo.EventName + '</span> This event is not open for registration. Please try again later.'; 322 break; 323 case 4: // Completed 324 message = '<span>' + $scope.eventInfo.EventName + '</span>
324 This event is now closed for registration. Thank you!'; 325 break; 326 case 3: // Deleted 327 message = 'This event is no longer available. Thank you!'; 328 break; 329 default: // Default 330 message = 'Something needs to be configured, Please contact administrator'; 331 break; 332 } 333 notificationService.displayError(message); 334 $scope.stateMessage = message; 335 } 336 }); 337 } 338 339 $scope.storeEventRegistration = function (isValid, $event) { 340 341 //var chkpolicy = $scope.eventInfo.accept; 342 343 //if (chkpolicy == false || chkpolicy == undefined) { 344 345 // notificationService.displayError('Please accept policy'); 346 // return; 347 //} 348 349 if ($scope.stateView == state.preview) { 350 notificationService.displaySuccess('You are on preview mode, nothing to be registered here!'); 351 return; 352 } 353 354 if (isValid) { 355 356 var parsedRegistration = {}; 357 $scope.registrationTemplate.fields.forEach(function (element) { 358 359 if (element.type == 'date') { 360 if (element.name == "DateOfBirth") { 361 $scope.isDOBRequired = element.isRequired; 362 $scope.isValidAge = true; 363 var age = $scope.calculateAge(element.data); 364 if (age < 21) { 365 $scope.isValidAge = false; 366 } 367 } 368 } 369 370 if (element.type == 'select' && element.data != undefined) { 371 addKeyValue(parsedRegistration, element.name, element.data.name); 372 } 373 else if (element.type == 'checkbox') { 374 375 var checkboxOptions = []; 376 checkboxOptions = element.options; 377 var strChecked = ''; 378 angular.forEach(checkboxOptions, function (value, key) { 379 if (value.data == true) { 380 if (strChecked != '') { 381 strChecked = strChecked + ", "; 382 } 383 strChecked = strChecked + value.name; 384 } 385 }); 386 387 addKeyValue(parsedRegistration, element.name, strChecked); 388 if (element.isRequired && strChecked === "") { 389 $scope.ChkTitle = element.name; 390 $scope.ChkValid = true; 391 } else { 392 $scope.ChkValid = false; 393 } 394 } 395 else if (element.type === 'radio') { 396 var strRadio = ''; 397 if ('data' in element) { 398 if (element.data !== undefined) { 399 if (strRadio !== '') { 400 strRadio = strRadio + ", "; 401 } 402 strRadio = strRadio + element.data; 403 } 404 } 405 406 addKeyValue(parsedRegistration, element.name, strRadio); 407 if (element.isRequired && strRadio === "") { 408 $scope.ChkTitle = element.name; 409 $scope.isRadioBotton = true; 410 } else { 411 $scope.isRadioBotton = false; 412 } 413 } 414 else { 415 416 addKeyValue(parsedRegistration, element.name, element.data); 417 } 418 $event.preventDefault(); 419 }); 420 421 422 //console.log("parsedRegistration" + parsedRegistration.toSource()); 423 // Manipulate additional fields & prepare registration object 424 var templateData = []; 425 Object.keys(parsedRegistration).map(function (key) { 426 if (Object.keys(registration).indexOf(key) > -1) { 427 registration[key] = parsedRegistration[key]; 428 } else { 429 var objData = {}; 430 objData[key] = parsedRegistration[key]; 431 templateData.push(objData); 432 } 433 }); 434 if (templateData.length > 0) { 435 parsedRegistration.TemplateRegistrationData = JSON.stringify(templateData); 436 } 437 parsedRegistration.EventId = $scope.eventInfo.EventId; 438 439 if (parsedRegistration !== null) { 440 if ($scope.isDOBRequired) 441 { 442 if ($scope.isValidAge == false) 443 { 444 notificationService.displayError("You must be of legal drinking age to register"); 445 $event.preventDefault(); 446 return; 447 } 448 } 449 if (parsedRegistration.DateOfBirth != undefined && parsedRegistration.DateOfBirth != '' && parsedRegistration.DateOfBirth != null) { 450 parsedRegistration.DateOfBirth = $filter('date')(parsedRegistration.DateOfBirth, 'MM/dd/yyyy h:mma'); 451 } 452 if (!$scope.ChkValid && !$scope.isRadioBotton) { 453 $scope.isloading = true; 454 rsvpEventService.insertrsvpeventregistration(parsedRegistration).then(function (response) { 455 456 if (response && response.isSuccess === true) 457 { 458 if (response.isEmailSent === true) { 459 if ($scope.stateView == 'new') { 460 $scope.isloading = false; 461 notificationService.displaySuccess('Registration success!'); 462 generateTemplate(); 463 if (!$scope.$$phase) 464 $scope.apply(); 465 $scope.stateView = state.success; 466 $scope.stateMessage = '<h2>Registration success!</h2><br/><p>Registration success! You have been successfully registered for this event.<br/><b>For any inquiries please email:<b> <a href="mailto:' + $scope.eventInfo.EnquiryEmail + '">' + $scope.eventInfo.EnquiryEmail + '<\a></p>'; 467 468 } 469 else { 470 $scope.isloading = false; 471 notificationService.displaySuccess('Something went wrong in registration, Please try again!'); 472 if (!$scope.$$phase) 473 $scope.apply(); 474 $scope.stateView = state.error; 475 $scope.stateMessage = 'Something went wrong in registration, Please try again!'; 476 } 477 } 478 else if (response.isEmailSent === false) 479 { 480 $scope.isloading = false; 481 notificationService.displayError('Error occurred while sending email.!'); 482 } 483 } 484 if (response.isSuccess == true && response.isEventCapacityFull == true) { 485 notificationService.displayError(response.ErrorMsg); 486 } 487 if (response.recordIsExist === true) { 488 notificationService.displayError('Registration is already done for this event!'); 489 } 490 $scope.isloading = false; 491 $event.preventDefault(); 492 }); 493 } 494 else { 495 notificationService.displayError($scope.ChkTitle + " is mandatory field"); 496 $event.preventDefault(); 497 } 498 } 499 } 500 }; 501 502 var initFilters = function () { 503 generateTemplate(); 504 505 }; 506 507 initFilters(); 508 509 } 510 511})(angular.module("distPortal"));
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.