|
|
|
@ -24,6 +24,7 @@ import 'package:hexcolor/hexcolor.dart';
|
|
|
|
|
import 'package:intl/intl.dart';
|
|
|
|
|
import 'package:doctor_app_flutter/models/sickleave/get_all_sickleave_response.dart';
|
|
|
|
|
import 'package:provider/provider.dart';
|
|
|
|
|
import 'package:doctor_app_flutter/screens/reschedule-leaves/add-rescheduleleave.dart';
|
|
|
|
|
|
|
|
|
|
Helpers helpers = Helpers();
|
|
|
|
|
|
|
|
|
@ -49,13 +50,40 @@ class _RescheduleLeaveScreen extends State<RescheduleLeaveScreen> {
|
|
|
|
|
var fromDate;
|
|
|
|
|
var toDate;
|
|
|
|
|
var clinicID;
|
|
|
|
|
var fromTime;
|
|
|
|
|
var toTime;
|
|
|
|
|
TextEditingController _controller4;
|
|
|
|
|
void _presentDatePicker(id) {
|
|
|
|
|
var date = new DateTime.now();
|
|
|
|
|
var initialDate = id == 'fromDate'
|
|
|
|
|
? new DateTime(date.year, date.month, date.day + 15)
|
|
|
|
|
: new DateTime(fromDate.year, fromDate.month, fromDate.day);
|
|
|
|
|
var firstDate = id == 'fromDate'
|
|
|
|
|
? new DateTime(date.year, date.month, date.day + 15)
|
|
|
|
|
: new DateTime(fromDate.year, fromDate.month, fromDate.day);
|
|
|
|
|
showDatePicker(
|
|
|
|
|
context: context,
|
|
|
|
|
initialDate: new DateTime(date.year, date.month, date.day + 15),
|
|
|
|
|
firstDate: new DateTime(date.year, date.month, date.day + 15),
|
|
|
|
|
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) {
|
|
|
|
@ -328,7 +356,7 @@ class _RescheduleLeaveScreen extends State<RescheduleLeaveScreen> {
|
|
|
|
|
TextInputType.number,
|
|
|
|
|
controller: _toDateController,
|
|
|
|
|
onTap: () {
|
|
|
|
|
_presentDatePicker(
|
|
|
|
|
_presentCurrentDate(
|
|
|
|
|
'fromDate');
|
|
|
|
|
},
|
|
|
|
|
inputFormatter: ONLY_DATE,
|
|
|
|
@ -355,14 +383,11 @@ class _RescheduleLeaveScreen extends State<RescheduleLeaveScreen> {
|
|
|
|
|
crossAxisAlignment:
|
|
|
|
|
CrossAxisAlignment.start,
|
|
|
|
|
children: [
|
|
|
|
|
// new AppTextFormField(
|
|
|
|
|
// readOnly: true,
|
|
|
|
|
// hintText: "",
|
|
|
|
|
// borderColor: Colors.white,
|
|
|
|
|
// onSaved: (value) {},
|
|
|
|
|
// inputFormatter: ONLY_NUMBERS),
|
|
|
|
|
|
|
|
|
|
DateTimePicker(
|
|
|
|
|
timeHintText:
|
|
|
|
|
TranslationBase.of(
|
|
|
|
|
context)
|
|
|
|
|
.fromTime,
|
|
|
|
|
type:
|
|
|
|
|
DateTimePickerType.time,
|
|
|
|
|
controller: _controller4,
|
|
|
|
@ -373,6 +398,7 @@ class _RescheduleLeaveScreen extends State<RescheduleLeaveScreen> {
|
|
|
|
|
//locale: Locale('en', 'US'),
|
|
|
|
|
onChanged: (val) => () {
|
|
|
|
|
print(val);
|
|
|
|
|
this.fromTime = val;
|
|
|
|
|
},
|
|
|
|
|
validator: (val) {
|
|
|
|
|
print(val);
|
|
|
|
@ -403,16 +429,15 @@ class _RescheduleLeaveScreen extends State<RescheduleLeaveScreen> {
|
|
|
|
|
CrossAxisAlignment.start,
|
|
|
|
|
children: [
|
|
|
|
|
DateTimePicker(
|
|
|
|
|
timeHintText:
|
|
|
|
|
TranslationBase.of(
|
|
|
|
|
context)
|
|
|
|
|
.toTime,
|
|
|
|
|
type:
|
|
|
|
|
DateTimePickerType.time,
|
|
|
|
|
controller: _controller4,
|
|
|
|
|
//initialValue: _initialValue,
|
|
|
|
|
// icon: Icon(Icons.access_time),
|
|
|
|
|
|
|
|
|
|
//use24HourFormat: false,
|
|
|
|
|
//locale: Locale('en', 'US'),
|
|
|
|
|
onChanged: (val) => () {
|
|
|
|
|
print(val);
|
|
|
|
|
this.toTime = val;
|
|
|
|
|
},
|
|
|
|
|
validator: (val) {
|
|
|
|
|
print(val);
|
|
|
|
@ -761,7 +786,7 @@ class _RescheduleLeaveScreen extends State<RescheduleLeaveScreen> {
|
|
|
|
|
"clinicId": this.profile['ClinicID'],
|
|
|
|
|
"doctorId": this.profile['DoctorID'],
|
|
|
|
|
"dateTimeFrom": df.format(fromDate),
|
|
|
|
|
"dateTimeTo": df.format(toDate),
|
|
|
|
|
"dateTimeTo": toDate != null ? df.format(toDate) : df.format(fromDate),
|
|
|
|
|
"date": df.format(DateTime.now()),
|
|
|
|
|
"reasonId": reason == null ? model.allOffTime[0]['code'] : reason,
|
|
|
|
|
"coveringDoctorId":
|
|
|
|
@ -772,8 +797,8 @@ class _RescheduleLeaveScreen extends State<RescheduleLeaveScreen> {
|
|
|
|
|
"weekDayId": 1,
|
|
|
|
|
"shiftId": 1,
|
|
|
|
|
"isOpen": true,
|
|
|
|
|
"timeFrom": null,
|
|
|
|
|
"timeTo": null,
|
|
|
|
|
"timeFrom": fromTime,
|
|
|
|
|
"timeTo": toTime,
|
|
|
|
|
"timeFromstr": "",
|
|
|
|
|
"timeTostr": ""
|
|
|
|
|
}
|
|
|
|
@ -784,7 +809,13 @@ class _RescheduleLeaveScreen extends State<RescheduleLeaveScreen> {
|
|
|
|
|
model.addReschedule(request).then((response) {
|
|
|
|
|
DrAppToastMsg.showSuccesToast(TranslationBase.of(context).leaveCreated);
|
|
|
|
|
Navigator.pop(context);
|
|
|
|
|
model.getRescheduleLeave();
|
|
|
|
|
Navigator.push(
|
|
|
|
|
context,
|
|
|
|
|
MaterialPageRoute(
|
|
|
|
|
builder: (context) => AddRescheduleLeavScreen(),
|
|
|
|
|
// MyReferredPatient(),
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -797,7 +828,7 @@ class _RescheduleLeaveScreen extends State<RescheduleLeaveScreen> {
|
|
|
|
|
"clinicId": this.profile['ClinicID'],
|
|
|
|
|
"doctorId": this.profile['DoctorID'],
|
|
|
|
|
"dateTimeFrom": df.format(fromDate),
|
|
|
|
|
"dateTimeTo": df.format(toDate),
|
|
|
|
|
"dateTimeTo": toDate != null ? df.format(toDate) : df.format(fromDate),
|
|
|
|
|
"date": df.format(DateTime.now()),
|
|
|
|
|
"reasonId": reason == null ? model.allOffTime[0]['code'] : reason,
|
|
|
|
|
"coveringDoctorId":
|
|
|
|
@ -808,8 +839,8 @@ class _RescheduleLeaveScreen extends State<RescheduleLeaveScreen> {
|
|
|
|
|
"weekDayId": 1,
|
|
|
|
|
"shiftId": 1,
|
|
|
|
|
"isOpen": true,
|
|
|
|
|
"timeFrom": null,
|
|
|
|
|
"timeTo": null,
|
|
|
|
|
"timeFrom": fromTime,
|
|
|
|
|
"timeTo": toTime,
|
|
|
|
|
"timeFromstr": "",
|
|
|
|
|
"timeTostr": ""
|
|
|
|
|
}
|
|
|
|
|