View Freight Bill GRN Details

feature_dev_ankit
Ankit Sharma 2025-02-05 14:05:35 +05:30
commit e4ad29f845
27 changed files with 2247 additions and 2323 deletions

View File

@ -254,7 +254,7 @@
"languageVersion": "3.6"
}
],
"generated": "2025-02-05T07:53:21.908016Z",
"generated": "2025-02-05T08:21:07.654873Z",
"generator": "pub",
"generatorVersion": "3.6.1",
"flutterRoot": "file:///C:/src/flutter/flutter",

View File

@ -194,7 +194,7 @@ class _CustomDropdownState<T> extends State<CustomDropdown<T>> {
message: widget.itemLabel(item),
child: Text(
widget.itemLabel(item),
style: 12.txtSBoldGrey,
style: 11.txtSBoldGrey,
),
),
onTap: () => _selectItem(item),
@ -278,9 +278,16 @@ class _CustomDropdownState<T> extends State<CustomDropdown<T>> {
selectedItem != null
? widget.itemLabel(selectedItem as T)
: widget.hintText,
style: 12.txtSBoldGrey,
style: 11.txtSBoldGrey,
overflow: TextOverflow.ellipsis,
),
// Text(
// selectedItem != null
// ? widget.itemLabel(selectedItem as T)
// : widget.hintText,
// style: 12.txtSBoldGrey,
// overflow: TextOverflow.ellipsis,
// ),
),
const Icon(
Icons.keyboard_arrow_down_outlined,

View File

@ -4,18 +4,26 @@ import 'package:shayog/components/styles/textStyles.dart';
DataCell editableCell(int index, String? value,
{bool isLink = false, VoidCallback? onTap}) {
return DataCell(
GestureDetector(
onTap: isLink && onTap != null ? onTap : null,
child: MouseRegion(
cursor: isLink ? SystemMouseCursors.click : SystemMouseCursors.basic,
child: Text(
value ?? "",
textAlign: TextAlign.center,
maxLines: 2,
style: isLink ? 11.txtSBoldBlue : 11.txtSBoldBlack,
child: Container(
alignment: Alignment.center,
child: MouseRegion(
cursor: isLink ? SystemMouseCursors.click : SystemMouseCursors.basic,
child: Center(
child: Text(
value ?? "",
textAlign: TextAlign.center,
maxLines: 2,
style: isLink ? 11.txtSBoldBlue : 11.txtSBoldBlack,
),
),
),
),
),
);
}

View File

@ -7,14 +7,16 @@ import '../../../components/styles/app_colors.dart';
class InputField extends StatelessWidget {
InputField(
{super.key,
this.title,
this.controller,
this.inputFormatter,
this.onChanged,
this.onFieldSubmitted,
this.validator,
this.edgesInsects,
this.underLineBorder,this.maxLength});
this.title,
this.controller,
this.inputFormatter,
this.onChanged,
this.onFieldSubmitted,
this.validator,
this.edgesInsects,
this.errorTxtColor,
this.underLineBorder,
this.maxLength});
String? title;
OutlineInputBorder? underLineBorder;
@ -25,6 +27,8 @@ class InputField extends StatelessWidget {
List<TextInputFormatter>? inputFormatter;
EdgeInsets? edgesInsects;
int? maxLength;
Color? errorTxtColor;
var inputBorder = OutlineInputBorder(
borderRadius: BorderRadius.circular(2.0),
borderSide: BorderSide(color: AppColors.clrGrey));
@ -36,11 +40,11 @@ class InputField extends StatelessWidget {
Widget build(BuildContext context) {
return TextFormField(
controller: controller,
contextMenuBuilder: (context, editableTextState) {
return Container(height: 0, color: Colors.transparent);
},
// contextMenuBuilder: (context, editableTextState) {
// return Container(height: 0, color: Colors.transparent);
// },
style: 12.txtSBoldBlack,
maxLength: maxLength,
maxLength: maxLength,
decoration: InputDecoration(counterText: '',
@ -60,10 +64,10 @@ class InputField extends StatelessWidget {
labelStyle: 12.txtSBoldGrey,
fillColor: AppColors.clrD9,
errorStyle: TextStyle(
fontSize: 10.0,
// height: 0.2,
),
// errorText: "",
errorStyle: TextStyle(fontSize: 10.0, color: errorTxtColor
// height: 0.2,
),
),
inputFormatters: inputFormatter,
validator: validator,

View File

@ -10,4 +10,5 @@ static Color clrF2 = Color(0xffF2F2F2);
static Color black = Color(0xff000000);
static Color white = Color(0xffFFFFFF);
static Color green = Color(0xff10A711);
static Color red = Colors.red;
}

View File

@ -27,6 +27,7 @@ extension TextStyles on num{
TextStyle get txtSBoldGrey => _textStyle(this,AppColors.darkGrey,Family.semiBold);
TextStyle get txtSBoldBlue => _textStyle(this,AppColors.primaryClr,Family.semiBold);
TextStyle get txtSBoldRed => _textStyle(this,Colors.red,Family.semiBold);
TextStyle get txtTransparent => _textStyle(this,Colors.transparent,Family.semiBold);
TextStyle get txtSBoldWhite => _textStyle(this,Colors.white,Family.semiBold);

View File

@ -1,6 +1,7 @@
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:shayog/components/common/common_button.dart';
import 'package:shayog/components/styles/textStyles.dart';
import 'package:shayog/feature/presentation/widgets/text_view.dart';
import '../../../../../../components/common/common_btn.dart';
import '../../../../../../components/common/custom_drop_down.dart';
@ -20,259 +21,234 @@ class AddInternalUser extends StatelessWidget {
return Container(
padding: EdgeInsets.all(16),
color: AppColors.clrF2,
child: Stack(
children: [
Form(
key: controller.formKey,
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
// Obx(
// () => Column(
// crossAxisAlignment: CrossAxisAlignment.start,
// children: [
// CustomDropdown<String>(
// items: ['Item 1', 'Item 2', 'Item 3'],
// itemLabel: (item) => item,
// onSelected: (selected) {
// if (selected != null) {
// controller.selectedItem.value = selected;
// }
// },
// hintText: 'Select an item',
// ),
// controller.showE.value == true &&
// controller.selectedItem.value == ''
// ? Column(
// crossAxisAlignment: CrossAxisAlignment.start,
// mainAxisAlignment: MainAxisAlignment.start,
// children: [
// const SizedBox(
// height: 4,
// ),
// Text(
// 'Please Select an option',
// style: TextStyle(
// color: Colors.red, fontSize: 10),
// ),
// ],
// )
// : Text(''),
// ],
// ),
// ),
Row(
children: [
Expanded(
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
TextView(
text: AppStrings.firstName,isRequired: true,
),
SizedBox(height: 8),
InputField(
validator: Validations.checkValidations,
controller: controller.nameCtrl,
title: AppStrings.enterFirstName,
),
],
)),
SizedBox(width: 16),
Expanded(
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
TextView(
text: AppStrings.lastName,isRequired: true,
),
SizedBox(height: 8),
InputField(
validator: Validations.checkValidations,
controller: controller.lastNCtrl,
title: AppStrings.enterLastName,
),
],
)),
SizedBox(width: 16),
Expanded(
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
TextView(
text: AppStrings.employeeCode,isRequired: true,
),
SizedBox(height: 8),
InputField(
validator: Validations.checkValidations,
controller: controller.employeeCodeCtrl,
title: AppStrings.enterEmployeeCode,
),
],
)),
],
),
Padding(
padding: const EdgeInsets.only(top: 16.0),
child: Row(
child: allData(),
);
}
allData() {
return Column(
children: [
Form(
key: controller.formKey,
//autovalidateMode: AutovalidateMode.onUserInteraction,
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
children: [
Expanded(
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Expanded(
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
TextView(
text: AppStrings.userType,
),
SizedBox(height: 8),
CustomDropdown(
initialValue: controller.userTypeList[1],
backClr: AppColors.clrD9,
borderClr: AppColors.clrGrey,
items: controller.userTypeList,
itemLabel: (item) => item,
onSelected: (selected) {
if (selected != null) {
controller.selectedValue.value = selected;
}
},
hintText: 'Select User Type',
),
],
)),
SizedBox(width: 16),
Expanded(
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
TextView(
text: AppStrings.status,
),
SizedBox(height: 8),
CustomDropdown(
initialValue: controller.status[0],
backClr: AppColors.clrD9,
borderClr: AppColors.clrGrey,
items: controller.status,
itemLabel: (item) => item,
onSelected: (selected) {
if (selected != null) {
controller.selectedStatus.value = selected;
}
},
hintText: 'Active'),
],
)),
SizedBox(width: 16),
Expanded(
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
TextView(
text: AppStrings.emailAddress,isRequired: true,
),
SizedBox(height: 8),
InputField(
validator: Validations.checkEmailValidations,
controller: controller.emailCtrl,
title: AppStrings.enterEmailAddress,
),
],
)),
TextView(
text: AppStrings.firstName,
isRequired: true,
),
InputField(
errorTxtColor: controller.errorTextColor,
validator: Validations.checkValidations,
controller: controller.nameCtrl,
title: AppStrings.enterFirstName,
),
],
),
),
Padding(
padding: const EdgeInsets.only(top: 16.0, bottom: 8),
child: TextView(
text: AppStrings.mobileNo,isRequired: true,
),
),
Row(
children: [
Expanded(
child: Padding(
padding: const EdgeInsets.only(right: 8.0),
child: InputField(
maxLength: 10,
validator: Validations.checkPhoneValidations,
controller: controller.mobileCtrl,
title: AppStrings.enterMobileNo,
),
)),
Expanded(
flex: 2,
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 8.0),
child: Row(
mainAxisAlignment: MainAxisAlignment.end,
children: [
CommonBtn(
bkClr: Colors.white,
text: AppStrings.cancel,
clickAction: () {
Get.back();
},
),
SizedBox(width: 16),
controller.employeeCodeCtrl.text.isEmpty
? CommonButton(
height: 30,
width: 100,
borderRadius: 4,
isLoading: controller.isLoading,
text: AppStrings.add,
clickAction: () {
controller.createUser();
}
// if(controller.formKey.currentState!.validate()){
// controller.createUser();
// } else {
// controller.validatePlants.value == true;
//
// }
// if (controller.formKey.currentState
// ?.validate() ??
// false) {
// ScaffoldMessenger.of(context)
// .showSnackBar(
// SnackBar(
// content: Text(
// 'Form submitted successfully!')),
// );
// controller.createUser();
// } else {
// controller.showE.value = true;
// }
// }
)
: CommonButton(
height: 30,
width: 100,
borderRadius: 4,
isLoading: controller.editLoading,
text: AppStrings.edit,
clickAction: () {
controller.editAllUser(
controller.employeeCodeCtrl.text);
},
),
],
),
))
],
),
],
),
)),
SizedBox(width: 16),
Expanded(
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
TextView(
text: AppStrings.lastName,
isRequired: true,
),
InputField(
errorTxtColor: controller.errorTextColor,
validator: Validations.checkValidations,
controller: controller.lastNCtrl,
title: AppStrings.enterLastName,
),
],
)),
SizedBox(width: 16),
Expanded(
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
TextView(
text: AppStrings.employeeCode,
isRequired: true,
),
InputField(
errorTxtColor: controller.errorTextColor,
validator: Validations.checkValidations,
controller: controller.employeeCodeCtrl,
title: AppStrings.enterEmployeeCode,
),
],
)),
],
),
SizedBox(height:8 ),
Row(
children: [
Flexible(
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
TextView(
text: AppStrings.userType,
),
SizedBox(height: 8),
CustomDropdown(
initialValue: controller.userTypeList[1],
backClr: AppColors.clrD9,
borderClr: AppColors.clrGrey,
items: controller.userTypeList,
itemLabel: (item) => item,
onSelected: (selected) {
if (selected != null) {
controller.selectedValue.value = selected;
}
},
hintText: 'Select User Type',
),
Obx(() => controller.validateAdduser.value == true ?
TextView(
margin: EdgeInsets.only(top: 4),
text: "Required",
style: 10.txtTransparent,
) :
SizedBox.shrink(
))
],
)),
SizedBox(width: 16),
Expanded(
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
TextView(
text: AppStrings.status,
),
SizedBox(height: 8),
CustomDropdown(
//initialValue: controller.status[0],
initialValue: "Active",
backClr: AppColors.clrD9,
borderClr: AppColors.clrGrey,
items: controller.status,
itemLabel: (item) => item,
onSelected: (selected) {
if (selected != null) {
controller.selectedStatus.value = selected;
}
},
hintText: 'Active'),
Obx(() => controller.validateAdduser.value == true ?
TextView(
margin: EdgeInsets.only(top: 4),
text: "Required",
style: 10.txtTransparent,
) :
SizedBox.shrink(
))
],
)),
SizedBox(width: 16),
Expanded(
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
TextView(
text: AppStrings.emailAddress,
isRequired: true,
),
SizedBox(height: 8),
InputField(
errorTxtColor: controller.errorTextColor,
validator: Validations.checkEmailValidations,
controller: controller.emailCtrl,
title: AppStrings.enterEmailAddress,
),
],
)),
],
),
TextView(
text: AppStrings.mobileNo,
isRequired: true,
),
Row(
children: [
Expanded(
child: Padding(
padding: const EdgeInsets.only(right: 8.0),
child: InputField(
errorTxtColor: controller.errorTextColor,
maxLength: 10,
validator: Validations.checkPhoneValidations,
controller: controller.mobileCtrl,
title: AppStrings.enterMobileNo,
),
)),
Expanded(
flex: 2,
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 8.0),
child: Row(
mainAxisAlignment: MainAxisAlignment.end,
children: [
CommonBtn(
bkClr: Colors.white,
text: AppStrings.cancel,
clickAction: () {
Get.back();
},
),
SizedBox(width: 16),
controller.employeeCodeCtrl.text.isEmpty
? CommonButton(
height: 30,
width: 100,
borderRadius: 4,
isLoading: controller.isLoading,
text: AppStrings.add,
clickAction: () {
controller.createUser();
}
)
: CommonButton(
height: 30,
width: 100,
borderRadius: 4,
isLoading: controller.editLoading,
text: AppStrings.edit,
clickAction: () {
controller.editAllUser(
controller.employeeCodeCtrl.text);
},
),
],
),
))
],
),
],
),
],
),
),
],
);
}
}

