<?php
date_default_timezone_set('America/Costa_Rica');

session_start();

 $usu=$_SESSION['username'];
 

		include('../conexion.php'); 
		if($_SESSION['tipo_usu']=='a' or $_SESSION['tipo_usu']=='s'  or $_SESSION['tipo_usu']=='c'  or $_SESSION['tipo_usu']=='v'){
		}else{
		header('location:acceso_denegado.php');
		}



 $codmov=$_GET["codigo"];



$consulta = "SELECT * FROM movimientos_caja WHERE codmov='$codmov' ";
$resultado = $mysqli->query($consulta);
$row = $resultado->fetch_array();

$codigo = $row["codigo"];
$nombre = $row["nombre"];
$fecfac = $row["fecha"];
$fecfac = implode("-", array_reverse(explode("-", $fecfac)));  
$numdoc = $row["numdoc"];
$total  = $row["total"];
$detmov = $row["detmov"];
$tipmov = $row["tipmov"];
$cdgcaj = $row["cdgcaj"];
$numche = $row["numche"];
$ctaban = $row["ctaban"];
$salact = $row["salact"];
$totnet = $row["total"];

  if ($tipmov=="VAL") {

$consulta = "SELECT * FROM web_2101 WHERE numfac='$numdoc' AND  cdgcli='$codigo' ";
$resultado = $mysqli->query($consulta);
$row = $resultado->fetch_array();
$salact = $row["SALACT"];
$totnet = $row["TOTNET"];

} 




$consulta = "SELECT * FROM usuarios WHERE codusu='$cdgcaj'";
$resultado = $mysqli->query($consulta);
$row = $resultado->fetch_array();
 $nomb = $row["usu"];
?>


<html>
	<head>
		<title>Principal</title>
		<link href="../estilos/estilos.css" type="text/css" rel="stylesheet">
		
		
		<script src="../jquery/jquery-1.3.2.js" type="text/javascript"></script>
		<script src="../jquery/jquery.maskedinput-1.2.2.js" type="text/javascript"></script>
		
		<script language="javascript">
		
	
		var cursor;
		if (document.all) {
		// Está utilizando EXPLORER
		cursor='hand';
		} else {
		// Está utilizando MOZILLA/NETSCAPE
		cursor='pointer';
		}
		
function anular_doc(codmov,codigo,tipmov){
	val="VAL";
	rec="REC";
	if (tipmov==val  || tipmov==rec ) {
			if (confirm(" Desea anular este Documento ? ")){
				var mensaje="";
				if (parseFloat(document.getElementById("salfac").value) < parseFloat ( document.getElementById("totfac").value )){ 
	  			
	alert("Atencion, Este Documento ya posee movimientos no puede ser ANULADO su saldo actual es :\n\n"+document.getElementById("salfac").value);
			
			
				} else {
				
			
				location.href="anular_doc.php?codmov=" + codmov + " &codigo=" + codigo;
			}  
			
			  
			}
				} else {
			
				if (confirm(" Desea anular este Documento ? "))	{
				
			location.href="anular_doc.php?codmov=" + codmov + " &codigo=" + codigo;	
			}
		}
		
		}
		
		
			
	
			function cancelar() {
			location.href="index.php";
		}
		


					function nobackbutton(){	
   window.location.hash="no-back-button";	
   window.location.hash="Again-No-back-button" //chrome	
   window.onhashchange=function(){window.location.hash="no-back-button";}	
}
	
		</script>
	</head>
   
			<body onLoad=" nobackbutton(); ">
		<div id="">
			<div id="zonaContenido">
				<div align="center">
				<div id="tituloForm" class="header">Eliminar Documento</div>
			
				<p>&nbsp;</p>
					<form id="formulario" name="formulario" method="post" action="guardar_cxp.php" >
				<div id="formulario" class="contenidoCliente">
				<table class="fuente8" width="100%" cellspacing=2 cellpadding=0 border=0>
                    <tr>
                      <td width="6%">&nbsp;</td>
                      <td width="15%">&nbsp;</td>
                      <td width="14%">&nbsp;</td>
                      <td colspan="5"><div align="right"></div></td>
                      <td><div align="center"></div></td>
                    </tr>
                    <tr>
                      <td>&nbsp;</td>
                      <td>&nbsp;</td>
                      <td>&nbsp;</td>
                      <td width="5%">&nbsp;</td>
                      <td width="8%">&nbsp;</td>
                      <td width="14%">&nbsp;</td>
                      <td>&nbsp;</td>
                      <td>&nbsp;</td>
                      <td>&nbsp;</td>
                    </tr>
                    <tr>
                      <td>&nbsp;</td>
         <td width="15%"> Numero </td>
         <td><input NAME="numfac" type="text" class="cajaGrande" id="numfac" style='text-align:center;'  value="<?php echo $numdoc ?>" readonly></td>
