This repository has been archived by the owner on Dec 31, 2023. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #86 from hardingadonis/hoang_admin_dashboard
Hoang admin dashboard
- Loading branch information
Showing
8 changed files
with
148 additions
and
62 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
var orderId; | ||
|
||
function openEditStatusModal() { | ||
$('#editOrderModal').modal('show'); | ||
} | ||
|
||
// Function to populate fields in the edit modal with existing data | ||
function populateEditModalFields(row) { | ||
var orderStatus = row.cells[4].textContent.trim(); | ||
|
||
document.getElementById('editStatus').value = orderStatus; | ||
} | ||
|
||
function openEditOrderStatusModal(id) { | ||
orderId = id; | ||
|
||
openEditStatusModal(); | ||
} | ||
|
||
function saveChangesEditOrder() { | ||
let editedStatus = document.getElementById('editStatus').value; | ||
|
||
// Get the order ID from the row or another source | ||
|
||
const url = contextPath + '/admin/order?id=' + orderId + '&status=' + editedStatus; | ||
|
||
$.ajax({ | ||
url: url, | ||
type: "POST", | ||
dataType: "json", | ||
success: function (data) { | ||
if (data.status === "success") { | ||
Swal.fire({ | ||
title: "Success!", | ||
text: "Order Status information updated successfully!", | ||
icon: "success" | ||
}).then((result) => { | ||
if (result.isConfirmed) { | ||
window.location.reload(); | ||
} | ||
}); | ||
} else { | ||
Swal.fire({ | ||
title: "Oops...", | ||
text: "Something went wrong!", | ||
icon: "error" | ||
}); | ||
} | ||
}, | ||
}); | ||
} | ||
|
||
|
||
// Function to close the edit modal | ||
function closeEditModal() { | ||
$('#editOrderModal').modal('hide'); | ||
} | ||
|
||
//// Event delegation to handle dynamically added elements | ||
//$(document).on('click', '.btn-tiny', function () { | ||
// openEditModal.call(this); // Phải gọi hàm openEditModal với this là element được click | ||
// populateEditModalFields($(this).closest('tr')[0]); | ||
//}); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -231,4 +231,4 @@ | |
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/umd/simple-datatables.min.js"></script> | ||
<script src="<%=request.getContextPath()%>/assets/js/admin/datatables-simple-demo.js"></script> | ||
</body> | ||
</html> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -88,29 +88,29 @@ | |
Order Table | ||
</div> | ||
<div class="card-body"> | ||
<table id="datatablesSimple" class="datatable-table"> | ||
<table id="datatablesSimple"> | ||
<thead> | ||
<tr> | ||
<th>ID</th> | ||
<th>User ID</th> | ||
<th>User Full Name</th> | ||
<th>Total Price</th> | ||
<th>Payment</th> | ||
<th>Status</th> | ||
<th>Actions</th> | ||
<th>Action</th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
<c:forEach var="c" items="${Singleton.orderDAO.getAll()}"> | ||
<tr> | ||
<td>${c.ID}</td> | ||
<td>${c.userID}</td> | ||
<td>${Singleton.userDAO.get(c.userID).getFullName()}</td> | ||
<td>${c.totalPrice}</td> | ||
<td>${c.payment}</td> | ||
<td>${c.status}</td> | ||
<td> | ||
<a href="#" class="btn btn-info btn-tiny" title="Edit"> | ||
<button href="#" class="btn btn-info btn-tiny" title="Edit" onclick="openEditOrderStatusModal(${c.ID})"> | ||
<i class="fa fa-pencil"></i> | ||
</a> | ||
</button> | ||
</td> | ||
</tr> | ||
</c:forEach> | ||
|
@@ -152,18 +152,18 @@ | |
<div class="form-group"> | ||
<label for="editStatus">Status:</label> | ||
<select class="form-select" id="editStatus"> | ||
<option value="Processing">Processing</option> | ||
<option value="Shipping">Shipping</option> | ||
<option value="Done">Done</option> | ||
<option value="Cancel">Canceled</option> | ||
<option value="processing">PROCESSING</option> | ||
<option value="shipping">SHIPPING</option> | ||
<option value="done">DONE</option> | ||
<option value="canceled">CANCELED</option> | ||
</select> | ||
</div> | ||
</form> | ||
</div> | ||
|
||
<!-- Modal Footer --> | ||
<div class="modal-footer"> | ||
<button type="button" class="btn btn-primary" onclick="saveChanges()">Save changes</button> | ||
<button type="button" class="btn btn-primary" onclick="saveChangesEditOrder()">Save changes</button> | ||
<button type="button" class="btn btn-secondary" data-dismiss="modal" onclick="closeEditModal()">Cancel</button> | ||
</div> | ||
</div> | ||
|
@@ -183,6 +183,8 @@ | |
<script src="<%=request.getContextPath()%>/assets/js/admin/chart-pie-demo.js"></script> | ||
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/umd/simple-datatables.min.js"></script> | ||
<script src="<%=request.getContextPath()%>/assets/js/admin/datatables-simple-demo.js"></script> | ||
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@11"></script> | ||
|
||
</body> | ||
</html> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters