1angular.module('BungeeApp') 2 .controller('PublicSiteController', function ($scope, $compile, $window, $uibModal, DTOptionsBuilder, DTColumnDefBuilder, AppConstants, $timeout, $filter) { 3 $scope.setPage('Public Site', 'publicsite'); 4 $scope.privacyPolicyLink = ''; 5 6 $scope.appConstants = AppConstants; 7 $scope.noIndex = ""; 8 9 var currentUrlLocation = window.location.href; 10 $scope.currentUrlLocation = currentUrlLocation; 11 12 $scope.countries = null; 13 $scope.ajaxCall('/Country/CountryList', {}, function (data) { 14 $scope.countries = data; 15 }); 16 17 $scope.formType = null; 18 $scope.formTypeDisplay = null; 19 $scope.dashFormList = null; 20 $scope.takeFormId = null; 21 $scope.takeFormData = null; 22 $scope.takeFormSubmitted = false; 23 $scope.formNavLink = ""; 24 $scope.adminContacts = null; 25 var blankWidget = null; 26 var formSplit1 = currentUrlLocation.split("/"); 27 var formTypeSplit = formSplit1[formSplit1.length - 1].split("-"); 28 if (formTypeSplit.length > 0) { 29 $scope.formType = formTypeSplit[formTypeSplit.length - 1]; 30 switch ($scope.formType) { 31 case "violations": 32 $scope.formTypeDisplay = "Violations"; 33 $scope.formNavLink = "violations"; 34 break; 35 case "forms": 36 $scope.formTypeDisplay = "Custom Forms"; 37 $scope.formNavLink = "custom-forms"; 38 break; 39 case "ticketing": 40 $scope.formTypeDisplay = "Ticketing"; 41 $scope.formNavLink = "ticketing"; 42 break; 43 case "polls": 44 $scope.formTypeDisplay = "Polls"; 45 $scope.formNavLink = "polls"; 46 break; 47 } 48 if (formTypeSplit.length > 8) { 49 var totalLength = formTypeSplit.length; 50 $scope.takeFormId = formTypeSplit[totalLength - 6] + "-" + formTypeSplit[totalLength - 5] + "-" + formTypeSplit[totalLength - 4] + "-" + formTypeSplit[totalLength - 3] + "-" + formTypeSplit[totalLength - 2]; 51 } 52 } 53 54 if (currentUrlLocation.includes("free.membershine") || currentUrlLocation.includes("free.hoastart")) { 55 $scope.noIndex = '<meta name="robots" content="noindex" />'; 56 } 57 58 $scope.getLogoId = function () { 59 $scope.ajaxCall('/Customer/GetLogoId', { customerId: $scope.sitedata.customerId }, function (data) { 60 $scope.displayLogoId = data; 61 }); 62 } 63 64 $scope.getAdminContacts = function () { 65 $scope.ajaxCall('/Customer/GetAdminContacts', { customerId: $scope.sitedata.customerId }, function (data) { 66 $scope.adminContacts = data; 67 }); 68 } 69 70 $scope.pageId = null; 71 $scope.sitedata = []; 72 $scope.currentPage = null; 73 $scope.isMember = false; 74 75 $scope.sitePrefix = ""; 76 $scope.specialPage = false; 77 $scope.specialPageType = ""; 78 79 80 81 $scope.results = null; 82 83 $scope.selectedColorPalette = null; 84 85 $scope.endImpersonation = function () { 86 $scope.ajaxCall('/User/EndImpersonate', null, function () { 87 sessionStorage.setItem("bungee-sitecookie-region", "admin"); 88 $window.location.href = '/'; 89 }); 90 }; 91 92 $scope.triggerParallax = function (section) { 93 $timeout(function () { 94 jQuery('.parallaxsupport[data-section=' + section.sectionId + ']').parallax({ imageSrc: $scope.imageSrc(section.backgroundImageId) }); 95 }, 100); 96 } 97 98 $scope.stateName = function (stateId) { 99 var index1 = $scope.states.map(function (e) { return e.stateId; }).indexOf(stateId); 100 if (index1 !== -1) { 101 return $scope.states[index1].name; 102 } 103 } 104
105 $scope.sectionBackgroundTextColor = function (section) { 106 var classes = []; 107 108 if (section.backgroundType == 1) { 109 switch (section.backgroundColor) { 110 case 1: 111 classes.push('customBg1'); 112 break; 113 case 2: 114 classes.push('customBg2'); 115 break; 116 case 3: 117 classes.push('customBg3'); 118 break; 119 case 4: 120 classes.push('customBg4'); 121 break; 122 case 5: 123 classes.push('customBg5'); 124 break; 125 case 6: 126 classes.push('customBg6'); 127 break; 128 case 7: 129 classes.push('customBg7'); 130 break; 131 case 8: 132 classes.push('customBg8'); 133 break; 134 } 135 } 136 137 138 switch (section.fontColor) { 139 case 1: 140 classes.push('customText1'); 141 break; 142 case 2: 143 classes.push('customText2'); 144 break; 145 case 3: 146 classes.push('customText3'); 147 break; 148 case 4: 149 classes.push('customText4'); 150 break; 151 case 5: 152 classes.push('customText5'); 153 break; 154 case 6: 155 classes.push('customText6'); 156 break; 157 case 7: 158 classes.push('customText7'); 159 break; 160 } 161 162 return classes.join(" "); 163 } 164 165 $scope.previewCards = JSON.parse(sessionStorage.getItem("memberPortalCardPreview")); 166 $scope.portalWelcomeText = JSON.parse(sessionStorage.getItem("memberPortalWelcomeText")); 167 168 $scope.getInitialsFromName = function () { 169 var initials = ""; 170 if ($scope.currentUser == null || $scope.currentUser.firstName == null || $scope.currentUser.lastName == null) { 171 return ""; 172 } 173 initials += $scope.currentUser.firstName.substring(0, 1); 174 initials += $scope.currentUser.lastName.substring(0, 1); 175 return initials; 176 } 177 178 $scope.isPreviewingDesktop = true; 179 180 $scope.sectionBackgroundImage = function (section) { 181 var stylestring = ''; 182 183 if (section.backgroundImageId != null && section.backgroundType == 2) { 184 stylestring += 'background-image: url(' + $scope.imageSrc(section.backgroundImageId) + ');'; 185 186 if (section.backgroundRepeat == 1) { 187 stylestring += 'background-repeat: no-repeat; background-size: cover;'; 188 189 switch (section.backgroundFocus) { 190 case 1: 191 stylestring += 'background-position: center center;'; 192 break; 193 case 2: 194 stylestring += 'background-position: left center;'; 195 break; 196 case 3: 197 stylestring += 'background-position: right center;'; 198 break; 199 } 200 } 201 } 202 203 return stylestring; 204 } 205 206 $scope.sectionStyles = function (section) { 207 var stylestring = ''; 208 209 if (section.sectionHeight != 0 && section.sectionHeight != null) { 210 stylestring += 'height: ' + section.sectionHeight + 'px;'; 211 } 212 213 if (section.borderTopThickness != 0 && section.borderTopThickness != null) { 214 stylestring += 'border-top-width: ' + section.borderTopThickness + 'px; border-top-style: solid; '; 215 } 216 if (section.borderBottomThickness != 0 && section.borderBottomThickness != null) { 217 stylestring += 'border-bottom-width: ' + section.borderBottomThickness + 'px; border-bottom-style: solid;'; 218 } 219 if (section.paddingTop != 0 && section.paddingTop != null) { 220 stylestring += 'padding-top: ' + section.paddingTop + 'px;'; 221 } 222 if (section.paddingLeft != 0 && section.paddingLeft != null) { 223 stylestring += 'padding-left: ' + section.paddingLeft + 'px;'; 224 } 225 if (section.paddingRight != 0 && section.paddingRight != null) { 226 stylestring += 'padding-right: ' + section.paddingRight + 'px;'; 227 } 228 if (section.paddingBottom != 0 && section.paddingBottom != null) { 229 stylestring += 'padding-bottom: ' + section.paddingBottom + 'px;'; 230 } 231 232 return stylestring; 233 } 234 235 $scope.overlayStyles = function (block) { 236 var stylestring = ''; 237 238 if (block.widgetOverlayBorderRadius != null) { 239 stylestring += 'border-radius: ' + block.widgetOverlayBorderRadius + 'px;'; 240 } 241 242 return stylestring; 243 } 244
245 $scope.overlayClasses = function (block) { 246 var classes = []; 247 248 switch (block.widgetOverlayColor) { 249 case 1: 250 classes.push('customBg1'); 251 break; 252 case 2: 253 classes.push('customBg2'); 254 break; 255 case 3: 256 classes.push('customBg3'); 257 break; 258 case 4: 259 classes.push('customBg4'); 260 break; 261 case 5: 262 classes.push('customBg5'); 263 break; 264 case 6: 265 classes.push('customBg6'); 266 break; 267 case 7: 268 classes.push('customBg7'); 269 break; 270 case 8: 271 classes.push('customBg8'); 272 break; 273 } 274 275 //return "mytestclass"; 276 return classes.join(" "); 277 } 278 279 $scope.sectionFont = function (section) { 280 var stylestring = ''; 281 282 if (section.font != null) { 283 stylestring += 'font-family: ' + $scope.formatFont(section.font) + ';'; 284 285 if (section.font.includes(':')) { 286 var explodeFont = section.font.split(':'); 287 stylestring += ' font-weight: ' + explodeFont[1] + ';'; 288 } else { 289 stylestring += ' font-weight: initial;'; 290 } 291 } 292 293 if (section.fontSize != 0 && section.fontSize != null) { 294 stylestring += 'font-size: ' + section.fontSize + 'px;'; 295 } 296 297 298 if (section.letterSpacing != 0 && section.letterSpacing != null) { 299 stylestring += 'letter-spacing: ' + section.letterSpacing + 'px;'; 300 } 301 302 303 if (section.lineHeight != 0 && section.lineHeight != null) { 304 stylestring += 'line-height: ' + section.lineHeight + 'px;'; 305 } 306 307 if (section.textAlignment != 0 && section.textAlignment != null) { 308 stylestring += 'text-alignment: ' + section.textAlignment + 'px;'; 309 } 310 311 return stylestring; 312 } 313 314 $scope.headerTextStyles = function (block) { 315 316 var stylestring = ''; 317 318 if (block.headerFont != null) { 319 stylestring += 'font-family: ' + $scope.formatFont(block.headerFont) + ';'; 320 321 if (block.headerFont.includes(':')) { 322 var explodeFont = block.headerFont.split(':'); 323 stylestring += ' font-weight: ' + explodeFont[1] + ';'; 324 } else { 325 stylestring += ' font-weight: initial;'; 326 } 327 } 328 329 if (block.headerFontSize != 0 && block.headerFontSize != null) { 330 stylestring += 'font-size: ' + block.headerFontSize + 'px;'; 331 } 332 if (block.headerLetterSpacing != 0 && block.headerLetterSpacing != null) { 333 stylestring += 'letter-spacing: ' + block.headerLetterSpacing + 'px;'; 334 } 335 if (block.headerLineHeight != 0 && block.headerLineHeight != null) { 336 stylestring += 'line-height: ' + block.headerLineHeight + 'px;'; 337 } 338 339 if (block.headerTextAlignment != 0 && block.headerTextAlignment != null) { 340 switch (block.headerTextAlignment) { 341 case 1: 342 stylestring += 'text-align: center;'; 343 break; 344 case 2: 345 stylestring += 'text-align: left;'; 346 break; 347 case 3: 348 stylestring += 'text-align: right;'; 349 break; 350 } 351 } 352 353 return stylestring; 354 } 355 $scope.headerTextClasses = function (block) { 356 var classes = []; 357 358 359 switch (block.headerFontColor) { 360 case 1: 361 classes.push('customText1'); 362 break; 363 case 2: 364 classes.push('customText2'); 365 break; 366 case 3: 367 classes.push('customText3'); 368 break; 369 case 4: 370 classes.push('customText4'); 371 break; 372 case 5: 373 classes.push('customText5'); 374 break; 375 case 6: 376 classes.push('customText6'); 377 break; 378 case 7: 379 classes.push('customText7'); 380 break; 381 } 382 return classes.join(" "); 383 } 384 385 $scope.subheadTextStyles = function (block) { 386 var stylestring = ''; 387 388 if (block.subheadFont != null) { 389 stylestring += 'font-family: ' + $scope.formatFont(block.subheadFont) + ';'; 390 391 if (block.subheadFont.includes(':')) { 392 var explodeFont = block.subheadFont.split(':'); 393 stylestring += ' font-weight: ' + explodeFont[1] + ';'; 394 } else { 395 stylestring += ' font-weight: initial;'; 396 } 397 } 398 399 if (block.subheadFontSize != 0 && block.subheadFontSize != null) { 400 stylestring += 'font-size: ' + block.subheadFontSize + 'px;'; 401 } 402 if (block.subheadLetterSpacing != 0 && block.subheadLetterSpacing != null) { 403 stylestring += 'letter-spacing: ' + block.subheadLetterSpacing + 'px;'; 404 } 405 if (block.subheadLineHeight != 0 && block.subheadLineHeight != null) { 406 stylestring += 'line-height: ' + block.subheadLineHeight + 'px;'; 407 } 408 409 if (block.subheadTextAlignment != 0 && block.subheadTextAlignment != null) { 410 switch (block.subheadTextAlignment) { 411 case 1: 412 stylestring += 'text-align: center;'; 413 break; 414 case 2: 415 stylestring += 'text-align: left;'; 416 break; 417 case 3: 418 stylestring += 'text-align: right;'; 419 break; 420 } 421 } 422 423 return stylestring; 424 } 425 $scope.subheadTextClasses = function (block) { 426 var classes = []; 427 428 429 switch (block.subheadFontColor) { 430 case 1: 431 classes.push('customText1'); 432 break; 433 case 2: 434 classes.push('customText2'); 435 break; 436 case 3: 437 classes.push('customText3'); 438 break; 439 case 4: 440 classes.push('customText4'); 441 break; 442 case 5: 443 classes.push('customText5'); 444 break; 445 case 6: 446 classes.push('customText6'); 447 break; 448 case 7: 449 classes.push('customText7'); 450 break; 451 } 452 return classes.join(" "); 453 } 454 455 $scope.paragraphTextStyles = function (block) { 456 var stylestring = ''; 457 458 if (block.paragraphFont != null) { 459 stylestring += 'font-family: ' + $scope.formatFont(block.paragraphFont) + ';'; 460 461 if (block.paragraphFont.includes(':')) { 462 var explodeFont = block.paragraphFont.split(':'); 463 stylestring += ' font-weight: ' + explodeFont[1] + ';'; 464 } else { 465 stylestring += ' font-weight: initial;'; 466 } 467 } 468 469 if (block.paragraphFontSize != 0 && block.paragraphFontSize != null) { 470 stylestring += 'font-size: ' + block.paragraphFontSize + 'px;'; 471 } 472 if (block.paragraphLetterSpacing != 0 && block.paragraphLetterSpacing != null) { 473 stylestring += 'letter-spacing: ' + block.paragraphLetterSpacing + 'px;'; 474 } 475 if (block.paragraphLineHeight != 0 && block.paragraphLineHeight != null) { 476 stylestring += 'line-height: ' + block.paragraphLineHeight + 'px;'; 477 } 478 479 if (block.paragraphTextAlignment != 0 && block.paragraphTextAlignment != null) { 480 switch (block.paragraphTextAlignment) { 481 case 1: 482 stylestring += 'text-align: center;'; 483 break; 484 case 2: 485 stylestring += 'text-align: left;'; 486 break; 487 case 3: 488 stylestring += 'text-align: right;'; 489 break; 490 } 491 } 492 493 return stylestring; 494 } 495 $scope.paragraphTextClasses = function (block) { 496 var classes = []; 497 498 499 switch (block.paragraphFontColor) { 500 case 1: 501 classes.push('customText1'); 502 break; 503 case 2: 504 classes.push('customText2'); 505 break; 506 case 3: 507 classes.push('customText3'); 508 break; 509 case 4: 510 classes.push('customText4'); 511 break; 512 case 5: 513 classes.push('customText5'); 514 break; 515 case 6: 516 classes.push('customText6'); 517 break; 518 case 7: 519 classes.push('customText7'); 520 break; 521 } 522 return classes.join(" "); 523 } 524 525 /* 526 public int? buttonFontColor { get; set; }
527 public int? buttonBackgroundColor { get; set; } 528 public int? buttonBorderColor { get; set; } 529 public int? buttonBorderRadius { get; set; } 530 public int? buttonHoverBackgroundColor { get; set; } 531 public int? buttonHoverFontColor { get; set; } 532 public int? buttonBorderThickness { get; set; } 533 public int? buttonHoverBorderColor { get; set; } 534 * */ 535 $scope.buttonStyles = function (block) { 536 var stylestring = ''; 537 538 if (block.buttonFont != null) { 539 stylestring += 'font-family: ' + $scope.formatFont(block.buttonFont) + ';'; 540 541 if (block.buttonFont.includes(':')) { 542 var explodeFont = block.buttonFont.split(':'); 543 stylestring += ' font-weight: ' + explodeFont[1] + ';'; 544 } else { 545 stylestring += ' font-weight: initial;'; 546 } 547 } 548 549 if (block.buttonFontSize != 0 && block.buttonFontSize != null) { 550 stylestring += 'font-size: ' + block.buttonFontSize + 'px;'; 551 } 552 if (block.buttonLetterSpacing != 0 && block.buttonLetterSpacing != null) { 553 stylestring += 'letter-spacing: ' + block.buttonLetterSpacing + 'px;'; 554 } 555 if (block.buttonLineHeight != 0 && block.buttonLineHeight != null) { 556 stylestring += 'line-height: ' + block.buttonLineHeight + 'px;'; 557 } 558 if (block.buttonBorderRadius != 0 && block.buttonBorderRadius != null) { 559 stylestring += 'border-radius: ' + block.buttonBorderRadius + 'px;'; 560 } 561 if (block.buttonBorderThickness != 0 && block.buttonBorderThickness != null) { 562 stylestring += 'border-width: ' + block.buttonBorderThickness + 'px;'; 563 } else { 564 stylestring += 'border-width: 0px;'; 565 } 566 if (block.buttonPaddingTop != 0 && block.buttonPaddingTop != null) { 567 stylestring += 'padding-top: ' + block.buttonPaddingTop + 'px;'; 568 } 569 if (block.buttonPaddingLeft != 0 && block.buttonPaddingLeft != null) { 570 stylestring += 'padding-left: ' + block.buttonPaddingLeft + 'px;'; 571 } 572 if (block.buttonPaddingRight != 0 && block.buttonPaddingRight != null) { 573 stylestring += 'padding-right: ' + block.buttonPaddingRight + 'px;'; 574 } 575 if (block.buttonPaddingBottom != 0 && block.buttonPaddingBottom != null) { 576 stylestring += 'padding-bottom: ' + block.buttonPaddingBottom + 'px;'; 577 } 578 579 /* 580 if (block.buttonTextAlignment != 0 && block.buttonTextAlignment != null) { 581 switch (block.buttonTextAlignment) { 582 case 1: 583 stylestring += 'text-align: center;'; 584 break; 585 case 2: 586 stylestring += 'text-align: left;'; 587 break; 588 case 3: 589 stylestring += 'text-align: right;'; 590 break; 591 } 592 } 593 */ 594 595 return stylestring; 596 } 597 598 $scope.buttonClasses = function (block) { 599 var classes = []; 600 601 602 switch (block.buttonFontColor) { 603 case 1: 604 classes.push('customText1'); 605 break; 606 case 2: 607 classes.push('customText2'); 608 break; 609 case 3: 610 classes.push('customText3'); 611 612 break; 613 case 4: 614 classes.push('customText4'); 615 616 break; 617 case 5: 618 classes.push('customText5'); 619 620 break; 621 case 6: 622 classes.push('customText6'); 623 624 break; 625 case 7: 626 classes.push('customText7'); 627 break; 628 } 629 switch (block.buttonHoverFontColor) { 630 case 1: 631 classes.push('customHoverText1'); 632 break; 633 case 2: 634 classes.push('customHoverText2'); 635 break; 636 case 3: 637 classes.push('customHoverText3'); 638 639 break; 640 case 4: 641 classes.push('customHoverText4'); 642 643 break; 644 case 5: 645 classes.push('customHoverText5'); 646 647 break; 648 case 6: 649 classes.push('customHoverText6'); 650 651 break; 652 case 7: 653 classes.push('customHoverText7'); 654 break; 655 } 656
657 switch (block.buttonBackgroundColor) { 658 case 1: 659 classes.push('customBg1'); 660 break; 661 case 2: 662 classes.push('customBg2'); 663 break; 664 case 3: 665 classes.push('customBg3'); 666 break; 667 case 4: 668 classes.push('customBg4'); 669 break; 670 case 5: 671 classes.push('customBg5'); 672 break; 673 case 6: 674 classes.push('customBg6'); 675 break; 676 case 7: 677 classes.push('customBg7'); 678 break; 679 case 8: 680 classes.push('customBg8'); 681 break; 682 } 683 switch (block.buttonHoverBackgroundColor) { 684 case 1: 685 classes.push('customHoverBg1'); 686 break; 687 case 2: 688 classes.push('customHoverBg2'); 689 break; 690 case 3: 691 classes.push('customHoverBg3'); 692 break; 693 case 4: 694 classes.push('customHoverBg4'); 695 break; 696 case 5: 697 classes.push('customHoverBg5'); 698 break; 699 case 6: 700 classes.push('customHoverBg6'); 701 break; 702 case 7: 703 classes.push('customHoverBg7'); 704 break; 705 case 8: 706 classes.push('customHoverBg8'); 707 break; 708 } 709 710 711 712 switch (block.buttonBorderColor) { 713 case 1: 714 classes.push('customBorder1'); 715 break; 716 case 2: 717 classes.push('customBorder2'); 718 break; 719 case 3: 720 classes.push('customBorder3'); 721 break; 722 case 4: 723 classes.push('customBorder4'); 724 break; 725 case 5: 726 classes.push('customBorder5'); 727 break; 728 case 6: 729 classes.push('customBorder6'); 730 break; 731 case 7: 732 classes.push('customBorder7'); 733 break; 734 case 8: 735 classes.push('customBorder8'); 736 break; 737 } 738 switch (block.buttonHoverBorderColor) { 739 case 1: 740 classes.push('customHoverBorder1'); 741 break; 742 case 2: 743 classes.push('customHoverBorder2'); 744 break; 745 case 3: 746 classes.push('customHoverBorder3'); 747 break; 748 case 4: 749 classes.push('customHoverBorder4'); 750 break; 751 case 5: 752 classes.push('customHoverBorder5'); 753 break; 754 case 6: 755 classes.push('customHoverBorder6'); 756 break; 757 case 7: 758 classes.push('customHoverBorder7'); 759 break; 760 case 8: 761 classes.push('customHoverBorder8'); 762 break; 763 } 764 return classes.join(" "); 765 } 766 767 $scope.formatFont = function (fonttext) { 768 if (fonttext) { 769 var font = fonttext.replace(/\+/g, ' ').split(':'); 770 771 return font[0]; 772 } else { 773 return "No font selected"; 774 } 775 } 776 777 $scope.handleClick = function (widget) { 778 if (widget.buttonType == 1) { 779 location.href = $scope.sitePrefix+"/" + widget.buttonUrl; 780 } else { 781 window.open(widget.buttonUrl, "_blank"); 782 } 783 } 784 785 $scope.messageMembers = []; 786 787 $scope.getMessageMembers = function () { 788 if (!$scope.isMember) { 789 return; 790 } 791 $scope.ajaxCall('/Customer/GetCustomerMembersForMessaging', { customerId: $scope.sitedata.customerId }, function (data) { 792 $scope.messageMembers = data; 793 794 }, function () { 795 796 }, false); 797 } 798 799 $scope.tagMembers = []; 800 801 $scope.getTagMembers = function () { 802 if (!$scope.isMember) { 803 return; 804 } 805 $scope.ajaxCall('/Customer/GetCustomerTagMembers', { customerId: $scope.sitedata.customerId }, function (data) { 806 $scope.tagMembers = data; 807 808 }, function () { 809 810 }, false); 811 } 812 813 $scope.joinApplyCommittee = function (committee) { 814 if (!$scope.isMember) { 815 return; 816 } 817 818 if (committee.formId) { 819 $scope.applyCommittee(committee); 820 } else { 821 $scope.joinCommittee(committee); 822 } 823 } 824 825 $scope.joinCommittee = function (committee) { 826 if (!$scope.isMember) { 827 return; 828 } 829 $uibModal.open({ 830 templateUrl: 'join-committee-modal', 831 controller: function ($scope, $timeout) { 832 $scope.join = function () { 833 $scope.$close(); 834 } 835 }, 836 backdrop: 'static', 837 resolve: { 838 } 839 }).result.then(function () { 840 $scope.ajaxCall('/Sites/JoinCommittee', { customerId: $scope.sitedata.customerId, committeeId: committee.committeeId }, function (data) { 841 $scope.getCommittees();
842 }); 843 }, function () { 844 845 }); 846 } 847 848 $scope.applyCommittee = function (committee) { 849 if (!$scope.isMember) { 850 return; 851 } 852 $uibModal.open({ 853 templateUrl: 'apply-committee-modal', 854 controller: function ($scope, $timeout, formId, customerId, committeeId) { 855 $scope.customerId = customerId; 856 $scope.committeeId = committeeId; 857 $scope.formId = null; 858 $scope.formdata = null; 859 860 $scope.initMultipleUpload = function () { 861 $timeout(function () { 862 jQuery('.customMultipleUpload').each(function () { 863 jQuery(this).find('input').prop('multiple', true); 864 }); 865 866 }, 50); 867 } 868 869 $scope.file = null; 870 871 $scope.inUpload = false; 872 $scope.startFileUpload = function (files) { 873 $scope.inUpload = true; 874 }; 875 876 $scope.successFileUploadCustomMultiple = function (response, field) { 877 $scope.inUpload = false; 878 if (response.data.success) { 879 880 if (!field.attachments) { 881 field.attachments = []; 882 } 883 angular.forEach(response.data.results, function (result) { 884 var folderFile = {}; 885 folderFile.uploadedFileId = result.fileId; 886 folderFile.sizeInt = result.fileSizeBytes; 887 folderFile.name = result.fileName; 888 folderFile.type = result.fileType; 889 890 891 field.attachments.push(folderFile); 892 }); 893 } else { 894 $scope.errorMessage('One or more files exceeds the maximum file size of 15MB.'); 895 } 896 }; 897 898 $scope.removeFormFile = function (index, field) { 899 field.attachments.splice(index, 1); 900 } 901 902 $scope.imageSrc = function (fileId) { 903 if (fileId != null) { 904 return '/File/Get/' + fileId; 905 } 906 return null; 907 }; 908 909 $scope.ajaxCall('/Customer/GetFormSetupPublic', { customerId: $scope.customerId, formId: formId }, function (data) { 910 $scope.formdata = data; 911 }); 912 913 $scope.submitApplication = function () { 914 $scope.customAnswers = []; 915 916 jQuery('#applicationForm' + ' .customFormItem').each(function () { 917 $scope.customAnswers.push({ questionId: jQuery(this).attr('data-id'), answer: jQuery(this).val() }); 918 }); 919 920 jQuery('#applicationForm' + ' .checkboxGroup').each(function () { 921 var vals = []; 922 var questionId = ""; 923 924 jQuery(this).find('.customFormCheckbox').each(function () { 925 if (jQuery(this).prop('checked')) { 926 var dataval = jQuery(this).val().split('|'); 927 questionId = dataval[0]; 928 vals.push(dataval[1].split(",").join("|")); 929 } 930 }); 931 932 $scope.customAnswers.push({ questionId: questionId, answer: vals.join(', ') }); 933 934 }); 935 jQuery('#applicationForm' + ' .customFormRadio').each(function () { 936 if (jQuery(this).prop('checked')) { 937 var dataval = jQuery(this).val().split('|'); 938 $scope.customAnswers.push({ questionId: dataval[0], answer: dataval[1] }); 939 } 940 }); 941 942 $scope.loopfailed = false; 943 944 angular.forEach($scope.formdata.sections, function (section) { 945 angular.forEach(section.questions, function (question) { 946 if (question.required) { 947 var failed = true; 948 949 950 if (question.questionControlType == 8) { 951 if (!question.attachments) { 952 question.isInvalid = true; 953 } else { 954 if (!question.attachments.length) { 955 question.isInvalid = true; 956 } else { 957 958 var answer = ""; 959 angular.forEach(question.attachments, function (attachment) { 960 961 if (answer != "") { 962 answer += ","; 963 } 964 answer += attachment.uploadedFileId; 965 }); 966 967 $scope.customAnswers.push({ questionId: question.questionId, answer: answer, isUpload: true });
968 failed = false; 969 } 970 } 971 972 973 } else { 974 975 angular.forEach($scope.customAnswers, function (answer) { 976 question.isInvalid = true; 977 if (answer.questionId == question.questionId && answer.answer.length > 0) { 978 failed = false; 979 question.isInvalid = false; 980 } 981 }); 982 if (question.min != null || question.max != null) { 983 angular.forEach($scope.customAnswers, function (answer) { 984 if (answer.questionId == question.questionId && answer.answer.length > 0) { 985 var arr = answer.answer.split(','); 986 var count = arr.length; 987 if (question.min != null) { 988 if (count < question.min) { 989 question.incorrectMinMax = true; 990 failed = true; 991 } 992 } 993 if (question.max != null) { 994 if (count > question.max) { 995 question.incorrectMinMax = true; 996 failed = true; 997 } 998 999 } 1000 } 1001 }); 1002 } 1003 } 1004 if (failed) { 1005 $scope.loopfailed = true; 1006 } 1007 } else { 1008 if (question.questionControlType == 8) { 1009 if (!question.attachments) { 1010 //do nothing 1011 } else { 1012 if (!question.attachments.length) { 1013 //do nothing 1014 } else { 1015 1016 var answer = ""; 1017 angular.forEach(question.attachments, function (attachment) { 1018 1019 if (answer != "") { 1020 answer += ","; 1021 } 1022 answer += attachment.uploadedFileId; 1023 }); 1024 1025 $scope.customAnswers.push({ questionId: question.questionId, answer: answer, isUpload: true }); 1026 failed = false; 1027 } 1028 } 1029 1030 1031 } 1032 } 1033 }); 1034 }); 1035 1036 if ($scope.loopfailed) { 1037 $scope.submitAttempt = true; 1038 return; 1039 } 1040 $scope.submitAttempt = false; 1041 1042 $scope.ajaxCall('/Sites/SubmitCommitteeApplication', { customerId: $scope.customerId, committeeId: $scope.committeeId, data: $scope.customAnswers }, function (data) {
1043 alert("Thank you for submitting our form. We will get back with you"); 1044 $scope.$close(); 1045 }); 1046 } 1047 }, 1048 backdrop: 'static', 1049 size: 'lg', 1050 resolve: { 1051 formId: function () { 1052 return committee.formId; 1053 }, 1054 customerId: function () { 1055 return $scope.sitedata.customerId; 1056 }, 1057 committeeId: function () { 1058 return committee.committeeId; 1059 } 1060 } 1061 }).result.then(function () { 1062 $scope.getCommittees(); 1063 }, function () { 1064 1065 }); 1066 } 1067 1068 $scope.loadUrls = function () { 1069 //Set Amenities Url 1070 $scope.ajaxCall('/Amenity/GetAmenitiesUrl', { customerId: $scope.sitedata.customerId }, function (data) { 1071 $scope.amenitiesUrl = data; 1072 }); 1073 1074 //Set Committees Url 1075 $scope.ajaxCall('/Sites/GetCommitteesUrl', { customerId: $scope.sitedata.customerId }, function (data) { 1076 $scope.committeesUrl = data; 1077 }); 1078 1079 //Set Dues Url 1080 $scope.ajaxCall('/Customer/GetDuesUrl', { customerId: $scope.sitedata.customerId }, function (data) { 1081 $scope.duesUrl = data; 1082 }); 1083 1084 //Set Events Url 1085 $scope.ajaxCall('/Sites/GetEventsUrl', { customerId: $scope.sitedata.customerId }, function (data) { 1086 $scope.eventsUrl = data; 1087 }); 1088 1089 //Set Directory Url 1090 $scope.ajaxCall('/Sites/GetDirectoryUrl', { customerId: $scope.sitedata.customerId }, function (data) { 1091 $scope.directoryUrl = data; 1092 }); 1093 1094 //Set Documents Url 1095 $scope.ajaxCall('/Sites/GetDocumentsUrl', { customerId: $scope.sitedata.customerId }, function (data) { 1096 $scope.documentsUrl = data; 1097 }); 1098 1099 //Set Newsfeed Url 1100 $scope.ajaxCall('/Sites/GetNewsfeedUrl', { customerId: $scope.sitedata.customerId }, function (data) { 1101 $scope.newsfeedUrl = data; 1102 }); 1103 1104 $scope.getLogoId(); 1105 1106 if ($scope.formType != null) { 1107 $scope.ajaxCall('/Customer/GetMemberDashboardFormsByType', { customerId: $scope.sitedata.customerId, formType: $scope.formType }, function (data) { 1108 $scope.dashFormList = data; 1109 }); 1110 } 1111 1112 if ($scope.takeFormId != null) { 1113 $scope.ajaxCall('/Customer/GetFormSetupPublic', { customerId: $scope.sitedata.customerId, formId: $scope.takeFormId }, function (data) { 1114 $scope.takeFormData = data; 1115 $scope.blankWidget = { 1116 widgetId: "takeForm", 1117 formdata: $scope.takeFormData, 1118 formReset: data, 1119 }; 1120 }, function () { 1121 1122 }, false); 1123 } 1124 } 1125 1126 1127 1128 $scope.committees = []; 1129 $scope.mycommittees = []; 1130 $scope.committeesUrl = ''; 1131 1132 $scope.gotCommittees = false; 1133 $scope.getCommittees = function () { 1134 1135 if ($scope.gotCommittees) { 1136 return; 1137 } 1138 if (!$scope.isMember) { 1139 return; 1140 } 1141 1142 $scope.gotCommittees = true; 1143 $scope.ajaxCall('/Committee/GetSiteCommittees/', { customerId: $scope.sitedata.customerId }, function (data) { 1144 $scope.committees = data; 1145 }); 1146 $scope.ajaxCall('/Committee/GetMyCommittees/', { customerId: $scope.sitedata.customerId }, function (data) { 1147 $scope.mycommittees = data; 1148 }); 1149 $scope.ajaxCall('/Sites/GetCommitteesUrl', { customerId: $scope.sitedata.customerId }, function (data) { 1150 $scope.committeesUrl = data; 1151 }); 1152 1153 } 1154 1155 $scope.myamenities = []; 1156 $scope.amenitiesUrl = ''; 1157 $scope.getMyAmenities = function () { 1158 if (!$scope.isMember) { 1159 return; 1160 } 1161 $scope.ajaxCall('/Amenity/GetMyReservations/', { customerId: $scope.sitedata.customerId }, function (data) { 1162 $scope.myamenities = data; 1163 }); 1164 $scope.ajaxCall('/Amenity/GetAmenitiesUrl', { customerId: $scope.sitedata.customerId }, function (data) { 1165 $scope.amenitiesUrl = data; 1166 }); 1167 } 1168 1169 $scope.events = []; 1170 $scope.myevents = []; 1171 $scope.upcomingevents = []; 1172 $scope.eventsUrl = ''; 1173 1174 $scope.getMyEvents = function () { 1175 if (!$scope.isMember) { 1176 return; 1177 } 1178 1179 $scope.ajaxCall('/Event/GetMyEvents/', { customerId: $scope.sitedata.customerId }, function (data) { 1180 $scope.myevents = data; 1181 }, function () { 1182 1183 }, false); 1184 $scope.ajaxCall('/Sites/GetEventsUrl', { customerId: $scope.sitedata.customerId }, function (data) { 1185 $scope.eventsUrl = data; 1186 }, function () { 1187 1188 }, false); 1189 } 1190 1191 $scope.getUpcomingEvents = function () { 1192 $scope.ajaxCall('/Event/GetSiteEvents/', { customerId: $scope.sitedata.customerId }, function (data) { 1193 $scope.upcomingevents = data; 1194 }, function () { 1195 1196 }, false); 1197 $scope.ajaxCall('/Sites/GetEventsUrl', { customerId: $scope.sitedata.customerId }, function (data) { 1198 $scope.eventsUrl = data; 1199 }, function () { 1200 1201 }, false); 1202 } 1203 1204 $scope.eventSearch = { name: '', start: '', end: '', location: '' }; 1205 1206 $scope.clearEventSearch = function () { 1207 $scope.eventSearch = { name: '', start: '', end: '', location: '' }; 1208 $scope.getEvents(); 1209 } 1210 1211 1212 $scope.editSponsorImage = function () { 1213 $uibModal.open({ 1214 templateUrl: 'edit-sponsor-image-modal', 1215 size: 'lg', 1216 controller: function ($scope, $timeout, eventRegistration) { 1217 1218 1219 $scope.file = null; 1220 $scope.uploadImageId = null; 1221 1222 $scope.uploadImageId = eventRegistration.sponsorImageId; 1223 1224 $scope.uploadFileName = ''; 1225 1226 1227 $scope.cropimage = null; 1228 1229 $scope.inUpload = false; 1230 $scope.startFileUpload = function (files) { 1231 $scope.inUpload = true; 1232 }; 1233 1234 $scope.cropperdata = { imageId: null, positionX: 0, positionY: 0, newWidth: 0, newHeight: 350, imageData: '' } 1235 $scope.successFileUpload = function (response) { 1236 if (response.data.success) { 1237 $scope.file = response.data.results[0]; 1238 $scope.uploadImageId = $scope.file.fileId; 1239 $scope.uploadFileName = $scope.file.fileName; 1240 1241 $timeout(function () { 1242 $scope.cropimage = jQuery('#cropImage'); 1243 $scope.cropimage.cropper('destroy'); 1244 1245 $scope.cropimage.cropper({ 1246 viewMode: 2, 1247 autoCropArea: 1, 1248 aspectRatio: NaN, 1249 minContainerHeight: 200, 1250 minContainerWidth: 500, 1251 minCanvasHeight: 200, 1252 minCanvasWidth: 500, 1253 crop: function (event) { 1254 $scope.cropperdata.positionX = event.detail.x; 1255 $scope.cropperdata.positionY = event.detail.y; 1256 $scope.cropperdata.newWidth = event.detail.width; 1257 $scope.cropperdata.newHeight = event.detail.height; 1258 1259 } 1260 }); 1261 $scope.inUpload = false; 1262 1263 }, 100); 1264 1265 } else { 1266 $scope.inUpload = false; 1267 1268 $scope.errorMessage('Your file exceeds the maximum file size of 15MB.'); 1269 } 1270 }; 1271 1272 $scope.imageSrc = function (fileId) { 1273 if (fileId != null) { 1274 return '/File/Get/' + fileId; 1275 } 1276 return null; 1277 }; 1278 1279 $scope.removeFile = function () { 1280 $scope.file = null; 1281 } 1282
1283 $scope.saveChanges = function () { 1284 $scope.cropperdata.imageId = $scope.uploadImageId; 1285 1286 $scope.ajaxCall('/File/CropImage', { data: $scope.cropperdata }, function (data) { 1287 $scope.$close({ imageId: data, imageName: $scope.uploadFileName }); 1288 }); 1289 1290 }; 1291 }, 1292 backdrop: 'static', 1293 resolve: { 1294 eventRegistration: function () { 1295 return $scope.eventRegistration; 1296 }, 1297 } 1298 }).result.then(function (imagedata) { 1299 1300 $scope.eventRegistration.sponsorImageId = imagedata.imageId; 1301 1302 }, function () { 1303 1304 }); 1305 }; 1306 1307 $scope.getQueryVariable = function (variable) { 1308 var query = window.location.search.substring(1); 1309 var vars = query.split("&"); 1310 for (var i = 0; i < vars.length; i++) { 1311 var pair = vars[i].split("="); 1312 if (pair[0] == variable) { return pair[1]; } 1313 } 1314 return (false); 1315 } 1316 1317 $scope.initConversations = function () { 1318 var conversation = $scope.getQueryVariable('conversation'); 1319 if (conversation) { 1320 if (conversation == 'all') { 1321 $scope.showFlyout(); 1322 } else { 1323 $scope.showFlyout(); 1324 angular.forEach($scope.conversations, function (conversationloop) { 1325 1326 if (conversationloop.conversationId == conversation) { 1327 $scope.openConversation(conversationloop); 1328 } 1329 }); 1330 1331 } 1332 } 1333 1334 } 1335 1336 $scope.packageForm = function (package) { 1337 $uibModal.open({ 1338 templateUrl: 'event-form-modal', 1339 controller: function ($scope, $timeout, formId, customerId, package, eventRegistration) { 1340 $scope.customerId = customerId; 1341 $scope.package = package; 1342 $scope.eventRegistration = eventRegistration; 1343 $scope.formId = null; 1344 $scope.formdata = null; 1345 1346 1347 $scope.initMultipleUpload = function () { 1348 $timeout(function () { 1349 jQuery('.customMultipleUpload').each(function () { 1350 jQuery(this).find('input').prop('multiple', true); 1351 }); 1352 1353 }, 50); 1354 } 1355 1356 1357 $scope.file = null; 1358 1359 $scope.inUpload = false; 1360 $scope.startFileUpload = function (files) { 1361 $scope.inUpload = true; 1362 }; 1363 1364 $scope.successFileUploadCustomMultiple = function (response, field) { 1365 $scope.inUpload = false; 1366 if (response.data.success) { 1367 1368 if (!field.attachments) { 1369 field.attachments = []; 1370 } 1371 angular.forEach(response.data.results, function (result) { 1372 var folderFile = {}; 1373 folderFile.uploadedFileId = result.fileId; 1374 folderFile.sizeInt = result.fileSizeBytes; 1375 folderFile.name = result.fileName; 1376 folderFile.type = result.fileType; 1377 1378 1379 field.attachments.push(folderFile); 1380 }); 1381 } else { 1382 $scope.errorMessage('One or more files exceeds the maximum file size of 15MB.'); 1383 } 1384 }; 1385 1386 $scope.removeFormFile = function (index, field) { 1387 field.attachments.splice(index, 1); 1388 } 1389 1390 $scope.imageSrc = function (fileId) { 1391 if (fileId != null) { 1392 return '/File/Get/' + fileId; 1393 } 1394 return null; 1395 }; 1396 1397 1398 $scope.ajaxCall('/Customer/GetFormSetupPublic', { customerId: $scope.customerId, formId: formId }, function (data) { 1399 $scope.formdata = data; 1400 $timeout(function () { 1401 if ($scope.eventRegistration.packageFormData) { 1402 angular.forEach($scope.eventRegistration.packageFormData, function (answer) { 1403 jQuery('.customFormItem').each(function () { 1404 if (jQuery(this).attr('data-id') == answer.questionId) { 1405 jQuery(this).val(answer.answer); 1406 } 1407 }); 1408 1409 var radioval = answer.questionId + '|' + answer.answer; 1410 var split = answer.answer.split(', '); 1411 1412 angular.forEach(split, function (uniqueanswer) { 1413 var checkboxval = answer.questionId + '|' + uniqueanswer; 1414 jQuery('.customFormCheckbox').each(function () { 1415 if (jQuery(this).val() == checkboxval) { 1416 jQuery(this).prop('checked', true); 1417 } 1418 }); 1419 1420 }); 1421 1422 jQuery('.customFormRadio').each(function () { 1423 if (jQuery(this).val() == radioval) { 1424 jQuery(this).prop('checked', true); 1425 } 1426 }); 1427 }); 1428 1429 1430 } 1431 }, 50); 1432 }); 1433 1434 $scope.submitApplication = function () { 1435 $scope.customAnswers = []; 1436 1437 jQuery('#applicationForm' + ' .customFormItem').each(function () { 1438 $scope.customAnswers.push({ questionId: jQuery(this).attr('data-id'), answer: jQuery(this).val() }); 1439 }); 1440 1441 jQuery('#applicationForm' + ' .checkboxGroup').each(function () { 1442 var vals = []; 1443 var questionId = ""; 1444 1445 jQuery(this).find('.customFormCheckbox').each(function () { 1446 if (jQuery(this).prop('checked')) { 1447 var dataval = jQuery(this).val().split('|'); 1448 questionId = dataval[0]; 1449 vals.push(dataval[1].split(",").join("|")); 1450 } 1451 }); 1452 1453 $scope.customAnswers.push({ questionId: questionId, answer: vals.join(', ') }); 1454 1455 }); 1456 jQuery('#applicationForm' + ' .customFormRadio').each(function () { 1457 if (jQuery(this).prop('checked')) { 1458 var dataval = jQuery(this).val().split('|'); 1459 $scope.customAnswers.push({ questionId: dataval[0], answer: dataval[1] }); 1460 } 1461 }); 1462 1463 $scope.loopfailed = false; 1464 1465 angular.forEach($scope.formdata.sections, function (section) { 1466 angular.forEach(section.questions, function (question) { 1467 if (question.required) { 1468 var failed = true; 1469 1470 1471 if (question.questionControlType == 8) { 1472 if (!question.attachments) { 1473 question.isInvalid = true; 1474 } else { 1475 if (!question.attachments.length) { 1476 question.isInvalid = true; 1477 } else { 1478 1479 var answer = ""; 1480 angular.forEach(question.attachments, function (attachment) { 1481 1482 if (answer != "") { 1483 answer += ","; 1484 } 1485 answer += attachment.uploadedFileId; 1486 }); 1487 1488 $scope.customAnswers.push({ questionId: question.questionId, answer: answer, isUpload: true });
1489 failed = false; 1490 } 1491 } 1492 1493 1494 } else { 1495 1496 angular.forEach($scope.customAnswers, function (answer) { 1497 question.isInvalid = true; 1498 if (answer.questionId == question.questionId && answer.answer.length > 0) { 1499 failed = false; 1500 question.isInvalid = false; 1501 } 1502 }); 1503 if (question.min != null || question.max != null) { 1504 angular.forEach($scope.customAnswers, function (answer) { 1505 if (answer.questionId == question.questionId && answer.answer.length > 0) { 1506 var arr = answer.answer.split(','); 1507 var count = arr.length; 1508 if (question.min != null) { 1509 if (count < question.min) { 1510 question.incorrectMinMax = true; 1511 failed = true; 1512 } 1513 } 1514 if (question.max != null) { 1515 if (count > question.max) { 1516 question.incorrectMinMax = true; 1517 failed = true; 1518 } 1519 1520 } 1521 } 1522 }); 1523 } 1524 } 1525 if (failed) { 1526 $scope.loopfailed = true; 1527 } 1528 } else { 1529 if (question.questionControlType == 8) { 1530 if (!question.attachments) { 1531 //do nothing 1532 } else { 1533 if (!question.attachments.length) { 1534 //do nothing 1535 } else { 1536 1537 var answer = ""; 1538 angular.forEach(question.attachments, function (attachment) { 1539 1540 if (answer != "") { 1541 answer += ","; 1542 } 1543 answer += attachment.uploadedFileId; 1544 }); 1545 1546 $scope.customAnswers.push({ questionId: question.questionId, answer: answer, isUpload: true }); 1547 failed = false; 1548 } 1549 } 1550 1551 1552 } 1553 } 1554 }); 1555 }); 1556 1557 if ($scope.loopfailed) { 1558 $scope.submitAttempt = true; 1559 return; 1560 } 1561 $scope.submitAttempt = false; 1562 1563 $scope.$close($scope.customAnswers); 1564 } 1565 }, 1566 backdrop: 'static', 1567 size: 'lg', 1568 resolve: { 1569 formId: function () { 1570 return package.forms; 1571 }, 1572 customerId: function () { 1573 return $scope.sitedata.customerId; 1574 }, 1575 package: function () { 1576 return package; 1577 }, 1578 eventRegistration: function () { 1579 return $scope.eventRegistration; 1580 }, 1581 } 1582 }).result.then(function (answers) { 1583 $scope.eventRegistration.packageFormData = answers; 1584 }, function () { 1585 1586 }); 1587 } 1588 1589 $scope.viewCommitteeMembers = function (committee) { 1590 $uibModal.open({ 1591 templateUrl: 'committee-members-modal', 1592 controller: function ($scope, $timeout, committee) { 1593 $scope.committee = committee; 1594 1595 }, 1596 backdrop: 'static', 1597 size: 'lg', 1598 resolve: { 1599 committee: function () { 1600 return committee; 1601 }, 1602 } 1603 }).result.then(function (answers) { 1604 1605 }, function () { 1606 1607 }); 1608 } 1609 1610 $scope.initiateOneTimeChargeModal = function (charge) { 1611 $uibModal.open({ 1612 templateUrl: 'one-time-charge-modal', 1613 controller: function ($scope, $timeout, charge, parentScope, customerId, sitedata, user) { 1614 $scope.charge = charge; 1615 $scope.customerId = customerId; 1616 $scope.sitedata = sitedata; 1617 1618 $scope.payment = { chargeId: $scope.charge.chargeId, userId: null, amount: "1.00", numberOfPurchases: 1, country: 1, submissionId: null, paymentComments: "" }; 1619 $scope.isMember = false; 1620 if (parentScope.currentUser) { 1621 $scope.isMember = true; 1622 $scope.payment.userId = parentScope.currentUser.userId;
1623 $scope.payment.firstName = parentScope.currentUser.firstName; 1624 $scope.payment.lastName = parentScope.currentUser.lastName; 1625 $scope.payment.emailAddress = parentScope.currentUser.emailAddress; 1626 $scope.payment.phoneNumber = parentScope.currentUser.phone; 1627 $scope.payment.address1 = parentScope.currentUser.address1; 1628 $scope.payment.city = parentScope.currentUser.city; 1629 $scope.payment.stateId = parentScope.currentUser.state; 1630 $scope.payment.zip = parentScope.currentUser.zip; 1631 } 1632 1633 $scope.$watch('payment.amount', function (input) { 1634 if ($scope.payment.amount != null && input != null && $scope.payment.amount != 0) { 1635 $scope.payment.amount = input.replace(/[^0-9\\.]+/g, ''); 1636 1637 if ($scope.payment.amount < 0) { 1638 $scope.payment.amount = 0; 1639 } 1640 } 1641 }); 1642 1643 $scope.validateNumberOfPurchases = function () { 1644 if ($scope.payment.numberOfPurchases != null) { 1645 1646 if ($scope.payment.numberOfPurchases < 1) { 1647 $scope.payment.numberOfPurchases = 1; 1648 } 1649 } else { 1650 1651 $scope.payment.numberOfPurchases = 1; 1652 } 1653 } 1654 1655 1656 $scope.calculateChargeAmount = function (payment, charge, wallet) { 1657 var charge = $scope.charge.amount; 1658 if ($scope.charge.isFlexiblePaymentsEnabled) { 1659 if ($scope.payment.amount != null) { 1660 if (!isNaN($scope.payment.amount)) { 1661 charge = $scope.payment.amount; 1662 } else { 1663 charge = 0; 1664 } 1665 } 1666 } 1667 1668 return $scope.formatMoney(parseFloat(charge) * parseFloat($scope.payment.numberOfPurchases)); 1669 } 1670 1671 $scope.calculateSalesTaxAmount = function (payment, charge, wallet) { 1672 var charge = $scope.charge.amount; 1673 if ($scope.charge.isFlexiblePaymentsEnabled) { 1674 if ($scope.payment.amount != null) { 1675 if (!isNaN($scope.payment.amount)) { 1676 charge = $scope.payment.amount; 1677 } else { 1678 charge = 0; 1679 } 1680 } 1681 } 1682 1683 //charge -= $scope.calculateTotalWalletPaymentAmount(payment, charge, wallet); 1684 1685 1686 return $scope.formatMoney(((parseFloat(charge) * parseFloat($scope.payment.numberOfPurchases)) / 100) * parseFloat($scope.charge.salesTaxPercentage)); 1687 } 1688 1689 $scope.calculateServiceFeeAmount = function (payment, charge, wallet) { 1690 var charge = $scope.charge.amount; 1691 if ($scope.charge.isFlexiblePaymentsEnabled) { 1692 if ($scope.payment.amount != null) { 1693 if (!isNaN($scope.payment.amount)) { 1694 charge = $scope.payment.amount; 1695 } else { 1696 charge = 0; 1697 } 1698 } 1699 } 1700 1701 var charges = charge * $scope.payment.numberOfPurchases; 1702 1703 if ($scope.charge.isSalesTaxEnabled) { 1704 var salesTax = ((charge * $scope.payment.numberOfPurchases) / 100) * $scope.charge.salesTaxPercentage; 1705 charges += salesTax; 1706 } 1707 1708 charges -= $scope.calculateTotalWalletPaymentAmount(payment, charge, wallet); 1709 1710 if (charges <= 0) { 1711 return "$0.00"; 1712 } 1713 1714 1715 if ($scope.isMember) { 1716 if (!$scope.charge.paymentMethod) { 1717 return "TBD"; 1718 } 1719 var paymentMethodIndex = $scope.charge.paymentMethods.map(function (e) { return e.paymentMethodId }).indexOf($scope.charge.paymentMethod); 1720 if (paymentMethodIndex == -1) { 1721 return "TBD"; 1722 } 1723 1724 if ($scope.charge.paymentMethods[paymentMethodIndex].isAch) { 1725 return '$' + $scope.formatMoney((charges + parseFloat(($scope.charge.convenienceFeeDollarAmountPlaid ? parseFloat($scope.charge.convenienceFeeDollarAmountPlaid) : 0))) / (1 - (parseFloat(($scope.charge.convenienceFeePercentagePlaid ? $scope.charge.convenienceFeePercentagePlaid : 0)) / 100)) - charges); 1726 } else { 1727 return '$' + $scope.formatMoney((charges + parseFloat(($scope.charge.serviceFeeAmount ? parseFloat($scope.charge.serviceFeeAmount) : 0))) / (1 - (parseFloat(($scope.charge.serviceFeePercentage ? $scope.charge.serviceFeePercentage : 0)) / 100)) - charges); 1728 } 1729 1730 } else { 1731 return '$' + $scope.formatMoney((charges + parseFloat(($scope.charge.serviceFeeAmount ? parseFloat($scope.charge.serviceFeeAmount) : 0))) / (1 - (parseFloat(($scope.charge.serviceFeePercentage ? $scope.charge.serviceFeePercentage : 0)) / 100)) - charges); 1732 } 1733 } 1734 1735 $scope.calculateTotalPaymentAmount = function (payment, charge, wallet) { 1736 var charge = $scope.charge.amount; 1737 if ($scope.charge.isFlexiblePaymentsEnabled) { 1738 if ($scope.payment.amount != null) { 1739 if (!isNaN($scope.payment.amount)) { 1740 charge = $scope.payment.amount; 1741 } else { 1742 charge = 0; 1743 } 1744 } 1745 } 1746 1747 var charges = charge * $scope.payment.numberOfPurchases; 1748 1749 if ($scope.charge.isSalesTaxEnabled) { 1750 var salesTax = ((charge * $scope.payment.numberOfPurchases) / 100) * $scope.charge.salesTaxPercentage; 1751 charges += salesTax; 1752 } 1753 1754 charges -= $scope.calculateTotalWalletPaymentAmount(payment, charge, wallet); 1755 1756 if (charges <= 0) { 1757 return 0; 1758 } 1759 1760 if ($scope.charge.isServiceFeeEnabled) { 1761 1762 if ($scope.isMember) { 1763 if (!$scope.charge.paymentMethod) { 1764 return "TBD"; 1765 } 1766 var paymentMethodIndex = $scope.charge.paymentMethods.map(function (e) { return e.paymentMethodId }).indexOf($scope.charge.paymentMethod); 1767 if (paymentMethodIndex == -1) { 1768 return "TBD"; 1769 } 1770 1771 if ($scope.charge.paymentMethods[paymentMethodIndex].isAch) { 1772 charges = (charges + parseFloat(($scope.charge.convenienceFeeDollarAmountPlaid ? parseFloat($scope.charge.convenienceFeeDollarAmountPlaid) : 0))) / (1 - (parseFloat(($scope.charge.convenienceFeePercentagePlaid ? $scope.charge.convenienceFeePercentagePlaid : 0)) / 100)); 1773 } else { 1774 charges = (charges + parseFloat(($scope.charge.serviceFeeAmount ? parseFloat($scope.charge.serviceFeeAmount) : 0))) / (1 - (parseFloat(($scope.charge.serviceFeePercentage ? $scope.charge.serviceFeePercentage : 0)) / 100)); 1775 } 1776 1777 } else { 1778 charges = (charges + parseFloat(($scope.charge.serviceFeeAmount ? parseFloat($scope.charge.serviceFeeAmount) : 0))) / (1 - (parseFloat(($scope.charge.serviceFeePercentage ? $scope.charge.serviceFeePercentage : 0)) / 100)); 1779 } 1780 } 1781 1782 return '$' + $scope.formatMoney(charges); 1783 } 1784 1785 1786 $scope.calculateTotalWalletPaymentAmount = function (payment, charge, wallet) { 1787 var charge = $scope.charge.amount; 1788 if ($scope.charge.isFlexiblePaymentsEnabled) { 1789 if ($scope.payment.amount != null) { 1790 if (!isNaN($scope.payment.amount)) { 1791 charge = $scope.payment.amount; 1792 } else { 1793 charge = 0; 1794 } 1795 } 1796 } 1797 1798 var charges = charge * $scope.payment.numberOfPurchases; 1799 1800 if ($scope.charge.isSalesTaxEnabled) { 1801 var salesTax = ((charge * $scope.payment.numberOfPurchases) / 100) * $scope.charge.salesTaxPercentage; 1802 charges += salesTax; 1803 } 1804 1805 if (wallet != null) { 1806 var available = charges - wallet.balanceAmount; 1807 if (available < 0) { 1808 return charges; 1809 } else { 1810 return wallet.balanceAmount; 1811 } 1812 } 1813 1814 1815 return 0; 1816 } 1817 1818 $scope.chargeForm = function (payment, charge) { 1819 $uibModal.open({ 1820 templateUrl: 'charge-form-modal', 1821 controller: function ($scope, $timeout, formId, customerId, payment) { 1822 $scope.customerId = customerId; 1823 $scope.payment = payment; 1824 $scope.formId = null; 1825 $scope.formdata = null; 1826 1827 $scope.initMultipleUpload = function () { 1828 $timeout(function () { 1829 jQuery('.customMultipleUpload').each(function () { 1830 jQuery(this).find('input').prop('multiple', true); 1831 }); 1832 1833 }, 50); 1834 } 1835 1836 1837 $scope.file = null; 1838 1839 $scope.inUpload = false; 1840 $scope.startFileUpload = function (files) { 1841 $scope.inUpload = true; 1842 }; 1843 1844 $scope.successFileUploadCustomMultiple = function (response, field) { 1845 $scope.inUpload = false; 1846 if (response.data.success) { 1847 1848 if (!field.attachments) { 1849 field.attachments = []; 1850 } 1851 angular.forEach(response.data.results, function (result) { 1852 var folderFile = {}; 1853 folderFile.uploadedFileId = result.fileId; 1854 folderFile.sizeInt = result.fileSizeBytes; 1855 folderFile.name = result.fileName; 1856 folderFile.type = result.fileType; 1857 1858 1859 field.attachments.push(folderFile); 1860 }); 1861 } else { 1862 $scope.errorMessage('One or more files exceeds the maximum file size of 15MB.'); 1863 } 1864 }; 1865 1866 $scope.removeFormFile = function (index, field) { 1867 field.attachments.splice(index, 1); 1868 } 1869 1870 $scope.imageSrc = function (fileId) { 1871 if (fileId != null) { 1872 return '/File/Get/' + fileId; 1873 } 1874 return null; 1875 }; 1876 1877 $scope.ajaxCall('/Customer/GetFormSetupPublic', { customerId: $scope.customerId, formId: formId }, function (data) { 1878 $scope.formdata = data; 1879 $timeout(function () { 1880 if ($scope.payment.formData) { 1881 angular.forEach($scope.payment.formData, function (answer) { 1882 jQuery('.customFormItem').each(function () { 1883 if (jQuery(this).attr('data-id') == answer.questionId) { 1884 jQuery(this).val(answer.answer); 1885 } 1886 }); 1887 1888 var radioval = answer.questionId + '|' + answer.answer; 1889 var split = answer.answer.split(', '); 1890 1891 angular.forEach(split, function (uniqueanswer) { 1892 var checkboxval = answer.questionId + '|' + uniqueanswer; 1893 jQuery('.customFormCheckbox').each(function () { 1894 if (jQuery(this).val() == checkboxval) { 1895 jQuery(this).prop('checked', true); 1896 } 1897 }); 1898 1899 }); 1900 1901 jQuery('.customFormRadio').each(function () { 1902 if (jQuery(this).val() == radioval) { 1903 jQuery(this).prop('checked', true); 1904 } 1905 }); 1906 }); 1907 } 1908 }, 50); 1909 }); 1910 1911 $scope.submitForm = function () { 1912 $scope.customAnswers = []; 1913 1914 jQuery('#applicationForm' + ' .customFormItem').each(function () { 1915 $scope.customAnswers.push({ questionId: jQuery(this).attr('data-id'), answer: jQuery(this).val() }); 1916
1916 }); 1917 1918 jQuery('#applicationForm' + ' .checkboxGroup').each(function () { 1919 var vals = []; 1920 var questionId = ""; 1921 1922 jQuery(this).find('.customFormCheckbox').each(function () { 1923 if (jQuery(this).prop('checked')) { 1924 var dataval = jQuery(this).val().split('|'); 1925 questionId = dataval[0]; 1926 vals.push(dataval[1].split(",").join("|")); 1927 } 1928 }); 1929 1930 $scope.customAnswers.push({ questionId: questionId, answer: vals.join(', ') }); 1931 1932 }); 1933 jQuery('#applicationForm' + ' .customFormRadio').each(function () { 1934 if (jQuery(this).prop('checked')) { 1935 var dataval = jQuery(this).val().split('|'); 1936 $scope.customAnswers.push({ questionId: dataval[0], answer: dataval[1] }); 1937 } 1938 }); 1939 1940 $scope.loopfailed = false; 1941 1942 1943 angular.forEach($scope.formdata.sections, function (section) { 1944 angular.forEach(section.questions, function (question) { 1945 if (question.required) { 1946 var failed = true; 1947 1948 if (question.questionControlType == 8) { 1949 if (!question.attachments) { 1950 question.isInvalid = true; 1951 } else { 1952 if (!question.attachments.length) { 1953 question.isInvalid = true; 1954 } else { 1955 1956 var answer = ""; 1957 angular.forEach(question.attachments, function (attachment) { 1958 1959 if (answer != "") { 1960 answer += ","; 1961 } 1962 answer += attachment.uploadedFileId; 1963 }); 1964 1965 $scope.customAnswers.push({ questionId: question.questionId, answer: answer, isUpload: true }); 1966 failed = false; 1967 } 1968 } 1969 1970 1971 } else { 1972 question.isInvalid = true; 1973 angular.forEach($scope.customAnswers, function (answer) { 1974 if (answer.questionId == question.questionId && answer.answer.length > 0) { 1975 failed = false; 1976 question.isInvalid = false; 1977 } 1978 }); 1979 1980 if (question.min != null || question.max != null) { 1981 angular.forEach($scope.customAnswers, function (answer) { 1982 if (answer.questionId == question.questionId && answer.answer.length > 0) { 1983 var arr = answer.answer.split(','); 1984 var count = arr.length; 1985 if (question.min != null) { 1986 if (count < question.min) { 1987 question.incorrectMinMax = true; 1988 failed = true; 1989 } 1990 } 1991 if (question.max != null) { 1992 if (count > question.max) { 1993 question.incorrectMinMax = true; 1994 failed = true; 1995 } 1996 1997 } 1998 } 1999 }); 2000 } 2001 2002 } 2003 if (failed) { 2004 jQuery('.form-check-input').each(function () { 2005 var aVal = $(this).val(); 2006 var valSplit = aVal.split('|'); 2007 if (valSplit[0] == question.detailId || valSplit[0] == question.questionId) { 2008 $(this).next().addClass('invalid-label'); 2009 } 2010 }); 2011 2012 $scope.loopfailed = true; 2013 jQuery('.custom-feedback[data-id-feedback=' + question.detailId + ']').css('display', 'block'); 2014 jQuery('.customFormItem[data-id=' + question.detailId + ']').addClass("custominvali
2014d"); 2015 jQuery('.customFormItem[data-id=' + question.questionId + ']').addClass("custominvalid"); 2016 jQuery('.custom-feedback[data-id-feedback=' + question.questionId + ']').css('display', 'block'); 2017 } 2018 } else { 2019 if (question.questionControlType == 8) { 2020 if (!question.attachments) { 2021 //do nothing 2022 } else { 2023 if (!question.attachments.length) { 2024 //do nothing 2025 } else { 2026 2027 var answer = ""; 2028 angular.forEach(question.attachments, function (attachment) { 2029 2030 if (answer != "") { 2031 answer += ","; 2032 } 2033 answer += attachment.uploadedFileId; 2034 }); 2035 2036 $scope.customAnswers.push({ questionId: question.questionId, answer: answer, isUpload: true }); 2037 failed = false; 2038 } 2039 } 2040 2041 2042 } 2043 } 2044 }); 2045 }); 2046 2047 2048 if ($scope.loopfailed) { 2049 $scope.submitAttempt = true; 2050 return; 2051 } 2052 $scope.submitAttempt = false; 2053 2054 $scope.$close($scope.customAnswers); 2055 } 2056 }, 2057 backdrop: 'static', 2058 size: 'lg', 2059 resolve: { 2060 formId: function () { 2061 return charge.formId; 2062 }, 2063 customerId: function () { 2064 return $scope.sitedata.customerId; 2065 }, 2066 payment: function () { 2067 return payment; 2068 }, 2069 } 2070 }).result.then(function (answers) { 2071 $scope.payment.formData = answers; 2072 console.log($scope.payment); 2073 }, function () { 2074 2075 }); 2076 } 2077 2078 $scope.makePayment = function () { 2079 $uibModal.open({ 2080 templateUrl: 'one-time-charge-payment-modal', 2081 size: 'lg', 2082 controller: function ($scope, $timeout, charge, payment, parentScope, sitedata, user) { 2083 $scope.sitedata = sitedata; 2084 $scope.charge = charge; 2085 $scope.payment = payment; 2086 $scope.payment.amount = parseFloat($scope.payment.amount); 2087 $scope.parentScope = parentScope; 2088 2089 $scope.countries = null; 2090 $scope.ajaxCall('/Country/CountryList', {}, function (data) { 2091 $scope.countries = data; 2092 }); 2093 2094 $scope.wallets = []; 2095 if (user != null && user.userId != null) { 2096 $scope.ajaxCall('/Wallet/GetMyWallets', { customerId: customerId }, function (data) { 2097 $scope.wallets = data; 2098 }); 2099 } 2100 2101 $scope.selectedWallet = null; 2102 $scope.myWallet = {walletId: null}; 2103 2104 $scope.updateWallet = function () { 2105 $scope.selectedWallet = null; 2106 angular.forEach($scope.wallets, function (wallet) { 2107 if (wallet.walletId == $scope.myWallet.walletId) { 2108 $scope.selectedWallet = wallet; 2109 } 2110 }); 2111 } 2112 2113 $scope.needsPayment = function () { 2114 return true; 2115 if ($scope.selectedWallet != null) { 2116 if ($scope.selectedWallet.balanceAmount >= $scope.payment.amount) { 2117 return false; 2118 } 2119 } 2120 2121 return true; 2122 } 2123 2124 $scope.$watch('payment.phoneNumber', function (input) { 2125 if ($scope.payment.phoneNumber != null && input != null) { 2126 2127 var cleaned = input.replace(/[^0-9\\.]+/g, ''); 2128 var match = cleaned.match(/^(\d{0,3})(\d{0,3})(\d{0,4})$/) 2129 if (match) { 2130 var formattedPhone = match[1]; 2131 if (match[2].length > 0) { 2132 formattedPhone += '-' + match[2]; 2133 } 2134 if (match[3].length > 0) { 2135 formattedPhone += '-' + match[3]; 2136 } 2137 $scope.payment.phoneNumber = formattedPhone.substr(0, 12); 2138 } 2139 } 2140 }); 2141 2142 $scope.$watch('payment.zip', function (input) { 2143 if ($scope.payment.zip != null && input != null) { 2144 $scope.payment.zip = input.replace(/[^0-9\\.]+/g, ''); 2145 } 2146 }); 2147 2148 $scope.paymentStep = 1; 2149 2150 if (charge.paymentMethod) { 2151 $scope.payment.paymentMethod = charge.paymentMethod; 2152 } 2153 2154 $scope.states = []; 2155 $scope.ajaxCall('/State/StateList', {}, function (data) { 2156 $scope.states = data; 2157 }, function () { 2158 2159 }, false); 2160 2161 $scope.loadStripe = function () { 2162 $scope.ajaxCall('/Customer/GetMyStripeCustomerInfo', { customerId: $scope.sitedata.customerId }, function (data) { 2163 $scope.stripeapi = Stripe(data);//stripe dev key, replace with live! 2164 2165 //$scope.loadStripe = function () { 2166 $scope.elements = $scope.stripeapi.elements(); 2167 2168 // Custom styling can be passed to options when creating an Element. 2169 // (Note that this demo uses a wider set of styles than the guide below.) 2170 $scope.style = { 2171 base: { 2172 color: '#32325d', 2173 fontFamily: '"Helvetica Neue", Helvetica, sans-serif', 2174 fontSmoothing: 'antialiased', 2175 fontSize: '16px', 2176 '::placeholder': { 2177 color: '#495057', 2178 }, 2179 border: '1px solid #ced4da', 2180 2181 }, 2182 invalid: { 2183 color: '#fa755a', 2184 iconColor: '#fa755a' 2185 } 2186 }; 2187 2188 $scope.card = $scope.elements.create('card', { style: $scope.style }); 2189 $scope.card.mount('#stripe-card-element'); 2190 }); 2191 } 2192 2193 $scope.backButtonClicked = function () { 2194 if ($scope.paymentStep == 1) { 2195 $scope.$dismiss(); 2196 } else { 2197 $scope.paymentStep = 1; 2198 jQuery('.tempResize').addClass('modal-lg').removeClass('tempResize'); 2199 } 2200 } 2201 2202 $scope.submitAttempt = false; 2203 $scope.invalidForm = false; 2204 $scope.blockSubmit = false; 2205 2206 $scope.submitPayment = function (form) { 2207 console.log(form); 2208 $scope.submitAttempt = true; 2209
2210 if (form.$invalid) { 2211 return; 2212 } 2213 2214 if ($scope.charge.formId != null) { 2215 if (!$scope.payment.formData) { 2216 $scope.invalidForm = true; 2217 return; 2218 } 2219 } 2220 2221 $scope.invalidForm = false; 2222 $scope.submitAttempt = false; 2223 2224 if ($scope.paymentStep == 1) { 2225 if (!parentScope.isMember) { 2226 $scope.stripeapi.createToken($scope.card).then(function (result) { 2227 if (result.error) { 2228 alert("Error processing card"); 2229 return; 2230 } else { 2231 $scope.payment.stripeToken = result.token; 2232 $scope.payment.stripeTokenCard = result.token; 2233 $scope.paymentStep = 2; 2234 jQuery('.modal-lg').addClass('tempResize').removeClass('modal-lg'); 2235 } 2236 }); 2237 } else { 2238 $scope.paymentStep = 2; 2239 jQuery('.modal-lg').addClass('tempResize').removeClass('modal-lg'); 2240 } 2241 2242 return; 2243 } 2244 2245 if ($scope.blockSubmit) { 2246 return; 2247 } 2248 $scope.blockSubmit = true; 2249 2250 $scope.payment.wallet = $scope.selectedWallet; 2251 grecaptcha.execute('6LeBhgskAAAAAE14Yen7FmvsB0LI-rK5DBohK0GX', { action: 'submit' }).then(function (token) { 2252 $scope.ajaxCall('/OneTimeCharge/SubmitOneTimeChargePayment', { customerId: parentScope.customerId, paymentInfo: $scope.payment }, function (data) { 2253 $scope.successMessage("Your payment was successful."); 2254 2255 $scope.blockSubmit = false; 2256 2257 $scope.$close(); 2258 }, function () { 2259 $scope.blockSubmit = false; 2260 2261 }); 2262 }); 2263 } 2264 2265 $scope.manageChargeCards = function () { 2266 console.log("Managing charge cards"); 2267 $uibModal.open({ 2268 size: 'lg', 2269 templateUrl: 'manage-cards-modal', 2270 controller: function ($scope, $timeout, customerId, charge, sitedata, user) { 2271 $scope.charge = charge; 2272 $scope.sitedata = sitedata; 2273 2274 $scope.removeAutopay = true; 2275 2276 $scope.elements = null; 2277 $scope.style = null; 2278 $scope.card = null; 2279 $scope.paymentType = "card"; 2280 $scope.plaidObject = { plaidLinked: fal
2280se }; 2281 2282 $scope.customerId = customerId; 2283 $scope.stripeapi = null; 2284 2285 $scope.stripeApiKey = null; 2286 $scope.ajaxCall('/Customer/GetMyStripeCustomerInfo', { customerId: $scope.customerId }, function (data) { 2287 $scope.stripeapi = Stripe(data);//stripe dev key, replace with live! 2288 $scope.stripeApiKey = data; 2289 2290 //$scope.loadStripe = function () { 2291 $scope.elements = $scope.stripeapi.elements(); 2292 2293 // Custom styling can be passed to options when creating an Element. 2294 // (Note that this demo uses a wider set of styles than the guide below.) 2295 $scope.style = { 2296 base: { 2297 color: '#32325d', 2298 fontFamily: '"Helvetica Neue", Helvetica, sans-serif', 2299 fontSmoothing: 'antialiased', 2300 fontSize: '16px', 2301 '::placeholder': { 2302 color: '#495057', 2303 }, 2304 border: '1px solid #ced4da', 2305 2306 }, 2307 invalid: { 2308 color: '#fa755a', 2309 iconColor: '#fa755a' 2310 } 2311 }; 2312 2313 $scope.card = $scope.elements.create('card', { style: $scope.style }); 2314 $scope.card.mount('#stripe-card-element'); 2315 // } 2316 2317 2318 }); 2319 2320 $scope.paymentMethods = []; 2321 $scope.getPaymentMethods = function () { 2322 $scope.ajaxCall('/Customer/GetMyPaymentMethods', { customerId: $scope.customerId }, function (data) { 2323 $scope.paymentMethods = data; 2324 2325 $timeout(function () { 2326 jQuery('.paymentMethodList').each(function () { 2327 if (jQuery(this).val() == $scope.charge.paymentMethod) { 2328 jQuery(this).prop('checked', true); 2329 } 2330 }); 2331 }, 50) 2332 }); 2333 } 2334 2335 $scope.selectedPaymentMethod = null; 2336 $scope.getPaymentMethods(); 2337 2338 $scope.remove = function (paymentMethodId) { 2339 $uibModal.open({ 2340 templateUrl: 'remove-card-modal', 2341 controller: function ($scope, $timeout) { 2342 $scope.remove = function () { 2343 $scope.$close(); 2344 } 2345 }, 2346 backdrop: 'static', 2347 resolve: { 2348 } 2349 }).result.then(function () { 2350 $scope.ajaxCall('/Customer/RemoveMyPaymentMethod', { customerId: $scope.customerId, paymentMethodId }, function (data) { 2351 $scope.getPaymentMethods(); 2352 }); 2353 }, function () { 2354 2355 }); 2356 } 2357 2358 2359 $scope.errorHappened = false; 2360 $scope.addCard = function () { 2361 if ($scope.paymentType == "card") { 2362 $scope.stripeapi.createToken($scope.card).then(function (result) { 2363 if (result.error) { 2364 $scope.errorHappened = true; 2365 } else { 2366 $scope.errorHappened = false; 2367 $scope.ajaxCall('/Customer/SaveMyPaymentMethod', { customerId: $scope.customerId, paymentMethod: result.token }, function (data) { 2368 $scope.getPaymentMethods(); 2369 $scope.card.clear(); 2370 }); 2371 } 2372 }); 2373 2374 } 2375 else if ($scope.paymentType == "plaid") { 2376 $scope.errorHappened = false; 2377 $scope.ajaxCall('/Customer/SaveMyPaymentMethodPlaid', { customerId: $scope.customerId, plaidObject: $scope.plaidObject }, function (data) { 2378 $scope.getPaymentMethods(); 2379 $scope.card.clear(); 2380 $scope.plaidLinked = false; 2381 }); 2382 } 2383 } 2384 2385 2386 $scope.loadStripeACH = function () { 2387 $scope.pendingAchAccount = ''; 2388 $scope.pendingAchId = ''; 2389 2390 console.log("Started payment setup -- 3"); 2391 $scope.ajaxCall('/Stripe/CreatePaymentSetupIntent', { customerId: $scope.sitedata.customerId }, function (data) { 2392 if (data == "n/a") { 2393 $scope.sitedata.plaidEnabled = false; 2394 //Unable to connect to plaid, don't show it 2395 } else { 2396 $scope.plaidLoaded = true; 2397 2398 2399 var datasplit = data.split('|'); 2400 2401 $scope.stripeapi = Stripe($scope.stripeApiKey, { stripeAccount: datasplit[1] });//stripe dev key, replace with live! 2402 2403 $scope.pendingAchAccount = datasplit[0];
2404 $scope.pendingAchId = datasplit[2]; 2405 2406 // Calling this method will open the instant verification dialog. 2407 $scope.stripeapi.collectBankAccountForSetup({ 2408 clientSecret: datasplit[0], 2409 params: { 2410 payment_method_type: 'us_bank_account', 2411 payment_method_data: { 2412 billing_details: { 2413 name: user.firstName + " " + user.lastName, 2414 email: user.emailAddress, 2415 }, 2416 }, 2417 }, 2418 expand: ['payment_method'], 2419 }) 2420 .then(({ setupIntent, error }) => { 2421 if (error) { 2422 console.error(error.message); 2423 // PaymentMethod collection failed for some reason. 2424 } else if (setupIntent.status === 'requires_payment_method') { 2425 // Customer canceled the hosted verification modal. Present them with other 2426 // payment method type options. 2427 console.log("MEHEHH"); 2428 return; 2429 } else if (setupIntent.status === 'requires_confirmation') { 2430 // We collected an account - possibly instantly verified, but possibly 2431 // manually-entered. Display payment method details and mandate text 2432 // to the customer and confirm the intent once they accept 2433 // the mandate. 2434 console.log("Make mandate"); 2435 //confirmationForm.show(); 2436 $scope.plaidObject.plaidLinked = true; 2437 2438 } 2439 }); 2440 } 2441 2442 $scope.confirmStripeACH = function () { 2443 $scope.stripeapi.confirmUsBankAccountSetup($scope.pendingAchAccount) 2444 .then(({ setupIntent, error }) => { 2445 if (error) { 2446 console.error(error.message); 2447 $scope.errorMessage("Unable to link your account. Please try with a different payment method."); 2448 } else if (setupIntent.status === "requires_payment_method") { 2449 $scope.errorMessage("Unable to link your account. Please try with a different payment method."); 2450 } else if (setupIntent.status === "succeeded") { 2451 $scope.ajaxCall('/Stripe/FinalizePaymentSetupIntent', { customerId: $scope.sitedata.customerId, paymentMethodId: $scope.pendingAchId }, function (data) { 2452 $scope.pendingAchAccount = ''; 2453 $scope.pendingAchId = ''; 2454 2455 $scope.getPaymentMethods(); 2456 $scope.card.clear(); 2457 $scope.plaidObject.plaidLinked = false; 2458 }); 2459 } else if (setupIntent.next_action?.type === "verify_with_microdeposits") { 2460 $scope.errorMessage(""); 2461 } 2462 }); 2463 2464 } 2465 2466 }, function () { 2467 $scope.sitedata.plaidEnabled = false; 2468 2469 return; 2470 }, false); 2471 } 2472 2473 $scope.loadCardPlaid = function () { 2474 $scope.ajaxCall('/Pricing/GetCustomerPlaidToken', { customerId: $scope.sitedata.customerId }, function (data) { 2475 if (data == "n/a") { 2476 $scope.sitedata.plaidEnabled = false; 2477 //Unable to connect to plaid, don't show it 2478 } else { 2479 $scope.plaidLoaded = true; 2480 2481 $scope.eventLinkHandler = Plaid.create({ 2482 env: 'production', 2483 clientName: $scope.sitedata.siteName, 2484 token: data, 2485 product: ['auth'], 2486 apiVersion: 'v2', 2487 selectAccount: true, 2488 onSuccess: function (public_token, metadata) { 2489 // Send the public_token and account ID to your app server.
2490 $scope.plaidObject.plaidtoken = public_token; 2491 $scope.plaidObject.plaidid = metadata.account_id; 2492 $scope.plaidObject.plaidLinked = true; 2493 $scope.plaidObject.plaidInstitution = metadata.institution.name; 2494 $scope.$apply(); 2495 2496 $scope.errorHappened = false; 2497 $scope.ajaxCall('/Customer/SaveMyPaymentMethodPlaid', { customerId: $scope.customerId, plaidObject: $scope.plaidObject }, function (data) { 2498 $scope.getPaymentMethods(); 2499 $scope.card.clear(); 2500 $scope.plaidObject = { plaidLinked: false }; 2501 }, function () { 2502 $scope.plaidObject.plaidtoken = ""; 2503 $scope.plaidObject.plaidid = ""; 2504 $scope.plaidObject.plaidLinked = false; 2505 $scope.plaidObject.plaidInstitution = ""; 2506 }, true); 2507 2508 }, 2509 onExit: function (err, metadata) { 2510 // The user exited the Link flow. 2511 if (err != null) { 2512 // The user encountered a Plaid API error prior to exiting. 2513 } 2514 }, 2515 }); 2516 2517 // Trigger the Link UI 2518 document.getElementById('cardsLinkButton').onclick = function () { 2519 $scope.eventLinkHandler.open(); 2520 }; 2521 } 2522 2523 }, function () { 2524 $scope.sitedata.plaidEnabled = false; 2525 2526 return; 2527 }, false); 2528 2529 $scope.$apply(); 2530 } 2531 2532 $scope.noCardSelected = false; 2533 $scope.saveChanges = function () { 2534 $scope.noCardSelected = true; 2535 2536 var newvalue = null; 2537 jQuery('.paymentMethodList').each(function () { 2538 if (jQuery(this).prop('checked') == true) { 2539 newvalue = jQuery(this).val(); 2540 } 2541 }); 2542 2543 if (newvalue == null) { 2544 return; 2545 } 2546 $scope.noCardSelected = false; 2547 2548 $scope.charge.paymentMethod = newvalue; 2549 $scope.charge.paymentMethods = $scope.paymentMethods; 2550 2551 $scope.$close($scope.charge); 2552 } 2553 // Create an instance of the card Element. 2554 }, 2555 backdrop: 'static', 2556 resolve: { 2557 customerId: function () { 2558 return $scope.sitedata.customerId; 2559 }, 2560 charge: function () { 2561 return charge; 2562 }, 2563 sitedata: function () { 2564 return $scope.sitedata; 2565 }, 2566 user: function () { 2567 return user; 2568 } 2569 } 2570 }).result.then(function (data) { 2571 charge.paymentMethod = data.paymentMethod; 2572 $scope.payment.paymentMethod = charge.paymentMethod; 2573 }, function () { 2574 2575 }); 2576 }; 2577 }, 2578 backdrop: 'static', 2579 size: 'lg', 2580 resolve: { 2581 charge: function () { 2582 return $scope.charge; 2583 }, 2584 payment: function () { 2585 return $scope.payment; 2586 }, 2587 parentScope: function () { 2588 return $scope; 2589 }, 2590 sitedata: function () { 2591 return $scope.sitedata; 2592 }, 2593 user: function () { 2594 return user; 2595 } 2596 } 2597 }).result.then(function () { 2598 $scope.$close(); 2599 }, function () { 2600 2601 }); 2602 } 2603 2604 }, 2605 backdrop: 'static', 2606 resolve: { 2607 charge: function () { 2608 return charge; 2609 }, 2610 parentScope: function () { 2611 return $scope; 2612 }, 2613 customerId: function () { 2614 return $scope.sitedata.customerId; 2615 }, 2616 sitedata: function () { 2617 return $scope.sitedata; 2618 }, 2619 user: function () { 2620 return AppConstants.CurrentUser; 2621 } 2622 } 2623 }).result.then(function (answers) { 2624 $scope.refreshWalletBalance(); 2625 }, function () { 2626 $scope.refreshWalletBalance(); 2627 }); 2628 } 2629 2630 $scope.activityForm = function (activity) { 2631 $uibModal.open({ 2632 templateUrl: 'event-form-modal', 2633 controller: function ($scope, $timeout, formId, customerId, activity) { 2634 $scope.customerId = customerId; 2635 $scope.activity = activity; 2636 $scope.formId = null; 2637 $scope.formdata = null; 2638 $scope.ajaxCall('/Customer/GetFormSetupPublic', { customerId: $scope.customerId, formId: formId }, function (data) { 2639 $scope.formdata = data; 2640 2641 $timeout(function () { 2642 if ($scope.activity.activityFormData) { 2643 angular.forEach($scope.activity.activityFormData, function (answer) { 2644 jQuery('.customFormItem').each(function () { 2645 if (jQuery(this).attr('data-id') == answer.questionId) { 2646 jQuery(this).val(answer.answer); 2647 } 2648 }); 2649 2650 var radioval = answer.questionId + '|' + answer.answer; 2651 var split = answer.answer.split(', '); 2652 2653 angular.forEach(split, function (uniqueanswer) { 2654 var checkboxval = answer.questionId + '|' + uniqueanswer; 2655 jQuery('.customFormCheckbox').each(function () { 2656 if (jQuery(this).val() == checkboxval) { 2657 jQuery(this).prop('checked', true); 2658 } 2659 }); 2660 2661 }); 2662 2663 jQuery('.customFormRadio').each(function () { 2664 if (jQuery(this).val() == radioval) { 2665 jQuery(this).prop('checked', true); 2666 } 2667 }); 2668 }); 2669 2670 2671 } 2672 }, 50); 2673 2674 }); 2675 2676 $scope.initMultipleUpload = function () { 2677 $timeout(function () { 2678 jQuery('.customMultipleUpload').each(function () { 2679 jQuery(this).find('input').prop('multiple', true); 2680 }); 2681 2682 }, 50); 2683 } 2684 2685 2686 $scope.file = null; 2687 2688 $scope.inUpload = false; 2689 $scope.startFileUpload = function (files) { 2690 $scope.inUpload = true; 2691 }; 2692 2693 $scope.successFileUploadCustomMultiple = function (response, field) { 2694 $scope.inUpload = false; 2695 if (response.data.success) { 2696 2697 if (!field.attachments) { 2698 field.attachments = []; 2699 } 2700 angular.forEach(response.data.results, function (result) { 2701 var folderFile = {}; 2702 folderFile.uploadedFileId = result.fileId; 2703 folderFile.sizeInt = result.fileSizeBytes; 2704 folderFile.name = result.fileName; 2705 folderFile.type = result.fileType; 2706 2707 2708 field.attachments.push(folderFile); 2709 }); 2710 } else { 2711 $scope.errorMessage('One or more files exceeds the maximum file size of 15MB.'); 2712 } 2713 }; 2714 2715 $scope.removeFormFile = function (index, field) { 2716 field.attachments.splice(index, 1); 2717 } 2718 2719 $scope.imageSrc = function (fileId) { 2720 if (fileId != null) { 2721 return '/File/Get/' + fileId; 2722 } 2723 return null; 2724 }; 2725 2726 $scope.submitApplication = function () { 2727 $scope.customAnswers = []; 2728 2729 jQuery('#applicationForm' + ' .customFormItem').each(function () { 2730 $scope.customAnswers.push({ questionId: jQuery(this).attr('data-id'), answer: jQuery(this).val() }); 2731 }); 2732 2733 jQuery('#applicationForm' + ' .checkboxGroup').each(function () { 2734 var vals = []; 2735 var questionId = ""; 2736 2737 jQuery(this).find('.customFormCheckbox').each(function () { 2738 if (jQuery(this).prop('checked')) { 2739 var dataval = jQuery(this).val().split('|'); 2740 questionId = dataval[0]; 2741 vals.push(dataval[1].split(",").join("|")); 2742 } 2743 }); 2744 2745 $scope.customAnswers.push({ questionId: questionId, answer: vals.join(', ') }); 2746 2747 }); 2748 jQuery('#applicationForm' + ' .customFormRadio').each(function () { 2749 if (jQuery(this).prop('checked')) { 2750 var dataval = jQuery(this).val().split('|'); 2751 $scope.customAnswers.push({ questionId: dataval[0], answer: dataval[1] }); 2752 } 2753 }); 2754 2755 $scope.loopfailed = false; 2756 2757 angular.forEach($scope.formdata.sections, function (section) { 2758 angular.forEach(section.questions, function (question) { 2759 if (question.required) { 2760 var failed = true; 2761 2762 2763 if (question.questionControlType == 8) { 2764 if (!question.attachments) { 2765 question.isInvalid = true; 2766 } else { 2767 if (!question.attachments.length) { 2768 question.isInvalid = true; 2769 } else { 2770 2771 var answer = ""; 2772 angular.forEach(question.attachments, function (attachment) { 2773 2774 if (answer != "") { 2775 answer += ","; 2776 } 2777 answer += attachment.uploadedFileId; 2778 }); 2779 2780 $scope.customAnswers.push({ questionId: question.questionId, answer: answer, isUpload: true });
2781 failed = false; 2782 } 2783 } 2784 2785 2786 } else { 2787 2788 angular.forEach($scope.customAnswers, function (answer) { 2789 question.isInvalid = true; 2790 if (answer.questionId == question.questionId && answer.answer.length > 0) { 2791 failed = false; 2792 question.isInvalid = false; 2793 } 2794 }); if (question.min != null || question.max != null) { 2795 angular.forEach($scope.customAnswers, function (answer) { 2796 if (answer.questionId == question.questionId && answer.answer.length > 0) { 2797 var arr = answer.answer.split(','); 2798 var count = arr.length; 2799 if (question.min != null) { 2800 if (count < question.min) { 2801 question.incorrectMinMax = true; 2802 failed = true; 2803 } 2804 } 2805 if (question.max != null) { 2806 if (count > question.max) { 2807 question.incorrectMinMax = true; 2808 failed = true; 2809 } 2810 2811 } 2812 } 2813 }); 2814 } 2815 2816 } 2817 if (failed) { 2818 $scope.loopfailed = true; 2819 } 2820 } else { 2821 if (question.questionControlType == 8) { 2822 if (!question.attachments) { 2823 //do nothing 2824 } else { 2825 if (!question.attachments.length) { 2826 //do nothing 2827 } else { 2828 2829 var answer = ""; 2830 angular.forEach(question.attachments, function (attachment) { 2831 2832 if (answer != "") { 2833 answer += ","; 2834 } 2835 answer += attachment.uploadedFileId; 2836 }); 2837 2838 $scope.customAnswers.push({ questionId: question.questionId, answer: answer, isUpload: true }); 2839 failed = false; 2840 } 2841 } 2842 2843 2844 } 2845 } 2846 }); 2847 }); 2848 2849 if ($scope.loopfailed) { 2850 $scope.submitAttempt = true; 2851 return; 2852 } 2853 $scope.submitAttempt = false; 2854 2855 $scope.$close($scope.customAnswers); 2856 } 2857 }, 2858 backdrop: 'static', 2859 size: 'lg', 2860 resolve: { 2861 formId: function () { 2862 return activity.forms; 2863 }, 2864 customerId: function () { 2865 return $scope.sitedata.customerId; 2866 }, activity: function () { 2867 return activity; 2868 }, 2869 } 2870 }).result.then(function (answers) { 2871 activity.activityFormData = answers; 2872 }, function () { 2873 2874 }); 2875 } 2876 2877 $scope.nextEventSection = function () { 2878 switch ($scope.registrationTab) { 2879 case "start": 2880 if ($scope.registerEvent.hasTickets) { 2881 $scope.registrationTab = "tickets"; 2882 } else if ($scope.registerEvent.hasSponsors) { 2883 $scope.registrationTab = "sponsors"; 2884 } else { 2885 $scope.registrationTab = "final"; 2886 } 2887 break; 2888 case "tickets": 2889 if ($scope.registerEvent.hasActivities) { 2890 $scope.registrationTab = "activities"; 2891 } else if ($scope.registerEvent.hasSponsors) { 2892 $scope.registrationTab = "sponsors"; 2893 } else { 2894 $scope.registrationTab = "final"; 2895 } 2896 break; 2897 case "activities": 2898 if ($scope.registerEvent.hasSponsors) { 2899 $scope.registrationTab = "sponsors"; 2900 } else { 2901 $scope.registrationTab = "final"; 2902 } 2903 break; 2904 case "sponsors": 2905 $scope.registrationTab = "final"; 2906 break; 2907 case "final": 2908 //return;//Shouldn't happen here 2909 break; 2910 } 2911 2912 $scope.eventRegistration.grandTotal = 0; 2913 if ($scope.eventRegistration.ticketsBought > 0) { 2914 if ($scope.eventRegistration.package && $scope.registerEvent.hasPackages) { 2915 var index1 = $scope.registerEvent.packages.map(function (e) { return e.packageId; }).indexOf($scope.eventRegistration.package); 2916 if (index1 !== -1) { 2917 $scope.eventRegistration.grandTotal += $scope.registerEvent.packages[index1].ticketPrice * $scope.eventRegistration.ticketsBought; 2918 } 2919 } else if (!$scope.registerEvent.hasPackages) { 2920 $scope.eventRegistration.grandTotal += $scope.registerEvent.ticketPrice * $scope.eventRegistration.ticketsBought; 2921 } 2922 } 2923 2924 angular.forEach($scope.eventRegistration.activityDays, function (day) { 2925 angular.forEach(day.activities, function (activity) { 2926 $scope.eventRegistration.grandTotal += activity.selectedSeats * activity.ticketPrice; 2927 }); 2928 }); 2929 2930 if ($scope.eventRegistration.isSponsor) { 2931 $scope.eventRegistration.grandTotal += parseFloat($scope.eventRegistration.sponsorAmount); 2932 } 2933 } 2934 2935 $scope.updateGrandTotal = function () { 2936 $scope.eventRegistration.grandTotal = 0; 2937 if ($scope.eventRegistration.ticketsBought > 0) { 2938 if ($scope.eventRegistration.package && $scope.registerEvent.hasPackages) { 2939 var index1 = $scope.registerEvent.packages.map(function (e) { return e.packageId; }).indexOf($scope.eventRegistration.package); 2940 if (index1 !== -1) { 2941 $scope.eventRegistration.grandTotal += $scope.registerEvent.packages[index1].ticketPrice * $scope.eventRegistration.ticketsBought; 2942 } 2943 } else if (!$scope.registerEvent.hasPackages) { 2944 $scope.eventRegistration.grandTotal += $scope.registerEvent.ticketPrice * $scope.eventRegistration.ticketsBought; 2945 } 2946 } 2947 2948 var maxSeats = 99; 2949 2950 angular.forEach($scope.eventRegistration.activityDays, function (day) { 2951 angular.forEach(day.activities, function (activity) { 2952 if (activity.selectedSeats < 0) { 2953 activity.selectedSeats = 0; 2954 } else if (activity.selectedSeats > maxSeats) { 2955 activity.selectedSeats = maxSeats; 2956 } 2957 2958 $scope.eventRegistration.grandTotal += activity.selectedSeats * activity.ticketPrice; 2959 }); 2960 }); 2961 2962 if ($scope.eventRegistration.isSponsor) { 2963 $scope.eventRegistration.grandTotal += parseFloat($scope.eventRegistration.sponsorAmount); 2964 } 2965 } 2966 2967 $scope.prevEventSection = function () { 2968 $scope.eventValidationRan = false; 2969 2970 switch ($scope.registrationTab) { 2971 case "start": 2972 //return; //Shouldn't happen. 2973 break; 2974 case "tickets": 2975 $scope.registrationTab = "start"; 2976 break; 2977 case "activities": 2978 if ($scope.registerEvent.hasTickets) { 2979 $scope.registrationTab = "tickets"; 2980 } else { 2981 $scope.registrationTab = "start"; 2982 } 2983 2984 break; 2985 case "sponsors": 2986 if ($scope.registerEvent.hasActivities) { 2987 $scope.registrationTab = "activities"; 2988 } else if ($scope.registerEvent.hasTickets) { 2989 $scope.registrationTab = "tickets"; 2990 } else { 2991 $scope.registrationTab = "start"; 2992 } break; 2993 case "final": 2994 if ($scope.registerEvent.hasSponsors) { 2995 $scope.registrationTab = "sponsors"; 2996 } else if ($scope.registerEvent.hasActivities) { 2997 $scope.registrationTab = "activities"; 2998 } else if ($scope.registerEvent.hasTickets) { 2999 $scope.registrationTab = "tickets"; 3000 } else { 3001 $scope.registrationTab = "start"; 3002 } 3003 break; 3004 } 3005 } 3006 3007 $scope.blockSubmit = false; 3008 $scope.completeRegistration = function () { 3009 if ($scope.eventRegistration.grandTotal > 0) { 3010 3011 if ($scope.eventRegistration.paymentType == "card") { 3012 $scope.stripeapi.createToken($scope.card).then(function (result) { 3013 if (result.error) { 3014 alert("Error processing card"); 3015 return; 3016 } else { 3017 $scope.eventRegistration.stripeToken = result.token; 3018 3019 $scope.eventRegistration.activities = []; 3020 3021 angular.forEach($scope.eventRegistration.activityDays, function (day) { 3022 angular.forEach(day.activities, function (activity) { 3023 if (activity.selectedSeats > 0) { 3024 var activityItem = { activityId: activity.activityId, ticketsBought: activity.selectedSeats, activityFormData: activity.activityFormData } 3025 $scope.eventRegistration.activities.push(activityItem); 3026 } 3027 }); 3028 }); 3029 3030 $scope.eventRegistration.eventId = $scope.registerEvent.eventId; 3031 3032 if ($scope.blockSubmit) { 3033 return; 3034 } 3035 $scope.blockSubmit = true; 3036 3037 grecaptcha.execute('6LeBhgskAAAAAE14Yen7FmvsB0LI-rK5DBohK0GX', { action: 'submit' }).then(function (token) { 3038 $scope.ajaxCall('/Event/RegisterEvent/', { customerId: $scope.sitedata.customerId, eventData: $scope.eventRegistration }, function (data) { 3039 $scope.blockSubmit = false; 3040 3041 $scope.registrationTab = "complete"; 3042 }, function () { 3043 $scope.blockSubmit = false; 3044 }); 3045 }); 3046 3047 } 3048 }); 3049 } else if ($scope.eventRegistration.paymentType == "plaid") { 3050 if (!$scope.eventRegistration.plaidLinked) { 3051 return; 3052 } 3053 3054 $scope.eventRegistration.activities = []; 3055 3056 angular.forEach($scope.eventRegistration.activityDays, function (day) { 3057 angular.forEach(day.activities, function (activity) { 3058 if (activity.selectedSeats > 0) { 3059 var activityItem = { activityId: activity.activityId, ticketsBought: activity.selectedSeats, activityFormData: activity.activityFormData } 3060 $scope.eventRegistration.activities.push(activityItem); 3061 } 3062 }); 3063 }); 3064 3065 $scope.eventRegistration.eventId = $scope.registerEvent.eventId; 3066 $scope.ajaxCall('/Event/RegisterEvent/', { customerId: $scope.sitedata.customerId, eventData: $scope.eventRegistration }, function (data) { 3067 $scope.registrationTab = "complete"; 3068 }); 3069 } 3070 3071 } else { 3072 3073 3074 $scope.eventRegistration.activities = []; 3075 3076 angular.forEach($scope.eventRegistration.activityDays, function (day) { 3077 angular.forEach(day.activities, function (activity) { 3078 if (activity.selectedSeats > 0) { 3079 var activityItem = { activityId: activity.activityId, ticketsBought: activity.selectedSeats, activityFormData: activity.activityFormData } 3080 $scope.eventRegistration.activities.push(activityItem); 3081 } 3082 }); 3083 }); 3084 3085 $scope.eventRegistration.eventId = $scope.registerEvent.eventId; 3086 $scope.ajaxCall('/Event/RegisterEvent/', { customerId: $scope.sitedata.customerId, eventData: $scope.eventRegistration }, function (data) { 3087 $scope.registrationTab = "complete"; 3088 }); 3089 } 3090 } 3091 3092 $scope.missingEventForms = false; 3093 $scope.validateNextEventSection = function (form) { 3094 $scope.eventValidationRan = true;
3095 if (form.$invalid) { 3096 return; 3097 } 3098 3099 $scope.failedForm = false; 3100 if ($scope.registrationTab == 'tickets') { 3101 if ($scope.registerEvent.hasPackages) { 3102 angular.forEach($scope.registerEvent.packages, function (package) { 3103 if ($scope.eventRegistration.package == package.packageId && package.forms != '00000000-0000-0000-0000-000000000000' && package.forms != null && (!$scope.eventRegistration.packageFormData || !$scope.eventRegistration.packageFormData.length)) { 3104 $scope.failedForm = true; 3105 } 3106 }); 3107 } 3108 } 3109 3110 if ($scope.registrationTab == 'activities') { 3111 if ($scope.registerEvent.hasActivities) { 3112 angular.forEach($scope.eventRegistration.activityDays, function (activityDay) { 3113 angular.forEach(activityDay.activities, function (activity) { 3114 if (activity.selectedSeats != null && activity.selectedSeats > 0) { 3115 if (activity.forms && activity.forms != '00000000-0000-0000-0000-000000000000') { 3116 if (!activity.activityFormData || !activity.activityFormData.length) { 3117 $scope.missingEventForms = true; 3118 $scope.failedForm = true; 3119 } 3120 } 3121 } 3122 }); 3123 }); 3124 } 3125 } 3126 3127 if ($scope.failedForm) { 3128 return; 3129 } 3130 3131 $scope.missingEventForms = false; 3132 3133 $scope.eventValidationRan = false; 3134 $scope.nextEventSection(); 3135 } 3136 3137 $scope.initFlatPicker = function () { 3138 $timeout(function () { 3139 $('.flatPickrField').flatpickr({ 3140 minDate: "today", 3141 dateFormat: "m/d/Y", 3142 }); 3143 3144 $('.flatPickrTime').flatpickr({ 3145 enableTime: true, 3146 noCalendar: true, 3147 dateFormat: "h:iK", 3148 }); 3149 3150 }, 50); 3151 } 3152 3153 $scope.getEvents = function () { 3154 $scope.ajaxCall('/Event/GetSiteEvents/', { customerId: $scope.sitedata.customerId, name: $scope.eventSearch.name, start: $scope.eventSearch.start, end: $scope.eventSearch.end, location: $scope.eventSearch.location }, function (data) { 3155 3156 $scope.events = []; 3157 angular.forEach(data, function (event) { 3158 if (event.isEvent) { 3159 $scope.events.push(event); 3160 } 3161 }) 3162 }); 3163 $scope.ajaxCall('/Sites/GetEventsUrl', { customerId: $scope.sitedata.customerId }, function (data) { 3164 $scope.eventsUrl = data; 3165 }, function () { 3166 3167 }, false); 3168 } 3169 3170 $scope.getEventsWithPopup = function () { 3171 $scope.ajaxCall('/Event/GetSiteEvents/', { customerId: $scope.sitedata.customerId, name: $scope.eventSearch.name, start: $scope.eventSearch.start, end: $scope.eventSearch.end, location: $scope.eventSearch.location }, function (data) { 3172 3173 $scope.events = []; 3174 angular.forEach(data, function (event) { 3175 if (event.isEvent) { 3176 $scope.events.push(event); 3177 } 3178 }); 3179 3180 $timeout(function () { 3181 var openEvent = $scope.getQueryVariable('event'); 3182 if (openEvent) { 3183 3184 angular.forEach($scope.events, function (event) { 3185 if (event.eventId == openEvent) { 3186 $scope.viewEvent(event, true); 3187 } 3188 }); 3189 } 3190 }, 10); 3191 3192 3193 }); 3194 $scope.ajaxCall('/Sites/GetEventsUrl', { customerId: $scope.sitedata.customerId }, function (data) { 3195 $scope.eventsUrl = data; 3196 }, function () { 3197 3198 }, false); 3199 } 3200 3201 $scope.registerEvent = null; 3202 3203 $scope.unsetRegister = function () { 3204 $scope.registerEvent = null; 3205 } 3206 3207 $scope.eventRegistration = { country: 1, stateId: null, package: null, paymentType: "card", ticketsBought: 0, grandTotal: 0, sponsor: false } 3208 3209 $scope.$watch('eventRegistration.phone', function (input) { 3210 if ($scope.eventRegistration.phone != null && input != null) { 3211 3212 var cleaned = input.replace(/[^0-9\\.]+/g, ''); 3213 var match = cleaned.match(/^(\d{0,3})(\d{0,3})(\d{0,4})$/) 3214 if (match) { 3215 var formattedPhone = match[1]; 3216 if (match[2].length > 0) { 3217 formattedPhone += '-' + match[2]; 3218 } 3219 if (match[3].length > 0) { 3220 formattedPhone += '-' + match[3]; 3221 } 3222 $scope.eventRegistration.phone = formattedPhone.substr(0, 12); 3223 } 3224 } 3225 }); 3226 3227 3228 $scope.$watch('eventRegistration.zip', function (input) { 3229 if ($scope.eventRegistration.zip != null && input != null) { 3230 $scope.eventRegistration.zip = input.replace(/[^0-9\\.]+/g, ''); 3231 } 3232 }); 3233 3234 3235 $scope.preventDefault = function ($event) { 3236 $event.preventDefault(); 3237 } 3238 3239 3240 $scope.countDecimals = function (value) { 3241 if (Math.floor(value) === value) return 0; 3242 return value.toString().split(".")[1].length || 0; 3243 } 3244 3245 $scope.$watch('eventRegistration.sponsorAmount', function (input) { 3246 if ($scope.eventRegistration.sponsorAmount != null && input != null && $scope.eventRegistration.sponsorAmount != 0) { 3247 $scope.eventRegistration.sponsorAmount = input.replace(/[^0-9\\.]+/g, ''); 3248 3249 if ($scope.countDecimals($scope.eventRegistration.sponsorAmount) > 2) { 3250 $scope.eventRegistration.sponsorAmount = parseFloat($scope.eventRegistration.sponsorAmount).toFixed(2); 3251 } 3252 3253 3254 if ($scope.eventRegistration.sponsorAmount < 0) { 3255 $scope.eventRegistration.sponsorAmount = 0; 3256 } 3257 } 3258 3259 }); 3260 3261 3262 $scope.$watch('eventRegistration.ticketsBought', function (input) { 3263 if (!$scope.registerEvent) { 3264 return; 3265 } 3266 var max = 99; 3267 if (!$scope.registerEvent.hasPackages && $scope.registerEvent.
3267seats) { 3268 max = $scope.registerEvent.seats - $scope.registerEvent.purchasedSeats; 3269 } 3270 3271 if ($scope.eventRegistration.ticketsBought > max) { 3272 $scope.eventRegistration.ticketsBought = max; 3273 } else if ($scope.eventRegistration.ticketsBought < 0) { 3274 $scope.eventRegistration.ticketsBought = 0; 3275 } 3276 3277 }); 3278 3279 $scope.registrationTab = 'start'; 3280 $scope.setRegistrationTab = function (tab) { 3281 $scope.registrationTab = tab; 3282 } 3283 3284 $scope.removePackage = function (eventRegistration) { 3285 eventRegistration.package = null; 3286 eventRegistration.packageSeats = 0; 3287 } 3288 3289 $scope.packageName = function (eventRegistration) { 3290 var index1 = $scope.registerEvent.packages.map(function (e) { return e.packageId; }).indexOf(eventRegistration.package); 3291 if (index1 !== -1) { 3292 return $scope.registerEvent.packages[index1].name; 3293 } 3294 } 3295 $scope.packageCost = function (eventRegistration) { 3296 var index1 = $scope.registerEvent.packages.map(function (e) { return e.packageId; }).indexOf(eventRegistration.package); 3297 if (index1 !== -1) { 3298 3299 3300 3301 return $scope.priceformatter.format($scope.registerEvent.packages[index1].ticketPrice * $scope.eventRegistration.ticketsBought); 3302 3303 //return '$' + ($scope.registerEvent.packages[index1].ticketPrice * $scope.eventRegistration.ticketsBought); 3304 } 3305 } 3306 $scope.ticketCost = function (eventRegistration) { 3307 return $scope.priceformatter.format($scope.registerEvent.ticketPrice * $scope.eventRegistration.ticketsBought); 3308 //return '$' + ($scope.registerEvent.ticketPrice * $scope.eventRegistration.ticketsBought); 3309 } 3310 3311 $scope.setMaxActivity = function (item) { 3312 var max = 99; 3313 if (item.seats) { 3314 max = item.seats - item.purchasedSeats; 3315 } 3316 3317 if (item.selectedSeats > max) { 3318 item.selectedSeats = max; 3319 } 3320 } 3321 3322 $scope.activityRegistration = function (eventRegistration) { 3323 var html = ''; 3324 angular.forEach($scope.eventRegistration.activityDays, function (day) { 3325 angular.forEach(day.activities, function (activity) { 3326 if (activity.selectedSeats > 0) { 3327 html += '<tr><td style="vertical-align:middle;">' + 3328 '<span class="text-muted"> <small>' + activity.name + ' x' + activity.selectedSeats + '</small></span>' + 3329 '</td>' + 3330 '<td style = "vertical-align:middle;"><p class="price">' + $scope.priceformatter.format(activity.ticketPrice * activity.selectedSeats) + 3331 '</p></td><tr>'; 3332 } 3333 }); 3334 }); 3335 return html; 3336 } 3337 3338 $scope.setUrl = function (url) { 3339 window.location.href = url; 3340 } 3341 3342 3343 3344 $scope.viewDescriptionModal = function (activity) { 3345 $uibModal.open({ 3346 templateUrl: 'view-activity-description-modal', 3347 size: 'lg', 3348 controller: function ($scope, $timeout, description) { 3349 $scope.description = description; 3350 }, 3351 backdrop: 'static', 3352 resolve: { 3353 description: function () { 3354 return activity.description; 3355 }, 3356 } 3357 }).result.then(function () { 3358 3359 }, function () { 3360 3361 }); 3362 } 3363 3364 $scope.clearEventMemberInformation = function () { 3365 $scope.eventRegistration.firstName = ''; 3366 $scope.eventRegistration.lastName = ''; 3367 $scope.eventRegistration.phone = ''; 3368 $scope.eventRegistration.emailAddress = ''; 3369 $scope.eventRegistration.address1 = ''; 3370 $scope.eventRegistration.address2 = ''; 3371 $scope.eventRegistration.city = ''; 3372 $scope.eventRegistration.stateId = ''; 3373 $scope.eventRegistration.zip = ''; 3374 $scope.eventRegistration.internationalZip = ''; 3375 $scope.eventRegistration.internationalState = ''; 3376 $scope.eventRegistration.country = 1; 3377 } 3378 3379 $scope.viewEvent = function (event, showRegister) { 3380 $uibModal.open({ 3381 templateUrl: 'view-event-modal', 3382 size: 'lg', 3383 controller: function ($scope, $timeout, event, showRegister) { 3384 $scope.showRegister = showRegister; 3385 $scope.event = event; 3386 $scope.registerEvent = function () { 3387 $scope.$close(); 3388 } 3389 }, 3390 backdrop: 'static', 3391 resolve: { 3392 event: function () { 3393 return event; 3394 }, 3395 showRegister: function () { 3396 return showRegister; 3397 } 3398 } 3399 }).result.then(function () { 3400 $scope.registerEvent = event; 3401 $scope.eventRegistration = { country: 1, stateId: null, package: null, paymentType: "card", ticketsBought: 0, grandTotal: 0, sponsor: false } 3402 if ($scope.currentUser) { 3403 $scope.eventRegistration.firstName = $scope.currentUser.firstName; 3404 $scope.eventRegistration.lastName = $scope.currentUser.lastName; 3405 $scope.eventRegistration.phone = $scope.currentUser.phone; 3406 $scope.eventRegistration.emailAddress = $scope.currentUser.emailAddress; 3407 $scope.eventRegistration.address1 = $scope.currentUser.address1; 3408 $scope.eventRegistration.address2 = $scope.currentUser.address2; 3409 $scope.eventRegistration.city = $scope.currentUser.city; 3410 $scope.eventRegistration.stateId = $scope.currentUser.state; 3411 $scope.eventRegistration.zip = $scope.currentUser.zip; 3412 $scope.eventRegistration.internationalZip = $scope.currentUser.internationalZip; 3413 $scope.eventRegistration.internationalState = $scope.currentUser.internationalState; 3414 $scope.eventRegistration.country = $scope.currentUser.country; 3415 } 3416 3417 $scope.registrationTab = 'start'; 3418 3419 $scope.eventRegistration.package = null; 3420 3421 $scope.eventRegistration.activityDays = $scope.registerEvent.activityDays; 3422 3423 angular.forEach($scope.eventRegistration.activityDays, function (day) { 3424 angular.forEach(day.activities, function (activity) { 3425 activity.selectedSeats = 0; 3426 }); 3427 }); 3428 }, function () { 3429 3430 }); 3431 } 3432 3433 $scope.viewEventRegistration = function (event, showRegister) { 3434 $uibModal.open({ 3435 templateUrl: 'view-event-registration-modal', 3436 size: 'lg', 3437 controller: function ($scope, $timeout, event, showRegister) { 3438 $scope.showRegister = showRegister; 3439 $scope.event = event; 3440 $scope.registration = event.registration; 3441 3442 $scope.registerEvent = function () { 3443 $scope.$close(); 3444 } 3445 }, 3446 backdrop: 'static', 3447 resolve: { 3448 event: function () { 3449 return event; 3450 }, 3451 showRegister: function () { 3452 return showRegister; 3453 } 3454 } 3455 }).result.then(function () { 3456 3457 }, function () { 3458 3459 }); 3460 } 3461 3462 3463 $scope.viewRegistrationPricing = function (registration) { 3464 $uibModal.open({ 3465 templateUrl: 'view-registration-pricing-modal', 3466 size: 'lg', 3467 controller: function ($scope, $timeout, event) { 3468 $scope.registration = event.registration; 3469 }, 3470 backdrop: 'static', 3471 resolve: { 3472 event: function () { 3473 return registration; 3474 }, 3475 } 3476 }).result.then(function () { 3477 3478 }, function () { 3479 3480 }); 3481 } 3482 $scope.viewReservationPricing = function (reservation) { 3483 $uibModal.open({ 3484 templateUrl: 'view-amenity-pricing-modal', 3485 size: 'lg', 3486 controller: function ($scope, $timeout, reservation) { 3487 $scope.reservation = reservation; 3488 }, 3489 backdrop: 'static', 3490 resolve: { 3491 reservation: function () { 3492 return reservation; 3493 }, 3494 } 3495 }).result.then(function () { 3496 3497 }, function () { 3498 3499 }); 3500 } 3501 3502 $scope.checkMemberInMessageSearchArray = function (member) { 3503 if ($scope.messageSearchMembers.map(function (e) { return e.userId; }).indexOf(member.userId) == -1) { 3504 return true; 3505 } 3506 3507 return false; 3508 } 3509 3510 $scope.checkMembersInMessageSearchArray = function (filteredList) { 3511 var found = false; 3512 3513 angular.forEach(filteredList, function (member) { 3514 if ($scope.messageSearchMembers.map(function (e) { return e.userId; }).indexOf(member.userId) == -1) { 3515 found = true; 3516 } 3517 3518 }); 3519 3520 return found; 3521 } 3522 3523 $scope.showMessages = false; 3524 $scope.showFlyout = function () { 3525 $scope.showMessages = true; 3526 } 3527 3528 $scope.slowPropagation = function () { 3529 $scope.canOpenConversation = false; 3530 $timeout(function () { 3531 $scope.canOpenConversation = true; 3532 }, 500); 3533 } 3534 3535 $scope.hideFlyout = function () { 3536 $scope.showMessages = false; 3537 } 3538 3539 $scope.renameConversation = function (conversation) { 3540 $uibModal.open({ 3541 templateUrl: 'edit-conversation-modal', 3542 controller: function ($scope, $timeout, conversation) { 3543 $scope.conversation = jQuery.extend(true, {}, conversation); 3544 3545 $scope.init = function () { 3546 3547 } 3548 $scope.submitAttempt = false; 3549
3550 $scope.saveChanges = function (form) { 3551 $scope.submitAttempt = true; 3552 3553 if (form.$invalid) { 3554 return; 3555 } 3556 3557 $scope.submitAttempt = false; 3558 3559 $scope.ajaxCall('/Sites/RenameConversation', { conversationId: $scope.conversation.conversationId, name: $scope.conversation.name }, function (data) { 3560 $scope.successMessage("Successfully renamed the conversation."); 3561 $scope.$close(); 3562 }); 3563 }; 3564 }, 3565 backdrop: 'static', 3566 resolve: { 3567 conversation: function () { 3568 return conversation; 3569 }, 3570 } 3571 }).result.then(function () { 3572 $scope.getConversations(); 3573 }, function () { 3574 3575 }); 3576 }; 3577 3578 $scope.messagetab = 'all'; 3579 3580 $scope.setMessageTab = function (tab) { 3581 $scope.messagetab = tab; 3582 3583 $scope.messageSearchMembers = []; 3584 $scope.messageSearch = ''; 3585 $scope.message.text = ''; 3586 $scope.message.attachments = []; 3587 3588 3589 if (tab == 'new') { 3590 /* 3591 if ($scope.theme.paymentPlans != null && $scope.theme.paymentPlans) { 3592 angular.forEach($scope.theme.paymentPlans, function (plan) { 3593 jQuery('[data-id=supportedPlans] option[value=' + plan.planId + ']').prop('selected', true); 3594 }); 3595 } 3596 */ 3597 3598 jQuery('#example-multiselect2').multiselect(); 3599 $scope.selectedConversation = null; 3600 3601 } else if (tab == 'all') { 3602 $scope.selectedConversation = null; 3603 } else if (tab == 'conversation') { 3604 3605 $timeout(function () { 3606 window.emojiPicker = new EmojiPicker({ 3607 emojiable_selector: '[data-emojiable=unicode]', 3608 assetsPath: '/plugins/emoji-picker/img/', 3609 popupButtonClasses: 'far fa-smile' 3610 }); 3611 window.emojiPicker.discover(); 3612 3613 jQuery('.emojiField[data-emojiable=unicode]').removeAttr('data-emojiable'); 3614 3615 $timeout(function () { 3616 jQuery('.emoji-picker').each(function () { 3617 var dataid = jQuery(this).attr('data-id'); 3618 jQuery(this).attr('onclick', 'openEmojiPicker("' + dataid + '");'); 3619 jQuery(this).siblings('.emoji-wysiwyg-editor').unbind('keypress').on('keypress', function (e) { 3620 if (e.which == 13) { 3621 var itemid = jQuery(this).siblings('[data-item-id]').first().attr('data-item-id'); 3622 3623 var newvalue = jQuery(this).html().replace(/'/g, "\'"); 3624 } 3625 }); 3626 }); 3627 }, 100); 3628 3629 var objDiv = document.getElementById("messagesContainerScroll"); 3630 objDiv.scrollTop = objDiv.scrollHeight; 3631 $scope.showNoEmojiInput = $('.emoji-wysiwyg-editor').length == 0; 3632 }, 50); 3633 } 3634 } 3635 3636 $scope.messageSearchMembers = []; 3637 3638 $scope.addSearchMember = function (member) { 3639 $scope.messageSearchMembers.push(member); 3640 $scope.messageSearch = ''; 3641 } 3642 $scope.removeSearchMember = function (index) { 3643 $scope.messageSearchMembers.splice(index, 1); 3644 } 3645 3646 $scope.stopPropagation = function (event) { 3647 event.stopPropagation(); 3648 event.stopImmediatePropagation(); 3649 } 3650 3651 $scope.message = { text: '', attachments: [] }; 3652 3653 $scope.canOpenConversation = true; 3654 3655 $scope.selectedConversation = null; 3656 $scope.openConversation = function (conversation) { 3657 $timeout(function () { 3658 if (!$scope.canOpenConversation) { 3659 return; 3660 } 3661 $scope.ajaxCall('/Sites/ViewConversation', { conversationId: conversation.conversationId }, function (data) { 3662 $scope.getConversations(); 3663 $scope.setMessageTab('conversation'); 3664 $scope.selectedConversation = conversation; 3665 }); 3666 }, 50); 3667 3668 3669 } 3670 $scope.openConversationParticipants = function (conversation) { 3671 $scope.getConversations(); 3672 $scope.setMessageTab('participants'); 3673 $scope.selectedConversation = conversation; 3674 } 3675 3676 $scope.file = null; 3677 3678 $scope.inUpload = false; 3679 $scope.startFileUpload = function (files) { 3680 $scope.inUpload = true; 3681 }; 3682 $scope.successFileUpload = function (response) { 3683 $scope.inUpload = false; 3684 if (response.data.success) { 3685 $scope.file = response.data.results[0]; 3686 $scope.message.attachments.push(response.data.results[0]); 3687 } else { 3688 $scope.errorMessage('Your file exceeds the maximum file size of 15MB.'); 3689 } 3690 }; 3691 3692 3693 $scope.successFileUploadCustomMultiple = function (response, field) { 3694 $scope.inUpload = false; 3695 if (response.data.success) { 3696 3697 if (!field.attachments) { 3698 field.attachments = []; 3699 } 3700 angular.forEach(response.data.results, function (result) { 3701 var folderFile = {}; 3702 folderFile.uploadedFileId = result.fileId; 3703 folderFile.sizeInt = result.fileSizeBytes; 3704 folderFile.name = result.fileName; 3705 folderFile.type = result.fileType; 3706 field.attachments.push(folderFile); 3707 }); 3708 } else { 3709 $scope.errorMessage('One or more files exceeds the maximum file size of 15MB.'); 3710 } 3711 }; 3712 3713 $scope.removeFile = function (index) { 3714 $scope.message.attachments.splice(index, 1); 3715 } 3716 3717 $scope.removeFormFile = function (index, field) { 3718 field.attachments.splice(index, 1); 3719 } 3720 3721 $scope.imageSrc = function (fileId) { 3722 if (fileId != null) { 3723 return '/File/Get/' + fileId; 3724 } 3725 return null; 3726 }; 3727 3728 $scope.newMessageSubmitAttempt = false; 3729 $scope.createNewMessageGroup = function (form) { 3730 $scope.newMessageSubmitAttempt = true; 3731
3732 if (form.$invalid) { 3733 return; 3734 } 3735 $scope.newMessageSubmitAttempt = false; 3736 3737 3738 var groups = jQuery('.uniqueMultiselectVals').val(); 3739 3740 angular.forEach(groups, function (option) { 3741 var index1 = $scope.tagMembers.map(function (e) { return e.name; }).indexOf(option); 3742 if (index1 !== -1) { 3743 angular.forEach($scope.tagMembers[index1].members, function (tagMember) { 3744 var index2 = $scope.messageSearchMembers.map(function (e) { return e.userId; }).indexOf(tagMember.userId); 3745 if (index2 == -1) { 3746 $scope.messageSearchMembers.push(tagMember); 3747 } 3748 }); 3749 } 3750 3751 }); 3752 3753 var foundconversation = null; 3754 3755 if (!$scope.messageSearchMembers.length) { 3756 return; 3757 } else { 3758 3759 angular.forEach($scope.conversations, function (conversation) { 3760 var passing = false; 3761 3762 angular.forEach(conversation.participants, function (participant) { 3763 if (participant.userId != $scope.userId) { 3764 var memberIndex = $scope.messageSearchMembers.map(function (e) { return e.userId; }).indexOf(participant.userId); 3765 if (memberIndex == -1) { 3766 passing = true; 3767 } 3768 } 3769 }); 3770 3771 angular.forEach($scope.messageSearchMembers, function (participant) { 3772 if (participant.userId != $scope.userId) { 3773 var memberIndex = conversation.participants.map(function (e) { return e.userId; }).indexOf(participant.userId); 3774 if (memberIndex == -1) { 3775 passing = true; 3776 } 3777 } 3778 }); 3779 3780 3781 if (!passing) { 3782 foundconversation = conversation; 3783 } 3784 }); 3785 } 3786 3787 if (foundconversation) { 3788 $uibModal.open({ 3789 templateUrl: 'conversation-exists-modal', 3790 controller: function ($scope, $timeout) { 3791 $scope.continue = function () { 3792 $scope.$close('continue'); 3793 } 3794 $scope.open = function () { 3795 $scope.$close('open'); 3796 } 3797 }, 3798 backdrop: 'static', 3799 resolve: { 3800 } 3801 }).result.then(function (data) { 3802 if (data == 'continue') { 3803 $scope.ajaxCall('/Sites/CreateMessageGroup', { customerId: $scope.sitedata.customerId, message: $scope.message, participants: $scope.messageSearchMembers }, function (data) { 3804 $scope.successMessage("Conversation started!"); 3805 $scope.setMessageTab("all"); 3806 $scope.getConversations(); 3807 }, function () { 3808 3809 }, false); 3810 } else if (data == 'open') { 3811 $scope.openConversation(foundconversation); 3812 } 3813 }, function () { 3814 3815 }); 3816 3817 } else { 3818 3819 $scope.ajaxCall('/Sites/CreateMessageGroup', { customerId: $scope.sitedata.customerId, message: $scope.message, participants: $scope.messageSearchMembers }, function (data) { 3820 $scope.successMessage("Conversation started!"); 3821 $scope.setMessageTab("all"); 3822 $scope.getConversations(); 3823 }, function () { 3824 3825 }); 3826 } 3827 } 3828 $scope.sendMessageToGroup = function () { 3829 if (!$scope.message.text.length && !$scope.message.attachments.length) { 3830 return; 3831 } 3832 3833 if ($scope.editingMessage) { 3834 $scope.ajaxCall('/Sites/EditMessage', { customerId: $scope.sitedata.customerId, message: $scope.message }, function (data) { 3835 $scope.message.text = ""; 3836 $scope.message.attachments = []; 3837 3838 $scope.editingMessage = false; 3839 3840 jQuery('#messageFooter').find('.emoji-wysiwyg-editor').html(''); 3841 jQuery('#messageFooter').find('#messageContent').html(''); 3842 3843 $scope.getConversationsNoSpinner(); 3844 }, function () { 3845 3846 }, false); 3847 } else { 3848 $scope.ajaxCall('/Sites/SendMessageToGroup', { customerId: $scope.sitedata.customerId, conversationId: $scope.selectedConversation.conversationId, message: $scope.message }, function (data) { 3849 $scope.message.text = ""; 3850 $scope.message.attachments = []; 3851 3852 jQuery('#messageFooter').find('.emoji-wysiwyg-editor').html(''); 3853 jQuery('#messageFooter').find('#messageContent').html(''); 3854 $scope.getConversationsNoSpinner(); 3855 }, function () { 3856 3857 }, false); 3858 } 3859 } 3860 3861 $scope.addParticipant = function (member) { 3862 $uibModal.open({ 3863 templateUrl: 'add-participant-modal', 3864 controller: function ($scope, $timeout) {
3865 $scope.saveChanges = function () { 3866 $scope.$close(); 3867 } 3868 }, 3869 backdrop: 'static', 3870 resolve: { 3871 } 3872 }).result.then(function () { 3873 $scope.ajaxCall('/Sites/AddParticipant', { customerId: $scope.sitedata.customerId, conversationId: $scope.selectedConversation.conversationId, userId: member.userId }, function (data) { 3874 $scope.successMessage("Successfully added this participant!"); 3875 $scope.getConversations(); 3876 $scope.messageSearch = ''; 3877 }); 3878 }, function () { 3879 3880 }); 3881 3882 } 3883 $scope.removeParticipant = function (member) { 3884 $uibModal.open({ 3885 templateUrl: 'remove-participant-modal', 3886 controller: function ($scope, $timeout) { 3887 $scope.saveChanges = function () { 3888 $scope.$close(); 3889 } 3890 }, 3891 backdrop: 'static', 3892 resolve: { 3893 } 3894 }).result.then(function () { 3895 $scope.ajaxCall('/Sites/RemoveParticipant', { customerId: $scope.sitedata.customerId, conversationId: $scope.selectedConversation.conversationId, userId: member.userId }, function (data) { 3896 $scope.successMessage("Successfully removed this participant!"); 3897 3898 $scope.getConversations(); 3899 }); 3900 }, function () { 3901 3902 }); 3903 3904 } 3905 $scope.removeMessage = function (message) { 3906 $uibModal.open({ 3907 templateUrl: 'remove-message-modal', 3908 controller: function ($scope, $timeout) { 3909 $scope.remove = function () { 3910 $scope.$close(); 3911 } 3912 }, 3913 backdrop: 'static', 3914 resolve: { 3915 } 3916 }).result.then(function () { 3917 $scope.ajaxCall('/Sites/RemoveMessage', { customerId: $scope.sitedata.customerId, messageId: message.messageId }, function (data) { 3918 $scope.successMessage("Successfully removed this message!"); 3919 3920 $scope.getConversations(); 3921 }); 3922 }, function () { 3923 3924 }); 3925 3926 } 3927 3928 $scope.editingMessage = false; 3929 $scope.editMessage = function (message) { 3930 $scope.message.attachments = []; 3931 $scope.message.messageId = message.messageId; 3932 $scope.message.text = message.message; 3933 jQuery('#messageFooter').find('.emoji-wysiwyg-editor').html($scope.message.text); 3934 3935 3936 $scope.editingMessage = true; 3937 } 3938 $scope.leaveConversation = function (member) { 3939 $uibModal.open({ 3940 templateUrl: 'leave-participant-modal', 3941 controller: function ($scope, $timeout) { 3942 $scope.saveChanges = function () { 3943 $scope.$close(); 3944 } 3945 }, 3946 backdrop: 'static', 3947 resolve: { 3948 } 3949 }).result.then(function () { 3950 $scope.ajaxCall('/Sites/LeaveConversation', { customerId: $scope.sitedata.customerId, conversationId: $scope.selectedConversation.conversationId }, function (data) { 3951 $scope.successMessage("Successfully left the conversation!"); 3952 $scope.setMessageTab('all'); 3953 3954 $scope.getConversations(); 3955 }); 3956 }, function () { 3957 3958 }); 3959 3960 } 3961 3962 $scope.hideNav = false; 3963 3964 $scope.keypressSendMessage = function ($event) { 3965 if ($event.keyCode == 13) { 3966 $scope.sendMessageToGroup(); 3967 } 3968 }; 3969 3970 $scope.isAdmin = false; 3971 $scope.isSubAdmin = false; 3972 3973 $scope.mapFunction = function (e) { return e.userId; } 3974 3975 $scope.userId = null; 3976 $scope.currentUser = null; 3977 $scope.avatar = null; 3978 3979 $scope.isBlocked = false; 3980 3981 $scope.hasNewsfeed = false; 3982 $scope.newsfeedWidget = null; 3983 3984 $scope.setId = async function (id, featurepage) { 3985 await $scope.checkPublicSites(); 3986 $scope.loadPage(id, featurepage); 3987 } 3988 3989 $scope.loadPage = function (id, featurepage) { 3990 3991 if (featurepage && featurepage.length > 0) { 3992 $scope.specialPageType = featurepage; 3993 $scope.specialPage = true; 3994 } 3995 3996 $scope.showNoEmojiInput = true; 3997 3998 $scope.pageId = id; 3999 4000 $scope.cards = []; 4001 $scope.fetchCards = function () { 4002 $scope.ajaxCall('/Mobile/GetMemberPortalCards', { customerId: $scope.sitedata.customerId }, function (data) { 4003 console.log("All Cards: " + data); 4004 4005 $scope.cards = data; 4006 4007 $scope.fillActiveLists();
4008 4009 $scope.countActive(); 4010 }); 4011 } 4012 4013 $scope.ajaxCall('/Sites/GetPublicPage', { pageId: $scope.pageId }, function (data) { 4014 if (!data) { return; } 4015 if (location.hostname && data.customDomain) { 4016 if (location.hostname.toLowerCase() != data.customDomain.toLowerCase() && "www." + location.hostname.toLowerCase() != data.customDomain.toLowerCase() && location.hostname.toLowerCase() != "www." + data.customDomain.toLowerCase()) { 4017 $scope.sitePrefix = "/" + data.siteSlug; 4018 } 4019 } else { 4020 $scope.sitePrefix = "/" + data.siteSlug; 4021 } 4022 4023 if (data.invalidPerms) { 4024 window.location.href = $scope.sitePrefix + "/"; 4025 return; 4026 } 4027 4028 if (data.blockContent) { 4029 $scope.hideNav = true; 4030 var content = localStorage.getItem("bungee-sitecookie-blockcontent-cookie"); 4031 if (!content) { 4032 $scope.blockContentModal(data); 4033 localStorage.setItem("bungee-sitecookie-blockcontent-cookie", true); 4034 } 4035 else { 4036 localStorage.removeItem("bungee-sitecookie-blockcontent-cookie", true); 4037 } 4038 } else { 4039 localStorage.removeItem("bungee-sitecookie-blockcontent-cookie", true); 4040 } 4041 4042 $scope.sitedata = data; 4043 if ($scope.sitedata.isSubAdmin) { 4044 $scope.isSubAdmin = true; 4045 } 4046 4047 jQuery('title').text($scope.sitedata.siteName); 4048 4049 $scope.selectedColorPalette = $scope.sitedata.colorPalette; 4050 4051 $scope.analytics += $scope.sitedata.googleanalytics; 4052 4053 $scope.loadScript($scope.analytics, 'text/javascript', 'utf-8'); 4054 $timeout(function () { 4055 window.dataLayer = window.dataLayer || []; 4056 function gtag() { dataLayer.push(arguments); } 4057 gtag('js', new Date()); 4058 4059 gtag('config', $scope.sitedata.googleanalytics); 4060 console.log("Logging analytics"); 4061 console.log($scope.sitedata.googleanalytics); 4062 }, 100); 4063 4064 $scope.currentPage = $scope.sitedata.pages[0]; 4065 angular.forEach($scope.currentPage.sections, function (section) { 4066 angular.forEach(section.widgets, function (widget) { 4067 if (widget.type == 8) { 4068 if (widget.widgets) { 4069 widget.currentFaqWidget = widget.widgets[0]; 4070 } 4071 } else if (widget.type == 24) { 4072 $scope.hasNewsfeed = true; 4073 $scope.newsfeedWidget = widget; 4074 } else if (widget.type == 3) { 4075 angular.forEach(widget.widgets, function (subwidget) { 4076 if (subwidget.buttonType == 1) { 4077 subwidget.buttonUrl = $scope.sitePrefix + '/' + subwidget.buttonUrl; 4078 } 4079 }); 4080 } 4081 4082 }); 4083 }); 4084 4085 switch ($scope.sitedata.brand) { 4086 case "membershine": 4087 $scope.privacyPolicyLink = 'https://membershine.com/privacy-policy/'; 4088 break; 4089 case "hoastart": 4090 $scope.privacyPolicyLink = 'https://hoastart.com/privacy-policy/'; 4091 break; 4092 } 4093 4094 if (AppConstants.CurrentUser != null) { 4095 if (AppConstants.CurrentUser.sites != null) { 4096 4097 var siteindex = AppConstants.CurrentUser.sites.map(function (e) { return e.customerId; }).indexOf($scope.sitedata.customerId); 4098 if (siteindex != -1) { 4099 $scope.isMember = true; 4100 4101 if (AppConstants.CurrentUser.sites[siteindex].isAdmin) { 4102 $scope.isAdmin = true; 4103 } 4104 if (AppConstants.CurrentUser.sites[siteindex].isBlocked) { 4105 $scope.isBlocked = true; 4106 } 4107 4108 $scope.setCurrentCustomerSite(AppConstants.CurrentUser.sites[siteindex]); 4109 4110 $scope.checkProptia(); 4111 4112 if ($scope.sitedata.hasMessages && $scope.currentCustomerSite.enableChatUser) { 4113 $scope.getMessageMembers(); 4114 $scope.getConversations(); 4115 } 4116 $scope.getTagMembers(); 4117 4118 $scope.userId = AppConstants.CurrentUser.userId;
4119 4120 $scope.loadUrls(); 4121 4122 $scope.getAdminContacts(); 4123 4124 $scope.ajaxCall('/Sites/GetSiteImage', { customerId: $scope.sitedata.customerId, siteId: $scope.sitedata.siteId }, function (imageId) { 4125 $scope.logoId = imageId; 4126 }); 4127 4128 $scope.ajaxCall('/Customer/GetMember', { customerId: $scope.sitedata.customerId, userId: $scope.userId, includeAdminOnlyFields: false }, function (datax) { 4129 $scope.currentUser = datax; 4130 }); 4131 4132 $scope.avatar = AppConstants.CurrentUser.avatar; 4133 4134 sessionStorage.setItem("bungee-sitecookie-site", $scope.sitedata.siteSlug); 4135 } 4136 } 4137 } 4138 4139 if ($scope.sitedata.isMissingRequiredFields) { 4140 $scope.editUser(false); 4141 } 4142 4143 if (!$scope.isMember) { 4144 //sessionStorage.removeItem("bungee-sitecookie-site"); 4145 } 4146 4147 if ($scope.specialPageType == 'member-dashboard') { 4148 if (!$scope.isMember) { 4149 window.location.href = $scope.sitePrefix + '/'; 4150 } else { 4151 $scope.getDashboardData(); 4152 } 4153 } 4154 4155 $scope.params = new URLSearchParams(window.location.search); 4156 if ($scope.params.get("formId") != null) { 4157 $scope.submitDashboardForm($scope.params.get("formId")); 4158 } 4159 4160 $scope.userNumberOfHouseholds = 0; 4161 $scope.singleHouseholdWalletBalance = 0; 4162 if ($scope.isMember) { 4163 $scope.ajaxCall('/Households/GetMemberHouseholds', { customerId: $scope.sitedata.customerId, userId: $scope.userId }, function (data) { 4164 let count = 0; 4165 let indexOfWallet = -1; 4166 4167 for (let i = 0; i < data.length; i++) { 4168 if (data[i].walletBal != 0 && data[i].walletBal != null) { 4169 indexOfWallet = i; 4170 count++; 4171 } 4172 } 4173 4174 if (count == 1) { 4175 $scope.singleHouseholdWalletBalance = data[indexOfWallet].walletBal; 4176 } 4177 4178 $scope.userNumberOfHouseholds = count; 4179 }) 4180 } 4181 4182 //Move to here 4183 $scope.userBalance = "$0.00"; 4184 if ($scope.isMember) { 4185 $scope.ajaxCall('/Wallet/GetMemberWalletBalance', { customerId: $scope.sitedata.customerId, userId: $scope.userId }, function (data) { 4186 $scope.userBalance = data; 4187 }) 4188 } 4189 4190 $scope.userBalanceDec = 0.0; 4191 if ($scope.isMember) { 4192 $scope.ajaxCall('/Wallet/GetMyWalletBalance', { customerId: $scope.sitedata.customerId }, function (data) { 4193 $scope.userBalanceDec = data; 4194 }) 4195 } 4196 4197 jQuery(".pre-loader-public").fadeOut("fast"); 4198 }, function () { 4199 //window.location.href = '/'; 4200 }); 4201 } 4202 4203 $scope.loadedInitConversation = false; 4204 4205 $scope.conversations = []; 4206 $scope.newMessages = false; 4207 4208 $scope.refreshWalletBalance = function () { 4209 $scope.userNumberOfHouseholds = 0; 4210 $scope.singleHouseholdWalletBalance = 0; 4211 if ($scope.isMember) { 4212 $scope.ajaxCall('/Households/GetMemberHouseholds', { customerId: $scope.sitedata.customerId, userId: $scope.userId }, function (data) { 4213 let count = 0; 4214 let indexOfWallet = -1; 4215 4216 for (let i = 0; i < data.length; i++) { 4217 if (data[i].walletBal != 0 && data[i].walletBal != null) { 4218 indexOfWallet = i; 4219 count++; 4220 } 4221 } 4222 4223 if (count == 1) { 4224 $scope.singleHouseholdWalletBalance = data[indexOfWallet].walletBal; 4225 } 4226 $scope.userNumberOfHouseholds = count; 4227 }) 4228 } 4229 //Move to here 4230 $scope.userBalance = "$0.00"; 4231 if ($scope.isMember) { 4232 $scope.ajaxCall('/Wallet/GetMemberWalletBalance', { customerId: $scope.sitedata.customerId, userId: $scope.userId }, function (data) { 4233 $scope.userBalance = data; 4234 }) 4235 } 4236 4237 $scope.userBalanceDec = 0.0; 4238 if ($scope.isMember) { 4239 $scope.ajaxCall('/Wallet/GetMyWalletBalance', { customerId: $scope.sitedata.customerId }, function (data) { 4240 $scope.userBalanceDec = data; 4241 }) 4242 } 4243 } 4244 $scope.getConversations = function () { 4245 $scope.ajaxCall('/Sites/GetMyMessages', { customerId: $scope.sitedata.customerId }, function (data) { 4246 $scope.conversations = data; 4247 4248 if (!$scope.loadedInitConversation) { 4249 $scope.initConversations(); 4250 $scope.loadedInitConversation = true; 4251 } 4252 4253 $scope.newMessages = false; 4254 angular.forEach($scope.conversations, function (conversation) { 4255 if (conversation.newMessages) { 4256 $scope.newMessages = true; 4257 } 4258 }); 4259 if ($scope.selectedConversation != null) { 4260 var index = $scope.conversations.map(function (e) { return e.conversationId; }).indexOf($scope.selectedConversation.conversationId); 4261 $scope.selectedConversation = $scope.conversations[index]; 4262 4263 if ($scope.messagetab == "conversation") { 4264 $timeout(function () { 4265 var objDiv = document.getElementById("messagesContainerScroll"); 4266 jQuery("#messagesContainerScroll").animate({ scrollTop: objDiv.scrollHeight + 'px' }); 4267 }, 50); 4268 } 4269 4270 } 4271 }, function () { 4272 4273 }, false); 4274 } 4275 4276 $scope.getConversationsNoSpinner = function () { 4277 $scope.ajaxCall('/Sites/GetMyMessages', { customerId: $scope.sitedata.customerId }, function (data) { 4278 $scope.conversations = data; 4279 4280 $scope.newMessages = false; 4281 angular.forEach($scope.conversations, function (conversation) { 4282 if (conversation.newMessages) { 4283 $scope.newMessages = true; 4284 } 4285 }); 4286 if ($scope.selectedConversation != null) { 4287 var index = $scope.conversations.map(function (e) { return e.conversationId; }).indexOf($scope.selectedConversation.conversationId); 4288 $scope.selectedConversation = $scope.conversations[index]; 4289 4290 if ($scope.messagetab == "conversation") { 4291 $timeout(function () { 4292 var objDiv = document.getElementById("messagesContainerScroll"); 4293 jQuery("#messagesContainerScroll").animate({ scrollTop: objDiv.scrollHeight + 'px' }); 4294 }, 50); 4295 } 4296 } 4297 }, function () { 4298 4299 }, false); 4300 } 4301 4302 $scope.openEmojiPicker = function (id) { 4303 jQuery('.emoji-menu[data-id=' + id + ']').css('display', 'block'); 4304 } 4305 4306 $scope.initEmojis = function () { 4307 $(function () { 4308 //Super weird, this emoji plugin is difficult to tie into angular 4309 window.emojiPicker = new EmojiPicker({ 4310 emojiable_selector: '[data-emojiable=unicode]', 4311 assetsPath: '/plugins/emoji-picker/img/',
4312 popupButtonClasses: 'far fa-smile' 4313 }); 4314 window.emojiPicker.discover(); 4315 4316 jQuery('.emojiField[data-emojiable=unicode]').removeAttr('data-emojiable'); 4317 4318 $timeout(function () { 4319 jQuery('.emoji-picker').each(function () { 4320 var dataid = jQuery(this).attr('data-id'); 4321 jQuery(this).attr('onclick', 'openEmojiPicker("' + dataid + '");'); 4322 /*jQuery(this).siblings('.emoji-wysiwyg-editor').unbind('keypress').on('keypress', function (e) { 4323 if (e.which == 13) { 4324 var itemid = jQuery(this).siblings('[data-item-id]').first().attr('data-item-id'); 4325 4326 var newvalue = jQuery(this).html().replace(/'/g, "\'"); 4327 4328 $scope.ajaxCall('/Sites/AddComment', { customerId: $scope.sitedata.customerId, newsfeedId: itemid, message: newvalue }, function (data) { 4329 $scope.getNewsfeed(); 4330 }); 4331 } 4332 });*/ 4333 }); 4334 }, 100); 4335 }); 4336 } 4337 4338 $scope.newsfeeditems = []; 4339 $scope.newsfeedall = []; 4340 $scope.newsfeedpinned = []; 4341 $scope.newsfeedmine = []; 4342 4343 $scope.newsfeeddata = {}; 4344 4345 $scope.newsfeedId = null; 4346 $scope.subjects = null; 4347 $scope.subjectFilter = { selections: [] }; 4348 4349 $scope.updateNewsfeedFilters = function () { 4350 console.log("Updating filters"); 4351 if ($scope.subjectFilter.selections != null && $scope.subjectFilter.selections.length > 0) { 4352 $scope.newsfeedall = []; 4353 $scope.newsfeedpinned = []; 4354 $scope.newsfeedmine = []; 4355 4356 angular.forEach($scope.newsfeeddata.all, function (post) { 4357 var addPost = false; 4358 angular.forEach(post.subjectIds, function (subjectId) { 4359 if ($scope.subjectFilter.selections.includes(subjectId)) { 4360 addPost = true; 4361 } 4362 }); 4363 4364 if (addPost) { 4365 $scope.newsfeedall.push(post); 4366 } 4367 }); 4368 angular.forEach($scope.newsfeeddata.pinned, function (post) { 4369 var addPost = false; 4370 angular.forEach(post.subjectIds, function (subjectId) { 4371 if ($scope.subjectFilter.selections.includes(subjectId)) { 4372 addPost = true; 4373 } 4374 }); 4375 4376 if (addPost) { 4377 $scope.newsfeedpinned.push(post); 4378 } 4379 }); 4380 angular.forEach($scope.newsfeeddata.mine, function (post) { 4381 var addPost = false; 4382 angular.forEach(post.subjectIds, function (subjectId) { 4383 if ($scope.subjectFilter.selections.includes(subjectId)) { 4384 addPost = true; 4385 } 4386 }); 4387 4388 if (addPost) { 4389 $scope.newsfeedmine.push(post); 4390 } 4391 }); 4392 4393 console.log("Filters applied"); 4394 4395 } else { 4396 console.log("All, no filters"); 4397 $scope.newsfeedall = jQuery.extend(true, [], $scope.newsfeeddata.all); 4398 $scope.newsfeedpinned = jQuery.extend(true, [], $scope.newsfeeddata.pinned); 4399 $scope.newsfeedmine = jQuery.extend(true, [], $scope.newsfeeddata.mine); 4400 } 4401 4402 switch ($scope.newsfeedFilter) { 4403 case 'all': 4404 $scope.newsfeeditems = $scope.newsfeedall; 4405 break; 4406 case 'pinned': 4407 $scope.newsfeeditems = $scope.newsfeedpinned; 4408 break; 4409 case 'mine': 4410 $scope.newsfeeditems = $scope.newsfeedmine; 4411 break; 4412 } 4413 4414 } 4415 4416 $scope.getNewsfeed = function (widgetId) { 4417 if (widgetId) { 4418 $scope.newsfeedId = widgetId; 4419 } 4420 4421 $scope.ajaxCall('/Sites/GetNewsfeed', { customerId: $scope.sitedata.customerId, widgetId: $scope.newsfeedId, lazyload1: $scope.lazyload1, lazyload2: $scope.lazyload2, lazyload3: $scope.lazyload3 }, function (data) { 4422 $scope.newsfeeddata = jQuery.extend(true, {}, data); 4423 4424 $scope.newsfeedall = data.all; 4425 $scope.newsfeedpinned = data.pinned; 4426 $scope.newsfeedmine = data.mine; 4427 4428 switch ($scope.newsfeedFilter) { 4429 case 'all': 4430 $scope.newsfeeditems = $scope.newsfeedall; 4431 break; 4432 case 'pinned': 4433 $scope.newsfeeditems = $scope.newsfeedpinned; 4434 break; 4435 case 'mine': 4436 $scope.newsfeeditems = $scope.newsfeedmine; 4437 break; 4438 } 4439 4440 $scope.updateNewsfeedFilters(); 4441 }); 4442 } 4443 4444 $scope.recentNewsfeed = []; 4445 4446 $scope.getRecentNewsfeed = function (widget) { 4447 $scope.ajaxCall('/Sites/GetRecentNewsfeed', { customerId: $scope.sitedata.customerId, showAll: widget.newsfeedShowAllPosts }, function (data) { 4448 $scope.recentNewsfeed = data; 4449 }); 4450 $scope.ajaxCall('/Sites/GetNewsfeedUrl', { customerId: $scope.sitedata.customerId }, function (data) { 4451 $scope.newsfeedUrl = data; 4452 }); 4453 } 4454 4455 $scope.editNewsfeed = function (newsfeedId) { 4456 $uibModal.open({ 4457 templateUrl: 'create-post-modal', 4458 windowClass: "modal-xxl", 4459 4460 controller: function ($scope, $timeout, customerId, newsfeedId, widget) { 4461 $scope.customerId = customerId; 4462 $scope.widget = widget; 4463 4464 $scope.initCkEditor = function () { 4465 $timeout(function () { 4466 CKEDITOR.replace('editor2', { 4467 disallowedContent: 'img{*}' 4468 }).on('instanceReady', function (evt) { 4469 evt.editor.on('paste', function (e) { 4470 var data = e.data.dataValue; 4471 if (data) { 4472 data = data.replace(/<img[^>]*>/gi, ''); 4473 } 4474 4475 e.data.dataValue = data; 4476 }); 4477 }); 4478 }, 1); 4479 } 4480 4481 $scope.message = null; 4482 if (newsfeedId != null) { 4483 $scope.ajaxCall('/Sites/GetNewsfeedDetail
4483s', { customerId: $scope.customerId, newsfeedId: newsfeedId }, function (data) { 4484 $scope.message = data; 4485 }); 4486 } else { 4487 $scope.message = { title: '', text: '', attachments: [], subjectIds: [] }; 4488 if ($scope.widget.subjects != null && $scope.widget.subjects.length) { 4489 if (!$scope.message.subjectIds) { 4490 $scope.message.subjectIds = []; 4491 } 4492 4493 angular.forEach($scope.widget.subjects, function (subject) { 4494 $scope.message.subjectIds.push(subject.subjectId); 4495 }); 4496 $scope.message.subjectIds.push($scope.widget.subjects[0].subjectId); 4497 } 4498 4499 } 4500 4501 4502 $scope.file = null; 4503 4504 $scope.inUpload = false; 4505 $scope.startFileUpload = function (files) { 4506 $scope.inUpload = true; 4507 }; 4508 4509 $scope.successFileUpload = function (response) { 4510 $scope.inUpload = false; 4511 if (response.data.success) { 4512 $scope.file = response.data.results[0]; 4513 4514 $scope.message.attachments.push(response.data.results[0]); 4515 4516 if (!$scope.message.images) { 4517 $scope.message.images = []; 4518 } 4519 if (!$scope.message.documents) { 4520 $scope.message.documents = []; 4521 } 4522 if ($scope.file.fileType.includes('image')) { 4523 $scope.message.images.push(response.data.results[0]); 4524 } else { 4525 $scope.message.documents.push(response.data.results[0]); 4526 } 4527 } else { 4528 $scope.errorMessage('Your file exceeds the maximum file size of 15MB.'); 4529 } 4530 }; 4531 4532 $scope.removeFile = function (index) { 4533 var fileId = $scope.message.documents[index].fileId; 4534 4535 var sectionIndex = $scope.message.attachments.map(function (e) { return e.fileId; }).indexOf(fileId); 4536 $scope.message.attachments.splice(sectionIndex, 1); 4537 4538 $scope.message.documents.splice(index, 1); 4539 } 4540 4541 $scope.removeImageFile = function (index) { 4542 var fileId = $scope.message.images[index].fileId; 4543 4544 var sectionIndex = $scope.message.attachments.map(function (e) { return e.fileId; }).indexOf(fileId); 4545 $scope.message.attachments.splice(sectionIndex, 1); 4546 4547 $scope.message.images.splice(index, 1); 4548 } 4549 4550 $scope.imageSrc = function (fileId) { 4551 if (fileId != null) { 4552 return '/File/Get/' + fileId; 4553 } 4554 return null; 4555 }; 4556 4557 $scope.submitAttempt = false; 4558 $scope.saveChanges = function (form) { 4559 $scope.submitAttempt = true; 4560 4561 if (form.$invalid) { 4562 return; 4563 } 4564 4565 if ($scope.widget.subjects != null && $scope.widget.subjects.length == 1) { 4566 if (!$scope.message.subjectIds || !$scope.message.subjectIds.length) { 4567 return; 4568 } 4569 } 4570 4571 $scope.submitAttempt = false; 4572 4573 $scope.message.text = CKEDITOR.instances.editor2.getData(); 4574 4575 if (newsfeedId) { 4576 $scope.ajaxCall('/Sites/EditNewsfeed', { customerId: $scope.customerId, message: $scope.message }, function (data) { 4577 $scope.successMessage("Post Updated!"); 4578 $scope.$close(); 4579 }, function () { 4580 $scope.errorMessage("Unable to update post"); 4581 }); 4582 } else { 4583 $scope.ajaxCall('/Sites/CreateNewsfeed', { customerId: $scope.customerId, message: $scope.message }, function (data) { 4584 $scope.successMessage("Post Submitted!"); 4585 $scope.$close(); 4586 }, function () { 4587 $scope.errorMessage("Unable to submit post"); 4588 }); 4589 } 4590 } 4591 }, 4592 backdrop: 'static', 4593 resolve: { 4594 customerId: function () { return $scope.sitedata.customerId; }, 4595 newsfeedId: function () { return newsfeedId; }, 4596 widget: function () { return $scope.newsfeedWidget; }, 4597 } 4598 }).result.then(function () { 4599 $scope.getNewsfeed(); 4600 }, function () { 4601 4602 }); 4603 } 4604 4605 $scope.pin = function (newsfeed) { 4606 if ($scope.isBlocked) { 4607 return; 4608 } 4609 $uibModal.open({ 4610 templateUrl: 'pin-post-modal', 4611 controller: function ($scope, $timeout) {
4612 $scope.saveChanges = function () { 4613 $scope.$close(); 4614 } 4615 }, 4616 backdrop: 'static', 4617 resolve: { 4618 } 4619 }).result.then(function () { 4620 $scope.ajaxCall('/Sites/AddPin', { customerId: $scope.sitedata.customerId, newsfeedId: newsfeed.newsfeedId }, function (data) { 4621 $scope.getNewsfeed(); 4622 }); 4623 }, function () { 4624 4625 }); 4626 } 4627 4628 $scope.unpin = function (newsfeed) { 4629 if ($scope.isBlocked) { 4630 return; 4631 } 4632 4633 $uibModal.open({ 4634 templateUrl: 'unpin-post-modal', 4635 controller: function ($scope, $timeout) { 4636 $scope.saveChanges = function () { 4637 $scope.$close(); 4638 } 4639 }, 4640 backdrop: 'static', 4641 resolve: { 4642 } 4643 }).result.then(function () { 4644 $scope.ajaxCall('/Sites/RemovePin', { customerId: $scope.sitedata.customerId, newsfeedId: newsfeed.newsfeedId }, function (data) { 4645 $scope.getNewsfeed(); 4646 }); 4647 }, function () { 4648 4649 }); 4650 } 4651 4652 $scope.like = function (item) { 4653 $scope.ajaxCall('/Sites/AddLike', { customerId: $scope.sitedata.customerId, newsfeedId: item.newsfeedId }, function (data) { 4654 $scope.getNewsfeed(); 4655 }); 4656 } 4657 $scope.unlike = function (item) { 4658 $scope.ajaxCall('/Sites/RemoveLike', { customerId: $scope.sitedata.customerId, newsfeedId: item.newsfeedId }, function (data) { 4659 $scope.getNewsfeed(); 4660 }); 4661 } 4662 4663 $scope.keypressSendReply = function ($event, newsfeed, comment) { 4664 if ($event.keyCode == 13 && comment.newmessage.length) { 4665 4666 comment.newmessage = comment.newmessage.replace(/\n/g, "<br />"); 4667 4668 $scope.ajaxCall('/Sites/AddComment', { customerId: $scope.sitedata.customerId, newsfeedId: newsfeed.newsfeedId, message: comment.newmessage }, function (data) { 4669 comment.newmessage = ''; 4670 $scope.getNewsfeed(); 4671 }); 4672 } 4673 }; 4674 4675 4676 $scope.manualSendReply = function (newsfeed, comment) { 4677 if (comment.newmessage.length) { 4678 4679 comment.newmessage = comment.newmessage.replace(/\n/g, "<br />"); 4680 4681 var dataid = jQuery('#submission-' + newsfeed.newsfeedId).attr('data-id'); 4682 var newmessage = jQuery('#submission-' + newsfeed.newsfeedId).val(); 4683 var newmessage2 = jQuery('.emoji-wysiwyg-editor[data-id=' + dataid + ']').html(); 4684 newmessage = newmessage.replace(/\n/g, "<br />"); 4685 if (newmessage2 == undefined) { 4686 newmessage2 = newmessage; 4687 } 4688 $scope.ajaxCall('/Sites/AddComment', { customerId: $scope.sitedata.customerId, newsfeedId: newsfeed.newsfeedId, message: newmessage2 }, function (data) { 4689 comment.newmessage = ''; 4690 $scope.getNewsfeed(); 4691 }); 4692 } 4693 }; 4694 4695 4696 4697 $scope.expandedList = []; 4698 4699 $scope.toggleList = function (id) { 4700 if ($scope.expandedList.indexOf(id) == -1) { 4701 $scope.expandedList.push(id); 4702 } else { 4703 $scope.expandedList = $scope.expandedList.splice($scope.expandedList.indexOf(id), 1); 4704 } 4705 } 4706 4707 $scope.triggerEditComment = function (comment) { 4708 if ($scope.isBlocked) { 4709 return; 4710 } 4711 if (!$scope.sitedata.isNewsfeedAdmin && comment.userId != $scope.userId) { 4712 return; 4713 } 4714 4715 var commentObject = jQuery('#comment-' + comment.postId); 4716 4717 commentObject.prop('contenteditable', true).focus().blur(function () { 4718 jQuery(this).attr('contenteditable', false).unbind('blur'); 4719 var newhtml = jQuery(this).html(); 4720 4721 $scope.updateComment(comment, newhtml); 4722 }); 4723 4724 } 4725 4726 $scope.updateComment = function (comment, newhtml) { 4727 comment.text = newhtml.replace(/<a[^>]*>|<\/a>/g, ""); 4728 $scope.ajaxCall('/Sites/EditPost', { customerId: $scope.sitedata.customerId, message: comment }, function (data) { 4729 $scope.getNewsfeed(); 4730 }); 4731 } 4732 4733 $scope.lazyload1 = 5; 4734 $scope.lazyload2 = 5; 4735 $scope.lazyload3 = 5; 4736 4737 $scope.loadmore = function (filter) { 4738 switch (filter) { 4739 case 'all': 4740 $scope.lazyload1 += 3; 4741 break; 4742 case 'pinned': 4743 $scope.lazyload2 += 3; 4744 break; 4745 case 'mine': 4746 $scope.lazyload3 += 3; 4747 break; 4748 } 4749 4750 $scope.getNewsfeed(); 4751 } 4752 4753 4754 $scope.newsfeedFilter = 'all'; 4755 $scope.setNewsfeedFilter = function (filter) { 4756 switch (filter) { 4757 case 'all': 4758 $scope.newsfeeditems = $scope.newsfeedall; 4759 break; 4760 case 'pinned': 4761 $scope.newsfeeditems = $scope.newsfeedpinned; 4762 break; 4763 case 'mine': 4764 $scope.newsfeeditems = $scope.newsfeedmine; 4765 break; 4766 } 4767
4768 $scope.newsfeedFilter = filter; 4769 } 4770 4771 $scope.removeNewsfeed = function (postId) { 4772 $uibModal.open({ 4773 templateUrl: 'remove-post-modal', 4774 controller: function ($scope, $timeout) { 4775 $scope.remove = function () { 4776 $scope.$close(); 4777 } 4778 }, 4779 backdrop: 'static', 4780 resolve: { 4781 } 4782 }).result.then(function () { 4783 $scope.ajaxCall('/Sites/RemoveNewsfeed', { customerId: $scope.sitedata.customerId, newsfeedId: postId }, function (data) { 4784 $scope.getNewsfeed(); 4785 }); 4786 }, function () { 4787 4788 }); 4789 } 4790 4791 $scope.triggerBanUser = function (userId) { 4792 $uibModal.open({ 4793 templateUrl: 'ban-user-modal', 4794 controller: function ($scope, $timeout) { 4795 $scope.ban = function () { 4796 $scope.$close(); 4797 } 4798 }, 4799 backdrop: 'static', 4800 resolve: { 4801 } 4802 }).result.then(function () { 4803 $scope.ajaxCall('/Sites/BlockUser', { customerId: $scope.sitedata.customerId, userId: userId }, function (data) { 4804 $scope.getNewsfeed(); 4805 }); 4806 }, function () { 4807 4808 }); 4809 } 4810 4811 $scope.removeComment = function (postId) { 4812 $uibModal.open({ 4813 templateUrl: 'remove-comment-modal', 4814 controller: function ($scope, $timeout) { 4815 $scope.remove = function () { 4816 $scope.$close(); 4817 } 4818 }, 4819 backdrop: 'static', 4820 resolve: { 4821 } 4822 }).result.then(function () { 4823 $scope.ajaxCall('/Sites/RemoveComment', { customerId: $scope.sitedata.customerId, postId: postId }, function (data) { 4824 $scope.getNewsfeed(); 4825 }); 4826 }, function () { 4827 4828 }); 4829 } 4830 4831 $scope.loadSlider = function (index) { 4832 4833 $timeout(function () { 4834 jQuery('.imageSlider' + index).slick({ 4835 dots: true, 4836 infinite: true, 4837 adaptiveHeight: false, 4838 speed: 300, 4839 slidesToShow: 1, 4840 slidesToScroll: 1, 4841 arrows: true, 4842 responsive: [ 4843 { 4844 breakpoint: 1024, 4845 settings: { 4846 slidesToShow: 1, 4847 slidesToScroll: 1, 4848 infinite: true, 4849 dots: true 4850 } 4851 }, 4852 { 4853 breakpoint: 600, 4854 settings: { 4855 slidesToShow: 1, 4856 slidesToScroll: 1 4857 } 4858 }, 4859 { 4860 breakpoint: 480, 4861 settings: { 4862 slidesToShow: 1, 4863 slidesToScroll: 1 4864 } 4865 } 4866 ] 4867 }); 4868 }, 050); 4869 4870 } 4871 4872 $scope.loadForm = function (widget) { 4873 if (widget.formId) { 4874 4875 $scope.ajaxCall('/Customer/GetFormSetupPublic', { customerId: $scope.sitedata.customerId, formId: widget.formId }, function (data) { 4876 widget.formdata = data; 4877 widget.formReset = data; 4878 $scope.updateWidgetValue(widget); 4879 }); 4880 } 4881 } 4882 4883 $scope.loadOneTimeCharge = function (widget) { 4884 if (widget.oneTimeChargeId) { 4885 $scope.ajaxCall('/OneTimeCharge/GetOneTimeChargePublic', { customerId: $scope.sitedata.customerId, chargeId: widget.oneTimeChargeId }, function (data) { 4886 widget.chargedata = data; 4887 $scope.updateWidgetValue(widget); 4888 }, function () { 4889 4890 }, false); 4891 } 4892 } 4893 4894 $scope.resetForm = function (widget) { 4895 widget.formdata = jQuery.extend(true, {}, widget.formReset); 4896 widget.formReset = data; 4897 } 4898 4899 $scope.updateWidgetValue = function (widget) { 4900 var sectionIndex = $scope.currentPage.sections.map(function (e) { return e.sectionId; }).indexOf(widget.sectionId); 4901 4902 var istopwidget = true; 4903 var widgetindex1 = 0; 4904 var widgetindex2 = 0; 4905 4906 var w1 = 0; 4907 4908 angular.forEach($scope.currentPage.sections[sectionIndex].widgets, function (widget1) { 4909 4910 if (widget1.widgetId == widget.widgetId) { 4911 istopwidget = true; 4912 widgetindex1 = w1; 4913 } 4914 var w2 = 0; 4915 angular.forEach(widget1.widgets, function (widget2) { 4916 if (widget2.widgetId == widget.widgetId) { 4917 istopwidget = false; 4918 widgetindex1 = w1; 4919 widgetindex2 = w2; 4920 } 4921 w2++; 4922 }); 4923 4924 w1++; 4925 }); 4926 4927 //var widgetIndex = $scope.currentPage.sections[sectionIndex].widgets.map(function (e) { return e.widgetId; }).indexOf(widget.widgetId); 4928 if (istopwidget) { 4929 $scope.currentPage.sections[sectionIndex].widgets[widgetindex1] = jQuery.extend(true, {}, widget); 4930 } else { 4931 $scope.currentPage.sections[sectionIndex].widgets[widgetindex1].widgets[widgetindex2] = jQuery.extend(true, {}, widget); 4932 } 4933 } 4934 4935 $scope.memberSearchData = null; 4936 $scope.memberDirectorySearch = { input: "", value: "" }; 4937 $scope.pageList = []; 4938 $scope.gettingMembers = false; 4939 $scope.getMembers = function (page = 1) { 4940 if(!$scope.isMember) { 4941 return; 4942 } 4943 $scope.ajaxCall('/Customer/GetCustomerMembersDirectoryWithPagination', { customerId: $scope.sitedata.customerId, page: page, search: $scope.memberDirectorySearch.value }, function (data) { 4944 $scope.memberSearchData = data; 4945 $scope.members = $scope.memberSearchData.users; 4946 var count = 1; 4947 $scope.pageList = []; 4948 while (count <= $scope.memberSearchData.numPages) { 4949 $scope.pageList.push(count); 4950 count++; 4951 } 4952 $scope.membercount = $scope.members.length; 4953 $scope.loadGeomap(100); 4954 }); 4955 } 4956 4957 4958 $scope.searchMembers = function () { 4959 $scope.memberDirectorySearch.value = $scope.memberDirectorySearch.input; 4960 4961 $scope.memberSearch = $scope.memberSearchText; 4962 $scope.getMembers(1); 4963 } 4964 4965 $scope.clearMemberSearch = function () { 4966 4967 $scope.memberSearch = ""; 4968 $scope.memberSearchText = ""; 4969 } 4970 4971 $scope.addManualMemberFilter = function ($event) { 4972 if ($event.keyCode == 13) { 4973 $scope.searchMembers(); 4974 } 4975 }; 4976 4977 4978 $scope.hideMap = false; 4979 $scope.swapMemberDirectoryView = function () { 4980 $scope.hideMap = !$scope.hideMap;
4981 } 4982 4983 $scope.memberSearchText = ""; 4984 $scope.memberSearch = ""; 4985 $scope.members = []; 4986 $scope.membercount = 0; 4987 $scope.clickSponsor = function (sponsorId) { 4988 $scope.ajaxCall('/Sponsor/TriggerSponsorClick', { sponsorId: sponsorId }, function (data) { 4989 4990 }); 4991 } 4992 4993 $scope.sponsors = []; 4994 $scope.getsponsors = function () { 4995 $scope.ajaxCall('/Sponsor/GetCustomerSponsorsPublic', { customerId: $scope.sitedata.customerId }, function (data) { 4996 $scope.sponsors = []; 4997 var scount = 0; 4998 var sponsorobject = []; 4999 angular.forEach(data, function (sponsor) { 5000 if (scount == 4) { 5001 scount = 0; 5002 $scope.sponsors.push(sponsorobject); 5003 sponsorobject = []; 5004 } 5005 5006 sponsorobject.push(sponsor); 5007 5008 scount++; 5009 $scope.ajaxCall('/Sponsor/TriggerSponsorView', { sponsorId: sponsor.sponsorId }, function (data) { 5010 5011 }); 5012 5013 5014 }); 5015 if (sponsorobject.length) 5016 $scope.sponsors.push(sponsorobject); 5017 }); 5018 5019 } 5020 $scope.states = []; 5021 $scope.ajaxCall('/State/StateList', {}, function (data) { 5022 $scope.states = data; 5023 }, function () { 5024 5025 }, false); 5026 5027 5028 $scope.loadMap = function (widget) { 5029 5030 jQuery(document).ready(function () { 5031 var iframescript = ''; 5032 if (widget.gMapsAddress1 || widget.gMapsCity || widget.gMapsState || widget.gMapsZip) { 5033 //var address1 = widget.gMapsAddress1.replace(/ /g, '%20').replace(/_/g, '%20'); 5034 var search = ''; 5035 5036 if (widget.gMapsAddress1) { 5037 search += '%20' + encodeURI(widget.gMapsAddress1); 5038 } 5039 if (widget.gMapsAddress2) { 5040 search += '%20' + encodeURI(widget.gMapsAddress2); 5041 } 5042 if (widget.gMapsCity) { 5043 search += '%20' + encodeURI(widget.gMapsCity); 5044 } 5045 if (widget.gMapsState) { 5046 var stateIndex = $scope.states.map(function (e) { return e.stateId; }).indexOf(widget.gMapsState); 5047 search += '%20' + encodeURI($scope.states[stateIndex].name); 5048 } 5049 if (widget.gMapsZip) { 5050 search += '%20' + encodeURI(widget.gMapsZip); 5051 } 5052 5053 iframescript = '<iframe id="iframe-' + widget.widgetId + '" width="100%" height="100%" frameborder="0" style="border: 0" src="https://www.google.com/maps/embed/v1/place?q=' + search + '&key=AIzaSyDpOPKSpS9Jj2Iv9SP2J6OrAC-MERlJd0E" allowfullscreen></iframe>'; 5054 } else { 5055 iframescript = '<iframe id="iframe-' + widget.widgetId + '" width="100%" height="100%" frameborder="0" style="border: 0" src="https://www.google.com/maps/embed/v1/place?q=Houston,TX&key=AIzaSyDpOPKSpS9Jj2Iv9SP2J6OrAC-MERlJd0E" allowfullscreen></iframe>'; 5056 } 5057 5058 jQuery('[data-iframe-widgetid="' + widget.widgetId + '"]').empty().html(iframescript); 5059 5060 }); 5061 } 5062 5063 $scope.imageSrc = function (fileId) { 5064 if (fileId != null) { 5065 return '/File/Get/' + fileId; 5066 } 5067 return null; 5068 }; 5069 $scope.initEvoCalendar = function (widget) { 5070 jQuery('.evoCalendar').evoCalendar({ 5071 todayHighlight: true, 5072 sidebarToggler: false, 5073 eventListToggler: false, 5074 onAddEvent: null, 5075 eventDisplayDefault: false, 5076 sidebarDisplayDefault: false, 5077 calendarEvents: [ 5078 ], 5079 onSelectDate: function () { 5080 }, 5081 onAddEvent: function () { 5082 } 5083 5084 }); 5085 } 5086 5087 $scope.memberDetails = function (member) { 5088 $uibModal.open({ 5089 size: 'lg', 5090 templateUrl: 'member-detail-modal', 5091 controller: function ($scope, $timeout, member) { 5092 $scope.member = member; 5093 }, 5094 backdrop: 'static', 5095 resolve: { 5096 member: function () { 5097 return member; 5098 }, 5099 } 5100 }).result.then(function () { 5101 }, function () { 5102 5103 }); 5104 }; 5105 5106 $scope.blockContentModal = function (data) { 5107 $uibModal.open({ 5108 templateUrl: 'outstanding-modal', 5109 controller: function ($scope, $timeout) { 5110 }, 5111 backdrop: 'static', 5112 resolve: { 5113 } 5114 }).result.then(function () { 5115 $scope.ajaxCall('/Customer/GetDuesUrl', { customerId: data.customerId }, function (duesUrlData) { 5116 console.log(duesUrlData) 5117 console.log(window.location.href) 5118 if (window.location.href.includes(duesUrlData)) { 5119 $scope.hideNav = true; 5120 } else { 5121 window.location.href = $scope.sitePrefix + "/" + duesUrlData; 5122 return; 5123 } 5124 }); 5125 }); 5126 }; 5127 5128 5129 5130 $scope.switchSiteModal = function () { 5131 console.log("LOGGING :)"); 5132 console.log($scope.currentUser); 5133 $uibModal.open({ 5134 templateUrl: 'switch-site-modal', 5135 controller: function ($scope, $timeout, DTOptionsBuilder, DTColumnDefBuilder, $compile) { 5136 $scope.switchsites = []; 5137 $scope.ajaxCall('/User/GetMyAdminSites', {}, function (data) { 5138 $scope.switchsites = data; 5139 }); 5140 5141 $scope.changeSite = function (slug, name) { 5142 if (AppConstants.CurrentUser.isAdmin) { 5143 $scope.setUrl('/#!/' + slug + '/dashboard'); 5144 return; 5145 } 5146 5147 var siteindex = AppConstants.CurrentUser.sites.map(function (e) { return e.customerSlug; }).indexOf(slug); 5148 if (siteindex != -1) { 5149 var selectedSite = AppConstants.CurrentUser.sites[siteindex]; 5150 5151 if (selectedSite.customDomain && !AppConstants.CurrentUser.isAdmin) { 5152 //$scope.setUrl(selectedSite.customDomain + '/admin-dashboard/#!/' + selectedSite.customerSlug + '/dashboard'); 5153 $scope.transferToInternalSite(selectedSite.customDomain, selectedSite.customerId); 5154 } else if (!AppConstants.CurrentUser.isAdmin) { 5155 //$scope.setUrl(selectedSite.dashboardUrl + '/#!/' + selectedSite.customerSlug + '/dashboard'); 5156 $scope.transferToInternalSite(selectedSite.dashboardUrl, selectedSite.customerId); 5157 } else { 5158 $scope.setUrl(selectedSite.dashboardUrl + '/#!/' + selectedSite.customerSlug + '/dashboard'); 5159 } 5160 $scope.$close(); 5161 } 5162 } 5163 5164 $scope.searchName = ""; 5165 $scope.doSearch = function () { 5166 if ($scope.dt.instance) { 5167 $scope.dt.instance.reloadData(); 5168 } 5169 }; 5170 $scope.clearSearch = function () { 5171 $scope.searchName = ""; 5172 $scope.doSearch(); 5173 }; 5174 5175 $scope.checkDoSearch = function ($event) { 5176 if ($event.keyCode == 13) { 5177 $scope.doSearch(); 5178 } 5179 } 5180 5181 $scope.currentSite = $scope.getSite(); 5182 5183 $scope.mobileRender = function (api, rowIdx, columns) { 5184 var data = $.map(columns, function (col, i) { 5185 return col.hidden ? 5186 '<li data-dtr-index="' + col.columnIndex + '" data-dt-row="' + col.rowIndex + '" data-dt-column="' + col.columnIndex + '">' + 5187 '<span class="dtr-title">' + 5188 col.title + 5189 '</span> ' + 5190 '<span class="dtr-data">' + 5191 col.data + 5192 '</span>' + 5193 '</li>' : 5194 ''; 5195 }).join(''); 5196 5197 return data ? 5198 $compile(angular.element($('<ul data-dtr-index="' + rowIdx + '" class="dtr-details" />').append(data)))($scope) : 5199 false; 5200 } 5201 5202 $scope.dt = { 5203 instance: null, 5204 options: DTOptionsBuilder.newOptions() 5205 .withDOM('tip') 5206 .withOption('ajax', function (data, callback, settings) { 5207 data.name = $scope.searchName; 5208 5209 $scope.ajaxCall('/User/SiteList', data, function (results) { 5210 callback(results); 5211 }); 5212 }) 5213 .withDataProp('data') 5214 .withOption('serverSide', true) 5215 .withOption('bFilter', false) 5216 .withOption('responsive', { details: { renderer: $scope.mobileRender } }) 5217 .withDisplayLength(5) 5218 .withLanguage({ 5219 'oPaginate': { 5220 'sPrevious': '<i class="far fa-arrow-left"></i>', 5221 'sNext': '<i class="far fa-arrow-right"></i>' 5222 } 5223 }) 5224 .withOption('order', [[0, 'asc']]) 5225 .withOption('initComplete', function () { 5226 $('#sitePagination .dt-pagination-info').empty().html($('#' + $scope.dt.instance.id + '_wrapper .dataTables_info')); 5227 $('#sitePagination .paginate-buttons-here').empty().html($('#' + $scope.dt.instance.id + '_wrapper .dataTables_paginate')); 5228 }) 5229 .withOption('fnFooterCallback', function () { 5230 }) 5231 .withOption('createdRow', function (nRow, aData, iDataIndex) { 5232 $compile(nRow)($scope); 5233 }), 5234 columns: [ 5235 DTColumnDefBuilder.newColumnDef(0).withTitle('Name').withOption('name', 'customerName').withClass('').withOption('mDataProp', 'customerName'), 5236 DTColumnDefBuilder.newColumnDef(1).withTitle('Actions').notSortable().withClass('actions text-right') 5237 .renderWith(function (data, type, full) { 5238 return '<span ng-if="' + (full.customerSlug == $scope.currentSite) + '">current</span><a ng-if="' + (full.customerSlug != $scope.currentSite) + '" data-toggle="tooltip" title="Switch" class="action-circle mr-2" href="javascript:void(0)" ng-click="changeSite(\'' + full.customerSlug + '\', \'' + full.customerName.replace(/'/g, "\\'") + '\')" data-original-title="Go to this site"><i class="fas fa-arrow-right"></i></a>'; 5239 }), 5240 ] 5241 }; 5242 5243 $scope.doSearch(); 5244 }, 5245 backdrop: 'static', 5246 resolve: { 5247 } 5248 }).result.then(function () { 5249 5250 }, function () { 5251 }); 5252 } 5253 5254 $scope.manageCards = function (due) { 5255 $uibModal.open({ 5256 size: 'lg', 5257 templateUrl: 'manage-cards-modal', 5258 controller: function ($scope, $timeout, customerId, due, sitedata, user) { 5259 console.log(user); 5260 $scope.due = jQuery.extend(true, {}, due); 5261 $scope.sitedata = sitedata; 5262 5263 $scope.elements = null; 5264 $scope.style = null; 5265 $scope.card = null; 5266 $scope.paymentType = "card";
5267 $scope.plaidObject = { plaidLinked: false }; 5268 5269 $scope.customerId = customerId; 5270 $scope.stripeapi = null; 5271 5272 $scope.stripeApiKey = null; 5273 $scope.ajaxCall('/Customer/GetMyStripeCustomerInfo', { customerId: $scope.customerId }, function (data) { 5274 $scope.stripeapi = Stripe(data);//stripe dev key, replace with live! 5275 $scope.stripeApiKey = data; 5276 //$scope.loadStripe = function () { 5277 $scope.elements = $scope.stripeapi.elements(); 5278 5279 // Custom styling can be passed to options when creating an Element. 5280 // (Note that this demo uses a wider set of styles than the guide below.) 5281 $scope.style = { 5282 base: { 5283 color: '#32325d', 5284 fontFamily: '"Helvetica Neue", Helvetica, sans-serif', 5285 fontSmoothing: 'antialiased', 5286 fontSize: '16px', 5287 '::placeholder': { 5288 color: '#495057', 5289 }, 5290 border: '1px solid #ced4da', 5291 5292 }, 5293 invalid: { 5294 color: '#fa755a', 5295 iconColor: '#fa755a' 5296 } 5297 }; 5298 5299 $scope.card = $scope.elements.create('card', { style: $scope.style }); 5300 $scope.card.mount('#stripe-card-element'); 5301 // } 5302 5303 5304 }); 5305 5306 $scope.paymentMethods = []; 5307 $scope.getPaymentMethods = function () { 5308 $scope.ajaxCall('/Customer/GetMyPaymentMethods', { customerId: $scope.customerId }, function (data) { 5309 $scope.paymentMethods = data; 5310 5311 $timeout(function () { 5312 jQuery('.paymentMethodList').each(function () { 5313 if (jQuery(this).val() == $scope.due.paymentMethod) { 5314 jQuery(this).prop('checked', true); 5315 } 5316 }); 5317 }, 50) 5318 }); 5319 } 5320 5321 $scope.selectedPaymentMethod = null; 5322 $scope.getPaymentMethods(); 5323 5324 $scope.remove = function (paymentMethodId) { 5325 $uibModal.open({ 5326 templateUrl: 'remove-card-modal', 5327 controller: function ($scope, $timeout) { 5328 $scope.remove = function () { 5329 $scope.$close(); 5330 } 5331 }, 5332 backdrop: 'static', 5333 resolve: { 5334 } 5335 }).result.then(function () { 5336 $scope.ajaxCall('/Customer/RemoveMyPaymentMethod', { customerId: $scope.customerId, paymentMethodId }, function (data) { 5337 $scope.getPaymentMethods(); 5338 }); 5339 }, function () { 5340 5341 }); 5342 } 5343 5344 5345 $scope.errorHappened = false; 5346 $scope.addCard = function () { 5347 if ($scope.paymentType == "card") { 5348 5349 /* 5350 const payload = await $scope.stripeapi.createPaymentMethod({ 5351 type: 'card', 5352 card: $scope.card, 5353 }); 5354 5355 console.log(payload); 5356 5357 $scope.stripeapi.createToken($scope.card).then(function (result) { 5358 if (result.error) { 5359 $scope.errorHappened = true; 5360 } else { 5361 $scope.errorHappened = false; 5362 $scope.ajaxCall('/Customer/SaveMyPaymentMethod', { customerId: $scope.customerId, paymentMethod: payload.paymentMethod }, function (data) { 5363 $scope.getPaymentMethods(); 5364 $scope.card.clear(); 5365 }); 5366 } 5367 }); 5368 */ 5369 $scope.stripeapi.createToken($scope.card).then(function (result) { 5370 if (result.error) { 5371 $scope.errorHappened = true; 5372 } else { 5373 $scope.errorHappened = false; 5374 $scope.ajaxCall('/Customer/SaveMyPaymentMethod', { customerId: $scope.customerId, paymentMethod: result.token }, function (data) { 5375 $scope.getPaymentMethods(); 5376 $scope.card.clear(); 5377 }); 5378 } 5379 }); 5380 5381 } 5382 else if ($scope.paymentType == "plaid") { 5383 $scope.errorHappened = false; 5384 $scope.ajaxCall('/Customer/SaveMyPaymentMethodPlaid', { customerId: $scope.customerId, plaidObject: $scope.plaidObject }, function (data) { 5385 $scope.getPaymentMethods(); 5386 $scope.card.clear(); 5387 $scope.plaidLinked = false; 5388 }); 5389 } 5390 } 5391 5392 $scope.pendingAchAccount = ''; 5393 $scope.pendingAchId = ''; 5394 5395 $scope.loadStripeACH = function () { 5396 5397 $scope.pendingAchAccount = ''; 5398 $scope.pendingAchId = ''; 5399 5400 console.log("Started payment setup -- 3"); 5401 $scope.ajaxCall('/Stripe/CreatePaymentSetupIntent', { customerId: $scope.sitedata.customerId }, function (data) { 5402 if (data == "n/a") { 5403 $scope.sitedata.plaidEnabled = false; 5404 //Unable to connect to plaid, don't show it 5405 } else { 5406 $scope.plaidLoaded = true; 5407 5408 var datasplit = data.split('|'); 5409 5410 $scope.stripeapi = Stripe($scope.stripeApiKey, { stripeAccount: datasplit[1] });//stripe dev key, replace with live! 5411 5412 $scope.pendingAchAccount = datasplit[0];
5413 $scope.pendingAchId = datasplit[2]; 5414 5415 // Calling this method will open the instant verification dialog. 5416 $scope.stripeapi.collectBankAccountForSetup({ 5417 clientSecret: datasplit[0], 5418 params: { 5419 payment_method_type: 'us_bank_account', 5420 payment_method_data: { 5421 billing_details: { 5422 name: user.firstName + " " + user.lastName, 5423 email: user.emailAddress, 5424 }, 5425 }, 5426 }, 5427 expand: ['payment_method'], 5428 }) 5429 .then(({ setupIntent, error }) => { 5430 if (error) { 5431 console.error(error.message); 5432 // PaymentMethod collection failed for some reason. 5433 } else if (setupIntent.status === 'requires_payment_method') { 5434 // Customer canceled the hosted verification modal. Present them with other 5435 // payment method type options. 5436 console.log("MEHEHH"); 5437 return; 5438 } else if (setupIntent.status === 'requires_confirmation') { 5439 // We collected an account - possibly instantly verified, but possibly 5440 // manually-entered. Display payment method details and mandate text 5441 // to the customer and confirm the intent once they accept 5442 // the mandate. 5443 console.log("Make mandate"); 5444 //confirmationForm.show(); 5445 $scope.plaidObject.plaidLinked = true; 5446 5447 } 5448 }); 5449 } 5450 5451 $scope.confirmStripeACH = function () { 5452 $scope.stripeapi.confirmUsBankAccountSetup($scope.pendingAchAccount) 5453 .then(({ setupIntent, error }) => { 5454 if (error) { 5455 console.error(error.message); 5456 $scope.errorMessage("Unable to link your account. Please try with a different payment method."); 5457 } else if (setupIntent.status === "requires_payment_method") { 5458 $scope.errorMessage("Unable to link your account. Please try with a different payment method."); 5459 } else if (setupIntent.status === "succeeded") { 5460 $scope.ajaxCall('/Stripe/FinalizePaymentSetupIntent', { customerId: $scope.sitedata.customerId, paymentMethodId: $scope.pendingAchId }, function (data) { 5461 $scope.pendingAchAccount = ''; 5462 $scope.pendingAchId = ''; 5463 5464 $scope.getPaymentMethods(); 5465 $scope.card.clear(); 5466 $scope.plaidObject.plaidLinked = false; 5467 }); 5468 } else if (setupIntent.next_action?.type === "verify_with_microdeposits") { 5469 $scope.errorMessage(""); 5470 } 5471 }); 5472 5473 } 5474 5475 }, function () { 5476 $scope.sitedata.plaidEnabled = false; 5477 5478 return; 5479 }, false); 5480 } 5481 5482 $scope.loadCardPlaid = function () { 5483 $scope.ajaxCall('/Pricing/GetCustomerPlaidToken', { customerId: $scope.sitedata.customerId }, function (data) { 5484 if (data == "n/a") { 5485 $scope.sitedata.plaidEnabled = false; 5486 //Unable to connect to plaid, don't show it 5487 } else { 5488 $scope.plaidLoaded = true; 5489 5490 $scope.eventLinkHandler = Plaid.create({ 5491 env: 'production', 5492 clientName: $scope.sitedata.siteName, 5493 token: data, 5494 product: ['auth'], 5495 apiVersion: 'v2', 5496 selectAccount: true, 5497 onSuccess: function (public_token, metadata) { 5498 // Send the public_token and account ID to your app server.
5499 $scope.plaidObject.plaidtoken = public_token; 5500 $scope.plaidObject.plaidid = metadata.account_id; 5501 $scope.plaidObject.plaidLinked = true; 5502 $scope.plaidObject.plaidInstitution = metadata.institution.name; 5503 $scope.$apply(); 5504 5505 $scope.errorHappened = false; 5506 $scope.ajaxCall('/Customer/SaveMyPaymentMethodPlaid', { customerId: $scope.customerId, plaidObject: $scope.plaidObject }, function (data) { 5507 $scope.getPaymentMethods(); 5508 $scope.card.clear(); 5509 $scope.plaidObject = { plaidLinked: false }; 5510 }, function () { 5511 $scope.plaidObject.plaidtoken = ""; 5512 $scope.plaidObject.plaidid = ""; 5513 $scope.plaidObject.plaidLinked = false; 5514 $scope.plaidObject.plaidInstitution = ""; 5515 }, true); 5516 5517 }, 5518 onExit: function (err, metadata) { 5519 // The user exited the Link flow. 5520 if (err != null) { 5521 // The user encountered a Plaid API error prior to exiting. 5522 } 5523 }, 5524 }); 5525 5526 // Trigger the Link UI 5527 document.getElementById('cardsLinkButton').onclick = function () { 5528 $scope.eventLinkHandler.open(); 5529 }; 5530 } 5531 5532 }, function () { 5533 $scope.sitedata.plaidEnabled = false; 5534 5535 return; 5536 }, false); 5537 5538 $scope.$apply(); 5539 } 5540 5541 $scope.noCardSelected = false; 5542 $scope.saveChanges = function () { 5543 $scope.noCardSelected = true; 5544 5545 var newvalue = null; 5546 jQuery('.paymentMethodList').each(function () { 5547 if (jQuery(this).prop('checked') == true) { 5548 newvalue = jQuery(this).val(); 5549 } 5550 }); 5551 5552 if (newvalue == null) { 5553 return; 5554 } 5555 $scope.noCardSelected = false; 5556 5557 $scope.due.paymentMethod = newvalue; 5558 $scope.$close($scope.due); 5559 } 5560 // Create an instance of the card Element. 5561 }, 5562 backdrop: 'static', 5563 resolve: { 5564 customerId: function () { 5565 return $scope.sitedata.customerId; 5566 }, 5567 due: function () { 5568 return due; 5569 }, 5570 sitedata: function () { 5571 return $scope.sitedata; 5572 }, 5573 user: function () { 5574 return AppConstants.CurrentUser; 5575 } 5576 } 5577 }).result.then(function (data) { 5578 due.paymentMethod = data.paymentMethod; 5579 due.autopayEnabled = data.autopayEnabled; 5580 5581 $scope.getPaymentMethods(); 5582 5583 $scope.ajaxCall('/Customer/UpdateMemberAutopay', { customerId: $scope.sitedata.customerId, dueId: due.dueId, paymentId: due.paymentMethod, autopay: due.autopayEnabled }, function (data) { 5584 5585 }); 5586 }, function () { 5587 5588 }); 5589 }; 5590 5591 $scope.card = null; 5592 $scope.stripeapi = null; 5593 5594 $scope.loadStripe = function () { 5595 $scope.ajaxCall('/Customer/GetMyStripeCustomerInfo', { customerId: $scope.sitedata.customerId }, function (data) { 5596 $scope.stripeapi = Stripe(data);//stripe dev key, replace with live! 5597 5598 //$scope.loadStripe = function () { 5599 $scope.elements = $scope.stripeapi.elements(); 5600 5601 // Custom styling can be passed to options when creating an Element. 5602 // (Note that this demo uses a wider set of styles than the guide below.) 5603 $scope.style = { 5604 base: { 5605 color: '#32325d', 5606 fontFamily: '"Helvetica Neue", Helvetica, sans-serif', 5607 fontSmoothing: 'antialiased', 5608 fontSize: '16px', 5609 '::placeholder': { 5610 color: '#495057', 5611 }, 5612 border: '1px solid #ced4da', 5613 5614 }, 5615 invalid: { 5616 color: '#fa755a', 5617 iconColor: '#fa755a' 5618 } 5619 }; 5620 5621 $scope.card = $scope.elements.create('card', { style: $scope.style }); 5622 $scope.card.mount('#stripe-card-element'); 5623 // } 5624 5625 5626 }); 5627 } 5628 5629 $scope.viewInvoiceInfo = function (info, paid) { 5630 $uibModal.open({ 5631 templateUrl: 'invoice-info-modal', 5632 controller: function ($scope, $timeout, info, paid, customerId) { 5633 $scope.info = info; 5634 $scope.paid = paid; 5635 $scope.customerId = customerId; 5636 5637 $scope.sendReceipt = function () { 5638 $scope.ajaxCall('/Customer/ResendReceipt', { customerId: $scope.customerId, paymentId: info.paymentId }, function (data) { 5639 $scope.successMessage("Receipt sent!"); 5640 }); 5641 } 5642 }, 5643 backdrop: 'static', 5644 resolve: { 5645 info: function () { 5646 return info; 5647 }, 5648 paid: function () { 5649 return paid; 5650 }, 5651 customerId: function () { 5652 return $scope.sitedata.customerId; 5653 }, 5654 } 5655 }).result.then(function () { 5656 }, function () { 5657 5658 }); 5659 }; 5660 5661 $scope.viewChargePaymentInfo = function (info) { 5662 $uibModal.open({ 5663 templateUrl: 'charge-payment-info-modal', 5664 controller: function ($scope, $timeout, info, customerId) { 5665 $scope.info = info; 5666 console.log($scope.info); 5667 $scope.customerId = customerId; 5668 5669 $scope.sendReceipt = function () { 5670 $scope.ajaxCall('/OneTimeCharge/TriggerResendInvoiceEmail', { paymentId: info.paymentId }, function (data) { 5671 $scope.successMessage("Receipt sent!"); 5672 }); 5673 } 5674 }, 5675 backdrop: 'static', 5676 resolve: { 5677 info: function () { 5678 return info; 5679 }, 5680 customerId: function () { 5681 return $scope.sitedata.customerId; 5682 }, 5683 } 5684 }).result.then(function () { 5685 }, function () { 5686 5687 }); 5688 }; 5689 5690 $scope.makePayment = function (info, paymentMethods) { 5691 if (info.paymentMethod == null) { 5692 info.requiresPaymentMethod = true; 5693 return; 5694 } 5695 5696 var paymentMethodIndex = paymentMethods.map(function (e) { return e.paymentMethodId }).indexOf(info.paymentMethod); 5697 if (paymentMethodIndex == -1) { 5698 return; 5699 } 5700 5701 info.requiresPaymentMethod = false; 5702 5703 $uibModal.open({ 5704 templateUrl: 'make-payment-modal', 5705 controller: function ($scope, $timeout, info, customerId, paymentMethod, userBalanceDec, useWallet) { 5706 console.log("MMeh"); 5707 console.log(paymentMethod); 5708 $scope.paymentMethod = paymentMethod; 5709 $scope.info = info; 5710 $scope.userBalanceDec = userBalanceDec; 5711 $scope.customerId = customerId; 5712 $scope.lockPaymentAmount = false; 5713 $scope.maxPaymentAmount = 0; 5714 $scope.lateFee = 0; 5715 $scope.householdWalletBalance = 0; 5716 $scope.useWallet = useWallet; 5717 $scope.useWallet = false; 5718 $scope.junk = false; 5719 5720 console.log(paymentMethod); 5721 5722 $scope.ajaxCall('/Customer/GetMyStripeCustomerInfo', { customerId: $scope.customerId }, function (data) { });
5723 5724 if (info.isHouseholdDue) { 5725 $scope.ajaxCall('/Wallet/GetMyHouseholdWalletBalance', { customerId: $scope.customerId, householdId: info.householdId }, function (res) { $scope.householdWalletBalance = res }); 5726 5727 } 5728 5729 $scope.formatDecimals = function (number) { 5730 return parseFloat(number).toFixed(2); 5731 } 5732 5733 $scope.flipUseWallet = function () { 5734 $scope.useWallet = !$scope.useWallet; 5735 $scope.calculatePaymentAmount(); 5736 } 5737 5738 $scope.formatPayment = function () { 5739 if ($scope.info.paymentAmount < 0) { 5740 $scope.info.paymentAmount = 0.00; 5741 } 5742 5743 if (($scope.info.paymentAmount > $scope.maxPaymentAmount) || (($scope.maxPaymentAmount - $scope.info.paymentAmount) < 1)) { 5744 $scope.info.paymentAmount = $scope.maxPaymentAmount.toString(); 5745 } 5746 5747 if ($scope.info.paymentAmount != $scope.formatDecimals($scope.info.paymentAmount)) { 5748 $scope.info.paymentAmount = $scope.formatDecimals($scope.info.paymentAmount); 5749 } 5750 } 5751 5752 $scope.calculatePaymentAmount = function () { 5753 var paymentAmount = 0; 5754 var invoices = 0; 5755 $scope.lateFee = 0; 5756 5757 angular.forEach($scope.info.invoices, function (invoice) { 5758 if (invoice.submitPayment) { 5759 paymentAmount += invoice.price; 5760 $scope.lateFee += invoice.lateFee; 5761 invoices++; 5762 } 5763 }); 5764 5765 $scope.maxPaymentAmount = paymentAmount; 5766 $scope.info.paymentAmount = paymentAmount; 5767 var base = $scope.info.paymentAmount; 5768 /*if ($scope.useWallet) { 5769 if ($scope.info.isHouseholdDue) { 5770 base = base - $scope.householdWalletBalance; 5771 } 5772 else { 5773 base = base - $scope.userBalanceDec; 5774 } 5775 if (base < 0) { 5776 base = 0; 5777 } 5778 }*/ 5779 $scope.info.paymentAmount = base; 5780 $scope.formatPayment(); 5781 $scope.lockPaymentAmount = (invoices != 1); 5782 } 5783 5784 5785 5786 $scope.calculateConvenienceFeeWithWallet = function (value, percentage, dollarAmount, lateFee) { 5787 if (isNaN(percentage) || percentage == null) { 5788 percentage = 0; 5789 } 5790 5791 if (isNaN(dollarAmount) || dollarAmount == null) { 5792 dollarAmount = 0; 5793 } 5794 5795 if (isNaN(lateFee) || lateFee == null) { 5796 lateFee = 0; 5797 } 5798 5799 if (isNaN(value) || value == null) { 5800 value = 0; 5801 } 5802 5803 var charge = (parseFloat(value) + lateFee); 5804 5805 if ($scope.useWallet) { 5806 if ($scope.info.isHouseholdDue) { 5807 charge = charge - $scope.householdWalletBalance; 5808 } 5809 else { 5810 charge = charge - $scope.userBalanceDec; 5811 } 5812 if (charge <= 0) { 5813 return 0; 5814 } 5815 } 5816 5817 return ((charge + parseFloat(dollarAmount)) / (1 - (parseFloat(percentage) / 100)) - charge); 5818 } 5819 5820 $scope.calculateTotalPayment = function () { 5821 var base = 0; 5822 console.log("calculating"); 5823 if ($scope.info.paymentAmount != 0 && $scope.info.paymentAmount != null) { 5824 if ($scope.info.enableConvenienceFee) { 5825 if ($scope.paymentMethod.isAch) { 5826 base = ($scope.calculateConvenienceFee($scope.info.paymentAmount, $scope.info.convenienceFeePercentagePlaid, $scope.info.convenienceFeeDollarAmountPlaid, $scope.lateFee) + parseFloat($scope.info.paymentAmount) + $scope.lateFee); 5827 } else { 5828 base = ($scope.calculateConvenienceFeeWithWallet($scope.info.paymentAmount, $scope.info.convenienceFeePercentage, $scope.info.convenienceFeeDollarAmount, $scope.lateFee) + parseFloat($scope.info.paymentAmount) + $scope.lateFee); 5829 } 5830 } else { 5831 base = (parseFloat($scope.info.paymentAmount) + $scope.lateFee); 5832 } 5833 } else { 5834 base = 0; 5835 } 5836 //Subtract wallet balance if they want it, clamp at 0 5837 if ($scope.useWallet) { 5838 if ($scope.info.isHouseholdDue) { 5839 base = base - $scope.householdWalletBalance; 5840 } 5841 else { 5842 base = base - $scope.userBalanceDec; 5843 } 5844 if (base < 0) { 5845 base = 0; 5846 } 5847 } 5848 return base; 5849 }; 5850 5851 $scope.selectedPayments = true; 5852 5853 $scope.submitAttempt = false; 5854 5855 $scope.submittingPayment = false; 5856 $scope.blockSubmit = false; 5857 5858 $scope.pay = function () { 5859 $scope.submitAttempt = true; 5860 var paidIndex = $scope.info.invoices.map(function (e) { return e.submitPayment; }).indexOf(true); 5861 if (paidIndex == -1) { 5862 $scope.selectedPayments = false; 5863 return; 5864 } 5865 5866 if ($scope.info.paymentAmount <= 0) { 5867 if ($scope.info.paymentAmount != 0 || !$scope.useWallet || $scope.info.invoices.length == 0) { 5868 return 5869 } 5870 //Otherwise, they have chosen invoices to pay, using a wallet balance, and they have not bugged the system to get a negative payment amt 5871 } 5872 $scope.submitAttempt = false; 5873 5874 if ($scope.submittingPayment) { 5875 return; 5876 } 5877 5878 $scope.submittingPayment = true; 5879 5880 if ($scope.blockSubmit) { 5881 return; 5882 } 5883 $scope.blockSubmit = true; 5884 5885 5886 grecaptcha.execute('6LeBhgskAAAAAE14Yen7FmvsB0LI-rK5DBohK0GX', { action: 'submit' }).then(function (token) { 5887 $scope.ajaxCall('/Customer/MakeMemberPayment', { customerId: $scope.customerId, dueinfo: $scope.info, useWalletBalance: $scope.useWallet }, function (data) { 5888 $scope.submittingPayment = false; 5889 $scope.blockSubmit = false; 5890 5891 $scope.$close(); 5892 }, function () { 5893 $scope.blockSubmit = false; 5894 }); 5895 }); 5896 } 5897 5898 }, 5899 backdrop: 'static', 5900 resolve: { 5901 info: function () { 5902 return info; 5903 }, 5904 customerId: function () { 5905 return $scope.sitedata.customerId; 5906 }, 5907 paymentMethod: function () { 5908 return paymentMethods[paymentMethodIndex]; 5909 }, 5910 useWallet: function () { 5911 return $scope.useWallet; 5912 }, 5913 5914 userBalanceDec: function () { 5915 return $scope.userBalanceDec; 5916 } 5917 } 5918 }).result.then(function () { 5919 5920 if ($scope.sitedata.latePayment) { 5921 location.reload(); 5922 } else { 5923 $scope.getMemberDues(); 5924 $scope.refreshWalletBalance(); 5925 $scope.getPaymentHistory(); 5926 } 5927 }, function () { 5928 $scope.refreshWalletBalance(); 5929 }); 5930 }; 5931 5932 $scope.initMultipleUpload = function () { 5933 $timeout(function () { 5934 jQuery('.customMultipleUpload').each(function () { 5935 jQuery(this).find('input').prop('multiple', true); 5936 }); 5937 5938 }, 50); 5939 } 5940 5941 $scope.canSubmitCustomForm = true; 5942 $scope.submitCustomForm = function (form, widget) {
5943 jQuery('.customFormItem').removeClass("custominvalid"); 5944 jQuery('.invalid-label').removeClass("invalid-label"); 5945 jQuery('.custom-feedback').css('display', 'none'); 5946 5947 5948 $scope.customAnswers = []; 5949 5950 jQuery('#' + widget.widgetId + ' .customFormItem').each(function () { 5951 console.log(jQuery(this).val()); 5952 console.log(jQuery(this).attr('data-id')); 5953 let f = jQuery(this).val(); 5954 if (f != "Select" && f != "select") { 5955 $scope.customAnswers.push({ questionId: jQuery(this).attr('data-id'), answer: jQuery(this).val() }); 5956 } 5957 }); 5958 5959 jQuery('#' + widget.widgetId + ' .checkboxGroup').each(function () { 5960 var vals = []; 5961 var questionId = ""; 5962 5963 jQuery(this).find('.customFormCheckbox').each(function () { 5964 if (jQuery(this).prop('checked')) { 5965 var dataval = jQuery(this).val().split('|'); 5966 questionId = dataval[0]; 5967 vals.push(dataval[1].split(",").join("|")); 5968 } 5969 }); 5970 5971 $scope.customAnswers.push({ questionId: questionId, answer: vals.join(', ') }); 5972 5973 }); 5974 jQuery('#' + widget.widgetId + ' .customFormRadio').each(function () { 5975 if (jQuery(this).prop('checked')) { 5976 var dataval = jQuery(this).val().split('|'); 5977 $scope.customAnswers.push({ questionId: dataval[0], answer: dataval[1] }); 5978 } 5979 }); 5980 5981 $scope.loopfailed = false; 5982 5983 angular.forEach(widget.formdata.sections, function (section) { 5984 angular.forEach(section.questions, function (question) { 5985 if (question.required) { 5986 var failed = true; 5987 5988 if (question.questionControlType == 8) { 5989 if (!question.attachments) { 5990 question.isInvalid = true; 5991 } else { 5992 if (!question.attachments.length) { 5993 question.isInvalid = true; 5994 } else { 5995 5996 var answer = ""; 5997 angular.forEach(question.attachments, function (attachment) { 5998 5999 if (answer != "") { 6000 answer += ","; 6001 } 6002 answer += attachment.uploadedFileId; 6003 }); 6004 6005 $scope.customAnswers.push({ questionId: question.questionId, answer: answer, isUpload: true }); 6006 failed = false; 6007 } 6008 } 6009 6010 6011 } else { 6012 question.isInvalid = true; 6013 angular.forEach($scope.customAnswers, function (answer) { 6014 if (answer.questionId == question.questionId && answer.answer.length > 0) { 6015 failed = false; 6016 question.isInvalid = false; 6017 } 6018 }); 6019 6020 if (question.min != null || question.max != null) { 6021 angular.forEach($scope.customAnswers, function (answer) { 6022 if (answer.questionId == question.questionId && answer.answer.length > 0) { 6023 var arr = answer.answer.split(','); 6024 var count = arr.length; 6025 if (question.min != null) { 6026 if (count < question.min) { 6027 question.incorrectMinMax = true; 6028 failed = true; 6029 } 6030 } 6031 if (question.max != null) { 6032 if (count > question.max) { 6033 question.incorrectMinMax = true; 6034 failed = true; 6035 } 6036 6037 } 6038 } 6039 }); 6040 } 6041 6042 } 6043 if (failed) { 6044 jQuery('.form-check-input').each(function () { 6045 var aVal = $(this).val(); 6046 var valSplit = aVal.split('|'); 6047 if (valSplit[0] == question.detailId || valSplit[0] == question.questionId) { 6048 $(this).next().addClass('invalid-label'); 6049 } 6050 }); 6051 6052 $scope.loopfailed = true; 6053 jQuery('.custom-feedback[data-id-feedback=' + question.detailId + ']').css('display', 'block'); 6054 jQuery('.customFormItem[data-id=' + question.detailId + ']').addClass("custominvali
6054d"); 6055 jQuery('.customFormItem[data-id=' + question.questionId + ']').addClass("custominvalid"); 6056 jQuery('.custom-feedback[data-id-feedback=' + question.questionId + ']').css('display', 'block'); 6057 } 6058 } else { 6059 if (question.questionControlType == 8) { 6060 if (!question.attachments) { 6061 //do nothing 6062 } else { 6063 if (!question.attachments.length) { 6064 //do nothing 6065 } else { 6066 6067 var answer = ""; 6068 angular.forEach(question.attachments, function (attachment) { 6069 6070 if (answer != "") { 6071 answer += ","; 6072 } 6073 answer += attachment.uploadedFileId; 6074 }); 6075 6076 $scope.customAnswers.push({ questionId: question.questionId, answer: answer, isUpload: true }); 6077 failed = false; 6078 } 6079 } 6080 6081 6082 } 6083 } 6084 }); 6085 }); 6086 6087 if (widget.formdata.isTicketing && !widget.formdata.subject) { 6088 $scope.loopfailed = true; 6089 } 6090 6091 if ($scope.loopfailed) { 6092 widget.submitAttempt = true; 6093 return; 6094 } 6095 widget.submitAttempt = false; 6096 6097 if (!widget.formdata.subject) { 6098 widget.formdata.subject = ""; 6099 } 6100 6101 6102 if (!$scope.canSubmitCustomForm) { 6103 return; 6104 } 6105 $scope.canSubmitCustomForm = false; 6106 6107 $scope.ajaxCall('/Sites/SubmitCustomForm', { data: $scope.customAnswers, widgetId: widget.widgetId, subject: widget.formdata.subject }, function (data) { 6108 $scope.canSubmitCustomForm = true; 6109 6110 //alert("Thank you for submitting our form. We will get back with you"); 6111 $scope.loadForm(widget); 6112 widget.isSubmitted = true; 6113 widget.formdata.isSubmitted = true; 6114 }); 6115 } 6116 6117 $scope.canSubmitCustomFormNoWidget = true; 6118 6119 $scope.submitCustomFormNoWidget = function (form, takeForm) { 6120 6121 jQuery('.customFormItem').removeClass("custominvalid"); 6122 jQuery('.custom-feedback').css('display', 'none'); 6123 jQuery('.invalid-label').removeClass("invalid-label"); 6124 6125 6126 $scope.customAnswers = []; 6127 6128 const widget = { 6129 widgetId: "takeForm", 6130 formdata: takeForm, 6131 }; 6132 6133 jQuery('#' + widget.widgetId + ' .customFormItem').each(function () { 6134 console.log(jQuery(this).val()); 6135 console.log(jQuery(this).attr('data-id')); 6136 let f = jQuery(this).val(); 6137 if (f != "Select" && f != "select") { 6138 $scope.customAnswers.push({ questionId: jQuery(this).attr('data-id'), answer: jQuery(this).val() }); 6139 } 6140 }); 6141 6142 jQuery('#' + widget.widgetId + ' .checkboxGroup').each(function () { 6143 var vals = []; 6144 var questionId = ""; 6145 6146 jQuery(this).find('.customFormCheckbox').each(function () { 6147 if (jQuery(this).prop('checked')) { 6148 var dataval = jQuery(this).val().split('|'); 6149 questionId = dataval[0]; 6150 vals.push(dataval[1].split(",").join("|")); 6151 } 6152 }); 6153 6154 $scope.customAnswers.push({ questionId: questionId, answer: vals.join(', ') }); 6155 6156 }); 6157 jQuery('#' + widget.widgetId + ' .customFormRadio').each(function () { 6158 if (jQuery(this).prop('checked')) { 6159 var dataval = jQuery(this).val().split('|'); 6160 $scope.customAnswers.push({ questionId: dataval[0], answer: dataval[1] }); 6161 } 6162 }); 6163 6164 $scope.loopfailed = false; 6165 6166 angular.forEach(widget.formdata.sections, function (section) { 6167 angular.forEach(section.questions, function (question) { 6168 if (question.required) { 6169 var failed = true; 6170 6171 if (question.questionControlType == 8) { 6172 if (!question.attachments) { 6173 question.isInvalid = true; 6174 } else { 6175 if (!question.attachments.length) { 6176 question.isInvalid = true; 6177 } else { 6178 6179 var answer = ""; 6180 angular.forEach(question.attachments, function (attachment) { 6181 6182 if (answer != "") { 6183 answer += ","; 6184 } 6185 answer += attachment.uploadedFileId; 6186 }); 6187 6188 $scope.customAnswers.push({ questionId: question.questionId, answer: answer, isUpload: true });
6189 failed = false; 6190 } 6191 } 6192 6193 6194 } else { 6195 question.isInvalid = true; 6196 angular.forEach($scope.customAnswers, function (answer) { 6197 if (answer.questionId == question.questionId && answer.answer.length > 0) { 6198 failed = false; 6199 question.isInvalid = false; 6200 } 6201 }); 6202 if (question.min != null || question.max != null) { 6203 angular.forEach($scope.customAnswers, function (answer) { 6204 if (answer.questionId == question.questionId && answer.answer.length > 0) { 6205 var arr = answer.answer.split(','); 6206 var count = arr.length; 6207 if (question.min != null) { 6208 if (count < question.min) { 6209 question.incorrectMinMax = true; 6210 failed = true; 6211 } 6212 } 6213 if (question.max != null) { 6214 if (count > question.max) { 6215 question.incorrectMinMax = true; 6216 failed = true; 6217 } 6218 6219 } 6220 } 6221 }); 6222 } 6223 } 6224 if (failed) { 6225 jQuery('.form-check-input').each(function () { 6226 var aVal = $(this).val(); 6227 var valSplit = aVal.split('|'); 6228 if (valSplit[0] == question.detailId || valSplit[0] == question.questionId) { 6229 $(this).next().addClass('invalid-label'); 6230 } 6231 }); 6232 6233 $scope.loopfailed = true; 6234 jQuery('.custom-feedback[data-id-feedback=' + question.detailId + ']').css('display', 'block'); 6235 jQuery('.customFormItem[data-id=' + question.detailId + ']').addClass("custominvalid"); 6236 jQuery('.customFormItem[data-id=' + question.questionId + ']').addClass("custominvalid"); 6237 jQuery('.custom-feedback[data-id-feedback=' + question.questionId + ']').css('display', 'block'); 6238 } 6239 } else { 6240 if (question.questionControlType == 8) { 6241 if (!question.attachments) { 6242 //do nothing 6243 } else { 6244 if (!question.attachments.length) { 6245 //do nothing 6246 } else { 6247 6248 var answer = ""; 6249 angular.forEach(question.attachments, function (attachment) { 6250 6251 if (answer != "") { 6252 answer += ","; 6253 } 6254 answer += attachment.uploadedFileId; 6255 }); 6256 6257 $scope.customAnswers.push({ questionId: question.questionId, answer: answer, isUpload: true }); 6258 failed = false; 6259 } 6260 } 6261 6262 6263 } 6264 } 6265 }); 6266 }); 6267 6268 if (widget.formdata.isTicketing && !widget.formdata.subject) { 6269 $scope.loopfailed = true; 6270 } 6271 6272 if ($scope.loopfailed) { 6273 widget.submitAttempt = true; 6274 return; 6275 } 6276 widget.submitAttempt = false; 6277 6278 if (!widget.formdata.subject) { 6279 widget.formdata.subject = ""; 6280 } 6281 6282 if (!$scope.canSubmitCustomFormNoWidget) { 6283 return; 6284 } 6285 $scope.canSubmitCustomFormNoWidget = false; 6286 6287 6288 $scope.ajaxCall('/Sites/SubmitDashboardCustomForm', { formId: widget.formdata.formId, data: $scope.customAnswers, subject: widget.formdata.subject }, function (data) { 6289 $scope.canSubmitCustomFormNoWidget = true; 6290
6291 //alert("Thank you for submitting our form. We will get back with you"); 6292 $scope.loadForm(widget); 6293 $scope.takeFormSubmitted = true; 6294 }); 6295 } 6296 6297 $scope.currentFaqWidget = null; 6298 $scope.setFaqWidget = function (widget, parent) { 6299 parent.currentFaqWidget = widget; 6300 } 6301 6302 $scope.contact = { firstName: "", lastName: "", phoneNumber: "", emailAddress: "", message: "" }; 6303 $scope.clearContact = function () { 6304 $scope.contact = { firstName: "", lastName: "", phoneNumber: "", emailAddress: "", message: "" }; 6305 $scope.contactSubmitAttempt = false; 6306 } 6307 6308 $scope.$watch('contact.phoneNumber', function (input) { 6309 if ($scope.contact.phoneNumber != null && input != null) { 6310 6311 var cleaned = input.replace(/[^0-9\\.]+/g, ''); 6312 var match = cleaned.match(/^(\d{0,3})(\d{0,3})(\d{0,4})$/) 6313 if (match) { 6314 var formattedPhone = match[1]; 6315 if (match[2].length > 0) { 6316 formattedPhone += '-' + match[2]; 6317 } 6318 if (match[3].length > 0) { 6319 formattedPhone += '-' + match[3]; 6320 } 6321 $scope.contact.phoneNumber = formattedPhone.substr(0, 12); 6322 } 6323 } 6324 }); 6325 6326 $scope.contactSubmitAttempt = false; 6327 $scope.sendMessage = function (form, widget) { 6328 $scope.contactSubmitAttempt = true; 6329 if (form.$invalid) { 6330 return true; 6331 } 6332 6333 $scope.ajaxCall('/Sites/SubmitContactForm', { data: $scope.contact, widgetId: widget.widgetId }, function (data) { 6334 alert("Thank you for submitting our form. We will get back with you"); 6335 $scope.contactSubmitAttempt = false; 6336 $scope.clearContact(); 6337 }); 6338 } 6339 6340 $scope.analytics = "https://www.googletagmanager.com/gtag/js?id="; 6341 6342 $scope.map; 6343 6344 $scope.addMarker = function (latLng, member) { 6345 6346 let marker = new google.maps.Marker({ 6347 map: $scope.map, 6348 position: latLng, 6349 member: member 6350 }); 6351 6352 $scope.bounds.extend(marker.position); 6353 marker.addListener('click', function () { 6354 $scope.memberDetails(member); 6355 }); 6356 6357 $scope.map.fitBounds($scope.bounds); 6358 $scope.markersArray.push(marker); 6359 } 6360 6361 $scope.searchtimeout = null; 6362 6363 $scope.triggerUpdateMap = function (text) { 6364 $timeout.cancel($scope.searchtimeout); 6365 $scope.searchtimeout = $timeout(function () { 6366 $scope.searchMembers(); 6367 }, 750) 6368 } 6369 6370 $scope.searchComparator = function (actual) { 6371 var expected = $scope.geomapSearch.toLowerCase(); 6372 if (actual.firstName.toLowerCase().includes(expected) || actual.lastName.toLowerCase().includes(expected) || (actual.emailAddress != null && actual.emailAddress.toLowerCase().includes(expected)) || (actual.address1 != null && actual.address1.toLowerCase().includes(expected)) || (actual.address2 != null && actual.address2.toLowerCase().includes(expected)) || (actual.city != null && actual.city.toLowerCase().includes(expected)) || (actual.stateName != null && actual.stateName.toLowerCase().includes(expected)) || (actual.zip != null && actual.zip.toLowerCase().includes(expected))) { 6373 return true; 6374 } 6375 6376 return false; 6377 } 6378 6379 6380 $scope.canLoadModal = true; 6381 $scope.login = function () { 6382 6383 if (!$scope.canLoadModal) { 6384 return; 6385 } 6386 6387 $scope.canLoadModal = false; 6388 6389 $uibModal.open({ 6390 templateUrl: 'login-reset-modal', 6391 size: 'lg', 6392 controller: 'PublicLoginRegisterController', 6393 backdrop: 'static', 6394 6395 resolve: { 6396 screen: function () { 6397 return "login"; 6398 }, 6399 brand: function () { 6400 return $scope.sitedata.brand; 6401 }, 6402 logoId: function () { 6403 return $scope.sitedata.logoId; 6404 }, 6405 siteName: function () { 6406 return $scope.sitedata.siteName; 6407 }, 6408 customerId: function () { 6409 return $scope.sitedata.customerId; 6410 }, 6411 slug: function () { 6412 return $scope.sitedata.siteSlug; 6413 }, 6414 sitedata: function () { 6415 return $scope.sitedata; 6416 }, 6417 } 6418 }).result.then(function (login) { 6419 $scope.canLoadModal = true; 6420 6421 if (login == true) { 6422 if ($scope.sitedata.logIntoPortal) { 6423 window.location.href = "https://hoastartmobileportal.azurewebsites.net/"; 6424 } else { 6425 window.location.reload(); 6426 } 6427 } else { 6428 alert("You've been registered!"); 6429 } 6430 }, function () { 6431 $scope.canLoadModal = true; 6432 6433 }); 6434 }; 6435 6436 $scope.register = function () { 6437 if (!$scope.canLoadModal) { 6438 return; 6439 } 6440 6441 $scope.canLoadModal = false; 6442 6443 $uibModal.open({ 6444 templateUrl: 'login-reset-modal', 6445 size: 'lg', 6446 controller: 'PublicLoginRegisterController', 6447 backdrop: 'static', 6448 6449 resolve: { 6450 screen: function () { 6451 return "register"; 6452 }, 6453 brand: function () { 6454 return $scope.sitedata.brand; 6455 }, 6456 logoId: function () { 6457 return $scope.sitedata.logoId; 6458 }, 6459 siteName: function () { 6460 return $scope.sitedata.siteName; 6461 }, 6462 customerId: function () { 6463 return $scope.sitedata.customerId; 6464 }, 6465 slug: function () { 6466 return $scope.sitedata.siteSlug; 6467 }, 6468 sitedata: function () { 6469 return $scope.sitedata; 6470 } 6471 } 6472 }).result.then(function (login) { 6473 $scope.canLoadModal = true; 6474 6475 if (login == true) { 6476 window.location.reload(); 6477 } else { 6478 alert("You've been registered!"); 6479 } 6480 }, function () { 6481 $scope.canLoadModal = true; 6482 6483 }); 6484 }; 6485 6486 $scope.geomapSearch = ""; 6487 6488 $scope.loadMoreMembers = function () { 6489 $scope.loadGeomap($scope.loadedMembers + $scope.loadAtATime); 6490 } 6491 6492 $scope.loadAtATime = 100; 6493 $scope.loadedMembers = $scope.loadAtATime; 6494 $scope.loadGeomap = function (members) { 6495 $scope.loadedMembers = members; 6496 $scope.markersArray = []; 6497 $scope.bounds = new google.maps.LatLngBounds(); 6498 $scope.positionMarker = null; 6499 // global array to store the marker object 6500 6501 if ($scope.members.length > 0) { 6502 var lat = '29.7604'; 6503 var lon = '-95.3698'; 6504 6505 if (lat != '' && lon != '') { 6506 $scope.map = new google.maps.Map(document.getElementById('member-map'), { 6507 center: { lat: parseFloat(lat), lng: parseFloat(lon) }, 6508 zoom: 6, 6509 }); 6510 6511 var timeout = 50; 6512 var count = 0; 6513 $timeout(function () { 6514 6515 angular.forEach($scope.members, function (member) { 6516 if (!member.address1) { 6517 return; 6518 } 6519 6520 count++; 6521 if (count > members) { 6522 return;; 6523 } 6524 6525 var exists = false; 6526 Object.keys(member).forEach( 6527 function (key) { 6528 try { 6529 //List of searchable fields. Not the cleanest way to do this, but better than filtering out unsearchables (there are so many) 6530 if (key == "customAnswers" || key == "tags") {
6531 member[key].forEach(function (answer) { 6532 if (answer.answer != null) { 6533 answer = answer.answer; 6534 } 6535 if (answer.toLowerCase().includes($scope.geomapSearch.toLowerCase())) { 6536 exists = true; 6537 } 6538 }); 6539 } 6540 if (member[key].toLowerCase().includes($scope.geomapSearch.toLowerCase()) && 6541 ( 6542 key == "address1" || 6543 key == "address2" || 6544 key == "city" || 6545 key == "emailAddress" || 6546 key == "firstName" || 6547 key == "fullName" || 6548 key == "lastName" || 6549 key == "phone" || 6550 key == "stateName" || 6551 key == "zip" 6552 )) { 6553 exists = true; 6554 } 6555 } 6556 catch (e) { 6557 6558 } 6559 6560 6561 /*if (typeof actual[key] === 'string' || actual[key] instanceof String) { 6562 if (actual[key].contains(expected)) { 6563 return true; 6564 } 6565 return false; 6566 }*/ 6567 }); 6568 if (!exists) { 6569 return; 6570 } 6571 var search = ''; 6572 6573 if (member.address1) { 6574 search += '' + encodeURIComponent(member.address1); 6575 } 6576 if (member.city) { 6577 search += '+' + encodeURIComponent(member.city); 6578 } 6579 if (member.stateName) { 6580 search += '+' + encodeURIComponent(member.stateName); 6581 } 6582 if (member.zip) { 6583 search += '+' + encodeURIComponent(member.zip); 6584 } 6585 6586 if (search.length > 0) { 6587 if (member.latitude && member.longitude) { 6588 $scope.addMarker({ lat: parseFloat(member.latitude), lng: parseFloat(member.longitude) }, member); 6589 } else { 6590 jQuery.ajax('https://maps.googleapis.com/maps/api/geocode/json?address=' + search + '&key=AIzaSyDpOPKSpS9Jj2Iv9SP2J6OrAC-MERlJd0E') 6591 .done(function (data) { 6592 try { 6593 $scope.addMarker({ lat: data.results[0].geometry.location.lat, lng: data.results[0].geometry.location.lng }, member); 6594 $scope.ajaxCall('/Customer/SaveMemberCoordinates', { customerId: $scope.sitedata.customerId, userId: member.userId, latitude: data.results[0].geometry.location.lat, longitude: data.results[0].geometry.location.lng }, function (data) { 6595 //Coordinates updated 6596 }, function () { }, false); 6597 } 6598 catch { 6599 console.log("Failed to find a location based on address: " + search); 6600 } 6601 }); 6602 } 6603 } 6604 }); 6605 }); 6606 } 6607 } 6608 } 6609 6610 $scope.emailMessage = function () { 6611 $uibModal.open({ 6612 templateUrl: 'receiveemailmodal', 6613 controller: function ($scope, $timeout) { 6614 }, 6615 resolve: { 6616 } 6617 }).result.then(function () { 6618 }, function () { 6619 6620 }); 6621 } 6622 6623 $scope.memberDues = []; 6624 $scope.paymentMethods = []; 6625 $scope.myHouseholdsForWallets = []; 6626 $scope.myWallet = null; 6627 $scope.getPaymentMethods = function () { 6628 $scope.ajaxCall('/Customer/GetMyPaymentMethods', { customerId: $scope.sitedata.customerId }, function (data) { 6629 $scope.paymentMethods = data; 6630 }); 6631 } 6632 $scope.getMemberDues = function () { 6633 $scope.ajaxCall('/Customer/GetMemberDues', { customerId: $scope.sitedata.customerId }, function (data) { 6634 $scope.memberDues = data; 6635 $scope.getPaymentMethods(); 6636 }); 6637 } 6638 6639 $scope.memberDueHistory = []; 6640 $scope.householdDueHistory = []; 6641 $scope.getPaymentHistory = function () { 6642 $scope.ajaxCall('/Customer/GetMemberDueHistory', { customerId: $scope.sitedata.customerId }, function (data) { 6643 $scope.memberDueHistory = data; 6644 }); 6645 } 6646 6647 $scope.folders = []; 6648 $scope.selectedFolder = null; 6649 $scope.folderPath = ''; 6650 6651 $scope.searchFolderTree = { name: '' }; 6652 $scope.searchFolderContents = { name: '' }; 6653 6654 $scope.findFolder = function (folderId, folderList, folderpath) { 6655 6656 var found = false; 6657 angular.forEach(folderList, function (folder) { 6658 if (folder.folderId == folderId) { 6659 $scope.selectedFolder = folder; 6660 $scope.folderPath = folderpath + '<span class="font-weight-bold">' + folder.name + '</span>'; 6661 6662 } 6663 6664 if (folder.folders.length) { 6665 var newfolderpath = folderpath + '<span>' + folder.name + '</span>' + " > "; 6666 var checkAgain = $scope.findFolder(folderId, folder.folders, newfolderpath); 6667 } 6668 }); 6669 6670 return null; 6671 } 6672 6673 $scope.order = 'asc'; 6674 $scope.orderby = 'default'; 6675 6676 $scope.setOrder = function (orderby) { 6677 if (orderby == $scope.orderby) { 6678 if ($scope.order == 'asc') { 6679 $scope.order = 'desc'; 6680 } else { 6681 $scope.order = 'asc'; 6682 } 6683 } 6684 6685 $scope.orderby = orderby; 6686 6687 $scope.loadFolderContents($scope.selectedFolderId); 6688 6689 } 6690 6691 $scope.downloadFile = function (itemId) { 6692 window.open('/File/Get/' + itemId, '_blank'); 6693 } 6694 6695 $scope.previewFile = function (file) { 6696 $scope.supportedFileTypes = ["png", "jpg", "jpeg", "gif", "svg", "pdf"]; 6697 $scope.size = ''; 6698 6699 $scope.fileSplit = file.name.split('.'); 6700 if ($scope.fileSplit.length >= 1) { 6701 $scope.fileExtension = $scope.fileSplit[$scope.fileSplit.length - 1].toLowerCase(); 6702 6703 if ($scope.supportedFileTypes.includes($scope.fileExtension)) { 6704 $scope.size = 'xxl'; 6705 } 6706 } 6707 6708 $uibModal.open({ 6709 templateUrl: 'preview-file-modal', 6710 size: $scope.size, 6711 controller: function ($scope, $timeout, file) { 6712 $scope.supportedFileTypes = ["png", "jpg", "jpeg", "gif", "svg", "pdf"]; 6713 $scope.file = file; 6714 $scope.showPreview = false; 6715 $scope.isPdf = false; 6716 $scope.showButtons = false; 6717 6718 $scope.fileSplit = $scope.file.name.split('.'); 6719 if ($scope.fileSplit.length >= 1) { 6720 $scope.fileExtension = $scope.fileSplit[$scope.fileSplit.length - 1].toLowerCase(); 6721 6722 if ($scope.supportedFileTypes.includes($scope.fileExtension)) { 6723 $scope.showPreview = true; 6724 6725 if ($scope.fileExtension == 'pdf') { 6726 $scope.isPdf = true; 6727 6728 $timeout(function () { 6729 var bodyHeight = jQuery('.previewModalBody').height(); 6730 var newHeight = bodyHeight - 90; 6731 6732 var e = document.createElement('embed'); 6733 e.src = '/File/View/' + $scope.file.uploadId; 6734 e.type = "image/svg+xml"; 6735 e.height = newHeight;
6736 e.width = '100%'; 6737 document.getElementById('previewAreaPDF').appendChild(e); 6738 6739 e.addEventListener('load', function () { 6740 jQuery('.previewLoaderSpinner').remove(); 6741 jQuery('.previewAreaPDF').css('height', newHeight + 'px'); 6742 $scope.showButtons = true; 6743 }); 6744 }, 1); 6745 6746 } 6747 } 6748 } 6749 6750 $scope.checkImageLoad = function () { 6751 jQuery('.previewImage').on('load', function () { 6752 var bodyHeight = jQuery('.previewModalBody').height(); 6753 var newHeight = bodyHeight - 90; 6754 6755 jQuery('.previewLoaderSpinner').remove(); 6756 jQuery('.previewAreaImage').css('height', newHeight + 'px'); 6757 $scope.showButtons = true; 6758 }); 6759 } 6760 6761 $scope.downloadFile = function () { 6762 window.open('/File/Get/' + $scope.file.uploadId, '_blank'); 6763 } 6764 }, 6765 backdrop: 'static', 6766 resolve: { 6767 file: function () { 6768 return file; 6769 } 6770 } 6771 }).result.then(function () { 6772 $scope.$close(true); 6773 }, function () { 6774 6775 }); 6776 }; 6777 6778 $scope.selectedFolderId = null; 6779 $scope.selectedFolderContents = []; 6780 $scope.selectFolder = function (folderId) { 6781 var folder = $scope.findFolder(folderId, $scope.folders, ''); 6782 $scope.loadFolderContents(folderId); 6783 6784 jQuery('.list-group-item.active').removeClass('active'); 6785 jQuery('.folder-' + folderId).parent().addClass('active'); 6786 } 6787 6788 $scope.hasFiles = false; 6789 $scope.loadFolderContents = function (folderId) { 6790 6791 $scope.ajaxCall('/Document/GetFolderContentsPublic', { customerId: $scope.sitedata.customerId, folderId: folderId, orderby: $scope.orderby, order: $scope.order }, function (data) { 6792 $scope.selectedFolderId = folderId; 6793 $scope.selectedFolderContents = data; 6794 6795 $scope.hasFiles = false; 6796 angular.forEach(data, function (item) { 6797 if (!item.isFolder) { 6798 $scope.hasFiles = true; 6799 } 6800 }); 6801 }); 6802 } 6803 6804 $scope.generateFolderStructure = function (folder) { 6805 var list = { 6806 text: '<a style="color: #0076b9" class="treefolderitem folder-' + folder.folderId + '" ng-click="selectFolder(\'' + folder.folderId + '\')">' + folder.name + '</a>', 6807 }; 6808 6809 if (folder.folders.length) { 6810 list.nodes = []; 6811 angular.forEach(folder.folders, function (subfolder) { 6812 list.nodes.push($scope.generateFolderStructure(subfolder)); 6813 }); 6814 } 6815 6816 return list; 6817 } 6818 6819 6820 $scope.searchTimeout = null; 6821 $scope.updateTree = function () { 6822 $timeout.cancel($scope.searchTimeout); 6823 6824 6825 $scope.searchTimeout = $timeout(function () { 6826 $scope.initTree(); 6827 }, 250); 6828 6829 } 6830 6831 $scope.initTree = function () { 6832 jQuery('#tree').remove(); 6833 jQuery('.folderCol').append('<div id="tree"></div>'); 6834 var myList = []; 6835 6836 var filteredFolders = $filter('filter')($scope.folders, $scope.searchFolderTree.name); 6837 6838 angular.forEach(filteredFolders, function (folder) { 6839 myList.push($scope.generateFolderStructure(folder)); 6840 }); 6841 6842 jQuery('#tree').bstreeview({ 6843 data: myList 6844 }); 6845 6846 $compile(jQuery("#tree").contents())($scope); 6847 } 6848 6849 $scope.bulkDownload = function (folderId) { 6850 $uibModal.open({ 6851 templateUrl: 'bulk-download-modal', 6852 size: 'xl', 6853 controller: function ($scope, $timeout, folderId, customerId) { 6854 $scope.folderId = folderId; 6855 $scope.customerId = customerId; 6856 6857 $scope.files = []; 6858 6859 $scope.order = 'asc'; 6860 $scope.orderby = 'default'; 6861 6862 $scope.setOrder = function (orderby) { 6863 if (orderby == $scope.orderby) { 6864 if ($scope.order == 'asc') { 6865 $scope.order = 'desc'; 6866 } else { 6867 $scope.order = 'asc'; 6868 } 6869 } 6870 6871 $scope.orderby = orderby; 6872 6873 $scope.ajaxCall('/Document/GetFolderContentsPublic', { customerId: $scope.sitedata.customerId, folderId: folderId, orderby: $scope.orderby, order: $scope.order }, function (data) { 6874 $scope.files = []; 6875 angular.forEach(data, function (file) { 6876 if (!file.isFolder) { 6877 $scope.files.push(file); 6878 } 6879 }); 6880 }); 6881 } 6882 6883 $scope.selectAll = function () { 6884 if ($scope.selectedAll) { 6885 $scope.selectedItems = []; 6886 $scope.selectedAll = false; 6887 jQuery('.selectedFiles').each(function () { 6888 jQuery(this).prop('checked', false); 6889 }); 6890 } else { 6891 $scope.selectedItems = jQuery.extend(true, [], $scope.files); 6892 $scope.selectedAll = true; 6893 6894 jQuery('.selectedFiles').each(function () { 6895 jQuery(this).prop('checked', true); 6896 }); 6897 } 6898 } 6899 6900 $scope.selectedAll = false; 6901 $scope.selectedItems = []; 6902 $scope.selectItem = function (item) { 6903 var index = $scope.selectedItems.map(function (e) { return e.itemId; }).indexOf(item.itemId); 6904 if (index == -1) { 6905 $scope.selectedItems.push(item); 6906 } else { 6907 $scope.selectedItems.splice(index, 1); 6908 } 6909 } 6910 6911 $scope.ajaxCall('/Document/GetFolderContentsPublic', { customerId: $scope.customerId, folderId: folderId, orderby: $scope.orderby, order: $scope.order }, function (data) { 6912 angular.forEach(data, function (file) { 6913 if (!file.isFolder) { 6914 $scope.files.push(file); 6915 } 6916 }); 6917 }); 6918 6919 $scope.download = function () { 6920 if ($scope.selectedItems.length) { 6921 jQuery('#formdata').val(JSON.stringify($scope.selectedItems)); 6922 jQuery('#invisible_form').submit(); 6923 6924 $timeout(function () { 6925 $scope.$close(); 6926 }, 50); 6927 } else { 6928 $scope.$close(); 6929 } 6930 } 6931 6932 }, 6933 backdrop: 'static', 6934 resolve: { 6935 folderId: function () { 6936 return folderId; 6937 }, 6938 customerId: function () { 6939 return $scope.sitedata.customerId; 6940 } 6941 } 6942 }).result.then(function (data) { 6943 6944 }, function () { 6945 6946 }); 6947 } 6948 6949 $scope.viewResults = function (formId) { 6950 $scope.resultsCount = null; 6951 $scope.results = null; 6952 6953 $scope.ajaxCall('/Customer/GetFormResultsWithCount', { customerId: $scope.sitedata.customerId, formId: formId }, function (data) { 6954 $scope.results = data.questions; 6955 $scope.resultsCount = data.submissions; 6956 6957 $uibModal.open({ 6958 templateUrl: 'view-form-results-modal', 6959 controller: function ($scope, $timeout, formId, customerId, results, resultsCount) { 6960 $scope.customerId = customerId; 6961 $scope.formId = null; 6962 $scope.resultsCount = 0; 6963 $scope.results = results; 6964 $scope.resultsCount = resultsCount; 6965 6966 $scope.formdata = null; 6967 $scope.ajaxCall('/Customer/GetFormSetupPublic', { customerId: $scope.customerId, formId: formId }, function (data) { 6968 $scope.formdata = data; 6969 }); 6970 6971 6972 6973 6974 }, 6975 backdrop: 'static', 6976 size: 'lg', 6977 resolve: { 6978 formId: function () { 6979 return formId; 6980 }, 6981 customerId: function () { 6982 return $scope.sitedata.customerId; 6983 }, 6984 results: function () { 6985 return $scope.results; 6986 }, 6987 resultsCount: function () { 6988 return $scope.resultsCount; 6989 } 6990 } 6991 }).opened.then(function () { 6992 $scope.index = 0; 6993 angular.forEach($scope.results, function (item) { 6994 6995 google.charts.load('current', { 'packages': ['corechart'] }); 6996 google.charts.setOnLoadCallback(drawChart); 6997 6998 function drawChart() { 6999 var resultArray = [['Question', 'Answered by Students']]; 7000 7001 angular.forEach(item.results, function (result) { 7002 resultArray.push([result.name, result.votes]); 7003 }); 7004 var data = google.visualization.arrayToDataTable(resultArray); 7005 7006 var options = { 7007 title: item.name, 7008 height: 300, 7009 width: "100%", 7010 colors: ['#2946D9', '#68B849', '#C937D3', '#4EBACD', '#E75737'], 7011 fontSize: 12, 7012 fontName: 'Montserrat', 7013 fontWeight: '300', 7014 legend: { position: "right", alignment: "start" }, 7015 chartArea: { left: 20, right: 30 }, 7016 tooltip: { 7017 isHtml: true 7018 } 7019 }; 7020 7021 7022 var chart = new google.visualization.PieChart(document.getElementById('piechart' + $scope.index)); 7023 7024 7025 chart.draw(data, options); 7026 $scope.index++; 7027 7028 } 7029 7030 }); 7031 }); 7032 }); 7033 } 7034 7035 7036 $scope.getFolders = function () { 7037 if (!$scope.sitedata.customerId) { 7038 return; 7039 } 7040 $scope.ajaxCall('/Document/GetFoldersPublic', { customerId: $scope.sitedata.customerId }, function (data) { 7041 $scope.folders = data; 7042 7043 $scope.initTree(); 7044 7045 if ($scope.selectedFolderId) { 7046 jQuery('.list-group-item.active').removeClass('active'); 7047 jQuery('.folder-' + $scope.selectedFolderId).parent().addClass('active'); 7048 } 7049 }); 7050 } 7051 $scope.getFolders(); 7052 7053 $scope.concludeLeadQual = function () { 7054 $scope.ajaxCall('/Customer/ConcludeLeadQual', { 7055 customerId: $scope.sitedata.customerId, 7056 leadChoices: { 7057 userId: $scope.currentUser.userId, 7058 homeLotCount: $scope.homeLotCount, 7059 featureSetOne: $scope.featureSetOne, 7060 featureSetTwo: $scope.featureSetTwo, 7061 orgType: $scope.orgType, 7062 orgSelectOption: $scope.orgSelectOption 7063 } 7064 }, function () { 7065 $scope.setUrl('/#!/' + $scope.sitedata.siteSlug + '/dashboard'); 7066 }); 7067 } 7068 7069 $scope.openContactModal = function () { 7070 $uibModal.open({ 7071 templateUrl: 'contact-form-modal', 7072 controller: function ($scope, $timeout) { 7073 $(".mobile-menu-overlay").removeClass("show"); 7074 $scope.contact = { firstName: "", lastName: "", phoneNumber: "", emailAddress: "", message: "" }; 7075 7076 $scope.clearContact = function () { 7077 $scope.contact = { firstName: "", lastName: "", phoneNumber: "", emailAddress: "", message: "" }; 7078 $scope.contactSubmitAttempt = false; 7079 } 7080 7081 $scope.$watch('$scope.contact.phoneNumber', function (input) { 7082 if ($scope.contact.phoneNumber != null && input != null) { 7083 7084 var cleaned = input.replace(/[^0-9\\.]+/g, ''); 7085 var match = cleaned.match(/^(\d{0,3})(\d{0,3})(\d{0,4})$/) 7086 if (match) { 7087 var formattedPhone = match[1]; 7088 if (match[2].length > 0) { 7089 formattedPhone += '-' + match[2]; 7090 } 7091 if (match[3].length > 0) { 7092 formattedPhone += '-' + match[3]; 7093 } 7094 $scope.contact.phoneNumber = formattedPhone.substr(0, 12); 7095 } 7096 } 7097 }); 7098 7099 $scope.contactSubmitAttempt = false; 7100 7101 $scope.submitForm = function (form) { 7102 $scope.contactSubmitAttempt = true;
7103 if (form.$invalid) { 7104 return true; 7105 } 7106 7107 $scope.ajaxCall('/Sites/SubmitContactModalForm', { data: $scope.contact, customerId: $scope.currentCustomerSite.customerId }, function (data) { 7108 alert("Thank you for submitting our form. We will get back with you"); 7109 $scope.contactSubmitAttempt = false; 7110 $scope.$close(); 7111 }); 7112 } 7113 7114 7115 7116 7117 }, 7118 backdrop: 'static', 7119 resolve: { 7120 } 7121 }).result.then(function () { 7122 }, function () { 7123 7124 }); 7125 } 7126 7127 7128 $scope.editUser = function (canClose) { 7129 var userId = AppConstants.CurrentUser.userId; 7130 $(".mobile-menu-overlay").toggleClass("show"); 7131 $uibModal.open({ 7132 size: 'xxl', 7133 templateUrl: 'add-edit-user-modal', 7134 backdrop: 'static', 7135 keyboard: false, 7136 controller: function ($scope, $timeout, userId, states, customerId, sitedata, canClose) { 7137 $scope.countries = null; 7138 $scope.ajaxCall('/Country/CountryList', {}, function (data) { 7139 $scope.countries = data; 7140 }); 7141 7142 $scope.userId = userId; 7143 $scope.sitedata = sitedata; 7144 $scope.canClose = canClose; 7145 7146 $scope.customerId = customerId; 7147 $scope.states = states; 7148 $scope.forms = {}; 7149 $scope.file; 7150 $scope.questions = []; 7151 $scope.originalEmail = ""; 7152 7153 $scope.ajaxCall('/Customer/GetMemberInfo', { customerId: $scope.customerId, userId: userId, includeAdminOnlyFields: false }, function (data) { 7154 $scope.currentUser = data; 7155 $scope.originalEmail = $scope.currentUser.emailAddress; 7156 7157 $scope.ajaxCall('/Customer/GetCustomerForm', { customerId: $scope.customerId, includeAdminOnlyFields: false }, function (data) { 7158 $scope.questions = data; 7159 7160 $timeout(function () { 7161 7162 angular.forEach($scope.currentUser.customAnswers, function (answer) { 7163 index0 = $scope.questions.map(function (e) { return e.name; }).indexOf(answer.question); 7164 if (index0 > -1) { 7165 $scope.questions[index0].hasMemberDirectoryOptIn = answer.hasMemberDirectoryOptIn; 7166 7167 } 7168 if (answer.isUpload) { 7169 console.log(answer); 7170 var index1 = $scope.questions.map(function (e) { return e.name; }).indexOf(answer.question); 7171 if (index1 == -1) { 7172 $scope.questions.push({ name: answer.question, uploads: [] }); 7173 } 7174 7175 index1 = $scope.questions.map(function (e) { return e.name; }).indexOf(answer.question); 7176 if (!$scope.questions[index1].attachments) { 7177 $scope.questions[index1].attachments = []; 7178 } 7179 $scope.questions[index1].attachments.push(answer); 7180 } else { 7181 jQuery('.customFormItem').each(function () { 7182 if (jQuery(this).attr('data-id') == answer.detailId) { 7183 jQuery(this).val(answer.answer); 7184 } 7185 }); 7186 7187 var radioval = answer.detailId + '|' + answer.answer; 7188 var split = []; 7189 if (answer.answer != null) { 7190 split = answer.answer.split('| '); 7191 } 7192 7193 angular.forEach(split, function (uniqueanswer) { 7194 var checkboxval = answer.detailId + '|' + uniqueanswer; 7195 jQuery('.customFormCheckbox').each(function () { 7196 if (jQuery(this).val() == checkboxval) { 7197 jQuery(this).prop('checked', true); 7198 } 7199 }); 7200 7201 }); 7202 7203 jQuery('.customFormRadio').each(function () { 7204 if (jQuery(this).val() == radioval) { 7205 jQuery(this).prop('checked', true); 7206 } 7207 }); 7208 } 7209 7210 }); 7211 }, 1); 7212 7213 }); 7214 }); 7215 $scope.ajaxCall('/State/StateList', {}, function (data) { 7216 $scope.states = data; 7217 }); 7218 7219 $scope.inUpload = false; 7220 $scope.startFileUpload = function (files) { 7221 $scope.inUpload = true; 7222 }; 7223 7224 $scope.successFileUploadCustomMultiple = function (response, field) { 7225 $scope.inUpload = false; 7226 if (response.data.success) { 7227 7228 if (!field.attachments) { 7229 field.attachments = []; 7230 } 7231 angular.forEach(response.data.results, function (result) { 7232 var folderFile = {}; 7233 folderFile.uploadedFileId = result.fileId; 7234 folderFile.sizeInt = result.fileSizeBytes; 7235 folderFile.name = result.fileName; 7236 folderFile.type = result.fileType; 7237 7238 field.attachments.push(folderFile); 7239 }); 7240 } else { 7241 $scope.errorMessage('One or more files exceeds the maximum file size of 15MB.'); 7242 } 7243 }; 7244 7245 $scope.removeFormFile = function (index, field) { 7246 if (!field.removedAttachments) { 7247 field.removedAttachments = []; 7248 } 7249 7250 field.removedAttachments.push(field.attachments[index]); 7251 field.attachments.splice(index, 1); 7252 } 7253 7254 $scope.triggerAccordion = function (detailId) { 7255 var accordion = jQuery('.attachmentCollapse[data-item=' + detailId + ']'); 7256 if (accordion.hasClass('isExpanded')) { 7257 accordion.removeClass('isExpanded').slide
7257Up(); 7258 } else { 7259 accordion.addClass('isExpanded').slideDown(); 7260 } 7261 } 7262 $scope.cropperdata = { imageId: null, positionX: 0, positionY: 0, newWidth: 0, newHeight: 100, imageData: '' } 7263 $scope.cropimage = null; 7264 $scope.newImageId = null; 7265 $scope.successFileUpload = function (response) { 7266 if (response.data.success) { 7267 $scope.file = response.data.results[0]; 7268 $scope.newImageId = $scope.file.fileId; 7269 7270 $timeout(function () { 7271 $scope.cropimage = jQuery('#cropImage'); 7272 $scope.cropimage.cropper('destroy'); 7273 7274 $scope.cropimage.cropper({ 7275 viewMode: 2, 7276 autoCropArea: 1, 7277 aspectRatio: 1, 7278 minContainerHeight: 200, 7279 minContainerWidth: 500, 7280 minCanvasHeight: 200, 7281 minCanvasWidth: 500, 7282 crop: function (event) { 7283 $scope.cropperdata.positionX = event.detail.x; 7284 $scope.cropperdata.positionY = event.detail.y; 7285 $scope.cropperdata.newWidth = event.detail.width; 7286 $scope.cropperdata.newHeight = event.detail.height; 7287 7288 } 7289 }); 7290 $scope.inUpload = false; 7291 7292 }, 100); 7293 7294 //$scope.sponsor.logoFileId = $scope.file.fileId; 7295 } else { 7296 $scope.inUpload = false; 7297 7298 $scope.errorMessage('Your file exceeds the maximum file size of 15MB.'); 7299 } 7300 }; 7301 7302 $scope.formatPhone = function (input) { 7303 if ($scope.currentUser.phone != null && input != null) { 7304 7305 var cleaned = input.replace(/[^0-9\\.]+/g, ''); 7306 var match = cleaned.match(/^(\d{0,3})(\d{0,3})(\d{0,4})(\d{0,2})$/) 7307 if (match) { 7308 var formattedPhone = match[1]; 7309 if (match[2].length > 0) { 7310 formattedPhone += '-' + match[2]; 7311 } 7312 if (match[3].length > 0) { 7313 formattedPhone += '-' + match[3]; 7314 } 7315 $scope.currentUser.phone = formattedPhone.substr(0, 12); 7316 } 7317 } 7318 } 7319 7320 /*$scope.$watch('currentUser.phone', function (input) { 7321 if ($scope.currentUser.phone != null && input != null) { 7322 7323 var cleaned = input.replace(/[^0-9\\.]+/g, ''); 7324 var match = cleaned.match(/^(\d{0,3})(\d{0,3})(\d{0,4})$/) 7325 if (match) { 7326 var formattedPhone = match[1]; 7327 if (match[2].length > 0) { 7328 formattedPhone += '-' + match[2]; 7329 } 7330 if (match[3].length > 0) { 7331 formattedPhone += '-' + match[3]; 7332 } 7333 $scope.currentUser.phone = formattedPhone.substr(0, 12); 7334 } 7335 } 7336 });*/ 7337 7338 7339 7340 $scope.$watch('currentUser.zip', function (input) { 7341 if ($scope.currentUser.zip != null && input != null) { 7342 $scope.currentUser.zip = input.replace(/[^0-9\\.]+/g, ''); 7343 } 7344 }); 7345 7346 $scope.imageSrc = function (fileId) { 7347 if (fileId != null) { 7348 return '/File/Get/' + fileId; 7349 } 7350 return null; 7351 }; 7352 7353 $scope.checkDirty = true; 7354 $scope.submitAttempt = false; 7355 $scope.newemail = false; 7356 $scope.blockSubmit = false;
7357 $scope.saveUser = function (form) { 7358 jQuery('.invalid-label').removeClass("invalid-label"); 7359 7360 jQuery('.customFormItem').removeClass("custominvalid"); 7361 jQuery('.custom-feedback').css('display', 'none'); 7362 7363 $scope.submitAttempt = true; 7364 $scope.showError = false; 7365 if (form.$invalid) { 7366 $scope.showError = true; 7367 return; 7368 } 7369 if ($scope.currentUser.state == null && $scope.currentUser.country == 1) { 7370 $scope.showError = true; 7371 return; 7372 } 7373 7374 if ($scope.currentUser.emailAddress != $scope.originalEmail) { 7375 $scope.newemail = true; 7376 } 7377 7378 $scope.customAnswers = []; 7379 7380 $scope.requiredCheckFailed = false; 7381 7382 jQuery('.customFormItem').each(function () { 7383 let j = jQuery(this); 7384 let f = jQuery(this).val(); 7385 if (f != "Select") { 7386 jQuery(this).removeClass('manualinvalid'); 7387 7388 if (jQuery(this).val() == 'Select' && jQuery(this).hasClass('customFormDropdown')) { 7389 jQuery(this).addClass('manualinvalid'); 7390 } else { 7391 $scope.customAnswers.push({ detailId: jQuery(this).attr('data-id'), answer: jQuery(this).val() }); 7392 } 7393 } 7394 }); 7395 7396 7397 jQuery('.checkboxGroup').each(function () { 7398 var vals = []; 7399 var detailId = ""; 7400 7401 var localCheckFailed = jQuery(this).attr('data-required') == "true"; 7402 var localId = null; 7403 7404 jQuery(this).find('.customFormCheckbox').each(function () { 7405 7406 var dataval = jQuery(this).val().split('|'); 7407 detailId = dataval[0]; 7408 localId = dataval[0]; 7409 7410 if (jQuery(this).prop('checked')) { 7411 vals.push(dataval[1]); 7412 localCheckFailed = false; 7413 } 7414 }); 7415 7416 if (localCheckFailed) { 7417 $scope.requiredCheckFailed = true; 7418 jQuery('.custom-feedback[data-id-feedback=' + localId + ']').css('display', 'block'); 7419 } else { 7420 jQuery('.custom-feedback[data-id-feedback=' + localId + ']').css('display', 'none'); 7421 } 7422 7423 $scope.customAnswers.push({ detailId: detailId, answer: vals.join('| ') }); 7424 7425 }); 7426 7427 jQuery('.radioGroup').each(function () { 7428 var dataval = []; 7429 7430 jQuery(this).find('.customFormRadio').each(function () { 7431 dataval[0] = jQuery(this).val().split('|')[0]; 7432 7433 if (jQuery(this).prop('checked')) { 7434 dataval = jQuery(this).val().split('|'); 7435 } 7436 }); 7437 7438 if (dataval.length == 2) { 7439 $scope.customAnswers.push({ detailId: dataval[0], answer: dataval[1] }); 7440 } else if (dataval.length == 1) { 7441 $scope.customAnswers.push({ detailId: dataval[0], answer: "" }); 7442 } 7443 }); 7444 7445 7446 7447 $scope.loopfailed = false; 7448 7449 angular.forEach($scope.questions, function (question) { 7450 var failed = true; 7451 7452 if (question.required) { 7453 var failed = true; 7454 7455 if (question.detailControlType == 8) { 7456 if (!question.attachments) { 7457 question.isInvalid = true; 7458 } else { 7459 if (!question.attachments.length) { 7460 question.isInvalid = true; 7461 } else { 7462 7463 var answer = ""; 7464 angular.forEach(question.attachments, function (attachment) { 7465 7466 if (answer != "") { 7467 answer += ","; 7468 } 7469 answer += attachment.uploadedFileId; 7470 }); 7471 7472 $scope.customAnswers.push({ detailId: question.detailId, answer: answer, isUpload: true });
7473 failed = false; 7474 } 7475 } 7476 7477 7478 } else { 7479 angular.forEach($scope.customAnswers, function (answer) { 7480 question.isInvalid = true; 7481 if (answer.detailId == question.detailId && answer.answer.length > 0) { 7482 failed = false; 7483 question.isInvalid = false; 7484 } 7485 }); 7486 if (question.min != null || question.max != null) { 7487 angular.forEach($scope.customAnswers, function (answer) { 7488 if (answer.questionId == question.questionId && answer.answer.length > 0) { 7489 var arr = answer.answer.split(','); 7490 var count = arr.length; 7491 if (question.min != null) { 7492 if (count < question.min) { 7493 question.incorrectMinMax = true; 7494 failed = true; 7495 } 7496 } 7497 if (question.max != null) { 7498 if (count > question.max) { 7499 question.incorrectMinMax = true; 7500 failed = true; 7501 } 7502 7503 } 7504 } 7505 }); 7506 } 7507 } 7508 if (failed) { 7509 $scope.loopfailed = true; 7510 } 7511 } else { 7512 failed = false; 7513 if (question.detailControlType == 8) { 7514 if (!question.attachments) { 7515 //do nothing 7516 } else { 7517 if (!question.attachments.length) { 7518 //do nothing 7519 } else { 7520 7521 var answer = ""; 7522 angular.forEach(question.attachments, function (attachment) { 7523 7524 if (answer != "") { 7525 answer += ","; 7526 } 7527 answer += attachment.uploadedFileId; 7528 }); 7529 7530 $scope.customAnswers.push({ detailId: question.detailId, answer: answer, isUpload: true }); 7531 failed = false; 7532 } 7533 } 7534 } 7535 } 7536 7537 if (question.removedAttachments) { 7538 var removedAnswer = ""; 7539 angular.forEach(question.removedAttachments, function (attachment) { 7540 if (removedAnswer != "") { 7541 removedAnswer += ","; 7542 } 7543 removedAnswer += attachment.uploadedFileId; 7544 }); 7545 $scope.customAnswers.push({ detailId: question.detailId, answer: "", removedAnswer: removedAnswer, isUpload: true });
7546 } 7547 7548 if (failed) { 7549 7550 jQuery('.form-check-input').each(function () { 7551 var aVal = $(this).val(); 7552 var valSplit = aVal.split('|'); 7553 if (valSplit[0] == question.detailId || valSplit[0] == question.questionId) { 7554 $(this).next().addClass('invalid-label'); 7555 } 7556 }); 7557 7558 $scope.loopfailed = true; 7559 jQuery('.custom-feedback[data-id-feedback=' + question.detailId + ']').css('display', 'block'); 7560 jQuery('.customFormItem[data-id=' + question.detailId + ']').addClass("custominvalid"); 7561 } else if (question.detailControlType != 3) { 7562 jQuery('.custom-feedback[data-id-feedback=' + question.detailId + ']').css('display', 'none'); 7563 } 7564 7565 var indexQ = $scope.customAnswers.map(function (e) { return e.detailId; }).indexOf(question.detailId); 7566 if (indexQ !== -1) { 7567 $scope.customAnswers[indexQ].hasMemberDirectoryOptIn = question.hasMemberDirectoryOptIn; 7568 } 7569 7570 }); 7571 7572 if ($scope.requiredCheckFailed) { 7573 $scope.showError = true; 7574 return; 7575 } 7576 7577 if ($scope.loopfailed) { 7578 $scope.showError = true; 7579 return; 7580 } 7581 7582 $scope.currentUser.customAnswers = $scope.customAnswers; 7583 7584 if ($scope.blockSubmit) { 7585 return; 7586 } 7587 7588 $scope.blockSubmit = true; 7589 7590 if ($scope.newImageId) { 7591 $scope.cropperdata.imageId = $scope.newImageId; 7592 7593 $scope.ajaxCall('/File/CropImage', { data: $scope.cropperdata }, function (data) { 7594 $scope.currentUser.fileId = data; 7595 $scope.ajaxCall('/Customer/SaveMember', { customerId: $scope.customerId, user: $scope.currentUser }, function () { 7596 $scope.blockSubmit = false; 7597 $scope.checkDirty = false; 7598 $timeout(function () { 7599 7600 $scope.$close($scope.newemail); 7601 }, 100); 7602 }); 7603 }); 7604 7605 } else { 7606 $scope.ajaxCall('/Customer/SaveMember', { customerId: $scope.customerId, user: $scope.currentUser }, function () { 7607 $scope.blockSubmit = false; 7608 $scope.checkDirty = false; 7609 $timeout(function () { 7610 $scope.$close($scope.newemail); 7611 }, 100); 7612 }); 7613 } 7614 }; 7615 }, 7616 backdrop: 'static', 7617 resolve: { 7618 userId: function () { 7619 return userId; 7620 }, 7621 states: function () { 7622 return $scope.states; 7623 }, 7624 customerId: function () { 7625 return $scope.sitedata.customerId; 7626 }, 7627 sitedata: function () { 7628 return $scope.sitedata; 7629 }, 7630 canClose: function () { 7631 return canClose; 7632 }, 7633 } 7634 }).result.then(function (newemail) { 7635 if (newemail) { 7636 $scope.successMessage("The new email address won't appear on their profile until the member confirms the change via the email sent to their previous email address."); 7637 } 7638 }, function () { 7639 7640 }); 7641 7642 }; 7643 7644 $scope.StopEventPropagation = (e) => { 7645 if (!e) return; 7646 e.cancelBubble = true; 7647 if (e.stopPropagation) e.stopPropagation(); 7648 }; 7649 7650 $scope.InitCalendar = (id) => ({ 7651 id: id, 7652 data: [], 7653 el: undefined, 7654 y: undefined, 7655 m: undefined, 7656 onDateClick(e) { 7657 $scope.StopEventPropagation(e); 7658 const el = e.srcElement; 7659 }, 7660 onEventClick(e) { 7661 $scope.StopEventPropagation(e); 7662 const el = e.srcElement; 7663 }, 7664 bindData(events) { 7665 this.data = events.sort((a, b) => { 7666 if (a.time < b.time) return -1; 7667 if (a.time > b.time) return 1; 7668 return 0; 7669 }); 7670 }, 7671 renderEvents() { 7672 if (!this.data || this.data.length <= 0) return; 7673 //const lis = this.el.querySelectorAll(`.${this.id} .days .inside`); 7674 const lis = this.el.querySelectorAll(`.days .inside`); 7675 let y = this.el.querySelector('.month-year .year').innerText; 7676 let m = lis[0].querySelector('.date').getAttribute('month'); 7677 lis.forEach((li) => { 7678 let d = li.innerText; 7679 let divEvents = li.querySelector('.events'); 7680 li.onclick = this.onDateClick; 7681 this.data.forEach((ev) => { 7682 let evTime = moment(ev.time); 7683 if (evTime.year() == y && evTime.month() == m && evTime.date() == d) { 7684 let frgEvent = document.createRange().createContextualFragment(` 7685 <div time="${ev.time}" data-eventId="${ev.eventId}" data-entryId="${ev.entryId}" ng-click="handleCalendarClick('${ev.eventId}', '${ev.entryId}', '${ev.amenityId}
7685', '${ev.time}')" class="event ${ev.cls}">${ev.desc}</div> 7686 `); 7687 divEvents.appendChild(frgEvent); 7688 let divEvent = divEvents.querySelector(`.event[time='${ev.time}']`); 7689 divEvent.onclick = this.onEventClick; 7690 } 7691 }); 7692 }); 7693 }, 7694 render(y, m) { 7695 //------------------------------------------------------------------------------------------- 7696 //first time when you call render() without params, it is going to default to current date. 7697 //this logic here is to make sure if you re-render by calling render() without any param again, 7698 //if the calendar is already looking at some other month, then it will get the updated data, but 7699 //the calendar will not jump back to current month and stay at the previous month you are looking at. 7700 //this is useful when server side has updated events, calendar can re-bindData() and re-render() 7701 //itself correctly to reflect any changes. 7702 if (isNaN(y) && isNaN(this.y)) { 7703 this.y = moment().year(); 7704 } else if ((!isNaN(y) && isNaN(this.y)) || (!isNaN(y) && !isNaN(this.y))) { 7705 this.y = y > 1600 ? y : moment().year(); //calendar doesn't exist before 1600! :) 7706 } 7707 if (isNaN(m) && isNaN(this.m)) { 7708 this.m = moment().month(); 7709 } else if ((!isNaN(m) && isNaN(this.m)) || (!isNaN(m) && !isNaN(this.m))) { 7710 this.m = m >= 0 ? m : moment().month(); //momentjs month starts from 0-11 7711 } 7712 //------------------------------------------------------------------------------------------ 7713 7714 const d = moment().year(this.y).month(this.m).date(1); //first date of month 7715 var endOfMonth = d.clone().endOf('month'); 7716 7717 const now = moment(); 7718 const frgCal = document.createRange().createContextualFragment(` 7719 <div class="calendar noselect p-5"> 7720 <div class="month-year-btn d-flex justify-content-center align-items-center mb-2"> 7721 <a class="prev-month"><i class="fas fa-caret-left fa-lg m-3"></i></a> 7722 <div class="month-year d-flex justify-content-center align-items-center"> 7723 <div class="month mb-2 mr-2">${moment().month(this.m).format('MMMM')}</div> 7724 <div class="year mb-2">${this.y}</div> 7725 </div> 7726 <a class="next-month"><i class="fas fa-caret-right fa-lg m-3" aria-hidden="true"></i></a> 7727 </div> 7728 <ol class="day-names list-unstyled"> 7729 <li><h6 class="initials">Sun</h6></li> 7730 <li><h6 class="initials">Mon</h6></li> 7731 <li><h6 class="initials">Tue</h6></li> 7732 <li><h6 class="initials">Wed</h6></li> 7733 <li><h6 class="initials">Thu</h6></li> 7734 <li><h6 class="initials">Fri</h6></li> 7735 <li><h6 class="initials">Sat</h6></li> 7736 </ol> 7737 </div> 7738 `); 7739 const isSameDate = (d1, d2) => d1.format('YYYY-MM-DD') == d2.format('YYYY-MM-DD'); 7740 let frgWeek; 7741 d.day(-1); //move date to the oldest Sunday, so that it lines up with the calendar layout 7742 7743 7744 var i = 0; 7745 for (let i = 0; i < 6; i++) { //loop thru 35 boxes on the calendar month 7746 7747 d.add(1, 'd'); 7748 if (d >= endOfMonth) { 7749 i = 6; 7750 } else { 7751 7752 d.add(-1, 'd'); 7753 7754 frgWeek = document.createRange().createContextualFragment(` 7755 <ol class="days list-unstyled" week="${d.week()}"> 7756 <li class="${d.add(1, 'd'), this.m != d.month() ? ' outside' : 'inside'}${isSameDate(d, now) ? ' today' : ''}"><div month="${d.month()}" class="date">${d.format('D')}</div><div class="events"></div></li> 7757 <li class="${d.add(1, 'd'), this.m != d.month() ? ' outside' : 'inside'}${isSameDate(d, now) ? ' today' : ''}"><div month="${d.month()}" class="date">${d.format('D')}</div><div class="events"></div></li> 7758 <li class="${d.add(1, 'd'), this.m != d.month() ? ' outside' : 'inside'}${isSameDate(d, now) ? ' today' : ''}"><div month="${d.month()}" class="date">${d.format('D')}</div><div class="events"></div></li> 7759 <li class="${d.add(1, 'd'), this.m != d.month() ? ' outside' : 'inside'}${isSameDate(d, now) ? ' today' : ''}"><div month="${d.month()}" class="date">${d.format('D')}</div><div class="events"></div></li> 7760 <li class="${d.add(1, 'd'), this.m != d.month() ? ' outside' : 'inside'}${isSameDate(d, now) ? ' today' : ''}"><div month="${d.month()}" class="date">${d.format('D')}</div><div class="events"></div></li> 7761 <li class="${d.add(1, 'd'), this.m != d.month() ? ' outside' : 'inside'}${isSameDate(d, now) ? ' today' : ''}"><div month="${d.month()}" class="date">${d.format('D')}</div><div class="events"></div></li> 7762 <li class="${d.add(1, 'd'), this.m != d.month() ? ' outside' : 'inside'}${isSameDate(d, now) ? ' today' : ''}"><div month="${d.month()}" class="date">${d.format('D')}</div><div class="events"></div></li> 7763 </ol> 7764 `); 7765 7766 if (d >= endOfMonth) { 7767 i = 6; 7768 } 7769 //i++; 7770 frgCal.querySelector('.calendar').appendChild(frgWeek); 7771 } 7772 } 7773 7774 frgCal.querySelector('.prev-month').onclick = () => { 7775 const dp = moment().year(this.y).month(this.m).date(1).subtract(1, 'month'); 7776 this.render(dp.year(), dp.month()); 7777 $scope.refreshCalButtons(id); 7778 }; 7779 frgCal.querySelector('.next-month').onclick = () => { 7780 const dn = moment().year(this.y).month(this.m).date(1).add(1, 'month'); 7781 this.render(dn.year(), dn.month()); 7782 7783 $scope.refreshCalButtons(id); 7784 }; 7785 this.el = document.getElementById(this.id); 7786 this.el.innerHTML = ''; //replacing 7787 this.el.appendChild(frgCal); 7788 this.renderEvents(); 7789 } 7790 }); 7791 7792 7793 7794 $scope.loadCalendarEventModal = function (event) { 7795 $uibModal.open({ 7796 templateUrl: 'view-calendar-event-modal', 7797 size: 'lg', 7798 controller: function ($scope, $timeout, eventId, customerId, sitePrefix) { 7799 $scope.sitePrefix = sitePrefix; 7800 $scope.event = null; 7801 $scope.ajaxCall('/Sites/GetEventsUrl', { customerId: customerId }, function (data) { 7802 $scope.eventsUrl = data; 7803 }, function () { 7804 7805 }, false); 7806 7807 $scope.ajaxCall('/Sites/GetEvent', { customerId: customerId, eventId: eventId }, function (data) { 7808 $scope.event = data; 7809 }); 7810 $scope.setUrl = function (url) { 7811 window.location.href = url; 7812 } 7813 7814 }, 7815 backdrop: 'static', 7816 resolve: { 7817 eventId: function () { 7818 return event; 7819 }, 7820 customerId: function () { 7821 return $scope.sitedata.customerId; 7822 }, 7823 sitePrefix: function () { 7824 return $scope.sitePrefix; 7825 } 7826 } 7827 }).result.then(function () { 7828 }, function () { 7829 7830 }); 7831 } 7832 7833 $scope.renderCalendarTime = function (entry) { 7834 if (entry.isAllDay) { 7835 return 'All Day'; 7836 } else if (entry.startTime && entry.endTime) { 7837 return entry.startTime + ' â ' + entry.endTime; 7838 } else { 7839 return entry.startTime; 7840 } 7841 } 7842
7843 $scope.loadCalendarEntryModal = function (entry, date) { 7844 var renderCalendarTime = $scope.renderCalendarTime; 7845 7846 $uibModal.open({ 7847 templateUrl: 'view-calendar-entry-modal', 7848 size: 'lg', 7849 controller: function ($scope, $timeout, entryId, customerId, date) { 7850 $scope.selectedDate = Date.parse(date); 7851 $scope.formattedDate = $filter('date')($scope.selectedDate, 'M/d/yyyy'); 7852 7853 $scope.entry = null; 7854 7855 $scope.ajaxCall('/Sites/GetCalendarEntryPublic', { customerId: customerId, entryId: entryId }, function (data) { 7856 $scope.entry = data; 7857 $scope.entry.formattedTime = renderCalendarTime($scope.entry); 7858 }); 7859 }, 7860 backdrop: 'static', 7861 resolve: { 7862 entryId: function () { 7863 return entry; 7864 }, 7865 customerId: function () { 7866 return $scope.sitedata.customerId; 7867 }, 7868 date: function () { 7869 return date; 7870 }, 7871 } 7872 }).result.then(function () { 7873 }, function () { 7874 7875 }); 7876 } 7877 7878 $scope.loadAmenityCalendarEntryModal = function (amenityId, time) { 7879 $uibModal.open({ 7880 templateUrl: 'view-amenity-calendar-entry-modal', 7881 size: 'lg', 7882 controller: function ($scope, $timeout, amenityId, customerId, time) { 7883 $scope.amenity = null; 7884 $scope.date = time; 7885 $scope.currentTimestamp = (new Date()).toString(); 7886 7887 $scope.ajaxCall('/Sites/GetAmenityCalendarEntryPublic', { customerId: customerId, amenityId: amenityId, date: $scope.date }, function (data) { 7888 console.log(data); 7889 $scope.amenity = data; 7890 }); 7891 7892 $scope.selectAvailability = function (availability) { 7893 if (!availability.isBooked && availability.isAvailable) { 7894 if ($scope.isSlotSelected() && !$scope.amenity.isConsecutiveReservationsAllowed){ 7895 return; 7896 } 7897 availability.selected = !availability.selected; 7898 } 7899 } 7900 7901 $scope.isDateLessThan = function (time1, date1, datetime2) { 7902 var brokentime = time1.split(":"); 7903 var hour = parseInt(brokentime[0]); 7904 var mins = brokentime[1].slice(0, 2); 7905 if (brokentime[1].slice(2) == "PM" && hour != 12) { 7906 hour += 12; 7907 } 7908 var dateified = new Date(date1); 7909 dateified.setHours(hour); 7910 dateified = (new Date(dateified)).setMinutes(mins); 7911 7912 var isLess = (new Date(dateified)) < new Date(); 7913 return isLess; 7914 } 7915 7916 $scope.hasOpenSlots = function () { 7917 var hasSlots = false; 7918 angular.forEach($scope.amenity.availabilitySlots, function (slot) { 7919 if (!slot.isBooked && slot.isAvailable) { 7920 hasSlots = true; 7921 } 7922 }); 7923 7924 return hasSlots 7925 } 7926 7927 7928 $scope.isSlotSelected = function () { 7929 var isSelected = false; 7930 angular.forEach($scope.amenity.availabilitySlots, function (slot) { 7931 if (slot.selected && slot.isAvailable) { 7932 isSelected = true; 7933 } 7934 }); 7935 7936 return isSelected 7937 } 7938 7939 $scope.lastAvailableIndex = null; 7940 $scope.invalidIndexes = false; 7941 $scope.noSelections = false; 7942 $scope.reserve = function () { 7943 $scope.invalidIndexes = false; 7944 $scope.lastAvailableIndex = null; 7945 7946 var index = 0; 7947 angular.forEach($scope.amenity.availabilitySlots, function (slot) { 7948 if (slot.isAvailable) { 7949 7950 7951 console.log(slot); 7952 if (slot.selected) { 7953 if ($scope.lastAvailableIndex != null) { 7954 if ($scope.lastAvailableIndex != index - 1) { 7955 $scope.invalidIndexes = true; 7956 console.log("Found conflict"); 7957 console.log(index); 7958 return; 7959 } 7960 } 7961 7962 $scope.lastAvailableIndex = index; 7963 } 7964 7965 index++; 7966 } 7967 }); 7968 7969 if ($scope.invalidIndexes) { 7970 return; 7971 } 7972 7973 $scope.invalidIndexes = false; 7974 if ($scope.lastAvailableIndex == null) { 7975 console.log("Found no selections"); 7976 7977 $scope.noSelections = true; 7978 return; 7979 } 7980 7981 $scope.noSelections = false; 7982 7983 //Check availability slots here 7984 $scope.$close($scope.amenity); 7985 } 7986 }, 7987 backdrop: 'static', 7988 resolve: { 7989 amenityId: function () { 7990 return amenityId; 7991 }, 7992 customerId: function () { 7993 return $scope.sitedata.customerId; 7994 }, 7995 time: function () { 7996 return time; 7997 }, 7998 } 7999 }).result.then(function (amenity) { 8000 $scope.triggerReserveAmenity(amenity, amenity.searchDate); 8001 }, function () { 8002 8003 }); 8004 } 8005 8006 $scope.cal; 8007 8008 $scope.calendarData = []; 8009 8010 $scope.loadCalendar = function (widget) { 8011 if (widget.membersOnlyCalendar && !$scope.isMember) { 8012 return; 8013 } 8014 8015 mobiscroll.setOptions({ 8016 theme: 'ios', 8017 themeVariant: 'light', 8018 select: 'off', 8019 clickToCreate: false, 8020 dragToCreate: false, 8021 dragToMove: false, 8022 dragToResize: false, 8023 height: 700 8024 }); 8025 8026 $timeout(function () { 8027 $(function () { 8028 widget.cal = $('#' + 'calendar-' + widget.widgetId).mobiscroll().eventcalendar({ 8029 view: { 8030 calendar: { labels: true } 8031 }, 8032 onEventClick: function (event, inst) { 8033 console.log(event); 8034 if (event.event.entryid != null) { 8035 angular.element(document.getElementById('publicSiteControllerIdentifier')).scope().loadCalendarEntryM
8035odal(event.event.entryid, event.date); 8036 } 8037 if (event.event.eventId != null) { 8038 angular.element(document.getElementById('publicSiteControllerIdentifier')).scope().loadCalendarEventModal(event.event.eventId); 8039 } 8040 if (event.event.amenityId != null) { 8041 angular.element(document.getElementById('publicSiteControllerIdentifier')).scope().loadAmenityCalendarEntryModal(event.event.amenityId, event.event.start); 8042 } 8043 }, 8044 }).mobiscroll('getInst'); 8045 8046 var calendarId = widget.calendarId; 8047 if (calendarId) { 8048 $scope.ajaxCall('/Sites/GetCalendarEntriesPublic', { customerId: $scope.sitedata.customerId, calendarId: calendarId }, function (data) { 8049 angular.forEach(data, function (item) { 8050 if (item.recurring != null && item.recurring.hasOwnProperty('pos')) { 8051 if (!item.recurring.pos) { 8052 delete item.recurring.pos; 8053 } 8054 } 8055 }); 8056 8057 widget.cal.setEvents(data); 8058 }); 8059 } 8060 }); 8061 }, 50); 8062 } 8063 8064 8065 8066 $scope.amenityHtml = ""; 8067 $scope.compileAmenity = function (id) { 8068 8069 if (jQuery(id).html() != $scope.amenityHtml) { 8070 $compile(jQuery(id).contents())($scope); 8071 $scope.amenityHtml = jQuery(id).html(); 8072 } 8073 8074 $timeout(function () { 8075 $scope.compileAmenity(id); 8076 }, 1000); 8077 } 8078 8079 $scope.amenities = []; 8080 8081 $scope.initMultiSelectDropdown = function () { 8082 $timeout(function () { 8083 $('.example-multiselect').each(function () { 8084 $(this).multiselect("destroy").multiselect(); 8085 }); 8086 }); 8087 } 8088 8089 $scope.searchAmenity = { name: "", ids: [] } 8090 $scope.clearAmenities = function (widget) { 8091 8092 $scope.searchAmenity.name = ""; 8093 $scope.searchAmenity.ids = []; 8094 $scope.initMultiSelectDropdown(); 8095 $scope.loadAmenityCalendar(widget); 8096 } 8097 8098 $scope.loadAmenityCalendar = function (widget) { 8099 if (!$scope.isMember) { 8100 return; 8101 } 8102 8103 $scope.ajaxCall('/Sites/GetAmenitiesPublic', { customerId: $scope.sitedata.customerId }, function (data) { 8104 $scope.amenities = data; 8105 $scope.initMultiSelectDropdown(); 8106 }); 8107 8108 mobiscroll.setOptions({ 8109 theme: 'ios', 8110 themeVariant: 'light', 8111 select: 'off', 8112 clickToCreate: false, 8113 dragToCreate: false, 8114 dragToMove: false, 8115 dragToResize: false, 8116 height: 700 8117 8118 }); 8119 8120 $timeout(function () { 8121 $(function () { 8122 widget.cal = $('#' + 'calendar-' + widget.widgetId).mobiscroll().eventcalendar({ 8123 view: { 8124 calendar: { labels: true } 8125 }, 8126 onEventClick: function (event, inst) { 8127 console.log(event); 8128 if (event.event.entryid != null) { 8129 angular.element(document.getElementById('publicSiteControllerIdentifier')).scope().loadCalendarEntryModal(event.event.entryid, event.date); 8130 } 8131 if (event.event.eventId != null) { 8132 angular.element(document.getElementById('publicSiteControllerIdentifier')).scope().loadCalendarEventModal(event.event.eventId); 8133 } 8134 if (event.event.amenityId != null) { 8135 angular.element(document.getElementById('publicSiteControllerIdentifier')).scope().loadAmenityCalendarEntryM
8135odal(event.event.amenityId, event.event.start); 8136 } 8137 }, 8138 }).mobiscroll('getInst'); 8139 8140 $scope.ajaxCall('/Sites/GetAmenityCalendarEntriesPublic', { customerId: $scope.sitedata.customerId, amenityName: $scope.searchAmenity.name, amenityIds: $scope.searchAmenity.ids }, function (data) { 8141 widget.cal.setEvents(data); 8142 }); 8143 }); 8144 }, 50); 8145 } 8146 8147 $scope.amenityTab = 'start'; 8148 $scope.reserveAmenity = null; 8149 $scope.amenityReservation = null; 8150 8151 $scope.setAmenityTab = function (tab) { 8152 $scope.amenityTab = tab; 8153 } 8154 8155 $scope.clearAmenityMemberInformation = function () { 8156 $scope.amenityReservation.firstName = ''; 8157 $scope.amenityReservation.lastName = ''; 8158 $scope.amenityReservation.phone = ''; 8159 $scope.amenityReservation.emailAddress = ''; 8160 $scope.amenityReservation.country = 1; 8161 $scope.amenityReservation.address1 = ''; 8162 $scope.amenityReservation.address2 = ''; 8163 $scope.amenityReservation.city = ''; 8164 $scope.amenityReservation.stateId = ''; 8165 $scope.amenityReservation.zip = ''; 8166 $scope.amenityReservation.country = 1; 8167 $scope.amenityReservation.internationalZip = ''; 8168 $scope.amenityReservation.internationalState = ''; 8169 } 8170 8171 $scope.amenityMembers = null; 8172 $scope.getAmenityMembers = function () { 8173 if (!$scope.isAdmin) { 8174 return; 8175 } 8176 $scope.ajaxCall('/Customer/GetCustomerMembers', { customerId: $scope.sitedata.customerId }, function (data) { 8177 $scope.amenityMembers = data; 8178 }, function () { }, false); 8179 } 8180 8181 $scope.triggerReserveAmenity = function (amenity, date) { 8182 $scope.amenityReservation = { stateId: null, attendees: 1, anotherMember: false, country: 1, reservationUserId: null, paymentType: "card", duration: 1, grandTotal: 0, isSponsor: false, date: date } 8183 8184 if ($scope.currentUser) { 8185 $scope.amenityReservation.firstName = $scope.currentUser.firstName; 8186 $scope.amenityReservation.lastName = $scope.currentUser.lastName; 8187 $scope.amenityReservation.phone = $scope.currentUser.phone; 8188 $scope.amenityReservation.emailAddress = $scope.currentUser.emailAddress; 8189 $scope.amenityReservation.address1 = $scope.currentUser.address1; 8190 $scope.amenityReservation.address2 = $scope.currentUser.address2; 8191 $scope.amenityReservation.city = $scope.currentUser.city; 8192 $scope.amenityReservation.stateId = $scope.currentUser.state; 8193 $scope.amenityReservation.zip = $scope.currentUser.zip; 8194 $scope.amenityReservation.country = $scope.currentUser.country; 8195 $scope.amenityReservation.internationalState = $scope.currentUser.internationalState; 8196 $scope.amenityReservation.internationalZip = $scope.currentUser.internationalZip; 8197 $scope.amenityReservation.startTime = "12:00PM"; 8198 8199 var count = 0; 8200 8201 8202 angular.forEach(amenity.availabilitySlots, function (slot) { 8203 if (slot.selected) { 8204 if (count == 0) { 8205 $scope.amenityReservation.startTime = slot.startTime; 8206 } 8207 8208 count++; 8209 } 8210 }); 8211 8212 $scope.amenityReservation.duration = count; 8213 8214 if (amenity.duration == 9) { 8215 $scope.amenityReservation.duration = 1; 8216 } 8217 8218 } 8219 8220 $scope.reserveAmenity = amenity; 8221 8222 $scope.amenityTab = 'start'; 8223 } 8224 8225 $scope.clearAmenity = function () { 8226 $scope.reserveAmenity = null; 8227 } 8228 8229 $scope.nextAmenitySection = function () { 8230 switch ($scope.amenityTab) { 8231 case "start": 8232 $scope.amenityTab = "information"; 8233 break; 8234 case "information": 8235 8236 if ($scope.reserveAmenity.documentId || $scope.reserveAmenity.ageLimit || $scope.reserveAmenity.formId) { 8237 $scope.amenityTab = "terms"; 8238 } else { 8239 $scope.amenityTab = "final"; 8240 } 8241 break; 8242 case "terms": 8243 $scope.amenityTab = "final"; 8244 break; 8245 case "final": 8246 //nothing here 8247 break; 8248 } 8249 8250 $scope.amenityReservation.grandTotal = 0; 8251 $scope.amenityReservation.convenienceFee = 0; 8252 var paymentMethodTemp = null; 8253 8254 console.log($scope.amenityReservation.paymentMethods); 8255 if ($scope.amenityReservation.paymentMethods) { 8256 console.log("Payment Method Index Found"); 8257 8258 var paymentMethodIndex = $scope.amenityReservation.paymentMethods.map(function (e) { return e.paymentMethodId }).indexOf($scope.amenityReservation.paymentMethod); 8259 if (paymentMethodIndex != -1) { 8260 $scope.paymentMethodTemp = $scope.amenityReservation.paymentMethods[paymentMethodIndex]; 8261 } 8262 } 8263 8264 if ($scope.reserveAmenity.requiresPayment) { 8265 var total = 0; 8266 var convenienceFee = 0; 8267 8268 if ($scope.reserveAmenity.perPerson) { 8269 8270 if ($scope.reserveAmenity.maxCapacity != null) { 8271 if ($scope.amenityReservation.attendees > $scope.reserveAmenity.maxCapacity) { 8272 $scope.amenityReservation.attendees = $scope.reserveAmenity.maxCapacity; 8273 } 8274 } else { 8275 if ($scope.amenityReservation.attendees > 99) { 8276 $scope.amenityReservation.attendees = 99; 8277 } 8278 } 8279 8280 total = $scope.amenityReservation.duration * $scope.reserveAmenity.price * $scope.amenityReservation.attendees; 8281 } else { 8282 total = $scope.amenityReservation.duration * $scope.reserveAmenity.price; 8283 } 8284 8285 if ($scope.reserveAmenity.enableConvenienceFee) { 8286 8287 if (paymentMethodTemp) { 8288 if (paymentMethodTemp.isAch) { 8289 var calculateCharge = (total); 8290 convenienceFee = ((calculateCharge + parseFloat(($scope.reserveAmenity.convenienceFeeDollarAmountPlaid ? parseFloat($scope.reserveAmenity.convenienceFeeDollarAmountPlaid) : 0))) / (1 - (parseFloat(($scope.reserveAmenity.convenienceFeePercentagePlaid ? parseFloat($scope.reserveAmenity.convenienceFeePercentagePlaid) : 0)) / 100)) - calculateCharge); 8291 } else { 8292 var calculateCharge = (total); 8293 convenienceFee = ((calculateCharge + parseFloat(($scope.reserveAmenity.convenienceFeeDollarAmount ? parseFloat($scope.reserveAmenity.convenienceFeeDollarAmount) : 0))) / (1 - (parseFloat(($scope.reserveAmenity.convenienceFeePercentage ? parseFloat($scope.reserveAmenity.convenienceFeePercentage) : 0)) / 100)) - calculateCharge); 8294 } 8295 } 8296 8297/* var percentageAmount = (total / 100) * ($scope.reserveAmenity.convenienceFeePercentage ? parseFloat($scope.reserveAmenity.convenienceFeePercentage) : 0); 8298 convenienceFee = parseFloat(percentageAmount) + ($scope.reserveAmenity.convenienceFeeDollarAmount ? parseFloat($scope.reserveAmenity.convenienceFeeDollarAmount) : 0); 8299*/ } 8300 8301 $scope.amenityReservation.convenienceFee = convenienceFee; 8302 $scope.amenityReservation.grandTotal = total + convenienceFee; 8303 } 8304 } 8305 8306 $scope.updateAmenityGrandTotal = function () { 8307 $scope.amenityReservation.grandTotal = 0; 8308 $scope.amenityReservation.convenienceFee = 0; 8309 if ($scope.reserveAmenity.requiresPayment) { 8310 var total = 0; 8311 var convenienceFee = 0; 8312 8313 if ($scope.reserveAmenity.perPerson) { 8314 8315 if ($scope.reserveAmenity.maxCapacity != null) { 8316 if ($scope.amenityReservation.attendees > $scope.reserveAmenity.maxCapacity) { 8317 $scope.amenityReservation.attendees = $scope.reserveAmenity.maxCapacity; 8318 } 8319 } else { 8320 if ($scope.amenityReservation.attendees > 99) { 8321 $scope.amenityReservation.attendees = 99; 8322 } 8323 } 8324 8325 total = $scope.amenityReservation.duration * $scope.reserveAmenity.price * $scope.amenityReservation.attendees; 8326 } else { 8327 total = $scope.amenityReservation.duration * $scope.reserveAmenity.price; 8328 } 8329 8330 if ($scope.reserveAmenity.enableConvenienceFee) { 8331 var paymentMethodTemp = null; 8332 8333 console.log($scope.amenityReservation.paymentMethods); 8334 8335 if ($scope.amenityReservation.paymentMethods) { 8336 console.log("Payment Method Index Found"); 8337 8338 var paymentMethodIndex = $scope.amenityReservation.paymentMethods.map(function (e) { return e.paymentMethodId }).indexOf($scope.amenityReservation.paymentMethod); 8339 if (paymentMethodIndex != -1) { 8340 paymentMethodTemp = $scope.amenityReservation.paymentMethods[paymentMethodIndex]; 8341 console.log("Found Payment Method Tmp"); 8342 } 8343 } 8344 8345 if (paymentMethodTemp) { 8346 console.log("Checking payment method Temp"); 8347 console.log(paymentMethodTemp); 8348 if (paymentMethodTemp.isAch) { 8349 var calculateCharge = (total); 8350 convenienceFee = ((calculateCharge + parseFloat(($scope.reserveAmenity.convenienceFeeDollarAmountPlaid ? parseFloat($scope.reserveAmenity.convenienceFeeDollarAmountPlaid) : 0))) / (1 - (parseFloat(($scope.reserveAmenity.convenienceFeePercentagePlaid ? parseFloat($scope.reserveAmenity.convenienceFeePercentagePlaid) : 0)) / 100)) - calculateCharge); 8351 8352 8353 } else { 8354 var calculateCharge = (total); 8355 convenienceFee = ((calculateCharge + parseFloat(($scope.reserveAmenity.convenienceFeeDollarAmount ? parseFloat($scope.reserveAmenity.convenienceFeeDollarAmount) : 0))) / (1 - (parseFloat(($scope.reserveAmenity.convenienceFeePercentage ? parseFloat($scope.reserveAmenity.convenienceFeePercentage) : 0)) / 100)) - calculateCharge); 8356 } 8357 } 8358 } 8359 8360 $scope.amenityReservation.convenienceFee = convenienceFee; 8361 $scope.amenityReservation.grandTotal = total + convenienceFee; 8362 } 8363 } 8364 8365 $scope.prevAmenitySection = function () { 8366 $scope.amenityValidationRan = false; 8367 switch ($scope.amenityTab) { 8368 case "start": 8369 //return; //Shouldn't happen. 8370 break; 8371 case "information": 8372 $scope.amenityTab = "start"; 8373 break; 8374 case "terms": 8375 $scope.amenityTab = "information"; 8376 break; 8377 case "final": 8378 8379 if ($scope.reserveAmenity.documentId || $scope.reserveAmenity.ageLimit || $scope.reserveAmenity.formId) { 8380 $scope.amenityTab = "terms"; 8381 } else { 8382 $scope.amenityTab = "information"; 8383 } 8384 8385 break; 8386 } 8387 } 8388 8389 $scope.manageAmenityCards = function () { 8390 $uibModal.open({ 8391 size: 'lg', 8392 templateUrl: 'manage-cards-modal', 8393 controller: function ($scope, $timeout, customerId, amenityReservation, sitedata, user) { 8394 $scope.amenityReservation = amenityReservation; 8395 $scope.sitedata = sitedata; 8396 8397 $scope.removeAutopay = true; 8398 8399 $scope.elements = null; 8400 $scope.style = null; 8401 $scope.card = null; 8402 $scope.paymentType = "card";
8403 $scope.plaidObject = { plaidLinked: false }; 8404 8405 $scope.customerId = customerId; 8406 $scope.stripeapi = null; 8407 8408 $scope.stripeApiKey = null; 8409 $scope.ajaxCall('/Customer/GetMyStripeCustomerInfo', { customerId: $scope.customerId }, function (data) { 8410 $scope.stripeapi = Stripe(data);//stripe dev key, replace with live! 8411 $scope.stripeApiKey = data; 8412 8413 //$scope.loadStripe = function () { 8414 $scope.elements = $scope.stripeapi.elements(); 8415 8416 // Custom styling can be passed to options when creating an Element. 8417 // (Note that this demo uses a wider set of styles than the guide below.) 8418 $scope.style = { 8419 base: { 8420 color: '#32325d', 8421 fontFamily: '"Helvetica Neue", Helvetica, sans-serif', 8422 fontSmoothing: 'antialiased', 8423 fontSize: '16px', 8424 '::placeholder': { 8425 color: '#495057', 8426 }, 8427 border: '1px solid #ced4da', 8428 8429 }, 8430 invalid: { 8431 color: '#fa755a', 8432 iconColor: '#fa755a' 8433 } 8434 }; 8435 8436 $scope.card = $scope.elements.create('card', { style: $scope.style }); 8437 $scope.card.mount('#stripe-card-element'); 8438 // } 8439 8440 8441 }); 8442 8443 $scope.paymentMethods = []; 8444 $scope.getPaymentMethods = function () { 8445 $scope.ajaxCall('/Customer/GetMyPaymentMethods', { customerId: $scope.customerId }, function (data) { 8446 $scope.paymentMethods = data; 8447 8448 $timeout(function () { 8449 jQuery('.paymentMethodList').each(function () { 8450 if (jQuery(this).val() == $scope.amenityReservation.paymentMethod) { 8451 jQuery(this).prop('checked', true); 8452 } 8453 }); 8454 }, 50) 8455 }); 8456 } 8457 8458 $scope.selectedPaymentMethod = null; 8459 $scope.getPaymentMethods(); 8460 8461 $scope.remove = function (paymentMethodId) { 8462 $uibModal.open({ 8463 templateUrl: 'remove-card-modal', 8464 controller: function ($scope, $timeout) { 8465 $scope.remove = function () { 8466 $scope.$close(); 8467 } 8468 }, 8469 backdrop: 'static', 8470 resolve: { 8471 } 8472 }).result.then(function () { 8473 $scope.ajaxCall('/Customer/RemoveMyPaymentMethod', { customerId: $scope.customerId, paymentMethodId }, function (data) { 8474 $scope.getPaymentMethods(); 8475 }); 8476 }, function () { 8477 8478 }); 8479 } 8480 8481 8482 $scope.errorHappened = false; 8483 $scope.addCard = function () { 8484 if ($scope.paymentType == "card") { 8485 $scope.stripeapi.createToken($scope.card).then(function (result) { 8486 if (result.error) { 8487 $scope.errorHappened = true; 8488 } else { 8489 $scope.errorHappened = false; 8490 $scope.ajaxCall('/Customer/SaveMyPaymentMethod', { customerId: $scope.customerId, paymentMethod: result.token }, function (data) { 8491 $scope.getPaymentMethods(); 8492 $scope.card.clear(); 8493 }); 8494 } 8495 }); 8496 8497 } 8498 else if ($scope.paymentType == "plaid") { 8499 $scope.errorHappened = false; 8500 $scope.ajaxCall('/Customer/SaveMyPaymentMethodPlaid', { customerId: $scope.customerId, plaidObject: $scope.plaidObject }, function (data) { 8501 $scope.getPaymentMethods(); 8502 $scope.card.clear(); 8503 $scope.plaidLinked = false; 8504 }); 8505 } 8506 } 8507 8508 8509 $scope.loadStripeACH = function () { 8510 $scope.pendingAchAccount = ''; 8511 $scope.pendingAchId = ''; 8512 8513 console.log("Started payment setup -- 3"); 8514 $scope.ajaxCall('/Stripe/CreatePaymentSetupIntent', { customerId: $scope.sitedata.customerId }, function (data) { 8515 if (data == "n/a") { 8516 $scope.sitedata.plaidEnabled = false; 8517 //Unable to connect to plaid, don't show it 8518 } else { 8519 $scope.plaidLoaded = true; 8520 8521 8522 var datasplit = data.split('|'); 8523 8524 $scope.stripeapi = Stripe($scope.stripeApiKey, { stripeAccount: datasplit[1] });//stripe dev key, replace with live! 8525 8526 $scope.pendingAchAccount = datasplit[0];
8527 $scope.pendingAchId = datasplit[2]; 8528 8529 // Calling this method will open the instant verification dialog. 8530 $scope.stripeapi.collectBankAccountForSetup({ 8531 clientSecret: datasplit[0], 8532 params: { 8533 payment_method_type: 'us_bank_account', 8534 payment_method_data: { 8535 billing_details: { 8536 name: user.firstName + " " + user.lastName, 8537 email: user.emailAddress, 8538 }, 8539 }, 8540 }, 8541 expand: ['payment_method'], 8542 }) 8543 .then(({ setupIntent, error }) => { 8544 if (error) { 8545 console.error(error.message); 8546 // PaymentMethod collection failed for some reason. 8547 } else if (setupIntent.status === 'requires_payment_method') { 8548 // Customer canceled the hosted verification modal. Present them with other 8549 // payment method type options. 8550 console.log("MEHEHH"); 8551 return; 8552 } else if (setupIntent.status === 'requires_confirmation') { 8553 // We collected an account - possibly instantly verified, but possibly 8554 // manually-entered. Display payment method details and mandate text 8555 // to the customer and confirm the intent once they accept 8556 // the mandate. 8557 console.log("Make mandate"); 8558 //confirmationForm.show(); 8559 $scope.plaidObject.plaidLinked = true; 8560 8561 } 8562 }); 8563 } 8564 8565 $scope.confirmStripeACH = function () { 8566 $scope.stripeapi.confirmUsBankAccountSetup($scope.pendingAchAccount) 8567 .then(({ setupIntent, error }) => { 8568 if (error) { 8569 console.error(error.message); 8570 $scope.errorMessage("Unable to link your account. Please try with a different payment method."); 8571 } else if (setupIntent.status === "requires_payment_method") { 8572 $scope.errorMessage("Unable to link your account. Please try with a different payment method."); 8573 } else if (setupIntent.status === "succeeded") { 8574 $scope.ajaxCall('/Stripe/FinalizePaymentSetupIntent', { customerId: $scope.sitedata.customerId, paymentMethodId: $scope.pendingAchId }, function (data) { 8575 $scope.pendingAchAccount = ''; 8576 $scope.pendingAchId = ''; 8577 8578 $scope.getPaymentMethods(); 8579 $scope.card.clear(); 8580 $scope.plaidObject.plaidLinked = false; 8581 }); 8582 } else if (setupIntent.next_action?.type === "verify_with_microdeposits") { 8583 $scope.errorMessage(""); 8584 } 8585 }); 8586 8587 } 8588 8589 }, function () { 8590 $scope.sitedata.plaidEnabled = false; 8591 8592 return; 8593 }, false); 8594 } 8595 8596 $scope.loadCardPlaid = function () { 8597 $scope.ajaxCall('/Pricing/GetCustomerPlaidToken', { customerId: $scope.sitedata.customerId }, function (data) { 8598 if (data == "n/a") { 8599 $scope.sitedata.plaidEnabled = false; 8600 //Unable to connect to plaid, don't show it 8601 } else { 8602 $scope.plaidLoaded = true; 8603 8604 $scope.eventLinkHandler = Plaid.create({ 8605 env: 'production', 8606 clientName: $scope.sitedata.siteName, 8607 token: data, 8608 product: ['auth'], 8609 apiVersion: 'v2', 8610 selectAccount: true, 8611 onSuccess: function (public_token, metadata) { 8612 // Send the public_token and account ID to your app server.
8613 $scope.plaidObject.plaidtoken = public_token; 8614 $scope.plaidObject.plaidid = metadata.account_id; 8615 $scope.plaidObject.plaidLinked = true; 8616 $scope.plaidObject.plaidInstitution = metadata.institution.name; 8617 $scope.$apply(); 8618 8619 $scope.errorHappened = false; 8620 $scope.ajaxCall('/Customer/SaveMyPaymentMethodPlaid', { customerId: $scope.customerId, plaidObject: $scope.plaidObject }, function (data) { 8621 $scope.getPaymentMethods(); 8622 $scope.card.clear(); 8623 $scope.plaidObject = { plaidLinked: false }; 8624 }, function () { 8625 $scope.plaidObject.plaidtoken = ""; 8626 $scope.plaidObject.plaidid = ""; 8627 $scope.plaidObject.plaidLinked = false; 8628 $scope.plaidObject.plaidInstitution = ""; 8629 }, true); 8630 8631 }, 8632 onExit: function (err, metadata) { 8633 // The user exited the Link flow. 8634 if (err != null) { 8635 // The user encountered a Plaid API error prior to exiting. 8636 } 8637 }, 8638 }); 8639 8640 // Trigger the Link UI 8641 document.getElementById('cardsLinkButton').onclick = function () { 8642 $scope.eventLinkHandler.open(); 8643 }; 8644 } 8645 8646 }, function () { 8647 $scope.sitedata.plaidEnabled = false; 8648 8649 return; 8650 }, false); 8651 8652 $scope.$apply(); 8653 } 8654 8655 $scope.noCardSelected = false; 8656 $scope.saveChanges = function () { 8657 $scope.noCardSelected = true; 8658 8659 var newvalue = null; 8660 jQuery('.paymentMethodList').each(function () { 8661 if (jQuery(this).prop('checked') == true) { 8662 newvalue = jQuery(this).val(); 8663 } 8664 }); 8665 8666 if (newvalue == null) { 8667 return; 8668 } 8669 $scope.noCardSelected = false; 8670 8671 $scope.amenityReservation.paymentMethod = newvalue; 8672 $scope.amenityReservation.paymentMethods = $scope.paymentMethods; 8673 8674 $scope.$close($scope.amenityReservation); 8675 } 8676 // Create an instance of the card Element. 8677 }, 8678 backdrop: 'static', 8679 resolve: { 8680 customerId: function () { 8681 return $scope.sitedata.customerId; 8682 }, 8683 amenityReservation: function () { 8684 return $scope.amenityReservation; 8685 }, 8686 sitedata: function () { 8687 return $scope.sitedata; 8688 }, 8689 user: function () { 8690 return AppConstants.CurrentUser; 8691 } 8692 } 8693 }).result.then(function (data) { 8694 8695 $scope.updateAmenityGrandTotal(); 8696 }, function () { 8697 $scope.updateAmenityGrandTotal(); 8698 }); 8699 }; 8700 8701 $scope.failedDate = false; 8702 $scope.amenitiesUnderstood = false; 8703 $scope.validateNextAmenitySection = function (form) { 8704 $scope.amenityValidationRan = true;
8705 if (form.$invalid) { 8706 console.log(form); 8707 return; 8708 } 8709 8710 if ($scope.amenityTab == "start") { 8711 if ($scope.amenityReservation.anotherMember && (!$scope.amenityReservation.reservationUserId || !$scope.amenityReservation.amenitiesUnderstood)) { 8712 return; 8713 } 8714 8715 $scope.nextAmenitySection(); 8716 8717 } else if ($scope.amenityTab == "information") { 8718 console.log($scope.reserveAmenity); 8719 8720 if ($scope.reserveAmenity.duration != 9) { 8721 $scope.ajaxCall('/Sites/CheckAmenityTimeslotValid/', { customerId: $scope.sitedata.customerId, amenityId: $scope.reserveAmenity.amenityId, date: $scope.amenityReservation.date, time: $scope.amenityReservation.startTime, slots: $scope.amenityReservation.duration }, function (data) { 8722 if (data == true) { 8723 $scope.failedDate = false; 8724 $scope.amenityValidationRan = false; 8725 $scope.nextAmenitySection(); 8726 8727 } else { 8728 $scope.failedDate = true; 8729 } 8730 }); 8731 } else { 8732 console.log("Should trigger next"); 8733 $scope.nextAmenitySection(); 8734 } 8735 8736 } else if ($scope.amenityTab == "terms") { 8737 8738 $scope.amenityValidationRan = true; 8739 8740 if (!$scope.amenityReservation.anotherMember && $scope.reserveAmenity.formId != null && !$scope.amenityReservation.formData.length) { 8741 return; 8742 } else if (!$scope.amenityReservation.verifiedAgeLimit && $scope.reserveAmenity.ageLimit) { 8743 return; 8744 } else if (!$scope.amenityReservation.verifiedDocument && $scope.reserveAmenity.acknowledgeDocument && $scope.reserveAmenity.documentId) { 8745 return; 8746 } 8747 8748 $scope.amenityValidationRan = false; 8749 8750 $scope.nextAmenitySection(); 8751 } else { 8752 $scope.amenityValidationRan = false; 8753 8754 $scope.nextAmenitySection(); 8755 } 8756 } 8757 8758 $scope.amenityForm = function () { 8759 $uibModal.open({ 8760 templateUrl: 'event-form-modal', 8761 controller: function ($scope, $timeout, formId, customerId, amenityReservation) { 8762 $scope.customerId = customerId; 8763 $scope.amenityReservation = amenityReservation; 8764 $scope.formId = null; 8765 $scope.formdata = null; 8766 8767 $scope.initMultipleUpload = function () { 8768 $timeout(function () { 8769 jQuery('.customMultipleUpload').each(function () { 8770 jQuery(this).find('input').prop('multiple', true); 8771 }); 8772 }, 50); 8773 } 8774 8775 $scope.file = null; 8776 $scope.inUpload = false; 8777 $scope.startFileUpload = function (files) { 8778 $scope.inUpload = true; 8779 }; 8780 8781 $scope.successFileUploadCustomMultiple = function (response, field) { 8782 $scope.inUpload = false; 8783 if (response.data.success) { 8784 8785 if (!field.attachments) { 8786 field.attachments = []; 8787 } 8788 angular.forEach(response.data.results, function (result) { 8789 var folderFile = {}; 8790 folderFile.uploadedFileId = result.fileId; 8791 folderFile.sizeInt = result.fileSizeBytes; 8792 folderFile.name = result.fileName; 8793 folderFile.type = result.fileType; 8794 8795 8796 field.attachments.push(folderFile); 8797 }); 8798 } else { 8799 $scope.errorMessage('One or more files exceeds the maximum file size of 15MB.'); 8800 } 8801 }; 8802 8803 $scope.removeFormFile = function (index, field) { 8804 field.attachments.splice(index, 1); 8805 } 8806 8807 $scope.imageSrc = function (fileId) { 8808 if (fileId != null) { 8809 return '/File/Get/' + fileId; 8810 } 8811 return null; 8812 }; 8813 $scope.ajaxCall('/Customer/GetFormSetupPublic', { customerId: $scope.customerId, formId: formId }, function (data) { 8814 $scope.formdata = data; 8815 $timeout(function () { 8816 if ($scope.amenityReservation.formData) { 8817 angular.forEach($scope.amenityReservation.formData, function (answer) { 8818 jQuery('.customFormItem').each(function () { 8819 if (jQuery(this).attr('data-id') == answer.questionId) { 8820 jQuery(this).val(answer.answer); 8821 } 8822 }); 8823 8824 var radioval = answer.questionId + '|' + answer.answer; 8825 var split = answer.answer.split(', '); 8826 8827 angular.forEach(split, function (uniqueanswer) { 8828 var checkboxval = answer.questionId + '|' + uniqueanswer; 8829 jQuery('.customFormCheckbox').each(function () { 8830 if (jQuery(this).val() == checkboxval) { 8831 jQuery(this).prop('checked', true); 8832 } 8833 }); 8834 8835 }); 8836 8837 jQuery('.customFormRadio').each(function () { 8838 if (jQuery(this).val() == radioval) { 8839 jQuery(this).prop('checked', true); 8840 } 8841 }); 8842 }); 8843 8844 8845 } 8846 }, 50); 8847 }); 8848 8849 $scope.submitApplication = function () { 8850 $scope.customAnswers = []; 8851 8852 jQuery('#applicationForm' + ' .customFormItem').each(function () { 8853 $scope.customAnswers.push({ questionId: jQuery(this).attr('data-id'), answer: jQuery(this).val() }); 8854 }); 8855 8856 jQuery('#applicationForm' + ' .checkboxGroup').each(function () { 8857 var vals = []; 8858 var questionId = ""; 8859 8860 jQuery(this).find('.customFormCheckbox').each(function () { 8861 if (jQuery(this).prop('checked')) { 8862 var dataval = jQuery(this).val().split('|'); 8863 questionId = dataval[0]; 8864 vals.push(dataval[1].split(",").join("|")); 8865 } 8866 }); 8867 8868 $scope.customAnswers.push({ questionId: questionId, answer: vals.join(', ') }); 8869 8870 }); 8871 jQuery('#applicationForm' + ' .customFormRadio').each(function () { 8872 if (jQuery(this).prop('checked')) { 8873 var dataval = jQuery(this).val().split('|'); 8874 $scope.customAnswers.push({ questionId: dataval[0], answer: dataval[1] }); 8875 } 8876 }); 8877 8878 $scope.loopfailed = false; 8879 8880 angular.forEach($scope.formdata.sections, function (section) { 8881 angular.forEach(section.questions, function (question) { 8882 if (question.required) { 8883 var failed = true; 8884 8885 8886 if (question.questionControlType == 8) { 8887 if (!question.attachments) { 8888 question.isInvalid = true; 8889 } else { 8890 if (!question.attachments.length) { 8891 question.isInvalid = true; 8892 } else { 8893 8894 var answer = ""; 8895 angular.forEach(question.attachments, function (attachment) { 8896 8897 if (answer != "") { 8898 answer += ","; 8899 } 8900 answer += attachment.uploadedFileId; 8901 }); 8902 8903 $scope.customAnswers.push({ questionId: question.questionId, answer: answer, isUpload: true });
8904 failed = false; 8905 } 8906 } 8907 8908 8909 } else { 8910 8911 angular.forEach($scope.customAnswers, function (answer) { 8912 question.isInvalid = true; 8913 if (answer.questionId == question.questionId && answer.answer.length > 0) { 8914 failed = false; 8915 question.isInvalid = false; 8916 } 8917 }); 8918 if (question.min != null || question.max != null) { 8919 angular.forEach($scope.customAnswers, function (answer) { 8920 if (answer.questionId == question.questionId && answer.answer.length > 0) { 8921 var arr = answer.answer.split(','); 8922 var count = arr.length; 8923 if (question.min != null) { 8924 if (count < question.min) { 8925 question.incorrectMinMax = true; 8926 failed = true; 8927 } 8928 } 8929 if (question.max != null) { 8930 if (count > question.max) { 8931 question.incorrectMinMax = true; 8932 failed = true; 8933 } 8934 8935 } 8936 } 8937 }); 8938 } 8939 } 8940 if (failed) { 8941 $scope.loopfailed = true; 8942 } 8943 } else { 8944 if (question.questionControlType == 8) { 8945 if (!question.attachments) { 8946 //do nothing 8947 } else { 8948 if (!question.attachments.length) { 8949 //do nothing 8950 } else { 8951 8952 var answer = ""; 8953 angular.forEach(question.attachments, function (attachment) { 8954 8955 if (answer != "") { 8956 answer += ","; 8957 } 8958 answer += attachment.uploadedFileId; 8959 }); 8960 8961 $scope.customAnswers.push({ questionId: question.questionId, answer: answer, isUpload: true }); 8962 failed = false; 8963 } 8964 } 8965 8966 8967 } 8968 } 8969 }); 8970 }); 8971 8972 if ($scope.loopfailed) { 8973 $scope.submitAttempt = true; 8974 return; 8975 } 8976 $scope.submitAttempt = false; 8977 8978 $scope.$close($scope.customAnswers); 8979 } 8980 }, 8981 backdrop: 'static', 8982 size: 'lg', 8983 resolve: { 8984 formId: function () { 8985 return $scope.reserveAmenity.formId; 8986 }, 8987 customerId: function () { 8988 return $scope.sitedata.customerId; 8989 }, 8990 amenityReservation: function () { 8991 return $scope.amenityReservation; 8992 }, 8993 } 8994 }).result.then(function (answers) { 8995 $scope.amenityReservation.formData = answers; 8996 }, function () { 8997 8998 }); 8999 } 9000 9001 $scope.$watch('amenityReservation.phone', function (input) { 9002 if (!$scope.amenityReservation) { 9003 return; 9004 } 9005 9006 if ($scope.amenityReservation.phone != null && input != null) { 9007 var cleaned = input.replace(/[^0-9\\.]+/g, ''); 9008 var match = cleaned.match(/^(\d{0,3})(\d{0,3})(\d{0,4})$/) 9009 if (match) { 9010 var formattedPhone = match[1]; 9011 if (match[2].length > 0) { 9012 formattedPhone += '-' + match[2]; 9013 } 9014 if (match[3].length > 0) { 9015 formattedPhone += '-' + match[3]; 9016 } 9017 $scope.amenityReservation.phone = formattedPhone.substr(0, 12); 9018 } 9019 } 9020 }); 9021 9022 $scope.$watch('amenityReservation.zip', function (input) { 9023 if (!$scope.amenityReservation) { 9024 return; 9025 } 9026 9027 if ($scope.amenityReservation.zip != null && input != null) { 9028 $scope.amenityReservation.zip = input.replace(/[^0-9\\.]+/g, ''); 9029 } 9030 }); 9031 9032 $scope.canReserveAmenity = true; 9033 $scope.finalSubmitAttempt = false; 9034 $scope.invalidPayment = false; 9035 $scope.blockSubmit = false; 9036 $scope.completeReservation = function () { 9037 $scope.finalSubmitAttempt = true; 9038 if ($scope.amenityReservation.grandTotal > 0 && !$scope.amenityReservation.anotherMember && $scope.amenityReservation.paymentMethod == null) { 9039 $scope.canReserveAmenity = true; 9040 $scope.invalidPayment = true; 9041 return; 9042 } 9043 $scope.invalidPayment = false; 9044 if ($scope.reserveAmenity.enableDamageFee && !$scope.amenityReservation.anotherMember && !$scope.amenityReservation.damageFeeUnderstood) { 9045 $scope.canReserveAmenity = true; 9046 return; 9047 } 9048 if ($scope.reserveAmenity.isDigitalSignatureRequired && !$scope.amenityReservation.digitalSignature.length) { 9049 $scope.canReserveAmenity = true; 9050 return; 9051 } 9052 9053 $scope.canReserveAmenity = false; 9054 $scope.finalSubmitAttempt = false; 9055 9056 $scope.amenityReservation.amenityId = $scope.reserveAmenity.amenityId; 9057 9058 if ($scope.blockSubmit) { 9059 return; 9060 } 9061 $scope.blockSubmit = true; 9062 9063 grecaptcha.execute('6LeBhgskAAAAAE14Yen7FmvsB0LI-rK5DBohK0GX', { action: 'submit' }).then(function (token) { 9064 $scope.ajaxCall('/Amenity/ReserveAmenity/', { customerId: $scope.sitedata.customerId, amenityData: $scope.amenityReservation }, function (data) { 9065 $scope.canReserveAmenity = true; 9066 $scope.blockSubmit = false; 9067 $scope.amenityTab = "complete"; 9068 }, function () { 9069 $scope.blockSubmit = false; 9070 }); 9071 }); 9072 9073 } 9074 9075 $scope.refreshCalButtons = function (id) { 9076 /*$timeout(function () { 9077 $compile(jQuery(id).contents())($scope); 9078 9079 }, 1000); 9080 */ 9081 } 9082 9083 $scope.adjustHeight = function () { 9084 $timeout(function () { 9085 jQuery(document).ready(function () { 9086 var footerHeight = jQuery('#footerSection').height(); 9087 9088 if (jQuery(window).height() > (jQuery('.templateContainer').height() + footerHeight)) { 9089 jQuery('#footerSection').addClass('customStickyFooter').removeClass('noStickyFooter'); 9090 jQuery('#footerSection').addClass('customStickyFooter').removeClass('noStickyFooter'); 9091 } else { 9092 jQuery('#footerSection').removeClass('customStickyFooter').addClass("noStickyFooter"); 9093 } 9094 9095 $timeout($scope.adjustHeight(), 100); 9096 }); 9097 }, 10); 9098 } 9099 9100 $scope.loadGallery = function (widget) { 9101 if (widget.widgets.length) { 9102 $timeout(function () { 9103 jQuery('#gallery-' + widget.widgetId).each(function () { 9104 jQuery(this).unitegallery({ 9105 gallery_theme: "tilesgrid", 9106 9107 gallery_width: "100%", 9108 9109 tile_enable_textpanel: true, 9110 tile_textpanel_title_text_align: "center", 9111 9112 tile_width: 300, 9113 tile_height: 230, 9114 9115 tiles_min_columns: 3, 9116 tiles_max_columns: 3 9117 }); 9118 }); 9119 }, 50); 9120 } 9121 } 9122 9123 9124 $scope.$watch('amenityReservation.attendees', function (input) { 9125 if (!$scope.amenityReservation) { 9126 return; 9127 } 9128 9129 var max = 99; 9130 9131 if ($scope.reserveAmenity.maxCapacity != null) { 9132 max = $scope.reserveAmenity.maxCapacity; 9133 } 9134 9135 if ($scope.amenityReservation.attendees > max) { 9136 $scope.amenityReservation.attendees = max; 9137 } else if ($scope.amenityReservation.attendees < 0) { 9138 $scope.amenityReservation.attendees = 0; 9139 } 9140 9141 }); 9142 9143 9144 $scope.getDashboardData = function () { 9145 $scope.cardLoaders = { 9146 paymentCard: true, 9147 sponsorCard: true, 9148 newsfeedCard: true, 9149 eventsCard: true, 9150 reservationsCard: true, 9151 formsCard: true, 9152 documentsCard: true, 9153 committeesCard: true, 9154 conversationCard: true, 9155 ticketsCard: true, 9156 violationsCard: true, 9157 } 9158 9159 $scope.ajaxCall('/Customer/GetMemberInfo', { customerId: $scope.sitedata.customerId, userId: AppConstants.CurrentUser.userId, includeAdminOnlyFields: false }, function (data) { 9160 $scope.currentUser = data; 9161 }); 9162 9163 $scope.currentUserHouseholds = []; 9164 $scope.ajaxCall('/Households/GetMemberHouseholds', { customerId: $scope.sitedata.customerId, userId: AppConstants.CurrentUser.userId }, function (data) { 9165 $scope.currentUserHouseholds = data; 9166 }); 9167 9168 $scope.pendingMembers = []; 9169 $scope.recentLogins = []; 9170 9171 $scope.currentUserJoinDate = ''; 9172 $scope.ajaxCall('/Customer/GetCurrentUserJoinDate', { customerId: $scope.sitedata.customerId }, function (data) { 9173 $scope.currentUserJoinDate = data; 9174 }, function (data) { 9175 }, false); 9176 9177 $scope.recentNewsfeed = []; 9178 $scope.newsfeedUrl = "/"; 9179 $scope.getNewsfeedCard = function () { 9180 $scope.ajaxCall('/Sites/GetRecentNewsfeed', { customerId: $scope.sitedata.customerId, showAll: false }, function (data) { 9181 $scope.recentNewsfeed = data; 9182 $scope.cardLoaders.newsfeedCard = false; 9183 }, function () { 9184 $scope.cardLoaders.newsfeedCard = false; 9185 }, false); 9186 $scope.ajaxCall('/Sites/GetNewsfeedUrl', { customerId: $scope.sitedata.customerId }, function (data) { 9187 $scope.newsfeedUrl = data; 9188 }, function () { 9189 9190 }, false); 9191 } 9192 9193 $scope.recentEvents = []; 9194 $scope.upcomingevents = []; 9195 $scope.eventsUrl = "/"; 9196 $scope.getEventsCard = function () { 9197 $scope.ajaxCall('/Event/GetSiteEvents/', { customerId: $scope.sitedata.customerId }, function (data) { 9198 $scope.upcomingevents = data; 9199 9200 $scope.ajaxCall('/Event/GetMyEvents', { customerId: $scope.sitedata.customerId }, function (data) { 9201 $scope.recentEvents = data; 9202 9203 angular.forEach($scope.upcomingevents, function (upcoming) { 9204 upcoming.isRegistered = false; 9205 angular.forEach($scope.recentEvents, function (recent) { 9206 if (upcoming.eventId == recent.eventId) { 9207 upcoming.isRegistered = true; 9208 } 9209 }); 9210 }); 9211 9212 $scope.cardLoaders.eventsCard = false; 9213 }, function () { 9214 $scope.cardLoaders.eventsCard = false; 9215 }, false); 9216 9217 }, function () { 9218 $scope.cardLoaders.eventsCard = false; 9219 }, false); 9220 9221 $scope.ajaxCall('/Sites/GetEventsUrl', { customerId: $scope.sitedata.customerId }, function (data) { 9222 $scope.eventsUrl = data; 9223 }, function () { 9224 9225 }, false); 9226 9227 } 9228 9229 $scope.recentForms = []; 9230 $scope.getFormsCard = function () { 9231 $scope.ajaxCall('/Customer/GetMemberDashboardForms', { customerId: $scope.sitedata.customerId }, function (data) { 9232 $scope.recentForms = data; 9233 $scope.cardLoaders.formsCard = false; 9234 }, function () { 9235 $scope.cardLoaders.formsCard = false; 9236 }, false); 9237 } 9238 9239 $scope.formLazyLoad = 6; 9240 $scope.loadForms = function () { 9241 $scope.formLazyLoad += 4; 9242 } 9243 9244 $scope.pendingTickets = []; 9245 $scope.requestedInfoTickets = []; 9246 9247 $scope.getTicketsCard = function () { 9248 $scope.ajaxCall('/Customer/GetMemberDashboardTickets', { customerId: $scope.sitedata.customerId }, function (data) { 9249 $scope.pendingTickets = data; 9250 $scope.requestedInfoTickets = []; 9251 angular.forEach($scope.pendingTickets, function (ticket) { 9252 if (ticket.status == 4) { 9253 $scope.requestedInfoTickets.push(ticket); 9254 } 9255 }); 9256 $scope.cardLoaders.ticketsCard = false; 9257 }, function () { 9258 $scope.cardLoaders.ticketsCard = false; 9259 }, false); 9260 } 9261 9262 $scope.pendingViolations = []; 9263 9264 $scope.getViolationsCard = function () { 9265 $scope.ajaxCall('/Customer/GetMemberDashboardViolations', { customerId: $scope.sitedata.customerId }, function (data) { 9266 $scope.pendingViolations = data; 9267 $scope.cardLoaders.violationsCard = false; 9268 }, function () { 9269 $scope.cardLoaders.violationsCard = false; 9270 }, false); 9271 } 9272 9273 9274 $scope.recentDocuments = []; 9275 $scope.documentsUrl = '/'; 9276 $scope.getDocumentsCard = function () { 9277 $scope.ajaxCa
9277ll('/Document/GetRecentDocuments', { customerId: $scope.sitedata.customerId }, function (data) { 9278 $scope.recentDocuments = data; 9279 $scope.cardLoaders.documentsCard = false; 9280 }, function () { 9281 $scope.cardLoaders.documentsCard = false; 9282 }, false); 9283 $scope.ajaxCall('/Sites/GetDocumentsUrl', { customerId: $scope.sitedata.customerId }, function (data) { 9284 $scope.documentsUrl = data; 9285 }, function () { 9286 9287 }, false); 9288 } 9289 9290 $scope.myCommittees = []; 9291 $scope.committeesUrl = '/'; 9292 $scope.getCommitteesCard = function () { 9293 $scope.ajaxCall('/Committee/GetMyCommittees/', { customerId: $scope.sitedata.customerId }, function (data) { 9294 $scope.myCommittees = data; 9295 $scope.cardLoaders.committeesCard = false; 9296 9297 }, function () { 9298 9299 }, false); 9300 $scope.ajaxCall('/Sites/GetCommitteesUrl', { customerId: $scope.sitedata.customerId }, function (data) { 9301 $scope.committeesUrl = data; 9302 $scope.cardLoaders.committeesCard = false; 9303 9304 }, function () { 9305 9306 }, false); 9307 } 9308 9309 9310 $scope.sponsors = []; 9311 $scope.getSponsorsCard = function () { 9312 $scope.ajaxCall('/Sponsor/GetMemberSponsorsCard', { customerId: $scope.sitedata.customerId }, function (data) { 9313 $scope.sponsors = data; 9314 $scope.cardLoaders.sponsorCard = false; 9315 }, function () { 9316 $scope.cardLoaders.sponsorCard = false; 9317 }, false); 9318 } 9319 9320 9321 $scope.myamenities = []; 9322 $scope.amenitiesUrl = '/'; 9323 $scope.getReservationsCard = function () { 9324 $scope.ajaxCall('/Amenity/GetMyReservations/', { customerId: $scope.sitedata.customerId }, function (data) { 9325 $scope.myamenities = data; 9326 $scope.cardLoaders.reservationsCard = false; 9327 9328 }, function () { 9329 $scope.cardLoaders.reservationsCard = false; 9330 }, false); 9331 $scope.ajaxCall('/Amenity/GetAmenitiesUrl', { customerId: $scope.sitedata.customerId }, function (data) { 9332 $scope.amenitiesUrl = data; 9333 }, function () { 9334 }, false); 9335 } 9336 9337 $scope.cardMemberDues = []; 9338 $scope.cardDuesUrl = "/"; 9339 $scope.duesDue = 0; 9340 $scope.getPaymentsCard = function () { 9341 $scope.ajaxCall('/Customer/GetMemberDues', { customerId: $scope.sitedata.customerId }, function (data) { 9342 $scope.cardMemberDues = []; 9343 $scope.cardLoaders.paymentCard = false; 9344 9345 angular.forEach(data, function (due) { 9346 if (!due.isPaid) { 9347 if (due.totalprice > 0) { 9348 $scope.duesDue++; 9349 $scope.cardMemberDues.push(due); 9350 } 9351 } 9352 }); 9353 }, function () { 9354 $scope.cardLoaders.paymentCard = false; 9355 }, false); 9356 9357 $scope.ajaxCall('/Customer/GetDuesUrl', { customerId: $scope.sitedata.customerId }, function (data) { 9358 $scope.cardDuesUrl = data; 9359 }, function () { 9360 }, false); 9361 } 9362 9363 $scope.recentConversations = []; 9364 $scope.getConversationsCard = function () { 9365 $scope.ajaxCall('/Customer/GetRecentConversationsCard', { customerId: $scope.sitedata.customerId }, function (data) { 9366 $scope.recentConversations = data; 9367 $scope.cardLoaders.conversationCard = false; 9368 }, function () { 9369 $scope.cardLoaders.conversationCard = false; 9370 }, false); 9371 } 9372 9373 /* Modals Here */ 9374 9375 9376 $scope.viewDashboardEvent = function (event) { 9377 $uibModal.open({ 9378 templateUrl: 'view-event-modal', 9379 size: 'lg', 9380 controller: function ($scope, $timeout, event) { 9381 $scope.event = event; 9382 }, 9383 backdrop: 'static', 9384 resolve: { 9385 event: function () { 9386 return event; 9387 }, 9388 } 9389 }).result.then(function () { 9390 9391 }, function () { 9392 9393 }); 9394 } 9395 9396 $scope.viewDashboardResults = function (formId) { 9397 9398 $uibModal.open({ 9399 templateUrl: 'view-form-results-modal', 9400 controller: function ($scope, $timeout, formId, customerId) { 9401 $scope.customerId = customerId; 9402 $scope.formId = null; 9403 $scope.results = null; 9404 $scope.resultsCount = 0; 9405 $scope.resultsCount = null; 9406 $scope.results = null; 9407 9408 $scope.ajaxCall('/Customer/GetFormResultsWithCount', { customerId: customerId, formId: formId }, function (data) { 9409 $scope.results = data.questions; 9410 $scope.resultsCount = data.submissions; 9411 9412 $scope.formdata = null; 9413 $scope.ajaxCall('/Customer/GetFormSetupPublic', { customerId: $scope.customerId, formId: formId }, function (data) { 9414 $scope.formdata = data; 9415 9416 $scope.index = 0; 9417 angular.forEach($scope.results, function (item) { 9418 9419 google.charts.load('current', { 'packages': ['corechart'] }); 9420 google.charts.setOnLoadCallback(drawChart); 9421 9422 function drawChart() { 9423 var resultArray = [['Question', 'Answered by Students']]; 9424 9425 angular.forEach(item.results, function (result) { 9426 resultArray.push([result.name, result.votes]); 9427 }); 9428 var data = google.visualization.arrayToDataTable(resultArray); 9429 9430 var options = { 9431 title: item.name, 9432 height: 300, 9433 width: "100%", 9434 colors: ['#2946D9', '#68B849', '#C937D3', '#4EBACD', '#E75737'], 9435 fontSize: 12, 9436 fontName: 'Montserrat', 9437 fontWeight: '300', 9438 legend: { position: "right", alignment: "start" }, 9439 chartArea: { left: 20, right: 30 }, 9440 tooltip: { 9441 isHtml: true 9442 } 9443 }; 9444 9445 9446 var chart = new google.visualization.PieChart(document.getElementById('piechart' + $scope.index)); 9447 9448 9449 chart.draw(data, options); 9450 $scope.index++; 9451 9452 } 9453 9454 }); 9455 }); 9456 }); 9457 9458 }, 9459 backdrop: 'static', 9460 size: 'lg', 9461 resolve: { 9462 formId: function () { 9463 return formId; 9464 }, 9465 customerId: function () { 9466 return $scope.sitedata.customerId; 9467 }, 9468 } 9469 }).result.then(function () { 9470 9471 }, function () { 9472 9473 }); 9474 } 9475 } 9476 9477 $scope.submitDashboardForm = function (formId) { 9478 $uibModal.open({ 9479 templateUrl: 'complete-form-modal', 9480 controller: function ($scope, $timeout, formId, customerId) { 9481 $scope.customerId = customerId; 9482 $scope.formId = null; 9483 $scope.formdata = null; 9484 $scope.ajaxCall('/Customer/GetFormSetupPublic', { customerId: $scope.customerId, formId: formId }, function (data) { 9485 $scope.formdata = data; 9486 }); 9487 9488 $scope.initMultipleUpload = function () { 9489 $timeout(function () { 9490 jQuery('.customMultipleUpload').each(function () { 9491 jQuery(this).find('input').prop('multiple', true); 9492 }); 9493 9494 }, 50); 9495 } 9496 9497 $scope.file = null; 9498 9499 $scope.inUpload = false; 9500 $scope.startFileUpload = function (files) { 9501 $scope.inUpload = true; 9502 }; 9503 9504 $scope.successFileUploadCustomMultiple = function (response, field) { 9505 $scope.inUpload = false; 9506 if (response.data.success) { 9507 9508 if (!field.attachments) { 9509 field.attachments = []; 9510 } 9511 angular.forEach(response.data.results, function (result) { 9512 var folderFile = {}; 9513 folderFile.uploadedFileId = result.fileId; 9514 folderFile.sizeInt = result.fileSizeBytes; 9515 folderFile.name = result.fileName; 9516 folderFile.type = result.fileType; 9517 9518 field.attachments.push(folderFile); 9519 }); 9520 } else { 9521 $scope.errorMessage('One or more files exceeds the maximum file size of 15MB.'); 9522 } 9523 }; 9524 9525 $scope.removeFormFile = function (index, field) { 9526 field.attachments.splice(index, 1); 9527 } 9528 9529 $scope.imageSrc = function (fileId) { 9530 if (fileId != null) { 9531 return '/File/Get/' + fileId; 9532 } 9533 return null; 9534 }; 9535 9536 9537 $scope.submitForm = function () { 9538 $scope.customAnswers = []; 9539 9540 jQuery('#applicationForm' + ' .customFormItem').each(function () { 9541 $scope.customAnswers.push({ questionId: jQuery(this).attr('data-id'), answer: jQuery(this).val() }); 9542 }); 9543 9544 jQuery('#applicationForm' + ' .checkboxGroup').each(function () { 9545 var vals = []; 9546 var questionId = ""; 9547 9548 jQuery(this).find('.customFormCheckbox').each(function () { 9549 if (jQuery(this).prop('checked')) { 9550 var dataval = jQuery(this).val().split('|'); 9551 questionId = dataval[0]; 9552 vals.push(dataval[1].split(",").join("|")); 9553 } 9554 }); 9555 9556 $scope.customAnswers.push({ questionId: questionId, answer: vals.join(', ') }); 9557 9558 }); 9559 jQuery('#applicationForm' + ' .customFormRadio').each(function () { 9560 if (jQuery(this).prop('checked')) { 9561 var dataval = jQuery(this).val().split('|'); 9562 $scope.customAnswers.push({ questionId: dataval[0], answer: dataval[1] }); 9563 } 9564 }); 9565 9566 $scope.loopfailed = false; 9567 9568 angular.forEach($scope.formdata.sections, function (section) { 9569 angular.forEach(section.questions, function (question) { 9570 if (question.required) { 9571 var failed = true; 9572 9573 9574 if (question.questionControlType == 8) { 9575 if (!question.attachments) { 9576 question.isInvalid = true; 9577 } else { 9578 if (!question.attachments.length) { 9579 question.isInvalid = true; 9580 } else { 9581 9582 var answer = ""; 9583 angular.forEach(question.attachments, function (attachment) { 9584 9585 if (answer != "") { 9586 answer += ","; 9587 } 9588 answer += attachment.uploadedFileId; 9589 }); 9590 9591 $scope.customAnswers.push({ questionId: question.questionId, answer: answer, isUpload: true });
9592 failed = false; 9593 } 9594 } 9595 9596 9597 } else { 9598 9599 angular.forEach($scope.customAnswers, function (answer) { 9600 question.isInvalid = true; 9601 if (answer.questionId == question.questionId && answer.answer.length > 0) { 9602 failed = false; 9603 question.isInvalid = false; 9604 } 9605 }); 9606 if (question.min != null || question.max != null) { 9607 angular.forEach($scope.customAnswers, function (answer) { 9608 if (answer.questionId == question.questionId && answer.answer.length > 0) { 9609 var arr = answer.answer.split(','); 9610 var count = arr.length; 9611 if (question.min != null) { 9612 if (count < question.min) { 9613 question.incorrectMinMax = true; 9614 failed = true; 9615 } 9616 } 9617 if (question.max != null) { 9618 if (count > question.max) { 9619 question.incorrectMinMax = true; 9620 failed = true; 9621 } 9622 9623 } 9624 } 9625 }); 9626 } 9627 } 9628 if (failed) { 9629 $scope.loopfailed = true; 9630 } 9631 } else { 9632 if (question.questionControlType == 8) { 9633 if (!question.attachments) { 9634 //do nothing 9635 } else { 9636 if (!question.attachments.length) { 9637 //do nothing 9638 } else { 9639 9640 var answer = ""; 9641 angular.forEach(question.attachments, function (attachment) { 9642 9643 if (answer != "") { 9644 answer += ","; 9645 } 9646 answer += attachment.uploadedFileId; 9647 }); 9648 9649 $scope.customAnswers.push({ questionId: question.questionId, answer: answer, isUpload: true }); 9650 failed = false; 9651 } 9652 } 9653 9654 9655 } 9656 } 9657 }); 9658 }); 9659 9660 if ($scope.formdata.isTicketing && !$scope.formdata.subject) { 9661 $scope.loopfailed = true; 9662 } 9663 9664 if ($scope.loopfailed) { 9665 $scope.submitAttempt = true; 9666 return; 9667 } 9668 $scope.submitAttempt = false; 9669 9670 if (!$scope.formdata.subject) { 9671 $scope.formdata.subject = ""; 9672 } 9673 9674 $scope.ajaxCall('/Sites/SubmitDashboardCustomForm', { formId: formId, data: $scope.customAnswers, subject: $scope.formdata.subject }, function (data) {
9675 alert("Thank you for submitting our form. If this warrants a response you will be contacted."); 9676 9677 $scope.$close($scope.customAnswers); 9678 }); 9679 } 9680 }, 9681 backdrop: 'static', 9682 size: 'lg', 9683 resolve: { 9684 formId: function () { 9685 return formId; 9686 }, 9687 customerId: function () { 9688 return $scope.sitedata.customerId; 9689 }, 9690 } 9691 }).result.then(function (answers) { 9692 $scope.getFormsCard(); 9693 }, function () { 9694 9695 }); 9696 } 9697 9698 $scope.loadEventPlaid = function () { 9699 $scope.ajaxCall('/Pricing/GetCustomerPlaidToken', { customerId: $scope.sitedata.customerId }, function (data) { 9700 if (data == "n/a") { 9701 $scope.sitedata.plaidEnabled = false; 9702 9703 } else { 9704 $scope.plaidLoaded = true; 9705 9706 $scope.eventLinkHandler = Plaid.create({ 9707 env: 'production', 9708 clientName: $scope.sitedata.siteName, 9709 token: data, 9710 product: ['auth'], 9711 apiVersion: 'v2', 9712 selectAccount: true, 9713 onSuccess: function (public_token, metadata) { 9714 // Send the public_token and account ID to your app server.
9715 $scope.eventRegistration.plaidtoken = public_token; 9716 $scope.eventRegistration.plaidid = metadata.account_id; 9717 $scope.eventRegistration.plaidLinked = true; 9718 $scope.eventRegistration.plaidInstitution = metadata.institution.name; 9719 $scope.$apply(); 9720 }, 9721 onExit: function (err, metadata) { 9722 // The user exited the Link flow. 9723 if (err != null) { 9724 // The user encountered a Plaid API error prior to exiting. 9725 } 9726 }, 9727 }); 9728 9729 // Trigger the Link UI 9730 document.getElementById('eventLinkButton').onclick = function () { 9731 $scope.eventLinkHandler.open(); 9732 }; 9733 } 9734 9735 }, function () { 9736 $scope.sitedata.plaidEnabled = false; 9737 return; 9738 }, false); 9739 9740 $scope.$apply(); 9741 } 9742 9743 $scope.cancelReservation = function (reservation) { 9744 $uibModal.open({ 9745 templateUrl: 'cancel-reservation-modal', 9746 controller: function ($scope, $timeout, customerId, reservation) { 9747 $scope.customerId = customerId; 9748 console.log(reservation); 9749 console.log($scope.customerId); 9750 9751 $scope.confirm = function () { 9752 $scope.ajaxCall('/Amenity/RequestCancellation', { customerId: $scope.customerId, reservationId: reservation.reservationId }, function (data) { 9753 $scope.$close(); 9754 }); 9755 } 9756 }, 9757 backdrop: 'static', 9758 resolve: { 9759 customerId: function () { 9760 return $scope.sitedata.customerId; 9761 }, 9762 reservation: function () { 9763 return reservation; 9764 }, 9765 } 9766 }).result.then(function () { 9767 $scope.successMessage("Successfully submitted your cancellation request"); 9768 $scope.getMyAmenities(); 9769 }, function () { 9770 9771 }); 9772 } 9773 9774 $scope.loadAmenityPlaid = function () { 9775 $scope.ajaxCall('/Pricing/GetCustomerPlaidToken', { customerId: $scope.sitedata.customerId }, function (data) { 9776 if (data == "n/a") { 9777 $scope.sitedata.plaidEnabled = false; 9778 9779 } else { 9780 $scope.plaidLoaded = true; 9781 9782 $scope.eventLinkHandler = Plaid.create({ 9783 env: 'production', 9784 clientName: $scope.sitedata.siteName, 9785 token: data, 9786 product: ['auth'], 9787 apiVersion: 'v2', 9788 selectAccount: true, 9789 onSuccess: function (public_token, metadata) { 9790 // Send the public_token and account ID to your app server.
9791 $scope.amenityReservation.plaidtoken = public_token; 9792 $scope.amenityReservation.plaidid = metadata.account_id; 9793 $scope.amenityReservation.plaidLinked = true; 9794 $scope.amenityReservation.plaidInstitution = metadata.institution.name; 9795 $scope.$apply(); 9796 }, 9797 onExit: function (err, metadata) { 9798 // The user exited the Link flow. 9799 if (err != null) { 9800 // The user encountered a Plaid API error prior to exiting. 9801 } 9802 }, 9803 }); 9804 9805 // Trigger the Link UI 9806 document.getElementById('amenityLinkButton').onclick = function () { 9807 $scope.eventLinkHandler.open(); 9808 }; 9809 } 9810 9811 }, function () { 9812 $scope.sitedata.plaidEnabled = false; 9813 9814 return; 9815 }, false); 9816 9817 $scope.$apply(); 9818 } 9819 9820 $scope.clearAmenityPlaid = function () { 9821 $scope.amenityReservation.plaidtoken = ''; 9822 $scope.amenityReservation.plaidid = ''; 9823 $scope.amenityReservation.plaidLinked = false; 9824 $scope.amenityReservation.plaidInstitution = ''; 9825 } 9826 9827 $scope.clearEventPlaid = function () { 9828 $scope.eventRegistration.plaidtoken = ''; 9829 $scope.eventRegistration.plaidid = ''; 9830 $scope.eventRegistration.plaidLinked = false; 9831 $scope.eventRegistration.plaidInstitution = ''; 9832 } 9833 9834 $scope.viewUserHouseholds = function () { 9835 $uibModal.open({ 9836 size: 'lg', 9837 templateUrl: 'view-member-households-modal', 9838 controller: function ($scope, $timeout, households) { 9839 $scope.households = households; 9840 }, 9841 backdrop: 'static', 9842 resolve: { 9843 households: function () { 9844 return $scope.currentUserHouseholds; 9845 }, 9846 } 9847 }).result.then(function () { 9848 9849 }, function () { 9850 9851 }); 9852 } 9853 9854 $scope.viewComments = function (submissionId) { 9855 $uibModal.open({ 9856 templateUrl: 'view-comments-modal', 9857 controller: function ($scope, $timeout, submissionId, customerId, userId) { 9858 $scope.customerId = customerId; 9859 $scope.comments = []; 9860 $scope.userId = userId; 9861 $scope.attachments = []; 9862 9863 $scope.getComments = function () { 9864 $scope.ajaxCall('/Customer/GetTicketCommentsMember', { customerId: $scope.customerId, submissionId: submissionId }, function (data) { 9865 $scope.comments = data; 9866 $scope.attachments = []; 9867 9868 angular.forEach($scope.comments, function (comment) { 9869 if (comment.attachments != null && comment.attachments.length) { 9870 angular.forEach(comment.attachments, function (attachment) { 9871 $scope.attachments.push(attachment); 9872 }); 9873 } 9874 }); 9875 9876 $timeout(function () { 9877 var objDiv = document.getElementById("ticketCommentContainer"); 9878 jQuery("#ticketCommentContainer").animate({ scrollTop: objDiv.scrollHeight + 'px' }); 9879 }, 25); 9880 }); 9881 } 9882 $scope.getComments(); 9883 9884 $scope.triggerAccordion = function (questionId) { 9885 var accordion = jQuery('.attachmentCollapse[data-item=' + questionId + ']'); 9886 if (accordion.hasClass('isExpanded')) { 9887 accordion.removeClass('isExpanded').slide
9887Up(); 9888 } else { 9889 accordion.addClass('isExpanded').slideDown(); 9890 } 9891 } 9892 9893 $scope.addComment = function (comment) { 9894 $uibModal.open({ 9895 templateUrl: 'add-comment-modal', 9896 controller: function ($scope, $timeout, submissionId, customerId, comment) { 9897 $scope.customerId = customerId; 9898 $scope.comment = ""; 9899 $scope.adminOnly = false; 9900 $scope.isEdit = false; 9901 $scope.attachments = []; 9902 9903 if (comment != null) { 9904 $scope.comment = comment.message; 9905 $scope.isEdit = true; 9906 9907 $scope.addComment = function () { 9908 $scope.ajaxCall('/Customer/EditTicketCommentMember', { customerId: $scope.customerId, commentId: comment.commentId, comment: $scope.comment }, function (data) { 9909 $scope.$close(); 9910 }); 9911 } 9912 } else { 9913 $scope.addComment = function () { 9914 $scope.ajaxCall('/Customer/AddTicketCommentMember', { customerId: $scope.customerId, submissionId: submissionId, comment: $scope.comment, attachments: $scope.attachments }, function (data) { 9915 $scope.$close(); 9916 }); 9917 } 9918 } 9919 9920 $scope.triggerAccordion = function (questionId) { 9921 var accordion = jQuery('.attachmentCollapse[data-item=' + questionId + ']'); 9922 if (accordion.hasClass('isExpanded')) { 9923 accordion.removeClass('isExpanded').slideUp(); 9924 } else { 9925 accordion.addClass('isExpanded').slideDown(); 9926 } 9927 } 9928 9929 $scope.initMultipleUpload = function () { 9930 $timeout(function () { 9931 jQuery('.customMultipleUpload').each(function () { 9932 jQuery(this).find('input').prop('multiple', true); 9933 }); 9934 9935 }, 50); 9936 } 9937 9938 9939 $scope.file = null; 9940 9941 $scope.inUpload = false; 9942 $scope.startFileUpload = function (files) { 9943 $scope.inUpload = true; 9944 }; 9945 9946 $scope.successFileUploadCustomMultiple = function (response) { 9947 $scope.inUpload = false; 9948 if (response.data.success) { 9949 angular.forEach(response.data.results, function (result) { 9950 var folderFile = {}; 9951 folderFile.uploadedFileId = result.fileId; 9952 folderFile.sizeInt = result.fileSizeBytes; 9953 folderFile.name = result.fileName; 9954 folderFile.type = result.fileType; 9955 9956 $scope.attachments.push(folderFile); 9957 }); 9958 } else { 9959 $scope.errorMessage('One or more files exceeds the maximum file size of 15MB.'); 9960 } 9961 }; 9962 9963 $scope.removeFormFile = function (index) { 9964 $scope.attachments.splice(index, 1); 9965 } 9966 }, 9967 backdrop: 'static', 9968 resolve: { 9969 submissionId: function () { 9970 return submissionId; 9971 }, 9972 customerId: function () { 9973 return $scope.customerId; 9974 }, 9975 comment: function () { 9976 return comment; 9977 }, 9978 } 9979 }).result.then(function () { 9980 $scope.getComments(); 9981 }, function () { 9982 9983 }); 9984 9985 } 9986 9987 9988 9989 $scope.removeComment = function (comment) { 9990 $uibModal.open({ 9991 templateUrl: 'remove-ticket-comment-modal', 9992 controller: function ($scope, $timeout, customerId, comment) { 9993 $scope.customerId = customerId; 9994 $scope.adminOnly = false; 9995 $scope.isEdit = false; 9996 9997 $scope.remove = function () { 9998 $scope.ajaxCall('/Customer/RemoveTicketComment', { customerId: $scope.customerId, commentId: comment.commentId }, function (data) { 9999 $scope.$close(); 10000 }); 10001 } 10002 }, 10003 backdrop: 'static', 10004 resolve: { 10005 customerId: function () { 10006 return $scope.customerId; 10007 }, 10008 comment: function () { 10009 return comment; 10010 }, 10011 } 10012 }).result.then(function () { 10013 $scope.getComments(); 10014 }, function () { 10015 10016 }); 10017 } 10018 }, 10019 backdrop: 'static', 10020 resolve: { 10021 submissionId: function () { 10022 return submissionId; 10023 }, 10024 customerId: function () { 10025 return $scope.sitedata.customerId; 10026 }, 10027 userId: function () { 10028 return $scope.userId;
10029 }, 10030 } 10031 }).result.then(function () { 10032 $scope.doSearchRefresh(); 10033 }, function () { 10034 10035 }); 10036 } 10037 10038 $scope.viewViolation = function (violationId) { 10039 $uibModal.open({ 10040 templateUrl: '/Customer/ViolationDetail', 10041 controller: 'ViolationDetailController', 10042 windowClass: "modal-xxl", 10043 resolve: { 10044 violationId: ['$route', function ($route) { 10045 return violationId; 10046 }], 10047 customerId: ['$route', function ($route) { 10048 return $scope.sitedata.customerId; 10049 }], 10050 customerSlug: ['$route', function ($route) { 10051 return $scope.sitedata.siteSlug; 10052 }], 10053 dismissText: ['$route', function ($route) { 10054 return " back to violations"; 10055 }], 10056 isPublic: ['$route', function ($route) { 10057 return true; 10058 }], 10059 } 10060 }).result.then(function () { 10061 $scope.refreshSearch(); 10062 }, function () { 10063 $scope.refreshSearch(); 10064 //silence is golden 10065 }); 10066 } 10067 10068 $scope.openHouseholdWalletModal = function () { 10069 $uibModal.open({ 10070 size: 'lg', 10071 templateUrl: 'public-site-household-wallet-modal', 10072 controller: function ($scope, $timeout, customerId, userId) { 10073 $scope.customerId = customerId; 10074 $scope.userId = userId; 10075 $scope.listOfHouseholds = []; 10076 10077 $scope.ajaxCall('/Households/GetMemberHouseholds', { customerId: $scope.customerId, userId: $scope.userId }, function (data) { 10078 $scope.listOfHouseholds = data; 10079 for (let i = 0; i < $scope.listOfHouseholds.length; i++) { 10080 $scope.ajaxCall('/Wallet/GetHouseholdWalletBalance', { customerId: $scope.customerId, householdId: $scope.listOfHouseholds[i].householdId, userId: $scope.userId }, function (res) { 10081 $scope.listOfHouseholds[i].balance = res; 10082 }) 10083 } 10084 }); 10085 10086 $scope.openIndividualHouseholdWalletModal = function (household) { 10087 $uibModal.open({ 10088 size: 'lg', 10089 templateUrl: 'public-site-individual-household-wallet-modal', 10090 controller: function ($scope, $timeout, customerId, userId, household) { 10091 $scope.customerId = customerId; 10092 $scope.userId = userId; 10093 $scope.household = household; 10094 $scope.listOfHouseholdTransactions = []; 10095 10096 $scope.ajaxCall('/Wallet/GetPublicHouseholdWalletTransactionList', { customerId: $scope.customerId, userId: $scope.userId, householdId: $scope.household.householdId }, function (data) { 10097 $scope.listOfHouseholdTransactions = data; 10098 }); 10099 10100 }, 10101 backdrop: 'static', 10102 resolve: { 10103 customerId: function () { 10104 return $scope.customerId; 10105 }, 10106 userId: function () { 10107 return $scope.userId; 10108 }, 10109 household: function () { 10110 return household; 10111 } 10112 } 10113 }).result.then(function () { 10114 10115 }, function () { 10116 10117 }); 10118 }; 10119 10120 10121 }, 10122 backdrop: 'static', 10123 resolve: { 10124 customerId: function () { 10125 return $scope.sitedata.customerId; 10126 }, 10127 userId: function () { 10128 return $scope.currentUser.userId;
10129 } 10130 } 10131 }).result.then(function () { 10132 10133 }, function () { 10134 10135 }); 10136 }; 10137 10138 $scope.openMemberWalletModal = function () { 10139 $uibModal.open({ 10140 size: 'lg', 10141 templateUrl: 'public-site-member-wallet-modal', 10142 controller: function ($scope, $timeout, customerId, userId) { 10143 $scope.customerId = customerId; 10144 $scope.userId = userId; 10145 $scope.listOfTransactions = []; 10146 10147 $scope.ajaxCall('/Wallet/GetPublicMemberWalletTransactionList', { customerId: $scope.customerId, userId: $scope.userId }, function (data) { 10148 $scope.listOfTransactions = data; 10149 }); 10150 }, 10151 backdrop: 'static', 10152 resolve: { 10153 customerId: function () { 10154 return $scope.sitedata.customerId; 10155 }, 10156 userId: function () { 10157 return $scope.currentUser.userId; 10158 } 10159 } 10160 }).result.then(function () { 10161 10162 }, function () { 10163 10164 }); 10165 }; 10166 10167 $scope.viewTicket = function (submissionId) { 10168 $uibModal.open({ 10169 size: 'xxl', 10170 templateUrl: 'view-ticket-full-modal', 10171 controller: function ($scope, $timeout, submissionId, customerId, mainScope, currentUser) { 10172 $scope.customerId = customerId; 10173 $scope.formId = null; 10174 $scope.formdata = null; 10175 $scope.submission = null; 10176 $scope.mainScope = mainScope; 10177 $scope.currentUser = currentUser; 10178 $scope.attachments = []; 10179 $scope.comment = ""; 10180 $scope.status = null; 10181 $scope.submissionAttachmentBlocks = []; 10182 10183 $scope.getSubmission = function () { 10184 $scope.ajaxCall('/Customer/GetFormTicketSubmission', { customerId: $scope.customerId, submissionId: submissionId }, function (data) { 10185 $scope.submission = data; 10186 $scope.formId = data.formId; 10187 $scope.submissionAttachmentBlocks = []; 10188 angular.forEach($scope.submission.customAnswers, function (answer) { 10189 if (answer.isUpload) { 10190 var index1 = $scope.submissionAttachmentBlocks.map(function (e) { return e.name; }).indexOf(answer.question); 10191 if (index1 == -1) { 10192 $scope.submissionAttachmentBlocks.push({ name: answer.question, uploads: [] }); 10193 } 10194 10195 index1 = $scope.submissionAttachmentBlocks.map(function (e) { return e.name; }).indexOf(answer.question); 10196 $scope.submissionAttachmentBlocks[index1].uploads.push(answer); 10197 } 10198 }); 10199 10200 switch ($scope.submission.status) { 10201 case 1: 10202 $scope.status = "Pending"; 10203 break; 10204 case 2: 10205 $scope.status = "Approved"; 10206 break; 10207 case 3: 10208 $scope.status = "Rejected"; 10209 break; 10210 case 4: 10211 $scope.status = "Requested Amendment"; 10212 break; 10213 } 10214 }); 10215 } 10216 $scope.getSubmission(); 10217 10218 $scope.comments = []; 10219 $scope.uploads = []; 10220 10221 $scope.getComments = function () { 10222 $scope.ajaxCall('/Customer/GetTicketCommentsMember', { customerId: $scope.customerId, submissionId: submissionId }, function (data) { 10223 $scope.comments = data; 10224 $scope.attachments = []; 10225 angular.forEach($scope.comments, function (comment) { 10226 if (comment.attachments != null && comment.attachments.length) { 10227 angular.forEach(comment.attachments, function (attachment) { 10228 attachment.timestamp = comment.created; 10229 $scope.attachments.push(attachment); 10230 }); 10231 } 10232 }); 10233 10234 $timeout(function () { 10235 var objDiv = document.getElementById("ticketCommentContainer"); 10236 jQuery("#ticketCommentContainer").animate({ scrollTop: objDiv.scrollHeight + 'px' }); 10237 }, 25); 10238 }); 10239 } 10240 $scope.getComments(); 10241 10242 $scope.validationRan = false; 10243 10244 $scope.addComment = function () { 10245 $scope.validationRan = true; 10246 if (!$scope.comment.length) { 10247 return; 10248 } 10249 $scope.validationRan = false; 10250 $scope.ajaxCall('/Customer/AddTicketCommentMember', { customerId: $scope.customerId, submissionId: submissionId, comment: $scope.comment, attachments: $scope.uploads }, function (data) { 10251 $scope.uploads = []; 10252 $scope.comment = ""; 10253 $scope.getComments(); 10254 //$scope.$close(); 10255 }); 10256 } 10257 10258 $scope.resubmit = function () { 10259 $scope.validationRan = true; 10260 if (!$scope.comment.length) { 10261 return; 10262 } 10263 $scope.validationRan = false; 10264 10265 $scope.ajaxCall('/Customer/ResubmitTicket', { customerId: $scope.customerId, submissionId: submissionId, comment: $scope.comment, attachments: $scope.uploads }, function (data) { 10266 $scope.uploads = []; 10267 $scope.comment = ""; 10268 $scope.getComments(); 10269 $scope.getSubmission(); 10270 }); 10271 } 10272 10273 $scope.triggerUpload = function () { 10274 jQuery('.custom-hidden-upload-label-public input').click(); 10275 } 10276 10277 $scope.amendForm = function () { 10278 $scope.$close('amend'); 10279 } 10280 10281 $scope.initMultipleUpload = function () { 10282 $timeout(function () { 10283 jQuery('.customMultipleUpload').each(function () { 10284 jQuery(this).find('input').prop('multiple', true); 10285 }); 10286 10287 }, 50); 10288 } 10289 10290 $scope.file = null; 10291 10292 $scope.inUpload = false; 10293 $scope.startFileUpload = function (files) { 10294 $scope.inUpload = true; 10295 }; 10296 10297 $scope.successFileUploadCustomMultiple = function (response) { 10298 $scope.inUpload = false; 10299 if (response.data.success) { 10300 angular.forEach(response.data.results, function (result) { 10301 var folderFile = {}; 10302 folderFile.uploadedFileId = result.fileId; 10303 folderFile.sizeInt = result.fileSizeBytes; 10304 folderFile.name = result.fileName; 10305 folderFile.type = result.fileType; 10306 10307 $scope.uploads.push(folderFile); 10308 }); 10309 } else { 10310 $scope.errorMessage('One or more files exceeds the maximum file size of 15MB.'); 10311 } 10312 }; 10313 10314 $scope.removeFormFile = function (index) { 10315 $scope.uploads.splice(index, 1); 10316 } 10317 10318 $scope.triggerAccordion = function (questionId) { 10319 var accordion = jQuery('.attachmentCollapse[data-item=' + questionId + ']'); 10320 if (accordion.hasClass('isExpanded')) { 10321 accordion.removeClass('isExpanded').slide
10321Up(); 10322 } else { 10323 accordion.addClass('isExpanded').slideDown(); 10324 } 10325 } 10326 10327 $scope.resolveTicket = function (submissionId) { 10328 $uibModal.open({ 10329 templateUrl: 'approve-ticket-modal', 10330 controller: function ($scope, $timeout, submissionId, customerId) { 10331 $scope.customerId = customerId; 10332 10333 $scope.approve = function () { 10334 $scope.ajaxCall('/Customer/ResolveTicket', { customerId: $scope.customerId, submissionId: submissionId }, function (data) { 10335 $scope.$close(); 10336 }); 10337 } 10338 }, 10339 backdrop: 'static', 10340 resolve: { 10341 submissionId: function () { 10342 return submissionId; 10343 }, 10344 customerId: function () { 10345 return $scope.customerId; 10346 }, 10347 } 10348 }).result.then(function () { 10349 $scope.getSubmission(); 10350 }, function () { 10351 10352 }); 10353 } 10354 10355 $scope.rejectTicket = function (submissionId) { 10356 $uibModal.open({ 10357 templateUrl: 'reject-ticket-modal', 10358 controller: function ($scope, $timeout, submissionId, customerId) { 10359 $scope.customerId = customerId; 10360 10361 $scope.reject = function () { 10362 $scope.ajaxCall('/Customer/RejectTicket', { customerId: $scope.customerId, submissionId: submissionId }, function (data) { 10363 $scope.$close(); 10364 }); 10365 } 10366 }, 10367 backdrop: 'static', 10368 resolve: { 10369 submissionId: function () { 10370 return submissionId; 10371 }, 10372 customerId: function () { 10373 return $scope.customerId; 10374 }, 10375 } 10376 }).result.then(function () { 10377 $scope.getSubmission(); 10378 }, function () { 10379 10380 }); 10381 } 10382 10383 10384 $scope.amendForm = function (submissionId) { 10385 $uibModal.open({ 10386 size: 'lg', 10387 templateUrl: 'amend-form-modal', 10388 controller: function ($scope, $timeout, submissionId, customerId) { 10389 $scope.customerId = customerId; 10390 $scope.formId = null; 10391 $scope.formdata = null; 10392 $scope.submission = null; 10393 10394 $scope.ajaxCall('/Customer/GetFormTicketSubmission', { customerId: $scope.customerId, submissionId: submissionId }, function (data) { 10395 $scope.submission = data; 10396 $scope.formId = data.formId; 10397 10398 $scope.ajaxCall('/Customer/GetFormSetupPublic', { customerId: $scope.customerId, formId: data.formId }, function (data2) { 10399 $scope.formdata = data2; 10400 $timeout(function () { 10401 if ($scope.submission.customAnswers) { 10402 angular.forEach($scope.submission.customAnswers, function (answer) { 10403 if (answer.isUpload) { 10404 var folderFile = {}; 10405 folderFile.uploadedFileId = answer.uploadedFileId; 10406 folderFile.name = answer.uploadName; 10407 10408 angular.forEach($scope.formdata.sections, function (section) { 10409 angular.forEach(section.questions, function (field) { 10410 if (field.questionId == answer.questionId) { 10411 if (!field.attachments) { 10412 field.attachments = []; 10413 } 10414 field.attachments.push(folderFile); 10415 } 10416 }); 10417 }); 10418 } else { 10419 jQuery('.customFormItem').each(function () { 10420 if (jQuery(this).attr('data-id') == answer.questionId) { 10421 jQuery(this).val(answer.answer); 10422 } 10423 }); 10424 10425 var radioval = answer.questionId + '|' + answer.answer; 10426 var split = answer.answer.split(', '); 10427 10428 angular.forEach(split, function (uniqueanswer) { 10429 var checkboxval = answer.questionId + '|' + uniqueanswer; 10430 jQuery('.customFormCheckbox').each(function () { 10431 if (jQuery(this).val() == checkboxval) { 10432 jQuery(this).prop('checked', true); 10433 } 10434 }); 10435 10436 }); 10437 10438 jQuery('.customFormRadio').each(function () { 10439 if (jQuery(this).val() == radioval) { 10440 jQuery(this).prop('checked', true); 10441 } 10442 }); 10443 } 10444 }); 10445 } 10446 }, 50); 10447 }); 10448 }); 10449 10450 $scope.initMultipleUpload = function () { 10451 $timeout(function () { 10452 jQuery('.customMultipleUpload').each(function () { 10453 jQuery(this).find('input').prop('multiple', true); 10454 }); 10455 10456 }, 50); 10457 } 10458 10459 $scope.triggerAccordion = function (questionId) { 10460 var accordion = jQuery('.attachmentCollapse[data-item=' + questionId + ']'); 10461 if (accordion.hasClass('isExpanded')) { 10462 accordion.removeClass('isExpanded').slide
10462Up(); 10463 } else { 10464 accordion.addClass('isExpanded').slideDown(); 10465 } 10466 } 10467 10468 $scope.file = null; 10469 10470 $scope.inUpload = false; 10471 $scope.startFileUpload = function (files) { 10472 $scope.inUpload = true; 10473 }; 10474 10475 $scope.successFileUploadCustomMultiple = function (response, field) { 10476 $scope.inUpload = false; 10477 if (response.data.success) { 10478 10479 if (!field.attachments) { 10480 field.attachments = []; 10481 } 10482 angular.forEach(response.data.results, function (result) { 10483 var folderFile = {}; 10484 folderFile.uploadedFileId = result.fileId; 10485 folderFile.sizeInt = result.fileSizeBytes; 10486 folderFile.name = result.fileName; 10487 folderFile.type = result.fileType; 10488 10489 10490 field.attachments.push(folderFile); 10491 }); 10492 } else { 10493 $scope.errorMessage('One or more files exceeds the maximum file size of 15MB.'); 10494 } 10495 }; 10496 10497 $scope.removeFormFile = function (index, field) { 10498 field.attachments.splice(index, 1); 10499 } 10500 10501 $scope.imageSrc = function (fileId) { 10502 if (fileId != null) { 10503 return '/File/Get/' + fileId; 10504 } 10505 return null; 10506 }; 10507 10508 $scope.submitApplication = function () { 10509 $scope.customAnswers = []; 10510 10511 jQuery('#applicationForm' + ' .customFormItem').each(function () { 10512 $scope.customAnswers.push({ questionId: jQuery(this).attr('data-id'), answer: jQuery(this).val() }); 10513 }); 10514 10515 jQuery('#applicationForm' + ' .checkboxGroup').each(function () { 10516 var vals = []; 10517 var questionId = ""; 10518 10519 jQuery(this).find('.customFormCheckbox').each(function () { 10520 if (jQuery(this).prop('checked')) { 10521 var dataval = jQuery(this).val().split('|'); 10522 questionId = dataval[0]; 10523 vals.push(dataval[1].split(",").join("|")); 10524 } 10525 }); 10526 10527 $scope.customAnswers.push({ questionId: questionId, answer: vals.join(', ') }); 10528 10529 }); 10530 jQuery('#applicationForm' + ' .customFormRadio').each(function () { 10531 if (jQuery(this).prop('checked')) { 10532 var dataval = jQuery(this).val().split('|'); 10533 $scope.customAnswers.push({ questionId: dataval[0], answer: dataval[1] }); 10534 } 10535 }); 10536 10537 $scope.loopfailed = false; 10538 10539 angular.forEach($scope.formdata.sections, function (section) { 10540 angular.forEach(section.questions, function (question) { 10541 if (question.required) { 10542 var failed = true; 10543 10544 if (question.questionControlType == 8) { 10545 if (!question.attachments) { 10546 question.isInvalid = true; 10547 } else { 10548 if (!question.attachments.length) { 10549 question.isInvalid = true; 10550 } else { 10551 10552 var answer = ""; 10553 angular.forEach(question.attachments, function (attachment) { 10554 10555 if (answer != "") { 10556 answer += ","; 10557 } 10558 answer += attachment.uploadedFileId; 10559 }); 10560 10561 $scope.customAnswers.push({ questionId: question.questionId, answer: answer, isUpload: true });
10562 failed = false; 10563 } 10564 } 10565 10566 10567 } else { 10568 10569 angular.forEach($scope.customAnswers, function (answer) { 10570 question.isInvalid = true; 10571 if (answer.questionId == question.questionId && answer.answer.length > 0) { 10572 failed = false; 10573 question.isInvalid = false; 10574 } 10575 }); 10576 if (question.min != null || question.max != null) { 10577 angular.forEach($scope.customAnswers, function (answer) { 10578 if (answer.questionId == question.questionId && answer.answer.length > 0) { 10579 var arr = answer.answer.split(','); 10580 var count = arr.length; 10581 if (question.min != null) { 10582 if (count < question.min) { 10583 question.incorrectMinMax = true; 10584 failed = true; 10585 } 10586 } 10587 if (question.max != null) { 10588 if (count > question.max) { 10589 question.incorrectMinMax = true; 10590 failed = true; 10591 } 10592 10593 } 10594 } 10595 }); 10596 } 10597 } 10598 if (failed) { 10599 $scope.loopfailed = true; 10600 } 10601 } else { 10602 if (question.questionControlType == 8) { 10603 if (!question.attachments) { 10604 //do nothing 10605 } else { 10606 if (!question.attachments.length) { 10607 //do nothing 10608 } else { 10609 10610 var answer = ""; 10611 angular.forEach(question.attachments, function (attachment) { 10612 10613 if (answer != "") { 10614 answer += ","; 10615 } 10616 answer += attachment.uploadedFileId; 10617 }); 10618 10619 $scope.customAnswers.push({ questionId: question.questionId, answer: answer, isUpload: true });
10620 failed = false; 10621 } 10622 } 10623 } 10624 } 10625 }); 10626 }); 10627 10628 if ($scope.loopfailed) { 10629 $scope.submitAttempt = true; 10630 return; 10631 } 10632 $scope.submitAttempt = false; 10633 $scope.submission.customAnswers = $scope.customAnswers; 10634 10635 $scope.ajaxCall('/Customer/AmendFormTicketSubmission', { customerId: $scope.customerId, submission: $scope.submission }, function (data) { 10636 $scope.ajaxCall('/Customer/ResubmitTicket', { customerId: $scope.customerId, submissionId: $scope.submission.submissionId, comment: "" }, function (data) { 10637 $scope.$close(); 10638 }); 10639 }); 10640 10641 } 10642 }, 10643 backdrop: 'static', 10644 resolve: { 10645 submissionId: function () { 10646 return submissionId; 10647 }, 10648 customerId: function () { 10649 return $scope.customerId; 10650 }, 10651 } 10652 }).result.then(function () { 10653 $scope.getSubmission(); 10654 }, function () { 10655 10656 }); 10657 } 10658 10659 }, 10660 backdrop: 'static', 10661 resolve: { 10662 submissionId: function () { 10663 return submissionId; 10664 }, 10665 customerId: function () { 10666 return $scope.sitedata.customerId; 10667 }, 10668 mainScope: function () { 10669 return $scope; 10670 }, 10671 currentUser: function () { 10672 return $scope.currentUser; 10673 } 10674 } 10675 }).result.then(function (data) { 10676 10677 }, function () { 10678 10679 }); 10680 } 10681 10682 $scope.resubmitTicket = function (submissionId) { 10683 $uibModal.open({ 10684 templateUrl: 'resubmit-ticket-modal', 10685 controller: function ($scope, $timeout, submissionId, customerId) { 10686 $scope.customerId = customerId; 10687 $scope.comment = ""; 10688 10689 $scope.sendRequest = function () { 10690 $scope.ajaxCall('/Customer/ResubmitTicket', { customerId: $scope.customerId, submissionId: submissionId, comment: $scope.comment }, function (data) { 10691 $scope.$close(); 10692 }); 10693 } 10694 }, 10695 backdrop: 'static', 10696 resolve: { 10697 submissionId: function () { 10698 return submissionId; 10699 }, 10700 customerId: function () { 10701 return $scope.sitedata.customerId; 10702 }, 10703 } 10704 }).result.then(function () { 10705 $scope.getTicketsCard(); 10706 }, function () { 10707 10708 }); 10709 10710 } 10711 10712 10713 10714 $scope.amendForm = function (submissionId) { 10715 $uibModal.open({ 10716 size: 'lg', 10717 templateUrl: 'amend-form-modal', 10718 controller: function ($scope, $timeout, submissionId, customerId) { 10719 $scope.customerId = customerId; 10720 $scope.formId = null; 10721 $scope.formdata = null; 10722 $scope.submission = null; 10723 10724 $scope.ajaxCall('/Customer/GetFormTicketSubmission', { customerId: $scope.customerId, submissionId: submissionId }, function (data) { 10725 $scope.submission = data; 10726 $scope.formId = data.formId; 10727 10728 $scope.ajaxCall('/Customer/GetFormSetupPublic', { customerId: $scope.customerId, formId: data.formId }, function (data2) { 10729 $scope.formdata = data2; 10730 $timeout(function () { 10731 if ($scope.submission.customAnswers) { 10732 angular.forEach($scope.submission.customAnswers, function (answer) { 10733 if (answer.isUpload) { 10734 var folderFile = {}; 10735 folderFile.uploadedFileId = answer.uploadedFileId; 10736 folderFile.name = answer.uploadName; 10737 10738 angular.forEach($scope.formdata.sections, function (section) { 10739 angular.forEach(section.questions, function (field) { 10740 if (field.questionId == answer.questionId) { 10741 if (!field.attachments) { 10742 field.attachments = []; 10743 } 10744 field.attachments.push(folderFile); 10745 } 10746 }); 10747 }); 10748 } else { 10749 jQuery('.customFormItem').each(function () { 10750 if (jQuery(this).attr('data-id') == answer.questionId) { 10751 jQuery(this).val(answer.answer); 10752 } 10753 }); 10754 10755 var radioval = answer.questionId + '|' + answer.answer; 10756 var split = answer.answer.split(', '); 10757 10758 angular.forEach(split, function (uniqueanswer) { 10759 var checkboxval = answer.questionId + '|' + uniqueanswer; 10760 jQuery('.customFormCheckbox').each(function () { 10761 if (jQuery(this).val() == checkboxval) { 10762 jQuery(this).prop('checked', true); 10763 } 10764 }); 10765 10766 }); 10767 10768 jQuery('.customFormRadio').each(function () { 10769 if (jQuery(this).val() == radioval) { 10770 jQuery(this).prop('checked', true); 10771 } 10772 }); 10773 } 10774 }); 10775 } 10776 }, 50); 10777 }); 10778 }); 10779 10780 $scope.initMultipleUpload = function () { 10781 $timeout(function () { 10782 jQuery('.customMultipleUpload').each(function () { 10783 jQuery(this).find('input').prop('multiple', true); 10784 }); 10785 10786 }, 50); 10787 } 10788 10789 $scope.triggerAccordion = function (questionId) { 10790 var accordion = jQuery('.attachmentCollapse[data-item=' + questionId + ']'); 10791 if (accordion.hasClass('isExpanded')) { 10792 accordion.removeClass('isExpanded').slide
10792Up(); 10793 } else { 10794 accordion.addClass('isExpanded').slideDown(); 10795 } 10796 } 10797 10798 $scope.file = null; 10799 10800 $scope.inUpload = false; 10801 $scope.startFileUpload = function (files) { 10802 $scope.inUpload = true; 10803 }; 10804 10805 $scope.successFileUploadCustomMultiple = function (response, field) { 10806 $scope.inUpload = false; 10807 if (response.data.success) { 10808 10809 if (!field.attachments) { 10810 field.attachments = []; 10811 } 10812 angular.forEach(response.data.results, function (result) { 10813 var folderFile = {}; 10814 folderFile.uploadedFileId = result.fileId; 10815 folderFile.sizeInt = result.fileSizeBytes; 10816 folderFile.name = result.fileName; 10817 folderFile.type = result.fileType; 10818 field.attachments.push(folderFile); 10819 }); 10820 } else { 10821 $scope.errorMessage('One or more files exceeds the maximum file size of 15MB.'); 10822 } 10823 }; 10824 10825 $scope.removeFormFile = function (index, field) { 10826 field.attachments.splice(index, 1); 10827 } 10828 10829 $scope.imageSrc = function (fileId) { 10830 if (fileId != null) { 10831 return '/File/Get/' + fileId; 10832 } 10833 return null; 10834 }; 10835 10836 $scope.submitApplication = function () { 10837 $scope.customAnswers = []; 10838 10839 jQuery('#applicationForm' + ' .customFormItem').each(function () { 10840 $scope.customAnswers.push({ questionId: jQuery(this).attr('data-id'), answer: jQuery(this).val() }); 10841 }); 10842 10843 jQuery('#applicationForm' + ' .checkboxGroup').each(function () { 10844 var vals = []; 10845 var questionId = ""; 10846 10847 jQuery(this).find('.customFormCheckbox').each(function () { 10848 if (jQuery(this).prop('checked')) { 10849 var dataval = jQuery(this).val().split('|'); 10850 questionId = dataval[0]; 10851 vals.push(dataval[1].split(",").join("|")); 10852 } 10853 }); 10854 10855 $scope.customAnswers.push({ questionId: questionId, answer: vals.join(', ') }); 10856 10857 }); 10858 jQuery('#applicationForm' + ' .customFormRadio').each(function () { 10859 if (jQuery(this).prop('checked')) { 10860 var dataval = jQuery(this).val().split('|'); 10861 $scope.customAnswers.push({ questionId: dataval[0], answer: dataval[1] }); 10862 } 10863 }); 10864 10865 $scope.loopfailed = false; 10866 10867 angular.forEach($scope.formdata.sections, function (section) { 10868 angular.forEach(section.questions, function (question) { 10869 if (question.required) { 10870 var failed = true; 10871 10872 10873 if (question.questionControlType == 8) { 10874 if (!question.attachments) { 10875 question.isInvalid = true; 10876 } else { 10877 if (!question.attachments.length) { 10878 question.isInvalid = true; 10879 } else { 10880 10881 var answer = ""; 10882 angular.forEach(question.attachments, function (attachment) { 10883 10884 if (answer != "") { 10885 answer += ","; 10886 } 10887 answer += attachment.uploadedFileId; 10888 }); 10889 10890 $scope.customAnswers.push({ questionId: question.questionId, answer: answer, isUpload: true });
10891 failed = false; 10892 } 10893 } 10894 10895 10896 } else { 10897 10898 angular.forEach($scope.customAnswers, function (answer) { 10899 question.isInvalid = true; 10900 if (answer.questionId == question.questionId && answer.answer.length > 0) { 10901 failed = false; 10902 question.isInvalid = false; 10903 } 10904 }); 10905 if (question.min != null || question.max != null) { 10906 angular.forEach($scope.customAnswers, function (answer) { 10907 if (answer.questionId == question.questionId && answer.answer.length > 0) { 10908 var arr = answer.answer.split(','); 10909 var count = arr.length; 10910 if (question.min != null) { 10911 if (count < question.min) { 10912 question.incorrectMinMax = true; 10913 failed = true; 10914 } 10915 } 10916 if (question.max != null) { 10917 if (count > question.max) { 10918 question.incorrectMinMax = true; 10919 failed = true; 10920 } 10921 10922 } 10923 } 10924 }); 10925 } 10926 } 10927 if (failed) { 10928 $scope.loopfailed = true; 10929 } 10930 } else { 10931 if (question.questionControlType == 8) { 10932 if (!question.attachments) { 10933 //do nothing 10934 } else { 10935 if (!question.attachments.length) { 10936 //do nothing 10937 } else { 10938 10939 var answer = ""; 10940 angular.forEach(question.attachments, function (attachment) { 10941 10942 if (answer != "") { 10943 answer += ","; 10944 } 10945 answer += attachment.uploadedFileId; 10946 }); 10947 10948 $scope.customAnswers.push({ questionId: question.questionId, answer: answer, isUpload: true }); 10949 failed = false; 10950 } 10951 } 10952 } 10953 } 10954 }); 10955 }); 10956 10957 if ($scope.loopfailed) { 10958 $scope.submitAttempt = true; 10959 return; 10960 } 10961 $scope.submitAttempt = false; 10962 $scope.submission.customAnswers = $scope.customAnswers; 10963 10964 $scope.ajaxCall('/Customer/AmendFormTicketSubmission', { customerId: $scope.customerId, submission: $scope.submission }, function (data) { 10965 $scope.$close(); 10966 }); 10967 10968 } 10969 }, 10970 backdrop: 'static', 10971 resolve: { 10972 submissionId: function () { 10973 return submissionId; 10974 }, 10975 customerId: function () { 10976 return $scope.sitedata.customerId; 10977 }, 10978 } 10979 }).result.then(function () { 10980 10981 }, function () { 10982 10983 }); 10984 } 10985 10986 }).directive('backImg', function () { 10987 return function (scope, element, attrs) { 10988 var url = attrs.backImg; 10989 element.css({ 10990 'background-image': 'url(' + url + ')', 10991 'background-size': 'cover' 10992 }); 10993 }; 10994 }).directive('select2SimpleMultiselect', function ($timeout, $compile) { 10995 return { 10996 require: 'ngModel', 10997 link: function (scope, element, $attrs, ngModel) { 10998 $timeout(function () { 10999 $(element).multiselect({ nonSelectedText: 'None', enableFiltering: true, enableCaseInsensitiveFiltering: true });
11000 }, 1); 11001 } 11002 } 11003 }) 11004 ;
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.