<td>&nbsp;</td>
<td><div align="center">Fecha</div></td>
<td><input name="fecfac" type="text" class="cajaGrande" id="fecfac"  style='text-align:center;' value="<?php echo $fecfac?>"  readonly="" ></td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td width="13%">&nbsp;</td>
                    </tr>
                    <tr>
                      <td>&nbsp;</td>
                      <td>Nombre</td>
                      <td><input name="cdgcli" type="text" class="cajaGrande" id="cdgcli"   click="limpiarcaja()" style='text-align:center;'  value="<?php echo $codigo?>"  readonly="" ></td>
                      <td colspan="5"><input name="dsccli" type="text" class="cajaGrande" id="dsccli"   click="limpiarcaja()" style='text-align:center;'  value="<?php echo $nombre?>"  readonly="" ></td>
                      <td>&nbsp;</td>
                    <tr>
							    
					
                      <td>&nbsp;</td>
                      <td>Cajero</td>
                      <td><input name="cajero" type="text" class="cajaGrande" id="cajero"   click="limpiarcaja()" style='text-align:center;' value="<?php echo $nomb ?>" readonly="" ></td>
                      <td>&nbsp;</td>
                      <td>&nbsp;</td>
                      <td>&nbsp;</td>
                      <td>&nbsp;</td>
                      <td>&nbsp;</td>
                      <td>&nbsp;</td>
                    <tr>
                      <td>&nbsp;</td>
                      <td>&nbsp;</td>
                      <td>&nbsp;</td>
                      <td>&nbsp;</td>
                      <td>&nbsp;</td>
                      <td>&nbsp;</td>
                      <td>&nbsp;</td>
                      <td>&nbsp;</td>
                      <td>&nbsp;</td>
                    <tr>
                      <td>&nbsp;</td>
                      <td>Monto</td>
<td><input name="total" type="text" class="cajaGrande" id="total"  style='text-align:right;' value="<?php echo number_format( $total,2,".",",")?>"  readonly="" ></td>
                      <td>&nbsp;</td>
		
<td><div align="left">Tipo</div>
<td colspan="2"><input name="tipmov" type="text" class="cajaGrande" id="tipmov" style='text-align:center;' value="<?php echo $tipmov?>"  readonly="" ></td>
                      <td>&nbsp;</td>
                      <td>&nbsp;</td>
                    <tr>
                      <td>&nbsp;</td>
                      <td>&nbsp;</td>
                      <td colspan="5">&nbsp;</td>
                      <td>&nbsp;</td>
                      <td>&nbsp;</td>
                    <tr>
                      <td>&nbsp;</td>
                      <td><div align="left">Detalle</div></td>
                      <td colspan="5"><input name="detmov" type="text" class="cajaGrande" id="detmov"   click="limpiarcaja()" style='text-align:center;'  value="<?php echo $detmov?>"  readonly="" ></td>
                      <td>&nbsp;</td>
                      <td>&nbsp;</td>
                    <tr>
                      <td height="22">&nbsp;</td>
                      <td>&nbsp;</td>
                      <td>&nbsp;</td>
                      <td>&nbsp;</td>
                      <td>&nbsp;</td>
                      <td>&nbsp;</td>
                      <td>&nbsp;</td>
                      <td>&nbsp;</td>
                      <td>&nbsp;</td>
                    <tr>
                      <td height="22">&nbsp;</td>
                      <td>Cheque</td>
                      <td colspan="4"><input name="numche" type="text" class="cajaGrande" id="numche"   click="limpiarcaja()" style='text-align:center;'  value="<?php echo $numche?>"  readonly="" ></td>
                      <td>&nbsp;</td>
                      <td>&nbsp;</td>
                      <td>&nbsp;</td>
                    <tr>
                      <td width="6%" height="22">&nbsp;</td>
                      <td width="15%">Banco</td>
                      <td colspan="4"><input name="ctaban" type="text" class="cajaGrande" id="ctaban"   click="limpiarcaja()" style='text-align:center;'  value="<?php echo $ctaban?>"  readonly="" ></td>
                      <td width="9%">&nbsp;</td>
                      <td width="16%">&nbsp;</td>
                      <td width="13%">&nbsp;</td>
					 <input  name="salfac" type="hidden"  id="salfac"  value="<?php echo $salact?>" />
					<input  name="totfac" type="hidden"  id="totfac"  value="<?php echo $totnet?>" />
                  </table>
				</div>
			     <td colspan="5"><div align="center"><img src="../img/Symbol-Check_48x48-32.png" width="48" height="48" onClick="anular_doc(<?php echo $codmov ?>,<?php echo $codigo ?>,'<?php echo $tipmov ?>')" border="0" onMouseOver="style.cursor=cursor" title="Anular">
			       <img src="../img/Symbol-Delete_48x48-32.png" width="48" height="48" onClick="cancelar()" border="0" onMouseOver="style.cursor=cursor" title="Cancelar"> </div></td>
				</form>
			  </div>
		  </div>
		</div>
	</body>
</html>
