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.

reimburse_screen.dart 48KB

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