def change(): c = Db() crntpswrd = request.form['textfield'] newpswrd = request.form['textfield2'] cnfrmpswrd = request.form['textfield3'] x = session['userid'] if newpswrd == cnfrmpswrd: qry = "select password from login where lid='" + str(x) + "'" res = c.selectOne(qry) if res is not None: if res['password'] == crntpswrd: q = "update login set password='******' where lid='" + str( x) + "'" c.update(q) y = "select * from login where lid='" + str(x) + "'" r = c.selectOne(y) if r is not None: type = r['type'] if type == 'admin': return adm_home() else: return user_home() else: return '''<script>alert('incorrect current password');window.location='/chpswrd';</script>''' else: return '''<script>alert('passwords not matching');window.location='/chpswrd';</script>'''
def and_payment(): acc = request.form['acnt'] val = request.form['mmyy'] pinno = request.form['pin'] ccv = request.form['ccv'] tid = request.form['t_id'] total = request.form['amnt'] lid = request.form['custid'] qry = "select * from bank where customer_id='" + lid + "' and card_number='" + acc + "' and valid_thru='" + val + "' and cvv='" + ccv + "' and pin='" + pinno + "'" d = Db() res = d.selectOne(qry) if res is None: return jsonify(status="invalid") else: balance = res['bal'] session['a'] = balance if int(balance) < int(total): return jsonify(status="insuff") else: oid = d.insert( "insert into `table_booking`(`table_hotel_id`,`cust_id`,`date`,`time`,`status`)values('" + tid + "','" + lid + "',curdate(),curtime(),'alloted')") d.update("update bank set bal='" + str(session['a']) + "'-'" + str(total) + "' where bank_id='" + str(res['bank_id']) + "'") return jsonify(status="ok")
def adm_reply_post(): if session['lin'] == "lin": obj1=Db() reply=request.form['r'] qry= "update complaint set reply='"+reply+"',reply_date=curdate(),status='replied' where c_id='"+str(session['com'])+"'" obj1.update(qry) return ''' <script> alert('replyed succesfully');window.location="/adm_vcomt"; </script> ''' else: return render_template("login.html")
def view_user_pro_bank(): d = Db() print("mr") uid = request.form["uid"] ac = request.form["ac"] pwd = request.form["pwd"] prd_pr = request.form["price"] tid = request.form["tid"] print("mr") q = "select amt from bank where login_id='" + str( uid) + "' and ac_no='" + ac + "' and pwd='" + pwd + "'" print(q) r = d.selectOne(q) print("r=", r) bnk_blc = int(r["amt"]) pri = int(prd_pr) new_bl = 0 print("b1=", bnk_blc) print("b2=", pri) if bnk_blc > pri: print("mmm22") new_bl = bnk_blc - pri print("now ba=", new_bl) qq2 = "update bank set amt='" + str( new_bl) + "' where ac_no='" + ac + "' and pwd='" + pwd + "'" d.insert(qq2) qq25 = "update table_hotel set status='ok' where table_hotel_id='" + str( tid) + "'" print("qqq") d.insert(qq25) qq23 = "INSERT INTO `table_booking`(`table_hotel_id`,`cust_id`,`date`,`time`,`status`)VALUES('" + str( tid) + "','" + str(uid) + "',CURDATE(),CURTIME(),'pending')" print("qqq") d.insert(qq23) new_ot_bl = 0 qr3 = "select amt from bank where login_id='1'" print(qr3) rrk = d.selectOne(qr3) othr_bl = int(rrk["amt"]) print("othr=", othr_bl) print("pp=", pri) new_ot_bl = othr_bl + pri qr4 = "update bank set amt='" + str(new_ot_bl) + "' where login_id='1'" print(qr4) d.update(qr4) return jsonify(status="ok") else: return jsonify(status="no")
def mng_accept22(vid, id): qr = "update table_hotel set status='pending' where table_hotel_id='" + str( id) + "'" print(qr) db = Db() res = db.update(qr) qr2 = "delete from table_booking where table_book_id='" + str(vid) + "'" print(qr2) db = Db() db.update(qr2) return mng_view_ordrrer()
def reply(): c = Db() response = request.form['textfield'] q = "update complaint set response='" + response + "' where cmpid='" + session[ "id"] + "'" r = c.update(q) return adm_cmplnt()
def workdetails1(a, b): db = Db() num = request.form['no'] sdate = request.form['sdate'] edate = request.form['edate'] amt = request.form['amt'] qr_code = qrcode.make(b) qr_code.save("E:\\welding\\WeldingConsultancy_python\\static\\qrcode\\" + str(b) + ".png") db.insert("insert into payment VALUES ('','" + b + "','" + amt + "','','','pending')") db.insert("insert into schedule VALUES ('','" + b + "','" + sdate + "','" + edate + "','" + num + "')") db.update("update worktable set work_status='confirm' WHERE workid='" + b + "' ") return '<script>alert("Added successfully");window.location="/confirmwork"</script>'
def Admin_reply_post(): cid=request.form["cid"] reply=request.form ["textarea"] db=Db() qry="update complaint set C_reply='"+reply+"' where C_id='"+cid+"'" res = db.update(qry) return admin_view_complaint()
def adm_edit_add_table(): db = Db() y = session['rid'] tabnum = request.form['textfield'] charge = request.form['textfield1'] qry = "select * from table_hotel where table_num='" + tabnum + "' and table_hotel_id!='" + str( y) + "'" res = db.select(qry) print(res) if len(res) > 0: return 'Table Number Already Existing' else: qry = "update table_hotel set table_num='" + tabnum + "',charge='" + charge + "' " if request.files is not None: if 'filefield' in request.files: img = request.files['filefield'] if img.filename != "": img.save(static_path + "Table\\" + img.filename) path = "/static/Table/" + img.filename qry = qry + ",picture='" + path + "'" else: return 'no' qry = qry + " where table_hotel_id='" + str(y) + "'" res = db.update(qry) return adm_view_tables()
def trn_edit_add_category(): db = Db() y = session['pp'] category = request.form['select'] qr = "update category set category_name='" + category + "' where category_id='" + str( y) + "'" res = db.update(qr) return adm_View_Category()
def updateraw1(id): db = Db() name = request.form['raw_name'] quantity = request.form['raw_quantity'] desc = request.form['description'] qry = db.update("update rawmaterial set raw_name='" + name + "',quantity='" + quantity + "',description='" + desc + "' where raw_id='" + id + "'") return viewrawmaterial()
def editworker1(id): db = Db() name = request.form['txt_name'] dob = request.form['txt_dob'] mobile = request.form['txt_mobile'] adhar = request.form['txt_adhar'] email = request.form['txt_email'] house = request.form['txt_house'] place = request.form['txt_place'] post = request.form['txt_post'] pin = request.form['txt_pin'] photo = request.files['photo'] wages = request.form['wages'] if request.files is not None: if photo.filename != "": date = datetime.datetime.now().strftime("%y%m%d-%H%M%S") photo.save(path + date + ".jpg") pth = "/static/photos/" + date + ".jpg" qry = db.update("update worker set worker_name='" + name + "',dob='" + dob + "',phone_no='" + mobile + "',adhar_no='" + adhar + "',worker_email='" + email + "',house_name='" + house + "',place='" + place + "',post='" + post + "',pin='" + pin + "',photo='" + str(pth) + "',wages='" + wages + "' where workerid='" + id + "'") return viewworker() else: qry = db.update("update worker set worker_name='" + name + "',dob='" + dob + "',phone_no='" + mobile + "',adhar_no='" + adhar + "',worker_email='" + email + "',house_name='" + house + "',place='" + place + "',post='" + post + "',pin='" + pin + "',wages='" + wages + "' where workerid='" + id + "'") return viewworker() else: qry = db.update("update worker set worker_name='" + name + "',dob='" + dob + "',phone_no='" + mobile + "',adhar_no='" + adhar + "',worker_email='" + email + "',house_name='" + house + "',place='" + place + "',post='" + post + "',pin='" + pin + "',wages='" + wages + "' where workerid='" + id + "'") return viewworker()
def and_payment_food(): acc = request.form['acnt'] val = request.form['mmyy'] pinno = request.form['pin'] ccv = request.form['ccv'] total = request.form['amnt'] lid = request.form['custid'] qry = "select * from bank where customer_id='" + lid + "' and card_number='" + acc + "' and valid_thru='" + val + "' and cvv='" + ccv + "' and pin='" + pinno + "'" d = Db() res = d.selectOne(qry) if res is None: return jsonify(status="invalid") else: balance = res['bal'] session['a'] = balance if int(balance) < int(total): return jsonify(status="insuff") else: print("ok") qry2 = "select * from cart where cust_id='" + lid + "'" res2 = d.select(qry2) qqq = "select table_hotel_id from table_booking where cust_id='" + lid + "'" rrr = d.selectOne(qqq) session['ti'] = rrr['table_hotel_id'] oid = d.insert( "insert into order_master(`customer_id`,`total`,`date`,`status`,`type`,`table_hotel_id`) values('" + lid + "','" + total + "',curdate(),'success','food','" + str(session['ti']) + "')") for i in res2: qry3 = "insert into order_table(`food_items_id`,`quantity`,`order_master_id`) values('" + str( i['food_id']) + "','" + str( i['quantity']) + "','" + str(oid) + "')" d.insert(qry3) d.delete("delete from cart where cart_id='" + str(i['cart_id']) + "'") d.update("update bank set bal='" + str(session['a']) + "'-'" + str(total) + "' where bank_id='" + str(res['bank_id']) + "'") return jsonify(status="ok")
def pchange(): if session['lin'] == "lin": obj1=Db() crpswd=request.form['cpsw'] newpswd=request.form['newpsw'] cnfpswd = request.form['cpswd'] if newpswd == cnfpswd: qry= "select password from login where login_id='"+str(session["userid"])+"'" res=obj1.selectOne(qry) if res is not None: if res['password']==crpswd: q="update login set password='******' where login_id='"+str( session["userid"])+"'" obj1.update(q) return userhome() else: return '''<script>alert('incorrect current password');window.location='/cpswd';</script>''' else: return '''<script>alert(' passwords not matching ');window.location='/cpswd';</script>''' else: return render_template("login.html")
def payment(id, amount): db = Db() account = request.form['acc'] ifc = request.form['i'] total = request.form['textfield3'] a = db.selectOne("select * from account where account_no='" + account + "' and ifsc_code='" + ifc + "'") o_account = db.selectOne("select * from account where account_id='2'") if a is not None: balance = a['balance'] if float(balance) > float(total): available_balance = float(balance) - float(total) o_balance = o_account['balance'] o_cbalance = float(o_balance) + float(total) db.update("update account set balance='" + str(available_balance) + "' where account_no='" + account + "'") db.update("update account set balance='" + str(o_cbalance) + "' where account_id='3'") db.update( "update payment set status='salary_paid' where workid='" + str(id) + "'") qry2 = db.select( "select * from scheduleworker where scheduleworker.workid='" + str(id) + "'") for i in qry2: worker_id = i['worker_id'] q = db.insert("insert into salary values ('','" + str(amount) + "','" + str(worker_id) + "',curdate())") return '<script>alert("Payment successfully");window.location="/confirmwork"</script>' else: return '<script>alert("Insufficent Balance");window.location="/confirmwork"</script>' else: return '<script>alert("Invalid Account");window.location="/confirmwork"</script>'
def edit_maintanance_post(i): name = request.form['name'] number = request.form['name2'] email = request.form['name3'] place = request.form['name4'] area = request.form['name5'] db = Db() query = db.update("update maintenance set maintenance_name='" + name + "',ph_number='" + number + "',email='" + email + "',place='" + place + "',area='" + area + "' where maintenance_id='" + str(i) + "'") return '<script>alert("Updated Successfully");window.location="/view_maintenance"</script>'
def view_user_pro_bank2(): d = Db() print("mr") uid = request.form["uid"] ac = request.form["ac"] pwd = request.form["pwd"] prd_pr = request.form["price"] print("mr") q = "select amt from bank where login_id='" + str( uid) + "' and ac_no='" + ac + "' and pwd='" + pwd + "'" print(q) r = d.selectOne(q) print("r=", r) bnk_blc = int(r["amt"]) pri = int(prd_pr) new_bl = 0 print("b1=", bnk_blc) print("b2=", pri) if bnk_blc > pri: print("mmm22") new_bl = bnk_blc - pri print("now ba=", new_bl) qq2 = "update bank set amt='" + str( new_bl) + "' where ac_no='" + ac + "' and pwd='" + pwd + "'" d.insert(qq2) q11 = "select order_master_id from order_master where customer_id='" + str( uid) + "' and status='pending'" print(q11) rm = d.selectOne(q11) print("rm=", rm) qq2 = "update order_master set status='ok' where order_master_id='" + str( rm['order_master_id']) + "'" print(qq2) d.update(qq2) new_ot_bl = 0 qr3 = "select amt from bank where login_id='1'" print(qr3) rrk = d.selectOne(qr3) othr_bl = int(rrk["amt"]) print("othr=", othr_bl) print("pp=", pri) new_ot_bl = othr_bl + pri qr4 = "update bank set amt='" + str(new_ot_bl) + "' where login_id='1'" print(qr4) d.update(qr4) qq2 = "delete from cart where cust_id='" + str(uid) + "'" d.update(qq2) return jsonify(status="ok") else: return jsonify(status="no")
def payment(): db = Db() # lid=request.form['lid'] workid = request.form['workid'] qry1 = db.selectOne( "select * from payment where status='paid' and workid='" + str(workid) + "' ") res = {} if qry1 is not None: res['status'] = "Oops! Already paid" else: qry = db.update("update payment set status='paid' WHERE workid='" + workid + "'") res['status'] = "OK" return demjson.encode(res)
def change_password_post(): current_password =request.form["textfield"] password= request.form["textfield2"] confirm_password=request.form["textfield3"] db=Db() lid=session["lid"] qry2="select Password from login where Login_id ='"+str(lid)+"'" res =db.selectOne(qry2) if res["Password"] == current_password : if password == confirm_password : qry ="update login set Password = '******'WHERE Login_id = '"+str(lid)+"'" res = db.update(qry) return '''<script>alert('Password changed');window.location ='/'</script> ''' else: return '''<script>alert('Password not equal to current password');window.location ='/Change_password'</script> ''' else : return '''<script>alert('Password incorrect');window.location ='/Change_password'</script> '''
def act_reply(id): r = request.form["txt_reply"] db = Db() db.update("update complaint set reply_date=now(),reply='" + r + "' where complaint_id='" + str(id) + "'") return viewcomplaint()
def mng_accept(vid): qr = "UPDATE `order_master` SET `status`='approved' where order_master_id='" + vid + "'" db = Db() res = db.update(qr) return mng_view_order()
def wtr_view_itemfffs(vid): qr = "update order_master set status='over' where order_master_id='" + str( vid) + "'" db = Db() res = db.update(qr) return render_template("Waitor/wtrdashboard.html")
def reject_leave(id): db = Db() qry = db.update( "update worker_leave set status='reject' where leave_id='" + str(id) + "'") return '<script>alert("Rejected");window.location="/confirmleave"</script>'
def reject_work(a): db = Db() db.update("update worktable set work_status='reject' WHERE workid='" + a + "' ") return '<script>alert("Rejected");window.location="/confirmwork"</script>'
def admin_accept_reject_doctor(lid,status): qry="update login set Login_type ='"+status+"'where Login_id ='"+lid+"'" db=Db() db.update(qry) return '''<script>alert('Succesfully Updated');window.location="/adm_view_doctor_request"</script>'''
def update_work_status_post(id): s = request.form['txt_reply'] db = Db() qry = db.update("update worktable set work_status='" + str(s) + "' where workid='" + str(id) + "' ") return '<script>alert("Status Updated");window.location="/confirmwork"</script>'
def block(id, type): c = Db() q = "update login set type='" + type + "' where lid='" + id + "'" res = c.update(q) return adm_users()
def status1(id): db = Db() status = request.form['raw_name'] qry = db.update("update worktable set status='" + status + "' where workid='" + id + "'") return updatestaus()
def delete(a): db = Db() rq = db.update("update service set status='0' WHERE service_id='" + a + "'") return '<script>alert("Removed....");window.location="/viewservice"</script>'
def enable(a): db = Db() rq = db.update("update service set status='1' WHERE service_id='" + a + "'") return '<script>alert("Successfully added.....");window.location="/enableservice"</script>'