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

View File

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

View File

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

View File

@ -9,84 +9,56 @@ GetAllUserResModel getAllUserResModelFromJson(String str) => GetAllUserResModel.
String getAllUserResModelToJson(GetAllUserResModel data) => json.encode(data.toJson());
class GetAllUserResModel {
final int? status;
final String? message;
final UserData? data;
final DateTime? timestamp;
GetAllUserResModel({
this.status,
this.message,
this.data,
this.timestamp,
});
factory GetAllUserResModel.fromJson(Map<String, dynamic> json) => GetAllUserResModel(
status: json["status"],
message: json["message"],
data: json["data"] == null ? null : UserData.fromJson(json["data"]),
timestamp: json["timestamp"] == null ? null : DateTime.parse(json["timestamp"]),
);
Map<String, dynamic> toJson() => {
"status": status,
"message": message,
"data": data?.toJson(),
"timestamp": timestamp?.toIso8601String(),
};
}
class UserData {
final List<AllUser>? content;
final List<List<AllUser>>? content;
final Pageable? pageable;
final bool? last;
final int? totalElements;
final int? totalPages;
final bool? first;
final bool? last;
final int? size;
final int? number;
final Sort? sort;
final bool? first;
final int? numberOfElements;
final bool? empty;
UserData({
GetAllUserResModel({
this.content,
this.pageable,
this.last,
this.totalElements,
this.totalPages,
this.first,
this.last,
this.size,
this.number,
this.sort,
this.first,
this.numberOfElements,
this.empty,
});
factory UserData.fromJson(Map<String, dynamic> json) => UserData(
content: json["content"] == null ? [] : List<AllUser>.from(json["content"]!.map((x) => AllUser.fromJson(x))),
factory GetAllUserResModel.fromJson(Map<String, dynamic> json) => GetAllUserResModel(
content: json["content"] == null ? [] : List<List<AllUser>>.from(json["content"]!.map((x) => List<AllUser>.from(x.map((x) => AllUser.fromJson(x))))),
pageable: json["pageable"] == null ? null : Pageable.fromJson(json["pageable"]),
last: json["last"],
totalElements: json["totalElements"],
totalPages: json["totalPages"],
first: json["first"],
last: json["last"],
size: json["size"],
number: json["number"],
sort: json["sort"] == null ? null : Sort.fromJson(json["sort"]),
first: json["first"],
numberOfElements: json["numberOfElements"],
empty: json["empty"],
);
Map<String, dynamic> toJson() => {
"content": content == null ? [] : List<dynamic>.from(content!.map((x) => x.toJson())),
"content": content == null ? [] : List<dynamic>.from(content!.map((x) => List<dynamic>.from(x.map((x) => x.toJson())))),
"pageable": pageable?.toJson(),
"last": last,
"totalElements": totalElements,
"totalPages": totalPages,
"first": first,
"last": last,
"size": size,
"number": number,
"sort": sort?.toJson(),
"first": first,
"numberOfElements": numberOfElements,
"empty": empty,
};
@ -108,7 +80,7 @@ class AllUser {
final int? createdBy;
final DateTime? lastUpdatedOn;
final int? lastUpdatedBy;
final bool isSelected;
bool isSelected;
AllUser({
this.userId,
@ -126,7 +98,7 @@ class AllUser {
this.createdBy,
this.lastUpdatedOn,
this.lastUpdatedBy,
this.isSelected = false
this.isSelected = false,
});
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_strings.dart';
import '../../dashboard/controller/dashboard_ctrl.dart';
import 'add_internal_user.dart';
import 'internal_user/add_internal_user.dart';
import 'user_type.dart';
import 'internal_user_role_mapping.dart';
import 'manage_user.dart';
@ -49,7 +49,7 @@ class UserScreen extends StatelessWidget {
ctrl.getManageUser();
}
if (ctrl.selectedUser.value == 2) {
ctrl.clearPrefillData();
// ctrl.clearPrefillData();
ctrl.showRolesSection.value = false;
}
if (ctrl.selectedUser.value != 3) {
@ -72,7 +72,7 @@ class UserScreen extends StatelessWidget {
width: 3))),
child: Center(
child: TextView(
text: ctrl.userTabs[index].title ?? "",
text: ctrl.userTabs[index].title ?? "",
style: 12.txtBoldWhite,
// style: TextStyle(
// fontSize: 12,
@ -95,18 +95,17 @@ class UserScreen extends StatelessWidget {
Padding(
padding: const EdgeInsets.all(8.0),
child: TextView(
text: AppStrings.refresh,
text: AppStrings.refresh,
style: 12.txtBoldWhite,
),
),
Obx(
() => Visibility(
visible: ctrl.selectedUser.value == 0,
child: InkWell(
onTap:(){
ctrl.toggleContainer();
},
onTap: () {
ctrl.toggleContainer();
},
child: Image.asset(AppImages.filter,
height: 16, width: 16)),
),
@ -117,7 +116,7 @@ class UserScreen extends StatelessWidget {
child: Padding(
padding: const EdgeInsets.all(8.0),
child: TextView(
text: AppStrings.filter,
text: AppStrings.filter,
style: 12.txtBoldWhite,
),
),
@ -149,11 +148,8 @@ class UserScreen extends StatelessWidget {
),
SizedBox(height: 8),
InputField(
title: "Enter User Name",
controller: ctrl.userTypeCtrl
),
title: "Enter User Name",
controller: ctrl.nameCtrl),
// CustomDropdown(
// backClr: AppColors.clrD9,
@ -182,9 +178,7 @@ class UserScreen extends StatelessWidget {
SizedBox(height: 8),
InputField(
title: "Enter User Type",
controller: ctrl.userTypeCtrl
),
controller: ctrl.userTypeCtrl),
// CustomDropdown(
// backClr: AppColors.clrD9,
// borderClr: AppColors.clrGrey,
@ -212,8 +206,7 @@ class UserScreen extends StatelessWidget {
SizedBox(height: 8),
InputField(
title: "Enter Email Address",
controller: ctrl.emailCtrl
),
controller: ctrl.emailCtrl),
// CustomDropdown(
// backClr: AppColors.clrD9,
// borderClr: AppColors.clrGrey,
@ -231,8 +224,7 @@ class UserScreen extends StatelessWidget {
],
),
Padding(
padding: const EdgeInsets.only(
top: 16.0),
padding: const EdgeInsets.only(top: 16.0),
child: Row(
children: [
Expanded(
@ -248,8 +240,7 @@ class UserScreen extends StatelessWidget {
SizedBox(height: 8),
InputField(
title: "Enter Employee Code",
controller: ctrl.employeeCodeCtrl
),
controller: ctrl.employeeCodeCtrl),
// CustomDropdown(
// backClr: AppColors.clrD9,
// borderClr: AppColors.clrGrey,
@ -273,14 +264,12 @@ class UserScreen extends StatelessWidget {
CrossAxisAlignment.start,
children: [
TextView(
text:
"Status",
text: "Status",
),
SizedBox(height: 8),
InputField(
title: "Enter Status",
controller: ctrl.statusCtrl
),
controller: ctrl.statusCtrl),
// CustomDropdown(
// backClr: AppColors.clrD9,
// borderClr: AppColors.clrGrey,
@ -317,7 +306,8 @@ class UserScreen extends StatelessWidget {
SizedBox(width: 16),
CommonButton(
borderRadius: 4,
width: 100,height:30,
width: 100,
height: 30,
text: AppStrings.submit,
textStyle: 14.txtSBoldWhite,
clickAction: () {

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -1,200 +1,493 @@
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:shayog/components/common/common_btn.dart';
import 'package:shayog/components/styles/textStyles.dart';
import 'package:shayog/feature/presentation/screens/transporter/model/view_freight_bill_res_model.dart';
import 'package:sizer/sizer.dart';
import 'package:vph_web_date_picker/vph_web_date_picker.dart';
import '../../../../../../../components/common/data_cell.dart';
import '../../../../../../../components/styles/app_colors.dart';
import '../../../../../../../components/styles/app_strings.dart';
import '../../../../../../components/common/common_button.dart';
import '../../../../../../components/common/custom_drop_down.dart';
import '../../../../widgets/custom_pagination.dart';
import '../../../../widgets/text_view.dart';
import '../../view_model/transport_controller.dart';
import '../../widgets/common_card.dart';
import '../../widgets/freightbill_dialog.dart';
class ViewFreightBill extends StatelessWidget {
ViewFreightBill({super.key});
final ScrollController horizontalScrollController = ScrollController();
final ScrollController verticalScrollController = ScrollController();
final ctrl = Get.put(TransportController());
final controller = Get.put(TransportController());
@override
Widget build(BuildContext context) {
return Obx(() {
if (ctrl.freightViewLoader.value) {
return Center(
child: CircularProgressIndicator(
color: AppColors.primaryClr,
),
);
} else {
return Column(
children: [
Scrollbar(
thumbVisibility: true,
controller: verticalScrollController,
child: SingleChildScrollView(
controller: verticalScrollController,
child: Scrollbar(
thumbVisibility: true,
controller: horizontalScrollController,
child: SingleChildScrollView(
scrollDirection: Axis.horizontal,
controller: horizontalScrollController,
child: Container(
decoration: BoxDecoration(
border: Border.all(
color: Colors.grey.shade400,
width: 1.0,
return Column(
children: [
Container(
padding: EdgeInsets.all(16),
color: AppColors.clrF2,
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
children: [
Expanded(
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
TextView(text: "Plant"),
SizedBox(height: 8),
CustomDropdown(
backClr: AppColors.clrD9,
borderClr: AppColors.clrGrey,
items: controller.plant,
itemLabel: (item) =>
"${item.plantCode}-${item.plantDesc}",
onSelected: (selected) {
if (selected != null) {
controller.selectPlant.value =
selected.plantCode ?? "";
print(
"selectPlant${controller.selectPlant.value}");
}
},
hintText: "Select Plant",
),
),
child: DataTable(
dataRowHeight: 28,
headingRowHeight: 38,
headingRowColor:
WidgetStateProperty.all(AppColors.clrF2),
],
),
),
SizedBox(width: 16),
Expanded(
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
TextView(text: "Product Name"),
SizedBox(height: 8),
CustomDropdown<dynamic>(
width: 250,
backClr: AppColors.clrD9,
borderClr: AppColors.clrGrey,
items: controller.product,
itemLabel: (item) =>
"${item.materialCode}-${item.materialDescription}",
onSelected: (selected) {
if (selected != null) {
controller.selectProduct.value = selected;
print(
"selectPlant${controller.selectProduct.value}");
}
},
hintText: "Select Product Name",
),
],
),
),
SizedBox(width: 16),
Expanded(
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
TextView(text: "Transaction Type"),
SizedBox(height: 8),
CustomDropdown<String>(
backClr: AppColors.clrD9,
borderClr: AppColors.clrGrey,
items: controller.transactionType,
itemLabel: (item) => item,
onSelected: (selected) {
if (selected != null) {
controller.selectTransactionType.value = selected;
print(
"selectTransactionType${controller.selectTransactionType.value}");
}
},
hintText: "Select Transaction Type",
),
],
),
),
],
),
Padding(
padding: const EdgeInsets.only(top: 16.0, left: 0, right: 8),
child: Row(
children: [
Expanded(
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
TextView(text: "MRN Date Range"),
Container(
margin: EdgeInsets.only(top: 8),
height: 35,
child: TextFormField(
key: controller.fromTextFieldKey,
controller: controller.fromController,
onTap: () async {
final pickedDate = await showWebDatePicker(
width: 20.w,
context: controller
.fromTextFieldKey.currentContext!,
initialDate: controller.fromSelectedDate,
firstDate: DateTime(2000),
lastDate: DateTime.now(),
);
border: TableBorder(
horizontalInside:
BorderSide(color: AppColors.clrGrey),
verticalInside: BorderSide(color: AppColors.clrGrey),
bottom: BorderSide(color: AppColors.clrGrey),
left: BorderSide(color: AppColors.clrGrey),
right: BorderSide(color: AppColors.clrGrey),
top: BorderSide(color: AppColors.clrGrey),
),
columns: [
dataColumn(AppStrings.srNo),
dataColumn(AppStrings.plant),
dataColumn(
AppStrings.productName,
onSort: (_, __) => ctrl.changeSort(
AppStrings.productName.toLowerCase()),
if (pickedDate != null) {
controller.fromSelectedDate = pickedDate;
String formattedDate =
controller.getFormattedDate(pickedDate);
controller.fromController.text =
formattedDate;
controller.dateCheck.value = true;
}
},
decoration: InputDecoration(
fillColor: AppColors.clrD9,
filled: true,
hintText: 'Select MRN Date Range',
hintStyle: TextStyle(
fontSize: 12,
overflow: TextOverflow.ellipsis),
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(2.0),
borderSide:
BorderSide(color: AppColors.black),
),
enabledBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(2.0),
borderSide:
BorderSide(color: AppColors.clrGrey),
),
focusedBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(2.0),
borderSide:
BorderSide(color: AppColors.clrGrey),
),
disabledBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(2.0),
borderSide:
BorderSide(color: AppColors.clrGrey),
),
suffixIcon: controller.dateCheck.value
? InkWell(
onTap: () {
controller.dateCheck.value = false;
controller.fromController.clear();
controller.fromSelectedDate =
DateTime.now();
},
child: Icon(Icons.close, size: 1.2.w),
)
: null,
contentPadding: const EdgeInsets.symmetric(
horizontal: 12.0, vertical: 0.0),
),
),
),
dataColumn(AppStrings.freightBillNo),
dataColumn(AppStrings.freightBillDate),
dataColumn(AppStrings.freightInvoice),
dataColumn(AppStrings.freightInvoiceDate),
dataColumn(AppStrings.billingQty),
dataColumn(AppStrings.uom),
dataColumn(AppStrings.freightAmount),
dataColumn(AppStrings.cGST),
dataColumn(AppStrings.sGST),
dataColumn(AppStrings.iGST),
dataColumn(AppStrings.totalGst),
dataColumn(AppStrings.totalInvoiceAmt),
dataColumn(AppStrings.cCN),
dataColumn(AppStrings.cCNDate),
dataColumn(AppStrings.miroStatus),
dataColumn(AppStrings.gstHold),
dataColumn(AppStrings.gstRelease),
dataColumn(AppStrings.utrNo),
dataColumn(AppStrings.utrDate),
dataColumn(AppStrings.amount),
dataColumn("${AppStrings.utrNo} 1"),
dataColumn(AppStrings.utrDate),
dataColumn("${AppStrings.amount} 1"),
dataColumn("${AppStrings.utrNo} 2"),
dataColumn(AppStrings.utrDate),
dataColumn("${AppStrings.amount} 2"),
dataColumn("${AppStrings.utrNo} 3"),
dataColumn(AppStrings.utrDate),
dataColumn("${AppStrings.amount} 3"),
dataColumn("${AppStrings.utrNo} 4"),
dataColumn(AppStrings.utrDate),
dataColumn("${AppStrings.amount} 4"),
dataColumn("${AppStrings.utrNo} 5"),
dataColumn(AppStrings.utrDate),
dataColumn("${AppStrings.amount} 5"),
],
rows: List<DataRow>.generate(
ctrl.freightBillData.length, (index) {
final freightBill = ctrl.freightBillData[index];
return DataRow(
cells: [
editableCell(index, "0${index + 1}"),
editableCell(index, "${freightBill.plantCode}"),
editableCell(index, "${freightBill.status}"),
editableCell(
index,
"${freightBill.freightbillId}",
isLink: true,
onTap: () {
showFreightBillDetailsDialog(
context, freightBill);
),
),
SizedBox(width: 16),
Expanded(
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
TextView(text: "From Location"),
SizedBox(height: 8),
CustomDropdown<dynamic>(
backClr: AppColors.clrD9,
borderClr: AppColors.clrGrey,
items: controller.fromLocation,
itemLabel: (item) => item,
onSelected: (selected) {
if (selected != null) {
controller.selectLocation.value = selected;
}
},
hintText: "Select From Location",
),
],
),
),
SizedBox(
width: 16,
),
Expanded(
//flex: 2,
child: Column(
children: [
TextView(
text: "",
),
Padding(
padding: const EdgeInsets.only(top: 8.0),
child: Row(
mainAxisAlignment: MainAxisAlignment.end,
children: [
CommonBtn(
bkClr: Colors.white,
text: AppStrings.cancel,
clickAction: () {},
),
SizedBox(width: 16),
CommonButton(
borderRadius: 4,
height: 30,
width: 100,
text: AppStrings.submit,
clickAction: () {
controller.postData();
},
),
editableCell(index, "${freightBill.utr1Date}"),
editableCell(
index, "${freightBill.trasnporterInvoiceNo}"),
editableCell(index,
"${freightBill.trasnporterInvoiceNoDate}"),
editableCell(index, "${freightBill.billingQty}"),
editableCell(index, "${freightBill.uom}"),
editableCell(
index, "${freightBill.freightAmount}"),
editableCell(index, "${freightBill.cgst}"),
editableCell(index, "${freightBill.sgst}"),
editableCell(index, "${freightBill.igst}"),
editableCell(index, "${freightBill.totalGst}"),
editableCell(index, "${freightBill.totalGst}"),
editableCell(
index, "${freightBill.freightAmount}"),
editableCell(index,
"${freightBill.trasnporterInvoiceNoDate}"),
editableCell(index, "${freightBill.status}"),
editableCell(index, "${freightBill.totalGst}"),
editableCell(index,
"${freightBill.trasnporterInvoiceNoDate}"),
editableCell(index, "${freightBill.utr5No}"),
editableCell(index, "${freightBill.utr1Date}"),
editableCell(
index, "${freightBill.freightAmount}"),
editableCell(index, "${freightBill.utr1No}"),
editableCell(index, "${freightBill.utr1Date}"),
editableCell(
index, "${freightBill.utr1PaymentAmount}"),
editableCell(index, "${freightBill.utr2No}"),
editableCell(index, "${freightBill.utr2Date}"),
editableCell(
index, "${freightBill.utr2PaymentAmount}"),
editableCell(index, "${freightBill.utr3No}"),
editableCell(index, "${freightBill.utr3Date}"),
editableCell(
index, "${freightBill.utr3PaymentAmount}"),
editableCell(index, "${freightBill.utr4No}"),
editableCell(index, "${freightBill.utr4Date}"),
editableCell(
index, "${freightBill.utr4PaymentAmount}"),
editableCell(index, "${freightBill.utr5No}"),
editableCell(index, "${freightBill.utr5Date}"),
editableCell(
index, "${freightBill.utr5PaymentAmount}"),
],
);
}),
),
),
],
))
],
),
),
],
),
),
Container(
padding: EdgeInsets.symmetric(horizontal: 10),
margin: EdgeInsets.only(top: 16),
height: 45,
color: AppColors.primaryClr,
child: Row(
children: [
TextView(text: AppStrings.viewGrnDetails, style: 14.txtBoldWhite),
Spacer(),
CommonBtn(
width: 150,
bkClr: AppColors.white,
borderClr: AppColors.primaryClr,
style: 12.txtBoldBlue,
text: "Generate Freight Bill",
clickAction: () {
bool hasSelectedRows = controller.grnDetails
.any((element) => element.isSelected);
if (!hasSelectedRows) {
showPopup(
context: context,
onClick: () {
Get.back();
});
} else {
CommonAlertDialog.showDialog(
message: "Are you sure want to\nsave this?",
positiveText: "Save",
negativeText: "Cancel",
positiveBtCallback: () {
Get.back();
controller.addFreightBill();
showFreightBill(context);
},
negativeBtCallback: () {});
}
}),
],
),
),
Obx(() {
if (controller.freightViewLoader.value) {
return Center(
child: CircularProgressIndicator(
color: AppColors.primaryClr,
),
);
} else {
return Column(
children: [
Scrollbar(
thumbVisibility: true,
controller: verticalScrollController,
child: SingleChildScrollView(
controller: verticalScrollController,
child: Scrollbar(
thumbVisibility: true,
controller: horizontalScrollController,
child: SingleChildScrollView(
scrollDirection: Axis.horizontal,
controller: horizontalScrollController,
child: Container(
decoration: BoxDecoration(
border: Border.all(
color: Colors.grey.shade400,
width: 1.0,
),
),
child: DataTable(
dataRowHeight: 28,
headingRowHeight: 38,
headingRowColor:
WidgetStateProperty.all(AppColors.clrF2),
border: TableBorder(
horizontalInside:
BorderSide(color: AppColors.clrGrey),
verticalInside:
BorderSide(color: AppColors.clrGrey),
bottom: BorderSide(color: AppColors.clrGrey),
left: BorderSide(color: AppColors.clrGrey),
right: BorderSide(color: AppColors.clrGrey),
top: BorderSide(color: AppColors.clrGrey),
),
columns: [
dataColumn(AppStrings.srNo),
dataColumn(AppStrings.plant),
dataColumn(
AppStrings.productName,
onSort: (_, __) => controller.changeSort(
AppStrings.productName.toLowerCase()),
),
dataColumn(AppStrings.freightBillNo),
dataColumn(AppStrings.freightBillDate),
dataColumn(AppStrings.freightInvoice),
dataColumn(AppStrings.freightInvoiceDate),
dataColumn(AppStrings.billingQty),
dataColumn(AppStrings.uom),
dataColumn(AppStrings.freightAmount),
dataColumn(AppStrings.cGST),
dataColumn(AppStrings.sGST),
dataColumn(AppStrings.iGST),
dataColumn(AppStrings.totalGst),
dataColumn(AppStrings.totalInvoiceAmt),
dataColumn(AppStrings.cCN),
dataColumn(AppStrings.cCNDate),
dataColumn(AppStrings.miroStatus),
dataColumn(AppStrings.gstHold),
dataColumn(AppStrings.gstRelease),
dataColumn(AppStrings.utrNo),
dataColumn(AppStrings.utrDate),
dataColumn(AppStrings.amount),
dataColumn("${AppStrings.utrNo} 1"),
dataColumn(AppStrings.utrDate),
dataColumn("${AppStrings.amount} 1"),
dataColumn("${AppStrings.utrNo} 2"),
dataColumn(AppStrings.utrDate),
dataColumn("${AppStrings.amount} 2"),
dataColumn("${AppStrings.utrNo} 3"),
dataColumn(AppStrings.utrDate),
dataColumn("${AppStrings.amount} 3"),
dataColumn("${AppStrings.utrNo} 4"),
dataColumn(AppStrings.utrDate),
dataColumn("${AppStrings.amount} 4"),
dataColumn("${AppStrings.utrNo} 5"),
dataColumn(AppStrings.utrDate),
dataColumn("${AppStrings.amount} 5"),
],
rows: List<DataRow>.generate(
controller.freightBillData.length, (index) {
final freightBill =
controller.freightBillData[index];
return DataRow(
cells: [
editableCell(index, "0${index + 1}"),
editableCell(
index, "${freightBill.plantCode}"),
editableCell(index, "${freightBill.status}"),
editableCell(
index,
"${freightBill.freightbillId}",
isLink: true,
onTap: () {
showFreightBillDetailsDialog(
context, freightBill);
},
),
editableCell(
index, "${freightBill.utr1Date}"),
editableCell(index,
"${freightBill.trasnporterInvoiceNo}"),
editableCell(index,
"${freightBill.trasnporterInvoiceNoDate}"),
editableCell(
index, "${freightBill.billingQty}"),
editableCell(index, "${freightBill.uom}"),
editableCell(
index, "${freightBill.freightAmount}"),
editableCell(index, "${freightBill.cgst}"),
editableCell(index, "${freightBill.sgst}"),
editableCell(index, "${freightBill.igst}"),
editableCell(
index, "${freightBill.totalGst}"),
editableCell(
index, "${freightBill.totalGst}"),
editableCell(
index, "${freightBill.freightAmount}"),
editableCell(index,
"${freightBill.trasnporterInvoiceNoDate}"),
editableCell(index, "${freightBill.status}"),
editableCell(
index, "${freightBill.totalGst}"),
editableCell(index,
"${freightBill.trasnporterInvoiceNoDate}"),
editableCell(index, "${freightBill.utr5No}"),
editableCell(
index, "${freightBill.utr1Date}"),
editableCell(
index, "${freightBill.freightAmount}"),
editableCell(index, "${freightBill.utr1No}"),
editableCell(
index, "${freightBill.utr1Date}"),
editableCell(index,
"${freightBill.utr1PaymentAmount}"),
editableCell(index, "${freightBill.utr2No}"),
editableCell(
index, "${freightBill.utr2Date}"),
editableCell(index,
"${freightBill.utr2PaymentAmount}"),
editableCell(index, "${freightBill.utr3No}"),
editableCell(
index, "${freightBill.utr3Date}"),
editableCell(index,
"${freightBill.utr3PaymentAmount}"),
editableCell(index, "${freightBill.utr4No}"),
editableCell(
index, "${freightBill.utr4Date}"),
editableCell(index,
"${freightBill.utr4PaymentAmount}"),
editableCell(index, "${freightBill.utr5No}"),
editableCell(
index, "${freightBill.utr5Date}"),
editableCell(index,
"${freightBill.utr5PaymentAmount}"),
],
);
}),
),
),
),
),
),
),
),
),
CustomPagination(
currentPage: ctrl.currentPage.value,
totalPages: ctrl.totalPages.value,
onPageChanged: (int page) {
ctrl.onPageChanged(page);
},
),
],
);
}
});
CustomPagination(
currentPage: controller.currentPage.value,
totalPages: controller.totalPages.value,
onPageChanged: (int page) {
controller.onPageChanged(page);
},
),
],
);
}
}),
],
);
}
void showFreightBillDetailsDialog(
@ -259,7 +552,7 @@ class ViewFreightBill extends StatelessWidget {
dataColumn(AppStrings.mrnNo),
dataColumn(
AppStrings.plantName,
onSort: (_, __) => ctrl.changeSort(
onSort: (_, __) => controller.changeSort(
AppStrings.productName.toLowerCase()),
),
dataColumn(AppStrings.product),
@ -276,8 +569,9 @@ class ViewFreightBill extends StatelessWidget {
dataColumn(AppStrings.freightAmount),
],
rows: List<DataRow>.generate(
ctrl.freightBillData.length, (index) {
final freightBill = ctrl.freightBillData[index];
controller.freightBillData.length, (index) {
final freightBill =
controller.freightBillData[index];
return DataRow(
cells: [
editableCell(index, "0${index + 1}"),

View File

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

View File

@ -1,15 +1,14 @@
import 'package:flutter/cupertino.dart';
import 'package:get/get.dart';
import 'package:intl/intl.dart';
import 'package:shayog/components/styles/app_images.dart';
import 'package:shayog/services/network/get_requests.dart';
import '../../../../../../components/common/common_model.dart';
import '../../../../../../components/styles/app_strings.dart';
import '../../../../../../services/model/generate_freight_model.dart';
import '../../../../../../services/network/post_request.dart';
import '../model/freightbill_res_model.dart';
import '../model/grn_panding_res_model.dart';
import '../model/view_freight_bill_res_model.dart';
class TransportController extends GetxController {
@ -17,14 +16,14 @@ class TransportController extends GetxController {
final ScrollController verticalScrollController = ScrollController();
var selectedIndex = 0.obs;
var selectedUser = 0.obs;
var selectPlant = ''.obs;
RxString selectPlant = ''.obs;
var selectProduct = ''.obs;
var selectLocation = ''.obs;
var selectTransactionType = ''.obs;
var selectedItem = false.obs;
var grnDetails = <Content>[].obs;
var product = [].obs;
var plant = [].obs;
var product = <Prodect>[].obs;
var plant = <Plant>[].obs;
var freightBill = [].obs;
var fromLocation = [].obs;
var grnList = [].obs;
@ -47,6 +46,8 @@ class TransportController extends GetxController {
void onInit() {
getFreightBills();
viewFreightView();
grnPending();
super.onInit();
}
@ -72,10 +73,11 @@ class TransportController extends GetxController {
CommonModel(title: AppStrings.pendingGeneration),
].obs;
var isLoading = true.obs;
var grnListLoader = true.obs;
var freightViewLoader = true.obs;
var generateBill = true.obs;
var isLoading = false.obs;
var grnListLoader = false.obs;
var freightViewLoader = false.obs;
var generateBill = false.obs;
var grnPendingLoader = false.obs;
var errorMessage = ''.obs;
postData() async {
@ -303,4 +305,38 @@ class TransportController extends GetxController {
}
// 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:shayog/components/styles/textStyles.dart';
import 'dart:math' as math;
import '../../../components/styles/app_colors.dart';
class CustomPagination extends StatelessWidget {
@ -19,27 +18,28 @@ class CustomPagination extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Container(
padding: const EdgeInsets.symmetric(vertical: 8.0),
decoration: BoxDecoration(
color: Colors.grey[200],
//color: Colors.grey[200],
border: Border(
top: BorderSide(color: Colors.grey[300]!),
),
),
child: Row(
mainAxisAlignment: MainAxisAlignment.end,
mainAxisAlignment: MainAxisAlignment.end, // Center the pagination
children: [
IconButton(
icon: const Icon(Icons.chevron_left),
onPressed:
currentPage > 1 ? () => onPageChanged(currentPage - 1) : null,
currentPage > 1 ? () => onPageChanged(currentPage - 1) : null,
),
_buildPageButton(1),
if (currentPage > 3)
const Text('...', style: TextStyle(fontSize: 20)),
for (int i = math.max(2, currentPage - 1);
i <= math.min(totalPages - 1, currentPage + 1);
i++)
i <= math.min(totalPages - 1, currentPage + 1);
i++)
_buildPageButton(i),
if (currentPage < totalPages - 2)
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';
@ -10,12 +258,12 @@ class GenerateFreightBills {
final List<List<Content>>? content;
final Pageable? pageable;
final bool? last;
final int? totalElements;
final int? totalPages;
final int? totalElements;
final bool? first;
final int? size;
final int? number;
final Sort? sort;
final bool? first;
final int? numberOfElements;
final bool? empty;
@ -24,26 +272,27 @@ class GenerateFreightBills {
this.content,
this.pageable,
this.last,
this.totalElements,
this.totalPages,
this.totalElements,
this.first,
this.size,
this.number,
this.sort,
this.first,
this.numberOfElements,
this.empty,
});
factory GenerateFreightBills.fromJson(Map<String, dynamic> json) => GenerateFreightBills(
content: json["content"] == null ? [] : List<List<Content>>.from(json["content"]!.map((x) => List<Content>.from(x.map((x) => Content.fromJson(x))))),
pageable: json["pageable"] == null ? null : Pageable.fromJson(json["pageable"]),
last: json["last"],
totalElements: json["totalElements"],
totalPages: json["totalPages"],
totalElements: json["totalElements"],
first: json["first"],
size: json["size"],
number: json["number"],
sort: json["sort"] == null ? null : Sort.fromJson(json["sort"]),
first: json["first"],
numberOfElements: json["numberOfElements"],
empty: json["empty"],
);
@ -52,12 +301,12 @@ class GenerateFreightBills {
"content": content == null ? [] : List<dynamic>.from(content!.map((x) => List<dynamic>.from(x.map((x) => x.toJson())))),
"pageable": pageable?.toJson(),
"last": last,
"totalElements": totalElements,
"totalPages": totalPages,
"totalElements": totalElements,
"first": first,
"size": size,
"number": number,
"sort": sort?.toJson(),
"first": first,
"numberOfElements": numberOfElements,
"empty": empty,
};
@ -68,13 +317,11 @@ class Content {
final String? grnNo;
final String? plantCode;
final String? materialCode;
final CodeValue? codeValue;
final String? codeValue;
final String? transporterCode;
final DateTime? grnDate;
final String? fromLocation;
final String? vehicleNo;
// final FromLocation? fromLocation;
// final VehicleNo? vehicleNo;
final String? lrNo;
final DateTime? lrDate;
final double? dispQty;
@ -83,6 +330,7 @@ class Content {
final int? freightRate;
final double? shipmentCost;
final int? statusId;
final dynamic remark;
bool isSelected;
Content({
@ -103,6 +351,7 @@ class Content {
this.freightRate,
this.shipmentCost,
this.statusId,
this.remark,
this.isSelected = false,
});
@ -111,13 +360,11 @@ class Content {
grnNo: json["grn_no"],
plantCode: json["plant_code"],
materialCode: json["material_code"],
codeValue: codeValueValues.map[json["code_value"]]!,
codeValue: json["code_value"],
transporterCode: json["transporter_code"],
grnDate: json["grn_date"] == null ? null : DateTime.parse(json["grn_date"]),
// fromLocation: fromLocationValues.map[json["from_location"]]!,
// vehicleNo: vehicleNoValues.map[json["vehicle_no"]]!,
fromLocation: json["from_location"]!,
vehicleNo: json["vehicle_no"]!,
fromLocation: json["from_location"],
vehicleNo: json["vehicle_no"],
lrNo: json["lr_no"],
lrDate: json["lr_date"] == null ? null : DateTime.parse(json["lr_date"]),
dispQty: json["disp_qty"]?.toDouble(),
@ -126,6 +373,7 @@ class Content {
freightRate: json["freight_rate"],
shipmentCost: json["shipment_cost"]?.toDouble(),
statusId: json["status_id"],
remark: json["remark"],
);
Map<String, dynamic> toJson() => {
@ -133,11 +381,11 @@ class Content {
"grn_no": grnNo,
"plant_code": plantCode,
"material_code": materialCode,
"code_value": codeValueValues.reverse[codeValue],
"code_value": codeValue,
"transporter_code": transporterCode,
"grn_date": "${grnDate!.year.toString().padLeft(4, '0')}-${grnDate!.month.toString().padLeft(2, '0')}-${grnDate!.day.toString().padLeft(2, '0')}",
"from_location": fromLocationValues.reverse[fromLocation],
"vehicle_no": vehicleNoValues.reverse[vehicleNo],
"from_location": fromLocation,
"vehicle_no": vehicleNo,
"lr_no": lrNo,
"lr_date": "${lrDate!.year.toString().padLeft(4, '0')}-${lrDate!.month.toString().padLeft(2, '0')}-${lrDate!.day.toString().padLeft(2, '0')}",
"disp_qty": dispQty,
@ -146,46 +394,23 @@ class Content {
"freight_rate": freightRate,
"shipment_cost": shipmentCost,
"status_id": statusId,
"remark": remark,
};
}
enum CodeValue {
INBOUND
}
final codeValueValues = EnumValues({
"INBOUND": CodeValue.INBOUND
});
enum FromLocation {
NOIDA_UP_TEST
}
final fromLocationValues = EnumValues({
"NOIDA(UP-TEST)": FromLocation.NOIDA_UP_TEST
});
enum VehicleNo {
RJ07_GC9764
}
final vehicleNoValues = EnumValues({
"RJ07GC9764": VehicleNo.RJ07_GC9764
});
class Pageable {
final Sort? sort;
final int? offset;
final int? pageSize;
final int? pageNumber;
final int? pageSize;
final bool? unpaged;
final bool? paged;
Pageable({
this.sort,
this.offset,
this.pageSize,
this.pageNumber,
this.pageSize,
this.unpaged,
this.paged,
});
@ -193,8 +418,8 @@ class Pageable {
factory Pageable.fromJson(Map<String, dynamic> json) => Pageable(
sort: json["sort"] == null ? null : Sort.fromJson(json["sort"]),
offset: json["offset"],
pageSize: json["pageSize"],
pageNumber: json["pageNumber"],
pageSize: json["pageSize"],
unpaged: json["unpaged"],
paged: json["paged"],
);
@ -202,8 +427,8 @@ class Pageable {
Map<String, dynamic> toJson() => {
"sort": sort?.toJson(),
"offset": offset,
"pageSize": pageSize,
"pageNumber": pageNumber,
"pageSize": pageSize,
"unpaged": unpaged,
"paged": paged,
};
@ -232,15 +457,3 @@ class Sort {
"unsorted": unsorted,
};
}
class EnumValues<T> {
Map<String, T> map;
late Map<T, String> reverseMap;
EnumValues(this.map);
Map<T, String> get reverse {
reverseMap = map.map((k, v) => MapEntry(v, k));
return reverseMap;
}
}

View File

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

View File

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