forked from ArctosDB/arctos
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPermit.cfm
705 lines (675 loc) · 27.1 KB
/
Permit.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
<cfinclude template = "includes/_header.cfm">
<script>
$(document).ready(function() {
$(".reqdClr:visible").each(function(e){
$(this).prop('required',true);
});
$("input[type='date'], input[type='datetime']" ).datepicker();
});
</script>
<!--- no security --->
<cfquery name="ctPermitType" datasource="user_login" username="#session.dbuser#" password="#decrypt(session.epw,session.sessionKey)#">
select * from ctpermit_type
</cfquery>
<cfif #action# is "nothing">
<cfoutput>
Search for permits. Any part of dates and names accepted, case isn't important.<br>
Leave "until date" fields empty unless you use the field to its left.<br>
<cfform name="findPermit" action="Permit.cfm" method="post">
<input type="hidden" name="Action" value="search">
<table><tr>
<td align="right">Issued By</td>
<td><input type="text" name="IssuedByAgent"></td>
<td align="right">Issued To</td>
<td><input type="text" name="IssuedToAgent"></td>
</tr>
<tr>
<td align="right">Issued Date</td>
<td><input type="text" name="issued_date"></td>
<td align="right">Issued Until Date (leave blank otherwise)</td>
<td><input type="text" name="issued_until_date"></td>
</tr>
<tr>
<td align="right">Renewed Date</td>
<td><input type="text" name="renewed_date"></td>
<td align="right">Renewed Until Date (leave blank otherwise)</td>
<td><input type="text" name="renewed_until_date"></td>
</tr>
<tr>
<td align="right">Expiration Date</td>
<td><input type="text" name="exp_date"></td>
<td align="right">Expiration Until Date (leave blank otherwise)</td>
<td><input type="text" name="exp_until_date"></td>
</tr>
<tr>
<td align="right">Permit Type</td>
<td>
<select name="permit_type" size="1">
<option value=""></option>
<cfloop query="ctPermitType">
<option value = "#ctPermitType.permit_type#">#ctPermitType.permit_type#</option>
</cfloop>
</select>
</td>
<td align="right">Remarks</td>
<td><input type="text" name="permit_remarks"></td>
</tr>
<tr>
<td align="right">Permit Number</td>
<td><input type="text" name="permit_num"></td>
<td align="right">Contact Agent</td>
<td><input type="text" name="ContactAgent"></td>
</tr>
<tr>
<td colspan="4" align="center">
<input type="button" value="Search" class="schBtn"
onmouseover="this.className='schBtn btnhov'" onmouseout="this.className='schBtn'"
onClick="findPermit.Action.value='search';submit();">
<input type="reset" value="Clear" class="qutBtn"
onmouseover="this.className='qutBtn btnhov'" onmouseout="this.className='qutBtn'">
<input type="button" value="Create New Permit" class="insBtn"
onmouseover="this.className='insBtn btnhov'" onmouseout="this.className='insBtn'"
onClick="findPermit.Action.value='newPermit';submit();">
</td>
</tr>
</table>
</cfform>
<hr>
</cfoutput>
</cfif>
<!--------------------------------------------------------------------------->
<cfif #Action# is "search">
<cfparam name="IssuedByAgent" default="">
<cfparam name="IssuedToAgent" default="">
<cfparam name="issued_Date" default="">
<cfparam name="renewed_Date" default="">
<cfparam name="exp_Date" default="">
<cfparam name="permit_Num" default="">
<cfparam name="permit_Type" default="">
<cfparam name="permit_remarks" default="">
<cfparam name="permit_id" default="">
<cfparam name="ContactAgent" default="">
<cfoutput>
<!--- set dateformat --->
<cfif not isdefined("sql") or len(#sql#) is 0>
<!--- regular old search ---->
<cfset sql = "select permit.permit_id,
issuedBy.agent_name as IssuedByAgent,
issuedTo.agent_name as IssuedToAgent,
Contact.agent_name as ContactAgent,
issued_Date,
renewed_Date,
exp_Date,
permit_Num,
permit_Type,
permit_remarks
from
permit, preferred_agent_name issuedTo, preferred_agent_name issuedBy, preferred_agent_name Contact
where
permit.issued_by_agent_id = issuedBy.agent_id (+) and
permit.issued_to_agent_id = issuedTo.agent_id (+) and
permit.contact_agent_id = Contact.agent_id (+)">
<cfif len(#IssuedByAgent#) gt 0>
<cfset sql = "#sql# AND upper(issuedBy.agent_name) like '%#ucase(IssuedByAgent)#%'">
</cfif>
<cfif isdefined("ISSUED_BY_AGENT_ID") and len(#ISSUED_BY_AGENT_ID#) gt 0>
<cfset sql = "#sql# AND ISSUED_BY_AGENT_ID = #ISSUED_BY_AGENT_ID#">
</cfif>
<cfif isdefined("ISSUED_TO_AGENT_ID") and len(#ISSUED_TO_AGENT_ID#) gt 0>
<cfset sql = "#sql# AND ISSUED_TO_AGENT_ID = #ISSUED_TO_AGENT_ID#">
</cfif>
<cfif isdefined("CONTACT_AGENT_ID") and len(#CONTACT_AGENT_ID#) gt 0>
<cfset sql = "#sql# AND CONTACT_AGENT_ID = #CONTACT_AGENT_ID#">
</cfif>
<cfif len(#IssuedToAgent#) gt 0>
<cfset sql = "#sql# AND upper(issuedTo.agent_name) like '%#ucase(IssuedToAgent)#%'">
</cfif>
<cfif len(#issued_date#) gt 0>
<cfif len(#issued_until_date#) gt 0>
<cfset sql = "#sql# AND upper(issued_date) between to_date('#issued_date#', 'yyyy-mm-dd')
and to_date('#issued_until_date#', 'yyyy-mm-dd')">
<cfelse>
<cfset sql = "#sql# AND upper(issued_date) like to_date('#issued_date#', 'yyyy-mm-dd')">
</cfif>
</cfif>
<cfif len(#renewed_date#) gt 0>
<cfif len(#renewed_until_date#) gt 0>
<cfset sql = "#sql# AND upper(renewed_date) between to_date('#renewed_date#', 'yyyy-mm-dd')
and to_date('#renewed_until_date#', 'yyyy-mm-dd')">
<cfelse>
<cfset sql = "#sql# AND upper(renewed_date) like to_date('#renewed_date#', 'yyyy-mm-dd')">
</cfif>
</cfif>
<cfif len(#exp_date#) gt 0>
<cfif len(#exp_until_date#) gt 0>
<cfset sql = "#sql# AND upper(exp_date) between to_date('#exp_date#', 'yyyy-mm-dd')
and to_date('#exp_until_date#', 'yyyy-mm-dd')">
<cfelse>
<cfset sql = "#sql# AND upper(exp_date) like to_date('#exp_date#', 'yyyy-mm-dd')">
</cfif>
</cfif>
<cfif len(#permit_Num#) gt 0>
<cfset sql = "#sql# AND upper(permit_Num) like '%#ucase(permit_Num)#%'">
</cfif>
<cfif len(#ContactAgent#) gt 0>
<cfset sql = "#sql# AND upper(Contact.agent_name) like '%#ucase(ContactAgent)#%'
AND permit.contact_agent_id = Contact.agent_id">
</cfif>
<cfif len(#permit_type#) gt 0>
<cfset permit_Type = #replace(permit_type,"'","''","All")#>
<cfset sql = "#sql# AND permit_type = '#permit_type#'">
</cfif>
<cfif len(#permit_remarks#) gt 0>
<cfset sql = "#sql# AND upper(permit_remarks) like '%#ucase(permit_remarks)#%'">
</cfif>
<cfif len(#permit_id#) gt 0>
<cfset sql = "#sql# AND permit_id = #permit_id#">
</cfif>
<cfif #sql# is "select * from permit, agent_name issuedTo, agent_name issuedBy where permit.issued_by_agent_id = issuedBy.agent_id and permit.issued_to_agent_id = issuedTo.agent_id ">
Enter some criteria.<cfabort>
</cfif>
<cfset thisSql = #sql#>
<cfelse><!--- came in with sql defined ---->
<cfset thisSql = "#sql# ORDER BY #order_by# #order_order#">
</cfif><!--- end sql isdefined --->
<cfquery name="matchPermit" datasource="user_login" username="#session.dbuser#" password="#decrypt(session.epw,session.sessionKey)#">
#preservesinglequotes(thisSql)#
</cfquery>
<table border>
<tr>
<form name="reorder" method="post" action="Permit.cfm">
<input type="hidden" name="sql" value="#sql#">
<input type="hidden" name="action" value="search">
<input type="hidden" name="order_by">
<input type="hidden" name="order_order">
<td>
<strong>Permit Number</strong>
<cfset thisTerm = "permit_num">
<cfset thisName = #replace(thisTerm,",","_","all")#>
<br>
<a href="javascript: void"
onClick="reorder.order_by.value='#thisTerm#';reorder.order_order.value='asc';reorder.submit();"
onMouseOver="self.status='Sort Ascending.';#thisName#up.src='/images/up_mo.gif';return true;"
onmouseout="self.status='';#thisName#up.src='/images/up.gif';return true;">
<img src="/images/up.gif" border="0" name="#thisName#up"></a>
<a href="javascript: void"
onClick="reorder.order_by.value='#thisTerm#';reorder.order_order.value='desc';reorder.submit();"
onMouseOver="self.status='Sort Descending.';#thisName#dn.src='/images/down_mo.gif';return true;"
onmouseout="self.status='';#thisName#dn.src='/images/down.gif';return true;">
<img src="/images/down.gif" border="0" name="#thisName#dn"></a>
</td>
<td>
<strong>Permit Type</strong>
<cfset thisTerm = "permit_Type">
<cfset thisName = #replace(thisTerm,",","_","all")#>
<br>
<a href="javascript: void"
onClick="reorder.order_by.value='#thisTerm#';reorder.order_order.value='asc';reorder.submit();"
onMouseOver="self.status='Sort Ascending.';#thisName#up.src='/images/up_mo.gif';return true;"
onmouseout="self.status='';#thisName#up.src='/images/up.gif';return true;">
<img src="/images/up.gif" border="0" name="#thisName#up"></a>
<a href="javascript: void"
onClick="reorder.order_by.value='#thisTerm#';reorder.order_order.value='desc';reorder.submit();"
onMouseOver="self.status='Sort Descending.';#thisName#dn.src='/images/down_mo.gif';return true;"
onmouseout="self.status='';#thisName#dn.src='/images/down.gif';return true;">
<img src="/images/down.gif" border="0" name="#thisName#dn"></a>
</td>
<td>
<strong>Issued To</strong>
<cfset thisTerm = "IssuedToAgent">
<cfset thisName = #replace(thisTerm,",","_","all")#>
<br>
<a href="javascript: void"
onClick="reorder.order_by.value='#thisTerm#';reorder.order_order.value='asc';reorder.submit();"
onMouseOver="self.status='Sort Ascending.';#thisName#up.src='/images/up_mo.gif';return true;"
onmouseout="self.status='';#thisName#up.src='/images/up.gif';return true;">
<img src="/images/up.gif" border="0" name="#thisName#up"></a>
<a href="javascript: void"
onClick="reorder.order_by.value='#thisTerm#';reorder.order_order.value='desc';reorder.submit();"
onMouseOver="self.status='Sort Descending.';#thisName#dn.src='/images/down_mo.gif';return true;"
onmouseout="self.status='';#thisName#dn.src='/images/down.gif';return true;">
<img src="/images/down.gif" border="0" name="#thisName#dn"></a>
</td>
<td>
<strong>Issued By</strong>
<cfset thisTerm = "IssuedByAgent">
<cfset thisName = #replace(thisTerm,",","_","all")#>
<br>
<a href="javascript: void"
onClick="reorder.order_by.value='#thisTerm#';reorder.order_order.value='asc';reorder.submit();"
onMouseOver="self.status='Sort Ascending.';#thisName#up.src='/images/up_mo.gif';return true;"
onmouseout="self.status='';#thisName#up.src='/images/up.gif';return true;">
<img src="/images/up.gif" border="0" name="#thisName#up"></a>
<a href="javascript: void"
onClick="reorder.order_by.value='#thisTerm#';reorder.order_order.value='desc';reorder.submit();"
onMouseOver="self.status='Sort Descending.';#thisName#dn.src='/images/down_mo.gif';return true;"
onmouseout="self.status='';#thisName#dn.src='/images/down.gif';return true;">
<img src="/images/down.gif" border="0" name="#thisName#dn"></a>
</td>
<td>
<strong>Issued Date</strong>
<cfset thisTerm = "issued_Date">
<cfset thisName = #replace(thisTerm,",","_","all")#>
<br>
<a href="javascript: void"
onClick="reorder.order_by.value='#thisTerm#';reorder.order_order.value='asc';reorder.submit();"
onMouseOver="self.status='Sort Ascending.';#thisName#up.src='/images/up_mo.gif';return true;"
onmouseout="self.status='';#thisName#up.src='/images/up.gif';return true;">
<img src="/images/up.gif" border="0" name="#thisName#up"></a>
<a href="javascript: void"
onClick="reorder.order_by.value='#thisTerm#';reorder.order_order.value='desc';reorder.submit();"
onMouseOver="self.status='Sort Descending.';#thisName#dn.src='/images/down_mo.gif';return true;"
onmouseout="self.status='';#thisName#dn.src='/images/down.gif';return true;">
<img src="/images/down.gif" border="0" name="#thisName#dn"></a>
</td>
<td>
<strong>Renewed Date</strong>
<cfset thisTerm = "renewed_Date">
<cfset thisName = #replace(thisTerm,",","_","all")#>
<br>
<a href="javascript: void"
onClick="reorder.order_by.value='#thisTerm#';reorder.order_order.value='asc';reorder.submit();"
onMouseOver="self.status='Sort Ascending.';#thisName#up.src='/images/up_mo.gif';return true;"
onmouseout="self.status='';#thisName#up.src='/images/up.gif';return true;">
<img src="/images/up.gif" border="0" name="#thisName#up"></a>
<a href="javascript: void"
onClick="reorder.order_by.value='#thisTerm#';reorder.order_order.value='desc';reorder.submit();"
onMouseOver="self.status='Sort Descending.';#thisName#dn.src='/images/down_mo.gif';return true;"
onmouseout="self.status='';#thisName#dn.src='/images/down.gif';return true;">
<img src="/images/down.gif" border="0" name="#thisName#dn"></a>
</td>
<td>
<strong>Expires Date</strong>
<br>
<cfset thisTerm = "exp_Date">
<cfset thisName = #replace(thisTerm,",","_","all")#>
<a href="javascript: void"
onClick="reorder.order_by.value='#thisTerm#';reorder.order_order.value='asc';reorder.submit();"
onMouseOver="self.status='Sort Ascending.';#thisName#up.src='/images/up_mo.gif';return true;"
onmouseout="self.status='';#thisName#up.src='/images/up.gif';return true;">
<img src="/images/up.gif" border="0" name="#thisName#up"></a>
<a href="javascript: void"
onClick="reorder.order_by.value='#thisTerm#';reorder.order_order.value='desc';reorder.submit();"
onMouseOver="self.status='Sort Descending.';#thisName#dn.src='/images/down_mo.gif';return true;"
onmouseout="self.status='';#thisName#dn.src='/images/down.gif';return true;">
<img src="/images/down.gif" border="0" name="#thisName#dn"></a>
</td>
<td><strong>Remarks</strong></td>
<td>
<strong>Contact</strong>
<br>
<cfset thisTerm = "ContactAgent">
<cfset thisName = #replace(thisTerm,",","_","all")#>
<a href="javascript: void"
onClick="reorder.order_by.value='#thisTerm#';reorder.order_order.value='asc';reorder.submit();"
onMouseOver="self.status='Sort Ascending.';#thisName#up.src='/images/up_mo.gif';return true;"
onmouseout="self.status='';#thisName#up.src='/images/up.gif';return true;">
<img src="/images/up.gif" border="0" name="#thisName#up"></a>
<a href="javascript: void"
onClick="reorder.order_by.value='#thisTerm#';reorder.order_order.value='desc';reorder.submit();"
onMouseOver="self.status='Sort Descending.';#thisName#dn.src='/images/down_mo.gif';return true;"
onmouseout="self.status='';#thisName#dn.src='/images/down.gif';return true;">
<img src="/images/down.gif" border="0" name="#thisName#dn"></a>
</td>
<td> </td>
</form>
</tr>
</cfoutput>
<a href="Permit.cfm">Search Again</a>
<cfoutput query="matchPermit" group="permit_id">
<cfif len(#exp_Date#) gt 0>
<cfset ExpiresInDays = #datediff("d",now(),exp_Date)#>
<cfif ExpiresInDays lt 0>
<cfset tabCol = "##666666">
<cfelseif ExpiresInDays lt 10>
<cfset tabCol = "##FF0000">
<cfelseif ExpiresInDays lt 30>
<cfset tabCol = "##FF8040">
<cfelseif ExpiresInDays lt 180>
<cfset tabCol = "##FFFF00">
<cfelseif ExpiresInDays gte 180>
<cfset tabCol = "##00FF00">
<cfelse>
<cfset tabCol = "##FFFFFF">
</cfif>
<cfelse>
<!--- there's a permit with no exp date - treat this as bad! --->
<cfset tabCol = "##FF0000">
</cfif>
<tr>
<td>#permit_Num#</td>
<td>#permit_Type#</td>
<td>#IssuedToAgent#</td>
<td>#IssuedByAgent#</td>
<td>#dateformat(issued_Date,"yyyy-mm-dd")#</td>
<td>#dateformat(renewed_Date,"yyyy-mm-dd")#</td>
<td style="background-color:#tabCol#; ">
#dateformat(exp_Date,"yyyy-mm-dd")#
<cfif len(#exp_Date#) is 0>
not given!
<cfelseif #ExpiresInDays# lt 0>
<font size="-2"><br>(expired)</font>
<cfelse>
<font size="-2"><br>(exp in #ExpiresInDays# d.)</font>
</cfif>
</td>
<td>#permit_remarks#</td>
<td>#contactAgent#</td>
<td>
<form action="Permit.cfm" method="post" name="Copy">
<input type="hidden" name="permit_id" value="#permit_id#">
<input type="hidden" name="Action" value="editPermit">
<input type="submit" value="Edit this permit" class="lnkBtn"
onmouseover="this.className='lnkBtn btnhov'" onmouseout="this.className='lnkBtn'">
</form>
<form action="editAccn.cfm" method="post">
<input type="hidden" name="permit_id" value="#permit_id#">
<input type="hidden" name="Action" value="findAccessions">
<input type="submit" value="Accession List" class="lnkBtn"
onmouseover="this.className='lnkBtn btnhov'" onmouseout="this.className='lnkBtn'">
</form>
<form action="Reports/permit.cfm" method="post">
<input type="hidden" name="permit_id" value="#permit_id#">
<input type="submit" value="Permit Report" class="lnkBtn"
onmouseover="this.className='lnkBtn btnhov'" onmouseout="this.className='lnkBtn'">
</form>
</td>
</tr>
</cfoutput>
</table>
</cfif>
<!--------------------------------------------------------------------------->
<!--------------------------------------------------------------------------->
<cfif #Action# is "newPermit">
<font size="+1"><strong>New Permit</strong></font><br>
<cfoutput>
<cfform name="newPermit" action="Permit.cfm" method="post">
<input type="hidden" name="Action" value="createPermit">
<table>
<tr>
<td>Issued By</td>
<td colspan="3">
<input type="hidden" name="IssuedByAgentId">
<input type="text" name="IssuedByAgent" class="reqdClr" size="50"
onchange="getAgent('IssuedByAgentId','IssuedByAgent','newPermit',this.value); return false;"
onKeyUp="return noenter();">
</td>
</tr>
<tr>
<td>Issued To</td>
<td colspan="3">
<input type="hidden" name="IssuedToAgentId">
<input type="text" name="IssuedToAgent" class="reqdClr" size="50"
onchange="getAgent('IssuedToAgentId','IssuedToAgent','newPermit',this.value); return false;"
onKeyUp="return noenter();">
</td>
</tr>
<tr>
<td>Contact Person</td>
<td colspan="3">
<input type="hidden" name="contact_agent_id">
<input type="text" name="ContactAgent" size="50"
onchange="getAgent('contact_agent_id','ContactAgent','newPermit',this.value); return false;"
onKeyUp="return noenter();">
</td>
</tr>
<tr>
<td>Issued Date</td>
<td><input type="text" name="issued_Date"></td>
<td>Renewed Date</td>
<td><input type="text" name="renewed_Date"></td>
</tr>
<tr>
<td>Expiration Date</td>
<td><input type="text" name="exp_Date"></td>
<td>Permit Number</td>
<td><input type="text" name="permit_Num"></td>
</tr>
<tr>
<td>Permit Type</td>
<td>
<select name="permit_Type" size="1" class="reqdClr">
<option value=""></option>
<cfloop query="ctPermitType">
<option value = "#ctPermitType.permit_type#">#ctPermitType.permit_type#</option>
</cfloop>
</select>
</td>
<td>Remarks</td>
<td><input type="text" name="permit_remarks"></td>
</tr>
<tr>
<td colspan="4" align="center">
<input type="submit" value="Save this permit" class="insBtn"
onmouseover="this.className='insBtn btnhov'" onmouseout="this.className='insBtn'">
<input type="button" value="Quit" class="qutBtn"
onmouseover="this.className='qutBtn btnhov'" onmouseout="this.className='qutBtn'"
onClick="document.location='Permit.cfm'">
</td>
</tr>
</table>
</cfform>
</cfoutput>
</cfif>
<!--------------------------------------------------------------------------------------------------->
<!--------------------------------------------------------------------------------------------------->
<cfif #Action# is "editPermit">
<font size="+1"><strong>Edit Permit</strong></font><br>
<cfoutput>
<cfif not isdefined("permit_id") OR len(#permit_id#) is 0>
Something bad happened. You didn't pass this form a permit_id. Go back and try again.<cfabort>
</cfif>
<cfquery name="permitInfo" datasource="user_login" username="#session.dbuser#" password="#decrypt(session.epw,session.sessionKey)#">
select permit.permit_id,
issuedBy.agent_name as IssuedByAgent,
issuedBy.agent_id as IssuedByAgentID,
issuedTo.agent_name as IssuedToAgent,
issuedTo.agent_id as IssuedToAgentID,
contact_agent_id,
contact.agent_name as ContactAgent,
issued_Date,
renewed_Date,
exp_Date,
permit_Num,
permit_Type,
permit_remarks
from
permit,
preferred_agent_name issuedTo,
preferred_agent_name issuedBy ,
preferred_agent_name contact
where
permit.issued_by_agent_id = issuedBy.agent_id (+) and
permit.issued_to_agent_id = issuedTo.agent_id (+) AND
permit.contact_agent_id = contact.agent_id (+)
and permit_id=#permit_id#
order by permit_id
</cfquery>
</cfoutput>
<cfoutput query="permitInfo" group="permit_id">
<cfform name="newPermit" action="Permit.cfm" method="post">
<input type="hidden" name="Action">
<input type="hidden" name="permit_id" value="#permit_id#">
<table>
<tr>
<td>Issued By</td>
<td colspan="3">
<input type="hidden" name="IssuedByAgentId">
<input type="hidden" name="IssuedByOldAgentId" value="#IssuedByAgentID#">
<input type="text" name="IssuedByAgent" class="reqdClr" size="50"
value="#IssuedByAgent#"
onchange="getAgent('IssuedByAgentId','IssuedByAgent','newPermit',this.value); return false;"
onKeyUp="return noenter();">
</td>
</tr>
<tr>
<td>Issued To</td>
<td colspan="3">
<input type="hidden" name="IssuedToAgentId">
<input type="text" name="IssuedToAgent" class="reqdClr" size="50"
value="#IssuedToAgent#"
onchange="getAgent('IssuedToAgentId','IssuedToAgent','newPermit',this.value); return false;"
onKeyUp="return noenter();">
</td>
</tr>
<tr>
<td>Contact Person</td>
<td colspan="3">
<input type="hidden" name="contact_agent_id" value="#contact_agent_id#">
<input type="text" name="ContactAgent" class="reqdClr" size="50" value="#ContactAgent#"
onchange="getAgent('contact_agent_id','ContactAgent','newPermit',this.value); return false;"
onKeyUp="return noenter();">
</td>
</tr>
<tr>
<td>Issued Date</td>
<td><input type="datetime" name="issued_Date" value="#dateformat(issued_Date,"yyyy-mm-dd")#"></td>
<td>Renewed Date</td>
<td><input type="datetime" name="renewed_Date" value="#dateformat(renewed_Date,"yyyy-mm-dd")#"></td>
</tr>
<tr>
<td>Expiration Date</td>
<td><input type="datetime" name="exp_Date" value="#dateformat(exp_Date,"yyyy-mm-dd")#"></td>
<td>Permit Number</td>
<td><input type="text" name="permit_Num" value="#permit_Num#"></td>
</tr>
<tr>
<td>Permit Type</td>
<td>
<select name="permit_Type" size="1">
<option value=""></option>
<cfloop query="ctPermitType">
<option <cfif #ctPermitType.permit_type# is "#permitInfo.permit_type#"> selected </cfif>value = "#ctPermitType.permit_type#">#ctPermitType.permit_type#</option>
</cfloop>
</select>
</td>
<td>Remarks</td>
<td><input type="text" name="permit_remarks" value="#permit_remarks#"></td>
</tr>
<tr>
<td colspan="4" align="center">
<input type="submit" value="Save changes" class="savBtn"
onmouseover="this.className='savBtn btnhov'" onmouseout="this.className='savBtn'"
onCLick="newPermit.Action.value='saveChanges';">
<input type="button" value="Quit" class="qutBtn"
onmouseover="this.className='qutBtn btnhov'" onmouseout="this.className='qutBtn'"
onClick="document.location='Permit.cfm'">
<input type="button" value="Delete" class="delBtn"
onmouseover="this.className='delBtn btnhov'" onmouseout="this.className='delBtn'"
onCLick="newPermit.Action.value='deletePermit';confirmDelete('newPermit');">
</td>
</tr>
</table>
</cfform>
</cfoutput>
</cfif>
<!--------------------------------------------------------------------------------------------------->
<!--------------------------------------------------------------------------------------------------->
<cfif #Action# is "saveChanges">
<cfoutput>
<cfquery name="updatePermit" datasource="user_login" username="#session.dbuser#" password="#decrypt(session.epw,session.sessionKey)#">
UPDATE permit SET
permit_id = #permit_id#
<cfif len(#issuedByAgentId#) gt 0>
,ISSUED_BY_AGENT_ID = #issuedByAgentId#
</cfif>
<cfif len(#ISSUED_DATE#) gt 0>
,ISSUED_DATE = '#ISSUED_DATE#'
</cfif>
<cfif len(#IssuedToAgentId#) gt 0>
,ISSUED_TO_AGENT_ID = #IssuedToAgentId#
</cfif>
<cfif len(#RENEWED_DATE#) gt 0>
,RENEWED_DATE = '#RENEWED_DATE#'
</cfif>
<cfif len(#EXP_DATE#) gt 0>
,EXP_DATE = '#EXP_DATE#'
</cfif>
<cfif len(#PERMIT_NUM#) gt 0>
,PERMIT_NUM = '#PERMIT_NUM#'
</cfif>
<cfif len(#PERMIT_TYPE#) gt 0>
,PERMIT_TYPE = '#PERMIT_TYPE#'
</cfif>
<cfif len(#PERMIT_REMARKS#) gt 0>
,PERMIT_REMARKS = '#PERMIT_REMARKS#'
</cfif>
<cfif len(#contact_agent_id#) gt 0>
,contact_agent_id = #contact_agent_id#
<cfelse>
,contact_agent_id = null
</cfif>
where permit_id = #permit_id#
</cfquery>
<cflocation url="Permit.cfm?Action=editPermit&permit_id=#permit_id#">
</cfoutput>
</cfif>
<!--------------------------------------------------------------------------------------------------->
<!--------------------------------------------------------------------------------------------------->
<cfif #Action# is "createPermit">
<cfoutput>
<cfquery name="nextPermit" datasource="user_login" username="#session.dbuser#" password="#decrypt(session.epw,session.sessionKey)#">
select sq_permit_id.nextval nextPermit from dual
</cfquery>
<cfquery name="newPermit" datasource="user_login" username="#session.dbuser#" password="#decrypt(session.epw,session.sessionKey)#">
INSERT INTO permit (
PERMIT_ID,
ISSUED_BY_AGENT_ID
<cfif len(#ISSUED_DATE#) gt 0>
,ISSUED_DATE
</cfif>
,ISSUED_TO_AGENT_ID
<cfif len(#RENEWED_DATE#) gt 0>
,RENEWED_DATE
</cfif>
<cfif len(#EXP_DATE#) gt 0>
,EXP_DATE
</cfif>
<cfif len(#PERMIT_NUM#) gt 0>
,PERMIT_NUM
</cfif>
,PERMIT_TYPE
<cfif len(#PERMIT_REMARKS#) gt 0>
,PERMIT_REMARKS
</cfif>
<cfif len(#contact_agent_id#) gt 0>
,contact_agent_id
</cfif>)
VALUES (
#nextPermit.nextPermit#,
#IssuedByAgentId#
<cfif len(#ISSUED_DATE#) gt 0>
,'#dateformat(ISSUED_DATE,"yyyy-mm-dd")#'
</cfif>
,#IssuedToAgentId#
<cfif len(#RENEWED_DATE#) gt 0>
,'#dateformat(RENEWED_DATE,"yyyy-mm-dd")#'
</cfif>
<cfif len(#EXP_DATE#) gt 0>
,'#dateformat(EXP_DATE,"yyyy-mm-dd")#'
</cfif>
<cfif len(#PERMIT_NUM#) gt 0>
,'#PERMIT_NUM#'
</cfif>
,'#PERMIT_TYPE#'
<cfif len(#PERMIT_REMARKS#) gt 0>
<cfset remarks = #replace(permit_remarks,"'","''")#>
,'#remarks#'
</cfif>
<cfif len(#contact_agent_id#) gt 0>
,#contact_agent_id#
</cfif>)
</cfquery>
<cflocation url="Permit.cfm?Action=editPermit&permit_id=#nextPermit.nextPermit#">
</cfoutput>
</cfif>
<!--------------------------------------------------------------------------------------------------->
<cfif #Action# is "deletePermit">
<cfoutput>
<cfquery name="deletePermit" datasource="user_login" username="#session.dbuser#" password="#decrypt(session.epw,session.sessionKey)#">
DELETE FROM permit WHERE permit_id = #permit_id#
</cfquery>
<cflocation url="Permit.cfm">
</cfoutput>
</cfif>
<cfinclude template = "includes/_footer.cfm">