Subversion Repositories SmartDukaan

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
33507 tejus.loha 1
$(document).on('click', ".onboarding-form1", function () {
2
    doGetAjaxRequestHandler(`${context}/onboardingForm`,
3
        function (response) {
4
            $('#' + 'main-content').html(response);
5
        });
6
});
7
 
33577 tejus.loha 8
 
9
$(document).on('change', "#maritalStatus", function () {
10
    let maritalStatus = $(this).val();
11
    console.log("maritalStatus - " + maritalStatus);
12
    if (maritalStatus == 1) {
13
        $(".loiAnniversaryDate").removeClass('hide-model');
14
        $(".loiAnniversaryDate").addClass('show-model');
15
    } else {
16
        $(".loiAnniversaryDate").removeClass('show-model');
17
        $(".loiAnniversaryDate").addClass('hide-model');
18
    }
19
 
20
});
21
 
33578 tejus.loha 22
 
33577 tejus.loha 23
$(document).on('click', ".submitLoiForm", function () {
24
    // Gather input values
25
    const referId = $('select[name="referId"]').val();
26
    const billingAddress = $('select[name="billingAddress"]').val();
33582 tejus.loha 27
    const acquiredDate = $('input[name="acquiredDate"]').val();
33577 tejus.loha 28
    const firstName = $('input[name="firstName"]').val();
29
    const lastName = $('input[name="lastName"]').val();
30
    const mobile = $('input[name="mobile"]').val();
33780 tejus.loha 31
 
32
    // validate email pattern
33
    const emailValue = $('input[name="email"]').val();
34
    var email;
35
    if (emailValue.length > 0) {
36
        if (isValidEmail(emailValue)) {
37
            email = emailValue;
38
        } else {
39
            alert("Please check your Email Address");
40
            return;
41
        }
42
    }
33577 tejus.loha 43
    const landline = $('input[name="landline"]').val();
44
    const dob = $('input[name="dob"]').val();
33624 tejus.loha 45
    var today = new Date();
46
    var birthDate = new Date(dob);
47
    var age = today.getFullYear() - birthDate.getFullYear();
48
    var monthDiff = today.getMonth() - birthDate.getMonth();
49
 
50
    if (monthDiff < 0 || (monthDiff === 0 && today.getDate() < birthDate.getDate())) {
51
        age--;
52
    }
33577 tejus.loha 53
    var maritalStatus = $('select[name="maritalStatus"]').val();
54
    const anniversaryDate = $('input[name="anniversaryDate"]').val();
55
    const panNo = $('input[name="panNo"]').val();
56
    const adharNo = $('input[name="adharNo"]').val();
57
    const gstNo = $('input[name="gstNo"]').val();
58
    const bankName = $('input[name="bankName"]').val();
59
    const ifscCode = $('input[name="ifscCode"]').val();
60
    const accountNo = $('input[name="accountNo"]').val();
61
    const businessType = $('select[name="businessType"]').val();
62
    const companyName = $('input[name="companyName"]').val();
63
    const gstPin = $('input[name="gstPin"]').val();
64
    const gstState = $('input[name="gstState"]').val();
65
    const gstCity = $('input[name="gstCity"]').val();
66
    const gstDistrict = $('input[name="gstDistrict"]').val();
67
    const agreeWalletValue = $('select[name="agreeWalletValue"]').val();
68
    const storeArea = $('input[name="storeArea"]').val();
69
    const storePotential = $('input[name="storePotential"]').val();
33658 tejus.loha 70
    let brandCommitment = [];
71
    var brandCommitmentInputs = document.querySelectorAll(".brand-commitment");
72
    brandCommitmentInputs.forEach(function (input) {
73
        var commitmentValue = parseInt(input.value);
74
        if (!isNaN(commitmentValue)) {
75
            brandCommitment.push({
76
                brandName: input.getAttribute("name"),
77
                value: commitmentValue
78
            });
79
        }
80
    });
81
    let totalCommitment = brandCommitment.reduce((total, commitment) => total + commitment.value, 0);
82
    console.log("Total Commitment Amount:", totalCommitment);
33577 tejus.loha 83
    const lessCommitReason = $('input[name="lessCommitReason"]').val();
33658 tejus.loha 84
    let minCommit = totalCommitment >= storePotential * (70 / 100);
33577 tejus.loha 85
    const agreedBrandFees = $('select[name="agreedBrandFees"]').val();
86
    console.log("agreedBrandFees - ", agreedBrandFees);
33624 tejus.loha 87
    const values = agreedBrandFees.split(/[-]/); // Split the string
88
    const brandFee = parseFloat(values[1]);
33577 tejus.loha 89
    const brandFeesCollected = $('input[name="brandFeesCollected"]').val();
90
    const paymentMode = $('select[name="paymentMode"]').val();
91
    const paymentReferenceNo = $('input[name="paymentReferenceNo"]').val();
33578 tejus.loha 92
    const feeCollectingDate = $('input[name="feeCollectingDate"]').val();
33577 tejus.loha 93
 
94
    let missingFields = [];
95
    if (!firstName) missingFields.push('First Name');
96
    if (!lastName) missingFields.push('Last Name');
97
    if (mobile.length < 10 || !mobile) {
98
        missingFields.push('Mobile number should be 10 digit');
99
    }
33658 tejus.loha 100
    if (!minCommit) {
33577 tejus.loha 101
        if (!lessCommitReason) missingFields.push('Less Commit Reason');
102
    }
103
    if (!maritalStatus) missingFields.push('Marital Status');
104
    if (maritalStatus == 1) {
105
        if (!anniversaryDate) missingFields.push('Anniversary Date');
106
    }
107
    if (!email) missingFields.push('Email');
33582 tejus.loha 108
    if (!acquiredDate) missingFields.push('Acquired date');
33577 tejus.loha 109
    if (!dob) missingFields.push('dob(Date of Birth)');
33624 tejus.loha 110
    if (age <= 18) missingFields.push('You must be at least 18 years old to Fill LOI FORM. ');
33577 tejus.loha 111
    if (!panNo) missingFields.push('Pan Number');
112
    if (!adharNo) missingFields.push('Aadhar Number');
113
    if (!gstNo) missingFields.push('GST Number');
114
    if (!bankName) missingFields.push('Bank Name');
115
    if (!ifscCode) missingFields.push('IFSC code');
116
    if (!accountNo) missingFields.push('Account Number');
117
    if (!businessType) missingFields.push('businessType');
118
    if (!companyName) missingFields.push('Company Name');
119
    if (!agreeWalletValue) missingFields.push('Agree Wallet Value');
120
    if (!storeArea) missingFields.push('storeArea');
121
    if (!storePotential) missingFields.push('Store Potential');
122
    if (!agreedBrandFees) missingFields.push('Agreed Brand Fees');
123
    if (!brandFeesCollected) missingFields.push('Brand Fees Collected');
33624 tejus.loha 124
    if (brandFeesCollected > brandFee) missingFields.push('Payment Brand fee ');
33577 tejus.loha 125
    if (!paymentMode) missingFields.push('Payment Mode');
126
    if (!paymentReferenceNo) missingFields.push('Payment Reference No');
33578 tejus.loha 127
    if (!feeCollectingDate) missingFields.push('Fee Collecting Date');
33577 tejus.loha 128
    if (missingFields.length > 0) {
129
        alert('The following fields are required: ' + missingFields.join(', '));
130
        return;
131
    }
132
    const loiFormData = {
133
        referId: referId,
134
        businessType: businessType,
33582 tejus.loha 135
        acquiredDate: acquiredDate,
33577 tejus.loha 136
        firstName: firstName,
137
        lastName: lastName,
138
        mobile: mobile,
139
        email: email,
140
        landline: landline,
141
        dob: dob,
142
        anniversaryDate: anniversaryDate,
143
        panNo: panNo,
144
        adharNo: adharNo,
145
        gstNo: gstNo,
146
        bankName: bankName,
147
        ifscCode: ifscCode,
148
        accountNo: accountNo,
149
        companyName: companyName,
150
        gstPin: gstPin,
151
        gstState: gstState,
152
        gstCity: gstCity,
153
        gstDistrict: gstDistrict,
154
        agreeWalletValue: agreeWalletValue,
155
        storeArea: storeArea,
156
        storePotential: storePotential,
157
        lessCommitReason: lessCommitReason,
158
        agreedBrandFees: agreedBrandFees,
159
        brandFeesCollected: brandFeesCollected,
160
        paymentMode: paymentMode,
161
        paymentReferenceNo: paymentReferenceNo,
33578 tejus.loha 162
        feeCollectingTimeStamp: feeCollectingDate,
33658 tejus.loha 163
        billingAddress: billingAddress,
164
        brandCommitment: brandCommitment
33577 tejus.loha 165
    };
33658 tejus.loha 166
 
33577 tejus.loha 167
    console.log("form data - ", loiFormData);
168
    if (confirm("Are you sure to submit the form ?")) {
169
        doPostAjaxRequestWithJsonHandler(`${context}/submitLoiForm`, JSON.stringify(loiFormData), function (response) {
170
            console.log('responsee', response);
33507 tejus.loha 171
            if (response) {
172
                alert("Your LOI form Submitted successfully ");
173
                pendingLoiForm("main-content");
174
 
175
            } else {
176
                alert("Your LOI form not Submitted , try again ");
177
                doGetAjaxRequestHandler(`${context}/onboardingForm`,
178
                    function (response) {
179
                        $('#' + 'main-content').html(response);
180
                    });
181
            }
182
        });
183
    }
184
});
33578 tejus.loha 185
 
