#function add_php dbase_id table_id #query select DatabaseName from `database` where DatabaseID=?dbase_id? #query select TableID, Subject, Title, Checks, Session, TableName, IDfield from `tables` where TableID=?table_id? #set orderfield='0' #query select `FieldID` as orderfield, FieldName as ordername from `fields` where `TableID`=?table_id? and `Type`='ordering' #print page_header 'add' dbase_id table_id #print 'Create(\"' ^ DatabaseName ^ '\");\n' #record select fieldID, `Add`, Name, FieldName, `Type`, DisplayName, DisplayLength, Help, areaheight, areawidth, LookupTable, OrderByField, LookupIDField, SessionVar, LookupDisplayField from `fields` where TableID=?table_id? and LookupTable<>'' and SessionVar<>'' and DisplayName='' order by `order` #print '$sql->QueryItem(\"SELECT `' ^ LookupDisplayField ^ '` FROM `' ^ LookupTable ^ '` WHERE `' ^ LookupIDField ^ '` = $' ^ SessionVar ^ '\");\n' #print '$' ^ Name ^ ' = htmlspecialchars($sql->data[0]);\n' #end #set firstfield='none' #query select FieldName as firstfield from `fields` where TableID=?table_id? and Record<>'none' and FieldName<>'' order by `order` limit 1 #print 'if ($_POST[\'' ^ firstfield ^ '\']!=\'\') {\n' #record select Name, FieldName, `Type`, DisplayName, DisplayLength, areaheight, areawidth, LookupTable, OrderByField, LookupIDField, LookupDisplayField from `fields` where TableID=?table_id? and Record<>'none' and FieldName<>'' order by `order` #if Type='varchar' or Type='text' #print ' $' ^ Name ^ ' = ($_POST[\'' ^ FieldName ^ '\']);\n' #else #if Type='date' #print '$' ^ Name ^ ' = date(\'j/n/Y\', strtotime($_POST[\'' ^ FieldName ^ '\']));\n' #else #print '$' ^ Name ^ ' = $_POST[\'' ^ FieldName ^ '\'];\n' #end #end #end #print '}\n' #print '?>\n' #print '\n' #print '\n' #print ' \n' #print ' ' ^ Title ^ ' add\n' #print '\n' #print '\n' #record select Code from actions where TableID=?table_id? and Action='add' and Part='header' #print Code ^ '\n' #end #print '
\n' #print '\n' #print ' \n' #print ' \n' #print ' \n' #print ' \n' #print ' \n' #print ' \n' #if orderfield<>'0' #print ' \">\n' #end #record select `Add`, FieldName, `Type`, DisplayName, `default`, SessionVar, Help, areaheight, listwidth, listwidth*7 as pxwidth, LookupTable, OrderByField, LookupIDField, LookupDisplayField from `fields` where TableID=?table_id? and Record<>'none' order by `order` #if SessionVar<>'' #print ' \">\n' #end #print ' \n' #print ' \n' #print ' \n' #print ' \n' #end #print ' \n' #print '
\n' #print '

' #print '' ^ Title ^ ' add\n' #print '

\n' #print '
\n' #print '

\n' #print ' ' ^ DisplayName ^'\n' #print '

\n' #print '
\n' #print '

