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

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