<?session_start();
$fi=$_GET["fechaini"];
$ff=$_GET["fechafin"];
require("../conectar.php");
require("funciones.php");
$idpropiedad=$_GET['id'];
$propiedad=$_GET['propiedad'];
?>
<!doctype html>
<html>
<head>
<title>Tipo de renta</title>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>		
<script type="text/javascript" src="js/highcharts.js"></script>			
<script type="text/javascript" src="js/modules/exporting.js"></script>
<script type="text/javascript" src="js/themes/grid.js"></script>
<link rel="stylesheet" type="text/css" href="css/estiloorg.css" />
	<style type="text/css">
        p.ps{ font-size:9px;height:7px; }
	.ps:hover{ font-size:10px; background:#487f1a;}	
	
.ocupacion {
	-webkit-box-shadow: 5px 5px #000000;
	box-shadow: 5px 5px #000000;
	font-family: Cambria, "Hoefler Text", "Liberation Serif", Times, "Times New Roman", serif;
}

.ocupacion td {
	text-align: center;
	border-collapse: separate;
	background-color: #E6E6E6;
	color: #000000;
	border-top: thin solid #000000;
	border-bottom: thin solid #000000;
	border-left:thin solid #000000;
	border-right:thin solid #000000;
}
.ocupacion tr th {
	text-align: center;
	border-collapse: separate;
	background-color: #000000;
	border-left:thin solid #ffffff;
	border-top: thin solid #000000;
	border-bottom: thin solid #000000;
	border-right:thin solid #ffffff;
}
.ocupacion input {
	background-color: #E6E6E6;
	border-style: none;
	text-align: center;
	color: #000000;
	width:60px;
}


.ocupacion2 {
	-webkit-box-shadow: 5px 5px #000000;
	box-shadow: 5px 5px #000000;
	font-family: Cambria, "Hoefler Text", "Liberation Serif", Times, "Times New Roman", serif;
}

.ocupacion2 td {
	text-align: right;
	border-collapse: separate;
	background-color: #E6E6E6;
	color: #000000;
	border-top: thin solid #000000;
	border-bottom: thin solid #000000;
	border-left:thin solid #000000;
	border-right:thin solid #000000;
}
.ocupacion2 tr th {
	text-align: center;
	border-collapse: separate;
	background-color: #000000;
	border-left:thin solid #ffffff;
	border-top: thin solid #000000;
	border-bottom: thin solid #000000;
	border-right:thin solid #ffffff;
}
.ocupacion2 input {
	background-color: #E6E6E6;
	border-style: none;
	text-align: center;
	color: #000000;
	width:60px;
}

               a{text-decoration:none;outline:none;}
               .boton{margin-left:2px;margin-right:2px;float:left;width:100px;height:30px;background: url(images/bkbtn.png) no-repeat;color:#000;font-weight:bold;font-size:10px;text-align:center;text:decoration:none !important;}
               .boton:hover{background-position: left bottom;}
               .boton .d{position:relative;margin:auto;top:8px;font-size:9px;}
               .boton .db{position:relative;margin:auto;top:5px;font-size:9px;}
               .boton .n{position:relative;margin:auto;top:8px;}
	</style>
</head>
<body>

<center>
<table border="1">
<tr>
   <td colspan="3"><CENTER><h1>INCIDENTES <?echo $propiedad;?></h1><CENTER></td></tr>
<tr>
<TD>
<table class="ocupacion2">
<tr>
   <td colspan="3"><CENTER><B>SERVICIOS</B></CENTER></td></tr>
<tr>
<th>Categoria</th>
<th>Subcategoria</th>
<th>Total</th>
</tr>
<?
$sql="SELECT COUNT(p.subcategoria) as cuantos,p.categoria,p.subcategoria
FROM pendientes as p  
WHERE (p.fecha_ingreso BETWEEN '$fi' AND '$ff') AND p.propiedad='$idpropiedad' and p.categoria='SERVICIOS' GROUP BY p.subcategoria";
$query=mysql_query($sql);
while($usd=mysql_fetch_array($query))
{
$categoria=$usd["categoria"];
$concepto=$usd["subcategoria"];
$cuantos=$usd['cuantos'];
$total=$total+$cuantos;
?>
	<tr>
	<td><font align="right"><?echo $categoria?></td>
	<td><font align="right"><?echo $concepto?></td>
	<td><font align="right"><?echo $cuantos;?></td>
	</tr>
<?
    $val=$val.",".$cuantos;
	$lc=strlen($val);
	$lc=$lc-1;
	$val=substr($val,-$lc);
	$totg=",{name:^$concepto^,data:[$val]}";
	$totgg=$totgg.$totg;
	$val="";

}
    $ltg=strlen($totgg);
	$ltg=$ltg-1;
    $datacl=substr($totgg,-$ltg);
    $va=$datacl;
    $val=str_replace("^", "'", $va);
?>
<tr>
<th></th>
<th>Gran Total</th>
<th><a href="detallereportependientes.php?fechaini=<? echo $fi;?>&fechafin=<?echo $ff;?>&id=<?echo $idpropiedad;?>&propiedad=<?echo $propiedad;?>&tipo=SERVICIOS" target="_blank" onClick="window.open(this.href, this.target, 'toolbar=no,location=no,directories=no,status=yes,menubar=yes,scrollbars=yes,resizable=yes,top=0,left=0,width=900,height=700'); return false;"><?echo $total;?></a></th>
<td></td>
</tr>
<tr><td colspan="3"><script>
		<!-- 2. Add the JavaScript to initialize the chart on document ready -->		
			var chart;
			$(document).ready(function() {
				chart = new Highcharts.Chart({
					chart: {
						renderTo: 'container',
						defaultSeriesType: 'column',
						marginRight: 200,
						marginBottom: 50
					},
					title: {
						text: 'INCIDENTES CATEGORIA SERVICIOS',
						x: -20 //center
					},
					subtitle: {
						text: 'Mexico en Renta',
						x: -20
					},
					xAxis: {
						categories: ['Total']
					},
					yAxis: {
						title: {
							text: 'Numero de Incidentes'
						},
						plotLines: [{
							value: 0,
							width: 1,
							color: '#808080'
						}]
					},
					tooltip: {
						formatter: function() {
				                return '<b>'+ this.series.name +'</b><br/>'+
								this.x +': '+ this.y +'';
						}
					},
					 plotOptions: {
						column: {
							dataLabels: {
								enabled: true
							}
						}
					},
					legend: {
						layout: 'vertical',
						align: 'right',
						verticalAlign: 'top',
						x: -10,
						y: 100,
						borderWidth: 1
					},
					series: [<?echo $val;?>]
				});
				
				
			});
</script>
		<center><div id="container" style="width: 700px; height: 300px;"></div></center></td></tr>
</table>
</TD>

<tr>
<TD>
<table class="ocupacion2">
<tr>
   <td colspan="3"><CENTER><B>MANTENIMIENTO</B></CENTER></td>
 </tr>
<tr>
<th>Categoria</th>
<th>Subcategoria</th>
<th>Total</th>
</tr>
<tr><td></td></tr>
<?
$total=0;
$sql="SELECT COUNT(p.subcategoria) as cuantos,p.categoria,p.subcategoria
FROM pendientes as p  
WHERE (p.fecha_ingreso BETWEEN '$fi' AND '$ff') AND p.propiedad='$idpropiedad' and p.categoria='MANTENIMIENTO' GROUP BY p.subcategoria";
$query=mysql_query($sql);
while($usd=mysql_fetch_array($query))
{
$categoria=$usd["categoria"];
$concepto=$usd["subcategoria"];
$cuantos=$usd['cuantos'];
$total=$total+$cuantos;
?>
	<tr>
	<td><font align="right"><?echo $categoria?></td>
	<td><font align="right"><?echo $concepto?></td>
	<td><font align="right"><?echo $cuantos;?></td>
	</tr>
<?
    $valM=$valM.",".$cuantos;
	$lcM=strlen($valM);
	$lcM=$lcM-1;
	$valM=substr($valM,-$lcM);
	$totgM=",{name:^$concepto^,data:[$valM]}";
	$totggM=$totggM.$totgM;
	$valM="";

}
    $ltg=strlen($totgg);
	$ltg=$ltg-1;
    $datacl=substr($totgg,-$ltg);
	
    $ltgM=strlen($totggM);
	$ltgM=$ltgM-1;
    $dataclM=substr($totggM,-$ltgM);
    $vaM=$dataclM;
    $valM=str_replace("^", "'", $vaM);
?>
<tr>
<th></th>
<th>Gran Total</th>
<th><a href="detallereportependientes.php?fechaini=<? echo $fi;?>&fechafin=<?echo $ff;?>&id=<?echo $idpropiedad;?>&propiedad=<?echo $propiedad;?>&tipo=MANTENIMIENTO" target="_blank" onClick="window.open(this.href, this.target, 'toolbar=no,location=no,directories=no,status=yes,menubar=yes,scrollbars=yes,resizable=yes,top=0,left=0,width=900,height=700'); return false;"><?echo $total;?></a></th>
</tr>
<tr><td colspan="3">&nbsp;</td></tr>
<tr>
<td colspan="3">
<script>
		<!-- 2. Add the JavaScript to initialize the chart on document ready -->		
			var chart;
			$(document).ready(function() {
				chart = new Highcharts.Chart({
					chart: {
						renderTo: 'container2',
						defaultSeriesType: 'column',
						marginRight: 200,
						marginBottom: 50
					},
					title: {
						text: 'INCIDENTES CATEGORIA MANTENIMIENTO',
						x: -20 //center
					},
					subtitle: {
						text: 'Mexico en Renta',
						x: -20
					},
					xAxis: {
						categories: ['Total']
					},
					yAxis: {
						title: {
							text: 'Numero de Incidentes'
						},
						plotLines: [{
							value: 0,
							width: 1,
							color: '#808080'
						}]
					},
					tooltip: {
						formatter: function() {
				                return '<b>'+ this.series.name +'</b><br/>'+
								this.x +': '+ this.y +'';
						}
					},
					 plotOptions: {
						column: {
							dataLabels: {
								enabled: true
							}
						}
					},
					legend: {
						layout: 'vertical',
						align: 'right',
						verticalAlign: 'top',
						x: -10,
						y: 100,
						borderWidth: 1
					},
					series: [<?echo $valM;?>]
				});
				
				
			});
</script>
		<center><div id="container2" style="width: 700px; height: 300px;"></div></center></td></tr>
</table>
</TD>
</tr>

<tr>
<TD>
<table class="ocupacion2">
<tr>
   <td colspan="3"><CENTER><B>LIMPIEZA</B></CENTER></td>
 </tr>
<tr>
<th>Categoria</th>
<th>Subcategoria</th>
<th>Total</th>
</tr>
<tr><td></td></tr>
<?
$total=0;
$sql="SELECT COUNT(p.subcategoria) as cuantos,p.categoria,p.subcategoria
FROM pendientes as p  
WHERE (p.fecha_ingreso BETWEEN '$fi' AND '$ff') AND p.propiedad='$idpropiedad' and p.categoria='LIMPIEZA' GROUP BY p.subcategoria";
$query=mysql_query($sql);
while($usd=mysql_fetch_array($query))
{
$categoria=$usd["categoria"];
$concepto=$usd["subcategoria"];
$cuantos=$usd['cuantos'];
$total=$total+$cuantos;
?>
	<tr>
	<td><font align="right"><?echo $categoria?></td>
	<td><font align="right"><?echo $concepto?></td>
	<td><font align="right"><?echo $cuantos;?></td>
	</tr>
<?
    $valL=$valL.",".$cuantos;
	$lcL=strlen($valL);
	$lcL=$lcL-1;
	$valL=substr($valL,-$lcL);
	$totgL=",{name:^$concepto^,data:[$valL]}";
	$totggL=$totggL.$totgL;
	$valL="";

}	
    $ltgL=strlen($totggL);
	$ltgL=$ltgL-1;
    $dataclL=substr($totggL,-$ltgL);
    $vaL=$dataclL;
    $valL=str_replace("^", "'", $vaL);
?>
<tr>
<th></th>
<th>Gran Total</th>
<th><a href="detallereportependientes.php?fechaini=<? echo $fi;?>&fechafin=<?echo $ff;?>&id=<?echo $idpropiedad;?>&propiedad=<?echo $propiedad;?>&tipo=LIMPIEZA" target="_blank" onClick="window.open(this.href, this.target, 'toolbar=no,location=no,directories=no,status=yes,menubar=yes,scrollbars=yes,resizable=yes,top=0,left=0,width=900,height=700'); return false;"><?echo $total;?></a></th>
</tr>
<tr><td colspan="3">&nbsp;</td></tr>
<tr>
<td colspan="3">
<script>
		<!-- 2. Add the JavaScript to initialize the chart on document ready -->		
			var chart;
			$(document).ready(function() {
				chart = new Highcharts.Chart({
					chart: {
						renderTo: 'container3',
						defaultSeriesType: 'column',
						marginRight: 200,
						marginBottom: 50
					},
					title: {
						text: 'INCIDENTES CATEGORIA LIMPIEZA',
						x: -20 //center
					},
					subtitle: {
						text: 'Mexico en Renta',
						x: -20
					},
					xAxis: {
						categories: ['Total']
					},
					yAxis: {
						title: {
							text: 'Numero de Incidentes'
						},
						plotLines: [{
							value: 0,
							width: 1,
							color: '#808080'
						}]
					},
					tooltip: {
						formatter: function() {
				                return '<b>'+ this.series.name +'</b><br/>'+
								this.x +': '+ this.y +'';
						}
					},
					 plotOptions: {
						column: {
							dataLabels: {
								enabled: true
							}
						}
					},
					legend: {
						layout: 'vertical',
						align: 'right',
						verticalAlign: 'top',
						x: -10,
						y: 100,
						borderWidth: 1
					},
					series: [<?echo $valL;?>]
				});
				
				
			});
</script>
		<center><div id="container3" style="width: 700px; height: 300px;"></div></center></td></tr>
</table>
</TD>
</tr>




</tr>
</TABLE>
</center>
</body>
</html>