<?
require_once('../../conf/connection.php');
 
$numero =$_GET["numero"];
$descuento =$_GET["descuento"];
$fecha_ft=date('Y-m-d');
$hoy=date("Y-m-d");
$hrs=date("H:i:s");
//suma total de ventas boletas = "1" y faturas="2" 

  $query_sum="SELECT sum(valor_total) AS total_venta FROM detalles_pedido  WHERE numero='$numero'";
  $res_sum=mysql_query($query_sum); 
  $total=mysql_result($res_sum,0,"total_venta");
  $total_final=$total-$descuento;
  
  $query="SELECT * FROM tp_doc  WHERE numero='$numero'";
  $res=mysql_query($query); 
  $fecha=mysql_result($res,0,"fecha");
  $doc=mysql_result($res,0,"pedido");
  
  $query_sum="SELECT sum(valor_total) AS total_venta FROM detalles_pedido  WHERE numero='$doc'";
  $res_sum=mysql_query($query_sum); 
  $total=mysql_result($res_sum,0,"total_venta");
  $total_final=$total-$descuento;

?>
<!DOCTYPE html>
<html dir="ltr" lang="en-US"><head>
    <meta charset="utf-8">
    <title>mod_venta</title>
    <meta name="viewport" content="initial-scale = 1.0, maximum-scale = 1.0, user-scalable = no, width = device-width">
    <script type='text/javascript' src='../jquery-1.7.1.min.js'></script>
    <!--[if lt IE 9]><script src="https://html5shiv.googlecode.com/svn/trunk/html5.js"></script><![endif]-->
    <link rel="stylesheet" href="../../style.css" media="screen">
    <!--[if lte IE 7]><link rel="stylesheet" href="style.ie7.css" media="screen" /><![endif]-->
    <link rel="stylesheet" href="../../style.responsive.css" media="all">

    <script src="../../jquery.js"></script>
    <script src="../../script.js"></script>
    <script src="../../script.responsive.js"></script>



<style>.art-content .art-postcontent-0 .layout-item-0 { border-top-width:1px;border-top-style:solid;border-top-color:#B1C9C7;margin-top: 10px;margin-bottom: 10px;  }
.art-content .art-postcontent-0 .layout-item-1 { border-right-style:solid;border-right-width:1px;border-right-color:#B1C9C7; padding-right: 10px;padding-left: 10px;  }
.ie7 .art-post .art-layout-cell {border:none !important; padding:0 !important; }
.ie6 .art-post .art-layout-cell {border:none !important; padding:0 !important; }

</style>
<script>

function cerrar() {
			window.close();
		}
		
</script>  
<script language="javascript">

function imprimir() {
	window.open("rejilla_imprime.php?fecha=<? echo $fecha ?>");
	window.history.back()
	
}
function cerrar() {
	window.close();	
}

function ver(){
			miPopup = window.open("ver.php","residente","width=700,height=380,scrollbars=yes");
			miPopup.focus();
		}
function volver(){
			
			window.history.back();
		}

</script>
       

</head>
<body>
<div id="art-main">

<div class="art-sheet clearfix">
            <div class="art-layout-wrapper">
                <div class="art-content-layout">
                    <div class="art-content-layout-row">
                        <div class="art-layout-cell art-content"><article class="art-post art-article">
                                
                                                
                                <div class="art-postcontent art-postcontent-0 clearfix"><div class="art-content-layout">
    <div class="art-content-layout-row">
    <div class="art-layout-cell layout-item-1" style="width: 100%" >
       
        <p>
      
<h3>Registro de anulación de documentos</h3>

<form action="reg.php" id="anular" name="anular" method="post">
 <input type="hidden" value="<? echo $numero ?>" name="numero" id="numero">
 
      <table width="350" border=0 cellpadding=3 cellspacing=0 class="fuente8">
					  
					  <tr>
					    <td >Fecha: <? echo $fecha ?></td>
      </tr>
					  
					 
					  <tr>
					    <td >Numero de venta: <? echo $numero ?> </td>
      </tr>
					  <tr>
					    <td ><fieldset>
				          <legend>Tipo de anulación </legend>
                            
                            <input name="tipo" id="tipo" type="radio" value="1"> Por cambio de producto.<br> 
							<input name="tipo" id="tipo" type="radio" value="2"> Por Devolución de producto. 

                          
					    </fieldset></td>
	    </tr>
					  <tr>
					    <td >
                        <fieldset>
				          <legend>Datos de anulación</legend>
                            
                            <table width="287" border="0">
  <tr>
    <td>Fecha de anulación</td>
    <td><input type="text" id="fecha_an" name="fecha_an" value="<? echo $hoy ?>" ></td>
  </tr>
  <tr>
    <td>Hora de anulación</td>
    <td><input type="text" id="hrs_an" name="hrs_an" value="<? echo $hrs ?>" ></td>
  </tr>
                            </table>

                            
                            
                          
					    </fieldset>
                        
                        </td>
	    </tr>
					  
					  
                      </table>
                      
                     <table width="975">
					  
					        <tr>
					          <td>Detalles:
                                 <?  
          $buscar='select *from detalles_pedido inner join articulos ON 
          articulos.referencia=detalles_pedido.codarticulo where numero like \'%'.$doc.'%\'';
		   $r=mysql_query($buscar,$conn) or die("Error en el query: ".mysql_error());
		   $n=mysql_num_rows($r);
		  
		    //si hay registros los procesamos
			if($n>0)
			{
			?>
			                    <table  width="350" border="0">
				<tr >
				<td width="166">Productos</td>
				<td width="97">Cantidad</td>
				<td width="81">Total</td>
              </tr>
				<tr >
				  <td colspan="3"><hr></td>
				  </tr>
				<?
				while($row=mysql_fetch_assoc($r))
				{ //Procesamos cada registro como una fila de tabla
					?>
					<tr><?
					//$row["nomCampo"] estos nomCampo son los campos devueltos por el
					//query en la variable $r que procesa mysql_fetch_assoc
					?>
					 <td height="10"><? $codarticulo=$row["referencia"]; echo  $row["descripcion"] ?></td>
					 <td align="right"><? echo $row["cantidad"] ?></td>
					 <td align="right"><? echo 
					 $format_number = number_format($row["valor_total"], 0, ',', '.');
					 
					 $idplatos=$row["idplatos"];  ?></td>
				    </tr>
					
				<? }
				
				?>
                <tr>
					  <td height="10" colspan="3"><hr></td>
				  </tr>
				</table>
			    
			      <? } ?>
                  <table width="350">
			        <tr>
					  <td width="113" height="4">&nbsp;</td>
					  <td width="107" height="4" align="right">Subtotal: </td>
					  <td width="121" height="4" align="right"><? echo $total ?></td>
				    </tr>
				  </table>
       
       <input type="submit" value="Guardar" class="art-button" >
       </form>
       
       <input type="button" value="Volver atrás" class="art-button" onClick="volver()">
        </p>
</div>
    </div>
</div>
<div class="art-content-layout-br layout-item-0">
</div></div>


</article></div>
                    </div>
                </div>
            </div>

    </div>
    
</div>


</body></html>
