-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcheckContainerMovement.cfm
469 lines (436 loc) · 17.4 KB
/
checkContainerMovement.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">
<style>
.good{background-color:#00FF00;}
.mebbe{background-color:#FFFF00;}
.bad{background-color:#FF0000;}
</style>
<!----
checks containers in table cf_temp_container_location,
which must be populated prior to calling this application,
for validity, availability, etc.
Include it with a cfinclude tag
---->
<!---- get the scans we care about ---->
<cfif #action# is "makeParentLabelsUnknown">
<cfquery name="isParentLabel" datasource="user_login" username="#session.dbuser#" password="#decrypt(session.epw,session.sessionKey)#">
select container_type,container.container_id
from cf_temp_container_location,container
where container.container_id = cf_temp_container_location.parent_container_id
and upper(container_type) like '%LABEL%'
</cfquery>
<cfoutput>
<cfloop query="isParentLabel">
<cfquery name="upCont" datasource="user_login" username="#session.dbuser#" password="#decrypt(session.epw,session.sessionKey)#">
update container set container_type='unknown'
where container_id=#container_id#
</cfquery>
</cfloop>
<cflocation url="checkContainerMovement.cfm" addtoken="no">
</cfoutput>
</cfif>
<!---------------------------------------------------->
<cfif #action# is "deleteSelected">
<cfoutput>
<cfloop list="#delPair#" delimiters="," index="p">
#p#<br />
<cfset cid = listgetat(p,1,"|")>
<cfset pid = listgetat(p,2,"|")>
<cfset ts = listgetat(p,3,"|")>
<cfquery name="DIE" datasource="user_login" username="#session.dbuser#" password="#decrypt(session.epw,session.sessionKey)#">
delete from cf_temp_container_location where
container_id=#cid# and
parent_container_id=#pid# and
timestamp='to_date(#ts#)'
</cfquery>
</cfloop>
<cflocation url="checkContainerMovement.cfm" addtoken="no">
</cfoutput>
</cfif>
<!---------------------------------------------------->
<cfif #action# is "loadEverything">
<cftry>
<cftransaction>
<cfquery name="data" datasource="user_login" username="#session.dbuser#" password="#decrypt(session.epw,session.sessionKey)#">
select * from cf_temp_container_location
</cfquery>
<cfloop query="data">
<cfquery name="insThis" datasource="user_login" username="#session.dbuser#" password="#decrypt(session.epw,session.sessionKey)#">
UPDATE
container
SET
parent_container_id = #parent_container_id#
WHERE
container_id=#container_id#
</cfquery>
</cfloop>
</cftransaction>
<cflocation url="checkContainerMovement.cfm" addtoken="no">
<cfcatch>
Yikes! Something hinky happened.
<cfoutput>
<p>#cfcatch.Message#
<br />#cfcatch.Detail#
</p>
</cfoutput>
</cfcatch>
</cftry>
</cfif>
<!---------------------------------------------------->
<cfif #action# is "deleteEverything">
<cfquery name="diediedie" datasource="user_login" username="#session.dbuser#" password="#decrypt(session.epw,session.sessionKey)#">
delete from cf_temp_container_location
</cfquery>
<cflocation url="checkContainerMovement.cfm" addtoken="no">
</cfif>
<!----------------------------------------------------------------------------------->
<cfif #action# is "deleteLoaded">
<cfquery name="delAlreadyLoaded" datasource="user_login" username="#session.dbuser#" password="#decrypt(session.epw,session.sessionKey)#">
delete from cf_temp_container_location where (
container_id,
parent_container_id,
to_char(timestamp,'yyyy-mm-ddTHH24:MI:SS'))
IN (
select container_id,
parent_container_id,
to_char(parent_install_date,'yyyy-mm-ddTHH24:MI:SS')
FROM container
)
</cfquery>
<cflocation url="checkContainerMovement.cfm">
</cfif>
<!----------------------------------------------------------------------------------->
<cfif #action# is "makeChildLabelsUnknown">
<cfquery name="isChildLabel" datasource="user_login" username="#session.dbuser#" password="#decrypt(session.epw,session.sessionKey)#">
select
container_type,
container.container_id,
label
from cf_temp_container_location,container
where container.container_id = cf_temp_container_location.container_id
and upper(container_type) like '%LABEL%'
</cfquery>
<cfoutput>
<cfloop query="isChildLabel">
<cfquery name="upCont" datasource="user_login" username="#session.dbuser#" password="#decrypt(session.epw,session.sessionKey)#">
update container set container_type='#container_type#'
where container_id=#container_id#
</cfquery>
</cfloop>
<cflocation url="checkContainerMovement.cfm">
</cfoutput>
</cfif>
<!----------------------------------------------------------------------------------->
<cfif #action# is "nothing">
<cfset thisIsBad = "">
<cfoutput>
<!--- kill true duplicates --->
<cftry>
<cfquery name="byenow" datasource="user_login" username="#session.dbuser#" password="#decrypt(session.epw,session.sessionKey)#">
drop table cf_temp_container_location_two
</cfquery>
<cfcatch>bahhh</cfcatch>
</cftry>
<cftransaction>
<cfquery name="bethere" datasource="user_login" username="#session.dbuser#" password="#decrypt(session.epw,session.sessionKey)#">
create table cf_temp_container_location_two as select * from cf_temp_container_location
</cfquery>
<cfquery name="beGone" datasource="user_login" username="#session.dbuser#" password="#decrypt(session.epw,session.sessionKey)#">
delete from cf_temp_container_location
</cfquery>
<cfquery name="noDups" datasource="user_login" username="#session.dbuser#" password="#decrypt(session.epw,session.sessionKey)#">
insert into cf_temp_container_location (
CONTAINER_ID,
PARENT_CONTAINER_ID,
TIMESTAMP)
select
CONTAINER_ID,
PARENT_CONTAINER_ID,
TIMESTAMP
FROM
cf_temp_container_location_two
group by CONTAINER_ID,
PARENT_CONTAINER_ID,
TIMESTAMP
</cfquery>
</cftransaction>
<cfquery name="ctcontainer_type" datasource="user_login" username="#session.dbuser#" password="#decrypt(session.epw,session.sessionKey)#">
select container_type from ctcontainer_type
where container_type <> 'collection object'
</cfquery>
<cfquery name="isChildLabel" datasource="user_login" username="#session.dbuser#" password="#decrypt(session.epw,session.sessionKey)#">
select
container_type,
container.container_id,
label
from cf_temp_container_location,container
where container.container_id = cf_temp_container_location.container_id
and upper(container_type) like '%LABEL%'
</cfquery>
<cfif #isChildLabel.recordcount# gt 0>
<cfset thisIsBad = "bad">
<div class="bad">
The following child containers are labels:
<cfloop query="isChildLabel">
<br />
<a href="EditContainer.cfm?container_id=#container_id#">#label# (#container_type#)</a>
</cfloop>
<p>
Read the data above. Really! Check a couple of them. If there are only a few and you know what they should be,
change them.
</p>
</div>
<div class="mebbe">
Change all these containers to type:
<form name="newType" method="post" action="checkContainerMovement.cfm">
<input type="hidden" name="action" value="makeChildLabelsUnknown" />
<select name="container_type" size="1">
<cfloop query="ctcontainer_type">
<option value="#container_type#">#container_type#</option>
</cfloop>
</select>
<input type="submit" value="Change All" class="savBtn"
onmouseover="this.className='savBtn btnhov'" onmouseout="this.className='savBtn'">
</form>
</form>
</div>
<cfelse>
<div class="good">
There are no child containers of type label.
</div>
</cfif>
<hr />
<cfquery name="isParentLabel" datasource="user_login" username="#session.dbuser#" password="#decrypt(session.epw,session.sessionKey)#">
select container_type,container.container_id,label
from cf_temp_container_location,container
where container.container_id = cf_temp_container_location.parent_container_id
and upper(container_type) like '%LABEL%'
</cfquery>
<cfif #isParentLabel.recordcount# gt 0>
<cfset thisIsBad = "bad">
<div class="bad">
<br />The following parent containers are labels:
<cfloop query="isParentLabel">
<br />
<a href="EditContainer.cfm?container_id=#container_id#">#isParentLabel.label# (#isParentLabel.container_type#)</a>
</cfloop>
<p>
Read the data above. Really! Check a couple of them. If there are only a few and you know what they should be,
change them.
</p>
</div>
<div class="mebbe">
If you're really really sure you want to, <a href="checkContainerMovement.cfm?action=makeParentLabelsUnknown">click here</a>
to change them all to containers_type='unknown'.
</div>
<cfelse>
<div class="good">
There are no parent containers of type label.
</div>
</cfif>
<hr />
<cfquery name="dups" datasource="user_login" username="#session.dbuser#" password="#decrypt(session.epw,session.sessionKey)#">
select
CONTAINER_ID,
count(CONTAINER_ID)
from cf_temp_container_location
having count(CONTAINER_ID) > 1
group by CONTAINER_ID
</cfquery>
<br />There are #dups.recordcount# duplicate child records in cf_temp_container_location.
<cfset dupId = valuelist(dups.container_id)>
<cfif #dups.recordcount# gt 0>
You may continue, but there are no guarantees about where they'll end up! Locations are NOT sorted by date.
<cfquery name="dupDetail" datasource="user_login" username="#session.dbuser#" password="#decrypt(session.epw,session.sessionKey)#">
select
CONTAINER_ID,
get_container_barcode(container_id) child_barcode,
parent_container_id,
get_container_barcode(parent_container_id) parent_barcode,
timestamp
from cf_temp_container_location
where container_id IN (#dupId#)
order by container_id, timestamp
</cfquery>
<table border>
<tr>
<td>Parent barcode</td>
<td>Duplicate Child barcode</td>
<td>Timestamp</td>
</tr>
<cfloop query="dupDetail">
<tr>
<td><a href="EditContainer.cfm?container_id=#parent_container_id#">#parent_barcode#</a></td>
<td><a href="EditContainer.cfm?container_id=#CONTAINER_ID#">#child_barcode#</a></td>
<td>#dateformat(timestamp,"yyyy-mm-dd")# #timeformat(timestamp,"hh:mm:ss")#</td>
</tr>
</cfloop>
</table>
</cfif>
<hr />
<cfquery name="howMany" datasource="user_login" username="#session.dbuser#" password="#decrypt(session.epw,session.sessionKey)#">
SELECT container_id, parent_container_id, timestamp FROM cf_temp_container_location
group by
container_id, parent_container_id, timestamp
</cfquery>
<cfquery name="isMatches" datasource="user_login" username="#session.dbuser#" password="#decrypt(session.epw,session.sessionKey)#">
select
cf_temp_container_location.container_id,
cf_temp_container_location.parent_container_id,
to_char(cf_temp_container_location.timestamp,'yyyy-mm-ddTHH24:MI:SS') timestamp,
get_container_barcode(cf_temp_container_location.container_id) child_barcode,
get_container_barcode(cf_temp_container_location.parent_container_id) parent_barcode
FROM
cf_temp_container_location,
container
WHERE
cf_temp_container_location.container_id = container.container_id AND
cf_temp_container_location.parent_container_id = container.parent_container_id AND
to_char(cf_temp_container_location.timestamp,'yyyy-mm-ddTHH24:MI:SS') = to_char(container.parent_install_date,'DD-MON-YYYY HH24:MI:SS')
GROUP BY
cf_temp_container_location.container_id,
cf_temp_container_location.parent_container_id,
to_char(cf_temp_container_location.timestamp,'yyyy-mm-ddTHH24:MI:SS'),
get_container_barcode(cf_temp_container_location.container_id) ,
get_container_barcode(cf_temp_container_location.parent_container_id)
</cfquery>
There are <strong>#howMany.recordcount#</strong> unique values in table cf_temp_container_location.
<strong>#isMatches.recordcount#</strong> of these are already loaded.
<cfif #isMatches.recordcount# gt 0>
<form name="remLoaded" method="post" action="checkContainerMovement.cfm">
<input type="hidden" name="action" value="deleteLoaded" />
<input type="submit" value="Delete Loaded Records" class="delBtn"
onmouseover="this.className='delBtn btnhov'" onmouseout="this.className='delBtn'">
</form>
<form name="d" method="post" action="checkContainerMovement.cfm">
<input type="hidden" name="action" value="deleteSelected" />
<table border>
<tr>
<td>Parent</td>
<td>Child</td>
<td>Date</td>
<td>Die Die Die</td>
</tr>
<cfloop query="isMatches">
<tr>
<td>#parent_barcode#</td>
<td>#child_barcode#</td>
<td>#timestamp#</td>
<td>
<input type="checkbox" name="delPair" value="#container_id#|#parent_container_id#|#timestamp#" />
</td>
</tr>
</cfloop>
</table>
<input type="submit" value="Delete Checked" class="delBtn"
onmouseover="this.className='delBtn btnhov'" onmouseout="this.className='delBtn'">
</form>
</cfif>
<hr />
</cfoutput>
<br />
<p>Potential Errors in Data: (Note: this table does NOT include errors listed above.)</p>
<table border>
<tr>
<td>Parent barcode</td>
<td>Child barcode</td>
<td>Problem</td>
<td>Delete</td>
</tr>
<cfset globalError = "">
<cfquery name="scans" datasource="user_login" username="#session.dbuser#" password="#decrypt(session.epw,session.sessionKey)#">
SELECT container_id, parent_container_id,
to_char(timestamp,'yyyy-mm-ddTHH24:MI:SS') timestamp
FROM cf_temp_container_location
group by
container_id, parent_container_id, timestamp
</cfquery>
<form name="d_tab" method="post" action="checkContainerMovement.cfm">
<input type="hidden" name="action" value="deleteSelected" />
<cfoutput query="scans">
<cfset error="">
<!--- we already have container_ids and a timestamp in date format;
don't worry about checking that ---->
<!--- get container info and check standard stoopidity ---->
<cfquery name="child" datasource="user_login" username="#session.dbuser#" password="#decrypt(session.epw,session.sessionKey)#">
select * from container where container_id = #container_id#
</cfquery>
<cfquery name="parent" datasource="user_login" username="#session.dbuser#" password="#decrypt(session.epw,session.sessionKey)#">
select * from container where container_id = #parent_container_id#
</cfquery>
<!---- see how the dimensions work.
Ignore it unless there's a dimension for each container
----->
<cfif len(#child.width#) gt 0 and len(#parent.width#) gt 0>
<cfif #child.width# gte #parent.width#>
<cfset thisIsBad = "bad">
<cfset error = "#error#; The child width is greater than the parent">
</cfif>
</cfif>
<cfif len(#child.length#) gt 0 and len(#parent.length#) gt 0>
<cfif #child.length# gte #parent.length#>
<cfset thisIsBad = "bad">
<cfset error = "#error#; The child length is greater than the parent">
</cfif>
</cfif>
<!--- is the child position locked? ---->
<cfif #child.locked_position# gt 0>
<cfset thisIsBad = "bad">
<cfset error = "#error#; The child is locked into position and cannot be moved.">
</cfif>
<!--- are they trying to put something in a collection object? ---->
<cfif #parent.container_type# is "collection object">
<cfset thisIsBad = "bad">
<cfset error = "#error#; You are trying to put a container in a collection object!">
</cfif>
<cfif len(#error#) gt 0>
<cfset globalError = "#globalError#; #error#">
<cfset error = replace(error,"; ","","first")>
<cfif len(#child.barcode#) gt 0>
<cfset childLink = "<a href=""EditContainer.cfm?container_id=#child.container_id#"" target=""_blank"">#child.barcode#</a>">
<cfelse>
<cfset childLink = "<a href=""EditContainer.cfm?container_id=#child.container_id#"" target=""_blank"">#child.container_id#</a>">
</cfif>
<cfif len(#parent.barcode#) gt 0>
<cfset parentLink = "<a href=""EditContainer.cfm?container_id=#parent.container_id#"" target=""_blank"">#parent.barcode#</a>">
<cfelse>
<cfset parentLink = "<a href=""EditContainer.cfm?container_id=#parent.container_id#"" target=""_blank"">#child.container_id#</a>">
</cfif>
<tr>
<td>#parentLink#</td>
<td>#childLink#</td>
<td><font color="##FF0000">#error#</font></td>
<td>
<input type="checkbox" name="delPair" value="#container_id#|#parent_container_id#|#timestamp#" />
</td>
</tr>
<cfelse>
<tr>
<td>#parent.barcode#</td>
<td>#child.barcode#</td>
<td>none</td>
<td>
<input type="checkbox" name="delPair" value="#container_id#|#parent_container_id#|#timestamp#" />
</td>
</tr>
</cfif>
</cfoutput>
</table>
<input type="submit" value="Delete Checked" class="delBtn"
onmouseover="this.className='delBtn btnhov'" onmouseout="this.className='delBtn'">
</form>
<cfif len(#thisIsBad#) is 0>
<form name="loadAll" method="post" action="checkContainerMovement.cfm">
<input type="hidden" name="action" value="loadEverything" />
<input type="submit" value="LOAD all Records" class="insBtn"
onmouseover="this.className='insBtn btnhov'" onmouseout="this.className='insBtn'">
</form>
</cfif>
<p> </p>
<form name="remAll" method="post" action="checkContainerMovement.cfm">
<input type="hidden" name="action" value="deleteEverything" />
<input type="button" value="Delete ALL Records" class="delBtn"
onmouseover="this.className='delBtn btnhov'" onmouseout="this.className='delBtn'"
onclick="confirmDelete('remAll');">
</form>
</cfif>
<cfinclude template="/includes/_footer.cfm">