Keine Beschreibung
Du kannst nicht mehr als 25 Themen auswählen Themen müssen mit entweder einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

ajukancuti_screen.dart 40KB

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