<?php
	date_default_timezone_set("America/Mazatlan");
	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">
		<link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
		<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> 
		<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.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="f">
	<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;
		}
		#popup {
		left: 0;
		position: absolute;
		top: 0;
		width: 100%;
			height: 100%;
		z-index: 1001;
	}

	.content-popup {
		margin:0px auto;
		margin-top:120px;
		position:relative;
		padding:10px;
		width:100%;
		height: 100%;
		min-height:250px;
		border-radius:4px;
		background-color:#FFFFFF;
		box-shadow: 0 2px 5px #000;
	}

	.content-popup h2 {
		color:#48484B;
		border-bottom: 1px solid #48484B;
		margin-top: 0;
		padding-bottom: 4px;
	}

	.popup-overlay {
		left: 0;
		position: absolute;
		top: 0;
		width: 100%;
		z-index: 999;
		display:none;
		background-color: #777777;
		cursor: pointer;
		opacity: 0.7;
	}

	.close {
		position: absolute;
		right: 15px;
	}
			@media screen and (max-width: 600px) {
		table {
			width:100%;
		}
		thead {
			display: none;
		}
		tr:nth-of-type(2n) {
			background-color: inherit;
		}
		tr td:first-child {
			background: #f0f0f0;
			font-weight:bold;
			font-size:1.3em;
		}
		tbody td {
			display: block;
			text-align:center;
		}
		tbody td:before {
			content: attr(data-th);
			display: block;
			text-align:center;
		}
				
				#popup {
		left: 0;
		position: absolute;
		top: 0;
		width: 100%;
		z-index: 1001;
	}

	.content-popup {
		margin:0px auto;
		margin-top:120px;
		position:relative;
		padding:10px;
		width:300px;
		min-height:250px;
		border-radius:4px;
		background-color:#FFFFFF;
		box-shadow: 0 2px 5px #666666;
	}

	.content-popup h2 {
		color:#48484B;
		border-bottom: 1px solid #48484B;
		margin-top: 0;
		padding-bottom: 4px;
	}

	.popup-overlay {
		left: 0;
		position: absolute;
		top: 0;
		width: 100%;
		z-index: 999;
		display:none;
		background-color: #777777;
		cursor: pointer;
		opacity: 0.7;
	}

	.close {
		position: absolute;
		right: 15px;
	}
	}
		.contenedor {
		width: 95%;
		max-width:1000px;
		margin:auto;
	}
	
	.contenedor p {
		margin-bottom:40px;
	}
	
	
	.menu-fixed {
		position:fixed;
		z-index:1000;
		top:0;
		/*max-width:1000px;*/
		left:35%;
		width:100%;
		/*box-shadow:0px 4px 3px rgba(0,0,0,.5);*/
	}
		th {
		text-align: center;
	}
	</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>

		<?php  
			$email="";
			$sql = "select ";
			$sql.="email ";
			$sql.="from ";
			$sql.="clientes  ";
			$sql.="where ";
			$sql.="id_cliente= ".$_SESSION['id_cliente'];

			$resultado = $iden->query($sql); 

			while($fila = $resultado->fetch_assoc()) 
			{	 
				$email=$fila["email"];
			}

			$resultado->free();

		?>
		<div id="reenvioCorreo" class="col-md-4 col-md-offset-4" style="display: none;">
			<div class="panel panel-success">
				<div class="panel-heading" style="height:40px;">Reenvio de Correo</div>
				<div class="panel-body">
					<input type="text" class="form-control" id="txtCorreo" placeholder="Ingrese correo" value="<?php echo $email; ?>">
					<br>
					<div class="row form-group" style="text-align: right;">
						<button class="btn btn-success btn-sm" onclick="enviarCorreo();">Enviar</button>
						<button class="btn btn-danger btn-sm" onclick="regresarReenvio();">Regresar</button>
					</div>
				</div>
			</div>
		</div>
		<div id="divFacturas">
			<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;">Facturas&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;&nbs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bsp;&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;">   
									<div class="contenedor">
									<tr style="height:30px;" class="menu">
										<td style="width:150px;font-weight: bold;"><input type="button" onclick="window.location.reload()" class="btn btn-default" value="Limpiar"></td>
										<td></td>
										<td></td>
										<td width="97px"><input type="button" id="btnconsulta" onclick="cargafacturas()" class="btn btn-default" value="Consultar"/></td>
										<td style="width:350px">
											<input type="button" onclick="detalles(2)" class="btn btn-default" value="Detalle"> 
											<input type="button" onclick="reporte_facturas(1)" class="btn btn-default" value="Reporte PDF">
											<input type="button" onclick="reporte_facturas(2)" class="btn btn-default" value="Reporte XLS">	
												
										</td>
										</tr>
										</table>
									
									<table style="width:auto;" align="left">
										</div>
										<tr style="height:30px;">
										<td style="font-weight: bold;">Cliente</td>
										<td><?php echo $_SESSION['id_cliente'];?></td>
										<td></td>
										<td></td>
										<td></td>
									</tr>	
									<tr style="height:30px;">
										<td style="font-weight: bold;">Razon Social</td>
										<td><?php echo $_SESSION['razon_social'];?></td>
										<td></td>
										<td></td>
										<td></td>
									</tr>
									<tr style="height:30px;">
										<td >Estatus</td>
										<td><input type="checkbox" name="estatus" id="activo">Activa&nbsp;&nbsp;&nbsp;&nbsp;<input type="checkbox" name="estatus" id="cancelada">Cancelada &nbsp;&nbsp;&nbsp;&nbsp;<input type="checkbox" name="estatus" id="reproceso">Reproceso</td>
										<td> </td>
										<td></td>
										<td></td>
									</tr>
									
										<?php
											$sql ="select tipo from clientes where id_cliente=".$_SESSION['id_cliente'];
											$resultado = $iden->query($sql); 
											$fila = $resultado->fetch_assoc();
										?>
										<input type="hidden" name="tipocli" id="tipocli" value="<?php echo $fila['tipo']; ?>">
									
									
									<tr style="height:30px;">
										<td><input type="checkbox" name="checkestatus" id="chkTurno">Fecha Contable</td>
										<td><input type="text" id="txtFechaContableIni" name="turnoini" class="numeros" placeholder="Inicial" disabled style="text-align: right;width: 205px;"> <input type="text" id="txtFechaContableFin" name="turnofin" class="numeros" placeholder="Final" disabled style="text-align: right;width: 205px;"></td>
										<td></td>
										<td></td>
										<td></td>
									</tr>
									<tr style="height:30px;">
										<td><input type="checkbox" name="fechaini" onChange="activar(1)" id="fechaini">Fechas Registro</td>
										<td><input type="text" id="txtFechaRegistroIni" name="turnoini" class="numeros" style="text-align: right;width: 205px;" placeholder="Inicial" disabled>  <input type="text" id="txtFechaRegistroFin" name="turnofin" class="numeros" style="text-align: right;width: 205px;" placeholder="Final" disabled></td>
										<td align="right"> </td>
										<td align="right"> </td>
										<td ></td>
									</tr>
									<tr style="height:30px;">
										<td align="left"><input type="checkbox" name="checkestatus" id="serie"> Serie</td>
										<td align="left">  <input type="text" name="serietxt" id="seriet" disabled></td>
										<td align="right"></td>
										<td ></td>
										<td ></td>
									</tr>
									<tr style="height:30px;">
										<td align="left"><input type="checkbox" name="checkestatus" id="folio"> Folio</td>
										<td align="left"> <input type="text" name="foliotxt" id="foliot" class="numeros"disabled></td>
										<td align="right"> </td>
										<td align="right"> </td>
										<td ></td>
									</tr>
								</table>				
								
								
					
				</td>
			</tr>
			</table>
					
		<div id="myDiv2" align="center"></div>
					<table align="right">
						<tr>
						<td>
							<img width="150px;" src="images/GasLight System.jpg"></img>
						</td>
						</tr>
					</table>			
				</td>
			</tr>	
		</table>
		<div id="popup" style="display: none;">
		<div class="content-popup">
		
			<div class="close"><a href="#" id="close"><img src="images/close.png"/></a></div>
			<div>
			<h2 id="tituloventana"><font color="#000000"></h2>
			
			</div>
			
			<div id="loader" style="position: absolute;	text-align: center;	top: 55px;	width: 100%;display:none;"></div>
		<div class="outer_div" ></div>
				<div id="myDiv" align="center"></div>
				
		</div>
	</div>
		<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>
		</div>
		
	</body>
