<?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_Recordsetst = 25;
		$pageNum_Recordsetst = 0;
		if (isset($_GET['pageNum_Recordsetst'])) {
		  $pageNum_Recordsetst = $_GET['pageNum_Recordsetst'];
		}
		$startRow_Recordsetst = $pageNum_Recordsetst * $maxRows_Recordsetst;
		$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_Recordsetst = "SELECT pieza_strong.* FROM pieza_strong";
		//$query_Recordsetst = "select pieza.*, piezacodigo.id_marca from pieza left join piezacodigo on pieza.id = piezacodigo.id_pieza where id_marca = 'c8730441-b37d-4824-8a40-a00c22ba8979' or id_marca = '2be8c832-3d18-4721-b64f-9dfc16d02c8e' or id_marca = '1417ea7e-7f6c-4854-9e23-becf7bb4582a'";
		//BÚSQUEDA POR MARCA/SEGMENTO/MODELO
		if (isset($_SESSION['idMarca']) && $_SESSION['idMarca'] != "") { 
			$query_Recordsetst = sprintf("%s INNER JOIN vehiculo ON pieza_strong.id = vehiculo.id_pieza LEFT JOIN segmento ON vehiculo.id_segmento = segmento.id  WHERE id_marcavehiculo = '%s'", $query_Recordsetst, $_SESSION['idMarca']);
			if (isset($_SESSION['segmento']) && $_SESSION['segmento'] != "" && $_SESSION['segmento'] != '0'){
				$query_Recordsetst = sprintf("%s AND segmento = '%s'", $query_Recordsetst, $_SESSION['segmento']);
				if (isset($_SESSION['modelo']) && $_SESSION['modelo'] != "" && $_SESSION['modelo'] != '0'){
					$query_Recordsetst = sprintf("%s AND modelo = '%s'", $query_Recordsetst, $_SESSION['modelo']);
				}
			}
			$query_Recordsetst = sprintf("%s GROUP BY pieza_strong.id ORDER BY pieza_strong.id", $query_Recordsetst);
		}
		//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_Recordsetst = sprintf("%s INNER JOIN piezacodigo ON pieza_strong.id = piezacodigo.id_pieza WHERE codigo = '%s' UNION SELECT pieza_strong.* FROM pieza_strong INNER JOIN vehiculo ON pieza_strong.id = vehiculo.id_pieza WHERE oems = '%s'",$query_Recordsetst, $codigo, $oemPosible);
		}
		//BÚSQUEDA POR MEDIDA
		else if (isset($_SESSION['tipo_pieza'])){
			$tipoPieza = $_SESSION['tipo_pieza'];
			$query_Recordsetst = sprintf("%s WHERE tipoPieza = '%s'", $query_Recordsetst, $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_Recordsetst = 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_Recordsetst, $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_Recordsetst = 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_Recordsetst, $longitudMenor, $longitudMayor, $longitudMenor, $longitudMayor, $longitudMenor, $longitudMayor, $longitudMenor, $longitudMayor, $longitudMenor, $longitudMayor, $longitudMenor, $longitudMayor, $longitudMenor, $longitudMayor, $longitudMenor, $longitudMayor, $longitudMenor, $longitudMayor, $longitudMenor, $longitudMayor);
					}
					$query_Recordsetst = sprintf("%s)", $query_Recordsetst);
				}
				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_Recordsetst = 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_Recordsetst, $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_Recordsetst = 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_Recordsetst, $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_Recordsetst = sprintf("%s) AND (
							CAST(REPLACE(Z, ',', '.') AS DECIMAL(10,4)) >= %s 
								AND CAST(REPLACE(Z, ',', '.') AS DECIMAL(10,4)) <= %s",$query_Recordsetst,  $longitudMenor, $longitudMayor);
					}
					$query_Recordsetst = sprintf("%s)", $query_Recordsetst);
				}
				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_Recordsetst = sprintf("%s AND (
						CAST(REPLACE(Z, ',', '.') AS DECIMAL(10,4)) >= %s 
							AND CAST(REPLACE(Z, ',', '.') AS DECIMAL(10,4)) <= %s)",$query_Recordsetst, $longitudMenor, $longitudMayor);
				}
			}
		}
		
		//PARA TEST
		//echo "_SESSION Seteada? = " . isset($_SESSION['idMarca']) . " - Valor idMarca = " . $_SESSION['idMarca'];
		//echo "TipoPieza:". $_SESSION['tipo_pieza'];
		//echo "\n CONSULTA SQL: ". $query_Recordsetst;
		$query_limit_Recordsetst = sprintf("%s LIMIT %d, %d", $query_Recordsetst, $startRow_Recordsetst, $maxRows_Recordsetst);
		$Recordsetst = mysqli_query($catalogo, $query_limit_Recordsetst) or die(mysql_error());
		$row_Recordsetst = $Recordsetst->fetch_assoc();
		
		if (isset($_GET['totalRows_Recordsetst'])) {
		  $totalRows_Recordsetst = $_GET['totalRows_Recordsetst'];
		} else {
		  $all_Recordsetst = mysqli_query($catalogo, $query_Recordsetst);
		  $totalRows_Recordsetst = $all_Recordsetst->num_rows;
		}
		$totalPages_Recordsetst = ceil($totalRows_Recordsetst/$maxRows_Recordsetst)-1;
		
		$queryString_Recordsetst = "";
		if (!empty($_SERVER['QUERY_STRING'])) {
		  $params = explode("&", $_SERVER['QUERY_STRING']);
		  $newParams = array();
		  foreach ($params as $param) {
			if (stristr($param, "pageNum_Recordsetst") == false && 
				stristr($param, "totalRows_Recordsetst") == false) {
			  array_push($newParams, $param);
			}
		  }
		  if (count($newParams) != 0) {
			$queryString_Recordsetst = "&" . htmlentities(implode("&", $newParams));
		  }
		}
		$queryString_Recordsetst = sprintf("&totalRows_Recordsetst=%d%s", $totalRows_Recordsetst, $queryString_Recordsetst);
    } 
