<?php	
	//$StrAG="S";+++
	$Emp_=LIKE($StrEmp);
	$Dex_=ToDate($StrDex);
	$Hax_=ToDate($StrHax);
	$TOT_OI=gn("SUM(TOT)","z_vis_ingresos","FEC>='$Dex_' AND FEC<='$Hax_' AND EC LIKE '$Emp_'");
	//VENTAS-CONTADO	
		$T_C_CO_T=gn("SUM(T)","_cot","TP='CO' AND F>='$Dex_' AND F<='$Hax_' AND EC LIKE '$Emp_'");
		$T_C_CO_E=gn("SUM(T)","_cot","TP='CO' AND M='E' AND F>='$Dex_' AND F<='$Hax_' AND EC LIKE '$Emp_'");
		$T_C_CO_D=gn("SUM(T)","_cot","TP='CO' AND M='D' AND F>='$Dex_' AND F<='$Hax_' AND EC LIKE '$Emp_'");
    //
		$T_V_CO_T=gn("SUM(T)","_ven","TP='CO' AND F>='$Dex_' AND F<='$Hax_' AND EC LIKE '$Emp_'");
		$T_V_CO_E=gn("SUM(T)","_ven","TP='CO' AND M='E' AND F>='$Dex_' AND F<='$Hax_' AND EC LIKE '$Emp_'");
		$T_V_CO_D=gn("SUM(T)","_ven","TP='CO' AND M='D' AND F>='$Dex_' AND F<='$Hax_' AND EC LIKE '$Emp_'");
	//VENTAS-CREDITO				 	
		$T_C_CR_T=gn("SUM(T)","_cot","TP='CR' AND F>='$Dex_' AND F<='$Hax_' AND EC LIKE '$Emp_'");
		$T_C_CR_E=gn("SUM(A)","_cot","TP='CR' AND M='E' AND F>='$Dex_' AND F<='$Hax_' AND EC LIKE '$Emp_'");
		$T_C_CR_D=gn("SUM(A)","_cot","TP='CR' AND M='D' AND F>='$Dex_' AND F<='$Hax_' AND EC LIKE '$Emp_'");	
	//
		$T_V_CR_T=gn("SUM(T)","_ven","TP='CR' AND F>='$Dex_' AND F<='$Hax_' AND EC LIKE '$Emp_'");
		$T_V_CR_E=gn("SUM(A)","_ven","TP='CR' AND M='E' AND F>='$Dex_' AND F<='$Hax_' AND EC LIKE '$Emp_'");
		$T_V_CR_D=gn("SUM(A)","_ven","TP='CR' AND M='D' AND F>='$Dex_' AND F<='$Hax_' AND EC LIKE '$Emp_'");	
	//COBROS DEL MISMO DIA
	$T_CMD_E=0;
	$T_CMD_D=0;
	if($StrAG=="SI"){
		$T_CMD_E=gn("SUM(T)","_cob","M='E' AND F>='$Dex_' AND F<='$Hax_' AND C=0 AND MD=1 AND EC LIKE '$Emp_'");
		$T_CMD_D=gn("SUM(T)","_cob","M='D' AND F>='$Dex_' AND F<='$Hax_' AND C=0 AND MD=1 AND EC LIKE '$Emp_'");				
	}
	//COBROS
	if($StrAG=="NO"){
		$T_K_T=gn("SUM(T)","_cob","F>='$Dex_' AND F<='$Hax_' AND C=0 AND EC LIKE '$Emp_'");
		$T_K_E=gn("SUM(T)","_cob","M='E' AND F>='$Dex_' AND F<='$Hax_' AND C=0 AND EC LIKE '$Emp_'");
		$T_K_D=gn("SUM(T)","_cob","M='D' AND F>='$Dex_' AND F<='$Hax_' AND C=0 AND EC LIKE '$Emp_'");
	}else{
		$T_K_T=gn("SUM(T)","_cob","F>='$Dex_' AND F<='$Hax_' AND C=0 AND MD=0 AND EC LIKE '$Emp_'");
		$T_K_E=gn("SUM(T)","_cob","M='E' AND F>='$Dex_' AND F<='$Hax_' AND C=0 AND MD=0 AND EC LIKE '$Emp_'");
		$T_K_D=gn("SUM(T)","_cob","M='D' AND F>='$Dex_' AND F<='$Hax_' AND C=0 AND MD=0 AND EC LIKE '$Emp_'");		
	}	
	//CONTRATOS
		$T_CON_T=gn("SUM(A)","_kon","F>='$Dex_' AND F<='$Hax_' AND EC LIKE '$Emp_'");
		$T_CON_E=gn("SUM(A)","_kon","M='E' AND F>='$Dex_' AND F<='$Hax_' AND EC LIKE '$Emp_'");
		$T_CON_D=gn("SUM(A)","_kon","M='D' AND F>='$Dex_' AND F<='$Hax_' AND EC LIKE '$Emp_'");
	
		$T_COIN_T=gn("SUM(T)","_koni","F>='$Dex_' AND F<='$Hax_' AND EC LIKE '$Emp_'");
		$T_COIN_E=gn("SUM(T)","_koni","M='E' AND F>='$Dex_' AND F<='$Hax_' AND EC LIKE '$Emp_'");
		$T_COIN_D=gn("SUM(T)","_koni","M='D' AND F>='$Dex_' AND F<='$Hax_' AND EC LIKE '$Emp_'");
	
	//GASTOS
	$T_GAS=gn("SUM(TOT)","_egr","FEC>='$Dex_' AND FEC<='$Hax_' AND EC LIKE '$Emp_' AND MODA='EFECTIVO'");
	$T_DEV=gn("SUM(TOT)","_dev","ANU='N' AND DIN='1' AND FEC>='$Dex_' AND FEC<='$Hax_' AND EC LIKE '$Emp_'");
	////////////////////////////////////////////////////
	$TOT_VEN_CO=$T_C_CO_T + $T_V_CO_T;
	$TOT_VEN_CO_E=$T_C_CO_E + $T_V_CO_E;
	$TOT_VEN_CO_D=$T_C_CO_D + $T_V_CO_D;
	
	$TOT_VEN_CR=$T_C_CR_T + $T_V_CR_T ;
	$TOT_VEN_CR_E=$T_C_CR_E + $T_V_CR_E + $T_CMD_E;
	$TOT_VEN_CR_D=$T_C_CR_D + $T_V_CR_D + $T_CMD_D;
	
	$TOT_COB=$T_K_T;
	$TOT_COB_E=$T_K_E;
	$TOT_COB_D=$T_K_D;
	
	$TOT_CON=$T_CON_T + $T_COIN_T;
	$TOT_CON_E=$T_CON_E + $T_COIN_E;
	$TOT_CON_D=$T_CON_D + $T_COIN_D;
	
	$TOT_GAS_E=$T_GAS;
	$TOT_DEV_E=$T_DEV;	
	
	////////////////////////////////////////////////////	
	$RES_EFE=($TOT_VEN_CO_E + $TOT_VEN_CR_E + $TOT_COB_E + $TOT_CON_E + $TOT_OI) - ($TOT_GAS_E + $TOT_DEV_E) ;
	$RES_DEP=($TOT_VEN_CO_D + $TOT_VEN_CR_D + $TOT_COB_D + $TOT_CON_D);
	//
	$LStrFoc="document.getElementById('TxtDex').focus();";
	$LStrMsg="onload=\"$LStrFoc;\"";
?>