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.

pengajuan_st.dart 57KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124
  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/SuratTugas/RequestHttp/pengajuanST_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. List<String> fileAttach = [""];
  14. TextEditingController keperluanTeksController = TextEditingController();
  15. TextEditingController tujuanTeksController = TextEditingController();
  16. TextEditingController uangMukaTeksController = TextEditingController();
  17. TextEditingController ticketFromTeksController = TextEditingController();
  18. TextEditingController ticketToTeksController = TextEditingController();
  19. TextEditingController ticketPriceTeksController = TextEditingController();
  20. class PengajuanST_Screen extends StatefulWidget {
  21. const PengajuanST_Screen({Key? key}) : super(key: key);
  22. @override
  23. State<PengajuanST_Screen> createState() => _PengajuanST_Screen_State();
  24. }
  25. class _PengajuanST_Screen_State extends State<PengajuanST_Screen> {
  26. String _fileText = "";
  27. String _totalFile = "";
  28. bool visibleDateST = false;
  29. bool visibleDateDeparture = false;
  30. bool visibleDateReturn = false;
  31. bool visibleDateTicket = false;
  32. DateTime dateFrom = DateTime.now();
  33. late String formattedDateST = "";
  34. late String formattedDateDeparture = "";
  35. late String formattedDateReturn = "";
  36. late String formattedDateTicket = "";
  37. late String kendaraan;
  38. var selectedTicketType;
  39. initState() {
  40. keperluanTeksController.clear();
  41. tujuanTeksController.clear();
  42. uangMukaTeksController.clear();
  43. ticketFromTeksController.clear();
  44. ticketToTeksController.clear();
  45. ticketPriceTeksController.clear();
  46. //loadingPage();
  47. /*WidgetsBinding.instance.addPostFrameCallback((_) {
  48. cutiType = getJenisCuti();
  49. });*/
  50. super.initState();
  51. }
  52. @override
  53. Widget build(BuildContext context) {
  54. var size = MediaQuery.of(context).size;
  55. return Scaffold(
  56. body: SingleChildScrollView(
  57. child: Column(
  58. children: <Widget>[
  59. Stack(
  60. children: [
  61. WavyHeader(),
  62. Container(
  63. margin: EdgeInsets.only(
  64. top: MediaQuery.of(context).size.height / 6 - 20),
  65. padding: EdgeInsets.fromLTRB(20, 5, 25, 5),
  66. child: Row(
  67. mainAxisAlignment: MainAxisAlignment.end,
  68. crossAxisAlignment: CrossAxisAlignment.end,
  69. children: [
  70. Text(
  71. 'Submission\t\t',
  72. maxLines: 2,
  73. style: GoogleFonts.luckiestGuy(
  74. fontSize: 28,
  75. color: Color(0xFF4858A7),
  76. fontStyle: FontStyle.italic,
  77. ),
  78. ),
  79. Image.asset(
  80. 'assets/images/submit_st.png',
  81. width: 40,
  82. height: 40,
  83. ),
  84. ],
  85. )),
  86. SafeArea(
  87. child: Container(
  88. width: MediaQuery.of(context).size.width,
  89. margin: EdgeInsets.only(
  90. top: MediaQuery.of(context).size.height / 5,
  91. left: 10,
  92. right: 10,
  93. bottom: 10),
  94. child: Column(
  95. children: [
  96. Container(
  97. child: Card(
  98. elevation: 10,
  99. child: Container(
  100. decoration: BoxDecoration(
  101. color: Color(0XFFFAF7EE),
  102. borderRadius: BorderRadius.circular(10)),
  103. child: Column(
  104. children: [
  105. Container(
  106. margin: EdgeInsets.only(
  107. left: 10, right: 10, top: 15, bottom: 15),
  108. child: Text(
  109. 'Assignment Letter Submission',
  110. style: GoogleFonts.josefinSans(
  111. fontSize: 18,
  112. fontWeight: FontWeight.bold,
  113. decoration: TextDecoration.underline,
  114. decorationStyle:
  115. TextDecorationStyle.dashed),
  116. ),
  117. ),
  118. Container(
  119. margin: EdgeInsets.only(
  120. left: 10, right: 10, top: 10, bottom: 10),
  121. child: Column(
  122. children: [
  123. Align(
  124. alignment: Alignment.centerLeft,
  125. child: Text(
  126. 'Assignment Letter Date',
  127. style: GoogleFonts.inconsolata(
  128. fontSize: 16,
  129. fontWeight:
  130. FontWeight.bold),
  131. )),
  132. ElevatedButton(
  133. onPressed: () async {
  134. DateTime? newDate =
  135. await showDatePicker(
  136. context: context,
  137. initialDate: dateFrom,
  138. firstDate: DateTime(1900),
  139. lastDate: DateTime(2100));
  140. final DateFormat formatter =
  141. DateFormat('yyyy-MM-dd');
  142. if (newDate == null) {
  143. return;
  144. } else {
  145. setState(() {
  146. if (visibleDateST == false) {
  147. visibleDateST =
  148. !visibleDateST;
  149. }
  150. formattedDateST =
  151. formatter.format(newDate);
  152. //dateFrom = formattedFrom as DateTime;
  153. });
  154. }
  155. },
  156. /*style: ElevatedButton.styleFrom(
  157. backgroundColor:
  158. CupertinoColors
  159. .systemGrey2),*/
  160. child: Container(
  161. width: double.infinity,
  162. child: Text(
  163. "Choose Date",
  164. style: TextStyle(
  165. color: Colors.white,
  166. fontSize: 16,
  167. fontWeight:
  168. FontWeight.w400),
  169. ),
  170. ),
  171. ),
  172. Visibility(
  173. visible: visibleDateST,
  174. child: Container(
  175. alignment:
  176. Alignment.centerLeft,
  177. margin: EdgeInsets.only(
  178. left: 15,
  179. right: 15,
  180. bottom: 5),
  181. child: Text(
  182. formattedDateST,
  183. overflow:
  184. TextOverflow.ellipsis,
  185. maxLines: 1,
  186. style: TextStyle(
  187. color:
  188. Colors.black54),
  189. ),
  190. ),
  191. )
  192. ],
  193. ),
  194. ),
  195. Container(
  196. margin: EdgeInsets.only(
  197. left: 10, right: 10, top: 10, bottom: 10),
  198. child: Column(
  199. children: [
  200. Align(
  201. alignment: Alignment.centerLeft,
  202. child: Text(
  203. 'Description of Needs',
  204. style: GoogleFonts.inconsolata(
  205. fontSize: 16, fontWeight: FontWeight.bold),
  206. )
  207. ),
  208. Container(
  209. margin: EdgeInsets.only(top: 7),
  210. decoration: BoxDecoration(
  211. color: Colors.white,
  212. borderRadius:
  213. BorderRadius.circular(5)),
  214. child: Padding(
  215. padding: EdgeInsets.only(
  216. left: 10,
  217. right: 10,
  218. top: 5,
  219. bottom: 5),
  220. child: TextFormField(
  221. keyboardType:
  222. TextInputType.multiline,
  223. maxLines: 1,
  224. textInputAction:
  225. TextInputAction.next,
  226. controller:
  227. keperluanTeksController,
  228. decoration: InputDecoration(
  229. border:
  230. InputBorder.none,
  231. hintText:
  232. "description")),
  233. ))
  234. ],
  235. ),
  236. ),
  237. Container(
  238. margin: EdgeInsets.only(
  239. left: 10, right: 10, top: 10, bottom: 10),
  240. child: Column(
  241. children: [
  242. Align(
  243. alignment: Alignment.centerLeft,
  244. child: Text(
  245. 'Departure Date',
  246. style: GoogleFonts.inconsolata(
  247. fontSize: 16, fontWeight: FontWeight.bold),
  248. )
  249. ),
  250. ElevatedButton(
  251. onPressed: () async {
  252. DateTime? newDate =
  253. await showDatePicker(
  254. context: context,
  255. initialDate:
  256. dateFrom,
  257. firstDate:
  258. DateTime(1900),
  259. lastDate:
  260. DateTime(2100));
  261. final DateFormat formatter =
  262. DateFormat(
  263. 'yyyy-MM-dd');
  264. if (newDate == null) {
  265. return;
  266. } else {
  267. setState(() {
  268. if (visibleDateDeparture ==
  269. false) {
  270. visibleDateDeparture =
  271. !visibleDateDeparture;
  272. }
  273. formattedDateDeparture =
  274. formatter.format(
  275. newDate);
  276. //dateFrom = formattedFrom as DateTime;
  277. });
  278. }
  279. },
  280. /*style: ElevatedButton.styleFrom(
  281. backgroundColor:
  282. CupertinoColors
  283. .systemGrey2),*/
  284. child: Container(
  285. width: double.infinity,
  286. child: Text(
  287. "Choose Date",
  288. style: TextStyle(
  289. color: Colors.white,
  290. fontSize: 16,
  291. fontWeight:
  292. FontWeight.w400),
  293. ),
  294. ),
  295. ),
  296. Visibility(
  297. visible: visibleDateDeparture,
  298. child: Container(
  299. alignment:
  300. Alignment.centerLeft,
  301. margin: EdgeInsets.only(
  302. left: 15,
  303. right: 15,
  304. bottom: 5),
  305. child: Text(
  306. formattedDateDeparture,
  307. overflow:
  308. TextOverflow.ellipsis,
  309. maxLines: 1,
  310. style: TextStyle(
  311. color:
  312. Colors.black54),
  313. ),
  314. ),
  315. ),
  316. ],
  317. ),
  318. ),
  319. Container(
  320. margin: EdgeInsets.only(
  321. left: 10, right: 10, top: 10, bottom: 10),
  322. child: Column(
  323. children: [
  324. Align(
  325. alignment: Alignment.centerLeft,
  326. child: Text(
  327. 'Return Date',
  328. style: GoogleFonts.inconsolata(
  329. fontSize: 16, fontWeight: FontWeight.bold),
  330. )
  331. ),
  332. ElevatedButton(
  333. onPressed: () async {
  334. DateTime? newDate =
  335. await showDatePicker(
  336. context: context,
  337. initialDate:
  338. dateFrom,
  339. firstDate:
  340. DateTime(1900),
  341. lastDate:
  342. DateTime(2100));
  343. final DateFormat formatter =
  344. DateFormat(
  345. 'yyyy-MM-dd');
  346. if (newDate == null) {
  347. return;
  348. } else {
  349. setState(() {
  350. if (visibleDateReturn ==
  351. false) {
  352. visibleDateReturn =
  353. !visibleDateReturn;
  354. }
  355. formattedDateReturn =
  356. formatter.format(
  357. newDate);
  358. //dateFrom = formattedFrom as DateTime;
  359. });
  360. }
  361. },
  362. /*style: ElevatedButton.styleFrom(
  363. backgroundColor:
  364. CupertinoColors
  365. .systemGrey2),*/
  366. child: Container(
  367. width: double.infinity,
  368. child: Text(
  369. "Choose Date",
  370. style: TextStyle(
  371. color: Colors.white,
  372. fontSize: 16,
  373. fontWeight:
  374. FontWeight.w400),
  375. ),
  376. ),
  377. ),
  378. Visibility(
  379. visible: visibleDateReturn,
  380. child: Container(
  381. alignment:
  382. Alignment.centerLeft,
  383. margin: EdgeInsets.only(
  384. left: 15,
  385. right: 15,
  386. bottom: 5),
  387. child: Text(
  388. formattedDateReturn,
  389. overflow:
  390. TextOverflow.ellipsis,
  391. maxLines: 1,
  392. style: TextStyle(
  393. color:
  394. Colors.black54),
  395. ),
  396. ),
  397. ),
  398. ],
  399. ),
  400. ),
  401. Container(
  402. margin: EdgeInsets.only(
  403. left: 10, right: 10, top: 10, bottom: 10),
  404. child: Column(
  405. children: [
  406. Align(
  407. alignment: Alignment.centerLeft,
  408. child: Text(
  409. 'Destination',
  410. style: GoogleFonts.inconsolata(
  411. fontSize: 16, fontWeight: FontWeight.bold),
  412. )
  413. ),
  414. Container(
  415. margin: EdgeInsets.only(top: 7),
  416. decoration: BoxDecoration(
  417. color: Colors.white,
  418. borderRadius:
  419. BorderRadius.circular(5)),
  420. child: Padding(
  421. padding: EdgeInsets.only(
  422. left: 10,
  423. right: 10,
  424. top: 5,
  425. bottom: 5),
  426. child: TextFormField(
  427. keyboardType:
  428. TextInputType.multiline,
  429. maxLines: null,
  430. textInputAction:
  431. TextInputAction.next,
  432. controller:
  433. tujuanTeksController,
  434. decoration: InputDecoration(
  435. border:
  436. InputBorder.none,
  437. hintText: "ex. Bali")),
  438. )
  439. ),
  440. ],
  441. ),
  442. ),
  443. Container(
  444. margin: EdgeInsets.only(
  445. left: 10, right: 10, top: 10, bottom: 10),
  446. child: Column(
  447. children: [
  448. Align(
  449. alignment: Alignment.centerLeft,
  450. child: Text(
  451. 'Down Payment',
  452. style: GoogleFonts.inconsolata(
  453. fontSize: 16, fontWeight: FontWeight.bold),
  454. )),
  455. Container(
  456. margin: EdgeInsets.only(top: 7),
  457. decoration: BoxDecoration(
  458. color: Colors.white,
  459. borderRadius:
  460. BorderRadius.circular(5)),
  461. child: Padding(
  462. padding: EdgeInsets.only(
  463. left: 10,
  464. right: 10,
  465. top: 5,
  466. bottom: 5),
  467. child: TextFormField(
  468. keyboardType:
  469. TextInputType.number,
  470. maxLines: null,
  471. textInputAction:
  472. TextInputAction.next,
  473. controller:
  474. uangMukaTeksController,
  475. decoration: InputDecoration(
  476. border:
  477. InputBorder.none,
  478. hintText:
  479. "ex. 1500500")),
  480. )
  481. ),
  482. ],
  483. ),
  484. ),
  485. Container(
  486. margin: EdgeInsets.only(
  487. left: 10, right: 10, top: 10, bottom: 10),
  488. child: Column(
  489. children: [
  490. Align(
  491. alignment: Alignment.centerLeft,
  492. child: Text(
  493. 'Ticket Type',
  494. style: GoogleFonts.inconsolata(
  495. fontSize: 16, fontWeight: FontWeight.bold),
  496. )),
  497. Container(
  498. margin: EdgeInsets.only(top: 7),
  499. decoration: BoxDecoration(
  500. color:
  501. CupertinoColors.systemGrey2,
  502. borderRadius:
  503. BorderRadius.circular(5)),
  504. child: DropdownButton(
  505. menuMaxHeight: size.height * 0.31,
  506. value: this.selectedTicketType,
  507. isExpanded: true,
  508. underline: SizedBox(),
  509. hint: Text(
  510. '\t\tChoose Ticket Type',
  511. style: TextStyle(
  512. color: Colors.black54),
  513. ),
  514. onChanged: (value) {
  515. print(value);
  516. setState(() {
  517. selectedTicketType = value!;
  518. if (selectedTicketType ==
  519. "airplane") {
  520. kendaraan = "pesawat";
  521. } else if (selectedTicketType ==
  522. "train") {
  523. kendaraan = "kereta";
  524. }
  525. });
  526. },
  527. items: ticketType
  528. .map(
  529. (e) => DropdownMenuItem(
  530. value: e,
  531. child:
  532. Text("\t\t\t" + e)),
  533. )
  534. .toList(),
  535. ),
  536. ),
  537. ],
  538. ),
  539. ),
  540. Container(
  541. margin: EdgeInsets.only(
  542. left: 10, right: 10, top: 10, bottom: 10),
  543. child: Column(
  544. children: [
  545. Align(
  546. alignment: Alignment.centerLeft,
  547. child: Text(
  548. 'Ticket From',
  549. style: GoogleFonts.inconsolata(
  550. fontSize: 16, fontWeight: FontWeight.bold),
  551. )),
  552. Container(
  553. margin: EdgeInsets.only(top: 7),
  554. decoration: BoxDecoration(
  555. color: Colors.white,
  556. borderRadius:
  557. BorderRadius.circular(5)),
  558. child: Padding(
  559. padding: EdgeInsets.only(
  560. left: 10,
  561. right: 10,
  562. top: 5,
  563. bottom: 5),
  564. child: TextFormField(
  565. keyboardType:
  566. TextInputType.multiline,
  567. maxLines: null,
  568. textInputAction:
  569. TextInputAction.next,
  570. controller:
  571. ticketFromTeksController,
  572. decoration: InputDecoration(
  573. border:
  574. InputBorder.none,
  575. hintText:
  576. "ex. Jakarta")),
  577. )
  578. ),
  579. ],
  580. ),
  581. ),
  582. Container(
  583. margin: EdgeInsets.only(
  584. left: 10, right: 10, top: 10, bottom: 10),
  585. child: Column(
  586. children: [
  587. Align(
  588. alignment: Alignment.centerLeft,
  589. child: Text(
  590. 'Ticket To',
  591. style: GoogleFonts.inconsolata(
  592. fontSize: 16, fontWeight: FontWeight.bold),
  593. )),
  594. Container(
  595. margin: EdgeInsets.only(top: 7),
  596. decoration: BoxDecoration(
  597. color: Colors.white,
  598. borderRadius:
  599. BorderRadius.circular(5)),
  600. child: Padding(
  601. padding: EdgeInsets.only(
  602. left: 10,
  603. right: 10,
  604. top: 5,
  605. bottom: 5),
  606. child: TextFormField(
  607. keyboardType:
  608. TextInputType.multiline,
  609. maxLines: null,
  610. textInputAction:
  611. TextInputAction.next,
  612. controller:
  613. ticketToTeksController,
  614. decoration: InputDecoration(
  615. border:
  616. InputBorder.none,
  617. hintText: "ex. Bali")),
  618. )
  619. ),
  620. ],
  621. ),
  622. ),
  623. Container(
  624. margin: EdgeInsets.only(
  625. left: 10, right: 10, top: 10, bottom: 10),
  626. child: Column(
  627. children: [
  628. Align(
  629. alignment: Alignment.centerLeft,
  630. child: Text(
  631. 'Ticket Date',
  632. style: GoogleFonts.inconsolata(
  633. fontSize: 16, fontWeight: FontWeight.bold),
  634. )),
  635. ElevatedButton(
  636. onPressed: () async {
  637. DateTime? newDate =
  638. await showDatePicker(
  639. context: context,
  640. initialDate:
  641. dateFrom,
  642. firstDate:
  643. DateTime(1900),
  644. lastDate:
  645. DateTime(2100));
  646. final DateFormat formatter =
  647. DateFormat(
  648. 'yyyy-MM-dd');
  649. if (newDate == null) {
  650. return;
  651. } else {
  652. setState(() {
  653. if (visibleDateTicket ==
  654. false) {
  655. visibleDateTicket =
  656. !visibleDateTicket;
  657. }
  658. formattedDateTicket =
  659. formatter.format(
  660. newDate);
  661. //dateFrom = formattedFrom as DateTime;
  662. });
  663. }
  664. },
  665. /*style: ElevatedButton.styleFrom(
  666. backgroundColor:
  667. CupertinoColors
  668. .systemGrey2),*/
  669. child: Container(
  670. width: double.infinity,
  671. child: Text(
  672. "Choose Date",
  673. style: TextStyle(
  674. color: Colors.white,
  675. fontSize: 16,
  676. fontWeight:
  677. FontWeight.w400),
  678. ),
  679. ),
  680. ),
  681. Visibility(
  682. visible: visibleDateTicket,
  683. child: Container(
  684. alignment:
  685. Alignment.centerLeft,
  686. margin: EdgeInsets.only(
  687. left: 15,
  688. right: 15,
  689. bottom: 5),
  690. child: Text(
  691. formattedDateTicket,
  692. overflow:
  693. TextOverflow.ellipsis,
  694. maxLines: 1,
  695. style: TextStyle(
  696. color:
  697. Colors.black54),
  698. ),
  699. ),
  700. )
  701. ],
  702. ),
  703. ),
  704. Container(
  705. margin: EdgeInsets.only(
  706. left: 10, right: 10, top: 10, bottom: 10),
  707. child: Column(
  708. children: [
  709. Align(
  710. alignment: Alignment.centerLeft,
  711. child: Text(
  712. 'Ticket Price',
  713. style: GoogleFonts.inconsolata(
  714. fontSize: 16, fontWeight: FontWeight.bold),
  715. )),
  716. Container(
  717. margin: EdgeInsets.only(top: 7),
  718. decoration: BoxDecoration(
  719. color: Colors.white,
  720. borderRadius:
  721. BorderRadius.circular(5)),
  722. child: Padding(
  723. padding: EdgeInsets.only(
  724. left: 10,
  725. right: 10,
  726. top: 5,
  727. bottom: 5),
  728. child: TextFormField(
  729. keyboardType:
  730. TextInputType.number,
  731. maxLines: null,
  732. textInputAction:
  733. TextInputAction.done,
  734. controller:
  735. ticketPriceTeksController,
  736. decoration: InputDecoration(
  737. border:
  738. InputBorder.none,
  739. hintText:
  740. "ex. 1550000")),
  741. )
  742. )
  743. ],
  744. ),
  745. ),
  746. InkWell(
  747. child: Container(
  748. margin: EdgeInsets.only(left: 10, right: 10, bottom: 15, top: 10),
  749. padding: EdgeInsets.fromLTRB(10, 10, 10, 10),
  750. width: double.infinity,
  751. decoration: BoxDecoration(
  752. borderRadius:
  753. BorderRadius.circular(5),
  754. gradient: LinearGradient(colors: [
  755. Color(0xFFFF9945),
  756. Color(0xFFFc6076)
  757. ])),
  758. child: Text('Submit',
  759. textAlign: TextAlign.center,
  760. style: TextStyle(
  761. color: Colors.white,
  762. fontSize: 17,
  763. fontWeight: FontWeight.w500)),
  764. ),
  765. onTap: () async {
  766. ProgressDialog loading =
  767. ProgressDialog(context);
  768. loading = ProgressDialog(context,
  769. type: ProgressDialogType.normal,
  770. isDismissible: false,
  771. showLogs: true);
  772. loading.style(
  773. message: 'Please Wait .....',
  774. borderRadius: 3,
  775. backgroundColor: Colors.white,
  776. progressWidget:
  777. CircularProgressIndicator(),
  778. elevation: 10.0,
  779. padding: EdgeInsets.all(10),
  780. insetAnimCurve: Curves.easeInOut,
  781. progress: 0.0,
  782. maxProgress: 100.0,
  783. progressTextStyle: TextStyle(
  784. color: Colors.black,
  785. fontSize: 10.0,
  786. fontWeight: FontWeight.w400),
  787. messageTextStyle: TextStyle(
  788. color: Colors.black,
  789. fontSize: 15.0,
  790. fontWeight: FontWeight.w600));
  791. if (!validateFormPengajuanST(
  792. context)) {
  793. return;
  794. } else if (validateFormPengajuanST(
  795. context)) {
  796. await loading.show();
  797. PengajuanST_Post.connectToAPI(
  798. formattedDateST,
  799. uangMukaTeksController.text
  800. .toString(),
  801. keperluanTeksController.text
  802. .toString(),
  803. formattedDateDeparture,
  804. formattedDateReturn,
  805. tujuanTeksController.text
  806. .toString(),
  807. kendaraan,
  808. ticketFromTeksController
  809. .text
  810. .toString(),
  811. ticketToTeksController.text
  812. .toString(),
  813. formattedDateTicket,
  814. ticketPriceTeksController
  815. .text
  816. .toString())
  817. .then((valueResult) async {
  818. logDev.log(kendaraan,
  819. name:
  820. "TICKET TYPE - Kendaraan");
  821. Map<String, dynamic> object =
  822. json.decode(valueResult);
  823. if (object
  824. .containsKey("result")
  825. .toString() ==
  826. "true") {
  827. String result =
  828. object['result'].toString();
  829. if (result.contains("failed")) {
  830. await loading.hide();
  831. Widget okButton = TextButton(
  832. child: Text("OK"),
  833. onPressed: () {
  834. Navigator.of(context,
  835. rootNavigator:
  836. true)
  837. .pop();
  838. },
  839. );
  840. // set up the AlertDialog
  841. AlertDialog alert =
  842. AlertDialog(
  843. title: Text(
  844. "Employee Self Service"),
  845. content: Text(
  846. "Error Submit, Please Try Again Later!"),
  847. actions: [
  848. okButton,
  849. ],
  850. );
  851. // show the dialog
  852. showDialog(
  853. context: context,
  854. builder:
  855. (BuildContext context) {
  856. return alert;
  857. },
  858. );
  859. } else {
  860. await loading.hide();
  861. /*formattedDateFrom = "";
  862. visibleDateFrom = false;
  863. visibleDateFrom = false;
  864. deskripsiTeksController.clear();*/
  865. Widget okButton = TextButton(
  866. child: Text("OK"),
  867. onPressed: () {
  868. Navigator.of(context,
  869. rootNavigator:
  870. true)
  871. .pop();
  872. Navigator.pushReplacement(
  873. context,
  874. MaterialPageRoute(
  875. builder: (context) =>
  876. PengajuanST_Screen()));
  877. },
  878. );
  879. // set up the AlertDialog
  880. AlertDialog alert =
  881. AlertDialog(
  882. title: Text(
  883. "Employee Self Service"),
  884. content: Text(
  885. "Success Submit Assignment Letter"),
  886. actions: [
  887. okButton,
  888. ],
  889. );
  890. // show the dialog
  891. showDialog(
  892. context: context,
  893. builder:
  894. (BuildContext context) {
  895. return alert;
  896. },
  897. );
  898. }
  899. } else {
  900. await loading.hide();
  901. alertDialogFailedResponse(
  902. context);
  903. }
  904. });
  905. }
  906. },
  907. ),
  908. ],
  909. ),
  910. ),
  911. ),
  912. ),
  913. ],
  914. ),
  915. ),
  916. ),
  917. ],
  918. ),
  919. ],
  920. )),
  921. );
  922. }
  923. bool validateFormPengajuanST(BuildContext context) {
  924. bool result = true;
  925. if (formattedDateST == "") {
  926. Fluttertoast.showToast(
  927. msg: "Assignment Letter Date\nNot Selected",
  928. toastLength: Toast.LENGTH_SHORT,
  929. gravity: ToastGravity.CENTER,
  930. timeInSecForIosWeb: 1,
  931. textColor: Colors.white,
  932. fontSize: 16.0);
  933. result = false;
  934. } else if (keperluanTeksController.text.toString().isEmpty) {
  935. Fluttertoast.showToast(
  936. msg: "Description of Needs Required!",
  937. toastLength: Toast.LENGTH_SHORT,
  938. gravity: ToastGravity.CENTER,
  939. timeInSecForIosWeb: 1,
  940. textColor: Colors.white,
  941. fontSize: 16.0);
  942. result = false;
  943. } else if (formattedDateDeparture == "") {
  944. Fluttertoast.showToast(
  945. msg: "Departure Date Not Selected",
  946. toastLength: Toast.LENGTH_SHORT,
  947. gravity: ToastGravity.CENTER,
  948. timeInSecForIosWeb: 1,
  949. textColor: Colors.white,
  950. fontSize: 16.0);
  951. result = false;
  952. } else if (formattedDateReturn == "") {
  953. Fluttertoast.showToast(
  954. msg: "Return Date Not Selected",
  955. toastLength: Toast.LENGTH_SHORT,
  956. gravity: ToastGravity.CENTER,
  957. timeInSecForIosWeb: 1,
  958. textColor: Colors.white,
  959. fontSize: 16.0);
  960. result = false;
  961. } else if (tujuanTeksController.text.toString().isEmpty) {
  962. Fluttertoast.showToast(
  963. msg: "Destination Required!",
  964. toastLength: Toast.LENGTH_SHORT,
  965. gravity: ToastGravity.CENTER,
  966. timeInSecForIosWeb: 1,
  967. textColor: Colors.white,
  968. fontSize: 16.0);
  969. result = false;
  970. } else if (uangMukaTeksController.text.toString().isEmpty) {
  971. Fluttertoast.showToast(
  972. msg: "Down Payment Required!",
  973. toastLength: Toast.LENGTH_SHORT,
  974. gravity: ToastGravity.CENTER,
  975. timeInSecForIosWeb: 1,
  976. textColor: Colors.white,
  977. fontSize: 16.0);
  978. result = false;
  979. }
  980. /*else if (selectedTicketType == null) {
  981. Fluttertoast.showToast(
  982. msg: "Ticket Type Not Selected",
  983. toastLength: Toast.LENGTH_SHORT,
  984. gravity: ToastGravity.CENTER,
  985. timeInSecForIosWeb: 1,
  986. textColor: Colors.white,
  987. fontSize: 16.0);
  988. result = false;
  989. } else if (ticketFromTeksController.text.toString().isEmpty){
  990. Fluttertoast.showToast(
  991. msg: "Ticket From Required!",
  992. toastLength: Toast.LENGTH_SHORT,
  993. gravity: ToastGravity.CENTER,
  994. timeInSecForIosWeb: 1,
  995. textColor: Colors.white,
  996. fontSize: 16.0);
  997. result = false;
  998. } else if (ticketToTeksController.text.toString().isEmpty){
  999. Fluttertoast.showToast(
  1000. msg: "Ticket To Required!",
  1001. toastLength: Toast.LENGTH_SHORT,
  1002. gravity: ToastGravity.CENTER,
  1003. timeInSecForIosWeb: 1,
  1004. textColor: Colors.white,
  1005. fontSize: 16.0);
  1006. result = false;
  1007. } else if (formattedDateTicket == "") {
  1008. Fluttertoast.showToast(
  1009. msg: "Ticket Date Not Selected",
  1010. toastLength: Toast.LENGTH_SHORT,
  1011. gravity: ToastGravity.CENTER,
  1012. timeInSecForIosWeb: 1,
  1013. textColor: Colors.white,
  1014. fontSize: 16.0);
  1015. result = false;
  1016. } else if (ticketPriceTeksController.text.toString().isEmpty){
  1017. Fluttertoast.showToast(
  1018. msg: "Ticket Price Required!",
  1019. toastLength: Toast.LENGTH_SHORT,
  1020. gravity: ToastGravity.CENTER,
  1021. timeInSecForIosWeb: 1,
  1022. textColor: Colors.white,
  1023. fontSize: 16.0);
  1024. result = false;
  1025. }*/
  1026. return result;
  1027. }
  1028. }
  1029. alertDialogFailedRetrievedData(BuildContext context) {
  1030. Widget okButton = TextButton(
  1031. child: Text("Refresh"),
  1032. onPressed: () {
  1033. /*Navigator.of(context, rootNavigator: true).pop();
  1034. Navigator.pushReplacement(context, MaterialPageRoute(
  1035. builder: (context) => AjukanCutiScreen()));*/
  1036. },
  1037. );
  1038. Widget noButton = TextButton(
  1039. child: Text("Back"),
  1040. onPressed: () {
  1041. Navigator.of(context, rootNavigator: true).pop();
  1042. Navigator.pop(context);
  1043. },
  1044. );
  1045. // set up the AlertDialog
  1046. AlertDialog alert = AlertDialog(
  1047. title: Text("Employee Self Service"),
  1048. content: Text("Failed to Retrieve Data"),
  1049. actions: [
  1050. noButton,
  1051. okButton,
  1052. ],
  1053. );
  1054. // show the dialog
  1055. showDialog(
  1056. context: context,
  1057. builder: (BuildContext context) {
  1058. return alert;
  1059. },
  1060. );
  1061. }
  1062. alertDialogFailedResponse(BuildContext context) {
  1063. Widget okButton = TextButton(
  1064. child: Text("Refresh"),
  1065. onPressed: () {
  1066. /* Navigator.of(context, rootNavigator: true).pop();
  1067. Navigator.pushReplacement(context, MaterialPageRoute(
  1068. builder: (context) => AjukanCutiScreen()));*/
  1069. },
  1070. );
  1071. Widget noButton = TextButton(
  1072. child: Text("Back"),
  1073. onPressed: () {
  1074. Navigator.of(context, rootNavigator: true).pop();
  1075. Navigator.pop(context);
  1076. },
  1077. );
  1078. // set up the AlertDialog
  1079. AlertDialog alert = AlertDialog(
  1080. title: Text("Employee Self Service"),
  1081. content: Text("Server Response Error"),
  1082. actions: [
  1083. noButton,
  1084. okButton,
  1085. ],
  1086. );
  1087. // show the dialog
  1088. showDialog(
  1089. context: context,
  1090. builder: (BuildContext context) {
  1091. return alert;
  1092. },
  1093. );
  1094. }
  1095. List<String> ticketType = ["airplane", "train"];