<?php
/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */


require_once './modelos/Consultas.php';
$dbManager = new Consultas();
$jornadas = $dbManager->todasJornadas();
$empleados = $dbManager->empleados($_POST["sede"], $_POST["depto"], $_POST["persona"]);
$start = new DateTime($_POST['desde'] . " 00:00:00");
$interval = new DateInterval('P1D');
$end = new DateTime($_POST['hasta'] . " 23:59:59");
$dias = new DatePeriod($start, $interval, $end);
$diasEntreFechas = date_diff($start, $end);
$empleados = reporteMarcas($dbManager, $empleados, $dias, $jornadas, $diasEntreFechas);

$nameReporte = '';
$vistaReporte = 'vistas/tablaReportes.php';
if($_POST["correo"] == '1') {
  $vistaReporte = 'vistas/correoReportes.php';
}
switch($_POST['tipo']) {
  case 1:
    $mostrar = 'marcacion';
    $nameReporte = 'Marcaciones o Uso del Sistema.';
    break;
  case 2:
    $mostrar = 'diferencia';
    $nameReporte = 'Tiempos de Llegada y Salida.';
    break;
  case 3:
    $mostrar = 'tiempo';
    $nameReporte = 'Tiempo trabajado Dia a Dia.';
    $vistaReporte = 'vistas/tablaReportesTrabajado.php';
    break;
  default :
    $empleados = array();
    break;
}
if(/*isset($_POST["persona"]) and ! is_null($_POST["persona"]) and $_POST["persona"] != '00' and*/ $_POST["correo"] != '1') {
  include 'vistas/form-enviarReporte.php';
}

if($_POST["correo"] == '1') {
  echo '<h2>Reporte de ' . $nameReporte . '</h2>';
}

include $vistaReporte;
?>


<?php
/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
