<?php
    session_start();
    ini_set('display_errors','On');
    require_once($_SERVER['DOCUMENT_ROOT'].'/shine/model/clsProducto.php');
    
    $header = '
        <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
        <html xmlns="http://www.w3.org/1999/xhtml">
        <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <style type="text/css">
            table{
                width:100%;
                border: 1px solid #CCC;
                cellspacing:0;
                cellpadding:0;
                rules:all;
            }
            body { 
                font: 100%/1.4 "Arimo", sans-serif;
                font-family: "Arimo", sans-serif;	 
            }
            .header_consulta{
                font-weight:bold;
                text-align:center;
                vertical-align:middle;
                background-color:#CCC;
                width:100%;
            }
            .filapar_consulta{
                font-weight:normal;
                text-align:left;
                vertical-align:middle;
                background-color:#FFF;
            }
            .filaimpar_consulta{
                font-weight:normal;
                text-align:left;
                vertical-align:middle;
                background-color:#CCC;
            }
        </style>
        <title>Consulta</title>
        </head>
        <body>
        <center>
        <table >
        <tr class="header_consulta" >
        ';
    
    
        echo '<form id="frm" method=post>Buscar: <input type=text id="consulta" name="consulta" value="'.$_POST['consulta'].'"> <input type=submit value="Consultar"></form>';
      /*  if(strlen(trim($_POST['consulta'])) > 0){
            $esquema = 'seguridad';
            $funcion = 'c_rolxusuario';
            $parametros = array(
                'p_nom_usuario' => $_GET['nom_usuario']
               ,'p_buscar' => $_POST['consulta']
            );
        }


*/


    /*****************************************************************/
	if(isset($_POST['consulta'])){
		$etiq_tr='';
        $objConsulta = new clsProducto();
        $r = $objConsulta->MET_consulta($_POST['consulta'], $_SESSION['tip_categoria']);
		//print_r($r);exit;
        if(!$r){
            echo 'No existen datos';
            exit();
        }
        echo $header;       
        echo '<td>CODIGO</td>';
		echo '<td>REFERENCIA</td>';
		echo '<td>DESCRIPCION</td>';
		echo '<td>PRECIO</td>';
		echo '<td>STOCK</td>';
		echo '<td>P. COMERCIAL</td>';
		echo '<td>P. CATALOGO</td>';
        echo '</tr>';
        foreach($r as $key=>$value) {
            if(($key%2)==0){
                $etiq_tr= '<tr class="filapar_consulta"';
            }else{
                $etiq_tr = '<tr class="filaimpar_consulta"';
            }
			//consultaProducto(codigo, nombre, precio, stock)
            //echo $etiq_tr.' onclick = "window.opener.consultaModal('.$value['id'].'); window.close();" style="cursor:hand">';
            echo $etiq_tr.' onclick = "window.opener.consultaProducto('."'".$value['COD_ITEM']."',"."'".$value['NOM_ITEM']."',"."'".$value['VAL_VENTA']."',"."'".$value['NUM_STOCK']."'".'); window.close();" style="cursor:hand">';
            foreach($value as $key1=>$value1) {
                echo '<td>'.$value1.'</td>';
            }
            echo '</tr>';
        } 
        echo '</table></body></html>';
	}
    exit;
?>
