<?php 
	include("encabezado.php");
	require_once('../Connections/pandora.php');
	
	//ESTO PARA OCULTAR LOS PARÁMETROS GET
	if (!$_GET){
		$_SESSION['got'] = $_GET;
		$uri_parts = explode('?', $_SERVER['REQUEST_URI'], 2);
		$actual_link = "http://$_SERVER[HTTP_HOST]" . $uri_parts[0];
		echo $actual_link;
        header('Location: ' . $actual_link);
        die;
    }
    else{
		if (!empty($_SESSION['got'])){
			$_GET = $_SESSION['got'];
			unset($_SESSION['got']);
		}
		
		$currentPage = $_SERVER["PHP_SELF"];
		$maxRows_Recordset1 = 5;
		$pageNum_Recordset1 = 0;
		if (isset($_GET['pageNum_Recordset1'])) {
		  $pageNum_Recordset1 = $_GET['pageNum_Recordset1'];
		}
		$startRow_Recordset1 = $pageNum_Recordset1 * $maxRows_Recordset1;
		$idMarca = $idSegmento = $idModelo = "";
		
		//Controlamos que no haya pasado con parametros vacíos
		if ((!isset($_GET['modelo']) || $_GET['modelo'] == "" || 
				$_GET['modelo'] == '0')
			&& (!isset($_GET['codigo_pieza']) || $_GET['codigo_pieza'] == "") 
			&& (!isset($_GET['diametro']) || $_GET['diametro'] == "") 
			&& (!isset($_GET['longitud']) || $_GET['longitud'] == "")
			&& (!isset($_GET['tipo_pieza']) || 
					(isset($_GET['tipo_pieza']) && $_GET['tipo_pieza'] != "Movimiento"))
		   ){
			//Y que las variables de sesión estén vacías (sino es que volvió para atrás del detalle)
			if ($_SESSION['idMarca'] == "" && $_SESSION['segmento'] == "" 
			&& $_SESSION['modelo'] == "" && $_SESSION['codigo_pieza'] == ""
			&& $_SESSION['diametro'] == "" && $_SESSION['longitud'] == ""
			&& $_SESSION['tipo_pieza'] == ""){	
				header("Location: http://www.etma.com.ar/catalogo");
				exit;	
			}
		}
		
		if (isset($_GET['idMarca'])) {
			$_SESSION['idMarca'] = $_GET['idMarca'];
			if (isset($_GET['segmento'])) {
				$_SESSION['segmento'] = $_GET['segmento'];
				if (isset($_GET['modelo'])) {
					$_SESSION['modelo'] = $_GET['modelo'];
				}
			}
			$_SESSION['codigo_pieza'] = "";
			$_SESSION['diametro'] = "";
			$_SESSION['longitud'] = "";
			$_SESSION['tipo_pieza'] = "";
		}
		if (isset($_GET['codigo_pieza'])) {
			$_SESSION['idMarca'] = "";
			$_SESSION['segmento'] = "";
			$_SESSION['modelo'] = "";
			$_SESSION['codigo_pieza'] = $_GET['codigo_pieza'];
			$_SESSION['diametro'] = "";
			$_SESSION['longitud'] = "";
			$_SESSION['tipo_pieza'] = "";
		}
		if (isset($_GET['tipo_pieza'])) {
			$_SESSION['idMarca'] = "";
			$_SESSION['segmento'] = "";
			$_SESSION['modelo'] = "";
			$_SESSION['codigo_pieza'] = "";
			$_SESSION['diametro'] = $_GET['diametro'];
			$_SESSION['longitud'] = $_GET['longitud'];
			$_SESSION['tipo_pieza'] = $_GET['tipo_pieza'];
		}
		
		//PARA TEST
		//echo "TipoPieza: " . $_GET['tipo_pieza'] . " - Diametro: " . $_GET['diametro'] . " - SesionDiametro: " . $_SESSION['diametro'] . " - Longitud: " . $_GET['longitud'] . " SesiónLongitud: " . $_SESSION['longitud'];
		
		$query_Recordset1 = "SELECT pieza.* FROM pieza";
		//BÚSQUEDA POR MARCA/SEGMENTO/MODELO
		if (isset($_SESSION['idMarca']) && $_SESSION['idMarca'] != "") { 
			$query_Recordset1 = sprintf("%s INNER JOIN vehiculo ON pieza.id = vehiculo.id_pieza LEFT JOIN segmento ON vehiculo.id_segmento = segmento.id  WHERE id_marcavehiculo = '%s'", $query_Recordset1, $_SESSION['idMarca']);
			if (isset($_SESSION['segmento']) && $_SESSION['segmento'] != "" && $_SESSION['segmento'] != '0'){
				$query_Recordset1 = sprintf("%s AND segmento = '%s'", $query_Recordset1, $_SESSION['segmento']);
				if (isset($_SESSION['modelo']) && $_SESSION['modelo'] != "" && $_SESSION['modelo'] != '0'){
					$query_Recordset1 = sprintf("%s AND modelo = '%s'", $query_Recordset1, $_SESSION['modelo']);
				}
			}
			$query_Recordset1 = sprintf("%s GROUP BY pieza.id ORDER BY pieza.id", $query_Recordset1);
		}
		//BÚSQUEDA POR CÓDIGO DE PIEZA
		else if (isset($_SESSION['codigo_pieza']) && $_SESSION['codigo_pieza'] != "" ) {  
			$codigo = $_SESSION['codigo_pieza'];
			//$oemPosible = "%" . $_SESSION['codigo_pieza'] . "%";
			$oemPosible = $_SESSION['codigo_pieza'];
			$query_Recordset1 = sprintf("%s INNER JOIN piezacodigo ON pieza.id = piezacodigo.id_pieza WHERE codigo = '%s' UNION SELECT pieza.* FROM pieza INNER JOIN vehiculo ON pieza.id = vehiculo.id_pieza WHERE oems = '%s'",$query_Recordset1, $codigo, $oemPosible);
		}
		//BÚSQUEDA POR MEDIDA
		else if (isset($_SESSION['tipo_pieza'])){
			$tipoPieza = $_SESSION['tipo_pieza'];
			$query_Recordset1 = sprintf("%s WHERE tipoPieza = '%s'", $query_Recordset1, $tipoPieza);
			
			//CRUCETA
			if ($tipoPieza == "Cruceta"){
				if (isset($_SESSION['diametro']) && $_SESSION['diametro'] != "") {  //CARGÓ DIAMETRO
					$diametro = $_SESSION['diametro'];
					$diametro = str_replace(',', '.', $diametro);
					$diametroMenor = $diametro - 0.5;
					$diametroMayor = $diametro + 0.5;
					$query_Recordset1 = sprintf("%s AND (
						(CAST(REPLACE(C1, ',', '.') AS DECIMAL(10,4)) >= %s 
							AND CAST(REPLACE(C1, ',', '.') AS DECIMAL(10,4)) <= %s) 
						OR (CAST(REPLACE(Di, ',', '.') AS DECIMAL(10,4)) >= %s 
							AND CAST(REPLACE(Di, ',', '.') AS DECIMAL(10,4)) <= %s) 
						OR (CAST(REPLACE(S1, ',', '.') AS DECIMAL(10,4)) >= %s 
							AND CAST(REPLACE(S1, ',', '.') AS DECIMAL(10,4)) <= %s)",$query_Recordset1, $diametroMenor, $diametroMayor, $diametroMenor, $diametroMayor, $diametroMenor, $diametroMayor);
					if (isset($_SESSION['longitud']) && $_SESSION['longitud']){   //Y TAMBIÉN LONGITUD
						$longitud = $_SESSION['longitud'];
						$longitud = str_replace(',', '.', $longitud);
						$longitudMenor = $longitud - 0.5;
						$longitudMayor = $longitud + 0.5;
						$query_Recordset1 = sprintf("%s AND (
						(CAST(REPLACE(A1, ',', '.') AS DECIMAL(10,4)) >= %s 
							AND CAST(REPLACE(A1, ',', '.') AS DECIMAL(10,4)) <= %s) 
						OR (CAST(REPLACE(A2, ',', '.') AS DECIMAL(10,4)) >= %s 
							AND CAST(REPLACE(A2, ',', '.') AS DECIMAL(10,4)) <= %s) 
						OR (CAST(REPLACE(B1, ',', '.') AS DECIMAL(10,4)) >= %s 
							AND CAST(REPLACE(B1, ',', '.') AS DECIMAL(10,4)) <= %s) 
						OR (CAST(REPLACE(C2, ',', '.') AS DECIMAL(10,4)) >= %s 
							AND CAST(REPLACE(C2, ',', '.') AS DECIMAL(10,4)) <= %s) 
						OR (CAST(REPLACE(C3, ',', '.') AS DECIMAL(10,4)) >= %s 
							AND CAST(REPLACE(C3, ',', '.') AS DECIMAL(10,4)) <= %s) 
						OR (CAST(REPLACE(C4, ',', '.') AS DECIMAL(10,4)) >= %s 
							AND CAST(REPLACE(C4, ',', '.') AS DECIMAL(10,4)) <= %s) 
						OR (CAST(REPLACE(D1, ',', '.') AS DECIMAL(10,4)) >= %s 
							AND CAST(REPLACE(D1, ',', '.') AS DECIMAL(10,4)) <= %s) 
						OR (CAST(REPLACE(D2, ',', '.') AS DECIMAL(10,4)) >= %s 
							AND CAST(REPLACE(D2, ',', '.') AS DECIMAL(10,4)) <= %s) 
						OR (CAST(REPLACE(H, ',', '.') AS DECIMAL(10,4)) >= %s 
							AND CAST(REPLACE(H, ',', '.') AS DECIMAL(10,4)) <= %s) 
						OR (CAST(REPLACE(H1, ',', '.') AS DECIMAL(10,4)) >= %s 
							AND CAST(REPLACE(H1, ',', '.') AS DECIMAL(10,4)) <= %s))",$query_Recordset1, $longitudMenor, $longitudMayor, $longitudMenor, $longitudMayor, $longitudMenor, $longitudMayor, $longitudMenor, $longitudMayor, $longitudMenor, $longitudMayor, $longitudMenor, $longitudMayor, $longitudMenor, $longitudMayor, $longitudMenor, $longitudMayor, $longitudMenor, $longitudMayor, $longitudMenor, $longitudMayor);
					}
					$query_Recordset1 = sprintf("%s)", $query_Recordset1);
				}
				else if (isset($_SESSION['longitud']) && $_SESSION['longitud']){  //SOLO CARGÓ LONGITUD
					$longitud = $_SESSION['longitud'];
					$longitud = str_replace(',', '.', $longitud);
					$longitudMenor = $longitud - 0.5;
					$longitudMayor = $longitud + 0.5;
					$query_Recordset1 = sprintf("%s AND (
						(CAST(REPLACE(A1, ',', '.') AS DECIMAL(10,4)) >= %s 
							AND CAST(REPLACE(A1, ',', '.') AS DECIMAL(10,4)) <= %s) 
						OR (CAST(REPLACE(A2, ',', '.') AS DECIMAL(10,4)) >= %s 
							AND CAST(REPLACE(A2, ',', '.') AS DECIMAL(10,4)) <= %s) 
						OR (CAST(REPLACE(B1, ',', '.') AS DECIMAL(10,4)) >= %s 
							AND CAST(REPLACE(B1, ',', '.') AS DECIMAL(10,4)) <= %s) 
						OR (CAST(REPLACE(C2, ',', '.') AS DECIMAL(10,4)) >= %s 
							AND CAST(REPLACE(C2, ',', '.') AS DECIMAL(10,4)) <= %s) 
						OR (CAST(REPLACE(C3, ',', '.') AS DECIMAL(10,4)) >= %s 
							AND CAST(REPLACE(C3, ',', '.') AS DECIMAL(10,4)) <= %s) 
						OR (CAST(REPLACE(C4, ',', '.') AS DECIMAL(10,4)) >= %s 
							AND CAST(REPLACE(C4, ',', '.') AS DECIMAL(10,4)) <= %s) 
						OR (CAST(REPLACE(D1, ',', '.') AS DECIMAL(10,4)) >= %s 
							AND CAST(REPLACE(D1, ',', '.') AS DECIMAL(10,4)) <= %s) 
						OR (CAST(REPLACE(D2, ',', '.') AS DECIMAL(10,4)) >= %s 
							AND CAST(REPLACE(D2, ',', '.') AS DECIMAL(10,4)) <= %s) 
						OR (CAST(REPLACE(H, ',', '.') AS DECIMAL(10,4)) >= %s 
							AND CAST(REPLACE(H, ',', '.') AS DECIMAL(10,4)) <= %s) 
						OR (CAST(REPLACE(H1, ',', '.') AS DECIMAL(10,4)) >= %s 
							AND CAST(REPLACE(H1, ',', '.') AS DECIMAL(10,4)) <= %s))",$query_Recordset1, $longitudMenor, $longitudMayor, $longitudMenor, $longitudMayor, $longitudMenor, $longitudMayor, $longitudMenor, $longitudMayor, $longitudMenor, $longitudMayor, $longitudMenor, $longitudMayor, $longitudMenor, $longitudMayor, $longitudMenor, $longitudMayor, $longitudMenor, $longitudMayor, $longitudMenor, $longitudMayor);
				}
			}
			//TRICETA
			else if ($tipoPieza == "Triceta"){
				if (isset($_SESSION['diametro']) && $_SESSION['diametro'] != "") {  //CARGÓ DIAMETRO
					$diametro = $_SESSION['diametro'];
					$diametro = str_replace(',', '.', $diametro);
					$diametroMenor = $diametro - 0.5;
					$diametroMayor = $diametro + 0.5;
					$query_Recordset1 = sprintf("%s AND (
						(CAST(REPLACE(C1, ',', '.') AS DECIMAL(10,4)) >= %s 
							AND CAST(REPLACE(C1, ',', '.') AS DECIMAL(10,4)) <= %s) 
						OR (CAST(REPLACE(Di, ',', '.') AS DECIMAL(10,4)) >= %s 
							AND CAST(REPLACE(Di, ',', '.') AS DECIMAL(10,4)) <= %s) 
						OR (CAST(REPLACE(S1, ',', '.') AS DECIMAL(10,4)) >= %s 
							AND CAST(REPLACE(S1, ',', '.') AS DECIMAL(10,4)) <= %s)",$query_Recordset1, $diametroMenor, $diametroMayor, $diametroMenor, $diametroMayor, $diametroMenor, $diametroMayor);
					if (isset($_SESSION['longitud']) && $_SESSION['longitud'] 
					&& is_numeric($_SESSION['longitud'])){   //Y TAMBIÉN LONGITUD(ESTRIAS)
						$longitudMenor = $_SESSION['longitud'] - 0.5;
						$longitudMayor = $_SESSION['longitud'] + 0.5;
						$query_Recordset1 = sprintf("%s) AND (
							CAST(REPLACE(Z, ',', '.') AS DECIMAL(10,4)) >= %s 
								AND CAST(REPLACE(Z, ',', '.') AS DECIMAL(10,4)) <= %s",$query_Recordset1,  $longitudMenor, $longitudMayor);
					}
					$query_Recordset1 = sprintf("%s)", $query_Recordset1);
				}
				else if (isset($_SESSION['longitud']) && $_SESSION['longitud']){  //SOLO CARGÓ LONGITUD (ESTRIAS)
					$longitud = $_SESSION['longitud'];
					$longitud = str_replace(',', '.', $longitud);
					$longitudMenor = $_SESSION['longitud'] - 0.5;
					$longitudMayor = $_SESSION['longitud'] + 0.5;
					$query_Recordset1 = sprintf("%s AND (
						CAST(REPLACE(Z, ',', '.') AS DECIMAL(10,4)) >= %s 
							AND CAST(REPLACE(Z, ',', '.') AS DECIMAL(10,4)) <= %s)",$query_Recordset1, $longitudMenor, $longitudMayor);
				}
			}
		}
		
		//PARA TEST
		//echo "_SESSION Seteada? = " . isset($_SESSION['idMarca']) . " - Valor idMarca = " . $_SESSION['idMarca'];
		//echo "TipoPieza:". $_SESSION['tipo_pieza'];
		//echo "\n CONSULTA SQL: ". $query_Recordset1;
		$query_limit_Recordset1 = sprintf("%s LIMIT %d, %d", $query_Recordset1, $startRow_Recordset1, $maxRows_Recordset1);
		$Recordset1 = mysqli_query($catalogo, $query_limit_Recordset1) or die(mysql_error());
		$row_Recordset1 = $Recordset1->fetch_assoc();
		
		if (isset($_GET['totalRows_Recordset1'])) {
		  $totalRows_Recordset1 = $_GET['totalRows_Recordset1'];
		} else {
		  $all_Recordset1 = mysqli_query($catalogo, $query_Recordset1);
		  $totalRows_Recordset1 = $all_Recordset1->num_rows;
		}
		$totalPages_Recordset1 = ceil($totalRows_Recordset1/$maxRows_Recordset1)-1;
		
		$queryString_Recordset1 = "";
		if (!empty($_SERVER['QUERY_STRING'])) {
		  $params = explode("&", $_SERVER['QUERY_STRING']);
		  $newParams = array();
		  foreach ($params as $param) {
			if (stristr($param, "pageNum_Recordset1") == false && 
				stristr($param, "totalRows_Recordset1") == false) {
			  array_push($newParams, $param);
			}
		  }
		  if (count($newParams) != 0) {
			$queryString_Recordset1 = "&" . htmlentities(implode("&", $newParams));
		  }
		}
		$queryString_Recordset1 = sprintf("&totalRows_Recordset1=%d%s", $totalRows_Recordset1, $queryString_Recordset1);
    } 
?>
<div class="contenido">
<p>&nbsp; </p>
<div style="overflow-x:auto">
<table border="0" cellpadding="5" cellspacing="0" width="100%">
  <?php 
  if ($totalRows_Recordset1 > 0){
	  ?>
      <tr style="background-image:url(imagenes/fondo_2.png); height:90px; color:#000; font-size:1.2em; border-radius:8px; ">
      		<td align="center"><?php echo $diccionario['ver']; ?></td>
            <td align="center"><?php echo $diccionario['codigos']; ?></td>
            <td align="center"><?php echo $diccionario['pieza']; ?></td>
       <?php 
 		 if ($_SESSION['tipo_pieza'] != "" && $_SESSION['tipo_pieza'] == "Cruceta"){
	  	?>
            <td align="center"><?php echo $diccionario['a1']; ?></td>
            <td align="center"><?php echo $diccionario['a2']; ?></td>
            <td align="center"><?php echo $diccionario['b1']; ?></td>
            <td align="center"><?php echo $diccionario['c1']; ?></td>
            <td align="center"><?php echo $diccionario['c1prima']; ?></td>
            <td align="center"><?php echo $diccionario['c2']; ?></td>
            <td align="center"><?php echo $diccionario['c3']; ?></td>
            <td align="center"><?php echo $diccionario['c4']; ?></td>
            <td align="center"><?php echo $diccionario['d1']; ?></td>
            <td align="center"><?php echo $diccionario['d2']; ?></td>
            <td align="center"><?php echo $diccionario['largo_sin_cubetas']; ?></td>
            <td align="center"><?php echo $diccionario['diametro_munion']; ?></td>
            <td align="center"><?php echo $diccionario['descripcion_cubetas']; ?></td>
        <?php 
		 }
		 else if ($_SESSION['tipo_pieza'] != "" && $_SESSION['tipo_pieza'] == "Triceta"){  
		 ?>
         	<td align="center"><?php echo $diccionario['c1']; ?></td>
            <td align="center"><?php echo $diccionario['h']; ?></td>
            <td align="center"><?php echo $diccionario['h1']; ?></td>
            <td align="center"><?php echo $diccionario['s1']; ?></td>
            <td align="center"><?php echo $diccionario['di']; ?></td>
            <td align="center"><?php echo $diccionario['z']; ?></td>
            <td align="center"><?php echo $diccionario['diametro_munion']; ?></td>
            <td align="center"><?php echo $diccionario['descripcion_cubetas']; ?></td>
            <?php 
		 }
		 else if ($_SESSION['tipo_pieza'] != "" && $_SESSION['tipo_pieza'] == "Movimiento"){
			?>
            
            <td align="center"><?php echo $diccionario['d1']; ?></td>
            <td align="center"><?php echo $diccionario['d2']; ?></td>
            <td align="center"><?php echo $diccionario['e1']; ?></td>
            <td align="center"><?php echo $diccionario['e2']; ?></td>
            <td align="center"><?php echo $diccionario['f1']; ?></td>
            <td align="center"><?php echo $diccionario['f2']; ?></td>
            <td align="center"><?php echo $diccionario['observaciones']; ?></td>
            <?php
		 } 
		 else {   //TODOS
	  	?>
        	 <td align="center"><?php echo $diccionario['a1']; ?></td>
            <td align="center"><?php echo $diccionario['a2']; ?></td>
            <td align="center"><?php echo $diccionario['b1']; ?></td>
            <td align="center"><?php echo $diccionario['c1']; ?></td>
            <td align="center"><?php echo $diccionario['c1prima']; ?></td>
            <td align="center"><?php echo $diccionario['c2']; ?></td>
            <td align="center"><?php echo $diccionario['c3']; ?></td>
            <td align="center"><?php echo $diccionario['c4']; ?></td>
            <td align="center"><?php echo $diccionario['d1']; ?></td>
            <td align="center"><?php echo $diccionario['d2']; ?></td>
            <td align="center"><?php echo $diccionario['e1']; ?></td>
            <td align="center"><?php echo $diccionario['e2']; ?></td>
            <td align="center"><?php echo $diccionario['f1']; ?></td>
            <td align="center"><?php echo $diccionario['f2']; ?></td>
            <td align="center"><?php echo $diccionario['h']; ?></td>
            <td align="center"><?php echo $diccionario['h1']; ?></td>
            <td align="center"><?php echo $diccionario['s1']; ?></td>
            <td align="center"><?php echo $diccionario['di']; ?></td>
            <td align="center"><?php echo $diccionario['z']; ?></td>
          <?php
		 }
	  	?>
	</tr>
    <tr>
   		<td align="center" style="height:2px;"></td>
    </tr>
      <?php
	  do { ?>
        <tr class="fila">
          <td align="center">
            <a href="tabs_respuesta.php?idPieza=<?php echo $row_Recordset1['id']; ?>">
                <div class="btn_pieza"><img src="imagenes/btn_buscar.png" width="57" height="58" /></div>
            </a>
          </td>
          <td align="center">
          	<?php include("fragmento_codigos_marcas_resultado.php"); ?>
          </td>
          <td align="center">
             <img src="imagenes/Figura/<?php echo $row_Recordset1['rutafichero'].".png"; ?>" width="150px" height="150px" onclick="mostrarPopup(this)" style="cursor:pointer"/>
          </td>
          <?php 
			 if ($_SESSION['tipo_pieza'] != "" && $_SESSION['tipo_pieza'] == "Cruceta"){
			?>
              <td align="center">
                <?php if ($row_Recordset1['a1'] <> "NULL") echo "<b>" . str_replace(".",",",$row_Recordset1['a1']) . "</b>"; else echo '0' ?>
              </td>
              <td align="center">
                <?php if ($row_Recordset1['a2'] <> "NULL") echo "<b>" . str_replace(".",",",$row_Recordset1['a2']) . "</b>"; else echo '0' ?>
              </td>
              <td align="center">
                <?php if ($row_Recordset1['b1'] <> "NULL") echo "<b>" . str_replace(".",",",$row_Recordset1['b1']) . "</b>"; else echo '0' ?>
              </td>
              <td align="center">
                <?php if ($row_Recordset1['c1'] <> "NULL") echo "<b>" . str_replace(".",",",$row_Recordset1['c1']) . "</b>"; else echo '0' ?>
              </td>
              <td align="center">
                <?php if ($row_Recordset1['c1prima'] <> "NULL") echo "<b>" . str_replace(".",",",$row_Recordset1['c1prima']) . "</b>"; else echo '0' ?>
              </td>
              <td align="center">
                <?php if ($row_Recordset1['c2'] <> "NULL") echo "<b>" . str_replace(".",",",$row_Recordset1['c2']) . "</b>"; else echo '0' ?>
              </td>
              <td align="center">
                <?php if ($row_Recordset1['c3'] <> "NULL") echo "<b>" . str_replace(".",",",$row_Recordset1['c3']) . "</b>"; else echo '0' ?>
              </td>
              <td align="center">
                <?php if ($row_Recordset1['c4'] <> "NULL") echo "<b>" . str_replace(".",",",$row_Recordset1['c4']) . "</b>"; else echo '0' ?>
              </td>
              <td align="center">
                <?php if ($row_Recordset1['d1'] <> "NULL") echo "<b>" . str_replace(".",",",$row_Recordset1['d1']) . "</b>"; else echo '0' ?>
              </td>
              <td align="center">
                <?php if ($row_Recordset1['d2'] <> "NULL") echo "<b>" . str_replace(".",",",$row_Recordset1['d2']) . "</b>"; else echo '0' ?>
              </td>
              <td align="center">
                <?php if ($row_Recordset1['largosincubeta'] <> "NULL") echo "<b>" . str_replace(".",",",$row_Recordset1['largosincubeta']) . "</b>"; else echo '0' ?>
              </td>
              <td align="center">
                <?php if ($row_Recordset1['diametromunion'] <> "NULL") echo "<b>" . str_replace(".",",",$row_Recordset1['diametromunion']) . "</b>"; else echo '0' ?>
              </td>
              <td align="center">
                <?php if ($row_Recordset1['descripcioncubetas'] <> "NULL") echo "<b>" . $row_Recordset1['descripcioncubetas'] . "</b>"; else echo '0' ?>
              </td>
         <?php 
		 }
		 else if ($_SESSION['tipo_pieza'] != "" && $_SESSION['tipo_pieza'] == "Triceta"){ ?>
              <td align="center">
                <?php if ($row_Recordset1['c1'] <> "NULL") echo "<b>" . str_replace(".",",",$row_Recordset1['c1']) . "</b>"; else echo '0' ?>
              </td>
              <td align="center">
                <?php if ($row_Recordset1['h'] <> "NULL") echo "<b>" . str_replace(".",",",$row_Recordset1['h']) . "</b>"; else echo '0' ?>
              </td>
              <td align="center">
                <?php if ($row_Recordset1['h1'] <> "NULL") echo "<b>" . str_replace(".",",",$row_Recordset1['h1']) . "</b>"; else echo '0' ?>
              </td>
              <td align="center">
                <?php if ($row_Recordset1['s1'] <> "NULL") echo "<b>" . str_replace(".",",",$row_Recordset1['s1']) . "</b>"; else echo '0' ?>
              </td>
              <td align="center">
                <?php if ($row_Recordset1['di'] <> "NULL") echo "<b>" . str_replace(".",",",$row_Recordset1['di']) . "</b>"; else echo '0' ?>
              </td>
              <td align="center">
                <?php if ($row_Recordset1['z'] <> "NULL") echo "<b>" . str_replace(".",",",$row_Recordset1['z']) . "</b>"; else echo '0' ?>
              </td>
              <td align="center">
                <?php if ($row_Recordset1['diametromunion'] <> "NULL") echo "<b>" . str_replace(".",",",$row_Recordset1['diametromunion']) . "</b>"; else echo '0' ?>
              </td>
              <td align="center">
                <?php if ($row_Recordset1['descripcioncubetas'] <> "NULL") echo "<b>" . $row_Recordset1['descripcioncubetas'] . "</b>"; else echo '0' ?>
              </td>
		 	<?php 
		 }
		 else if ($_SESSION['tipo_pieza'] != "" && $_SESSION['tipo_pieza'] == "Movimiento"){ ?>
         		
              <td align="center">
                <?php if ($row_Recordset1['d1'] <> "NULL") echo "<b>" . str_replace(".",",",$row_Recordset1['d1']) . "</b>"; else echo '0' ?>
              </td>
              <td align="center">
                <?php if ($row_Recordset1['d2'] <> "NULL") echo "<b>" . str_replace(".",",",$row_Recordset1['d2']) . "</b>"; else echo '0' ?>
              </td>
              <td align="center">
                <?php if ($row_Recordset1['e1'] <> "NULL") echo "<b>" . str_replace(".",",",$row_Recordset1['e1']) . "</b>"; else echo '0' ?>
              </td>
              <td align="center">
                 <?php if ($row_Recordset1['e2'] <> "NULL") echo "<b>" . str_replace(".",",",$row_Recordset1['e2']) . "</b>"; else echo '0' ?>
              </td>
              <td align="center">
                <?php if ($row_Recordset1['f1'] <> "NULL") echo "<b>" . str_replace(".",",",$row_Recordset1['f1']) . "</b>"; else echo '0' ?>
              </td>
              <td align="center">
                 <?php if ($row_Recordset1['f2'] <> "NULL") echo "<b>" . str_replace(".",",",$row_Recordset1['f2']) . "</b>"; else echo '0' ?>
              </td>
              <td align="center">
                <?php if ($row_Recordset1['observaciones'] <> "NULL") echo "<b>" . $row_Recordset1['observaciones']. "</b>"; else echo '-' ?>
              </td>
         <?php 
		 }
		 else { ?>
         <td align="center">
                <?php if ($row_Recordset1['a1'] <> "NULL") echo "<b>" . str_replace(".",",",$row_Recordset1['a1']) . "</b>"; else echo '0' ?>
              </td>
              <td align="center">
                <?php if ($row_Recordset1['a2'] <> "NULL") echo "<b>" . str_replace(".",",",$row_Recordset1['a2']) . "</b>"; else echo '0' ?>
              </td>
              <td align="center">
                <?php if ($row_Recordset1['b1'] <> "NULL") echo "<b>" . str_replace(".",",",$row_Recordset1['b1']) . "</b>"; else echo '0' ?>
              </td>
         	 <td align="center">
                <?php if ($row_Recordset1['c1'] <> "NULL") echo "<b>" . str_replace(".",",",$row_Recordset1['c1']) . "</b>"; else echo '0' ?>
              </td>
              	 <td align="center">
                <?php if ($row_Recordset1['c1prima'] <> "NULL") echo "<b>" . str_replace(".",",",$row_Recordset1['c1prima']) . "</b>"; else echo '0' ?>
              </td>
              <td align="center">
                <?php if ($row_Recordset1['c2'] <> "NULL") echo "<b>" . str_replace(".",",",$row_Recordset1['c2']) . "<B>"; else echo '0' ?>
              </td>
              <td align="center">
                <?php if ($row_Recordset1['c3'] <> "NULL") echo "<b>" . str_replace(".",",",$row_Recordset1['c3']) . "</b>"; else echo '0' ?>
              </td>
              <td align="center">
                <?php if ($row_Recordset1['c4'] <> "NULL") echo "<b>" . str_replace(".",",",$row_Recordset1['c4']) . "</b>"; else echo '0' ?>
              </td>
              <td align="center">
                <?php if ($row_Recordset1['d1'] <> "NULL") echo "<b>" . str_replace(".",",",$row_Recordset1['d1']) . "</b>"; else echo '0' ?>
              </td>
              <td align="center">
                <?php if ($row_Recordset1['d2'] <> "NULL") echo "<b>" . str_replace(".",",",$row_Recordset1['d2']) . "</b>"; else echo '0' ?>
              </td>
              <td align="center">
                <?php if ($row_Recordset1['e1'] <> "NULL") echo "<b>" . str_replace(".",",",$row_Recordset1['e1']) . "</b>"; else echo '0' ?>
              </td>
              <td align="center">
                 <?php if ($row_Recordset1['e2'] <> "NULL") echo "<b>" . str_replace(".",",",$row_Recordset1['e2']) . "</b>"; else echo '0' ?>
              </td>
              <td align="center">
                <?php if ($row_Recordset1['f1'] <> "NULL") echo "<b>" . str_replace(".",",",$row_Recordset1['f1']) . "</b>"; else echo '0' ?>
              </td>
              <td align="center">
                 <?php if ($row_Recordset1['f2'] <> "NULL") echo "<b>" . str_replace(".",",",$row_Recordset1['f2']) . "</b>"; else echo '0' ?>
              </td>
              <td align="center">
                <?php if ($row_Recordset1['h'] <> "NULL") echo "<b>" . str_replace(".",",",$row_Recordset1['h']) . "</b>"; else echo '0' ?>
              </td>
              <td align="center">
                <?php if ($row_Recordset1['h1'] <> "NULL") echo "<b>" . str_replace(".",",",$row_Recordset1['h1']) . "</b>"; else echo '0' ?>
              </td>
              <td align="center">
                <?php if ($row_Recordset1['s1'] <> "NULL") echo "<b>" . str_replace(".",",",$row_Recordset1['s1']) . "</b>"; else echo '0' ?>
              </td>
              <td align="center">
                <?php if ($row_Recordset1['di'] <> "NULL") echo "<b>" . str_replace(".",",",$row_Recordset1['di']) . "</b>"; else echo '0' ?>
              </td>
              <td align="center">
                <?php if ($row_Recordset1['z'] <> "NULL") echo "<b>" . str_replace(".",",",$row_Recordset1['z']) . "</b>"; else echo '0' ?>
              </td>
         <?php } 
		 ?>
        </tr>
        </tr>
        <td></td>
    <?php } while ($row_Recordset1 = $Recordset1->fetch_assoc()); 
	}?><tr>
</table>
</div>
<p>
<table border="0" width="100%" style="height:90px; border-radius:8px;  background-image:url(imagenes/fondo_2.png);">
  <tr>
  	 <?php 
  		if ($totalRows_Recordset1 > 0){?>
            <td align="center" width="5%">
				<?php if ($pageNum_Recordset1 > 0) { // Show if not first page ?>
                <a href="<?php printf("%s?pageNum_Recordset1=%d%s", $currentPage, 0, $queryString_Recordset1); ?>"><img src="imagenes/btn_primero.png" /></a>
           		<?php } // Show if not first page ?>
            </td>
            <td align="center" width="5%">
				<?php if ($pageNum_Recordset1 > 0) { // Show if not first page ?>
                <a href="<?php printf("%s?pageNum_Recordset1=%d%s", $currentPage, max(0, $pageNum_Recordset1 - 1), $queryString_Recordset1); ?>"><img src="imagenes/btn_ant.png" /></a>
            	<?php } // Show if not first page ?>
            </td>
            <td align="center" width="90%">
            	
            </td>
            <td align="center" width="5%">
				<?php if ($pageNum_Recordset1 < $totalPages_Recordset1) { // Show if not last page ?>
                <a href="<?php printf("%s?pageNum_Recordset1=%d%s", $currentPage, min($totalPages_Recordset1, $pageNum_Recordset1 + 1), $queryString_Recordset1); ?>"><img src="imagenes/btn_sig.png" /></a>
            <?php } // Show if not last page ?>
            </td>
            <td align="center" width="5%">
				<?php if ($pageNum_Recordset1 < $totalPages_Recordset1) { // Show if not last page ?>
                <a href="<?php printf("%s?pageNum_Recordset1=%d%s", $currentPage, $totalPages_Recordset1, $queryString_Recordset1); ?>"><img src="imagenes/btn_ultimo.png" /></a>
            <?php } // Show if not last page ?>
            </td>
    <?php 
	}
	else{?>
    	<td align="center" style="font-weight:bold;">
        	<br />
            <br />
            <h2>
            <a href="index.php">
        	<img src="imagenes/solo_logo_transparente_original.png" width="97" height="83" style="vertical-align:middle; margin-top:-10px; margin-left:25px">
            </a>
                    
            
        	<?php echo $diccionario['no_resultados_para_busqueda']; ?>
            </h2>
            	<?php include('ayuda.php') ?>
            <br />
            <br />

            <br />
            <br />
        </td>
    <?php 
	}?>
  </tr>
</table>
</p>
</div>
<div class="focus" style="text-align:center;" onclick="cerrarPopup()">
    <div class="container">
    </div>
</div>
<?php 
	include("pie.php"); 
?>
</body>
<script type="text/javascript">
	function mostrarPopup(sel){
		var focus = $('.focus');
 		var container = $('.focus .container');
		container.empty();
		container.append('<img src=\"' + sel.src + '\" widht="500px" height="500px" style="background-color:#fff"/>');
		focus.fadeIn().addClass('enabled');
		$('.contenido').append('<div class="overlay" style="z-index:10000;"></div>');

	}
	function cerrarPopup(){
		var options = {};
		$( ".focus" ).hide( "fade", options, 300, null );
		
		setTimeout(function() {
			$('.focus').css('display', 'none').removeClass('enabled');
    		$('.contenido').removeClass('darken');
    		$('.overlay').remove();
      	}, 300 );
	}

</script>
<?php
	mysqli_free_result($Recordset1);
?>
</html>
