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