Skip to content

Commit 79cc66a

Browse files
Fix: "send message with formatting, add box column to the items table, changed some columns in box table"
1 parent 0f9687d commit 79cc66a

File tree

7 files changed

+88
-43
lines changed

7 files changed

+88
-43
lines changed

box.php

Lines changed: 32 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,6 @@
3434
$sql = "SELECT * FROM box";
3535
$result = $conn->query($sql);
3636
}
37-
38-
3937
?>
4038

4139
<!DOCTYPE html>
@@ -530,14 +528,17 @@
530528
?>
531529
<table class="table table-borderless datatable mt-4" style="table-layout: fixed;">
532530
<thead>
533-
<tr>
534-
535-
<th scope="col" style="width:10%;">#</th>
536-
<th scope="col" style="width: 20%;">Box name</th>
537-
<th scope="col" style="width: 20%;">Box ID</th>
538-
<th scope="col" style="width: 20%;">Comp. Name</th>
531+
<tr>
532+
<th scope="col" style="width: 8%;">Box ID</th>
533+
<th scope="col" style="width: 14%;">Box name</th>
534+
<th scope="col" style="width: 14%;">Company</th>
535+
<th scope="col" style="width: 14%;">Branch</th>
539536
<!-- <th scope="col" style="width: 24%;">Company Name</th> -->
540-
<th scope="col" style="width: 20%;">Created at</th>
537+
<th scope="col" style="width: 14%;">Created at</th>
538+
<th scope="col" style="width: 14%;">Receive Date</th>
539+
<th scope="col" style="width: 10%;">Sender</th>
540+
<th scope="col" style="width: 14%;">Received via</th>
541+
541542
<!-- <th scope="col" style="width: 30%;">Barcode</th> -->
542543
<th scope="col" style="width: 10%;">Action</th>
543544
</tr>
@@ -556,31 +557,48 @@
556557

557558
echo "<tr>";
558559
echo "<tr>";
559-
echo "<td>" . $counter++ . "</td>";
560+
echo "<td>" . ($row["box_id"]) . "</td>";
560561
?>
561562
<td>
562563
<?php echo $row['box_name']; ?>
563564
</td>
564565
<?php
565566

566-
echo "<td>" . ($row["box_id"]) . "</td>";
567+
567568

568569
//get specific company id
569-
$comp_item=$row['companiID_FK'];
570+
$comp_id=$row['companiID_FK'];
570571

571572
//show company name of box
572-
$sql3 = "SELECT * FROM compani WHERE comp_id= '$comp_item'";
573+
$sql3 = "SELECT * FROM compani WHERE comp_id= '$comp_id'";
573574
$result3 = $conn->query($sql3);
574-
if($result->num_rows>0){
575+
if($result3->num_rows>0){
575576
$row3= $result3->fetch_assoc();
576577
$comp_name=$row3['comp_name'];
577578
}
578579

579580

580581
echo "<td>" . $comp_name. "</td>";
582+
583+
584+
//get specific branch id
585+
$branch_id=$row['branchID_FK'];
586+
587+
//show branch name of box
588+
$sql7 = "SELECT * FROM branch WHERE branch_id= '$branch_id'";
589+
$result7 = $conn->query($sql7);
590+
if($result7->num_rows>0){
591+
$row7= $result7->fetch_assoc();
592+
$branch_name=$row7['branch_name'];
593+
}
594+
595+
echo "<td>" . $branch_name. "</td>";
581596

582597

583598
echo "<td>" . ($row["created_at"]) . "</td>";
599+
echo "<td>" . ($row["rec_date"]) . "</td>";
600+
echo "<td>" . ($row["sender"]) . "</td>";
601+
echo "<td>" . ($row["rec_via"]) . "</td>";
584602
// echo "<td>" . '<img class="barcode" alt="' . ($row["barcode"]) . '" src="barcode.php?text=' . urlencode($row["barcode"]) . '&codetype=code128&orientation=horizontal&size=20&print=false"/>' . "</td>";
585603
?>
586604
<td>

createBox.php

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@
2828
$company_id = $_POST['company'];
2929
$branch_id = $_POST['branch'];
3030
$barcode = $_POST['barcode'];
31+
$rec_date= $_POST['rec_date'];
32+
$sender=$_POST['sender'];
33+
$rec_via=$_POST['rec_via'];
3134

3235
// Check if the box name and barcode already exists in the database
3336
$nameCheck = "SELECT * FROM `box` WHERE `box_name` = '$box_name' AND `barcode`='$barcode'";
@@ -38,7 +41,7 @@
3841
}
3942

