| from flask import Blueprint, render_template, request, session, jsonify |
| from salesforce import get_salesforce_connection |
|
|
| order_blueprint = Blueprint('order', __name__) |
|
|
| |
| sf = get_salesforce_connection() |
| @order_blueprint.route("/order", methods=["GET"]) |
| def order_summary(): |
| email = session.get('user_email') |
| if not email: |
| return redirect(url_for("login")) |
|
|
| try: |
| |
| result = sf.query(f""" |
| SELECT Id, Customer_Name__c, Customer_Email__c, Total_Amount__c, Order_Details__c, Order_Status__c, Discount__c, Total_Bill__c |
| FROM Order__c |
| WHERE Customer_Email__c = '{email}' |
| ORDER BY CreatedDate DESC |
| LIMIT 1 |
| """) |
| order = result.get("records", [])[0] if result.get("records") else None |
|
|
| if not order: |
| return render_template("order.html", order=None) |
|
|
| return render_template("order.html", order=order) |
| except Exception as e: |
| print(f"Error fetching order details: {str(e)}") |
| return render_template("order.html", order=None, error=str(e)) |