33658 tejus.loha 186
$(document).on('click', ".updateLoiForm", function () {
33507 tejus.loha 187
    let loiId = $(this).val();
188
    console.log("form id - ", loiId);
33658 tejus.loha 189
    doGetAjaxRequestHandler(context + "/updateLoiForm?loiId=" + loiId,
33507 tejus.loha 190
        function (response) {
191
            $('#' + 'main-content').html(response);
192
        });
193
});
33711 tejus.loha 194
$(document).on('click', ".cancel_loi", function () {
195
    let loiId = $(this).val();
196
    let companyName = $(this).data('company');
197
    console.log("form id - ", loiId);
198
    if (confirm(`Are you sure to Cancel "${companyName}" LOI`)) {
199
        doPutAjaxRequestHandler(`${context}/cancelLoi?loiId=${loiId}`,
200
            function (response) {
201
                pendingLoiForm("main-content");
202
            });
203
    }
204
});
33710 tejus.loha 205
$(document).on('click', ".save_agree_brand_fee", function () {
206
    let loiId = $(this).val();
207
    var $tr = $(this).closest('tr');
208
    var agreedBrandFee = $tr.find('input[name="brandFee"]').val();
209
    if (confirm("Are you sure to change Agreed brand fee")) {
210
        doPutAjaxRequestHandler(`${context}/updateAgreedBrandFee?loiId=${loiId}&brandFee=${agreedBrandFee}`, function (response) {
211
            pendingLoiForm("main-content");
212
        });
213
    } else {
214
        pendingLoiForm("main-content");
215
    }
216
});
33507 tejus.loha 217
 