4043
//insert data into box
41-
$sql = "INSERT INTO box (box_name, companiID_FK, branchID_FK, barcode) VALUES ('$box_name', '$company_id', '$branch_id', '$barcode')";
44+
$sql = "INSERT INTO box (box_name, companiID_FK, branchID_FK, barcode, rec_date, sender, rec_via) VALUES ('$box_name', '$company_id', '$branch_id', '$barcode', '$rec_date', '$sender', '$rec_via')";
4245

4346
if ($conn->query($sql) === TRUE) {
4447
header("location: box.php");
@@ -458,6 +461,20 @@
458461
</div>
459462
</div>
460463

464+
<div class="col-md-6">
465+
<label for="rec_date">Receive date</label>
466+
<input type="datetime-local" class="form-control" name="rec_date">
467+
</div>
468+
<div class="col-md-6">
469+
<label for="sender">Sender</label>
470+
<input type="text" class="form-control" name="sender">
471+
</div>
472+
473+
<div class="col-md-6">
474+
<label for="rec_via">Receive via</label>
475+
<input type="text" class="form-control" name="rec_via">
476+
</div>
477+
461478
<div class="col-md-6">
462479
<label class="form-label">Barcode</label>
463480
<input type="text" class="form-control" name="barcode" id="box_barcode">

createitem.php

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,18 +15,16 @@
1515

1616
$email = $_SESSION['email'];
1717
//get user name and email from register table
18-
$getAdminData = "SELECT * FROM register WHERE email = '$email'";
19-
$resultData = mysqli_query($conn, $getAdminData);
20-
if($resultData ->num_rows > 0){
21-
$row2= $resultData->fetch_assoc();
22-
$adminName= $row2['name'];
23-
$adminEmail=$row2['email'];
24-
}
18+
$getAdminData = "SELECT * FROM register WHERE email = '$email'";
19+
$resultData = mysqli_query($conn, $getAdminData);
20+
if ($resultData->num_rows > 0) {
21+
$row2 = $resultData->fetch_assoc();
22+
$adminName = $row2['name'];
23+
$adminEmail = $row2['email'];
24+
}
2525

2626
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
2727
$item_name = mysqli_real_escape_string($conn, $_POST['item_name']);
28-
$item_price = mysqli_real_escape_string($conn, $_POST['item_price']);
29-
$item_quantity = mysqli_real_escape_string($conn, $_POST['item_quantity']);
3028
$company_FK_item = mysqli_real_escape_string($conn, $_POST['comp_FK_item']);
3129
$box_FK_item = mysqli_real_escape_string($conn, $_POST['box_FK_item']);
3230
$branch_FK_item = mysqli_real_escape_string($conn, $_POST['branch_FK_item']);
@@ -41,8 +39,8 @@
4139
die("Error: The item name '$item_name' and barcode '$barcode' already exists.");
4240
}
4341

44-
$sql = "INSERT INTO item (comp_FK_item, box_FK_item, branch_FK_item, item_name, item_price, item_quantity, status, barcode)
45-
VALUES ('$company_FK_item', '$box_FK_item', '$branch_FK_item' ,'$item_name', '$item_price', '$item_quantity' ,'$status', '$barcode')";
42+
$sql = "INSERT INTO item (comp_FK_item, box_FK_item, branch_FK_item, item_name, status, barcode)
43+
VALUES ('$company_FK_item', '$box_FK_item', '$branch_FK_item' ,'$item_name','$status', '$barcode')";
4644

