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
});
33710 tejus.loha 183
$(document).on('click', ".save_agree_brand_fee", function () {
184
    let loiId = $(this).val();
185
    var $tr = $(this).closest('tr');
186
    var agreedBrandFee = $tr.find('input[name="brandFee"]').val();
187
    if (confirm("Are you sure to change Agreed brand fee")) {
188
        doPutAjaxRequestHandler(`${context}/updateAgreedBrandFee?loiId=${loiId}&brandFee=${agreedBrandFee}`, function (response) {
189
            pendingLoiForm("main-content");
190
        });
191
    } else {
192
        pendingLoiForm("main-content");
193
    }
194
});
33507 tejus.loha 195
 
33658 tejus.loha 196
$(document).on('click', ".updateLoiFormDataButton", function () {
197
    console.log("updateLoiFormDataButton clicked..");
198
    let loiId = $(this).data('loiid');
199
 
200
    const firstName = $('input[name="firstName"]').val();
201
    const lastName = $('input[name="lastName"]').val();
202
    const mobile = $('input[name="mobile"]').val();
203
    const email = $('input[name="email"]').val();
204
    const landline = $('input[name="landline"]').val();
205
    const dob = $('input[name="dob"]').val();
206
    const panNo = $('input[name="panNo"]').val();
207
    const adharNo = $('input[name="adharNo"]').val();
208
    let missingFields = [];
209
    if (!firstName) missingFields.push('First Name');
210
    if (!lastName) missingFields.push('Last Name');
211
    if (mobile.length < 10 || !mobile) {
212
        missingFields.push('Mobile number should be 10 digit');
213
    }
214
    if (!dob) missingFields.push('dob(Date of Birth)');
215
    if (!panNo) missingFields.push('Pan Number');
216
    if (!adharNo) missingFields.push('Aadhar Number');
217
    if (!email) missingFields.push('Email');
218
    if (missingFields.length > 0) {
219
        alert('The following fields are required: ' + missingFields.join(', '));
220
        return;
221
    }
222
    const loiFormData = {
223
        firstName: firstName,
224
        lastName: lastName,
225
        mobile: mobile,
226
        email: email,
227
        landline: landline,
228
        dob: dob,
229
        panNo: panNo,
230
        adharNo: adharNo
231
    };
232
    console.log("loiFormData - ", loiFormData);
233
    alert("you want update ..");
234
    doPostAjaxRequestWithJsonHandler(`${context}/updateLoiFormData?loiId=${loiId}`, JSON.stringify(loiFormData), function (response) {
33507 tejus.loha 235
        pendingLoiForm("main-content");
236
    });
237
 
238
});
239
 
240
$(document).on('click', ".pending-onboarding-form", function () {
33710 tejus.loha 241
    doGetAjaxRequestHandler(`${context}/pendingLoiForm`,
33507 tejus.loha 242
        function (response) {
243
            $('#' + 'main-content').html(response);
244
        });
245
});
246
$(document).on('click', "#addBrandFeePayment", function () {
247
    let formData = objectifyForm($("form[name='brandFeeCollectionForm']").serializeArray());
248
    let loiId = $(this).val();
249
    console.log("form id -", loiId);
250
    for (var key in formData) {
251
        if (formData.hasOwnProperty(key) && formData[key].trim() === '') {
252
            alert("The (" + key + ") value is blank please fill this field !");
253
            return false;
254
        }
255
    }
256
    let jsonData = JSON.stringify(formData);
33658 tejus.loha 257
    if (confirm("Are you sure to add payment ?")) {
33525 tejus.loha 258
        doPostAjaxRequestWithJsonHandler(`${context}/brandfeeCollection?loiId=` + loiId, jsonData, function (response) {
259
            if (response) {
260
                alert("Payment add successfully...");
261
                pendingLoiForm("main-content");
33507 tejus.loha 262
 
33525 tejus.loha 263
            }
264
        });
265
    } else {
33658 tejus.loha 266
        alert("Payment is not add.");
267
 
33525 tejus.loha 268
    }
33507 tejus.loha 269
 
270
});
271
 
272
$(document).on('click', ".generateLoi", function () {
273
    let loiId = $(this).val();
274
    console.log("form id - ", loiId);
275
    doGetAjaxRequestHandler(context + "/generateLoi?loiId=" + loiId,
276
        function (response) {
277
            $('#' + 'main-content').html(response);
278
        });
279
});
280
 
