HEX
Server: Apache
System: Linux iad1-shared-e1-19 6.6.49-grsec-jammy+ #10 SMP Thu Sep 12 23:23:08 UTC 2024 x86_64
User: austral3d (14892361)
PHP: 5.6.40
Disabled: NONE
Upload Files
File: /home/austral3d/fourdplan.com/php/reportefdplunes.php
<?php
require("conexion.php");
date_default_timezone_set('America/Santiago');	
$today = date('Y-m-d');
$start_date = date('Y-m-d', strtotime($today. ' - 7 days'));

$opcion = $_GET['receptor'];

/*
dia lunes
MRL@Reinike.cl
MEspinoza@Reinike.cl
VBarrales@Reinike.cl
EMolina@Reinike.cl
GCaro@Reinike.cl
ASanchez@Reinike.cl
FInostroza@Reinike.cl
JArevalo@Reinike.cl
MOlmos@Reinike.cl
FTobar@Reinike.cl
RMartinez@Reinike.cl
PRichter@Reinike.cl
GToro@Reinike.cl
Farredondo@Reinike.cl
*/
if($opcion == 'cliente'){
	//$mails[] = 'rainmake123@gmail.com';
	$subject = 'Reporte semanal de avance Fourdplan';
	$mails = array('MRL@Reinike.cl','MEspinoza@Reinike.cl','VBarrales@Reinike.cl','EMolina@Reinike.cl','GCaro@Reinike.cl','ASanchez@Reinike.cl','FInostroza@Reinike.cl','JArevalo@Reinike.cl','MOlmos@Reinike.cl','FTobar@Reinike.cl','RMartinez@Reinike.cl','PRichter@Reinike.cl','GToro@Reinike.cl','Farredondo@Reinike.cl','tecnologia@austral3d.com');
}elseif($opcion == 'admin'){
	$subject = 'PRELIMINAR CONFIRMAR DATOS';
	//$mails[] = "nd0806@gmail.com";
	$mails[] = "tecnologia@austral3d.com";
}

/*
dia jueves
VBarrales@Reinike.cl
JArevalo@Reinike.cl
GToro@Reinike.cl
MOlmos@Reinike.cl
EMolina@Reinike.cl
MEspinoza@Reinike.cl
Farredondo@Reinike.cl
*/
//$mails = array('VBarrales@Reinike.cl','JArevalo@Reinike.cl','GToro@Reinike.cl','MOlmos@Reinike.cl','EMolina@Reinike.cl','MEspinoza@Reinike.cl','Farredondo@Reinike.cl');
//$mails = array('','');

