<?php
session_start();
$ruta='../';
require_once("clases/covensol_cxc_c_cuentasxcobrar.php");
$objcxc = new covensol_cxc_cuentasxcobrar();
$objcxc->io_conexiones->decodificar_post();
$datos = $objcxc->io_conexiones->asignar_post();
$resp = $objcxc->MonedaPorDefecto();
$datos['criterio'] = 'por_listado';
$filas = $objcxc->consulta_documentos($datos);

if(!$filas['rs']->RecordCount()){exit();}

?>
<link href="../shared/css/tablas.css" rel="stylesheet" type="text/css">
<link href="../shared/css/ventanas.css" rel="stylesheet" type="text/css">
<link href="../shared/css/cabecera.css" rel="stylesheet" type="text/css">
<link href="../shared/css/general.css" rel="stylesheet" type="text/css">
<link href="../shared/css/catalogos.css" rel="stylesheet" type="text/css">
<?php

$Titulo='Notas de Crédito';
$objcxc->Grid->IdGrid = 'GridNotCre';
$objcxc->Grid->AddColumn(1,'Suc',50);
$objcxc->Grid->AddColumn(2,'Caj',50);
$objcxc->Grid->AddColumn(3,'N° NC',70);
$objcxc->Grid->AddColumn(4,'N° Fac',70);
$objcxc->Grid->AddColumn(5,'Cliente',200);
$objcxc->Grid->AddColumn(6,'rif',80);
$objcxc->Grid->AddColumn(7,'Fec',60);
$objcxc->Grid->AddColumn(8,'Form Pag',60);
$objcxc->Grid->AddColumn(9,'Mon',50);
$objcxc->Grid->AddColumn(10,'Tasa',50);
$objcxc->Grid->AddColumn(11,'Subtot',80);
$objcxc->Grid->AddColumn(12,'iva',80);
$objcxc->Grid->AddColumn(12,'total',80);
$objcxc->Grid->AddColumn(13,'Mon Aplic',80);
$objcxc->Grid->NroFila=1;

$objcxc->Grid->InitMarcoGrid();
$objcxc->Grid->TituloGrid($Titulo);
$objcxc->Grid->EncabezadoGrid();
foreach($filas['rs'] as $datosRow) {
		
		//SEGURIDAD DE LA SUCURSAL
        $objcxc->codintper = $datosRow['codsuc'];		
        if(!$objcxc->obtSegCxc()){continue;}
        
        //SEGURIDAD DE LA CAJA
        $objcxc->codintper = $datosRow['codsuc'].' - '.$datosRow['codcaj'];		
        if(!$objcxc->obtSegCxc()){continue;}
		
		$datosRow = $objcxc->FormatDatosDocPresent($datosRow);	
				
		$cargar = 'ObjForm.Aceptar('."'".$datosRow['codsuc']."','".
										 $datosRow['codcaj']."','".
										 $datosRow['tipdoc']."','".
										 $datosRow['id_doc']."','".
										 $datosRow['codtipdoc']."','".
										 $datosRow['numdoc']."','".
										 $datosRow['id_fact']."',".												   										  				   
										 $objcxc->Grid->NroFila.');';
					
		$SaldoAplicado = '0,00';
		
		/*
		$datosRow['id_doc']=$datosRow['idant'];
		$cobrado = $objcxc->BuscarMontoCobradoAnt($datosRow);		
		$Saldo = $objcxc->SaldoAnt($datosRow);
		*/
			   
		if($datosRow['abrmon']=='E'){$datosRow['abrmon']='&#x20AC';}								
				
		$objcxc->Grid->InitRow();		
		$objcxc->Grid->JsOnClickRow = $cargar;
		$objcxc->Grid->EstiloRow="cursor:pointer";
		$objcxc->Grid->CaracteresCell[1] = 10;
		$objcxc->Grid->CaracteresCell[5] = 40;
		$objcxc->Grid->AddDataCell(1,'codsuc',$datosRow['codsuc'],'center','html');
		$objcxc->Grid->AddDataCell(2,'codcaj',$datosRow['codcaj'],'center','html');				
		$objcxc->Grid->AddDataCell(3,'numdoc',$datosRow['numdoc'],'center','html');
		$objcxc->Grid->AddDataCell(4,'numfact',$datosRow['numfact'],'center','html');
		$objcxc->Grid->AddDataCell(5,'nombre_cliente',$datosRow['nombre_cliente'],'left','cell');
		$objcxc->Grid->AddDataCell(6,'rif_completo',$datosRow['rif_completo'],'center','html');
		$objcxc->Grid->AddDataCell(7,'fecdoc',$datosRow['fecdoc'],'center','html');
		$objcxc->Grid->AddDataCell(8,'formpagdoc',$datosRow['formpagdoc'],'center','html');
		$objcxc->Grid->AddDataCell(9,'abrmon',$datosRow['abrmon'],'center','html');
		$objcxc->Grid->AddDataCell(10,'tascam',$datosRow['tascam'],'center','html');
		$objcxc->Grid->AddDataCell(11,'subtot_doc',$datosRow['subtot_doc'],'right','html');
		$objcxc->Grid->AddDataCell(12,'iva_doc',$datosRow['iva_doc'],'right','html');
		$objcxc->Grid->AddDataCell(13,'total_doc',$datosRow['total_doc'],'right','html');		
		$objcxc->Grid->AddDataCell(14,'saldoapli',$SaldoAplicado,'right','html');
		$objcxc->Grid->AddCampoHidden('nombre_cliente',$datosRow['nombre_cliente']);
		$objcxc->Grid->FilaGrid();
		$objcxc->Grid->NroFila++; 
		
}
$objcxc->Grid->EndMarcoGrid();
?>	         