/
agent.cfm
469 lines (462 loc) · 13.4 KB
/
agent.cfm
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
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
<cfinclude template = "/includes/_header.cfm">
<script src="/includes/sorttable.js"></script>
<cfoutput>
<cfset title = "Agent Activity">
<cfparam name="agent_name" default="">
<form name="f" method="post" action="agent.cfm">
<label for="agent_name">Agent Name</label>
<input type="text" value="#agent_name#" name="agent_name" id="agent_name">
<br><input type="submit" value="search">
</form>
<!---- if we don't have a name or an ID, abort ---->
<!--- if we DO NOT have an ID and we DO have a name, search ---->
<cfif (not isdefined("agent_id") or len(agent_id) is 0) and len(agent_name) gt 0>
<cfquery name="srch" datasource="uam_god" cachedwithin="#createtimespan(0,0,60,0)#">
select
agent.agent_id,
agent.preferred_agent_name,
agent_type
from
agent,
agent_name
where
agent.agent_id=agent_name.agent_id (+) and
(
upper(agent.preferred_agent_name) like '%#trim(ucase(escapeQuotes(agent_name)))#%' or
upper(agent_name.agent_name) like '%#trim(ucase(escapeQuotes(agent_name)))#%'
)
group by
agent.agent_id,
agent.preferred_agent_name,
agent_type
order by
agent.preferred_agent_name
</cfquery>
<cfif srch.recordcount is 0>
<p>
Nothing found.<cfabort>
</p>
<cfelseif srch.recordcount is 1>
<cflocation url="agent.cfm?agent_id=#srch.agent_id#&agent_name=#srch.preferred_agent_name#" addtoken="false">
<cfelse>
<cfset title = "Agent Activity: Search Results">
<p>
#srch.recordcount# matches found:
<ul>
<cfloop query="srch">
<li>
<a href="agent.cfm?agent_id=#srch.agent_id#&agent_name=#srch.preferred_agent_name#">
#srch.preferred_agent_name#
</a> (#srch.agent_type#)
</li>
</cfloop>
</ul>
</p>
</cfif>
</cfif>
<!--- If we DO have an ID, show the agent info ---->
<cfif isdefined("agent_id") and len(agent_id) gt 0>
<div align="center">
<div class="ui-state-highlight ui-corner-all" style="display:inline-block;margin:1em;padding:1em;">
Your login may prevent access to some linked data. The summary data below are accurate, except
agent-related encumbrances exclude records.
<cfif session.roles contains "manage_agent">
<div align="left">
<br><a href="/info/agentActivity.cfm?agent_id=#agent_id#">Agent Activity</a>
<br><a href="/agents.cfm?agent_id=#agent_id#">Edit Agent</a>
</div>
</cfif>
</div>
</div>
<cfquery name="agent" datasource="uam_god" cachedwithin="#createtimespan(0,0,60,0)#">
select
agent.preferred_agent_name,
agent.agent_type,
agent.agent_remarks,
agent_name.agent_name,
agent_name.agent_name_type
FROM
agent,
agent_name
where
agent.agent_id=agent_name.agent_id (+) and
agent.agent_id=#val(agent_id)#
order by agent_name
</cfquery>
<cfset title = "#agent.preferred_agent_name# - Agent Activity">
<!--- control what names are released, order what's left --->
<cfset names=structNew()>
<!---
list of name types that we want to display here in order
EXCLUDE:
login (nobody cares),
preferred (we've already got one)
---->
<cfset ordnames=queryNew("name,nametype")>
<cfset ant='first name,middle name,last name,full,Kew abbr.,maiden,married,initials plus last,last plus initials,last name first'>
<cfset ant=ant&',abbreviation,aka,alternate spelling,initials,labels,job title'>
<cfset q=1>
<cfloop list="#ant#" index="i">
<cfquery name="p" dbtype="query">
select agent_name from agent where agent_name_type='#i#' order by agent_name
</cfquery>
<cfloop query="p">
<cfset queryaddrow(ordnames,1)>
<cfset querysetcell(ordnames,"name",agent_name,q)>
<cfset querysetcell(ordnames,"nametype",i,q)>
<cfset q=q+1>
</cfloop>
</cfloop>
<p>
Agent Summary for <strong>#agent.preferred_agent_name# (#agent.agent_type#)</strong>
</p>
<cfif ordnames.recordcount gt 0>
<p>
Agent Names:
<ul>
<cfloop query="ordnames">
<li>
#name# (#nametype#) <a href="agent.cfm?agent_name=#name#" class="infoLink"> [ search ]</a>
</li>
</cfloop>
</ul>
</p>
</cfif>
<cfif len(agent.agent_remarks) gt 0>
<p>
Agent Remarks:
<blockquote>
#agent.agent_remarks#
</blockquote>
</p>
</cfif>
<cfif agent.agent_type is "group">
<cfquery name="grpagnt" datasource="uam_god" cachedwithin="#createtimespan(0,0,60,0)#">
select MEMBER_AGENT_ID,getPreferredAgentName(MEMBER_AGENT_ID) name from group_member where GROUP_AGENT_ID=#val(agent_id)#
</cfquery>
<p>
Group Members:
<ul>
<cfloop query="grpagnt">
<li><a href="/agent.cfm?agent_id=#MEMBER_AGENT_ID#">#name#</a></li>
</cfloop>
</ul>
</p>
</cfif>
<cfquery name="agent_relations" datasource="uam_god" cachedwithin="#createtimespan(0,0,60,0)#">
select
AGENT_RELATIONSHIP,agent_name,RELATED_AGENT_ID
from agent_relations,preferred_agent_name
where
agent_relations.RELATED_AGENT_ID=preferred_agent_name.agent_id and
agent_relations.agent_id=#val(agent_id)#
</cfquery>
<cfif agent_relations.recordcount gt 0>
<p>
Relationships FROM #agent.preferred_agent_name#:
<ul>
<cfloop query="agent_relations">
<li>#AGENT_RELATIONSHIP# <a href="agent.cfm?agent_id=#RELATED_AGENT_ID#">#agent_name#</a></li>
</cfloop>
</ul>
</p>
</cfif>
<cfquery name="agent_relationsto" datasource="uam_god" cachedwithin="#createtimespan(0,0,60,0)#">
select AGENT_RELATIONSHIP,agent_name,preferred_agent_name.agent_id
from agent_relations,preferred_agent_name
where
agent_relations.agent_id=preferred_agent_name.agent_id and
RELATED_AGENT_ID=#val(agent_id)#
</cfquery>
<cfif agent_relationsto.recordcount gt 0>
<p>
Relationships TO #agent.preferred_agent_name#:
<ul>
<cfloop query="agent_relationsto">
<li><a href="agent.cfm?agent_id=#agent_id#">#agent_name#</a> is #AGENT_RELATIONSHIP#</li>
</cfloop>
</ul>
</p>
</cfif>
<cfquery name="group_member" datasource="uam_god" cachedwithin="#createtimespan(0,0,60,0)#">
select
agent_name,
GROUP_AGENT_ID
from
group_member, preferred_agent_name
where
group_member.GROUP_AGENT_ID=preferred_agent_name.agent_id and
MEMBER_AGENT_ID=#val(agent_id)#
order by agent_name
</cfquery>
<cfif group_member.recordcount gt 0>
<p>
Groups:
<ul>
<cfloop query="group_member">
<li><a href="agent.cfm?agent_id=#GROUP_AGENT_ID#">#agent_name#</a></li>
</cfloop>
</ul>
</p>
</cfif>
<!--- this is a public page; don't share internal address info --->
<cfquery name="address" datasource="uam_god" cachedwithin="#createtimespan(0,0,60,0)#">
select
ADDRESS_TYPE,
address
from
address
where
address.address_type in ('url','ORCID','Wikidata') and
address.agent_id=#val(agent_id)#
order by
address
</cfquery>
<cfif len(address.address) gt 0>
<p>
Address
<ul>
<cfloop query="address">
<li>
#ADDRESS_TYPE#:
<cfif ADDRESS_TYPE is "url" or ADDRESS_TYPE is "ORCID" or ADDRESS_TYPE is "Wikidata">
<a href="#ADDRESS#" class="external" target="_blank">#ADDRESS#</a>
<cfelse>
#ADDRESS#
</cfif>
</li>
</cfloop>
</ul>
</p>
</cfif>
<cfquery name="collector" datasource="uam_god" cachedwithin="#createtimespan(0,0,60,0)#">
select
count(distinct(collector.collection_object_id)) cnt,
collection.guid_prefix,
collection.collection_id,
collector.collector_role
from
collector,
cataloged_item,
collection
where
collector.collection_object_id = cataloged_item.collection_object_id AND
cataloged_item.collection_id = collection.collection_id AND
agent_id=#val(agent_id)# and
cataloged_item.collection_object_id not in (
select coll_object_encumbrance.collection_object_id from
coll_object_encumbrance,
encumbrance where
encumbrance.EXPIRATION_DATE > sysdate and
coll_object_encumbrance.encumbrance_id=encumbrance.encumbrance_id and
encumbrance.encumbrance_action in ('mask collector','mask preparator','mask record')
)
group by
collection.guid_prefix,
collection.collection_id,
collector.collector_role
</cfquery>
<cfquery name="ssc" dbtype="query">
select sum(cnt) sc from collector
</cfquery>
<cfquery name="cnorole" dbtype="query">
select
sum(cnt) cnt,
guid_prefix,
collection_id
from
collector
where
guid_prefix is not null
group by
guid_prefix,
collection_id
order by
guid_prefix,
collection_id
</cfquery>
<cfquery name="cnorolenc" dbtype="query">
select
sum(cnt) cnt,
collector_role
from
collector
where
guid_prefix is not null
group by
collector_role
order by
collector_role
</cfquery>
<cfif cnorole.recordcount gt 0>
Collector [<span class="infoLink" onclick="getCtDoc('ctcollector_role');">Define</span>]
<table border id="t" class="sortable">
<tr>
<th>Role</th>
<th>Collection</th>
<th>SpecimenCount</th>
<th>Link</th>
</tr>
<tr>
<td>(any)</td>
<td>(all)</td>
<td>#ssc.sc#</td>
<td><a href="/SpecimenResults.cfm?collector_agent_id=#agent_id#">Open Specimen Results</a></td>
</tr>
<CFLOOP query="cnorolenc">
<tr>
<td>#cnorolenc.collector_role#</td>
<td>(all)</td>
<td>#cnorolenc.cnt#</td>
<td>
<a href="/SpecimenResults.cfm?collector_agent_id=#agent_id#&coll_role=#cnorolenc.collector_role#">
Open Specimen Results
</a>
</td>
</tr>
</CFLOOP>
<CFLOOP query="cnorole">
<tr>
<td>(any)</td>
<td>#cnorole.guid_prefix#</td>
<td>#cnorole.cnt#</td>
<td>
<a href="/SpecimenResults.cfm?collector_agent_id=#agent_id#&collection_id=#cnorole.collection_id#">
Open Specimen Results
</a>
</td>
</tr>
<cfquery name="crole" dbtype="query">
select collector_role,cnt from collector where collection_id=#collection_id#
</cfquery>
<cfloop query="crole">
<tr>
<td>#crole.collector_role#</td>
<td>#cnorole.guid_prefix#</td>
<td>#crole.cnt#</td>
<td>
<a href="/SpecimenResults.cfm?collector_agent_id=#agent_id#&collection_id=#cnorole.collection_id#&coll_role=#crole.collector_role#">
Open Specimen Results
</a>
</td>
</tr>
</cfloop>
</CFLOOP>
</table>
</cfif>
<cfquery name="collectormedia" datasource="uam_god" cachedwithin="#createtimespan(0,0,60,0)#">
select count(*) c
from
collector,
media_relations
where
collector.collection_object_id = media_relations.related_primary_key AND
media_relations.media_relationship='shows cataloged_item' AND
collector.agent_id=#val(agent_id)#
</cfquery>
<cfif collectormedia.c gt 0>
<p>
Media:
<ul>
<li>
<a href="/MediaSearch.cfm?action=search&collected_by_agent_id=#agent_id#">
#collectormedia.c# Media records referencing collected/prepared specimens
</a>
</li>
</ul>
</p>
</cfif>
<cfquery name="createdmedia" datasource="uam_god" cachedwithin="#createtimespan(0,0,60,0)#">
select count(*) c
from
media_relations
where
media_relations.media_relationship='created by agent' AND
media_relations.related_primary_key=#val(agent_id)#
</cfquery>
<cfif createdmedia.c gt 0>
<p>
Create Media:
<ul>
<li>
<a href="/MediaSearch.cfm?action=search&created_by_agent_id=#agent_id#">
#createdmedia.c# Media records created
</a>
</li>
</ul>
</p>
</cfif>
<cfquery name="project_agent" datasource="uam_god" cachedwithin="#createtimespan(0,0,60,0)#">
select
project_name,
project.project_id
from
project_agent,
project
where
project.project_id=project_agent.project_id and
project_agent.agent_id=#val(agent_id)#
group by
project_name,
project.project_id
</cfquery>
<cfif len(project_agent.project_name) gt 0>
<p>
Projects
<ul>
<cfloop query="project_agent">
<li><a href="/project/#project_id#">#project_name#</a></li>
</cfloop>
</ul>
</p>
</cfif>
<cfquery name="publication_agent" datasource="uam_god" cachedwithin="#createtimespan(0,0,60,0)#">
select
publication.PUBLICATION_ID,
full_citation,
doi
from
publication,
publication_agent
where
publication.publication_id=publication_agent.publication_id and
publication_agent.agent_id=#val(agent_id)#
group by
publication.PUBLICATION_ID,
full_citation,
doi
order by
full_citation
</cfquery>
<cfif len(publication_agent.full_citation) gt 0>
<p>
Publications
<ul>
<cfloop query="publication_agent">
<li>
<a href="/publication/#PUBLICATION_ID#">#full_citation#</a>
<cfquery name="citn" datasource="uam_god">
select count(*) c from citation where publication_id=#publication_id#
</cfquery>
<ul>
<li>
<cfif citn.c gt 0>
<a href="/SpecimenResults.cfm?publication_id=#publication_id#">#citn.c# citations</a>
<cfelse>
No citations
</cfif>
</li>
<cfif len(doi) gt 0>
<li>
<a href="https://doi.org/#doi#" target="_blank" class="external">#doi#</a>
</li>
</cfif>
</ul>
</li>
</cfloop>
</ul>
</p>
</cfif>
</cfif>
</cfoutput>
<cfinclude template = "/includes/_footer.cfm">