Beispiel #1
0
def update_customer():
    user = helpers.is_authenticated()
    if user[1].accType == "NCE":
        if request.method == "POST":
            customer_details = Customer.query.filter_by(
                customerid=int(request.get_json()["cid"]),
                status="active").first()
            customer_details.name = request.get_json()["name"]
            customer_details.ssnid = int(request.get_json()["ssnid"])
            customer_details.age = int(request.get_json()["age"])
            customer_details.address = request.get_json()["addr"]
            customer_details.message = "Account Updated"
            customer_details.last_update = datetime.now().strftime(
                "%d-%m-%Y, %H:%M:%S %p")
            db.session.commit()
            flash("Successfully Updated", "success")
        return render_template("customerCRUD.html",
                               title="Update Customer",
                               type="update",
                               user=user[1].name,
                               userdesg=user[1].accType)
    else:
        flash(
            "You are not allowed to enter this view, contact your supervisor",
            "danger")
        return redirect(url_for("usermgmt.dashboard"))
Beispiel #2
0
def withdraw_account():
    user = helpers.is_authenticated()
    if user[1].accType == "CT":
        return render_template("transactionCRUD.html",
                               type="withdraw",
                               user=user[1].name,
                               userdesg=user[1].accType)
Beispiel #3
0
def newcustomer():
    user = helpers.is_authenticated()
    if user[1].accType == "NCE":
        form = NewCustomer()
        if form.validate_on_submit():
            print("entering Done")
            addr = form.Address.data + ", " + form.City.data + ", " + form.State.data
            u = Customer(ssnid=int(form.Ssnid.data),
                         name=form.Name.data,
                         status="inactive",
                         age=int(form.Age.data),
                         address=addr)
            db.session.add(u)
            db.session.commit()
            flash(
                "New Customer created successfully, please wait to get verified",
                "success")
        return render_template("customerCRUD.html",
                               form=form,
                               title="New Customer",
                               type="create",
                               user=user[1].name,
                               userdesg=user[1].accType)
    else:
        flash(
            "You are not allowed to enter this view, contact your supervisor",
            "danger")
        return redirect(url_for("usermgmt.dashboard"))
Beispiel #4
0
def view_account_info():
    user = helpers.is_authenticated()
    if user[1].accType == "CT":
        return render_template("transactionCRUD.html",
                               type="view",
                               user=user[1].name,
                               userdesg=user[1].accType)
    else:
        flash("Not allowed in this view", "danger")
        return redirect(url_for("usermgmt.dashboard"))
Beispiel #5
0
def view_customers():
    user = helpers.is_authenticated()
    if user[1].accType == "NCE":
        customers = Customer.query.all()
        accounts = list(
            db.engine.execute(
                """select account.customerid, accountid, customer.name, customer.ssnid, account.status,account.last_update, "accType", amount from customer, account
                                        where customer.customerid = account.customerid and account.status = 'active'"""
            ))
        return render_template("customerCRUD.html",
                               title="View All Customers",
                               type="read",
                               user=user[1].name,
                               userdesg=user[1].accType,
                               customers=customers,
                               accounts=accounts)
    else:
        flash(
            "You are not allowed to enter this view, contact your supervisor",
            "danger")
        return redirect(url_for("usermgmt.dashboard"))
Beispiel #6
0
def dashboard():
    user = helpers.is_authenticated()
    if user[1].accType == "NCE":
        inactiveusers = list(
            Customer.query.filter_by(status='inactive')) + list(
                Account.query.filter_by(status='inactive'))
        inactiveaccounts = list(
            db.engine.execute(
                """select account.customerid, name, ssnid, account.status, account.accountid from customer, account
                                                  where customer.customerid=account.customerid and account.status='pending'"""
            ))
        return render_template("dashboard.html",
                               title="Dashboard",
                               user=user[1].name,
                               userdesg=user[1].accType,
                               inactiveusers=inactiveusers,
                               inactiveaccounts=inactiveaccounts)
    elif user[1].accType == "CT":
        return render_template("dashboard.html",
                               title="Dashboard",
                               user=user[1].name,
                               userdesg=user[1].accType)
Beispiel #7
0
def new_account():
    user = helpers.is_authenticated()
    if user[1].accType == "NCE":
        form = NewAccount()
        if form.validate_on_submit():
            newAcc = Account(customerid=form.Cid.data,
                             accType=form.account.data,
                             amount=form.deposit.data)
            db.session.add(newAcc)
            db.session.commit()
            flash("Account creation successful and is to be verified",
                  category="success")
            return redirect(url_for('usermgmt.dashboard'))
        return render_template("accountCRUD.html",
                               form=form,
                               title="New Account",
                               type="read",
                               user=user[1].name,
                               userdesg=user[1].accType)
    else:
        flash(
            "You are not allowed to enter this view, contact your supervisor",
            "danger")
        return redirect(url_for("usermgmt.dashboard"))