#function generate_screen dbase_id screen_id
#query select ApplicationName, OutputLocation from `database` where DatabaseID=?dbase_id?
#query select title, name as screen_name, `class` as classname from screen where screen=?screen_id?
#do system_log 1 ('Generate screen: ' ^ screen_name)
#if classname<>'menu'
#print page_header 'screen' dbase_id screen_id
#print '\n'
#print '
\n'
#print ' '
#end
#set first=true
#record select part.part, part.`type`, part.`title`, `table`, screen.name as link, `code` from part left join screen on part.link=screen.screen where part.screen=?screen_id? order by `order`, `part`
#if title<>'' and type<>'icon' and type<>'link'
#if not first
#print ' '
#end
#print '\n'
#end
#if type='link'
#set ScreenWidth='500'
#set ScreenHeight='500'
#query select Subject, IDfield, ScreenWidth, ScreenHeight from `tables` where `tableID`=?table?
#if code='edit'
#if IDfield<>'$'
#print ' \',\'\',\'width=' ^ ScreenWidth ^ ',height=' ^ ScreenHeight ^ ',location=no,menubar=no,scrollbars=yes,status=no,resizable=yes\'); return false;\">\n'
#else
#print ' \n'
#end
#else
#if code='screen'
#print ' \n'
#else
#if code=''
#print ' \n'
#else
#print '' ^ title ^ ' '
#end
#end
#end
#end
#if type='icon'
#print ''0'
#print 'if (true'
#record select SessionVar from `fields` where `TableId`=?table? and SessionVar<>''
#print ' and $_SESSION[var_' ^ SessionVar ^ ']<>\'\''
#end
#print ') {\n'
#end
#print ' echo \'\';\n'
#if table<>'0'
#print '}\n'
#end
#print '?>\n'
#end
#if type='script'
#print ' \n'
#set sf=open_out (OutputLocation ^ '/script_' ^ title ^ '.php')
#do output_string sf ('')
#do close_out sf
#end
#if type='record'
#print generate_record dbase_id table
#end
#if type='edit'
#print generate_edit dbase_id table
#end
#if type='list'
#print generate_list dbase_id table (if link=screen_name then '' else link) part
#end
#if type='html'
#set str=replace '\"' '\\\"' (fieldreplace code '0')
#print '\n'
#end
#set first=false
#end
#if classname<>'menu'
#print '
'
#print '\n'
#print '\n'
#end
#end
#function rights_screen dbase_id screen_id
#query select ApplicationName from `database` where DatabaseID=?dbase_id?
#query select title, name as screen_name, `class` as classname from screen where screen=?screen_id?
#do system_log 1 ('Generate rights screen: ' ^ screen_name)
#print page_header 'screen' dbase_id screen_id
#print '\n'
#print '\n'
#print '