	<!DOCTYPE html>
<html>
   <head>
      <title>Oferta</title>
      <meta name = "viewport" content = "width = device-width, initial-scale = 1">
      <link rel = "stylesheet" href = "https://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.css">
      <script src = "https://code.jquery.com/jquery-1.11.3.min.js"></script>
      <script src = "https://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.js"></script>
	  <script src = "js/navegar.js"></script>	  
	  <script src = "hoferta.js"></script>
      <script src ="js/cambio_periodo.js"></script>	  
   </head>

   <body>
      <div data-role = "page" id = "page1">
         <div data-role = "navbar" >
                <ul>
                    <li><a href="javascript:navegar_oferta  ()" class = "ui-btn-active ui-state-persist">Ofertas</a></li>
                    <li><a href="javascript:navegar_compra  ()" class = "ui-btn ui-btn-inline ui-btn-a ">Fruta y Verdura</a></li>
                    <li><a href="javascript:navegar_obrador ()" class = "ui-btn ui-btn-inline ui-btn-a ">Obrador</a></li>
					<li><a href="javascript:navegar_flor ()" class = "ui-btn ui-btn-inline ui-btn-a ">Flor</a></li>
					<li><a href="javascript:navegar_historico ()" class = "ui-btn ui-btn-inline ui-btn-a ">Historico</a></li>					
					<li><a href="logout.php" class = "ui-btn ui-btn-inline ui-btn-a ">Salir</a></li>						
                </ul>		 
         </div>
                 
         <div data-role = "header"  data-position="fixed">	 
            <h2>OFERTA</h2>
         </div>
         
         <div data-role = "main" class = "ui-content">
		 
