Няма описание
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.

reimburse_screen.dart 44KB

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