summaryrefslogtreecommitdiffstats
path: root/did-html.lsp
blob: 36445c53adc008f8a1a430ad7c3534625c94a9e0 (plain)
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
<% local data, viewlibrary, page_info, session = ... 
require("htmlviewfunctions")
html = require("acf.html")
%>

<% local subdata = data.value.definitions.value %>
<% local pagedata = data.value.pagedata.value %>

<script type="text/javascript">
function newPopup(url) {
	popupWindow = window.open(
		url,'popUpWindow','width=600,resizable=yes,scrollbars=yes,toolbar=no,menubar=no,location=no,directories=no,status=no')
}
</script>

<% if session.editdefinitionresult then
	session.didresult = session.editdefinitionresult.value
	session.editdefinitionresult = nil
end %>
<% if session.didresult then %>
<H1>Last Result</H1><DL>
<P CLASS="descr"><%= string.gsub(html.html_escape(session.didresult), "\n", "<BR>") %></P>
</DL>
<% end %>

<% htmlviewfunctions.displaycommandresults({"editdefinition", "editdefinitionextension", "deletedefinition", "publish", "publishall", "requestdid"}, session) %>

<% if data.value.did.value ~= "" or (data.value.extension and data.value.extension.value ~= "") or data.value.description.value ~= "" or data.value.identification.value ~= "" or data.value.department.value ~= "" then %>
<H2>Search Description</H2>
<DL>
<% if data.value.did.value ~= "" then %><DT>DID</DT><DD><%= data.value.did.value %></DD><% end %>
<% if (data.value.extension and data.value.extension.value ~= "") then %><DT>Extension</DT><DD><%= data.value.extension.value %></DD><% end %>
<% if data.value.description.value ~= "" then %><DT>Description</DT><DD><%= data.value.description.value %></DD><% end %>
<% if data.value.identification.value ~= "" then %><DT>Identification</DT><DD><%= data.value.identification.value %></DD><% end %>
<% if data.value.department.value ~= "" then %><DT>Department</DT><DD><%= data.value.department.value %></DD><% end %>
</DL>
<% end %>

<% -- let's create a redirection string
local redirectstring = {}
for i,name in ipairs({"page", "did", "extension", "description", "identification", "department"}) do
	if page_info.clientdata[name] and page_info.clientdata[name] ~= "" then
		redirectstring[#redirectstring+1] = name.."="..page_info.clientdata[name]
	end
end
if #redirectstring > 0 then
	redirectstring = page_info.orig_action.."?"..table.concat(redirectstring, "&")
else
	redirectstring = page_info.orig_action
end
%>

<H1><%= html.html_escape(data.label) %></H1>
<DL>
<% htmlviewfunctions.displaypagination(pagedata, page_info) %>
<TABLE>
	<TR style="background:#eee;font-weight:bold;">
		<TD style="padding-right:20px;white-space:nowrap;" class="header">Action</TD>
		<TD style="padding-right:20px;white-space:nowrap;" class="header">DID</TD>
	<% if subdata[1] and subdata[1].extension then %>
		<TD style="padding-right:20px;white-space:nowrap;" class="header">Extensions</TD>
	<% end %>
		<TD style="padding-right:20px;white-space:nowrap;" class="header">ID Number</TD>
		<TD style="padding-right:20px;white-space:nowrap;" class="header">Department</TD>
		<TD style="white-space:nowrap;" WIDTD="90%" class="header">Description</TD>
	</TR>
<% for i,def in ipairs(subdata) do %>
	<TR>
		<TD>
	<% if viewlibrary.check_permission("editdefinition") then %>
		<form action="/cgi-bin/acf/did/did/editdefinition" method="POST">
		<input class="hidden" type="hidden" name="did" value="<%= html.html_escape(def.did) %>">
		<input class="hidden" type="hidden" name="redir" value="<%= html.html_escape(redirectstring) %>">
		<input class="submit" type="submit" name="submit" value="Edit"></form>
	<% elseif viewlibrary.check_permission("editdefinitionextension") then %>
		<form action="/cgi-bin/acf/did/did/editdefinitionextension" method="POST">
		<input class="hidden" type="hidden" name="did" value="<%= html.html_escape(def.did) %>">
		<input class="hidden" type="hidden" name="redir" value="<%= html.html_escape(redirectstring) %>">
		<input class="submit" type="submit" name="submit" value="Edit"></form>
	<% end %>
	<% if viewlibrary.check_permission("publish") then %>
		<%= html.link{value = "publish?did=" .. def.did, label="Publish "} %>
	<% end %>
	<% if viewlibrary.check_permission("deletedefinition") then %>
		<%= html.link{value = "deletedefinition?did=" .. def.did, label="Delete "} %>
	<% end %>
		</TD>
		<TD><%= html.html_escape(def.did) %></TD>
	<% if def.extension then %>
		<TD><%= html.html_escape(def.extension) %></TD>
	<% end %>
		<TD><%= html.html_escape(def.identification) %></TD>
		<TD><%= html.html_escape(def.department) %></TD>
		<TD><%= html.html_escape(def.description) %></TD>
	</TR>
<% end %>
</TABLE>

<% if data.errtxt then %>
<p class='error'><%= html.html_escape(data.errtxt) %></p>
<% end %>
<% if #subdata == 0 then %>
<p>No definitions found</p>
<% end %>

<% if viewlibrary.check_permission("publishall") then %>
<form action="<%= html.html_escape(page_info.script .. page_info.prefix .. page_info.controller .. "/publishall") %>">
<DT>Publish All DIDs</DT>
<DD><input class="submit" type="submit" value="Publish"></DD>
</form>
<% end %>

<% if viewlibrary.check_permission("requestdid") then %>
<form action="<%= html.html_escape(page_info.script .. page_info.prefix .. page_info.controller .. "/requestdid") %>">
<DT>Request a new DID</DT>
<DD><input class="submit" type="submit" value="Request"></DD>
</form>
<% end %>
</DL>