2020-05-29 07:45:27 +06:30
|
|
|
import 'package:flutter/cupertino.dart';
|
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
|
import 'package:intl/intl.dart';
|
|
|
|
|
import 'package:provider/provider.dart';
|
|
|
|
|
import 'package:fcs/model/main_model.dart';
|
|
|
|
|
import 'package:fcs/model/po_model.dart';
|
2020-09-04 15:30:10 +06:30
|
|
|
import 'package:fcs/fcs/common/helpers/theme.dart';
|
2020-05-29 07:45:27 +06:30
|
|
|
import 'package:fcs/vo/po.dart';
|
|
|
|
|
import 'package:fcs/widget/local_text.dart';
|
|
|
|
|
import 'package:fcs/widget/my_data_table.dart';
|
|
|
|
|
import 'package:fcs/widget/number_cell.dart';
|
|
|
|
|
import 'package:fcs/widget/progress.dart';
|
|
|
|
|
|
|
|
|
|
class RevenueLineDetail extends StatefulWidget {
|
|
|
|
|
final DateTime date;
|
|
|
|
|
const RevenueLineDetail(this.date);
|
|
|
|
|
@override
|
|
|
|
|
_RevenueLineDetailState createState() => _RevenueLineDetailState();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class _RevenueLineDetailState extends State<RevenueLineDetail> {
|
|
|
|
|
final numberFormatter = new NumberFormat("#,###");
|
|
|
|
|
var dateFormatter = new DateFormat('dd-MMM-yyyy');
|
|
|
|
|
bool _isLoading = false;
|
|
|
|
|
List<POSubmission> pos = [];
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
void initState() {
|
|
|
|
|
super.initState();
|
|
|
|
|
POSubmissionModel pOModel =
|
|
|
|
|
Provider.of<POSubmissionModel>(context, listen: false);
|
|
|
|
|
pOModel.getPOForRevenue(widget.date).then((pos) {
|
|
|
|
|
if (mounted) {
|
|
|
|
|
setState(() {
|
|
|
|
|
this.pos = pos;
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
|
var mainModel = Provider.of<MainModel>(context);
|
|
|
|
|
return LocalProgress(
|
|
|
|
|
inAsyncCall: _isLoading,
|
|
|
|
|
child: Scaffold(
|
|
|
|
|
appBar: AppBar(
|
|
|
|
|
backgroundColor: primaryColor,
|
|
|
|
|
title: mainModel.user.isOwnerAndAbove()
|
|
|
|
|
? LocalText(
|
|
|
|
|
context,
|
|
|
|
|
'revenue.detail.title',
|
|
|
|
|
translationVariables: [dateFormatter.format(widget.date)],
|
|
|
|
|
color: Colors.white,
|
|
|
|
|
fontSize: 18,
|
|
|
|
|
)
|
|
|
|
|
: LocalText(
|
|
|
|
|
context,
|
|
|
|
|
'spending.detail.title',
|
|
|
|
|
translationVariables: [dateFormatter.format(widget.date)],
|
|
|
|
|
color: Colors.white,
|
|
|
|
|
fontSize: 18,
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
body: Container(
|
|
|
|
|
padding: EdgeInsets.only(top: 5),
|
|
|
|
|
child: SingleChildScrollView(
|
|
|
|
|
scrollDirection: Axis.vertical,
|
|
|
|
|
child: SingleChildScrollView(
|
|
|
|
|
scrollDirection: Axis.horizontal,
|
|
|
|
|
padding: EdgeInsets.only(left: 3),
|
|
|
|
|
child: MyDataTable(
|
|
|
|
|
columnSpacing: 20,
|
|
|
|
|
columns: [
|
|
|
|
|
MyDataColumn(label: LocalText(context, "po.name")),
|
|
|
|
|
MyDataColumn(label: LocalText(context, "po.po_num")),
|
|
|
|
|
MyDataColumn(
|
|
|
|
|
label: LocalText(context, "po.amount"), numeric: true),
|
|
|
|
|
],
|
|
|
|
|
rows: getProductRow(),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
List<MyDataRow> getProductRow() {
|
|
|
|
|
return pos.map((p) {
|
|
|
|
|
var r = MyDataRow(
|
|
|
|
|
cells: [
|
|
|
|
|
MyDataCell(
|
|
|
|
|
new Text(p.userName, style: textStyle),
|
|
|
|
|
),
|
|
|
|
|
MyDataCell(
|
|
|
|
|
new Text(p.poNumber, style: textStyle),
|
|
|
|
|
),
|
|
|
|
|
MyDataCell(NumberCell(p.amount)),
|
|
|
|
|
],
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
return r;
|
|
|
|
|
}).toList();
|
|
|
|
|
}
|
|
|
|
|
}
|