$ListItem)
{
//echo('ListItem');
//print_r($ListItem);
$Type = GetTypeDefinition($ListItem['Type']);
if($ListItem['VisibleInPointer'] == 1)
{
if($Type['ParentType'] == TypePointerOneToOneId)
{
//print_r($Type);
$DbResult = $Database->select(array('Database' => $List['Database'], 'Table' => $List['TableName'], 'Condition' => $List['IdName'].'='.$Item['Value']));
$DbRow = $DbResult->fetch_assoc();
$DefinitionItem = array('Name' => $Index, 'Type' => $Item['Type'], 'Caption' => $Item['TextBefore'], 'Value' => $DbRow[$Index], 'SourceTable' => $List['Id'], 'SourceItemId' => 0);
$SubTarget = $this->GetTablePointerName($Type, $DefinitionItem);
$Columns .= '"'.$SubTarget['Name'].' ",';
} else $Columns .= '`'.$ListItem['Name'].'`," ",';
}
}
$Columns = substr($Columns, 0, -1);
if($Columns == '') $Columns = '`'.$List['IdName'].'` AS `Name`, `'.$List['IdName'].'`';
else $Columns = 'CONCAT('.$Columns.') AS `Name`, `'.$List['IdName'].'`';
$DbResult = $Database->select(array('Database' => $List['Database'], 'Table' => $TargetTable, 'Columns' => $Columns, 'Condition' => $List['IdName'].'='.$Item['Value']));
//echo($Database->LastQuery);
if($DbResult->num_rows > 0)
{
return($DbResult->fetch_assoc());
} else return('');
}
function GetTablePointerNameList($Type, $Item)
{
global $Database;
$Columns = '';
$List = GetListDefinition($Type['Parameters'][0]);
$TargetTable = $List['TableName'];
foreach($List['Items'] as $ListItem)
if($ListItem['VisibleInPointer'] == 1) $Columns .= '`'.$ListItem['Name'].'`," ",';
$Columns = 'CONCAT('.substr($Columns, 0, -1).') AS Name, `'.$List['IdName'].'`';
$DbResult = $Database->select(array('Database' => $List['Database'], 'Table' => $TargetTable, 'Columns' => $Columns));
//echo($Database->LastQuery);
if($DbResult->num_rows > 0)
{
$Result = array(array('Name' => 'Žádný', 'Id' => 0));
while($DbRow = $DbResult->fetch_assoc())
$Result[] = $DbRow;
return($Result);
} else return(array());
}
function OnView($Item)
{
global $Database;
$Type = GetTypeDefinition($Item['Type']);
$List = GetListDefinition($Type['Parameters'][0]);
$TargetTable = $Type['Parameters'][0];
$TargetName = $this->GetTablePointerName($Type, $Item);
if($TargetName != '') $Output = ''.$TargetName['Name'].'';
else $Output = '';
return($Output);
}
function OnEdit($Item)
{
global $Database, $Types;
$Type = $Types[$Item['Type']];
$List = GetListDefinition($Type['Parameters'][0]);
$Output = '';
return($Output);
}
function OnLoad($Item)
{
return($_POST[$Item['Name']]);
}
}
?>