<style type="text/css">
<!--
.Estilo2 {
	color: #000000;
	font-weight: bold;
	font-size: 18px;
}
-->

</style>

<?php
	$servername = "localhost";
    $username = "u628200248_terrapro";
  	$password = "Terrapro2025";
  	$dbname = "u628200248_terrapro";

	$conn = new mysqli($servername, $username, $password, $dbname);
      if($conn->connect_error){
        die("Conexión fallida: ".$conn->connect_error);
      }
	
    $salida = "";
//$idm = mysqli_query("SELECT * FROM cotizacion ");
	
//$table = "SELECT products.p_id, products.p_code, products.p_name, product_to_store.sell_price FROM `quotation_info` 
  //INNER JOIN `product_to_store` ON products.p_id = product_to_store.product_id
  //WHERE p_code LIKE '%$q%' OR p_name LIKE '%$q%'";




    $query = "SELECT products.*, product_to_store.purchase_price , product_to_store.sell_price , product_to_store.fecha FROM `products` 
  LEFT JOIN `product_to_store` ON products.p_id = product_to_store.product_id
  WHERE products.p_id NOT LIKE '' ORDER By products.p_id LIMIT 25";

    if (isset($_POST['consulta'])) {
    	$q = $conn->real_escape_string($_POST['consulta']);
    	$query = "SELECT products.*, product_to_store.purchase_price , product_to_store.sell_price, product_to_store.fecha FROM `products` 
  LEFT JOIN `product_to_store` ON products.p_id = product_to_store.product_id
  WHERE products.p_name LIKE '%$q%' OR p_code LIKE '%$q%'";
    }

    $resultado = $conn->query($query);

    if ($resultado->num_rows>0) {
    	?>
<table border=1 class=tabla_datos>
    				<tr id=titulo>
					<td align="right">Ultima Actuali.</td>
						<td align="right">codigo</td>
    					<td>nombre</td>
						<td><strong><span class=Estilo1>precio compra</span></strong></td>
						<td>precio de venta</td>
						<td>precio nuevo</td>
    			 <tr>
		<?php	
		while ($fila = $resultado->fetch_array()) {
		$importe = $fila['purchase_price'];
	//round($importe, 2);
	echo "<tr>";
	echo "<td >";
	echo $fila['fecha'];
	echo "</td>";
	echo "<td >";
	echo $fila['p_code'];
	echo "</td>";
	echo "<td align=left>";
	echo $fila['p_name'];
	echo "</td>";
	echo "<td> <strong><span class=Estilo3>";
	echo $fila['purchase_price'];
	echo "</span></strong></td>";
	echo "<td> <strong><span class=Estilo3>";
	echo $fila['sell_price'];
	echo "</span></strong></td>";
	echo "<td><form action='index.php' method=post><input type=text size=6 name=precio value=".$fila['purchase_price']."><input type=hidden size= 5 name=id_prod value=".$fila['p_id']."><input type=submit value='Guardar'></form></td>
	</tr>";
	}} else{
    	$salida="NO HAY ARTICULOS CON ESE CODIGO";
    }   
    echo "</table>";
	
	echo $salida;
    $conn->close();
	
//echo:"cotizacion"$cotizacion

?>

<title>EDICION DE PRECIOS</title>