|
|
|
|
import 'dart:convert';
|
|
|
|
|
|
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
|
import 'package:provider/provider.dart';
|
|
|
|
|
import 'package:test_sa/controllers/localization/localization.dart';
|
|
|
|
|
import 'package:test_sa/controllers/providers/api/user_provider.dart';
|
|
|
|
|
import 'package:test_sa/models/pantry/pentry.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/date_and_time/date_picker.dart';
|
|
|
|
|
import 'package:test_sa/views/widgets/e_signature/e_signature.dart';
|
|
|
|
|
import 'package:test_sa/views/widgets/status/pentry/pentry_visit_status_mune.dart';
|
|
|
|
|
import 'package:test_sa/views/widgets/timer/app_timer.dart';
|
|
|
|
|
import 'package:test_sa/views/widgets/titles/app_sub_title.dart';
|
|
|
|
|
|
|
|
|
|
import '../images/multi_image_picker.dart';
|
|
|
|
|
import '../status/pentry/pentry_status_mune.dart';
|
|
|
|
|
|
|
|
|
|
class PentryInfoForm extends StatefulWidget {
|
|
|
|
|
final Pentry model;
|
|
|
|
|
final bool enableValidate;
|
|
|
|
|
|
|
|
|
|
const PentryInfoForm({
|
|
|
|
|
Key key,
|
|
|
|
|
this.model,
|
|
|
|
|
this.enableValidate,
|
|
|
|
|
}) : super(key: key);
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
State<PentryInfoForm> createState() => _PentryInfoFormState();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class _PentryInfoFormState extends State<PentryInfoForm> {
|
|
|
|
|
@override
|
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
|
widget.model?.files ??= [];
|
|
|
|
|
final subtitle = AppLocalization.of(context).subtitle;
|
|
|
|
|
final userProvider = Provider.of<UserProvider>(context);
|
|
|
|
|
return Padding(
|
|
|
|
|
padding: EdgeInsets.only(
|
|
|
|
|
top: 12 * AppStyle.getScaleFactor(context), left: 12 * AppStyle.getScaleFactor(context), right: 12 * AppStyle.getScaleFactor(context), bottom: 80 * AppStyle.getScaleFactor(context)),
|
|
|
|
|
child: SingleChildScrollView(
|
|
|
|
|
child: Column(
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.stretch,
|
|
|
|
|
children: [
|
|
|
|
|
const SizedBox(
|
|
|
|
|
height: 8,
|
|
|
|
|
),
|
|
|
|
|
const ASubTitle("PPM Visit Status"),
|
|
|
|
|
if (widget.enableValidate && widget.model.ppmVisitStatus == null)
|
|
|
|
|
ASubTitle(
|
|
|
|
|
subtitle.requiredWord,
|
|
|
|
|
color: Colors.red,
|
|
|
|
|
),
|
|
|
|
|
const SizedBox(
|
|
|
|
|
height: 4,
|
|
|
|
|
),
|
|
|
|
|
PentryVisitsStatusMenu(
|
|
|
|
|
initialValue: widget.model.ppmVisitStatus,
|
|
|
|
|
onSelect: (status) {
|
|
|
|
|
if (status != null) {
|
|
|
|
|
widget.model.ppmVisitStatus = status;
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
const SizedBox(
|
|
|
|
|
height: 8,
|
|
|
|
|
),
|
|
|
|
|
const ASubTitle("Timer"),
|
|
|
|
|
if (widget.enableValidate && widget.model?.timer?.endAt == null)
|
|
|
|
|
ASubTitle(
|
|
|
|
|
subtitle.requiredWord,
|
|
|
|
|
color: Colors.red,
|
|
|
|
|
),
|
|
|
|
|
const SizedBox(
|
|
|
|
|
height: 4,
|
|
|
|
|
),
|
|
|
|
|
AppTimer(
|
|
|
|
|
timer: widget.model.timer,
|
|
|
|
|
enabled: widget.model.timer.endAt == null,
|
|
|
|
|
onChange: (timer) async {
|
|
|
|
|
widget.model.timer = timer;
|
|
|
|
|
return true;
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
const SizedBox(
|
|
|
|
|
height: 8,
|
|
|
|
|
),
|
|
|
|
|
const ASubTitle("Status"),
|
|
|
|
|
if (widget.enableValidate && widget.model.status == null)
|
|
|
|
|
ASubTitle(
|
|
|
|
|
subtitle.requiredWord,
|
|
|
|
|
color: Colors.red,
|
|
|
|
|
),
|
|
|
|
|
const SizedBox(
|
|
|
|
|
height: 4,
|
|
|
|
|
),
|
|
|
|
|
PentryStatusMenu(
|
|
|
|
|
initialValue: widget.model.status,
|
|
|
|
|
onSelect: (status) {
|
|
|
|
|
widget.model.status = status;
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
const SizedBox(
|
|
|
|
|
height: 8,
|
|
|
|
|
),
|
|
|
|
|
const ASubTitle("Actual Visit Date"),
|
|
|
|
|
if (widget.enableValidate && widget.model.actualVisitDate == null)
|
|
|
|
|
ASubTitle(
|
|
|
|
|
subtitle.requiredWord,
|
|
|
|
|
color: Colors.red,
|
|
|
|
|
),
|
|
|
|
|
const SizedBox(
|
|
|
|
|
height: 4,
|
|
|
|
|
),
|
|
|
|
|
ADatePicker(
|
|
|
|
|
date: widget.model.actualVisitDate,
|
|
|
|
|
from: DateTime.now().subtract(const Duration(days: 30)),
|
|
|
|
|
onDatePicker: (date) {
|
|
|
|
|
if (date == null) return;
|
|
|
|
|
widget.model.actualVisitDate = date;
|
|
|
|
|
setState(() {});
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
const SizedBox(
|
|
|
|
|
height: 8,
|
|
|
|
|
),
|
|
|
|
|
const ASubTitle("Expected Visit Date"),
|
|
|
|
|
if (widget.enableValidate && widget.model.expectedVisitDate == null)
|
|
|
|
|
ASubTitle(
|
|
|
|
|
subtitle.requiredWord,
|
|
|
|
|
color: Colors.red,
|
|
|
|
|
),
|
|
|
|
|
const SizedBox(
|
|
|
|
|
height: 4,
|
|
|
|
|
),
|
|
|
|
|
ADatePicker(
|
|
|
|
|
date: widget.model.expectedVisitDate,
|
|
|
|
|
from: DateTime.now().subtract(const Duration(days: 30)),
|
|
|
|
|
onDatePicker: (date) {
|
|
|
|
|
if (date == null) return;
|
|
|
|
|
widget.model.expectedVisitDate = date;
|
|
|
|
|
setState(() {});
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
const SizedBox(
|
|
|
|
|
height: 8,
|
|
|
|
|
),
|
|
|
|
|
const ASubTitle("Traveling Hours"),
|
|
|
|
|
const SizedBox(
|
|
|
|
|
height: 4,
|
|
|
|
|
),
|
|
|
|
|
ATextFormField(
|
|
|
|
|
initialValue: (widget.model.travelingHours ?? "").toString(),
|
|
|
|
|
textAlign: TextAlign.center,
|
|
|
|
|
style: Theme.of(context).textTheme.titleMedium,
|
|
|
|
|
textInputType: TextInputType.number,
|
|
|
|
|
onChange: (value) {
|
|
|
|
|
widget.model.travelingHours = value;
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
const SizedBox(height: 12),
|
|
|
|
|
MultiFilesPicker(label: "PPM Attachments", files: widget.model.files),
|
|
|
|
|
// AMiniOneFilePicker(
|
|
|
|
|
// //error: _validate && _serviceReport.image == null,
|
|
|
|
|
// file: widget.model.file,
|
|
|
|
|
// onPick: (file) {
|
|
|
|
|
// widget.model.file = file;
|
|
|
|
|
// },
|
|
|
|
|
// ),
|
|
|
|
|
const SizedBox(
|
|
|
|
|
height: 8,
|
|
|
|
|
),
|
|
|
|
|
const ASubTitle("Nurse Signature"),
|
|
|
|
|
ESignature(
|
|
|
|
|
oldSignature: widget.model.signatureNurse,
|
|
|
|
|
newSignature: widget.model.localNurseSignature,
|
|
|
|
|
onChange: (signature) {
|
|
|
|
|
if (signature == null || signature.isEmpty) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
widget.model.localNurseSignature = signature;
|
|
|
|
|
widget.model.signatureNurse = "${DateTime.now().toIso8601String()}.png|${base64Encode(signature)}";
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
const SizedBox(
|
|
|
|
|
height: 8,
|
|
|
|
|
),
|
|
|
|
|
const ASubTitle("Engineer Signature"),
|
|
|
|
|
ESignature(
|
|
|
|
|
oldSignature: widget.model.signatureEngineer,
|
|
|
|
|
newSignature: widget.model.localEngineerSignature,
|
|
|
|
|
onChange: (signature) {
|
|
|
|
|
if (signature == null || signature.isEmpty) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
widget.model.localEngineerSignature = signature;
|
|
|
|
|
widget.model.signatureEngineer = "${DateTime.now().toIso8601String()}.png|${base64Encode(signature)}";
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
const SizedBox(
|
|
|
|
|
height: 8,
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|