?>
<div class="contenido">
<p>&nbsp; </p>
<div style="overflow-x:auto">
<table border="0" cellpadding="5" cellspacing="0" width="100%">
  <?php 
  if ($totalRows_Recordsetst > 0){
	  ?>
	  	  <p>&nbsp; </p>
   <label for="premium" class="lbl_strong">STRONG</label>
   
      <tr style="background-color:#f5c81a; color:#000; font-size:1.2em; border-radius:8px; ">
            <td align="center"><?php echo "<b>" . $diccionario['codigos'] ."</b>"; ?></td>
       <?php 
 		 if ($_SESSION['tipo_pieza'] != "" && $_SESSION['tipo_pieza'] == "Cruceta"){
	  	?>
            <td align="center"><?php echo "<b>" .$diccionario['a1'] ."</b>"; ?></td>
            <td align="center"><?php echo "<b>" .$diccionario['a2'] ."</b>"; ?></td>
            <td align="center"><?php echo "<b>" .$diccionario['b1'] ."</b>"; ?></td>
            <td align="center"><?php echo "<b>" .$diccionario['c1'] ."</b>"; ?></td>
            <td align="center"><?php echo "<b>" .$diccionario['c1prima'] ."</b>"; ?></td>
            <td align="center"><?php echo "<b>" .$diccionario['c2'] ."</b>"; ?></td>
            <td align="center"><?php echo "<b>" .$diccionario['c3'] ."</b>"; ?></td>
            <td align="center"><?php echo "<b>" .$diccionario['c4'] ."</b>"; ?></td>
            <td align="center"><?php echo "<b>" .$diccionario['d1'] ."</b>"; ?></td>
            <td align="center"><?php echo "<b>" .$diccionario['d2'] ."</b>"; ?></td>
            <td align="center"><?php echo "<b>" .$diccionario['largo_sin_cubetas'] ."</b>"; ?></td>
            <td align="center"><?php echo "<b>" .$diccionario['diametro_munion'] ."</b>"; ?></td>
            <td align="center"><?php echo "<b>" .$diccionario['lubricacion'] ."</b>"; ?></td>
            <td align="center"><?php echo "<b>" .$diccionario['descripcion_cubetas'] ."</b>"; ?></td>
        <?php 
		 }
		 else if ($_SESSION['tipo_pieza'] != "" && $_SESSION['tipo_pieza'] == "Triceta"){  
		 ?>
         	<td align="center"><?php echo "<b>" .$diccionario['c1'] ."</b>"; ?></td>
            <td align="center"><?php echo "<b>" .$diccionario['h'] ."</b>"; ?></td>
            <td align="center"><?php echo "<b>" .$diccionario['h1'] ."</b>"; ?></td>
            <td align="center"><?php echo "<b>" .$diccionario['s1'] ."</b>"; ?></td>
            <td align="center"><?php echo "<b>" .$diccionario['di'] ."</b>"; ?></td>
            <td align="center"><?php echo "<b>" .$diccionario['z'] ."</b>"; ?></td>
            <td align="center"><?php echo "<b>" .$diccionario['diametro_munion'] ."</b>"; ?></td>
            <td align="center"><?php echo "<b>" .$diccionario['descripcion_cubetas'] ."</b>"; ?></td>
            <?php 
		 }
		 else if ($_SESSION['tipo_pieza'] != "" && $_SESSION['tipo_pieza'] == "Movimiento"){
			?>
            
            <td align="center"><?php echo "<b>" .$diccionario['d1'] ."</b>"; ?></td>
            <td align="center"><?php echo "<b>" .$diccionario['d2'] ."</b>"; ?></td>
            <td align="center"><?php echo "<b>" .$diccionario['e1'] ."</b>"; ?></td>
            <td align="center"><?php echo "<b>" .$diccionario['e2'] ."</b>"; ?></td>
            <td align="center"><?php echo "<b>" .$diccionario['f1'] ."</b>"; ?></td>
            <td align="center"><?php echo "<b>" .$diccionario['f2'] ."</b>"; ?></td>
            <td align="center"><?php echo "<b>" .$diccionario['observaciones'] ."</b>"; ?></td>
            <?php
		 } 
		 else {   //TODOS
	  	?>
        	 <td align="center"><?php echo "<b>" .$diccionario['a1'] ."</b>"; ?></td>
            <td align="center"><?php echo "<b>" .$diccionario['a2'] ."</b>"; ?></td>
            <td align="center"><?php echo "<b>" .$diccionario['b1'] ."</b>"; ?></td>
            <td align="center"><?php echo "<b>" .$diccionario['c1'] ."</b>"; ?></td>
            <td align="center"><?php echo "<b>" .$diccionario['c1prima'] ."</b>"; ?></td>
            <td align="center"><?php echo "<b>" .$diccionario['c2'] ."</b>"; ?></td>
            <td align="center"><?php echo "<b>" .$diccionario['c3'] ."</b>"; ?></td>
            <td align="center"><?php echo "<b>" .$diccionario['c4'] ."</b>"; ?></td>
            <td align="center"><?php echo "<b>" .$diccionario['d1'] ."</b>"; ?></td>
            <td align="center"><?php echo "<b>" .$diccionario['d2'] ."</b>"; ?></td>
            <td align="center"><?php echo "<b>" .$diccionario['e1'] ."</b>"; ?></td>
            <td align="center"><?php echo "<b>" .$diccionario['e2'] ."</b>"; ?></td>
            <td align="center"><?php echo "<b>" .$diccionario['f1'] ."</b>"; ?></td>
            <td align="center"><?php echo "<b>" .$diccionario['f2'] ."</b>"; ?></td>
            <td align="center"><?php echo "<b>" .$diccionario['h'] ."</b>"; ?></td>
            <td align="center"><?php echo "<b>" .$diccionario['h1'] ."</b>"; ?></td>
            <td align="center"><?php echo "<b>" .$diccionario['s1'] ."</b>"; ?></td>
            <td align="center"><?php echo "<b>" .$diccionario['di'] ."</b>"; ?></td>
            <td align="center"><?php echo "<b>" .$diccionario['z'] ."</b>"; ?></td>
            <td align="center"><?php echo "<b>" .$diccionario['lubricacion'] ."</b>"; ?></td>
          <?php
		 }
	  	?>
	</tr>
    <tr>
   		<td align="center" style="height:2px;"></td>
    </tr>
      <?php
	  do { ?>
        <tr class="fila-tabla">
          <td align="left">
          	<?php include("fragmento_codigos_marcas_resultado.php"); ?>
          </td>
          <?php 
			 if ($_SESSION['tipo_pieza'] != "" && $_SESSION['tipo_pieza'] == "Cruceta"){
			?>
              <td align="center">
                <?php if ($row_Recordsetst['a1'] <> "NULL") echo  str_replace(".",",",$row_Recordsetst['a1']) ; else echo '0' ?>
              </td>
              <td align="center">
                <?php if ($row_Recordsetst['a2'] <> "NULL") echo  str_replace(".",",",$row_Recordsetst['a2']) ; else echo '0' ?>
              </td>
              <td align="center">
                <?php if ($row_Recordsetst['b1'] <> "NULL") echo  str_replace(".",",",$row_Recordsetst['b1']) ; else echo '0' ?>
              </td>
              <td align="center">
                <?php if ($row_Recordsetst['c1'] <> "NULL") echo  str_replace(".",",",$row_Recordsetst['c1']) ; else echo '0' ?>
              </td>
              <td align="center">
                <?php if ($row_Recordsetst['c1prima'] <> "NULL") echo  str_replace(".",",",$row_Recordsetst['c1prima']) ; else echo '0' ?>
              </td>
              <td align="center">
                <?php if ($row_Recordsetst['c2'] <> "NULL") echo  str_replace(".",",",$row_Recordsetst['c2']) ; else echo '0' ?>
              </td>
              <td align="center">
                <?php if ($row_Recordsetst['c3'] <> "NULL") echo  str_replace(".",",",$row_Recordsetst['c3']) ; else echo '0' ?>
              </td>
              <td align="center">
                <?php if ($row_Recordsetst['c4'] <> "NULL") echo  str_replace(".",",",$row_Recordsetst['c4']) ; else echo '0' ?>
              </td>
              <td align="center">
                <?php if ($row_Recordsetst['d1'] <> "NULL") echo  str_replace(".",",",$row_Recordsetst['d1']) ; else echo '0' ?>
              </td>
              <td align="center">
                <?php if ($row_Recordsetst['d2'] <> "NULL") echo  str_replace(".",",",$row_Recordsetst['d2']) ; else echo '0' ?>
              </td>
              <td align="center">
                <?php if ($row_Recordsetst['largosincubeta'] <> "NULL") echo  str_replace(".",",",$row_Recordsetst['largosincubeta']) ; else echo '0' ?>
              </td>
              <td align="center">
                <?php if ($row_Recordsetst['diametromunion'] <> "NULL") echo  str_replace(".",",",$row_Recordsetst['diametromunion']) ; else echo '0' ?>
              </td>
               <td align="center">
                <?php if ($row_Recordsetst['diametromunion'] <> "NULL") echo  str_replace(".",",",$row_Recordsetst['lubricacionubicacion']) ; else echo '0' ?>
              </td>
              <td align="center">
                <?php if ($row_Recordsetst['descripcioncubetas'] <> "NULL") echo  $row_Recordsetst['descripcioncubetas'] ; else echo '0' ?>
              </td>
         <?php 
		 }
		 else if ($_SESSION['tipo_pieza'] != "" && $_SESSION['tipo_pieza'] == "Triceta"){ ?>
              <td align="center">
                <?php if ($row_Recordsetst['c1'] <> "NULL") echo  str_replace(".",",",$row_Recordsetst['c1']) ; else echo '0' ?>
              </td>
              <td align="center">
                <?php if ($row_Recordsetst['h'] <> "NULL") echo  str_replace(".",",",$row_Recordsetst['h']) ; else echo '0' ?>
              </td>
              <td align="center">
                <?php if ($row_Recordsetst['h1'] <> "NULL") echo  str_replace(".",",",$row_Recordsetst['h1']) ; else echo '0' ?>
              </td>
              <td align="center">
                <?php if ($row_Recordsetst['s1'] <> "NULL") echo  str_replace(".",",",$row_Recordsetst['s1']) ; else echo '0' ?>
              </td>
              <td align="center">
                <?php if ($row_Recordsetst['di'] <> "NULL") echo  str_replace(".",",",$row_Recordsetst['di']) ; else echo '0' ?>
              </td>
              <td align="center">
                <?php if ($row_Recordsetst['z'] <> "NULL") echo  str_replace(".",",",$row_Recordsetst['z']) ; else echo '0' ?>
              </td>
              <td align="center">
                <?php if ($row_Recordsetst['diametromunion'] <> "NULL") echo  str_replace(".",",",$row_Recordsetst['diametromunion']) ; else echo "0" ?>
              </td>
              <td align="center">
                <?php if ($row_Recordsetst['descripcioncubetas'] <> "NULL") echo  $row_Recordsetst['descripcioncubetas'] ; else echo '0' ?>
              </td>
		 	<?php 
		 }
		 else if ($_SESSION['tipo_pieza'] != "" && $_SESSION['tipo_pieza'] == "Movimiento"){ ?>
         		
              <td align="center">
                <?php if ($row_Recordsetst['d1'] <> "NULL") echo  str_replace(".",",",$row_Recordsetst['d1']) ; else echo '0' ?>
              </td>
              <td align="center">
                <?php if ($row_Recordsetst['d2'] <> "NULL") echo  str_replace(".",",",$row_Recordsetst['d2']) ; else echo '0' ?>
              </td>
              <td align="center">
                <?php if ($row_Recordsetst['e1'] <> "NULL") echo  str_replace(".",",",$row_Recordsetst['e1']) ; else echo '0' ?>
              </td>
              <td align="center">
                 <?php if ($row_Recordsetst['e2'] <> "NULL") echo  str_replace(".",",",$row_Recordsetst['e2']) ; else echo '0' ?>
              </td>
              <td align="center">
                <?php if ($row_Recordsetst['f1'] <> "NULL") echo  str_replace(".",",",$row_Recordsetst['f1']) ; else echo '0' ?>
              </td>
              <td align="center">
                 <?php if ($row_Recordsetst['f2'] <> "NULL") echo  str_replace(".",",",$row_Recordsetst['f2']) ; else echo '0' ?>
              </td>
              <td align="center">
                <?php if ($row_Recordsetst['observaciones'] <> "NULL") echo  $row_Recordsetst['observaciones']; else echo '-' ?>
              </td>
         <?php 
		 }
		 else { ?>
         <td align="center">
                <?php if ($row_Recordsetst['a1'] <> "NULL") echo  str_replace(".",",",$row_Recordsetst['a1']) ; else echo '0' ?>
              </td>
              <td align="center">
                <?php if ($row_Recordsetst['a2'] <> "NULL") echo  str_replace(".",",",$row_Recordsetst['a2']) ; else echo '0' ?>
              </td>
              <td align="center">
                <?php if ($row_Recordsetst['b1'] <> "NULL") echo  str_replace(".",",",$row_Recordsetst['b1']) ; else echo '0' ?>
              </td>
         	 <td align="center">
                <?php if ($row_Recordsetst['c1'] <> "NULL") echo  str_replace(".",",",$row_Recordsetst['c1']) ; else echo '0' ?>
              </td>
              	 <td align="center">
                <?php if ($row_Recordsetst['c1prima'] <> "NULL") echo  str_replace(".",",",$row_Recordsetst['c1prima']) ; else echo '0' ?>
              </td>
              <td align="center">
                <?php if ($row_Recordsetst['c2'] <> "NULL") echo  str_replace(".",",",$row_Recordsetst['c2']) . "<B>"; else echo '0' ?>
              </td>
              <td align="center">
                <?php if ($row_Recordsetst['c3'] <> "NULL") echo  str_replace(".",",",$row_Recordsetst['c3']) ; else echo '0' ?>
              </td>
              <td align="center">
                <?php if ($row_Recordsetst['c4'] <> "NULL") echo  str_replace(".",",",$row_Recordsetst['c4']) ; else echo '0' ?>
              </td>
              <td align="center">
                <?php if ($row_Recordsetst['d1'] <> "NULL") echo  str_replace(".",",",$row_Recordsetst['d1']) ; else echo '0' ?>
              </td>
              <td align="center">
                <?php if ($row_Recordsetst['d2'] <> "NULL") echo  str_replace(".",",",$row_Recordsetst['d2']) ; else echo '0' ?>
              </td>
              <td align="center">
                <?php if ($row_Recordsetst['e1'] <> "NULL") echo  str_replace(".",",",$row_Recordsetst['e1']) ; else echo '0' ?>
              </td>
              <td align="center">
                 <?php if ($row_Recordsetst['e2'] <> "NULL") echo  str_replace(".",",",$row_Recordsetst['e2']) ; else echo '0' ?>
              </td>
              <td align="center">
                <?php if ($row_Recordsetst['f1'] <> "NULL") echo  str_replace(".",",",$row_Recordsetst['f1']) ; else echo '0' ?>
              </td>
              <td align="center">
                 <?php if ($row_Recordsetst['f2'] <> "NULL") echo  str_replace(".",",",$row_Recordsetst['f2']) ; else echo '0' ?>
              </td>
              <td align="center">
                <?php if ($row_Recordsetst['h'] <> "NULL") echo  str_replace(".",",",$row_Recordsetst['h']) ; else echo '0' ?>
              </td>
              <td align="center">
                <?php if ($row_Recordsetst['h1'] <> "NULL") echo  str_replace(".",",",$row_Recordsetst['h1']) ; else echo '0' ?>
              </td>
              <td align="center">
                <?php if ($row_Recordsetst['s1'] <> "NULL") echo  str_replace(".",",",$row_Recordsetst['s1']) ; else echo '0' ?>
              </td>
              <td align="center">
                <?php if ($row_Recordsetst['di'] <> "NULL") echo  str_replace(".",",",$row_Recordsetst['di']) ; else echo '0' ?>
              </td>
              <td align="center">
                <?php if ($row_Recordsetst['z'] <> "NULL") echo  str_replace(".",",",$row_Recordsetst['z']) ; else echo '0' ?>
              </td>
              <td align="center">
                <?php if ($row_Recordsetst['diametromunion'] <> "NULL") echo  str_replace(".",",",$row_Recordsetst['lubricacionubicacion']) ; else echo '0' ?>
              </td>
         <?php } 
		 ?>
        </tr>
        </tr>
        <td></td>
    <?php } while ($row_Recordsetst = $Recordsetst->fetch_assoc()); 
	}?><tr>
