generate freight bill

dev_branch
Priya Chetiwal 2025-02-04 20:09:25 +05:30
parent faf484e8e0
commit a52b90a7d2
9 changed files with 1011 additions and 636 deletions

View File

@ -546,6 +546,13 @@ class _CustomDropdownState<T> extends State<CustomDropdown<T>> {
style: 12.txtSBoldGrey, style: 12.txtSBoldGrey,
overflow: TextOverflow.ellipsis, overflow: TextOverflow.ellipsis,
), ),
// Text(
// selectedItem != null
// ? widget.itemLabel(selectedItem as T)
// : widget.hintText,
// style: 12.txtSBoldGrey,
// overflow: TextOverflow.ellipsis,
// ),
), ),
const Icon( const Icon(
Icons.keyboard_arrow_down_outlined, Icons.keyboard_arrow_down_outlined,

View File

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

View File

@ -41,7 +41,7 @@ class PendingGeneration extends StatelessWidget {
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
TextView(text: TextView(text:
"Plant"), "Plant", isRequired: true),
SizedBox(height: 8), SizedBox(height: 8),
CustomDropdown( CustomDropdown(
backClr: AppColors.clrD9, backClr: AppColors.clrD9,
@ -50,13 +50,21 @@ class PendingGeneration extends StatelessWidget {
itemLabel: (item) => "${item.plantCode}-${item.plantDesc}", itemLabel: (item) => "${item.plantCode}-${item.plantDesc}",
onSelected: (selected) { onSelected: (selected) {
if (selected != null) { if (selected != null) {
controller.selectPlant.value = selected.plantCode ?? ""; controller.selectPlantPending.value = selected.plantCode ?? "";
print( controller.showPlantErrorPending.value = false;
"selectPlant${controller.selectPlant.value}");
} }
}, },
hintText: "Select Plant", hintText: "Select Plant",
), ),
Obx(() => controller.showPlantErrorPending.value
? Padding(
padding: const EdgeInsets.only(top: 4),
child: Text(
'Please select a plant',
style: TextStyle(color: Colors.red, fontSize: 12),
),
)
: SizedBox.shrink()),
], ],
), ),
), ),
@ -66,7 +74,7 @@ class PendingGeneration extends StatelessWidget {
mainAxisAlignment: MainAxisAlignment.start, mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
TextView(text:"Product Name"), TextView(text:"Product Name", isRequired: true),
SizedBox(height: 8), SizedBox(height: 8),
CustomDropdown<dynamic>( CustomDropdown<dynamic>(
width: 250, width: 250,
@ -76,7 +84,7 @@ class PendingGeneration extends StatelessWidget {
itemLabel: (item) => "${item.materialCode}-${item.materialDescription}", itemLabel: (item) => "${item.materialCode}-${item.materialDescription}",
onSelected: (selected) { onSelected: (selected) {
if (selected != null) { if (selected != null) {
controller.selectProduct.value = selected; controller.selectProductPending.value = selected;
print( print(
"selectPlant${controller.selectProduct.value}"); "selectPlant${controller.selectProduct.value}");
} }
@ -92,7 +100,7 @@ class PendingGeneration extends StatelessWidget {
mainAxisAlignment: MainAxisAlignment.start, mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
TextView(text:"Transaction Type"), TextView(text:"Transaction Type", isRequired: true),
SizedBox(height: 8), SizedBox(height: 8),
CustomDropdown<String>( CustomDropdown<String>(
backClr: AppColors.clrD9, backClr: AppColors.clrD9,
@ -101,13 +109,20 @@ class PendingGeneration extends StatelessWidget {
itemLabel: (item) => item, itemLabel: (item) => item,
onSelected: (selected) { onSelected: (selected) {
if (selected != null) { if (selected != null) {
controller.selectTransactionType.value = selected; controller.selectTransactionTypePending.value = selected;
print( controller.showTransactionErrorPending.value = false; }
"selectTransactionType${controller.selectTransactionType.value}");
}
}, },
hintText: "Select Transaction Type", hintText: "Select Transaction Type",
), ),
Obx(() => controller.showTransactionErrorPending.value
? Padding(
padding: const EdgeInsets.only(top: 4),
child: Text(
'Please select Transaction Type',
style: TextStyle(color: Colors.red, fontSize: 12),
),
)
: SizedBox.shrink()),
], ],
), ),
), ),
@ -258,7 +273,16 @@ class PendingGeneration extends StatelessWidget {
text: AppStrings.submit, text: AppStrings.submit,
clickAction: () { clickAction: () {
controller.postData(); controller.validateFieldsPending();
if (controller.showPlantErrorPending.value ||
controller.showProductErrorPending.value ||
controller.showTransactionErrorPending.value
) {
} else {
controller.postData();
}
}, },
), ),
], ],

