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