<?
  session_start();
  require('../valtiempoinact.php');
  require("../conectar.php");
  $usuario_nivel=$_SESSION['usuario_nivel'];
  $usuario_login=$_SESSION['usuario_login'];
?>
<html>
<head>
<title></title>
<!--Evita que muestre signos raros al colocar ñ y acentos -->
<meta content="text/html; charset="iso-8859-1; http-equiv="Content-Type" />  
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

<!--estilo de la tabla      conflictoooooooooooo-->
<link rel="stylesheet" href="style.css"/>

</head>
<body>
			        
					     <caption>
					     <h4><b><center>SELECCIÓN DE DEPARTAMENTO</center></b></h4>
					     </caption>
				     <br><br><br><br><br>
                	<div class="post_section" style="text-align:center;">
                        <p>
						
				      <table width="835" border="0" cellpadding="0" cellspacing="0" class="sortable" id="table">
							    <thead>
								
									<tr>
									  <th width="47" class="nosort"><h6>ID</h6></th>
									  <th width="47" class="nosort"><h6>CLAVE</h6></th>
									  <th width="453"><h6>DESCRIPCIÓN</h6></th>
									  <th width="231"><h6>COMPLEJO</h6></th>
									  <th width="122"><h6>TIPO</h6></th>
									  <th width="126"><h6>INSERTAR TARIFA </h6></th>
								    </tr>
								</thead>
								<tbody>
													  
								 <?php
								
								 $busqueda=mysql_query("select * from departamentos where id_complejo='$_GET[id]' order by id_departamento asc",$db_conexion);
								 								 
								 while($res=mysql_fetch_array($busqueda))
								 {
								 ?>
								    <tr>
										<td><font size="1"><? echo $res['id_departamento']; ?></font></td>
										<td><font size="1"><? echo $res['clave']; ?></font></td>
										<td><font size="1"><? echo substr($res['descripcion'],0,50)."..."; ?></font></td>
										<td><font size="1">
										<? 
										$complejo=mysql_query("select * from complejo where id_complejo='$res[id_complejo]'",$db_conexion);
										if($rom=mysql_fetch_array($complejo))
										{ echo $nombre=$rom['nombre']; }
										?>
										</font></td>
										<td><font size="1"><? echo $res['tipo']; ?></font></td>	
										<td><div align="center"><font size="1">
										<?php
										$tarifa_alta=mysql_query("select count(*) as alta from tarifa_alta where id_departamento='$res[id_departamento]'");
										$alta=mysql_fetch_array($tarifa_alta);
																				
										$tarifa_baja=mysql_query("select count(*) as baja from tarifa_baja where id_departamento='$res[id_departamento]'");
										$baja=mysql_fetch_array($tarifa_baja);
																				
										$tarifa_media=mysql_query("select count(*) as media from tarifa_media where id_departamento='$res[id_departamento]'");
										$media=mysql_fetch_array($tarifa_media);
										
										$tarifa_muybaja=mysql_query("select count(*) as muybaja from tarifa_muybaja where id_departamento='$res[id_departamento]'");
										$muybaja=mysql_fetch_array($tarifa_muybaja);
										
										$total=$alta['alta'] + $baja['baja'] + $media['media'] + $muybaja['muybaja'];
										
										if($total<4)
										{
										?>
									    <a href="tarifas_registro.php?id=<? echo $res['id_departamento']; ?>" target="_blank" onClick="window.open(this.href, this.target, 'scrollbars=yes'); return false;"><img src="images/mod.png" border="0" width="16" height="16"></a>
										<?php
										}
										else
										{
										echo "<font color=#006699>Tarifas Completas</font>";
										}
										?>
										</font></div></td>
									</tr>
									
								  <?								  
								   } // cierre del while
								 ?>
					    </tbody>
					  </table>
					  
							<div id="controls">
								<div id="perpage">
									<select onChange="sorter.size(this.value)">
									    <option value="1">1</option>
										<option value="10" selected="selected">10</option>
										<option value="20">20</option>
										<option value="50">50</option>
										<option value="100">100</option>
									</select>
									<span>Entradas por Página</span>
								</div>
								<div id="navigation">
									<img src="images/first.gif" width="16" height="16" alt="First Page" onClick="sorter.move(-1,true)" />
									<img src="images/previous.gif" width="16" height="16" alt="First Page" onClick="sorter.move(-1)" />
									<img src="images/next.gif" width="16" height="16" alt="First Page" onClick="sorter.move(1)" />
									<img src="images/last.gif" width="16" height="16" alt="Last Page" onClick="sorter.move(1,true)" />
								</div>
								<div id="text">Pagina <span id="currentpage"></span> de <span id="pagelimit"></span></div>
							</div>
							<script type="text/javascript" src="script.js"></script>
							<script type="text/javascript">
								var sorter = new TINY.table.sorter("sorter");
								sorter.head = "head";
								sorter.asc = "asc";
								sorter.desc = "desc";
								sorter.even = "evenrow";
								sorter.odd = "oddrow";
								sorter.evensel = "evenselected";
								sorter.oddsel = "oddselected";
								sorter.paginate = true;
								sorter.currentid = "currentpage";
								sorter.limitid = "pagelimit";
								sorter.init("table",1);
							</script>
					
						</p>                
                    </div>
					
</body>