281
$(document).on('click', "#LOI_otp", function () {
282
    let loiId = $(this).val();
283
    console.log("loiId-", loiId);
33577 tejus.loha 284
    if (confirm("Are you sure to send OTP ?")) {
285
        doPostAjaxRequestHandler(`${context}/loiAcceptanceOtp?loiId=` + loiId,
286
            function (response) {
287
                alert(response);
288
                doGetAjaxRequestHandler(context + "/generateLoi?loiId=" + loiId,
289
                    function (response) {
290
                        $('#' + 'main-content').html(response);
291
                    });
292
            });
293
    } else {
294
        alert("OTP not send .");
295
    }
296
 
33507 tejus.loha 297
});
298
 
299
 
300
$(document).on('click', ".onboardingFormDone", function () {
301
    let loiId = $(this).val();
302
    var loi = $(document).find(".upload-form-loi input[type=file]").val();
303
    console.log("form id - ", loiId);
304
    doPostAjaxRequestHandler(`${context}/uploadLoi?loiId=${loiId}&loi=${loi}`,
305
        function (response) {
306
            $('#' + 'main-content').html(response);
307
        });
308
});
309
 
310
//confirmPayment
33525 tejus.loha 311
$(document).on('click', ".paymentConfirmBtn", function () {
312
    let approval = $(this).data('approval');
33507 tejus.loha 313
    let bfcId = $(this).val();
33525 tejus.loha 314
    let description = "All details are correct";
315
    if (confirm("Are you sure to confirm this payment ?")) {
316
        doPutAjaxRequestHandler(`${context}/feePaymentApproval?bfcId=${bfcId}&feePaymentStatus=${approval}&description=${description}`,
317
            function (response) {
318
                if (response) {
319
                    alert("Payment is confirm successfully");
320
                }
321
                pendingLoiForm("main-content");
322
            });
323
    } else {
324
        //do nothing
325
    }
326
});
327
 
328
$(document).on('click', ".paymentRejectBtn", function () {
33507 tejus.loha 329
    let approval = $(this).data('approval');
33525 tejus.loha 330
    let bfcId = $(this).val();
331
    let description;
332
    description = prompt("Reason for rejection..");
333
    if (description !== null) {
334
        if (confirm("Are you sure to Reject this payment ?")) {
335
            doPutAjaxRequestHandler(`${context}/feePaymentApproval?bfcId=${bfcId}&feePaymentStatus=${approval}&description=${description}`,
336
                function (response) {
337
                    if (!response) {
338
                        alert("Payment is rejected successfully");
339
                    }
340
                    pendingLoiForm("main-content");
341
                });
342
        } else {
343
            //do nothing
344
        }
345
    } else {
346
        alert("Please mention the reason as description and try again");
347
    }
33507 tejus.loha 348
});
349
$(document).on('click', ".upload-document-form", function () {
350
    let loiId = $(this).val();
33617 tejus.loha 351
    doGetAjaxRequestHandler(`${context}/uploadDocumentForm?loiId=${loiId}`,
33507 tejus.loha 352
        function (response) {
353
            $('#' + 'main-content').html(response);
354
        });
355
});
356
$(document).on('input', 'table#OnboardingDocumentTable input[type=file]', function () {
357
    if (confirm('Confirm file upload ?')) {
358
        var fileSelector = $(this)[0];
359
        if (fileSelector != undefined
360
            && fileSelector.files[0] != undefined) {
361
            var file = this.files[0];
362
            console.log("file", file);
363
            let fileInput = $(this);
364
            console.log("fileInput", file);
365
            uploadDocument(file, function (documentId) {
366
                console.log("documentIdzzz  : ", documentId);
367
                fileInput.closest('td').find(".documentId").val(documentId);
368
            });
369
        }
370
    }
371
});
372
$(document).on('click', ".mk_docApproval", function () {
373
    let loiId = $(this).data('form_id');
374
    let docMasterId = $(this).data('doc_master_id');
375
    let flag = $(this).data('flag');
376
    console.log("flag -", flag);
377
    doPutAjaxRequestHandler(`${context}/documentVerify?loiId=${loiId}&docMasterId=${docMasterId}&flag=${flag}`,
378
        function (response) {
379
            alert(response);
33617 tejus.loha 380
            doGetAjaxRequestHandler(`${context}/uploadDocumentForm?loiId=${loiId}`,
33507 tejus.loha 381
                function (response) {
382
                    $('#' + 'main-content').html(response);
383
                });
384
 
385
        });
386
});
387
$(document).on('click', "#uploadDocumentbtn1", function () {
388
    if (confirm("Are you sure to upload all documents ?")) {
389
        var loiId = $(this).val();
390
        var loiDocModels = [];
391
        console.log("loiId -", loiId);
392
        $("#OnboardingDocumentTable > tbody > tr").each(function (rowIndex) {
393
            var marsterId = $(this).find(".masterId").val();
394
            var docId = $(this).find(".documentId").val();
395
            var docName = $(this).find(".documentName").val();
396
            console.log("marsterId -", marsterId);
397
            var loiDocModel = {
398
                documentId: docId,
399
                documentName: docName,
400
                documentMasterId: marsterId
401
            };
402
            loiDocModels.push(loiDocModel);
403
        });
404
        console.log(loiDocModels);
405
        var loiDocModelData = JSON.stringify(loiDocModels);
406
        doPostAjaxRequestWithJsonHandler(`${context}/uploadOnboardingDocument?loiId=${loiId}`, loiDocModelData, function (response) {
407
            console.log('response-', response);
408
            pendingLoiForm("main-content");
409
        });
410
    } else {
411
        //Nothing to do
412
    }
413
 
414
 
415
});
416
 
