diff --git a/assets/js/ExScript.js b/assets/js/ExScript.js
index 47388e9..b1450bb 100644
--- a/assets/js/ExScript.js
+++ b/assets/js/ExScript.js
@@ -47,7 +47,7 @@ const showSuggestionsEx = (i) => {
}
};
-const addInput = (e) => {
+var addInput = (e) => {
for(const Selecteday of Exdays) {
if (ExDb[Selecteday][`${e.target.id.substring(0, e.target.id.length - 3)}`].length >
@@ -103,9 +103,9 @@ const addInput = (e) => {
});
for (let lea = 0; lea < 3; lea++) {
let htm1 = "";
- htm1 = `
`;
+ htm1 = `";
@@ -116,6 +116,7 @@ const addInput = (e) => {
`#${Selecteday}Tbl #${e.target.id.substring(0, e.target.id.length - 3)}Tr`
)
.appendChild(newTd1);
+ newTd1.classList.add(`${e.target.id.substring(0, e.target.id.length - 3)}SubTd`);
}
});
diff --git a/assets/js/domGet.js b/assets/js/domGet.js
index 7a22100..312c72d 100644
--- a/assets/js/domGet.js
+++ b/assets/js/domGet.js
@@ -52,6 +52,9 @@ const selectedItemsList = document.getElementsByClassName("selectedItems");
var timeInput = document.querySelectorAll("input[type='time']");
const body = document.body;
+const getBothBtn = document.getElementById("getBothBtn");
+const getExBtn =document.getElementById("getExBtn");
+
const trItems = document.querySelectorAll("#foodTable tr");
const trItemsData = document.querySelectorAll("#DataTable tr");
diff --git a/assets/js/eventListeners.js b/assets/js/eventListeners.js
index 66029ae..ea47c84 100644
--- a/assets/js/eventListeners.js
+++ b/assets/js/eventListeners.js
@@ -211,14 +211,13 @@ setOrderBtn.addEventListener("click", (e) => {
const newDiv = document.createElement("div");
newDiv.innerHTML = `
+ .join("")}" '>${order[i].textContent}
{
.addEventListener("click", addSelectedEx);
const userInputEx = document.querySelectorAll("[list='itemListEx']");
console.log(userInputEx);
- document.getElementById(`${order[i].textContent.split(" ").join("")}Var`).addEventListener("change", addInput);
+ document.getElementById(`${order[i].textContent.split(" ").join("")}Var`).addEventListener("change", (e)=> addInput(e));
userInputEx.forEach((j) => {
j.addEventListener("keyup", (k) => {
showSuggestionsEx(k.target);
@@ -304,3 +303,14 @@ DayExChks.forEach((i) => {
});
AlldayEx.addEventListener("click", CheckAllEx);
+getPDFBtn.addEventListener("click", (e) => {
+ printPdf(e,0);
+});
+
+getExBtn.addEventListener("click", (e) => {
+ printPdf(e,1);
+});
+
+getBothBtn.addEventListener("click", (e) => {
+ printPdf(e,2);
+});
diff --git a/assets/js/printPdf.js b/assets/js/printPdf.js
index c7f7407..5371b02 100644
--- a/assets/js/printPdf.js
+++ b/assets/js/printPdf.js
@@ -3,81 +3,14 @@
* Represents an event listener for the "getPDFBtn" button click.
* @param {Event} e - The click event object.
*/
-getPDFBtn.addEventListener("click", (e) => {
+
+function printPdf(e, i) {
+
+
e.preventDefault();
const nameval = document.getElementById("client_name").value;
const clientid = document.getElementById("membership_id").value;
console.log(goal)
- const dayOne = [
- ["Day 1", "Exercise", "Rep", "Sets", "Rest"],
- ];
- const dayTwo = [
- ["Day 1", "Exercise", "Rep", "Sets", "Rest"],
- ];
- const dayThree = [
- ["Day 1", "Exercise", "Rep", "Sets", "Rest"],
- ];
- const dayFour = [
- ["Day 1", "Exercise", "Rep", "Sets", "Rest"],
- ];
- const dayFive = [
- ["Day 1", "Exercise", "Rep", "Sets", "Rest"],
- ];
- const daySix = [
- ["Day 1", "Exercise", "Rep", "Sets", "Rest"],
- ];
- const daySeven = [
- ["Day 1", "Exercise", "Rep", "Sets", "Rest"],
- ];
- const tableLayout = [
- { text: "Column 1", width: "*" },
- { text: "Column 2" },
- { text: "Column 3", alignment: "right" },
- ];
-
- const table2Content = dayTwo.map((row) => {
- return tableLayout.map((column, index) => {
- return { text: row[index] };
- });
- });
-
- const table3Content = dayThree.map((row) => {
- return tableLayout.map((column, index) => {
- return { text: row[index] };
- });
- });
-
- const table4Content = dayFour.map((row) => {
- return tableLayout.map((column, index) => {
- return { text: row[index] };
- });
- });
-
- const table5Content = dayFive.map((row) => {
- return tableLayout.map((column, index) => {
- return { text: row[index] };
- });
- });
-
- const table6Content = daySix.map((row) => {
- return tableLayout.map((column, index) => {
- return { text: row[index] };
- });
- });
-
- const table7Content = daySeven.map((row) => {
- return tableLayout.map((column, index) => {
- return { text: row[index] };
- });
- });
-
- const table1Content = dayOne.map((row) => {
- return tableLayout.map((column, index) => {
- return { text: row[index] };
- });
- });
-
-
const canvasy = document.getElementById("foo");
const imageData = canvasy.toDataURL();
//docDefinition
@@ -394,20 +327,108 @@ getPDFBtn.addEventListener("click", (e) => {
}
];
+ //widths: [85, 103, 93, 93, 93],
let exerciseTable = [
{
margin: [0, 20, 0, 0],
text: "Exercise Plan",
style: 'header',
},
- {
+ ];
+
+
+ let DaysEx = {
+
+ Day1: {
margin: [0, 10, 0, 0],
table: {
- headerRows: 1,
- widths: [55, 55, 55, 55, 55],
+ widths: [85, 103, 93, 93, 93],
body: [
[
- { text: "Day", bold: true },
+ { text: "Day 1", bold: true },
+ { text: "Exercise", bold: true },
+ { text: "Rep", bold: true },
+ { text: "Sets", bold: true },
+ { text: "Rest", bold: true },
+ ],
+ ],
+ },
+ },
+
+ Day2: {
+ margin: [0, 10, 0, 0],
+ table: {
+ widths: [85, 103, 93, 93, 93],
+ body: [
+ [
+ { text: "Day 2", bold: true },
+ { text: "Exercise", bold: true },
+ { text: "Rep", bold: true },
+ { text: "Sets", bold: true },
+ { text: "Rest", bold: true },
+ ],
+ ],
+ },
+ },
+
+ Day3: {
+ margin: [0, 10, 0, 0],
+ table: {
+ widths: [85, 103, 93, 93, 93],
+ body: [
+ [
+ { text: "Day 3", bold: true },
+ { text: "Exercise", bold: true },
+ { text: "Rep", bold: true },
+ { text: "Sets", bold: true },
+ { text: "Rest", bold: true },
+ ],
+ ],
+ },
+ },
+
+
+ Day4: {
+ margin: [0, 10, 0, 0],
+ table: {
+ widths: [85, 103, 93, 93, 93],
+ body: [
+ [
+ { text: "Day 4", bold: true },
+ { text: "Exercise", bold: true },
+ { text: "Rep", bold: true },
+ { text: "Sets", bold: true },
+ { text: "Rest", bold: true },
+ ],
+ ],
+ },
+ },
+
+
+ Day5: {
+ margin: [0, 10, 0, 0],
+ table: {
+ widths: [85, 103, 93, 93, 93],
+ body: [
+ [
+ { text: "Day 5", bold: true },
+ { text: "Exercise", bold: true },
+ { text: "Rep", bold: true },
+ { text: "Sets", bold: true },
+ { text: "Rest", bold: true },
+ ],
+ ],
+ },
+ },
+
+
+ Day6: {
+ margin: [0, 10, 0, 0],
+ table: {
+ widths: [85, 103, 93, 93, 93],
+ body: [
+ [
+ { text: "Day 6", bold: true },
{ text: "Exercise", bold: true },
{ text: "Rep", bold: true },
{ text: "Sets", bold: true },
@@ -416,7 +437,50 @@ getPDFBtn.addEventListener("click", (e) => {
],
},
},
- ];
+
+
+ Day7: {
+ margin: [0, 10, 0, 0],
+ table: {
+ widths: [85, 103, 93, 93, 93],
+ body: [
+ [
+ { text: "Day 7", bold: true },
+ { text: "Exercise", bold: true },
+ { text: "Rep", bold: true },
+ { text: "Sets", bold: true },
+ { text: "Rest", bold: true },
+ ],
+ ],
+ },
+ },
+ }
+
+
+
+
+
+ for (const daysL in ExDb) {
+ let jo = 0;
+ for (const x in ExDb[daysL]) {
+ DaysEx[daysL].table.body.push([{ text: x, bold: true }, { layout: 'lightHorizontalLines', table: { body: [] } }, { layout: 'lightHorizontalLines', table: { body: [] } }, { layout: 'lightHorizontalLines', table: { body: [] } }, { layout: 'lightHorizontalLines', table: { body: [] } }]);
+ let lim = Number(document.querySelectorAll(`#${daysL}Tbl .${x}SubTd .In0`)[0].getAttribute('data-lim'));
+ for (const y in ExDb.Day1[x]) {
+ DaysEx[daysL].table.body[1 + jo][1].table.body.push([ExDb.Day1[x][y]])
+ }
+ for (let i = 0; i < lim; i++) {
+ DaysEx[daysL].table.body[1 + jo][2].table.body.push([document.querySelectorAll(`#${daysL}Tbl .${x}SubTd .In${i}`)[0].value])
+ DaysEx[daysL].table.body[1 + jo][3].table.body.push([document.querySelectorAll(`#${daysL}Tbl .${x}SubTd .In${i}`)[1].value])
+ DaysEx[daysL].table.body[1 + jo][4].table.body.push([document.querySelectorAll(`#${daysL}Tbl .${x}SubTd .In${i}`)[2].value])
+
+ }
+ jo++;
+ }
+
+ exerciseTable.push(DaysEx[daysL]);
+ }
+
+
let remarks = [
@@ -447,10 +511,15 @@ getPDFBtn.addEventListener("click", (e) => {
+
+
+ if(i === 0 || i===2) {
DataDef.content.push(foodTable);
+ }
+ if(i === 1 || i===2) {
DataDef.content.push(exerciseTable);
+ }
DataDef.content.push(remarks);
DataDef.styles = style;
-
pdfMake.createPdf(DataDef).download(`${nameval}-Diet.pdf`);
-});
+};