text:
function load_maker_table() {
    //@Sachith
    var tableData = '';
    $.post("views/loadTables.php", {table: "maker_info"}, function (e) {
        if (e === undefined || e.length === 0 || e === null) {
            tableData += '
 -- No Data Found --
';
            $('.maker_info_table tbody').html('').append(tableData);
        } else {
            $.each(e, function (index, qData) {
                index++;
                tableData += '
';
                tableData += '' + qData.maker_name + '	';
                tableData += '
<button class="btn btn-custom-save sel_maker" value="' + qData.maker_id + '"> Edit</button><button class="btn btn-custom-light del_maker" value="' + qData.maker_id + '"> Delete</button>
	';
                tableData += '
';
            });
            $('.maker_info_table tbody').html('').append(tableData);
            tableSorter('.maker_info_table');

            // TABLE ACTION BUTTONS
            //UPDATE
            $('.sel_maker').click(function () {
                select_maker($(this).val());
            });
            //DELETE
            $('.del_maker').click(function () {
                delete_maker($(this).val());

            });
        }
    }, "json");
}
function load_proInvoiceView_table(callBack) {
    //@VIRAJ
    var inv_status = $('#cmb_inv_status').val();
    var tableData = '';
    $.post("views/loadTables.php", {table: "load_proInvoiceView_table", inv_status: inv_status}, function (e) {
        if (e === undefined || e.length === 0 || e === null) {
            tableData += '
 -- No Data Found --
';
            $('.load_proInvoiceView_table tbody').html('').append(tableData);
        } else {
            $.each(e, function (index, Rdata) {
                index++;
                tableData += '
';
                tableData += '' + Rdata.pi_no + '	';
                tableData += '' + Rdata.pi_date + '	';
                tableData += '' + Rdata.cus_inv_name + '	';
                tableData += '' + Rdata.consignee_name + '	';
                tableData += '' + Rdata.last_shipment_date + '	';
                tableData += '' + Rdata.port_discharge + '	';
                tableData += '' + Rdata.validity + '	';
                tableData += '' + Rdata.total_cif + '	';
                tableData += '';
                tableData += '
';
                tableData += '<button class="btn btn-custom-save edit_prInv" value="' + Rdata.pi_id + '"> </button>';
                if (parseInt(inv_status) === 1) {
                    tableData += '<button class="btn btn-custom-light btn-sm cansel_prIn" value="' + Rdata.pi_id + '"></button>';
                    tableData += '<button class="btn btn-custom-light btn-sm reprint_inv" data-invtype="' + Rdata.pi_type + '" value="' + Rdata.pi_id + '"></button>';
                }
                tableData += '
';
                tableData += '	';
                tableData += '
';
            });
            $('.load_proInvoiceView_table tbody').html('').append(tableData);
            if (callBack !== undefined) {
                if (typeof callBack === 'function') {
                    callBack();
                }
            }
        }

    }, "json");
}
function kitz_load_customers() {
    var tableData = '';
    $.post("views/loadTables.php", {table: "c_customers_table"}, function (e) {
        if (e === undefined || e.length === 0 || e === null) {
            tableData += '
 -- No Data Found --
';
            $('.c_customers_table tbody').html('').append(tableData);
        } else {
            $.each(e, function (index, qData) {
                index++;
                tableData += '
';
//                tableData += '' + index + '	';
                tableData += '' + qData.cus_name + '	';
                tableData += '' + qData.cus_inv_name + '	';
                tableData += '' + qData.cus_address + '	';
//                tableData += '' + qData.cus_inv_address + '	';
                tableData += '' + qData.cus_phone1 + '	';
                tableData += '' + qData.cus_phone2 + '	';
                tableData += '' + qData.other_contact + '	';
//                tableData += '' + qData.comments + '	';
                tableData += '
<button class="btn btn-custom-save c_select_customer" value="' + qData.cus_id + '"> </button><button class="btn btn-custom-light c_delete_customer" value="' + qData.cus_id + '"></button>
	';
                tableData += '
';
            });
            $('.c_customers_table tbody').html('').append(tableData);
            tableSorter('.c_customers_table');

            // TABLE ACTION BUTTONS
            //SELECT
            $('.c_select_customer').click(function () {
                kitz_select_costomer($(this).val());
            });
            //DELETE
            $('.c_delete_customer').click(function () {
                kitz_delete_customer($(this).val());
            });
        }
    }, "json");
}

function load_model_table(maker_id) {
    //@Sachith
    var tableData = '';
    $.post("views/loadTables.php", {table: "model_info", maker_id: maker_id}, function (e) {
        if (e === undefined || e.length === 0 || e === null) {
            tableData += '
 -- No Data Found --
';
            $('.model_info_tbl tbody').html('').append(tableData);
        } else {
            $.each(e, function (index, qData) {
                index++;
                tableData += '
';
                tableData += '' + qData.mod_name + '	';
                tableData += '
<button class="btn btn-custom-save sel_model" value="' + qData.mod_id + '"> Edit</button><button class="btn btn-custom-light del_model" value="' + qData.mod_id + '"> Delete</button>
	';
                tableData += '
';
            });
            $('.model_info_tbl tbody').html('').append(tableData);
            tableSorter('.model_info_tbl');

            // TABLE ACTION BUTTONS
            //UPDATE
            $('.sel_model').click(function () {
                select_model($(this).val());
            });
            //DELETE
            $('.del_model').click(function () {
                delete_model($(this).val());
            });
        }
    }, "json");
}
function load_sup_reg_tbl() {
    var tableData = '';
    $.post("views/loadTables.php", {table: "load_sup_reg_tbl"}, function (e) {
        if (e === undefined || e.length === 0 || e === null) {
            tableData += '
 -- No Data Found --
';
            $('.reg_sup_details_tbl tbody').html('').append(tableData);
        } else {
            $.each(e, function (index, data) {
                index++;
                tableData += '
';
                tableData += '' + data.supp_code + '	';
                tableData += '' + data.supp_name + '	';
                tableData += '' + data.supp_address + '	';
                tableData += '' + data.phone + '	';
                tableData += '' + data.supp_fax + '	';
                tableData += '' + data.supp_email + '	';
                tableData += '' + data.web + '	';
                tableData += '
<button class="btn btn-custom-save select_supp" value="' + data.supp_id + '"> Edit</button>  <button class="btn btn-custom-light delete_supp" value="' + data.supp_id + '"> Delete</button>
	';
                tableData += '
';
            });
            $('.reg_sup_details_tbl tbody').html('').append(tableData);

            $('.select_supp').click(function () {
                var sup_id = $(this).val();
                get_selected_supp_data(sup_id);
            });

            $('.delete_supp').click(function () {
                delete_supplier($(this).val());
            });

        }

    }, "json");
}

