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

function DisplayMasterTableInfo_cliente($params)
{
	$detailtable=$params["detailtable"];
	$keys=$params["keys"];
	global $conn,$strTableName;
	$xt = new Xtempl();
	
	$oldTableName=$strTableName;
	$strTableName="cliente";

//$strSQL = "SELECT idcliente,   denominacion,   ruc_ci,   direccion,   idciudad,   telefono,   observacion  FROM cliente ";

	$cipherer = new RunnerCipherer($strTableName);
	$settings = new ProjectSettings($strTableName, PAGE_PRINT);
	
	$masterQuery = $settings->getSQLQuery();
	$viewControls = new ViewControlsContainer($settings, PAGE_PRINT);

$where="";

global $pageObject, $page_styles, $page_layouts, $page_layout_names, $container_styles;
$layout = new TLayout("masterprint","BoldAqua","MobileAqua");
$layout->blocks["bare"] = array();
$layout->containers["0"] = array();

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


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

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


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


$showKeys = "";
if($detailtable=="venta")
{
		$where.= GetFullFieldName("idcliente", "", false)."=".$cipherer->MakeDBValue("idcliente",$keys[1-1], "", "", true);
	$showKeys .= " "."Idcliente".": ".$keys[1-1];
	$xt->assign('showKeys',$showKeys);
	
}
if(!$where)
{
	$strTableName=$oldTableName;
	return;
}
	$str = SecuritySQL("Export");
	if(strlen($str))
		$where.=" and ".$str;
	
	$strWhere = whereAdd($masterQuery->m_where->toSql($masterQuery),$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["idcliente"]));
	

//	idcliente - 
			$xt->assign("idcliente_mastervalue", $viewControls->showDBValue("idcliente", $data, $keylink));

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

//	ruc_ci - 
			$xt->assign("ruc_ci_mastervalue", $viewControls->showDBValue("ruc_ci", $data, $keylink));

//	direccion - 
			$xt->assign("direccion_mastervalue", $viewControls->showDBValue("direccion", $data, $keylink));

//	idciudad - 
			$xt->assign("idciudad_mastervalue", $viewControls->showDBValue("idciudad", $data, $keylink));

//	telefono - 
			$xt->assign("telefono_mastervalue", $viewControls->showDBValue("telefono", $data, $keylink));

//	observacion - 
			$xt->assign("observacion_mastervalue", $viewControls->showDBValue("observacion", $data, $keylink));
	$xt->display("cliente_masterprint.htm");
	$strTableName=$oldTableName;

}

?>