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();
59
    const lessCommitReason = $('input[name="lessCommitReason"]').val();
60
    const vivoCommitmentAmount = $('input[name="vivoCommitmentAmount"]').val();
61
    const oppoCommitmentAmount = $('input[name="oppoCommitmentAmount"]').val();
62
    const samsungCommitmentAmount = $('input[name="samsungCommitmentAmount"]').val();
63
    const xiaomiCommitmentAmount = $('input[name="xiaomiCommitmentAmount"]').val();
64
    const accessoriesCommitmentAmount = $('input[name="accessoriesCommitmentAmount"]').val();
65
    const otherBrandsCommitmentAmount = $('input[name="otherBrandsCommitmentAmount"]').val();
66
    const totalCommit = $('input[name="totaCommitmentAmount"]').val();
67
    let minCommint = totalCommit >= storePotential * (70 / 100);
68
    const agreedBrandFees = $('select[name="agreedBrandFees"]').val();
69
    console.log("agreedBrandFees - ", agreedBrandFees);
33624 tejus.loha 70
    const values = agreedBrandFees.split(/[-]/); // Split the string
71
    const brandFee = parseFloat(values[1]);
33577 tejus.loha 72
    const brandFeesCollected = $('input[name="brandFeesCollected"]').val();
73
    const paymentMode = $('select[name="paymentMode"]').val();
74
    const paymentReferenceNo = $('input[name="paymentReferenceNo"]').val();
33578 tejus.loha 75
    const feeCollectingDate = $('input[name="feeCollectingDate"]').val();
33577 tejus.loha 76
 
77
    let missingFields = [];
78
    if (!firstName) missingFields.push('First Name');
79
    if (!lastName) missingFields.push('Last Name');
80
    if (mobile.length < 10 || !mobile) {
81
        missingFields.push('Mobile number should be 10 digit');
82
    }
83
    if (!minCommint) {
84
        if (!lessCommitReason) missingFields.push('Less Commit Reason');
85
    }
86
    if (!maritalStatus) missingFields.push('Marital Status');
87
    if (maritalStatus == 1) {
88
        if (!anniversaryDate) missingFields.push('Anniversary Date');
89
    }
90
    if (!email) missingFields.push('Email');
33582 tejus.loha 91
    if (!acquiredDate) missingFields.push('Acquired date');
33577 tejus.loha 92
    if (!dob) missingFields.push('dob(Date of Birth)');
33624 tejus.loha 93
    if (age <= 18) missingFields.push('You must be at least 18 years old to Fill LOI FORM. ');
33577 tejus.loha 94
    if (!panNo) missingFields.push('Pan Number');
95
    if (!adharNo) missingFields.push('Aadhar Number');
96
    if (!gstNo) missingFields.push('GST Number');
97
    if (!bankName) missingFields.push('Bank Name');
98
    if (!ifscCode) missingFields.push('IFSC code');
99
    if (!accountNo) missingFields.push('Account Number');
100
    if (!businessType) missingFields.push('businessType');
101
    if (!companyName) missingFields.push('Company Name');
102
    if (!agreeWalletValue) missingFields.push('Agree Wallet Value');
103
    if (!storeArea) missingFields.push('storeArea');
104
    if (!storePotential) missingFields.push('Store Potential');
105
    if (!oppoCommitmentAmount) missingFields.push('Oppo Commitment');
106
    if (!vivoCommitmentAmount) missingFields.push('Vivo Commitment');
107
    if (!samsungCommitmentAmount) missingFields.push('Samsung Commitment');
108
    if (!xiaomiCommitmentAmount) missingFields.push('Xiaomi Commitment');
109
    if (!accessoriesCommitmentAmount) missingFields.push('Accessories Commitment');
110
    if (!otherBrandsCommitmentAmount) missingFields.push('other Brands Commitment');
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
        vivoCommitmentAmount: vivoCommitmentAmount,
148
        oppoCommitmentAmount: oppoCommitmentAmount,
149
        samsungCommitmentAmount: samsungCommitmentAmount,