</table>
</div>
<p>
<table border="0" width="100%" style="border-radius:8px;  background-image:url(imagenes/fondo_2.png);">
  <tr>
  	 <?php 
  		if ($totalRows_Recordsetst > 0){?>
            <td align="center" width="5%">
				<?php if ($pageNum_Recordsetst > 0) { // Show if not first page ?>
                <a href="<?php printf("%s?pageNum_Recordsetst=%d%s", $currentPage, 0, $queryString_Recordsetst); ?>"><img src="imagenes/btn_primero.png" /></a>
           		<?php } // Show if not first page ?>
            </td>
            <td align="center" width="5%">
				<?php if ($pageNum_Recordsetst > 0) { // Show if not first page ?>
                <a href="<?php printf("%s?pageNum_Recordsetst=%d%s", $currentPage, max(0, $pageNum_Recordsetst - 1), $queryString_Recordsetst); ?>"><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_Recordsetst < $totalPages_Recordsetst) { // Show if not last page ?>
                <a href="<?php printf("%s?pageNum_Recordsetst=%d%s", $currentPage, min($totalPages_Recordsetst, $pageNum_Recordsetst + 1), $queryString_Recordsetst); ?>"><img src="imagenes/btn_sig.png" /></a>
            <?php } // Show if not last page ?>
            </td>
            <td align="center" width="5%">
				<?php if ($pageNum_Recordsetst < $totalPages_Recordsetst) { // Show if not last page ?>
                <a href="<?php printf("%s?pageNum_Recordsetst=%d%s", $currentPage, $totalPages_Recordsetst, $queryString_Recordsetst); ?>"><img src="imagenes/btn_ultimo.png" /></a>
            <?php } // Show if not last page ?>
            </td>
    <?php 
	}
	else{?>

    <?php 
	}?>
  </tr>
</table>
</p>
</div>
<div class="focus" style="text-align:center;" onclick="cerrarPopup()">
    <div class="container">
    </div>
</div>