|
|
|
@ -1,3 +1,4 @@
|
|
|
|
|
import 'package:date_time_picker/date_time_picker.dart';
|
|
|
|
|
import 'package:doctor_app_flutter/config/config.dart';
|
|
|
|
|
import 'package:doctor_app_flutter/config/shared_pref_kay.dart';
|
|
|
|
|
import 'package:doctor_app_flutter/config/size_config.dart';
|
|
|
|
@ -34,16 +35,24 @@ class RescheduleLeaveScreen extends StatefulWidget {
|
|
|
|
|
class _RescheduleLeaveScreen extends State<RescheduleLeaveScreen> {
|
|
|
|
|
DrAppSharedPreferances sharedPref = new DrAppSharedPreferances();
|
|
|
|
|
TextEditingController _toDateController = new TextEditingController();
|
|
|
|
|
TextEditingController _toDateController2 = new TextEditingController();
|
|
|
|
|
ProjectViewModel projectsProvider;
|
|
|
|
|
String _selectedClinic;
|
|
|
|
|
Map profile = {};
|
|
|
|
|
AddSickLeaveRequest addSickLeave = AddSickLeaveRequest();
|
|
|
|
|
var offTime = '2';
|
|
|
|
|
var date;
|
|
|
|
|
var doctorID;
|
|
|
|
|
var reason;
|
|
|
|
|
var fromDate;
|
|
|
|
|
var toDate;
|
|
|
|
|
TextEditingController _controller4;
|
|
|
|
|
// AddSickLeaveRequest addSickLeave = AddSickLeaveRequest();
|
|
|
|
|
void _presentDatePicker(id) {
|
|
|
|
|
showDatePicker(
|
|
|
|
|
context: context,
|
|
|
|
|
initialDate: DateTime.now(),
|
|
|
|
|
firstDate: DateTime(2019),
|
|
|
|
|
lastDate: DateTime.now(),
|
|
|
|
|
firstDate: DateTime.now(),
|
|
|
|
|
lastDate: DateTime(2050),
|
|
|
|
|
).then((pickedDate) {
|
|
|
|
|
if (pickedDate == null) {
|
|
|
|
|
return;
|
|
|
|
@ -51,9 +60,16 @@ class _RescheduleLeaveScreen extends State<RescheduleLeaveScreen> {
|
|
|
|
|
setState(() {
|
|
|
|
|
// var selectedDate = DateFormat.yMd().format(pickedDate);
|
|
|
|
|
final df = new DateFormat('yyyy-MM-dd');
|
|
|
|
|
addSickLeave.startDate = df.format(pickedDate);
|
|
|
|
|
|
|
|
|
|
_toDateController.text = addSickLeave.startDate;
|
|
|
|
|
//addSickLeave.startDate;
|
|
|
|
|
|
|
|
|
|
if (id == 'fromDate') {
|
|
|
|
|
fromDate = pickedDate; //df.format();
|
|
|
|
|
_toDateController.text = df.format(pickedDate);
|
|
|
|
|
} else {
|
|
|
|
|
toDate = pickedDate; //
|
|
|
|
|
_toDateController2.text = df.format(pickedDate);
|
|
|
|
|
}
|
|
|
|
|
//addSickLeave.startDate = selectedDate;
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
@ -223,8 +239,10 @@ class _RescheduleLeaveScreen extends State<RescheduleLeaveScreen> {
|
|
|
|
|
child: DropdownButton(
|
|
|
|
|
focusColor: Colors.grey,
|
|
|
|
|
isExpanded: true,
|
|
|
|
|
value: model2.allOffTime[0]
|
|
|
|
|
['code'],
|
|
|
|
|
value: offTime == null
|
|
|
|
|
? model2.allOffTime[0]
|
|
|
|
|
['code']
|
|
|
|
|
: offTime,
|
|
|
|
|
iconSize: 40,
|
|
|
|
|
elevation: 16,
|
|
|
|
|
selectedItemBuilder:
|
|
|
|
@ -248,7 +266,18 @@ class _RescheduleLeaveScreen extends State<RescheduleLeaveScreen> {
|
|
|
|
|
);
|
|
|
|
|
}).toList();
|
|
|
|
|
},
|
|
|
|
|
onChanged: (newValue) => {},
|
|
|
|
|
onChanged: (newValue) => {
|
|
|
|
|
setState(() {
|
|
|
|
|
offTime = newValue;
|
|
|
|
|
}),
|
|
|
|
|
if (offTime == '1')
|
|
|
|
|
{model2.getReasons(18)}
|
|
|
|
|
else if (offTime == '2')
|
|
|
|
|
{model2.getReasons(19)}
|
|
|
|
|
else if (offTime == '3' ||
|
|
|
|
|
offTime == '5')
|
|
|
|
|
{model2.getReasons(102)}
|
|
|
|
|
},
|
|
|
|
|
items: model2.allOffTime
|
|
|
|
|
.map((item) {
|
|
|
|
|
return DropdownMenuItem<
|
|
|
|
@ -270,88 +299,215 @@ class _RescheduleLeaveScreen extends State<RescheduleLeaveScreen> {
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
)),
|
|
|
|
|
Container(
|
|
|
|
|
margin: EdgeInsets.all(8),
|
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
|
borderRadius:
|
|
|
|
|
BorderRadius.all(Radius.circular(6.0)),
|
|
|
|
|
border: Border.all(
|
|
|
|
|
width: 1.0,
|
|
|
|
|
color: HexColor("#CCCCCC"))),
|
|
|
|
|
padding: EdgeInsets.all(5),
|
|
|
|
|
child: Column(
|
|
|
|
|
crossAxisAlignment: 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: () {
|
|
|
|
|
_presentDatePicker('_selectedToDate');
|
|
|
|
|
},
|
|
|
|
|
inputFormatter: ONLY_DATE,
|
|
|
|
|
onChanged: (value) {
|
|
|
|
|
addSickLeave.startDate = value;
|
|
|
|
|
}),
|
|
|
|
|
],
|
|
|
|
|
)),
|
|
|
|
|
offTime == '1'
|
|
|
|
|
? Column(
|
|
|
|
|
children: [
|
|
|
|
|
Container(
|
|
|
|
|
margin: EdgeInsets.all(8),
|
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
|
borderRadius: BorderRadius.all(
|
|
|
|
|
Radius.circular(6.0)),
|
|
|
|
|
border: Border.all(
|
|
|
|
|
width: 1.0,
|
|
|
|
|
color: HexColor("#CCCCCC"))),
|
|
|
|
|
padding: EdgeInsets.all(5),
|
|
|
|
|
child: Column(
|
|
|
|
|
crossAxisAlignment:
|
|
|
|
|
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: () {
|
|
|
|
|
_presentDatePicker(
|
|
|
|
|
'fromDate');
|
|
|
|
|
},
|
|
|
|
|
inputFormatter: ONLY_DATE,
|
|
|
|
|
onChanged: (value) {
|
|
|
|
|
fromDate = value;
|
|
|
|
|
}),
|
|
|
|
|
],
|
|
|
|
|
)),
|
|
|
|
|
Row(
|
|
|
|
|
children: [
|
|
|
|
|
Expanded(
|
|
|
|
|
child: Container(
|
|
|
|
|
margin: EdgeInsets.all(8),
|
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
|
borderRadius:
|
|
|
|
|
BorderRadius.all(
|
|
|
|
|
Radius.circular(6.0)),
|
|
|
|
|
border: Border.all(
|
|
|
|
|
width: 1.0,
|
|
|
|
|
color:
|
|
|
|
|
HexColor("#CCCCCC"))),
|
|
|
|
|
padding: EdgeInsets.all(5),
|
|
|
|
|
child: Column(
|
|
|
|
|
crossAxisAlignment:
|
|
|
|
|
CrossAxisAlignment.start,
|
|
|
|
|
children: [
|
|
|
|
|
// new AppTextFormField(
|
|
|
|
|
// readOnly: true,
|
|
|
|
|
// hintText: "",
|
|
|
|
|
// borderColor: Colors.white,
|
|
|
|
|
// onSaved: (value) {},
|
|
|
|
|
// inputFormatter: ONLY_NUMBERS),
|
|
|
|
|
|
|
|
|
|
Row(
|
|
|
|
|
children: [
|
|
|
|
|
Expanded(
|
|
|
|
|
child: Container(
|
|
|
|
|
margin: EdgeInsets.all(8),
|
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
|
borderRadius: BorderRadius.all(
|
|
|
|
|
Radius.circular(6.0)),
|
|
|
|
|
border: Border.all(
|
|
|
|
|
width: 1.0,
|
|
|
|
|
color: HexColor("#CCCCCC"))),
|
|
|
|
|
padding: EdgeInsets.all(5),
|
|
|
|
|
child: Column(
|
|
|
|
|
crossAxisAlignment:
|
|
|
|
|
CrossAxisAlignment.start,
|
|
|
|
|
children: [
|
|
|
|
|
new AppTextFormField(
|
|
|
|
|
readOnly: true,
|
|
|
|
|
hintText: "",
|
|
|
|
|
borderColor: Colors.white,
|
|
|
|
|
onSaved: (value) {},
|
|
|
|
|
inputFormatter: ONLY_NUMBERS),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
Expanded(
|
|
|
|
|
child: Container(
|
|
|
|
|
margin: EdgeInsets.all(8),
|
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
|
borderRadius: BorderRadius.all(
|
|
|
|
|
Radius.circular(6.0)),
|
|
|
|
|
border: Border.all(
|
|
|
|
|
width: 1.0,
|
|
|
|
|
color: HexColor("#CCCCCC"))),
|
|
|
|
|
padding: EdgeInsets.all(5),
|
|
|
|
|
child: Column(
|
|
|
|
|
crossAxisAlignment:
|
|
|
|
|
CrossAxisAlignment.start,
|
|
|
|
|
children: [
|
|
|
|
|
new AppTextFormField(
|
|
|
|
|
readOnly: true,
|
|
|
|
|
hintText: "",
|
|
|
|
|
borderColor: Colors.white,
|
|
|
|
|
onSaved: (value) {},
|
|
|
|
|
inputFormatter: ONLY_NUMBERS),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
DateTimePicker(
|
|
|
|
|
type:
|
|
|
|
|
DateTimePickerType.time,
|
|
|
|
|
controller: _controller4,
|
|
|
|
|
//initialValue: _initialValue,
|
|
|
|
|
// icon: Icon(Icons.access_time),
|
|
|
|
|
|
|
|
|
|
//use24HourFormat: false,
|
|
|
|
|
//locale: Locale('en', 'US'),
|
|
|
|
|
onChanged: (val) => () {
|
|
|
|
|
print(val);
|
|
|
|
|
},
|
|
|
|
|
validator: (val) {
|
|
|
|
|
print(val);
|
|
|
|
|
// setState(
|
|
|
|
|
// () => _valueToValidate4 = val);
|
|
|
|
|
return null;
|
|
|
|
|
},
|
|
|
|
|
onSaved: (val) => {},
|
|
|
|
|
)
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
Expanded(
|
|
|
|
|
child: Container(
|
|
|
|
|
margin: EdgeInsets.all(8),
|
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
|
borderRadius:
|
|
|
|
|
BorderRadius.all(
|
|
|
|
|
Radius.circular(6.0)),
|
|
|
|
|
border: Border.all(
|
|
|
|
|
width: 1.0,
|
|
|
|
|
color:
|
|
|
|
|
HexColor("#CCCCCC"))),
|
|
|
|
|
padding: EdgeInsets.all(5),
|
|
|
|
|
child: Column(
|
|
|
|
|
crossAxisAlignment:
|
|
|
|
|
CrossAxisAlignment.start,
|
|
|
|
|
children: [
|
|
|
|
|
DateTimePicker(
|
|
|
|
|
type:
|
|
|
|
|
DateTimePickerType.time,
|
|
|
|
|
controller: _controller4,
|
|
|
|
|
//initialValue: _initialValue,
|
|
|
|
|
// icon: Icon(Icons.access_time),
|
|
|
|
|
|
|
|
|
|
//use24HourFormat: false,
|
|
|
|
|
//locale: Locale('en', 'US'),
|
|
|
|
|
onChanged: (val) => () {
|
|
|
|
|
print(val);
|
|
|
|
|
},
|
|
|
|
|
validator: (val) {
|
|
|
|
|
print(val);
|
|
|
|
|
// setState(
|
|
|
|
|
// () => _valueToValidate4 = val);
|
|
|
|
|
return null;
|
|
|
|
|
},
|
|
|
|
|
onSaved: (val) =>
|
|
|
|
|
{print(val)},
|
|
|
|
|
)
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
)
|
|
|
|
|
],
|
|
|
|
|
)
|
|
|
|
|
],
|
|
|
|
|
)
|
|
|
|
|
: Column(
|
|
|
|
|
children: [
|
|
|
|
|
Container(
|
|
|
|
|
margin: EdgeInsets.all(8),
|
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
|
borderRadius: BorderRadius.all(
|
|
|
|
|
Radius.circular(6.0)),
|
|
|
|
|
border: Border.all(
|
|
|
|
|
width: 1.0,
|
|
|
|
|
color: HexColor("#CCCCCC"))),
|
|
|
|
|
padding: EdgeInsets.all(5),
|
|
|
|
|
child: Column(
|
|
|
|
|
crossAxisAlignment:
|
|
|
|
|
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: () {
|
|
|
|
|
_presentDatePicker(
|
|
|
|
|
'fromDate');
|
|
|
|
|
},
|
|
|
|
|
inputFormatter: ONLY_DATE,
|
|
|
|
|
onChanged: (value) {
|
|
|
|
|
setState(() {
|
|
|
|
|
toDate = value;
|
|
|
|
|
});
|
|
|
|
|
}),
|
|
|
|
|
],
|
|
|
|
|
)),
|
|
|
|
|
Container(
|
|
|
|
|
margin: EdgeInsets.all(8),
|
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
|
borderRadius: BorderRadius.all(
|
|
|
|
|
Radius.circular(6.0)),
|
|
|
|
|
border: Border.all(
|
|
|
|
|
width: 1.0,
|
|
|
|
|
color: HexColor("#CCCCCC"))),
|
|
|
|
|
padding: EdgeInsets.all(5),
|
|
|
|
|
child: Column(
|
|
|
|
|
crossAxisAlignment:
|
|
|
|
|
CrossAxisAlignment.start,
|
|
|
|
|
children: [
|
|
|
|
|
AppTextFormField(
|
|
|
|
|
hintText: TranslationBase
|
|
|
|
|
.of(context)
|
|
|
|
|
.fromDate,
|
|
|
|
|
borderColor: Colors.white,
|
|
|
|
|
prefix: IconButton(
|
|
|
|
|
icon: Icon(
|
|
|
|
|
Icons
|
|
|
|
|
.calendar_today)),
|
|
|
|
|
textInputType:
|
|
|
|
|
TextInputType.number,
|
|
|
|
|
controller:
|
|
|
|
|
_toDateController2,
|
|
|
|
|
onTap: () {
|
|
|
|
|
_presentDatePicker(
|
|
|
|
|
'toDate');
|
|
|
|
|
},
|
|
|
|
|
inputFormatter: ONLY_DATE,
|
|
|
|
|
onChanged: (value) {
|
|
|
|
|
setState(() {
|
|
|
|
|
toDate = value;
|
|
|
|
|
});
|
|
|
|
|
}),
|
|
|
|
|
],
|
|
|
|
|
))
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
)
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
Container(
|
|
|
|
|
margin: EdgeInsets.all(8),
|
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
@ -382,9 +538,11 @@ class _RescheduleLeaveScreen extends State<RescheduleLeaveScreen> {
|
|
|
|
|
child: DropdownButton(
|
|
|
|
|
focusColor: Colors.grey,
|
|
|
|
|
isExpanded: true,
|
|
|
|
|
value: model2.allReasons[0]
|
|
|
|
|
['id']
|
|
|
|
|
.toString(),
|
|
|
|
|
value: reason == null
|
|
|
|
|
? model2.allReasons[0]
|
|
|
|
|
['id']
|
|
|
|
|
.toString()
|
|
|
|
|
: reason,
|
|
|
|
|
iconSize: 40,
|
|
|
|
|
elevation: 16,
|
|
|
|
|
selectedItemBuilder:
|
|
|
|
@ -412,7 +570,11 @@ class _RescheduleLeaveScreen extends State<RescheduleLeaveScreen> {
|
|
|
|
|
);
|
|
|
|
|
}).toList();
|
|
|
|
|
},
|
|
|
|
|
onChanged: (newValue) => {},
|
|
|
|
|
onChanged: (newValue) => {
|
|
|
|
|
setState(() {
|
|
|
|
|
reason = newValue;
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
items: model2.allReasons
|
|
|
|
|
.map((item) {
|
|
|
|
|
return DropdownMenuItem<
|
|
|
|
@ -468,10 +630,12 @@ class _RescheduleLeaveScreen extends State<RescheduleLeaveScreen> {
|
|
|
|
|
child: DropdownButton(
|
|
|
|
|
focusColor: Colors.grey,
|
|
|
|
|
isExpanded: true,
|
|
|
|
|
value: model2
|
|
|
|
|
.coveringDoctors[0]
|
|
|
|
|
['doctorID']
|
|
|
|
|
.toString(),
|
|
|
|
|
value: doctorID == null
|
|
|
|
|
? model2
|
|
|
|
|
.coveringDoctors[0]
|
|
|
|
|
['doctorID']
|
|
|
|
|
.toString()
|
|
|
|
|
: doctorID,
|
|
|
|
|
iconSize: 40,
|
|
|
|
|
elevation: 16,
|
|
|
|
|
selectedItemBuilder:
|
|
|
|
@ -500,7 +664,11 @@ class _RescheduleLeaveScreen extends State<RescheduleLeaveScreen> {
|
|
|
|
|
);
|
|
|
|
|
}).toList();
|
|
|
|
|
},
|
|
|
|
|
onChanged: (newValue) => {},
|
|
|
|
|
onChanged: (newValue) => {
|
|
|
|
|
setState(() {
|
|
|
|
|
doctorID = newValue;
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
items: model2
|
|
|
|
|
.coveringDoctors
|
|
|
|
|
.map((item) {
|
|
|
|
@ -536,7 +704,9 @@ class _RescheduleLeaveScreen extends State<RescheduleLeaveScreen> {
|
|
|
|
|
children: <Widget>[
|
|
|
|
|
AppButton(
|
|
|
|
|
title: TranslationBase.of(context).add,
|
|
|
|
|
onPressed: () {},
|
|
|
|
|
onPressed: () {
|
|
|
|
|
addRecheduleLeave(model2);
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
@ -569,4 +739,38 @@ class _RescheduleLeaveScreen extends State<RescheduleLeaveScreen> {
|
|
|
|
|
model.clinicsList.where((i) => i['ClinicID'] == clinicID).toList();
|
|
|
|
|
return clinicInfo.length > 0 ? clinicInfo[0]['ClinicDescription'] : "";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
addRecheduleLeave(model) {
|
|
|
|
|
final df = new DateFormat('yyyy-MM-ddThh:mm:ss');
|
|
|
|
|
Map<String, dynamic> request = {
|
|
|
|
|
"Requisition": {
|
|
|
|
|
"requisitionNo": 0,
|
|
|
|
|
"requisitionType": offTime,
|
|
|
|
|
"clinicId": this.profile['ClinicID'],
|
|
|
|
|
"doctorId": this.profile['ClinicID'],
|
|
|
|
|
"dateTimeFrom": df.format(fromDate),
|
|
|
|
|
"dateTimeTo": df.format(toDate),
|
|
|
|
|
"date": df.format(DateTime.now()),
|
|
|
|
|
"reasonId": reason == null ? model.allOffTime[0]['code'] : reason,
|
|
|
|
|
"coveringDoctorId":
|
|
|
|
|
doctorID == null ? model.coveringDoctors[0]['doctorID'] : doctorID,
|
|
|
|
|
"status": 2,
|
|
|
|
|
"schedule": [
|
|
|
|
|
{
|
|
|
|
|
"weekDayId": 1,
|
|
|
|
|
"shiftId": 1,
|
|
|
|
|
"isOpen": true,
|
|
|
|
|
"timeFrom": null,
|
|
|
|
|
"timeTo": null,
|
|
|
|
|
"timeFromstr": "",
|
|
|
|
|
"timeTostr": ""
|
|
|
|
|
}
|
|
|
|
|
]
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
model.addReschedule(request).then((response) {
|
|
|
|
|
print(response);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|