Esempio n. 1
0
def generate_bill(a_family, a_cost_per_person):
    a_title = DIR_UBERSICHT + "Vorauszahlung_Ubersicht_"+a_family+".pdf"
    pdf = PDFDocument(a_title)
    pdf.init_report()
    pdf.p_markup("Automatisch generiert am: "+ str(date.today()), pdf.style.right)
    pdf.spacer(20)
    pdf.h1("Übersicht Vorauszahlung für Familie " + a_family)
    pdf.spacer(20)
    pdf.h2("Kostenaufstellung")
    pdf.hr()
    pdf.spacer(10)
    my_list = []
    q = db.query(Members).join(Familys).filter_by(f_name=a_family)
    total = 0
    for result in db.execute(q):
        my_list.append([result[2] + " " + result[3], str(a_cost_per_person) + " €"])
        total += a_cost_per_person
    try:
        pdf.table(my_list, 220)
    except Exception:
        print("No members")
    pdf.spacer(10)
    pdf.hr()
    pdf.spacer(20)
    pdf.p_markup("Total: " + str(total) + " €", pdf.style.bold)
    pdf.spacer(20)
    pdf.p(UBERWEISUNG_FOOTER)
    pdf.generate()
    return os.path.abspath(a_title)
Esempio n. 2
0
def register():
    form = RegisterForm()
    
    if form.validate_on_submit():
        if g.user.f_validated:
            flash("Bearbeitung nicht mehr möglich! Sie haben die Eingaben bereits bestätigt")
        else:
            if datetime.datetime.now() > LEVEL1DATE:
                flash("Änderungen der Mitglieder sind nicht mehr möglich!")
                flash("Änderungen der Mitglieder werden nicht gespeichert.")
            else:
                Members.query.filter_by(m_familyname=g.user.f_name).delete()
                for i in range(10):
                    a_prename = eval("form.prename"+str(i)+".data")
                    a_surname = eval("form.surname"+str(i)+".data")
                    if a_prename.strip() == "" and a_surname.strip() == "":
                        continue
                    member = Members(g.user.f_name, a_prename, a_surname)
                    db.add(member)
                db.query(Familys).filter_by(f_name=g.user.f_name).update({Familys.f_info:form.info.data})
                flash("Eingaben wurden gespeichert")
            if form.festzusagen.data == True:
                db.query(Familys).filter_by(f_name=g.user.f_name).update({Familys.f_validated:form.festzusagen.data})
                flash("Zusage gespeichert")
            db.commit()
            return redirect("register")

    q = db.query(Members).join(Familys).filter_by(f_name=g.user.f_name)
    i = 0
    for result in db.execute(q):
        prename_field = eval("form.prename"+str(i))
        surname_field = eval("form.surname"+str(i))
        prename_field.data = result[2]
        surname_field.data = result[3]
        i += 1
    
    form.info.data = Familys.query.filter_by(f_name=g.user.f_name).first().f_info
    form.festzusagen.data = Familys.query.filter_by(f_name=g.user.f_name).first().f_validated
    
    editing_allowed = True
    if datetime.datetime.now() > LEVEL1DATE:
        editing_allowed = False
    
    show_zusagen = False
    if datetime.datetime.now() > LEVEL2DATE:
        show_zusagen = True
    
    return render_template("register.html",
                           title="Register",
                           form=form,
                           cur_time= datetime.datetime.now().strftime("%d-%m-%Y %H:%M"),
                           show_zusagen=show_zusagen,
                           editing_allowed=editing_allowed,
                           LEVEL1DATE=LEVEL1DATE.strftime("%d-%m-%Y"),
                           LEVEL2DATE=LEVEL2DATE.strftime("%d-%m-%Y"),
                           LEVEL3DATE=LEVEL3DATE.strftime("%d-%m-%Y"),
                           CREATE_BILL_BY_FAMILY=CREATE_BILL_BY_FAMILY
                           )
Esempio n. 3
0
def generate_teilnehmerliste():
    a_title = DIR_TEILNEHMERLISTE + "Teilnehmer.pdf"
    pdf = PDFDocument(a_title)
    pdf.init_report()
    pdf.p_markup(date.today(), pdf.style.right)
    pdf.spacer(20)
    pdf.h1("Teilnehmer Skifahren 2017")
    pdf.hr_mini()
    pdf.spacer(20)
    familys = Familys.query.all()
    for family in familys:
        pdf.h3(family.f_name)
        q = db.query(Members).join(Familys).filter_by(f_name=family.f_name)
        members = []
        for result in db.execute(q):
            members.append(result[2] + " " + result[3])
        pdf.ul(members)
        pdf.spacer(10)
        pdf.p("Info:")
        pdf.p(family.f_info)
        pdf.spacer(20)
        pdf.hr()
    pdf.generate()
    return os.path.abspath(a_title)