Compare commits

...

4 Commits

33 changed files with 3044 additions and 848 deletions

View File

@ -1,5 +1,5 @@
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:shayog/components/styles/app_colors.dart';
import 'package:shayog/components/styles/textStyles.dart';
class CustomDropdown<T> extends StatefulWidget {
@ -8,7 +8,7 @@ class CustomDropdown<T> extends StatefulWidget {
final Function(T?) onSelected;
final String hintText;
final bool enableSearch;
// final double width;
final double? width;
final EdgeInsetsGeometry padding;
final T? initialValue; // Add initialValue parameter
final bool showError;
@ -22,7 +22,7 @@ class CustomDropdown<T> extends StatefulWidget {
required this.onSelected,
required this.hintText,
this.enableSearch = true,
// this.width = 100.0,
this.width,
this.padding = const EdgeInsets.all(8.0),
this.initialValue, // Initialize with a value for edit mode
this.showError = false,
@ -156,7 +156,7 @@ class _CustomDropdownState<T> extends State<CustomDropdown<T>> {
child: Stack(
children: [
Positioned(
width: 150,
width: widget.width?? 250,
child: CompositedTransformFollower(
link: layerLink,
showWhenUnlinked: false,

View File

@ -85,4 +85,7 @@ class AppStrings {
static const String cancelledInvoice = "Cancelled Invoice";
static const String ccnView = "CCN View";
static const String transporterInbound = "Transporter Inbound Transaction";
static const String billdayConfiguration = "Bill day Configuration";
static const String bufferdayConfiguration = "Buffer day Configuration";
static const String ccnConfiguration = "CCN Configuration";
}

View File

@ -1,42 +1,300 @@
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:get/get_core/src/get_main.dart';
import 'package:get/get_state_manager/src/rx_flutter/rx_obx_widget.dart';
import 'package:shayog/feature/presentation/screens/admin/configuration_management/configuration_screen_controller.dart';
import '../../../../../components/common/common_btn.dart';
import '../../../../../components/common/input_field.dart';
import '../../../../../components/styles/app_colors.dart';
import '../../../../../components/styles/app_images.dart';
import '../../../../../components/styles/app_strings.dart';
import '../../../widgets/custom_table.dart';
class ConfigurationScreen extends StatelessWidget {
class ConfigurationScreen extends StatefulWidget {
const ConfigurationScreen({super.key});
@override
State<ConfigurationScreen> createState() => _ConfigurationScreenState();
}
class _ConfigurationScreenState extends State<ConfigurationScreen> {
final ctrl = Get.put(ConfigurationScreenController());
@override
Widget build(BuildContext context) {
return Padding(
padding: const EdgeInsets.all(8.0),
child: Column(
children: [
// Row 1 (Header Row)
Row(
children: [
CustomTable(text:"Header 1", isHeader: true),
CustomTable(text:"Header 2", isHeader: true),
CustomTable(text:"Header 3", isHeader: true),
],
),
Row(
children: [
CustomTable(text:"Row 1, Col 1"),
CustomTable(text:"Row 1, Col 2"),
CustomTable(text:"Row 1, Col 3"),
],
),
Row(
children: [
CustomTable(text:"Row 2, Col 1"),
CustomTable(text:"Row 2, Col 2"),
CustomTable(text:"Row 2, Col 3"),
],
Container(
padding: EdgeInsets.only(bottom: 4),
margin: EdgeInsets.all(8),
child: Column(
children: [
Container(
margin: EdgeInsets.only(bottom: 12),
height: 45,
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.selectedState.value = index;
},
child: Container(
margin: EdgeInsets.only(bottom: 10, top: 10),
decoration: BoxDecoration(
border: Border(
bottom: BorderSide(
color:
ctrl.selectedState.value == index
? Colors.white
: AppColors.primaryClr,
width: 3))),
child: Center(
child: Text(
ctrl.userTabs[index].title ?? "",
style: TextStyle(
fontSize: 12,
fontWeight: FontWeight.w900,
color: Colors.white),
),
),
),
),
);
},
separatorBuilder: (context, index) {
return SizedBox(width: 16);
},
itemCount: ctrl.userTabs.length),
Spacer(),
InkWell(
child: Image.asset(AppImages.refresh,
height: 10, width: 10)),
Padding(
padding: const EdgeInsets.all(8.0),
child: Text(
AppStrings.refresh,
style: TextStyle(
color: AppColors.white,
fontSize: 10,
fontWeight: FontWeight.normal),
),
),
],
),
),
],
),
),
],
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: [
_commonText(
"Plant",
),
SizedBox(height: 8),
InputField(
title: "Select Plant ",
),
// Obx(
// () => Container(
// padding: EdgeInsets.only(left: 8),
// height: 35,
// decoration: BoxDecoration(
// borderRadius:
// BorderRadius.circular(4.0),
// color: AppColors.clrD9,
// border: Border.all(
// color: AppColors.clrGrey)),
// child: DropdownButton<String>(
// icon: Icon(
// Icons
// .keyboard_arrow_down_outlined,
// size: 20,
// color: AppColors.darkGrey),
//
// isExpanded: true,
// underline: SizedBox(),
//
// value: ctrl
// .selectedInvoice.value,
// // Use the selected value
// onChanged: (String? newValue) {
// if (newValue != null) {
// ctrl.selectedInvoice.value =
// newValue; // Update the selected value
// }
// },
// items: ctrl.invoiceNoItems
// .map((String value) {
// return DropdownMenuItem<String>(
// value: value.toString(),
// child: Text(
// value,
// style: TextStyle(
// fontSize: 12,
// color:
// AppColors.darkGrey),
// ),
// );
// }).toList(),
// ),
// ),
// ),
],
)),
SizedBox(width: 16),
Expanded(
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
_commonText(
"User Name",
),
SizedBox(height: 8),
InputField(
title: "Select User Name",
),
],
)),
SizedBox(width: 16),
Expanded(
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
_commonText(
"Product Name",
),
SizedBox(height: 8),
InputField(
title: "Select Product Name ",
),
// Obx(
// () => Container(
// padding: EdgeInsets.only(left: 8),
// height: 35,
// decoration: BoxDecoration(
// borderRadius:
// BorderRadius.circular(4.0),
// color: AppColors.clrD9,
// border: Border.all(
// color: AppColors.clrGrey)),
// child: DropdownButton<String>(
// icon: Icon(
// Icons
// .keyboard_arrow_down_outlined,
// size: 20,
// color: AppColors.darkGrey),
//
// isExpanded: true,
// underline: SizedBox(),
//
// value: ctrl
// .selectedFreightNo.value,
// // Use the selected value
// onChanged: (String? newValue) {
// if (newValue != null) {
// ctrl
// .selectedFreightNo.value =
// newValue; // Update the selected value
// }
// },
// items: ctrl.freightBillNoItems
// .map((String value) {
// return DropdownMenuItem<String>(
// value: value.toString(),
// child: Text(
// value,
// style: TextStyle(
// fontSize: 12,
// color:
// AppColors.darkGrey),
// ),
// );
// }).toList(),
// ),
// ),
// ),
],
)),
],
),
Padding(
padding:
const EdgeInsets.only(top: 16.0, left: 0, right: 8),
child: Row(
children: [
Expanded(
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
_commonText(
"Bill day",
),
SizedBox(height: 8),
InputField(
title: "Select Bill Day",
),
],
)),
],
),
),
Padding(
padding: const EdgeInsets.all(16.0),
child: Row(
mainAxisAlignment: MainAxisAlignment.end,
children: [
CommonBtn(
bkClr: Colors.white,
text: AppStrings.cancel,
clickAction: () {},
),
SizedBox(width: 16),
CommonBtn(
bkClr: Colors.white,
text: AppStrings.submit,
clickAction: () {},
),
],
),
),
],
),
)
],
),
);
}
_commonText(String title) {
return Text(
title,
style: TextStyle(
fontSize: 13, color: Colors.black, fontWeight: FontWeight.w900),
);
}
}

View File

@ -0,0 +1,24 @@
import 'package:get/get_rx/src/rx_types/rx_types.dart';
import 'package:get/get_state_manager/src/simple/get_controllers.dart';
import '../../../../../components/common/common_model.dart';
import '../../../../../components/styles/app_strings.dart';
class ConfigurationScreenController extends GetxController{
var selectedState = 0.obs;
RxBool isSelected = false.obs;
RxList userTabs = <CommonModel>[
CommonModel(title: AppStrings.billdayConfiguration),
CommonModel(title: AppStrings.bufferdayConfiguration),
CommonModel(title: AppStrings.ccnConfiguration),
].obs;
var selectedInvoice = '41896424644'.obs; // Default value
var selectedFreightNo = '9841651635426'.obs; // Default value
void toggleContainer() {
isSelected.value = true;
print("isSelected.value..${isSelected.value}");
}
var invoiceNoItems = ['41896424644', '41896424644',
'41896424644', '41896424644','41896424644'].obs;
var freightBillNoItems = ['9841651635426','9841651635426','9841651635426','9841651635426','9841651635426'];
}

View File

