|
|
@ -9,10 +9,9 @@ import 'package:test_sa/controllers/providers/api/user_provider.dart';
|
|
|
|
import 'package:test_sa/controllers/providers/settings/setting_provider.dart';
|
|
|
|
import 'package:test_sa/controllers/providers/settings/setting_provider.dart';
|
|
|
|
import 'package:test_sa/controllers/validator/validator.dart';
|
|
|
|
import 'package:test_sa/controllers/validator/validator.dart';
|
|
|
|
import 'package:test_sa/extensions/context_extension.dart';
|
|
|
|
import 'package:test_sa/extensions/context_extension.dart';
|
|
|
|
import 'package:test_sa/models/gas_refill/gas_refill_details.dart';
|
|
|
|
import 'package:test_sa/extensions/int_extensions.dart';
|
|
|
|
import 'package:test_sa/models/gas_refill/gas_refill_model.dart';
|
|
|
|
import 'package:test_sa/extensions/widget_extensions.dart';
|
|
|
|
import 'package:test_sa/models/lookup.dart';
|
|
|
|
import 'package:test_sa/models/lookup.dart';
|
|
|
|
import 'package:test_sa/models/subtitle.dart';
|
|
|
|
|
|
|
|
import 'package:test_sa/models/timer_model.dart';
|
|
|
|
import 'package:test_sa/models/timer_model.dart';
|
|
|
|
import 'package:test_sa/views/app_style/sizing.dart';
|
|
|
|
import 'package:test_sa/views/app_style/sizing.dart';
|
|
|
|
import 'package:test_sa/views/widgets/app_text_form_field.dart';
|
|
|
|
import 'package:test_sa/views/widgets/app_text_form_field.dart';
|
|
|
@ -29,10 +28,14 @@ import 'package:test_sa/views/widgets/status/gas_refill/gas_status.dart';
|
|
|
|
import 'package:test_sa/views/widgets/status/gas_refill/gas_type.dart';
|
|
|
|
import 'package:test_sa/views/widgets/status/gas_refill/gas_type.dart';
|
|
|
|
import 'package:test_sa/views/widgets/titles/app_sub_title.dart';
|
|
|
|
import 'package:test_sa/views/widgets/titles/app_sub_title.dart';
|
|
|
|
|
|
|
|
|
|
|
|
import '../../../../controllers/localization/localization.dart';
|
|
|
|
|
|
|
|
import '../../../../controllers/providers/api/hospitals_provider.dart';
|
|
|
|
import '../../../../controllers/providers/api/hospitals_provider.dart';
|
|
|
|
import '../../../widgets/e_signature/e_signature.dart';
|
|
|
|
import '../../../../extensions/text_extensions.dart';
|
|
|
|
import '../../../widgets/timer/app_timer.dart';
|
|
|
|
import '../../../../models/new_models/gas_refill_model.dart';
|
|
|
|
|
|
|
|
import '../../../../new_views/common_widgets/app_text_form_field.dart';
|
|
|
|
|
|
|
|
import '../../../../new_views/common_widgets/default_app_bar.dart';
|
|
|
|
|
|
|
|
import '../../../../new_views/common_widgets/single_item_drop_down_menu.dart';
|
|
|
|
|
|
|
|
import '../../../../providers/gas_request_providers/gas_status_provider.dart';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class RequestGasRefill extends StatefulWidget {
|
|
|
|
class RequestGasRefill extends StatefulWidget {
|
|
|
|
static const String id = "/request-gas-refill";
|
|
|
|
static const String id = "/request-gas-refill";
|
|
|
@ -52,9 +55,11 @@ class _RequestGasRefillState extends State<RequestGasRefill> {
|
|
|
|
SettingProvider _settingProvider;
|
|
|
|
SettingProvider _settingProvider;
|
|
|
|
GasRefillProvider _gasRefillProvider;
|
|
|
|
GasRefillProvider _gasRefillProvider;
|
|
|
|
GasRefillDetails _currentDetails = GasRefillDetails();
|
|
|
|
GasRefillDetails _currentDetails = GasRefillDetails();
|
|
|
|
final TextEditingController _requestedQuantityController = TextEditingController();
|
|
|
|
|
|
|
|
final TextEditingController _deliveredQuantityController = TextEditingController();
|
|
|
|
final TextEditingController _deliveredQuantityController = TextEditingController();
|
|
|
|
GasRefillModel _formModel = GasRefillModel(details: []);
|
|
|
|
final TextEditingController _commentController = TextEditingController();
|
|
|
|
|
|
|
|
final TextEditingController _workingHoursController = TextEditingController();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
GasRefillModel _formModel = GasRefillModel(gazRefillDetails: []);
|
|
|
|
final GlobalKey<FormState> _formKey = GlobalKey<FormState>();
|
|
|
|
final GlobalKey<FormState> _formKey = GlobalKey<FormState>();
|
|
|
|
final GlobalKey _DetailsKey = GlobalKey<FormState>();
|
|
|
|
final GlobalKey _DetailsKey = GlobalKey<FormState>();
|
|
|
|
final GlobalKey<ScaffoldState> _scaffoldKey = GlobalKey<ScaffoldState>();
|
|
|
|
final GlobalKey<ScaffoldState> _scaffoldKey = GlobalKey<ScaffoldState>();
|
|
|
@ -73,26 +78,27 @@ class _RequestGasRefillState extends State<RequestGasRefill> {
|
|
|
|
if (mounted) super.setState(() {});
|
|
|
|
if (mounted) super.setState(() {});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
_onSubmit() async {
|
|
|
|
_onSubmit(BuildContext context) async {
|
|
|
|
if (_formModel.details.isEmpty) {
|
|
|
|
if (_formModel.gazRefillDetails.isEmpty) {
|
|
|
|
if (!_addNewModel()) return;
|
|
|
|
if (!(await _addNewModel(context))) return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
_isLoading = true;
|
|
|
|
//_isLoading = true;
|
|
|
|
setState(() {});
|
|
|
|
|
|
|
|
if (widget.gasRefillModel != null) {
|
|
|
|
|
|
|
|
if (!_formModel.validate()) {
|
|
|
|
|
|
|
|
_isLoading = false;
|
|
|
|
|
|
|
|
setState(() {});
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (_gasRefillProvider.department?.name == null) {
|
|
|
|
|
|
|
|
ScaffoldMessenger.of(context).showSnackBar(const SnackBar(content: Text("Select department")));
|
|
|
|
|
|
|
|
_isLoading = false;
|
|
|
|
|
|
|
|
setState(() {});
|
|
|
|
setState(() {});
|
|
|
|
return;
|
|
|
|
// if (widget.gasRefillModel != null) {
|
|
|
|
}
|
|
|
|
// if (!(await _formModel.validate(context))) {
|
|
|
|
|
|
|
|
// _isLoading = false;
|
|
|
|
|
|
|
|
// setState(() {});
|
|
|
|
|
|
|
|
// return;
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
//if(!(_formKey.currentState.validate())) return;
|
|
|
|
|
|
|
|
// if (_gasRefillProvider.department?.name == null) {
|
|
|
|
|
|
|
|
// ScaffoldMessenger.of(context).showSnackBar(const SnackBar(content: Text("Select department")));
|
|
|
|
|
|
|
|
// _isLoading = false;
|
|
|
|
|
|
|
|
// setState(() {});
|
|
|
|
|
|
|
|
// return;
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
int status = widget.gasRefillModel == null
|
|
|
|
int status = widget.gasRefillModel == null
|
|
|
|
? null /*await _gasRefillProvider.createModel(
|
|
|
|
? null /*await _gasRefillProvider.createModel(
|
|
|
@ -105,7 +111,7 @@ class _RequestGasRefillState extends State<RequestGasRefill> {
|
|
|
|
oldModel: widget.gasRefillModel,
|
|
|
|
oldModel: widget.gasRefillModel,
|
|
|
|
newModel: _formModel,
|
|
|
|
newModel: _formModel,
|
|
|
|
);
|
|
|
|
);
|
|
|
|
_isLoading = false;
|
|
|
|
//_isLoading = false;
|
|
|
|
setState(() {});
|
|
|
|
setState(() {});
|
|
|
|
if (status >= 200 && status < 300) {
|
|
|
|
if (status >= 200 && status < 300) {
|
|
|
|
Fluttertoast.showToast(
|
|
|
|
Fluttertoast.showToast(
|
|
|
@ -121,23 +127,24 @@ class _RequestGasRefillState extends State<RequestGasRefill> {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool _addNewModel() {
|
|
|
|
Future<bool> _addNewModel(BuildContext context) async {
|
|
|
|
_validate = true;
|
|
|
|
_validate = true;
|
|
|
|
if (!_formKey.currentState.validate()) {
|
|
|
|
if (!_formKey.currentState.validate()) {
|
|
|
|
setState(() {});
|
|
|
|
setState(() {});
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
_formKey.currentState.save();
|
|
|
|
_formKey.currentState.save();
|
|
|
|
if (!_currentDetails.validate()) {
|
|
|
|
if (!(await _currentDetails.validate(context))) {
|
|
|
|
setState(() {});
|
|
|
|
setState(() {});
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
_formModel.details.insert(0, _currentDetails);
|
|
|
|
_formModel.gazRefillDetails.insert(0, _currentDetails);
|
|
|
|
_validate = false;
|
|
|
|
_validate = false;
|
|
|
|
Scrollable.ensureVisible(_DetailsKey.currentContext);
|
|
|
|
Scrollable.ensureVisible(_DetailsKey.currentContext);
|
|
|
|
_requestedQuantityController.clear();
|
|
|
|
|
|
|
|
_deliveredQuantityController.clear();
|
|
|
|
_deliveredQuantityController.clear();
|
|
|
|
|
|
|
|
_workingHoursController.clear();
|
|
|
|
|
|
|
|
_commentController.clear();
|
|
|
|
_currentDetails = GasRefillDetails();
|
|
|
|
_currentDetails = GasRefillDetails();
|
|
|
|
setState(() {});
|
|
|
|
setState(() {});
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
@ -145,8 +152,9 @@ class _RequestGasRefillState extends State<RequestGasRefill> {
|
|
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
@override
|
|
|
|
void dispose() {
|
|
|
|
void dispose() {
|
|
|
|
_requestedQuantityController.dispose();
|
|
|
|
|
|
|
|
_deliveredQuantityController.dispose();
|
|
|
|
_deliveredQuantityController.dispose();
|
|
|
|
|
|
|
|
_commentController.dispose();
|
|
|
|
|
|
|
|
_workingHoursController.dispose();
|
|
|
|
super.dispose();
|
|
|
|
super.dispose();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -162,10 +170,10 @@ class _RequestGasRefillState extends State<RequestGasRefill> {
|
|
|
|
if (_firstTime) {
|
|
|
|
if (_firstTime) {
|
|
|
|
String _clientName;
|
|
|
|
String _clientName;
|
|
|
|
if (widget.gasRefillModel != null) {
|
|
|
|
if (widget.gasRefillModel != null) {
|
|
|
|
_formModel.status = widget.gasRefillModel?.status ?? Lookup(value: 0);
|
|
|
|
//_formModel.status = widget.gasRefillModel?.status ?? Lookup(value: 0);
|
|
|
|
_gasRefillProvider.expectedDateTime = _formModel.expectedDate;
|
|
|
|
_gasRefillProvider.expectedDateTime = DateTime.tryParse(_formModel.expectedDate??"");
|
|
|
|
_gasRefillProvider.timer = TimerModel(startAt: widget.gasRefillModel?.startDate, endAt: widget.gasRefillModel?.endDate);
|
|
|
|
_gasRefillProvider.timer = TimerModel(startAt: DateTime.tryParse(widget.gasRefillModel?.startDate??""), endAt: DateTime.tryParse(widget.gasRefillModel?.endDate??""));
|
|
|
|
_clientName = _formModel.clientName;
|
|
|
|
_clientName = _formModel.site.custName;
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
_gasRefillProvider.timer = null;
|
|
|
|
_gasRefillProvider.timer = null;
|
|
|
|
_clientName = _userProvider.user?.clientName;
|
|
|
|
_clientName = _userProvider.user?.clientName;
|
|
|
@ -181,6 +189,7 @@ class _RequestGasRefillState extends State<RequestGasRefill> {
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return Scaffold(
|
|
|
|
return Scaffold(
|
|
|
|
|
|
|
|
appBar: DefaultAppBar(title: context.translation.updateRequest),
|
|
|
|
key: _scaffoldKey,
|
|
|
|
key: _scaffoldKey,
|
|
|
|
body: Form(
|
|
|
|
body: Form(
|
|
|
|
key: _formKey,
|
|
|
|
key: _formKey,
|
|
|
@ -191,379 +200,92 @@ class _RequestGasRefillState extends State<RequestGasRefill> {
|
|
|
|
stateCode: 200,
|
|
|
|
stateCode: 200,
|
|
|
|
onRefresh: () async {},
|
|
|
|
onRefresh: () async {},
|
|
|
|
child: SingleChildScrollView(
|
|
|
|
child: SingleChildScrollView(
|
|
|
|
padding: EdgeInsets.all(12 * AppStyle.getScaleFactor(context)),
|
|
|
|
|
|
|
|
child: Column(
|
|
|
|
child: Column(
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
|
|
children: [
|
|
|
|
children: [
|
|
|
|
Center(
|
|
|
|
Column(
|
|
|
|
child: Padding(
|
|
|
|
|
|
|
|
padding: const EdgeInsets.all(8.0),
|
|
|
|
|
|
|
|
child: Text(
|
|
|
|
|
|
|
|
"${widget.gasRefillModel == null ? "Request" : "Update"} Gas Refill",
|
|
|
|
|
|
|
|
style: Theme.of(context).textTheme.headline5.copyWith(color: Theme.of(context).primaryColor, fontSize: 28, fontWeight: FontWeight.bold),
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
// const SizedBox(height: 4,),
|
|
|
|
|
|
|
|
// ASubTitle(context.translation.title),
|
|
|
|
|
|
|
|
// if(_validate && _formModel.title == null)
|
|
|
|
|
|
|
|
// ASubTitle(context.translation.requiredWord,color: Colors.red,),
|
|
|
|
|
|
|
|
// SizedBox(height: 4,),
|
|
|
|
|
|
|
|
// ATextFormField(
|
|
|
|
|
|
|
|
// initialValue: _formModel?.title,
|
|
|
|
|
|
|
|
// textAlign: TextAlign.center,
|
|
|
|
|
|
|
|
// style: Theme.of(context).textTheme.subtitle1,
|
|
|
|
|
|
|
|
// textInputType: TextInputType.text,
|
|
|
|
|
|
|
|
// onSaved: (value){
|
|
|
|
|
|
|
|
// _formModel.title = value;
|
|
|
|
|
|
|
|
// },
|
|
|
|
|
|
|
|
// ),
|
|
|
|
|
|
|
|
// const SizedBox(height: 8,),
|
|
|
|
|
|
|
|
ASubTitle(context.translation.status),
|
|
|
|
|
|
|
|
if (_validate && _formModel.status == null)
|
|
|
|
|
|
|
|
ASubTitle(
|
|
|
|
|
|
|
|
context.translation.requiredWord,
|
|
|
|
|
|
|
|
color: Colors.red,
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
const SizedBox(
|
|
|
|
|
|
|
|
height: 4,
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
GasStatusMenu(
|
|
|
|
|
|
|
|
initialValue: _formModel.status ?? Lookup(value: 0),
|
|
|
|
|
|
|
|
enabled: widget.gasRefillModel != null,
|
|
|
|
|
|
|
|
onSelect: (status) {
|
|
|
|
|
|
|
|
_formModel.status = status;
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
const SizedBox(
|
|
|
|
|
|
|
|
height: 8,
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
Divider(
|
|
|
|
|
|
|
|
color: Theme.of(context).colorScheme.primary,
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
const SizedBox(
|
|
|
|
|
|
|
|
height: 4,
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
HospitalAutoCompleteField(
|
|
|
|
|
|
|
|
enabled: false,
|
|
|
|
|
|
|
|
initialValue: _gasRefillProvider.hospital?.name,
|
|
|
|
|
|
|
|
// onSave: (value){
|
|
|
|
|
|
|
|
// _search.hospital = value;
|
|
|
|
|
|
|
|
// },
|
|
|
|
|
|
|
|
onSearch: (value) {
|
|
|
|
|
|
|
|
_gasRefillProvider.hospital = value;
|
|
|
|
|
|
|
|
_gasRefillProvider.building = null;
|
|
|
|
|
|
|
|
_gasRefillProvider.floor = null;
|
|
|
|
|
|
|
|
_gasRefillProvider.department = null;
|
|
|
|
|
|
|
|
setState(() {});
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
const SizedBox(
|
|
|
|
|
|
|
|
height: 8,
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
BuildingTypeMenu(
|
|
|
|
|
|
|
|
initialValue: _gasRefillProvider?.building,
|
|
|
|
|
|
|
|
building: _gasRefillProvider?.hospital?.buildings,
|
|
|
|
|
|
|
|
loading: _firstTime,
|
|
|
|
|
|
|
|
enabled: widget.gasRefillModel == null,
|
|
|
|
|
|
|
|
onSelect: (status) {
|
|
|
|
|
|
|
|
_gasRefillProvider.building = status;
|
|
|
|
|
|
|
|
setState(() {});
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
const SizedBox(height: 8),
|
|
|
|
|
|
|
|
FloorTypeMenu(
|
|
|
|
|
|
|
|
initialValue: _gasRefillProvider?.floor,
|
|
|
|
|
|
|
|
floors: _gasRefillProvider?.building?.floors,
|
|
|
|
|
|
|
|
enabled: widget.gasRefillModel == null,
|
|
|
|
|
|
|
|
loading: _firstTime,
|
|
|
|
|
|
|
|
onSelect: (status) {
|
|
|
|
|
|
|
|
_gasRefillProvider.floor = status;
|
|
|
|
|
|
|
|
setState(() {});
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
const SizedBox(height: 8),
|
|
|
|
|
|
|
|
DepartmentTypeMenu(
|
|
|
|
|
|
|
|
initialValue: _gasRefillProvider?.department,
|
|
|
|
|
|
|
|
departments: _gasRefillProvider?.floor?.departments,
|
|
|
|
|
|
|
|
loading: _firstTime,
|
|
|
|
|
|
|
|
enabled: widget.gasRefillModel == null,
|
|
|
|
|
|
|
|
onSelect: (status) {
|
|
|
|
|
|
|
|
_gasRefillProvider.department = status;
|
|
|
|
|
|
|
|
setState(() {});
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
const SizedBox(height: 8),
|
|
|
|
|
|
|
|
if (widget.gasRefillModel != null) ASubTitle(context.translation.workingHours),
|
|
|
|
|
|
|
|
if (widget.gasRefillModel != null) const SizedBox(height: 8),
|
|
|
|
|
|
|
|
if (widget.gasRefillModel != null)
|
|
|
|
|
|
|
|
Row(
|
|
|
|
|
|
|
|
children: [
|
|
|
|
children: [
|
|
|
|
Expanded(
|
|
|
|
Container(
|
|
|
|
child: AppTimer(
|
|
|
|
width: MediaQuery.of(context).size.width,
|
|
|
|
timer: _gasRefillProvider.timer,
|
|
|
|
decoration: ShapeDecoration(
|
|
|
|
onChange: (timer) async {
|
|
|
|
color: Colors.white,
|
|
|
|
_gasRefillProvider.timer = timer;
|
|
|
|
shape: RoundedRectangleBorder(
|
|
|
|
_formModel.workingHours = num.tryParse((((timer?.durationInSecond ?? 0) / 60) / 60)?.toStringAsFixed(2) ?? "0");
|
|
|
|
borderRadius: BorderRadius.circular(20),
|
|
|
|
_formModel.startDate = timer.startAt;
|
|
|
|
|
|
|
|
_formModel.endDate = timer.endAt;
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
),
|
|
|
|
),
|
|
|
|
|
|
|
|
shadows: const [BoxShadow(color: Color(0x07000000), blurRadius: 14, offset: Offset(0, 0), spreadRadius: 0)],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
],
|
|
|
|
child: Column(
|
|
|
|
),
|
|
|
|
|
|
|
|
//const SizedBox(height: 8),
|
|
|
|
|
|
|
|
// if (_userProvider.user?.type == UsersTypes.normal_user || widget.gasRefillModel != null)
|
|
|
|
|
|
|
|
// Column(
|
|
|
|
|
|
|
|
// crossAxisAlignment: CrossAxisAlignment.stretch,
|
|
|
|
|
|
|
|
// children: [
|
|
|
|
|
|
|
|
// const ASubTitle("Expected Date"),
|
|
|
|
|
|
|
|
// SizedBox(
|
|
|
|
|
|
|
|
// height: 8 * AppStyle.getScaleFactor(context),
|
|
|
|
|
|
|
|
// ),
|
|
|
|
|
|
|
|
// ADateTimePicker(
|
|
|
|
|
|
|
|
// date: _gasRefillProvider.expectedDateTime,
|
|
|
|
|
|
|
|
// from: DateTime.now().subtract(const Duration(days: 365)),
|
|
|
|
|
|
|
|
// to: DateTime.now().add(const Duration(days: 365)),
|
|
|
|
|
|
|
|
// onDateTimePicker: (date) {
|
|
|
|
|
|
|
|
// _gasRefillProvider.expectedDateTime = date;
|
|
|
|
|
|
|
|
// _formModel.expectedDate = _gasRefillProvider.expectedDateTime;
|
|
|
|
|
|
|
|
// setState(() {});
|
|
|
|
|
|
|
|
// },
|
|
|
|
|
|
|
|
// ),
|
|
|
|
|
|
|
|
// ],
|
|
|
|
|
|
|
|
// ),
|
|
|
|
|
|
|
|
// if (_userProvider.user?.type == UsersTypes.engineer)
|
|
|
|
|
|
|
|
// Column(
|
|
|
|
|
|
|
|
// children: [
|
|
|
|
|
|
|
|
// Row(
|
|
|
|
|
|
|
|
// children: [
|
|
|
|
|
|
|
|
// Expanded(
|
|
|
|
|
|
|
|
// child: Column(
|
|
|
|
|
|
|
|
// crossAxisAlignment: CrossAxisAlignment.stretch,
|
|
|
|
|
|
|
|
// children: [
|
|
|
|
|
|
|
|
// const ASubTitle("Start of Work"),
|
|
|
|
|
|
|
|
// SizedBox(
|
|
|
|
|
|
|
|
// height: 8 * AppStyle.getScaleFactor(context),
|
|
|
|
|
|
|
|
// ),
|
|
|
|
|
|
|
|
// ADateTimePicker(
|
|
|
|
|
|
|
|
// date: _gasRefillProvider.startDate,
|
|
|
|
|
|
|
|
// from: DateTime.now().subtract(const Duration(days: 365)),
|
|
|
|
|
|
|
|
// to: DateTime.now().add(const Duration(days: 365)),
|
|
|
|
|
|
|
|
// onDateTimePicker: (date) {
|
|
|
|
|
|
|
|
// _gasRefillProvider.startDate = date;
|
|
|
|
|
|
|
|
// setState(() {});
|
|
|
|
|
|
|
|
// },
|
|
|
|
|
|
|
|
// ),
|
|
|
|
|
|
|
|
// ],
|
|
|
|
|
|
|
|
// ),
|
|
|
|
|
|
|
|
// ),
|
|
|
|
|
|
|
|
// const SizedBox(width: 8),
|
|
|
|
|
|
|
|
// Expanded(
|
|
|
|
|
|
|
|
// child: Column(
|
|
|
|
|
|
|
|
// crossAxisAlignment: CrossAxisAlignment.stretch,
|
|
|
|
|
|
|
|
// children: [
|
|
|
|
|
|
|
|
// const ASubTitle("End of Work"),
|
|
|
|
|
|
|
|
// SizedBox(
|
|
|
|
|
|
|
|
// height: 8 * AppStyle.getScaleFactor(context),
|
|
|
|
|
|
|
|
// ),
|
|
|
|
|
|
|
|
// ADateTimePicker(
|
|
|
|
|
|
|
|
// date: _gasRefillProvider.endDate,
|
|
|
|
|
|
|
|
// from: DateTime.now().subtract(const Duration(days: 365)),
|
|
|
|
|
|
|
|
// to: DateTime.now().add(const Duration(days: 365)),
|
|
|
|
|
|
|
|
// onDateTimePicker: (date) {
|
|
|
|
|
|
|
|
// _gasRefillProvider.endDate = date;
|
|
|
|
|
|
|
|
// setState(() {});
|
|
|
|
|
|
|
|
// },
|
|
|
|
|
|
|
|
// ),
|
|
|
|
|
|
|
|
// ],
|
|
|
|
|
|
|
|
// ),
|
|
|
|
|
|
|
|
// ),
|
|
|
|
|
|
|
|
// ],
|
|
|
|
|
|
|
|
// ),
|
|
|
|
|
|
|
|
// const SizedBox(height: 8),
|
|
|
|
|
|
|
|
// ASubTitle(context.translation.workingHours),
|
|
|
|
|
|
|
|
// const SizedBox(height: 4),
|
|
|
|
|
|
|
|
// ATextFormField(
|
|
|
|
|
|
|
|
// initialValue: null,
|
|
|
|
|
|
|
|
// textAlign: TextAlign.center,
|
|
|
|
|
|
|
|
// hintText: _gasRefillProvider.startDate == null
|
|
|
|
|
|
|
|
// ? "0"
|
|
|
|
|
|
|
|
// : ((_gasRefillProvider.endDate?.difference(_gasRefillProvider.startDate)?.inMinutes ?? 0) / 60)?.toStringAsFixed(2)?.toString() ?? "0",
|
|
|
|
|
|
|
|
// enable: false,
|
|
|
|
|
|
|
|
// style: Theme.of(context).textTheme.subtitle1,
|
|
|
|
|
|
|
|
// validator: (value) => Validator.isNumeric(value) ? null : context.translation.requiredWord,
|
|
|
|
|
|
|
|
// textInputType: TextInputType.number,
|
|
|
|
|
|
|
|
// onSaved: (value) {
|
|
|
|
|
|
|
|
// // _serviceReport.workHours = value;
|
|
|
|
|
|
|
|
// },
|
|
|
|
|
|
|
|
// ),
|
|
|
|
|
|
|
|
// ],
|
|
|
|
|
|
|
|
// ),
|
|
|
|
|
|
|
|
if (widget.gasRefillModel == null)
|
|
|
|
|
|
|
|
Column(
|
|
|
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
children: [
|
|
|
|
children: [
|
|
|
|
const SizedBox(height: 8),
|
|
|
|
Text(context.translation.gasRefill, style: AppTextStyles.heading5.copyWith(color: const Color(0xFF3B3D4A))),
|
|
|
|
Divider(color: Theme.of(context).colorScheme.primary),
|
|
|
|
8.height,
|
|
|
|
const SizedBox(height: 4),
|
|
|
|
Text(
|
|
|
|
const ASubTitle("Gas Type"),
|
|
|
|
'Gas Request:',
|
|
|
|
if (_validate && _currentDetails.type == null) ASubTitle(context.translation.requiredWord, color: Colors.red),
|
|
|
|
style: AppTextStyles.bodyText.copyWith(color: Color(0xFF757575)),
|
|
|
|
const SizedBox(height: 4),
|
|
|
|
|
|
|
|
GasTypeMenu(
|
|
|
|
|
|
|
|
initialValue: _currentDetails.type,
|
|
|
|
|
|
|
|
onSelect: (status) {
|
|
|
|
|
|
|
|
_currentDetails.type = status;
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
),
|
|
|
|
),
|
|
|
|
const SizedBox(height: 8),
|
|
|
|
Text(
|
|
|
|
const ASubTitle("Cylinder Size"),
|
|
|
|
'Cylinder Size: ${widget.gasRefillModel.gazRefillDetails[0].cylinderSize.value}',
|
|
|
|
if (_validate && _currentDetails.cylinderSize == null)
|
|
|
|
style: AppTextStyles.bodyText.copyWith(color: Color(0xFF757575)),
|
|
|
|
ASubTitle(
|
|
|
|
|
|
|
|
context.translation.requiredWord,
|
|
|
|
|
|
|
|
color: Colors.red,
|
|
|
|
|
|
|
|
),
|
|
|
|
),
|
|
|
|
const SizedBox(
|
|
|
|
Text(
|
|
|
|
height: 4,
|
|
|
|
'Request Quantity: ${widget.gasRefillModel.gazRefillDetails[0].requestedQty}',
|
|
|
|
|
|
|
|
style: AppTextStyles.bodyText.copyWith(color: Color(0xFF757575)),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
GasCylinderSizeMenu(
|
|
|
|
Text(
|
|
|
|
initialValue: _currentDetails.cylinderSize,
|
|
|
|
'Site: ${widget.gasRefillModel.site.name}',
|
|
|
|
onSelect: (status) {
|
|
|
|
style: AppTextStyles.bodyText.copyWith(color: Color(0xFF757575)),
|
|
|
|
_currentDetails.cylinderSize = status;
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
const SizedBox(
|
|
|
|
|
|
|
|
height: 8,
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
const ASubTitle("Cylinder Type"),
|
|
|
|
|
|
|
|
if (_validate && _currentDetails.cylinderSize == null)
|
|
|
|
|
|
|
|
ASubTitle(
|
|
|
|
|
|
|
|
context.translation.requiredWord,
|
|
|
|
|
|
|
|
color: Colors.red,
|
|
|
|
|
|
|
|
),
|
|
|
|
),
|
|
|
|
const SizedBox(
|
|
|
|
],
|
|
|
|
height: 4,
|
|
|
|
).paddingAll(16),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
GasCylinderTypesMenu(
|
|
|
|
12.height,
|
|
|
|
initialValue: _currentDetails.cylinderType,
|
|
|
|
AppTextFormField(
|
|
|
|
onSelect: (status) {
|
|
|
|
labelText: context.translation.workingHours,
|
|
|
|
_currentDetails.cylinderType = status;
|
|
|
|
onSaved:(value){
|
|
|
|
|
|
|
|
_formModel?.workingHours = double.tryParse(value);
|
|
|
|
},
|
|
|
|
},
|
|
|
|
),
|
|
|
|
|
|
|
|
const SizedBox(
|
|
|
|
|
|
|
|
height: 8,
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
ASubTitle(context.translation.requestedQuantity),
|
|
|
|
|
|
|
|
if (_validate && _currentDetails?.requestedQuantity == null)
|
|
|
|
|
|
|
|
ASubTitle(
|
|
|
|
|
|
|
|
context.translation.requiredWord,
|
|
|
|
|
|
|
|
color: Colors.red,
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
SizedBox(
|
|
|
|
|
|
|
|
height: 4,
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
ATextFormField(
|
|
|
|
|
|
|
|
initialValue: (_currentDetails?.requestedQuantity ?? "").toString(),
|
|
|
|
|
|
|
|
textAlign: TextAlign.center,
|
|
|
|
|
|
|
|
controller: _requestedQuantityController,
|
|
|
|
|
|
|
|
style: Theme.of(context).textTheme.subtitle1,
|
|
|
|
|
|
|
|
validator: (value) => Validator.isNumeric(value) ? null : "allow numbers only",
|
|
|
|
|
|
|
|
textInputType: TextInputType.number,
|
|
|
|
textInputType: TextInputType.number,
|
|
|
|
onChange: (value) {
|
|
|
|
controller: _workingHoursController,
|
|
|
|
_currentDetails?.requestedQuantity = double.tryParse(value);
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
if (widget.gasRefillModel != null) const SizedBox(height: 16),
|
|
|
|
|
|
|
|
if (widget.gasRefillModel != null) ASubTitle(context.translation.deliveredQuantity),
|
|
|
|
|
|
|
|
if (widget.gasRefillModel != null && _validate && _currentDetails?.deliveredQuantity == null)
|
|
|
|
|
|
|
|
ASubTitle(
|
|
|
|
|
|
|
|
context.translation.requiredWord,
|
|
|
|
|
|
|
|
color: Colors.red,
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
if (widget.gasRefillModel != null) const SizedBox(height: 4),
|
|
|
|
|
|
|
|
if (widget.gasRefillModel != null)
|
|
|
|
|
|
|
|
ATextFormField(
|
|
|
|
|
|
|
|
initialValue: (_currentDetails?.deliveredQuantity ?? "").toString(),
|
|
|
|
|
|
|
|
textAlign: TextAlign.center,
|
|
|
|
|
|
|
|
controller: _deliveredQuantityController,
|
|
|
|
|
|
|
|
style: Theme.of(context).textTheme.subtitle1,
|
|
|
|
|
|
|
|
validator: (value) => Validator.isNumeric(value) ? null : "allow numbers only",
|
|
|
|
validator: (value) => Validator.isNumeric(value) ? null : "allow numbers only",
|
|
|
|
textInputType: TextInputType.number,
|
|
|
|
|
|
|
|
onChange: (value) {
|
|
|
|
|
|
|
|
_currentDetails?.deliveredQuantity = double.tryParse(value);
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
),
|
|
|
|
),
|
|
|
|
const SizedBox(height: 16),
|
|
|
|
12.height,
|
|
|
|
AButton(
|
|
|
|
SingleItemDropDownMenu<Lookup,GasStatusProvider >(
|
|
|
|
text: context.translation.add,
|
|
|
|
context: context,
|
|
|
|
onPressed: _addNewModel,
|
|
|
|
title: context.translation.reportStatus,
|
|
|
|
),
|
|
|
|
initialValue: _formModel.status,
|
|
|
|
],
|
|
|
|
onSelect: (value) {
|
|
|
|
),
|
|
|
|
_formModel.status=value;
|
|
|
|
const SizedBox(height: 16),
|
|
|
|
|
|
|
|
if (_formModel.details.isNotEmpty) const ASubTitle("Gas Requests"),
|
|
|
|
|
|
|
|
ListView.builder(
|
|
|
|
|
|
|
|
key: _DetailsKey,
|
|
|
|
|
|
|
|
shrinkWrap: true,
|
|
|
|
|
|
|
|
physics: const ClampingScrollPhysics(),
|
|
|
|
|
|
|
|
itemCount: _formModel.details.length,
|
|
|
|
|
|
|
|
itemBuilder: (context, index) {
|
|
|
|
|
|
|
|
final model = _formModel.details[index];
|
|
|
|
|
|
|
|
return GasRefillCreateDetailsItem(
|
|
|
|
|
|
|
|
isUpdate: widget.gasRefillModel != null,
|
|
|
|
|
|
|
|
model: model,
|
|
|
|
|
|
|
|
onPressed: () {
|
|
|
|
|
|
|
|
if (widget.gasRefillModel != null) {
|
|
|
|
|
|
|
|
model.selectedForEditing = !(model.selectedForEditing ?? false);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (widget.gasRefillModel == null) {
|
|
|
|
|
|
|
|
_formModel.details.remove(model);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
setState(() {});
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
}),
|
|
|
|
|
|
|
|
if (widget.gasRefillModel != null) const SizedBox(height: 16),
|
|
|
|
|
|
|
|
if (widget.gasRefillModel != null) const ASubTitle("Nurse Signature"),
|
|
|
|
|
|
|
|
if (widget.gasRefillModel != null)
|
|
|
|
|
|
|
|
ESignature(
|
|
|
|
|
|
|
|
oldSignature: _formModel.signatureNurse,
|
|
|
|
|
|
|
|
newSignature: _formModel.localNurseSignature,
|
|
|
|
|
|
|
|
onChange: (signature) {
|
|
|
|
|
|
|
|
if (signature == null || signature.isEmpty) {
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
_formModel.localNurseSignature = signature;
|
|
|
|
|
|
|
|
_formModel.signatureNurse = "${DateTime.now().toIso8601String()}.png|${base64Encode(signature)}";
|
|
|
|
|
|
|
|
},
|
|
|
|
},
|
|
|
|
),
|
|
|
|
),
|
|
|
|
if (widget.gasRefillModel != null)
|
|
|
|
12.height,
|
|
|
|
const SizedBox(
|
|
|
|
AppTextFormField(
|
|
|
|
height: 8,
|
|
|
|
labelText: context.translation.deliveredQuantity,
|
|
|
|
|
|
|
|
onSaved:(value){
|
|
|
|
|
|
|
|
_currentDetails?.deliverdQty = double.tryParse(value);
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
textInputType: TextInputType.number,
|
|
|
|
|
|
|
|
controller: _deliveredQuantityController,
|
|
|
|
|
|
|
|
validator: (value) => Validator.isNumeric(value) ? null : "allow numbers only",
|
|
|
|
),
|
|
|
|
),
|
|
|
|
if (widget.gasRefillModel != null) const ASubTitle("Engineer Signature"),
|
|
|
|
12.height,
|
|
|
|
if (widget.gasRefillModel != null)
|
|
|
|
/// TBD
|
|
|
|
ESignature(
|
|
|
|
AppTextFormField(
|
|
|
|
oldSignature: _formModel.signatureEngineer,
|
|
|
|
labelText: context.translation.comments,
|
|
|
|
newSignature: _formModel.localEngineerSignature,
|
|
|
|
textInputType: TextInputType.multiline,
|
|
|
|
onChange: (signature) {
|
|
|
|
alignLabelWithHint: true,
|
|
|
|
if (signature == null || signature.isEmpty) {
|
|
|
|
controller: _commentController,
|
|
|
|
return;
|
|
|
|
onSaved: (value){
|
|
|
|
}
|
|
|
|
|
|
|
|
_formModel.localEngineerSignature = signature;
|
|
|
|
|
|
|
|
_formModel.signatureEngineer = "${DateTime.now().toIso8601String()}.png|${base64Encode(signature)}";
|
|
|
|
|
|
|
|
},
|
|
|
|
},
|
|
|
|
),
|
|
|
|
),
|
|
|
|
const SizedBox(height: 16),
|
|
|
|
],
|
|
|
|
|
|
|
|
).paddingAll(16),
|
|
|
|
AButton(
|
|
|
|
AButton(
|
|
|
|
text: widget.gasRefillModel == null ? context.translation.submit : context.translation.update,
|
|
|
|
text: widget.gasRefillModel == null ? context.translation.submit : context.translation.update,
|
|
|
|
onPressed: _onSubmit,
|
|
|
|
onPressed:()async{_onSubmit.call(context);},
|
|
|
|
),
|
|
|
|
).paddingAll(16),
|
|
|
|
const SizedBox(height: 100)
|
|
|
|
|
|
|
|
],
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
)
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|