PageSourceSearch

https://sbisyd.com.au/eremits/js/front-user.js?v=1790767198

js sbisyd.com.au collected 2026-10-01 23:59:18 UTC 244,627 bytes, 4,837 lines download raw bytes

1var Eremit = {
2    Utility: {
3        getUrl: function (path) {
4            // This condition are added to solve IE issue
5            if (path === undefined) {
6                return window.location.origin;
7            }
8            return window.location.origin + path;
9        },
10        isNumber: function (evt) {
11            evt = (evt) ? evt : window.event;
12            var charCode = (evt.which) ? evt.which : evt.keyCode;
13            if (charCode > 31 && ((charCode < 48 || charCode > 57) && (charCode < 96 || charCode > 105))) {
14                evt.preventDefault();
15            }
16        },
17        onlyAlphaAndSpace: function (element) {
18            if (element) {
19                element.onkeypress = function (event) {
20                    var charCode = (event.which) ? event.which : event.keyCode;
21                    if (charCode > 31 && (charCode < 65 || charCode > 90) && (charCode < 97 || charCode > 122) && charCode != 32) {
22                        event.preventDefault();
23                    }
24                };
25            }
26        },
27        onlyAlphaAndSpaceAndSemicolons: function (element) {
28            if (element) {
29                element.onkeypress = function (event) {
30                    var charCode = (event.which) ? event.which : event.keyCode;
31        
32                    // Allow uppercase letters (65-90), lowercase letters (97-122), space (32), and semicolon (59)
33                    if (
34                        charCode > 31 && 
35                        (charCode < 65 || charCode > 90) && 
36                        (charCode < 97 || charCode > 122) && 
37                        charCode != 32 && 
38                        charCode != 59 // Allow only one ';' at the end
39                    ) {
40                        event.preventDefault();
41                    }
42                };
43        
44                // Restrict multiple semicolons and ensure it's only allowed at the end
45                element.oninput = function () {
46                    var regex = /^[a-zA-Z]+(?: {1,}[a-zA-Z]+)*( ?;?)$/;
47                    if (!regex.test(element.value)) {
48                        // Remove invalid characters
49                        element.value = element.value.replace(/[^a-zA-Z ]+$/, "");
50                    }
51                };
52            }
53        },
54        onlyAlpha: function (element) {
55            if (element) {
56                element.onkeypress = function (event) {
57                    var charCode = (event.which) ? event.which : event.keyCode;
58                    if (charCode >
58 31 && (charCode < 65 || charCode > 90) && (charCode < 97 || charCode > 122)) {
59                        event.preventDefault();
60                    }
61                };
62            }
63        },
64        onlyAlphaNumericSpace: function (element) {
65            if (element) {
66                element.onkeypress = function (event) {
67                    var charCode = (event.which) ? event.which : event.keyCode;
68                    if (charCode > 31 && (charCode < 65 || charCode > 90) && (charCode < 97 || charCode > 122) && (charCode < 48 || charCode > 57) && charCode != 32) {
69                        event.preventDefault();
70                    }
71                };
72            }
73        },
74        onlyAlphaNumeric: function (element) {
75            if (element) {
76                element.onkeypress = function (event) {
77                    var charCode = (event.which) ? event.which : event.keyCode;
78                    if (charCode > 31 && (charCode < 65 || charCode > 90) && (charCode < 97 || charCode > 122) && (charCode < 48 || charCode > 57)) {
79                        event.preventDefault();
80                    }
81                };
82            }
83        },
84        onlyNumeric: function (element) {
85            if (element) {
86                element.onkeypress = function (event) {
87                    var charCode = (event.which) ? event.which : event.keyCode;
88                    if (charCode < 48 || charCode > 57) {
89                        event.preventDefault();
90                    }
91                };
92            }
93        },
94        limitLength: function (element) {
95            if (element) {
96                var limit = element.attributes.limitLength.value;
97                element.onkeypress = function (event) {
98                    var charCode = (event.which) ? event.which : event.keyCode;
99                    if (charCode > 31 && ((charCode >= 48 && charCode <= 57) || (charCode >= 65 && charCode <= 90) || (charCode >= 97 || charCode <= 122))) {
100                        if (this.value.length >= limit) {
101                            return false;
102                        };
103                    }
104                };
105            }
106        },
107        generateRandomText: function () {
108            var result = '';
109            var chars = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
110            var length = 32;
111
112            for (var i = length; i > 0; --i) result += chars[Math.round(Math.random() * (chars.length - 1))];
113            return result;
114        },
115        // Security: escapes untrusted strings before inserting into the DOM.
116        escapeHtml: function (str) {
117            var div = document.createElement('div');
118            div.appendChild(document.createTextNode(str));
119            return div.innerHTML;
120        },
121        // Security: builds a safe DocumentFragment from an array of plain-text
122        // lines, separating them with <br> elements (no raw HTML injection).
123        buildSafeMessageFragment: function (lines) {
124            var frag = document.createDocumentFragment();
125            lines.forEach(function (line, idx) {
126                frag.appendChild(document.createTextNode(line));
127                if (idx < lines.length - 1) {
128                    frag.appendChild(document.createElement('br'));
129                }
130            });
131            return frag;
132        },
133        handleAjaxValidationErorrs: function (XMLHttpRequest, textStatus, errorThrown) {
134            if (XMLHttpRequest.status == 422 || XMLHttpRequest.status == 423) {
135                var errors = XMLHttpRequest.responseJSON.errors;
136                // Security: collect plain-text lines; DOM nodes built safely below
137                var lines = [];
138                $.each(errors, function (key, value) {
139                    lines.push(String(value));
140                });
141                var php_err = $('.container-custom .inner-header').next('.alert-info.alert');
142
143                if (php_err.html() != undefined && php_err.html().length > 0) {
144                    $(php_err).addClass('d-none');
145                }
146
147                var $alert = $('.register-message');
148                if ($alert.length === 0) {
149                    $alert = $('.alert');
150                }
151                $alert.empty();
152                $alert[0].appendChild(Eremit.Utility.buildSafeMessageFragment(lines));
153                $alert.removeClass('d-none').addClass('alert-danger red-font');
154                window.scrollTo(0, 0);
155                if (Eremit.Utility.errorTimeoutId) {
156                    clearTimeout(Eremit.Utility.errorTimeoutId);
157                }
158                Eremit.Utility.errorTimeoutId = setTimeout(function () {
159                    $alert.empty();
160                    $alert.removeClass('alert-danger red-font').addClass('d-none');
161                }, 7000);
162            }
163        },
164        handleAjaxValidationErorrsModal: function (XMLHttpRequest, textStatus, errorThrown) {
165            if (XMLHttpRequest.status == 422 || XMLHttpRequest.status == 423) {
166                var errors = XMLHttpRequest.responseJSON;
167                // Security: collect plain-text lines; DOM nodes built safely below
168                var lines = [];
169                $.each(errors.errors, function (key, value) {
170                    lines.push(String(value[0]));
171                });
172                var $modalAlert = $('.modal-body .alert');
173                $modalAlert.empty();
174                $modalAlert[0].appendChild(Eremit.Utility.buildSafeMessageFragment(lines));
175                $modalAlert.removeClass('d-none');
176                window.scrollTo(0, 0);
177                if (Eremit.Utility.modalErrorTimeoutId) {
178                    clearTimeout(Eremit.Utility.modalErrorTimeoutId);
179                }
180                Eremit.Utility.modalErrorTimeoutId = setTimeout(function () {
181                    $modalAlert.empty();
182                    $modalAlert.addClass('d-none');
183                }, 7000);
184            }
185        },
186        handleUserDefineSuccess: function (message) {
187            // Security: use .text() to prevent XSS from message content
188            var $alert = $('.register-message');
189            if ($alert.length === 0) {
190                $alert = $('.alert');
191            }
192            $alert.addClass('black-font').removeClass('red-font d-none');
193            $alert.text(message);
194            window.scrollTo(0, 0);
195            if (Eremit.Utility.errorTimeoutId) {
196                clearTimeout(Eremit.Utility.errorTimeoutId);
197            }
198            Eremit.Utility.errorTimeoutId = setTimeout(function () {
199                $alert.empty().addClass('d-none red-font').removeClass('black-font');
200            }, 7000);
201        },
202        handleUserDefineSuccessModal: function (message) {
203            // Security: use .text() to prevent XSS from message content
204            var $modalAlert = $('.modal-body .alert');
205            $modalAlert.addClass('black-font alert-success').removeClass('red-font alert-danger d-none');
206            $modalAlert.text(message);
207            window.scrollTo(0, 0);
208            if (Eremit.Utility.modalErrorTimeoutId) {
209                clearTimeout(Eremit.Utility.modalErrorTimeoutId);
210            }
211            Eremit.Utility.modalErrorTimeoutId = setTimeout(function () {
212                $modalAlert.empty().addClass('d-none red-font').removeClass('black-font');
213            }, 7000);
214        },
215        handleUserDefineErrorModal: function (message) {
216            // Security: use .text() to prevent XSS from message content
217            var $modalAlert = $('.modal-body .alert');
218            $modalAlert.removeClass('d-none');
219            $modalAlert.text(message);
220            window.scrollTo(0, 0);
221            if (Eremit.Utility.modalErrorTimeoutId) {
222                clearTimeout(Eremit.Utility.modalErrorTimeoutId);
223            }
224            Eremit.Utility.modalErrorTimeoutId = setTimeout(function () {
225                $modalAlert.empty().addClass('d-none');
226            }, 7000);
227        },
228        handleUserDefineError: function (message, cssClass) {
229            var php_err = $('.container-custom .inner-header').next('.alert-info.alert');
230
231            if (php_err.html() != undefined && php_err.html().length > 0) {
232                $(php_err).addClass('d-none');
233            }
234            // Security: use .text() to prevent XSS from message content.
235            // Optional cssClass applies styling to the container, not the message string.
236            var $regMsg = $('.register-message');
237            $regMsg.removeClass('d-none');
238            $regMsg.text(message);
239            if (cssClass) {
240                $regMsg.addClass(cssClass);
241            }
242            window.scrollTo(0, 0);
243            if (Eremit.Utility.errorTimeoutId) {
244                clearTimeout(Eremit.Utility.errorTimeoutId);
245            }
246            Eremit.Utility.errorTimeoutId = setTimeout(function () {
247                if (cssClass) {
248                    $regMsg.removeClass(cssClass);
249                }
250                $regMsg.empty().addClass('d-none');
251            }, 7000);
252        },
253        handleSettingEvent: function () {
254            CustomeWebUiInterface.handleSettingEvent();
255        },
256        handleLogoutEvent: function () {
257            var logoutURL = window.location.origin + "/eremit/logout"
258            $.get(logoutURL, function (data) { });
259            CustomeWebUiInterface.handleLogoutEvent();
260        },
261        handleLogout: function () {
262            var logoutURL = window.location.origin + "/eremit/logout"
263            $.get(logoutURL, function (data) { });
264        },
265        repeatString: function (string, times) {
266            // Check if times is negative and return an empty string if true
267            if (times < 0) {
268                return "";
269            }
270            // Check if times equals to 1 and return the string itself if it's the case.
271            if (times === 1) {
272                return string;
273            }
274            // Use recursion
275            else {
276                return string + Eremit.Utility.repeatString(string, times - 1); // return "abcabcabc";
277            }
278        },
279        formatCurrencyAmount: function (amount) {
280            return (amount || 0).toString().replace(/(\d)(?=(\d{3})+(?!\d))/g, "$1,");
281        },
282        parseCurrency: function (amount) {
283            return (amount || '0').replace(/,/g, '');
284        },
285        debounce: function (func, wait, immediate) {
286            var timeout;
287            return function () {
288                var context = this,
289                    args = arguments;
290                var later = function () {
291                    timeout = null;
292                    if (!immediate) func.apply(context, args);
293                };
294                var callNow = immediate && !timeout;
295                clearTimeout(timeout);
296                timeout = setTimeout(later, wait);
297                if (callNow) func.apply(context, args);
298            };
299        },
300        CryptoJSAesEncrypt: function (passphrase, plain_text) {
301
302            var salt = CryptoJS.lib.WordArray.random(256);
303            var iv = CryptoJS.lib.WordArray.random(16);
304            //for more random entropy can use : https://github.com/wwwtyro/cryptico/blob/master/random.js instead CryptoJS random() or another js PRNG
305
306            var key = CryptoJS.PBKDF2(passphrase, salt, { hasher: CryptoJS.algo.SHA512, keySize: 64 / 8, iterations: 999 });
307
308            var encrypted = CryptoJS.AES.encrypt(plain_text, key, { iv: iv });
309
310            var data = {
311                ciphertext: CryptoJS.enc.Base64.stringify(encrypted.ciphertext),
312                salt: CryptoJS.enc.Hex.stringify(salt),
313                iv: CryptoJS.enc.Hex.stringify(iv)
314            }
315
316            return JSON.stringify(data);
317        }
318
319    },
320    Datepicker: {
321        init: function () {
322            $(".logindatepicker").dateDropdowns({
323                defaultDate: null,
324                defaultDateFormat: "dd-mm-yyyy",
325                submitFormat: "yyyy-mm-dd",
326                monthFormat: "short",
327                daySuffixes: false,
328                required: true,
329                dropdownClass: "form-select",
330                wrapperClass: "d-flex justify-content-between"
331            });
332            $(".eremitdatepicker").dateDropdowns({
333                defaultDate: null,
334                defaultDateFormat: "dd-mm-yyyy",
335                submitFormat: "yyyy-mm-dd",
336                monthFormat: "short",
337                daySuffixes: false,
338                required: true,
339                dropdownClass: "form-select",
340                wrapperClass: "d-flex justify-content-between"
341            });
342        }
343    },
344    Validate: {
345        init: {
346            errorClass: 'validation-invalid-label',
347            highlight: function (element, errorClass) {
348                $("#Int_BIC_Code-error").removeAttr('style');
349                $("#Int_BIC_Code-error").removeClass('d-none');
350                $(element).removeClass(errorClass);
351            },
352            unhighlight: function (element, errorClass) {
353                $("#Int_BIC_Code-error").removeAttr('style');
354                $("#Int_BIC_Code-error").removeClass('d-none');
355                $(element).removeClass(errorClass);
356            },
357            errorPlacement: function (error, element) {
358                // Unstyled checkboxes, radios
359                if (element.parents().hasClass('form-check')) {
360                    error.appendTo(element.parents('.form-check').parent());
361                }
362                // Input with icons and Select2
363                else if (element.parents().hasClass('form-group-feedback') || element.hasClass('select2-hidden-accessible')) {
364                    error.appendTo(element.parent());
365                }
366                else if (element.hasClass("readonly-inp")) {
367                    return true;
368                }
369                // Input group, styled file input
370                else if (element.parent().is('.uniform-uploader, .uniform-select') || element.parents().hasClass('input-group')) {
371                    error.appendTo(element.parent().parent());
372                }
373                // Other elements
374                else {
375                    error.insertAfter(element);
376                }
377            },
378            validateError: function (error, element) {
379                $('.register-message').removeClass('d-none');
380                $('.register-message').text(error);
381                setTimeout(function () {
382                    $('.register-message').text('');
383                    $('.register-message').addClass('d-none');
384                }, 7000);
385            },
386            loginValidateError: function (error, element) {
387                error.appendTo(element.parent().parent().parent());
388            },
389        },
390        Login: function (event) {
391            var Rules = Eremit.Validate.init;
392            var $validator = $(".form-validate-jquery").validate({
393                errorClass: Rules.errorClass,
394                highlight: Rules.highlight,
395                unhighlight: Rules.unhighlight,
396                errorPlacement: Rules.loginValidateError,
397                groups: {
398                    DOB: "date_[day] date_[month] date_[year]"
399                },
400                rules: {
401                    vali: "required",
402                    Customer_ID: {
403                        required: true,
404                        exactlength: 9,
405                        numbers: true,
406                    },
407                    Password: {
408                        required: true,
409                    },
410                    DOB: {
411                        required: true,
412                    },
413                },
414                messages: {
415                    'Customer_ID': {
416                        numbers: "Please enter only numbers.",
417                    },
418                    'DOB': {
419                        required: "This fields are required.",
420                    }
421                }
422            });
423            Eremit.Validate.$validator = $validator;
424        },
425        DeleteBeneficiaries: function (event) {
426            var Rules = Eremit.Validate.init;
427            var $validator = $(".form-validate-jquery").validate({
428                errorClass: Rules.errorClass,
429                highlight: Rules.highlight,
430                unhighlight: Rules.unhighlight,
431                errorPlacement: Rules.validateError,
432                rules: {
433                    vali: "required",
434                    'delete[]': {
435                        required: true
436                    }
437                },
438                messages: {
439                    'delete[]': {
440                        required: "Please select atleast one beneficiary"
441                    }
442                }
443            });
444        },
445        searchIfscCodes: function (event) {
446            var Rules = Eremit.Validate.init;
447            var $searchIfscCodesvalidator = $(".searchifsccodes").validate({
448                errorClass: Rules.errorClass,
449                highlight: Rules.highlight,
450                unhighlight: Rules.unhighlight,
451                errorPlacement: Rules.errorPlacement,
452                rules: {
453                    vali: "required",
454                    bank_names: {
455                        required: true
456                    }
457                },
458            });
459            Eremit.Validate.$searchIfscCodesvalidator = $searchIfscCodesvalidator;
460        },
461        searchBicCodes: function (event) {
462            var Rules = Eremit.Validate.init;
463            var $searchBicCodesvalidator = $(".searchbiccodes").validate({
464                errorClass: Rules.errorClass,
465                highlight: Rules.highlight,
466                unhighlight: Rules.unhighlight,
467                errorPlacement: Rules.errorPlacement,
468                rules: {
469                    vali: "required",
470                    bank_names: {
471                        required: true
472                    }
473                },
474            });
475            Eremit.Validate.$searchBicCodesvalidator = $searchBicCodesvalidator;
476        },
477        searchIntBicCodes: function (event) {
478            var Rules = Eremit.Validate.init;
479            var $searchIntBicCodesvalidator = $(".searchintbiccodes").validate({
480                errorClass: Rules.errorClass,
481                highlight: Rules.highlight,
482                unhighlight: Rules.unhighlight,
483                errorPlacement: Rules.errorPlacement,
484                rules: {
485                    vali: "required",
486                    int_bank_names: {
487                        required: true
488                    },
489                    int_bic_code_radio_button: {
490                        notEqual: "#bic_code_radio_button",
491                    }
492                },
493            });
494            Eremit.Validate.$searchIntBicCodesvalidator = $searchIntBicCodesvalidator;
495        },
496        AddBeneficiaries: function (event) {
497            $("#Int_BIC_Code-error").removeAttr('style');
498            $("#BIC_Code-error").removeAttr('style');
499            $("#IFSC_Code-error").removeAttr('style');
500            jQuery.validator.addMethod("alphanumericwithspace", function (value, element) {
501                return this.optional(element) || /^[0-9a-zA-Z ]*$/i.test(value);
502            }, "This field must be alphanumeric and space.");
503
504            jQuery.validator.addMethod("numericonly", function (value, element) {
505                return this.optional(element) || /^[1-9][0-9]{5}$/i.test(value);
506            }, "Indian Postcode must be 6 digit long and should not start with 0.");
507
508            jQuery.validator.addMethod("alphanumeric", function (value, element) {
509                return this.optional(element) || /^[0-9a-zA-Z]*$/i.test(value);
510            }, "This field must be alphanumeric.");
511
512            // jQuery.validator.addMethod("alphaspace", function (value, element) {
513            //     return this.optional(element) || /^[a-zA-Z ]*$/i.test(value);
514            // }, "This field must be contain alphabet and space.");
515
516            jQuery.validator.addMethod("alphaspace", function (value, element) {
517                // return this.optional(element) || /^[a-zA-Z]+(?: [a-zA-Z]+)*( ?;?)$/i.test(value);
518                return this.optional(element) || /^[a-zA-Z]+(?: {1,}[a-zA-Z]+)*( ?;?)$/i.test(value);
519            }, "This field must be contain alphabet and space");
520
521            jQuery.validator.addMethod("alphanumericOrNumeric", function (value, element) {
522                if (moduleConfig.routingIbanLbl == 'bsb') {
523                    return this.optional(element) || /^[0-9]*$/i.test(value);
524                } else {
525                    return this.optional(element) || /^[0-9a-zA-Z]*$/i.test(value);
526                }
527            }, "This field must be alphanumeric.");
528
529            var validationRules = {
530                vali: "required",
531                Post_Code: {
532                    maxlength: ((moduleConfig.selectedCurrency == 'inr' || moduleConfig.selectedCurrency == 'aud') ? 6 : 9),
533                    numericonly: ((moduleConfig.selectedCurrency == 'inr' || moduleConfig.selectedCurrency == 'aud') ? true : false)
534                },
535                IFSC_Code: {
536                    exactlength: 11,
537                    required: true,
538                },
539                Beneficiary_Name: {
540                    required: true,
541                    alphaspace: true,
542                    maxlength: 255,
543                },
544                Address_1: {
545                    required: true,
546                    alphanumericwithspace: true,
547                    maxlength: 255,
548                    validaddress: true
549                },
550                Address_2: {
551                    required: false,
552                    alphanumericwithspace: true,
553                    maxlength: 255,
554                    validaddress: true
555                },
556                City: {
557                    required: true,
558                    alphanumericwithspace: ((moduleConfig.selectedCurrency == 'inr' || moduleConfig.selectedCurrency == 'aud') ? false : true),
559                    maxlength: 255,
560                },
561                State: {
562                    required: true,
563                    alphanumericwithspace: ((moduleConfig.selectedCurrency == 'inr' || moduleConfig.selectedCurrency == 'aud') ? false : true),
564                    maxlength: 255,
565                },
566                Country: {
567                    required: true,
568                    maxlength: 255,
569                },
570                Account_Number: {
571                    required: true,
572                    alphanumeric: true,
573                    minlength: 5,
574                    maxlength: 33,
575                },
576                Confirm_Account_No: {
577                    required: true,
578                    minlength: 5,
579                    maxlength: 33,
580                    alphanumeric: true,
581                    equalTo: "#Account_No"
582                },
583                IFSC_Code: {
584                    remote: {
585                        url: moduleConfig.VerifyIFSCCodeUrl,
586                        type: "post",
587                        data: {
588                            term: function () { return $('#IFSC_Code').val(); }
589                        }
590                    }
591                },
592                BIC_Code: {
593                    remote: {
594                        url: moduleConfig.VerifyBicCodeUrl,
595                        type: "post",
596                        data: {
597                            term: function () { return $('#BIC_Code').val(); },
598                            biccode: true,
599                        }
600                    }
601                },
602                BBIC_Code: {
603                    exactlength: 11,
604                    alphanumeric: true,
605                },
606                /*routing_iban: {
607                    maxlength: (moduleConfig.routingIbanLbl == 'bsb')? 6:40,
608                    alphanumericOrNumeric: true,
609                },*/
610                Int_BIC_Code: {
611                    notEqual: "#BBIC_Code",
612                    checkCountry: {
613                        'country': moduleConfig.countryArray
614                    }
615                }
616            };
617            if (window.location.href.indexOf("inr") > -1) {
618                validationRules.Account_Number.minlength = 5;
619                validationRules.Confirm_Account_No.minlength = 5;
620            }
621            var Rules = Eremit.Validate.init;
622            var $AddBeneficiaries = $(".form-validate-jquery").validate({
623                errorClass: Rules.errorClass,
624                highlight: Rules.highlight,
625                unhighlight: Rules.unhighlight,
626                errorPlacement: Rules.errorPlacement,
627                normalizer: function (value) {
628                    // Trim the value of every element
629                    return String(value).trim();
630                },
631                rules: validationRules,
632                messages: {
633                    /* 'routing_iban': {
634                         maxlength: (moduleConfig.routingIbanLbl == 'bsb')? "More than 6 digits are not allowed": "More than 40 characters are not allowed",
635                         alphanumericOrNumeric: (moduleConfig.routingIbanLbl == 'bsb')? "This field must be numeric.": "This field must be alphanumeric.",
636                     },*/
637                    'IFSC_Code': {
638                        remote: "Please enter valid IFS code.",
639                    },
640                    'BIC_Code': {
641                        remote: "Please enter the valid BIC code.",
642                    },
643                    'Int_BIC_Code': {
644                        remote: "Plaese enter valid Intermediate BIC Country",
645                    }
646                }
647            });
648            Eremit.Validate.$AddBeneficiaries = $AddBeneficiaries;
649        },
650        ChangePassword: function (event) {
651            var Rules = Eremit.Validate.init;
652            var $ChangePassword = $(".form-validate-jquery").validate({
653                errorClass: Rules.errorClass,
654                highlight: Rules.highlight,
655                unhighlight: Rules.unhighlight,
656                errorPlacement: Rules.errorPlacement,
657                rules: {
658                    vali: "required",
659                    Password: {
660                        required: true,
661                        minlength: 8,
662                    },
663                    confirm_password: {
664                        required: true,
665                        minlength: 8,
666                        equalTo: "#Password"
667                    }
668                },
669            });
670            Eremit.Validate.$ChangePassword = $ChangePassword;
671        },
672        TwoFactorAuthentication: function (event) {
673            var Rules = Eremit.Validate.init;
674            var $verification = $(".form-validate-jquery").validate({
675                errorClass: Rules.errorClass,
676                highlight: Rules.highlight,
677                unhighlight: Rules.unhighlight,
678                errorPlacement: Rules.errorPlacement,
679                rules: {
680                    vali: "required",
681                    verification_code: {
682                        required: true,
683                        minlength: 6,
684                        exactlength: 6,
685                    }
686                },
687                messages: {
688                    'verification_code': {
689                        required: 'Please enter the verification code.'
690                    }
691                }
692            });
693            Eremit.Validate.$verification = $verification;
694        },
695        UpdateEmail: function (event) {
696            var Rules = Eremit.Validate.init;
697            var $UpdateEmail = $("#updateemail").validate({
698                errorClass: Rules.errorClass,
699                highlight: Rules.highlight,
700                unhighlight: Rules.unhighlight,
701                errorPlacement: Rules.errorPlacement,
702                rules: {
703                    vali: "required",
704                    new_email: {
705                        required: true,
706                        email: true
707                    },
708                },
709            });
710            Eremit.Validate.$UpdateEmail = $UpdateEmail;
711        },
712        UpdateMobile: function (event) {
713            var Rules = Eremit.Validate.init;
714            var $UpdateMobile = $("#updatemobile").validate({
715                errorClass: Rules.errorClass,
716                highlight: Rules.highlight,
717                unhighlight: Rules.unhighlight,
718                errorPlacement: Rules.errorPlacement,
719                rules: {
720                    vali: "required",
721                    country_mobile_code: {
722                        required: true,
723                    },
724                    new_mobile: {
725                        required: true,
726                    },
727                    mobile_otp: {
728                        required: true,
729                    }
730                },
731            });
732            Eremit.Validate.$UpdateMobile = $UpdateMobile;
733        },
734        UpdatePassword: function (event) {
735            var Rules = Eremit.Validate.init;
736            var $UpdatePassword = $("#updatepassword").validate({
737                errorClass: Rules.errorClass,
738                highlight: Rules.highlight,
739                unhighlight: Rules.unhighlight,
740                errorPlacement: Rules.errorPlacement,
741                rules: {
742                    vali: "required",
743                    current_password: {
744                        required: true
745                    },
746                    new_password: {
747                        required: true,
748                        minlength: 8,
749                    },
750                    confirm_new_password: {
751                        required: true,
752                        minlength: 8,
753                        equalTo: "#new_password"
754                    }
755                },
756            });
757            Eremit.Validate.$UpdatePassword = $UpdatePassword;
758            var $UpdateSecurity = $("#updatesecurity").validate({
759                errorClass: Rules.errorClass,
760                highlight: Rules.highlight,
761                unhighlight: Rules.unhighlight,
762                errorPlacement: Rules.errorPlacement,
763                rules: {
764                    vali: "required",
765                    Security_Question: {
766                        required: true,
767                    },
768                    Security_Answer: {
769                        required: true,
770                    },
771                    current_password: {
772                        required: true
773                    }
774                },
775            });
776            Eremit.Validate.$UpdateSecurity = $UpdateSecurity;
777        },
778        UpdateAddress: function (event) {
779            var Rules = Eremit.Validate.init;
780            var $UpdateAddress = $("#updateaddress").validate({
781                errorClass: Rules.errorClass,
782                highlight: Rules.highlight,
783                unhighlight: Rules.unhighlight,
784                errorPlacement: Rules.errorPlacement,
785                rules: {
786                    vali: "required",
787                    state: {
788                        required: true,
789                    },
790                    postcode: {
791                        required: true,
792                    },
793                    suburb: {
794                        required: true,
795                    },
796                },
797            });
798            Eremit.Validate.$UpdateAddress = $UpdateAddress;
799        },
800        UpdateProfileDetailsPopup: function (event) {
801            var Rules = Eremit.Validate.init;
802            var $validator = $("#eremit-update-limited-profile-form").validate({
803                errorClass: Rules.errorClass,
804                highlight: Rules.highlight,
805                unhighlight: Rules.unhighlight,
806                errorPlacement: Rules.loginValidateError,
807                rules: {
808                    vali: "required",
809                    employment_status: {
810                        required: true
811                    },
812                    income_type: {
813                        required: true
814                    },
815                    country_of_birth: {
816                        required: true
817                    },
818                },
819                messages: {
820                }
821            });
822            Eremit.Validate.$validator = $validator;
823        },
824        UpdateProfileDetailsPopupLimited: function (event) {
825
826            jQuery.validator.addMethod("alphanumeric", function (value, element) {
827                return this.optional(element) || /^[\w.]+$/i.test(value);
828            }, "The username can only  contain  alphanumeric characters, underscore (_) or period(.) .");
829
830
831            var Rules = Eremit.Validate.init;
832            var $validator = $("#eremit-update-limited-profile-form").validate({
833                errorClass: Rules.errorClass,
834                highlight: Rules.highlight,
835                unhighlight: Rules.unhighlight,
836                errorPlacement: Rules.loginValidateError,
837                rules: {
838                    vali: "required",
839                    user_id: {
840                        alphanumeric: true,
841                        minlength: 6,
842                        maxlength: 20,
843                    },
844                    resident_status: {
845                        required: true
846                    },
847                },
848                messages: {
849                }
850            });
851            Eremit.Validate.$validator = $validator;
852        },
853        MultiBenefForm: function (event) {
854            var Rules = Eremit.Validate.init;
855            var $validator = $("#multibenef-form").validate({
856                errorClass: Rules.errorClass,
857                highlight: Rules.highlight,
858                unhighlight: Rules.unhighlight,
859                errorPlacement: Rules.errorPlacement,
860                rules: {
861                    "purpose_of_transfer": "required",
862                    "source_of_fund": "required",
863                    "multibenef[]": "required",
864                    "inp_amt_aud[]": {
865                        required: true,
866                        min: 0.1
867                    },
868                    "inp_amt_inr[]": {
869                        required: true,
870                        min: 0.1
871                    },
872                    ignoreTitle: ['.readonly-inp'],
873                },
874                messages: {
875                    "purpose_of_transfer": "Please choose Purpose of Transfer",
876                    "source_of_fund": "Please choose Source of Funds",
877                    "multibenef[]": "Please choose a Beneficiary",
878                    "inp_amt_aud[]": "Please enter AUD Amount",
879                    "inp_amt_inr[]": "Please enter INR Amount",
880                }
881            });
882
883            Eremit.Validate.$validator = $validator;
884
885            /* if ($('#multibenef-form').valid() == false) {
886                console.log('valid false')
887                //$('#multibenef-form-corporate-offer-modal').modal('hide');
888                // return false;
889            } */
890        }
891    },
892    Login: {
893        init: function (event, formdata) {
894            if (formdata === undefined) {
895                formdata = null;
896            }
897            var $valid = $("#eremit-login-form").valid();
898            if (!$valid) {
899                Eremit.Validate.$validator.focusInvalid();
900                return false;
901            } else {
902
903                var captchResponse = grecaptcha.getResponse();
904                // if (captchResponse.length == 0) {
905                //     document.getElementById('g-recaptcha-error').innerHTML = '<span style="color:red;">Please verify that you are not a robot.</span>';
906                //     return false;
907                // }
908
909                $('#loadingDiv').removeClass('d-none');
910
911                if (formdata === null) {
912                    var data = new FormData($('#eremit-login-form')[0]);
913                } else {
914                    var data = formdata;
915                }
916
917                event.preventDefault();
918
919                var transmitCustomerID = data.Customer_ID;
920
921                window.tsPlatform.drs.setAuthenticatedUser(transmitCustomerID);
922
923                var encodedCustomer_ID = Eremit.Login.CryptoJSAesEncrypt(moduleConfig.salt, data.Customer_ID);
924                data.Customer_ID = window.btoa(encodedCustomer_ID);
925
926                var encodedPassword = Eremit.Login.CryptoJSAesEncrypt(moduleConfig.salt, data.Password);
927                data.Password = window.btoa(encodedPassword);
928
929                window.tsPlatform.drs.triggerActionEvent("login", { claimedUserId: transmitCustomerID }).then((actionResponse) => {
930                    console.log('Transmit Track Started');
931                    let actionToken = actionResponse.actionToken;
932
933                    $.ajax({
934                        type: "POST",
935                        url: moduleConfig.transmitTokenUrl,
936                        data: {
937                            'type': 'login',
938                            'customerID': transmitCustomerID
939                        },
940                        cache: false,
941                        async: false,
942                        success: function (response) {
943
944                            if (response.result !== undefined) {
945                                var accessToken = response.result.access_token;
946
947                                // Transmit Recommandation API
948                                $.ajax({
949                                    type: "POST",
950                                    url: moduleConfig.transmitRecommendation,
951                                    data: {
952                                        'action_token': actionToken,
953                                        'access_token': accessToken,
954                                        'customerID': transmitCustomerID,
955                                        'type': 'login',
956                                    },
957                                    cache: false,
958                                    async: true,
959                                    success: function (response) {
960                                        $('#loadingDiv').addClass('d-none');
961                                        if (response.status == 2) {
962                                            Eremit.Utility.handleUserDefineError('We are unable to proceed with your login at this time, please try again after sometime. Please contact the administrator.');
963                                            $('form#eremit-login-form').reset();
964                                            window.scrollTo(0, 0);
965                                            grecaptcha.reset();
966                                            return false;
967                                        } else {
968                                            Eremit.Login.ajaxSubmitLogin(data, captchResponse);
969                                        }
970
971                                    },
972                                    error: function (XMLHttpRequest, textStatus, errorThrown) {
973                                        $('#loadingDiv').addClass('d-none');
974                                        Eremit.Login.ajaxSubmitLogin(data, captchResponse);
975                                    },
976                                });
977                            } else {
978                                $('#loadingDiv').addClass('d-none');
979                                Eremit.Login.ajaxSubmitLogin(data, captchResponse);
980                            }
981
982                        },
983                        error: function (XMLHttpRequest, textStatus, errorThrown) {
984                            $('#loadingDiv').addClass('d-none');
985                            Eremit.Login.ajaxSubmitLogin(data, captchResponse);
986                        },
987                    });
988                });
989
990                window.tsPlatform.drs.clearUser();
991
992            }
993        },
994        ajaxSubmitLogin: function (data, captchResponse) {
995
996            data['g-recaptcha-response'] = captchResponse;
997
998            // Ajax Call For Submit the login
999            $.ajax({
1000                type: "POST",
1001                url: moduleConfig.LoginUrl,
1002                data: data,
1003                cache: false,
1004                async: false,
1005                success: function (response) {
1006                    // Reseting the Captcha
1007                    grecaptcha.reset();
1008
1009
1010                    var response = JSON.parse(response);
1011                    if (response.status == true) {
1012                        window.location.href = response.redirect;
1013                    } else if (response.status == false) {
1014                        if (response.data == 'try-block') {
1015                            Eremit.Utility.handleUserDefineError('You have exceeds Two Factor Authentication OTP attempts limit. Your account was blocked for ' + moduleConfig.update_mobile_block_hours + ' Hours.', 'alert-danger red-font');
1016                            setTimeout(function () { window.location.href = response.redirect; }, 5000);
1017                            return false;
1018                        }
1019
1020                        if (response.data == 'request-block') {
1021                            Eremit.Utility.handleUserDefineError('You have exceeds Two Factor Authentication OTP generate limit. Your account was blocked for ' + moduleConfig.update_mobile_block_hours + ' Hours.', 'alert-danger red-font');
1022                            setTimeout(function () { window.location.href = response.redirect; }, 5000);
1023                            return false;
1024                        }
1025                        Eremit.Utility.handleUserDefineError(response.redirect);
1026
1027                    } else {
1028                        if (response.status == 500) {
1029                            error = "These credentials do not match our records.";
1030                        } else {
1031                            error = "Something went wrong.Please try agian!";
1032                        }
1033                        Eremit.Utility.handleUserDefineError(error);
1034                    }
1035                    window.scrollTo(0, 0);
1036                    $('#loadingDiv').addClass('d-none');
1037                },
1038                error: function (XMLHttpRequest, textStatus, errorThrown) {
1039                    Eremit.Utility.handleAjaxValidationErorrs(XMLHttpRequest, textStatus, errorThrown);
1040                    $('#loadingDiv').addClass('d-none');
1041                    // Reseting the Captcha
1042                    grecaptcha.reset();
1043                }
1044            });
1045        },
1046        CryptoJSAesEncrypt: function (passphrase, plain_text) {
1047
1048            var salt = CryptoJS.lib.WordArray.random(256);
1049            var iv = CryptoJS.lib.WordArray.random(16);
1050            //for more random entropy can use : https://github.com/wwwtyro/cryptico/blob/master/random.js instead CryptoJS random() or another js PRNG
1051
1052            var key = CryptoJS.PBKDF2(passphrase, salt, { hasher: CryptoJS.algo.SHA512, keySize: 64 / 8, iterations: 999 });
1053
1054            var encrypted = CryptoJS.AES.encrypt(plain_text, key, { iv: iv });
1055
1056            var data = {
1057                ciphertext: CryptoJS.enc.Base64.stringify(encrypted.ciphertext),
1058                salt: CryptoJS.enc.Hex.stringify(salt),
1059                iv: CryptoJS.enc.Hex.stringify(iv)
1060            }
1061
1062            return JSON.stringify(data);
1063        },
1064    },
1065    sendForgotOtp: {
1066        init: function (requestData, event) {
1067            event.preventDefault();
1068            $.ajax({
1069                type: "POST",
1070                url: requestData.url,
1071                data: "Customer_ID=" + requestData.customerId + "&_token=" + requestData.token,
1072                cache: false,
1073                success: function (response) {
1074                    var response = JSON.parse(response);
1075                    if (response.status == true) {
1076                        window.location.href = response.redirect;
1077                    } else if (response.status == false) {
1078                        if (response.data == 'try-block') {
1079                            Eremit.Utility.handleUserDefineError('You have exceeds OTP attempts limit. Your account was blocked for ' + requestData.update_mobile_block_hours + ' Hours.', 'alert-danger red-font');
1080                            setTimeout(function () { window.location.href = response.redirect; }, 5000);
1081                            return false;
1082                        }
1083
1084                        if (response.data == 'request-block') {
1085                            Eremit.Utility.handleUserDefineError('You have exceeds OTP generate limit. Your account was blocked for ' + requestData.update_mobile_block_hours + ' Hours.', 'alert-danger red-font');
1086                            setTimeout(function () { window.location.href = response.redirect; }, 5000);
1087                            return false;
1088                        }
1089                        Eremit.Utility.handleUserDefineError(response.data);
1090                    } else {
1091                        if (response.status == 500) {
1092                            error = "These credentials do not match our records.";
1093                        } else {
1094                            error = "Something went wrong.Please try agian!";
1095                        }
1096                        Eremit.Utility.handleUserDefineError(error);
1097                    }
1098                    window.scrollTo(0, 0);
1099                },
1100                error: function (XMLHttpRequest, textStatus, errorThrown) {
1101                    Eremit.Utility.handleAjaxValidationErorrs(XMLHttpRequest, textStatus, errorThrown);
1102                }
1103            });
1104        },
1105    },
1106    resendOtp: {
1107        init: function (parameter, event) {
1108            event.preventDefault();
1109            $.ajax({
1110                type: "POST",
1111                url: parameter.resendOtpURL,
1112                data: "Customer_ID=" + parameter.customerId + "&_token=" + parameter.token,
1113                cache: false,
1114                success: function (response) {
1115                    var response = JSON.parse(response);
1116                    if (response.status == true) {
1117                        Eremit.Utility.handleUserDefineError(response.data);
1118                    } else {
1119                        if (response.data == 'try-block') {
1120                            Eremit.Utility.handleUserDefineError('You have exceeds OTP attempts limit. Your account was blocked for ' + parameter.update_mobile_block_hours + ' Hours.', 'alert-danger red-font');
1121                            setTimeout(function () { window.location.href = response.redirect; }, 5000);
1122                            return false;
1123                        }
1124
1125                        if (response.data == 'request-block') {
1126                            Eremit.Utility.handleUserDefineError('You have exceeds OTP generate limit. Your account was blocked for ' + parameter.update_mobile_block_hours + ' Hours.', 'alert-danger red-font');
1127                            setTimeout(function () { window.location.href = response.redirect; }, 5000);
1128                            return false;
1129                        }
1130                        if (response.status == 500) {
1131                            error = "These credentials do not match our records.";
1132                        } else {
1133                            error = "Something went wrong.Please try agian!";
1134                        }
1135                        Eremit.Utility.handleUserDefineError(error);
1136                    }
1137                    window.scrollTo(0, 0);
1138                },
1139                error: function (XMLHttpRequest, textStatus, errorThrown) {
1140                    Eremit.Utility.handleAjaxValidationErorrs(XMLHttpRequest, textStatus, errorThrown);
1141                }
1142            });
1143        },
1144    },
1145    verifyForgotOtp: {
1146        init: function (parameter, event) {
1147            event.preventDefault();
1148            $.ajax({
1149                type: "POST",
1150                url: parameter.verifyForgotOtpURL,
1151                data: "Customer_ID=" + parameter.customerId + "&mobileOtp=" + parameter.otp + "&_token=" + parameter.token,
1152                cache: false,
1153                success: function (response) {
1154                    var response = JSON.parse(response);
1155                    if (response.status == true) {
1156                        window.location.href = response.redirect;
1157                    } else {
1158                        if (response.status == 500) {
1159                            error = "These credentials do not match our records.";
1160                            Eremit.Utility.handleUserDefineError(error);
1161                        } else if (response.data != 'try-block' && response.data != 'request-block') {
1162                            error = response.data;
1163                            Eremit.Utility.handleUserDefineError(error);
1164                        } else {
1165                            error = "Invalid otp. Please try again";
1166                            Eremit.Utility.handleUserDefineError(error);
1167                        }
1168
1169                        if (response.data == 'try-block') {
1170                            Eremit.Utility.handleUserDefineError('You have exceeds OTP attempts limit. Your account was blocked for ' + parameter.update_mobile_block_hours + ' Hours.', 'alert-danger red-font');
1171                            setTimeout(function () { window.location.href = response.redirect; }, 5000);
1172                        } else if (response.data == 'request-block') {
1173                            Eremit.Utility.handleUserDefineError('You have exceeds OTP generate limit. Your account was blocked for ' + parameter.update_mobile_block_hours + ' Hours.', 'alert-danger red-font');
1174                            setTimeout(function () { window.location.href = response.redirect; }, 5000);
1175                        }
1176                    }
1177                    window.scrollTo(0, 0);
1178                },
1179                error: function (XMLHttpRequest, textStatus, errorThrown) {
1180                    Eremit.Utility.handleAjaxValidationErorrs(XMLHttpRequest, textStatus, errorThrown);
1181                }
1182            });
1183        },
1184    },
1185    CurrencyGraph: {
1186        init: function (data) {
1187            var jsonData = JSON.parse(data);
1188            var isTV = $('.tv-main').length > 0;
1189            
1190            var chartOptions = {
1191                chart: {
1192                    zoomType: 'x'
1193                },
1194                title: {
1195                    text: 'AUD to INR Exchange Rate Chart',
1196                    style: {
1197                        fontWeight: 'normal'
1198                    }
1199                },
1200                xAxis: {
1201                    type: 'datetime'
1202                },
1203                yAxis: {
1204                    title: {
1205                        text: 'Exchange rate'
1206                    },
1207                    tickInterval: 1
1208                },
1209                plotOptions: {
1210                    area: {
1211                        fillColor: {
1212                            linearGradient: {
1213                                x1: 0,
1214                                y1: 0,
1215                                x2: 0,
1216                                y2: 1
1217                            },
1218                            stops: isTV ? [
1219                                [0, 'rgba(124, 181, 236, 1)'],
1220                                [1, 'rgba(124, 181, 236, 0)']
1221                            ] : [
1222                                [0, Highcharts.getOptions().colors[0]],
1223                                [1, new Highcharts.Color(Highcharts.getOptions().colors[0]).setOpacity(0).get('rgba')]
1224                            ]
1225                        },
1226                        marker: {
1227                            radius: 2
1228                        },
1229                        lineWidth: 1,
1230                        states: {
1231                            hover: {
1232                                lineWidth: 1
1233                            }
1234                        },
1235                        threshold: null
1236                    }
1237                },
1238                credits: {
1239                    enabled: false
1240                },
1241                series: [{
1242                    type: 'area',
1243                    name: 'AUD to INR',
1244                    data: jsonData,
1245                }]
1246            };
1247
1248            if (isTV) {
1249                chartOptions.accessibility = { enabled: false };
1250            }
1251
1252            Highcharts.chart('container', chartOptions);
1253        }
1254    },
1255    Transaction: {
1256        init: function () {
1257            // Fetch Bpay Fees
1258            $('.pay-mode-right').on("click", function () {
1259                $(this).find('input[type=radio]').prop('checked', true);
1260                $('.poli_checkbox_div, .debitacc_checkbox_div,.payid_checkbox_div,.payto_checkbox_div').removeClass('checked');
1261                $('.bpay_checkbox_div').addClass('checked');
1262                Eremit.Transaction.paymentMethodChangeEvent();
1263            });
1264
1265            //Fetch Poli Fees
1266            $('.pay-mode-left').on("click", function () {
1267                $(this).find('input[type=radio]').prop('checked', true);
1268                $('.poli_checkbox_div').addClass('checked');
1269                $('.bpay_checkbox_div, .debitacc_checkbox_div,.payid_checkbox_div,.payto_checkbox_div').removeClass('checked');
1270                Eremit.Transaction.paymentMethodChangeEvent();
1271            });
1272
1273            // Fetch Debit from Current Account Fees
1274            $('.pay-mode-right-1').on("click", function () {
1275                $(this).find('input[type=radio]').prop('checked', true);
1276                $('.debitacc_checkbox_div').addClass('checked');
1277                $('.bpay_checkbox_div, .poli_checkbox_div,.payid_checkbox_div,.payto_checkbox_div').removeClass('checked');
1278                Eremit.Transaction.paymentMethodChangeEvent();
1279            });
1280
1281            // Fetch Debit from PayId Fees
1282            $('.pay-mode-right-2').on("click", function () {
1283                $(this).find('input[type=radio]').prop('checked', true);
1284                $('.payid_checkbox_div').addClass('checked');
1285                $('.bpay_checkbox_div, .poli_checkbox_div,.debitacc_checkbox_div,.payto_checkbox_div').removeClass('checked');
1286                Eremit.Transaction.paymentMethodChangeEvent();
1287            });
1288
1289            // Fetch Debit from PayTo Fees
1290            $('.pay-mode-right-3').on("click", function () {
1291                $(this).find('input[type=radio]').prop('checked', true);
1292                $('.payto_checkbox_div').addClass('checked');
1293                $('.bpay_checkbox_div, .poli_checkbox_div,.debitacc_checkbox_div,.payid_checkbox_div').removeClass('checked');
1294                Eremit.Transaction.paymentMethodChangeEvent();
1295            });
1296
1297            if ($('#base_currency_value').val() == '1' && $('#exchange_currency_value').val() == '2') {
1298            } else {
1299                $(".purpose_of_transfer option[value='Covid-19 - Medical Emergency']").remove();
1300            }
1301
1302            $('#transaction_amount').keypress(function (eve) {
1303                if ((eve.which != 46 || $(this).val().indexOf('.') != -1) && (eve.which < 48 || eve.which > 57) || (eve.which == 46 && this.selectionStart === 0)) {
1304                    eve.preventDefault();
1305                }
1306
1307                // this part is when left part of number is deleted and leaves a . in the leftmost position. For example, 33.25, then 33 is deleted
1308                $('#transaction_amount').keyup(function (eve) {
1309                    if ($(this).val().indexOf('.') == 0) {
1310                        $(this).val($(this).val().substring(1));
1311                    }
1312                });
1313            });
1314
1315
1316            $('#transaction_amount').focusout(function (event) {
1317                event.stopImmediatePropagation();
1318                if ($(this).val() != "" && $(this).val() > 0 && $(this).hasClass('readonly-inp') == false) {
1319                    var v = parseFloat(this.value);
1320                    this.value = (isNaN(v)) ? '' : v.toFixed(2);
1321                    var covidpur = $('.purpose_of_transfer').val() == 'Covid-19 - Medical Emergency' ? '1' : '0';
1322                    if (v > 25000) {
1323                        if ($("input[name='payment_method']:checked").val() == "PayTo") {
1324                            window.scrollTo(0, 0);
1325                            Eremit.Utility.handleUserDefineError('Transfer amount has to be less than AUD 25,000.00 to process with PayTo.', 'override-primary');
1326                            Eremit.Transaction.handleResetCalculationErrrorResponse();
1327                        }
1328
1329                        $('.payto_checkbox_div').addClass('pe-none bg-secondary-subtle');
1330                        $('.enable-content').addClass('d-none');
1331                        $(".disable-content").removeClass('d-none');
1332                        $("input[name=payment_method][value='PayTo']").prop('checked', false);
1333                        $(".payto_checkbox_div").removeClass('checked');
1334
1335                        if ($("input[name=payment_method][value='PayId']").length > 0 && !$(".payid_checkbox_div").hasClass('disabled')) {
1336                            $("input[name=payment_method][value='PayId']").prop('checked', true);
1337                            $(".payid_checkbox_div").addClass('checked');
1338                        } else if ($("input[name=payment_method][value='Bpay']").length > 0) {
1339                            $("input[name=payment_method][value='Bpay']").prop('checked', true);
1340                            $(".bpay_checkbox_div").addClass('checked');
1341                        } else if ($("input[name=payment_method][value='DebitFromAcc']").length > 0) {
1342                            $("input[name=payment_method][value='DebitFromAcc']").prop('checked', true);
1343                            $(".debitacc_checkbox_div").addClass('checked');
1344                        }
1345                    } else {
1346                        $('.payto_checkbox_div').removeClass('pe-none bg-secondary-subtle');
1347                        $('.enable-content').removeClass('d-none');
1348                        $(".disable-content").addClass('d-none');
1349                    }
1350                    Eremit.Transaction.amountChangeEvent({
1351                        'base_currency': $('#base_currency_value').val(),
1352                        'exchange_currency': $('#exchange_currency_value').val(),
1353                        'payment_method': $("input[name='payment_method']:checked").val(),
1354                        'amount': $(this).val(),
1355                        'covidpurpose': covidpur
1356                    });
1357                } else if ($(this).val() <= 0) {
1358                    Eremit.Utility.handleUserDefineError("Transfer amount has to be more than remittance fee.");
1359                    Eremit.Transaction.handleResetCalculationErrrorResponse();
1360                }
1361            });
1362
1363            // Re-Calculate while "Purpose of Transfer" Changed
1364            $(document).on('change', '.purpose_of_transfer', function () {
1365                $('#loadingDiv').removeClass('d-none');
1366
1367                if ($('#transaction_amount').val() == '' || $('#transaction_amount').val() == 0) {
1368                    Eremit.Utility.handleUserDefineError("Please enter Transfer amount.");
1369                    $('.purpose_of_transfer').val('');
1370                    $('#loadingDiv').addClass('d-none');
1371                    return false;
1372                }
1373
1374                if ($(this).val() == 'Covid-19 - Medical Emergency' && $('#transaction_amount').val() != '' && $('#transaction_amount').val() > 0) {
1375                    $('.cvdphdn').val('1');
1376                    if ($('#transaction_amount').hasClass('readonly-inp') == true) {
1377                        var v = parseFloat($('#foreign_currency_amount').val());
1378                    } else {
1379                        var v = parseFloat($('#transaction_amount').val());
1380                    }
1381
1382                    // Get Toggle details and promo details
1383                    var checkedCurrency = $("input[name='currency_type']:checked").val();
1384                    var toggleFeature = $("input#hdn_toggle_feature").val();
1385                    var amountBasedPromo = $("input#hdn_amount_based_promo").val();
1386
1387                    // If Toggle Feature is enabled and Non-AUD to AUD toggle selected
1388                    if (checkedCurrency != 'aud' && toggleFeature == 1 && amountBasedPromo == 0) {
1389                        Eremit.Transaction.amountChangeEvent({
1390                            'base_currency': $('#exchange_currency_value').val(),
1391                            'exchange_currency': $('#base_currency_value').val(),
1392                            'payment_method': $("input[name='payment_method']:checked").val(),
1393                            'amount': v,
1394                            'covidpurpose': '1',
1395                        });
1396                    } else {
1397                        Eremit.Transaction.amountChangeEvent({
1398                            'base_currency': $('#base_currency_value').val(),
1399                            'exchange_currency': $('#exchange_currency_value').val(),
1400                            'payment_method': $("input[name='payment_method']:checked").val(),
1401                            'amount': v,
1402                            'covidpurpose': '1',
1403                        });
1404                    }
1405                } else if ($('#transaction_amount').val() != '' && $('#transaction_amount').val() > 0) {
1406                    $('.cvdphdn').val('0');
1407                    var v = parseFloat($('#transaction_amount').val());
1408
1409                    if (window.location.href.includes('transaction/aud') == true) {
1410                        Eremit.Transaction.amountChangeEvent({
1411                            'base_currency': $('#base_currency_value').val(),
1412                            'exchange_currency': $('#exchange_currency_value').val(),
1413                            'payment_method': $("input[name='payment_method']:checked").val(),
1414                            'amount': v,
1415                            'covidpurpose': '0',
1416                        });
1417                    } else {
1418                        var checkedCurrency = $("input[name='currency_type']:checked").val();
1419
1420                        if ($('#transaction_amount').hasClass('readonly-inp') == true) {
1421                            var v = parseFloat($('#foreign_currency_amount').val());
1422                        } else {
1423                            var v = parseFloat($('#transaction_amount').val());
1424                        }
1425
1426                        // Get Toggle details and promo details
1427                        var toggleFeature = $("input#hdn_toggle_feature").val();
1428                        var amountBasedPromo = $("input#hdn_amount_based_promo").val();
1429
1430                        // If Toggle Feature is enabled and Non-AUD to AUD toggle selected
1431                        if (checkedCurrency != 'aud' && toggleFeature == 1 && amountBasedPromo == 0) {
1432                            Eremit.Transaction.amountChangeEvent({
1433                                'base_currency': $('#exchange_currency_value').val(),
1434                                'exchange_currency': $('#base_currency_value').val(),
1435                                'payment_method': $("input[name='payment_method']:checked").val(),
1436                                'amount': v,
1437                                'covidpurpose': '0',
1438                            });
1439                        } else {
1440                            Eremit.Transaction.amountChangeEvent({
1441                                'base_currency': $('#base_currency_value').val(),
1442                                'exchange_currency': $('#exchange_currency_value').val(),
1443                                'payment_method': $("input[name='payment_method']:checked").val(),
1444                                'amount': v,
1445                                'covidpurpose': '0',
1446                            });
1447                        }
1448                    }
1449                }
1450            });
1451
1452            // Currency SWITCH toggle button click event
1453            $(document).on('click', '.currency-switch-trans label.btn', function (e) {
1454                Eremit.Transaction.handleResetCalculationErrrorResponse();
1455                $('#transaction_amount').val('0.00');
1456                $('#foreign_currency_amount').val('0.00');
1457                var clickedCurrency = $(this).children('input').val();
1458                //  console.log(clickedCurrency);
1459                if (clickedCurrency == 'aud') {
1460                    $('#foreign_currency_amount').attr('readonly', 'readonly');
1461                    $('#foreign_currency_amount').addClass('readonly-inp');
1462                    $('#transaction_amount').removeAttr('readonly');
1463                    $('#transaction_amount').removeClass('readonly-inp');
1464                    $(this).siblings().removeClass('active btn-success');
1465                    $(this).addClass('active btn-warning');
1466                } else {
1467                    $('#transaction_amount').attr('readonly', 'readonly');
1468                    $('#transaction_amount').addClass('readonly-inp');
1469                    $('#foreign_currency_amount').removeAttr('readonly');
1470                    $('#foreign_currency_amount').removeClass('readonly-inp');
1471                    $(this).siblings().removeClass('active btn-warning');
1472                    $(this).addClass('active btn-success');
1473                }
1474                //Eremit.Transaction.handleResetCalculationErrrorResponse();
1475            });
1476
1477            $('#foreign_currency_amount').focusout(function (event) {
1478                event.stopPropagation();
1479                event.stopImmediatePropagation();
1480                if ($(this).val() != "" && $(this).val() > 0 && $(this).hasClass('readonly-inp') == false) {
1481
1482                    var v = parseFloat(this.value);
1483                    this.value = (isNaN(v)) ? '' : v.toFixed(2);
1484                    var covidpur = $('.purpose_of_transfer').val() == 'Covid-19 - Medical Emergency' ? '1' : '0';
1485
1486                    Eremit.Transaction.amountChangeEvent({
1487                        'base_currency': $('#exchange_currency_value').val(),
1488                        'exchange_currency': $('#base_currency_value').val(),
1489                        'payment_method': $("input[name='payment_method']:checked").val(),
1490                        'amount': $(this).val(),
1491                        'covidpurpose': covidpur
1492                    });
1493                } else if ($(this).val() <= 0) {
1494                    Eremit.Utility.handleUserDefineError("Transfer amount has to be more than remittance fee.");
1495                    Eremit.Transaction.handleResetCalculationErrrorResponse();
1496                }
1497
1498                setTimeout(() => {
1499                    $('#loadingDiv').addClass('d-none');
1500                }, 2200);
1501            });
1502
1503
1504            $('#transactionSubmit').on('click', function (e) {
1505                e.preventDefault();
1506                $('#loadingDiv').removeClass('d-none');
1507
1508                if (typeof window.tsPlatform === 'undefined' || !window.tsPlatform.drs) {
1509                    $('#transactionForm').submit();
1510                    return;
1511                }
1512
1513                window.tsPlatform.drs.setAuthenticatedUser(moduleConfig.CustomerID);
1514
1515                window.tsPlatform.drs.triggerActionEvent("checkout", { claimedUserId: moduleConfig.CustomerID }).then((actionResponse) => {
1516                    console.log('Transmit Track Started');
1517                    let actionToken = actionResponse.actionToken;
1518
1519                    $.ajax({
1520                        type: "POST",
1521                        url: moduleConfig.transmitTokenUrl,
1522                        data: {
1523                            'type': 'checkout',
1524                            'customerID': moduleConfig.CustomerID
1525                        },
1526                        cache: false,
1527                        async: false,
1528                        success: function (response) {
1529                            var accessToken = response.result.access_token;
1530
1531                            // Transmit Recommandation API
1532                            $.ajax({
1533                                type: "POST",
1534                                url: moduleConfig.transmitRecommendation,
1535                                data: {
1536                                    'action_token': actionToken,
1537                                    'access_token': accessToken,
1538                                    'customerID': moduleConfig.CustomerID,
1539                                    'type': 'checkout',
1540                                },
1541                                cache: false,
1542                                async: false,
1543                                success: function (response) {
1544                                    $('#transactionForm').submit();
1545                                },
1546                                error: function (XMLHttpRequest, textStatus, errorThrown) {
1547                                    $('#transactionForm').submit();
1548                                },
1549                            });
1550
1551                        },
1552                        error: function (XMLHttpRequest, textStatus, errorThrown) {
1553                            $('#transactionForm').submit();
1554                        },
1555                    });
1556                }).catch((error) => {
1557                    $('#transactionForm').submit();
1558                });
1559
1560                window.tsPlatform.drs.clearUser();
1561
1562            });
1563        },
1564        paymentMethodChangeEvent: function () {
1565            var paymentMethod = $("input[name='payment_method']:checked").val();
1566            if (paymentMethod === 'POLi') {
1567                $('.poli-notification').removeClass('d-none');
1568            } else {
1569                $('.poli-notification').addClass('d-none');
1570            }
1571            if ($('#transaction_amount').val() != "" && $('#transaction_amount').val() > 0) {
1572                var covidpur = $('.purpose_of_transfer').val() == 'Covid-19 - Medical Emergency' ? '1' : '0';
1573
1574                if (window.location.href.includes('transaction/aud') == true) {
1575                    Eremit.Transaction.amountChangeEvent({
1576                        'base_currency': $('#base_currency_value').val(),
1577                        'exchange_currency': $('#exchange_currency_value').val(),
1578                        'payment_method': paymentMethod,
1579                        'amount': $('#transaction_amount').val(),
1580                        'covidpurpose': covidpur
1581                    });
1582                } else {
1583                    var checkedCurrency = $("input[name='currency_type']:checked").val();
1584
1585                    if ($('#transaction_amount').hasClass('readonly-inp') == true) {
1586                        var v = parseFloat($('#foreign_currency_amount').val());
1587                    } else {
1588                        var v = parseFloat($('#transaction_amount').val());
1589                    }
1590
1591                    // Get Toggle details and promo details
1592                    var toggleFeature = $("input#hdn_toggle_feature").val();
1593                    var amountBasedPromo = $("input#hdn_amount_based_promo").val();
1594
1595                    // If Toggle Feature is enabled and Non-AUD to AUD toggle selected
1596                    if (checkedCurrency != 'aud' && toggleFeature == 1 && amountBasedPromo == 0) {
1597                        Eremit.Transaction.amountChangeEvent({
1598                            'base_currency': $('#exchange_currency_value').val(),
1599                            'exchange_currency': $('#base_currency_value').val(),
1600                            'payment_method': $("input[name='payment_method']:checked").val(),
1601                            'amount': v,
1602                            'covidpurpose': covidpur
1603                        });
1604                    } else {
1605                        Eremit.Transaction.amountChangeEvent({
1606                            'base_currency': $('#base_currency_value').val(),
1607                            'exchange_currency': $('#exchange_currency_value').val(),
1608                            'payment_method': $("input[name='payment_method']:checked").val(),
1609                            'amount': v,
1610                            'covidpurpose': covidpur
1611                        });
1612                    }
1613                }
1614            } else if ($('#transaction_amount').val() <= 0) {
1615                Eremit.Utility.handleUserDefineError("Transfer amount has to be more than remittance fee.");
1616                Eremit.Transaction.handleResetCalculationErrrorResponse();
1617            }
1618        },
1619        // Re-Calculate all amounts with latest scenarios
1620        amountChangeEvent: function (requestData) {
1621            $.ajax({
1622                type: "POST",
1623                url: moduleConfig.AmountCalculationUrl,
1624                data: requestData,
1625                cache: false,
1626                success: function (response) {
1627                    $('#loadingDiv').addClass('d-none');
1628                    var response = JSON.parse(response);
1629                    if (response.status == true) {
1630                        var php_err = $('.container-custom .inner-header').next('.alert-info.alert');
1631                        if (php_err.html() != undefined && php_err.html().length > 0) {
1632                            $(php_err).addClass('d-none');
1633                        }
1634
1635                        Eremit.Transaction.handleCalculationSuccessResponse(response);
1636                    } else {
1637                        Eremit.Transaction.handleResetCalculationErrrorResponse();
1638                        Eremit.Utility.handleUserDefineError(response.error);
1639                    }
1640                },
1641                error: function (XMLHttpRequest, textStatus, errorThrown) {
1642                    $('#loadingDiv').addClass('d-none');
1643                    Eremit.Transaction.handleResetCalculationErrrorResponse();
1644                    Eremit.Utility.handleAjaxValidationErorrs(XMLHttpRequest, textStatus, errorThrown);
1645                }
1646            });
1647        },
1648        handleResetCalculationErrrorResponse: function () {
1649            $('.applied_fee_value').val('');
1650            $('.applied_exchange_rate_value').val('');
1651            $('.foreign_currency_amount').val('');
1652            $('.original_rate_value').val('');
1653            $('.original_fee_value').val('');
1654            $('.transaction_amount_text').html('');
1655            // Total Section
1656            $('.foreign_currency_amount_text').html('');
1657            $('.total_amount_text').html('');
1658            // Fees inner Section
1659            $('.applied_fee_text').html('');
1660            $('.original_fee_text').html('');
1661            $('.discount_fee_text').html('');
1662            // Exchange Rate inner Section
1663            $('.applied_rate_text').html('');
1664            $('.original_rate_text').html('');
1665            $('.discount_rate_text').html('');
1666            // Transaction benefits Text
1667            $(".transaction-benefits-body").html('');
1668            // Your saved text
1669            $(".you-saved-body").html('');
1670            $(".you-saved-div").addClass('d-none');
1671            $(".transaction-benefits-body").html('');
1672            $(".transaction-benefits-div").addClass('d-none');
1673            $('.applied_fee_text').html('');
1674            $('.applied_rate_text').html('');
1675        },
1676        // Update all amounts in page
1677        handleCalculationSuccessResponse: function (response) {
1678            if (response.foreign_currency == 'AUD' && response.base_currency != 'AUD') {
1679                var appliedExchangeRate = response.applied_rate,
1680                    originalExchangeRate = response.original_rate,
1681                    discountExchangeRate = response.discount_rate,
1682                    appliedRemittanceFee = response.applied_fee,
1683                    originalRemittanceFee = response.original_fee,
1684                    discountRemittanceFee = response.discount_fee,
1685                    amountExcludingFee = response.foreign_currency_amount - appliedRemittanceFee;
1686                // Populate disabled field
1687                $('.applied_fee_value').val(appliedRemittanceFee);
1688                $('.applied_exchange_rate_value').val(appliedExchangeRate);
1689                $('#transaction_amount').val(response.foreign_currency_amount);
1690                $('.original_rate_value').val(originalExchangeRate);
1691                $('.original_fee_value').val(originalRemittanceFee);
1692                $('.foreign_currency_amount').val(response.original_amount);
1693                // Show Transaction Summary
1694                // Original amount
1695                $('.transaction_amount_text').html('$' + response.foreign_currency_amount);
1696                // Total Section
1697                $('.foreign_currency_amount_text').html(response.original_amount + ' ' + response.base_currency);
1698                $('.total_amount_text').html('Total ' + response.base_currency + ' ($' + amountExcludingFee + ' * ' + appliedExchangeRate + ') :');
1699                if (response.foreign_currency == "INR") {
1700                    // Fees inner Section
1701                    $('.applied_fee_text').html('$' + appliedRemittanceFee);
1702                    $('.original_fee_text').html('$' + originalRemittanceFee);
1703                    $('.discount_fee_text').html('$' + discountRemittanceFee);
1704                    // Exchange Rate inner Section
1705                    $('.applied_rate_text').html(appliedExchangeRate + ' ' + response.foreign_currency);
1706                    $('.original_rate_text').html(originalExchangeRate + ' ' + response.foreign_currency);
1707                    $('.discount_rate_text').html('+' + discountExchangeRate + ' ' + response.foreign_currency);
1708                    // Transaction benefits Text
1709                    if ($(".transaction-benefits-div").hasClass("d-none")) {
1710                        $(".transaction-benefits-body").html(response.benefit_text);
1711                        $(".transaction-benefits-div").removeClass('d-none');
1712                    } else {
1713                        $(".transaction-benefits-body").html(response.benefit_text);
1714                    }
1715                    // Diwali promotion
1716
1717                    // Your saved text
1718                    $(".you-saved-body").html(response.you_saved);
1719                    if (response.you_saved != "") {
1720                        if ($(".you-saved-div").hasClass("d-none")) {
1721                            $(".you-saved-div").removeClass('d-none');
1722                        }
1723                    } else {
1724                        if (!$(".you-saved-div").hasClass("d-none")) {
1725                            $(".you-saved-div").addClass('d-none');
1726                        }
1727                    }
1728                }
1729                /* if (response.foreign_currency == "INR") */
1730                else if (response.foreign_currency == "NPR") {
1731                    // $('.foreign_currency_amount_text').html(response.foreign_currency_amount + ' ' + response.foreign_currency);
1732                    // Fees inner Section
1733                    $('.applied_fee_text').html('$' + appliedRemittanceFee);
1734                    $('.original_fee_text').html('$' + originalRemittanceFee);
1735                    $('.discount_fee_text').html('$' + discountRemittanceFee);
1736                    // Exchange Rate inner Section
1737                    $('.applied_rate_text').html(appliedExchangeRate + ' ' + response.foreign_currency);
1738                    $('.original_rate_text').html(originalExchangeRate + ' ' + response.foreign_currency);
1739                    $('.discount_rate_text').html('+' + discountExchangeRate + ' ' + response.foreign_currency);
1740                    // Transaction benefits Text
1741                    if ($(".transaction-benefits-div").hasClass("d-none")) {
1742                        $(".transaction-benefits-body").html(response.benefit_text);
1743                        $(".transaction-benefits-div").removeClass('d-none');
1744                    } else {
1745                        $(".transaction-benefits-body").html(response.benefit_text);
1746                    }
1747                    // Diwali promotion
1748
1749                    // Your saved text
1750                    $(".you-saved-body").html(response.you_saved);
1751                    if (response.you_saved != "") {
1752                        if ($(".you-saved-div").hasClass("d-none")) {
1753                            $(".you-saved-div").removeClass('d-none');
1754                        }
1755                    } else {
1756                        if (!$(".you-saved-div").hasClass("d-none")) {
1757                            $(".you-saved-div").addClass('d-none');
1758                        }
1759                    }
1760                }
1761                /* else if(response.foreign_currency == "NPR") */
1762                else {
1763                    if (response.base_currency == "INR") {
1764                        if ($(".transaction-benefits-div").hasClass("d-none")) {
1765                            $(".transaction-benefits-body").html(response.benefit_text);
1766                            $(".transaction-benefits-div").removeClass('d-none');
1767                        } else {
1768                            $(".transaction-benefits-body").html(response.benefit_text);
1769                        }
1770                        $(".you-saved-body").html(response.you_saved);
1771                        if (response.you_saved != "") {
1772                            if ($(".you-saved-div").hasClass("d-none")) {
1773                                $(".you-saved-div").removeClass('d-none');
1774                            }
1775                        } else {
1776                            if (!$(".you-saved-div").hasClass("d-none")) {
1777                                $(".you-saved-div").addClass('d-none');
1778                            }
1779                        }
1780
1781                        $('.original_fee_text').html('$' + originalRemittanceFee);
1782                        $('.discount_fee_text').html('$' + discountRemittanceFee);
1783                        // Exchange Rate inner Section
1784                        $('.original_rate_text').html(originalExchangeRate + ' ' + response.base_currency);
1785                        $('.discount_rate_text').html('+' + discountExchangeRate + ' ' + response.base_currency);
1786                    }
1787                    /* response.base_currency == "INR" */
1788                    else if (response.base_currency == "NPR") {
1789                        // $('.foreign_currency_amount_text').html(response.foreign_currency_amount + ' ' + response.foreign_currency);
1790                        if ($(".transaction-benefits-div").hasClass("d-none")) {
1791                            $(".transaction-benefits-body").html(response.benefit_text);
1792                            $(".transaction-benefits-div").removeClass('d-none');
1793                        } else {
1794                            $(".transaction-benefits-body").html(response.benefit_text);
1795                        }
1796                        $(".you-saved-body").html(response.you_saved);
1797                        if (response.you_saved != "") {
1798                            if ($(".you-saved-div").hasClass("d-none")) {
1799                                $(".you-saved-div").removeClass('d-none');
1800                            }
1801                        } else {
1802                            if (!$(".you-saved-div").hasClass("d-none")) {
1803                                $(".you-saved-div").addClass('d-none');
1804                            }
1805                        }
1806
1807                        $('.original_fee_text').html('$' + originalRemittanceFee);
1808                        $('.discount_fee_text').html('$' + discountRemittanceFee);
1809                        // Exchange Rate inner Section
1810                        $('.original_rate_text').html(originalExchangeRate + ' ' + response.base_currency);
1811                        $('.discount_rate_text').html('+' + discountExchangeRate + ' ' + response.base_currency);
1812                    }
1813                    /* response.base_currency == "NPR" */
1814
1815                    $(".transaction-benefits-body").html(response.benefit_text);
1816                    $(".transaction-benefits-div").removeClass('d-none');
1817                    $('.applied_fee_text').html('$' + appliedRemittanceFee);
1818                    $('.applied_rate_text').html(appliedExchangeRate + ' ' + response.base_currency);
1819                    // Your saved text
1820                    $(".you-saved-body").html(response.you_saved);
1821                    if (response.you_saved != "") {
1822                        if ($(".you-saved-div").hasClass("d-none")) {
1823                            $(".you-saved-div").removeClass('d-none');
1824                        }
1825                    } else {
1826                        if (!$(".you-saved-div").hasClass("d-none")) {
1827                            $(".you-saved-div").addClass('d-none');
1828                        }
1829                    }
1830                }
1831            }
1832            /* response.foreign_currency == 'AUD' && response.base_currency != 'AUD' */
1833            else {
1834                var appliedExchangeRate = response.applied_rate,
1835                    originalExchangeRate = response.original_rate,
1836                    discountExchangeRate = response.discount_rate,
1837                    appliedRemittanceFee = response.applied_fee,
1838                    originalRemittanceFee = response.original_fee,
1839                    discountRemittanceFee = response.discount_fee,
1840                    amountExcludingFee = response.original_amount - appliedRemittanceFee;
1841                // Populate disabled field
1842                $('.applied_fee_value').val(appliedRemittanceFee);
1843                $('.applied_exchange_rate_value').val(appliedExchangeRate);
1844                $('.foreign_currency_amount').val(response.foreign_currency_amount);
1845                $('.original_rate_value').val(originalExchangeRate);
1846                $('.original_fee_value').val(originalRemittanceFee);
1847                // Show Transaction Summary
1848                // Original amount
1849                $('.transaction_amount_text').html('$' + response.original_amount);
1850                // Total Section
1851                $('.foreign_currency_amount_text').html(response.foreign_currency_amount + ' ' + response.foreign_currency);
1852                $('.total_amount_text').html('Total ' + response.foreign_currency + ' ($' + amountExcludingFee + ' * ' + appliedExchangeRate + ') :');
1853
1854                if (response.foreign_currency == "INR") {
1855                    // Fees inner Section
1856                    $('.applied_fee_text').html('$' + appliedRemittanceFee);
1857                    $('.original_fee_text').html('$' + originalRemittanceFee);
1858                    $('.discount_fee_text').html('$' + discountRemittanceFee);
1859                    // Exchange Rate inner Section
1860                    $('.applied_rate_text').html(appliedExchangeRate + ' ' + response.foreign_currency);
1861                    $('.original_rate_text').html(originalExchangeRate + ' ' + response.foreign_currency);
1862                    $('.discount_rate_text').html('+' + discountExchangeRate + ' ' + response.foreign_currency);
1863                    // Transaction benefits Text
1864                    if ($(".transaction-benefits-div").hasClass("d-none")) {
1865                        $(".transaction-benefits-body").html(response.benefit_text);
1866                        $(".transaction-benefits-div").removeClass('d-none');
1867                    } else {
1868                        $(".transaction-benefits-body").html(response.benefit_text);
1869                    }
1870                    // Diwali promotion
1871
1872                    // Your saved text
1873                    $(".you-saved-body").html(response.you_saved);
1874                    if (response.you_saved != "") {
1875                        if ($(".you-saved-div").hasClass("d-none")) {
1876                            $(".you-saved-div").removeClass('d-none');
1877                        }
1878                    } else {
1879                        if (!$(".you-saved-div").hasClass("d-none")) {
1880                            $(".you-saved-div").addClass('d-none');
1881                        }
1882                    }
1883                }
1884                /* if (response.foreign_currency == "INR") { */
1885                else if (response.foreign_currency == "NPR") {
1886                    // Fees inner Section
1887                    $('.foreign_currency_amount_text').html(response.foreign_currency_amount + ' ' + response.foreign_currency);
1888                    $('.applied_fee_text').html('$' + appliedRemittanceFee);
1889                    $('.original_fee_text').html('$' + originalRemittanceFee);
1890                    $('.discount_fee_text').html('$' + discountRemittanceFee);
1891                    // Exchange Rate inner Section
1892                    $('.applied_rate_text').html(appliedExchangeRate + ' ' + response.foreign_currency);
1893                    $('.original_rate_text').html(originalExchangeRate + ' ' + response.foreign_currency);
1894                    $('.discount_rate_text').html('+' + discountExchangeRate + ' ' + response.foreign_currency);
1895                    // Transaction benefits Text
1896                    if ($(".transaction-benefits-div").hasClass("d-none")) {
1897                        $(".transaction-benefits-body").html(response.benefit_text);
1898                        $(".transaction-benefits-div").removeClass('d-none');
1899                    } else {
1900                        $(".transaction-benefits-body").html(response.benefit_text);
1901                    }
1902                    // Diwali promotion
1903
1904                    // Your saved text
1905                    $(".you-saved-body").html(response.you_saved);
1906                    if (response.you_saved != "") {
1907                        if ($(".you-saved-div").hasClass("d-none")) {
1908                            $(".you-saved-div").removeClass('d-none');
1909                        }
1910                    } else {
1911                        if (!$(".you-saved-div").hasClass("d-none")) {
1912                            $(".you-saved-div").addClass('d-none');
1913                        }
1914                    }
1915                }
1916                /* response.foreign_currency == "NPR" */
1917                else {
1918                    $('.foreign_currency_amount_text').html(response.foreign_currency_amount + ' ' + response.foreign_currency + '#');
1919                    $(".transaction-benefits-body").html(response.benefit_text);
1920                    $(".transaction-benefits-div").removeClass('d-none');
1921                    $('.applied_fee_text').html('$' + appliedRemittanceFee);
1922                    $('.applied_rate_text').html(appliedExchangeRate + ' ' + response.foreign_currency);
1923
1924                    // Your saved text
1925                    $(".you-saved-body").html(response.you_saved);
1926                    if (response.you_saved != "") {
1927                        if ($(".you-saved-div").hasClass("d-none")) {
1928                            $(".you-saved-div").removeClass('d-none');
1929                        }
1930                    } else {
1931                        if (!$(".you-saved-div").hasClass("d-none")) {
1932                            $(".you-saved-div").addClass('d-none');
1933                        }
1934                    }
1935                }
1936            }
1937        },
1938        print: function () {
1939            var printContents = document.getElementById("print-area").innerHTML,
1940                originalContents = document.body.innerHTML;
1941            document.body.innerHTML = printContents;
1942            setTimeout(function () {
1943                window.print();
1944                document.body.innerHTML = originalContents;
1945            }, 250);
1946        }
1947    },
1948    HomePage: {
1949        init: function () {
1950            var baseCurrencyObject = document.getElementById('base_currency');
1951            baseCurrencyObject.selectedIndex = 0;
1952            baseCurrencyObject.disabled = true;
1953            $('#Amount').keypress(function (event) {
1954                Eremit.Utility.isNumber(event);
1955            });
1956            $('#converted-amount').keypress(function (event) {
1957                Eremit.Utility.isNumber(event);
1958            });
1959            $("#Amount").keyup(Eremit.Utility.debounce(function () {
1960                $("#Amount").val(Eremit.Utility.parseCurrency($("#Amount").val()));
1961                if (Eremit.HomePage.validateCalculator(false)) {
1962                    Eremit.HomePage.calculatorConverter({
1963                        'base_currency': document.getElementById("base_currency").value,
1964                        'exchange_currency': document.getElementById("exchange_currency").value,
1965                        'amount': Eremit.Utility.parseCurrency($("#Amount").val()),
1966                        'payment_method': "BPay",
1967                        'landing_page': false
1968                    }, false);
1969                } else {
1970                    Eremit.CurrencyCalculator.clearCalculation();
1971                }
1972            }, 500));
1973            $("#converted-amount").keyup(Eremit.Utility.debounce(function () {
1974                $("#converted-amount").val(Eremit.Utility.parseCurrency($("#converted-amount").val()));
1975                if (Eremit.HomePage.validateCalculator(false)) {
1976                    Eremit.HomePage.calculatorConverter({
1977                        'base_currency': document.getElementById("exchange_currency").value, // here we send exchange currency as a base currency
1978                        'exchange_currency': document.getElementById("base_currency").value,
1979                        'amount': Eremit.Utility.parseCurrency($("#converted-amount").val()),
1980                        'payment_method': "BPay",
1981                        'converted_amount': true,
1982                        'landing_page': false
1983                    }, false, true);
1984                } else {
1985                    Eremit.CurrencyCalculator.clearCalculation();
1986                }
1987            }, 500));
1988            $('#exchange_currency').change(function (event) {
1989                var selectedValue = $(this).val(),
1990                    exchangeCurrencyObject = $(this);
1991                Eremit.CurrencyCalculator.clearCalculation();
1992                if (selectedValue != 1) {
1993                    exchangeCurrencyObject.selectedIndex = 0;
1994                    exchangeCurrencyObject.disabled = true;
1995                } else {
1996                    exchangeCurrencyObject.disabled = false;
1997                }
1998            });
1999        },
2000        validateCalculator: function ($landingPage) {
2001            // Assigning Variable
2002            var baseCurrencyObject = document.getElementById("base_currency"),
2003                exchangeCurrencyObject = document.getElementById("exchange_currency"),
2004                amount = document.getElementById("Amount").value,
2005                buttonObject = document.getElementById("calculateCurrency"),
2006                errorObj = document.getElementById("error_result"),
2007                resultObj = document.getElementById("currency_result"),
2008                convertedObj = document.getElementById("converted-amount"),
2009                paymentMethod = "POLi Payment";
2010            if ($landingPage) {
2011                if (baseCurrencyObject.value == "") {
2012                    alert("Please Select Base Currency To Convert");
2013                    Eremit.CurrencyCalculator.clearCalculation();
2014                    return false;
2015                } else if (exchangeCurrencyObject.value == "") {
2016                    alert("Please Select Exchange Currency To Convert");
2017                    Eremit.CurrencyCalculator.clearCalculation();
2018                    return false;
2019                } else if (baseCurrencyObject.value == exchangeCurrencyObject.value && exchangeCurrencyObject.value != 1) {
2020                    alert("Base currency & Exchange Currency Can't be same");
2021                    Eremit.CurrencyCalculator.clearCalculation();
2022                    return false;
2023                } else if (baseCurrencyObject.value != 1 && exchangeCurrencyObject.value != 1) {
2024                    alert("Either Base currency OR exchange rate must be AUD");
2025                    Eremit.CurrencyCalculator.clearCalculation();
2026                    return false;
2027                } else if (amount == "" && convertedObj.value == "") {
2028                    alert("Please enter amount to be calculated");
2029                    Eremit.CurrencyCalculator.clearCalculation();
2030                    document.getElementById('converted-amount').value = '';
2031                    document.getElementById('current_exchange_rate').innerHTML = '0.00';
2032                    document.getElementById('fee_break_down_secondary').innerHTML = '0.00';
2033                    document.getElementById('fee_break_down_primary').innerHTML = '0.00';
2034                    return false;
2035                } else if (amount <= 0 && convertedObj.value == "" || amount == "" && convertedObj.value <= 0) {
2036                    alert("Transfer amount has to be more than remittance fee.");
2037                    Eremit.CurrencyCalculator.clearCalculation();
2038                    return false;
2039                }
2040            } else {
2041                // Validating inputs
2042                if (baseCurrencyObject.value == "") {
2043                    Eremit.HomePage.showValidationError("Please Select Base Currency To Convert");
2044                    Eremit.CurrencyCalculator.clearCalculation();
2045                    return false;
2046                } else if (exchangeCurrencyObject.value == "") {
2047                    Eremit.HomePage.showValidationError("Please Select Exchange Currency To Convert");
2048                    Eremit.CurrencyCalculator.clearCalculation();
2049                    return false;
2050                } else if (baseCurrencyObject.value == exchangeCurrencyObject.value && exchangeCurrencyObject.value != 1) {
2051                    Eremit.CurrencyCalculator.clearCalculation();
2052                    Eremit.HomePage.showValidationError("Base currency & Exchange Currency Can't be same");
2053                    return false;
2054                } else if (baseCurrencyObject.value != 1 && exchangeCurrencyObject.value != 1) {
2055                    Eremit.CurrencyCalculator.clearCalculation();
2056                    Eremit.HomePage.showValidationError("Either Base currency OR exchange rate must be AUD");
2057                    return false;
2058                } else if (amount == "" && convertedObj.value == "") {
2059                    Eremit.CurrencyCalculator.clearCalculation();
2060                    Eremit.HomePage.showValidationError("Please enter amount to be calculated");
2061                    return false;
2062                } else if (amount <= 0 && convertedObj.value == "" || amount == "" && convertedObj.value <= 0) {
2063                    //   Eremit.HomePage.showValidationError("Transfer amount has to be more than remittance fee.");
2064                    //  return false;
2065                    Eremit.CurrencyCalculator.clearCalculation();
2066                }
2067            }
2068            return true;
2069        },
2070        showValidationError: function (message) {
2071            $('#error_result').removeClass('d-none');
2072            $('#error_result').html(message);
2073            window.scrollTo(0, 0);
2074            setTimeout(function () {
2075                $('#error_result').html('');
2076                $('#error_result').addClass('d-none');
2077            }, 7000);
2078        },
2079        calculatorConverter: function (requestData, $landingPage, isConvertedAmount) {
2080            $.ajax({
2081                type: "POST",
2082                url: moduleConfig.currencyConverterUrl,
2083                data: requestData,
2084                cache: false,
2085                success: function (response) {
2086                    var response = JSON.parse(response);
2087                    if (response.status == true) {
2088                        Eremit.CurrencyCalculator.handleSuccessResponse(response, $landingPage, isConvertedAmount);
2089                    } else {
2090                        Eremit.CurrencyCalculator.clearCalculation();
2091                        Eremit.Utility.handleUserDefineError(response.error);
2092                    }
2093                },
2094                error: function (XMLHttpRequest, textStatus, errorThrown) {
2095                    // console.log(XMLHttpRequest);
2096                    Eremit.CurrencyCalculator.clearCalculation()
2097                    Eremit.Utility.handleAjaxValidationErorrs(XMLHttpRequest, textStatus, errorThrown);
2098                }
2099            });
2100        },
2101    },
2102    MultiBenefPage: {
2103        init: function () {
2104            var wrapper = '.rows-ben';
2105            // While changing the AUD Amount textbox value
2106            var timer;
2107
2108            $('.custom_amt_aud, .custom_amt_inr').keypress(function (eve) {
2109
2110                if ((eve.which != 46 || $(this).val().indexOf('.') != -1) && (eve.which < 48 || eve.which > 57) || (eve.which == 46 && this.selectionStart === 0)) {
2111
2112                    eve.preventDefault();
2113                }
2114
2115                // this part is when left part of number is deleted and leaves a . in the leftmost position. For example, 33.25, then 33 is deleted
2116                $('.custom_amt_aud, .custom_amt_inr').keyup(function (eve) {
2117                    if ($(this).val().indexOf('.') == 0) {
2118                        $(this).val($(this).val().substring(1));
2119                    }
2120                });
2121            });
2122
2123            $(wrapper).on('focusout', '.custom_amt_aud', Eremit.Utility.debounce(function (eve) {
2124                var totalAudAmtFinal = 0.00;
2125
2126                $('.custom_amt_aud').each(function (i, obj) {
2127                    var textBoxValue = $(this).val();
2128                    textBoxValue = parseFloat(textBoxValue);
2129                    textBoxValueFinal = (isNaN(textBoxValue)) ? '' : textBoxValue.toFixed(2);
2130
2131                    if (textBoxValueFinal <= 0.00 || textBoxValueFinal == '') {
2132                        amtErr = true;
2133                    } else {
2134                        totalAudAmtFinal += parseFloat(textBoxValueFinal);
2135                    }
2136                });
2137                // $('#loadingDiv').removeClass('d-none');
2138                clearTimeout(timer);
2139                var thisEle = $(this);
2140                //timer = setTimeout(function() {
2141                eve.isImmediatePropagationStopped();
2142                if (thisEle.attr('id') != '' || thisEle.attr('id') != undefined) {
2143                    var elemID = thisEle.attr('id');
2144                    var splitID = elemID.split('_');
2145                    var INDEX = splitID[3];
2146                    var audElemID = 'inp_amt_aud_' + INDEX;
2147                    var audElem = $('#' + audElemID);
2148
2149                    audElem.val(Eremit.Utility.parseCurrency(audElem.val()));
2150
2151                    var purposeOfTransfer = $("#purpose_of_transfer").val();
2152                    var covidpurpose = 0;
2153
2154                    if (purposeOfTransfer == 'Covid-19 - Medical Emergency') {
2155                        covidpurpose = 1;
2156                    }
2157
2158                    // Check if Corporate offer selected
2159                    var corpMultiBeneOffer = $("input[name='applied_corporate_offer']:checked").val();
2160                    var corpMultiBeneOfferVal = 0;
2161
2162                    if (corpMultiBeneOffer != undefined && corpMultiBeneOffer == '1') {
2163                        corpMultiBeneOfferVal = 1;
2164                    }
2165
2166                    if (totalAudAmtFinal > 25000) {
2167                        if ($("input[name='payment_method']:checked").val() == "PayTo") {
2168                            window.scrollTo(0, 0)
2169                            Eremit.Utility.handleUserDefineError('Transfer amount has to be less than AUD 25,000.00 to process with PayTo.', 'override-primary');
2170                            Eremit.Transaction.handleResetCalculationErrrorResponse();
2171                        }
2172
2173                        $('.payto_checkbox_multibenef_div').addClass('pe-none bg-secondary-subtle');
2174                        $('.enable-content').addClass('d-none');
2175                        $(".disable-content").removeClass('d-none');
2176                        $("input[name=payment_method][value='PayTo']").prop('checked', false);
2177                        $(".payto_checkbox_multibenef_div").removeClass('checked');
2178
2179                        if ($("input[name=payment_method][value='PayId']").length > 0 && !$('.payid_checkbox_multibenef_div').hasClass('disabled')) {
2180                            $("input[name=payment_method][value='PayId']").prop('checked', true);
2181                            $(".payid_checkbox_multibenef_div").addClass('checked');
2182                        } else if ($("input[name=payment_method][value='Bpay']").length > 0) {
2183                            $("input[name=payment_method][value='Bpay']").prop('checked', true);
2184                            $(".bpay_checkbox_multibenef_div").addClass('checked');
2185                        }
2185 else if ($("input[name=payment_method][value='DebitFromAcc']").length > 0) {
2186                            $("input[name=payment_method][value='DebitFromAcc']").prop('checked', true);
2187                            $(".debitac_checkbox_multibenef_div").addClass('checked');
2188                        }
2189                    } else {
2190                        $('.payto_checkbox_multibenef_div').removeClass('pe-none bg-secondary-subtle');
2191                        $('.enable-content').removeClass('d-none');
2192                        $(".disable-content").addClass('d-none');
2193                    }
2194                    var paymentMethod = $("input[name='payment_method']:checked").val();
2195                    var requestData = {
2196                        'base_currency': 1,
2197                        'exchange_currency': 2,
2198                        'amount': Eremit.Utility.parseCurrency(audElem.val()),
2199                        'payment_method': ((paymentMethod != '') ? paymentMethod : 'Bpay'),
2200                        'is_multi_benef_amt': '1',
2201                        'covidpurpose': covidpurpose,
2202                        'corpMultiBeneOffer': corpMultiBeneOfferVal,
2203                    };
2204                    Eremit.MultiBenefPage.handleAmountCalculation('AUD', elemID, requestData);
2205                }
2206                $('#loadingDiv').addClass('d-none');
2207                // }, 0);
2208            }));
2209
2210            // While changing the INR Amount textbox value
2211            $(wrapper).on('focusout', '.custom_amt_inr', Eremit.Utility.debounce(function (eve) {
2212                //$('#loadingDiv').removeClass('d-none');
2213                if (eve.keyCode == 9 || $(this).attr('readonly') != undefined) return;
2214                clearTimeout(timer);
2215                var thisEle = $(this);
2216                // timer = setTimeout(function() {
2217                eve.isImmediatePropagationStopped();
2218                if (thisEle.attr('id') != '' || thisEle.attr('id') != undefined) {
2219                    var elemID = thisEle.attr('id');
2220                    var splitID = elemID.split('_');
2221                    var INDEX = splitID[3];
2222                    var inrElemID = 'inp_amt_inr_' + INDEX;
2223                    var inrElem = $('#' + inrElemID);
2224
2225                    var purposeOfTransfer = $("#purpose_of_transfer").val();
2226                    var covidpurpose = 0;
2227
2228                    if (purposeOfTransfer == 'Covid-19 - Medical Emergency') {
2229                        covidpurpose = 1;
2230                    }
2231
2232                    // Check if Corporate offer selected
2233                    var corpMultiBeneOffer = $("input[name='applied_corporate_offer']:checked").val();
2234                    var corpMultiBeneOfferVal = 0;
2235
2236                    if (corpMultiBeneOffer != undefined && corpMultiBeneOffer == '1') {
2237                        corpMultiBeneOfferVal = 1;
2238                    }
2239
2240                    inrElem.val(Eremit.Utility.parseCurrency(inrElem.val()));
2241                    var paymentMethod = $("input[name='payment_method']:checked").val();
2242                    var requestData = {
2243                        'base_currency': 2,
2244                        'exchange_currency': 1,
2245                        'amount': Eremit.Utility.parseCurrency(inrElem.val()),
2246                        'payment_method': ((paymentMethod != '') ? paymentMethod : 'Bpay'),
2247                        'is_multi_benef_amt': '1',
2248                        'covidpurpose': covidpurpose,
2249                        'corpMultiBeneOffer': corpMultiBeneOfferVal,
2250                    };
2251                    Eremit.MultiBenefPage.handleAmountCalculation('INR', elemID, requestData);
2252                }
2253                $('#loadingDiv').addClass('d-none');
2254                // }, 0);
2255            }));
2256
2257            // Currency SWITCH toggle button click event
2258            $(wrapper).on('click', '.currency-switch label.btn', function (e) {
2259                var parentID = $(this).parent('div.currency-switch').attr('id');
2260                var split_id = parentID.split('_');
2261                var INDEX = Number(split_id[1]);
2262                var inrElemID = 'inp_amt_inr_' + INDEX;
2263                var audElemID = 'inp_amt_aud_' + INDEX;
2264                var finalRowAmt = 'row_amt_div_' + INDEX;
2265                var inrElem = $('#' + inrElemID);
2266                var audElem = $('#' + audElemID);
2267                var finalAmtEle = $('#' + finalRowAmt);
2268                var finalExRate = 'row_exchangerate_div_' + INDEX;
2269                var finalFees = 'row_fees_div_' + INDEX;
2270                var clickedCurrency = $(this).children('input').val();
2271                var exchRateHdn = 'exch_rate_hdn_' + INDEX;
2272                var feesAmtHdn = 'fees_amt_hdn_' + INDEX;
2273                var rowExchRateHdnEle = $('#' + exchRateHdn);
2274                var rowFeesEle = $('#' + feesAmtHdn);
2275
2276                $(inrElem).val('0.00');
2277                $(audElem).val('0.00');
2278                $('.last_col_' + INDEX + ' a.benefit-text').addClass('d-none').attr('title', '');
2279                $('.last_col_' + INDEX + ' .applied_promotion_id').val('');
2280                $('.last_col_' + INDEX + ' .loyaltypoint_elig').val('');
2281                $('.last_col_' + INDEX + ' .standard_fees_hdn').val('');
2282                $('.last_col_' + INDEX + ' .card_rate_hdn').val('');
2283                $('.last_col_' + INDEX + ' .fee_disc_text_hdn').val('');
2284                document.getElementById(finalRowAmt).innerHTML = '<h5 class="row-amt">$0.00</h5>';
2285                document.getElementById(finalExRate).innerHTML = '0.00';
2286                document.getElementById(finalFees).innerHTML = '$0.00';
2287                rowExchRateHdnEle.val('0.00');
2288                rowFeesEle.val('0.00');
2289
2290                if (clickedCurrency == 'inr') {
2291                    $(audElem).attr('readonly', 'readonly');
2292                    $(audElem).addClass('readonly-inp');
2293                    $(inrElem).removeAttr('readonly');
2294                    $(inrElem).removeClass('readonly-inp');
2295                    $(this).siblings().removeClass('active btn-success');
2296                    $(this).addClass('active btn-warning');
2297                } else if (clickedCurrency == 'aud') {
2298                    $(inrElem).attr('readonly', 'readonly');
2299                    $(inrElem).addClass('readonly-inp');
2300                    $(audElem).removeAttr('readonly');
2301                    $(audElem).removeClass('readonly-inp');
2302                    $(this).siblings().removeClass('active btn-warning');
2303                    $(this).addClass('active btn-success');
2304                } else {
2305                    $(inrElem).attr('readonly', 'readonly');
2306                    $(audElem).attr('readonly', 'readonly');
2307                    $(audElem).addClass('readonly-inp');
2308                    $(inrElem).addClass('readonly-inp');
2309                    $(inrElem, audElem, finalAmtEle).val('0.00');
2310                }
2311
2312                Eremit.MultiBenefPage.updateTotalAUDAmt();
2313            });
2314
2315            // Amount Change Event
2316            $(wrapper).on('keypress keyup blur', '.custom-amt', Eremit.Utility.debounce(function (event) {
2317                //this.value = this.value.replace(/[^0-9\.]/g,'');
2318                $(this).val($(this).val().replace(/[^0-9\.]/g, ''));
2319                if ((event.which != 46 || $(this).val().indexOf('.') != -1) && (event.which < 48 || event.which > 57)) {
2320                    event.preventDefault();
2321                }
2322            }, 10));
2323
2324            $('body').on('click', '#multibenef_corporate_submit_btn', function (event) {
2325                // console.log('clicked corporate button');
2326                $('#multibenef-form-conf-modal').modal('hide');
2327                $('#multibenef-form-corporate-offer-modal').modal('hide');
2328                Eremit.Validate.MultiBenefForm();
2329
2330                // prevent default submit action
2331                event.preventDefault();
2332
2333                $("input[name=applied_corporate_offer][value='0']").prop("checked", true);
2334                $("input[name=applied_corporate_offer][value='1']").prop("checked", false);
2335
2336                var corpMultiBeneOffer = $("input[name='applied_corporate_offer']:checked").val();
2337                // console.log(corpMultiBeneOffer);
2338
2339                $('#loadingDiv').removeClass('d-none');
2340                Eremit.MultiBenefPage.paymentMethodChangeEventMultiBenef();
2341
2342                Eremit.MultiBenefPage.updateTotalAUDAmt();
2343
2344                $('#loadingDiv').removeClass('d-none');
2345                setTimeout(() => {
2346                    // $('#loadingDiv').addClass('d-none');
2347                    $('form#multibenef-form').submit();
2348                }, 6000);
2349
2350                return;
2351
2352            });
2353
2354            // NEXT (SUBMIT) button click event
2355            $('body').on('submit', 'form#multibenef-form', function (event) {
2356                //  console.log('hello');
2357                $('#multibenef-form-conf-modal').modal('hide');
2358                $('#multibenef-form-corporate-offer-modal').modal('hide');
2359                Eremit.Validate.MultiBenefForm();
2360
2361                // prevent default submit action
2362                event.preventDefault();
2363
2364                Eremit.MultiBenefPage.updateTotalAUDAmt();
2365                var amtErr = false;
2366                var benefErr = false;
2367
2368                /* $('.custom-amt').each(function(i, obj) {
2369                    var textBoxValue = $(this).val();
2370                        if (textBoxValue <= 0.00 || textBoxValue === '')  {
2371                            amtErr = true;
2372                        }
2373                });
2374
2375                $('.ben-fld-name').each(function(i, obj) {
2376                    var benefValue = $(this).val();
2377                        if (benefValue == '')  {
2378                            benefErr = true;
2379                        }
2380                }); */
2381
2382                var corpMultiBeneOffer = $("input[name='applied_corporate_offer']:checked").val();
2383                if (corpMultiBeneOffer != undefined && corpMultiBeneOffer == '1') {
2384                    var totalBenef = $('.custom_amt_aud').length;
2385                    var totalAudAmtFinal = 0.00;
2386
2387                    $('.custom_amt_aud').each(function (i, obj) {
2388                        var textBoxValue = $(this).val();
2389                        textBoxValue = parseFloat(textBoxValue);
2390                        textBoxValueFinal = (isNaN(textBoxValue)) ? '' : textBoxValue.toFixed(2);
2391
2392                        if (textBoxValueFinal <= 0.00 || textBoxValueFinal == '') {
2393                            amtErr = true;
2394                        } else {
2395                            totalAudAmtFinal += parseFloat(textBoxValueFinal);
2396                        }
2397                    });
2398
2399                    if (totalBenef == undefined || totalBenef < 3 || totalAudAmtFinal <= 10000.00) {
2400                        //    console.log('eeror true');
2401                        amtErr = true;
2402                    }
2403                }
2404
2405                if ($("form").valid() == false) {
2406                    // console.log('invalid form final')
2407                    $('#multibenef-form-corporate-offer-modal').modal('hide');
2408                    return false;
2409                }
2410
2411                if ($("form").valid() == false || amtErr === true || benefErr === true) {
2412                    if (amtErr === true || benefErr === true) {
2413                        //alert('Please add at least 3 beneficiaries and total AUD amount must be more than $10000 to get 5 paisa extra and ZERO remittance fee.');
2414                    }
2415                    return false;
2416                }
2417                this.submit();
2418
2419                return;
2420            });
2421
2422            // While changing the Beneficiary from list & check before its not used already
2423            $(wrapper).on('change', '.ben-fld-name', Eremit.Utility.debounce(function () {
2424                // Get List of Beneficiaries
2425                var usedBenefArr = [];
2426                $('.ben-fld-name').each(function () { usedBenefArr.push(parseInt($(this).val())); });
2427                var val = $(this).val();
2428                const index = usedBenefArr.indexOf(parseInt(val));
2429
2430                if (index > -1) {
2431                    usedBenefArr.splice(index, 1);
2432                }
2433
2434                if (jQuery.inArray(parseInt($(this).val()), usedBenefArr) !== -1) {
2435                    $(this).val('');
2436                    alert('Beneficiary already selected!');
2437                }
2438            }, 100));
2439
2440            // Remove Beneficiary Button click event
2441            $(wrapper).on('click', '.remove_button', function () {
2442                $('.add_button').removeClass('d-none');
2443                $(this).parents('.row-ben-root').remove();
2444                setTimeout(() => {
2445                    var incrVal = 1;
2446                    $('.numberic-incr').each(function () {
2447                        $(this).html(incrVal + '.');
2448                        incrVal++;
2449                    });
2450                }, 100);
2451                Eremit.MultiBenefPage.updateTotalAUDAmt();
2452            });
2453
2454            $(document).on('change', '#purpose_of_transfer', function () {
2455                //$('#loadingDiv').removeClass('d-none');
2456
2457                Eremit.MultiBenefPage.paymentMethodChangeEventMultiBenef();
2458                setTimeout(() => {
2459                    $('#loadingDiv').addClass('d-none');
2460                }, 4000);
2461            });
2462
2463            $('input[type=radio][name=applied_corporate_offer]').on('ifChanged', function (event) {
2464                /* event.stopImmediatePropagation();
2465                event.preventDefault();
2466                event.stopPropagation(); */
2467
2468                if ($(this).prop('checked') == true) {
2469                    $('#loadingDiv').removeClass('d-none');
2470                    Eremit.MultiBenefPage.paymentMethodChangeEventMultiBenef();
2471                    setTimeout(() => {
2472                        $('#loadingDiv').addClass('d-none');
2473                    }, 4000);
2474                }
2475            });
2476
2477            // Fetch Bpay fees and Amount Calculation
2478            $('.pay-mode-multibenef-right').on("click", function () {
2479                $('#loadingDiv').removeClass('d-none');
2480                $(this).find('input[type=radio]').prop('checked', true);
2481                $('.debitac_checkbox_multibenef_div,.payid_checkbox_multibenef_div,.payto_checkbox_multibenef_div').removeClass('checked');
2482                $('.bpay_checkbox_multibenef_div').addClass('checked');
2483                Eremit.MultiBenefPage.paymentMethodChangeEventMultiBenef();
2484                setTimeout(() => {
2485                    $('#loadingDiv').addClass('d-none');
2486                }, 4000);
2487            });
2488            $('.pay-mode-multibenef-left').on("click", function () {
2489                $('#loadingDiv').removeClass('d-none');
2490                $(this).find('input[type=radio]').prop('checked', true);
2491                $('.bpay_checkbox_multibenef_div,.payid_checkbox_multibenef_div,.payto_checkbox_multibenef_div').removeClass('checked');
2492                $('.debitac_checkbox_multibenef_div').addClass('checked');
2493                Eremit.MultiBenefPage.paymentMethodChangeEventMultiBenef();
2494                setTimeout(() => {
2495                    $('#loadingDiv').addClass('d-none');
2496                }, 4000);
2497            });
2498            $('.pay-mode-multibenef-right-1').on("click", function () {
2499                $('#loadingDiv').removeClass('d-none');
2500                $(this).find('input[type=radio]').prop('checked', true);
2501                $('.bpay_checkbox_multibenef_div,.debitac_checkbox_multibenef_div,.payto_checkbox_multibenef_div').removeClass('checked');
2502                $('.payid_checkbox_multibenef_div').addClass('checked');
2503                Eremit.MultiBenefPage.paymentMethodChangeEventMultiBenef();
2504                setTimeout(() => {
2505                    $('#loadingDiv').addClass('d-none');
2506                }, 4000);
2507            });
2508
2509            $('.pay-mode-multibenef-right-3').on("click", function () {
2510                $('#loadingDiv').show();
2511                $(this).find('input[type=radio]').prop('checked', true);
2512                $('.bpay_checkbox_multibenef_div,.debitac_checkbox_multibenef_div,.payid_checkbox_multibenef_div').removeClass('checked');
2513                $('.payto_checkbox_multibenef_div').addClass('checked');
2514                Eremit.MultiBenefPage.paymentMethodChangeEventMultiBenef();
2515                setTimeout(() => {
2516                    $('#loadingDiv').addClass('d-none');
2517                }, 4000);
2518            });
2519
2520            $("#multibenef-form-next").on('click', function () {
2521                event.preventDefault();
2522                var inputs = $(".prevelem");
2523                for (var i = 0; i < inputs.length; i++) {
2524                    if ($(inputs[i]).val() == 1) {
2525                        return false;
2526                    }
2527                }
2528
2529                Eremit.Validate.MultiBenefForm();
2530                Eremit.MultiBenefPage.updateTotalAUDAmt();
2531                var amtErr = false;
2532                var benefErr = false;
2533
2534                /* $('.custom-amt').each(function(i, obj) {
2535                    var textBoxValue = $(this).val();
2536                        if (textBoxValue <= 0.00 || textBoxValue === '')  {
2537                            amtErr = true;
2538                        }
2539                });
2540
2541                $('.ben-fld-name').each(function(i, obj) {
2542                    var benefValue = $(this).val();
2543                        if (benefValue == '')  {
2544                            benefErr = true;
2545                        }
2546                }); */
2547
2548                /*                 if ($("form").valid() == false || amtErr === true || benefErr === true) {
2549                                    if (amtErr === true || benefErr === true) {
2550                                        alert('Please fill out all fields.');
2551                                    }
2552                                    return false;
2553                                } */
2554
2555                var corpMultiBeneOffer = $("input[name='applied_corporate_offer']:checked").val();
2556                if (corpMultiBeneOffer != undefined && corpMultiBeneOffer == '1') {
2557                    var totalBenef = $('.custom_amt_aud').length;
2558                    var totalAudAmtFinal = 0.00;
2559
2560                    $('.custom_amt_aud').each(function (i, obj) {
2561                        var textBoxValue = $(this).val();
2562                        textBoxValue = parseFloat(textBoxValue);
2563                        textBoxValueFinal = (isNaN(textBoxValue)) ? '' : textBoxValue.toFixed(2);
2564
2565                        if (textBoxValueFinal > 0.00) {
2566                            totalAudAmtFinal += parseFloat(textBoxValueFinal);
2567                        }
2568                    });
2569
2570                    if (totalBenef == undefined || totalBenef < 3 || totalAudAmtFinal <= 10000.00) {
2571                        //   console.log('eeror true');
2572
2573                        amtErr = true;
2574                    }
2575
2576                }
2577
2578
2579                if ($("form").valid() == false) {
2580                    $('#multibenef-form-corporate-offer-modal').modal('hide');
2581                    return false;
2582                }
2583
2584                if (amtErr === true || benefErr === true) {
2585                    $('#multibenef-form-corporate-offer-modal').modal('show');
2586                    return;
2587                }
2588
2589                $('#password_validation').modal({ backdrop: 'static', keyboard: false });
2590                $('#multibenef-form-conf-modal').modal('show');
2591            });
2592        },
2593        updateAllAmts: function (amtType, elemID, response) {
2594            var splitID = elemID.split('_');
2595            var INDEX = splitID[3];
2596            var inrElemID = 'inp_amt_inr_' + INDEX;
2597            var audElemID = 'inp_amt_aud_' + INDEX;
2598            var finalRowAmt = 'row_amt_div_' + INDEX;
2599            var inrElem = $('#' + inrElemID);
2600            var inrElemError = $('#' + inrElemID + '-error');
2601            var audElem = $('#' + audElemID);
2602            var finalExRate = 'row_exchangerate_div_' + INDEX;
2603            var finalFees = 'row_fees_div_' + INDEX;
2604            var exchRateHdn = 'exch_rate_hdn_' + INDEX;
2605            var feesAmtHdn = 'fees_amt_hdn_' + INDEX;
2606            var rowExchRateHdnEle = $('#' + exchRateHdn);
2607            var rowFeesEle = $('#' + feesAmtHdn);
2608
2609            if (amtType == 'AUD') {
2610                inrElem.val(response.foreign_currency_amount);
2611                audElem.val((Math.round(Eremit.Utility.parseCurrency(response.original_amount) * 100) / 100).toFixed(2));
2612                document.getElementById(finalRowAmt).innerHTML = '<h5 class="row-amt">$' + (isNaN(response.original_amount) === false ? (Math.round(response.original_amount * 100) / 100).toFixed(2) : '0.00') + '</h5>';
2613            } else if (amtType == 'INR') {
2614                audElem.val(response.foreign_currency_amount);
2615                inrElem.val((Math.round(Eremit.Utility.parseCurrency(response.original_amount) * 100) / 100).toFixed(2));
2616                document.getElementById(finalRowAmt).innerHTML = '<h5 class="row-amt">$' + (isNaN(response.foreign_currency_amount) === false ? (Math.round(response.foreign_currency_amount * 100) / 100).toFixed(2) : '0.00') + '</h5>';
2617            }
2618
2619            if (amtType == 'AUD' || amtType == 'INR') {
2620                document.getElementById(finalFees).innerHTML = '$' + (isNaN(response.applied_fee) === false ? (Math.round(response.applied_fee * 100) / 100).toFixed(2) : '0.00');
2621                document.getElementById(finalExRate).innerHTML = (isNaN(response.applied_rate) === false ? (Math.round(response.applied_rate * 100) / 100).toFixed(2) : '0.00');
2622                rowExchRateHdnEle.val((isNaN(response.applied_rate) === false ? (Math.round(response.applied_rate * 100) / 100).toFixed(2) : '0.00'));
2623                rowFeesEle.val((isNaN(response.applied_fee) === false ? (Math.round(response.applied_fee * 100) / 100).toFixed(2) : '0.00'));
2624
2625                $('.last_col_' + INDEX + ' .applied_promotion_id').val(response.applied_promotion_id);
2626                $('.last_col_' + INDEX + ' .loyaltypoint_elig').val(response.loyaltypoint_elig);
2627                $('.last_col_' + INDEX + ' .standard_fees_hdn').val(response.original_fee);
2628                $('.last_col_' + INDEX + ' .card_rate_hdn').val(response.original_rate);
2629                $('.last_col_' + INDEX + ' .fee_disc_text_hdn').val(response.fee_discount_text);
2630                if (response.benefit_text != null) {
2631                    $('.last_col_' + INDEX + ' a.benefit-text').removeClass('d-none').attr('title', response.benefit_text);
2632                } else {
2633                    $('.last_col_' + INDEX + ' a.benefit-text').addClass('d-none').attr('title', '');
2634                }
2635            }
2636        },
2637        updateTotalAUDAmt: function () {
2638            // $('#loadingDiv').removeClass('d-none');
2639            var totalAUDAmount = 0.00;
2640            var totalINRAmount = 0.00;
2641            var totalFees = 0.00;
2642            $('.custom_amt_aud').each(function (i, obj) {
2643                var textBoxValue = $(this).val();
2644                textBoxValue = parseFloat(textBoxValue);
2645                textBoxValueFinal = (isNaN(textBoxValue)) ? '' : textBoxValue.toFixed(2);
2646
2647                if (textBoxValueFinal > 0.00) {
2648                    totalAUDAmount += parseFloat(textBoxValueFinal);
2649                }
2650            });
2651
2652            $('.custom_amt_inr').each(function (i, obj) {
2653                var textBoxValue = $(this).val();
2654                textBoxValue = parseFloat(textBoxValue);
2655                textBoxValueFinal = (isNaN(textBoxValue)) ? '' : textBoxValue.toFixed(2);
2656
2657                if (textBoxValueFinal > 0.00) {
2658                    totalINRAmount += parseFloat(textBoxValueFinal);
2659                }
2660            });
2661
2662            $('.row-fees-div').each(function (i, obj) {
2663                var textBoxValue = $(this).html();
2664                var split_id = textBoxValue.split('$');
2665                var amt = split_id[1];
2666                amt = parseFloat(amt);
2667                if (!isNaN(amt) && amt > 0.00) {
2668                    totalFees += parseFloat(amt);
2669                }
2670            });
2671
2672            var FullAmtAUD = (isNaN(totalAUDAmount)) ? 'Error' : totalAUDAmount.toFixed(2);
2673            var FullAmtINR = (isNaN(totalINRAmount)) ? 'Error' : totalINRAmount.toFixed(2);
2674            var FullFees = (isNaN(totalFees)) ? 'Error' : totalFees.toFixed(2);
2675            $('.total_aud_amount_hdn').val((Math.round(parseFloat(FullAmtAUD) * 100) / 100).toFixed(2));
2676            $('.total_inr_amount_hdn').val((Math.round(parseFloat(FullAmtINR) * 100) / 100).toFixed(2));
2677            $('.total_fees_amount_hdn').val((Math.round(parseFloat(FullFees) * 100) / 100).toFixed(2));
2678            $('.foreign_currency_amount_text').html('$' + (Math.round(parseFloat(FullAmtAUD) * 100) / 100).toFixed(2));
2679            $('.base_currency_amount_text').html((Math.round(parseFloat(FullAmtINR) * 100) / 100).toFixed(2));
2680            $('.total_fees_amount_text').html('$' + (Math.round(parseFloat(FullFees) * 100) / 100).toFixed(2));
2681            // $('#loadingDiv').addClass('d-none');
2682        },
2683        resetAllAmts: function (amtType, elemID, response) {
2684            var splitID = elemID.split('_');
2685            var INDEX = splitID[3];
2686            var inrElemID = 'inp_amt_inr_' + INDEX;
2687            var audElemID = 'inp_amt_aud_' + INDEX;
2688            var finalRowAmt = 'row_amt_div_' + INDEX;
2689            var inrElem = $('#' + inrElemID);
2690            var audElem = $('#' + audElemID);
2691            var finalExRate = 'row_exchangerate_div_' + INDEX;
2692            var finalFees = 'row_fees_div_' + INDEX;
2693            var exchRateHdn = 'exch_rate_hdn_' + INDEX;
2694            var feesAmtHdn = 'fees_amt_hdn_' + INDEX;
2695            var rowExchRateHdnEle = $('#' + exchRateHdn);
2696            var rowFeesEle = $('#' + feesAmtHdn);
2697
2698            audElem.val('0.00');
2699            inrElem.val('0.00');
2700            rowExchRateHdnEle.val('0.00');
2701            rowFeesEle.val('0.00');
2702            $('.last_col_' + INDEX + ' a.benefit-text').addClass('d-none').attr('title', '');
2703            $('.last_col_' + INDEX + ' .applied_promotion_id').val('');
2704            $('.last_col_' + INDEX + ' .loyaltypoint_elig').val('');
2705            $('.last_col_' + INDEX + ' .standard_fees_hdn').val('');
2706            $('.last_col_' + INDEX + ' .card_rate_hdn').val('');
2707            $('.last_col_' + INDEX + ' .fee_disc_text_hdn').val('');
2708            document.getElementById(finalRowAmt).innerHTML = '<h5 class="row-amt">$0.00</h5>';
2709            document.getElementById(finalExRate).innerHTML = '0.00';
2710            document.getElementById(finalFees).innerHTML = '$0.00';
2711            Eremit.Utility.handleUserDefineError(response.error);
2712        },
2713        handleAmountCalculation: function (amtType, elemID, requestData) {
2714            if (requestData) {
2715                $.ajax({
2716                    type: "POST",
2717                    url: moduleConfig.currencyConverterUrl,
2718                    data: requestData,
2719                    cache: false,
2720                    success: function (response) {
2721                        var response = JSON.parse(response);
2722
2723                        if (response.status == true) {
2724                            Eremit.MultiBenefPage.updateAllAmts(amtType, elemID, response);
2725                        } else {
2726                            Eremit.MultiBenefPage.resetAllAmts(amtType, elemID, response);
2727                        }
2728                        Eremit.MultiBenefPage.updateTotalAUDAmt();
2729                    },
2730                    error: function (XMLHttpRequest, textStatus, errorThrown) {
2731                        //Eremit.MultiBenefPage.resetAllAmts(amtType, elemID, response);
2732                        Eremit.MultiBenefPage.updateTotalAUDAmt();
2733                    }
2734                });
2735            }
2736        },
2737        paymentMethodChangeEventMultiBenef: function () {
2738            var purposeOfTransfer = $("#purpose_of_transfer").val();
2739            var covidpurpose = 0;
2740
2741            if (purposeOfTransfer == 'Covid-19 - Medical Emergency') {
2742                covidpurpose = 1;
2743            }
2744
2745            // Check if Corporate offer selected
2746            var corpMultiBeneOffer = $("input[name='applied_corporate_offer']:checked").val();
2747            var corpMultiBeneOfferVal = 0;
2748
2749            if (corpMultiBeneOffer != undefined && corpMultiBeneOffer == '1') {
2750                corpMultiBeneOfferVal = 1;
2751            }
2752
2753            if ($('.custom_amt_aud').length > 0) {
2754                $('.custom_amt_aud').each(function (i, obj) {
2755                    var audAmtValue = $(this).val();
2756                    var elemID = $(this).attr('id');
2757                    var splitID = elemID.split('_');
2758                    var INDEX = splitID[3];
2759                    var inrAmtValue = $('#inp_amt_inr_' + INDEX).val();
2760                    var switchEleVal = $('.currency-switch #currency_type_' + INDEX + ':checked').val();
2761
2762                    if (switchEleVal == 'aud') {
2763                        if (audAmtValue > 0.00) {
2764                            Eremit.MultiBenefPage.handleAmountCalculation('AUD', $(this).attr('id'), {
2765                                'base_currency': 1,
2766                                'exchange_currency': 2,
2767                                'payment_method': $("input[name='payment_method']:checked").val(),
2768                                'amount': audAmtValue,
2769                                'covidpurpose': covidpurpose,
2770                                'is_multi_benef_amt': '1',
2771                                'corpMultiBeneOffer': corpMultiBeneOfferVal
2772                            });
2773                        } else if ($('.custom_amt_aud').length == 1 && audAmtValue == '') {
2774                            return;
2775                        } else if (audAmtValue <= 0) {
2776                            Eremit.Utility.handleUserDefineError("Transfer amount has to be more than remittance fee.");
2777                        }
2778                    } else if (switchEleVal == 'inr') {
2779                        if (inrAmtValue > 0.00) {
2780                            Eremit.MultiBenefPage.handleAmountCalculation('INR', $(this).attr('id'), {
2781                                'base_currency': 2,
2782                                'exchange_currency': 1,
2783                                'payment_method': $("input[name='payment_method']:checked").val(),
2784                                'amount': inrAmtValue,
2785                                'covidpurpose': covidpurpose,
2786                                'is_multi_benef_amt': '1',
2787                                'corpMultiBeneOffer': corpMultiBeneOfferVal
2788                            });
2789                        } else if ($('.custom_amt_aud').length == 1 && inrAmtValue == '') {
2790                            return;
2791                        } else if (inrAmtValue <= 0) {
2792                            Eremit.Utility.handleUserDefineError("Transfer amount has to be more than remittance fee.");
2793                        }
2794                    }
2795                });
2796            }
2797        },
2798    },
2799    AddBeneficiaries: {
2800        AccountNo: function () {
2801            var $input = $("#Account_Number"),
2802                $AccountNumber = $("#Account_No");
2803            $input.on("focus", function (event) {
2804                $input.val($AccountNumber.val());
2805                $input.attr('readonly', false);
2806            });
2807            $input.on("blur", function (event) {
2808                $input.attr('readonly', true);
2809                var text = $input.val(),
2810                    total = text.length,
2811                    maskString = Eremit.Utility.repeatString("X", total - 4);
2812                $AccountNumber.val($input.val());
2813                if (total > 4) {
2814                    var newText = text.substring(0, 2) + maskString + text.substring(total - 2, total);
2815                    $input.val(newText);
2816                }
2817            });
2818        },
2819        IFSCCode: function () {
2820            $("#IFSC_Code").keyup(function () {
2821                $('#IFSC_Code-error').removeAttr('style');
2822            })
2823            $("#IFSC_Code").focusout(function () {
2824                $('#IFSC_Code-error').removeAttr('style');
2825            })
2826            // IFSCcode autocomplate
2827            $("#IFSC_Code").autocomplete({
2828                delay: 300,
2829                scroll: true,
2830                source: function (request, response) {
2831                    $.ajax({
2832                        url: moduleConfig.IFSCCodeUrl,
2833                        type: "post",
2834                        dataType: "json",
2835                        sync: true,
2836                        data: {
2837                            term: request.term
2838                        },
2839                        success: function (data) {
2840                            $('#IFSC_Code-error').removeAttr('style');
2841                            $('#error-ifsc-code').addClass('d-none');
2842                            $('#is_fcra_account_div').addClass('d-none');
2843                            $("#beneficiarySave").attr("disabled", false);
2844                            $("#fcra_msg").html('');
2845                            $('input[type=radio][name=is_fcra_account]').iCheck('uncheck');
2846                            $('#BBank_Name').val('');
2847                            $('#BBranch').val('');
2848                            $('#BAddress').val('');
2849                            $('#BIFSC_Code').val('');
2850                            $('#IFSC_Code_ID').val('');
2851
2852                            response($.map(data, function (item) {
2853                                return {
2854                                    label: item.IFSC_Code,
2855                                    value: item.IFSC_Code
2856                                };
2857                            }));
2858                        },
2859                        error: function (XMLHttpRequest, textStatus, errorThrown) {
2860                            $('#is_fcra_account_div').addClass('d-none');
2861                            $("#beneficiarySave").attr("disabled", false);
2862                            $("#fcra_msg").html('');
2863                            $('input[type=radio][name=is_fcra_account]').iCheck('uncheck');
2864                            $('#BBank_Name').val('');
2865                            $('#BBranch').val('');
2866                            $('#BAddress').val('');
2867                            $('#BIFSC_Code').val('');
2868                            $('#IFSC_Code_ID').val('');
2869                            Eremit.Utility.handleAjaxValidationErorrs(XMLHttpRequest, textStatus, errorThrown);
2870                        },
2871                    });
2872                },
2873                minLength: 4,
2874                select: function (event, ui) {
2875                    var selectedValue = ui.item.value;
2876                    $.ajax({
2877                        url: moduleConfig.IFSCCodeUrl,
2878                        type: "post",
2879                        dataType: "json",
2880                        sync: true,
2881                        data: {
2882                            IfscCode: selectedValue
2883                        },
2884                        success: function (response) {
2885                            if (response.status == true) {
2886                                $data = response.data;
2887                                $("#beneficiarySave").attr("disabled", false);
2888                                $("#fcra_msg").html('');
2889                                $('input[type=radio][name=is_fcra_account]').iCheck('uncheck');
2890
2891                                if ($data.IFSC_Code.toLowerCase() == 'sbin0000691') {
2892                                    $('#is_fcra_account_div').removeClass('d-none');
2893                                } else {
2894                                    $('#is_fcra_account_div').addClass('d-none');
2895                                }
2896
2897                                $('#BBank_Name').val($data.Bank_Name);
2898                                $('#BBranch').val($data.Branch_Name);
2899                                $('#BAddress').val($data.Address);
2900                                $('#BIFSC_Code').val($data.IFSC_Code);
2901                                $('#IFSC_Code_ID').val($data.Auto_ID);
2902                            } else {
2903                                $('#BBank_Name').val('');
2904                                $('#BBranch').val('');
2905                                $('#BAddress').val('');
2906                                $('#BIFSC_Code').val('');
2907                                $('#IFSC_Code_ID').val('');
2908                                $('#is_fcra_account_div').addClass('d-none');
2909                                $("#beneficiarySave").attr("disabled", false);
2910                                $("#fcra_msg").html('');
2911                                $('input[type=radio][name=is_fcra_account]').iCheck('uncheck');
2912                                $('#IFSC_Code-error').removeAttr('style');
2913                                $('#IFSC_Code-error').html(response.data);
2914                                $('#IFSC_Code-error').removeClass('d-none');
2915
2916                            }
2917                        },
2918                    });
2919                }
2920            });
2921            // On click of validate button check ifsccode
2922            $('#ifsc-find').click(function (e) {
2923                e.preventDefault();
2924                $('#IFSC_Code-error').removeAttr('style');
2925                $('#IFSC_Code-error').addClass('d-none');
2926                var $valid = $(".form-validate-jquery").valid();
2927                if (!$valid) {
2928                    Eremit.Validate.$AddBeneficiaries.focusInvalid();
2929                    return false;
2930                } else {
2931                    if ($('#IFSC_Code').valid()) {
2932                        $.ajax({
2933                            type: "POST",
2934                            url: moduleConfig.IFSCCodeUrl,
2935                            data: {
2936                                IfscCode: $('#IFSC_Code').val()
2937                            },
2938                            cache: false,
2939                            success: function (response) {
2940                                var response = JSON.parse(response);
2941
2942                                $("#beneficiarySave").attr("disabled", false);
2943                                $("#fcra_msg").html('');
2944                                $('input[type=radio][name=is_fcra_account]').iCheck('uncheck');
2945
2946                                if (response.status == true) {
2947                                    $data = response.data;
2948
2949                                    if ($data.IFSC_Code.toLowerCase() == 'sbin0000691') {
2950                                        $('#is_fcra_account_div').removeClass('d-none');
2951                                    } else {
2952                                        $('#is_fcra_account_div').addClass('d-none');
2953                                    }
2954                                    $('#BBank_Name').val($data.Bank_Name);
2955                                    $('#BBranch').val($data.Branch_Name);
2956                                    $('#BAddress').val($data.Address);
2957                                    $('#BIFSC_Code').val($data.IFSC_Code);
2958                                    $('#IFSC_Code_ID').val($data.Auto_ID);
2959                                } else {
2960                                    $('#is_fcra_account_div').addClass('d-none');
2961                                    $('#BBank_Name').val('');
2962                                    $('#BBranch').val('');
2963                                    $('#BAddress').val('');
2964                                    $('#BIFSC_Code').val('');
2965                                    $('#IFSC_Code_ID').val('');
2966                                    $('#IFSC_Code-error').removeAttr('style');
2967                                    $('#IFSC_Code-error').html(response.data);
2968                                    $('#IFSC_Code-error').removeClass('d-none');
2969                                }
2970                            },
2971                            error: function (XMLHttpRequest, textStatus, errorThrown) {
2972                                Eremit.Utility.handleAjaxValidationErorrs(XMLHttpRequest, textStatus, errorThrown);
2973                            }
2974                        });
2975                    }
2976                }
2977            });
2978            $('body').on('click', '.bene-modal-close', function (e) {
2979                $('#IFSC_Code').prop('disabled', false);
2980                $('#ifsc-find').prop('disabled', false);
2981                $('#IFSC_Code').prop('required', true);
2982                $('#IFSC_Code_label').addClass('required');
2983            });
2984            $('#search_ifsc_codes').click(function (e) {
2985                $('#ifsc').prop("checked", false);
2986                $('#IFSC_Code').val('');
2987                $('#IFSC_Code').prop('disabled', true);
2988                $('#ifsc-find').prop('disabled', true);
2989                $('#IFSC_Code').prop('required', false);
2990                $('#IFSC_Code_label').removeClass('required');
2991                $('#IFSC_Code-error').removeAttr('style');
2992                $('#IFSC_Code-error').addClass('d-none');
2993                var $valid = $(".form-validate-jquery").valid();
2994                if (!$valid) {
2995                    Eremit.Validate.$AddBeneficiaries.focusInvalid();
2996                    $('#IFSC_Code').prop('disabled', false);
2997                    $('#ifsc-find').prop('disabled', false);
2998                    $('#IFSC_Code').prop('required', true);
2999                    $('#IFSC_Code_label').addClass('required');
3000                    return false;
3001                } else {
3002                    $('#branch-detail-block').removeClass('d-none');
3003                    $("#find-branch").modal('show');
3004                }
3005            });
3006            $('#show_branches, #narrow_search').on('click', function (event) {
3007                Eremit.Validate.searchIfscCodes();
3008                var $valid = $(".searchifsccodes").valid();
3009                if (!$valid) {
3010                    Eremit.Validate.$searchIfscCodesvalidator.focusInvalid();
3011                    return false;
3012                } else {
3013                    var data = new FormData($('.searchifsccodes')[0]);
3014                    event.preventDefault();
3015                    $.ajax({
3016                        type: "POST",
3017                        url: moduleConfig.searchIfscCodeURL,
3018                        data: data,
3019                        cache: false,
3020                        processData: false,
3021                        contentType: false,
3022                        success: function (response) {
3023                            var response = JSON.parse(response);
3024                            if (response.status == true) {
3025                                $('#ifsc-code-table').html(response.data);
3026                                $('#ifsc-code-table').removeClass('d-none');
3027                            } else {
3028                                $('#ifsc-code-table').html(response.data);
3029                                $('#ifsc-code-table').removeClass('d-none');
3030                            }
3031                            window.scrollTo(0, 0);
3032                        },
3033                        error: function (XMLHttpRequest, textStatus, errorThrown) {
3034                            Eremit.Utility.handleAjaxValidationErorrs(XMLHttpRequest, textStatus, errorThrown);
3035                        }
3036                    });
3037                }
3038            });
3039            $('body').on('click', '#submit-ifsc-code', function (e) {
3040                var $lengthOfselectedCode = $('input[name=ifsc_code_radio_button]:checked').length;
3041                if ($lengthOfselectedCode > 0) {
3042                    var $data = $('input[name=ifsc_code_radio_button]:checked').data();
3043
3044                    $("#beneficiarySave").attr("disabled", false);
3045                    $("#fcra_msg").html('');
3046                    $('input[type=radio][name=is_fcra_account]').iCheck('uncheck');
3047
3048                    if ($data.ifsc_code.toLowerCase() == 'sbin0000691') {
3049                        $('#is_fcra_account_div').removeClass('d-none');
3050                    } else {
3051                        $('#is_fcra_account_div').addClass('d-none');
3052                    }
3053                    $('#BBank_Name').val($data.bank_name);
3054                    $('#BBranch').val($data.branch_name);
3055                    $('#BAddress').val($data.address);
3056                    $('#BIFSC_Code').val($data.ifsc_code);
3057                    $('#IFSC_Code_ID').val($data.auto_id);
3058                    $('#find-branch').modal('hide');
3059                    // add value in validate ifsc field as discussed with utkarsh
3060                    $('#IFSC_Code').val($data.ifsc_code);
3061                } else {
3062                    $("#beneficiarySave").attr("disabled", false);
3063                    $("#fcra_msg").html('');
3064                    $('input[type=radio][name=is_fcra_account]').iCheck('uncheck');
3065
3066                    $('#is_fcra_account_div').addClass('d-none');
3067                    $('#BBank_Name').val('');
3068                    $('#BBranch').val('');
3069                    $('#BAddress').val('');
3070                    $('#BIFSC_Code').val('');
3071                    $('#IFSC_Code_ID').val('');
3072                    $('#error-ifsc-code').removeClass('d-none');
3073                    $('#error-ifsc-code').html('Please select branch.');
3074                }
3075            });
3076        },
3077        BICCode: function () {
3078            $("#BIC_Code").keyup(function () {
3079                $("#Int_BIC_Code-error").removeAttr('style');
3080                $('#BIC_Code-error').removeAttr('style');
3081            })
3082            $("#BIC_Code").focusout(function () {
3083                $("#Int_BIC_Code-error").removeAttr('style');
3084                $('#BIC_Code-error').removeAttr('style');
3085            })
3086            if ($('#is_int_bic_on').val() == 1) {
3087                $('#intermediate_section').removeClass('d-none');
3088            } else {
3089                $('#intermediate_section').addClass('d-none');
3090            }
3091            $("#Int_BIC_Code-error").removeAttr('style');
3092            $('#BIC_Code-error').removeAttr('style');
3093            // BIC Code autocomplate
3094            $("#BIC_Code").autocomplete({
3095                delay: 300,
3096                scroll: true,
3097                source: function (request, response) {
3098                    $.ajax({
3099                        url: moduleConfig.BicCodeUrl,
3100                        type: "post",
3101                        dataType: "json",
3102                        sync: true,
3103                        data: {
3104                            term: request.term,
3105                            biccode: true,
3106                        },
3107                        success: function (data) {
3108                            $('#BIC_Code-error').removeAttr('style');
3109                            $('#BIC_Code-error').addClass('d-none');
3110                            $('#BBank_Name').val('');
3111                            $('#BBranch').val('');
3112                            $('#BBIC_Code').val('');
3113                            $('#BAddress').val('');
3114                            $('#BBIC_City').val('');
3115                            $('#BBIC_Country').val('');
3116                            $('#BIC_Code_ID').val('');
3117                            response($.map(data, function (item) {
3118                                return {
3119                                    label: item.bic_code,
3120                                    value: item.bic_code,
3121                                };
3122                            }));
3123                        },
3124                        error: function (XMLHttpRequest, textStatus, errorThrown) {
3125                            $('#BBank_Name').val('');
3126                            $('#BBranch').val('');
3127                            $('#BBIC_Code').val('');
3128                            $('#BAddress').val('');
3129                            $('#BBIC_City').val('');
3130                            $('#BBIC_Country').val('');
3131                            $('#BIC_Code_ID').val('');
3132                            Eremit.Utility.handleAjaxValidationErorrs(XMLHttpRequest, textStatus, errorThrown);
3133                        },
3134                    });
3135                },
3136                minLength: 4,
3137                select: function (event, ui) {
3138                    var selectedValue = ui.item.value;
3139                    $.ajax({
3140                        url: moduleConfig.selectBicCodeURL,
3141                        type: "get",
3142                        dataType: "json",
3143                        sync: true,
3144                        data: {
3145                            term: selectedValue,
3146                            type: "primary",
3147                            validatesection: true
3148                        },
3149                        success: function (response) {
3150                            $data = response;
3151                            var $showIntermidiate = true,
3152                                $countryCode = $data.bic_code.substring(4, 6),
3153                                $currentCurrency = $('#currency').val();
3154                            $('#BIC_Code-error').removeAttr('style');
3155                            $("#Int_BIC_Code-error").removeAttr('style');
3156                            if ($countryCode == "AU" && $currentCurrency == "aud") {
3157                                $('#BIC_Code-error').html("Beneficiary BIC Code should not be in an Australian Bank");
3158                                $('#BIC_Code-error').removeClass('d-none');
3159                            } else {
3160                                if ($.inArray($countryCode, moduleConfig.countryArray) != -1) {
3161                                    $showIntermidiate = false;
3162                                }
3163                                if ($currentCurrency == 'aud' && selectedValue.indexOf('SBININ') == 0) {
3164                                    $('#Int_BBIC_Code').val('SBINAU2SXXX');
3165                                    $showIntermidiate = false;
3166                                }
3167                                if ($showIntermidiate) {
3168                                    $('#routing_iban_block').addClass('d-none');
3169                                    $('#routing_iban').val('');
3170                                    $('#intermediate_section').removeClass('d-none');
3171                                    $('#is_int_bic_on').val(1);
3172                                } else {
3173                                    $('#routing_iban_block').removeClass('d-none');
3174                                    $('#intermediate_section').addClass('d-none');
3175                                    $('#is_int_bic_on').val(0);
3176                                }
3177                                $('#BBank_Name').val($data.institution_name);
3178                                $('#BBranch').val($data.branch_information);
3179                                $('#BBIC_Code').val($data.bic_code);
3180                                $('#BAddress').val($data.address);
3181                                $('#BBIC_City').val($data.city);
3182                                $('#BBIC_Country').val($data.country);
3183                                $('#BIC_Code_ID').val($data.id);
3184                            }
3185                        },
3186                    });
3187                }
3188            });
3189            $('#bic-find').click(function (e) {
3190                e.preventDefault();
3191                $('#BIC_Code-error').removeAttr('style');
3192                $('#Int_BIC_Code-error').removeAttr('style');
3193                $('#intermediate_section').addClass('d-none');
3194                $('#routing_iban_block').addClass('d-none');
3195                $('#routing_iban').val('');
3196                $('#BIC_Code-error').addClass('d-none');
3197                var $valid = $(".form-validate-jquery").valid();
3198                if (!$valid) {
3199                    Eremit.Validate.$AddBeneficiaries.focusInvalid();
3200                    return false;
3201                } else {
3202                    if ($('#BIC_Code').valid()) {
3203                        $.ajax({
3204                            type: "POST",
3205                            url: moduleConfig.BicCodeUrl,
3206                            data: {
3207                                BicCode: $('#BIC_Code').val()
3208                            },
3209                            cache: false,
3210                            success: function (response) {
3211                                var response = JSON.parse(response);
3212                                var selectedValue = $('#BIC_Code').val();
3213                                if (response.status == true) {
3214                                    $data = response.data;
3215                                    $('#BIC_Code-error').removeAttr('style');
3216                                    $("#Int_BIC_Code-error").removeAttr('style');
3217                                    var $showIntermidiate = true,
3218                                        $countryCode = $data.bic_code.substring(4, 6),
3219                                        $currentCurrency = $('#currency').val();
3220                                    if ($countryCode == "AU" && $currentCurrency == "aud") {
3221                                        $('#BIC_Code-error').html("Beneficiary BIC Code should not be in an Australian Bank");
3222                                        $('#BIC_Code-error').removeClass('d-none');
3223                                    } else {
3224                                        if ($.inArray($countryCode, moduleConfig.countryArray) != -1) {
3225                                            $showIntermidiate = false;
3226                                        }
3227                                        if ($currentCurrency == 'aud' && selectedValue.indexOf('SBININ') == 0) {
3228                                            $('#Int_BBIC_Code').val('SBINAU2SXXX');
3229                                            $showIntermidiate = false;
3230                                        }
3231                                        if ($showIntermidiate) {
3232                                            $('#routing_iban_block').addClass('d-none');
3233                                            $('#routing_iban').val('');
3234                                            $('#intermediate_section').removeClass('d-none');
3235                                            $('#is_int_bic_on').val(1);
3236                                        } else {
3237                                            $('#routing_iban_block').removeClass('d-none');
3238                                            $('#intermediate_section').addClass('d-none');
3239                                            $('#is_int_bic_on').val(0);
3240                                        }
3241                                        $('#BBank_Name').val($data.institution_name);
3242                                        $('#BBranch').val($data.branch_information);
3243                                        $('#BBIC_Code').val($data.bic_code);
3244                                        $('#BAddress').val($data.address);
3245                                        $('#BBIC_City').val($data.city);
3246                                        $('#BBIC_Country').val($data.country);
3247                                        $('#BIC_Code_ID').val($data.id);
3248                                    }
3249                                } else {
3250                                    $('#BBank_Name').val('');
3251                                    $('#BBranch').val('');
3252                                    $('#BBIC_Code').val('');
3253                                    $('#BAddress').val('');
3254                                    $('#BBIC_City').val('');
3255                                    $('#BBIC_Country').val('');
3256                                    $('#BIC_Code_ID').val('');
3257                                    $('#BIC_Code-error').removeAttr('style');
3258                                    $('#BIC_Code-error').html(response.data);
3259                                    $('#BIC_Code-error').removeClass('d-none');
3260                                }
3261                            },
3262                            error: function (XMLHttpRequest, textStatus, errorThrown) {
3263                                $('#BBank_Name').val('');
3264                                $('#BBranch').val('');
3265                                $('#BBIC_Code').val('');
3266                                $('#BAddress').val('');
3267                                $('#BBIC_City').val('');
3268                                $('#BBIC_Country').val('');
3269                                $('#BIC_Code_ID').val('');
3270                                Eremit.Utility.handleAjaxValidationErorrs(XMLHttpRequest, textStatus, errorThrown);
3271                            }
3272                        });
3273                    }
3274                }
3275            });
3276            $('#search_bic_codes').click(function (e) {
3277                $('#BIC_Code').val('');
3278                $('#BIC_Code').prop('disabled', true);
3279                $('#bic-find').prop('disabled', true);
3280                $('#BIC_Code').prop('required', false);
3281                $('#BIC_Code_label').removeClass('required');
3282                $('#BIC_Code-error').removeAttr('style');
3283                $('#BIC_Code-error').addClass('d-none');
3284                var $valid = $(".form-validate-jquery").valid();
3285                if (!$valid) {
3286                    Eremit.Validate.$AddBeneficiaries.focusInvalid();
3287                    return false;
3288                } else {
3289                    $('#branch-detail-block').removeClass('d-none');
3290                    $('#find-branch').modal('show');
3291                }
3292            });
3293            $('.npr-countries').change(function () {
3294                var optionSelected = $('option:selected', $(this)).val();
3295
3296                // if (optionSelected == 'Nepal') {
3297                //     $('.npr-selectbox-states').removeAttr('style');
3298                //     $('.npr-textbox').addClass('d-none');
3299                //     $('.npr-state-txtbox').attr('name', 'State1');
3300                //     $('.npr-states').attr('name', 'State');
3301                //     $('#State').val('');
3302                // } else {
3303                //     $('.npr-textbox').removeAttr('style');
3304                //     $('.npr-selectbox-states').addClass('d-none');
3305                //     $('.npr-state-txtbox').attr('name', 'State');
3306                //     $('.npr-states').attr('name', 'State1');
3307                //     $('#State').val('');
3308                // }
3309
3310                if (optionSelected == 'Nepal') {
3311                    $('.npr-textbox').addClass('d-none');
3312                    $('.npr-selectbox-states').removeClass('d-none');
3313                    $('.npr-state-txtbox').attr('name', 'State1');
3314                    $('.npr-states').attr('name', 'State');
3315                    $('#State').val('');
3316                } else {
3317                    $('.npr-textbox').removeClass('d-none');
3318                    $('.npr-selectbox-states').addClass('d-none');
3319                    $('.npr-state-txtbox').attr('name', 'State');
3320                    $('.npr-states').attr('name', 'State1');
3321                    $('#State').val('');
3322                }
3323            });
3324            // bank_names autocomplete
3325            $("#bank_names").autocomplete({
3326                delay: 300,
3327                scroll: true,
3328                source: function (request, response) {
3329                    $.ajax({
3330                        url: moduleConfig.searchBicCodeURL,
3331                        type: "get",
3332                        dataType: "json",
3333                        sync: true,
3334                        data: {
3335                            term: request.term
3336                        },
3337                        success: function (data) {
3338                            $('#error-bic-code').addClass('d-none');
3339                            response($.map(data, function (item) {
3340                                return {
3341                                    label: item.institution_name,
3342                                    value: item.institution_name
3343                                };
3344                            }));
3345                        },
3346                        error: function (XMLHttpRequest, textStatus, errorThrown) {
3347                            Eremit.Utility.handleAjaxValidationErorrs(XMLHttpRequest, textStatus, errorThrown);
3348                        },
3349                    });
3350                },
3351                minLength: 4,
3352                select: function (event, ui) {
3353                    var selectedValue = ui.item.value;
3354                    $.ajax({
3355                        url: moduleConfig.selectBicCodeURL,
3356                        type: "get",
3357                        dataType: "json",
3358                        sync: true,
3359                        data: {
3360                            term: selectedValue,
3361                            type: "primary"
3362                        },
3363                        success: function (response) {
3364                            $('#bic-code-table').html(response.data);
3365                            $('#bic-code-table').removeClass('d-none');
3366                        },
3367                    });
3368                }
3369            });
3370            $('body').on('click', '#submit-bic-code', function (e) {
3371                var $lengthOfselectedCode = $('input[name=bic_code_radio_button]:checked').length;
3372                if ($lengthOfselectedCode > 0) {
3373                    var $data = $('input[name=bic_code_radio_button]:checked').data();
3374                    var $showIntermidiate = true,
3375                        $countryCode = $data.bic_code.substring(4, 6),
3376                        $currentCurrency = $('#currency').val();
3377                    if ($.inArray($countryCode, moduleConfig.countryArray) != -1) {
3378                        $showIntermidiate = false;
3379                    }
3380                    if ($currentCurrency == 'aud' && selectedValue.indexOf('SBININ') == 0) {
3381                        $('#Int_BBIC_Code').val('SBINAU2SXXX');
3382                        $showIntermidiate = false;
3383                    }
3384                    if ($showIntermidiate) {
3385                        $('#routing_iban_block').addClass('d-none');
3386                        $('#routing_iban').val('');
3387                        $('#intermediate_section').removeClass('d-none');
3388                        $('#is_int_bic_on').val(1);
3389                    } else {
3390                        $('#routing_iban_block').removeClass('d-none');
3391                        $('#intermediate_section').addClass('d-none');
3392                        $('#is_int_bic_on').val(0);
3393                    }
3394                    $('#BBank_Name').val($data.institution_name);
3395                    $('#BBranch').val($data.branch_information);
3396                    $('#BBIC_Code').val($data.bic_code);
3397                    $('#BAddress').val($data.address);
3398                    $('#BBIC_City').val($data.city);
3399                    $('#BBIC_Country').val($data.country);
3400                    $('#BIC_Code_ID').val($data.id);
3401                    // As discussed vwith utkarsh add selected bitcode in validate box
3402                    $('#BIC_Code').val($data.bic_code);
3403                    $('#find-branch').modal('hide');
3404                } else {
3405                    $('#BBank_Name').val('');
3406                    $('#BBranch').val('');
3407                    $('#BBIC_Code').val('');
3408                    $('#BAddress').val('');
3409                    $('#BBIC_City').val('');
3410                    $('#BBIC_Country').val('');
3411                    $('#BIC_Code_ID').val('');
3412                    $('#error-bic-code').removeClass('d-none');
3413                    $('#error-bic-code').html('Please select branch.');
3414                }
3415            });
3416            $('body').on('change', '.npr-selectbox', function (e) {
3417                e.preventDefault();
3418                e.stopPropagation();
3419                var id = $(this).val();
3420                $.ajax({
3421                    url: moduleConfig.selectBicCodeURL,
3422                    type: "get",
3423                    dataType: "json",
3424                    sync: true,
3425                    data: {
3426                        nprid: id
3427                    },
3428                    success: function (response) {
3429                        $data = response;
3430                        $('#BBank_Name').val($data.institution_name);
3431                        $('#BBranch').val($data.branch_information);
3432                        $('#BBIC_Code').val($data.bic_code);
3433                        $('#BAddress').val($data.address);
3434                        $('#BBIC_City').val($data.city);
3435                        $('#BBIC_Country').val($data.country);
3436                        $('#BIC_Code_ID').val($data.id);
3437                    },
3438                });
3439            });
3440        },
3441        IntermediateBICCode: function () {
3442            // Int BIC Code autocomplate
3443            $("#Int_BIC_Code").keyup(function () {
3444                $("#Int_BIC_Code-error").removeAttr('style');
3445            })
3446            $("#Int_BIC_Code").focusout(function () {
3447                $("#Int_BIC_Code-error").removeAttr('style');
3448            })
3449            $(".int_bic_section").focusout(function () {
3450                $("#Int_BIC_Code-error").removeAttr('style');
3451            })
3452            $("#Int_BIC_Code-error").removeAttr('style');
3453            $("#Int_BIC_Code").autocomplete({
3454                delay: 300,
3455                scroll: true,
3456                source: function (request, response) {
3457                    $.ajax({
3458                        url: moduleConfig.BicCodeUrl,
3459                        type: "post",
3460                        dataType: "json",
3461                        sync: true,
3462                        data: {
3463                            term: request.term,
3464                            biccode: true
3465                        },
3466                        success: function (data) {
3467                            $("#Int_BIC_Code-error").removeAttr('style');
3468                            $('#Int_BIC_Code-error').addClass('d-none');
3469                            $('#Int_Bank_Name').val('');
3470                            $('#Int_Branch').val('');
3471                            $('#Int_BBIC_Code').val('');
3472                            $('#Int_Address').val('');
3473                            $('#Int_BIC_City').val('');
3474                            $('#Int_BIC_Country').val('');
3475                            $('#Int_BIC_Code_ID').val('');
3476                            response($.map(data, function (item) {
3477                                return {
3478                                    label: item.bic_code,
3479                                    value: item.bic_code,
3480                                };
3481                            }));
3482                        },
3483                        error: function (XMLHttpRequest, textStatus, errorThrown) {
3484                            $('#Int_Bank_Name').val('');
3485                            $('#Int_Branch').val('');
3486                            $('#Int_BBIC_Code').val('');
3487                            $('#Int_Address').val('');
3488                            $('#Int_BIC_City').val('');
3489                            $('#Int_BIC_Country').val('');
3490                            $('#Int_BIC_Code_ID').val('');
3491                            Eremit.Utility.handleAjaxValidationErorrs(XMLHttpRequest, textStatus, errorThrown);
3492                        },
3493                    });
3494                },
3495                minLength: 4,
3496                select: function (event, ui) {
3497                    var selectedValue = ui.item.value;
3498                    $.ajax({
3499                        url: moduleConfig.selectBicCodeURL,
3500                        type: "get",
3501                        dataType: "json",
3502                        sync: true,
3503                        data: {
3504                            term: selectedValue,
3505                            type: "intermediate",
3506                            validatesection: true
3507                        },
3508                        success: function (response) {
3509                            $data = response;
3510                            $('#Int_Bank_Name').val($data.institution_name);
3511                            $('#Int_Branch').val($data.branch_information);
3512                            $('#Int_BBIC_Code').val($data.bic_code);
3513                            $('#Int_Address').val($data.address);
3514                            $('#Int_BIC_City').val($data.city);
3515                            $('#Int_BIC_Country').val($data.country);
3516                            $('#Int_BIC_Code_ID').val($data.id);
3517                        },
3518                    });
3519                }
3520            });
3521            $('#int-bic-find').click(function (e) {
3522                e.preventDefault();
3523                $("#Int_BIC_Code-error").removeAttr('style');
3524                var $valid = $(".form-validate-jquery").valid();
3525                if (!$valid) {
3526                    $("#Int_BIC_Code-error").removeAttr('style');
3527                    Eremit.Validate.$AddBeneficiaries.focusInvalid();
3528                    return false;
3529                } else {
3530                    $("#Int_BIC_Code-error").removeAttr('style');
3531                    var checkBoxStatus = $('#int_bic_code').prop("checked");
3532                    // if (checkBoxStatus) {
3533                    if ($('#Int_BIC_Code').valid()) {
3534                        $.ajax({
3535                            type: "POST",
3536                            url: moduleConfig.BicCodeUrl,
3537                            data: {
3538                                BicCode: $('#Int_BIC_Code').val()
3539                            },
3540                            cache: false,
3541                            success: function (response) {
3542                                $("#Int_BIC_Code-error").removeAttr('style');
3543                                var response = JSON.parse(response);
3544
3545                                if (response.status == true) {
3546                                    $data = response.data;
3547                                    $('#Int_Bank_Name').val($data.institution_name);
3548                                    $('#Int_Branch').val($data.branch_information);
3549                                    $('#Int_BBIC_Code').val($data.bic_code);
3550                                    $('#Int_Address').val($data.address);
3551                                    $('#Int_BIC_City').val($data.city);
3552                                    $('#Int_BIC_Country').val($data.country);
3553                                    $('#Int_BIC_Code_ID').val($data.id);
3554                                } else {
3555                                    $('#Int_Bank_Name').val('');
3556                                    $('#Int_Branch').val('');
3557                                    $('#Int_BBIC_Code').val('');
3558                                    $('#Int_Address').val('');
3559                                    $('#Int_BIC_City').val('');
3560                                    $('#Int_BIC_Country').val('');
3561                                    $('#Int_BIC_Code_ID').val('');
3562                                    $("#Int_BIC_Code-error").removeAttr('style');
3563                                    $('#Int_BIC_Code-error').html(response.data);
3564                                    $('#Int_BIC_Code-error').removeClass('d-none');
3565                                }
3566                            },
3567                            error: function (XMLHttpRequest, textStatus, errorThrown) {
3568                                $('#Int_Bank_Name').val('');
3569                                $('#Int_Branch').val('');
3570                                $('#Int_BBIC_Code').val('');
3571                                $('#Int_Address').val('');
3572                                $('#Int_BIC_City').val('');
3573                                $('#Int_BIC_Country').val('');
3574                                $('#Int_BIC_Code_ID').val('');
3575                                $("#Int_BIC_Code-error").removeAttr('style');
3576                                Eremit.Utility.handleAjaxValidationErorrs(XMLHttpRequest, textStatus, errorThrown);
3577                            }
3578                        });
3579                        // }
3580                    }
3581                }
3582            });
3583            $('#search_int_bic_codes').click(function (e) {
3584                $('#int_bic_code').prop("checked", false);
3585                $('#Int_BIC_Code').val('');
3586                $('#Int_BIC_Code').prop('disabled', true);
3587                $('#int-bic-find').prop('disabled', true);
3588                $('#Int_BIC_Code').prop('required', false);
3589                $('#Int_BIC_Code_label').removeClass('required');
3590                $("#Int_BIC_Code-error").removeAttr('style');
3591                $('#Int_BIC_Code-error').addClass('d-none');
3592                var $valid = $(".form-validate-jquery").valid();
3593                if (!$valid) {
3594                    Eremit.Validate.$AddBeneficiaries.focusInvalid();
3595                    return false;
3596                } else {
3597                    $('#int-branch-detail-block').removeClass('d-none');
3598                    $('#find-int-branch').modal('show');
3599                }
3600            });
3601            // bank_names autocomplete
3602            $("#int_bank_names").autocomplete({
3603                delay: 300,
3604                scroll: true,
3605                source: function (request, response) {
3606                    $.ajax({
3607                        url: moduleConfig.searchBicCodeURL,
3608                        type: "get",
3609                        dataType: "json",
3610                        sync: true,
3611                        data: {
3612                            term: request.term
3613                        },
3614                        success: function (data) {
3615                            $('#error-int-bic-code').addClass('d-none');
3616                            response($.map(data, function (item) {
3617                                return {
3618                                    label: item.institution_name,
3619                                    value: item.institution_name
3620                                };
3621                            }));
3622                        },
3623                        error: function (XMLHttpRequest, textStatus, errorThrown) {
3624                            Eremit.Utility.handleAjaxValidationErorrs(XMLHttpRequest, textStatus, errorThrown);
3625                        },
3626                    });
3627                },
3628                minLength: 4,
3629                select: function (event, ui) {
3630                    var selectedValue = ui.item.value;
3631                    $.ajax({
3632                        url: moduleConfig.selectBicCodeURL,
3633                        type: "get",
3634                        dataType: "json",
3635                        sync: true,
3636                        data: {
3637                            term: selectedValue,
3638                            type: "intermediate"
3639                        },
3640                        success: function (response) {
3641                            $('#int-bic-code-table').html(response.data);
3642                            $('#int-bic-code-table').removeClass('d-none');
3643                        },
3644                    });
3645                }
3646            });
3647            $('body').on('click', '#submit-inc-bic-code', function (e) {
3648                Eremit.Validate.searchIntBicCodes();
3649                var $valid = $(".searchintbiccodes").valid();
3650                if (!$valid) {
3651                    Eremit.Validate.$searchIntBicCodesvalidator.focusInvalid();
3652                    return false;
3653                } else {
3654                    var $lengthOfselectedCode = $('input[name=int_bic_code_radio_button]:checked').length;
3655                    if ($lengthOfselectedCode > 0) {
3656                        var $data = $('input[name=int_bic_code_radio_button]:checked').data();
3657                        $('#Int_Bank_Name').val($data.institution_name);
3658                        $('#Int_Branch').val($data.branch_information);
3659                        $('#Int_BBIC_Code').val($data.bic_code);
3660                        $('#Int_Address').val($data.address);
3661                        $('#Int_BIC_City').val($data.city);
3662                        $('#Int_BIC_Country').val($data.country);
3663                        $('#Int_BIC_Code_ID').val($data.id);
3664                        // add value in validate intermediate bic code field as discussed with utkarsh
3665                        $('#Int_BIC_Code').val($data.bic_code);
3666                        $('#find-int-branch').modal('hide');
3667                    } else {
3668                        $('#Int_Bank_Name').val('');
3669                        $('#Int_Branch').val('');
3670                        $('#Int_BBIC_Code').val('');
3671                        $('#Int_Address').val('');
3672                        $('#Int_BIC_City').val('');
3673                        $('#Int_BIC_Country').val('');
3674                        $('#Int_BIC_Code_ID').val('');
3675                        $('#error-inc-bic-code').removeClass('d-none');
3676                        $('#error-inc-bic-code').html('Please select branch.');
3677                    }
3678                }
3679            });
3680        }
3681    },
3682    UpdateProfile: {
3683        UpdateEmail: function () {
3684            $('#updateemail_click').click(function () {
3685                $('#old_email_address_block').addClass('d-none');
3686                $('#new_email_address_block').removeClass('d-none');
3687                $("#updateemail :input").attr("readonly", false);
3688                $(".updateemail-button").removeClass('d-none')
3689            });
3690            $("#resendemailotp-submit").on('click', function () {
3691                var data = new FormData($('#updateemail')[0]);
3692                $('#loadingDiv').removeClass('d-none');
3693                $.ajax({
3694                    type: "POST",
3695                    url: moduleConfig.resendMailOtpURL,
3696                    data: data,
3697                    cache: false,
3698                    processData: false,
3699                    contentType: false,
3700                    success: function (response) {
3701                        var response = JSON.parse(response);
3702                        if (response.status == true) {
3703                            $('#updateemail-submit').addClass('d-none');
3704                            $('#new_email').attr('readonly', 'readonly');
3705                            $('#enter_email_otp_block').removeClass('d-none');
3706                            $('#verifyemailotp-submit').removeClass('d-none');
3707                            $('#resendemailotp-submit').removeClass('d-none');
3708                            Eremit.Utility.handleUserDefineSuccess(response.data);
3709                        } else {
3710                            Eremit.Utility.handleUserDefineError(response.data);
3711                        }
3712                        $('#loadingDiv').addClass('d-none');
3713                    },
3714                    error: function (XMLHttpRequest, textStatus, errorThrown) {
3715                        Eremit.Utility.handleAjaxValidationErorrs(XMLHttpRequest, textStatus, errorThrown);
3716                        if (response.block == true) {
3717                            setTimeout(function () { location.reload(true); }, 5000);
3718                        }
3719                        $('#loadingDiv').handleCalculationSuccessResponse();
3720                    }
3721                });
3722            });
3723            $("#updateemail-submit").on('click', function () {
3724                var $valid = $("#updateemail").valid();
3725                if (!$valid) {
3726                    Eremit.Validate.$UpdateEmail.focusInvalid();
3727                    return false;
3728                } else {
3729                    var data = new FormData($('#updateemail')[0]);
3730                    $('#loadingDiv').removeClass('d-none');
3731                    $.ajax({
3732                        type: "POST",
3733                        url: moduleConfig.UpdateEmailUrl,
3734                        data: data,
3735                        cache: false,
3736                        processData: false,
3737                        contentType: false,
3738                        success: function (response) {
3739                            var response = JSON.parse(response);
3740                            if (response.status == true) {
3741                                $('#updateemail-submit').addClass('d-none');
3742                                $('#new_email').attr('readonly', 'readonly');
3743                                $('#enter_email_otp_block').removeClass('d-none');
3744                                $('#verifyemailotp-submit').removeClass('d-none');
3745                                $('#resendemailotp-submit').removeClass('d-none');
3746                                Eremit.Utility.handleUserDefineSuccess(response.data);
3747                            } else {
3748                                Eremit.Utility.handleUserDefineError(response.data);
3749                            }
3750                            $('#loadingDiv').addClass('d-none');
3751                        },
3752                        error: function (XMLHttpRequest, textStatus, errorThrown) {
3753                            Eremit.Utility.handleAjaxValidationErorrs(XMLHttpRequest, textStatus, errorThrown);
3754                            $('#loadingDiv').addClass('d-none');
3755                        }
3756                    });
3757                }
3758            });
3759            $('body').on('click', '#verifyemailotp-submit', function () {
3760                if ($('#email_otp').valid()) {
3761                    $('#email_otp_error').html('');
3762
3763                    /** Encryption  **/
3764                    var profileOldEmail = $('#old_email').val();
3765                    var profileNewEmail = $('#new_email').val();
3766                    var profileEmailOTP = $('#email_otp').val();
3767
3768                    $('#old_email').val(window.btoa(Eremit.Login.CryptoJSAesEncrypt(moduleConfig.salt, $('#old_email').val())));
3769                    $('#new_email').val(window.btoa(Eremit.Login.CryptoJSAesEncrypt(moduleConfig.salt, $('#new_email').val())));
3770                    $('#email_otp_enc').val(window.btoa(Eremit.Login.CryptoJSAesEncrypt(moduleConfig.salt, $('#email_otp').val())));
3771                    /** End Encryption **/
3772
3773                    var data = new FormData($('#updateemail')[0]);
3774                    // Removing Email_otp
3775                    data.delete('email_otp');
3776
3777                    $('#new_email').val(profileNewEmail);
3778                    data.append("type", 'email');
3779
3780                    $('#loadingDiv').removeClass('d-none');
3781                    $.ajax({
3782                        type: "POST",
3783                        url: moduleConfig.verifyOtpURL,
3784                        data: data,
3785                        cache: false,
3786                        processData: false,
3787                        contentType: false,
3788                        success: function (response) {
3789                            var response = JSON.parse(response);
3790                            if (response.status == true) {
3791                                location.reload();
3792                                $('#updateemail-submit').removeClass('d-none');
3793                                $('#new_email').removeAttr('readonly');
3794                                $('#enter_email_otp_block').addClass('d-none');
3795                                $('#verifyemailotp-submit').addClass('d-none');
3796                                $('#resendemailotp-submit').addClass('d-none');
3797                                $('#old_email').val(profileNewEmail);
3798                                $('#new_email').val('');
3799                                $('#email_otp').val('');
3800                                Eremit.Utility.handleUserDefineSuccess(response.data);
3801                            } else {
3802                                Eremit.Utility.handleUserDefineError(response.data);
3803                            }
3804                            $('#loadingDiv').addClass('d-none');
3805                        },
3806                        error: function (XMLHttpRequest, textStatus, errorThrown) {
3807                            Eremit.Utility.handleAjaxValidationErorrs(XMLHttpRequest, textStatus, errorThrown);
3808                            $('#loadingDiv').addClass('d-none');
3809                        }
3810                    });
3811                }
3812            });
3813        },
3814        UpdateMobile: function () {
3815            $('#updatemobile_click').click(function () {
3816                $('#old_mobile_number_block').addClass('d-none');
3817                $('#new_mobile_number_block').removeClass('d-none');
3818                $("#updatemobile :input").attr("readonly", false);
3819                $(".updatemobile-button").removeClass('d-none')
3820            });
3821            $("#resendmobileotp-submit").on('click', function () {
3822                var data = new FormData($('#updatemobile')[0]);
3823                data.delete('mobile_otp');
3824                data.delete('new_mobile');
3825                $('#loadingDiv').removeClass('d-none');
3826                $.ajax({
3827                    type: "POST",
3828                    url: moduleConfig.resendOtpURL,
3829                    data: data,
3830                    cache: false,
3831                    processData: false,
3832                    contentType: false,
3833                    success: function (response) {
3834                        var response = JSON.parse(response);
3835                        if (response.status == true) {
3836                            $('#updatemobile-submit').addClass('d-none');
3837                            $('#country_mobile_code').attr('readonly', 'readonly');
3838                            $('#new_mobile').attr('readonly', 'readonly');
3839                            $('#enter_otp_block').removeClass('d-none');
3840                            $('#verifymobileotp-submit').removeClass('d-none');
3841                            $('#resendmobileotp-submit').removeClass('d-none');
3842                            Eremit.Utility.handleUserDefineSuccess(response.data);
3843                        } else {
3844                            Eremit.Utility.handleUserDefineError(response.data);
3845                            if (response.block == true) {
3846                                setTimeout(function () { location.reload(true); }, 5000);
3847                            }
3848                        }
3849                        $('#loadingDiv').addClass('d-none');
3850                    },
3851                    error: function (XMLHttpRequest, textStatus, errorThrown) {
3852                        Eremit.Utility.handleAjaxValidationErorrs(XMLHttpRequest, textStatus, errorThrown);
3853                        $('#loadingDiv').addClass('d-none');
3854                    }
3855                });
3856            });
3857            $('#verifypwdform').on('keyup keypress', function (e) {
3858                var keyCode = e.keyCode || e.which;
3859                if (keyCode === 13) {
3860                    e.preventDefault();
3861                    return false;
3862                }
3863            });
3864            $("#updatemobile-submit").on('click', function () {
3865                var $valid = $("#updatemobile").valid();
3866                if (!$valid) {
3867                    Eremit.Validate.$UpdateMobile.focusInvalid();
3868                    return false;
3869                } else {
3870                    $('#password_validation').modal({ backdrop: 'static', keyboard: false });
3871
3872                    $('#password_validation').modal('show');
3873
3874                    if ($('#country_mobile_code').val() == '61') {
3875                        $('.holding_visa-field').addClass('d-none');
3876                    } else {
3877                        $('input[name="holding_visa"]').iCheck('uncheck');
3878                        $('.holding_visa-field').removeClass('d-none');
3879                    }
3880
3881                    $("div.iradio_flat-blue").removeClass('checked');
3882                    $('body').off('click', '#verifypwd').on('click', '#verifypwd', function () {
3883                        var $valid = $("#verifypwdform").valid();
3884                        if (!$valid) {
3885                            Eremit.Validate.$UpdateMobile.focusInvalid();
3886                            return false;
3887                        }
3888                        var customer_id = $('#customer_id').val();
3889                        var password = $('#password').val();
3890
3891                        $('#customer_id').val(window.btoa(Eremit.Login.CryptoJSAesEncrypt(moduleConfig.salt, $('#customer_id').val())));
3892                        $('#password').val(window.btoa(Eremit.Login.CryptoJSAesEncrypt(moduleConfig.salt, $('#password').val())));
3893
3894                        var data = new FormData($('#verifypwdform')[0]);
3895                        $('#holding_visa').val($("input[name='holding_visa']:checked").val());
3896                        $('#loadingDiv').removeClass('d-none');
3897                        $.ajax({
3898                            type: "POST",
3899                            url: moduleConfig.verifypasswordURL,
3900                            data: data,
3901                            cache: false,
3902                            processData: false,
3903                            contentType: false,
3904                            success: function (response) {
3905                                $('#password_validation').modal('hide');
3906                                $('#loadingDiv').removeClass('d-none');
3907                                $('#verifypwdform').trigger("reset");
3908                                var response = JSON.parse(response);
3909                                if (response.status == true) {
3910                                    var data = new FormData($('#updatemobile')[0]);
3911                                    $.ajax({
3912                                        type: "POST",
3913                                        url: moduleConfig.UpdateMobileURL,
3914                                        data: data,
3915                                        cache: false,
3916                                        processData: false,
3917                                        contentType: false,
3918                                        success: function (response) {
3919                                            var response = JSON.parse(response);
3920                                            if (response.status == true) {
3921                                                $('#updatemobile-submit').addClass('d-none');
3922                                                $('#country_mobile_code').attr('readonly', 'readonly');
3923                                                $('#new_mobile').attr('readonly', 'readonly');
3924                                                $('#enter_otp_block').removeClass('d-none');
3925                                                $('#verifymobileotp-submit').removeClass('d-none');
3926                                                $('#resendmobileotp-submit').removeClass('d-none');
3927                                                $('#customer_id').val(customer_id);
3928                                                $('#password').val('');
3929                                                Eremit.Utility.handleUserDefineSuccess(response.data);
3930                                            } else {
3931                                                $('#customer_id').val(customer_id);
3932                                                $('#password').val('');
3933                                                Eremit.Utility.handleUserDefineError(response.data);
3934                                            }
3935                                            $('#loadingDiv').addClass('d-none');
3936                                        },
3937                                        error: function (XMLHttpRequest, textStatus, errorThrown) {
3938                                            $('#customer_id').val(customer_id);
3939                                            $('#password').val('');
3940                                            Eremit.Utility.handleAjaxValidationErorrs(XMLHttpRequest, textStatus, errorThrown);
3941                                            $('#loadingDiv').addClass('d-none');
3942                                        }
3943                                    });
3944                                } else {
3945                                    $('input[name="holding_visa"]').iCheck('uncheck');
3946                                    $('#customer_id').val(customer_id);
3947                                    $('#password').val('');
3948                                    Eremit.Utility.handleUserDefineError(response.data);
3949                                }
3950                            },
3951                            error: function (XMLHttpRequest, textStatus, errorThrown) {
3952                                $('#password_validation').modal('hide');
3953                                $('#loadingDiv').removeClass('d-none');
3954                                $('#verifypwdform').trigger("reset");
3955                                Eremit.Utility.handleAjaxValidationErorrs(XMLHttpRequest, textStatus, errorThrown);
3956                            }
3957                        });
3958                    });
3959                }
3960            });
3961            $('body').on('click', '#verifymobileotp-submit', function () {
3962                if ($('#mobile_otp').valid()) {
3963                    $('#mobile_otp_error').html('');
3964
3965
3966                    /** Encryption  **/
3967                    var profileOldMobile = $('#old_mobile').val();
3968                    var profileNewMobile = $('#new_mobile').val();
3969                    var profileMobileOTP = $('#mobile_otp').val();
3970
3971                    $('#old_mobile').val(window.btoa(Eremit.Login.CryptoJSAesEncrypt(moduleConfig.salt, $('#old_mobile').val())));
3972                    $('#new_mobile_enc').val(window.btoa(Eremit.Login.CryptoJSAesEncrypt(moduleConfig.salt, $('#new_mobile').val())));
3973                    $('#mobile_otp_enc').val(window.btoa(Eremit.Login.CryptoJSAesEncrypt(moduleConfig.salt, $('#mobile_otp').val())));
3974                    /** End Encryption **/
3975                    var data = new FormData($('#updatemobile')[0]);
3976                    // Removing mobile_otp
3977                    data.delete('mobile_otp');
3978                    data.delete('new_mobile');
3979
3980                    data.append("type", 'mobile');
3981                    $('#loadingDiv').removeClass('d-none');
3982                    $.ajax({
3983                        type: "POST",
3984                        url: moduleConfig.verifyOtpURL,
3985                        data: data,
3986                        cache: false,
3987                        processData: false,
3988                        contentType: false,
3989                        success: function (response) {
3990                            var response = JSON.parse(response);
3991                            if (response.status == true) {
3992                                location.reload();
3993                                $('#updatemobile-submit').removeClass('d-none');
3994                                $('#country_mobile_code').removeAttr('readonly');
3995                                $('#new_mobile').removeAttr('readonly', 'readonly');
3996                                $('#enter_otp_block').addClass('d-none');
3997                                $('#verifymobileotp-submit').addClass('d-none');
3998                                $('#resendmobileotp-submit').addClass('d-none');
3999                                $('#old_mobile').val($('#country_mobile_code').val() + $('#new_mobile').val());
4000                                $('#country_mobile_code').val('61');
4001                                $('#new_mobile').val('');
4002                                $('#mobile_otp').val('');
4003                                Eremit.Utility.handleUserDefineSuccess(response.data);
4004                            } else {
4005                                Eremit.Utility.handleUserDefineError(response.data);
4006                                if (response.block == true) {
4007                                    setTimeout(function () { location.reload(true); }, 5000);
4008                                }
4009                            }
4010                            $('#loadingDiv').addClass('d-none');
4011                        },
4012                        error: function (XMLHttpRequest, textStatus, errorThrown) {
4013                            Eremit.Utility.handleAjaxValidationErorrs(XMLHttpRequest, textStatus, errorThrown);
4014                            $('#loadingDiv').addClass('d-none');
4015                        }
4016                    });
4017                }
4018            });
4019        },
4020        PasswordVerification: function () {
4021            var data = new FormData($('#updatemobile')[0]);
4022            $('#loadingDiv').removeClass('d-none');
4023            $.ajax({
4024                type: "POST",
4025                url: moduleConfig.UpdateMobileURL,
4026                data: data,
4027                cache: false,
4028                processData: false,
4029                contentType: false,
4030                success: function (response) {
4031                    var response = JSON.parse(response);
4032                    if (response.status == true) {
4033                        $('#updatemobile-submit').addClass('d-none');
4034                        $('#country_mobile_code').attr('readonly', 'readonly');
4035                        $('#new_mobile').attr('readonly', 'readonly');
4036                        $('#enter_otp_block').removeClass('d-none');
4037                        $('#verifymobileotp-submit').removeClass('d-none');
4038                        $('#resendmobileotp-submit').removeClass('d-none');
4039                        Eremit.Utility.handleUserDefineSuccess(response.data);
4040                    } else {
4041                        Eremit.Utility.handleUserDefineError(response.data);
4042                    }
4043                    $('#loadingDiv').addClass('d-none');
4044                },
4045                error: function (XMLHttpRequest, textStatus, errorThrown) {
4046                    Eremit.Utility.handleAjaxValidationErorrs(XMLHttpRequest, textStatus, errorThrown);
4047                    $('#loadingDiv').addClass('d-none');
4048                }
4049            });
4050        },
4051        UpdatePassword: function () {
4052            $('#updatepassword_click').click(function () {
4053                $("#updatepassword :input").attr("readonly", false);
4054                $("#updatesecurity :input").attr("readonly", false);
4055                $(".updatepassword-button").removeClass('d-none');
4056
4057            });
4058            $("#updatepassword-submit").on('click', function () {
4059                var $valid = $("#updatepassword").valid();
4060                if (!$valid) {
4061                    Eremit.Validate.$UpdatePassword.focusInvalid();
4062                    return false;
4063                } else {
4064                    $('#current_password').val(window.btoa(Eremit.Login.CryptoJSAesEncrypt(moduleConfig.salt, $('#current_password').val())));
4065                    $('#new_password').val(window.btoa(Eremit.Login.CryptoJSAesEncrypt(moduleConfig.salt, $('#new_password').val())));
4066                    $('#confirm_new_password').val(window.btoa(Eremit.Login.CryptoJSAesEncrypt(moduleConfig.salt, $('#confirm_new_password').val())));
4067
4068                    var data = new FormData($('#updatepassword')[0]);
4069                    data.append("type", 'password');
4070                    $('#loadingDiv').removeClass('d-none');
4071                    $.ajax({
4072                        type: "POST",
4073                        url: moduleConfig.UpdatePasswordURL,
4074                        data: data,
4075                        cache: false,
4076                        processData: false,
4077                        contentType: false,
4078                        success: function (response) {
4079                            var response = JSON.parse(response);
4080                            $('#updatepassword')[0].reset();
4081                            if (response.status == true) {
4082                                Eremit.Utility.handleUserDefineSuccess(response.data);
4083                                swal.fire({
4084                                    text: "Your password has been changed successfully. Please log in to continue..",
4085                                    type: "success"
4086                                }).then(function () {
4087                                    location.reload();
4088                                });
4089                            } else {
4090                                $('#current_password').val('');
4091                                $('#new_password').val('');
4092                                $('#confirm_new_password').val('');
4093                                Eremit.Utility.handleUserDefineError(response.data);
4094                            }
4095                            $('#loadingDiv').addClass('d-none');
4096                        },
4097                        error: function (XMLHttpRequest, textStatus, errorThrown) {
4098                            $('#current_password').val('');
4099                            $('#new_password').val('');
4100                            $('#confirm_new_password').val('');
4101                            Eremit.Utility.handleAjaxValidationErorrs(XMLHttpRequest, textStatus, errorThrown);
4102                            $('#loadingDiv').addClass('d-none');
4103                        }
4104                    });
4105                }
4106            });
4107            $("#updatesecurity-submit").on('click', function () {
4108                var $valid = $("#updatesecurity").valid();
4109                if (!$valid) {
4110                    Eremit.Validate.$UpdateSecurity.focusInvalid();
4111                    return false;
4112                } else {
4113                    var data = new FormData($('#updatesecurity')[0]);
4114                    data.append("type", 'security');
4115                    $('#loadingDiv').removeClass('d-none');
4116                    $.ajax({
4117                        type: "POST",
4118                        url: moduleConfig.UpdatePasswordURL,
4119                        data: data,
4120                        cache: false,
4121                        processData: false,
4122                        contentType: false,
4123                        success: function (response) {
4124                            var response = JSON.parse(response);
4125                            $('#updatesecurity')[0].reset();
4126                            if (response.status == true) {
4127                                Eremit.Utility.handleUserDefineSuccess(response.data);
4128                                location.reload();
4129                            } else {
4130                                Eremit.Utility.handleUserDefineError(response.data);
4131                            }
4132                            $('#loadingDiv').addClass('d-none');
4133                        },
4134                        error: function (XMLHttpRequest, textStatus, errorThrown) {
4135                            Eremit.Utility.handleAjaxValidationErorrs(XMLHttpRequest, textStatus, errorThrown);
4136                            $('#loadingDiv').addClass('d-none');
4137                        }
4138                    });
4139                }
4140            });
4141        },
4142        UpdateAddress: function () {
4143            $("#updateaddress-submit").on('click', function () {
4144                var $valid = $("#updateaddress").valid();
4145                if (!$valid) {
4146                    Eremit.Validate.$UpdateAddress.focusInvalid();
4147                    return false;
4148                } else {
4149                    var data = new FormData($('#updateaddress')[0]);
4150                    $('#loadingDiv').removeClass('d-none');
4151                    $.ajax({
4152                        type: "POST",
4153                        url: moduleConfig.UpdateAddressURL,
4154                        data: data,
4155                        cache: false,
4156                        processData: false,
4157                        contentType: false,
4158                        success: function (response) {
4159                            var response = JSON.parse(response);
4160                            if (response.status == true) {
4161                                Eremit.Utility.handleUserDefineSuccess(response.data);
4162                                location.reload();
4163                            } else {
4164                                Eremit.Utility.handleUserDefineError(response.data);
4165                            }
4166                            $('#loadingDiv').addClass('d-none');
4167                        },
4168                        error: function (XMLHttpRequest, textStatus, errorThrown) {
4169                            Eremit.Utility.handleAjaxValidationErorrs(XMLHttpRequest, textStatus, errorThrown);
4170                            $('#loadingDiv').addClass('d-none');
4171                        }
4172                    });
4173                }
4174            });
4175        },
4176        Address: function () {
4177            $('#updateaddress_click').click(function () {
4178                $("#updateaddress :input").attr("readonly", false);
4179                $("#updateaddress #address").attr("readonly", true);
4180                $("#updateaddress :input").val('');
4181                $(".updateaddress-button").removeClass('d-none');
4182                $('select#suburb').val(null).trigger('change');
4183            });
4184
4185            $('#checkb-change-addr-yes').click(function () {
4186                $("#updateaddress :input").attr("readonly", false);
4187                $("#updateaddress :input").val('');
4188                $("#updateaddress #address").attr("readonly", true);
4189                $(".updateaddress-button").removeClass('d-none');
4190                $("#updateaddress").removeClass('d-none');
4191            });
4192
4193            $('#checkb-change-addr-no').click(function () {
4194                $("#updateaddress :input").attr("readonly", true);
4195                $(".updateaddress-button").addClass('d-none');
4196                $("#updateaddress").addClass('d-none');
4197            });
4198            if ($('option:selected', $('#dwelling_type')).attr('value') == 1) {
4199                $('#unit_no_label').addClass('required');
4200                $("#unit_no").attr('disabled', false);
4201            } else {
4202                $("#unit_no").val('');
4203                $('#unit_no_label').removeClass('required');
4204                $("#unit_no").attr('disabled', true);
4205            }
4206            $('#dwelling_type').change(function () {
4207                var optionSelected = $('option:selected', $(this)).val();
4208                if (optionSelected == '1') {
4209                    $('#unit_no_label').addClass('required');
4210                    $("#unit_no").attr('disabled', false);
4211                } else {
4212                    $("#unit_no").val('');
4213                    $('#unit_no_label').removeClass('required');
4214                    $("#unit_no").attr('disabled', true);
4215                }
4216            });
4217            $('#postcode, #state').change(function () {
4218                $('#postcode_error .error').html('');
4219                if ($('#state').val() != '' && $('#postcode').val() != '') {
4220                    if (isNaN($('#postcode').val())) {
4221                        $('#postcode_error').append('<label class="error" >Please enter numbers only.</label>');
4222                    } else {
4223                        if ($('#postcode').val().length == 4) {
4224                            // $('select#suburb').val('');
4225                            // $('.select2-selection__rendered').removeAttr('title');
4226                            // $('.select2-selection__rendered').html('Please Search your Suburb');
4227                            $('select#suburb option').remove();
4228                            $('select#suburb').val(null).trigger('change');
4229
4230                            $('select#suburb').prop('disabled', false);
4231                            // $.ajax({
4232                            //     url: moduleConfig.AddressifySuburbURL,
4233                            //     type: "get",
4234                            //     dataType: "json",
4235                            //     sync: true,
4236                            //     data: {
4237                            //         term: ' ',
4238                            //         state: $('#state').val(),
4239                            //         postcode: $('#postcode').val()
4240                            //     },
4241                            //     success: function(data) {
4242                            //         if (data.length > 0) {
4243                            //             $('#suburb').children().remove();
4244                            //             for (var i = 0; i < data.length; i++) {
4245                            //                 $('#suburb').append($('<option>').val(data[i].value).text(data[i].label));
4246                            //             }
4247                            //         } else {
4248                            //             $('#suburb').children().remove();
4249                            //             $("#suburb").val('');
4250                            //             $('#suburb').append($('<option>').val('').text('No Records Found.'));
4251                            //         }
4252                            //         $('#loadingDiv').addClass('d-none');
4253                            //     },
4254                            //     error: function(XMLHttpRequest, textStatus, errorThrown) {
4255                            //         Eremit.Utility.handleAjaxValidationErorrs(XMLHttpRequest, textStatus, errorThrown);
4256                            //         $('#loadingDiv').addClass('d-none');
4257                            //     },
4258                            // });
4259                        } else {
4260                            $('#postcode_error').append('<label class="error">Please enter 4 characters for postcode.</label>');
4261                        }
4262                    }
4263                }
4264            });
4265            // Update the address when any address field change
4266            $('#state, #postcode, #dwelling_type, #unit_no, #street_number, #street_name, #suburb').change(function () {
4267                $("#force_address").prop("checked", false);
4268                $('#address').val("");
4269            });
4270
4271            $('#find-verify-address').click(function () {
4272                var validStreetNumber = $('#street_number').valid(),
4273                    validStreet = $('#street_name').valid(),
4274                    validState = $('#state').valid(),
4275                    validPostcode = $('#postcode').valid(),
4276                    validSuburb = $('#suburb').valid(),
4277                    validDwellingType = $('#dwelling_type').valid();
4278                if ($('option:selected', $('#dwelling_type')).attr('value') == 1) {
4279                    var validUnitNo = $('#unit_no').valid();
4280                } else {
4281                    var validUnitNo = true;
4282                }
4283                if (validStreetNumber && validStreet && validState && validPostcode && validSuburb && validDwellingType && validUnitNo) {
4284                    $('#loadingDiv').removeClass('d-none');
4285                    $.ajax({
4286                        url: moduleConfig.AddressifyURL,
4287                        type: "get",
4288                        dataType: "json",
4289                        sync: true,
4290                        data: {
4291                            street_number: $('#street_number').val(),
4292                            street: $('#street_name').val(),
4293                            state: $('#state').val(),
4294                            postcode: $('#postcode').val(),
4295                            suburb: $('#suburb').val(),
4296                            dwelling_type: $("#dwelling_type").val(),
4297                            unit_no: $("#unit_no").val()
4298                        },
4299                        success: function (data) {
4300                            $('.fadein-address').removeClass('d-none');
4301                            if (data.length > 0) {
4302                                $('#simillar_address').children().remove();
4303                                for (var i = 0; i < data.length; i++) {
4304                                    $('#simillar_address').append($('<option>').val(data[i].value).text(data[i].label));
4305                                }
4306                                if (data.length == 1) {
4307                                    if (data[0].value != "") {
4308                                        Eremit.UpdateProfile.ParseAddress(data[0].value);
4309                                    }
4310                                }
4311                            } else {
4312                                $('#simillar_address').append($('<option>').val('').text('No Records Found.'));
4313                            }
4314                            $('#loadingDiv').addClass('d-none');
4315                        },
4316                        error: function (XMLHttpRequest, textStatus, errorThrown) {
4317                            Eremit.Utility.handleAjaxValidationErorrs(XMLHttpRequest, textStatus, errorThrown);
4318                            $('#loadingDiv').addClass('d-none');
4319                        },
4320                    });
4321                    setTimeout(function () {
4322                        $('.force-address-block').removeClass('d-none');
4323                    }, 3000);
4324                }
4325            });
4326            $('#simillar_address').change(function () {
4327                Eremit.UpdateProfile.ParseAddress($(this).val());
4328            });
4329            $('#force_address').change(function () {
4330                var selectedValue = $(this).is(":checked");
4331                if (selectedValue) {
4332                    var state = $('#state').val(),
4333                        postcode = $('#postcode').val(),
4334                        suburb = $('#suburb').val(),
4335                        dwelling_type = $("#dwelling_type").val(),
4336                        street = $('#street_name').val(),
4337                        streetnumber = $('#street_number').val(),
4338                        unit_no = $("#unit_no").val(),
4339                        mergeName = "";
4340                    mergeName = streetnumber + ' ' + street + ', ' + suburb + ' ' + state + ' ' + postcode;
4341                    if (dwelling_type == 1) {
4342                        mergeName = 'UNIT ' + unit_no + ', ' + mergeName;
4343                    } else {
4344                        mergeName = mergeName;
4345                    }
4346                    $('#address').val(mergeName);
4347                    $('.fadein-mainaddress').removeClass('d-none');
4348                    $('#simillar_address').attr('disabled', true);
4349                } else {
4350                    $('#address').val("");
4351                    $('#simillar_address').attr('disabled', false);
4352                    $("#simillar_address").val([]);
4353                }
4354            });
4355        },
4356        ParseAddress: function (selectedValue) {
4357            $.ajax({
4358                url: moduleConfig.AddressifyParsedURL,
4359                type: "get",
4360                dataType: "json",
4361                sync: true,
4362                data: {
4363                    term: selectedValue
4364                },
4365                success: function (data) {
4366                    $('#address').val(selectedValue);
4367                    $('.fadein-mainaddress').removeClass('d-none');
4368                    $('#street_name').val(data.Street);
4369                    $('#street_number').val(data.Number);
4370                    $('#property').val(data.BuildingName);
4371                    $('#streettype').val(data.StreetType);
4372                    $('#unit_no').val(data.UnitNumber);
4373
4374                    if (data.UnitNumber !== null) {
4375                        $('#dwelling_type').val(1);
4376                        $('#unit_no_label').addClass('required');
4377                        $("#unit_no").attr('disabled', false);
4378                    } else {
4379                        $('#dwelling_type').val(2);
4380                        $('#unit_no_label').removeClass('required');
4381                        $("#unit_no").attr('disabled', true);
4382                    }
4383
4384                    if (data.length > 0) {
4385                        response(data);
4386                    }
4387                },
4388            });
4389        },
4390    },
4391    UpdateProfileWithPopupLimited: {
4392        init: function () {
4393            console.log('UpdateProfileWithPopupLimited');
4394            $('#employment_status').change(function () {
4395                var optionSelected = $(this).val();
4396
4397                if (optionSelected == 7 || optionSelected == 8 || optionSelected == 9 || optionSelected == 10 || optionSelected == 11) {
4398                    $("#nature_of_business_div").addClass('d-none');
4399                    $('#nature_of_business_label').removeClass('required');
4400                    $("#nature_of_business").attr('disabled', true);
4401
4402                    $('#abn_div').addClass('d-none');
4403                    $('#abn_label').removeClass('required');
4404                    $("#abn").attr('disabled', true);
4405
4406                    $("#occupation_category_div").removeClass('d-none');
4407                    $('#occupation_category_label').addClass('required');
4408                    $("#occupation_category").attr('disabled', false);
4409
4410                    $("#position_div").removeClass('d-none');
4411                    $('#position_label').addClass('required');
4412                    $("#position").attr('disabled', false);
4413
4414                    // Employment type = Sole trader
4415                } else if (optionSelected == 2) {
4416                    $('#occupation_category_div').addClass('d-none');
4417                    $('#occupation_category_label').removeClass('required');
4418                    $("#occupation_category").attr('disabled', true);
4419
4420                    $("#position").val('');
4421                    $('#position_label').removeClass('required');
4422                    $("#position").attr('disabled', true);
4423
4424                    $("#nature_of_business_div").removeClass('d-none');
4425                    $('#nature_of_business_label').addClass('required');
4426                    $("#nature_of_business").attr('disabled', false);
4427
4428                    $('#abn_div').removeClass('d-none');
4429                    $('#abn_label').addClass('required');
4430                    $("#abn").attr('disabled', false);
4431
4432                } else {
4433                    $("#nature_of_business_div").addClass('d-none');
4434                    $('#nature_of_business_label').removeClass('required');
4435                    $("#nature_of_business").attr('disabled', true);
4436
4437                    $('#abn_div').addClass('d-none');
4438                    $('#abn_label').removeClass('required');
4439                    $("#abn").attr('disabled', true);
4440
4441                    $('#occupation_category_div').addClass('d-none');
4442                    $('#occupation_category_label').removeClass('required');
4443                    $("#occupation_category").attr('disabled', true);
4444
4445                    $("#position").val('');
4446                    $('#position_label').removeClass('required');
4447                    $("#position").attr('disabled', true);
4448                }
4449
4450                // Unemployed, Retired, Students and Social Security == 0-50k
4451                if (optionSelected == 3 || optionSelected == 4 || optionSelected == 5 || optionSelected == 13) {
4452                    $("#income_type option[value='3']").addClass('d-none');
4453                    $("#income_type option[value='4']").addClass('d-none');
4454                    $("#income_type option[value='5']").addClass('d-none');
4455                } else {
4456                    $("#income_type option[value='3']").removeClass('d-none');
4457                    $("#income_type option[value='4']").removeClass('d-none');
4458                    $("#income_type option[value='5']").removeClass('d-none');
4459                }
4460            });
4461
4462            $('body').on('click', '#updateProfileButton', function (e) {
4463                Eremit.Validate.UpdateProfileDetailsPopup(e);
4464
4465                var $valid = $("#eremit-update-limited-profile-form").valid();
4466                if (!$valid) {
4467                    return false;
4468                } else {
4469                    //Eremit.ProcessAjaxSubmit.EncryptPassword();
4470                    var data = new FormData($('#eremit-update-limited-profile-form')[0]);
4471
4472                    Eremit.ProcessAjaxSubmit.submitForm(this, data);
4473                }
4474            });
4475        }
4476    },
4477    ProcessAjaxSubmit: {
4478        submitForm: function (elem, data) {
4479            $.ajax({
4480                type: "POST",
4481                url: moduleConfig.updateProfileWithPopupURL,
4482                data: data,
4483                context: elem,
4484                cache: false,
4485                processData: false,
4486                contentType: false,
4487                success: function (response) {
4488                    if (jQuery.type(response) !== "string" || response.indexOf('{') !== -1
4489                    ) {
4490                        var response = JSON.parse(response);
4491                    }
4492
4493                    $contType = typeof response;
4494
4495                    if (response == true || response == 'true' || Object.keys(response).length > 0) {
4496                        $('#eremit-update-limited-profile-form')[0].reset();
4497
4498                        Eremit.Utility.handleUserDefineSuccessModal(response.data);
4499                        setTimeout(function () {
4500                            location.reload();
4501                        }, 3000);
4502
4503                    } else {
4504                        Eremit.Utility.handleUserDefineErrorModal(response);
4505                    }
4506                },
4507                error: function (XMLHttpRequest, textStatus, errorThrown) {
4508                    Eremit.Utility.handleAjaxValidationErorrsModal(XMLHttpRequest, textStatus, errorThrown);
4509                }
4510            });
4511        },
4512        EncryptPassword: function () {
4513            var current_password = Eremit.Utility.CryptoJSAesEncrypt(moduleConfig.decriptKey, $('#current_password').val());
4514            var new_password = Eremit.Utility.CryptoJSAesEncrypt(moduleConfig.decriptKey, $('#new_password').val());
4515            var password_confirmation = Eremit.Utility.CryptoJSAesEncrypt(moduleConfig.decriptKey, $('#confirm_new_password').val());
4516            $('#current_password').val(window.btoa(current_password));
4517            $('#new_password').val(window.btoa(new_password));
4518            $('#confirm_new_password').val(window.btoa(password_confirmation));
4519        }
4520    },
4521    LandingPage: {
4522        init: function (includeCalculator) {
4523            // This condition are added to solve IE issue
4524            if (includeCalculator === undefined) {
4525                includeCalculator = false;
4526            }
4527            Eremit.Datepicker.init();
4528            $('#loginBtn').on('click', function (e) {
4529                Eremit.Validate.Login(e);
4530                Eremit.Login.init(e, {
4531                    "Customer_ID": $('#Customer_ID').val(),
4532                    "Password": $('#Password').val(),
4533                    "DOB": $('#DOB').val(),
4534                });
4535            });
4536            if (includeCalculator === true) {
4537                Eremit.LandingPage.calculator();
4538            }
4539        },
4540        calculator: function () {
4541            var baseCurrencyObject = document.getElementById('base_currency');
4542            baseCurrencyObject.selectedIndex = 0;
4543            baseCurrencyObject.disabled = true;
4544            $('#Amount').keypress(function (event) {
4545                Eremit.Utility.isNumber(event);
4546            });
4547            $('#converted-amount').keypress(function (event) {
4548                Eremit.Utility.isNumber(event);
4549            });
4550            $("#Amount").keyup(Eremit.Utility.debounce(function () {
4551                console.log('landing page')
4552                $("#Amount").val(Eremit.Utility.parseCurrency($("#Amount").val()));
4553                if (Eremit.HomePage.validateCalculator(true)) {
4554                    Eremit.HomePage.calculatorConverter({
4555                        'base_currency': document.getElementById("base_currency").value,
4556                        'exchange_currency': document.getElementById("exchange_currency").value,
4557                        'amount': Eremit.Utility.parseCurrency($("#Amount").val()),
4558                        'payment_method': "BPay",
4559                        'landing_page': true
4560                    }, true);
4561                } else {
4562                    document.getElementById('converted-amount').value = '';
4563                    document.getElementById('current_exchange_rate').innerHTML = '0.00';
4564                    document.getElementById('fee_break_down_secondary').innerHTML = '0.00';
4565                    document.getElementById('fee_break_down_primary').innerHTML = '0.00';
4566                }
4567            }, 500));
4568            $("#converted-amount").keyup(Eremit.Utility.debounce(function () {
4569                $("#converted-amount").val(Eremit.Utility.parseCurrency($("#converted-amount").val()));
4570                if (Eremit.HomePage.validateCalculator(true)) {
4571                    Eremit.HomePage.calculatorConverter({
4572                        'base_currency': document.getElementById("exchange_currency").value, // here we send exchange currency as a base currency
4573                        'exchange_currency': document.getElementById("base_currency").value,
4574                        'amount': Eremit.Utility.parseCurrency($("#converted-amount").val()),
4575                        'payment_method': "BPay",
4576                        'converted_amount': true,
4577                        'landing_page': true
4578                    }, true, true);
4579                } else {
4580                    document.getElementById('Amount').value = '';
4581                    document.getElementById('current_exchange_rate').innerHTML = '0.00';
4582                    document.getElementById('fee_break_down_secondary').innerHTML = '0.00';
4583                    document.getElementById('fee_break_down_primary').innerHTML = '0.00';
4584                }
4585            }, 500));
4586            $('#exchange_currency').change(function (event) {
4587                var selectedValue = $(this).val(),
4588                    exchangeCurrencyObject = $(this);
4589                document.getElementById('Amount').value = '';
4590                document.getElementById('converted-amount').value = '';
4591                document.getElementById('current_exchange_rate').innerHTML = '0.00';
4592                document.getElementById('fee_break_down_secondary').innerHTML = '0.00';
4593                document.getElementById('fee_break_down_primary').innerHTML = '0.00';
4594                if (selectedValue != 1) {
4595                    exchangeCurrencyObject.selectedIndex = 0;
4596                    exchangeCurrencyObject.disabled = true;
4597                } else {
4598                    exchangeCurrencyObject.disabled = false;
4599                }
4600            });
4601        },
4602        landingPageForgotPassword: function () {
4603            $.ajax({
4604                type: "POST",
4605                url: moduleConfig.ForgotPassUrl,
4606                data: "Customer_ID=" + $('#Customer_ID').val() + "&DOB=" + $('#DOB').val() + "&_token=" + moduleConfig.token,
4607                cache: false,
4608                success: function (response) {
4609                    var response = JSON.parse(response);
4610                    if (response.status == true) {
4611                        window.location.href = response.redirect;
4612                    } else {
4613                        if (response.status == 500) {
4614                            error = "These credentials do not match our records.";
4615                        } else if (response.message != '') {
4616                            error = response.message;
4617                        } else {
4618                            error = "Something went wrong.Please try agian!";
4619                        }
4620                        Eremit.Utility.handleUserDefineError(error);
4621                    }
4622                    window.scrollTo(0, 0);
4623                },
4624                error: function (XMLHttpRequest, textStatus, errorThrown) {
4625                    Eremit.Utility.handleAjaxValidationErorrs(XMLHttpRequest, textStatus, errorThrown);
4626                }
4627            });
4628        }
4629    },
4630    CurrencyCalculator: {
4631        init: function () {
4632            $("#base_currency[name='country']").select2({
4633                allowHtml: true,
4634                data: Eremit.CurrencyCalculator.isoCountries(),
4635                placeholder: "Select a currency",
4636                templateResult: Eremit.CurrencyCalculator.formatCountry,
4637                templateSelection: Eremit.CurrencyCalculator.formatSelectedCountry,
4638            });
4639            $("#exchange_currency[name='country']").select2({
4640                allowHtml: true,
4641                data: Eremit.CurrencyCalculator.isoCountriesExchangeCurrency(),
4642                placeholder: "Select a currency",
4643                templateResult: Eremit.CurrencyCalculator.formatCountry,
4644                templateSelection: Eremit.CurrencyCalculator.formatSelectedCountry,
4645            });
4646            $("[name='country']").select2({
4647                allowHtml: true,
4648                data: Eremit.CurrencyCalculator.isoCountries(),
4649                placeholder: "Select a currency",
4650                templateResult: Eremit.CurrencyCalculator.formatCountry,
4651                templateSelection: Eremit.CurrencyCalculator.formatSelectedCountry,
4652            });
4653            $('.clear-amount').click(function () {
4654                Eremit.CurrencyCalculator.clearCalculation();
4655            });
4656        },
4657        isoCountries: function () {
4658            return [{
4659                id: '1',
4660                text: 'AUD',
4661                url: Eremit.Utility.getUrl("/eremits/image/aud.png")
4662            }, {
4663                id: '2',
4664                text: 'INR',
4665                url: Eremit.Utility.getUrl("/eremits/image/inr.png")
4666            }, {
4667                id: '3',
4668                text: 'USD',
4669                url: Eremit.Utility.getUrl("/eremits/image/usd.png")
4670            }, {
4671                id: '9',
4672                text: 'NPR',
4673                url: Eremit.Utility.getUrl("/eremits/image/npr.png")
4674            }, {
4675                id: '4',
4676                text: 'GBP',
4677                url: Eremit.Utility.getUrl("/eremits/image/gbp.png")
4678            }, {
4679                id: '5',
4680                text: 'EUR',
4681                url: Eremit.Utility.getUrl("/eremits/image/eur.png")
4682            }, {
4683                id: '6',
4684                text: 'NZD',
4685                url: Eremit.Utility.getUrl("/eremits/image/nzd.png")
4686            }, {
4687                id: '7',
4688                text: 'CAD',
4689                url: Eremit.Utility.getUrl("/eremits/image/cad.png")
4690            }, {
4691                id: '8',
4692                text: 'SGD',
4693                url: Eremit.Utility.getUrl("/eremits/image/sgd.png")
4694            }];
4695        },
4696        isoCountriesExchangeCurrency: function () {
4697            return [{
4698                id: '2',
4699                text: 'INR',
4700                url: Eremit.Utility.getUrl("/eremits/image/inr.png")
4701            }, {
4702                id: '3',
4703                text: 'USD',
4704                url: Eremit.Utility.getUrl("/eremits/image/usd.png")
4705            }, {
4706                id: '9',
4707                text: 'NPR',
4708                url: Eremit.Utility.getUrl("/eremits/image/npr.png")
4709            }, {
4710                id: '4',
4711                text: 'GBP',
4712                url: Eremit.Utility.getUrl("/eremits/image/gbp.png")
4713            }, {
4714                id: '5',
4715                text: 'EUR',
4716                url: Eremit.Utility.getUrl("/eremits/image/eur.png")
4717            }, {
4718                id: '6',
4719                text: 'NZD',
4720                url: Eremit.Utility.getUrl("/eremits/image/nzd.png")
4721            }, {
4722                id: '7',
4723                text: 'CAD',
4724                url: Eremit.Utility.getUrl("/eremits/image/cad.png")
4725            }, {
4726                id: '8',
4727                text: 'SGD',
4728                url: Eremit.Utility.getUrl("/eremits/image/sgd.png")
4729            }, {
4730                id: '1',
4731                text: 'AUD',
4732                url: Eremit.Utility.getUrl("/eremits/image/aud.png")
4733            }];
4734        },
4735        formatCountry: function (country) {
4736            if (!country.id) {
4737                return country.text;
4738            }
4739            var $country = $('<img src=' + country.url + '>' + '<span class="flag-text">' + country.text + "</span>");
4740            return $country;
4741        },
4742        formatSelectedCountry: function (country) {
4743            if (!country.id) {
4744                return country.text;
4745            }
4746            var $country = $('<img width="20%" style="margin-left: 5px" src=' + country.url + '>' + '<span class="flag-text" style="margin-left: 5px">' + country.text + "</span>");
4747            return $country;
4748        },
4749        clearCalculation: function () {
4750            document.getElementById("Amount").value = '';
4751            document.getElementById('base-currency-value') ? document.getElementById('base-currency-value').innerHTML = '' : '';
4752            document.getElementById('applied-fees') ? document.getElementById('applied-fees').innerHTML = '' : '';
4753            document.getElementById('original-exchange-rate') ? document.getElementById('original-exchange-rate').innerHTML = '' : '';
4754            document.getElementById('converted-amount-text') ? document.getElementById('converted-amount-text').innerHTML = '' : '';
4755            document.getElementById('converted-amount').value = '';
4756            document.getElementById('promotion-exchange-rate') ? document.getElementById('promotion-exchange-rate').classList.add('d-none') : '';
4757            document.getElementById('applied-exchange-rate') ? document.getElementById('applied-exchange-rate').innerHTML = '' : '';
4758
4759        },
4760        handleSuccessResponse: function (response, $landingPage, isConvertedAmount) {
4761            if ($landingPage == true) {
4762                if (isConvertedAmount == true) {
4763                    document.getElementById('Amount').value = response.foreign_currency_amount;
4764                } else {
4765                    document.getElementById('converted-amount').value = response.foreign_currency_amount;
4766                }
4767                document.getElementById('current_exchange_rate').innerHTML = response.applied_rate;
4768                document.getElementById('fee_break_down_secondary').innerHTML = response.applied_fee;
4769                document.getElementById('fee_break_down_primary').innerHTML = response.applied_fee;
4770            } else {
4771                if (isConvertedAmount == true) {
4772                    document.getElementById('Amount').value = response.foreign_currency_amount;
4773                    document.getElementById('converted-amount').value = response.original_amount;
4774                    document.getElementById('base-currency-value').innerHTML = response.foreign_currency_amount + ' ' + response.foreign_currency;
4775                    document.getElementById('applied-fees').innerHTML = response.applied_fee + ' AUD';
4776                    document.getElementById('original-exchange-rate').innerHTML = response.original_rate + ' ' + response.base_currency;
4777                    document.getElementById('converted-amount-text').innerHTML = response.original_amount + ' ' + response.base_currency;
4778                    if (response.applied_rate != response.original_rate) {
4779                        document.getElementById('promotion-exchange-rate').classList.remove('d-none');
4780                        document.getElementById('applied-exchange-rate').innerHTML = response.applied_rate + ' ' + response.base_currency;
4781                    } else {
4782                        document.getElementById('promotion-exchange-rate').classList.add('d-none');
4783                        document.getElementById('applied-exchange-rate').innerHTML = '';
4784                    }
4785                } else {
4786                    document.getElementById('converted-amount').value = response.foreign_currency_amount;
4787                    document.getElementById('base-currency-value').innerHTML = response.original_amount + ' ' + response.base_currency;
4788                    document.getElementById('applied-fees').innerHTML = response.applied_fee + ' AUD';
4789                    document.getElementById('original-exchange-rate').innerHTML = response.original_rate + ' ' + response.foreign_currency;
4790                    document.getElementById('converted-amount-text').innerHTML = response.foreign_currency_amount + ' ' + response.foreign_currency;
4791                    if (response.applied_rate != response.original_rate) {
4792                        document.getElementById('promotion-exchange-rate').classList.remove('d-none');
4793                        document.getElementById('applied-exchange-rate').innerHTML = response.applied_rate + ' ' + response.foreign_currency;
4794                    } else {
4795                        document.getElementById('promotion-exchange-rate').classList.add('d-none');
4796                        document.getElementById('applied-exchange-rate').innerHTML = '';
4797                    }
4798                }
4799            }
4800        }
4801    },
4802    resendTfaOtp: {
4803        init: function (parameter, event) {
4804            event.preventDefault();
4805            $.ajax({
4806                type: "POST",
4807                url: parameter.resendOtpURL,
4808                data: "tfa_token=" + parameter.tfaToken,
4809                cache: false,
4810                success: function (response) {
4811                    var response = JSON.parse(response);
4812
4813                    if (response.status == true) {
4814                        Eremit.Utility.handleUserDefineError(response.data);
4815                    } else {
4816                        if (response.data == 'try-block') {
4817                            Eremit.Utility.handleUserDefineError('You have exceeds OTP attempts limit. Your account was blocked for ' + parameter.update_mobile_block_hours + ' Hours.', 'alert-danger red-font');
4818                            setTimeout(function () { window.location.href = response.redirect; }, 5000);
4819                            return false;
4820                        }
4821
4822                        if (response.data == 'request-block') {
4823                            Eremit.Utility.handleUserDefineError('You have exceeds OTP generate limit. Your account was blocked for ' + parameter.update_mobile_block_hours + ' Hours.', 'alert-danger red-font');
4824                            setTimeout(function () { window.location.href = response.redirect; }, 5000);
4825                            return false;
4826                        }
4827                        Eremit.Utility.handleUserDefineError(error);
4828                    }
4829                    window.scrollTo(0, 0);
4830                },
4831                error: function (XMLHttpRequest, textStatus, errorThrown) {
4832                    Eremit.Utility.handleAjaxValidationErorrs(XMLHttpRequest, textStatus, errorThrown);
4833                }
4834            });
4835        },
4836    },
4837}

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.