33658 tejus.loha 218
$(document).on('click', ".updateLoiFormDataButton", function () {
219
    console.log("updateLoiFormDataButton clicked..");
220
    let loiId = $(this).data('loiid');
221
 
222
    const firstName = $('input[name="firstName"]').val();
223
    const lastName = $('input[name="lastName"]').val();
224
    const mobile = $('input[name="mobile"]').val();
225
    const email = $('input[name="email"]').val();
226
    const landline = $('input[name="landline"]').val();
227
    const dob = $('input[name="dob"]').val();
228
    const panNo = $('input[name="panNo"]').val();
229
    const adharNo = $('input[name="adharNo"]').val();
230
    let missingFields = [];
231
    if (!firstName) missingFields.push('First Name');
232
    if (!lastName) missingFields.push('Last Name');
233
    if (mobile.length < 10 || !mobile) {
234
        missingFields.push('Mobile number should be 10 digit');
235
    }
236
    if (!dob) missingFields.push('dob(Date of Birth)');
237
    if (!panNo) missingFields.push('Pan Number');
238
    if (!adharNo) missingFields.push('Aadhar Number');
239
    if (!email) missingFields.push('Email');
240
    if (missingFields.length > 0) {
241
        alert('The following fields are required: ' + missingFields.join(', '));
242
        return;
243
    }
244
    const loiFormData = {
245
        firstName: firstName,
246
        lastName: lastName,
247
        mobile: mobile,
248
        email: email,
249
        landline: landline,
250
        dob: dob,
251
        panNo: panNo,
252
        adharNo: adharNo
253
    };
254
    console.log("loiFormData - ", loiFormData);
255
    alert("you want update ..");
256
    doPostAjaxRequestWithJsonHandler(`${context}/updateLoiFormData?loiId=${loiId}`, JSON.stringify(loiFormData), function (response) {
33507 tejus.loha 257
        pendingLoiForm("main-content");
258
    });
259
 
260
});
261
 
