Subversion Repositories SmartDukaan

Rev

Rev 33525 | Rev 33578 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed

$(document).on('click', ".onboarding-form1", function () {
    doGetAjaxRequestHandler(`${context}/onboardingForm`,
        function (response) {
            $('#' + 'main-content').html(response);
        });
});


$(document).on('change', "#maritalStatus", function () {
    let maritalStatus = $(this).val();
    console.log("maritalStatus - " + maritalStatus);
    if (maritalStatus == 1) {
        $(".loiAnniversaryDate").removeClass('hide-model');
        $(".loiAnniversaryDate").addClass('show-model');
    } else {
        $(".loiAnniversaryDate").removeClass('show-model');
        $(".loiAnniversaryDate").addClass('hide-model');
    }

});
// $(document).on('click', ".submitLoiForm", function () {
//     console.log("submitLoiForm clicked");
//     $("#Loi_Form").validate({
//         rules: {
//             firstName: {required: true},
//             lastName: {required: true},
//             mobile: {
//                 required: true,
//                 minlength: 10,
//                 maxlength: 10
//             },
//             landline: {required: false},
//             email: {
//                 required: true,
//                 email: true
//             },
//             dob: {required: true, data: true},
//             anniversaryDate: {required: false,},
//             panNo: {
//                 required: true,
//                 minlength: 10,
//                 maxlength: 10
//             },
//             adharNo: {
//                 required: true,
//                 minlength: 10,
//                 maxlength: 10
//             },
//             gstNo: {required: true},
//             bankName: {required: true},
//             ifscCode: {required: true},
//             accountNo: {required: true},
//
//         },
//         messages: {
//             firstName: {required: "Please fill First Name"},
//             lastName: {required: "Please fill Last Name"},
//             mobile: {required: "Please fill 10 Digit Mobile Number"},
//             email: {required: "Please fill email"},
//             dob: {required: "Please fill Date of Birth", data: true},
//             anniversaryDate: {required: false,},
//             panNo: {required: "Please fill Pan Number"},
//             adharNo: {required: "Please fill 12 digit Aadhar Number"},
//             gstNo: {required: "Please fill GST No"},
//             bankName: {required: "Please fill Bank Name"},
//             ifscCode: {required: "Please fill Ifsc Code"},
//             accountNo: {required: "Please fill Account Number"},
//         },
//         submitHandler: function (form, event) {
//             console.log("submit handler");
//             event.preventDefault();
//             let loiFormData = {};
//             loiFormData['firstName'] = $('input[name="firstName"]').val();
//             loiFormData['lastName'] = $('input[name="lastName"]').val();
//             loiFormData['mobile'] = $('input[name="mobile"]').val();
//             loiFormData['email'] = $('input[name="email"]').val();
//             loiFormData['dob'] = $('input[name="dob"]').val();
//             loiFormData['city'] = $('input[name="city"]').val();
//             loiFormData['anniversaryDate'] = $('input[name="anniversaryDate"]').val();
//             loiFormData['panNo'] = $('input[name="panNo"]').val();
//             loiFormData['adharNo'] = $('input[name="adharNo"]').val();
//             loiFormData['gstNo'] = $('input[name="gstNo"]').val();
//             loiFormData['adharNo'] = $('input[name="adharNo"]').val();
//             loiFormData['bankName'] = $('input[name="bankName"]').val();
//             loiFormData['ifscCode'] = $('input[name="ifscCode"]').val();
//             loiFormData['accountNo'] = $('input[name="accountNo"]').val();
//             loiFormData['businessType'] = $('input[name="businessType"]').val();
//             loiFormData['companyName'] = $('input[name="companyName"]').val();
//             loiFormData['gstPin'] = $('input[name="gstPin"]').val();
//             loiFormData['gstState'] = $('input[name="gstState"]').val();
//             loiFormData['gstCity'] = $('input[name="gstCity"]').val();
//             loiFormData['gstDistrict'] = $('input[name="gstDistrict"]').val();
//             loiFormData['bankName'] = $('input[name="bankName"]').val();
//             loiFormData['agreeWalletValue'] = $('input[name="agreeWalletValue"]').val();
//             loiFormData['storeArea'] = $('input[name="storeArea"]').val();
//             loiFormData['storePotential'] = $('input[name="storePotential"]').val();
//             loiFormData['totaCommitmentAmount'] = $('input[name="totaCommitmentAmount"]').val();
//             loiFormData['lessCommitReason'] = $('input[name="lessCommitReason"]').val();
//             loiFormData['vivoCommitmentAmount'] = $('input[name="vivoCommitmentAmount"]').val();
//             loiFormData['oppoCommitmentAmount'] = $('input[name="oppoCommitmentAmount"]').val();
//             loiFormData['samsungCommitmentAmount'] = $('input[name="samsungCommitmentAmount"]').val();
//             loiFormData['xiaomiCommitmentAmount'] = $('input[name="xiaomiCommitmentAmount"]').val();
//             loiFormData['accessoriesCommitmentAmount'] = $('input[name="accessoriesCommitmentAmount"]').val();
//             loiFormData['otherBrandsCommitmentAmount'] = $('input[name="otherBrandsCommitmentAmount"]').val();
//             loiFormData['agreedBrandFees'] = $('input[name="agreedBrandFees"]').val();
//             loiFormData['brandFeesCollected'] = $('input[name="brandFeesCollected"]').val();
//             loiFormData['paymentMode'] = $('input[name="paymentMode"]').val();
//             loiFormData['paymentReferenceNo'] = $('input[name="paymentReferenceNo"]').val();
//             loiFormData['paymentMode'] = $('input[name="paymentMode"]').val();
//             //let formData = objectifyForm($("form[name='Loi_Form']").serializeArray());
//             if (confirm("Are you sure to submit form ?")) {
//                 let jsonData = JSON.stringify(loiFormData);
//                 console.log("jsonData - ", jsonData);
//                 doPostAjaxRequestWithJsonHandler(`${context}/submitLoiForm`, jsonData, function (response) {
//                     if (response) {
//                         alert("Your LOI form Submitted successfully ");
//                         pendingLoiForm("main-content");
//
//                     } else {
//                         alert("Your LOI form not Submitted , try again ");
//
//                     }
//                 });
//             }
//         }
//
//     });
//
// });

