<!DOCTYPE html>
<html>
   <head>
      <title>Comprar</title>      
	  <meta name = "viewport" content = "width = device-width, initial-scale = 1">
	  <link rel = "stylesheet" href = "css/flex.css">	 	  	  


   </head>


<?php

include($_SERVER['DOCUMENT_ROOT'].'/_configs/conecta.php' );
include($_SERVER['DOCUMENT_ROOT'].'/_configs/conecta2.php' );

             
                        $idEmpresa = ("1");
//                        $numpedido = $_GET["numPedido"];
                        $idData = 1;
                        $idDataParent = 1;

			$queryFamilia = ("SELECT DISTINCT familia.codfamilia,desfamilia FROM DBA.familia,DBA.articulo where familia.codfamilia=articulo.codfamilia and familia.codfamilia <> 'AL' and familia.codfamilia <> 'XX'  and prod_in_fam > 0 ORDER BY desfamilia;");
			$resultado = odbc_exec($conexion_mercafruit,$queryFamilia );



			echo "<div id='productgridcontainer' class='product-grid-container container-center'>
			";

			// comienza un bucle que leera todos los registros y ejecutara las ordenes que siguen
			while ($productosFamilia = odbc_fetch_array($resultado)) { 
//  			    $queryFamStock = ("SELECT  _por_ven_com  (\"1\",\"".$productosFamilia['codfamilia']."\") as cantidad from fsfamili where cod_famili = \"".$productosFamilia['codfamilia']."\";");
//				$resFamStock = odbc_exec($conexion_resdis,$queryFamStock );
//				$stockFam = odbc_fetch_array($resFamStock);
			
				$productosFamilia['codfamilia'] = str_replace ('\xef\xbf\xbd','&Ntilde;', $productosFamilia['codfamilia']);
                echo "<div class='product-list--row'> ";
//					echo "<h3>".number_format($stockFam['cantidad'],2).'% - ' .$productosFamilia['desfamilia']."</h3>";
//					echo "<h3>".$productosFamilia['desfamilia']."</h3>";
//					echo "<table >" ;
					$idDataParent= $idData ;
					$idData++;
					$contengan=chr(209);
					//DETALLE
					$queryArtFam = ("SELECT DISTINCT catalogo.codart codart,catalogo.desccatalogo descart,catalogo.codref codref, catalogo.codcatalogo FROM DBA.articulo,DBA.catalogo where 
							CATALOGO.CODART  NOT LIKE '%".$contengan."%'  AND 
							catalogo.activo='S' AND articulo.codart = catalogo.codart AND codsubfam <> 'DE' AND  codfamilia='".$productosFamilia['codfamilia']."'  ORDER BY desccatalogo ;");
					$resArtFam = odbc_exec($conexion_mercafruit,$queryArtFam );
					while ($productosArtFam = odbc_fetch_array($resArtFam)) { 
//$productosArtFam['descart'] =str_replace ('\xef\xbf\xbd'.'&Ntilde;',$productosArtFam['descart']);
					$queryArtFamStock = ("SELECT  _stock_art  (\"1\",\"".$productosArtFam['codart']."\") as cantidad from fsarticu where emp_articu = \"1\" and cod_articu = \"".$productosArtFam['codart']."\";");
					$resArtFamStock = odbc_exec($conexion_resdis,$queryArtFamStock );
					$stockArt = odbc_fetch_array($resArtFamStock);


                echo "<div class='product-list__item'> ";
					echo "<div class='prod_grid' data-productcode='".$productosArtFam['codart']."'> ";				
//						echo "<tr>";
						echo "<ul class='product-grid-icons'></ul>";
							echo "<a href='' title='' class='productMainLink'>";
							echo "<div class='column-left'>";
							echo "<div class='thumb'>";
								echo "<img class='crispImage' intemprop='image' src='img\\".trim($productosArtFam['codart']).".jpg' alt='".$productosArtFam['descart']."' onerror='missingImage(this);' width='100' height='100'>";
							echo "</div>";
							echo "<div class='column-right'>";
								echo "<span class='details'>".$productosArtFam['descart']."</span>";
								echo "<div class='price-container'>";								
									echo "<p class='price'></p>";
									echo "<p class='pricePerKilogram'></p>";
								echo "</div>";
								echo "<ul class ='product-grid-labels'></ul>";
								echo "<div class ='cart'>";
									echo "<form id='updateCartFormByProduct_".trim($productosArtFam['codart'])."' name='UpdateQuantityForm' data-productdescription='DescripciondeProduccion' class='UpdateQuantityForm' action='' method='post' data-productcode='".$productosArtFam['codart']."' >";
										echo "<input type='hidden' class='productCode' name='productCodePost' value='".trim($productosArtFam['codart'])."'";
										echo "<input type='hidden' class='initialQuantity' name='initialQuantity' value='1'";
										echo "<input type='hidden' class='quantity' name='quantity' value='1'";										
										echo "<input type='hidden' class='soldByType' name='soldByType' value='QUANTITY'";																				
										echo "<input type='hidden' class='price' name='priceBr' value='2,05'";																														
									echo "</form>";									
									echo "<div class='product-initialAddToCart productGrid-product-initialialAddToCart' data-productcode='".trim($productosArtFam['codart'])."'>";
										echo "<button>Añadir</button>";
									echo "</div>";									
								echo "</div>";
//						    echo "<td id='stock' style='font-size: 12px;'>".$stockArt['cantidad']."</td>";						
//							echo "<td><center><img src=\"img\\".$productosArtFam['codart'].".jpg\" width=\"100\" height=\"100\"></td>";
//							echo "<td id='descart' width='55%'  height='48px' style='font-size: 13px;'>".$productosArtFam['descart']."</td>";
//							echo "<td id='cantidad' width='15%'><input   class='cantidad' type = 'number' min='0' max='99' value  id='v_".$productosArtFam['codart']."|".$productosArtFam['codref']."|".$productosArtFam['codcatalogo']."'></td>";
//							echo "<td width='30%' ><select id='o_".$productosArtFam['codart']."|".$productosArtFam['codref']."|".$productosArtFam['codcatalogo']."' class='selector'>
//									<option value = '' selected='selected'></option>
//									<option value = 'MEDIA' >MEDIA</option>
//									<option value = 'VERDE'>VERDE</option>
//									<option value = 'MADURO'>MADURO</option>
//									<option value = 'PEDIDO'>PEDIDO</option>
//									<option value = 'CAJAGRANDE'>CAJA G</option>
//									<option value = 'CAJAPEQUENA'>CAJA P</option>
//								</select> </td>";
							echo "</div>";
							echo "</div>";
							echo "</a>";
//						echo "</tr>";
					echo "</div>";
				echo "</div>";
                    }
					odbc_free_result ($resArtFam);
//					echo "</table>";
				echo "</div>";
//F DETALLE 
			} // fin del bucle de ordenes
            odbc_free_result($resultado); 
							
			//cerramos la etiqueta tabla
echo "</div>";


?>

   </body>
</html>