262
$(document).on('click', ".pending-onboarding-form", function () {
33710 tejus.loha 263
    doGetAjaxRequestHandler(`${context}/pendingLoiForm`,
33507 tejus.loha 264
        function (response) {
265
            $('#' + 'main-content').html(response);
266
        });
267
});
268
$(document).on('click', "#addBrandFeePayment", function () {
269
    let formData = objectifyForm($("form[name='brandFeeCollectionForm']").serializeArray());
270
    let loiId = $(this).val();
271
    console.log("form id -", loiId);
272
    for (var key in formData) {
273
        if (formData.hasOwnProperty(key) && formData[key].trim() === '') {
274
            alert("The (" + key + ") value is blank please fill this field !");
275
            return false;
276
        }
277
    }
278
    let jsonData = JSON.stringify(formData);
33658 tejus.loha 279
    if (confirm("Are you sure to add payment ?")) {
33525 tejus.loha 280
        doPostAjaxRequestWithJsonHandler(`${context}/brandfeeCollection?loiId=` + loiId, jsonData, function (response) {
281
            if (response) {
282
                alert("Payment add successfully...");
283
                pendingLoiForm("main-content");
33507 tejus.loha 284
 
33525 tejus.loha 285
            }
286
        });
287
    } else {
33658 tejus.loha 288
        alert("Payment is not add.");
289
 
33525 tejus.loha 290
    }
33507 tejus.loha 291
 
292
});
293
 
294
$(document).on('click', ".generateLoi", function () {
295
    let loiId = $(this).val();
296
    console.log("form id - ", loiId);
297
    doGetAjaxRequestHandler(context + "/generateLoi?loiId=" + loiId,
298
        function (response) {
299
            $('#' + 'main-content').html(response);
300
        });
301
});
302
 
303
$(document).on('click', "#LOI_otp", function () {
304
    let loiId = $(this).val();
305
    console.log("loiId-", loiId);
33577 tejus.loha 306
    if (confirm("Are you sure to send OTP ?")) {
307
        doPostAjaxRequestHandler(`${context}/loiAcceptanceOtp?loiId=` + loiId,
308
            function (response) {
309
                alert(response);
310
                doGetAjaxRequestHandler(context + "/generateLoi?loiId=" + loiId,
311
                    function (response) {
312
                        $('#' + 'main-content').html(response);
313
                    });
314
            });
315
    } else {
316
        alert("OTP not send .");
317
    }
318
 
33507 tejus.loha 319
});
320
 
321
 
322
$(document).on('click', ".onboardingFormDone", function () {
323
    let loiId = $(this).val();
324
    var loi = $(document).find(".upload-form-loi input[type=file]").val();
325
    console.log("form id - ", loiId);
326
    doPostAjaxRequestHandler(`${context}/uploadLoi?loiId=${loiId}&loi=${loi}`,
327
        function (response) {
328
            $('#' + 'main-content').html(response);
329
        });
330
});
331
 