150
        xiaomiCommitmentAmount: xiaomiCommitmentAmount,
151
        accessoriesCommitmentAmount: accessoriesCommitmentAmount,
152
        otherBrandsCommitmentAmount: otherBrandsCommitmentAmount,
153
        agreedBrandFees: agreedBrandFees,
154
        brandFeesCollected: brandFeesCollected,
155
        paymentMode: paymentMode,
156
        paymentReferenceNo: paymentReferenceNo,
33578 tejus.loha 157
        feeCollectingTimeStamp: feeCollectingDate,
33577 tejus.loha 158
        billingAddress: billingAddress
159
    };
160
    console.log("form data - ", loiFormData);
161
    if (confirm("Are you sure to submit the form ?")) {
162
        doPostAjaxRequestWithJsonHandler(`${context}/submitLoiForm`, JSON.stringify(loiFormData), function (response) {
163
            console.log('responsee', response);
33507 tejus.loha 164
            if (response) {
165
                alert("Your LOI form Submitted successfully ");
166
                pendingLoiForm("main-content");
167
 
168
            } else {
169
                alert("Your LOI form not Submitted , try again ");
170
                doGetAjaxRequestHandler(`${context}/onboardingForm`,
171
                    function (response) {
172
                        $('#' + 'main-content').html(response);
173
                    });
174
            }
175
        });
176
    }
177
});
33578 tejus.loha 178
 
33507 tejus.loha 179
$(document).on('click', ".updateOnboardingForm", function () {
180
    let loiId = $(this).val();
181
    console.log("form id - ", loiId);
182
    doGetAjaxRequestHandler(context + "/updateOnboardingForm?loiId=" + loiId,
183
        function (response) {
184
            $('#' + 'main-content').html(response);
185
        });
186
});
187
 
33577 tejus.loha 188
$(document).on('click', ".updateLoiFormData", function () {
33507 tejus.loha 189
    let loiId = $(this).val();
190
    let formData = {};
191
    let jsonData = JSON.stringify(objectifyForm($("form[name='Loi_Form']").serializeArray())).trim();
33577 tejus.loha 192
    doPostAjaxRequestWithJsonHandler(`${context}/updateLoiFormData?loiId=` + loiId, jsonData, function (response) {
33507 tejus.loha 193
        if (response) {
194
            alert("LOI Form Updated Successfully..");
195
        }
196
        pendingLoiForm("main-content");
197
    });
198
 
199
});
200
 
201
$(document).on('click', ".pending-onboarding-form", function () {
202
    doGetAjaxRequestHandler(`${context}/pendingOnboardingForm`,
203
        function (response) {
204
            $('#' + 'main-content').html(response);
205
        });
206
});
207
$(document).on('click', "#addBrandFeePayment", function () {
208
    let formData = objectifyForm($("form[name='brandFeeCollectionForm']").serializeArray());
209
    let loiId = $(this).val();
210
    console.log("form id -", loiId);
211
    for (var key in formData) {
212
        if (formData.hasOwnProperty(key) && formData[key].trim() === '') {
213
            alert("The (" + key + ") value is blank please fill this field !");
214
            return false;
215
        }
216
    }
217
    let jsonData = JSON.stringify(formData);
33525 tejus.loha 218
    if (confirm("Are you sure all payment details are correct ? once payment is add ,you can't able to change details.")) {
219
        doPostAjaxRequestWithJsonHandler(`${context}/brandfeeCollection?loiId=` + loiId, jsonData, function (response) {
220
            console.log("brand collection...");
221
            if (response) {
222
                alert("Payment add successfully...");
223
                pendingLoiForm("main-content");
33507 tejus.loha 224
 
33525 tejus.loha 225
            } else {
226
                //console
227
            }
228
        });
229
    } else {
230
        //Do nothing
231
    }
33507 tejus.loha 232
 
233
});
234
 
