Skip to content

Commit

Permalink
changed details row with table
Browse files Browse the repository at this point in the history
  • Loading branch information
kamranzafar4343 committed Nov 22, 2024
1 parent 20801e4 commit 31d7bce
Show file tree
Hide file tree
Showing 5 changed files with 143 additions and 33 deletions.
11 changes: 11 additions & 0 deletions assignTaskForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -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')";
Expand Down
Binary file added image/messages_3.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
24 changes: 17 additions & 7 deletions order.php
Original file line number Diff line number Diff line change
Expand Up @@ -532,6 +532,7 @@
<div class="card-body">
<h5 class="card-title">List of Delivery Work Orders</h5>
<?php

// Check if there are any results
if ($resultShowOrders->num_rows > 0) {
// Display table
Expand All @@ -552,16 +553,26 @@
echo '</tr>
</thead>
<tbody style="font-size: 11px; text-align: left;">';

// 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 '<tr>';




//workorder_no
echo '<td>' . ($row['order_no']) . '</td>';
echo '<td>' . $theStatus . '</td>';


// Get specific company id
$comp_id = $row['comp_id_fk'];
Expand All @@ -583,7 +594,7 @@

// Show account
echo '<td>' . $comp_name . " / " . $branch_name . '</td>';


echo '<td>';
if ($row["status"] == 'Completed') {
Expand Down Expand Up @@ -632,12 +643,11 @@

<a type="button"
class=""
style="height: 26px; width: 25px;"
style="height: 30px; width: 30px;"
href="assignTaskForm.php?id=<?php echo $row['order_no']; ?>"
target="_blank">
<img src="assets/img/Gartoon-Team-Gartoon-Misc-Stock-Task-Assigned.32.png" alt="View">
</a>

</div>
</td>
<?php
Expand Down Expand Up @@ -721,7 +731,7 @@ class=""
//collapse by default
"searchPanes": {
"initCollapsed": true,
columns: [1, 3, 4] // Enable filters for columns 1, 3, and 5 only
columns: [1, 3, 4] // Enable filters for columns 1, 3, and 5 only
}

});
Expand Down
138 changes: 115 additions & 23 deletions taskView.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@
$rec_name = mysqli_real_escape_string($conn, $_POST['rec_name']);
$rec_phone = mysqli_real_escape_string($conn, $_POST['rec_phone']);

//---------------------------set image variable------------------------ and its validation
//ensure file is uploaded
if (!isset($_FILES['image']) || $_FILES['image']['error'] == UPLOAD_ERR_NO_FILE) {
//---------------------------set image variable------------------------ and its validation
//ensure file is uploaded
if (!isset($_FILES['image']) || $_FILES['image']['error'] == UPLOAD_ERR_NO_FILE) {
die("No file was uploaded.");
}

Expand Down Expand Up @@ -72,14 +72,24 @@
$cross_check = mysqli_real_escape_string($conn, $_POST['checkbox1']);
$verification = mysqli_real_escape_string($conn, $_POST['checkbox2']);

//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) {
$_SESSION['success'] = "Task Completed";
header("Location: tasks.php");
} else {
echo "Error: ". $insertData . "<br>". $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 . "<br>" . $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 . "<br>" . $conn->error;
}
}
?>

Expand Down Expand Up @@ -473,6 +483,85 @@
<h6><strong>Instructions by admin:</strong></h6>
<p> 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.</p>
</div>

<div class="row">
<!-- start table of delivery items -->
<div class="cardBranch recent-sales overflow-auto">
<div class="card-body">
<?php
//get data from`assign_tasks` table
$assign_tasks = "Select * FROM assign_task WHERE order_no_fk = '$order_no'";
$result_assign_tasks = $conn->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 '<table id="orderT" class="table mt-4 nowrap" style="font-size: 12px;">
<thead>
<tr >
<th scope="col" style="width: 8%;">Box</th>
<th scope="col" style="width: 8%;">Items</th>
<th scope="col" style="width: 8%;">Location</th>
<th scope="col" style="width: 8%;">Hand over to</th>';
echo '</tr>
</thead>
<tbody>';

