No Description
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 41KB

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