DONE: confirmation and list online form
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
@@ -346,6 +347,98 @@ class PembiayaanOnlineController extends Controller
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Operasi: printable batch kelulusan form.
|
||||
*/
|
||||
public function operasiPrintBatch($kodcaw, $batchId)
|
||||
{
|
||||
$api_url = config('api.url');
|
||||
|
||||
$detail = $this->api()
|
||||
->get($api_url . '/api/pembiayaan-online/operasi/' . $kodcaw . '/batches/' . $batchId)
|
||||
->json();
|
||||
|
||||
if (!is_array($detail) || empty($detail['batch'])) {
|
||||
return redirect()
|
||||
->route('pembiayaan.online.operasi')
|
||||
->with('error', 'Batch tidak dijumpai.');
|
||||
}
|
||||
|
||||
$batch = $detail['batch'];
|
||||
$lines = $detail['lines'] ?? [];
|
||||
if (!is_array($lines)) {
|
||||
$lines = [];
|
||||
}
|
||||
|
||||
$cawanganResp = $this->api()
|
||||
->get($api_url . '/api/cawangan/detail/' . $kodcaw)
|
||||
->json();
|
||||
$cawangan_detail = (is_array($cawanganResp) && isset($cawanganResp[0]))
|
||||
? $cawanganResp[0]
|
||||
: (is_array($cawanganResp) ? $cawanganResp : []);
|
||||
|
||||
$cawangan = $cawangan_detail['namacaw']
|
||||
?? $cawangan_detail['details_caw']
|
||||
?? $cawangan_detail['nama']
|
||||
?? $kodcaw;
|
||||
$alamat1 = $cawangan_detail['alamat1'] ?? '';
|
||||
$alamat2 = $cawangan_detail['alamat2'] ?? '';
|
||||
$notel = $cawangan_detail['notel'] ?? '';
|
||||
|
||||
$batchNo = $batch['batch_no'] ?? '-';
|
||||
$slot = $batch['slot'] ?? '-';
|
||||
$status = $batch['status'] ?? '-';
|
||||
$dihantarOleh = $batch['pc_submitted_by'] ?? '-';
|
||||
|
||||
$jumlah = (float) ($batch['jumlah_keseluruhan'] ?? 0);
|
||||
if ($jumlah <= 0 && count($lines) > 0) {
|
||||
$jumlah = (float) collect($lines)->sum(function ($line) {
|
||||
return (float) ($line['pinjaman'] ?? 0);
|
||||
});
|
||||
}
|
||||
|
||||
$opsBy = Auth::user()['name'] ?? '';
|
||||
foreach ($lines as $line) {
|
||||
if (!empty($line['ops_by'])) {
|
||||
$opsBy = $line['ops_by'];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
$tarikh = $this->formatPrintDate($batch['tarikh'] ?? null);
|
||||
$dihantarPada = $this->formatPrintDate($batch['submitted_at'] ?? null, true);
|
||||
|
||||
return view('print.borang_batch_pembiayaan_online', compact(
|
||||
'cawangan',
|
||||
'kodcaw',
|
||||
'alamat1',
|
||||
'alamat2',
|
||||
'notel',
|
||||
'tarikh',
|
||||
'batchNo',
|
||||
'slot',
|
||||
'status',
|
||||
'dihantarOleh',
|
||||
'dihantarPada',
|
||||
'opsBy',
|
||||
'lines',
|
||||
'jumlah'
|
||||
));
|
||||
}
|
||||
|
||||
protected function formatPrintDate($value, $withTime = false)
|
||||
{
|
||||
if ($value === null || $value === '' || $value === '-') {
|
||||
return '-';
|
||||
}
|
||||
|
||||
try {
|
||||
return Carbon::parse($value)->format($withTime ? 'd/m/Y H:i' : 'd/m/Y');
|
||||
} catch (\Exception $e) {
|
||||
return (string) $value;
|
||||
}
|
||||
}
|
||||
|
||||
public function operasiApproveLine(Request $request, $kodcaw, $id)
|
||||
{
|
||||
$res = $this->api()
|
||||
|
||||
Reference in New Issue
Block a user