<?php include('meta.php') ?>
<?php $bg_header = "bg_sala"; include('header.php') ?>
<style type="text/css">
  #box_html{
    width: 1024px;
  }
</style>
<script type="text/javascript">
	// haces referencia al elemento (en este caso div) e indicas el tiempo de espera en segundos
	var strCmd = "document.getElementById('alert').style.display = 'none'";
	var waitseconds = 4;
	// Calculas el tiempo en milisegundos y ejecutas la acción
	var timeOutPeriod = waitseconds * 800;
	var hideTimer = setTimeout(strCmdtimeOutPeriod);
	$(document).ready(function() {
    $('#allpatient').DataTable( {
    	"iDisplayLength": 50,
    	 "order": [[ 4"asc" ]],
        "language": {
        	"search": "Buscar:",
        	"lengthMenu":    "Mostrar _MENU_  productos en la tabla",
            "info":           "Mostrando de [ _START_ -  _END_ ] de un total de  _TOTAL_ registros",
            "infoEmpty":      "No hay elementos en la tabla"      
            "infoPostFix":    "",
            "infoFiltered": "(filtered from _MAX_ total records)",
            "loadingRecords": "Cargando registros...",
            "zeroRecords":    "No hay elementos en la tabla",
            "emptyTable":     "No hay elementos en la tabla",
            "paginate": {
            			"first":      "Primero",
            			"previous":   "Anterior",
            			"next":       "Siguiente",
            			"last":       "&Uacuteltimo"
            			},
        }
	} );
} );
</script>
<?php
	if ($_GET['update'] == 'ok'){
       		 echo "<div id='alert' class='alert alert-success'><strong>Actualización exitosa</strong></div>";
            };

 ?>

	<div id="box_body"><!-- body center -->
		<br /><span class="big_title_h2">Listado de citas por día</span>
				
		<!-- ver cita por dia y listado -->
		<?php
		    if(isset($_POST['day_view'])) { 
				$day_view = $_POST['day_view'];
		   		$month_view= $_POST['month_view'];
		    	$year_view = $_POST['year_view'];
			} else {
				$day_view = $_GET['day_view'];
		   		$month_view= $_GET['month_view'];
		    	$year_view = $_GET['year_view'];
			};
		    $date4 = $year_view."-".$month_view."-".$day_view;
		    if($day_view != "0"){
		    	echo "<br /><span class='big_title'><strong>día:</strong> ".$day_view." del mes ".$month_view." del ".$year_view."</span><br /><br />";	
		    	$result = mysqli_query($con,"SELECT * FROM se_evenement WHERE start LIKE '$date4%' ORDER BY name");

					echo "<table id='allpatient' class='display table table-hover'> \n"; 
					echo "
					<thead>
						<tr>
						<th>Nombre</th>
						<th>Tipo de cita </th>
						<th>Teléfono</th>
						<th>Comentario</th>
						<th>Fecha y hora</th>
						<th>Estado</th>
						<th></th>
						</tr>
					</thead>
					<tbody>	\n"; 
					while ($row = mysqli_fetch_row($result))
					{ 
						echo "<tr> 
								<form name='form3' method='post' action='reports_list_update.php' >
								<input type='hidden' name='day_view' value='$day_view'>
								<input type='hidden' name='month_view' value='$month_view'>
								<input type='hidden' name='year_view' value='$year_view'>	
								<td><input type='hidden' name='id' value='$row[0]'> 
								<strong>$row[1]</strong></td>
								<td>$row[36]</td>
						      	<td>$row[29]</td>
						      	<td><input type='text' name='comments' value='$row[37]'></td>
						      	<td>$row[4]</td>
						      	<td><select name='status'>
									<option value='$row[27]' selected>$row[27]</option>
									<option></option>
									<option value='Sala de espera'>Sala de espera</option>
									<option value='Reagendado'>Reagendado</option>
								    <option value='Confirmada'>Confirmada</option>
								    <option value='Cancelada'>Cancelada</option>
								    <option value='No contesta'>No contesta</option>
								    </select>
						      	</td>
						      	<td><input type='submit' class='btn btn-warning' value='Guardar'></td>

						      </tr></form>";
					};
					echo " \n"; 
					echo " </tbody></table> \n";
					echo " <br>";
					 }		    
		?>
	</div><!-- END body center -->
<?php include('../footer.php') ?>