This commit is contained in:
Sai Naw Wun
2020-10-07 02:33:06 +06:30
parent 01a2798a74
commit 65dda16fe6
475 changed files with 1543 additions and 90780 deletions

View File

@@ -0,0 +1,9 @@
import 'auth_status.dart';
class AuthResult {
AuthStatus authStatus;
String authErrorCode;
String authErrorMsg;
AuthResult({this.authStatus, this.authErrorCode, this.authErrorMsg});
}

View File

@@ -0,0 +1 @@
enum AuthStatus { SMS_SENT, AUTH_VERIFIED, ERROR, SIGN_OUT }

View File

@@ -0,0 +1,31 @@
class BankAccount {
int index;
String bankName;
String bankLogo;
String accountName;
String accountNumber;
BankAccount(
{this.index,
this.bankName,
this.bankLogo,
this.accountName,
this.accountNumber});
BankAccount.fromMap(int index, Map<String, dynamic> json) {
this.index = index;
bankName = json['bank_name'];
bankLogo = json['bank_logo'];
accountName = json['account_name'];
accountNumber = json['account_number'];
}
Map<String, dynamic> toMap() {
return {
"index": index,
'bank_name': bankName,
'bank_logo': bankLogo,
'account_name': accountName,
'account_number': accountNumber,
};
}
}

View File

@@ -0,0 +1,72 @@
import 'package:fcs/domain/vo/shipment_status.dart';
import 'package:fcs/domain/vo/shipping_address.dart';
import 'cargo.dart';
import 'package.dart';
class Box {
String id;
String shipmentNumber;
String senderFCSID;
String senderName;
String receiverFCSID;
String receiverName;
String receiverAddress;
String receiverNumber;
String boxNumber;
String status;
String cargoDesc;
int width;
int height;
int length;
int shipmentWeight;
int rate;
int weight;
String packageType;
String pickUpID;
List<String> photos;
String remark;
DateTime arrivedDate;
List<Package> packages;
List<Cargo> cargoTypes;
ShippingAddress shippingAddress;
int get amount => rate != null && weight != null ? rate * weight : 0;
String get packageNumber =>
shipmentNumber + "-" + receiverNumber + " #" + boxNumber;
double get price => rate.toDouble() * weight;
List<ShipmentStatus> shipmentHistory;
Box(
{this.id,
this.shipmentNumber,
this.senderFCSID,
this.senderName,
this.receiverFCSID,
this.receiverName,
this.receiverNumber,
this.receiverAddress,
this.boxNumber,
this.width,
this.height,
this.length,
this.shipmentWeight,
this.rate,
this.weight,
this.packageType,
this.pickUpID,
this.remark,
this.status,
this.arrivedDate,
this.cargoDesc,
this.shipmentHistory,
this.packages,
this.cargoTypes,
this.shippingAddress});
}

View File

@@ -0,0 +1,6 @@
class Cargo {
String type;
int price;
int weight;
Cargo({this.type, this.price, this.weight});
}

View File

@@ -0,0 +1,5 @@
class Connectivity {
get isConnected {
return true;
}
}

View File

@@ -0,0 +1,6 @@
class Custom{
String id;
String productType;
int fee;
Custom({this.productType,this.fee});
}

View File

@@ -0,0 +1,36 @@
class Customer {
String id;
String name;
String phoneNumber;
String status;
Customer({
this.id,
this.name,
this.status,
this.phoneNumber,
});
factory Customer.fromMap(Map<String, dynamic> map, String docID) {
return Customer(
id: docID,
name: map['user_name'],
phoneNumber: map['phone_number'],
status: map['status'],
);
}
Map<String, dynamic> toMap() {
return {
'user_name': name,
'phone_number': phoneNumber,
};
}
@override
String toString() {
return 'Customer{name: $name, phoneNumber: $phoneNumber,statis:$status}';
}
}

View File

@@ -0,0 +1,16 @@
class Discount {
String code;
String customer;
String status;
double amount;
int weight;
double discountRate;
Discount(
{this.code,
this.customer,
this.amount,
this.status,
this.weight,
this.discountRate});
}

