0% found this document useful (0 votes)
10 views

Class Note Lesson of Python - Print

Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views

Class Note Lesson of Python - Print

Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

PRINT BAST ASSET menggunakan PYTHON

@app.route('/printbastseragamhrga', methods=['GET', 'POST'])

def printbastseragamhrga():

msg = ''

if 'loggedin' in session:

# Check userRole

userRole = session['userRole']

nobastseragamhrga = request.form['nobastseragamhrga']

if userRole == '2':

# We need all the account info for the user so we can display it on the profile page

conn = mysql.connect()

cursor = conn.cursor(pymysql.cursors.DictCursor)

cursor.execute('SELECT * FROM user WHERE userRole = %s', (session['userRole'],))

account = cursor.fetchone()

container = []

form = DateForm()
if form.validate_on_submit():

return form.dt.data.strftime('%s'), form.dte.data.strftime('%s')

conn.commit()

conn = mysql.connect()

cursor.execute("SELECT * FROM bastseragamhrga b, karyawan k, jenisseragamhrga j WHERE


b.id_karyawan=k.id_karyawan AND b.idjenisseragamhrga=j.idjenisseragamhrga AND
b.nobastseragamhrga= %s", [nobastseragamhrga])

result = cursor.fetchall()

for row in result:

container.append(row)

cursor.close()

containerb = []

form = DateForm()

if form.validate_on_submit():

return form.dt.data.strftime('%s'), form.dte.data.strftime('%s')

conn = mysql.connect()

cursor = conn.cursor(pymysql.cursors.DictCursor)
cursor.execute("SELECT * FROM bastseragamhrga WHERE nobastseragamhrga= %s GROUP BY
nobastseragamhrga", [nobastseragamhrga])

resultb = cursor.fetchall()

for row in resultb:

containerb.append(row)

cursor.close()

containerc = []

form = DateForm()

if form.validate_on_submit():

return form.dt.data.strftime('%s'), form.dte.data.strftime('%s')

conn = mysql.connect()

cursor = conn.cursor(pymysql.cursors.DictCursor)

cursor.execute("SELECT *, FORMAT((SUM(qtybastseragamhrga)),0) AS qtyJumlah FROM


bastseragamhrga b, karyawan k, jenisseragamhrga j WHERE b.id_karyawan=k.id_karyawan AND
b.idjenisseragamhrga=j.idjenisseragamhrga AND b.nobastseragamhrga= %s", [nobastseragamhrga])

resultc = cursor.fetchall()

for row in resultc:


containerc.append(row)

cursor.close()

return render_template('printbastseragamhrga.html', container=container,


containerb=containerb, containerc=containerc, account=account, form=form)

elif userRole != '2':

# userRole not in the right place

return redirect(url_for('logout'))

return redirect(url_for('login'))

You might also like