//$mails[] = "tecnologia@austral3d.com";
$conteo = count($mails);
$aaa = 0;
//echo $mails[3];
while($aaa < $conteo){	
	$to  = $mails[$aaa];
	
	/*
	if($to == "tecnologia@austral3d.com"){
		$id_usuario = 1;
	}else{
		$consulta_id_usuario = mysql_query("select id from Usuario where mail = '".$mails[$aaa]."'");
		$id_usuario = mysql_result($consulta_id_usuario,0,"id");
	}
	*/
	
	//$consulta_permisos = mysql_query("select proyecto_id from Permisos where usuario_id = '".$id_usuario."'");
	$consulta_permisos = mysql_query("select proyecto_id from Permisos where usuario_id = 29");
	while($arrayproyectos = mysql_fetch_array($consulta_permisos)){
	$array1[] = $arrayproyectos['proyecto_id'];
	}

	$contador = count($array1);

	$asdcabeza ='
	<center>
	<img src="http://www.fourdplan.com/webservices/banner2.jpg" height="107" width="765">
	<br style = "color: white;"></br>
	<table style="width:100%;">
		<tr>
			<th style = "border: 1px solid black;">FOURDPLAN</th>
			<th style = "border: 1px solid black; font-size:22px;">Reporte semanal, Avance Fourdplan</th> 
			<th style = "border: 1px solid black;">AUSTRAL3D</th>
		</tr>
	</table>

	<table style="width:100%;">
		<tr>
			<td style = "border: 1px solid black; font-weight: bold;">Desde:</td>
			<td style = "border: 1px solid black;">' . $start_date . '</td>
			<td style = "border: 1px solid black; font-weight: bold;">Hasta:</td>
			<td style = "border: 1px solid black;">' . $today . '</td>
		</tr>
	</table>
	</center>';

	$a=0;
	while($a < $contador){
	$proyecto_id = $array1[$a];
	$a;

	$consulta_proyecto_nombre = mysql_query("select nombre from Proyecto where id = '$proyecto_id'");
	$proyecto_nombre = mysql_result($consulta_proyecto_nombre,0,"nombre");

	$consulta_total = mysql_query("select sum(E.peso)as peso from Instancia I JOIN Elemento E ON I.elemento_id = E.id Join Descripcion D ON E.descripcion_id = D.id join Assembly A on D.assembly_id = A.id where A.proyecto_id = '".$proyecto_id."'");							
	if(empty(mysql_result($consulta_total,0,"peso"))){
		$arraytotal = 0;
	}else{	
		$arraytotal = mysql_result($consulta_total,0,"peso");	
	}

	$consulta_planificacion = mysql_query("select sum(E.peso)as peso from Instancia I JOIN Elemento E ON I.elemento_id = E.id Join Descripcion D ON E.descripcion_id = D.id join Assembly A on D.assembly_id = A.id where I.fecha_planificacion != 00-00-0000 and A.proyecto_id = '".$proyecto_id."' ");
	if(empty(mysql_result($consulta_planificacion,0,"peso"))){
		$arrayplani = 0;
	}else{	
		$arrayplani = mysql_result($consulta_planificacion,0,"peso");	
	}

	$consulta_pre_material = mysql_query("select sum(E.peso)as peso from Instancia I JOIN Elemento E ON I.elemento_id = E.id Join Descripcion D ON E.descripcion_id = D.id join Assembly A on D.assembly_id = A.id where I.fecha_preparacion_material != 00-00-0000 and A.proyecto_id = '".$proyecto_id."'");
	if(empty(mysql_result($consulta_pre_material,0,"peso"))){
		$arraypremate = 0;
	}else{	
		$arraypremate = mysql_result($consulta_pre_material,0,"peso");	
	}	

	$consulta_armado = mysql_query("select sum(E.peso)as peso from Instancia I JOIN Elemento E ON I.elemento_id = E.id Join Descripcion D ON E.descripcion_id = D.id join Assembly A on D.assembly_id = A.id where I.fecha_armado != 00-00-0000 and A.proyecto_id = '".$proyecto_id."' ");
	if(empty(mysql_result($consulta_armado,0,"peso"))){
		$arrayarmado = 0;
	}else{	
		$arrayarmado = mysql_result($consulta_armado,0,"peso");	
	}

	$consulta_soldadura = mysql_query("select sum(E.peso)as peso from Instancia I JOIN Elemento E ON I.elemento_id = E.id Join Descripcion D ON E.descripcion_id = D.id join Assembly A on D.assembly_id = A.id where I.fecha_soldadura != 00-00-0000 and A.proyecto_id = '".$proyecto_id."' ");
	if(empty(mysql_result($consulta_soldadura,0,"peso"))){
		$arraysoldadura = 0;
	}else{	
		$arraysoldadura = mysql_result($consulta_soldadura,0,"peso");	
	}

	$consulta_granallado = mysql_query("select sum(E.peso)as peso from Instancia I JOIN Elemento E ON I.elemento_id = E.id Join Descripcion D ON E.descripcion_id = D.id join Assembly A on D.assembly_id = A.id where I.fecha_granallado != 00-00-0000 and A.proyecto_id = '".$proyecto_id."' ");
	if(empty(mysql_result($consulta_granallado,0,"peso"))){
		$arraygranallado = 0;
	}else{	
		$arraygranallado = mysql_result($consulta_granallado,0,"peso");	
	}

	$consulta_pintura = mysql_query("select sum(E.peso)as peso from Instancia I JOIN Elemento E ON I.elemento_id = E.id Join Descripcion D ON E.descripcion_id = D.id join Assembly A on D.assembly_id = A.id where I.fecha_pintura != 00-00-0000 and A.proyecto_id = '".$proyecto_id."' ");
	if(empty(mysql_result($consulta_pintura,0,"peso"))){
		$arraypintura = 0;
	}else{	
		$arraypintura = mysql_result($consulta_pintura,0,"peso");	
	}

	$consulta_liberacion = mysql_query("select sum(E.peso)as peso from Instancia I JOIN Elemento E ON I.elemento_id = E.id Join Descripcion D ON E.descripcion_id = D.id join Assembly A on D.assembly_id = A.id where I.fecha_liberacion != 00-00-0000 and A.proyecto_id = '".$proyecto_id."' ");
	if(empty(mysql_result($consulta_liberacion,0,"peso"))){
		$arrayliberacion = 0;
	}else{	
		$arrayliberacion = mysql_result($consulta_liberacion,0,"peso");	
	}

	$consulta_despacho = mysql_query("select sum(E.peso)as peso from Instancia I JOIN Elemento E ON I.elemento_id = E.id Join Descripcion D ON E.descripcion_id = D.id join Assembly A on D.assembly_id = A.id where I.fecha_despacho != 00-00-0000 and A.proyecto_id = '".$proyecto_id."' ");
	if(empty(mysql_result($consulta_despacho,0,"peso"))){
		$arraydespacho = 0;
	}else{	
		$arraydespacho = mysql_result($consulta_despacho,0,"peso");	
	}

	require('conexion2.php');

	$fecha = mysql_query("Select fecha From TablaProgramadoVsReal where fecha <= NOW() and proyecto_id = '".$proyecto_id."' ORDER BY 1 desc");

	@$fechas = mysql_result($fecha,0,"fecha");

	$ton_consulta_planificado = mysql_query("select ton_programado from TablaProgramadoVsRealPlanificado where fecha = '".$fechas."' and proyecto_id = '".$proyecto_id."'");
	if(empty(@mysql_result($ton_consulta_planificado,0,"ton_programado"))){
		$plani_pro = 0;
	}else{	
		$plani_pro = mysql_result($ton_consulta_planificado,0,"ton_programado");	
	}

	$ton_consulta_pre_material = mysql_query("select ton_programado from TablaProgramadoVsRealPreMaterial where fecha = '".$fechas."' and proyecto_id = '".$proyecto_id."'");
	if(empty(@mysql_result($ton_consulta_pre_material,0,"ton_programado"))){
		$pre_pro = 0;
	}else{	
		$pre_pro = mysql_result($ton_consulta_pre_material,0,"ton_programado");	
	}

	$ton_consulta_armado = mysql_query("select ton_programado from TablaProgramadoVsRealArmado where fecha = '".$fechas."' and proyecto_id = '".$proyecto_id."'");
	if(empty(@mysql_result($ton_consulta_armado,0,"ton_programado"))){
		$pre_arma = 0;
	}else{	
		$pre_arma = mysql_result($ton_consulta_armado,0,"ton_programado");	
	}

	$ton_consulta_negro= mysql_query("select ton_programado from TablaProgramadoVsRealNegro where fecha = '".$fechas."' and proyecto_id = '".$proyecto_id."'");
	if(empty(@mysql_result($ton_consulta_negro,0,"ton_programado"))){
		$pre_negro = 0;
	}else{	
		$pre_negro = mysql_result($ton_consulta_negro,0,"ton_programado");	
	}

	$ton_consulta_granallado= mysql_query("select ton_programado from TablaProgramadoVsRealGranallado where fecha = '".$fechas."' and proyecto_id = '".$proyecto_id."'");
	if(empty(@mysql_result($ton_consulta_granallado,0,"ton_programado"))){
		$pre_granallado = 0;
	}else{	
		$pre_granallado = mysql_result($ton_consulta_granallado,0,"ton_programado");	
	}

	$ton_consulta_pintura= mysql_query("select ton_programado from TablaProgramadoVsRealPintura where fecha = '".$fechas."' and proyecto_id = '".$proyecto_id."'");
	if(empty(@mysql_result($ton_consulta_pintura,0,"ton_programado"))){
		$pre_pintura = 0;
	}else{	
		$pre_pintura = mysql_result($ton_consulta_pintura,0,"ton_programado");	
	}

	$ton_consulta_liberacion= mysql_query("select ton_programado from TablaProgramadoVsRealLiberacion where fecha = '".$fechas."' and proyecto_id = '".$proyecto_id."'");
	if(empty(@mysql_result($ton_consulta_liberacion,0,"ton_programado"))){
		$pre_liberacion = 0;
	}else{	
		$pre_liberacion = mysql_result($ton_consulta_liberacion,0,"ton_programado");	
	}

	$ton_consulta_despacho = mysql_query("select ton_programado from TablaProgramadoVsRealDespacho where fecha = '".$fechas."' and proyecto_id = '".$proyecto_id."'");
	if(empty(@mysql_result($ton_consulta_despacho,0,"ton_programado"))){
		$pre_despacho = 0;
	}else{	
		$pre_despacho = mysql_result($ton_consulta_despacho,0,"ton_programado");	
	}

	$ton_consulta_total= mysql_query("select ton_real from TablaProgramadoVsReal where fecha = '".$fechas."' and proyecto_id = '".$proyecto_id."'");
	if(empty(@mysql_result($ton_consulta_total,0,"ton_real"))){
		$pre_total = 0;
	}else{	
		$pre_total = mysql_result($ton_consulta_total,0,"ton_real");	
	}

	$decimales = 2;

	$titulotabla = array($fechas,"Toneladas","Planificado","Pre. Material", "Armado","Soldadura","Granallado","Pintura","Liberacion","Despacho");
	$columna1tabla = array("Planificado",round(number_format($arraytotal,0,",","."),$decimales),$plani_pro,$pre_pro,$pre_arma,$pre_negro,$pre_pintura,$pre_pintura,$pre_pintura,$pre_despacho);
	$columna2tabla = array("Ejecutado",
	$pre_total,
	round(number_format($arrayplani,0,",","."),$decimales),
	round(number_format($arraypremate,0,",","."),$decimales),
	round(number_format($arrayarmado,0,",","."),$decimales),
	round(number_format($arraysoldadura,0,",","."),$decimales),
	round(number_format($arraygranallado,0,",","."),$decimales),
	round(number_format($arraypintura,0,",","."),$decimales),
	round(number_format($arrayliberacion,0,",","."),$decimales),
	round(number_format($arraydespacho,0,",","."),$decimales)
	);

	if($arraytotal != 0){
	$resultado_pla = $arrayplani * 100 /$arraytotal;
	$resultado_pre = $arraypremate * 100 /$arraytotal;
	$resultado_arm = $arrayarmado * 100 /$arraytotal;
	$resultado_sol = $arraysoldadura * 100 /$arraytotal;
	$resultado_gra = $arraygranallado * 100 /$arraytotal;
	$resultado_pin = $arraypintura * 100 /$arraytotal;
	$resultado_lib = $arrayliberacion * 100 /$arraytotal;
	$resultado_des = $arraydespacho * 100 /$arraytotal;
	}else{
	$resultado_pla = $arrayplani;
	$resultado_pre = $arraypremate;
	$resultado_arm = $arrayarmado;
	$resultado_sol = $arraysoldadura;
	$resultado_gra = $arraygranallado;
	$resultado_pin = $arraypintura;
	$resultado_lib = $arrayliberacion;
	$resultado_des = $arraydespacho;
	}

	$decimales1 = 1;

	$columna3tabla = array("",
	"",
	round($resultado_pla,$decimales1)."%",
	round($resultado_pre,$decimales1)."%",
	round($resultado_arm,$decimales1)."%",
	round($resultado_sol,$decimales1)."%",
	round($resultado_gra,$decimales1)."%",
	round($resultado_pin,$decimales1)."%",
	round($resultado_lib,$decimales1)."%",
	round($resultado_des,$decimales1)."%");
	
	$asd ='<center>	

	<h1>Proyecto: '.$proyecto_nombre.'</h1>
	<h2>Proceso de fabricacion</h2>
	<table style="width:100%;">
						
			<tr bgcolor="#363636">
				<th><font color="#fff">Edificios</font></th>
				<th><font color="#fff">Toneladas</font></th>
				<th><font color="#fff">Planificacion</font></th>
				<th><font color="#fff">Pre. material</font></th>
				<th><font color="#fff">Armado</font></th>
				<th><font color="#fff">Soldadura</font></th>
				<th><font color="#fff">Granallado</font></th>
				<th><font color="#fff">Pintura</font></th>
				<th><font color="#fff">Liberacion</font></th>
				<th><font color="#fff">Despacho</font></th>
				<th><font color="#fff">Avance</font></th>									
			</tr>';
		
		require('conexion.php');
		$consulta_assembly = mysql_query("select * from Assembly where proyecto_id = $proyecto_id");
		
		while($arrayase = mysql_fetch_array($consulta_assembly)){
		
		$consulta_numero_instancias = mysql_query("select sum(E.peso)as peso from Instancia I JOIN Elemento E ON I.elemento_id = E.id Join Descripcion D ON E.descripcion_id = D.id where D.assembly_id = '".$arrayase[0]."'");

		$arraytotal = mysql_fetch_array($consulta_numero_instancias);
		$vatiable = $arraytotal[0];
		if(!empty($vatiable)){										
			$r1 =$vatiable;										
		}else {
			$r1 = 0;
		}	
		//Consulta plnajificacion-----------------------------------------
		$consulta_numero_instancias_planificacion = mysql_query("select sum(E.peso)as peso from Instancia I JOIN Elemento E ON I.elemento_id = E.id Join Descripcion D ON E.descripcion_id = D.id where D.assembly_id = '".$arrayase[0]."' and fecha_planificacion != 0000-00-00");

		$arraytotalplanificacion = mysql_fetch_array($consulta_numero_instancias_planificacion);	
		$vatiableplanificacion = $arraytotalplanificacion[0];	
		if(!empty($vatiableplanificacion)){											
			$r2planificacion =$vatiableplanificacion;										
		}else {
			$r2planificacion = 0;
		}									 
		if($r1 != 0){										
			$resultadoplanificacion = ($r2planificacion * 100) / $r1 ;
			$resultado2planificacion = 100 - $resultadoplanificacion ;										
		}else {										
			$resultadoplanificacion = 0;
			$resultado2planificacion = 100;										
		}									
		//Consulta pre. material------------------------------------------
		$consulta_numero_instancias_prematerial = mysql_query("select sum(E.peso)as peso from Instancia I JOIN Elemento E ON I.elemento_id = E.id Join Descripcion D ON E.descripcion_id = D.id where D.assembly_id = '".$arrayase[0]."' and fecha_preparacion_material != 0000-00-00");

		$arraytotalprematerial = mysql_fetch_array($consulta_numero_instancias_prematerial);	
		$vatiableprematerial = $arraytotalprematerial[0];	

		if(!empty($vatiableprematerial)){											
			$r2prematerial =$vatiableprematerial;										
		}else {
			$r2prematerial = 0;
		}									 
		if($r1 != 0){										
			$resultadoprematerial = ($r2prematerial* 100) / $r1 ;
			$resultado2prematerial = 100 - $resultadoprematerial;										
		}else {										
			$resultadoprematerial = 0;
			$resultado2prematerial= 100;										
		}					
		//Consulta armado-------------------------------------------------
		$consulta_numero_instancias_armado = mysql_query("select sum(E.peso)as peso from Instancia I JOIN Elemento E ON I.elemento_id = E.id Join Descripcion D ON E.descripcion_id = D.id where D.assembly_id = '".$arrayase[0]."' and fecha_armado != 0000-00-00");

		$arraytotalarmado = mysql_fetch_array($consulta_numero_instancias_armado);	
		$vatiablearmado = $arraytotalarmado[0];	
		if(!empty($vatiablearmado)){											
			$r2armado =$vatiablearmado;										
		}else {
			$r2armado = 0;
		}									 
		if($r1 != 0){										
			$resultadoarmado = ($r2armado* 100) / $r1 ;
			$resultado2armado = 100 - $resultadoarmado;										
		}else {										
			$resultadoarmado = 0;
			$resultado2armado= 100;										
		}				
		//Consulta soldadura----------------------------------------------
		$consulta_numero_instancias_soldadura = mysql_query("select sum(E.peso)as peso from Instancia I JOIN Elemento E ON I.elemento_id = E.id Join Descripcion D ON E.descripcion_id = D.id where D.assembly_id = '".$arrayase[0]."' and fecha_soldadura != 0000-00-00");

		$arraytotalsoldadura = mysql_fetch_array($consulta_numero_instancias_soldadura);	
		$vatiablesoldadura = $arraytotalsoldadura[0];	
		if(!empty($vatiablesoldadura)){											
			$r2soldadura =$vatiablesoldadura;										
		}else {
			$r2soldadura = 0;
		}									 
		if($r1 != 0){										
			$resultadosoldadura = ($r2soldadura* 100) / $r1 ;
			$resultado2soldadura = 100 - $resultadosoldadura;										
		}else {										
			$resultadosoldadura = 0;
			$resultado2soldadura= 100;										
		}					
		//Consulta granallado---------------------------------------------
		$consulta_numero_instancias_granallado= mysql_query("select sum(E.peso)as peso from Instancia I JOIN Elemento E ON I.elemento_id = E.id Join Descripcion D ON E.descripcion_id = D.id where D.assembly_id = '".$arrayase[0]."' and fecha_granallado != 0000-00-00");

		$arraytotalgranallado = mysql_fetch_array($consulta_numero_instancias_granallado);	
		$vatiablegranallado = $arraytotalgranallado[0];	
		if(!empty($vatiablegranallado)){											
			$r2granallado =$vatiablegranallado;										
		}else {
			$r2granallado = 0;
		}									 
		if($r1 != 0){										
			$resultadogranallado = ($r2granallado* 100) / $r1 ;
			$resultado2granallado = 100 - $resultadogranallado;										
		}else {										
			$resultadogranallado = 0;
			$resultado2granallado= 100;										
		}					
		//Consulta pintura------------------------------------------------								
		$consulta_numero_instancias_pintura= mysql_query("select sum(E.peso)as peso from Instancia I JOIN Elemento E ON I.elemento_id = E.id Join Descripcion D ON E.descripcion_id = D.id where D.assembly_id = '".$arrayase[0]."' and fecha_pintura != 0000-00-00");

		$arraytotalpintura = mysql_fetch_array($consulta_numero_instancias_pintura);	
		$vatiablepintura = $arraytotalpintura[0];	
		if(!empty($vatiablepintura)){											
			$r2pintura =$vatiablepintura;										
		}else {
			$r2pintura = 0;
		}									 
		if($r1 != 0){										
			$resultadopintura = ($r2pintura* 100) / $r1 ;
			$resultado2pintura = 100 - $resultadopintura;										
		}else {										
			$resultadopintura = 0;
			$resultado2pintura= 100;										
		}					
		//Consulta liberacion---------------------------------------------	
		$consulta_numero_instancias_liberacion= mysql_query("select sum(E.peso)as peso from Instancia I JOIN Elemento E ON I.elemento_id = E.id Join Descripcion D ON E.descripcion_id = D.id where D.assembly_id = '".$arrayase[0]."' and fecha_liberacion != 0000-00-00");

		$arraytotalliberacion = mysql_fetch_array($consulta_numero_instancias_liberacion);	
		$vatiableliberacion = $arraytotalliberacion[0];	
		if(!empty($vatiableliberacion)){											
			$r2liberacion =$vatiableliberacion;										
		}else {
			$r2liberacion = 0;
		}									 
		if($r1 != 0){										
			$resultadoliberacion = ($r2liberacion* 100) / $r1 ;
			$resultado2liberacion = 100 - $resultadoliberacion;										
		}else {										
			$resultadoliberacion = 0;
			$resultado2liberacion= 100;										
		}					
		//Consulta despacho------------------------------------------------	
		$consulta_numero_instancias_despacho= mysql_query("select sum(E.peso)as peso from Instancia I JOIN Elemento E ON I.elemento_id = E.id Join Descripcion D ON E.descripcion_id = D.id where D.assembly_id = '".$arrayase[0]."' and fecha_despacho != 0000-00-00");

		$arraytotaldespacho = mysql_fetch_array($consulta_numero_instancias_despacho);	
		$vatiabledespacho = $arraytotaldespacho[0];	
		if(!empty($vatiabledespacho)){											
			$r2despacho =$vatiabledespacho;										
		}else {
			$r2despacho = 0;
		}									 
		if($r1 != 0){										
			$resultadodespacho = ($r2despacho* 100) / $r1 ;
			$resultado2despacho = 100 - $resultadodespacho;										
		}else {										
			$resultadodespacho = 0;
			$resultado2despacho= 100;										
		}
		
			if($r1 < 1000){$toneladas = round($r1/1000,$decimales);}else{$toneladas = round(number_format($r1,0,",","."),$decimales);}
			if($r2planificacion < 1000){$planificacion = round($r2planificacion/1000,$decimales);}else{$planificacion = round(number_format($r2planificacion,0,",","."),$decimales);}
			if($r2prematerial < 1000){$prematerial = round($r2prematerial/1000,$decimales);}else{$prematerial = round(number_format($r2prematerial,0,",","."),$decimales);}
			if($r2armado < 1000){$armado = round($r2armado/1000,$decimales);}else{$armado = round(number_format($r2armado,0,",","."),$decimales);}
			if($r2soldadura < 1000){$soldadura = round($r2soldadura/1000,$decimales);}else{$soldadura = round(number_format($r2soldadura,0,",","."),$decimales);}
			if($r2granallado < 1000){$granallado = round($r2granallado/1000,$decimales);}else{$granallado = round(number_format($r2granallado,0,",","."),$decimales);}
			if($r2pintura < 1000){$pintura = round($r2pintura/1000,$decimales);}else{$pintura = round(number_format($r2pintura,0,",","."),$decimales);}
			if($r2liberacion < 1000){$liberacion = round($r2liberacion/1000,$decimales);}else{$liberacion = round(number_format($r2liberacion,0,",","."),$decimales);}
			if($r2despacho < 1000){$despacho = round($r2despacho/1000,$decimales);}else{$despacho = round(number_format($r2despacho,0,",","."),$decimales);}
			$avance = $r2planificacion+$r2prematerial+$r2armado+$r2soldadura+$r2granallado+$r2pintura+$r2liberacion+$r2despacho;
			if($r1!= 0){$ravance = ($avance/8)/$r1*100; $avances = round($ravance,$decimales)." %";}else{$avances = "0 %";}

		$asd.='	<tr bgcolor="#e6e6e6">
					<th>'.$arrayase[1].'</th>
					<td>'.$toneladas.'</td>
					<td>'.$planificacion.'</td>
					<td>'.$prematerial.'</td>
					<td>'.$armado.'</td>
					<td>'.$soldadura.'</td>
					<td>'.$granallado.'</td>
					<td>'.$pintura.'</td>
					<td>'.$liberacion.'</td>
					<td>'.$despacho.'</td>
					<td>'.$avances.'</td>																		
				</tr>';		
		}
		
	$asd.='</table>
	<br>

	<h2>Comparativa Real vs Programado</h2>

	<table style="width:100%;">
		<thead>
			<tr bgcolor="#363636">
				<th><font color="#fff">'.$titulotabla[0].'</font></th>
				<th><font color="#fff">'.$titulotabla[1].'</font></th>
				<th><font color="#fff">'.$titulotabla[2].'</font></th>
				<th><font color="#fff">'.$titulotabla[3].'</font></th>
				<th><font color="#fff">'.$titulotabla[4].'</font></th>
				<th><font color="#fff">'.$titulotabla[5].'</font></th>
				<th><font color="#fff">'.$titulotabla[6].'</font></th>
				<th><font color="#fff">'.$titulotabla[7].'</font></th>
				<th><font color="#fff">'.$titulotabla[8].'</font></th>
				<th><font color="#fff">'.$titulotabla[9].'</font></th>
			</tr>
		</thead>
		<tbody>
			<tr bgcolor="#e6e6e6">
				<th>'.$columna1tabla[0].'</th>
				<td>'.$columna1tabla[1].'</td>
				<td>'.$columna1tabla[2].'</td>
				<td>'.$columna1tabla[3].'</td>
				<td>'.$columna1tabla[4].'</td>
				<td>'.$columna1tabla[5].'</td>
				<td>'.$columna1tabla[6].'</td>
				<td>'.$columna1tabla[7].'</td>
				<td>'.$columna1tabla[8].'</td>
				<td>'.$columna1tabla[9].'</td>										
			</tr>
			<tr bgcolor="#e6e6e6">
				<th>'.$columna2tabla[0].'</th>
				<td>'.$columna2tabla[1].'</td>
				<td>'.$columna2tabla[2].'</td>
				<td>'.$columna2tabla[3].'</td>
				<td>'.$columna2tabla[4].'</td>
				<td>'.$columna2tabla[5].'</td>
				<td>'.$columna2tabla[6].'</td>
				<td>'.$columna2tabla[7].'</td>
				<td>'.$columna2tabla[8].'</td>
				<td>'.$columna2tabla[9].'</td>												
			</tr>
			<tr bgcolor="#e6e6e6">
				<th>'.$columna3tabla[0].'</th>
				<td>'.$columna3tabla[1].'</td>
				<td>'.$columna3tabla[2].'</td>
				<td>'.$columna3tabla[3].'</td>
				<td>'.$columna3tabla[4].'</td>
				<td>'.$columna3tabla[5].'</td>
				<td>'.$columna3tabla[6].'</td>
				<td>'.$columna3tabla[7].'</td>
				<td>'.$columna3tabla[8].'</td>
				<td>'.$columna3tabla[9].'</td>
			</tr>
		</tbody>
	</table></center>
	<br>
	<br>
	<hr>
	';
	$a+=1;
	$arraya[] = $asd;
	}

	$msj = implode($arraya);

	$headers  = 'MIME-Version: 1.0' . "\r\n";
	$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
	$headers .= 'From: Austral3D <tecnologia@austral3d.com>' . "\r\n";

	//mail($to, $subject, $asdcabeza.$msj, $headers);
	$aaa+=1;
	$a = 0;
	$arraya = "";
	$array1 = "";
}
?>