Skip to content

Commit

Permalink
Giocata per il certificato pdf (illuminazione)
Browse files Browse the repository at this point in the history
  • Loading branch information
LaErre9 committed Sep 3, 2022
1 parent 5251ace commit 5a27bc7
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 3 deletions.
40 changes: 39 additions & 1 deletion main.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
#################################################
# SelfTestCOVID-19
#################################################
from flask import Flask, render_template, redirect, request, session
from flask import Flask, render_template, redirect, request, session, url_for, Response
from fpdf import FPDF
import sqlite3, pickle
import smtplib, ssl, qrcode, os
from email.mime.multipart import MIMEMultipart
Expand Down Expand Up @@ -156,6 +157,43 @@ def covid_checker():
def About():
return render_template('about.html')

@app.route('/download/report/pdf/<int:ID>', methods=["GET", "POST"])
def download_report(ID):
pdf = FPDF()
pdf.add_page()

page_width = pdf.w - 2 * pdf.l_margin

pdf.set_font('Arial','B',14.0)
pdf.cell(page_width, 0.0, 'CERTIFICATO TAMPONE', align='C')
pdf.ln(10)

pdf.set_font('Arial', '', 12)

col_width = page_width/4

connection = connectDB()
nomepaziente = connection.execute('SELECT Nome FROM Pazienti WHERE ID = ?',(ID,)).fetchone()
connection.close()

#Non sono riuscito (a volo dopo la partita, non so cosa sto sbagliando) a far passare i dati indicati
pdf.cell(page_width, 0.0, 'GENTILE ' + str(nomepaziente) + ' Cognome', align='L')
pdf.ln(7)
pdf.cell(page_width, 0.0, 'Il tampone MOLECOLARE/RAPIDO somministrato ', align='L')
pdf.ln(7)
pdf.cell(page_width, 0.0, 'nella Farmacia XYZ in data XXYYZZ è risultato NEGATIVO', align='L')
#pdf.cell(page_width, 0.0, 'Il tampone' + str(tipoTampone) + ' effettuato nella Farmacia ' + str(nomefarmacia) + 'in data ' + str(data) +' è risultato ' + str(esitoTampone), align='L')

th = pdf.font_size

pdf.ln(10)

pdf.set_font('Arial','',10.0)
pdf.cell(page_width, 0.0, '- La si ringrazia per aver scelto la nostra farmacia -', align='C')

return Response(pdf.output(dest='S').encode('latin-1'), mimetype='application/pdf', headers={'Content-Disposition':'attachment;filename=certificato_tampone_selftestCOVID19.pdf'})


@app.route('/scopri', methods=["GET", "POST"])
def scopri():
return render_template('scopri.html')
Expand Down
Binary file modified selftestcovid19.db
Binary file not shown.
6 changes: 4 additions & 2 deletions templates/PazienteRegistratoView/dashboardPaziente.html
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ <h2 class="text-center" style="margin: 25px;"><b><span style="color: #006eff;">
<th scope="col">Ora</th>
<th scope="col">Tipo Tampone</th>
<th scope="col">Esito</th>
<th scope="col">Certificato</th>
</tr>
</thead>
<tbody>
Expand All @@ -129,8 +130,9 @@ <h2 class="text-center" style="margin: 25px;"><b><span style="color: #006eff;">
{% elif esiti.EsitoTampone == "In analisi" %}
<span class="badge bg-primary text-white" style="font-size: 16px;">In Analisi</span>
{% endif %}


</td>
<td>
<a href="{{ url_for('.download_report', ID=esiti.ID) }}">Certificato disponibile</a>
</td>
</tr>
</tbody>
Expand Down

0 comments on commit 5a27bc7

Please sign in to comment.