<?php
include_once(getabspath("include/cuenta_settings.php"));

function DisplayMasterTableInfo_cuenta($params)
{
	$detailtable = $params["detailtable"];
	$keys = $params["keys"];
	$detailPageObj = $params["detailPageObj"];
	global $conn,$strTableName;
	$xt = new Xtempl();
	$oldTableName = $strTableName;
	$strTableName = "cuenta";
	
	$settings = new ProjectSettings($strTableName, PAGE_LIST);
	$cipherer = new RunnerCipherer($strTableName);
	
	$masterQuery = $settings->getSQLQuery();
	
	$viewControls = new ViewControlsContainer($settings, PAGE_LIST);

$where = "";
$mKeys = array();
$showKeys = "";

global $page_styles, $page_layouts, $page_layout_names, $container_styles;

$layout = new TLayout("masterlist","BoldAqua","MobileAqua");
$layout->blocks["bare"] = array();
$layout->containers["0"] = array();

$layout->containers["0"][] = array("name"=>"masterlistheader","block"=>"","substyle"=>1);


$layout->skins["0"] = "empty";
$layout->blocks["bare"][] = "0";
$layout->containers["mastergrid"] = array();

$layout->containers["mastergrid"][] = array("name"=>"masterlistfields","block"=>"","substyle"=>1);


$layout->skins["mastergrid"] = "grid";
$layout->blocks["bare"][] = "mastergrid";$page_layouts["cuenta_masterlist"] = $layout;


if($detailtable == "cobro")
{
		$where.= GetFullFieldName("idcuenta", "", false)."=".$cipherer->MakeDBValue("idcuenta",$keys[1-1], "", "", true);
	$showKeys .= " "."ID Cuenta".": ".$keys[1-1];
	$xt->assign('showKeys',$showKeys);
}
	if(!$where)
	{
		$strTableName = $oldTableName;
		return;
	}
	$str = SecuritySQL("Search");
	if(strlen($str))
		$where.= " and ".$str;

	$strWhere = whereAdd($masterQuery->WhereToSql(),$where);
	if(strlen($strWhere))
		$strWhere = " where ".$strWhere." ";
	$strSQL = $masterQuery->HeadToSql().' '.$masterQuery->FromToSql().$strWhere.$masterQuery->TailToSql();

//	$strSQL = AddWhere($strSQL,$where);
	LogInfo($strSQL);
	$rs = db_query($strSQL,$conn);
	$data = $cipherer->DecryptFetchedArray($rs);
	if(!$data)
	{
		$strTableName = $oldTableName;
		return;
	}
	$keylink = "";
	$keylink.="&key1=".htmlspecialchars(rawurlencode(@$data["idcuenta"]));
	

//	idcuenta - 
			$value="";

					$xt->assign("idcuenta_mastervalue", $viewControls->showDBValue("idcuenta", $data, $keylink));

//	idtipo_cuenta - 
			$value="";

					$xt->assign("idtipo_cuenta_mastervalue", $viewControls->showDBValue("idtipo_cuenta", $data, $keylink));

//	denominacion - 
			$value="";

					$xt->assign("denominacion_mastervalue", $viewControls->showDBValue("denominacion", $data, $keylink));

//	fecha_alta - Datetime
			$value="";

					$xt->assign("fecha_alta_mastervalue", $viewControls->showDBValue("fecha_alta", $data, $keylink));

//	saldo - Number
			$value="";

					$xt->assign("saldo_mastervalue", $viewControls->showDBValue("saldo", $data, $keylink));

//	estado - 
			$value="";

					$xt->assign("estado_mastervalue", $viewControls->showDBValue("estado", $data, $keylink));

//	idusuario - 
			$value="";

					$xt->assign("idusuario_mastervalue", $viewControls->showDBValue("idusuario", $data, $keylink));

	$viewControls->addControlsJSAndCSS();
	$detailPageObj->viewControlsMap['mViewControlsMap'] = $viewControls->viewControlsMap;

	$layout = GetPageLayout("cuenta", 'masterlist');
	if($layout)
		$xt->assign("pageattrs", 'class="'.$layout->style." page-".$layout->name.'"');
	
	$xt->display("cuenta_masterlist.htm");
	
	$strTableName=$oldTableName;
}

?>