332
//confirmPayment
33525 tejus.loha 333
$(document).on('click', ".paymentConfirmBtn", function () {
334
    let approval = $(this).data('approval');
33507 tejus.loha 335
    let bfcId = $(this).val();
33525 tejus.loha 336
    let description = "All details are correct";
337
    if (confirm("Are you sure to confirm this payment ?")) {
338
        doPutAjaxRequestHandler(`${context}/feePaymentApproval?bfcId=${bfcId}&feePaymentStatus=${approval}&description=${description}`,
339
            function (response) {
340
                if (response) {
341
                    alert("Payment is confirm successfully");
342
                }
343
                pendingLoiForm("main-content");
344
            });
345
    } else {
346
        //do nothing
347
    }
348
});
349
 
350
$(document).on('click', ".paymentRejectBtn", function () {
33507 tejus.loha 351
    let approval = $(this).data('approval');
33525 tejus.loha 352
    let bfcId = $(this).val();
353
    let description;
354
    description = prompt("Reason for rejection..");
355
    if (description !== null) {
356
        if (confirm("Are you sure to Reject this payment ?")) {
357
            doPutAjaxRequestHandler(`${context}/feePaymentApproval?bfcId=${bfcId}&feePaymentStatus=${approval}&description=${description}`,
358
                function (response) {
359
                    if (!response) {
360
                        alert("Payment is rejected successfully");
361
                    }
362
                    pendingLoiForm("main-content");
363
                });
364
        } else {
365
            //do nothing
366
        }
367
    } else {
368
        alert("Please mention the reason as description and try again");
369
    }
33507 tejus.loha 370
});
371
$(document).on('click', ".upload-document-form", function () {
372
    let loiId = $(this).val();
33617 tejus.loha 373
    doGetAjaxRequestHandler(`${context}/uploadDocumentForm?loiId=${loiId}`,
33507 tejus.loha 374
        function (response) {
375
            $('#' + 'main-content').html(response);
376
        });
377
});
378
$(document).on('input', 'table#OnboardingDocumentTable input[type=file]', function () {
379
    if (confirm('Confirm file upload ?')) {
380
        var fileSelector = $(this)[0];
381
        if (fileSelector != undefined
382
            && fileSelector.files[0] != undefined) {
383
            var file = this.files[0];
384
            console.log("file", file);
385
            let fileInput = $(this);
386
            console.log("fileInput", file);
387
            uploadDocument(file, function (documentId) {
388
                console.log("documentIdzzz  : ", documentId);
389
                fileInput.closest('td').find(".documentId").val(documentId);
390
            });
391
        }
392
    }
393
});
394
$(document).on('click', ".mk_docApproval", function () {
395
    let loiId = $(this).data('form_id');
396
    let docMasterId = $(this).data('doc_master_id');
397
    let flag = $(this).data('flag');
398
    console.log("flag -", flag);
399
    doPutAjaxRequestHandler(`${context}/documentVerify?loiId=${loiId}&docMasterId=${docMasterId}&flag=${flag}`,
400
        function (response) {
401
            alert(response);
33617 tejus.loha 402
            doGetAjaxRequestHandler(`${context}/uploadDocumentForm?loiId=${loiId}`,
33507 tejus.loha 403
                function (response) {
404
                    $('#' + 'main-content').html(response);
405
                });
406
 
407
        });
408
});
409
$(document).on('click', "#uploadDocumentbtn1", function () {
410
    if (confirm("Are you sure to upload all documents ?")) {
411
        var loiId = $(this).val();
412
        var loiDocModels = [];
413
        console.log("loiId -", loiId);
414
        $("#OnboardingDocumentTable > tbody > tr").each(function (rowIndex) {
415
            var marsterId = $(this).find(".masterId").val();
416
            var docId = $(this).find(".documentId").val();
417
            var docName = $(this).find(".documentName").val();
418
            console.log("marsterId -", marsterId);
419
            var loiDocModel = {
420
                documentId: docId,
421
                documentName: docName,
422
                documentMasterId: marsterId
423
            };
424
            loiDocModels.push(loiDocModel);
425
        });
426
        console.log(loiDocModels);
427
        var loiDocModelData = JSON.stringify(loiDocModels);
428
        doPostAjaxRequestWithJsonHandler(`${context}/uploadOnboardingDocument?loiId=${loiId}`, loiDocModelData, function (response) {
429
            console.log('response-', response);
430
            pendingLoiForm("main-content");
431
        });
432
    } else {
433
        //Nothing to do
434
    }
435
 
436
 
437
});
438
 