$(document).on('click', ".submitLoiForm", function () {
    // Gather input values
    const referId = $('select[name="referId"]').val();
    const billingAddress = $('select[name="billingAddress"]').val();
    const firstName = $('input[name="firstName"]').val();
    const lastName = $('input[name="lastName"]').val();
    const mobile = $('input[name="mobile"]').val();
    const email = $('input[name="email"]').val();
    const landline = $('input[name="landline"]').val();
    const dob = $('input[name="dob"]').val();
    var maritalStatus = $('select[name="maritalStatus"]').val();
    console.log("maritalStatus - ", maritalStatus);
    const anniversaryDate = $('input[name="anniversaryDate"]').val();
    const panNo = $('input[name="panNo"]').val();
    const adharNo = $('input[name="adharNo"]').val();
    const gstNo = $('input[name="gstNo"]').val();
    const bankName = $('input[name="bankName"]').val();
    const ifscCode = $('input[name="ifscCode"]').val();
    const accountNo = $('input[name="accountNo"]').val();
    const businessType = $('select[name="businessType"]').val();
    const companyName = $('input[name="companyName"]').val();
    const gstPin = $('input[name="gstPin"]').val();
    const gstState = $('input[name="gstState"]').val();
    const gstCity = $('input[name="gstCity"]').val();
    const gstDistrict = $('input[name="gstDistrict"]').val();
    const agreeWalletValue = $('select[name="agreeWalletValue"]').val();
    const storeArea = $('input[name="storeArea"]').val();
    const storePotential = $('input[name="storePotential"]').val();
    const lessCommitReason = $('input[name="lessCommitReason"]').val();
    const vivoCommitmentAmount = $('input[name="vivoCommitmentAmount"]').val();
    const oppoCommitmentAmount = $('input[name="oppoCommitmentAmount"]').val();
    const samsungCommitmentAmount = $('input[name="samsungCommitmentAmount"]').val();
    const xiaomiCommitmentAmount = $('input[name="xiaomiCommitmentAmount"]').val();
    const accessoriesCommitmentAmount = $('input[name="accessoriesCommitmentAmount"]').val();
    const otherBrandsCommitmentAmount = $('input[name="otherBrandsCommitmentAmount"]').val();
    const totalCommit = $('input[name="totaCommitmentAmount"]').val();
    console.log("totalCommit - ", totalCommit);
    let minCommint = totalCommit >= storePotential * (70 / 100);
    const agreedBrandFees = $('select[name="agreedBrandFees"]').val();
    console.log("agreedBrandFees - ", agreedBrandFees);
    const brandFeesCollected = $('input[name="brandFeesCollected"]').val();
    const paymentMode = $('select[name="paymentMode"]').val();
    console.log("paymentMode - ", paymentMode);
    const paymentReferenceNo = $('input[name="paymentReferenceNo"]').val();


    let missingFields = [];
    if (!firstName) missingFields.push('First Name');
    if (!referId) missingFields.push('Refer by');
    if (!lastName) missingFields.push('Last Name');
    if (mobile.length < 10 || !mobile) {
        missingFields.push('Mobile number should be 10 digit');
    }
    if (!minCommint) {
        if (!lessCommitReason) missingFields.push('Less Commit Reason');
    }
    if (!maritalStatus) missingFields.push('Marital Status');
    if (maritalStatus == 1) {
        if (!anniversaryDate) missingFields.push('Anniversary Date');
    }
    if (!email) missingFields.push('Email');
    if (!dob) missingFields.push('dob(Date of Birth)');
    if (!panNo) missingFields.push('Pan Number');
    if (!adharNo) missingFields.push('Aadhar Number');
    if (!gstNo) missingFields.push('GST Number');
    if (!bankName) missingFields.push('Bank Name');
    if (!ifscCode) missingFields.push('IFSC code');
    if (!accountNo) missingFields.push('Account Number');
    if (!businessType) missingFields.push('businessType');
    if (!companyName) missingFields.push('Company Name');
    if (!agreeWalletValue) missingFields.push('Agree Wallet Value');
    if (!storeArea) missingFields.push('storeArea');
    if (!storePotential) missingFields.push('Store Potential');
    if (!oppoCommitmentAmount) missingFields.push('Oppo Commitment');
    if (!vivoCommitmentAmount) missingFields.push('Vivo Commitment');
    if (!samsungCommitmentAmount) missingFields.push('Samsung Commitment');
    if (!xiaomiCommitmentAmount) missingFields.push('Xiaomi Commitment');
    if (!accessoriesCommitmentAmount) missingFields.push('Accessories Commitment');
    if (!otherBrandsCommitmentAmount) missingFields.push('other Brands Commitment');
    if (!agreedBrandFees) missingFields.push('Agreed Brand Fees');
    if (!brandFeesCollected) missingFields.push('Brand Fees Collected');
    if (!paymentMode) missingFields.push('Payment Mode');
    if (!paymentReferenceNo) missingFields.push('Payment Reference No');
    if (!brandFeesCollected) missingFields.push('Brand Fees Collected');

    if (missingFields.length > 0) {
        alert('The following fields are required: ' + missingFields.join(', '));
        return;
    }

    const loiFormData = {
        referId: referId,
        businessType: businessType,
        firstName: firstName,
        lastName: lastName,
        mobile: mobile,
        email: email,
        landline: landline,
        dob: dob,
        anniversaryDate: anniversaryDate,
        panNo: panNo,
        adharNo: adharNo,
        gstNo: gstNo,
        bankName: bankName,
        ifscCode: ifscCode,
        accountNo: accountNo,
        companyName: companyName,
        gstPin: gstPin,
        gstState: gstState,
        gstCity: gstCity,
        gstDistrict: gstDistrict,
        agreeWalletValue: agreeWalletValue,
        storeArea: storeArea,
        storePotential: storePotential,
        lessCommitReason: lessCommitReason,
        vivoCommitmentAmount: vivoCommitmentAmount,
        oppoCommitmentAmount: oppoCommitmentAmount,
        samsungCommitmentAmount: samsungCommitmentAmount,
        xiaomiCommitmentAmount: xiaomiCommitmentAmount,
        accessoriesCommitmentAmount: accessoriesCommitmentAmount,
        otherBrandsCommitmentAmount: otherBrandsCommitmentAmount,
        agreedBrandFees: agreedBrandFees,
        brandFeesCollected: brandFeesCollected,
        paymentMode: paymentMode,
        paymentReferenceNo: paymentReferenceNo,
        billingAddress: billingAddress
    };
    console.log("form data - ", loiFormData);
    if (confirm("Are you sure to submit the form ?")) {
        doPostAjaxRequestWithJsonHandler(`${context}/submitLoiForm`, JSON.stringify(loiFormData), function (response) {
            console.log('responsee', response);
            if (response) {
                alert("Your LOI form Submitted successfully ");
                pendingLoiForm("main-content");

            } else {
                alert("Your LOI form not Submitted , try again ");
                doGetAjaxRequestHandler(`${context}/onboardingForm`,
                    function (response) {
                        $('#' + 'main-content').html(response);
                    });
            }
        });
    }
});
// $(document).on('click', ".submitLoiForm", function () {
//     if (confirm("Are you sure to submit form ?")) {
//         let formData = objectifyForm($("form[name='Loi_Form']").serializeArray());
//         for (var key in formData) {
//             if ((formData.hasOwnProperty(key) && formData[key].trim() === '')||formData[key].trim() !== null) {
//                 alert("The (" + key + ") value is blank please fill this field !");
//                 return false;
//             }
//         }
//         let jsonData = JSON.stringify(formData);
//         doPostAjaxRequestWithJsonHandler(`${context}/submitLoiForm`, jsonData, function (response) {
//             if (response) {
//                 alert("Your LOI form Submitted successfully ");
//                 pendingLoiForm("main-content");
//
//             } else {
//                 alert("Your LOI form not Submitted , try again ");
//                 doGetAjaxRequestHandler(`${context}/onboardingForm`,
//                     function (response) {
//                         $('#' + 'main-content').html(response);
//                     });
//             }
//         });
//     } else {
//         //nothing to do now
//     }
//
// });
$(document).on('click', ".updateOnboardingForm", function () {
    let loiId = $(this).val();
    console.log("form id - ", loiId);
    doGetAjaxRequestHandler(context + "/updateOnboardingForm?loiId=" + loiId,
        function (response) {
            $('#' + 'main-content').html(response);
        });
});

