Commit d4887d64 by taufikyu

revisi output html qrcode

1 parent 1da78899
......@@ -26,7 +26,8 @@ from ..tools import (
terbilang,
thousand,
dmy,
BULANS
BULANS,
get_settings
)
from ..models import DBSession
from ..models.isipkd import(
......@@ -882,10 +883,14 @@ def view_pdf(request):
item.denda = (row.tgl_bayar) and thousand(row.bunga) or (row.denda) and thousand(row.denda) or '0'
item.bayar = row.bayar and thousand(row.bayar) or (row.jumlah) and thousand(row.jumlah) or (int(item.pokok)+int(item.denda))
from ..tools import get_settings
qrcodename = 'skrd_{}'.format(params['id'])
path = '/tmp/' + qrcodename
imgqrcode = qrcode.make(str('{}/public/skrd?id={}'.format(get_settings()['_host'],params['id'])))
## ambil host
settings = get_settings()
host = settings['_host']
## generate qrcode
imgqrcode = qrcode.make('{}/public/skrd?id={}'\
.format(host, params['id']))
imgqrcode.save(path, 'PNG')
item.qrcode = open(path, 'rb').read()
......
......@@ -3,6 +3,7 @@ import re
import logging
import os
import qrcode
import base64
from email.utils import parseaddr
from sqlalchemy import not_, func, or_, desc
from datetime import datetime
......@@ -26,7 +27,8 @@ from ..tools import (
terbilang,
thousand,
dmy,
BULANS
BULANS,
get_settings
)
from ..models import DBSession
from ..models.isipkd import(
......@@ -324,7 +326,7 @@ def session_failed(request, session_name):
del request.session[SESS_ADD_FAILED]
return r
@view_config(route_name='public-act', renderer='templates/public/public.pt')
@view_config(route_name='public-act', renderer='templates/public/skrd.pt')
def view_public(request):
params = request.params
url_dict = request.matchdict
......@@ -366,6 +368,19 @@ def view_public(request):
jml = terbilang(row.jumlah) + ' Rupiah'
tahun = datetime.now().year
## buat nama di folder /tmp
qrcodename = 'skrd_{}{}'.format(row.invoice_id,'.png')
path = '/tmp/' + qrcodename
## ambil host
settings = get_settings()
host = settings['_host']
##Generate dulu qrcode nya
imgqrcode = qrcode.make(str('{}/public/skrd?id={}'.format(host,row.invoice_id)))
imgqrcode.save(path, 'PNG')
## Ambil isinya
readqrcode = open(path, 'rb').read()
## convert ke base64
qrcodebase64 = base64.b64encode(readqrcode) ##akan diouput ke html image
return dict(data=row, jml_terbilang=jml, tahun=tahun, qrcodename=qrcodename, found=found)
return dict(data=row, jml_terbilang=jml, tahun=tahun, qrcodebase64=qrcodebase64, found=found)
......@@ -148,7 +148,7 @@
</td>
</tr>
<tr>
<td align="center"><p><img src="/tmp/${qrcodename}" width="150" height="150"></p></td>
<td align="center"><p><img src="data:image/png;base64, ${qrcodebase64}" width="150" height="150"></p></td>
<td></td>
<td align="center"><b>${data.tgl_tetap.strftime('%d %B')}, Tahun ${data.tahun_id}</b><br>
${data.pejabat_pangkat}<br><br><br><br><br>
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!