2020-10-19 05:13:49 +06:30
|
|
|
import 'package:fcs/domain/constants.dart';
|
2020-10-15 17:33:43 +06:30
|
|
|
import 'package:fcs/domain/entities/fcs_shipment.dart';
|
|
|
|
|
import 'package:fcs/helpers/theme.dart';
|
2020-10-19 05:13:49 +06:30
|
|
|
import 'package:fcs/pages/fcs_shipment/model/fcs_shipment_model.dart';
|
|
|
|
|
import 'package:fcs/pages/main/util.dart';
|
2020-10-15 17:33:43 +06:30
|
|
|
import 'package:fcs/pages/widgets/display_text.dart';
|
2024-01-25 17:40:35 +06:30
|
|
|
import 'package:fcs/pages/widgets/local_app_bar.dart';
|
2020-10-19 05:13:49 +06:30
|
|
|
import 'package:fcs/pages/widgets/local_button.dart';
|
2020-10-15 17:33:43 +06:30
|
|
|
import 'package:fcs/pages/widgets/local_text.dart';
|
2020-10-28 05:11:06 +06:30
|
|
|
import 'package:fcs/pages/widgets/pdf_screen.dart';
|
2020-10-15 17:33:43 +06:30
|
|
|
import 'package:fcs/pages/widgets/popupmenu.dart';
|
|
|
|
|
import 'package:fcs/pages/widgets/progress.dart';
|
|
|
|
|
import 'package:flutter/cupertino.dart';
|
|
|
|
|
import 'package:flutter/material.dart';
|
2021-09-10 12:00:08 +06:30
|
|
|
import 'package:flutter_vector_icons/flutter_vector_icons.dart';
|
2020-10-15 17:33:43 +06:30
|
|
|
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
|
|
|
|
|
import 'package:intl/intl.dart';
|
2020-10-19 05:13:49 +06:30
|
|
|
import 'package:provider/provider.dart';
|
2020-10-15 17:33:43 +06:30
|
|
|
|
|
|
|
|
import 'fcs_shipment_editor.dart';
|
|
|
|
|
|
|
|
|
|
class FcsShipmentInfo extends StatefulWidget {
|
2021-09-10 12:00:08 +06:30
|
|
|
final FcsShipment? fcsShipment;
|
2020-10-15 17:33:43 +06:30
|
|
|
FcsShipmentInfo({this.fcsShipment});
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
_FcsShipmentInfoState createState() => _FcsShipmentInfoState();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class _FcsShipmentInfoState extends State<FcsShipmentInfo> {
|
|
|
|
|
var dateFormatter = new DateFormat('dd MMM yyyy');
|
2021-09-10 12:00:08 +06:30
|
|
|
FcsShipment? _fcsShipment;
|
2020-10-15 17:33:43 +06:30
|
|
|
bool _isLoading = false;
|
|
|
|
|
TextEditingController _shipmentNumberController = new TextEditingController();
|
|
|
|
|
TextEditingController _cutoffDateController = new TextEditingController();
|
|
|
|
|
TextEditingController _arrivalDateController = new TextEditingController();
|
|
|
|
|
TextEditingController _departureDateControler = new TextEditingController();
|
|
|
|
|
TextEditingController _shipmentTypeControler = new TextEditingController();
|
|
|
|
|
TextEditingController _consigneeController = new TextEditingController();
|
|
|
|
|
TextEditingController _portController = new TextEditingController();
|
|
|
|
|
TextEditingController _destinationController = new TextEditingController();
|
|
|
|
|
TextEditingController _statusController = new TextEditingController();
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
void initState() {
|
|
|
|
|
super.initState();
|
|
|
|
|
_fcsShipment = widget.fcsShipment;
|
2020-10-19 14:02:34 +06:30
|
|
|
_load();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_load() {
|
2021-09-13 14:24:04 +06:30
|
|
|
_shipmentNumberController.text = _fcsShipment?.shipmentNumber ?? "";
|
|
|
|
|
if (_fcsShipment?.cutoffDate != null)
|
|
|
|
|
_cutoffDateController.text =
|
|
|
|
|
dateFormatter.format(_fcsShipment!.cutoffDate!);
|
|
|
|
|
if (_fcsShipment?.arrivalDate != null)
|
|
|
|
|
_arrivalDateController.text =
|
|
|
|
|
dateFormatter.format(_fcsShipment!.arrivalDate!);
|
|
|
|
|
if (_fcsShipment?.departureDate != null)
|
|
|
|
|
_departureDateControler.text =
|
|
|
|
|
dateFormatter.format(_fcsShipment!.departureDate!);
|
2021-09-10 15:23:13 +06:30
|
|
|
_shipmentTypeControler.text = _fcsShipment!.shipType ?? "";
|
|
|
|
|
_consigneeController.text = _fcsShipment!.consignee ?? "";
|
|
|
|
|
_portController.text = _fcsShipment!.port ?? "";
|
|
|
|
|
_destinationController.text = _fcsShipment!.destination ?? "";
|
|
|
|
|
_statusController.text = _fcsShipment!.status ?? "";
|
2020-10-15 17:33:43 +06:30
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
void dispose() {
|
|
|
|
|
super.dispose();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
|
final cutoffDateDBox = DisplayText(
|
|
|
|
|
text: _cutoffDateController.text,
|
|
|
|
|
labelTextKey: "FCSshipment.cutoff_date",
|
|
|
|
|
iconData: Icons.date_range,
|
|
|
|
|
);
|
|
|
|
|
final etaBox = DisplayText(
|
|
|
|
|
text: _arrivalDateController.text,
|
|
|
|
|
labelTextKey: "FCSshipment.ETA",
|
|
|
|
|
iconData: Icons.date_range,
|
|
|
|
|
);
|
2024-01-30 17:13:49 +06:30
|
|
|
final cartonBox = DisplayText(
|
|
|
|
|
//text: _arrivalDateController.text,
|
|
|
|
|
labelTextKey: "FCSshipment.carton",
|
|
|
|
|
iconData: MaterialCommunityIcons.package,
|
|
|
|
|
);
|
|
|
|
|
final packageBox = DisplayText(
|
|
|
|
|
//text: _arrivalDateController.text,
|
|
|
|
|
labelTextKey: "FCSshipment.package",
|
|
|
|
|
iconData: Octicons.package,
|
|
|
|
|
);
|
2020-10-15 17:33:43 +06:30
|
|
|
|
|
|
|
|
final shipTypeBox = DisplayText(
|
|
|
|
|
text: _shipmentTypeControler.text,
|
|
|
|
|
labelTextKey: "FCSshipment.shipment_type",
|
|
|
|
|
iconData: Ionicons.ios_airplane,
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
final consigneeBox = DisplayText(
|
|
|
|
|
text: _consigneeController.text,
|
|
|
|
|
labelTextKey: "FCSshipment.consignee",
|
|
|
|
|
iconData: Icons.work,
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
final portBox = DisplayText(
|
|
|
|
|
text: _portController.text,
|
|
|
|
|
labelTextKey: "FCSshipment.port_of_loading",
|
|
|
|
|
iconData: FontAwesomeIcons.ship,
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
final destinationBox = DisplayText(
|
|
|
|
|
text: _destinationController.text,
|
|
|
|
|
labelTextKey: "FCSshipment.final_destination",
|
|
|
|
|
iconData: MaterialCommunityIcons.location_enter,
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
final statusBox = DisplayText(
|
|
|
|
|
text: _statusController.text,
|
|
|
|
|
labelTextKey: "FCSshipment.status",
|
2024-01-30 17:47:17 +06:30
|
|
|
iconData: Feather.clock,
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
final shipBtn = Padding(
|
|
|
|
|
padding: const EdgeInsets.symmetric(horizontal: 30),
|
|
|
|
|
child: LocalButton(
|
|
|
|
|
textKey: "FCSshipment.ship.btn",
|
|
|
|
|
callBack: _ship,
|
|
|
|
|
),
|
2020-10-15 17:33:43 +06:30
|
|
|
);
|
2024-01-31 16:20:59 +06:30
|
|
|
final processBtn = Padding(
|
|
|
|
|
padding: const EdgeInsets.symmetric(horizontal: 30),
|
|
|
|
|
child: LocalButton(
|
|
|
|
|
textKey: "FCSshipment.process.btn",
|
2024-02-22 17:09:48 +06:30
|
|
|
callBack: _process,
|
2024-01-31 16:20:59 +06:30
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
final arriveBtn = Padding(
|
|
|
|
|
padding: const EdgeInsets.symmetric(horizontal: 30),
|
|
|
|
|
child: LocalButton(
|
|
|
|
|
textKey: "FCSshipment.arrive.btn",
|
2024-02-22 17:09:48 +06:30
|
|
|
callBack: _arrive,
|
2024-01-31 16:20:59 +06:30
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
final invoiceBtn = Padding(
|
|
|
|
|
padding: const EdgeInsets.symmetric(horizontal: 30),
|
|
|
|
|
child: LocalButton(
|
|
|
|
|
textKey: "FCSshipment.invoice.btn",
|
2024-02-22 17:09:48 +06:30
|
|
|
callBack: _invoice,
|
2024-01-31 16:20:59 +06:30
|
|
|
),
|
|
|
|
|
);
|
2020-10-15 17:33:43 +06:30
|
|
|
|
2024-01-30 17:47:17 +06:30
|
|
|
final cancelBtn = Padding(
|
|
|
|
|
padding: const EdgeInsets.symmetric(horizontal: 30),
|
|
|
|
|
child: LocalButton(
|
|
|
|
|
color: dangerColor,
|
|
|
|
|
textKey: "FCSshipment.cancel.btn",
|
|
|
|
|
callBack: () {
|
|
|
|
|
showConfirmDialog(context, "FCSshipment.cancel.confirm", () {});
|
|
|
|
|
},
|
|
|
|
|
),
|
2020-10-19 05:13:49 +06:30
|
|
|
);
|
|
|
|
|
|
2020-10-15 17:33:43 +06:30
|
|
|
return LocalProgress(
|
|
|
|
|
inAsyncCall: _isLoading,
|
|
|
|
|
child: Scaffold(
|
2024-01-25 17:40:35 +06:30
|
|
|
appBar: LocalAppBar(
|
2024-01-30 17:47:17 +06:30
|
|
|
titleWidget: Text(_shipmentNumberController.text,
|
|
|
|
|
style: TextStyle(fontSize: 20, color: primaryColor)),
|
2020-10-15 17:33:43 +06:30
|
|
|
backgroundColor: Colors.white,
|
2024-01-25 17:40:35 +06:30
|
|
|
labelColor: primaryColor,
|
|
|
|
|
arrowColor: primaryColor,
|
2020-10-15 17:33:43 +06:30
|
|
|
actions: [
|
|
|
|
|
IconButton(
|
|
|
|
|
icon: Icon(Icons.edit, color: primaryColor),
|
|
|
|
|
onPressed: _edit,
|
|
|
|
|
),
|
2024-01-30 17:13:49 +06:30
|
|
|
//menuPopWidget(context)
|
2020-10-15 17:33:43 +06:30
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
body: Card(
|
2024-01-25 17:40:35 +06:30
|
|
|
elevation: 0,
|
2024-01-30 17:47:17 +06:30
|
|
|
child: Padding(
|
2024-02-14 16:58:45 +06:30
|
|
|
padding: const EdgeInsets.only(left: 12.0, right: 12),
|
2024-01-30 17:47:17 +06:30
|
|
|
child: ListView(children: <Widget>[
|
|
|
|
|
statusBox,
|
|
|
|
|
Row(mainAxisAlignment: MainAxisAlignment.end, children: [
|
|
|
|
|
Expanded(
|
|
|
|
|
child: cutoffDateDBox,
|
|
|
|
|
flex: 2,
|
|
|
|
|
),
|
|
|
|
|
Flexible(
|
|
|
|
|
child: etaBox,
|
|
|
|
|
),
|
|
|
|
|
]),
|
|
|
|
|
Row(
|
|
|
|
|
children: [
|
|
|
|
|
Expanded(
|
|
|
|
|
child: cartonBox,
|
|
|
|
|
flex: 2,
|
|
|
|
|
),
|
|
|
|
|
Flexible(child: packageBox),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
shipTypeBox,
|
|
|
|
|
consigneeBox,
|
|
|
|
|
portBox,
|
|
|
|
|
destinationBox,
|
|
|
|
|
const SizedBox(height: 30),
|
2024-01-31 16:20:59 +06:30
|
|
|
_fcsShipment?.status == fcs_shipment_pending_status
|
|
|
|
|
? processBtn
|
2024-01-30 17:47:17 +06:30
|
|
|
: Container(),
|
2024-01-31 16:20:59 +06:30
|
|
|
_fcsShipment?.status == fcs_shipment_pending_status
|
2024-01-30 17:47:17 +06:30
|
|
|
? Container(
|
|
|
|
|
padding: EdgeInsets.only(top: 3), child: cancelBtn)
|
|
|
|
|
: Container(),
|
2024-02-14 16:58:45 +06:30
|
|
|
_fcsShipment?.status == fcs_shipment_processing_status
|
2024-01-31 16:20:59 +06:30
|
|
|
? shipBtn
|
|
|
|
|
: Container(),
|
2024-02-14 16:58:45 +06:30
|
|
|
_fcsShipment?.status == fcs_shipment_shipped_status
|
2024-01-31 16:20:59 +06:30
|
|
|
? arriveBtn
|
|
|
|
|
: Container(),
|
2024-02-14 16:58:45 +06:30
|
|
|
_fcsShipment?.status == fcs_shipment_arrived_status
|
2024-01-31 16:20:59 +06:30
|
|
|
? invoiceBtn
|
|
|
|
|
: Container(),
|
2024-02-21 17:05:20 +06:30
|
|
|
SizedBox(height: 20)
|
2024-01-30 17:47:17 +06:30
|
|
|
]),
|
2020-10-15 17:33:43 +06:30
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_edit() async {
|
2021-09-10 12:00:08 +06:30
|
|
|
bool? updated = await Navigator.push<bool>(
|
2020-10-15 17:33:43 +06:30
|
|
|
context,
|
|
|
|
|
CupertinoPageRoute(
|
|
|
|
|
builder: (context) => FcsShipmentEditor(shipment: _fcsShipment)),
|
|
|
|
|
);
|
2020-10-20 06:19:10 +06:30
|
|
|
if (updated ?? false) {
|
2020-10-19 14:02:34 +06:30
|
|
|
var shipmentModel = Provider.of<FcsShipmentModel>(context, listen: false);
|
2021-09-13 14:24:04 +06:30
|
|
|
if (_fcsShipment != null && _fcsShipment!.id != null) {
|
|
|
|
|
FcsShipment? f = await shipmentModel.getFcsShipment(_fcsShipment!.id!);
|
|
|
|
|
if (f == null) return;
|
|
|
|
|
setState(() {
|
|
|
|
|
_fcsShipment = f;
|
|
|
|
|
});
|
|
|
|
|
_load();
|
|
|
|
|
}
|
2020-10-19 14:02:34 +06:30
|
|
|
}
|
2020-10-15 17:33:43 +06:30
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Widget menuPopWidget(BuildContext context) {
|
|
|
|
|
return PopupMenuButton<PopupMenu>(
|
|
|
|
|
elevation: 3.2,
|
|
|
|
|
icon: Icon(Icons.more_vert, color: primaryColor),
|
|
|
|
|
onSelected: (choice) {
|
2020-10-28 05:11:06 +06:30
|
|
|
_showPDF(choice.id);
|
2020-10-15 17:33:43 +06:30
|
|
|
},
|
|
|
|
|
itemBuilder: (BuildContext context) {
|
|
|
|
|
return menuPopup.map((PopupMenu choice) {
|
|
|
|
|
return PopupMenuItem<PopupMenu>(
|
|
|
|
|
value: choice,
|
|
|
|
|
child: Row(
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
|
children: <Widget>[
|
|
|
|
|
Container(
|
|
|
|
|
padding: EdgeInsets.only(left: 15),
|
|
|
|
|
child: LocalText(
|
|
|
|
|
context,
|
|
|
|
|
choice.status,
|
|
|
|
|
color: primaryColor,
|
|
|
|
|
)),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
}).toList();
|
|
|
|
|
});
|
|
|
|
|
}
|
2020-10-19 05:13:49 +06:30
|
|
|
|
2024-02-22 17:09:48 +06:30
|
|
|
_process() {
|
|
|
|
|
showConfirmDialog(context, "FCSshipment.process.confirm", () {
|
|
|
|
|
_processFcsShipment();
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_processFcsShipment() async {
|
|
|
|
|
setState(() {
|
|
|
|
|
_isLoading = true;
|
|
|
|
|
});
|
|
|
|
|
try {
|
|
|
|
|
FcsShipmentModel fcsShipmentModel =
|
|
|
|
|
Provider.of<FcsShipmentModel>(context, listen: false);
|
|
|
|
|
await fcsShipmentModel.process(_fcsShipment!.id!);
|
|
|
|
|
Navigator.pop(context, true);
|
|
|
|
|
} catch (e) {
|
|
|
|
|
showMsgDialog(context, "Error", e.toString());
|
|
|
|
|
} finally {
|
|
|
|
|
setState(() {
|
|
|
|
|
_isLoading = false;
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-10-19 05:13:49 +06:30
|
|
|
_ship() {
|
|
|
|
|
showConfirmDialog(context, "FCSshipment.ship.confirm", () {
|
|
|
|
|
_shipFcsShipment();
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_shipFcsShipment() async {
|
|
|
|
|
setState(() {
|
|
|
|
|
_isLoading = true;
|
|
|
|
|
});
|
|
|
|
|
try {
|
|
|
|
|
FcsShipmentModel fcsShipmentModel =
|
|
|
|
|
Provider.of<FcsShipmentModel>(context, listen: false);
|
2024-02-21 17:05:20 +06:30
|
|
|
await fcsShipmentModel.ship(_fcsShipment!.id!);
|
2020-10-19 05:13:49 +06:30
|
|
|
Navigator.pop(context, true);
|
|
|
|
|
} catch (e) {
|
|
|
|
|
showMsgDialog(context, "Error", e.toString());
|
|
|
|
|
} finally {
|
2024-02-22 17:09:48 +06:30
|
|
|
setState(() {
|
|
|
|
|
_isLoading = false;
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_arrive() {
|
|
|
|
|
showConfirmDialog(context, "FCSshipment.arrive.confirm", () {
|
|
|
|
|
_arriveFcsShipment();
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_arriveFcsShipment() async {
|
|
|
|
|
setState(() {
|
|
|
|
|
_isLoading = true;
|
|
|
|
|
});
|
|
|
|
|
try {
|
|
|
|
|
FcsShipmentModel fcsShipmentModel =
|
|
|
|
|
Provider.of<FcsShipmentModel>(context, listen: false);
|
|
|
|
|
await fcsShipmentModel.arrive(_fcsShipment!.id!);
|
|
|
|
|
Navigator.pop(context, true);
|
|
|
|
|
} catch (e) {
|
|
|
|
|
showMsgDialog(context, "Error", e.toString());
|
|
|
|
|
} finally {
|
|
|
|
|
setState(() {
|
|
|
|
|
_isLoading = false;
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_invoice() {
|
|
|
|
|
showConfirmDialog(context, "FCSshipment.invoice.confirm", () {
|
|
|
|
|
_invoiceFcsShipment();
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_invoiceFcsShipment() async {
|
|
|
|
|
setState(() {
|
|
|
|
|
_isLoading = true;
|
|
|
|
|
});
|
|
|
|
|
try {
|
|
|
|
|
FcsShipmentModel fcsShipmentModel =
|
|
|
|
|
Provider.of<FcsShipmentModel>(context, listen: false);
|
|
|
|
|
await fcsShipmentModel.invoice(_fcsShipment!.id!);
|
|
|
|
|
Navigator.pop(context, true);
|
|
|
|
|
} catch (e) {
|
|
|
|
|
showMsgDialog(context, "Error", e.toString());
|
|
|
|
|
} finally {
|
2020-10-19 05:13:49 +06:30
|
|
|
setState(() {
|
|
|
|
|
_isLoading = false;
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
2020-10-28 05:11:06 +06:30
|
|
|
|
|
|
|
|
_showPDF(int id) async {
|
|
|
|
|
setState(() {
|
|
|
|
|
_isLoading = true;
|
|
|
|
|
});
|
|
|
|
|
try {
|
|
|
|
|
var reportName = "";
|
|
|
|
|
if (id == 1) {
|
|
|
|
|
reportName = "commercial_invoice";
|
|
|
|
|
} else if (id == 2) {
|
|
|
|
|
reportName = "packing_list";
|
|
|
|
|
} else if (id == 3) {
|
|
|
|
|
reportName = "dms";
|
|
|
|
|
} else if (id == 4) {
|
|
|
|
|
reportName = "manifest";
|
|
|
|
|
}
|
2021-09-10 12:00:08 +06:30
|
|
|
_fcsShipment!.reportName = reportName;
|
2020-10-28 05:11:06 +06:30
|
|
|
|
|
|
|
|
FcsShipmentModel fcsShipmentModel =
|
|
|
|
|
Provider.of<FcsShipmentModel>(context, listen: false);
|
2021-09-10 12:00:08 +06:30
|
|
|
String url = await fcsShipmentModel.report(_fcsShipment!);
|
2020-10-28 05:11:06 +06:30
|
|
|
Navigator.of(context).push(CupertinoPageRoute(
|
|
|
|
|
builder: (context) => PDFScreen(
|
|
|
|
|
title: "",
|
|
|
|
|
url: url,
|
|
|
|
|
)));
|
|
|
|
|
// Navigator.pop(context, true);
|
|
|
|
|
} catch (e) {
|
|
|
|
|
showMsgDialog(context, "Error", e.toString());
|
|
|
|
|
} finally {
|
|
|
|
|
setState(() {
|
|
|
|
|
_isLoading = false;
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
2020-10-15 17:33:43 +06:30
|
|
|
}
|