<?php
session_start();
include($_SERVER['DOCUMENT_ROOT'].'/_configs/conecta.php' );
include($_SERVER['DOCUMENT_ROOT'].'/_configs/conecta2.php' );

                        $idEmpresa = ("1");
                        $idData = 1;
                        $idDataParent = 1;


			echo "<div data-role='none'>";

			// comienza un bucle que leera todos los registros y ejecutara las ordenes que siguen
			
			/**********************************OFERTAS***********************************************/
                echo "<div data-role='collapsible' > ";
					echo "<h3>OFERTAS</h3>";
					echo "<table >" ;
					$idDataParent= $idData ;
					$idData++;
					$contengan=chr(209);
					//DETALLE
					$queryArtFam = ("SELECT merca_oferta.*, des_articu descart, cod_articu codart
												FROM merca_oferta ,fsarticu WHERE empresa = emp_articu AND codigoarticulo = cod_articu AND fecha = today ");
					$resArtFam = odbc_exec($conexion_resdis,$queryArtFam );
					while ($productosArtFam = odbc_fetch_array($resArtFam)) { 
						$queryArtFamM = ("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 articulo.codart ='".$productosArtFam['codart']."' ORDER BY desccatalogo ;");
						$resArtFamM = odbc_exec($conexion_mercafruit,$queryArtFamM );
						while ($productosArtFamM = odbc_fetch_array($resArtFamM)) { 
						
							  echo "<tr>";
							   echo "<td id='descart' width='50%' height='48px' style='font-size: 12px;'>".$productosArtFamM['descart']."</td>";
							    echo "<td id='pvp' width='10%'>".number_format($productosArtFam['pvp'],2)."</td>";
							   echo "<td id='cantidad' width='10%'><input class='cantidadOferta'  type = 'number' value  id='v_".$productosArtFamM['codart']."|".$productosArtFamM['codref']."|".$productosArtFamM['codcatalogo']."'></td>";
							   echo "<td width='30%' style=\"font-size: 10px;\" >".$productosArtFam['observaciones']."</td>";
							   echo "</tr>";
						}
					
  				    odbc_free_result ($resArtFamM);					
					}
					odbc_free_result ($resArtFam);

					
					
					echo "</table>";
				echo "</div>";

				/**********************************OFERTAS***********************************************/
//F DETALLE 
                /**********************************SUGERENCIAS*******************************************/
				echo "<div data-role='collapsible' > ";
					echo "<h3>SUGERENCIAS</h3>";
					echo "<table >" ;
					$idDataParent= $idData ;
					$idData++;
					$contengan=chr(209);
					//DETALLE
					$queryArtFam = ("SELECT merca_sugerencias.*, des_articu descart, cod_articu codart
                                 FROM merca_sugerencias ,fsarticu WHERE empresa = emp_articu AND codigoarticulo = cod_articu AND fin > today ORDER BY DES_ARTICU");
					$resArtFam = odbc_exec($conexion_resdis,$queryArtFam );
					while ($productosArtFam = odbc_fetch_array($resArtFam)) { 

						$queryArtFamM = ("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 articulo.codart ='".$productosArtFam['codart']."' ORDER BY desccatalogo ;");
						$resArtFamM = odbc_exec($conexion_mercafruit,$queryArtFamM );
						while ($productosArtFamM = odbc_fetch_array($resArtFamM)) {									
 							echo "<tr style=\"background-color:#D6DBDF\">";
							   echo "<td id='descart' width='50%' height='48px' style='font-size: 12px;' >".$productosArtFam['descart']."</td>";
							   echo "<td id='pvp' width='10%'>".number_format($productosArtFam['pvp'],2)."</td>";
							   echo "<td id='cantidad' width='10%'><input  class='cantidadOferta'  type = 'number' value  id='v_".$productosArtFamM['codart']."|".$productosArtFamM['codref']."|".$productosArtFamM['codcatalogo']."'></td>";
							   echo "<td width='30%' style=\"font-size: 10px;\" >".$productosArtFam['observaciones']."</td>";
							echo "</tr>";
						}
						if (isset($resArtFamM)) {odbc_free_result ($resArtFamM);}
                    }

					if (isset($resArtFam)) {odbc_free_result ($resArtFam);}
					echo "</table>";
				echo "</div>";
				/**********************************SUGERENCIAS*******************************************/

			/*******************FIN ************/
                /**********************************TEMPORADA*******************************************/
				echo "<div data-role='collapsible' > ";
					echo "<h3>TEMPORADA</h3>";
					echo "<table >" ;
					echo "<tr style=\"background-color:white\">";
								echo "<td width='100%' id='descart' style=\"font-size: 16px;\"></td>";
								echo "<td width='100%' id='descart' style=\"font-size: 16px;\"></td>";
								echo "<td width='100%' id='descart' style=\"font-size: 16px;\"></td>";
							echo "</tr>";
					$idDataParent= $idData ;
					$idData++;
					$contengan=chr(209);
					//DETALLE
					$queryArtFam = ("SELECT merca_temporada.*, des_articu descart,  cod_articu codart,ter_articu ampliada,ori_articu origen
                                 FROM merca_temporada ,fsarticu WHERE empresa = emp_articu AND codigoarticulo = cod_articu AND fin > today ORDER BY DES_ARTICU");
					$resArtFam = odbc_exec($conexion_resdis,$queryArtFam );
					while ($productosArtFam = odbc_fetch_array($resArtFam)) { 

						$queryArtFamM = ("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 articulo.codart ='".$productosArtFam['codart']."' ORDER BY desccatalogo ;");
						$resArtFamM = odbc_exec($conexion_mercafruit,$queryArtFamM );
						while ($productosArtFamM = odbc_fetch_array($resArtFamM)) {									
 							echo "<tr style=\"background-color:#D6DBDF\">";
								echo "<td width='100%' height='48px' id='descart' style=\"font-size: 16px;\">".$productosArtFam['descart']."</td>";
								
							echo "</tr>";
						}
                    }
					if (isset($resArtFamM)) {odbc_free_result ($resArtFamM);}
					odbc_free_result ($resArtFam);
					echo "</table>";
				echo "</div>";
				/**********************************SUGERENCIAS*******************************************/

			/*******************FIN ************/
            
							
			//cerramos la etiqueta tabla
echo "</div>";




?>
		 
         </div>
         
         <div data-role = "footer" data-position="fixed">
						<a href="info_venta.php" DATA-ICON="user"  class = "ui-icon-user" data-rel="dialog" data-transition="pop" style='background-color:#e7416d;color:WHITE'>i</a>		 
						<a href='javascript:limpiaOferta()' class = "ui-btn"  style='width:130px;margin-left:10px;background-color:#E7BB41;color: WHITE;text-shadow: 0 1px 0 #C39619;' >Borrar</a>
						<a href='javascript:confirmaOferta()' class = "ui-btn"  style='width:130px;background-color:teal;color: white;text-shadow: 0 1px 0 #13520C;' >Comprar</a>           			
         </div>
			<section id="info" data-role="dialog" >
				<header data-role="header">
					<h1>Informacion</h1>
				</header>
				<article data-role="content">
					<p>Usuario o contraseña no valida</p>
					<a href="#" data-role="button" data-rel="back">Aceptar</a>
				</article>
			</section>		 
      </div>

   </body>
</html>