<% local form, viewlibrary, page_info, session = ... %>
<% htmlviewfunctions = require("htmlviewfunctions") %>
<% html = require("acf.html") %>

<% htmlviewfunctions.displaycommandresults({"upgrade", "install"}, session) %>

<H1><%= form.label %></H1>
<DL>
<TABLE>
	<TR style="background:#eee;font-weight:bold;">
	<% if viewlibrary.check_permission("install") or viewlibrary.check_permission("upgrade") then %>
		<TD style="padding-right:20px;white-space:nowrap;" class="header">Action</TD>
	<% end %>
		<TD style="padding-right:20px;white-space:nowrap;" class="header">Package Name</TD>
		<TD style="white-space:nowrap;" WIDTH="90%" class="header">Version</TD>
	</TR>

<% for i,packagetable in pairs(form.value) do %>
	<TR>
	<% if viewlibrary.check_permission("install") or viewlibrary.check_permission("upgrade") then %>
		<TD style="padding-right:20px;white-space:nowrap;">
	<% if viewlibrary.check_permission("install") and not packagetable.upgrade then %>
		<%= html.link{value = "install?submit=true&package=" .. packagetable.name, label="Install "} %>
	<% end %>
	<% if viewlibrary.check_permission("upgrade") and packagetable.upgrade then %>
		<%= html.link{value = "upgrade?submit=true&package=" .. packagetable.name, label="Upgrade "} %>
	<% end %>
		</TD>
	<% end %>
		<TD><%= html.link{value = "details?package="..packagetable.name, label=packagetable.name} %></TD>
		<TD><%= html.html_escape(packagetable.version) %></TD>
	</TR>
<% end %>
</TABLE>
</DL>
