db-viewtable-html.lsp 2.63 KB
Newer Older
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
<% local form, viewlibrary, page_info, session = ... %>
<% require("htmlviewfunctions") %>
<% html = require("acf.html") %>

<% htmlviewfunctions.displaycommandresults({"deletetableentry", "updatetableentry"}, session) %>
<% htmlviewfunctions.displaycommandresults({"createtableentry"}, session, true) %>

<H1><%= html.html_escape(form.label) %> - <%= html.html_escape(form.value.table.value) %></H1>
<DL>
<TABLE>
	<TR style="background:#eee;font-weight:bold;">
	<% if viewlibrary.check_permission("deletetableentry") or viewlibrary.check_permission("updatetableentry") then %>
		<TD style="padding-right:20px;white-space:nowrap;" class="header">Action</TD>
	<% end %>
	<% for i,f in ipairs(form.value.fields.value) do %>
		<TD style="padding-right:20px;white-space:nowrap;" class="header"><%= html.html_escape(f) %></TD>
	<% end %>
	</TR>

<% for i,tableentry in ipairs(form.value.entries.value) do %>
	<TR>
	<% if viewlibrary.check_permission("deletetableentry") or viewlibrary.check_permission("updatetableentry") then %>
		<TD style="padding-right:20px;white-space:nowrap;">
	<% if viewlibrary.check_permission("updatetableentry") then %>
		<form action="updatetableentry" method="POST">
                <input class="hidden" type="hidden" name="table" value="<%= html.html_escape(form.value.table.value) %>">
                <input class="hidden" type="hidden" name="id" value="<%= html.html_escape(tableentry.id) %>">
                <input class="hidden" type="hidden" name="redir" value="<%= html.html_escape(page_info.orig_action.."?table="..form.value.table.value) %>">
                <input class="submit" type="submit" value="Update"></form>
	<% end %>
	<% if viewlibrary.check_permission("deletetableentry") then %>
		<form action="deletetableentry" method="POST">
                <input class="hidden" type="hidden" name="table" value="<%= html.html_escape(form.value.table.value) %>">
                <input class="hidden" type="hidden" name="id" value="<%= html.html_escape(tableentry.id) %>">
                <input class="submit" type="submit" name="submit" value="Delete"></form>
	<% end %>
		</TD>
	<% end %>
	<% for i,f in ipairs(form.value.fields.value) do %>
		<TD><%= html.html_escape(tableentry[f]) %></TD>
	<% end %>
	</TR>
<% end %>
</TABLE>
<% if form.errtxt then %>
<p class="error"><%= html.html_escape(form.errtxt) %></p>
<% end %>
<% if #form.value.entries.value == 0 then %>
<p>No entries found</p>
<% end %>
</DL>

<% if page_info.action == "viewtable" and viewlibrary and viewlibrary.dispatch_component and viewlibrary.check_permission("createtableentry") then
	viewlibrary.dispatch_component("createtableentry", {table=form.value.table.value})
end %>