$(document).ready(function () {
    closeLoading();
});
function save() {
    var code = getQuery("code");
    var userList = [];
    $('[data-id="employee"]').each(function () {
        if ($(this).is(":checked") && Number($(this).attr("data-code")) > 0)
            userList.push($(this).attr("data-code"));
    });
    var data = getJsonValue('');
    var error = checkValidation('');
    if (error === "") {
        data["Users"] = userList;
        ajax({
            loading: true,
            url: "SaleApi/" + (code === "" ? "InsertStore" : "UpdateStore"),
            data: data,
            success: function (result) {
                refreshParent('loadGrid()');
                showMsgModal(2, result.FinalMessage);
                closeTopModal();
            }
        });
    }
    else {
        showMsgModal(0, error, error, '0');
    }
}
function checkedEmployee() {
    $('#cboAllUserCreadit').prop('checked', true);
    $('[data-id="employee"]').each(function () {
        if (!$(this).is(":checked")) {
            $("#cboAllUserCreadit").prop('checked', false);
        }
    });
}
function checkedAllEmployee() {
    var checked = $('#cboAllUserCreadit').is(":checked");
    $('[data-id="employee"]').each(function () {
        $(this).prop('checked', checked);
    });
}
async function getEventLookupCombo($combo, search, code) {
    var id = $combo.attr('id');
    var url = "";
    var data = null;
    switch (id) {
        case "cboTafsil":
            url = "AccountingApi/GetTafsilList";
            data = { level: -1, search: search, pageNo: 1, selectedCode: code };
            break;
    }
    if (url != "") {
        await ajax({
            url: url,
            loading: false,
            data: data,
            success: function (result) {
                $combo.lookupBuilder().bindData(result);
            }
        });
    }
}