235
$(document).on('click', ".generateLoi", function () {
236
    let loiId = $(this).val();
237
    console.log("form id - ", loiId);
238
    doGetAjaxRequestHandler(context + "/generateLoi?loiId=" + loiId,
239
        function (response) {
240
            $('#' + 'main-content').html(response);
241
        });
242
});
243
 
244
$(document).on('click', "#LOI_otp", function () {
245
    let loiId = $(this).val();
246
    console.log("loiId-", loiId);
33577 tejus.loha 247
    if (confirm("Are you sure to send OTP ?")) {
248
        doPostAjaxRequestHandler(`${context}/loiAcceptanceOtp?loiId=` + loiId,
249
            function (response) {
250
                alert(response);
251
                doGetAjaxRequestHandler(context + "/generateLoi?loiId=" + loiId,
252
                    function (response) {
253
                        $('#' + 'main-content').html(response);
254
                    });
255
            });
256
    } else {
257
        alert("OTP not send .");
258
    }
259
 
33507 tejus.loha 260
});
261
 
262
 
263
$(document).on('click', ".onboardingFormDone", function () {
264
    let loiId = $(this).val();
265
    var loi = $(document).find(".upload-form-loi input[type=file]").val();
266
    console.log("form id - ", loiId);
267
    doPostAjaxRequestHandler(`${context}/uploadLoi?loiId=${loiId}&loi=${loi}`,
268
        function (response) {
269
            $('#' + 'main-content').html(response);
270
        });
271
});
272
 
273
//confirmPayment
33525 tejus.loha 274
$(document).on('click', ".paymentConfirmBtn", function () {
275
    let approval = $(this).data('approval');
33507 tejus.loha 276
    let bfcId = $(this).val();
33525 tejus.loha 277
    let description = "All details are correct";
278
    if (confirm("Are you sure to confirm this payment ?")) {
279
        doPutAjaxRequestHandler(`${context}/feePaymentApproval?bfcId=${bfcId}&feePaymentStatus=${approval}&description=${description}`,
280
            function (response) {
281
                if (response) {
282
                    alert("Payment is confirm successfully");
283
                }
284
                pendingLoiForm("main-content");
285
            });
286
    } else {
287
        //do nothing
288
    }
289
});
290
 
