Exemplo n.º 1
0
def contactleftLaterPages(canvas):
	textobject = canvas.beginText()
	lflwidth = canvas.stringWidth('LEFT FIELD LABS','Gridnik',12)
	addrwidth = canvas.stringWidth('510 Victoria Ave, Venice CA 90291','Akkurat',10)
	urlwidth = canvas.stringWidth('www.leftfieldlabs.com','Akkurat',10)
	phonewidth = canvas.stringWidth('424-500-2045','Akkurat',10)	
	phonex = addrwidth - phonewidth + 18
	lflx = addrwidth - lflwidth + 18
	urlx = addrwidth - urlwidth + 18
	textobject.setTextOrigin(lflx,75)
	textobject.setFont('Gridnik',12)
	textobject.textLine('LEFT FIELD LABS')
	y = textobject.getY()
	textobject.setTextOrigin(18,y)
	textobject.setFont('Akkurat',10)
	textobject.textLine('510 Victoria Ave, Venice CA 90291')
	yy = textobject.getY()
	textobject.setTextOrigin(urlx,yy)
	textobject.textLine('www.leftfieldlabs.com')
	yyy = textobject.getY()
	textobject.setTextOrigin(phonex,yyy)
	textobject.textLine('424-500-2045')
	canvas.drawText(textobject)
Exemplo n.º 2
0
def contactleftFirstPage(canvas):
	textobject = canvas.beginText()
	addrwidth = canvas.stringWidth('510 Victoria Ave, Venice CA 90291','Akkurat',10)
	urlwidth = canvas.stringWidth('www.leftfieldlabs.com','Akkurat',10)
	urlx = addrwidth - urlwidth + 18
	phonewidth = canvas.stringWidth('424-500-2045','Akkurat',10)	
	phonex = addrwidth - phonewidth + 18	
	textobject.setTextOrigin(18,75)	
	textobject.setFont('Akkurat',10)
	textobject.textLine('510 Victoria Ave, Venice CA 90291')
	yy = textobject.getY()
	textobject.setTextOrigin(urlx,yy)
	textobject.textLine('www.leftfieldlabs.com')
	yyy = textobject.getY()
	textobject.setTextOrigin(phonex,yyy)
	textobject.textLine('424-500-2045')
	canvas.drawText(textobject)
