-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgetReceivedFiles.php
More file actions
165 lines (147 loc) · 6.31 KB
/
getReceivedFiles.php
File metadata and controls
165 lines (147 loc) · 6.31 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
<script>
function acceptFile(dispatchID, fileID) {
$.ajax({
type: 'POST',
url: 'ajaxCalls/acceptSharedFile.php',
data: {
dispatchID: dispatchID,
fileID: fileID
},
success: function(response) {
alert(response);
location.reload();
}
});
}
function rejectFile(dispatchID, fileID) {
$.ajax({
type: 'POST',
url: 'ajaxCalls/rejectSharedFile.php',
data: {
dispatchID: dispatchID,
fileID: fileID
},
success: function(response) {
alert(response);
location.reload();
}
});
}
function deleteFile(dispatchID, fileID) {
if (confirm('Are you sure and want to delete the file ?')) {
$.ajax({
type: 'POST',
url: 'ajaxCalls/deleteSharedFile.php',
data: {
dispatchID: dispatchID,
fileID: fileID
},
success: function(response) {
alert(response);
location.reload();
}
});
}
}
function downloadFile(filePath) {
$.ajax({
type: 'POST',
url: `ajaxCalls/downloadFile.php`,
data: {
filePath: filePath
},
success: function(response) {
alert(response);
location.reload();
}
});
}
</script>
<?php
if (isset($_SESSION['userID'])) {
$userID = $_SESSION['userID'];
$folderID = -2;
$sql = "SELECT * FROM dispatch, files, user WHERE dispatch.dispatchTo='$userID' AND user.userID=dispatch.dispatchBy AND files.fileID=dispatch.fileID AND status='Pending'";
$result = mysqli_query($con, $sql);
if (mysqli_num_rows($result) != 0) {
?>
<div>Pending Files to be Approved</div>
<table class="receivedFileTable w-full">
<thead>
<th></th>
<th class="p-2 w-[20%] text-start overflow-scroll">File Name</th>
<th class="p-2 w-[10%]">File Type</th>
<th class="p-2 w-[20%]">Sent By</th>
<th class="p-2 w-[20%]">TimeStamp</th>
<th class="p-2 w-[10%] overflow-scroll">Comments</th>
<th class="p-2 w-[10%]" colspan="2">Actions</th>
</thead>
<tbody>
<?php
foreach ($result as $file) {
?>
<tr>
<td><i class="fa fa-file text-blue-400"></i></td>
<td class="p-2 text-start"><?php echo $file['fileName']; ?></td>
<td class="p-2"><?php echo $file['fileType']; ?></td>
<td class="p-2"><?php echo $file['Name'] . ' ( ' . $file['userID'] . ' )'; ?></td>
<td class="p-2"><?php echo $file['dispatchTimestamp']; ?></td>
<td class="p-2"><?php echo $file['comments']; ?></td>
<td class="p-2"><button onclick="acceptFile('<?php echo $file['dispatchID'] ?>', '<?php echo $file['fileID'] ?>')"><i class="fa fa-check p-2 rounded-full border text-green-500 hover:bg-gray-300"></i></button></td>
<td class="p-2"><button onclick="rejectFile('<?php echo $file['dispatchID'] ?>', '<?php echo $file['fileID'] ?>')"><i class="fa fa-close p-2 rounded-full border text-red-500 hover:bg-gray-300"></i></button> </td>
</tr>
<?php
}
?>
</tbody>
</table>
<?php
} else {
?>
<div class="w-full h-full flex items-center justify-center flex-col gap-8">
<div class="text-center text-xl md:text-2xl lg:text-4xl ">No Files to be Received</div>
<i class="fa fa-file-import text-gray-200 text-9xl opacity-5"></i>
</div>
<?php
}
$sql = "SELECT * FROM dispatch, files, user WHERE dispatch.dispatchTo='$userID' AND user.userID=dispatch.dispatchBy AND files.fileID=dispatch.fileID AND status='Accepted'";
$result = mysqli_query($con, $sql);
if (mysqli_num_rows($result) != 0) {
?>
<div>Received Files</div>
<table class="receivedFileTable w-full">
<thead>
<th></th>
<th class="p-2 w-[20%] text-start overflow-scroll">File Name</th>
<th class="p-2 w-[10%]">File Type</th>
<th class="p-2 w-[20%]">Sent By</th>
<th class="p-2 w-[20%]">TimeStamp</th>
<th class="p-2 w-[10%] overflow-scroll">Comments</th>
<th class="p-2 w-[10%]" colspan="2">Actions</th>
</thead>
<tbody>
<?php
foreach ($result as $file) {
$sender = $file['userID'] . $file['Name'] . $file['contactNo'];
$rootDirectory = $_SESSION['userID'] . $_SESSION['Name'] . $_SESSION['contactNo'];
?>
<tr>
<td><i class="fa fa-file text-blue-400"></i></td>
<td class="p-2 text-start"><?php echo $file['fileName']; ?></td>
<td class="p-2"><?php echo $file['fileType']; ?></td>
<td class="p-2"><?php echo $file['Name'] . ' ( ' . $file['userID'] . ' )'; ?></td>
<td class="p-2"><?php echo $file['dispatchTimestamp']; ?></td>
<td class="p-2"><?php echo $file['comments']; ?></td>
<td class="p-2"><button onclick="deleteFile('<?php echo $file['dispatchID']; ?>', '<?php echo $file['fileID']; ?>')"><i class="fas fa-trash text-red-600 text-lg"></i></button></td>
<td class="p-2"> <a href="<?php echo 'userFolders/' . $rootDirectory . '/Received' . '/' . $sender . '/' . $file['fileName'] ?>" download><i class="fas fa-download text-orange-600 text-lg"></i></a> </td>
<!-- <td><button onclick="sendFile('<?php echo $file['fileID'] ?>')"><i class="fas fa-share"></i></button></td> -->
</tr>
<?php
}
?>
</tbody>
</table>
<?php
}
}
?>