Spaces:
Runtime error
Runtime error
Update transporter.py
Browse files- transporter.py +14 -2
transporter.py
CHANGED
|
@@ -22,6 +22,18 @@ def add_transporter(company_name, load_requirements, source, destination):
|
|
| 22 |
transporters_df.to_excel(file_path, sheet_name='Transporters', index=False)
|
| 23 |
return transporters_df
|
| 24 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 25 |
def transporter_ui():
|
| 26 |
with gr.Blocks() as transporter_block:
|
| 27 |
gr.Markdown("### Transporter Functions")
|
|
@@ -37,7 +49,7 @@ def transporter_ui():
|
|
| 37 |
load_requirements_update = gr.Textbox(label="Load Requirements")
|
| 38 |
update_btn = gr.Button("Update Load Requirements")
|
| 39 |
updated_data = gr.DataFrame()
|
| 40 |
-
update_btn.click(
|
| 41 |
|
| 42 |
gr.Markdown("### View Transporters Data")
|
| 43 |
view_data_btn = gr.Button("View Transporters Data")
|
|
@@ -46,5 +58,5 @@ def transporter_ui():
|
|
| 46 |
gr.Markdown("### Check Booking Status and Current Truck Location")
|
| 47 |
check_status_btn = gr.Button("Check Booking Status")
|
| 48 |
status_display = gr.Text()
|
| 49 |
-
check_status_btn.click(
|
| 50 |
return transporter_block
|
|
|
|
| 22 |
transporters_df.to_excel(file_path, sheet_name='Transporters', index=False)
|
| 23 |
return transporters_df
|
| 24 |
|
| 25 |
+
def update_transporter_status(transporter_id, load_requirements_update):
|
| 26 |
+
global transporters_df
|
| 27 |
+
transporters_df.loc[transporters_df['Transporter ID'] == transporter_id, 'Load Requirements'] = load_requirements_update
|
| 28 |
+
transporters_df.to_excel(file_path, sheet_name='Transporters', index=False)
|
| 29 |
+
return transporters_df
|
| 30 |
+
|
| 31 |
+
def check_booking_status(transporter_id):
|
| 32 |
+
global transporters_df
|
| 33 |
+
booking_status = transporters_df.loc[transporters_df['Transporter ID'] == transporter_id, 'Booking Status'].iloc[0]
|
| 34 |
+
current_location = transporters_df.loc[transporters_df['Transporter ID'] == transporter_id, 'Current Truck Location'].iloc[0]
|
| 35 |
+
return f"Booking Status: {booking_status}, Current Location: {current_location}"
|
| 36 |
+
|
| 37 |
def transporter_ui():
|
| 38 |
with gr.Blocks() as transporter_block:
|
| 39 |
gr.Markdown("### Transporter Functions")
|
|
|
|
| 49 |
load_requirements_update = gr.Textbox(label="Load Requirements")
|
| 50 |
update_btn = gr.Button("Update Load Requirements")
|
| 51 |
updated_data = gr.DataFrame()
|
| 52 |
+
update_btn.click(update_transporter_status, inputs=[transporter_id, load_requirements_update], outputs=updated_data)
|
| 53 |
|
| 54 |
gr.Markdown("### View Transporters Data")
|
| 55 |
view_data_btn = gr.Button("View Transporters Data")
|
|
|
|
| 58 |
gr.Markdown("### Check Booking Status and Current Truck Location")
|
| 59 |
check_status_btn = gr.Button("Check Booking Status")
|
| 60 |
status_display = gr.Text()
|
| 61 |
+
check_status_btn.click(check_booking_status, inputs=transporter_id, outputs=status_display)
|
| 62 |
return transporter_block
|