Açıklama Yok
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

ajukancuti_screen.dart 37KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781
  1. import 'dart:convert';
  2. import 'dart:io';
  3. import 'package:file_picker/file_picker.dart';
  4. import 'package:flutter/cupertino.dart';
  5. import 'package:flutter/material.dart';
  6. import 'package:flutter/rendering.dart';
  7. import 'package:fluttertoast/fluttertoast.dart';
  8. import 'package:google_fonts/google_fonts.dart';
  9. import 'package:employee_selfservice_mobile/Screens/Menu/AjukanCuti/RequestHttp/jenisCuti_post.dart';
  10. import 'package:employee_selfservice_mobile/Screens/Menu/AjukanCuti/RequestHttp/pengajuanCuti_post.dart';
  11. import 'package:employee_selfservice_mobile/Screens/Menu/AjukanCuti/history_cuti.dart';
  12. import 'package:intl/intl.dart';
  13. import 'package:progress_dialog_null_safe/progress_dialog_null_safe.dart';
  14. import 'dart:developer' as logDev;
  15. import '../SlipGaji/background.dart';
  16. List<String> fileAttach = [""];
  17. TextEditingController deskripsiTeksController = TextEditingController();
  18. class AjukanCutiScreen extends StatefulWidget {
  19. const AjukanCutiScreen({Key? key}) : super(key: key);
  20. @override
  21. State<AjukanCutiScreen> createState() => _AjukanCutiScreenState();
  22. }
  23. class _AjukanCutiScreenState extends State<AjukanCutiScreen> {
  24. var selectedType;
  25. String _fileText = "";
  26. String _totalFile= "";
  27. bool visibleDateFrom = false;
  28. bool visibleDateTo = false;
  29. late List <String> idCutiType;
  30. late List <String> cutiType;
  31. DateTime dateFrom = DateTime.now();
  32. DateTime dateTo = DateTime.now();
  33. late String formattedDateFrom = "";
  34. late String formattedDateTo = "";
  35. late String idCuti;
  36. initState(){
  37. deskripsiTeksController.clear();
  38. cutiType = [""];
  39. idCutiType = [""];
  40. formattedDateFrom = "";
  41. visibleDateFrom = false;
  42. formattedDateTo = "";
  43. visibleDateTo = false;
  44. deskripsiTeksController.clear();
  45. WidgetsBinding.instance.addPostFrameCallback((_) {
  46. cutiType = getJenisCuti();
  47. });
  48. super.initState();
  49. }
  50. getJenisCuti () async {
  51. ProgressDialog loading = ProgressDialog(context);
  52. loading = ProgressDialog(context,
  53. type: ProgressDialogType.normal, isDismissible: false, showLogs: true);
  54. loading.style(
  55. message: 'Please Wait .....',
  56. borderRadius: 3,
  57. backgroundColor: Colors.white,
  58. progressWidget: CircularProgressIndicator(),
  59. elevation: 10.0,
  60. padding: EdgeInsets.all(10),
  61. insetAnimCurve: Curves.easeInOut,
  62. progress: 0.0,
  63. maxProgress: 100.0,
  64. progressTextStyle: TextStyle(
  65. color: Colors.black, fontSize: 10.0, fontWeight: FontWeight.w400),
  66. messageTextStyle: TextStyle(
  67. color: Colors.black, fontSize: 15.0, fontWeight: FontWeight.w600));
  68. await loading.show();
  69. JenisCuti_Post.connectToAPI().then((valueResult) async {
  70. Map<String, dynamic> object = json.decode(valueResult);
  71. if (object.containsKey("result").toString() == "true"){
  72. String result = object['result'].toString();
  73. logDev.log(result, name: "Jenis Cuti Result");
  74. if (result.contains("Failed")) {
  75. await loading.hide();
  76. setState(() {
  77. cutiType = [""];
  78. alertDialogFailedRetrievedData(context);
  79. });
  80. } else {
  81. List <dynamic> jenis = object['result']['jenis'];
  82. setState(() {
  83. idCutiType.removeAt(0);
  84. cutiType.removeAt(0);
  85. for (int i = 0; i < jenis.length; i++){
  86. String id = jenis[i]['id'].toString();
  87. String text = jenis[i]['text'].toString();
  88. idCutiType.add(id);
  89. cutiType.add(text);
  90. }
  91. });
  92. await loading.hide();
  93. }
  94. } else {
  95. setState((){
  96. cutiType = [""];
  97. alertDialogFailedResponse(context);
  98. /*Fluttertoast.showToast(
  99. msg: "Server Response Error",
  100. toastLength: Toast.LENGTH_SHORT,
  101. gravity: ToastGravity.CENTER,
  102. timeInSecForIosWeb: 1,
  103. textColor: Colors.white,
  104. fontSize: 16.0);*/
  105. });
  106. await loading.hide();
  107. }
  108. });
  109. return cutiType;
  110. }
  111. @override
  112. Widget build(BuildContext context) {
  113. var size = MediaQuery.sizeOf(context);
  114. return Scaffold(
  115. body: SingleChildScrollView(
  116. child: Column(
  117. children: <Widget>[
  118. Stack(
  119. children: [
  120. WavyHeader(),
  121. Container(
  122. margin: EdgeInsets.only(top: MediaQuery.of(context).size.height/6 - 20),
  123. padding: EdgeInsets.fromLTRB(20, 5, 25, 5),
  124. child: Row(
  125. mainAxisAlignment: MainAxisAlignment.end,
  126. crossAxisAlignment: CrossAxisAlignment.end,
  127. children: [
  128. Text(
  129. 'Leaves\t\t',
  130. maxLines: 1,
  131. style: GoogleFonts.luckiestGuy(
  132. fontSize: 28,
  133. color: Color(0xFF4858A7),
  134. fontStyle: FontStyle.italic,
  135. ),
  136. ),
  137. Image.asset(
  138. 'assets/icons/menu/ic_cuti.png',
  139. width: 40,
  140. height: 40,
  141. ),
  142. ],
  143. )),
  144. SafeArea(
  145. child: Container(
  146. width: MediaQuery.of(context).size.width,
  147. margin: EdgeInsets.only(
  148. top: MediaQuery.of(context).size.height / 5,
  149. left: 10,
  150. right: 10,
  151. bottom : 15,
  152. ),
  153. child: Column(
  154. children: [
  155. InkWell(
  156. child: Container(
  157. margin: EdgeInsets.only(top: 15, bottom: 15),
  158. padding: EdgeInsets.fromLTRB(10, 10, 10, 10),
  159. width: double.infinity,
  160. decoration: BoxDecoration(
  161. borderRadius: BorderRadius.circular(5),
  162. gradient: LinearGradient(colors: [
  163. Color(0xFF2D4059),
  164. Color(0xFF2D4059),
  165. /*Color(0xFFEAFFD0),
  166. Color(0xFF95E1D3),*/
  167. ])),
  168. child: Row(
  169. mainAxisAlignment: MainAxisAlignment.center,
  170. children: [
  171. Text(' See Leaves History\t\t',
  172. textAlign: TextAlign.center,
  173. style: TextStyle(
  174. color: Colors.white,
  175. fontSize: 17,
  176. fontWeight: FontWeight.w500)),
  177. Image.asset(
  178. 'assets/images/ic_arrow_white.png',
  179. width: 30,
  180. height: 30,
  181. )
  182. ],
  183. )),
  184. onTap: () {
  185. deskripsiTeksController.clear();
  186. visibleDateFrom = !visibleDateFrom;
  187. visibleDateTo = !visibleDateTo;
  188. Navigator.push(context, MaterialPageRoute(
  189. builder: (context) => HistoryCuti()));
  190. },
  191. ),
  192. Container(
  193. child: Card(
  194. elevation: 10,
  195. child: Container(
  196. decoration: BoxDecoration(
  197. color: Color(0XFFFAF7EE),
  198. borderRadius: BorderRadius.circular(10)),
  199. child: Column(
  200. children: [
  201. Container(
  202. margin: EdgeInsets.only(
  203. left: 10, right: 10, top: 15, bottom: 10),
  204. child: Text('Leaves Submission', style:
  205. GoogleFonts.josefinSans(fontSize: 18, fontWeight: FontWeight.bold, decoration: TextDecoration.underline,
  206. decorationStyle: TextDecorationStyle.dashed),),
  207. ),
  208. Container(
  209. margin: EdgeInsets.only(
  210. left: 10, right: 10, top: 10, bottom: 10),
  211. child: Column(
  212. children: [
  213. Align(
  214. alignment: Alignment.centerLeft,
  215. child: Text(
  216. 'Type',
  217. style: GoogleFonts.inconsolata(
  218. fontSize: 16, fontWeight: FontWeight.bold),
  219. )),
  220. Container(
  221. margin: EdgeInsets.only(top: 7),
  222. decoration: BoxDecoration(
  223. color:
  224. CupertinoColors.systemGrey2,
  225. borderRadius:
  226. BorderRadius.circular(5)),
  227. child: DropdownButton(
  228. menuMaxHeight: size.height * 0.31,
  229. dropdownColor: Colors.grey.shade300,
  230. value: this.selectedType,
  231. isExpanded: true,
  232. underline: SizedBox(),
  233. hint: Text(
  234. '\t\t\tChoose Leaves Type',
  235. style: TextStyle(
  236. color: Colors.black54),
  237. ),
  238. onChanged: (value) {
  239. logDev.log(value.toString(), name: "VALUENYA");
  240. //print(value);
  241. setState(() {
  242. selectedType = value!;
  243. for (int i = 0; i < cutiType.length; i++){
  244. if (selectedType == cutiType.elementAt(i)){
  245. idCuti = idCutiType.elementAt(i);
  246. }
  247. }
  248. });
  249. },
  250. items: cutiType
  251. .map((e) => DropdownMenuItem(
  252. value: e,
  253. child:
  254. Text("\t\t\t" + e)),
  255. ).toList(),
  256. ),
  257. ),
  258. ],
  259. ),
  260. ),
  261. Container(
  262. margin: EdgeInsets.only(
  263. left: 10, right: 10, top: 10, bottom: 10),
  264. child: Column(
  265. children: [
  266. Align(
  267. alignment: Alignment.centerLeft,
  268. child: Text('From',
  269. style: GoogleFonts.inconsolata(
  270. fontSize: 16, fontWeight: FontWeight.bold),
  271. )
  272. ),
  273. ElevatedButton(
  274. onPressed: () async {
  275. DateTime? newDate =
  276. await showDatePicker(
  277. context: context,
  278. initialDate: dateFrom,
  279. firstDate:
  280. DateTime(1900),
  281. lastDate:
  282. DateTime(2100));
  283. final DateFormat formatter = DateFormat('yyyy-MM-dd');
  284. if (newDate == null) {
  285. return;
  286. } else {
  287. setState(() {
  288. if (visibleDateFrom == false){
  289. visibleDateFrom = !visibleDateFrom;
  290. }
  291. formattedDateFrom = formatter.format(newDate);
  292. //dateFrom = formattedFrom as DateTime;
  293. });
  294. }
  295. },
  296. /*style: ElevatedButton.styleFrom(
  297. backgroundColor:
  298. CupertinoColors
  299. .systemGrey2),*/
  300. child: Container(
  301. width: double.infinity,
  302. child: Text(
  303. "Choose Date",
  304. style: TextStyle(
  305. color: Colors.white,
  306. fontSize: 16,
  307. fontWeight:
  308. FontWeight.w400),
  309. ),
  310. ),
  311. ),
  312. Visibility(
  313. visible: visibleDateFrom,
  314. child: Container(
  315. alignment: Alignment.centerLeft,
  316. margin: EdgeInsets.only(
  317. left: 15,
  318. right: 15,
  319. bottom: 5),
  320. child: Text(formattedDateFrom,
  321. overflow:
  322. TextOverflow.ellipsis,
  323. maxLines: 1,
  324. style: TextStyle(
  325. color: Colors.black54),
  326. ),
  327. ),
  328. ),
  329. ],
  330. ),
  331. ),
  332. Container(
  333. margin: EdgeInsets.only(
  334. left: 10, right: 10, top: 10, bottom: 10),
  335. child: Column(
  336. children: [
  337. Align(
  338. alignment: Alignment.centerLeft,
  339. child: Text(
  340. 'To',
  341. style: GoogleFonts.inconsolata(
  342. fontSize: 16, fontWeight: FontWeight.bold),
  343. ),
  344. ),
  345. Column(
  346. children: [
  347. ElevatedButton(
  348. onPressed: () async {DateTime? newDate = await showDatePicker(context: context, initialDate: dateTo, firstDate: DateTime(1900),
  349. lastDate: DateTime(2100));
  350. final DateFormat formatter = DateFormat('yyyy-MM-dd');
  351. if (newDate == null) {
  352. return;
  353. } else {
  354. setState(() {
  355. if (visibleDateTo == false){
  356. visibleDateTo = !visibleDateTo;
  357. }
  358. formattedDateTo = formatter.format(newDate);
  359. });
  360. }
  361. },
  362. /*style: ElevatedButton.styleFrom(
  363. backgroundColor:
  364. CupertinoColors
  365. .systemGrey2),*/
  366. child: Container(
  367. width: double.infinity,
  368. child: Text(
  369. "Choose Date",
  370. style: TextStyle(
  371. color: Colors.white,
  372. fontSize: 16,
  373. fontWeight:
  374. FontWeight.w400),
  375. ),
  376. ),
  377. ),
  378. Visibility(
  379. visible: visibleDateTo,
  380. child: Container(
  381. alignment: Alignment.centerLeft,
  382. margin: EdgeInsets.only(
  383. left: 15,
  384. right: 15,
  385. bottom: 5),
  386. child: Text(formattedDateTo,
  387. overflow:
  388. TextOverflow.ellipsis,
  389. maxLines: 1,
  390. style: TextStyle(
  391. color: Colors.black54),
  392. ),
  393. ),
  394. )
  395. ],
  396. ),
  397. ],
  398. ),
  399. ),
  400. Container(
  401. margin: EdgeInsets.only(
  402. left: 10, right: 10, top: 10, bottom: 10),
  403. child: Column(
  404. children: [
  405. Align(
  406. alignment: Alignment.centerLeft,
  407. child: Text(
  408. 'Description',
  409. style: GoogleFonts.inconsolata(
  410. fontSize: 16, fontWeight: FontWeight.bold),
  411. )),
  412. Container(
  413. margin: EdgeInsets.only(top: 7),
  414. decoration: BoxDecoration(
  415. color: Colors.white,
  416. borderRadius:
  417. BorderRadius.circular(5)),
  418. child: Padding(
  419. padding: EdgeInsets.only(
  420. left: 10,
  421. right: 10,
  422. top: 5,
  423. bottom: 5),
  424. child: TextFormField(
  425. keyboardType: TextInputType.multiline,
  426. maxLines: null,
  427. textInputAction: TextInputAction.done,
  428. controller: deskripsiTeksController,
  429. decoration: InputDecoration(
  430. border:
  431. InputBorder.none,
  432. hintText: "description")),
  433. )
  434. ),
  435. ],
  436. ),
  437. ),
  438. Container(
  439. margin: EdgeInsets.only(
  440. left: 10, right: 10, top: 10),
  441. child: Column(
  442. children: [
  443. Align(
  444. alignment: Alignment.centerLeft,
  445. child: Text(
  446. 'Attachment',
  447. style: GoogleFonts.inconsolata(
  448. fontSize: 16, fontWeight: FontWeight.bold),
  449. ),
  450. ),
  451. Container(
  452. child: ElevatedButton(
  453. onPressed: () {
  454. _pickMultipleFiles();
  455. },
  456. /*style: ElevatedButton.styleFrom(
  457. backgroundColor:
  458. CupertinoColors
  459. .systemGrey2),*/
  460. child: Container(
  461. width: double.infinity,
  462. child: Text("Choose File",
  463. style: TextStyle(
  464. color: Colors.white,
  465. fontSize: 16,
  466. fontWeight:
  467. FontWeight.w400)),
  468. ),
  469. ),
  470. ),
  471. Container(
  472. alignment:
  473. Alignment.centerLeft,
  474. margin: EdgeInsets.only(
  475. left: 15,
  476. right: 15,
  477. bottom: 10),
  478. child: Text(_totalFile + _fileText,
  479. overflow:
  480. TextOverflow.ellipsis,
  481. /*maxLines: 7,*/
  482. style: TextStyle(
  483. color: Colors.black54),
  484. ),
  485. ),
  486. ],
  487. ),
  488. ),
  489. InkWell(
  490. child: Container(
  491. margin: EdgeInsets.only(left: 10, right: 10, bottom: 15),
  492. padding: EdgeInsets.fromLTRB(
  493. 10, 10, 10, 10),
  494. width: double.infinity,
  495. decoration: BoxDecoration(
  496. borderRadius:
  497. BorderRadius.circular(5),
  498. gradient: LinearGradient(colors: [
  499. Color(0xFFFF9945),
  500. Color(0xFFFc6076)
  501. ])),
  502. child: Text('Submit',
  503. textAlign: TextAlign.center,
  504. style: TextStyle(
  505. color: Colors.white,
  506. fontSize: 17,
  507. fontWeight: FontWeight.w500)),
  508. ),
  509. onTap: () async {
  510. ProgressDialog loading = ProgressDialog(context);
  511. loading = ProgressDialog(context,
  512. type: ProgressDialogType.normal, isDismissible: false, showLogs: true);
  513. loading.style(
  514. message: 'Please Wait .....',
  515. borderRadius: 3,
  516. backgroundColor: Colors.white,
  517. progressWidget: CircularProgressIndicator(),
  518. elevation: 10.0,
  519. padding: EdgeInsets.all(10),
  520. insetAnimCurve: Curves.easeInOut,
  521. progress: 0.0,
  522. maxProgress: 100.0,
  523. progressTextStyle: TextStyle(
  524. color: Colors.black, fontSize: 10.0, fontWeight: FontWeight.w400),
  525. messageTextStyle: TextStyle(
  526. color: Colors.black, fontSize: 15.0, fontWeight: FontWeight.w600));
  527. //loading.show();
  528. if (!validateFormCuti(context)){
  529. return;
  530. } else if (validateFormCuti(context)){
  531. await loading.show();
  532. PengajuanCuti_Post.connectToAPI(idCuti, formattedDateFrom,
  533. formattedDateTo, deskripsiTeksController.text.toString(), fileAttach)
  534. .then((valueResult) async {
  535. Map<String, dynamic> object = json.decode(valueResult);
  536. logDev.log(fileAttach.toString(), name: "Attachment File Upload");
  537. if (object.containsKey("result").toString() == "true") {
  538. /*String employee = object['result']['employee'].toString();
  539. String tipe = object['result']['tipe'].toString();
  540. String from = object['result']['from'].toString();
  541. String to = object['result']['to'].toString();
  542. String deskripsi = object['result']['deskripsi'].toString();
  543. String attachment = object['result']['attachment'].toString();*/
  544. await loading.hide();
  545. deskripsiTeksController.clear();
  546. Widget okButton = TextButton(
  547. child: Text("OK"),
  548. onPressed: () {
  549. Navigator.of(context, rootNavigator: true).pop();
  550. Navigator.pushReplacement(context, MaterialPageRoute(
  551. builder: (context) => AjukanCutiScreen()));
  552. },
  553. );
  554. // set up the AlertDialog
  555. AlertDialog alert = AlertDialog(
  556. title: Text("Employee Self Service"),
  557. content: Text("Success Submit Leaves"),
  558. actions: [
  559. okButton,
  560. ],
  561. );
  562. // show the dialog
  563. showDialog(
  564. context: context,
  565. builder: (BuildContext context) {
  566. return alert;
  567. },
  568. );
  569. /* deskripsiTeksController.clear();
  570. formattedDateFrom = "";
  571. formattedDateTo = "";
  572. visibleDateFrom = false;
  573. visibleDateFrom = false;*/
  574. } else if (object.containsKey("error").toString() == "true") {
  575. String errorMessage = object['error']['data']['message']
  576. .toString();
  577. await loading.hide();
  578. Widget okButton = TextButton(
  579. child: Text("OK"),
  580. onPressed: () {
  581. Navigator.of(context, rootNavigator: true).pop();
  582. },
  583. );
  584. // set up the AlertDialog
  585. AlertDialog alert = AlertDialog(
  586. title: Text("Employee Self Service"),
  587. content: Text(errorMessage),
  588. actions: [
  589. okButton,
  590. ],
  591. );
  592. // show the dialog
  593. showDialog(
  594. context: context,
  595. builder: (BuildContext context) {
  596. return alert;
  597. },
  598. );
  599. }
  600. });
  601. }
  602. },
  603. )
  604. ],
  605. ),
  606. ),
  607. ),
  608. ),
  609. ],
  610. ),
  611. ),
  612. ),
  613. ],
  614. ),
  615. ],
  616. )),
  617. );
  618. }
  619. void _pickMultipleFiles() async {
  620. FilePickerResult? result = await FilePicker.platform.pickFiles(allowMultiple: true);
  621. if (_fileText != ""){
  622. _fileText = "";
  623. }
  624. if (result != null) {
  625. List<File> files = result.paths.map((path) => File(path!)).toList();
  626. for (int i = 0; i< files.length; i++){
  627. String fileName = files[i].path.split('/').last;
  628. _fileText = _fileText + "\n" + fileName;
  629. List<int> fileInBytes = files[i].readAsBytesSync();
  630. String toBase64 = base64Encode(fileInBytes);
  631. fileAttach.add(toBase64);
  632. }
  633. fileAttach.removeAt(0);
  634. logDev.log(fileAttach.length.toString(), name: "Length File Attach");
  635. logDev.log(files.toString(), name: "Files Picked");
  636. setState(() {
  637. _fileText;
  638. _totalFile = "Total File : " + files.length.toString();
  639. });
  640. } else {
  641. // User canceled the picker
  642. }
  643. }
  644. bool validateFormCuti(BuildContext context) {
  645. bool result = true;
  646. if (selectedType == null) {
  647. Fluttertoast.showToast(
  648. msg: " Type Not Selected",
  649. toastLength: Toast.LENGTH_SHORT,
  650. gravity: ToastGravity.CENTER,
  651. timeInSecForIosWeb: 1,
  652. textColor: Colors.white,
  653. fontSize: 16.0);
  654. result = false;
  655. } else if (formattedDateFrom == "" || formattedDateTo == "") {
  656. Fluttertoast.showToast(
  657. msg: "Time Off Date Not Selected",
  658. toastLength: Toast.LENGTH_SHORT,
  659. gravity: ToastGravity.CENTER,
  660. timeInSecForIosWeb: 1,
  661. textColor: Colors.white,
  662. fontSize: 16.0);
  663. result = false;
  664. } else if (deskripsiTeksController.text.toString().isEmpty) {
  665. Fluttertoast.showToast(
  666. msg: "Description Required!",
  667. toastLength: Toast.LENGTH_SHORT,
  668. gravity: ToastGravity.CENTER,
  669. timeInSecForIosWeb: 1,
  670. textColor: Colors.white,
  671. fontSize: 16.0);
  672. result = false;
  673. }
  674. return result;
  675. }
  676. }
  677. alertDialogFailedRetrievedData(BuildContext context){
  678. Widget okButton = TextButton(
  679. child: Text("Refresh"),
  680. onPressed: () {
  681. Navigator.of(context, rootNavigator: true).pop();
  682. Navigator.pushReplacement(context, MaterialPageRoute(
  683. builder: (context) => AjukanCutiScreen()));
  684. },
  685. );
  686. Widget noButton = TextButton(
  687. child: Text("Back"),
  688. onPressed: () {
  689. Navigator.of(context, rootNavigator: true).pop();
  690. Navigator.pop(context);
  691. },
  692. );
  693. // set up the AlertDialog
  694. AlertDialog alert = AlertDialog(
  695. title: Text("Employee Self Service"),
  696. content: Text("Failed to Retrieve Data"),
  697. actions: [
  698. noButton,
  699. okButton,
  700. ],
  701. );
  702. // show the dialog
  703. showDialog(
  704. context: context,
  705. builder: (BuildContext context) {
  706. return alert;
  707. },
  708. );
  709. }
  710. alertDialogFailedResponse(BuildContext context){
  711. Widget okButton = TextButton(
  712. child: Text("Refresh"),
  713. onPressed: () {
  714. Navigator.of(context, rootNavigator: true).pop();
  715. Navigator.pushReplacement(context, MaterialPageRoute(
  716. builder: (context) => AjukanCutiScreen()));
  717. },
  718. );
  719. Widget noButton = TextButton(
  720. child: Text("Back"),
  721. onPressed: () {
  722. Navigator.of(context, rootNavigator: true).pop();
  723. Navigator.pop(context);
  724. },
  725. );
  726. // set up the AlertDialog
  727. AlertDialog alert = AlertDialog(
  728. title: Text("Employee Self Service"),
  729. content: Text("Server Response Error"),
  730. actions: [
  731. noButton,
  732. okButton,
  733. ],
  734. );
  735. // show the dialog
  736. showDialog(
  737. context: context,
  738. builder: (BuildContext context) {
  739. return alert;
  740. },
  741. );
  742. }