\n' #print ' '' #if pxwidth<>'0' #print ' echo (\"\");\n' #end #if default='' #print ' echo (\"\");\n' #set default='' #end #if default<>'' and string_find default '$'<0 #print ' echo (\"\");\n' #end #if LookupDisplayField='' #print ' $sql->QueryTry(\"' ^ LookupTable ^ '\");\n' #else #print ' $sql->Query(\"SELECT ' #print queryvars '' LookupDisplayField '0' 1 ^ ', `' ^ LookupTable ^ '`.' ^ LookupIDField #print ' FROM `' ^ LookupTable ^'` ' #set wcheck='' #query select Checks as wcheck from `tables` where databaseID=?dbase_id? and TableName=?LookupTable? #if wcheck<>'' #print ' \n WHERE ' ^ fieldreplace wcheck '0' ^ '\n' #end #print ' ORDER BY ' ^ OrderByField ^ ' ASC\");\n' #end #print ' for ($i = 0; $i < $sql->rows; $i++)\n' #print ' {\n' #print ' $sql->Fetch($i);\n' #print ' $opzoekID = $sql->data[' ^ LookupIDField ^ '];\n' #if LookupDisplayField='' #print ' $opzoekweergave = $opzoekID;\n' #else #set expr=fieldreplace LookupDisplayField '0' #print getvars #print ' $opzoekweergave = \"' ^ expr ^ '\";\n' #end #print ' echo (\"\\n\";\n' #end #end #print ' echo (\"\");\n' #end #if Type='int' or Type='data' or Type='varchar' #if default='' #print ' $strdefault = $_POST[\'' ^ FieldName ^ '\'];\n' #print ' echo \"\";\n' #else #print ' $strdefault = ' ^default^ ';\n' #print ' if ($current) {$strdefault = $_POST[\'' ^ FieldName ^ '\'];}\n' #print ' echo \"\";\n' #end #end #if Type='text' or Type='mediumtext' or Type='longtext' #print ' $strdefault = $_POST[\'' ^ FieldName ^ '\'];\n' #print ' echo \"\";\n' #end #end #print ' ?>\n' #if Help<>'' #print ' \n\n' #end #print '

\n' #print '
\n' #print '

\n' #set Code='' #query select Code from actions where TableID=?table_id? and Action='add' and Part='complete' #if Code<>'' #print '\\n\"; }\n' #print '?>\n' #else #print '\n' #end #print '\n' #print '