View File

@ -10,11 +10,17 @@ import '../../../../../components/styles/app_colors.dart';
import '../../../../../components/styles/app_strings.dart';
import '../../transporter/widgets/common_card.dart';
class InternalUserRoleMapping extends StatelessWidget {
InternalUserRoleMapping({super.key});
class InternalUserRoleMapping extends StatefulWidget {
const InternalUserRoleMapping({super.key});
@override
State<InternalUserRoleMapping> createState() => _InternalUserRoleMappingState();
}
class _InternalUserRoleMappingState extends State<InternalUserRoleMapping> {
final ctrl = Get.put(DashboardCtrl());
@override
Widget build(BuildContext context) {
return Obx(() {
@ -29,6 +35,8 @@ class InternalUserRoleMapping extends StatelessWidget {
color: Colors.white,
child: Column(
children: [
Container(
color: AppColors.clrF2,
child: Padding(
@ -54,16 +62,22 @@ class InternalUserRoleMapping extends StatelessWidget {
onSelected: (selected) {
if (selected != null) {
ctrl.selectedEmpCode.value = selected;
}
},
hintText: "Select Employee Code",
),
SizedBox(height: 5),
ctrl.validateRoleMapCode.value == true ? TextView(
ctrl.validateRoleEmail.value == true ? TextView(
text: "Required",
style: 10.txtSBoldRed,
style: 10.txtTransparent,
) : TextView(
text: "ABC",
style: 10.txtTransparent,
),
) : SizedBox.shrink(),
],
)),
SizedBox(width: 16),
@ -85,6 +99,7 @@ class InternalUserRoleMapping extends StatelessWidget {
onSelected: (selected) {
if (selected != null) {
ctrl.selectedEmail.value = selected;
ctrl.validateRoleEmail.value = false;
}
},
hintText: "Select Email",
@ -94,7 +109,11 @@ class InternalUserRoleMapping extends StatelessWidget {
text: "Required",
style: 10.txtSBoldRed,
) : SizedBox.shrink(),
) : TextView(
text: "ABC",
style: 10.txtTransparent,
),
],
)),
SizedBox(width: 16),
@ -122,12 +141,12 @@ class InternalUserRoleMapping extends StatelessWidget {
width: 100,
text: AppStrings.submit,
clickAction: () {
if(ctrl.selectedEmail.value == "Select Email" ||ctrl.selectedEmpCode.value == "Select Employee Code" ){
if(ctrl.selectedEmail.value == "Select Email" ){
ctrl.validateRoleEmail.value = true;
ctrl.validateRoleMapCode.value = true;
} else{
ctrl.validateRoleEmail.value = false;
ctrl.validateRoleMapCode.value = false;
ctrl.getRoleMappingData();
}
@ -226,11 +245,12 @@ class InternalUserRoleMapping extends StatelessWidget {
clickAction: () {},
),
SizedBox(width: 16),
CommonButton(
borderRadius: 4,
height: 30,
width: 100,
text: AppStrings.submit,
text: AppStrings.save,
clickAction: () {
CommonAlertDialog.showDialog(

View File

@ -4,6 +4,7 @@ import 'package:intl/intl.dart';
import 'package:shayog/components/styles/textStyles.dart';
import '../../../../../components/common/common_btn.dart';
import '../../../../../components/common/common_button.dart';
import '../../../../../components/common/custom_drop_down.dart';
import '../../../../../components/common/data_cell.dart';
import '../../../../../components/common/input_field.dart';
import '../../../../../components/styles/app_colors.dart';
@ -24,207 +25,188 @@ class ManageUser extends StatelessWidget {
crossAxisAlignment: CrossAxisAlignment.end,
children: [
Obx(
() => controller.isSelected.value
() => controller.isSelected.value
? Container(
margin: EdgeInsets.symmetric(vertical: 16),
padding: EdgeInsets.all(16),
color: AppColors.clrF2,
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
children: [
Expanded(
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment:
CrossAxisAlignment.start,
children: [
TextView(
text: "User Name",
),
SizedBox(height: 8),
InputField(
title: "Enter User Name",
controller: controller.nameCtrl),
// margin: EdgeInsets.symmetric(vertical: 16),
padding: EdgeInsets.all(16),
color: AppColors.clrF2,
// CustomDropdown(
// backClr: AppColors.clrD9,
// borderClr: AppColors.clrGrey,
// items: ctrl.plantList,
// itemLabel: (item) => item,
// onSelected: (selected) {
// if (selected != null) {
// ctrl.selectedPlant.value =
// selected;
// }
// },
// hintText: 'Select Plant'),
],
)),
SizedBox(width: 16),
Expanded(
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment:
CrossAxisAlignment.start,
children: [
TextView(
text: "User Type",
),
SizedBox(height: 8),
InputField(
title: "Enter User Type",
controller: controller.userTypeCtrl),
// CustomDropdown(
// backClr: AppColors.clrD9,
// borderClr: AppColors.clrGrey,
// items: ctrl.freightBillList,
// itemLabel: (item) => item,
// onSelected: (selected) {
// if (selected != null) {
// ctrl.selectedFreight.value =
// selected;
// }
// },
// hintText: 'Select Freight Number'),
],
)),
SizedBox(width: 16),
Expanded(
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment:
CrossAxisAlignment.start,
children: [
TextView(
text: "Email Address",
),
SizedBox(height: 8),
InputField(
title: "Enter Email Address",
controller: controller.emailCtrl),
// CustomDropdown(
// backClr: AppColors.clrD9,
// borderClr: AppColors.clrGrey,
// items: ctrl.plantList,
// itemLabel: (item) => item,
// onSelected: (selected) {
// if (selected != null) {
// ctrl.selectedPlant.value =
// selected;
// }
// },
// hintText: 'Select Product'),
],
)),
],
),
Padding(
padding: const EdgeInsets.only(top: 16.0),
child: Row(
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Expanded(
child: Column(
mainAxisAlignment:
MainAxisAlignment.start,
crossAxisAlignment:
CrossAxisAlignment.start,
Row(
children: [
Expanded(
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
TextView(
text: "User Name",
),
SizedBox(height: 8),
CustomDropdown(
backClr: AppColors.clrD9,
borderClr: AppColors.clrGrey,
items: controller.userNames,
itemLabel: (item) => item,
onSelected: (selected) {
if (selected != null) {
controller.selectUser.value =
selected;
}
},
hintText: 'Select UserName'),
],
)),
SizedBox(width: 16),
Expanded(
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
TextView(
text: "User Type",
),
SizedBox(height: 8),
CustomDropdown(
backClr: AppColors.clrD9,
borderClr: AppColors.clrGrey,
items: controller.userTypesNames,
itemLabel: (item) => item,
onSelected: (selected) {
if (selected != null) {
controller.selectType.value =
selected;
}
},
hintText: 'Select User Type'),
],
)),
SizedBox(width: 16),
Expanded(
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
TextView(
text: "Email Address",
),
SizedBox(height: 8),
CustomDropdown(
backClr: AppColors.clrD9,
borderClr: AppColors.clrGrey,
items: controller.userEmail,
itemLabel: (item) => item,
onSelected: (selected) {
if (selected != null) {
controller.selectEmail.value =
selected;
}
},
hintText: 'Select Email Address'),
],
)),
],
),
SizedBox(height: 8),
Row(
children: [
Expanded(
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
TextView(
text: "Employee/Transporter Code",
),
SizedBox(height: 8),
InputField(
title: "Enter Employee Code",
controller: controller.employeeCodeCtrl),
// CustomDropdown(
// backClr: AppColors.clrD9,
// borderClr: AppColors.clrGrey,
// items: ctrl.plantList,
// itemLabel: (item) => item,
// onSelected: (selected) {
// if (selected != null) {
// ctrl.selectedPlant.value =
// selected;
// }
// },
// hintText: 'Select Product'),
CustomDropdown(
backClr: AppColors.clrD9,
borderClr: AppColors.clrGrey,
items: controller.userEmpCode,
itemLabel: (item) => item,
onSelected: (selected) {
if (selected != null) {
controller.selectCode.value =
selected;
}
},
hintText: 'Select Employer Code'),
],
)),
SizedBox(width: 16),
Expanded(
child: Column(
mainAxisAlignment:
MainAxisAlignment.start,
crossAxisAlignment:
CrossAxisAlignment.start,
SizedBox(width: 16),
Expanded(
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
TextView(
text: "Status",
),
SizedBox(height: 8),
InputField(
title: "Enter Status",
controller: controller.statusCtrl),
// CustomDropdown(
// backClr: AppColors.clrD9,
// borderClr: AppColors.clrGrey,
// items: ctrl.plantList,
// itemLabel: (item) => item,
// onSelected: (selected) {
// if (selected != null) {
// ctrl.selectedPlant.value =
// selected;
// }
// },
// hintText: 'Select Product'),
CustomDropdown(
backClr: AppColors.clrD9,
borderClr: AppColors.clrGrey,
items: controller.userStatus,
itemLabel: (item) => item,
onSelected: (selected) {
if (selected != null) {
controller.selectUserStatus.value =
selected;
}
},
hintText: 'Select Status'),
],
)),
SizedBox(width: 16),
Expanded(
child: Column(
children: [
TextView(
text: "",
),
SizedBox(height: 8),
Row(
mainAxisAlignment:
MainAxisAlignment.end,
SizedBox(width: 16),
Expanded(
child: Column(
children: [
CommonBtn(
bkClr: Colors.white,
text: AppStrings.cancel,
clickAction: () {
controller.isSelected.value = false;
},
TextView(
text: "",
),
SizedBox(width: 16),
CommonButton(
borderRadius: 4,
width: 100,
height: 30,
text: AppStrings.submit,
textStyle: 14.txtSBoldWhite,
clickAction: () {
controller.isSelected.value = false;
controller.getManageUser();
controller.getAllUser();
},
SizedBox(height: 8),
Row(
mainAxisAlignment: MainAxisAlignment.end,
children: [
CommonBtn(
bkClr: Colors.white,
text: AppStrings.cancel,
clickAction: () {
controller.isSelected.value = false;
controller.clearUserData();
},
),
SizedBox(width: 16),
CommonButton(
borderRadius: 4,
width: 100,
height: 30,
text: AppStrings.submit,
textStyle: 14.txtSBoldWhite,
clickAction: () {
//controller.isSelected.value = false;
controller.getManageUser();
controller.getAllUser();
},
),
],
),
],
),
],
),
),
],
),
],
),
),
],
),
)
)
: SizedBox(),
),
Obx(() {
@ -236,129 +218,136 @@ class ManageUser extends StatelessWidget {
mainAxisAlignment: MainAxisAlignment.end,
crossAxisAlignment: CrossAxisAlignment.end,
children: [
Scrollbar(
thumbVisibility: true,
controller: controller.verticalScrollController,
child: SingleChildScrollView(
Container(
margin: EdgeInsets.only(bottom: 16, top: 16),
height: MediaQuery.of(context).size.height * 0.4,
child: RawScrollbar(
thumbColor: AppColors.clrD9,
radius: Radius.circular(2),
trackVisibility: true,
thumbVisibility: true,
thickness: 14,
controller: controller.verticalScrollController,
child: Scrollbar(
thumbVisibility: true,
controller: controller.horizontalScrollController,
child: SingleChildScrollView(
scrollDirection: Axis.horizontal,
child: SingleChildScrollView(
controller: controller.verticalScrollController,
child: RawScrollbar(
thumbColor: AppColors.clrD9,
radius: Radius.circular(2),
thickness: 14,
trackVisibility: true,
thumbVisibility: true,
controller: controller.horizontalScrollController,
child: Container(
margin: EdgeInsets.only(top: 16),
decoration: BoxDecoration(
border: Border.all(
color: Colors.grey.shade400,
width: 1.0,
child: SingleChildScrollView(
scrollDirection: Axis.horizontal,
controller: controller.horizontalScrollController,
child: Container(
margin: EdgeInsets.only(bottom: 24, right: 24),
child: DataTable(
dataRowHeight: 28,
headingRowHeight: 40,
headingRowColor:
WidgetStateProperty.all(AppColors.clrF2),
border: TableBorder(
horizontalInside:
BorderSide(color: AppColors.clrGrey),
verticalInside:
BorderSide(color: AppColors.clrGrey),
bottom: BorderSide(color: AppColors.clrGrey),
left: BorderSide(color: AppColors.clrGrey),
right: BorderSide(color: AppColors.clrGrey),
top: BorderSide(color: AppColors.clrGrey),
),
columns: [
dataColumn("User Name"),
dataColumn("Email ID"),
dataColumn("Employee/\nTransporter Code"),
dataColumn("Mobile No."),
dataColumn("User Type"),
dataColumn("Created By"),
dataColumn("Created Date"),
dataColumn("Last Updated By"),
dataColumn("Last Update Date"),
dataColumn("Status"),
dataColumn("Action"),
],
rows: List<DataRow>.generate(
controller.getAllUserMain.length, (index) {
final stoppage = controller.getAllUserMain[index];
return DataRow(
selected: stoppage.isSelected,
cells: [
editableCell(index, stoppage.userName ?? "-"),
editableCell(
index, stoppage.userEmail ?? "-"),
editableCell(
index, stoppage.userEmpTransCode ?? "-"),
editableCell(
index, stoppage.userMobile ?? "-"),
editableCell(
index, stoppage.usertypeName ?? "-"),
editableCell(
index, stoppage.createdBy.toString()),
editableCell(
index,
DateFormat("d MMMM yyyy").format(
DateTime.parse(
'${stoppage.createdOn}'))),
editableCell(
index, stoppage.lastUpdatedBy.toString()),
editableCell(
index,
DateFormat("d MMMM yyyy").format(
DateTime.parse(
'${stoppage.lastUpdatedOn}'))),
editableCell(
index,
stoppage.status == "A"
? "Active"
: "In-Active"),
DataCell(CommonBtn(
style: 8.txtSBoldWhite,
margin: EdgeInsets.symmetric(vertical: 6),
width: 35,
text: "Edit",
clickAction: () {
controller.nameCtrl.text =
stoppage.userFname ?? '';
controller.lastNCtrl.text =
stoppage.userLname ?? '';
controller.mobileCtrl.text =
stoppage.userMobile ?? '';
controller.emailCtrl.text =
stoppage.userEmail ?? '';
controller.userTypeId.value =
stoppage.usertypeId.toString();
controller.selectedValue.value =
stoppage.userAddedChannel ?? '';
controller.selectedStatus.value =
stoppage.status ?? '';
controller.employeeCodeCtrl.text =
stoppage.userEmpTransCode ?? '';
controller.selectUserVal.value =
stoppage.usertypeName ?? '';
controller.selectedUser.value = 1;
},
)),
],
);
}),
),
),
child: DataTable(
dataRowHeight: 28,
headingRowHeight: 40,
headingRowColor:
WidgetStateProperty.all(AppColors.clrF2),
border: TableBorder(
horizontalInside:
BorderSide(color: AppColors.clrGrey),
verticalInside:
BorderSide(color: AppColors.clrGrey),
bottom: BorderSide(color: AppColors.clrGrey),
left: BorderSide(color: AppColors.clrGrey),
right: BorderSide(color: AppColors.clrGrey),
top: BorderSide(color: AppColors.clrGrey),
),
columns: [
dataColumn("User Name"),
dataColumn("Email ID"),
dataColumn("Employee/\nTransporter Code"),
dataColumn("Mobile No."),
dataColumn("User Type"),
dataColumn("Created By"),
dataColumn("Created Date"),
dataColumn("Last Updated By"),
dataColumn("Last Update Date"),
dataColumn("Status"),
dataColumn("Action"),
],
rows: List<DataRow>.generate(
controller.getAllUser.length, (index) {
final stoppage = controller.getAllUser[index];
return DataRow(
selected: stoppage.isSelected,
// onSelectChanged: (value) {
// controller.toggleSelection(index, value ?? false);
// },
cells: [
// editableCell(index, ""
// "${index + 1}"),
editableCell(index, stoppage.userName ?? "-"),
editableCell(index, stoppage.userEmail ?? "-"),
editableCell(
index, stoppage.userEmpTransCode ?? "-"),
editableCell(index, stoppage.userMobile ?? "-"),
editableCell(
index, stoppage.usertypeName ?? "-"),
editableCell(
index, stoppage.createdBy.toString()),
editableCell(index, DateFormat("d MMMM yyyy").format(DateTime.parse('${stoppage.createdOn}'))),
editableCell(
index, stoppage.lastUpdatedBy.toString()),
editableCell(
index,
DateFormat("d MMMM yyyy").format(
DateTime.parse(
'${stoppage.lastUpdatedOn}'))),
editableCell(index, stoppage.status =="A"?"Active":"In-Active"),
DataCell(CommonBtn(
style: 8.txtSBoldWhite,
margin: EdgeInsets.symmetric(vertical: 6),
width: 35,
text: "Edit",
clickAction: () {
controller.nameCtrl.text =
stoppage.userFname ?? '';
controller.lastNCtrl.text =
stoppage.userLname ?? '';
controller.mobileCtrl.text =
stoppage.userMobile ?? '';
controller.emailCtrl.text =
stoppage.userEmail ?? '';
controller.userTypeId.value =
stoppage.usertypeId.toString();
controller.selectedValue.value =
stoppage.userAddedChannel ?? '';
controller.selectedStatus.value =
stoppage.status ?? '';
controller.employeeCodeCtrl.text =
stoppage.userEmpTransCode ?? '';
controller.selectUserVal.value =
stoppage.usertypeName ?? '';
controller.selectedUser.value = 1;
},
)),
],
);
}),
),
),
),
),
),
),
SizedBox(height: 16),
],
);
}),
CustomPagination(
currentPage: controller.currentPage.value,
totalPages: controller.totalPages.value,
@ -366,7 +355,6 @@ class ManageUser extends StatelessWidget {
controller.onPageChanged(page);
},
),
],
);
}

View File

@ -34,7 +34,7 @@ class UserPlantMapping extends StatelessWidget {
children: [
TextView(
text: "Employee/Transporter Code",
style: 13.txtBoldBlack,
isRequired: true,
),
SizedBox(height: 8),
@ -52,11 +52,16 @@ class UserPlantMapping extends StatelessWidget {
hintText: 'Select Employee Code',
),
SizedBox(height: 5),
ctrl.validatePlantCode.value == true ? TextView(
ctrl.validatePlantEmail.value == true ? TextView(
text: "Required",
style: 10.txtSBoldRed,
style: 10.txtTransparent,
) : TextView(
text: "ABC",
style: 10.txtTransparent,
),
) : SizedBox.shrink(),
],
)),
@ -69,7 +74,7 @@ class UserPlantMapping extends StatelessWidget {
crossAxisAlignment: CrossAxisAlignment.start,
children: [
TextView(text:
"Email Address",style:13.txtBoldBlack,isRequired: true,
"Email Address",isRequired: true,
),
SizedBox(height: 8),
CustomDropdown(
@ -89,7 +94,11 @@ class UserPlantMapping extends StatelessWidget {
text: "Required",
style: 10.txtSBoldRed,
) : SizedBox.shrink(),
) : TextView(
text: "ABC",
style: 10.txtTransparent,
),
],
)),
@ -121,20 +130,18 @@ class UserPlantMapping extends StatelessWidget {
text: AppStrings.submit,
clickAction: () {
if(ctrl.selectPlantEmail.value == "Select Email" ||ctrl.selectedCode.value == "Select Employee Code" ){
if(ctrl.selectPlantEmail.value == "Select Email"){
ctrl.validatePlantEmail.value = true;
ctrl.validatePlantCode.value = true;
} else{
ctrl.validatePlantEmail.value = false;
ctrl.validatePlantCode.value = false;
ctrl.getPlantMapping();
}
},
// clickAction: () {
// ctrl.checkPlants();
// },
),
],
),
@ -179,9 +186,9 @@ class UserPlantMapping extends StatelessWidget {
value ?? false);
},
activeColor: AppColors.primaryClr,
// Custom color when selected
checkColor: Colors.white,
// Custom color for check mark
materialTapTargetSize: MaterialTapTargetSize
.shrinkWrap,
),
@ -236,7 +243,7 @@ class UserPlantMapping extends StatelessWidget {
clickAction: () {
CommonAlertDialog.showDialog(
message: 'Are you sure you want to do this action?',
positiveText: "Submit",
positiveText: "Save",
negativeBtCallback: () {
Get.back();
},

View File

@ -1,12 +1,8 @@
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:shayog/components/common/input_field.dart';
import 'package:shayog/components/styles/textStyles.dart';
import 'package:shayog/feature/presentation/screens/admin/user_management/user_plant_mapping.dart';
import 'package:shayog/feature/presentation/widgets/text_view.dart';
import '../../../../../components/common/common_btn.dart';
import '../../../../../components/common/common_button.dart';
import '../../../../../components/styles/app_colors.dart';
import '../../../../../components/styles/app_images.dart';
import '../../../../../components/styles/app_strings.dart';
@ -24,341 +20,136 @@ class UserScreen extends StatelessWidget {
@override
Widget build(BuildContext context) {
return SingleChildScrollView(
child: Column(
children: [
Container(
padding: EdgeInsets.only(bottom: 16),
margin: EdgeInsets.all(16),
child: Column(
children: [
Container(
height: 50,
color: AppColors.primaryClr,
child: Row(
children: [
ListView.separated(
padding: EdgeInsets.symmetric(horizontal: 16),
scrollDirection: Axis.horizontal,
shrinkWrap: true,
itemBuilder: (context, index) {
return Obx(
() => InkWell(
onTap: () {
ctrl.selectedUser.value = index;
ctrl.clearPrefillData();
ctrl.isSelected.value = false;
if (ctrl.selectedUser.value == 0) {
print("fhudsfh");
ctrl.getManageUser();
}
if (ctrl.selectedUser.value == 2) {
ctrl.showRolesSection.value = false;
}
if (ctrl.selectedUser.value != 3) {
ctrl.selectPlantEmail.value =
"Select Email";
ctrl.selectPlantCode.value =
'Select Employee Code';
ctrl.plantMapping.clear();
}
},
child: Container(
margin: EdgeInsets.only(bottom: 10, top: 10),
decoration: BoxDecoration(
border: Border(
bottom: BorderSide(
color: ctrl.selectedUser.value ==
index
? Colors.white
: AppColors.primaryClr,
width: 3))),
child: Center(
child: TextView(
text: ctrl.userTabs[index].title ?? "",
style: 12.txtBoldWhite,
// style: TextStyle(
// fontSize: 12,
// fontWeight: FontWeight.w900,
// color: Colors.white),
),
),
child: Container(
padding: EdgeInsets.only(bottom: 16),
margin: EdgeInsets.all(16),
child: Column(
children: [
Container(
height: 50,
color: AppColors.primaryClr,
child: Row(
children: [
ListView.separated(
padding: EdgeInsets.symmetric(horizontal: 16),
scrollDirection: Axis.horizontal,
shrinkWrap: true,
itemBuilder: (context, index) {
return Obx(
() => InkWell(
onTap: () {
ctrl.selectedUser.value = index;
ctrl.clearPrefillData();
ctrl.isSelected.value = false;
ctrl.validateRoleEmail.value = false;
ctrl.validatePlantEmail.value = false;
if (ctrl.selectedUser.value == 0) {
ctrl.getManageUser();
}
if (ctrl.selectedUser.value == 2) {
ctrl.showRolesSection.value = false;
}
if (ctrl.selectedUser.value != 3) {
ctrl.selectPlantEmail.value =
"Select Email";
ctrl.selectPlantCode.value =
'Select Employee Code';
ctrl.plantMapping.clear();
}
},
child: Container(
margin: EdgeInsets.only(bottom: 10, top: 10),
decoration: BoxDecoration(
border: Border(
bottom: BorderSide(
color: ctrl.selectedUser.value ==
index
? Colors.white
: AppColors.primaryClr,
width: 3))),
child: Center(
child: TextView(
text: ctrl.userTabs[index].title ?? "",
style: 12.txtBoldWhite,
),
),
);
},
separatorBuilder: (context, index) {
return SizedBox(width: 16);
},
itemCount: 5),
Spacer(),
InkWell(
),
),
);
},
separatorBuilder: (context, index) {
return SizedBox(width: 16);
},
itemCount: 5),
Spacer(),
InkWell(
onTap: () {
ctrl.selectedUser.value == 0
? ctrl.getManageUser()
: ctrl.selectedUser.value == 1
? ctrl.clearPrefillData()
: ctrl.selectedUser.value == 2
? ctrl.clearRoleMapping()
: ctrl.selectedUser.value == 3
? ctrl.clearPlants()
: ctrl.clearUserType();
},
child: Image.asset(AppImages.refresh,
height: 12, width: 12)),
Padding(
padding: const EdgeInsets.all(8.0),
child: TextView(
text: AppStrings.refresh,
style: 12.txtBoldWhite,
),
),
Obx(
() => Visibility(
visible: ctrl.selectedUser.value == 0,
child: InkWell(
onTap: () {
ctrl.selectedUser.value == 0
? ctrl.getManageUser()
: ctrl.selectedUser.value == 1
? ctrl.clearPrefillData()
: ctrl.selectedUser.value == 2
? ctrl.clearRoleMapping()
: ctrl.selectedUser.value == 3
? ctrl.clearPlants()
: ctrl.clearUserType();
ctrl.toggleContainer();
},
child: Image.asset(AppImages.refresh,
height: 12, width: 12)),
Padding(
child: Image.asset(AppImages.filter,
height: 16, width: 16)),
),
),
Obx(
() => Visibility(
visible: ctrl.selectedUser.value == 0,
child: Padding(
padding: const EdgeInsets.all(8.0),
child: TextView(
text: AppStrings.refresh,
text: AppStrings.filter,
style: 12.txtBoldWhite,
),
),
Obx(
() => Visibility(
visible: ctrl.selectedUser.value == 0,
child: InkWell(
onTap: () {
ctrl.toggleContainer();
},
child: Image.asset(AppImages.filter,
height: 16, width: 16)),
),
),
Obx(
() => Visibility(
visible: ctrl.selectedUser.value == 0,
child: Padding(
padding: const EdgeInsets.all(8.0),
child: TextView(
text: AppStrings.filter,
style: 12.txtBoldWhite,
),
),
),
),
],
),
),
),
Obx(
() => ctrl.isSelected.value
? Container(
margin: EdgeInsets.symmetric(vertical: 16),
padding: EdgeInsets.all(16),
color: AppColors.clrF2,
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
children: [
Expanded(
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment:
CrossAxisAlignment.start,
children: [
TextView(
text: "User Name",
),
SizedBox(height: 8),
InputField(
title: "Enter User Name",
controller: ctrl.nameCtrl),
// CustomDropdown(
// backClr: AppColors.clrD9,
// borderClr: AppColors.clrGrey,
// items: ctrl.plantList,
// itemLabel: (item) => item,
// onSelected: (selected) {
// if (selected != null) {
// ctrl.selectedPlant.value =
// selected;
// }
// },
// hintText: 'Select Plant'),
],
)),
SizedBox(width: 16),
Expanded(
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment:
CrossAxisAlignment.start,
children: [
TextView(
text: "User Type",
),
SizedBox(height: 8),
InputField(
title: "Enter User Type",
controller: ctrl.userTypeCtrl),
// CustomDropdown(
// backClr: AppColors.clrD9,
// borderClr: AppColors.clrGrey,
// items: ctrl.freightBillList,
// itemLabel: (item) => item,
// onSelected: (selected) {
// if (selected != null) {
// ctrl.selectedFreight.value =
// selected;
// }
// },
// hintText: 'Select Freight Number'),
],
)),
SizedBox(width: 16),
Expanded(
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment:
CrossAxisAlignment.start,
children: [
TextView(
text: "Email Address",
),
SizedBox(height: 8),
InputField(
title: "Enter Email Address",
controller: ctrl.emailCtrl),
// CustomDropdown(
// backClr: AppColors.clrD9,
// borderClr: AppColors.clrGrey,
// items: ctrl.plantList,
// itemLabel: (item) => item,
// onSelected: (selected) {
// if (selected != null) {
// ctrl.selectedPlant.value =
// selected;
// }
// },
// hintText: 'Select Product'),
],
)),
],
),
Padding(
padding: const EdgeInsets.only(top: 16.0),
child: Row(
children: [
Expanded(
child: Column(
mainAxisAlignment:
MainAxisAlignment.start,
crossAxisAlignment:
CrossAxisAlignment.start,
children: [
TextView(
text: "Employee/Transporter Code",
),
SizedBox(height: 8),
InputField(
title: "Enter Employee Code",
controller: ctrl.employeeCodeCtrl),
// CustomDropdown(
// backClr: AppColors.clrD9,
// borderClr: AppColors.clrGrey,
// items: ctrl.plantList,
// itemLabel: (item) => item,
// onSelected: (selected) {
// if (selected != null) {
// ctrl.selectedPlant.value =
// selected;
// }
// },
// hintText: 'Select Product'),
],
)),
SizedBox(width: 16),
Expanded(
child: Column(
mainAxisAlignment:
MainAxisAlignment.start,
crossAxisAlignment:
CrossAxisAlignment.start,
children: [
TextView(
text: "Status",
),
SizedBox(height: 8),
InputField(
title: "Enter Status",
controller: ctrl.statusCtrl),
// CustomDropdown(
// backClr: AppColors.clrD9,
// borderClr: AppColors.clrGrey,
// items: ctrl.plantList,
// itemLabel: (item) => item,
// onSelected: (selected) {
// if (selected != null) {
// ctrl.selectedPlant.value =
// selected;
// }
// },
// hintText: 'Select Product'),
],
)),
SizedBox(width: 16),
Expanded(
child: Column(
children: [
TextView(
text: "",
),
SizedBox(height: 8),
Row(
mainAxisAlignment:
MainAxisAlignment.end,
children: [
CommonBtn(
bkClr: Colors.white,
text: AppStrings.cancel,
clickAction: () {
ctrl.isSelected.value = false;
},
),
SizedBox(width: 16),
CommonButton(
borderRadius: 4,
width: 100,
height: 30,
text: AppStrings.submit,
textStyle: 14.txtSBoldWhite,
clickAction: () {
ctrl.isSelected.value = false;
ctrl.getAllUser();
},
),
],
),
],
),
),
],
),
),
],
),
)
: SizedBox(),
),
Obx(() {
switch (ctrl.selectedUser.value) {
case 0:
return ManageUser();
case 1:
return AddInternalUser();
case 2:
return InternalUserRoleMapping();
case 3:
return UserPlantMapping();
default:
return UserType();
}
}),
],
],
),
),
)
],
Obx(() {
switch (ctrl.selectedUser.value) {
case 0:
return ManageUser();
case 1:
return AddInternalUser();
case 2:
return InternalUserRoleMapping();
case 3:
return UserPlantMapping();
default:
return UserType();
}
}),
],
),
),
);
}

View File

@ -28,105 +28,96 @@ class UserType extends StatelessWidget {
color: AppColors.clrF2,
child: Row(
children: [
Expanded(
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
TextView(text:
Expanded(child: SizedBox(
// color: Colors.pink,
height: 100,
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
TextView(text:
"Add User Type",isRequired: true,
),
SizedBox(height: 8),
InputField(
controller: controller.userTypeCtrl,
title: "Enter User Type",
),
SizedBox(height: 5),
controller.validateUserType.value == true ? TextView(
text: "Required",
style: 10.txtSBoldRed,
),
SizedBox(height: 8),
InputField(
) : SizedBox.shrink(),
],
controller: controller.userTypeCtrl,
title: "Enter User Type",
),
],
),
)),
SizedBox(width: 16),
Expanded(
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
TextView(
text:
"Status Type",isRequired: true,
),
SizedBox(height: 8),
CustomDropdown(
initialValue: controller.selectStatus.value,
backClr: AppColors.clrD9,
borderClr: AppColors.clrGrey,
items: controller.userTypeStatus,
itemLabel: (item) => item,
onSelected: (selected) {
if (selected != null) {
controller.selectStatus.value = selected;
}
},
hintText: 'Select Status'),
SizedBox(height: 5),
controller.validateUserType.value == true ? TextView(
text: "Required",
style: 10.txtSBoldRed,
Expanded(child: SizedBox(
// color: Colors.green,
height: 100,
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
TextView(
text:
"Status Type",isRequired: true,
),
SizedBox(height: 8),
CustomDropdown(
initialValue: controller.selectStatus.value,
backClr: AppColors.clrD9,
borderClr: AppColors.clrGrey,
items: controller.userTypeStatus,
itemLabel: (item) => item,
onSelected: (selected) {
if (selected != null) {
controller.selectStatus.value = selected;
}
},
hintText: 'Select Status'),
) : SizedBox.shrink(),
],
],
),
)),
SizedBox(width: 16),
Expanded(
//flex: 2,
child: Column(
children: [
TextView(text:
Expanded(child: SizedBox(
height: 100,
child: Column(
children: [
TextView(text:
"",
),
Padding(
padding: const EdgeInsets.only(top: 8.0),
child: Row(
mainAxisAlignment: MainAxisAlignment.end,
children: [
CommonBtn(
bkClr: Colors.white,
text: AppStrings.cancel,
clickAction: () {},
),
SizedBox(width: 16),
CommonButton(
isLoading: controller.userTypeLoading,
height: 28,
borderRadius: 4,
width: 100,
text: AppStrings.submit,
),
Padding(
padding: const EdgeInsets.only(top: 18.0),
child: Row(
mainAxisAlignment: MainAxisAlignment.end,
children: [
CommonBtn(
bkClr: Colors.white,
text: AppStrings.cancel,
clickAction: () {},
),
SizedBox(width: 16),
CommonButton(
isLoading: controller.userTypeLoading,
height: 28,
borderRadius: 4,
width: 100,
text: AppStrings.submit,
clickAction: () {
if(controller.userTypeCtrl.text.isEmpty ||controller.selectStatus.value == "Select Status" ){
controller.validateUserStatus.value = true;
controller.validateUserType.value = true;
} else{
controller.validateUserStatus.value = false;
controller.validateUserType.value = false;
clickAction: () {
controller.createUserType();
}
},
),
],
},
),
],
),
),
),
],
],
),
))
],
),
)
),
),
Container(

View File

@ -1,4 +1,5 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:shayog/components/styles/app_images.dart';
import 'package:shayog/feature/presentation/screens/admin/user_management/model/select_assign_role_model/select_assign_role_model.dart';
@ -41,12 +42,20 @@ class DashboardCtrl extends GetxController {
RxBool isSelected = false.obs;
RxString selectedItem = ''.obs;
@override
void onClose() {
verticalScrollController.dispose();
horizontalScrollController.dispose();
super.onClose();
}
void toggleContainer() {
isSelected.value = true;
print("isSelected.value..${isSelected.value}");
}
String? validateDropdown(String? value) {
print('data');
if (value == null || value.isEmpty) {
return 'Please select an item';
}
@ -85,7 +94,7 @@ class DashboardCtrl extends GetxController {
@override
void onInit() {
getManageUser();
getDropDownData();
getPlantEmailCode();
getEmailCodeOfRoleMapping();
userTypeDetails();
super.onInit();
@ -95,27 +104,63 @@ class DashboardCtrl extends GetxController {
RxInt currentPage = 1.obs; // Current page being viewed
RxInt totalPages = 1.obs; // Total number of pages from the API
RxList<AllUser> getAllUser = <AllUser>[].obs;
final int limit = 20;
RxList<AllUser> getAllUserMain = <AllUser>[].obs;
RxInt limit = 20.obs;
var userLoading = false.obs;
setNextPage() {
if (currentPage.value < totalPages.value.toInt()) {
currentPage.value++;
getManageUser();
}
}
setPrevPage() {
if (currentPage.value > 1) {
currentPage.value--;
getManageUser();
}
}
var userNames =[].obs;
var userTypesNames =[].obs;
var userEmpCode =[].obs;
var userEmail =[].obs;
var selectUser = "Select User Name".obs;
var selectEmail = "Select Email".obs;
var selectCode = "Select Employee Code".obs;
var selectType = "Select UserType".obs;
getManageUser() async {
try {
userLoading.value = true;
Map<String, String> requestBody = {
"userName": "",
"userTypeName": "",
"email": "",
"employeeTransCode": "",
"status": ""
"userName": selectUser.value == "Select User Name" ? "" : selectUser.value,
"userTypeName": selectType.value == "Select UserType" ? "" : selectType.value,
"Email": selectEmail.value == "Select Email" ?"": selectEmail.value,
"EmployeeTransCode":
selectCode.value == "Select Employee Code" ? "" : selectCode.value,
"status": selectUserStatus.value == "Select Status"
? ""
: selectUserStatus.value == "Active"
? "A"
: "I",
};
var response =
await PostRequests.getAllUser(requestBody, currentPage.value, limit);
await PostRequests.getAllUser(requestBody, currentPage.value);
if (response != null) {
List<AllUser> flattenedContent =
response.content!.expand((list) => list).toList();
getAllUser.assignAll(flattenedContent);
getAllUserMain.assignAll(flattenedContent);
for (var i = 0; i < flattenedContent.length; i++) {
userTypesNames.add(flattenedContent[i].usertypeName);
userNames.add(flattenedContent[i].userName);
userEmpCode.add(flattenedContent[i].userEmpTransCode);
userEmail.add(flattenedContent[i].userEmail);
}
totalPages.value = response.totalPages!;
print("getAllUser>>>>>${getAllUser.length}");
}
@ -123,24 +168,31 @@ class DashboardCtrl extends GetxController {
userLoading.value = false;
}
}
clearUserData(){
selectUser.value = "Select User Name";
selectEmail.value = "Select Email";
selectCode.value = "Select Employee Code";
selectType.value = "Select UserType";
selectedStatus.value = "Select Status";
getManageUser();
}
void nextPage() {
if (currentPage.value < totalPages.value) {
currentPage.value++;
getManageUser(); // Fetch data for the next page
getManageUser();
}
}
void previousPage() {
if (currentPage.value > 1) {
currentPage.value--;
getManageUser(); // Fetch data for the previous page
getManageUser();
}
}
void onPageChanged(int page) {
currentPage.value = page;
getManageUser(); // Fetch data for the selected page
getManageUser();
}
//********************************edit User****************************//
@ -166,7 +218,6 @@ class DashboardCtrl extends GetxController {
getManageUser();
getAllUser.refresh();
//employeeCodeCtrl.clear();
}
// employeeCodeCtrl.clear();
selectedUser.value = 0;
@ -183,9 +234,14 @@ class DashboardCtrl extends GetxController {
var selectedStatus = 'Select Status'.obs;
var selectedValue = 'Select User Type'.obs;
Color errorTextColor = Colors.red;
void createUser() {
if (formKey.currentState!.validate()) {
validateAdduser.value = false;
addInternalUser();
} else {
validateAdduser.value = true;
}
}
@ -216,6 +272,8 @@ class DashboardCtrl extends GetxController {
onclick: () {
Get.back();
getManageUser();
getEmailCodeOfRoleMapping();
getPlantEmailCode();
clearPrefillData();
selectedUser.value = 0;
});
@ -286,29 +344,21 @@ class DashboardCtrl extends GetxController {
var userTypeData = <UserTypeData>[].obs;
var userTypeStatus = ['Active', 'In-Active'];
var selectStatus = 'Select Status'.obs;
clearUserType() {
userTypeCtrl.text.isEmpty;
selectedStatus.value.isEmpty;
}
// addUserType() {
// if (userTypeCtrl.text.isEmpty || selectedStatus.value == "") {
// CommonDialog.showDialog(
// message: "Select all mandatory fields",
// onclick: () {
// Get.back();
// });
// } else {
// createUserType();
// }
// }
var selectUserStatus = "Select Status".obs;
var userStatus = ["Active", "In-Active"];
createUserType() async {
try {
userTypeLoading.value = true;
Map<String, String> requestBody = {
"userTypeName": userTypeCtrl.text,
"status": selectStatus.value == "Active" ? "A" : "I",
"status": selectUserStatus.value == "Active" ? "A" : "I",
"createdBy": "0",
"lastUpdatedBy": "0"
};
@ -330,7 +380,7 @@ class DashboardCtrl extends GetxController {
var employeeCode = [].obs;
var userEmails = [].obs;
getDropDownData() async {
getPlantEmailCode() async {
try {
dropDownLoader.value = true;
@ -348,31 +398,19 @@ class DashboardCtrl extends GetxController {
var plantMappingLoader = false.obs;
RxList<PlantsData> plantMapping = <PlantsData>[].obs;
clearPlants() {
selectPlantEmail.value.isEmpty;
selectPlantCode.value.isEmpty;
}
checkPlants() {
if (selectPlantEmail.value == "Select Email" ||
selectPlantCode.value == "Select Employee Code") {
CommonDialog.showDialog(
message: "Select all mandatory fields",
onclick: () {
Get.back();
});
} else {
getPlantMapping();
}
}
clearRoleMapping() {
selectedEmail.value.isEmpty;
selectedEmpCode.value.isEmpty;
}
getPlantMapping() async {
try {
plantMappingLoader.value = true;
@ -386,7 +424,6 @@ class DashboardCtrl extends GetxController {
plantMapping.value = response.data!;
showPlantRolesSection.value = true;
}
} finally {
plantMappingLoader.value = false;
}
@ -396,7 +433,9 @@ class DashboardCtrl extends GetxController {
RxList<InternalRoleMappingData> roleMappingData =
<InternalRoleMappingData>[].obs;
var fetchEmailsNCodesLoading = false.obs;
var statusMessage = "".obs;
// roleMappingEmailCode
getRoleMappingData() async {
try {
fetchEmailsNCodesLoading.value = true;
@ -404,11 +443,15 @@ class DashboardCtrl extends GetxController {
"email": selectedEmail.value,
"employeeTransCode": selectedEmpCode.value,
};
var response = await PostRequests.fetchEmailsAndEmpCodes(requestBody);
var response = await PostRequests.fetchEmailsAndEmpCodes(requestBody,statusMessage.value);
if (response != null) {
print('fetch role desc ${response.data?.length}');
roleMappingData.value = response.data!;
showRolesSection.value = true;
} else {
//print("cdg");
// AppAlerts.alert(message: "sxjs");
}
} finally {
fetchEmailsNCodesLoading.value = false;
@ -534,10 +577,35 @@ class DashboardCtrl extends GetxController {
userTypeLoader.value = false;
}
}
RxBool validateRoleEmail = false.obs;
RxBool validateRoleMapCode = false.obs;
RxBool validatePlantEmail = false.obs;
RxBool validatePlantCode = false.obs;
RxBool validateUserStatus = false.obs;
RxBool validateUserType = false.obs;
RxBool validateAdduser = false.obs;
searchEmpCode(String enterValue) {
print('-----typing ---- ${enterValue}');
//List<AllChandlo> searchList = [];
List<AllUser> searchList = [];
if (enterValue.isEmpty) {
//searchList = getCndMain;
searchList = getAllUserMain;
} else {
searchList = getAllUserMain
.where((user) =>
user.usertypeName!.toLowerCase().contains(enterValue.toLowerCase()))
.toList();
}
getAllUser.assignAll(searchList);
getAllUser.refresh();
for (var item in getAllUser) {
print('name :: ${item.usertypeName}');
}
}
RxString? validateEmail;
}

View File

@ -24,6 +24,7 @@ class _DashboardScreenState extends State<DashboardScreen> {
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: AppColors.white,
appBar: AppBar(
automaticallyImplyLeading: false,
backgroundColor: AppColors.secondaryClr,

View File

@ -26,471 +26,474 @@ class PendingGeneration extends StatelessWidget {
Widget build(BuildContext context) {
return Column(
children: [
Container(
padding: EdgeInsets.all(16),
color: AppColors.clrF2,
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
children: [
Expanded(
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
TextView(text:
"Plant", isRequired: true),
SizedBox(height: 8),
CustomDropdown(
backClr: AppColors.clrD9,
borderClr: AppColors.clrGrey,
items: controller.plant,
itemLabel: (item) => "${item.plantCode}-${item.plantDesc}",
onSelected: (selected) {
if (selected != null) {
controller.selectPlant.value = selected.plantCode ?? "";
controller.showPlantErrorPending.value = false;
}
},
hintText: "Select Plant",
),
// Obx(() => controller.showPlantErrorPending.value
// ? Padding(
// padding: const EdgeInsets.only(top: 4),
// child: Text(
// 'Required',
// style: TextStyle(color: Colors.red, fontSize: 12),
// ),
// )
// : SizedBox.shrink()),
],
),
),
SizedBox(width: 16),
Expanded(
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
TextView(text:"Product Name", isRequired: true),
SizedBox(height: 8),
CustomDropdown<dynamic>(
width: 250,
backClr: AppColors.clrD9,
borderClr: AppColors.clrGrey,
items: controller.product,
itemLabel: (item) => "${item.materialCode}-${item.materialDescription}",
onSelected: (selected) {
if (selected != null) {
controller.selectProduct.value = selected;
print(
"selectPlant${controller.selectProduct.value}");
}
},
hintText: "Select Product Name",
),
],
),
),
SizedBox(width: 16),
Expanded(
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
TextView(text:"Transaction Type", isRequired: true),
SizedBox(height: 8),
CustomDropdown<String>(
backClr: AppColors.clrD9,
borderClr: AppColors.clrGrey,
items: controller.transactionType,
itemLabel: (item) => item,
onSelected: (selected) {
if (selected != null) {
controller.selectTransactionType.value = selected;
controller.showTransactionErrorPending.value = false; }
},
hintText: "Select Transaction Type",
),
// Obx(() => controller.showTransactionErrorPending.value
// ? Padding(
// padding: const EdgeInsets.only(top: 4),
// child: Text(
// 'Required',
// style: TextStyle(color: Colors.red, fontSize: 12),
// ),
// )
// : SizedBox.shrink()),
],
),
),
],
),
Padding(
padding: const EdgeInsets.only(top: 16.0, left: 0, right: 8),
child: Row(
children: [
Expanded(
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
Obx(() => controller.isFilterVisiblePendingGeneration.value
? Column(children: [
Container(
padding: EdgeInsets.all(16),
color: AppColors.clrF2,
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
children: [
TextView(text:"MRN Date Range"),
// SizedBox(height: 8),
// CustomDropdown<String>(
// borderClr: AppColors.clrGrey,
// items: controller.date,
// itemLabel: (item) => item,
// onSelected: (selected) {
// if (selected != null) {
// controller.selectPlant.value = selected;
// }
// },
// hintText: "Select MRN Date Range",
// ),
Container(
margin: EdgeInsets.only(top: 8),
height: 35,
child: TextFormField(
Expanded(
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
TextView(text: "Plant", isRequired: true),
SizedBox(height: 8),
CustomDropdown(
backClr: AppColors.clrD9,
borderClr: AppColors.clrGrey,
key: controller.fromTextFieldKey,
controller: controller.fromController,
onTap: () async {
final pickedDate = await showWebDatePicker(
width: 20.w,
context: controller
.fromTextFieldKey.currentContext!,
initialDate: controller.fromSelectedDate,
firstDate: DateTime(2000),
lastDate: DateTime.now(),
);
if (pickedDate != null) {
controller.fromSelectedDate = pickedDate;
String formattedDate =
controller.getFormattedDate(pickedDate);
controller.fromController.text =
formattedDate;
controller.dateCheck.value = true;
}
},
decoration: InputDecoration(
fillColor:AppColors.clrD9,
filled: true,
hintText: 'Select MRN Date Range',
hintStyle: TextStyle(
fontSize: 12,
overflow: TextOverflow.ellipsis),
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(2.0),
borderSide:
BorderSide(color: AppColors.black),
),
enabledBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(2.0),
borderSide:
BorderSide(color: AppColors.clrGrey),
),
focusedBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(2.0),
borderSide:
BorderSide(color: AppColors.clrGrey),
),
disabledBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(2.0),
borderSide:
BorderSide(color: AppColors.clrGrey),
),
suffixIcon: controller.dateCheck.value
? InkWell(
onTap: () {
controller.dateCheck.value = false;
controller.fromController.clear();
controller.fromSelectedDate =
DateTime.now();
items: controller.plant,
itemLabel: (item) =>
"${item.plantCode}-${item.plantDesc}",
onSelected: (selected) {
if (selected != null) {
controller.selectPlantPending.value =
selected.plantCode ?? "";
controller.showPlantErrorPending.value =
false;
}
},
child: Icon(Icons.close, size: 1.2.w),
)
: null,
contentPadding: const EdgeInsets.symmetric(
horizontal: 12.0, vertical: 0.0),
),
hintText: "Select Plant",
),
Obx(() => controller.showPlantErrorPending.value
? Text(
'Required',
style: TextStyle(
color: Colors.red, fontSize: 12),
)
: Text('')),
],
),
),
SizedBox(width: 16),
Expanded(
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
TextView(
text: "Product Name", isRequired: true),
SizedBox(height: 8),
CustomDropdown<dynamic>(
width: 250,
backClr: AppColors.clrD9,
borderClr: AppColors.clrGrey,
items: controller.product,
itemLabel: (item) =>
"${item.materialCode}-${item.materialDescription}",
onSelected: (selected) {
if (selected != null) {
controller.selectProductPending.value =
selected.materialCode;
controller.showProductErrorPending.value =
false;
print(
"selectPlant${controller.selectProduct.value}");
}
},
hintText: "Select Product Name",
),
Obx(() => controller
.showProductErrorPending.value
? Text(
'Required',
style: TextStyle(
color: Colors.red, fontSize: 12),
)
: Text('')),
],
),
),
SizedBox(width: 16),
Expanded(
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
TextView(
text: "Transaction Type", isRequired: true),
SizedBox(height: 8),
CustomDropdown<String>(
backClr: AppColors.clrD9,
borderClr: AppColors.clrGrey,
items: controller.transactionType,
itemLabel: (item) => item,
onSelected: (selected) {
if (selected != null) {
controller.selectTransactionTypePending
.value = selected;
controller.showTransactionErrorPending
.value = false;
}
},
hintText: "Select Transaction Type",
),
Obx(() => controller
.showTransactionErrorPending.value
? Text(
'Required',
style: TextStyle(
color: Colors.red, fontSize: 12),
)
: Text('')),
],
),
),
],
),
),
SizedBox(width: 16),
Expanded(
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
TextView(text:"From Location"),
SizedBox(height: 8),
CustomDropdown<dynamic>(
backClr: AppColors.clrD9,
borderClr: AppColors.clrGrey,
items: controller.fromLocation,
itemLabel: (item) => item,
onSelected: (selected) {
if (selected != null) {
controller.selectLocation.value = selected;
}
},
hintText: "Select From Location",
),
],
),
),
SizedBox(
width: 16,
),
Expanded(
//flex: 2,
child: Column(
Padding(
padding:
const EdgeInsets.only(top: 16.0, left: 0, right: 8),
child: Row(
children: [
TextView(text:
"",
),
Padding(
padding: const EdgeInsets.only(top: 8.0),
child: Row(
mainAxisAlignment: MainAxisAlignment.end,
Expanded(
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
CommonBtn(
bkClr: Colors.white,
text: AppStrings.cancel,
clickAction: () {},
),
SizedBox(width: 16),
CommonButton(
borderRadius: 4,
height: 30,
width: 100,
text: AppStrings.submit,
TextView(text: "MRN Date Range"),
// SizedBox(height: 8),
// CustomDropdown<String>(
// borderClr: AppColors.clrGrey,
// items: controller.date,
// itemLabel: (item) => item,
// onSelected: (selected) {
// if (selected != null) {
// controller.selectPlant.value = selected;
// }
// },
// hintText: "Select MRN Date Range",
// ),
Container(
margin: EdgeInsets.only(top: 8),
height: 35,
child: TextFormField(
key: controller.fromTextFieldKey,
controller: controller.fromController,
onTap: () async {
final pickedDate =
await showWebDatePicker(
width: 20.w,
context: controller
.fromTextFieldKey.currentContext!,
initialDate:
controller.fromSelectedDate,
firstDate: DateTime(2000),
lastDate: DateTime.now(),
);
clickAction: () {
controller.validateFieldsPending();
if (controller.showPlantErrorPending.value ||
controller.showProductErrorPending.value ||
controller.showTransactionErrorPending.value
) {
} else {
controller.postData();
}
},
if (pickedDate != null) {
controller.fromSelectedDate =
pickedDate;
String formattedDate = controller
.getFormattedDate(pickedDate);
controller.fromController.text =
formattedDate;
controller.dateCheck.value = true;
}
},
decoration: InputDecoration(
fillColor: AppColors.clrD9,
filled: true,
hintText: 'Select MRN Date Range',
hintStyle: TextStyle(
fontSize: 12,
overflow: TextOverflow.ellipsis),
border: OutlineInputBorder(
borderRadius:
BorderRadius.circular(2.0),
borderSide: BorderSide(
color: AppColors.black),
),
enabledBorder: OutlineInputBorder(
borderRadius:
BorderRadius.circular(2.0),
borderSide: BorderSide(
color: AppColors.clrGrey),
),
focusedBorder: OutlineInputBorder(
borderRadius:
BorderRadius.circular(2.0),
borderSide: BorderSide(
color: AppColors.clrGrey),
),
disabledBorder: OutlineInputBorder(
borderRadius:
BorderRadius.circular(2.0),
borderSide: BorderSide(
color: AppColors.clrGrey),
),
suffixIcon: controller.dateCheck.value
? InkWell(
onTap: () {
controller.dateCheck.value =
false;
controller.fromController
.clear();
controller.fromSelectedDate =
DateTime.now();
},
child: Icon(Icons.close,
size: 1.2.w),
)
: null,
contentPadding:
const EdgeInsets.symmetric(
horizontal: 12.0,
vertical: 0.0),
),
),
),
],
),
),
],
))
],
),
),
],
),
),
Container(
padding: EdgeInsets.symmetric(horizontal: 10),
margin: EdgeInsets.only(top: 16),
height: 45,
color: AppColors.primaryClr,
child: Row(
children: [
TextView(text: AppStrings.viewGrnDetails, style: 14.txtBoldWhite),
Spacer(),
CommonBtn(
width: 150,
bkClr: AppColors.white,
borderClr: AppColors.primaryClr,
style: 12.txtBoldBlue,
text: "Generate Freight Bill",
// text: AppStrings.save,
clickAction: () {
bool hasSelectedRows = controller.grnDetails
.any((element) => element.isSelected);
if (!hasSelectedRows) {
showPopup(context: context, onClick: () {
Get.back();
});
} else {
CommonAlertDialog.showDialog(
message: "Are you sure want to\nsave this?",
positiveText: "Save",
negativeText: "Cancel",
positiveBtCallback: () {
Get.back();
controller.addFreightBill();
showFreightBill(context);
},
negativeBtCallback: () {});
}
}),
],
),
),
Obx(() {
if (controller.freightViewLoader.value) {
return Center(
child: CircularProgressIndicator(
color: AppColors.primaryClr,
),
);
} else {
return Column(
children: [
Obx(() {
if (controller.grnPendingLoader.value) {
return Center(child: CircularProgressIndicator());
}
if (controller.errorMessage.isNotEmpty) {
return Center(child: Text(controller.errorMessage.value));
}
if (controller.grnPendingData.isEmpty) {
return Center(child: Text('No data available.'));
}
return Scrollbar(
thumbVisibility: true,
controller: controller.verticalScrollController,
child: SingleChildScrollView(
controller: controller.verticalScrollController,
child: Scrollbar(
thumbVisibility: true,
controller: controller.horizontalScrollController,
child: SingleChildScrollView(
scrollDirection: Axis.horizontal,
controller: controller.horizontalScrollController,
child: Container(
decoration: BoxDecoration(
border: Border.all(
color: Colors.grey.shade400,
width: 1.0,
SizedBox(width: 16),
Expanded(
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
TextView(text: "From Location"),
SizedBox(height: 8),
CustomDropdown<dynamic>(
backClr: AppColors.clrD9,
borderClr: AppColors.clrGrey,
items: controller.fromLocation,
itemLabel: (item) => item,
onSelected: (selected) {
if (selected != null) {
controller.selectLocation.value =
selected;
}
},
hintText: "Select From Location",
),
],
),
),
child: DataTable(
dataRowHeight: 28,
headingRowHeight: 40,
headingRowColor:
SizedBox(
width: 16,
),
Expanded(
//flex: 2,
child: Column(
children: [
TextView(
text: "",
),
Padding(
padding: const EdgeInsets.only(top: 8.0),
child: Row(
mainAxisAlignment: MainAxisAlignment.end,
children: [
CommonBtn(
bkClr: Colors.white,
text: AppStrings.cancel,
clickAction: () => controller.clearFiltersPendingGeneration(),
),
SizedBox(width: 16),
CommonButton(
borderRadius: 4,
height: 30,
width: 100,
text: AppStrings.submit,
clickAction: () =>
// controller.validateFieldsPending();
// if (controller.showPlantErrorPending
// .value ||
// controller.showProductErrorPending
// .value ||
// controller
// .showTransactionErrorPending
// .value) {
// } else {
// controller.postData();
// }
controller
.handleFilterSubmitPendingGeneration(),
),
],
),
),
],
))
],
),
),
],
),
)
])
: SizedBox.shrink()),
Obx(() {
if (controller.grnPendingLoader.value) {
return SizedBox(
height: MediaQuery.sizeOf(context).height,
width: MediaQuery.sizeOf(context).width,
child: Center(
child: CircularProgressIndicator(
color: AppColors.primaryClr,
)),
);
}
if (controller.errorMessage.isNotEmpty) {
return SizedBox(
height: MediaQuery.sizeOf(context).height,
width: MediaQuery.sizeOf(context).width,
child: Center(child: Text(controller.errorMessage.value)));
}
if (controller.grnPendingData.isEmpty) {
return SizedBox(
height: MediaQuery.sizeOf(context).height,
width: MediaQuery.sizeOf(context).width,
child: Center(child: Text('No data available.',)));
}
return
Column(
children: [
SizedBox(height: 20,),
Scrollbar(
thumbVisibility: true,
controller: controller.verticalScrollController,
child: SingleChildScrollView(
controller: controller.verticalScrollController,
child: Scrollbar(
thumbVisibility: true,
controller: controller.horizontalScrollController,
child: SingleChildScrollView(
scrollDirection: Axis.horizontal,
controller: controller.horizontalScrollController,
child: Container(
decoration: BoxDecoration(
border: Border.all(
color: Colors.grey.shade400,
width: 1.0,
),
),
child: DataTable(
dataRowHeight: 40,
headingRowHeight: 40,
headingRowColor:
WidgetStateProperty.all(AppColors.clrF2),
border: TableBorder(
horizontalInside:
border: TableBorder(
horizontalInside:
BorderSide(color: AppColors.clrGrey),
verticalInside:
verticalInside:
BorderSide(color: AppColors.clrGrey),
bottom: BorderSide(color: AppColors.clrGrey),
left: BorderSide(color: AppColors.clrGrey),
right: BorderSide(color: AppColors.clrGrey),
top: BorderSide(color: AppColors.clrGrey),
bottom: BorderSide(color: AppColors.clrGrey),
left: BorderSide(color: AppColors.clrGrey),
right: BorderSide(color: AppColors.clrGrey),
top: BorderSide(color: AppColors.clrGrey),
),
columns: [
DataColumn(
label: Transform.scale(
scale: 0.80,
child: Checkbox(
value: controller.selectAllField.value,
onChanged: (value) {
controller.selectAll(value ?? false);
},
activeColor: AppColors.primaryClr,
checkColor: Colors.white,
materialTapTargetSize:
MaterialTapTargetSize.shrinkWrap,
),
),
columns: [
DataColumn(
label: Transform.scale(
),
// dataColumn(AppStrings.srNo),
dataColumn(AppStrings.plantName),
dataColumn(AppStrings.productName),
dataColumn(AppStrings.date),
dataColumn(AppStrings.fromLocation),
dataColumn(AppStrings.vehicleNo),
dataColumn(AppStrings.transporterLrNo),
dataColumn(AppStrings.transporterLrNoDate),
dataColumn(AppStrings.dispQty),
dataColumn(AppStrings.netQty),
dataColumn(AppStrings.billingQty),
dataColumn(AppStrings.uom),
dataColumn(AppStrings.freightRate),
dataColumn(AppStrings.freightAmount),
dataColumn(AppStrings.remark),
],
rows: List<DataRow>.generate(
controller.grnPendingData.length, (index) {
final stoppage = controller.grnPendingData[index];
return DataRow(
selected: stoppage.isSelected,
cells: [
DataCell(
Transform.scale(
scale: 0.80,
child: Checkbox(
value: controller.selectAllField.value,
value: stoppage.isSelected,
onChanged: (value) {
controller.selectAll(value ?? false);
controller.toggleSelection(
index, value ?? false);
},
activeColor: AppColors.primaryClr,
checkColor: Colors.white,
materialTapTargetSize:
MaterialTapTargetSize.shrinkWrap,
MaterialTapTargetSize.shrinkWrap,
),
),
),
// dataColumn(AppStrings.srNo),
dataColumn(AppStrings.plantName),
dataColumn(AppStrings.productName),
dataColumn(AppStrings.date),
dataColumn(AppStrings.fromLocation),
dataColumn(AppStrings.vehicleNo),
dataColumn(AppStrings.transporterLrNo),
dataColumn(AppStrings.transporterLrNoDate),
dataColumn(AppStrings.dispQty),
dataColumn(AppStrings.netQty),
dataColumn(AppStrings.billingQty),
dataColumn(AppStrings.uom),
dataColumn(AppStrings.freightRate),
dataColumn(AppStrings.freightAmount),
dataColumn(AppStrings.remark),
// editableCell(index, "0${index + 1}"),
editableCell(index, stoppage.plantCode ?? ""),
editableCell(index, stoppage.plantCode ?? ""),
editableCell(
index,
DateFormat('yyyy-MM-dd').format(
stoppage.grnDate ?? DateTime.now())),
editableCell(
index, stoppage.fromLocation ?? ""),
editableCell(index, stoppage.vehicleNo ?? ""),
editableCell(index, stoppage.lrNo ?? ""),
editableCell(
index,
DateFormat('yyyy-MM-dd').format(
stoppage.lrDate ?? DateTime.now())),
editableCell(
index, stoppage.dispQty?.toString() ?? ""),
editableCell(
index, stoppage.netQty?.toString() ?? ""),
editableCell(index,
stoppage.billingQty?.toString() ?? ""),
editableCell(index,
stoppage.codeValue?.toString() ?? ""),
editableCell(index,
stoppage.freightRate?.toString() ?? ""),
editableCell(index,
stoppage.shipmentCost?.toString() ?? ""),
editableCell(
index, stoppage.remark?.toString() ?? ""),
],
rows: List<DataRow>.generate(
controller.grnPendingData.length, (index) {
final stoppage = controller.grnPendingData[index];
return DataRow(
selected: stoppage.isSelected,
cells: [
DataCell(
Transform.scale(
scale: 0.80,
child: Checkbox(
value: stoppage.isSelected,
onChanged: (value) {
controller.toggleSelection(
index, value ?? false);
},
activeColor: AppColors.primaryClr,
checkColor: Colors.white,
materialTapTargetSize: MaterialTapTargetSize
.shrinkWrap,
),
),
),
// editableCell(index, "0${index + 1}"),
editableCell(index, stoppage.plantCode ?? ""),
editableCell(index, stoppage.plantCode ?? ""),
editableCell(
index,
DateFormat('yyyy-MM-dd').format(
stoppage.grnDate ?? DateTime.now())),
editableCell(
index, stoppage.fromLocation ?? ""),
editableCell(index, stoppage.vehicleNo ?? ""),
editableCell(index, stoppage.lrNo ?? ""),
editableCell(
index,
DateFormat('yyyy-MM-dd').format(
stoppage.lrDate ?? DateTime.now())),
editableCell(
index, stoppage.dispQty?.toString() ?? ""),
editableCell(
index, stoppage.netQty?.toString() ?? ""),
editableCell(index,
stoppage.billingQty?.toString() ?? ""),
editableCell(index,
stoppage.codeValue?.toString() ?? ""),
editableCell(index,
stoppage.freightRate?.toString() ?? ""),
editableCell(
index, stoppage.shipmentCost?.toString() ?? ""),
editableCell(
index, stoppage.remark?.toString() ?? ""),
],
);
}),
),
),
);
}),
),
),
),
);
}),
],
);
}
),
),
),
],
);
}),
],
);

View File

@ -61,16 +61,16 @@ class ViewFreightBill extends StatelessWidget {
},
hintText: "Select Plant",
),
// Obx(() =>
// controller.showPlantErrorFreight.value
// ? Padding(
// padding: const EdgeInsets.only(top: 4),
// child: Text(
// 'Required',
// style: TextStyle(color: Colors.red, fontSize: 12),
// ),
// )
// : SizedBox.shrink()),
Obx(() => controller.showPlantErrorFreight.value
? Padding(
padding: const EdgeInsets.only(top: 4),
child: Text(
'Please select a plant',
style: TextStyle(
color: Colors.red, fontSize: 12),
),
)
: SizedBox.shrink()),
],
),
),
@ -125,16 +125,16 @@ class ViewFreightBill extends StatelessWidget {
},
hintText: "Select Transaction Type",
),
// Obx(() =>
// controller.showTransactionErrorFreight.value
// ? Padding(
// padding: const EdgeInsets.only(top: 4),
// child: Text(
// 'Required',
// style: TextStyle(color: Colors.red, fontSize: 12),
// ),
// )
// : SizedBox.shrink()),
Obx(() => controller.showTransactionErrorFreight.value
? Padding(
padding: const EdgeInsets.only(top: 4),
child: Text(
'Please select Transaction Type',
style: TextStyle(
color: Colors.red, fontSize: 12),
),
)
: SizedBox.shrink()),
],
),
),
@ -276,10 +276,11 @@ class ViewFreightBill extends StatelessWidget {
.showProductErrorFreight.value ||
controller
.showTransactionErrorFreight.value) {
print(
'controller.showProductError.value ${controller.showProductError.value}');
} else {
controller.postData();
}
controller.postData();
},
),
],
@ -293,48 +294,6 @@ class ViewFreightBill extends StatelessWidget {
],
),
),
// Container(
// padding: EdgeInsets.symmetric(horizontal: 10),
// margin: EdgeInsets.only(top: 16),
// height: 45,
// color: AppColors.primaryClr,
// child: Row(
// children: [
// TextView(text: AppStrings.viewGrnDetails, style: 14.txtBoldWhite),
// Spacer(),
// CommonBtn(
// width: 150,
// bkClr: AppColors.white,
// borderClr: AppColors.primaryClr,
// style: 12.txtBoldBlue,
// text: "Generate Freight Bill",
//
// clickAction: () {
// bool hasSelectedRows = controller.grnDetails
// .any((element) => element.isSelected);
// if (!hasSelectedRows) {
// showPopup(
// context: context,
// onClick: () {
// Get.back();
// });
// } else {
// CommonAlertDialog.showDialog(
// message: "Are you sure want to\nsave this?",
// positiveText: "Save",
// negativeText: "Cancel",
// positiveBtCallback: () {
// Get.back();
// controller.addFreightBill();
//
// showFreightBill(context);
// },
// negativeBtCallback: () {});
// }
// }),
// ],
// ),
// ),
SizedBox(
height: 20,
),
@ -556,10 +515,8 @@ class ViewFreightBill extends StatelessWidget {
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
"${AppStrings.freightBill} ${freightBill.freightbillId ?? "-"}"),
Text(
"${AppStrings.freightDate} ${freightBill.statusDate ?? "-"}"),
Text("${AppStrings.freightBill} ${freightBill.freightbillId}"),
Text("${AppStrings.freightDate} ${freightBill.statusDate}"),
const SizedBox(
height: 8,
),

