Tracking DOs and other stuff added
This commit is contained in:
parent
058b7f8233
commit
16e76a93de
24
.idea/workspace.xml
generated
24
.idea/workspace.xml
generated
@ -4,11 +4,12 @@
|
|||||||
<option name="autoReloadType" value="SELECTIVE" />
|
<option name="autoReloadType" value="SELECTIVE" />
|
||||||
</component>
|
</component>
|
||||||
<component name="ChangeListManager">
|
<component name="ChangeListManager">
|
||||||
<list default="true" id="5112d569-3a3f-4a44-9bd9-2c9295e7fe64" name="Changes" comment="Web front enabled basic flask setup">
|
<list default="true" id="5112d569-3a3f-4a44-9bd9-2c9295e7fe64" name="Changes" comment="Login and Dashboard added">
|
||||||
<change afterPath="$PROJECT_DIR$/app/templates/login.html" afterDir="false" />
|
<change afterPath="$PROJECT_DIR$/app/templates/do_entry.html" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/app/__init__.py" beforeDir="false" afterPath="$PROJECT_DIR$/app/__init__.py" afterDir="false" />
|
<change afterPath="$PROJECT_DIR$/app/templates/move_do.html" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/app/auth.py" beforeDir="false" afterPath="$PROJECT_DIR$/app/auth.py" afterDir="false" />
|
<change afterPath="$PROJECT_DIR$/app/templates/track_do.html" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/app/models.py" beforeDir="false" afterPath="$PROJECT_DIR$/app/models.py" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/app/routes.py" beforeDir="false" afterPath="$PROJECT_DIR$/app/routes.py" afterDir="false" />
|
||||||
</list>
|
</list>
|
||||||
<option name="SHOW_DIALOG" value="false" />
|
<option name="SHOW_DIALOG" value="false" />
|
||||||
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
||||||
@ -94,7 +95,15 @@
|
|||||||
<option name="project" value="LOCAL" />
|
<option name="project" value="LOCAL" />
|
||||||
<updated>1748943934876</updated>
|
<updated>1748943934876</updated>
|
||||||
</task>
|
</task>
|
||||||
<option name="localTasksCounter" value="5" />
|
<task id="LOCAL-00005" summary="Login and Dashboard added">
|
||||||
|
<option name="closed" value="true" />
|
||||||
|
<created>1748944937448</created>
|
||||||
|
<option name="number" value="00005" />
|
||||||
|
<option name="presentableId" value="LOCAL-00005" />
|
||||||
|
<option name="project" value="LOCAL" />
|
||||||
|
<updated>1748944937448</updated>
|
||||||
|
</task>
|
||||||
|
<option name="localTasksCounter" value="6" />
|
||||||
<servers />
|
<servers />
|
||||||
</component>
|
</component>
|
||||||
<component name="Vcs.Log.Tabs.Properties">
|
<component name="Vcs.Log.Tabs.Properties">
|
||||||
@ -138,6 +147,7 @@
|
|||||||
<component name="VcsManagerConfiguration">
|
<component name="VcsManagerConfiguration">
|
||||||
<MESSAGE value="First Commit" />
|
<MESSAGE value="First Commit" />
|
||||||
<MESSAGE value="Web front enabled basic flask setup" />
|
<MESSAGE value="Web front enabled basic flask setup" />
|
||||||
<option name="LAST_COMMIT_MESSAGE" value="Web front enabled basic flask setup" />
|
<MESSAGE value="Login and Dashboard added" />
|
||||||
|
<option name="LAST_COMMIT_MESSAGE" value="Login and Dashboard added" />
|
||||||
</component>
|
</component>
|
||||||
</project>
|
</project>
|
||||||
105
app/routes.py
105
app/routes.py
@ -29,3 +29,108 @@ def store_dashboard():
|
|||||||
<li><a href='/store/track'>Track DOs</a> (coming soon)</li>
|
<li><a href='/store/track'>Track DOs</a> (coming soon)</li>
|
||||||
</ul>
|
</ul>
|
||||||
"""
|
"""
|
||||||
|
from flask import request
|
||||||
|
from .models import DeliveryOrder, Store
|
||||||
|
from . import db
|
||||||
|
|
||||||
|
@main.route('/store/do-entry', methods=['GET', 'POST'])
|
||||||
|
def do_entry():
|
||||||
|
if 'store_id' not in session:
|
||||||
|
return redirect(url_for('auth.login'))
|
||||||
|
|
||||||
|
stores = Store.query.order_by(Store.name).all()
|
||||||
|
|
||||||
|
if request.method == 'POST':
|
||||||
|
do_number = request.form.get('do_number')
|
||||||
|
delivery_number = request.form.get('delivery_number')
|
||||||
|
final_location = int(request.form.get('final_location'))
|
||||||
|
created_by = session.get('store_name')
|
||||||
|
|
||||||
|
# Prevent duplicate DO numbers
|
||||||
|
existing = DeliveryOrder.query.filter_by(do_number=do_number).first()
|
||||||
|
if existing:
|
||||||
|
flash("DO already exists!", "danger")
|
||||||
|
return redirect(url_for('main.do_entry'))
|
||||||
|
|
||||||
|
new_do = DeliveryOrder(
|
||||||
|
do_number=do_number,
|
||||||
|
delivery_number=delivery_number,
|
||||||
|
final_location=final_location,
|
||||||
|
created_by=created_by,
|
||||||
|
status="Ready for Collection"
|
||||||
|
)
|
||||||
|
|
||||||
|
db.session.add(new_do)
|
||||||
|
db.session.commit()
|
||||||
|
flash("DO created successfully.", "success")
|
||||||
|
return redirect(url_for('main.store_dashboard'))
|
||||||
|
|
||||||
|
return render_template("do_entry.html", stores=stores)
|
||||||
|
@main.route('/store/track', methods=['GET', 'POST'])
|
||||||
|
def track_do():
|
||||||
|
if 'store_id' not in session:
|
||||||
|
return redirect(url_for('auth.login'))
|
||||||
|
|
||||||
|
do = None
|
||||||
|
movements = []
|
||||||
|
|
||||||
|
if request.method == 'POST':
|
||||||
|
search = request.form.get('search')
|
||||||
|
do = DeliveryOrder.query.filter(
|
||||||
|
(DeliveryOrder.do_number == search) |
|
||||||
|
(DeliveryOrder.delivery_number == search)
|
||||||
|
).first()
|
||||||
|
|
||||||
|
if do:
|
||||||
|
movements = do.movements
|
||||||
|
|
||||||
|
return render_template('track_do.html', do=do, movements=movements)
|
||||||
|
from datetime import datetime
|
||||||
|
from .models import Movement
|
||||||
|
|
||||||
|
@main.route('/store/move', methods=['GET', 'POST'])
|
||||||
|
def move_do():
|
||||||
|
if 'store_id' not in session:
|
||||||
|
return redirect(url_for('auth.login'))
|
||||||
|
|
||||||
|
message = None
|
||||||
|
if request.method == 'POST':
|
||||||
|
search = request.form.get('do_search')
|
||||||
|
do = DeliveryOrder.query.filter(
|
||||||
|
(DeliveryOrder.do_number == search) |
|
||||||
|
(DeliveryOrder.delivery_number == search)
|
||||||
|
).first()
|
||||||
|
|
||||||
|
if not do:
|
||||||
|
flash("DO not found", "danger")
|
||||||
|
return redirect(url_for('main.move_do'))
|
||||||
|
|
||||||
|
handled_by = request.form.get('handled_by')
|
||||||
|
comment = request.form.get('comment')
|
||||||
|
mark_departed = request.form.get('departed')
|
||||||
|
|
||||||
|
branch_id = session.get('store_id')
|
||||||
|
|
||||||
|
# Check if this store has already logged a movement
|
||||||
|
existing = Movement.query.filter_by(do_id=do.id, branch_id=branch_id).first()
|
||||||
|
|
||||||
|
if not existing:
|
||||||
|
# First time it arrived at this store
|
||||||
|
move = Movement(
|
||||||
|
do_id=do.id,
|
||||||
|
branch_id=branch_id,
|
||||||
|
handled_by=handled_by,
|
||||||
|
comment=comment
|
||||||
|
)
|
||||||
|
db.session.add(move)
|
||||||
|
else:
|
||||||
|
# Already exists → optionally mark departure
|
||||||
|
if mark_departed == "on" and not existing.departed_at:
|
||||||
|
existing.departed_at = datetime.utcnow()
|
||||||
|
existing.comment = (existing.comment or '') + f" | {comment}"
|
||||||
|
|
||||||
|
db.session.commit()
|
||||||
|
flash("Movement updated successfully.", "success")
|
||||||
|
return redirect(url_for('main.track_do'))
|
||||||
|
|
||||||
|
return render_template("move_do.html")
|
||||||
|
|||||||
34
app/templates/do_entry.html
Normal file
34
app/templates/do_entry.html
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<title>New DO Entry</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<h1>Enter a New Delivery Order</h1>
|
||||||
|
|
||||||
|
<form method="POST">
|
||||||
|
<label>DO Number:</label><br>
|
||||||
|
<input type="text" name="do_number" required><br>
|
||||||
|
|
||||||
|
<label>Delivery Number:</label><br>
|
||||||
|
<input type="text" name="delivery_number" required><br>
|
||||||
|
|
||||||
|
<label>Final Destination:</label><br>
|
||||||
|
<select name="final_location">
|
||||||
|
{% for store in stores %}
|
||||||
|
<option value="{{ store.id }}">{{ store.name }} ({{ store.id }})</option>
|
||||||
|
{% endfor %}
|
||||||
|
</select><br><br>
|
||||||
|
|
||||||
|
<button type="submit">Create DO</button>
|
||||||
|
</form>
|
||||||
|
|
||||||
|
<p><a href="/store">Back to Dashboard</a></p>
|
||||||
|
|
||||||
|
{% with messages = get_flashed_messages(with_categories=true) %}
|
||||||
|
{% for category, message in messages %}
|
||||||
|
<p style="color:red;">{{ message }}</p>
|
||||||
|
{% endfor %}
|
||||||
|
{% endwith %}
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
35
app/templates/move_do.html
Normal file
35
app/templates/move_do.html
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<title>Mark DO Movement</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<h1>Mark Arrival/Departure</h1>
|
||||||
|
|
||||||
|
<form method="POST">
|
||||||
|
<label>DO Number or Delivery Number:</label><br>
|
||||||
|
<input type="text" name="do_search" required><br>
|
||||||
|
|
||||||
|
<label>Your Name (who handled it):</label><br>
|
||||||
|
<input type="text" name="handled_by" required><br>
|
||||||
|
|
||||||
|
<label>Comment (optional):</label><br>
|
||||||
|
<input type="text" name="comment"><br>
|
||||||
|
|
||||||
|
<label>
|
||||||
|
<input type="checkbox" name="departed">
|
||||||
|
Mark as Departed
|
||||||
|
</label><br><br>
|
||||||
|
|
||||||
|
<button type="submit">Submit</button>
|
||||||
|
</form>
|
||||||
|
|
||||||
|
<p><a href="/store">Back to Dashboard</a></p>
|
||||||
|
|
||||||
|
{% with messages = get_flashed_messages(with_categories=true) %}
|
||||||
|
{% for category, message in messages %}
|
||||||
|
<p style="color:red;">{{ message }}</p>
|
||||||
|
{% endfor %}
|
||||||
|
{% endwith %}
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
41
app/templates/track_do.html
Normal file
41
app/templates/track_do.html
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<title>Track Delivery Order</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<h1>Track a Delivery Order</h1>
|
||||||
|
|
||||||
|
<form method="POST">
|
||||||
|
<label>Enter DO Number or Delivery Number:</label><br>
|
||||||
|
<input type="text" name="search" required>
|
||||||
|
<button type="submit">Search</button>
|
||||||
|
</form>
|
||||||
|
|
||||||
|
{% if do %}
|
||||||
|
<h2>DO: {{ do.do_number }} / {{ do.delivery_number }}</h2>
|
||||||
|
<p>Status: <strong>{{ do.status }}</strong></p>
|
||||||
|
<p>Created by: {{ do.created_by }}</p>
|
||||||
|
<p>Final Destination: {{ do.final_location }}</p>
|
||||||
|
<p>Collected By: {{ do.collected_by if do.collected_by else "Not collected yet" }}</p>
|
||||||
|
<p>Created: {{ do.created_at }}</p>
|
||||||
|
|
||||||
|
<h3>Movement History:</h3>
|
||||||
|
{% if movements %}
|
||||||
|
<ul>
|
||||||
|
{% for m in movements %}
|
||||||
|
<li>
|
||||||
|
📍 {{ m.branch_id }} | Handled by {{ m.handled_by }} | Arrived: {{ m.arrived_at }}
|
||||||
|
{% if m.departed_at %}| Departed: {{ m.departed_at }}{% endif %}
|
||||||
|
{% if m.comment %}<br>📝 {{ m.comment }}{% endif %}
|
||||||
|
</li>
|
||||||
|
{% endfor %}
|
||||||
|
</ul>
|
||||||
|
{% else %}
|
||||||
|
<p>No movement data yet.</p>
|
||||||
|
{% endif %}
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
<p><a href="/store">Back to Dashboard</a></p>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
Loading…
x
Reference in New Issue
Block a user