View File

@@ -0,0 +1,6 @@
class DiscountRate {
int weight;
double discountRate;
DiscountRate({this.weight, this.discountRate});
}

View File

@@ -0,0 +1,58 @@
class FAQ {
String id;
int sn;
String questionEng;
String questionMm;
String answerEng;
String answerMm;
String pageLinkLabelEng;
String pageLinkLabelMm;
String pageLink;
String question(bool isEng) => isEng ? questionEng : questionMm;
String answer(bool isEng) => isEng ? answerEng : answerMm;
FAQ(
{this.id,
this.sn,
this.questionEng,
this.questionMm,
this.answerEng,
this.answerMm,
this.pageLinkLabelEng,
this.pageLinkLabelMm,
this.pageLink});
Map<String, dynamic> toMap() {
return {
'id': id,
'sn': sn,
'question_eng': questionEng,
'answer_eng': answerEng,
'question_mm': questionMm,
'answer_mm': answerMm,
'page_link_label_eng': pageLinkLabelEng,
'page_link_label_mm': pageLinkLabelMm,
'page_link': pageLink,
};
}
factory FAQ.fromMap(Map<String, dynamic> map, String id) {
return FAQ(
id: id,
sn: map['sn'],
questionEng: map['question_eng'],
answerEng: map['answer_eng'],
questionMm: map['question_mm'],
answerMm: map['answer_mm'],
pageLinkLabelEng: map['page_link_label_eng'],
pageLinkLabelMm: map['page_link_label_mm'],
pageLink: map['page_link'],
);
}
@override
String toString() {
return 'FAQ{id: $id, questionEng: $questionEng,questionMm:$questionMm}';
}
}

View File

@@ -0,0 +1,32 @@
import 'package.dart';
import 'receipt.dart';
class Invoice {
String invoiceNumber;
DateTime invoiceDate;
String customerName;
String customerPhoneNumber;
double amount;
String discount;
String status;
String paymentAttachment;
List<Package> packages;
List<Receipt> receipts;
List<String> receiptPhotos;
Invoice(
{this.invoiceNumber,
this.invoiceDate,
this.customerName,
this.customerPhoneNumber,
this.amount,
this.discount,
this.status,
this.paymentAttachment,
this.packages,
this.receiptPhotos,
this.receipts});
double get getAmount => packages.fold(0, (p, e) => (e.rate * e.weight) + p);
}

View File

@@ -0,0 +1,28 @@
class Market {
String id;
String name;
Market({
this.id,
this.name,
});
Map<String, dynamic> toMap() {
return {
'id': id,
'name': name,
};
}
factory Market.fromMap(Map<String, dynamic> map, String id) {
return Market(
id: id,
name: map['name'],
);
}
@override
String toString() {
return 'Market{id: $id, name: $name}';
}
}

View File

