Commit c9392444 by yasir

merubah view list payment dalam bentuk form, penambahan tombol advice untuk tran…

…saksi dengan status = 0
1 parent 0e80ebbd
import colander
from opensipkd.base.views import BaseView
from ..tools import btn_inquiry, btn_payment, btn_advice, btn_next, btn_close
from ..tools import get_settings
from deform import widget, Form, ValidationFailure
from pyramid.view import view_config
from ..models import (DBSession, PartnerPay, Partner)
from opensipkd.base.tools import format_json
from .api_merchant import build_request, qry_vendor_produk
from opensipkd.pasar.models import Partner, Produk
from pyramid.httpexceptions import HTTPFound
form_params_view = dict(scripts="""
$(document).ready(function(){
$("form#deform input[type=text]").each(function() {
var input = $(this).prop("disabled", true);
})
$("form#deform textarea").each(function() {
var input = $(this).prop("disabled", true);
})
});
""")
class DetailSchema(colander.Schema):
vend_inv_no = colander.SchemaNode(colander.String(), title = "Vend Inv No ", missing=colander.drop)
cust_inv_no = colander.SchemaNode(colander.String(), title = "Cust Inv No ", missing=colander.drop)
tx_id = colander.SchemaNode(colander.String(), title = "Tx Id ", missing=colander.drop)
vendor = colander.SchemaNode(colander.String(), title = "Vendor", missing=colander.drop)
produk = colander.SchemaNode(colander.String(), title = "Produk", missing=colander.drop)
produk_id = colander.SchemaNode(colander.Integer(), oid="produk_id", widget=widget.HiddenWidget(readonly=True), missing=colander.drop)
vendor_id = colander.SchemaNode(colander.Integer(), oid="vendor_id", widget=widget.HiddenWidget(readonly=True), missing=colander.drop)
customer = colander.SchemaNode(colander.String(), title = "Customer", missing=colander.drop)
cust_addr = colander.SchemaNode(colander.String(), title = "Cust Addr ", missing=colander.drop)
cust_phone = colander.SchemaNode(colander.String(), title = "Cust Phone ", missing=colander.drop)
cust_city = colander.SchemaNode(colander.String(), title = "Cust Email", missing=colander.drop)
cust_state = colander.SchemaNode(colander.String(), title = "Cust City", missing=colander.drop)
cust_pos = colander.SchemaNode(colander.String(), title = "Cust Pos ", missing=colander.drop)
cust_country = colander.SchemaNode(colander.String(), title = "Cust Country ", missing=colander.drop)
inquiry = colander.SchemaNode(colander.String(), widget=widget.TextAreaWidget(rows=5, css_class="readonly"), title = "Inquiry", missing=colander.drop)
payment = colander.SchemaNode(colander.String(), widget=widget.TextAreaWidget(rows=5, css_class="readonly"), title = "Payment ", missing=colander.drop)
advice = colander.SchemaNode(colander.String(), widget=widget.TextAreaWidget(rows=5, css_class="readonly"), title = "Advice ", missing=colander.drop)
notify = colander.SchemaNode(colander.String(), widget=widget.TextAreaWidget(rows=5, css_class="readonly"), title = "Notify ", missing=colander.drop)
cancel = colander.SchemaNode(colander.String(), widget=widget.TextAreaWidget(rows=5, css_class="readonly"), title = "Cancel", missing=colander.drop)
cart = colander.SchemaNode(colander.String(), widget=widget.TextAreaWidget(rows=5, css_class="readonly"), title = "Cart", missing=colander.drop)
def form_validator(form, value):
pass
def get_form(request, class_form, buttons=None, row=None):
schema = class_form(validator=form_validator)
# schema = schema.bind(vendor=Partner.get_vendor_list(),
# produk=Produk.get_e_list(),
# customer=Partner.get_customer_list())
schema.request = request
if row:
schema.deserialize(row)
if not buttons:
# buttons = (btn_inquiry, btn_reset)
buttons = ()
return Form(schema, buttons=buttons)
class ViewDetail(BaseView):
@view_config(route_name='api-payment-view',
permission="api-payment-list",
renderer='templates/form.pt')
def view_detail(self):
request = self.req
session = self.ses
url_dict = request.matchdict
view_id = url_dict['id']
# print('masuk sini id nya : >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>')
# print(view_id)
data = PartnerPay.query_id(id=view_id).first()
if request.POST:
# print('iya masuk post .... >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>')
controls = request.POST.items()
controls = dict(controls)
# print('isi controls >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>')
# print(controls)
# print('isi request.POST >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>')
# print(request.POST)
if 'advice' in request.POST:
# print('tombol advice di klik >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>')
# id = 'id' in values and values['id'] or None
vendor_produk = qry_vendor_produk() \
.filter(Partner.id == controls['vendor_id']) \
.filter(Produk.id == controls['produk_id']).first()
# print('isi vendor_produk >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>')
# print(vendor_produk.id)
id = view_id
if not id:
session.flash('Belum ada Invoice', 'error')
if data.status == 0:
form = get_form(request, DetailSchema, (btn_advice, btn_close))
else:
form = get_form(request, DetailSchema, (btn_close, ))
form.render(values)
return dict(form=form, params=form_params_view)
invoice_det = query_id(id).first()
if not invoice_det :
session.flash('Data Tidak Ditemukan', 'error')
if data.status == 0:
form = get_form(request, DetailSchema, (btn_advice, btn_close))
else:
form = get_form(request, DetailSchema, (btn_close, ))
form.render(values)
return dict(form=form, params=form_params_view)
result = build_request('advice', vendor_produk, invoice_det)
print(result)
if 'close' in request.POST:
# print('tombol close di klik >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>')
return HTTPFound(location=request.route_url('api-payment-list'))
# form = get_form(request, DetailSchema, (btn_advice, btn_close))
if data.status == 0:
form = get_form(request, DetailSchema, (btn_advice, btn_close))
else:
form = get_form(request, DetailSchema, (btn_close, ))
values = data.to_dict()
values['vendor'] = data.vendor.nama
values['vendor_id'] = data.vendor_id
values['produk'] = data.produk.nama
values['produk_id'] = data.produk_id
values['customer'] = data.customer.nama
values['cust_addr'] = data.inv_cust_addr
values['cust_phone'] = data.inv_cust_phone
values['cust_city'] = data.inv_cust_city
values['cust_state'] = data.inv_cust_state
values['cust_pos'] = data.inv_cust_pos
values['cust_country'] = data.inv_cust_country
values['inquiry'] = format_json(data.inquiry)
values['payment'] = format_json(data.payment)
values['advice'] = format_json(data.advice)
values['notify'] = format_json(data.notify)
values['cancel'] = format_json(data.cancel)
values['cart'] = format_json(data.cart)
form.render(values)
return dict(form=form, params=form_params_view)
def query_id(id):
#id = request.matchdict['id']
return PartnerPay.query_id(id)
\ No newline at end of file
......@@ -252,106 +252,106 @@ class ViewData(BaseView):
return payment_advice(dat)
@view_config(route_name='api-payment-view',
permission="api-payment-list",
renderer='templates/payment/view.pt')
def view_detail(self):
request = self.req
url_dict = request.matchdict
view_id = url_dict['id']
data = PartnerPay.query_id(id=view_id).first()
params = dict(
form=None
)
if data:
customer = '{cust} - ({merc})'.format(cust=data.inv_cust_nm, merc=data.customer.nama)
form_list = (
('vend_inv_no', data.vend_inv_no or '', 'text'),
('cust_inv_no', data.cust_inv_no or '', 'text'),
('tx_id', data.tx_id or '', 'text'),
('vendor', data.vendor.nama, 'text'),
('produk', data.produk.nama, 'text'),
# ('id_pel', data.id_pel or '', 'text'),
('customer', customer, 'text'),
('cust_addr', data.inv_cust_addr or '', 'text'),
('cust_phone', data.inv_cust_phone or '', 'text'),
('cust_email', data.inv_cust_email or '', 'text'),
('cust_city', data.inv_cust_city or '', 'text'),
('cust_state', data.inv_cust_state or '', 'text'),
('cust_pos', data.inv_cust_pos or '', 'text'),
('cust_country', data.inv_cust_country or '', 'text'),
# ('inv_valid_date', data.description, 'text'),
# ('inv_valid_time', data.description, 'text'),
# ('inv_time_stamp', data.description, 'text'),
# ('inv_cust_va', data.description, 'text'),
#
# ('delivery_addr', data.description, 'text'),
# ('delivery_city', data.description, 'text'),
# ('delivery_country', data.description, 'text'),
# ('delivery_nm', data.description, 'text'),
# ('delivery_phone', data.description, 'text'),
# ('delivery_pos', data.description, 'text'),
# ('delivery_state', data.description, 'text'),
# ('delivery_email', data.description, 'text'),
# ('subtotal', data.subtotal, 'text'),
# ('discount', data.discount, 'text'),
# ('amt_sell', data.amt_sell, 'text'),
('inquiry', format_json(data.inquiry), 'textarea'),
('payment', format_json(data.payment), 'textarea'),
('advice', format_json(data.advice), 'textarea'),
('notify', format_json(data.notify), 'textarea'),
('cancel', format_json(data.cancel), 'textarea'),
('cart', format_json(data.cart), 'textarea'),
# ('notes', data.notes, 'text'),
# ('description', data.description, 'text'),
# ('fee', data.description, 'text'),
# ('instmnt_mon', data.description, 'text'),
# ('instmnt_type', data.description, 'text'),
# ('recurr_opt', data.description, 'text'),
# ('m_ref_no', data.description, 'text'),
# ('notax_amt', data.description, 'text'),
# ('pay_valid_dt', data.description, 'text'),
# ('pay_valid_tm', data.description, 'text'),
#
# ('req_dt', data.description, 'text'),
# ('req_tm', data.description, 'text'),
#
# ('vat', data.description, 'text'),
# ('trans_dt', data.description, 'text'),
# ('trans_tm', data.description, 'text'),
# ('card_no', data.description, 'text'),
# ('callback_url', data.description, 'text'),
)
sm = colander.Schema()
values = {}
for f in form_list:
k = f[0]
v = f[1]
wg = f[2] == 'textarea' and widget.TextAreaWidget(rows=5, css_class="readonly") or\
widget.TextInputWidget(readonly=True)
sm.add(colander.SchemaNode(
colander.String(),
name=k,
oid=k,
widget=wg
))
values.update({k: v})
form = Form(sm)
form.render(values)
params['form'] = form
return dict(params=params)
# @view_config(route_name='api-payment-view',
# permission="api-payment-list",
# renderer='templates/payment/view.pt')
# def view_detail(self):
# request = self.req
# url_dict = request.matchdict
# view_id = url_dict['id']
# data = PartnerPay.query_id(id=view_id).first()
# params = dict(
# form=None
# )
# if data:
# customer = '{cust} - ({merc})'.format(cust=data.inv_cust_nm, merc=data.customer.nama)
# form_list = (
# ('vend_inv_no', data.vend_inv_no or '', 'text'),
# ('cust_inv_no', data.cust_inv_no or '', 'text'),
# ('tx_id', data.tx_id or '', 'text'),
# ('vendor', data.vendor.nama, 'text'),
# ('produk', data.produk.nama, 'text'),
# # ('id_pel', data.id_pel or '', 'text'),
# ('customer', customer, 'text'),
# ('cust_addr', data.inv_cust_addr or '', 'text'),
# ('cust_phone', data.inv_cust_phone or '', 'text'),
# ('cust_email', data.inv_cust_email or '', 'text'),
# ('cust_city', data.inv_cust_city or '', 'text'),
# ('cust_state', data.inv_cust_state or '', 'text'),
# ('cust_pos', data.inv_cust_pos or '', 'text'),
# ('cust_country', data.inv_cust_country or '', 'text'),
# # ('inv_valid_date', data.description, 'text'),
# # ('inv_valid_time', data.description, 'text'),
# # ('inv_time_stamp', data.description, 'text'),
# # ('inv_cust_va', data.description, 'text'),
# #
# # ('delivery_addr', data.description, 'text'),
# # ('delivery_city', data.description, 'text'),
# # ('delivery_country', data.description, 'text'),
# # ('delivery_nm', data.description, 'text'),
# # ('delivery_phone', data.description, 'text'),
# # ('delivery_pos', data.description, 'text'),
# # ('delivery_state', data.description, 'text'),
# # ('delivery_email', data.description, 'text'),
# # ('subtotal', data.subtotal, 'text'),
# # ('discount', data.discount, 'text'),
# # ('amt_sell', data.amt_sell, 'text'),
# ('inquiry', format_json(data.inquiry), 'textarea'),
# ('payment', format_json(data.payment), 'textarea'),
# ('advice', format_json(data.advice), 'textarea'),
# ('notify', format_json(data.notify), 'textarea'),
# ('cancel', format_json(data.cancel), 'textarea'),
# ('cart', format_json(data.cart), 'textarea'),
# # ('notes', data.notes, 'text'),
# # ('description', data.description, 'text'),
# # ('fee', data.description, 'text'),
# # ('instmnt_mon', data.description, 'text'),
# # ('instmnt_type', data.description, 'text'),
# # ('recurr_opt', data.description, 'text'),
# # ('m_ref_no', data.description, 'text'),
# # ('notax_amt', data.description, 'text'),
# # ('pay_valid_dt', data.description, 'text'),
# # ('pay_valid_tm', data.description, 'text'),
# #
# # ('req_dt', data.description, 'text'),
# # ('req_tm', data.description, 'text'),
# #
# # ('vat', data.description, 'text'),
# # ('trans_dt', data.description, 'text'),
# # ('trans_tm', data.description, 'text'),
# # ('card_no', data.description, 'text'),
# # ('callback_url', data.description, 'text'),
# )
# sm = colander.Schema()
# values = {}
# for f in form_list:
# k = f[0]
# v = f[1]
# wg = f[2] == 'textarea' and widget.TextAreaWidget(rows=5, css_class="readonly") or\
# widget.TextInputWidget(readonly=True)
# sm.add(colander.SchemaNode(
# colander.String(),
# name=k,
# oid=k,
# widget=wg
# ))
# values.update({k: v})
# form = Form(sm)
# form.render(values)
# params['form'] = form
# return dict(params=params)
......@@ -183,14 +183,14 @@
$('#btn_view').click(function() {
if (mID) {
//window.location = oTableUri + '/' + mID + '/view';
$('#payment-view').modal('show');
} else {
$.SmartMessageBox({
title : "View",
content : "Pilih Baris yang akan di lihat...",
buttons : '[Oke]'
});
window.location = oTableUri + '/' + mID + '/view';
// $('#payment-view').modal('show');
// } else {
// $.SmartMessageBox({
// title : "View",
// content : "Pilih Baris yang akan di lihat...",
// buttons : '[Oke]'
// });
}
});
......
......@@ -210,9 +210,16 @@ class ViewHome(BaseView):
result = build_request('payment', vendor_produk, invoice_det)
elif 'advice' in request.POST:
id = values['id']
id = 'id' in values and values['id'] or None
if not id:
session.flash('Belum ada Invoice', 'error')
form = get_form(request, EditSchema, (btn_inquiry, btn_purchase,
btn_payment, btn_advice, btn_next))
form.render(values)
return dict(form=form, params=form_params_view)
invoice_det = query_id(id).first()
if not invoice_det:
if not invoice_det :
session.flash('Data Tidak Ditemukan', 'error')
form = get_form(request, EditSchema, (btn_inquiry, btn_purchase,
btn_payment, btn_advice, btn_next))
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!