<?session_start();
$fi=$_GET["fechaini"];
$ff=$_GET["fechafin"];
require("../conectar.php");
require("funciones.php");?>
<!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/gray.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>
<script>
function clientelist(con,fi,ff,x)
{ 
c=1;
e="";
//while(document.getElementById("clientelist"+c)){if(c!=x){ $("#clientelist"+c).html("");} c++;}
$.post("clientelistaff.php",{ id:x,con:con,fi:fi,ff:ff},function(data,status){
$("#clientelist"+x).html(data);
});
}
</script>
</head>
<body>
<center>
<table class="ocupacion2">
<tr><td colspan="2"><h1>Formas de pago</h1></td></tr>
<tr>
<th>Forma de pago</th>
<th>Ingresos (MXN)</th>
</tr>
<?
$concepto=0;$x=0;$cantidad=0;$pes=0;$usds=0;$total=0;$pestot=0;$usdtot=0;
$sql="SELECT p.formapago, sum(p.monto) as mon, sum(p.monto*p.divisa) as moncon, p.tipo_moneda 
FROM conceptos as c 
INNER JOIN pagos as p ON p.id_concepto=c.id_concepto 
WHERE p.concepto IN('RENTA','SEGUIMIENTO') AND (p.fecha BETWEEN '$fi' AND '$ff') AND p.valadmon='s' GROUP BY p.formapago";
$query=mysql_query($sql);
while($usd=mysql_fetch_array($query))
{
$x++;
$pes=0;$usds=0;$concepto=$usd["formapago"];
if($usd["tipo_moneda"]=="USD"){$ingreso=$usd["mon"]+$ingreso;$total=$total+$usd["moncon"];$muestr=$usd["moncon"]; } 
if($usd["tipo_moneda"]=="MXN"){$ingreso=$usd["mon"]+$ingreso;$total=$total+$usd["mon"];$muestr=$usd["mon"]; } 
$usdtot=$usds+$usdtot;
?>
	<tr>
	<td><font align="right"><?echo $concepto?><input type="hidden" name="concepto<?echo$x?>" id="concepto<?echo$x?>" value="<?echo$concepto?>" ></td>
	<td><font align="right"><?echo moneda($muestr);?><input type="hidden" name="ingreso<?echo$x?>" id="ingreso<?echo$x?>" value="<?echo$ingreso?>" ></td>
	</tr>
<?$ing=$muestr;$formap=$formap.",^$concepto^";$datosi=$datosi.",".$ing;
}$fp=strlen($formap);$fp=$fp-1;$formap=substr($formap,-$fp);$lpi=strlen($datosi);$lpi=$lpi-1;$datosi=substr($datosi,-$lpi);
?>
<tr>
<th>Gran Total</th>
<th><?echo "MXN ".moneda($total);?><input type="hidden" name="pestot" id="pestot" value="<?echo$total?>" ></td>
<td></td>
</tr>
<tr><td colspan="2">&nbsp;</td></tr>
<!--<tr><td colspan="2"><a href="graficas/formadepago.php?datos=<?echo$datosi;?>&fpago=<?echo$formap;?>" 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=1170,height=550');return false;"><div class="boton"><font class="db">GRAFICA FORMAS DE PAGO</font></div></a></td></tr>-->
</table>
</center>
<?
 $me=$formap;
 $meses=str_replace("^", "'", $me);
 $datas=$datosi;
?>
<br>

<br>
		<script type="text/javascript">
		
			var chart;
			$(document).ready(function() {
				chart = new Highcharts.Chart({
					chart: {
						renderTo: 'container5',
						defaultSeriesType: 'column',
						marginRight: 200,
						marginBottom: 50
					},
					title: {
						text: 'FORMAS DE PAGO',
						x: -20 //center
					},
					subtitle: {
						text: 'Mexico en Renta',
						x: -20
					},
					xAxis: {
						categories: [<?echo $meses?>]
					},
					yAxis: {
						title: {
							text: 'Cantidad (MXN)'
						},labels: {
								formatter: function() {
									return Math.round(this.value);
								}},
						plotLines: [{
							value: 0,
							width: 1,
							color: '#808080'
						}]
					},
					tooltip: {
						formatter: function() {
				                return '<b>'+ this.series.name +'</b><br/>'+
								this.x +': '+ this.y +' Pesos';
						}
					},
					 plotOptions: {
						column: {
							dataLabels: {
								enabled: true
							}
						}
					}
					,
					legend: {
						layout: 'vertical',
						align: 'right',
						verticalAlign: 'top',
						x: -10,
						y: 100,
						borderWidth: 0
					},
					series:[{name: 'INGRESOS',
						data: [<?echo $datas;?>],
							dataLabels: {
							enabled: true,
							color: '#000',
							align: 'right',
							formatter: function() {
								return this.y;
							},
							style: {
								font: 'normal 9px Verdana, sans-serif'
							}
						}	
						
						}]
				});
				
				
			});
				
		</script>
		<center><div id="container5" style="width: 700px; height: 300px; margin: 0 auto"></div></center>
</body>
</html>