<?php
include_once('service.php');
$date = date("Y-m-d");
// Si selecciono el botón View
if (isset($_GET['view'])) {

    //echo "Click en botón View";
    $dateStart = $_GET['dateStart'];
    $dateEnd = $_GET['dateEnd'];
    $timeStart = $_GET['timeStart'];
    $timeEnd = $_GET['timeEnd'];
    $reporte = $_GET['reporte'];
    $serviceName = $_GET['service'];

    // Validación de fechas
    if (($reporte == 2 || $reporte == 2.1 || $reporte == 2.3 || $reporte == 3 || $reporte == 4 || $reporte == 6 || $reporte == 7 || $reporte == 9 || $reporte == 11 || $reporte == 17 || $reporte == 18 || $reporte == 19 || $reporte == 20 || $reporte == 21 || $reporte == 22 || $reporte == 23 || $reporte == 24 || $reporte == 25 || $reporte == 26 || $reporte == 27 || $reporte == 28) && $dateStart > $dateEnd) {
        echo  '<div class="container">
                            <div class="alert alert-danger">
                            <button class="close" data-dismiss="alert"><span>&times;</span></button>
                            <strong>Invalid date range, Date start cannot be greater than Date end</strong>
                            </div>
                        </div>';
    } elseif (($reporte == 2 || $reporte == 2.1 || $reporte == 2.3 || $reporte == 3 || $reporte == 4 || $reporte == 6 || $reporte == 7 || $reporte == 9 || $reporte == 11 || $reporte == 17 || $reporte == 18 || $reporte == 19 || $reporte == 20 || $reporte == 21 || $reporte == 22 || $reporte == 23 || $reporte == 24 || $reporte == 25 || $reporte == 26 || $reporte == 27 || $reporte == 28) && $dateStart > $date) {
        echo '<div class="container">
                        <div class="alert alert-danger">
                        <button class="close" data-dismiss="alert"><span>&times;</span></button>
                        <strong>Invalid date range, Date start cannot be greater than current date</strong>
                        </div>
                    </div>';
    } elseif (($reporte == 2 || $reporte == 2.1 || $reporte == 2.3 || $reporte == 3 || $reporte == 4 || $reporte == 6 || $reporte == 7 || $reporte == 9 || $reporte == 11 || $reporte == 17 || $reporte == 18 || $reporte == 19 || $reporte == 20 || $reporte == 21 || $reporte == 22 || $reporte == 23 || $reporte == 24 || $reporte == 25 || $reporte == 26 || $reporte == 27 || $reporte == 28) && $dateEnd > $date) {
        echo '<div class="container">
                        <div class="alert alert-danger">
                        <button class="close" data-dismiss="alert"><span>&times;</span></button>
                        <strong>Invalid date range, Date end cannot be greater than current date</strong>
                        </div>
                    </div>';
    } elseif ($reporte == 2) {
        header("Location: views/viewCallsAnsweredReport.php?dateStart=$dateStart&dateEnd=$dateEnd&timeStart=$timeStart&timeEnd=$timeEnd&reporte=$reporte&service=$serviceName");
    } elseif ($reporte == 2.1) {
        header("Location: views/viewCallsAbandonedReport.php?dateStart=$dateStart&dateEnd=$dateEnd&timeStart=$timeStart&timeEnd=$timeEnd&reporte=$reporte&service=$serviceName");
    } elseif ($reporte == 2.3) {
        header("Location: views/viewCallsLess60SegReport.php?dateStart=$dateStart&dateEnd=$dateEnd&timeStart=$timeStart&timeEnd=$timeEnd&reporte=$reporte&service=$serviceName");
    } elseif ($reporte == 3) {
        header("Location: views/viewCallsAnsweredDetailReport.php?dateStart=$dateStart&dateEnd=$dateEnd&timeStart=$timeStart&timeEnd=$timeEnd&reporte=$reporte&service=$serviceName");
    } elseif ($reporte == 4) {
        header("Location: views/viewCallsAbandonedDetailReport.php?dateStart=$dateStart&dateEnd=$dateEnd&timeStart=$timeStart&timeEnd=$timeEnd&reporte=$reporte&service=$serviceName");
    } elseif ($reporte == 6) {
        header("Location: views/viewCallsOfferedReport.php?dateStart=$dateStart&dateEnd=$dateEnd&timeStart=$timeStart&timeEnd=$timeEnd&reporte=$reporte&service=$serviceName");
    } elseif ($reporte == 7) {
        header("Location: views/viewCallsOfferedDetailReport.php?dateStart=$dateStart&dateEnd=$dateEnd&timeStart=$timeStart&timeEnd=$timeEnd&reporte=$reporte&service=$serviceName");
    } elseif ($reporte == 9) {
        header("Location: views/viewAgentsPerformanceReport.php?dateStart=$dateStart&dateEnd=$dateEnd&timeStart=$timeStart&timeEnd=$timeEnd&reporte=$reporte&service=$serviceName");
    } elseif ($reporte == 11) {
        header("Location: views/viewOverallSlaAhtReport.php?dateStart=$dateStart&dateEnd=$dateEnd&timeStart=$timeStart&timeEnd=$timeEnd&reporte=$reporte&service=$serviceName");
    } elseif ($reporte == 17) {
        header("Location: views/viewAgentsPerformanceChart.php?dateStart=$dateStart&dateEnd=$dateEnd&timeStart=$timeStart&timeEnd=$timeEnd&reporte=$reporte&service=$serviceName");
    } elseif ($reporte == 18) {
        header("Location: views/viewOverallSlaAhtChart.php?dateStart=$dateStart&dateEnd=$dateEnd&timeStart=$timeStart&timeEnd=$timeEnd&reporte=$reporte&service=$serviceName");
    } elseif ($reporte == 19) {
        header("Location: views/viewOverallSlaChart.php?dateStart=$dateStart&dateEnd=$dateEnd&timeStart=$timeStart&timeEnd=$timeEnd&reporte=$reporte&service=$serviceName");
    } elseif ($reporte == 20) {
        header("Location: views/viewAgentsPerformanceDetailReport.php?dateStart=$dateStart&dateEnd=$dateEnd&timeStart=$timeStart&timeEnd=$timeEnd&reporte=$reporte&service=$serviceName");
    } elseif ($reporte == 21) {
        header("Location: views/viewStatisticsReport.php?dateStart=$dateStart&dateEnd=$dateEnd&timeStart=$timeStart&timeEnd=$timeEnd&reporte=$reporte&service=$serviceName");
    } elseif ($reporte == 22) {
        header("Location: views/viewCallsAnsweredAverageWaitingTimeReport.php?dateStart=$dateStart&dateEnd=$dateEnd&timeStart=$timeStart&timeEnd=$timeEnd&reporte=$reporte&service=$serviceName");
    } elseif ($reporte == 23) {
        header("Location: views/viewCallsAbandonedAverageWaitingTimeReport.php?dateStart=$dateStart&dateEnd=$dateEnd&timeStart=$timeStart&timeEnd=$timeEnd&reporte=$reporte&service=$serviceName");
    } elseif ($reporte == 24) {
        header("Location: views/viewAgentTimesReport.php?dateStart=$dateStart&dateEnd=$dateEnd&timeStart=$timeStart&timeEnd=$timeEnd&reporte=$reporte&service=$serviceName");
    } elseif ($reporte == 25) {
        header("Location: views/viewAgentBreakReport.php?dateStart=$dateStart&dateEnd=$dateEnd&timeStart=$timeStart&timeEnd=$timeEnd&reporte=$reporte&service=$serviceName");
    } elseif ($reporte == 26) {
        header("Location: views/viewAvgAttentionTimeReport.php?dateStart=$dateStart&dateEnd=$dateEnd&timeStart=$timeStart&timeEnd=$timeEnd&reporte=$reporte&service=$serviceName");
    } elseif ($reporte == 27) {
        header("Location: views/viewAgentsOperationPanel2Report.php?dateStart=$dateStart&dateEnd=$dateEnd&timeStart=$timeStart&timeEnd=$timeEnd&reporte=$reporte&service=$serviceName");
    } elseif ($reporte == 28) {
        header("Location: views/viewAgentsOperationPanel2DetailReport.php?dateStart=$dateStart&dateEnd=$dateEnd&timeStart=$timeStart&timeEnd=$timeEnd&reporte=$reporte&service=$serviceName");
    }
}

?>