var code = getQuery("code");
var date = getQuery("date");
var bankTafsilGroupCode = $("#hfBankGroup").val();
$(document).ready(function () {
    $("#hfBankGroup").remove();
});
async function getEventLookupCombo($combo, search, code) {
    var id = $combo.attr('id');
    var url = "";
    var data = {};
    switch (id) {
        case "cboMoain":
            url = "AccountingApi/GetMoainLinkedTafsilGroup";
            data = { tafsilGroupCode: bankTafsilGroupCode, search: search, pageNo: 1 };
            break;
        case "cboTafsil":
            var codeMoain = $("#cboMoain").lookupBuilder().getSelectedValue();
            if (!codeMoain)
                return;
            url = "AccountingApi/GetTafsilList";
            data = { moainCode: codeMoain, tafsilGroupCode: bankTafsilGroupCode, level: 21, search: search, pageNo: 1, selectedCode: code };
            break;
    }
    if (url)
        await ajax({
            url: url,
            data: data,
            success: function (result) {
                $combo.lookupBuilder().bindData(result);
            }
        });
}
function save() {
    var data = getJsonValue();
    var exceptionText = checkValidation('');
    if (exceptionText === '') {
        if (code !== "")
            data["Code"] = code;
        data["PatternCode"] = data["PatternCode"] || null;
        ajax({
            loading: true,
            url: "AccountingApi/" + (code === "" ? "InsertBankConflictHeader" : "UpdateBankConflictHeader"),
            data: data ,
            success: function () {
                showMsgModal(2, window.top.savedSuccessfully);
                refreshParent('refresh()');
                closeTopModal();

            }
        });
    }
    else {
        showMsgModal(0, exceptionText);
    }
}
