Add export data
This commit is contained in:
@@ -93,20 +93,52 @@ class LelongController extends Controller
|
||||
public function exportData($lelongid)
|
||||
{
|
||||
|
||||
$lelong = Lelong::with('cawangan')->where('lelong.id', $lelongid)->first();
|
||||
$lelong = Lelong::with(['cawangan', 'lelongBidJual'])->find($lelongid);
|
||||
$allCawangan = $lelong->cawangan->keyBy('caw_code');
|
||||
$lelongBid = $lelong->lelongBidJual->groupBy('kodcaw');
|
||||
|
||||
foreach ($lelongBid as $index => $lelong_bid) {
|
||||
foreach ($allCawangan as $data => $cawangan) {
|
||||
if ($data == $index) {
|
||||
$cawangan['lelongBid'] = $lelong_bid;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($lelong->cawangan as $index => $caw) {
|
||||
$allLelongBid = $caw->lelongBid->count();
|
||||
$settlePayment = $caw->lelongBid->where('status_payment', 1)->count();
|
||||
|
||||
$lelong->cawangan[$index]['lelong_laku'] = $allLelongBid;
|
||||
$lelong->cawangan[$index]['selesai_bayar'] = $settlePayment;
|
||||
}
|
||||
$lelong['jumlah_lelong_laku'] = $lelong->lelongBidJual->count();
|
||||
|
||||
return view('lelong.exportData', compact('lelong'));
|
||||
}
|
||||
|
||||
public function exportDataToApi(Request $request)
|
||||
{
|
||||
$lelongDetails = Lelong::find($request->lelong_id);
|
||||
$cawanganLelong = CawanganLelong::with('cawangan')->where('caw_id', $request->cawangan)->where('lelong_id', $request->lelong_id)->first();
|
||||
$lelongBidMaster = LelongBid::where('lelong_id', $request->lelong_id)
|
||||
$lelongBidMaster = LelongBid::with('payment:norujukan,status_payment_opt,remark')
|
||||
->where('lelong_id', $request->lelong_id)
|
||||
->where('status_jual', 1)
|
||||
->where('status_payment', 1)
|
||||
->where('kodcaw', $cawanganLelong->cawangan->caw_code)
|
||||
->get();
|
||||
|
||||
|
||||
foreach ($lelongBidMaster as $index => $lelongBid) {
|
||||
if ($lelongBid->payment->status_payment_opt == 1) {
|
||||
$lelongBidMaster[$index]['payment_method'] = "TUNAI";
|
||||
$lelongBidMaster[$index]['teller'] = "LELONG";
|
||||
} elseif ($lelongBid->payment->status_payment_opt == 2) {
|
||||
$lelongBidMaster[$index]['payment_method'] = "BAYARAN ONLINE";
|
||||
$lelongBidMaster[$index]['teller'] = "LELONG ONLINE";
|
||||
}
|
||||
}
|
||||
|
||||
$lelongbid = $lelongBidMaster->pluck('id');
|
||||
$lelongbidId = $lelongBidMaster->keyBy('id');
|
||||
|
||||
@@ -120,25 +152,25 @@ class LelongController extends Controller
|
||||
|
||||
$paymentOnline = Payment::where('lelong_id', $request->lelong_id)
|
||||
->where('status', '=', 2)
|
||||
->where('status_payment_opt', '=', 2)
|
||||
->where('remark', '=', 'BERJAYA BAYARAN ONLINE')
|
||||
->where('kodcaw', '=', $cawanganLelong->cawangan->caw_code)
|
||||
->sum('total_payment');
|
||||
|
||||
$paymentTunai = Payment::where('lelong_id', $request->lelong_id)
|
||||
->where('status', '=', 1)
|
||||
->where('status', '=', 2)
|
||||
->where('status_payment_opt', '=', 1)
|
||||
->where('remark', '=', 'TUNAI')
|
||||
->where('kodcaw', '=', $cawanganLelong->cawangan->caw_code)
|
||||
->sum('total_payment');
|
||||
// dd($paymentOnline, $paymentTunai);
|
||||
|
||||
// dd($lelongBidMaster->toArray(), $lelongbidmarhun->toArray(), floatval($paymentOnline), floatval($paymentTunai));
|
||||
|
||||
|
||||
|
||||
$exportData = Http::withOptions(['verify' => config('app.api_verify')])->post(
|
||||
config('app.api_url') . 'exportLelong',
|
||||
[
|
||||
'kodcaw' => $cawanganLelong->cawangan->caw_code,
|
||||
'tarikh' => $request->tarikh_lelong,
|
||||
'masadari' => $lelongDetails->masamula_lelong,
|
||||
'masahingga' => $lelongDetails->masatamat_lelong,
|
||||
'lelongbid' => $lelongBidMaster->toArray(),
|
||||
'lelongbidmarhun' => $lelongbidmarhun->toArray(),
|
||||
'gldetail' => floatval($paymentOnline),
|
||||
|
||||
Reference in New Issue
Block a user