\n' #print '
\n' #record select Code from actions where TableID=?table_id? and Action='add' and Part='footer' #print '\n' #end #print '\n' #print '\n' #end #function postadd_php dbase_id table_id #query select DatabaseName from `database` where DatabaseID=?dbase_id? #query select TableName, TableID, Checks, Session, Subject, IDfield, Include, ListOrderByField from `tables` where TableID=?table_id? #set orderfield='0' #query select `FieldID` as orderfield, FieldName as ordername from `fields` where `TableID`=?table_id? and `Type`='ordering' #print page_header 'postadd' dbase_id table_id #print 'Create(\"' ^ DatabaseName ^ '\");\n' # remove return form : better implementation needed with no $_POST inside input html code # print 'echo \"
\\n\";\n' # print 'echo \"\\n\";\n' # record select `Add`, FieldName, `Type`, DisplayName, DisplayLength, SessionVar, areaheight, areawidth, LookupTable, OrderByField, LookupIDField, LookupDisplayField from `fields` where TableID=?table_id? order by `order` # if Add='true' # print 'echo \"\\n\";\n' # end # end # print 'echo \"
\\n\";\n' #record select `Add`, Name, FieldName, `Type`, DisplayName, `default`, DisplayLength, SessionVar, areaheight, areawidth, LookupTable, OrderByField, LookupIDField, LookupDisplayField from `fields` where TableID=?table_id? and SessionVar='' and FieldName<>'' and FieldName<>?IDfield? order by `order` #print '$' ^ FieldName ^ '=quote($_POST[\'' ^ FieldName ^ '\']);\n' #if LookupTable<>'' and FieldName='' #if default<>'' #print 'if ($' ^ Name ^ '<>\'\\\'' ^ default ^ '\\\'\') {\n' #end #print '$sql->Query(\"SELECT ' #print queryvars 'T' LookupDisplayField '0' 1 ^ ', T.' ^ LookupIDField #print ' FROM `' ^ LookupTable ^'` as T \n' #set wcheck='' #query select Checks as wcheck from `tables` where databaseID=?dbase_id? and TableName=?LookupTable? #if wcheck<>'' #print 'WHERE ' ^ fieldreplace wcheck '0' ^ '\n' #end #print 'and `' ^ LookupIDField ^ '`=$' ^ Name #print '\");\n' #print 'if ($sql->rows==0) { die (\"No related record field: ' ^ Name ^ ' value: $' ^ Name ^ '\"); }\n' #if default<>'' #print '}\n' #end #end #end #if orderfield<>'0' #set where='1' #record select FieldName, SessionVar from `fields` where TableID=?table_id? and SessionVar<>'' and FieldName<>?IDfield? and FieldName<>'' order by `order` #if where='1' #set where='' #else #set where=where ^ ' AND ' #end #set where=where ^'`' ^ TableName ^ '`.`' ^ FieldName ^ '`=\'$' ^ SessionVar ^ '\'' #end #print 'if ($' ^ ordername ^ '<>\'\') {\n' #print ' $sql->Query(\"UPDATE `' ^ TableName ^ '` SET `' ^ ordername ^ '`=`' ^ ordername ^ '`+1 WHERE `' ^ ordername ^ '`>=$' ^ordername ^' AND ' ^ where ^'\");\n' #print '} else {\n' #print ' $sql->QueryItem(\"SELECT `' ^ ordername ^ '`+1 as next FROM `' ^ TableName ^ '` WHERE ' ^ where ^ ' ORDER BY `' ^ ordername ^ '` DESC LIMIT 1\");\n' #print ' if (!$sql->data[next]) {\n' #print ' $' ^ ordername ^'=1;\n' #print ' } else {\n' #print ' $' ^ ordername ^ '=$sql->data[next];\n' #print ' }\n' #print '}\n' #end #print '$sql->Insert(\"INSERT INTO `' ^ TableName ^ '`\n' #print ' (\n' #set first=true #record select `Add`, FieldName, `Type`, DisplayName, DisplayLength, areaheight, areawidth, LookupTable, OrderByField, LookupIDField, LookupDisplayField, SessionVar from `fields` where TableID=?table_id? and FieldName<>'' and FieldName<>?IDfield? order by `order` #if first #set first=false #else #print ',\n' #end #print ' `' ^ FieldName ^ '`' #end #print '\n )\n' #print ' VALUES (\n' #set first=true #record select `Add`, FieldName, `Type`, DisplayName, DisplayLength, areaheight, areawidth, LookupTable, OrderByField, LookupIDField, LookupDisplayField, SessionVar from `fields` where TableID=?table_id? and FieldName<>'' and FieldName<>?IDfield? order by `order` #if first #set first=false #else #print ',\n' #end #if SessionVar<>'' #print ' \'$' ^ SessionVar ^'\'' #else #print ' $' ^ FieldName #end #end #print '\n )\");\n' #print '$affected_rows = $sql->a_rows;\n' #record select Code from actions where TableID=?table_id? and Action='add' and Part='onchange' #print 'if ($affected_rows>0) {\n' ^ Code ^ '\n}\n' #end #print 'echo \"

\";\n' #print 'echo \"Er is/zijn $affected_rows records toegevoegd
\";\n' #record select `Add`, FieldName, `Type`, DisplayName, DisplayLength, areaheight, areawidth, LookupTable, OrderByField, LookupIDField, LookupDisplayField from `fields` where TableID=?table_id? order by `order` #if Add='true' #print 'echo \"$' ^ FieldName ^ '
\";\n' #end #end #print 'echo \"

\";\n' #print 'if ($affected_rows>0) {\n' #print ' echo \"\";\n' #print ' echo \"\";\n' #print '}\n' #record select `Add`, FieldName, `Type`, DisplayName, DisplayLength, areaheight, areawidth, LookupTable, OrderByField, LookupIDField, LookupDisplayField, SessionVar from `fields` where TableID=?table_id? and FieldName<>'' and FieldName<>?IDfield? and FieldName=?ListOrderByField? #if SessionVar<>'' #print '$_SESSION[\'last_'^TableID^'\']=\'$' ^ SessionVar ^'\';\n' #else #print '$_SESSION[\'last_'^TableID^'\']=$' ^ FieldName ^ ';\n' #end #end #print ';\n' #print '?>\n' #print '\n' #end