// Loop through results
while ($row = $resultShowOrders->fetch_assoc()) {
echo '<tr>';

echo '<td>';
$barcodes = explode(',', $row['barcode']); // Split comma-separated values into an array
echo '<ul style="list-style: none; margin-left: -30px;">'; // Start unordered list
foreach ($barcodes as $barcode) {
echo '<li>' . htmlspecialchars($barcode) . '</li>'; // Escape HTML for safety
}
echo '</ul>'; // End unordered list
echo '</td>';

echo '<td>';
$item_barcodes = explode(',', $row['item_barcode']); // Split comma-separated values into an array
echo '<ul style="list-style: none; margin-left: -30px;">'; // Start unordered list
foreach ($item_barcodes as $item_barcode) {
echo '<li>' . htmlspecialchars($item_barcode) . '</li>'; // Escape HTML for safety
}
echo '</ul>'; // End unordered list
echo '</td>';


echo '</ul>'; // End unordered list
echo '</td>';

echo '<td>' .
"L4-B-02-C-01" .
'</td>';


echo '<td>' .
$handover_to .
'</td>';
}
echo '</tbody></table>';
} else {
// Display message if no results
echo '<p>No items found.</p>';
}

?>
</div>
</div>
</div>

<!-- start row -->
<div class="row">
<div class="col-md-3">
<h6><b>Box:</b></h6>
Expand All @@ -491,6 +580,10 @@
<h6><b>Location:</b></h6>
<p>L4-B-02-C-01</p>
</div>
<div class="col-md-3">
<h6><b>Handover to:</b></h6>
<p>Courier</p>
</div>
</div>

</div>
Expand All @@ -503,15 +596,15 @@
<input type="text" class="form-control mb-1" id="" name="rec_phone" placeholder="Receiver's Phone Number" required>
<input type="text" class="form-control mb-2" id="" name="rec_cnic" placeholder="Recevier's CNIC" required>
</div>

<div class="row-md-4 mb-2">
<label for="image" class="form-label" style="font-size: 0.8rem;">Attach (receipt image):</label>
<input type="file" style="font-size: 0.9rem;" class="form-control" id="image" name="image" required accept=".jpg,.jpeg,.png" title="Only JPG, JPEG, and PNG formats are allowed">
<!-- Error messages -->
<div id="image-error" style="color:red; display:none;">Invalid image format. Only JPG, JPEG, and PNG formats are allowed.</div>
<div id="size-error" style="color:red; display:none;">File size exceeds 2 MB.</div>
<div id="dimension-error" style="color:red; display:none;">Image dimensions exceed the allowed 1024x768 size.</div>
</div>
<label for="image" class="form-label" style="font-size: 0.8rem;">Attach (receipt image):</label>
<input type="file" style="font-size: 0.9rem;" class="form-control" id="image" name="image" required accept=".jpg,.jpeg,.png" title="Only JPG, JPEG, and PNG formats are allowed">
<!-- Error messages -->
<div id="image-error" style="color:red; display:none;">Invalid image format. Only JPG, JPEG, and PNG formats are allowed.</div>
<div id="size-error" style="color:red; display:none;">File size exceeds 2 MB.</div>
<div id="dimension-error" style="color:red; display:none;">Image dimensions exceed the allowed 1024x768 size.</div>
</div>


<div class="row-md-4 mb-2">
Expand All @@ -533,9 +626,8 @@
</div>
</div>


<div class="text-center mt-4 mb-2">
<button type="submit" class="btn btn-outline-primary mr-2" name="submit" value="submit">Submit</button>
<button type="submit" class="btn btn-outline-primary mr-2" name="submit" disabled onclick="showMessage()" value="submit">Submit</button>
<button type="reset" class="btn btn-outline-secondary ">Reset</button>
</div>
</form>
Expand Down Expand Up @@ -594,8 +686,8 @@
endif;
?>

<!-- Validation Script of the header and the size of the image -->
<script>
<!-- Validation Script of the header and the size of the image -->
<script>
document.getElementById('image').addEventListener('change', function() {
const file = this.files[0];
const imageError = document.getElementById('image-error');
Expand Down
3 changes: 0 additions & 3 deletions viewOrder.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<?php

// session_start(); // Start the session
session_start();

Expand All @@ -22,7 +21,6 @@
$adminEmail = $row2['email'];
}


// Get order ID from query string
$order_no = $_GET['id'];

Expand Down Expand Up @@ -709,7 +707,6 @@
doc.document.open();
doc.document.write('<!DOCTYPE html><html><head>' + styles + '</head><body>' + content + '</body></html>');
doc.document.close();

doc.window.print();
return this;
}
Expand Down

0 comments on commit 31d7bce

Please sign in to comment.