$(document).on('click', ".updateLoiFormData", function () {
    let loiId = $(this).val();
    let formData = {};
    let jsonData = JSON.stringify(objectifyForm($("form[name='Loi_Form']").serializeArray())).trim();
    doPostAjaxRequestWithJsonHandler(`${context}/updateLoiFormData?loiId=` + loiId, jsonData, function (response) {
        if (response) {
            alert("LOI Form Updated Successfully..");
        }
        pendingLoiForm("main-content");
    });

});

$(document).on('click', ".pending-onboarding-form", function () {
    doGetAjaxRequestHandler(`${context}/pendingOnboardingForm`,
        function (response) {
            $('#' + 'main-content').html(response);
        });
});
$(document).on('click', "#addBrandFeePayment", function () {
    let formData = objectifyForm($("form[name='brandFeeCollectionForm']").serializeArray());
    let loiId = $(this).val();
    console.log("form id -", loiId);
    for (var key in formData) {
        if (formData.hasOwnProperty(key) && formData[key].trim() === '') {
            alert("The (" + key + ") value is blank please fill this field !");
            return false;
        }
    }
    let jsonData = JSON.stringify(formData);
    if (confirm("Are you sure all payment details are correct ? once payment is add ,you can't able to change details.")) {
        doPostAjaxRequestWithJsonHandler(`${context}/brandfeeCollection?loiId=` + loiId, jsonData, function (response) {
            console.log("brand collection...");
            if (response) {
                alert("Payment add successfully...");
                pendingLoiForm("main-content");

            } else {
                //console
            }
        });
    } else {
        //Do nothing
    }

});

