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

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

//$strSQL = "SELECT idarticulo,   codigo,   nombre,   idcategoria,   idsubcategoria,   costo,   precio,   stock,   idproveedor,   fecha_carga,   observacion  FROM articulo ";

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


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

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

//	codigo - 
			$xt->assign("codigo_mastervalue", $viewControls->showDBValue("codigo", $data, $keylink));

//	nombre - 
			$xt->assign("nombre_mastervalue", $viewControls->showDBValue("nombre", $data, $keylink));

//	idcategoria - 
			$xt->assign("idcategoria_mastervalue", $viewControls->showDBValue("idcategoria", $data, $keylink));

//	idsubcategoria - 
			$xt->assign("idsubcategoria_mastervalue", $viewControls->showDBValue("idsubcategoria", $data, $keylink));

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

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

//	stock - 
			$xt->assign("stock_mastervalue", $viewControls->showDBValue("stock", $data, $keylink));

//	idproveedor - 
			$xt->assign("idproveedor_mastervalue", $viewControls->showDBValue("idproveedor", $data, $keylink));

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

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

}

?>