second commit

This commit is contained in:
Anbarasu
2026-05-27 10:35:09 +05:30
parent c53794c04c
commit 1435ac47b0
501 changed files with 52818 additions and 0 deletions

View File

@@ -0,0 +1,144 @@
import 'package:flutter/cupertino.dart';
import 'package:get/get.dart';
import 'package:rounded_loading_button_plus/rounded_loading_button.dart';
import 'package:shared_preferences/shared_preferences.dart';
import '../../../../Data/Repository/Staffs/Addstaff/Addstaffrepository.dart';
import '../../../../Data/Repository/Tenantlocation/Getlocationrepository.dart';
import '../../../../Helper/toast.dart';
import '../../../../Model/Request/Staffs/Addstaffs/Addstaffsrequest.dart';
import '../../../../Model/Response/Staffs/Addstaffs/Addstaffresponse.dart';
import '../../../../Model/Response/Tenantlocation/Getlocationbyidresponse.dart';
import '../../../../View/More/Staffs/Staffview.dart';
class AddStaffController extends GetxController{
String? locationName;
String? locationAddress;
String? locationSuburb;
String? locationCity;
String? locationState;
String? locationPostcode;
int?tenantId;
int?appLocationId;
int?partnerId;
RxInt locationId = 0.obs;
RxBool isLocation = false.obs;
RxBool progress = false.obs;
List<TenantLocationDetails>? tenantLocation;
final RoundedLoadingButtonController btnController = RoundedLoadingButtonController();
TextEditingController nameController = TextEditingController();
TextEditingController lastNameController = TextEditingController();
TextEditingController phoneNoController = TextEditingController();
TextEditingController emailController = TextEditingController();
GetLocationsRepository getLocationsRepository= GetLocationsRepository();
AddStaffRepository addStaffRepository = AddStaffRepository();
getLocation()async {
GetLocationByTenantId? result = await getLocationsRepository.getTenantLocationById();
tenantLocation = result?.details??[];
update();
print('resultgetLocation${result?.toJson()}');
}
describeValidation({bool isUpdate = false}) {
if (nameController.text.isEmpty) {
btnController.reset();
Toast.showToast("Please Enter first name");
// AwesomeHelper.createAwesome(title: "title", message: "message");
} else if (lastNameController.text.isEmpty) {
btnController.reset();
Toast.showToast("Please Enter last name");
} else if (phoneNoController.text.isEmpty) {
btnController.reset();
Toast.showToast("Please Enter contact no");
} else if (emailController.text.isEmpty) {
btnController.reset();
// Toast.showToast("Please enter email");
Toast.showToast("Please Enter email");
} else if (RegExp(
r"^[a-zA-Z0-9.a-zA-Z0-9.!#$%&'*+-/=?^_`{|}~]+@[a-zA-Z0-9]+\.[a-zA-Z]+")
.hasMatch(emailController.text) ==
false) {
btnController.reset();
// Toast.showToast("Enter valid email");
Toast.showToast("Please enter vaid email address");
} else if (locationId.value ==0) {
btnController.reset();
Toast.showToast("Please select location");
} else {
progress.value = true;
addStaff();
}
}
addStaff()async{
SharedPreferences prefs = await SharedPreferences.getInstance();
tenantId = prefs.getInt('tenantId');
appLocationId = prefs.getInt('appLocationId');
partnerId = prefs.getInt('partnerId');
addStaffsResult(
CreateStaffRequest(
userid:0,
authname:"${emailController.text}",
configid: 1,
contactno:"${phoneNoController.text}",
firstname:"${nameController.text}",
lastrname:"${lastNameController.text}",
email:"${emailController.text}",
address:"$locationAddress",
suburb:"$locationSuburb",
city:"$locationCity",
state:"$locationState",
postcode:"$locationPostcode",
roleid:2,
applocationid:appLocationId,
partnerid:partnerId,
tenantid:tenantId,
locationid:locationId.value
)
);
}
addStaffsResult(CreateStaffRequest data)async{
CreateStaffResponse? result = await addStaffRepository.addStaff(data);
if(result?.status == true){
Get.to(()=>StaffsView());
nameController.clear();
lastNameController.clear();
phoneNoController.clear();
emailController.clear();
locationId.value = 0;
}
}
@override
void onInit() {
// TODO: implement onInit
super.onInit();
}
}

View File

@@ -0,0 +1,29 @@
import 'package:get/get.dart';
import '../../../Data/Repository/Staffs/Getstaffsrepository.dart';
import '../../../Model/Response/Staffs/Getstaffsresponse.dart';
class StaffsController extends GetxController{
bool shimmer = true;
List<StaffDetails>getStaff = [];
GetStaffsRepository getStaffsRepository = GetStaffsRepository();
getStaffs()async{
GetStaffsResponse? result = await getStaffsRepository.getStaffs();
if(result?.status == true){
getStaff = result?.details??[];
shimmer = false;
update();
}
}
@override
void onInit() {
// TODO: implement onInit
super.onInit();
}
}

