Keine Beschreibung
Du kannst nicht mehr als 25 Themen auswählen Themen müssen mit entweder einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

deklarasi_st.dart 27KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563
  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 DeklarasiST_Screen extends StatefulWidget {
  21. const DeklarasiST_Screen({Key? key}) : super(key: key);
  22. @override
  23. State<DeklarasiST_Screen> createState() => _DeklarasiST_Screen_State();
  24. }
  25. class _DeklarasiST_Screen_State extends State<DeklarasiST_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. super.initState();
  44. }
  45. /*loadingPage(){
  46. ProgressDialog loading = ProgressDialog(context);
  47. loading = ProgressDialog(context,
  48. type: ProgressDialogType.normal, isDismissible: false, showLogs: true);
  49. loading.style(
  50. message: 'Please Wait .....',
  51. borderRadius: 3,
  52. backgroundColor: Colors.white,
  53. progressWidget: CircularProgressIndicator(),
  54. elevation: 10.0,
  55. padding: EdgeInsets.all(10),
  56. insetAnimCurve: Curves.easeInOut,
  57. progress: 0.0,
  58. maxProgress: 100.0,
  59. progressTextStyle: TextStyle(
  60. color: Colors.black, fontSize: 10.0, fontWeight: FontWeight.w400),
  61. messageTextStyle: TextStyle(
  62. color: Colors.black, fontSize: 15.0, fontWeight: FontWeight.w600));
  63. loading.show();
  64. WidgetsBinding.instance.addPostFrameCallback((_){
  65. loading.hide();
  66. });
  67. }*/
  68. @override
  69. Widget build(BuildContext context) {
  70. return Scaffold(
  71. body: SingleChildScrollView(
  72. child: Column(
  73. children: <Widget>[
  74. Stack(
  75. children: [
  76. WavyHeader(),
  77. Container(
  78. margin: EdgeInsets.only(top: MediaQuery.of(context).size.height/6 - 20),
  79. padding: EdgeInsets.fromLTRB(20, 5, 25, 5),
  80. child: Row(
  81. mainAxisAlignment: MainAxisAlignment.end,
  82. crossAxisAlignment: CrossAxisAlignment.end,
  83. children: [
  84. Text(
  85. 'Declaration of\nAssignment Letter\t\t',
  86. maxLines: 2,
  87. style: GoogleFonts.luckiestGuy(
  88. fontSize: 28,
  89. color: Color(0xFF4858A7),
  90. fontStyle: FontStyle.italic,
  91. ),
  92. ),
  93. Image.asset('assets/images/submit_st.png',
  94. width: 40,
  95. height: 40,
  96. ),
  97. ],
  98. )),
  99. SafeArea(
  100. child: Container(
  101. width: MediaQuery.of(context).size.width,
  102. margin: EdgeInsets.only(
  103. top: MediaQuery.of(context).size.height / 5, left: 10, right: 10, bottom: 10
  104. ),
  105. child: Column(
  106. children: [
  107. Container(
  108. child: Card(
  109. elevation: 10,
  110. child: Container(
  111. decoration: BoxDecoration(
  112. color: Color(0XFFFAF7EE),
  113. borderRadius: BorderRadius.circular(10)),
  114. child: Column(
  115. children: [
  116. /*Container(
  117. margin: EdgeInsets.only(
  118. left: 10, right: 10, top: 15, bottom: 15),
  119. child: Text('Assignment Letter Submission', style:
  120. GoogleFonts.josefinSans(fontSize: 18, fontWeight: FontWeight.bold, decoration: TextDecoration.underline,
  121. decorationStyle: TextDecorationStyle.dashed),),
  122. ),*/
  123. Container(
  124. margin: EdgeInsets.only(
  125. left: 10, right: 10, top: 10, bottom: 10),
  126. child: Row(
  127. children: [
  128. Expanded(
  129. flex: 3,
  130. child: Text(
  131. 'Total Amount',
  132. style: GoogleFonts.inconsolata(
  133. fontSize: 17),
  134. )),
  135. Expanded(
  136. flex: 7,
  137. child: Container(
  138. decoration: BoxDecoration(
  139. color: Colors.white,
  140. borderRadius:
  141. BorderRadius.circular(5)),
  142. child: Padding(
  143. padding: EdgeInsets.only(
  144. left: 10,
  145. right: 10,
  146. top: 5,
  147. bottom: 5),
  148. child: TextFormField(
  149. keyboardType:
  150. TextInputType.multiline,
  151. maxLines: 1,
  152. textInputAction:
  153. TextInputAction.next,
  154. controller: keperluanTeksController,
  155. decoration: InputDecoration(
  156. border:
  157. InputBorder.none,
  158. hintText: "ex. 2500750")),
  159. ))),
  160. ],
  161. ),
  162. ),
  163. Container(
  164. margin: EdgeInsets.only(
  165. left: 10, right: 10, top: 10, bottom: 10),
  166. child: Row(
  167. children: [
  168. Expanded(
  169. flex: 3,
  170. child: Text(
  171. 'Description',
  172. style: GoogleFonts.inconsolata(
  173. fontSize: 17),
  174. )),
  175. Expanded(
  176. flex: 7,
  177. child: Container(
  178. decoration: BoxDecoration(
  179. color: Colors.white,
  180. borderRadius:
  181. BorderRadius.circular(5)),
  182. child: Padding(
  183. padding: EdgeInsets.only(
  184. left: 10,
  185. right: 10,
  186. top: 5,
  187. bottom: 5),
  188. child: TextFormField(
  189. keyboardType:
  190. TextInputType.multiline,
  191. maxLines: null,
  192. textInputAction:
  193. TextInputAction.next,
  194. controller: tujuanTeksController,
  195. decoration: InputDecoration(
  196. border:
  197. InputBorder.none,
  198. hintText: "description")),
  199. ))),
  200. ],
  201. ),
  202. ),
  203. Container(
  204. margin: EdgeInsets.only(
  205. left: 10, right: 10, top: 10, bottom: 10),
  206. child: Column(
  207. children: [
  208. Row(
  209. children: [
  210. Expanded(
  211. flex: 3,
  212. child: Text(
  213. 'Attachment',
  214. style: GoogleFonts.inconsolata(
  215. fontSize: 17),
  216. ),
  217. ),
  218. Expanded(
  219. flex: 7,
  220. child: Container(
  221. child: ElevatedButton(
  222. onPressed: () {
  223. _pickMultipleFiles();
  224. },
  225. /*style: ElevatedButton.styleFrom(
  226. backgroundColor:
  227. CupertinoColors
  228. .systemGrey2),*/
  229. child: Container(
  230. width: double.infinity,
  231. child: Text("Choose File",
  232. style: TextStyle(
  233. color: Colors.white,
  234. fontSize: 16,
  235. fontWeight:
  236. FontWeight.w400)),
  237. ),
  238. ),
  239. ),
  240. )
  241. ],
  242. ),
  243. Row(
  244. children: [
  245. Expanded(
  246. flex: 3,
  247. child: Text(
  248. '',
  249. style: GoogleFonts.inconsolata(
  250. fontSize: 17),
  251. ),
  252. ),
  253. Expanded(
  254. flex: 7,
  255. child: Container(
  256. alignment:
  257. Alignment.centerLeft,
  258. margin: EdgeInsets.only(
  259. left: 15,
  260. right: 15,
  261. bottom: 10),
  262. child: Text(_totalFile + _fileText,
  263. overflow:
  264. TextOverflow.ellipsis,
  265. /*maxLines: 7,*/
  266. style: TextStyle(
  267. color: Colors.black54),
  268. ),
  269. ),
  270. )
  271. ],
  272. ),
  273. InkWell(
  274. child: Container(
  275. padding: EdgeInsets.fromLTRB(
  276. 10, 10, 10, 10),
  277. width: double.infinity,
  278. decoration: BoxDecoration(
  279. borderRadius:
  280. BorderRadius.circular(5),
  281. gradient: LinearGradient(colors: [
  282. Color(0xFFFF9945),
  283. Color(0xFFFc6076)
  284. ])),
  285. child: Text('Submit',
  286. textAlign: TextAlign.center,
  287. style: TextStyle(
  288. color: Colors.white,
  289. fontSize: 17,
  290. fontWeight: FontWeight.w500)),
  291. ),
  292. onTap: () {
  293. ProgressDialog loading = ProgressDialog(context);
  294. loading = ProgressDialog(context,
  295. type: ProgressDialogType.normal, isDismissible: false, showLogs: true);
  296. loading.style(
  297. message: 'Please Wait .....',
  298. borderRadius: 3,
  299. backgroundColor: Colors.white,
  300. progressWidget: CircularProgressIndicator(),
  301. elevation: 10.0,
  302. padding: EdgeInsets.all(10),
  303. insetAnimCurve: Curves.easeInOut,
  304. progress: 0.0,
  305. maxProgress: 100.0,
  306. progressTextStyle: TextStyle(
  307. color: Colors.black, fontSize: 10.0, fontWeight: FontWeight.w400),
  308. messageTextStyle: TextStyle(
  309. color: Colors.black, fontSize: 15.0, fontWeight: FontWeight.w600));
  310. //loading.show();
  311. /*if (!validateFormCuti(context)){
  312. return;
  313. } else if (validateFormCuti(context)){
  314. loading.show();
  315. PengajuanCuti_Post.connectToAPI(idCuti, formattedDateFrom,
  316. formattedDateTo, deskripsiTeksController.text.toString(), fileAttach)
  317. .then((valueResult) async {
  318. Map<String, dynamic> object = json.decode(valueResult);
  319. logDev.log(fileAttach.toString(), name: "Attachment File Upload");
  320. if (object.containsKey("result").toString() == "true") {
  321. *//*String employee = object['result']['employee'].toString();
  322. String tipe = object['result']['tipe'].toString();
  323. String from = object['result']['from'].toString();
  324. String to = object['result']['to'].toString();
  325. String deskripsi = object['result']['deskripsi'].toString();
  326. String attachment = object['result']['attachment'].toString();*//*
  327. loading.hide();
  328. deskripsiTeksController.clear();
  329. Widget okButton = TextButton(
  330. child: Text("OK"),
  331. onPressed: () {
  332. Navigator.of(context, rootNavigator: true).pop();
  333. Navigator.pushReplacement(context, MaterialPageRoute(
  334. builder: (context) => AjukanCutiScreen()));
  335. },
  336. );
  337. // set up the AlertDialog
  338. AlertDialog alert = AlertDialog(
  339. title: Text("Employee Self Service"),
  340. content: Text("Success Submit Time Off"),
  341. actions: [
  342. okButton,
  343. ],
  344. );
  345. // show the dialog
  346. showDialog(
  347. context: context,
  348. builder: (BuildContext context) {
  349. return alert;
  350. },
  351. );
  352. *//* deskripsiTeksController.clear();
  353. formattedDateFrom = "";
  354. formattedDateTo = "";
  355. visibleDateFrom = false;
  356. visibleDateFrom = false;*//*
  357. } else if (object.containsKey("error").toString() == "true") {
  358. String errorMessage = object['error']['data']['message']
  359. .toString();
  360. loading.hide();
  361. Widget okButton = TextButton(
  362. child: Text("OK"),
  363. onPressed: () {
  364. Navigator.of(context, rootNavigator: true).pop();
  365. },
  366. );
  367. // set up the AlertDialog
  368. AlertDialog alert = AlertDialog(
  369. title: Text("Employee Self Service"),
  370. content: Text(errorMessage),
  371. actions: [
  372. okButton,
  373. ],
  374. );
  375. // show the dialog
  376. showDialog(
  377. context: context,
  378. builder: (BuildContext context) {
  379. return alert;
  380. },
  381. );
  382. }
  383. });
  384. }*/
  385. },
  386. )
  387. ],
  388. ),
  389. ),
  390. ],
  391. ),
  392. ),
  393. ),
  394. ),
  395. ],
  396. ),
  397. ),
  398. ),
  399. ],
  400. ),
  401. ],
  402. )),
  403. );
  404. }
  405. void _pickMultipleFiles() async {
  406. FilePickerResult? result = await FilePicker.platform.pickFiles(allowMultiple: true);
  407. if (_fileText != ""){
  408. _fileText = "";
  409. }
  410. if (result != null) {
  411. List<File> files = result.paths.map((path) => File(path!)).toList();
  412. for (int i = 0; i< files.length; i++){
  413. String fileName = files[i].path.split('/').last;
  414. _fileText = _fileText + "\n" + fileName;
  415. List<int> fileInBytes = files[i].readAsBytesSync();
  416. String toBase64 = base64Encode(fileInBytes);
  417. fileAttach.add(toBase64);
  418. }
  419. fileAttach.removeAt(0);
  420. logDev.log(fileAttach.length.toString(), name: "Length File Attach");
  421. logDev.log(files.toString(), name: "Files Picked");
  422. setState(() {
  423. _fileText;
  424. _totalFile = "Total File : " + files.length.toString();
  425. });
  426. } else {
  427. // User canceled the picker
  428. }
  429. }
  430. bool validateFormPengajuanST (BuildContext context) {
  431. bool result = true;
  432. if (formattedDateST == "") {
  433. Fluttertoast.showToast(
  434. msg: "Assignment Letter Date\nNot Selected",
  435. toastLength: Toast.LENGTH_SHORT,
  436. gravity: ToastGravity.CENTER,
  437. timeInSecForIosWeb: 1,
  438. textColor: Colors.white,
  439. fontSize: 16.0);
  440. result = false;
  441. } else if (keperluanTeksController.text.toString().isEmpty) {
  442. Fluttertoast.showToast(
  443. msg: "Description of Needs Required!",
  444. toastLength: Toast.LENGTH_SHORT,
  445. gravity: ToastGravity.CENTER,
  446. timeInSecForIosWeb: 1,
  447. textColor: Colors.white,
  448. fontSize: 16.0);
  449. result = false;
  450. }
  451. return result;
  452. }
  453. }
  454. alertDialogFailedRetrievedData(BuildContext context){
  455. Widget okButton = TextButton(
  456. child: Text("Refresh"),
  457. onPressed: () {
  458. /*Navigator.of(context, rootNavigator: true).pop();
  459. Navigator.pushReplacement(context, MaterialPageRoute(
  460. builder: (context) => AjukanCutiScreen()));*/
  461. },
  462. );
  463. Widget noButton = TextButton(
  464. child: Text("Back"),
  465. onPressed: () {
  466. Navigator.of(context, rootNavigator: true).pop();
  467. Navigator.pop(context);
  468. },
  469. );
  470. // set up the AlertDialog
  471. AlertDialog alert = AlertDialog(
  472. title: Text("Employee Self Service"),
  473. content: Text("Failed to Retrieve Data"),
  474. actions: [
  475. noButton,
  476. okButton,
  477. ],
  478. );
  479. // show the dialog
  480. showDialog(
  481. context: context,
  482. builder: (BuildContext context) {
  483. return alert;
  484. },
  485. );
  486. }
  487. alertDialogFailedResponse(BuildContext context){
  488. Widget okButton = TextButton(
  489. child: Text("Refresh"),
  490. onPressed: () {
  491. /* Navigator.of(context, rootNavigator: true).pop();
  492. Navigator.pushReplacement(context, MaterialPageRoute(
  493. builder: (context) => AjukanCutiScreen()));*/
  494. },
  495. );
  496. Widget noButton = TextButton(
  497. child: Text("Back"),
  498. onPressed: () {
  499. Navigator.of(context, rootNavigator: true).pop();
  500. Navigator.pop(context);
  501. },
  502. );
  503. // set up the AlertDialog
  504. AlertDialog alert = AlertDialog(
  505. title: Text("Employee Self Service"),
  506. content: Text("Server Response Error"),
  507. actions: [
  508. noButton,
  509. okButton,
  510. ],
  511. );
  512. // show the dialog
  513. showDialog(
  514. context: context,
  515. builder: (BuildContext context) {
  516. return alert;
  517. },
  518. );
  519. }
  520. List<String> ticketType = [
  521. "airplane",
  522. "train"
  523. ];