Bez popisu
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 62KB

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