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