@@ -0,0 +1,125 @@
import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:fcs/domain/vo/shipment_status.dart';
class Package {
String id;
String trackingID;
String userID;
String fcsID;
String userName;
String phoneNumber;
String currentStatus;
DateTime currentStatusDate;
List<String> photoUrls;
List<ShipmentStatus> shipmentHistory;
String desc;
String status;
String shipmentNumber;
String senderFCSID;
String senderName;
String receiverFCSID;
String receiverName;
String receiverAddress;
String receiverNumber;
String boxNumber;
String cargoDesc;
String market;
int rate;
int weight;
String packageType;
String pickUpID;
List<String> photos;
String remark;
DateTime arrivedDate;
int get amount => rate != null && weight != null ? rate * weight : 0;
String get packageNumber =>
shipmentNumber + "-" + receiverNumber + " #" + boxNumber;
double get price => rate.toDouble() * weight;
Package({
this.id,
this.trackingID,
this.userID,
this.userName,
this.fcsID,
this.phoneNumber,
this.shipmentNumber,
this.senderFCSID,
this.senderName,
this.receiverFCSID,
this.receiverName,
this.receiverNumber,
this.receiverAddress,
this.boxNumber,
this.rate,
this.weight,
this.packageType,
this.pickUpID,
this.remark,
this.status,
this.arrivedDate,
this.cargoDesc,
this.market,
this.shipmentHistory,
this.currentStatus,
this.currentStatusDate,
this.photoUrls,
this.desc,
});
factory Package.fromMap(Map<String, dynamic> map, String docID) {
var _currentStatusDate = (map['current_status_date'] as Timestamp);
List<ShipmentStatus> _shipmentStatus = List.from(map['all_status'])
.map((e) => ShipmentStatus.fromMap(Map<String, dynamic>.from(e)))
.toList();
List<String> _photoUrls =
map['photo_urls'] == null ? [] : List.from(map['photo_urls']);
return Package(
id: docID,
userID: map['user_id'],
fcsID: map['fcs_id'],
trackingID: map['tracking_id'],
market: map['market'],
userName: map['user_name'],
phoneNumber: map['phone_number'],
remark: map['remark'],
desc: map['desc'],
currentStatus: map['current_status'],
currentStatusDate:
_currentStatusDate != null ? _currentStatusDate.toDate() : null,
photoUrls: _photoUrls,
shipmentHistory: _shipmentStatus);
}
Map<String, dynamic> toJson() => {
'id': id,
'tracking_id': trackingID,
'market': market,
'fcs_id': fcsID,
"desc": desc,
"remark": remark,
"photo_urls": photoUrls
};
factory Package.fromJson(Map<String, dynamic> json) {
return Package(
id: json['id'],
trackingID: json['tracking_id'],
market: json['market'],
userName: json['user_name'],
phoneNumber: json['phone_number'],
currentStatus: json['current_status'],
currentStatusDate: DateTime.parse(json['current_status_date']));
}
@override
String toString() {
return 'Package{id: $id, currentStatus: $currentStatus, market:$market, trackingID: $trackingID,}';
}
}

View File

@@ -0,0 +1,42 @@
class PaymentMethod {
String id;
String name;
String accountName;
String account;
String phone;
String email;
String link;
PaymentMethod(
{this.id,
this.name,
this.accountName,
this.account,
this.phone,
this.email,
this.link});
factory PaymentMethod.fromMap(Map<String, dynamic> map, String id) {
return PaymentMethod(
id: id,
name: map['name'],
accountName: map['account_name'],
account: map['account'],
phone: map['phone'],
email: map['email'],
link: map['link'],
);
}
Map<String, dynamic> toMap() {
return {
'id': id,
'name': name,
"account_name": accountName,
"account": account,
"phone": phone,
"email": email,
"link": link,
};
}
}

View File

@@ -0,0 +1,54 @@
import 'cargo.dart';
class PickUp {
String id;
String userName;
String phoneNumber;
String fromTime;
String toTime;
int numberOfPackage;
int weight;
int handlingFee;
String address;
String status;
DateTime date;
List<Cargo> cargoTypes;
bool isCourier;
int radioIndex;
PickUp(
{this.id,
this.userName,
this.phoneNumber,
this.fromTime,
this.toTime,
this.numberOfPackage,
this.weight,
this.handlingFee,
this.address,
this.status,
this.date,
this.cargoTypes,
this.isCourier = false,
this.radioIndex = 1});
int get last => DateTime.now().difference(date).inDays;
factory PickUp.fromMap(Map<String, dynamic> map, String id) {
return PickUp(
id: id,
userName: map['user_name'],
phoneNumber: map['phone_number'],
fromTime: map['from_time'],
toTime: map['to_time'],
numberOfPackage: map['number_of_package'],
weight: map['weight'],
address: map['address'],
status: map['status']);
}
@override
String toString() {
return 'PickUp{id:$id, userName:$userName,phoneNumber:$phoneNumber,fromTime:$fromTime,toTime:$toTime,numberOfPackage:$numberOfPackage,weight:$weight,status:$status}';
}
}

View File