function load_vehicle_clearnce_tbl() {
    //@Ashan
    var tableData = '';
    $.post("views/loadTables.php", {table: "load_clearnce_tbl"}, function (e) {
        if (e === undefined || e.length === 0 || e === null) {
            tableData += '
 -- No Data Found --
';
            $('.clearing_details_tbl tbody').html('').append(tableData);
        } else {
            $.each(e, function (index, data) {
                index++;
                tableData += '
';
                tableData += '' + data.clr_id + '	';
                tableData += '' + data.vh_id + '	';
                tableData += '' + data.shipped_date + '	';
                tableData += '' + data.arrival_date + '	';
                tableData += '' + data.duty + '	';
                tableData += '
<button class="btn btn-custom-save select_supp" value="' + data.clr_id + '"> Edit</button>  <button class="btn btn-custom-light delete_supp" value="' + data.clr_id + '"> Delete</button>
	';
                tableData += '
';
            });
            $('.clearing_details_tbl tbody').html('').append(tableData);

//            $('.select_supp').click(function () {
//                var sup_id = $(this).val();
//                get_selected_supp_data(sup_id);
//            });
//
//            $('.delete_supp').click(function () {
//                delete_supplier($(this).val());
//            });

        }

    }, "json");
}
//// viraj
function vehicleModiTable(vh_id) {
    var tableData = '';
    $.post("views/loadTables.php", {table: "vehicleModiTable", vh_id: vh_id}, function (e) {
        if (e === undefined || e.length === 0 || e === null) {
            tableData += '
 -- No Data Found for Selected Vehicle--
';
            $('.vehicleModiTable tbody').html('').append(tableData);
        } else {
            $.each(e, function (index, data) {
                index++;
                tableData += '
';
                tableData += '' + data.vh_code + '	';
                tableData += '' + data.cus_name + '	';
                tableData += '' + data.desc + '	';
                tableData += '' + data.options + '	';
                tableData += '' + data.other_opt + '	';
                tableData += '' + data.request_date + '	';
                tableData += '
<button class="btn btn-custom-save modific_up" value="' + data.mod_id + '"> </button>  <button class="btn btn-custom-light modific_del" value="' + data.mod_id + '"> </button>
	';
                tableData += '
';
            });
            $('.vehicleModiTable tbody').html('').append(tableData);

            $('.modific_up').click(function () {
                var modific_up = $(this).val();
                $('#mod_update_div').removeClass('hidden');
                $('#mod_save_div').addClass('hidden');
                get_selected_modd_data(modific_up);
            });

            $('.modific_del').click(function () {
                delete_modific($(this).val());
            });
        }

    }, "json");
}
//// end viraj
function load_coordinator_table() {
    //@Sachith
    var tableData = '';
    $.post("views/loadTables.php", {table: "load_coordinator_tbl"}, function (e) {
        if (e === undefined || e.length === 0 || e === null) {
            tableData += '
 -- No Data Found --
';
            $('.coordinator_tbl tbody').html('').append(tableData);
        } else {
            $.each(e, function (index, qData) {
                index++;
                tableData += '
';
                tableData += '' + qData.coordinator_name + '	';
                tableData += '' + qData.short_name + '	';
                tableData += '' + qData.phone + '	';
                tableData += '
<button class="btn btn-custom-save sel_maker" value="' + qData.coordinator_id + '"> Edit</button><button class="btn btn-custom-light del_maker" value="' + qData.coordinator_id + '"> Delete</button>
	';
                tableData += '
';
            });
            $('.coordinator_tbl tbody').html('').append(tableData);
            tableSorter('.coordinator_tbl');

            // TABLE ACTION BUTTONS
            //UPDATE
            $('.sel_maker').click(function () {
                select_coordinator($(this).val());
            });
            //DELETE
            $('.del_maker').click(function () {
                delete_coordinator($(this).val());

            });
        }
    }, "json");
}

function load_view_orders_table(order_status, callBack) {
    //@Sampath
    var tableData = '';
    $.post("views/loadTables.php", {table: "load_view_order_tbl", order_status: order_status}, function (e) {
        if (e === undefined || e.length === 0 || e === null) {
            tableData += '
 -- No Data Found --
';
            $('.view_order_table tbody').html('').append(tableData);
        } else {
            $.each(e, function (index, qData) {
                index++;
                tableData += '
';
                tableData += '' + qData.order_no + '	';
                tableData += '' + qData.order_date + '	';
                tableData += '' + qData.vh_code + '	';
//                tableData += '' + qData.maker_name + '	';
                tableData += '' + qData.mod_name + '	';
                tableData += '' + qData.vh_year + '	';
                tableData += '' + qData.vh_color + '	';
                tableData += '' + qData.milage_max + '	';
                tableData += '' + qData.vh_options + '	';
                tableData += '' + qData.cus_conditions + '	';
                tableData += '' + qData.order_actions + '	';
                tableData += '' + qData.max_price + '	';
                tableData += '' + qData.pay_advance + '	';
                tableData += '' + qData.coordinator_name + '	';
                tableData += '' + qData.gb + '	';
                tableData += '' + qData.cus_name + '	';
                tableData += '' + qData.pay_comments + '	';
                tableData += '' + qData.description + '	';
                if (parseInt(qData.order_status) < 3) {
                    tableData += '
';
                    if (parseInt(qData.vh_reserved) > 0) {
                        tableData += '<button class="btn btn-custom-light del_order" value="' + qData.order_id + '"> Cancel</button>';
                    } else {
                        tableData += '<button class="btn btn-custom-save sel_order_id" value="' + qData.order_id + '"> </button>' +
                                '<button class="btn btn-custom-light del_order" value="' + qData.order_id + '"> Cancel</button>';
                    }
                    tableData += '
	';
                } else {
                    tableData += ' 	';
                }
                tableData += '
';
            });
            $('.view_order_table tbody').html('').append(tableData);
//            tableSorter('.view_order_table');

            // TABLE ACTION BUTTONS
            //SELECT
            $('.sel_order_id').click(function () {
                load_order_details($(this).val());
            });
            //DELETE
            $('.del_order').click(function () {
                order_cancel($(this).val());
            });
            if (callBack !== undefined) {
                if (typeof callBack === 'function') {
                    callBack();
                }
            }
        }
    }, "json");
}

function load_order_details(order_id) {
    var win = window.open('customer_order.php?order_id=' + order_id, '_blank');
    win.focus();
}

function load_vehicle_table(page, callback) {
    //@Sampath
    var supp_id = $('#cmb_supp').val();
    var stock_status = $('#cmb_stock_status').val();
    var records = $('#page_records').val();
    var tableData = '';
    if (page === undefined || isNaN(parseInt(page)) || parseInt(page) <= 0) {
        page = 1;
    }
    $.post("views/loadTables.php", {table: "load_view_vehicle_tbl", supp_id: supp_id, stock_status: stock_status, page: page, records: records}, function (e) {
        if (e === undefined || e.length === 0 || e === null) {
            tableData += '
 -- No Data Found --
';
            $('.view_vh_table tbody').html('').append(tableData);
        } else {
            $.each(e, function (index, qData) {
//                qData.color_group

                index++;
                tableData += '
 0) {
                    tableData += ' style="background-color:#' + qData.color_group + ';"';
                }
                tableData += '>';
                tableData += '';
                tableData += '
<button class="btn btn-custom-light btn-xs sel_order_id" value="' + qData.vh_id + '" data-toggle="tooltip" data-placement="bottom" title="Edit Vehicle"> </button>'
                        + '<button class="btn btn-custom-save btn-xs veiw_details_ex" value="' + qData.vh_id + '" data-toggle="tooltip" data-placement="bottom" title="View Details"> </button>
';
//                <button class="btn "> </button>
                tableData += '	';
                tableData += '<input type="checkbox" class="checkBX" value="' + qData.vh_id + '" data-toggle="tooltip" data-placement="top" title="Select Record"> 	';
                tableData += '' + qData.vh_index_num + '	';
//                tableData += '' + qData.supp_name + '	';
                tableData += '' + qData.vh_code + '	';
                tableData += '' + qData.supp_name + '	';
                tableData += '' + qData.maker_name + '	';
                tableData += '' + qData.mod_name + '	';
                tableData += '' + qData.vh_chassis_code + '	';
                tableData += '' + qData.vh_chassis_num + '	';
                tableData += '' + qData.engine_code + '	';
                tableData += '' + qData.engine_num + '	';
                tableData += '' + qData.engine_cc + '	';
                tableData += '' + qData.package + '	';
                tableData += '' + qData.vh_year + '	';
                tableData += '' + qData.vh_color + '	';
                tableData += '' + qData.vh_milage + '	';
                tableData += '' + qData.vh_options + '	';
                tableData += '' + qData.additional_options + '	';
                tableData += '' + qData.bid_date + '	';
                tableData += '' + qData.auction_name + '	';
                tableData += '' + qData.auction_grade + '	';
//                tableData += '' + qData.lot_no + '	';
//                tableData += '' + qData.auc_display_price + '	';
//                tableData += '' + qData.stock_location + '	';
//                tableData += '' + qData.short_name + '	';
                tableData += '
';
            });
            $('.view_vh_table tbody').html('').append(tableData);

            // TABLE ACTION BUTTONS
            //SELECT
            $('.sel_order_id').click(function () {
                load_vh_edit($(this).val());
            });
            //DETAILS
            $('.veiw_details_ex').click(function () {
                submitSingleDataByPost('vehicle_single_view.php', 'veh_id', $(this).val());
            });
            //DELETE
            $('.del_maker').click(function () {
            });
        }
        load_vhview_paging(page, supp_id, stock_status, records);
        if ($.type(callback) === 'function') {
            callback();
        }
    }, "json");
}

