#function generate_screen project screen_id
#query select name as application from `project` where project=?project?
#query select title, name as screen_name, `class` as classname, `parent` as parent_screen, `helpfile` from screen where screen=?screen_id?
#do system_log 1 ('Generate screen: ' ^ screen_name)
#if classname<>'menu'
#print page_header 'screen' project screen_id
#print '<html>\n'
#print '<head>\n'
#print ' <link href=\"list.css\" type=\"text/css\" rel=stylesheet>\n'
#print ' <meta content=\"text/css\" http-equiv=\"Content-Style-Type\">\n'
#print ' <title>' ^ application ^ ' Scherm: ' ^ title ^ '</title>\n'
#print '</head>\n'
#print '<script type=\"text/javascript\" src=\"handlers.js\" language=\"JavaScript\">\n'
#print ' alert (\"no code\");\n'
#print '</script>\n'
#print '<body>\n'
#print '<?php\n'
#print 'include \'menu.php\';\n'
#print 'include \'makemenu.php\';\n'
#query select `screen` as menu from screen where `project`=?project? and `class`='menu'
#set pmenu=-1
#set smenu=0
#set last=''
#record select `link` as screen, code from part where `screen`=?menu? order by `order`
#if code=''
#set pmenu=pmenu+1
#set smenu=0
#else
#if code=last
#set smenu=smenu+1
#else
#set pmenu=pmenu+1
#set smenu=0
#end
#end
#if screen=parent_screen
#break
#end
#set last=code
#end
#print ' makeMenu(' ^ string_of_int pmenu ^ ', ' ^ string_of_int smenu ^ ', \''^helpfile^'\');\n'
#print '?>\n'
#print '<div id=\"content\">\n'
#end
#set first=true
#set last=''
#record select part.part, part.`type`, part.`title`, part.`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 '<br><br><br>'
#end
#print '<table class=ruler><tr><td>' ^ title ^ '</td></tr></table>\n'
#end
#if type='link'
#set ScreenWidth='500'
#set ScreenHeight='500'
#query select name as tablename, id_field, ScreenWidth, ScreenHeight from `table` where `table`=?table?
#if code='edit'
#if id_field<>'$'
#print '<input type=button value=\"' ^ title ^ '\" onClick=\"javascript: window.open(\'edit' ^ tablename ^ '.php?' ^ id_field ^ '=<?php echo \"$' ^id_field ^ '\"; ?>\',\'\',\'width=' ^ ScreenWidth ^ ',height=' ^ ScreenHeight ^ ',location=no,menubar=no,scrollbars=yes,status=no,resizable=yes\'); return false;\">\n'
#else
#print '<input type=button value=\"' ^ title ^ '\" onClick=\"javascript: window.open(\'edit' ^ tablename ^ '.php\',\'\',\'width=' ^ ScreenWidth ^ ',height=' ^ ScreenHeight ^ ',location=no,menubar=no,scrollbars=yes,status=no,resizable=yes\'); return false;\">\n'
#end
#else
#if code='screen'
#print '<input type=button value=\"' ^ title ^ '\" onClick=\"javascript: location=\'' ^ link ^'\'; return false;\">\n'
#else
#if code=''
#print '<input type=button value=\"' ^ title ^ '\" onClick=\"javascript: window.open(\'' ^ link ^ '\',\'\',\'width=' ^ ScreenWidth ^ ',height=' ^ ScreenHeight ^ ',location=no,menubar=no,scrollbars=yes,status=no,resizable=yes\'); return false;\">\n'
#else
#print '<a href=\"' ^ code ^ '\">' ^ title ^ '</a>'
#end
#end
#end
#end
#if type='icon'
#if last=''
#print '<?php\n$items=array(\n '
#end
#if code=''
#if last<>''
#if last<>'**'
#print ')),\n '
#else
#print ',\n '
#end
#end
#print 'array(\"' ^ replace ' ' ' ' title ^ '\",\"' ^ link ^ '\",array())'
#set last='**'
#else
#if last<>''
#if code<>last
#if last<>'**'
#print ')),\n '
#else
#print ',\n '
#end
#else
#print ',\n\t'
#end
#end
#if code<>last
#print 'array(\"' ^ code ^ '\",\"' ^ link ^ '\",\n\tarray(array(\"' ^ replace ' ' ' ' title ^ '\",\"' ^ link ^ '\"'
#else
#print 'array(\"' ^ replace ' ' ' ' title ^ '\",\"' ^ link ^ '\"'
#end
#set last=code
#end
#if table<>'0'
#set where=''
#query select `sql` as tablesql, id_field from `table` where `table`=?table?
#set first2=true
#query select field.name as mainfield from table_order left join table_ofield on table_ofield.table_order=table_order.table_order left join `field` on field.field=table_ofield.field where table_order.table=?table? order by table_order.order, table_ofield.order limit 1
#record select field.sql as fieldsql, name, SessionVar from `field` where field.`table`=?table? and SessionVar<>'' and field.sql<>''
#if first2
#print ',\"'
#set first2=false
#else
#print '|'
#end
#print 'var_' ^ SessionVar
#if where<>''
#set where=where ^ ' and '
#end
#set where=where ^ '`' ^ fieldsql ^ '`=\'$_SESSION[var_' ^ SessionVar ^ ']\''
#end
#if not first2
#print '\",\"select `' ^ mainfield ^ '` as title from `' ^ tablesql ^ '` where ' ^ where ^ '\")'
#else
#print ')'
#end
#else
#print ')'
#end
#end
#if type='script'
#print '<?php system(\"' ^ code ^ '\") ?>\n'
## print '<input type=button value=\"' ^ title ^ '\" onClick=\"javascript: window.open(\'script_' ^ title ^ '.php\',\'' ^ title
## print '\',\'width=660,height=680,location=no,menubar=no,scrollbars=yes,status=no,resizable=yes\'); return false;\">\n'
## set sf=ope_out (OutputLocation ^ '/script_' ^ title ^ '.php')
## do output_string sf ('<?php system(\"' ^ code ^ '\") ?>')
## do close_out sf
#end
#if type='record'
#print generate_record project table
#end
#if type='edit'
#print generate_edit project table
#end
#if type='list'
#print generate_list project table (if link=screen_name then '' else link) part
#end
#if type='html'
#set str=replace '\"' '\\\"' (fieldreplace code '0')
#print '<?php\n'
#print 'echo \"' ^ str ^ '\";\n'
#print '?>\n'
#end
#set first=false
#end
#if last<>''
#print ';\n?>\n'
#end
#if classname<>'menu'
#print '</div>'
#print '</body>\n'
#print '</html>\n'
#end
#end
#function rights_screen project screen_id
#query select name as application from `project` where project=?project?
#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' project screen_id
#print '<html>\n'
#print '<head>\n'
#print ' <link href=\"list.css\" type=\"text/css\" rel=stylesheet>\n'
#print ' <meta content=\"text/css\" http-equiv=\"Content-Style-Type\">\n'
#print ' <title>' ^ application ^ ' Scherm: ' ^ title ^ '</title>\n'
#print '</head>\n'
#print '<script type=\"text/javascript\" src=\"handlers.js\" language=\"JavaScript\">\n'
#print ' alert (\"no code\");\n'
#print '</script>\n'
#if classname<>''
#print '<body class=\"' ^ classname ^ '\">\n'
#else
#print '<body>\n'
#end
#set first=true
#set last=''
#record select part.`part`, part.`type`, part.`title`, part.`table`, screen.name as link, `code` from part left join screen on part.link=screen.screen where part.screen=?screen_id?
#if title<>'' and type<>'icon' and type<>'link'
#if not first
#print '<br><br><br>'
#end
#print '<table class=ruler><tr><td>' ^ title ^ '</td></tr></table>\n'
#end
#if type='link'
#print '<input type=button value=\"' ^ title ^ '\" onClick=\"location=\'rights_' ^ link ^ '\'\">\n'
#print part_rights_link part 'hide'
#end
#if type='icon'
#if code=''
#print 'array(\"' ^ title ^ '\",\"rights_' ^ link ^ '\",array()),\n'
#else
#if last<>''
#if code<>last
#print '),\n'
#else
#print ','
#end
#end
#if code<>last
#print 'array(\"' ^ code ^ '\",\"rights_' ^ link ^ '\",array(array(\"' ^ title ^ '\",\"rights_' ^ link ^ '\")'
#else
#print 'array(\"' ^ title ^ '\",\"rights_' ^ link ^ '\")'
#end
#end
## print '<table class=menu><tr><td><p><a href=\"rights_' ^ link ^ '\" target=main>'
## print '<img src=\"' ^ code ^ '\"><br>' ^ title ^ '</a></p></td></tr></table>\n'
## print part_rights_link part 'show'
#end
#if type='script'
#print '<input type=button value=\"' ^ title ^ '\" onClick=\"javascript: window.open(\'rights_' ^ title ^ '.php\',\'' ^ title
#print '\',\'width=660,height=680,location=no,menubar=no,scrollbars=yes,status=no,resizable=yes\'); return false;\">\n'
#print part_rights_link part 'show'
#end
#if type='record'
#print rights_record project table
#end
#if type='list'
#print rights_list project table (if link=screen_name then '' else link) part
#end
#if type='html'
#set str=replace '\"' '\\\"' (fieldreplace code '0')
#print '<?php\n'
#print 'echo \"' ^ str ^ '\";\n'
#print '?>\n'
#end
#set first=false
#end
#print '</body>\n'
#print '</html>\n'
#end