<?php
 
session_start();
include("DMMYSQLG.php");
include("DSA1000.php");
include("DMMYSQLG.php");
include("DF30000.inc");
$tipVen=$_SESSION['tipven'];
?>
<?php

if($_SESSION['tipven']=="" || $_SESSION['vendedor']==""){
	echo '<h2>VUELVA A IDENTIFICARSE!!</h2>';
	exit();
}
?>
<html>
<link rel="stylesheet" href="css/estilo1.css" type="text/css"/>
<script type="text/javascript" language="JavaScript1.2" src="DSSCRIPT.js"></script>
<body>
<form id="frm1" name="frm1" method="post" action="" >
  <table  align="center">
    <tr>
      <th colspan="2" scope="col">CONSULTA CANCELA PAGOS </th>
    </tr>
    <tr>
      <td colspan="2"><div align="center">
        <input name="r1" type="radio" tabindex="2" value="consulta" checked>
        Consultar Pagos &nbsp;&nbsp;&nbsp;&nbsp;
        <input name="r1" type="radio" value="cancelar" tabindex="3">
      Cancela Pagos</div></td>
    </tr>
    <tr>
      <td><div align="center">
       
            Fecha inicial:
                <input name="t1" type="text" class="emplea" id="t1" size="15" readonly
			  <?php
 
				  $axc = date('d/m/Y');
				  if(isset($_POST['t1'])){
					echo 'value="'.$_POST['t1'].'"'; 
				  }else{
					echo 'value="'.$axc.'"'; 
				  }
			  ?>
			  >
            <input name="reset2" id="bot1" value=" ... " type="image" src="logos/cal4.jpg"/>
            <script type="text/javascript">
				  	Calendar.setup(
    					{
      						inputField  : "t1",        // ID of the input field
      						ifFormat    : "%d/%m/%Y",    // the date format
      						button      : "bot1"      // ID of the button
    					}
  					);
				</script>

      </div></td>
      <td><div align="center">
Fecha final:
            <input name="t2" type="text" class="emplea" id="t2" size="15" readonly 
			  <?php
 
			  if(isset($_POST['t2'])){
			  	echo 'value="'.$_POST['t2'].'"'; 
			  }else{
			  	echo 'value="'.$axc.'"'; 
			  }
			  ?>
			  >
            <input name="reset2" id="bot2" value=" ... " type="image" src="logos/cal4.jpg"/>
            <script type="text/javascript">
				  	Calendar.setup(
    					{
      						inputField  : "t2",        // ID of the input field
      						ifFormat    : "%d/%m/%Y",    // the date format
      						button      : "bot2"      // ID of the button
    					}
  					);
				</script>

      </div></td>
    </tr>
    <tr>
      <td colspan="2"><div align="center">
        <input type="submit" name="Submit22" value="Procesar" onClick="openpage('DG35000_PR.php','_self')"/>
        <label>
        <input type="button" name="Submit6" value="Imprimir" onClick="openpage('DG35000_IM.php','_self')"/>
        </label>
      </div></td>
    </tr>
  </table>
<br>
<?php
 
