<?php

	include('../../php/conn.php');

	require_once 'dompdf/autoload.inc.php';

	use Dompdf\Dompdf;

	// Parámetros principales
		$Id_Pedido = $_GET["Id"];
		$Id_PedidoDetalle = $_GET["Id_Detalle"];
		$cliente = str_replace('*', ' ', $_GET["Cli"]);
		$tipo_muestra = str_replace('*', ' ', $_GET["TM"]);
		$nom_muestra = str_replace('*', ' ', $_GET["M"]);
		$peso_muestra = $_GET["PM"];
		$detalle_envase = str_replace('*', ' ', $_GET["DE"]);
		$fecha_recepcion = $_GET["FR"];
		$fecha_entrega = $_GET["FE"];
		$elemento_analisis = str_replace('*', ' ', $_GET["EA"]);
		$fecha_informe = $_GET["FI"];
		$obs_reporte = $_GET["Obs"];
		$sucursal = $_GET["S"];

	// Leyes
		$augt = $_GET["augt"];
		$auot =$_GET["auot"];
		$aggt =$_GET["aggt"];
		$agot =$_GET["agot"];
		$cu =$_GET["cu"];
		$pb =$_GET["pb"];
		$zn = $_GET["zn"];
		$as =$_GET["as"];
		$sb =$_GET["sb"];
		$s =$_GET["s"];
		$fe =$_GET["fe"];
		$ho = $_GET["ho"];

	// Número de Código
		$q_codigoinforme = "SELECT  Correlativo
                              FROM  _max_labperu_CorrelativoInformeEnsayos
                             WHERE  Id_Pedido = ".$Id_Pedido."
                               AND  Id_Detalle_Pedido = ".$Id_PedidoDetalle;

		if ($res_codigoinforme = sqlsrv_query($enlacehost, $q_codigoinforme)) {
			while($row_codigoinforme = sqlsrv_fetch_array($res_codigoinforme)) {
				$correlativo = $row_codigoinforme["Correlativo"];
			}
		}

	$html = '<!DOCTYPE html>
			<html lang="es">
				<head>
			        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
			        <meta charset="utf-8">
			        <meta http-equiv="X-UA-Compatible" content="IE=edge">
			        <meta name="viewport" content="width=device-width, initial-scale=1">

			        <title>Informe de Ensayo - '.(($sucursal == 2) ? 'SU ' : '').$correlativo.'</title>

			        <!-- Bootstrap -->
			        <link href="../vendors/bootstrap/dist/css/bootstrap.min.css" rel="stylesheet">
			        
			        <!-- Custom Theme Style -->
			        <link href="../build/css/custom.min.css" rel="stylesheet">

					<style type="text/css">
				        html {
							margin: 0;
						}
						body {
							font-family: "Times New Roman", Times, serif;
						}
					</style>
			    </head>

				<body class="nav-md" style="background-color: #ffffff"">
					<div class="container body" style="font-size: 12px; color: #000000">
						<div class="" style="text-align: center; position: absolute;">
							<img src="images/informe_ensayos.png" height="1120px" width="792px"/>
						</div>

						<div class="row" style="position: absolute;">
							<div class="col-md-1 col-sm-1 col-xs-1">

							</div>
							<div class="col-md-8 col-sm-8 col-xs-8" Style="background-color: #BF9000; margin-top: 210px; margin-left: 15px; height: 26px; font-size: 16px; color: #ffffff; text-align: center; border: solid; border-width: 1px; border-color: #D9D9D9;">
								<label><center>
									<b>INFORME DE ENSAYO</b>
								</center></label>
							</div>
						</div>

						<div class="row" style="position: absolute;">
							<div class="col-md-1 col-sm-1 col-xs-1">

							</div>
							<div class="col-md-4 col-sm-4 col-xs-4" Style="background-color: #BF9000; margin-top: 250px; margin-left: 15px; height: 26px; font-size: 12px; color: #ffffff; width: 23.7%; border: solid; border-width: 1px; border-color: #D9D9D9;">
								<label style="text-align: right; margin-top: 1px">
									<b>NÚMERO DE CÓDIGO</b>
								</label>
							</div>
							<div class="col-md-5 col-sm-5 col-xs-5" Style="background-color: #ffffff; margin-top: 250px; margin-left: -9px; height: 26px; font-size: 12px; color: #000000; width: 40.3%; border: solid; border-width: 1px; border-color: #D9D9D9;">
								<label style="text-align: left; margin-top: 1px"><b>'.(($sucursal == 2) ? 'SU ' : '').$correlativo.'</b></label>
							</div>
						</div>

						<div class="row" style="position: absolute;">
							<div class="col-md-1 col-sm-1 col-xs-1">

							</div>
							<div class="col-md-4 col-sm-4 col-xs-4" Style="background-color: #BF9000; margin-top: 277px; margin-left: 15px; height: 26px; font-size: 12px; color: #ffffff; width: 23.7%; border: solid; border-width: 1px; border-color: #D9D9D9;">
								<label style="text-align: right; margin-top: 1px">
									<b>CLIENTE / EMPRESA</b>
								</label>
							</div>
							<div class="col-md-5 col-sm-5 col-xs-5" Style="background-color: #ffffff; margin-top: 277px; margin-left: -9px; height: 26px; font-size: 12px; color: #000000; width: 40.3%; border: solid; border-width: 1px; border-color: #D9D9D9;">
								<label style="text-align: left; margin-top: 1px"><b>'.strtoupper($cliente).'</b></label>
							</div>
						</div>

						<div class="row" style="position: absolute;">
							<div class="col-md-1 col-sm-1 col-xs-1">

							</div>
							<div class="col-md-4 col-sm-4 col-xs-4" Style="background-color: #BF9000; margin-top: 304px; margin-left: 15px; height: 26px; font-size: 12px; color: #ffffff; width: 23.7%; border: solid; border-width: 1px; border-color: #D9D9D9;">
								<label style="text-align: right; margin-top: 1px">
									<b>DESCRIPCIÓN TIPO MUESTRA</b>
								</label>
							</div>
							<div class="col-md-5 col-sm-5 col-xs-5" Style="background-color: #ffffff; margin-top: 304px; margin-left: -9px; height: 26px; font-size: 12px; color: #000000; width: 40.3%; border: solid; border-width: 1px; border-color: #D9D9D9;">
								<label style="text-align: left; margin-top: 1px"><b>'.strtoupper($tipo_muestra).'</b></label>
							</div>
						</div>

						<div class="row" style="position: absolute;">
							<div class="col-md-1 col-sm-1 col-xs-1">

							</div>
							<div class="col-md-4 col-sm-4 col-xs-4" Style="background-color: #BF9000; margin-top: 331px; margin-left: 15px; height: 26px; font-size: 12px; color: #ffffff; width: 23.7%; border: solid; border-width: 1px; border-color: #D9D9D9;">
								<label style="text-align: right; margin-top: 1px">
									<b>IDENTIFICACIÓN MUESTRA</b>
								</label>
							</div>
							<div class="col-md-5 col-sm-5 col-xs-5" Style="background-color: #ffffff; margin-top: 331px; margin-left: -9px; height: 26px; font-size: 12px; color: #000000; width: 40.3%; border: solid; border-width: 1px; border-color: #D9D9D9;">
								<label style="text-align: left; margin-top: 1px"><b>'.strtoupper($nom_muestra).'</b></label>
							</div>
						</div>

						<div class="row" style="position: absolute;">
							<div class="col-md-1 col-sm-1 col-xs-1">

							</div>
							<div class="col-md-4 col-sm-4 col-xs-4" Style="background-color: #BF9000; margin-top: 358px; margin-left: 15px; height: 26px; font-size: 12px; color: #ffffff; width: 23.7%; border: solid; border-width: 1px; border-color: #D9D9D9;">
								<label style="text-align: right; margin-top: 1px">
									<b>CANTIDAD DE MUESTRAS</b>
								</label>
							</div>
							<div class="col-md-5 col-sm-5 col-xs-5" Style="background-color: #ffffff; margin-top: 358px; margin-left: -9px; height: 26px; font-size: 12px; color: #000000; width: 40.3%; border: solid; border-width: 1px; border-color: #D9D9D9;">
								<label style="text-align: left; margin-top: 1px"><b>APROX. '.number_format($peso_muestra, 3, '.', ',').' KG</b></label>
							</div>
						</div>

						<div class="row" style="position: absolute;">
							<div class="col-md-1 col-sm-1 col-xs-1">

							</div>
							<div class="col-md-4 col-sm-4 col-xs-4" Style="background-color: #BF9000; margin-top: 385px; margin-left: 15px; height: 26px; font-size: 12px; color: #ffffff; width: 23.7%; border: solid; border-width: 1px; border-color: #D9D9D9;">
								<label style="text-align: right; margin-top: 1px">
									<b>DETALLE DEL ENVASE</b>
								</label>
							</div>
							<div class="col-md-5 col-sm-5 col-xs-5" Style="background-color: #ffffff; margin-top: 385px; margin-left: -9px; height: 26px; font-size: 12px; color: #000000; width: 40.3%; border: solid; border-width: 1px; border-color: #D9D9D9;">
								<label style="text-align: left; margin-top: 1px"><b>'.strtoupper($detalle_envase).'</b></label>
							</div>
						</div>

						<div class="row" style="position: absolute;">
							<div class="col-md-1 col-sm-1 col-xs-1">

							</div>
							<div class="col-md-4 col-sm-4 col-xs-4" Style="background-color: #BF9000; margin-top: 412px; margin-left: 15px; height: 26px; font-size: 12px; color: #ffffff; width: 23.7%; border: solid; border-width: 1px; border-color: #D9D9D9;">
								<label style="text-align: right; margin-top: 1px">
									<b>FECHA RECEPCIÓN</b>
								</label>
							</div>
							<div class="col-md-5 col-sm-5 col-xs-5" Style="background-color: #ffffff; margin-top: 412px; margin-left: -9px; height: 26px; font-size: 12px; color: #000000; width: 40.3%; border: solid; border-width: 1px; border-color: #D9D9D9;">
								<label style="text-align: left; margin-top: 1px"><b>'.$fecha_recepcion.'</b></label>
							</div>
						</div>

						<div class="row" style="position: absolute;">
							<div class="col-md-1 col-sm-1 col-xs-1">

							</div>
							<div class="col-md-4 col-sm-4 col-xs-4" Style="background-color: #BF9000; margin-top: 439px; margin-left: 15px; height: 26px; font-size: 12px; color: #ffffff; width: 23.7%; border: solid; border-width: 1px; border-color: #D9D9D9;">
								<label style="text-align: right; margin-top: 1px">
									<b>FECHA ENSAYOS</b>
								</label>
							</div>
							<div class="col-md-5 col-sm-5 col-xs-5" Style="background-color: #ffffff; margin-top: 439px; margin-left: -9px; height: 26px; font-size: 12px; color: #000000; width: 40.3%; border: solid; border-width: 1px; border-color: #D9D9D9;">
								<label style="text-align: left; margin-top: 1px"><b>'.$fecha_entrega.'</b></label>
							</div>
						</div>';

	// Obteniendo el Método Analitico
		$e = 0;
		$_metodos = '';
		$elementos = explode('-', $elemento_analisis);

		$entro_augt = 0;
		$entro_cu = 0;
		$entro_pb = 0;
		$entro_as = 0;
		$entro_otros = 0;
		$entro_ho = 0;

		while ($e <= count($elementos)){
			$elemento = $elementos[$e];

			if ($entro_augt == 0){
				if (trim(strtolower($elemento)) == 'au' || trim(strtolower($elemento)) == 'ag'){
					$_metodos = 'VÍA SECA (AU-AG)';

					$entro_augt = 1;
				}
			}

			if ($entro_cu == 0){
				if (trim(strtolower($elemento)) == 'cu'){
					// Obteniendo Ley
						$ley = $cu;

					// Deterinando Método
						if ($ley < 6.5){
							$_metodos .= ((strlen($_metodos) > 0) ? ' | ' : '').'ABSORCIÓN ATÓMICA (CU)';
						}
						else{
							$_metodos .= ((strlen($_metodos) > 0) ? ' | ' : '').'VOLUMETRÍA (CU)';
						}

					$entro_cu = 1;
				}
			}

			if ($entro_pb == 0){
				if (trim(strtolower($elemento)) == 'pb' || trim(strtolower($elemento)) == 'zn'){
					// Obteniendo Ley
						$ley = $cu;

					// Deterinando Método
						if ($ley < 12){
							$_metodos .= ((strlen($_metodos) > 0) ? ' | ' : '').'ABSORCIÓN ATÓMICA ('.trim(mb_strtoupper($elemento)).')';
						}
						else{
							$_metodos .= ((strlen($_metodos) > 0) ? ' | ' : '').'VOLUMETRÍA ('.trim(mb_strtoupper($elemento)).')';
						}

					$entro_pb = 1;
				}
			}

			if ($entro_as == 0){
				if (trim(strtolower($elemento)) == 'as'){
					$_metodos .= ((strlen($_metodos) > 0) ? ' | ' : '').'ABSORCIÓN ATÓMICA (AS)';

					$entro_as = 1;
				}
			}

			if ($entro_otros == 0){
				if (trim(strtolower($elemento)) == 'sb' || trim(strtolower($elemento)) == 's' || trim(strtolower($elemento)) == 'fe'){
					$_metodos .= ((strlen($_metodos) > 0) ? ' | ' : '').'ABSORCIÓN ATÓMICA ('.trim(mb_strtoupper($elemento)).')';

					$entro_otros = 1;
				}
			}

			if ($entro_ho == 0){
				if (trim(strtolower($elemento)) == 'h2o'){
					$_metodos .= ((strlen($_metodos) > 0) ? ' | ' : '').'GRAVIMETRÍA ('.trim(mb_strtoupper($elemento)).')';

					$entro_ho = 1;
				}
			}

			$e += 1;
		}

	// Pintando Métodos Analíticos
		$html .= '			<div class="row" style="position: absolute;">
								<div class="col-md-1 col-sm-1 col-xs-1">

								</div>
								<div class="col-md-4 col-sm-4 col-xs-4" Style="background-color: #BF9000; margin-top: 466px; margin-left: 15px; height: 55px; font-size: 12px; color: #ffffff; width: 23.7%; border: solid; border-width: 1px; border-color: #D9D9D9;">
									<label style="text-align: right; margin-top: 9px">
										<b>MÉTODO ANALÍTICO</b>
									</label>
								</div>
								<div class="col-md-5 col-sm-5 col-xs-5" Style="background-color: #ffffff; margin-top: 466px; margin-left: -9px; height: 55px; font-size: 11px; color: #000000; width: 40.3%; border: solid; border-width: 1px; border-color: #D9D9D9;">
									<label style="text-align: left; margin-top: 3px"><b>'.$_metodos.'</b></label>
								</div>
							</div>';

	// Pitando los detalles
		$html .= '			<div class="row" style="position: absolute;">
								<div class="col-md-3 col-sm-3 col-xs-3">

								</div>
								<div class="col-md-5 col-sm-5 col-xs-5" Style="background-color: #BF9000; margin-top: 556px; margin-left: -15px; height: 26px; font-size: 16px; color: #ffffff; text-align: center; border: solid; border-width: 1px; border-color: #D9D9D9;">
									<label><center>
										<b>RESULTADOS</b>
									</center></label>
								</div>
							</div>';

		// Bucle por elementos
			$e = 0;
			$_metodos = '';
			$margin_top = 0;
			$elementos = explode('-', $elemento_analisis);

			while ($e <= count($elementos)){
				$elemento = $elementos[$e];

				if (trim(strtolower($elemento)) == 'au'){
					$margin_top = (556 + 40);

					$html .= '			<div class="row" style="position: absolute;">
											<div class="col-md-3 col-sm-3 col-xs-3">

											</div>
											<div class="col-md-5 col-sm-5 col-xs-5" Style="background-color: #BF9000; margin-top: '.$margin_top.'px; margin-left: -15px; height: 26px; font-size: 12px; color: #ffffff; width: 23.7%; border: solid; border-width: 1px; border-color: #D9D9D9;">
												<label style="text-align: right; margin-top: 1px">
													<b>Au - ORO (g/tm)</b>
												</label>
											</div>
											<div class="col-md-5 col-sm-5 col-xs-5" Style="background-color: #ffffff; margin-top: '.$margin_top.'px; margin-left: -9px; height: 26px; font-size: 12px; color: #000000; width: 15.3%; border: solid; border-width: 1px; border-color: #D9D9D9;">
												<label style="text-align: left; margin-top: 1px;"><center><b>'.number_format($augt, 2, '.', ',').'</b></center></label>
											</div>
										</div>

										<div class="row" style="position: absolute;">
											<div class="col-md-3 col-sm-3 col-xs-3">

											</div>
											<div class="col-md-5 col-sm-5 col-xs-5" Style="background-color: #BF9000; margin-top: '.($margin_top + 27).'px; margin-left: -15px; height: 26px; font-size: 12px; color: #ffffff; width: 23.7%; border: solid; border-width: 1px; border-color: #D9D9D9;">
												<label style="text-align: right; margin-top: 1px">
													<b>Au - ORO (oz/tc)</b>
												</label>
											</div>
											<div class="col-md-5 col-sm-5 col-xs-5" Style="background-color: #ffffff; margin-top: '.($margin_top + 27).'px; margin-left: -9px; height: 26px; font-size: 12px; color: #000000; width: 15.3%; border: solid; border-width: 1px; border-color: #D9D9D9;">
												<label style="text-align: left; margin-top: 1px;"><center><b>'.number_format($auot, 2, '.', ',').'</b></center></label>
											</div>
										</div>';

					$margin_top = ($margin_top + 27);
				}

				if (trim(strtolower($elemento)) == 'ag'){
					$margin_top = (($margin_top == 0) ? (556 + 40) : ($margin_top + 27));

					$html .= '			<div class="row" style="position: absolute;">
											<div class="col-md-3 col-sm-3 col-xs-3">

											</div>
											<div class="col-md-5 col-sm-5 col-xs-5" Style="background-color: #BF9000; margin-top: '.$margin_top.'px; margin-left: -15px; height: 26px; font-size: 12px; color: #ffffff; width: 23.7%; border: solid; border-width: 1px; border-color: #D9D9D9;">
												<label style="text-align: right; margin-top: 1px">
													<b>Ag - PLATA (g/tm)</b>
												</label>
											</div>
											<div class="col-md-5 col-sm-5 col-xs-5" Style="background-color: #ffffff; margin-top: '.$margin_top.'px; margin-left: -9px; height: 26px; font-size: 12px; color: #000000; width: 15.3%; border: solid; border-width: 1px; border-color: #D9D9D9;">
												<label style="text-align: left; margin-top: 1px;"><center><b>'.round($aggt).'</b></center></label>
											</div>
										</div>

										<div class="row" style="position: absolute;">
											<div class="col-md-3 col-sm-3 col-xs-3">

											</div>
											<div class="col-md-5 col-sm-5 col-xs-5" Style="background-color: #BF9000; margin-top: '.($margin_top + 27).'px; margin-left: -15px; height: 26px; font-size: 12px; color: #ffffff; width: 23.7%; border: solid; border-width: 1px; border-color: #D9D9D9;">
												<label style="text-align: right; margin-top: 1px">
													<b>Ag - PLATA (oz/tc)</b>
												</label>
											</div>
											<div class="col-md-5 col-sm-5 col-xs-5" Style="background-color: #ffffff; margin-top: '.($margin_top + 27).'px; margin-left: -9px; height: 26px; font-size: 12px; color: #000000; width: 15.3%; border: solid; border-width: 1px; border-color: #D9D9D9;">
												<label style="text-align: left; margin-top: 1px;"><center><b>'.number_format($agot, 2, '.', ',').'</b></center></label>
											</div>
										</div>';

					$margin_top = ($margin_top + 27);
				}

				if (trim(strtolower($elemento)) == 'cu'){
					$margin_top = (($margin_top == 0) ? (556 + 40) : ($margin_top + 27));

					$html .= '			<div class="row" style="position: absolute;">
											<div class="col-md-3 col-sm-3 col-xs-3">

											</div>
											<div class="col-md-5 col-sm-5 col-xs-5" Style="background-color: #BF9000; margin-top: '.$margin_top.'px; margin-left: -15px; height: 26px; font-size: 12px; color: #ffffff; width: 23.7%; border: solid; border-width: 1px; border-color: #D9D9D9;">
												<label style="text-align: right; margin-top: 1px">
													<b>Cu - COBRE (%)</b>
												</label>
											</div>
											<div class="col-md-5 col-sm-5 col-xs-5" Style="background-color: #ffffff; margin-top: '.$margin_top.'px; margin-left: -9px; height: 26px; font-size: 12px; color: #000000; width: 15.3%; border: solid; border-width: 1px; border-color: #D9D9D9;">
												<label style="text-align: left; margin-top: 1px;"><center><b>'.number_format($cu, 2, '.', ',').'</b></center></label>
											</div>
										</div>';
				}

				if (trim(strtolower($elemento)) == 'pb'){
					$margin_top = (($margin_top == 0) ? (556 + 40) : ($margin_top + 27));

					$html .= '			<div class="row" style="position: absolute;">
											<div class="col-md-3 col-sm-3 col-xs-3">

											</div>
											<div class="col-md-5 col-sm-5 col-xs-5" Style="background-color: #BF9000; margin-top: '.$margin_top.'px; margin-left: -15px; height: 26px; font-size: 12px; color: #ffffff; width: 23.7%; border: solid; border-width: 1px; border-color: #D9D9D9;">
												<label style="text-align: right; margin-top: 1px">
													<b>Pb - PLOMO (%)</b>
												</label>
											</div>
											<div class="col-md-5 col-sm-5 col-xs-5" Style="background-color: #ffffff; margin-top: '.$margin_top.'px; margin-left: -9px; height: 26px; font-size: 12px; color: #000000; width: 15.3%; border: solid; border-width: 1px; border-color: #D9D9D9;">
												<label style="text-align: left; margin-top: 1px;"><center><b>'.number_format($pb, 2, '.', ',').'</b></center></label>
											</div>
										</div>';
				}

				if (trim(strtolower($elemento)) == 'zn'){
					$margin_top = (($margin_top == 0) ? (556 + 40) : ($margin_top + 27));

					$html .= '			<div class="row" style="position: absolute;">
											<div class="col-md-3 col-sm-3 col-xs-3">

											</div>
											<div class="col-md-5 col-sm-5 col-xs-5" Style="background-color: #BF9000; margin-top: '.$margin_top.'px; margin-left: -15px; height: 26px; font-size: 12px; color: #ffffff; width: 23.7%; border: solid; border-width: 1px; border-color: #D9D9D9;">
												<label style="text-align: right; margin-top: 1px">
													<b>Zn - ZINC (%)</b>
												</label>
											</div>
											<div class="col-md-5 col-sm-5 col-xs-5" Style="background-color: #ffffff; margin-top: '.$margin_top.'px; margin-left: -9px; height: 26px; font-size: 12px; color: #000000; width: 15.3%; border: solid; border-width: 1px; border-color: #D9D9D9;">
												<label style="text-align: left; margin-top: 1px;"><center><b>'.number_format($zn, 2, '.', ',').'</b></center></label>
											</div>
										</div>';
				}

				if (trim(strtolower($elemento)) == 'as'){
					$margin_top = (($margin_top == 0) ? (556 + 40) : ($margin_top + 27));

					$html .= '			<div class="row" style="position: absolute;">
											<div class="col-md-3 col-sm-3 col-xs-3">

											</div>
											<div class="col-md-5 col-sm-5 col-xs-5" Style="background-color: #BF9000; margin-top: '.$margin_top.'px; margin-left: -15px; height: 26px; font-size: 12px; color: #ffffff; width: 23.7%; border: solid; border-width: 1px; border-color: #D9D9D9;">
												<label style="text-align: right; margin-top: 1px">
													<b>As - ARSÉNICO (%)</b>
												</label>
											</div>
											<div class="col-md-5 col-sm-5 col-xs-5" Style="background-color: #ffffff; margin-top: '.$margin_top.'px; margin-left: -9px; height: 26px; font-size: 12px; color: #000000; width: 15.3%; border: solid; border-width: 1px; border-color: #D9D9D9;">
												<label style="text-align: left; margin-top: 1px;"><center><b>'.number_format($as, 2, '.', ',').'</b></center></label>
											</div>
										</div>';
				}

				if (trim(strtolower($elemento)) == 'sb'){
					$margin_top = (($margin_top == 0) ? (556 + 40) : ($margin_top + 27));

					$html .= '			<div class="row" style="position: absolute;">
											<div class="col-md-3 col-sm-3 col-xs-3">

											</div>
											<div class="col-md-5 col-sm-5 col-xs-5" Style="background-color: #BF9000; margin-top: '.$margin_top.'px; margin-left: -15px; height: 26px; font-size: 12px; color: #ffffff; width: 23.7%; border: solid; border-width: 1px; border-color: #D9D9D9;">
												<label style="text-align: right; margin-top: 1px">
													<b>Sb - ANTIMONIO (%)</b>
												</label>
											</div>
											<div class="col-md-5 col-sm-5 col-xs-5" Style="background-color: #ffffff; margin-top: '.$margin_top.'px; margin-left: -9px; height: 26px; font-size: 12px; color: #000000; width: 15.3%; border: solid; border-width: 1px; border-color: #D9D9D9;">
												<label style="text-align: left; margin-top: 1px;"><center><b>'.number_format($sb, 2, '.', ',').'</b></center></label>
											</div>
										</div>';
				}

				if (trim(strtolower($elemento)) == 's'){
					$margin_top = (($margin_top == 0) ? (556 + 40) : ($margin_top + 27));

					$html .= '			<div class="row" style="position: absolute;">
											<div class="col-md-3 col-sm-3 col-xs-3">

											</div>
											<div class="col-md-5 col-sm-5 col-xs-5" Style="background-color: #BF9000; margin-top: '.$margin_top.'px; margin-left: -15px; height: 26px; font-size: 12px; color: #ffffff; width: 23.7%; border: solid; border-width: 1px; border-color: #D9D9D9;">
												<label style="text-align: right; margin-top: 1px">
													<b>S - AZUFRE (%)</b>
												</label>
											</div>
											<div class="col-md-5 col-sm-5 col-xs-5" Style="background-color: #ffffff; margin-top: '.$margin_top.'px; margin-left: -9px; height: 26px; font-size: 12px; color: #000000; width: 15.3%; border: solid; border-width: 1px; border-color: #D9D9D9;">
												<label style="text-align: left; margin-top: 1px;"><center><b>'.number_format($s, 2, '.', ',').'</b></center></label>
											</div>
										</div>';
				}

				if (trim(strtolower($elemento)) == 'fe'){
					$margin_top = (($margin_top == 0) ? (556 + 40) : ($margin_top + 27));

					$html .= '			<div class="row" style="position: absolute;">
											<div class="col-md-3 col-sm-3 col-xs-3">

											</div>
											<div class="col-md-5 col-sm-5 col-xs-5" Style="background-color: #BF9000; margin-top: '.$margin_top.'px; margin-left: -15px; height: 26px; font-size: 12px; color: #ffffff; width: 23.7%; border: solid; border-width: 1px; border-color: #D9D9D9;">
												<label style="text-align: right; margin-top: 1px">
													<b>Fe - FIERRO (%)</b>
												</label>
											</div>
											<div class="col-md-5 col-sm-5 col-xs-5" Style="background-color: #ffffff; margin-top: '.$margin_top.'px; margin-left: -9px; height: 26px; font-size: 12px; color: #000000; width: 15.3%; border: solid; border-width: 1px; border-color: #D9D9D9;">
												<label style="text-align: left; margin-top: 1px;"><center><b>'.number_format($fe, 2, '.', ',').'</b></center></label>
											</div>
										</div>';
				}

				if (trim(strtolower($elemento)) == 'h2o'){
					$margin_top = (($margin_top == 0) ? (556 + 40) : ($margin_top + 27));

					$html .= '			<div class="row" style="position: absolute;">
											<div class="col-md-3 col-sm-3 col-xs-3">

											</div>
											<div class="col-md-5 col-sm-5 col-xs-5" Style="background-color: #BF9000; margin-top: '.$margin_top.'px; margin-left: -15px; height: 26px; font-size: 12px; color: #ffffff; width: 23.7%; border: solid; border-width: 1px; border-color: #D9D9D9;">
												<label style="text-align: right; margin-top: 1px">
													<b>H2O - HUMEDAD (%)</b>
												</label>
											</div>
											<div class="col-md-5 col-sm-5 col-xs-5" Style="background-color: #ffffff; margin-top: '.$margin_top.'px; margin-left: -9px; height: 26px; font-size: 12px; color: #000000; width: 15.3%; border: solid; border-width: 1px; border-color: #D9D9D9;">
												<label style="text-align: left; margin-top: 1px;"><center><b>'.number_format($ho, 2, '.', ',').'</b></center></label>
											</div>
										</div>';
				}

				$e += 1;
			}

	// Agregar Observación
		if (strlen(trim($obs_reporte)) > 0){
			$html .= '			<div class="row" style="position: absolute;">
								<div class="col-md-3 col-sm-3 col-xs-3">

								</div>
								<div class="col-md-5 col-sm-5 col-xs-5" Style="background-color: #ffffff; margin-top: 860px; margin-left: -15px; height: 36px; font-size: 12px; text-align: center; border: solid; border-width: 1px; border-color: #D9D9D9; vertical-align: middle">
									<label style="margin-top: '.((strlen(trim($obs_reporte)) >= 43) ? '1' : '5').'px; vertical-align: middle"><center>
										<b>'.$obs_reporte.'</b>
									</center></label>
								</div>
							</div>';
		}

	// Fecha de Emisión
		$html .= '			<div class="row" style="position: absolute;">
								<div class="col-md-1 col-sm-1 col-xs-1">

								</div>
								<div class="col-md-4 col-sm-4 col-xs-4" Style="background-color: #BF9000; margin-top: 910px; margin-left: 15px; height: 26px; font-size: 12px; color: #ffffff; width: 23.7%; border: solid; border-width: 1px; border-color: #D9D9D9;">
									<label style="text-align: right; margin-top: 1px">
										<b>FECHA DE EMISIÓN</b>
									</label>
								</div>
								<div class="col-md-5 col-sm-5 col-xs-5" Style="background-color: #ffffff; margin-top: 910px; margin-left: -9px; height: 26px; font-size: 12px; color: #000000; width: 15.3%; border: solid; border-width: 1px; border-color: #D9D9D9;">
									<label style="text-align: left; margin-top: 1px;"><center><b>'.$fecha_informe.'</b></center></label>
								</div>
							</div>';

	// Finalizando html
		$html .= '				
							</div>
						</body>
				  	</html>';

	// $options = new Options();
	// $options -> set('enable-javascript', TRUE);

	// $document = new Dompdf($options);
	$document = new Dompdf();

	$document -> loadHtml($html,'UTF-8');
	$document -> setPaper('A4', 'postrait');
	$document -> render();
	$document -> stream((($sucursal == 2) ? 'SU ' : '').$correlativo, array('Attachment' => 0));


?>
