-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patheditIdentifiers.cfm
373 lines (372 loc) · 14.4 KB
/
editIdentifiers.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
<cfinclude template="/includes/alwaysInclude.cfm">
<cfset title = "Edit Identifiers">
<cfif action is "nothing">
<script>
function cloneFullCatalogedItem(collection_object_id){
jQuery('#cloned').css("display", "inline").html('<img src="/images/indicator.gif">Creating clone(s) - hold tight.....');
jQuery.getJSON("/component/functions.cfc",
{
method : "cloneFullCatalogedItem",
collection_object_id : collection_object_id,
returnformat : "json",
queryformat : 'column'
},
function (r) {
var q='created <a target="_blank" href="/guid/' + r + '">' + r + '</a>';
jQuery('#cloned').css("display", "inline").html(q);
}
);
}
function cloneCatalogedItem(collection_object_id){
jQuery('#cloned').css("display", "inline").html('<img src="/images/indicator.gif">Creating clone(s) - hold tight.....');
jQuery.getJSON("/component/functions.cfc",
{
method : "cloneCatalogedItem",
collection_object_id : collection_object_id,
numRecs: $("#numRecs").val(),
refType: $("#refType").val(),
taxon_name: $("#taxon_name").val(),
collection_id: $("#collection_id").val(),
returnformat : "json",
queryformat : 'column'
},
function (r) {
if (r == 'spiffy') {
var q='created ' + $("#numRecs").val() + ' clones in bulkloader.';
} else {
var q='cloning failed.';
}
jQuery('#cloned').css("display", "inline").html(q);
}
);
}
jQuery(document).ready(function() {
$("#formEdit").submit(function(event){
//event.preventDefault();
var i;
for ( i = 1; i <= $("#numberOfIDs").val(); i++ ) {
if ($("#delete_" + i).prop('checked')!==true) {
//console.log('nodelete');
if ($("#other_id_prefix_" + i).val().length===0 && $("#other_id_number_" + i).val().length===0 && $("#other_id_suffix_" + i).val().length===0){
alert('Prefix, Number, and Suffix may not all be NULL. Check the delete box and save to remove an identifier');
$("#trid_" + i).addClass('badPick');
return false;
}
}
}
});
$("#newOID").submit(function(event){
if ($("#other_id_prefix").val().length===0 && $("#other_id_number").val().length===0 && $("#other_id_suffix").val().length===0){
alert('Prefix, Number, and Suffix may not all be NULL.');
$("#trid_new").addClass('badPick');
return false;
}
});
});
</script>
<cfoutput>
<cfquery name="c" datasource="user_login" username="#session.dbuser#" password="#decrypt(session.epw,session.sessionKey)#" cachedwithin="#createtimespan(0,0,60,0)#">
select guid_prefix,collection_id from collection ORDER BY guid_prefix
</cfquery>
<cfquery name="ctid_references" datasource="user_login" username="#session.dbuser#" password="#decrypt(session.epw,session.sessionKey)#">
select id_references from ctid_references order by id_references
</cfquery>
<cfquery name="thisrec" datasource="user_login" username="#session.dbuser#" password="#decrypt(session.epw,session.sessionKey)#">
select
flat.scientific_name,
flat.collection_id,
collection.guid_prefix
from
flat,
collection
where
flat.collection_id=collection.collection_id and
collection_object_id=#collection_object_id#
</cfquery>
<span class="likeLink" onclick="document.getElementById('cThis').style.display='block';">[ Clone This Record ]</span>
<div id="cThis" style="display:none; border:2px solid green;">
Option One: Click <span class="likeLink" onclick="cloneFullCatalogedItem(#collection_object_id#)" >here</span>
to IMMEDIATELY clone this ENTIRE record, including parts, containers, loan history, etc.
<br>USE THIS OPTION WITH CAUTION. There is no review process; the insert is immediate.
<br>You can encumber and delete accidental insertions.
<br>The new record will take about a minute to become available to the interfaces; immediately clicking the
returned GUID will probably 404 - grab a cup of coffee and then reload.
<hr>
Option Two: Click <span class="likeLink" onclick="cloneCatalogedItem(#collection_object_id#)" >here</span>
to create a record in the bulkloader, where you
may further edit the record or flag it to load, as with any other new record.
<br>Check specimen remarks in the bulkloader for things that might have been missed - this
application has limited handling of agents, identifiers, attributes, and parts.
<br>
This might take a minute.
Don't get all clicky or you'll make a mess.
<br>Create
<form name="clone">
<label for="numRecs">Number of new records</label>
<select name="numRecs" id="numRecs">
<cfloop from="1" to="1000" index="i">
<option value="#i#">#i#</option>
</cfloop>
</select>
<label for="refType">relationship (id_references in bulkloader) to this record</label>
<select name="refType" id="refType" size="1">
<option value="">-pick one-</option>
<cfloop query="ctid_references">
<option value="#ctid_references.id_references#">#ctid_references.id_references#</option>
</cfloop>
</select>
<input type="hidden" name="nothing">
<label for="taxon_name">as taxon name</label>
<input type="text" name="taxon_name"class="reqdClr" size="40" id="taxon_name" value="#thisRec.scientific_name#" onchange="taxaPick('nothing',this.id,'clone',this.value)">
<label for="collection_id">in collection</label>
<select name="collection_id" id="collection_id">
<cfloop query="c">
<option <cfif c.collection_id is thisrec.collection_id> selected="selected" </cfif>value="#collection_id#">#guid_prefix#</option>
</cfloop>
</select>
<br><input type="button" onclick="cloneCatalogedItem(#collection_object_id#)" value="Create Clone" class="insBtn">
</form>
</div>
<br>
<div id="cloned" style="display:none" class="redBorder"></div>
<cfquery name="getIDs" datasource="user_login" username="#session.dbuser#" password="#decrypt(session.epw,session.sessionKey)#">
select
COLL_OBJ_OTHER_ID_NUM_ID,
cat_num,
other_id_prefix,
other_id_number,
other_id_suffix,
other_id_type,
cataloged_item.collection_id,
id_references,
guid_prefix,
coll_obj_other_id_num_id
from
cataloged_item,
coll_obj_other_id_num,
collection
where
cataloged_item.collection_id=collection.collection_id and
cataloged_item.collection_object_id=coll_obj_other_id_num.collection_object_id (+) and
cataloged_item.collection_object_id=#collection_object_id#
</cfquery>
<cfquery name="ctType" datasource="user_login" username="#session.dbuser#" password="#decrypt(session.epw,session.sessionKey)#">
select other_id_type from ctcoll_other_id_type order by other_id_type
</cfquery>
<cfquery name="cat" dbtype="query">
select
cat_num,
guid_prefix,
collection_id
from
getIDs
group by
cat_num,
guid_prefix,
collection_id
</cfquery>
<cfquery name="oids" dbtype="query">
select
COLL_OBJ_OTHER_ID_NUM_ID,
other_id_prefix,
other_id_number,
other_id_suffix,
other_id_type,
id_references,
coll_obj_other_id_num_id
from
getIDs
where
COLL_OBJ_OTHER_ID_NUM_ID is not null
group by
COLL_OBJ_OTHER_ID_NUM_ID,
other_id_prefix,
other_id_number,
other_id_suffix,
other_id_type,
id_references,
coll_obj_other_id_num_id
</cfquery>
<h3>Identifiers</h3>
<b>Edit existing Identifiers:</b>
<form name="ids" id="formEdit" method="post" action="editIdentifiers.cfm">
<input type="hidden" name="collection_object_id" value="#collection_object_id#">
<input type="hidden" name="Action" value="saveEdits">
<table>
<tr #iif(i MOD 2,DE("class='oddRow'"),DE("class='evenRow'"))#>
<input type="hidden" name="oldcat_num" value="#cat.cat_num#">
<td>Catalog Number:</td>
<td>#cat.guid_prefix#:</td>
<td><input type="text" name="cat_num" value="#cat.cat_num#" size="12" class="reqdClr"></td>
<td>
<span class="infoLink"onClick="window.open('/tools/findGap.cfm','','width=400,height=338, resizable,scrollbars');">[ find gaps ]</span>
</td>
</tr>
</table>
<cfset i=1>
<table>
<tr>
<th>
ID Type
<span class="infoLink" onClick="getCtDoc('ctcoll_other_id_type','')">[ define ]</span>
</th>
<th>Prefix or String</th>
<th>ID Number (int)</th>
<th>Suffix</th>
<th>
Relationship
<span class="infoLink" onClick="getCtDoc('ctid_references','')">[ define ]</span>
</th>
<th>Delete</th>
</tr>
<cfloop query="oids">
<input type="hidden" name="coll_obj_other_id_num_id_#i#" value="#coll_obj_other_id_num_id#">
<tr id="trid_#i#" #iif(i MOD 2,DE("class='oddRow'"),DE("class='evenRow'"))#>
<td>
<select name="other_id_type_#i#" id="other_id_type_#i#" size="1">
<cfloop query="ctType">
<option <cfif ctType.other_id_type is oids.other_id_type> selected="selected" </cfif>
value="#ctType.other_id_type#">#ctType.other_id_type#</option>
</cfloop>
</select>
</td>
<td>
<input type="text" value="#oids.other_id_prefix#" size="12" name="other_id_prefix_#i#" id="other_id_prefix_#i#">
</td>
<td>
<input type="number" step="any" value="#oids.other_id_number#" size="12" name="other_id_number_#i#" id="other_id_number_#i#">
</td>
<td>
<input type="text" value="#oids.other_id_suffix#" size="12" name="other_id_suffix_#i#" id="other_id_suffix_#i#">
</td>
<td>
<select name="id_references_#i#" id="id_references_#i#" size="1">
<cfloop query="ctid_references">
<option <cfif ctid_references.id_references is oids.id_references> selected="selected" </cfif>
value="#ctid_references.id_references#">#ctid_references.id_references#</option>
</cfloop>
</select>
</td>
<td>
<input type="checkbox" id="delete_#i#" name="delete_#i#" value="1">
</td>
</tr>
<cfset i=i+1>
</cfloop>
<cfset nid=i-1>
<input type="hidden" value="#nid#" name="numberOfIDs" id="numberOfIDs">
</table>
<input type="submit" name="not_submit" value="Save Changes" class="savBtn">
</form>
<b>Add New Identifier:</b>
<form name="newOID" id="newOID" method="post" action="editIdentifiers.cfm">
<input type="hidden" name="collection_object_id" value="#collection_object_id#">
<input type="hidden" name="Action" value="newOID">
<table class="newRec">
<tr id="trid_new">
<td>
<select name="other_id_type" id="other_id_type" size="1">
<cfloop query="ctType">
<option value="#ctType.other_id_type#">#ctType.other_id_type#</option>
</cfloop>
</select>
</td>
<td>
<input type="text" size="12" name="other_id_prefix" id="other_id_prefix">
</td>
<td>
<input type="number" step="any" size="12" name="other_id_number" id="other_id_number">
</td>
<td>
<input type="text" size="12" name="other_id_suffix" id="other_id_suffix">
</td>
<td>
<select name="id_references" id="id_references" size="1">
<cfloop query="ctid_references">
<option <cfif ctid_references.id_references is 'self'> selected="selected" </cfif>
value="#ctid_references.id_references#">#ctid_references.id_references#</option>
</cfloop>
</select>
</td>
</tr>
</table>
<input type="submit" value="Insert" class="insBtn">
</form>
</cfoutput>
</cfif>
<!-------------------------------------------------------->
<cfif action is "saveEdits">
<cfoutput>
<cftransaction>
<!--- save an update if possible --->
<cfif oldcat_num is not cat_num>
<cfquery name="upCat" datasource="user_login" username="#session.dbuser#" password="#decrypt(session.epw,session.sessionKey)#">
UPDATE cataloged_item SET
cat_num = '#cat_num#'
WHERE collection_object_id=#collection_object_id#
</cfquery>
</cfif>
<cfloop from="1" to="#numberOfIDs#" index="n">
<cfset thisCOLL_OBJ_OTHER_ID_NUM_ID = evaluate("COLL_OBJ_OTHER_ID_NUM_ID_" & n)>
<cfset thisID_REFERENCES = evaluate("ID_REFERENCES_" & n)>
<cfset thisOTHER_ID_NUMBER = evaluate("OTHER_ID_NUMBER_" & n)>
<cfset thisOTHER_ID_PREFIX = evaluate("OTHER_ID_PREFIX_" & n)>
<cfset thisOTHER_ID_SUFFIX = evaluate("OTHER_ID_SUFFIX_" & n)>
<cfset thisOTHER_ID_TYPE = evaluate("OTHER_ID_TYPE_" & n)>
<cfif isdefined("delete_" & n) and evaluate("delete_" & n) is 1>
<cfquery name="dOIDt" datasource="user_login" username="#session.dbuser#" password="#decrypt(session.epw,session.sessionKey)#">
delete from coll_obj_other_id_num WHERE
COLL_OBJ_OTHER_ID_NUM_ID=#thisCOLL_OBJ_OTHER_ID_NUM_ID#
</cfquery>
<cfelse>
<cfquery name="upOIDt" datasource="user_login" username="#session.dbuser#" password="#decrypt(session.epw,session.sessionKey)#">
UPDATE
coll_obj_other_id_num
SET
other_id_type = '#thisOTHER_ID_TYPE#',
other_id_prefix='#thisOTHER_ID_PREFIX#',
<cfif len(thisOTHER_ID_NUMBER) gt 0>
other_id_number=#thisOTHER_ID_NUMBER#,
<cfelse>
other_id_number=NULL,
</cfif>
other_id_suffix='#thisOTHER_ID_SUFFIX#',
id_references='#thisID_REFERENCES#'
WHERE
COLL_OBJ_OTHER_ID_NUM_ID=#thisCOLL_OBJ_OTHER_ID_NUM_ID#
</cfquery>
</cfif>
</cfloop>
</cftransaction>
<cflocation url="editIdentifiers.cfm?collection_object_id=#collection_object_id#">
</cfoutput>
</cfif>
<!-------------------------------------------------------->
<cfif action is "newOID">
<cfoutput>
<cfquery name="newOIDt" datasource="user_login" username="#session.dbuser#" password="#decrypt(session.epw,session.sessionKey)#">
INSERT INTO coll_obj_other_id_num
(collection_object_id,
other_id_type,
other_id_prefix,
other_id_number,
other_id_suffix,
id_references
) VALUES (
#collection_object_id#,
'#other_id_type#',
'#other_id_prefix#',
<cfif len(other_id_number) gt 0>
#other_id_number#
<cfelse>
NULL
</cfif>
,
'#other_id_suffix#',
'#id_references#')
</cfquery>
<cflocation url="editIdentifiers.cfm?collection_object_id=#collection_object_id#">
</cfoutput>
</cfif>
<!-------------------------------------------------------->
<cf_customizeIFrame>