function load_vehicle_table_local(page, callback) {
    //@Sampath
    var supp_id = $('#cmb_supp').val();
    var stock_status = $('#cmb_stock_status').val();
    var records = $('#page_records').val();
    var tableData = '';
    if (page === undefined || isNaN(parseInt(page)) || parseInt(page) <= 0) {
        page = 1;
    }
    $.post("views/loadTables.php", {table: "load_view_vehicle_tbl", supp_id: supp_id, stock_status: stock_status, page: page, records: records}, function (e) {
        if (e === undefined || e.length === 0 || e === null) {
            tableData += '
 -- No Data Found --
';
            $('.view_vh_table tbody').html('').append(tableData);
        } else {
            $.each(e, function (index, qData) {
//                qData.color_group

                index++;
                tableData += '
 0) {
                    tableData += ' style="background-color:#' + qData.color_group + ';"';
                }
                tableData += '>';
                tableData += '';
                tableData += '
' +
                        '<button type="button" class="btn btn-custom-save btn-xs dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">Action </button>' +
                        '
' +
                        '
View
' +
                        '
Edit
' +
                        '
Sales & Payments

';
                //'

' +
                //'
Other Actions...

';

//                tableData += '
<button class="btn btn-custom-light btn-xs sel_order_id" value="' + qData.vh_id + '" data-toggle="tooltip" data-placement="bottom" title="Edit Vehicle"> </button>'
//                        + '<button class="btn btn-custom-save btn-xs veiw_details_ex" value="' + qData.vh_id + '" data-toggle="tooltip" data-placement="bottom" title="View Details"> </button>
';
                tableData += '	';
                tableData += '<input type="checkbox" class="checkBX" value="' + qData.vh_id + '" data-toggle="tooltip" data-placement="top" title="Select Record"> 	';
                tableData += '' + qData.vh_index_num + '	';
//                tableData += '' + qData.supp_name + '	';
                tableData += '' + qData.vh_code + '	';
                tableData += '' + qData.supp_name + '	';
                tableData += '' + qData.maker_name + '	';
                tableData += '' + qData.mod_name + '	';
                tableData += '' + qData.vh_chassis_code + '	';
                tableData += '' + qData.vh_chassis_num + '	';
//                tableData += '' + qData.engine_code + '	';
//                tableData += '' + qData.engine_num + '	';
                tableData += '' + qData.engine_cc + '	';
                tableData += '' + qData.package + '	';
                tableData += '' + qData.vh_year + '	';
                tableData += '' + qData.vh_color + '	';
                tableData += '' + qData.vh_milage + '	';
                tableData += '
';
            });
            $('.view_vh_table tbody').html('').append(tableData);
            $('.sel_order_id').click(function () {
                load_vh_edit_local($(this).val());
            });
            $('.veiw_details_ex').click(function () {
                submitSingleDataByPost('vehicle_single_view.php', 'veh_id', $(this).val());
            });
            $('.sell_vh').click(function () {
                submitSingleDataByPost("vehicle_sell.php", "vh_id", $(this).val());
            });
        }
        load_vhview_paging(page, supp_id, stock_status, records);
        if ($.type(callback) === 'function') {
            callback();
        }
    }, "json");
}

function load_vhview_paging(page, supp_id, stock_status, records) {
    //@Sachith
    var tableData = '';
    $.post("views/loadTables.php", {table: "view_vehicle_tbl_paging", stock_status: stock_status, supp_id: supp_id, records: records}, function (e) {
        if (e === undefined || e.length === 0 || e === null) {
            tableData = '';
            $('.vh_view_pg').html('').append(tableData);
        } else {
            var totpg = parseInt(e.tot_pg);
            if (totpg < 11) {
                for (i = 1; i <= totpg; i++) {
                    if (!isNaN(page) && parseInt(page) === i) {
                        tableData += '<button type="button" class="btn btn-custom-light disabled go_to_pg" value="' + i + '">' + i + '</button>';
                    } else {
                        tableData += '<button type="button" class="btn btn-custom-light go_to_pg" value="' + i + '">' + i + '</button>';
                    }
                }

            } else {
                var sel_page = parseInt(page);
                var prev_page = 1;
                var next_page = totpg;
                if ((sel_page - 3) > 1) {
                    prev_page = sel_page - 3;
                }
                if ((sel_page + 3) < totpg) {
                    next_page = sel_page + 3;
                }

                tableData += '<button type="button" class="btn btn-custom-light go_to_pg" value="' + 1 + '">First</button>';
                for (var i = prev_page; i <= next_page; i++) {
                    if (!isNaN(page) && parseInt(page) === i) {
                        tableData += '<button type="button" class="btn btn-custom-light disabled go_to_pg" style="width:36px;" value="' + i + '">' + i + '</button>';
                    } else {
                        tableData += '<button type="button" class="btn btn-custom-light go_to_pg" style="width:36px;" value="' + i + '">' + i + '</button>';
                    }
                }
                tableData += '<button type="button" class="btn btn-custom-light go_to_pg" value="' + totpg + '">Last</button>';

            }
            $('.vh_view_pg').html('').append(tableData);

            //UPDATE
            $('.go_to_pg').click(function () {
                load_vehicle_table($(this).val());
            });
        }
    }, "json");
}

