<?
require_once("../../clases/datosbd.class.php");

$qDoce="select rfcreceptor,tipodocto,serie,folio,adicionalA as uuid,rfcemisor from doce where adicionalA='".$_REQUEST["uuid"]."'";
if(!$rDoce = mysqli_query($conexion->CONEXION,$qDoce)){
	?><script>$j_7.messager.alert("Error","Ocurrio un error al consultar el documento de pago.","error");</script><?exit;
}

if(mysqli_num_rows($rDoce) <= 0){

	?><script>$j_7.messager.alert("Error","No se encontro el documento de pago.","error");</script><?exit;
}

$tDoce = mysqli_fetch_assoc($rDoce);

$datosbd = new datosbd();
$datosbd->getConfig($tDoce["rfcemisor"]);
if($datosbd->noerror == -1){
	$datosbd->Alert($datosbd->mensaje);
}
if($datosbd->cConfig == null){
	$datosbd->Alert("No se encontro la configuración del receptor.");exit;
}



$queryDocs="select r.rfcemisor,r.tipodocto,r.uuid,r.serie,r.folio,r.total,r.fechadocto, subtipodocto, getStatusPagado(rdt.totalPagoDocumentosRef,rdt.totalIngresoCompensado,total,".$datosbd->cConfig["tolerancia_FacturaPagada"].") as statusPagada 
from recibedoce r inner join recibedoce_totales rdt on rdt.uuid=r.uuid inner join receptor rtor on rtor.rfc = r.rfc_receptor inner join tdoctos_r t 
on rtor.idReceptor = t.idReceptor and t.tipoDocto=r.tipoDocto where t.subtipodocto='I' and status='A' and rfcemisor='".$tDoce["rfcreceptor"]."' having statusPagada = 0";
// echo $queryDocs;exit;

if(!$resultD = mysqli_query($conexion->CONEXION,$queryDocs)){
	?><script>$j_7.messager.alert("Error","Ocurrio un error al consultar los documentos recibidos.","error");</script><?exit;
}

?>
<script language="javascript" src="../libs/js/funciones.js"></script>
<table width="98%">
	<tr style="background-color: #000000; color: #FFFFFF">
		<td></td>
		<td>Emisor</td>
		<td>Tipo Documento</td>
		<td>Serie</td>
		<td>Folio</td>
		<td>UUID</td>
		<td>Fecha</td>
		<td>Total</td>
	</tr>
<?if(mysqli_num_rows($resultD) > 0){
$con=0;
	
	while($tmp = mysqli_fetch_array($resultD,MYSQLI_ASSOC)){
	$con++;
	$res = $con%2;
	$trEstilo="";
	if($res == 0)
		$trEstilo = "style='background-color: #999999'";
?>
	<tr <?=$trEstilo?>>
		<td>
			<img onclick="agregarDoc('<?=$tmp['uuid']?>')" src="../Imagenes/addDoc.png" style="cursor:pointer" width="32" height="32" />
		</td>
		<td><?=$tmp['rfcemisor']?></td>
		<td><?=$tmp['tipodocto']?></td>
		<td><?=$tmp['serie']?></td>
		<td><?=$tmp['folio']?></td>
		<td><?=$tmp['uuid']?></td>
		<td><?=$tmp['fechadocto']?></td>
		<td><?=$tmp['total']?></td>
	</tr>
<?}}?>
</table>

<div id="resultD"></div>