View File

@@ -0,0 +1,145 @@
import 'package:flutter/cupertino.dart';
import 'package:get/get.dart';
import 'package:rounded_loading_button_plus/rounded_loading_button.dart';
import '../../../../Data/Repository/Staffs/Updatestaff/Updatestaffrepository.dart';
import '../../../../Data/Repository/Tenantlocation/Getlocationrepository.dart';
import '../../../../Helper/toast.dart';
import '../../../../Model/Request/Staffs/UpdateStaff/Updatestaffrequest.dart';
import '../../../../Model/Response/Staffs/Getstaffsresponse.dart';
import '../../../../Model/Response/Staffs/Updatestaff/Updatestaffresponse.dart';
import '../../../../Model/Response/Tenantlocation/Getlocationbyidresponse.dart';
import '../../../../View/More/Staffs/Staffview.dart';
class UpdateStaffController extends GetxController{
String? locationName;
String? locationAddress;
String? locationSuburb;
String? locationCity;
String? locationState;
String? locationPostcode;
int?tenantId;
int?appLocationId;
int?partnerId;
int?userId;
int?roleId;
RxInt locationId = 0.obs;
RxBool isLocation = false.obs;
RxBool progress = false.obs;
StaffDetails? staffData;
List<TenantLocationDetails>? tenantLocation;
TextEditingController nameController = TextEditingController();
TextEditingController lastNameController = TextEditingController();
TextEditingController phoneNoController = TextEditingController();
TextEditingController emailController = TextEditingController();
GetLocationsRepository getLocationsRepository= GetLocationsRepository();
UpdateStaffRepository updateStaffRepository = UpdateStaffRepository();
final RoundedLoadingButtonController btnController = RoundedLoadingButtonController();
setValues(){
nameController.text = staffData?.firstname??'';
lastNameController.text = staffData?.lastname??'';
phoneNoController.text = staffData?.contactno??'';
emailController.text = staffData?.email??'';
locationId.value = staffData?.locationid??0;
tenantId = staffData?.tenantid??0;
appLocationId = staffData?.applocationid??0;
partnerId = staffData?.partnerid??0;
userId = staffData?.userid??0;
roleId = staffData?.roleid??0;
update();
}
getLocation()async {
GetLocationByTenantId? result = await getLocationsRepository.getTenantLocationById();
tenantLocation = result?.details??[];
update();
print('resultgetLocation${result?.toJson()}');
}
describeValidation({bool isUpdate = false}) {
if (nameController.text.isEmpty) {
btnController.reset();
Toast.showToast("Please Enter first name");
// AwesomeHelper.createAwesome(title: "title", message: "message");
} else if (lastNameController.text.isEmpty) {
btnController.reset();
Toast.showToast("Please Enter last name");
} else if (phoneNoController.text.isEmpty) {
btnController.reset();
Toast.showToast("Please Enter contact no");
} else if (emailController.text.isEmpty) {
btnController.reset();
// Toast.showToast("Please enter email");
Toast.showToast("Please Enter email");
} else if (RegExp(
r"^[a-zA-Z0-9.a-zA-Z0-9.!#$%&'*+-/=?^_`{|}~]+@[a-zA-Z0-9]+\.[a-zA-Z]+")
.hasMatch(emailController.text) ==
false) {
btnController.reset();
// Toast.showToast("Enter valid email");
Toast.showToast("Please enter vaid email address");
} else if (locationId.value ==0) {
btnController.reset();
Toast.showToast("Please select location}");
} else {
progress.value = true;
updateStaff();
}
}
updateStaff()async {
updateStaffResult(
UpdateStaffRequest(
userid:userId,
authname:"${emailController.text}",
configid: 1,
contactno:"${phoneNoController.text}",
firstname:"${nameController.text}",
lastrname:"${lastNameController.text}",
email:"${emailController.text}",
address:"$locationAddress",
suburb:"$locationSuburb",
city:"$locationCity",
state:"$locationState",
postcode:"$locationPostcode",
roleid:roleId,
applocationid:appLocationId,
partnerid:partnerId,
tenantid:tenantId,
locationid:locationId.value
)
);
}
updateStaffResult(UpdateStaffRequest data)async{
UpdateStaffResponse? result = await updateStaffRepository.updateStaff(data);
if(result?.status == true){
Get.to(()=>StaffsView());
}
}
@override
void onInit() {
// TODO: implement onInit
super.onInit();
}
}