4745
if ($conn->query($sql) === TRUE) {
4846
header("location: showItems.php");
@@ -420,7 +418,11 @@
420418
<div class="card-body">
421419
<br>
422420
<!-- Multi Columns Form -->
423-
<form class="row g-3 needs-validation" action="" method="POST" enctype="multipart/form-data">
421+
<form class="row g-3 needs-validation" id="addItemForm" action="" method="POST" enctype="multipart/form-data">
422+
423+
<!-- Checkbox to cancel auto-selection -->
424+
<input type="checkbox" id="cancelAutoSelection" name="cancelAutoSelection">
425+
<label for="cancelAutoSelection">Cancel Auto-Selection</label>
424426

425427
<div class="col-md-6">
426428
<label for="company">Select Company:</label>

itemUpdate.php

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,6 @@
5252
//update the record
5353
if (isset($_POST['update'])) {
5454
$item_name = mysqli_real_escape_string($conn, $_POST['item_name']);
55-
$item_price = mysqli_real_escape_string($conn, $_POST['item_price']);
56-
$item_quantity = mysqli_real_escape_string($conn, $_POST['item_quantity']);
5755
$status = mysqli_real_escape_string($conn, $_POST['status']);
5856

5957
$sql = "UPDATE `item` SET `item_name`='$item_name', `item_price`='$item_price' , `item_quantity`='$item_quantity', `status`='$status' WHERE `item_id`='$item_id'";
@@ -650,17 +648,7 @@
650648
<input type="text" class="form-control" name="item_name" required pattern="[A-Za-z\s]+" required minlength="3" maxlength="38" title="only letters allowed; at least 3" value="<?php echo $item_name; ?>" required>
651649

652650
</div>
653-
<div class="col-md-6">
654-
<label class="form-label">Item price</label>
655-
<input type="text" class="form-control" name="item_price" value="<?php echo $item_price; ?>" required>
656-
657-
</div>
658-
659-
<div class="col-md-6">
660-
<label class="form-label">Item quantity</label>
661-
<input type="text" class="form-control" name="item_quantity" value="<?php echo $item_quantity; ?>" required>
662-
663-
</div>
651+
664652

665653
<div class="col-md-6">
666654
<label class="form-label">Item Condition</label>
@@ -670,7 +658,7 @@
670658

671659
<div class="col-md-6">
672660
<label class="form-label">Barcode</label>
673-
<input type="text" class="form-control" name="barcode" value="<?php echo $barcode; ?>" required>
661+
<input type="text" class="form-control" name="barcode" value="<?php echo $barcode; ?>" readonly>
674662

675663
</div>
676664

pages-contact.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,6 @@
211211
<nav>
212212
<ol class="breadcrumb">
213213
<li class="breadcrumb-item"><a href="index.html">Home</a></li>
214-
<li class="breadcrumb-item">Pages</li>
215214
<li class="breadcrumb-item active">Contact</li>
216215
</ol>
217216
</nav>

sendmail.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
//Content
3737
$mail->isHTML(true); //Set email format to HTML
3838
$mail->Subject = $subject;
39-
$mail->Body = $message;
39+
$mail->Body = nl2br($message); //used nlbr which is used for new lines or formatting
4040

4141
$mail->send();
4242
echo 'Message has been sent';

showItems.php

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,11 @@
2727

2828
// Search query: match barcode exactly or item name partially
2929
$sql = "SELECT * FROM item WHERE barcode = '$searchQuery' OR item_name LIKE '%$searchQuery%'";
30+
$result = $conn->query($sql);
3031
} else {
3132
// Default query if no search is performed
3233
$sql = "SELECT * FROM item";
34+
$result = $conn->query($sql);
3335
}
3436

3537
$result = $conn->query($sql);
@@ -577,6 +579,7 @@
577579
<th scope="col" style="width: 10%;">#</th>
578580

579581
<th scope="col" style="width: 15%;">Item Name</th>
582+
<th scope="col" style="width: 17%;">Box</th>
580583
<th scope="col" style="width: 13%;">Condition</th>
581584
<th scope="col" style="width: 20%;">Created at</th>
582585
<th scope="col" style="width: 25%;"> Barcode </th>
@@ -597,8 +600,24 @@
597600
echo "<tr>";
598601
echo "<td>" . $counter++ . "</td>";
599602
echo "<td>" . ($row["item_name"]) . "</td>";
603+
604+
//get specific box id
605+
$box_id = $row['box_FK_item'];
606+
607+
//show company name of box
608+
$sql5 = "SELECT * FROM box WHERE box_id= '$box_id'";
609+
$result5 = $conn->query($sql5);
610+
if ($result5->num_rows > 0) {
611+
$row5 = $result5->fetch_assoc();
612+
$box_name = $row5['box_name'];
613+
}
614+
615+
echo "<td>" . $box_name . "</td>";
616+
600617
echo "<td><span>" . $row["status"] . "</span></td>";
618+
601619
echo "<td>" . ($row["timestamp"]) . "</td>";
620+
602621
echo "<td>" . '<img class="barcode" alt="' . ($row["item_id"]) . '" src="barcode.php?text=' . urlencode($row["item_id"]) . '&codetype=code128&orientation=horizontal&size=20&print=false"/>' . "</td>";
603622

604623
?>
@@ -612,6 +631,8 @@
612631
</td>
613632
</tr>
614633
<?php
634+
635+
615636
}
616637
?>
617638

0 commit comments

Comments
 (0)