From d42fc35983a12375554b00c373ddd42ee984dbd3 Mon Sep 17 00:00:00 2001 From: Daniel Rahamim Date: Fri, 24 Feb 2023 22:15:38 -0800 Subject: [PATCH] feat: history buttons for assets and staff (#31) * feat: history buttons for assets and staff * style: formatting app.py --- src/invenflask/app.py | 23 ++++- src/invenflask/templates/single_history.html | 94 ++++++++++++++++++++ src/invenflask/templates/staff.html | 4 + src/invenflask/templates/status.html | 3 + 4 files changed, 123 insertions(+), 1 deletion(-) create mode 100644 src/invenflask/templates/single_history.html diff --git a/src/invenflask/app.py b/src/invenflask/app.py index ac0068d..bb5a068 100644 --- a/src/invenflask/app.py +++ b/src/invenflask/app.py @@ -346,7 +346,7 @@ def checkin(): ('Available', asset_id)) conn.commit() flash('Asset checkin Completed') - return redirect(url_for('checkout')) + return redirect(url_for('checkin')) except sqlite3.IntegrityError as e: flash(f"{e}") return redirect(url_for('checkin')) @@ -464,3 +464,24 @@ def parseCSV_staff( flash("Asset upload failed import") return redirect(url_for('create_asset')) return redirect(url_for('status')) + + +@app.route('/single_history//') +def single_history(rq_type, item_id): + + if rq_type == 'asset': + conn = get_db() + current = conn.execute( + 'select * from checkouts where assetid = ?', (item_id,)) + history = conn.execute( + 'select * from history where assetid = ?', (item_id,)) + conn.commit() + if rq_type == 'staff': + conn = get_db() + current = conn.execute( + 'select * from checkouts where staffid = ?', (item_id,)) + history = conn.execute( + 'select * from history where staffid = ?', (item_id,)) + conn.commit() + return render_template('single_history.html', hist_type=rq_type, + current=current, history=history) diff --git a/src/invenflask/templates/single_history.html b/src/invenflask/templates/single_history.html new file mode 100644 index 0000000..b60f373 --- /dev/null +++ b/src/invenflask/templates/single_history.html @@ -0,0 +1,94 @@ +{% extends 'base.html' %} + +{% block content %} +{% if hist_type == 'staff' %} +

Staff History

+ + + + + + + + + + {% for item in current %} + + + + + {% endfor %} + +
Asset IDTime Stamp
{{ item.assetid }}{{ item.timestamp }}
+ + + + + + + + + + + + {% for item in history %} + + + + + + {% endfor %} + +
Asset IDCheck OutCheck In
{{ item.assetid }}{{ item.checkouttime }}{{ item.returntime }}
+ +{% else %} + +

Asset History

+ + + + + + + + + + + {% for item in current %} + + + + + + {% endfor %} + +
Staff IDDepartmentTimestamp
{{ item.staffid }}{{ item.department }}{{ item.timestamp }}
+ + + + + + + + + + + + + + {% for item in history %} + + + + + + + + +
Staff IDDepartmentdivisionCheck OutCheck In
{{ item.staffid }}{{ item.department }}{{ item.division }}{{ item.checkouttime }}{{ item.returntime }}
+{% endfor %} + +{% endif %} +{{ data_var|safe }} + +{% endblock %} \ No newline at end of file diff --git a/src/invenflask/templates/staff.html b/src/invenflask/templates/staff.html index c9f9914..9b0a23e 100644 --- a/src/invenflask/templates/staff.html +++ b/src/invenflask/templates/staff.html @@ -10,6 +10,8 @@ Division Department Title + Edit + History @@ -23,6 +25,8 @@ {{ staff.title }} + + {% endfor %} diff --git a/src/invenflask/templates/status.html b/src/invenflask/templates/status.html index 0ec8371..3785844 100644 --- a/src/invenflask/templates/status.html +++ b/src/invenflask/templates/status.html @@ -8,6 +8,7 @@ Type Status Edit + History @@ -18,6 +19,8 @@ {{ asset.asset_status }} + + {% endfor %}