function vehicle_keyword_search(callback) {
    //@Sampath
    var search_entered = $('#txt_search_key').val();
    var key_arr = search_entered.split(" ");
    var supp_id = $('#cmb_supp').val();
    var stock_status = $('#cmb_stock_status').val();
    var tableData = '';
    if (key_arr.length > 0) {
//        if (page === undefined || isNaN(parseInt(page)) || parseInt(page) <= 0) {
//            page = 1;
//        }

        $.post("views/loadTables.php", {table: "view_vehicle_keyword_search", key_arr: key_arr}, function (e) {
            if (e === undefined || e.length === 0 || e === null) {
                tableData += '
 -- No Data Found --
';
                $('.view_vh_table tbody').html('').append(tableData);
            } else {
                $.each(e, function (index, qData) {
                    index++;
                    tableData += '
';
                    tableData += '
<button class="btn btn-custom-light btn-xs sel_order_id" value="' + qData.vh_id + '"> </button>'
                            + '<button class="btn btn-custom-save btn-xs veiw_details_ex" value="' + qData.vh_id + '"> </button>
	';
                    tableData += '<input type="checkbox" value="' + qData.vh_id + '"> 	';
                    tableData += '' + qData.vh_index_num + '	';
//                tableData += '' + qData.supp_name + '	';
                    tableData += '' + qData.vh_code + '	';
                    tableData += '' + qData.supp_name + '	';
                    tableData += '' + qData.maker_name + '	';
                    tableData += '' + qData.mod_name + '	';
                    tableData += '' + qData.vh_chassis_code + '	';
                    tableData += '' + qData.vh_chassis_num + '	';
                    tableData += '' + qData.engine_code + '	';
                    tableData += '' + qData.engine_num + '	';
                    tableData += '' + qData.engine_cc + '	';
                    tableData += '' + qData.package + '	';
                    tableData += '' + qData.vh_year + '	';
                    tableData += '' + qData.vh_color + '	';
                    tableData += '' + qData.vh_milage + '	';
                    tableData += '' + qData.vh_options + '	';
                    tableData += '' + qData.additional_options + '	';
                    tableData += '' + qData.bid_date + '	';
                    tableData += '' + qData.auction_name + '	';
                    tableData += '' + qData.auction_grade + '	';
//                tableData += '' + qData.lot_no + '	';
//                tableData += '' + qData.auc_display_price + '	';
//                tableData += '' + qData.stock_location + '	';
//                    tableData += '' + qData.short_name + '	';
                    tableData += '
';
                });
                $('.view_vh_table tbody').html('').append(tableData);

                // TABLE ACTION BUTTONS
                //SELECT
                $('.sel_order_id').click(function () {
                    load_vh_edit($(this).val());
                });
                $('.veiw_details_ex').click(function () {
                    submitSingleDataByPost('vehicle_single_view.php', 'veh_id', $(this).val());
                });
                //DELETE
                $('.del_maker').click(function () {
                });
            }
            $('.vh_view_pg').html('');
            if ($.type(callback) === 'function') {
                callback();
            }
        }, "json");

    } else {
        alertify.error("Enter keywords", 2000);
    }
}
function vehicle_keyword_search_local(callback) {
    //@Sampath
    var search_entered = $('#txt_search_key').val();
    var key_arr = search_entered.split(" ");
    var supp_id = $('#cmb_supp').val();
    var stock_status = $('#cmb_stock_status').val();
    var tableData = '';
    if (key_arr.length > 0) {
//        if (page === undefined || isNaN(parseInt(page)) || parseInt(page) <= 0) {
//            page = 1;
//        }

        $.post("views/loadTables.php", {table: "view_vehicle_keyword_search", key_arr: key_arr}, function (e) {
            if (e === undefined || e.length === 0 || e === null) {
                tableData += '
 -- No Data Found --
';
                $('.view_vh_table tbody').html('').append(tableData);
            } else {
                $.each(e, function (index, qData) {
                    index++;
                    tableData += '
';
                    tableData += '
' +
                            '<button type="button" class="btn btn-custom-save btn-xs dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">Action </button>' +
                            '
' +
                            '
View
' +
                            '
Edit
' +
                            '
Sales & Payments

	';

//                    tableData += '
<button class="btn btn-custom-light btn-xs sel_order_id" value="' + qData.vh_id + '"> </button>'
//                            + '<button class="btn btn-custom-save btn-xs veiw_details_ex" value="' + qData.vh_id + '"> </button>
	';
                    tableData += '<input type="checkbox" value="' + qData.vh_id + '"> 	';
                    tableData += '' + qData.vh_index_num + '	';
//                tableData += '' + qData.supp_name + '	';
                    tableData += '' + qData.vh_code + '	';
                    tableData += '' + qData.supp_name + '	';
                    tableData += '' + qData.maker_name + '	';
                    tableData += '' + qData.mod_name + '	';
                    tableData += '' + qData.vh_chassis_code + '	';
                    tableData += '' + qData.vh_chassis_num + '	';
//                    tableData += '' + qData.engine_code + '	';
//                    tableData += '' + qData.engine_num + '	';
                    tableData += '' + qData.engine_cc + '	';
                    tableData += '' + qData.package + '	';
                    tableData += '' + qData.vh_year + '	';
                    tableData += '' + qData.vh_color + '	';
                    tableData += '' + qData.vh_milage + '	';
                    tableData += '
';
                });
                $('.view_vh_table tbody').html('').append(tableData);

                // TABLE ACTION BUTTONS
                //SELECT
                $('.sel_order_id').click(function () {
//                    load_vh_edit($(this).val());
                    load_vh_edit_local($(this).val());
                });
                $('.veiw_details_ex').click(function () {
                    submitSingleDataByPost('vehicle_single_view.php', 'veh_id', $(this).val());
                });
                //DELETE
                $('.del_maker').click(function () {
                });
            }
            $('.vh_view_pg').html('');
            if ($.type(callback) === 'function') {
                callback();
            }
        }, "json");

    } else {
        alertify.error("Enter keywords", 2000);
    }
}
// ************** image galary load by V!rj
function veh_imageload_galary(vehicleID) {
//    alert(vehicleID);
    var galaryData = '';
    $.post("views/loadTables.php", {galary: "veh_imageload_galary", vehicleID: vehicleID}, function (e) {
        if (e === undefined || e.length === 0 || e === null) {
            galaryData += '
No images available
';
        } else {
            $.each(e, function (index, qData) {
                var visible = parseInt(qData.p_visible);
                galaryData += '
';
                galaryData += '';
                galaryData += '
';
                if (visible === 1) {
                    galaryData += '<input type="checkbox" class="imgCheck" data-picId="' + qData.ph_id + '" value="' + qData.ph_id + '" checked="" /> Visible';
                } else {
                    galaryData += '<input type="checkbox" class="imgCheck" data-picId="' + qData.ph_id + '" value="' + qData.ph_id + '" /> Visible';
                }
                galaryData += '<button class="btn btn-sm btn-danger pull-right img_dlt_btn" type="button" data-vh_id="' + vehicleID + '" data-ph_id="' + qData.ph_id + '"></button>';
                galaryData += '
';
                galaryData += '
';
            });
            //****** delete selected image********//
        }
        $('#image_galary').html(galaryData);
    }, "json");
}

function load_vh_edit(vh_id) {
    var win = window.open('vehicle_reg.php?vh_id=' + vh_id, '_blank');
    win.focus();
}

