Repository navigation
Expand file tree
/
Copy pathscript.js
More file actions
92 lines (81 loc) · 4.11 KB
/
Copy pathscript.js
File metadata and controls
92 lines (81 loc) · 4.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
async function generatePlan() {
const { jsPDF } = window.jspdf;
const doc = new jsPDF();
const formData = {
title: "PRAKTIKPLAN",
subtitle: "Studerandes kontaktuppgifter:",
date: getDate(),
name: document.getElementById('name').value,
phone: document.getElementById('phone').value,
subtitle2: "Företagets kontaktuppgifter:",
department: document.getElementById('department').value,
address: document.getElementById('address').value,
website: document.getElementById('website').value,
contactPerson: document.getElementById('contactPerson').value,
contactPhone: document.getElementById('contactPhone').value,
email: document.getElementById('email').value,
subtitle3: "Titel & beskrivning:",
assignment: document.getElementById('assignment').value,
subtitle4: "Förhandskunskaper:",
prerequisites: document.getElementById('prerequisites').value,
subtitle5: "Arbetsuppgifter:",
tasks: document.getElementById('tasks').value,
};
// Add a logo image
const imgData = './logo_small.png '; // Placeholder image URL
doc.addImage(imgData, 'PNG', 110, 0, 80, 40); // Adjust dimensions as needed
// Add form data to PDF
doc.setFontSize(20);
doc.text(formData.title, 20, 20);
doc.setFontSize(16);
doc.text(formData.subtitle, 20, 30);
doc.setDrawColor(0); doc.setFillColor(255, 255, 255);
doc.rect(20, 35, doc.internal.pageSize.width * 0.8, 25 , 'FD');
doc.text(`Datum: ${formData.date}`, 25, 42, { maxWidth: doc.internal.pageSize.width * 0.75 });
doc.text(`Namn: ${formData.name}`, 25, 49, { maxWidth: doc.internal.pageSize.width * 0.75 });
doc.text(`Telefon: ${formData.phone}`, 25, 56, { maxWidth: doc.internal.pageSize.width * 0.75 });
doc.setFontSize(16);
doc.text(formData.subtitle2, 20, 70);
doc.setDrawColor(0); doc.setFillColor(255, 255, 255);
doc.rect(20, 75, doc.internal.pageSize.width * 0.8, 46, 'FD');
doc.text(`Namn/Avdelning: ${formData.department}`, 25, 82, { maxWidth: doc.internal.pageSize.width * 0.75 });
doc.text(`Adress: ${formData.address}`, 25, 89, { maxWidth: doc.internal.pageSize.width * 0.75 });
doc.text(`Webbsida: ${formData.website}`, 25, 96, { maxWidth: doc.internal.pageSize.width * 0.75 });
doc.text(`Kontaktperson/Handledare: ${formData.contactPerson}`, 25, 103, { maxWidth: doc.internal.pageSize.width * 0.75 });
doc.text(`Telefon: ${formData.contactPhone}`, 25, 110, { maxWidth: doc.internal.pageSize.width * 0.75 });
doc.text(`Epost: ${formData.email}`, 25, 117, { maxWidth: doc.internal.pageSize.width * 0.75 });
doc.setFontSize(16);
doc.text(formData.subtitle3, 20, 130);
doc.setDrawColor(0); doc.setFillColor(255, 255, 255);
doc.rect(20, 135, doc.internal.pageSize.width * 0.8, 30, 'FD');
doc.text(`${formData.assignment}`, 25, 142, { maxWidth: doc.internal.pageSize.width * 0.75 });
doc.setFontSize(16);
doc.text(formData.subtitle4, 20, 175);
doc.setDrawColor(0); doc.setFillColor(255, 255, 255);
doc.rect(20, 180, doc.internal.pageSize.width * 0.8, 30, 'FD');
doc.text(`${formData.prerequisites}`, 25, 187, { maxWidth: doc.internal.pageSize.width * 0.75 });
doc.setFontSize(16);
doc.text(formData.subtitle5, 20, 220);
// Black border, white fill for box
doc.setDrawColor(0); doc.setFillColor(255, 255, 255);
doc.rect(20, 225, doc.internal.pageSize.width * 0.8, 30, 'FD');
doc.text(`${formData.tasks}`, 25, 232, { maxWidth: doc.internal.pageSize.width * 0.75 });
doc.save('report.pdf');
}
function toggleForm() {
if (document.querySelector("#planForm").style.display != "block") {
document.querySelector("#planForm").style.display = "block";
} else {
document.querySelector("#planForm").style.display = "none"
}
}
function getDate()
{
let today = new Date();
let dd = today.getDate();
let mm = today.getMonth()+1; //January is 0!
let yyyy = today.getFullYear();
if(dd<10){dd='0'+dd} if(mm<10){mm='0'+mm}
today = dd+"."+mm+"."+yyyy;
return today;
}