<?php
include("cls_conexion.php");$CNN=new ClsMySQL();include("conexion23.php");
include("funciones.php");
//++
$OK=0;
$ER=0;
$IN=0;
$REC=0;
$REC_NO=0;
//++
$s="SELECT * FROM ventas WHERE anu='N' AND ven_cob_kod>0 ORDER BY id_venta";
$rs=grs($s);
while($r=$rs->fetch_assoc()){
	$VEN_KOD=$r['id_venta'];
	$COB_KOD=$r['ven_cob_kod'];
	$CX=gn("count(*)","cobroz_ventas","cv_id_cob=$COB_KOD AND cv_id_ven=$VEN_KOD");
	if($CX==1){
		$OK++;
	}else{
		if($CX>1){
			$IN++;
			$z="SELECT * FROM cobroz_ventas WHERE cv_id_cob=$COB_KOD AND cv_id_ven=$VEN_KOD ORDER BY id_cv";
			$rz=grs($z);
			while($z=$rz->fetch_assoc()){
				echo "IN VENTA = ".$z['cv_id_ven']."  / COBRO = ".$z['cv_id_cob']."  / CV_ID=".$z['id_cv']."<br>";
			}
		}else{
			$V_COT_KOD=VEN_GET_COT_KOD($VEN_KOD);
			$C_COT_KOD=COB_GET_COT_KOD($COB_KOD);
			$KON=gn("count(*)","cobroz","id_cobro=".$COB_KOD);
			if($V_COT_KOD==$C_COT_KOD && $KON>0){
				$REC++;
				echo "REC <br>";				
			}else{
				$REC_NO++;
				echo "NO REC <br>";
				VENTAS_COBROZ_REPARAR($VEN_KOD);
			}
			$ER++;
		}
		
	}
}
//
echo "OK=".$OK."<br>";
echo "IN=".$IN."<br>";
echo "ER=".$ER."<br>";
echo "REC=".$REC."<br>";
echo "REC_NO=".$REC_NO."<br>";
?>