diff --git a/app/Http/Controllers/ProfileController.php b/app/Http/Controllers/ProfileController.php index ba5fc11..870af50 100644 --- a/app/Http/Controllers/ProfileController.php +++ b/app/Http/Controllers/ProfileController.php @@ -5,6 +5,11 @@ namespace App\Http\Controllers; use App\Http\Requests\ProfileRequest; use App\Http\Requests\PasswordRequest; use Illuminate\Support\Facades\Hash; +use Illuminate\Http\Request; +use Carbon\Carbon; +use Illuminate\Support\Facades\Http; +use Illuminate\Support\Facades\Session; +use PDF; class ProfileController extends Controller { @@ -52,4 +57,98 @@ class ProfileController extends Controller return back()->withPasswordStatus(__('Password successfully updated.')); } + + public function printSuratWakil($kodcaw, $norujukan) + { + $api_url = config('api.urlujrah'); + $current = Carbon::now(); + $current = new Carbon(); + $t_cetak = $current->toDateString(); + + $tarikh_cetak = date('d-m-Y'); + $check_norujukan = Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.urlujrah') . '/api/checksurat/' . $kodcaw . '/' . $norujukan)->json(); + if ($check_norujukan == $norujukan) { + + //get details gadai && detail customer + + $update_wakil = Http::withOptions(['verify' => config('app.api_verify')])->put(config('api.urlujrah') . '/api/updatewakil/' . $kodcaw . '/' . $norujukan)->json(); + + $gadai = Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.urlujrah') . '/api/gadai/norujukan/' . $norujukan)->json(); + $gadai_details = $gadai[0][0]; + + $noic = $gadai_details['nokp']; + $customer_detail = Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.urlujrah') . '/api/customers/' . $noic)->json(); + + $cawangan = Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.urlujrah') . '/api/cawangan/detail/' . $kodcaw)->json(); + + $cawangan_detail = $cawangan[0]; + + $nosiri = Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.urlujrah') . '/api/nosiri/wakil/' . $kodcaw . '/' . $norujukan)->json(); + + // $pdf=PDF::loadView('print.surat_wakil', compact('customer_detail','current','auth_user','api_url','cawangan_detail')) + // ->setPaper('A4','potrait'); + // return $pdf->download('notislelong_'.'.pdf'); + // dd($gadai_details); + + + // return view('print.surat_wakil', compact('customer_detail', 'current', 'kodcaw', 'api_url', 'cawangan_detail', 'tarikh_cetak', 'gadai_details', 'noic', 'nosiri')); + $pdf = PDF::loadView('print.surat_wakil', compact('customer_detail', 'current', 'kodcaw', 'api_url', 'cawangan_detail', 'tarikh_cetak', 'gadai_details', 'noic', 'nosiri')) + ->setPaper('a4', 'potrait'); + return $pdf->download('Surat Wakil.pdf'); + } else { + + // insert into wakil_surat + + $current_year = substr($current->year, 2, 2); + $current_month = sprintf("%02d", $current->month); + $current_day = sprintf("%02d", $current->day); + + + $surat_wakil = Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.urlujrah') . '/api/wakil/' . $kodcaw . '/' . $t_cetak)->json(); + if ($surat_wakil) { + $new_suratid = $surat_wakil['nosiri'] + 1; + } else { + $new_suratid = 1; + } + + + $new_surat = sprintf("%04d", $new_suratid); + + $no_surat = 'WK' . $current_year . $current_month . $current_day . '-' . $new_surat; + Session::put('norujukan', $norujukan); + Session::put('no_surat', $no_surat); + Session::put('page_reload', true); + $gadai = Http::withOptions(['verify' => config('app.api_verify')])->post(config('api.urlujrah') . '/api/wakil/' . $kodcaw, [ + 'nosiri' => $new_suratid, + 'no_surat' => $no_surat, + 'norujukan' => $norujukan, + 't_cetak' => $t_cetak, + + ]); + + //get details gadai && detail customer + + $gadai = Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.urlujrah') . '/api/gadai/norujukan/' . $norujukan)->json(); + $gadai_details = $gadai[0][0]; + + $noic = $gadai_details['nokp']; + $customer_detail = Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.urlujrah') . '/api/customers/' . $noic)->json(); + + $cawangan = Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.urlujrah') . '/api/cawangan/detail/' . $kodcaw)->json(); + + $cawangan_detail = $cawangan[0]; + + $nosiri = Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.urlujrah') . '/api/nosiri/wakil/' . $kodcaw . '/' . $norujukan)->json(); + + + // $pdf=PDF::loadView('print.surat_wakil', compact('customer_detail','current','auth_user','api_url','cawangan_detail')) + // ->setPaper('A4','potrait'); + // return $pdf->download('notislelong_'.'.pdf'); + + // return view('print.surat_wakil', compact('customer_detail', 'current', 'kodcaw', 'api_url', 'cawangan_detail', 'tarikh_cetak', 'gadai_details', 'noic', 'nosiri')); + $pdf = PDF::loadView('print.surat_wakil', compact('customer_detail', 'current', 'kodcaw', 'api_url', 'cawangan_detail', 'tarikh_cetak', 'gadai_details', 'noic', 'nosiri')) + ->setPaper('a4', 'potrait'); + return $pdf->download('Surat Wakil.pdf'); + } + } } diff --git a/app/Services/MarhunService.php b/app/Services/MarhunService.php index c86ccdb..6a7d99c 100644 --- a/app/Services/MarhunService.php +++ b/app/Services/MarhunService.php @@ -32,7 +32,7 @@ class MarhunService $marhunDetailPipelines = [ fn($x) => $getMarhunDetails($x), fn($x) => $x == null ? [] : $x, - fn($x) => array_map(fn($y) => array_merge([], ...$y), $x), + fn($x) => $x[0], fn($x) => $formatMarhunDetailData($x), ]; diff --git a/config/api.php b/config/api.php index e8ea7a3..a64a030 100644 --- a/config/api.php +++ b/config/api.php @@ -1,4 +1,4 @@ env('API_URL') -]; \ No newline at end of file + 'url' => env('API_URL'), +]; diff --git a/public/img/ARRAHN1.png b/public/img/ARRAHN1.png new file mode 100644 index 0000000..50c0e08 Binary files /dev/null and b/public/img/ARRAHN1.png differ diff --git a/public/img/kopkb.png b/public/img/kopkb.png new file mode 100644 index 0000000..c0ca932 Binary files /dev/null and b/public/img/kopkb.png differ diff --git a/resources/views/includes/partials/table-pembiayaan.blade.php b/resources/views/includes/partials/table-pembiayaan.blade.php index 42aaaab..f998ee3 100644 --- a/resources/views/includes/partials/table-pembiayaan.blade.php +++ b/resources/views/includes/partials/table-pembiayaan.blade.php @@ -8,6 +8,7 @@ T Akhir Keuntungan Cawangan + Surat Wakil @@ -27,6 +28,8 @@ {{ $data->tarikh_akhir }} {{ $data->upah_tawarruq_formatted }} {{ $data->cawangan_name }} + + 🖨️ @endforeach diff --git a/resources/views/modal/marhun.blade.php b/resources/views/modal/marhun.blade.php index e2c6acf..9dfbcef 100644 --- a/resources/views/modal/marhun.blade.php +++ b/resources/views/modal/marhun.blade.php @@ -1,5 +1,7 @@ + +