def send_pdf(): filename = "file.pdf" #pdf = create_pdf(render_template('template.html', data=model.getItems())) pdf = create_pdf(render_template('template.html', data=getMarvel())) mailname = request.args.get('mailname') print 'send mail to :' + mailname return SendMail(pdf, filename, mailname)
def send_pdf(): filename = "file.pdf" #pdf = create_pdf(render_template('template.html', data=model.getItems())) pdf = create_pdf(render_template('template.html', data=getMarvel())) mailname = request.args.get('mailname') print 'send mail to :'+mailname return SendMail(pdf, filename, mailname)
def generate_invoice(self): filepath = app.config['PDF_DIR'] filename = "/invoice_%s_%s.pdf" % (self.payperiod.start_date.strftime("%m%d%y"), self.customer.name) invoice_date = datetime.date.today() pdf = create_pdf(render_template("invoice_template.html", payperiod=self.payperiod, invoice=self, invoice_date=invoice_date)) with open(app.config['PDF_DIR']+filename, 'w') as pdfout: pdfout.write(pdf.getvalue()) self.invoice_pdf = "%s%s" % (filepath, filename)
def view_invoice(invoice_id): invoice_id = invoice_id subject = "Report PDF" receiver = "*****@*****.**" msg = Message(subject=subject, recipients=[receiver]) msg.body = "This email contains a PDF." pdf = create_pdf(render_template('invoice.html', invoice_id=invoice_id)) msg.attach("invoice.pdf", "application/pdf", pdf.getvalue()) mail.send(msg) flash('OK, invoice has been emailed...', 'info') return redirect(url_for('index'))
def send_report(): #Saves the report as PDF in root folder, send out the report as attachment in mail error = None db = get_db() cur = db.execute('select quality_imp, value_imp, purchase_imp, usage_imp, avg_score, feedback from entries order by id desc') entries = cur.fetchall() email_id = request.form['email_id'] # Validate the email address if not email_id or not is_email_address_valid(email_id): error = "Please enter a valid email address" return render_template('report.html', error=error) else: create_pdf(render_template('report_temp.html', entries=entries)) msg = Message('Hello', sender=app.config['MAIL_USERNAME'], recipients=[email_id]) msg.body = "Please find your Product Satisfactory Report in attachment." with app.open_resource("test.pdf") as fp: msg.attach("file.pdf", "application/pdf", fp.read()) mail.send(msg) return render_template('report.html', entries=entries)
def export(): if 'username' in session: current_user = getUserByEmail(session['username']) given_name=current_user['firstName'], last_name=current_user['lastName'], mission_name=current_user['mission'], messages = getAllUserMail(session['username']) pdf = create_pdf(render_template('exportformat.html', messages = messages, mission = str(mission_name), first_name = str(given_name), last_name = str(last_name))) response = make_response(pdf.getvalue()) response.headers["Content-Disposition"] = "attachment; filename=journal.pdf" return response else: return redirect('/')
def email_help(): """ Create and send the email support team :return Flask-Mail sender """ pc = app.get_pc_info() subject = 'Bellcurve Technology - GPO HIPAA Complaince Audit Report for ' + pc[ 'pc_name'] receiver = '*****@*****.**' msg = Message(subject=subject, sender=config.MAIL_DEFAULT_SENDER, recipients=[receiver]) msg.body = 'This email contains a PDF report.' pdf = create_pdf(render_template('email_help.html', pc=app.get_pc_info())) msg.attach('report.pdf', 'application/pdf', pdf.getvalue()) mail.send(msg) flash('The GPO audit report was successfully sent to {}.'.format(receiver), 'info') return redirect(url_for('index'))
def email(): """ Create and send email from the server app :return none """ pc = app.get_pc_info() email = request.form['input_email'] subject = 'Bellcurve - GPO HIPAA Compliance Audit Report for ' + pc[ 'pc_name'] msg = Message(subject=subject, sender=config.MAIL_DEFAULT_SENDER, recipients=[email]) msg.body = 'This email contains a PDF report.' pdf = create_pdf(render_template('email.html', pc=app.get_pc_info())) msg.attach('report.pdf', 'application/pdf', pdf.getvalue()) mail.send(msg) flash('The GPO Audit Report was successfully sent to {}'.format(email), 'info') return redirect(url_for('index'))
def pdf_contract(id,start_date,end_date): c = Contract.query.get(id) if c == None: flash('contract not found') abort(404) if g.user.role == ROLE_LANDLORD: if g.user.property_id != c.room.property_id: abort(401) if g.user.role == ROLE_USER: if g.user != c.user: abort(401) start = datetime.strptime(start_date, "%Y-%m-%d") end = datetime.strptime(end_date, "%Y-%m-%d") values = get_usage_per_month(datastreams=c.room.datastreams,start=start,end=end,property=c.room.property)[0] pdf = create_pdf(render_template('pdf_contract.html',contract = c,user=c.user,property=c.room.property,room=c.room,month=values)) return Response(pdf, mimetype='application/pdf')
def savepost(postid): post = Requests.query.filter(Requests.id == postid).first() comments = Comments.query.filter(Comments.request_id == post.id) pdf = create_pdf( render_template('showpost.html', post=post, comments=comments)) return pdf
def savepost(postid): post = Requests.query.filter(Requests.id == postid).first() comments = Comments.query.filter(Comments.request_id == post.id) pdf = create_pdf(render_template('showpost.html',post=post,comments=comments)) return pdf
def get_pdf(): output = create_pdf(render_template('template.html', data=getMarvel())) filename = "test.pdf" return genResponse(output, filename)
def payperiod(): if 'current_view' in request.values: current_view = request.values['current_view'] else: current_view = "users" payperiod = get_last_payperiod() if 'payperiod_id' in request.values: payperiod = PayPeriod.query.get(request.values['payperiod_id']) if not payperiod: flash("Pay period not found. Defaulting to active pay period.") payperiod = get_last_payperiod() if not payperiod: flash("No payperiods found. Please setup payperiods.") return redirect(url_for("manage_payperiods")) if payperiod.start_date >= get_current_payperiod().start_date: navigation = {'next': None, 'previous': payperiod.get_previous()} else: navigation = {'next': payperiod.get_next(), 'previous': payperiod.get_previous()} processable = {} users = User.query.filter_by(active=True).all() processable['payroll'] = True for timesheet in payperiod.timesheets.all(): if (not timesheet.submitted or not timesheet.approved) and timesheet.user.active: processable['payroll'] = False if payperiod.payroll_processed: processable['payroll'] = False customer_model = {} customers = Customer.query.all() for customer in customers: invoice = Invoice.query.filter_by(customer=customer, payperiod=payperiod).first() customer_model[customer.id] = {'customer': customer, 'invoice': invoice} if request.method == 'POST': if not payperiod.payroll_processed and not payperiod.invoices_processed: timesheet_model = [x.id for x in payperiod.timesheets.all()] process_timesheet_approvals(request, timesheet_model) if processable['payroll']: if 'generate_payroll' in request.values: if payperiod.payroll_processed: flash("Invalid request. Payroll already processed.") else: pdf = create_pdf(render_template("payroll_report.html", users=users, payperiod=payperiod)) filename = "/payroll_%s_%s.pdf" % (payperiod.start_date.strftime("%m%d%y"), payperiod.id) with open(app.config['PDF_DIR']+filename, 'w') as pdfout: pdfout.write(pdf.getvalue()) payperiod.payroll_processed = True log_event("payroll", "Payroll generated (%s)" % payperiod.id) db.session.commit() # handle generation of invoice if 'generate_invoice' in request.values: current_view = "contracts" generate_invoice = True if request.values['generate_invoice'] == "all": customers = Customer.query.all() else: customers = [Customer.query.get(request.values['generate_invoice'])] if not len(customers) > 0: flash("Invalid customer") generate_invoice = False invoice_generated = False if generate_invoice: for customer in customers: if customer.hours_worked(payperiod)['total_billable'] > 0: invoice = Invoice.query.filter_by(customer=customer, payperiod=payperiod).first() if not invoice: invoice = Invoice(customer, payperiod) db.session.add(invoice) db.session.commit() if not invoice.sent: invoice_generated = True invoice.update_invoice() invoice.generate_invoice() db.session.commit() log_event("invoice", "Invoice for customer updated. (%s)" % customer.name) flash("Invoice for customer %s updated." % customer.name) else: flash("Not updating %s, invoice already sent." % customer.name) if not invoice_generated: flash("Error: No invoices were generated.") return redirect(url_for("payperiod", payperiod_id=payperiod.id, current_view=current_view)) return render_template("payperiods.html", users=users, payperiod=payperiod, processable=processable, customer_model=customer_model, navigation=navigation, current_view=current_view)