291
$(document).on('click', ".paymentRejectBtn", function () {
33507 tejus.loha 292
    let approval = $(this).data('approval');
33525 tejus.loha 293
    let bfcId = $(this).val();
294
    let description;
295
    description = prompt("Reason for rejection..");
296
    if (description !== null) {
297
        if (confirm("Are you sure to Reject this payment ?")) {
298
            doPutAjaxRequestHandler(`${context}/feePaymentApproval?bfcId=${bfcId}&feePaymentStatus=${approval}&description=${description}`,
299
                function (response) {
300
                    if (!response) {
301
                        alert("Payment is rejected successfully");
302
                    }
303
                    pendingLoiForm("main-content");
304
                });
305
        } else {
306
            //do nothing
307
        }
308
    } else {
309
        alert("Please mention the reason as description and try again");
310
    }
33507 tejus.loha 311
});
312
$(document).on('click', ".upload-document-form", function () {
313
    let loiId = $(this).val();
33617 tejus.loha 314
    doGetAjaxRequestHandler(`${context}/uploadDocumentForm?loiId=${loiId}`,
33507 tejus.loha 315
        function (response) {
316
            $('#' + 'main-content').html(response);
317
        });
318
});
319
$(document).on('input', 'table#OnboardingDocumentTable input[type=file]', function () {
320
    if (confirm('Confirm file upload ?')) {
321
        var fileSelector = $(this)[0];
322
        if (fileSelector != undefined
323
            && fileSelector.files[0] != undefined) {
324
            var file = this.files[0];
325
            console.log("file", file);
326
            let fileInput = $(this);
327
            console.log("fileInput", file);
328
            uploadDocument(file, function (documentId) {
329
                console.log("documentIdzzz  : ", documentId);
330
                fileInput.closest('td').find(".documentId").val(documentId);
331
            });
332
        }
333
    }
334
});
335
$(document).on('click', ".mk_docApproval", function () {
336
    let loiId = $(this).data('form_id');
337
    let docMasterId = $(this).data('doc_master_id');
338
    let flag = $(this).data('flag');
339
    console.log("flag -", flag);
340
    doPutAjaxRequestHandler(`${context}/documentVerify?loiId=${loiId}&docMasterId=${docMasterId}&flag=${flag}`,
341
        function (response) {
342
            alert(response);
33617 tejus.loha 343
            doGetAjaxRequestHandler(`${context}/uploadDocumentForm?loiId=${loiId}`,
33507 tejus.loha 344
                function (response) {
345
                    $('#' + 'main-content').html(response);
346
                });
347
 
348
        });
349
});
350
$(document).on('click', "#uploadDocumentbtn1", function () {
351
    if (confirm("Are you sure to upload all documents ?")) {
352
        var loiId = $(this).val();
353
        var loiDocModels = [];
354
        console.log("loiId -", loiId);
355
        $("#OnboardingDocumentTable > tbody > tr").each(function (rowIndex) {
356
            var marsterId = $(this).find(".masterId").val();
357
            var docId = $(this).find(".documentId").val();
358
            var docName = $(this).find(".documentName").val();
359
            console.log("marsterId -", marsterId);
360
            var loiDocModel = {
361
                documentId: docId,
362
                documentName: docName,
363
                documentMasterId: marsterId
364
            };
365
            loiDocModels.push(loiDocModel);
366
        });
367
        console.log(loiDocModels);
368
        var loiDocModelData = JSON.stringify(loiDocModels);
369
        doPostAjaxRequestWithJsonHandler(`${context}/uploadOnboardingDocument?loiId=${loiId}`, loiDocModelData, function (response) {
370
            console.log('response-', response);
371
            pendingLoiForm("main-content");
372
        });
373
    } else {
374
        //Nothing to do
375
    }
376
 
377
 
378
});
379
 
380
$(document).on('click', ".CompletedLoiForm", function () {
33617 tejus.loha 381
    doGetAjaxRequestHandler(`${context}/completedLoiForms`,
33507 tejus.loha 382
        function (response) {
383
            $('#' + 'main-content').html(response);
384
        });
385
});
386
 
387
$(document).on('click', "#createNewOnboardingPanel", function () {
388
    let loiId = $(this).val();
389
    let authId = $(this).closest('tr').find('.authId').val();
390
    if (authId != " ") {
391
 
33617 tejus.loha 392
        doPostAjaxRequestHandler(`${context}/createNewOnboardingPanel?loiId=${loiId}&authId=${authId}`,
33507 tejus.loha 393
            function (response) {
394
                if (response) {
33617 tejus.loha 395
                    doGetAjaxRequestHandler(`${context}/completedLoiForms`,
33507 tejus.loha 396
                        function (response) {
397
                            $('#' + 'main-content').html(response);
398
                        });
399
                } else {
400
                    //nothing
401
                }
402
 
403
            });
404
    } else {
405
        alert("Please choose RBM ");
406
    }
407
 
408
});
409
 
33617 tejus.loha 410
$(document).on('click', "#downloadAllLoiForm", function () {
411
    const from = $('input[name="from"]').val();
412
    const to = $('input[name="to"]').val();
413
    let missingFields = [];
414
    if (!from) missingFields.push('From date');
415
    if (!to) missingFields.push('To date');
416
    if (missingFields.length > 0) {
417
        alert('Please select : ' + missingFields.join(','));
418
        return;
419
    }
420
    console.log("From - ", from)
421
    console.log("To - ", to)
422
 
423
    window.location.href = `${context}/downloadLoiFromReport?from=${from}&to=${to}`;
424
});
425
 
33507 tejus.loha 426
function pendingLoiForm(domId) {
427
    doGetAjaxRequestHandler(`${context}/pendingOnboardingForm`,
428
        function (response) {
429
            $('#' + domId).html(response);
430
        });
431
}