<% local form, viewlibrary, page_info, session = ... %> <% htmlviewfunctions = require("htmlviewfunctions") %> <% html = require("acf.html") %> <% local redir = cfe({ type="hidden", value=page_info.orig_action.."?table="..html.url_encode(form.value.table.value) }) local keyvalues = {table=form.value.table.value} if form.value.connection then keyvalues.connection = {} for n,v in pairs(form.value.connection.value) do redir.value = redir.value.."&connection."..n.."="..html.url_encode(v.value) keyvalues.connection[n] = v.value end end keyvalues.redir = redir.value %> <% htmlviewfunctions.displaycommandresults({"deletetableentry", "updatetableentry"}, session) %> <% htmlviewfunctions.displaycommandresults({"createtableentry"}, session, true) %> <% if form.value.table.value ~= "" then form.label = form.label.." - "..form.value.table.value end %> <% local header_level = htmlviewfunctions.displaysectionstart(form, page_info) %> <% local header_level2 = htmlviewfunctions.incrementheader(header_level) htmlviewfunctions.displayformstart(form, page_info) if form.value.connection and next(form.value.connection.value) ~= nil then htmlviewfunctions.displayitem(form.value.connection, page_info, header_level2, "connection") end htmlviewfunctions.displayitem(form.value.table, page_info, header_level2, "table") form.option = "Update" htmlviewfunctions.displayformend(form, htmlviewfunctions.incrementheader(header_level)) %> <% if viewlibrary.check_permission("deletetableentry") or viewlibrary.check_permission("updatetableentry") then %> <% end %> <% for i,f in ipairs(form.value.fields.value) do %> <% end %> <% -- We will reuse the form connection structure to pass key values to updatetableentry and deletetableentry local formvalues = {} if form.value.connection then formvalues.connection = form.value.connection for n,v in pairs(form.value.connection.value) do v.type="hidden" end end local reversekeyfields = {} if form.value.keyfields then formvalues.fields = cfe({ type="group", value={} }) formvalues.nulls = cfe({ type="group", value={} }) for i,f in ipairs(form.value.keyfields.value) do formvalues.fields.value[f] = cfe({ type="hidden" }) formvalues.nulls.value[f] = cfe({ type="hidden", value="false" }) reversekeyfields[f] = i end end formvalues.table = form.value.table form.value.table.type = "hidden" formvalues.redir = redir -- We will hide the update link if all fields are key fields local allowupdate = false for i,f in ipairs(form.value.fields.value) do if not reversekeyfields[f] then allowupdate = true break end end allowupdate = allowupdate and viewlibrary.check_permission("updatetableentry") %> <% for i,tableentry in ipairs(form.value.entries.value) do %> <% if viewlibrary.check_permission("deletetableentry") or allowupdate then %> <% if formvalues.fields then for i,f in ipairs(form.value.keyfields.value) do if not tableentry[f] then formvalues.nulls.value[f].value = "true" else formvalues.fields.value[f].value = tableentry[f] end end end %> <% end %> <% for i,f in ipairs(form.value.fields.value) do %> <% end %> <% end %>
Action<%= html.html_escape(f) %>
<% if allowupdate then %> <% htmlviewfunctions.displayitem(cfe({type="link", value=formvalues, label="", option="Update", action="updatetableentry"}), page_info, -1) %> <% end %> <% if viewlibrary.check_permission("deletetableentry") then %> <% htmlviewfunctions.displayitem(cfe({type="form", value=formvalues, label="", option="Delete", action="deletetableentry", class="deletetableentry"}), page_info, -1) %> <% end %> <% if not tableentry[f] then %> NULL <% else %> <%= html.html_escape(tableentry[f]) %> <% end %>
<% htmlviewfunctions.displayinfo(form) %> <% if #form.value.entries.value == 0 then %>

No entries found

<% end %> <% htmlviewfunctions.displaysectionend(header_level) %> <% if page_info.action == "viewtable" and viewlibrary and viewlibrary.dispatch_component and viewlibrary.check_permission("createtableentry") then viewlibrary.dispatch_component("createtableentry", keyvalues) end %>