417
$(document).on('click', ".CompletedLoiForm", function () {
33617 tejus.loha 418
    doGetAjaxRequestHandler(`${context}/completedLoiForms`,
33507 tejus.loha 419
        function (response) {
420
            $('#' + 'main-content').html(response);
421
        });
422
});
423
 
424
$(document).on('click', "#createNewOnboardingPanel", function () {
425
    let loiId = $(this).val();
33710 tejus.loha 426
    //let authId = $(this).closest('tr').find('.authId').val();
33507 tejus.loha 427
 
33710 tejus.loha 428
    if (true) {
429
 
430
        doPostAjaxRequestHandler(`${context}/createNewOnboardingPanel?loiId=${loiId}&authId=${0}`,
33507 tejus.loha 431
            function (response) {
432
                if (response) {
33710 tejus.loha 433
                    // doGetAjaxRequestHandler(`${context}/completedLoiForms`,
434
                    //     function (response) {
435
                    //         $('#' + 'main-content').html(response);
436
                    //     });
437
                    alert("it moved successfully ");
33507 tejus.loha 438
                } else {
439
                    //nothing
440
                }
441
 
442
            });
443
    } else {
444
        alert("Please choose RBM ");
445
    }
446
 
447
});
448
 
33617 tejus.loha 449
$(document).on('click', "#downloadAllLoiForm", function () {
450
    const from = $('input[name="from"]').val();
451
    const to = $('input[name="to"]').val();
452
    let missingFields = [];
453
    if (!from) missingFields.push('From date');
454
    if (!to) missingFields.push('To date');
455
    if (missingFields.length > 0) {
456
        alert('Please select : ' + missingFields.join(','));
457
        return;
458
    }
459
    console.log("From - ", from)
460
    console.log("To - ", to)
461
 
462
    window.location.href = `${context}/downloadLoiFromReport?from=${from}&to=${to}`;
463
});
33658 tejus.loha 464
$(document).on('click', ".brandFeePaymentEdit", function () {
465
    var bfcId = $(this).val();
466
    console.log("bfcId - ", bfcId);
467
    // Get the table row
468
    var $row = $(this).closest('tr');
469
    console.log("row - ", $row);
470
    var feeCollectingTimeStamp = $row.find('input[name="feeCollectingTimeStamp"]').val();
471
    var collectedAmount = $row.find('input[name="collectedAmount"]').val();
472
    var paymentReferenceNo = $row.find('input[name="paymentReferenceNo"]').val();
473
    var paymentMode = $row.find('select[name="paymentMode"]').val();
474
    const Data = {
475
        id: bfcId,
476
        feeCollectingTimeStamp: feeCollectingTimeStamp,
477
        collectedAmount: collectedAmount,
478
        paymentReferenceNo: paymentReferenceNo,
479
        paymentMode: paymentMode
480
    };
481
    var jsonData = JSON.stringify(Data);
482
    if (confirm("Are you sure to update details")) {
483
        doPostAjaxRequestWithJsonHandler(`${context}/updatePayment`, jsonData,
484
            function (response) {
485
                pendingLoiForm('main-content');
486
            });
487
    } else {
488
        pendingLoiForm('main-content');
489
    }
33617 tejus.loha 490
 
33658 tejus.loha 491
 
492
});
493
 
494
 
33507 tejus.loha 495
function pendingLoiForm(domId) {
33710 tejus.loha 496
    doGetAjaxRequestHandler(`${context}/pendingLoiForm`,
33507 tejus.loha 497
        function (response) {
498
            $('#' + domId).html(response);
499
        });
500
}