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

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

//$strSQL = "SELECT  idtransaccion,  tipo,  fecha,  cliente,  idarticulo,  costo,  precio,  cant,  total,  importe,  descuento,  observacion,  cobrado,  anulado,  ganancia  FROM transaccion  WHERE (tipo =\"VENTA\")  ORDER BY idtransaccion DESC  ";

	$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["transaccion_masterprint"] = $layout;


$showKeys = "";
if($detailtable=="cobro")
{
		$where.= GetFullFieldName("idtransaccion", "", false)."=".$cipherer->MakeDBValue("idtransaccion",$keys[1-1], "", "", true);
	$showKeys .= " "."ID".": ".$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["idtransaccion"]));
	

//	idtransaccion - 
			$xt->assign("idtransaccion_mastervalue", $viewControls->showDBValue("idtransaccion", $data, $keylink));

//	tipo - 
			$xt->assign("tipo_mastervalue", $viewControls->showDBValue("tipo", $data, $keylink));

//	fecha - Short Date
			$xt->assign("fecha_mastervalue", $viewControls->showDBValue("fecha", $data, $keylink));

//	cliente - 
			$xt->assign("cliente_mastervalue", $viewControls->showDBValue("cliente", $data, $keylink));

//	idarticulo - 
			$xt->assign("idarticulo_mastervalue", $viewControls->showDBValue("idarticulo", $data, $keylink));

//	costo - Number
			$xt->assign("costo_mastervalue", $viewControls->showDBValue("costo", $data, $keylink));

//	precio - Number
			$xt->assign("precio_mastervalue", $viewControls->showDBValue("precio", $data, $keylink));

//	cant - Number
			$xt->assign("cant_mastervalue", $viewControls->showDBValue("cant", $data, $keylink));

//	total - Number
			$xt->assign("total_mastervalue", $viewControls->showDBValue("total", $data, $keylink));

//	importe - Number
			$xt->assign("importe_mastervalue", $viewControls->showDBValue("importe", $data, $keylink));

//	descuento - Number
			$xt->assign("descuento_mastervalue", $viewControls->showDBValue("descuento", $data, $keylink));

//	observacion - 
			$xt->assign("observacion_mastervalue", $viewControls->showDBValue("observacion", $data, $keylink));

//	cobrado - 
			$xt->assign("cobrado_mastervalue", $viewControls->showDBValue("cobrado", $data, $keylink));

//	anulado - 
			$xt->assign("anulado_mastervalue", $viewControls->showDBValue("anulado", $data, $keylink));

//	ganancia - Number
			$xt->assign("ganancia_mastervalue", $viewControls->showDBValue("ganancia", $data, $keylink));
	$xt->display("transaccion_masterprint.htm");
	$strTableName=$oldTableName;

}

?>