diff --git a/assignTaskForm.php b/assignTaskForm.php index b2fb740..191b4bd 100644 --- a/assignTaskForm.php +++ b/assignTaskForm.php @@ -98,6 +98,17 @@ $adminInstructions = mysqli_real_escape_string($conn, $_POST['admin_instruction']); $handover_to = mysqli_real_escape_string($conn, $_POST['handover_to']); + + //check for duplicate task + $checkTask = "SELECT * FROM assign_task WHERE order_no_fk = '$workorder_no'"; + $resultCheck = mysqli_query($conn, $checkTask); + if ($resultCheck->num_rows > 0) { + // If task already exists, redirect to assignTaskForm.php with error message + $_SESSION['error_message'] = "Task already assigned!"; + header("Location: assignTaskForm.php?id=$workorder_no"); + exit; + } + // Insert data into box table $sql = "INSERT INTO assign_task (order_no_fk, assign_to, location, bank_instruction, admin_instruction, box, items, is_read, handover_to) VALUES ('$workorder_no', '$assign_to', '$location', '$bankInstructions', '$adminInstructions', '$barcode', '$json_items', '0', '$handover_to')"; diff --git a/image/messages_3.jpg b/image/messages_3.jpg new file mode 100644 index 0000000..390712b Binary files /dev/null and b/image/messages_3.jpg differ diff --git a/order.php b/order.php index 9da7e30..1de41ec 100644 --- a/order.php +++ b/order.php @@ -532,6 +532,7 @@
List of Delivery Work Orders
num_rows > 0) { // Display table @@ -552,16 +553,26 @@ echo ' '; - + // Counter variable $counter = 1; + //fetch is_read status from assign_task table + $getStatus = "SELECT is_read FROM assign_task WHERE order_no_fk = '$order_no'"; + $resultStatus = mysqli_query($conn, $getStatus); + if ($resultStatus->num_rows > 0) { + $rowStatus = $resultStatus->fetch_assoc(); + $theStatus = $rowStatus['is_read']; + } // Loop through results while ($row = $resultShowOrders->fetch_assoc()) { echo ''; - + + + //workorder_no - echo '' . ($row['order_no']) . ''; + echo '' . $theStatus . ''; + // Get specific company id $comp_id = $row['comp_id_fk']; @@ -583,7 +594,7 @@ // Show account echo '' . $comp_name . " / " . $branch_name . ''; - + echo ''; if ($row["status"] == 'Completed') { @@ -632,12 +643,11 @@ View -
query($insertData) === TRUE) { - $_SESSION['success'] = "Task Completed"; -header("Location: tasks.php"); -} else { -echo "Error: ". $insertData . "
". $conn->error; -} + + //insert into db + $insertData = "UPDATE assign_task SET receiver_name = '$rec_name', receiver_phone = '$rec_phone', receiver_cnic = '$rec_cnic', proof = '$img_des', any_comments ='$any_detail', cross_check='$cross_check', verification='$verification' WHERE order_no_fk = '$order_no'"; + + if ($conn->query($insertData) === TRUE) { + // update status to 1 + $updateStatus = "UPDATE assign_task SET is_read = '1' WHERE order_no_fk = '$order_no'"; + } else { + echo "Error: " . $insertData . "
" . $conn->error; + } + + if ($conn->query($updateStatus) === TRUE) { + //set success message and redirect to tasks page + $_SESSION['success'] = "Task Completed"; + header("Location: tasks.php"); + } else { + echo "Error: " . $insertData . "
" . $conn->error; + } } ?> @@ -473,6 +483,85 @@
Instructions by admin:

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.

+ +
+ +
+
+ query($assign_tasks); + if ($result_assign_tasks->num_rows > 0) { + $row121 = $result_assign_tasks->fetch_assoc(); + $handover_to = $row121['handover_to']; + } + + $showOrders = "Select * FROM orders WHERE order_no = '$order_no'"; + $resultShowOrders = $conn->query($showOrders); + + // Check if there are any results + if ($resultShowOrders->num_rows > 0) { + + // Display table + echo ' + + + + + + '; + echo ' + + '; + + // Loop through results + while ($row = $resultShowOrders->fetch_assoc()) { + echo ''; + + echo ''; + + echo ''; + + + echo ''; // End unordered list + echo ''; + + echo ''; + + + echo ''; + } + echo '
BoxItemsLocationHand over to
'; + $barcodes = explode(',', $row['barcode']); // Split comma-separated values into an array + echo '
    '; // Start unordered list + foreach ($barcodes as $barcode) { + echo '
  • ' . htmlspecialchars($barcode) . '
  • '; // Escape HTML for safety + } + echo '
'; // End unordered list + echo '
'; + $item_barcodes = explode(',', $row['item_barcode']); // Split comma-separated values into an array + echo '
    '; // Start unordered list + foreach ($item_barcodes as $item_barcode) { + echo '
  • ' . htmlspecialchars($item_barcode) . '
  • '; // Escape HTML for safety + } + echo '
'; // End unordered list + echo '
' . + "L4-B-02-C-01" . + '' . + $handover_to . + '
'; + } else { + // Display message if no results + echo '

No items found.

'; + } + + ?> +
+
+
+ +
Box:
@@ -491,6 +580,10 @@
Location:

L4-B-02-C-01

+
+
Handover to:
+

Courier

+
@@ -503,15 +596,15 @@ - +
- - - - - - -
+ + + + + + +
@@ -533,9 +626,8 @@
-
- +
@@ -594,8 +686,8 @@ endif; ?> - -