-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patheditTag.php
More file actions
638 lines (590 loc) · 23.7 KB
/
Copy patheditTag.php
File metadata and controls
638 lines (590 loc) · 23.7 KB
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
<?php
require './config.inc.php';
?>
<!DOCTYPE html PUBLIC "-//WAPFORUM//DTD XHTML Mobile 1.0//EN" "http://www.wapforum.org/DTD/xhtml-mobile10.dtd">
<html lang="en">
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<meta charset="utf-8">
<title>Project Tag Edit</title>
<meta name="generator" content="Bootply" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<link href="css/bootstrap.min.css" rel="stylesheet">
<link href="//netdna.bootstrapcdn.com/font-awesome/3.2.1/css/font-awesome.min.css" rel="stylesheet">
<!--[if lt IE 9]>
<script src="//html5shim.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<!-- Custom CSS -->
<link href="css/landing-page.css" rel="stylesheet">
<link href="css/styles.css" rel="stylesheet">
</head>
<body>
<nav class="navbar navbar-static">
<div class="container">
<div class="navbar-header">
<a class="navbar-brand" href="whereIsHome.php" target=""><b>Schneider Electric</b></a>
<a class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
<span class="glyphicon glyphicon-chevron-down"></span>
</a>
</div>
<ul class="nav navbar-nav navbar-right navbar-user">
<li><a href="userLogout.php"><i class="fa fa-power-off"></i><b>Log Out</b></a></li>
</ul>
</div>
</nav><!-- /.navbar -->
<h1><center>Tag Edit</center></a></h1><br>
<!-- Begin Body -->
<div class="container">
<div class="no-gutter row">
<!-- left side column -->
<div class="col-md-2">
<div class="panel panel-default" id="sidebar">
<!--<div class="panel-heading" style="background-color:#64F797"></div>
<div class="panel-body">
<ul class="nav nav-stacked">
<li><a href="searchTag.php">Tag Search</a></li>
<li><a href="insertTag.php">Tag Insert</a></li>
<li><a href="viewTag.php">Tag View</a></li>
</ul>
</div>/panel body-->
</div><!--/panel-->
</div><!--/end left column-->
<!--mid column-->
<div class="col-md-6">
<div class="panel" id="midCol">
<div class="panel-heading" style="background-color:#3DC66D"></div>
<div class="panel-body">
<div class="table-responsive">
<table>
<tr> <!--row0-->
<th>Tag#</th>
<th>Rev#</th>
<th>Last Revised</th>
</tr>
<tr>
<td> <form method="post"> <input type="text" style="width:90px" name="NO" id="NO" readonly> </form> </td>
<td> <form method="post"> <input type="text" style="text-align:right; width:40px" name="Rev#" id="Rev" readonly> </form></td>
<td> <form method="post"> <input type="text" style="width:150px" name="Date" id="Date" readonly></form></td>
</tr>
<tr>
<th>Sub-Category</th>
<th>Complexity</th>
<th>Lead Time</th>
<th>User</th>
</tr>
<tr> <!--row1-->
<td>
<?php
$options = '<option></option>';
$subcat="SELECT * FROM SUBCATEGORIES";
$result = $db->query($subcat);
while($row = $result->fetch_assoc()) {
$options .="<option value=" . '"' . $row['SubCategory'] . '"' . ">" . $row['SubCategory'] . "</option>";
}
$menu="<form id='Subcat' name='Subcat' method='post' action=''>
<select name='SubCategory' id='SubCategory'>
" . $options . "
</select>
</form>";
echo $menu;
?>
</td>
<td>
<?php
$options = '<option></option>';
$comp="SELECT * FROM COMPLEXITIES";
$result = $db->query($comp);
while($row = $result->fetch_assoc()) {
$options .="<option value=" . '"' . $row['Complexity'] . '"' . ">" . $row['Complexity'] . "</option>";
}
$menu="<form id='Complex' name='Complex' method='post' action=''>
<select name='Complexity' id='Complexity'>
" . $options . "
</select>
</form>";
echo $menu;
?>
</td>
<td> <form method="post"> <input type="text" style="width:75px; text-align:right" name="LeadTime" id="LeadTime"></form></td>
<td> <form method="post"> <input type="text" style="width:75px; text-align:right" name="User" id="User" readonly></form></td>
</tr>
</table> <br>
</div>
<div class="table-responsive">
<table>
<tr> <!--row0-->
<td> Tag Description: </td>
</tr>
<tr> <!--row1-->
<td> <div class="form-group">
<textarea class="form-control" style="width:460px; height:75px" rows="5" id="Description"></textarea>
</div></form></td>
</tr>
<tr> <!--row2-->
<td> Tag Notes: </td>
</tr>
<tr> <!--row3-->
<td> <div class="form-group">
<textarea class="form-control" style="width:460px; height:75px" rows="5" id="Notes"></textarea>
</div></form></td>
</tr>
<tr> <!--row2-->
<td> Price Note </td>
</tr>
<tr> <!--row3-->
<td> <div class="form-group">
<textarea class="form-control" style="width:460px; height:75px" rows="5" id="PriceNotes"></textarea>
</div>
</tr>
<tr> <!--row4-->
<td> <strong>Product Lines Tag May be Applied To: </strong> </td>
</tr>
</table></div>
<div class="table-responsive">
<br>
<table>
<tr> <!--row0-->
<th> </th>
<th> </th>
<th> <center>USA$ </center><br></th>
<th> <center>Canada$</center><br></th>
<th> <center>Mexico$</center><br></th>
</tr>
<tr> <!--row1-->
<td><input type="checkbox" class="checkbox" id="HVL"/> </td>
<td> HVL </td>
<td><form method="post"> <input type="text" style="width:100px; text-align:center" name="HVLUSA" id="HVLUSA" readonly></form></td>
<td><form method="post"> <input type="text" style="width:100px; text-align:center" name="HVLCA" id="HVLCA" readonly></form></td>
<td><form method="post"> <input type="text" style="width:100px; text-align:center" name="HVLMEX" id="HVLMEX" readonly></form></td>
</tr>
<tr> <!--row2-->
<td><input type="checkbox" class="checkbox" id="HVLCC"/> </td>
<td> HVL/CC </td>
<td><form method="post"> <input type="text" style="width:100px; text-align:center" name="HVLCCUSA" id="HVLCCUSA" readonly></form></td>
<td><form method="post"> <input type="text" style="width:100px; text-align:center" name="HVLCCCA" id="HVLCCCA" readonly></form></td>
<td><form method="post"> <input type="text" style="width:100px; text-align:center" name="HVLCCMEX" id="HVLCCMEX" readonly></form></td>
</tr>
<tr> <!--row3-->
<td><input type="checkbox" class="checkbox" id="MetalClad"/> </td>
<td> Metal Clad </td>
<td><form method="post"> <input type="text" style="width:100px; text-align:center" name="MCUSA" id="MCUSA" readonly></form></td>
<td><form method="post"> <input type="text" style="width:100px; text-align:center" name="MCCA" id="MCCA" readonly></form></td>
<td><form method="post"> <input type="text" style="width:100px; text-align:center" name="MCMEX" id="MCMEX" readonly></form></td>
</tr>
<tr> <!--row4-->
<td><input type="checkbox" class="checkbox" id="MVMCC"/> </td>
<td> MVMCC </td>
<td><form method="post"> <input type="text" style="width:100px; text-align:center" name="MVMCCUSA" id="MVMCCUSA" readonly></form></td>
<td><form method="post"> <input type="text" style="width:100px; text-align:center" name="MVMCCCA" id="MVMCCCA" readonly></form></td>
<td><form method="post"> <input type="text" style="width:100px; text-align:center" name="MVMCCMEX" id="MVMCCMEX" readonly></form></td>
</tr>
</table></div>
<div class="table-responsive">
<br><br>
<table >
<tr>
<th> Applied FO: </td>
</tr>
</table><br><hr></div>
<div class="table-responsive">
<table id="result2" data-toggle="table" data-url="" data-cache="false" class="table table-bordered table-striped">
</table>
<hr>
<table name="checks">
<tr>
<th> Type: </td>
<td> <input type="checkbox" name="ckQ" id="ckQ" class="checkbox"/> </td>
<td> Quote </th>
<td> <input type="checkbox" name="ckF" id="ckF" class="checkbox"/> </td>
<td> Factory order </th>
</tr>
</table>
<br>
<table class="table table-bordered table-striped">
<thead>
<tr>
<th><center>FO Number Applied To</center></th>
<th><center>Notes to Next Engineer</center></th>
</tr>
</thead>
<tr>
<td><form method="post"> <input type="text" style="width:100%; text-align:center" name="fo#" id="fo#"></form></td>
<td><form method="post"> <input type="text" style="width:100%; text-align:center" name="notes" id="notes"></form></td>
</tr>
</table>
</div> <!--table-responsive-->
<table align="right">
<tr> <!--row0-->
<th><button type="button" class="btn btn-default" onclick="newFO()" >Apply new FO</button> </th>
</tr>
</table>
</div>
</div><!--/panel-->
</div><!--/end mid column-->
<!-- right content column-->
<div class="col-md-4">
<div class="panel" id ="rightcol">
<div class="panel-heading" style="background-color:#057A2E"></div>
<div class="panel-body">
<h4><center><i>Pricing Information </i></center></h4>
<table class="table table-borderless">
<tr> <!--row0-->
<th>Material: </th>
<th><form method="post"> <input type="text" style="width:200px; text-align:right" name="Material" id="Material"></form></th>
</tr>
<tr> <!--row1-->
<th>Labor: </th>
<th><form method="post"> <input type="text" style="width:200px; text-align:right" name="Labor" id="Labor"></form></th>
</tr>
<tr> <!--row2-->
<th>Engineering: </th>
<th><form method="post"> <input type="text" style="width:200px; text-align:right" name="Engineering" id="Engineering"></form></th>
</tr>
</table>
<hr>
<table class="table table-borderless">
<tr> <!--row0-->
<th nowrap>Install Cost: </th>
<th><form method="post"> <input type="text" style="width:150px; text-align:right" name="Install" id="Install" readonly></form></th>
</tr>
<tr> <!--row1-->
<th nowrap>Price Expires: </th>
<th><form method="post"> <input type="date" style="width:150px; text-align:right" name="PriceExpires" id="PriceExpires"></form></th>
</tr>
</table>
<br>
<!-- <table id="obsoleteCB">
<tr>
<td><input type="checkbox" class="checkbox" id="Obsolete"/></td>
<td> Check To Make TAG Permanently Obsolete</td>
</tr>
</table> -->
<br>
<table align="center">
<tr> <!--row0-->
<th><button type="button" style="width:150px" class="button" name="save" value="update" id="saveBtn" onclick="save();">Save</button> </th>
</tr>
</table> <br>
<form method="post" enctype="multipart/form-data">
<table align="center">
<tr></tr>
<tr colspan="2">
<input type="hidden" name="MAX_FILE_SIZE" value="2000000">
<input name="userfile" type="file" id="userfile">
</tr>
<tr>
<td width="80"><input name="upload" type="submit" class="box" id="upload" value="Add Attachment"></td>
</tr>
</table>
</form>
</div><!--/panel-body-->
<div>
<hr><h4><center><i>Attachments</i></center></h4>
<br>
<table class="table table-bordered table-striped">
<thead>
<tr>
<th>File Name</th>
</tr>
</thead>
<tbody class="result3">
</tbody>
</table>
<br><hr><br>
</div>
</div><!--/panel-->
<!--/end right column-->
</div>
</div>
<div class="result"></div>
</div>
<!-- script references -->
<script src="//ajax.googleapis.com/ajax/libs/jquery/2.0.2/jquery.min.js"></script>
<script src="js/bootstrap.min.js"></script>
<script src="js/scripts.js"></script>
<script type="text/javascript">
window.onload = populateAndCalc();
function getAttachments(){
var TagNo = document.getElementById("NO").value;
var RevNo = document.getElementById("Rev").value;
var action = 'getAttachments';
var ajaxurl = 'ajax.php',
data = {'action':action,
'TagNo': TagNo,
'RevNo': RevNo};
$.post(ajaxurl,data,function(response){
$(".result3").html(response);
});
}
function downloadAttachments(id){
$.ajax({
url: 'fileDownload.php',
type: 'POST',
success: function(){
createCookie('id',id,0);
window.location = 'fileDownload.php';
}
});
}
function getFO(){
var TagNo = document.getElementById("NO").value;
var RevNo = document.getElementById("Rev").value;
setCookie("TagNumber", TagNo, 1);
setCookie("RevNumber", RevNo, 1);
var action = 'popFO';
var ajaxurl = 'ajax.php',
data = {'action':action,
'TagNo': TagNo,
'RevNo': RevNo};
$.post(ajaxurl,data,function(response){
$("#result2").html(response);
getAttachments();
});
}
function setCookie(cname, cvalue, exdays) {
var d = new Date();
d.setTime(d.getTime() + (exdays*24*60*60*1000));
var expires = "expires="+d.toUTCString();
document.cookie = cname + "=" + cvalue + "; " + expires;
}
function newFO(){
var TagNO = document.getElementById("NO").value;
var RevNO = document.getElementById("Rev").value;
var FoNo = document.getElementById("fo#").value;
var Notes = document.getElementById("notes").value;
var x = document.getElementById("ckQ").checked;
if(x){
var CkQ = 1;
}
else{
var CkQ = 0;
}
var y = document.getElementById("ckF").checked;
if(y){
var CkF = 1;
}
else{
var CkF = 0;
};
var action = 'newFO';
var ajaxurl = 'ajax.php',
data = {'action':action,
'TagNO':TagNO,
'RevNO':RevNO,
'FoNo':FoNo,
'Notes':Notes,
'CkQ':CkQ,
'CkF':CkF};
$.post(ajaxurl,data,function(response){
var jsonData = JSON.parse(response);
if(jsonData){
alert("Added FO successfully.");
}else{
alert("Error adding FO.");
}
createCookie("tag", TagNO, 0);
createCookie("rev", RevNO, 0);
location.reload();
});
}
/*
function uploadIt(){
var TagNo = document.getElementById("NO").value;
var RevNo = document.getElementById("Rev").value;
var action = 'uploadAttachments';
var ajaxurl = 'ajax.php',
data = {'action':action,
'TagNo':TagNo,
'RevNo':RevNo};
$.post(ajaxurl,data,function(response){
var jsonData = JSON.parse(response);
if(jsonData){
alert("Attached successfully.");
}else{
alert("Error attaching file.");
}
window.location = "whereIsHome.php";
});
}
*/
//Populates entry fields and calculates values for current tag info
function populateAndCalc(){
var tag = readCookie('tag');
var rev = readCookie('rev');
var action = 'display';
var ajaxurl = 'ajax.php',
data = {'action':action,
'tag':tag,
'rev':rev};
$.post(ajaxurl,data,function(response){
//$(".result").html(response); //debug stuff
var jsonData = JSON.parse(response);
var matCost = parseFloat(jsonData.tag.MatCost);
var labCost = (parseFloat(jsonData.tag.LabCost) * parseFloat(jsonData.hourly[1].Value));
var engCost = (parseFloat(jsonData.tag.EngCost) * parseFloat(jsonData.hourly[0].Value));
var insCost = (matCost + labCost + engCost);
document.getElementById("NO").value = jsonData.tag.NO;
document.getElementById("Description").value = jsonData.tag.Description;
document.getElementById("Rev").value = jsonData.tag.Rev;
document.getElementById("Date").value = jsonData.tag.CurrentDate;
document.getElementById("SubCategory").value = jsonData.tag.SubCategory;
document.getElementById("Complexity").value = jsonData.tag.Complexity;
document.getElementById("LeadTime").value = jsonData.tag.LeadTime;
document.getElementById("Notes").value = jsonData.tag.Notes;
document.getElementById("PriceNotes").value = jsonData.tag.PriceNotes;
document.getElementById("Material").value = jsonData.tag.MatCost;
document.getElementById("Labor").value = jsonData.tag.LabCost;
document.getElementById("Engineering").value = jsonData.tag.EngCost;
document.getElementById("Install").value = insCost;
document.getElementById("User").value = jsonData.tag.TAGMember;
document.getElementById("PriceExpires").value = jsonData.tag.PriceExpires;
if(jsonData.tag.HVL == 1){
document.getElementById("HVL").checked = true;
document.getElementById("HVLUSA").value = (parseFloat(insCost) * parseInt(jsonData.product[0].Mult) * parseFloat(jsonData.country[2].Mult)).toFixed(2);
document.getElementById("HVLCA").value = (parseFloat(insCost) * parseInt(jsonData.product[0].Mult) * parseFloat(jsonData.country[0].Mult)).toFixed(2);
document.getElementById("HVLMEX").value = (parseFloat(insCost) * parseInt(jsonData.product[0].Mult) * parseFloat(jsonData.country[1].Mult)).toFixed(2);
}
if(jsonData.tag.HVLCC == 1){
document.getElementById("HVLCC").checked = true;
document.getElementById("HVLCCUSA").value = (parseFloat(insCost) * parseInt(jsonData.product[1].Mult) * parseFloat(jsonData.country[2].Mult)).toFixed(2);
document.getElementById("HVLCCCA").value = (parseFloat(insCost) * parseInt(jsonData.product[1].Mult) * parseFloat(jsonData.country[0].Mult)).toFixed(2);
document.getElementById("HVLCCMEX").value = (parseFloat(insCost) * parseInt(jsonData.product[1].Mult) * parseFloat(jsonData.country[1].Mult)).toFixed(2);
}
if(jsonData.tag.MetalClad == 1){
document.getElementById("MetalClad").checked = true;
document.getElementById("MCUSA").value = (parseFloat(insCost) * parseInt(jsonData.product[2].Mult) * parseFloat(jsonData.country[2].Mult)).toFixed(2);
document.getElementById("MCCA").value = (parseFloat(insCost) * parseInt(jsonData.product[2].Mult) * parseFloat(jsonData.country[0].Mult)).toFixed(2);
document.getElementById("MCMEX").value = (parseFloat(insCost) * parseInt(jsonData.product[2].Mult) * parseFloat(jsonData.country[1].Mult)).toFixed(2);
}
if(jsonData.tag.MVMCC == 1){
document.getElementById("MVMCC").checked = true;
document.getElementById("MVMCCUSA").value = (parseFloat(insCost) * parseInt(jsonData.product[3].Mult) * parseFloat(jsonData.country[2].Mult)).toFixed(2);
document.getElementById("MVMCCCA").value = (parseFloat(insCost) * parseInt(jsonData.product[3].Mult) * parseFloat(jsonData.country[0].Mult)).toFixed(2);
document.getElementById("MVMCCMEX").value = (parseFloat(insCost) * parseInt(jsonData.product[3].Mult) * parseFloat(jsonData.country[1].Mult)).toFixed(2);
}
if(jsonData.tag.Obsolete == 1)
document.getElementById("Obsolete").checked = true;
eraseCookie('tag');
eraseCookie('rev');
getFO();
});
}
//Handles button functionality
function save(){
var tag = $('#NO').val();
var rev = $('#Rev').val();
var date = $('#Date').val();
var sub = $('#Subcat option:selected').html();
var comp = $('#Complex option:selected').html();
var mat = $('#Material').val();
var lab = $('#Labor').val();
var eng = $('#Engineering').val();
var ins = $('#Install').val();
var exp = $('#PriceExpires').val();
var notes = $('#Notes').val();
var price = $('#PriceNotes').val();
var time = $('#LeadTime').val();
var user = $('#User').val();
var hvl = $("#HVL").is(':checked');
var cc = $("#HVLCC").is(':checked');
var metal = $("#MetalClad").is(':checked');
var mvmcc = $("#MVMCC").is(':checked');
var obs = $("#Obsolete").is(':checked');
var action = 'update';
var ajaxurl = 'ajax.php',
data = {'action':action,
'NO':tag,
'SubCategory':sub,
'Rev':rev,
'CurrentDate':date,
'Complexity':comp,
'LeadTime':time,
'Notes':notes,
'PriceNotes':price,
'MatCost':mat,
'LabCost':lab,
'EngCost':eng,
'InsCost':ins,
'PriceExpires':exp,
'TAGMember':user,
'HVL':hvl,
'HVLCC':cc,
'MetalClad':metal,
'MVMCC':mvmcc,
'Obsolete':obs};
$.post(ajaxurl, data, function (response) {
$(".result").html(response); //debug stuff
var jsonData = JSON.parse(response);
alert(jsonData.success);
rev = parseInt(rev)+1;
createCookie("tag",tag,0); //current tag
createCookie("rev",rev,0); //next revision
window.location="viewTag.php";
});
}
//Creates cookie with specified name:value pair and length of existance
function createCookie(name,value,days){
if(days){
var date = new Date();
date.setTime(date.getTime()+(days*24*60*60*1000));
var expires = "; expires=" + date.toGMTString();
}
else var expires = "";
document.cookie = name + "=" + value + expires + "; path=/";
}
//Returns value of specified cookie key
function readCookie(name){
var nameEQ = name + "=";
var ca = document.cookie.split(';');
for(var i=0; i<ca.length; i++){
var c = ca[i];
while (c.charAt(0)==' '){
c = c.substring(1, c.length);
}
if(c.indexOf(nameEQ) == 0){
return c.substring(nameEQ.length, c.length);
}
}
return null;
}
//Erases cookie of specified key
function eraseCookie(name){
createCookie(name,"",-1);
}
</script>
</body>
</html>
<?php
if(isset($_POST['upload'])){
$fileName = $_FILES['userfile']['name'];
$tmpName = $_FILES['userfile']['tmp_name'];
$fileSize = $_FILES['userfile']['size'];
$fileType = $_FILES['userfile']['type'];
$TagNo = $_COOKIE['TagNumber'];
$RevNo = $_COOKIE['RevNumber'];
unset($_COOKIE['TagNumber']);
unset($_COOKIE['RevNumber']);
echo '<script language="javascript">';
echo '</script>';
$fp = fopen($tmpName, 'r');
$content = fread($fp, filesize($tmpName));
$content = addslashes($content);
fclose($fp);
if(!get_magic_quotes_gpc())
{
$fileName = addslashes($fileName);
}
$query = "INSERT INTO FILETESTING (filecontents, filename, filesize, filetype, TagNo, RevNo ) VALUES ('".$content."', '".$fileName."', '".$fileSize."', '".$fileType."', '".$TagNo."', '".$RevNo."');";
$result = $db->query($query) or die('Error, query failed');
if($result){
echo "<script type=".'"'."text/javascript".'"'.">alert(".'"'."File $fileName uploaded.".'"'.");window.location=".'"'."searchTag.php".'"'.";</script>"; //
}else{
echo "<script type=".'"'."text/javascript".'"'.">alert(".'"'."File $fileName NOT uploaded.".'"'.");window.location=".'"'."searchTag.php".'"'.";</script>";
}
// echo "<script type=".'"'."text/javascript".'"'.">";
// echo "createCookie(".'"'."tag".'"'.",$TagNo,0);";
// echo "createCookie(".'"'."rev".'"'.",$RevNo,0);";
// echo "location.reload();";
// echo "</script>";
}
?>