Menu

[r3]: / src / screens / add.cs  Maximize  Restore  History

Download this file

297 lines (288 with data), 13.8 kB

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
#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 '<?php\n'
#record select Code from actions where TableID=?table_id? and Action='add' and Part='session'
#print Code ^ '\n'
#end
#print '$sql = new MySQL_class;\n'
#print '$sql->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 '<HTML>\n'
#print '<HEAD>\n'
#print ' <META HTTP-EQUIV=\"CONTENT-TYPE\" CONTENT=\"text/html; charset=windows-1252\">\n'
#print ' <TITLE>' ^ Title ^ ' add</TITLE>\n'
#print '</HEAD>\n'
#print '<BODY LANG=\"en-US\" DIR=\"LTR\">\n'
#record select Code from actions where TableID=?table_id? and Action='add' and Part='header'
#print Code ^ '\n'
#end
#print '<FORM NAME=\"Insert\" ACTION=\"postadd' ^ Subject ^ '.php\" METHOD=POST>\n'
#print '<TABLE WIDTH=100% BORDER=0 CELLPADDING=4 CELLSPACING=1>\n'
#print ' <THEAD>\n'
#print ' <TR>\n'
#print ' <TD COLSPAN=2 WIDTH=100% VALIGN=TOP BGCOLOR=\"#000080\">\n'
#print ' <P><FONT COLOR=\"#ffffff\"><FONT FACE=\"Verdana, sans-serif\"><FONT SIZE=1 STYLE=\"font-size: 8pt\">'
#print '<B>' ^ Title ^ ' add\n'
#print ' </B></FONT></FONT></FONT></P>\n'
#print ' </TD>\n'
#print ' </TR>\n'
#print ' </THEAD>\n'
#print ' <TBODY>\n'
#if orderfield<>'0'
#print ' <INPUT TYPE=HIDDEN NAME=\"' ^ ordername ^ '\" VALUE=\"<?php echo $_GET[' ^ ordername ^']; ?>\">\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 ' <INPUT TYPE=HIDDEN NAME=\"' ^ SessionVar ^ '\" VALUE=\"<?php echo $' ^ SessionVar ^ '; ?>\">\n'
#end
#print ' <TR VALIGN=TOP>\n'
#print ' <TD WIDTH=20% BGCOLOR=\"#e6e6ff\">\n'
#print ' <P><FONT COLOR=\"#000080\"><FONT FACE=\"Verdana, sans-serif\"><FONT SIZE=1 STYLE=\"font-size: 8pt\">\n'
#print ' ' ^ DisplayName ^'\n'
#print ' </FONT></FONT></FONT></P>\n'
#print ' </TD>\n'
#print ' <TD WIDTH=80%>\n'
#print ' <P><FONT COLOR=\"#000080\"><FONT FACE=\"Verdana, sans-serif\"><FONT SIZE=1 STYLE=\"font-size: 8pt\">\n'
#print ' <?php\n'
#print ' $current=($_POST[\'' ^ FieldName ^ '\']!=\'\');\n'
#if LookupTable<>''
#if pxwidth<>'0'
#print ' echo (\"<SELECT NAME=\\\"' ^ FieldName ^ '\\\" STYLE=\\\"width: ' ^ pxwidth ^ 'px\\\" OnChange=\\\"Insert.action=\'\'; Insert.submit();\\\">\");\n'
#else
#print ' echo (\"<SELECT NAME=\\\"' ^ FieldName ^ '\\\" OnChange=\\\"Insert.action=\'\'; Insert.submit();\\\">\");\n'
#end
#if default='<empty>'
#print ' echo (\"<OPTION VALUE=\\\"\\\"></OPTION>\");\n'
#set default=''
#end
#if default<>'' and string_find default '$'<0
#print ' echo (\"<OPTION VALUE=\\\"' ^default^ '\\\">' ^ default ^ '</OPTION>\");\n'
#end
#if LookupDisplayField=''
#print ' $sql->QueryTry(\"' ^ LookupTable ^ '\");\n'
#else
#print ' $sql->Query(\"SELECT '
#print queryvars 'T' LookupDisplayField '0' 1 ^ ', T.' ^ LookupIDField
#print ' FROM `' ^ LookupTable ^'` as T'
#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 (\"<OPTION \");\n'
#if default<>''
#print ' if (!$current && $opzoekID == \"' ^ default ^ '\") {echo \"SELECTED \";};\n'
#end
#print ' if ($current && $opzoekID == $_POST[\'' ^ FieldName ^ '\']) {echo \"SELECTED \";};\n'
#print ' echo \"VALUE=\\\"$opzoekID\\\">$opzoekweergave\";\n'
#print ' }\n'
#print ' echo (\"</SELECT>\");\n'
#else
#if Type='enum'
#if pxwidth <>'0'
#print ' echo (\"<SELECT NAME=\\\"' ^ FieldName ^ '\\\" STYLE=\\\"width: ' ^ pxwidth ^ 'px\\\" OnChange=\\\"Insert.action=\'\'; Insert.submit();\\\">\");\n'
#else
#print ' echo (\"<SELECT NAME=\\\"' ^ FieldName ^ '\\\" OnChange=\\\"Insert.action=\'\'; Insert.submit();\\\">\");\n'
#end
#set val=enum data_connection TableName FieldName
#split res=val on ,
#match res with '\(.*\)' into res
#print ' if (\''^res^'\' == $_POST[\'' ^ FieldName ^'\']) {$sel=\'SELECTED \';} else {$sel=\'\';};\n'
#print ' echo \"<OPTION VALUE=\\\"' ^ res ^ '\\\"$sel>' ^ res ^ '</OPTION>\\n\";\n'
#end
#end
#print ' echo (\"</SELECT></FONT></FONT>\");\n'
#end
#if Type='int' or Type='data' or Type='varchar'
#if default=''
#print ' $strdefault = $_POST[\'' ^ FieldName ^ '\'];\n'
#print ' echo \"<INPUT TYPE=TEXT NAME=\\\"' ^ FieldName ^ '\\\" SIZE=' ^ listwidth ^ ' VALUE=\\\"$strdefault\\\">\";\n'
#else
#print ' $strdefault = ' ^default^ ';\n'
#print ' if ($current) {$strdefault = $_POST[\'' ^ FieldName ^ '\'];}\n'
#print ' echo \"<INPUT TYPE=TEXT NAME=\\\"' ^ FieldName ^ '\\\" SIZE=' ^ listwidth ^ ' VALUE=\\\"$strdefault\\\">\";\n'
#end
#end
#if Type='text' or Type='mediumtext' or Type='longtext'
#print ' $strdefault = $_POST[\'' ^ FieldName ^ '\'];\n'
#print ' echo \"<TEXTAREA NAME=\\\"' ^ FieldName ^ '\\\" ROWS=' ^ areaheight ^' COLS=' ^ listwidth ^ '>$strdefault</TEXTAREA>\";\n'
#end
#end
#print ' ?>\n'
#if Help<>''
#print ' <INPUT TYPE=BUTTON VALUE=\"Help\" onClick=\"javascript: window.open(\'vraagbaak.php?zoekitem=' ^ Help ^ '\',\'Help\',\'width=300,height=500,location=no,menubar=no,scrollbars=yes,status=no,resizable=yes\'); return false;\">\n\n'
#end
#print ' </FONT></FONT></FONT></P>\n'
#print ' </TD>\n'
#print ' </TR>\n'
#end
#print ' </TBODY>\n'
#print '</TABLE>\n'
#print '<P ALIGN=RIGHT>\n'
#set Code=''
#query select Code from actions where TableID=?table_id? and Action='add' and Part='complete'
#if Code<>''
#print '<?php\n'
#print 'if ('^ Code ^') { echo \"<INPUT TYPE=submit VALUE=Add>\\n\"; }\n'
#print '?>\n'
#else
#print '<INPUT TYPE=submit VALUE=Add>\n'
#end
#print '<INPUT TYPE=BUTTON VALUE=\"Cancel\" onClick=\"window.close()\">\n'
#print '</P>\n'
#print '</FORM>\n'
#record select Code from actions where TableID=?table_id? and Action='add' and Part='footer'
#print '<?php\n' ^ Code ^ '\n?>\n'
#end
#print '</BODY>\n'
#print '</HTML>\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 '<?php\n'
#print '$sql = new MySQL_class;\n'
#print '$sql->Create(\"' ^ DatabaseName ^ '\");\n'
# remove return form : better implementation needed with no $_POST inside input html code
# print 'echo \"<FORM NAME=\\\"Terug\\\" ACTION=\\\"add' ^ Subject ^ '.php\\\" METHOD=POST>\\n\";\n'
# print 'echo \"<INPUT TYPE=button VALUE=\\\"Back\\\" onClick=\\\"Terug.submit()\\\">\\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 \"<INPUT TYPE=hidden NAME=\\\"' ^ FieldName ^ '\\\" VALUE=\\\"$_POST[\'' ^ FieldName ^'\']\\\">\\n\";\n'
# end
# end
# print 'echo \"</FORM>\\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'
#print 'echo \"<P><FONT FACE=\\\"Verdana, sans-serif\\\"><FONT SIZE=1 STYLE=\\\"font-size: 8pt\\\">\";\n'
#print 'echo \"Er is/zijn $affected_rows records toegevoegd<BR>\";\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 ^ '<BR>\";\n'
#end
#end
#print 'echo \"</P>\";\n'
#print 'if ($affected_rows>0) {\n'
#print ' echo \"<script>window.opener.location.reload(true)</script>\";\n'
#print ' echo \"<script>window.close(self)</script>\";\n'
#print '}\n'
#print '$_SESSION[\'last_'^TableID^'\']='
#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 '\'$' ^ SessionVar ^'\';\n'
#else
#print '$' ^ FieldName ^ ';\n'
#end
#end
#print ';\n'
#print '?>\n'
#print '<INPUT TYPE=BUTTON VALUE=\"Close\" onClick=\"window.opener.location.reload(true);self.close()\">\n'
#end
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.