<?php
$strTableName="##@TABLE.strDataSourceTable s##";
$_SESSION["OwnerID"] = $_SESSION["_".$strTableName."_OwnerID"];

##if @TABLE.strOriginalTable##
$strOriginalTableName="##@TABLE.strOriginalTable s##";
##else##
$strOriginalTableName="##@TABLE.strDataSourceTable s##";
##endif##

##if @TABLE.nType==titTABLE || @TABLE.nType==titVIEW##
$gPageSize=##@TABLE.nNumberOfRecords##;
##endif##

$gstrOrderBy="##@TABLE.strOrderBy s##";
if(strlen($gstrOrderBy) && strtolower(substr($gstrOrderBy,0,8))!="order by")
	$gstrOrderBy="order by ".$gstrOrderBy;

$g_orderindexes=array();
##if @TABLE.nType==titTABLE || @TABLE.nType==titVIEW || @TABLE.nType==titREPORT##
	##foreach @TABLE.arrOrderIndexes as @o order @o.nOrderIndex##
$g_orderindexes[] = array(##@o.nIndex##, (##@o.bAsc## ? "ASC" : "DESC"), "##@o.strOrderField s##");
	##endfor##
##endif##
$gsqlHead="##@TABLE.sqlHead ls##";
$gsqlFrom="##@TABLE.sqlFrom ls##";
$gsqlWhereExpr="##@TABLE.sqlWhere ls##";
$gsqlTail="##@TABLE.sqlTail ls##";

include("##@TABLE.strShortTableName##_settings.php");
##if @TABLE.arrEventHandlers.len##
include("##@TABLE.strShortTableName##_events.php");
##endif##

$reportCaseSensitiveGroupFields = false;

$gstrSQL = gSQLWhere("");

##foreach @TABLE.arrEventHandlers as @eh filter @eh.strEventID=="EVENT_INIT_TABLE"##
// here goes EVENT_INIT_TABLE event
##@eh.strEventCode e##
;
##endfor##

?>