if ($_REQUEST['r1']=="consulta"){
?>
<table  align="center">
  <tr>
    <td class="thagre"><div align="center">N Caja</div></td>
    <td class="thagre"><div align="center">Recibo </div></td>
    <td class="thagre"><div align="center">Fecha</div></td>
    <td class="thagre"><div align="center">Movimiento</div></td>
    <td class="thagre"><div align="center">Cliente</div></td>
    <td class="thagre"><div align="center">Pedido</div></td>
    <td class="thagre"><div align="center">Total</div></td>
    <td class="thagre"><div align="center"> Cancelada</div></td>
  </tr>
  <?php
 
  	//fechas
	$fec = $_POST['t1'];
	include('DF20000.php');
	$fec_ini = $f_m;
	$fec = $_POST['t2'];
	include('DF20000.php');
	$fec_fin = $f_m;

	$bus1 = mysqli_query($con ,"SELECT * FROM dgger_cajerosj where fec_rec between '$fec_ini' and '$fec_fin' and tip_caj='$tipVen'"); 
	while ($reg1 = mysqli_fetch_array($bus1)){
		$dt_pemema=mysqli_fetch_array(mysqli_query($con ,"SELECT * FROM dgpemema WHERE fol_ven='".$reg1['pedido']."'")); 
			$esVis='';
		if($dt_pemema['es_vis'])
			$esVis='V-';
		if($reg1['cancelado']=="0"){
			$reg2 = mysqli_fetch_array(mysqli_query ("SELECT * FROM dgcatcli where cod_cli = '".$reg1['num_cli']."'"));
			$nomCli=$reg2['nom_cli']. ' ' .$reg2['ap_pat_cli']. ' ' .$reg2['ap_mat_cli'];

			$cancel = "NO";
		}else{
			$cancel = "SI";
			$nomCli="CANCELADO";

		}

		echo '<tr>';
		echo '<td><div align="center">'.$reg1['tip_caj'].'&nbsp;</div></td>';
		echo '<td><div align="center">'.$reg1['n_rec'].'&nbsp;</div></td>';
		$fec1 = $reg1['fec_rec'];
		include('DF20000.php');
		echo '<td><div align="center">'.$f_f.'&nbsp;</div></td>';
		echo '<td><div align="center">'.$reg1['tip_mov'].'&nbsp;</div></td>';
		$bus2 = mysqli_query ("SELECT * FROM dgcatcli where cod_cli = '".$reg1['num_cli']."'"); 
		$reg2 = mysqli_fetch_array($bus2);
		echo '<td><div align="left">'.$esVis.$nomCli.'&nbsp;</div></td>';
		echo '<td><div align="center">'.$dt_pemema['con_ven'].'&nbsp;</div></td>';
		echo '<td><div align="center">'.number_format($reg1['importe'],2,'.',',').'&nbsp;</div></td>';
		echo '<td><div align="center">'.$cancel.'&nbsp;</div></td>';
		echo '</tr>';
	}
  ?>
</table>
<?php
 
}elseif ($_REQUEST['r1']=="cancelar"){
?>
<table  align="center">
  <tr>
    <td class="thagre"><div align="center">Sel</div></td>
    <td class="thagre"><div align="center">N Caja </div></td>
    <td class="thagre"><div align="center">Recibo </div></td>
    <td class="thagre"><div align="center">Fecha</div></td>
    <td class="thagre"><div align="center">Movimiento</div></td>
    <td class="thagre"><div align="center">Cliente</div></td>
    <td class="thagre"><div align="center">Fecha Venta </div></td>
    <td class="thagre"><div align="center">Total</div></td>
    <td class="thagre"><div align="center"> Cancelada</div></td>
  </tr>
  <tr>
    <td class="inputcodigo"><div align="center">
      <input type="checkbox" name="checkbox2" value="checkbox" onClick="todos(this)">
    </div></td>

    <td colspan="8" class="inputcodigo"><input name="cancel2" type="button" class="boton" onClick="if(confirm('REALMENTE DESEA CANCELAR LOS RECIBOS!!!??')) openpage('DG35000_CA.php','_self');" value="Cancelar" /></td>
  </tr>
<?php
 
  	//fechas
	$fec = $_POST['t1'];
	include('DF20000.php');
	$fec_ini = $f_m;
	$fec = $_POST['t2'];
	include('DF20000.php');
	$fec_fin = $f_m;
	//$fec_ini =$_SESSION['fecven'];
	//$fec_fin =$_SESSION['fecven'];
  	$bus1 = mysqli_query($con ,"SELECT * FROM dgger_cajerosj where fec_rec between '$fec_ini' and '$fec_fin' AND cancelado=0 AND tip_caj='$tipVen'"); 
	$jj = 0;
	while ($reg1 = mysqli_fetch_array($bus1)){
		$dt_pemema=mysqli_fetch_array(mysqli_query($con ,"SELECT * FROM dgpemema WHERE fol_ven='".$reg1['pedido']."'")); 
			$esVis='';
		if($dt_pemema['es_vis'])
			$esVis='V-';	 
		$jj += 1;
		if($reg1['cancelado']=="0"){
			$reg2 = mysqli_fetch_array(mysqli_query ("SELECT * FROM dgcatcli where cod_cli = '".$reg1['num_cli']."'"));
			$nomCli=$reg2['nom_cli']. ' ' .$reg2['ap_pat_cli']. ' ' .$reg2['ap_mat_cli'];

			$cancel = "NO";
		}else{
			$cancel = "SI";
			$nomCli="CANCELADO";

		}
		
		echo '<tr>';
		echo '<td><div align="center"><input name="sel'.$jj.'" id="sel'.$jj.'" type="checkbox" value="'. $reg1['n_rec'].'"></td>';
		echo '<td><div align="center">'.$reg1['tip_caj'].'&nbsp;</div></td>';
		echo '<td><div align="center">'.$reg1['n_rec'].'&nbsp;</div></td>';
		$fec1 = $reg1['fec_rec'];
		include('DF20000.php');
		echo '<td><div align="center">'.$f_f.'&nbsp;</div></td>';
		echo '<td><div align="center">'.$reg1['tip_mov'].'&nbsp;</div></td>';
		echo '<td><div align="left">'.$esVis.$nomCli.'&nbsp;</div></td>';
		echo '<td><div align="center">'.$dt_pemema['con_ven'].'&nbsp;</div></td>';
		echo '<td><div align="right">'.number_format($reg1['importe'],2,'.',',').'&nbsp;</div></td>';

		echo '<td><div align="center">'.$cancel.'&nbsp;</div></td>';
		echo '</tr>';
	}
?>
</table>
<?php
 
	}
?>
<input name="val_fac" id="val_fac" type="hidden" value="0">
</form>
</body>
</html>