<?php
    include('config.php');
?>

<!DOCTYPE html>
<html lang="en" class="light-style customizer-hide">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
        <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0"/>
        <title>Cherry Dashboard</title>
        <meta name="description" content="" />
        <!-- Fonts -->
        <link rel="preconnect" href="https://fonts.googleapis.com" />
        <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
        <link href="https://fonts.googleapis.com/css2?family=Roboto:wght@300;400;500&display=swap" rel="stylesheet">
        <link href="assets/css/main.d810cf0ae7f39f28f336.css" rel="stylesheet">
        <link href="assets/css/animate.css" rel="stylesheet">
        <link href="assets/css/animate.min.css" rel="stylesheet">
        <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-multiselect/0.9.15/css/bootstrap-multiselect.css">
        <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
        <link rel="stylesheet" type="text/css" href="assets/wizard/fonts/material-design-iconic-font/css/material-design-iconic-font.min.css">
        <link rel="stylesheet" href="assets/wizard/css/style.css"/>
        <link rel="stylesheet" href="assets/select2/select2.min.css">
        <script type="text/javascript" src="assets/scripts/jquery.min.js"></script>
    
        <style>
            body
            {
                font-family: 'Roboto' !important;
                overflow-x:hidden;
                background-color : #E4ECF3 !important;
            }
            .app-theme-white.fixed-header .app-header__logo
            {
                background: none;
            }
            .app-theme-white.app-container {
                background-color: white;
            }
            .vertical-nav-menu li a:hover
            {
                color: #FFFFFF !important;
                font-weight: normal !important;
                background-color: #0066CC !important;
                box-shadow: none !important;
                cursor: pointer;
            }
            .vertical-nav-menu li a.tbt:hover {
                color: #000000 !important;
                font-weight: normal !important;
                background-color: #DEEAF6 !important;
                box-shadow: none !important;
                cursor: pointer;

            }
            .pikachu a[aria-expanded="true"]
            {
                background-color: #0066CC;
                color: #FFFFFF !important;
                font-weight: normal !important;
            }
            .pikachu a[aria-expanded="false"]
            {
                color: #000000 !important;
            }

            .app-sidebar .app-sidebar__inner
            {
                padding: 0px !important;
            }
            .app-sidebar {
                width: 240px !important;
                min-width: 240px !important;
            }
            .tooltiptext
            {
                visibility: hidden;
                width: 120px;
                background-color: #333;
                color: #fff;
                text-align: center;
                border-radius: 6px;
                padding: 5px;
                position: absolute;
                z-index: 1;
                margin-left: -60px;
                opacity: 0;
                transition: opacity 0.3s;
            }
            .wizard-v1-content
            {
                width: 100% !important;
                margin: 0 !important;
            }
            .form-register .content {
                background: none;
                box-shadow: rgba(14, 30, 37, 0.12) 0px 2px 4px 0px, rgba(14, 30, 37, 0.32) 0px 2px 16px 0px;
                padding-bottom:80px;
            }
            .actions
            {
                display:none;
            }
            /* SELECT 2 START */
                .select2-container
                {
                    width: 190px !important;
                    margin-top: 11px !important;
                    cursor: pointer !important;
                }
                .select2-container--default .select2-selection--single 
                {
                    height:34px !important;
                }
                .select2-container--default .select2-selection--single .select2-selection__rendered 
                {
                    line-height: 31px !important;
                }
                .select2-container--default .select2-selection--single .select2-selection__arrow 
                {
                    top: 3px !important;
                }
                .select2-container--open .select2-dropdown--below 
                {
                    top: -10px !important;
                }
                .select2-container--default .select2-results__option--highlighted[aria-selected] 
                {
                    background-color: #0066CC !important;
                    color: white;
                }
            /* SELECT 2 END */
            ul.multiselect-container.dropdown-menu.show
            {
                padding: 0 !important;
                /* border: none !important; */
                min-width: fit-content !important;
            }
            .multiselect-container
            {
                transform: translate3d(0px, 0px, 0px) !important;
                max-height: 250px;
                overflow-y: auto;
                width: 250px;
            }
            .multiselect-container>li>a>label
            {
                padding: 3px 10px 3px 10px !important;
            }
            ul.multiselect-container.dropdown-menu.show {
                min-width: 350px !important;
            }
            .multiselect-container>li.active>a:hover, .multiselect-container>li.active>a {
                background: none !important;
                color: #16181b;
            }
            .multiselect-container>li.active>a:hover label, .multiselect-container>li.active>a label {
                font-weight: 400 !important;
            }
            /* .btn-group
            {
                width:350px !important;
                border: 1px solid #ced4da !important;
                border-radius: 3px !important;
                display: block !important;
            } */
            .app-sidebar.sidebar-shadow
            {
                margin-top: -5px;
            }
            .app-sidebar
            {
                padding-top:25px !important;
            }
            .uniquebtn:hover
            {
                background-color:#ffffff !important;
                color:#3f6ad8 !important;
            }
            .form-register .steps li.current a .step-icon, .form-register .steps li.current a:active .step-icon, .form-register .steps .done::before, .form-register .steps li.done a .step-icon, .form-register .steps li.done a:active .step-icon {
                background: #FCAA4D;
            }
            .steps
            {
                margin-top:40px !important;
            }
            .form-register .steps li.current::after {
                position: none !important;
                width: 0px !important;
                height: 0px !important;
                background: none !important;
                top: 0 !important;
                left: 0 !important;
            }
            .app-header {
                height:50px !important;
            }

            .nav-item a.active {
                background-color: #000000 !important;
                color: #FFFFFF !important;
            }

            .nav-item a {
                background-color: none !important;
                color: #333333 !important;
            }
            .card-header>.nav .nav-link::before {
                background:none !important;
            }
            .popup-btn a {
                letter-spacing: 3px;
                width: auto;
                font-size: 15px;
                top: 15px;
                position: fixed;
                right: 610px;
                z-index: 1000;
                /* transform: rotate(-90deg); */
                background-color: #0066CC !important;
                padding: 3px 40px 24px 40px;
                height: 0px;
                text-decoration:none;
                color: #FFFFFF;
                border-radius: 10px;
            }
            .trends a {
                right: 770px;
            }
            /* .popup-btn a:hover {
                text-decoration: none;
                background-color:#333333 !important;
                color: #FFD938 !important;
            } */
            .sidebar2 {
                height: 700px;
                width: 0;
                position: fixed;
                z-index: 99999;
                top: 0px;
                right: 0;
                background-color: #ffffff;
                overflow-x: hidden;
                transition: 0.5s;

            }

            .sidebar2 .closebtn {
                position: relative;
                top: 0px;
                left: 180px;
                font-size: 24px;
                margin-left: 50px;
            }

            .sidebar2 a {
                padding: 8px 8px 8px 32px;
                text-decoration: none;
                font-size: 25px;
                color: #245798;
                display: block;
                transition: 0.3s;
            }
            .highcharts-container {
                text-align: center !important;
                width: auto !important;
                margin: 0 auto !important;
            }

            .font {
                font-weight: 500;
            }

            .div-head {
                background-color: #000000;
                color: #FFFFFF;
                text-align: center;
                margin: 0px !important;
                border-radius: 5px;
                height: 50px;

            }
            fieldset {
                border: 1px solid #ddd !important;
                align-content: center !important;
                margin: 0 !important;
                min-width: 0 !important;
                height: auto !important;
                position: relative !important;
                border-radius: 4px !important;
                border: 1px solid black !important;
            }

            legend {
                font-size: 14px !important;
                text-align: left !important;
                margin-bottom: 0px !important;
                width: auto !important;
                border-radius: 4px !important;
                padding: 5px 5px 5px 10px !important;
            }

            ul.multiselect-container.dropdown-menu.show {
                padding: 0 !important;
                border: none !important;
                min-width: fit-content !important;
            }

            .multiselect-container {
                transform: translate3d(0px, 0px, 0px) !important;
                MAX-HEIGHT: 250px;
                overflow-y: auto;
                width: 250px;
            }

            .multiselect-container>li>a>label {
                padding: 3px 10px 3px 10px !important;
            }

            .vertical-nav-menu ul:before {
                background: white !important;
                content: none !important;
            }

            button.multiselect.dropdown-toggle.btn.btn-default {
                margin-top: -5px !important;
                border: 1px solid grey !important;
                width: 232px !important;
                margin-left: 5px !important;
                margin-bottom: 5px !important;
                /* background-color: aliceblue !important; */
                text-align: left !important;
            }

            .vertical-nav-menu li a {
                font-size: 0.9rem !important;
            }

            .vertical-nav-menu li a {
                display: block;
                line-height: 2.4rem;
                height: 2.4rem;
                /* padding: 0 1.5rem 0 45px; */
                position: relative;
                border-radius: 0.25rem;
                color: #343a40;
                white-space: nowrap;
                transition: all .2s;
                /* margin: 0.1rem 0; */
            }
            .vertical-nav-menu ul {
                padding: 0 0 0 0 !important;
            }
            .vertical-nav-menu ul:before {
                background: white !important;
                content: none !important;
            }
            .vertical-nav-menu li a {
                white-space: normal;
            }
            /* .btn-brand
            {
                color:#000000 !important;
            }
            .btn-brand:hover
            {
                color:#000000 !important;
            } */
            /* .pr
            {
                margin-left:-30px;
            }
            .pr2
            {
                margin-right:-15px;
            }
            .pr3
            {
                margin-left:-30px;
                margin-right:0.8%;
            }
            .pr4
            {
                margin-right:10px;
                margin-left:-15px;
            } */
            .pr3
            {
                margin-left:-20px;
                margin-right:0.8%;
            }
            .highcharts-stack-labels-box
            {
                x:-15 !important;
                width:67px !important;
            }
            .splash {
                position: absolute !important;
                width: 100% !important;
                height: 100% !important;
                background: white;
                left: 0 !important;
                top: 0 !important;
                opacity: 0.9 !important;
                z-index: 999999999999;
            }

            .splash-title {
                text-align: center;
                max-width: 500px;
                padding: 170px;
                margin-top: 9%;
                margin-left: auto;
                margin-bottom: auto;
                margin-right: auto;
            }

            .spinner {
                border: 10px solid #f3f3f3;
                border-radius: 50%;
                border-top: 10px solid #003266;
                width: 90px;
                height: 90px;
                -webkit-animation: spin 2s linear infinite;
                /* Safari */
                animation: spin 2s linear infinite;
            }

            /* Safari */
            @-webkit-keyframes spin {
                0% {
                    -webkit-transform: rotate(0deg);
                }

                100% {
                    -webkit-transform: rotate(360deg);
                }
            }

            @keyframes spin {
                0% {
                    transform: rotate(0deg);
                }

                100% {
                    transform: rotate(360deg);
                }
            }

            .switchbtn {
                padding-left: 10px;
                display: inline-flex;

            }

            .switch {
                margin-top: 6px;
                margin-left: 5px;
                margin-right: 5px
            }

            .switch {
                position: relative;
                display: inline-block;
                width: 50px;
                height: 26px;
            }

            .switch input {
                opacity: 0;
                width: 0;
                height: 0;
            }
            .slider {
                position: absolute;
                cursor: pointer !important;
                top: 0;
                left: 0;
                right: 0;
                bottom: 0;
                background-color: #ccc;
                -webkit-transition: .4s;
                transition: .4s;
            }

            .slider:before {
                position: absolute;
                content: "";
                height: 22px;
                width: 20px;
                left: 3px;
                bottom: 3px;
                background-color: white;
                -webkit-transition: .4s;
                transition: .4s;
            }

            input:checked+.slider {
                background-color: #0066CC;
            }

            input:focus+.slider {
                box-shadow: 0 0 1px #0066CC;
            }

            input:checked+.slider:before {
                -webkit-transform: translateX(26px);
                -ms-transform: translateX(26px);
                transform: translateX(26px);
            }

            /* Rounded sliders */
            .slider.round {
                border-radius: 34px;
            }

            .slider.round:before {
                border-radius: 50%;
            }

            .tt {
                margin-top: 8px;
                font-weight: 500;

            }
            .multiselect-container > li.active:hover
            {
                color:black !important;
                background-color:#0066CC !important;
            }

            b
            {
                letter-spacing: 1px !important;
            }

                

            /* Styles for small screens (up to 767px) */
            @media only screen and (max-width: 767px) {
            /* Your styles for small screens go here */
                /* #overallBase b
                {
                    font-weight: 500;
                    color:red !important;
                } */
            }

            /* Styles for medium-sized screens (768px to 1023px) */
            @media only screen and (min-width: 768px) and (max-width: 1023px) {
            /* Your styles for medium-sized screens go here */
                #overallBase b
                {
                    font-weight: 500;
                    color:black !important;
                }
            }

            /* Styles for large screens (1024px and above) */
            @media only screen and (min-width: 1024px) {
            /* Your styles for large screens go here */
                #overallBase b
                {
                    font-weight: 500;
                    color:black !important;
                }
            }

            /* Media query for laptops with a resolution between 1366x768 and 1600x900 */
            /* My laptop starting with 125% */
            @media only screen and (min-width: 800px) and (max-width: 1300px) {
                #overallBase b
                {
                    font-weight: 500 !important;
                    color:black !important;
                }
                h6
                {
                    font-size:0.8rem !important;
                }
                h5
                {
                    font-size:13px !important;
                }
                
                .highcharts-axis-labels.highcharts-xaxis-labels 
                {
                    font-size: 0.8rem !important;
                }
                .nav-item a.active {
                    font-size: 0.77rem;
                }
                .card-header>.nav .nav-link {
                    font-size: 0.77rem;
                }
                .app-sidebar {
                    width: 220px !important;
                    min-width: 220px !important;
                }
                .vertical-nav-menu li a {
                    font-size:0.8rem !important;
                }
            }

            /* Media query for laptops with a resolution between 1366x768 and 1600x900 */
            /* My laptop starting with 100% and end on 125% */
            @media only screen and (min-width: 1367px) and (max-width: 1600px) {
                #overallBase b
                {
                    font-weight: 500;
                    color:black !important;
                }
            }

            /* Media query for laptops with a resolution between 1601x900 and 1920x1080 */
            /* My laptop starting with 90% and end on 100% */
            @media only screen and (min-width: 1601px) and (max-width: 1920px) {
                #overallBase b
                {
                    font-weight: 500;
                    color:black !important;
                }
            }

            /* Media query for laptops with a resolution greater than 1920x1080 */
            /* @media only screen and (min-width: 1921px) {
                
            } */

            /* CUSTOM SCROLLBAR START */
                body::-webkit-scrollbar {
                    width: 15px;
                    height: 15px;
                }

                body::-webkit-scrollbar-track {
                    border-radius: 10px;
                    background-color: white;
                }

                /* body::-webkit-scrollbar:hover {
                    background-color: rgba(0,255,255,0.3);
                } */

                body::-webkit-scrollbar-thumb {
                    background: #0066CC;
                    border-radius: 10px;
                    /* box-shadow: 0px 0px 15px #0066CC; */
                }

                /* body::-webkit-scrollbar-thumb:hover {
                    background-color: #0066CC;
                } */
            /* CUSTOM SCROLLBAR END */
            b
            {
                letter-spacing:1px;
            }
            .sidebar 
            {
                height: 500px;
                width: 0;
                position: fixed;
                z-index: 999;
                top: 56px;
                left: 0;
                background-color: #ffffff;
                overflow-x: hidden;
                transition: 0.5s;
                padding-top:20px;
            }
            .app-main .app-main__inner 
            {
                padding: 0px 30px 0 !important;
                flex: 1 !important;
            }
            .fixed-sidebar .app-main .app-main__outer {
                z-index: 9;
                padding-left: 0px !important;
            }
        </style>

    </head>

    <body>
        <div class="app-container app-theme-white body-tabs-shadow fixed-header fixed-sidebar" id="app-containerX" onclick="closeF()">
            <div class="app-header header-shadow header-text-light">
                <div class="app-header__logo" style="background-color:white">
                    <img src="assets/images/nlogo.png" style="height:30px"alt="">
                </div>
                <div class="app-header__mobile-menu">
                    <div>
                        <button type="button" class="hamburger hamburger--elastic mobile-toggle-nav">
                        <span class="hamburger-box">
                        <span class="hamburger-inner"></span>
                        </span>
                        </button>
                    </div>
                </div><!-- app-header mobile menu div-->
                <div class="app-header__menu">
                    <span>
                        <button type="button" class="btn-icon btn-icon-only btn btn-primary btn-sm mobile-toggle-header-nav">
                        <span class="btn-icon-wrapper">
                        <i class="fa fa-ellipsis-v fa-w-6"></i>
                        </span>
                        </button>
                    </span>
                </div><!-- app-header menu div-->
                <div class="app-header__content" style="background-color:white">
                    <div class="app-header-left"></div>
                    <div class="app-header-right">
                        <!-- <h6 class="mt-3"><?php //echo $user_name; ?></h6>
                        <img src="assets\images\PNG\Mask group.png" alt=""> -->
                        <div style="margin-right:10px">
                            <select class="js-select2 form-control" name="oem" id="oem" onchange="viewModel(this.id)" style="height:35px;margin-top:10px;cursor:pointer !important">
                                <?php
                                    echo '<option value="0">--SELECT OEMs--</option>';
                                    foreach($brand2 as $key => $value)
                                    {
                                        echo '<option value='.($key).'>'.$value.'</option>';
                                    }
                                ?>
                            </select>
                            <div class="dropDownSelect2"></div>
                        </div>
                        <div class="dropDownSelect2"></div>
                        <button type="button" class="btn-transition btn btn-outline-primary btn-sm btn-brand" data-value="OEM" onclick="viewOEM();" style="height:35px;cursor:pointer;margin-top:10px;margin-right:10px;display:none" id="view_oem_btn">
                            View All OEMs
                        </button>
                        <button type="button" class="btn-transition btn btn-outline-primary btn-sm btn-brand" data-value="Top" onclick="swapChart(this);" style="height:35px;cursor:pointer;margin-top:10px;margin-right:10px" id="swap_chart_btn">
                            Top 2 Score
                        </button>
                        <button type="button" class="btn-transition btn btn-outline-primary btn-sm btn-brand" data-value="Tbl" onclick="swapTable(this);" style="height:35px;cursor:pointer;margin-top:10px;margin-right:10px" id="swap_tbl_btn">
                            Show Table
                        </button>
                        <button type="button" class="btn-transition btn btn-outline-primary btn-sm vocnot"
                            onclick="exportExcelFlag();" data-toggle="tooltip" data-placement="bottom" title=""
                            data-original-title="Export Excel" style="height:35px;width:35px;margin-top:10px;margin-right:5px;">
                            <img src="assets/images/excel.png" height="25" width="20" />
                        </button>
                        <button type="button" class="btn-transition btn btn-outline-primary btn-sm logout_btns" onclick="logout();"
                            data-toggle="tooltip" data-placement="bottom" title="" data-original-title="Logout"
                            style="height:35px;width:35px;margin-top:10px">
                            <img src="assets/images/logout.png" height="20" width="20" />
                        </button>
                    </div>
                </div><!-- app-header content-->
            </div><!-- app-header div-->
            <div id="mySidebar" class="sidebar">
                <?php include("tabs.php"); ?>
            </div>
            <div class="app-main" id="main">
                <div class="splash">
                    <div class="splash-title">
                        <div class="spinner">

                        </div>
                    </div>
                </div>
                <div class="app-main__outer" style="background-color: #E4ECF3;">
                    <div class="app-main__inner" style="padding: 0px;padding-right:15px">
                        <div class="tab-content">
                            <div class="card card-shadow-danger mb-2 mt-1 pr3" style="background-color:#FFFFFF;">
                                <div class="row">
                                    <div class="col-md-3" id="activetabname">
                                        <h6 class="ml-2 mt-2"><b style="font-weight: 500;color:#000000">KPI</b></h6>
                                    </div>
                                    <div class="col-md-7" style="text-align:end">
                                    </div>
                                    <div class="col-md-2" id="overallBase" style="text-align:center">
                                    </div>
                                </div>
                            </div>
                            <div class="card card-shadow-danger mb-2 mt-1 pr3" style="background-color:#FFFFFF;">
                                <div class="row">
                                    <div class="col-md-12">
                                        <textarea class="paraX" style="height:auto;max-width:200px;word-wrap:break-word;display:none">Filters:All Selected</textarea>
                                        <p class="ml-2 mt-3 paraY" style="height:auto;color:#000000">Filters:All Selected</p>
                                    </div>
                                </div>
                            </div>
                            <div class="tab-pane active custom-tab-pane" id="tab-eg7-0" role="tabpanel" data-status="active">
                                <div class="card-header pr3">
                                    <ul class="nav nav-justified ml-2" id="subtabs1">
                                    </ul>
                                </div>
                                <div class="tab-content">
                                    <div class="tab-pane active" id="tab-eg8-91" role="tabpanel">
                                        <?php include "exceldiv/experienceX.php"; ?>
                                    </div>
                                    <div class="tab-pane" id="tab-eg8-0" role="tabpanel">
                                        <?php include "exceldiv/nps.php"; ?>
                                    </div>
                                    <div class="tab-pane" id="tab-eg8-1" role="tabpanel">
                                        <?php include "exceldiv/satisfaction.php"; ?>
                                    </div>
                                    <div class="tab-pane" id="tab-eg8-90" role="tabpanel">
                                        <?php include "exceldiv/repurchase.php"; ?>
                                    </div>
                                </div>
                            </div>
                            <div class="tab-pane custom-tab-pane" id="tab-eg7-1" role="tabpanel" data-status="inactive">
                                <?php include "exceldiv/presales.php"; ?>
                            </div>
                            <div class="tab-pane custom-tab-pane" id="tab-eg7-2" role="tabpanel" data-status="inactive">
                                <div class="card-header pr3">
                                    <ul class="nav nav-justified ml-2" id="subtabs2">
                                    </ul>
                                </div>
                                <div class="tab-content">
                                    <div class="tab-pane active" id="tab-eg8-2" role="tabpanel">
                                        <?php include "exceldiv/facility_rating.php"; ?>
                                    </div>
                                    <div class="tab-pane" id="tab-eg8-3" role="tabpanel">
                                        <?php include "exceldiv/facility_diagnostics.php"; ?>
                                    </div>
                                </div>
                            </div>
                            <div class="tab-pane custom-tab-pane" id="tab-eg7-3" role="tabpanel" data-status="inactive">
                                <div class="card-header pr3">
                                    <ul class="nav nav-justified ml-2" id="subtabs3">
                                    </ul>
                                </div>
                                <div class="tab-content">
                                    <div class="tab-pane active" id="tab-eg8-4" role="tabpanel">
                                        <?php include "exceldiv/sales_rating.php"; ?>
                                    </div>
                                    <div class="tab-pane" id="tab-eg8-5" role="tabpanel">
                                        <?php include "exceldiv/sales_diagnostics.php"; ?>
                                    </div>
                                </div>
                            </div>
                            <div class="tab-pane custom-tab-pane" id="tab-eg7-4" role="tabpanel" data-status="inactive">
                                <div class="card-header pr3">
                                    <ul class="nav nav-justified ml-2" id="subtabs4">
                                    </ul>
                                </div>
                                <div class="tab-content">
                                    <div class="tab-pane active" id="tab-eg8-6" role="tabpanel">
                                        <?php include "exceldiv/test_rating.php"; ?>
                                    </div>
                                    <div class="tab-pane" id="tab-eg8-7" role="tabpanel">
                                        <?php include "exceldiv/test_diagnostics.php"; ?>
                                    </div>
                                </div>
                            </div>
                            <div class="tab-pane custom-tab-pane" id="tab-eg7-5" role="tabpanel" data-status="inactive">
                                <div class="card-header pr3">
                                    <ul class="nav nav-justified ml-2" id="subtabs5">
                                    </ul>
                                </div>
                                <div class="tab-content">
                                    <div class="tab-pane active" id="tab-eg8-8" role="tabpanel">
                                        <?php include "exceldiv/booking_rating.php"; ?>
                                    </div>
                                    <div class="tab-pane" id="tab-eg8-9" role="tabpanel">
                                        <?php include "exceldiv/booking_diagnostics.php"; ?>
                                    </div>
                                </div>
                            </div>
                            <div class="tab-pane custom-tab-pane" id="tab-eg7-6" role="tabpanel" data-status="inactive">
                                <?php include "exceldiv/waiting.php"; ?>
                            </div>
                            <div class="tab-pane custom-tab-pane" id="tab-eg7-7" role="tabpanel" data-status="inactive">
                                <div class="card-header pr3">
                                    <ul class="nav nav-justified ml-2" id="subtabs6">
                                    </ul>
                                </div>
                                <div class="tab-content">
                                    <div class="tab-pane active" id="tab-eg8-10" role="tabpanel">
                                        <?php include "exceldiv/delivery_rating.php"; ?>
                                    </div>
                                    <div class="tab-pane" id="tab-eg8-11" role="tabpanel">
                                        <?php include "exceldiv/delivery_diagnostics.php"; ?>
                                    </div>
                                </div>
                            </div>
                            <div class="tab-pane custom-tab-pane" id="tab-eg7-8" role="tabpanel" data-status="inactive">
                                <?php include "exceldiv/postsales.php"; ?>
                            </div>
                        </div><!-- tab-content -->
                    </div><!-- app-main inner-->
                </div><!-- app-main outer-->
            </div><!-- app-main div-->
        </div><!-- app-container div-->
        <div class="popup-btn" onclick="openF()">
            <a href="javascript:void(0)">
                FILTERS
            </a>
        </div>
        <!-- <div class="popup-btn trends" onclick="trends(1)" id="trends_open_div">
            <a href="javascript:void(0)">
                TRENDS
            </a>
        </div>
        <div class="popup-btn trends" onclick="trends(2)" id="trends_close_div" style="display:none">
            <a href="javascript:void(0)">
                GO BACK
            </a>
        </div> -->
        <div id="mySidebar2" class="sidebar2">
            <a href="javascript:void(0)" class="closebtn" onclick="closeF()">×</a>
            <ul class="vertical-nav-menu mb-5"
                style="padding:0px 20px 20px 20px !important;font-family: 'Roboto', sans-serif" id="filterX">
                <?php include('filter.php');?>
            </ul>
        </div>
        <script type="text/javascript" src="assets/scripts/main.d810cf0ae7f39f28f336.js"></script>
        <script type="text/javascript" src="assets/select2/select2.min.js"></script>
        <script async defer src="https://buttons.github.io/buttons.js"></script>
        <script src="https://cdn.jsdelivr.net/jquery.validation/1.16.0/jquery.validate.min.js"></script>
	    <script src="https://cdn.jsdelivr.net/jquery.validation/1.16.0/additional-methods.min.js"></script>
        <script src="assets/wizard/js/jquery.steps.js"></script>
	    <script src="assets/wizard/js/main.js"></script>
        <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
        <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-multiselect/0.9.15/js/bootstrap-multiselect.min.js"></script>
        <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-multiselect/0.9.15/js/bootstrap-multiselect.js"></script>
        <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-multiselect/0.9.15/js/bootstrap-multiselect.min.js.map"></script>
        <script type="text/javascript" src="https://code.highcharts.com/highcharts.js"></script>
        <script type="text/javascript" src="https://code.highcharts.com/modules/variable-pie.js"></script>
        <script type="text/javascript" src="https://code.highcharts.com/highcharts-more.js"></script>
        <script type="text/javascript" src="https://code.highcharts.com/modules/exporting.js"></script>
        <script type="text/javascript" src="https://code.highcharts.com/modules/offline-exporting.js"></script>
        <!-- <script type="text/javascript" src="https://cdn.jsdelivr.net/gh/linways/table-to-excel@v1.0.4/dist/tableToExcel.js"></script> -->
        
        <script lang="javascript" src="https://cdn.sheetjs.com/xlsx-0.20.1/package/dist/xlsx.full.min.js"></script>
        
        <script>
            //var demoTxt = ["Month 1","Month 2","Month 3","Month 4","Month 5"];
            var cityLengthX = zoneLengthX = regionLengthX = timeLengthX = '';
            var condX = ``;
            var conX = ``;
            var trendcondX = ``;
            var filtercondX = ``;
            var tabsName = ``;
            var tabsSerial = ``;
            var overallBase = ``;
            var zoneTxt = [];
            var regionTxt = [];
            var cityTxt = [];
            var timeTxt = [];
            var timeVal = [];
            var statusArr = ['active', 'active', 'active', 'active', 'active', 'active', 'active', 'active', 'active'];
            var classArr = [];
            var innerTabE = ["KPI","Pre Sales","Facility Infrastucture","Sales Initiation","Test Drive","Booking and Deal Closure","Waiting Period","Delivery ","Post Sales"];
            var allAjax = [firstAjax,secondAjax,thirdAjax,forthAjax,fifthAjax,sixthAjax,seventhAjax,eigthAjax,ninthAjax];
            //var trendsAjax = [tenthAjax,eleventhAjax,twelfthAjax,thirteenthAjax,fourteenthAjax,fifteenthAjax,sixteenthAjax,seventeenthAjax,eighteenthAjax];
            //var trendsAjax = [thirteenthAjax,fourteenthAjax,fifteenthAjax,sixteenthAjax,seventeenthAjax,eighteenthAjax];
            var functionFlag = [false,false,false,false,false,false,false,false,false];
            var functionFlagT = [false,false,false,false,false,false,false,false,false];
            var excelStatus = true;
            // START export advance
                //Setting all ajax to false jaise jaise ajax call complete hoga us index ki value true hoti jayegi
                var ajaxFlag = [false,false,false,false,false,false,false,false,false];
            // END export advance
            var brandTxt = ["Maruti Suzuki Arena","Maruti Suzuki Nexa","Hyundai","Kia","Mahindra","Tata Motors","Toyota","MG"];
            // var modelTxt = [
            //     ["Hyundai Accent","Hyundai Alcazar","Hyundai Aura","Hyundai Creta","Hyundai Elantra","Hyundai Eon","Hyundai Exter","Hyundai Getz","Hyundai i10","Hyundai i20","Hyundai Santro","Hyundai Sonata","Hyundai Terracan","Hyundai Tucson","Hyundai Venue","Hyundai Verna","Hyundai Xcent"],
            //     ["Kia Carens","Kia Carnival","Kia Seltos","Kia Sonnet"],
            //     ["Mahindra Bolero","Mahindra Commander","Mahindra KUV100","Mahindra Marazzo","Mahindra Marshal","Mahindra Maxx","Mahindra Nuvosport","Mahindra Quanto","Mahindra Reva","Mahindra Savari","Mahindra Scorpio","Mahindra Scorpio N","Mahindra Thar","Mahindra TUV300","Mahindra Verito","Mahindra Vibe","Mahindra Voyager","Mahindra XUV 300","Mahindra XUV 400","Mahindra XUV 500","Mahindra XUV700","Mahindra Xylo"],
            //     ["Maruti Suzuki Alto 800","Maruti Suzuki Alto K10","Maruti Suzuki Celerio","Maruti Suzuki Ritz","Maruti Suzuki S-Presso","Maruti Suzuki Swift","Maruti Suzuki Swift Dzire","Maruti Suzuki SX4","Maruti Suzuki Vitara Brezza","Maruti Suzuki Wagon R","Maruti Suzuki Ertiga"],
            //     ["Maruti Suzuki Ciaz","Maruti Suzuki Baleno","Maruti Suzuki Fronx","Maruti Suzuki Grand Vitara","Maruti Suzuki Invicto","Maruti Suzuki XL6","Maruti Suzuki S-cross","Maruti Suzuki Jimny","Maruti Suzuki Ignis"],
            //     ["Tata Altroz","Tata Aria","Tata Bolt","Tata Estate","Tata Harrier","Tata Hexa","Tata Indica","Tata Indigo","Tata Nano","Tata Nexon","Tata Punch","Tata Safari","Tata Sierra","Tata Sumo","Tata Tiago","Tata Tigor","Tata Venture","Tata Zest"],
            //     ["Toyota Camry","Toyota Corolla","Toyota Etios","Toyota Fortuner","Toyota Glanza","Toyota Hyryder","Toyota Innova","Toyota Innova Crysta","Toyota Innova Hycross","Toyota Land Cruiser Prado","Toyota Urban Cruiser","Toyota Yaris"],
            //     ["MG Astor","MG Gloster","MG Hector","MG ZS EV"]
            // ];
            var modelTxt = [
                ["Hyundai Alcazar", "Hyundai Aura", "Hyundai Creta", "Hyundai Exter", "Hyundai i10", "Hyundai i20", "Hyundai Tucson", "Hyundai Venue", "Hyundai Verna"],
                ["Kia Carens", "Kia Seltos", "Kia Sonnet"],
                ["Mahindra Bolero", "Mahindra Scorpio", "Mahindra Scorpio N", "Mahindra Thar", "Mahindra XUV 300", "Mahindra XUV 400", "Mahindra XUV 500", "Mahindra XUV 700"],
                ["Maruti Suzuki Alto 800", "Maruti Suzuki Celerio", "Maruti Suzuki Swift", "Maruti Suzuki Swift Dzire", "Maruti Suzuki Vitara Brezza", "Maruti Suzuki Wagon R", "Maruti Suzuki Ertiga"],
                ["Maruti Suzuki Ciaz", "Maruti Suzuki Baleno", "Maruti Suzuki Fronx", "Maruti Suzuki Grand Vitara", "Maruti Suzuki Invicto", "Maruti Suzuki XL6", "Maruti Suzuki S-cross", "Maruti Suzuki Jimny", "Maruti Suzuki Ignis"],
                ["Tata Altroz", "Tata Harrier", "Tata Nexon", "Tata Punch", "Tata Safari", "Tata Tiago", "Tata Tigor"],
                ["Toyota Camry", "Toyota Corolla", "Toyota Fortuner", "Toyota Glanza", "Toyota Hyryder", "Toyota Innova Crysta", "Toyota Innova Hycross"],
                ["MG Astor", "MG Gloster", "MG Hector", "MG ZS EV"]
            ];
            var regionLabel = [["North-1","North-2","North-3"],["East-1","East-2","East-3"],["West-1","West-2","West-3"],["South-1","South-2","South-3"],["Central-1 & Central-2","Central-3","Central-4"],["South-East-1","South-East-2"]];
            var regionLabelIndex = [["1","2","3"],["4","5","6"],["7","8","9"],["10","11","12"],["13","14","15"],["16","17"]];
            var cityLabel = [["DEHRADUN"],["CHANDIGARH","JALLANDHAR","JAMMU","SRINAGAR"],["AGRA","GORAKHPUR","KANPUR","LUCKNOW"],["KOLKATA"],["PATNA","RANCHI"],["GUWAHATI"],["GOA","MUMBAI"],["NAGPUR","PUNE"],["AHMEDABAD","RAJKOT","SURAT","VADODARA"],["CHENNAI","COIMBATORE","MADURAI"],["BANGALORE"],["CALICUT","COCHIN","MALAPPURAM","TRIVANDRUM"],["NCR"],["JAIPUR","UDAIPUR"],["BHOPAL","GWALIOR","INDORE"],["HYDERABAD","VIJAYAWADA","VISHAKHAPATNAM"],["BHUBANESHWAR","RAIPUR"]];
            var cityLabelIndex = [["1"],["2","3","4","5"],["6","7","8","9"],["10"],["11","12"],["13"],["14","15"],["16","17"],["18","19","20","21"],["22","23","24"],["25"],["26","27","28","29"],["30"],["31","32"],["33","34","35"],["36","37","38"],["39","40"]];
            var QFIX1Label = ["% of Yes","% of No"];
            var QFIX3Label = ["Within 5 mins","Within 10 mins","Within 15 mins","More than 15 mins"];
            var QSIX1Label = ["Not at all","Partially","Completely"];
            var QSI2Label = ["No follow up needed","1-2 times","3-4 times","4-5 times","More than 5 times","Only when asked"];
            var QBDX3Label = ["More than my expectations","Same as my expectations","Less than my expectations"];
            // var QBDX4Label = ["Within a week","Within 2 weeks","Within 3 weeks","Within a month","Within 2 months","As soon as possible","No specific deadline", "flexible timeline"];
            var QBDX4Label = ["Within a week","Within 2 weeks","Within 3 weeks","Within a month","Within 2 months","As soon as possible","No specific deadline"];
            var QDPD1Label = ["Took delivery at the dealership","Had it delivered to my home/office","Took delivery at field"];
            const npsLabel = ['Detractors','Passive','Promoters','NPS'];
            const npsColor = ['#E66C37','#77C3FE','#12239E','#333333'];
            const customLabel = ['Mean','Top 2%'];
            const customColor = ['#255A29','#8F9831'];
            const yesnocolor = ['#77C3FE','#ffa31a'];
            // const fourcolor = ['#000000','#0066cc','#0080ff','#3399ff','#4da6ff'];
            //const fourcolor = ['#4da6ff','#77C3FE','#239DFF','#1678CF','#09579E','#003870'];
            //const fourcolor = ['#191970', '#000080', '#4169E1', '#0000CD', '#1E90FF', '#87CEEB', '#87CEFA'].reverse();
            const fourcolor = ['#023858','#035B8A','#0470B0','#3690BF','#74A9CE','#A6BCDB','#D0D0E7'];
            const fourcolorT = ['#023858','#035B8A','#0470B0','#3690BF','#74A9CE','#A6BCDB','#D0D0E7']; 
            var oemVal = '0';
            var tblHeadType_1 = ["Brand","Mean Score","Top 2 Score"];
            var tblHeadType_2 = ["Brand","Detractors","Passives","Promoters","NPS"];
            var tblHeadType_3 = ["Brand","% of Yes"];
            var tblHeadType_4 = ["Brand","% of No"];
            var tblHeadType_7 = ["Brand","Experienced Index"];

            //=================================Document.Ready START============================================

            $(document).ready(function() {
                
                var subsTab1 = ``;
                var subsTab2 = ``;
                var subsTab3 = ``;
                var subsTab4 = ``;
                var subsTab5 = ``;
                var subsTab6 = ``;
                
                $(".custom-tab-pane").each(function(i,e){
                    
                    var classArr2 = []
                    $(this).find(".row").each(function(i2,e2){
                        classArr2 = [];
                        $(this).find('table').addClass(`tbl_${i}`);
                        classArr2.push(`tbl_${i}`);
                    });
                    classArr.push(classArr2);
                });
            });
            $(window).on("load", function() {
                applyF();
            });
            //=================================Document.Ready END============================================

            // START export advance
                // Function to check all AJAX calls have completed
                function checkAjaxCompletion()
                {
                    console.log(ajaxFlag);
                    if (ajaxFlag.every(flag => flag === true)) 
                    {
                        exportExcel();
                        console.log("Done Now");
                    }
                    else
                    {
                        console.log("Not Now");
                    }
                }
                
            // END export advance

            function applyF()
            {
                condX = ``;
                trendcondX = ``;
                conX = ``;
                filtercondX = ``;
                zoneTxt = [];
                regionTxt = [];
                cityTxt = [];
                timeTxt = [];

                // Function to get the value of a URL parameter by name
                function getParameterValue(parameterName) {
                    // Get the query string part of the URL
                    var queryString = window.location.search.substring(1);
                    
                    // Split the query string into individual parameters
                    var parameters = queryString.split("&");
                    
                    // Loop through each parameter to find the one with the specified name
                    for (var i = 0; i < parameters.length; i++) {
                        var parameter = parameters[i].split("=");
                        if (parameter[0] === parameterName) {
                            // Decode and return the value of the parameter
                            return decodeURIComponent(parameter[1]);
                        }
                    }
                    // Return null if the parameter is not found
                    return null;
                }

                // Example usage:

                var queryString = window.location.search;
                var urlParams = new URLSearchParams(queryString);

                // Get the values of the variables
                condX = urlParams.get('condX');
                conX = urlParams.get('conX');
                oemVal = urlParams.get('oemVal');
                filtercondX = urlParams.get('filtercondX');
                filtercondX = filtercondX.replace(/<\/?b>/g, '');
                // Now you can use variableValue in your JavaScript code
                console.log("condX");
                console.log(condX); // This will print the value of the variable to the console

                console.log("conX");
                console.log(conX); // This will print the value of the variable to the console

                console.log("filtercondX");
                console.log(filtercondX); // This will print the value of the variable to the console

                console.log("oemVal");
                console.log(oemVal); // This will print the value of the variable to the console

                statusArr.forEach(function(e,i,a){
                    if(e=="active")
                    {
                        if(functionFlag[i]===false)
                        {
                            const selectedFunction = allAjax[i];
                            functionFlag[i]=true;
                            selectedFunction();
                        }
                        else{}
                    }
                });
            }

            function firstAjax()
            {
                debugger;
                $.ajax({
                    url: "api/ajax1.php",
                    type: "POST",
                    data: {
                        'condX' : condX,
                        'conX' : conX,
                        'oemVal' : oemVal
                    },
                    async:false,
                    success: function(response) {
                        var data = JSON.parse(response);
                        var QA1Brand = data['QA1'];
                        var QA2Brand = data['QA2'];
                        var QA4Brand = data['QA4'];
                        var QA2L = data['QA2L'];
                        var QA1L = data['QA1L'];
                        var QA4L = data['QA4L'];
                        var QA1BrandGlobal = data['QA1X'];
                        var QA2BrandGlobal = data['QA2X'];
                        overallBase = data['overall_base'];

                        var htmlBase = `<h6 class="ml-2 mt-2"><b>Sample Size: ${overallBase}</b></h6>`;
                        $("#overallBase").empty().append(htmlBase);

                        if(overallBase!=0)
                        {
                                //Experience
                                console.log(QA1BrandGlobal);
                                console.log(QA2BrandGlobal);

                                var flattenedArray1 = QA1BrandGlobal.flatMap(x => x);
                                console.log(flattenedArray1);

                                var flattenedArray2 = QA2BrandGlobal.flatMap(x => x);
                                console.log(flattenedArray2);

                                var summedElements = flattenedArray1.map(function(element, index) {
                                    return parseInt(((element + flattenedArray2[index])/2).toFixed());
                                });

                                console.log(summedElements);

                                var experiencedLucifer = [{
                                    name: 'Experienced Score',
                                    color:'#0066CC',
                                    data: summedElements,
                                }];

                                console.log(experiencedLucifer);

                                var htmlHead_experiencedMean = ``;
                                htmlHead_experiencedMean += `<tr style="display:none"><th>Sample Size: ${overallBase}</th></tr>`;
                                htmlHead_experiencedMean += `<tr style="display:none"><th>${filtercondX}</th></tr>`;
                                htmlHead_experiencedMean += `<tr style="display:none"><th>Experienced Index</th></tr>`;
                                htmlHead_experiencedMean += `<tr>`;
                                tblHeadType_7.forEach(function(e,i,a){
                                    htmlHead_experiencedMean += `<th>${e}</th>`;
                                });
                                htmlHead_experiencedMean += `</tr>`;

                                var htmlBody_experiencedMean = ``;
                                
                                QA1L.forEach(function(e,i,a){
                                    htmlBody_experiencedMean += `<tr>`;
                                    htmlBody_experiencedMean += `<th>${e}</th>`;
                                    htmlBody_experiencedMean += `<td>${summedElements[i]}%</td>`;
                                    htmlBody_experiencedMean += `</tr>`;
                                });

                                $("#experienced_tbl > thead").empty().append(htmlHead_experiencedMean);
                                $("#experienced_tbl > tbody").empty().append(htmlBody_experiencedMean);

                            //Experience
                            
                            // QA1Brand
                                if(QA1Brand.length===0)
                                {
                                    $("#qa1_meanbrand").empty().append(`<h6 class="blank_msg">No Data to Preview</h6>`);
                                    $("#qa1_topbrand").empty().append(`<h6 class="blank_msg">No Data to Preview</h6>`);
                                    $("#QA1_tbl > thead").empty();
                                    $("#QA1_tbl > tbody").empty().append(`<h6 class="blank_msg">No Data to Preview</h6>`);
                                }
                                else
                                {
                                    var QA1Brand_transposeData = QA1Brand[0].map((col, i) => QA1Brand.map(row => row[i]));
                                    var QA1BrandMean_luciferX = QA1Brand_transposeData[0];
                                    var QA1BrandTop_luciferX = QA1Brand_transposeData[1];

                                    var QA1BrandMean_lucifer = [{
                                        name: 'Mean Score',
                                        color:'#6190E6',
                                        data: QA1BrandMean_luciferX,
                                    }];

                                    var QA1BrandTop_lucifer = [{
                                        name: 'Top 2 Score',
                                        color:'#0066CC',
                                        data: QA1BrandTop_luciferX,
                                    }];

                                    var htmlHead_QA1Mean = ``;
                                    htmlHead_QA1Mean += `<tr style="display:none"><th>Overall Satisfaction</th></tr>`;
                                    htmlHead_QA1Mean += `<tr>`;
                                    tblHeadType_1.forEach(function(e,i,a){
                                        htmlHead_QA1Mean += `<th>${e}</th>`;
                                    });
                                    htmlHead_QA1Mean += `</tr>`;

                                    var htmlBody_QA1Mean = ``;
                                    
                                    QA1L.forEach(function(e,i,a){
                                        htmlBody_QA1Mean += `<tr>`;
                                        htmlBody_QA1Mean += `<th>${e}</th>`;
                                        htmlBody_QA1Mean += `<td>${QA1BrandMean_luciferX[i]}</td>`;
                                        htmlBody_QA1Mean += `<td>${QA1BrandTop_luciferX[i]}%</td>`;
                                        htmlBody_QA1Mean += `</tr>`;
                                    });

                                    $("#QA1_tbl > thead").empty().append(htmlHead_QA1Mean);
                                    $("#QA1_tbl > tbody").empty().append(htmlBody_QA1Mean);
                                }
                            // QA1Brand

                            // QA2Brand
                                if(QA2Brand.length===0)
                                {
                                    $("#qa2_brand").empty().append(`<h6 class="blank_msg">No Data to Preview</h6>`);
                                    $("#QA2_tbl > thead").empty();
                                    $("#QA2_tbl > tbody").empty().append(`<h6 class="blank_msg">No Data to Preview</h6>`);
                                }
                                else
                                {
                                    var npsData = QA2Brand.map(function(subArray) {
                                        return subArray.pop();
                                    });
                                    
                                    var QA2Brand_transposeData = QA2Brand[0].map((col, i) => QA2Brand.map(row => row[i]));

                                    var customE = Array.from({ length: QA2L.length }, () => null);
                                    QA2Brand_transposeData.push(customE);

                                    var QA2Brand_lucifer = Object.assign(QA2Brand_transposeData.map(function(element,index){
                                        return {
                                            ['name']:npsLabel[index],
                                            ['color']: npsColor[index],
                                            ['data']:element
                                        };
                                    }));

                                    var htmlHead_QA2Mean = ``;
                                    htmlHead_QA2Mean += `<tr style="display:none"><th>NPS</th></tr>`;
                                    htmlHead_QA2Mean += `<tr>`;
                                    tblHeadType_2.forEach(function(e,i,a){
                                        htmlHead_QA2Mean += `<th>${e}</th>`;
                                    });
                                    htmlHead_QA2Mean += `</tr>`;

                                    var htmlBody_QA2Mean = ``;
                                    QA2L.forEach(function(e2,i2,a2){
                                        htmlBody_QA2Mean += `<tr>`;
                                        htmlBody_QA2Mean += `<th>${e2}</th>`;
                                        QA2Brand_transposeData.forEach(function(e,i,a){
                                            if(e[i2]==null)
                                            {
                                                htmlBody_QA2Mean += `<td>${npsData[i2].toFixed()}%</td>`;
                                            }
                                            else
                                            {
                                                htmlBody_QA2Mean += `<td>${e[i2]}%</td>`;
                                            }
                                            
                                        });
                                        htmlBody_QA2Mean += `</tr>`;
                                    })
                                    
                                    $("#QA2_tbl > thead").empty().append(htmlHead_QA2Mean);
                                    $("#QA2_tbl > tbody").empty().append(htmlBody_QA2Mean);
                                }
                            // QA2Brand

                            // QA4Brand
                                if(QA4Brand.length===0)
                                {
                                    $("#qa4_meanbrand").empty().append(`<h6 class="blank_msg">No Data to Preview</h6>`);
                                    $("#qa4_topbrand").empty().append(`<h6 class="blank_msg">No Data to Preview</h6>`);
                                    
                                    $("#QA4_tbl > thead").empty();
                                    $("#QA4_tbl > tbody").empty().append(`<h6 class="blank_msg">No Data to Preview</h6>`);
                                }
                                else
                                {
                                    var QA4Brand_transposeData = QA4Brand[0].map((col, i) => QA4Brand.map(row => row[i]));
                                    var QA4BrandMean_luciferX = QA4Brand_transposeData[0];
                                    var QA4BrandTop_luciferX = QA4Brand_transposeData[1];

                                    var QA4BrandMean_lucifer = [{
                                        name: 'Mean Score',
                                        color:'#6190E6',
                                        data: QA4BrandMean_luciferX,
                                    }];
                                    var QA4BrandTop_lucifer = [{
                                        name: 'Top 2 Score',
                                        color:'#0066CC',
                                        data: QA4BrandTop_luciferX,
                                    }];

                                    var htmlHead_QA4Mean = ``;
                                    htmlHead_QA4Mean += `<tr style="display:none"><th>Likely to Repurchase</th></tr>`;
                                    htmlHead_QA4Mean += `<tr>`;
                                    tblHeadType_1.forEach(function(e,i,a){
                                        htmlHead_QA4Mean += `<th>${e}</th>`;
                                    });
                                    htmlHead_QA4Mean += `</tr>`;
                                    var htmlBody_QA4Mean = ``;
                                    QA4L.forEach(function(e,i,a){
                                        htmlBody_QA4Mean += `<tr>`;
                                        htmlBody_QA4Mean += `<th>${e}</th>`;
                                        htmlBody_QA4Mean += `<td>${QA4BrandMean_luciferX[i]}</td>`;
                                        htmlBody_QA4Mean += `<td>${QA4BrandTop_luciferX[i]}%</td>`;
                                        htmlBody_QA4Mean += `</tr>`;
                                    });
                                    $("#QA4_tbl > thead").empty().append(htmlHead_QA4Mean);
                                    $("#QA4_tbl > tbody").empty().append(htmlBody_QA4Mean);
                                }
                            // QA4Brand
                        }
                        else
                        {
                            $("#qa1_meanbrand").empty().append(`<h6 class="blank_msg">No Data to Preview</h6>`);
                            $("#qa1_topbrand").empty().append(`<h6 class="blank_msg">No Data to Preview</h6>`);
                            $("#qa2_brand").empty().append(`<h6 class="blank_msg">No Data to Preview</h6>`);
                            $("#qa4_meanbrand").empty().append(`<h6 class="blank_msg">No Data to Preview</h6>`);
                            $("#qa4_topbrand").empty().append(`<h6 class="blank_msg">No Data to Preview</h6>`);

                            $("#QA1_tbl > thead").empty();
                            $("#QA1_tbl > tbody").empty().append(`<h6 class="blank_msg">No Data to Preview</h6>`);
                            $("#QA2_tbl > thead").empty();
                            $("#QA2_tbl > tbody").empty().append(`<h6 class="blank_msg">No Data to Preview</h6>`);
                            $("#QA4_tbl > thead").empty();
                            $("#QA4_tbl > tbody").empty().append(`<h6 class="blank_msg">No Data to Preview</h6>`);
                        }
                    },
                    complete: function (data) 
                    {
                        ajaxFlag[0] = true;
                        if(excelStatus===true)
                        {
                            checkAjaxCompletion()
                        }
                    }
                });
            }

            function secondAjax()
            {
                $.ajax({
                    url: "api/ajax2.php",
                    type: "POST",
                    data: {
                        'condX' : condX,
                        'conX' : conX,
                        'oemVal' : oemVal
                    },
                    async:false,
                    success: function(response) {
                        var data = JSON.parse(response);
                        console.log("ajax2");
                        console.log(data);
                        var QPS2Brand = data['QPS2'];
                        var QPS3Brand = data['QPS3'];
                        var QPS4Brand = data['QPS4'];
                        var QPS2L = data['QPS2L'];
                        var QPS3L = data['QPS3L'];
                        var QPS4L = data['QPS4L'];

                        if(overallBase!=0)
                        {
                            //QPS2
                                if(QPS2Brand.length===0)
                                {
                                    $("#qps2_meanbrand").empty().append(`<h6 class="blank_msg">No Data to Preview</h6>`);
                                    $("#qps2_topbrand").empty().append(`<h6 class="blank_msg">No Data to Preview</h6>`);

                                    $("#QPS2_tbl > thead").empty();
                                    $("#QPS2_tbl > tbody").empty().append(`<h6 class="blank_msg">No Data to Preview</h6>`);
                                }
                                else
                                {
                                    var QPS2Brand_transposeData = QPS2Brand[0].map((col, i) => QPS2Brand.map(row => row[i]));
                                    var QPS2BrandMean_luciferX = QPS2Brand_transposeData[0];
                                    var QPS2BrandTop_luciferX = QPS2Brand_transposeData[1];

                                    var QPS2BrandMean_lucifer = [{
                                        name: 'Mean Score',
                                        color:'#6190E6',
                                        data: QPS2BrandMean_luciferX,
                                    }];
                                    var QPS2BrandTop_lucifer = [{
                                        name: 'Top 2 Score',
                                        color:'#0066CC',
                                        data: QPS2BrandTop_luciferX,
                                    }];

                                    var htmlHead_QPS2Mean = ``;
                                    htmlHead_QPS2Mean += `<tr style="display:none"><th>Experience with Website</th></tr>`;
                                    htmlHead_QPS2Mean += `<tr>`;
                                    tblHeadType_1.forEach(function(e,i,a){
                                        htmlHead_QPS2Mean += `<th>${e}</th>`;
                                    });
                                    htmlHead_QPS2Mean += `</tr>`;

                                    var htmlBody_QPS2Mean = ``;
                                    
                                    QPS2L.forEach(function(e,i,a){
                                        htmlBody_QPS2Mean += `<tr>`;
                                        htmlBody_QPS2Mean += `<th>${e}</th>`;
                                        htmlBody_QPS2Mean += `<td>${QPS2BrandMean_luciferX[i]}</td>`;
                                        htmlBody_QPS2Mean += `<td>${QPS2BrandTop_luciferX[i]}%</td>`;
                                        htmlBody_QPS2Mean += `</tr>`;
                                    });

                                    $("#QPS2_tbl > thead").empty().append(htmlHead_QPS2Mean);
                                    $("#QPS2_tbl > tbody").empty().append(htmlBody_QPS2Mean);
                                }
                            //QPS2

                            //QPS3
                                if(QPS3Brand.length===0)
                                {
                                    $("#qps3_meanbrand").empty().append(`<h6 class="blank_msg">No Data to Preview</h6>`);
                                    $("#qps3_topbrand").empty().append(`<h6 class="blank_msg">No Data to Preview</h6>`);
                                    $("#QPS3_tbl > thead").empty();
                                    $("#QPS3_tbl > tbody").empty().append(`<h6 class="blank_msg">No Data to Preview</h6>`);
                                }
                                else
                                {
                                    var QPS3Brand_transposeData = QPS3Brand[0].map((col, i) => QPS3Brand.map(row => row[i]));
                                    var QPS3BrandMean_luciferX = QPS3Brand_transposeData[0];
                                    var QPS3BrandTop_luciferX = QPS3Brand_transposeData[1];

                                    var QPS3BrandMean_lucifer = [{
                                        name: 'Mean Score',
                                        color:'#6190E6',
                                        data: QPS3BrandMean_luciferX,
                                    }];
                                    var QPS3BrandTop_lucifer = [{
                                        name: 'Top 2 Score',
                                        color:'#0066CC',
                                        data: QPS3BrandTop_luciferX,
                                    }];

                                    
                                    var htmlHead_QPS3Mean = ``;
                                    htmlHead_QPS3Mean += `<tr style="display:none"><th>Availability of Dealer Staff for interaction at pre- decided time and place</th></tr>`;
                                    htmlHead_QPS3Mean += `<tr>`;
                                    tblHeadType_1.forEach(function(e,i,a){
                                        htmlHead_QPS3Mean += `<th>${e}</th>`;
                                    });
                                    htmlHead_QPS3Mean += `</tr>`;

                                    var htmlBody_QPS3Mean = ``;
                                    
                                    QPS3L.forEach(function(e,i,a){
                                        htmlBody_QPS3Mean += `<tr>`;
                                        htmlBody_QPS3Mean += `<th>${e}</th>`;
                                        htmlBody_QPS3Mean += `<td>${QPS3BrandMean_luciferX[i]}</td>`;
                                        htmlBody_QPS3Mean += `<td>${QPS3BrandTop_luciferX[i]}%</td>`;
                                        htmlBody_QPS3Mean += `</tr>`;
                                    });

                                    $("#QPS3_tbl > thead").empty().append(htmlHead_QPS3Mean);
                                    $("#QPS3_tbl > tbody").empty().append(htmlBody_QPS3Mean);
                                }
                            //QPS3

                            //QPS4
                                debugger;
                                if(QPS4Brand.length===0)
                                {
                                    $("#qps4_meanbrand").empty().append(`<h6 class="blank_msg">No Data to Preview</h6>`);
                                    $("#qps4_topbrand").empty().append(`<h6 class="blank_msg">No Data to Preview</h6>`);
                                    $("#QPS4_tbl > thead").empty();
                                    $("#QPS4_tbl > tbody").empty().append(`<h6 class="blank_msg">No Data to Preview</h6>`);
                                }
                                else
                                {
                                    var QPS4Brand_transposeData = QPS4Brand[0].map((col, i) => QPS4Brand.map(row => row[i]));
                                    var QPS4BrandMean_luciferX = QPS4Brand_transposeData[0];
                                    var QPS4BrandTop_luciferX = QPS4Brand_transposeData[1];

                                    var QPS4BrandMean_lucifer = [{
                                        name: 'Mean Score',
                                        color:'#6190E6',
                                        data: QPS4BrandMean_luciferX,
                                    }];
                                    var QPS4BrandTop_lucifer = [{
                                        name: 'Top 2 Score',
                                        color:'#0066CC',
                                        data: QPS4BrandTop_luciferX,
                                    }];

                                    
                                    var htmlHead_QPS4Mean = ``;
                                    htmlHead_QPS4Mean += `<tr style="display:none"><th>Sample Size: ${overallBase}</th></tr>`;
                                    htmlHead_QPS4Mean += `<tr style="display:none"><th>${filtercondX}</th></tr>`;
                                    htmlHead_QPS4Mean += `<tr style="display:none"><th>Pre-Sales Satisfaction</th></tr>`;
                                    htmlHead_QPS4Mean += `<tr>`;
                                    tblHeadType_1.forEach(function(e,i,a){
                                        htmlHead_QPS4Mean += `<th>${e}</th>`;
                                    });
                                    htmlHead_QPS4Mean += `</tr>`;

                                    var htmlBody_QPS4Mean = ``;
                                    
                                    QPS4L.forEach(function(e,i,a){
                                        htmlBody_QPS4Mean += `<tr>`;
                                        htmlBody_QPS4Mean += `<th>${e}</th>`;
                                        htmlBody_QPS4Mean += `<td>${QPS4BrandMean_luciferX[i]}</td>`;
                                        htmlBody_QPS4Mean += `<td>${QPS4BrandTop_luciferX[i]}%</td>`;
                                        htmlBody_QPS4Mean += `</tr>`;
                                    });

                                    $("#QPS4_tbl > thead").empty().append(htmlHead_QPS4Mean);
                                    $("#QPS4_tbl > tbody").empty().append(htmlBody_QPS4Mean);
                                }
                            //QPS4
                        }
                        else
                        {
                            $("#qps2_meanbrand").empty().append(`<h6 class="blank_msg">No Data to Preview</h6>`);
                            $("#qps2_topbrand").empty().append(`<h6 class="blank_msg">No Data to Preview</h6>`);
                            $("#QPS2_tbl > thead").empty(); 
                            $("#QPS2_tbl > tbody").empty().append(`<h6 class="blank_msg">No Data to Preview</h6>`);
                            $("#qps3_meanbrand").empty().append(`<h6 class="blank_msg">No Data to Preview</h6>`);
                            $("#qps3_topbrand").empty().append(`<h6 class="blank_msg">No Data to Preview</h6>`);
                            $("#QPS3_tbl > thead").empty();
                            $("#QPS3_tbl > tbody").empty().append(`<h6 class="blank_msg">No Data to Preview</h6>`);
                            $("#qps4_meanbrand").empty().append(`<h6 class="blank_msg">No Data to Preview</h6>`);
                            $("#qps4_topbrand").empty().append(`<h6 class="blank_msg">No Data to Preview</h6>`);
                            $("#QPS4_tbl > thead").empty();
                            $("#QPS4_tbl > tbody").empty().append(`<h6 class="blank_msg">No Data to Preview</h6>`);
                        }
                    },
                    complete: function (data) 
                    {
                        ajaxFlag[1] = true;
                        if(excelStatus===true)
                        {
                            checkAjaxCompletion()
                        }
                    }
                });
            }

            function thirdAjax()
            {
                $.ajax({
                    url: "api/ajax3.php",
                    type: "POST",
                    data: {
                        'condX' : condX,
                        'conX' : conX,
                        'oemVal' : oemVal
                    },
                    success: function(response) {
                        var data = JSON.parse(response);
                        console.log("ajax3");
                        console.log(data);
                        var QFLBrand = data['QFI'];
                        var QFILabelBrand = data['QFIL'];
                        var QFILabelOVBrand = data['QFIOVERALLL'];
                        var QFILBrand = QFLBrand[0];
                        var QFLOVBrand = QFLBrand[1];
                        var QFIXBrand = data['QFIX'];
                        var QFIXLabelBrand = data['QFIXL'];
                        var QFIX3Brand = data['QFIX3'];
                        var QFIX3LabelBrand = data['QFIX3L'];

                        if(overallBase!=0)
                        {
                            //QFLOV
                                if(QFLOVBrand.length===0)
                                {
                                    $("#qflov_meanbrand").empty().append(`<h6 class="blank_msg" >No Data to Preview</h6>`);
                                    $("#qflov_topbrand").empty().append(`<h6 class="blank_msg" >No Data to Preview</h6>`);

                                    $("#QFLOV_tbl > thead").empty();
                                    $("#QFLOV_tbl > tbody").empty().append(`<h6 class="blank_msg" >No Data to Preview</h6>`);
                                }
                                else
                                {
                                    var QFLOVBrand_transposeData = QFLOVBrand[0].map((col, i) => QFLOVBrand.map(row => row[i]));
                                    var QFLOVBrandMean_luciferX = QFLOVBrand_transposeData[0];
                                    var QFLOVBrandTop_luciferX = QFLOVBrand_transposeData[1];

                                    var QFLOVBrandMean_lucifer = [{
                                        name: 'Mean Score',
                                        color:'#6190E6',
                                        data: QFLOVBrandMean_luciferX,
                                    }];
                                    var QFLOVBrandTop_lucifer = [{
                                        name: 'Top 2 Score',
                                        color:'#0066CC',
                                        data: QFLOVBrandTop_luciferX,
                                    }];

                                    
                                    var htmlHead_QFLOVMean = ``;
                                    htmlHead_QFLOVMean += `<tr style="display:none"><th>Sample Size: ${overallBase}</th></tr>`;
                                    htmlHead_QFLOVMean += `<tr style="display:none"><th>${filtercondX}</th></tr>`;
                                    htmlHead_QFLOVMean += `<tr style="display:none"><th>Overall facilities/ Infrastructure</th></tr>`;
                                    htmlHead_QFLOVMean += `<tr>`;
                                    tblHeadType_1.forEach(function(e,i,a){
                                        htmlHead_QFLOVMean += `<th>${e}</th>`;
                                    });
                                    htmlHead_QFLOVMean += `</tr>`;
                                    var htmlBody_QFLOVMean = ``;
                                    QFILabelOVBrand.forEach(function(e,i,a){
                                        htmlBody_QFLOVMean += `<tr>`;
                                        htmlBody_QFLOVMean += `<th>${e}</th>`;
                                        htmlBody_QFLOVMean += `<td>${QFLOVBrandMean_luciferX[i]}</td>`;
                                        htmlBody_QFLOVMean += `<td>${QFLOVBrandTop_luciferX[i]}%</td>`;
                                        htmlBody_QFLOVMean += `</tr>`;
                                    });
                                    $("#QFLOV_tbl > thead").empty().append(htmlHead_QFLOVMean);
                                    $("#QFLOV_tbl > tbody").empty().append(htmlBody_QFLOVMean);
                                }
                                
                            //QFLOV

                            //QFIL
                                if(QFILBrand.length===0)
                                {
                                    $("#qfil_1_meanbrand").empty().append(`<h6 class="blank_msg" >No Data to Preview</h6>`);
                                    $("#qfil_1_topbrand").empty().append(`<h6 class="blank_msg" >No Data to Preview</h6>`);
                                    $("#qfil_2_meanbrand").empty().append(`<h6 class="blank_msg" >No Data to Preview</h6>`);
                                    $("#qfil_2_topbrand").empty().append(`<h6 class="blank_msg" >No Data to Preview</h6>`);
                                    $("#qfil_3_meanbrand").empty().append(`<h6 class="blank_msg" >No Data to Preview</h6>`);
                                    $("#qfil_3_topbrand").empty().append(`<h6 class="blank_msg" >No Data to Preview</h6>`);
                                    $("#qfil_4_meanbrand").empty().append(`<h6 class="blank_msg" >No Data to Preview</h6>`);
                                    $("#qfil_4_topbrand").empty().append(`<h6 class="blank_msg" >No Data to Preview</h6>`);
                                    
                                    $("#QFIL_1tbl > thead").empty();
                                    $("#QFIL_2tbl > thead").empty();
                                    $("#QFIL_3tbl > thead").empty();
                                    $("#QFIL_4tbl > thead").empty();

                                    $("#QFIL_1tbl > tbody").empty().append(`<h6 class="blank_msg" >No Data to Preview</h6>`);
                                    $("#QFIL_2tbl > tbody").empty().append(`<h6 class="blank_msg" >No Data to Preview</h6>`);
                                    $("#QFIL_3tbl > tbody").empty().append(`<h6 class="blank_msg" >No Data to Preview</h6>`);
                                    $("#QFIL_4tbl > tbody").empty().append(`<h6 class="blank_msg" >No Data to Preview</h6>`);
                                }
                                else
                                {   
                                    var QFILBrand_1 = QFILBrand[0];
                                    var QFILBrand_2 = QFILBrand[1];
                                    var QFILBrand_3 = QFILBrand[2];
                                    var QFILBrand_4 = QFILBrand[3];

                                    var QFILBrand_1_transposeData = QFILBrand_1[0].map((col, i) => QFILBrand_1.map(row => row[i]));
                                    var QFILBrand_1_Mean_luciferX = QFILBrand_1_transposeData[0];
                                    var QFILBrand_1_Top_luciferX = QFILBrand_1_transposeData[1];

                                    var QFILBrand_1_Mean_lucifer = [{
                                        name: 'Mean Score',
                                        color:'#6190E6',
                                        data: QFILBrand_1_Mean_luciferX,
                                    }];
                                    var QFILBrand_1_Top_lucifer = [{
                                        name: 'Top 2 Score',
                                        color:'#0066CC',
                                        data: QFILBrand_1_Top_luciferX,
                                    }];

                                    var QFILBrand_2_transposeData = QFILBrand_2[0].map((col, i) => QFILBrand_2.map(row => row[i]));
                                    var QFILBrand_2_Mean_luciferX = QFILBrand_2_transposeData[0];
                                    var QFILBrand_2_Top_luciferX = QFILBrand_2_transposeData[1];

                                    var QFILBrand_2_Mean_lucifer = [{
                                        name: 'Mean Score',
                                        color:'#6190E6',
                                        data: QFILBrand_2_Mean_luciferX,
                                    }];
                                    var QFILBrand_2_Top_lucifer = [{
                                        name: 'Top 2 Score',
                                        color:'#0066CC',
                                        data: QFILBrand_2_Top_luciferX,
                                    }];

                                    var QFILBrand_3_transposeData = QFILBrand_3[0].map((col, i) => QFILBrand_3.map(row => row[i]));
                                    var QFILBrand_3_Mean_luciferX = QFILBrand_3_transposeData[0];
                                    var QFILBrand_3_Top_luciferX = QFILBrand_3_transposeData[1];

                                    var QFILBrand_3_Mean_lucifer = [{
                                        name: 'Mean Score',
                                        color:'#6190E6',
                                        data: QFILBrand_3_Mean_luciferX,
                                    }];
                                    var QFILBrand_3_Top_lucifer = [{
                                        name: 'Top 2 Score',
                                        color:'#0066CC',
                                        data: QFILBrand_3_Top_luciferX,
                                    }];

                                    var QFILBrand_4_transposeData = QFILBrand_4[0].map((col, i) => QFILBrand_4.map(row => row[i]));
                                    var QFILBrand_4_Mean_luciferX = QFILBrand_4_transposeData[0];
                                    var QFILBrand_4_Top_luciferX = QFILBrand_4_transposeData[1];

                                    var QFILBrand_4_Mean_lucifer = [{
                                        name: 'Mean Score',
                                        color:'#6190E6',
                                        data: QFILBrand_4_Mean_luciferX,
                                    }];
                                    var QFILBrand_4_Top_lucifer = [{
                                        name: 'Top 2 Score',
                                        color:'#0066CC',
                                        data: QFILBrand_4_Top_luciferX,
                                    }];

                                    
                                    var htmlHead_QFIL_1Mean = ``;
                                    htmlHead_QFIL_1Mean += `<tr style="display:none"><th>Promptness and reception</th></tr>`;
                                    htmlHead_QFIL_1Mean += `<tr>`;
                                    tblHeadType_1.forEach(function(e,i,a){
                                        htmlHead_QFIL_1Mean += `<th>${e}</th>`;
                                    });
                                    htmlHead_QFIL_1Mean += `</tr>`;
                                    var htmlBody_QFIL_1Mean = ``;
                                    QFILabelBrand[0].forEach(function(e,i,a){
                                        htmlBody_QFIL_1Mean += `<tr>`;
                                        htmlBody_QFIL_1Mean += `<th>${e}</th>`;
                                        htmlBody_QFIL_1Mean += `<td>${QFILBrand_1_Mean_luciferX[i]}</td>`;
                                        htmlBody_QFIL_1Mean += `<td>${QFILBrand_1_Top_luciferX[i]}%</td>`;
                                        htmlBody_QFIL_1Mean += `</tr>`;
                                    });
                                    $("#QFIL_1tbl > thead").empty().append(htmlHead_QFIL_1Mean);
                                    $("#QFIL_1tbl > tbody").empty().append(htmlBody_QFIL_1Mean);

                                    var htmlHead_QFIL_2Mean = ``;
                                    htmlHead_QFIL_2Mean += `<tr style="display:none"><th>Showroom Ambience</th></tr>`;
                                    htmlHead_QFIL_2Mean += `<tr>`;
                                    tblHeadType_1.forEach(function(e,i,a){
                                        htmlHead_QFIL_2Mean += `<th>${e}</th>`;
                                    });
                                    htmlHead_QFIL_2Mean += `</tr>`;
                                    var htmlBody_QFIL_2Mean = ``;
                                    QFILabelBrand[1].forEach(function(e,i,a){
                                        htmlBody_QFIL_2Mean += `<tr>`;
                                        htmlBody_QFIL_2Mean += `<th>${e}</th>`;
                                        htmlBody_QFIL_2Mean += `<td>${QFILBrand_2_Mean_luciferX[i]}</td>`;
                                        htmlBody_QFIL_2Mean += `<td>${QFILBrand_2_Top_luciferX[i]}%</td>`;
                                        htmlBody_QFIL_2Mean += `</tr>`;
                                    });
                                    $("#QFIL_2tbl > thead").empty().append(htmlHead_QFIL_2Mean);
                                    $("#QFIL_2tbl > tbody").empty().append(htmlBody_QFIL_2Mean);

                                    var htmlHead_QFIL_3Mean = ``;
                                    htmlHead_QFIL_3Mean += `<tr style="display:none"><th>Quality of offering refreshments</th></tr>`;
                                    htmlHead_QFIL_3Mean += `<tr>`;
                                    tblHeadType_1.forEach(function(e,i,a){
                                        htmlHead_QFIL_3Mean += `<th>${e}</th>`;
                                    });
                                    htmlHead_QFIL_3Mean += `</tr>`;
                                    var htmlBody_QFIL_3Mean = ``;
                                    QFILabelBrand[2].forEach(function(e,i,a){
                                        htmlBody_QFIL_3Mean += `<tr>`;
                                        htmlBody_QFIL_3Mean += `<th>${e}</th>`;
                                        htmlBody_QFIL_3Mean += `<td>${QFILBrand_3_Mean_luciferX[i]}</td>`;
                                        htmlBody_QFIL_3Mean += `<td>${QFILBrand_3_Top_luciferX[i]}%</td>`;
                                        htmlBody_QFIL_3Mean += `</tr>`;
                                    });
                                    $("#QFIL_3tbl > thead").empty().append(htmlHead_QFIL_3Mean);
                                    $("#QFIL_3tbl > tbody").empty().append(htmlBody_QFIL_3Mean);

                                    var htmlHead_QFIL_4Mean = ``;
                                    htmlHead_QFIL_4Mean += `<tr style="display:none"><th>Ability to showcase the car model</th></tr>`;
                                    htmlHead_QFIL_4Mean += `<tr>`;
                                    tblHeadType_1.forEach(function(e,i,a){
                                        htmlHead_QFIL_4Mean += `<th>${e}</th>`;
                                    });
                                    htmlHead_QFIL_4Mean += `</tr>`;
                                    var htmlBody_QFIL_4Mean = ``;
                                    QFILabelBrand[2].forEach(function(e,i,a){
                                        htmlBody_QFIL_4Mean += `<tr>`;
                                        htmlBody_QFIL_4Mean += `<th>${e}</th>`;
                                        htmlBody_QFIL_4Mean += `<td>${QFILBrand_4_Mean_luciferX[i]}</td>`;
                                        htmlBody_QFIL_4Mean += `<td>${QFILBrand_4_Top_luciferX[i]}%</td>`;
                                        htmlBody_QFIL_4Mean += `</tr>`;
                                    });
                                    $("#QFIL_4tbl > thead").empty().append(htmlHead_QFIL_4Mean);
                                    $("#QFIL_4tbl > tbody").empty().append(htmlBody_QFIL_4Mean);
                                }
                                
                            //QFIL

                            //QFIX
                                if(QFIXBrand.length===0)
                                {
                                    $("#qfix_1brand").empty().append(`<h6 class="blank_msg" >No Data to Preview</h6>`);
                                    $("#qfix_2brand").empty().append(`<h6 class="blank_msg" >No Data to Preview</h6>`);
                                    
                                    $("#QFIX_1tbl > thead").empty();
                                    $("#QFIX_1tbl > tbody").empty().append(`<h6 class="blank_msg" >No Data to Preview</h6>`);
                                    $("#QFIX_2tbl > thead").empty();
                                    $("#QFIX_2tbl > tbody").empty().append(`<h6 class="blank_msg" >No Data to Preview</h6>`);
                                }
                                else
                                {
                                    var QFIX1Brand_LuciferX = QFIXBrand[0];
                                    var QFIX2Brand_LuciferX = QFIXBrand[1];

                                    var QFIX1Brand_transposeLuciferX = QFIX1Brand_LuciferX[0].map((col, i) => QFIX1Brand_LuciferX.map(row => row[i]));

                                    var QFIX1Brand_Lucifer = Object.assign(QFIX1Brand_transposeLuciferX.map(function(element, index) {
                                        return {
                                            ['name']: QFIX1Label[index],
                                            ['color']: yesnocolor[index],
                                            ['data']: element
                                        };
                                    }));

                                    var QFIX2Brand_transposeLuciferX = QFIX2Brand_LuciferX[0].map((col, i) => QFIX2Brand_LuciferX.map(row => row[i]));

                                    var QFIX2Brand_Lucifer = Object.assign(QFIX2Brand_transposeLuciferX.map(function(element, index) {
                                        return {
                                            ['name']: QFIX1Label[index],
                                            ['color']: yesnocolor[index],
                                            ['data']: element
                                        };
                                    }));

                                    
                                    var htmlHead_QFIX_1Mean = ``;
                                    htmlHead_QFIX_1Mean += `<tr style="display:none"><th>Availability of Parking Facility</th></tr>`;
                                    htmlHead_QFIX_1Mean += `<tr>`;
                                    tblHeadType_3.forEach(function(e,i,a){
                                        htmlHead_QFIX_1Mean += `<th>${e}</th>`;
                                    });
                                    htmlHead_QFIX_1Mean += `</tr>`;
                                    var htmlBody_QFIX_1Mean = ``;
                                    QFIXLabelBrand[0].forEach(function(e,i,a){
                                        htmlBody_QFIX_1Mean += `<tr>`;
                                        htmlBody_QFIX_1Mean += `<th>${e}</th>`;
                                        htmlBody_QFIX_1Mean += `<td>${QFIX1Brand_transposeLuciferX[0][i]}%</td>`;
                                        htmlBody_QFIX_1Mean += `</tr>`;
                                    });
                                    $("#QFIX_1tbl > thead").empty().append(htmlHead_QFIX_1Mean);
                                    $("#QFIX_1tbl > tbody").empty().append(htmlBody_QFIX_1Mean);

                                    var htmlHead_QFIX_2Mean = ``;
                                    htmlHead_QFIX_2Mean += `<tr style="display:none"><th>Parking Assistance available or Provided by Dealer</th></tr>`;
                                    htmlHead_QFIX_2Mean += `<tr>`;
                                    tblHeadType_3.forEach(function(e,i,a){
                                        htmlHead_QFIX_2Mean += `<th>${e}</th>`;
                                    });
                                    htmlHead_QFIX_2Mean += `</tr>`;
                                    var htmlBody_QFIX_2Mean = ``;
                                    QFIXLabelBrand[1].forEach(function(e,i,a){
                                        htmlBody_QFIX_2Mean += `<tr>`;
                                        htmlBody_QFIX_2Mean += `<th>${e}</th>`;
                                        htmlBody_QFIX_2Mean += `<td>${QFIX2Brand_transposeLuciferX[0][i]}%</td>`;
                                        htmlBody_QFIX_2Mean += `</tr>`;
                                    });
                                    $("#QFIX_2tbl > thead").empty().append(htmlHead_QFIX_2Mean);
                                    $("#QFIX_2tbl > tbody").empty().append(htmlBody_QFIX_2Mean);
                                }
                                
                            //QFIX

                            //QFIX3
                                if(QFIX3Brand.length===0)
                                {
                                    $("#qfix_3brand").empty().append(`<h6 class="blank_msg" >No Data to Preview</h6>`);

                                    $("#QFIX_3tbl > thead").empty();
                                    $("#QFIX_3tbl > tbody").empty().append(`<h6 class="blank_msg" >No Data to Preview</h6>`);
                                }
                                else
                                {
                                    var QFIX3Brand_Lucifer = Object.assign(QFIX3Brand.map(function(element, index) {
                                        return {
                                            ['name']: QFIX3Label[index],
                                            ['color']: fourcolor[index],
                                            ['data']: element
                                        };
                                    }));

                                   
                                    var htmlHead_QFIX_3Mean = ``;
                                    htmlHead_QFIX_3Mean += `<tr style="display:none"><th>Time taken to assign a Sales Representative</th></tr>`;
                                    htmlHead_QFIX_3Mean += `<tr>`;
                                    htmlHead_QFIX_3Mean += `<th>Brand</th>`;
                                    QFIX3Label.forEach(function(e,i,a){
                                        htmlHead_QFIX_3Mean += `<th>${e}</th>`;
                                    });
                                    htmlHead_QFIX_3Mean += `</tr>`;
                                    var htmlBody_QFIX_3Mean = ``;
                                    QFIX3LabelBrand[0].forEach(function(e,i,a){
                                        htmlBody_QFIX_3Mean += `<tr>`;
                                        htmlBody_QFIX_3Mean += `<th>${e}</th>`;
                                        QFIX3Brand.forEach(function(e2,i2,a2){
                                            htmlBody_QFIX_3Mean += `<td>${e2[i]}%</td>`;
                                        });
                                        htmlBody_QFIX_3Mean += `</tr>`;
                                    });
                                    $("#QFIX_3tbl > thead").empty().append(htmlHead_QFIX_3Mean);
                                    $("#QFIX_3tbl > tbody").empty().append(htmlBody_QFIX_3Mean);
                                }
                            //QFIX3                          
                        }
                        else
                        {
                            $("#qflov_meanbrand").empty().append(`<h6 class="blank_msg" >No Data to Preview</h6>`);
                            $("#qflov_topbrand").empty().append(`<h6 class="blank_msg" >No Data to Preview</h6>`);
                            $("#qfil_1_meanbrand").empty().append(`<h6 class="blank_msg" >No Data to Preview</h6>`);
                            $("#qfil_1_topbrand").empty().append(`<h6 class="blank_msg" >No Data to Preview</h6>`);
                            $("#qfil_2_meanbrand").empty().append(`<h6 class="blank_msg" >No Data to Preview</h6>`);
                            $("#qfil_2_topbrand").empty().append(`<h6 class="blank_msg" >No Data to Preview</h6>`);
                            $("#qfil_3_meanbrand").empty().append(`<h6 class="blank_msg" >No Data to Preview</h6>`);
                            $("#qfil_3_topbrand").empty().append(`<h6 class="blank_msg" >No Data to Preview</h6>`);
                            $("#qfil_4_meanbrand").empty().append(`<h6 class="blank_msg" >No Data to Preview</h6>`);
                            $("#qfil_4_topbrand").empty().append(`<h6 class="blank_msg" >No Data to Preview</h6>`);
                            $("#qfix_1brand").empty().append(`<h6 class="blank_msg" >No Data to Preview</h6>`);
                            $("#qfix_2brand").empty().append(`<h6 class="blank_msg" >No Data to Preview</h6>`);
                            $("#qfix_3brand").empty().append(`<h6 class="blank_msg" >No Data to Preview</h6>`);

                            $("#QFLOV_tbl > thead").empty();
                            $("#QFLOV_tbl > tbody ").empty().append(`<h6 class="blank_msg" >No Data to Preview</h6>`);


                            $("#QFIL_1tbl > thead").empty();
                            $("#QFIL_2tbl > thead").empty();
                            $("#QFIL_3tbl > thead").empty();
                            $("#QFIL_4tbl > thead").empty();

                            $("#QFIL_1tbl > tbody").empty().append(`<h6 class="blank_msg" >No Data to Preview</h6>`);
                            $("#QFIL_2tbl > tbody").empty().append(`<h6 class="blank_msg" >No Data to Preview</h6>`);
                            $("#QFIL_3tbl > tbody").empty().append(`<h6 class="blank_msg" >No Data to Preview</h6>`);
                            $("#QFIL_4tbl > tbody").empty().append(`<h6 class="blank_msg" >No Data to Preview</h6>`);

                            $("#QFIX_1tbl > thead").empty();
                            $("#QFIX_1tbl > tbody").empty().append(`<h6 class="blank_msg" >No Data to Preview</h6>`);
                            $("#QFIX_2tbl > thead").empty();
                            $("#QFIX_2tbl > tbody").empty().append(`<h6 class="blank_msg" >No Data to Preview</h6>`);


                            $("#QFIX_3tbl > thead").empty();
                            $("#QFIX_3tbl > tbody").empty().append(`<h6 class="blank_msg" >No Data to Preview</h6>`);
                        }
                    },
                    complete: function (data) 
                    {
                        ajaxFlag[2] = true;
                        if(excelStatus===true)
                        {
                            checkAjaxCompletion()
                        }
                    }
                });
            }

            function forthAjax()
            {
                $.ajax({
                    url: "api/ajax4.php",
                    type: "POST",
                    data: {
                        'condX' : condX,
                        'conX' : conX,
                        'oemVal' : oemVal
                    },
                    success: function(response) {
                        var data = JSON.parse(response);
                        console.log("ajax4");
                        console.log(data);
                        var QSIBrand = data['QSI'];
                        var QSILBrand = QSIBrand[0];
                        var QSIOVBrand = QSIBrand[1];
                        var QSILabelBrand = data['QSIL'];
                        var QSILabelOVBrand = data['QSIOVERALLL'];
                        var QSIX1Brand = data['QSIX1'];
                        var QSIX1LabelBrand = data['QSIX1L'];
                        var QSIX2Brand = data['QSIX2'];
                        var QSIX2LabelBrand = data['QSIX2L'];
                        var QSIX3Brand = data['QSIX3'];
                        var QSIX3LabelBrand = data['QSIX3L'];
                        var QSI2Brand = data['QSI2'];
                        var QSI2LabelBrand = data['QSI2L'];

                        if(overallBase!=0)
                        {
                            //QSIOV
                                debugger;
                                if(QSIOVBrand.length===0)
                                {
                                    $("#qsiov_meanbrand").empty().append(`<h6 class="blank_msg" >No Data to Preview</h6>`);
                                    $("#qsiov_topbrand").empty().append(`<h6 class="blank_msg" >No Data to Preview</h6>`);
                                    
                                    $("#QSIOV_tbl > thead").empty();
                                    $("#QSIOV_tbl > tbody").empty().append(`<h6 class="blank_msg" >No Data to Preview</h6>`);
                                }
                                else
                                {
                                    var QSIOVBrand_transposeData = QSIOVBrand[0].map((col, i) => QSIOVBrand.map(row => row[i]));
                                    var QSIOVBrandMean_luciferX = QSIOVBrand_transposeData[0];
                                    var QSIOVBrandTop_luciferX = QSIOVBrand_transposeData[1];

                                    var QSIOVBrandMean_lucifer = [{
                                        name: 'Mean Score',
                                        color:'#6190E6',
                                        data: QSIOVBrandMean_luciferX,
                                    }];
                                    var QSIOVBrandTop_lucifer = [{
                                        name: 'Top 2 Score',
                                        color:'#0066CC',
                                        data: QSIOVBrandTop_luciferX,
                                    }];

                                    
                                    var htmlHead_QSIOVMean = ``;
                                    htmlHead_QSIOVMean += `<tr style="display:none"><th>Sample Size: ${overallBase}</th></tr>`;
                                    htmlHead_QSIOVMean += `<tr style="display:none"><th>${filtercondX}</th></tr>`;
                                    htmlHead_QSIOVMean += `<tr style="display:none"><th>Overall sales initiation</th></tr>`;
                                    htmlHead_QSIOVMean += `<tr>`;
                                    tblHeadType_1.forEach(function(e,i,a){
                                        htmlHead_QSIOVMean += `<th>${e}</th>`;
                                    });
                                    htmlHead_QSIOVMean += `</tr>`;
                                    var htmlBody_QSIOVMean = ``;
                                    QSILabelOVBrand.forEach(function(e,i,a){
                                        htmlBody_QSIOVMean += `<tr>`;
                                        htmlBody_QSIOVMean += `<th>${e}</th>`;
                                        htmlBody_QSIOVMean += `<td>${QSIOVBrandMean_luciferX[i]}</td>`;
                                        htmlBody_QSIOVMean += `<td>${QSIOVBrandTop_luciferX[i]}%</td>`;
                                        htmlBody_QSIOVMean += `</tr>`;
                                    });
                                    $("#QSIOV_tbl > thead").empty().append(htmlHead_QSIOVMean);
                                    $("#QSIOV_tbl > tbody").empty().append(htmlBody_QSIOVMean);
                                }
                            //QSIOV

                            //QSIL
                                if(QSILBrand.length===0)
                                {
                                    $("#qsil_1_meanbrand").empty().append(`<h6 class="blank_msg" >No Data to Preview</h6>`);
                                    $("#qsil_1_topbrand").empty().append(`<h6 class="blank_msg" >No Data to Preview</h6>`);
                                    $("#qsil_2_meanbrand").empty().append(`<h6 class="blank_msg" >No Data to Preview</h6>`);
                                    $("#qsil_2_topbrand").empty().append(`<h6 class="blank_msg" >No Data to Preview</h6>`);
                                    $("#qsil_3_meanbrand").empty().append(`<h6 class="blank_msg" >No Data to Preview</h6>`);
                                    $("#qsil_3_topbrand").empty().append(`<h6 class="blank_msg" >No Data to Preview</h6>`);
                                    $("#qsil_4_meanbrand").empty().append(`<h6 class="blank_msg" >No Data to Preview</h6>`);
                                    $("#qsil_4_topbrand").empty().append(`<h6 class="blank_msg" >No Data to Preview</h6>`);
                                    $("#qsil_5_meanbrand").empty().append(`<h6 class="blank_msg" >No Data to Preview</h6>`);
                                    $("#qsil_5_topbrand").empty().append(`<h6 class="blank_msg" >No Data to Preview</h6>`);

                                    $("#QSIL_1tbl > thead").empty();
                                    $("#QSIL_2tbl > thead").empty();
                                    $("#QSIL_3tbl > thead").empty();
                                    $("#QSIL_4tbl > thead").empty();
                                    $("#QSIL_5tbl > thead").empty();

                                    $("#QSIL_1tbl > tbody").empty().append(`<h6 class="blank_msg" >No Data to Preview</h6>`);
                                    $("#QSIL_2tbl > tbody").empty().append(`<h6 class="blank_msg" >No Data to Preview</h6>`);
                                    $("#QSIL_3tbl > tbody").empty().append(`<h6 class="blank_msg" >No Data to Preview</h6>`);
                                    $("#QSIL_4tbl > tbody").empty().append(`<h6 class="blank_msg" >No Data to Preview</h6>`);
                                    $("#QSIL_5tbl > tbody").empty().append(`<h6 class="blank_msg" >No Data to Preview</h6>`);
                                }
                                else
                                {
                                    var QSILBrand_1 = QSILBrand[0];
                                    var QSILBrand_2 = QSILBrand[1];
                                    var QSILBrand_3 = QSILBrand[2];
                                    var QSILBrand_4 = QSILBrand[3];
                                    var QSILBrand_5 = QSILBrand[4];

                                    var QSILBrand_1_transposeData = QSILBrand_1[0].map((col, i) => QSILBrand_1.map(row => row[i]));
                                    var QSILBrand_1_Mean_luciferX = QSILBrand_1_transposeData[0];
                                    var QSILBrand_1_Top_luciferX = QSILBrand_1_transposeData[1];

                                    var QSILBrand_1_Mean_lucifer = [{
                                        name: 'Mean Score',
                                        color:'#6190E6',
                                        data: QSILBrand_1_Mean_luciferX,
                                    }];
                                    var QSILBrand_1_Top_lucifer = [{
                                        name: 'Top 2 Score',
                                        color:'#0066CC',
                                        data: QSILBrand_1_Top_luciferX,
                                    }];

                                    var QSILBrand_2_transposeData = QSILBrand_2[0].map((col, i) => QSILBrand_2.map(row => row[i]));
                                    var QSILBrand_2_Mean_luciferX = QSILBrand_2_transposeData[0];
                                    var QSILBrand_2_Top_luciferX = QSILBrand_2_transposeData[1];

                                    var QSILBrand_2_Mean_lucifer = [{
                                        name: 'Mean Score',
                                        color:'#6190E6',
                                        data: QSILBrand_2_Mean_luciferX,
                                    }];
                                    var QSILBrand_2_Top_lucifer = [{
                                        name: 'Top 2 Score',
                                        color:'#0066CC',
                                        data: QSILBrand_2_Top_luciferX,
                                    }];

                                    var QSILBrand_3_transposeData = QSILBrand_3[0].map((col, i) => QSILBrand_3.map(row => row[i]));
                                    var QSILBrand_3_Mean_luciferX = QSILBrand_3_transposeData[0];
                                    var QSILBrand_3_Top_luciferX = QSILBrand_3_transposeData[1];

                                    var QSILBrand_3_Mean_lucifer = [{
                                        name: 'Mean Score',
                                        color:'#6190E6',
                                        data: QSILBrand_3_Mean_luciferX,
                                    }];
                                    var QSILBrand_3_Top_lucifer = [{
                                        name: 'Top 2 Score',
                                        color:'#0066CC',
                                        data: QSILBrand_3_Top_luciferX,
                                    }];

                                    var QSILBrand_4_transposeData = QSILBrand_4[0].map((col, i) => QSILBrand_4.map(row => row[i]));
                                    var QSILBrand_4_Mean_luciferX = QSILBrand_4_transposeData[0];
                                    var QSILBrand_4_Top_luciferX = QSILBrand_4_transposeData[1];

                                    var QSILBrand_4_Mean_lucifer = [{
                                        name: 'Mean Score',
                                        color:'#6190E6',
                                        data: QSILBrand_4_Mean_luciferX,
                                    }];
                                    var QSILBrand_4_Top_lucifer = [{
                                        name: 'Top 2 Score',
                                        color:'#0066CC',
                                        data: QSILBrand_4_Top_luciferX,
                                    }];

                                    var QSILBrand_5_transposeData = QSILBrand_5[0].map((col, i) => QSILBrand_5.map(row => row[i]));
                                    var QSILBrand_5_Mean_luciferX = QSILBrand_5_transposeData[0];
                                    var QSILBrand_5_Top_luciferX = QSILBrand_5_transposeData[1];

                                    var QSILBrand_5_Mean_lucifer = [{
                                        name: 'Mean Score',
                                        color:'#6190E6',
                                        data: QSILBrand_5_Mean_luciferX,
                                    }];
                                    var QSILBrand_5_Top_lucifer = [{
                                        name: 'Top 2 Score',
                                        color:'#0066CC',
                                        data: QSILBrand_5_Top_luciferX,
                                    }];


                                    
                                    var htmlHead_QSIL_1Mean = ``;
                                    htmlHead_QSIL_1Mean += `<tr style="display:none"><th>Ease of reaching out to sales representative regarding any query</th></tr>`;
                                    htmlHead_QSIL_1Mean += `<tr>`;
                                    tblHeadType_1.forEach(function(e,i,a){
                                        htmlHead_QSIL_1Mean += `<th>${e}</th>`;
                                    });
                                    htmlHead_QSIL_1Mean += `</tr>`;
                                    var htmlBody_QSIL_1Mean = ``;
                                    QSILabelBrand[0].forEach(function(e,i,a){
                                        htmlBody_QSIL_1Mean += `<tr>`;
                                        htmlBody_QSIL_1Mean += `<th>${e}</th>`;
                                        htmlBody_QSIL_1Mean += `<td>${QSILBrand_1_Mean_luciferX[i]}</td>`;
                                        htmlBody_QSIL_1Mean += `<td>${QSILBrand_1_Top_luciferX[i]}%</td>`;
                                        htmlBody_QSIL_1Mean += `</tr>`;
                                    });
                                    $("#QSIL_1tbl > thead").empty().append(htmlHead_QSIL_1Mean);
                                    $("#QSIL_1tbl > tbody").empty().append(htmlBody_QSIL_1Mean);

                                    var htmlHead_QSIL_2Mean = ``;
                                    htmlHead_QSIL_2Mean += `<tr style="display:none"><th>Courteousness/Attentiveness of sales representative during discussion</th></tr>`;
                                    htmlHead_QSIL_2Mean += `<tr>`;
                                    tblHeadType_1.forEach(function(e,i,a){
                                        htmlHead_QSIL_2Mean += `<th>${e}</th>`;
                                    });
                                    htmlHead_QSIL_2Mean += `</tr>`;
                                    var htmlBody_QSIL_2Mean = ``;
                                    QSILabelBrand[1].forEach(function(e,i,a){
                                        htmlBody_QSIL_2Mean += `<tr>`;
                                        htmlBody_QSIL_2Mean += `<th>${e}</th>`;
                                        htmlBody_QSIL_2Mean += `<td>${QSILBrand_2_Mean_luciferX[i]}</td>`;
                                        htmlBody_QSIL_2Mean += `<td>${QSILBrand_2_Top_luciferX[i]}%</td>`;
                                        htmlBody_QSIL_2Mean += `</tr>`;
                                    });
                                    $("#QSIL_2tbl > thead").empty().append(htmlHead_QSIL_2Mean);
                                    $("#QSIL_2tbl > tbody").empty().append(htmlBody_QSIL_2Mean);

                                    var htmlHead_QSIL_3Mean = ``;
                                    htmlHead_QSIL_3Mean += `<tr style="display:none"><th>Knowledge of sales representative</th></tr>`;
                                    htmlHead_QSIL_3Mean += `<tr>`;
                                    tblHeadType_1.forEach(function(e,i,a){
                                        htmlHead_QSIL_3Mean += `<th>${e}</th>`;
                                    });
                                    htmlHead_QSIL_3Mean += `</tr>`;
                                    var htmlBody_QSIL_3Mean = ``;
                                    QSILabelBrand[2].forEach(function(e,i,a){
                                        htmlBody_QSIL_3Mean += `<tr>`;
                                        htmlBody_QSIL_3Mean += `<th>${e}</th>`;
                                        htmlBody_QSIL_3Mean += `<td>${QSILBrand_3_Mean_luciferX[i]}</td>`;
                                        htmlBody_QSIL_3Mean += `<td>${QSILBrand_3_Top_luciferX[i]}%</td>`;
                                        htmlBody_QSIL_3Mean += `</tr>`;
                                    });
                                    $("#QSIL_3tbl > thead").empty().append(htmlHead_QSIL_3Mean);
                                    $("#QSIL_3tbl > tbody").empty().append(htmlBody_QSIL_3Mean);

                                    var htmlHead_QSIL_4Mean = ``;
                                    htmlHead_QSIL_4Mean += `<tr style="display:none"><th>Quality of sales executive</th></tr>`;
                                    htmlHead_QSIL_4Mean += `<tr>`;
                                    tblHeadType_1.forEach(function(e,i,a){
                                        htmlHead_QSIL_4Mean += `<th>${e}</th>`;
                                    });
                                    htmlHead_QSIL_4Mean += `</tr>`;
                                    var htmlBody_QSIL_4Mean = ``;
                                    QSILabelBrand[3].forEach(function(e,i,a){
                                        htmlBody_QSIL_4Mean += `<tr>`;
                                        htmlBody_QSIL_4Mean += `<th>${e}</th>`;
                                        htmlBody_QSIL_4Mean += `<td>${QSILBrand_4_Mean_luciferX[i]}</td>`;
                                        htmlBody_QSIL_4Mean += `<td>${QSILBrand_4_Top_luciferX[i]}%</td>`;
                                        htmlBody_QSIL_4Mean += `</tr>`;
                                    });
                                    $("#QSIL_4tbl > thead").empty().append(htmlHead_QSIL_4Mean);
                                    $("#QSIL_4tbl > tbody").empty().append(htmlBody_QSIL_4Mean);

                                    var htmlHead_QSIL_5Mean = ``;
                                    htmlHead_QSIL_5Mean += `<tr style="display:none"><th>Transparency in explanation of all costing related aspects</th></tr>`;
                                    htmlHead_QSIL_5Mean += `<tr>`;
                                    tblHeadType_1.forEach(function(e,i,a){
                                        htmlHead_QSIL_5Mean += `<th>${e}</th>`;
                                    });
                                    htmlHead_QSIL_5Mean += `</tr>`;
                                    var htmlBody_QSIL_5Mean = ``;
                                    QSILabelBrand[4].forEach(function(e,i,a){
                                        htmlBody_QSIL_5Mean += `<tr>`;
                                        htmlBody_QSIL_5Mean += `<th>${e}</th>`;
                                        htmlBody_QSIL_5Mean += `<td>${QSILBrand_5_Mean_luciferX[i]}</td>`;
                                        htmlBody_QSIL_5Mean += `<td>${QSILBrand_5_Top_luciferX[i]}%</td>`;
                                        htmlBody_QSIL_5Mean += `</tr>`;
                                    });
                                    $("#QSIL_5tbl > thead").empty().append(htmlHead_QSIL_5Mean);
                                    $("#QSIL_5tbl > tbody").empty().append(htmlBody_QSIL_5Mean);
                                }
                            //QSIL

                            //QSIX1
                                if(QSIX1Brand.length===0)
                                {
                                    $("#qsix_1brand").empty().append(`<h6 class="blank_msg" >No Data to Preview</h6>`);

                                    $("#QSIX_1tbl > thead").empty();
                                    $("#QSIX_1tbl > tbody").empty().append(`<h6 class="blank_msg" >No Data to Preview</h6>`);
                                }
                                else
                                {
                                    var QSIX1Brand_Lucifer = Object.assign(QSIX1Brand.map(function(element, index) {
                                        return {
                                            ['name']: QSIX1Label[index],
                                            ['color']: fourcolor[index],
                                            ['data']: element
                                        };
                                    }));

                                    
                                    var htmlHead_QSIX_1Mean = ``;
                                    htmlHead_QSIX_1Mean += `<tr style="display:none"><th>Sales Representative Understand your Needs</th></tr>`;
                                    htmlHead_QSIX_1Mean += `<tr>`;
                                    htmlHead_QSIX_1Mean += `<th>Brand</th>`;
                                    QSIX1Label.forEach(function(e,i,a){
                                        htmlHead_QSIX_1Mean += `<th>${e}</th>`;
                                    });
                                    htmlHead_QSIX_1Mean += `</tr>`;
                                    var htmlBody_QSIX_1Mean = ``;
                                    QSIX1LabelBrand[0].forEach(function(e,i,a){
                                        htmlBody_QSIX_1Mean += `<tr>`;
                                        htmlBody_QSIX_1Mean += `<th>${e}</th>`;
                                        QSIX1Brand.forEach(function(e2,i2,a2){
                                            htmlBody_QSIX_1Mean += `<td>${e2[i]}%</td>`;
                                        });
                                        htmlBody_QSIX_1Mean += `</tr>`;
                                    });
                                    $("#QSIX_1tbl > thead").empty().append(htmlHead_QSIX_1Mean);
                                    $("#QSIX_1tbl > tbody").empty().append(htmlBody_QSIX_1Mean);
                                }
                            //QSIX1

                            //QSIX2
                                if(QSIX2Brand.length===0)
                                {
                                    $("#qsix_2brand").empty().append(`<h6 class="blank_msg" >No Data to Preview</h6>`);
                                    
                                    
                                    $("#QSIX_2tbl > thead").empty();
                                    $("#QSIX_2tbl > tbody").empty().append(`<h6 class="blank_msg" >No Data to Preview</h6>`);
                                }
                                else
                                {
                                    var QSIX2Brand_LuciferX = QSIX2Brand[0];
                                    var QSIX2Brand_transposeLuciferX = QSIX2Brand_LuciferX[0].map((col, i) => QSIX2Brand_LuciferX.map(row => row[i]));
                                    var QSIX2Brand_Lucifer = Object.assign(QSIX2Brand_transposeLuciferX.map(function(element, index) {
                                        return {
                                            ['name']: QFIX1Label[index],
                                            ['color']: yesnocolor[index],
                                            ['data']: element
                                        };
                                    }));

                                    
                                    var htmlHead_QSIX_2Mean = ``;
                                    htmlHead_QSIX_2Mean += `<tr style="display:none"><th>Comprehensive explanations of features/ benefits</th></tr>`;
                                    htmlHead_QSIX_2Mean += `<tr>`;
                                    tblHeadType_3.forEach(function(e,i,a){
                                        htmlHead_QSIX_2Mean += `<th>${e}</th>`;
                                    });
                                    htmlHead_QSIX_2Mean += `</tr>`;
                                    var htmlBody_QSIX_2Mean = ``;
                                    QSIX2LabelBrand[0].forEach(function(e,i,a){
                                        htmlBody_QSIX_2Mean += `<tr>`;
                                        htmlBody_QSIX_2Mean += `<th>${e}</th>`;
                                        htmlBody_QSIX_2Mean += `<td>${QSIX2Brand_transposeLuciferX[0][i]}%</td>`;
                                        htmlBody_QSIX_2Mean += `</tr>`;
                                    });
                                    $("#QSIX_2tbl > thead").empty().append(htmlHead_QSIX_2Mean);
                                    $("#QSIX_2tbl > tbody").empty().append(htmlBody_QSIX_2Mean);
                                }
                            //QSIX2

                            //QSIX3
                                if(QSIX3Brand.length===0)
                                {
                                    $("#qsix3_1brand").empty().append(`<h6 class="blank_msg" >No Data to Preview</h6>`);
                                    $("#qsix3_2brand").empty().append(`<h6 class="blank_msg" >No Data to Preview</h6>`);
                                    
                                    $("#QSIX3_1tbl > thead").empty();
                                    $("#QSIX3_2tbl > thead").empty();
                                    $("#QSIX3_1tbl > tbody").empty().append(`<h6 class="blank_msg" >No Data to Preview</h6>`);
                                    $("#QSIX3_2tbl > tbody").empty().append(`<h6 class="blank_msg" >No Data to Preview</h6>`);
                                }
                                else
                                {
                                    var QSIX3_1Brand_LuciferX = QSIX3Brand[0];
                                    var QSIX3_2Brand_LuciferX = QSIX3Brand[1];

                                    var QSIX3_1Brand_transposeLuciferX = QSIX3_1Brand_LuciferX[0].map((col, i) => QSIX3_1Brand_LuciferX.map(row => row[i]));

                                    var QSIX3_1Brand_Lucifer = Object.assign(QSIX3_1Brand_transposeLuciferX.map(function(element, index) {
                                        return {
                                            ['name']: QFIX1Label[index],
                                            ['color']: yesnocolor[index],
                                            ['data']: element
                                        };
                                    }));

                                    var QSIX3_2Brand_transposeLuciferX = QSIX3_2Brand_LuciferX[0].map((col, i) => QSIX3_2Brand_LuciferX.map(row => row[i]));

                                    var QSIX3_2Brand_Lucifer = Object.assign(QSIX3_2Brand_transposeLuciferX.map(function(element, index) {
                                        return {
                                            ['name']: QFIX1Label[index],
                                            ['color']: yesnocolor[index],
                                            ['data']: element
                                        };
                                    }));

                                    
                                    var htmlHead_QSIX3_1Mean = ``;
                                    htmlHead_QSIX3_1Mean += `<tr style="display:none"><th>The dealer staff was too pushy in trying to sell additional products</th></tr>`;
                                    htmlHead_QSIX3_1Mean += `<tr>`;
                                    tblHeadType_3.forEach(function(e,i,a){
                                        htmlHead_QSIX3_1Mean += `<th>${e}</th>`;
                                    });
                                    htmlHead_QSIX3_1Mean += `</tr>`;
                                    var htmlBody_QSIX3_1Mean = ``;
                                    QSIX3LabelBrand[0].forEach(function(e,i,a){
                                        htmlBody_QSIX3_1Mean += `<tr>`;
                                        htmlBody_QSIX3_1Mean += `<th>${e}</th>`;
                                        htmlBody_QSIX3_1Mean += `<td>${QSIX3_1Brand_transposeLuciferX[0][i]}%</td>`;
                                        htmlBody_QSIX3_1Mean += `</tr>`;
                                    });
                                    $("#QSIX3_1tbl > thead").empty().append(htmlHead_QSIX3_1Mean);
                                    $("#QSIX3_1tbl > tbody").empty().append(htmlBody_QSIX3_1Mean);

                                    var htmlHead_QSIX3_2Mean = ``;
                                    htmlHead_QSIX3_2Mean += `<tr style="display:none"><th>The dealer staff attempted to add things to my overall vehicle package</th></tr>`;
                                    htmlHead_QSIX3_2Mean += `<tr>`;
                                    tblHeadType_3.forEach(function(e,i,a){
                                        htmlHead_QSIX3_2Mean += `<th>${e}</th>`;
                                    });
                                    htmlHead_QSIX3_2Mean += `</tr>`;
                                    var htmlBody_QSIX3_2Mean = ``;
                                    QSIX3LabelBrand[1].forEach(function(e,i,a){
                                        htmlBody_QSIX3_2Mean += `<tr>`;
                                        htmlBody_QSIX3_2Mean += `<th>${e}</th>`;
                                        htmlBody_QSIX3_2Mean += `<td>${QSIX3_2Brand_transposeLuciferX[0][i]}%</td>`;
                                        htmlBody_QSIX3_2Mean += `</tr>`;
                                    });
                                    $("#QSIX3_2tbl > thead").empty().append(htmlHead_QSIX3_2Mean);
                                    $("#QSIX3_2tbl > tbody").empty().append(htmlBody_QSIX3_2Mean);
                                }
                                
                            //QSIX3

                            //QSI2
                                if(QSI2Brand.length===0)
                                {
                                    $("#qsi2_brand").empty().append(`<h6 class="blank_msg" >No Data to Preview</h6>`);

                                    $("#QSI2_tbl > thead").empty();
                                    $("#QSI2_tbl > tbody").empty().append(`<h6 class="blank_msg" >No Data to Preview</h6>`);
                                }
                                else
                                {
                                    var QSI2Brand_Lucifer = Object.assign(QSI2Brand.map(function(element, index) {
                                        return {
                                            ['name']: QSI2Label[index],
                                            ['color']: fourcolor[index],
                                            ['data']: element
                                        };
                                    }));

                                    
                                    var htmlHead_QSI2_Mean = ``;
                                    htmlHead_QSI2_Mean += `<tr style="display:none"><th>Desired acceptable frequency of follow ups before booking of the car</th></tr>`;
                                    htmlHead_QSI2_Mean += `<tr>`;
                                    htmlHead_QSI2_Mean += `<th>Brand</th>`;
                                    QSI2Label.forEach(function(e,i,a){
                                        htmlHead_QSI2_Mean += `<th>${e}</th>`;
                                    });
                                    htmlHead_QSI2_Mean += `</tr>`;
                                    var htmlBody_QSI2_Mean = ``;
                                    QSI2LabelBrand[0].forEach(function(e,i,a){
                                        htmlBody_QSI2_Mean += `<tr>`;
                                        htmlBody_QSI2_Mean += `<th>${e}</th>`;
                                        QSI2Brand.forEach(function(e2,i2,a2){
                                            htmlBody_QSI2_Mean += `<td>${e2[i]}%</td>`;
                                        });
                                        htmlBody_QSI2_Mean += `</tr>`;
                                    });
                                    $("#QSI2_tbl > thead").empty().append(htmlHead_QSI2_Mean);
                                    $("#QSI2_tbl > tbody").empty().append(htmlBody_QSI2_Mean);
                                }
                            //QSI2            
                        }
                        else
                        {
                            $("#qsiov_meanbrand").empty().append(`<h6 class="blank_msg" >No Data to Preview</h6>`);
                            $("#qsiov_topbrand").empty().append(`<h6 class="blank_msg" >No Data to Preview</h6>`);
                            
                            $("#qsil_1_meanbrand").empty().append(`<h6 class="blank_msg" >No Data to Preview</h6>`);
                            $("#qsil_1_topbrand").empty().append(`<h6 class="blank_msg" >No Data to Preview</h6>`);
                            $("#qsil_2_meanbrand").empty().append(`<h6 class="blank_msg" >No Data to Preview</h6>`);
                            $("#qsil_2_topbrand").empty().append(`<h6 class="blank_msg" >No Data to Preview</h6>`);
                            $("#qsil_3_meanbrand").empty().append(`<h6 class="blank_msg" >No Data to Preview</h6>`);
                            $("#qsil_3_topbrand").empty().append(`<h6 class="blank_msg" >No Data to Preview</h6>`);
                            $("#qsil_4_meanbrand").empty().append(`<h6 class="blank_msg" >No Data to Preview</h6>`);
                            $("#qsil_4_topbrand").empty().append(`<h6 class="blank_msg" >No Data to Preview</h6>`);
                            $("#qsil_5_meanbrand").empty().append(`<h6 class="blank_msg" >No Data to Preview</h6>`);
                            $("#qsil_5_topbrand").empty().append(`<h6 class="blank_msg" >No Data to Preview</h6>`);
                            $("#qsix_1brand").empty().append(`<h6 class="blank_msg" >No Data to Preview</h6>`);
                            $("#qsix_2brand").empty().append(`<h6 class="blank_msg" >No Data to Preview</h6>`);
                            $("#qsix3_1brand").empty().append(`<h6 class="blank_msg" >No Data to Preview</h6>`);
                            $("#qsix3_2brand").empty().append(`<h6 class="blank_msg" >No Data to Preview</h6>`);
                            $("#qsi2_brand").empty().append(`<h6 class="blank_msg" >No Data to Preview</h6>`);

                            $("#QSIOV_tbl > thead").empty();
                            $("#QSIOV_tbl > tbody").empty().append(`<h6 class="blank_msg" >No Data to Preview</h6>`);

                            $("#QSIL_1tbl > thead").empty();
                            $("#QSIL_2tbl > thead").empty();
                            $("#QSIL_3tbl > thead").empty();
                            $("#QSIL_4tbl > thead").empty();
                            $("#QSIL_5tbl > thead").empty();

                            $("#QSIL_1tbl > tbody").empty().append(`<h6 class="blank_msg" >No Data to Preview</h6>`);
                            $("#QSIL_2tbl > tbody").empty().append(`<h6 class="blank_msg" >No Data to Preview</h6>`);
                            $("#QSIL_3tbl > tbody").empty().append(`<h6 class="blank_msg" >No Data to Preview</h6>`);
                            $("#QSIL_4tbl > tbody").empty().append(`<h6 class="blank_msg" >No Data to Preview</h6>`);
                            $("#QSIL_5tbl > tbody").empty().append(`<h6 class="blank_msg" >No Data to Preview</h6>`);


                            $("#QSIX_1tbl > thead").empty();
                            $("#QSIX_1tbl > tbody").empty().append(`<h6 class="blank_msg" >No Data to Preview</h6>`);

                            $("#QSIX_2tbl > thead").empty();
                            $("#QSIX_2tbl > tbody").empty().append(`<h6 class="blank_msg" >No Data to Preview</h6>`);

                            $("#QSIX3_1tbl > thead").empty();
                            $("#QSIX3_2tbl > thead").empty();
                            $("#QSIX3_1tbl > tbody").empty().append(`<h6 class="blank_msg" >No Data to Preview</h6>`);
                            $("#QSIX3_2tbl > tbody").empty().append(`<h6 class="blank_msg" >No Data to Preview</h6>`);

                            $("#QSI2_tbl > thead").empty();
                            $("#QSI2_tbl > tbody").empty().append(`<h6 class="blank_msg" >No Data to Preview</h6>`);
                        }
                    },
                    complete: function (data) 
                    {
                        ajaxFlag[3] = true;
                        if(excelStatus===true)
                        {
                            checkAjaxCompletion()
                        }
                    }
                });
            }

            function fifthAjax()
            {
                $.ajax({
                    url: "api/ajax5.php",
                    type: "POST",
                    data: {
                        'condX' : condX,
                        'conX' : conX,
                        'oemVal' : oemVal
                    },
                    success: function(response) {
                        var data = JSON.parse(response);
                        console.log("ajax5");
                        console.log(data);
                        var QTDBrand = data['QTD'];
                        var QTDLBrand = QTDBrand[0];
                        var QTDOVBrand = QTDBrand[1];
                        var QTD1LabelBrand = data['QTD1L'];
                        var QTDOVERALLLabelBrand = data['QTDOVERALLL'];
                        var QTD1Brand = data['QTDD'];
                        var QTDDLabelBrand = data['QTDDL'];

                        if(overallBase!=0)
                        {
                            //QTDOV
                                if(QTDOVBrand.length===0)
                                {
                                    $("#qtdov_meanbrand").empty().append(`<h6 class="blank_msg" >No Data to Preview</h6>`);
                                    $("#qtdov_topbrand").empty().append(`<h6 class="blank_msg" >No Data to Preview</h6>`);

                                    $("#QTDOV_tbl > thead").empty();
                                    $("#QTDOV_tbl > tbody").empty().append(`<h6 class="blank_msg" >No Data to Preview</h6>`);
                                }
                                else
                                {   
                                    var QTDOVBrand_transposeData = QTDOVBrand[0].map((col, i) => QTDOVBrand.map(row => row[i]));
                                    var QTDOVBrandMean_luciferX = QTDOVBrand_transposeData[0];
                                    var QTDOVBrandTop_luciferX = QTDOVBrand_transposeData[1];

                                    var QTDOVBrandMean_lucifer = [{
                                        name: 'Mean Score',
                                        color:'#6190E6',
                                        data: QTDOVBrandMean_luciferX,
                                    }];
                                    var QTDOVBrandTop_lucifer = [{
                                        name: 'Top 2 Score',
                                        color:'#0066CC',
                                        data: QTDOVBrandTop_luciferX,
                                    }];

                                    
                                    var htmlHead_QTDOVMean = ``;
                                    htmlHead_QTDOVMean += `<tr style="display:none"><th>Sample Size: ${overallBase}</th></tr>`;
                                    htmlHead_QTDOVMean += `<tr style="display:none"><th>${filtercondX}</th></tr>`;
                                    htmlHead_QTDOVMean += `<tr style="display:none"><th>Overall test drive experience</th></tr>`;
                                    htmlHead_QTDOVMean += `<tr>`;
                                    tblHeadType_1.forEach(function(e,i,a){
                                        htmlHead_QTDOVMean += `<th>${e}</th>`;
                                    });
                                    htmlHead_QTDOVMean += `</tr>`;
                                    var htmlBody_QTDOVMean = ``;
                                    QTDOVERALLLabelBrand.forEach(function(e,i,a){
                                        htmlBody_QTDOVMean += `<tr>`;
                                        htmlBody_QTDOVMean += `<th>${e}</th>`;
                                        htmlBody_QTDOVMean += `<td>${QTDOVBrandMean_luciferX[i]}</td>`;
                                        htmlBody_QTDOVMean += `<td>${QTDOVBrandTop_luciferX[i]}%</td>`;
                                        htmlBody_QTDOVMean += `</tr>`;
                                    });
                                    $("#QTDOV_tbl > thead").empty().append(htmlHead_QTDOVMean);
                                    $("#QTDOV_tbl > tbody").empty().append(htmlBody_QTDOVMean);
                                }
                            //QTDOV

                            //QTDL
                                if(QTDLBrand.length===0)
                                {
                                    $("#qtdl_1_meanbrand").empty().append(`<h6 class="blank_msg" >No Data to Preview</h6>`);
                                    $("#qtdl_1_topbrand").empty().append(`<h6 class="blank_msg" >No Data to Preview</h6>`);
                                    $("#qtdl_2_meanbrand").empty().append(`<h6 class="blank_msg" >No Data to Preview</h6>`);
                                    $("#qtdl_2_topbrand").empty().append(`<h6 class="blank_msg" >No Data to Preview</h6>`);
                                    $("#qtdl_3_meanbrand").empty().append(`<h6 class="blank_msg" >No Data to Preview</h6>`);
                                    $("#qtdl_3_topbrand").empty().append(`<h6 class="blank_msg" >No Data to Preview</h6>`);
                                    $("#qtdl_4_meanbrand").empty().append(`<h6 class="blank_msg" >No Data to Preview</h6>`);
                                    $("#qtdl_4_topbrand").empty().append(`<h6 class="blank_msg" >No Data to Preview</h6>`);

                                    $("#QTDL_1tbl > thead").empty();
                                    $("#QTDL_2tbl > thead").empty();
                                    $("#QTDL_3tbl > thead").empty();
                                    $("#QTDL_4tbl > thead").empty();
                                    
                                    $("#QTDL_1tbl > tbody").empty().append(`<h6 class="blank_msg" >No Data to Preview</h6>`);
                                    $("#QTDL_2tbl > tbody").empty().append(`<h6 class="blank_msg" >No Data to Preview</h6>`);
                                    $("#QTDL_3tbl > tbody").empty().append(`<h6 class="blank_msg" >No Data to Preview</h6>`);
                                    $("#QTDL_4tbl > tbody").empty().append(`<h6 class="blank_msg" >No Data to Preview</h6>`);
                                }
                                else
                                {
                                    var QTDLBrand_1 = QTDLBrand[0];
                                    var QTDLBrand_2 = QTDLBrand[1];
                                    var QTDLBrand_3 = QTDLBrand[2];
                                    var QTDLBrand_4 = QTDLBrand[3];

                                    var QTDLBrand_1_transposeData = QTDLBrand_1[0].map((col, i) => QTDLBrand_1.map(row => row[i]));
                                    var QTDLBrand_1_Mean_luciferX = QTDLBrand_1_transposeData[0];
                                    var QTDLBrand_1_Top_luciferX = QTDLBrand_1_transposeData[1];

                                    var QTDLBrand_1_Mean_lucifer = [{
                                        name: 'Mean Score',
                                        color:'#6190E6',
                                        data: QTDLBrand_1_Mean_luciferX,
                                    }];
                                    var QTDLBrand_1_Top_lucifer = [{
                                        name: 'Top 2 Score',
                                        color:'#0066CC',
                                        data: QTDLBrand_1_Top_luciferX,
                                    }];

                                    var QTDLBrand_2_transposeData = QTDLBrand_2[0].map((col, i) => QTDLBrand_2.map(row => row[i]));
                                    var QTDLBrand_2_Mean_luciferX = QTDLBrand_2_transposeData[0];
                                    var QTDLBrand_2_Top_luciferX = QTDLBrand_2_transposeData[1];

                                    var QTDLBrand_2_Mean_lucifer = [{
                                        name: 'Mean Score',
                                        color:'#6190E6',
                                        data: QTDLBrand_2_Mean_luciferX,
                                    }];
                                    var QTDLBrand_2_Top_lucifer = [{
                                        name: 'Top 2 Score',
                                        color:'#0066CC',
                                        data: QTDLBrand_2_Top_luciferX,
                                    }];

                                    var QTDLBrand_3_transposeData = QTDLBrand_3[0].map((col, i) => QTDLBrand_3.map(row => row[i]));
                                    var QTDLBrand_3_Mean_luciferX = QTDLBrand_3_transposeData[0];
                                    var QTDLBrand_3_Top_luciferX = QTDLBrand_3_transposeData[1];

                                    var QTDLBrand_3_Mean_lucifer = [{
                                        name: 'Mean Score',
                                        color:'#6190E6',
                                        data: QTDLBrand_3_Mean_luciferX,
                                    }];
                                    var QTDLBrand_3_Top_lucifer = [{
                                        name: 'Top 2 Score',
                                        color:'#0066CC',
                                        data: QTDLBrand_3_Top_luciferX,
                                    }];

                                    var QTDLBrand_4_transposeData = QTDLBrand_4[0].map((col, i) => QTDLBrand_4.map(row => row[i]));
                                    var QTDLBrand_4_Mean_luciferX = QTDLBrand_4_transposeData[0];
                                    var QTDLBrand_4_Top_luciferX = QTDLBrand_4_transposeData[1];

                                    var QTDLBrand_4_Mean_lucifer = [{
                                        name: 'Mean Score',
                                        color:'#6190E6',
                                        data: QTDLBrand_4_Mean_luciferX,
                                    }];
                                    var QTDLBrand_4_Top_lucifer = [{
                                        name: 'Top 2 Score',
                                        color:'#0066CC',
                                        data: QTDLBrand_4_Top_luciferX,
                                    }];


                                    
                                    var htmlHead_QTDL_1Mean = ``;
                                    htmlHead_QTDL_1Mean += `<tr style="display:none"><th>Duration and Place of Test Drive</th></tr>`;
                                    htmlHead_QTDL_1Mean += `<tr>`;
                                    tblHeadType_1.forEach(function(e,i,a){
                                        htmlHead_QTDL_1Mean += `<th>${e}</th>`;
                                    });
                                    htmlHead_QTDL_1Mean += `</tr>`;
                                    var htmlBody_QTDL_1Mean = ``;
                                    QTD1LabelBrand[0].forEach(function(e,i,a){
                                        htmlBody_QTDL_1Mean += `<tr>`;
                                        htmlBody_QTDL_1Mean += `<th>${e}</th>`;
                                        htmlBody_QTDL_1Mean += `<td>${QTDLBrand_1_Mean_luciferX[i]}</td>`;
                                        htmlBody_QTDL_1Mean += `<td>${QTDLBrand_1_Top_luciferX[i]}%</td>`;
                                        htmlBody_QTDL_1Mean += `</tr>`;
                                    });
                                    $("#QTDL_1tbl > thead").empty().append(htmlHead_QTDL_1Mean);
                                    $("#QTDL_1tbl > tbody").empty().append(htmlBody_QTDL_1Mean);

                                    var htmlHead_QTDL_2Mean = ``;
                                    htmlHead_QTDL_2Mean += `<tr style="display:none"><th>Timely availability of desired model at desired place</th></tr>`;
                                    htmlHead_QTDL_2Mean += `<tr>`;
                                    tblHeadType_1.forEach(function(e,i,a){
                                        htmlHead_QTDL_2Mean += `<th>${e}</th>`;
                                    });
                                    htmlHead_QTDL_2Mean += `</tr>`;
                                    var htmlBody_QTDL_2Mean = ``;
                                    QTD1LabelBrand[1].forEach(function(e,i,a){
                                        htmlBody_QTDL_2Mean += `<tr>`;
                                        htmlBody_QTDL_2Mean += `<th>${e}</th>`;
                                        htmlBody_QTDL_2Mean += `<td>${QTDLBrand_2_Mean_luciferX[i]}</td>`;
                                        htmlBody_QTDL_2Mean += `<td>${QTDLBrand_2_Top_luciferX[i]}%</td>`;
                                        htmlBody_QTDL_2Mean += `</tr>`;
                                    });
                                    $("#QTDL_2tbl > thead").empty().append(htmlHead_QTDL_2Mean);
                                    $("#QTDL_2tbl > tbody").empty().append(htmlBody_QTDL_2Mean);

                                    var htmlHead_QTDL_3Mean = ``;
                                    htmlHead_QTDL_3Mean += `<tr style="display:none"><th>Information provided during the test drive</th></tr>`;
                                    htmlHead_QTDL_3Mean += `<tr>`;
                                    tblHeadType_1.forEach(function(e,i,a){
                                        htmlHead_QTDL_3Mean += `<th>${e}</th>`;
                                    });
                                    htmlHead_QTDL_3Mean += `</tr>`;
                                    var htmlBody_QTDL_3Mean = ``;
                                    QTD1LabelBrand[2].forEach(function(e,i,a){
                                        htmlBody_QTDL_3Mean += `<tr>`;
                                        htmlBody_QTDL_3Mean += `<th>${e}</th>`;
                                        htmlBody_QTDL_3Mean += `<td>${QTDLBrand_3_Mean_luciferX[i]}</td>`;
                                        htmlBody_QTDL_3Mean += `<td>${QTDLBrand_3_Top_luciferX[i]}%</td>`;
                                        htmlBody_QTDL_3Mean += `</tr>`;
                                    });
                                    $("#QTDL_3tbl > thead").empty().append(htmlHead_QTDL_3Mean);
                                    $("#QTDL_3tbl > tbody").empty().append(htmlBody_QTDL_3Mean);

                                    var htmlHead_QTDL_4Mean = ``;
                                    htmlHead_QTDL_4Mean += `<tr style="display:none"><th>Quality & maintenance of test drive car</th></tr>`;
                                    htmlHead_QTDL_4Mean += `<tr>`;
                                    tblHeadType_1.forEach(function(e,i,a){
                                        htmlHead_QTDL_4Mean += `<th>${e}</th>`;
                                    });
                                    htmlHead_QTDL_4Mean += `</tr>`;
                                    var htmlBody_QTDL_4Mean = ``;
                                    QTD1LabelBrand[3].forEach(function(e,i,a){
                                        htmlBody_QTDL_4Mean += `<tr>`;
                                        htmlBody_QTDL_4Mean += `<th>${e}</th>`;
                                        htmlBody_QTDL_4Mean += `<td>${QTDLBrand_4_Mean_luciferX[i]}</td>`;
                                        htmlBody_QTDL_4Mean += `<td>${QTDLBrand_4_Top_luciferX[i]}%</td>`;
                                        htmlBody_QTDL_4Mean += `</tr>`;
                                    });
                                    $("#QTDL_4tbl > thead").empty().append(htmlHead_QTDL_4Mean);
                                    $("#QTDL_4tbl > tbody").empty().append(htmlBody_QTDL_4Mean);

                                }
                                
                            //QTDL

                            //QTD1
                                if(QTD1Brand.length===0)
                                {
                                    $("#qtd1_brand").empty().append(`<h6 class="blank_msg" >No Data to Preview</h6>`);

                                    $("#QTD1_tbl > thead").empty();
                                    $("#QTD1_tbl > tbody").empty().append(`<h6 class="blank_msg" >No Data to Preview</h6>`);
                                }
                                else
                                {
                                    var QTD1Brand_LuciferX = QTD1Brand[0];
                                    var QTD1Brand_transposeLuciferX = QTD1Brand_LuciferX[0].map((col, i) => QTD1Brand_LuciferX.map(row => row[i]));
                                    var QTD1Brand_Lucifer = Object.assign(QTD1Brand_transposeLuciferX.map(function(element, index) {
                                        return {
                                            ['name']: QFIX1Label[index],
                                            ['color']: yesnocolor[index],
                                            ['data']: element
                                        };
                                    }));

                                    
                                    var htmlHead_QTD1_Mean = ``;
                                    htmlHead_QTD1_Mean += `<tr style="display:none"><th>Took Test Drive at the time of purchase</th></tr>`;
                                    htmlHead_QTD1_Mean += `<tr>`;
                                    tblHeadType_3.forEach(function(e,i,a){
                                        htmlHead_QTD1_Mean += `<th>${e}</th>`;
                                    });
                                    htmlHead_QTD1_Mean += `</tr>`;
                                    var htmlBody_QTD1_Mean = ``;
                                    QTDDLabelBrand[0].forEach(function(e,i,a){
                                        htmlBody_QTD1_Mean += `<tr>`;
                                        htmlBody_QTD1_Mean += `<th>${e}</th>`;
                                        htmlBody_QTD1_Mean += `<td>${QTD1Brand_transposeLuciferX[0][i]}%</td>`;
                                        htmlBody_QTD1_Mean += `</tr>`;
                                    });
                                    $("#QTD1_tbl > thead").empty().append(htmlHead_QTD1_Mean);
                                    $("#QTD1_tbl > tbody").empty().append(htmlBody_QTD1_Mean);
                                }
                            //QTD1
                        }
                        else
                        {
                            $("#qtdov_meanbrand").empty().append(`<h6 class="blank_msg" >No Data to Preview</h6>`);
                            $("#qtdov_topbrand").empty().append(`<h6 class="blank_msg" >No Data to Preview</h6>`);
                            
                            $("#qtdl_1_meanbrand").empty().append(`<h6 class="blank_msg" >No Data to Preview</h6>`);
                            $("#qtdl_1_topbrand").empty().append(`<h6 class="blank_msg" >No Data to Preview</h6>`);
                            $("#qtdl_2_meanbrand").empty().append(`<h6 class="blank_msg" >No Data to Preview</h6>`);
                            $("#qtdl_2_topbrand").empty().append(`<h6 class="blank_msg" >No Data to Preview</h6>`);
                            $("#qtdl_3_meanbrand").empty().append(`<h6 class="blank_msg" >No Data to Preview</h6>`);
                            $("#qtdl_3_topbrand").empty().append(`<h6 class="blank_msg" >No Data to Preview</h6>`);
                            $("#qtdl_4_meanbrand").empty().append(`<h6 class="blank_msg" >No Data to Preview</h6>`);
                            $("#qtdl_4_topbrand").empty().append(`<h6 class="blank_msg" >No Data to Preview</h6>`);

                            $("#qtd1_brand").empty().append(`<h6 class="blank_msg" >No Data to Preview</h6>`);

                            $("#QTDOV_tbl > thead").empty();
                            $("#QTDOV_tbl > tbody").empty().append(`<h6 class="blank_msg" >No Data to Preview</h6>`);

                            $("#QTDL_1tbl > thead").empty();
                            $("#QTDL_2tbl > thead").empty();
                            $("#QTDL_3tbl > thead").empty();
                            $("#QTDL_4tbl > thead").empty();
                            
                            $("#QTDL_1tbl > tbody").empty().append(`<h6 class="blank_msg" >No Data to Preview</h6>`);
                            $("#QTDL_2tbl > tbody").empty().append(`<h6 class="blank_msg" >No Data to Preview</h6>`);
                            $("#QTDL_3tbl > tbody").empty().append(`<h6 class="blank_msg" >No Data to Preview</h6>`);
                            $("#QTDL_4tbl > tbody").empty().append(`<h6 class="blank_msg" >No Data to Preview</h6>`);


                            $("#QTD1_tbl > thead").empty();
                            $("#QTD1_tbl > tbody").empty().append(`<h6 class="blank_msg" >No Data to Preview</h6>`);
                            
                        }
                    },
                    complete: function (data) 
                    {
                        ajaxFlag[4] = true;
                        if(excelStatus===true)
                        {
                            checkAjaxCompletion()
                        }
                    }
                });
            }

            function sixthAjax()
            {
                $.ajax({
                    url: "api/ajax6.php",
                    type: "POST",
                    data: {
                        'condX' : condX,
                        'conX' : conX,
                        'oemVal' : oemVal
                    },
                    success: function(response) {
                        var data = JSON.parse(response);
                        console.log("ajax6");
                        console.log(data);
                        var QBDBrand = data['QBD'];
                        var QBDLBrand = QBDBrand[0];
                        var QBDOVBrand = QBDBrand[1];
                        var QBDLABELLBrand = data['QBDL'];
                        var QBDLABELOVBrand = data['QBDOVERALLL'];
                        var QBDYBrand = data['QBDY'];
                        var QBDYLabelBrand = data['QBDYL'];
                        var QBDXBrand = data['QBDX'];
                        var QBDXLabelBrand = data['QBDXL'];
                        var QBDX3Brand = data['QBDX3'];
                        var QBDX3LabelBrand = data['QBDX3L'];
                        var QBDX4Brand = data['QBDX4'];
                        var QBDX4LabelBrand = data['QBDX4L'];

                        if(overallBase!=0)
                        {
                            //QBDOV
                                if(QBDOVBrand.length===0)
                                {
                                    $("#qbdov_meanbrand").empty().append(`<h6 class="blank_msg" >No Data to Preview</h6>`);
                                    $("#qbdov_topbrand").empty().append(`<h6 class="blank_msg" >No Data to Preview</h6>`);

                                    $("#QBDOV_tbl > thead").empty();
                                    $("#QBDOV_tbl > tbody").empty().append(`<h6 class="blank_msg" >No Data to Preview</h6>`);
                                }
                                else
                                {
                                    var QBDOVBrand_transposeData = QBDOVBrand[0].map((col, i) => QBDOVBrand.map(row => row[i]));
                                    var QBDOVBrandMean_luciferX = QBDOVBrand_transposeData[0];
                                    var QBDOVBrandTop_luciferX = QBDOVBrand_transposeData[1];

                                    var QBDOVBrandMean_lucifer = [{
                                        name: 'Mean Score',
                                        color:'#6190E6',
                                        data: QBDOVBrandMean_luciferX,
                                    }];
                                    var QBDOVBrandTop_lucifer = [{
                                        name: 'Top 2 Score',
                                        color:'#0066CC',
                                        data: QBDOVBrandTop_luciferX,
                                    }];

                                    
                                    var htmlHead_QBDOVMean = ``;
                                    htmlHead_QBDOVMean += `<tr style="display:none"><th>Sample Size: ${overallBase}</th></tr>`;
                                    htmlHead_QBDOVMean += `<tr style="display:none"><th>${filtercondX}</th></tr>`;
                                    htmlHead_QBDOVMean += `<tr style="display:none"><th>Overall Booking and Deal Closure</th></tr>`;
                                    htmlHead_QBDOVMean += `<tr>`;
                                    tblHeadType_1.forEach(function(e,i,a){
                                        htmlHead_QBDOVMean += `<th>${e}</th>`;
                                    });
                                    htmlHead_QBDOVMean += `</tr>`;
                                    var htmlBody_QBDOVMean = ``;
                                    QBDLABELOVBrand.forEach(function(e,i,a){
                                        htmlBody_QBDOVMean += `<tr>`;
                                        htmlBody_QBDOVMean += `<th>${e}</th>`;
                                        htmlBody_QBDOVMean += `<td>${QBDOVBrandMean_luciferX[i]}</td>`;
                                        htmlBody_QBDOVMean += `<td>${QBDOVBrandTop_luciferX[i]}%</td>`;
                                        htmlBody_QBDOVMean += `</tr>`;
                                    });
                                    $("#QBDOV_tbl > thead").empty().append(htmlHead_QBDOVMean);
                                    $("#QBDOV_tbl > tbody").empty().append(htmlBody_QBDOVMean);
                                }
                                
                            //QBDOV

                            //QBDL
                                
                                if(QBDLBrand.length===0)
                                {
                                    $("#qbdl_1_meanbrand").empty().append(`<h6 class="blank_msg" >No Data to Preview</h6>`);
                                    $("#qbdl_1_topbrand").empty().append(`<h6 class="blank_msg" >No Data to Preview</h6>`);
                                    $("#qbdl_2_meanbrand").empty().append(`<h6 class="blank_msg" >No Data to Preview</h6>`);
                                    $("#qbdl_2_topbrand").empty().append(`<h6 class="blank_msg" >No Data to Preview</h6>`);
                                    $("#qbdl_3_meanbrand").empty().append(`<h6 class="blank_msg" >No Data to Preview</h6>`);
                                    $("#qbdl_3_topbrand").empty().append(`<h6 class="blank_msg" >No Data to Preview</h6>`);
                                    $("#qbdl_4_meanbrand").empty().append(`<h6 class="blank_msg" >No Data to Preview</h6>`);
                                    $("#qbdl_4_topbrand").empty().append(`<h6 class="blank_msg" >No Data to Preview</h6>`);

                                    $("#QBDL_1tbl > thead").empty();
                                    $("#QBDL_1tbl > tbody").empty().append(`<h6 class="blank_msg" >No Data to Preview</h6>`);
                                    $("#QBDL_2tbl > thead").empty();
                                    $("#QBDL_2tbl > tbody").empty().append(`<h6 class="blank_msg" >No Data to Preview</h6>`);
                                    $("#QBDL_3tbl > thead").empty();
                                    $("#QBDL_3tbl > tbody").empty().append(`<h6 class="blank_msg" >No Data to Preview</h6>`);
                                    $("#QBDL_4tbl > thead").empty();
                                    $("#QBDL_4tbl > tbody").empty().append(`<h6 class="blank_msg" >No Data to Preview</h6>`);
                                }
                                else
                                {
                                    var QBDLBrand_1 = QBDLBrand[0];
                                    var QBDLBrand_2 = QBDLBrand[1];
                                    var QBDLBrand_3 = QBDLBrand[2];
                                    var QBDLBrand_4 = QBDLBrand[3];

                                    var QBDLBrand_1_transposeData = QBDLBrand_1[0].map((col, i) => QBDLBrand_1.map(row => row[i]));
                                    var QBDLBrand_1_Mean_luciferX = QBDLBrand_1_transposeData[0];
                                    var QBDLBrand_1_Top_luciferX = QBDLBrand_1_transposeData[1];

                                    var QBDLBrand_1_Mean_lucifer = [{
                                        name: 'Mean Score',
                                        color:'#6190E6',
                                        data: QBDLBrand_1_Mean_luciferX,
                                    }];
                                    var QBDLBrand_1_Top_lucifer = [{
                                        name: 'Top 2 Score',
                                        color:'#0066CC',
                                        data: QBDLBrand_1_Top_luciferX,
                                    }];

                                    var QBDLBrand_2_transposeData = QBDLBrand_2[0].map((col, i) => QBDLBrand_2.map(row => row[i]));
                                    var QBDLBrand_2_Mean_luciferX = QBDLBrand_2_transposeData[0];
                                    var QBDLBrand_2_Top_luciferX = QBDLBrand_2_transposeData[1];

                                    var QBDLBrand_2_Mean_lucifer = [{
                                        name: 'Mean Score',
                                        color:'#6190E6',
                                        data: QBDLBrand_2_Mean_luciferX,
                                    }];
                                    var QBDLBrand_2_Top_lucifer = [{
                                        name: 'Top 2 Score',
                                        color:'#0066CC',
                                        data: QBDLBrand_2_Top_luciferX,
                                    }];

                                    var QBDLBrand_3_transposeData = QBDLBrand_3[0].map((col, i) => QBDLBrand_3.map(row => row[i]));
                                    var QBDLBrand_3_Mean_luciferX = QBDLBrand_3_transposeData[0];
                                    var QBDLBrand_3_Top_luciferX = QBDLBrand_3_transposeData[1];

                                    var QBDLBrand_3_Mean_lucifer = [{
                                        name: 'Mean Score',
                                        color:'#6190E6',
                                        data: QBDLBrand_3_Mean_luciferX,
                                    }];
                                    var QBDLBrand_3_Top_lucifer = [{
                                        name: 'Top 2 Score',
                                        color:'#0066CC',
                                        data: QBDLBrand_3_Top_luciferX,
                                    }];

                                    var QBDLBrand_4_transposeData = QBDLBrand_4[0].map((col, i) => QBDLBrand_4.map(row => row[i]));
                                    var QBDLBrand_4_Mean_luciferX = QBDLBrand_4_transposeData[0];
                                    var QBDLBrand_4_Top_luciferX = QBDLBrand_4_transposeData[1];

                                    var QBDLBrand_4_Mean_lucifer = [{
                                        name: 'Mean Score',
                                        color:'#6190E6',
                                        data: QBDLBrand_4_Mean_luciferX,
                                    }];
                                    var QBDLBrand_4_Top_lucifer = [{
                                        name: 'Top 2 Score',
                                        color:'#0066CC',
                                        data: QBDLBrand_4_Top_luciferX,
                                    }];

                                    
                                    var htmlHead_QBDL_1Mean = ``;
                                    htmlHead_QBDL_1Mean += `<tr style="display:none"><th>Ease of sharing the documents</th></tr>`;
                                    htmlHead_QBDL_1Mean += `<tr>`;
                                    tblHeadType_1.forEach(function(e,i,a){
                                        htmlHead_QBDL_1Mean += `<th>${e}</th>`;
                                    });
                                    htmlHead_QBDL_1Mean += `</tr>`;
                                    var htmlBody_QBDL_1Mean = ``;
                                    QBDLABELLBrand[0].forEach(function(e,i,a){
                                        htmlBody_QBDL_1Mean += `<tr>`;
                                        htmlBody_QBDL_1Mean += `<th>${e}</th>`;
                                        htmlBody_QBDL_1Mean += `<td>${QBDLBrand_1_Mean_luciferX[i]}</td>`;
                                        htmlBody_QBDL_1Mean += `<td>${QBDLBrand_1_Top_luciferX[i]}%</td>`;
                                        htmlBody_QBDL_1Mean += `</tr>`;
                                    });
                                    $("#QBDL_1tbl > thead").empty().append(htmlHead_QBDL_1Mean);
                                    $("#QBDL_1tbl > tbody").empty().append(htmlBody_QBDL_1Mean);


                                    var htmlHead_QBDL_2Mean = ``;
                                    htmlHead_QBDL_2Mean += `<tr style="display:none"><th>Ease of closing the deal</th></tr>`;
                                    htmlHead_QBDL_2Mean += `<tr>`;
                                    tblHeadType_1.forEach(function(e,i,a){
                                        htmlHead_QBDL_2Mean += `<th>${e}</th>`;
                                    });
                                    htmlHead_QBDL_2Mean += `</tr>`;
                                    var htmlBody_QBDL_2Mean = ``;
                                    QBDLABELLBrand[1].forEach(function(e,i,a){
                                        htmlBody_QBDL_2Mean += `<tr>`;
                                        htmlBody_QBDL_2Mean += `<th>${e}</th>`;
                                        htmlBody_QBDL_2Mean += `<td>${QBDLBrand_2_Mean_luciferX[i]}</td>`;
                                        htmlBody_QBDL_2Mean += `<td>${QBDLBrand_2_Top_luciferX[i]}%</td>`;
                                        htmlBody_QBDL_2Mean += `</tr>`;
                                    });
                                    $("#QBDL_2tbl > thead").empty().append(htmlHead_QBDL_2Mean);
                                    $("#QBDL_2tbl > tbody").empty().append(htmlBody_QBDL_2Mean);

                                    var htmlHead_QBDL_3Mean = ``;
                                    htmlHead_QBDL_3Mean += `<tr style="display:none"><th>Fulfilment on commitments made at the time of enquiry</th></tr>`;
                                    htmlHead_QBDL_3Mean += `<tr>`;
                                    tblHeadType_1.forEach(function(e,i,a){
                                        htmlHead_QBDL_3Mean += `<th>${e}</th>`;
                                    });
                                    htmlHead_QBDL_3Mean += `</tr>`;
                                    var htmlBody_QBDL_3Mean = ``;
                                    QBDLABELLBrand[2].forEach(function(e,i,a){
                                        htmlBody_QBDL_3Mean += `<tr>`;
                                        htmlBody_QBDL_3Mean += `<th>${e}</th>`;
                                        htmlBody_QBDL_3Mean += `<td>${QBDLBrand_3_Mean_luciferX[i]}</td>`;
                                        htmlBody_QBDL_3Mean += `<td>${QBDLBrand_3_Top_luciferX[i]}%</td>`;
                                        htmlBody_QBDL_3Mean += `</tr>`;
                                    });
                                    $("#QBDL_3tbl > thead").empty().append(htmlHead_QBDL_3Mean);
                                    $("#QBDL_3tbl > tbody").empty().append(htmlBody_QBDL_3Mean);

                                    var htmlHead_QBDL_4Mean = ``;
                                    htmlHead_QBDL_4Mean += `<tr style="display:none"><th>Willingness to assist financing with customer's preferred bank</th></tr>`;
                                    htmlHead_QBDL_4Mean += `<tr>`;
                                    tblHeadType_1.forEach(function(e,i,a){
                                        htmlHead_QBDL_4Mean += `<th>${e}</th>`;
                                    });
                                    htmlHead_QBDL_4Mean += `</tr>`;
                                    var htmlBody_QBDL_4Mean = ``;
                                    QBDLABELLBrand[3].forEach(function(e,i,a){
                                        htmlBody_QBDL_4Mean += `<tr>`;
                                        htmlBody_QBDL_4Mean += `<th>${e}</th>`;
                                        htmlBody_QBDL_4Mean += `<td>${QBDLBrand_4_Mean_luciferX[i]}</td>`;
                                        htmlBody_QBDL_4Mean += `<td>${QBDLBrand_4_Top_luciferX[i]}%</td>`;
                                        htmlBody_QBDL_4Mean += `</tr>`;
                                    });
                                    $("#QBDL_4tbl > thead").empty().append(htmlHead_QBDL_4Mean);
                                    $("#QBDL_4tbl > tbody").empty().append(htmlBody_QBDL_4Mean);
                                }
                            //QBDL

                            //QBDY
                                if(QBDYBrand.length===0)
                                {
                                    $("#qbdy_brand").empty().append(`<h6 class="blank_msg" >No Data to Preview</h6>`);;
                                    $("#QBDY_tbl > thead").empty();
                                    $("#QBDY_tbl > tbody").empty().append(`<h6 class="blank_msg" >No Data to Preview</h6>`);
                                }
                                else
                                {
                                    var QBDYBrand_LuciferX = QBDYBrand[0];
                                    var QBDYBrand_transposeLuciferX = QBDYBrand_LuciferX[0].map((col, i) => QBDYBrand_LuciferX.map(row => row[i]));
                                    var QBDYBrand_Lucifer = Object.assign(QBDYBrand_transposeLuciferX.map(function(element, index) {
                                        return {
                                            ['name']: QFIX1Label[index],
                                            ['color']: yesnocolor[index],
                                            ['data']: element
                                        };
                                    }));

                                    
                                    var htmlHead_QBDY_Mean = ``;
                                    htmlHead_QBDY_Mean += `<tr style="display:none"><th>Provided detailed information about accessories, insurance, warranty etc</th></tr>`;
                                    htmlHead_QBDY_Mean += `<tr>`;
                                    tblHeadType_3.forEach(function(e,i,a){
                                        htmlHead_QBDY_Mean += `<th>${e}</th>`;
                                    });
                                    htmlHead_QBDY_Mean += `</tr>`;
                                    var htmlBody_QBDY_Mean = ``;
                                    QBDYLabelBrand[0].forEach(function(e,i,a){
                                        htmlBody_QBDY_Mean += `<tr>`;
                                        htmlBody_QBDY_Mean += `<th>${e}</th>`;
                                        htmlBody_QBDY_Mean += `<td>${QBDYBrand_transposeLuciferX[0][i]}%</td>`;
                                        htmlBody_QBDY_Mean += `</tr>`;
                                    });
                                    $("#QBDY_tbl > thead").empty().append(htmlHead_QBDY_Mean);
                                    $("#QBDY_tbl > tbody").empty().append(htmlBody_QBDY_Mean);
                                }
                                
                            //QBDY

                            //QBDX
                                if(QBDXBrand.length===0)
                                {
                                    $("#qbdx_1brand").empty().append(`<h6 class="blank_msg" >No Data to Preview</h6>`);
                                    $("#qbdx_2brand").empty().append(`<h6 class="blank_msg" >No Data to Preview</h6>`);

                                    $("#QBDX_1tbl > thead").empty();
                                    $("#QBDX_1tbl > tbody").empty().append(`<h6 class="blank_msg" >No Data to Preview</h6>`);

                                    $("#QBDX_2tbl > thead").empty();
                                    $("#QBDX_2tbl > tbody").empty().append(`<h6 class="blank_msg" >No Data to Preview</h6>`);
                                }
                                else
                                {
                                    var QBDX_1Brand_LuciferX = QBDXBrand[0];
                                    var QBDX_2Brand_LuciferX = QBDXBrand[1];

                                    var QBDX_1Brand_transposeLuciferX = QBDX_1Brand_LuciferX[0].map((col, i) => QBDX_1Brand_LuciferX.map(row => row[i]));
                                    var QBDX_1Brand_Lucifer = Object.assign(QBDX_1Brand_transposeLuciferX.map(function(element, index) {
                                        return {
                                            ['name']: QFIX1Label[index],
                                            ['color']: yesnocolor[index],
                                            ['data']: element
                                        };
                                    }));

                                    var QBDX_2Brand_transposeLuciferX = QBDX_2Brand_LuciferX[0].map((col, i) => QBDX_2Brand_LuciferX.map(row => row[i]));
                                    var QBDX_2Brand_Lucifer = Object.assign(QBDX_2Brand_transposeLuciferX.map(function(element, index) {
                                        return {
                                            ['name']: QFIX1Label[index],
                                            ['color']: yesnocolor[index],
                                            ['data']: element
                                        };
                                    }));

                                    
                                    var htmlHead_QBDX_1Mean = ``;
                                    htmlHead_QBDX_1Mean += `<tr style="display:none"><th>Provided guidance & assistance on the Payment Mode</th></tr>`;
                                    htmlHead_QBDX_1Mean += `<tr>`;
                                    tblHeadType_3.forEach(function(e,i,a){
                                        htmlHead_QBDX_1Mean += `<th>${e}</th>`;
                                    });
                                    htmlHead_QBDX_1Mean += `</tr>`;
                                    var htmlBody_QBDX_1Mean = ``;
                                    QBDXLabelBrand[0].forEach(function(e,i,a){
                                        htmlBody_QBDX_1Mean += `<tr>`;
                                        htmlBody_QBDX_1Mean += `<th>${e}</th>`;
                                        htmlBody_QBDX_1Mean += `<td>${QBDX_1Brand_transposeLuciferX[0][i]}%</td>`;
                                        htmlBody_QBDX_1Mean += `</tr>`;
                                    });
                                    $("#QBDX_1tbl > thead").empty().append(htmlHead_QBDX_1Mean);
                                    $("#QBDX_1tbl > tbody").empty().append(htmlBody_QBDX_1Mean);

                                    var htmlHead_QBDX_2Mean = ``;
                                    htmlHead_QBDX_2Mean += `<tr style="display:none"><th>Communicated clearly on waiting period of car</th></tr>`;
                                    htmlHead_QBDX_2Mean += `<tr>`;
                                    tblHeadType_3.forEach(function(e,i,a){
                                        htmlHead_QBDX_2Mean += `<th>${e}</th>`;
                                    });
                                    htmlHead_QBDX_2Mean += `</tr>`;
                                    var htmlBody_QBDX_2Mean = ``;
                                    QBDXLabelBrand[0].forEach(function(e,i,a){
                                        htmlBody_QBDX_2Mean += `<tr>`;
                                        htmlBody_QBDX_2Mean += `<th>${e}</th>`;
                                        htmlBody_QBDX_2Mean += `<td>${QBDX_2Brand_transposeLuciferX[0][i]}%</td>`;
                                        htmlBody_QBDX_2Mean += `</tr>`;
                                    });
                                    $("#QBDX_2tbl > thead").empty().append(htmlHead_QBDX_2Mean);
                                    $("#QBDX_2tbl > tbody").empty().append(htmlBody_QBDX_2Mean);
                                }
                                
                            //QBDX

                            //QBDX3
                                if(QBDX3Brand.length===0)
                                {
                                    $("#qbdx_3brand").empty().append(`<h6 class="blank_msg" >No Data to Preview</h6>`);
                                    $("#QBDX_3tbl > thead").empty();
                                    $("#QBDX_3tbl > tbody").empty().append(`<h6 class="blank_msg" >No Data to Preview</h6>`);
                                }
                                else
                                {
                                    var QBDX3Brand_Lucifer = Object.assign(QBDX3Brand.map(function(element, index) {
                                        return {
                                            ['name']: QBDX3Label[index],
                                            ['color']: fourcolor[index],
                                            ['data']: element
                                        };
                                    }));

                                    
                                    var htmlHead_QBDX3_Mean = ``;
                                    htmlHead_QBDX3_Mean += `<tr style="display:none"><th>Time Taken to complete the paperwork</th></tr>`;
                                    htmlHead_QBDX3_Mean += `<tr>`;
                                    htmlHead_QBDX3_Mean += `<th>Brand</th>`;
                                    QBDX3Label.forEach(function(e,i,a){
                                        htmlHead_QBDX3_Mean += `<th>${e}</th>`;
                                    });
                                    htmlHead_QBDX3_Mean += `</tr>`;
                                    var htmlBody_QBDX3_Mean = ``;
                                    QBDX3LabelBrand[0].forEach(function(e,i,a){
                                        htmlBody_QBDX3_Mean += `<tr>`;
                                        htmlBody_QBDX3_Mean += `<th>${e}</th>`;
                                        QBDX3Brand.forEach(function(e2,i2,a2){
                                            htmlBody_QBDX3_Mean += `<td>${e2[i]}%</td>`;
                                        });
                                        htmlBody_QBDX3_Mean += `</tr>`;
                                    });
                                    $("#QBDX_3tbl > thead").empty().append(htmlHead_QBDX3_Mean);
                                    $("#QBDX_3tbl > tbody").empty().append(htmlBody_QBDX3_Mean);
                                }
                                
                            //QBDX3

                            //QBDX4
                                if(QBDX4Brand.length===0)
                                {
                                    $("#qbdx_4brand").empty().append(`<h6 class="blank_msg" >No Data to Preview</h6>`);

                                    $("#QBDX_4tbl > thead").empty();
                                    $("#QBDX_4tbl > tbody").empty().append(`<h6 class="blank_msg" >No Data to Preview</h6>`);
                                }
                                else
                                {
                                    var QBDX4Brand_Lucifer = Object.assign(QBDX4Brand.map(function(element, index) {
                                        return {
                                            ['name']: QBDX4Label[index],
                                            ['color']: fourcolor[index],
                                            ['data']: element
                                        };
                                    }));

                                    
                                    var htmlHead_QBDX4_Mean = ``;
                                    htmlHead_QBDX4_Mean += `<tr style="display:none"><th>Desired acceptable frequency of time period for completing the paperwork</th></tr>`;
                                    htmlHead_QBDX4_Mean += `<tr>`;
                                    htmlHead_QBDX4_Mean += `<th>Brand</th>`;
                                    QBDX4Label.forEach(function(e,i,a){
                                        htmlHead_QBDX4_Mean += `<th>${e}</th>`;
                                    });
                                    htmlHead_QBDX4_Mean += `</tr>`;
                                    var htmlBody_QBDX4_Mean = ``;
                                    QBDX4LabelBrand[0].forEach(function(e,i,a){
                                        htmlBody_QBDX4_Mean += `<tr>`;
                                        htmlBody_QBDX4_Mean += `<th>${e}</th>`;
                                        QBDX4Brand.forEach(function(e2,i2,a2){
                                            htmlBody_QBDX4_Mean += `<td>${e2[i]}%</td>`;
                                        });
                                        htmlBody_QBDX4_Mean += `</tr>`;
                                    });
                                    $("#QBDX_4tbl > thead").empty().append(htmlHead_QBDX4_Mean);
                                    $("#QBDX_4tbl > tbody").empty().append(htmlBody_QBDX4_Mean);
                                }
                                
                            //QBDX4
                        }
                        else
                        {
                            $("#qbdov_meanbrand").empty().append(`<h6 class="blank_msg" >No Data to Preview</h6>`);
                            $("#qbdov_topbrand").empty().append(`<h6 class="blank_msg" >No Data to Preview</h6>`);
                            $("#qbdl_1_meanbrand").empty().append(`<h6 class="blank_msg" >No Data to Preview</h6>`);
                            $("#qbdl_1_topbrand").empty().append(`<h6 class="blank_msg" >No Data to Preview</h6>`);
                            $("#qbdl_2_meanbrand").empty().append(`<h6 class="blank_msg" >No Data to Preview</h6>`);
                            $("#qbdl_2_topbrand").empty().append(`<h6 class="blank_msg" >No Data to Preview</h6>`);
                            $("#qbdl_3_meanbrand").empty().append(`<h6 class="blank_msg" >No Data to Preview</h6>`);
                            $("#qbdl_3_topbrand").empty().append(`<h6 class="blank_msg" >No Data to Preview</h6>`);
                            $("#qbdl_4_meanbrand").empty().append(`<h6 class="blank_msg" >No Data to Preview</h6>`);
                            $("#qbdl_4_topbrand").empty().append(`<h6 class="blank_msg" >No Data to Preview</h6>`);
                            $("#qbdy_brand").empty().append(`<h6 class="blank_msg" >No Data to Preview</h6>`);
                            $("#qbdx_1brand").empty().append(`<h6 class="blank_msg" >No Data to Preview</h6>`);
                            $("#qbdx_2brand").empty().append(`<h6 class="blank_msg" >No Data to Preview</h6>`);
                            $("#qbdx_3brand").empty().append(`<h6 class="blank_msg" >No Data to Preview</h6>`);
                            $("#qbdx_4brand").empty().append(`<h6 class="blank_msg" >No Data to Preview</h6>`);


                            $("#QBDOV_tbl > thead").empty();
                            $("#QBDOV_tbl > tbody").empty().append(`<h6 class="blank_msg" >No Data to Preview</h6>`);

                            $("#QBDL_1tbl > thead").empty();
                            $("#QBDL_1tbl > tbody").empty().append(`<h6 class="blank_msg" >No Data to Preview</h6>`);
                            $("#QBDL_2tbl > thead").empty();
                            $("#QBDL_2tbl > tbody").empty().append(`<h6 class="blank_msg" >No Data to Preview</h6>`);
                            $("#QBDL_3tbl > thead").empty();
                            $("#QBDL_3tbl > tbody").empty().append(`<h6 class="blank_msg" >No Data to Preview</h6>`);
                            $("#QBDL_4tbl > thead").empty();
                            $("#QBDL_4tbl > tbody").empty().append(`<h6 class="blank_msg" >No Data to Preview</h6>`);

                            $("#QBDY_tbl > thead").empty();
                            $("#QBDY_tbl > tbody").empty().append(`<h6 class="blank_msg" >No Data to Preview</h6>`);

                            $("#QBDX_1tbl > thead").empty();
                            $("#QBDX_1tbl > tbody").empty().append(`<h6 class="blank_msg" >No Data to Preview</h6>`);

                            $("#QBDX_2tbl > thead").empty();
                            $("#QBDX_2tbl > tbody").empty().append(`<h6 class="blank_msg" >No Data to Preview</h6>`);

                            $("#QBDX_3tbl > thead").empty();
                            $("#QBDX_3tbl > tbody").empty().append(`<h6 class="blank_msg" >No Data to Preview</h6>`);

                            $("#QBDX_4tbl > thead").empty();
                            $("#QBDX_4tbl > tbody").empty().append(`<h6 class="blank_msg" >No Data to Preview</h6>`);
                        }
                    },
                    complete: function (data) 
                    {
                        ajaxFlag[5] = true;
                        if(excelStatus===true)
                        {
                            checkAjaxCompletion()
                        }
                    }
                });
            }

            function seventhAjax()
            {
                $.ajax({
                    url: "api/ajax7.php",
                    type: "POST",
                    data: {
                        'condX' : condX,
                        'conX' : conX,
                        'oemVal' : oemVal
                    },
                    success: function(response) {
                        debugger;
                        var data = JSON.parse(response);
                        console.log("ajax7");
                        console.log(data);
                        var QWPBrand = data['QWP'];
                        var QWPLBrand = QWPBrand[0];
                        var QWPOVBrand = QWPBrand[1];
                        var QWPLABELL = data['QWPL'];
                        var QWPOVERALLLABEL = data['QWPOVERALL'];

                        if(overallBase!=0)
                        {
                            //QWPOV
                                if(QWPOVBrand.length===0)
                                {
                                    $("#qwpov_meanbrand").empty().append(`<h6 class="blank_msg" >No Data to Preview</h6>`);
                                    $("#qwpov_topbrand").empty().append(`<h6 class="blank_msg" >No Data to Preview</h6>`);

                                    $("#QWPOV_tbl > thead").empty();
                                    $("#QWPOV_tbl > tbody").empty().append(`<h6 class="blank_msg" >No Data to Preview</h6>`);
                                }
                                else
                                {
                                    var QWPOVBrand_transposeData = QWPOVBrand[0].map((col, i) => QWPOVBrand.map(row => row[i]));
                                    var QWPOVBrandMean_luciferX = QWPOVBrand_transposeData[0];
                                    var QWPOVBrandTop_luciferX = QWPOVBrand_transposeData[1];

                                    var QWPOVBrandMean_lucifer = [{
                                        name: 'Mean Score',
                                        color:'#6190E6',
                                        data: QWPOVBrandMean_luciferX,
                                    }];
                                    var QWPOVBrandTop_lucifer = [{
                                        name: 'Top 2 Score',
                                        color:'#0066CC',
                                        data: QWPOVBrandTop_luciferX,
                                    }];

                                    
                                    var htmlHead_QWPOVMean = ``;
                                    htmlHead_QWPOVMean += `<tr style="display:none"><th>Sample Size: ${overallBase}</th></tr>`;
                                    htmlHead_QWPOVMean += `<tr style="display:none"><th>${filtercondX}</th></tr>`;
                                    htmlHead_QWPOVMean += `<tr style="display:none"><th>Overall waiting period</th></tr>`;
                                    htmlHead_QWPOVMean += `<tr>`;
                                    tblHeadType_1.forEach(function(e,i,a){
                                        htmlHead_QWPOVMean += `<th>${e}</th>`;
                                    });
                                    htmlHead_QWPOVMean += `</tr>`;
                                    var htmlBody_QWPOVMean = ``;
                                    QWPOVERALLLABEL.forEach(function(e,i,a){
                                        htmlBody_QWPOVMean += `<tr>`;
                                        htmlBody_QWPOVMean += `<th>${e}</th>`;
                                        htmlBody_QWPOVMean += `<td>${QWPOVBrandMean_luciferX[i]}</td>`;
                                        htmlBody_QWPOVMean += `<td>${QWPOVBrandTop_luciferX[i]}%</td>`;
                                        htmlBody_QWPOVMean += `</tr>`;
                                    });
                                    $("#QWPOV_tbl > thead").empty().append(htmlHead_QWPOVMean);
                                    $("#QWPOV_tbl > tbody").empty().append(htmlBody_QWPOVMean);
                                }
                            //QWPOV

                            //QWPL
                                if(QWPLBrand.length===0)
                                {
                                    $("#qwpl_1_meanbrand").empty().append(`<h6 class="blank_msg" >No Data to Preview</h6>`);
                                    $("#qwpl_1_topbrand").empty().append(`<h6 class="blank_msg" >No Data to Preview</h6>`);
                                    $("#qwpl_2_meanbrand").empty().append(`<h6 class="blank_msg" >No Data to Preview</h6>`);
                                    $("#qwpl_2_topbrand").empty().append(`<h6 class="blank_msg" >No Data to Preview</h6>`);
                                    
                                    $("#QWPL_1tbl > thead").empty();
                                    $("#QWPL_1tbl > tbody").empty().append(`<h6 class="blank_msg" >No Data to Preview</h6>`);
                                    $("#QWPL_2tbl > thead").empty();
                                    $("#QWPL_2tbl > tbody").empty().append(`<h6 class="blank_msg" >No Data to Preview</h6>`);
                                }
                                else
                                {
                                    var QWPLBrand_1 = QWPLBrand[0];
                                    var QWPLBrand_2 = QWPLBrand[1];

                                    var QWPLBrand_1_transposeData = QWPLBrand_1[0].map((col, i) => QWPLBrand_1.map(row => row[i]));
                                    var QWPLBrand_1_Mean_luciferX = QWPLBrand_1_transposeData[0];
                                    var QWPLBrand_1_Top_luciferX = QWPLBrand_1_transposeData[1];

                                    var QWPLBrand_1_Mean_lucifer = [{
                                        name: 'Mean Score',
                                        color:'#6190E6',
                                        data: QWPLBrand_1_Mean_luciferX,
                                    }];
                                    var QWPLBrand_1_Top_lucifer = [{
                                        name: 'Top 2 Score',
                                        color:'#0066CC',
                                        data: QWPLBrand_1_Top_luciferX,
                                    }];

                                    var QWPLBrand_2_transposeData = QWPLBrand_2[0].map((col, i) => QWPLBrand_2.map(row => row[i]));
                                    var QWPLBrand_2_Mean_luciferX = QWPLBrand_2_transposeData[0];
                                    var QWPLBrand_2_Top_luciferX = QWPLBrand_2_transposeData[1];

                                    var QWPLBrand_2_Mean_lucifer = [{
                                        name: 'Mean Score',
                                        color:'#6190E6',
                                        data: QWPLBrand_2_Mean_luciferX,
                                    }];
                                    var QWPLBrand_2_Top_lucifer = [{
                                        name: 'Top 2 Score',
                                        color:'#0066CC',
                                        data: QWPLBrand_2_Top_luciferX,
                                    }];

                                    
                                    var htmlHead_QWPL_1Mean = ``;
                                    htmlHead_QWPL_1Mean += `<tr style="display:none"><th>Timely updates on the sales transactions</th></tr>`;
                                    htmlHead_QWPL_1Mean += `<tr>`;
                                    tblHeadType_1.forEach(function(e,i,a){
                                        htmlHead_QWPL_1Mean += `<th>${e}</th>`;
                                    });
                                    htmlHead_QWPL_1Mean += `</tr>`;
                                    var htmlBody_QWPL_1Mean = ``;
                                    QWPLABELL[0].forEach(function(e,i,a){
                                        htmlBody_QWPL_1Mean += `<tr>`;
                                        htmlBody_QWPL_1Mean += `<th>${e}</th>`;
                                        htmlBody_QWPL_1Mean += `<td>${QWPLBrand_1_Mean_luciferX[i]}</td>`;
                                        htmlBody_QWPL_1Mean += `<td>${QWPLBrand_1_Top_luciferX[i]}%</td>`;
                                        htmlBody_QWPL_1Mean += `</tr>`;
                                    });
                                    $("#QWPL_1tbl > thead").empty().append(htmlHead_QWPL_1Mean);
                                    $("#QWPL_1tbl > tbody").empty().append(htmlBody_QWPL_1Mean);

                                    var htmlHead_QWPL_2Mean = ``;
                                    htmlHead_QWPL_2Mean += `<tr style="display:none"><th>Quality of Communication during Waiting Period</th></tr>`;
                                    htmlHead_QWPL_2Mean += `<tr>`;
                                    tblHeadType_1.forEach(function(e,i,a){
                                        htmlHead_QWPL_2Mean += `<th>${e}</th>`;
                                    });
                                    htmlHead_QWPL_2Mean += `</tr>`;
                                    var htmlBody_QWPL_2Mean = ``;
                                    QWPLABELL[1].forEach(function(e,i,a){
                                        htmlBody_QWPL_2Mean += `<tr>`;
                                        htmlBody_QWPL_2Mean += `<th>${e}</th>`;
                                        htmlBody_QWPL_2Mean += `<td>${QWPLBrand_2_Mean_luciferX[i]}</td>`;
                                        htmlBody_QWPL_2Mean += `<td>${QWPLBrand_2_Top_luciferX[i]}%</td>`;
                                        htmlBody_QWPL_2Mean += `</tr>`;
                                    });
                                    $("#QWPL_2tbl > thead").empty().append(htmlHead_QWPL_2Mean);
                                    $("#QWPL_2tbl > tbody").empty().append(htmlBody_QWPL_2Mean);
                                }
                            //QWPL
                        }
                        else
                        {
                            $("#qwpov_meanbrand").empty().append(`<h6 class="blank_msg" >No Data to Preview</h6>`);
                            $("#qwpov_topbrand").empty().append(`<h6 class="blank_msg" >No Data to Preview</h6>`);
                            $("#qwpl_1_meanbrand").empty().append(`<h6 class="blank_msg" >No Data to Preview</h6>`);
                            $("#qwpl_1_topbrand").empty().append(`<h6 class="blank_msg" >No Data to Preview</h6>`);
                            $("#qwpl_2_meanbrand").empty().append(`<h6 class="blank_msg" >No Data to Preview</h6>`);
                            $("#qwpl_2_topbrand").empty().append(`<h6 class="blank_msg" >No Data to Preview</h6>`);
                            $("#QWPOV_tbl > thead").empty();
                            $("#QWPOV_tbl > tbody").empty().append(`<h6 class="blank_msg" >No Data to Preview</h6>`);
                            $("#QWPL_1tbl > thead").empty();
                            $("#QWPL_1tbl > tbody").empty().append(`<h6 class="blank_msg" >No Data to Preview</h6>`);
                            $("#QWPL_2tbl > thead").empty();
                            $("#QWPL_2tbl > tbody").empty().append(`<h6 class="blank_msg" >No Data to Preview</h6>`);
                        }
                    },
                    complete: function (data) 
                    {
                        ajaxFlag[6] = true;
                        if(excelStatus===true)
                        {
                            checkAjaxCompletion()
                        }
                    }
                });
            }

            function eigthAjax()
            {
                $.ajax({
                    url: "api/ajax8.php",
                    type: "POST",
                    data: {
                        'condX' : condX,
                        'conX' : conX,
                        'oemVal' : oemVal
                    },
                    success: function(response) {
                        var data = JSON.parse(response);
                        console.log("ajax8");
                        console.log(data);
                        var QDPBrand = data['QDP'];
                        var QDPLBrand = QDPBrand[0];
                        var QDPOVBrand = QDPBrand[1];
                        var QDPLABELLBrand = data['QDPL'];
                        var QDPLABELOVBrand = data['QDPOVERALLL'];
                        var QDPDBrand = data['QDPD'];
                        var QDPDLABELBrand = data['QDPDL'];
                        var QDP1DBrand = data['QDP1D'];
                        var QDP1DLABELBrand = data['QDP1DL'];

                        if(overallBase!=0)
                        {
                            //QDPOV
                                if(QDPOVBrand.length===0)
                                {
                                    $("#qdpov_meanbrand").empty().append(`<h6 class="blank_msg" >No Data to Preview</h6>`);
                                    $("#qdpov_topbrand").empty().append(`<h6 class="blank_msg" >No Data to Preview</h6>`);

                                    $("#QDPOV_tbl > thead").empty();
                                    $("#QDPOV_tbl > tbody").empty().append(`<h6 class="blank_msg" >No Data to Preview</h6>`);
                                }
                                else
                                {
                                    var QDPOVBrand_transposeData = QDPOVBrand[0].map((col, i) => QDPOVBrand.map(row => row[i]));
                                    var QDPOVBrandMean_luciferX = QDPOVBrand_transposeData[0];
                                    var QDPOVBrandTop_luciferX = QDPOVBrand_transposeData[1];

                                    var QDPOVBrandMean_lucifer = [{
                                        name: 'Mean Score',
                                        color:'#6190E6',
                                        data: QDPOVBrandMean_luciferX,
                                    }];
                                    var QDPOVBrandTop_lucifer = [{
                                        name: 'Top 2 Score',
                                        color:'#0066CC',
                                        data: QDPOVBrandTop_luciferX,
                                    }];

                                   
                                    var htmlHead_QDPOVMean = ``;
                                    htmlHead_QDPOVMean += `<tr style="display:none"><th>Sample Size: ${overallBase}</th></tr>`;
                                    htmlHead_QDPOVMean += `<tr style="display:none"><th>${filtercondX}</th></tr>`;
                                    htmlHead_QDPOVMean += `<tr style="display:none"><th>Overall delivery experience</th></tr>`;
                                    htmlHead_QDPOVMean += `<tr>`;
                                    tblHeadType_1.forEach(function(e,i,a){
                                        htmlHead_QDPOVMean += `<th>${e}</th>`;
                                    });
                                    htmlHead_QDPOVMean += `</tr>`;
                                    var htmlBody_QDPOVMean = ``;
                                    QDPLABELOVBrand.forEach(function(e,i,a){
                                        htmlBody_QDPOVMean += `<tr>`;
                                        htmlBody_QDPOVMean += `<th>${e}</th>`;
                                        htmlBody_QDPOVMean += `<td>${QDPOVBrandMean_luciferX[i]}</td>`;
                                        htmlBody_QDPOVMean += `<td>${QDPOVBrandTop_luciferX[i]}%</td>`;
                                        htmlBody_QDPOVMean += `</tr>`;
                                    });
                                    $("#QDPOV_tbl > thead").empty().append(htmlHead_QDPOVMean);
                                    $("#QDPOV_tbl > tbody").empty().append(htmlBody_QDPOVMean);
                                }
                            //QDPOV

                            //QDPL
                                if(QDPLBrand.length===0)
                                {
                                    $("#qdpl_1_meanbrand").empty().append(`<h6 class="blank_msg" >No Data to Preview</h6>`);
                                    $("#qdpl_1_topbrand").empty().append(`<h6 class="blank_msg" >No Data to Preview</h6>`);
                                    $("#qdpl_2_meanbrand").empty().append(`<h6 class="blank_msg" >No Data to Preview</h6>`);
                                    $("#qdpl_2_topbrand").empty().append(`<h6 class="blank_msg" >No Data to Preview</h6>`);
                                    $("#qdpl_3_meanbrand").empty().append(`<h6 class="blank_msg" >No Data to Preview</h6>`);
                                    $("#qdpl_3_topbrand").empty().append(`<h6 class="blank_msg" >No Data to Preview</h6>`);
                                    $("#qdpl_4_meanbrand").empty().append(`<h6 class="blank_msg" >No Data to Preview</h6>`);
                                    $("#qdpl_4_topbrand").empty().append(`<h6 class="blank_msg" >No Data to Preview</h6>`);
                                    $("#qdpl_5_meanbrand").empty().append(`<h6 class="blank_msg" >No Data to Preview</h6>`);
                                    $("#qdpl_5_topbrand").empty().append(`<h6 class="blank_msg" >No Data to Preview</h6>`);
                                    $("#qdpl_6_meanbrand").empty().append(`<h6 class="blank_msg" >No Data to Preview</h6>`);
                                    $("#qdpl_6_topbrand").empty().append(`<h6 class="blank_msg" >No Data to Preview</h6>`);

                                    $("#QDPL_1_tbl > thead").empty();
                                    $("#QDPL_1_tbl > tbody").empty().append(`<h6 class="blank_msg" >No Data to Preview</h6>`);

                                    $("#QDPL_2_tbl > thead").empty();
                                    $("#QDPL_2_tbl > tbody").empty().append(`<h6 class="blank_msg" >No Data to Preview</h6>`);

                                    $("#QDPL_3_tbl > thead").empty();
                                    $("#QDPL_3_tbl > tbody").empty().append(`<h6 class="blank_msg" >No Data to Preview</h6>`);

                                    $("#QDPL_4_tbl > thead").empty();
                                    $("#QDPL_4_tbl > tbody").empty().append(`<h6 class="blank_msg" >No Data to Preview</h6>`);

                                    $("#QDPL_5_tbl > thead").empty();
                                    $("#QDPL_5_tbl > tbody").empty().append(`<h6 class="blank_msg" >No Data to Preview</h6>`);

                                    $("#QDPL_6_tbl > thead").empty();
                                    $("#QDPL_6_tbl > tbody").empty().append(`<h6 class="blank_msg" >No Data to Preview</h6>`);
                                }
                                else
                                {
                                    var QDPLBrand_1 = QDPLBrand[0];
                                    var QDPLBrand_2 = QDPLBrand[1];
                                    var QDPLBrand_3 = QDPLBrand[2];
                                    var QDPLBrand_4 = QDPLBrand[3];
                                    var QDPLBrand_5 = QDPLBrand[4];
                                    var QDPLBrand_6 = QDPLBrand[5];

                                    var QDPLBrand_1_transposeData = QDPLBrand_1[0].map((col, i) => QDPLBrand_1.map(row => row[i]));
                                    var QDPLBrand_1_Mean_luciferX = QDPLBrand_1_transposeData[0];
                                    var QDPLBrand_1_Top_luciferX = QDPLBrand_1_transposeData[1];

                                    var QDPLBrand_1_Mean_lucifer = [{
                                        name: 'Mean Score',
                                        color:'#6190E6',
                                        data: QDPLBrand_1_Mean_luciferX,
                                    }];
                                    var QDPLBrand_1_Top_lucifer = [{
                                        name: 'Top 2 Score',
                                        color:'#0066CC',
                                        data: QDPLBrand_1_Top_luciferX,
                                    }];

                                    var QDPLBrand_2_transposeData = QDPLBrand_2[0].map((col, i) => QDPLBrand_2.map(row => row[i]));
                                    var QDPLBrand_2_Mean_luciferX = QDPLBrand_2_transposeData[0];
                                    var QDPLBrand_2_Top_luciferX = QDPLBrand_2_transposeData[1];

                                    var QDPLBrand_2_Mean_lucifer = [{
                                        name: 'Mean Score',
                                        color:'#6190E6',
                                        data: QDPLBrand_2_Mean_luciferX,
                                    }];
                                    var QDPLBrand_2_Top_lucifer = [{
                                        name: 'Top 2 Score',
                                        color:'#0066CC',
                                        data: QDPLBrand_2_Top_luciferX,
                                    }];

                                    var QDPLBrand_3_transposeData = QDPLBrand_3[0].map((col, i) => QDPLBrand_3.map(row => row[i]));
                                    var QDPLBrand_3_Mean_luciferX = QDPLBrand_3_transposeData[0];
                                    var QDPLBrand_3_Top_luciferX = QDPLBrand_3_transposeData[1];

                                    var QDPLBrand_3_Mean_lucifer = [{
                                        name: 'Mean Score',
                                        color:'#6190E6',
                                        data: QDPLBrand_3_Mean_luciferX,
                                    }];
                                    var QDPLBrand_3_Top_lucifer = [{
                                        name: 'Top 2 Score',
                                        color:'#0066CC',
                                        data: QDPLBrand_3_Top_luciferX,
                                    }];

                                    var QDPLBrand_4_transposeData = QDPLBrand_4[0].map((col, i) => QDPLBrand_4.map(row => row[i]));
                                    var QDPLBrand_4_Mean_luciferX = QDPLBrand_4_transposeData[0];
                                    var QDPLBrand_4_Top_luciferX = QDPLBrand_4_transposeData[1];

                                    var QDPLBrand_4_Mean_lucifer = [{
                                        name: 'Mean Score',
                                        color:'#6190E6',
                                        data: QDPLBrand_4_Mean_luciferX,
                                    }];
                                    var QDPLBrand_4_Top_lucifer = [{
                                        name: 'Top 2 Score',
                                        color:'#0066CC',
                                        data: QDPLBrand_4_Top_luciferX,
                                    }];

                                    var QDPLBrand_5_transposeData = QDPLBrand_5[0].map((col, i) => QDPLBrand_5.map(row => row[i]));
                                    var QDPLBrand_5_Mean_luciferX = QDPLBrand_5_transposeData[0];
                                    var QDPLBrand_5_Top_luciferX = QDPLBrand_5_transposeData[1];

                                    var QDPLBrand_5_Mean_lucifer = [{
                                        name: 'Mean Score',
                                        color:'#6190E6',
                                        data: QDPLBrand_5_Mean_luciferX,
                                    }];
                                    var QDPLBrand_5_Top_lucifer = [{
                                        name: 'Top 2 Score',
                                        color:'#0066CC',
                                        data: QDPLBrand_5_Top_luciferX,
                                    }];

                                    var QDPLBrand_6_transposeData = QDPLBrand_6[0].map((col, i) => QDPLBrand_6.map(row => row[i]));
                                    var QDPLBrand_6_Mean_luciferX = QDPLBrand_6_transposeData[0];
                                    var QDPLBrand_6_Top_luciferX = QDPLBrand_6_transposeData[1];

                                    var QDPLBrand_6_Mean_lucifer = [{
                                        name: 'Mean Score',
                                        color:'#6190E6',
                                        data: QDPLBrand_6_Mean_luciferX,
                                    }];
                                    var QDPLBrand_6_Top_lucifer = [{
                                        name: 'Top 2 Score',
                                        color:'#0066CC',
                                        data: QDPLBrand_6_Top_luciferX,
                                    }];


                                    
                                    var htmlHead_QDPL_1Mean = ``;
                                    htmlHead_QDPL_1Mean += `<tr style="display:none"><th>Timeliness of completing the final delivery</th></tr>`;
                                    htmlHead_QDPL_1Mean += `<tr>`;
                                    tblHeadType_1.forEach(function(e,i,a){
                                        htmlHead_QDPL_1Mean += `<th>${e}</th>`;
                                    });
                                    htmlHead_QDPL_1Mean += `</tr>`;
                                    var htmlBody_QDPL_1Mean = ``;
                                    QDPLABELLBrand[0].forEach(function(e,i,a){
                                        htmlBody_QDPL_1Mean += `<tr>`;
                                        htmlBody_QDPL_1Mean += `<th>${e}</th>`;
                                        htmlBody_QDPL_1Mean += `<td>${QDPLBrand_1_Mean_luciferX[i]}</td>`;
                                        htmlBody_QDPL_1Mean += `<td>${QDPLBrand_1_Top_luciferX[i]}%</td>`;
                                        htmlBody_QDPL_1Mean += `</tr>`;
                                    });
                                    $("#QDPL_1_tbl > thead").empty().append(htmlHead_QDPL_1Mean);
                                    $("#QDPL_1_tbl > tbody").empty().append(htmlBody_QDPL_1Mean);

                                    var htmlHead_QDPL_2Mean = ``;
                                    htmlHead_QDPL_2Mean += `<tr style="display:none"><th>Condition of your vehicle</th></tr>`;
                                    htmlHead_QDPL_2Mean += `<tr>`;
                                    tblHeadType_1.forEach(function(e,i,a){
                                        htmlHead_QDPL_2Mean += `<th>${e}</th>`;
                                    });
                                    htmlHead_QDPL_2Mean += `</tr>`;
                                    var htmlBody_QDPL_2Mean = ``;
                                    QDPLABELLBrand[1].forEach(function(e,i,a){
                                        htmlBody_QDPL_2Mean += `<tr>`;
                                        htmlBody_QDPL_2Mean += `<th>${e}</th>`;
                                        htmlBody_QDPL_2Mean += `<td>${QDPLBrand_2_Mean_luciferX[i]}</td>`;
                                        htmlBody_QDPL_2Mean += `<td>${QDPLBrand_2_Top_luciferX[i]}%</td>`;
                                        htmlBody_QDPL_2Mean += `</tr>`;
                                    });
                                    $("#QDPL_2_tbl > thead").empty().append(htmlHead_QDPL_2Mean);
                                    $("#QDPL_2_tbl > tbody").empty().append(htmlBody_QDPL_2Mean);


                                    var htmlHead_QDPL_3Mean = ``;
                                    htmlHead_QDPL_3Mean += `<tr style="display:none"><th>Experience of purchasing related products</th></tr>`;
                                    htmlHead_QDPL_3Mean += `<tr>`;
                                    tblHeadType_1.forEach(function(e,i,a){
                                        htmlHead_QDPL_3Mean += `<th>${e}</th>`;
                                    });
                                    htmlHead_QDPL_3Mean += `</tr>`;
                                    var htmlBody_QDPL_3Mean = ``;
                                    QDPLABELLBrand[2].forEach(function(e,i,a){
                                        htmlBody_QDPL_3Mean += `<tr>`;
                                        htmlBody_QDPL_3Mean += `<th>${e}</th>`;
                                        htmlBody_QDPL_3Mean += `<td>${QDPLBrand_3_Mean_luciferX[i]}</td>`;
                                        htmlBody_QDPL_3Mean += `<td>${QDPLBrand_3_Top_luciferX[i]}%</td>`;
                                        htmlBody_QDPL_3Mean += `</tr>`;
                                    });
                                    $("#QDPL_3_tbl > thead").empty().append(htmlHead_QDPL_3Mean);
                                    $("#QDPL_3_tbl > tbody").empty().append(htmlBody_QDPL_3Mean);

                                    var htmlHead_QDPL_4Mean = ``;
                                    htmlHead_QDPL_4Mean += `<tr style="display:none"><th>Delivery ceremony</th></tr>`;
                                    htmlHead_QDPL_4Mean += `<tr>`;
                                    tblHeadType_1.forEach(function(e,i,a){
                                        htmlHead_QDPL_4Mean += `<th>${e}</th>`;
                                    });
                                    htmlHead_QDPL_4Mean += `</tr>`;
                                    var htmlBody_QDPL_4Mean = ``;
                                    QDPLABELLBrand[3].forEach(function(e,i,a){
                                        htmlBody_QDPL_4Mean += `<tr>`;
                                        htmlBody_QDPL_4Mean += `<th>${e}</th>`;
                                        htmlBody_QDPL_4Mean += `<td>${QDPLBrand_4_Mean_luciferX[i]}</td>`;
                                        htmlBody_QDPL_4Mean += `<td>${QDPLBrand_4_Top_luciferX[i]}%</td>`;
                                        htmlBody_QDPL_4Mean += `</tr>`;
                                    });
                                    $("#QDPL_4_tbl > thead").empty().append(htmlHead_QDPL_4Mean);
                                    $("#QDPL_4_tbl > tbody").empty().append(htmlBody_QDPL_4Mean);


                                    var htmlHead_QDPL_5Mean = ``;
                                    htmlHead_QDPL_5Mean += `<tr style="display:none"><th>Dealership staff on their preparedness and enthusiasm</th></tr>`;
                                    htmlHead_QDPL_5Mean += `<tr>`;
                                    tblHeadType_1.forEach(function(e,i,a){
                                        htmlHead_QDPL_5Mean += `<th>${e}</th>`;
                                    });
                                    htmlHead_QDPL_5Mean += `</tr>`;
                                    var htmlBody_QDPL_5Mean = ``;
                                    QDPLABELLBrand[4].forEach(function(e,i,a){
                                        htmlBody_QDPL_5Mean += `<tr>`;
                                        htmlBody_QDPL_5Mean += `<th>${e}</th>`;
                                        htmlBody_QDPL_5Mean += `<td>${QDPLBrand_5_Mean_luciferX[i]}</td>`;
                                        htmlBody_QDPL_5Mean += `<td>${QDPLBrand_5_Top_luciferX[i]}%</td>`;
                                        htmlBody_QDPL_5Mean += `</tr>`;
                                    });
                                    $("#QDPL_5_tbl > thead").empty().append(htmlHead_QDPL_5Mean);
                                    $("#QDPL_5_tbl > tbody").empty().append(htmlBody_QDPL_5Mean);


                                    var htmlHead_QDPL_6Mean = ``;
                                    htmlHead_QDPL_6Mean += `<tr style="display:none"><th>Thoroughness of explanations</th></tr>`;
                                    htmlHead_QDPL_6Mean += `<tr>`;
                                    tblHeadType_1.forEach(function(e,i,a){
                                        htmlHead_QDPL_6Mean += `<th>${e}</th>`;
                                    });
                                    htmlHead_QDPL_6Mean += `</tr>`;
                                    var htmlBody_QDPL_6Mean = ``;
                                    QDPLABELLBrand[5].forEach(function(e,i,a){
                                        htmlBody_QDPL_6Mean += `<tr>`;
                                        htmlBody_QDPL_6Mean += `<th>${e}</th>`;
                                        htmlBody_QDPL_6Mean += `<td>${QDPLBrand_6_Mean_luciferX[i]}</td>`;
                                        htmlBody_QDPL_6Mean += `<td>${QDPLBrand_6_Top_luciferX[i]}%</td>`;
                                        htmlBody_QDPL_6Mean += `</tr>`;
                                    });
                                    $("#QDPL_6_tbl > thead").empty().append(htmlHead_QDPL_6Mean);
                                    $("#QDPL_6_tbl > tbody").empty().append(htmlBody_QDPL_6Mean);
                                }
                                
                            //QDPL

                            //QDP1DBrand
                                if(QDP1DBrand.length===0)
                                {
                                    $("#qdpd_1brand").empty().append(`<h6 class="blank_msg" >No Data to Preview</h6>`);
                                    
                                    $("#QDPD_1tbl > thead").empty();
                                    $("#QDPD_1tbl > tbody").empty().append(`<h6 class="blank_msg" >No Data to Preview</h6>`);
                                }
                                else
                                {
                                    var QDPD_0Brand_Lucifer = Object.assign(QDP1DBrand.map(function(element, index) {
                                        return {
                                            ['name']: QDPD1Label[index],
                                            ['color']: fourcolor[index],
                                            ['data']: element
                                        };
                                    }));

                                    
                                    var htmlHead_QDP1D_Mean = ``;
                                    htmlHead_QDP1D_Mean += `<tr style="display:none"><th>Took delivery of your vehicle</th></tr>`;
                                    htmlHead_QDP1D_Mean += `<tr>`;
                                    htmlHead_QDP1D_Mean += `<th>Brand</th>`;
                                    QDPD1Label.forEach(function(e,i,a){
                                        htmlHead_QDP1D_Mean += `<th>${e}</th>`;
                                    });
                                    htmlHead_QDP1D_Mean += `</tr>`;
                                    var htmlBody_QDP1D_Mean = ``;
                                    QDP1DLABELBrand[0].forEach(function(e,i,a){
                                        htmlBody_QDP1D_Mean += `<tr>`;
                                        htmlBody_QDP1D_Mean += `<th>${e}</th>`;
                                        QDP1DBrand.forEach(function(e2,i2,a2){
                                            htmlBody_QDP1D_Mean += `<td>${e2[i]}%</td>`;
                                        });
                                        htmlBody_QDP1D_Mean += `</tr>`;
                                    });
                                    $("#QDPD_1tbl > thead").empty().append(htmlHead_QDP1D_Mean);
                                    $("#QDPD_1tbl > tbody").empty().append(htmlBody_QDP1D_Mean);
                                }
                            //QDP1DBrand

                            //QDPD
                                if(QDPDBrand.length===0)
                                {
                                    $("#qdpd_2brand").empty().append(`<h6 class="blank_msg" >No Data to Preview</h6>`);
                                    $("#qdpd_3brand").empty().append(`<h6 class="blank_msg" >No Data to Preview</h6>`);
                                    $("#qdpd_4brand").empty().append(`<h6 class="blank_msg" >No Data to Preview</h6>`);
                                    $("#qdpd_5brand").empty().append(`<h6 class="blank_msg" >No Data to Preview</h6>`);
                                    $("#qdpd_6brand").empty().append(`<h6 class="blank_msg" >No Data to Preview</h6>`);
                                    $("#qdpd_7brand").empty().append(`<h6 class="blank_msg" >No Data to Preview</h6>`);
                                    
                                    $("#QDPD_2tbl > thead").empty();
                                    $("#QDPD_2tbl > tbody").empty().append(`<h6 class="blank_msg" >No Data to Preview</h6>`);
                                    $("#QDPD_3tbl > thead").empty();
                                    $("#QDPD_3tbl > tbody").empty().append(`<h6 class="blank_msg" >No Data to Preview</h6>`);
                                    $("#QDPD_4tbl > thead").empty();
                                    $("#QDPD_4tbl > tbody").empty().append(`<h6 class="blank_msg" >No Data to Preview</h6>`);
                                    $("#QDPD_5tbl > thead").empty();
                                    $("#QDPD_5tbl > tbody").empty().append(`<h6 class="blank_msg" >No Data to Preview</h6>`);
                                    $("#QDPD_6tbl > thead").empty();
                                    $("#QDPD_6tbl > tbody").empty().append(`<h6 class="blank_msg" >No Data to Preview</h6>`);
                                    $("#QDPD_7tbl > thead").empty();
                                    $("#QDPD_7tbl > tbody").empty().append(`<h6 class="blank_msg" >No Data to Preview</h6>`);
                                }
                                else
                                {
                                    var QDPD_1Brand_LuciferX = QDPDBrand[0];
                                    var QDPD_2Brand_LuciferX = QDPDBrand[1];
                                    var QDPD_3Brand_LuciferX = QDPDBrand[2];
                                    var QDPD_4Brand_LuciferX = QDPDBrand[3];
                                    var QDPD_5Brand_LuciferX = QDPDBrand[4];
                                    var QDPD_6Brand_LuciferX = QDPDBrand[5];

                                    var QDPD_1Brand_transposeLuciferX = QDPD_1Brand_LuciferX[0].map((col, i) => QDPD_1Brand_LuciferX.map(row => row[i]));
                                    var QDPD_1Brand_Lucifer = Object.assign(QDPD_1Brand_transposeLuciferX.map(function(element, index) {
                                        return {
                                            ['name']: QFIX1Label[index],
                                            ['color']: yesnocolor[index],
                                            ['data']: element
                                        };
                                    }));

                                    var QDPD_2Brand_transposeLuciferX = QDPD_2Brand_LuciferX[0].map((col, i) => QDPD_2Brand_LuciferX.map(row => row[i]));
                                    var QDPD_2Brand_Lucifer = Object.assign(QDPD_2Brand_transposeLuciferX.map(function(element, index) {
                                        return {
                                            ['name']: QFIX1Label[index],
                                            ['color']: yesnocolor[index],
                                            ['data']: element
                                        };
                                    }));

                                    var QDPD_3Brand_transposeLuciferX = QDPD_3Brand_LuciferX[0].map((col, i) => QDPD_3Brand_LuciferX.map(row => row[i]));
                                    var QDPD_3Brand_Lucifer = Object.assign(QDPD_3Brand_transposeLuciferX.map(function(element, index) {
                                        return {
                                            ['name']: QFIX1Label[index],
                                            ['color']: yesnocolor[index],
                                            ['data']: element
                                        };
                                    }));

                                    var QDPD_4Brand_transposeLuciferX = QDPD_4Brand_LuciferX[0].map((col, i) => QDPD_4Brand_LuciferX.map(row => row[i]));
                                    var QDPD_4Brand_Lucifer = Object.assign(QDPD_4Brand_transposeLuciferX.map(function(element, index) {
                                        return {
                                            ['name']: QFIX1Label[index],
                                            ['color']: yesnocolor[index],
                                            ['data']: element
                                        };
                                    }));

                                    var QDPD_5Brand_transposeLuciferX = QDPD_5Brand_LuciferX[0].map((col, i) => QDPD_5Brand_LuciferX.map(row => row[i]));
                                    var QDPD_5Brand_Lucifer = Object.assign(QDPD_5Brand_transposeLuciferX.map(function(element, index) {
                                        return {
                                            ['name']: QFIX1Label[index],
                                            ['color']: yesnocolor[index],
                                            ['data']: element
                                        };
                                    }));

                                    var QDPD_6Brand_transposeLuciferX = QDPD_6Brand_LuciferX[0].map((col, i) => QDPD_6Brand_LuciferX.map(row => row[i]));
                                    var QDPD_6Brand_Lucifer = Object.assign(QDPD_6Brand_transposeLuciferX.map(function(element, index) {
                                        return {
                                            ['name']: QFIX1Label[index],
                                            ['color']: yesnocolor[index],
                                            ['data']: element
                                        };
                                    }));


                                    
                                    var htmlHead_QDPD_2Mean = ``;
                                    htmlHead_QDPD_2Mean += `<tr style="display:none"><th>Introduced to the Service Facility</th></tr>`;
                                    htmlHead_QDPD_2Mean += `<tr>`;
                                    tblHeadType_3.forEach(function(e,i,a){
                                        htmlHead_QDPD_2Mean += `<th>${e}</th>`;
                                    });
                                    htmlHead_QDPD_2Mean += `</tr>`;
                                    var htmlBody_QDPD_2Mean = ``;
                                    QDPDLABELBrand[0].forEach(function(e,i,a){
                                        htmlBody_QDPD_2Mean += `<tr>`;
                                        htmlBody_QDPD_2Mean += `<th>${e}</th>`;
                                        htmlBody_QDPD_2Mean += `<td>${QDPD_1Brand_transposeLuciferX[0][i]}%</td>`;
                                        htmlBody_QDPD_2Mean += `</tr>`;
                                    });
                                    $("#QDPD_2tbl > thead").empty().append(htmlHead_QDPD_2Mean);
                                    $("#QDPD_2tbl > tbody").empty().append(htmlBody_QDPD_2Mean);

                                    var htmlHead_QDPD_3Mean = ``;
                                    htmlHead_QDPD_3Mean += `<tr style="display:none"><th>Your car delivered at your convenient place</th></tr>`;
                                    htmlHead_QDPD_3Mean += `<tr>`;
                                    tblHeadType_3.forEach(function(e,i,a){
                                        htmlHead_QDPD_3Mean += `<th>${e}</th>`;
                                    });
                                    htmlHead_QDPD_3Mean += `</tr>`;
                                    var htmlBody_QDPD_3Mean = ``;
                                    QDPDLABELBrand[1].forEach(function(e,i,a){
                                        htmlBody_QDPD_3Mean += `<tr>`;
                                        htmlBody_QDPD_3Mean += `<th>${e}</th>`;
                                        htmlBody_QDPD_3Mean += `<td>${QDPD_2Brand_transposeLuciferX[0][i]}%</td>`;
                                        htmlBody_QDPD_3Mean += `</tr>`;
                                    });
                                    $("#QDPD_3tbl > thead").empty().append(htmlHead_QDPD_3Mean);
                                    $("#QDPD_3tbl > tbody").empty().append(htmlBody_QDPD_3Mean);


                                    var htmlHead_QDPD_4Mean = ``;
                                    htmlHead_QDPD_4Mean += `<tr style="display:none"><th>Your car delivered at promised date and time</th></tr>`;
                                    htmlHead_QDPD_4Mean += `<tr>`;
                                    tblHeadType_3.forEach(function(e,i,a){
                                        htmlHead_QDPD_4Mean += `<th>${e}</th>`;
                                    });
                                    htmlHead_QDPD_4Mean += `</tr>`;
                                    var htmlBody_QDPD_4Mean = ``;
                                    QDPDLABELBrand[2].forEach(function(e,i,a){
                                        htmlBody_QDPD_4Mean += `<tr>`;
                                        htmlBody_QDPD_4Mean += `<th>${e}</th>`;
                                        htmlBody_QDPD_4Mean += `<td>${QDPD_3Brand_transposeLuciferX[0][i]}%</td>`;
                                        htmlBody_QDPD_4Mean += `</tr>`;
                                    });
                                    $("#QDPD_4tbl > thead").empty().append(htmlHead_QDPD_4Mean);
                                    $("#QDPD_4tbl > tbody").empty().append(htmlBody_QDPD_4Mean);

                                    var htmlHead_QDPD_5Mean = ``;
                                    htmlHead_QDPD_5Mean += `<tr style="display:none"><th>Received all the necessary sales documents</th></tr>`;
                                    htmlHead_QDPD_5Mean += `<tr>`;
                                    tblHeadType_3.forEach(function(e,i,a){
                                        htmlHead_QDPD_5Mean += `<th>${e}</th>`;
                                    });
                                    htmlHead_QDPD_5Mean += `</tr>`;
                                    var htmlBody_QDPD_5Mean = ``;
                                    QDPDLABELBrand[3].forEach(function(e,i,a){
                                        htmlBody_QDPD_5Mean += `<tr>`;
                                        htmlBody_QDPD_5Mean += `<th>${e}</th>`;
                                        htmlBody_QDPD_5Mean += `<td>${QDPD_4Brand_transposeLuciferX[0][i]}%</td>`;
                                        htmlBody_QDPD_5Mean += `</tr>`;
                                    });
                                    $("#QDPD_5tbl > thead").empty().append(htmlHead_QDPD_5Mean);
                                    $("#QDPD_5tbl > tbody").empty().append(htmlBody_QDPD_5Mean);


                                    var htmlHead_QDPD_6Mean = ``;
                                    htmlHead_QDPD_6Mean += `<tr style="display:none"><th>Delivery Ceremony Done at the time of delivery</th></tr>`;
                                    htmlHead_QDPD_6Mean += `<tr>`;
                                    tblHeadType_3.forEach(function(e,i,a){
                                        htmlHead_QDPD_6Mean += `<th>${e}</th>`;
                                    });
                                    htmlHead_QDPD_6Mean += `</tr>`;
                                    var htmlBody_QDPD_6Mean = ``;
                                    QDPDLABELBrand[4].forEach(function(e,i,a){
                                        htmlBody_QDPD_6Mean += `<tr>`;
                                        htmlBody_QDPD_6Mean += `<th>${e}</th>`;
                                        htmlBody_QDPD_6Mean += `<td>${QDPD_5Brand_transposeLuciferX[0][i]}%</td>`;
                                        htmlBody_QDPD_6Mean += `</tr>`;
                                    });
                                    $("#QDPD_6tbl > thead").empty().append(htmlHead_QDPD_6Mean);
                                    $("#QDPD_6tbl > tbody").empty().append(htmlBody_QDPD_6Mean);


                                    var htmlHead_QDPD_7Mean = ``;
                                    htmlHead_QDPD_7Mean += `<tr style="display:none"><th>Pro-actively keep you informed of delivery status</th></tr>`;
                                    htmlHead_QDPD_7Mean += `<tr>`;
                                    tblHeadType_3.forEach(function(e,i,a){
                                        htmlHead_QDPD_7Mean += `<th>${e}</th>`;
                                    });
                                    htmlHead_QDPD_7Mean += `</tr>`;
                                    var htmlBody_QDPD_7Mean = ``;
                                    QDPDLABELBrand[5].forEach(function(e,i,a){
                                        htmlBody_QDPD_7Mean += `<tr>`;
                                        htmlBody_QDPD_7Mean += `<th>${e}</th>`;
                                        htmlBody_QDPD_7Mean += `<td>${QDPD_6Brand_transposeLuciferX[0][i]}%</td>`;
                                        htmlBody_QDPD_7Mean += `</tr>`;
                                    });
                                    $("#QDPD_7tbl > thead").empty().append(htmlHead_QDPD_7Mean);
                                    $("#QDPD_7tbl > tbody").empty().append(htmlBody_QDPD_7Mean);
                                }
                            //QDPD
                        }
                        else
                        {
                            $("#qdpov_meanbrand").empty().append(`<h6 class="blank_msg" >No Data to Preview</h6>`);
                            $("#qdpov_topbrand").empty().append(`<h6 class="blank_msg" >No Data to Preview</h6>`);
                            $("#qdpl_1_meanbrand").empty().append(`<h6 class="blank_msg" >No Data to Preview</h6>`);
                            $("#qdpl_1_topbrand").empty().append(`<h6 class="blank_msg" >No Data to Preview</h6>`);
                            $("#qdpl_2_meanbrand").empty().append(`<h6 class="blank_msg" >No Data to Preview</h6>`);
                            $("#qdpl_2_topbrand").empty().append(`<h6 class="blank_msg" >No Data to Preview</h6>`);
                            $("#qdpl_3_meanbrand").empty().append(`<h6 class="blank_msg" >No Data to Preview</h6>`);
                            $("#qdpl_3_topbrand").empty().append(`<h6 class="blank_msg" >No Data to Preview</h6>`);
                            $("#qdpl_4_meanbrand").empty().append(`<h6 class="blank_msg" >No Data to Preview</h6>`);
                            $("#qdpl_4_topbrand").empty().append(`<h6 class="blank_msg" >No Data to Preview</h6>`);
                            $("#qdpl_5_meanbrand").empty().append(`<h6 class="blank_msg" >No Data to Preview</h6>`);
                            $("#qdpl_5_topbrand").empty().append(`<h6 class="blank_msg" >No Data to Preview</h6>`);
                            $("#qdpl_6_meanbrand").empty().append(`<h6 class="blank_msg" >No Data to Preview</h6>`);
                            $("#qdpl_6_topbrand").empty().append(`<h6 class="blank_msg" >No Data to Preview</h6>`);
                            
                            $("#qdpd_1brand").empty().append(`<h6 class="blank_msg" >No Data to Preview</h6>`);
                            $("#qdpd_2brand").empty().append(`<h6 class="blank_msg" >No Data to Preview</h6>`);
                            $("#qdpd_3brand").empty().append(`<h6 class="blank_msg" >No Data to Preview</h6>`);
                            $("#qdpd_4brand").empty().append(`<h6 class="blank_msg" >No Data to Preview</h6>`);
                            $("#qdpd_5brand").empty().append(`<h6 class="blank_msg" >No Data to Preview</h6>`);
                            $("#qdpd_6brand").empty().append(`<h6 class="blank_msg" >No Data to Preview</h6>`);
                            $("#qdpd_7brand").empty().append(`<h6 class="blank_msg" >No Data to Preview</h6>`);


                            $("#QDPOV_tbl > thead").empty();
                            $("#QDPOV_tbl > tbody").empty().append(`<h6 class="blank_msg" >No Data to Preview</h6>`);
                            
                            $("#QDPL_1_tbl > thead").empty();
                            $("#QDPL_1_tbl > tbody").empty().append(`<h6 class="blank_msg" >No Data to Preview</h6>`);

                            $("#QDPL_2_tbl > thead").empty();
                            $("#QDPL_2_tbl > tbody").empty().append(`<h6 class="blank_msg" >No Data to Preview</h6>`);

                            $("#QDPL_3_tbl > thead").empty();
                            $("#QDPL_3_tbl > tbody").empty().append(`<h6 class="blank_msg" >No Data to Preview</h6>`);

                            $("#QDPL_4_tbl > thead").empty();
                            $("#QDPL_4_tbl > tbody").empty().append(`<h6 class="blank_msg" >No Data to Preview</h6>`);

                            $("#QDPL_5_tbl > thead").empty();
                            $("#QDPL_5_tbl > tbody").empty().append(`<h6 class="blank_msg" >No Data to Preview</h6>`);

                            $("#QDPL_6_tbl > thead").empty();
                            $("#QDPL_6_tbl > tbody").empty().append(`<h6 class="blank_msg" >No Data to Preview</h6>`);

                            $("#QDPD_1tbl > thead").empty();
                            $("#QDPD_1tbl > tbody").empty().append(`<h6 class="blank_msg" >No Data to Preview</h6>`);
                            $("#QDPD_2tbl > thead").empty();
                            $("#QDPD_2tbl > tbody").empty().append(`<h6 class="blank_msg" >No Data to Preview</h6>`);
                            $("#QDPD_3tbl > thead").empty();
                            $("#QDPD_3tbl > tbody").empty().append(`<h6 class="blank_msg" >No Data to Preview</h6>`);
                            $("#QDPD_4tbl > thead").empty();
                            $("#QDPD_4tbl > tbody").empty().append(`<h6 class="blank_msg" >No Data to Preview</h6>`);
                            $("#QDPD_5tbl > thead").empty();
                            $("#QDPD_5tbl > tbody").empty().append(`<h6 class="blank_msg" >No Data to Preview</h6>`);
                            $("#QDPD_6tbl > thead").empty();
                            $("#QDPD_6tbl > tbody").empty().append(`<h6 class="blank_msg" >No Data to Preview</h6>`);
                            $("#QDPD_7tbl > thead").empty();
                            $("#QDPD_7tbl > tbody").empty().append(`<h6 class="blank_msg" >No Data to Preview</h6>`);
                            
                        }
                    },
                    complete: function (data) 
                    {
                        ajaxFlag[7] = true;
                        if(excelStatus===true)
                        {
                            checkAjaxCompletion()
                        }
                    }
                });
            }

            function ninthAjax()
            {
                $.ajax({
                    url: "api/ajax9.php",
                    type: "POST",
                    data: {
                        'condX' : condX,
                        'conX' : conX,
                        'oemVal' : oemVal
                    },
                    success: function(response) {
                        var data = JSON.parse(response);
                        var QPJBrand = data['QPJ'];
                        var QPJLBrand = QPJBrand[0];
                        var QPJOVBrand = QPJBrand[1];

                        var QPJLABELLBrand = data['QPJL'];
                        var QPJLABELOVBrand = data['QPJOVERALLL'];

                        if(overallBase!=0)
                        {
                            //QPJOV
                                if(QPJOVBrand.length===0)
                                {
                                    $("#qpjov_meanbrand").empty().append(`<h6 class="blank_msg" >No Data to Preview</h6>`);
                                    $("#qpjov_topbrand").empty().append(`<h6 class="blank_msg" >No Data to Preview</h6>`);

                                    $("#QPJOV_tbl > thead").empty();
                                    $("#QPJOV_tbl > tbody").empty().append(`<h6 class="blank_msg" >No Data to Preview</h6>`);
                                }
                                else
                                {
                                    var QPJOVBrand_transposeData = QPJOVBrand[0].map((col, i) => QPJOVBrand.map(row => row[i]));
                                    var QPJOVBrandMean_luciferX = QPJOVBrand_transposeData[0];
                                    var QPJOVBrandTop_luciferX = QPJOVBrand_transposeData[1];

                                    var QPJOVBrandMean_lucifer = [{
                                        name: 'Mean Score',
                                        color:'#6190E6',
                                        data: QPJOVBrandMean_luciferX,
                                    }];
                                    var QPJOVBrandTop_lucifer = [{
                                        name: 'Top 2 Score',
                                        color:'#0066CC',
                                        data: QPJOVBrandTop_luciferX,
                                    }];

                                    
                                    var htmlHead_QPJOVMean = ``;
                                    htmlHead_QPJOVMean += `<tr style="display:none"><th>Sample Size: ${overallBase}</th></tr>`;
                                    htmlHead_QPJOVMean += `<tr style="display:none"><th>${filtercondX}</th></tr>`;
                                    htmlHead_QPJOVMean += `<tr style="display:none"><th>Overall Post Sales Experience</th></tr>`;
                                    htmlHead_QPJOVMean += `<tr>`;
                                    tblHeadType_1.forEach(function(e,i,a){
                                        htmlHead_QPJOVMean += `<th>${e}</th>`;
                                    });
                                    htmlHead_QPJOVMean += `</tr>`;
                                    var htmlBody_QPJOVMean = ``;
                                    QPJLABELOVBrand.forEach(function(e,i,a){
                                        htmlBody_QPJOVMean += `<tr>`;
                                        htmlBody_QPJOVMean += `<th>${e}</th>`;
                                        htmlBody_QPJOVMean += `<td>${QPJOVBrandMean_luciferX[i]}</td>`;
                                        htmlBody_QPJOVMean += `<td>${QPJOVBrandTop_luciferX[i]}%</td>`;
                                        htmlBody_QPJOVMean += `</tr>`;
                                    });
                                    $("#QPJOV_tbl > thead").empty().append(htmlHead_QPJOVMean);
                                    $("#QPJOV_tbl > tbody").empty().append(htmlBody_QPJOVMean);
                                }
                            //QPJOV

                            //QPJL
                                if(QPJLBrand.length===0)
                                {
                                    $("#qpjl_1_meanbrand").empty().append(`<h6 class="blank_msg" >No Data to Preview</h6>`);
                                    $("#qpjl_1_topbrand").empty().append(`<h6 class="blank_msg" >No Data to Preview</h6>`);
                                    $("#qpjl_2_meanbrand").empty().append(`<h6 class="blank_msg" >No Data to Preview</h6>`);
                                    $("#qpjl_2_topbrand").empty().append(`<h6 class="blank_msg" >No Data to Preview</h6>`);
                                    $("#qpjl_3_meanbrand").empty().append(`<h6 class="blank_msg" >No Data to Preview</h6>`);
                                    $("#qpjl_3_topbrand").empty().append(`<h6 class="blank_msg" >No Data to Preview</h6>`);
                                    $("#qpjl_4_meanbrand").empty().append(`<h6 class="blank_msg" >No Data to Preview</h6>`);
                                    $("#qpjl_4_topbrand").empty().append(`<h6 class="blank_msg" >No Data to Preview</h6>`);

                                    $("#QPJL_1_tbl > thead").empty();
                                    $("#QPJL_1_tbl > tbody").empty().append(`<h6 class="blank_msg" >No Data to Preview</h6>`);

                                    $("#QPJL_2_tbl > thead").empty();
                                    $("#QPJL_2_tbl > tbody").empty().append(`<h6 class="blank_msg" >No Data to Preview</h6>`);

                                    $("#QPJL_3_tbl > thead").empty();
                                    $("#QPJL_3_tbl > tbody").empty().append(`<h6 class="blank_msg" >No Data to Preview</h6>`);

                                    $("#QPJL_4_tbl > thead").empty();
                                    $("#QPJL_4_tbl > tbody").empty().append(`<h6 class="blank_msg" >No Data to Preview</h6>`);
                                }
                                else
                                {
                                    var QPJLBrand_1 = QPJLBrand[0];
                                    var QPJLBrand_2 = QPJLBrand[1];
                                    var QPJLBrand_3 = QPJLBrand[2];
                                    var QPJLBrand_4 = QPJLBrand[3];

                                    var QPJLBrand_1_transposeData = QPJLBrand_1[0].map((col, i) => QPJLBrand_1.map(row => row[i]));
                                    var QPJLBrand_1_Mean_luciferX = QPJLBrand_1_transposeData[0];
                                    var QPJLBrand_1_Top_luciferX = QPJLBrand_1_transposeData[1];

                                    var QPJLBrand_1_Mean_lucifer = [{
                                        name: 'Mean Score',
                                        color:'#6190E6',
                                        data: QPJLBrand_1_Mean_luciferX,
                                    }];
                                    var QPJLBrand_1_Top_lucifer = [{
                                        name: 'Top 2 Score',
                                        color:'#0066CC',
                                        data: QPJLBrand_1_Top_luciferX,
                                    }];

                                    var QPJLBrand_2_transposeData = QPJLBrand_2[0].map((col, i) => QPJLBrand_2.map(row => row[i]));
                                    var QPJLBrand_2_Mean_luciferX = QPJLBrand_2_transposeData[0];
                                    var QPJLBrand_2_Top_luciferX = QPJLBrand_2_transposeData[1];

                                    var QPJLBrand_2_Mean_lucifer = [{
                                        name: 'Mean Score',
                                        color:'#6190E6',
                                        data: QPJLBrand_2_Mean_luciferX,
                                    }];
                                    var QPJLBrand_2_Top_lucifer = [{
                                        name: 'Top 2 Score',
                                        color:'#0066CC',
                                        data: QPJLBrand_2_Top_luciferX,
                                    }];

                                    var QPJLBrand_3_transposeData = QPJLBrand_3[0].map((col, i) => QPJLBrand_3.map(row => row[i]));
                                    var QPJLBrand_3_Mean_luciferX = QPJLBrand_3_transposeData[0];
                                    var QPJLBrand_3_Top_luciferX = QPJLBrand_3_transposeData[1];

                                    var QPJLBrand_3_Mean_lucifer = [{
                                        name: 'Mean Score',
                                        color:'#6190E6',
                                        data: QPJLBrand_3_Mean_luciferX,
                                    }];
                                    var QPJLBrand_3_Top_lucifer = [{
                                        name: 'Top 2 Score',
                                        color:'#0066CC',
                                        data: QPJLBrand_3_Top_luciferX,
                                    }];

                                    var QPJLBrand_4_transposeData = QPJLBrand_4[0].map((col, i) => QPJLBrand_4.map(row => row[i]));
                                    var QPJLBrand_4_Mean_luciferX = QPJLBrand_4_transposeData[0];
                                    var QPJLBrand_4_Top_luciferX = QPJLBrand_4_transposeData[1];

                                    var QPJLBrand_4_Mean_lucifer = [{
                                        name: 'Mean Score',
                                        color:'#6190E6',
                                        data: QPJLBrand_4_Mean_luciferX,
                                    }];
                                    var QPJLBrand_4_Top_lucifer = [{
                                        name: 'Top 2 Score',
                                        color:'#0066CC',
                                        data: QPJLBrand_4_Top_luciferX,
                                    }];

                                    
                                    var htmlHead_QPJL_1Mean = ``;
                                    htmlHead_QPJL_1Mean += `<tr style="display:none"><th>Proactiveness in follow up</th></tr>`;
                                    htmlHead_QPJL_1Mean += `<tr>`;
                                    tblHeadType_1.forEach(function(e,i,a){
                                        htmlHead_QPJL_1Mean += `<th>${e}</th>`;
                                    });
                                    htmlHead_QPJL_1Mean += `</tr>`;
                                    var htmlBody_QPJL_1Mean = ``;
                                    QPJLABELLBrand[0].forEach(function(e,i,a){
                                        htmlBody_QPJL_1Mean += `<tr>`;
                                        htmlBody_QPJL_1Mean += `<th>${e}</th>`;
                                        htmlBody_QPJL_1Mean += `<td>${QPJLBrand_1_Mean_luciferX[i]}</td>`;
                                        htmlBody_QPJL_1Mean += `<td>${QPJLBrand_1_Top_luciferX[i]}%</td>`;
                                        htmlBody_QPJL_1Mean += `</tr>`;
                                    });
                                    $("#QPJL_1_tbl > thead").empty().append(htmlHead_QPJL_1Mean);
                                    $("#QPJL_1_tbl > tbody").empty().append(htmlBody_QPJL_1Mean);



                                    var htmlHead_QPJL_2Mean = ``;
                                    htmlHead_QPJL_2Mean += `<tr style="display:none"><th>Timely handover of important documents</th></tr>`;
                                    htmlHead_QPJL_2Mean += `<tr>`;
                                    tblHeadType_1.forEach(function(e,i,a){
                                        htmlHead_QPJL_2Mean += `<th>${e}</th>`;
                                    });
                                    htmlHead_QPJL_2Mean += `</tr>`;
                                    var htmlBody_QPJL_2Mean = ``;
                                    QPJLABELLBrand[1].forEach(function(e,i,a){
                                        htmlBody_QPJL_2Mean += `<tr>`;
                                        htmlBody_QPJL_2Mean += `<th>${e}</th>`;
                                        htmlBody_QPJL_2Mean += `<td>${QPJLBrand_2_Mean_luciferX[i]}</td>`;
                                        htmlBody_QPJL_2Mean += `<td>${QPJLBrand_2_Top_luciferX[i]}%</td>`;
                                        htmlBody_QPJL_2Mean += `</tr>`;
                                    });
                                    $("#QPJL_2_tbl > thead").empty().append(htmlHead_QPJL_2Mean);
                                    $("#QPJL_2_tbl > tbody").empty().append(htmlBody_QPJL_2Mean);



                                    var htmlHead_QPJL_3Mean = ``;
                                    htmlHead_QPJL_3Mean += `<tr style="display:none"><th>Promptness in resolution of query raised during feedback call</th></tr>`;
                                    htmlHead_QPJL_3Mean += `<tr>`;
                                    tblHeadType_1.forEach(function(e,i,a){
                                        htmlHead_QPJL_3Mean += `<th>${e}</th>`;
                                    });
                                    htmlHead_QPJL_3Mean += `</tr>`;
                                    var htmlBody_QPJL_3Mean = ``;
                                    QPJLABELLBrand[2].forEach(function(e,i,a){
                                        htmlBody_QPJL_3Mean += `<tr>`;
                                        htmlBody_QPJL_3Mean += `<th>${e}</th>`;
                                        htmlBody_QPJL_3Mean += `<td>${QPJLBrand_3_Mean_luciferX[i]}</td>`;
                                        htmlBody_QPJL_3Mean += `<td>${QPJLBrand_3_Top_luciferX[i]}%</td>`;
                                        htmlBody_QPJL_3Mean += `</tr>`;
                                    });
                                    $("#QPJL_3_tbl > thead").empty().append(htmlHead_QPJL_3Mean);
                                    $("#QPJL_3_tbl > tbody").empty().append(htmlBody_QPJL_3Mean);


                                    var htmlHead_QPJL_4Mean = ``;
                                    htmlHead_QPJL_4Mean += `<tr style="display:none"><th>Experience of Post Sale feedback call</th></tr>`;
                                    htmlHead_QPJL_4Mean += `<tr>`;
                                    tblHeadType_1.forEach(function(e,i,a){
                                        htmlHead_QPJL_4Mean += `<th>${e}</th>`;
                                    });
                                    htmlHead_QPJL_4Mean += `</tr>`;
                                    var htmlBody_QPJL_4Mean = ``;
                                    QPJLABELLBrand[3].forEach(function(e,i,a){
                                        htmlBody_QPJL_4Mean += `<tr>`;
                                        htmlBody_QPJL_4Mean += `<th>${e}</th>`;
                                        htmlBody_QPJL_4Mean += `<td>${QPJLBrand_4_Mean_luciferX[i]}</td>`;
                                        htmlBody_QPJL_4Mean += `<td>${QPJLBrand_4_Top_luciferX[i]}%</td>`;
                                        htmlBody_QPJL_4Mean += `</tr>`;
                                    });
                                    $("#QPJL_4_tbl > thead").empty().append(htmlHead_QPJL_4Mean);
                                    $("#QPJL_4_tbl > tbody").empty().append(htmlBody_QPJL_4Mean);
                                }
                            //QPJL
                        }
                        else
                        {
                            $("#qpjov_meanbrand").empty().append(`<h6 class="blank_msg" >No Data to Preview</h6>`);
                            $("#qpjov_topbrand").empty().append(`<h6 class="blank_msg" >No Data to Preview</h6>`);
                            $("#qpjl_1_meanbrand").empty().append(`<h6 class="blank_msg" >No Data to Preview</h6>`);
                            $("#qpjl_1_topbrand").empty().append(`<h6 class="blank_msg" >No Data to Preview</h6>`);
                            $("#qpjl_2_meanbrand").empty().append(`<h6 class="blank_msg" >No Data to Preview</h6>`);
                            $("#qpjl_2_topbrand").empty().append(`<h6 class="blank_msg" >No Data to Preview</h6>`);
                            $("#qpjl_3_meanbrand").empty().append(`<h6 class="blank_msg" >No Data to Preview</h6>`);
                            $("#qpjl_3_topbrand").empty().append(`<h6 class="blank_msg" >No Data to Preview</h6>`);
                            $("#qpjl_4_meanbrand").empty().append(`<h6 class="blank_msg" >No Data to Preview</h6>`);
                            $("#qpjl_4_topbrand").empty().append(`<h6 class="blank_msg" >No Data to Preview</h6>`);

                            $("#QPJOV_tbl > thead").empty();
                            $("#QPJOV_tbl > tbody").empty().append(`<h6 class="blank_msg" >No Data to Preview</h6>`);

                            $("#QPJL_1_tbl > thead").empty();
                            $("#QPJL_1_tbl > tbody").empty().append(`<h6 class="blank_msg" >No Data to Preview</h6>`);

                            $("#QPJL_2_tbl > thead").empty();
                            $("#QPJL_2_tbl > tbody").empty().append(`<h6 class="blank_msg" >No Data to Preview</h6>`);

                            $("#QPJL_3_tbl > thead").empty();
                            $("#QPJL_3_tbl > tbody").empty().append(`<h6 class="blank_msg" >No Data to Preview</h6>`);

                            $("#QPJL_4_tbl > thead").empty();
                            $("#QPJL_4_tbl > tbody").empty().append(`<h6 class="blank_msg" >No Data to Preview</h6>`);
                        }
                    },
                    complete: function (data) 
                    {
                        ajaxFlag[8] = true;
                        if(excelStatus===true)
                        {
                            checkAjaxCompletion()
                        }
                    }
                });
            }
