<?php
date_default_timezone_set("America/Mexico_City");
session_start();
include('conexion.php');
//include('mysql_Valida_permiso.php');	
function FechaFormateada($FechaStamp)
{
	$ano = date('Y',$FechaStamp); //<-- Año
	$mes = date('m',$FechaStamp); //<-- número de mes (01-31)
	$dia = date('d',$FechaStamp); //<-- Día del mes (1-31)
	$dialetra = date('w',$FechaStamp);  //Día de la semana(0-7)
	switch($dialetra)
	{
		case 0: $dialetra="Domingo"; break;
		case 1: $dialetra="Lunes"; break;
		case 2: $dialetra="Martes"; break;
		case 3: $dialetra="Miércoles"; break;
		case 4: $dialetra="Jueves"; break;
		case 5: $dialetra="Viernes"; break;
		case 6: $dialetra="Sábado"; break;
	}
	switch($mes) 
	{
		case '01': $mesletra="Enero"; break;
		case '02': $mesletra="Febrero"; break;
		case '03': $mesletra="Marzo"; break;
		case '04': $mesletra="Abril"; break;
		case '05': $mesletra="Mayo"; break;
		case '06': $mesletra="Junio"; break;
		case '07': $mesletra="Julio"; break;
		case '08': $mesletra="Agosto"; break;
		case '09': $mesletra="Septiembre"; break;
		case '10': $mesletra="Octubre"; break;
		case '11': $mesletra="Noviembre"; break;
		case '12': $mesletra="Diciembre"; break;
	}    
	return "$dialetra, $dia de $mesletra de $ano";
}
if (isset($_SESSION['id_usuario']))
{
?>
<HTML>
<head>

	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<link rel="shortcut icon" href="images/Sysmental.jpg" type="image/jpeg"/>
	<title>Flotillas</title>
	<link href="css/bootstrap.min.css" rel="stylesheet">
	<script src="//code.jquery.com/jquery-1.10.2.js"></script>
	<script src="//code.jquery.com/ui/1.11.1/jquery-ui.js"></script>	
	<script type="text/javascript" src="//cdn.jsdelivr.net/jquery/1/jquery.min.js"></script>
	<script type="text/javascript" src="//cdn.jsdelivr.net/momentjs/latest/moment.min.js"></script> 
	<!-- Include Date Range Picker -->
	<script type="text/javascript" src="//cdn.jsdelivr.net/bootstrap.daterangepicker/2/daterangepicker.js"></script>
	<link rel="stylesheet" type="text/css" href="//cdn.jsdelivr.net/bootstrap.daterangepicker/2/daterangepicker.css" />
	<!--alert-->
	<script src = "sweetalert-master/dist/sweetalert.min.js" ></script>  
	<link rel = "stylesheet" type = "text/css" href = "sweetalert-master/dist/sweetalert.css" >
	<input type="hidden" name="vartime" id="vartime" value="c">
<script type="text/javascript" src="js/funciones.js"></script>	
</head>
<style>
fieldset.scheduler-border {
    border: 1px groove #ddd !important;
    padding-top: 0px;
    padding-right: 10px;
    padding-bottom: 10px;
    padding-left: 10px;
    margin: 0 0 1em 0 !important;
    -webkit-box-shadow:  0px 0px 0px 0px #000;
            box-shadow:  0px 0px 0px 0px #000;
}

    legend.scheduler-border {
        font-size: 1em !important;
        font-weight: bold !important;
        text-align: left !important;
        width:auto;     		
        border-bottom:none;
    }
</style>

<body>
	<nav class="navbar navbar-default">
	  <div class="container-fluid">
		<div class="navbar-header">
		  <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
			<span class="sr-only">Toggle navigation</span>
			<span class="icon-bar"></span>
			<span class="icon-bar"></span>
			<span class="icon-bar"></span>
		  </button>
		  <img  src="images/Logo.jpg" width="130" align="left" style="border:outset" />	
		</div>
		<center style="width:auto;align:center;" valign="center">					
			<H1 style="color:white;font-weight: bold;">FLOTILLAS</H1>
		</center>
		<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
		  <ul class="nav navbar-nav">
			<li><a style="font-weight: bold;font-size:20;" href="catalogo_vehiculos.php">Vehiculos</a></li> 
			  <li ><a id="transac" style="font-weight: bold;font-size:20;display:<?php if($_SESSION['transacciones']==1){echo 'block';}else{ echo 'none';}?>" href="catalogo_transacciones.php">Transacciones</a></li> 
		  <li ><a id="fact" style="font-weight: bold;font-size:20;display:<?php if($_SESSION['facturas']==1){echo 'block';}else{ echo 'none';}?>" href="catalogo_facturas.php">Facturas</a></li> 
			<li><a style="font-weight: bold;font-size:20;" href="catalogo_consumos.php">Reportes</a></li> 		
		  </ul>      
		  <ul class="nav navbar-nav navbar-right">
			<li><a style="font-weight: bold;font-size:20;pointer-events: none;cursor: default;color:white;" ><?php echo $_SESSION['id_usuario'];?></a></li>
			<li><a style="font-weight: bold;font-size:20;" href="logout.php">Salir</a></li>
		  </ul>
		</div>
	  </div>
	</nav>
	<table align="center" style="background-color:transparent;">
		<tr>
			<td>
				<center style="width:900px;align:center;background-color:transparent;" valign="center" id="Contenedor">
					<div class="panel panel-success" style="background-color:transparent;height:auto;width:900px;" >
						<div class="panel-heading" style="height:40px;">Reportes&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<?php $fecha = time();  echo FechaFormateada($fecha). "  "; ?>
						
						</div>
						<div class="panel-body" >
							<table style="width:auto;">   
								<tr style="height:30px;">
									<td style="width:150px;font-weight: bold;">Rango de fechas: </td>
									<td style="width:540px;"><input type="text" style="width:270;" name="daterange" id="daterange" value="" onchange="limpiar()"/></td>	
									<td style="width:350px">
										<input type="button" id="btnconsulta" onclick="buscar()" class="btn btn-default" value="Consulta"/>		
										<input type="button" id="btntxt" onclick="generar_txt()" class="btn btn-default" value="TXT"/>		
									</td>
								</tr>
								<tr style="height:30px;">
									<td style="width:150px;font-weight: bold;">Tarjeta</td>
									<td colspan="2">
									<?php		
										$sql="select ";
										$sql.="id_vehiculo, ";
										$sql.="descripcion, ";
										$sql.="placa, ";
										$sql.="id_tag, ";
										$sql.="estado ";	
										$sql.="from ";
										$sql.="vehiculos ";
										$sql.="where ";
										$sql.="id_cliente = ".  $_SESSION['id_cliente'];
										
										$result = $conexion->query($sql); 	
										
										if(!$result) 
										die("Error: no se pudo realizar la consulta");		
									?>
										<select id="cmbtarjeta" name="cmbtarjeta" style="width:270" onchange="limpiar()">
											<option value ="0">seleccionar</option>
											<?php
											while ($row=$result->fetch_row()){ 
											?>
											<option value="<?php echo $row[0];?>"><?php echo $row[3] .' - '. $row[2]  ; ?></option>
											<?php
											}
											$result->free();
											?>
										</select>
									</td>									
								</tr>										
								<tr id="btnrendimiento" style="display:<?php if($_SESSION['reporte_rendimiento']==1){echo 'block';}else{ echo 'none';}?> ">
									<td colspan="3">
										<p><input type="checkbox" id="cbxRRV" name="" onclick="habilita_RRV()">Rendimiento </input></p>
									</td>		
								</tr>
								<tr>
									<td>
										<p id="Costo_unidad" style="display:none" ><input type="checkbox" id="cbxCU" onclick="rendimiento_unidad()">Costo por Unidad</input></p>
									</td>
									<td>
										<p id="Combustible_unidad" style="display:none" ><input type="checkbox" id="cbxRU" onclick="rendimiento()">Combustible por Unidad</input></p>
									</td>
									<td></td>
								</tr>
								<tr id="btncontrol" style="display:<?php if($_SESSION['reporte_control']==1){echo 'block';}else{ echo 'none';}?> ">
									<td colspan="3">
									<p><input type="checkbox" id="cbxCV" name="" onclick="habilita_CV()">Control Vehiculo</input></p>
									</td>
								</tr>
								<tr id="btnconsumos" style="display:<?php if($_SESSION['reporte_consumos']==1){echo 'block';}else{ echo 'none';}?> ">
									<td colspan="3">
									<p><input  type="checkbox" id="cbxC" name="" onclick="habilita_C()">Consumos</input></p>
									</td>
								</tr>
								<tr id="btnestado" style="display:<?php if($_SESSION['reporte_estado']==1){echo 'block';}else{ echo 'none';}?> ">
									<td colspan="3">
										<p><input  type="checkbox" id="cbxE" name="" onclick="habilita_E()">Estado de cuenta</input></p>
									</td>
								</tr>
								<tr id="btnadeudos" style="display:<?php if($_SESSION['reporte_adeudo']==1){echo 'block';}else{ echo 'none';}?> ">
									<td colspan="3">
										<p><input  type="checkbox" id="cbxA" name="" onclick="habilita_A()">Adeudos de cobro</input></p>
									</td>
								</tr>	
							</table>				
							<center style="width:auto;align:left;color:black;position: relative;top:15px;" id="centro_catalogo">
							</center>
						</div>	
					</div>
				</center> 	
			</td>
		</tr>
		<tr>		
			<td align="right">
				<table>
					<tr>
					<td>
						<img width="150px;" src="images/GasLight System.jpg"></img>
					</td>
					</tr>
				</table>			
			</td>
		</tr>	
	</table>
	<div style="display:none">
	<input style="display:none" type="button" id="btnagregar" type="hidden"/>
	<input style="display:none" type="button" id="btneditar" type="hidden"/>
	</div>
</body>
<?php 
}	
else
{
header('location: inicio.php');
}
?>
</html>
