def CreateCustomer(id, Acctype): form = createcustomer() if form.validate_on_submit(): print("entered validate") cuslast = B_Customer.query.all()[-1] cusid = "C" + str(int(cuslast.C_id[1:]) + 1) cus1 = B_Customer(C_id=cusid, firstname=form.firstname.data, lastname=form.lastname.data, gender=form.gender.data, age=form.age.data, email=form.email.data, address=form.address.data, number=form.phone.data, C_pass="******", balance=form.balance.data) db.session.add(cus1) db.session.commit() cardno = B_Customer_Card_Details.query.all()[-1] cardid = cardno.Card_No + 1 card1 = B_Customer_Card_Details(C_id=cusid, Card_Type="MasterCard", Card_No=cardid, Card_Activate=True, Usagetype="Domestic", Card_Status_Type="Debit", ExpiryDate="02/23") db.session.add(card1) now = datetime.now() dt_string = now.strftime("%B %d %Y-- %H:%M:%S") log = logs(Actor_id=id, Actor_Type=Acctype, ActionDone="Created a New customer", OtherId=cusid, ActionTime=dt_string) db.session.add(log) db.session.commit() msg1 = "Customer Successfully Created" sub = "Account Created" htmlbody = f"Hello <b>{form.firstname.data}</b>,<br><br>Your Account has been Created<br><b>Username</b> : {cusid}<br><b>Password</b> : password<br><br>please login to portal to find more<br>if not done by you please report us<br><b>Best Wishes,</b><br><br>Team Bank Application" msg = Message(sub, sender='*****@*****.**', recipients=[form.email.data]) msg.html = htmlbody mail.send(msg) return render_template('CreateAlert.html', id=id, msg=msg1, Atype=Acctype) else: err = form.errors for i in err: flash(i + "-" + str(err[i])) return render_template('CreateNewCustomer.html', id=id, form=form, Acctype=Acctype)
def EditEmployeeDeatils(id, cid, Acctype): form = EditEmployee() custm = B_Employee.query.filter_by(E_id=cid).first() if form.validate_on_submit(): custm = B_Employee.query.filter_by(E_id=cid).first() if (form.firstname.data): custm.E_firstname = form.firstname.data if (form.lastname.data): custm.E_lastname = form.lastname.data if (form.gender.data): custm.E_gender = form.gender.data if (form.age.data): custm.E_age = form.age.data if (form.address.data): custm.E_address = form.address.data if (form.phone.data): custm.E_number = form.phone.data db.session.add(custm) now = datetime.now() dt_string = now.strftime("%B %d %Y-- %H:%M:%S") log = logs(Actor_id=id, Actor_Type=Acctype, ActionDone="Edited Employee Details", OtherId=cid, ActionTime=dt_string) db.session.add(log) db.session.commit() sub = "Account Details Edited" htmlbody = f"Hello <b>{custm.E_firstname}</b>,<br><br>Your Account Account Details has been edited <br><b>please login to portal to find more<br>if not done on your request, please report us<br><b>Best Wishes,</b><br><br>Team Bank Application" msg = Message(sub, sender='*****@*****.**', recipients=[custm.E_email]) msg.html = htmlbody mail.send(msg) msg = "Employee Details Successfully Edited" return render_template('CreateAlert.html', id=id, msg=msg, Atype=Acctype) else: err = form.errors for i in err: flash(i + "-" + str(err[i])) return render_template('EditEmployeeDetails.html', id=id, form=form, custm=custm, Acctype=Acctype)
def CreateEmployee(id): form = createemloyee() if form.validate_on_submit(): print("entered validate") emplast = B_Employee.query.all()[-1] empid = "E" + str(int(emplast.E_id[1:]) + 1) print(empid) Emp1 = B_Employee(E_id=empid, firstname=form.firstname.data, lastname=form.lastname.data, gender=form.gender.data, age=form.age.data, email=form.email.data, address=form.address.data, number=form.phone.data, E_pass="******") db.session.add(Emp1) now = datetime.now() dt_string = now.strftime("%B %d %Y-- %H:%M:%S") log = logs(Actor_id=id, Actor_Type="Admin", ActionDone="Created a New Employee ", OtherId=empid, ActionTime=dt_string) db.session.add(log) db.session.commit() msg1 = "Employee Successfully Created" sub = "Account Created" htmlbody = f"Hello <b>{form.firstname.data}</b>,<br><br>welcome to the Organization.we are glad that ypu are joining us<br>Your Account has been Created<br><b>Username</b> : {empid}<br><b>Password</b> : password<br><br>please login to portal to find more<br>if not done on your request, please report us<br><b>Best Wishes,</b><br><br>Team Bank Application" msg = Message(sub, sender='*****@*****.**', recipients=[form.email.data]) msg.html = htmlbody mail.send(msg) return render_template('CreateAlert.html', id=id, msg=msg1, Atype="Admin") else: err = form.errors for i in err: flash(i + "-" + str(err[i])) return render_template('CreateNewEmployee.html', id=id, form=form)
def AddAmounttoCustomerAccount1(id, cid, Acctype): form = AmountTransferForm() cust = B_Customer.query.filter_by(C_id=cid).first() if form.validate_on_submit(): cust = B_Customer.query.filter_by(C_id=cid).first() cust.C_balance = cust.C_balance + int(form.Amount.data) db.session.add(cust) now = datetime.now() dt_string = now.strftime("%B %d %Y-- %H:%M:%S") log = logs(Actor_id=id, Actor_Type=Acctype, ActionDone="Added Amount to customer Account ", OtherId=cid, ActionTime=dt_string) db.session.add(log) db.session.commit() sub = f"Amount Rs.{form.Amount.data} Credited into your Account" htmlbody = f"Hello <b>{cust.C_firstname}</b>,<br><br> An Amount of Rs.{form.Amount.data} credited into your Account <br><br>please login to portal to find more<br>if not done on your request, please report us<br><b>Best Wishes,</b><br><br>Team Bank Application" msg = Message(sub, sender='*****@*****.**', recipients=[cust.C_email]) msg.html = htmlbody mail.send(msg) msg = "Succesfully Added Amount to the Customer Account" return render_template('CreateAlert.html', id=id, msg=msg, Atype=Acctype) else: print(form.errors) return render_template('AddAmounttoCustomerAccount1.html', id=id, form=form, cust=cust, Acctype=Acctype)
db.session.add(Cardn) db.session.commit() event.listen( CardRequests.__table__, "after_create", DDL("ALTER TABLE CardRequests SET id = 85000001 WHERE id=1;") ) req=CardDeActLogs(C_id="C1",CardNo=456484560001,DeActReason="Lost") db.session.add(req) db.session.commit() event.listen( CardDeActLogs.__table__, "after_create", DDL("ALTER TABLE CardDeActLogs SET id = 24000001 WHERE id=1;") ) log=logs(Actor_id="A1",Actor_Type="Admin",ActionDone="Created a New Customer",OtherId="C1",ActionTime=dt_string) db.session.add(log) log0=logs(Actor_id="A1",Actor_Type="Admin",ActionDone="Created a New Customer",OtherId="C1",ActionTime=dt_string) db.session.add(log0) log1=logs(Actor_id="A1",Actor_Type="Admin",ActionDone="Created a New Employee ",OtherId="E1",ActionTime=dt_string) db.session.add(log1) db.session.add(tarns) db.session.add(tarns1) db.session.commit() employee=B_Employee.query.all() print(employee) customer=B_Customer.query.all() print(customer)
def EvaluateDeactivateCardRequest(id, rid, Acctype): reqs = CardDeActLogs.query.filter_by(id=rid).first() cust = B_Customer.query.filter_by(C_id=reqs.C_id).first() form = EvaluationForm() if form.validate_on_submit(): if form.Approve.data: card = B_Customer_Card_Details.query.filter_by( Card_No=reqs.CardNo).first() card.Card_Activate = False db.session.add(card) db.session.delete(reqs) now = datetime.now() dt_string = now.strftime("%B %d %Y-- %H:%M:%S") log = logs( Actor_id=id, Actor_Type=Acctype, ActionDone="Accepted Customer Request for card Deactivation ", OtherId=rid, ActionTime=dt_string) db.session.add(log) db.session.commit() sub = "Card Deactivation Request Approved" htmlbody = f"Hello <b>{cust.C_firstname}</b>,<br><br>Your Request for Card Deactivation is Approved <br><b>Reference Id</b> :{rid}<br>please login to portal to find more<br>if not done on your request, please report us<br><b>Best Wishes,</b><br><br>Team Bank Application" msg = Message(sub, sender='*****@*****.**', recipients=[cust.C_email]) msg.html = htmlbody mail.send(msg) msg = "Accepted Customer Request for card Deactivation" return render_template('CreateAlert.html', id=id, msg=msg, Atype=Acctype) else: db.session.delete(reqs) now = datetime.now() dt_string = now.strftime("%B %d %Y-- %H:%M:%S") log = logs( Actor_id=id, Actor_Type=Acctype, ActionDone="Declined Customer Request for card Deactivation ", OtherId=rid, ActionTime=dt_string) db.session.add(log) db.session.commit() sub = "Card Deactivation Request Declined" htmlbody = f"Hello <b>{cust.C_firstname}</b>,<br><br>Your Request for Card Deactivation is Declined <br><b>Reference Id</b> :{rid}<br>please login to portal to find more<br>if not done on your request, please report us<br><b>Best Wishes,</b><br><br>Team Bank Application" msg = Message(sub, sender='*****@*****.**', recipients=[cust.C_email]) msg.html = htmlbody mail.send(msg) msg = "Declined Customer Request for card Deactivation" return render_template('CreateAlert.html', id=id, msg=msg, Atype=Acctype) else: flash(form.errors) return render_template('EvaluateDeactivateCardRequest.html', id=id, reqs=reqs, cust=cust, form=form, Acctype=Acctype)
def EvaluateIssueCardRequest(id, rid): reqs = CardRequests.query.filter_by(id=rid).first() cust = B_Customer.query.filter_by(C_id=reqs.C_id).first() form = EvaluationForm() if form.validate_on_submit(): if form.Approve.data: cardno = B_Customer_Card_Details.query.all()[-1] cardid = cardno.Card_No + 1 card1 = B_Customer_Card_Details( C_id=reqs.C_id, Card_Type=reqs.Card_Type, Card_No=cardid, Card_Activate=True, Usagetype=reqs.Usagetype, Card_Status_Type=reqs.Card_Status_Type, ExpiryDate="02/28") db.session.add(card1) db.session.delete(reqs) now = datetime.now() dt_string = now.strftime("%B %d %Y-- %H:%M:%S") log = logs(Actor_id=id, Actor_Type="Admin", ActionDone="Issue a new card for an customer ", OtherId=rid, ActionTime=dt_string) db.session.add(log) db.session.commit() sub = "Card Approved" htmlbody = f"Hello <b>{cust.C_firstname}</b>,<br><br>Your Request for new Card is Approved <br><b>Reference Id</b> :{rid}<br>please login to portal to find more<br>if not done on your request, please report us<br><b>Best Wishes,</b><br><br>Team Bank Application" msg = Message(sub, sender='*****@*****.**', recipients=[cust.C_email]) msg.html = htmlbody mail.send(msg) msg1 = "Issued a new card succesfully" return render_template('CreateAlert.html', id=id, msg=msg1, Atype="Admin") else: db.session.delete(reqs) now = datetime.now() dt_string = now.strftime("%B %d %Y-- %H:%M:%S") log = logs(Actor_id=id, Actor_Type="Admin", ActionDone="Declined a Customer Request for new card ", OtherId=rid, ActionTime=dt_string) db.session.add(log) db.session.commit() sub = "Card Declined" htmlbody = f"Hello <b>{cust.C_firstname}</b>,<br><br>Your Request for new Card is Declined <br><b>Reference Id</b> :{rid}<br>please login to portal to find more<br>if not done on your request, please report us<br><b>Best Wishes,</b><br><br>Team Bank Application" msg = Message(sub, sender='*****@*****.**', recipients=[cust.C_email]) msg.html = htmlbody mail.send(msg) msg = "Declined a Customer Request for new card" return render_template('CreateAlert.html', id=id, msg=msg, Atype="Admin") else: flash(form.errors) return render_template('EvaluateIssueCardRequest.html', id=id, reqs=reqs, cust=cust, form=form)