Repository navigation
Expand file tree
/
Copy pathadd-progress.php
More file actions
200 lines (187 loc) · 10.4 KB
/
Copy pathadd-progress.php
File metadata and controls
200 lines (187 loc) · 10.4 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
<?php include("includes/header.php");
$sql = "SELECT * FROM shipping_progress WHERE shipping_id = '".$_GET['id']."' and status = '1'";
$query = $db->query($sql);
if (empty($_SESSION['session'])) {
header("Location:index.php");
} else {
if(!empty($_SESSION['type'] == "CUST")){
header("Location:dashboard.php");
}
if (!empty($_SESSION['session'])) {
//delete
if (!empty($_GET['del'])) {
$query = $db->prepare("delete from shipping_progress WHERE id = :dl");
$delete = $query->execute(array('dl' => $_GET['del']));
header("Location: add-progress.php?id=" . $_GET['id']);
}
//update
if (!empty($_POST['add_progress'])) {
$add_progress = $db->prepare("INSERT INTO shipping_progress SET shipping_id = ?, progress_date = ?, progress_location = ?, progress_time = ?, progress_details = ?");
$add_progress->execute(array($_POST['shipping_id'],$_POST['progress_date'],$_POST['progress_location'],$_POST['progress_time'],$_POST['progress_details']));
if ($add_progress->rowCount()) {
header("Location: add-progress.php?id=" . $_GET['id']);
} else {
$errMSGs = "An error occurred!";
}
} else {}
//edit
if (!empty($_POST['edit_progress'])) {
$update = "UPDATE shipping_progress SET shipping_id = :shipid, progress_date = :pdate, progress_location = :ploc, progress_time = :ptime, progress_details = :pdet WHERE id = :d";
$stmt = $db->prepare($update);
$stmt->bindParam(':shipid', $_GET['id'], PDO::PARAM_INT);
$stmt->bindParam(':pdate', $_POST['progress_date'], PDO::PARAM_STR);
$stmt->bindParam(':ploc', $_POST['progress_location'], PDO::PARAM_STR);
$stmt->bindParam(':ptime', $_POST['progress_time'], PDO::PARAM_STR);
$stmt->bindParam(':pdet', $_POST['progress_details'], PDO::PARAM_STR);
$stmt->bindParam(':d', $_POST['id'], PDO::PARAM_INT);
if ($stmt->execute()) {
//$successMSG = "Lead has been successfully updated.";
header("Location: add-progress.php?id=" . $_GET['id']);
} else {
$errMSGs = "An error occurred!";
}
} else {}
?>
<div class="row layout-top-spacing" id="cancel-row">
<div class="col-xl-12 col-lg-12 col-sm-12 layout-spacing">
<div class="widget-content widget-content-area br-6">
<div class="row">
<div class="col-lg-8 col-12 mx-auto">
<?php if (!empty($successMSG)) {
echo '<div class="alert alert-success mb-4 alert-dismissable">
<button type="button" class="close" data-dismiss="alert" aria-hidden="true"><button type="button" class="close" data-dismiss="alert" aria-label="Close"> <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-x close" data-dismiss="alert"><line x1="18" y1="6" x2="6" y2="18"></line><line x1="6" y1="6" x2="18" y2="18"></line></svg></button>'.$successMSG.'</div>';
}
if (!empty($errMSGs)) {
echo '<div class="alert alert-danger mb-4 alert-dismissable">
<button type="button" class="close" data-dismiss="alert" aria-hidden="true"><button type="button" class="close" data-dismiss="alert" aria-label="Close"> <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-x close" data-dismiss="alert"><line x1="18" y1="6" x2="6" y2="18"></line><line x1="6" y1="6" x2="18" y2="18"></line></svg></button>'.$errMSGs.'</div>';
} ?>
</div>
</div>
<button type="button" class="btn btn-primary" data-toggle="modal" data-target="#addRole">Add Progress</button>
<!-- Add Modal -->
<div class="modal fade" id="addRole" tabindex="-1" role="dialog" aria-labelledby="addModal" aria-hidden="true">
<div class="modal-dialog modal-dialog-centered modal-lg" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="addModal">Add Progress</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<svg aria-hidden="true" xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-x"><line x1="18" y1="6" x2="6" y2="18"></line><line x1="6" y1="6" x2="18" y2="18"></line></svg>
</button>
</div>
<div class="modal-body">
<form method="POST">
<div class="form-row">
<div class="form-group col-md-4">
<label>Date</label>
<input type="date" class="form-control" name="progress_date">
</div>
<div class="form-group col-md-4">
<label>Location</label>
<input type="text" class="form-control" name="progress_location">
</div>
<div class="form-group col-md-4">
<label>Time</label>
<input type="text" class="form-control" name="progress_time">
</div>
</div>
<div class="form-group">
<label>Details</label>
<textarea type="text" class="form-control" name="progress_details"></textarea>
</div>
<input type="hidden" name="shipping_id" value="<?php echo $_GET['id'];?>">
<input type="submit" class="btn btn-primary mt-3" value="Add" name="add_progress">
</form>
</div>
</div>
</div>
</div>
<div class="table-responsive mb-4 mt-4">
<?php if ($query->rowCount()) { ?>
<table id="zero-config" class="table table-hover non-hover" style="width:100%">
<thead>
<tr>
<th>ID</th>
<th>Date</th>
<th>Location</th>
<th>Time</th>
<th>Progress</th>
<th>Action</th>
</tr>
</thead>
<tbody>
<?php foreach ($query as $row) { ?>
<tr>
<td><?php echo $row['id']; ?></td>
<td><?php echo $row['progress_date']; ?></td>
<td><?php echo $row['progress_location']; ?></td>
<td><?php echo $row['progress_time']; ?></td>
<td><?php echo $row['progress_details']; ?></td>
<td>
<div class="btn-group">
<button type="button" class="btn btn-dark btn-sm">Open</button>
<button type="button" class="btn btn-dark btn-sm dropdown-toggle dropdown-toggle-split" id="dropdownMenuReference1" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" data-reference="parent">
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-chevron-down"><polyline points="6 9 12 15 18 9"></polyline></svg>
</button>
<div class="dropdown-menu" aria-labelledby="dropdownMenuReference1">
<a class="dropdown-item" data-toggle="modal" data-target="#editProgress<?php echo $row['id']; ?>">Edit</a>
<a class="dropdown-item" href="add-progress.php?del=<?php echo $row['id']; ?>" onClick="return confirm('Are you sure you want to delete?');">Delete</a>
</div>
</div>
<!-- Edit Modal -->
<div class="modal fade" id="editProgress<?php echo $row['id']; ?>" tabindex="-1" role="dialog" aria-labelledby="editingModal<?php echo $row['master_id']; ?>" aria-hidden="true">
<div class="modal-dialog modal-dialog-centered modal-lg" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="editingModal<?php echo $row['id']; ?>">Edit Progress #<?php echo $row['id']; ?></h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<svg aria-hidden="true" xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-x"><line x1="18" y1="6" x2="6" y2="18"></line><line x1="6" y1="6" x2="18" y2="18"></line></svg>
</button>
</div>
<div class="modal-body">
<form method="POST">
<input type="hidden" name="id" value="<?php echo $row['id']; ?>">
<div class="form-row">
<div class="form-group col-md-4">
<label>Date</label>
<input type="date" class="form-control" name="progress_date" value="<?php echo $row['progress_date']; ?>">
</div>
<div class="form-group col-md-4">
<label>Location</label>
<input type="text" class="form-control" name="progress_location" value="<?php echo $row['progress_location']; ?>">
</div>
<div class="form-group col-md-4">
<label>Time</label>
<input type="text" class="form-control" name="progress_time" value="<?php echo $row['progress_time']; ?>">
</div>
</div>
<div class="form-group">
<label>Details</label>
<textarea type="text" class="form-control" name="progress_details"><?php echo $row['progress_details']; ?></textarea>
</div>
<input type="submit" class="btn btn-primary mt-3" value="Update" name="edit_progress">
</form>
</div>
</div>
</div>
</div>
</td>
</tr>
<?php } ?>
</tbody>
<tfoot>
<tr>
<th>ID</th>
<th>Date</th>
<th>Location</th>
<th>Time</th>
<th>Progress</th>
<th>Action</th>
</tr>
</tfoot>
</table>
<?php } else { echo '<br><p>There were no results</p>'; } ?>
</div>
</div>
</div>
</div>
<?php } } include("includes/footer.php"); ?>