//------------------------------------------------------------EXCEL EXPORT--------------------------------------------------------------
function exportExcelFlag()
{
    statusArr = ["active","active","active","active","active","active","active","active","active"];
    excelStatus=true;
    if (ajaxFlag.every(flag => flag === true)) 
    {
        exportExcel()
    }
    else
    {
        applyF();
    }
}

function exportExcel()
{
    excelStatus=false;
    
    let workbook = XLSX.utils.book_new(); // Initialize the workbook outside the loop
    console.log(classArr)
    classArr.forEach(function(ele, ind) {
        const sheetName = innerTabE[ind];
        const tables = document.getElementsByClassName(ele);
        // Initialize an array to store data from all tables
        let allTablesData = [];

        // Loop through each table
        for (let i = 0; i < tables.length; i++) {
            const table = tables[i];
            const ws = XLSX.utils.table_to_sheet(table, { raw: true });

            // Append data from current table to allTablesData
            allTablesData.push(XLSX.utils.sheet_to_json(ws, { header: 1 }));
        }

        // Calculate the total column count for all tables
        let totalColCount = 0;
        for (let i = 0; i < allTablesData.length; i++) {
            const tableData = allTablesData[i];
            const tableColCount = getColumnCount(tableData);
            totalColCount = Math.max(totalColCount, tableColCount);
        }

        // Add an empty row between each table's data
        for (let i = 0; i < allTablesData.length - 1; i++) {
            allTablesData[i].push([]);
        }

        // Merge data from all tables into one array
        let mergedData = [];
        for (let i = 0; i < allTablesData.length; i++) {
            mergedData = mergedData.concat(allTablesData[i]);
        }

        // Merge cells for the first row of each table
        const merges = [];
        let rowIndex = 0;
        for (let i = 0; i < allTablesData.length; i++) {
            const tableData = allTablesData[i];
            const rowCount = tableData.length;
            merges.push({
                s: { r: rowIndex, c: 0 },
                e: { r: rowIndex, c: totalColCount - 1 }
            });
            rowIndex += rowCount;
        }

        // Convert merged data back to a worksheet
        const mergedSheet = XLSX.utils.aoa_to_sheet(mergedData);

        // Add merges to the mergedSheet
        mergedSheet["!merges"] = merges;

        // Set column widths if needed
        mergedSheet['!cols'] = [{ width: 60 }, { width: 20 }, { width: 20 }, { width: 20 }];

        XLSX.utils.book_append_sheet(workbook, mergedSheet, `${sheetName}`);
    });

    XLSX.writeFile(workbook, "Cherry Dashboard Data.xlsx");

    // Function to get the number of columns in a table
    function getColumnCount(ws) {
        let maxCol = 0;
        for (const cellRange in ws) {
            const colIndex = XLSX.utils.decode_cell(cellRange).c;
            maxCol = Math.max(maxCol, colIndex);
        }
        return maxCol + 1; // Since column indices start from 0
    }
}
        </script>
    </body>
</html>