function load_vh_edit_local(vh_id) {
    var win = window.open('vehicle_reg_local.php?vh_id=' + vh_id, '_blank');
    win.focus();
}
function search_cust(text, callBack) {
    var tableData = '';
    $.post("views/loadTables.php", {table: 'customer_search_res', text: text}, function (e) {
        if (e === undefined || e.length === 0 || e === null) {
            tableData += '
 -- No Data Found --
';
            $('.cus_search_result tbody').html('').append(tableData);
        } else {
            $.each(e, function (index, qData) {
                index++;
                tableData += '
';
                tableData += '' + qData.cus_inv_name + '	';
                tableData += '' + qData.cus_address + '	';
                tableData += '' + qData.cus_phone1 + '	';
                tableData += '' + qData.cus_phone2 + '	';
                tableData += '' + qData.cus_email1 + '	';
                tableData += '
<button class="btn btn-custom-save sel_found_cust" value="' + qData.cus_id + '"> Select</button>
	';
                tableData += '
';
            });
            $('.cus_search_result tbody').html('').append(tableData);
            $('.sel_found_cust').click(function () {
                $('.customer_ComboBox').val($(this).val());
                kitz_select_costomer($(this).val());
                $('#cus_searchModal').modal('hide');
                chosenRefresh();
            });

        }
        if (callBack !== undefined) {
            if (typeof callBack === 'function') {
                callBack();
            }
        }
    }, 'json');
}
function search_cust_local(text, callBack) {
    var tableData = '';
    $.post("views/loadTables.php", {table: 'customer_search_res', text: text}, function (e) {
        if (e === undefined || e.length === 0 || e === null) {
            tableData += '
 -- No Data Found --
';
            $('.cus_search_result tbody').html('').append(tableData);
        } else {
            $.each(e, function (index, qData) {
                index++;
                tableData += '
';
                tableData += '' + qData.cus_inv_name + '	';
                tableData += '' + qData.cus_address + '	';
                tableData += '' + qData.cus_phone1 + '	';
                tableData += '' + qData.cus_phone2 + '	';
                tableData += '' + qData.cus_email1 + '	';
                tableData += '
<button class="btn btn-custom-save sel_found_cust" value="' + qData.cus_id + '"> Select</button>
	';
                tableData += '
';
            });
            $('.cus_search_result tbody').html('').append(tableData);
            $('.sel_found_cust').click(function () {
                $('.customer_ComboBox').val($(this).val());
                sam_select_costomer_local($(this).val());
                $('#cus_searchModal').modal('hide');
                chosenRefresh();
            });

        }
        if (callBack !== undefined) {
            if (typeof callBack === 'function') {
                callBack();
            }
        }
    }, 'json');
}
function search_cust_proInv(text, callBack) {
    var tableData = '';
    $.post("views/loadTables.php", {table: 'customer_search_res', text: text}, function (e) {
        if (e === undefined || e.length === 0 || e === null) {
            tableData += '
 -- No Data Found --
';
            $('.cus_search_result tbody').html('').append(tableData);
        } else {
            $.each(e, function (index, qData) {
                index++;
                tableData += '
';
                tableData += '' + qData.cus_inv_name + '	';
                tableData += '' + qData.cus_address + '	';
                tableData += '' + qData.cus_phone1 + '	';
                tableData += '' + qData.cus_phone2 + '	';
                tableData += '' + qData.cus_email1 + '	';
                tableData += '
<button class="btn btn-custom-save sel_found_cust" value="' + qData.cus_id + '"> Select</button>
	';
                tableData += '
';
            });
            $('.cus_search_result tbody').html('').append(tableData);
            $('.sel_found_cust').click(function () {
//                $('.customer_ComboBox').val($(this).val());
                select_customer_consignee($(this).val());
                $('#cus_searchModal').modal('hide');
//                chosenRefresh();
            });

        }
        if (callBack !== undefined) {
            if (typeof callBack === 'function') {
                callBack();
            }
        }
    }, 'json');
}
function search_cust_proInv_local(text, callBack) {
    var tableData = '';
    $.post("views/loadTables.php", {table: 'customer_search_res', text: text}, function (e) {
        if (e === undefined || e.length === 0 || e === null) {
            tableData += '
 -- No Data Found --
';
            $('.cus_search_result tbody').html('').append(tableData);
        } else {
            $.each(e, function (index, qData) {
                index++;
                tableData += '
';
                tableData += '' + qData.cus_inv_name + '	';
                tableData += '' + qData.cus_address + '	';
                tableData += '' + qData.cus_phone1 + '	';
                tableData += '' + qData.cus_phone2 + '	';
                tableData += '' + qData.cus_email1 + '	';
                tableData += '
<button class="btn btn-custom-save sel_found_cust" value="' + qData.cus_id + '"> Select</button>
	';
                tableData += '
';
            });
            $('.cus_search_result tbody').html('').append(tableData);
            $('.sel_found_cust').click(function () {
//                $('.customer_ComboBox').val($(this).val());
                select_customer_consignee($(this).val());
                $('#cus_searchModal').modal('hide');
//                chosenRefresh();
            });

        }
        if (callBack !== undefined) {
            if (typeof callBack === 'function') {
                callBack();
            }
        }
    }, 'json');
}

function search_vehicle(callBack) {
    var tableData = '';
    $.post("views/loadTables.php", {table: 'vh_search_res'}, function (e) {
        if (e === undefined || e.length === 0 || e === null) {
            tableData += '
 -- No Data Found --
';
            $('.vh_search_result tbody').html('').append(tableData);
        } else {
            $.each(e, function (index, qData) {
                index++;
                tableData += '
';
                tableData += '' + qData.vh_code + '	';
                tableData += '' + qData.maker_name + '	';
                tableData += '' + qData.mod_name + '	';
                tableData += '' + qData.vh_chassis_code + '-' + qData.vh_chassis_num + '	';
                tableData += '' + qData.vh_color + '	';
                tableData += '
<button class="btn btn-custom-save sel_found_vh" value="' + qData.vh_id + '"> Select</button>
	';
                tableData += '
';
            });
            $('.vh_search_result tbody').html('').append(tableData);
            $('.sel_found_vh').click(function () {
                $('.vahicle_code_combo').val($(this).val());
                $('#vh_searchModal').modal('hide');
                chosenRefresh();
            });

        }
        if (callBack !== undefined) {
            if (typeof callBack === 'function') {
                callBack();
            }
        }
    }, 'json');
}

function search_vehicle2(param, callBack) {
    var vh_maker = param.maker;
    var vh_model = param.model;
    var tableData = '';
    $.post("views/loadTables.php", {table: 'vh_search_filtered', vh_maker: vh_maker, vh_model: vh_model}, function (e) {
        if (e === undefined || e.length === 0 || e === null) {
            tableData += '
 -- No Data Found --
';
//            $('.vh_search_result tbody').html('').append(tableData);
            $('.vh_search_result tbody').html(tableData);
        } else {
            $.each(e, function (index, qData) {
                index++;
                tableData += '
';
                tableData += '' + qData.vh_code + '	';
                tableData += '' + qData.maker_name + '	';
                tableData += '' + qData.mod_name + '	';
                tableData += '' + qData.vh_chassis_code + '-' + qData.vh_chassis_num + '	';
                tableData += '' + qData.vh_color + '	';
                tableData += '
<button class="btn btn-custom-save sel_found_vh" value="' + qData.vh_id + '"> Select</button>
	';
                tableData += '
';
            });
            $('.vh_search_result tbody').html(tableData);
//            $('.vh_search_result tbody').html('').append(tableData);
            $('.sel_found_vh').click(function () {
                $('.vahicle_code_combo_filtered').val($(this).val());
                chosenRefresh();
            });

        }
        if (callBack !== undefined) {
            if (typeof callBack === 'function') {
                callBack();
            }
        }
    }, 'json');
}

function load_PI_vehicle_table(ref_id, callback) {
    var tableData = '';
    $.post("views/loadTables.php", {table: "load_proinv_vehicle_tbl", ref_id: ref_id}, function (e) {
        if (e === undefined || e.length === 0 || e === null) {
            tableData += '
 -- No Data Found --
';
            $('.proinv_vh_table tbody').html('').append(tableData);
        } else {
            var tot = 0;
            var units = 0;
            $.each(e, function (index, qData) {
                index++;
                tableData += '
';
                tableData += '
<button class="btn btn-custom-light btn-xs sel_inv_vh data-toggle="modal" data-target="#vh_chargesModal" value="' + qData.pi_entry_id + '">FOB</button>
	';
                tableData += '' + qData.vh_code + '	';
                tableData += '' + qData.maker_name + '	';
                tableData += '' + qData.mod_name + '	';
                tableData += '' + qData.vh_chassis_code + qData.vh_chassis_num + '	';
//                tableData += '' + qData.engine_code + qData.engine_num +'	';
                tableData += '' + qData.engine_cc + '	';
                tableData += '' + qData.vh_year + '	';
                tableData += '' + qData.tot_amt + '	';
                tableData += '
';
                tot += parseFloat(qData.tot_amt);
                if (index === 1) {
                    invnum = 'PI-' + qData.vh_code;
                    $('#proinv_num').val(invnum);
                }
                units++;
            });
            tableData += '
Total	' + units + '	Units	' + tot + '
';
            $('.proinv_vh_table tbody').html('').append(tableData);
            $('#tot_cif').val(tot);
            if (units === 1) {
                $('#is_one_vh').val('1');
            } else {
                $('#is_one_vh').val(units);
            }
            // TABLE ACTION BUTTONS
            //SELECT
            $('.sel_inv_vh').click(function () {
                $('#pi_entry_id').val($(this).val());
                $('#vh_amount').modal('show');
//                load_vh_edit($(this).val());
            });
            //DELETE
            $('.del_maker').click(function () {
//                delete_coordinator($(this).val());
            });
        }
        if ($.type(callback) === 'function') {
            callback();
        }
    }, "json");
}

