update shipment filter

This commit is contained in:
tzw
2024-01-31 17:54:22 +06:30
parent 9f88d4e525
commit a592413449
5 changed files with 50 additions and 27 deletions

View File

@@ -54,6 +54,7 @@ const fcs_shipment_processing_status = "processing";
const fcs_shipment_arrived_status = "arrived";
const fcs_shipment_invoiced_status = "invoiced";
const fcs_shipment_delivered_status = "delivered";
const fcs_shipment_canceled_status = "canceled";
// Package status
const package_received_status = "received";

View File

@@ -59,7 +59,6 @@ class FcsShipment {
'cutoff_date': cutoffDate?.toUtc().toIso8601String(),
'shipment_type': shipType,
'arrival_date': arrivalDate?.toUtc().toIso8601String(),
'departure_date': departureDate?.toUtc().toIso8601String(),
'consignee': consignee,
'port': port,
'destination': destination,

View File

@@ -44,29 +44,23 @@ class _FcsShipmentListState extends State<FcsShipmentList> {
final popupMenu = LocalPopupMenuButton(
popmenus: [
LocalPopupMenu(
id: 0,
text: "All",
selected: shipmentModel.selectedIndex == 0),
id: 0, text: "All", selected: shipmentModel.selectedIndex == 0),
LocalPopupMenu(
id: 1,
text: "Pending",
selected: shipmentModel.selectedIndex == 1),
id: 1, text: "Pending", selected: shipmentModel.selectedIndex == 1),
LocalPopupMenu(
id: 2,
text: "Processing",
selected: shipmentModel.selectedIndex == 2),
LocalPopupMenu(
id: 3,
text: "Shipped",
selected: shipmentModel.selectedIndex == 3),
id: 3, text: "Shipped", selected: shipmentModel.selectedIndex == 3),
LocalPopupMenu(
id: 4,
text: "Arrived",
selected: shipmentModel.selectedIndex == 4),
id: 4, text: "Arrived", selected: shipmentModel.selectedIndex == 4),
LocalPopupMenu(
id: 5,
text: "Invoiced",
selected: shipmentModel.selectedIndex == 5)
selected: shipmentModel.selectedIndex == 5),
LocalPopupMenu(
id: 6, text: "Canceled", selected: shipmentModel.selectedIndex == 6)
],
popupMenuCallback: (p) {
setState(() {

View File

@@ -28,18 +28,48 @@ class FcsShipmentModel extends BaseModel {
Query col = FirebaseFirestore.instance.collection(path);
Query pageQuery = FirebaseFirestore.instance.collection(path);
// pending status
if (index == 1) {
col = col.where("status", isEqualTo: fcs_shipment_confirmed_status);
col = col.where("status", isEqualTo: fcs_shipment_pending_status);
pageQuery =
pageQuery.where("status", isEqualTo: fcs_shipment_confirmed_status);
pageQuery.where("status", isEqualTo: fcs_shipment_pending_status);
}
// processing status
if (index == 2) {
col = col.where("status", isEqualTo: fcs_shipment_processing_status);
pageQuery =
pageQuery.where("status", isEqualTo: fcs_shipment_processing_status);
}
// shipped status
if (index == 3) {
col = col.where("status", isEqualTo: fcs_shipment_shipped_status);
pageQuery =
pageQuery.where("status", isEqualTo: fcs_shipment_shipped_status);
}
// arrived status
if (index == 4) {
col = col.where("status", isEqualTo: fcs_shipment_arrived_status);
pageQuery =
pageQuery.where("status", isEqualTo: fcs_shipment_arrived_status);
}
// invoiced status
if (index == 5) {
col = col.where("status", isEqualTo: fcs_shipment_invoiced_status);
pageQuery =
pageQuery.where("status", isEqualTo: fcs_shipment_invoiced_status);
}
// canceled status
if (index == 6) {
col = col.where("status", isEqualTo: fcs_shipment_canceled_status);
pageQuery =
pageQuery.where("status", isEqualTo: fcs_shipment_canceled_status);
}
pageQuery = pageQuery.orderBy("shipment_number", descending: true);
fcsShipments?.close();

View File

@@ -74,16 +74,15 @@ class _LocalPopupMenuButtonState extends State<LocalPopupMenuButton> {
//color: Colors.white,
),
child: Stack(
fit: StackFit.expand,
alignment: Alignment.center,
children: <Widget>[
Icon(
widget.buttonIcon ?? Icons.filter_list,
color: Colors.white,
),
hightlight
? Positioned(
bottom: 0,
bottom: 15,
right: 0,
child: Container(
width: 10,
@@ -106,11 +105,12 @@ class _LocalPopupMenuButtonState extends State<LocalPopupMenuButton> {
choice.text != null
? Text(choice.text!,
style: TextStyle(
fontSize: 13,
fontSize: 14,
color:
choice.enabled ? primaryColor : Colors.grey))
: LocalText(context, choice.textKey ?? "",
color: choice.enabled ? primaryColor : Colors.grey),
color: choice.enabled ? primaryColor : Colors.grey,
fontSize: 14),
SizedBox(
width: 10,
),
@@ -119,8 +119,7 @@ class _LocalPopupMenuButtonState extends State<LocalPopupMenuButton> {
Icons.check,
color: Colors.grey,
)
: Container(
),
: Container(),
],
),
);