Menu

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

Download this file

325 lines (316 with data), 14.5 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
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
#function add_php project table_id
#query select name as application from `project` where project=?project?
#query select `table`, name as tablename, title as tabletitle, `where`, `sql` as tablesql, id_field from `table` where `table`=?table_id?
#set orderfield='0'
#query select `field` as orderfield, field.sql as ordername from `field` where `table`=?table_id? and `Type`='ordering'
#print page_header 'add' project table_id
#print '<?php\n'
#record select Code from actions where `table`=?table_id? and Action='add' and Part='session'
#print Code ^ '\n'
#end
#record select field, `Add`, name, field.sql as fieldsql, `Type`, title, width, height, link_table, link_field, SessionVar, link_display from `field` where `table`=?table_id? and link_table<>'' and title='' order by `order`
#print '$sql->QueryItem(\"SELECT ' ^ queryvars ('T' ^ field) link_display field 1 ^ ' FROM `' ^ link_table ^ '` as T' ^ field ^ ' WHERE `' ^ link_field ^ '` = $' ^ SessionVar ^ '\");\n'
#set getvars=''
#set expr=fieldreplace link_display field
#print getvars
#print ' $' ^ name ^ '_lup = \"' ^ expr ^ '\";\n'
#end
#set firstfield='none'
#query select name as firstfield from `field` where `table`=?table_id? and Record<>'none' and field.sql<>'' order by `order` limit 1
#print 'if ($_POST[\'' ^ firstfield ^ '\']!=\'\') {\n'
#record select name, field.sql as fieldsql, `Type`, title, width, height, link_table, link_field, link_display from `field` where `table`=?table_id? and Record<>'none' and field.sql<>'' order by `order`
#if Type='varchar' or Type='text' or Type='password'
#print ' $' ^ name ^ ' = ($_POST[\'' ^ name ^ '\']);\n'
#else
#if Type='date'
#print '$' ^ name ^ ' = date(\'j/n/Y\', strtotime($_POST[\'' ^ name ^ '\']));\n'
#else
#print '$' ^ name ^ ' = $_POST[\'' ^ name ^ '\'];\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>' ^ tabletitle ^ ' add</TITLE>\n'
#print '</HEAD>\n'
#print '<BODY LANG=\"en-US\" DIR=\"LTR\" ONLOAD=\"Insert.<?php\n'
#set fid='0'
#set ff=''
#record select field, `Record`, `Edit`, field.sql as fieldsql, name, `Type`, title, SessionVar, height, link_table, link_field, link_display, `default` from `field` where `table`=?table_id? and field.sql<>'' and Record<>'none' and `Edit`<>'false' order by `order`
#if ff=''
#set ff=fieldsql
#end
#if fid>'0'
#print 'if ($_POST[FOCUS]==' ^ fid ^ ') {echo \'' ^ name ^ '\';}\nelse '
#set fid='0'
#end
#if link_table<>'' or Type='enum'
#set fid=field
#end
#end
#print '{echo \'' ^ ff ^ '\';}\n'
#print '?>.focus();\">\n'
#record select Code from actions where `table`=?table_id? and Action='add' and Part='header'
#print Code ^ '\n'
#end
#print '<FORM NAME=\"Insert\" ACTION=\"postadd' ^ tablename ^ '.php\" METHOD=POST>\n'
#print '<INPUT TYPE=\"HIDDEN\" NAME=\"FOCUS\" VALUE=\"\">\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>' ^ tabletitle ^ ' 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 field, `Add`, name, field.sql as fieldsql, `Type`, title, `default`, SessionVar, width as ListWidth, width * 7 as width, height, link_table, link_where, link_field, link_display from `field` where `table`=?table_id? and Record<>'none' and `Add`<>'false' 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 ' ' ^ title ^'\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[\'' ^ name ^ '\']!=\'\');\n'
#if link_table<>''
#if width<>'0'
#print ' echo (\"<SELECT NAME=\\\"' ^ name ^ '\\\" STYLE=\\\"width: ' ^ width ^ 'px\\\" OnChange=\\\"Insert.action=\'\'; Insert.FOCUS.value=\'' ^ field ^ '\'; Insert.submit();\\\">\");\n'
#else
#print ' echo (\"<SELECT NAME=\\\"' ^ name ^ '\\\" OnChange=\\\"Insert.action=\'\'; Insert.FOCUS.value=\'' ^ field ^ '\'; 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 link_display=''
#print ' $sql->QueryTry(\"' ^ link_table ^ '\");\n'
#else
#print '$sql->Query(\"SELECT '
#print queryvars '' link_display '0' 1 ^ ', `' ^ link_table ^ '`.' ^ link_field
#print ' FROM `' ^ link_table ^'`' ^ queryjoin ^ ' '
#set wcheck=''
#query select `where` as wcheck from `table` where project=?project? and name=?link_table?
#if wcheck<>''
#print '\n WHERE ' ^ fieldreplace wcheck '0'
#if link_where<>''
#print ' and ' ^ link_where
#end
#print '\n'
#else
#if link_where<>''
#print ' where ' ^ link_where ^ '\n'
#end
#end
#print ' ' ^ queryorder ^ '\");\n'
#end
#print ' for ($i = 0; $i < $sql->rows; $i++)\n'
#print ' {\n'
#print ' $sql->Fetch($i);\n'
#if link_display=''
#set lfield=''
#match link_field with \([^,]+\),\(.*\) into lfield,dfield
#print ' $searchID = $sql->data[' ^ lfield ^ '];\n'
#print ' $searchshow = $sql->data[' ^ dfield ^ '];\n'
#end
#if lfield=''
#print ' $searchID = $sql->data[' ^ link_field ^ '];\n'
#print ' $searchshow = $searchID;\n'
#end
#else
#print ' $searchID = $sql->data[' ^ link_field ^ '];\n'
#set expr=fieldreplace link_display '0'
#print getvars
#print ' $searchshow = \"' ^ expr ^ '\";\n'
#end
#print ' echo (\"<OPTION \");\n'
#if default<>''
#print ' if (!$current && $searchID == \"' ^ default ^ '\") {echo \"SELECTED \";};\n'
#end
#print ' if ($current && $searchID == $_POST[\'' ^ name ^ '\']) {echo \"SELECTED \";};\n'
#print ' echo \"VALUE=\\\"$searchID\\\">$searchshow\";\n'
#print ' }\n'
#print ' echo (\"</SELECT>\");\n'
#else
#if Type='enum'
#if width <>'0'
#print ' echo (\"<SELECT NAME=\\\"' ^ name ^ '\\\" STYLE=\\\"width: ' ^ width ^ 'px\\\" OnChange=\\\"Insert.action=\'\'; Insert.FOCUS.value=\'' ^ field ^ '\'; Insert.submit();\\\">\");\n'
#else
#print ' echo (\"<SELECT NAME=\\\"' ^ name ^ '\\\" OnChange=\\\"Insert.action=\'\'; Insert.FOCUS.value=\'' ^ field ^ '\'; Insert.submit();\\\">\");\n'
#end
#set val=enum data_connection tablesql fieldsql
#split res=val on ,
#match res with '\(.*\)' into res
#print ' if (\''^res^'\' == $_POST[\'' ^ name ^'\']) {$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' or Type='password'
#if default=''
#print ' $strdefault = $_POST[\'' ^ name ^ '\'];\n'
#print ' echo \"<INPUT TYPE=TEXT NAME=\\\"' ^ name ^ '\\\" SIZE=' ^ ListWidth ^ ' VALUE=\\\"$strdefault\\\">\";\n'
#else
#print ' $strdefault = ' ^default^ ';\n'
#print ' if ($current) {$strdefault = $_POST[\'' ^ name ^ '\'];}\n'
#print ' echo \"<INPUT TYPE=TEXT NAME=\\\"' ^ name ^ '\\\" SIZE=' ^ ListWidth ^ ' VALUE=\\\"$strdefault\\\">\";\n'
#end
#end
#if Type='text' or Type='mediumtext' or Type='longtext'
#print ' $strdefault = $_POST[\'' ^ name ^ '\'];\n'
#print ' echo \"<TEXTAREA NAME=\\\"' ^ name ^ '\\\" ROWS=' ^ height ^' COLS=' ^ ListWidth ^ '>$strdefault</TEXTAREA>\";\n'
#end
#end
#print ' ?>\n'
#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 `table`=?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 `table`=?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 project table_id
#query select name as application from `project` where project=?project?
#query select name as tablesql, `table`, `where`, name as tablename, id_field from `table` where `table`=?table_id?
#set orderfield='0'
#query select `field` as orderfield, field.sql as ordername from `field` where `table`=?table_id? and `Type`='ordering'
#print page_header 'postadd' project table_id
#print '<?php\n'
# remove return form : better implementation needed with no $_POST inside input html code
# print 'echo \"<FORM NAME=\\\"Terug\\\" ACTION=\\\"add' ^ tablename ^ '.php\\\" METHOD=POST>\\n\";\n'
# print 'echo \"<INPUT TYPE=button VALUE=\\\"Back\\\" onClick=\\\"Terug.submit()\\\">\\n\";\n'
# record select `Add`, name, field.sql as fieldsql, `Type`, title, width, SessionVar, height, link_table, OrderByField, link_field, link_display from `field` where `table`=?table_id? order by `order`
# if Add='true'
# print 'echo \"<INPUT TYPE=hidden NAME=\\\"' ^ name ^ '\\\" VALUE=\\\"$_POST[\'' ^ name ^'\']\\\">\\n\";\n'
# end
# end
# print 'echo \"</FORM>\\n\";\n'
#record select `Add`, name, field.sql as fieldsql, `Type`, title, `default`, width, SessionVar, height, link_table, link_field, link_display from `field` where `table`=?table_id? and SessionVar='' and field.sql<>'' and field.sql<>?id_field? order by `order`
#print '$' ^ name ^ '=quote($_POST[\'' ^ name ^ '\']);\n'
#if link_table<>'' and fieldsql=''
#if default<>''
#print 'if ($' ^ name ^ '<>\'\\\'' ^ default ^ '\\\'\') {\n'
#end
#print '$sql->Query(\"SELECT '
#print queryvars 'T' link_display '0' 1 ^ ', T.' ^ link_field
#print ' FROM `' ^ link_table ^'` as T \n'
#set wcheck=''
#query select `where` as wcheck from `table` where project=?project? and name=?link_table?
#if wcheck<>''
#print 'WHERE ' ^ fieldreplace wcheck '0' ^ '\n'
#end
#print 'and `' ^ link_field ^ '`=$' ^ 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 field.sql as fieldsql, SessionVar from `field` where `table`=?table_id? and SessionVar<>'' and field.sql<>?id_field? and field.sql<>'' order by `order`
#if where='1'
#set where=''
#else
#set where=where ^ ' AND '
#end
#set where=where ^'`' ^ tablesql ^ '`.`' ^ fieldsql ^ '`=\'$' ^ SessionVar ^ '\''
#end
#print 'if ($' ^ ordername ^ '<>\'\' && $' ^ ordername ^ '<>\'\\\'\\\'\') {\n'
#print ' $sql->Query(\"UPDATE `' ^ tablesql ^ '` SET `' ^ ordername ^ '`=`' ^ ordername ^ '`+1 WHERE `' ^ ordername ^ '`>=$' ^ordername ^' AND ' ^ where ^'\");\n'
#print '} else {\n'
#print ' $sql->QueryItem(\"SELECT `' ^ ordername ^ '`+1 as next FROM `' ^ tablesql ^ '` 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 `' ^ tablesql ^ '`\n'
#print ' (\n'
#set first=true
#record select `Add`, name, field.sql as fieldsql, `Type`, title, width, height, link_table, link_field, link_display, SessionVar from `field` where field.`table`=?table_id? and field.sql<>'' and field.sql<>?id_field? order by `order`
#if first
#set first=false
#else
#print ',\n'
#end
#print ' `' ^ fieldsql ^ '`'
#end
#print '\n )\n'
#print ' VALUES (\n'
#set first=true
#record select `Add`, name, field.sql as fieldsql, `Type`, title, width, height, link_table, link_field, link_display, SessionVar from `field` where field.`table`=?table_id? and field.sql<>'' and field.sql<>?id_field? order by `order`
#if first
#set first=false
#else
#print ',\n'
#end
#if SessionVar<>''
#print ' \'$' ^ SessionVar ^'\''
#else
#print ' $' ^ name
#end
#end
#print '\n )\");\n'
#print '$affected_rows = $sql->a_rows;\n'
#record select Code from actions where actions.`table`=?table_id? and Action='add' and Part='onchange'
#print 'if ($affected_rows>0) {\n' ^ Code ^ '\n}\n'
#end
#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`, field.sql as fieldsql, name, `Type`, title, width, height, link_table, link_field, link_display from `field` where field.`table`=?table_id? order by `order`
#if Add='true'
#print 'echo \"$' ^ name ^ '<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'
## create last_table field from current table_order
##record select `Add`, name, field.sql as fieldsql, `Type`, title, width, height, link_table, link_field, link_display, SessionVar from `field` where field.`table`=?table_id? and field.sql<>'' and field.sql<>?id_field? and `sql`=?ListOrderByField?
##print '$_SESSION[\'last_'^table^'\']=$' ^ name ^ ';\n'
##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.