<?
session_name('portal_absa');
session_start();

if(!isset($_SESSION['usuario_p_prov_absa']) || trim($_SESSION['usuario_p_prov_absa']) == "" || trim(strtoupper($_SESSION["URL_PORTAL"]."admin.php")) != trim(strtoupper($_SERVER['HTTP_REFERER']))){
	?><script>window.location.href="<?=$_SESSION["URL_PORTAL"]."index.php"?>"</script><?
	exit;
}
?>

<script>
$j_6(function(){
	$j_6('#tree_CFDIRelacionados').treegrid({
		title:'Documentos relacionados',
		iconCls:'icon-save',
		width:1000,
		height:1000,
		nowrap: false,
		rownumbers: true,
		animate:true,
		collapsible:true,
		url:'extras/cfdirelacionadosJSON.php?uuid=<?=$_POST['id']?>',
		idField:'uuid',
		treeField:'uuid',
		frozenColumns:[[			
			{title:'UUID',field:'uuid',height: 100,width:500,
				formatter:function(value){
					value=value.replace("--TAG1--",'<span style="color: red">');
					return value=value.replace("--TAG2--",'</span>');
				}
			}
		]],
		columns:[[
			{field:'serie',title:'Serie',height: 100,width:70},
			{field:'folio',title:'Folio',height: 100,width:100,rowspan:2},
			{field:'nombreemi',title:'Emisor',height: 100,width:330,rowspan:2}
		]],/*,
		onBeforeLoad:function(row,param){
			if (row){
				$j_6(this).treegrid('options').url = 'extras/treegrid_subdata.json';
			} else {
				$j_6(this).treegrid('options').url = 'extras/cfdirelacionados.json';
			}
		}*/
		onContextMenu: function(e,row){
			e.preventDefault();
			$j_6(this).treegrid('unselectAll');
			$j_6(this).treegrid('select', row.uuid);
			$j_6('#mm').menu('show', {
				left: e.pageX,
				top: e.pageY
			});
		}
		
	});
});
function getFile(tipo){
	var node = $j_6('#tree_CFDIRelacionados').treegrid('getSelected');
	$j_6.post("extras/getNameFile.php",{uuid: node.uuid,tipo: tipo},function(data){
		$j_6("#result").html(data);
	});
}
</script>

<table id="tree_CFDIRelacionados"></table>