Exemplo n.º 3
0
def pdf(etu, master, presence, administration):

    from reportlab.lib.units import cm, inch
    usmb = os.path.join("./app/static/img", 'logoUSMB2.png')
    fc = os.path.join("./app/static/img", "logoFC.jpg")
    signaturePNG = os.path.join("./app/static/img", "signature.png")

    president = administration[0][4]
    SFC = administration[0][5]

    master = master
    alternant = etu
    periodeDebut = administration[0][2]
    periodeFin = administration[0][3]

    pathPDF = "./app/static/pdf"
    pathArchive = "./app/static/archive"
    filename = alternant + " Attestation.pdf"
    currDate = datetime.now()
    c = canvas.Canvas(os.path.join(pathPDF, filename))
    #obtention de l'année scolaire
    debutScol = datetime.strptime(administration[0][0], '%d/%m/%Y').date()
    finScol = datetime.strptime(administration[0][1], '%d/%m/%Y').date()
    anneeScolaire = str(debutScol.year) + "/" + str(finScol.year)
    #calcul de la présence
    dateDebut = datetime.strptime(periodeDebut, '%d/%m/%Y').date()
    dateFin = datetime.strptime(periodeFin, '%d/%m/%Y').date()
    for i in range(0, len(presence)):
        presence[i] = list(presence[i])

        presence[i][3] = datetime.strptime(presence[i][3], '%d/%m/%Y').date()
    presence = sorted(presence, key=lambda presence: presence[3])

    i = 0
    while (i != len(presence)):
        if (presence[i][3] < dateDebut):
            presence.remove(presence[i])
        elif (presence[i][3] > dateFin):
            presence.remove(presence[i])
        else:
            i += 1

    presenceVirtuel = len(presence) * 7

    cnx = mysql.connector.connect(host=config.BDD_host,
                                  database=config.BDD_database,
                                  user=config.BDD_user,
                                  password=config.BDD_password)
    cursor = cnx.cursor()

    tabEtu = alternant.split()
    query = ("SELECT numeroEtudiant FROM etudiant WHERE nom='" +
             str(tabEtu[0]) + "' AND prenom='" + str(tabEtu[1]) + "'")

    cursor.execute(query)
    numEtu = cursor.fetchall()

    cnx.close()

    tabPresence = fonctionPy.heurePresentParMoisLimiteAffichage(
        numEtu[0][0])  # On récupère les présences selon les dates données

    presenceEffective = 0
    for key, value in tabPresence.items():
        presenceEffective += value

    # origin x y en haut à gauche
    c.translate(inch, inch)

    c.line(0, 600, 440, 600)
    c.line(0, 560, 440, 560)
    c.line(0, 600, 0, 560)
    c.line(440, 600, 440, 560)
    # Police basique
    c.setFont("Helvetica", 14)

    #Service formation continue
    c.setFont("Helvetica-Bold", 12)
    c.drawString(0, 660, "Service Formation Continue")
    c.setFont("Helvetica", 12)
    c.drawString(0, 643, "N° déclaration d'activité : 8273 P 000273")
    c.drawString(0, 626, "SIRET : 197 308 588 000 15")
    #attestation de presence
    c.setFont("Helvetica-Bold", 14)
    c.drawCentredString(230, 575, "ATTESTATION DE PRÉSENCE")
    #Je soussigné
    c.setFont("Helvetica", 12)
    textobject = c.beginText(0, 540)
    soussigne = "Je soussigné " + president + ", Président de l'université Savoie Mont Blanc \natteste que le stagiaire: "
    for line in soussigne.splitlines(False):
        textobject.textLine(line.rstrip())
    c.drawText(textobject)
    c.setFont("Helvetica-Bold", 12)
    c.drawCentredString(200, 500, alternant)
    #inscription
    c.setFont("Helvetica", 12)
    textobject = c.beginText(0, 450)
    inscription = "est inscrit en " + master + " \npour l'année " + anneeScolaire + " et a suivi les cours pour la période du " + periodeDebut + "\nau " + periodeFin + " selon détail ci-dessous :"
    for line in inscription.splitlines(False):
        textobject.textLine(line.rstrip())
    c.drawText(textobject)

    # Heures de présence / mois

    hauteur = 400
    for key, value in tabPresence.items():
        c.drawString(50, hauteur, "- " + str(key) + " :")
        c.drawString(130, hauteur, str(value) + " heures")
        hauteur -= 15

    hauteur -= 15
    c.setFont("Helvetica-Bold", 12)
    c.drawString(
        0, hauteur,
        "Soit un total de " + str(presenceEffective) + " heures de présence.")

    hauteur -= 30
    c.setFont("Helvetica", 12)
    c.drawString(
        0, hauteur,
        "Heures de cours prévues : " + str(presenceVirtuel) + " heures.")

    c.drawString(
        200, 150, "Le Bourget du Lac,le " + str(currDate.day) + "/" +
        str(currDate.month) + "/" + str(currDate.year))
    # #ajoute la date
    c.drawString(0, 120, "Signature du stagiaire")
    c.setFont("Helvetica-Bold", 12)
    c.drawString(200, 120, "Pour l'organisme de formation")
    c.setFont("Helvetica", 12)
    c.drawString(200, 105,
                 "Pour le Président de l'Université Savoie Mont Blanc")
    c.drawString(200, 75, "Le directeur du S.F.C")
    c.drawString(200, 50, SFC)
    # change color
    c.setFillColorRGB(0, 0, 0)
    #ajout d'image
    c.drawImage(usmb, 0, 690, 150, 60)
    c.drawImage(fc, 420, -30, 250, 50)
    c.drawImage(signaturePNG, 280, -20, 130, 80)
    c.showPage()
    c.save()

    # ARCHIVAGE
    fichierAnneeScolaire = str(debutScol.year) + "-" + str(finScol.year)
    fichierDateDebut = (
        "0" + str(dateDebut.day) if dateDebut.day < 10 else str(dateDebut.day)
    ) + "-" + ("0" + str(dateDebut.month) if dateDebut.month < 10 else str(
        dateDebut.month)) + "-" + str(dateDebut.year)
    fichierDateFin = ("0" + str(dateFin.day) if dateFin.day < 10 else str(
        dateFin.day)) + "-" + ("0" + str(dateFin.month) if dateFin.month < 10
                               else str(dateFin.month)) + "-" + str(
                                   dateFin.year)

    nomArchive = fichierAnneeScolaire + " " + master + " " + alternant + " du " + fichierDateDebut + " au " + fichierDateFin + " Attestation Présence"

    # Gestion des duplicatas
    if os.path.isfile(os.path.join(pathArchive, nomArchive) + ".pdf"):
        numDuplicata = 1
        while os.path.isfile(
                os.path.join(pathArchive, nomArchive) + " (" +
                str(numDuplicata) + ").pdf"):
            numDuplicata += 1

        nomArchive += " (" + str(numDuplicata) + ")"

    nomArchive += ".pdf"  # Ajout de l'extension
    shutil.copy2(os.path.join(pathPDF, filename),
                 os.path.join(pathArchive, nomArchive))
    return c
