Skip to content

Commit

Permalink
Merge branch 'testing' into SPD-151-SPD-153-SPD-154
Browse files Browse the repository at this point in the history
  • Loading branch information
F-Seannnnnn authored Jul 19, 2024
2 parents 66dd169 + 79f12ff commit 6adc6c9
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 32 deletions.
24 changes: 7 additions & 17 deletions src/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -230,12 +230,12 @@
</div>
</div>

<div class="row">
<div class="row mt-2">
<div class="col-md-9"> <!-- Increased py-4 for more padding -->
<div class="col-md-12 bg-white mb-3 rounded-3 p-4" style="box-shadow: 0px 0px 10px rgba(0, 0, 0, 0.4); height: 410px;"> <!-- Added box-shadow style for drop shadow -->
<!-- Larger Container 3 -->
<div class="p-2 mb-2 fw-semibold text-carbon-grey">
WEEKLY TOP SOLD PRODUCTS
TOP PRODUCT PAIRINGS OF THE WEEK
</div>
<div class="table-container">
<table id="example" class="styled-table">
Expand All @@ -252,7 +252,7 @@
$output = shell_exec('python apriori/apriori_algo.py 2>&1');

// Fetch the specific item with ID 1 from the database
$sql = "SELECT antecedent, consequent FROM frequent_items WHERE id = 1";
$sql = "SELECT antecedent, consequent FROM frequent_items";
$result = $db->query($sql);

$topPickData = [];
Expand All @@ -262,15 +262,13 @@
echo "<tr>
<td>
<div class='product-info'>
<img class='pt-2 card-img-top' src='images/coffee-img-placeholder.png'>
<span class='spaced-text text-capitalize fw-semibold'>" . htmlspecialchars($row["antecedent"]) . "</span>
<span class='spaced-text text-capitalize'>" . htmlspecialchars($row["antecedent"]) . "</span>
</div>
</td>
<td class='plus-sign' style='color: #C57C47;'>+</td>
<td class='fw-bold' style='color: #343a40;'>+</td>
<td>
<div class='product-info'>
<img class='pt-2 card-img-top' src='images/coffee-img-placeholder.png'>
<span class='spaced-text text-capitalize fw-semibold'>" . htmlspecialchars($row["consequent"]) . "</span>
<span class='spaced-text text-capitalize'>" . htmlspecialchars($row["consequent"]) . "</span>
</div>
</td>
</tr>";
Expand All @@ -285,15 +283,7 @@
</td>
</tr>";
}
// Fetch the all the items from the database
$sql = "SELECT antecedent, consequent FROM frequent_items";
$result = $db->query($sql);

$topPickDatas = [];
if ($result->num_rows > 0) {
while ($row = $result->fetch_assoc()) {
$topPickDatas[] = [addslashes($row["antecedent"]), '+', addslashes($row["consequent"])];}}
$jsonTopPickData = json_encode($topPickDatas);
$jsonTopPickData = json_encode($topPickData);
?>
</tbody>
</table>
Expand Down
22 changes: 13 additions & 9 deletions src/javascript/reports.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ async function downloadPDF() {
},
bodyStyles: {
fillColor: "#ffffff",
textColor: "#88531E",
textColor: "#000000",
},
});

Expand Down Expand Up @@ -147,14 +147,14 @@ async function downloadPDF() {
},
bodyStyles: {
fillColor: "#ffffff",
textColor: "#88531E",
textColor: "#000000",
},
});

// Top Pick and Likely Paired With Table
doc.setFontSize(14);
doc.setFont("Helvetica", "bold");
doc.text("Weekly Top Sold Products", 15, doc.previousAutoTable.finalY + 10);
doc.text("Top Product Pairings of the Week", 15, doc.previousAutoTable.finalY + 10);

const topPickHeaders = ["Top Pick", "", "Likely Paired With"];
doc.autoTable({
Expand All @@ -163,19 +163,23 @@ async function downloadPDF() {
body: topPickData,
theme: "grid",
styles: {
textColor: "#88531E",
fillColor: "#ffffff",
textColor: "#ffffff",
fillColor: "#88531E",
halign: "center",
},
headStyles: {
fillColor: "#ffffff",
textColor: "#88531E",
fillColor: "#88531E",
textColor: "#ffffff",
},
bodyStyles: {
fillColor: "#ffffff",
textColor: "#88531E",
textColor: "#000000",
},
});

doc.save("report.pdf");
// Format the date for the filename
const formattedDate = today.toLocaleDateString('en-GB').replace(/\//g, '-');
const fileName = `Reports for ${formattedDate}.pdf`;

doc.save(fileName);
}
7 changes: 1 addition & 6 deletions src/styles/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -12795,7 +12795,7 @@ textarea.form-control-lg {
.styled-table thead tr {
background-color: #FFFFFF;
/* Changed background color */
color: #343a40;
color: #C57C47;
}

.styled-table th,
Expand All @@ -12819,11 +12819,6 @@ textarea.form-control-lg {
background-color: #FFFFFF;
}

.styled-table tbody tr.active-row {
font-weight: bold;
color: #343a40;
}

.plus-sign {
font-weight: bold;
font-size: 5em;
Expand Down

0 comments on commit 6adc6c9

Please sign in to comment.