forked from ArctosDB/arctos
-
Notifications
You must be signed in to change notification settings - Fork 0
/
editAccn.cfm
1017 lines (993 loc) · 39.7 KB
/
editAccn.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
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<cfinclude template="includes/_header.cfm">
<script language="javascript" type="text/javascript">
jQuery(document).ready(function() {
$("#b_ent_date").datepicker();
$("#e_ent_date").datepicker();
$("#rec_date").datepicker();
$("#rec_until_date").datepicker();
$("#issued_date").datepicker();
$("#renewed_date").datepicker();
$("#exp_date").datepicker();
$("#editAccn").submit(function(event){
// just call the function - it will prevent submission if necessary
checkReplaceNoPrint(event,'nature_of_material');
checkReplaceNoPrint(event,'remarks');
});
});
function addAccnContainer(transaction_id,barcode){
$('#newbarcode').addClass('red');
$.getJSON("/component/functions.cfc",
{
method : "addAccnContainer",
transaction_id : transaction_id,
barcode : barcode,
returnformat : "json",
queryformat : 'column'
},
function(r) {
if (r.STATUS == 'success') {
$('#newbarcode').removeClass('red').val('').focus();
var d='<div id="tc_' + r.BARCODE + '">' + r.BARCODE + ' <span class="infoLink" onclick="removeAccnContainer(' + r.TRANSACTION_ID + ',\'' + r.BARCODE + '\')">Remove</span></div>';
$('#existingAccnContainers').append(d);
} else {
alert('An error occured! \n ' + r.ERROR);
$('#newbarcode').focus();
}
}
);
}
function removeAccnContainer(transaction_id,barcode){
$('#newbarcode').addClass('red');
$.getJSON("/component/functions.cfc",
{
method : "removeAccnContainer",
transaction_id : transaction_id,
barcode : barcode,
returnformat : "json",
queryformat : 'column'
},
function(r) {
if (r.STATUS == 'success') {
$('#tc_' + r.BARCODE).remove();
$('#newbarcode').focus();
} else {
alert('An error occured! \n ' + r.ERROR);
$('#newbarcode').focus();
}
}
);
}
function removeMediaDiv() {
if(document.getElementById('bgDiv')){
jQuery('#bgDiv').remove();
}
if (document.getElementById('mediaDiv')) {
jQuery('#mediaDiv').remove();
}
}
function addMediaHere (accnnum,transid){
var bgDiv = document.createElement('div');
bgDiv.id = 'bgDiv';
bgDiv.className = 'bgDiv';
bgDiv.setAttribute('onclick','removeMediaDiv()');
document.body.appendChild(bgDiv);
var theDiv = document.createElement('div');
theDiv.id = 'mediaDiv';
theDiv.className = 'annotateBox';
ctl='<span class="likeLink" style="position:absolute;right:0px;top:0px;padding:5px;color:red;" onclick="removeMediaDiv();">Close Frame</span>';
theDiv.innerHTML=ctl;
document.body.appendChild(theDiv);
jQuery('#mediaDiv').append('<iframe id="mediaIframe" />');
jQuery('#mediaIframe').attr('src', '/media.cfm?action=newMedia').attr('width','100%').attr('height','100%');
jQuery('iframe#mediaIframe').load(function() {
jQuery('#mediaIframe').contents().find('#relationship__1').val('documents accn');
jQuery('#mediaIframe').contents().find('#related_value__1').val(accnnum);
jQuery('#mediaIframe').contents().find('#related_id__1').val(transid);
viewport.init("#mediaDiv");
});
}
</script>
<cfset title="Edit Accession">
<cfif not isdefined("project_id")>
<cfset project_id = -1>
</cfif>
<cfquery name="cttrans_agent_role" datasource="user_login" username="#session.dbuser#" password="#decrypt(session.epw,session.sessionKey)#" cachedwithin="#createtimespan(0,0,60,0)#">
select distinct(trans_agent_role) from cttrans_agent_role where trans_agent_role != 'entered by' order by trans_agent_role
</cfquery>
<cfquery name="ctcoll" 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="ctStatus" datasource="user_login" username="#session.dbuser#" password="#decrypt(session.epw,session.sessionKey)#" cachedwithin="#createtimespan(0,0,60,0)#">
select accn_status from ctaccn_status order by accn_status
</cfquery>
<cfquery name="ctType" datasource="user_login" username="#session.dbuser#" password="#decrypt(session.epw,session.sessionKey)#" cachedwithin="#createtimespan(0,0,60,0)#">
select accn_type from ctaccn_type order by accn_type
</cfquery>
<cfquery name="ctPermitType" datasource="user_login" username="#session.dbuser#" password="#decrypt(session.epw,session.sessionKey)#" cachedwithin="#createtimespan(0,0,60,0)#">
select * from ctpermit_type order by permit_type
</cfquery>
<!-------------------------------------------------------------------->
<cfif action is "deleteAccn">
<cftransaction>
<cfquery name="delAgnt" datasource="user_login" username="#session.dbuser#" password="#decrypt(session.epw,session.sessionKey)#">
delete from trans_agent where transaction_id=#transaction_id#
</cfquery>
<cfquery name="delAccn" datasource="user_login" username="#session.dbuser#" password="#decrypt(session.epw,session.sessionKey)#">
delete from accn where transaction_id=#transaction_id#
</cfquery>
<cfquery name="delTrans" datasource="user_login" username="#session.dbuser#" password="#decrypt(session.epw,session.sessionKey)#">
delete from trans where transaction_id=#transaction_id#
</cfquery>
</cftransaction>
you deleted it
</cfif>
<!-------------------------------------------------------------------->
<cfif action is "edit">
<cfoutput>
<script>
jQuery(document).ready(function() {
getMedia('accn','#transaction_id#','accnMediaDiv','6','1');
});
</script>
<cfset title="Edit Accession">
<cfquery name="accnData" datasource="user_login" username="#session.dbuser#" password="#decrypt(session.epw,session.sessionKey)#">
SELECT
trans.transaction_id,
accn_number,
accn_status,
accn_type,
received_date,
nature_of_material,
trans_remarks,
trans_date,
guid_prefix,
trans.collection_id,
CORRESP_FG,
concattransagent(trans.transaction_id,'entered by') enteredby,
estimated_count,
is_public_fg
FROM
trans,
accn,
collection
WHERE
trans.transaction_id = accn.transaction_id AND
trans.collection_id=collection.collection_id and
trans.transaction_id = #transaction_id#
</cfquery>
<cfquery name="transAgents" datasource="user_login" username="#session.dbuser#" password="#decrypt(session.epw,session.sessionKey)#">
select
trans_agent_id,
trans_agent.agent_id,
agent_name,
trans_agent_role
from
trans_agent,
preferred_agent_name
where
trans_agent.agent_id = preferred_agent_name.agent_id and
trans_agent_role != 'entered by' and
trans_agent.transaction_id=#transaction_id#
order by
trans_agent_role,
agent_name
</cfquery>
<div style="clear:both"><strong>Edit Accession</strong></div>
<table><tr><td valign="top">
<form action="editAccn.cfm" method="post" name="editAccn" id="editAccn">
<input type="hidden" name="action" value="saveChanges">
<input type="hidden" name="transaction_id" value="#accnData.transaction_id#">
<cfset tIA=accnData.collection_id>
<table border>
<tr>
<td>
<label for="collection_id">Collection</label>
<select name="collection_id" size="1" class="reqdClr" id="collection_id">
<cfloop query="ctcoll">
<option <cfif #ctcoll.collection_id# is #tIA#> selected </cfif>
value="#ctcoll.collection_id#">#ctcoll.guid_prefix#</option>
</cfloop>
</select>
</td>
<td>
<label for="accn_number">Accn Number</label>
<input type="text" name="accn_number" value="#accnData.accn_number#" id="accn_number" class="reqdClr">
</td>
<td>
<label for="accn_type">How Obtained?</label>
<select name="accn_type" size="1" class="reqdClr" id="accn_type">
<cfloop query="cttype">
<option <cfif #cttype.accn_type# is "#accnData.accn_type#"> selected </cfif>
value="#cttype.accn_type#">#cttype.accn_type#</option>
</cfloop>
</select>
</td>
<td>
<label for="accn_status">Status</label>
<select name="accn_status" size="1" class="reqdClr" id="accn_status">
<cfloop query="ctStatus">
<option <cfif #ctStatus.accn_status# is "#accnData.accn_status#">selected </cfif>
value="#ctStatus.accn_status#">#ctStatus.accn_status#</option>
</cfloop>
</select>
</td>
<td>
<label for="rec_date">Received Date</label>
<input type="text"
name="rec_date"
value="#DateFormat(accnData.received_date, 'yyyy-mm-dd')#"
size="10"
id="rec_date">
</td>
<td>
<label for="estimated_count" onClick="getDocs('accession','estimated_count')" class="likeLink">
Est. Cnt.
</label>
<input type="text" validate="integer"
message="##Specimens must be a number" name="estimated_count"
value="#accnData.estimated_count#" size="10" id="estimated_count">
</td>
</tr>
<tr>
<td colspan="6">
<label for="nature_of_material">Nature of Material:</label>
<textarea name="nature_of_material" rows="5" cols="90" class="reqdClr"
id="nature_of_material">#accnData.nature_of_material#</textarea>
</td>
</tr>
<tr>
<td colspan="6">
<table border>
<tr>
<th>Agent Name</th>
<th>Role</th>
<th>Delete?</th>
<th></th>
</tr>
<cfloop query="transAgents">
<tr>
<td>
<input type="text" name="trans_agent_#trans_agent_id#" class="reqdClr" size="50" value="#agent_name#"
onchange="getAgent('trans_agent_id_#trans_agent_id#','trans_agent_#trans_agent_id#','editAccn',this.value); return false;"
onKeyPress="return noenter(event);">
<input type="hidden" name="trans_agent_id_#trans_agent_id#" value="#agent_id#">
</td>
<td>
<cfset thisRole = #trans_agent_role#>
<select name="trans_agent_role_#trans_agent_id#">
<cfloop query="cttrans_agent_role">
<option
<cfif #trans_agent_role# is #thisRole#> selected="selected"</cfif>
value="#trans_agent_role#">#trans_agent_role#</option>
</cfloop>
</select>
</td>
<td>
<input type="checkbox" name="del_agnt_#trans_agent_id#">
</td>
<td><span class="infoLink" onclick="rankAgent('#agent_id#');">Rank</span></td>
</tr>
</cfloop>
<tr class="newRec">
<td>
<label for="new_trans_agent">Add Agent:</label>
<input type="text" name="new_trans_agent" id="new_trans_agent" class="reqdClr" size="50"
onchange="getAgent('new_trans_agent_id','new_trans_agent','editAccn',this.value); return false;"
onKeyPress="return noenter(event);">
<input type="hidden" name="new_trans_agent_id">
</td>
<td>
<label for="new_trans_agent_role"> </label>
<select name="new_trans_agent_role" id="new_trans_agent_role">
<cfloop query="cttrans_agent_role">
<option value="#trans_agent_role#">#trans_agent_role#</option>
</cfloop>
</select>
</td>
<td> </td>
</tr>
</table>
</td>
</tr>
<tr>
<td colspan="6">
<label for="remarks">Remarks:</label>
<textarea name="remarks" rows="5" cols="90" id="remarks">#accnData.trans_remarks#</textarea>
</td>
</tr>
<tr>
<td colspan="3">
<em>Entered by</em>
<strong>#accnData.enteredby#</strong> <em>on</em> <strong>#dateformat(accnData.trans_date,'yyyy-mm-dd')#</strong>
</td>
<td colspan="2">
<label for="">Has Correspondence?</label>
<select name="CORRESP_FG" size="1" id="CORRESP_FG">
<option <cfif #accnData.CORRESP_FG# is "1">selected</cfif> value="1">Yes</option>
<option <cfif #accnData.CORRESP_FG# is "0">selected</cfif> value="0">No</option>
</select>
</td>
<td>
<label for="">Public?</label>
<select name="is_public_fg" size="1" id="is_public_fg">
<option <cfif #accnData.is_public_fg# is "1">selected</cfif> value="1">public</option>
<option <cfif #accnData.is_public_fg# is "0">selected</cfif> value="0">private</option>
</select>
</td>
</tr>
<tr>
<td colspan="6" align="center">
<input type="button" value="Save Changes" class="savBtn"
onClick="editAccn.action.value='saveChanges';editAccn.submit();">
<input type="button" value="Quit without saving" class="qutBtn"
onclick = "document.location = 'editAccn.cfm'">
<input type="button" value="Delete" class="delBtn" onClick="editAccn.action.value='deleteAccn';confirmDelete('editAccn');">
<input type="button" value="Specimen List" class="lnkBtn"
onclick = "window.open('SpecimenResults.cfm?accn_trans_id=#transaction_id#');">
<input type="button" value="BerkeleyMapper" class="lnkBtn"
onclick = "window.open('/bnhmMaps/bnhmMapData.cfm?accn_number=#accnData.accn_number#','_blank');">
</td>
</tr>
</table>
</div>
</td><td valign="top">
<cfquery name="accncontainers" datasource="user_login" username="#session.dbuser#" password="#decrypt(session.epw,session.sessionKey)#">
select barcode from container, trans_container where
container.container_id=trans_container.container_id and
transaction_id=#transaction_id#
</cfquery>
<table border="1">
<tr>
<td>
<strong>Accn Containers</strong>
<br><a target="_blank" href="/findContainer.cfm?transaction_id=#transaction_id#&autosubmit=true">Show Locations</a>
</td>
</tr>
<tr>
<td>
<label for="">Scan New Barcode</label>
<input type="text" id="newbarcode" name="newbarcode" size="15" onchange="addAccnContainer(#transaction_id#,this.value)">
</td>
</tr>
<tr>
<td id="existingAccnContainers">
<cfloop query="accncontainers">
<div id="tc_#barcode#">
#barcode# <span class="infoLink" onclick="removeAccnContainer(#transaction_id#,'#barcode#')">Remove</span>
</div>
</cfloop>
</td>
</tr>
</table>
</td><td valign="top">
<strong>Projects associated with this Accn:</strong>
<ul>
<cfquery name="projs" datasource="user_login" username="#session.dbuser#" password="#decrypt(session.epw,session.sessionKey)#">
select project_name, project.project_id from project,
project_trans where
project_trans.project_id = project.project_id
and transaction_id=#transaction_id#
</cfquery>
<cfif #projs.recordcount# gt 0>
<cfloop query="projs">
<li>
<a href="/Project.cfm?action=editProject&project_id=#project_id#"><strong>#project_name#</strong></a><br>
</li>
</cfloop>
<cfelse>
<li>None</li>
</cfif>
</ul>
<table class="newRec" width="100%">
<tr>
<td>
<label for="project_name">New Project</label>
<input type="hidden" name="project_id">
<input type="text"
size="50"
name="project_name"
id="project_name"
class="reqdClr"
onchange="getProject('project_id','project_name','editAccn',this.value); return false;"
onKeyPress="return noenter(event);"
placeholder="Project or Project Agent then TAB">
</td>
</tr>
</table>
</form>
<strong>Media associated with this Accn:</strong>
<br><span class="likeLink"
onclick="addMediaHere('#accnData.guid_prefix# #accnData.accn_number#','#transaction_id#');">
Create Media
</span> ~ <a href="/MediaSearch.cfm" target="_blank">Link Media</a>
<div id="accnMediaDiv"></div>
</div>
<cfquery name="getPermits" datasource="user_login" username="#session.dbuser#" password="#decrypt(session.epw,session.sessionKey)#">
SELECT
permit.permit_id,
issuedBy.agent_name as IssuedByAgent,
issuedTo.agent_name as IssuedToAgent,
issued_date,
renewed_date,
exp_date,
permit_Num,
permit_Type,
permit_remarks
FROM
permit,
permit_trans,
preferred_agent_name issuedTo,
preferred_agent_name issuedBy
WHERE
permit.permit_id = permit_trans.permit_id AND
permit.issued_by_agent_id = issuedBy.agent_id AND
permit.issued_to_agent_id = issuedTo.agent_id AND
permit_trans.transaction_id = #accnData.transaction_id#
</cfquery>
<div style="float:left;width:55%;">
<br><strong>Permits:</strong>
<cfloop query="getPermits">
<p><strong>Permit ## #permit_Num# (#permit_Type#)</strong> issued to #IssuedToAgent# by #IssuedByAgent# on #dateformat(issued_date,"yyyy-mm-dd")#. <cfif len(#renewed_date#) gt 0> (renewed #renewed_date#)</cfif>Expires #dateformat(exp_date,"yyyy-mm-dd")# <cfif len(#permit_remarks#) gt 0>Remarks: #permit_remarks# </cfif>
<form name="killPerm#currentRow#" method="post" action="editAccn.cfm">
<input type="hidden" name="transaction_id" value="#accnData.transaction_id#">
<input type="hidden" name="action" value="delePermit">
<input type="hidden" name="permit_id" value="#permit_id#">
<input type="submit" value="Remove this Permit" class="delBtn">
</form>
</cfloop>
<form name="addPermit" action="editAccn.cfm" method="post">
<input type="hidden" name="transaction_id" value="#accnData.transaction_id#">
<input type="hidden" name="permit_id">
<input type="button" value="Add a permit" class="picBtn"
onClick="javascript: window.open('picks/PermitPick.cfm?transaction_id=#transaction_id#', 'PermitPick',
'resizable,scrollbars=yes,width=600,height=600')">
</form>
</td></tr></table>
</cfoutput>
</cfif>
<!-------------------------------------------------------------------->
<cfif action is "nothing">
<cfset title = "Find Accession">
<cfoutput>
<strong>Find Accession
<cfif #project_id# gt 0>to add to project ## #project_id#</cfif>
</strong>
<form action="editAccn.cfm" method="post" name="SpecData" preservedata="yes">
<input type="hidden" name="action" value="findAccessions">
<input type="hidden" <cfif project_id gt 0> value = "#project_id#" </cfif> name="project_id">
<table border>
<tr>
<td>
<label for="accn_number">Accn Number</label>
<input type="text" name="accn_number" id="accn_number">
<span class="smaller"> Exact Match?</span> <input type="checkbox" name="exactAccnNumMatch" value="1">
</td>
<td align="right">
<label for="collection_id">Collection</label>
<select name="collection_id" size="1" id="collection_id">
<option value=""></option>
<cfloop query="ctcoll">
<option value="#ctcoll.collection_id#">#ctcoll.guid_prefix#</option>
</cfloop>
</select>
</td>
<td>
<label for="accn_status">Status</label>
<select name="accn_status" id="accn_status" size="1">
<option value=""></option>
<cfloop query="ctStatus">
<option value="#ctStatus.accn_status#">#ctStatus.accn_status#</option>
</cfloop>
</select>
</td>
</tr>
<tr>
<td align="right">
Agent:<select name="trans_agent_role_1">
<option value=""></option>
<cfloop query="cttrans_agent_role">
<option value="#trans_agent_role#">#trans_agent_role#</option>
</cfloop>
</select>
</td>
<td colspan="2">
<input type="text" name="agent_1" size="50">
</td>
</tr>
<tr>
<td align="right">
Agent:<select name="trans_agent_role_2">
<option value=""></option>
<cfloop query="cttrans_agent_role">
<option value="#trans_agent_role#">#trans_agent_role#</option>
</cfloop>
</select>
</td>
<td colspan="2">
<input type="text" name="agent_2" size="50">
</td>
</tr>
<tr>
<td align="right">
Agent:<select name="trans_agent_role_3">
<option value=""></option>
<cfloop query="cttrans_agent_role">
<option value="#trans_agent_role#">#trans_agent_role#</option>
</cfloop>
</select>
</td>
<td colspan="2">
<input type="text" name="agent_3" size="50">
</td>
</tr>
<tr>
<td colspan="3">
<label for="nature_of_material">Nature of Material</label>
<input <cfif isdefined("nature_of_material")>value="#nature_of_material#"</cfif>
type="text" name="nature_of_material" id="nature_of_material" size="90">
</td>
</tr>
<tr>
<td>
<label for="accn_type">Accn Type</label>
<select name="accn_type" id="accn_type" size="1">
<option value=""></option>
<cfloop query="cttype">
<option value="#cttype.accn_type#">#cttype.accn_type#</option>
</cfloop>
</select>
</td>
<td>
<label for="accn_media">Media</label>
<select name="accn_media" id="accn_media" size="1">
<option value=""></option>
<option value="1">require</option>
</select>
</td>
</tr>
<tr>
<td colspan="3">
<label for="remarks">Remarks</label>
<input <cfif isdefined("remarks")>value="#remarks#"</cfif>
type="text" name="remarks" id="remarks" size="90">
</td>
</tr>
<tr>
<td>
<table cellspacing='0' cellpadding='0'>
<td>
<label for="b_ent_date">Entry Date:</label>
<input type="text" name="b_ent_date" id="b_ent_date">
</td>
<td>
<label for="e_ent_date">Until: (leave blank otherwise)</label>
<input type='text' name='e_ent_date' id='e_ent_date'>
</td>
</table>
</td>
<td colspan=2 nowrap>
<table cellspacing='0' cellpadding='0'>
<td>
<label for="rec_date">Received Date:</label>
<input type="text" name="rec_date" id="rec_date">
</td>
<td>
<label for="rec_until_date">Until: (leave blank otherwise)</label>
<input type='text' name='rec_until_date' id='rec_until_date'>
</td>
</table>
</td>
</tr>
<tr>
<td><strong>Permits:</strong></td>
</tr>
<tr>
<td>
<label for="IssuedByAgent">Issued By</label>
<input type="text" name="IssuedByAgent" id="IssuedByAgent">
</td>
<td>
<label for="IssuedByAgent">Issued To</label>
<input type="text" name="IssuedToAgent" id="IssuedToAgent">
</td>
</tr>
<tr>
<td>
<label for="IssuedByAgent">Issued Date</label>
<input type="text" name="issued_date" id="issued_date">
</td>
<td>
<label for="IssuedByAgent">Renewed Date</label>
<input type="text" name="renewed_date" id="renewed_date">
</td>
</tr>
<tr>
<td>
<label for="IssuedByAgent">Expiration Date</label>
<input type="text" name="exp_date" id="exp_date">
</td>
<td>
<label for="IssuedByAgent">Permit Number</label>
<input type="text" name="permit_num" id="permit_num">
</td>
</tr>
<tr>
<td>
<label for="permit_Type">Permit Type</label>
<select name="permit_Type" size="1" id="permit_Type">
<option value=""></option>
<cfloop query="ctPermitType">
<option value = "#ctPermitType.permit_type#">#ctPermitType.permit_type#</option>
</cfloop>
</select>
</td>
<td>
<label for="permit_remarks">Remarks</label>
<input type="text" name="permit_remarks" id="permit_remarks">
</td>
<tr>
<td colspan="4" align="center">
<input type="submit" value="Find Accession" class="schBtn">
<input type="button" value="Create a new accession" class="insBtn"
onClick="document.location = 'newAccn.cfm';">
<input type="button" value="Clear Form" class="clrBtn" onClick="document.location='editAccn.cfm';">
<input type="button" value="Add Specimens to an Accn" class="lnkBtn"
onclick = "window.open('SpecimenSearch.cfm?action=addAccn');">
</td>
</tr>
</table>
</form>
</cfoutput>
</cfif>
<!------------------------------------------------------------------------------------------->
<cfif #action# is "findAccessions">
<cfset title = "Accession Search Results">
<cfoutput>
<cfset sel = "SELECT
trans.transaction_id,
accn_number,
nature_of_material,
received_date,
accn_status,
trans_remarks,
issuedTo.agent_name as issuedTo,
issuedBy.agent_name as issuedBy,
guid_prefix,
project_name,
project.project_id pid,
estimated_count,
concattransagent(trans.transaction_id,'entered by') ENTAGENT,
concattransagent(trans.transaction_id,'received from') RECFROMAGENT">
<cfset frm=" from
accn,
trans,
permit_trans,
permit,
preferred_agent_name issuedBy,
preferred_agent_name issuedTo,
collection,
project_trans,
project">
<cfset sql = " where accn.transaction_id = trans.transaction_id and
trans.transaction_id = permit_trans.transaction_id (+) and
permit_trans.permit_id = permit.permit_id (+) and
permit.issued_by_agent_id = issuedBy.agent_id (+) and
permit.issued_to_agent_id = issuedTo.agent_id (+) and
trans.transaction_id = project_trans.transaction_id (+) and
project_trans.project_id = project.project_id (+) AND
trans.collection_id=collection.collection_id ">
<cfif isdefined("accn_media") AND len(accn_media) gt 0>
<cfset frm="#frm#,media_relations">
<cfset sql="#sql# and media_relations.media_relationship like '% accn' and accn.transaction_id = media_relations.related_primary_key">
</cfif>
<cfif isdefined("trans_agent_role_1") AND len(#trans_agent_role_1#) gt 0>
<cfset frm="#frm#,trans_agent trans_agent_1">
<cfset sql="#sql# and trans.transaction_id = trans_agent_1.transaction_id">
<cfset sql = "#sql# AND trans_agent_1.trans_agent_role = '#trans_agent_role_1#'">
</cfif>
<cfif isdefined("agent_1") AND len(#agent_1#) gt 0>
<cfif #sql# does not contain "trans_agent_1">
<cfset frm="#frm#,trans_agent trans_agent_1">
<cfset sql="#sql# and trans.transaction_id = trans_agent_1.transaction_id">
</cfif>
<cfset frm="#frm#,preferred_agent_name trans_agent_name_1">
<cfset sql="#sql# and trans_agent_1.agent_id = trans_agent_name_1.agent_id">
<cfset sql = "#sql# AND upper(trans_agent_name_1.agent_name) like '%#escapeQuotes(ucase(agent_1))#%'">
</cfif>
<cfif isdefined("trans_agent_role_2") AND len(#trans_agent_role_2#) gt 0>
<cfset frm="#frm#,trans_agent trans_agent_2">
<cfset sql="#sql# and trans.transaction_id = trans_agent_2.transaction_id">
<cfset sql = "#sql# AND trans_agent_2.trans_agent_role = '#trans_agent_role_2#'">
</cfif>
<cfif isdefined("agent_2") AND len(#agent_2#) gt 0>
<cfif #sql# does not contain "trans_agent_2">
<cfset frm="#frm#,trans_agent trans_agent_2">
<cfset sql="#sql# and trans.transaction_id = trans_agent_2.transaction_id">
</cfif>
<cfset frm="#frm#,preferred_agent_name trans_agent_name_2">
<cfset sql="#sql# and trans_agent_2.agent_id = trans_agent_name_2.agent_id">
<cfset sql = "#sql# AND upper(trans_agent_name_2.agent_name) like '%#escapeQuotes(ucase(agent_2))#%'">
</cfif>
<cfif isdefined("trans_agent_role_3") AND len(#trans_agent_role_3#) gt 0>
<cfset frm="#frm#,trans_agent trans_agent_3">
<cfset sql="#sql# and trans.transaction_id = trans_agent_3.transaction_id">
<cfset sql = "#sql# AND trans_agent_3.trans_agent_role = '#trans_agent_role_3#'">
</cfif>
<cfif isdefined("agent_3") AND len(#agent_3#) gt 0>
<cfif #sql# does not contain "trans_agent_3">
<cfset frm="#frm#,trans_agent trans_agent_3">
<cfset sql="#sql# and trans.transaction_id = trans_agent_3.transaction_id">
</cfif>
<cfset frm="#frm#,preferred_agent_name trans_agent_name_3">
<cfset sql="#sql# and trans_agent_3.agent_id = trans_agent_name_3.agent_id">
<cfset sql = "#sql# AND upper(trans_agent_name_3.agent_name) like '%#escapeQuotes(ucase(agent_3))#%'">
</cfif>
<cfif isdefined("collection_id") and len(#collection_id#) gt 0>
<cfset sql = "#sql# AND trans.collection_id = #collection_id#">
</cfif>
<cfif isdefined("accn_number") and len(#accn_number#) gt 0>
<cfif isdefined("exactAccnNumMatch") and #exactAccnNumMatch# is 1>
<cfset sql = "#sql# AND accn_number = '#accn_number#'">
<cfelse>
<cfset sql = "#sql# AND upper(accn_number) LIKE '%#ucase(accn_number)#%'">
</cfif>
</cfif>
<cfif isdefined("accn_status") and len(#accn_status#) gt 0>
<cfset sql = "#sql# AND accn_status = '#accn_status#'">
</cfif>
<cfif isdefined("rec_date") and len(#rec_date#) gt 0>
<cfif isdefined("rec_until_date") and len(#rec_until_date#) gt 0>
<cfset sql = "#sql# AND upper(received_date) between to_date('#rec_date#', 'yyyy-mm-dd')
and to_date('#rec_until_date#', 'yyyy-mm-dd')">
<cfelse>
<cfset sql = "#sql# AND upper(received_date) like to_date('#rec_date#', 'yyyy-mm-dd')">
</cfif>
</cfif>
<cfif isdefined("NATURE_OF_MATERIAL") and len(#NATURE_OF_MATERIAL#) gt 0>
<cfset sql = "#sql# AND upper(NATURE_OF_MATERIAL) like '%#ucase(escapeQuotes(NATURE_OF_MATERIAL))#%'">
</cfif>
<cfif isdefined("trans_agency") and len(#trans_agency#) gt 0>
<cfset sql = "#sql# AND upper(transAgent.agent_name) LIKE '%#ucase(trans_agency)#%'">
</cfif>
<cfif isdefined("accn_type") and len(#accn_type#) gt 0>
<cfset sql = "#sql# AND accn_type = '#accn_type#'">
</cfif>
<cfif isdefined("remarks") and len(#remarks#) gt 0>
<cfset sql = "#sql# AND upper(trans_remarks) like '%#ucase(remarks)#%'">
</cfif>
<cfif isdefined("b_ent_date") and len(b_ent_date) gt 0>
<cfif not isdefined("e_ent_date") or len(e_ent_date) is 0>
<cfset e_ent_date=b_ent_date>
</cfif>
<cfset sql = "#sql# AND TRANS_DATE between '#b_ent_date#' and '#e_ent_date#'">
</cfif>
<cfif isdefined("IssuedByAgent") and len(#IssuedByAgent#) gt 0>
<cfset sql = "#sql# AND upper(issuedBy.agent_name) like '%#ucase(IssuedByAgent)#%'">
</cfif>
<cfif isdefined("IssuedToAgent") and len(#IssuedToAgent#) gt 0>
<cfset sql = "#sql# AND upper(issuedTo.agent_name) like '%#ucase(IssuedToAgent)#%'">
</cfif>
<cfif isdefined("issued_date") and len(#issued_date#) gt 0>
<cfset sql = "#sql# AND upper(issued_date) like '%#ucase(issued_date)#%'">
</cfif>
<cfif isdefined("renewed_date") and len(#renewed_date#) gt 0>
<cfset sql = "#sql# AND upper(renewed_date) like '%#ucase(renewed_date)#%'">
</cfif>
<cfif isdefined("exp_date") and len(#exp_date#) gt 0>
<cfset sql = "#sql# AND upper(exp_date) like '%#ucase(exp_date)#%'">
</cfif>
<cfif isdefined("permit_id") and len(#permit_id#) gt 0>
<cfset sql = "#sql# AND permit.permit_id = '#permit_id#'">
</cfif>
<cfif isdefined("permit_Num") and len(#permit_Num#) gt 0>
<cfset sql = "#sql# AND permit_Num = '#permit_Num#'">
</cfif>
<cfif isdefined("permit_Type") and len(#permit_Type#) gt 0>
<cfset permit_Type = #replace(permit_type,"'","''","All")#>
<cfset sql = "#sql# AND permit_Type = '#permit_Type#'">
</cfif>
<cfif isdefined("permit_remarks") and len(#permit_remarks#) gt 0>
<cfset sql = "#sql# AND upper(permit_remarks) like '%#ucase(permit_remarks)#%'">
</cfif>
<cfset thisSQL = "#sel# #frm# #sql# ORDER BY accn_number, trans.transaction_id ">
<cfquery name="getAccns" datasource="user_login" username="#session.dbuser#" password="#decrypt(session.epw,session.sessionKey)#">
#preservesinglequotes(thisSQL)#
</cfquery>
<cfif not isdefined("csv")>
<cfset csv=false>
</cfif>
<cfif getAccns.recordcount is 0>
Nothing matched your search criteria.
<cfabort>
<cfelse>
<cfquery name="c" dbtype="query">
select count(distinct(transaction_id)) c from getAccns
</cfquery>
Found #c.c# Accessions
<cfif getAccns.recordcount lt 1000>
<cfquery name="specs" datasource="user_login" username="#session.dbuser#" password="#decrypt(session.epw,session.sessionKey)#">
select count(*) c from cataloged_item where accn_id in (#valuelist(getAccns.transaction_id)#)
</cfquery>
<a href="/SpecimenResults.cfm?accn_trans_id=#valuelist(getAccns.transaction_id)#">
[ View #specs.c# Specimens ]
</a>
</cfif>
<cfset rURL="editAccn.cfm?csv=true">
<cfloop list="#StructKeyList(form)#" index="key">
<cfif len(form[key]) gt 0>
<cfset rURL='#rURL#&#key#=#form[key]#'>
</cfif>
</cfloop>
<br><a href="#rURL#">[ download CSV ]</a>
</cfif>
<cfif csv is true>
<cfset dlFile = "ArctosAccnSearchData.csv">
<cfset variables.fileName="#Application.webDirectory#/download/#dlFile#">
<cfset variables.encoding="UTF-8">
<cfscript>
variables.joFileWriter = createObject('Component', '/component.FileWriter').init(variables.fileName, variables.encoding, 32768);
d='accn_number,accn_status,received_from,received_date,nature_of_material,remarks,estimated_count,entered_by';
variables.joFileWriter.writeLine(d);
</cfscript>
</cfif>
<cfset i=1>
<cfif project_id gt 0>
<cfquery name="sfproj" datasource="user_login" username="#session.dbuser#" password="#decrypt(session.epw,session.sessionKey)#">
select project_name from project where project_id=#project_id#
</cfquery>
</cfif>
</cfoutput>
<table cellpadding="0" cellspacing="0">
<cfoutput query="getAccns" group="transaction_id">
<div #iif(i MOD 2,DE("class='evenRow'"),DE("class='oddRow'"))#>
<cfif #project_id# gt 0>
<a href="Project.cfm?action=addTrans&project_id=#project_id#&transaction_id=#transaction_id#">
Add Accn #accn_number#
</a>
to Project <strong>#sfproj.project_name#</strong>
<cfelse>
<a href="editAccn.cfm?action=edit&transaction_id=#transaction_id#"><strong>#guid_prefix# #accn_number#</strong></a>
<span style="font-size:smaller">(#accn_status#)</span>
</cfif>
<div style="padding-left:2em;">
Received from: <strong>#recFromAgent#</strong>
<br>Received date: <strong>#DateFormat(received_date, "yyyy-mm-dd")#</strong>
<br>Nature of Material: <strong>#nature_of_material#</strong>
<cfif len(#trans_remarks#) gt 0>
<br>Remarks: <strong>#trans_remarks#</strong>
</cfif>
<cfif len(#estimated_count#) gt 0>
<br>Estimated Count: <strong>#estimated_count#</strong>
</cfif>
<br>Entered by: <strong>#entAgent#</strong>
<cfquery name="p" dbtype="query">
select project_name,pid from getAccns where project_name is not null and
transaction_id=#transaction_id#
group by project_name,pid
</cfquery>
<CFIF #P.RECORDCOUNT# gt 0>
<br>Project(s):
<div style="padding-left:2em">
<cfloop query="p">
<a href="/Project.cfm?action=editProject&project_id=#p.pid#"><strong>#P.project_name#</strong></a><BR>
</cfloop>
</div>
</CFIF>
</div>
</div>
<cfif csv is true>
<cfset d='"#escapeDoubleQuotes(guid_prefix)# #escapeDoubleQuotes(accn_number)#"'>
<cfset d=d &',"#escapeDoubleQuotes(accn_status)#"'>
<cfset d=d &',"#escapeDoubleQuotes(recFromAgent)#"'>
<cfset d=d &',"#DateFormat(received_date, "yyyy-mm-dd")#"'>
<cfset d=d &',"#escapeDoubleQuotes(nature_of_material)#"'>
<cfset d=d &',"#escapeDoubleQuotes(trans_remarks)#"'>
<cfset d=d &',"#escapeDoubleQuotes(estimated_count)#"'>
<cfset d=d &',"#escapeDoubleQuotes(entAgent)#"'>
<cfscript>
variables.joFileWriter.writeLine(d);
</cfscript>
</cfif>
<cfset i=i+1>
</cfoutput>
<cfif csv is true>
<cfscript>
variables.joFileWriter.close();
</cfscript>
<cfoutput>
<cflocation url="/download.cfm?file=#dlFile#" addtoken="false">
</cfoutput>
</cfif>
</cfif>
<!------------------------------------------------------------------------------------------->
<cfif #action# is "delePermit">
<cfoutput>
<cfquery name="killPerm" datasource="user_login" username="#session.dbuser#" password="#decrypt(session.epw,session.sessionKey)#">
DELETE FROM permit_trans WHERE transaction_id = #transaction_id# and
permit_id=#permit_id#
</cfquery>
<cflocation url="editAccn.cfm?action=edit&transaction_id=#transaction_id#" addtoken="false">
</cfoutput>
</cfif>
<!------------------------------------------------------------------------------------------->
<cfif #action# is "saveChanges">
<cfoutput>
<cftransaction>
<!--- see if they're adding project --->
<cfif isdefined("project_id") and project_id gt 0>
<cfquery name="newProj" datasource="user_login" username="#session.dbuser#" password="#decrypt(session.epw,session.sessionKey)#">
INSERT INTO project_trans (
project_id, transaction_id)
VALUES (
#project_id#,#transaction_id#)
</cfquery>
</cfif>
<cfquery name="updateAccn" datasource="user_login" username="#session.dbuser#" password="#decrypt(session.epw,session.sessionKey)#">
UPDATE accn SET
ACCN_TYPE = '#accn_type#',
ACCN_NUMber = '#ACCN_NUMber#',
RECEIVED_DATE=to_date('#dateformat(rec_date,"yyyy-mm-dd")#'),
ACCN_STATUS = '#accn_status#'
<cfif len(estimated_count) gt 0>
,estimated_count=#estimated_count#
</cfif>
WHERE transaction_id = #transaction_id#
</cfquery>
<cfquery name="updateTrans" datasource="user_login" username="#session.dbuser#" password="#decrypt(session.epw,session.sessionKey)#">
UPDATE trans SET
transaction_id = #transaction_id#
,TRANSACTION_TYPE = 'accn',
collection_id=#collection_id#
<cfif len(#NATURE_OF_MATERIAL#) gt 0>
,NATURE_OF_MATERIAL = '#NATURE_OF_MATERIAL#'
</cfif>
<cfif len(#REMARKS#) gt 0>
,TRANS_REMARKS = '#REMARKS#'
<cfelse>
,TRANS_REMARKS = NULL
</cfif>
,CORRESP_FG=#CORRESP_FG#,
is_public_fg=#is_public_fg#
WHERE transaction_id = #transaction_id#
</cfquery>
<cfquery name="wutsThere" datasource="user_login" username="#session.dbuser#" password="#decrypt(session.epw,session.sessionKey)#">
select * from trans_agent where transaction_id=#transaction_id#
and trans_agent_role !='entered by'
</cfquery>
<cfloop query="wutsThere">
<!--- first, see if the deleted - if so, nothing else matters --->
<cfif isdefined("del_agnt_#trans_agent_id#")>
<cfquery name="wutsThere" datasource="user_login" username="#session.dbuser#" password="#decrypt(session.epw,session.sessionKey)#">
delete from trans_agent where trans_agent_id=#trans_agent_id#
</cfquery>
<cfelse>
<!--- update, just in case --->
<cfset thisAgentId = evaluate("trans_agent_id_" & trans_agent_id)>
<cfset thisRole = evaluate("trans_agent_role_" & trans_agent_id)>
<cfquery name="wutsThere" datasource="user_login" username="#session.dbuser#" password="#decrypt(session.epw,session.sessionKey)#">
update trans_agent set
agent_id = #thisAgentId#,
trans_agent_role = '#thisRole#'
where
trans_agent_id=#trans_agent_id#
</cfquery>
</cfif>
</cfloop>
<cfif isdefined("new_trans_agent_id") and len(#new_trans_agent_id#) gt 0>