This commit is contained in:
PhyoThandar
2020-10-14 13:56:03 +06:30
11 changed files with 481 additions and 519 deletions

View File

@@ -50,7 +50,12 @@ const privilege_processing = "pr";
const privilege_receiving = "rc";
// Pickup types
const shipment_local_pickup = "Local Pickup";
const shipment_courier_pickup = "Courier Pickup";
const shipment_local_dropoff = "Local Drop-off";
const shipment_courier_dropoff = "Courier Drop-off";
const shipment_local_pickup = "Local pickup";
const shipment_courier_pickup = "Courier pickup";
const shipment_local_dropoff = "Local drop-off";
const shipment_courier_dropoff = "Courier drop-off";
//Carton types
const carton_from_packages = "From packages";
const carton_from_shipments = "From shipments";
const carton_mix_box = "Mix box";

View File

@@ -19,7 +19,9 @@ import 'package:fcs/pages/widgets/delivery_address_selection.dart';
import 'package:fcs/pages/widgets/display_text.dart';
import 'package:fcs/pages/widgets/fcs_id_icon.dart';
import 'package:fcs/pages/widgets/input_text.dart';
import 'package:fcs/pages/widgets/local_radio_buttons.dart';
import 'package:fcs/pages/widgets/local_text.dart';
import 'package:fcs/pages/widgets/local_title.dart';
import 'package:fcs/pages/widgets/my_data_table.dart';
import 'package:fcs/pages/widgets/progress.dart';
import 'package:fcs/pages/widgets/title_with_add_button.dart';
@@ -33,6 +35,7 @@ import 'package:timeline_list/timeline.dart';
import 'package:timeline_list/timeline_model.dart';
import 'cargo_type_editor.dart';
import 'model/box_model.dart';
class BoxEditor extends StatefulWidget {
final Box box;
@@ -53,7 +56,8 @@ class _BoxEditorState extends State<BoxEditor> {
bool isMixBox = false;
DeliveryAddress _deliveryAddress = new DeliveryAddress();
User user;
String selectShipmentNumber;
String _selectShipmentNumber;
String _selectedCartonType;
List<Package> _packages = [];
List<Cargo> _cargoTypes = [];
double volumetricRatio = 0;
@@ -80,7 +84,7 @@ class _BoxEditorState extends State<BoxEditor> {
_box = widget.box;
_deliveryAddress = _box.shippingAddress;
_cargoTypes = _box.cargoTypes;
selectShipmentNumber = _box.shipmentNumber;
_selectShipmentNumber = _box.shipmentNumber;
_widthController.text = _box.width.toString();
_heightController.text = _box.height.toString();
_lengthController.text = _box.length.toString();
@@ -156,38 +160,35 @@ class _BoxEditorState extends State<BoxEditor> {
@override
Widget build(BuildContext context) {
var languageModel = Provider.of<LanguageModel>(context);
var boxModel = Provider.of<BoxModel>(context);
var shipmentBox = Container(
child: Padding(
padding: const EdgeInsets.only(left: 10.0, right: 10),
child: DropdownButtonFormField(
value: selectShipmentNumber,
decoration: InputDecoration(
fillColor: Colors.white,
labelText:
AppTranslations.of(context).text("box.fcs_shipment_num"),
labelStyle: languageModel.isEng
? TextStyle(fontWeight: FontWeight.w500)
: TextStyle(
fontWeight: FontWeight.w500, fontFamily: "Myanmar3"),
icon: Icon(
Ionicons.ios_airplane,
color: primaryColor,
)),
items: ["A102", "A103", "A201", "A202"]
.map((e) => DropdownMenuItem(
child: Text(
e,
style: TextStyle(color: primaryColor),
),
value: e))
.toList(),
onChanged: (value) {
setState(() {
selectShipmentNumber = value;
});
},
)));
child: DropdownButtonFormField(
value: _selectShipmentNumber,
decoration: InputDecoration(
fillColor: Colors.white,
labelText: AppTranslations.of(context).text("box.fcs_shipment_num"),
labelStyle: languageModel.isEng
? TextStyle(fontWeight: FontWeight.w500)
: TextStyle(fontWeight: FontWeight.w500, fontFamily: "Myanmar3"),
icon: Icon(
Ionicons.ios_airplane,
color: primaryColor,
)),
items: ["A102", "A103", "A201", "A202"]
.map((e) => DropdownMenuItem(
child: Text(
e,
style: TextStyle(color: primaryColor),
),
value: e))
.toList(),
onChanged: (value) {
setState(() {
_selectShipmentNumber = value;
});
},
));
final mixBox = Container(
child: new Row(
@@ -216,41 +217,35 @@ class _BoxEditorState extends State<BoxEditor> {
),
);
final fcsIDBox = Container(
padding: EdgeInsets.only(left: 10),
child: Row(
children: <Widget>[
Expanded(
child: DisplayText(
text: user != null ? user.fcsID : "",
labelTextKey: "box.fcs.id",
icon: FcsIDIcon(),
)),
IconButton(
icon: Icon(Icons.search, color: primaryColor),
onPressed: () => searchUser(context, callbackUserSelect: (u) {
setState(() {
this.user = u;
});
})),
],
));
final fcsIDBox = Row(
children: <Widget>[
Expanded(
child: DisplayText(
text: user != null ? user.fcsID : "",
labelTextKey: "box.fcs.id",
icon: FcsIDIcon(),
)),
IconButton(
icon: Icon(Icons.search, color: primaryColor),
onPressed: () => searchUser(context, callbackUserSelect: (u) {
setState(() {
this.user = u;
});
})),
],
);
final phoneNumberBox = Container(
padding: EdgeInsets.only(left: 10),
child: DisplayText(
text: user != null ? user.phoneNumber : "",
labelTextKey: "box.phone",
iconData: Icons.phone,
));
final phoneNumberBox = DisplayText(
text: user != null ? user.phoneNumber : "",
labelTextKey: "box.phone",
iconData: Icons.phone,
);
final namebox = Container(
padding: EdgeInsets.only(left: 10),
child: DisplayText(
text: user != null ? user.name : "",
labelTextKey: "box.name",
iconData: Icons.person,
));
final namebox = DisplayText(
text: user != null ? user.name : "",
labelTextKey: "box.name",
iconData: Icons.person,
);
final packageTitle = Container(
padding: EdgeInsets.only(right: 10.0, top: 20),
@@ -485,7 +480,7 @@ class _BoxEditorState extends State<BoxEditor> {
title: widget.box == null
? LocalText(
context,
"boxes.new",
"boxes.create.title",
fontSize: 20,
color: primaryColor,
)
@@ -496,44 +491,36 @@ class _BoxEditorState extends State<BoxEditor> {
color: primaryColor,
),
),
body: ListView(
shrinkWrap: true,
children: [
widget.box == null
? Container()
: Center(child: nameWidget(_box.packageNumber)),
Container(
padding: EdgeInsets.only(top: 10),
child: TitleWithAddButton(
titleKey: "box.shipment_info",
body: Padding(
padding: const EdgeInsets.all(10.0),
child: ListView(
shrinkWrap: true,
children: [
widget.box == null
? Container()
: Center(child: nameWidget(_box.packageNumber)),
SizedBox(
height: 10,
),
),
Column(
children: [
shipmentBox,
SizedBox(
height: 10,
),
fcsIDBox,
phoneNumberBox,
namebox,
mixBox,
SizedBox(
height: 10,
),
],
),
Divider(),
Container(
padding: EdgeInsets.only(top: 10, left: 10),
child: TitleWithAddButton(
iconData: Octicons.package,
titleKey: "box.packages",
LocalTitle(textKey: "box.type.title"),
LocalRadioButtons(
values: boxModel.cartonTypes,
selectedValue: _selectedCartonType,
callback: (v) {
print(v);
setState(() {
_selectedCartonType = v;
});
}),
LocalTitle(textKey: "box.shipment_info"),
shipmentBox,
SizedBox(
height: 10,
),
),
Container(
padding: EdgeInsets.only(left: 10, right: 10),
child: Column(
fcsIDBox,
namebox,
LocalTitle(textKey: "box.packages"),
Column(
children: [
packageTitle,
Divider(
@@ -545,117 +532,111 @@ class _BoxEditorState extends State<BoxEditor> {
SizedBox(height: 10),
],
),
),
Divider(),
Container(
padding: EdgeInsets.only(left: 10),
child: TitleWithAddButton(
iconData: MaterialCommunityIcons.briefcase_check,
titleKey: "box.cargo_type",
onTap: () async {
Cargo cargo = await Navigator.push<Cargo>(
context,
CupertinoPageRoute(
builder: (context) => CargoTypeEditor()));
if (cargo != null) {
setState(() {
_box.cargoTypes.add(cargo);
});
}
}),
),
Container(
padding: EdgeInsets.only(left: 10, right: 10),
child: Column(
children: [
cargoTitle,
Divider(
color: Colors.grey[400],
),
Column(
children: getCargoRowList(),
),
SizedBox(height: 10),
],
Divider(),
Container(
padding: EdgeInsets.only(left: 10),
child: TitleWithAddButton(
iconData: MaterialCommunityIcons.briefcase_check,
titleKey: "box.cargo_type",
onTap: () async {
Cargo cargo = await Navigator.push<Cargo>(
context, BottomUpPageRoute(CargoTypeEditor()));
if (cargo != null) {
setState(() {
_box.cargoTypes.add(cargo);
});
}
}),
),
),
Divider(),
SizedBox(
height: 10,
),
TitleWithAddButton(
titleKey: "box.dimension",
),
Column(
children: [
shipmentWeightBox,
widthBox,
heightBox,
lengthBox,
SizedBox(height: 25),
],
),
Divider(),
Container(
padding: EdgeInsets.only(left: 10, right: 10),
child: DefaultDeliveryAddress(
deliveryAddress: _deliveryAddress,
onTap: () async {
DeliveryAddress d = await Navigator.push<DeliveryAddress>(
context,
CupertinoPageRoute(
builder: (context) => DeliveryAddressSelection(
deliveryAddress: _deliveryAddress,
)),
);
if (d == null) return;
setState(() {
this._deliveryAddress = d;
});
}),
),
SizedBox(height: 15),
Divider(),
isNew
? Container()
: Column(
children: [
Padding(
padding: EdgeInsets.only(top: 10),
child: TitleWithAddButton(
titleKey: "box.status",
Container(
padding: EdgeInsets.only(left: 10, right: 10),
child: Column(
children: [
cargoTitle,
Divider(
color: Colors.grey[400],
),
Column(
children: getCargoRowList(),
),
SizedBox(height: 10),
],
),
),
Divider(),
SizedBox(
height: 10,
),
TitleWithAddButton(
titleKey: "box.dimension",
),
shipmentWeightBox,
widthBox,
heightBox,
lengthBox,
SizedBox(height: 25),
Divider(),
Container(
padding: EdgeInsets.only(left: 10, right: 10),
child: DefaultDeliveryAddress(
deliveryAddress: _deliveryAddress,
labelKey: "box.delivery_address",
onTap: () async {
DeliveryAddress d = await Navigator.push<DeliveryAddress>(
context,
BottomUpPageRoute(DeliveryAddressSelection(
deliveryAddress: _deliveryAddress,
)),
);
if (d == null) return;
setState(() {
this._deliveryAddress = d;
});
}),
),
SizedBox(height: 15),
Divider(),
isNew
? Container()
: Column(
children: [
Padding(
padding: EdgeInsets.only(top: 10),
child: TitleWithAddButton(
titleKey: "box.status",
),
),
),
Container(
height: 230,
padding: EdgeInsets.only(left: 10),
child: isNew
? Container()
: Timeline(
children: _models(),
position: TimelinePosition.Left),
),
],
),
isNew ? Container() : Divider(),
SizedBox(
height: 10,
),
widget.box == null
? createBtn
: Container(
child: Column(
children: <Widget>[
completeBtn,
widget.box.status == 'Arrived'
? deliveryBtn
: Container(),
],
)),
SizedBox(
height: 20,
),
],
Container(
height: 230,
padding: EdgeInsets.only(left: 10),
child: isNew
? Container()
: Timeline(
children: _models(),
position: TimelinePosition.Left),
),
],
),
isNew ? Container() : Divider(),
SizedBox(
height: 10,
),
widget.box == null
? createBtn
: Container(
child: Column(
children: <Widget>[
completeBtn,
widget.box.status == 'Arrived'
? deliveryBtn
: Container(),
],
)),
SizedBox(
height: 20,
),
],
),
),
),
);

View File

@@ -1,6 +1,7 @@
import 'dart:async';
import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:fcs/domain/constants.dart';
import 'package:fcs/domain/entities/box.dart';
import 'package:fcs/domain/entities/cargo.dart';
import 'package:fcs/domain/entities/package.dart';
@@ -295,6 +296,12 @@ class BoxModel extends BaseModel {
});
}
List<String> cartonTypes = [
carton_from_packages,
carton_from_shipments,
carton_mix_box
];
void initUser(user) {
super.initUser(user);
}

View File

@@ -55,7 +55,7 @@ class _InvitationCreateState extends State<InvitationCreate> {
),
title: LocalText(
context,
"invitation.new",
"invitation.form.title",
fontSize: 20,
color: primaryColor,
),

View File

@@ -18,6 +18,7 @@ import 'package:fcs/pages/widgets/display_text.dart';
import 'package:fcs/pages/widgets/input_text.dart';
import 'package:fcs/pages/widgets/local_dropdown.dart';
import 'package:fcs/pages/widgets/local_text.dart';
import 'package:fcs/pages/widgets/local_title.dart';
import 'package:fcs/pages/widgets/multi_img_controller.dart';
import 'package:fcs/pages/widgets/multi_img_file.dart';
import 'package:fcs/pages/widgets/my_data_table.dart';
@@ -197,181 +198,141 @@ class _InvoiceEditorState extends State<InvoiceEditor> {
title: LocalText(context, 'invoice.form.title',
color: primaryColor, fontSize: 20),
),
body: Card(
child: Column(
body: Padding(
padding: const EdgeInsets.all(8.0),
child: ListView(
children: <Widget>[
Expanded(
child: Padding(
padding: const EdgeInsets.all(10.0),
child: ListView(children: <Widget>[
DisplayText(
labelTextKey: 'invoice.date',
iconData: Icons.date_range,
text: _dateController.text),
widget.invoice == null
? Container()
: DisplayText(
labelTextKey: 'invoice.number',
iconData: FontAwesomeIcons.fileInvoice,
text: _invoiceNumberController.text),
widget.invoice == null
? Row(
children: <Widget>[
Expanded(
child: DisplayText(
text: user != null ? user.name : "",
labelTextKey: "invoice.customer_name",
iconData: Feather.user,
)),
IconButton(
icon: Icon(Icons.search, color: primaryColor),
onPressed: () => searchUser(context,
callbackUserSelect: (u) {
setState(() {
this.user = u;
});
})),
],
)
: DisplayText(
text: _nameController.text,
iconData: Feather.user,
labelTextKey: 'invoice.customer_name'),
InputText(
controller: _handlingFeeController,
iconData: FontAwesomeIcons.moneyBill,
labelTextKey: 'invoice.handling_fee'),
SizedBox(height: 15),
discountBox,
widget.invoice == null
? Container()
: DisplayText(
text: _statusController.text,
iconData: Icons.av_timer,
labelTextKey: 'invoice.status'),
SizedBox(height: 30),
Container(
child: Row(
children: [
Icon(MaterialCommunityIcons.package,
color: primaryColor),
SizedBox(width: 10),
LocalText(
context,
"invoice.box_info",
color: Colors.grey,
fontSize: 20,
fontWeight: FontWeight.w700,
),
],
),
),
Container(
padding: const EdgeInsets.only(top: 15),
child: SingleChildScrollView(
scrollDirection: Axis.horizontal,
child: MyDataTable(
headingRowHeight: 40,
columnSpacing: 20,
columns: [
MyDataColumn(
label: Text(''),
),
MyDataColumn(
label: LocalText(
context,
"invoice.box.number",
color: Colors.grey,
),
),
MyDataColumn(
label: Text(
getLocalString(context, "invoice.box.length") +
' x ' +
getLocalString(context, "invoice.box.width") +
' x ' +
getLocalString(context, "invoice.box.height"),
),
),
],
rows: getBoxRow(context),
),
),
),
SizedBox(height: 40),
Container(
child: Row(
children: [
Icon(MaterialCommunityIcons.briefcase_check,
color: primaryColor),
SizedBox(width: 10),
LocalText(
context,
"invoice.cargo_type",
color: Colors.grey,
fontSize: 20,
fontWeight: FontWeight.w700,
),
],
),
),
Container(
padding: const EdgeInsets.only(top: 10),
child: Column(children: getCargoTableByBox(context)),
),
SizedBox(height: 20),
Container(
padding: EdgeInsets.only(top: 5, left: 18),
child: Row(
LocalTitle(textKey: "package.create.name"),
DisplayText(
labelTextKey: 'invoice.date',
iconData: Icons.date_range,
text: _dateController.text),
widget.invoice == null
? Container()
: DisplayText(
labelTextKey: 'invoice.number',
iconData: FontAwesomeIcons.fileInvoice,
text: _invoiceNumberController.text),
widget.invoice == null
? Row(
children: <Widget>[
Expanded(
child: LocalText(context, 'invoice.payment_method',
fontSize: 16,
color: Colors.grey,
fontWeight: FontWeight.bold),
),
child: DisplayText(
text: user != null ? user.name : "",
labelTextKey: "invoice.customer_name",
iconData: Feather.user,
)),
IconButton(
icon: Icon(Icons.search, color: primaryColor),
onPressed: () =>
searchUser(context, callbackUserSelect: (u) {
setState(() {
this.user = u;
});
})),
],
)
: DisplayText(
text: _nameController.text,
iconData: Feather.user,
labelTextKey: 'invoice.customer_name'),
InputText(
controller: _handlingFeeController,
iconData: FontAwesomeIcons.moneyBill,
labelTextKey: 'invoice.handling_fee'),
SizedBox(height: 15),
discountBox,
widget.invoice == null
? Container()
: DisplayText(
text: _statusController.text,
iconData: Icons.av_timer,
labelTextKey: 'invoice.status'),
SizedBox(height: 30),
LocalTitle(textKey: "invoice.box_info"),
SingleChildScrollView(
scrollDirection: Axis.horizontal,
child: MyDataTable(
headingRowHeight: 40,
// columnSpacing: 20,
columns: [
MyDataColumn(
label: Text(''),
),
MyDataColumn(
label: LocalText(
context,
"invoice.box.number",
color: Colors.grey,
),
),
MyDataColumn(
label: Text(
getLocalString(context, "invoice.box.length") +
' x ' +
getLocalString(context, "invoice.box.width") +
' x ' +
getLocalString(context, "invoice.box.height"),
),
),
],
rows: getBoxRow(context),
),
),
SizedBox(height: 40),
LocalTitle(textKey: "invoice.cargo_type"),
Column(children: getCargoTableByBox(context)),
SizedBox(height: 20),
Container(
padding: EdgeInsets.only(top: 5, left: 18),
child: Row(
children: <Widget>[
Expanded(
child: LocalText(context, 'invoice.payment_method',
fontSize: 16,
color: Colors.grey,
fontWeight: FontWeight.bold),
),
Container(
width: 150.0,
child: DropdownButtonFormField(
icon: Icon(Icons.edit),
value: paymentMethod,
items: paymentMethodModel.paymentMethods
.map((e) => DropdownMenuItem(
child: Text(e.name), value: e.name))
.toList(),
onChanged: (selected) => {},
),
),
],
),
),
SizedBox(height: 30),
!isNew
? Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Container(
width: 150.0,
child: DropdownButtonFormField(
icon: Icon(Icons.edit),
value: paymentMethod,
items: paymentMethodModel.paymentMethods
.map((e) => DropdownMenuItem(
child: Text(e.name), value: e.name))
.toList(),
onChanged: (selected) => {},
child: Row(
children: [
Icon(Icons.receipt, color: primaryColor),
SizedBox(width: 10),
LocalText(
context,
"invoice.payment_attachment",
color: Colors.grey,
fontSize: 20,
fontWeight: FontWeight.w700,
),
],
),
),
Spacer(),
Icon(Icons.add, color: primaryColor),
],
),
),
SizedBox(height: 30),
!isNew
? Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Container(
child: Row(
children: [
Icon(Icons.receipt, color: primaryColor),
SizedBox(width: 10),
LocalText(
context,
"invoice.payment_attachment",
color: Colors.grey,
fontSize: 20,
fontWeight: FontWeight.w700,
),
],
),
),
Spacer(),
Icon(Icons.add, color: primaryColor),
],
)
: Container()
]),
)),
)
: Container(),
widget.invoice == null
? fcsButton(
context, getLocalString(context, 'invoice.btn_create'))

View File

@@ -64,7 +64,7 @@ class _PaymentMethodEditorState extends State<PaymentMethodEditor> {
),
title: LocalText(
context,
isNew ? "pm.new" : "pm.update",
isNew ? "pm.form.new" : "pm.update",
fontSize: 20,
color: primaryColor,
),

View File

@@ -144,7 +144,7 @@ class _ReceivingEditorState extends State<ReceivingEditor> {
backgroundColor: Colors.white,
title: LocalText(
context,
_isNew ? "receiving.new" : "receiving.update",
_isNew ? "receiving.create" : "receiving.update",
fontSize: 20,
color: primaryColor,
),

View File

@@ -72,7 +72,6 @@ class _ShipmentBoxEditorState extends State<ShipmentBoxEditor> {
double l = double.parse(_lengthCtl.text, (s) => 0);
double w = double.parse(_widthCtl.text, (s) => 0);
double h = double.parse(_heightCtl.text, (s) => 0);
print("$l $w $h");
setState(() {
shipmentWeight = l * w * h / volumetricRatio;
});
@@ -129,7 +128,7 @@ class _ShipmentBoxEditorState extends State<ShipmentBoxEditor> {
backgroundColor: Colors.white,
title: LocalText(
context,
_isNew ? "boxes.new" : "box.edit.title",
_isNew ? "boxes.create.title" : "box.edit.title",
fontSize: 20,
color: primaryColor,
),

View File

@@ -242,7 +242,6 @@ class _ShipmentEditorState extends State<ShipmentEditor> {
},
),
),
Column(
children: getBoxList(context, boxModel.boxes),
),