$(document).on('click', ".generateLoi", function () {
    let loiId = $(this).val();
    console.log("form id - ", loiId);
    doGetAjaxRequestHandler(context + "/generateLoi?loiId=" + loiId,
        function (response) {
            $('#' + 'main-content').html(response);
        });
});

$(document).on('click', "#LOI_otp", function () {
    let loiId = $(this).val();
    console.log("loiId-", loiId);
    if (confirm("Are you sure to send OTP ?")) {
        doPostAjaxRequestHandler(`${context}/loiAcceptanceOtp?loiId=` + loiId,
            function (response) {
                alert(response);
                doGetAjaxRequestHandler(context + "/generateLoi?loiId=" + loiId,
                    function (response) {
                        $('#' + 'main-content').html(response);
                    });
            });
    } else {
        alert("OTP not send .");
    }

});


$(document).on('click', ".onboardingFormDone", function () {
    let loiId = $(this).val();
    var loi = $(document).find(".upload-form-loi input[type=file]").val();
    console.log("form id - ", loiId);
    doPostAjaxRequestHandler(`${context}/uploadLoi?loiId=${loiId}&loi=${loi}`,
        function (response) {
            $('#' + 'main-content').html(response);
        });
});

//confirmPayment
$(document).on('click', ".paymentConfirmBtn", function () {
    let approval = $(this).data('approval');
    let bfcId = $(this).val();
    let description = "All details are correct";
    if (confirm("Are you sure to confirm this payment ?")) {
        doPutAjaxRequestHandler(`${context}/feePaymentApproval?bfcId=${bfcId}&feePaymentStatus=${approval}&description=${description}`,
            function (response) {
                if (response) {
                    alert("Payment is confirm successfully");
                }
                pendingLoiForm("main-content");
            });
    } else {
        //do nothing
    }
});

