<?
//session_start();
//require('../valtiempoinact.php');
require("../conectar.php");
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
    <head>
        <style>	 
            .tabla{width:100%;background:#ffffff;border-collapse: collapse;font-family:arial;}
			.titulo{height:35px;max-height:35px !important;background:#ffffff url(images/tlcancion.jpg) repeat-x;color:#0d0d0d;font-size:15px;}
			.titulos{height:30px;background:url(images/tcancion.jpg) repeat-x;max-height:30px !important;color:#ffffff;font-size:12px;}
			.nombre{height:28px;background:#0a0a0a;color:#ffffff;text-align:center;font-size:12px;}
			.concepto{height:28px;background:url(images/tcancion.jpg) repeat-x;color:#ffffff;text-align:center;font-size:11px;}
			.inp{width:38px;text-align:right;font-size:10px;}
			.inpd{width:15px;text-align:right;font-size:10px;}
			.tdcal{background:#ffffff;}
			.tdcal:hover .inpd{border:1px;Moz-box-shadow: 0 0 5px 2px #000;-webkit-box-shadow: 0 0 5px 2px #000; box-shadow: 0 0 5px 2px #000;}.act{display:block;overflow:hidden;width:100%;height:50px;background:#BEF781;font-family:arial;font-size:17px;font-weight:bold;color:#4B610B;text-align:center;border:solid 2px #4B610B;-moz-border-radius: 5px;-webkit-border-radius: 5px;border-radius: 5px;-khtml-border-radius: 5px; -Moz-box-shadow: 0px 5px 10px # 556B2F;-webkit-box-shadow: 0px 5px 10px #556B2F; box-shadow: 0px 5px 10px #556B2F;}
			.act p{position:relative;top:0px;}
			.act img{position:relative;width:40px;height:40px;top:-50px;left:250px;}
			 h2{font-family:arial;font-size:16px;}
			.inpof{width:15px;text-align:right;font-size:10px;border:none;}
			.nd{cursor:hand;cursor:pointer;}
			.nd1{font-size:12px;}
			.nd2{font-size:10px;text-align:center;font-weight:bold;}
			.nd3{font-size:11px;text-align:left;font-weight:bold;}
    		.nd4{font-size:13px;text-align:center;font-weight:bold;}
			.nd5{font-size:11px;text-align:center;font-weight:bold;background-color:#0d0d0d;font-family:arial;color:#ffffff;}
			.fila{position:relative;width:30%;}		.subt{z-index:1000;position:fixed;width:100%;height:0px;background:#084B8A;margin-left:0px;margin-rigth:4px;top:0px;background:#045FB4;color:#FFFFFF;text-align:center;}
			.tr1{background:#D8D8D8;}
            .tr2{background:#F2F2F2;}
	        .tr3:hover{background:#01A9DB;color:#ffffff;}	
	        .tr3:hover a{color:#ffffff;}
			.sinfor{text-decoration:none}
        </style>
        <script src="js/jquery-1.8.2.min.js" type="text/javascript"></script>		
	</head>
	<body>
	<?
	if(isset($_POST['guardar'])){
	  $tot=$_POST['tot'];
	  //ALTA
	  $id="id";
	  $anualA="taa";
	  $_5a8A="ta5a8";
	  $_2a4A="ta2a4";
	  $mesA="tam";
	  $semanaA="tas";
	  $nocheA="tan";
	  //MEDIA
	  $idM="idtm";
	  $anualM="tma";
	  $_5a8M="tm5a8";
	  $_2a4M="tm2a4";
	  $mesM="tmm";
	  $semanaM="tms";
	  $nocheM="tmn";
	  //BAJA
	  $idB="idtb";
	  $anualB="tba";
	  $_5a8B="tb5a8";
	  $_2a4B="tb2a4";
	  $mesB="tbm";
	  $semanaB="tbs";
	  $nocheB="tbn";
	  
	  for($i=1;$i<$tot;$i++){
	  //ALTA
	  $ids=$_POST["$id$i"];
	  $anualTA=$_POST["$anualA$i"];
	  $_5a8TA=$_POST["$_5a8A$i"];
	  $_2a4TA=$_POST["$_2a4A$i"];
	  $mesTA=$_POST["$mesA$i"];
	  $semanaTA=$_POST["$semanaA$i"];
	  $nocheTA=$_POST["$nocheA$i"];
	  //MEDIA
	  $idsM=$_POST["$idM$i"];
	  $anualTM=$_POST["$anualM$i"];
	  $_5a8TM=$_POST["$_5a8M$i"];
	  $_2a4TM=$_POST["$_2a4M$i"];
	  $mesTM=$_POST["$mesM$i"];
	  $semanaTM=$_POST["$semanaM$i"];
	  $nocheTM=$_POST["$nocheM$i"];
	  //BAJA
	  $idsB=$_POST["$idB$i"];
	  $anualTB=$_POST["$anualB$i"];
	  $_5a8TB=$_POST["$_5a8B$i"];
	  $_2a4TB=$_POST["$_2a4B$i"];
	  $mesTB=$_POST["$mesB$i"];
	  $semanaTB=$_POST["$semanaB$i"];
	  $nocheTB=$_POST["$nocheB$i"];
	  $sqlA="UPDATE tarifa_alta 
	         SET anual='$anualTA', 5a8='$_5a8TA', 2a4='$_2a4TA', mes='$mesTA', semana='$semanaTA', noche='$nocheTA'
			 where id_tarifaalta='$ids'";
	         mysql_query($sqlA);
	  $sqlM="UPDATE tarifa_media 
	         SET anual='$anualTM', 5a8='$_5a8TM', 2a4='$_2a4TM', mes='$mesTM', semana='$semanaTM', noche='$nocheTM'
			 where id_tarifamedia='$idsM'";
			 mysql_query($sqlM);
	  $sqlB="UPDATE tarifa_baja 
	         SET anual='$anualTB', 5a8='$_5a8TB', 2a4='$_2a4TB', mes='$mesTB', semana='$semanaTB', noche='$nocheTB'
			 where id_tarifa='$idsB'";
			 mysql_query($sqlB);
	  }
	}
	
	  require('../conectar.php');
	  $sql="SELECT p.nombre AS propiedad,
	               d.no_depto AS no,
 				   d.clave  AS clave,
				   d.id_departamento
			FROM departamentos AS d 
	        INNER JOIN complejo as p 
			ON d.id_complejo=p.id_complejo 
			order by p.id_complejo=22,p.id_complejo=21,
			p.id_complejo='14',
			p.id_complejo='6',
			p.id_complejo='5',
			p.id_complejo='1',
			p.id_complejo='3',
			p.id_complejo='2',
			p.id_complejo='4',
			d.no_depto, d.tipo ASC";
    ?>
<form action="tarifas_modificar2.php" method="POST">
 <table border="0" class="subt">
    <tr>
	  <td width="18%"></td>
	  <td width="21%" style="background-color:#319300" class="nd4">TARIFA RACK 76% al 100% Ocupacion</td>
	  <td width="5%"></td>
	  <td width="21%" style="background-color:#F781BE" class="nd4">TARIFA STANDAR 41% al 75% Ocupacion</td>
	  <td width="5%"></td>
	  <td width="21%" style="background-color:#F89E18" class="nd4">TARIFA PROMOCION 0% al 40% Ocupacion</td>
	</tr>
</table>
<br>

<br>
<table width="100%" border="0">
    <?
$r=mysql_query($sql);
$nprop="";
$n=1;
$f=1;
$c="";
while($ls=mysql_fetch_array($r)){
                        $iddepto=$ls['id_departamento'];
                        if($f==1){$f=2;}else{$f=1;}
					     if($nprop!=$ls["propiedad"]){
				        ?>
						  <tr>
						    <td></td>
                            <?
							 for($i=1;$i<4;$i++){?>
							    <td colspan="6" class="nd5"><?echo $ls["propiedad"]?></td>
								<?if($i<3){?>
								<td width="5%"></td>
							 <?}}
							?>
						  </tr>
				                <?$nprop=$ls["propiedad"];?>
						 <tr>
						    <td class="nd3">DEPTO</td>
							<td class="nd2">ANUAL</td>
							<td class="nd2">5 a 8</td>
							<td class="nd2">2 a 4</td>
							<td class="nd2">MES</td>
							<td class="nd2">SEMANA</td>
							<td class="nd2">NOCHE</td>
							<td width="5%"></td>
							
							<td class="nd2">ANUAL</td>
							<td class="nd2">5 a 8</td>
							<td class="nd2">2 a 4</td>
							<td class="nd2">MES</td>
							<td class="nd2">SEMANA</td>
							<td class="nd2">NOCHE</td>
							<td width="5%"></td>
							
							<td class="nd2">ANUAL</td>
							<td class="nd2">5 a 8</td>
							<td class="nd2">2 a 4</td>
							<td class="nd2">MES</td>
							<td class="nd2">SEMANA</td>
							<td class="nd2">NOCHE</td>
						 </tr>	
								<?}?>
						  <tr class="tr<?echo $f;?>"> <!--tr3<?echo $c?>">-->
						    <td class="nd1">
							<a href="detalle.php?iddepto=<?echo$iddepto;?>&depto=<?echo $ls['no']." (".$ls['clave'].")";?>&prop=<?echo$nprop;?>" target="_blank" onClick="window.open(this.href, this.target, 'width=300,height=400'); return false;" class="sinfor" style="color:#000">
                         <?
						    // if($nprop=="CASA TIZTIK"){$nprop="TIZTIK";}
						     $arr=explode(" ",$nprop);
							 for($i=0;$i<count($arr);$i++){
							     if(substr($arr[$i], 0, 1)=="C"){echo "";}else{echo substr($arr[$i], 0, 1);}
							 } echo $ls['no']." (".$ls['clave'].")";?></a>
							</td>
						<?	 
							 $sqlta="SELECT * from tarifa_alta where id_departamento='$ls[id_departamento]'";
							 $ejeta=mysql_query($sqlta);
							 $ta=mysql_fetch_array($ejeta);
						?>   
						     <input type="hidden" name="id<?echo $n;?>" value="<?echo$ta['id_tarifaalta'];?>" class="inp">
						     <td><input type="text" name="taa<?echo $n;?>" value="<?echo$ta['anual'];?>" class="inp"></td>
							 <td><input type="text" name="ta5a8<?echo $n;?>" value="<?echo$ta['5a8'];?>" class="inp"></td>
							 <td><input type="text" name="ta2a4<?echo $n;?>" value="<?echo$ta['2a4'];?>" class="inp"></td>
							 <td><input type="text" name="tam<?echo $n;?>" value="<?echo$ta['mes'];?>" class="inp"></td>
							 <td><input type="text" name="tas<?echo $n;?>" value="<?echo$ta['semana'];?>" class="inp"></td>
                             <td><input type="text" name="tan<?echo $n;?>" value="<?echo$ta['noche'];?>" class="inp"></td> 
						<?	 
							 $sqltm="SELECT * from tarifa_media where id_departamento='$ls[id_departamento]'";
							 $ejetm=mysql_query($sqltm);
							 $tm=mysql_fetch_array($ejetm);
						?>
						     <td width="5%"></td>
							 <input type="hidden" name="idtm<?echo $n;?>" value="<?echo$tm['id_tarifamedia'];?>" class="inp">
							 <td><input type="text" name="tma<?echo $n;?>" value="<?echo$tm['anual'];?>" class="inp"></td>
							 <td><input type="text" name="tm5a8<?echo $n;?>" value="<?echo$tm['5a8'];?>" class="inp"></td>
							 <td><input type="text" name="tm2a4<?echo $n;?>" value="<?echo$tm['2a4'];?>" class="inp"></td>
							 <td><input type="text" name="tmm<?echo $n;?>" value="<?echo$tm['mes'];?>" class="inp"></td>
							 <td><input type="text" name="tms<?echo $n;?>" value="<?echo$tm['semana'];?>" class="inp"></td>
							 <td><input type="text" name="tmn<?echo $n;?>" value="<?echo$tm['noche'];?>" class="inp"></td>							 
						<?	 
							 $sqltb="SELECT * from tarifa_baja where id_departamento='$ls[id_departamento]'";
							 $ejetb=mysql_query($sqltb);
							 $tb=mysql_fetch_array($ejetb);
						?>
						     <td width="5%"></td>
							 <input type="hidden" name="idtb<?echo $n;?>" value="<?echo$tb['id_tarifa'];?>" class="inp">
                             <td><input type="text" name="tba<?echo $n;?>" value="<?echo$tb['anual'];?>" class="inp"></td>
							 <td><input type="text" name="tb5a8<?echo $n;?>" value="<?echo$tb['5a8'];?>" class="inp"></td>
							 <td><input type="text" name="tb2a4<?echo $n;?>" value="<?echo$tb['2a4'];?>" class="inp"></td>
							 <td><input type="text" name="tbm<?echo $n;?>" value="<?echo$tb['mes'];?>" class="inp"></td>
							 <td><input type="text" name="tbs<?echo $n;?>" value="<?echo$tb['semana'];?>" class="inp"></td>
							 <td><input type="text" name="tbn<?echo $n;?>" value="<?echo$tb['noche'];?>" class="inp"></td>
						   </tr>
				         <?
						 $n++;
						 if($c==""){$c="1";}else{$c="";}
				     }
		?>
		<input type="hidden" name="tot" value="<?echo $n;?>">
		<tr class="tr1">
		  <td></td>
		  <td colspan="6" class="nd5">EXTRAS</td>
		</tr>
		<tr>
						    <td class="nd3"></td>
							<td class="nd2"></td>
							<td class="nd2"></td>
							<td class="nd2"></td>
							<td class="nd2">MES</td>
							<td class="nd2">SEMANA</td>
							<td class="nd2">NOCHE</td>
 
		</tr>
		<tr class="tr1">
		  <td class="nd1">PERSONA EXTRA</td>
		  <td></td>
		  <td></td>
		  <td></td>
		  <td class="nd2">120</td>
		  <td class="nd2">35</td>
		  <td class="nd2">5</td>		
		</tr>
		<tr class="tr2">
		  <td class="nd1">ESTACIONAMIENTO</td>
		  <td></td>
		  <td></td>
		  <td></td>
		  <td class="nd2">240</td>
		  <td class="nd2">60</td>
		  <td class="nd2">10</td>		
		</tr>
		<tr class="tr1">
		  <td class="nd1">CAMA EXTRA</td>
		  <td></td>
		  <td></td>
		  <td></td>
		  <td class="nd2">130</td>
		  <td class="nd2">75</td>
		  <td class="nd2">15</td>		
		</tr>
		<tr class="tr2">
		  <td class="nd1">MASCOTA</td>
		  <td></td>
		  <td></td>
		  <td></td>
		  <td class="nd2">100</td>
		  <td class="nd2">35</td>
		  <td class="nd2">10</td>		
		</tr>
		<tr class="tr1">
		  <td class="nd1">CUNA</td>
		  <td></td>
		  <td></td>
		  <td></td>
		  <td class="nd2"></td>
		  <td class="nd2"></td>
		  <td class="nd2">5</td>		
		</tr>
		<tr class="tr2">
		  <td class="nd1">LIMPIEZA</td>
		  <td></td>
		  <td></td>
		  <td></td>
		  <td class="nd2"></td>
		  <td class="nd2"></td>
		  <td class="nd2">15</td>		
		</tr>
		<tr class="tr1">
		  <td class="nd1">BLANCOS</td>
		  <td></td>
		  <td></td>
		  <td></td>
		  <td class="nd2">50</td>
		  <td class="nd2"></td>
		  <td class="nd2"></td>		
		</tr>
		<tr><td colspan="21" align="center"><input type="submit" name="guardar" value="guardar"></td></tr>
	</table>
</form>
	</body>
</html>
