<?php if(!isset($_SESSION)){session_start();} ////// EMPIEZA CODIGO PARA VERIFICAR LOGEO
$MM_authorizedUsers = "";
$MM_donotCheckaccess = "true";
function isAuthorized($strUsers, $strGroups, $UserName, $UserGroup) { 
  // For security, start by assuming the visitor is NOT authorized. 
  $isValid = False;
  // When a visitor has logged into this site, the Session variable MM_Username set equal to their username. 
  // Therefore, we know that a user is NOT logged in if that Session variable is blank. 
  if (!empty($UserName)) { 
    // Besides being logged in, you may restrict access to only certain users based on an ID established when they login. 
    // Parse the strings into arrays. 
    $arrUsers = Explode(",", $strUsers); 
    $arrGroups = Explode(",", $strGroups); 
    if (in_array($UserName, $arrUsers)) { $isValid = true; } 
    // Or, you may restrict access to only certain users based on their username. 
    if (in_array($UserGroup, $arrGroups)) { $isValid = true; } 
    if (($strUsers == "") && true) { $isValid = true;  }  } 
  return $isValid; }
$MM_restrictGoTo = "index.php?banned";
if (!((isset($_SESSION['MM_Username'])) && (isAuthorized("",$MM_authorizedUsers, $_SESSION['MM_Username'], $_SESSION['MM_UserGroup'])))) {   
  $MM_qsChar = "?";
  $MM_referrer = $_SERVER['PHP_SELF'];
  if (strpos($MM_restrictGoTo, "?")) $MM_qsChar = "&";
  if (isset($QUERY_STRING) && strlen($QUERY_STRING) > 0) 
  $MM_referrer .= "?" . $QUERY_STRING;
  $MM_restrictGoTo = $MM_restrictGoTo. $MM_qsChar . "accesscheck=" . urlencode($MM_referrer);
  header("Location: ". $MM_restrictGoTo); 
  exit;} ////// TERMINA CODIGO PARA VERIFICAR LOGEO

	require_once('Connections/nosotros_connection.php');	
	include_once "nosotros.php";

	include("header.html");
	include("menu.html");
?>

	//desarrollar el cdodigo debajo de este comentario 

<div class='container'>	
    <div class='row'>
		<h1>Listado de Viajes</h1>
<?php
/*
	$user=$_SESSION['MM_Username'];
	$sql ="SELECT * FROM `ingreso` WHERE `user` LIKE '$user' LIMIT 0 , 30";
	$resultado0 = mysqli_query($odonto_connection,$sql);
	$fila0 = mysqli_fetch_assoc($resultado0);
	$id_user = $fila0['id_user']; */
	
	$sql ="SELECT * FROM  `viajes` ORDER BY fecha ASC";
	$resultado = mysqli_query($odonto_connection,$sql);
	if (!$resultado)
	{ reportarErrorSQL($sql);
	return;} 
	
	if(mysqli_num_rows($resultado)==0)
	echo "No hay viajes pendientes";
	else
	{
	
		echo '<div>';
		echo '<button id="exportarExcel" class="btn btn-primary">Exportar</button>';
		echo "</div><br>";
		echo '<div class="table-responsive">';
		echo '<table class="table table-hover table-bordered">';
		echo "<thead>";
		echo "<th>N&deg; Ref</th>";
		echo "<th> Fecha Inicio </th>";
		echo "<th> Destinos </th>";
		echo "<th> Cantidad Reservas </th>";
		echo "<th> Cantidad Pasajeros </th>";
		echo "<th></th>";
		echo "</thead>";
		echo "<tbody>";
/*
		while ($fila = mysql_fetch_assoc($resultado))
		{
			echo "<tr class=\"hover\">";
			//echo '<td><input type="checkbox" name="idausentismo[]" value="' . $fila["idausentismo"] . '" class="idausentismo" /></td>';
			echo "<td align=\"right\">" . $fila["idausentismo"] . "</td>";
			$apellido=textToHTML( $fila["apellido"] );
			$nombre=textToHTML( $fila["nombre"] );
			$sexo=textToHTML( $fila["sexo"] );
			$ciudad=textToHTML( $fila["ciudad"] );
			$provincia=textToHTML( $fila["provincia"] );
			//$telefono=textToHTML( $fila["telefonocontacto"] );
			$legajo=$fila["legajo"];
			$razonsocial=textToHTML( $fila["razonsocial"] );
			//$domicilio=textToHTML( $fila["domiciliocontacto"] );
			$comentario=textToHTML( $fila["comentario"] );
			$fechainicio=fechaDBToSystem( $fila["fechainicio"] );
			echo "<td>$fechainicio</td>";
			echo "<td>$legajo</td>";
			echo "<td>$apellido</td>";
			echo "<td>$nombre</td>";
			echo "<td>$comentario</td>";
			echo '<td><a href="javascript:cargarDiagnosticoPorAusentismo(' . $fila["idausentismo"] . ');">Detalles</a></td>';
			echo "</tr>";
		}
*/
		while ($fila = mysqli_fetch_assoc($resultado))
		{
		
		echo "<tr class=\"hover\">";
			echo "<td align=\"right\">".$fila['id_viaje']."</td>";
			echo "<td>".$fila['fecha']."</td>";
			echo "<td>".$fila['detalle']."</td>";
			echo "<td align=\"center\">0</td>";
			echo "<td align=\"center\">0</td>";
			$id_viaje=$fila['id_viaje'];
			echo "<td align=\"center\"><a href=\"javascript:verDetalleViaje($id_viaje);\">Detalles</a></td>";
			echo "<td align=\"center\"><a href=\"detalle_viaje_ajax.php?id_viaje=$id_viaje\">Editar</a></td>";
		echo "</tr>";
		}
		
		
		echo "</tbody></table>";
		echo "</div>";
//		mysql_free_result($resultado);
	}
?>

</div>	
</div>	
<?php
	include("footer.html");
?>
