def vouchers_use(): try: print("In use voucher") # access session data (session['k']=v) try: cookie_id = request.cookies.get('{0}'.format(cookie_jar)) except Exception as e: cookie_id = None if cookie_id != None: session_details = session['{0}'.format(cookie_id)] print("Session Data") print(session_details) else: session_details = {} svc = vouchersServices(session_details) if request.method == 'POST': print("In POST") data = svc.useVoucher(request.form.to_dict()) print(data) return json.dumps(data) else: return json.dumps(code="01", msg="Wrong method used.") except TemplateNotFound as e: raise e
def vouchers_page_detatils(bulk_id): try: print("In vouchers") # access session data (session['k']=v) try: cookie_id = request.cookies.get('{0}'.format(cookie_jar)) except Exception as e: cookie_id = None if cookie_id != None: session_details = session['{0}'.format(cookie_id)] print("Session Data") print(session_details) else: return redirect(url_for("home.home_page")) svc = vouchersServices(session_details) if request.method == 'POST': print("In POST") data = svc.getVoucherByBulkId(bulk_id, request.form.to_dict()) return jsonify(data) data = svc.getVoucherByBulkId(bulk_id, {'page': 0, 'serial_status': "", 'branch_assigned': ""}) print(data) user_lang = lang if "lang" in session_details: user_lang = getattr(language, session_details['lang']) return render_template("vouchers/vouchers_detail.html", lang=user_lang, mStyle=language.STYLE['mer_style'], userdata=session_details, data=data, bulkId = bulk_id) except TemplateNotFound as e: raise e
def uploads_decline(): try: print("In uploads") # access session data (session['k']=v) try: cookie_id = request.cookies.get('{0}'.format(cookie_jar)) except Exception as e: cookie_id = None if cookie_id != None: session_details = session['{0}'.format(cookie_id)] print("Session Data") print(session_details) else: return redirect(url_for("home.home_page")) if request.method == 'POST': svc = vouchersServices(session_details) data = svc.decline_uploaded_file(request.form.to_dict()) return json.dumps(data) except TemplateNotFound as e: raise e
def vouchers_search(): try: print("In vouchers search") # access session data (session['k']=v) try: cookie_id = request.cookies.get('{0}'.format(cookie_jar)) except Exception as e: cookie_id = None if cookie_id != None: session_details = session['{0}'.format(cookie_id)] print("Session Data") print(session_details) else: return redirect(url_for("home.home_page")) print(session_details) request_data = request.form.to_dict() svc = vouchersServices(session_details) result = svc.searchvouchers(request_data) return json.dumps(result) except TemplateNotFound as e: raise e
def vouchers_update(): try: print("In bulkpay Add") # access session data (session['k']=v) try: cookie_id = request.cookies.get('{0}'.format(cookie_jar)) except Exception as e: cookie_id = None if cookie_id != None: session_details = session['{0}'.format(cookie_id)] print("Session Data") print(session_details) else: return redirect(url_for("home.home_page")) svc = vouchersServices(session_details) if request.method == 'POST': print("In POST") data = svc.updateCustomer(request.form.to_dict()) return json.dumps(data) else: return json.dumps(code="01", msg="Wrong method used.") except TemplateNotFound as e: raise e
def vouchers_export(): try: print("In Vouchers Export") # access session data (session['k']=v) try: cookie_id = request.cookies.get('{0}'.format(cookie_jar)) except Exception as e: cookie_id = None if cookie_id != None: session_details = session['{0}'.format(cookie_id)] print("Session Data") print(session_details) else: return redirect(url_for("home.home_page")) svc = vouchersServices(session_details) if request.method == 'GET': print("In GET") print(request.args.to_dict()) data = svc.getAllvouchersExport(request.args.to_dict()) print(data) response_data = excel.make_response_from_array(data, "xls") response = make_response(response_data) response.headers['Content-Disposition'] = 'attachment; filename=siclife_vouchers.xls' response.headers['Content-Type'] = 'application/xls' return response except TemplateNotFound as e: raise e
def serial_verification(): try: # access session data (session['k']=v) print("In serial verification route") try: cookie_id = request.cookies.get('{0}'.format(cookie_jar)) except Exception as e: cookie_id = None if cookie_id != None: session_details = session['{0}'.format(cookie_id)] print("Session Data") print(session_details) else: return redirect(url_for("home.home_page")) svc = vouchersServices(session_details) if request.method == 'POST': result = svc.getVerificationHistory(request.form.to_dict()) print(result) return jsonify(result) else: return redirect(url_for("home.home_page")) except TemplateNotFound as e: raise e
def check_vouch(): if request.method == 'POST': request_data = request.form.to_dict() svc = vouchersServices({}) data = svc.getSerialDetialsValidate(request_data) print(data) return jsonify(data) else: return json.dumps({"error": "invalid request sent"})
def vouchers_reg_uploads(): try: print("In Customer uploads") # access session data (session['k']=v) try: cookie_id = request.cookies.get('{0}'.format(cookie_jar)) except Exception as e: cookie_id = None if cookie_id != None: session_details = session['{0}'.format(cookie_id)] print("Session Data") print(session_details) else: return redirect(url_for("home.home_page")) svc = vouchersServices(session_details) if request.method == 'POST': print("In POST") data = svc.getAllUploadsRequests(request.form.to_dict()) #return jsonify(**data) return json.dumps(data) data = svc.getAllUploadsRequests({ 'page': 0, 'fromdate': "", 'todate': ""}) request_data = svc.getAllCustomerRequests({ 'page': 0, 'fromdate': "", 'todate': "", "branch":"", "request_type":""}) uploads_data = svc.getAllUploadsRequests({ 'page': 0, 'fromdate': "", 'todate': ""}) print(data) print() print(request_data) user_lang = lang if "lang" in session_details: user_lang = getattr(language, session_details['lang']) # print(user_lang) return render_template("vouchers/vouchers.html", lang=user_lang, mStyle=language.STYLE['mer_style'], userdata=session_details, data=data, req_data=request_data, up_data=uploads_data) except TemplateNotFound as e: raise e
def vouchers_page(): try: print("In vouchers") # access session data (session['k']=v) try: cookie_id = request.cookies.get('{0}'.format(cookie_jar)) except Exception as e: cookie_id = None if cookie_id != None: session_details = session['{0}'.format(cookie_id)] print("Session Data") print(session_details) else: return redirect(url_for("home.home_page")) svc = vouchersServices(session_details) if request.method == 'POST': print("In POST") data = svc.getAllVouchers(request.form.to_dict()) #return jsonify(**data) return json.dumps(data) data = svc.getAllVouchers({ 'page': 0, 'fromdate': "", 'todate': ""}) uploads_data = svc.getAllUploadsRequests({ 'page': 0, 'fromdate': "", 'todate': ""}) history = svc.getVerificationHistory({'page': 0, 'fromdate': "", 'todate': "", "status": "All"}) length = history["pages"] print("length is ", str(length)) user_lang = lang if "lang" in session_details: user_lang = getattr(language, session_details['lang']) return render_template("vouchers/vouchers.html", length = length, lang=user_lang, mStyle=language.STYLE['mer_style'], userdata=session_details, data=data, up_data=uploads_data, history=history) except TemplateNotFound as e: raise e
def uploads_upload(): try: print("In uploads") # access session data (session['k']=v) try: cookie_id = request.cookies.get('{0}'.format(cookie_jar)) except Exception as e: cookie_id = None if cookie_id != None: session_details = session['{0}'.format(cookie_id)] print("Session Data") print(session_details) else: return redirect(url_for("home.home_page")) if request.method == 'POST': # data = request.form.to_dict() # print("Data") # print(data) # file_obl = request.files['file'] # print("File") # print(file_obl.filename) #check if request has file object if 'file' not in request.files: return redirect(url_for("vouchers.vouchers_page")) file_obl = request.files['file'] #if user submit empty form part without filename if file_obl.filename == '': return redirect(url_for("vouchers.vouchers_page")) svc = vouchersServices(session_details) data = svc.record_uploaded_file(file_obl) return redirect(url_for("vouchers.vouchers_page")) except TemplateNotFound as e: raise e