|
|
|
|
@ -6,6 +6,7 @@ import 'package:doctor_app_flutter/core/viewModel/patient_view_model.dart';
|
|
|
|
|
import 'package:doctor_app_flutter/core/viewModel/project_view_model.dart';
|
|
|
|
|
import 'package:doctor_app_flutter/core/viewModel/sick_leave_view_model.dart';
|
|
|
|
|
import 'package:doctor_app_flutter/models/sickleave/add_sickleave_request.dart';
|
|
|
|
|
import 'package:doctor_app_flutter/routes.dart';
|
|
|
|
|
import 'package:doctor_app_flutter/screens/base/base_view.dart';
|
|
|
|
|
import 'package:doctor_app_flutter/util/dr_app_shared_pref.dart';
|
|
|
|
|
import 'package:doctor_app_flutter/util/dr_app_toast_msg.dart';
|
|
|
|
|
@ -41,9 +42,10 @@ class _RescheduleLeaveScreen extends State<RescheduleLeaveScreen> {
|
|
|
|
|
TextEditingController _toDateController = new TextEditingController();
|
|
|
|
|
TextEditingController _toDateController2 = new TextEditingController();
|
|
|
|
|
ProjectViewModel projectsProvider;
|
|
|
|
|
SickLeaveViewModel sickLeaveViewModel;
|
|
|
|
|
String _selectedClinic;
|
|
|
|
|
Map profile = {};
|
|
|
|
|
var offTime = '2';
|
|
|
|
|
var offTime = '1';
|
|
|
|
|
var date;
|
|
|
|
|
var doctorID;
|
|
|
|
|
var reason;
|
|
|
|
|
@ -53,6 +55,7 @@ class _RescheduleLeaveScreen extends State<RescheduleLeaveScreen> {
|
|
|
|
|
var fromTime;
|
|
|
|
|
var toTime;
|
|
|
|
|
TextEditingController _controller4;
|
|
|
|
|
TextEditingController _controller5;
|
|
|
|
|
void _presentDatePicker(id) {
|
|
|
|
|
var date = new DateTime.now();
|
|
|
|
|
var initialDate = id == 'fromDate'
|
|
|
|
|
@ -66,25 +69,6 @@ class _RescheduleLeaveScreen extends State<RescheduleLeaveScreen> {
|
|
|
|
|
initialDate: initialDate,
|
|
|
|
|
firstDate: firstDate,
|
|
|
|
|
lastDate: DateTime(2050),
|
|
|
|
|
).then((pickedDate) {
|
|
|
|
|
if (pickedDate == null) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
setState(() {
|
|
|
|
|
final df = new DateFormat('yyyy-MM-dd');
|
|
|
|
|
fromDate = pickedDate; //df.format();
|
|
|
|
|
_toDateController.text = df.format(pickedDate);
|
|
|
|
|
toDate = pickedDate;
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void _presentCurrentDate(id) {
|
|
|
|
|
showDatePicker(
|
|
|
|
|
context: context,
|
|
|
|
|
initialDate: DateTime.now(),
|
|
|
|
|
firstDate: DateTime.now(),
|
|
|
|
|
lastDate: DateTime(2050),
|
|
|
|
|
).then((pickedDate) {
|
|
|
|
|
if (pickedDate == null) {
|
|
|
|
|
return;
|
|
|
|
|
@ -99,6 +83,13 @@ class _RescheduleLeaveScreen extends State<RescheduleLeaveScreen> {
|
|
|
|
|
_toDateController2.text = df.format(pickedDate);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
setState(() {
|
|
|
|
|
final df = new DateFormat('yyyy-MM-dd');
|
|
|
|
|
fromDate = pickedDate; //df.format();
|
|
|
|
|
_toDateController.text = df.format(pickedDate);
|
|
|
|
|
toDate = pickedDate;
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -112,6 +103,7 @@ class _RescheduleLeaveScreen extends State<RescheduleLeaveScreen> {
|
|
|
|
|
@override
|
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
|
projectsProvider = Provider.of(context);
|
|
|
|
|
|
|
|
|
|
return BaseView<PatientViewModel>(
|
|
|
|
|
onModelReady: (model) => model.getClinicsList(),
|
|
|
|
|
builder: (_, model, w) => BaseView<SickLeaveViewModel>(
|
|
|
|
|
@ -345,24 +337,26 @@ class _RescheduleLeaveScreen extends State<RescheduleLeaveScreen> {
|
|
|
|
|
CrossAxisAlignment.start,
|
|
|
|
|
children: [
|
|
|
|
|
AppTextFormField(
|
|
|
|
|
hintText: TranslationBase.of(
|
|
|
|
|
context)
|
|
|
|
|
.fromDate,
|
|
|
|
|
borderColor: Colors.white,
|
|
|
|
|
prefix: IconButton(
|
|
|
|
|
icon: Icon(Icons
|
|
|
|
|
.calendar_today)),
|
|
|
|
|
textInputType:
|
|
|
|
|
TextInputType.number,
|
|
|
|
|
controller: _toDateController,
|
|
|
|
|
onTap: () {
|
|
|
|
|
_presentCurrentDate(
|
|
|
|
|
'fromDate');
|
|
|
|
|
},
|
|
|
|
|
inputFormatter: ONLY_DATE,
|
|
|
|
|
onChanged: (value) {
|
|
|
|
|
fromDate = value;
|
|
|
|
|
}),
|
|
|
|
|
hintText:
|
|
|
|
|
TranslationBase.of(context)
|
|
|
|
|
.fromDate,
|
|
|
|
|
borderColor: Colors.white,
|
|
|
|
|
prefix: IconButton(
|
|
|
|
|
icon: Icon(
|
|
|
|
|
Icons.calendar_today)),
|
|
|
|
|
textInputType:
|
|
|
|
|
TextInputType.number,
|
|
|
|
|
controller: _toDateController,
|
|
|
|
|
onTap: () {
|
|
|
|
|
_presentDatePicker(
|
|
|
|
|
'fromDate');
|
|
|
|
|
},
|
|
|
|
|
inputFormatter: ONLY_DATE,
|
|
|
|
|
onChanged: (val) =>
|
|
|
|
|
fromDate = val,
|
|
|
|
|
onSaved: (val) =>
|
|
|
|
|
fromDate = val,
|
|
|
|
|
)
|
|
|
|
|
],
|
|
|
|
|
)),
|
|
|
|
|
Row(
|
|
|
|
|
@ -391,22 +385,16 @@ class _RescheduleLeaveScreen extends State<RescheduleLeaveScreen> {
|
|
|
|
|
type:
|
|
|
|
|
DateTimePickerType.time,
|
|
|
|
|
controller: _controller4,
|
|
|
|
|
//initialValue: _initialValue,
|
|
|
|
|
// icon: Icon(Icons.access_time),
|
|
|
|
|
|
|
|
|
|
//use24HourFormat: false,
|
|
|
|
|
//locale: Locale('en', 'US'),
|
|
|
|
|
onChanged: (val) => () {
|
|
|
|
|
print(val);
|
|
|
|
|
this.fromTime = val;
|
|
|
|
|
},
|
|
|
|
|
onChanged: (val) =>
|
|
|
|
|
fromTime = val,
|
|
|
|
|
validator: (val) {
|
|
|
|
|
print(val);
|
|
|
|
|
// setState(
|
|
|
|
|
// () => _valueToValidate4 = val);
|
|
|
|
|
return null;
|
|
|
|
|
},
|
|
|
|
|
onSaved: (val) => {},
|
|
|
|
|
onSaved: (val) =>
|
|
|
|
|
fromTime = val,
|
|
|
|
|
)
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
@ -435,10 +423,9 @@ class _RescheduleLeaveScreen extends State<RescheduleLeaveScreen> {
|
|
|
|
|
.toTime,
|
|
|
|
|
type:
|
|
|
|
|
DateTimePickerType.time,
|
|
|
|
|
controller: _controller4,
|
|
|
|
|
onChanged: (val) => () {
|
|
|
|
|
this.toTime = val;
|
|
|
|
|
},
|
|
|
|
|
controller: _controller5,
|
|
|
|
|
onChanged: (val) =>
|
|
|
|
|
toTime = val,
|
|
|
|
|
validator: (val) {
|
|
|
|
|
print(val);
|
|
|
|
|
// setState(
|
|
|
|
|
@ -446,7 +433,7 @@ class _RescheduleLeaveScreen extends State<RescheduleLeaveScreen> {
|
|
|
|
|
return null;
|
|
|
|
|
},
|
|
|
|
|
onSaved: (val) =>
|
|
|
|
|
{print(val)},
|
|
|
|
|
toTime = val,
|
|
|
|
|
)
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
@ -510,7 +497,7 @@ class _RescheduleLeaveScreen extends State<RescheduleLeaveScreen> {
|
|
|
|
|
AppTextFormField(
|
|
|
|
|
hintText: TranslationBase
|
|
|
|
|
.of(context)
|
|
|
|
|
.fromDate,
|
|
|
|
|
.toDate,
|
|
|
|
|
borderColor: Colors.white,
|
|
|
|
|
prefix: IconButton(
|
|
|
|
|
icon: Icon(
|
|
|
|
|
@ -777,16 +764,34 @@ class _RescheduleLeaveScreen extends State<RescheduleLeaveScreen> {
|
|
|
|
|
return clinicInfo.length > 0 ? clinicInfo[0]['ClinicDescription'] : "";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
addRecheduleLeave(model) {
|
|
|
|
|
final df = new DateFormat('yyyy-MM-ddThh:mm:ss');
|
|
|
|
|
addRecheduleLeave(model) async {
|
|
|
|
|
final df = new DateFormat('yyyy-MM-ddTHH:MM:ss');
|
|
|
|
|
final dateFormat = new DateFormat('yyyy-MM-dd');
|
|
|
|
|
var fromDates = fromDate;
|
|
|
|
|
var toDates = toDate;
|
|
|
|
|
if (offTime == '1') {
|
|
|
|
|
fromDate = df.format(DateTime.parse(dateFormat.format(fromDates) +
|
|
|
|
|
'T' +
|
|
|
|
|
fromTime +
|
|
|
|
|
':' +
|
|
|
|
|
DateTime.now().second.toString()));
|
|
|
|
|
toDate = df.format(DateTime.parse(dateFormat.format(fromDates) +
|
|
|
|
|
'T' +
|
|
|
|
|
toTime +
|
|
|
|
|
':' +
|
|
|
|
|
DateTime.now().second.toString()));
|
|
|
|
|
} else {
|
|
|
|
|
fromDate = df.format(fromDates);
|
|
|
|
|
toDate = df.format(toDates);
|
|
|
|
|
}
|
|
|
|
|
Map<String, dynamic> request = {
|
|
|
|
|
"Requisition": {
|
|
|
|
|
"requisitionNo": 0,
|
|
|
|
|
"requisitionType": offTime,
|
|
|
|
|
"clinicId": this.profile['ClinicID'],
|
|
|
|
|
"doctorId": this.profile['DoctorID'],
|
|
|
|
|
"dateTimeFrom": df.format(fromDate),
|
|
|
|
|
"dateTimeTo": toDate != null ? df.format(toDate) : df.format(fromDate),
|
|
|
|
|
"dateTimeFrom": fromDate,
|
|
|
|
|
"dateTimeTo": toDate,
|
|
|
|
|
"date": df.format(DateTime.now()),
|
|
|
|
|
"reasonId": reason == null ? model.allOffTime[0]['code'] : reason,
|
|
|
|
|
"coveringDoctorId":
|
|
|
|
|
@ -797,8 +802,8 @@ class _RescheduleLeaveScreen extends State<RescheduleLeaveScreen> {
|
|
|
|
|
"weekDayId": 1,
|
|
|
|
|
"shiftId": 1,
|
|
|
|
|
"isOpen": true,
|
|
|
|
|
"timeFrom": fromTime,
|
|
|
|
|
"timeTo": toTime,
|
|
|
|
|
"timeFrom": "",
|
|
|
|
|
"timeTo": "",
|
|
|
|
|
"timeFromstr": "",
|
|
|
|
|
"timeTostr": ""
|
|
|
|
|
}
|
|
|
|
|
@ -806,29 +811,41 @@ class _RescheduleLeaveScreen extends State<RescheduleLeaveScreen> {
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
model.addReschedule(request).then((response) {
|
|
|
|
|
DrAppToastMsg.showSuccesToast(TranslationBase.of(context).leaveCreated);
|
|
|
|
|
Navigator.pop(context);
|
|
|
|
|
Navigator.push(
|
|
|
|
|
context,
|
|
|
|
|
MaterialPageRoute(
|
|
|
|
|
builder: (context) => AddRescheduleLeavScreen(),
|
|
|
|
|
// MyReferredPatient(),
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
await model.addReschedule(request).then((value) {
|
|
|
|
|
if (model.postSechedule != null) {
|
|
|
|
|
DrAppToastMsg.showSuccesToast(TranslationBase.of(context).leaveCreated);
|
|
|
|
|
Navigator.pushNamedAndRemoveUntil(context, HOME, (r) => false);
|
|
|
|
|
Navigator.push(
|
|
|
|
|
context,
|
|
|
|
|
MaterialPageRoute(
|
|
|
|
|
builder: (context) => AddRescheduleLeavScreen(),
|
|
|
|
|
// MyReferredPatient(),
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
updateRecheduleLeave(model) {
|
|
|
|
|
final df = new DateFormat('yyyy-MM-ddThh:mm:ss');
|
|
|
|
|
final dateFormat = new DateFormat('yyyy-MM-dd');
|
|
|
|
|
|
|
|
|
|
if (offTime == '1') {
|
|
|
|
|
fromDate = dateFormat.format(fromDate) + 'T' + fromTime + '00';
|
|
|
|
|
toDate = dateFormat.format(fromDate) + 'T' + toTime + '00';
|
|
|
|
|
} else {
|
|
|
|
|
fromDate = df.format(fromDate);
|
|
|
|
|
toDate = df.format(toDate);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Map<String, dynamic> request = {
|
|
|
|
|
"Requisition": {
|
|
|
|
|
"requisitionNo": 0,
|
|
|
|
|
"requisitionType": offTime,
|
|
|
|
|
"clinicId": this.profile['ClinicID'],
|
|
|
|
|
"doctorId": this.profile['DoctorID'],
|
|
|
|
|
"dateTimeFrom": df.format(fromDate),
|
|
|
|
|
"dateTimeTo": toDate != null ? df.format(toDate) : df.format(fromDate),
|
|
|
|
|
"dateTimeFrom": fromDate,
|
|
|
|
|
"dateTimeTo": toDate,
|
|
|
|
|
"date": df.format(DateTime.now()),
|
|
|
|
|
"reasonId": reason == null ? model.allOffTime[0]['code'] : reason,
|
|
|
|
|
"coveringDoctorId":
|
|
|
|
|
@ -849,7 +866,17 @@ class _RescheduleLeaveScreen extends State<RescheduleLeaveScreen> {
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
model.updateReschedule(request).then((response) {
|
|
|
|
|
print(response);
|
|
|
|
|
if (model.postSechedule != null) {
|
|
|
|
|
DrAppToastMsg.showSuccesToast(TranslationBase.of(context).leaveCreated);
|
|
|
|
|
Navigator.pushNamedAndRemoveUntil(context, HOME, (r) => false);
|
|
|
|
|
Navigator.push(
|
|
|
|
|
context,
|
|
|
|
|
MaterialPageRoute(
|
|
|
|
|
builder: (context) => AddRescheduleLeavScreen(),
|
|
|
|
|
// MyReferredPatient(),
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|