@ -342,10 +342,6 @@ class FreightBillScreen extends StatelessWidget {
TableRow(
decoration: BoxDecoration(color: AppColors.secondaryClr),
children: [
_cellText(
text: "SR. No.",
clr: Colors.black,
fontWeight: FontWeight.bold),
_cellText(
text: "Transporter Name",
clr: Colors.black,
@ -378,7 +374,6 @@ class FreightBillScreen extends StatelessWidget {
fontWeight: FontWeight.bold),
]),
TableRow(children: [
_cellText(text: "01"),
_cellText(text: "User 1"),
_cellText(text: "9841651635426", clr: AppColors.primaryClr),
_cellText(text: "1 August 2024"),
@ -389,7 +384,6 @@ class FreightBillScreen extends StatelessWidget {
_cellText(text: "78646646"),
]),
TableRow(children: [
_cellText(text: "02"),
_cellText(text: "User 2"),
_cellText(text: "9841651635426", clr: AppColors.primaryClr),
_cellText(text: "1 August 2024"),
@ -400,7 +394,6 @@ class FreightBillScreen extends StatelessWidget {
_cellText(text: "78646646"),
]),
TableRow(children: [
_cellText(text: "03"),
_cellText(text: "User 3"),
_cellText(text: "9841651635426", clr: AppColors.primaryClr),
_cellText(text: "1 August 2024"),
@ -411,7 +404,6 @@ class FreightBillScreen extends StatelessWidget {
_cellText(text: "-"),
]),
TableRow(children: [
_cellText(text: "04"),
_cellText(text: "User 4"),
_cellText(text: "9841651635426", clr: AppColors.primaryClr),
_cellText(text: "1 August 2024"),
@ -422,7 +414,6 @@ class FreightBillScreen extends StatelessWidget {
_cellText(text: "78646646"),
]),
TableRow(children: [
_cellText(text: "05"),
_cellText(text: "User 5"),
_cellText(text: "9841651635426", clr: AppColors.primaryClr),
_cellText(text: "1 August 2024"),

View File

@ -6,6 +6,7 @@ import '../../../../../../components/styles/app_strings.dart';
class MasterCtrl extends GetxController{
var selectedUser = 0.obs;
RxBool isSelected = false.obs;
var supplierCode = 'Supplier Code'.obs;
var bpGrouping = 'BP Grouping'.obs;
var accountGrp = 'Supplier Account Group'.obs;
@ -24,4 +25,8 @@ class MasterCtrl extends GetxController{
CommonModel(title: AppStrings.plantMaster),
].obs;
void toggleContainer() {
isSelected.value = true;
print("isSelected.value..${isSelected.value}");
}
}

View File

@ -1,6 +1,8 @@
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import '../../../../../components/common/common_btn.dart';
import '../../../../../components/common/custom_drop_down.dart';
import '../../../../../components/common/input_field.dart';
import '../../../../../components/styles/app_colors.dart';
import '../../../../../components/styles/app_images.dart';
import '../../../../../components/styles/app_strings.dart';
@ -79,6 +81,7 @@ class MasterScreen extends StatelessWidget {
),
),
InkWell(
onTap: masterCtrl.toggleContainer,
child: Image.asset(AppImages.filter,
height: 12, width: 12)),
Padding(
@ -107,13 +110,371 @@ class MasterScreen extends StatelessWidget {
],
),
),
Obx(
() => masterCtrl.isSelected.value
? 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: [
_commonText(
"Supplier Code",
),
SizedBox(height: 8),
InputField(
title: "Enter Supplier Code ",
),
// Obx(
// () => Container(
// padding: EdgeInsets.only(left: 8),
// height: 35,
// decoration: BoxDecoration(
// borderRadius:
// BorderRadius.circular(4.0),
// color: AppColors.clrD9,
// border: Border.all(
// color: AppColors.clrGrey)),
// child: DropdownButton<String>(
// icon: Icon(
// Icons
// .keyboard_arrow_down_outlined,
// size: 20,
// color: AppColors.darkGrey),
//
// isExpanded: true,
// underline: SizedBox(),
//
// value: ctrl
// .selectedInvoice.value,
// // Use the selected value
// onChanged: (String? newValue) {
// if (newValue != null) {
// ctrl.selectedInvoice.value =
// newValue; // Update the selected value
// }
// },
// items: ctrl.invoiceNoItems
// .map((String value) {
// return DropdownMenuItem<String>(
// value: value.toString(),
// child: Text(
// value,
// style: TextStyle(
// fontSize: 12,
// color:
// AppColors.darkGrey),
// ),
// );
// }).toList(),
// ),
// ),
// ),
],
)),
SizedBox(width: 16),
Expanded(
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
_commonText(
"Supplier Name",
),
SizedBox(height: 8),
InputField(
title: "Enter Supplier Name",
),
],
)),
SizedBox(width: 16),
Expanded(
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
_commonText(
"Supplier Account Group",
),
SizedBox(height: 8),
InputField(
title: "Supplier Account Group ",
),
// Obx(
// () => Container(
// padding: EdgeInsets.only(left: 8),
// height: 35,
// decoration: BoxDecoration(
// borderRadius:
// BorderRadius.circular(4.0),
// color: AppColors.clrD9,
// border: Border.all(
// color: AppColors.clrGrey)),
// child: DropdownButton<String>(
// icon: Icon(
// Icons
// .keyboard_arrow_down_outlined,
// size: 20,
// color: AppColors.darkGrey),
//
// isExpanded: true,
// underline: SizedBox(),
//
// value: ctrl
// .selectedFreightNo.value,
// // Use the selected value
// onChanged: (String? newValue) {
// if (newValue != null) {
// ctrl
// .selectedFreightNo.value =
// newValue; // Update the selected value
// }
// },
// items: ctrl.freightBillNoItems
// .map((String value) {
// return DropdownMenuItem<String>(
// value: value.toString(),
// child: Text(
// value,
// style: TextStyle(
// fontSize: 12,
// color:
// AppColors.darkGrey),
// ),
// );
// }).toList(),
// ),
// ),
// ),
],
)),
],
),
Padding(
padding:
const EdgeInsets.only(top: 16.0, left: 0, right: 8),
child: Row(
children: [
Expanded(
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
_commonText(
"State",
),
SizedBox(height: 8),
InputField(
title: "Select State ",
),
// Obx(
// () => Container(
// padding: EdgeInsets.only(left: 8),
// height: 35,
// decoration: BoxDecoration(
// borderRadius:
// BorderRadius.circular(4.0),
// color: AppColors.clrD9,
// border: Border.all(
// color: AppColors.clrGrey)),
// child: DropdownButton<String>(
// icon: Icon(
// Icons
// .keyboard_arrow_down_outlined,
// size: 20,
// color: AppColors.darkGrey),
//
// isExpanded: true,
// underline: SizedBox(),
//
// value: ctrl
// .selectedInvoice.value,
// // Use the selected value
// onChanged: (String? newValue) {
// if (newValue != null) {
// ctrl.selectedInvoice.value =
// newValue; // Update the selected value
// }
// },
// items: ctrl.invoiceNoItems
// .map((String value) {
// return DropdownMenuItem<String>(
// value: value.toString(),
// child: Text(
// value,
// style: TextStyle(
// fontSize: 12,
// color:
// AppColors.darkGrey),
// ),
// );
// }).toList(),
// ),
// ),
// ),
],
)),
SizedBox(width: 16,),
Expanded(
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
_commonText(
"BP Group",
),
SizedBox(height: 8),
InputField(
title: "Select BP Group ",
),
// Obx(
// () => Container(
// padding: EdgeInsets.only(left: 8),
// height: 35,
// decoration: BoxDecoration(
// borderRadius:
// BorderRadius.circular(4.0),
// color: AppColors.clrD9,
// border: Border.all(
// color: AppColors.clrGrey)),
// child: DropdownButton<String>(
// icon: Icon(
// Icons
// .keyboard_arrow_down_outlined,
// size: 20,
// color: AppColors.darkGrey),
//
// isExpanded: true,
// underline: SizedBox(),
//
// value: ctrl
// .selectedInvoice.value,
// // Use the selected value
// onChanged: (String? newValue) {
// if (newValue != null) {
// ctrl.selectedInvoice.value =
// newValue; // Update the selected value
// }
// },
// items: ctrl.invoiceNoItems
// .map((String value) {
// return DropdownMenuItem<String>(
// value: value.toString(),
// child: Text(
// value,
// style: TextStyle(
// fontSize: 12,
// color:
// AppColors.darkGrey),
// ),
// );
// }).toList(),
// ),
// ),
// ),
],
)),
SizedBox(width: 16,),
Expanded(
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
_commonText(
"Status",
),
SizedBox(height: 8),
InputField(
title: "Select Status ",
),
// Obx(
// () => Container(
// padding: EdgeInsets.only(left: 8),
// height: 35,
// decoration: BoxDecoration(
// borderRadius:
// BorderRadius.circular(4.0),
// color: AppColors.clrD9,
// border: Border.all(
// color: AppColors.clrGrey)),
// child: DropdownButton<String>(
// icon: Icon(
// Icons
// .keyboard_arrow_down_outlined,
// size: 20,
// color: AppColors.darkGrey),
//
// isExpanded: true,
// underline: SizedBox(),
//
// value: ctrl
// .selectedInvoice.value,
// // Use the selected value
// onChanged: (String? newValue) {
// if (newValue != null) {
// ctrl.selectedInvoice.value =
// newValue; // Update the selected value
// }
// },
// items: ctrl.invoiceNoItems
// .map((String value) {
// return DropdownMenuItem<String>(
// value: value.toString(),
// child: Text(
// value,
// style: TextStyle(
// fontSize: 12,
// color:
// AppColors.darkGrey),
// ),
// );
// }).toList(),
// ),
// ),
// ),
],
)),
],
),
),
Padding(
padding: const EdgeInsets.all(16.0),
child: Row(
mainAxisAlignment: MainAxisAlignment.end,
children: [
CommonBtn(
bkClr: Colors.white,
text: AppStrings.cancel,
clickAction: () {},
),
SizedBox(width: 16),
CommonBtn(
text: AppStrings.submit,
clickAction: () {},
),
],
),
),
],
),
)
: SizedBox(),
),
SizedBox(height: 20,),
Obx(() {
switch (masterCtrl.selectedUser.value) {
case 0:
return _tableView();
default:
default:
return Text("");
}
}),
@ -129,10 +490,11 @@ _tableView(){
TableRow(
decoration: BoxDecoration(color: AppColors.secondaryClr),
children: [
_cellText(text: "SR. No."),
// _cellText(text: "SR. No."),
//CustomTable(text: "SR. NO."),
CustomDropdown<String>(
items: masterCtrl.supplier,
backClr: AppColors.clrD9,
itemLabel: (item) => item,
onSelected: (selected) {
if (selected != null) {
@ -142,6 +504,7 @@ _tableView(){
hintText: 'Supplier Code'),
CustomDropdown<String>(
items: masterCtrl.supplier,
backClr: AppColors.clrD9,
itemLabel: (item) => item,
onSelected: (selected) {
if (selected != null) {
@ -151,6 +514,7 @@ _tableView(){
hintText: 'BP Grouping'),
CustomDropdown<String>(
items: masterCtrl.supplier,
backClr: AppColors.clrD9,
itemLabel: (item) => item,
onSelected: (selected) {
if (selected != null) {
@ -160,6 +524,7 @@ _tableView(){
hintText: 'Supplier Account Group'),
CustomDropdown<String>(
items: masterCtrl.supplier,
backClr: AppColors.clrD9,
itemLabel: (item) => item,
onSelected: (selected) {
if (selected != null) {
@ -170,7 +535,6 @@ _tableView(){
_cellText(text: "Legal Entity"),
]),
TableRow(children: [
_cellText(text: "01"),
_cellText(text: "11059440"),
_cellText(text: "ZIPT"),
_cellText(text: "ZIPT"),
@ -178,7 +542,6 @@ _tableView(){
_cellText(text: "0"),
]),
TableRow(children: [
_cellText(text: "02"),
_cellText(text: "11059440"),
_cellText(text: "ZIPT"),
_cellText(text: "ZIPT"),
@ -187,7 +550,6 @@ _tableView(){
]),
TableRow(children: [
_cellText(text: "03"),
_cellText(text: "11059440"),
_cellText(text: "ZIPT"),
_cellText(text: "ZIPT"),
@ -195,7 +557,6 @@ _tableView(){
_cellText(text: "0"),
]),
TableRow(children: [
_cellText(text: "04"),
_cellText(text: "11059440"),
_cellText(text: "ZIPT"),
_cellText(text: "ZIPT"),
@ -219,4 +580,11 @@ _tableView(){
),
);
}
_commonText(String title) {
return Text(
title,
style: TextStyle(
fontSize: 13, color: Colors.black, fontWeight: FontWeight.w900),
);
}
}

View File

@ -2,13 +2,13 @@ import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:shayog/components/common/common_button.dart';
import 'package:shayog/feature/presentation/widgets/text_view.dart';
import '../../../../../components/common/common_btn.dart';
import '../../../../../components/common/custom_drop_down.dart';
import '../../../../../components/common/input_field.dart';
import '../../../../../components/styles/app_colors.dart';
import '../../../../../components/styles/app_strings.dart';
import '../../../../../utils/validations.dart';
import '../../dashboard/controller/dashboard_ctrl.dart';
import '../../../../../../components/common/common_btn.dart';
import '../../../../../../components/common/custom_drop_down.dart';
import '../../../../../../components/common/input_field.dart';
import '../../../../../../components/styles/app_colors.dart';
import '../../../../../../components/styles/app_strings.dart';
import '../../../../../../utils/validations.dart';
import '../../../dashboard/controller/dashboard_ctrl.dart';
class AddInternalUser extends StatelessWidget {
AddInternalUser({super.key});
@ -34,8 +34,7 @@ class AddInternalUser extends StatelessWidget {
crossAxisAlignment: CrossAxisAlignment.start,
children: [
TextView(
text: AppStrings.firstName,
text: AppStrings.firstName,
),
SizedBox(height: 8),
InputField(
@ -51,8 +50,8 @@ class AddInternalUser extends StatelessWidget {
crossAxisAlignment: CrossAxisAlignment.start,
children: [
TextView(
text: AppStrings.lastName,
),
text: AppStrings.lastName,
),
SizedBox(height: 8),
InputField(
validator: Validations.checkLastName,
@ -68,8 +67,8 @@ class AddInternalUser extends StatelessWidget {
crossAxisAlignment: CrossAxisAlignment.start,
children: [
TextView(
text: AppStrings.employeeCode,
),
text: AppStrings.employeeCode,
),
SizedBox(height: 8),
InputField(
controller: ctrl.employeeCodeCtrl,
@ -89,11 +88,11 @@ class AddInternalUser extends StatelessWidget {
crossAxisAlignment: CrossAxisAlignment.start,
children: [
TextView(
text: AppStrings.userType,
),
text: AppStrings.userType,
),
SizedBox(height: 8),
CustomDropdown(
initialValue: ctrl.selectUserVal.value,
initialValue: ctrl.userTypeList[1],
backClr: AppColors.clrD9,
borderClr: AppColors.clrGrey,
items: ctrl.userTypeList,
@ -125,11 +124,11 @@ class AddInternalUser extends StatelessWidget {
crossAxisAlignment: CrossAxisAlignment.start,
children: [
TextView(
text: AppStrings.status,
),
text: AppStrings.status,
),
SizedBox(height: 8),
CustomDropdown(
initialValue: ctrl.selectedStatus.value,
initialValue: ctrl.status[0],
backClr: AppColors.clrD9,
borderClr: AppColors.clrGrey,
items: ctrl.status,
@ -149,8 +148,8 @@ class AddInternalUser extends StatelessWidget {
crossAxisAlignment: CrossAxisAlignment.start,
children: [
TextView(
text: AppStrings.emailAddress,
),
text: AppStrings.emailAddress,
),
SizedBox(height: 8),
InputField(
controller: ctrl.emailCtrl,
@ -164,8 +163,8 @@ class AddInternalUser extends StatelessWidget {
Padding(
padding: const EdgeInsets.only(top: 16.0, bottom: 8),
child: TextView(
text: AppStrings.mobileNo,
),
text: AppStrings.mobileNo,
),
),
Row(
children: [
@ -197,12 +196,12 @@ class AddInternalUser extends StatelessWidget {
height: 30,
width: 100,
borderRadius: 4,
isLoading: ctrl.employeeCodeCtrl.text.isEmpty ? ctrl.isLoading : ctrl.editLoading,
isLoading: ctrl.employeeCodeCtrl.text.isEmpty
? ctrl.isLoading
: ctrl.editLoading,
text: ctrl.employeeCodeCtrl.text.isEmpty
? AppStrings.add
: AppStrings.edit,
clickAction: () {
ctrl.employeeCodeCtrl.text.isEmpty
? ctrl.createUser()

View File

@ -1,11 +1,11 @@
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:intl/intl.dart';
import 'package:shayog/components/common/common_button.dart';
import 'package:shayog/components/styles/textStyles.dart';
import '../../../../../components/common/common_btn.dart';
import '../../../../../components/common/data_cell.dart';
import '../../../../../components/styles/app_colors.dart';
import '../../../widgets/custom_pagination.dart';
import '../../dashboard/controller/dashboard_ctrl.dart';
class ManageUser extends StatelessWidget {
@ -16,8 +16,8 @@ class ManageUser extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.end,
crossAxisAlignment: CrossAxisAlignment.end,
children: [
Obx(() {
if (controller.userLoading.value) {
@ -25,6 +25,8 @@ class ManageUser extends StatelessWidget {
}
return Column(
mainAxisAlignment: MainAxisAlignment.end,
crossAxisAlignment: CrossAxisAlignment.end,
children: [
Scrollbar(
thumbVisibility: true,
@ -61,7 +63,7 @@ class ManageUser extends StatelessWidget {
top: BorderSide(color: AppColors.clrGrey),
),
columns: [
dataColumn("Sr.No."),
// dataColumn("Sr.No."),
dataColumn("User Name"),
dataColumn("Email ID"),
dataColumn("Employee/\nTransporter Code"),
@ -84,15 +86,15 @@ class ManageUser extends StatelessWidget {
// controller.toggleSelection(index, value ?? false);
// },
cells: [
editableCell(index, ""
"${index + 1}"),
editableCell(index, stoppage.userName ?? ""),
editableCell(index, stoppage.userEmail ?? ""),
// editableCell(index, ""
// "${index + 1}"),
editableCell(index, stoppage.userName ?? "-"),
editableCell(index, stoppage.userEmail ?? "-"),
editableCell(
index, stoppage.userEmpTransCode ?? ""),
editableCell(index, stoppage.userMobile ?? ""),
index, stoppage.userEmpTransCode ?? "-"),
editableCell(index, stoppage.userMobile ?? "-"),
editableCell(
index, stoppage.usertypeName ?? ""),
index, stoppage.usertypeName ?? "-"),
editableCell(
index, stoppage.createdBy.toString()),
editableCell(
@ -107,7 +109,9 @@ class ManageUser extends StatelessWidget {
DateFormat("d MMMM yyyy").format(
DateTime.parse(
'${stoppage.lastUpdatedOn}'))),
editableCell(index, stoppage.status.toString()),
editableCell(index, stoppage.status == "A" ? "Active":"In-Active"),
DataCell(CommonBtn(
style: 8.txtSBoldWhite,
margin: EdgeInsets.symmetric(vertical: 6),
@ -145,26 +149,21 @@ class ManageUser extends StatelessWidget {
),
),
SizedBox(height: 16),
Row(
mainAxisAlignment: MainAxisAlignment.end,
children: [
CommonButton(
height: 30,
width: 100,
text: "Previous",
clickAction: controller.previousPage),
Text(
'Page ${controller.currentPage.value} of ${controller.totalPages.value}'),
CommonButton(
height: 30,
width: 100,
text: "Next",
clickAction: controller.nextPage),
],
),
],
);
}),
CustomPagination(
currentPage: controller.currentPage.value,
totalPages: controller.totalPages.value,
onPageChanged: (int page) {
controller.onPageChanged(page);
},
),
],
);
}

View File

@ -9,7 +9,7 @@ String editUserResModelToJson(EditUserResModel data) =>
class EditUserResModel {
final int? status;
final String? message;
final Data? data;
final EditUser? data;
final DateTime? timestamp;
EditUserResModel({
@ -23,7 +23,7 @@ class EditUserResModel {
EditUserResModel(
status: json["status"],
message: json["message"],
data: json["data"] == null ? null : Data.fromJson(json["data"]),
data: json["data"] == null ? null : EditUser.fromJson(json["data"]),
timestamp: json["timestamp"] == null
? null
: DateTime.parse(json["timestamp"]),
@ -37,20 +37,20 @@ class EditUserResModel {
};
}
class Data {
class EditUser {
final String? action;
final String? employeeTransCode;
final int? userId;
final String? email;
Data({
EditUser({
this.action,
this.employeeTransCode,
this.userId,
this.email,
});
factory Data.fromJson(Map<String, dynamic> json) => Data(
factory EditUser.fromJson(Map<String, dynamic> json) => EditUser(
action: json["action"],
employeeTransCode: json["employeeTransCode"],
userId: json["userId"],

View File

@ -9,84 +9,56 @@ GetAllUserResModel getAllUserResModelFromJson(String str) => GetAllUserResModel.
String getAllUserResModelToJson(GetAllUserResModel data) => json.encode(data.toJson());
class GetAllUserResModel {
final int? status;
final String? message;
final UserData? data;
final DateTime? timestamp;
GetAllUserResModel({
this.status,
this.message,
this.data,
this.timestamp,
});
factory GetAllUserResModel.fromJson(Map<String, dynamic> json) => GetAllUserResModel(
status: json["status"],
message: json["message"],
data: json["data"] == null ? null : UserData.fromJson(json["data"]),
timestamp: json["timestamp"] == null ? null : DateTime.parse(json["timestamp"]),
);
Map<String, dynamic> toJson() => {
"status": status,
"message": message,
"data": data?.toJson(),
"timestamp": timestamp?.toIso8601String(),
};
}
class UserData {
final List<AllUser>? content;
final List<List<AllUser>>? content;
final Pageable? pageable;
final bool? last;
final int? totalElements;
final int? totalPages;
final bool? first;
final int? size;
final int? number;
final Sort? sort;
final bool? first;
final int? numberOfElements;
final bool? empty;
UserData({
GetAllUserResModel({
this.content,
this.pageable,
this.last,
this.totalElements,
this.totalPages,
this.first,
this.size,
this.number,
this.sort,
this.first,
this.numberOfElements,
this.empty,
});
factory UserData.fromJson(Map<String, dynamic> json) => UserData(
content: json["content"] == null ? [] : List<AllUser>.from(json["content"]!.map((x) => AllUser.fromJson(x))),
factory GetAllUserResModel.fromJson(Map<String, dynamic> json) => GetAllUserResModel(
content: json["content"] == null ? [] : List<List<AllUser>>.from(json["content"]!.map((x) => List<AllUser>.from(x.map((x) => AllUser.fromJson(x))))),
pageable: json["pageable"] == null ? null : Pageable.fromJson(json["pageable"]),
last: json["last"],
totalElements: json["totalElements"],
totalPages: json["totalPages"],
first: json["first"],
size: json["size"],
number: json["number"],
sort: json["sort"] == null ? null : Sort.fromJson(json["sort"]),
first: json["first"],
numberOfElements: json["numberOfElements"],
empty: json["empty"],
);
Map<String, dynamic> toJson() => {
"content": content == null ? [] : List<dynamic>.from(content!.map((x) => x.toJson())),
"content": content == null ? [] : List<dynamic>.from(content!.map((x) => List<dynamic>.from(x.map((x) => x.toJson())))),
"pageable": pageable?.toJson(),
"last": last,
"totalElements": totalElements,
"totalPages": totalPages,
"first": first,
"size": size,
"number": number,
"sort": sort?.toJson(),
"first": first,
"numberOfElements": numberOfElements,
"empty": empty,
};
@ -98,17 +70,18 @@ class AllUser {
final String? usertypeName;
final String? userName;
final String? userFname;
final String? userLname;
final dynamic userMname;
final dynamic userLname;
final String? userEmail;
final String? userMobile;
final String? userEmpTransCode;
final String? userAddedChannel;
final String? status;
final DateTime? createdOn;
final int? createdBy;
final String? createdBy;
final DateTime? lastUpdatedOn;
final int? lastUpdatedBy;
final bool isSelected;
final String? lastUpdatedBy;
bool isSelected;
AllUser({
this.userId,
@ -116,6 +89,7 @@ class AllUser {
this.usertypeName,
this.userName,
this.userFname,
this.userMname,
this.userLname,
this.userEmail,
this.userMobile,
@ -126,7 +100,7 @@ class AllUser {
this.createdBy,
this.lastUpdatedOn,
this.lastUpdatedBy,
this.isSelected = false
this.isSelected = false,
});
factory AllUser.fromJson(Map<String, dynamic> json) => AllUser(
@ -135,6 +109,7 @@ class AllUser {
usertypeName: json["usertype_name"],
userName: json["user_name"],
userFname: json["user_fname"],
userMname: json["user_mname"],
userLname: json["user_lname"],
userEmail: json["user_email"],
userMobile: json["user_mobile"],
@ -153,6 +128,7 @@ class AllUser {
"usertype_name": usertypeName,
"user_name": userName,
"user_fname": userFname,
"user_mname": userMname,
"user_lname": userLname,
"user_email": userEmail,
"user_mobile": userMobile,

View File

@ -10,7 +10,7 @@ import '../../../../../components/styles/app_colors.dart';
import '../../../../../components/styles/app_images.dart';
import '../../../../../components/styles/app_strings.dart';
import '../../dashboard/controller/dashboard_ctrl.dart';
import 'add_internal_user.dart';
import 'internal_user/add_internal_user.dart';
import 'user_type.dart';
import 'internal_user_role_mapping.dart';
import 'manage_user.dart';
@ -49,7 +49,7 @@ class UserScreen extends StatelessWidget {
ctrl.getManageUser();
}
if (ctrl.selectedUser.value == 2) {
ctrl.clearPrefillData();
// ctrl.clearPrefillData();
ctrl.showRolesSection.value = false;
}
if (ctrl.selectedUser.value != 3) {
@ -71,12 +71,13 @@ class UserScreen extends StatelessWidget {
: AppColors.primaryClr,
width: 3))),
child: Center(
child: Text(
ctrl.userTabs[index].title ?? "",
style: TextStyle(
fontSize: 12,
fontWeight: FontWeight.w900,
color: Colors.white),
child: TextView(
text: ctrl.userTabs[index].title ?? "",
style: 12.txtBoldWhite,
// style: TextStyle(
// fontSize: 12,
// fontWeight: FontWeight.w900,
// color: Colors.white),
),
),
),
@ -93,21 +94,18 @@ class UserScreen extends StatelessWidget {
height: 12, width: 12)),
Padding(
padding: const EdgeInsets.all(8.0),
child: Text(
AppStrings.refresh,
style: TextStyle(
color: AppColors.white,
fontSize: 12,
fontWeight: FontWeight.bold),
child: TextView(
text: AppStrings.refresh,
style: 12.txtBoldWhite,
),
),
Obx(
() => Visibility(
visible: ctrl.selectedUser.value == 0,
child: InkWell(
onTap:(){
ctrl.toggleContainer();
},
onTap: () {
ctrl.toggleContainer();
},
child: Image.asset(AppImages.filter,
height: 16, width: 16)),
),
@ -117,12 +115,9 @@ class UserScreen extends StatelessWidget {
visible: ctrl.selectedUser.value == 0,
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Text(
AppStrings.filter,
style: TextStyle(
color: AppColors.white,
fontSize: 12,
fontWeight: FontWeight.bold),
child: TextView(
text: AppStrings.filter,
style: 12.txtBoldWhite,
),
),
),
@ -153,11 +148,8 @@ class UserScreen extends StatelessWidget {
),
SizedBox(height: 8),
InputField(
title: "Enter User Name",
controller: ctrl.userTypeCtrl
),
title: "Enter User Name",
controller: ctrl.nameCtrl),
// CustomDropdown(
// backClr: AppColors.clrD9,
@ -186,9 +178,7 @@ class UserScreen extends StatelessWidget {
SizedBox(height: 8),
InputField(
title: "Enter User Type",
controller: ctrl.userTypeCtrl
),
controller: ctrl.userTypeCtrl),
// CustomDropdown(
// backClr: AppColors.clrD9,
// borderClr: AppColors.clrGrey,
@ -216,8 +206,7 @@ class UserScreen extends StatelessWidget {
SizedBox(height: 8),
InputField(
title: "Enter Email Address",
controller: ctrl.emailCtrl
),
controller: ctrl.emailCtrl),
// CustomDropdown(
// backClr: AppColors.clrD9,
// borderClr: AppColors.clrGrey,
@ -235,8 +224,7 @@ class UserScreen extends StatelessWidget {
],
),
Padding(
padding: const EdgeInsets.only(
top: 16.0),
padding: const EdgeInsets.only(top: 16.0),
child: Row(
children: [
Expanded(
@ -252,8 +240,7 @@ class UserScreen extends StatelessWidget {
SizedBox(height: 8),
InputField(
title: "Enter Employee Code",
controller: ctrl.employeeCodeCtrl
),
controller: ctrl.employeeCodeCtrl),
// CustomDropdown(
// backClr: AppColors.clrD9,
// borderClr: AppColors.clrGrey,
@ -277,14 +264,12 @@ class UserScreen extends StatelessWidget {
CrossAxisAlignment.start,
children: [
TextView(
text:
"Status",
text: "Status",
),
SizedBox(height: 8),
InputField(
title: "Enter Status",
controller: ctrl.statusCtrl
),
controller: ctrl.statusCtrl),
// CustomDropdown(
// backClr: AppColors.clrD9,
// borderClr: AppColors.clrGrey,
@ -321,7 +306,8 @@ class UserScreen extends StatelessWidget {
SizedBox(width: 16),
CommonButton(
borderRadius: 4,
width: 100,height:30,
width: 100,
height: 30,
text: AppStrings.submit,
textStyle: 14.txtSBoldWhite,
clickAction: () {

View File

@ -158,11 +158,12 @@ class UserType extends StatelessWidget {
top: BorderSide(color: AppColors.clrGrey),
),
columns: [
dataColumn("SR.No."),
// dataColumn("SR.No."),
dataColumn("User Type"),
dataColumn("Status"),
dataColumn("Action"),
],
rows: List<DataRow>.generate(
controller.userType.length, (index) {
final stoppage = controller.userType[index];
@ -170,7 +171,7 @@ class UserType extends StatelessWidget {
return DataRow(
cells: [
editableCell(index, "0$index"),
// editableCell(index, "0$index"),
editableCell(
index, stoppage.usertypeName ?? ""),
editableCell(

View File

@ -14,7 +14,6 @@ import '../../admin/user_management/model/getAllUserResModel.dart';
import '../../admin/user_management/model/plant_mapping_res_model.dart';
import '../../admin/user_management/model/user_type_details_res_model.dart';
import '../../admin/user_management/model/user_type_res_model.dart';
import '../../transporter/widgets/freightbill_dialog.dart';
class DashboardCtrl extends GetxController {
@ -33,7 +32,7 @@ class DashboardCtrl extends GetxController {
var selectedIndex = 0.obs;
var selectUserType = 0.obs;
var selectedUser = 0.obs;
var selectedValue = ''.obs;
var errorText = ''.obs;
RxBool showRolesSection = false.obs;
@ -90,10 +89,10 @@ class DashboardCtrl extends GetxController {
//**************************Manage-User************************************
var currentPage = 1.obs;
var totalPages = 3.obs;
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 = 10;
var getAllUser = <AllUser>[].obs;
var userLoading = false.obs;
getManageUser() async {
@ -110,7 +109,11 @@ class DashboardCtrl extends GetxController {
var response = await PostRequests.getAllUser(requestBody,currentPage.value,limit);
if (response != null) {
getAllUser.assignAll(response.data?.content ?? []);
List<AllUser> flattenedContent =
response.content!.expand((list) => list).toList();
getAllUser.assignAll(flattenedContent);
totalPages.value = response.totalPages!;
print("getAllUser>>>>>${getAllUser.length}");
}
} finally {
userLoading.value = false;
@ -122,15 +125,21 @@ class DashboardCtrl extends GetxController {
getManageUser(); // Fetch data for the next page
}
}
void previousPage() {
if (currentPage.value > 1) {
currentPage.value--;
getManageUser(); // Fetch data for the previous page
}
}
void onPageChanged(int page) {
currentPage.value = page;
getManageUser(); // Fetch data for the selected page
}
//********************************edit User****************************//
var editLoading = false.obs;
Rx<Data> editUserResModel = Data().obs;
Rx<EditUser> editUserResModel = EditUser().obs;
editAllUser(String id) async {
try {
@ -162,8 +171,9 @@ class DashboardCtrl extends GetxController {
//**************************Add Internal-User******************************
var isLoading = false.obs;
var status = ['A', 'I'];
var status = ['Active', 'In-Active'];
var selectedStatus = 'Select Status'.obs;
var selectedValue = 'Select User Type'.obs;
void createUser() {
if (selectedValue.value.isEmpty ||
selectedStatus.value.isEmpty ||
@ -179,7 +189,6 @@ class DashboardCtrl extends GetxController {
Get.back();
});
} else {
print("???????????????");
addInternalUser();
}
}
@ -197,7 +206,7 @@ class DashboardCtrl extends GetxController {
"mobile": mobileCtrl.text,
"employeeTransCode": employeeCodeCtrl.text,
"email": emailCtrl.text,
"status": selectedStatus.value,
"status": selectedStatus.value == "Active" ? "A":"I",
"addedChannel": "F"
}
];

View File

@ -3,8 +3,8 @@ import 'package:get/get.dart';
import 'package:shayog/components/styles/app_strings.dart';
import 'package:shayog/components/styles/textStyles.dart';
import 'package:shayog/feature/presentation/screens/transporter/view/transport_view.dart';
import '../../../../components/styles/app_colors.dart';
import '../../widgets/text_view.dart';
import '../admin/configuration_management/configuration_screen.dart';
import '../admin/freight_bills/freightbill_screen.dart';
import '../admin/masters/master_screen.dart';
@ -25,6 +25,7 @@ class _DashboardScreenState extends State<DashboardScreen> {
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
automaticallyImplyLeading: false,
backgroundColor: AppColors.secondaryClr,
title: RichText(
textAlign: TextAlign.center,
@ -61,32 +62,46 @@ class _DashboardScreenState extends State<DashboardScreen> {
style: 12.txtBoldBlack,
),
),
PopupMenuButton(
PopupMenuButton<int>(
color: Colors.white,
onSelected: (val) {},
onSelected: (val) {
// Handle selection
},
child: Icon(
Icons.keyboard_arrow_down_outlined,
color: Colors.black,
size: 20,
),
itemBuilder: (context) {
return List.generate(
2,
(index) {
return PopupMenuItem(
onTap: () {
ctrl.selectUserType.value = index;
},
child: Text(
index == 0
? AppStrings.adminUser
: AppStrings.transportVendor,
style: 12.txtSBoldGrey),
);
},
);
return [
PopupMenuItem<int>(
value: 0,
height: 30,
onTap: () {
ctrl.selectUserType.value = 0;
},
child: TextView(
text: AppStrings.adminUser,
style: 12.txtSBoldGrey,
),
),
const PopupMenuDivider(), // Divider between items
PopupMenuItem<int>(
value: 1,
height: 35,
onTap: () {
ctrl.selectUserType.value = 1;
},
child: TextView(
text: AppStrings.transportVendor,
style: 12.txtSBoldGrey,
),
),
];
},
),
SizedBox(width: 8),
],
),

View File

@ -56,7 +56,7 @@ class _LoginScreenState extends State<LoginScreen> {
color: AppColors.primaryClr,
fontWeight: FontWeight.w900),
)),
Container(
SizedBox(
height: 100,
width: 150,
child: Image.asset("assets/images/back2.png")),

View File

@ -9,10 +9,10 @@ FreightBillsResModel freightBillsResModelFromJson(String str) => FreightBillsRes
String freightBillsResModelToJson(FreightBillsResModel data) => json.encode(data.toJson());
class FreightBillsResModel {
final List<String>? plant;
final List<String>? prodect;
final List<Plant>? plant;
final List<Prodect>? prodect;
final List<String>? fromLocation;
final List<dynamic>? freightBill;
final List<String>? freightBill;
FreightBillsResModel({
this.plant,
@ -22,16 +22,58 @@ class FreightBillsResModel {
});
factory FreightBillsResModel.fromJson(Map<String, dynamic> json) => FreightBillsResModel(
plant: json["Plant"] == null ? [] : List<String>.from(json["Plant"]!.map((x) => x)),
prodect: json["prodect"] == null ? [] : List<String>.from(json["prodect"]!.map((x) => x)),
plant: json["Plant"] == null ? [] : List<Plant>.from(json["Plant"]!.map((x) => Plant.fromJson(x))),
prodect: json["prodect"] == null ? [] : List<Prodect>.from(json["prodect"]!.map((x) => Prodect.fromJson(x))),
fromLocation: json["fromLocation"] == null ? [] : List<String>.from(json["fromLocation"]!.map((x) => x)),
freightBill: json["FreightBill"] == null ? [] : List<dynamic>.from(json["FreightBill"]!.map((x) => x)),
freightBill: json["FreightBill"] == null ? [] : List<String>.from(json["FreightBill"]!.map((x) => x)),
);
Map<String, dynamic> toJson() => {
"Plant": plant == null ? [] : List<dynamic>.from(plant!.map((x) => x)),
"prodect": prodect == null ? [] : List<dynamic>.from(prodect!.map((x) => x)),
"Plant": plant == null ? [] : List<dynamic>.from(plant!.map((x) => x.toJson())),
"prodect": prodect == null ? [] : List<dynamic>.from(prodect!.map((x) => x.toJson())),
"fromLocation": fromLocation == null ? [] : List<dynamic>.from(fromLocation!.map((x) => x)),
"FreightBill": freightBill == null ? [] : List<dynamic>.from(freightBill!.map((x) => x)),
};
}
class Plant {
final String? plantCode;
final String? plantDesc;
bool isSelected;
Plant({
this.plantCode,
this.plantDesc,
this.isSelected = false,
});
factory Plant.fromJson(Map<String, dynamic> json) => Plant(
plantCode: json["plant_code"],
plantDesc: json["plant_desc"],
);
Map<String, dynamic> toJson() => {
"plant_code": plantCode,
"plant_desc": plantDesc,
};
}
class Prodect {
final String? materialCode;
final String? materialDescription;
Prodect({
this.materialCode,
this.materialDescription,
});
factory Prodect.fromJson(Map<String, dynamic> json) => Prodect(
materialCode: json["material_code"],
materialDescription: json["material_description"],
);
Map<String, dynamic> toJson() => {
"material_code": materialCode,
"material_description": materialDescription,
};
}

View File

@ -0,0 +1,211 @@
// To parse this JSON data, do
//
// final grnPendingBillsResModel = grnPendingBillsResModelFromJson(jsonString);
import 'dart:convert';
GrnPendingBillsResModel grnPendingBillsResModelFromJson(String str) => GrnPendingBillsResModel.fromJson(json.decode(str));
String grnPendingBillsResModelToJson(GrnPendingBillsResModel data) => json.encode(data.toJson());
class GrnPendingBillsResModel {
final List<List<GrnPending>>? content;
final Pageable? pageable;
final bool? last;
final int? totalPages;
final int? totalElements;
final bool? first;
final int? size;
final int? number;
final Sort? sort;
final int? numberOfElements;
final bool? empty;
GrnPendingBillsResModel({
this.content,
this.pageable,
this.last,
this.totalPages,
this.totalElements,
this.first,
this.size,
this.number,
this.sort,
this.numberOfElements,
this.empty,
});
factory GrnPendingBillsResModel.fromJson(Map<String, dynamic> json) => GrnPendingBillsResModel(
content: json["content"] == null ? [] : List<List<GrnPending>>.from(json["content"]!.map((x) => List<GrnPending>.from(x.map((x) => GrnPending.fromJson(x))))),
pageable: json["pageable"] == null ? null : Pageable.fromJson(json["pageable"]),
last: json["last"],
totalPages: json["totalPages"],
totalElements: json["totalElements"],
first: json["first"],
size: json["size"],
number: json["number"],
sort: json["sort"] == null ? null : Sort.fromJson(json["sort"]),
numberOfElements: json["numberOfElements"],
empty: json["empty"],
);
Map<String, dynamic> toJson() => {
"content": content == null ? [] : List<dynamic>.from(content!.map((x) => List<dynamic>.from(x.map((x) => x.toJson())))),
"pageable": pageable?.toJson(),
"last": last,
"totalPages": totalPages,
"totalElements": totalElements,
"first": first,
"size": size,
"number": number,
"sort": sort?.toJson(),
"numberOfElements": numberOfElements,
"empty": empty,
};
}
class GrnPending {
final int? grnId;
final String? grnNo;
final String? plantCode;
final String? materialCode;
final String? codeValue;
final String? transporterCode;
final DateTime? grnDate;
final String? fromLocation;
final String? vehicleNo;
final String? lrNo;
final DateTime? lrDate;
final double? dispQty;
final double? netQty;
final double? billingQty;
final int? freightRate;
final double? shipmentCost;
final int? statusId;
final String? remark;
bool isSelected;
GrnPending({
this.grnId,
this.grnNo,
this.plantCode,
this.materialCode,
this.codeValue,
this.transporterCode,
this.grnDate,
this.fromLocation,
this.vehicleNo,
this.lrNo,
this.lrDate,
this.dispQty,
this.netQty,
this.billingQty,
this.freightRate,
this.shipmentCost,
this.statusId,
this.remark,
this.isSelected = false,
});
factory GrnPending.fromJson(Map<String, dynamic> json) => GrnPending(
grnId: json["grn_id"],
grnNo: json["grn_no"],
plantCode: json["plant_code"],
materialCode: json["material_code"],
codeValue: json["code_value"],
transporterCode: json["transporter_code"],
grnDate: json["grn_date"] == null ? null : DateTime.parse(json["grn_date"]),
fromLocation: json["from_location"],
vehicleNo: json["vehicle_no"],
lrNo: json["lr_no"],
lrDate: json["lr_date"] == null ? null : DateTime.parse(json["lr_date"]),
dispQty: json["disp_qty"]?.toDouble(),
netQty: json["net_qty"]?.toDouble(),
billingQty: json["billing_qty"]?.toDouble(),
freightRate: json["freight_rate"],
shipmentCost: json["shipment_cost"]?.toDouble(),
statusId: json["status_id"],
remark: json["remark"],
);
Map<String, dynamic> toJson() => {
"grn_id": grnId,
"grn_no": grnNo,
"plant_code": plantCode,
"material_code": materialCode,
"code_value": codeValue,
"transporter_code": transporterCode,
"grn_date": "${grnDate!.year.toString().padLeft(4, '0')}-${grnDate!.month.toString().padLeft(2, '0')}-${grnDate!.day.toString().padLeft(2, '0')}",
"from_location": fromLocation,
"vehicle_no": vehicleNo,
"lr_no": lrNo,
"lr_date": "${lrDate!.year.toString().padLeft(4, '0')}-${lrDate!.month.toString().padLeft(2, '0')}-${lrDate!.day.toString().padLeft(2, '0')}",
"disp_qty": dispQty,
"net_qty": netQty,
"billing_qty": billingQty,
"freight_rate": freightRate,
"shipment_cost": shipmentCost,
"status_id": statusId,
"remark": remark,
};
}
class Pageable {
final Sort? sort;
final int? offset;
final int? pageSize;
final int? pageNumber;
final bool? unpaged;
final bool? paged;
Pageable({
this.sort,
this.offset,
this.pageSize,
this.pageNumber,
this.unpaged,
this.paged,
});
factory Pageable.fromJson(Map<String, dynamic> json) => Pageable(
sort: json["sort"] == null ? null : Sort.fromJson(json["sort"]),
offset: json["offset"],
pageSize: json["pageSize"],
pageNumber: json["pageNumber"],
unpaged: json["unpaged"],
paged: json["paged"],
);
Map<String, dynamic> toJson() => {
"sort": sort?.toJson(),
"offset": offset,
"pageSize": pageSize,
"pageNumber": pageNumber,
"unpaged": unpaged,
"paged": paged,
};
}
class Sort {
final bool? empty;
final bool? sorted;
final bool? unsorted;
Sort({
this.empty,
this.sorted,
this.unsorted,
});
factory Sort.fromJson(Map<String, dynamic> json) => Sort(
empty: json["empty"],
sorted: json["sorted"],
unsorted: json["unsorted"],
);
Map<String, dynamic> toJson() => {
"empty": empty,
"sorted": sorted,
"unsorted": unsorted,
};
}

View File

@ -1,6 +1,7 @@
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:intl/intl.dart';
import 'package:shayog/components/common/common_button.dart';
import 'package:shayog/components/styles/app_colors.dart';
import 'package:shayog/components/styles/textStyles.dart';
import 'package:shayog/feature/presentation/widgets/text_view.dart';
@ -10,15 +11,68 @@ import '../../../../../../../components/common/common_btn.dart';
import '../../../../../../../components/common/custom_drop_down.dart';
import '../../../../../../../components/common/data_cell.dart';
import '../../../../../../../components/styles/app_strings.dart';
import '../../view_model/transport_controller.dart';
import '../../widgets/common_card.dart';
import '../../widgets/freightbill_dialog.dart';
import 'package:syncfusion_flutter_datepicker/datepicker.dart';
class GenerateFrightBill extends StatelessWidget {
class GenerateFrightBill extends StatefulWidget {
GenerateFrightBill({super.key});
@override
State<GenerateFrightBill> createState() => _GenerateFrightBillState();
}
class _GenerateFrightBillState extends State<GenerateFrightBill> {
final controller = Get.put(TransportController());
String _selectedDateRange = '';
void _onSelectionChanged(DateRangePickerSelectionChangedArgs args) {
final startDate = args.value.startDate;
final endDate = args.value.endDate;
// If a valid range is selected
if (startDate != null && endDate != null) {
setState(() {
_selectedDateRange =
'Selected Range: ${startDate.toLocal()} - ${endDate.toLocal()}';
});
// Update the TextFormField with the formatted date range
String formattedStartDate =
DateFormat('dd/MM/yyyy').format(startDate);
String formattedEndDate =
DateFormat('dd-MM/yyyy').format(endDate);
controller.fromController.text = '$formattedStartDate - $formattedEndDate';
}
}
// Show the date range picker dialog
void _showDateRangePicker() async {
showDialog(
context: context,
builder: (BuildContext context) {
return Dialog(
child: Container(
height: 350,
width: 650,
margin: EdgeInsets.all(16),
child: SfDateRangePicker(
selectionMode: DateRangePickerSelectionMode.range,
enableMultiView: true, // Enable multi-view calendar
onSelectionChanged: _onSelectionChanged,
headerStyle: DateRangePickerHeaderStyle(
textAlign: TextAlign.center,
),
),
),
);
},
);
}
@override
Widget build(BuildContext context) {
@ -38,16 +92,17 @@ class GenerateFrightBill extends StatelessWidget {
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
_commonText("Plant"),
TextView(text:
"Plant"),
SizedBox(height: 8),
CustomDropdown<dynamic>(
CustomDropdown(
backClr: AppColors.clrD9,
borderClr: AppColors.clrGrey,
items: controller.plant,
itemLabel: (item) => item,
itemLabel: (item) => "${item.plantCode}-${item.plantDesc}",
onSelected: (selected) {
if (selected != null) {
controller.selectPlant.value = selected;
controller.selectPlant.value = selected.plantCode ?? "";
print(
"selectPlant${controller.selectPlant.value}");
}
@ -63,13 +118,14 @@ class GenerateFrightBill extends StatelessWidget {
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
_commonText("Product Name"),
TextView(text:"Product Name"),
SizedBox(height: 8),
CustomDropdown<dynamic>(
width: 250,
backClr: AppColors.clrD9,
borderClr: AppColors.clrGrey,
items: controller.product,
itemLabel: (item) => item,
itemLabel: (item) => "${item.materialCode}-${item.materialDescription}",
onSelected: (selected) {
if (selected != null) {
controller.selectProduct.value = selected;
@ -88,7 +144,7 @@ class GenerateFrightBill extends StatelessWidget {
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
_commonText("Transaction Type"),
TextView(text:"Transaction Type"),
SizedBox(height: 8),
CustomDropdown<String>(
backClr: AppColors.clrD9,
@ -118,7 +174,7 @@ class GenerateFrightBill extends StatelessWidget {
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
_commonText("MRN Date Range"),
TextView(text:"MRN Date Range"),
// SizedBox(height: 8),
// CustomDropdown<String>(
// borderClr: AppColors.clrGrey,
@ -137,26 +193,34 @@ class GenerateFrightBill extends StatelessWidget {
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(),
);
if (pickedDate != null) {
controller.fromSelectedDate = pickedDate;
String formattedDate =
controller.getFormattedDate(pickedDate);
controller.fromController.text =
formattedDate;
controller.dateCheck.value = true;
}
readOnly: true, // Set as readonly so user can't type
onTap: () {
_showDateRangePicker();
},
// 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,
@ -206,7 +270,7 @@ class GenerateFrightBill extends StatelessWidget {
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
_commonText("From Location"),
TextView(text:"From Location"),
SizedBox(height: 8),
CustomDropdown<dynamic>(
backClr: AppColors.clrD9,
@ -230,7 +294,7 @@ class GenerateFrightBill extends StatelessWidget {
//flex: 2,
child: Column(
children: [
_commonText(
TextView(text:
"",
),
Padding(
@ -244,9 +308,12 @@ class GenerateFrightBill extends StatelessWidget {
clickAction: () {},
),
SizedBox(width: 16),
CommonBtn(
CommonButton(
borderRadius: 4,
height: 30,
width: 100,
text: AppStrings.submit,
style: 14.txtBoldWhite,
clickAction: () {
controller.postData();
},
@ -269,13 +336,15 @@ class GenerateFrightBill extends StatelessWidget {
color: AppColors.primaryClr,
child: Row(
children: [
TextView(text: AppStrings.viewGrnDetails, style: 15.txtBoldWhite),
TextView(text: AppStrings.viewGrnDetails, style: 14.txtBoldWhite),
Spacer(),
CommonBtn(
width: 150,
bkClr: AppColors.white,
borderClr: AppColors.primaryClr,
style: 14.txtBoldBlue,
text: AppStrings.save,
style: 12.txtBoldBlue,
text: "Generate Freight Bill",
// text: AppStrings.save,
clickAction: () {
bool hasSelectedRows = controller.grnDetails
.any((element) => element.isSelected);
@ -360,7 +429,7 @@ class GenerateFrightBill extends StatelessWidget {
),
),
),
dataColumn(AppStrings.srNo),
// dataColumn(AppStrings.srNo),
dataColumn(AppStrings.mrnNo),
dataColumn(AppStrings.plantNo),
dataColumn(AppStrings.product),
@ -401,20 +470,20 @@ class GenerateFrightBill extends StatelessWidget {
),
),
),
editableCell(index, "0${index + 1}"),
// editableCell(index, "0${index + 1}"),
editableCell(index, stoppage.grnNo ?? ""),
editableCell(index, stoppage.plantCode ?? ""),
editableCell(index, stoppage.materialCode ?? ""),
editableCell(
index,
DateFormat('yyyy-MM-dd').format(
DateFormat('dd/MM/yyyy').format(
stoppage.grnDate ?? DateTime.now())),
editableCell(index, stoppage.fromLocation ?? ""),
editableCell(index, stoppage.vehicleNo ?? ""),
editableCell(index, stoppage.lrNo ?? ""),
editableCell(
index,
DateFormat('yyyy-MM-dd')
DateFormat('dd/MM/yyyy')
.format(stoppage.lrDate ?? DateTime.now())),
editableCell(
index, stoppage.dispQty?.toString() ?? ""),
@ -441,12 +510,4 @@ class GenerateFrightBill extends StatelessWidget {
],
);
}
_commonText(String title) {
return Text(
title,
style: TextStyle(
fontSize: 13, color: Colors.black, fontWeight: FontWeight.w900),
);
}
}

View File

@ -42,7 +42,9 @@ class _TransportViewState extends State<InvoiceManagement> {
itemBuilder: (context, index) {
return Obx(
() => InkWell(
onTap: () {},
onTap: () {
ctrl.selectedState.value = index;
},
child: Container(
margin: EdgeInsets.only(bottom: 10, top: 10),
decoration: BoxDecoration(

View File

@ -1,10 +1,19 @@
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:intl/intl.dart';
import 'package:shayog/components/styles/textStyles.dart';
import 'package:shayog/feature/presentation/screens/transporter/view_model/transport_controller.dart';
import 'package:sizer/sizer.dart';
import 'package:vph_web_date_picker/vph_web_date_picker.dart';
import '../../../../../../../components/common/data_cell.dart';
import '../../../../../../../components/styles/app_colors.dart';
import '../../../../../../../components/styles/app_strings.dart';
import '../../../../../../components/common/common_btn.dart';
import '../../../../../../components/common/common_button.dart';
import '../../../../../../components/common/custom_drop_down.dart';
import '../../../../widgets/text_view.dart';
import '../../widgets/common_card.dart';
import '../../widgets/freightbill_dialog.dart';
class PendingGeneration extends StatelessWidget {
PendingGeneration({super.key});
@ -15,161 +24,451 @@ class PendingGeneration extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Obx(() {
if (controller.freightViewLoader.value) {
return Center(
child: CircularProgressIndicator(
color: AppColors.primaryClr,
),
);
} else {
return Column(
children: [
Obx(() {
if (controller.isLoading.value) {
return Center(child: CircularProgressIndicator());
}
if (controller.errorMessage.isNotEmpty) {
return Center(child: Text(controller.errorMessage.value));
}
if (controller.grnDetails.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,
),
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"),
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 ?? "";
print(
"selectPlant${controller.selectPlant.value}");
}
},
hintText: "Select Plant",
),
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(
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,
],
),
),
SizedBox(width: 16),
Expanded(
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
TextView(text:"Product Name"),
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"),
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;
print(
"selectTransactionType${controller.selectTransactionType.value}");
}
},
hintText: "Select Transaction Type",
),
],
),
),
],
),
Padding(
padding: const EdgeInsets.only(top: 16.0, left: 0, right: 8),
child: Row(
children: [
Expanded(
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
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(
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();
},
child: Icon(Icons.close, size: 1.2.w),
)
: null,
contentPadding: const EdgeInsets.symmetric(
horizontal: 12.0, vertical: 0.0),
),
),
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.grnDetails.length, (index) {
final stoppage = controller.grnDetails[index];
),
],
),
),
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(
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(
borderRadius: 4,
height: 30,
width: 100,
text: AppStrings.submit,
return DataRow(
selected: stoppage.isSelected,
cells: [
DataCell(
Transform.scale(
clickAction: () {
controller.postData();
},
),
],
),
),
],
))
],
),
),
],
),
),
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,
),
),
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(
label: Transform.scale(
scale: 0.80,
child: Checkbox(
value: stoppage.isSelected,
value: controller.selectAllField.value,
onChanged: (value) {
controller.toggleSelection(
index, value ?? false);
controller.selectAll(value ?? false);
},
activeColor: AppColors.primaryClr,
checkColor: Colors.white,
materialTapTargetSize: MaterialTapTargetSize
.shrinkWrap,
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.freightRate?.toString() ?? ""),
editableCell(
index, stoppage.freightRate?.toString() ?? ""),
// 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: 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

@ -1,220 +1,493 @@
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:shayog/components/common/common_btn.dart';
import 'package:shayog/components/styles/textStyles.dart';
import 'package:shayog/feature/presentation/screens/transporter/model/view_freight_bill_res_model.dart';
import 'package:sizer/sizer.dart';
import 'package:vph_web_date_picker/vph_web_date_picker.dart';
import '../../../../../../../components/common/data_cell.dart';
import '../../../../../../../components/styles/app_colors.dart';
import '../../../../../../../components/styles/app_strings.dart';
import '../../../../../../components/common/common_button.dart';
import '../../../../../../components/common/custom_drop_down.dart';
import '../../../../widgets/custom_pagination.dart';
import '../../../../widgets/text_view.dart';
import '../../view_model/transport_controller.dart';
import '../../widgets/common_card.dart';
import '../../widgets/freightbill_dialog.dart';
class ViewFreightBill extends StatelessWidget {
ViewFreightBill({super.key});
final ScrollController horizontalScrollController = ScrollController();
final ScrollController verticalScrollController = ScrollController();
final ctrl = Get.put(TransportController());
final controller = Get.put(TransportController());
@override
Widget build(BuildContext context) {
return Obx(() {
if (ctrl.freightViewLoader.value) {
return Center(
child: CircularProgressIndicator(
color: AppColors.primaryClr,
),
);
} else {
return Column(
children: [
Scrollbar(
thumbVisibility: true,
controller: verticalScrollController,
child: SingleChildScrollView(
controller: verticalScrollController,
child: Scrollbar(
thumbVisibility: true,
controller: horizontalScrollController,
child: SingleChildScrollView(
scrollDirection: Axis.horizontal,
controller: horizontalScrollController,
child: Container(
decoration: BoxDecoration(
border: Border.all(
color: Colors.grey.shade400,
width: 1.0,
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"),
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 ?? "";
print(
"selectPlant${controller.selectPlant.value}");
}
},
hintText: "Select Plant",
),
),
child: DataTable(
dataRowHeight: 28,
headingRowHeight: 38,
headingRowColor:
WidgetStateProperty.all(AppColors.clrF2),
],
),
),
SizedBox(width: 16),
Expanded(
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
TextView(text: "Product Name"),
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"),
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;
print(
"selectTransactionType${controller.selectTransactionType.value}");
}
},
hintText: "Select Transaction Type",
),
],
),
),
],
),
Padding(
padding: const EdgeInsets.only(top: 16.0, left: 0, right: 8),
child: Row(
children: [
Expanded(
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
TextView(text: "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(),
);
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(AppStrings.srNo),
dataColumn(AppStrings.plant),
dataColumn(
AppStrings.productName,
onSort: (_, __) => ctrl.changeSort(
AppStrings.productName.toLowerCase()),
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),
),
),
),
dataColumn(AppStrings.freightBillNo),
dataColumn(AppStrings.freightBillDate),
dataColumn(AppStrings.freightInvoice),
dataColumn(AppStrings.freightInvoiceDate),
dataColumn(AppStrings.billingQty),
dataColumn(AppStrings.uom),
dataColumn(AppStrings.freightAmount),
dataColumn(AppStrings.cGST),
dataColumn(AppStrings.sGST),
dataColumn(AppStrings.iGST),
dataColumn(AppStrings.totalGst),
dataColumn(AppStrings.totalInvoiceAmt),
dataColumn(AppStrings.cCN),
dataColumn(AppStrings.cCNDate),
dataColumn(AppStrings.miroStatus),
dataColumn(AppStrings.gstHold),
dataColumn(AppStrings.gstRelease),
dataColumn(AppStrings.utrNo),
dataColumn(AppStrings.utrDate),
dataColumn(AppStrings.amount),
dataColumn("${AppStrings.utrNo} 1"),
dataColumn(AppStrings.utrDate),
dataColumn("${AppStrings.amount} 1"),
dataColumn("${AppStrings.utrNo} 2"),
dataColumn(AppStrings.utrDate),
dataColumn("${AppStrings.amount} 2"),
dataColumn("${AppStrings.utrNo} 3"),
dataColumn(AppStrings.utrDate),
dataColumn("${AppStrings.amount} 3"),
dataColumn("${AppStrings.utrNo} 4"),
dataColumn(AppStrings.utrDate),
dataColumn("${AppStrings.amount} 4"),
dataColumn("${AppStrings.utrNo} 5"),
dataColumn(AppStrings.utrDate),
dataColumn("${AppStrings.amount} 5"),
],
rows: List<DataRow>.generate(
ctrl.freightBillData.length, (index) {
final freightBill = ctrl.freightBillData[index];
return DataRow(
cells: [
editableCell(index, "0${index + 1}"),
editableCell(index, "${freightBill.plantCode}"),
editableCell(index, "${freightBill.status}"),
editableCell(
index,
"${freightBill.freightbillId}",
isLink: true,
onTap: () {
showFreightBillDetailsDialog(
context, freightBill);
),
),
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(
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(
borderRadius: 4,
height: 30,
width: 100,
text: AppStrings.submit,
clickAction: () {
controller.postData();
},
),
editableCell(index, "${freightBill.utr1Date}"),
editableCell(
index, "${freightBill.trasnporterInvoiceNo}"),
editableCell(index,
"${freightBill.trasnporterInvoiceNoDate}"),
editableCell(index, "${freightBill.billingQty}"),
editableCell(index, "${freightBill.uom}"),
editableCell(
index, "${freightBill.freightAmount}"),
editableCell(index, "${freightBill.cgst}"),
editableCell(index, "${freightBill.sgst}"),
editableCell(index, "${freightBill.igst}"),
editableCell(index, "${freightBill.totalGst}"),
editableCell(index, "${freightBill.totalGst}"),
editableCell(
index, "${freightBill.freightAmount}"),
editableCell(index,
"${freightBill.trasnporterInvoiceNoDate}"),
editableCell(index, "${freightBill.status}"),
editableCell(index, "${freightBill.totalGst}"),
editableCell(index,
"${freightBill.trasnporterInvoiceNoDate}"),
editableCell(index, "${freightBill.utr5No}"),
editableCell(index, "${freightBill.utr1Date}"),
editableCell(
index, "${freightBill.freightAmount}"),
editableCell(index, "${freightBill.utr1No}"),
editableCell(index, "${freightBill.utr1Date}"),
editableCell(
index, "${freightBill.utr1PaymentAmount}"),
editableCell(index, "${freightBill.utr2No}"),
editableCell(index, "${freightBill.utr2Date}"),
editableCell(
index, "${freightBill.utr2PaymentAmount}"),
editableCell(index, "${freightBill.utr3No}"),
editableCell(index, "${freightBill.utr3Date}"),
editableCell(
index, "${freightBill.utr3PaymentAmount}"),
editableCell(index, "${freightBill.utr4No}"),
editableCell(index, "${freightBill.utr4Date}"),
editableCell(
index, "${freightBill.utr4PaymentAmount}"),
editableCell(index, "${freightBill.utr5No}"),
editableCell(index, "${freightBill.utr5Date}"),
editableCell(
index, "${freightBill.utr5PaymentAmount}"),
],
);
}),
),
),
],
))
],
),
),
],
),
),
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: () {});
}
}),
],
),
),
Obx(() {
if (controller.freightViewLoader.value) {
return Center(
child: CircularProgressIndicator(
color: AppColors.primaryClr,
),
);
} else {
return Column(
children: [
Scrollbar(
thumbVisibility: true,
controller: verticalScrollController,
child: SingleChildScrollView(
controller: verticalScrollController,
child: Scrollbar(
thumbVisibility: true,
controller: horizontalScrollController,
child: SingleChildScrollView(
scrollDirection: Axis.horizontal,
controller: horizontalScrollController,
child: Container(
decoration: BoxDecoration(
border: Border.all(
color: Colors.grey.shade400,
width: 1.0,
),
),
child: DataTable(
dataRowHeight: 28,
headingRowHeight: 38,
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(AppStrings.srNo),
dataColumn(AppStrings.plant),
dataColumn(
AppStrings.productName,
onSort: (_, __) => controller.changeSort(
AppStrings.productName.toLowerCase()),
),
dataColumn(AppStrings.freightBillNo),
dataColumn(AppStrings.freightBillDate),
dataColumn(AppStrings.freightInvoice),
dataColumn(AppStrings.freightInvoiceDate),
dataColumn(AppStrings.billingQty),
dataColumn(AppStrings.uom),
dataColumn(AppStrings.freightAmount),
dataColumn(AppStrings.cGST),
dataColumn(AppStrings.sGST),
dataColumn(AppStrings.iGST),
dataColumn(AppStrings.totalGst),
dataColumn(AppStrings.totalInvoiceAmt),
dataColumn(AppStrings.cCN),
dataColumn(AppStrings.cCNDate),
dataColumn(AppStrings.miroStatus),
dataColumn(AppStrings.gstHold),
dataColumn(AppStrings.gstRelease),
dataColumn(AppStrings.utrNo),
dataColumn(AppStrings.utrDate),
dataColumn(AppStrings.amount),
dataColumn("${AppStrings.utrNo} 1"),
dataColumn(AppStrings.utrDate),
dataColumn("${AppStrings.amount} 1"),
dataColumn("${AppStrings.utrNo} 2"),
dataColumn(AppStrings.utrDate),
dataColumn("${AppStrings.amount} 2"),
dataColumn("${AppStrings.utrNo} 3"),
dataColumn(AppStrings.utrDate),
dataColumn("${AppStrings.amount} 3"),
dataColumn("${AppStrings.utrNo} 4"),
dataColumn(AppStrings.utrDate),
dataColumn("${AppStrings.amount} 4"),
dataColumn("${AppStrings.utrNo} 5"),
dataColumn(AppStrings.utrDate),
dataColumn("${AppStrings.amount} 5"),
],
rows: List<DataRow>.generate(
controller.freightBillData.length, (index) {
final freightBill =
controller.freightBillData[index];
return DataRow(
cells: [
editableCell(index, "0${index + 1}"),
editableCell(
index, "${freightBill.plantCode}"),
editableCell(index, "${freightBill.status}"),
editableCell(
index,
"${freightBill.freightbillId}",
isLink: true,
onTap: () {
showFreightBillDetailsDialog(
context, freightBill);
},
),
editableCell(
index, "${freightBill.utr1Date}"),
editableCell(index,
"${freightBill.trasnporterInvoiceNo}"),
editableCell(index,
"${freightBill.trasnporterInvoiceNoDate}"),
editableCell(
index, "${freightBill.billingQty}"),
editableCell(index, "${freightBill.uom}"),
editableCell(
index, "${freightBill.freightAmount}"),
editableCell(index, "${freightBill.cgst}"),
editableCell(index, "${freightBill.sgst}"),
editableCell(index, "${freightBill.igst}"),
editableCell(
index, "${freightBill.totalGst}"),
editableCell(
index, "${freightBill.totalGst}"),
editableCell(
index, "${freightBill.freightAmount}"),
editableCell(index,
"${freightBill.trasnporterInvoiceNoDate}"),
editableCell(index, "${freightBill.status}"),
editableCell(
index, "${freightBill.totalGst}"),
editableCell(index,
"${freightBill.trasnporterInvoiceNoDate}"),
editableCell(index, "${freightBill.utr5No}"),
editableCell(
index, "${freightBill.utr1Date}"),
editableCell(
index, "${freightBill.freightAmount}"),
editableCell(index, "${freightBill.utr1No}"),
editableCell(
index, "${freightBill.utr1Date}"),
editableCell(index,
"${freightBill.utr1PaymentAmount}"),
editableCell(index, "${freightBill.utr2No}"),
editableCell(
index, "${freightBill.utr2Date}"),
editableCell(index,
"${freightBill.utr2PaymentAmount}"),
editableCell(index, "${freightBill.utr3No}"),
editableCell(
index, "${freightBill.utr3Date}"),
editableCell(index,
"${freightBill.utr3PaymentAmount}"),
editableCell(index, "${freightBill.utr4No}"),
editableCell(
index, "${freightBill.utr4Date}"),
editableCell(index,
"${freightBill.utr4PaymentAmount}"),
editableCell(index, "${freightBill.utr5No}"),
editableCell(
index, "${freightBill.utr5Date}"),
editableCell(index,
"${freightBill.utr5PaymentAmount}"),
],
);
}),
),
),
),
),
),
),
),
),
Align(
alignment: Alignment.bottomRight,
child: Container(
padding: const EdgeInsets.only(bottom: 16),
child: Row(
mainAxisAlignment: MainAxisAlignment.end,
children: [
IconButton(
icon: Icon(Icons.chevron_left),
onPressed: ctrl.currentPage.value > 0
? () => ctrl.previousPage()
: null,
),
SizedBox(width: 16),
Text(
'Page ${ctrl.currentPage.value + 1} of ${ctrl.totalPages.value}',
style: TextStyle(fontSize: 16),
),
SizedBox(width: 16),
IconButton(
icon: Icon(Icons.chevron_right),
onPressed: ctrl.currentPage.value < ctrl.totalPages.value - 1
? () => ctrl.nextPage()
: null,
),
],
CustomPagination(
currentPage: controller.currentPage.value,
totalPages: controller.totalPages.value,
onPageChanged: (int page) {
controller.onPageChanged(page);
},
),
),
)
],
);
}
});
],
);
}
}),
],
);
}
void showFreightBillDetailsDialog(
@ -279,7 +552,7 @@ class ViewFreightBill extends StatelessWidget {
dataColumn(AppStrings.mrnNo),
dataColumn(
AppStrings.plantName,
onSort: (_, __) => ctrl.changeSort(
onSort: (_, __) => controller.changeSort(
AppStrings.productName.toLowerCase()),
),
dataColumn(AppStrings.product),
@ -296,8 +569,9 @@ class ViewFreightBill extends StatelessWidget {
dataColumn(AppStrings.freightAmount),
],
rows: List<DataRow>.generate(
ctrl.freightBillData.length, (index) {
final freightBill = ctrl.freightBillData[index];
controller.freightBillData.length, (index) {
final freightBill =
controller.freightBillData[index];
return DataRow(
cells: [
editableCell(index, "0${index + 1}"),

View File

@ -43,7 +43,7 @@ class _TransportViewState extends State<TransportView> {
scrollDirection: Axis.vertical,
itemBuilder: (context, index) {
return Obx(
() => InkWell(
() => InkWell(
onTap: () {
ctrl.selectedIndex.value = index;
},
@ -68,10 +68,9 @@ class _TransportViewState extends State<TransportView> {
),
),
TextView(
text: ctrl.tabs[index].title ?? "",
text: ctrl.tabs[index].title ?? "",
textAlign: TextAlign.center,
style: 10.txtBoldWhite,
)
],
),
@ -114,7 +113,7 @@ class _TransportViewState extends State<TransportView> {
child: Column(
children: [
Container(
height: 60,
height: 50,
color: AppColors.primaryClr,
child: Row(
children: [
@ -133,16 +132,15 @@ class _TransportViewState extends State<TransportView> {
decoration: BoxDecoration(
border: Border(
bottom: BorderSide(
color: ctrl.selectedUser.value == index
? Colors.white
: AppColors.primaryClr,
color:
ctrl.selectedUser.value == index
? Colors.white
: AppColors.primaryClr,
width: 3))),
child: Center(
child: TextView(
text:
ctrl.userTabs[index].title ?? "",
text: ctrl.userTabs[index].title ?? "",
style: 12.txtBoldWhite,
),
),
),
@ -156,7 +154,6 @@ class _TransportViewState extends State<TransportView> {
),
Spacer(),
InkWell(
child: Image.asset(AppImages.refresh,
height: 16, width: 16)),
Padding(
@ -164,11 +161,10 @@ class _TransportViewState extends State<TransportView> {
child: Text(
AppStrings.refresh,
style: 12.txtBoldWhite,
),
),
Obx(() =>
Visibility(
Obx(
() => Visibility(
visible: ctrl.selectedUser.value >= 1,
child: InkWell(
onTap: ctrl.toggleContainer,
@ -181,10 +177,8 @@ class _TransportViewState extends State<TransportView> {
child: Padding(
padding: const EdgeInsets.all(8.0),
child: TextView(
text:AppStrings.filter,
text: AppStrings.filter,
style: 12.txtBoldWhite,
),
),
),
@ -192,103 +186,71 @@ class _TransportViewState extends State<TransportView> {
),
),
Obx(
() => ctrl.isSelected.value
() => 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'),
],
)),
],
),
Padding(
padding: const EdgeInsets.only(
top: 16.0, left: 8, right: 8),
child: Row(
margin: EdgeInsets.symmetric(vertical: 16),
padding: EdgeInsets.all(16),
color: AppColors.clrF2,
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Expanded(
child: Column(
Row(
children: [
Expanded(
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment:
CrossAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
TextView(
text:
"Plant",
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(
@ -302,20 +264,21 @@ class _TransportViewState extends State<TransportView> {
}
},
hintText: 'Select Product'),
],
)),
SizedBox(width: 16),
Expanded(
child: Column(
],
),
SizedBox(height: 12),
Row(
children: [
Expanded(
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment:
CrossAxisAlignment.start,
CrossAxisAlignment.start,
children: [
TextView(
text:
"Transaction Type",
text: "Plant",
),
SizedBox(height: 8),
CustomDropdown(
@ -325,52 +288,75 @@ class _TransportViewState extends State<TransportView> {
itemLabel: (item) => item,
onSelected: (selected) {
if (selected != null) {
ctrl.selectedPlant.value = selected;
ctrl.selectedPlant.value =
selected;
}
},
hintText: 'Select Product'),
],
)),
SizedBox(width: 16),
Expanded(
child: Column(
children: [
TextView(
text:
"" ,
),
SizedBox(height: 8),
Row(
mainAxisAlignment:
MainAxisAlignment.end,
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: [
CommonBtn(
bkClr: Colors.white,
text: AppStrings.cancel, clickAction: () {
ctrl.isSelected.value = false;
},),
SizedBox(width: 16),
CommonBtn(
text: AppStrings.submit,
style: 14.txtBoldWhite, clickAction: () {
ctrl.isSelected.value = false;
},
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(() {
@ -389,6 +375,4 @@ class _TransportViewState extends State<TransportView> {
],
);
}
}

View File

@ -1,15 +1,14 @@
import 'package:flutter/cupertino.dart';
import 'package:get/get.dart';
import 'package:intl/intl.dart';
import 'package:shayog/components/styles/app_images.dart';
import 'package:shayog/services/network/get_requests.dart';
import '../../../../../../components/common/common_model.dart';
import '../../../../../../components/styles/app_strings.dart';
import '../../../../../../services/model/generate_freight_model.dart';
import '../../../../../../services/network/post_request.dart';
import '../model/freightbill_res_model.dart';
import '../model/grn_panding_res_model.dart';
import '../model/view_freight_bill_res_model.dart';
class TransportController extends GetxController {
@ -17,14 +16,14 @@ class TransportController extends GetxController {
final ScrollController verticalScrollController = ScrollController();
var selectedIndex = 0.obs;
var selectedUser = 0.obs;
var selectPlant = ''.obs;
RxString selectPlant = ''.obs;
var selectProduct = ''.obs;
var selectLocation = ''.obs;
var selectTransactionType = ''.obs;
var selectedItem = false.obs;
var grnDetails = <Content>[].obs;
var product = [].obs;
var plant = [].obs;
var product = <Prodect>[].obs;
var plant = <Plant>[].obs;
var freightBill = [].obs;
var fromLocation = [].obs;
var grnList = [].obs;
@ -47,6 +46,8 @@ class TransportController extends GetxController {
void onInit() {
getFreightBills();
viewFreightView();
grnPending();
super.onInit();
}
@ -72,10 +73,11 @@ class TransportController extends GetxController {
CommonModel(title: AppStrings.pendingGeneration),
].obs;
var isLoading = true.obs;
var grnListLoader = true.obs;
var freightViewLoader = true.obs;
var generateBill = true.obs;
var isLoading = false.obs;
var grnListLoader = false.obs;
var freightViewLoader = false.obs;
var generateBill = false.obs;
var grnPendingLoader = false.obs;
var errorMessage = ''.obs;
postData() async {
@ -199,19 +201,56 @@ class TransportController extends GetxController {
////////////////////////////////////////// PRIYA ///////////////////////////////////////////////
var freightBillData = <FreightBill>[].obs;
var currentPage = 0.obs;
var totalPages = 0.obs;
var totalElements = 0.obs;
var pageSize = 2.obs;
var sortField = "grn_date".obs;
var sortDirection = "desc".obs;
viewFreightView({int? page, String? sort, String? direction}) async {
// 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;
currentPage.value = page ?? currentPage.value;
if (sort != null) sortField.value = sort;
if (direction != null) sortDirection.value = direction;
// currentPage.value = page ?? currentPage.value;
// if (sort != null) sortField.value = sort;
// if (direction != null) sortDirection.value = direction;
Map<String, String> requestBody = {
"plant": "",
@ -230,7 +269,7 @@ class TransportController extends GetxController {
currentPage.value, pageSize.value, '$sortField', '$sortDirection');
if (response != null) {
List<FreightBill> flattenedContent =
response.content!.expand((list) => list).toList();
response.content!.expand((list) => list).toList();
freightBillData.assignAll(flattenedContent);
totalPages.value = response.totalPages ?? 0;
@ -241,15 +280,22 @@ class TransportController extends GetxController {
}
}
void nextPage() {
if (currentPage < totalPages.value - 1) {
viewFreightView(page: currentPage.value + 1);
if (currentPage.value < totalPages.value) {
currentPage.value++;
viewFreightView(); // Fetch data for the next page
}
}
void previousPage() {
if (currentPage > 0) {
viewFreightView(page: currentPage.value - 1);
if (currentPage.value > 1) {
currentPage.value--;
viewFreightView();// Fetch data for the previous page
}
}
void onPageChanged(int page) {
currentPage.value = page;
viewFreightView();// Fetch data for the selected page
}
void changeSort(String field) {
if (field == sortField.value) {
sortDirection.value = sortDirection.value == "asc" ? "desc" : "asc";
@ -257,6 +303,40 @@ class TransportController extends GetxController {
sortField.value = field;
sortDirection.value = "desc";
}
viewFreightView(page: 0);
// viewFreightView(page: 0);
}
var grnPendingData = <GrnPending>[].obs;
grnPending() async {
try {
grnPendingLoader.value = true;
Map<String, String> requestBody =
{
"plant": "",
"productNane": "",
"transactionType": "",
"fromLocation": "",
"grnFromDate": "",
"grnToDate": ""
};
var response = await PostRequests.grnPending(requestBody,
);
if (response != null) {
List<GrnPending> flattenedContent =
response.content!.expand((list) => list).toList();
grnPendingData.assignAll(flattenedContent);
}
} finally {
grnPendingLoader.value = false;
}
}
}

View File

@ -0,0 +1,253 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
class DropdownDateRange extends StatefulWidget {
@override
_DropdownDateRangeState createState() => _DropdownDateRangeState();
}
class _DropdownDateRangeState extends State<DropdownDateRange> {
bool isCalendarVisible = false;
DateTime selectedStartDate = DateTime.now();
DateTime selectedEndDate = DateTime.now().add(Duration(days: 5));
DateTime displayedStartMonth = DateTime.now();
DateTime displayedEndMonth = DateTime.now().add(Duration(days: 60));
List<String> weekdays = ['Mo', 'Tu', 'We', 'Th', 'Fr', 'Sa', 'Su'];
List<String> months = [
'January', 'February', 'March', 'April', 'May', 'June',
'July', 'August', 'September', 'October', 'November', 'December'
];
@override
Widget build(BuildContext context) {
return Material(
color: Colors.transparent,
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
// Clickable Container
GestureDetector(
onTap: () {
setState(() {
isCalendarVisible = !isCalendarVisible;
});
},
child: Container(
padding: EdgeInsets.symmetric(horizontal: 16, vertical: 12),
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(4),
border: Border.all(color: Colors.grey.shade300),
),
child: Row(
mainAxisSize: MainAxisSize.min,
children: [
Text(
'${selectedStartDate.day} ${months[selectedStartDate.month - 1]} ${selectedStartDate.year} - '
'${selectedEndDate.day} ${months[selectedEndDate.month - 1]} ${selectedEndDate.year}',
style: TextStyle(fontSize: 14),
),
SizedBox(width: 8),
Icon(Icons.arrow_drop_down),
],
),
),
),
// Dropdown Calendar
if (isCalendarVisible)
Container(
margin: EdgeInsets.only(top: 8),
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(8),
boxShadow: [
BoxShadow(
color: Colors.grey.withOpacity(0.2),
spreadRadius: 1,
blurRadius: 8,
offset: Offset(0, 4),
),
],
),
child: Column(
children: [
Padding(
padding: EdgeInsets.all(16),
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
_buildCalendar(displayedStartMonth, true),
SizedBox(width: 32),
_buildCalendar(displayedEndMonth, false),
],
),
),
],
),
),
],
),
);
}
Widget _buildCalendar(DateTime displayedMonth, bool isStartCalendar) {
return Container(
width: 280,
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(8),
),
child: Column(
children: [
// Month Header
Padding(
padding: EdgeInsets.all(8),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
IconButton(
icon: Icon(Icons.chevron_left),
onPressed: () {
setState(() {
if (isStartCalendar) {
displayedStartMonth = DateTime(
displayedStartMonth.year,
displayedStartMonth.month - 1,
);
} else {
displayedEndMonth = DateTime(
displayedEndMonth.year,
displayedEndMonth.month - 1,
);
}
});
},
),
Text(
'${months[displayedMonth.month - 1]} (${displayedMonth.year})',
style: TextStyle(fontWeight: FontWeight.bold),
),
IconButton(
icon: Icon(Icons.chevron_right),
onPressed: () {
setState(() {
if (isStartCalendar) {
displayedStartMonth = DateTime(
displayedStartMonth.year,
displayedStartMonth.month + 1,
);
} else {
displayedEndMonth = DateTime(
displayedEndMonth.year,
displayedEndMonth.month + 1,
);
}
});
},
),
],
),
),
// Weekday Headers
Row(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: weekdays.map((day) =>
Container(
width: 32,
alignment: Alignment.center,
child: Text(
day,
style: TextStyle(
fontSize: 12,
color: Colors.grey[600],
),
),
),
).toList(),
),
// Calendar Grid
Container(
padding: EdgeInsets.symmetric(vertical: 8),
child: Column(
children: _buildCalendarDays(displayedMonth),
),
),
],
),
);
}
List<Widget> _buildCalendarDays(DateTime displayedMonth) {
List<Widget> weeks = [];
DateTime firstDay = DateTime(displayedMonth.year, displayedMonth.month, 1);
int daysInMonth = DateTime(displayedMonth.year, displayedMonth.month + 1, 0).day;
int firstWeekdayOfMonth = firstDay.weekday;
int currentDay = 1 - firstWeekdayOfMonth + 1;
for (int week = 0; week < 6; week++) {
List<Widget> days = [];
for (int i = 0; i < 7; i++) {
if (currentDay <= 0 || currentDay > daysInMonth) {
days.add(Container(width: 32, height: 32));
} else {
final date = DateTime(displayedMonth.year, displayedMonth.month, currentDay);
final isSelected = date.isAfter(selectedStartDate.subtract(Duration(days: 1))) &&
date.isBefore(selectedEndDate.add(Duration(days: 1)));
final isToday = date.year == DateTime.now().year &&
date.month == DateTime.now().month &&
date.day == DateTime.now().day;
days.add(
GestureDetector(
onTap: () {
setState(() {
if (date.isBefore(selectedEndDate)) {
selectedStartDate = date;
} else {
selectedEndDate = date;
}
});
},
child: Container(
width: 32,
height: 32,
alignment: Alignment.center,
decoration: BoxDecoration(
color: isSelected ? Colors.blue : Colors.transparent,
borderRadius: BorderRadius.circular(16),
border: isToday ? Border.all(color: Colors.blue) : null,
),
child: Text(
currentDay.toString(),
style: TextStyle(
color: isSelected ? Colors.white : Colors.black,
fontWeight: isToday ? FontWeight.bold : FontWeight.normal,
),
),
),
),
);
}
currentDay++;
}
weeks.add(
Row(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: days,
),
);
}
return weeks;
}
}

View File

@ -0,0 +1,83 @@
import 'package:flutter/material.dart';
import 'package:shayog/components/styles/textStyles.dart';
import 'dart:math' as math;
import '../../../components/styles/app_colors.dart';
class CustomPagination extends StatelessWidget {
final int currentPage;
final int totalPages;
final Function(int) onPageChanged;
const CustomPagination({
super.key,
required this.currentPage,
required this.totalPages,
required this.onPageChanged,
});
@override
Widget build(BuildContext context) {
return Container(
padding: const EdgeInsets.symmetric(vertical: 8.0),
decoration: BoxDecoration(
//color: Colors.grey[200],
border: Border(
top: BorderSide(color: Colors.grey[300]!),
),
),
child: Row(
mainAxisAlignment: MainAxisAlignment.end, // Center the pagination
children: [
IconButton(
icon: const Icon(Icons.chevron_left),
onPressed:
currentPage > 1 ? () => onPageChanged(currentPage - 1) : null,
),
_buildPageButton(1),
if (currentPage > 3)
const Text('...', style: TextStyle(fontSize: 20)),
for (int i = math.max(2, currentPage - 1);
i <= math.min(totalPages - 1, currentPage + 1);
i++)
_buildPageButton(i),
if (currentPage < totalPages - 2)
const Text('...', style: TextStyle(fontSize: 20)),
if (totalPages > 1) _buildPageButton(totalPages),
IconButton(
icon: const Icon(Icons.chevron_right),
onPressed: currentPage < totalPages
? () => onPageChanged(currentPage + 1)
: null,
),
],
),
);
}
Widget _buildPageButton(int pageNumber) {
final isSelected = pageNumber == currentPage;
return InkWell(
onTap: () => onPageChanged(pageNumber),
child: Container(
height: 25,
width: 25,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(8),
border: Border.all(
color: isSelected ? AppColors.primaryClr : AppColors.primaryClr),
color: isSelected ? AppColors.primaryClr : Colors.transparent,
),
margin: EdgeInsets.symmetric(horizontal: 4.0),
child: Center(
child: Text(
pageNumber.toString(),
style: isSelected ? 12.txtBoldWhite : 12.txtBoldBlue,
),
),
),
);
}
}

View File

@ -20,7 +20,7 @@ class MyApp extends StatelessWidget {
return GetMaterialApp(
debugShowCheckedModeBanner: false,
title: 'Shayog',
initialRoute: PageRoutes.login,
initialRoute: PageRoutes.dashboard,
onGenerateRoute: Navigation.onGenerateRoutes,
// home: DashboardScreen(),
);

View File

@ -1,4 +1,252 @@
//
//
// import 'dart:convert';
//
// GenerateFreightBills generateFreightBillsFromJson(String str) => GenerateFreightBills.fromJson(json.decode(str));
//
// String generateFreightBillsToJson(GenerateFreightBills data) => json.encode(data.toJson());
//
// class GenerateFreightBills {
// final List<List<Content>>? content;
// final Pageable? pageable;
// final bool? last;
// final int? totalElements;
// final int? totalPages;
// final int? size;
// final int? number;
// final Sort? sort;
// final bool? first;
// final int? numberOfElements;
// final bool? empty;
//
//
// GenerateFreightBills({
// this.content,
// this.pageable,
// this.last,
// this.totalElements,
// this.totalPages,
// this.size,
// this.number,
// this.sort,
// this.first,
// this.numberOfElements,
// this.empty,
// });
//
// factory GenerateFreightBills.fromJson(Map<String, dynamic> json) => GenerateFreightBills(
// content: json["content"] == null ? [] : List<List<Content>>.from(json["content"]!.map((x) => List<Content>.from(x.map((x) => Content.fromJson(x))))),
// pageable: json["pageable"] == null ? null : Pageable.fromJson(json["pageable"]),
// last: json["last"],
// totalElements: json["totalElements"],
// totalPages: json["totalPages"],
// size: json["size"],
// number: json["number"],
// sort: json["sort"] == null ? null : Sort.fromJson(json["sort"]),
// first: json["first"],
// numberOfElements: json["numberOfElements"],
// empty: json["empty"],
// );
//
// Map<String, dynamic> toJson() => {
// "content": content == null ? [] : List<dynamic>.from(content!.map((x) => List<dynamic>.from(x.map((x) => x.toJson())))),
// "pageable": pageable?.toJson(),
// "last": last,
// "totalElements": totalElements,
// "totalPages": totalPages,
// "size": size,
// "number": number,
// "sort": sort?.toJson(),
// "first": first,
// "numberOfElements": numberOfElements,
// "empty": empty,
// };
// }
//
// class Content {
// final int? grnId;
// final String? grnNo;
// final String? plantCode;
// final String? materialCode;
// final CodeValue? codeValue;
// final String? transporterCode;
// final DateTime? grnDate;
// final String? fromLocation;
// final String? vehicleNo;
// // final FromLocation? fromLocation;
// // final VehicleNo? vehicleNo;
// final String? lrNo;
// final DateTime? lrDate;
// final double? dispQty;
// final double? netQty;
// final double? billingQty;
// final int? freightRate;
// final double? shipmentCost;
// final int? statusId;
// bool isSelected;
//
// Content({
// this.grnId,
// this.grnNo,
// this.plantCode,
// this.materialCode,
// this.codeValue,
// this.transporterCode,
// this.grnDate,
// this.fromLocation,
// this.vehicleNo,
// this.lrNo,
// this.lrDate,
// this.dispQty,
// this.netQty,
// this.billingQty,
// this.freightRate,
// this.shipmentCost,
// this.statusId,
// this.isSelected = false,
// });
//
// factory Content.fromJson(Map<String, dynamic> json) => Content(
// grnId: json["grn_id"],
// grnNo: json["grn_no"],
// plantCode: json["plant_code"],
// materialCode: json["material_code"],
// codeValue: codeValueValues.map[json["code_value"]]!,
// transporterCode: json["transporter_code"],
// grnDate: json["grn_date"] == null ? null : DateTime.parse(json["grn_date"]),
// // fromLocation: fromLocationValues.map[json["from_location"]]!,
// // vehicleNo: vehicleNoValues.map[json["vehicle_no"]]!,
// fromLocation: json["from_location"]!,
// vehicleNo: json["vehicle_no"]!,
// lrNo: json["lr_no"],
// lrDate: json["lr_date"] == null ? null : DateTime.parse(json["lr_date"]),
// dispQty: json["disp_qty"]?.toDouble(),
// netQty: json["net_qty"]?.toDouble(),
// billingQty: json["billing_qty"]?.toDouble(),
// freightRate: json["freight_rate"],
// shipmentCost: json["shipment_cost"]?.toDouble(),
// statusId: json["status_id"],
// );
//
// Map<String, dynamic> toJson() => {
// "grn_id": grnId,
// "grn_no": grnNo,
// "plant_code": plantCode,
// "material_code": materialCode,
// "code_value": codeValueValues.reverse[codeValue],
// "transporter_code": transporterCode,
// "grn_date": "${grnDate!.year.toString().padLeft(4, '0')}-${grnDate!.month.toString().padLeft(2, '0')}-${grnDate!.day.toString().padLeft(2, '0')}",
// "from_location": fromLocationValues.reverse[fromLocation],
// "vehicle_no": vehicleNoValues.reverse[vehicleNo],
// "lr_no": lrNo,
// "lr_date": "${lrDate!.year.toString().padLeft(4, '0')}-${lrDate!.month.toString().padLeft(2, '0')}-${lrDate!.day.toString().padLeft(2, '0')}",
// "disp_qty": dispQty,
// "net_qty": netQty,
// "billing_qty": billingQty,
// "freight_rate": freightRate,
// "shipment_cost": shipmentCost,
// "status_id": statusId,
// };
// }
//
// enum CodeValue {
// INBOUND
// }
//
// final codeValueValues = EnumValues({
// "INBOUND": CodeValue.INBOUND
// });
//
// enum FromLocation {
// NOIDA_UP_TEST
// }
//
// final fromLocationValues = EnumValues({
// "NOIDA(UP-TEST)": FromLocation.NOIDA_UP_TEST
// });
//
// enum VehicleNo {
// RJ07_GC9764
// }
//
// final vehicleNoValues = EnumValues({
// "RJ07GC9764": VehicleNo.RJ07_GC9764
// });
//
// class Pageable {
// final Sort? sort;
// final int? offset;
// final int? pageSize;
// final int? pageNumber;
// final bool? unpaged;
// final bool? paged;
//
// Pageable({
// this.sort,
// this.offset,
// this.pageSize,
// this.pageNumber,
// this.unpaged,
// this.paged,
// });
//
// factory Pageable.fromJson(Map<String, dynamic> json) => Pageable(
// sort: json["sort"] == null ? null : Sort.fromJson(json["sort"]),
// offset: json["offset"],
// pageSize: json["pageSize"],
// pageNumber: json["pageNumber"],
// unpaged: json["unpaged"],
// paged: json["paged"],
// );
//
// Map<String, dynamic> toJson() => {
// "sort": sort?.toJson(),
// "offset": offset,
// "pageSize": pageSize,
// "pageNumber": pageNumber,
// "unpaged": unpaged,
// "paged": paged,
// };
// }
//
// class Sort {
// final bool? empty;
// final bool? sorted;
// final bool? unsorted;
//
// Sort({
// this.empty,
// this.sorted,
// this.unsorted,
// });
//
// factory Sort.fromJson(Map<String, dynamic> json) => Sort(
// empty: json["empty"],
// sorted: json["sorted"],
// unsorted: json["unsorted"],
// );
//
// Map<String, dynamic> toJson() => {
// "empty": empty,
// "sorted": sorted,
// "unsorted": unsorted,
// };
// }
//
// class EnumValues<T> {
// Map<String, T> map;
// late Map<T, String> reverseMap;
//
// EnumValues(this.map);
//
// Map<T, String> get reverse {
// reverseMap = map.map((k, v) => MapEntry(v, k));
// return reverseMap;
// }
// }
// To parse this JSON data, do
//
// final generateFreightBills = generateFreightBillsFromJson(jsonString);
import 'dart:convert';
@ -10,12 +258,12 @@ class GenerateFreightBills {
final List<List<Content>>? content;
final Pageable? pageable;
final bool? last;
final int? totalElements;
final int? totalPages;
final int? totalElements;
final bool? first;
final int? size;
final int? number;
final Sort? sort;
final bool? first;
final int? numberOfElements;
final bool? empty;
@ -24,26 +272,27 @@ class GenerateFreightBills {
this.content,
this.pageable,
this.last,
this.totalElements,
this.totalPages,
this.totalElements,
this.first,
this.size,
this.number,
this.sort,
this.first,
this.numberOfElements,
this.empty,
});
factory GenerateFreightBills.fromJson(Map<String, dynamic> json) => GenerateFreightBills(
content: json["content"] == null ? [] : List<List<Content>>.from(json["content"]!.map((x) => List<Content>.from(x.map((x) => Content.fromJson(x))))),
pageable: json["pageable"] == null ? null : Pageable.fromJson(json["pageable"]),
last: json["last"],
totalElements: json["totalElements"],
totalPages: json["totalPages"],
totalElements: json["totalElements"],
first: json["first"],
size: json["size"],
number: json["number"],
sort: json["sort"] == null ? null : Sort.fromJson(json["sort"]),
first: json["first"],
numberOfElements: json["numberOfElements"],
empty: json["empty"],
);
@ -52,12 +301,12 @@ class GenerateFreightBills {
"content": content == null ? [] : List<dynamic>.from(content!.map((x) => List<dynamic>.from(x.map((x) => x.toJson())))),
"pageable": pageable?.toJson(),
"last": last,
"totalElements": totalElements,
"totalPages": totalPages,
"totalElements": totalElements,
"first": first,
"size": size,
"number": number,
"sort": sort?.toJson(),
"first": first,
"numberOfElements": numberOfElements,
"empty": empty,
};
@ -68,13 +317,11 @@ class Content {
final String? grnNo;
final String? plantCode;
final String? materialCode;
final CodeValue? codeValue;
final String? codeValue;
final String? transporterCode;
final DateTime? grnDate;
final String? fromLocation;
final String? vehicleNo;
// final FromLocation? fromLocation;
// final VehicleNo? vehicleNo;
final String? lrNo;
final DateTime? lrDate;
final double? dispQty;
@ -83,6 +330,7 @@ class Content {
final int? freightRate;
final double? shipmentCost;
final int? statusId;
final dynamic remark;
bool isSelected;
Content({
@ -103,6 +351,7 @@ class Content {
this.freightRate,
this.shipmentCost,
this.statusId,
this.remark,
this.isSelected = false,
});
@ -111,13 +360,11 @@ class Content {
grnNo: json["grn_no"],
plantCode: json["plant_code"],
materialCode: json["material_code"],
codeValue: codeValueValues.map[json["code_value"]]!,
codeValue: json["code_value"],
transporterCode: json["transporter_code"],
grnDate: json["grn_date"] == null ? null : DateTime.parse(json["grn_date"]),
// fromLocation: fromLocationValues.map[json["from_location"]]!,
// vehicleNo: vehicleNoValues.map[json["vehicle_no"]]!,
fromLocation: json["from_location"]!,
vehicleNo: json["vehicle_no"]!,
fromLocation: json["from_location"],
vehicleNo: json["vehicle_no"],
lrNo: json["lr_no"],
lrDate: json["lr_date"] == null ? null : DateTime.parse(json["lr_date"]),
dispQty: json["disp_qty"]?.toDouble(),
@ -126,6 +373,7 @@ class Content {
freightRate: json["freight_rate"],
shipmentCost: json["shipment_cost"]?.toDouble(),
statusId: json["status_id"],
remark: json["remark"],
);
Map<String, dynamic> toJson() => {
@ -133,11 +381,11 @@ class Content {
"grn_no": grnNo,
"plant_code": plantCode,
"material_code": materialCode,
"code_value": codeValueValues.reverse[codeValue],
"code_value": codeValue,
"transporter_code": transporterCode,
"grn_date": "${grnDate!.year.toString().padLeft(4, '0')}-${grnDate!.month.toString().padLeft(2, '0')}-${grnDate!.day.toString().padLeft(2, '0')}",
"from_location": fromLocationValues.reverse[fromLocation],
"vehicle_no": vehicleNoValues.reverse[vehicleNo],
"from_location": fromLocation,
"vehicle_no": vehicleNo,
"lr_no": lrNo,
"lr_date": "${lrDate!.year.toString().padLeft(4, '0')}-${lrDate!.month.toString().padLeft(2, '0')}-${lrDate!.day.toString().padLeft(2, '0')}",
"disp_qty": dispQty,
@ -146,46 +394,23 @@ class Content {
"freight_rate": freightRate,
"shipment_cost": shipmentCost,
"status_id": statusId,
"remark": remark,
};
}
enum CodeValue {
INBOUND
}
final codeValueValues = EnumValues({
"INBOUND": CodeValue.INBOUND
});
enum FromLocation {
NOIDA_UP_TEST
}
final fromLocationValues = EnumValues({
"NOIDA(UP-TEST)": FromLocation.NOIDA_UP_TEST
});
enum VehicleNo {
RJ07_GC9764
}
final vehicleNoValues = EnumValues({
"RJ07GC9764": VehicleNo.RJ07_GC9764
});
class Pageable {
final Sort? sort;
final int? offset;
final int? pageSize;
final int? pageNumber;
final int? pageSize;
final bool? unpaged;
final bool? paged;
Pageable({
this.sort,
this.offset,
this.pageSize,
this.pageNumber,
this.pageSize,
this.unpaged,
this.paged,
});
@ -193,8 +418,8 @@ class Pageable {
factory Pageable.fromJson(Map<String, dynamic> json) => Pageable(
sort: json["sort"] == null ? null : Sort.fromJson(json["sort"]),
offset: json["offset"],
pageSize: json["pageSize"],
pageNumber: json["pageNumber"],
pageSize: json["pageSize"],
unpaged: json["unpaged"],
paged: json["paged"],
);
@ -202,8 +427,8 @@ class Pageable {
Map<String, dynamic> toJson() => {
"sort": sort?.toJson(),
"offset": offset,
"pageSize": pageSize,
"pageNumber": pageNumber,
"pageSize": pageSize,
"unpaged": unpaged,
"paged": paged,
};
@ -232,15 +457,3 @@ class Sort {
"unsorted": unsorted,
};
}
class EnumValues<T> {
Map<String, T> map;
late Map<T, String> reverseMap;
EnumValues(this.map);
Map<T, String> get reverse {
reverseMap = map.map((k, v) => MapEntry(v, k));
return reverseMap;
}
}

View File

@ -1,22 +1,22 @@
class ApiUrls {
ApiUrls._();
static const String baseUrl = "http://localhost:9098/";
static const String baseUrl = "http://localhost:9092/";
static const String baseUrlImage =
"https://codingacademy.world/early_eyes/public/images/user/";
static const addFreightBill =
'bill/grndetails?page=0&size=20&sort=grn_date,desc';
static const getFreightBills = 'bill/dropdown';
static const generateFreightBill =
'http://localhost:9098/bill/addFreightBill';
'http://localhost:9092/bill/addFreightBill';
static const createUser = 'http://localhost:9090/api/users/createUser';
static const editUser =
'http://localhost:9090/api/users/update?userEmpTransCode=';
static const getAllUser =
'http://localhost:9090/api/users/userdetails?page=';
static const viewFreightBill =
'http://localhost:9098/bill/freightbill?page';
static const viewFreightBill = 'http://localhost:9092/bill/freightbill?page';
static const addUserType =
'http://localhost:9090/api/user-types/createUserType';
static const dropDownList =
@ -32,5 +32,7 @@ class ApiUrls {
static const selectAndAssignRole =
"http://localhost:9090/api/user-roles/assignRoles";
static const assignPlantRole = "http://localhost:9090/userplant/assignPlants";
static const userTypeDetails = "http://localhost:9090/api/user-types/usertypedetails?page=0&size=15&sort=last_updated_on,desc";
static const userTypeDetails =
"http://localhost:9090/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

@ -9,6 +9,7 @@ import '../../feature/presentation/screens/admin/user_management/model/getAllUse
import '../../feature/presentation/screens/admin/user_management/model/select_assign_role_model/select_assign_role_model.dart';
import '../../feature/presentation/screens/admin/user_management/model/user_type_details_res_model.dart';
import '../../feature/presentation/screens/admin/user_management/model/user_type_res_model.dart';
import '../../feature/presentation/screens/transporter/model/grn_panding_res_model.dart';
import '../../feature/presentation/screens/transporter/model/view_freight_bill_res_model.dart';
import '../model/generate_bill_res_model.dart';
import '../model/generate_freight_model.dart';
@ -68,7 +69,7 @@ class PostRequests {
static Future<GetAllUserResModel?> getAllUser(
Map<String, String> requestBody,int page, int limit) async {
var apiResponse =
await RemoteService.postUser(requestBody, "${ApiUrls.getAllUser}$page&size=$limit&sort=last_updated_on,desc");
await RemoteService.postUser(requestBody, "${ApiUrls.getAllUser}$page&size=10$limit&sort=last_updated_on,desc");
if (apiResponse != null) {
return getAllUserResModelFromJson(apiResponse.response!);
@ -76,7 +77,17 @@ class PostRequests {
return null;
}
}
// static Future<GetAllUserResModel?> getAllUser(
// Map<String, String> requestBody) async {
// var apiResponse =
// await RemoteService.postUser(requestBody, ApiUrls.getAllUser);
//
// if (apiResponse != null) {
// return getAllUserResModelFromJson(apiResponse.response!);
// } else {
// return null;
// }
// }
static Future<EditUserResModel?> editUser(
Map<String, String> requestBody, String id) async {
var apiResponse =
@ -181,4 +192,14 @@ class PostRequests {
return null;
}
}
static Future<GrnPendingBillsResModel?> grnPending(
Map<String, String> requestBody) async {
var apiResponse = await RemoteService.postUser(
requestBody, ApiUrls.grnPendingDetails);
if (apiResponse != null) {
return grnPendingBillsResModelFromJson(apiResponse.response!);
} else {
return null;
}
}
}

View File

@ -20,7 +20,10 @@ class Validations {
return 'Please Enter Your Mobile Number';
} else if (enteredValue.length != 10) {
return "Please Enter a Valid Number";
} else {
} else if (!RegExp(r'^[0-9]+$').hasMatch(enteredValue)) {
return 'Please Enter a Valid Number (only digits allowed)';
}
else {
return null;
}
}

View File

@ -296,6 +296,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "2.4.1"
simple_gesture_detector:
dependency: transitive
description:
name: simple_gesture_detector
sha256: ba2cd5af24ff20a0b8d609cec3f40e5b0744d2a71804a2616ae086b9c19d19a3
url: "https://pub.dev"
source: hosted
version: "0.2.1"
sizer:
dependency: "direct main"
description:
@ -341,6 +349,30 @@ packages:
url: "https://pub.dev"
source: hosted
version: "1.3.0"
syncfusion_flutter_core:
dependency: transitive
description:
name: syncfusion_flutter_core
sha256: "213ada2c3b3555a73cb0eb1530d24d27dcf1a0a1555c0f00dd3e1486b01878ad"
url: "https://pub.dev"
source: hosted
version: "28.2.3"
syncfusion_flutter_datepicker:
dependency: "direct main"
description:
name: syncfusion_flutter_datepicker
sha256: "9d2694d618d081c9477402175ff027936f60ac053d0989ca02ee65b2e27a65c7"
url: "https://pub.dev"
source: hosted
version: "28.2.3"
table_calendar:
dependency: "direct main"
description:
name: table_calendar
sha256: "0c0c6219878b363a2d5f40c7afb159d845f253d061dc3c822aa0d5fe0f721982"
url: "https://pub.dev"
source: hosted
version: "3.2.0"
term_glyph:
dependency: transitive
description:

View File

@ -40,6 +40,8 @@ dependencies:
sizer: ^3.0.5
intl: ^0.20.1
vph_web_date_picker: ^0.0.6
table_calendar: ^3.2.0
syncfusion_flutter_datepicker: ^28.2.3
dev_dependencies: