|
|
|
|
@ -289,168 +289,176 @@ class _RequestGasRefillState extends State<RequestGasRefill> {
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
if (_userProvider.user?.type == UsersTypes.engineer)
|
|
|
|
|
Row(
|
|
|
|
|
Column(
|
|
|
|
|
children: [
|
|
|
|
|
Expanded(
|
|
|
|
|
child: Column(
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.stretch,
|
|
|
|
|
children: [
|
|
|
|
|
const ASubTitle("Start of Work"),
|
|
|
|
|
SizedBox(
|
|
|
|
|
height: 8 * AppStyle.getScaleFactor(context),
|
|
|
|
|
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(() {});
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
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(_subtitle.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 : _subtitle.requiredWord,
|
|
|
|
|
textInputType: TextInputType.number,
|
|
|
|
|
onSaved: (value) {
|
|
|
|
|
// _serviceReport.workHours = value;
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
if (widget.gasRefillModel == null)
|
|
|
|
|
Column(
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
|
children: [
|
|
|
|
|
const SizedBox(height: 8),
|
|
|
|
|
Divider(color: Theme.of(context).colorScheme.primary),
|
|
|
|
|
const SizedBox(height: 4),
|
|
|
|
|
const ASubTitle("Type"),
|
|
|
|
|
if (_validate && _currentDetails.type == null) ASubTitle(_subtitle.requiredWord, color: Colors.red),
|
|
|
|
|
const SizedBox(height: 4),
|
|
|
|
|
GasTypeMenu(
|
|
|
|
|
initialValue: _currentDetails.type,
|
|
|
|
|
onSelect: (status) {
|
|
|
|
|
_currentDetails.type = status;
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
const SizedBox(height: 8),
|
|
|
|
|
const ASubTitle("Cylinder Size"),
|
|
|
|
|
if (_validate && _currentDetails.cylinderSize == null)
|
|
|
|
|
ASubTitle(
|
|
|
|
|
_subtitle.requiredWord,
|
|
|
|
|
color: Colors.red,
|
|
|
|
|
),
|
|
|
|
|
const SizedBox(
|
|
|
|
|
height: 4,
|
|
|
|
|
),
|
|
|
|
|
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(() {});
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
GasCylinderSizeMenu(
|
|
|
|
|
initialValue: _currentDetails.cylinderSize,
|
|
|
|
|
onSelect: (status) {
|
|
|
|
|
_currentDetails.cylinderSize = status;
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
const SizedBox(
|
|
|
|
|
height: 8,
|
|
|
|
|
),
|
|
|
|
|
const SizedBox(
|
|
|
|
|
height: 8,
|
|
|
|
|
),
|
|
|
|
|
const ASubTitle("Cylinder Type"),
|
|
|
|
|
if (_validate && _currentDetails.cylinderSize == null)
|
|
|
|
|
ASubTitle(
|
|
|
|
|
_subtitle.requiredWord,
|
|
|
|
|
color: Colors.red,
|
|
|
|
|
),
|
|
|
|
|
const SizedBox(
|
|
|
|
|
height: 4,
|
|
|
|
|
),
|
|
|
|
|
GasCylinderTypesMenu(
|
|
|
|
|
initialValue: _currentDetails.cylinderType,
|
|
|
|
|
onSelect: (status) {
|
|
|
|
|
_currentDetails.cylinderType = status;
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
const SizedBox(
|
|
|
|
|
height: 8,
|
|
|
|
|
),
|
|
|
|
|
ASubTitle(_subtitle.requestedQuantity),
|
|
|
|
|
if (_validate && _currentDetails?.requestedQuantity == null)
|
|
|
|
|
ASubTitle(
|
|
|
|
|
_subtitle.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,
|
|
|
|
|
onChange: (value) {
|
|
|
|
|
_currentDetails?.requestedQuantity = double.tryParse(value);
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
if (widget.gasRefillModel != null) const SizedBox(height: 16),
|
|
|
|
|
if (widget.gasRefillModel != null) ASubTitle(_subtitle.deliveredQuantity),
|
|
|
|
|
if (widget.gasRefillModel != null && _validate && _currentDetails?.deliveredQuantity == null)
|
|
|
|
|
ASubTitle(
|
|
|
|
|
_subtitle.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",
|
|
|
|
|
textInputType: TextInputType.number,
|
|
|
|
|
onChange: (value) {
|
|
|
|
|
_currentDetails?.deliveredQuantity = double.tryParse(value);
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
const SizedBox(height: 16),
|
|
|
|
|
AButton(
|
|
|
|
|
text: _subtitle.add,
|
|
|
|
|
onPressed: _addNewModel,
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
if (_userProvider.user?.type == UsersTypes.engineer) const SizedBox(height: 8),
|
|
|
|
|
if (_userProvider.user?.type == UsersTypes.engineer) ASubTitle(_subtitle.workingHours),
|
|
|
|
|
if (_userProvider.user?.type == UsersTypes.engineer) const SizedBox(height: 4),
|
|
|
|
|
if (_userProvider.user?.type == UsersTypes.engineer)
|
|
|
|
|
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 : _subtitle.requiredWord,
|
|
|
|
|
textInputType: TextInputType.number,
|
|
|
|
|
onSaved: (value) {
|
|
|
|
|
// _serviceReport.workHours = value;
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
const SizedBox(height: 8),
|
|
|
|
|
Divider(color: Theme.of(context).colorScheme.primary),
|
|
|
|
|
const SizedBox(height: 4),
|
|
|
|
|
const ASubTitle("Type"),
|
|
|
|
|
if (_validate && _currentDetails.type == null) ASubTitle(_subtitle.requiredWord, color: Colors.red),
|
|
|
|
|
const SizedBox(height: 4),
|
|
|
|
|
GasTypeMenu(
|
|
|
|
|
initialValue: _currentDetails.type,
|
|
|
|
|
onSelect: (status) {
|
|
|
|
|
_currentDetails.type = status;
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
const SizedBox(height: 8),
|
|
|
|
|
const ASubTitle("Cylinder Size"),
|
|
|
|
|
if (_validate && _currentDetails.cylinderSize == null)
|
|
|
|
|
ASubTitle(
|
|
|
|
|
_subtitle.requiredWord,
|
|
|
|
|
color: Colors.red,
|
|
|
|
|
),
|
|
|
|
|
const SizedBox(
|
|
|
|
|
height: 4,
|
|
|
|
|
),
|
|
|
|
|
GasCylinderSizeMenu(
|
|
|
|
|
initialValue: _currentDetails.cylinderSize,
|
|
|
|
|
onSelect: (status) {
|
|
|
|
|
_currentDetails.cylinderSize = status;
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
const SizedBox(
|
|
|
|
|
height: 8,
|
|
|
|
|
),
|
|
|
|
|
|
|
|
|
|
const SizedBox(
|
|
|
|
|
height: 8,
|
|
|
|
|
),
|
|
|
|
|
const ASubTitle("Cylinder Type"),
|
|
|
|
|
if (_validate && _currentDetails.cylinderSize == null)
|
|
|
|
|
ASubTitle(
|
|
|
|
|
_subtitle.requiredWord,
|
|
|
|
|
color: Colors.red,
|
|
|
|
|
),
|
|
|
|
|
const SizedBox(
|
|
|
|
|
height: 4,
|
|
|
|
|
),
|
|
|
|
|
GasCylinderTypesMenu(
|
|
|
|
|
initialValue: _currentDetails.cylinderType,
|
|
|
|
|
onSelect: (status) {
|
|
|
|
|
_currentDetails.cylinderType = status;
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
const SizedBox(
|
|
|
|
|
height: 8,
|
|
|
|
|
),
|
|
|
|
|
ASubTitle(_subtitle.requestedQuantity),
|
|
|
|
|
if (_validate && _currentDetails?.requestedQuantity == null)
|
|
|
|
|
ASubTitle(
|
|
|
|
|
_subtitle.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,
|
|
|
|
|
onChange: (value) {
|
|
|
|
|
_currentDetails?.requestedQuantity = double.tryParse(value);
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
if (widget.gasRefillModel != null) const SizedBox(height: 16),
|
|
|
|
|
if (widget.gasRefillModel != null) ASubTitle(_subtitle.deliveredQuantity),
|
|
|
|
|
if (widget.gasRefillModel != null && _validate && _currentDetails?.deliveredQuantity == null)
|
|
|
|
|
ASubTitle(
|
|
|
|
|
_subtitle.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",
|
|
|
|
|
textInputType: TextInputType.number,
|
|
|
|
|
onChange: (value) {
|
|
|
|
|
_currentDetails?.deliveredQuantity = double.tryParse(value);
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
const SizedBox(height: 16),
|
|
|
|
|
AButton(
|
|
|
|
|
text: _subtitle.add,
|
|
|
|
|
onPressed: _addNewModel,
|
|
|
|
|
),
|
|
|
|
|
|
|
|
|
|
if (_formModel.details.isNotEmpty) const ASubTitle("Gas Requests"),
|
|
|
|
|
ListView.builder(
|
|
|
|
|
key: _DetailsKey,
|
|
|
|
|
@ -460,9 +468,15 @@ class _RequestGasRefillState extends State<RequestGasRefill> {
|
|
|
|
|
itemBuilder: (context, index) {
|
|
|
|
|
final model = _formModel.details[index];
|
|
|
|
|
return GasRefillCreateDetailsItem(
|
|
|
|
|
isUpdate: widget.gasRefillModel != null,
|
|
|
|
|
model: model,
|
|
|
|
|
onDelete: () {
|
|
|
|
|
_formModel.details.remove(model);
|
|
|
|
|
onPressed: () {
|
|
|
|
|
if (widget.gasRefillModel != null) {
|
|
|
|
|
model.selectedForEditing = !(model.selectedForEditing ?? false);
|
|
|
|
|
}
|
|
|
|
|
if (widget.gasRefillModel == null) {
|
|
|
|
|
_formModel.details.remove(model);
|
|
|
|
|
}
|
|
|
|
|
setState(() {});
|
|
|
|
|
},
|
|
|
|
|
);
|
|
|
|
|
|