@@ -0,0 +1,31 @@
class Rate {
String id;
String name;
String description;
String fromTime;
String toTime;
int price;
Rate(
{this.id,
this.name,
this.description,
this.fromTime,
this.toTime,
this.price,});
factory Rate.fromMap(Map<String, dynamic> map, String id) {
return Rate(
id: id,
name: map['name'],
description: map['description'],
fromTime: map['from_time'],
toTime: map['to_time'],
price: map['price'],);
}
@override
String toString() {
return 'Rate{id:$id, name:$name,description:$description,fromTime:$fromTime,toTime:$toTime}';
}
}

View File

@@ -0,0 +1,6 @@
class Receipt {
int amount;
DateTime date;
Receipt({this.amount, this.date});
}

View File

@@ -0,0 +1,67 @@
class Role {
String roleID;
String roleName;
String privileges;
Role({this.roleName, this.roleID, this.privileges});
Role.fromJson(Map<String, dynamic> json) {
roleName = json['role_name'];
roleID = json['role_id'];
privileges = json['privileges'];
}
}
class Parser {
String status;
String message;
Role data;
Parser({this.status, this.message, this.data});
Parser.fromJson(Map<String, dynamic> json) {
status = json['status'];
message = json['message'];
if (json['status'] == 'Ok') {
data = Role.fromJson(json['data']);
}
}
}
class StatusParser {
String status;
String message;
StatusParser(this.status, this.message);
StatusParser.fromJson(Map<String, dynamic> json) {
status = json['status'];
message = json['message'];
}
}
class Privilege {
String id;
String name;
String desc;
bool sysAdminOnly = true;
bool isChecked = false;
Privilege({this.id, this.name, this.desc, this.isChecked, this.sysAdminOnly});
factory Privilege.fromMap(Map<String, dynamic> map, String docID) {
return Privilege(
id: docID,
name: map['name'],
desc: map['desc'],
sysAdminOnly: map['sys_admin_only']);
}
}
class UserLevel {
String id;
String name;
int level;
UserLevel({this.id, this.name, this.level});
factory UserLevel.fromMap(Map<String, dynamic> map, String docID) {
return UserLevel(id: docID, name: map['name'], level: map['level']);
}
}

View File

