<?php
// FECHA Y HORA
$dateStart = $_GET['dateStart'];
$dateEnd = $_GET['dateEnd'];
$timeStart = $_GET['timeStart'];
$timeEnd = $_GET['timeEnd'];
$serviceName = $_GET['service'];

include_once('../head.php');
require_once('../models/queryReports.php');
?>
<br>
<!-- Columns start at 50% wide on mobile and bump up to 33.3% wide on desktop -->

<body>
    <div class="row">
        <div class="col-6 col-md-1"></div>
        <!--<div class="col-6 col-md-10">-->
            <div class="col-sm-10">

            <h5 class="text-center"> Report: Answered Calls Average Waiting Time <br>
                Service: <?php echo $serviceName ?>
                <br>
                From:<strong> <?php echo $dateStart ?></strong> to <strong><?php echo $dateEnd ?></strong>
            </h5>
            <br>
            <div class="text-center">
                <a href="../index.php?dateStart=<?php echo urlencode($dateStart); ?>&dateEnd=<?php echo urlencode($dateEnd); ?>&timeStart=<?php echo urlencode($timeStart); ?>&timeEnd=<?php echo urlencode($timeEnd); ?>&service=<?php echo urlencode($serviceName); ?>" class="btn btn-info" id="submit">
                    <i class="fa fa-chevron-left"></i> Back
                </a>
            </div>

            <br><br>
            <table class="table table-hover table-bordered" border="1" bordercolor="#666666" id="calls_answered" style="border-collapse:collapse;">
                <thead>
                    <tr>
                        <th class="th2 text-center">Date</th>
                        <th class="th2 text-center">Answered Calls Average Waiting Time</th>
                    </tr>

                </thead>
                <tbody>
                    <?php

                    $AnsAvgWT = 0;
                    $resultAnswered = $mysqli->query($queryAnsweredAvgWT);
                    while ($rowAswered = mysqli_fetch_array($resultAnswered)) {
                        $date = $rowAswered["Date"];
                        $AnsAvgWT = $rowAswered["AnsAvgWT"];

                        if ($date == NULL) {
                            $date = "Total";
                        }

                    ?>
                        <tr>
                            <td><?php echo $date ?></td>
                            <td><?php echo $AnsAvgWT  ?></td>

                        </tr>
                    <?php
                    }
                    ?>
                </tbody>
            </table>

            <br />

        </div>
    </div>


    <!-- Datatables CSS -->
    <link rel="stylesheet" type="text/css" href="datatables/datatables.min.css" />
    <!-- Datatables Bootstrap 4 CSS -->
    <link rel="stylesheet" type="text/css" href="datatables/DataTables-1.10.18/css/dataTables.bootstrap4.min.css">
    <!-- Datatables JS -->
    <script type="text/javascript" src="datatables/datatables.min.js"></script>
    <!-- Usar botones en datatables JS -->
    <script src="datatables/Buttons-1.5.6/js/dataTables.buttons.min.js"></script>
    <script src="datatables/JSZip-2.5.0/jszip.min.js"></script>
    <script src="datatables/pdfmake-0.1.36/pdfmake.min.js"></script>
    <script src="datatables/pdfmake-0.1.36/vfs_fonts.js"></script>
    <script src="datatables/Buttons-1.5.6/js/buttons.html5.min.js"></script>

    <script type="text/javascript" src="js/tables.js"></script>

    <?php include_once('foot.php'); ?>

</body>

</html>