$(document).on('click', ".paymentRejectBtn", function () {
    let approval = $(this).data('approval');
    let bfcId = $(this).val();
    let description;
    description = prompt("Reason for rejection..");
    if (description !== null) {
        if (confirm("Are you sure to Reject this payment ?")) {
            doPutAjaxRequestHandler(`${context}/feePaymentApproval?bfcId=${bfcId}&feePaymentStatus=${approval}&description=${description}`,
                function (response) {
                    if (!response) {
                        alert("Payment is rejected successfully");
                    }
                    pendingLoiForm("main-content");
                });
        } else {
            //do nothing
        }
    } else {
        alert("Please mention the reason as description and try again");
    }
});
$(document).on('click', ".upload-document-form", function () {
    let loiId = $(this).val();
    doPutAjaxRequestHandler(`${context}/uploadDocumentForm?loiId=${loiId}`,
        function (response) {
            $('#' + 'main-content').html(response);
        });
});
$(document).on('input', 'table#OnboardingDocumentTable input[type=file]', function () {
    if (confirm('Confirm file upload ?')) {
        var fileSelector = $(this)[0];
        if (fileSelector != undefined
            && fileSelector.files[0] != undefined) {
            var file = this.files[0];
            console.log("file", file);
            let fileInput = $(this);
            console.log("fileInput", file);
            uploadDocument(file, function (documentId) {
                console.log("documentIdzzz  : ", documentId);
                fileInput.closest('td').find(".documentId").val(documentId);
            });
        }
    }
});
$(document).on('click', ".mk_docApproval", function () {
    let loiId = $(this).data('form_id');
    let docMasterId = $(this).data('doc_master_id');
    let flag = $(this).data('flag');
    console.log("flag -", flag);
    doPutAjaxRequestHandler(`${context}/documentVerify?loiId=${loiId}&docMasterId=${docMasterId}&flag=${flag}`,
        function (response) {
            alert(response);
            doPutAjaxRequestHandler(`${context}/uploadDocumentForm?loiId=${loiId}`,
                function (response) {
                    $('#' + 'main-content').html(response);
                });

        });
});
$(document).on('click', "#uploadDocumentbtn1", function () {
    if (confirm("Are you sure to upload all documents ?")) {
        var loiId = $(this).val();
        var loiDocModels = [];
        console.log("loiId -", loiId);
        $("#OnboardingDocumentTable > tbody > tr").each(function (rowIndex) {
            var marsterId = $(this).find(".masterId").val();
            var docId = $(this).find(".documentId").val();
            var docName = $(this).find(".documentName").val();
            console.log("marsterId -", marsterId);
            var loiDocModel = {
                documentId: docId,
                documentName: docName,
                documentMasterId: marsterId
            };
            loiDocModels.push(loiDocModel);
        });
        console.log(loiDocModels);
        var loiDocModelData = JSON.stringify(loiDocModels);
        doPostAjaxRequestWithJsonHandler(`${context}/uploadOnboardingDocument?loiId=${loiId}`, loiDocModelData, function (response) {
            console.log('response-', response);
            pendingLoiForm("main-content");
        });
    } else {
        //Nothing to do
    }


});
$(document).on('click', ".documnet-verifed", function () {
    let loiId = $(this).val();
    if (confirm("Are you sure to verify All document ?")) {
        doPutAjaxRequestHandler(`${context}/documentApproved?loiId=${loiId}`,
            function (response) {
                alert(response);
                pendingLoiForm("main-content");
            });
    } else {
        console.log(" All docs not verify");
        //Nothing
    }
});
$(document).on('click', ".loiFormComplete", function () {
    let loiId = $(this).val();
    if (confirm("Are you sure all things are done ?")) {
        doPutAjaxRequestHandler(`${context}/loiFormComplete?loiId=${loiId}`,
            function (response) {
                alert(response);
            });
        pendingLoiForm("main-content");

    } else {
        console.log("Loi form not completed !");
        //Nothing
    }
});
$(document).on('click', ".deleteLoiForm", function () {
    let loiId = $(this).val();
    if (confirm("Are you sure to delete ?")) {
        doPutAjaxRequestHandler(`${context}/deleteLoiForm?loiId=${loiId}`,
            function (response) {
                if (response) {
                    alert("Loi form deleted ");
                } else {
                    //nothing to do
                }
            });
        doGetAjaxRequestHandler(`${context}/pendingOnboardingForm`,
            function (response) {
                $('#' + 'main-content').html(response);
            });

    } else {
        console.log("");
        //Nothing
    }
});

$(document).on('click', ".CompletedLoiForm", function () {
    doPutAjaxRequestHandler(`${context}/completedLoiForms`,
        function (response) {
            $('#' + 'main-content').html(response);
        });
});

$(document).on('click', "#createNewOnboardingPanel", function () {
    let loiId = $(this).val();
    let authId = $(this).closest('tr').find('.authId').val();
    if (authId != " ") {

        doPutAjaxRequestHandler(`${context}/createNewOnboardingPanel?loiId=${loiId}&authId=${authId}`,
            function (response) {
                if (response) {
                    doPutAjaxRequestHandler(`${context}/completedLoiForms`,
                        function (response) {
                            $('#' + 'main-content').html(response);
                        });
                } else {
                    //nothing
                }

            });
    } else {
        alert("Please choose RBM ");
    }

});

function pendingLoiForm(domId) {
    doGetAjaxRequestHandler(`${context}/pendingOnboardingForm`,
        function (response) {
            $('#' + domId).html(response);
        });
}