function bankTable() {
    var tableData = '';
    $.post("views/loadTables.php", {table: "load_supp_bank_tbl"}, function (e) {
        if (e === undefined || e.length === 0 || e === null) {
            tableData += '
 -- No Data Found--
';
            $('.bank_tbl tbody').html('').append(tableData);
        } else {
            $.each(e, function (index, data) {
                index++;
                tableData += '
';
                tableData += '' + data.bank_name + '	';
                tableData += '' + data.swift + '	';
                tableData += '' + data.branch + '	';
                tableData += '' + data.ac_num + '	';
                tableData += '
' +
                        '<button class="btn btn-custom-save bank_sel" value="' + data.bank_id + '"> </button>' +
                        '<button class="btn btn-custom-light bank_upd" value="' + data.bank_id + '"> </button>' +
                        '<button class="btn btn-custom-light bank_del" value="' + data.bank_id + '"> </button>' +
                        '
	';
                tableData += '
';
            });
            $('.bank_tbl tbody').html('').append(tableData);

            $('.bank_sel').click(function () {
                var bank_id = $(this).val();
                get_selected_bank(bank_id);
            });
            $('.bank_upd').click(function () {
                var modific_up = $(this).val();
                show_bank_btn();
                select_bank_update(modific_up);
            });
            $('.bank_del').click(function () {
                delete_supp_bank($(this).val());
            });
        }

    }, "json");
}

function leaseCoTable() {
    var tableData = '';
    $.post("views/loadTables.php", {table: "load_lease_co_tbl"}, function (e) {
        if (e === undefined || e.length === 0 || e === null) {
            tableData += '
 -- No Data Found--
';
            $('.leasing_co_tbl tbody').html('').append(tableData);
        } else {
            $.each(e, function (index, data) {
                index++;
                tableData += '
';
                tableData += '' + data.ls_name + '	';
                tableData += '' + data.ls_address + '	';
                tableData += '
' +
                        '<button class="btn btn-custom-save co_sel" value="' + data.ls_id + '"> </button>' +
                        '<button class="btn btn-custom-light co_upd" value="' + data.ls_id + '"> </button>' +
                        '<button class="btn btn-custom-light co_del" value="' + data.ls_id + '"> </button>' +
                        '
	';
                tableData += '
';
            });
            $('.leasing_co_tbl tbody').html('').append(tableData);

            $('.co_sel').click(function () {
                var co_id = $(this).val();
                get_selected_lease(co_id);
            });
            $('.co_upd').click(function () {
                var modific_up = $(this).val();
                show_lease_btn();
                select_leaseCo_update(modific_up);
            });

            $('.co_del').click(function () {
                delete_leaseCo($(this).val());
            });
        }

    }, "json");
}

function leaseCoTable_local() {
    var tableData = '';
    $.post("views/loadTables.php", {table: "load_lease_co_tbl"}, function (e) {
        if (e === undefined || e.length === 0 || e === null) {
            tableData += '
 -- No Data Found--
';
            $('.leasing_co_tbl tbody').html('').append(tableData);
        } else {
            $.each(e, function (index, data) {
                index++;
                tableData += '
';
                tableData += '' + data.ls_name + '	';
                tableData += '' + data.ls_address + '	';
                tableData += '
' +
                        '<button class="btn btn-custom-save" id="sel_leaseComp" value="' + data.ls_id + '"> </button>' +
                        '<button class="btn btn-custom-light co_upd" value="' + data.ls_id + '"> </button>' +
                        '<button class="btn btn-custom-light co_del" value="' + data.ls_id + '"> </button>' +
                        '
	';
                tableData += '
';
            });
            $('.leasing_co_tbl tbody').html('').append(tableData);

            $('.co_upd').click(function () {
                var modific_up = $(this).val();
                show_lease_btn();
                select_leaseCo_update(modific_up);
            });

            $('.co_del').click(function () {
                delete_leaseCo($(this).val());
            });
        }

    }, "json");
}

function test_tbl_filter() {
    $.post("views/loadTables.php", {table: 'load_view_vehicle_tbl2'}, function (e) {
//        alert('ok');
    }, "json");
}

function load_syscode_table(type_id) {
    //@Sachith
    var tableData = '';
    $.post("views/loadTables.php", {table: "syscode_tbl", type_id: type_id}, function (e) {
        if (e === undefined || e.length === 0 || e === null) {
            tableData += '
 -- No Data Found --
';
            $('.syscode_info_tbl tbody').html('').append(tableData);
        } else {
            $.each(e, function (index, qData) {
                index++;
                tableData += '
';
                tableData += '' + qData.description + '	';
                tableData += '' + qData.remarks + '	';
                tableData += '
<button class="btn btn-custom-save sel_syscode" value="' + qData.sys_id + '"> Edit</button><button class="btn btn-custom-light del_syscode" value="' + qData.sys_id + '"> Delete</button>
	';
                tableData += '
';
            });
            $('.syscode_info_tbl tbody').html('').append(tableData);
            // TABLE ACTION BUTTONS
            //UPDATE
            $('.sel_syscode').click(function () {
                select_syscode($(this).val());
            });
//            //DELETE
            $('.del_syscode').click(function () {
                delete_syscode($(this).val());
            });
        }
    }, "json");
}
function load_vh_features_table() {
    //@Sachith
    var tableData = '';
    $.post("views/loadTables.php", {table: "web_vh_feauture_list", type_id: '30'}, function (e) {
        if (e === undefined || e.length === 0 || e === null) {
            tableData += '
 -- No Data Found --
';
            $('.features_table tbody').html('').append(tableData);
        } else {
//            $.each(e, function (index, qData) {
//                index++;
//                tableData += '
';
//                tableData += '<input type="checkbox" value=""/>' + qData.description + '	';
//                tableData += '
';
//            });
            $('.features_table tbody').append(e);
        }
    }, "html");
}

function load_web_homepg_data(section) {
    //@Sachith
    var tableData = '';
    $.post("views/loadTables.php", {table: "tbl_web_homepg", section: section}, function (e) {
        if (e === undefined || e.length === 0 || e === null) {
            tableData += '
 -- No Data Found --
';
            $('.web_homepg_content tbody').html('').append(tableData);
        } else {
            $.each(e, function (index, qData) {
                index++;
                tableData += '
';
                tableData += '' + qData.wh_head1 + '	';
                tableData += '	';
                tableData += '
<button class="btn btn-custom-save sel_content" value="' + qData.wh_id + '"> Edit</button><button data-imgfile="' + qData.wh_image + '" class="btn btn-custom-light del_content" value="' + qData.wh_id + '"> Delete</button>
	';
                tableData += '
';
            });
            $('.web_homepg_content tbody').html('').append(tableData);

            // TABLE ACTION BUTTONS
            //UPDATE
            $('.sel_content').click(function () {
                select_homepg_content($(this).val());
            });
            //DELETE
            $('.del_content').click(function () {
                $(this).data("imgfile");
                delete_web_homepg($(this).val(), $(this).data("imgfile"));

            });
        }
    }, "json");
}