439
$(document).on('click', ".CompletedLoiForm", function () {
33617 tejus.loha 440
    doGetAjaxRequestHandler(`${context}/completedLoiForms`,
33507 tejus.loha 441
        function (response) {
442
            $('#' + 'main-content').html(response);
443
        });
444
});
445
 
446
$(document).on('click', "#createNewOnboardingPanel", function () {
447
    let loiId = $(this).val();
33710 tejus.loha 448
    //let authId = $(this).closest('tr').find('.authId').val();
33507 tejus.loha 449
 
33710 tejus.loha 450
    if (true) {
451
 
452
        doPostAjaxRequestHandler(`${context}/createNewOnboardingPanel?loiId=${loiId}&authId=${0}`,
33507 tejus.loha 453
            function (response) {
454
                if (response) {
33710 tejus.loha 455
                    // doGetAjaxRequestHandler(`${context}/completedLoiForms`,
456
                    //     function (response) {
457
                    //         $('#' + 'main-content').html(response);
458
                    //     });
459
                    alert("it moved successfully ");
33507 tejus.loha 460
                } else {
461
                    //nothing
462
                }
463
 
464
            });
465
    } else {
466
        alert("Please choose RBM ");
467
    }
468
 
469
});
470
 
33617 tejus.loha 471
$(document).on('click', "#downloadAllLoiForm", function () {
472
    const from = $('input[name="from"]').val();
473
    const to = $('input[name="to"]').val();
474
    let missingFields = [];
475
    if (!from) missingFields.push('From date');
476
    if (!to) missingFields.push('To date');
477
    if (missingFields.length > 0) {
478
        alert('Please select : ' + missingFields.join(','));
479
        return;
480
    }
481
    console.log("From - ", from)
482
    console.log("To - ", to)
483
 
484
    window.location.href = `${context}/downloadLoiFromReport?from=${from}&to=${to}`;
485
});
33658 tejus.loha 486
$(document).on('click', ".brandFeePaymentEdit", function () {
487
    var bfcId = $(this).val();
488
    console.log("bfcId - ", bfcId);
489
    // Get the table row
490
    var $row = $(this).closest('tr');
491
    console.log("row - ", $row);
492
    var feeCollectingTimeStamp = $row.find('input[name="feeCollectingTimeStamp"]').val();
493
    var collectedAmount = $row.find('input[name="collectedAmount"]').val();
494
    var paymentReferenceNo = $row.find('input[name="paymentReferenceNo"]').val();
495
    var paymentMode = $row.find('select[name="paymentMode"]').val();
496
    const Data = {
497
        id: bfcId,
498
        feeCollectingTimeStamp: feeCollectingTimeStamp,
499
        collectedAmount: collectedAmount,
500
        paymentReferenceNo: paymentReferenceNo,
501
        paymentMode: paymentMode
502
    };
503
    var jsonData = JSON.stringify(Data);
504
    if (confirm("Are you sure to update details")) {
505
        doPostAjaxRequestWithJsonHandler(`${context}/updatePayment`, jsonData,
506
            function (response) {
507
                pendingLoiForm('main-content');
508
            });
509
    } else {
510
        pendingLoiForm('main-content');
511
    }
33617 tejus.loha 512
 
33658 tejus.loha 513
 
514
});
515
 
516
 
33507 tejus.loha 517
function pendingLoiForm(domId) {
33710 tejus.loha 518
    doGetAjaxRequestHandler(`${context}/pendingLoiForm`,
33507 tejus.loha 519
        function (response) {
520
            $('#' + domId).html(response);
521
        });
522
}