diff --git a/lib/client/base_app_client.dart b/lib/client/base_app_client.dart index 94c732a5..c0a6b357 100644 --- a/lib/client/base_app_client.dart +++ b/lib/client/base_app_client.dart @@ -85,7 +85,7 @@ class BaseAppClient { if (!parsed['IsAuthenticated']) { //need to uncomment // await helpers.logout(); - + onSuccess(parsed, statusCode); helpers.showErrorToast('Your session expired Please login agian'); } else if (parsed['MessageStatus'] == 1) { onSuccess(parsed, statusCode); diff --git a/lib/config/config.dart b/lib/config/config.dart index 17e23187..39dfb023 100644 --- a/lib/config/config.dart +++ b/lib/config/config.dart @@ -83,7 +83,9 @@ const GET_SICKLEAVE_STATISTIC = 'Services/DoctorApplication.svc/REST/PreSickLeaveStatistics'; const ARRIVED_PATIENT_URL = 'Services/DoctorApplication.svc/REST/PatientArrivalList​'; - +const ADD_SICK_LEAVE = 'Services/DoctorApplication.svc/REST/PostSickLeave'; +const GET_SICK_LEAVE = 'Services/DoctorApplication.svc/REST/GetAllSickLeaves'; +const EXTEND_SICK_LEAVE = 'Services/DoctorApplication.svc/REST/ExtendSickLeave'; var selectedPatientType = 1; //*********change value to decode json from Dropdown ************ diff --git a/lib/config/localized_values.dart b/lib/config/localized_values.dart index dddccfa2..0abdad83 100644 --- a/lib/config/localized_values.dart +++ b/lib/config/localized_values.dart @@ -266,7 +266,7 @@ const Map> localizedValues = { }, 'gender2': {'en': 'Gender: ', 'ar': 'الجنس: '}, 'age2': {'en': 'Age: ', 'ar': 'العمر: '}, - "sick-leaves": {"en": "Patient Sick", "ar": "الاجازات المرضية"}, + "sick-leaves": {"en": "Patient Sick Leave", "ar": "الاجازات المرضية"}, "patient-sick": {"en": "Patient Sick", "ar": "المرضية"}, "leave": {"en": "Leave", "ar": "غادر"}, "submit": {"en": "Submit", "ar": "ارسال"}, @@ -295,4 +295,14 @@ const Map> localizedValues = { 'applynow': {'en': "Apply Now", 'ar': 'قدم الآن'}, 'add-sickleave': {'en': "ADD SICK LEAVE", 'ar': 'أضف إجازة مرضية'}, 'add': {'en': "Add", 'ar': 'أضف'}, + 'approved': {'en': "Approved", 'ar': 'وافق'}, + 'extended': {'en': "Extended", 'ar': 'وسعوا'}, + 'pending': {'en': "Pending", 'ar': 'قيد الانتظار'}, + 'leave-start-date': {'en': "Leave start date", 'ar': 'تاريخ بدء المغادرة'}, + 'days-sick-leave': {'en': "DAYS OF SICK LEAVE", 'ar': 'أيام الإجازة المرضية'}, + 'extend': {'en': "Extend", 'ar': 'تمديد'}, + 'extend-sickleave': { + 'en': "EXTEND SICK LEAVE", + 'ar': 'قم بتمديد الإجازة المرضية' + }, }; diff --git a/lib/core/service/sickleave_service.dart b/lib/core/service/sickleave_service.dart index 7e9de230..1c5ee415 100644 --- a/lib/core/service/sickleave_service.dart +++ b/lib/core/service/sickleave_service.dart @@ -1,10 +1,16 @@ import 'package:doctor_app_flutter/config/config.dart'; import 'package:doctor_app_flutter/core/service/base/base_service.dart'; +import 'package:doctor_app_flutter/models/sickleave/add_sickleave_request.dart'; +import 'package:doctor_app_flutter/models/sickleave/extend_sick_leave_request.dart'; +import 'package:doctor_app_flutter/models/sickleave/get_all_sickleave_response.dart'; // import 'package:doctor_app_flutter/models/dashboard/dashboard_model.dart'; class SickLeaveService extends BaseService { Map get sickLeavestatisitics => _statistics; Map _statistics = {}; + + List get getAllSickLeave => _getAllsickLeave; + List _getAllsickLeave = []; Future getStatistics() async { hasError = false; await baseAppClient.post( @@ -18,7 +24,70 @@ class SickLeaveService extends BaseService { hasError = true; super.error = error; }, - body: {"PatientMRN": 3120737, "AppointmentNo": 2016055008}, + body: {"PatientMRN": 3120746, "AppointmentNo": 2016054661}, + ); + } + + Future addSickLeave(AddSickLeaveRequest addSickLeaveRequest) async { + addSickLeaveRequest.appointmentNo = '2016054661'; + addSickLeaveRequest.patientMRN = '3120746'; + hasError = false; + await baseAppClient.post( + ADD_SICK_LEAVE, + onSuccess: (dynamic response, int statusCode) { + Future.value(response); + print(response); + // _statistics = {}; + // _statistics = response['SickLeaveStatistics']; + }, + onFailure: (String error, int statusCode) { + hasError = true; + super.error = error; + }, + body: addSickLeaveRequest.toJson(), + ); + } + + Future extendSickLeave(GetAllSickLeaveResponse request) async { + var extendSickLeaveRequest = ExtendSickLeaveRequest(); + extendSickLeaveRequest.patientMRN = + request.patientMRN.toString(); //'3120746'; + extendSickLeaveRequest.previousRequestNo = request.requestNo.toString(); + extendSickLeaveRequest.noOfDays = request.noOfDays.toString(); + extendSickLeaveRequest.remarks = request.remarks; + hasError = false; + await baseAppClient.post( + EXTEND_SICK_LEAVE, + onSuccess: (dynamic response, int statusCode) { + Future.value(response); + print(response); + // _statistics = {}; + // _statistics = response['SickLeaveStatistics']; + }, + onFailure: (String error, int statusCode) { + hasError = true; + super.error = error; + }, + body: extendSickLeaveRequest.toJson(), + ); + } + + Future getSickLeave() async { + hasError = false; + await baseAppClient.post( + GET_SICK_LEAVE, + onSuccess: (dynamic response, int statusCode) { + Future.value(response); + _getAllsickLeave.clear(); + response['SickLeavesList']['entityList'].forEach((v) { + _getAllsickLeave.add(GetAllSickLeaveResponse.fromJson(v)); + }); + }, + onFailure: (String error, int statusCode) { + hasError = true; + super.error = error; + }, + body: {'PatientMRN': 3120772}, ); } } diff --git a/lib/core/viewModel/sick_leave_view_model.dart b/lib/core/viewModel/sick_leave_view_model.dart index eecee46d..7eac919f 100644 --- a/lib/core/viewModel/sick_leave_view_model.dart +++ b/lib/core/viewModel/sick_leave_view_model.dart @@ -1,6 +1,9 @@ import 'package:doctor_app_flutter/core/enum/viewstate.dart'; import 'package:doctor_app_flutter/core/service/sickleave_service.dart'; import 'package:doctor_app_flutter/core/service/medicine_service.dart'; +import 'package:doctor_app_flutter/models/sickleave/add_sickleave_request.dart'; +import 'package:doctor_app_flutter/models/sickleave/extend_sick_leave_request.dart'; +import 'package:doctor_app_flutter/models/sickleave/get_all_sickleave_response.dart'; import '../../locator.dart'; import 'base_view_model.dart'; @@ -8,16 +11,26 @@ import 'base_view_model.dart'; class SickLeaveViewModel extends BaseViewModel { SickLeaveService _sickLeaveService = locator(); get sickLeaveStatistics => _sickLeaveService.sickLeavestatisitics; + get getAllSIckLeave => _sickLeaveService.getAllSickLeave; + Future addSickLeave(AddSickLeaveRequest addSickLeaveRequest) async { + setState(ViewState.Busy); + await _sickLeaveService.addSickLeave(addSickLeaveRequest); + if (_sickLeaveService.hasError) { + error = _sickLeaveService.error; + setState(ViewState.Error); + } else + setState(ViewState.Idle); + } - // Future getDashboard() async { - // setState(ViewState.Busy); - // await _dashboardService.getDashboard(); - // if (_dashboardService.hasError) { - // error = _dashboardService.error; - // setState(ViewState.Error); - // } else - // setState(ViewState.Idle); - // } + Future extendSickLeave(GetAllSickLeaveResponse extendSickLeaveRequest) async { + setState(ViewState.Busy); + await _sickLeaveService.extendSickLeave(extendSickLeaveRequest); + if (_sickLeaveService.hasError) { + error = _sickLeaveService.error; + setState(ViewState.Error); + } else + setState(ViewState.Idle); + } Future preSickLeaveStatistics() async { setState(ViewState.Busy); @@ -28,4 +41,14 @@ class SickLeaveViewModel extends BaseViewModel { } else setState(ViewState.Idle); } + + Future getSickLeave() async { + setState(ViewState.Busy); + await _sickLeaveService.getSickLeave(); + if (_sickLeaveService.hasError) { + error = _sickLeaveService.error; + setState(ViewState.Error); + } else + setState(ViewState.Idle); + } } diff --git a/lib/models/sickleave/add_sickleave_request.dart b/lib/models/sickleave/add_sickleave_request.dart new file mode 100644 index 00000000..d398153b --- /dev/null +++ b/lib/models/sickleave/add_sickleave_request.dart @@ -0,0 +1,32 @@ +class AddSickLeaveRequest { + String patientMRN; + String appointmentNo; + String startDate; + String noOfDays; + String remarks; + + AddSickLeaveRequest( + {this.patientMRN, + this.appointmentNo, + this.startDate, + this.noOfDays, + this.remarks}); + + AddSickLeaveRequest.fromJson(Map json) { + patientMRN = json['PatientMRN']; + appointmentNo = json['AppointmentNo']; + startDate = json['StartDate']; + noOfDays = json['NoOfDays']; + remarks = json['Remarks']; + } + + Map toJson() { + final Map data = new Map(); + data['PatientMRN'] = this.patientMRN; + data['AppointmentNo'] = this.appointmentNo; + data['StartDate'] = this.startDate; + data['NoOfDays'] = this.noOfDays; + data['Remarks'] = this.remarks; + return data; + } +} diff --git a/lib/models/sickleave/extend_sick_leave_request.dart b/lib/models/sickleave/extend_sick_leave_request.dart new file mode 100644 index 00000000..8b61eb90 --- /dev/null +++ b/lib/models/sickleave/extend_sick_leave_request.dart @@ -0,0 +1,25 @@ +class ExtendSickLeaveRequest { + String patientMRN; + String previousRequestNo; + String noOfDays; + String remarks; + + ExtendSickLeaveRequest( + {this.patientMRN, this.previousRequestNo, this.noOfDays, this.remarks}); + + ExtendSickLeaveRequest.fromJson(Map json) { + patientMRN = json['PatientMRN']; + previousRequestNo = json['PreviousRequestNo']; + noOfDays = json['NoOfDays']; + remarks = json['Remarks']; + } + + Map toJson() { + final Map data = new Map(); + data['PatientMRN'] = this.patientMRN; + data['PreviousRequestNo'] = this.previousRequestNo; + data['NoOfDays'] = this.noOfDays; + data['Remarks'] = this.remarks; + return data; + } +} diff --git a/lib/models/sickleave/get_all_sickleave_response.dart b/lib/models/sickleave/get_all_sickleave_response.dart new file mode 100644 index 00000000..f3fc8032 --- /dev/null +++ b/lib/models/sickleave/get_all_sickleave_response.dart @@ -0,0 +1,44 @@ +class GetAllSickLeaveResponse { + int appointmentNo; + bool isExtendedLeave; + int noOfDays; + int patientMRN; + String remarks; + int requestNo; + String startDate; + int status; + + GetAllSickLeaveResponse( + {this.appointmentNo, + this.isExtendedLeave, + this.noOfDays, + this.patientMRN, + this.remarks, + this.requestNo, + this.startDate, + this.status}); + + GetAllSickLeaveResponse.fromJson(Map json) { + appointmentNo = json['appointmentNo']; + isExtendedLeave = json['isExtendedLeave']; + noOfDays = json['noOfDays']; + patientMRN = json['patientMRN']; + remarks = json['remarks']; + requestNo = json['requestNo']; + startDate = json['startDate']; + status = json['status']; + } + + Map toJson() { + final Map data = new Map(); + data['appointmentNo'] = this.appointmentNo; + data['isExtendedLeave'] = this.isExtendedLeave; + data['noOfDays'] = this.noOfDays; + data['patientMRN'] = this.patientMRN; + data['remarks'] = this.remarks; + data['requestNo'] = this.requestNo; + data['startDate'] = this.startDate; + data['status'] = this.status; + return data; + } +} diff --git a/lib/screens/sick-leave/add-sickleave.dart b/lib/screens/sick-leave/add-sickleave.dart index 57960ec2..697b9127 100644 --- a/lib/screens/sick-leave/add-sickleave.dart +++ b/lib/screens/sick-leave/add-sickleave.dart @@ -1,58 +1,184 @@ +import 'package:doctor_app_flutter/config/size_config.dart'; +import 'package:doctor_app_flutter/core/viewModel/patient_view_model.dart'; +import 'package:doctor_app_flutter/core/viewModel/sick_leave_view_model.dart'; +import 'package:doctor_app_flutter/icons_app/doctor_app_icons.dart'; +import 'package:doctor_app_flutter/models/sickleave/get_all_sickleave_response.dart'; +import 'package:doctor_app_flutter/screens/base/base_view.dart'; import 'package:doctor_app_flutter/screens/sick-leave/sick_leave.dart'; import 'package:doctor_app_flutter/util/translations_delegate_base.dart'; import 'package:doctor_app_flutter/widgets/shared/app_scaffold_widget.dart'; import 'package:doctor_app_flutter/widgets/shared/app_texts_widget.dart'; +import 'package:doctor_app_flutter/widgets/shared/card_with_bgNew_widget.dart'; import 'package:flutter/material.dart'; import 'package:hexcolor/hexcolor.dart'; class AddSickLeavScreen extends StatelessWidget { @override Widget build(BuildContext context) { - return AppScaffold( - appBarTitle: TranslationBase.of(context).sickleave, - body: new Builder(builder: (context) { - return Center( - child: Column( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Container( - padding: EdgeInsets.all(40), - decoration: BoxDecoration( - border: Border.all(color: HexColor('#B8382C'), width: 4), - borderRadius: BorderRadius.all(Radius.circular(100))), - child: IconButton( - icon: Icon( - Icons.add, - size: 35, - ), - onPressed: () { - openSickLeave(context); + return BaseView( + onModelReady: (model) => model.getSickLeave(), + builder: (_, model, w) => AppScaffold( + baseViewModel: model, + appBarTitle: TranslationBase.of(context).sickleave, + body: model.getAllSIckLeave.length > 0 + ? SingleChildScrollView( + child: Column( + children: model.getAllSIckLeave + .map((GetAllSickLeaveResponse item) { + return CardWithBgWidgetNew( + widget: Column( + children: [ + Container( + padding: EdgeInsets.only(left: 10, right: 10), + child: Row( + mainAxisAlignment: MainAxisAlignment.start, + children: [ + Expanded( + flex: 4, + child: Row( + mainAxisAlignment: + MainAxisAlignment.start, + children: [ + Column( + crossAxisAlignment: + CrossAxisAlignment.start, + children: [ + Container( + padding: EdgeInsets.all(3), + child: AppText( + item.status == 1 + ? TranslationBase.of( + context) + .approved + : item.status == 2 + ? TranslationBase + .of(context) + .extended + : TranslationBase + .of(context) + .pending, + fontWeight: FontWeight.bold, + color: Colors.white, + ), + color: item.status == 1 + ? Colors.green + : Colors.yellow[800], + ), + Row( + children: [ + AppText( + TranslationBase.of( + context) + .leaveStartDate, + fontWeight: + FontWeight.bold, + ), + AppText(item.startDate) + ], + ), + AppText( + item.noOfDays.toString() + + ' ' + + TranslationBase.of( + context) + .daysSickleave, + fontWeight: FontWeight.bold, + ), + Row(children: [ + AppText( + item.remarks, + ) + ]), + ], + ), + SizedBox( + width: 20, + ), + ], + ), + ), + (item.status == 1 || item.status == 2) + ? Expanded( + flex: 1, + child: IconButton( + icon: Icon( + Icons.open_in_full, + size: 40, + ), + // color: Colors.green, //Colors.black, + onPressed: () => { + openSickLeave(context, true, + extendedData: item) + }, + )) + : SizedBox(), + ], + )), + SizedBox( + height: 20, + ), + Divider( + height: 1, + ), + ], + )); + }).toList(), + ), + ) + : new Builder(builder: (context) { + return Center( + child: SingleChildScrollView( + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Container( + padding: EdgeInsets.all(40), + decoration: BoxDecoration( + border: Border.all( + color: HexColor('#B8382C'), width: 4), + borderRadius: + BorderRadius.all(Radius.circular(100))), + child: IconButton( + icon: Icon( + Icons.add, + size: 35, + ), + onPressed: () { + openSickLeave( + context, + false, + ); + }), + ), + Padding( + child: AppText( + TranslationBase.of(context).noSickLeaveApplied, + fontWeight: FontWeight.bold, + ), + padding: EdgeInsets.all(10), + ), + AppText( + TranslationBase.of(context).applyNow, + fontWeight: FontWeight.bold, + color: HexColor('#B8382C'), + ) + ], + ), + )); }), - ), - Padding( - child: AppText( - TranslationBase.of(context).noSickLeaveApplied, - fontWeight: FontWeight.bold, - ), - padding: EdgeInsets.all(10), - ), - AppText( - TranslationBase.of(context).applyNow, - fontWeight: FontWeight.bold, - color: HexColor('#B8382C'), - ) - ], - ), - ); - }), - ); + )); } - openSickLeave(BuildContext context) { + openSickLeave(BuildContext context, isExtend, + {GetAllSickLeaveResponse extendedData}) { showModalBottomSheet( context: context, builder: (context) { - return new Container(child: SickLeaveScreen()); + return new Container( + child: SickLeaveScreen( + isExtended: isExtend, + extendedData: extendedData, + )); }); } } diff --git a/lib/screens/sick-leave/sick_leave.dart b/lib/screens/sick-leave/sick_leave.dart index 1eac90c3..7091a54f 100644 --- a/lib/screens/sick-leave/sick_leave.dart +++ b/lib/screens/sick-leave/sick_leave.dart @@ -3,9 +3,11 @@ import 'package:doctor_app_flutter/config/shared_pref_kay.dart'; import 'package:doctor_app_flutter/config/size_config.dart'; import 'package:doctor_app_flutter/core/viewModel/patient_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/screens/base/base_view.dart'; import 'package:doctor_app_flutter/util/dr_app_shared_pref.dart'; import 'package:doctor_app_flutter/util/helpers.dart'; +import 'package:doctor_app_flutter/util/text_validator.dart'; import 'package:doctor_app_flutter/util/translations_delegate_base.dart'; import 'package:doctor_app_flutter/widgets/shared/Text.dart'; import 'package:doctor_app_flutter/widgets/shared/app_buttons_widget.dart'; @@ -17,10 +19,14 @@ import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:hexcolor/hexcolor.dart'; import 'package:intl/intl.dart'; +import 'package:doctor_app_flutter/models/sickleave/get_all_sickleave_response.dart'; Helpers helpers = Helpers(); class SickLeaveScreen extends StatefulWidget { + final bool isExtended; + final GetAllSickLeaveResponse extendedData; + SickLeaveScreen({this.isExtended = false, this.extendedData}); @override _SickLeaveScreenState createState() => _SickLeaveScreenState(); } @@ -30,6 +36,7 @@ class _SickLeaveScreenState extends State { TextEditingController _toDateController = new TextEditingController(); String _selectedClinic; Map profile = {}; + AddSickLeaveRequest addSickLeave = AddSickLeaveRequest(); void _presentDatePicker(id) { showDatePicker( context: context, @@ -41,8 +48,12 @@ class _SickLeaveScreenState extends State { return; } setState(() { - var selectedDate = DateFormat.yMd().format(pickedDate); - _toDateController.text = selectedDate; + // var selectedDate = DateFormat.yMd().format(pickedDate); + final df = new DateFormat('yyyy-MM-dd'); + addSickLeave.startDate = df.format(pickedDate); + + _toDateController.text = addSickLeave.startDate; + //addSickLeave.startDate = selectedDate; }); }); } @@ -58,233 +69,291 @@ class _SickLeaveScreenState extends State { return BaseView( onModelReady: (model) => model.getClinicsList(), builder: (_, model, w) => BaseView( - onModelReady: (model2) => model2.preSickLeaveStatistics(), - builder: (_, model2, w) => Center( - child: Container( - margin: EdgeInsets.only(top: 10), - child: FractionallySizedBox( - widthFactor: 0.9, - child: ListView( - children: [ - Padding( - child: AppText( - TranslationBase.of(context).addSickLeave, - fontWeight: FontWeight.bold, + onModelReady: (model2) => model2.preSickLeaveStatistics(), + builder: (_, model2, w) => AppScaffold( + baseViewModel: model2, + isShowAppBar: false, + body: Center( + child: Container( + margin: EdgeInsets.only(top: 10), + child: FractionallySizedBox( + widthFactor: 0.9, + child: ListView( + children: [ + Padding( + child: AppText( + widget.isExtended == true + ? TranslationBase.of(context) + .extendSickLeave + : TranslationBase.of(context) + .addSickLeave, + fontWeight: FontWeight.bold, + ), + padding: EdgeInsets.all(10)), + Container( + margin: EdgeInsets.only(left: 10, right: 10), + 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( + borderColor: Colors.white, + onChanged: (value) { + addSickLeave.noOfDays = value; + }, + hintText: widget.extendedData != null + ? widget.extendedData.noOfDays + .toString() + : TranslationBase.of(context) + .sickLeaveDays, + // validator: (value) { + // return TextValidator().validateName(value); + // }, + inputFormatter: ONLY_NUMBERS) + ]), ), - padding: EdgeInsets.all(10)), - Container( - margin: EdgeInsets.only(left: 10, right: 10), - 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( - borderColor: Colors.white, - onSaved: (value) {}, - hintText: TranslationBase.of(context) - .sickLeaveDays, - // validator: (value) { - // return TextValidator().validateName(value); - // }, - inputFormatter: ONLY_NUMBERS) - ]), - ), - SizedBox( - height: 10, - ), - Container( - margin: EdgeInsets.only(left: 10, right: 10), - 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: [ - // AppText( - // TranslationBase.of(context).sickLeaveDate, - // fontSize: 10, - // ), - AppTextFormField( - hintText: TranslationBase.of(context) - .sickLeaveDate, - borderColor: Colors.white, - prefix: IconButton( - icon: Icon(Icons.calendar_today)), - textInputType: TextInputType.number, - controller: _toDateController, - onTap: () { - _presentDatePicker('_selectedToDate'); - }, - inputFormatter: ONLY_DATE, - onSaved: (value) {}), - ], - )), - Container( - margin: EdgeInsets.all(10), - decoration: BoxDecoration( - borderRadius: - BorderRadius.all(Radius.circular(6.0)), - border: Border.all( - width: 1.0, color: HexColor("#CCCCCC"))), - width: double.infinity, - child: Padding( - padding: EdgeInsets.only( - top: SizeConfig.widthMultiplier * 0.9, - bottom: SizeConfig.widthMultiplier * 0.9, - right: SizeConfig.widthMultiplier * 3, - left: SizeConfig.widthMultiplier * 3), + SizedBox( + height: 10, + ), + Container( + margin: EdgeInsets.only(left: 10, right: 10), + 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: [ + // AppText( + // TranslationBase.of(context).sickLeaveDate, + // fontSize: 10, + // ), + AppTextFormField( + hintText: widget.extendedData != null + ? widget.extendedData.startDate + : TranslationBase.of(context) + .sickLeaveDate, + 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; + }), + ], + )), + Container( + margin: EdgeInsets.only( + top: 10, left: 10, right: 10), + decoration: BoxDecoration( + borderRadius: + BorderRadius.all(Radius.circular(6.0)), + border: Border.all( + width: 1.0, + color: HexColor("#CCCCCC"))), + width: double.infinity, + child: Padding( + padding: EdgeInsets.only( + top: SizeConfig.widthMultiplier * 0.9, + bottom: SizeConfig.widthMultiplier * 0.9, + right: SizeConfig.widthMultiplier * 3, + left: SizeConfig.widthMultiplier * 3), + child: Column( + crossAxisAlignment: + CrossAxisAlignment.start, + children: [ + // AppText( + // TranslationBase.of(context).clinicName, + // fontSize: 10, + // ), + Row( + mainAxisSize: MainAxisSize.max, + children: [ + Expanded( + // add Expanded to have your dropdown button fill remaining space + child: DropdownButtonHideUnderline( + child: new IgnorePointer( + ignoring: true, + child: DropdownButton( + isExpanded: true, + value: getClinicName( + model) ?? + "", + iconSize: 40, + elevation: 16, + selectedItemBuilder: + (BuildContext + context) { + return model + .getClinicNameList() + .map((item) { + return Row( + mainAxisSize: + MainAxisSize + .max, + children: [ + AppText( + item, + fontSize: SizeConfig + .textMultiplier * + 2.1, + ), + ], + ); + }).toList(); + }, + onChanged: (newValue) => + {}, + items: model + .getClinicNameList() + .map((item) { + return DropdownMenuItem( + value: + item.toString(), + child: Text( + item, + textAlign: + TextAlign.end, + ), + ); + }).toList(), + ))), + ), + ], + ) + ], + ), + )), + model2.sickLeaveStatistics[ + 'recommendedSickLeaveDays'] != + null + ? Padding( + child: AppText( + model2.sickLeaveStatistics[ + 'recommendedSickLeaveDays'], + fontWeight: FontWeight.bold, + ), + padding: EdgeInsets.all(10), + ) + : SizedBox( + height: 10, + ), + Container( + margin: EdgeInsets.only(left: 10, right: 10), + 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: [ // AppText( - // TranslationBase.of(context).clinicName, + // TranslationBase.of(context).doctorName, // fontSize: 10, // ), - Row( - mainAxisSize: MainAxisSize.max, - children: [ - Expanded( - // add Expanded to have your dropdown button fill remaining space - child: DropdownButtonHideUnderline( - child: new IgnorePointer( - ignoring: true, - child: DropdownButton( - isExpanded: true, - value: getClinicName(model) ?? - "", - iconSize: 40, - elevation: 16, - selectedItemBuilder: - (BuildContext context) { - return model - .getClinicNameList() - .map((item) { - return Row( - mainAxisSize: - MainAxisSize.max, - children: [ - AppText( - item, - fontSize: SizeConfig - .textMultiplier * - 2.1, - ), - ], - ); - }).toList(); - }, - onChanged: (newValue) => {}, - items: model - .getClinicNameList() - .map((item) { - return DropdownMenuItem( - value: item.toString(), - child: Text( - item, - textAlign: - TextAlign.end, - ), - ); - }).toList(), - ))), - ), - ], - ) + new IgnorePointer( + ignoring: true, + child: AppTextFormField( + readOnly: true, + hintText: profile['DoctorName'], + borderColor: Colors.white, + onSaved: (value) {}, + // validator: (value) { + // return TextValidator().validateName(value); + // }, + inputFormatter: ONLY_NUMBERS)) ], ), - )), - Container( - margin: EdgeInsets.only(left: 10, right: 10), - 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: [ - // AppText( - // TranslationBase.of(context).doctorName, - // fontSize: 10, - // ), - AppTextFormField( - readOnly: true, - hintText: profile['DoctorName'], - borderColor: Colors.white, - onSaved: (value) {}, - // validator: (value) { - // return TextValidator().validateName(value); - // }, - inputFormatter: ONLY_NUMBERS) - ], - ), - ), - SizedBox( - height: 10, - ), - Container( - margin: EdgeInsets.only(left: 10, right: 10), - 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: [ - // AppText( - // TranslationBase.of(context).remarks, - // fontSize: 10, - // ), - AppTextFormField( - borderColor: Colors.white, - hintText: TranslationBase.of(context).remarks, - onSaved: (value) {}, - // validator: (value) { - // return TextValidator().validateName(value); - // }, - inputFormatter: ONLY_NUMBERS) - ], - ), - ), - Container( - margin: - EdgeInsets.all(SizeConfig.widthMultiplier * 5), - child: Wrap( - alignment: WrapAlignment.center, - children: [ - AppButton( - title: TranslationBase.of(context).add, - onPressed: () { - // _validateInputs(); - }, + ), + SizedBox( + height: 10, + ), + Container( + margin: EdgeInsets.only(left: 10, right: 10), + 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: [ + // AppText( + // TranslationBase.of(context).remarks, + // fontSize: 10, + // ), + AppTextFormField( + borderColor: Colors.white, + hintText: widget.extendedData != null + ? widget.extendedData.remarks + : TranslationBase.of(context).remarks, + onChanged: (value) { + addSickLeave.remarks = value; + }, + validator: (value) { + // return TextValidator().validateName(value); + }, + inputFormatter: ONLY_LETTERS) + ], ), - ], - ), - ), - Column( - children: [ - Texts(TranslationBase.of(context) - .previousSickLeaveIssue + - ' ') + ), + Container( + margin: EdgeInsets.all( + SizeConfig.widthMultiplier * 5), + child: Wrap( + alignment: WrapAlignment.center, + children: [ + AppButton( + title: widget.isExtended == true + ? TranslationBase.of(context).extend + : TranslationBase.of(context).add, + onPressed: () { + if (widget.isExtended) { + model2 + .extendSickLeave( + widget.extendedData) + .then((value) => (value) { + print(value); + }); + } else { + model2 + .addSickLeave(addSickLeave) + .then((value) => print(value)); + } + }, + ), + ], + ), + ), + // Column( + // children: [ + // Texts(TranslationBase.of(context) + // .previousSickLeaveIssue + + // ' ') + // ], + // ) ], - ) - ], + ), + ), ), ), - ), - ), - )); + ))); } getProfile() async { diff --git a/lib/util/translations_delegate_base.dart b/lib/util/translations_delegate_base.dart index 5290e933..43fec17b 100644 --- a/lib/util/translations_delegate_base.dart +++ b/lib/util/translations_delegate_base.dart @@ -326,6 +326,16 @@ class TranslationBase { String get addSickLeave => localizedValues['add-sickleave'][locale.languageCode]; String get add => localizedValues['add'][locale.languageCode]; + String get approved => localizedValues['approved'][locale.languageCode]; + String get extended => localizedValues['extended'][locale.languageCode]; + String get pending => localizedValues['pending'][locale.languageCode]; + String get leaveStartDate => + localizedValues['leave-start-date'][locale.languageCode]; + String get daysSickleave => + localizedValues['days-sick-leave'][locale.languageCode]; + String get extend => localizedValues['extend'][locale.languageCode]; + String get extendSickLeave => + localizedValues['extend-sickleave'][locale.languageCode]; } class TranslationBaseDelegate extends LocalizationsDelegate {