<table class="ocupacion2" align="center">
<tr><td colspan="2"><h2>Formas de pago</h2></td></tr>
<tr>
<th>Forma de pago</th>
<th>Ingresos (MXN)</th>
</tr>
<?
require("../conectar.php");
//$fi=$_GET["fechaini"];
//$ff=$_GET["fechafin"];
$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>
<?$ingg=$muestr;
$formap=$formap.",^$concepto^";
$datosi=$datosi.",".$ingg;
}
$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>
</table>
<?
 $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>