@@ -0,0 +1,192 @@
import 'package:cloud_firestore/cloud_firestore.dart';
import 'bank_account.dart';
List<Day> dayLists = [
Day(id: 1, name: 'Sun'),
Day(id: 2, name: 'Mon'),
Day(id: 3, name: 'Tue'),
Day(id: 4, name: 'Wed'),
Day(id: 5, name: 'Thu'),
Day(id: 6, name: 'Fri'),
Day(id: 7, name: 'Sat'),
];
class Setting {
final int supportBuildNum;
// contact page
String usaAddress;
String mmAddress;
String usaContactNumber;
String mmContactNumber;
String emailAddress;
String facebookLink;
bool inviteRequired;
String appUrl;
final String termsEng;
final String termsMm;
final String okEnergyId;
final String about;
int poExpireInHours;
int doExpireInHours;
int poOpenAt;
int poCloseAt;
List<int> poCloseOn;
int latestDeliveryDay;
int firstStorageChargeIn;
int firstStorageCharge;
int secondStorageChargeIn;
int secondStorageCharge;
int deliveryStartWaitMin;
String reportURL;
String helpVersion;
String helpURL;
List<String> phones;
String deliveryPhone;
String address;
String website;
DateTime priceLastUpdate;
String bankAccountInfo;
List<BankAccount> bankAccounts;
String get getPoOpenAt => poOpenAt > 12
? (poOpenAt - 12).toString() + "PM"
: poOpenAt.toString() + "AM";
String get getPoCloseAt => poCloseAt > 12
? (poCloseAt - 12).toString() + "PM"
: poCloseAt.toString() + "AM";
String get getPoCloseOn => poCloseOn.fold(
"", (p, e) => p + (p == "" ? "" : ", ") + dayLists[e - 1].name);
String get getPoOpenOn => dayLists.fold(
"",
(p, e) =>
p +
(p == "" ? "" : poCloseOn.contains(e.id) ? "" : ", ") +
(poCloseOn.contains(e.id) ? "" : e.name));
bool get isPOClose {
DateTime now = DateTime.now();
// dart starts from monday width starting index one
// server starts from sunday with starting index one
var day = (now.weekday + 1) == 8 ? 1 : now.weekday + 1;
return poCloseOn.contains(day) ||
(now.hour < poOpenAt || now.hour >= poCloseAt);
}
Setting(
{this.supportBuildNum,
this.usaAddress,
this.mmAddress,
this.usaContactNumber,
this.mmContactNumber,
this.emailAddress,
this.facebookLink,
this.inviteRequired,
this.appUrl,
this.termsEng,
this.termsMm,
this.about,
this.okEnergyId,
this.poExpireInHours,
this.doExpireInHours,
this.poOpenAt,
this.poCloseAt,
this.poCloseOn,
this.latestDeliveryDay,
this.firstStorageCharge,
this.firstStorageChargeIn,
this.secondStorageCharge,
this.secondStorageChargeIn,
this.deliveryStartWaitMin,
this.reportURL,
this.helpVersion,
this.helpURL,
this.phones,
this.website,
this.priceLastUpdate,
this.bankAccountInfo,
this.bankAccounts,
this.deliveryPhone,
this.address});
factory Setting.fromMap(Map<String, dynamic> map) {
var ts = (map['price_last_update'] as Timestamp);
var list = (map['bank_accounts'] as List);
List<BankAccount> bankAccounts = [];
if (list != null) {
list.asMap().forEach((index, item) {
bankAccounts
.add(BankAccount.fromMap(index, item.cast<String, dynamic>()));
});
}
return Setting(
supportBuildNum: map['support_build_number'],
inviteRequired: map['invite_required'],
appUrl: map['app_url'],
usaAddress: map['usa_address'],
mmAddress: map['mm_address'],
usaContactNumber: map['usa_contact_number'],
mmContactNumber: map['mm_contact_number'],
emailAddress: map['email_address'],
facebookLink: map['facebook_link'],
about: map['about'],
termsEng: map['terms_eng'],
termsMm: map['terms_mm'],
priceLastUpdate: ts?.toDate(),
okEnergyId: map['ok_energy_id'],
poExpireInHours: map['po_expire_hours'],
doExpireInHours: map['do_expire_hours'],
poOpenAt: map['po_open_at'],
poCloseAt: map['po_close_at'],
latestDeliveryDay: map['latest_delivery_days'],
firstStorageChargeIn: map['first_storage_charge_in'],
firstStorageCharge: map['first_storage_charge'],
secondStorageChargeIn: map['second_storage_charge_in'],
secondStorageCharge: map['second_storage_charge'],
deliveryStartWaitMin: map['delivery_start_wait_min'],
reportURL: map['report_url'],
helpVersion: map['help_version'],
helpURL: map['help_url'],
deliveryPhone: map['delivery_phone'],
address: map['address'],
website: map['website'],
bankAccountInfo: map['bank_account_info'],
bankAccounts: bankAccounts);
}
Map<String, dynamic> toMap() {
return {
'terms_eng': termsEng,
'terms_mm': termsMm,
};
}
String helpFileName() {
return "help-v$helpVersion.zip";
}
@override
String toString() {
return 'Setting{supportBuildNum:$supportBuildNum,about:$about,okEnergyId:$okEnergyId}';
}
}
class Day {
int id;
String name;
bool isChecked = false;
Day({this.id, this.name, this.isChecked});
@override
String toString() {
return 'Day{id:$id,name:$name,isChecked:$isChecked}';
}
}

View File

@@ -0,0 +1,25 @@
class Shipment {
DateTime shipDate;
String shipmentNumber;
DateTime cutoffDate;
String shipType;
DateTime arrivalDate;
DateTime departureDate;
String consignee;
String port;
String destination;
String status;
String remark;
Shipment(
{this.shipDate,
this.shipmentNumber,
this.cutoffDate,
this.shipType,
this.status,
this.arrivalDate,
this.departureDate,
this.consignee,
this.port,
this.destination,
this.remark});
}

View File

