<?php include "../index/conexion.inc" ?>
<?php include "../index/validacion.php" ?>
<?php
	$cV01 = $_POST['v1'];	/* DESDE */
	$cV02 = $_POST['v2'];	/* HASTA */
?>
<?php
	// conexión
	$servername = $svr_servidor;
	$conectioninfo = array("Database"=>$svr_base, "UID"=>$svr_usuario, "PWD"=>$svr_contrasena, "CharacterSet"=>"UTF-8");
	$conexion = sqlsrv_connect($servername, $conectioninfo);
	if ($conexion == false)
	{
		$mensaje = "Existe un error al intentar conectarse con el servidor...";
	}
	else
	{
		// CONSULTA SQL
		$sql= "EXECUTE JOIN_DEPOSITOS_REPOR01 '".$cV01."' , '".$cV02."'";
		$pa1 = array();
		$op1 = array("scrollable" => SQLSRV_CURSOR_KEYSET);
		// Lanzar la consulta
		$re1 = sqlsrv_query($conexion, $sql, $pa1, $op1);
		if (sqlsrv_num_rows($re1) != 0)
		{
			echo "
			<div class='x_panel'>
				<div class='x_title'>
					<h3>Depositos Autorizados</h3>
					<div class='clearfix'></div>
				</div>
				<button type='submit' class='btn btn-success'>
					<span class='glyphicon glyphicon-export' aria-hidden='true'></span> Exportar a excel
				</button>
				<div class='table-responsive'>
					<table id='example' class='table table-striped table-bordered' style='width:100%'>
						<thead>
							<tr>
								<th>FECHA</th>
								<th>CODCLIENTE</th>
								<th>BANCO</th>
								<th>DEPOSITOC</th>
								<th>VALORC</th>
								<th>DOCENTRY</th>
								<th>ID</th>
								<th>FECHA_ACCION</th>
								<th>HORA_ACCION</th>
								<th>NOMVENDEDOR</th>
							</tr>
						</thead>
						<tbody>";
						while($fila = sqlsrv_fetch_array($re1))
						{
							echo "
								<tr>
									<td>".$fila['FECHA']->format('Y-m-d')."</td>
									<td>".$fila['CODCLIENTE']."</td>
									<td>".$fila['BANCO']."</td>
									<td>".$fila['DEPOSITOC']."</td>
									<td>".$fila['VALORC']."</td>
									<td>".$fila['DOCENTRY']."</td>
									<td>".$fila['ID']."</td>
									<td>".$fila['FECHA_ACCION']."</td>
									<td>".$fila['HORA_ACCION']."</td>
									<td>".$fila['NOMVENDEDOR']."</td>
								</tr>
							";
						}
						echo "
						</tbody>
					</table>
				</div>
			</div>
			";
		}
		else
		{
			echo "
			<div class='alert alert-warning alert-dismissible fade in' role='alert'>
			<button type='button' class='close' data-dismiss='alert' aria-label='Close'><span aria-hidden='true'>×</span>
			</button>
				Registros <strong>NO</strong> localizados.
			</div>
			";
		}
		sqlsrv_free_stmt($re1);
	}
	sqlsrv_close($conexion);
?>
<script>
	$(document).ready(function() {
		$('#example').DataTable();
	} );
</script>