validations changes

feature_dev_ankit
Pratibha Chaudhary 2025-02-03 11:41:10 +05:30
parent b8c648641f
commit 3cf903f44b
20 changed files with 1715 additions and 625 deletions

View File

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

View File

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

View File

@ -1,7 +1,6 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:get/get.dart'; import 'package:get/get.dart';
import 'package:intl/intl.dart'; import 'package:intl/intl.dart';
import 'package:shayog/components/common/common_button.dart';
import 'package:shayog/components/styles/textStyles.dart'; import 'package:shayog/components/styles/textStyles.dart';
import '../../../../../components/common/common_btn.dart'; import '../../../../../components/common/common_btn.dart';
import '../../../../../components/common/data_cell.dart'; import '../../../../../components/common/data_cell.dart';
@ -17,8 +16,8 @@ class ManageUser extends StatelessWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Column( return Column(
mainAxisAlignment: MainAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.end,
crossAxisAlignment: CrossAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.end,
children: [ children: [
Obx(() { Obx(() {
if (controller.userLoading.value) { if (controller.userLoading.value) {
@ -26,6 +25,8 @@ class ManageUser extends StatelessWidget {
} }
return Column( return Column(
mainAxisAlignment: MainAxisAlignment.end,
crossAxisAlignment: CrossAxisAlignment.end,
children: [ children: [
Scrollbar( Scrollbar(
thumbVisibility: true, thumbVisibility: true,
@ -62,7 +63,7 @@ class ManageUser extends StatelessWidget {
top: BorderSide(color: AppColors.clrGrey), top: BorderSide(color: AppColors.clrGrey),
), ),
columns: [ columns: [
dataColumn("Sr.No."), // dataColumn("Sr.No."),
dataColumn("User Name"), dataColumn("User Name"),
dataColumn("Email ID"), dataColumn("Email ID"),
dataColumn("Employee/\nTransporter Code"), dataColumn("Employee/\nTransporter Code"),
@ -85,15 +86,15 @@ class ManageUser extends StatelessWidget {
// controller.toggleSelection(index, value ?? false); // controller.toggleSelection(index, value ?? false);
// }, // },
cells: [ cells: [
editableCell(index, "" // editableCell(index, ""
"${index + 1}"), // "${index + 1}"),
editableCell(index, stoppage.userName ?? ""), editableCell(index, stoppage.userName ?? "-"),
editableCell(index, stoppage.userEmail ?? ""), editableCell(index, stoppage.userEmail ?? "-"),
editableCell( editableCell(
index, stoppage.userEmpTransCode ?? ""), index, stoppage.userEmpTransCode ?? "-"),
editableCell(index, stoppage.userMobile ?? ""), editableCell(index, stoppage.userMobile ?? "-"),
editableCell( editableCell(
index, stoppage.usertypeName ?? ""), index, stoppage.usertypeName ?? "-"),
editableCell( editableCell(
index, stoppage.createdBy.toString()), index, stoppage.createdBy.toString()),
editableCell( editableCell(
@ -109,6 +110,7 @@ class ManageUser extends StatelessWidget {
DateTime.parse( DateTime.parse(
'${stoppage.lastUpdatedOn}'))), '${stoppage.lastUpdatedOn}'))),
editableCell(index, stoppage.status.toString()), editableCell(index, stoppage.status.toString()),
DataCell(CommonBtn( DataCell(CommonBtn(
style: 8.txtSBoldWhite, style: 8.txtSBoldWhite,
margin: EdgeInsets.symmetric(vertical: 6), margin: EdgeInsets.symmetric(vertical: 6),
@ -149,17 +151,18 @@ class ManageUser extends StatelessWidget {
CustomPagination(
currentPage: controller.currentPage.value,
totalPages: controller.totalPages.value,
onPageChanged: (int page) {
controller.onPageChanged(page);
},
),
], ],
); );
}), }),
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 { class EditUserResModel {
final int? status; final int? status;
final String? message; final String? message;
final Data? data; final EditUser? data;
final DateTime? timestamp; final DateTime? timestamp;
EditUserResModel({ EditUserResModel({
@ -23,7 +23,7 @@ class EditUserResModel {
EditUserResModel( EditUserResModel(
status: json["status"], status: json["status"],
message: json["message"], 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 timestamp: json["timestamp"] == null
? null ? null
: DateTime.parse(json["timestamp"]), : DateTime.parse(json["timestamp"]),
@ -37,20 +37,20 @@ class EditUserResModel {
}; };
} }
class Data { class EditUser {
final String? action; final String? action;
final String? employeeTransCode; final String? employeeTransCode;
final int? userId; final int? userId;
final String? email; final String? email;
Data({ EditUser({
this.action, this.action,
this.employeeTransCode, this.employeeTransCode,
this.userId, this.userId,
this.email, this.email,
}); });
factory Data.fromJson(Map<String, dynamic> json) => Data( factory EditUser.fromJson(Map<String, dynamic> json) => EditUser(
action: json["action"], action: json["action"],
employeeTransCode: json["employeeTransCode"], employeeTransCode: json["employeeTransCode"],
userId: json["userId"], userId: json["userId"],

View File

@ -9,84 +9,56 @@ GetAllUserResModel getAllUserResModelFromJson(String str) => GetAllUserResModel.
String getAllUserResModelToJson(GetAllUserResModel data) => json.encode(data.toJson()); String getAllUserResModelToJson(GetAllUserResModel data) => json.encode(data.toJson());
class GetAllUserResModel { class GetAllUserResModel {
final int? status; final List<List<AllUser>>? content;
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 Pageable? pageable; final Pageable? pageable;
final bool? last;
final int? totalElements; final int? totalElements;
final int? totalPages; final int? totalPages;
final bool? first; final bool? last;
final int? size; final int? size;
final int? number; final int? number;
final Sort? sort; final Sort? sort;
final bool? first;
final int? numberOfElements; final int? numberOfElements;
final bool? empty; final bool? empty;
UserData({ GetAllUserResModel({
this.content, this.content,
this.pageable, this.pageable,
this.last,
this.totalElements, this.totalElements,
this.totalPages, this.totalPages,
this.first, this.last,
this.size, this.size,
this.number, this.number,
this.sort, this.sort,
this.first,
this.numberOfElements, this.numberOfElements,
this.empty, this.empty,
}); });
factory UserData.fromJson(Map<String, dynamic> json) => UserData( factory GetAllUserResModel.fromJson(Map<String, dynamic> json) => GetAllUserResModel(
content: json["content"] == null ? [] : List<AllUser>.from(json["content"]!.map((x) => AllUser.fromJson(x))), 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"]), pageable: json["pageable"] == null ? null : Pageable.fromJson(json["pageable"]),
last: json["last"],
totalElements: json["totalElements"], totalElements: json["totalElements"],
totalPages: json["totalPages"], totalPages: json["totalPages"],
first: json["first"], last: json["last"],
size: json["size"], size: json["size"],
number: json["number"], number: json["number"],
sort: json["sort"] == null ? null : Sort.fromJson(json["sort"]), sort: json["sort"] == null ? null : Sort.fromJson(json["sort"]),
first: json["first"],
numberOfElements: json["numberOfElements"], numberOfElements: json["numberOfElements"],
empty: json["empty"], empty: json["empty"],
); );
Map<String, dynamic> toJson() => { 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(), "pageable": pageable?.toJson(),
"last": last,
"totalElements": totalElements, "totalElements": totalElements,
"totalPages": totalPages, "totalPages": totalPages,
"first": first, "last": last,
"size": size, "size": size,
"number": number, "number": number,
"sort": sort?.toJson(), "sort": sort?.toJson(),
"first": first,
"numberOfElements": numberOfElements, "numberOfElements": numberOfElements,
"empty": empty, "empty": empty,
}; };
@ -108,7 +80,7 @@ class AllUser {
final int? createdBy; final int? createdBy;
final DateTime? lastUpdatedOn; final DateTime? lastUpdatedOn;
final int? lastUpdatedBy; final int? lastUpdatedBy;
final bool isSelected; bool isSelected;
AllUser({ AllUser({
this.userId, this.userId,
@ -126,7 +98,7 @@ class AllUser {
this.createdBy, this.createdBy,
this.lastUpdatedOn, this.lastUpdatedOn,
this.lastUpdatedBy, this.lastUpdatedBy,
this.isSelected = false this.isSelected = false,
}); });
factory AllUser.fromJson(Map<String, dynamic> json) => AllUser( factory AllUser.fromJson(Map<String, dynamic> json) => AllUser(

View File

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

View File

@ -163,6 +163,7 @@ class UserType extends StatelessWidget {
dataColumn("Status"), dataColumn("Status"),
dataColumn("Action"), dataColumn("Action"),
], ],
rows: List<DataRow>.generate( rows: List<DataRow>.generate(
controller.userType.length, (index) { controller.userType.length, (index) {
final stoppage = controller.userType[index]; final stoppage = controller.userType[index];

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/plant_mapping_res_model.dart';
import '../../admin/user_management/model/user_type_details_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 '../../admin/user_management/model/user_type_res_model.dart';
import '../../transporter/widgets/freightbill_dialog.dart'; import '../../transporter/widgets/freightbill_dialog.dart';
class DashboardCtrl extends GetxController { class DashboardCtrl extends GetxController {
@ -33,7 +32,7 @@ class DashboardCtrl extends GetxController {
var selectedIndex = 0.obs; var selectedIndex = 0.obs;
var selectUserType = 0.obs; var selectUserType = 0.obs;
var selectedUser = 0.obs; var selectedUser = 0.obs;
var selectedValue = ''.obs;
var errorText = ''.obs; var errorText = ''.obs;
RxBool showRolesSection = false.obs; RxBool showRolesSection = false.obs;
@ -90,10 +89,10 @@ class DashboardCtrl extends GetxController {
//**************************Manage-User************************************ //**************************Manage-User************************************
RxInt currentPage = 1.obs; RxInt currentPage = 1.obs; // Current page being viewed
RxInt totalPages = 3.obs; RxInt totalPages = 1.obs; // Total number of pages from the API
RxList<AllUser> getAllUser = <AllUser>[].obs;
final int limit = 10; final int limit = 10;
var getAllUser = <AllUser>[].obs;
var userLoading = false.obs; var userLoading = false.obs;
getManageUser() async { getManageUser() async {
@ -110,7 +109,11 @@ class DashboardCtrl extends GetxController {
var response = await PostRequests.getAllUser(requestBody,currentPage.value,limit); var response = await PostRequests.getAllUser(requestBody,currentPage.value,limit);
if (response != null) { 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 { } finally {
userLoading.value = false; userLoading.value = false;
@ -136,7 +139,7 @@ class DashboardCtrl extends GetxController {
//********************************edit User****************************// //********************************edit User****************************//
var editLoading = false.obs; var editLoading = false.obs;
Rx<Data> editUserResModel = Data().obs; Rx<EditUser> editUserResModel = EditUser().obs;
editAllUser(String id) async { editAllUser(String id) async {
try { try {
@ -168,8 +171,9 @@ class DashboardCtrl extends GetxController {
//**************************Add Internal-User****************************** //**************************Add Internal-User******************************
var isLoading = false.obs; var isLoading = false.obs;
var status = ['A', 'I']; var status = ['Active', 'In-Active'];
var selectedStatus = 'Select Status'.obs; var selectedStatus = 'Select Status'.obs;
var selectedValue = 'Select User Type'.obs;
void createUser() { void createUser() {
if (selectedValue.value.isEmpty || if (selectedValue.value.isEmpty ||
selectedStatus.value.isEmpty || selectedStatus.value.isEmpty ||
@ -203,7 +207,7 @@ class DashboardCtrl extends GetxController {
"mobile": mobileCtrl.text, "mobile": mobileCtrl.text,
"employeeTransCode": employeeCodeCtrl.text, "employeeTransCode": employeeCodeCtrl.text,
"email": emailCtrl.text, "email": emailCtrl.text,
"status": selectedStatus.value, "status": selectedStatus.value == "Active" ? "A":"I",
"addedChannel": "F" "addedChannel": "F"
} }
]; ];

View File

@ -3,7 +3,6 @@ import 'package:get/get.dart';
import 'package:shayog/components/styles/app_strings.dart'; import 'package:shayog/components/styles/app_strings.dart';
import 'package:shayog/components/styles/textStyles.dart'; import 'package:shayog/components/styles/textStyles.dart';
import 'package:shayog/feature/presentation/screens/transporter/view/transport_view.dart'; import 'package:shayog/feature/presentation/screens/transporter/view/transport_view.dart';
import '../../../../components/styles/app_colors.dart'; import '../../../../components/styles/app_colors.dart';
import '../../widgets/text_view.dart'; import '../../widgets/text_view.dart';
import '../admin/configuration_management/configuration_screen.dart'; import '../admin/configuration_management/configuration_screen.dart';
@ -26,6 +25,7 @@ class _DashboardScreenState extends State<DashboardScreen> {
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Scaffold( return Scaffold(
appBar: AppBar( appBar: AppBar(
automaticallyImplyLeading: false,
backgroundColor: AppColors.secondaryClr, backgroundColor: AppColors.secondaryClr,
title: RichText( title: RichText(
textAlign: TextAlign.center, textAlign: TextAlign.center,

View File

@ -9,10 +9,10 @@ FreightBillsResModel freightBillsResModelFromJson(String str) => FreightBillsRes
String freightBillsResModelToJson(FreightBillsResModel data) => json.encode(data.toJson()); String freightBillsResModelToJson(FreightBillsResModel data) => json.encode(data.toJson());
class FreightBillsResModel { class FreightBillsResModel {
final List<String>? plant; final List<Plant>? plant;
final List<String>? prodect; final List<Prodect>? prodect;
final List<String>? fromLocation; final List<String>? fromLocation;
final List<dynamic>? freightBill; final List<String>? freightBill;
FreightBillsResModel({ FreightBillsResModel({
this.plant, this.plant,
@ -22,16 +22,58 @@ class FreightBillsResModel {
}); });
factory FreightBillsResModel.fromJson(Map<String, dynamic> json) => FreightBillsResModel( factory FreightBillsResModel.fromJson(Map<String, dynamic> json) => FreightBillsResModel(
plant: json["Plant"] == null ? [] : List<String>.from(json["Plant"]!.map((x) => x)), plant: json["Plant"] == null ? [] : List<Plant>.from(json["Plant"]!.map((x) => Plant.fromJson(x))),
prodect: json["prodect"] == null ? [] : List<String>.from(json["prodect"]!.map((x) => 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)), 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() => { Map<String, dynamic> toJson() => {
"Plant": plant == null ? [] : List<dynamic>.from(plant!.map((x) => x)), "Plant": plant == null ? [] : List<dynamic>.from(plant!.map((x) => x.toJson())),
"prodect": prodect == null ? [] : List<dynamic>.from(prodect!.map((x) => x)), "prodect": prodect == null ? [] : List<dynamic>.from(prodect!.map((x) => x.toJson())),
"fromLocation": fromLocation == null ? [] : List<dynamic>.from(fromLocation!.map((x) => x)), "fromLocation": fromLocation == null ? [] : List<dynamic>.from(fromLocation!.map((x) => x)),
"FreightBill": freightBill == null ? [] : List<dynamic>.from(freightBill!.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

@ -11,7 +11,6 @@ import '../../../../../../../components/common/common_btn.dart';
import '../../../../../../../components/common/custom_drop_down.dart'; import '../../../../../../../components/common/custom_drop_down.dart';
import '../../../../../../../components/common/data_cell.dart'; import '../../../../../../../components/common/data_cell.dart';
import '../../../../../../../components/styles/app_strings.dart'; import '../../../../../../../components/styles/app_strings.dart';
import '../../view_model/transport_controller.dart'; import '../../view_model/transport_controller.dart';
import '../../widgets/common_card.dart'; import '../../widgets/common_card.dart';
import '../../widgets/freightbill_dialog.dart'; import '../../widgets/freightbill_dialog.dart';
@ -42,14 +41,14 @@ class GenerateFrightBill extends StatelessWidget {
TextView(text: TextView(text:
"Plant"), "Plant"),
SizedBox(height: 8), SizedBox(height: 8),
CustomDropdown<dynamic>( CustomDropdown(
backClr: AppColors.clrD9, backClr: AppColors.clrD9,
borderClr: AppColors.clrGrey, borderClr: AppColors.clrGrey,
items: controller.plant, items: controller.plant,
itemLabel: (item) => item, itemLabel: (item) => "${item.plantCode}-${item.plantDesc}",
onSelected: (selected) { onSelected: (selected) {
if (selected != null) { if (selected != null) {
controller.selectPlant.value = selected; controller.selectPlant.value = selected.plantCode ?? "";
print( print(
"selectPlant${controller.selectPlant.value}"); "selectPlant${controller.selectPlant.value}");
} }
@ -68,10 +67,11 @@ class GenerateFrightBill extends StatelessWidget {
TextView(text:"Product Name"), TextView(text:"Product Name"),
SizedBox(height: 8), SizedBox(height: 8),
CustomDropdown<dynamic>( CustomDropdown<dynamic>(
width: 250,
backClr: AppColors.clrD9, backClr: AppColors.clrD9,
borderClr: AppColors.clrGrey, borderClr: AppColors.clrGrey,
items: controller.product, items: controller.product,
itemLabel: (item) => item, itemLabel: (item) => "${item.materialCode}-${item.materialDescription}",
onSelected: (selected) { onSelected: (selected) {
if (selected != null) { if (selected != null) {
controller.selectProduct.value = selected; controller.selectProduct.value = selected;
@ -137,6 +137,7 @@ class GenerateFrightBill extends StatelessWidget {
margin: EdgeInsets.only(top: 8), margin: EdgeInsets.only(top: 8),
height: 35, height: 35,
child: TextFormField( child: TextFormField(
key: controller.fromTextFieldKey, key: controller.fromTextFieldKey,
controller: controller.fromController, controller: controller.fromController,
onTap: () async { onTap: () async {
@ -159,6 +160,8 @@ class GenerateFrightBill extends StatelessWidget {
} }
}, },
decoration: InputDecoration( decoration: InputDecoration(
fillColor:AppColors.clrD9,
filled: true,
hintText: 'Select MRN Date Range', hintText: 'Select MRN Date Range',
hintStyle: TextStyle( hintStyle: TextStyle(
fontSize: 12, fontSize: 12,
@ -277,10 +280,12 @@ class GenerateFrightBill extends StatelessWidget {
TextView(text: AppStrings.viewGrnDetails, style: 14.txtBoldWhite), TextView(text: AppStrings.viewGrnDetails, style: 14.txtBoldWhite),
Spacer(), Spacer(),
CommonBtn( CommonBtn(
width: 150,
bkClr: AppColors.white, bkClr: AppColors.white,
borderClr: AppColors.primaryClr, borderClr: AppColors.primaryClr,
style: 14.txtBoldBlue, style: 12.txtBoldBlue,
text: AppStrings.save, text: "Generate Freight Bill",
// text: AppStrings.save,
clickAction: () { clickAction: () {
bool hasSelectedRows = controller.grnDetails bool hasSelectedRows = controller.grnDetails
.any((element) => element.isSelected); .any((element) => element.isSelected);
@ -365,7 +370,7 @@ class GenerateFrightBill extends StatelessWidget {
), ),
), ),
), ),
dataColumn(AppStrings.srNo), // dataColumn(AppStrings.srNo),
dataColumn(AppStrings.mrnNo), dataColumn(AppStrings.mrnNo),
dataColumn(AppStrings.plantNo), dataColumn(AppStrings.plantNo),
dataColumn(AppStrings.product), dataColumn(AppStrings.product),
@ -406,7 +411,7 @@ class GenerateFrightBill extends StatelessWidget {
), ),
), ),
), ),
editableCell(index, "0${index + 1}"), // editableCell(index, "0${index + 1}"),
editableCell(index, stoppage.grnNo ?? ""), editableCell(index, stoppage.grnNo ?? ""),
editableCell(index, stoppage.plantCode ?? ""), editableCell(index, stoppage.plantCode ?? ""),
editableCell(index, stoppage.materialCode ?? ""), editableCell(index, stoppage.materialCode ?? ""),

View File

@ -1,10 +1,19 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:get/get.dart'; import 'package:get/get.dart';
import 'package:intl/intl.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: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/common/data_cell.dart';
import '../../../../../../../components/styles/app_colors.dart'; import '../../../../../../../components/styles/app_colors.dart';
import '../../../../../../../components/styles/app_strings.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 { class PendingGeneration extends StatelessWidget {
PendingGeneration({super.key}); PendingGeneration({super.key});
@ -15,161 +24,451 @@ class PendingGeneration extends StatelessWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Obx(() { return Column(
if (controller.freightViewLoader.value) { children: [
return Center( Container(
child: CircularProgressIndicator( padding: EdgeInsets.all(16),
color: AppColors.primaryClr, color: AppColors.clrF2,
), child: Column(
); mainAxisAlignment: MainAxisAlignment.start,
} else { crossAxisAlignment: CrossAxisAlignment.start,
return Column( children: [
children: [ Row(
Obx(() { children: [
if (controller.isLoading.value) { Expanded(
return Center(child: CircularProgressIndicator()); child: Column(
} mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
if (controller.errorMessage.isNotEmpty) { children: [
return Center(child: Text(controller.errorMessage.value)); TextView(text:
} "Plant"),
SizedBox(height: 8),
if (controller.grnDetails.isEmpty) { CustomDropdown(
return Center(child: Text('No data available.')); backClr: AppColors.clrD9,
} borderClr: AppColors.clrGrey,
return Scrollbar( items: controller.plant,
thumbVisibility: true, itemLabel: (item) => "${item.plantCode}-${item.plantDesc}",
controller: controller.verticalScrollController, onSelected: (selected) {
child: SingleChildScrollView( if (selected != null) {
controller: controller.verticalScrollController, controller.selectPlant.value = selected.plantCode ?? "";
child: Scrollbar( print(
thumbVisibility: true, "selectPlant${controller.selectPlant.value}");
controller: controller.horizontalScrollController, }
child: SingleChildScrollView( },
scrollDirection: Axis.horizontal, hintText: "Select Plant",
controller: controller.horizontalScrollController,
child: Container(
decoration: BoxDecoration(
border: Border.all(
color: Colors.grey.shade400,
width: 1.0,
),
), ),
child: DataTable( ],
dataRowHeight: 28, ),
headingRowHeight: 40, ),
headingRowColor: SizedBox(width: 16),
WidgetStateProperty.all(AppColors.clrF2), Expanded(
border: TableBorder( child: Column(
horizontalInside: mainAxisAlignment: MainAxisAlignment.start,
BorderSide(color: AppColors.clrGrey), crossAxisAlignment: CrossAxisAlignment.start,
verticalInside: children: [
BorderSide(color: AppColors.clrGrey), TextView(text:"Product Name"),
bottom: BorderSide(color: AppColors.clrGrey), SizedBox(height: 8),
left: BorderSide(color: AppColors.clrGrey), CustomDropdown<dynamic>(
right: BorderSide(color: AppColors.clrGrey), width: 250,
top: BorderSide(color: AppColors.clrGrey), backClr: AppColors.clrD9,
), borderClr: AppColors.clrGrey,
columns: [ items: controller.product,
DataColumn( itemLabel: (item) => "${item.materialCode}-${item.materialDescription}",
label: Transform.scale( onSelected: (selected) {
scale: 0.80, if (selected != null) {
child: Checkbox( controller.selectProduct.value = selected;
value: controller.selectAllField.value, print(
onChanged: (value) { "selectPlant${controller.selectProduct.value}");
controller.selectAll(value ?? false); }
}, },
activeColor: AppColors.primaryClr, hintText: "Select Product Name",
checkColor: Colors.white, ),
materialTapTargetSize: ],
MaterialTapTargetSize.shrinkWrap, ),
),
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), SizedBox(width: 16),
dataColumn(AppStrings.vehicleNo), Expanded(
dataColumn(AppStrings.transporterLrNo), child: Column(
dataColumn(AppStrings.transporterLrNoDate), mainAxisAlignment: MainAxisAlignment.start,
dataColumn(AppStrings.dispQty), crossAxisAlignment: CrossAxisAlignment.start,
dataColumn(AppStrings.netQty), children: [
dataColumn(AppStrings.billingQty), TextView(text:"From Location"),
dataColumn(AppStrings.uom), SizedBox(height: 8),
dataColumn(AppStrings.freightRate), CustomDropdown<dynamic>(
dataColumn(AppStrings.freightAmount), backClr: AppColors.clrD9,
dataColumn(AppStrings.remark), borderClr: AppColors.clrGrey,
], items: controller.fromLocation,
rows: List<DataRow>.generate( itemLabel: (item) => item,
controller.grnDetails.length, (index) { onSelected: (selected) {
final stoppage = controller.grnDetails[index]; 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( clickAction: () {
selected: stoppage.isSelected, controller.postData();
cells: [ },
DataCell( ),
Transform.scale( ],
),
),
],
))
],
),
),
],
),
),
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, scale: 0.80,
child: Checkbox( child: Checkbox(
value: stoppage.isSelected, value: controller.selectAllField.value,
onChanged: (value) { onChanged: (value) {
controller.toggleSelection( controller.selectAll(value ?? false);
index, value ?? false);
}, },
activeColor: AppColors.primaryClr, activeColor: AppColors.primaryClr,
checkColor: Colors.white, checkColor: Colors.white,
materialTapTargetSize:
materialTapTargetSize: MaterialTapTargetSize MaterialTapTargetSize.shrinkWrap,
.shrinkWrap,
), ),
), ),
), ),
editableCell(index, "0${index + 1}"), // dataColumn(AppStrings.srNo),
editableCell(index, stoppage.plantCode ?? ""), dataColumn(AppStrings.plantName),
editableCell(index, stoppage.plantCode ?? ""), dataColumn(AppStrings.productName),
dataColumn(AppStrings.date),
editableCell( dataColumn(AppStrings.fromLocation),
index, dataColumn(AppStrings.vehicleNo),
DateFormat('yyyy-MM-dd').format( dataColumn(AppStrings.transporterLrNo),
stoppage.grnDate ?? DateTime.now())), dataColumn(AppStrings.transporterLrNoDate),
editableCell( dataColumn(AppStrings.dispQty),
index, stoppage.fromLocation ?? ""), dataColumn(AppStrings.netQty),
editableCell(index, stoppage.vehicleNo ?? ""), dataColumn(AppStrings.billingQty),
editableCell(index, stoppage.lrNo ?? ""), dataColumn(AppStrings.uom),
editableCell( dataColumn(AppStrings.freightRate),
index, dataColumn(AppStrings.freightAmount),
DateFormat('yyyy-MM-dd').format( dataColumn(AppStrings.remark),
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() ?? ""),
], ],
); 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,200 +1,493 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:get/get.dart'; import 'package:get/get.dart';
import 'package:shayog/components/common/common_btn.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: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/common/data_cell.dart';
import '../../../../../../../components/styles/app_colors.dart'; import '../../../../../../../components/styles/app_colors.dart';
import '../../../../../../../components/styles/app_strings.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/custom_pagination.dart';
import '../../../../widgets/text_view.dart';
import '../../view_model/transport_controller.dart'; import '../../view_model/transport_controller.dart';
import '../../widgets/common_card.dart';
import '../../widgets/freightbill_dialog.dart';
class ViewFreightBill extends StatelessWidget { class ViewFreightBill extends StatelessWidget {
ViewFreightBill({super.key}); ViewFreightBill({super.key});
final ScrollController horizontalScrollController = ScrollController(); final ScrollController horizontalScrollController = ScrollController();
final ScrollController verticalScrollController = ScrollController(); final ScrollController verticalScrollController = ScrollController();
final ctrl = Get.put(TransportController()); final controller = Get.put(TransportController());
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Obx(() { return Column(
if (ctrl.freightViewLoader.value) { children: [
return Center( Container(
child: CircularProgressIndicator( padding: EdgeInsets.all(16),
color: AppColors.primaryClr, color: AppColors.clrF2,
), child: Column(
); mainAxisAlignment: MainAxisAlignment.start,
} else { crossAxisAlignment: CrossAxisAlignment.start,
return Column( children: [
children: [ Row(
Scrollbar( children: [
thumbVisibility: true, Expanded(
controller: verticalScrollController, child: Column(
child: SingleChildScrollView( mainAxisAlignment: MainAxisAlignment.start,
controller: verticalScrollController, crossAxisAlignment: CrossAxisAlignment.start,
child: Scrollbar( children: [
thumbVisibility: true, TextView(text: "Plant"),
controller: horizontalScrollController, SizedBox(height: 8),
child: SingleChildScrollView( CustomDropdown(
scrollDirection: Axis.horizontal, backClr: AppColors.clrD9,
controller: horizontalScrollController, borderClr: AppColors.clrGrey,
child: Container( items: controller.plant,
decoration: BoxDecoration( itemLabel: (item) =>
border: Border.all( "${item.plantCode}-${item.plantDesc}",
color: Colors.grey.shade400, onSelected: (selected) {
width: 1.0, if (selected != null) {
controller.selectPlant.value =
selected.plantCode ?? "";
print(
"selectPlant${controller.selectPlant.value}");
}
},
hintText: "Select Plant",
), ),
), ],
child: DataTable( ),
dataRowHeight: 28, ),
headingRowHeight: 38, SizedBox(width: 16),
headingRowColor: Expanded(
WidgetStateProperty.all(AppColors.clrF2), 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( if (pickedDate != null) {
horizontalInside: controller.fromSelectedDate = pickedDate;
BorderSide(color: AppColors.clrGrey), String formattedDate =
verticalInside: BorderSide(color: AppColors.clrGrey), controller.getFormattedDate(pickedDate);
bottom: BorderSide(color: AppColors.clrGrey), controller.fromController.text =
left: BorderSide(color: AppColors.clrGrey), formattedDate;
right: BorderSide(color: AppColors.clrGrey), controller.dateCheck.value = true;
top: BorderSide(color: AppColors.clrGrey), }
), },
columns: [ decoration: InputDecoration(
fillColor: AppColors.clrD9,
dataColumn(AppStrings.srNo), filled: true,
dataColumn(AppStrings.plant), hintText: 'Select MRN Date Range',
dataColumn( hintStyle: TextStyle(
AppStrings.productName, fontSize: 12,
onSort: (_, __) => ctrl.changeSort( overflow: TextOverflow.ellipsis),
AppStrings.productName.toLowerCase()), 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]; SizedBox(width: 16),
Expanded(
return DataRow( child: Column(
cells: [ mainAxisAlignment: MainAxisAlignment.start,
editableCell(index, "0${index + 1}"), crossAxisAlignment: CrossAxisAlignment.start,
editableCell(index, "${freightBill.plantCode}"), children: [
editableCell(index, "${freightBill.status}"), TextView(text: "From Location"),
editableCell( SizedBox(height: 8),
index, CustomDropdown<dynamic>(
"${freightBill.freightbillId}", backClr: AppColors.clrD9,
isLink: true, borderClr: AppColors.clrGrey,
onTap: () { items: controller.fromLocation,
showFreightBillDetailsDialog( itemLabel: (item) => item,
context, freightBill); 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}"),
],
);
}),
),
),
), ),
), ),
), ),
), ),
), CustomPagination(
), currentPage: controller.currentPage.value,
CustomPagination( totalPages: controller.totalPages.value,
currentPage: ctrl.currentPage.value, onPageChanged: (int page) {
totalPages: ctrl.totalPages.value, controller.onPageChanged(page);
onPageChanged: (int page) { },
ctrl.onPageChanged(page); ),
}, ],
), );
}
}),
], ],
); );
}
});
} }
void showFreightBillDetailsDialog( void showFreightBillDetailsDialog(
@ -259,7 +552,7 @@ class ViewFreightBill extends StatelessWidget {
dataColumn(AppStrings.mrnNo), dataColumn(AppStrings.mrnNo),
dataColumn( dataColumn(
AppStrings.plantName, AppStrings.plantName,
onSort: (_, __) => ctrl.changeSort( onSort: (_, __) => controller.changeSort(
AppStrings.productName.toLowerCase()), AppStrings.productName.toLowerCase()),
), ),
dataColumn(AppStrings.product), dataColumn(AppStrings.product),
@ -276,8 +569,9 @@ class ViewFreightBill extends StatelessWidget {
dataColumn(AppStrings.freightAmount), dataColumn(AppStrings.freightAmount),
], ],
rows: List<DataRow>.generate( rows: List<DataRow>.generate(
ctrl.freightBillData.length, (index) { controller.freightBillData.length, (index) {
final freightBill = ctrl.freightBillData[index]; final freightBill =
controller.freightBillData[index];
return DataRow( return DataRow(
cells: [ cells: [
editableCell(index, "0${index + 1}"), editableCell(index, "0${index + 1}"),

View File

@ -268,94 +268,91 @@ class _TransportViewState extends State<TransportView> {
)), )),
], ],
), ),
Padding( SizedBox(height: 12),
padding: const EdgeInsets.only( Row(
top: 16.0, left: 8, right: 8), children: [
child: Row( Expanded(
children: [
Expanded(
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment:
CrossAxisAlignment.start,
children: [
TextView(
text: "Plant",
),
SizedBox(height: 8),
CustomDropdown(
backClr: AppColors.clrD9,
borderClr: AppColors.clrGrey,
items: ctrl.plantList,
itemLabel: (item) => item,
onSelected: (selected) {
if (selected != null) {
ctrl.selectedPlant.value =
selected;
}
},
hintText: 'Select Product'),
],
)),
SizedBox(width: 16),
Expanded(
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment:
CrossAxisAlignment.start,
children: [
TextView(
text: "Transaction Type",
),
SizedBox(height: 8),
CustomDropdown(
backClr: AppColors.clrD9,
borderClr: AppColors.clrGrey,
items: ctrl.plantList,
itemLabel: (item) => item,
onSelected: (selected) {
if (selected != null) {
ctrl.selectedPlant.value =
selected;
}
},
hintText: 'Select Product'),
],
)),
SizedBox(width: 16),
Expanded(
child: Column( child: Column(
children: [ mainAxisAlignment: MainAxisAlignment.start,
TextView( crossAxisAlignment:
text: "", CrossAxisAlignment.start,
), children: [
SizedBox(height: 8), TextView(
Row( text: "Plant",
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.txtBoldWhite,
clickAction: () {
ctrl.isSelected.value = false;
},
),
],
),
],
), ),
SizedBox(height: 8),
CustomDropdown(
backClr: AppColors.clrD9,
borderClr: AppColors.clrGrey,
items: ctrl.plantList,
itemLabel: (item) => item,
onSelected: (selected) {
if (selected != null) {
ctrl.selectedPlant.value =
selected;
}
},
hintText: 'Select Product'),
],
)),
SizedBox(width: 16),
Expanded(
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment:
CrossAxisAlignment.start,
children: [
TextView(
text: "Transaction Type",
),
SizedBox(height: 8),
CustomDropdown(
backClr: AppColors.clrD9,
borderClr: AppColors.clrGrey,
items: ctrl.plantList,
itemLabel: (item) => item,
onSelected: (selected) {
if (selected != null) {
ctrl.selectedPlant.value =
selected;
}
},
hintText: 'Select Product'),
],
)),
SizedBox(width: 16),
Expanded(
child: Column(
children: [
TextView(
text: "",
),
SizedBox(height: 8),
Row(
mainAxisAlignment:
MainAxisAlignment.end,
children: [
CommonBtn(
bkClr: Colors.white,
text: AppStrings.cancel,
clickAction: () {
ctrl.isSelected.value = false;
},
),
SizedBox(width: 16),
CommonBtn(
text: AppStrings.submit,
style: 14.txtSBoldWhite,
clickAction: () {
ctrl.isSelected.value = false;
},
),
],
),
],
), ),
], ),
), ],
), ),
], ],
), ),

View File

@ -1,15 +1,14 @@
import 'package:flutter/cupertino.dart'; import 'package:flutter/cupertino.dart';
import 'package:get/get.dart'; import 'package:get/get.dart';
import 'package:intl/intl.dart';
import 'package:shayog/components/styles/app_images.dart'; import 'package:shayog/components/styles/app_images.dart';
import 'package:shayog/services/network/get_requests.dart'; import 'package:shayog/services/network/get_requests.dart';
import '../../../../../../components/common/common_model.dart'; import '../../../../../../components/common/common_model.dart';
import '../../../../../../components/styles/app_strings.dart'; import '../../../../../../components/styles/app_strings.dart';
import '../../../../../../services/model/generate_freight_model.dart'; import '../../../../../../services/model/generate_freight_model.dart';
import '../../../../../../services/network/post_request.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'; import '../model/view_freight_bill_res_model.dart';
class TransportController extends GetxController { class TransportController extends GetxController {
@ -17,14 +16,14 @@ class TransportController extends GetxController {
final ScrollController verticalScrollController = ScrollController(); final ScrollController verticalScrollController = ScrollController();
var selectedIndex = 0.obs; var selectedIndex = 0.obs;
var selectedUser = 0.obs; var selectedUser = 0.obs;
var selectPlant = ''.obs; RxString selectPlant = ''.obs;
var selectProduct = ''.obs; var selectProduct = ''.obs;
var selectLocation = ''.obs; var selectLocation = ''.obs;
var selectTransactionType = ''.obs; var selectTransactionType = ''.obs;
var selectedItem = false.obs; var selectedItem = false.obs;
var grnDetails = <Content>[].obs; var grnDetails = <Content>[].obs;
var product = [].obs; var product = <Prodect>[].obs;
var plant = [].obs; var plant = <Plant>[].obs;
var freightBill = [].obs; var freightBill = [].obs;
var fromLocation = [].obs; var fromLocation = [].obs;
var grnList = [].obs; var grnList = [].obs;
@ -47,6 +46,8 @@ class TransportController extends GetxController {
void onInit() { void onInit() {
getFreightBills(); getFreightBills();
viewFreightView(); viewFreightView();
grnPending();
super.onInit(); super.onInit();
} }
@ -72,10 +73,11 @@ class TransportController extends GetxController {
CommonModel(title: AppStrings.pendingGeneration), CommonModel(title: AppStrings.pendingGeneration),
].obs; ].obs;
var isLoading = true.obs; var isLoading = false.obs;
var grnListLoader = true.obs; var grnListLoader = false.obs;
var freightViewLoader = true.obs; var freightViewLoader = false.obs;
var generateBill = true.obs; var generateBill = false.obs;
var grnPendingLoader = false.obs;
var errorMessage = ''.obs; var errorMessage = ''.obs;
postData() async { postData() async {
@ -303,4 +305,38 @@ class TransportController extends GetxController {
} }
// 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

@ -1,7 +1,6 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:shayog/components/styles/textStyles.dart'; import 'package:shayog/components/styles/textStyles.dart';
import 'dart:math' as math; import 'dart:math' as math;
import '../../../components/styles/app_colors.dart'; import '../../../components/styles/app_colors.dart';
class CustomPagination extends StatelessWidget { class CustomPagination extends StatelessWidget {
@ -19,27 +18,28 @@ class CustomPagination extends StatelessWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Container( return Container(
padding: const EdgeInsets.symmetric(vertical: 8.0), padding: const EdgeInsets.symmetric(vertical: 8.0),
decoration: BoxDecoration( decoration: BoxDecoration(
color: Colors.grey[200], //color: Colors.grey[200],
border: Border( border: Border(
top: BorderSide(color: Colors.grey[300]!), top: BorderSide(color: Colors.grey[300]!),
), ),
), ),
child: Row( child: Row(
mainAxisAlignment: MainAxisAlignment.end, mainAxisAlignment: MainAxisAlignment.end, // Center the pagination
children: [ children: [
IconButton( IconButton(
icon: const Icon(Icons.chevron_left), icon: const Icon(Icons.chevron_left),
onPressed: onPressed:
currentPage > 1 ? () => onPageChanged(currentPage - 1) : null, currentPage > 1 ? () => onPageChanged(currentPage - 1) : null,
), ),
_buildPageButton(1), _buildPageButton(1),
if (currentPage > 3) if (currentPage > 3)
const Text('...', style: TextStyle(fontSize: 20)), const Text('...', style: TextStyle(fontSize: 20)),
for (int i = math.max(2, currentPage - 1); for (int i = math.max(2, currentPage - 1);
i <= math.min(totalPages - 1, currentPage + 1); i <= math.min(totalPages - 1, currentPage + 1);
i++) i++)
_buildPageButton(i), _buildPageButton(i),
if (currentPage < totalPages - 2) if (currentPage < totalPages - 2)
const Text('...', style: TextStyle(fontSize: 20)), const Text('...', style: TextStyle(fontSize: 20)),
@ -80,3 +80,4 @@ class CustomPagination extends StatelessWidget {
); );
} }
} }

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'; import 'dart:convert';
@ -10,12 +258,12 @@ class GenerateFreightBills {
final List<List<Content>>? content; final List<List<Content>>? content;
final Pageable? pageable; final Pageable? pageable;
final bool? last; final bool? last;
final int? totalElements;
final int? totalPages; final int? totalPages;
final int? totalElements;
final bool? first;
final int? size; final int? size;
final int? number; final int? number;
final Sort? sort; final Sort? sort;
final bool? first;
final int? numberOfElements; final int? numberOfElements;
final bool? empty; final bool? empty;
@ -24,26 +272,27 @@ class GenerateFreightBills {
this.content, this.content,
this.pageable, this.pageable,
this.last, this.last,
this.totalElements,
this.totalPages, this.totalPages,
this.totalElements,
this.first,
this.size, this.size,
this.number, this.number,
this.sort, this.sort,
this.first,
this.numberOfElements, this.numberOfElements,
this.empty, this.empty,
}); });
factory GenerateFreightBills.fromJson(Map<String, dynamic> json) => GenerateFreightBills( 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))))), 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"]), pageable: json["pageable"] == null ? null : Pageable.fromJson(json["pageable"]),
last: json["last"], last: json["last"],
totalElements: json["totalElements"],
totalPages: json["totalPages"], totalPages: json["totalPages"],
totalElements: json["totalElements"],
first: json["first"],
size: json["size"], size: json["size"],
number: json["number"], number: json["number"],
sort: json["sort"] == null ? null : Sort.fromJson(json["sort"]), sort: json["sort"] == null ? null : Sort.fromJson(json["sort"]),
first: json["first"],
numberOfElements: json["numberOfElements"], numberOfElements: json["numberOfElements"],
empty: json["empty"], 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())))), "content": content == null ? [] : List<dynamic>.from(content!.map((x) => List<dynamic>.from(x.map((x) => x.toJson())))),
"pageable": pageable?.toJson(), "pageable": pageable?.toJson(),
"last": last, "last": last,
"totalElements": totalElements,
"totalPages": totalPages, "totalPages": totalPages,
"totalElements": totalElements,
"first": first,
"size": size, "size": size,
"number": number, "number": number,
"sort": sort?.toJson(), "sort": sort?.toJson(),
"first": first,
"numberOfElements": numberOfElements, "numberOfElements": numberOfElements,
"empty": empty, "empty": empty,
}; };
@ -68,13 +317,11 @@ class Content {
final String? grnNo; final String? grnNo;
final String? plantCode; final String? plantCode;
final String? materialCode; final String? materialCode;
final CodeValue? codeValue; final String? codeValue;
final String? transporterCode; final String? transporterCode;
final DateTime? grnDate; final DateTime? grnDate;
final String? fromLocation; final String? fromLocation;
final String? vehicleNo; final String? vehicleNo;
// final FromLocation? fromLocation;
// final VehicleNo? vehicleNo;
final String? lrNo; final String? lrNo;
final DateTime? lrDate; final DateTime? lrDate;
final double? dispQty; final double? dispQty;
@ -83,6 +330,7 @@ class Content {
final int? freightRate; final int? freightRate;
final double? shipmentCost; final double? shipmentCost;
final int? statusId; final int? statusId;
final dynamic remark;
bool isSelected; bool isSelected;
Content({ Content({
@ -103,6 +351,7 @@ class Content {
this.freightRate, this.freightRate,
this.shipmentCost, this.shipmentCost,
this.statusId, this.statusId,
this.remark,
this.isSelected = false, this.isSelected = false,
}); });
@ -111,13 +360,11 @@ class Content {
grnNo: json["grn_no"], grnNo: json["grn_no"],
plantCode: json["plant_code"], plantCode: json["plant_code"],
materialCode: json["material_code"], materialCode: json["material_code"],
codeValue: codeValueValues.map[json["code_value"]]!, codeValue: json["code_value"],
transporterCode: json["transporter_code"], transporterCode: json["transporter_code"],
grnDate: json["grn_date"] == null ? null : DateTime.parse(json["grn_date"]), grnDate: json["grn_date"] == null ? null : DateTime.parse(json["grn_date"]),
// fromLocation: fromLocationValues.map[json["from_location"]]!, fromLocation: json["from_location"],
// vehicleNo: vehicleNoValues.map[json["vehicle_no"]]!, vehicleNo: json["vehicle_no"],
fromLocation: json["from_location"]!,
vehicleNo: json["vehicle_no"]!,
lrNo: json["lr_no"], lrNo: json["lr_no"],
lrDate: json["lr_date"] == null ? null : DateTime.parse(json["lr_date"]), lrDate: json["lr_date"] == null ? null : DateTime.parse(json["lr_date"]),
dispQty: json["disp_qty"]?.toDouble(), dispQty: json["disp_qty"]?.toDouble(),
@ -126,6 +373,7 @@ class Content {
freightRate: json["freight_rate"], freightRate: json["freight_rate"],
shipmentCost: json["shipment_cost"]?.toDouble(), shipmentCost: json["shipment_cost"]?.toDouble(),
statusId: json["status_id"], statusId: json["status_id"],
remark: json["remark"],
); );
Map<String, dynamic> toJson() => { Map<String, dynamic> toJson() => {
@ -133,11 +381,11 @@ class Content {
"grn_no": grnNo, "grn_no": grnNo,
"plant_code": plantCode, "plant_code": plantCode,
"material_code": materialCode, "material_code": materialCode,
"code_value": codeValueValues.reverse[codeValue], "code_value": codeValue,
"transporter_code": transporterCode, "transporter_code": transporterCode,
"grn_date": "${grnDate!.year.toString().padLeft(4, '0')}-${grnDate!.month.toString().padLeft(2, '0')}-${grnDate!.day.toString().padLeft(2, '0')}", "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], "from_location": fromLocation,
"vehicle_no": vehicleNoValues.reverse[vehicleNo], "vehicle_no": vehicleNo,
"lr_no": lrNo, "lr_no": lrNo,
"lr_date": "${lrDate!.year.toString().padLeft(4, '0')}-${lrDate!.month.toString().padLeft(2, '0')}-${lrDate!.day.toString().padLeft(2, '0')}", "lr_date": "${lrDate!.year.toString().padLeft(4, '0')}-${lrDate!.month.toString().padLeft(2, '0')}-${lrDate!.day.toString().padLeft(2, '0')}",
"disp_qty": dispQty, "disp_qty": dispQty,
@ -146,46 +394,23 @@ class Content {
"freight_rate": freightRate, "freight_rate": freightRate,
"shipment_cost": shipmentCost, "shipment_cost": shipmentCost,
"status_id": statusId, "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 { class Pageable {
final Sort? sort; final Sort? sort;
final int? offset; final int? offset;
final int? pageSize;
final int? pageNumber; final int? pageNumber;
final int? pageSize;
final bool? unpaged; final bool? unpaged;
final bool? paged; final bool? paged;
Pageable({ Pageable({
this.sort, this.sort,
this.offset, this.offset,
this.pageSize,
this.pageNumber, this.pageNumber,
this.pageSize,
this.unpaged, this.unpaged,
this.paged, this.paged,
}); });
@ -193,8 +418,8 @@ class Pageable {
factory Pageable.fromJson(Map<String, dynamic> json) => Pageable( factory Pageable.fromJson(Map<String, dynamic> json) => Pageable(
sort: json["sort"] == null ? null : Sort.fromJson(json["sort"]), sort: json["sort"] == null ? null : Sort.fromJson(json["sort"]),
offset: json["offset"], offset: json["offset"],
pageSize: json["pageSize"],
pageNumber: json["pageNumber"], pageNumber: json["pageNumber"],
pageSize: json["pageSize"],
unpaged: json["unpaged"], unpaged: json["unpaged"],
paged: json["paged"], paged: json["paged"],
); );
@ -202,8 +427,8 @@ class Pageable {
Map<String, dynamic> toJson() => { Map<String, dynamic> toJson() => {
"sort": sort?.toJson(), "sort": sort?.toJson(),
"offset": offset, "offset": offset,
"pageSize": pageSize,
"pageNumber": pageNumber, "pageNumber": pageNumber,
"pageSize": pageSize,
"unpaged": unpaged, "unpaged": unpaged,
"paged": paged, "paged": paged,
}; };
@ -232,15 +457,3 @@ class Sort {
"unsorted": unsorted, "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 { class ApiUrls {
ApiUrls._(); ApiUrls._();
static const String baseUrl = "http://localhost:9098/"; static const String baseUrl = "http://localhost:9092/";
static const String baseUrlImage = static const String baseUrlImage =
"https://codingacademy.world/early_eyes/public/images/user/"; "https://codingacademy.world/early_eyes/public/images/user/";
static const addFreightBill = static const addFreightBill =
'bill/grndetails?page=0&size=20&sort=grn_date,desc'; 'bill/grndetails?page=0&size=20&sort=grn_date,desc';
static const getFreightBills = 'bill/dropdown'; static const getFreightBills = 'bill/dropdown';
static const generateFreightBill = static const generateFreightBill =
'http://localhost:9098/bill/addFreightBill'; 'http://localhost:9092/bill/addFreightBill';
static const createUser = 'http://localhost:9090/api/users/createUser'; static const createUser = 'http://localhost:9090/api/users/createUser';
static const editUser = static const editUser =
'http://localhost:9090/api/users/update?userEmpTransCode='; 'http://localhost:9090/api/users/update?userEmpTransCode=';
static const getAllUser = static const getAllUser =
'http://localhost:9090/api/users/userdetails?page='; 'http://localhost:9090/api/users/userdetails?page=';
static const viewFreightBill = static const viewFreightBill = 'http://localhost:9092/bill/freightbill?page';
'http://localhost:9098/bill/freightbill?page';
static const addUserType = static const addUserType =
'http://localhost:9090/api/user-types/createUserType'; 'http://localhost:9090/api/user-types/createUserType';
static const dropDownList = static const dropDownList =
@ -32,5 +32,7 @@ class ApiUrls {
static const selectAndAssignRole = static const selectAndAssignRole =
"http://localhost:9090/api/user-roles/assignRoles"; "http://localhost:9090/api/user-roles/assignRoles";
static const assignPlantRole = "http://localhost:9090/userplant/assignPlants"; 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/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_details_res_model.dart';
import '../../feature/presentation/screens/admin/user_management/model/user_type_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 '../../feature/presentation/screens/transporter/model/view_freight_bill_res_model.dart';
import '../model/generate_bill_res_model.dart'; import '../model/generate_bill_res_model.dart';
import '../model/generate_freight_model.dart'; import '../model/generate_freight_model.dart';
@ -76,7 +77,17 @@ class PostRequests {
return null; 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( static Future<EditUserResModel?> editUser(
Map<String, String> requestBody, String id) async { Map<String, String> requestBody, String id) async {
var apiResponse = var apiResponse =
@ -181,4 +192,14 @@ class PostRequests {
return null; 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;
}
}
} }