import 'dart:convert'; import 'dart:io'; import 'package:flutter/cupertino.dart'; import 'package:generp/Models/ViewVisitDetailsResponseNew.dart'; import 'package:generp/Models/commonModels/DistrictsResponse.dart'; import 'package:generp/Models/commonModels/SubLocationsResponse.dart'; import 'package:generp/Models/commonModels/commonAccessiblePagesResponse.dart'; import 'package:generp/Models/commonModels/commonAddAccountsViewResponse.dart'; import 'package:generp/Models/crmModels/AccessiblePagesResponse.dart'; import 'package:generp/Models/crmModels/GetDistrictOnStateResponse.dart'; import 'package:generp/Models/crmModels/GetSegmentOnTeamResponse.dart'; import 'package:generp/Models/crmModels/GetSourceOnReferenceResponse.dart'; import 'package:generp/Models/crmModels/GetSubLocOnDistrictResponse.dart'; import 'package:generp/Models/crmModels/LeadListContactPopUpResponse.dart'; import 'package:generp/Models/crmModels/LeadListViewResponse.dart'; import 'package:generp/Models/crmModels/ProspectListViewResponse.dart'; import 'package:generp/Models/crmModels/SubmitLeadListFilterResponse.dart'; import 'package:generp/Models/crmModels/crmDashboardQuotationResponse.dart'; import 'package:generp/Models/crmModels/crmDownloadGenQuoteResponse.dart'; import 'package:generp/Models/crmModels/crmLeadDetailsGenerateQuotationSubmitResponse.dart'; import 'package:generp/Models/crmModels/crmNewLeadsProspectsSubmitResponse.dart'; import 'package:generp/Models/crmModels/crmNewLeadsProspectsViewResponse.dart'; import 'package:generp/Models/crmModels/crmProspectDetailsAddFollowUpAppointmentResponse.dart'; import 'package:generp/Models/crmModels/crmProspectDetailsAddLeadsResponse.dart'; import 'package:generp/Models/crmModels/crmProspectDetailsResponse.dart'; import 'package:generp/Models/financeModels/addDirectPaymentResponse.dart'; import 'package:generp/Models/financeModels/paymentRequisitionPaymentsListResponse.dart'; import 'package:generp/Models/hrmModels/attendanceRequestListResponse.dart'; import 'package:generp/Models/hrmModels/jobDescriptionResponse.dart'; import 'package:generp/Models/hrmModels/leaveApplicationDetailsResponse.dart'; import 'package:generp/Models/hrmModels/leaveApplicationLIstResponse.dart'; import 'package:generp/Models/hrmModels/rewardListResponse.dart'; import 'package:generp/Models/hrmModels/tourExpensesAddViewResponse.dart'; import 'package:generp/Models/hrmModels/tourExpensesDetailsResponse.dart'; import 'package:generp/Models/hrmModels/tourExpensesListResponse.dart'; import 'package:generp/Models/ordersModels/PendingTPCAgentListResponse.dart'; import 'package:generp/Models/ordersModels/TPCAgentDetailsResponse.dart'; import 'package:generp/Models/ordersModels/TPCListResponse.dart'; import 'package:generp/Models/ordersModels/orderDashboardResponse.dart'; import 'package:generp/services/api_names.dart'; import 'package:generp/services/api_post_request.dart'; import 'package:http/http.dart' as http; import 'package:path_provider/path_provider.dart'; import '../Models/AccountSuggestionResponse.dart'; import '../Models/AddContactResponse.dart'; import '../Models/AttendanceListResponse.dart'; import '../Models/CheckInResponse.dart'; import '../Models/CheckOutResponse.dart'; import '../Models/ComplaintsSelectionResponse.dart'; import '../Models/DashboardResponse.dart'; import '../Models/DayWiseAttendance.dart'; import '../Models/FollowUpResponse.dart'; import '../Models/Inventory_Part_details_response.dart'; import '../Models/LoginQRResponse.dart'; import '../Models/LogoutResponse.dart'; import '../Models/NearbyGeneratorsResponse.dart'; import '../Models/PaymentCollectionResponse.dart'; import '../Models/PaymentCollectionValidateOTPResponse.dart'; import '../Models/PaymentCollectionWalletResponse.dart'; import '../Models/ProfileResponse.dart'; import '../Models/SessionResponse.dart'; import '../Models/StatusResponse.dart'; import '../Models/SubmitComplaintResponse.dart'; import '../Models/TagGeneratorResponse.dart'; import '../Models/TagLocationResponse.dart'; import '../Models/TechnicianAddPaymentCollectionResponse.dart'; import '../Models/TechnicianDashboardResponse.dart'; import '../Models/TechnicianLoadNumbersResponse.dart'; import '../Models/TechniciansPendingComplaintsResponse.dart'; import '../Models/TodayVisitResponse.dart'; import '../Models/UpdateComplaintResponse.dart'; import '../Models/UpdatePasswordResponse.dart'; import '../Models/VersionsResponse.dart'; import '../Models/ViewVisitDetailsResponse.dart'; import '../Models/commonModels/commonAddAccountsSubmitResponse.dart'; import '../Models/crmModels/appointmentCalendarResponse.dart'; import '../Models/crmModels/crmAddFollowUpResponse.dart'; import '../Models/crmModels/crmDashboardFollowUpResponse.dart'; import '../Models/crmModels/crmDashboardResponse.dart'; import '../Models/crmModels/crmPendingTasksResponse.dart'; import '../Models/crmModels/crmSelectedProductDetailsResponse.dart'; import '../Models/crmModels/crmUniversalSearchResponse.dart'; import '../Models/financeModels/paymentRequestionBankDetailsResponse.dart'; import '../Models/commonModels/commonAccountLedgerFilterResponse.dart'; import '../Models/commonModels/commonAccountLedgerResponse.dart'; import '../Models/commonModels/commonAccountdetailsResponse.dart'; import '../Models/commonModels/commonAccountlistResponse.dart'; import '../Models/crmModels/LeadDetailsResponse.dart'; import '../Models/crmModels/NearbyOpenLeadsResponse.dart'; import '../Models/crmModels/SubmitProspectListFilterResponse.dart'; import '../Models/crmModels/crmLeadDetailsEditAccountViewResponse.dart'; import '../Models/crmModels/crmLeadDetailsEditProductsViewResponse.dart'; import '../Models/crmModels/crmLeadDetailsGenerateQuotationViewResponse.dart'; import '../Models/crmModels/crmProspectDetailsEditAccountViewResponse.dart'; import '../Models/financeModels/addPaymentRequestionResponse.dart'; import '../Models/financeModels/addReceiptPaymentResponse.dart'; import '../Models/financeModels/paymentRequesitionListsResponse.dart'; import '../Models/financeModels/paymentRequisitionDetailsResponse.dart'; import '../Models/financeModels/paymentRequisitionPaymentsDetailsResponse.dart'; import '../Models/financeModels/paymentRequisitionPaymentsReceiptsDetailsResponse.dart'; import '../Models/financeModels/paymentRequisitionPaymentsReceiptsListResponse.dart'; import '../Models/generatorComplaintResponse.dart'; import '../Models/hrmModels/attendanceRequestDetailsResponse.dart'; import '../Models/hrmModels/hrmAccessiblePagesResponse.dart'; import '../Models/hrmmodels/ogresponse.dart'; import '../Models/loadGeneratorDetailsResponse.dart'; import '../Models/financeModels/financeDashboardPagesResponse.dart'; import '../Models/ordersModels/AddOrderPaymentSelectAccountResponse.dart'; import '../Models/ordersModels/AddOrderPaymentSelectOrderResponse.dart'; import '../Models/ordersModels/AddOrderViewResponse.dart'; import '../Models/ordersModels/EditPaymentDetailsAdjustedOrdersViewResponse.dart'; import '../Models/ordersModels/addOrderAccontDetailsResponse.dart'; import '../Models/ordersModels/addOrderPaymentViewResponse.dart'; import '../Models/ordersModels/addOrderTpcAgentListResponse.dart'; import '../Models/ordersModels/commonResponse.dart'; import '../Models/ordersModels/orderPendingTasksListResponse.dart'; import '../Models/ordersModels/ordersAccessiblePagesResponse.dart'; import '../Models/ordersModels/ordersDetailsByModeResponse.dart'; import '../Models/ordersModels/ordersDetailsDispatchOrderViewResponse.dart'; import '../Models/ordersModels/ordersDetailsEditOrderViewResponse.dart'; import '../Models/ordersModels/ordersListByModeFilterResponse.dart'; import '../Models/ordersModels/ordersListByModeResponse.dart'; import '../Models/ordersModels/ordersPdiIdByEngNumberResponse.dart'; import '../Models/ordersModels/paymentDetailsByModeFilterResponse.dart'; import '../Models/ordersModels/paymentListByModeFilterResponse.dart'; import '../Models/ordersModels/paymentListByModeResponse.dart'; import '../Models/ordersModels/technicianAddPaymentResendOTPResponse.dart'; import '../Notifiers/financeProvider/approveRejectPaymentRequestResponse.dart'; import '../Utils/commonServices.dart'; import 'package:http_parser/http_parser.dart'; class ApiCalling { static Future download_files(empId, session, url, cntxt) async { try { Map data = { 'emp_id': (empId).toString(), 'session_id': (session).toString(), }; final res = await post(data, url, {}); if (res != null) { final bytes = res.bodyBytes; var directory = ""; if (Platform.isAndroid) { directory = "/storage/emulated/0/Download"; var _directory = Directory(directory); if (!_directory.existsSync()) { // If the directory does not exist, create it _directory.createSync(recursive: true); debugPrint('Directory created: $_directory'); } else { debugPrint('Directory already exists: $_directory'); } // final androiddirectory = await getDownloadsDirectory(); // directory = androiddirectory!.path; } else if (Platform.isIOS) { final iosDirectory = await getApplicationSupportDirectory(); directory = iosDirectory!.path; } final contentDisposition = res.headers['content-disposition']; debugPrint( "contentDisposition ${contentDisposition?.split('filename=')[1]}", ); // final filename = contentDisposition != null // ? contentDisposition.split('filename=')[1] // : 'file'; var filename = (contentDisposition?.split('filename=')[1])?.replaceAll( '"', "", ); // ignore: unnecessary_brace_in_string_interps final file = File('${directory}/${filename}'); await file.writeAsBytes(bytes); toast( cntxt, "File saved to your downloads as ${filename} to ${directory}, Successfully", ); debugPrint('File saved successfully'); return jsonDecode(res.body); } else { debugPrint("Null Response"); return null; } } catch (e) { debugPrint('hello bev=bug $e '); return null; } } static Future checkAppVersionApi() async { try { final response = await post({}, getAppVersionUrl, {}); if (response != null) { print("${response.body}"); return VersionsResponse.fromJson(jsonDecode(response.body)); } else { return null; } } catch (e, s) { return null; } } static Future CheckSessionExistsApi(empId, session) async { try { Map data = { 'emp_id': (empId).toString(), 'session_id': (session).toString(), }; // print(data); final res = await post(data, getEmployeeSessionDetailsUrl, {}); if (res != null) { // print("check_session: ${res.body}"); return SessionResponse.fromJson(jsonDecode(res.body)); } else { debugPrint("Null Response"); return null; } } catch (e) { debugPrint('hello bev=bug $e '); return null; } } static Future LoginFunctionApi( email, password, token, deviceID, deviceInfo, ) async { try { Map data = { 'email_id': (email).toString(), 'password': (password).toString(), 'token_id': (token).toString(), 'device_id': (deviceID).toString(), 'device_details': (deviceInfo).toString(), }; final res = await post(data, loginUrl, {}); if (res != null) { // debugPrint("Login: ${res.body}"); // print(data); return StatusResponse.fromJson(jsonDecode(res.body)); } else { debugPrint("Null Response"); return null; } } catch (e) { debugPrint('hello bev=bug $e '); return null; } } static Future UpdatePasswordApi( empId, session, password, conf_password, ) async { try { Map data = { 'emp_id': (empId).toString(), 'session_id': (session).toString(), 'password': (password).toString(), 'confirm_password': (conf_password).toString(), }; final res = await post(data, updatePasswordUrl, {}); if (res != null) { debugPrint("update password ${res.body}"); debugPrint("update password ${data}"); return UpdatePasswordResponse.fromJson(jsonDecode(res.body)); } else { debugPrint("Null Response"); return null; } } catch (e) { debugPrint('hello bev=bug $e '); return null; } } static Future DashboardFunctionApi(empId, session) async { try { Map data = { 'emp_id': (empId).toString(), 'session_id': (session).toString(), }; final res = await post(data, employeeDashboardUrl, {}); if (res != null) { // debugPrint("Dashboard: ${res.body}"); return DashboardResponse.fromJson(jsonDecode(res.body)); } else { debugPrint("Null Response"); return null; } } catch (e) { debugPrint('hello bev=bug $e '); return null; } } static Future ProfileFunctionApi(empId, session) async { try { Map data = { 'emp_id': (empId).toString(), 'session_id': (session).toString(), }; final res = await post(data, employeeProfileUrl, {}); if (res != null) { // debugPrint("profile-details: ${res.body}"); return ProfileResponse.fromJson(jsonDecode(res.body)); } else { debugPrint("Null Response"); return null; } } catch (e) { debugPrint('hello bev=bug $e '); return null; } } static Future QRLoginRequestAPI( empId, session, type, token, ) async { try { Map data = { 'emp_id': (empId).toString(), 'session_id': (session).toString(), 'type': (type).toString(), 'token': (token).toString(), }; final res = await post(data, qrCodeLoginUrl, {}); if (res != null) { // debugPrint(res.body); return LoginQRResponse.fromJson(jsonDecode(res.body)); } else { debugPrint("Null Response"); return null; } } catch (e) { debugPrint('hello bev=bug $e '); return null; } } static Future LogoutFunctionApi(empId, session) async { try { Map data = { 'emp_id': (empId).toString(), 'session_id': (session).toString(), }; final res = await post(data, logoutAppUrl, {}); if (res != null) { // debugPrint(res.body); return LogoutResponse.fromJson(jsonDecode(res.body)); } else { debugPrint("Null Response"); return null; } } catch (e) { debugPrint('hello bev=bug $e '); return null; } } static Future CheckInApi( empId, sessioId, location, latlngs, check_in_pic, ) async { try { Map data = { 'emp_id': (empId).toString(), 'session_id': (sessioId).toString(), 'posit': (latlngs).toString(), 'location': (location).toString(), }; var res; // if (check_in_pic != null) { res = await postImage(data, employeeChekInUrl, {}, check_in_pic); res = jsonDecode(res); // } else { // // res = await post(data, employeeChekInUrl, {}); // // res = jsonDecode(res.body); // } if (res != null) { return CheckInResponse.fromJson(res); } else { debugPrint("Null Response"); return null; } } catch (e) { debugPrint('hello bev=bug $e '); return null; } } static Future CheckOutApi( empId, sessioId, location, latlngs, check_out_pic, ) async { try { Map data = { 'emp_id': (empId).toString(), 'session_id': (sessioId).toString(), 'location': (location).toString(), 'posit': (latlngs).toString(), }; var res; // if (image != null) { // res = await postImage2(data, {}, employeeCheckOutUrl, image); // res = jsonDecode(res); // } else { // res = await post(data, employeeCheckOutUrl, {}); // res = jsonDecode(res); // } // if (res != null) { // return CheckOutResponse.fromJson(res); // } else { // debugPrint("Null Response"); // return null; // } // if (check_out_pic != null) { res = await postImageNew( data, {}, employeeCheckOutUrl, check_out_pic, 'check_out_pic', ); if (res != null) { res = jsonDecode(res); } // } else { // res = await post(data, employeeCheckOutUrl, {}); // res = jsonDecode(res.body); // } return CheckOutResponse.fromJson(res); } catch (e) { debugPrint('hello bev=bug $e '); return null; } } static Future AttendanceListApi(empId, session) async { try { Map data = { 'emp_id': (empId).toString(), 'session_id': (session).toString(), }; final res = await post(data, employeeAttendanceDashboardUrl, {}); if (res != null) { // debugPrint(res.body); return AttendanceDashboard.fromJson(jsonDecode(res.body)); } else { debugPrint("Null Response"); return null; } } catch (e) { debugPrint('hello bev=bug $e '); return null; } } static LoadAttendanceDetails(empId, session, month, year) async { try { Map data = { 'emp_id': (empId).toString(), 'session_id': (session).toString(), 'year': (year).toString(), 'month': month.toString(), }; final res = await post(data, employeeMonthwiseAttendanceUrl, {}); if (res != null) { // debugPrint("montly attendance: ${res.body}"); // return AttendanceHistory.fromJson(jsonDecode(res.body)); return res.body; } else { debugPrint("Null Response"); return null; } } catch (e) { debugPrint('hello bev=bug $e '); return null; } } static Future DateWiseAttendanceApi( empId, session, date, ) async { try { Map data = { 'emp_id': (empId).toString(), 'session_id': (session).toString(), 'date': (date).toString(), }; final res = await post(data, employeeDayAttendanceDetailsUrl, {}); if (res != null) { // debugPrint("Attendacnce API /; ${res.body}"); return AttendanceDaywiseResponse.fromJson(jsonDecode(res.body)); } else { debugPrint("Null Response"); return null; } } catch (e) { debugPrint('hello bev=bug $e '); return null; } } ///gen tracker static Future LoadGeneratorDetailsAPI( empId, session, gen_hash_id, ) async { try { Map data = { 'emp_id': (empId).toString(), 'session_id': (session).toString(), 'gen_hash_id': (gen_hash_id).toString(), }; final res = await post(data, genTrackerGeneratorDetailsUrl, {}); if (res != null) { debugPrint("gen details222: ${jsonDecode(res.body)['complaint_list']}"); return loadGeneratorDetailsResponse.fromJson(jsonDecode(res.body)); } else { debugPrint("Null Response"); return null; } } catch (e) { debugPrint('hello bev=bug $e '); return null; } } static Future LoadGeneratorComplaintListAPI( empId, session, gen_id, open_status, ) async { try { Map data = { 'emp_id': (empId).toString(), 'session_id': (session).toString(), 'gen_id': (gen_id).toString(), 'open_status': (open_status).toString(), }; final res = await post(data, genTrackerGeneratorComplaintsUrl, {}); if (res != null) { // debugPrint(res.body); return generatorComplaintResponse.fromJson(jsonDecode(res.body)); } else { debugPrint("Null Response"); return null; } } catch (e) { debugPrint('hello bev=bug $e '); return null; } } static Future TagLocationAPI( empId, session, gen_hash_id, location, attachment, ) async { try { Map data = { 'emp_id': (empId).toString(), 'session_id': (session).toString(), 'gen_hash_id': (gen_hash_id).toString(), 'location': (location).toString(), }; print("Tag Loation: ${data}"); var res; if (attachment != null) { res = await postImageNew( data, {}, genTrackerTagLocationUrl, attachment, "attachment", ); res = jsonDecode(res); return TagLocationResponse.fromJson(res); } else { res = await post(data, genTrackerTagLocationUrl, {}); if (res != null) { // debugPrint(res.body); return TagLocationResponse.fromJson(jsonDecode(res.body)); } else { debugPrint("Null Response"); return null; } } } catch (e) { debugPrint('hello bev=bug $e '); return null; } } static Future TagGeneratorAPI( empId, session, gen_hash_id, engine_no, ) async { try { Map data = { 'emp_id': (empId).toString(), 'session_id': (session).toString(), 'gen_hash_id': (gen_hash_id).toString(), 'engine_no': (engine_no).toString(), }; final res = await post(data, genTrackerTagGeneratorUrl, {}); if (res != null) { // debugPrint(res.body); return TagGeneratorResponse.fromJson(jsonDecode(res.body)); } else { debugPrint("Null Response"); return null; } } catch (e) { debugPrint('hello bev=bug $e '); return null; } } static Future TagGeneratorCheckAPI( empId, session, gen_hash_id, ) async { try { Map data = { 'emp_id': (empId).toString(), 'session_id': (session).toString(), 'gen_hash_id': (gen_hash_id).toString(), }; final res = await post(data, genTrackerCheckTagGeneratorUrl, {}); if (res != null) { // debugPrint(res.body); return TagGeneratorResponse.fromJson(jsonDecode(res.body)); } else { debugPrint("Null Response"); return null; } } catch (e) { debugPrint('hello bev=bug $e '); return null; } } static Future SubmitGeneratorComplaintAPI( empId, session, complaint_type_id, complaint_category_id, complaint_desc_id, running_hrs, gen_id, complaint_note, ) async { try { Map data = { 'emp_id': (empId).toString(), 'session_id': (session).toString(), 'complaint_type_id': (complaint_type_id).toString(), 'complaint_category_id': (complaint_category_id).toString(), 'complaint_desc_id': (complaint_desc_id).toString(), 'running_hrs': (running_hrs).toString(), 'gen_id': (gen_id).toString(), 'complaint_note': (complaint_note).toString(), }; final res = await post(data, genTrackerRegisterComplaint, {}); if (res != null) { // debugPrint(res.body); return SubmitComplaintResponse.fromJson(jsonDecode(res.body)); } else { debugPrint("Null Response"); return null; } } catch (e) { debugPrint('hello bev=bug $e '); return null; } } static Future ComplaintSelectionAPI( empId, session, gen_hash_id, ) async { try { Map data = { 'emp_id': (empId).toString(), 'session_id': (session).toString(), 'gen_hash_id': (gen_hash_id).toString(), }; final res = await post(data, complaintsSelectionUrl, {}); if (res != null) { // debugPrint(res.body); return ComplaintsSelectionResponse.fromJson(jsonDecode(res.body)); } else { debugPrint("Null Response"); return null; } } catch (e) { debugPrint('hello bev=bug $e '); return null; } } ///Inventory Module API's static Future LoadPartDetailsAPI( empId, session, part_id, ) async { try { Map data = { 'emp_id': (empId).toString(), 'session_id': (session).toString(), 'part_id': (part_id).toString(), }; final res = await post(data, inventoryPartDetailsUrl, {}); if (res != null) { debugPrint(res.body); return Inventory_Part_details_response.fromJson(jsonDecode(res.body)); } else { debugPrint("Null Response"); return null; } } catch (e) { debugPrint('hello bev=bug $e '); return null; } } static Future InventoryUpdateStockAPI( empId, session, qty, descr, part_id, tran_type, ) async { try { Map data = { 'emp_id': (empId).toString(), 'session_id': (session).toString(), 'qty': (qty).toString(), 'descr': (descr).toString(), 'product_id': (part_id).toString(), 'tran_type': (tran_type).toString(), }; final res = await post(data, inventoryStockUpdateUrl, {}); if (res != null) { print("Issue Receive $data"); debugPrint(res.body); return loadGeneratorDetailsResponse.fromJson(jsonDecode(res.body)); } else { debugPrint("Null Response"); return null; } } catch (e) { debugPrint('hello bev=bug $e '); return null; } } ///technician static Future LoadTechnicianGeneratorDetailsAPI(empId, session, gen_id) async { try { Map data = { 'emp_id': (empId).toString(), 'session_id': (session).toString(), 'gen_id': (gen_id).toString(), }; final res = await post(data, technicianGeneratorDetailsUrl, {}); if (res != null) { print("genderrails:${jsonDecode(res!.body)}"); return loadGeneratorDetailsResponse.fromJson(jsonDecode(res.body)); } else { debugPrint("Null Response"); return null; } } catch (e) { debugPrint('hello bev=bug $e '); return null; } } static Future loadTechnicianDashboardApi( empId, session, ) async { try { Map data = { 'emp_id': (empId).toString(), 'session_id': (session).toString(), }; final res = await post(data, technicianDashboardUrl, {}); if (res != null) { // debugPrint(res.body); return TechnicianResponse.fromJson(jsonDecode(res.body)); } else { debugPrint("Null Response"); return null; } } catch (e) { debugPrint('hello bev=bug $e '); return null; } } static Future getTodayVisitsListAPI( empId, session, ) async { try { Map data = { 'emp_id': (empId).toString(), 'session_id': (session).toString(), }; final res = await post(data, technicianTodayVisitsUrl, {}); if (res != null) { debugPrint(res.body); return TodayVisitResponse.fromJson(jsonDecode(res.body)); } else { debugPrint("Null Response"); return null; } } catch (e) { debugPrint('hello bev=bug $e '); return null; } } static Future getMonthVisitsListAPI( empId, session, ) async { try { Map data = { 'emp_id': (empId).toString(), 'session_id': (session).toString(), }; final res = await post(data, technicianMonthlyVisitsUrl, {}); if (res != null) { debugPrint(res.body); return TodayVisitResponse.fromJson(jsonDecode(res.body)); } else { debugPrint("Null Response"); return null; } } catch (e) { debugPrint('hello bev=bug $e '); return null; } } static Future loadNearbyGeneratorsAPI( empId, session, tech_loc, radius, status, ) async { try { Map data = { 'emp_id': (empId).toString(), 'session_id': (session).toString(), 'tech_loc': (tech_loc).toString(), 'radius': (radius).toString(), 'status': (status).toString(), }; final res = await post(data, technicianNearbyGeneratorsUrl, {}); if (res != null) { // print(data); // debugPrint(res.body); return NearbyGeneratorsResponse.fromJson(jsonDecode(res.body)); } else { debugPrint("Null Response"); return null; } } catch (e) { debugPrint('hello bev=bug $e '); return null; } } static Future AccountSuggestionAPI( empId, session, search_string, ) async { try { Map data = { 'emp_id': (empId).toString(), 'session_id': (session).toString(), 'search_string': (search_string).toString(), }; final res = await post(data, technicianAccountSearchUrl, {}); if (res != null) { // debugPrint(res.body); return AccountSuggestionResonse.fromJson(jsonDecode(res.body)); } else { debugPrint("Null Response"); return null; } } catch (e) { debugPrint('hello bev=bug $e '); return null; } } static Future LoadTechnicianComplaintsAPI(empId, session) async { try { Map data = { 'emp_id': (empId).toString(), 'session_id': (session).toString(), }; final res = await post(data, technicianPendingComplaintUrl, {}); if (res != null) { // debugPrint(res.body); return TechnicianPendingComplaintsResponse.fromJson( jsonDecode(res.body), ); } else { debugPrint("Null Response"); return null; } } catch (e) { debugPrint('hello bev=bug $e '); return null; } } static Future LoadContactsTechnicianAPI( empId, session, type, gen_id, account_id, ) async { try { Map data = { 'emp_id': (empId).toString(), 'session_id': (session).toString(), 'type': (type).toString(), 'gen_id': (gen_id).toString(), 'account_id': (account_id).toString(), }; print(data); final res = await post(data, technicianAddPaymentUrl, {}); if (res != null) { // debugPrint(res.body); return TechnicianLoadNumbersResponse.fromJson(jsonDecode(res.body)); } else { debugPrint("Null Response"); return null; } } catch (e) { debugPrint('hello bev=bug $e '); return null; } } static Future TechnicianUpdatepaymentAPI( empId, session, ref_type, ref_id, payment_mode_id, payment_ref_no, amount, otp_validated_name, otp_validated_mobile_number, payment_proof, ) async { try { Map data = { 'emp_id': (empId).toString(), 'session_id': (session).toString(), 'ref_type': (ref_type).toString(), 'ref_id': (ref_id).toString(), 'payment_mode_id': (payment_mode_id).toString(), 'payment_ref_no': (payment_ref_no).toString(), 'amount': (amount).toString(), 'otp_validated_name': (otp_validated_name).toString(), 'otp_validated_mobile_number': (otp_validated_mobile_number).toString(), }; var res; // if (payment_proof != null) { // res = await postImage3( // data, // {}, // technicianAddPaymentCollectionUrl, // payment_proof, // ); // res = jsonDecode(res); // } else { // res = await post(data, technicianAddPaymentCollectionUrl, {}); // res = jsonDecode(res); // } // if (res != null) { // return TechnicianAddPaymentCollectionResponse.fromJson(res); // } else { // debugPrint("Null Response"); // return null; // } print("send otp:${data}"); if (payment_proof != null) { res = await postImageNew( data, {}, technicianAddPaymentCollectionUrl, payment_proof, 'payment_proof', ); print("Add Payment $res"); res = jsonDecode(res); } else { print("Add Payment $res"); res = await post(data, technicianAddPaymentCollectionUrl, {}); res = jsonDecode(res.body); // return TechnicianAddPaymentCollectionResponse.fromJson(res); } return TechnicianAddPaymentCollectionResponse.fromJson(res); } catch (e) { debugPrint('hello bev=bug $e '); return null; } } static Future TechnicianPaymentOTPValidateAPI( empId, session, payment_collection_id, otp, ) async { try { Map data = { 'emp_id': (empId).toString(), 'session_id': (session).toString(), 'payment_collection_id': (payment_collection_id).toString(), 'otp': (otp).toString(), }; final res = await post(data, technicianPaymentCollectionOtpUrl, {}); if (res != null) { debugPrint("OTP${res.body}"); return PaymentCollectionValidateOTPResponse.fromJson( jsonDecode(res.body), ); } else { debugPrint("Null Response"); return null; } } catch (e) { debugPrint('hello bev=bug $e '); return null; } } static Future TechnicianPaymentOTPResendAPI(empId, session, payment_collection_id) async { try { Map data = { 'emp_id': (empId).toString(), 'session_id': (session).toString(), 'payment_collection_id': (payment_collection_id).toString(), }; final res = await post(data, technicianAddPaymentResendOTPUrl, {}); if (res != null) { debugPrint("OTP${res.body}"); return Technicianaddpaymentresendotpresponse.fromJson( jsonDecode(res.body), ); } else { debugPrint("Null Response"); return null; } } catch (e) { debugPrint('hello bev=bug $e '); return null; } } static Future paymentCollectionListAPI( empId, session, ) async { try { Map data = { 'emp_id': (empId).toString(), 'session_id': (session).toString(), }; final res = await post(data, technicianPaymentCollectionUrl, {}); if (res != null) { // debugPrint(res.body); return PaymentCollectionResponse.fromJson(jsonDecode(res.body)); } else { debugPrint("Null Response"); return null; } } catch (e) { debugPrint('hello bev=bug $e '); return null; } } static Future loadTransactionsListAPI( empId, session, ) async { try { Map data = { 'emp_id': (empId).toString(), 'session_id': (session).toString(), }; final res = await post(data, technicianWalletCollectionUrl, {}); if (res != null) { // debugPrint(res.body); return PaymentCollectionWalletResponse.fromJson(jsonDecode(res.body)); } else { debugPrint("Null Response"); return null; } } catch (e) { debugPrint('hello bev=bug $e '); return null; } } static Future loadVisitDetailsAPI( empId, session, comp_id, ) async { try { Map data = { 'emp_id': (empId).toString(), 'session_id': (session).toString(), 'comp_id': (comp_id).toString(), }; final res = await post(data, technicianComplaintDetailsUrl, {}); if (res != null) { debugPrint(res.body); return ViewVisitDetailsResponseNew.fromJson(jsonDecode(res.body)); } else { debugPrint("Null Response"); return null; } } catch (e) { debugPrint('hello bev=bug $e '); return null; } } static Future loadFollowupListAPI( empId, session, comp_id, ) async { try { Map data = { 'emp_id': (empId).toString(), 'session_id': (session).toString(), 'comp_id': (comp_id).toString(), }; final res = await post(data, technicianComplaintFollowUpUrl, {}); if (res != null) { debugPrint(res.body); return FollowupListResponse.fromJson(jsonDecode(res.body)); } else { debugPrint("Null Response"); return null; } } catch (e) { debugPrint('hello bev=bug $e '); return null; } } static Future AddContactAPI( empId, session, gen_id, name, designation, mob1, mob2, tel, mail, type, account_id, ) async { try { Map data = { 'emp_id': (empId).toString(), 'session_id': (session).toString(), 'gen_id': (gen_id).toString(), 'name': (name).toString(), 'designation': (designation).toString(), 'mob1': (mob1).toString(), 'mob2': (mob2).toString(), 'tel': (tel).toString(), 'mail': (mail).toString(), 'type': (type).toString(), 'account_id': (account_id).toString(), }; print("add: $data"); final res = await post(data, technicianAddContactUrl, {}); if (res != null) { debugPrint(res.body); return AddContactResponse.fromJson(jsonDecode(res.body)); } else { debugPrint("Null Response"); return null; } } catch (e) { debugPrint('hello bev=bug $e '); return null; } } static Future UpdateComplaintAPI( empId, session, complaint_id, in_time, feedback, fsr_no, running_hrs, complaint_status, fsr_file, ) async { try { Map data = { 'emp_id': (empId).toString(), 'session_id': (session).toString(), 'complaint_id': (complaint_id).toString(), 'in_time': (in_time).toString(), 'feedback': (feedback).toString(), 'fsr_no': (fsr_no).toString(), 'running_hrs': (running_hrs).toString(), 'complaint_status': (complaint_status).toString(), }; // print(data); // print(fsr_file); var res; if (fsr_file != null) { res = await postImageNew( data, {}, technicianUpdateVisitUrl, fsr_file, 'fsr_file', ); res = jsonDecode(res); return UpdateComplaintResponse.fromJson(res); } else { res = await post(data, technicianUpdateVisitUrl, {}); res = jsonDecode(res.body); return UpdateComplaintResponse.fromJson(res); } // debugPrint(res); if (res != null) { // debugPrint(res); return UpdateComplaintResponse.fromJson(res); } else { debugPrint("Null Response"); return null; } } catch (e) { debugPrint('hello bev=bug $e '); return null; } } ///finance Module static Future financeDashboardPagesAPI( empId, session, ) async { try { Map data = { 'emp_id': (empId).toString(), 'session_id': (session).toString(), }; final res = await post(data, financeDashboardPagesUrl, {}); if (res != null) { debugPrint(res.body); return financeDashboardPagesResponse.fromJson(jsonDecode(res.body)); } else { debugPrint("Null Response"); return null; } } catch (e) { debugPrint('hello bev=bug $e '); return null; } } static Future addFormfinanceFormAccessPagesAPI(empId, session) async { try { Map data = { 'emp_id': (empId).toString(), 'session_id': (session).toString(), }; final res = await post(data, financeAddFormPagesAccessUrl, {}); if (res != null) { debugPrint("adjf:${res.body}"); return financeDashboardPagesResponse.fromJson(jsonDecode(res.body)); } else { debugPrint("Null Response"); return null; } } catch (e) { debugPrint('hello bev=bug $e '); return null; } } static Future addPaymentRequestionViewAPI( empId, session, mode, ) async { try { Map data = { 'emp_id': (empId).toString(), 'session_id': (session).toString(), 'mode': (mode).toString(), }; final res = await post(data, addPaymentRequestionViewUrl, {}); if (res != null) { // print("add view:${data}"); // debugPrint(res.body); return addPaymentRequestionResponse.fromJson(jsonDecode(res.body)); } else { debugPrint("Null Response"); return null; } } catch (e) { debugPrint('hello bev=bug $e '); return null; } } static Future addDirectPaymentRequestionViewAPI( empId, session, ) async { try { Map data = { 'emp_id': (empId).toString(), 'session_id': (session).toString(), }; final res = await post(data, addDirectPaymentRequestionViewUrl, {}); if (res != null) { debugPrint(res.body); return addDirectPaymentResponse.fromJson(jsonDecode(res.body)); } else { debugPrint("Null Response"); return null; } } catch (e) { debugPrint('hello bev=bug $e '); return null; } } static Future addReceiptPaymentRequestionViewAPI( empId, session, ) async { try { Map data = { 'emp_id': (empId).toString(), 'session_id': (session).toString(), }; final res = await post(data, addPaymentReceiptViewUrl, {}); if (res != null) { debugPrint(res.body); return addReceiptPaymentResponse.fromJson(jsonDecode(res.body)); } else { debugPrint("Null Response"); return null; } } catch (e) { debugPrint('hello bev=bug $e '); return null; } } static Future addPaymentRequestionSubmitAPI( emp_id, session_id, type, account_id, requesting_purpose, description, amount, payment_mode_id, bank_name, bank_branch_name, bank_acc_number, bank_ifsc_code, acc_holder_name, bank_upi_id, approval_assignee_emp_id, attachment, ) async { try { Map data = { 'emp_id': emp_id.toString(), 'session_id': session_id.toString(), 'type': type.toString(), 'account_id': account_id.toString(), 'requesting_purpose': requesting_purpose.toString(), 'description': description.toString(), 'amount': amount.toString(), 'payment_mode_id': payment_mode_id.toString(), 'bank_name': bank_name.toString(), 'bank_branch_name': bank_branch_name.toString(), 'bank_acc_number': bank_acc_number.toString(), 'bank_ifsc_code': bank_ifsc_code.toString(), 'acc_holder_name': acc_holder_name.toString(), 'bank_upi_id': bank_upi_id.toString(), 'approval_assignee_emp_id': approval_assignee_emp_id.toString(), }; var res; print(data); if (attachment != null) { res = await postImageNew( data, {}, addPaymentRequestionSubmitUrl, attachment, "attachment", ); res = jsonDecode(res); return CommonResponse.fromJson(res); } else { res = await post(data, addPaymentRequestionSubmitUrl, {}); res = jsonDecode(res.body); return CommonResponse.fromJson(res); } } catch (e) { debugPrint('hello bev=bug $e '); return null; } } static Future addDirectPaymentRequestionSubmitAPI( emp_id, session_id, from_account_id, to_account_id, description, payment_mode_id, amount, payment_date, payment_reference_number, bank_name, bank_branch_name, bank_acc_number, bank_ifsc_code, acc_holder_name, bank_upi_id, attachment, ) async { try { Map data = { 'emp_id': emp_id.toString(), 'session_id': session_id.toString(), 'from_account_id': from_account_id.toString(), 'to_account_id': to_account_id.toString(), 'description': description.toString(), 'payment_mode_id': payment_mode_id.toString(), 'amount': amount.toString(), 'payment_date': payment_date.toString(), 'payment_reference_number': payment_reference_number.toString(), 'bank_name': bank_name.toString(), 'bank_branch_name': bank_branch_name.toString(), 'bank_acc_number': bank_acc_number.toString(), 'bank_ifsc_code': bank_ifsc_code.toString(), 'acc_holder_name': acc_holder_name.toString(), 'bank_upi_id': bank_upi_id.toString(), }; print(data); print(attachment); var res; if (attachment != null) { res = await postImageNew( data, {}, addDirectPaymentRequestionSubmitUrl, attachment, "attachment", ); res = jsonDecode(res); return addDirectPaymentResponse.fromJson(res); } else { res = await post(data, addDirectPaymentRequestionSubmitUrl, {}); res = jsonDecode(res.body); print(res); return addDirectPaymentResponse.fromJson(res); } if (res != null) { return res; } else { debugPrint("Null Response"); return null; } } catch (e) { debugPrint('hello bev=bug $e '); return null; } } static Future addReceiptPaymentRequestionSubmitAPI( emp_id, session_id, from_account_id, to_account_id, description, payment_mode_id, amount, receipt_date, payment_reference_number, bank_name, bank_branch_name, bank_acc_number, bank_ifsc_code, acc_holder_name, bank_upi_id, attachment, ) async { try { Map data = { 'emp_id': emp_id.toString(), 'session_id': session_id.toString(), 'from_account_id': from_account_id.toString(), 'to_account_id': to_account_id.toString(), 'description': description.toString(), 'payment_mode_id': payment_mode_id.toString(), 'amount': amount.toString(), 'receipt_date': receipt_date.toString(), 'payment_reference_number': payment_reference_number.toString(), 'bank_name': bank_name.toString(), 'bank_branch_name': bank_branch_name.toString(), 'bank_acc_number': bank_acc_number.toString(), 'bank_ifsc_code': bank_ifsc_code.toString(), 'acc_holder_name': acc_holder_name.toString(), 'bank_upi_id': bank_upi_id.toString(), }; var res; if (attachment != null) { res = await postImageNew( data, {}, addPaymentReceiptSubmitUrl, attachment, "attachment", ); res = jsonDecode(res); } else { res = await post(data, addPaymentReceiptSubmitUrl, {}); res = jsonDecode(res.body); // return addReceiptPaymentResponse.fromJson(res); } return addReceiptPaymentResponse.fromJson(res); } catch (e) { debugPrint('hello bev=bug $e '); return null; } } static Future paymentRequestionListsAPI( empId, session, mode, from_date, to_date, ) async { try { Map data = { 'emp_id': (empId).toString(), 'session_id': (session).toString(), 'mode': (mode).toString(), 'from': from_date.toString(), 'to': to_date.toString(), }; print(data); final res = await post(data, paymentRequestionListUrl, {}); if (res != null) { debugPrint(res.body); return paymentRequesitionListsResponse.fromJson(jsonDecode(res.body)); } else { debugPrint("Null Response"); return null; } } catch (e) { debugPrint('hello bev=bug $e '); return null; } } static Future paymentRequestionDetailsAPI( empId, session, payment_request_id, ) async { try { Map data = { 'emp_id': (empId).toString(), 'session_id': (session).toString(), 'payment_request_id': (payment_request_id).toString(), }; final res = await post(data, paymentRequestionDetailsUrl, {}); if (res != null) { debugPrint(res.body); return paymentRequisitionDetailsResponse.fromJson(jsonDecode(res.body)); } else { debugPrint("Null Response"); return null; } } catch (e) { debugPrint('hello bev=bug $e '); return null; } } static Future paymentRequestionBankDetailsAPI(empId, session, account_id) async { try { Map data = { 'emp_id': (empId).toString(), 'session_id': (session).toString(), 'account_id': (account_id).toString(), }; final res = await post(data, paymentRequestBankDetailsUrl, {}); if (res != null) { print("Bank Detaols ${data}"); debugPrint(res.body); return paymentRequestionBankDetailsResponse.fromJson( jsonDecode(res.body), ); } else { debugPrint("Null Response"); return null; } } catch (e) { debugPrint('hello bev=bug $e '); return null; } } static Future approveRejectPaymentRequestAPI(empId, session, payment_request_id) async { try { Map data = { 'emp_id': (empId).toString(), 'session_id': (session).toString(), 'payment_request_id': (payment_request_id).toString(), }; final res = await post(data, approveRejectPaymentRequestUrl, {}); if (res != null) { print("add payment:${data}"); debugPrint(res.body); return approveRejectPaymentRequestResponse.fromJson( jsonDecode(res.body), ); } else { debugPrint("Null Response"); return null; } } catch (e) { debugPrint('hello bev=bug $e '); return null; } } static Future RejectPaymentRequestSubmitAPI( empId, session, mode, payment_request_id, approve_remarks, ) async { try { Map data = { 'emp_id': (empId).toString(), 'session_id': (session).toString(), 'type': 'reject', 'mode': mode.toString(), 'payment_request_id': (payment_request_id).toString(), 'approve_remarks': approve_remarks, }; final res = await post(data, approveRejectPaymentRequestSubmitUrl, {}); if (res != null) { print(data); debugPrint(res.body); return approveRejectPaymentRequestResponse.fromJson( jsonDecode(res.body), ); } else { debugPrint("Null Response"); return null; } } catch (e) { debugPrint('hello bev=bug $e '); return null; } } static Future ApprovePaymentRequestSubmitAPI( empId, session, mode, payment_request_id, approved_amount, approve_remarks, proposed_payment_account_id, ) async { try { Map data = { 'emp_id': (empId).toString(), 'session_id': (session).toString(), 'type': 'approve', 'mode': mode.toString(), 'payment_request_id': (payment_request_id).toString(), 'approve_remarks': approve_remarks, 'approved_amount': approved_amount, 'proposed_payment_account_id': proposed_payment_account_id, }; // print(data); final res = await post(data, approveRejectPaymentRequestSubmitUrl, {}); if (res != null) { print(data); debugPrint(res.body); return approveRejectPaymentRequestResponse.fromJson( jsonDecode(res.body), ); } else { debugPrint("Null Response"); return null; } } catch (e) { debugPrint('hello bev=bug $e '); return null; } } static Future processApproveRejectPaymentRequestSubmitAPI( empId, session, mode, payment_reference_number, payment_amount, payment_request_id, payment_account_id, processing_remarks, attachment, ) async { try { Map data = { 'emp_id': (empId).toString(), 'session_id': (session).toString(), 'type': 'approve'.toString(), 'mode': mode.toString(), 'payment_reference_number': payment_reference_number.toString(), 'payment_amount': payment_amount.toString(), 'payment_request_id': (payment_request_id).toString(), 'payment_account_id': payment_account_id.toString(), 'processing_remarks': processing_remarks.toString(), }; var res; print("Process:${data}"); if (attachment != null) { res = await postImageNew( data, {}, approveRejectPaymentRequestSubmitUrl, attachment, "attachment", ); print("Process:${data}"); res = jsonDecode(res); print(data); return CommonResponse.fromJson(res); } else { res = await post(data, approveRejectPaymentRequestSubmitUrl, {}); res = jsonDecode(res.body); return CommonResponse.fromJson(res); } } catch (e) { debugPrint('hello bev=bug $e '); return null; } } static Future paymentRequisitionPaymentListAPI(empId, session, from, to) async { try { Map data = { 'emp_id': (empId).toString(), 'session_id': (session).toString(), 'from': (from).toString(), 'to': (to).toString(), }; final res = await post(data, paymentRequesitionPaymentsListUrl, {}); if (res != null) { print(data); print("payment req:${res.body}"); return paymentRequisitionPaymentsListResponse.fromJson( jsonDecode(res.body), ); } else { debugPrint("Null Response"); return null; } } catch (e) { debugPrint('hello bev=bug $e '); return null; } } static Future paymentRequisitionPaymentReceiptListAPI(empId, session, from, to) async { try { Map data = { 'emp_id': (empId).toString(), 'session_id': (session).toString(), 'from': (from).toString(), 'to': (to).toString(), }; final res = await post( data, paymentRequesitionPaymentsReceiptsListUrl, {}, ); if (res != null) { debugPrint(res.body); return paymentRequisitionPaymentsReceiptsListResponse.fromJson( jsonDecode(res.body), ); } else { debugPrint("Null Response"); return null; } } catch (e) { debugPrint('hello bev=bug $e '); return null; } } static Future paymentRequisitionPaymentDetailsAPI(empId, session, payment_id) async { try { Map data = { 'emp_id': (empId).toString(), 'session_id': (session).toString(), 'payment_id': (payment_id).toString(), }; final res = await post(data, paymentRequesitionPaymentsDetailsUrl, {}); if (res != null) { debugPrint(res.body); return paymentRequisitionPaymentsDetailsResponse.fromJson( jsonDecode(res.body), ); } else { debugPrint("Null Response"); return null; } } catch (e) { debugPrint('hello bev=bug $e '); return null; } } static Future paymentRequisitionPaymentReceiptDetailsAPI(empId, session, payment_id) async { try { Map data = { 'emp_id': (empId).toString(), 'session_id': (session).toString(), 'payment_receipt_id': (payment_id).toString(), }; final res = await post( data, paymentRequesitionPaymentsReceiptsDetailsUrl, {}, ); if (res != null) { debugPrint(res.body); return paymentRequisitionPaymentsReceiptsDetailsResponse.fromJson( jsonDecode(res.body), ); } else { debugPrint("Null Response"); return null; } } catch (e) { debugPrint('hello bev=bug $e '); return null; } } static Future editProcessedRequestAmountAPI( empId, session, process_payment_id, approval_amount, ) async { try { Map data = { 'emp_id': (empId).toString(), 'session_id': (session).toString(), 'process_payment_id': process_payment_id.toString(), 'approval_amount': approval_amount.toString(), }; print("Process EDIT:${data}"); var res = await post(data, paymentRequesitionEditProcessedPaymentUrl, {}); if (res != null) { return CommonResponse.fromJson(jsonDecode(res.body)); } else { debugPrint("Null Response"); return null; } } catch (e) { debugPrint('hello bev=bug $e '); return null; } } ///common Module static Future commonDashboardPagesAPI( empId, session, ) async { try { Map data = { 'emp_id': (empId).toString(), 'session_id': (session).toString(), }; final res = await post(data, commonAccessiblePagesUrl, {}); if (res != null) { debugPrint("CA:${res.body}"); return commonAccessiblePagesResponse.fromJson(jsonDecode(res.body)); } else { debugPrint("Null Response"); return null; } } catch (e) { debugPrint('hello bev=bug $e '); return null; } } static Future commonAddAccountViewAPI( empId, session, ) async { try { Map data = { 'emp_id': (empId).toString(), 'session_id': (session).toString(), }; final res = await post(data, commonAddAccountViewUrl, {}); if (res != null) { debugPrint(res.body); return commonAddAccountsViewResponse.fromJson(jsonDecode(res.body)); } else { debugPrint("Null Response"); return null; } } catch (e) { debugPrint('hello bev=bug $e '); return null; } } static Future commonAddAccountViewDistrictAPI( empId, session, state_id, ) async { try { Map data = { 'emp_id': (empId).toString(), 'session_id': (session).toString(), 'state_id': state_id.toString(), }; final res = await post(data, commonAddAccountViewgetDistrictUrl, {}); if (res != null) { debugPrint(res.body); return DistrictsResponse.fromJson(jsonDecode(res.body)); } else { debugPrint("Null Response"); return null; } } catch (e) { debugPrint('hello bev=bug $e '); return null; } } static Future commonAddAccountViewSubLocationAPI( empId, session, district_id, ) async { try { Map data = { 'emp_id': (empId).toString(), 'session_id': (session).toString(), 'district_id': district_id.toString(), }; final res = await post(data, commonAddAccountViewgetSubLocationUrl, {}); if (res != null) { debugPrint(res.body); return SubLocationsResponse.fromJson(jsonDecode(res.body)); } else { debugPrint("Null Response"); return null; } } catch (e) { debugPrint('hello bev=bug $e '); return null; } } static Future commonAddAccountCheckInputsAPI( empId, session, type, type_value, ) async { try { Map data = { 'emp_id': (empId).toString(), 'session_id': (session).toString(), 'type': (type).toString(), 'type_value': (type_value).toString(), }; final res = await post(data, commonAddAccountCheckInputsUrl, {}); if (res != null) { debugPrint(res.body); return commonAddAccountsViewResponse.fromJson(jsonDecode(res.body)); } else { debugPrint("Null Response"); return null; } } catch (e) { debugPrint('hello bev=bug $e '); return null; } } static Future commonAddAccountSubmitAPI( empId, session, type, name, mob1, mob2, tel, email, designation, address, state, district, sub_locality, bank_name, bank_branch_name, bank_ifsc_code, bank_account_holder_name, bank_account_number, bank_upi_id, ) async { try { Map data = { 'emp_id': (empId).toString(), 'session_id': (session).toString(), 'type': type.toString(), 'name': name.toString(), 'mob1': mob1.toString(), 'mob2': mob2.toString(), 'tel': tel.toString(), 'email': email.toString(), 'designation': designation.toString(), 'address': address.toString(), 'state': state.toString(), 'district': district.toString(), 'sub_locality': sub_locality.toString(), 'bank_name': bank_name.toString(), 'bank_branch_name': bank_branch_name.toString(), 'bank_ifsc_code': bank_ifsc_code.toString(), 'bank_account_holder_name': bank_account_holder_name.toString(), 'bank_account_number': bank_account_number.toString(), 'bank_upi_id': bank_upi_id.toString(), }; final res = await post(data, commonAddAccountSubmit, {}); if (res != null) { print(data); debugPrint(res.body); return commonAddAccountsSubmitResponse.fromJson(jsonDecode(res.body)); } else { debugPrint("Null Response"); return null; } } catch (e) { debugPrint('hello bev=bug $e '); return null; } } static Future commonAccountListAPI( empId, session, page_number, company_name, mobile_number, ) async { try { Map data = { 'emp_id': (empId).toString(), 'session_id': (session).toString(), 'page_number': page_number.toString(), 'company_name': company_name.toString(), 'mobile_number': mobile_number.toString(), }; final res = await post(data, commonAccountListUrl, {}); if (res != null) { debugPrint("adad:${res.body}"); return commonAccountlistResponse.fromJson(jsonDecode(res.body)); } else { debugPrint("Null Response"); return null; } } catch (e) { debugPrint('hello bev=bug $e '); return null; } } static Future commonAccountDetailsAPI( empId, session, account_id, ) async { try { Map data = { 'emp_id': (empId).toString(), 'session_id': (session).toString(), 'account_id': account_id.toString(), }; final res = await post(data, commonAccountLedgerAccountDetails, {}); if (res != null) { debugPrint(res.body); return commonAccountdetailsResponse.fromJson(jsonDecode(res.body)); } else { debugPrint("Null Response"); return null; } } catch (e) { debugPrint('hello bev=bug $e '); return null; } } static Future commonAccountLedgerDropDownAPI(empId, session) async { try { Map data = { 'emp_id': (empId).toString(), 'session_id': (session).toString(), }; final res = await post(data, commonAccountLedgerDropDownUrl, {}); if (res != null) { debugPrint(res.body); return commonAccountLedgerFilterResponse.fromJson(jsonDecode(res.body)); } else { debugPrint("Null Response"); return null; } } catch (e) { debugPrint('hello bev=bug $e '); return null; } } static Future commonAccountLedgerListAPI( empId, session, account_id, ) async { try { Map data = { 'emp_id': (empId).toString(), 'session_id': (session).toString(), 'account_id': account_id.toString(), }; print(data); final res = await post(data, commonAccountLedgerListWithFilterUrl, {}); if (res != null) { debugPrint(res.body); return commonAccountLedgerResponse.fromJson(jsonDecode(res.body)); } else { debugPrint("Null Response"); return null; } } catch (e) { debugPrint('hello bev=bug $e '); return null; } } ///Orders Module static Future ordersAccesiblePagesAPI( empId, session, ) async { try { Map data = { 'emp_id': (empId).toString(), 'session_id': (session).toString(), }; final res = await post(data, ordersAccessiblePagesUrl, {}); if (res != null) { debugPrint(res.body); return ordersAccessiblePagesResponse.fromJson(jsonDecode(res.body)); } else { debugPrint("Null Response"); return null; } } catch (e) { debugPrint('hello bev=bug $e '); return null; } } static Future ordersAccesibleAddPagesAPI( empId, session, ) async { try { Map data = { 'emp_id': (empId).toString(), 'session_id': (session).toString(), }; final res = await post(data, ordersAccessibleAddPagesUrl, {}); if (res != null) { debugPrint(res.body); return ordersAccessiblePagesResponse.fromJson(jsonDecode(res.body)); } else { debugPrint("Null Response"); return null; } } catch (e) { debugPrint('hello bev=bug $e '); return null; } } static Future orderPendingTasksListAPI( empId, session, ) async { try { Map data = { 'emp_id': (empId).toString(), 'session_id': (session).toString(), }; final res = await post(data, ordersPendingTasksListUrl, {}); if (res != null) { debugPrint(res.body); return orderPendingTasksListResponse.fromJson(jsonDecode(res.body)); } else { debugPrint("Null Response"); return null; } } catch (e) { debugPrint('hello bev=bug $e '); return null; } } static Future ordersDashboardAPI( empId, session, mode, from, to, teamemployee, ) async { try { Map data = { 'emp_id': (empId).toString(), 'session_id': (session).toString(), 'mode': (mode).toString(), 'from': (from).toString(), 'to': (to).toString(), 'teamemployee': (teamemployee).toString(), }; final res = await post(data, ordersDashboardUrl, {}); if (res != null) { debugPrint(res.body); return orderDashboardResponse.fromJson(jsonDecode(res.body)); } else { debugPrint("Null Response"); return null; } } catch (e) { debugPrint('hello bev=bug $e '); return null; } } static Future addOrderViewAPI( empId, session, mode, ) async { try { Map data = { 'emp_id': (empId).toString(), 'session_id': (session).toString(), 'mode': (mode).toString(), }; final res = await post(data, ordersAddOrderViewUrl, {}); if (res != null) { debugPrint(res.body); return AddOrderViewResponse.fromJson(jsonDecode(res.body)); } else { debugPrint("Null Response"); return null; } } catch (e) { debugPrint('hello bev=bug $e '); return null; } } static Future addOrderAccountDetailsAPI( empId, session, account_id, ) async { try { Map data = { 'emp_id': (empId).toString(), 'session_id': (session).toString(), 'account_id': (account_id).toString(), }; final res = await post(data, ordersAddOrderAccountDetailsUrl, {}); if (res != null) { debugPrint(res.body); return addOrderAccontDetailsResponse.fromJson(jsonDecode(res.body)); } else { debugPrint("Null Response"); return null; } } catch (e) { debugPrint('hello bev=bug $e '); return null; } } static Future addOrderTPCAgentListAPI( empId, session, mode, text, ) async { try { Map data = { 'emp_id': (empId).toString(), 'session_id': (session).toString(), 'mode': mode.toString(), 'text': (text).toString(), }; final res = await post(data, ordersAddOrderTpcAgentListUrl, {}); if (res != null) { debugPrint(res.body); return addOrderTpcAgentListResponse.fromJson(jsonDecode(res.body)); } else { debugPrint("Null Response"); return null; } } catch (e) { debugPrint('hello bev=bug $e '); return null; } } static Future addOrderSubmitAPI( empId, session, mode, sales_person_emp_id, selected_acc_id, dispatch_state_id, dispatch_district_id, dispatch_sub_location_id, dispatch_pincode, dispatch_address, basic_amount, cgst_amount, sgst_amount, igst_amount, total_amount, order_received_date, note, unloading, freight, erection, tpc_applicable, billing_name, billing_gst_no, billing_pincode, billing_address, billing_state, billing_district, billing_sub_locality, order_products, lead_id, feedback, in_time, loc, requested_tpc_amount, tpc_agent_id, po, ) async { try { Map data = { 'emp_id': empId.toString(), 'session_id': session.toString(), 'mode': mode.toString(), 'sales_person_emp_id': sales_person_emp_id.toString(), 'selected_acc_id': selected_acc_id.toString(), 'dispatch_state_id': dispatch_state_id.toString(), 'dispatch_district_id': dispatch_district_id.toString(), 'dispatch_sub_location_id': dispatch_sub_location_id.toString(), 'dispatch_pincode': dispatch_pincode.toString(), 'dispatch_address': dispatch_address.toString(), 'basic_amount': basic_amount.toString(), 'cgst_amount': cgst_amount.toString(), 'sgst_amount': sgst_amount.toString(), 'igst_amount': igst_amount.toString(), 'total_amount': total_amount.toString(), 'order_received_date': order_received_date.toString(), 'note': note.toString(), 'unloading': unloading.toString(), 'freight': freight.toString(), 'erection': erection.toString(), 'tpc_applicable': tpc_applicable.toString(), 'billing_name': billing_name.toString(), 'billing_gst_no': billing_gst_no.toString(), 'billing_pincode': billing_pincode.toString(), 'billing_address': billing_address.toString(), 'billing_state': billing_state.toString(), 'billing_district': billing_district.toString(), 'billing_sub_locality': billing_sub_locality.toString(), 'order_products': (order_products).toString(), 'lead_id': lead_id.toString(), 'feedback': feedback.toString(), 'in_time': in_time.toString(), 'loc': loc.toString(), 'requested_tpc_amount': requested_tpc_amount.toString(), 'tpc_agent_id': tpc_agent_id.toString(), }; var res; print("add order:${data}"); if (po != null) { res = await postImageNew(data, {}, ordersAddOrderSubmitUrl, po, "po"); res = jsonDecode(res); } else { res = await post(data, ordersAddOrderSubmitUrl, {}); res = jsonDecode(res.body); } return CommonResponse.fromJson(res); } catch (e) { debugPrint('hello bev=bug $e '); return null; } } static Future ordersListByModeFilterAPI( empId, session, mode, ) async { try { Map data = { 'emp_id': (empId).toString(), 'session_id': (session).toString(), 'mode': (mode).toString(), }; final res = await post(data, ordersOrderListByModeUrl, {}); if (res != null) { debugPrint(res.body); return ordersListByModeFilterResponse.fromJson(jsonDecode(res.body)); } else { debugPrint("Null Response"); return null; } } catch (e) { debugPrint('hello bev=bug $e '); return null; } } static Future ordersListByModeAPI( empId, session, mode, teamemployee, status, ) async { try { Map data = { 'emp_id': (empId).toString(), 'session_id': (session).toString(), 'mode': (mode).toString(), 'teamemployee': (teamemployee).toString(), 'status': (status).toString(), }; final res = await post(data, ordersOrderListFilterUrl, {}); if (res != null) { print("mode: $data"); debugPrint(res.body); return ordersListByModeResponse.fromJson(jsonDecode(res.body)); } else { debugPrint("Null Response"); return null; } } catch (e) { debugPrint('hello bev=bug $e '); return null; } } static Future ordersDetailsByModeAPI( empId, session, order_id, ) async { try { Map data = { 'emp_id': (empId).toString(), 'session_id': (session).toString(), 'order_id': (order_id).toString(), }; final res = await post(data, ordersOrderDetailsUrl, {}); if (res != null) { print("Order Details ${data}"); print("Order Details ${res.body}"); return ordersDetailsByModeResponse.fromJson(jsonDecode(res.body)); } else { debugPrint("Null Response"); return null; } } catch (e) { debugPrint('hello bev=bug $e '); return null; } } static Future ordersDetailsFeedbackSubmissionAPI( empId, session, order_id, feedback, status, attachment_file, ) async { try { Map data = { 'emp_id': (empId).toString(), 'session_id': (session).toString(), 'order_id': order_id.toString(), 'feedback': (feedback).toString(), 'status': status, }; var res; if (attachment_file != null) { res = await postImageNew( data, {}, ordersOrderDetailsFeedbackSubmitUrl, attachment_file, "attachment_file", ); res = jsonDecode(res); } else { res = await post(data, ordersOrderDetailsFeedbackSubmitUrl, {}); res = jsonDecode(res.body); } return CommonResponse.fromJson(res); } catch (e) { debugPrint('hello bev=bug $e '); return null; } } static Future ordersDetailsEditOrderViewAPI(empId, session, order_id) async { try { Map data = { 'emp_id': (empId).toString(), 'session_id': (session).toString(), 'order_id': order_id.toString(), }; var res = await post(data, ordersOrderDetailsEditOrderUrl, {}); if (res != null) { return ordersDetailsEditOrderViewResponse.fromJson( jsonDecode(res.body), ); } else { debugPrint("Null Response"); } } catch (e) { debugPrint('hello bev=bug $e '); return null; } } static Future ordersDetailsEditOrderSubmitAPI( empId, session, order_id, attachment_file, dispatch_state_id, district, sub_locality, dispatch_pincode, dispatch_address, unloading, freight, erection, note, ) async { try { Map data = { 'emp_id': empId.toString(), 'session_id': session.toString(), 'order_id': order_id.toString(), 'dispatch_state_id': dispatch_state_id.toString(), 'district': district.toString(), 'sub_locality': sub_locality.toString(), 'dispatch_pincode': dispatch_pincode.toString(), 'dispatch_address': dispatch_address.toString(), 'unloading': unloading.toString(), 'freight': freight.toString(), 'erection': erection.toString(), 'note': note.toString(), }; var res; print("Edit Order:$data"); if (attachment_file != null) { res = await postImageNew( data, {}, ordersOrderDetailsEditOrderSubmitUrl, attachment_file, "attachment_file", ); res = jsonDecode(res); } else { res = await post(data, ordersOrderDetailsEditOrderSubmitUrl, {}); res = jsonDecode(res.body); } return CommonResponse.fromJson(res); } catch (e) { debugPrint('hello bev=bug $e '); return null; } } static Future ordersDetailsDispatchOrderViewAPI(empId, session, order_id) async { try { Map data = { 'emp_id': empId.toString(), 'session_id': session.toString(), 'order_id': order_id.toString(), }; final res = await post(data, ordersOrderDetailsDispatchProductsUrl, {}); if (res != null) { return ordersDetailsDispatchOrderViewResponse.fromJson( jsonDecode(res.body), ); } else { debugPrint("Null Response"); } } catch (e) { debugPrint('hello bev=bug $e '); return null; } } static Future ordersPdiIdByEngNumberUrlAPI( empId, session, engine_number, ) async { try { Map data = { 'emp_id': empId.toString(), 'session_id': session.toString(), 'engine_number': engine_number.toString(), }; final res = await post(data, ordersPdiIdByEngNumberUrl, {}); if (res != null) { return ordersPdiIdByEngNumberResponse.fromJson(jsonDecode(res.body)); } else { debugPrint("Null Response"); } } catch (e) { debugPrint('hello bev=bug $e '); return null; } } static Future ordersDetailsApproveRejectAPI( empId, session, status, type, order_id, feedback, tpc_applicable, tpc_approved_amount, sale_order_number, edit_company_name, invoice_number, vehicle_number, driver_name, driver_mobile_no, crm_order_p_id, ) async { try { Map data = { 'emp_id': (empId).toString(), 'session_id': (session).toString(), "status": status.toString(), "type": type.toString(), "order_id": order_id.toString(), "feedback": feedback.toString(), "tpc_applicable": tpc_applicable.toString(), "tpc_approved_amount": tpc_approved_amount.toString(), "sale_order_number": sale_order_number.toString(), "edit_company_name": edit_company_name.toString(), "invoice_number": invoice_number.toString(), "vehicle_number": vehicle_number.toString(), "driver_name": driver_name.toString(), "driver_mobile_no": driver_mobile_no.toString(), "crm_order_p_id": crm_order_p_id.toString(), }; final res = await post(data, ordersOrderApproveRejectUrl, {}); if (res != null) { print("DATATATATA:: $data"); debugPrint(res.body); return CommonResponse.fromJson(jsonDecode(res.body)); } else { debugPrint("Null Response"); return null; } } catch (e) { debugPrint('hello bev=bug $e '); return null; } } static Future ordersDetailsDeleteAPI( empId, session, order_id, feedback, ) async { try { Map data = { 'emp_id': (empId).toString(), 'session_id': (session).toString(), "order_id": order_id.toString(), "feedback": feedback.toString(), }; final res = await post(data, ordersOrderLDeleteUrl, {}); if (res != null) { print(data); debugPrint(res.body); return CommonResponse.fromJson(jsonDecode(res.body)); } else { debugPrint("Null Response"); return null; } } catch (e) { debugPrint('hello bev=bug $e '); return null; } } static Future addOrderpaymentListViewAPI( empId, session, ) async { try { Map data = { 'emp_id': (empId).toString(), 'session_id': (session).toString(), }; final res = await post(data, ordersAddPaymentViewUrl, {}); if (res != null) { debugPrint(res.body); return addOrderPaymentViewResponse.fromJson(jsonDecode(res.body)); } else { debugPrint("Null Response"); return null; } } catch (e) { debugPrint('hello bev=bug $e '); return null; } } static Future addOrderpaymentListSubmitAPI( empId, session, account_id, description, selected_orders, payment_amount, payment_date, payment_type, ref_no, attachment, ) async { try { Map data = { 'emp_id': (empId).toString(), 'session_id': (session).toString(), 'account_id': account_id.toString(), 'description': description.toString(), 'selected_orders': jsonEncode(selected_orders).toString(), 'payment_amount': payment_amount.toString(), 'payment_date': payment_date.toString(), 'payment_type': payment_type.toString(), 'ref_no': ref_no.toString(), }; var res; print("Add Payment: ${data}"); if (attachment != null) { res = await postImageNew( data, {}, ordersAddPaymentSubmitUrl, attachment, "attachment", ); res = jsonDecode(res); } else { res = await post(data, ordersAddPaymentSubmitUrl, {}); res = jsonDecode(res.body); // return CommonResponse.fromJson(res); } return CommonResponse.fromJson(res); } catch (e) { debugPrint('hello bev=bug $e '); return null; } } static Future ordersEditPaymentDetailsAPI( empId, session, payment_id, description, payment_type, ref_no, payment_date, amount, ) async { try { Map data = { 'emp_id': (empId).toString(), 'session_id': (session).toString(), 'payment_id': payment_id.toString(), 'description': description.toString(), 'payment_type': payment_type.toString(), 'payment_date': payment_date.toString(), 'ref_no': ref_no.toString(), 'amount': amount.toString(), }; var res = await post(data, ordersEditPaymentDetailsUrl, {}); if (res != null) { return CommonResponse.fromJson(jsonDecode(res.body)); } else { debugPrint("Null Response"); } } catch (e) { debugPrint('hello bev=bug $e '); return null; } } static Future ordersEditPaymentDetailsAdjustedOrdersViewAPI( empId, session, payment_id, ) async { try { Map data = { 'emp_id': (empId).toString(), 'session_id': (session).toString(), 'payment_id': payment_id.toString(), }; var res = await post( data, ordersEditPaymentDetailsAdjustedOrdersViewUrl, {}, ); if (res != null) { print("edit adjusted : ${res.body}"); return EditPaymentDetailsAdjustedOrdersViewResponse.fromJson( jsonDecode(res.body), ); } else { debugPrint("Null Response"); } } catch (e) { debugPrint('hello bev=bug $e '); return null; } } static Future ordersEditPaymentDetailsAdjustedOrdersUpdateAPI( empId, session, payment_id, update_amounts, insert_amounts, ) async { try { Map data = { 'emp_id': (empId).toString(), 'session_id': (session).toString(), 'payment_id': payment_id.toString(), 'update_amounts': jsonEncode(update_amounts).toString(), 'insert_amounts': jsonEncode(insert_amounts).toString(), }; var res = await post(data, ordersEditPaymentDetailsAdjustedOrdersUrl, {}); if (res != null) { return EditPaymentDetailsAdjustedOrdersViewResponse.fromJson( jsonDecode(res.body), ); } else { debugPrint("Null Response"); } } catch (e) { debugPrint('hello bev=bug $e '); return null; } } static Future AddOrderPaymentSelectAccountAPI(empId, session, mode, search_term) async { try { Map data = { 'emp_id': (empId).toString(), 'session_id': (session).toString(), 'mode': mode.toString(), 'search_term': search_term.toString(), }; final res = await post( data, ordersAddPaymentSelectAccountForOrderUrl, {}, ); if (res != null) { print(data); print("PaymentSeralectAccount${res.body}"); return AddOrderPaymentSelectAccountResponse.fromJson( jsonDecode(res.body), ); } else { debugPrint("Null Response"); return null; } } catch (e) { debugPrint('hello bev=bug $e '); return null; } } static Future AddOrderPaymentSelectOrderAPI(empId, session, account_id) async { try { Map data = { 'emp_id': (empId).toString(), 'session_id': (session).toString(), 'account_id': account_id.toString(), }; final res = await post(data, ordersAddPaymentSelectOrderUrl, {}); if (res != null) { print(data); debugPrint("add order payment selected order: ${res.body}"); return AddOrderPaymentSelectOrderResponse.fromJson( jsonDecode(res.body), ); } else { debugPrint("Null Response"); return null; } } catch (e) { debugPrint('hello bev=bug $e '); return null; } } static Future paymentListByModeFilterAPI( empId, session, mode, ) async { try { Map data = { 'emp_id': (empId).toString(), 'session_id': (session).toString(), 'mode': (mode).toString(), }; final res = await post(data, ordersPaymentListFilterUrl, {}); if (res != null) { debugPrint(res.body); return paymentListByModeFilterResponse.fromJson(jsonDecode(res.body)); } else { debugPrint("Null Response"); return null; } } catch (e) { debugPrint('hello bev=bug $e '); return null; } } static Future paymentListsByModeAPI( empId, session, mode, teamemployee, ) async { try { Map data = { 'emp_id': (empId).toString(), 'session_id': (session).toString(), 'mode': (mode).toString(), 'teamemployee': (teamemployee).toString(), }; final res = await post(data, ordersPaymentListByModeUrl, {}); if (res != null) { print(data); debugPrint(res.body); return paymentListByModeResponse.fromJson(jsonDecode(res.body)); } else { debugPrint("Null Response"); return null; } } catch (e) { debugPrint('hello bev=bug $e '); return null; } } static Future paymentOrderApproveRejectAPI( empId, session, payment_id, type, remarks, ) async { try { Map data = { 'emp_id': (empId).toString(), 'session_id': (session).toString(), "payment_id": payment_id.toString(), "type": type.toString(), "remarks": remarks.toString(), }; final res = await post(data, ordersPaymentListApproveRejectUrl, {}); if (res != null) { print(data); debugPrint(res.body); return CommonResponse.fromJson(jsonDecode(res.body)); } else { debugPrint("Null Response"); return null; } } catch (e) { debugPrint('hello bev=bug $e '); return null; } } static Future verifyOrderAPI( empId, session, order_id, otp, ) async { try { Map data = { 'emp_id': (empId).toString(), 'session_id': (session).toString(), "order_id": order_id.toString(), "otp": otp.toString(), }; final res = await post(data, ordersVerifyOtpUrl, {}); if (res != null) { print(data); debugPrint(res.body); return CommonResponse.fromJson(jsonDecode(res.body)); } else { debugPrint("Null Response"); return null; } } catch (e) { debugPrint('hello bev=bug $e '); return null; } } static Future resendOTPOrderAPI( empId, session, order_id, ) async { try { Map data = { 'emp_id': (empId).toString(), 'session_id': (session).toString(), "order_id": order_id.toString(), }; final res = await post(data, ordersResendOtpUrl, {}); if (res != null) { print(data); debugPrint(res.body); return CommonResponse.fromJson(jsonDecode(res.body)); } else { debugPrint("Null Response"); return null; } } catch (e) { debugPrint('hello bev=bug $e '); return null; } } static Future paymentOrderDeleteAPI( empId, session, payment_id, ) async { try { Map data = { 'emp_id': (empId).toString(), 'session_id': (session).toString(), "payment_id": payment_id.toString(), }; final res = await post(data, ordersPaymentListDeleteUrl, {}); if (res != null) { print(data); debugPrint(res.body); return CommonResponse.fromJson(jsonDecode(res.body)); } else { debugPrint("Null Response"); return null; } } catch (e) { debugPrint('hello bev=bug $e '); return null; } } static Future paymentsDetailsByModeAPI( empId, session, payment_id, ) async { try { Map data = { 'emp_id': (empId).toString(), 'session_id': (session).toString(), 'payment_id': (payment_id).toString(), }; final res = await post(data, ordersPaymentDetailsUrl, {}); if (res != null) { print(data); debugPrint(res.body); return paymentDetailsByModeFilterResponse.fromJson( jsonDecode(res.body), ); } else { debugPrint("Null Response"); return null; } } catch (e) { debugPrint('hello bev=bug $e '); return null; } } static Future paymentsDetailsAddAdjustedOrderAPI( empId, session, payment_id, selected_order_id, amount, ) async { try { Map data = { 'emp_id': (empId).toString(), 'session_id': (session).toString(), 'payment_id': (payment_id).toString(), 'selected_order_id': (selected_order_id).toString(), 'amount': (amount).toString(), }; final res = await post(data, ordersPaymentDetailsAddOrderUrl, {}); if (res != null) { print("paymentsDetailsAddAdjusted: $data"); debugPrint(res.body); return CommonResponse.fromJson( jsonDecode(res.body), ); } else { debugPrint("Null Response"); return null; } } catch (e) { debugPrint('hello bev=bug $e '); return null; } } static Future paymentsDetailsEditAdjustedOrderAPI( empId, session, selected_order_id, amount, order_payment_id, ) async { try { Map data = { 'emp_id': (empId).toString(), 'session_id': (session).toString(), 'selected_order_id': (selected_order_id).toString(), 'amount': (amount).toString(), 'order_payment_id': (order_payment_id).toString(), }; final res = await post(data, ordersPaymentDetailsEditOrderUrl, {}); if (res != null) { print("paymentsDetailsEditAdjusted $data"); debugPrint(res.body); return CommonResponse.fromJson( jsonDecode(res.body), ); } else { debugPrint("Null Response"); return null; } } catch (e) { debugPrint('hello bev=bug $e '); return null; } } static Future ordersAddTPCAgentAPI( empId, session, agent_name, mobile_number, bank_name, bank_account_no, bank_ifsc_code, bank_beneficiary_name, note, id_proof, ) async { try { Map data = { 'emp_id': (empId).toString(), 'session_id': (session).toString(), 'agent_name': agent_name.toString(), 'mobile_number': mobile_number.toString(), 'bank_name': bank_name.toString(), 'bank_account_no': bank_account_no.toString(), 'bank_ifsc_code': bank_ifsc_code.toString(), 'bank_beneficiary_name': bank_beneficiary_name.toString(), 'note': note.toString(), }; var res; print("add TPC: $data"); if (id_proof != null) { res = await postImageNew( data, {}, ordersAddTPCAgentUrl, id_proof, "id_proof", ); res = jsonDecode(res); } else { res = await post(data, ordersAddTPCAgentUrl, {}); res = jsonDecode(res.body); // return CommonResponse.fromJson(res); } print("Add TPC: ${res}"); return CommonResponse.fromJson(res); } catch (e) { debugPrint('hello bev=bug $e '); return null; } } static Future TPCAgentListAPI(empId, session, mode) async { try { Map data = { 'emp_id': (empId).toString(), 'session_id': (session).toString(), 'mode': (mode).toString(), }; final res = await post(data, ordersTPCAgentListUrl, {}); if (res != null) { print(data); debugPrint(res.body); return TPCListResponse.fromJson(jsonDecode(res.body)); } else { debugPrint("Null Response"); return null; } } catch (e) { debugPrint('hello bev=bug $e '); return null; } } static Future TPCAgentDetailsAPI( empId, session, tpc_agent_id, ) async { try { Map data = { 'emp_id': (empId).toString(), 'session_id': (session).toString(), 'tpc_agent_id': (tpc_agent_id).toString(), }; final res = await post(data, ordersTPCAgentDetailsUrl, {}); if (res != null) { print(data); debugPrint(res.body); return TPCAgentDetailsResponse.fromJson(jsonDecode(res.body)); } else { debugPrint("Null Response"); return null; } } catch (e) { debugPrint('hello bev=bug $e '); return null; } } static Future pendingTPCAgentIssueListAPI( empId, session, ) async { try { Map data = { 'emp_id': (empId).toString(), 'session_id': (session).toString(), }; final res = await post(data, ordersPendingTPCIssueListUrl, {}); if (res != null) { print(data); debugPrint(res.body); return PendingTPCAgentListResponse.fromJson(jsonDecode(res.body)); } else { debugPrint("Null Response"); return null; } } catch (e) { debugPrint('hello bev=bug $e '); return null; } } static Future TpcIssueListApprovalAPI( empId, session, tpc_payment_mode, tpc_payment_reference_no, order_id, order_tpc_feedback, tpc_paym_attachment, ) async { try { Map data = { 'emp_id': (empId).toString(), 'session_id': (session).toString(), 'tpc_payment_mode': tpc_payment_mode.toString(), 'tpc_payment_reference_no': tpc_payment_reference_no.toString(), 'order_id': order_id.toString(), 'order_tpc_feedback': order_tpc_feedback.toString(), }; var res; if (tpc_paym_attachment != null) { res = await postImageNew( data, {}, ordersApprovePendingTPCIssueListUrl, tpc_paym_attachment, "tpc_paym_attachment", ); res = jsonDecode(res); } else { res = await post(data, ordersApprovePendingTPCIssueListUrl, {}); res = jsonDecode(res.body); // return CommonResponse.fromJson(res); } return CommonResponse.fromJson(res); } catch (e) { debugPrint('hello bev=bug $e '); return null; } } ///CRM Module static Future crmAccessiblePagesAPI( empId, session, ) async { try { Map data = { 'emp_id': (empId).toString(), 'session_id': (session).toString(), }; final res = await post(data, crmAccessiblePagesUrl, {}); if (res != null) { print(data); debugPrint("Accessibl pages: ${res.body}"); return AccessiblePagesResponse.fromJson(jsonDecode(res.body)); } else { debugPrint("Null Response"); return null; } } catch (e) { debugPrint('hello bev=bug $e '); return null; } } static Future crmNewLeadsProspectsViewAPI( empId, session, ) async { try { Map data = { 'emp_id': (empId).toString(), 'session_id': (session).toString(), }; final res = await post(data, crmNewProspectLeadViewUrl, {}); if (res != null) { print(data); debugPrint("New Leads prospecrs ${res.body}"); return crmNewLeadsProspectsViewResponse.fromJson(jsonDecode(res.body)); } else { debugPrint("Null Response"); return null; } } catch (e) { debugPrint('hello bev=bug $e '); return null; } } static Future crmNewLeadsProspectsSubmitAPI( session_id, emp_id, mode, acc_manager_id, salutation_name, name, contact_name, district, state, address, segment, source, reference, team, sub_locality, mob1, mob2, tel, email, designation, lead_status, products, ) async { try { Map data = { 'session_id': session_id.toString(), 'emp_id': emp_id.toString(), 'mode': mode.toString(), 'acc_manager_id': acc_manager_id.toString(), 'salutation_name': salutation_name.toString(), 'name': name.toString(), 'contact_name': contact_name.toString(), 'district': district.toString(), 'state': state.toString(), 'address': address.toString(), 'segment': segment.toString(), 'source': source.toString(), 'reference': reference.toString(), 'team': team.toString(), 'sub_locality': sub_locality.toString(), 'mob1': mob1.toString(), 'mob2': mob2.toString(), 'tel': tel.toString(), 'email': email.toString(), 'designation': designation.toString(), 'lead_status': lead_status.toString(), 'products': products.toString(), }; final res = await post(data, crmNewProspectLeadSubmitUrl, {}); if (res != null) { print(data); debugPrint("Submit New Leads ${res.body}"); return crmNewLeadsProspectsSubmitResponse.fromJson(jsonDecode(res.body)); } else { debugPrint("Null Response"); return null; } } catch (e) { debugPrint('hello bev=bug $e '); return null; } } static Future crmDashboardAPI( empId, session, emp_loc, ) async { try { Map data = { 'emp_id': (empId).toString(), 'session_id': (session).toString(), 'emp_loc': emp_loc.toString(), }; final res = await post(data, crmDashboardUrl, {}); if (res != null) { print(data); print("CRM Dash ${jsonDecode(res.body)}"); return crmDashboardResponse.fromJson(jsonDecode(res.body)); } else { debugPrint("Null Response"); return null; } } catch (e) { debugPrint('hello bev=bug $e '); return null; } } static Future crmPendingTasksAPI( empId, session, ) async { try { Map data = { 'emp_id': (empId).toString(), 'session_id': (session).toString(), }; final res = await post(data, crmPendingTasksListUrl, {}); if (res != null) { print(data); debugPrint("PEnding Tasks ${res.body}"); return crmPendingTasksResponse.fromJson(jsonDecode(res.body)); } else { debugPrint("Null Response"); return null; } } catch (e) { debugPrint('hello bev=bug $e '); return null; } } static Future crmUniversalSearchAPI( empId, session, q, ) async { try { Map data = { 'emp_id': (empId).toString(), 'session_id': (session).toString(), 'q': (q).toString(), }; final res = await post(data, crmUnivesalSearchUrl, {}); if (res != null) { print(data); debugPrint("Universal Search ${res.body}"); return crmUniversalSearchResponse.fromJson(jsonDecode(res.body)); } else { debugPrint("Null Response"); return null; } } catch (e) { debugPrint('hello bev=bug $e '); return null; } } static Future crmLeadListViewAPI( empId, session, mode, ) async { try { Map data = { 'emp_id': (empId).toString(), 'session_id': (session).toString(), 'mode': (mode).toString(), }; final res = await post(data, crmLeadListViewUrl, {}); if (res != null) { print(data); debugPrint("Lead ListView2: ${res.body}"); return LeadListViewResponse.fromJson(jsonDecode(res.body)); } else { debugPrint("Null Response"); return null; } } catch (e) { debugPrint('hello bev=bug $e '); return null; } } static Future crmLeadListFilterSubmitAPI( empId, session, mode, status, open_status, mob, com, source, reference, team, segment, alphabet, ) async { try { Map data = { 'emp_id': (empId).toString(), 'session_id': (session).toString(), 'mode': (mode).toString(), 'status': status.toString(), 'open_status': open_status.toString(), 'mob': mob.toString(), 'com': com.toString(), 'source': source.toString(), 'reference': reference.toString(), 'team': team.toString(), 'segment': segment.toString(), 'alphabet': alphabet.toString(), }; final res = await post(data, crmLeadListFilterSubmitUrl, {}); if (res != null) { print("Lead Filter:${data}"); debugPrint(res.body); return SubmitLeadListFilterResponse.fromJson(jsonDecode(res.body)); } else { debugPrint("Null Response"); return null; } } catch (e) { debugPrint('hello bev=bug $e '); return null; } } static Future crmLeadListSourceOnReferenceAPI( empId, session, source_id, ) async { try { Map data = { 'emp_id': (empId).toString(), 'session_id': (session).toString(), 'source_id': (source_id).toString(), }; final res = await post(data, crmLeadListSourceOnReferenceUrl, {}); if (res != null) { print(data); debugPrint("Source on Ref ${res.body}"); return GetSourceOnReferenceResponse.fromJson(jsonDecode(res.body)); } else { debugPrint("Null Response"); return null; } } catch (e) { debugPrint('hello bev=bug $e '); return null; } } static Future crmLeadListSegmentOnTeamAPI( empId, session, team_id, ) async { try { Map data = { 'emp_id': (empId).toString(), 'session_id': (session).toString(), 'team_id': (team_id).toString(), }; final res = await post(data, crmLeadListSegmentOnTeamUrl, {}); if (res != null) { print(data); print("Segemnt on team ${res.body}"); return GetSegmentOnTeamResponse.fromJson(jsonDecode(res.body)); } else { debugPrint("Null Response"); return null; } } catch (e) { debugPrint('hello bev=bug $e '); return null; } } static Future crmDistrictsOnStateAPI( empId, session, state_id, ) async { try { Map data = { 'emp_id': (empId).toString(), 'session_id': (session).toString(), 'state_id': (state_id).toString(), }; final res = await post(data, crmLeadListDistrictOnStateUrl, {}); if (res != null) { print(data); debugPrint("districts on State ${res.body}"); return GetDistrictOnStateResponse.fromJson(jsonDecode(res.body)); } else { debugPrint("Null Response"); return null; } } catch (e) { debugPrint('hello bev=bug $e '); return null; } } static Future crmSubLocOnDistrictAPI( empId, session, district_id, ) async { try { Map data = { 'emp_id': (empId).toString(), 'session_id': (session).toString(), 'district_id': (district_id).toString(), }; final res = await post(data, crmLeadListSubLocOnDistrictUrl, {}); if (res != null) { print(data); debugPrint("Sub loc on Dist ${res.body}"); return GetSubLocOnDistrictResponse.fromJson(jsonDecode(res.body)); } else { debugPrint("Null Response"); return null; } } catch (e) { debugPrint('hello bev=bug $e '); return null; } } static Future crmLeadListContactPopUpAPI( empId, session, account_id, ) async { try { Map data = { 'emp_id': (empId).toString(), 'session_id': (session).toString(), 'account_id': (account_id).toString(), }; final res = await post(data, crmLeadListContactPopUpUrl, {}); if (res != null) { print(data); debugPrint("Lead list contact ${res.body}"); return LeadListContactPopUpResponse.fromJson(jsonDecode(res.body)); } else { debugPrint("Null Response"); return null; } } catch (e) { debugPrint('hello bev=bug $e '); return null; } } static Future crmLeadDetailsAPI( empId, session, lead_id, mode, ) async { try { Map data = { 'emp_id': (empId).toString(), 'session_id': (session).toString(), 'lead_id': (lead_id).toString(), 'mode': (mode).toString(), }; final res = await post(data, crmLeadDetailsUrl, {}); if (res != null) { print(data); debugPrint("Lead Deatails ${res.body}"); return LeadDetailsResponse.fromJson(jsonDecode(res.body)); } else { debugPrint("Null Response"); return null; } } catch (e) { debugPrint('hello bev=bug $e '); return null; } } static Future crmLeadDetailsAddEditProductsAPI( empId, session, lead_id, type, lead_product_id, product_id, qty, amount, ) async { try { Map data = { 'emp_id': (empId).toString(), 'session_id': (session).toString(), 'lead_id': (lead_id).toString(), 'type': (type).toString(), 'lead_product_id': (lead_product_id).toString(), 'product_id': (product_id).toString(), 'qty': (qty).toString(), 'amount': (amount).toString(), }; final res = await post(data, crmLeadDetailsAddEditProductsUrl, {}); if (res != null) { print("AddEditProducts $data"); debugPrint("AddEditProducts: ${res.body}"); return CommonResponse.fromJson(jsonDecode(res.body)); } else { debugPrint("Null Response"); return null; } } catch (e) { debugPrint('hello bev=bug $e '); return null; } } static Future crmLeadDetailsAddFollowUpAPI( session_id, emp_id, nextapp, orderstatus, lead_id, followup_feedback, followup_type, followupintime, loc, competitor, reason, followup_status, next_appointment_date, appointment_type, sms, app_note, ) async { try { Map data = { 'session_id': session_id.toString(), 'emp_id': emp_id.toString(), 'nextapp': nextapp.toString(), 'orderstatus': orderstatus.toString(), 'lead_id': lead_id.toString(), 'followup_feedback': followup_feedback.toString(), 'followup_type': followup_type.toString(), 'followupintime': followupintime.toString(), 'loc': loc.toString(), 'competitor': competitor.toString(), 'reason': reason.toString(), 'followup_status': followup_status.toString(), 'next_appointment_date': next_appointment_date.toString(), 'appointment_type': appointment_type.toString(), 'sms': sms.toString(), 'app_note': app_note.toString(), }; final res = await post(data, crmLeadDetailsAddFollowUpUrl, {}); if (res != null) { print("crmAddFollowUp: $data"); debugPrint("crmAddFollowUp: ${res.body}"); return crmAddFollowUpResponse.fromJson(jsonDecode(res.body)); } else { debugPrint("Null Response"); return null; } } catch (e) { debugPrint('hello bev=bug $e '); return null; } } static Future crmLeadDetailsEditAccountViewAPI(empId, session, lead_id, mode) async { try { Map data = { 'emp_id': (empId).toString(), 'session_id': (session).toString(), 'lead_id': (lead_id).toString(), 'mode': (mode).toString(), }; final res = await post(data, crmLeadDetailsEditAccountViewUrl, {}); if (res != null) { print(data); debugPrint("crmLeadDetailsEditAccountViewAPI: ${res.body}"); return crmLeadDetailsEditAccountViewResponse.fromJson( jsonDecode(res.body), ); } else { debugPrint("Null Response"); return null; } } catch (e) { debugPrint('hello bev=bug $e '); return null; } } static Future crmLeadDetailsEditAccountSubmitAPI( empId, session, account_id, segment_id, team_id, account_name, ) async { try { Map data = { 'emp_id': (empId).toString(), 'session_id': (session).toString(), 'account_id': (account_id).toString(), 'segment_id': (segment_id).toString(), 'team_id': (team_id).toString(), 'account_name': (account_name).toString(), }; final res = await post(data, crmLeadDetailsEditAccountUrl, {}); if (res != null) { print(data); debugPrint("crmLeadDetailsEditAccountSubmitAPI ${res.body}"); return CommonResponse.fromJson(jsonDecode(res.body)); } else { debugPrint("Null Response"); return null; } } catch (e) { debugPrint('hello bev=bug $e '); return null; } } static Future crmLeadDetailsEditProductsViewAPI(empId, session, lead_id) async { try { Map data = { 'emp_id': (empId).toString(), 'session_id': (session).toString(), 'lead_id': (lead_id).toString(), }; final res = await post(data, crmLeadDetailsEditProductsViewUrl, {}); if (res != null) { print(data); print("crmLeadDetailsEditProductsViewAPI: ${jsonDecode(res.body)['lead_products']}"); debugPrint(res.body); return crmLeadDetailsEditProductsViewResponse.fromJson( jsonDecode(res.body), ); } else { debugPrint("Null Response"); return null; } } catch (e) { debugPrint('hello bev=bug $e '); return null; } } static Future crmLeadDetailsEditProductsSubmitAPI( empId, session, products, lead_id, ) async { try { Map data = { 'emp_id': (empId).toString(), 'session_id': (session).toString(), 'products': jsonEncode(products).toString(), 'lead_id': (lead_id).toString(), }; final res = await post(data, crmLeadDetailsEditProductsUrl, {}); if (res != null) { print(data); print("crmLeadDetailsEditProductsSubmitAPI: ${jsonDecode(res.body)}"); return CommonResponse.fromJson(jsonDecode(res.body)); } else { debugPrint("Null Response"); return null; } } catch (e) { debugPrint('hello bev=bug $e '); return null; } } static Future crmLeadDetailsAddContactAPI( empId, session, acc_id, name, mob1, designation, mob2, tel, email, ) async { try { Map data = { 'emp_id': (empId).toString(), 'session_id': (session).toString(), 'acc_id': (acc_id).toString(), 'name': (name).toString(), 'mob1': (mob1).toString(), 'designation': (designation).toString(), 'mob2': (mob2).toString(), 'tel': (tel).toString(), 'email': (email).toString(), }; final res = await post(data, crmLeadDetailsAddContactUrl, {}); if (res != null) { print(data); debugPrint("crmLeadDetailsAddContactAPI${res.body}"); return CommonResponse.fromJson(jsonDecode(res.body)); } else { debugPrint("Null Response"); return null; } } catch (e) { debugPrint('hello bev=bug $e '); return null; } } static Future crmLeadDetailsEditContactAPI( empId, session, contact_id, name, mob1, designation, mob2, tel, email, ) async { try { Map data = { 'emp_id': (empId).toString(), 'session_id': (session).toString(), 'contact_id': (contact_id).toString(), 'name': (name).toString(), 'mob1': (mob1).toString(), 'designation': (designation).toString(), 'mob2': (mob2).toString(), 'tel': (tel).toString(), 'email': (email).toString(), }; final res = await post(data, crmLeadDetailsEditContactUrl, {}); if (res != null) { print(data); debugPrint("crmLeadDetailsEditContactAPI ${res.body}"); return CommonResponse.fromJson(jsonDecode(res.body)); } else { debugPrint("Null Response"); return null; } } catch (e) { debugPrint('hello bev=bug $e '); return null; } } static Future crmLeadDetailsAddAppointmentAPI( empId, session, lead_id, appointment_date, type, note, ) async { try { Map data = { 'emp_id': (empId).toString(), 'session_id': (session).toString(), 'lead_id': (lead_id).toString(), 'appointment_date': (appointment_date).toString(), 'type': (type).toString(), 'note': (note).toString(), }; final res = await post(data, crmLeadDetailsAddAppointmentUrl, {}); if (res != null) { print(data); debugPrint(res.body); return CommonResponse.fromJson(jsonDecode(res.body)); } else { debugPrint("Null Response"); return null; } } catch (e) { debugPrint('hello bev=bug $e '); return null; } } static Future crmLeadDetailsGenerateQuotationViewAPI(empId, session, lead_id) async { try { Map data = { 'emp_id': (empId).toString(), 'session_id': (session).toString(), 'lead_id': (lead_id).toString(), }; final res = await post(data, crmLeadDetailsGenerateQuotationViewUrl, {}); if (res != null) { print(data); debugPrint("ListView1: ${res.body}"); return crmLeadDetailsGenerateQuotationViewResponse.fromJson( jsonDecode(res.body), ); } else { debugPrint("Null Response"); return null; } } catch (e) { debugPrint('hello bev=bug $e '); return null; } } static Future crmLeadDetailsGenerateQuotationSubmitAPI( emp_id, session_id, lead_id, quotemno, quotesubject, taxes, quotenote, quotefor, quotep_terms, quotemail, quote_products, quotation_type, ) async { try { Map data = { 'emp_id': emp_id.toString(), 'session_id': session_id.toString(), 'lead_id': lead_id.toString(), 'quotemno': quotemno.toString(), 'quotesubject': quotesubject.toString(), 'taxes': taxes.toString(), 'quotenote': quotenote.toString(), 'quotefor': quotefor.toString(), 'quotep_terms': quotep_terms.toString(), 'quotemail': quotemail.toString(), 'quote_products': jsonEncode(quote_products).toString(), 'quotation_type': quotation_type.toString(), }; final res = await post( data, crmLeadDetailsGenerateQuotationSubmitUrl, {}, ); if (res != null) { print("Filter: ${data}"); debugPrint(res.body); return crmLeadDetailsGenerateQuotationSubmitResponse.fromJson( jsonDecode(res.body), ); } else { debugPrint("Null Response"); return null; } } catch (e) { debugPrint('hello bev=bug $e '); return null; } } static Future crmDownloadGenQuoteAPI( emp_id, session_id, lead_id, quote_id, quotation_type, ) async { try { Map data = { 'emp_id': emp_id.toString(), 'session_id': session_id.toString(), 'lead_id': lead_id.toString(), 'quote_id': quote_id.toString(), 'quotation_type': quotation_type.toString(), }; final res = await post( data, crmDownloadGeneratedQuotationUrl, {}, ); if (res != null) { print("Filter: ${data}"); debugPrint(res.body); return crmDownloadGenQuoteResponse.fromJson( jsonDecode(res.body), ); } else { debugPrint("Null Response"); return null; } } catch (e) { debugPrint('hello bev=bug $e '); return null; } } static Future crmProspectListViewAPI( empId, session, mode, ) async { try { Map data = { 'emp_id': (empId).toString(), 'session_id': (session).toString(), 'mode': (mode).toString(), }; final res = await post(data, crmProspectListViewUrl, {}); if (res != null) { print(data); debugPrint("ListView3: ${res.body}"); return ProspectListViewResponse.fromJson(jsonDecode(res.body)); } else { debugPrint("Null Response"); return null; } } catch (e) { debugPrint('hello bev=bug $e '); return null; } } static Future crmProspectListFilterSubmitAPI( empId, session, mode, teamemployee, mob, company_name, ) async { try { Map data = { 'emp_id': (empId).toString(), 'session_id': (session).toString(), 'mode': (mode).toString(), 'teamemployee': teamemployee.toString(), 'mob': mob.toString(), 'company_name': company_name.toString(), }; final res = await post(data, crmProspectListFilterSubmitUrl, {}); if (res != null) { print("Filter:${data}"); debugPrint(res.body); return SubmitProspectListFilterResponse.fromJson(jsonDecode(res.body)); } else { debugPrint("Null Response"); return null; } } catch (e) { debugPrint('hello bev=bug $e '); return null; } } static Future crmProspectDetailsAPI( empId, session, account_id, ) async { try { Map data = { 'emp_id': (empId).toString(), 'session_id': (session).toString(), 'account_id': (account_id).toString(), }; final res = await post(data, crmProspectDetailsUrl, {}); if (res != null) { print("Filter:${data}"); debugPrint(res.body); return crmProspectDetailsResponse.fromJson(jsonDecode(res.body)); } else { debugPrint("Null Response"); return null; } } catch (e) { debugPrint('hello bev=bug $e '); return null; } } static Future crmProspectDetailsTransferAccountAPI( empId, session, account_id, tranemp_id, ) async { try { Map data = { 'emp_id': (empId).toString(), 'session_id': (session).toString(), 'account_id': (account_id).toString(), 'tranemp_id': (tranemp_id).toString(), }; final res = await post(data, crmProspectDetailsTransferAccountUrl, {}); if (res != null) { print("Filter:${data}"); debugPrint(res.body); return CommonResponse.fromJson(jsonDecode(res.body)); } else { debugPrint("Null Response"); return null; } } catch (e) { debugPrint('hello bev=bug $e '); return null; } } static Future crmProspectDetailsEditAccountViewAPI(empId, session, account_id) async { try { Map data = { 'emp_id': (empId).toString(), 'session_id': (session).toString(), 'account_id': (account_id).toString(), }; final res = await post(data, crmProspectDetailsEditAccountViewUrl, {}); if (res != null) { print("Filter:${data}"); print("Stetets:${jsonDecode(res.body)['states']}"); return crmProspectDetailsEditAccountViewResponse.fromJson( jsonDecode(res.body), ); } else { debugPrint("Null Response"); return null; } } catch (e) { debugPrint('hello bev=bug $e '); return null; } } static Future crmProspectDetailsEditAccountSubmitAPI( empId, session, account_id, edit_company_name, edit_salutation_name, state_id, district, sub_locality, pincode, address, ) async { try { Map data = { 'emp_id': (empId).toString(), 'session_id': (session).toString(), 'account_id': (account_id).toString(), 'edit_company_name': edit_company_name.toString(), 'edit_salutation_name': edit_salutation_name.toString(), 'state_id': state_id.toString(), 'district': district.toString(), 'sub_locality': sub_locality.toString(), 'pincode': pincode.toString(), 'address': address.toString(), }; final res = await post(data, crmProspectDetailsEditAccountSubmitUrl, {}); if (res != null) { print("Filter:${data}"); debugPrint(res.body); return CommonResponse.fromJson(jsonDecode(res.body)); } else { debugPrint("Null Response"); return null; } } catch (e) { debugPrint('hello bev=bug $e '); return null; } } static Future crmProspectDetailsAddLeadViewAPI(empId, session, mode) async { try { Map data = { 'emp_id': (empId).toString(), 'session_id': (session).toString(), 'mode': (mode).toString(), }; final res = await post(data, crmProspectDetailsAddLeadViewUrl, {}); if (res != null) { print("Filter:${data}"); debugPrint(res.body); return crmProspectDetailsAddLeadsResponse.fromJson( jsonDecode(res.body), ); } else { debugPrint("Null Response"); return null; } } catch (e) { debugPrint('hello bev=bug $e '); return null; } } static Future crmProspectDetailsAddLeadSubmitAPI( empId, session, mode, account_id, acc_manager_id, products, lead_status, ) async { try { Map data = { 'emp_id': (empId).toString(), 'session_id': (session).toString(), 'mode': (mode).toString(), 'account_id': account_id.toString(), 'acc_manager_id': acc_manager_id.toString(), 'products': jsonEncode(products).toString(), 'lead_status': lead_status.toString(), }; final res = await post(data, crmProspectDetailsAddLeadSubmitUrl, {}); if (res != null) { print("Filter:${data}"); debugPrint(res.body); return CommonResponse.fromJson(jsonDecode(res.body)); } else { debugPrint("Null Response"); return null; } } catch (e) { debugPrint('hello bev=bug $e '); return null; } } static Future crmProspectDetailsAddLeadAPI( empId, session, account_id, product_id, quantity, amount, lead_status, ) async { try { Map data = { 'emp_id': (empId).toString(), 'session_id': (session).toString(), 'account_id': account_id.toString(), 'product_id': product_id.toString(), 'quantity': quantity.toString(), 'amount': amount.toString(), 'lead_status': lead_status.toString(), }; final res = await post(data, crmProspectDetailsAddLeadUrl, {}); if (res != null) { print("crmProspectDetailsAddLead:${data}"); debugPrint(res.body); return CommonResponse.fromJson(jsonDecode(res.body)); } else { debugPrint("Null Response"); return null; } } catch (e) { debugPrint('hello bev=bug $e '); return null; } } static Future crmProspectDetailsAddAccountAPI( empId, session, name, acc_id, mob1, designation, email, tel, mob2, ) async { try { Map data = { 'emp_id': (empId).toString(), 'session_id': (session).toString(), 'name': name.toString(), 'acc_id': acc_id.toString(), 'mob1': mob1.toString(), 'designation': designation.toString(), 'email': email.toString(), 'tel': tel.toString(), 'mob2': mob2.toString(), }; final res = await post(data, crmProspectDetailsAddAccountUrl, {}); if (res != null) { print("crmProspectDetailsAddAccountAPI:${data}"); debugPrint(res.body); return CommonResponse.fromJson(jsonDecode(res.body)); } else { debugPrint("Null Response"); return null; } } catch (e) { debugPrint('hello bev=bug $e '); return null; } } static Future crmProspectDetailsEditContactAPI( empId, session, contact_id, name, acc_id, mob1, mob2, tel, designation, email, ) async { try { Map data = { 'emp_id': (empId).toString(), 'session_id': (session).toString(), 'contact_id': (contact_id).toString(), 'name': name.toString(), 'acc_id': acc_id.toString(), 'mob1': mob1.toString(), 'mob2': mob2.toString(), 'tel': tel.toString(), 'designation': designation.toString(), 'email': email.toString(), }; final res = await post(data, crmProspectDetailsEditContactUrl, {}); if (res != null) { print("Filter:${data}"); debugPrint(res.body); return CommonResponse.fromJson(jsonDecode(res.body)); } else { debugPrint("Null Response"); return null; } } catch (e) { debugPrint('hello bev=bug $e '); return null; } } static Future crmProspectDetailsFollowupNextAppointmentAPI( empId, session, nextapp, orderstatus, lead_id, followup_feedback, followup_type, followupintime, loc, followup_status, ) async { try { Map data = { 'emp_id': (empId).toString(), 'session_id': (session).toString(), 'nextapp': nextapp.toString(), 'orderstatus': orderstatus.toString(), 'lead_id': lead_id.toString(), 'followup_feedback': followup_feedback.toString(), 'followup_type': followup_type.toString(), 'followupintime': followupintime.toString(), 'loc': loc.toString(), 'followup_status': followup_status.toString(), }; final res = await post( data, crmProspectDetailsFollowupNextAppointmentUrl, {}, ); if (res != null) { print("Filter:${data}"); debugPrint(res.body); return crmProspectDetailsAddFollowUpAppointmentResponse.fromJson( jsonDecode(res.body), ); } else { debugPrint("Null Response"); return null; } } catch (e) { debugPrint('hello bev=bug $e '); return null; } } static Future crmAppointmentCalendarAPI( empId, session, appointment_date, type, ) async { try { Map data = { 'emp_id': (empId).toString(), 'session_id': (session).toString(), 'appointment_date': (appointment_date).toString(), 'type': (type).toString(), }; final res = await post(data, crmAppointmentCalendarUrl, {}); if (res != null) { print("appointmentCalendar: ${data}"); debugPrint(res.body); return appointmentCalendarResponse.fromJson(jsonDecode(res.body)); } else { debugPrint("Null Response"); return null; } } catch (e) { debugPrint('hello bev=bug $e '); return null; } } static Future crmSelectedProductDetailsApi( empId, session, product_id, ) async { try { Map data = { 'emp_id': (empId).toString(), 'session_id': (session).toString(), 'product_id': (product_id).toString(), }; final res = await post(data, crmSelectedProductDetailsUrl, {}); if (res != null) { print("crmSelectedProductDetailsApi: ${data}"); debugPrint(res.body); return crmSelectedProductDetailsResponse.fromJson(jsonDecode(res.body)); } else { debugPrint("Null Response"); return null; } } catch (e) { debugPrint('hello bev=bug $e '); return null; } } static Future crmCheckAccountFieldsApi( empId, session, type_value, type, ) async { try { Map data = { 'emp_id': (empId).toString(), 'session_id': (session).toString(), 'type_value': (type_value).toString(), 'type': (type).toString(), }; final res = await post(data, crmCheckAccountFieldsUrl, {}); if (res != null) { print("crmCheckAccountFieldsApi: ${data}"); debugPrint(res.body); return CommonResponse.fromJson(jsonDecode(res.body)); } else { debugPrint("Null Response"); return null; } } catch (e) { debugPrint('hello bev=bug $e '); return null; } } static Future crmProspectDetailsFollowupNextAppointmentOtherCaseAPI( empId, session, nextapp, orderstatus, lead_id, followup_feedback, followup_type, followupintime, loc, followup_status, appointmentset, app_date, sms, app_note, in_t, ) async { try { Map data = { 'emp_id': (empId).toString(), 'session_id': (session).toString(), 'nextapp': nextapp.toString(), 'orderstatus': orderstatus.toString(), 'lead_id': lead_id.toString(), 'followup_feedback': followup_feedback.toString(), 'followup_type': followup_type.toString(), 'followupintime': followupintime.toString(), 'loc': loc.toString(), 'followup_status': followup_status.toString(), 'appointmentset': appointmentset.toString(), 'app_date': app_date.toString(), 'sms': sms.toString(), 'app_note': app_note.toString(), 'in_t': in_t.toString(), }; final res = await post( data, crmProspectDetailsFollowupNextAppointmentUrl, {}, ); if (res != null) { print("Filter:${data}"); debugPrint(res.body); return CommonResponse.fromJson(jsonDecode(res.body)); } else { debugPrint("Null Response"); return null; } } catch (e) { debugPrint('hello bev=bug $e '); return null; } } static Future loadNearbyOpenLeadsAPI( empId, session, emp_loc, radius, ) async { try { Map data = { 'emp_id': (empId).toString(), 'session_id': (session).toString(), 'emp_loc': (emp_loc).toString(), 'radius': radius.toString(), }; final res = await post(data, crmNearbyOpenLeadsUrl, {}); if (res != null) { print(data); debugPrint(res.body); return NearbyOpenLeadsResponse.fromJson(jsonDecode(res.body)); } else { debugPrint("Null Response"); return null; } } catch (e) { debugPrint('hello bev=bug $e '); return null; } } static Future crmDashboardFollowUpAPI( empId, session, type, ) async { try { Map data = { 'emp_id': (empId).toString(), 'session_id': (session).toString(), 'type': (type).toString(), }; final res = await post(data, crmDashboardFollowUpUrl, {}); if (res != null) { print(data); debugPrint(res.body); return crmDashboardFollowUpResponse.fromJson(jsonDecode(res.body)); } else { debugPrint("Null Response"); return null; } } catch (e) { debugPrint('hello bev=bug $e '); return null; } } static Future crmDashboardQuotationsAPI( empId, session, ) async { try { Map data = { 'emp_id': (empId).toString(), 'session_id': (session).toString(), }; final res = await post(data, crmDashboardQuotationsUrl, {}); if (res != null) { print(data); debugPrint(res.body); return crmDashboardQuotationResponse.fromJson(jsonDecode(res.body)); } else { debugPrint("Null Response"); return null; } } catch (e) { debugPrint('hello bev=bug $e '); return null; } } ///hrm modules /// /// static Future ogChartAPI( empId, session, ) async { try { Map data = { 'emp_id': (empId).toString(), 'session_id': (session).toString(), }; final res = await post(data, ogcharturl, {}); if (res != null) { print(data); debugPrint(res.body); return ogresponse.fromJson(jsonDecode(res.body)); } else { debugPrint("Null Response"); return null; } } catch (e) { debugPrint('hello bev=bug $e '); return null; } } static Future jobDescriptAPI( empId, session, ) async { try { Map data = { 'session_id': (session).toString(), 'emp_id': (empId).toString(), }; final res = await post(data, JobDesciptionUrl, {}); if (res != null) { print(data); debugPrint(res.body); return jobDescriptionResponse.fromJson(jsonDecode(res.body)); } else { debugPrint("Null Response"); return null; } } catch (e) { debugPrint('hello bev=bug $e '); return null; } } static Future hrmAccessiblePagesAPI( empId, session, ) async { try { Map data = { 'emp_id': (empId).toString(), 'session_id': (session).toString(), }; final res = await post(data, HrmAccessiblePagesUrl, {}); if (res != null) { print(data); debugPrint(res.body); return hrmAccessiblePagesResponse.fromJson(jsonDecode(res.body)); } else { debugPrint("Null Response"); return null; } } catch (e) { debugPrint('hello bev=bug $e '); return null; } } static Future attendanceRequestListAPI( empId, session, type, from, to, mode ) async { try { Map data = { 'emp_id': (empId).toString(), 'session_id': (session).toString(), 'mode': (mode), 'type': (type), 'from': (from), 'to': (to), }; final res = await post(data, AttendanceRequestListUrl, {}); if (res != null) { print(data); debugPrint(res.body); return attendanceRequestListResponse.fromJson(jsonDecode(res.body)); } else { debugPrint("Null Response"); return null; } } catch (e) { debugPrint('hello bev=bug $e '); return null; } } static Future attendanceRequestDetailAPI( empId, session, attendanceRequestId, ) async { try { Map data = { 'emp_id': (empId).toString(), 'session_id': (session).toString(), 'attendance_request_id': (attendanceRequestId), }; final res = await post(data, AttendanceRequestDetailsUrl, {}); if (res != null) { print(data); debugPrint(res.body); return attendanceRequestDetailsResponse.fromJson(jsonDecode(res.body)); } else { debugPrint("Null Response"); return null; } } catch (e) { debugPrint('hello bev=bug $e '); return null; } } static Future attendanceRequestApproveRejectAPI( session, empId, mode, type, remarks, id, ) async { try { Map data = { 'session_id': (session).toString(), 'emp_id': (empId).toString(), 'mode': (mode).toString(), 'type': (type).toString(), 'remarks': (remarks).toString(), 'id': (id).toString(), }; final res = await post(data, AttendanceRequestRejectUrl, {}); if (res != null) { print("Attendance App Reje:${data}"); debugPrint(res.body); return CommonResponse.fromJson(jsonDecode(res.body)); } else { debugPrint("Null Response"); return null; } } catch (e) { debugPrint('hello bev=bug $e '); return null; } } static Future addAttendanceRequestAPI({ required String sessionId, required String empId, required String process, required String type, required String loc, required String checkDate, String? checkInTime, String? checkInLoc, File? checkInProof, String? checkOutTime, String? checkOutLoc, File? checkOutProof, String? note, }) async { try { var request = http.MultipartRequest('POST', Uri.parse(AddAttendanceRequestUrl)); // Add basic fields that are always required Map fields = { "session_id": sessionId, "emp_id": empId, "process": process, "type": type, "loc": loc, "check_date": checkDate, "note": note ?? "", }; // Conditionally add check-in fields based on type if (type == "Check In" || type == "Check In/Out") { fields["check_in_time"] = checkInTime ?? ""; fields["check_in_loc"] = checkInLoc ?? ""; if (checkInProof != null) { request.files.add(await http.MultipartFile.fromPath("check_in_proof", checkInProof.path)); } } // Conditionally add check-out fields based on type if (type == "Check Out" || type == "Check In/Out") { fields["check_out_time"] = checkOutTime ?? ""; fields["check_out_loc"] = checkOutLoc ?? ""; if (checkOutProof != null) { request.files.add(await http.MultipartFile.fromPath("check_out_proof", checkOutProof.path)); } } // Add all fields to the request request.fields.addAll(fields); // Log the actual fields being sent debugPrint("addAttendanceRequestAPI - Type: $type"); debugPrint("addAttendanceRequestAPI - Fields: $fields"); debugPrint("addAttendanceRequestAPI - Files: ${request.files.map((f) => f.filename).toList()}"); var response = await request.send(); var resBody = await response.stream.bytesToString(); debugPrint("Server Response: $resBody"); if (response.statusCode == 200) { return CommonResponse.fromJson(jsonDecode(resBody)); } else { return null; } } catch (e) { debugPrint("API Error: $e"); return null; } } //reward list static Future rewardListAPI( empId, session, ) async { try { Map data = { 'session_id': (session).toString(), 'emp_id': (empId).toString(), }; final res = await post(data, RewardListUrl, {}); if (res != null) { print(data); debugPrint(res.body); return rewardListResponse.fromJson(jsonDecode(res.body)); } else { debugPrint("Null Response"); return null; } } catch (e) { debugPrint('hello bev=bug $e '); return null; } } //tour exp static Future tourExpensesListAPI( empId, session, pageNumber, ) async { try { Map data = { 'session_id': (session).toString(), 'emp_id': (empId).toString(), 'page_number': (pageNumber), }; final res = await post(data, TourExpensesListUrl, {}); if (res != null) { print(data); debugPrint(res.body); return tourExpensesListResponse.fromJson(jsonDecode(res.body)); } else { debugPrint("Null Response"); return null; } } catch (e) { debugPrint('hello bev=bug $e '); return null; } } static Future tourExpensesDetailAPI( session, empId, tourBillId, ) async { try { Map data = { 'session_id': (session).toString(), 'emp_id': (empId).toString(), 'tour_bill_id': (tourBillId), }; final res = await post(data, TourExpensesDetailsUrl, {}); if (res != null) { print(data); debugPrint(res.body); return tourExpensesDetailsResponse.fromJson(jsonDecode(res.body)); } else { debugPrint("Null Response"); return null; } } catch (e) { debugPrint('hello bev=bug $e '); return null; } } static Future tourExpensesAddViewAPI( empId, session, tourBillId, ) async { try { Map data = { 'session_id': (session).toString(), 'emp_id': (empId).toString(), 'tour_bill_id': (tourBillId), }; final res = await post(data, TourExpensesAddViewUrl, {}); if (res != null) { print(data); debugPrint(res.body); return tourExpensesAddViewResponse.fromJson(jsonDecode(res.body)); } else { debugPrint("Null Response"); return null; } } catch (e) { debugPrint('hello bev=bug $e '); return null; } } static Future addTourBillAPI({ required String sessionId, required String empId, required String placeOfVisit, required String daAmount, required String tourType, required String tourDate, required List> travelExpenses, required List> hotelExpenses, required List> otherExpenses, List? travelImages, List? hotelImages, List? otherImages, }) async { try { var request = http.MultipartRequest("POST", Uri.parse(AddTourExpensesUrl)); /// Add text fields request.fields['session_id'] = sessionId; request.fields['emp_id'] = empId; request.fields['place_of_visit'] = placeOfVisit; request.fields['da_amount'] = daAmount; request.fields['tour_type'] = tourType; request.fields['tour_date'] = tourDate; /// Convert expense lists to JSON string request.fields['travel_expenses'] = jsonEncode(travelExpenses); request.fields['hotel_expenses'] = jsonEncode(hotelExpenses); request.fields['other_expenses'] = jsonEncode(otherExpenses); /// Add hotel images if (hotelImages!.isNotEmpty) { for (var file in hotelImages) { if (file.path.isNotEmpty) { request.files.add( await http.MultipartFile.fromPath( "hotel_image[]", file.path, ), ); } } } /// Add travel images if (travelImages!.isNotEmpty) { for (var file in travelImages) { if (file.path.isNotEmpty) { request.files.add( await http.MultipartFile.fromPath( "travel_image[]", file.path, ), ); } } } /// Add other images if (otherImages!.isNotEmpty) { for (var file in otherImages) { if (file.path.isNotEmpty) { request.files.add( await http.MultipartFile.fromPath( "other_image[]", file.path, ), ); } } } /// Send request var response = await request.send(); var resBody = await response.stream.bytesToString(); debugPrint("Request Fields: ${request.fields}"); debugPrint("Response: $resBody"); if (response.statusCode == 200) { return CommonResponse.fromJson(jsonDecode(resBody)); } else { debugPrint("Error: ${response.statusCode} - $resBody"); return null; } } catch (e) { debugPrint("Error in addTourBillAPI: $e"); return null; } } // Leave Application api // Leave Application api static Future leaveApplicationListAPI( session, empId, dateFrom, dateTo, mode ) async { try { Map data = { 'session_id': (session).toString(), 'emp_id': (empId).toString(), 'requested_date_from': (dateFrom), 'requested_date_to': (dateTo), 'mode': (mode), }; final res = await post(data, LeaveApplicationListUrl, {}); if (res != null) { print(data); debugPrint(res.body); return leaveApplicationLIstResponse.fromJson(jsonDecode(res.body)); } else { debugPrint("Null Response"); return null; } } catch (e) { debugPrint('hello bev=bug $e '); return null; } } static Future leaveApplicationDetailAPI( session, empId, leaveRequestId, ) async { try { Map data = { 'session_id': (session).toString(), 'emp_id': (empId).toString(), 'leave_request_id': (leaveRequestId), }; final res = await post(data, LeaveApplicationDetailsUrl, {}); if (res != null) { print(data); debugPrint(res.body); return leaveApplicationDetailsResponse.fromJson(jsonDecode(res.body)); } else { debugPrint("Null Response"); return null; } } catch (e) { debugPrint('hello bev=bug $e '); return null; } } //add leave request static Future leaveRequestAddAPI( session, empId, fromDate, fromTime, toDate, toTime, leaveType, reason ) async { try { Map data = { 'session_id': (session).toString(), 'emp_id': (empId).toString(), 'from_date': (fromDate).toString(), 'from_time': (fromTime).toString(), 'to_date': (toDate).toString(), 'to_time': (toTime).toString(), 'leave_type': (leaveType).toString(), 'reason': (reason).toString(), }; final res = await post(data, LeaveRequestAdditionUrl, {}); if (res != null) { print(data); debugPrint(res.body); return CommonResponse.fromJson(jsonDecode(res.body)); } else { debugPrint("Null Response"); return null; } } catch (e) { debugPrint('hello bev=bug $e '); return null; } } static Future leaveRequestRejectApproveAPI( session, empId, mode, type, remarks, id, ) async { try { Map data = { 'session_id': (session).toString(), 'emp_id': (empId).toString(), 'mode': (mode).toString(), 'type': (type).toString(), 'remarks': (remarks).toString(), 'id': (id).toString(), }; final res = await post(data, LeaveRequestRejectAprroveUrl, {}); if (res != null) { print(data); debugPrint(res.body); return CommonResponse.fromJson(jsonDecode(res.body)); } else { debugPrint("Null Response"); return null; } } catch (e) { debugPrint('hello bev=bug $e '); return null; } } // static Future TpcIssueListApprovalAPI( // empId, // session, // tpc_payment_mode, // tpc_payment_reference_no, // order_id, // order_tpc_feedback, // tpc_paym_attachment // ) async { // try { // Map data = { // 'emp_id': (empId).toString(), // 'session_id': (session).toString(), // 'tpc_payment_mode':tpc_payment_mode.toString(), // 'tpc_payment_reference_no':tpc_payment_reference_no.toString(), // 'order_id':order_id.toString(), // 'order_tpc_feedback':order_tpc_feedback.toString(), // }; // var res; // if (tpc_paym_attachment != null) { // res = await postImageNew( // data, // {}, // ordersApprovePendingTPCIssueListUrl, // tpc_paym_attachment, // "tpc_paym_attachment", // ); // res = jsonDecode(res); // } else { // res = await post(data, ordersApprovePendingTPCIssueListUrl, {}); // res = jsonDecode(res.body); // return CommonResponse.fromJson(res); // } // } catch (e) { // debugPrint('hello bev=bug $e '); // return null; // } // } }