def to_pdf(request, id):
    history = None
    try:
        history = History.objects.get(dentist=request.user, id=id)
    except:
        messages.error(request,
                       "Error: You are not authorized to view this history")
        return HttpResponseRedirect('/prescription/history/')
    response = HttpResponse(content_type='application/pdf')
    response[
        'Content-Disposition'] = 'attachment;filename="prescription_%d_%s.pdf"' % (
            history.patient.id, str(datetime.datetime.now()))
    buffer = BytesIO()
    p = canvas.Canvas(buffer)
    p.drawCentredString(300, 800, "Confident Dental Care")

    patient = history.patient
    prescription = history.prescription
    dentist = history.dentist

    patientString = '''Name: %s
Age:%s 
Gender: %s
Contact Number: %s
%s
''' % (patient.name, patient.age, patient.gender, patient.contact_number,
       str(datetime.datetime.now()))

    textobject = p.beginText()
    textobject.setTextOrigin(inch, inch * 10.5)
    textobject.textLines(patientString)

    dentistString = '''Dentist: %s
    %s
    Contact: %s
    Email: %s
''' % (dentist.name, dentist.about, dentist.contact_number, dentist.email)

    textobject.moveCursor(inch * 4.5, inch * -1)
    textobject.textLines(dentistString)
    textobject.moveCursor(inch * -4.5, inch * .5)
    textobject.textLine("Rx,")

    count = 1
    for medicine in prescription.recommended_medicines.all():
        textobject.moveCursor(inch * 1, inch * .1)
        medString = "%d. %s : %s %s" % (count, medicine.medicine.medicine_name,
                                        medicine.get_dosage_str(),
                                        medicine.comments)
        textobject.textLine(medString)
        count += 1

    if prescription.recommended_tests.count() > 0:
        textobject.moveCursor(inch * 1, inch * .15)
        textobject.textLine("Recommended Tests")
        count = 1
        for test in prescription.recommended_tests.all():
            textobject.moveCursor(inch * 1, inch * .1)
            testString = "%d. %s" % (count, test.test_name)
            textobject.textLine(testString)
            count += 1
    p.drawText(textobject)

    p.showPage()
    p.save()
    pdf = buffer.getvalue()
    buffer.close()
    response.write(pdf)
    send_prescription(pdf, patient, prescription.created_at)

    return response