function spec_table() {
    var tableData = '';
    var model_id = $('.model_ComboBox').val();
    $.post("views/loadTables.php", {table: "vehicle_spec_table", model_id: model_id}, function (e) {
        if (e === undefined || e.length === 0 || e === null) {
            tableData += '
 -- No Data Found--
';
            $('.spec_info_table tbody').html('').append(tableData);
        } else {
            $.each(e, function (index, data) {
                index++;
                tableData += '
';
                tableData += '' + data.spec_title + '	';
                tableData += '' + data.eng_cc + '	';
                tableData += '' + data.eng_rpm + '	';
                tableData += '' + data.perf_max_speed + '	';
                tableData += '' + data.trans_type + '	';
                tableData += '' + data.fuel_cons_highway + '	';
                tableData += '' + data.bd_curb_weight + '	';
                tableData += '' + data.cap_fuel_tank + '	';
                tableData += '
' +
                        '<button class="btn btn-custom-save spec_sel" value="' + data.spec_id + '"> </button>' +
                        '<button class="btn btn-custom-light spec_del" value="' + data.spec_id + '"> </button>' +
                        '
	';
                tableData += '
';
            });
            $('.spec_info_table tbody').html('').append(tableData);

            $('.spec_sel').click(function () {
                var spec_id = $(this).val();
                select_spec(spec_id);
                spec_showTabOne();
            });
            $('.spec_del').click(function () {
                var spec_id = $(this).val();
                delete_spec(spec_id);
            });
        }

    }, "json");
}

function sendWeb_selectedVh(idlist) {
    var tableData = '';
    $.post("views/loadTables.php", {table: "sendWeb_selectedVh", idlist: idlist}, function (e) {
        if (e === undefined || e.length === 0 || e === null) {
            tableData += '
 -- No Data Found--
';
            $('#send_web_selected tbody').html('').append(tableData);
        } else {
            $.each(e, function (index, data) {
                index++;
                tableData += '
';
                tableData += '' + data.vh_code + '	';
                tableData += '' + data.mod_name + '	';
                tableData += '' + data.package + '	';
                tableData += '' + data.vh_year + '	';
                tableData += '' + data.vh_color + '	';
                tableData += '
' +
                        '<button class="btn btn-custom-save btn_sel" data-vhcode="' + data.vh_code + '" data-model="' + data.mod_id + '" value="' + data.vh_id + '"> </button>' +
                        '
	';
                tableData += '
';
            });
            $('#send_web_selected tbody').html('').append(tableData);

            $('.btn_sel').click(function () {
                $('#vh_id').val($(this).val());
                $('#v_code_num').val($(this).data('vhcode'));
                $('.currency').html($('.cmb_currency').val());
                load_spec_list($(this).data('model'));
                select_vh_web_data($(this).val());
            });

        }

    }, "json");
}

function vh_inweb() {
    var tableData = '';
    $.post("views/loadTables.php", {table: "vh_inweb"}, function (e) {
        if (e === undefined || e.length === 0 || e === null) {
            tableData += '
 -- No Data Found--
';
            $('.tbl_vh_web tbody').html('').append(tableData);
        } else {
            $.each(e, function (index, data) {
                index++;
                tableData += '
';
                tableData += '' + data.vh_code + '	';
                tableData += '' + data.mod_name + '	';
                tableData += '' + data.vh_chassis + '	';
                tableData += '' + data.vh_year + '	';
                tableData += '' + data.vh_color + '	';
                tableData += '
' +
                        '<button class="btn btn-custom-save btn_sel" data-vhcode="' + data.vh_code + '" data-model="' + data.mod_id + '" data-toggle="tooltip" data-placement="bottom" title="Select Record" value="' + data.vh_id + '"> </button>' +
                        '<button class="btn btn-custom-light btn_del" data-vhcode="' + data.vh_code + '" data-model="' + data.mod_id + '" data-toggle="tooltip" data-placement="bottom" title="Delete Record" value="' + data.vh_id + '"> </button>' +
                        '
	';
                tableData += '
';
            });
            $('.tbl_vh_web tbody').html('').append(tableData);

            $('.btn_sel').click(function () {
                $('#vh_id').val($(this).val());
                $('#v_code_num').val($(this).data('vhcode'));
//                $('.currency').html($('.cmb_currency').val());
                load_spec_list($(this).data('model'));
                select_vh_web_data($(this).val());
            });
            $('.btn_del').click(function () {
                delete_vh_webdata($(this).val());
            });
        }
    }, "json");
}

function newsDetailsTable() {
    //@Cholitha
    var tableData = '';
    $.post("views/loadTables.php", {table: "news_details_tbl"}, function (e) {
        if (e === undefined || e.length === 0 || e === null) {
            tableData += '
 -- No Data Found --
';
            $('.newsDetailsTable tbody').html('').append(tableData);
        } else {

            $.each(e, function (index, qData) {
                index++;
                tableData += '
';
                tableData += '' + qData.posted_date + '	';
                tableData += '' + qData.heading_1 + '	';
                tableData += '	';
                tableData += '
<button class="btn btn-custom-save sel_news" value="' + qData.news_id + '"> Edit</button><button class="btn btn-custom-light del_news" data-imgfile="' + qData.image + '" value="' + qData.news_id + '"> Delete</button>
	';
                tableData += '
';
            });
            $('.newsDetailsTable tbody').html('').append(tableData);
            // TABLE ACTION BUTTONS
            //UPDATE
            $('.sel_news').click(function () {
                select_news($(this).val());
            });
//            //DELETE
            $('.del_news').click(function () {
                delete_news($(this).val(), $(this).data("imgfile"));
            });
        }
    }, "json");
}

function vh_group_tbl() {
    var tableData = '';
    $.post("views/loadTables.php", {table: "load_vh_group_tbl"}, function (e) {
        if (e === undefined || e.length === 0 || e === null) {
            tableData += '
 -- No Data Found--
';
            $('.vh_group_tbl tbody').html('').append(tableData);
        } else {
            $.each(e, function (index, data) {
                index++;
                tableData += '
';
                tableData += '' + data.vh_group + '	';
                tableData += '
' +
                        '<button class="btn btn-custom-light gr_upd" value="' + data.vh_group + '"> </button>' +
                        '<button class="btn btn-custom-light gr_sel" value="' + data.vh_group + '"> </button>' +
                        '<button class="btn btn-custom-light gr_del" value="' + data.vh_group + '"> </button>' +
                        '
	';
                tableData += '
';
            });
            $('.vh_group_tbl tbody').html('').append(tableData);

            $('.gr_upd').click(function () {
                show_group_btn();
                $('#group_name').val($(this).val());
                $('#group_name_pre').val($(this).val());
            });
            $('.gr_sel').click(function () {
                $('#group_name_pre').val('');
                hide_group_btn();
                $('#group_name').val($(this).val());

            });
            $('.gr_del').click(function () {
//                delete_supp_bank($(this).val());
            });
        }

    }, "json");
}

function properties_selectedVh(idlist) {
    var tableData = '';
    $.post("views/loadTables.php", {table: "sendWeb_selectedVh", idlist: idlist}, function (e) {
        if (e === undefined || e.length === 0 || e === null) {
            tableData += '
 -- No Data Found--
';
            $('#properties_selected_tbl tbody').html('').append(tableData);
        } else {
            $.each(e, function (index, data) {
                index++;
                tableData += '
';
                tableData += '' + data.vh_code + '	';
                tableData += '' + data.mod_name + '	';
                tableData += '' + data.package + '	';
                tableData += '' + data.vh_year + '	';
                tableData += '' + data.vh_color + '	';
                tableData += '
' +
                        '<button class="btn btn-custom-save btn_sel" data-vhcode="' + data.vh_code + '" data-model="' + data.mod_id + '" value="' + data.vh_id + '"> </button>' +
                        '
	';
                tableData += '
';
            });
            $('#properties_selected_tbl tbody').html('').append(tableData);

            $('.btn_sel').click(function () {
                properties_select_vehicle($(this).val());
            });
            $('.btn_del').click(function () {
//                var spec_id = $(this).val();
//                delete_spec(spec_id);
            });
        }

    }, "json");
}

