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