View File

@ -41,24 +41,35 @@ class ViewFreightBill extends StatelessWidget {
mainAxisAlignment: MainAxisAlignment.start, mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
TextView(text: "Plant"), TextView(text: "Plant", isRequired: true),
SizedBox(height: 8), SizedBox(height: 8),
CustomDropdown( CustomDropdown(
backClr: AppColors.clrD9, backClr: AppColors.clrD9,
borderClr: AppColors.clrGrey, borderClr: AppColors.clrGrey,
items: controller.plant, items: controller.plant,
itemLabel: (item) => itemLabel: (item) =>
"${item.plantCode}-${item.plantDesc}", "${item.plantCode}-${item.plantDesc}",
onSelected: (selected) { onSelected: (selected) {
if (selected != null) { if (selected != null) {
controller.selectPlant.value = controller.selectPlant.value =
selected.plantCode ?? ""; selected.plantCode ?? "";
controller.showPlantErrorFreight.value = false;
print( print(
"selectPlant${controller.selectPlant.value}"); "selectPlant${controller.selectPlant.value}");
} }
}, },
hintText: "Select Plant", hintText: "Select Plant",
), ),
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()),
], ],
), ),
), ),
@ -68,7 +79,7 @@ class ViewFreightBill extends StatelessWidget {
mainAxisAlignment: MainAxisAlignment.start, mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
TextView(text: "Product Name"), TextView(text: "Product Name", isRequired: true),
SizedBox(height: 8), SizedBox(height: 8),
CustomDropdown<dynamic>( CustomDropdown<dynamic>(
width: 250, width: 250,
@ -76,12 +87,13 @@ class ViewFreightBill extends StatelessWidget {
borderClr: AppColors.clrGrey, borderClr: AppColors.clrGrey,
items: controller.product, items: controller.product,
itemLabel: (item) => itemLabel: (item) =>
"${item.materialCode}-${item.materialDescription}", "${item.materialCode}-${item.materialDescription}",
onSelected: (selected) { onSelected: (selected) {
if (selected != null) { if (selected != null) {
controller.selectProduct.value = selected; controller.selectProduct.value = selected;
print( print(
"selectPlant${controller.selectProduct.value}"); "selectPlant${controller.selectProduct
.value}");
} }
}, },
hintText: "Select Product Name", hintText: "Select Product Name",
@ -95,7 +107,7 @@ class ViewFreightBill extends StatelessWidget {
mainAxisAlignment: MainAxisAlignment.start, mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
TextView(text: "Transaction Type"), TextView(text: "Transaction Type", isRequired: true),
SizedBox(height: 8), SizedBox(height: 8),
CustomDropdown<String>( CustomDropdown<String>(
backClr: AppColors.clrD9, backClr: AppColors.clrD9,
@ -105,12 +117,25 @@ class ViewFreightBill extends StatelessWidget {
onSelected: (selected) { onSelected: (selected) {
if (selected != null) { if (selected != null) {
controller.selectTransactionType.value = selected; controller.selectTransactionType.value = selected;
controller.showTransactionErrorFreight.value =
false;
print( print(
"selectTransactionType${controller.selectTransactionType.value}"); "selectTransactionType${controller
.selectTransactionType.value}");
} }
}, },
hintText: "Select Transaction Type", hintText: "Select Transaction Type",
), ),
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()),
], ],
), ),
), ),
@ -145,7 +170,7 @@ class ViewFreightBill extends StatelessWidget {
if (pickedDate != null) { if (pickedDate != null) {
controller.fromSelectedDate = pickedDate; controller.fromSelectedDate = pickedDate;
String formattedDate = String formattedDate =
controller.getFormattedDate(pickedDate); controller.getFormattedDate(pickedDate);
controller.fromController.text = controller.fromController.text =
formattedDate; formattedDate;
controller.dateCheck.value = true; controller.dateCheck.value = true;
@ -161,33 +186,33 @@ class ViewFreightBill extends StatelessWidget {
border: OutlineInputBorder( border: OutlineInputBorder(
borderRadius: BorderRadius.circular(2.0), borderRadius: BorderRadius.circular(2.0),
borderSide: borderSide:
BorderSide(color: AppColors.black), BorderSide(color: AppColors.black),
), ),
enabledBorder: OutlineInputBorder( enabledBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(2.0), borderRadius: BorderRadius.circular(2.0),
borderSide: borderSide:
BorderSide(color: AppColors.clrGrey), BorderSide(color: AppColors.clrGrey),
), ),
focusedBorder: OutlineInputBorder( focusedBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(2.0), borderRadius: BorderRadius.circular(2.0),
borderSide: borderSide:
BorderSide(color: AppColors.clrGrey), BorderSide(color: AppColors.clrGrey),
), ),
disabledBorder: OutlineInputBorder( disabledBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(2.0), borderRadius: BorderRadius.circular(2.0),
borderSide: borderSide:
BorderSide(color: AppColors.clrGrey), BorderSide(color: AppColors.clrGrey),
), ),
suffixIcon: controller.dateCheck.value suffixIcon: controller.dateCheck.value
? InkWell( ? InkWell(
onTap: () { onTap: () {
controller.dateCheck.value = false; controller.dateCheck.value = false;
controller.fromController.clear(); controller.fromController.clear();
controller.fromSelectedDate = controller.fromSelectedDate =
DateTime.now(); DateTime.now();
}, },
child: Icon(Icons.close, size: 1.2.w), child: Icon(Icons.close, size: 1.2.w),
) )
: null, : null,
contentPadding: const EdgeInsets.symmetric( contentPadding: const EdgeInsets.symmetric(
horizontal: 12.0, vertical: 0.0), horizontal: 12.0, vertical: 0.0),
@ -224,37 +249,50 @@ class ViewFreightBill extends StatelessWidget {
width: 16, width: 16,
), ),
Expanded( Expanded(
//flex: 2, //flex: 2,
child: Column( child: Column(
children: [ children: [
TextView( TextView(
text: "", text: "",
), ),
Padding( Padding(
padding: const EdgeInsets.only(top: 8.0), padding: const EdgeInsets.only(top: 8.0),
child: Row( child: Row(
mainAxisAlignment: MainAxisAlignment.end, mainAxisAlignment: MainAxisAlignment.end,
children: [ children: [
CommonBtn( CommonBtn(
bkClr: Colors.white, bkClr: Colors.white,
text: AppStrings.cancel, text: AppStrings.cancel,
clickAction: () {}, clickAction: () {},
),
SizedBox(width: 16),
CommonButton(
borderRadius: 4,
height: 30,
width: 100,
text: AppStrings.submit,
clickAction: () {
if (controller.showPlantErrorFreight
.value ||
controller.showProductErrorFreight
.value ||
controller.showTransactionErrorFreight
.value
) {
print(
'controller.showProductError.value ${controller
.showProductError.value}');
} else {
controller.postData();
}
},
),
],
), ),
SizedBox(width: 16), ),
CommonButton( ],
borderRadius: 4, ))
height: 30,
width: 100,
text: AppStrings.submit,
clickAction: () {
controller.postData();
},
),
],
),
),
],
))
], ],
), ),
), ),
@ -335,12 +373,12 @@ class ViewFreightBill extends StatelessWidget {
dataRowHeight: 28, dataRowHeight: 28,
headingRowHeight: 38, headingRowHeight: 38,
headingRowColor: headingRowColor:
WidgetStateProperty.all(AppColors.clrF2), WidgetStateProperty.all(AppColors.clrF2),
border: TableBorder( border: TableBorder(
horizontalInside: horizontalInside:
BorderSide(color: AppColors.clrGrey), BorderSide(color: AppColors.clrGrey),
verticalInside: verticalInside:
BorderSide(color: AppColors.clrGrey), BorderSide(color: AppColors.clrGrey),
bottom: BorderSide(color: AppColors.clrGrey), bottom: BorderSide(color: AppColors.clrGrey),
left: BorderSide(color: AppColors.clrGrey), left: BorderSide(color: AppColors.clrGrey),
right: BorderSide(color: AppColors.clrGrey), right: BorderSide(color: AppColors.clrGrey),
@ -351,8 +389,9 @@ class ViewFreightBill extends StatelessWidget {
dataColumn(AppStrings.plant), dataColumn(AppStrings.plant),
dataColumn( dataColumn(
AppStrings.productName, AppStrings.productName,
onSort: (_, __) => controller.changeSort( onSort: (_, __) =>
AppStrings.productName.toLowerCase()), controller.changeSort(
AppStrings.productName.toLowerCase()),
), ),
dataColumn(AppStrings.freightBillNo), dataColumn(AppStrings.freightBillNo),
dataColumn(AppStrings.freightBillDate), dataColumn(AppStrings.freightBillDate),
@ -393,7 +432,7 @@ class ViewFreightBill extends StatelessWidget {
rows: List<DataRow>.generate( rows: List<DataRow>.generate(
controller.freightBillData.length, (index) { controller.freightBillData.length, (index) {
final freightBill = final freightBill =
controller.freightBillData[index]; controller.freightBillData[index];
return DataRow( return DataRow(
cells: [ cells: [
@ -414,7 +453,8 @@ class ViewFreightBill extends StatelessWidget {
editableCell(index, editableCell(index,
"${freightBill.trasnporterInvoiceNo}"), "${freightBill.trasnporterInvoiceNo}"),
editableCell(index, editableCell(index,
"${freightBill.trasnporterInvoiceNoDate}"), "${freightBill
.trasnporterInvoiceNoDate}"),
editableCell( editableCell(
index, "${freightBill.billingQty}"), index, "${freightBill.billingQty}"),
editableCell(index, "${freightBill.uom}"), editableCell(index, "${freightBill.uom}"),
@ -430,12 +470,14 @@ class ViewFreightBill extends StatelessWidget {
editableCell( editableCell(
index, "${freightBill.freightAmount}"), index, "${freightBill.freightAmount}"),
editableCell(index, editableCell(index,
"${freightBill.trasnporterInvoiceNoDate}"), "${freightBill
.trasnporterInvoiceNoDate}"),
editableCell(index, "${freightBill.status}"), editableCell(index, "${freightBill.status}"),
editableCell( editableCell(
index, "${freightBill.totalGst}"), index, "${freightBill.totalGst}"),
editableCell(index, editableCell(index,
"${freightBill.trasnporterInvoiceNoDate}"), "${freightBill
.trasnporterInvoiceNoDate}"),
editableCell(index, "${freightBill.utr5No}"), editableCell(index, "${freightBill.utr5No}"),
editableCell( editableCell(
index, "${freightBill.utr1Date}"), index, "${freightBill.utr1Date}"),
@ -490,8 +532,8 @@ class ViewFreightBill extends StatelessWidget {
); );
} }
void showFreightBillDetailsDialog( void showFreightBillDetailsDialog(BuildContext context,
BuildContext context, FreightBill freightBill) { FreightBill freightBill) {
showDialog( showDialog(
context: context, context: context,
builder: (BuildContext context) { builder: (BuildContext context) {
@ -536,12 +578,12 @@ class ViewFreightBill extends StatelessWidget {
dataRowHeight: 28, dataRowHeight: 28,
headingRowHeight: 38, headingRowHeight: 38,
headingRowColor: headingRowColor:
WidgetStateProperty.all(AppColors.clrF2), WidgetStateProperty.all(AppColors.clrF2),
border: TableBorder( border: TableBorder(
horizontalInside: horizontalInside:
BorderSide(color: AppColors.clrGrey), BorderSide(color: AppColors.clrGrey),
verticalInside: verticalInside:
BorderSide(color: AppColors.clrGrey), BorderSide(color: AppColors.clrGrey),
bottom: BorderSide(color: AppColors.clrGrey), bottom: BorderSide(color: AppColors.clrGrey),
left: BorderSide(color: AppColors.clrGrey), left: BorderSide(color: AppColors.clrGrey),
right: BorderSide(color: AppColors.clrGrey), right: BorderSide(color: AppColors.clrGrey),
@ -552,8 +594,9 @@ class ViewFreightBill extends StatelessWidget {
dataColumn(AppStrings.mrnNo), dataColumn(AppStrings.mrnNo),
dataColumn( dataColumn(
AppStrings.plantName, AppStrings.plantName,
onSort: (_, __) => controller.changeSort( onSort: (_, __) =>
AppStrings.productName.toLowerCase()), controller.changeSort(
AppStrings.productName.toLowerCase()),
), ),
dataColumn(AppStrings.product), dataColumn(AppStrings.product),
dataColumn(AppStrings.date), dataColumn(AppStrings.date),
@ -571,7 +614,7 @@ class ViewFreightBill extends StatelessWidget {
rows: List<DataRow>.generate( rows: List<DataRow>.generate(
controller.freightBillData.length, (index) { controller.freightBillData.length, (index) {
final freightBill = final freightBill =
controller.freightBillData[index]; controller.freightBillData[index];
return DataRow( return DataRow(
cells: [ cells: [
editableCell(index, "0${index + 1}"), editableCell(index, "0${index + 1}"),

View File

@ -163,202 +163,38 @@ class _TransportViewState extends State<TransportView> {
style: 12.txtBoldWhite, style: 12.txtBoldWhite,
), ),
), ),
Obx( Obx(
() => Visibility( () => Visibility(
visible: ctrl.selectedUser.value >= 1, visible: ctrl.selectedUser.value == 0,
child: InkWell( child: InkWell(
onTap: ctrl.toggleContainer, onTap: () {
child: Image.asset(AppImages.filter, ctrl.toggleFilter(); // Toggle visibility on tap
height: 16, width: 16)), },
child: Image.asset(AppImages.filter, height: 16, width: 16),
),
), ),
), ),
Visibility(
visible: ctrl.selectedUser.value >= 1, Obx(
child: Padding( () => Visibility(
padding: const EdgeInsets.all(8.0), visible: ctrl.selectedUser.value == 0,
child: TextView( child: Padding(
text: AppStrings.filter, padding: const EdgeInsets.all(8.0),
style: 12.txtBoldWhite, 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(() { Obx(() {
switch (ctrl.selectedUser.value) { switch (ctrl.selectedUser.value) {
case 0: case 0:

View File

@ -20,13 +20,23 @@ class TransportController extends GetxController {
var selectProduct = ''.obs; var selectProduct = ''.obs;
var selectLocation = ''.obs; var selectLocation = ''.obs;
var selectTransactionType = ''.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 selectedItem = false.obs;
var grnDetails = <Content>[].obs; var grnDetails = <Content>[].obs;
var filterGrnDetails = <Content>[].obs;
var product = <Prodect>[].obs; var product = <Prodect>[].obs;
var plant = <Plant>[].obs; var plant = <Plant>[].obs;
var freightBill = [].obs; var freightBill = [].obs;
var fromLocation = [].obs; var fromLocation = [].obs;
var grnList = [].obs; var grnList = [].obs;
RxBool showE = false.obs;
RxBool selectAllField = false.obs; RxBool selectAllField = false.obs;
void toggleSelection(int index, bool? value) { void toggleSelection(int index, bool? value) {
@ -34,6 +44,26 @@ class TransportController extends GetxController {
grnDetails.refresh(); grnDetails.refresh();
} }
void toggleSelectionFilter(int index, bool? value) {
filterGrnDetails[index].isSelected = value!;
filterGrnDetails.refresh();
}
RxBool isFilterVisible = false.obs;
final int initialRecordCount = 20;
// Validation variables
RxBool showPlantError = false.obs;
RxBool showProductError = false.obs;
RxBool showTransactionError = false.obs;
void toggleFilter() {
isFilterVisible.value = !isFilterVisible.value; // Toggle the value
if (!isFilterVisible.value) {
// Clear filters when hiding
clearFilters();
}
}
void selectAll(bool value) { void selectAll(bool value) {
for (var item in grnDetails) { for (var item in grnDetails) {
item.isSelected = value; item.isSelected = value;
@ -41,12 +71,48 @@ class TransportController extends GetxController {
selectAllField.value = value; selectAllField.value = value;
grnDetails.refresh(); grnDetails.refresh();
} }
void selectAllFilter(bool value) {
for (var item in filterGrnDetails) {
item.isSelected = value;
}
selectAllField.value = value;
filterGrnDetails.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;
final selectProductValPending = Rx<dynamic>(null);
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 = selectProductValPending.value == null;
}
void validateFieldsGenerateFreight() {
showPlantErrorFreight.value = selectPlantFreight.value.isEmpty;
showTransactionErrorFreight.value =
selectTransactionTypeFreight.value.isEmpty;
showProductErrorFreight.value = selectProductFreight.value.isEmpty;
}
@override @override
void onInit() { void onInit() {
getFreightBills(); getFreightBills();
viewFreightView(); viewFreightView();
grnPending(); grnPending();
postData();
super.onInit(); super.onInit();
} }
@ -104,6 +170,100 @@ class TransportController extends GetxController {
} }
} }
void displayFilteredData() async {
try {
isLoading.value = true;
// Construct requestBody to filter based on selected values
Map<String, String> requestBody = {
"plant": selectPlantFreight.value,
"productNane": selectProductFreight.value,
"transactionType": selectTransactionTypeFreight.value,
"fromLocation": selectLocation.value, // If required
"grnFromDate": "",
"grnToDate": ""
};
// Make the API call
var response = await PostRequests.addFreightBill(requestBody);
if (response != null) {
print("API Response: $response"); // Debug print the API response
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}");
// Apply filters locally on the fetched data
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.transporterCode == selectTransactionTypeFreight.value
);
}).toList();
print("Filtered Data: ${filteredData.length}");
filterGrnDetails.assignAll(filteredData);
print("✅ Filtered Data: ${filteredData.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 handleFilterSubmit() {
// Step 1: Validate input fields
validateFieldsGenerateFreight();
// Step 2: Check if any required field is empty
if (selectPlantFreight.value.isEmpty ||
selectProductFreight.value.isEmpty ||
selectTransactionTypeFreight.value.isEmpty
) {
print('⚠️ Required fields are empty. Showing filtered data instead of calling API.');
// TODO: Implement logic to show filtered data here
displayFilteredData();
} else {
// Step 3: If all fields are filled, proceed with API call
print('✅ All fields are valid. Calling API...');
// postData();
// displayFilteredData();
}
}
void clearFilters() {
selectPlantFreight.value = '';
selectProductFreight.value = '';
selectTransactionTypeFreight.value = '';
fromController.clear();
showPlantError.value = false;
showProductError.value = false;
showTransactionError.value = false;
postData(); // Reload initial data
}
getFreightBills() async { getFreightBills() async {
try { try {
isLoading.value = true; isLoading.value = true;
@ -161,9 +321,9 @@ class TransportController extends GetxController {
addFreightBill() async { addFreightBill() async {
try { try {
grnListLoader.value = true; grnListLoader.value = true;
final addDataFromgrnDetails = grnDetails.isEmpty ? filterGrnDetails : grnDetails;
// Filter the selected rows // Filter the selected rows
final List<Map<String, dynamic>> selectedGrns = grnDetails final List<Map<String, dynamic>> selectedGrns = addDataFromgrnDetails
.where((grn) => grn.isSelected) // Get only the selected rows .where((grn) => grn.isSelected) // Get only the selected rows
.map((grn) => { .map((grn) => {
"grn_id": grn.grnId, "grn_id": grn.grnId,
@ -206,6 +366,7 @@ class TransportController extends GetxController {
var pageSize = 2.obs; var pageSize = 2.obs;
var sortField = "grn_date".obs; var sortField = "grn_date".obs;
var sortDirection = "desc".obs; var sortDirection = "desc".obs;
// viewFreightView({int? page, String? sort, String? direction}) async { // viewFreightView({int? page, String? sort, String? direction}) async {
// try { // try {
// freightViewLoader.value = true; // freightViewLoader.value = true;
@ -244,6 +405,7 @@ class TransportController extends GetxController {
RxInt currentPage = 1.obs; RxInt currentPage = 1.obs;
RxInt totalPages = 3.obs; RxInt totalPages = 3.obs;
final int limit = 10; final int limit = 10;
viewFreightView() async { viewFreightView() async {
try { try {
freightViewLoader.value = true; freightViewLoader.value = true;
@ -310,6 +472,7 @@ class TransportController extends GetxController {
} }
var grnPendingData = <GrnPending>[].obs; var grnPendingData = <GrnPending>[].obs;
grnPending() async { grnPending() async {
try { try {
grnPendingLoader.value = true; grnPendingLoader.value = true;

View File

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

View File

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