@@ -0,0 +1,159 @@
import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:fcs/helpers/const.dart';
import 'package:flutter/foundation.dart';
import 'package:intl/intl.dart';
DateFormat dayFormat = DateFormat("MMM dd yyyy");
DateFormat timeFormat = DateFormat("HH:mm");
final DateFormat dateFormat = DateFormat("d MMM yyyy");
class User {
String id;
String name;
String phoneNumber;
String status;
String fcsID;
DateTime lastMessageTime;
String lastMessage;
int userUnseenCount;
int fcsUnseenCount;
String get initial => name != null && name != "" ? name.substring(0, 1) : "?";
String get getLastMessage {
var msg = lastMessage ?? "Say hi to $name";
if (msg.length > 30) return msg.substring(0, 30) + " ... ";
return msg;
}
String get getLastMessageTime {
if (lastMessageTime == null) return "";
DateTime today = DateTime.now();
if (lastMessageTime.year == today.year &&
lastMessageTime.month == today.month &&
lastMessageTime.day == today.day) {
return timeFormat.format(lastMessageTime);
} else {
return dateFormat.format(lastMessageTime);
}
}
String get getUserUnseenCount => userUnseenCount != null
? userUnseenCount > 100 ? "99+" : userUnseenCount.toString()
: "0";
String get getFcsUnseenCount => fcsUnseenCount != null
? fcsUnseenCount > 100 ? "99+" : fcsUnseenCount.toString()
: "0";
List<String> privileges = [];
String get phone => phoneNumber != null && phoneNumber.startsWith("959")
? "0${phoneNumber.substring(2)}"
: phoneNumber;
bool get joined => status != null && status == userStatusJoined;
bool get invited => status != null && status == userStatusInvited;
bool get requested => status != null && status == userStatusRequested;
String get share => "Your phone number:$phoneNumber";
User(
{this.id,
this.name,
this.phoneNumber,
this.fcsID,
this.status,
this.privileges,
this.lastMessage,
this.lastMessageTime,
this.userUnseenCount,
this.fcsUnseenCount});
factory User.fromJson(Map<String, dynamic> json) {
return User(
id: json['id'],
name: json['user_name'],
fcsID: json['fcs_id'],
phoneNumber: json['phone_number'],
status: json['status'],
lastMessage: json['last_message'],
);
}
Map<String, dynamic> toJson() => {
'id': id,
'user_name': name,
'phone_number': phoneNumber,
};
Map<String, dynamic> toMap() {
return {
'user_name': name,
'phone_number': phoneNumber,
};
}
factory User.fromMap(Map<String, dynamic> map, String docID) {
var _date = (map['message_time'] as Timestamp);
List<String> _privileges =
map['privileges'] == null ? [] : map['privileges'].cast<String>();
return User(
id: docID,
name: map['user_name'],
phoneNumber: map['phone_number'],
status: map['status'],
fcsID: map['fcs_id'],
privileges: _privileges,
lastMessage: map['last_message'],
userUnseenCount: map['user_unseen_count'],
fcsUnseenCount: map['fcs_unseen_count'],
lastMessageTime: _date == null ? null : _date.toDate());
}
bool diffPrivileges(User another) {
another.privileges.sort((a, b) => a.compareTo(b));
privileges.sort((a, b) => a.compareTo(b));
return !listEquals(another.privileges, privileges);
}
bool isCustomer() {
return privileges == null || privileges.length == 0;
}
bool hasSysAdmin() {
return privileges != null ? privileges.contains('sa') : false;
}
bool hasAdmin() {
return privileges != null ? privileges.contains('admin') : false;
}
bool hasCustomers() {
return hasSysAdmin() ||
hasAdmin() ||
(privileges != null ? privileges.contains('c') : false);
}
bool hasStaffs() {
return hasSysAdmin() ||
hasAdmin() ||
(privileges != null ? privileges.contains('s') : false);
}
bool hasSupport() {
return hasSysAdmin() ||
hasAdmin() ||
(privileges != null ? privileges.contains('sp') : false);
}
bool hasPackages() {
return hasSysAdmin() ||
hasAdmin() ||
status == userStatusJoined ||
(privileges != null ? privileges.contains('p') : false);
}
@override
String toString() {
return 'User{id:$id, name: $name, phoneNumber: $phoneNumber,status:$status}';
}
}