From 198f7ccd1775e1378da37ee11aa2caebc5bbb069 Mon Sep 17 00:00:00 2001 From: sindhu Date: Tue, 16 Jan 2024 10:38:44 +0700 Subject: [PATCH] step 16 : add M_CompanyID for trans, menu drawer, fix bug overflow btn --- app_petty_cash/lib/app/route.dart | 31 +- .../lib/repository/auth_repository.dart | 6 +- .../lib/repository/base_repository.dart | 22 + .../lib/repository/transaksi_repository.dart | 3 + .../screen/change_company/change_company.dart | 1 + .../lib/screen/report/report_screen.dart | 686 +++++----- .../transaksi/history_transaksi_screen.dart | 91 ++ .../screen/transaksi/transaksi_screen.dart | 1154 +++++++++-------- app_petty_cash/lib/widget/custom_drawer.dart | 78 +- 9 files changed, 1201 insertions(+), 871 deletions(-) create mode 100644 app_petty_cash/lib/screen/transaksi/history_transaksi_screen.dart diff --git a/app_petty_cash/lib/app/route.dart b/app_petty_cash/lib/app/route.dart index 0c7457a..e4cdefc 100644 --- a/app_petty_cash/lib/app/route.dart +++ b/app_petty_cash/lib/app/route.dart @@ -1,7 +1,8 @@ - +import '../screen/change_company/change_company.dart'; import 'package:flutter/material.dart'; import '../screen/home/home_screen.dart'; +import '../screen/transaksi/history_transaksi_screen.dart'; import '../screen/transaksi/transaksi_screen.dart'; import '../screen/login/login_screen.dart'; import '../screen/splash/splash_screen.dart'; @@ -16,6 +17,8 @@ const homeRoute = "/homeRoute"; const transaksiRoute = "/transaksiRoute"; const userRoute = "/userRoute"; const reportRoute = "/reportRoute"; +const changeCompanyRoute = "/changeCompanyRoute"; +const historyTransaksiRoute = "/historyTransaksiRoute"; // test screen const testFilePickerRoute = "/testFilePickerRoute"; @@ -35,6 +38,32 @@ class AppRoute { }); } + // change Company + if (settings.name == changeCompanyRoute) { + return MaterialPageRoute(builder: (context) { + return MediaQuery( + data: MediaQuery.of(context).copyWith( + textScaleFactor: 1.0, + padding: EdgeInsets.all(0), + ), + child: ChangeCompanyScreen(), + ); + }); + } + + // history transaksi + if (settings.name == historyTransaksiRoute) { + return MaterialPageRoute(builder: (context) { + return MediaQuery( + data: MediaQuery.of(context).copyWith( + textScaleFactor: 1.0, + padding: EdgeInsets.all(0), + ), + child: HistoryTransaksiScreen(), + ); + }); + } + // report screen if (settings.name == reportRoute) { return MaterialPageRoute(builder: (context) { diff --git a/app_petty_cash/lib/repository/auth_repository.dart b/app_petty_cash/lib/repository/auth_repository.dart index 2762d47..b3daec9 100644 --- a/app_petty_cash/lib/repository/auth_repository.dart +++ b/app_petty_cash/lib/repository/auth_repository.dart @@ -1,3 +1,7 @@ +import 'dart:convert'; + +import 'package:shared_preferences/shared_preferences.dart'; + import '../app/constant.dart'; import '../model/auth_model.dart'; import 'base_repository.dart'; @@ -82,7 +86,7 @@ class AuthRepository extends BaseRepository { // model: AuthDoctorModel.fromJson(resp["data"]["user"]), // ); // return result; - + if (resp["status"] == "OK") { return resp['message']; } else { diff --git a/app_petty_cash/lib/repository/base_repository.dart b/app_petty_cash/lib/repository/base_repository.dart index 2ed2a75..35c0cf4 100644 --- a/app_petty_cash/lib/repository/base_repository.dart +++ b/app_petty_cash/lib/repository/base_repository.dart @@ -2,11 +2,33 @@ import 'dart:convert'; import 'dart:io'; import 'package:dio/dio.dart'; +import 'package:shared_preferences/shared_preferences.dart'; + +import '../app/constant.dart'; abstract class BaseRepository { final Dio dio; BaseRepository({required this.dio}); + Future getCompanyID() async { + final shared = await SharedPreferences.getInstance(); + String M_CompanyID = "0"; + + if (shared != null) { + final bearerString = shared.get(Constant.bearerName).toString(); + final xmodel = jsonDecode(bearerString); + if (xmodel != null) { + M_CompanyID = xmodel["model"]["M_CompanyID"]; + } + } + + if (M_CompanyID == "0") { + throw BaseRepositoryException(message: 'Invalid Company ID'); + } + + return M_CompanyID; + } + Future> post({ required Map param, required String service, diff --git a/app_petty_cash/lib/repository/transaksi_repository.dart b/app_petty_cash/lib/repository/transaksi_repository.dart index 9f90aa6..9c8fdc4 100644 --- a/app_petty_cash/lib/repository/transaksi_repository.dart +++ b/app_petty_cash/lib/repository/transaksi_repository.dart @@ -58,6 +58,7 @@ class TransaksiRepository extends BaseRepository { String sender, String url) async { String paramPostInUrl = ""; + String M_CompanyID = await getCompanyID(); if (tipe == "DEBIT") { sender = ""; paramPostInUrl = @@ -69,6 +70,8 @@ class TransaksiRepository extends BaseRepository { "?tanggal=$tanggal&tipe=$tipe&kategoriid=$kategoriid&jumlah=$jumlah&catatan=$catatan&url=$url&userid=$userid&sender=$sender"; } } + + paramPostInUrl += "&companyid=$M_CompanyID"; // /?tanggal=2023-12-29&tipe=KREDIT&kategoriid=3&jumlah=5000&catatan=Lakban%20Besar&url=&userid=1&sender= final service = diff --git a/app_petty_cash/lib/screen/change_company/change_company.dart b/app_petty_cash/lib/screen/change_company/change_company.dart index 98ece6a..6e4470c 100644 --- a/app_petty_cash/lib/screen/change_company/change_company.dart +++ b/app_petty_cash/lib/screen/change_company/change_company.dart @@ -25,6 +25,7 @@ class ChangeCompanyScreen extends StatelessWidget { ), ), drawer: CustomDrawer(), + body: Text('Under Construction'), ), ); } diff --git a/app_petty_cash/lib/screen/report/report_screen.dart b/app_petty_cash/lib/screen/report/report_screen.dart index d380ed6..ec67211 100644 --- a/app_petty_cash/lib/screen/report/report_screen.dart +++ b/app_petty_cash/lib/screen/report/report_screen.dart @@ -1,3 +1,7 @@ +import 'dart:convert'; + +import 'package:shared_preferences/shared_preferences.dart'; + import '../../widget/sankbar_widget.dart'; import 'package:flutter/material.dart'; import 'package:flutter_hooks/flutter_hooks.dart'; @@ -25,6 +29,26 @@ class ReportScreen extends HookConsumerWidget { final tglAkhir = useState(DateTime.now()); final tglAkhirTmp = useState(""); + String M_CompanyID = "0"; + + Future getCompanyID() async { + final shared = await SharedPreferences.getInstance(); + String M_CompanyID = "0"; + + if (shared != null) { + final bearerString = shared.get(Constant.bearerName).toString(); + final xmodel = jsonDecode(bearerString); + if (xmodel != null) { + M_CompanyID = xmodel["model"]["M_CompanyID"]; + } + } + + if (M_CompanyID == "0") { + // throw BaseRepositoryException(message: 'Invalid Company ID'); + } + + return M_CompanyID; + } useEffect(() { WidgetsBinding.instance.addPostFrameCallback((timeStamp) async { @@ -58,355 +82,361 @@ class ReportScreen extends HookConsumerWidget { ), drawer: CustomDrawer(), body: SafeArea( - child: SingleChildScrollView( - child: Padding( - padding: EdgeInsets.all(20), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text( - 'Tanggal Awal', - style: Constant.body1(context: context).copyWith( - fontWeight: FontWeight.w600, color: Constant.textBlack), - ), - SizedBox( - height: Constant.getActualYPhone(context: context, y: 10), - ), - // Tanggal Awal - Row( - children: [ - Expanded( - child: TextField( - controller: ctrlTglAwal, - decoration: InputDecoration( - hintStyle: - Constant.body2_400(context: context).copyWith( - color: Colors.orange, - ), - labelStyle: - Constant.body2_400(context: context).copyWith( - color: Colors.orange, - ), - border: OutlineInputBorder( - borderSide: BorderSide( - color: Colors.orange, - width: 1, - ), - ), - focusedBorder: OutlineInputBorder( - borderSide: BorderSide( - color: Colors.orange, - width: 1, - ), - ), - // labelText: "Tanggal Awal", - hintText: 'Tanggal Awal', - // suffixIcon: isLoadingFilterScope.value - // ? SizedBox( - // width: Constant.getActualXPhone( - // context: context, - // x: 4, - // ), - // height: Constant.getActualYPhone( - // context: context, - // y: 4, - // ), - // child: CircularProgressIndicator( - // color: Constant.textRed, - // ), - // ) - // : Icon( - // Icons.calendar_month_sharp, - // color: Constant.colorIconDate, - // ), - ), - onTap: () async { - final selectedDateAwal = await showDatePicker( - // locale: const Locale("en-CA"), - // locale: , - context: context, - initialEntryMode: - DatePickerEntryMode.calendarOnly, - firstDate: DateTime(2000), - lastDate: DateTime(2100), - - initialDate: (ctrlTglAwal.text.isEmpty) - ? DateTime.now() - : tglAwal.value, - ); - - if (selectedDateAwal != null) { - String formattedDate = DateFormat('dd-MM-yyyy') - .format(selectedDateAwal); - // ctrlTglAwal.text = - // selectedDateAwal.toString().split(' ')[0]; - ctrlTglAwal.text = formattedDate; - tglAwal.value = selectedDateAwal; - tglAwalTmp.value = selectedDateAwal.toString(); - } - - if (selectedDateAwal == null) { - print('cancel button'); - return; - } - }, - ), - ), - ], - ), - - SizedBox( - height: Constant.getActualYPhone(context: context, y: 20), - ), - - Text( - 'Tanggal Akhir', - style: Constant.body1(context: context).copyWith( - fontWeight: FontWeight.w600, color: Constant.textBlack), - ), - SizedBox( - height: Constant.getActualYPhone(context: context, y: 10), - ), - // Tanggal Akhir - Row( - children: [ - Expanded( - child: TextField( - controller: ctrlTglAkhir, - decoration: InputDecoration( - hintStyle: - Constant.body2_400(context: context).copyWith( - color: Colors.orange, - ), - labelStyle: - Constant.body2_400(context: context).copyWith( - color: Colors.orange, - ), - border: OutlineInputBorder( - borderSide: BorderSide( - color: Colors.orange, - width: 1, - ), - ), - focusedBorder: OutlineInputBorder( - borderSide: BorderSide( - color: Colors.orange, - width: 1, - ), - ), - // labelText: "Tanggal Awal", - hintText: 'Tanggal Akhir', - // suffixIcon: isLoadingFilterScope.value - // ? SizedBox( - // width: Constant.getActualXPhone( - // context: context, - // x: 4, - // ), - // height: Constant.getActualYPhone( - // context: context, - // y: 4, - // ), - // child: CircularProgressIndicator( - // color: Constant.textRed, - // ), - // ) - // : Icon( - // Icons.calendar_month_sharp, - // color: Constant.colorIconDate, - // ), - ), - onTap: () async { - final selectedDateAkhir = await showDatePicker( - // locale: const Locale("en-CA"), - // locale: , - context: context, - initialEntryMode: - DatePickerEntryMode.calendarOnly, - firstDate: DateTime(2000), - lastDate: DateTime(2100), - - initialDate: (ctrlTglAkhir.text.isEmpty) - ? DateTime.now() - : tglAkhir.value, - ); - - if (selectedDateAkhir != null) { - String formattedDate = DateFormat('dd-MM-yyyy') - .format(selectedDateAkhir); - // ctrlTglAkhir.text = - // selectedDateAkhir.toString().split(' ')[0]; - ctrlTglAkhir.text = formattedDate; - tglAkhir.value = selectedDateAkhir; - tglAkhirTmp.value = selectedDateAkhir.toString(); - } - - if (selectedDateAkhir == null) { - print('cancel button'); - return; - } - }, - ), - ), - ], - ), - ], - ), - ), - ), - ), - bottomNavigationBar: Container( - // height: 150, child: Padding( - padding: EdgeInsets.only( - // right: Constant.getActualXPhone(context: context, x: 27), - // left: Constant.getActualXPhone(context: context, x: 27), - // bottom: Constant.getActualYPhone(context: context, y: 32), - top: Constant.getActualYPhone(context: context, y: 24), - ), + padding: EdgeInsets.all(20), child: Column( + crossAxisAlignment: CrossAxisAlignment.start, children: [ - // Excel - Container( - width: Constant.getActualXPhone(context: context, x: 336), - height: Constant.getActualYPhone(context: context, y: 42), - child: ElevatedButton( - style: ButtonStyle( - backgroundColor: MaterialStateColor.resolveWith( - (states) => Colors.white), - // side: MaterialStateBorderSide.resolveWith( - // (states) => BorderSide(color: Colors.green), - // ), - - // backgroundColor: MaterialStateColor.resolveWith( - // (st) => Constant.pcBtnBackgroundColor), - shape: MaterialStateProperty.all( - RoundedRectangleBorder( - borderRadius: BorderRadius.circular(8), - side: BorderSide( - color: Colors.green, + Text( + 'Tanggal Awal', + style: Constant.body1(context: context).copyWith( + fontWeight: FontWeight.w600, color: Constant.textBlack), + ), + SizedBox( + height: Constant.getActualYPhone(context: context, y: 10), + ), + // Tanggal Awal + Row( + children: [ + Expanded( + child: TextField( + controller: ctrlTglAwal, + decoration: InputDecoration( + hintStyle: + Constant.body2_400(context: context).copyWith( + color: Colors.orange, ), + labelStyle: + Constant.body2_400(context: context).copyWith( + color: Colors.orange, + ), + border: OutlineInputBorder( + borderSide: BorderSide( + color: Colors.orange, + width: 1, + ), + ), + focusedBorder: OutlineInputBorder( + borderSide: BorderSide( + color: Colors.orange, + width: 1, + ), + ), + // labelText: "Tanggal Awal", + hintText: 'Tanggal Awal', + // suffixIcon: isLoadingFilterScope.value + // ? SizedBox( + // width: Constant.getActualXPhone( + // context: context, + // x: 4, + // ), + // height: Constant.getActualYPhone( + // context: context, + // y: 4, + // ), + // child: CircularProgressIndicator( + // color: Constant.textRed, + // ), + // ) + // : Icon( + // Icons.calendar_month_sharp, + // color: Constant.colorIconDate, + // ), ), + onTap: () async { + final selectedDateAwal = await showDatePicker( + // locale: const Locale("en-CA"), + // locale: , + context: context, + initialEntryMode: DatePickerEntryMode.calendarOnly, + firstDate: DateTime(2000), + lastDate: DateTime(2100), + + initialDate: (ctrlTglAwal.text.isEmpty) + ? DateTime.now() + : tglAwal.value, + ); + + if (selectedDateAwal != null) { + String formattedDate = DateFormat('dd-MM-yyyy') + .format(selectedDateAwal); + // ctrlTglAwal.text = + // selectedDateAwal.toString().split(' ')[0]; + ctrlTglAwal.text = formattedDate; + tglAwal.value = selectedDateAwal; + tglAwalTmp.value = selectedDateAwal.toString(); + } + + if (selectedDateAwal == null) { + print('cancel button'); + return; + } + }, ), - shadowColor: - MaterialStateProperty.all(Color(0xffff48423d)), - elevation: MaterialStateProperty.all(4.0), ), - child: Row( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Container( - width: - Constant.getActualXPhone(context: context, x: 16), - height: - Constant.getActualYPhone(context: context, y: 16), - // decoration: BoxDecoration(color: Colors.grey), - child: Image.asset( - "images/logo_excel.png", - fit: BoxFit.fill, - // scale: 1, - ), - ), - SizedBox( - height: - Constant.getActualXPhone(context: context, x: 8), - ), - Text( - 'Download Report (xls) ', - style: Constant.body1(context: context).copyWith( - fontWeight: FontWeight.w600, - color: Colors.green, - ), - ), - ], - ), - onPressed: () async { - // Awal - DateTime parsedDateAwal = DateFormat('dd-MM-yyyy').parse( - ctrlTglAwal.value.text.toString(), - ); - String formattedDateAwal = - DateFormat('yyyy-MM-dd').format(parsedDateAwal); - - // Akhir - DateTime parsedDateAkhir = DateFormat('dd-MM-yyyy').parse( - ctrlTglAwal.value.text.toString(), - ); - String formattedDateAkhir = - DateFormat('yyyy-MM-dd').format(parsedDateAkhir); - - String url = - "https://${Constant.baseUrlDevoneReport}/birt/run?__report=report/one/pettycash/rpt_r_pt_001.rptdesign&__format=pdf&PStartDate=$formattedDateAwal&PEndDate=$formattedDateAkhir&PCompanyID=0&username=adminsas%20"; - if (!await launchUrl(Uri.parse(url))) { - // throw Exception('Could not launch $url'); - SanckbarWidget(context, 'Could not launch $url', - snackbarType.error); - } - // https://devone.aplikasi.web.id/birt/run?__report=report/one/pettycash/rpt_r_pt_001.rptdesign&__format=pdf&PStartDate=2023-11-01&PEndDate=2023-12-30&PCompanyID=0&username=adminsas%20&tm=1701327096267 - }, - ), + ], ), SizedBox( height: Constant.getActualYPhone(context: context, y: 20), ), - // PDF - Container( - width: Constant.getActualXPhone(context: context, x: 336), - height: Constant.getActualYPhone(context: context, y: 42), - child: ElevatedButton( - style: ButtonStyle( - backgroundColor: MaterialStateColor.resolveWith( - (st) => Constant.pcBtnBackgroundColor), - shape: MaterialStateProperty.all( - RoundedRectangleBorder( - borderRadius: BorderRadius.circular(8), - side: BorderSide( - color: Constant.pcBtnBackgroundColor, + Text( + 'Tanggal Akhir', + style: Constant.body1(context: context).copyWith( + fontWeight: FontWeight.w600, color: Constant.textBlack), + ), + SizedBox( + height: Constant.getActualYPhone(context: context, y: 10), + ), + // Tanggal Akhir + Row( + children: [ + Expanded( + child: TextField( + controller: ctrlTglAkhir, + decoration: InputDecoration( + hintStyle: + Constant.body2_400(context: context).copyWith( + color: Colors.orange, ), + labelStyle: + Constant.body2_400(context: context).copyWith( + color: Colors.orange, + ), + border: OutlineInputBorder( + borderSide: BorderSide( + color: Colors.orange, + width: 1, + ), + ), + focusedBorder: OutlineInputBorder( + borderSide: BorderSide( + color: Colors.orange, + width: 1, + ), + ), + // labelText: "Tanggal Awal", + hintText: 'Tanggal Akhir', + // suffixIcon: isLoadingFilterScope.value + // ? SizedBox( + // width: Constant.getActualXPhone( + // context: context, + // x: 4, + // ), + // height: Constant.getActualYPhone( + // context: context, + // y: 4, + // ), + // child: CircularProgressIndicator( + // color: Constant.textRed, + // ), + // ) + // : Icon( + // Icons.calendar_month_sharp, + // color: Constant.colorIconDate, + // ), ), + onTap: () async { + final selectedDateAkhir = await showDatePicker( + // locale: const Locale("en-CA"), + // locale: , + context: context, + initialEntryMode: DatePickerEntryMode.calendarOnly, + firstDate: DateTime(2000), + lastDate: DateTime(2100), + + initialDate: (ctrlTglAkhir.text.isEmpty) + ? DateTime.now() + : tglAkhir.value, + ); + + if (selectedDateAkhir != null) { + String formattedDate = DateFormat('dd-MM-yyyy') + .format(selectedDateAkhir); + // ctrlTglAkhir.text = + // selectedDateAkhir.toString().split(' ')[0]; + ctrlTglAkhir.text = formattedDate; + tglAkhir.value = selectedDateAkhir; + tglAkhirTmp.value = selectedDateAkhir.toString(); + } + + if (selectedDateAkhir == null) { + print('cancel button'); + return; + } + }, ), - shadowColor: - MaterialStateProperty.all(Color(0xffff48423d)), - elevation: MaterialStateProperty.all(4.0), ), - child: Row( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Container( - width: - Constant.getActualXPhone(context: context, x: 16), - height: - Constant.getActualYPhone(context: context, y: 16), - // decoration: BoxDecoration(color: Colors.grey), - child: Image.asset( - "images/logo_pdf.png", - fit: BoxFit.fill, - // scale: 1, + ], + ), + + Spacer(), + + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + ElevatedButton( + style: ButtonStyle( + backgroundColor: MaterialStateColor.resolveWith( + (states) => Colors.white), + // side: MaterialStateBorderSide.resolveWith( + // (states) => BorderSide(color: Colors.green), + // ), + + // backgroundColor: MaterialStateColor.resolveWith( + // (st) => Constant.pcBtnBackgroundColor), + shape: + MaterialStateProperty.all( + RoundedRectangleBorder( + borderRadius: BorderRadius.circular(8), + side: BorderSide( + color: Colors.green, + ), ), ), - SizedBox( - height: - Constant.getActualXPhone(context: context, x: 8), - ), - Text( - 'Download Report (PDF)', - style: Constant.body1(context: context).copyWith( + shadowColor: + MaterialStateProperty.all(Color(0xffff48423d)), + elevation: MaterialStateProperty.all(4.0), + ), + child: Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Container( + width: Constant.getActualXPhone( + context: context, x: 16), + height: Constant.getActualYPhone( + context: context, y: 16), + // decoration: BoxDecoration(color: Colors.grey), + child: Image.asset( + "images/logo_excel.png", + fit: BoxFit.fill, + // scale: 1, + ), + ), + SizedBox( + height: Constant.getActualXPhone( + context: context, x: 8), + ), + Text( + 'Download Report (xls) ', + style: Constant.body1(context: context).copyWith( fontWeight: FontWeight.w600, - color: Constant.white), - ), - ], + color: Colors.green, + ), + ), + ], + ), + onPressed: () async { + M_CompanyID = await getCompanyID(); + if(M_CompanyID == "0"){ + SanckbarWidget(context, 'Invalid Company', snackbarType.error); + return; + } + // Awal + DateTime parsedDateAwal = + DateFormat('dd-MM-yyyy').parse( + ctrlTglAwal.value.text.toString(), + ); + String formattedDateAwal = + DateFormat('yyyy-MM-dd').format(parsedDateAwal); + + // Akhir + DateTime parsedDateAkhir = + DateFormat('dd-MM-yyyy').parse( + ctrlTglAwal.value.text.toString(), + ); + String formattedDateAkhir = + DateFormat('yyyy-MM-dd').format(parsedDateAkhir); + + String url = + "https://${Constant.baseUrlDevoneReport}/birt/run?__report=report/one/pettycash/rpt_r_pt_001.rptdesign&__format=xls&PStartDate=$formattedDateAwal&PEndDate=$formattedDateAkhir&PCompanyID=$M_CompanyID&username=adminsas%20"; + if (!await launchUrl(Uri.parse(url))) { + // throw Exception('Could not launch $url'); + SanckbarWidget(context, 'Could not launch $url', + snackbarType.error); + } + // https://devone.aplikasi.web.id/birt/run?__report=report/one/pettycash/rpt_r_pt_001.rptdesign&__format=pdf&PStartDate=2023-11-01&PEndDate=2023-12-30&PCompanyID=0&username=adminsas%20&tm=1701327096267 + }, ), - onPressed: () async { - // String url = - // "https://pub.dev/packages?q=url+launcher"; - // if (!await launchUrl(Uri.parse(url))) { - // // throw Exception('Could not launch $url'); - // SanckbarWidget(context, 'Could not launch $url', - // snackbarType.error); - // } - }, - ), + + // PDF + ElevatedButton( + style: ButtonStyle( + backgroundColor: MaterialStateColor.resolveWith( + (st) => Constant.pcBtnBackgroundColor), + shape: + MaterialStateProperty.all( + RoundedRectangleBorder( + borderRadius: BorderRadius.circular(8), + side: BorderSide( + color: Constant.pcBtnBackgroundColor, + ), + ), + ), + shadowColor: + MaterialStateProperty.all(Color(0xffff48423d)), + elevation: MaterialStateProperty.all(4.0), + ), + child: Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Container( + width: Constant.getActualXPhone( + context: context, x: 16), + height: Constant.getActualYPhone( + context: context, y: 16), + // decoration: BoxDecoration(color: Colors.grey), + child: Image.asset( + "images/logo_pdf.png", + fit: BoxFit.fill, + // scale: 1, + ), + ), + SizedBox( + height: Constant.getActualXPhone( + context: context, x: 8), + ), + Text( + 'Download Report (PDF)', + style: Constant.body1(context: context).copyWith( + fontWeight: FontWeight.w600, + color: Constant.white), + ), + ], + ), + onPressed: () async { + M_CompanyID = await getCompanyID(); + if(M_CompanyID == "0"){ + SanckbarWidget(context, 'Invalid Company', snackbarType.error); + return; + } + // Awal + DateTime parsedDateAwal = + DateFormat('dd-MM-yyyy').parse( + ctrlTglAwal.value.text.toString(), + ); + String formattedDateAwal = + DateFormat('yyyy-MM-dd').format(parsedDateAwal); + + // Akhir + DateTime parsedDateAkhir = + DateFormat('dd-MM-yyyy').parse( + ctrlTglAwal.value.text.toString(), + ); + String formattedDateAkhir = + DateFormat('yyyy-MM-dd').format(parsedDateAkhir); + + String url = + "https://${Constant.baseUrlDevoneReport}/birt/run?__report=report/one/pettycash/rpt_r_pt_001.rptdesign&__format=pdf&PStartDate=$formattedDateAwal&PEndDate=$formattedDateAkhir&PCompanyID=$M_CompanyID&username=adminsas%20"; + if (!await launchUrl(Uri.parse(url))) { + // throw Exception('Could not launch $url'); + SanckbarWidget(context, 'Could not launch $url', + snackbarType.error); + } + }, + ), + ], ), ], ), diff --git a/app_petty_cash/lib/screen/transaksi/history_transaksi_screen.dart b/app_petty_cash/lib/screen/transaksi/history_transaksi_screen.dart new file mode 100644 index 0000000..26c109f --- /dev/null +++ b/app_petty_cash/lib/screen/transaksi/history_transaksi_screen.dart @@ -0,0 +1,91 @@ +import 'package:flutter/material.dart'; +import 'package:hooks_riverpod/hooks_riverpod.dart'; + +import '../../app/constant.dart'; +import '../../widget/custom_drawer.dart'; + +class HistoryTransaksiScreen extends HookConsumerWidget { + const HistoryTransaksiScreen({super.key}); + + @override + Widget build(BuildContext context, WidgetRef ref) { + return Padding( + padding: EdgeInsets.only( + top: Constant.getActualYPhone(context: context, y: 30), + ), + child: Scaffold( + appBar: AppBar( + title: Text( + 'History Transaksi', + style: TextStyle(color: Constant.textWhite), + ), + backgroundColor: Constant.pcBtnBackgroundColor, + iconTheme: IconThemeData( + color: Constant.textWhite, + ), + ), + drawer: CustomDrawer(), + body: SafeArea( + child: SingleChildScrollView( + child: Padding( + padding: EdgeInsets.all(20), + child: Container( + height: MediaQuery.of(context).size.height - 10, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Card( + margin: EdgeInsets.all(16.0), + child: Padding( + padding: const EdgeInsets.all(16.0), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text('Tipe Catatan: DEBIT'), + SizedBox(height: 8.0), + Text('Tanggal: 15-12-2023'), + SizedBox(height: 8.0), + Text('Nominal: 100.000'), + SizedBox(height: 8.0), + Text('Kategori: Jumat Sehat'), + SizedBox(height: 8.0), + Chip( + label: Text('Verify'), + backgroundColor: Constant.green_600, + labelStyle: TextStyle(color: Colors.white), + ), + SizedBox(height: 16.0), + Row( + mainAxisAlignment: MainAxisAlignment.end, + children: [ + ElevatedButton( + onPressed: () { + // Handle delete button tap + }, + child: Text( + 'Delete', + style: TextStyle( + color: Constant.textWhite + ), + ), + style: ElevatedButton.styleFrom( + backgroundColor: Colors + .red, // Ganti dengan warna delete button yang diinginkan + ), + ), + ], + ), + ], + ), + ), + ), + ], + ), + ), + ), + ), + ), + ), + ); + } +} diff --git a/app_petty_cash/lib/screen/transaksi/transaksi_screen.dart b/app_petty_cash/lib/screen/transaksi/transaksi_screen.dart index 53e1cb6..be1089b 100644 --- a/app_petty_cash/lib/screen/transaksi/transaksi_screen.dart +++ b/app_petty_cash/lib/screen/transaksi/transaksi_screen.dart @@ -156,6 +156,9 @@ class TransaksiScreen extends HookConsumerWidget { // Navigator.popAndPushNamed(context, loginRoute); return; } + + ctrlCompanyName.text = + ref.read(currentUserProvider)?.model.M_CompanyName ?? ""; }); return () {}; }, []); @@ -200,19 +203,22 @@ class TransaksiScreen extends HookConsumerWidget { child: SingleChildScrollView( child: Padding( padding: EdgeInsets.all(20), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - // Company Name - Text( - 'Company Name', - style: Constant.body1(context: context).copyWith( - fontWeight: FontWeight.w600, color: Constant.textBlack), - ), - SizedBox( - height: Constant.getActualYPhone(context: context, y: 10), - ), - TextField( + child: Container( + height: MediaQuery.of(context).size.height - 10, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + // Company Name + Text( + 'Company Name', + style: Constant.body1(context: context).copyWith( + fontWeight: FontWeight.w600, + color: Constant.textBlack), + ), + SizedBox( + height: Constant.getActualYPhone(context: context, y: 10), + ), + TextField( controller: ctrlCompanyName, readOnly: true, decoration: InputDecoration( @@ -240,325 +246,11 @@ class TransaksiScreen extends HookConsumerWidget { hintText: 'Company Name', ), ), - SizedBox( - height: Constant.getActualYPhone(context: context, y: 20), - ), - Text( - 'Tanggal Transaksi', - style: Constant.body1(context: context).copyWith( - fontWeight: FontWeight.w600, color: Constant.textBlack), - ), - SizedBox( - height: Constant.getActualYPhone(context: context, y: 10), - ), - // Tanggal Transaksi - Row( - children: [ - Expanded( - child: TextField( - controller: ctrlTglAwal, - decoration: InputDecoration( - hintStyle: - Constant.body2_400(context: context).copyWith( - color: Constant.textGreyv2, - ), - labelStyle: - Constant.body2_400(context: context).copyWith( - color: Constant.textGreyv2, - ), - border: OutlineInputBorder( - borderSide: BorderSide( - color: Colors.orange, - width: 1, - ), - ), - focusedBorder: OutlineInputBorder( - borderSide: BorderSide( - color: Constant.textGreyv2, - width: 1, - ), - ), - // labelText: "Tanggal Awal", - hintText: 'Tanggal Transaksi', - // suffixIcon: isLoadingFilterScope.value - // ? SizedBox( - // width: Constant.getActualXPhone( - // context: context, - // x: 4, - // ), - // height: Constant.getActualYPhone( - // context: context, - // y: 4, - // ), - // child: CircularProgressIndicator( - // color: Constant.textRed, - // ), - // ) - // : Icon( - // Icons.calendar_month_sharp, - // color: Constant.colorIconDate, - // ), - ), - onTap: () async { - final selectedDateAwal = await showDatePicker( - // locale: const Locale("en-CA"), - // locale: , - context: context, - initialEntryMode: - DatePickerEntryMode.calendarOnly, - firstDate: DateTime(2000), - lastDate: DateTime(2100), - - initialDate: (ctrlTglAwal.text.isEmpty) - ? DateTime.now() - : tglAwal.value, - ); - - if (selectedDateAwal != null) { - String formattedDate = DateFormat('dd-MM-yyyy') - .format(selectedDateAwal); - // ctrlTglAwal.text = - // selectedDateAwal.toString().split(' ')[0]; - ctrlTglAwal.text = formattedDate; - tglAwal.value = selectedDateAwal; - tglAwalTmp.value = selectedDateAwal.toString(); - } - - if (selectedDateAwal == null) { - print('cancel button'); - return; - } - }, - ), - ), - ], - ), - - SizedBox( - height: Constant.getActualYPhone(context: context, y: 20), - ), - - // tipe transaksi - Text( - 'Tipe Transaksi', - style: Constant.body1(context: context).copyWith( - fontWeight: FontWeight.w600, color: Constant.textBlack), - ), - SizedBox( - height: Constant.getActualYPhone(context: context, y: 10), - ), - SizedBox( - width: Constant.getActualXPhone(context: context, x: 340), - height: Constant.getActualYPhone(context: context, y: 36), - child: (listTypeLoading.value) - ? SizedBox( - width: Constant.getActualXPhone( - context: context, x: 24), - height: Constant.getActualYPhone( - context: context, y: 32), - child: Center( - child: CircularProgressIndicator(), - ), - ) - : Row( - mainAxisAlignment: MainAxisAlignment.start, - children: [ - if (listTypeData.value.isEmpty) - Text('Radio Button Empty') - else - for (var i = 0; - i < listTypeData.value.length; - i++) - Padding( - padding: const EdgeInsets.only(right: 20), - child: Row( - children: [ - Radio( - activeColor: - Constant.pcBtnBackgroundColor, - value: listTypeData.value[i], - groupValue: - selectedListTypeData.value, - onChanged: (ListType? index) { - if (isMounted()) { - selectedListTypeData.value = - index!; - } else { - return; - } - }, - ), - Text( - listTypeData.value[i].typename ?? "", - style: - Constant.body1(context: context) - .copyWith( - color: Constant.textBlack, - fontWeight: FontWeight.w400, - ), - ), - ], - ), - ), - ], - ), - ), - - SizedBox( - height: Constant.getActualYPhone(context: context, y: 20), - ), - - // Kategori - if (selectedListTypeData.value.typeid == "KREDIT") ...[ - Text( - 'Kategori', - style: Constant.body1(context: context).copyWith( - fontWeight: FontWeight.w600, - color: Constant.textBlack, - ), - ), - SizedBox( - height: Constant.getActualYPhone(context: context, y: 10), - ), - // Dropdown kategori - (listCategoryLoading.value) - ? SizedBox( - width: Constant.getActualXPhone( - context: context, x: 24), - height: Constant.getActualYPhone( - context: context, y: 32), - child: Center( - child: CircularProgressIndicator(), - ), - ) - : SizedBox( - width: Constant.getActualXPhone( - context: context, x: 390), - child: DropdownButtonHideUnderline( - child: DropdownButton2( - isExpanded: true, - hint: Row( - children: [ - Expanded( - child: Text( - 'Select Item', - style: Constant.body1(context: context) - .copyWith( - fontWeight: FontWeight.w600, - color: Constant.textBlack), - overflow: TextOverflow.ellipsis, - ), - ), - ], - ), - items: listCategoryData.value - .map((ListCategory option) { - return DropdownMenuItem( - value: option, - child: Text( - option.categoryname ?? "", - style: Constant.body1(context: context) - .copyWith( - color: Constant.textBlack, - fontWeight: FontWeight.w600), - ), - ); - }).toList(), - value: selectedListCategory.value, - onChanged: (ListCategory? newValue) { - // if (newValue) { - selectedListCategory.value = newValue!; - print(selectedListCategory.value.categoryid); - // } - }, - buttonStyleData: ButtonStyleData( - height: Constant.getActualY( - context: context, y: 56), - width: Constant.getActualX( - context: context, x: 320), - padding: EdgeInsets.only( - left: Constant.getActualX( - context: context, x: 10), - right: Constant.getActualX( - context: context, x: 10), - ), - decoration: BoxDecoration( - color: Constant.white, - border: Border.all( - color: Constant.textBlack, width: 1), - borderRadius: BorderRadius.circular(8), - ), - elevation: 2, - ), - iconStyleData: IconStyleData( - icon: Icon( - Icons.keyboard_arrow_down_outlined, - ), - iconSize: 24, - iconEnabledColor: Constant.textBlack, - iconDisabledColor: Colors.grey, - ), - dropdownStyleData: DropdownStyleData( - maxHeight: Constant.getActualY( - context: context, y: 200), - // width: Constant.getActualX(context: context, x: 320), - padding: EdgeInsets.only( - top: Constant.getActualY( - context: context, y: 10), - left: Constant.getActualX( - context: context, x: 10), - right: Constant.getActualX( - context: context, x: 10), - bottom: Constant.getActualY( - context: context, y: 10), - ), - decoration: BoxDecoration( - color: Constant.white, - borderRadius: BorderRadius.circular(8), - boxShadow: [ - BoxShadow( - color: Colors.grey, - blurRadius: 20.0, - spreadRadius: 2.0, - offset: Offset(0.0, 0.0), - ), - ], - ), - elevation: 8, - offset: const Offset(0, -10), - scrollbarTheme: ScrollbarThemeData( - radius: const Radius.circular(40), - thickness: - MaterialStateProperty.all(6), - thumbVisibility: - MaterialStateProperty.all(true), - ), - ), - menuItemStyleData: MenuItemStyleData( - height: Constant.getActualY( - context: context, y: 56), - padding: EdgeInsets.only( - top: Constant.getActualY( - context: context, y: 10), - left: Constant.getActualX( - context: context, x: 10), - right: Constant.getActualX( - context: context, x: 10), - ), - ), - ), - ), - ), - SizedBox( height: Constant.getActualYPhone(context: context, y: 20), ), - ], - - // Nama Pengirim - if (selectedListTypeData.value.typeid == "DEBIT") ...[ Text( - 'Nama Pengirim', + 'Tanggal Transaksi', style: Constant.body1(context: context).copyWith( fontWeight: FontWeight.w600, color: Constant.textBlack), @@ -566,8 +258,373 @@ class TransaksiScreen extends HookConsumerWidget { SizedBox( height: Constant.getActualYPhone(context: context, y: 10), ), + // Tanggal Transaksi + Row( + children: [ + Expanded( + child: TextField( + controller: ctrlTglAwal, + decoration: InputDecoration( + hintStyle: + Constant.body2_400(context: context).copyWith( + color: Constant.textGreyv2, + ), + labelStyle: + Constant.body2_400(context: context).copyWith( + color: Constant.textGreyv2, + ), + border: OutlineInputBorder( + borderSide: BorderSide( + color: Colors.orange, + width: 1, + ), + ), + focusedBorder: OutlineInputBorder( + borderSide: BorderSide( + color: Constant.textGreyv2, + width: 1, + ), + ), + // labelText: "Tanggal Awal", + hintText: 'Tanggal Transaksi', + // suffixIcon: isLoadingFilterScope.value + // ? SizedBox( + // width: Constant.getActualXPhone( + // context: context, + // x: 4, + // ), + // height: Constant.getActualYPhone( + // context: context, + // y: 4, + // ), + // child: CircularProgressIndicator( + // color: Constant.textRed, + // ), + // ) + // : Icon( + // Icons.calendar_month_sharp, + // color: Constant.colorIconDate, + // ), + ), + onTap: () async { + final selectedDateAwal = await showDatePicker( + // locale: const Locale("en-CA"), + // locale: , + context: context, + initialEntryMode: + DatePickerEntryMode.calendarOnly, + firstDate: DateTime(2000), + lastDate: DateTime(2100), + + initialDate: (ctrlTglAwal.text.isEmpty) + ? DateTime.now() + : tglAwal.value, + ); + + if (selectedDateAwal != null) { + String formattedDate = DateFormat('dd-MM-yyyy') + .format(selectedDateAwal); + // ctrlTglAwal.text = + // selectedDateAwal.toString().split(' ')[0]; + ctrlTglAwal.text = formattedDate; + tglAwal.value = selectedDateAwal; + tglAwalTmp.value = selectedDateAwal.toString(); + } + + if (selectedDateAwal == null) { + print('cancel button'); + return; + } + }, + ), + ), + ], + ), + + SizedBox( + height: Constant.getActualYPhone(context: context, y: 20), + ), + + // tipe transaksi + Text( + 'Tipe Transaksi', + style: Constant.body1(context: context).copyWith( + fontWeight: FontWeight.w600, + color: Constant.textBlack), + ), + SizedBox( + height: Constant.getActualYPhone(context: context, y: 10), + ), + SizedBox( + width: Constant.getActualXPhone(context: context, x: 340), + height: Constant.getActualYPhone(context: context, y: 36), + child: (listTypeLoading.value) + ? SizedBox( + width: Constant.getActualXPhone( + context: context, x: 24), + height: Constant.getActualYPhone( + context: context, y: 32), + child: Center( + child: CircularProgressIndicator(), + ), + ) + : Row( + mainAxisAlignment: MainAxisAlignment.start, + children: [ + if (listTypeData.value.isEmpty) + Text('Radio Button Empty') + else + for (var i = 0; + i < listTypeData.value.length; + i++) + Padding( + padding: const EdgeInsets.only(right: 20), + child: Row( + children: [ + Radio( + activeColor: + Constant.pcBtnBackgroundColor, + value: listTypeData.value[i], + groupValue: + selectedListTypeData.value, + onChanged: (ListType? index) { + if (isMounted()) { + selectedListTypeData.value = + index!; + } else { + return; + } + }, + ), + Text( + listTypeData.value[i].typename ?? + "", + style: + Constant.body1(context: context) + .copyWith( + color: Constant.textBlack, + fontWeight: FontWeight.w400, + ), + ), + ], + ), + ), + ], + ), + ), + + SizedBox( + height: Constant.getActualYPhone(context: context, y: 20), + ), + + // Kategori + if (selectedListTypeData.value.typeid == "DEBIT") ...[ + Text( + 'Kategori', + style: Constant.body1(context: context).copyWith( + fontWeight: FontWeight.w600, + color: Constant.textBlack, + ), + ), + SizedBox( + height: + Constant.getActualYPhone(context: context, y: 10), + ), + // Dropdown kategori + (listCategoryLoading.value) + ? SizedBox( + width: Constant.getActualXPhone( + context: context, x: 24), + height: Constant.getActualYPhone( + context: context, y: 32), + child: Center( + child: CircularProgressIndicator(), + ), + ) + : SizedBox( + width: Constant.getActualXPhone( + context: context, x: 390), + child: DropdownButtonHideUnderline( + child: DropdownButton2( + isExpanded: true, + hint: Row( + children: [ + Expanded( + child: Text( + 'Select Item', + style: Constant.body1( + context: context) + .copyWith( + fontWeight: FontWeight.w600, + color: Constant.textBlack), + overflow: TextOverflow.ellipsis, + ), + ), + ], + ), + items: listCategoryData.value + .map((ListCategory option) { + return DropdownMenuItem( + value: option, + child: Text( + option.categoryname ?? "", + style: Constant.body1(context: context) + .copyWith( + color: Constant.textBlack, + fontWeight: FontWeight.w600), + ), + ); + }).toList(), + value: selectedListCategory.value, + onChanged: (ListCategory? newValue) { + // if (newValue) { + selectedListCategory.value = newValue!; + print( + selectedListCategory.value.categoryid); + // } + }, + buttonStyleData: ButtonStyleData( + height: Constant.getActualY( + context: context, y: 56), + width: Constant.getActualX( + context: context, x: 320), + padding: EdgeInsets.only( + left: Constant.getActualX( + context: context, x: 10), + right: Constant.getActualX( + context: context, x: 10), + ), + decoration: BoxDecoration( + color: Constant.white, + border: Border.all( + color: Constant.textBlack, width: 1), + borderRadius: BorderRadius.circular(8), + ), + elevation: 2, + ), + iconStyleData: IconStyleData( + icon: Icon( + Icons.keyboard_arrow_down_outlined, + ), + iconSize: 24, + iconEnabledColor: Constant.textBlack, + iconDisabledColor: Colors.grey, + ), + dropdownStyleData: DropdownStyleData( + maxHeight: Constant.getActualY( + context: context, y: 200), + // width: Constant.getActualX(context: context, x: 320), + padding: EdgeInsets.only( + top: Constant.getActualY( + context: context, y: 10), + left: Constant.getActualX( + context: context, x: 10), + right: Constant.getActualX( + context: context, x: 10), + bottom: Constant.getActualY( + context: context, y: 10), + ), + decoration: BoxDecoration( + color: Constant.white, + borderRadius: BorderRadius.circular(8), + boxShadow: [ + BoxShadow( + color: Colors.grey, + blurRadius: 20.0, + spreadRadius: 2.0, + offset: Offset(0.0, 0.0), + ), + ], + ), + elevation: 8, + offset: const Offset(0, -10), + scrollbarTheme: ScrollbarThemeData( + radius: const Radius.circular(40), + thickness: + MaterialStateProperty.all(6), + thumbVisibility: + MaterialStateProperty.all(true), + ), + ), + menuItemStyleData: MenuItemStyleData( + height: Constant.getActualY( + context: context, y: 56), + padding: EdgeInsets.only( + top: Constant.getActualY( + context: context, y: 10), + left: Constant.getActualX( + context: context, x: 10), + right: Constant.getActualX( + context: context, x: 10), + ), + ), + ), + ), + ), + + SizedBox( + height: + Constant.getActualYPhone(context: context, y: 20), + ), + ], + + // Nama Pengirim + if (selectedListTypeData.value.typeid == "KREDIT") ...[ + Text( + 'Nama Pengirim', + style: Constant.body1(context: context).copyWith( + fontWeight: FontWeight.w600, + color: Constant.textBlack), + ), + SizedBox( + height: + Constant.getActualYPhone(context: context, y: 10), + ), + TextField( + controller: ctrlNamaPengirim, + decoration: InputDecoration( + hintStyle: + Constant.body2_400(context: context).copyWith( + color: Constant.textGreyv2, + ), + labelStyle: + Constant.body2_400(context: context).copyWith( + color: Constant.textGreyv2, + ), + border: OutlineInputBorder( + borderSide: BorderSide( + color: Colors.orange, + width: 1, + ), + ), + focusedBorder: OutlineInputBorder( + borderSide: BorderSide( + color: Constant.textGreyv2, + width: 1, + ), + ), + labelText: "Nama Pengirim", + hintText: 'Nama Pengirim', + ), + ), + ], + SizedBox( + height: Constant.getActualYPhone(context: context, y: 20), + ), + + // jumlah + Text( + 'Jumlah', + style: Constant.body1(context: context).copyWith( + fontWeight: FontWeight.w600, + color: Constant.textBlack), + ), + SizedBox( + height: Constant.getActualYPhone(context: context, y: 20), + ), TextField( - controller: ctrlNamaPengirim, + controller: ctrlJumlah, + keyboardType: TextInputType.number, decoration: InputDecoration( hintStyle: Constant.body2_400(context: context).copyWith( @@ -589,217 +646,272 @@ class TransaksiScreen extends HookConsumerWidget { width: 1, ), ), - labelText: "Nama Pengirim", - hintText: 'Nama Pengirim', + labelText: "Jumlah", + hintText: 'Jumlah', ), ), - ], - SizedBox( - height: Constant.getActualYPhone(context: context, y: 20), - ), - // jumlah - Text( - 'Jumlah', - style: Constant.body1(context: context).copyWith( - fontWeight: FontWeight.w600, color: Constant.textBlack), - ), - SizedBox( - height: Constant.getActualYPhone(context: context, y: 20), - ), - TextField( - controller: ctrlJumlah, - keyboardType: TextInputType.number, - decoration: InputDecoration( - hintStyle: Constant.body2_400(context: context).copyWith( - color: Constant.textGreyv2, - ), - labelStyle: Constant.body2_400(context: context).copyWith( - color: Constant.textGreyv2, - ), - border: OutlineInputBorder( - borderSide: BorderSide( - color: Colors.orange, - width: 1, - ), - ), - focusedBorder: OutlineInputBorder( - borderSide: BorderSide( + SizedBox( + height: Constant.getActualYPhone(context: context, y: 20), + ), + + // catatan + Text( + 'Catatan', + style: Constant.body1(context: context).copyWith( + fontWeight: FontWeight.w600, + color: Constant.textBlack), + ), + SizedBox( + height: Constant.getActualYPhone(context: context, y: 20), + ), + + TextField( + controller: ctrlCatatan, + maxLines: 4, + decoration: InputDecoration( + hintStyle: + Constant.body2_400(context: context).copyWith( color: Constant.textGreyv2, - width: 1, ), - ), - labelText: "Jumlah", - hintText: 'Jumlah', - ), - ), - - SizedBox( - height: Constant.getActualYPhone(context: context, y: 20), - ), - - // catatan - Text( - 'Catatan', - style: Constant.body1(context: context).copyWith( - fontWeight: FontWeight.w600, color: Constant.textBlack), - ), - SizedBox( - height: Constant.getActualYPhone(context: context, y: 20), - ), - - TextField( - controller: ctrlCatatan, - maxLines: 4, - decoration: InputDecoration( - hintStyle: Constant.body2_400(context: context).copyWith( - color: Constant.textGreyv2, - ), - labelStyle: Constant.body2_400(context: context).copyWith( - color: Constant.textGreyv2, - ), - border: OutlineInputBorder( - borderSide: BorderSide( - color: Colors.orange, - width: 1, - ), - ), - focusedBorder: OutlineInputBorder( - borderSide: BorderSide( + labelStyle: + Constant.body2_400(context: context).copyWith( color: Constant.textGreyv2, - width: 1, ), - ), - labelText: "Catatan", - hintText: 'Catatan', - ), - ), - - SizedBox( - height: Constant.getActualYPhone(context: context, y: 20), - ), - - // Upload File - Container( - width: Constant.getActualXPhone(context: context, x: 390), - height: Constant.getActualYPhone(context: context, y: 83), - decoration: BoxDecoration(color: Constant.bgUploadFile), - child: Column( - mainAxisAlignment: MainAxisAlignment.center, - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - Icon( - Icons.upload_outlined, - color: Constant.pcBtnBackgroundColor, + border: OutlineInputBorder( + borderSide: BorderSide( + color: Colors.orange, + width: 1, + ), ), - Text( - 'Upload File', - style: Constant.body1(context: context).copyWith( - fontWeight: FontWeight.w600, - color: Constant.pcBtnBackgroundColor), - ) - ], - ), - ), - ], - ), - ), - ), - ), - bottomNavigationBar: Padding( - padding: EdgeInsets.only( - right: Constant.getActualXPhone(context: context, x: 27), - left: Constant.getActualXPhone(context: context, x: 27), - bottom: Constant.getActualYPhone(context: context, y: 32), - top: Constant.getActualYPhone(context: context, y: 10), - ), - child: BottomAppBar( - elevation: 2.0, - child: Container( - width: Constant.getActualXPhone(context: context, x: 336), - height: Constant.getActualYPhone(context: context, y: 42), - child: ElevatedButton( - style: ButtonStyle( - backgroundColor: MaterialStateColor.resolveWith( - (st) => Constant.pcBtnBackgroundColor), - shape: MaterialStateProperty.all( - RoundedRectangleBorder( - borderRadius: BorderRadius.circular(8), - side: BorderSide( - color: Constant.pcBtnBackgroundColor, + focusedBorder: OutlineInputBorder( + borderSide: BorderSide( + color: Constant.textGreyv2, + width: 1, + ), + ), + labelText: "Catatan", + hintText: 'Catatan', ), ), - ), - shadowColor: MaterialStateProperty.all(Color(0xffff48423d)), - elevation: MaterialStateProperty.all(4.0), - ), - child: Stack( - children: [ - (transaksiIsLoading.value) - ? SizedBox( - width: Constant.getActualXPhone( - context: context, x: 24), - height: Constant.getActualYPhone( - context: context, y: 32), - child: CircularProgressIndicator( - color: Colors.white, - ), - ) - : Text( - 'Simpan', + + SizedBox( + height: Constant.getActualYPhone(context: context, y: 20), + ), + + // Upload File + Container( + width: Constant.getActualXPhone(context: context, x: 390), + height: Constant.getActualYPhone(context: context, y: 83), + decoration: BoxDecoration(color: Constant.bgUploadFile), + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + Icon( + Icons.upload_outlined, + color: Constant.pcBtnBackgroundColor, + ), + Text( + 'Upload File', style: Constant.body1(context: context).copyWith( fontWeight: FontWeight.w600, - color: Constant.white), + color: Constant.pcBtnBackgroundColor), + ) + ], + ), + ), + + Spacer(), + + Container( + width: Constant.getActualXPhone(context: context, x: 390), + child: ElevatedButton( + style: ButtonStyle( + backgroundColor: MaterialStateColor.resolveWith( + (st) => Constant.pcBtnBackgroundColor), + shape: + MaterialStateProperty.all( + RoundedRectangleBorder( + borderRadius: BorderRadius.circular(8), + side: BorderSide( + color: Constant.pcBtnBackgroundColor, + ), + ), ), + shadowColor: + MaterialStateProperty.all(Color(0xffff48423d)), + elevation: MaterialStateProperty.all(4.0), + ), + child: Stack( + children: [ + (transaksiIsLoading.value) + ? SizedBox( + width: Constant.getActualXPhone( + context: context, x: 24), + height: Constant.getActualYPhone( + context: context, y: 32), + child: CircularProgressIndicator( + color: Colors.white, + ), + ) + : Text( + 'Simpan', + style: Constant.body1(context: context) + .copyWith( + fontWeight: FontWeight.w600, + color: Constant.white), + ), + ], + ), + onPressed: () { + if (selectedListTypeData.value.typeid.toString() == + "DEBIT") { + ctrlNamaPengirim.text = ""; + // validasi form + } else { + if (selectedListTypeData.value.typeid.toString() == + "KREDIT") { + selectedListCategory.value.categoryid = "0"; + // validasi form + } + } + + DateTime parsedDate = DateFormat('dd-MM-yyyy').parse( + ctrlTglAwal.value.text.toString(), + ); + String formattedDateTransaksi = + DateFormat('yyyy-MM-dd').format(parsedDate); + var param = { + "tgltransaksi": formattedDateTransaksi, + "typeid": + selectedListTypeData.value.typeid.toString(), + "categoryid": + selectedListCategory.value.categoryid.toString(), + "jumlah": ctrlJumlah.value.text.toString(), + "catatan": ctrlCatatan.value.text.toString(), + // "userid": "1", + "userid": userIDLogin, + "namapengirim": + ctrlNamaPengirim.value.text.toString(), + "url": "", + }; + print(param); + ref + .read(insertTransaksiProvider.notifier) + .insertTransaksi( + formattedDateTransaksi, + selectedListTypeData.value.typeid.toString(), + selectedListCategory.value.categoryid.toString(), + ctrlJumlah.value.text.toString(), + ctrlCatatan.value.text.toString(), + // "1", + userIDLogin, + ctrlNamaPengirim.value.text.toString(), + "", + ); + }, + ), + ), ], ), - onPressed: () { - if (selectedListTypeData.value.typeid.toString() == - "DEBIT") { - ctrlNamaPengirim.text = ""; - // validasi form - } else { - if (selectedListTypeData.value.typeid.toString() == - "KREDIT") { - selectedListCategory.value.categoryid = "0"; - // validasi form - } - } - - DateTime parsedDate = DateFormat('dd-MM-yyyy').parse( - ctrlTglAwal.value.text.toString(), - ); - String formattedDateTransaksi = - DateFormat('yyyy-MM-dd').format(parsedDate); - var param = { - "tgltransaksi": formattedDateTransaksi, - "typeid": selectedListTypeData.value.typeid.toString(), - "categoryid": - selectedListCategory.value.categoryid.toString(), - "jumlah": ctrlJumlah.value.text.toString(), - "catatan": ctrlCatatan.value.text.toString(), - // "userid": "1", - "userid": userIDLogin, - "namapengirim": ctrlNamaPengirim.value.text.toString(), - "url": "", - }; - print(param); - ref.read(insertTransaksiProvider.notifier).insertTransaksi( - formattedDateTransaksi, - selectedListTypeData.value.typeid.toString(), - selectedListCategory.value.categoryid.toString(), - ctrlJumlah.value.text.toString(), - ctrlCatatan.value.text.toString(), - // "1", - userIDLogin, - ctrlNamaPengirim.value.text.toString(), - "", - ); - }, ), ), ), ), + // bottomNavigationBar: Padding( + // padding: EdgeInsets.only( + // right: Constant.getActualXPhone(context: context, x: 27), + // left: Constant.getActualXPhone(context: context, x: 27), + // bottom: Constant.getActualYPhone(context: context, y: 32), + // top: Constant.getActualYPhone(context: context, y: 10), + // ), + // child: BottomAppBar( + // elevation: 2.0, + // child: Container( + // width: Constant.getActualXPhone(context: context, x: 336), + // height: Constant.getActualYPhone(context: context, y: 42), + // child: ElevatedButton( + // style: ButtonStyle( + // backgroundColor: MaterialStateColor.resolveWith( + // (st) => Constant.pcBtnBackgroundColor), + // shape: MaterialStateProperty.all( + // RoundedRectangleBorder( + // borderRadius: BorderRadius.circular(8), + // side: BorderSide( + // color: Constant.pcBtnBackgroundColor, + // ), + // ), + // ), + // shadowColor: MaterialStateProperty.all(Color(0xffff48423d)), + // elevation: MaterialStateProperty.all(4.0), + // ), + // child: Stack( + // children: [ + // (transaksiIsLoading.value) + // ? SizedBox( + // width: Constant.getActualXPhone( + // context: context, x: 24), + // height: Constant.getActualYPhone( + // context: context, y: 32), + // child: CircularProgressIndicator( + // color: Colors.white, + // ), + // ) + // : Text( + // 'Simpan', + // style: Constant.body1(context: context).copyWith( + // fontWeight: FontWeight.w600, + // color: Constant.white), + // ), + // ], + // ), + // onPressed: () { + // if (selectedListTypeData.value.typeid.toString() == "DEBIT") { + // ctrlNamaPengirim.text = ""; + // // validasi form + // } else { + // if (selectedListTypeData.value.typeid.toString() == + // "KREDIT") { + // selectedListCategory.value.categoryid = "0"; + // // validasi form + // } + // } + + // DateTime parsedDate = DateFormat('dd-MM-yyyy').parse( + // ctrlTglAwal.value.text.toString(), + // ); + // String formattedDateTransaksi = + // DateFormat('yyyy-MM-dd').format(parsedDate); + // var param = { + // "tgltransaksi": formattedDateTransaksi, + // "typeid": selectedListTypeData.value.typeid.toString(), + // "categoryid": + // selectedListCategory.value.categoryid.toString(), + // "jumlah": ctrlJumlah.value.text.toString(), + // "catatan": ctrlCatatan.value.text.toString(), + // // "userid": "1", + // "userid": userIDLogin, + // "namapengirim": ctrlNamaPengirim.value.text.toString(), + // "url": "", + // }; + // print(param); + // ref.read(insertTransaksiProvider.notifier).insertTransaksi( + // formattedDateTransaksi, + // selectedListTypeData.value.typeid.toString(), + // selectedListCategory.value.categoryid.toString(), + // ctrlJumlah.value.text.toString(), + // ctrlCatatan.value.text.toString(), + // // "1", + // userIDLogin, + // ctrlNamaPengirim.value.text.toString(), + // "", + // ); + // }, + // ), + // ), + // ), + // ), ), ); } diff --git a/app_petty_cash/lib/widget/custom_drawer.dart b/app_petty_cash/lib/widget/custom_drawer.dart index 2c352b6..203a50e 100644 --- a/app_petty_cash/lib/widget/custom_drawer.dart +++ b/app_petty_cash/lib/widget/custom_drawer.dart @@ -70,22 +70,22 @@ class CustomDrawer extends HookConsumerWidget { return Drawer( child: ListView( - padding: EdgeInsets.only( - top: Constant.getActualYPhone(context: context, y: 10), - ), + // padding: EdgeInsets.only( + // top: Constant.getActualYPhone(context: context, y: 10), + // ), children: [ - // DrawerHeader( - // decoration: BoxDecoration( - // color: Colors.blue, - // ), - // child: Text( - // 'Drawer Header', - // style: TextStyle( - // color: Colors.white, - // fontSize: 24, - // ), - // ), - // ), + DrawerHeader( + decoration: BoxDecoration( + color: Colors.blue, + ), + child: Text( + 'Drawer Header', + style: TextStyle( + color: Colors.white, + fontSize: 24, + ), + ), + ), ListTile( title: Text( 'Home', @@ -126,7 +126,7 @@ class CustomDrawer extends HookConsumerWidget { ), ListTile( title: Text( - 'Report', + 'History Transaksi', style: TextStyle( color: (currentMenu == 2) ? Constant.textWhite @@ -137,15 +137,15 @@ class CustomDrawer extends HookConsumerWidget { ? Constant.pcBtnBackgroundColor : Colors.transparent, onTap: () { - // Handle navigation to Transaksi screen + // Handle navigation to User screen Navigator.pop(context); ref.read(currentPageProvider.state).update((state) => 2); - Navigator.pushNamed(context, reportRoute); + Navigator.pushNamed(context, historyTransaksiRoute); }, ), ListTile( title: Text( - 'User', + 'Report', style: TextStyle( color: (currentMenu == 3) ? Constant.textWhite @@ -156,12 +156,50 @@ class CustomDrawer extends HookConsumerWidget { ? Constant.pcBtnBackgroundColor : Colors.transparent, onTap: () { - // Handle navigation to User screen + // Handle navigation to Transaksi screen Navigator.pop(context); ref.read(currentPageProvider.state).update((state) => 3); + Navigator.pushNamed(context, reportRoute); + }, + ), + ListTile( + title: Text( + 'User', + style: TextStyle( + color: (currentMenu == 4) + ? Constant.textWhite + : Constant.textBlack, + ), + ), + tileColor: (currentMenu == 4) + ? Constant.pcBtnBackgroundColor + : Colors.transparent, + onTap: () { + // Handle navigation to User screen + Navigator.pop(context); + ref.read(currentPageProvider.state).update((state) => 4); Navigator.pushNamed(context, userRoute); }, ), + ListTile( + title: Text( + 'Change Company', + style: TextStyle( + color: (currentMenu == 5) + ? Constant.textWhite + : Constant.textBlack, + ), + ), + tileColor: (currentMenu == 5) + ? Constant.pcBtnBackgroundColor + : Colors.transparent, + onTap: () { + // Handle navigation to User screen + Navigator.pop(context); + ref.read(currentPageProvider.state).update((state) => 5); + Navigator.pushNamed(context, changeCompanyRoute); + }, + ), ListTile( title: Text( 'Logout',