2025-04-02 15:02:49 +06:30
|
|
|
// ignore_for_file: use_build_context_synchronously
|
|
|
|
|
|
2024-09-22 16:49:59 +06:30
|
|
|
import 'package:fcs/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 {
|
2024-09-25 21:49:09 +06:30
|
|
|
final FcsShipment fcsShipment;
|
2025-03-07 17:41:09 +06:30
|
|
|
const FcsShipmentInfo({super.key, required this.fcsShipment});
|
2020-10-15 17:33:43 +06:30
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
_FcsShipmentInfoState createState() => _FcsShipmentInfoState();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class _FcsShipmentInfoState extends State<FcsShipmentInfo> {
|
2025-03-07 17:41:09 +06:30
|
|
|
var dateFormatter = DateFormat('dd MMM yyyy');
|
2025-02-17 20:13:30 +06:30
|
|
|
final NumberFormat numberFormatter = NumberFormat("#,###");
|
|
|
|
|
|
2024-09-25 21:49:09 +06:30
|
|
|
late FcsShipment _fcsShipment;
|
2020-10-15 17:33:43 +06:30
|
|
|
bool _isLoading = false;
|
2025-03-07 17:41:09 +06:30
|
|
|
TextEditingController shipmentNumberController = TextEditingController();
|
|
|
|
|
TextEditingController cutoffDateController = TextEditingController();
|
|
|
|
|
TextEditingController arrivalDateController = TextEditingController();
|
|
|
|
|
TextEditingController departureDateControler = TextEditingController();
|
|
|
|
|
TextEditingController shipmentTypeControler = TextEditingController();
|
|
|
|
|
TextEditingController consigneeController = TextEditingController();
|
|
|
|
|
TextEditingController portController = TextEditingController();
|
|
|
|
|
TextEditingController destinationController = TextEditingController();
|
|
|
|
|
TextEditingController statusController = TextEditingController();
|
2025-03-26 15:51:47 +06:30
|
|
|
int _packageCount = 0;
|
|
|
|
|
int _cartonCount = 0;
|
2020-10-15 17:33:43 +06:30
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
void initState() {
|
|
|
|
|
super.initState();
|
|
|
|
|
_fcsShipment = widget.fcsShipment;
|
2020-10-19 14:02:34 +06:30
|
|
|
_load();
|
|
|
|
|
}
|
|
|
|
|
|
2025-03-26 15:51:47 +06:30
|
|
|
_load() async {
|
|
|
|
|
try {
|
|
|
|
|
_isLoading = true;
|
|
|
|
|
shipmentNumberController.text = _fcsShipment.shipmentNumber ?? "";
|
|
|
|
|
if (_fcsShipment.cutoffDate != null) {
|
|
|
|
|
cutoffDateController.text =
|
|
|
|
|
dateFormatter.format(_fcsShipment.cutoffDate!);
|
|
|
|
|
}
|
|
|
|
|
if (_fcsShipment.etaDate != null) {
|
|
|
|
|
arrivalDateController.text =
|
|
|
|
|
dateFormatter.format(_fcsShipment.etaDate!);
|
|
|
|
|
}
|
|
|
|
|
if (_fcsShipment.departureDate != null) {
|
|
|
|
|
departureDateControler.text =
|
|
|
|
|
dateFormatter.format(_fcsShipment.departureDate!);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
shipmentTypeControler.text = _fcsShipment.shipmentTypeName ?? "";
|
|
|
|
|
consigneeController.text = _fcsShipment.consigneeName ?? '';
|
|
|
|
|
portController.text = _fcsShipment.loadingPortName ?? '';
|
|
|
|
|
destinationController.text = _fcsShipment.destinationPortName ?? '';
|
|
|
|
|
statusController.text = _fcsShipment.status ?? "";
|
|
|
|
|
|
|
|
|
|
await Future.wait([_loadPackageCount(), _loadCartonCount()]);
|
|
|
|
|
} finally {
|
|
|
|
|
_isLoading = false;
|
2025-03-07 17:41:09 +06:30
|
|
|
}
|
2025-03-26 15:51:47 +06:30
|
|
|
if (mounted) {
|
|
|
|
|
setState(() {});
|
2025-03-07 17:41:09 +06:30
|
|
|
}
|
2025-03-26 15:51:47 +06:30
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Future<void> _loadPackageCount() async {
|
|
|
|
|
int? count = await context
|
|
|
|
|
.read<FcsShipmentModel>()
|
|
|
|
|
.getPackageCount(fcsShipmentId: _fcsShipment.id ?? "");
|
|
|
|
|
_packageCount = count ?? 0;
|
|
|
|
|
if (mounted) {
|
|
|
|
|
setState(() {});
|
2025-03-07 17:41:09 +06:30
|
|
|
}
|
2025-03-26 15:51:47 +06:30
|
|
|
}
|
2024-09-25 21:49:09 +06:30
|
|
|
|
2025-03-26 15:51:47 +06:30
|
|
|
Future<void> _loadCartonCount() async {
|
|
|
|
|
int? count = await context
|
|
|
|
|
.read<FcsShipmentModel>()
|
|
|
|
|
.getCartonCount(fcsShipmentId: _fcsShipment.id ?? "");
|
|
|
|
|
_cartonCount = count ?? 0;
|
|
|
|
|
if (mounted) {
|
|
|
|
|
setState(() {});
|
|
|
|
|
}
|
2020-10-15 17:33:43 +06:30
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
void dispose() {
|
|
|
|
|
super.dispose();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
|
final cutoffDateDBox = DisplayText(
|
2025-03-07 17:41:09 +06:30
|
|
|
text: cutoffDateController.text,
|
2020-10-15 17:33:43 +06:30
|
|
|
labelTextKey: "FCSshipment.cutoff_date",
|
|
|
|
|
iconData: Icons.date_range,
|
|
|
|
|
);
|
|
|
|
|
final etaBox = DisplayText(
|
2025-03-07 17:41:09 +06:30
|
|
|
text: arrivalDateController.text,
|
2020-10-15 17:33:43 +06:30
|
|
|
labelTextKey: "FCSshipment.ETA",
|
|
|
|
|
iconData: Icons.date_range,
|
|
|
|
|
);
|
2025-02-17 20:13:30 +06:30
|
|
|
|
2024-01-30 17:13:49 +06:30
|
|
|
final cartonBox = DisplayText(
|
2025-03-26 15:51:47 +06:30
|
|
|
text: numberFormatter.format(_cartonCount),
|
2024-01-30 17:13:49 +06:30
|
|
|
labelTextKey: "FCSshipment.carton",
|
|
|
|
|
iconData: MaterialCommunityIcons.package,
|
|
|
|
|
);
|
2025-02-17 20:13:30 +06:30
|
|
|
|
2024-01-30 17:13:49 +06:30
|
|
|
final packageBox = DisplayText(
|
2025-03-26 15:51:47 +06:30
|
|
|
text: numberFormatter.format(_packageCount),
|
2024-01-30 17:13:49 +06:30
|
|
|
labelTextKey: "FCSshipment.package",
|
|
|
|
|
iconData: Octicons.package,
|
|
|
|
|
);
|
2020-10-15 17:33:43 +06:30
|
|
|
|
|
|
|
|
final shipTypeBox = DisplayText(
|
2025-03-07 17:41:09 +06:30
|
|
|
text: shipmentTypeControler.text,
|
2020-10-15 17:33:43 +06:30
|
|
|
labelTextKey: "FCSshipment.shipment_type",
|
|
|
|
|
iconData: Ionicons.ios_airplane,
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
final consigneeBox = DisplayText(
|
2025-03-07 17:41:09 +06:30
|
|
|
text: consigneeController.text,
|
2020-10-15 17:33:43 +06:30
|
|
|
labelTextKey: "FCSshipment.consignee",
|
|
|
|
|
iconData: Icons.work,
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
final portBox = DisplayText(
|
2025-03-07 17:41:09 +06:30
|
|
|
text: portController.text,
|
2020-10-15 17:33:43 +06:30
|
|
|
labelTextKey: "FCSshipment.port_of_loading",
|
|
|
|
|
iconData: FontAwesomeIcons.ship,
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
final destinationBox = DisplayText(
|
2025-03-07 17:41:09 +06:30
|
|
|
text: destinationController.text,
|
2020-10-15 17:33:43 +06:30
|
|
|
labelTextKey: "FCSshipment.final_destination",
|
|
|
|
|
iconData: MaterialCommunityIcons.location_enter,
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
final statusBox = DisplayText(
|
2025-03-07 17:41:09 +06:30
|
|
|
text: statusController.text,
|
2020-10-15 17:33:43 +06:30
|
|
|
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
|
|
|
);
|
2025-02-17 20:13:30 +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
|
|
|
),
|
|
|
|
|
);
|
2025-02-17 20:13:30 +06:30
|
|
|
|
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
|
|
|
),
|
|
|
|
|
);
|
2025-02-17 20:13:30 +06:30
|
|
|
|
2024-01-31 16:20:59 +06:30
|
|
|
final invoiceBtn = Padding(
|
|
|
|
|
padding: const EdgeInsets.symmetric(horizontal: 30),
|
|
|
|
|
child: LocalButton(
|
2024-03-02 18:15:05 +06:30
|
|
|
textKey: "FCSshipment.invoiced.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
|
|
|
|
2025-02-17 20:13:30 +06:30
|
|
|
final deliverBtn = Padding(
|
|
|
|
|
padding: const EdgeInsets.symmetric(horizontal: 30),
|
|
|
|
|
child: LocalButton(
|
|
|
|
|
textKey: "FCSshipment.deliver.btn",
|
|
|
|
|
callBack: _deliver,
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
|
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: () {
|
2024-03-01 17:27:56 +06:30
|
|
|
showConfirmDialog(context, "FCSshipment.cancel.confirm", () {
|
|
|
|
|
_cancelFcsShipment();
|
|
|
|
|
});
|
2024-01-30 17:47:17 +06:30
|
|
|
},
|
|
|
|
|
),
|
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(
|
2025-03-07 17:41:09 +06:30
|
|
|
titleWidget: Column(
|
|
|
|
|
children: [
|
|
|
|
|
LocalText(context, "FCSshipment.form.title",
|
|
|
|
|
fontSize: 20, color: primaryColor),
|
|
|
|
|
Text(shipmentNumberController.text,
|
|
|
|
|
style: TextStyle(fontSize: 15, color: Colors.black))
|
|
|
|
|
],
|
|
|
|
|
),
|
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: [
|
2024-09-25 21:49:09 +06:30
|
|
|
_fcsShipment.status == fcs_shipment_pending_status
|
2024-03-01 17:27:56 +06:30
|
|
|
? IconButton(
|
|
|
|
|
icon: Icon(Icons.edit, color: primaryColor),
|
|
|
|
|
onPressed: _edit,
|
|
|
|
|
)
|
|
|
|
|
: const SizedBox(),
|
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,
|
2025-04-02 15:02:49 +06:30
|
|
|
const SizedBox(height: 5),
|
2024-01-30 17:47:17 +06:30
|
|
|
Row(mainAxisAlignment: MainAxisAlignment.end, children: [
|
|
|
|
|
Expanded(
|
|
|
|
|
child: cutoffDateDBox,
|
2024-03-02 18:15:05 +06:30
|
|
|
// flex: 2,
|
2024-01-30 17:47:17 +06:30
|
|
|
),
|
2024-03-02 18:15:05 +06:30
|
|
|
Flexible(child: etaBox),
|
2024-01-30 17:47:17 +06:30
|
|
|
]),
|
2025-04-02 15:02:49 +06:30
|
|
|
const SizedBox(height: 5),
|
2024-01-30 17:47:17 +06:30
|
|
|
Row(
|
|
|
|
|
children: [
|
|
|
|
|
Expanded(
|
|
|
|
|
child: cartonBox,
|
2024-03-02 18:15:05 +06:30
|
|
|
// flex: 2,
|
2024-01-30 17:47:17 +06:30
|
|
|
),
|
2024-03-02 18:15:05 +06:30
|
|
|
Flexible(child: packageBox)
|
2024-01-30 17:47:17 +06:30
|
|
|
],
|
|
|
|
|
),
|
2025-04-02 15:02:49 +06:30
|
|
|
const SizedBox(height: 5),
|
2024-01-30 17:47:17 +06:30
|
|
|
shipTypeBox,
|
2025-04-02 15:02:49 +06:30
|
|
|
const SizedBox(height: 5),
|
2024-01-30 17:47:17 +06:30
|
|
|
consigneeBox,
|
2025-04-02 15:02:49 +06:30
|
|
|
const SizedBox(height: 5),
|
2024-01-30 17:47:17 +06:30
|
|
|
portBox,
|
2025-04-02 15:02:49 +06:30
|
|
|
const SizedBox(height: 5),
|
2024-01-30 17:47:17 +06:30
|
|
|
destinationBox,
|
|
|
|
|
const SizedBox(height: 30),
|
2024-09-25 21:49:09 +06:30
|
|
|
_fcsShipment.status == fcs_shipment_pending_status
|
2024-01-31 16:20:59 +06:30
|
|
|
? processBtn
|
2024-01-30 17:47:17 +06:30
|
|
|
: Container(),
|
2024-09-25 21:49:09 +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-09-25 21:49:09 +06:30
|
|
|
_fcsShipment.status == fcs_shipment_processed_status
|
2024-01-31 16:20:59 +06:30
|
|
|
? shipBtn
|
|
|
|
|
: Container(),
|
2024-09-25 21:49:09 +06:30
|
|
|
_fcsShipment.status == fcs_shipment_shipped_status
|
2024-01-31 16:20:59 +06:30
|
|
|
? arriveBtn
|
|
|
|
|
: Container(),
|
2024-09-25 21:49:09 +06:30
|
|
|
_fcsShipment.status == fcs_shipment_arrived_status
|
2024-01-31 16:20:59 +06:30
|
|
|
? invoiceBtn
|
|
|
|
|
: Container(),
|
2025-02-17 20:13:30 +06:30
|
|
|
_fcsShipment.status == fcs_shipment_invoiced_status
|
|
|
|
|
? deliverBtn
|
|
|
|
|
: 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);
|
2024-09-25 21:49:09 +06:30
|
|
|
if (_fcsShipment.id != null) {
|
|
|
|
|
FcsShipment? f = await shipmentModel.getFcsShipment(_fcsShipment.id!);
|
2021-09-13 14:24:04 +06:30
|
|
|
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 {
|
2024-09-25 21:49:09 +06:30
|
|
|
await context.read<FcsShipmentModel>().process(_fcsShipment.id!);
|
2024-02-22 17:09:48 +06:30
|
|
|
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 {
|
2024-09-25 21:49:09 +06:30
|
|
|
await context.read<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 {
|
2024-09-25 21:49:09 +06:30
|
|
|
await context.read<FcsShipmentModel>().arrive(_fcsShipment.id!);
|
2024-02-22 17:09:48 +06:30
|
|
|
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 {
|
2024-09-25 21:49:09 +06:30
|
|
|
await context.read<FcsShipmentModel>().invoice(_fcsShipment.id!);
|
2024-02-22 17:09:48 +06:30
|
|
|
Navigator.pop(context, true);
|
|
|
|
|
} catch (e) {
|
|
|
|
|
showMsgDialog(context, "Error", e.toString());
|
|
|
|
|
} finally {
|
2024-03-01 17:27:56 +06:30
|
|
|
setState(() {
|
|
|
|
|
_isLoading = false;
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_cancelFcsShipment() async {
|
|
|
|
|
setState(() {
|
|
|
|
|
_isLoading = true;
|
|
|
|
|
});
|
|
|
|
|
try {
|
2024-09-25 21:49:09 +06:30
|
|
|
await context.read<FcsShipmentModel>().cancel(_fcsShipment.id!);
|
2024-03-01 17:27:56 +06:30
|
|
|
Navigator.pop(context, true);
|
|
|
|
|
} catch (e) {
|
|
|
|
|
showMsgDialog(context, "Error", e.toString());
|
|
|
|
|
} finally {
|
2025-02-17 20:13:30 +06:30
|
|
|
setState(() {
|
|
|
|
|
_isLoading = false;
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_deliver() {
|
|
|
|
|
showConfirmDialog(context, "FCSshipment.deliver.confrim", () {
|
|
|
|
|
_deliverFcsShipment();
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_deliverFcsShipment() async {
|
|
|
|
|
setState(() {
|
|
|
|
|
_isLoading = true;
|
|
|
|
|
});
|
|
|
|
|
try {
|
|
|
|
|
await context.read<FcsShipmentModel>().deliver(_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";
|
|
|
|
|
}
|
2024-09-25 21:49:09 +06:30
|
|
|
_fcsShipment.reportName = reportName;
|
2020-10-28 05:11:06 +06:30
|
|
|
|
|
|
|
|
FcsShipmentModel fcsShipmentModel =
|
|
|
|
|
Provider.of<FcsShipmentModel>(context, listen: false);
|
2024-09-25 21:49:09 +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
|
|
|
}
|