tambah laporan lelong dlm admin

This commit is contained in:
BTMS2
2025-02-24 13:13:14 +08:00
parent faeee24071
commit 6a21d4afbb
6 changed files with 587 additions and 0 deletions
+79
View File
@@ -1757,5 +1757,84 @@ class AkaunController extends Controller
return view('akaun.laporan_saghilang', compact('hostname','polis','cawangan_detail','mula_date','hingga_date','tarikh_cetak','api_url'));
}
public function cetak_laporanlelong(Request $request)
{
$api_url = $request->hostname;
$auth_user = Auth::user();
$current = Carbon::now();
$tarikh_cetak = $current->toDateString();
$mula_date = $request->datemula ?? '2017-01-01';
$hingga_date = $request->datehingga ?? $current->toDateString();
$lelong = Http::get($request->hostname . 'api/laporan/lelong', [
'kodcaw' => $request->kodcaw,
'tarikh_mula' => $mula_date,
'tarikh_akhir' => $hingga_date
])->json();
// Initialize variables
$bakilelong = 0;
$rugilelong = 0;
// Ensure 'data' key exists before looping
if (isset($lelong['data']) && is_array($lelong['data'])) {
foreach ($lelong['data'] as $key => $item) {
// Check if 'nokp' exists and is not null
$lelong['data'][$key]['nama_cust'] = isset($item['nokp']) && !empty($item['nokp'])
? Http::get($request->hostname . 'api/customers/' . $item['nokp'])->json()['nama'] ?? 'Unknown'
: 'Unknown';
// ✅ Accumulate `bakilelong` and `rugilelong` based on `baki`
if (isset($item['baki'])) {
if ($item['baki'] > 0) {
$bakilelong += $item['baki'];
} else {
$rugilelong += $item['baki'];
}
}
}
}
// Get totals from API response
$total_pinjaman = $lelong['total_pinjaman'] ?? 0;
$total_nilaimarhun = $lelong['total_nilaimarhun'] ?? 0;
$total_keuntungan = $lelong['total_keuntungan'] ?? 0;
$total_onepercent = $lelong['total_onepercent'] ?? 0;
$total_ujrah = $lelong['total_ujrah'] ?? 0;
$total_cajlelong = $lelong['total_cajlelong'] ?? 0;
$total_hargajual = $lelong['total_hargajual'] ?? 0;
$total_baki = $lelong['total_baki'] ?? 0;
$total_hargaasas = $lelong['total_hargaasas'] ?? 0;
// Fetch cawangan details
$cawangan_info = Http::get($request->hostname . '/api/cawangan/'. $request->kodcaw)->json();
$cawangan = Http::get($request->hostname . '/api/cawangan/detail/'. $request->kodcaw)->json();
$cawangan_detail = $cawangan[0];
$hostname = $request->hostname;
if (isset($request->jenis) && $request->jenis == 'pdf') {
$pdf = PDF::loadView('akaun.laporan_lelong', compact(
'total_pinjaman', 'total_nilaimarhun', 'total_keuntungan', 'total_onepercent',
'total_ujrah', 'total_cajlelong', 'total_hargajual', 'total_baki',
'total_hargaasas', 'hostname', 'lelong', 'cawangan_detail',
'tarikh_cetak', 'mula_date', 'hingga_date', 'api_url',
'bakilelong', 'rugilelong'
))->setPaper('a4', 'portrait');
return $pdf->download('laporan_lelong_' . $request->kodcaw . '_' . $mula_date . '_' . $hingga_date . '.pdf');
}
return view('akaun.laporan_lelong', compact(
'total_pinjaman', 'total_nilaimarhun', 'total_keuntungan', 'total_onepercent',
'total_ujrah', 'total_cajlelong', 'total_hargajual', 'total_baki',
'total_hargaasas', 'hostname', 'lelong', 'cawangan_detail',
'tarikh_cetak', 'mula_date', 'hingga_date', 'api_url',
'bakilelong', 'rugilelong'
));
}
}
+5
View File
@@ -180,6 +180,11 @@
<h2 class="mx-auto text-center font-bold text-2xl uppercase">Sag Hilang</h2>
</router-link>
</div>
<div class="bg-white ml-2 shadow border border-solid px-6 py-4 rounded-lg hover:bg-yellow-300 hover:transition-all mb-2 cursor-pointer">
<router-link to="/akaunhome/laporanlelong">
<h2 class="mx-auto text-center font-bold text-2xl uppercase">Laporan Lelong</h2>
</router-link>
</div>
</div>
+128
View File
@@ -0,0 +1,128 @@
<template>
<div class="container">
<div class="flex w-full">
<div class="xl:w-2/3 2xl:w-1/2 p-8 mx-auto">
<div class="bg-yellow-600 text-gray-200 text-lg px-6 py-4 rounded-t-lg">
<router-link to="/akaunhome">
<i class="fas fa-backspace text-white"></i>
</router-link>
<span class="text-center mx-auto text-white font-bold">Laporan Lelong</span>
</div>
<form method="get" id="formringter" :action="Urlredirect()" target="_blank">
<div class="rounded bg-white shadow p-6">
<div class="pb-6">
<div class="flex justify-center mb-4">
<input :value="jenisgenerate" type="hidden" name="jenis" />
<input :value="$kodcaw" name="kodcaw" hidden/>
<input :value="$hostname" name="hostname" hidden/>
<span style="background-color: #F9FAFB" class="text-gray-600 border-2 rounded-l px-4 py-2 whitespace-no-wrap">Mula</span>
<input id="tarikhmula" name="datemula" class="border-2 border-l-0 rounded-r px-4 py-2 w-80r mr-2" type="date" min="2023-01-01" :max="maxDate"/>
<span style="background-color: #F9FAFB" class="text-gray-600 border-2 rounded-l px-4 py-2 whitespace-no-wrap">Hingga</span>
<input id="tarikhhingga" name="datehingga" class="border-2 border-l-0 rounded-r px-4 py-2 w-80r mr-2" type="date" min="2023-01-01" :max="maxDate"/>
</div>
<!-- <select name="sltalasan" v-model.trim="$v.selectedalasan.$model" class="w-full p-2 rounded-md border bg-white border-gray-400 focus:outline-none focus:ring-1 ring-cyan-500 uppercase">
<option value="" selected disabled hidden>Sila Pilih Alasan Anda Anda***</option>
<option v-for="(slt,i) in jenisalasan" :key="i" :value="slt.alasan">{{ slt.alasan }}</option>
<option value="all">Semua Alasan</option>
</select> -->
</div>
<div class="flex justify-end mt-10">
<button @click.prevent="generatepdf" class=" mr-2 border border-yellow-600 text-yellow-600 font-montserrat py-2 px-8 font-medium rounded-xl hover:bg-yellow-600 hover:text-white transition-all duration-300"><i class="fas fa-file-pdf mr-2"></i>PDF</button>
<button @click.prevent="generateview" class="border border-yellow-600 text-yellow-600 font-montserrat py-2 px-8 font-medium rounded-xl hover:bg-yellow-600 hover:text-white transition-all duration-300"><i class="fas fa-eye mr-2"></i>View</button>
</div>
</div>
</form>
</div>
</div>
</div>
</template>
<script>
import {
required,
minLength,
between
} from 'vuelidate/lib/validators'
export default {
data(){
return{
jenisgenerate:'none',
kodcaw:'',
maxDate: null,
yesterday: null,
selectedalasan: '',
jenisalasan: {}
}
},
mounted() {
this.setMaxDate();
},
created() {
this.senaraiAlasan();
},
methods: {
setMaxDate() {
const today = new Date();
today.setDate(today.getDate() - 1);
this.yesterday = today.toISOString().split('T')[0];
this.maxDate = this.yesterday;
},
async generatepdf(){
await this.setJenis('pdf');
Vue.swal({
title: 'Memuatkan...',
allowEscapeKey : false,
allowOutsideClick: false,
showCancelButton: false,
showConfirmButton: false,
timer: 8000,
});
document.getElementById("formringter").submit();
},
async generateview(){
await this.setJenis('view');
Vue.swal({
title: 'Memuatkan...',
allowEscapeKey : false,
allowOutsideClick: false,
showCancelButton: false,
showConfirmButton: false,
timer: 8000,
});
document.getElementById("formringter").submit();
},
Urlredirect: function() {
return window.route('cetak.laporanlelong')
},
setJenis: function(value){
return this.jenisgenerate = value;
},
senaraiAlasan: function () {
this.axios.get(this.$hostname + '/api/lookupalasan').then(response => {
this.jenisalasan = response.data;
});
},
},
validations: {
selectedalasan: {
required
}
}
}
</script>
+2
View File
@@ -60,6 +60,7 @@ import WtdSpecific from './WTD/SelectWTD'
import AuditPage from './Audit/Audit'
import KeuntunganSebenarPage from './Audit/KeuntunganSebenar'
import UpahSimpanPage from './Audit/UpahSimpan'
import LaporanLelong from './Akaun/LaporanLelong.vue'
@@ -103,6 +104,7 @@ export default new VueRouter({
{ path: '/akaunhome/AuditTrail', component: AuditTrail },
{ path: '/akaunhome/imbangdugabackup', component: ImbangDugaBackup },
{ path: '/akaunhome/saghilang', component: SagHilang },
{ path: '/akaunhome/laporanlelong', component: LaporanLelong },
@@ -0,0 +1,372 @@
<style>
#header {
font-family: Arial, Helvetica, sans-serif;
border-collapse: collapse;
width: 100%;
}
#header td, #customers th {
padding:4px;
font-size:10px;
}
#header tr:nth-child(even){background-color: #ffffff;}
#header tr:hover {background-color: #ddd;}
#header th {
padding-top: 12px;
padding-bottom: 12px;
text-align: left;
padding:4px;
color:black;
}
</style>
<style>
#scan {
font-family: Arial, Helvetica, sans-serif;
border-collapse: collapse;
width: 100%;
}
#scan td, #scan th {
padding: 8px;
font-size:11px;
}
#scan tr:nth-child(even){background-color: #ffffff;}
#scan tr:hover {background-color: #ddd;}
#scan th {
padding-top: 12px;
padding-bottom: 12px;
text-align: left;
padding:4px;
color:black;
}
</style>
<style>
#scan {
font-family: Arial, Helvetica, sans-serif;
border-collapse: collapse;
width: 100%;
}
#scan td, #scan th {
border-collapse: collapse;
padding: 8px;
font-size:11px;
}
#scan tr:nth-child(even){background-color: #ffffff;}
#scan tr:hover {background-color: #ddd;}
#scan th {
border-collapse: collapse;
padding-top: 12px;
padding-bottom: 12px;
text-align: left;
padding:4px;
color:black;
}
</style>
<style>
#details {
font-family: Arial, Helvetica, sans-serif;
border-collapse: collapse;
width: 100%;
}
#details td, #details th {
padding: 8px;
font-size:8px;
}
#details tr:nth-child(even){background-color: #ffffff;}
#details tr:hover {background-color: #ddd;}
#details th {
padding-top: 12px;
font-style:bold;
padding-bottom: 12px;
text-align: left;
padding:4px;
color:black;
}
</style>
<style>
#sign {
font-family: Arial, Helvetica, sans-serif;
border-collapse: collapse;
width: 100%;
}
#sign td, #sign th {
padding: 8px;
font-size:11px;
text-align: center;
}
#sign tr:nth-child(even){background-color: #ffffff;}
#sign tr:hover {background-color: #ddd;}
#sign th {
padding-top: 12px;
padding-bottom: 12px;
text-align: left;
padding:4px;
color:black;
}
@media print {
.new-page {
page-break-before: always;
}
}
</style>
<style>
.table-align {
width: 100%; /* Jadikan jadual lebar penuh */
border-collapse: collapse; /* Gabungkan sempadan */
}
.table-align td, .table-align th {
padding: 5px 10px; /* Ruang dalam jadual */
text-align: left; /* Selarikan teks ke kiri */
}
.table-align .total-section {
border-top: 1px solid black; /* Garisan pemisah */
font-weight: bold; /* Jadikan teks tebal */
}
</style>
<style>
footer {
margin-top: auto;
padding: 20px;
text-align: left;
}
footer hr {
margin: 20px 0;
border: 0;
border-top: 1px solid #ddd;
}
footer p {
font-size: 12px;
margin: 5px 0;
}
footer .signature {
margin-bottom: 20px;
font-family: "Trebuchet MS", Arial, Helvetica, sans-serif;
}
</style>
<body>
<table id="header">
<tr>
<td style="font-size:20px;font-weight:bold;">{{ $cawangan_detail['namacaw'] }}</td>
<td></td>
</tr>
</tr>
</table>
<br>
<table id="scan">
<tr>
<th colspan ="5"><b>LAPORAN LELONG</b></th>
<th> </th>
<th> </th>
<th></th>
</tr>
<tr>
<th colspan="5"><b> TARIKH CETAK:</b>
@php
$myDateTime = DateTime::createFromFormat('Y-m-d', $tarikh_cetak);
$formattedweddingdate = $myDateTime->format('d-m-Y');
echo($formattedweddingdate);
@endphp
</th>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<th style="width:20px"> <b>TARIKH:</b></th>
<th>@php
$myDateTime = DateTime::createFromFormat('Y-m-d', $mula_date);
$formattedweddingdate = $myDateTime->format('d-m-Y');
echo($formattedweddingdate);
@endphp</th>
<th style="width:20px"> <b>HINGGA:</b></th>
<th>@php
$myDateTime = DateTime::createFromFormat('Y-m-d', $hingga_date);
$formattedweddingdate = $myDateTime->format('d-m-Y');
echo($formattedweddingdate);
@endphp</th>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
</tr>
</table>
<br>
<table cellspacing="0" cellpadding="5" border="0" width="100%" height="80" align="left" id="scan">
<thead>
<tr>
<th>No</th>
<th align="left">No Rujukan</th>
<th align="left">Penggadai</th>
<th>Nilai Marhun Asal (RM)</th>
<th>Pembiayaan (RM)</th>
<th>Keuntungan (RM)</th>
<th>1% (RM)</th>
<th>Lain-Lain Caj (RM)</th>
<th>Caj Lelong (RM)</th>
<th>Harga Jual (RM)</th>
<th>Baki (RM)</th>
<th>Harga Asas (RM)</th>
<th align="left">Nama Pembeli</th>
</tr>
</thead>
@foreach($lelong['data'] as $sh)
<tr>
<td>{{ $loop->iteration }}</td>
<td style='white-space:nowrap;'>{{ $sh['norujukan'] }}</td>
<td align="left">{{ $sh['nama_cust'] ?? 'Unknown' }}<br>{{ $sh['nokp'] }}</td>
<td align="right">{{ $sh['nilaimarhun']}}</td>
<td align="right">{{ $sh['pinjaman']}}</td>
<td align="right">{{ $sh['bakiupah']}}</td>
<td align="right">{{ $sh['onepercent']}}</td>
<td align="right">{{ $sh['ujrah']}}</td>
<td align="right">{{ $sh['cajlelong']}}</td>
<td align="right">{{ $sh['hargajual']}}</td>
<td align="right">@if($sh['baki'] < 0)
({{ number_format(abs($sh['baki']), 2, '.', ',') }})
@else
{{ number_format($sh['baki'], 2, '.', ',') }}
@endif</td>
<td align="right">{{ $sh['hargaasas']}}</td>
<td align="left">{{ $sh['nama']}}</td>
<!-- <td align="left">{{ $sh['nama']}}<br>{{ $sh['nokppembeli'] }}</td> -->
</tr>
@endforeach
<tr>
<td colspan="3" align="left"><strong>Jumlah Keseluruhan</strong></td>
<td align="right"><strong>{{ number_format($total_nilaimarhun, 2)}}</strong></td>
<td align="right"><strong>{{ number_format($total_pinjaman, 2)}}</strong></td>
<td align="right"><strong>{{ number_format($total_keuntungan, 2)}}</strong></td>
<td align="right"><strong>{{ number_format($total_onepercent, 2)}}</strong></td>
<td align="right"><strong>{{ number_format($total_ujrah, 2)}}</strong></td>
<td align="right"><strong>{{ number_format($total_cajlelong, 2)}}</strong></td>
<td align="right"><strong>{{ number_format($total_hargajual, 2)}}</strong></td>
<td align="right"><strong>{{ number_format($total_baki, 2)}}</strong></td>
<td align="right"><strong>{{ number_format($total_hargaasas, 2)}}</strong></td>
<td></td>
</tr>
</table>
<br><br>
<!-- Table for Jumlah Baki A, Baki B -->
<table class="table-align" cellspacing="0" cellpadding="1" border="0" width="100%" height="80" align="left" id="scan">
<!-- Barisan Jumlah Baki A -->
<!-- Jumlah Baki A dan Baki B -->
<tr>
<td colspan="6" align="right"><b>Jumlah Baki Lelong (A):</b></td>
<td colspan="2" align="right"><b>@if($bakilelong < 0)
({{ number_format(abs($bakilelong), 2, '.', ',') }})
@else
{{ number_format($bakilelong, 2, '.', ',') }}
@endif<b></td>
</tr>
<tr>
<td colspan="6" align="right"><b>Jumlah Kerugian Lelong (B):</b></td>
<td colspan="2" align="right"><b>@if($rugilelong < 0)
({{ number_format(abs($rugilelong), 2, '.', ',') }})
@else
{{ number_format($rugilelong, 2, '.', ',') }}
@endif<b></td>
</tr>
<!-- Baki A - Baki B -->
<tr>
<td colspan="6" align="right"><b>A - B:</b></td>
<td colspan="2" align="right"><b>
@if($total_baki < 0)
({{ number_format(abs($total_baki), 2, '.', ',') }})
@else
{{ number_format($total_baki, 2, '.', ',') }}
@endif<b>
</td>
</tr>
</tbody>
</table>
</tbody>
<td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td>
<td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td>
<table id="scan">
<tr>
<td></td>
<td colspan="2"> .................................................................. </td>
<td> </td>
<td colspan="2"> .................................................................. </td>
<td> </td>
<td colspan="2">.................................................................. </td>
<td> </td>
</tr>
<tr>
<td></td>
<td colspan="2"><B> Disediakan </B> </td>
<td></td>
<td colspan="2"><B> Disemak </B> </td>
<td> </td>
<td colspan="2"><B> Disahkan </B></td>
<td> </td>
</tr>
</table>
+1
View File
@@ -129,6 +129,7 @@ Route::get('/akaunhome/cetakAnsuranRangeDate',['as'=>'cetak.ansuranRangeDate','u
Route::get('/akaunhome/cetakpenebusanRangeDate',['as'=>'cetak.penebusanRangeDate','uses'=>'App\Http\Controllers\AkaunController@cetakLaporanPenebusanRangeDate'])->middleware(['roleChecker:admin,akaun,operasi,kpo,callcenter']);
Route::get('/akaunhome/imbangdugabackup',['as'=>'cetak.imbangdugabackup','uses'=>'App\Http\Controllers\AkaunController@cetak_imbangdugaharian'])->middleware(['roleChecker:admin,akaun,operasi,kpo,callcenter']);
Route::get('/akaunhome/cetak_saghilang',['as'=>'cetak.saghilang','uses'=>'App\Http\Controllers\AkaunController@cetak_laporansaghilang'])->middleware(['roleChecker:admin,akaun,operasi,kpo,callcenter']);
Route::get('/akaunhome/cetak_laporanlelong',['as'=>'cetak.laporanlelong','uses'=>'App\Http\Controllers\AkaunController@cetak_laporanlelong'])->middleware(['roleChecker:admin,akaun,operasi,kpo,callcenter']);