function exvh_search_result(text, callBack) {
    var tableData = '';
    $.post("views/loadTables.php", {table: 'exvh_search_result', text: text}, function (e) {
        if (e === undefined || e.length === 0 || e === null) {
            tableData += '
 -- No Data Found --
';
            $('.exvh_search_result tbody').html('').append(tableData);
        } else {
            $.each(e, function (index, qData) {
                index++;
                tableData += '
';
                tableData += '' + qData.vh_code + '	';
                tableData += '' + qData.maker_name + '	';
                tableData += '' + qData.mod_name + '	';
                tableData += '' + qData.vh_chassis + '	';
                tableData += '
<button class="btn btn-custom-save sel_exvh" value="' + qData.vh_id + '"> Select</button>
	';
                tableData += '
';
            });
            $('.exvh_search_result tbody').html('').append(tableData);
            $('.sel_exvh').click(function () {
                select_exch_vehi_local($(this).val());
                $('#exvh_searchModal').modal('hide');
            });

        }
        if (callBack !== undefined) {
            if (typeof callBack === 'function') {
                callBack();
            }
        }
    }, 'json');
}

function vh_payments(vh_id, callBack) {
    var tableData = '';
    $.post("views/loadTables.php", {table: 'vh_payments', vh_id: vh_id}, function (e) {
        if (e === undefined || e.length === 0 || e === null) {
            tableData += '
 -- No Payments Found --
';
            $('.vh_payments tbody').html('').append(tableData);
        } else {
            $.each(e, function (index, qData) {
                index++;
                tableData += '
';
                tableData += '' + qData.pay_date + '	';
                tableData += '' + qData.pay_method + '	';
                tableData += '' + qData.pay_category + '	';
                tableData += '' + Number(qData.in_amount).toFixed(2) + '	';
                tableData += '' + qData.bank_account + '	';
                if (parseInt(qData.pay_confirmed) === 1) {
                    tableData += '' + '	';
                } else if (parseInt(qData.pay_confirmed) === 0) {
                    tableData += '' + '	';
                } else {
                    tableData += '' + '	';
                }
                tableData += '
' +
//                '<button class="btn btn-custom-save sel_payment" value="' + qData.vp_id + '"> Select</button>'+
                        '<button class="btn btn-custom-light cancel_payment" value="' + qData.vp_id + '"> Cancel</button>' +
                        '
	';
                tableData += '
';
            });
            $('.vh_payments tbody').html('').append(tableData);
            $('.cancel_payment').click(function () {
                cancel_vh_payment_local($(this).val());
            });

        }
        if (callBack !== undefined) {
            if (typeof callBack === 'function') {
                callBack();
            }
        }
    }, 'json');
}

function load_clearing_table(page, callback) {
    //@Ashan
    var supp_id = $('#cmb_supp').val();
    var stock_status = $('#cmb_stock_status').val();
    var records = $('#page_records').val();
    var tableData = '';
    if (page === undefined || isNaN(parseInt(page)) || parseInt(page) <= 0) {
        page = 1;
    }
    $.post("views/loadTables.php", {table: "load_view_clearing_tbl", supp_id: supp_id, stock_status: stock_status, page: page, records: records}, function (e) {
        if (e === undefined || e.length === 0 || e === null) {
            tableData += '
 -- No Data Found --
';
            $('.view_vh_table tbody').html('').append(tableData);
        } else {
            $.each(e, function (index, qData) {
//                qData.color_group

                index++;
                tableData += '
 0) {
                    tableData += ' style="background-color:#' + qData.color_group + ';"';
                }
                tableData += '>';
                tableData += '';
                tableData += '
<button class="btn btn-custom-light btn-xs sel_order_id" value="' + qData.vh_id + '" data-toggle="tooltip" data-placement="bottom" title="Edit Vehicle"> </button>'
                        + '<button class="btn btn-custom-save btn-xs veiw_details_ex" value="' + qData.vh_id + '" data-toggle="tooltip" data-placement="bottom" title="View Details"> </button>
';
//                <button class="btn "> </button>
                tableData += '	';
                tableData += '<input type="checkbox" class="checkBX" value="' + qData.vh_id + '" data-toggle="tooltip" data-placement="top" title="Select Record"> 	';
                tableData += '' + qData.vh_index_num + '	';
//                tableData += '' + qData.supp_name + '	';
                tableData += '' + qData.vh_code + '	';
                tableData += '' + qData.supp_name + '	';
                tableData += '' + qData.maker_name + '	';
                tableData += '' + qData.mod_name + '	';
                tableData += '' + qData.vh_chassis_num + '	';
                tableData += '' + qData.engine_cc + '	';
                tableData += '' + ((qData.shipped_date==null) ? '-':qData.shipped_date) + '	';
                tableData += '' + ((qData.vessel==null) ? '-':qData.vessel)+ '	';
                tableData += '' + ((qData.refunds==null) ? '-':qData.refunds) + '	';
                tableData += '' + ((qData.arrival_date==null) ? '-':qData.arrival_date) + '	';
                tableData += '' + ((qData.document_status==null) ? '-':qData.docuemnt_status) + '	';
                tableData += '' + ((qData.to_clr_agent==null) ? '-':qData.to_clr_agent) + '	';
                tableData += '' + ((qData.duty==null) ? '-':qData.duty) + '	';
                tableData += '' + ((qData.clr_date==null) ? '-':qData.clr_date) + '	';
                tableData += '' + ((qData.transport_method==null) ? '-':qData.transport_method) + '	';
                tableData += '' + ((qData.lc_no==null) ? '-':qData.lc_no) + '	';
//                tableData += '' + qData.lot_no + '	';
//                tableData += '' + qData.auc_display_price + '	';
//                tableData += '' + qData.stock_location + '	';
//                tableData += '' + qData.short_name + '	';
                tableData += '
';
            });
            $('.view_vh_table tbody').html('').append(tableData);

            // TABLE ACTION BUTTONS
            //SELECT
            $('.sel_order_id').click(function () {
                load_vh_edit($(this).val());
            });
            //DETAILS
            $('.veiw_details_ex').click(function () {
                submitSingleDataByPost('vehicle_single_view.php', 'veh_id', $(this).val());
            });
            //DELETE
            $('.del_maker').click(function () {
            });
        }
        load_vhview_paging(page, supp_id, stock_status, records);
        if ($.type(callback) === 'function') {
            callback();
        }
    }, "json");
}

function load_employee_tbl() {
    var tableData = '';
    $.post("views/loadTables.php", {table: "load_employee_tbl"}, function (e) {
        if (e === undefined || e.length === 0 || e === null) {
            tableData += '
 -- No Data Found --
';
            $('.employee_details_tbl tbody').html('').append(tableData);
        } else {
            $.each(e, function (index, data) {
                index++;
                tableData += '
';
                tableData += '' + (data.empno== null? '-':data.empno)+ '	';
                tableData += '' + (data.name == null ? '-':data.name)+ '	';
                tableData += '' + (data.nic== null ? '-':data.nic) + '	';
                tableData += '' + (data.designation== null ? '-':data.designation)+'	';
                tableData += '' + (data.tel== null? '-' :data.tel)+ '	';
                tableData += '' + (data.epfno == null ? '-':data.epfno) + '	';
                tableData += '' + (data.basic == null ? '-':data.basic)+ '	';
                tableData += '
<button class="btn btn-custom-save select_emp" value="' + data.emp_id + '"> Edit</button>  <button class="btn btn-custom-light delete_emp" value="' + data.emp_id + '"> Delete</button>
	';
                tableData += '
';
            });
            $('.employee_details_tbl tbody').html('').append(tableData);

            $('.select_emp').click(function () {
                var emp_id = $(this).val();
                get_selected_employee_data(emp_id);
            });

            $('.delete_emp').click(function () {
                delete_employee($(this).val());
            });

        }

    }, "json");
}