Exemplo n.º 5
0
def presence(etu, master, presenceJour, administration):

    from reportlab.lib.units import cm, inch

    usmb = os.path.join("./app/static/img", 'logoUSMB2.png')

    #obtention de l'année scolaire
    debutScol = datetime.strptime(administration[0][0], '%d/%m/%Y').date()
    finScol = datetime.strptime(administration[0][1], '%d/%m/%Y').date()
    anneeScolaire = str(debutScol.year) + "/" + str(finScol.year)

    master = master
    alternant = etu

    pathPDF = "./app/static/pdf"
    pathArchive = "./app/static/archive"
    filename = alternant + " Presence.pdf"

    periodeDebut = administration[0][2]
    periodeFin = administration[0][3]

    dateDebut = datetime.strptime(periodeDebut, '%d/%m/%Y').date()
    dateFin = datetime.strptime(periodeFin, '%d/%m/%Y').date()

    c = canvas.Canvas(os.path.join(pathPDF, filename))

    for i in range(0, len(presenceJour)):
        presenceJour[i] = list(presenceJour[i])

        presenceJour[i][3] = datetime.strptime(presenceJour[i][3],
                                               '%d/%m/%Y').date()
    presenceJour = sorted(presenceJour, key=lambda presence: presence[3])

    # origine x, y en haut à gauche
    c.translate(inch, inch)

    # Logo USMB
    c.drawImage(usmb, 0, 690, 150, 60)

    c.line(0, 600, 440, 600)
    c.line(0, 560, 440, 560)
    c.line(0, 600, 0, 560)
    c.line(440, 600, 440, 560)
    # Police basique
    c.setFont("Helvetica", 14)

    #Service formation continue
    c.setFont("Helvetica-Bold", 12)
    c.drawString(0, 660, "Service Formation Continue")
    c.setFont("Helvetica", 12)
    c.drawString(0, 643, "N° déclaration d'activité : 8273 P 000273")
    c.drawString(0, 626, "SIRET : 197 308 588 000 15")
    #attestation de presence
    c.setFont("Helvetica-Bold", 14)
    c.drawCentredString(230, 575, "FEUILLE DE PRÉSENCE")
    #Je soussigné
    c.setFont("Helvetica", 12)
    textobject = c.beginText(0, 540)
    soussigne = "Le stagiaire: "
    for line in soussigne.splitlines(False):
        textobject.textLine(line.rstrip())
    c.drawText(textobject)
    c.setFont("Helvetica-Bold", 12)
    c.drawCentredString(200, 500, alternant)
    #inscription
    c.setFont("Helvetica", 12)
    textobject = c.beginText(0, 450)
    inscription = "est inscrit en " + master + " \npour l'année " + anneeScolaire + " et a été présent sur les journées selon details ci dessous :"
    for line in inscription.splitlines(False):
        textobject.textLine(line.rstrip())
    c.drawText(textobject)

    #Affichage de l'ensemble des présences de l'étudiant traité

    i = 20
    for element in presenceJour:
        if (element[0] == 2):
            if (element[1] == 2):
                textobject.textLine(
                    datetime.strftime(element[3], '%d/%m/%Y') +
                    " - Absent journée ")
            else:
                textobject.textLine(
                    datetime.strftime(element[3], '%d/%m/%Y') +
                    " - Absent matin")
        elif (element[1] == 2):
            textobject.textLine(
                datetime.strftime(element[3], '%d/%m/%Y') +
                " - Absent après-midi")
        else:
            textobject.textLine(
                datetime.strftime(element[3], '%d/%m/%Y') + " - Présent")

        if (i % 50 == 0):
            if (i - 19 == len(presenceJour)):
                continue
            c.drawText(textobject)
            c.showPage()
            textobject = c.beginText(70, 800)

        i += 1
    c.drawText(textobject)

    c.showPage()
    c.save()

    # ARCHIVAGE
    fichierAnneeScolaire = str(debutScol.year) + "-" + str(finScol.year)
    fichierDateDebut = (
        "0" + str(dateDebut.day) if dateDebut.day < 10 else str(dateDebut.day)
    ) + "-" + ("0" + str(dateDebut.month) if dateDebut.month < 10 else str(
        dateDebut.month)) + "-" + str(dateDebut.year)
    fichierDateFin = ("0" + str(dateFin.day) if dateFin.day < 10 else str(
        dateFin.day)) + "-" + ("0" + str(dateFin.month) if dateFin.month < 10
                               else str(dateFin.month)) + "-" + str(
                                   dateFin.year)

    nomArchive = fichierAnneeScolaire + " " + master + " " + alternant + " du " + fichierDateDebut + " au " + fichierDateFin + " Feuille Présence"

    # Gestion des duplicatas
    if os.path.isfile(os.path.join(pathArchive, nomArchive) + ".pdf"):
        numDuplicata = 1
        while os.path.isfile(
                os.path.join(pathArchive, nomArchive) + " (" +
                str(numDuplicata) + ").pdf"):
            numDuplicata += 1

        nomArchive += " (" + str(numDuplicata) + ")"

    nomArchive += ".pdf"  # Ajout de l'extension
    shutil.copy2(os.path.join(pathPDF, filename),
                 os.path.join(pathArchive, nomArchive))
    return c
    return c