<?php 
}	
else
{
header('location: inicio.php');
}
?>
<script>
	$( function() {
	$( "#txtFechaRegistroIni" ).datepicker(
    	{
    		dateFormat: 'dd-mm-yy',
    		monthNames: ['Enero', 'Febrero', 'Marzo', 'Abril', 'Mayo', 'Junio',
            'Julio', 'Agosto', 'Septiembre', 'Octubre', 'Noviembre', 'Diciembre'
        	],
        	dayNames: ['Domingo', 'Lunes', 'Martes', 'Mi&eacute;rcoles', 'Jueves', 'Viernes', 'S&aacute;bado'],
        dayNamesShort: ['Dom', 'Lun', 'Mar', 'Mi&eacute;', 'Juv', 'Vie', 'S&aacute;b'],
        dayNamesMin: ['Do', 'Lu', 'Ma', 'Mi', 'Ju', 'Vi', 'S&aacute;']

    	});
	$( "#txtFechaRegistroFin" ).datepicker(
    	{
    		dateFormat: 'dd-mm-yy',
    		monthNames: ['Enero', 'Febrero', 'Marzo', 'Abril', 'Mayo', 'Junio',
            'Julio', 'Agosto', 'Septiembre', 'Octubre', 'Noviembre', 'Diciembre'
        	],
        	dayNames: ['Domingo', 'Lunes', 'Martes', 'Mi&eacute;rcoles', 'Jueves', 'Viernes', 'S&aacute;bado'],
        dayNamesShort: ['Dom', 'Lun', 'Mar', 'Mi&eacute;', 'Juv', 'Vie', 'S&aacute;b'],
        dayNamesMin: ['Do', 'Lu', 'Ma', 'Mi', 'Ju', 'Vi', 'S&aacute;']

    	});
    $( "#txtFechaContableIni" ).datepicker(
    	{
    		dateFormat: 'dd-mm-yy',
    		monthNames: ['Enero', 'Febrero', 'Marzo', 'Abril', 'Mayo', 'Junio',
            'Julio', 'Agosto', 'Septiembre', 'Octubre', 'Noviembre', 'Diciembre'
        	],
        	dayNames: ['Domingo', 'Lunes', 'Martes', 'Mi&eacute;rcoles', 'Jueves', 'Viernes', 'S&aacute;bado'],
        dayNamesShort: ['Dom', 'Lun', 'Mar', 'Mi&eacute;', 'Juv', 'Vie', 'S&aacute;b'],
        dayNamesMin: ['Do', 'Lu', 'Ma', 'Mi', 'Ju', 'Vi', 'S&aacute;']

    	});
    $( "#txtFechaContableFin" ).datepicker({
    		dateFormat: 'dd-mm-yy',
    		monthNames: ['Enero', 'Febrero', 'Marzo', 'Abril', 'Mayo', 'Junio',
            'Julio', 'Agosto', 'Septiembre', 'Octubre', 'Noviembre', 'Diciembre'
        	],
        	dayNames: ['Domingo', 'Lunes', 'Martes', 'Mi&eacute;rcoles', 'Jueves', 'Viernes', 'S&aacute;bado'],
        dayNamesShort: ['Dom', 'Lun', 'Mar', 'Mi&eacute;', 'Juv', 'Vie', 'S&aacute;b'],
        dayNamesMin: ['Do', 'Lu', 'Ma', 'Mi', 'Ju', 'Vi', 'S&aacute;']

    	});
  } );
</script>
</html>