View File

@ -29,6 +29,8 @@ class _TransportViewState extends State<TransportView> {
@override
Widget build(BuildContext context) {
return ListView(
shrinkWrap: true,
physics: NeverScrollableScrollPhysics(),
children: [
Row(
crossAxisAlignment: CrossAxisAlignment.start,
@ -163,210 +165,38 @@ class _TransportViewState extends State<TransportView> {
style: 12.txtBoldWhite,
),
),
Obx(
() => Visibility(
visible: ctrl.selectedUser.value >= 1,
child: InkWell(
onTap: ctrl.toggleContainer,
child: Image.asset(AppImages.filter,
height: 16, width: 16)),
),
InkWell(
onTap: () {
if(ctrl.selectedUser.value == 0){
ctrl.toggleFilter();
}
else if(ctrl.selectedUser.value == 2){
ctrl.togglePending();
}
},
child:
Image.asset(AppImages.filter, height: 16, width: 16),
),
Visibility(
visible: ctrl.selectedUser.value >= 1,
child: Padding(
padding: const EdgeInsets.all(8.0),
child: TextView(
text: AppStrings.filter,
style: 12.txtBoldWhite,
),
Padding(
padding: const EdgeInsets.all(8.0),
child: TextView(
text: AppStrings.filter,
style: 12.txtBoldWhite,
),
),
],
),
),
// Obx(
// () => ctrl.isSelected.value
// ? Container(
// margin: EdgeInsets.symmetric(vertical: 16),
// padding: EdgeInsets.all(16),
// color: AppColors.clrF2,
// child: Column(
// mainAxisAlignment: MainAxisAlignment.start,
// crossAxisAlignment: CrossAxisAlignment.start,
// children: [
// Row(
// children: [
// Expanded(
// child: Column(
// mainAxisAlignment: MainAxisAlignment.start,
// crossAxisAlignment: CrossAxisAlignment.start,
// children: [
// TextView(
// text: "Plant",
// ),
// SizedBox(height: 8),
// CustomDropdown(
// backClr: AppColors.clrD9,
// borderClr: AppColors.clrGrey,
// items: ctrl.plantList,
// itemLabel: (item) => item,
// onSelected: (selected) {
// if (selected != null) {
// ctrl.selectedPlant.value = selected;
// }
// },
// hintText: 'Select Plant'),
// ],
// )),
// SizedBox(width: 16),
// Expanded(
// child: Column(
// mainAxisAlignment: MainAxisAlignment.start,
// crossAxisAlignment: CrossAxisAlignment.start,
// children: [
// TextView(
// text: "Freight Bill No.",
// ),
// SizedBox(height: 8),
// CustomDropdown(
// backClr: AppColors.clrD9,
// borderClr: AppColors.clrGrey,
// items: ctrl.freightBillList,
// itemLabel: (item) => item,
// onSelected: (selected) {
// if (selected != null) {
// ctrl.selectedFreight.value =
// selected;
// }
// },
// hintText: 'Select Freight Number'),
// ],
// )),
// SizedBox(width: 16),
// Expanded(
// child: Column(
// mainAxisAlignment: MainAxisAlignment.start,
// crossAxisAlignment: CrossAxisAlignment.start,
// children: [
// TextView(
// text: "Product Name",
// ),
// SizedBox(height: 8),
// CustomDropdown(
// backClr: AppColors.clrD9,
// borderClr: AppColors.clrGrey,
// items: ctrl.plantList,
// itemLabel: (item) => item,
// onSelected: (selected) {
// if (selected != null) {
// ctrl.selectedPlant.value = selected;
// }
// },
// hintText: 'Select Product'),
// ],
// )),
// ],
// ),
// SizedBox(height: 12),
// Row(
// children: [
// Expanded(
// child: Column(
// mainAxisAlignment: MainAxisAlignment.start,
// crossAxisAlignment:
// CrossAxisAlignment.start,
// children: [
// TextView(
// text: "Plant",
// ),
// SizedBox(height: 8),
// CustomDropdown(
// backClr: AppColors.clrD9,
// borderClr: AppColors.clrGrey,
// items: ctrl.plantList,
// itemLabel: (item) => item,
// onSelected: (selected) {
// if (selected != null) {
// ctrl.selectedPlant.value =
// selected;
// }
// },
// hintText: 'Select Product'),
// ],
// )),
// SizedBox(width: 16),
// Expanded(
// child: Column(
// mainAxisAlignment: MainAxisAlignment.start,
// crossAxisAlignment:
// CrossAxisAlignment.start,
// children: [
// TextView(
// text: "Transaction Type",
// ),
// SizedBox(height: 8),
// CustomDropdown(
// backClr: AppColors.clrD9,
// borderClr: AppColors.clrGrey,
// items: ctrl.plantList,
// itemLabel: (item) => item,
// onSelected: (selected) {
// if (selected != null) {
// ctrl.selectedPlant.value =
// selected;
// }
// },
// hintText: 'Select Product'),
// ],
// )),
// SizedBox(width: 16),
// Expanded(
// child: Column(
// children: [
// TextView(
// text: "",
// ),
// SizedBox(height: 8),
// Row(
// mainAxisAlignment:
// MainAxisAlignment.end,
// children: [
// CommonBtn(
// bkClr: Colors.white,
// text: AppStrings.cancel,
// clickAction: () {
// ctrl.isSelected.value = false;
// },
// ),
// SizedBox(width: 16),
// CommonBtn(
// text: AppStrings.submit,
// style: 14.txtSBoldWhite,
// clickAction: () {
// ctrl.isSelected.value = false;
// },
// ),
// ],
// ),
// ],
// ),
// ),
// ],
// ),
// ],
// ),
// )
// : SizedBox(),
// ),
Obx(() {
switch (ctrl.selectedUser.value) {
case 0:
return GenerateFrightBill();
case 1:
return ViewFreightBill();
default:
case 2:
return PendingGeneration();
default :
return SizedBox.shrink();
}
}),
],

View File

@ -20,6 +20,14 @@ class TransportController extends GetxController {
var selectProduct = ''.obs;
var selectLocation = ''.obs;
var selectTransactionType = ''.obs;
RxString selectPlantFreight = ''.obs;
var selectProductFreight = ''.obs;
var selectLocationFreight = ''.obs;
var selectTransactionTypeFreight = ''.obs;
RxString selectPlantPending = ''.obs;
var selectProductPending = ''.obs;
var selectLocationPending = ''.obs;
var selectTransactionTypePending = ''.obs;
var selectedItem = false.obs;
var grnDetails = <Content>[].obs;
var product = <Prodect>[].obs;
@ -27,18 +35,44 @@ class TransportController extends GetxController {
var freightBill = [].obs;
var fromLocation = [].obs;
var grnList = [].obs;
final GlobalKey<FormState> formKey = GlobalKey<FormState>();
RxBool showE = false.obs;
RxBool selectAllField = false.obs;
RxBool plantValidate = false.obs;
RxBool transValidate = false.obs;
void toggleSelection(int index, bool? value) {
grnDetails[index].isSelected = value!;
grnDetails.refresh();
}
RxBool isFilterVisibleGenerateFreight = false.obs;
RxBool isFilterVisiblePendingGeneration = false.obs;
final int initialRecordCount = 20;
// Validation variables
RxBool showPlantError = false.obs;
RxBool showProductError = false.obs;
RxBool showTransactionError = false.obs;
void toggleFilter() {
// if (selectedUser.value == 0) {
isFilterVisibleGenerateFreight.value =
!isFilterVisibleGenerateFreight.value;
if (!isFilterVisibleGenerateFreight.value) {
clearFiltersGenerateFreightBill();
}
// }
// if (selectedUser.value == 2) {
// }
}
void togglePending(){
isFilterVisiblePendingGeneration.value =
!isFilterVisiblePendingGeneration.value;
if (!isFilterVisiblePendingGeneration.value) {
clearFiltersPendingGeneration();
}
}
void selectAll(bool value) {
for (var item in grnDetails) {
item.isSelected = value;
@ -47,11 +81,39 @@ RxBool transValidate = false.obs;
grnDetails.refresh();
}
RxBool showPlantErrorFreight = false.obs;
RxBool showProductErrorFreight = false.obs;
RxBool showTransactionErrorFreight = false.obs;
final selectProductValFreight = ''.obs;
RxBool showPlantErrorPending = false.obs;
RxBool showProductErrorPending = false.obs;
RxBool showTransactionErrorPending = false.obs;
void validateFields() {
showPlantError.value = selectPlant.value.isEmpty;
showTransactionError.value = selectTransactionType.value.isEmpty;
}
void validateFieldsPending() {
showPlantErrorPending.value = selectPlantPending.value.isEmpty;
showTransactionErrorPending.value =
selectTransactionTypePending.value.isEmpty;
showProductErrorPending.value = selectProductPending.value.isEmpty;
}
void validateFieldsGenerateFreight() {
showPlantErrorFreight.value = selectPlantFreight.value.isEmpty;
showTransactionErrorFreight.value =
selectTransactionTypeFreight.value.isEmpty;
showProductErrorFreight.value = selectProductFreight.value.isEmpty;
}
@override
void onInit() {
getFreightBills();
viewFreightView();
grnPending();
postData();
super.onInit();
}
@ -90,10 +152,10 @@ RxBool transValidate = false.obs;
isLoading.value = true;
Map<String, String> requestBody = {
"plant": selectPlant.value,
"productNane": selectProduct.value,
"transactionType": selectTransactionType.value,
"fromLocation": selectLocation.value,
"plant": "",
"productNane": "",
"transactionType": "",
"fromLocation": "",
"grnFromDate": "",
"grnToDate": ""
};
@ -109,12 +171,115 @@ RxBool transValidate = false.obs;
}
}
void displayFilteredData() async {
try {
isLoading.value = true;
Map<String, String> requestBody = {
"plant": selectPlantFreight.value,
"productNane": selectProductFreight.value,
"transactionType": selectTransactionTypeFreight.value,
"fromLocation": selectLocation.value,
"grnFromDate": "",
"grnToDate": ""
};
var response = await PostRequests.addFreightBill(requestBody);
if (response != null) {
List<Content> flattenedContent =
response.content!.expand((list) => list).toList();
print("Flattened content size: ${flattenedContent.length}");
print(
"Filter criteria: Plant: ${selectPlantFreight.value}, Product: ${selectProductFreight.value}, Transaction: ${selectTransactionTypeFreight.value}");
List<Content> filteredData = flattenedContent.where((item) {
return (selectPlantFreight.value.isEmpty ||
item.plantCode == selectPlantFreight.value) &&
(selectProductFreight.value.isEmpty ||
item.materialCode == selectProductFreight.value) &&
(selectTransactionTypeFreight.value.isEmpty ||
item.codeValue == selectTransactionTypeFreight.value);
}).toList();
print("Filtered Data: ${filteredData.length}");
grnDetails.assignAll(filteredData);
print("✅ Filtered Data: ${filteredData.length} items displayed.");
print("✅ Filtered Data: ${grnDetails.length} items displayed.");
} else {
print("❌ No response from API.");
}
} finally {
isLoading.value = false;
}
}
// void handleFilterSubmit() {
// validateFieldsGenerateFreight();
//
// if (showPlantError.value ||
// showProductError.value ||
// showTransactionError.value) {
// print('show errr');
// } else {
// postData();
// }
// }
void handleFilterSubmitGenerateFreight() {
validateFieldsGenerateFreight();
if (selectPlantFreight.value.isEmpty ||
selectProductFreight.value.isEmpty ||
selectTransactionTypeFreight.value.isEmpty) {
print('please fill data ');
}
else {
displayFilteredData();
}
}
void handleFilterSubmitPendingGeneration() {
validateFieldsPending();
if (selectPlantPending.value.isEmpty ||
selectProductPending.value.isEmpty ||
selectTransactionTypePending.value.isEmpty) {
}
else {
displayFilteredDataFromPending();
}
}
void clearFiltersGenerateFreightBill() {
selectPlantFreight.value = '';
selectProductFreight.value = '';
selectTransactionTypeFreight.value = '';
fromController.clear();
showPlantError.value = false;
showProductError.value = false;
showTransactionError.value = false;
postData();
}
void clearFiltersPendingGeneration() {
selectPlantPending.value = '';
selectProductPending.value = '';
selectTransactionTypePending.value = '';
fromController.clear();
showPlantErrorPending.value = false;
showProductErrorPending.value = false;
showTransactionErrorPending.value = false;
postData();
}
getFreightBills() async {
try {
isLoading.value = true;
var response = await GetRequests.getFreightBill();
if (response != null) {
print("gtyfhg");
plant.assignAll(response.plant ?? []);
product.assignAll(response.prodect ?? []);
freightBill.assignAll(response.freightBill ?? []);
@ -125,14 +290,6 @@ RxBool transValidate = false.obs;
}
}
bool isEmbeddedProduct(String materialCode) {
var product = <Prodect>[].obs;
return product.any((prodect) => prodect.materialCode == materialCode);
}
final fromTextFieldKey = GlobalKey();
TextEditingController fromController = TextEditingController();
DateTime fromSelectedDate = DateTime.now(); // Initialize with a default value
@ -163,21 +320,12 @@ RxBool transValidate = false.obs;
"Plant 5",
];
RxString selectedFreight = "".obs;
List freightBillList = [
"Plant 1",
"Plant 2",
"Plant 3",
"Plant 4",
"Plant 5",
];
addFreightBill() async {
try {
grnListLoader.value = true;
// Filter the selected rows
final List<Map<String, dynamic>> selectedGrns = grnDetails
.where((grn) => grn.isSelected) // Get only the selected rows
.where((grn) => grn.isSelected)
.map((grn) => {
"grn_id": grn.grnId,
"grn_no": grn.grnNo,
@ -219,44 +367,11 @@ RxBool transValidate = false.obs;
var pageSize = 2.obs;
var sortField = "grn_date".obs;
var sortDirection = "desc".obs;
// viewFreightView({int? page, String? sort, String? direction}) async {
// try {
// freightViewLoader.value = true;
//
// currentPage.value = page ?? currentPage.value;
// if (sort != null) sortField.value = sort;
// if (direction != null) sortDirection.value = direction;
//
// Map<String, String> requestBody = {
// "plant": "",
// "productNane": "",
// "freightBillNo": "",
// "transactionType": "",
// "fromLocation": "",
// "grnFromDate": "",
// "grnToDate": "",
// "page": currentPage.toString(),
// "size": pageSize.toString(),
// "sort": "${sortField.value},${sortDirection.value}"
// };
//
// var response = await PostRequests.viewFreightBill(requestBody,
// currentPage.value, pageSize.value, '$sortField', '$sortDirection');
// if (response != null) {
// List<FreightBill> flattenedContent =
// response.content!.expand((list) => list).toList();
// freightBillData.assignAll(flattenedContent);
//
// totalPages.value = response.totalPages ?? 0;
// totalElements.value = response.totalElements ?? 0;
// }
// } finally {
// freightViewLoader.value = false;
// }
// }
RxInt currentPage = 1.obs;
RxInt totalPages = 3.obs;
final int limit = 10;
viewFreightView() async {
try {
freightViewLoader.value = true;
@ -323,7 +438,9 @@ RxBool transValidate = false.obs;
}
var grnPendingData = <GrnPending>[].obs;
grnPending() async {
print('get pending');
try {
grnPendingLoader.value = true;
@ -343,39 +460,52 @@ RxBool transValidate = false.obs;
List<GrnPending> flattenedContent =
response.content!.expand((list) => list).toList();
grnPendingData.assignAll(flattenedContent);
print('response from pending tab${response.first.toString()} and ${flattenedContent.length} and ${grnPendingData.value[0].codeValue} and ${grnPendingData.value[0].plantCode} and ${grnPendingData.value[0].materialCode}');
}
} finally {
grnPendingLoader.value = false;
}
}
RxBool showPlantError = false.obs;
RxBool showProductError = false.obs;
RxBool showTransactionError = false.obs;
final selectProductVal = Rx<dynamic>(null);
RxBool showPlantErrorFreight = false.obs;
RxBool showProductErrorFreight = false.obs;
RxBool showTransactionErrorFreight = false.obs;
final selectProductValFreight = Rx<dynamic>(null);
RxBool showPlantErrorPending = false.obs;
RxBool showProductErrorPending = false.obs;
RxBool showTransactionErrorPending = false.obs;
final selectProductValPending = Rx<dynamic>(null);
void displayFilteredDataFromPending() async {
try {
isLoading.value = true;
Map<String, String> requestBody = {
"plant": selectPlantPending.value,
"productNane": selectProductPending.value,
"transactionType": selectTransactionTypePending.value,
"fromLocation": selectLocation.value,
"grnFromDate": "",
"grnToDate": ""
};
void validateFields() {
showPlantError.value = selectPlant.value.isEmpty;
showTransactionError.value = selectTransactionType.value.isEmpty;
showProductError.value = selectProductVal.value == null;
}
void validateFieldsPending() {
showPlantErrorPending.value = selectPlant.value.isEmpty;
showTransactionErrorPending.value = selectTransactionType.value.isEmpty;
showProductErrorPending.value = selectProductVal.value == null;
}
void validateFieldsFreight() {
showPlantErrorFreight.value = selectPlant.value.isEmpty;
showTransactionErrorFreight.value = selectTransactionType.value.isEmpty;
showProductErrorFreight.value = selectProductVal.value == null;
var response = await PostRequests.grnPending(requestBody);
if (response != null) {
List<GrnPending> flattenedContent =
response.content!.expand((list) => list).toList();
List<GrnPending> filteredData = flattenedContent.where((item) {
return (selectPlantFreight.value.isEmpty ||
item.plantCode == selectPlantFreight.value) &&
(selectProductFreight.value.isEmpty ||
item.materialCode == selectProductFreight.value) &&
(selectTransactionTypeFreight.value.isEmpty ||
item.codeValue == selectTransactionTypeFreight.value);
}).toList();
print("pending Data: ${filteredData.length}");
grnPendingData.assignAll(filteredData);
print("✅ pending Data: ${filteredData.length} items displayed pending.");
} else {
print("❌ No response from API.");
}
} finally {
isLoading.value = false;
}
}
}

View File

@ -207,7 +207,7 @@ void showFreightBill(BuildContext context) {
),
Obx(() {
if (controller.grnListLoader.value) {
return Center(child: CircularProgressIndicator());
return Center(child: CircularProgressIndicator(color: AppColors.primaryClr,));
}
if (controller.errorMessage.isNotEmpty) {
@ -271,7 +271,9 @@ void showFreightBill(BuildContext context) {
bkClr: Colors.white,
margin: EdgeInsets.only(top: 24),
text: "Done",
clickAction: (){}),
clickAction: (){
Get.back();
}),
)
],
),

View File

@ -20,12 +20,9 @@ class CustomPagination extends StatelessWidget {
Widget build(BuildContext context) {
return Container(
padding: const EdgeInsets.symmetric(vertical: 8.0),
padding: const EdgeInsets.symmetric(vertical: 2.0),
decoration: BoxDecoration(
//color: Colors.grey[200],
border: Border(
top: BorderSide(color: Colors.grey[300]!),
),
color: AppColors.clrF2,
),
child: Row(
mainAxisAlignment: MainAxisAlignment.end, // Center the pagination
@ -62,10 +59,10 @@ class CustomPagination extends StatelessWidget {
return InkWell(
onTap: () => onPageChanged(pageNumber),
child: Container(
height: 25,
width: 25,
height: 22,
width: 22,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(8),
borderRadius: BorderRadius.circular(4),
border: Border.all(
color: isSelected ? AppColors.primaryClr : AppColors.primaryClr),
color: isSelected ? AppColors.primaryClr : Colors.transparent,

View File

@ -48,33 +48,32 @@ class TextView extends StatelessWidget {
Widget build(BuildContext context) {
return Padding(
padding: margin ?? EdgeInsets.zero,
child: GestureDetector(
onTap: onTap,
child: Row(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Text(
capitalise != null && capitalise! ? text.toUpperCase() : text,
maxLines: maxlines,
overflow: maxlines != null ? TextOverflow.ellipsis : null,
textAlign: textAlign,
style: style ?? 12.txtBoldBlack,
),
if (isRequired == true)
const Padding(
padding: EdgeInsets.only(left: 4.0),
child: Text(
"*",
style: TextStyle(
color: Colors.red,
fontSize: 16,
fontWeight: FontWeight.bold,
),
child: Row(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Text(
capitalise != null && capitalise! ? text.toUpperCase() : text,
maxLines: maxlines,
overflow: maxlines != null ? TextOverflow.ellipsis : null,
textAlign: textAlign,
style: style ?? 12.txtBoldBlack,
),
if (isRequired == true)
const Padding(
padding: EdgeInsets.only(left: 4.0),
child: Text(
"*",
style: TextStyle(
color: Colors.red,
fontSize: 16,
fontWeight: FontWeight.bold,
),
),
],
),
),
],
),
);
}

View File

@ -35,3 +35,40 @@ class ApiUrls {
static const grnPendingDetails =
"http://46.28.44.130:9092/bill/grndetailsPanding?page=0&size=20&sort=grn_date,desc";
}
// class ApiUrls {
// ApiUrls._();
//
// static const String baseUrl = "http://localhost:9092/";
//
// static const addFreightBill =
// 'bill/grndetails?page=0&size=20&sort=grn_date,desc';
// static const getFreightBills = 'bill/dropdown';
// static const generateFreightBill =
// 'http://localhost:9092/bill/addFreightBill';
// static const createUser = 'http://localhost:9093/api/users/createUser';
// static const editUser =
// 'http://localhost:9093/api/users/update?userEmpTransCode=';
// static const getAllUser =
// 'http://localhost:9093/api/users/userdetails?page=';
// static const viewFreightBill =
// 'http://localhost:9092/bill/freightbill?page';
// static const addUserType =
// 'http://localhost:9093/api/user-types/createUserType';
// static const dropDownList =
// 'http://localhost:9093/api/user-roles/userrole_dropdown';
// static const plantMapping = 'http://localhost:9093/userplant/fetchPlants';
// static const checkStatus =
// 'http://localhost:9093/api/user-types/update-status/';
// static const getInternalUserDropdown =
// 'http://localhost:9093/api/user-roles/userrole_dropdown';
// static const fetchEmailsAndEmpCode =
// 'http://localhost:9093/api/user-roles/fetchRoles';
// static const selectAndAssignRole =
// "http://localhost:9093/api/user-roles/assignRoles";
// static const assignPlantRole =
// "http://localhost:9093/userplant/assignPlants";
// static const userTypeDetails =
// "http://localhost:9093/api/user-types/usertypedetails?page=0&size=15&sort=last_updated_on,desc";
// static const grnPendingDetails =
// "http://localhost:9092/bill/grndetailsPanding?page=0&size=20&sort=grn_date,desc";
// }

View File

@ -67,9 +67,9 @@ class PostRequests {
}
static Future<GetAllUserResModel?> getAllUser(
Map<String, String> requestBody, int page, int limit) async {
Map<String, String> requestBody, int page) async {
var apiResponse = await RemoteService.postUser(requestBody,
"${ApiUrls.getAllUser}$page&size=$limit&sort=last_updated_on,desc");
"${ApiUrls.getAllUser}$page&size=9&sort=last_updated_on,desc");
if (apiResponse != null) {
return getAllUserResModelFromJson(apiResponse.response!);
@ -155,17 +155,26 @@ class PostRequests {
}
}
// static Future<FetchInternalUserModel?> fetchEmailsAndEmpCodes(
// Map<String, String> requestBody) async {
// var apiResponse = await RemoteService.postUser(
// requestBody, ApiUrls.fetchEmailsAndEmpCode);
// if (apiResponse != null) {
// return fetchInternalUserModelFromJson(apiResponse.response!);
// } else {
// return null;
// }
// }
static Future<FetchInternalUserModel?> fetchEmailsAndEmpCodes(
Map<String, String> requestBody) async {
var apiResponse = await RemoteService.postUser(
requestBody, ApiUrls.fetchEmailsAndEmpCode);
Map<String, String> requestBody,String message) async {
var apiResponse = await RemoteService.postMethod(
requestBody, ApiUrls.fetchEmailsAndEmpCode,message);
if (apiResponse != null) {
return fetchInternalUserModelFromJson(apiResponse.response!);
} else {
return null;
}
}
static Future<SelectAssignRoleModel?> selectAssignRole(
Map<String, dynamic> requestBody) async {
var apiResponse =

View File

@ -53,7 +53,7 @@ class RemoteService {
try {
final map = jsonDecode(response.body) as Map<String, dynamic>;
AppAlerts.alert(message: '${map['message']}');
// AppAlerts.alert(message: '${map['message']}');
throw map['message'];
} catch (e) {
@ -133,7 +133,7 @@ class RemoteService {
} else {
try {
final map = jsonDecode(response.body) as Map<String, dynamic>;
AppAlerts.alert(message: '${map['message']}');
// AppAlerts.alert(message: '${map['message']}');
throw map['message'];
} catch (e) {
@ -156,7 +156,7 @@ class RemoteService {
} else {
try {
final map = jsonDecode(response.body) as Map<String, dynamic>;
AppAlerts.alert(message: '${map['message']}');
// AppAlerts.alert(message: '${map['message']}');
throw map['message'];
} catch (e) {
@ -210,7 +210,7 @@ class RemoteService {
} else {
try {
final map = jsonDecode(response.body) as Map<String, dynamic>;
AppAlerts.alert(message: '${map['message']}');
// AppAlerts.alert(message: '${map['message']}');
throw map['message'];
} catch (e) {
@ -225,7 +225,7 @@ class RemoteService {
final response =
await http.post(Uri.parse(endUrl), headers: getHeaders(), body: body);
print('${response.body}response');
print(_baseUrl + endUrl);
print(endUrl);
print('${response.statusCode}response');
var responseCode = response.statusCode;
@ -236,7 +236,7 @@ class RemoteService {
try {
final map = jsonDecode(response.body) as Map<String, dynamic>;
AppAlerts.alert(message: '${map['message']}');
// AppAlerts.alert(message: '${map['message']}');
throw map['message'];
} catch (e) {
@ -285,7 +285,34 @@ class RemoteService {
} else {
try {
final map = jsonDecode(response.body) as Map<String, dynamic>;
AppAlerts.alert(message: '${map['message']}');
// AppAlerts.alert(message: '${map['message']}');
throw map['message'];
} catch (e) {
return null;
}
}
}
static Future<CommonResModel?> postMethod(
Map<String, dynamic> requestBody, String endUrl,String message) async {
var body = json.encode(requestBody);
final response =
await http.post(Uri.parse(endUrl), headers: getHeaders(), body: body);
print('${response.body}response');
print(endUrl);
print('${response.statusCode}response');
var responseCode = response.statusCode;
if (Helpers.isResponseSuccessful(responseCode)) {
return CommonResModel(statusCode: responseCode, response: response.body);
} else {
print(response.body);
try {
final map = jsonDecode(response.body) as Map<String, dynamic>;
message = '${map['message']}';
print("message?????${message}");
throw map['message'];
} catch (e) {
return null;

View File

@ -321,5 +321,5 @@ packages:
source: hosted
version: "1.1.0"
sdks:
dart: ">=3.6.1 <4.0.0"
dart: ">=3.6.0 <4.0.0"
flutter: ">=3.18.0-18.0.pre.54"

View File

@ -19,8 +19,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev
version: 1.0.0+1
environment:
sdk: ^3.6.1
sdk: ^3.6.0
# Dependencies specify other packages that your package needs in order to work.
# To automatically upgrade your package dependencies to the latest versions