From 0aed0f29055469cc93581f978578ef399a8d354a Mon Sep 17 00:00:00 2001 From: yaso-meth Date: Fri, 16 Aug 2024 10:21:54 +0200 Subject: [PATCH] add copntact number to business --- .../patient_manager/lib/objects/business.dart | 3 +++ .../lib/pages/profileBusinessAdd.dart | 9 ++++++++ .../lib/pages/profileBusinessUpdate.dart | 11 ++++++++++ backend/routers/business.py | 22 ++++++++++++------- 4 files changed, 37 insertions(+), 8 deletions(-) diff --git a/Frontend/patient_manager/lib/objects/business.dart b/Frontend/patient_manager/lib/objects/business.dart index e901347d..93240eeb 100644 --- a/Frontend/patient_manager/lib/objects/business.dart +++ b/Frontend/patient_manager/lib/objects/business.dart @@ -6,6 +6,7 @@ class Business { final String registration_no; final String logo_name; final String logo_path; + final String contact_no; final String app_id; const Business( @@ -15,6 +16,7 @@ class Business { this.registration_no, this.logo_name, this.logo_path, + this.contact_no, this.app_id, ); @@ -26,6 +28,7 @@ class Business { json['registration_no'], json['logo_name'], json['logo_path'], + json['contact_no'], json['app_id'], ); } diff --git a/Frontend/patient_manager/lib/pages/profileBusinessAdd.dart b/Frontend/patient_manager/lib/pages/profileBusinessAdd.dart index c40c8766..197414f6 100644 --- a/Frontend/patient_manager/lib/pages/profileBusinessAdd.dart +++ b/Frontend/patient_manager/lib/pages/profileBusinessAdd.dart @@ -43,6 +43,7 @@ class _ProfileBusinessAddState extends State { final titleController = TextEditingController(); final signtureController = TextEditingController(); final accessController = TextEditingController(); + final contactController = TextEditingController(); late PlatformFile selectedLogo; late PlatformFile selectedSignature; @@ -113,6 +114,7 @@ class _ProfileBusinessAddState extends State { "logo_name": logonameController.text, "logo_path": "${widget.signedInUser.app_id}/business_files/${logonameController.text}", + "contact_no": contactController.text, }), ); if (response.statusCode == 201) { @@ -206,6 +208,13 @@ class _ProfileBusinessAddState extends State { editable: true, ), const SizedBox(height: 10.0), + MIHTextField( + controller: contactController, + hintText: "Contact Number", + editable: true, + required: true, + ), + const SizedBox(height: 10.0), MIHFileField( controller: logonameController, hintText: "Logo", diff --git a/Frontend/patient_manager/lib/pages/profileBusinessUpdate.dart b/Frontend/patient_manager/lib/pages/profileBusinessUpdate.dart index d79235e9..4a6df30b 100644 --- a/Frontend/patient_manager/lib/pages/profileBusinessUpdate.dart +++ b/Frontend/patient_manager/lib/pages/profileBusinessUpdate.dart @@ -45,6 +45,7 @@ class _ProfileBusinessUpdateState extends State { final titleController = TextEditingController(); final signtureController = TextEditingController(); final accessController = TextEditingController(); + final contactController = TextEditingController(); late PlatformFile? selectedLogo = null; late PlatformFile? selectedSignature = null; @@ -177,6 +178,7 @@ class _ProfileBusinessUpdateState extends State { "logo_name": logonameController.text, "logo_path": "${widget.arguments.signedInUser.app_id}/business_files/${logonameController.text}", + "contact_no": contactController.text, }), ); if (response.statusCode == 200) { @@ -228,6 +230,7 @@ class _ProfileBusinessUpdateState extends State { signtureController.text = widget.arguments.businessUser!.signature; titleController.text = widget.arguments.businessUser!.title; accessController.text = widget.arguments.businessUser!.access; + oldSigPath = widget.arguments.businessUser!.sig_path; //business = results; @@ -237,6 +240,7 @@ class _ProfileBusinessUpdateState extends State { typeController.text = widget.arguments.business!.type; logonameController.text = widget.arguments.business!.logo_name; oldLogoPath = widget.arguments.business!.logo_path; + contactController.text = widget.arguments.business!.contact_no; }); super.initState(); @@ -292,6 +296,13 @@ class _ProfileBusinessUpdateState extends State { editable: true, ), const SizedBox(height: 10.0), + MIHTextField( + controller: contactController, + hintText: "Contact Number", + editable: true, + required: true, + ), + const SizedBox(height: 10.0), MIHFileField( controller: logonameController, hintText: "Logo", diff --git a/backend/routers/business.py b/backend/routers/business.py index c4c3a27e..cc004fb2 100644 --- a/backend/routers/business.py +++ b/backend/routers/business.py @@ -22,6 +22,7 @@ class businessInsertRequest(BaseModel): registration_no: str logo_name: str logo_path: str + contact_no: str class businessUpdateRequest(BaseModel): business_id: str @@ -30,6 +31,7 @@ class businessUpdateRequest(BaseModel): registration_no: str logo_name: str logo_path: str + contact_no: str # Get List of all files @@ -37,7 +39,7 @@ class businessUpdateRequest(BaseModel): async def read_business_by_business_id(business_id: str, session: SessionContainer = Depends(verify_session())): #, session: SessionContainer = Depends(verify_session()) db = database.dbConnection.dbAppDataConnect() cursor = db.cursor() - query = "SELECT business.business_id, business.Name, business.type, business.registration_no, business.logo_name, business.logo_path, business_users.app_id " + query = "SELECT business.business_id, business.Name, business.type, business.registration_no, business.logo_name, business.logo_path, business.contact_no, business_users.app_id " query += "FROM business " query += "inner join business_users " query += "on business.business_id=business_users.business_id " @@ -54,7 +56,8 @@ async def read_business_by_business_id(business_id: str, session: SessionContain "registration_no": item[3], "logo_name": item[4], "logo_path": item[5], - "app_id": item[6], + "contact_no": item[6], + "app_id": item[7], } for item in cursor.fetchall() ] @@ -72,7 +75,7 @@ async def read_business_by_business_id(business_id: str, session: SessionContain async def read_business_by_app_id(app_id: str, session: SessionContainer = Depends(verify_session())): #, session: SessionContainer = Depends(verify_session()) db = database.dbConnection.dbAppDataConnect() cursor = db.cursor() - query = "SELECT business.business_id, business.Name, business.type, business.registration_no, business.logo_name, business.logo_path, business_users.app_id " + query = "SELECT business.business_id, business.Name, business.type, business.registration_no, business.logo_name, business.logo_path, business.contact_no, business_users.app_id " query += "FROM business " query += "inner join business_users " query += "on business.business_id=business_users.business_id " @@ -89,7 +92,8 @@ async def read_business_by_app_id(app_id: str, session: SessionContainer = Depen "registration_no": item[3], "logo_name": item[4], "logo_path": item[5], - "app_id": item[6], + "contact_no": item[6], + "app_id": item[7], } for item in cursor.fetchall() ] @@ -106,15 +110,16 @@ async def insert_business_details(itemRequest : businessInsertRequest, session: db = database.dbConnection.dbAppDataConnect() cursor = db.cursor() query = "insert into business " - query += "(business_id, Name, type, registration_no, logo_name, logo_path) " - query += "values (%s, %s, %s, %s, %s, %s)" + query += "(business_id, Name, type, registration_no, logo_name, logo_path, contact_no) " + query += "values (%s, %s, %s, %s, %s, %s, %s)" uuidString = str(uuid.uuid1()) userData = (uuidString, itemRequest.Name, itemRequest.type, itemRequest.registration_no, itemRequest.logo_name, - itemRequest.logo_path) + itemRequest.logo_path, + itemRequest.contact_no) try: cursor.execute(query, userData) except Exception as error: @@ -130,13 +135,14 @@ async def Update_Business_details(itemRequest : businessUpdateRequest, session: db = database.dbConnection.dbAppDataConnect() cursor = db.cursor() query = "update business " - query += "set Name=%s, type=%s, registration_no=%s, logo_name=%s, logo_path=%s " + query += "set Name=%s, type=%s, registration_no=%s, logo_name=%s, logo_path=%s, contact_no=%s " query += "where business_id=%s" userData = (itemRequest.Name, itemRequest.type, itemRequest.registration_no, itemRequest.logo_name, itemRequest.logo_path, + itemRequest.contact_no, itemRequest.business_id) try: cursor.execute(query, userData)