Initial Commit
This commit is contained in:
42
Jenkinsfile
vendored
Normal file
42
Jenkinsfile
vendored
Normal file
@@ -0,0 +1,42 @@
|
|||||||
|
pipeline {
|
||||||
|
agent any
|
||||||
|
|
||||||
|
environment {
|
||||||
|
PHP_VERSION = '8.1'
|
||||||
|
COMPOSER_HOME = "${WORKSPACE}/.composer"
|
||||||
|
DASHBOARD = '/var/www/lpj'
|
||||||
|
WORKDIR = '/var/www/lpj/Modules/Lpj'
|
||||||
|
GIT_SSH_COMMAND = 'ssh -i ~/.ssh/for_gitea -o StrictHostKeyChecking=no'
|
||||||
|
}
|
||||||
|
|
||||||
|
stages {
|
||||||
|
stage('Checkout') {
|
||||||
|
steps {
|
||||||
|
dir("${env.DASHBOARD}") {
|
||||||
|
sh "composer update daengdeni/lpj-module:dev-staging"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
stage('Build Assets') {
|
||||||
|
steps {
|
||||||
|
dir("${env.DASHBOARD}") {
|
||||||
|
sh "npm install"
|
||||||
|
sh "npm run build"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
post {
|
||||||
|
always {
|
||||||
|
cleanWs()
|
||||||
|
}
|
||||||
|
success {
|
||||||
|
echo 'The pipeline has succeeded!'
|
||||||
|
}
|
||||||
|
failure {
|
||||||
|
echo 'The pipeline has failed.'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
63
app/Emails/SendJadwalKunjunganEmail.php
Normal file
63
app/Emails/SendJadwalKunjunganEmail.php
Normal file
@@ -0,0 +1,63 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Modules\Lpj\Emails;
|
||||||
|
|
||||||
|
use Illuminate\Bus\Queueable;
|
||||||
|
use Illuminate\Mail\Mailable;
|
||||||
|
use Illuminate\Queue\SerializesModels;
|
||||||
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||||
|
|
||||||
|
class SendJadwalKunjunganEmail extends Mailable
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* ID Penilaian.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
public $id;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Waktu Penilaian.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
public $waktu_penilaian;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Deskripsi Penilaian.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
public $deskripsi_penilaian;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new message instance.
|
||||||
|
*
|
||||||
|
* @param array $emailData
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function __construct(array $emailData)
|
||||||
|
{
|
||||||
|
// Validasi data yang diterima
|
||||||
|
if (!isset($emailData['emailData']['id']) ||
|
||||||
|
!isset($emailData['emailData']['waktu_penilaian']) ||
|
||||||
|
!isset($emailData['emailData']['deskripsi_penilaian'])) {
|
||||||
|
throw new \InvalidArgumentException("Data email tidak lengkap.");
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->id = $emailData['emailData']['id'];
|
||||||
|
$this->waktu_penilaian = $emailData['emailData']['waktu_penilaian'];
|
||||||
|
$this->deskripsi_penilaian = $emailData['emailData']['deskripsi_penilaian'];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Build the message.
|
||||||
|
*
|
||||||
|
* @return $this
|
||||||
|
*/
|
||||||
|
public function build()
|
||||||
|
{
|
||||||
|
return $this->subject('Jadwal Kunjungan Penilaian Resmi')
|
||||||
|
->view('lpj::emails.jadwal-kunjungan');
|
||||||
|
}
|
||||||
|
}
|
||||||
58
app/Emails/SendPenawaranKJPPEmail.php
Normal file
58
app/Emails/SendPenawaranKJPPEmail.php
Normal file
@@ -0,0 +1,58 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Modules\Lpj\Emails;
|
||||||
|
|
||||||
|
use Illuminate\Bus\Queueable;
|
||||||
|
use Illuminate\Mail\Mailable;
|
||||||
|
use Illuminate\Queue\SerializesModels;
|
||||||
|
// use Illuminate\Contracts\Queue\ShouldQueue;
|
||||||
|
|
||||||
|
class SendPenawaranKJPPEmail extends Mailable
|
||||||
|
{
|
||||||
|
use Queueable, SerializesModels;
|
||||||
|
|
||||||
|
// Tambahkan properti untuk data yang akan dikirimkan ke view
|
||||||
|
public $dp1;
|
||||||
|
public $penawaran;
|
||||||
|
public $permohonan;
|
||||||
|
public $villages;
|
||||||
|
public $districts;
|
||||||
|
public $cities;
|
||||||
|
public $provinces;
|
||||||
|
public $user; // Tambahkan user ke data yang dikirimkan ke view, sebagai cc dan bcc
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new message instance.
|
||||||
|
*/
|
||||||
|
public function __construct($dp1, $penawaran, $permohonan, $villages, $districts, $cities, $provinces, $user)
|
||||||
|
{
|
||||||
|
// Assign data yang diterima ke properti
|
||||||
|
$this->dp1 = $dp1;
|
||||||
|
$this->penawaran = $penawaran;
|
||||||
|
$this->permohonan = $permohonan;
|
||||||
|
$this->villages = $villages;
|
||||||
|
$this->districts = $districts;
|
||||||
|
$this->cities = $cities;
|
||||||
|
$this->provinces = $provinces;
|
||||||
|
$this->user = $user; // Tambahkan user ke data yang dikirimkan ke view, sebagai cc dan bcc
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Build the message.
|
||||||
|
*/
|
||||||
|
public function build(): self
|
||||||
|
{
|
||||||
|
// Kirim data ke view
|
||||||
|
return $this->view('lpj::penawaran.kirimEmailKJPP')
|
||||||
|
->with([
|
||||||
|
'dp1' => $this->dp1,
|
||||||
|
'penawaran' => $this->penawaran,
|
||||||
|
'permohonan' => $this->permohonan,
|
||||||
|
'villages' => $this->villages,
|
||||||
|
'districts' => $this->districts,
|
||||||
|
'cities' => $this->cities,
|
||||||
|
'provinces' => $this->provinces,
|
||||||
|
'user' => $this->user // Tambahkan user ke data yang dikirimkan ke view, sebagai cc dan bcc
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
29
app/Emails/SendPenawaranTenderEmail.php
Normal file
29
app/Emails/SendPenawaranTenderEmail.php
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Modules\Lpj\Emails;
|
||||||
|
|
||||||
|
use Illuminate\Bus\Queueable;
|
||||||
|
use Illuminate\Mail\Mailable;
|
||||||
|
use Illuminate\Queue\SerializesModels;
|
||||||
|
// use Illuminate\Contracts\Queue\ShouldQueue;
|
||||||
|
|
||||||
|
class SendPenawaranTenderEmail extends Mailable
|
||||||
|
{
|
||||||
|
use Queueable, SerializesModels;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new message instance.
|
||||||
|
*/
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
//
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Build the message.
|
||||||
|
*/
|
||||||
|
public function build(): self
|
||||||
|
{
|
||||||
|
return $this->view('lpj::penawaran.kirimEmail');
|
||||||
|
}
|
||||||
|
}
|
||||||
47
app/Exports/ArahMataAnginExport.php
Normal file
47
app/Exports/ArahMataAnginExport.php
Normal file
@@ -0,0 +1,47 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Modules\Lpj\Exports;
|
||||||
|
|
||||||
|
use Maatwebsite\Excel\Concerns\FromCollection;
|
||||||
|
use Maatwebsite\Excel\Concerns\WithColumnFormatting;
|
||||||
|
use Maatwebsite\Excel\Concerns\WithHeadings;
|
||||||
|
use Maatwebsite\Excel\Concerns\WithMapping;
|
||||||
|
use Modules\Lpj\Models\ArahMataAngin;
|
||||||
|
use PhpOffice\PhpSpreadsheet\Style\NumberFormat;
|
||||||
|
|
||||||
|
class ArahMataAnginExport implements WithColumnFormatting, WithHeadings, FromCollection, withMapping
|
||||||
|
{
|
||||||
|
public function collection()
|
||||||
|
{
|
||||||
|
return ArahMataAngin::all();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function map($row)
|
||||||
|
: array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
$row->id,
|
||||||
|
$row->name,
|
||||||
|
$row->created_at
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function headings()
|
||||||
|
: array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'ID',
|
||||||
|
'Arah Mata Angin',
|
||||||
|
'Created At'
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function columnFormats()
|
||||||
|
: array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'A' => NumberFormat::FORMAT_NUMBER,
|
||||||
|
'C' => NumberFormat::FORMAT_DATE_DATETIME
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
58
app/Exports/BasicDataSurveyorExport.php
Normal file
58
app/Exports/BasicDataSurveyorExport.php
Normal file
@@ -0,0 +1,58 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Modules\Lpj\Exports;
|
||||||
|
|
||||||
|
use Maatwebsite\Excel\Concerns\FromCollection;
|
||||||
|
use Maatwebsite\Excel\Concerns\WithColumnFormatting;
|
||||||
|
use Maatwebsite\Excel\Concerns\WithHeadings;
|
||||||
|
use Maatwebsite\Excel\Concerns\WithMapping;
|
||||||
|
use PhpOffice\PhpSpreadsheet\Style\NumberFormat;
|
||||||
|
|
||||||
|
class BasicDataSurveyorExport implements WithColumnFormatting, WithHeadings, FromCollection, withMapping
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
protected $model;
|
||||||
|
|
||||||
|
|
||||||
|
public function __construct($model)
|
||||||
|
{
|
||||||
|
$this->model = $model;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function collection()
|
||||||
|
{
|
||||||
|
return $this->model::all();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function map($row)
|
||||||
|
: array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
$row->id,
|
||||||
|
$row->code,
|
||||||
|
$row->name,
|
||||||
|
$row->created_at
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function headings()
|
||||||
|
: array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'ID',
|
||||||
|
'Code',
|
||||||
|
'Name',
|
||||||
|
'Created At'
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function columnFormats()
|
||||||
|
: array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'A' => NumberFormat::FORMAT_NUMBER,
|
||||||
|
'D' => NumberFormat::FORMAT_DATE_DATETIME
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
49
app/Exports/CustomFieldExport.php
Normal file
49
app/Exports/CustomFieldExport.php
Normal file
@@ -0,0 +1,49 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Modules\Lpj\Exports;
|
||||||
|
|
||||||
|
use Maatwebsite\Excel\Concerns\FromCollection;
|
||||||
|
use Maatwebsite\Excel\Concerns\WithColumnFormatting;
|
||||||
|
use Maatwebsite\Excel\Concerns\WithHeadings;
|
||||||
|
use Maatwebsite\Excel\Concerns\WithMapping;
|
||||||
|
use Modules\Lpj\Models\CustomField;
|
||||||
|
use PhpOffice\PhpSpreadsheet\Style\NumberFormat;
|
||||||
|
|
||||||
|
class CustomFieldExport implements WithColumnFormatting, WithHeadings, FromCollection, WithMapping
|
||||||
|
{
|
||||||
|
public function collection()
|
||||||
|
{
|
||||||
|
return CustomField::all();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function map($row): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
$row->id,
|
||||||
|
$row->name,
|
||||||
|
$row->type,
|
||||||
|
$row->created_at,
|
||||||
|
$row->updated_at,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function headings(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'ID',
|
||||||
|
'Name',
|
||||||
|
'Type',
|
||||||
|
'Created At',
|
||||||
|
'Updated At',
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function columnFormats(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'A' => NumberFormat::FORMAT_NUMBER,
|
||||||
|
'D' => NumberFormat::FORMAT_DATE_DDMMYYYY,
|
||||||
|
'E' => NumberFormat::FORMAT_DATE_DDMMYYYY,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
81
app/Exports/DebitureExport.php
Normal file
81
app/Exports/DebitureExport.php
Normal file
@@ -0,0 +1,81 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Modules\Lpj\Exports;
|
||||||
|
|
||||||
|
use Maatwebsite\Excel\Concerns\FromCollection;
|
||||||
|
use Maatwebsite\Excel\Concerns\WithColumnFormatting;
|
||||||
|
use Maatwebsite\Excel\Concerns\WithHeadings;
|
||||||
|
use Maatwebsite\Excel\Concerns\WithMapping;
|
||||||
|
use Modules\Lpj\Models\Debiture;
|
||||||
|
use PhpOffice\PhpSpreadsheet\Style\NumberFormat;
|
||||||
|
|
||||||
|
class DebitureExport implements WithColumnFormatting, WithHeadings, FromCollection, withMapping
|
||||||
|
{
|
||||||
|
public function collection()
|
||||||
|
{
|
||||||
|
return Debiture::with('branch', 'province', 'city', 'district', 'village')->get();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function map($row)
|
||||||
|
: array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
$row->id,
|
||||||
|
$row->branch->name,
|
||||||
|
$row->cif,
|
||||||
|
$row->nomor_rekening,
|
||||||
|
$row->name,
|
||||||
|
$row->npwp,
|
||||||
|
$row->nomor_id,
|
||||||
|
$row->email,
|
||||||
|
$row->phone,
|
||||||
|
$row->province->name,
|
||||||
|
$row->city->name,
|
||||||
|
$row->district->name,
|
||||||
|
$row->village->name,
|
||||||
|
$row->postal_code,
|
||||||
|
$row->address,
|
||||||
|
$row->registered_at,
|
||||||
|
$row->created_at
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function headings()
|
||||||
|
: array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'ID',
|
||||||
|
'Branch',
|
||||||
|
'CIF',
|
||||||
|
'Nomor Rekening',
|
||||||
|
'Name',
|
||||||
|
'NPWP',
|
||||||
|
'Nomor ID',
|
||||||
|
'Email',
|
||||||
|
'Phone',
|
||||||
|
'Province',
|
||||||
|
'City',
|
||||||
|
'District',
|
||||||
|
'Village',
|
||||||
|
'Postal Code',
|
||||||
|
'Address',
|
||||||
|
'Registered At',
|
||||||
|
'Created At'
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function columnFormats()
|
||||||
|
: array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'A' => NumberFormat::FORMAT_NUMBER,
|
||||||
|
'C' => NumberFormat::FORMAT_NUMBER,
|
||||||
|
'D' => NumberFormat::FORMAT_NUMBER,
|
||||||
|
'F' => NumberFormat::FORMAT_NUMBER,
|
||||||
|
'G' => NumberFormat::FORMAT_NUMBER,
|
||||||
|
'P' => NumberFormat::FORMAT_DATE_DATETIME,
|
||||||
|
'Q' => NumberFormat::FORMAT_DATE_DATETIME
|
||||||
|
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
47
app/Exports/HubunganPemilikJaminanExport.php
Normal file
47
app/Exports/HubunganPemilikJaminanExport.php
Normal file
@@ -0,0 +1,47 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Modules\Lpj\Exports;
|
||||||
|
|
||||||
|
use Maatwebsite\Excel\Concerns\FromCollection;
|
||||||
|
use Maatwebsite\Excel\Concerns\WithColumnFormatting;
|
||||||
|
use Maatwebsite\Excel\Concerns\WithHeadings;
|
||||||
|
use Maatwebsite\Excel\Concerns\WithMapping;
|
||||||
|
use Modules\Lpj\Models\HubunganPemilikJaminan;
|
||||||
|
use PhpOffice\PhpSpreadsheet\Style\NumberFormat;
|
||||||
|
|
||||||
|
class HubunganPemilikJaminanExport implements WithColumnFormatting, WithHeadings, FromCollection, withMapping
|
||||||
|
{
|
||||||
|
public function collection()
|
||||||
|
{
|
||||||
|
return HubunganPemilikJaminan::all();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function map($row)
|
||||||
|
: array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
$row->id,
|
||||||
|
$row->name,
|
||||||
|
$row->created_at
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function headings()
|
||||||
|
: array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'ID',
|
||||||
|
'Hubungan Pemilik Jaminan',
|
||||||
|
'Created At'
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function columnFormats()
|
||||||
|
: array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'A' => NumberFormat::FORMAT_NUMBER,
|
||||||
|
'C' => NumberFormat::FORMAT_DATE_DATETIME
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
47
app/Exports/HubunganPenghuniJaminanExport.php
Normal file
47
app/Exports/HubunganPenghuniJaminanExport.php
Normal file
@@ -0,0 +1,47 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Modules\Lpj\Exports;
|
||||||
|
|
||||||
|
use Maatwebsite\Excel\Concerns\FromCollection;
|
||||||
|
use Maatwebsite\Excel\Concerns\WithColumnFormatting;
|
||||||
|
use Maatwebsite\Excel\Concerns\WithHeadings;
|
||||||
|
use Maatwebsite\Excel\Concerns\WithMapping;
|
||||||
|
use Modules\Lpj\Models\HubunganPenghuniJaminan;
|
||||||
|
use PhpOffice\PhpSpreadsheet\Style\NumberFormat;
|
||||||
|
|
||||||
|
class HubunganPenghuniJaminanExport implements WithColumnFormatting, WithHeadings, FromCollection, withMapping
|
||||||
|
{
|
||||||
|
public function collection()
|
||||||
|
{
|
||||||
|
return HubunganPenghuniJaminan::all();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function map($row)
|
||||||
|
: array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
$row->id,
|
||||||
|
$row->name,
|
||||||
|
$row->created_at
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function headings()
|
||||||
|
: array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'ID',
|
||||||
|
'Hubungan Penghuni Jaminan',
|
||||||
|
'Created At'
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function columnFormats()
|
||||||
|
: array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'A' => NumberFormat::FORMAT_NUMBER,
|
||||||
|
'C' => NumberFormat::FORMAT_DATE_DATETIME
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
47
app/Exports/IjinUsahaExport.php
Normal file
47
app/Exports/IjinUsahaExport.php
Normal file
@@ -0,0 +1,47 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Modules\Lpj\Exports;
|
||||||
|
|
||||||
|
use Maatwebsite\Excel\Concerns\FromCollection;
|
||||||
|
use Maatwebsite\Excel\Concerns\WithColumnFormatting;
|
||||||
|
use Maatwebsite\Excel\Concerns\WithHeadings;
|
||||||
|
use Maatwebsite\Excel\Concerns\WithMapping;
|
||||||
|
use Modules\Lpj\Models\IjinUsaha;
|
||||||
|
use PhpOffice\PhpSpreadsheet\Style\NumberFormat;
|
||||||
|
|
||||||
|
class IjinUsahaExport implements WithColumnFormatting, WithHeadings, FromCollection, withMapping
|
||||||
|
{
|
||||||
|
public function collection()
|
||||||
|
{
|
||||||
|
return IjinUsaha::all();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function map($row): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
$row->id,
|
||||||
|
$row->code,
|
||||||
|
$row->name,
|
||||||
|
$row->created_at
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function headings(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'ID',
|
||||||
|
'Code',
|
||||||
|
'Name',
|
||||||
|
'Created At'
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function columnFormats(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'A' => NumberFormat::FORMAT_NUMBER,
|
||||||
|
'B' => NumberFormat::FORMAT_NUMBER,
|
||||||
|
'E' => NumberFormat::FORMAT_DATE_DATETIME
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
49
app/Exports/JenisAsetExport.php
Normal file
49
app/Exports/JenisAsetExport.php
Normal file
@@ -0,0 +1,49 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Modules\Lpj\Exports;
|
||||||
|
|
||||||
|
use Maatwebsite\Excel\Concerns\FromCollection;
|
||||||
|
use Maatwebsite\Excel\Concerns\WithColumnFormatting;
|
||||||
|
use Maatwebsite\Excel\Concerns\WithHeadings;
|
||||||
|
use Maatwebsite\Excel\Concerns\WithMapping;
|
||||||
|
use Modules\Lpj\Models\JenisAset;
|
||||||
|
use PhpOffice\PhpSpreadsheet\Style\NumberFormat;
|
||||||
|
|
||||||
|
class JenisAsetExport implements WithColumnFormatting, WithHeadings, FromCollection, withMapping
|
||||||
|
{
|
||||||
|
public function collection()
|
||||||
|
{
|
||||||
|
return JenisAset::all();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function map($row)
|
||||||
|
: array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
$row->id,
|
||||||
|
$row->code,
|
||||||
|
$row->name,
|
||||||
|
$row->created_at
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function headings()
|
||||||
|
: array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'ID',
|
||||||
|
'Code',
|
||||||
|
'Name',
|
||||||
|
'Created At'
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function columnFormats()
|
||||||
|
: array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'A' => NumberFormat::FORMAT_NUMBER,
|
||||||
|
'D' => NumberFormat::FORMAT_DATE_DATETIME
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
51
app/Exports/JenisDokumenExport.php
Normal file
51
app/Exports/JenisDokumenExport.php
Normal file
@@ -0,0 +1,51 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Modules\Lpj\Exports;
|
||||||
|
|
||||||
|
use Maatwebsite\Excel\Concerns\FromCollection;
|
||||||
|
use Maatwebsite\Excel\Concerns\WithColumnFormatting;
|
||||||
|
use Maatwebsite\Excel\Concerns\WithHeadings;
|
||||||
|
use Maatwebsite\Excel\Concerns\WithMapping;
|
||||||
|
use Modules\Lpj\Models\JenisDokumen;
|
||||||
|
use PhpOffice\PhpSpreadsheet\Style\NumberFormat;
|
||||||
|
|
||||||
|
class JenisDokumenExport implements WithColumnFormatting, WithHeadings, FromCollection, withMapping
|
||||||
|
{
|
||||||
|
public function collection()
|
||||||
|
{
|
||||||
|
return JenisDokumen::all();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function map($row)
|
||||||
|
: array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
$row->id,
|
||||||
|
$row->name,
|
||||||
|
$row->max_size,
|
||||||
|
$row->description,
|
||||||
|
$row->created_at
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function headings()
|
||||||
|
: array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'ID',
|
||||||
|
'Name',
|
||||||
|
'Max Size',
|
||||||
|
'Description',
|
||||||
|
'Created At'
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function columnFormats()
|
||||||
|
: array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'A' => NumberFormat::FORMAT_NUMBER,
|
||||||
|
'E' => NumberFormat::FORMAT_DATE_DATETIME
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
49
app/Exports/JenisFasilitasKreditExport.php
Normal file
49
app/Exports/JenisFasilitasKreditExport.php
Normal file
@@ -0,0 +1,49 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Modules\Lpj\Exports;
|
||||||
|
|
||||||
|
use Maatwebsite\Excel\Concerns\FromCollection;
|
||||||
|
use Maatwebsite\Excel\Concerns\WithColumnFormatting;
|
||||||
|
use Maatwebsite\Excel\Concerns\WithHeadings;
|
||||||
|
use Maatwebsite\Excel\Concerns\WithMapping;
|
||||||
|
use Modules\Lpj\Models\JenisFasilitasKredit;
|
||||||
|
use PhpOffice\PhpSpreadsheet\Style\NumberFormat;
|
||||||
|
|
||||||
|
class JenisFasilitasKreditExport implements WithColumnFormatting, WithHeadings, FromCollection, withMapping
|
||||||
|
{
|
||||||
|
public function collection()
|
||||||
|
{
|
||||||
|
return JenisFasilitasKredit::all();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function map($row)
|
||||||
|
: array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
$row->id,
|
||||||
|
$row->code,
|
||||||
|
$row->name,
|
||||||
|
$row->created_at
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function headings()
|
||||||
|
: array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'ID',
|
||||||
|
'Code',
|
||||||
|
'Name',
|
||||||
|
'Created At'
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function columnFormats()
|
||||||
|
: array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'A' => NumberFormat::FORMAT_NUMBER,
|
||||||
|
'D' => NumberFormat::FORMAT_DATE_DATETIME
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
49
app/Exports/JenisJaminanExport.php
Normal file
49
app/Exports/JenisJaminanExport.php
Normal file
@@ -0,0 +1,49 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Modules\Lpj\Exports;
|
||||||
|
|
||||||
|
use Maatwebsite\Excel\Concerns\FromCollection;
|
||||||
|
use Maatwebsite\Excel\Concerns\WithColumnFormatting;
|
||||||
|
use Maatwebsite\Excel\Concerns\WithHeadings;
|
||||||
|
use Maatwebsite\Excel\Concerns\WithMapping;
|
||||||
|
use Modules\Lpj\Models\JenisJaminan;
|
||||||
|
use PhpOffice\PhpSpreadsheet\Style\NumberFormat;
|
||||||
|
|
||||||
|
class JenisJaminanExport implements WithColumnFormatting, WithHeadings, FromCollection, withMapping
|
||||||
|
{
|
||||||
|
public function collection()
|
||||||
|
{
|
||||||
|
return JenisJaminan::all();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function map($row)
|
||||||
|
: array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
$row->id,
|
||||||
|
$row->code,
|
||||||
|
$row->name,
|
||||||
|
$row->created_at
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function headings()
|
||||||
|
: array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'ID',
|
||||||
|
'Code',
|
||||||
|
'Name',
|
||||||
|
'Created At'
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function columnFormats()
|
||||||
|
: array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'A' => NumberFormat::FORMAT_NUMBER,
|
||||||
|
'D' => NumberFormat::FORMAT_DATE_DATETIME
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
46
app/Exports/JenisLampiranExport.php
Normal file
46
app/Exports/JenisLampiranExport.php
Normal file
@@ -0,0 +1,46 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Modules\Lpj\app\Exports;
|
||||||
|
|
||||||
|
use Maatwebsite\Excel\Concerns\FromCollection;
|
||||||
|
use Maatwebsite\Excel\Concerns\WithColumnFormatting;
|
||||||
|
use Maatwebsite\Excel\Concerns\WithHeadings;
|
||||||
|
use Maatwebsite\Excel\Concerns\WithMapping;
|
||||||
|
use PhpOffice\PhpSpreadsheet\Style\NumberFormat;
|
||||||
|
use Modules\Lpj\app\Models\JenisLampiran;
|
||||||
|
|
||||||
|
class JenisLampiranExport implements WithColumnFormatting, WithHeadings, FromCollection, WithMapping
|
||||||
|
{
|
||||||
|
public function collection()
|
||||||
|
{
|
||||||
|
return JenisLampiran::all();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function map($row): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
$row->id,
|
||||||
|
$row->nama,
|
||||||
|
$row->deskripsi,
|
||||||
|
$row->created_at
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function headings(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'ID',
|
||||||
|
'Nama',
|
||||||
|
'Deskripsi',
|
||||||
|
'Created At'
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function columnFormats(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'A' => NumberFormat::FORMAT_NUMBER,
|
||||||
|
'D' => NumberFormat::FORMAT_DATE_DATETIME
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
46
app/Exports/JenisLaporanExport.php
Normal file
46
app/Exports/JenisLaporanExport.php
Normal file
@@ -0,0 +1,46 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Modules\Lpj\Exports;
|
||||||
|
|
||||||
|
use Maatwebsite\Excel\Concerns\FromCollection;
|
||||||
|
use Maatwebsite\Excel\Concerns\WithColumnFormatting;
|
||||||
|
use Maatwebsite\Excel\Concerns\WithHeadings;
|
||||||
|
use Maatwebsite\Excel\Concerns\WithMapping;
|
||||||
|
use Modules\Lpj\Models\JenisLaporan;
|
||||||
|
use PhpOffice\PhpSpreadsheet\Style\NumberFormat;
|
||||||
|
|
||||||
|
class JenisLaporanExport implements WithColumnFormatting, WithHeadings, FromCollection, withMapping
|
||||||
|
{
|
||||||
|
public function collection()
|
||||||
|
{
|
||||||
|
return JenisLaporan::all();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function map($row): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
$row->id,
|
||||||
|
$row->code,
|
||||||
|
$row->name,
|
||||||
|
$row->created_at
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function headings(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'ID',
|
||||||
|
'Code',
|
||||||
|
'Name',
|
||||||
|
'Created At'
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function columnFormats(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'A' => NumberFormat::FORMAT_NUMBER,
|
||||||
|
'D' => NumberFormat::FORMAT_DATE_DATETIME
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
49
app/Exports/JenisLegalitasJaminanExport.php
Normal file
49
app/Exports/JenisLegalitasJaminanExport.php
Normal file
@@ -0,0 +1,49 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Modules\Lpj\Exports;
|
||||||
|
|
||||||
|
use Maatwebsite\Excel\Concerns\FromCollection;
|
||||||
|
use Maatwebsite\Excel\Concerns\WithColumnFormatting;
|
||||||
|
use Maatwebsite\Excel\Concerns\WithHeadings;
|
||||||
|
use Maatwebsite\Excel\Concerns\WithMapping;
|
||||||
|
use Modules\Lpj\Models\JenisLegalitasJaminan;
|
||||||
|
use PhpOffice\PhpSpreadsheet\Style\NumberFormat;
|
||||||
|
|
||||||
|
class JenisLegalitasJaminanExport implements WithColumnFormatting, WithHeadings, FromCollection, withMapping
|
||||||
|
{
|
||||||
|
public function collection()
|
||||||
|
{
|
||||||
|
return JenisLegalitasJaminan::all();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function map($row)
|
||||||
|
: array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
$row->id,
|
||||||
|
$row->code,
|
||||||
|
$row->name,
|
||||||
|
$row->created_at
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function headings()
|
||||||
|
: array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'ID',
|
||||||
|
'Code',
|
||||||
|
'Name',
|
||||||
|
'Created At'
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function columnFormats()
|
||||||
|
: array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'A' => NumberFormat::FORMAT_NUMBER,
|
||||||
|
'D' => NumberFormat::FORMAT_DATE_DATETIME
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
46
app/Exports/JenisPenilaianExport.php
Normal file
46
app/Exports/JenisPenilaianExport.php
Normal file
@@ -0,0 +1,46 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Modules\Lpj\Exports;
|
||||||
|
|
||||||
|
use Maatwebsite\Excel\Concerns\FromCollection;
|
||||||
|
use Maatwebsite\Excel\Concerns\WithColumnFormatting;
|
||||||
|
use Maatwebsite\Excel\Concerns\WithHeadings;
|
||||||
|
use Maatwebsite\Excel\Concerns\WithMapping;
|
||||||
|
use Modules\Lpj\Models\JenisPenilaian;
|
||||||
|
use PhpOffice\PhpSpreadsheet\Style\NumberFormat;
|
||||||
|
|
||||||
|
class JenisPenilaianExport implements WithColumnFormatting, WithHeadings, FromCollection, withMapping
|
||||||
|
{
|
||||||
|
public function collection()
|
||||||
|
{
|
||||||
|
return JenisPenilaian::all();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function map($row): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
$row->id,
|
||||||
|
$row->code,
|
||||||
|
$row->name,
|
||||||
|
$row->created_at
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function headings(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'ID',
|
||||||
|
'Code',
|
||||||
|
'Jenis Penilaian',
|
||||||
|
'Created At'
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function columnFormats(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'A' => NumberFormat::FORMAT_NUMBER,
|
||||||
|
'D' => NumberFormat::FORMAT_DATE_DATETIME
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
89
app/Exports/KJPPExport.php
Normal file
89
app/Exports/KJPPExport.php
Normal file
@@ -0,0 +1,89 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Modules\Lpj\Exports;
|
||||||
|
|
||||||
|
use Maatwebsite\Excel\Concerns\FromCollection;
|
||||||
|
use Maatwebsite\Excel\Concerns\WithColumnFormatting;
|
||||||
|
use Maatwebsite\Excel\Concerns\WithHeadings;
|
||||||
|
use Maatwebsite\Excel\Concerns\WithMapping;
|
||||||
|
use Modules\Lpj\Models\KJPP;
|
||||||
|
use PhpOffice\PhpSpreadsheet\Style\NumberFormat;
|
||||||
|
|
||||||
|
class KJPPExport implements WithColumnFormatting, WithHeadings, FromCollection, withMapping
|
||||||
|
{
|
||||||
|
public function collection()
|
||||||
|
{
|
||||||
|
return KJPP::all();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function map($row): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
$row->id,
|
||||||
|
$row->code,
|
||||||
|
$row->name,
|
||||||
|
$row->jenis_kantor,
|
||||||
|
$row->nomor_ijin_usaha,
|
||||||
|
$row->province_code,
|
||||||
|
$row->city_code,
|
||||||
|
$row->district_code,
|
||||||
|
$row->village_code,
|
||||||
|
$row->address,
|
||||||
|
$row->postal_code,
|
||||||
|
$row->nomor_telepon_kantor,
|
||||||
|
$row->email_kantor,
|
||||||
|
$row->nama_pimpinan,
|
||||||
|
$row->nomor_hp_pimpinan,
|
||||||
|
$row->nama_pic_reviewer,
|
||||||
|
$row->nomor_hp_pic_reviewer,
|
||||||
|
$row->nama_pic_admin,
|
||||||
|
$row->nomor_hp_pic_admin,
|
||||||
|
$row->nama_pic_marketing,
|
||||||
|
$row->nomor_hp_pic_marketing,
|
||||||
|
$row->ijin_usaha_id,
|
||||||
|
$row->jenis_aset_id,
|
||||||
|
$row->attachment,
|
||||||
|
$row->created_at
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function headings(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'ID',
|
||||||
|
'Code',
|
||||||
|
'Name',
|
||||||
|
'Jenis Kantor',
|
||||||
|
'Nomor Ijin Usaha',
|
||||||
|
'Province Code',
|
||||||
|
'City Code',
|
||||||
|
'District Code',
|
||||||
|
'Village Code',
|
||||||
|
'Address',
|
||||||
|
'Postal Code',
|
||||||
|
'Nomor Telepon Kantor',
|
||||||
|
'Email Kantor',
|
||||||
|
'Nama Pimpinan',
|
||||||
|
'Nomor HP Pimpinan',
|
||||||
|
'Nama PIC Reviewer',
|
||||||
|
'Nomor HP PIC Reviewer',
|
||||||
|
'Nama PIC Admin',
|
||||||
|
'Nomor HP PIC Admin',
|
||||||
|
'Nama PIC Marketing',
|
||||||
|
'Nomor HP PIC Marketing',
|
||||||
|
'Ijin Usaha ID',
|
||||||
|
'Jenis Aset ID',
|
||||||
|
'Attachment',
|
||||||
|
'Created At'
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function columnFormats(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'A' => NumberFormat::FORMAT_NUMBER,
|
||||||
|
'B' => NumberFormat::FORMAT_NUMBER,
|
||||||
|
'E' => NumberFormat::FORMAT_DATE_DATETIME
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
339
app/Exports/KertasKerjaExport.php
Normal file
339
app/Exports/KertasKerjaExport.php
Normal file
@@ -0,0 +1,339 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Modules\Lpj\Exports;
|
||||||
|
|
||||||
|
use Maatwebsite\Excel\Concerns\FromCollection;
|
||||||
|
use Maatwebsite\Excel\Concerns\WithHeadings;
|
||||||
|
use Maatwebsite\Excel\Concerns\WithStyles;
|
||||||
|
use Maatwebsite\Excel\Concerns\WithColumnWidths;
|
||||||
|
use Maatwebsite\Excel\Concerns\WithEvents;
|
||||||
|
use Maatwebsite\Excel\Events\AfterSheet;
|
||||||
|
use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet;
|
||||||
|
use PhpOffice\PhpSpreadsheet\Worksheet\Drawing;
|
||||||
|
|
||||||
|
class KertasKerjaExport implements FromCollection, WithHeadings, WithStyles, WithColumnWidths, WithEvents
|
||||||
|
{
|
||||||
|
// use Illuminate\Contracts\View\View;
|
||||||
|
// use Maatwebsite\Excel\Concerns\FromView;
|
||||||
|
// class KertasKerjaExport implements FromView
|
||||||
|
// {
|
||||||
|
|
||||||
|
protected $data;
|
||||||
|
|
||||||
|
public function __construct($data)
|
||||||
|
{
|
||||||
|
$this->data = $data;
|
||||||
|
}
|
||||||
|
|
||||||
|
// public function view(): View
|
||||||
|
// {
|
||||||
|
// return view('lpj::component.kertas-kerja', [
|
||||||
|
// 'data' => $this->data,
|
||||||
|
// ]);
|
||||||
|
// }
|
||||||
|
|
||||||
|
public function collection()
|
||||||
|
{
|
||||||
|
// $rows = [];
|
||||||
|
|
||||||
|
// $nomor = 1;
|
||||||
|
$fields = [
|
||||||
|
'jenis_aset' => 'Jenis Aset',
|
||||||
|
'luas_tanah' => 'Luas Tanah (M²)',
|
||||||
|
'luas_bangunan' => 'Luas Bangunan (M²)',
|
||||||
|
'harga' => 'Harga Transaksi/Penawaran',
|
||||||
|
'tanggal_penawaran' => 'Tanggal Penawaran/Transaksi',
|
||||||
|
'diskon' => 'Diskon %',
|
||||||
|
'esitmasi_harga' => 'Esitmasi Harga Transaksi (Rp)',
|
||||||
|
'no_telepon' => 'Telepon Contact Person',
|
||||||
|
'nama_nara_sumbr' => 'Nama Nara Sumber',
|
||||||
|
'status_nara_sumbr' => 'Status Nara Sumber',
|
||||||
|
'waktu_transaksi' => 'Waktu Transaksi/Penawaran',
|
||||||
|
'alamat' => 'Alamat Titik Gps',
|
||||||
|
|
||||||
|
'jalan' => 'Jalan',
|
||||||
|
'desa' => 'Desa/Kelurahan',
|
||||||
|
'kecamatan' => 'Kecamatan',
|
||||||
|
'kabupaten' => 'Kabupaten',
|
||||||
|
'provinsi' => 'Provinsi',
|
||||||
|
|
||||||
|
'jarak_pembanding' => 'Jarak Pembanding dengan Objek',
|
||||||
|
'elevasi' => 'Estimasi Ranking Tanah',
|
||||||
|
'peruntukan' => 'Estiamsi Rangkin Bangunan'
|
||||||
|
|
||||||
|
];
|
||||||
|
|
||||||
|
$rows = [];
|
||||||
|
$nomor = 1;
|
||||||
|
|
||||||
|
// Add general asset information
|
||||||
|
$rows[] = ['No.', 'Uraian', 'Objek Penilaian', 'Data Pembanding 1', 'Data Pembanding 2', 'Data Pembanding 3'];
|
||||||
|
|
||||||
|
foreach ($this->data['objek'] as $key => $value) {
|
||||||
|
$rows[] = [
|
||||||
|
$nomor++,
|
||||||
|
$key,
|
||||||
|
$value,
|
||||||
|
$this->data['pembanding1'][$key] ?? '',
|
||||||
|
$this->data['pembanding2'][$key] ?? '',
|
||||||
|
$this->data['pembanding3'][$key] ?? ''
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// B. Perhitungan Penyesuaian
|
||||||
|
$rows[] = [''];
|
||||||
|
$rows[] = [''];
|
||||||
|
$rows[] = ['B. Estimasi Nilai Tanah Pembanding dengan Teknik Penyisaan Tanah untuk mendapatkan per meter persegi estimasi Nilai Tanah Pembanding'];
|
||||||
|
$rows[] = ['No.','Uraian', 'Objek Penilaian', 'Data Pembanding 1', 'Data Pembanding 2', 'Data Pembanding 3'];
|
||||||
|
$nostimasi = 1;
|
||||||
|
$filedEstimasi = [
|
||||||
|
'estimasi' => 'Estimasi Biaya Pengganti Baru Bangunan (Rp)',
|
||||||
|
'estimasi_spl' => 'Estimasi Biaya Pengganti Baru SPL (Rp)',
|
||||||
|
'penyusutan' => 'Penyusutan Fisik Banguna',
|
||||||
|
|
||||||
|
'a' => 'a. rincian ttipe bangunan (MAPPI)',
|
||||||
|
'b' => 'b. umur ekonomis (MAPPI)',
|
||||||
|
'c' => 'c. estimasi Tahun tahun visual dengan mempertimbangkan renovasi',
|
||||||
|
'd' => 'd. Sehingga sisa umur efektif',
|
||||||
|
'e' => 'e. kondisi bagunan',
|
||||||
|
'f' => 'f.sehinggan penyusutan fisik',
|
||||||
|
'penyusutan_fungsi' => 'Penyusutan fungsi Bangunan (%)',
|
||||||
|
'penyusutan_ekonomi' => 'Penyusutan Ekonomi Bangunan (%)',
|
||||||
|
'total_penyusutan' => 'Total Penyusutan (%)',
|
||||||
|
'estimasi_nilai' => 'Estimasi Nilai Bangunan dan SPL (Rp)',
|
||||||
|
'estimasi_tanah' => 'Estimasi Nilai Tanah Pembanding (Rp)',
|
||||||
|
'estimasi_nilai' => 'Estimasi Nilai Tanah Pembanding (Rp)',
|
||||||
|
];
|
||||||
|
|
||||||
|
foreach ($filedEstimasi as $key => $label) {
|
||||||
|
$rows[] = [
|
||||||
|
$nostimasi++,
|
||||||
|
$label,
|
||||||
|
$this->data['estimasi'][$key] ?? '',
|
||||||
|
$this->data['estimasi1'][$key] ?? '',
|
||||||
|
$this->data['estimasi2'][$key] ?? '',
|
||||||
|
$this->data['estimasi3'][$key] ?? ''
|
||||||
|
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
$row[] = [''];
|
||||||
|
$row[] = [''];
|
||||||
|
$rows[] = ['INDIKASI NILAI TANAHATAS OBJEK PENILAIAN'];
|
||||||
|
|
||||||
|
$indikasi=[
|
||||||
|
'luas_tanah' => 'Luas Tanah ',
|
||||||
|
'indikasi_per' => 'INDIKASI TANAH PER M2 (RP/M2)',
|
||||||
|
'indikasi_total' => 'INDIKASI TANAH TOTAL(RP)',
|
||||||
|
'varian' => 'VARIANT(%)',
|
||||||
|
];
|
||||||
|
|
||||||
|
foreach ($indikasi as $key => $label) {
|
||||||
|
$rows[] = [
|
||||||
|
$label,
|
||||||
|
$this->data['indikasi'][$key] ?? '',
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// C. Peta Lokasi
|
||||||
|
$rows[] = [''];
|
||||||
|
$rows[] = [''];
|
||||||
|
$rows[] = ['C. Peta Lokasi'];
|
||||||
|
$rows[] = [$this->data['foto_objek']['foto_objek_peta'] ?? ''];
|
||||||
|
|
||||||
|
// D. Foto Objek dan Data Pembanding
|
||||||
|
$rows[] = [''];
|
||||||
|
$rows[] = ['D. Foto Objek dan Data Pembanding'];
|
||||||
|
$rows[] = [
|
||||||
|
$this->data['foto_objek1']['foto_objek'] ?? '',
|
||||||
|
$this->data['foto_objek2']['foto_objek'] ?? '',
|
||||||
|
'', '', ''
|
||||||
|
];
|
||||||
|
|
||||||
|
// E. Foto Objek
|
||||||
|
$rows[] = [''];
|
||||||
|
$rows[] = ['E. Foto Objek'];
|
||||||
|
$rows[] = [
|
||||||
|
$this->data['foto']['foto_objek'] ?? '',
|
||||||
|
$this->data['foto']['foto_objek'] ?? '',
|
||||||
|
'', '', ''
|
||||||
|
];
|
||||||
|
|
||||||
|
return collect($rows);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function headings(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
['KERTAS KERJA PENILAIAN'],
|
||||||
|
['Pendekatan Pasar'],
|
||||||
|
['Metode Perbandingan Data Pasar'],
|
||||||
|
['Tanggal Penilaian: ' . ($this->headerInfo['tanggal_penilaian'] ?? '')],
|
||||||
|
['Nama Pemilik Aset: ' . ($this->headerInfo['nama_pemilik'] ?? '')],
|
||||||
|
['Nama Pemberi Tugas: ' . ($this->headerInfo['nama_pemberi_tugas'] ?? '')],
|
||||||
|
['Lokasi: ' . ($this->headerInfo['lokasi_lengkap'] ?? '')],
|
||||||
|
|
||||||
|
];
|
||||||
|
}
|
||||||
|
public function registerEvents(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
AfterSheet::class => function (AfterSheet $event) {
|
||||||
|
// Styling untuk header utama
|
||||||
|
|
||||||
|
|
||||||
|
// Styling untuk setiap section header
|
||||||
|
$sectionRows = [10, 34, 56, 46, 52]; // Sesuaikan dengan posisi setiap section
|
||||||
|
foreach ($sectionRows as $row) {
|
||||||
|
$event->sheet->getStyle("A{$row}:F{$row}")->getFill()
|
||||||
|
->setFillType(\PhpOffice\PhpSpreadsheet\Style\Fill::FILL_SOLID)
|
||||||
|
->getStartColor()->setRGB('E2EFDA');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Merge cells untuk headers
|
||||||
|
$event->sheet->mergeCells('A1:E1');
|
||||||
|
$event->sheet->mergeCells('A2:E2');
|
||||||
|
$event->sheet->mergeCells('A4:E4');
|
||||||
|
$event->sheet->mergeCells('A5:E5');
|
||||||
|
$event->sheet->mergeCells('A6:E6');
|
||||||
|
$event->sheet->mergeCells('A7:E7');
|
||||||
|
$event->sheet->mergeCells('A8:E8');
|
||||||
|
|
||||||
|
// Alignment
|
||||||
|
$event->sheet->getStyle('A1:E8')->getAlignment()
|
||||||
|
->setHorizontal(\PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_LEFT);
|
||||||
|
$this->insertImages($event->sheet);
|
||||||
|
}
|
||||||
|
];
|
||||||
|
}
|
||||||
|
public function columnWidths(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'A' => 5,
|
||||||
|
'B' => 30,
|
||||||
|
'C' => 30,
|
||||||
|
'D' => 30,
|
||||||
|
'E' => 30,
|
||||||
|
'F' => 30,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function styles(Worksheet $sheet)
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
// Style for the main header
|
||||||
|
|
||||||
|
// Style for section headers
|
||||||
|
10 => ['font' => ['bold' => true]], // A. Informasi Umum
|
||||||
|
34 => ['font' => ['bold' => true]], // B. Estimasi Nilai Tanah
|
||||||
|
35 => ['font' => ['bold' => true]], // C. Peta Lokasi
|
||||||
|
57 => ['font' => ['bold' => true]], // D. Foto Objek dan Pembanding
|
||||||
|
60 => ['font' => ['bold' => true]], // E. Foto Objek
|
||||||
|
|
||||||
|
// Default styling for columns
|
||||||
|
'A:J' => [
|
||||||
|
'alignment' => ['horizontal' => 'left', 'vertical' => 'center'],
|
||||||
|
'wrapText' => true,
|
||||||
|
],
|
||||||
|
|
||||||
|
// Style for other sections (like photo and map sections)
|
||||||
|
|
||||||
|
// Style for the other headers
|
||||||
|
'A11:F11' => [
|
||||||
|
'font' => ['bold' => true],
|
||||||
|
'fill' => ['fillType' => 'solid', 'color' => ['rgb' => 'E2EFDA']],
|
||||||
|
'borders' => [
|
||||||
|
'allBorders' => [
|
||||||
|
'borderStyle' => \PhpOffice\PhpSpreadsheet\Style\Border::BORDER_THIN
|
||||||
|
]
|
||||||
|
]
|
||||||
|
],
|
||||||
|
'A12:F31' => [
|
||||||
|
'borders' => [
|
||||||
|
'allBorders' => [
|
||||||
|
'borderStyle' => \PhpOffice\PhpSpreadsheet\Style\Border::BORDER_THIN
|
||||||
|
]
|
||||||
|
]
|
||||||
|
],
|
||||||
|
|
||||||
|
|
||||||
|
'A35:F35' => [
|
||||||
|
'font' => ['bold' => true],
|
||||||
|
'fill' => ['fillType' => 'solid', 'color' => ['rgb' => 'E2EFDA']],
|
||||||
|
'borders' => [
|
||||||
|
'allBorders' => [
|
||||||
|
'borderStyle' => \PhpOffice\PhpSpreadsheet\Style\Border::BORDER_THIN
|
||||||
|
]
|
||||||
|
]
|
||||||
|
],
|
||||||
|
'A35:F49' => [
|
||||||
|
'borders' => [
|
||||||
|
'allBorders' => [
|
||||||
|
'borderStyle' => \PhpOffice\PhpSpreadsheet\Style\Border::BORDER_THIN
|
||||||
|
]
|
||||||
|
]
|
||||||
|
],
|
||||||
|
|
||||||
|
// end header
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
protected function insertImages($sheet)
|
||||||
|
{
|
||||||
|
ini_set('max_execution_time', '300');
|
||||||
|
|
||||||
|
$worksheet = $sheet->getDelegate();
|
||||||
|
|
||||||
|
// Insert images for pembanding1
|
||||||
|
if (!empty($this->data['pembanding1']['foto_objek'])) {
|
||||||
|
$drawing = new Drawing();
|
||||||
|
$drawing->setName('Pembanding 1');
|
||||||
|
$drawing->setDescription('Foto Objek Pembanding 1');
|
||||||
|
$drawing->setPath(storage_path('app/public/' . $this->data['pembanding1']['foto_objek'])); // Adjust path as needed
|
||||||
|
$drawing->setHeight(90);
|
||||||
|
$drawing->setCoordinates('C' . (count($this->collection()) + 2)); // Adjust coordinates as needed
|
||||||
|
$drawing->setWorksheet($worksheet);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Repeat for pembanding2 and pembanding3
|
||||||
|
if (!empty($this->data['pembanding2']['foto_objek'])) {
|
||||||
|
$drawing = new Drawing();
|
||||||
|
$drawing->setName('Pembanding 2');
|
||||||
|
$drawing->setDescription('Foto Objek Pembanding 2');
|
||||||
|
$drawing->setPath(storage_path('app/public/' . $this->data['pembanding2']['foto_objek'])); // Adjust path as needed
|
||||||
|
$drawing->setHeight(90);
|
||||||
|
$drawing->setCoordinates('C' . (count($this->collection()) + 4)); // Adjust coordinates as needed
|
||||||
|
$drawing->setWorksheet($worksheet);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!empty($this->data['pembanding3']['foto_objek'])) {
|
||||||
|
$drawing = new Drawing();
|
||||||
|
$drawing->setName('Pembanding 3');
|
||||||
|
$drawing->setDescription('Foto Objek Pembanding 3');
|
||||||
|
$drawing->setPath(storage_path('app/public/' . $this->data['pembanding3']['foto_objek'])); // Adjust path as needed
|
||||||
|
$drawing->setHeight(90);
|
||||||
|
$drawing->setCoordinates('C' . (count($this->collection()) + 6)); // Adjust coordinates as needed
|
||||||
|
$drawing->setWorksheet($worksheet);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Insert images for foto_objek
|
||||||
|
foreach ($this->data['foto_objek'] as $index => $foto) {
|
||||||
|
if (!empty($foto['foto_objek'])) {
|
||||||
|
$drawing = new Drawing();
|
||||||
|
$drawing->setName($foto['name_objek']);
|
||||||
|
$drawing->setDescription($foto['deskripsi_objek']);
|
||||||
|
$drawing->setPath(storage_path('app/public/' . $foto['foto_objek'])); // Adjust path as needed
|
||||||
|
$drawing->setHeight(90);
|
||||||
|
$drawing->setCoordinates('C' . (count($this->collection()) + (8 + $index * 2))); // Adjust coordinates as needed
|
||||||
|
$drawing->setWorksheet($worksheet);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
70
app/Exports/LaporanAdminKreditExport.php
Normal file
70
app/Exports/LaporanAdminKreditExport.php
Normal file
@@ -0,0 +1,70 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Modules\Lpj\Exports;
|
||||||
|
|
||||||
|
use Maatwebsite\Excel\Concerns\FromCollection;
|
||||||
|
use Maatwebsite\Excel\Concerns\WithColumnFormatting;
|
||||||
|
use Maatwebsite\Excel\Concerns\WithHeadings;
|
||||||
|
use Maatwebsite\Excel\Concerns\WithMapping;
|
||||||
|
use Modules\Lpj\Models\LaporanAdminKredit;
|
||||||
|
use PhpOffice\PhpSpreadsheet\Style\NumberFormat;
|
||||||
|
|
||||||
|
class LaporanAdminKreditExport implements WithColumnFormatting, WithHeadings, FromCollection, WithMapping
|
||||||
|
{
|
||||||
|
public function collection()
|
||||||
|
{
|
||||||
|
return LaporanAdminKredit::with('debiture')->get();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function map($row): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
$row->id,
|
||||||
|
$row->debiture->cif,
|
||||||
|
$row->debiture->name,
|
||||||
|
$row->debiture->branch->name,
|
||||||
|
$row->kode_register_t24,
|
||||||
|
$row->jenis_agunan,
|
||||||
|
$row->bukti_kepemilikan,
|
||||||
|
$row->alamat_agunan,
|
||||||
|
$row->nama_pemilik,
|
||||||
|
$row->tanggal_kunjungan,
|
||||||
|
$row->nilai_pasar_wajar,
|
||||||
|
$row->nilai_likuidasi,
|
||||||
|
$row->nama_penilai,
|
||||||
|
$row->created_at
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function headings(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'ID',
|
||||||
|
'CIF',
|
||||||
|
'Nama Debitur',
|
||||||
|
'Cabang',
|
||||||
|
'Kode Register T24',
|
||||||
|
'Jenis Agunan',
|
||||||
|
'Bukti Kepemilikan',
|
||||||
|
'Alamat Agunan',
|
||||||
|
'Nama Pemilik',
|
||||||
|
'Tanggal Kunjungan',
|
||||||
|
'Nilai Pasar Wajar',
|
||||||
|
'Nilai Likuidasi',
|
||||||
|
'Nama Penilai',
|
||||||
|
'Created At'
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function columnFormats(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'A' => NumberFormat::FORMAT_NUMBER,
|
||||||
|
'B' => NumberFormat::FORMAT_NUMBER,
|
||||||
|
'J' => NumberFormat::FORMAT_DATE_DDMMYYYY,
|
||||||
|
'K' => NumberFormat::FORMAT_NUMBER_COMMA_SEPARATED1,
|
||||||
|
'L' => NumberFormat::FORMAT_NUMBER_COMMA_SEPARATED1,
|
||||||
|
'M' => NumberFormat::FORMAT_DATE_DATETIME,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,288 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Modules\Lpj\Exports;
|
||||||
|
|
||||||
|
use Maatwebsite\Excel\Concerns\FromCollection;
|
||||||
|
use Maatwebsite\Excel\Concerns\WithHeadings;
|
||||||
|
use Maatwebsite\Excel\Concerns\WithMapping;
|
||||||
|
use Maatwebsite\Excel\Concerns\WithTitle;
|
||||||
|
use Maatwebsite\Excel\Concerns\WithCustomStartCell;
|
||||||
|
use Maatwebsite\Excel\Concerns\WithEvents;
|
||||||
|
use Maatwebsite\Excel\Events\AfterSheet;
|
||||||
|
use Modules\Lpj\Models\Permohonan;
|
||||||
|
use Modules\Lpj\Models\Branch;
|
||||||
|
use Illuminate\Support\Facades\Auth;
|
||||||
|
use Carbon\Carbon;
|
||||||
|
|
||||||
|
class LaporanHasilPenilaianJaminanInternalExternalExport implements FromCollection, WithHeadings, WithMapping, WithTitle, WithCustomStartCell, WithEvents
|
||||||
|
{
|
||||||
|
protected $request;
|
||||||
|
|
||||||
|
public function __construct($request)
|
||||||
|
{
|
||||||
|
$this->request = $request;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function collection()
|
||||||
|
{
|
||||||
|
$query = Permohonan::query();
|
||||||
|
$query = $query->where('status', 'done');
|
||||||
|
|
||||||
|
// Apply date range filter if provided
|
||||||
|
if ($this->request->has('start_date') || $this->request->has('end_date')) {
|
||||||
|
$query->whereBetween('tanggal_permohonan', [
|
||||||
|
$this->request->start_date ?? '1900-01-01',
|
||||||
|
$this->request->end_date ?? now()->toDateString()
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Apply branch filter if provided
|
||||||
|
if ($this->request->has('branch_id') && !empty($this->request->branch_id)) {
|
||||||
|
$query->where('branch_id', $this->request->branch_id);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($this->request->has('penilai_id') && !empty($this->request->penilai_id)) {
|
||||||
|
$request = $this->request; // Store in a local variable
|
||||||
|
$query->whereHas('penilaian._user_penilai.userPenilaiTeam', function($q) use ($request) {
|
||||||
|
$q->where('user_id', $request->penilai_id);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// Apply search filter if provided
|
||||||
|
if ($this->request->has('search') && !empty($this->request->search)) {
|
||||||
|
$search = $this->request->search;
|
||||||
|
$query->where(function ($q) use ($search) {
|
||||||
|
$q->where('nomor_registrasi', 'LIKE', '%' . $search . '%');
|
||||||
|
$q->orWhere('tanggal_permohonan', 'LIKE', '%' . $search . '%');
|
||||||
|
$q->orWhereRelation('user', 'name', 'LIKE', '%' . $search . '%');
|
||||||
|
$q->orWhereRelation('tujuanPenilaian', 'name', 'LIKE', '%' . $search . '%');
|
||||||
|
$q->orWhereRelation('branch', 'name', 'LIKE', '%' . $search . '%');
|
||||||
|
$q->orWhereRelation('jenisFasilitasKredit', 'name', 'LIKE', '%' . $search . '%');
|
||||||
|
$q->orWhereRelation('jenisPenilaian', 'name', 'LIKE', '%' . $search . '%');
|
||||||
|
$q->orWhere('status', 'LIKE', '%' . $search . '%');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// Default ordering
|
||||||
|
$query->orderBy('nomor_registrasi', 'asc');
|
||||||
|
|
||||||
|
return $query->get();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected $rowNumber = 0;
|
||||||
|
|
||||||
|
public function map($permohonan): array
|
||||||
|
{
|
||||||
|
$this->rowNumber++;
|
||||||
|
$luas_tanah = 0;
|
||||||
|
$luas_bangunan = 0;
|
||||||
|
$nilai_tanah = 0;
|
||||||
|
$nilai_bangunan = 0;
|
||||||
|
$npw = 0;
|
||||||
|
$nilai_liquidasi = 0;
|
||||||
|
|
||||||
|
if (isset($permohonan->penilai->lpj)) {
|
||||||
|
$lpj = json_decode($permohonan->penilai->lpj, true);
|
||||||
|
$npw = str_replace('.', '', $lpj['total_nilai_pasar_wajar'] ?? 0);
|
||||||
|
|
||||||
|
$luas_tanah = $lpj['luas_tanah'] ?? 0;
|
||||||
|
$luas_bangunan = $lpj['luas_bangunan'] ?? 0;
|
||||||
|
$nilai_tanah = str_replace('.', '', $lpj['nilai_tanah_2'] ?? 0);
|
||||||
|
$nilai_bangunan = str_replace('.', '', $lpj['nilai_bangunan_2'] ?? 0);
|
||||||
|
$nilai_liquidasi = str_replace('.', '', $lpj['likuidasi_nilai_2'] ?? 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
return [
|
||||||
|
$this->rowNumber,
|
||||||
|
$permohonan->nomor_registrasi,
|
||||||
|
$permohonan->tanggal_permohonan,
|
||||||
|
$permohonan->debiture->branch->name,
|
||||||
|
$permohonan->creator->name,
|
||||||
|
$permohonan->debiture->cif,
|
||||||
|
$permohonan->debiture->name,
|
||||||
|
$permohonan->jenisPenilaian->name,
|
||||||
|
$permohonan->tujuanPenilaian->name,
|
||||||
|
$permohonan->jenisFasilitasKredit->name,
|
||||||
|
$permohonan->documents->pluck('jenisJaminan.name')->unique()->implode(', '),
|
||||||
|
$permohonan->documents->map(function ($document) {
|
||||||
|
return formatAlamat($document);
|
||||||
|
})->unique()->implode(', '),
|
||||||
|
$permohonan->documents->flatMap(function ($document) {
|
||||||
|
return $document->detail->map(function ($detail) {
|
||||||
|
return (!empty($detail->dokumen_nomor) && is_array($detail->dokumen_nomor))
|
||||||
|
? ($detail->jenisLegalitasJaminan->name ?? '') . "\n" . implode(', ', $detail->dokumen_nomor)
|
||||||
|
: null;
|
||||||
|
});
|
||||||
|
})->filter()->unique()->implode(', '),
|
||||||
|
$permohonan->documents->pluck('pemilik.name')->unique()->implode(', '),
|
||||||
|
$luas_tanah . ' m²',
|
||||||
|
formatRupiah($nilai_tanah, 2),
|
||||||
|
$luas_bangunan . ' m²',
|
||||||
|
formatRupiah($nilai_bangunan, 2),
|
||||||
|
formatRupiah($permohonan->nilai_njop ?? 0, 2),
|
||||||
|
formatRupiah($npw, 2),
|
||||||
|
formatRupiah($nilai_liquidasi, 2),
|
||||||
|
$permohonan->documents->map(function ($document) {
|
||||||
|
return formatTanggalIndonesia($document->created_at);
|
||||||
|
})->first(),
|
||||||
|
'', // tanggal_spk
|
||||||
|
'', // nomor_spk
|
||||||
|
'', // tanggal_rencana_kunjungan
|
||||||
|
$permohonan->penilaian->tanggal_kunjungan ? formatTanggalIndonesia($permohonan->penilaian->tanggal_kunjungan) : '',
|
||||||
|
'', // tanggal_delivered
|
||||||
|
'', // jangka_waktu_sla
|
||||||
|
($permohonan->approval_dd_at || $permohonan->approval_eo_at) ?
|
||||||
|
formatTanggalIndonesia($permohonan->approval_dd_at ?? $permohonan->approval_eo_at) : '',
|
||||||
|
$permohonan->penilaian->tanggal_kunjungan ? formatTanggalIndonesia($permohonan->penilaian->tanggal_kunjungan) : '',
|
||||||
|
$permohonan->penilaian->_user_penilai->userPenilaiTeam->name ?? '',
|
||||||
|
$permohonan->penilaian->teams ?? '',
|
||||||
|
'', // saran
|
||||||
|
'' // catatan
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function headings(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'No',
|
||||||
|
'Nomor Registrasi',
|
||||||
|
'Tanggal Permohonan',
|
||||||
|
'Cabang',
|
||||||
|
'Pemohon',
|
||||||
|
'CIF',
|
||||||
|
'Nama Debitur',
|
||||||
|
'Jenis Penilaian',
|
||||||
|
'Tujuan Penilaian',
|
||||||
|
'Jenis Fasilitas Kredit',
|
||||||
|
'Jenis Agunan',
|
||||||
|
'Alamat Agunan',
|
||||||
|
'Bukti Kepemilikan',
|
||||||
|
'Nama Pemilik',
|
||||||
|
'Luas Tanah',
|
||||||
|
'Nilai Tanah',
|
||||||
|
'Luas Bangunan',
|
||||||
|
'Nilai Bangunan',
|
||||||
|
'Nilai NJOP',
|
||||||
|
'Nilai Pasar Wajar',
|
||||||
|
'Nilai Likuidasi',
|
||||||
|
'Tanggal Dokumen Diterima',
|
||||||
|
'Tanggal SPK',
|
||||||
|
'Nomor SPK',
|
||||||
|
'Tanggal Rencana Kunjungan',
|
||||||
|
'Tanggal Kunjungan',
|
||||||
|
'Tanggal Delivered',
|
||||||
|
'Jangka Waktu SLA',
|
||||||
|
'Tanggal Laporan',
|
||||||
|
'Tanggal Review',
|
||||||
|
'Nama Penilai',
|
||||||
|
'Nama Team Leader',
|
||||||
|
'Saran',
|
||||||
|
'Catatan'
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function title(): string
|
||||||
|
{
|
||||||
|
return 'Laporan Hasil Penilaian Jaminan Internal & External';
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function startCell(): string
|
||||||
|
{
|
||||||
|
return 'A7';
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function registerEvents(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
AfterSheet::class => function(AfterSheet $event) {
|
||||||
|
// Get the sheet
|
||||||
|
$sheet = $event->sheet->getDelegate();
|
||||||
|
|
||||||
|
// Set the title
|
||||||
|
$sheet->setCellValue('A1', 'LAPORAN PENILAIAN JAMINAN');
|
||||||
|
$sheet->getStyle('A1')->getFont()->setBold(true)->setSize(16);
|
||||||
|
|
||||||
|
// Merge cells for title
|
||||||
|
$sheet->mergeCells('A1:AH1');
|
||||||
|
$sheet->getStyle('A1')->getAlignment()->setHorizontal(\PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_CENTER);
|
||||||
|
|
||||||
|
// Set the branch information if filtered
|
||||||
|
$branchInfo = '';
|
||||||
|
if ($this->request->has('branch_id') && !empty($this->request->branch_id)) {
|
||||||
|
$branch = Branch::find($this->request->branch_id);
|
||||||
|
if ($branch) {
|
||||||
|
$branchInfo = 'Cabang: ' . $branch->name;
|
||||||
|
$sheet->setCellValue('A2', $branchInfo);
|
||||||
|
$sheet->mergeCells('A2:AH2');
|
||||||
|
$sheet->getStyle('A2')->getAlignment()->setHorizontal(\PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_CENTER);
|
||||||
|
$sheet->getStyle('A2')->getFont()->setBold(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Set the period
|
||||||
|
$startDate = $this->request->start_date ?? '';
|
||||||
|
$endDate = $this->request->end_date ?? '';
|
||||||
|
|
||||||
|
$rowIndex = $branchInfo ? 3 : 2;
|
||||||
|
|
||||||
|
if ($startDate && $endDate) {
|
||||||
|
$startDateFormatted = Carbon::parse($startDate)->format('d F Y');
|
||||||
|
$endDateFormatted = Carbon::parse($endDate)->format('d F Y');
|
||||||
|
$sheet->setCellValue('A' . $rowIndex, 'Periode: ' . $startDateFormatted . ' - ' . $endDateFormatted);
|
||||||
|
} else {
|
||||||
|
$sheet->setCellValue('A' . $rowIndex, 'Periode: Semua Data');
|
||||||
|
}
|
||||||
|
$sheet->mergeCells('A' . $rowIndex . ':AH' . $rowIndex);
|
||||||
|
$sheet->getStyle('A' . $rowIndex)->getAlignment()->setHorizontal(\PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_CENTER);
|
||||||
|
|
||||||
|
// Set the date of export
|
||||||
|
$rowIndex++;
|
||||||
|
$sheet->setCellValue('A' . $rowIndex, 'Tanggal Export: ' . Carbon::now()->format('d F Y H:i:s'));
|
||||||
|
|
||||||
|
// Set the user who exported
|
||||||
|
$rowIndex++;
|
||||||
|
$userName = Auth::user() ? Auth::user()->name : 'System';
|
||||||
|
$sheet->setCellValue('A' . $rowIndex, 'Diexport oleh: ' . $userName);
|
||||||
|
|
||||||
|
// Add a blank line
|
||||||
|
$rowIndex++;
|
||||||
|
$sheet->setCellValue('A' . $rowIndex, '');
|
||||||
|
|
||||||
|
// Style the header row
|
||||||
|
$headerRange = 'A7:' . $sheet->getHighestColumn() . '7';
|
||||||
|
$sheet->getStyle($headerRange)->getFont()->setBold(true);
|
||||||
|
$sheet->getStyle($headerRange)->getFill()
|
||||||
|
->setFillType(\PhpOffice\PhpSpreadsheet\Style\Fill::FILL_SOLID)
|
||||||
|
->getStartColor()->setARGB('FFCCCCCC');
|
||||||
|
|
||||||
|
// Auto-size columns - fixed to handle columns beyond Z
|
||||||
|
$highestColumn = $sheet->getHighestColumn();
|
||||||
|
$highestColumnIndex = \PhpOffice\PhpSpreadsheet\Cell\Coordinate::columnIndexFromString($highestColumn);
|
||||||
|
|
||||||
|
for ($i = 1; $i <= $highestColumnIndex; $i++) {
|
||||||
|
$currentColumn = \PhpOffice\PhpSpreadsheet\Cell\Coordinate::stringFromColumnIndex($i);
|
||||||
|
$sheet->getColumnDimension($currentColumn)->setAutoSize(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add borders to all cells with data
|
||||||
|
$dataRange = 'A7:' . $sheet->getHighestColumn() . $sheet->getHighestRow();
|
||||||
|
$sheet->getStyle($dataRange)->getBorders()->getAllBorders()->setBorderStyle(\PhpOffice\PhpSpreadsheet\Style\Border::BORDER_THIN);
|
||||||
|
|
||||||
|
// Center align the header row
|
||||||
|
$sheet->getStyle($headerRange)->getAlignment()->setHorizontal(\PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_CENTER);
|
||||||
|
|
||||||
|
// Set text wrap for header cells
|
||||||
|
$sheet->getStyle($headerRange)->getAlignment()->setWrapText(true);
|
||||||
|
},
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
102
app/Exports/LaporanPembatalanExport.php
Normal file
102
app/Exports/LaporanPembatalanExport.php
Normal file
@@ -0,0 +1,102 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Modules\Lpj\Exports;
|
||||||
|
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Facades\Auth;
|
||||||
|
use Maatwebsite\Excel\Concerns\FromCollection;
|
||||||
|
use Maatwebsite\Excel\Concerns\WithHeadings;
|
||||||
|
use Maatwebsite\Excel\Concerns\WithMapping;
|
||||||
|
use Modules\Lpj\Models\PermohonanPembatalan;
|
||||||
|
|
||||||
|
class LaporanPembatalanExport implements FromCollection, WithHeadings, WithMapping
|
||||||
|
{
|
||||||
|
protected $request;
|
||||||
|
|
||||||
|
public function __construct(Request $request)
|
||||||
|
{
|
||||||
|
$this->request = $request;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function collection()
|
||||||
|
{
|
||||||
|
$query = PermohonanPembatalan::where('status', 'batal');
|
||||||
|
|
||||||
|
if (!Auth::user()->hasAnyRole(['administrator'])) {
|
||||||
|
$query = $query->whereHas('permohonan', function ($q) {
|
||||||
|
$q->where('branch_id', Auth::user()->branch_id);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// Apply search filter if provided
|
||||||
|
if ($this->request->has('search') && !empty($this->request->get('search'))) {
|
||||||
|
$search = $this->request->get('search');
|
||||||
|
$query->where(function ($q) use ($search) {
|
||||||
|
$q->whereHas('permohonan', function ($subq) use ($search) {
|
||||||
|
$subq->where('nomor_registrasi', 'LIKE', '%' . $search . '%');
|
||||||
|
$subq->orWhereRelation('user', 'name', 'LIKE', '%' . $search . '%');
|
||||||
|
$subq->orWhereRelation('branch', 'name', 'LIKE', '%' . $search . '%');
|
||||||
|
});
|
||||||
|
$q->orWhere('alasan', 'LIKE', '%' . $search . '%');
|
||||||
|
$q->orWhere('status', 'LIKE', '%' . $search . '%');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// Filter by date range if provided
|
||||||
|
if ($this->request->has('start_date') || $this->request->has('end_date')) {
|
||||||
|
$query->whereBetween('created_at', [
|
||||||
|
$this->request->get('start_date') ?? '1900-01-01',
|
||||||
|
$this->request->get('end_date') ?? now()->toDateString()
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Filter by status if provided
|
||||||
|
if ($this->request->has('status') && !empty($this->request->get('status'))) {
|
||||||
|
$query->where('status', $this->request->get('status'));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Filter by branch if provided
|
||||||
|
if ($this->request->has('branch_id') && !empty($this->request->get('branch_id'))) {
|
||||||
|
$query->whereHas('permohonan', function ($q) {
|
||||||
|
$q->where('branch_id', $this->request->get('branch_id'));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
return $query->orderBy('created_at', 'desc')
|
||||||
|
->get();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function headings(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'No. Registrasi',
|
||||||
|
'Tanggal Permohonan',
|
||||||
|
'Tanggal Pembatalan',
|
||||||
|
'Cabang',
|
||||||
|
'Pemohon',
|
||||||
|
'Debitur',
|
||||||
|
'Alasan Pembatalan',
|
||||||
|
'Status',
|
||||||
|
'Diajukan Oleh',
|
||||||
|
'Disetujui Oleh',
|
||||||
|
'Tanggal Disetujui'
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function map($pembatalan): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
$pembatalan->permohonan->nomor_registrasi ?? '-',
|
||||||
|
$pembatalan->permohonan->tanggal_permohonan ? date('d-m-Y', strtotime($pembatalan->permohonan->tanggal_permohonan)) : '-',
|
||||||
|
date('d-m-Y', strtotime($pembatalan->created_at)),
|
||||||
|
$pembatalan->permohonan->branch->name ?? '-',
|
||||||
|
$pembatalan->permohonan->user->name ?? '-',
|
||||||
|
$pembatalan->permohonan->debiture->name ?? '-',
|
||||||
|
$pembatalan->alasan_pembatalan,
|
||||||
|
$pembatalan->status,
|
||||||
|
$pembatalan->user->name ?? '-',
|
||||||
|
$pembatalan->authorized_by ? $pembatalan->authorizedUser->name : '-',
|
||||||
|
$pembatalan->authorized_at ? formatTanggalIndonesia(strtotime($pembatalan->authorized_at),1) : '-'
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
177
app/Exports/LaporanPenilaiJaminanExport.php
Normal file
177
app/Exports/LaporanPenilaiJaminanExport.php
Normal file
@@ -0,0 +1,177 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Modules\Lpj\Exports;
|
||||||
|
|
||||||
|
use Maatwebsite\Excel\Concerns\FromQuery;
|
||||||
|
use Maatwebsite\Excel\Concerns\WithHeadings;
|
||||||
|
use Maatwebsite\Excel\Concerns\WithMapping;
|
||||||
|
use Maatwebsite\Excel\Concerns\ShouldAutoSize;
|
||||||
|
use Illuminate\Database\Eloquent\Builder;
|
||||||
|
use PhpOffice\PhpSpreadsheet\Style\NumberFormat;
|
||||||
|
use Modules\Lpj\Models\Debiture;
|
||||||
|
use Modules\Lpj\Models\Permohonan;
|
||||||
|
use Modules\Lpj\Helpers\Lpj;
|
||||||
|
|
||||||
|
class LaporanPenilaiJaminanExport implements FromQuery, WithHeadings, WithMapping, ShouldAutoSize
|
||||||
|
{
|
||||||
|
protected $tanggalAwal;
|
||||||
|
protected $tanggalAkhir;
|
||||||
|
protected $status;
|
||||||
|
protected $selectedIds;
|
||||||
|
|
||||||
|
public function __construct($tanggalAwal = null, $tanggalAkhir = null, $status = null, $selectedIds = null)
|
||||||
|
{
|
||||||
|
$this->tanggalAwal = $tanggalAwal;
|
||||||
|
$this->tanggalAkhir = $tanggalAkhir;
|
||||||
|
$this->status = $status;
|
||||||
|
$this->selectedIds = $selectedIds;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public function query()
|
||||||
|
{
|
||||||
|
$query = Permohonan::query()
|
||||||
|
->with(['user', 'debiture', 'branch', 'tujuanPenilaian', 'penilaian', 'dokumenjaminan.jenisJaminan','nilaiPlafond', 'penilai', 'inspeksi']);
|
||||||
|
|
||||||
|
// Filter by date range if provided
|
||||||
|
if ($this->tanggalAwal && $this->tanggalAkhir) {
|
||||||
|
$query->whereBetween('tanggal_permohonan', [$this->tanggalAwal, $this->tanggalAkhir]);
|
||||||
|
}
|
||||||
|
|
||||||
|
$query->where('status', 'done');
|
||||||
|
// Filter by status if provided
|
||||||
|
if ($this->status) {
|
||||||
|
$types = is_array($this->status) ? $this->status : [$this->status];
|
||||||
|
$types = array_map('strtolower', $types);
|
||||||
|
$query->whereHas('penilai', function (Builder $query) use ($types) {
|
||||||
|
$query->whereIn('type_penilai', $types);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Filter by selected IDs if provided
|
||||||
|
if ($this->selectedIds) {
|
||||||
|
$selectedIds = is_array($this->selectedIds) ? $this->selectedIds : explode(',', $this->selectedIds);
|
||||||
|
$query->whereIn('id', $selectedIds);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $query;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public function map($row): array
|
||||||
|
{
|
||||||
|
|
||||||
|
// ambil data alamat dari inspeksi
|
||||||
|
$alamat_inspeksi = null;
|
||||||
|
|
||||||
|
if ($row->inspeksi) {
|
||||||
|
$alamat_inspeksi = json_decode($row->inspeksi->data_form, true) ?? null;
|
||||||
|
$alamat_inspeksi = $alamat_inspeksi['asset']['alamat']['sesuai'] ?? $alamat_inspeksi['asset']['alamat']['tidak sesuai'] ?? [];
|
||||||
|
}
|
||||||
|
$alamat_inspeksi = $alamat_inspeksi['address'] ?? '-';
|
||||||
|
|
||||||
|
|
||||||
|
// ambil data dari table penilai
|
||||||
|
$fieldPenilai = ['lpj', 'resume', 'memo', 'rap', 'call-report'];
|
||||||
|
$penilaiCek = null;
|
||||||
|
|
||||||
|
// Cari field yang tersedia
|
||||||
|
foreach ($fieldPenilai as $value) {
|
||||||
|
if (!empty($row->penilai->$value)) {
|
||||||
|
$penilaiCek = $row->penilai->$value;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$decodePenilai = json_decode($penilaiCek, true) ?? [];
|
||||||
|
// Ambil nilai utama
|
||||||
|
$luasTanah = $decodePenilai['luas_tanah'] ?? 0;
|
||||||
|
$nilaiTanah1 = $decodePenilai['nilai_tanah_1'] ?? 0;
|
||||||
|
$luasBangunan = $decodePenilai['luas_bangunan'] ?? 0;
|
||||||
|
$nilaiBangunan1 = $decodePenilai['nilai_bangunan_1'] ?? 0;
|
||||||
|
$totalNilaiPasar = $decodePenilai['total_nilai_pasar_wajar'] ?? 0;
|
||||||
|
$likuidasi = $decodePenilai['likuidasi'] ?? 0;
|
||||||
|
|
||||||
|
// Ambil data npw_tambahan jika ada
|
||||||
|
$npwTambahan = $decodePenilai['npw_tambahan'] ?? [];
|
||||||
|
$tambahanDetails = [];
|
||||||
|
foreach ($npwTambahan as $tambahan) {
|
||||||
|
$tambahanDetails[] = sprintf(
|
||||||
|
'%s: Luas: %s, Nilai 1: %s, Nilai 2: %s',
|
||||||
|
$tambahan['name'] ?? '-',
|
||||||
|
$tambahan['luas'] ?? 0,
|
||||||
|
$tambahan['nilai_1'] ?? 0,
|
||||||
|
$tambahan['nilai_2'] ?? 0
|
||||||
|
);
|
||||||
|
}
|
||||||
|
$tambahanSummary = implode("; ", $tambahanDetails);
|
||||||
|
|
||||||
|
// Ambil data penilaian dari table penilaian
|
||||||
|
$user_penilai = $row->penilaian->userPenilai ?? null;
|
||||||
|
$user_penilai_name = null;
|
||||||
|
foreach ($user_penilai as $value) {
|
||||||
|
if ($value->role == 'penilai') {
|
||||||
|
$user_penilai_name = $value->user->name;
|
||||||
|
$nik_penilai = $value->user->nik ?? '-';
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
return [
|
||||||
|
$row->id,
|
||||||
|
$row->nomor_registrasi,
|
||||||
|
$row->user->name,
|
||||||
|
$row->branch->name,
|
||||||
|
$row->tujuanPenilaian->name,
|
||||||
|
$row->debiture->name,
|
||||||
|
$row->penilai->type_penilai ?? '-',
|
||||||
|
$alamat_inspeksi ?? '-',
|
||||||
|
$luasTanah,
|
||||||
|
$luasBangunan,
|
||||||
|
$nilaiTanah1,
|
||||||
|
$nilaiBangunan1,
|
||||||
|
$totalNilaiPasar,
|
||||||
|
$likuidasi,
|
||||||
|
$row->laporan->created_at ?? '-',
|
||||||
|
$user_penilai_name,
|
||||||
|
$nik_penilai,
|
||||||
|
$row->created_at,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public function headings(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'ID',
|
||||||
|
'Nomor Registrasi',
|
||||||
|
'User Pemohon',
|
||||||
|
'Cabang',
|
||||||
|
'Tujuan Penilaian',
|
||||||
|
'Debitur',
|
||||||
|
'Jenis Laporan',
|
||||||
|
'Lokasi Jaminan',
|
||||||
|
'Luas Tanah',
|
||||||
|
'Luas Bangunan',
|
||||||
|
'Harga Tanah',
|
||||||
|
'Harga Bangunan',
|
||||||
|
'Nilai Pasar Wajar',
|
||||||
|
'Likuidasi',
|
||||||
|
'Tanggal Laporan',
|
||||||
|
'Nama Penilai',
|
||||||
|
'Nik Penilai',
|
||||||
|
'Created At',
|
||||||
|
];
|
||||||
|
}
|
||||||
|
public function columnFormats(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'A' => NumberFormat::FORMAT_NUMBER,
|
||||||
|
'C' => NumberFormat::FORMAT_DATE_DATETIME,
|
||||||
|
'K' => NumberFormat::FORMAT_DATE_DATETIME,
|
||||||
|
'N' => NumberFormat::FORMAT_DATE_DATETIME
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
245
app/Exports/LaporanPenilaianJaminanExport.php
Normal file
245
app/Exports/LaporanPenilaianJaminanExport.php
Normal file
@@ -0,0 +1,245 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Modules\Lpj\Exports;
|
||||||
|
|
||||||
|
use Maatwebsite\Excel\Concerns\FromCollection;
|
||||||
|
use Maatwebsite\Excel\Concerns\WithHeadings;
|
||||||
|
use Maatwebsite\Excel\Concerns\WithMapping;
|
||||||
|
use Maatwebsite\Excel\Concerns\WithTitle;
|
||||||
|
use Maatwebsite\Excel\Concerns\WithCustomStartCell;
|
||||||
|
use Maatwebsite\Excel\Concerns\WithEvents;
|
||||||
|
use Maatwebsite\Excel\Events\AfterSheet;
|
||||||
|
use Modules\Lpj\Models\Permohonan;
|
||||||
|
use Modules\Lpj\Models\Branch;
|
||||||
|
use Illuminate\Support\Facades\Auth;
|
||||||
|
use Carbon\Carbon;
|
||||||
|
|
||||||
|
class LaporanPenilaianJaminanExport implements FromCollection, WithHeadings, WithMapping, WithTitle, WithCustomStartCell, WithEvents
|
||||||
|
{
|
||||||
|
protected $request;
|
||||||
|
|
||||||
|
public function __construct($request)
|
||||||
|
{
|
||||||
|
$this->request = $request;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function collection()
|
||||||
|
{
|
||||||
|
$query = Permohonan::query();
|
||||||
|
$query = $query->where('status', 'done');
|
||||||
|
|
||||||
|
// Apply date range filter if provided
|
||||||
|
if ($this->request->has('start_date') || $this->request->has('end_date')) {
|
||||||
|
$query->whereBetween('tanggal_permohonan', [
|
||||||
|
$this->request->start_date ?? '1900-01-01',
|
||||||
|
$this->request->end_date ?? now()->toDateString()
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Apply branch filter if provided
|
||||||
|
if ($this->request->has('branch_id') && !empty($this->request->branch_id)) {
|
||||||
|
$query->where('branch_id', $this->request->branch_id);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($this->request->has('penilai_id') && !empty($this->request->penilai_id)) {
|
||||||
|
$request = $this->request; // Store in a local variable
|
||||||
|
$query->whereHas('penilaian._user_penilai.userPenilaiTeam', function($q) use ($request) {
|
||||||
|
$q->where('user_id', $request->penilai_id);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// Apply search filter if provided
|
||||||
|
if ($this->request->has('search') && !empty($this->request->search)) {
|
||||||
|
$search = $this->request->search;
|
||||||
|
$query->where(function ($q) use ($search) {
|
||||||
|
$q->where('nomor_registrasi', 'LIKE', '%' . $search . '%');
|
||||||
|
$q->orWhere('tanggal_permohonan', 'LIKE', '%' . $search . '%');
|
||||||
|
$q->orWhereRelation('user', 'name', 'LIKE', '%' . $search . '%');
|
||||||
|
$q->orWhereRelation('tujuanPenilaian', 'name', 'LIKE', '%' . $search . '%');
|
||||||
|
$q->orWhereRelation('branch', 'name', 'LIKE', '%' . $search . '%');
|
||||||
|
$q->orWhereRelation('jenisFasilitasKredit', 'name', 'LIKE', '%' . $search . '%');
|
||||||
|
$q->orWhereRelation('jenisPenilaian', 'name', 'LIKE', '%' . $search . '%');
|
||||||
|
$q->orWhere('status', 'LIKE', '%' . $search . '%');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// Default ordering
|
||||||
|
$query->orderBy('nomor_registrasi', 'asc');
|
||||||
|
|
||||||
|
return $query->with(['debiture.branch'])->get();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected $rowNumber = 0;
|
||||||
|
|
||||||
|
public function map($permohonan): array
|
||||||
|
{
|
||||||
|
$this->rowNumber++;
|
||||||
|
$luas_tanah = 0;
|
||||||
|
$luas_bangunan = 0;
|
||||||
|
$nilai_tanah = 0;
|
||||||
|
$nilai_bangunan = 0;
|
||||||
|
$npw = 0;
|
||||||
|
$nilai_liquidasi = 0;
|
||||||
|
|
||||||
|
if (isset($permohonan->penilai->lpj)) {
|
||||||
|
$lpj = json_decode($permohonan->penilai->lpj, true);
|
||||||
|
$npw = str_replace('.', '', $lpj['total_nilai_pasar_wajar'] ?? 0);
|
||||||
|
|
||||||
|
$luas_tanah = $lpj['luas_tanah'] ?? 0;
|
||||||
|
$luas_bangunan = $lpj['luas_bangunan'] ?? 0;
|
||||||
|
$nilai_tanah = str_replace('.', '', $lpj['nilai_tanah_2'] ?? 0);
|
||||||
|
$nilai_bangunan = str_replace('.', '', $lpj['nilai_bangunan_2'] ?? 0);
|
||||||
|
$nilai_liquidasi = str_replace('.', '', $lpj['likuidasi_nilai_2'] ?? 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
return [
|
||||||
|
$this->rowNumber,
|
||||||
|
$permohonan->nomor_registrasi,
|
||||||
|
$permohonan->tanggal_permohonan,
|
||||||
|
$permohonan->debiture->branch->name,
|
||||||
|
$permohonan->debiture->name,
|
||||||
|
$permohonan->creator->name,
|
||||||
|
$permohonan->tujuanPenilaian->name,
|
||||||
|
$permohonan->documents->pluck('jenisJaminan.name')->unique()->implode(', '),
|
||||||
|
$permohonan->documents->map(function ($document) {
|
||||||
|
return formatAlamat($document);
|
||||||
|
})->unique()->implode(', '),
|
||||||
|
$luas_tanah . ' m²',
|
||||||
|
formatRupiah($nilai_tanah, 2),
|
||||||
|
$luas_bangunan . ' m²',
|
||||||
|
formatRupiah($nilai_bangunan, 2),
|
||||||
|
($permohonan->approval_dd_at || $permohonan->approval_eo_at) ?
|
||||||
|
formatTanggalIndonesia($permohonan->approval_dd_at ?? $permohonan->approval_eo_at) : '',
|
||||||
|
$permohonan->penilaian->tanggal_kunjungan ?
|
||||||
|
formatTanggalIndonesia($permohonan->penilaian->tanggal_kunjungan) : '',
|
||||||
|
formatRupiah($npw, 2),
|
||||||
|
formatRupiah($nilai_liquidasi, 2),
|
||||||
|
$permohonan->penilaian->_user_penilai->userPenilaiTeam->name,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function headings(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'No',
|
||||||
|
'Nomor Registrasi',
|
||||||
|
'Tanggal Permohonan',
|
||||||
|
'Cabang',
|
||||||
|
'Nama Debitur',
|
||||||
|
'Pemohon',
|
||||||
|
'Tujuan Penilaian',
|
||||||
|
'Jenis Agunan',
|
||||||
|
'Alamat Agunan',
|
||||||
|
'Luas Tanah',
|
||||||
|
'Nilai Tanah',
|
||||||
|
'Luas Bangunan',
|
||||||
|
'Nilai Bangunan',
|
||||||
|
'Tanggal Laporan',
|
||||||
|
'Tanggal Review',
|
||||||
|
'Nilai Pasar Wajar',
|
||||||
|
'Nilai Likuidasi',
|
||||||
|
'Nama Penilai',
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function title(): string
|
||||||
|
{
|
||||||
|
return 'Laporan Penilaian Jaminan';
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function startCell(): string
|
||||||
|
{
|
||||||
|
return 'A7';
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function registerEvents(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
AfterSheet::class => function(AfterSheet $event) {
|
||||||
|
// Get the sheet
|
||||||
|
$sheet = $event->sheet->getDelegate();
|
||||||
|
|
||||||
|
// Set the title
|
||||||
|
$sheet->setCellValue('A1', 'LAPORAN PENILAIAN JAMINAN');
|
||||||
|
$sheet->getStyle('A1')->getFont()->setBold(true)->setSize(16);
|
||||||
|
|
||||||
|
// Merge cells for title
|
||||||
|
$sheet->mergeCells('A1:R1');
|
||||||
|
$sheet->getStyle('A1')->getAlignment()->setHorizontal(\PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_CENTER);
|
||||||
|
|
||||||
|
// Set the branch information if filtered
|
||||||
|
$branchInfo = '';
|
||||||
|
if ($this->request->has('branch_id') && !empty($this->request->branch_id)) {
|
||||||
|
$branch = Branch::find($this->request->branch_id);
|
||||||
|
if ($branch) {
|
||||||
|
$branchInfo = 'Cabang: ' . $branch->name;
|
||||||
|
$sheet->setCellValue('A2', $branchInfo);
|
||||||
|
$sheet->mergeCells('A2:R2');
|
||||||
|
$sheet->getStyle('A2')->getAlignment()->setHorizontal(\PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_CENTER);
|
||||||
|
$sheet->getStyle('A2')->getFont()->setBold(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Set the period
|
||||||
|
$startDate = $this->request->start_date ?? '';
|
||||||
|
$endDate = $this->request->end_date ?? '';
|
||||||
|
|
||||||
|
$rowIndex = $branchInfo ? 3 : 2;
|
||||||
|
|
||||||
|
if ($startDate && $endDate) {
|
||||||
|
$startDateFormatted = Carbon::parse($startDate)->format('d F Y');
|
||||||
|
$endDateFormatted = Carbon::parse($endDate)->format('d F Y');
|
||||||
|
$sheet->setCellValue('A' . $rowIndex, 'Periode: ' . $startDateFormatted . ' - ' . $endDateFormatted);
|
||||||
|
} else {
|
||||||
|
$sheet->setCellValue('A' . $rowIndex, 'Periode: Semua Data');
|
||||||
|
}
|
||||||
|
$sheet->mergeCells('A' . $rowIndex . ':R' . $rowIndex);
|
||||||
|
$sheet->getStyle('A' . $rowIndex)->getAlignment()->setHorizontal(\PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_CENTER);
|
||||||
|
|
||||||
|
// Set the date of export
|
||||||
|
$rowIndex++;
|
||||||
|
$sheet->setCellValue('A' . $rowIndex, 'Tanggal Export: ' . Carbon::now()->format('d F Y H:i:s'));
|
||||||
|
|
||||||
|
// Set the user who exported
|
||||||
|
$rowIndex++;
|
||||||
|
$userName = Auth::user() ? Auth::user()->name : 'System';
|
||||||
|
$sheet->setCellValue('A' . $rowIndex, 'Diexport oleh: ' . $userName);
|
||||||
|
|
||||||
|
// Add a blank line
|
||||||
|
$rowIndex++;
|
||||||
|
$sheet->setCellValue('A' . $rowIndex, '');
|
||||||
|
|
||||||
|
// Style the header row
|
||||||
|
$headerRange = 'A7:' . $sheet->getHighestColumn() . '7';
|
||||||
|
$sheet->getStyle($headerRange)->getFont()->setBold(true);
|
||||||
|
$sheet->getStyle($headerRange)->getFill()
|
||||||
|
->setFillType(\PhpOffice\PhpSpreadsheet\Style\Fill::FILL_SOLID)
|
||||||
|
->getStartColor()->setARGB('FFCCCCCC');
|
||||||
|
|
||||||
|
// Auto-size columns
|
||||||
|
foreach(range('A', $sheet->getHighestColumn()) as $column) {
|
||||||
|
$sheet->getColumnDimension($column)->setAutoSize(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add borders to all cells with data
|
||||||
|
$dataRange = 'A7:' . $sheet->getHighestColumn() . $sheet->getHighestRow();
|
||||||
|
$sheet->getStyle($dataRange)->getBorders()->getAllBorders()->setBorderStyle(\PhpOffice\PhpSpreadsheet\Style\Border::BORDER_THIN);
|
||||||
|
|
||||||
|
// Center align the header row
|
||||||
|
$sheet->getStyle($headerRange)->getAlignment()->setHorizontal(\PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_CENTER);
|
||||||
|
|
||||||
|
// Set text wrap for header cells
|
||||||
|
$sheet->getStyle($headerRange)->getAlignment()->setWrapText(true);
|
||||||
|
},
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
98
app/Exports/LaporanPermohonanExport.php
Normal file
98
app/Exports/LaporanPermohonanExport.php
Normal file
@@ -0,0 +1,98 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Modules\Lpj\Exports;
|
||||||
|
|
||||||
|
use Maatwebsite\Excel\Concerns\FromCollection;
|
||||||
|
use Maatwebsite\Excel\Concerns\WithHeadings;
|
||||||
|
use Maatwebsite\Excel\Concerns\WithMapping;
|
||||||
|
use Modules\Lpj\Models\Permohonan;
|
||||||
|
use Illuminate\Support\Facades\Auth;
|
||||||
|
|
||||||
|
class LaporanPermohonanExport implements FromCollection, WithHeadings, WithMapping
|
||||||
|
{
|
||||||
|
protected $request;
|
||||||
|
|
||||||
|
public function __construct($request)
|
||||||
|
{
|
||||||
|
$this->request = $request;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function collection()
|
||||||
|
{
|
||||||
|
$query = Permohonan::query();
|
||||||
|
|
||||||
|
// Apply role-based filtering
|
||||||
|
if (!Auth::user()->hasAnyRole(['administrator'])) {
|
||||||
|
$query->where('branch_id', Auth::user()->branch_id);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Apply date range filter if provided
|
||||||
|
if ($this->request->has('start_date') || $this->request->has('end_date')) {
|
||||||
|
$query->whereBetween('tanggal_permohonan', [
|
||||||
|
$this->request->start_date ?? '1900-01-01',
|
||||||
|
$this->request->end_date ?? now()->toDateString()
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Apply status filter if provided
|
||||||
|
if ($this->request->has('status') && !empty($this->request->status)) {
|
||||||
|
$query->where('status', $this->request->status);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Apply branch filter if provided
|
||||||
|
if ($this->request->has('branch_id') && !empty($this->request->branch_id)) {
|
||||||
|
$query->where('branch_id', $this->request->branch_id);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Apply search filter if provided
|
||||||
|
if ($this->request->has('search') && !empty($this->request->search)) {
|
||||||
|
$search = $this->request->search;
|
||||||
|
$query->where(function ($q) use ($search) {
|
||||||
|
$q->where('nomor_registrasi', 'LIKE', '%' . $search . '%');
|
||||||
|
$q->orWhere('tanggal_permohonan', 'LIKE', '%' . $search . '%');
|
||||||
|
$q->orWhereRelation('user', 'name', 'LIKE', '%' . $search . '%');
|
||||||
|
$q->orWhereRelation('tujuanPenilaian', 'name', 'LIKE', '%' . $search . '%');
|
||||||
|
$q->orWhereRelation('branch', 'name', 'LIKE', '%' . $search . '%');
|
||||||
|
$q->orWhereRelation('jenisFasilitasKredit', 'name', 'LIKE', '%' . $search . '%');
|
||||||
|
$q->orWhereRelation('jenisPenilaian', 'name', 'LIKE', '%' . $search . '%');
|
||||||
|
$q->orWhere('status', 'LIKE', '%' . $search . '%');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// Default ordering
|
||||||
|
$query->orderBy('nomor_registrasi', 'asc');
|
||||||
|
|
||||||
|
return $query->get();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function map($permohonan): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
$permohonan->id,
|
||||||
|
$permohonan->nomor_registrasi,
|
||||||
|
$permohonan->tanggal_permohonan,
|
||||||
|
$permohonan->user ? $permohonan->user->name : '',
|
||||||
|
$permohonan->branch ? $permohonan->branch->name : '',
|
||||||
|
$permohonan->tujuanPenilaian ? $permohonan->tujuanPenilaian->name : '',
|
||||||
|
$permohonan->jenisFasilitasKredit ? $permohonan->jenisFasilitasKredit->name : '',
|
||||||
|
$permohonan->jenisPenilaian ? $permohonan->jenisPenilaian->name : '',
|
||||||
|
$permohonan->status,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function headings(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'ID',
|
||||||
|
'Nomor Registrasi',
|
||||||
|
'Tanggal Permohonan',
|
||||||
|
'Pemohon',
|
||||||
|
'Cabang',
|
||||||
|
'Tujuan Penilaian',
|
||||||
|
'Jenis Fasilitas Kredit',
|
||||||
|
'Jenis Penilaian',
|
||||||
|
'Status',
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
50
app/Exports/NilaiPlafondExport.php
Normal file
50
app/Exports/NilaiPlafondExport.php
Normal file
@@ -0,0 +1,50 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Modules\Lpj\Exports;
|
||||||
|
|
||||||
|
use Maatwebsite\Excel\Concerns\FromCollection;
|
||||||
|
use Maatwebsite\Excel\Concerns\WithColumnFormatting;
|
||||||
|
use Maatwebsite\Excel\Concerns\WithHeadings;
|
||||||
|
use Maatwebsite\Excel\Concerns\WithMapping;
|
||||||
|
use Modules\Lpj\Models\JenisJaminan;
|
||||||
|
use Modules\Lpj\Models\NilaiPlafond;
|
||||||
|
use PhpOffice\PhpSpreadsheet\Style\NumberFormat;
|
||||||
|
|
||||||
|
class NilaiPlafondExport implements WithColumnFormatting, WithHeadings, FromCollection, withMapping
|
||||||
|
{
|
||||||
|
public function collection()
|
||||||
|
{
|
||||||
|
return NilaiPlafond::all();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function map($row)
|
||||||
|
: array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
$row->id,
|
||||||
|
$row->code,
|
||||||
|
$row->name,
|
||||||
|
$row->created_at
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function headings()
|
||||||
|
: array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'ID',
|
||||||
|
'Code',
|
||||||
|
'Name',
|
||||||
|
'Created At'
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function columnFormats()
|
||||||
|
: array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'A' => NumberFormat::FORMAT_NUMBER,
|
||||||
|
'D' => NumberFormat::FORMAT_DATE_DATETIME
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
63
app/Exports/PenawaranTenderExport.php
Normal file
63
app/Exports/PenawaranTenderExport.php
Normal file
@@ -0,0 +1,63 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Modules\Lpj\Exports;
|
||||||
|
|
||||||
|
use Maatwebsite\Excel\Concerns\FromCollection;
|
||||||
|
use Maatwebsite\Excel\Concerns\WithColumnFormatting;
|
||||||
|
use Maatwebsite\Excel\Concerns\WithHeadings;
|
||||||
|
use Maatwebsite\Excel\Concerns\WithMapping;
|
||||||
|
use Modules\Lpj\Models\PenawaranTender;
|
||||||
|
use PhpOffice\PhpSpreadsheet\Style\NumberFormat;
|
||||||
|
|
||||||
|
class PenawaranTenderExport implements WithColumnFormatting, WithHeadings, FromCollection, withMapping
|
||||||
|
{
|
||||||
|
public function collection()
|
||||||
|
{
|
||||||
|
return PenawaranTender::all();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function map($row): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
$row->id,
|
||||||
|
$row->code,
|
||||||
|
$row->nama_kjpp_sebelumnya,
|
||||||
|
$row->biaya_kjpp_sebelumnya,
|
||||||
|
$row->tanggal_penilaian_sebelumnya,
|
||||||
|
$row->nomor_registrasi,
|
||||||
|
$row->tujuan_penilaian_kjpp_id,
|
||||||
|
$row->jenis_laporan_id,
|
||||||
|
$row->start_date,
|
||||||
|
$row->end_date,
|
||||||
|
$row->catatan,
|
||||||
|
$row->created_at
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function headings(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'ID',
|
||||||
|
'Nomor Penawaran',
|
||||||
|
'Nama KJPP Sebelumnya',
|
||||||
|
'Biaya KJPP Sebelumnya',
|
||||||
|
'Tanggal Penilaian Sebelumnya',
|
||||||
|
'Nomor Registrasi',
|
||||||
|
'Tujuan Penilaian KJPP ID',
|
||||||
|
'Jenis Laporan ID',
|
||||||
|
'Start Date',
|
||||||
|
'End Date',
|
||||||
|
'Catatan',
|
||||||
|
'Created At'
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function columnFormats(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'A' => NumberFormat::FORMAT_NUMBER,
|
||||||
|
'B' => NumberFormat::FORMAT_NUMBER,
|
||||||
|
'E' => NumberFormat::FORMAT_DATE_DATETIME
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
72
app/Exports/PermohonanExport.php
Normal file
72
app/Exports/PermohonanExport.php
Normal file
@@ -0,0 +1,72 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Modules\Lpj\Exports;
|
||||||
|
|
||||||
|
use Maatwebsite\Excel\Concerns\FromCollection;
|
||||||
|
use Maatwebsite\Excel\Concerns\WithColumnFormatting;
|
||||||
|
use Maatwebsite\Excel\Concerns\WithHeadings;
|
||||||
|
use Maatwebsite\Excel\Concerns\WithMapping;
|
||||||
|
use Modules\Lpj\Models\Debiture;
|
||||||
|
use Modules\Lpj\Models\Permohonan;
|
||||||
|
use PhpOffice\PhpSpreadsheet\Style\NumberFormat;
|
||||||
|
|
||||||
|
class PermohonanExport implements WithColumnFormatting, WithHeadings, FromCollection, withMapping
|
||||||
|
{
|
||||||
|
public function collection()
|
||||||
|
{
|
||||||
|
return Permohonan::get();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function map($row)
|
||||||
|
: array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
$row->id,
|
||||||
|
$row->nomor_registrasi,
|
||||||
|
$row->tanggal_permohonan,
|
||||||
|
$row->user->name,
|
||||||
|
$row->branch->name,
|
||||||
|
$row->tujuanPenilaian->name,
|
||||||
|
$row->debiture->name,
|
||||||
|
$row->jenisFasilitasKredit->name,
|
||||||
|
$row->nilaiPlafond->name,
|
||||||
|
$row->status,
|
||||||
|
$row->authorized_at,
|
||||||
|
$row->authorized_status,
|
||||||
|
$row->authorized_by,
|
||||||
|
$row->created_at
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function headings()
|
||||||
|
: array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'ID',
|
||||||
|
'Nomor Registrasi',
|
||||||
|
'Tanggal Permohonan',
|
||||||
|
'User Pemohon',
|
||||||
|
'Branch Pemohon',
|
||||||
|
'Tujuan Penilaian',
|
||||||
|
'Debitur',
|
||||||
|
'Jenis Fasilitas Kredit',
|
||||||
|
'Nilai Plafond',
|
||||||
|
'Status Permohonan',
|
||||||
|
'Tanggal Pengesahan',
|
||||||
|
'Status Pengesahan',
|
||||||
|
'Pengesah',
|
||||||
|
'Tanggal Dibuat'
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function columnFormats()
|
||||||
|
: array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'A' => NumberFormat::FORMAT_NUMBER,
|
||||||
|
'C' => NumberFormat::FORMAT_DATE_DATETIME,
|
||||||
|
'K' => NumberFormat::FORMAT_DATE_DATETIME,
|
||||||
|
'N' => NumberFormat::FORMAT_DATE_DATETIME
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
49
app/Exports/RegionExport.php
Normal file
49
app/Exports/RegionExport.php
Normal file
@@ -0,0 +1,49 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Modules\Lpj\Exports;
|
||||||
|
|
||||||
|
use Maatwebsite\Excel\Concerns\FromCollection;
|
||||||
|
use Maatwebsite\Excel\Concerns\WithColumnFormatting;
|
||||||
|
use Maatwebsite\Excel\Concerns\WithHeadings;
|
||||||
|
use Maatwebsite\Excel\Concerns\WithMapping;
|
||||||
|
use Modules\Lpj\Models\Regions;
|
||||||
|
use PhpOffice\PhpSpreadsheet\Style\NumberFormat;
|
||||||
|
|
||||||
|
class RegionExport implements WithColumnFormatting, WithHeadings, FromCollection, withMapping
|
||||||
|
{
|
||||||
|
public function collection()
|
||||||
|
{
|
||||||
|
return Regions::all();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function map($row)
|
||||||
|
: array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
$row->id,
|
||||||
|
$row->code,
|
||||||
|
$row->name,
|
||||||
|
$row->created_at
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function headings()
|
||||||
|
: array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'ID',
|
||||||
|
'Code',
|
||||||
|
'Name',
|
||||||
|
'Created At'
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function columnFormats()
|
||||||
|
: array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'A' => NumberFormat::FORMAT_NUMBER,
|
||||||
|
'D' => NumberFormat::FORMAT_DATE_DATETIME
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
53
app/Exports/StatusPermohonanExport.php
Normal file
53
app/Exports/StatusPermohonanExport.php
Normal file
@@ -0,0 +1,53 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Modules\Lpj\Exports;
|
||||||
|
|
||||||
|
use Maatwebsite\Excel\Concerns\FromCollection;
|
||||||
|
use Maatwebsite\Excel\Concerns\WithColumnFormatting;
|
||||||
|
use Maatwebsite\Excel\Concerns\WithHeadings;
|
||||||
|
use Maatwebsite\Excel\Concerns\WithMapping;
|
||||||
|
use Modules\Lpj\Models\StatusPermohonan;
|
||||||
|
use PhpOffice\PhpSpreadsheet\Style\NumberFormat;
|
||||||
|
|
||||||
|
class StatusPermohonanExport implements WithColumnFormatting, WithHeadings, FromCollection, withMapping
|
||||||
|
{
|
||||||
|
public function collection()
|
||||||
|
{
|
||||||
|
return StatusPermohonan::all();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function map($row)
|
||||||
|
: array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
$row->id,
|
||||||
|
$row->name,
|
||||||
|
$row->slug,
|
||||||
|
$row->description,
|
||||||
|
$row->status,
|
||||||
|
$row->created_at
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function headings()
|
||||||
|
: array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'ID',
|
||||||
|
'Name',
|
||||||
|
'Slug',
|
||||||
|
'Description',
|
||||||
|
'Status',
|
||||||
|
'Created At'
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function columnFormats()
|
||||||
|
: array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'A' => NumberFormat::FORMAT_NUMBER,
|
||||||
|
'F' => NumberFormat::FORMAT_DATE_DATETIME
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
57
app/Exports/TeamPenilaianExport.php
Normal file
57
app/Exports/TeamPenilaianExport.php
Normal file
@@ -0,0 +1,57 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Modules\Lpj\Exports;
|
||||||
|
|
||||||
|
use Maatwebsite\Excel\Concerns\FromCollection;
|
||||||
|
use Maatwebsite\Excel\Concerns\WithColumnFormatting;
|
||||||
|
use Maatwebsite\Excel\Concerns\WithHeadings;
|
||||||
|
use Maatwebsite\Excel\Concerns\WithMapping;
|
||||||
|
use Modules\Lpj\Models\JenisPenilaian;
|
||||||
|
use PhpOffice\PhpSpreadsheet\Style\NumberFormat;
|
||||||
|
use Illuminate\Support\Facades\DB;
|
||||||
|
use Modules\Lpj\Models\Teams;
|
||||||
|
|
||||||
|
class TeamPenilaianExport implements WithColumnFormatting, WithHeadings, FromCollection, withMapping
|
||||||
|
{
|
||||||
|
public function collection()
|
||||||
|
{
|
||||||
|
return Teams::select(
|
||||||
|
'teams.id as id',
|
||||||
|
'teams.name as team_name',
|
||||||
|
'regions.name as region_name',
|
||||||
|
DB::raw('STRING_AGG(users.name, \', \') as team_group')
|
||||||
|
)
|
||||||
|
->join('regions', 'teams.regions_id', '=', 'regions.id')
|
||||||
|
->leftJoin('teams_users', 'teams.id', '=', 'teams_users.teams_id')
|
||||||
|
->leftJoin('users', 'teams_users.user_id', '=', 'users.id')
|
||||||
|
->groupBy('teams.id', 'teams.name', 'regions.name')
|
||||||
|
->get();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function map($row): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
$row->team_name,
|
||||||
|
$row->region_name,
|
||||||
|
$row->team_group,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function headings(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'Name',
|
||||||
|
'Region',
|
||||||
|
'Anggota Team',
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function columnFormats(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'A' => NumberFormat::FORMAT_TEXT,
|
||||||
|
'B' => NumberFormat::FORMAT_TEXT,
|
||||||
|
'C' => NumberFormat::FORMAT_TEXT,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
49
app/Exports/TujuanPenilaianExport.php
Normal file
49
app/Exports/TujuanPenilaianExport.php
Normal file
@@ -0,0 +1,49 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Modules\Lpj\Exports;
|
||||||
|
|
||||||
|
use Maatwebsite\Excel\Concerns\FromCollection;
|
||||||
|
use Maatwebsite\Excel\Concerns\WithColumnFormatting;
|
||||||
|
use Maatwebsite\Excel\Concerns\WithHeadings;
|
||||||
|
use Maatwebsite\Excel\Concerns\WithMapping;
|
||||||
|
use Modules\Lpj\Models\TujuanPenilaian;
|
||||||
|
use PhpOffice\PhpSpreadsheet\Style\NumberFormat;
|
||||||
|
|
||||||
|
class TujuanPenilaianExport implements WithColumnFormatting, WithHeadings, FromCollection, withMapping
|
||||||
|
{
|
||||||
|
public function collection()
|
||||||
|
{
|
||||||
|
return TujuanPenilaian::all();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function map($row)
|
||||||
|
: array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
$row->id,
|
||||||
|
$row->code,
|
||||||
|
$row->name,
|
||||||
|
$row->created_at
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function headings()
|
||||||
|
: array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'ID',
|
||||||
|
'Code',
|
||||||
|
'Name',
|
||||||
|
'Created At'
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function columnFormats()
|
||||||
|
: array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'A' => NumberFormat::FORMAT_NUMBER,
|
||||||
|
'D' => NumberFormat::FORMAT_DATE_DATETIME
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
46
app/Exports/TujuanPenilaianKJPPExport.php
Normal file
46
app/Exports/TujuanPenilaianKJPPExport.php
Normal file
@@ -0,0 +1,46 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Modules\Lpj\Exports;
|
||||||
|
|
||||||
|
use Maatwebsite\Excel\Concerns\FromCollection;
|
||||||
|
use Maatwebsite\Excel\Concerns\WithColumnFormatting;
|
||||||
|
use Maatwebsite\Excel\Concerns\WithHeadings;
|
||||||
|
use Maatwebsite\Excel\Concerns\WithMapping;
|
||||||
|
use Modules\Lpj\Models\TujuanPenilaianKJPP;
|
||||||
|
use PhpOffice\PhpSpreadsheet\Style\NumberFormat;
|
||||||
|
|
||||||
|
class TujuanPenilaianKJPPExport implements WithColumnFormatting, WithHeadings, FromCollection, withMapping
|
||||||
|
{
|
||||||
|
public function collection()
|
||||||
|
{
|
||||||
|
return TujuanPenilaianKJPP::all();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function map($row): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
$row->id,
|
||||||
|
$row->code,
|
||||||
|
$row->name,
|
||||||
|
$row->created_at
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function headings(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'ID',
|
||||||
|
'Code',
|
||||||
|
'Name',
|
||||||
|
'Created At'
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function columnFormats(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'A' => NumberFormat::FORMAT_NUMBER,
|
||||||
|
'D' => NumberFormat::FORMAT_DATE_DATETIME
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
544
app/Helpers/Lpj.php
Normal file
544
app/Helpers/Lpj.php
Normal file
@@ -0,0 +1,544 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Carbon\Carbon;
|
||||||
|
use Illuminate\Support\Facades\DB;
|
||||||
|
use Modules\Location\Models\City;
|
||||||
|
use Modules\Location\Models\District;
|
||||||
|
use Modules\Location\Models\Province;
|
||||||
|
use Modules\Location\Models\Village;
|
||||||
|
use Modules\Lpj\Models\CustomField;
|
||||||
|
use Modules\Lpj\Models\HolidayCalendar;
|
||||||
|
use Modules\Lpj\Models\JenisDokumen;
|
||||||
|
use Modules\Lpj\Models\Laporan;
|
||||||
|
use Modules\Lpj\Models\PenawaranDetailTender;
|
||||||
|
use Modules\Lpj\Models\PenawaranTender;
|
||||||
|
use Modules\Lpj\Models\Penilaian;
|
||||||
|
use Modules\Lpj\Models\TeamsUsers;
|
||||||
|
use Modules\Usermanagement\Models\User;
|
||||||
|
|
||||||
|
function formatTanggalIndonesia($date, $time = false)
|
||||||
|
{
|
||||||
|
Carbon::setLocale('id');
|
||||||
|
try {
|
||||||
|
$waktu = Carbon::parse($date);
|
||||||
|
if (!$time) {
|
||||||
|
return $waktu->translatedFormat('d F Y');
|
||||||
|
}
|
||||||
|
return $waktu->translatedFormat('d F Y') . ' pukul ' . $waktu->format('H.i') . ' WIB';
|
||||||
|
} catch (Throwable $e) {
|
||||||
|
return $date;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function formatRupiah($number, $decimals = 0)
|
||||||
|
{
|
||||||
|
$number = (float) $number;
|
||||||
|
return 'Rp ' . number_format($number, $decimals, ',', '.');
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function formatAlamat($alamat)
|
||||||
|
{
|
||||||
|
return ($alamat->address ? $alamat->address . ', ' : '') . (isset($alamat->village) ? $alamat->village->name . ', ' : '') . (isset($alamat->city) ? $alamat->city->name . ', ' : '') . (isset($alamat->province) ? $alamat->province->name . ', ' : '') . ($alamat->village->postal_code ?? '');
|
||||||
|
}
|
||||||
|
|
||||||
|
// andy add
|
||||||
|
function checkActiveDateRangePenawaran($id)
|
||||||
|
{
|
||||||
|
$penawaran = PenawaranTender::find($id);
|
||||||
|
|
||||||
|
$start_date = strtotime($penawaran->start_date);
|
||||||
|
$end_date = strtotime($penawaran->end_date);
|
||||||
|
$todays_date = strtotime(now());
|
||||||
|
//$todays_date = strtotime("+1 day", strtotime(now()));
|
||||||
|
|
||||||
|
$allow = true;
|
||||||
|
if ($todays_date >= $start_date && $todays_date <= $end_date) {
|
||||||
|
//Penawaran dibuka
|
||||||
|
$allow = true;
|
||||||
|
} else {
|
||||||
|
if ($todays_date < $start_date) {
|
||||||
|
//Penawaran Belum dibuka
|
||||||
|
$allow = true;
|
||||||
|
} else {
|
||||||
|
//Penawaran sudah ditutup
|
||||||
|
$allow = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $allow;
|
||||||
|
}
|
||||||
|
|
||||||
|
function checkKelengkapanDetailKJPP($id)
|
||||||
|
{
|
||||||
|
$allow = true;
|
||||||
|
// DB::enableQueryLog();
|
||||||
|
// detail_penawaran apakah isian biaya_penawaran, attachment, dokumen_persetujuan sudah lengkap?
|
||||||
|
$query = PenawaranDetailTender::select('id')->where('penawaran_id', '=', $id)->where('status', '=', 1)->where(
|
||||||
|
function ($query) {
|
||||||
|
// no_proposal
|
||||||
|
$query->orWhere('no_proposal', '', "");
|
||||||
|
$query->orWhereNull('no_proposal');
|
||||||
|
|
||||||
|
// tgl_proposal
|
||||||
|
$query->orWhere('tgl_proposal', '', "");
|
||||||
|
$query->orWhereNull('tgl_proposal');
|
||||||
|
|
||||||
|
$query->orWhere('biaya_penawaran', '', "");
|
||||||
|
$query->orWhereNull('biaya_penawaran');
|
||||||
|
|
||||||
|
$query->orWhere('attachment', '', "");
|
||||||
|
$query->orWhereNull('attachment');
|
||||||
|
|
||||||
|
$query->orWhere('dokumen_persetujuan', '', "");
|
||||||
|
$query->orWhereNull('dokumen_persetujuan');
|
||||||
|
},
|
||||||
|
)->get();
|
||||||
|
// $sql = DB::getQueryLog();
|
||||||
|
|
||||||
|
|
||||||
|
if (sizeof($query) > 0) {
|
||||||
|
$allow = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $allow;
|
||||||
|
}
|
||||||
|
|
||||||
|
// convert
|
||||||
|
function convertSlug($slug)
|
||||||
|
{
|
||||||
|
$words = explode('-', $slug);
|
||||||
|
|
||||||
|
foreach ($words as $index => $word) {
|
||||||
|
$words[$index] = strtoupper($word);
|
||||||
|
}
|
||||||
|
|
||||||
|
return implode(' ', $words);
|
||||||
|
}
|
||||||
|
|
||||||
|
// generate last penawaran.code
|
||||||
|
function onLastnumberCodePenawaran()
|
||||||
|
: string
|
||||||
|
{
|
||||||
|
// ambil code terakhir
|
||||||
|
$maxCode = PenawaranTender::max('code');
|
||||||
|
// chek data penawaran terakhir --> mengurutkan data berdasarkan kolom `created_at` secara DESC
|
||||||
|
// $penawaran = PenawaranTender::latest()->first();
|
||||||
|
$penawaran = PenawaranTender::where('code', '=', $maxCode)->first();
|
||||||
|
$code_penawaran_last = '';
|
||||||
|
|
||||||
|
// nomor di set 0001
|
||||||
|
$noUrutAkhirString = sprintf("%04s", 1);
|
||||||
|
if ($penawaran) {
|
||||||
|
$isNum = substr($maxCode, 2); // memastikan string ke 3 s/d 8 adalan numiric
|
||||||
|
$isNP = substr($maxCode, 0, 2);
|
||||||
|
if ((8 == strlen($maxCode)) && ("NP" == $isNP) && (ctype_digit($isNum))) {
|
||||||
|
$code_penawaran_last = substr($maxCode, -4);
|
||||||
|
$year_penawaran_last = Carbon::parse($penawaran->created_at)->year;
|
||||||
|
$year_now = Carbon::now()->year;
|
||||||
|
if ($year_now == $year_penawaran_last) {
|
||||||
|
$noUrutAkhirString = sprintf("%04s", abs($code_penawaran_last + 1));
|
||||||
|
}
|
||||||
|
// jika ternyata tahun tdk sama (kurang dari tahun sekarang), maka nomor di set 0001
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
return 'NP' . Carbon::now()->format('y') . $noUrutAkhirString;
|
||||||
|
}
|
||||||
|
|
||||||
|
// generate last penawaran.no_spk
|
||||||
|
function onLastnumberCodePenawaranSPK($jenis_laporan_code)
|
||||||
|
: string
|
||||||
|
{
|
||||||
|
|
||||||
|
// 20241124_001 ==> spk_no_core
|
||||||
|
// XXX / PJ / JKT / MONTH-ROM / FR|SR / 2024
|
||||||
|
// 001 / PJ / JKT / XI / FR / 2024
|
||||||
|
$maxCode = PenawaranTender::max('spk_no_core');
|
||||||
|
$penawaran = PenawaranTender::where('spk_no_core', '=', $maxCode)->first();
|
||||||
|
$no_spk_penawaran_last = '';
|
||||||
|
$year_penawaran_last = '';
|
||||||
|
$year_now = Carbon::now()->year;
|
||||||
|
// nomor di set 001
|
||||||
|
$noUrutAkhirString = sprintf("%03s", 1);
|
||||||
|
if ($penawaran) {
|
||||||
|
$no_spk_penawaran_last = substr($maxCode, -3);
|
||||||
|
$year_penawaran_last = substr($maxCode, 0, 4);
|
||||||
|
|
||||||
|
if ($year_now == $year_penawaran_last) {
|
||||||
|
$noUrutAkhirString = sprintf("%03s", abs($no_spk_penawaran_last + 1));
|
||||||
|
}
|
||||||
|
// jika ternyata tahun tdk sama (kurang dari tahun sekarang), maka nomor di set 001
|
||||||
|
}
|
||||||
|
|
||||||
|
$month = onRomawi(Carbon::now()->month);
|
||||||
|
|
||||||
|
$lastSPK = $noUrutAkhirString . ' / PJ / JKT / ' . $month . ' / ' . $jenis_laporan_code . ' / ' . $year_now;
|
||||||
|
return $lastSPK;
|
||||||
|
}
|
||||||
|
|
||||||
|
function onRomawi(int $bln)
|
||||||
|
: string
|
||||||
|
{
|
||||||
|
return convertToRoman($bln);
|
||||||
|
}
|
||||||
|
|
||||||
|
function penyebut($nilai)
|
||||||
|
{
|
||||||
|
$nilai = abs($nilai);
|
||||||
|
$huruf = [
|
||||||
|
"",
|
||||||
|
"satu",
|
||||||
|
"dua",
|
||||||
|
"tiga",
|
||||||
|
"empat",
|
||||||
|
"lima",
|
||||||
|
"enam",
|
||||||
|
"tujuh",
|
||||||
|
"delapan",
|
||||||
|
"sembilan",
|
||||||
|
"sepuluh",
|
||||||
|
"sebelas"
|
||||||
|
];
|
||||||
|
$temp = "";
|
||||||
|
if ($nilai < 12) {
|
||||||
|
$temp = " " . $huruf[$nilai];
|
||||||
|
} else if ($nilai < 20) {
|
||||||
|
$temp = penyebut($nilai - 10) . " belas";
|
||||||
|
} else if ($nilai < 100) {
|
||||||
|
$temp = penyebut($nilai / 10) . " puluh" . penyebut($nilai % 10);
|
||||||
|
} else if ($nilai < 200) {
|
||||||
|
$temp = " seratus" . penyebut($nilai - 100);
|
||||||
|
} else if ($nilai < 1000) {
|
||||||
|
$temp = penyebut($nilai / 100) . " ratus" . penyebut($nilai % 100);
|
||||||
|
} else if ($nilai < 2000) {
|
||||||
|
$temp = " seribu" . penyebut($nilai - 1000);
|
||||||
|
} else if ($nilai < 1000000) {
|
||||||
|
$temp = penyebut($nilai / 1000) . " ribu" . penyebut($nilai % 1000);
|
||||||
|
} else if ($nilai < 1000000000) {
|
||||||
|
$temp = penyebut($nilai / 1000000) . " juta" . penyebut($nilai % 1000000);
|
||||||
|
} else if ($nilai < 1000000000000) {
|
||||||
|
$temp = penyebut($nilai / 1000000000) . " milyar" . penyebut(fmod($nilai, 1000000000));
|
||||||
|
} else if ($nilai < 1000000000000000) {
|
||||||
|
$temp = penyebut($nilai / 1000000000000) . " trilyun" . penyebut(fmod($nilai, 1000000000000));
|
||||||
|
}
|
||||||
|
return $temp;
|
||||||
|
}
|
||||||
|
|
||||||
|
function terbilang($nilai)
|
||||||
|
{
|
||||||
|
if ($nilai < 0) {
|
||||||
|
$hasil = "minus " . trim(penyebut($nilai));
|
||||||
|
} else {
|
||||||
|
$hasil = trim(penyebut($nilai));
|
||||||
|
}
|
||||||
|
return $hasil;
|
||||||
|
}
|
||||||
|
|
||||||
|
// andy add
|
||||||
|
|
||||||
|
|
||||||
|
function hitungHariKerja($tanggalMulai, $tanggalSelesai)
|
||||||
|
{
|
||||||
|
$tanggalMulai = Carbon::parse($tanggalMulai)->startOfDay();
|
||||||
|
$tanggalSelesai = Carbon::parse($tanggalSelesai)->endOfDay();
|
||||||
|
|
||||||
|
$hariKerja = 0;
|
||||||
|
$tanggalSekarang = $tanggalMulai->copy();
|
||||||
|
|
||||||
|
while ($tanggalSekarang <= $tanggalSelesai) {
|
||||||
|
// Cek apakah hari ini bukan Sabtu atau Minggu dan bukan hari libur
|
||||||
|
if (!$tanggalSekarang->isWeekend() && !in_array($tanggalSekarang->format('Y-m-d'), holidays())) {
|
||||||
|
$hariKerja++;
|
||||||
|
}
|
||||||
|
$tanggalSekarang->addDay();
|
||||||
|
}
|
||||||
|
|
||||||
|
return $hariKerja;
|
||||||
|
}
|
||||||
|
|
||||||
|
function countPermohonanForUser($userId)
|
||||||
|
{
|
||||||
|
$validStatuses = [
|
||||||
|
'assign',
|
||||||
|
'survey-completed',
|
||||||
|
'proses-laporan',
|
||||||
|
'paparan',
|
||||||
|
'proses-paparan',
|
||||||
|
'revisi-laporan',
|
||||||
|
'revisi-paparan',
|
||||||
|
'survey',
|
||||||
|
'proses-survey',
|
||||||
|
'request-reschedule',
|
||||||
|
'reschedule',
|
||||||
|
'rejected-reschedule',
|
||||||
|
'approved-reschedule',
|
||||||
|
'revisi-survey',
|
||||||
|
'revisi-pembayaran'
|
||||||
|
];
|
||||||
|
|
||||||
|
$result = Penilaian::whereHas('userPenilai', function ($query) use ($userId) {
|
||||||
|
$query->where('user_id', $userId);
|
||||||
|
})
|
||||||
|
->whereHas('permohonan', function ($query) use ($validStatuses) {
|
||||||
|
$query->whereIn('status', $validStatuses);
|
||||||
|
})
|
||||||
|
->get()
|
||||||
|
->groupBy(function ($item) {
|
||||||
|
// Pastikan mengakses properti dari model yang valid
|
||||||
|
return $item->userPenilai->first()->user_id . '-' . $item->permohonan->id;
|
||||||
|
})
|
||||||
|
->map(function ($group) {
|
||||||
|
return [
|
||||||
|
'statuses' => $group->pluck('permohonan.status')->unique()->values()->all(),
|
||||||
|
];
|
||||||
|
});
|
||||||
|
|
||||||
|
return $result->count();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function getMaxFileSize($jenis)
|
||||||
|
{
|
||||||
|
$jenisDokumen = JenisDokumen::where('name', $jenis)->first();
|
||||||
|
if (!$jenisDokumen) {
|
||||||
|
return 2048;
|
||||||
|
}
|
||||||
|
//konversi ke KB (1 MB = 1024 KB)
|
||||||
|
$maxSizeInKB = (int) $jenisDokumen->max_size * 1024;
|
||||||
|
|
||||||
|
return $maxSizeInKB;
|
||||||
|
}
|
||||||
|
|
||||||
|
function getUser($userId)
|
||||||
|
{
|
||||||
|
return User::find($userId);
|
||||||
|
}
|
||||||
|
|
||||||
|
function generateLpjUniqueCode($randomLength = 6)
|
||||||
|
{
|
||||||
|
|
||||||
|
$year = date('y');
|
||||||
|
$month = str_pad(date('m'), 2, '0', STR_PAD_LEFT);
|
||||||
|
$day = str_pad(date('d'), 2, '0', STR_PAD_LEFT);
|
||||||
|
|
||||||
|
// Generate random numbers
|
||||||
|
$randomNumber = str_pad(mt_rand(0, pow(10, $randomLength) - 1), $randomLength, '0', STR_PAD_LEFT);
|
||||||
|
|
||||||
|
// Concatenate components to create the custom code
|
||||||
|
return $year . $month . $day . $randomNumber;
|
||||||
|
}
|
||||||
|
|
||||||
|
function checkRegionUserName($userId)
|
||||||
|
{
|
||||||
|
$region = TeamsUsers::where('user_id', $userId)->first();
|
||||||
|
if ($region) {
|
||||||
|
return $region->team->regions->name;
|
||||||
|
} else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function getNomorLaporan($permohonanId, $documentId, $type = 'nomor_laporan')
|
||||||
|
{
|
||||||
|
|
||||||
|
$laporan = Laporan::where([
|
||||||
|
'permohonan_id' => $permohonanId,
|
||||||
|
'dokumen_jaminan_id' => $documentId,
|
||||||
|
])->first();
|
||||||
|
|
||||||
|
if (!$laporan) {
|
||||||
|
return $type == 'nomor_laporan' ? '-' : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $type == 'nomor_laporan' ? $laporan->nomor_laporan : $laporan->created_at;
|
||||||
|
}
|
||||||
|
|
||||||
|
function getCustomField($param)
|
||||||
|
{
|
||||||
|
if (is_numeric($param)) {
|
||||||
|
$field = CustomField::find($param);
|
||||||
|
} else {
|
||||||
|
$field = CustomField::where(['name' => $param])->first();
|
||||||
|
}
|
||||||
|
if ($field) {
|
||||||
|
return $field;
|
||||||
|
} else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function getWilayahName($code, $type)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
$wilayah = null;
|
||||||
|
|
||||||
|
if (!$code) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch ($type) {
|
||||||
|
case 'province':
|
||||||
|
$wilayah = Province::where('code', $code)->first();
|
||||||
|
return $wilayah ? $wilayah->name : null;
|
||||||
|
|
||||||
|
case 'city':
|
||||||
|
$wilayah = City::where('code', $code)->first();
|
||||||
|
return $wilayah ? $wilayah->name : null;
|
||||||
|
|
||||||
|
case 'district':
|
||||||
|
$wilayah = District::where('code', $code)->first();
|
||||||
|
return $wilayah ? $wilayah->name : null;
|
||||||
|
|
||||||
|
case 'village':
|
||||||
|
$wilayah = Village::where('code', $code)->first();
|
||||||
|
return $wilayah ? $wilayah->name : null;
|
||||||
|
|
||||||
|
default:
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
} catch (Exception $e) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function formatLabel($key)
|
||||||
|
{
|
||||||
|
|
||||||
|
static $labelCache = [];
|
||||||
|
if (isset($labelCache[$key])) {
|
||||||
|
return $labelCache[$key];
|
||||||
|
}
|
||||||
|
|
||||||
|
$customLabel = CustomField::where('name', $key)->first();
|
||||||
|
$labelCache[$key] = $customLabel->label ?? ucwords(str_replace('_', ' ', $key));
|
||||||
|
|
||||||
|
return $labelCache[$key];
|
||||||
|
}
|
||||||
|
|
||||||
|
function calculateSLA($permohonan, $type)
|
||||||
|
{
|
||||||
|
if (!$type) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
$nilai_plafond = in_array($permohonan->nilai_plafond_id, [2, 3]);
|
||||||
|
$nilai_plafond_2 = in_array($permohonan->nilai_plafond_id, [1]);
|
||||||
|
|
||||||
|
$slaMap = [
|
||||||
|
'resume' => $nilai_plafond ? 2 : null,
|
||||||
|
'paparan' => $nilai_plafond ? 2 : null,
|
||||||
|
'standard' => $nilai_plafond ? 3 : null,
|
||||||
|
'sederhana' => $nilai_plafond ? 2 : null,
|
||||||
|
'paparan' => $nilai_plafond_2 ? 3 : null,
|
||||||
|
'rap' => 3,
|
||||||
|
'memo' => $nilai_plafond ? 1 : null
|
||||||
|
];
|
||||||
|
|
||||||
|
if ($type === 'paparan' && isset($permohonan->tujuanPenilaian->name) && $permohonan->tujuanPenilaian->name === 'rap') {
|
||||||
|
return 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $slaMap[$type] ?? null;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Menghitung total nilai berdasarkan key dan jenis legalitas.
|
||||||
|
*
|
||||||
|
* @param array $detailsArray
|
||||||
|
* @param string $key
|
||||||
|
* @param int $jenisLegalitas
|
||||||
|
*
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
|
function calculateTotalLuas($detailsArray, $key, $jenisLegalitas, $defaultJenisLegalitas, $fallbackJenisLegalitas)
|
||||||
|
{
|
||||||
|
$total = 0;
|
||||||
|
|
||||||
|
if ($detailsArray) {
|
||||||
|
foreach ($detailsArray as $item) {
|
||||||
|
if (isset($item->jenis_legalitas_jaminan_id) && $item->jenis_legalitas_jaminan_id === $jenisLegalitas) {
|
||||||
|
$details = json_decode($item->details, true);
|
||||||
|
|
||||||
|
if (is_array($details)) {
|
||||||
|
foreach ($details as $detail) {
|
||||||
|
if (isset($detail[$key])) {
|
||||||
|
$total += (int) $detail[$key];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Jika total masih 0, gunakan jenis jaminan ppjb
|
||||||
|
if ($total === 0) {
|
||||||
|
foreach ($detailsArray as $item) {
|
||||||
|
if (isset($item->jenis_legalitas_jaminan_id) && $item->jenis_legalitas_jaminan_id === $defaultJenisLegalitas) {
|
||||||
|
$details = json_decode($item->details, true);
|
||||||
|
|
||||||
|
if (is_array($details)) {
|
||||||
|
foreach ($details as $detail) {
|
||||||
|
if (isset($detail[$key]) && $detail[$key] !== null) {
|
||||||
|
$total += (int) $detail[$key];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// jika total masih kosong juga maka gunakan ppb
|
||||||
|
if ($total === 0 && $fallbackJenisLegalitas !== null) {
|
||||||
|
foreach ($detailsArray as $item) {
|
||||||
|
if (isset($item->jenis_legalitas_jaminan_id) && $item->jenis_legalitas_jaminan_id === $fallbackJenisLegalitas) {
|
||||||
|
$details = json_decode($item->details, true);
|
||||||
|
|
||||||
|
if (is_array($details)) {
|
||||||
|
foreach ($details as $detail) {
|
||||||
|
if (isset($detail[$key]) && $detail[$key] !== null) {
|
||||||
|
$total += (int) $detail[$key];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $total > 0 ? $total : 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function ubahNomorHp($nomorHp)
|
||||||
|
{
|
||||||
|
|
||||||
|
$nomorHp = preg_replace('/\D/', '', $nomorHp);
|
||||||
|
if (strpos($nomorHp, '62') === 0) {
|
||||||
|
$nomorBaru = substr($nomorHp, 0, 5) . "xxxxx";
|
||||||
|
return '+' . $nomorBaru;
|
||||||
|
} else if (strpos($nomorHp, '0') === 0) {
|
||||||
|
|
||||||
|
$nomorBaru = substr($nomorHp, 0, 5) . "xxxxxx";
|
||||||
|
return $nomorBaru;
|
||||||
|
} else {
|
||||||
|
return "Nomor HP tidak valid";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function formatNotifikasi($notifikasi)
|
||||||
|
{
|
||||||
|
$data = json_decode(json_encode($notifikasi->data));
|
||||||
|
$message = $data->message;
|
||||||
|
$data = $data->data;
|
||||||
|
$notifikasi = [
|
||||||
|
'title' => 'Permohonan : ' . $data->nomor_registrasi,
|
||||||
|
'message' => $message,
|
||||||
|
];
|
||||||
|
return $notifikasi;
|
||||||
|
}
|
||||||
|
|
||||||
0
app/Http/Controllers/.gitkeep
Normal file
0
app/Http/Controllers/.gitkeep
Normal file
604
app/Http/Controllers/ActivityController.php
Normal file
604
app/Http/Controllers/ActivityController.php
Normal file
@@ -0,0 +1,604 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Modules\Lpj\Http\Controllers;
|
||||||
|
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use Exception;
|
||||||
|
use Carbon\Carbon;
|
||||||
|
use Illuminate\Http\RedirectResponse;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Modules\Lpj\Models\Permohonan;
|
||||||
|
use Modules\Lpj\Models\Penilaian;
|
||||||
|
use Modules\Lpj\Models\TeamsUsers;
|
||||||
|
use Modules\Lpj\Models\PenilaianTeam;
|
||||||
|
use Modules\Lpj\Models\StatusPermohonan;
|
||||||
|
use Modules\Lpj\Exports\PermohonanExport;
|
||||||
|
use Maatwebsite\Excel\Facades\Excel;
|
||||||
|
use Modules\Lpj\Models\Teams;
|
||||||
|
use Illuminate\Support\Facades\DB;
|
||||||
|
|
||||||
|
class ActivityController extends Controller
|
||||||
|
{
|
||||||
|
public $user;
|
||||||
|
/**
|
||||||
|
* Display a listing of the resource.
|
||||||
|
*/
|
||||||
|
public function index()
|
||||||
|
{
|
||||||
|
$status_permohonan = StatusPermohonan::all();
|
||||||
|
return view('lpj::activity.index', compact('status_permohonan'));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show the form for creating a new resource.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
public function progres_activity()
|
||||||
|
{
|
||||||
|
// Ambil user yang sedang login dengan roles
|
||||||
|
$user = auth()->user()->load('roles');
|
||||||
|
|
||||||
|
// Inisialisasi regionId dan teamId
|
||||||
|
$regionId = $teamId = null;
|
||||||
|
|
||||||
|
if ($user->roles->pluck('name')->contains('senior-officer')) {
|
||||||
|
$userTeam = TeamsUsers::with('team')->firstWhere('user_id', $user->id);
|
||||||
|
$regionId = $userTeam?->team->regions_id;
|
||||||
|
$teamId = $userTeam?->teams_id;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
$teamsActivity = TeamsUsers::with(['user', 'team', 'team.regions', 'user.roles'])
|
||||||
|
->whereHas('team', function ($q) use ($regionId, $teamId) {
|
||||||
|
$q->when($regionId, fn ($q) => $q->where('regions_id', $regionId))
|
||||||
|
->when($teamId, fn ($q) => $q->where('id', $teamId));
|
||||||
|
})
|
||||||
|
->where('user_id', '!=', $user->id)
|
||||||
|
->whereHas('user.roles', fn ($q) => $q->whereIn('name', ['surveyor', 'surveyor-penilai']))
|
||||||
|
->get();
|
||||||
|
|
||||||
|
$teamId = is_array($teamId) ? $teamId : [$teamId];
|
||||||
|
|
||||||
|
$teamPenilai = Teams::with(['regions', 'teamsUsers', 'teamsUsers.user'])->whereNotIn(
|
||||||
|
'id',
|
||||||
|
$teamId
|
||||||
|
)->get();
|
||||||
|
|
||||||
|
|
||||||
|
return view('lpj::activity.progres_activity.index', compact('teamsActivity', 'teamPenilai'));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public function updateTeamAssingment(Request $request)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
|
||||||
|
// dd($request->all());
|
||||||
|
$validatedData = $request->validate([
|
||||||
|
'id' => 'required|integer', // penilaian_id
|
||||||
|
'team_member_id' => 'nullable|integer',
|
||||||
|
'region_id' => 'nullable|integer',
|
||||||
|
'permohonan_id' => 'required|integer',
|
||||||
|
'user_id' => 'required|integer',
|
||||||
|
'team_id' => 'required|integer',
|
||||||
|
'penugasan' => 'required|string',
|
||||||
|
], [
|
||||||
|
'team_member_id.required_without' => 'Field team harus diisi.',
|
||||||
|
'.required_without' => 'Field harus diisi.',
|
||||||
|
]);
|
||||||
|
|
||||||
|
|
||||||
|
$penilaianId = $validatedData['id'];
|
||||||
|
$teamMemberId = $validatedData['team_member_id'] ?? null;
|
||||||
|
$regionId = $validatedData['region_id'] ?? null;
|
||||||
|
$permohonanId = $validatedData['permohonan_id'];
|
||||||
|
$userId = $validatedData['user_id'];
|
||||||
|
$teamId = $validatedData['team_id'];
|
||||||
|
$penugasan = $validatedData['penugasan'];
|
||||||
|
|
||||||
|
// Cek apakah permohonan ada
|
||||||
|
$permohonan = Permohonan::findOrFail($permohonanId);
|
||||||
|
|
||||||
|
// Validasi status permohonan
|
||||||
|
// if ($permohonan->status !== 'assign' && $permohonan->status !== 'proses-survey' && $permohonan->status !== 'survey' && $permohonan->status !== 'proses-laporan') {
|
||||||
|
// return response()->json([
|
||||||
|
// 'status' => 'error',
|
||||||
|
// 'message' => 'Tidak dapat mengganti tim, status permohonan tidak memungkinkan.',
|
||||||
|
// ]);
|
||||||
|
// }
|
||||||
|
|
||||||
|
// Ambil tim berdasarkan penilaian_id dan user_id
|
||||||
|
|
||||||
|
if ($penugasan === 'sama') {
|
||||||
|
$teams = PenilaianTeam::where('penilaian_id', $penilaianId)
|
||||||
|
->where('user_id', $userId)
|
||||||
|
->get();
|
||||||
|
// Cek apakah tim ditemukan
|
||||||
|
if ($teams->isEmpty()) {
|
||||||
|
return response()->json([
|
||||||
|
'status' => 'error',
|
||||||
|
'message' => 'Data tim tidak ditemukan.',
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Mulai transaksi
|
||||||
|
DB::beginTransaction();
|
||||||
|
$updated = false;
|
||||||
|
|
||||||
|
$status_permohonan = $permohonan->status;
|
||||||
|
|
||||||
|
// Proses update berdasarkan region_id
|
||||||
|
if ($regionId) {
|
||||||
|
foreach ($teams as $team) {
|
||||||
|
if ($team->role === 'surveyor') {
|
||||||
|
$team->update([
|
||||||
|
'team_id' => $regionId,
|
||||||
|
'user_id' => null,
|
||||||
|
'status' => $status_permohonan,
|
||||||
|
]);
|
||||||
|
$permohonan->update([
|
||||||
|
'status' => 'reassign'
|
||||||
|
]);
|
||||||
|
$updated = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($team->role === 'penilai') {
|
||||||
|
$team->update([
|
||||||
|
'team_id' => $regionId,
|
||||||
|
'user_id' => null,
|
||||||
|
'status' => $status_permohonan
|
||||||
|
]);
|
||||||
|
$permohonan->update([
|
||||||
|
'status' => 'reassign',
|
||||||
|
'region_id' => $regionId,
|
||||||
|
]);
|
||||||
|
$updated = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Proses update berdasarkan team_member_id
|
||||||
|
if ($teamMemberId) {
|
||||||
|
foreach ($teams as $team) {
|
||||||
|
if ($team->role === 'surveyor' || $team->role === 'penilai') {
|
||||||
|
$team->update(['user_id' => $teamMemberId]);
|
||||||
|
$updated = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($penugasan === 'surveyor' || $penugasan === 'penilai') {
|
||||||
|
$teams = PenilaianTeam::where('penilaian_id', $penilaianId)
|
||||||
|
->where('user_id', $userId)
|
||||||
|
->where('role', $penugasan)
|
||||||
|
->first();
|
||||||
|
|
||||||
|
// Cek apakah tim ditemukan
|
||||||
|
if (!$teams) {
|
||||||
|
return response()->json([
|
||||||
|
'status' => 'error',
|
||||||
|
'message' => 'Data tim tidak ditemukan.',
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Mulai transaksi
|
||||||
|
DB::beginTransaction();
|
||||||
|
$updated = false;
|
||||||
|
|
||||||
|
// Proses update berdasarkan region_id
|
||||||
|
if ($regionId) {
|
||||||
|
$teams->update([
|
||||||
|
'team_id' => $regionId,
|
||||||
|
'user_id' => null
|
||||||
|
]);
|
||||||
|
$permohonan->update([
|
||||||
|
'status' => $status_permohonan,
|
||||||
|
'region_id' => $regionId,
|
||||||
|
]);
|
||||||
|
$updated = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Proses update berdasarkan team_member_id
|
||||||
|
if ($teamMemberId) {
|
||||||
|
$teams->update(['user_id' => $teamMemberId]);
|
||||||
|
$updated = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if ($updated) {
|
||||||
|
DB::commit();
|
||||||
|
return response()->json([
|
||||||
|
'status' => 'success',
|
||||||
|
'message' => 'Data tim berhasil diperbarui.',
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
DB::rollBack();
|
||||||
|
return response()->json([
|
||||||
|
'status' => 'error',
|
||||||
|
'message' => 'Tidak ada perubahan yang dilakukan.',
|
||||||
|
]);
|
||||||
|
} catch (\Throwable $th) {
|
||||||
|
// Rollback transaksi jika terjadi error
|
||||||
|
DB::rollBack();
|
||||||
|
return response()->json([
|
||||||
|
'status' => 'error',
|
||||||
|
'message' => 'Terjadi kesalahan: ' . $th->getMessage(),
|
||||||
|
], 500);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public function senior()
|
||||||
|
{
|
||||||
|
return view('lpj::activity.senior_officer.index');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Store a newly created resource in storage.
|
||||||
|
*/
|
||||||
|
public function store(Request $request): RedirectResponse
|
||||||
|
{
|
||||||
|
//
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show the specified resource.
|
||||||
|
*/
|
||||||
|
public function show($id)
|
||||||
|
{
|
||||||
|
|
||||||
|
$status_permohonan = StatusPermohonan::orderBy('id')->get()->reverse();
|
||||||
|
|
||||||
|
$permohonan = Permohonan::with(
|
||||||
|
[
|
||||||
|
'user',
|
||||||
|
'debiture.province',
|
||||||
|
'debiture.city',
|
||||||
|
'debiture.district',
|
||||||
|
'debiture.village',
|
||||||
|
'branch',
|
||||||
|
'tujuanPenilaian',
|
||||||
|
'penilaian'
|
||||||
|
],
|
||||||
|
)->findOrFail($id);
|
||||||
|
|
||||||
|
return view('lpj::activity.activitydetail', compact('id', 'status_permohonan', 'permohonan'));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show the form for editing the specified resource.
|
||||||
|
*/
|
||||||
|
public function edit($id)
|
||||||
|
{
|
||||||
|
return view('lpj::edit');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update the specified resource in storage.
|
||||||
|
*/public function dataForDatatables(Request $request)
|
||||||
|
{
|
||||||
|
|
||||||
|
$user = auth()->user();
|
||||||
|
|
||||||
|
|
||||||
|
// Check permissions
|
||||||
|
if (is_null($this->user) || !$this->user->can('debitur.view')) {
|
||||||
|
// abort(403, 'Sorry! You are not allowed to view users.');
|
||||||
|
}
|
||||||
|
|
||||||
|
$userRole = $user->roles->pluck('name')->first();
|
||||||
|
$regionId = null;
|
||||||
|
|
||||||
|
// If user is senior-officer, get their regionId
|
||||||
|
if ($userRole === 'senior-officer') {
|
||||||
|
$userTeam = TeamsUsers::with('team')->firstWhere('user_id', $user->id);
|
||||||
|
$regionId = $userTeam?->team->regions_id;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Retrieve data from the database
|
||||||
|
$query = Permohonan::query();
|
||||||
|
|
||||||
|
// Apply search filter if provided
|
||||||
|
if ($request->has('search') && !empty($request->get('search'))) {
|
||||||
|
$search = $request->get('search');
|
||||||
|
$query->where(function ($q) use ($search) {
|
||||||
|
$q->where('nomor_registrasi', 'LIKE', '%' . $search . '%')
|
||||||
|
->orWhere('tanggal_permohonan', 'LIKE', '%' . $search . '%')
|
||||||
|
->orWhereRelation('user', 'name', 'LIKE', '%' . $search . '%')
|
||||||
|
->orWhereRelation('debiture', 'name', 'LIKE', '%' . $search . '%')
|
||||||
|
->orWhereRelation('tujuanPenilaian', 'name', 'LIKE', '%' . $search . '%')
|
||||||
|
->orWhereRelation('branch', 'name', 'LIKE', '%' . $search . '%');
|
||||||
|
|
||||||
|
// Split search term by comma to allow multiple statuses
|
||||||
|
$statusKeywords = explode(',', $search);
|
||||||
|
foreach ($statusKeywords as $keyword) {
|
||||||
|
$q->orWhere('status', 'LIKE', '%' . trim($keyword) . '%');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// Default sorting if no sort provided
|
||||||
|
if ($request->has('sortOrder') && !empty($request->get('sortOrder'))) {
|
||||||
|
$order = $request->get('sortOrder');
|
||||||
|
$column = $request->get('sortField');
|
||||||
|
$query->orderBy($column, $order);
|
||||||
|
} else {
|
||||||
|
$query->orderBy('nomor_registrasi', 'asc');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get total count of records before pagination
|
||||||
|
$totalRecords = $query->count();
|
||||||
|
|
||||||
|
// Pagination
|
||||||
|
if ($request->has('page') && $request->has('size')) {
|
||||||
|
$page = (int) $request->get('page', 1);
|
||||||
|
$size = (int) $request->get('size', 10);
|
||||||
|
$offset = ($page - 1) * $size;
|
||||||
|
$query->skip($offset)->take($size);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get filtered count
|
||||||
|
$filteredRecords = $query->count();
|
||||||
|
|
||||||
|
// Filter by region if user is senior-officer
|
||||||
|
if ($regionId) {
|
||||||
|
$query->whereHas('region', function ($q) use ($regionId) {
|
||||||
|
$q->where('region_id', $regionId);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// Filter for specific roles
|
||||||
|
if (in_array($userRole, ['surveyor', 'penilai'])) {
|
||||||
|
$query->whereHas('penilaian.userPenilai', function ($q) use ($user) {
|
||||||
|
$q->where('user_id', $user->id);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
$totalRecords = $query->count();
|
||||||
|
|
||||||
|
// Pagination
|
||||||
|
if ($request->has('page') && $request->has('size')) {
|
||||||
|
$page = (int) $request->get('page', 1);
|
||||||
|
$size = (int) $request->get('size', 10);
|
||||||
|
$offset = ($page - 1) * $size;
|
||||||
|
$query->skip($offset)->take($size);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get filtered count
|
||||||
|
$filteredRecords = $query->count();
|
||||||
|
|
||||||
|
// Get data with necessary relationships
|
||||||
|
$data = $query->with(['user', 'debiture', 'branch', 'tujuanPenilaian', 'penilaian', 'dokumenjaminan','nilaiPlafond'])->get();
|
||||||
|
|
||||||
|
// Calculate total pages
|
||||||
|
$pageCount = ceil($totalRecords / $request->get('size', 10));
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// Calculate total pages
|
||||||
|
$pageCount = ceil($totalRecords / $request->get('size', 10));
|
||||||
|
|
||||||
|
return response()->json([
|
||||||
|
'draw' => $request->get('draw'),
|
||||||
|
'recordsTotal' => $totalRecords,
|
||||||
|
'recordsFiltered' => $filteredRecords,
|
||||||
|
'pageCount' => $pageCount,
|
||||||
|
'page' => $request->get('page', 1),
|
||||||
|
'totalCount' => $totalRecords,
|
||||||
|
'data' => $data,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Download the specified resource from storage.
|
||||||
|
*/
|
||||||
|
public function download($id)
|
||||||
|
{
|
||||||
|
$document = Permohonan::find($id);
|
||||||
|
return response()->download(storage_path('app/public/' . $document->dokumen));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function export()
|
||||||
|
{
|
||||||
|
return Excel::download(new PermohonanExport(), 'activity.xlsx');
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public function dataTablesForActivity(Request $request, $id)
|
||||||
|
{
|
||||||
|
|
||||||
|
if (is_null($this->user) || !$this->user->can('debitur.view')) {
|
||||||
|
// abort(403, 'Sorry! You are not allowed to view users.');
|
||||||
|
}
|
||||||
|
// Query Penilaian dengan relasi yang diperlukan
|
||||||
|
$query = Penilaian::with([
|
||||||
|
'permohonan',
|
||||||
|
'permohonan.debiture',
|
||||||
|
'permohonan.tujuanPenilaian',
|
||||||
|
'permohonan.debiture.documents.jenisJaminan',
|
||||||
|
'userPenilai' => function ($query) use ($id) {
|
||||||
|
$query->where('user_id', $id);
|
||||||
|
},
|
||||||
|
'permohonan.penilai',
|
||||||
|
'permohonan.approveEo',
|
||||||
|
'permohonan.approveDd',
|
||||||
|
'permohonan.approveSo',
|
||||||
|
|
||||||
|
])
|
||||||
|
->whereHas('userPenilai', function ($q) use ($id) {
|
||||||
|
$q->where('user_id', $id);
|
||||||
|
})
|
||||||
|
->whereHas('permohonan', function ($q) {
|
||||||
|
$q->whereIn('status', [
|
||||||
|
'assign',
|
||||||
|
'survey-completed',
|
||||||
|
'proses-laporan',
|
||||||
|
'paparan',
|
||||||
|
'proses-paparan',
|
||||||
|
'revisi-laporan',
|
||||||
|
'revisi-paparan',
|
||||||
|
'survey',
|
||||||
|
'proses-survey',
|
||||||
|
'request-reschedule',
|
||||||
|
'reschedule',
|
||||||
|
'rejected-reschedule',
|
||||||
|
'approved-reschedule',
|
||||||
|
'revisi-survey',
|
||||||
|
'revisi-pembayaran'
|
||||||
|
]);
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// Filter pencarian
|
||||||
|
if ($request->has('search') && !empty($request->get('search'))) {
|
||||||
|
$search = $request->get('search');
|
||||||
|
$query->where(function ($q) use ($search) {
|
||||||
|
$q->where('nomor_registrasi', 'LIKE', "%$search%")
|
||||||
|
->orWhere('status', 'LIKE', "%$search%");
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// Sorting
|
||||||
|
if ($request->has('sortOrder') && !empty($request->get('sortOrder'))) {
|
||||||
|
$order = $request->get('sortOrder');
|
||||||
|
$column = $request->get('sortField');
|
||||||
|
$query->orderBy($column, $order);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Hitung total records
|
||||||
|
$totalRecords = $query->count();
|
||||||
|
|
||||||
|
// Pagination
|
||||||
|
$size = $request->get('size', 10);
|
||||||
|
$page = $request->get('page', 1);
|
||||||
|
$offset = ($page - 1) * $size;
|
||||||
|
|
||||||
|
// Ambil data dengan pagination
|
||||||
|
$data = $query->skip($offset)->take($size)->get();
|
||||||
|
|
||||||
|
$data = $data->map(function ($item) {
|
||||||
|
$jeniAsset = null;
|
||||||
|
$statusPembayaran = trim(strtolower($item->permohonan->status_bayar ?? ''));
|
||||||
|
$tujuanPenilaian = $item->permohonan->tujuanPenilaian->name ?? null;
|
||||||
|
$plafond = $item->permohonan->nilaiPlafond->name ?? null;
|
||||||
|
|
||||||
|
$now = Carbon::now();
|
||||||
|
$type_report = $item->permohonan->penilai->type ?? "";
|
||||||
|
|
||||||
|
$hari = $hariPaparan = 0;
|
||||||
|
|
||||||
|
if ($type_report == "sederhana") {
|
||||||
|
$hari = 2;
|
||||||
|
$item->paparan = 'Tidak Ada';
|
||||||
|
} else {
|
||||||
|
if ($plafond == '< 2M') {
|
||||||
|
$item->paparan = 'Tidak Ada';
|
||||||
|
$hari = 3;
|
||||||
|
} elseif ($plafond == '2 M - 5 M') {
|
||||||
|
$hari = 3;
|
||||||
|
$hariPaparan = 2;
|
||||||
|
} else {
|
||||||
|
$hari = 5;
|
||||||
|
$hariPaparan = 3;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($tujuanPenilaian == 'RAP') {
|
||||||
|
$hari = 2;
|
||||||
|
$hariPaparan = 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if ($item->permohonan && $item->permohonan->debiture) {
|
||||||
|
$jeniAsset = $item->permohonan->debiture->documents->first() ?? null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*$hariTambahan = 0;
|
||||||
|
|
||||||
|
if ($tujuanPenilaian == 'RAP') {
|
||||||
|
$hariTambahan = 2;
|
||||||
|
} else {
|
||||||
|
if ($statusPembayaran == 'sudah_bayar') {
|
||||||
|
$hariTambahan = 1; // H+1 untuk yang sudah bayar
|
||||||
|
} else {
|
||||||
|
$hariTambahan = 2; // H+2 untuk yang belum bayar
|
||||||
|
}
|
||||||
|
}*/
|
||||||
|
|
||||||
|
$tanggalMulai = $item->waktu_penilaian;
|
||||||
|
|
||||||
|
if ($tanggalMulai) {
|
||||||
|
if (!$tanggalMulai instanceof Carbon) {
|
||||||
|
$tanggalMulai = Carbon::parse($tanggalMulai);
|
||||||
|
}
|
||||||
|
$hariKerjaBerikutnya = hitungHariKerja($tanggalMulai->toDateString(), $tanggalMulai->copy()->addDays(1));
|
||||||
|
$hariKerjaBerikutnya = max($hariKerjaBerikutnya, 1);
|
||||||
|
$tanggalMulai = $tanggalMulai->copy()->addDays($hariKerjaBerikutnya);
|
||||||
|
|
||||||
|
// Konversi string tanggal ke objek Carbon jika belum
|
||||||
|
if (!$tanggalMulai instanceof Carbon) {
|
||||||
|
$tanggalMulai = Carbon::parse($tanggalMulai);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Hitung tanggal selesai berdasarkan hari tambahan
|
||||||
|
$tanggalSelesai = $tanggalMulai->copy()->addDays($hari);
|
||||||
|
$tanggalPaparan = $tanggalMulai->copy()->addDays($hariPaparan);
|
||||||
|
|
||||||
|
// Hitung hari kerja
|
||||||
|
$hariKerja = hitungHariKerja($tanggalMulai->toDateString(), $tanggalSelesai->toDateString());
|
||||||
|
$hariKerja = max($hariKerja, $hari);
|
||||||
|
|
||||||
|
$hariKerjaPaparan = hitungHariKerja($tanggalMulai->toDateString(), $tanggalPaparan->toDateString());
|
||||||
|
$hariKerjaPaparan = max($hariKerjaPaparan, $hariPaparan);
|
||||||
|
|
||||||
|
// Set due date SLA
|
||||||
|
$dueDateSla = $tanggalMulai->copy()->addDays($hariKerja);
|
||||||
|
$dueDateSlaPaparan = $tanggalMulai->copy()->addDays($hariKerjaPaparan);
|
||||||
|
|
||||||
|
// Cek apakah sudah melewati due date
|
||||||
|
/*if ($now->greaterThan($dueDateSla)) {
|
||||||
|
$item->due_date_sla = null;
|
||||||
|
} else {
|
||||||
|
$item->due_date_sla = $dueDateSla->toDateString();
|
||||||
|
}*/
|
||||||
|
|
||||||
|
$item->due_date_sla = $dueDateSla->toDateString();
|
||||||
|
$item->paparan = $dueDateSlaPaparan->toDateString();
|
||||||
|
} else {
|
||||||
|
$item->due_date_sla = null;
|
||||||
|
$item->paparan = null;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
return $item;
|
||||||
|
});
|
||||||
|
|
||||||
|
$filteredRecords = $data->count();
|
||||||
|
$pageCount = ceil($totalRecords / $size);
|
||||||
|
|
||||||
|
// Return data dalam bentuk JSON
|
||||||
|
return response()->json([
|
||||||
|
'draw' => $request->get('draw'),
|
||||||
|
'recordsTotal' => $totalRecords,
|
||||||
|
'recordsFiltered' => $filteredRecords,
|
||||||
|
'pageCount' => $pageCount,
|
||||||
|
'page' => $page,
|
||||||
|
'totalCount' => $totalRecords,
|
||||||
|
'data' => $data
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
149
app/Http/Controllers/ArahMataAnginController.php
Normal file
149
app/Http/Controllers/ArahMataAnginController.php
Normal file
@@ -0,0 +1,149 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Modules\Lpj\Http\Controllers;
|
||||||
|
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use Exception;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Maatwebsite\Excel\Facades\Excel;
|
||||||
|
use Modules\Lpj\Exports\ArahMataAnginExport;
|
||||||
|
use Modules\Lpj\Http\Requests\ArahMataAnginRequest;
|
||||||
|
use Modules\Lpj\Models\ArahMataAngin;
|
||||||
|
|
||||||
|
class ArahMataAnginController extends Controller
|
||||||
|
{
|
||||||
|
public $user;
|
||||||
|
|
||||||
|
public function index()
|
||||||
|
{
|
||||||
|
return view('lpj::arah_mata_angin.index');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function store(ArahMataAnginRequest $request)
|
||||||
|
{
|
||||||
|
$validate = $request->validated();
|
||||||
|
|
||||||
|
if ($validate) {
|
||||||
|
try {
|
||||||
|
// Save to database
|
||||||
|
ArahMataAngin::create($validate);
|
||||||
|
return redirect()
|
||||||
|
->route('basicdata.arah-mata-angin.index')
|
||||||
|
->with('success', 'Arah Mata Angin created successfully');
|
||||||
|
} catch (Exception $e) {
|
||||||
|
return redirect()
|
||||||
|
->route('basicdata.arah-mata-angin.create')
|
||||||
|
->with('error', 'Failed to create arah mata angin');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function create()
|
||||||
|
{
|
||||||
|
return view('lpj::arah_mata_angin.create');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function edit($id)
|
||||||
|
{
|
||||||
|
$arahMataAngin = ArahMataAngin::find($id);
|
||||||
|
return view('lpj::arah_mata_angin.create', compact('arahMataAngin'));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function update(ArahMataAnginRequest $request, $id)
|
||||||
|
{
|
||||||
|
$validate = $request->validated();
|
||||||
|
|
||||||
|
if ($validate) {
|
||||||
|
try {
|
||||||
|
// Update in database
|
||||||
|
$arahMataAngin = ArahMataAngin::find($id);
|
||||||
|
$arahMataAngin->update($validate);
|
||||||
|
return redirect()
|
||||||
|
->route('basicdata.arah-mata-angin.index')
|
||||||
|
->with('success', 'Arah Mata Angin updated successfully');
|
||||||
|
} catch (Exception $e) {
|
||||||
|
return redirect()
|
||||||
|
->route('basicdata.arah-mata-angin.edit', $id)
|
||||||
|
->with('error', 'Failed to update arah mata angin');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function destroy($id)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
// Delete from database
|
||||||
|
$arahMataAngin = ArahMataAngin::find($id);
|
||||||
|
$arahMataAngin->delete();
|
||||||
|
|
||||||
|
echo json_encode(['success' => true, 'message' => 'Arah Mata Angin deleted successfully']);
|
||||||
|
} catch (Exception $e) {
|
||||||
|
echo json_encode(['success' => false, 'message' => 'Failed to delete arah mata angin']);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function dataForDatatables(Request $request)
|
||||||
|
{
|
||||||
|
if (is_null($this->user) || !$this->user->can('arah_mata_angin.view')) {
|
||||||
|
//abort(403, 'Sorry! You are not allowed to view users.');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Retrieve data from the database
|
||||||
|
$query = ArahMataAngin::query();
|
||||||
|
|
||||||
|
// Apply search filter if provided
|
||||||
|
if ($request->has('search') && !empty($request->get('search'))) {
|
||||||
|
$search = $request->get('search');
|
||||||
|
$query->where(function ($q) use ($search) {
|
||||||
|
$q->Where('name', 'LIKE', "%$search%");
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// Apply sorting if provided
|
||||||
|
if ($request->has('sortOrder') && !empty($request->get('sortOrder'))) {
|
||||||
|
$order = $request->get('sortOrder');
|
||||||
|
$column = $request->get('sortField');
|
||||||
|
$query->orderBy($column, $order);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get the total count of records
|
||||||
|
$totalRecords = $query->count();
|
||||||
|
|
||||||
|
// Apply pagination if provided
|
||||||
|
if ($request->has('page') && $request->has('size')) {
|
||||||
|
$page = $request->get('page');
|
||||||
|
$size = $request->get('size');
|
||||||
|
$offset = ($page - 1) * $size; // Calculate the offset
|
||||||
|
|
||||||
|
$query->skip($offset)->take($size);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get the filtered count of records
|
||||||
|
$filteredRecords = $query->count();
|
||||||
|
|
||||||
|
// Get the data for the current page
|
||||||
|
$data = $query->get();
|
||||||
|
|
||||||
|
// Calculate the page count
|
||||||
|
$pageCount = ceil($totalRecords / $request->get('size'));
|
||||||
|
|
||||||
|
// Calculate the current page number
|
||||||
|
$currentPage = 0 + 1;
|
||||||
|
|
||||||
|
// Return the response data as a JSON object
|
||||||
|
return response()->json([
|
||||||
|
'draw' => $request->get('draw'),
|
||||||
|
'recordsTotal' => $totalRecords,
|
||||||
|
'recordsFiltered' => $filteredRecords,
|
||||||
|
'pageCount' => $pageCount,
|
||||||
|
'page' => $currentPage,
|
||||||
|
'totalCount' => $totalRecords,
|
||||||
|
'data' => $data,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function export()
|
||||||
|
{
|
||||||
|
return Excel::download(new ArahMataAnginExport, 'arah_mata_angin.xlsx');
|
||||||
|
}
|
||||||
|
}
|
||||||
328
app/Http/Controllers/BankDataController.php
Normal file
328
app/Http/Controllers/BankDataController.php
Normal file
@@ -0,0 +1,328 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Modules\Lpj\Http\Controllers;
|
||||||
|
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Routing\Controller;
|
||||||
|
use Illuminate\Support\Facades\Log;
|
||||||
|
use Modules\Location\Models\Province;
|
||||||
|
use Modules\Lpj\Http\Requests\BankDataRequest;
|
||||||
|
use Modules\Lpj\Models\BankData;
|
||||||
|
use Modules\Lpj\Models\Inspeksi;
|
||||||
|
use Modules\Lpj\Models\JenisJaminan;
|
||||||
|
use Modules\Lpj\Services\BankDataService;
|
||||||
|
|
||||||
|
class BankDataController extends Controller
|
||||||
|
{
|
||||||
|
protected $bankDataService;
|
||||||
|
protected $user;
|
||||||
|
|
||||||
|
public function __construct(BankDataService $bankDataService)
|
||||||
|
{
|
||||||
|
$this->bankDataService = $bankDataService;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function index(Request $request)
|
||||||
|
{
|
||||||
|
$provinces = Province::all();
|
||||||
|
$jenisJaminan = JenisJaminan::all();
|
||||||
|
|
||||||
|
//insert data pembanding
|
||||||
|
|
||||||
|
$inspeksi = Inspeksi::all();
|
||||||
|
|
||||||
|
foreach ($inspeksi as $item) {
|
||||||
|
if (isset($item->data_pembanding)) {
|
||||||
|
$data_pembanding = json_decode($item->data_pembanding);
|
||||||
|
|
||||||
|
$objekPenilaian = $data_pembanding->objek_penilaian;
|
||||||
|
if (isset($objekPenilaian)) {
|
||||||
|
$_lat = $objekPenilaian->kordinat_lat;
|
||||||
|
$_lng = $objekPenilaian->kordinat_lng;
|
||||||
|
|
||||||
|
if (!empty($_lat) && !empty($_lng) && $_lng !== null && $_lat !== null && $_lat !== '' && $_lng !== '') {
|
||||||
|
$_lat = floatval($_lat);
|
||||||
|
$_lng = floatval($_lng);
|
||||||
|
if ($_lat >= -90 && $_lat <= 90 && $_lng >= -180 && $_lng <= 180) {
|
||||||
|
|
||||||
|
$_data = [
|
||||||
|
'address' => $objekPenilaian->address,
|
||||||
|
'village_code' => $objekPenilaian->village_code,
|
||||||
|
'district_code' => $objekPenilaian->district_code,
|
||||||
|
'city_code' => $objekPenilaian->city_code,
|
||||||
|
'province_code' => $objekPenilaian->province_code,
|
||||||
|
'tahun' => $item->created_at->format('Y'),
|
||||||
|
//
|
||||||
|
'luas_tanah' => isset($objekPenilaian->luas_tanah) && is_numeric($objekPenilaian->luas_tanah) ? $objekPenilaian->luas_tanah : 0,
|
||||||
|
'luas_bangunan' => isset($objekPenilaian->luas_bangunan) && is_numeric($objekPenilaian->luas_bangunan) ? $objekPenilaian->luas_bangunan : 0,
|
||||||
|
//
|
||||||
|
'tahun_bangunan' => isset($objekPenilaian->tahun_bangunan) && is_numeric($objekPenilaian->tahun_bangunan) ? $objekPenilaian->tahun_bangunan : 0,
|
||||||
|
//
|
||||||
|
'harga' => isset($objekPenilaian->harga) && is_numeric($objekPenilaian->harga) ? $objekPenilaian->harga : 0,
|
||||||
|
'harga_diskon' => isset($objekPenilaian->harga_diskon) && is_numeric($objekPenilaian->harga_diskon) ? $objekPenilaian->harga_diskon : 0,
|
||||||
|
'diskon' => isset($objekPenilaian->diskon) && is_numeric(str_replace(',', '.', $objekPenilaian->diskon)) ? str_replace(',', '.', $objekPenilaian->diskon) : 0,
|
||||||
|
'total' => isset($objekPenilaian->total) && is_numeric($objekPenilaian->total) ? $objekPenilaian->total : 0,
|
||||||
|
'harga_penawaran' => isset($objekPenilaian->harga_penawaran) && is_numeric($objekPenilaian->harga_penawaran) ? $objekPenilaian->harga_penawaran : 0,
|
||||||
|
'nama_nara_sumber' => $objekPenilaian->nama_nara_sumber,
|
||||||
|
'peruntukan' => $objekPenilaian->peruntukan ?? "",
|
||||||
|
//
|
||||||
|
'penawaran' => $objekPenilaian->penawaran ?? "",
|
||||||
|
//
|
||||||
|
'telepon' => $objekPenilaian->telepon ?? "",
|
||||||
|
'hak_properti' => $objekPenilaian->hak_properti ?? "",
|
||||||
|
'jenis_aset' => $objekPenilaian->jenis_aset ?? "",
|
||||||
|
'foto_objek' => $objekPenilaian->foto_objek ?? "",
|
||||||
|
'tanggal' => $objekPenilaian->tanggal ?? null,
|
||||||
|
'kategori' => 'penilaian',
|
||||||
|
];
|
||||||
|
|
||||||
|
|
||||||
|
BankData::updateOrCreate(
|
||||||
|
[
|
||||||
|
'kordinat_lat' => $_lat,
|
||||||
|
'kordinat_lng' => $_lng,
|
||||||
|
'kategori' => 'penilaian'
|
||||||
|
],
|
||||||
|
$_data
|
||||||
|
);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// Invalid coordinates
|
||||||
|
Log::warning("Invalid coordinates: Lat: $_lat, Lng: $_lng"); // Do something to handle this situation, such as logging an error or skipping the record
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($data_pembanding->data_pembanding)) {
|
||||||
|
foreach ($data_pembanding->data_pembanding as $dataPembanding) {
|
||||||
|
if (!isset($dataPembanding->kordinat_lat) || !isset($dataPembanding->kordinat_lng)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
$lat = $dataPembanding->kordinat_lat;
|
||||||
|
$lng = $dataPembanding->kordinat_lng;
|
||||||
|
|
||||||
|
if (!empty($lat) && !empty($lng) && $lng !== null && $lat !== null && $lat !== '' && $lng !== '') {
|
||||||
|
$lat = floatval($lat);
|
||||||
|
$lng = floatval($lng);
|
||||||
|
|
||||||
|
if ($lat >= -90 && $lat <= 90 && $lng >= -180 && $lng <= 180) {
|
||||||
|
$data = [
|
||||||
|
'address' => $dataPembanding->address,
|
||||||
|
'village_code' => $dataPembanding->village_code,
|
||||||
|
'district_code' => $dataPembanding->district_code,
|
||||||
|
'city_code' => $dataPembanding->city_code,
|
||||||
|
'province_code' => $dataPembanding->province_code,
|
||||||
|
'tahun' => isset($dataPembanding->tahun) && is_numeric($dataPembanding->tahun) ? $dataPembanding->tahun : 0,
|
||||||
|
'luas_tanah' => isset($dataPembanding->luas_tanah) && is_numeric($dataPembanding->luas_tanah) ? $dataPembanding->luas_tanah : 0,
|
||||||
|
'luas_bangunan' => isset($dataPembanding->luas_bangunan) && is_numeric($dataPembanding->luas_bangunan) ? $dataPembanding->luas_bangunan : 0,
|
||||||
|
'tahun_bangunan' => isset($dataPembanding->tahun_bangunan) && is_numeric($dataPembanding->tahun_bangunan) ? $dataPembanding->tahun_bangunan : 0,
|
||||||
|
'harga' => isset($dataPembanding->harga) && is_numeric($dataPembanding->harga) ? $dataPembanding->harga : 0,
|
||||||
|
'harga_diskon' => isset($dataPembanding->harga_diskon) && is_numeric($dataPembanding->harga_diskon) ? $dataPembanding->harga_diskon : 0,
|
||||||
|
'diskon' => isset($dataPembanding->diskon) && is_numeric(str_replace(',', '.', $dataPembanding->diskon)) ? str_replace(',', '.', $dataPembanding->diskon) : 0,
|
||||||
|
'total' => isset($dataPembanding->total) && is_numeric($dataPembanding->total) ? $dataPembanding->total : 0,
|
||||||
|
'harga_penawaran' => isset($dataPembanding->harga_penawaran) && is_numeric($dataPembanding->harga_penawaran) ? $dataPembanding->harga_penawaran : 0,
|
||||||
|
'nama_nara_sumber' => $dataPembanding->nama_nara_sumber,
|
||||||
|
'peruntukan' => $dataPembanding->peruntukan,
|
||||||
|
'penawaran' => $dataPembanding->penawaran,
|
||||||
|
'telepon' => $dataPembanding->telepon,
|
||||||
|
'hak_properti' => $dataPembanding->hak_properti,
|
||||||
|
'jenis_aset' => $dataPembanding->jenis_aset,
|
||||||
|
'foto_objek' => $dataPembanding->foto_objek,
|
||||||
|
'tanggal' => $dataPembanding->tanggal ?? null,
|
||||||
|
'kategori' => 'data_pembanding',
|
||||||
|
];
|
||||||
|
|
||||||
|
BankData::updateOrCreate(
|
||||||
|
[
|
||||||
|
'kordinat_lat' => $lat,
|
||||||
|
'kordinat_lng' => $lng,
|
||||||
|
'kategori' => 'data_pembanding'
|
||||||
|
],
|
||||||
|
$data
|
||||||
|
);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// Invalid coordinates
|
||||||
|
Log::warning("Invalid coordinates: Lat: $lat, Lng: $lng"); // Do something to handle this situation, such as logging an error or skipping the record
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return view('lpj::bank-data.index', compact('provinces', 'jenisJaminan'));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function create()
|
||||||
|
{
|
||||||
|
return view('lpj::bank-data.create');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function store(BankDataRequest $request)
|
||||||
|
{
|
||||||
|
$data = $request->validated();
|
||||||
|
$bankData = $this->bankDataService->createBankData($data);
|
||||||
|
return redirect()
|
||||||
|
->route('lpj.bank-data.show', $bankData->id)
|
||||||
|
->with('success', 'Bank data created successfully.');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function show($id)
|
||||||
|
{
|
||||||
|
$bankData = $this->bankDataService->findBankData($id);
|
||||||
|
return view('lpj::bank-data.show', compact('bankData'));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function edit($id)
|
||||||
|
{
|
||||||
|
$bankData = $this->bankDataService->findBankData($id);
|
||||||
|
return view('lpj::bank-data.edit', compact('bankData'));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function update(BankDataRequest $request, $id)
|
||||||
|
{
|
||||||
|
$data = $request->validated();
|
||||||
|
$bankData = $this->bankDataService->updateBankData($id, $data);
|
||||||
|
return redirect()
|
||||||
|
->route('lpj.bank-data.show', $bankData->id)
|
||||||
|
->with('success', 'Bank data updated successfully.');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function destroy($id)
|
||||||
|
{
|
||||||
|
$this->bankDataService->deleteBankData($id);
|
||||||
|
return redirect()->route('lpj.bank-data.index')->with('success', 'Bank data deleted successfully.');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function dataForDatatables(Request $request)
|
||||||
|
{
|
||||||
|
if (is_null($this->user) || !$this->user->can('bank-data.view')) {
|
||||||
|
//abort(403, 'Sorry! You are not allowed to view bank data.');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Retrieve data from the database
|
||||||
|
$query = BankData::query();
|
||||||
|
|
||||||
|
// Apply search filter if provided
|
||||||
|
if ($request->has('search') && !empty($request->get('search'))) {
|
||||||
|
$search = $request->get('search');
|
||||||
|
$search = json_decode($search, true);
|
||||||
|
if (is_array($search)) {
|
||||||
|
|
||||||
|
if ($search['province_code']) {
|
||||||
|
$query->ofProvince($search['province_code']);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($search['kategori']) {
|
||||||
|
$query->where('kategori', $search['kategori']);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($search['city_code']) {
|
||||||
|
$query->ofCity($search['city_code']);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($search['district_code']) {
|
||||||
|
$query->ofDistrict($search['district_code']);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($search['village_code']) {
|
||||||
|
$query->ofVillage($search['village_code']);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($search['jenis_asset']) {
|
||||||
|
$query->ofAssetType($search['jenis_asset']);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($search['tahun']) {
|
||||||
|
$query->where('tahun', $search['tahun']);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($search['start_date'] && $search['end_date']) {
|
||||||
|
$query->betweenDates($search['start_date'], $search['end_date']);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$search = $request->get('search');
|
||||||
|
$query->where(function ($q) use ($search) {
|
||||||
|
$q->where('jenis_aset', 'LIKE', '%' . $search . '%');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Apply sorting if provided
|
||||||
|
if ($request->has('sortOrder') && !empty($request->get('sortOrder'))) {
|
||||||
|
$order = $request->get('sortOrder');
|
||||||
|
$column = $request->get('sortField');
|
||||||
|
|
||||||
|
// Handle special cases for computed fields
|
||||||
|
if ($column === 'location') {
|
||||||
|
$query->orderBy('kordinat_lat', $order)
|
||||||
|
->orderBy('kordinat_lng', $order);
|
||||||
|
}
|
||||||
|
// Map frontend column names to database columns
|
||||||
|
else if ($column === 'sumber') {
|
||||||
|
$column = 'kategori'; // Sort by kategori when sumber is requested
|
||||||
|
$query->orderBy($column, $order);
|
||||||
|
} else {
|
||||||
|
$query->orderBy($column, $order);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get the total count of records
|
||||||
|
$totalRecords = $query->count();
|
||||||
|
|
||||||
|
// Apply pagination if provided
|
||||||
|
if ($request->has('page') && $request->has('size')) {
|
||||||
|
$page = $request->get('page');
|
||||||
|
$size = $request->get('size');
|
||||||
|
$offset = ($page - 1) * $size; // Calculate the offset
|
||||||
|
|
||||||
|
$query->skip($offset)->take($size);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get the filtered count of records
|
||||||
|
$filteredRecords = $query->count();
|
||||||
|
|
||||||
|
// Get the data for the current page
|
||||||
|
$data = $query->get();
|
||||||
|
|
||||||
|
// Format the data as needed
|
||||||
|
$formattedData = $data->map(function ($item) {
|
||||||
|
return [
|
||||||
|
'id' => $item->id,
|
||||||
|
'jenis_aset' => $item->jenis_aset,
|
||||||
|
'tanggal' => isset($item->tanggal) && $item->tanggal ? $item->tanggal->format('d-m-Y') : '-',
|
||||||
|
'tahun' => $item->tahun,
|
||||||
|
'luas_tanah' => $item->luas_tanah,
|
||||||
|
'luas_bangunan' => $item->luas_bangunan,
|
||||||
|
'harga' => $item->harga,
|
||||||
|
'sumber' => $item->kategori ? ucwords(str_replace('_', ' ', $item->kategori)) : '-',
|
||||||
|
'kategori' => $item->kategori ?? 'data_pembanding',
|
||||||
|
'nilai_pasar' => $item->nilai_pasar,
|
||||||
|
'location' => $item->kordinat_lat . ', ' . $item->kordinat_lng,
|
||||||
|
'address' => formatAlamat($item),
|
||||||
|
'photos' => json_decode($item->foto_objek, true) ?: [$item->foto_objek],
|
||||||
|
// Add more fields as needed
|
||||||
|
];
|
||||||
|
});
|
||||||
|
|
||||||
|
// Calculate the page count
|
||||||
|
$pageCount = ceil($totalRecords / $request->get('size'));
|
||||||
|
|
||||||
|
// Calculate the current page number
|
||||||
|
$currentPage = $request->get('page', 1);
|
||||||
|
|
||||||
|
// Ensure current page doesn't exceed page count
|
||||||
|
$currentPage = min($currentPage, $pageCount);
|
||||||
|
|
||||||
|
|
||||||
|
// Return the response data as a JSON object
|
||||||
|
return response()->json([
|
||||||
|
'draw' => $request->get('draw'),
|
||||||
|
'recordsTotal' => $totalRecords,
|
||||||
|
'recordsFiltered' => $filteredRecords,
|
||||||
|
'pageCount' => $pageCount,
|
||||||
|
'page' => $currentPage,
|
||||||
|
'totalCount' => $totalRecords,
|
||||||
|
'data' => $formattedData,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
153
app/Http/Controllers/CustomFieldController.php
Normal file
153
app/Http/Controllers/CustomFieldController.php
Normal file
@@ -0,0 +1,153 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Modules\Lpj\Http\Controllers;
|
||||||
|
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use Exception;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Maatwebsite\Excel\Facades\Excel;
|
||||||
|
use Modules\Lpj\Exports\CustomFieldExport;
|
||||||
|
use Modules\Lpj\Http\Requests\CustomFieldRequest;
|
||||||
|
use Modules\Lpj\Models\CustomField;
|
||||||
|
|
||||||
|
class CustomFieldController extends Controller
|
||||||
|
{
|
||||||
|
public $user;
|
||||||
|
|
||||||
|
public function index()
|
||||||
|
{
|
||||||
|
return view('lpj::custom_fields.index');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function store(CustomFieldRequest $request)
|
||||||
|
{
|
||||||
|
$validate = $request->validated();
|
||||||
|
|
||||||
|
if ($validate) {
|
||||||
|
try {
|
||||||
|
// Save to database
|
||||||
|
CustomField::create($validate);
|
||||||
|
return redirect()
|
||||||
|
->route('basicdata.custom-field.index')
|
||||||
|
->with('success', 'Custom Field created successfully');
|
||||||
|
} catch (Exception $e) {
|
||||||
|
return redirect()
|
||||||
|
->route('basicdata.custom-field.create')
|
||||||
|
->with('error', $e->getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function create()
|
||||||
|
{
|
||||||
|
$urutan_prioritas = CustomField::max('urutan_prioritas')+1;
|
||||||
|
return view('lpj::custom_fields.create', compact('urutan_prioritas'));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function edit($id)
|
||||||
|
{
|
||||||
|
$customField = CustomField::find($id);
|
||||||
|
$urutan_prioritas = $customField->urutan_prioritas ?? CustomField::max('urutan_prioritas')+1;
|
||||||
|
return view('lpj::custom_fields.create', compact('customField', 'urutan_prioritas' ));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function update(CustomFieldRequest $request, $id)
|
||||||
|
{
|
||||||
|
$validate = $request->validated();
|
||||||
|
|
||||||
|
if ($validate) {
|
||||||
|
try {
|
||||||
|
// Update in database
|
||||||
|
$customField = CustomField::find($id);
|
||||||
|
$customField->update($validate);
|
||||||
|
return redirect()
|
||||||
|
->route('basicdata.custom-field.index')
|
||||||
|
->with('success', 'Custom Field updated successfully');
|
||||||
|
} catch (Exception $e) {
|
||||||
|
return redirect()
|
||||||
|
->route('basicdata.custom-field.edit', $id)
|
||||||
|
->with('error', 'Failed to update custom field');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function destroy($id)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
// Delete from database
|
||||||
|
$customField = CustomField::find($id);
|
||||||
|
$customField->delete();
|
||||||
|
|
||||||
|
echo json_encode(['success' => true, 'message' => 'Custom Field deleted successfully']);
|
||||||
|
} catch (Exception $e) {
|
||||||
|
echo json_encode(['success' => false, 'message' => 'Failed to delete custom field']);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function dataForDatatables(Request $request)
|
||||||
|
{
|
||||||
|
if (is_null($this->user) || !$this->user->can('custom_fields.view')) {
|
||||||
|
//abort(403, 'Sorry! You are not allowed to view custom fields.');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Retrieve data from the database
|
||||||
|
$query = CustomField::query();
|
||||||
|
|
||||||
|
// Apply search filter if provided
|
||||||
|
if ($request->has('search') && !empty($request->get('search'))) {
|
||||||
|
$search = $request->get('search');
|
||||||
|
$query->where(function ($q) use ($search) {
|
||||||
|
$q->where('name', 'LIKE', "%$search%");
|
||||||
|
$q->orWhere('label', 'LIKE', "%$search%");
|
||||||
|
$q->orWhere('type', 'LIKE', "%$search%");
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// Apply sorting if provided
|
||||||
|
if ($request->has('sortOrder') && !empty($request->get('sortOrder'))) {
|
||||||
|
$order = $request->get('sortOrder');
|
||||||
|
$column = $request->get('sortField');
|
||||||
|
$query->orderBy($column, $order);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get the total count of records
|
||||||
|
$totalRecords = $query->count();
|
||||||
|
|
||||||
|
// Apply pagination if provided
|
||||||
|
if ($request->has('page') && $request->has('size')) {
|
||||||
|
$page = $request->get('page');
|
||||||
|
$size = $request->get('size');
|
||||||
|
$offset = ($page - 1) * $size; // Calculate the offset
|
||||||
|
|
||||||
|
$query->skip($offset)->take($size);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get the filtered count of records
|
||||||
|
$filteredRecords = $query->count();
|
||||||
|
|
||||||
|
// Get the data for the current page
|
||||||
|
$data = $query->get();
|
||||||
|
|
||||||
|
// Calculate the page count
|
||||||
|
$pageCount = ceil($totalRecords / $request->get('size'));
|
||||||
|
|
||||||
|
// Calculate the current page number
|
||||||
|
$currentPage = 0 + 1;
|
||||||
|
|
||||||
|
// Return the response data as a JSON object
|
||||||
|
return response()->json([
|
||||||
|
'draw' => $request->get('draw'),
|
||||||
|
'recordsTotal' => $totalRecords,
|
||||||
|
'recordsFiltered' => $filteredRecords,
|
||||||
|
'pageCount' => $pageCount,
|
||||||
|
'page' => $currentPage,
|
||||||
|
'totalCount' => $totalRecords,
|
||||||
|
'data' => $data,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function export()
|
||||||
|
{
|
||||||
|
return Excel::download(new CustomFieldExport, 'custom_fields.xlsx');
|
||||||
|
}
|
||||||
|
}
|
||||||
199
app/Http/Controllers/DebitureController.php
Normal file
199
app/Http/Controllers/DebitureController.php
Normal file
@@ -0,0 +1,199 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Modules\Lpj\Http\Controllers;
|
||||||
|
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use Exception;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Maatwebsite\Excel\Facades\Excel;
|
||||||
|
use Modules\Location\Models\City;
|
||||||
|
use Modules\Location\Models\District;
|
||||||
|
use Modules\Location\Models\Province;
|
||||||
|
use Modules\Location\Models\Village;
|
||||||
|
use Modules\Lpj\Exports\DebitureExport;
|
||||||
|
use Modules\Lpj\Http\Requests\DebitureRequest;
|
||||||
|
use Modules\Lpj\Http\Requests\DokumenJaminanRequest;
|
||||||
|
use Modules\Lpj\Models\Branch;
|
||||||
|
use Modules\Lpj\Models\Debiture;
|
||||||
|
use Modules\Lpj\Models\DokumenJaminan;
|
||||||
|
use Modules\Lpj\Models\JenisJaminan;
|
||||||
|
use Modules\Lpj\Models\JenisLegalitasJaminan;
|
||||||
|
use Modules\Lpj\Models\PemilikJaminan;
|
||||||
|
use Illuminate\Support\Facades\Auth;
|
||||||
|
|
||||||
|
class DebitureController extends Controller
|
||||||
|
{
|
||||||
|
public $user;
|
||||||
|
|
||||||
|
public function index()
|
||||||
|
{
|
||||||
|
return view('lpj::debitur.index');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function store(DebitureRequest $request)
|
||||||
|
{
|
||||||
|
$validate = $request->validated();
|
||||||
|
|
||||||
|
if ($validate) {
|
||||||
|
try {
|
||||||
|
// Save to database
|
||||||
|
Debiture::create($validate);
|
||||||
|
return redirect()
|
||||||
|
->route('debitur.index')
|
||||||
|
->with('success', 'Debitur created successfully');
|
||||||
|
} catch (Exception $e) {
|
||||||
|
return redirect()
|
||||||
|
->route('debitur.create')
|
||||||
|
->with('error', 'Failed to create debitur');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function create()
|
||||||
|
{
|
||||||
|
$branches = Branch::all();
|
||||||
|
$provinces = Province::all();
|
||||||
|
return view('lpj::debitur.create', compact('branches', 'provinces'));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function edit($id)
|
||||||
|
{
|
||||||
|
$debitur = Debiture::find($id);
|
||||||
|
$branches = Branch::all();
|
||||||
|
$provinces = Province::all();
|
||||||
|
$cities = City::where('province_code', $debitur->province_code)->get();
|
||||||
|
$districts = District::where('city_code', $debitur->city_code)->get();
|
||||||
|
$villages = Village::where('district_code', $debitur->district_code)->get();
|
||||||
|
return view(
|
||||||
|
'lpj::debitur.edit',
|
||||||
|
compact('debitur', 'branches', 'provinces', 'cities', 'districts', 'villages'),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function update(DebitureRequest $request, $id)
|
||||||
|
{
|
||||||
|
//print_r($request->all());exit;
|
||||||
|
$validate = $request->validated();
|
||||||
|
|
||||||
|
if ($validate) {
|
||||||
|
try {
|
||||||
|
// Update in database
|
||||||
|
$debitur = Debiture::find($id);
|
||||||
|
$debitur->update($validate);
|
||||||
|
return redirect()
|
||||||
|
->route('debitur.index')
|
||||||
|
->with('success', 'Debitur updated successfully');
|
||||||
|
} catch (Exception $e) {
|
||||||
|
return redirect()
|
||||||
|
->route('debitur.edit', $id)
|
||||||
|
->with('error', 'Failed to update debitur');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function destroy($id)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
// Periksa apakah pengguna adalah administrator
|
||||||
|
if (!auth()->user()->hasRole('administrator')) {
|
||||||
|
return response()->json(['success' => false, 'message' => 'Hanya administrator yang dapat menghapus debitur'], 403);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Temukan debitur
|
||||||
|
$debitur = Debiture::find($id);
|
||||||
|
|
||||||
|
if (!$debitur) {
|
||||||
|
return response()->json(['success' => false, 'message' => 'Debitur tidak ditemukan'], 404);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Periksa apakah debitur memiliki permohonan aktif
|
||||||
|
if ($debitur->permohonan()->exists()) {
|
||||||
|
return response()->json(['success' => false, 'message' => 'Tidak dapat menghapus debitur yang masih memiliki permohonan aktif'], 400);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Hapus dari database
|
||||||
|
$debitur->delete();
|
||||||
|
|
||||||
|
return response()->json(['success' => true, 'message' => 'Debitur berhasil dihapus']);
|
||||||
|
} catch (Exception $e) {
|
||||||
|
return response()->json(['success' => false, 'message' => 'Gagal menghapus debitur: ' . $e->getMessage()], 500);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function dataForDatatables(Request $request)
|
||||||
|
{
|
||||||
|
if (is_null($this->user) || !$this->user->can('debitur.view')) {
|
||||||
|
//abort(403, 'Sorry! You are not allowed to view users.');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Retrieve data from the database
|
||||||
|
$query = Debiture::query();
|
||||||
|
|
||||||
|
if (!Auth::user()->hasAnyRole(['administrator'])) {
|
||||||
|
$query = $query->where('branch_id', Auth::user()->branch_id);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Apply search filter if provided
|
||||||
|
if ($request->has('search') && !empty($request->get('search'))) {
|
||||||
|
$search = $request->get('search');
|
||||||
|
$query->where(function ($q) use ($search) {
|
||||||
|
$q->where('cif', 'LIKE', "%$search%");
|
||||||
|
$q->orWhere('name', 'LIKE', "%$search%");
|
||||||
|
$q->orWhereRelation('branch', 'name', 'LIKE', "%$search%");
|
||||||
|
$q->orWhere('address', 'LIKE', "%$search%");
|
||||||
|
$q->orWhere('npwp', 'LIKE', "%$search%");
|
||||||
|
$q->orWhere('nomor_id', 'LIKE', "%$search%");
|
||||||
|
$q->orWhere('email', 'LIKE', "%$search%");
|
||||||
|
$q->orWhere('phone', 'LIKE', "%$search%");
|
||||||
|
$q->orWhere('nomor_rekening', 'LIKE', "%$search%");
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// Apply sorting if provided
|
||||||
|
if ($request->has('sortOrder') && !empty($request->get('sortOrder'))) {
|
||||||
|
$order = $request->get('sortOrder');
|
||||||
|
$column = $request->get('sortField');
|
||||||
|
$query->orderBy($column, $order);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get the total count of records
|
||||||
|
$totalRecords = $query->count();
|
||||||
|
|
||||||
|
// Apply pagination if provided
|
||||||
|
if ($request->has('page') && $request->has('size')) {
|
||||||
|
$page = $request->get('page');
|
||||||
|
$size = $request->get('size');
|
||||||
|
$offset = ($page - 1) * $size; // Calculate the offset
|
||||||
|
|
||||||
|
$query->skip($offset)->take($size);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get the filtered count of records
|
||||||
|
$filteredRecords = $query->count();
|
||||||
|
|
||||||
|
// Get the data for the current page
|
||||||
|
$data = $query->with(['branch','permohonan'])->get();
|
||||||
|
|
||||||
|
// Calculate the page count
|
||||||
|
$pageCount = ceil($totalRecords / $request->get('size'));
|
||||||
|
|
||||||
|
// Calculate the current page number
|
||||||
|
$currentPage = 0 + 1;
|
||||||
|
|
||||||
|
// Return the response data as a JSON object
|
||||||
|
return response()->json([
|
||||||
|
'draw' => $request->get('draw'),
|
||||||
|
'recordsTotal' => $totalRecords,
|
||||||
|
'recordsFiltered' => $filteredRecords,
|
||||||
|
'pageCount' => $pageCount,
|
||||||
|
'page' => $currentPage,
|
||||||
|
'totalCount' => $totalRecords,
|
||||||
|
'data' => $data,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function export()
|
||||||
|
{
|
||||||
|
return Excel::download(new DebitureExport, 'debitur.xlsx');
|
||||||
|
}
|
||||||
|
}
|
||||||
665
app/Http/Controllers/DokumenJaminanController.php
Normal file
665
app/Http/Controllers/DokumenJaminanController.php
Normal file
@@ -0,0 +1,665 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Modules\Lpj\Http\Controllers;
|
||||||
|
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use Exception;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Http\JsonResponse;
|
||||||
|
use Illuminate\Support\Collection;
|
||||||
|
use Illuminate\Support\Facades\DB;
|
||||||
|
use Illuminate\Support\Facades\Storage;
|
||||||
|
use Illuminate\Http\UploadedFile;
|
||||||
|
use Log;
|
||||||
|
use Modules\Location\Models\City;
|
||||||
|
use Modules\Location\Models\District;
|
||||||
|
use Modules\Location\Models\Province;
|
||||||
|
use Modules\Location\Models\Village;
|
||||||
|
use Modules\Lpj\Http\Requests\DokumenJaminanRequest;
|
||||||
|
use Modules\Lpj\Models\CustomField;
|
||||||
|
use Modules\Lpj\Models\Debiture;
|
||||||
|
use Modules\Lpj\Models\DetailDokumenJaminan;
|
||||||
|
use Modules\Lpj\Models\DokumenJaminan;
|
||||||
|
use Modules\Lpj\Models\HubunganPemilikJaminan;
|
||||||
|
use Modules\Lpj\Models\JenisJaminan;
|
||||||
|
use Modules\Lpj\Models\JenisLegalitasJaminan;
|
||||||
|
use Modules\Lpj\Models\PemilikJaminan;
|
||||||
|
use Modules\Lpj\Models\Permohonan;
|
||||||
|
use ZipArchive;
|
||||||
|
|
||||||
|
class DokumenJaminanController extends Controller
|
||||||
|
{
|
||||||
|
public $user;
|
||||||
|
|
||||||
|
|
||||||
|
public function index($id)
|
||||||
|
{
|
||||||
|
$debitur = Debiture::find($id);
|
||||||
|
$documents = DokumenJaminan::with('pemilik', 'detail')->where('debiture_id', $id)->get();
|
||||||
|
if (request()->get('permohonan_id') !== null) {
|
||||||
|
$permohonan_id = request()->get('permohonan_id');
|
||||||
|
$documents = DokumenJaminan::with('pemilik', 'detail')
|
||||||
|
->where('debiture_id', $id)
|
||||||
|
->where('permohonan_id', $permohonan_id)
|
||||||
|
->get();
|
||||||
|
}
|
||||||
|
|
||||||
|
return view(
|
||||||
|
'lpj::debitur.edit',
|
||||||
|
compact('debitur', 'documents'),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function store(DokumenJaminanRequest $request, $id)
|
||||||
|
{
|
||||||
|
$debitur = Debiture::find($id);
|
||||||
|
|
||||||
|
$validate = $request->validated();
|
||||||
|
|
||||||
|
if ($validate) {
|
||||||
|
try {
|
||||||
|
DB::beginTransaction();
|
||||||
|
$validate['debiture_id'] = $id;
|
||||||
|
|
||||||
|
if ($validate['pemilik_jaminan_id'] == 0) {
|
||||||
|
$pemilik_jaminan = [
|
||||||
|
'hubungan_pemilik_jaminan_id' => 1,
|
||||||
|
'npwp' => $debitur->npwp,
|
||||||
|
'email' => $debitur->email,
|
||||||
|
'phone' => $debitur->phone,
|
||||||
|
'province_code' => $debitur->province_code,
|
||||||
|
'city_code' => $debitur->city_code,
|
||||||
|
'district_code' => $debitur->district_code,
|
||||||
|
'village_code' => $debitur->village_code,
|
||||||
|
'postal_code' => $debitur->postal_code,
|
||||||
|
'address' => $debitur->address,
|
||||||
|
];
|
||||||
|
|
||||||
|
$pemilikJaminan = PemilikJaminan::updateOrCreate([
|
||||||
|
'debiture_id' => $id,
|
||||||
|
'name' => $debitur->name,
|
||||||
|
], $pemilik_jaminan);
|
||||||
|
$validate['pemilik_jaminan_id'] = $pemilikJaminan->id;
|
||||||
|
}
|
||||||
|
|
||||||
|
$document = DokumenJaminan::create($validate);
|
||||||
|
|
||||||
|
if ($request->jenis_legalitas_jaminan_id) {
|
||||||
|
foreach ($request->jenis_legalitas_jaminan_id as $key => $value) {
|
||||||
|
$detailData = [
|
||||||
|
'dokumen_jaminan_id' => $document->id,
|
||||||
|
'jenis_legalitas_jaminan_id' => $value,
|
||||||
|
'name' => $request->name[$key],
|
||||||
|
'keterangan' => $request->keterangan[$key],
|
||||||
|
'details' => isset($request->custom_field[$key]) ? json_encode($request->custom_field[$key]) : ''
|
||||||
|
];
|
||||||
|
|
||||||
|
$dokumenJaminan = [];
|
||||||
|
$dokumenNomor = [];
|
||||||
|
if (isset($request->dokumen_jaminan[$key]) && is_array($request->dokumen_jaminan[$key])) {
|
||||||
|
foreach ($request->dokumen_jaminan[$key] as $index => $file) {
|
||||||
|
if ($file) {
|
||||||
|
$file_name = $file->getClientOriginalName();
|
||||||
|
$file->storeAs(
|
||||||
|
'public/jaminan/' . $debitur->id . '/' . $document->id . '/',
|
||||||
|
$file_name,
|
||||||
|
);
|
||||||
|
$dokumenJaminan[] = 'jaminan/' . $debitur->id . '/' . $document->id . '/' . $file_name;
|
||||||
|
$dokumenNomor[] = $request->dokumen_nomor[$key][$index] ?? '-';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!empty($dokumenJaminan)) {
|
||||||
|
$detailData['dokumen_jaminan'] = json_encode($dokumenJaminan);
|
||||||
|
$detailData['dokumen_nomor'] = json_encode($dokumenNomor);
|
||||||
|
}
|
||||||
|
|
||||||
|
DetailDokumenJaminan::create($detailData);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
DB::commit();
|
||||||
|
return redirect()->route('debitur.jaminan.index',['id'=>$id,'pemrohonan_id' => $validate['permohonan_id'] ])->with(
|
||||||
|
'success',
|
||||||
|
'Dokumen Jaminan berhasil ditambahkan',
|
||||||
|
);
|
||||||
|
} catch (Exception $e) {
|
||||||
|
DB::rollBack();
|
||||||
|
return redirect()->route('debitur.jaminan.create',['id'=>$id,'pemrohonan_id' => $validate['permohonan_id'] ])->with('error', $e->getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function create($id)
|
||||||
|
{
|
||||||
|
$debitur = Debiture::find($id);
|
||||||
|
$provinces = Province::all();
|
||||||
|
$jenisJaminan = JenisJaminan::all();
|
||||||
|
$jenisLegalitasJaminan = JenisLegalitasJaminan::all();
|
||||||
|
$pemilikJaminan = PemilikJaminan::where('debiture_id', $id)->get();
|
||||||
|
$hubunganPemilik = HubunganPemilikJaminan::all();
|
||||||
|
$permohonan = null;
|
||||||
|
if(request()->get('permohonan_id')) {
|
||||||
|
$permohonan = Permohonan::where('id', request()->get('permohonan_id'))->first();
|
||||||
|
}
|
||||||
|
return view(
|
||||||
|
'lpj::debitur.jaminan',
|
||||||
|
compact(
|
||||||
|
'debitur',
|
||||||
|
'provinces',
|
||||||
|
'jenisJaminan',
|
||||||
|
'jenisLegalitasJaminan',
|
||||||
|
'pemilikJaminan',
|
||||||
|
'hubunganPemilik',
|
||||||
|
'permohonan'
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function update(DokumenJaminanRequest $request, $id, $jaminan)
|
||||||
|
{
|
||||||
|
$debitur = Debiture::find($id);
|
||||||
|
|
||||||
|
$validate = $request->validated();
|
||||||
|
if ($validate) {
|
||||||
|
try {
|
||||||
|
DB::beginTransaction();
|
||||||
|
$validate['debiture_id'] = $id;
|
||||||
|
|
||||||
|
if ($validate['pemilik_jaminan_id'] == 00) {
|
||||||
|
$pemilik_jaminan = [
|
||||||
|
'hubungan_pemilik_jaminan_id' => request()->get('hubungan_pemilik_jaminan_id'),
|
||||||
|
'province_code' => $debitur->province_code,
|
||||||
|
'city_code' => $debitur->city_code,
|
||||||
|
'district_code' => $debitur->district_code,
|
||||||
|
'village_code' => $debitur->village_code,
|
||||||
|
'postal_code' => $debitur->postal_code,
|
||||||
|
'address' => $debitur->address,
|
||||||
|
'nomor_id' => request()->get('nomor_id'),
|
||||||
|
'name' => request()->get('pemilik_name'),
|
||||||
|
];
|
||||||
|
|
||||||
|
$detailSertifikat = [];
|
||||||
|
$names = request()->input('detail_sertifikat.name', []);
|
||||||
|
$nomorIds = request()->input('detail_sertifikat.nomor_id', []);
|
||||||
|
|
||||||
|
foreach ($names as $index => $name) {
|
||||||
|
if (isset($nomorIds[$index])) {
|
||||||
|
$detailSertifikat[] = [
|
||||||
|
'name' => $name,
|
||||||
|
'nomor_id' => $nomorIds[$index],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$pemilik_jaminan['detail_sertifikat'] = json_encode($detailSertifikat);
|
||||||
|
|
||||||
|
//dd($pemilik_jaminan);
|
||||||
|
|
||||||
|
try {
|
||||||
|
$pemilikJaminan = PemilikJaminan::updateOrCreate([
|
||||||
|
'debiture_id' => $id,
|
||||||
|
'name' => request()->get('pemilik_name'),
|
||||||
|
], $pemilik_jaminan);
|
||||||
|
} catch (Exception $e) {
|
||||||
|
return redirect()->route('debitur.jaminan.index', $id)->with(
|
||||||
|
'error',
|
||||||
|
'Gagal update pemilik jaminan: ' . $e->getMessage(),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
$validate['pemilik_jaminan_id'] = $pemilikJaminan->id;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if ($validate['pemilik_jaminan_id'] == 0) {
|
||||||
|
$pemilik_jaminan = [
|
||||||
|
'hubungan_pemilik_jaminan_id' => 1,
|
||||||
|
'npwp' => $debitur->npwp,
|
||||||
|
'email' => $debitur->email,
|
||||||
|
'phone' => $debitur->phone,
|
||||||
|
'province_code' => $debitur->province_code,
|
||||||
|
'city_code' => $debitur->city_code,
|
||||||
|
'district_code' => $debitur->district_code,
|
||||||
|
'village_code' => $debitur->village_code,
|
||||||
|
'postal_code' => $debitur->postal_code,
|
||||||
|
'address' => $debitur->address,
|
||||||
|
];
|
||||||
|
|
||||||
|
$pemilikJaminan = PemilikJaminan::updateOrCreate([
|
||||||
|
'debiture_id' => $id,
|
||||||
|
'name' => $debitur->name,
|
||||||
|
], $pemilik_jaminan);
|
||||||
|
|
||||||
|
$validate['pemilik_jaminan_id'] = $pemilikJaminan->id;
|
||||||
|
}
|
||||||
|
|
||||||
|
$document = DokumenJaminan::find($jaminan);
|
||||||
|
$document->update($validate);
|
||||||
|
|
||||||
|
// Get existing detail documents
|
||||||
|
$existingDetails = DetailDokumenJaminan::where('dokumen_jaminan_id', $document->id)->get()->keyBy(
|
||||||
|
'id',
|
||||||
|
);
|
||||||
|
|
||||||
|
if ($request->jenis_legalitas_jaminan_id) {
|
||||||
|
foreach ($request->jenis_legalitas_jaminan_id as $key => $value) {
|
||||||
|
$detailData = [
|
||||||
|
'dokumen_jaminan_id' => $document->id,
|
||||||
|
'jenis_legalitas_jaminan_id' => $value,
|
||||||
|
'name' => $request->name[$key],
|
||||||
|
'keterangan' => $request->keterangan[$key],
|
||||||
|
'details' => isset($request->custom_field[$key]) ? json_encode(array_values($request->custom_field[$key])) : ''
|
||||||
|
];
|
||||||
|
|
||||||
|
$dokumenJaminan = [];
|
||||||
|
$dokumenNomor = [];
|
||||||
|
|
||||||
|
if (isset($request->dokumen_jaminan[$key]) && is_array($request->dokumen_jaminan[$key])) {
|
||||||
|
foreach ($request->dokumen_jaminan[$key] as $index => $file) {
|
||||||
|
if ($file instanceof \Illuminate\Http\UploadedFile) {
|
||||||
|
// Jika file baru diupload
|
||||||
|
$file_name = $file->getClientOriginalName();
|
||||||
|
$file->storeAs(
|
||||||
|
'public/jaminan/' . $debitur->id . '/' . $document->id . '/',
|
||||||
|
$file_name,
|
||||||
|
);
|
||||||
|
$dokumenJaminan[] = 'jaminan/' . $debitur->id . '/' . $document->id . '/' . $file_name;
|
||||||
|
} elseif (is_string($file) && !empty($file)) {
|
||||||
|
// Jika file tidak diubah, gunakan path yang sudah ada
|
||||||
|
$dokumenJaminan[] = $file;
|
||||||
|
} else {
|
||||||
|
// Jika file kosong atau null, tambahkan placeholder atau skip
|
||||||
|
$dokumenJaminan[] = null; // atau skip dengan continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Selalu update dokumen_nomor, baik file diubah atau tidak
|
||||||
|
$dokumenNomor[] = $request->dokumen_nomor[$key][$index] ?? '-';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Setelah loop, periksa apakah ada dokumen yang dihapus
|
||||||
|
$existingDetail = $existingDetails->get($request->detail_dokumen_jaminan_id[$key] ?? null);
|
||||||
|
|
||||||
|
if ($existingDetail) {
|
||||||
|
$existingDokumen = json_decode($existingDetail->dokumen_jaminan, true) ?? [];
|
||||||
|
$existingNomor = json_decode($existingDetail->dokumen_nomor, true) ?? [];
|
||||||
|
|
||||||
|
$newDokumenJaminan = [];
|
||||||
|
$newDokumenNomor = [];
|
||||||
|
|
||||||
|
$allFilesDeleted = true;
|
||||||
|
|
||||||
|
foreach ($existingDokumen as $index => $existingFile) {
|
||||||
|
if (isset($request->dokumen_jaminan[$key][$index])) {
|
||||||
|
$allFilesDeleted = false;
|
||||||
|
$file = $request->dokumen_jaminan[$key][$index];
|
||||||
|
if ($file instanceof \Illuminate\Http\UploadedFile) {
|
||||||
|
// File baru diupload
|
||||||
|
$file_name = $file->getClientOriginalName();
|
||||||
|
$file->storeAs('public/jaminan/' . $debitur->id . '/' . $document->id . '/', $file_name);
|
||||||
|
$newDokumenJaminan[] = 'jaminan/' . $debitur->id . '/' . $document->id . '/' . $file_name;
|
||||||
|
$newDokumenNomor[] = $request->dokumen_nomor[$key][$index] ?? '-';
|
||||||
|
} elseif (is_string($file) && !empty($file)) {
|
||||||
|
// File tidak diubah
|
||||||
|
$newDokumenJaminan[] = $existingFile;
|
||||||
|
$newDokumenNomor[] = $request->dokumen_nomor[$key][$index] ?? $existingNomor[$index];
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// File dihapus, hapus dari storage jika ada
|
||||||
|
if (Storage::exists('public/' . $existingFile)) {
|
||||||
|
Storage::delete('public/' . $existingFile);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Tambahkan file baru yang mungkin ditambahkan
|
||||||
|
foreach ($request->dokumen_jaminan[$key] ?? [] as $index => $file) {
|
||||||
|
if ($file instanceof UploadedFile) {
|
||||||
|
$allFilesDeleted = false;
|
||||||
|
$file_name = $file->getClientOriginalName();
|
||||||
|
$path = 'jaminan/' . $debitur->id . '/' . $document->id . '/' . $file_name;
|
||||||
|
if (!in_array($path, $newDokumenJaminan)) {
|
||||||
|
$file->storeAs('public/' . dirname($path), $file_name);
|
||||||
|
$newDokumenJaminan[] = $path;
|
||||||
|
$newDokumenNomor[] = $request->dokumen_nomor[$key][$index] ?? '-';
|
||||||
|
}
|
||||||
|
} elseif (is_string($file) && !empty($file) && !in_array($file, $newDokumenJaminan)) {
|
||||||
|
$allFilesDeleted = false;
|
||||||
|
$newDokumenJaminan[] = $file;
|
||||||
|
$newDokumenNomor[] = $request->dokumen_nomor[$key][$index] ?? '-';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($allFilesDeleted) {
|
||||||
|
$dokumenJaminan = [];
|
||||||
|
$dokumenNomor = [];
|
||||||
|
} else {
|
||||||
|
$dokumenJaminan = $newDokumenJaminan;
|
||||||
|
$dokumenNomor = $newDokumenNomor;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if (!empty($dokumenJaminan)) {
|
||||||
|
$detailData['dokumen_jaminan'] = json_encode($dokumenJaminan);
|
||||||
|
$detailData['dokumen_nomor'] = json_encode($dokumenNomor);
|
||||||
|
} else if(empty($dokumenJaminan)){
|
||||||
|
$detailData['dokumen_jaminan'] = null;
|
||||||
|
$detailData['dokumen_nomor'] = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($request->detail_dokumen_jaminan_id[$key])) {
|
||||||
|
$detailId = $request->detail_dokumen_jaminan_id[$key];
|
||||||
|
$detailDocument = $existingDetails->get($detailId);
|
||||||
|
$detailDocument->update($detailData);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
DetailDokumenJaminan::create($detailData);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
DB::commit();
|
||||||
|
return redirect()->route('debitur.jaminan.index', $id)->with(
|
||||||
|
'success',
|
||||||
|
'Dokumen Jaminan berhasil diubah',
|
||||||
|
);
|
||||||
|
} catch (Exception $e) {
|
||||||
|
DB::rollBack();
|
||||||
|
return redirect()->route('debitur.jaminan.index', $id)->with('error', $e->getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function edit(
|
||||||
|
$id,
|
||||||
|
$jaminan,
|
||||||
|
)
|
||||||
|
{
|
||||||
|
$document = DokumenJaminan::find($jaminan);
|
||||||
|
$details = DetailDokumenJaminan::where('dokumen_jaminan_id', $document->id)->get();
|
||||||
|
|
||||||
|
$debitur = Debiture::find($document->debiture_id);
|
||||||
|
$provinces = Province::all();
|
||||||
|
$cities = City::where('province_code', $document->province_code)->get();
|
||||||
|
$districts = District::where('city_code', $document->city_code)->get();
|
||||||
|
$villages = Village::where('district_code', $document->district_code)->get();
|
||||||
|
|
||||||
|
|
||||||
|
$jenisJaminan = JenisJaminan::all();
|
||||||
|
$jenisLegalitasJaminan = JenisLegalitasJaminan::all();
|
||||||
|
|
||||||
|
$_jenisJaminan = JenisJaminan::find($document->jenis_jaminan_id);
|
||||||
|
|
||||||
|
$legalitas = '';
|
||||||
|
if ($_jenisJaminan) {
|
||||||
|
$legalitasJaminan = json_decode($_jenisJaminan->jenis_legalitas_jaminan_id, true);
|
||||||
|
|
||||||
|
$currentLegalitasJaminan = JenisLegalitasJaminan::whereIn(
|
||||||
|
'id',
|
||||||
|
$document->detail->pluck('jenis_legalitas_jaminan_id')->toArray(),
|
||||||
|
)->get();
|
||||||
|
|
||||||
|
|
||||||
|
// Remove values from $legalitasJaminan that are in $currentLegalitasJaminan
|
||||||
|
$legalitasJaminan = array_diff($legalitasJaminan, $currentLegalitasJaminan->pluck('code')->toArray());
|
||||||
|
|
||||||
|
$legalitas = JenisLegalitasJaminan::whereIn('code', $legalitasJaminan)->get();
|
||||||
|
}
|
||||||
|
|
||||||
|
$pemilikJaminan = PemilikJaminan::where('debiture_id', $document->debiture_id)->get();
|
||||||
|
$hubunganPemilik = HubunganPemilikJaminan::all();
|
||||||
|
|
||||||
|
return view(
|
||||||
|
'lpj::debitur.jaminan',
|
||||||
|
compact(
|
||||||
|
'debitur',
|
||||||
|
'provinces',
|
||||||
|
'jenisJaminan',
|
||||||
|
'jenisLegalitasJaminan',
|
||||||
|
'document',
|
||||||
|
'details',
|
||||||
|
'cities',
|
||||||
|
'districts',
|
||||||
|
'villages',
|
||||||
|
'pemilikJaminan',
|
||||||
|
'hubunganPemilik',
|
||||||
|
'legalitas',
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function destroy(
|
||||||
|
$id,
|
||||||
|
$jaminan_id,
|
||||||
|
)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
// Periksa apakah pengguna adalah admin
|
||||||
|
if (!auth()->user()->hasRole('administrator')) {
|
||||||
|
return response()->json(['success' => false, 'message' => 'Hanya administrator yang dapat menghapus dokumen jaminan'], 403);
|
||||||
|
}
|
||||||
|
|
||||||
|
$jaminan = DokumenJaminan::find($jaminan_id);
|
||||||
|
|
||||||
|
if (!$jaminan) {
|
||||||
|
return response()->json(['success' => false, 'message' => 'Dokumen Jaminan tidak ditemukan'], 404);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Periksa apakah dokumen jaminan terkait dengan permohonan aktif
|
||||||
|
if ($jaminan->permohonan()->exists()) {
|
||||||
|
return response()->json(['success' => false, 'message' => 'Tidak dapat menghapus dokumen jaminan yang terkait dengan permohonan aktif'], 400);
|
||||||
|
}
|
||||||
|
|
||||||
|
DB::beginTransaction();
|
||||||
|
|
||||||
|
$details = DetailDokumenJaminan::where('dokumen_jaminan_id', $jaminan->id)->get();
|
||||||
|
foreach ($details as $detail) {
|
||||||
|
Storage::delete('public/' . $detail->dokumen_jaminan);
|
||||||
|
$detail->delete();
|
||||||
|
}
|
||||||
|
$jaminan->delete();
|
||||||
|
|
||||||
|
DB::commit();
|
||||||
|
|
||||||
|
return response()->json(['success' => true, 'message' => 'Dokumen Jaminan berhasil dihapus']);
|
||||||
|
} catch (Exception $e) {
|
||||||
|
DB::rollBack();
|
||||||
|
return response()->json(['success' => false, 'message' => 'Gagal menghapus Dokumen Jaminan: ' . $e->getMessage()], 500);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function bulkDownload()
|
||||||
|
{
|
||||||
|
$dokumenIds = request()->get('jaminan'); // Expecting an array of dokumen_jaminan_id
|
||||||
|
$documents = DokumenJaminan::where('id', $dokumenIds)->with(['jenisJaminan', 'detail', 'debiture'])->get();
|
||||||
|
|
||||||
|
if ($documents->isEmpty()) {
|
||||||
|
return redirect()->back()->with('error', 'No documents found for the provided IDs.');
|
||||||
|
}
|
||||||
|
|
||||||
|
$zip = new ZipArchive;
|
||||||
|
$zipFileName = 'documents_jaminan_' . $dokumenIds . '.zip';
|
||||||
|
$zipFilePath = storage_path('app/public/' . $zipFileName);
|
||||||
|
|
||||||
|
if ($zip->open($zipFilePath, ZipArchive::CREATE) === true) {
|
||||||
|
foreach ($documents as $document) {
|
||||||
|
$jenisJaminan = $document->permohonan->nomor_registrasi ?? 'Uncategorized';
|
||||||
|
$folderName = $this->sanitizeFolderName($jenisJaminan);
|
||||||
|
|
||||||
|
foreach ($document->detail as $detail) {
|
||||||
|
if ($detail->dokumen_jaminan) {
|
||||||
|
$folderJaminanName = $this->sanitizeFolderName($detail->jenisLegalitasJaminan->name ?? 'Uncategorized');
|
||||||
|
$files = is_array(json_decode($detail->dokumen_jaminan))
|
||||||
|
? json_decode($detail->dokumen_jaminan)
|
||||||
|
: [$detail->dokumen_jaminan];
|
||||||
|
|
||||||
|
foreach ($files as $file) {
|
||||||
|
$filePath = storage_path('app/public/' . $file);
|
||||||
|
if (file_exists($filePath)) {
|
||||||
|
$zip->addFile($filePath, $folderName . '/' . $folderJaminanName . '/' . basename($filePath));
|
||||||
|
} else {
|
||||||
|
// Log or display an error message for missing files
|
||||||
|
Log::warning('File not found: ' . $filePath);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$zip->close();
|
||||||
|
|
||||||
|
if (!file_exists($zipFilePath)) {
|
||||||
|
return redirect()->back()->with('error', 'Failed to create ZIP file.');
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return redirect()->back()->with('error', 'Failed to create ZIP file.');
|
||||||
|
}
|
||||||
|
|
||||||
|
return response()->download($zipFilePath, $zipFileName, [
|
||||||
|
'Content-Type' => 'application/zip',
|
||||||
|
'Content-Disposition' => 'attachment; filename="' . $zipFileName . '"',
|
||||||
|
'Content-Length' => filesize($zipFilePath),
|
||||||
|
])->deleteFileAfterSend(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
private function sanitizeFolderName($name)
|
||||||
|
{
|
||||||
|
// Remove any characters that are not allowed in folder names
|
||||||
|
return preg_replace('/[^a-zA-Z0-9_\-]/', '_', $name);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public function download()
|
||||||
|
{
|
||||||
|
$dokumen = request()->get('dokumen');
|
||||||
|
$document = DetailDokumenJaminan::find($dokumen);
|
||||||
|
$file = is_array(json_decode($document->dokumen_jaminan)) ? json_decode(
|
||||||
|
$document->dokumen_jaminan,
|
||||||
|
) : [$document->dokumen_jaminan];
|
||||||
|
return response()->download(storage_path('app/public/' . $file[request()->get('index')]));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function legalitasJaminan($id)
|
||||||
|
{
|
||||||
|
$jenisJaminan = JenisJaminan::find($id);
|
||||||
|
$legalitasJaminan = $jenisJaminan->jenis_legalitas_jaminan_id;
|
||||||
|
|
||||||
|
$legalitas = JenisLegalitasJaminan::whereIn('code', json_decode($legalitasJaminan, true))->get();
|
||||||
|
echo json_encode($legalitas);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public function getLegalitasJaminan($id = 10, $jenisJaminanId = 1)
|
||||||
|
: JsonResponse
|
||||||
|
{
|
||||||
|
$jenisJaminan = JenisJaminan::findOrFail($jenisJaminanId);
|
||||||
|
$legalitasJaminan = $jenisJaminan->jenis_legalitas_jaminan_id;
|
||||||
|
$newLegalitasJaminan = JenisLegalitasJaminan::whereIn('code', json_decode($legalitasJaminan, true))->get();
|
||||||
|
|
||||||
|
$existingLegalitas = [];
|
||||||
|
$newLegalitas = [];
|
||||||
|
|
||||||
|
// Create a set of new jenis_legalitas_jaminan_ids for quick lookup
|
||||||
|
$newLegalitasIds = $newLegalitasJaminan->pluck('id')->toArray();
|
||||||
|
|
||||||
|
if ($id > 0) {
|
||||||
|
$document = DokumenJaminan::findOrFail($id);
|
||||||
|
if ($document && $document->detail) {
|
||||||
|
foreach ($document->detail as $detail) {
|
||||||
|
// Only include existing legalitas if its id is in the new set
|
||||||
|
if (in_array($detail->jenis_legalitas_jaminan_id, $newLegalitasIds)) {
|
||||||
|
$customFields = [];
|
||||||
|
if($detail->jenisLegalitasJaminan->custom_fields) {
|
||||||
|
$customFields = CustomField::whereIn('id', $detail->jenisLegalitasJaminan->custom_fields)
|
||||||
|
->get();
|
||||||
|
}
|
||||||
|
|
||||||
|
$existingLegalitas[] = [
|
||||||
|
'id' => $detail->id,
|
||||||
|
'jenis_legalitas_jaminan_id' => $detail->jenis_legalitas_jaminan_id,
|
||||||
|
'name' => $detail->jenisLegalitasJaminan->name,
|
||||||
|
'dokumen_jaminan' => json_decode(
|
||||||
|
$detail->dokumen_jaminan,
|
||||||
|
) ?? $detail->dokumen_jaminan,
|
||||||
|
'dokumen_nomor' => json_decode(
|
||||||
|
$detail->dokumen_nomor,
|
||||||
|
) ?? $detail->dokumen_nomor,
|
||||||
|
'custom_field' => $detail->jenisLegalitasJaminan->custom_field,
|
||||||
|
'custom_fields' => $customFields,
|
||||||
|
'custom_field_type' => $detail->jenisLegalitasJaminan->custom_field_type,
|
||||||
|
'details' => $detail->details,
|
||||||
|
'keterangan' => $detail->keterangan,
|
||||||
|
'is_existing' => true,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach ($newLegalitasJaminan as $legalitas) {
|
||||||
|
if (!Collection::make($existingLegalitas)->contains('jenis_legalitas_jaminan_id', $legalitas->id)) {
|
||||||
|
$customFields = [];
|
||||||
|
if($legalitas->custom_fields) {
|
||||||
|
$customFields = CustomField::whereIn('id', $legalitas->custom_fields)->get();
|
||||||
|
}
|
||||||
|
|
||||||
|
$newLegalitas[] = [
|
||||||
|
'id' => null,
|
||||||
|
'jenis_legalitas_jaminan_id' => $legalitas->id,
|
||||||
|
'name' => $legalitas->name,
|
||||||
|
'dokumen_jaminan' => null,
|
||||||
|
'dokumen_nomor' => null,
|
||||||
|
'custom_field' => $legalitas->custom_field,
|
||||||
|
'custom_field_type' => $legalitas->custom_field_type,
|
||||||
|
'custom_fields' => $customFields,
|
||||||
|
'details' => null,
|
||||||
|
'keterangan' => null,
|
||||||
|
'is_existing' => false,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$combinedLegalitas = array_merge($existingLegalitas, $newLegalitas);
|
||||||
|
return response()->json($combinedLegalitas);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function clearDetail(Request $request)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
DB::beginTransaction();
|
||||||
|
|
||||||
|
$detailId = $request->input('detail_id');
|
||||||
|
$detail = DetailDokumenJaminan::findOrFail($detailId);
|
||||||
|
|
||||||
|
// Delete associated files
|
||||||
|
if ($detail->dokumen_jaminan) {
|
||||||
|
$dokumen_jaminan = is_array(json_decode($detail->dokumen_jaminan))
|
||||||
|
? json_decode($detail->dokumen_jaminan)
|
||||||
|
: [$detail->dokumen_jaminan];
|
||||||
|
|
||||||
|
foreach ($dokumen_jaminan as $dokumen) {
|
||||||
|
if (Storage::exists($dokumen)) {
|
||||||
|
Storage::delete($dokumen);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Delete the detail record
|
||||||
|
$detail->delete();
|
||||||
|
|
||||||
|
DB::commit();
|
||||||
|
|
||||||
|
return response()->json(['success' => true, 'message' => 'Detail berhasil dihapus']);
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
DB::rollBack();
|
||||||
|
return response()->json([
|
||||||
|
'success' => false,
|
||||||
|
'message' => 'Gagal menghapus detail: ' . $e->getMessage()
|
||||||
|
], 500);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
149
app/Http/Controllers/HubunganPemilikJaminanController.php
Normal file
149
app/Http/Controllers/HubunganPemilikJaminanController.php
Normal file
@@ -0,0 +1,149 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Modules\Lpj\Http\Controllers;
|
||||||
|
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use Exception;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Maatwebsite\Excel\Facades\Excel;
|
||||||
|
use Modules\Lpj\Exports\HubunganPemilikJaminanExport;
|
||||||
|
use Modules\Lpj\Http\Requests\HubunganPemilikJaminanRequest;
|
||||||
|
use Modules\Lpj\Models\HubunganPemilikJaminan;
|
||||||
|
|
||||||
|
class HubunganPemilikJaminanController extends Controller
|
||||||
|
{
|
||||||
|
public $user;
|
||||||
|
|
||||||
|
public function index()
|
||||||
|
{
|
||||||
|
return view('lpj::hubungan_pemilik_jaminan.index');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function store(HubunganPemilikJaminanRequest $request)
|
||||||
|
{
|
||||||
|
$validate = $request->validated();
|
||||||
|
|
||||||
|
if ($validate) {
|
||||||
|
try {
|
||||||
|
// Save to database
|
||||||
|
HubunganPemilikJaminan::create($validate);
|
||||||
|
return redirect()
|
||||||
|
->route('basicdata.hubungan-pemilik-jaminan.index')
|
||||||
|
->with('success', 'Hubungan Pemilik Jaminan created successfully');
|
||||||
|
} catch (Exception $e) {
|
||||||
|
return redirect()
|
||||||
|
->route('basicdata.hubungan-pemilik-jaminan.create')
|
||||||
|
->with('error', 'Failed to create hubungan pemilik jaminan');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function create()
|
||||||
|
{
|
||||||
|
return view('lpj::hubungan_pemilik_jaminan.create');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function edit($id)
|
||||||
|
{
|
||||||
|
$hubunganPemilikJaminan = HubunganPemilikJaminan::find($id);
|
||||||
|
return view('lpj::hubungan_pemilik_jaminan.create', compact('hubunganPemilikJaminan'));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function update(HubunganPemilikJaminanRequest $request, $id)
|
||||||
|
{
|
||||||
|
$validate = $request->validated();
|
||||||
|
|
||||||
|
if ($validate) {
|
||||||
|
try {
|
||||||
|
// Update in database
|
||||||
|
$hubunganPemilikJaminan = HubunganPemilikJaminan::find($id);
|
||||||
|
$hubunganPemilikJaminan->update($validate);
|
||||||
|
return redirect()
|
||||||
|
->route('basicdata.hubungan-pemilik-jaminan.index')
|
||||||
|
->with('success', 'Hubungan Pemilik Jaminan updated successfully');
|
||||||
|
} catch (Exception $e) {
|
||||||
|
return redirect()
|
||||||
|
->route('basicdata.hubungan-pemilik-jaminan.edit', $id)
|
||||||
|
->with('error', 'Failed to update hubungan pemilik jaminan');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function destroy($id)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
// Delete from database
|
||||||
|
$hubunganPemilikJaminan = HubunganPemilikJaminan::find($id);
|
||||||
|
$hubunganPemilikJaminan->delete();
|
||||||
|
|
||||||
|
echo json_encode(['success' => true, 'message' => 'Hubungan Pemilik Jaminan deleted successfully']);
|
||||||
|
} catch (Exception $e) {
|
||||||
|
echo json_encode(['success' => false, 'message' => 'Failed to delete hubungan pemilik jaminan']);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function dataForDatatables(Request $request)
|
||||||
|
{
|
||||||
|
if (is_null($this->user) || !$this->user->can('hubungan_pemilik_jaminan.view')) {
|
||||||
|
//abort(403, 'Sorry! You are not allowed to view users.');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Retrieve data from the database
|
||||||
|
$query = HubunganPemilikJaminan::query();
|
||||||
|
|
||||||
|
// Apply search filter if provided
|
||||||
|
if ($request->has('search') && !empty($request->get('search'))) {
|
||||||
|
$search = $request->get('search');
|
||||||
|
$query->where(function ($q) use ($search) {
|
||||||
|
$q->Where('name', 'LIKE', "%$search%");
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// Apply sorting if provided
|
||||||
|
if ($request->has('sortOrder') && !empty($request->get('sortOrder'))) {
|
||||||
|
$order = $request->get('sortOrder');
|
||||||
|
$column = $request->get('sortField');
|
||||||
|
$query->orderBy($column, $order);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get the total count of records
|
||||||
|
$totalRecords = $query->count();
|
||||||
|
|
||||||
|
// Apply pagination if provided
|
||||||
|
if ($request->has('page') && $request->has('size')) {
|
||||||
|
$page = $request->get('page');
|
||||||
|
$size = $request->get('size');
|
||||||
|
$offset = ($page - 1) * $size; // Calculate the offset
|
||||||
|
|
||||||
|
$query->skip($offset)->take($size);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get the filtered count of records
|
||||||
|
$filteredRecords = $query->count();
|
||||||
|
|
||||||
|
// Get the data for the current page
|
||||||
|
$data = $query->get();
|
||||||
|
|
||||||
|
// Calculate the page count
|
||||||
|
$pageCount = ceil($totalRecords / $request->get('size'));
|
||||||
|
|
||||||
|
// Calculate the current page number
|
||||||
|
$currentPage = 0 + 1;
|
||||||
|
|
||||||
|
// Return the response data as a JSON object
|
||||||
|
return response()->json([
|
||||||
|
'draw' => $request->get('draw'),
|
||||||
|
'recordsTotal' => $totalRecords,
|
||||||
|
'recordsFiltered' => $filteredRecords,
|
||||||
|
'pageCount' => $pageCount,
|
||||||
|
'page' => $currentPage,
|
||||||
|
'totalCount' => $totalRecords,
|
||||||
|
'data' => $data,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function export()
|
||||||
|
{
|
||||||
|
return Excel::download(new HubunganPemilikJaminanExport, 'hubungan_pemilik_jaminan.xlsx');
|
||||||
|
}
|
||||||
|
}
|
||||||
149
app/Http/Controllers/HubunganPenghuniJaminanController.php
Normal file
149
app/Http/Controllers/HubunganPenghuniJaminanController.php
Normal file
@@ -0,0 +1,149 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Modules\Lpj\Http\Controllers;
|
||||||
|
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use Exception;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Maatwebsite\Excel\Facades\Excel;
|
||||||
|
use Modules\Lpj\Exports\HubunganPenghuniJaminanExport;
|
||||||
|
use Modules\Lpj\Http\Requests\HubunganPenghuniJaminanRequest;
|
||||||
|
use Modules\Lpj\Models\HubunganPenghuniJaminan;
|
||||||
|
|
||||||
|
class HubunganPenghuniJaminanController extends Controller
|
||||||
|
{
|
||||||
|
public $user;
|
||||||
|
|
||||||
|
public function index()
|
||||||
|
{
|
||||||
|
return view('lpj::hubungan_penghuni_jaminan.index');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function store(HubunganPenghuniJaminanRequest $request)
|
||||||
|
{
|
||||||
|
$validate = $request->validated();
|
||||||
|
|
||||||
|
if ($validate) {
|
||||||
|
try {
|
||||||
|
// Save to database
|
||||||
|
HubunganPenghuniJaminan::create($validate);
|
||||||
|
return redirect()
|
||||||
|
->route('basicdata.hubungan-penghuni-jaminan.index')
|
||||||
|
->with('success', 'Hubungan Penghuni Jaminan created successfully');
|
||||||
|
} catch (Exception $e) {
|
||||||
|
return redirect()
|
||||||
|
->route('basicdata.hubungan-penghuni-jaminan.create')
|
||||||
|
->with('error', 'Failed to create hubungan penghuni jaminan');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function create()
|
||||||
|
{
|
||||||
|
return view('lpj::hubungan_penghuni_jaminan.create');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function edit($id)
|
||||||
|
{
|
||||||
|
$hubunganPenghuniJaminan = HubunganPenghuniJaminan::find($id);
|
||||||
|
return view('lpj::hubungan_penghuni_jaminan.create', compact('hubunganPenghuniJaminan'));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function update(HubunganPenghuniJaminanRequest $request, $id)
|
||||||
|
{
|
||||||
|
$validate = $request->validated();
|
||||||
|
|
||||||
|
if ($validate) {
|
||||||
|
try {
|
||||||
|
// Update in database
|
||||||
|
$hubunganPenghuniJaminan = HubunganPenghuniJaminan::find($id);
|
||||||
|
$hubunganPenghuniJaminan->update($validate);
|
||||||
|
return redirect()
|
||||||
|
->route('basicdata.hubungan-penghuni-jaminan.index')
|
||||||
|
->with('success', 'Hubungan Penghuni Jaminan updated successfully');
|
||||||
|
} catch (Exception $e) {
|
||||||
|
return redirect()
|
||||||
|
->route('basicdata.hubungan-penghuni-jaminan.edit', $id)
|
||||||
|
->with('error', 'Failed to update hubungan penghuni jaminan');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function destroy($id)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
// Delete from database
|
||||||
|
$hubunganPenghuniJaminan = HubunganPenghuniJaminan::find($id);
|
||||||
|
$hubunganPenghuniJaminan->delete();
|
||||||
|
|
||||||
|
echo json_encode(['success' => true, 'message' => 'Hubungan Penghuni Jaminan deleted successfully']);
|
||||||
|
} catch (Exception $e) {
|
||||||
|
echo json_encode(['success' => false, 'message' => 'Failed to delete hubungan penghuni jaminan']);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function dataForDatatables(Request $request)
|
||||||
|
{
|
||||||
|
if (is_null($this->user) || !$this->user->can('hubungan_penghuni_jaminan.view')) {
|
||||||
|
//abort(403, 'Sorry! You are not allowed to view users.');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Retrieve data from the database
|
||||||
|
$query = HubunganPenghuniJaminan::query();
|
||||||
|
|
||||||
|
// Apply search filter if provided
|
||||||
|
if ($request->has('search') && !empty($request->get('search'))) {
|
||||||
|
$search = $request->get('search');
|
||||||
|
$query->where(function ($q) use ($search) {
|
||||||
|
$q->where('name', 'LIKE', "%$search%");
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// Apply sorting if provided
|
||||||
|
if ($request->has('sortOrder') && !empty($request->get('sortOrder'))) {
|
||||||
|
$order = $request->get('sortOrder');
|
||||||
|
$column = $request->get('sortField');
|
||||||
|
$query->orderBy($column, $order);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get the total count of records
|
||||||
|
$totalRecords = $query->count();
|
||||||
|
|
||||||
|
// Apply pagination if provided
|
||||||
|
if ($request->has('page') && $request->has('size')) {
|
||||||
|
$page = $request->get('page');
|
||||||
|
$size = $request->get('size');
|
||||||
|
$offset = ($page - 1) * $size; // Calculate the offset
|
||||||
|
|
||||||
|
$query->skip($offset)->take($size);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get the filtered count of records
|
||||||
|
$filteredRecords = $query->count();
|
||||||
|
|
||||||
|
// Get the data for the current page
|
||||||
|
$data = $query->get();
|
||||||
|
|
||||||
|
// Calculate the page count
|
||||||
|
$pageCount = ceil($totalRecords / $request->get('size'));
|
||||||
|
|
||||||
|
// Calculate the current page number
|
||||||
|
$currentPage = 0 + 1;
|
||||||
|
|
||||||
|
// Return the response data as a JSON object
|
||||||
|
return response()->json([
|
||||||
|
'draw' => $request->get('draw'),
|
||||||
|
'recordsTotal' => $totalRecords,
|
||||||
|
'recordsFiltered' => $filteredRecords,
|
||||||
|
'pageCount' => $pageCount,
|
||||||
|
'page' => $currentPage,
|
||||||
|
'totalCount' => $totalRecords,
|
||||||
|
'data' => $data,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function export()
|
||||||
|
{
|
||||||
|
return Excel::download(new HubunganPenghuniJaminanExport, 'hubungan_penghuni_jaminan.xlsx');
|
||||||
|
}
|
||||||
|
}
|
||||||
174
app/Http/Controllers/IjinUsahaController.php
Normal file
174
app/Http/Controllers/IjinUsahaController.php
Normal file
@@ -0,0 +1,174 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Modules\Lpj\Http\Controllers;
|
||||||
|
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use Exception;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Http\Response;
|
||||||
|
use Maatwebsite\Excel\Facades\Excel;
|
||||||
|
use Modules\Lpj\Exports\IjinUsahaExport;
|
||||||
|
use Modules\Lpj\Http\Requests\IjinUsahaRequest;
|
||||||
|
use Modules\Lpj\Models\IjinUsaha;
|
||||||
|
|
||||||
|
class IjinUsahaController extends Controller
|
||||||
|
{
|
||||||
|
public $user;
|
||||||
|
/**
|
||||||
|
* Display a listing of the resource.
|
||||||
|
*/
|
||||||
|
public function index()
|
||||||
|
{
|
||||||
|
return view('lpj::Ijin_usaha.index');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show the form for creating a new resource.
|
||||||
|
*/
|
||||||
|
public function create()
|
||||||
|
{
|
||||||
|
return view('lpj::Ijin_usaha.create');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Store a newly created resource in storage.
|
||||||
|
*/
|
||||||
|
public function store(IjinUsahaRequest $request)
|
||||||
|
{
|
||||||
|
$validate = $request->validated();
|
||||||
|
|
||||||
|
if ($validate) {
|
||||||
|
try {
|
||||||
|
IjinUsaha::create($validate);
|
||||||
|
return redirect()
|
||||||
|
->route('basicdata.ijin_usaha.index')
|
||||||
|
->with('success', 'Ijin Usaha created successfully');
|
||||||
|
} catch (Exception $e) {
|
||||||
|
return redirect()
|
||||||
|
->route('basicdata.ijin_usaha.create')
|
||||||
|
->with('error', 'Failed to create ijin Usaha');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show the specified resource.
|
||||||
|
*/
|
||||||
|
public function show($id)
|
||||||
|
{
|
||||||
|
// return view('lpj::show');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show the form for editing the specified resource.
|
||||||
|
*/
|
||||||
|
public function edit($id)
|
||||||
|
{
|
||||||
|
$ijin_usaha = IjinUsaha::find($id);
|
||||||
|
return view('lpj::Ijin_usaha.create', compact('ijin_usaha'));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update the specified resource in storage.
|
||||||
|
*/
|
||||||
|
public function update(IjinUsahaRequest $request, $id)
|
||||||
|
{
|
||||||
|
$validate = $request->validated();
|
||||||
|
|
||||||
|
if ($validate) {
|
||||||
|
try {
|
||||||
|
// Update in database
|
||||||
|
$ijin_usaha = IjinUsaha::find($id);
|
||||||
|
$ijin_usaha->update($validate);
|
||||||
|
return redirect()
|
||||||
|
->route('basicdata.ijin_usaha.index')
|
||||||
|
->with('success', 'Ijin Usaha updated successfully');
|
||||||
|
} catch (Exception $e) {
|
||||||
|
return redirect()
|
||||||
|
->route('basicdata.ijin_usaha.edit', $id)
|
||||||
|
->with('error', 'Failed to update ijin$ijin_usaha');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove the specified resource from storage.
|
||||||
|
*/
|
||||||
|
public function destroy($id)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
$ijin_usaha = IjinUsaha::find($id);
|
||||||
|
$ijin_usaha->delete();
|
||||||
|
|
||||||
|
echo json_encode(['success' => true, 'message' => 'Ijin Usaha deleted successfully']);
|
||||||
|
} catch (Exception $e) {
|
||||||
|
echo json_encode(['success' => false, 'message' => 'Failed to delete Ijin Usaha']);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function dataForDatatables(Request $request)
|
||||||
|
{
|
||||||
|
if (is_null($this->user) || !$this->user->can('Ijin_usaha.view')) {
|
||||||
|
//abort(403, 'Sorry! You are not allowed to view users.');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Retrieve data from the database
|
||||||
|
$query = IjinUsaha::query();
|
||||||
|
|
||||||
|
// Apply search filter if provided
|
||||||
|
if ($request->has('search') && !empty($request->get('search'))) {
|
||||||
|
$search = $request->get('search');
|
||||||
|
$query->where(function ($q) use ($search) {
|
||||||
|
$q->where('code', 'LIKE', "%$search%");
|
||||||
|
$q->orWhere('name', 'LIKE', "%$search%");
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// Apply sorting if provided
|
||||||
|
if ($request->has('sortOrder') && !empty($request->get('sortOrder'))) {
|
||||||
|
$order = $request->get('sortOrder');
|
||||||
|
$column = $request->get('sortField');
|
||||||
|
$query->orderBy($column, $order);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get the total count of records
|
||||||
|
$totalRecords = $query->count();
|
||||||
|
|
||||||
|
// Apply pagination if provided
|
||||||
|
if ($request->has('page') && $request->has('size')) {
|
||||||
|
$page = $request->get('page');
|
||||||
|
$size = $request->get('size');
|
||||||
|
$offset = ($page - 1) * $size; // Calculate the offset
|
||||||
|
|
||||||
|
$query->skip($offset)->take($size);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get the filtered count of records
|
||||||
|
$filteredRecords = $query->count();
|
||||||
|
|
||||||
|
// Get the data for the current page
|
||||||
|
$data = $query->get();
|
||||||
|
|
||||||
|
// Calculate the page count
|
||||||
|
$pageCount = ceil($totalRecords / $request->get('size'));
|
||||||
|
|
||||||
|
// Calculate the current page number
|
||||||
|
$currentPage = 0 + 1;
|
||||||
|
|
||||||
|
// Return the response data as a JSON object
|
||||||
|
return response()->json([
|
||||||
|
'draw' => $request->get('draw'),
|
||||||
|
'recordsTotal' => $totalRecords,
|
||||||
|
'recordsFiltered' => $filteredRecords,
|
||||||
|
'pageCount' => $pageCount,
|
||||||
|
'page' => $currentPage,
|
||||||
|
'totalCount' => $totalRecords,
|
||||||
|
'data' => $data,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function export()
|
||||||
|
{
|
||||||
|
return Excel::download(new IjinUsahaExport, 'ijin_usaha.xlsx');
|
||||||
|
}
|
||||||
|
}
|
||||||
150
app/Http/Controllers/JenisAsetController.php
Normal file
150
app/Http/Controllers/JenisAsetController.php
Normal file
@@ -0,0 +1,150 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Modules\Lpj\Http\Controllers;
|
||||||
|
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use Exception;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Maatwebsite\Excel\Facades\Excel;
|
||||||
|
use Modules\Lpj\Exports\JenisAsetExport;
|
||||||
|
use Modules\Lpj\Http\Requests\JenisAsetRequest;
|
||||||
|
use Modules\Lpj\Models\JenisAset;
|
||||||
|
|
||||||
|
class JenisAsetController extends Controller
|
||||||
|
{
|
||||||
|
public $user;
|
||||||
|
|
||||||
|
public function index()
|
||||||
|
{
|
||||||
|
return view('lpj::jenis_aset.index');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function store(JenisAsetRequest $request)
|
||||||
|
{
|
||||||
|
$validate = $request->validated();
|
||||||
|
|
||||||
|
if ($validate) {
|
||||||
|
try {
|
||||||
|
// Save to database
|
||||||
|
JenisAset::create($validate);
|
||||||
|
return redirect()
|
||||||
|
->route('basicdata.jenis-aset.index')
|
||||||
|
->with('success', 'Jenis Aset created successfully');
|
||||||
|
} catch (Exception $e) {
|
||||||
|
return redirect()
|
||||||
|
->route('basicdata.jenis-aset.create')
|
||||||
|
->with('error', 'Failed to create jenis aset');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function create()
|
||||||
|
{
|
||||||
|
return view('lpj::jenis_aset.create');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function edit($id)
|
||||||
|
{
|
||||||
|
$jenisAset = JenisAset::find($id);
|
||||||
|
return view('lpj::jenis_aset.create', compact('jenisAset'));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function update(JenisAsetRequest $request, $id)
|
||||||
|
{
|
||||||
|
$validate = $request->validated();
|
||||||
|
|
||||||
|
if ($validate) {
|
||||||
|
try {
|
||||||
|
// Update in database
|
||||||
|
$jenisAset = JenisAset::find($id);
|
||||||
|
$jenisAset->update($validate);
|
||||||
|
return redirect()
|
||||||
|
->route('basicdata.jenis-aset.index')
|
||||||
|
->with('success', 'Jenis Aset updated successfully');
|
||||||
|
} catch (Exception $e) {
|
||||||
|
return redirect()
|
||||||
|
->route('basicdata.jenis-aset.edit', $id)
|
||||||
|
->with('error', 'Failed to update jenis aset');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function destroy($id)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
// Delete from database
|
||||||
|
$jenisAset = JenisAset::find($id);
|
||||||
|
$jenisAset->delete();
|
||||||
|
|
||||||
|
echo json_encode(['success' => true, 'message' => 'Jenis Aset deleted successfully']);
|
||||||
|
} catch (Exception $e) {
|
||||||
|
echo json_encode(['success' => false, 'message' => 'Failed to delete jenis aset']);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function dataForDatatables(Request $request)
|
||||||
|
{
|
||||||
|
if (is_null($this->user) || !$this->user->can('jenis_aset.view')) {
|
||||||
|
//abort(403, 'Sorry! You are not allowed to view users.');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Retrieve data from the database
|
||||||
|
$query = JenisAset::query();
|
||||||
|
|
||||||
|
// Apply search filter if provided
|
||||||
|
if ($request->has('search') && !empty($request->get('search'))) {
|
||||||
|
$search = $request->get('search');
|
||||||
|
$query->where(function ($q) use ($search) {
|
||||||
|
$q->where('code', 'LIKE', "%$search%");
|
||||||
|
$q->orWhere('name', 'LIKE', "%$search%");
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// Apply sorting if provided
|
||||||
|
if ($request->has('sortOrder') && !empty($request->get('sortOrder'))) {
|
||||||
|
$order = $request->get('sortOrder');
|
||||||
|
$column = $request->get('sortField');
|
||||||
|
$query->orderBy($column, $order);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get the total count of records
|
||||||
|
$totalRecords = $query->count();
|
||||||
|
|
||||||
|
// Apply pagination if provided
|
||||||
|
if ($request->has('page') && $request->has('size')) {
|
||||||
|
$page = $request->get('page');
|
||||||
|
$size = $request->get('size');
|
||||||
|
$offset = ($page - 1) * $size; // Calculate the offset
|
||||||
|
|
||||||
|
$query->skip($offset)->take($size);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get the filtered count of records
|
||||||
|
$filteredRecords = $query->count();
|
||||||
|
|
||||||
|
// Get the data for the current page
|
||||||
|
$data = $query->get();
|
||||||
|
|
||||||
|
// Calculate the page count
|
||||||
|
$pageCount = ceil($totalRecords / $request->get('size'));
|
||||||
|
|
||||||
|
// Calculate the current page number
|
||||||
|
$currentPage = 0 + 1;
|
||||||
|
|
||||||
|
// Return the response data as a JSON object
|
||||||
|
return response()->json([
|
||||||
|
'draw' => $request->get('draw'),
|
||||||
|
'recordsTotal' => $totalRecords,
|
||||||
|
'recordsFiltered' => $filteredRecords,
|
||||||
|
'pageCount' => $pageCount,
|
||||||
|
'page' => $currentPage,
|
||||||
|
'totalCount' => $totalRecords,
|
||||||
|
'data' => $data,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function export()
|
||||||
|
{
|
||||||
|
return Excel::download(new JenisAsetExport, 'jenis_aset.xlsx');
|
||||||
|
}
|
||||||
|
}
|
||||||
151
app/Http/Controllers/JenisDokumenController.php
Normal file
151
app/Http/Controllers/JenisDokumenController.php
Normal file
@@ -0,0 +1,151 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Modules\Lpj\Http\Controllers;
|
||||||
|
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use Exception;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Maatwebsite\Excel\Facades\Excel;
|
||||||
|
use Modules\Lpj\Exports\JenisDokumenExport;
|
||||||
|
use Modules\Lpj\Http\Requests\JenisDokumenRequest;
|
||||||
|
use Modules\Lpj\Models\JenisDokumen;
|
||||||
|
|
||||||
|
class JenisDokumenController extends Controller
|
||||||
|
{
|
||||||
|
public $user;
|
||||||
|
|
||||||
|
public function index()
|
||||||
|
{
|
||||||
|
return view('lpj::jenis_dokumen.index');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function store(JenisDokumenRequest $request)
|
||||||
|
{
|
||||||
|
$validate = $request->validated();
|
||||||
|
|
||||||
|
if ($validate) {
|
||||||
|
try {
|
||||||
|
// Save to database
|
||||||
|
JenisDokumen::create($validate);
|
||||||
|
return redirect()
|
||||||
|
->route('basicdata.jenis-dokumen.index')
|
||||||
|
->with('success', 'Jenis Dokumen created successfully');
|
||||||
|
} catch (Exception $e) {
|
||||||
|
return redirect()
|
||||||
|
->route('basicdata.jenis-dokumen.create')
|
||||||
|
->with('error', 'Failed to create jenis dokumen');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function create()
|
||||||
|
{
|
||||||
|
return view('lpj::jenis_dokumen.create');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function edit($id)
|
||||||
|
{
|
||||||
|
$jenisDokumen = JenisDokumen::find($id);
|
||||||
|
return view('lpj::jenis_dokumen.create', compact('jenisDokumen'));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function update(JenisDokumenRequest $request, $id)
|
||||||
|
{
|
||||||
|
$validate = $request->validated();
|
||||||
|
|
||||||
|
if ($validate) {
|
||||||
|
try {
|
||||||
|
// Update in database
|
||||||
|
$jenisDokumen = JenisDokumen::find($id);
|
||||||
|
$jenisDokumen->update($validate);
|
||||||
|
return redirect()
|
||||||
|
->route('basicdata.jenis-dokumen.index')
|
||||||
|
->with('success', 'Jenis Dokumen updated successfully');
|
||||||
|
} catch (Exception $e) {
|
||||||
|
return redirect()
|
||||||
|
->route('basicdata.jenis-dokumen.edit', $id)
|
||||||
|
->with('error', 'Failed to update jenis dokumen');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function destroy($id)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
// Delete from database
|
||||||
|
$jenisDokumen = JenisDokumen::find($id);
|
||||||
|
$jenisDokumen->delete();
|
||||||
|
|
||||||
|
echo json_encode(['success' => true, 'message' => 'Jenis Dokumen deleted successfully']);
|
||||||
|
} catch (Exception $e) {
|
||||||
|
echo json_encode(['success' => false, 'message' => 'Failed to delete jenis dokumen']);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function dataForDatatables(Request $request)
|
||||||
|
{
|
||||||
|
if (is_null($this->user) || !$this->user->can('jenis_dokumen.view')) {
|
||||||
|
//abort(403, 'Sorry! You are not allowed to view users.');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Retrieve data from the database
|
||||||
|
$query = JenisDokumen::query();
|
||||||
|
|
||||||
|
// Apply search filter if provided
|
||||||
|
if ($request->has('search') && !empty($request->get('search'))) {
|
||||||
|
$search = $request->get('search');
|
||||||
|
$query->where(function ($q) use ($search) {
|
||||||
|
$q->where('max_size', 'LIKE', "%$search%");
|
||||||
|
$q->orWhere('name', 'LIKE', "%$search%");
|
||||||
|
$q->orWhere('description', 'LIKE', "%$search%");
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// Apply sorting if provided
|
||||||
|
if ($request->has('sortOrder') && !empty($request->get('sortOrder'))) {
|
||||||
|
$order = $request->get('sortOrder');
|
||||||
|
$column = $request->get('sortField');
|
||||||
|
$query->orderBy($column, $order);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get the total count of records
|
||||||
|
$totalRecords = $query->count();
|
||||||
|
|
||||||
|
// Apply pagination if provided
|
||||||
|
if ($request->has('page') && $request->has('size')) {
|
||||||
|
$page = $request->get('page');
|
||||||
|
$size = $request->get('size');
|
||||||
|
$offset = ($page - 1) * $size; // Calculate the offset
|
||||||
|
|
||||||
|
$query->skip($offset)->take($size);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get the filtered count of records
|
||||||
|
$filteredRecords = $query->count();
|
||||||
|
|
||||||
|
// Get the data for the current page
|
||||||
|
$data = $query->get();
|
||||||
|
|
||||||
|
// Calculate the page count
|
||||||
|
$pageCount = ceil($totalRecords / $request->get('size'));
|
||||||
|
|
||||||
|
// Calculate the current page number
|
||||||
|
$currentPage = 0 + 1;
|
||||||
|
|
||||||
|
// Return the response data as a JSON object
|
||||||
|
return response()->json([
|
||||||
|
'draw' => $request->get('draw'),
|
||||||
|
'recordsTotal' => $totalRecords,
|
||||||
|
'recordsFiltered' => $filteredRecords,
|
||||||
|
'pageCount' => $pageCount,
|
||||||
|
'page' => $currentPage,
|
||||||
|
'totalCount' => $totalRecords,
|
||||||
|
'data' => $data,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function export()
|
||||||
|
{
|
||||||
|
return Excel::download(new JenisDokumenExport, 'jenis_dokumen.xlsx');
|
||||||
|
}
|
||||||
|
}
|
||||||
157
app/Http/Controllers/JenisFasilitasKreditController.php
Normal file
157
app/Http/Controllers/JenisFasilitasKreditController.php
Normal file
@@ -0,0 +1,157 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Modules\Lpj\Http\Controllers;
|
||||||
|
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use Exception;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Maatwebsite\Excel\Facades\Excel;
|
||||||
|
use Modules\Lpj\Exports\JenisFasilitasKreditExport;
|
||||||
|
use Modules\Lpj\Http\Requests\JenisFasilitasKreditRequest;
|
||||||
|
use Modules\Lpj\Models\JenisFasilitasKredit;
|
||||||
|
use Modules\Lpj\Http\Library\LpjHelpers;
|
||||||
|
|
||||||
|
class JenisFasilitasKreditController extends Controller
|
||||||
|
{
|
||||||
|
public $user;
|
||||||
|
|
||||||
|
public function index()
|
||||||
|
{
|
||||||
|
return view('lpj::jenis_fasilitas_kredit.index');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function store(JenisFasilitasKreditRequest $request)
|
||||||
|
{
|
||||||
|
$validate = $request->validated();
|
||||||
|
|
||||||
|
if ($validate) {
|
||||||
|
try {
|
||||||
|
// Save to database
|
||||||
|
|
||||||
|
JenisFasilitasKredit::create($validate);
|
||||||
|
return redirect()
|
||||||
|
->route('basicdata.jenis-fasilitas-kredit.index')
|
||||||
|
->with('success', 'Jenis Fasilitas Kredit created successfully');
|
||||||
|
} catch (Exception $e) {dd($e);
|
||||||
|
return redirect()
|
||||||
|
->route('basicdata.jenis-fasilitas-kredit.create')
|
||||||
|
->with('error', 'Failed to create jenis fasilitas kredit');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function create()
|
||||||
|
{
|
||||||
|
return view('lpj::jenis_fasilitas_kredit.create');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function edit($id)
|
||||||
|
{
|
||||||
|
$jenisFasilitasKredit = JenisFasilitasKredit::find($id);
|
||||||
|
return view('lpj::jenis_fasilitas_kredit.create', compact('jenisFasilitasKredit'));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function update(JenisFasilitasKreditRequest $request, $id)
|
||||||
|
{
|
||||||
|
$validate = $request->validated();
|
||||||
|
|
||||||
|
if ($validate) {
|
||||||
|
try {
|
||||||
|
// Update in database
|
||||||
|
$jenisFasilitasKredit = JenisFasilitasKredit::find($id);
|
||||||
|
|
||||||
|
// andy add
|
||||||
|
$validate['name'] =strtoupper($request->name);
|
||||||
|
// andy add
|
||||||
|
|
||||||
|
$jenisFasilitasKredit->update($validate);
|
||||||
|
return redirect()
|
||||||
|
->route('basicdata.jenis-fasilitas-kredit.index')
|
||||||
|
->with('success', 'Jenis Fasilitas Kredit updated successfully');
|
||||||
|
} catch (Exception $e) {dd($e);
|
||||||
|
return redirect()
|
||||||
|
->route('basicdata.jenis-fasilitas-kredit.edit', $id)
|
||||||
|
->with('error', 'Failed to update jenis fasilitas kredit');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function destroy($id)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
// Delete from database
|
||||||
|
$jenisFasilitasKredit = JenisFasilitasKredit::find($id);
|
||||||
|
$jenisFasilitasKredit->delete();
|
||||||
|
|
||||||
|
echo json_encode(['success' => true, 'message' => 'Jenis Fasilitas Kredit deleted successfully']);
|
||||||
|
} catch (Exception $e) {
|
||||||
|
echo json_encode(['success' => false, 'message' => 'Failed to delete jenis fasilitas kredit']);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function dataForDatatables(Request $request)
|
||||||
|
{
|
||||||
|
if (is_null($this->user) || !$this->user->can('jenis_fasilitas_kredit.view')) {
|
||||||
|
//abort(403, 'Sorry! You are not allowed to view users.');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Retrieve data from the database
|
||||||
|
$query = JenisFasilitasKredit::query();
|
||||||
|
|
||||||
|
// Apply search filter if provided
|
||||||
|
if ($request->has('search') && !empty($request->get('search'))) {
|
||||||
|
$search = $request->get('search');
|
||||||
|
$query->where(function ($q) use ($search) {
|
||||||
|
$q->where('code', 'LIKE', "%$search%");
|
||||||
|
$q->orWhere('name', 'LIKE', "%$search%");
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// Apply sorting if provided
|
||||||
|
if ($request->has('sortOrder') && !empty($request->get('sortOrder'))) {
|
||||||
|
$order = $request->get('sortOrder');
|
||||||
|
$column = $request->get('sortField');
|
||||||
|
$query->orderBy($column, $order);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get the total count of records
|
||||||
|
$totalRecords = $query->count();
|
||||||
|
|
||||||
|
// Apply pagination if provided
|
||||||
|
if ($request->has('page') && $request->has('size')) {
|
||||||
|
$page = $request->get('page');
|
||||||
|
$size = $request->get('size');
|
||||||
|
$offset = ($page - 1) * $size; // Calculate the offset
|
||||||
|
|
||||||
|
$query->skip($offset)->take($size);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get the filtered count of records
|
||||||
|
$filteredRecords = $query->count();
|
||||||
|
|
||||||
|
// Get the data for the current page
|
||||||
|
$data = $query->get();
|
||||||
|
|
||||||
|
// Calculate the page count
|
||||||
|
$pageCount = ceil($totalRecords / $request->get('size'));
|
||||||
|
|
||||||
|
// Calculate the current page number
|
||||||
|
$currentPage = 0 + 1;
|
||||||
|
|
||||||
|
// Return the response data as a JSON object
|
||||||
|
return response()->json([
|
||||||
|
'draw' => $request->get('draw'),
|
||||||
|
'recordsTotal' => $totalRecords,
|
||||||
|
'recordsFiltered' => $filteredRecords,
|
||||||
|
'pageCount' => $pageCount,
|
||||||
|
'page' => $currentPage,
|
||||||
|
'totalCount' => $totalRecords,
|
||||||
|
'data' => $data,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function export()
|
||||||
|
{
|
||||||
|
return Excel::download(new JenisFasilitasKreditExport, 'jenis_fasilitas_kredit.xlsx');
|
||||||
|
}
|
||||||
|
}
|
||||||
162
app/Http/Controllers/JenisJaminanController.php
Normal file
162
app/Http/Controllers/JenisJaminanController.php
Normal file
@@ -0,0 +1,162 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Modules\Lpj\Http\Controllers;
|
||||||
|
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use Exception;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Maatwebsite\Excel\Facades\Excel;
|
||||||
|
use Modules\Lpj\Exports\JenisJaminanExport;
|
||||||
|
use Modules\Lpj\Http\Requests\JenisJaminanRequest;
|
||||||
|
use Modules\Lpj\Models\JenisJaminan;
|
||||||
|
use Modules\Lpj\Models\JenisLegalitasJaminan;
|
||||||
|
|
||||||
|
class JenisJaminanController extends Controller
|
||||||
|
{
|
||||||
|
public $user;
|
||||||
|
|
||||||
|
public function index()
|
||||||
|
{
|
||||||
|
return view('lpj::jenis_jaminan.index');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function store(JenisJaminanRequest $request)
|
||||||
|
{
|
||||||
|
$validate = $request->validated();
|
||||||
|
|
||||||
|
if ($validate) {
|
||||||
|
try {
|
||||||
|
// Save to database
|
||||||
|
JenisJaminan::create($validate);
|
||||||
|
return redirect()
|
||||||
|
->route('basicdata.jenis-jaminan.index')
|
||||||
|
->with('success', 'Jenis Jaminan created successfully');
|
||||||
|
} catch (Exception $e) {
|
||||||
|
return redirect()
|
||||||
|
->route('basicdata.jenis-jaminan.create')
|
||||||
|
->with('error', 'Failed to create jenis jaminan');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function create()
|
||||||
|
{
|
||||||
|
$jenisLegalitasJaminan = JenisLegalitasJaminan::all();
|
||||||
|
return view('lpj::jenis_jaminan.create', compact('jenisLegalitasJaminan'));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function edit($id)
|
||||||
|
{
|
||||||
|
$jenisJaminan = JenisJaminan::find($id);
|
||||||
|
$jenisLegalitasJaminan = JenisLegalitasJaminan::all();
|
||||||
|
return view('lpj::jenis_jaminan.create', compact('jenisJaminan', 'jenisLegalitasJaminan'));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function update(JenisJaminanRequest $request, $id)
|
||||||
|
{
|
||||||
|
$validate = $request->validated();
|
||||||
|
|
||||||
|
if ($validate) {
|
||||||
|
try {
|
||||||
|
// Update in database
|
||||||
|
$jenisJaminan = JenisJaminan::find($id);
|
||||||
|
$jenisJaminan->update($validate);
|
||||||
|
return redirect()
|
||||||
|
->route('basicdata.jenis-jaminan.index')
|
||||||
|
->with('success', 'Jenis Jaminan updated successfully');
|
||||||
|
} catch (Exception $e) {
|
||||||
|
return redirect()
|
||||||
|
->route('basicdata.jenis-jaminan.edit', $id)
|
||||||
|
->with('error', 'Failed to update jenis jaminan');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function destroy($id)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
// Delete from database
|
||||||
|
$jenisJaminan = JenisJaminan::find($id);
|
||||||
|
$jenisJaminan->delete();
|
||||||
|
|
||||||
|
echo json_encode(['success' => true, 'message' => 'Jenis Jaminan deleted successfully']);
|
||||||
|
} catch (Exception $e) {
|
||||||
|
echo json_encode(['success' => false, 'message' => 'Failed to delete jenis jaminan']);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function dataForDatatables(Request $request)
|
||||||
|
{
|
||||||
|
if (is_null($this->user) || !$this->user->can('jenis_jaminan.view')) {
|
||||||
|
//abort(403, 'Sorry! You are not allowed to view users.');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Retrieve data from the database
|
||||||
|
$query = JenisJaminan::query();
|
||||||
|
|
||||||
|
// Apply search filter if provided
|
||||||
|
if ($request->has('search') && !empty($request->get('search'))) {
|
||||||
|
$search = $request->get('search');
|
||||||
|
$query->where(function ($q) use ($search) {
|
||||||
|
$q->where('code', 'LIKE', "%$search%");
|
||||||
|
$q->orWhere('name', 'LIKE', "%$search%");
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// Apply sorting if provided
|
||||||
|
if ($request->has('sortOrder') && !empty($request->get('sortOrder'))) {
|
||||||
|
$order = $request->get('sortOrder');
|
||||||
|
$column = $request->get('sortField');
|
||||||
|
$query->orderBy($column, $order);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get the total count of records
|
||||||
|
$totalRecords = $query->count();
|
||||||
|
|
||||||
|
// Apply pagination if provided
|
||||||
|
if ($request->has('page') && $request->has('size')) {
|
||||||
|
$page = $request->get('page');
|
||||||
|
$size = $request->get('size');
|
||||||
|
$offset = ($page - 1) * $size; // Calculate the offset
|
||||||
|
|
||||||
|
$query->skip($offset)->take($size);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get the filtered count of records
|
||||||
|
$filteredRecords = $query->count();
|
||||||
|
|
||||||
|
// Get the data for the current page
|
||||||
|
$data = $query->get();
|
||||||
|
|
||||||
|
// Calculate the page count
|
||||||
|
$pageCount = ceil($totalRecords / $request->get('size'));
|
||||||
|
|
||||||
|
// Calculate the current page number
|
||||||
|
$currentPage = 0 + 1;
|
||||||
|
|
||||||
|
// Return the response data as a JSON object
|
||||||
|
return response()->json([
|
||||||
|
'draw' => $request->get('draw'),
|
||||||
|
'recordsTotal' => $totalRecords,
|
||||||
|
'recordsFiltered' => $filteredRecords,
|
||||||
|
'pageCount' => $pageCount,
|
||||||
|
'page' => $currentPage,
|
||||||
|
'totalCount' => $totalRecords,
|
||||||
|
'data' => $data,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function export()
|
||||||
|
{
|
||||||
|
return Excel::download(new JenisJaminanExport, 'jenis_jaminan.xlsx');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function legalitasJaminan($id)
|
||||||
|
{
|
||||||
|
$jenisJaminan = JenisJaminan::find($id);
|
||||||
|
$legalitasJaminan = $jenisJaminan->jenis_legalitas_jaminan_id;
|
||||||
|
|
||||||
|
$legalitas = JenisLegalitasJaminan::whereIn('code', json_decode($legalitasJaminan, true))->get();
|
||||||
|
echo json_encode($legalitas);
|
||||||
|
}
|
||||||
|
}
|
||||||
172
app/Http/Controllers/JenisLampiranController.php
Normal file
172
app/Http/Controllers/JenisLampiranController.php
Normal file
@@ -0,0 +1,172 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Modules\Lpj\Http\Controllers;
|
||||||
|
|
||||||
|
use Exception;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Routing\Controller;
|
||||||
|
use Illuminate\Support\Facades\Auth;
|
||||||
|
use Illuminate\Support\Facades\DB;
|
||||||
|
use Maatwebsite\Excel\Facades\Excel;
|
||||||
|
use Modules\Lpj\Exports\JenisLampiranExport;
|
||||||
|
use Modules\Lpj\Http\Requests\JenisLampiranRequest;
|
||||||
|
use Modules\Lpj\Models\JenisLampiran;
|
||||||
|
|
||||||
|
class JenisLampiranController extends Controller
|
||||||
|
{
|
||||||
|
public function index()
|
||||||
|
{
|
||||||
|
$jenisLampirans = JenisLampiran::all();
|
||||||
|
return view('lpj::jenis_lampiran.index', compact('jenisLampirans'));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function store(JenisLampiranRequest $request)
|
||||||
|
{
|
||||||
|
DB::beginTransaction();
|
||||||
|
try {
|
||||||
|
$validated = $request->validated();
|
||||||
|
$validated['created_by'] = Auth::id();
|
||||||
|
|
||||||
|
$jenisLampiran = JenisLampiran::create($validated);
|
||||||
|
|
||||||
|
DB::commit();
|
||||||
|
return redirect()
|
||||||
|
->route('basicdata.jenis-lampiran.index')
|
||||||
|
->with('success', 'Jenis Lampiran berhasil ditambahkan.');
|
||||||
|
} catch (Exception $e) {
|
||||||
|
DB::rollBack();
|
||||||
|
return redirect()
|
||||||
|
->back()
|
||||||
|
->with('error', 'Gagal menambahkan Jenis Lampiran: ' . $e->getMessage())
|
||||||
|
->withInput();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function create()
|
||||||
|
{
|
||||||
|
return view('lpj::jenis_lampiran.create');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function show($id)
|
||||||
|
{
|
||||||
|
$jenisLampiran = JenisLampiran::findOrFail($id);
|
||||||
|
return view('lpj::jenis_lampiran.show', compact('jenisLampiran'));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function edit($id)
|
||||||
|
{
|
||||||
|
$jenisLampiran = JenisLampiran::findOrFail($id);
|
||||||
|
return view('lpj::jenis_lampiran.create', compact('jenisLampiran'));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function update(JenisLampiranRequest $request, $id)
|
||||||
|
{
|
||||||
|
DB::beginTransaction();
|
||||||
|
try {
|
||||||
|
$jenisLampiran = JenisLampiran::findOrFail($id);
|
||||||
|
$validated = $request->validated();
|
||||||
|
$validated['updated_by'] = Auth::id();
|
||||||
|
|
||||||
|
$jenisLampiran->update($validated);
|
||||||
|
|
||||||
|
DB::commit();
|
||||||
|
return redirect()
|
||||||
|
->route('basicdata.jenis-lampiran.index')
|
||||||
|
->with('success', 'Jenis Lampiran berhasil diperbarui.');
|
||||||
|
} catch (Exception $e) {
|
||||||
|
DB::rollBack();
|
||||||
|
return redirect()
|
||||||
|
->back()
|
||||||
|
->with('error', 'Gagal memperbarui Jenis Lampiran: ' . $e->getMessage())
|
||||||
|
->withInput();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function destroy($id)
|
||||||
|
{
|
||||||
|
DB::beginTransaction();
|
||||||
|
try {
|
||||||
|
$jenisLampiran = JenisLampiran::findOrFail($id);
|
||||||
|
$jenisLampiran->deleted_by = Auth::id();
|
||||||
|
$jenisLampiran->save();
|
||||||
|
|
||||||
|
$jenisLampiran->delete();
|
||||||
|
|
||||||
|
DB::commit();
|
||||||
|
echo json_encode(['success' => true, 'message' => 'Jenis Lampiran berhasil dihapus.']);
|
||||||
|
|
||||||
|
} catch (Exception $e) {
|
||||||
|
DB::rollBack();
|
||||||
|
echo json_encode([
|
||||||
|
'success' => false,
|
||||||
|
'message' => 'Gagal menghapus Jenis Lampiran: ' . $e->getMessage()
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function dataForDatatables(Request $request)
|
||||||
|
{
|
||||||
|
// Retrieve data from the database
|
||||||
|
$query = JenisLampiran::query();
|
||||||
|
|
||||||
|
// Apply search filter if provided
|
||||||
|
if ($request->has('search') && !empty($request->get('search'))) {
|
||||||
|
$search = $request->get('search');
|
||||||
|
$query->where(function ($q) use ($search) {
|
||||||
|
$q->where('nama', 'LIKE', "%$search%")
|
||||||
|
->orWhere('deskripsi', 'LIKE', "%$search%");
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// Apply sorting if provided
|
||||||
|
if ($request->has('sortOrder') && !empty($request->get('sortOrder'))) {
|
||||||
|
$order = $request->get('sortOrder');
|
||||||
|
$column = $request->get('sortField');
|
||||||
|
$query->orderBy($column, $order);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get the total count of records
|
||||||
|
$totalRecords = $query->count();
|
||||||
|
|
||||||
|
// Apply pagination if provided
|
||||||
|
if ($request->has('page') && $request->has('size')) {
|
||||||
|
$page = $request->get('page');
|
||||||
|
$size = $request->get('size');
|
||||||
|
$offset = ($page - 1) * $size; // Calculate the offset
|
||||||
|
|
||||||
|
$query->skip($offset)->take($size);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get the filtered count of records
|
||||||
|
$filteredRecords = $query->count();
|
||||||
|
|
||||||
|
// Get the data for the current page
|
||||||
|
$data = $query->get();
|
||||||
|
|
||||||
|
// Calculate the page count
|
||||||
|
$pageCount = ceil($totalRecords / $request->get('size'));
|
||||||
|
|
||||||
|
// Calculate the current page number
|
||||||
|
$currentPage = $request->get('page', 1);
|
||||||
|
|
||||||
|
// Return the response data as a JSON object
|
||||||
|
return response()->json([
|
||||||
|
'draw' => $request->get('draw'),
|
||||||
|
'recordsTotal' => $totalRecords,
|
||||||
|
'recordsFiltered' => $filteredRecords,
|
||||||
|
'pageCount' => $pageCount,
|
||||||
|
'page' => $currentPage,
|
||||||
|
'totalCount' => $totalRecords,
|
||||||
|
'data' => $data,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function export()
|
||||||
|
{
|
||||||
|
if (is_null($this->user) || !$this->user->can('jenis_lampiran.export')) {
|
||||||
|
abort(403, 'Sorry! You are not allowed to export jenis lampiran.');
|
||||||
|
}
|
||||||
|
|
||||||
|
return Excel::download(new JenisLampiranExport, 'jenis_lampiran.xlsx');
|
||||||
|
}
|
||||||
|
}
|
||||||
174
app/Http/Controllers/JenisLaporanController.php
Normal file
174
app/Http/Controllers/JenisLaporanController.php
Normal file
@@ -0,0 +1,174 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Modules\Lpj\Http\Controllers;
|
||||||
|
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use Maatwebsite\Excel\Facades\Excel;
|
||||||
|
use Modules\Lpj\Models\JenisLaporan;
|
||||||
|
use Modules\Lpj\Exports\JenisLaporanExport;
|
||||||
|
use Modules\Lpj\Http\Requests\JenisLaporanRequest;
|
||||||
|
use Throwable;
|
||||||
|
|
||||||
|
class JenisLaporanController extends Controller
|
||||||
|
{
|
||||||
|
public $user;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Display a listing of the resource.
|
||||||
|
*/
|
||||||
|
public function index()
|
||||||
|
{
|
||||||
|
return view('lpj::jenis_laporan.index');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show the form for creating a new resource.
|
||||||
|
*/
|
||||||
|
public function create()
|
||||||
|
{
|
||||||
|
return view('lpj::jenis_laporan.create');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Store a newly created resource in storage.
|
||||||
|
*/
|
||||||
|
public function store(JenisLaporanRequest $request)
|
||||||
|
{
|
||||||
|
$validate = $request->validated();
|
||||||
|
|
||||||
|
if ($validate) {
|
||||||
|
try {
|
||||||
|
JenisLaporan::create($validate);
|
||||||
|
return redirect()
|
||||||
|
->route('basicdata.jenis_laporan.index')
|
||||||
|
->with('success', 'Jenis Laporan created successfully');
|
||||||
|
} catch (Throwable $e) {
|
||||||
|
return redirect()
|
||||||
|
->route('basicdata.jenis_laporan.create')
|
||||||
|
->with('success', 'Failed to create Jenis Laporan: ' . $e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show the specified resource.
|
||||||
|
*/
|
||||||
|
public function show($id)
|
||||||
|
{
|
||||||
|
// return view('lpj::show');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show the form for editing the specified resource.
|
||||||
|
*/
|
||||||
|
public function edit($id)
|
||||||
|
{
|
||||||
|
$jenisLaporan = JenisLaporan::find($id);
|
||||||
|
return view('lpj::jenis_laporan.create', compact('jenisLaporan'));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update the specified resource in storage.
|
||||||
|
*/
|
||||||
|
public function update(JenisLaporanRequest $request, $id)
|
||||||
|
{
|
||||||
|
$validate = $request->validated();
|
||||||
|
|
||||||
|
if ($validate) {
|
||||||
|
try {
|
||||||
|
$jenisLaporan = JenisLaporan::find($id);
|
||||||
|
$jenisLaporan->update($validate);
|
||||||
|
return redirect()
|
||||||
|
->route('basicdata.jenis_laporan.index')
|
||||||
|
->with('success', 'Jenis Laporan updated successfully');
|
||||||
|
} catch (Throwable $e) {
|
||||||
|
return redirect()
|
||||||
|
->route('basicdata.jenis_laporan.edit', $id)
|
||||||
|
->with('success', 'Failed to update Jenis Laporan: ' . $e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove the specified resource from storage.
|
||||||
|
*/
|
||||||
|
public function destroy($id)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
// Delete from database
|
||||||
|
$jenisLaporan = JenisLaporan::find($id);
|
||||||
|
$jenisLaporan->delete();
|
||||||
|
|
||||||
|
echo json_encode(['success' => true, 'message' => 'Jenis Laporan deleted successfully']);
|
||||||
|
} catch (Throwable $e) {
|
||||||
|
echo json_encode(['success' => false, 'message' => 'Failed to delete jenis Laporan']);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function dataForDatatables(Request $request)
|
||||||
|
{
|
||||||
|
if (is_null($this->user) || !$this->user->can('jenis_jaminan.view')) {
|
||||||
|
//abort(403, 'Sorry! You are not allowed to view users.');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Retrieve data from the database
|
||||||
|
$query = JenisLaporan::query();
|
||||||
|
|
||||||
|
// Apply search filter if provided
|
||||||
|
if ($request->has('search') && !empty($request->get('search'))) {
|
||||||
|
$search = $request->get('search');
|
||||||
|
$query->where(function ($q) use ($search) {
|
||||||
|
$q->where('code', 'LIKE', "%$search%");
|
||||||
|
$q->orWhere('name', 'LIKE', "%$search%");
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// Apply sorting if provided
|
||||||
|
if ($request->has('sortOrder') && !empty($request->get('sortOrder'))) {
|
||||||
|
$order = $request->get('sortOrder');
|
||||||
|
$column = $request->get('sortField');
|
||||||
|
$query->orderBy($column, $order);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get the total count of records
|
||||||
|
$totalRecords = $query->count();
|
||||||
|
|
||||||
|
// Apply pagination if provided
|
||||||
|
if ($request->has('page') && $request->has('size')) {
|
||||||
|
$page = $request->get('page');
|
||||||
|
$size = $request->get('size');
|
||||||
|
$offset = ($page - 1) * $size; // Calculate the offset
|
||||||
|
|
||||||
|
$query->skip($offset)->take($size);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get the filtered count of records
|
||||||
|
$filteredRecords = $query->count();
|
||||||
|
|
||||||
|
// Get the data for the current page
|
||||||
|
$data = $query->get();
|
||||||
|
|
||||||
|
// Calculate the page count
|
||||||
|
$pageCount = ceil($totalRecords / $request->get('size'));
|
||||||
|
|
||||||
|
// Calculate the current page number
|
||||||
|
$currentPage = 0 + 1;
|
||||||
|
|
||||||
|
// Return the response data as a JSON object
|
||||||
|
return response()->json([
|
||||||
|
'draw' => $request->get('draw'),
|
||||||
|
'recordsTotal' => $totalRecords,
|
||||||
|
'recordsFiltered' => $filteredRecords,
|
||||||
|
'pageCount' => $pageCount,
|
||||||
|
'page' => $currentPage,
|
||||||
|
'totalCount' => $totalRecords,
|
||||||
|
'data' => $data,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function export()
|
||||||
|
{
|
||||||
|
return Excel::download(new JenisLaporanExport, 'jenis_laporan.xlsx');
|
||||||
|
}
|
||||||
|
}
|
||||||
165
app/Http/Controllers/JenisLegalitasJaminanController.php
Normal file
165
app/Http/Controllers/JenisLegalitasJaminanController.php
Normal file
@@ -0,0 +1,165 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Modules\Lpj\Http\Controllers;
|
||||||
|
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use Exception;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Maatwebsite\Excel\Facades\Excel;
|
||||||
|
use Modules\Lpj\Exports\JenisLegalitasJaminanExport;
|
||||||
|
use Modules\Lpj\Http\Requests\JenisLegalitasJaminanRequest;
|
||||||
|
use Modules\Lpj\Models\CustomField;
|
||||||
|
use Modules\Lpj\Models\JenisLegalitasJaminan;
|
||||||
|
|
||||||
|
class JenisLegalitasJaminanController extends Controller
|
||||||
|
{
|
||||||
|
public $user;
|
||||||
|
|
||||||
|
public function index()
|
||||||
|
{
|
||||||
|
return view('lpj::jenis_legalitas_jaminan.index');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function store(JenisLegalitasJaminanRequest $request)
|
||||||
|
{
|
||||||
|
$validate = $request->validated();
|
||||||
|
|
||||||
|
if ($validate) {
|
||||||
|
try {
|
||||||
|
// Save to database
|
||||||
|
JenisLegalitasJaminan::create($validate);
|
||||||
|
return redirect()
|
||||||
|
->route('basicdata.jenis-legalitas-jaminan.index')
|
||||||
|
->with('success', 'Jenis Legalitas Jaminan created successfully');
|
||||||
|
} catch (Exception $e) {
|
||||||
|
return redirect()
|
||||||
|
->route('basicdata.jenis-legalitas-jaminan.create')
|
||||||
|
->with('error', 'Failed to create jenis legalitas jaminan');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function create()
|
||||||
|
{
|
||||||
|
$customFields = CustomField::orderBy('urutan_prioritas', 'asc')->get();
|
||||||
|
return view('lpj::jenis_legalitas_jaminan.create',compact('customFields'));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function edit($id)
|
||||||
|
{
|
||||||
|
$jenisLegalitasJaminan = JenisLegalitasJaminan::find($id);
|
||||||
|
$customFields = CustomField::orderBy('urutan_prioritas', 'asc')->get();
|
||||||
|
return view('lpj::jenis_legalitas_jaminan.create', compact('jenisLegalitasJaminan', 'customFields'));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function update(JenisLegalitasJaminanRequest $request, $id)
|
||||||
|
{
|
||||||
|
$validate = $request->validated();
|
||||||
|
|
||||||
|
if ($validate) {
|
||||||
|
try {
|
||||||
|
// Update in database
|
||||||
|
$jenisLegalitasJaminan = JenisLegalitasJaminan::find($id);
|
||||||
|
$jenisLegalitasJaminan->update($validate);
|
||||||
|
return redirect()
|
||||||
|
->route('basicdata.jenis-legalitas-jaminan.index')
|
||||||
|
->with('success', 'Jenis Legalitas Jaminan updated successfully');
|
||||||
|
} catch (Exception $e) {
|
||||||
|
return redirect()
|
||||||
|
->route('basicdata.jenis-legalitas-jaminan.edit', $id)
|
||||||
|
->with('error', 'Failed to update jenis legalitas jaminan');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function destroy($id)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
// Delete from database
|
||||||
|
$jenisLegalitasJaminan = JenisLegalitasJaminan::find($id);
|
||||||
|
$jenisLegalitasJaminan->delete();
|
||||||
|
|
||||||
|
echo json_encode(['success' => true, 'message' => 'Jenis Legalitas Jaminan deleted successfully']);
|
||||||
|
} catch (Exception $e) {
|
||||||
|
echo json_encode(['success' => false, 'message' => 'Failed to delete jenis legalitas jaminan']);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function dataForDatatables(Request $request)
|
||||||
|
{
|
||||||
|
if (is_null($this->user) || !$this->user->can('jenis_legalitas_jaminan.view')) {
|
||||||
|
//abort(403, 'Sorry! You are not allowed to view users.');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Retrieve data from the database
|
||||||
|
$query = JenisLegalitasJaminan::query();
|
||||||
|
|
||||||
|
// Apply search filter if provided
|
||||||
|
if ($request->has('search') && !empty($request->get('search'))) {
|
||||||
|
$search = $request->get('search');
|
||||||
|
$query->where(function ($q) use ($search) {
|
||||||
|
$q->where('code', 'LIKE', "%$search%");
|
||||||
|
$q->orWhere('name', 'LIKE', "%$search%");
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// Apply sorting if provided
|
||||||
|
if ($request->has('sortOrder') && !empty($request->get('sortOrder'))) {
|
||||||
|
$order = $request->get('sortOrder');
|
||||||
|
$column = $request->get('sortField');
|
||||||
|
$query->orderBy($column, $order);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get the total count of records
|
||||||
|
$totalRecords = $query->count();
|
||||||
|
|
||||||
|
// Apply pagination if provided
|
||||||
|
if ($request->has('page') && $request->has('size')) {
|
||||||
|
$page = $request->get('page');
|
||||||
|
$size = $request->get('size');
|
||||||
|
$offset = ($page - 1) * $size; // Calculate the offset
|
||||||
|
|
||||||
|
$query->skip($offset)->take($size);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get the filtered count of records
|
||||||
|
$filteredRecords = $query->count();
|
||||||
|
|
||||||
|
// Get the data for the current page
|
||||||
|
$data = $query->get();
|
||||||
|
|
||||||
|
// Calculate the page count
|
||||||
|
$pageCount = ceil($totalRecords / $request->get('size'));
|
||||||
|
|
||||||
|
// Calculate the current page number
|
||||||
|
$currentPage = 0 + 1;
|
||||||
|
|
||||||
|
// Return the response data as a JSON object
|
||||||
|
return response()->json([
|
||||||
|
'draw' => $request->get('draw'),
|
||||||
|
'recordsTotal' => $totalRecords,
|
||||||
|
'recordsFiltered' => $filteredRecords,
|
||||||
|
'pageCount' => $pageCount,
|
||||||
|
'page' => $currentPage,
|
||||||
|
'totalCount' => $totalRecords,
|
||||||
|
'data' => $data,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function export()
|
||||||
|
{
|
||||||
|
return Excel::download(new JenisLegalitasJaminanExport, 'jenis_legalitas_jaminan.xlsx');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getCustomFields($id)
|
||||||
|
{
|
||||||
|
$jenisLegalitasJaminan = JenisLegalitasJaminan::findOrFail($id);
|
||||||
|
if(!$jenisLegalitasJaminan->custom_fields) {
|
||||||
|
return response()->json([]);
|
||||||
|
}
|
||||||
|
|
||||||
|
$customFields = CustomField::whereIn('id', $jenisLegalitasJaminan->custom_fields)->get();
|
||||||
|
|
||||||
|
return response()->json($customFields);
|
||||||
|
}
|
||||||
|
}
|
||||||
156
app/Http/Controllers/JenisPenilaianController.php
Normal file
156
app/Http/Controllers/JenisPenilaianController.php
Normal file
@@ -0,0 +1,156 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Modules\Lpj\Http\Controllers;
|
||||||
|
|
||||||
|
use Exception;
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use Illuminate\Http\RedirectResponse;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Modules\Lpj\Models\JenisPenilaian;
|
||||||
|
use Modules\Lpj\Http\Requests\JenisPenilaianRequest;
|
||||||
|
use Modules\Lpj\Exports\JenisPenilaianExport;
|
||||||
|
use Maatwebsite\Excel\Facades\Excel;
|
||||||
|
|
||||||
|
class JenisPenilaianController extends Controller
|
||||||
|
{
|
||||||
|
public $user;
|
||||||
|
/**
|
||||||
|
* Display a listing of the resource.
|
||||||
|
*/
|
||||||
|
public function index()
|
||||||
|
{
|
||||||
|
return view('lpj::jenis_penilaian.index');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show the form for creating a new resource.
|
||||||
|
*/
|
||||||
|
public function create()
|
||||||
|
{
|
||||||
|
return view('lpj::jenis_penilaian.form');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Store a newly created resource in storage.
|
||||||
|
*/
|
||||||
|
public function store(JenisPenilaianRequest $request)
|
||||||
|
{
|
||||||
|
$validate = $request->validated();
|
||||||
|
|
||||||
|
try {
|
||||||
|
JenisPenilaian::create($validate);
|
||||||
|
return redirect()->route('basicdata.jenis-penilaian.index')->with('success', 'Jenis Penilaian created successfully');
|
||||||
|
} catch (Exception $e) {
|
||||||
|
return redirect()->route('basicdata.jenis-penilaian.create')->with('error', $e->getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show the form for editing the specified resource.
|
||||||
|
*/
|
||||||
|
public function edit($id)
|
||||||
|
{
|
||||||
|
$jenisPenilaian = JenisPenilaian::find($id);
|
||||||
|
return view('lpj::jenis_penilaian.form', compact('jenisPenilaian'));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update the specified resource in storage.
|
||||||
|
*/
|
||||||
|
public function update(JenisPenilaianRequest $request, $id)
|
||||||
|
{
|
||||||
|
|
||||||
|
$validated = $request->validated();
|
||||||
|
|
||||||
|
|
||||||
|
if ($validated) {
|
||||||
|
try {
|
||||||
|
$jenisPenilaian = JenisPenilaian::find($id);
|
||||||
|
$jenisPenilaian->update($validated);
|
||||||
|
return redirect()->route('basicdata.jenis-penilaian.index')->with('success', 'Jenis Penilaian updated successfully');
|
||||||
|
} catch (Exception $e) {
|
||||||
|
return redirect()->route('basicdata.jenis-penilaian.edit', $id)->with('error', $e->getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove the specified resource from storage.
|
||||||
|
*/
|
||||||
|
public function destroy($id)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
$jenisPenilaian = JenisPenilaian::find($id);
|
||||||
|
$jenisPenilaian->delete();
|
||||||
|
echo json_encode(['success' => true, 'message' => 'Jenis Penilaian deleted successfully']);
|
||||||
|
|
||||||
|
} catch (Exception $e) {
|
||||||
|
echo json_encode(['success' => false, 'message' => 'Failed to delete Jenis Penilaian']);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function dataForDatatables(Request $request)
|
||||||
|
{
|
||||||
|
if (is_null($this->user) || !$this->user->can('jenis_penilaian.view')) {
|
||||||
|
//abort(403, 'Sorry! You are not allowed to view users.');
|
||||||
|
}
|
||||||
|
|
||||||
|
$query = JenisPenilaian::query();
|
||||||
|
|
||||||
|
if ($request->has('search') && !empty($request->get('search'))) {
|
||||||
|
$search = $request->get('search');
|
||||||
|
$query->where(function ($q) use ($search) {
|
||||||
|
$q->where('code', 'LIKE', "%$search%");
|
||||||
|
$q->orWhere('name', 'LIKE', "%$search%");
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($request->has('sortOrder') && !empty($request->get('sortOrder'))) {
|
||||||
|
$order = $request->get('sortOrder');
|
||||||
|
$column = $request->get('sortField');
|
||||||
|
$query->orderBy($column, $order);
|
||||||
|
}
|
||||||
|
|
||||||
|
$totalRecords = $query->count();
|
||||||
|
|
||||||
|
|
||||||
|
$size = $request->get('size');
|
||||||
|
$pageCount = 1;
|
||||||
|
|
||||||
|
if ($size > 0) {
|
||||||
|
if ($request->has('page') && $request->has('size')) {
|
||||||
|
$page = $request->get('page');
|
||||||
|
$offset = ($page - 1) * $size;
|
||||||
|
$query->skip($offset)->take($size);
|
||||||
|
$filteredRecords = $query->count();
|
||||||
|
$pageCount = ceil($totalRecords / $size);
|
||||||
|
}
|
||||||
|
|
||||||
|
$data = $query->get();
|
||||||
|
} else {
|
||||||
|
$filteredRecords = $totalRecords;
|
||||||
|
$data = $query->get();
|
||||||
|
}
|
||||||
|
|
||||||
|
$currentPage = $request->get('page') ?? 1;
|
||||||
|
|
||||||
|
|
||||||
|
// Return the response data as a JSON object
|
||||||
|
return response()->json([
|
||||||
|
'draw' => $request->get('draw'),
|
||||||
|
'recordsTotal' => $totalRecords,
|
||||||
|
'recordsFiltered' => $filteredRecords,
|
||||||
|
'pageCount' => $pageCount,
|
||||||
|
'page' => $currentPage,
|
||||||
|
'totalCount' => $totalRecords,
|
||||||
|
'data' => $data
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public function export()
|
||||||
|
{
|
||||||
|
return Excel::download(new JenisPenilaianExport(), 'jenis-penilaian.xlsx');
|
||||||
|
}
|
||||||
|
}
|
||||||
525
app/Http/Controllers/KJPPController.php
Normal file
525
app/Http/Controllers/KJPPController.php
Normal file
@@ -0,0 +1,525 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Modules\Lpj\Http\Controllers;
|
||||||
|
|
||||||
|
use Throwable;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Modules\Lpj\Models\KJPP;
|
||||||
|
use Modules\Location\Models\City;
|
||||||
|
use Modules\Lpj\Models\IjinUsaha;
|
||||||
|
use Modules\Lpj\Exports\KJPPExport;
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use Maatwebsite\Excel\Facades\Excel;
|
||||||
|
use Modules\Location\Models\Village;
|
||||||
|
use Modules\Lpj\Models\JenisJaminan;
|
||||||
|
use Modules\Location\Models\District;
|
||||||
|
use Modules\Location\Models\Province;
|
||||||
|
use Illuminate\Support\Facades\Storage;
|
||||||
|
use Modules\Lpj\Http\Requests\KJPPRequest;
|
||||||
|
|
||||||
|
class KJPPController extends Controller
|
||||||
|
{
|
||||||
|
public $user;
|
||||||
|
/**
|
||||||
|
* Display a listing of the resource.
|
||||||
|
*/
|
||||||
|
public function index()
|
||||||
|
{
|
||||||
|
return view('lpj::kjpp.index');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show the form for creating a new resource.
|
||||||
|
*/
|
||||||
|
public function create()
|
||||||
|
{
|
||||||
|
$ijin_usaha = IjinUsaha::all();
|
||||||
|
$jenis_aset = JenisJaminan::all();
|
||||||
|
$provinces = Province::all();
|
||||||
|
|
||||||
|
// Generate KJPP Number
|
||||||
|
$lastKjpp = KJPP::orderBy('code', 'desc')->first();
|
||||||
|
$nextNumber = $lastKjpp ? intval(substr($lastKjpp->code, 1, 6)) + 1 : 1;
|
||||||
|
$kjppNumber = 'K' . str_pad($nextNumber, 6, '0', STR_PAD_LEFT);
|
||||||
|
|
||||||
|
// Combine KJPP number with branch code
|
||||||
|
$fullKjppNumber = $kjppNumber;
|
||||||
|
$detailJoinEmailKantor = json_encode([]);
|
||||||
|
$detailJoinPimpinan = json_encode([]);
|
||||||
|
$detailJoinPicReviewer = json_encode([]);
|
||||||
|
$detailJoinPicAdmin = json_encode([]);
|
||||||
|
$detailJoinPicMarketing = json_encode([]);
|
||||||
|
|
||||||
|
return view('lpj::kjpp.create', compact('ijin_usaha', 'jenis_aset', 'provinces', 'fullKjppNumber', 'detailJoinEmailKantor', 'detailJoinPimpinan', 'detailJoinPicReviewer', 'detailJoinPicAdmin', 'detailJoinPicMarketing'));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Store a newly created resource in storage.
|
||||||
|
*/
|
||||||
|
public function store(KJPPRequest $request)
|
||||||
|
{
|
||||||
|
$validated = $request->validated();
|
||||||
|
|
||||||
|
|
||||||
|
if ($validated) {
|
||||||
|
$detailEmailKantor = [];
|
||||||
|
$detailNamaPimpinan = [];
|
||||||
|
$detailNomorPicPimpinan = [];
|
||||||
|
$detailNamaPicReviewer = [];
|
||||||
|
$detailNomorHpPicReviewer = [];
|
||||||
|
$detailNamaPicAdmin = [];
|
||||||
|
$detailNomorHpPicAdmin = [];
|
||||||
|
$detailNamaPicMarketing = [];
|
||||||
|
$detailNomorHpPicMarketing = [];
|
||||||
|
|
||||||
|
$emailKantor = $request->input('detail_email_kantor.email_kantor', []);
|
||||||
|
$namaPimpinan = $request->input('detail_nama_pimpinan.nama_pimpinan', []);
|
||||||
|
$nomorHpPimpinan = $request->input('detail_nomor_hp_pimpinan.nomor_hp_pimpinan', []);
|
||||||
|
$namaPicReviewer = $request->input('detail_nama_pic_reviewer.nama_pic_reviewer', []);
|
||||||
|
$nomorHpPicReviewer = $request->input('detail_nomor_hp_pic_reviewer.nomor_hp_pic_reviewer', []);
|
||||||
|
$namaPicAdmin = $request->input('detail_nama_pic_admin.nama_pic_admin', []);
|
||||||
|
$nomorHpPicAdmin = $request->input('detail_nomor_hp_pic_admin.nomor_hp_pic_admin', []);
|
||||||
|
$namaPicMarketing = $request->input('detail_nama_pic_marketing.nama_pic_marketing', []);
|
||||||
|
$nomorHpPicMarketing = $request->input('detail_nomor_hp_pic_marketing.nomor_hp_pic_marketing', []);
|
||||||
|
|
||||||
|
foreach ($emailKantor as $value) {
|
||||||
|
$detailEmailKantor[] = $value;
|
||||||
|
}
|
||||||
|
// Encode to JSON and store
|
||||||
|
$detailEmailKantorJson = json_encode($detailEmailKantor);
|
||||||
|
|
||||||
|
// Process detail_nama_pimpinan
|
||||||
|
foreach ($namaPimpinan as $value) {
|
||||||
|
$detailNamaPimpinan[] = $value;
|
||||||
|
}
|
||||||
|
$detailNamaPimpinanJson = json_encode($detailNamaPimpinan);
|
||||||
|
|
||||||
|
// Process detail_nomor_pic_pimpinan
|
||||||
|
foreach ($nomorHpPimpinan as $value) {
|
||||||
|
$detailNomorPicPimpinan[] = $value;
|
||||||
|
}
|
||||||
|
$detailNomorPicPimpinanJson = json_encode($detailNomorPicPimpinan);
|
||||||
|
|
||||||
|
// Process detail_nama_pic_reviewer
|
||||||
|
foreach ($namaPicReviewer as $value) {
|
||||||
|
$detailNamaPicReviewer[] = $value;
|
||||||
|
}
|
||||||
|
$detailNamaPicReviewerJson = json_encode($detailNamaPicReviewer);
|
||||||
|
|
||||||
|
// Process detail_nomor_hp_pic_reviewer
|
||||||
|
foreach ($nomorHpPicReviewer as $value) {
|
||||||
|
$detailNomorHpPicReviewer[] = $value;
|
||||||
|
}
|
||||||
|
$detailNomorHpPicReviewerJson = json_encode($detailNomorHpPicReviewer);
|
||||||
|
|
||||||
|
// Process detail_nama_pic_admin
|
||||||
|
foreach ($namaPicAdmin as $value) {
|
||||||
|
$detailNamaPicAdmin[] = $value;
|
||||||
|
}
|
||||||
|
$detailNamaPicAdminJson = json_encode($detailNamaPicAdmin);
|
||||||
|
|
||||||
|
// Process detail_nomor_hp_pic_admin
|
||||||
|
foreach ($nomorHpPicAdmin as $value) {
|
||||||
|
$detailNomorHpPicAdmin[] = $value;
|
||||||
|
}
|
||||||
|
$detailNomorHpPicAdminJson = json_encode($detailNomorHpPicAdmin);
|
||||||
|
|
||||||
|
// Process detail_nama_pic_marketing
|
||||||
|
foreach ($namaPicMarketing as $value) {
|
||||||
|
$detailNamaPicMarketing[] = $value;
|
||||||
|
}
|
||||||
|
$detailNamaPicMarketingJson = json_encode($detailNamaPicMarketing);
|
||||||
|
|
||||||
|
// Process detail_nomor_hp_pic_marketing
|
||||||
|
foreach ($nomorHpPicMarketing as $value) {
|
||||||
|
$detailNomorHpPicMarketing[] = $value;
|
||||||
|
}
|
||||||
|
$detailNomorHpPicMarketingJson = json_encode($detailNomorHpPicMarketing);
|
||||||
|
|
||||||
|
|
||||||
|
$file = $request->file('attachment');
|
||||||
|
$filename = $file ? time() . '.' . $file->getClientOriginalExtension() : 'default.pdf';
|
||||||
|
|
||||||
|
if ($file) {
|
||||||
|
// Simpan file yang diunggah
|
||||||
|
$file->storeAs('public/uploads_pdf', $filename);
|
||||||
|
} else {
|
||||||
|
// Salin file default ke lokasi yang diinginkan
|
||||||
|
Storage::copy('public/test/default.pdf', 'public/uploads_pdf/' . $filename);
|
||||||
|
}
|
||||||
|
|
||||||
|
$validated['detail_email_kantor'] = $detailEmailKantorJson;
|
||||||
|
$validated['detail_nama_pimpinan'] = $detailNamaPimpinanJson;
|
||||||
|
$validated['detail_nomor_hp_pimpinan'] = $detailNomorPicPimpinanJson;
|
||||||
|
$validated['detail_nama_pic_reviewer'] = $detailNamaPicReviewerJson;
|
||||||
|
$validated['detail_nomor_hp_pic_reviewer'] = $detailNomorHpPicReviewerJson;
|
||||||
|
$validated['detail_nama_pic_admin'] = $detailNamaPicAdminJson;
|
||||||
|
$validated['detail_nomor_hp_pic_admin'] = $detailNomorHpPicAdminJson;
|
||||||
|
$validated['detail_nama_pic_marketing'] = $detailNamaPicMarketingJson;
|
||||||
|
$validated['detail_nomor_hp_pic_marketing'] = $detailNomorHpPicMarketingJson;
|
||||||
|
$validated['ijin_usaha_id'] = json_encode($validated['ijin_usaha_id']);
|
||||||
|
if (empty($validated['jenis_aset_id'])) {
|
||||||
|
$validated['jenis_aset_id'] = json_encode([]);
|
||||||
|
} else {
|
||||||
|
$validated['jenis_aset_id'] = json_encode($validated['jenis_aset_id']);
|
||||||
|
}
|
||||||
|
// Tambahkan nama file ke data yang divalidasi
|
||||||
|
$validated['attachment'] = $filename;
|
||||||
|
|
||||||
|
// dd($validated);
|
||||||
|
|
||||||
|
// Simpan data ke database
|
||||||
|
KJPP::create($validated);
|
||||||
|
|
||||||
|
return redirect()
|
||||||
|
->route('basicdata.kjpp.index')
|
||||||
|
->with('success', 'KJPP created successfully');
|
||||||
|
} else {
|
||||||
|
return redirect()
|
||||||
|
->route('basicdata.kjpp.create')
|
||||||
|
->with('error', 'Validation failed');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show the specified resource.
|
||||||
|
*/
|
||||||
|
public function show($id)
|
||||||
|
{
|
||||||
|
$kjpp = KJPP::find($id);
|
||||||
|
$ijin_usaha = IjinUsaha::where('code', $kjpp->nomor_ijin_usaha)->get();
|
||||||
|
$ijin_usahas = IjinUsaha::all();
|
||||||
|
$jenis_jaminan = JenisJaminan::all();
|
||||||
|
$provinces = Province::where('code', $kjpp->province_code)->get();
|
||||||
|
$cities = City::where('code', $kjpp->city_code)->get();
|
||||||
|
$districts = District::where('code', $kjpp->district_code)->get();
|
||||||
|
$villages = Village::where('code', $kjpp->village_code)->get();
|
||||||
|
$detailEmailKantor = json_decode($kjpp->detail_email_kantor);
|
||||||
|
$detailNamaPimpinan = json_decode($kjpp->detail_nama_pimpinan);
|
||||||
|
$detailNomorHpPimpinan = json_decode($kjpp->detail_nomor_hp_pimpinan);
|
||||||
|
$detailNamaPicReviewer = json_decode($kjpp->detail_nama_pic_reviewer);
|
||||||
|
$detailNomorHpPicReviewer = json_decode($kjpp->detail_nomor_hp_pic_reviewer);
|
||||||
|
$detailNamaPicAdmin = json_decode($kjpp->detail_nama_pic_admin);
|
||||||
|
$detailNomorHpPicAdmin = json_decode($kjpp->detail_nomor_hp_pic_admin);
|
||||||
|
$detailNamaPicMarketing = json_decode($kjpp->detail_nama_pic_marketing);
|
||||||
|
$detailNomorHpPicMarketing = json_decode($kjpp->detail_nomor_hp_pic_marketing);
|
||||||
|
|
||||||
|
$detailJoinEmailKantor = json_encode(array_map(function ($email) {
|
||||||
|
return [
|
||||||
|
'email_kantor' => $email
|
||||||
|
];
|
||||||
|
}, $detailEmailKantor));
|
||||||
|
|
||||||
|
$detailJoinPimpinan = json_encode(array_map(function ($nama, $nomor) {
|
||||||
|
return [
|
||||||
|
'nama_pimpinan' => $nama,
|
||||||
|
'nomor_hp_pimpinan' => $nomor
|
||||||
|
];
|
||||||
|
}, $detailNamaPimpinan, $detailNomorHpPimpinan));
|
||||||
|
|
||||||
|
|
||||||
|
$detailJoinPicReviewer = json_encode(array_map(function ($nama, $nomor) {
|
||||||
|
return [
|
||||||
|
'nama_pic_reviewer' => $nama,
|
||||||
|
'nomor_hp_pic_reviewer' => $nomor
|
||||||
|
];
|
||||||
|
}, $detailNamaPicReviewer, $detailNomorHpPicReviewer));
|
||||||
|
|
||||||
|
$detailJoinPicAdmin = json_encode(array_map(function ($nama, $nomor) {
|
||||||
|
return [
|
||||||
|
'nama_pic_admin' => $nama,
|
||||||
|
'nomor_hp_pic_admin' => $nomor
|
||||||
|
];
|
||||||
|
}, $detailNamaPicAdmin, $detailNomorHpPicAdmin));
|
||||||
|
|
||||||
|
$detailJoinPicMarketing = json_encode(array_map(function ($nama, $nomor) {
|
||||||
|
return [
|
||||||
|
'nama_pic_marketing' => $nama,
|
||||||
|
'nomor_hp_pic_marketing' => $nomor
|
||||||
|
];
|
||||||
|
}, $detailNamaPicMarketing, $detailNomorHpPicMarketing));
|
||||||
|
|
||||||
|
return view('lpj::kjpp.show', compact('jenis_jaminan', 'ijin_usahas', 'ijin_usaha', 'kjpp', 'provinces', 'cities', 'districts', 'villages', 'detailJoinEmailKantor', 'detailJoinPicReviewer', 'detailJoinPicAdmin', 'detailJoinPicMarketing', 'detailJoinPimpinan'));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show the form for editing the specified resource.
|
||||||
|
*/
|
||||||
|
public function edit($id)
|
||||||
|
{
|
||||||
|
$kjpp = KJPP::find($id);
|
||||||
|
$ijin_usaha = IjinUsaha::all();
|
||||||
|
$jenis_aset = JenisJaminan::all();
|
||||||
|
$provinces = Province::all();
|
||||||
|
$cities = City::where('province_code', $kjpp->province_code)->get();
|
||||||
|
$districts = District::where('city_code', $kjpp->city_code)->get();
|
||||||
|
$villages = Village::where('district_code', $kjpp->district_code)->get();
|
||||||
|
$detailEmailKantor = json_decode($kjpp->detail_email_kantor);
|
||||||
|
$detailNamaPimpinan = json_decode($kjpp->detail_nama_pimpinan);
|
||||||
|
$detailNomorHpPimpinan = json_decode($kjpp->detail_nomor_hp_pimpinan);
|
||||||
|
$detailNamaPicReviewer = json_decode($kjpp->detail_nama_pic_reviewer);
|
||||||
|
$detailNomorHpPicReviewer = json_decode($kjpp->detail_nomor_hp_pic_reviewer);
|
||||||
|
$detailNamaPicAdmin = json_decode($kjpp->detail_nama_pic_admin);
|
||||||
|
$detailNomorHpPicAdmin = json_decode($kjpp->detail_nomor_hp_pic_admin);
|
||||||
|
$detailNamaPicMarketing = json_decode($kjpp->detail_nama_pic_marketing);
|
||||||
|
$detailNomorHpPicMarketing = json_decode($kjpp->detail_nomor_hp_pic_marketing);
|
||||||
|
|
||||||
|
$detailJoinEmailKantor = json_encode(array_map(function ($email) {
|
||||||
|
return [
|
||||||
|
'email_kantor' => $email
|
||||||
|
];
|
||||||
|
}, $detailEmailKantor));
|
||||||
|
|
||||||
|
$detailJoinPimpinan = json_encode(array_map(function ($nama, $nomor) {
|
||||||
|
return [
|
||||||
|
'nama_pimpinan' => $nama,
|
||||||
|
'nomor_hp_pimpinan' => $nomor
|
||||||
|
];
|
||||||
|
}, $detailNamaPimpinan, $detailNomorHpPimpinan));
|
||||||
|
|
||||||
|
|
||||||
|
$detailJoinPicReviewer = json_encode(array_map(function ($nama, $nomor) {
|
||||||
|
return [
|
||||||
|
'nama_pic_reviewer' => $nama,
|
||||||
|
'nomor_hp_pic_reviewer' => $nomor
|
||||||
|
];
|
||||||
|
}, $detailNamaPicReviewer, $detailNomorHpPicReviewer));
|
||||||
|
|
||||||
|
$detailJoinPicAdmin = json_encode(array_map(function ($nama, $nomor) {
|
||||||
|
return [
|
||||||
|
'nama_pic_admin' => $nama,
|
||||||
|
'nomor_hp_pic_admin' => $nomor
|
||||||
|
];
|
||||||
|
}, $detailNamaPicAdmin, $detailNomorHpPicAdmin));
|
||||||
|
|
||||||
|
$detailJoinPicMarketing = json_encode(array_map(function ($nama, $nomor) {
|
||||||
|
return [
|
||||||
|
'nama_pic_marketing' => $nama,
|
||||||
|
'nomor_hp_pic_marketing' => $nomor
|
||||||
|
];
|
||||||
|
}, $detailNamaPicMarketing, $detailNomorHpPicMarketing));
|
||||||
|
|
||||||
|
return view('lpj::kjpp.create', compact('kjpp', 'ijin_usaha', 'jenis_aset', 'provinces', 'cities', 'districts', 'villages', 'detailJoinPicReviewer', 'detailJoinPicAdmin', 'detailJoinPicMarketing', 'detailJoinEmailKantor', 'detailJoinPimpinan'));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update the specified resource in storage.
|
||||||
|
*/
|
||||||
|
public function update(KJPPRequest $request, $id)
|
||||||
|
{
|
||||||
|
$validated = $request->validated();
|
||||||
|
|
||||||
|
// dd($validated);
|
||||||
|
|
||||||
|
if ($validated) {
|
||||||
|
$detailEmailKantor = [];
|
||||||
|
$detailNamaPimpinan = [];
|
||||||
|
$detailNomorHpPimpinan = [];
|
||||||
|
$detailNamaPicReviewer = [];
|
||||||
|
$detailNomorHpPicReviewer = [];
|
||||||
|
$detailNamaPicAdmin = [];
|
||||||
|
$detailNomorHpPicAdmin = [];
|
||||||
|
$detailNamaPicMarketing = [];
|
||||||
|
$detailNomorHpPicMarketing = [];
|
||||||
|
|
||||||
|
$emailKantor = $request->input('detail_email_kantor.email_kantor', []);
|
||||||
|
$namaPimpinan = $request->input('detail_nama_pimpinan.nama_pimpinan', []);
|
||||||
|
$nomorHpPimpinan = $request->input('detail_nomor_hp_pimpinan.nomor_hp_pimpinan', []);
|
||||||
|
$namaPicReviewer = $request->input('detail_nama_pic_reviewer.nama_pic_reviewer', []);
|
||||||
|
$nomorHpPicReviewer = $request->input('detail_nomor_hp_pic_reviewer.nomor_hp_pic_reviewer', []);
|
||||||
|
$namaPicAdmin = $request->input('detail_nama_pic_admin.nama_pic_admin', []);
|
||||||
|
$nomorHpPicAdmin = $request->input('detail_nomor_hp_pic_admin.nomor_hp_pic_admin', []);
|
||||||
|
$namaPicMarketing = $request->input('detail_nama_pic_marketing.nama_pic_marketing', []);
|
||||||
|
$nomorHpPicMarketing = $request->input('detail_nomor_hp_pic_marketing.nomor_hp_pic_marketing', []);
|
||||||
|
|
||||||
|
foreach ($emailKantor as $value) {
|
||||||
|
$detailEmailKantor[] = $value;
|
||||||
|
}
|
||||||
|
// Encode to JSON and store
|
||||||
|
$detailEmailKantorJson = json_encode($detailEmailKantor);
|
||||||
|
|
||||||
|
// Process detail_nama_pimpinan
|
||||||
|
foreach ($namaPimpinan as $value) {
|
||||||
|
$detailNamaPimpinan[] = $value;
|
||||||
|
}
|
||||||
|
$detailNamaPimpinanJson = json_encode($detailNamaPimpinan);
|
||||||
|
|
||||||
|
// Process detail_nomor_hp_pimpinan
|
||||||
|
foreach ($nomorHpPimpinan as $value) {
|
||||||
|
$detailNomorHpPimpinan[] = $value;
|
||||||
|
}
|
||||||
|
$detailNomorHpPimpinanJson = json_encode($detailNomorHpPimpinan);
|
||||||
|
|
||||||
|
// Process detail_nama_pic_reviewer
|
||||||
|
foreach ($namaPicReviewer as $value) {
|
||||||
|
$detailNamaPicReviewer[] = $value;
|
||||||
|
}
|
||||||
|
$detailNamaPicReviewerJson = json_encode($detailNamaPicReviewer);
|
||||||
|
|
||||||
|
// Process detail_nomor_hp_pic_reviewer
|
||||||
|
foreach ($nomorHpPicReviewer as $value) {
|
||||||
|
$detailNomorHpPicReviewer[] = $value;
|
||||||
|
}
|
||||||
|
$detailNomorHpPicReviewerJson = json_encode($detailNomorHpPicReviewer);
|
||||||
|
|
||||||
|
// Process detail_nama_pic_admin
|
||||||
|
foreach ($namaPicAdmin as $value) {
|
||||||
|
$detailNamaPicAdmin[] = $value;
|
||||||
|
}
|
||||||
|
$detailNamaPicAdminJson = json_encode($detailNamaPicAdmin);
|
||||||
|
|
||||||
|
// Process detail_nomor_hp_pic_admin
|
||||||
|
foreach ($nomorHpPicAdmin as $value) {
|
||||||
|
$detailNomorHpPicAdmin[] = $value;
|
||||||
|
}
|
||||||
|
$detailNomorHpPicAdminJson = json_encode($detailNomorHpPicAdmin);
|
||||||
|
|
||||||
|
// Process detail_nama_pic_marketing
|
||||||
|
foreach ($namaPicMarketing as $value) {
|
||||||
|
$detailNamaPicMarketing[] = $value;
|
||||||
|
}
|
||||||
|
$detailNamaPicMarketingJson = json_encode($detailNamaPicMarketing);
|
||||||
|
|
||||||
|
// Process detail_nomor_hp_pic_marketing
|
||||||
|
foreach ($nomorHpPicMarketing as $value) {
|
||||||
|
$detailNomorHpPicMarketing[] = $value;
|
||||||
|
}
|
||||||
|
$detailNomorHpPicMarketingJson = json_encode($detailNomorHpPicMarketing);
|
||||||
|
|
||||||
|
|
||||||
|
$file = $request->file('attachment');
|
||||||
|
$filename = $file ? time() . '.' . $file->getClientOriginalExtension() : null;
|
||||||
|
|
||||||
|
if ($file !== null) {
|
||||||
|
// Jika ada file dari database maka hapus file yang lama ke file yang baru
|
||||||
|
$kjpp = KJPP::find($id);
|
||||||
|
// Jika filenya ada default.pdf jangan dihapus
|
||||||
|
if ($kjpp->attachment !== 'default.pdf') {
|
||||||
|
Storage::delete('public/uploads_pdf/' . $kjpp->attachment);
|
||||||
|
}
|
||||||
|
// Simpan file yang diunggah
|
||||||
|
$file->storeAs('public/uploads_pdf', $filename);
|
||||||
|
$validated['attachment'] = $filename;
|
||||||
|
} else {
|
||||||
|
// Jika tidak ada file yang diunggah, gunakan file yang sudah ada atau file default
|
||||||
|
$kjpp = KJPP::find($id);
|
||||||
|
$validated['attachment'] = $kjpp->attachment ?? 'default.pdf';
|
||||||
|
}
|
||||||
|
|
||||||
|
$validated['detail_email_kantor'] = $detailEmailKantorJson;
|
||||||
|
$validated['detail_nama_pimpinan'] = $detailNamaPimpinanJson;
|
||||||
|
$validated['detail_nomor_hp_pimpinan'] = $detailNomorHpPimpinanJson;
|
||||||
|
$validated['detail_nama_pic_reviewer'] = $detailNamaPicReviewerJson;
|
||||||
|
$validated['detail_nomor_hp_pic_reviewer'] = $detailNomorHpPicReviewerJson;
|
||||||
|
$validated['detail_nama_pic_admin'] = $detailNamaPicAdminJson;
|
||||||
|
$validated['detail_nomor_hp_pic_admin'] = $detailNomorHpPicAdminJson;
|
||||||
|
$validated['detail_nama_pic_marketing'] = $detailNamaPicMarketingJson;
|
||||||
|
$validated['detail_nomor_hp_pic_marketing'] = $detailNomorHpPicMarketingJson;
|
||||||
|
$validated['ijin_usaha_id'] = json_encode($validated['ijin_usaha_id']);
|
||||||
|
if (empty($validated['jenis_aset_id'])) {
|
||||||
|
$validated['jenis_aset_id'] = json_encode([]);
|
||||||
|
} else {
|
||||||
|
$validated['jenis_aset_id'] = json_encode($validated['jenis_aset_id']);
|
||||||
|
}
|
||||||
|
// Perbarui data di database
|
||||||
|
KJPP::where('id', $id)->update($validated);
|
||||||
|
|
||||||
|
return redirect()
|
||||||
|
->route('basicdata.kjpp.index')
|
||||||
|
->with('success', 'KJPP updated successfully');
|
||||||
|
} else {
|
||||||
|
return redirect()
|
||||||
|
->route('basicdata.kjpp.edit', $id)
|
||||||
|
->with('error', 'Validation failed');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove the specified resource from storage.
|
||||||
|
*/
|
||||||
|
public function destroy($id)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
$kjpp = KJPP::find($id);
|
||||||
|
|
||||||
|
// Jangan hapus file default.pdf
|
||||||
|
if ($kjpp->attachment && $kjpp->attachment !== 'default.pdf') {
|
||||||
|
Storage::delete('public/uploads_pdf/' . $kjpp->attachment);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Hapus data dari database
|
||||||
|
$kjpp->delete();
|
||||||
|
|
||||||
|
echo json_encode(['success' => true, 'message' => 'KJPP deleted successfully']);
|
||||||
|
} catch (Throwable $e) {
|
||||||
|
echo json_encode(['success' => false, 'message' => 'Failed to delete branch: ' . $e]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function dataForDatatables(Request $request)
|
||||||
|
{
|
||||||
|
if (is_null($this->user) || !$this->user->can('kjpp.view')) {
|
||||||
|
//abort(403, 'Sorry! You are not allowed to view users.');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Retrieve data from the database order by code ascending
|
||||||
|
$query = KJPP::query()->orderBy('code', 'asc');
|
||||||
|
|
||||||
|
// Apply search filter if provided
|
||||||
|
if ($request->has('search') && !empty($request->get('search'))) {
|
||||||
|
$search = $request->get('search');
|
||||||
|
$query->where(function ($q) use ($search) {
|
||||||
|
$q->where('code', 'LIKE', "%$search%");
|
||||||
|
$q->orWhere('name', 'LIKE', "%$search%");
|
||||||
|
$q->orWhere('jenis_kantor', 'LIKE', "%$search%");
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// Apply sorting if provided
|
||||||
|
if ($request->has('sortOrder') && !empty($request->get('sortOrder'))) {
|
||||||
|
$order = $request->get('sortOrder');
|
||||||
|
$column = $request->get('sortField');
|
||||||
|
$query->orderBy($column, $order);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get the total count of records
|
||||||
|
$totalRecords = $query->count();
|
||||||
|
|
||||||
|
// Apply pagination if provided
|
||||||
|
if ($request->has('page') && $request->has('size')) {
|
||||||
|
$page = $request->get('page');
|
||||||
|
$size = $request->get('size');
|
||||||
|
$offset = ($page - 1) * $size; // Calculate the offset
|
||||||
|
|
||||||
|
$query->skip($offset)->take($size);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get the filtered count of records
|
||||||
|
$filteredRecords = $query->count();
|
||||||
|
|
||||||
|
// Get the data for the current page
|
||||||
|
$data = $query->with('city')->get();
|
||||||
|
|
||||||
|
// Calculate the page count
|
||||||
|
$pageCount = ceil($totalRecords / $request->get('size'));
|
||||||
|
|
||||||
|
// Calculate the current page number
|
||||||
|
$currentPage = 0 + 1;
|
||||||
|
|
||||||
|
// Return the response data as a JSON object
|
||||||
|
return response()->json([
|
||||||
|
'draw' => $request->get('draw'),
|
||||||
|
'recordsTotal' => $totalRecords,
|
||||||
|
'recordsFiltered' => $filteredRecords,
|
||||||
|
'pageCount' => $pageCount,
|
||||||
|
'page' => $currentPage,
|
||||||
|
'totalCount' => $totalRecords,
|
||||||
|
'data' => $data,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function export()
|
||||||
|
{
|
||||||
|
return Excel::download(new KJPPExport, 'kjpp.xlsx');
|
||||||
|
}
|
||||||
|
}
|
||||||
45
app/Http/Controllers/LampiranDokumenController.php
Normal file
45
app/Http/Controllers/LampiranDokumenController.php
Normal file
@@ -0,0 +1,45 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Modules\Lpj\Http\Controllers;
|
||||||
|
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Facades\Storage;
|
||||||
|
use Modules\Lpj\Models\LampiranDokumen;
|
||||||
|
|
||||||
|
class LampiranDokumenController extends Controller
|
||||||
|
{
|
||||||
|
public function download($id)
|
||||||
|
{
|
||||||
|
$lampiran = LampiranDokumen::findOrFail($id);
|
||||||
|
return Storage::download($lampiran->path_file, $lampiran->nama_file);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function upload(Request $request)
|
||||||
|
{
|
||||||
|
$request->validate([
|
||||||
|
'permohonan_id' => 'required|exists:permohonan,id',
|
||||||
|
'jenis_lampiran_id' => 'required|exists:jenis_lampiran,id',
|
||||||
|
'nama_file' => 'nullable|string|max:255',
|
||||||
|
'file' => 'required|file|max:10240',
|
||||||
|
'keterangan' => 'nullable|string|max:255',
|
||||||
|
]);
|
||||||
|
|
||||||
|
$lampiran = LampiranDokumen::uploadLampiran($request->all());
|
||||||
|
|
||||||
|
if ($lampiran) {
|
||||||
|
return redirect()->back()->with('success', 'Lampiran uploaded successfully');
|
||||||
|
} else {
|
||||||
|
return redirect()->back()->with('error', 'Unauthorized or upload failed');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function delete(LampiranDokumen $lampiran)
|
||||||
|
{
|
||||||
|
if ($lampiran->deleteLampiran()) {
|
||||||
|
return redirect()->back()->with('success', 'Lampiran deleted successfully');
|
||||||
|
} else {
|
||||||
|
return redirect()->back()->with('error', 'Unauthorized or delete failed');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
180
app/Http/Controllers/LaporanAdminKreditController.php
Normal file
180
app/Http/Controllers/LaporanAdminKreditController.php
Normal file
@@ -0,0 +1,180 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Modules\Lpj\Http\Controllers;
|
||||||
|
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Facades\Auth;
|
||||||
|
use Maatwebsite\Excel\Facades\Excel;
|
||||||
|
use Modules\Lpj\Exports\LaporanAdminKreditExport;
|
||||||
|
use Modules\Lpj\Models\LaporanAdminKredit;
|
||||||
|
use Modules\Lpj\Models\Permohonan;
|
||||||
|
|
||||||
|
class LaporanAdminKreditController extends Controller
|
||||||
|
{
|
||||||
|
public $user;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Display a listing of the resource.
|
||||||
|
*/
|
||||||
|
public function index()
|
||||||
|
{
|
||||||
|
$permohonan = Permohonan::where(['status' => 'done'])->get();
|
||||||
|
foreach ($permohonan as $_permohonan) {
|
||||||
|
$npw = 0;
|
||||||
|
if (isset($_permohonan->penilai->lpj)) {
|
||||||
|
$npw = json_decode($_permohonan->penilai->lpj, true);
|
||||||
|
$npw = $npw['total_nilai_pasar_wajar'] ?? 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
$dataAdk = [
|
||||||
|
'jenis_agunan' => $_permohonan->documents->pluck('jenisJaminan.name')->unique()->implode(', '),
|
||||||
|
'alamat_agunan' => $_permohonan->documents->map(function ($document) {
|
||||||
|
return formatAlamat($document);
|
||||||
|
})->unique()->implode(', '),
|
||||||
|
'nama_pemilik' => $_permohonan->documents->pluck('pemilik.name')->unique()->implode(', '),
|
||||||
|
'tanggal_kunjungan' => $_permohonan->penilaian->tanggal_kunjungan,
|
||||||
|
'nama_penilai' => $_permohonan->penilaian->_user_penilai->userPenilaiTeam->name,
|
||||||
|
'nilai_likuidasi' => $_permohonan->nilai_liquidasi,
|
||||||
|
'nilai_pasar_wajar' => str_replace('.', '', $npw),
|
||||||
|
'bukti_kepemilikan' => $_permohonan->documents->flatMap(function ($document) {
|
||||||
|
return $document->detail->map(function ($detail) {
|
||||||
|
return (!empty($detail->dokumen_nomor) && is_array($detail->dokumen_nomor))
|
||||||
|
? ($detail->jenisLegalitasJaminan->name ?? '') . "\n" . implode(', ', $detail->dokumen_nomor)
|
||||||
|
: null;
|
||||||
|
});
|
||||||
|
})->filter()->unique()->implode(', '),
|
||||||
|
];
|
||||||
|
|
||||||
|
LaporanAdminKredit::updateOrCreate([
|
||||||
|
'debiture_id' => $_permohonan->debiture_id,
|
||||||
|
], $dataAdk);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
$laporans = LaporanAdminKredit::with('debiture')->paginate(10);
|
||||||
|
return view('lpj::laporan_admin_kredit.index', compact('laporans'));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function dataForDatatables(Request $request)
|
||||||
|
{
|
||||||
|
if (is_null($this->user) || !$this->user->can('laporan-admin-kredit.view')) {
|
||||||
|
//abort(403, 'Sorry! You are not allowed to view laporan admin kredit.');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Retrieve data from the database
|
||||||
|
$query = LaporanAdminKredit::query();
|
||||||
|
|
||||||
|
if ($request->has('tanggal_awal') && $request->has('tanggal_akhir')) {
|
||||||
|
$query->whereBetween('tanggal_kunjungan', [$request->tanggal_awal, $request->tanggal_akhir]);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Apply search filter if provided
|
||||||
|
if ($request->has('search') && !empty($request->get('search'))) {
|
||||||
|
$search = $request->get('search');
|
||||||
|
$search_ = json_decode($search);
|
||||||
|
|
||||||
|
if (isset($search_->search)) {
|
||||||
|
$query->where(function ($q) use ($search_) {
|
||||||
|
$q->where('kode_register_t24', 'LIKE', '%' . $search_->search . '%')
|
||||||
|
->orWhere('jenis_agunan', 'LIKE', '%' . $search_->search . '%')
|
||||||
|
->orWhere('nama_pemilik', 'LIKE', '%' . $search_->search . '%')
|
||||||
|
->orWhereHas('debiture', function ($query) use ($search_) {
|
||||||
|
$query->where('name', 'LIKE', '%' . $search_->search . '%');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($search_->tanggal_awal) && isset($search_->tanggal_akhir)) {
|
||||||
|
$query->whereBetween('tanggal_kunjungan', [$search_->tanggal_awal, $search_->tanggal_akhir]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Apply sorting if provided
|
||||||
|
if ($request->has('sortOrder') && !empty($request->get('sortOrder'))) {
|
||||||
|
$order = $request->get('sortOrder');
|
||||||
|
$column = $request->get('sortField');
|
||||||
|
$query->orderBy($column, $order);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get the total count of records
|
||||||
|
$totalRecords = $query->count();
|
||||||
|
|
||||||
|
// Apply pagination if provided
|
||||||
|
if ($request->has('page') && $request->has('size')) {
|
||||||
|
$page = $request->get('page');
|
||||||
|
$size = $request->get('size');
|
||||||
|
$offset = ($page - 1) * $size; // Calculate the offset
|
||||||
|
|
||||||
|
$query->skip($offset)->take($size);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get the filtered count of records
|
||||||
|
$filteredRecords = $query->count();
|
||||||
|
|
||||||
|
// Get the data for the current page
|
||||||
|
$data = $query->with(['debiture.branch'])->get();
|
||||||
|
|
||||||
|
// Calculate the page count
|
||||||
|
$pageCount = ceil($totalRecords / $request->get('size'));
|
||||||
|
|
||||||
|
// Calculate the current page number
|
||||||
|
$currentPage = $request->get('page', 1);
|
||||||
|
|
||||||
|
// Return the response data as a JSON object
|
||||||
|
return response()->json([
|
||||||
|
'draw' => $request->get('draw'),
|
||||||
|
'recordsTotal' => $totalRecords,
|
||||||
|
'recordsFiltered' => $filteredRecords,
|
||||||
|
'pageCount' => $pageCount,
|
||||||
|
'page' => $currentPage,
|
||||||
|
'totalCount' => $totalRecords,
|
||||||
|
'data' => $data,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function export()
|
||||||
|
{
|
||||||
|
return Excel::download(new LaporanAdminKreditExport, 'laporan_admin_kredit.xlsx');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function edit($id)
|
||||||
|
{
|
||||||
|
$laporanAdminKredit = LaporanAdminKredit::with('debiture.branch')->find($id);
|
||||||
|
return view('lpj::laporan_admin_kredit.form', compact('laporanAdminKredit'));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function update(Request $request, $id)
|
||||||
|
{
|
||||||
|
$request->validate([
|
||||||
|
'kode_register_t24' => 'nullable',
|
||||||
|
'cif' => 'required',
|
||||||
|
]);
|
||||||
|
|
||||||
|
try {
|
||||||
|
$laporanAdminKredit = LaporanAdminKredit::find($id);
|
||||||
|
|
||||||
|
// Update only the editable fields
|
||||||
|
$laporanAdminKredit->update([
|
||||||
|
'kode_register_t24' => $request->kode_register_t24,
|
||||||
|
'updated_by' => Auth::id(),
|
||||||
|
]);
|
||||||
|
|
||||||
|
// Update CIF in the debiture table if needed
|
||||||
|
if ($laporanAdminKredit->debiture) {
|
||||||
|
$laporanAdminKredit->debiture->update([
|
||||||
|
'cif' => $request->cif,
|
||||||
|
'updated_by' => Auth::id(),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
return redirect()
|
||||||
|
->route('laporan-admin-kredit.index')
|
||||||
|
->with('success', 'Laporan Admin Kredit updated successfully');
|
||||||
|
} catch (Exception $e) {
|
||||||
|
return redirect()
|
||||||
|
->route('laporan-admin-kredit.edit', $id)
|
||||||
|
->with('error', 'Failed to update Laporan Admin Kredit');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
145
app/Http/Controllers/LaporanController.php
Normal file
145
app/Http/Controllers/LaporanController.php
Normal file
@@ -0,0 +1,145 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Modules\Lpj\Http\Controllers;
|
||||||
|
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Modules\Lpj\Models\Permohonan;
|
||||||
|
use Modules\Lpj\Http\Controllers\PenilaiController;
|
||||||
|
|
||||||
|
class LaporanController extends Controller
|
||||||
|
{
|
||||||
|
public $user;
|
||||||
|
public $penilaiController;
|
||||||
|
/**
|
||||||
|
* Display a listing of the resource.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
public function __construct(PenilaiController $penilaiController){
|
||||||
|
$this->penilaiController = $penilaiController;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function index()
|
||||||
|
{
|
||||||
|
return view('lpj::laporan.index');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function sederhana_index()
|
||||||
|
{
|
||||||
|
return view('lpj::laporan.sederhana_index');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function standard_index()
|
||||||
|
{
|
||||||
|
return view('lpj::laporan.standard_index');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show the specified resource.
|
||||||
|
*/
|
||||||
|
public function show($id) {
|
||||||
|
$permohonan = Permohonan::with([
|
||||||
|
'penilai',
|
||||||
|
'dokumenjaminan',
|
||||||
|
])->find($id);
|
||||||
|
|
||||||
|
if ($permohonan->penilai->type_penilai == 'memo') {
|
||||||
|
return $this->penilaiController->print_out($request = new Request(['documentId' => $permohonan->penilai->dokument_id, 'jaminanId' => $permohonan->dokumenjaminan[0]->jenis_jaminan_id, 'permohonanId' => $permohonan->id, 'statusLpj' => 1, 'type' => 'memo']));
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($permohonan->penilai->type_penilai == 'rap') {
|
||||||
|
return $this->penilaiController->print_out($request = new Request(['documentId' => $permohonan->penilai->dokument_id, 'jaminanId' => $permohonan->dokumenjaminan[0]->jenis_jaminan_id, 'permohonanId' => $permohonan->id, 'statusLpj' => 1, 'type' => 'rap']));
|
||||||
|
}
|
||||||
|
|
||||||
|
return view('lpj::laporan.show', compact('permohonan'));
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Store form inspeksi.
|
||||||
|
*/
|
||||||
|
public function store(Request $request) {
|
||||||
|
$permohonan = Permohonan::find($request->permohonan_id);
|
||||||
|
if($request->nilai_liquidasi) {
|
||||||
|
$permohonan->nilai_liquidasi = $request->liquidasi;
|
||||||
|
$permohonan->save();
|
||||||
|
return redirect()->route('laporan.index')->with('success', 'Nilai Liquidasi updated successfully');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function update(Request $request, $id) {}
|
||||||
|
|
||||||
|
public function dataForDatatables(Request $request)
|
||||||
|
{
|
||||||
|
if (is_null($this->user) || !$this->user->can('debitur.view')) {
|
||||||
|
//abort(403, 'Sorry! You are not allowed to view users.');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Retrieve data from the database
|
||||||
|
$query = Permohonan::query()->whereIn('status',['proses-laporan','done', 'paparan', 'proses-paparan'])->whereNotNull('approval_so_at')->whereNotNull('approval_eo_at')->where(function ($q) {
|
||||||
|
$q->whereIn('nilai_plafond_id', [1,4])
|
||||||
|
->whereNotNull('approval_dd_at')
|
||||||
|
->orWhereIn('nilai_plafond_id', [2,3]);
|
||||||
|
});
|
||||||
|
|
||||||
|
$query = $query->orderBy('nomor_registrasi', 'desc');
|
||||||
|
// Apply search filter if provided
|
||||||
|
if ($request->has('search') && !empty($request->get('search'))) {
|
||||||
|
$search = $request->get('search');
|
||||||
|
$query->where(function ($q) use ($search) {
|
||||||
|
$q->where('nomor_registrasi', 'LIKE', '%' . $search . '%');
|
||||||
|
$q->orWhere('tanggal_permohonan', 'LIKE', '%' . $search . '%');
|
||||||
|
$q->orWhereRelation('user', 'name', 'LIKE', '%' . $search . '%');
|
||||||
|
$q->orWhereRelation('debiture', 'name', 'LIKE', '%' . $search . '%');
|
||||||
|
$q->orWhereRelation('tujuanPenilaian', 'name', 'LIKE', '%' . $search . '%');
|
||||||
|
$q->orWhereRelation('branch', 'name', 'LIKE', '%' . $search . '%');
|
||||||
|
$q->orWhere('status', 'LIKE', '%' . $search . '%');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// Apply sorting if provided
|
||||||
|
if ($request->has('sortOrder') && !empty($request->get('sortOrder'))) {
|
||||||
|
$order = $request->get('sortOrder');
|
||||||
|
$column = $request->get('sortField');
|
||||||
|
$query->orderBy($column, $order);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get the total count of records
|
||||||
|
$totalRecords = $query->count();
|
||||||
|
$size = $request->get('size', 10);
|
||||||
|
if ($size == 0) {
|
||||||
|
$size = 10;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Apply pagination if provided
|
||||||
|
if ($request->has('page') && $request->has('size')) {
|
||||||
|
$page = $request->get('page');
|
||||||
|
$size = $request->get('size');
|
||||||
|
$offset = ($page - 1) * $size; // Calculate the offset
|
||||||
|
|
||||||
|
$query->skip($offset)->take($size);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get the filtered count of records
|
||||||
|
$filteredRecords = $query->count();
|
||||||
|
|
||||||
|
// Get the data for the current page
|
||||||
|
$data = $query->with(['user', 'debiture', 'branch', 'tujuanPenilaian', 'penilaian','jenisFasilitasKredit', 'documents.inspeksi','penilai','documents.detail'])->get();
|
||||||
|
|
||||||
|
// Calculate the page count
|
||||||
|
$pageCount = ceil($totalRecords / $size);
|
||||||
|
|
||||||
|
// Calculate the current page number
|
||||||
|
$currentPage = max(1, $request->get('page', 1));
|
||||||
|
|
||||||
|
// Return the response data as a JSON object
|
||||||
|
return response()->json([
|
||||||
|
'draw' => $request->get('draw'),
|
||||||
|
'recordsTotal' => $totalRecords,
|
||||||
|
'recordsFiltered' => $filteredRecords,
|
||||||
|
'pageCount' => $pageCount,
|
||||||
|
'page' => $currentPage,
|
||||||
|
'totalCount' => $totalRecords,
|
||||||
|
'data' => $data,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
173
app/Http/Controllers/LaporanExternalController.php
Normal file
173
app/Http/Controllers/LaporanExternalController.php
Normal file
@@ -0,0 +1,173 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Modules\Lpj\Http\Controllers;
|
||||||
|
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Modules\Lpj\Models\LaporanExternal;
|
||||||
|
use Modules\Lpj\Http\Requests\LaporanExternalRequest;
|
||||||
|
use Modules\Lpj\Models\Permohonan;
|
||||||
|
|
||||||
|
class LaporanExternalController extends Controller
|
||||||
|
{
|
||||||
|
public $user;
|
||||||
|
/**
|
||||||
|
* Display a listing of the resource.
|
||||||
|
*/
|
||||||
|
public function index()
|
||||||
|
{
|
||||||
|
$laporanExternals = LaporanExternal::with('permohonan')->paginate(10);
|
||||||
|
return view('lpj::laporan_external.index', compact('laporanExternals'));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show the form for creating a new resource.
|
||||||
|
*/
|
||||||
|
public function create()
|
||||||
|
{
|
||||||
|
return view('lpj::laporan_external.create');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Store a newly created resource in storage.
|
||||||
|
*/
|
||||||
|
public function store(LaporanExternalRequest $request)
|
||||||
|
{
|
||||||
|
$validatedData = $request->validated();
|
||||||
|
|
||||||
|
if ($request->hasFile('file_resume')) {
|
||||||
|
$validatedData['file_resume'] = $request->file('file_resume')->store('laporan_external/resume', 'public');
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($request->hasFile('file_laporan')) {
|
||||||
|
$validatedData['file_laporan'] = $request->file('file_laporan')->store('laporan_external/laporan', 'public');
|
||||||
|
}
|
||||||
|
|
||||||
|
LaporanExternal::create($validatedData);
|
||||||
|
|
||||||
|
return redirect()->route('laporan-external.index')->with('success', 'Laporan External berhasil ditambahkan.');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show the specified resource.
|
||||||
|
*/
|
||||||
|
public function show(LaporanExternal $laporanExternal)
|
||||||
|
{
|
||||||
|
return view('lpj::laporan_external.show', compact('laporanExternal'));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show the form for editing the specified resource.
|
||||||
|
*/
|
||||||
|
public function edit(LaporanExternal $laporanExternal)
|
||||||
|
{
|
||||||
|
$permohonan = Permohonan::find($laporanExternal->permohonan_id);
|
||||||
|
return view('lpj::laporan_external.create', compact('laporanExternal','permohonan'));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update the specified resource in storage.
|
||||||
|
*/
|
||||||
|
public function update(LaporanExternalRequest $request, LaporanExternal $laporanExternal)
|
||||||
|
{
|
||||||
|
$validatedData = $request->validated();
|
||||||
|
|
||||||
|
if ($request->hasFile('file_resume')) {
|
||||||
|
$validatedData['file_resume'] = $request->file('file_resume')->store('laporan_external/resume', 'public');
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($request->hasFile('file_laporan')) {
|
||||||
|
$validatedData['file_laporan'] = $request->file('file_laporan')->store('laporan_external/laporan', 'public');
|
||||||
|
}
|
||||||
|
|
||||||
|
$laporanExternal->update($validatedData);
|
||||||
|
|
||||||
|
return redirect()->route('laporan-external.index')->with('success', 'Laporan External berhasil diperbarui.');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove the specified resource from storage.
|
||||||
|
*/
|
||||||
|
public function destroy(LaporanExternal $laporanExternal)
|
||||||
|
{
|
||||||
|
$laporanExternal->delete();
|
||||||
|
|
||||||
|
return redirect()->route('laporan-external.index')->with('success', 'Laporan External berhasil dihapus.');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function dataForDatatables(Request $request)
|
||||||
|
{
|
||||||
|
if (is_null($this->user) || !$this->user->can('jenis_aset.view')) {
|
||||||
|
//abort(403, 'Sorry! You are not allowed to view users.');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Retrieve data from the database
|
||||||
|
$query = LaporanExternal::query();
|
||||||
|
|
||||||
|
// Apply search filter if provided
|
||||||
|
if ($request->has('search') && !empty($request->get('search'))) {
|
||||||
|
$search = $request->get('search');
|
||||||
|
$query->where(function ($q) use ($search) {
|
||||||
|
$q->where('nomor_laporan', 'LIKE', "%$search%")
|
||||||
|
->orWhere('tanggal_laporan', 'LIKE', "%$search%")
|
||||||
|
->orWhereHas('permohonan', function($q) use ($search) {
|
||||||
|
$q->where('nomor_permohonan', 'LIKE', "%$search%");
|
||||||
|
})
|
||||||
|
->orWhere('tgl_final_laporan', 'LIKE', "%$search%")
|
||||||
|
->orWhere('nilai_pasar', 'LIKE', "%$search%")
|
||||||
|
->orWhere('indikasi_nilai_likuidasi', 'LIKE', "%$search%")
|
||||||
|
->orWhere('indikasi_nilai_pasar_tanah', 'LIKE', "%$search%")
|
||||||
|
->orWhere('estimasi_harga_tanah', 'LIKE', "%$search%")
|
||||||
|
->orWhere('estimasi_harga_bangunan', 'LIKE', "%$search%")
|
||||||
|
->orWhere('indikasi_nilai_pasar_bangunan', 'LIKE', "%$search%")
|
||||||
|
->orWhere('indikasi_nilai_pasar_sarana_pelengkap', 'LIKE', "%$search%")
|
||||||
|
->orWhere('indikasi_nilai_pasar_mesin', 'LIKE', "%$search%")
|
||||||
|
->orWhere('indikasi_nilai_pasar_kendaraan_alat_berat', 'LIKE', "%$search%")
|
||||||
|
->orWhere('file_resume', 'LIKE', "%$search%")
|
||||||
|
->orWhere('file_laporan', 'LIKE', "%$search%");
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// Apply sorting if provided
|
||||||
|
if ($request->has('sortOrder') && !empty($request->get('sortOrder'))) {
|
||||||
|
$order = $request->get('sortOrder');
|
||||||
|
$column = $request->get('sortField');
|
||||||
|
$query->orderBy($column, $order);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get the total count of records
|
||||||
|
$totalRecords = $query->count();
|
||||||
|
|
||||||
|
// Apply pagination if provided
|
||||||
|
if ($request->has('page') && $request->has('size')) {
|
||||||
|
$page = $request->get('page');
|
||||||
|
$size = $request->get('size');
|
||||||
|
$offset = ($page - 1) * $size; // Calculate the offset
|
||||||
|
|
||||||
|
$query->skip($offset)->take($size);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get the filtered count of records
|
||||||
|
$filteredRecords = $query->count();
|
||||||
|
|
||||||
|
// Get the data for the current page
|
||||||
|
$data = $query->with(['permohonan.debiture','permohonan.penawaran.tujuanPenilaianKjpp','permohonan.dokumenjaminan.jenisjaminan'])->get();
|
||||||
|
|
||||||
|
// Calculate the page count
|
||||||
|
$pageCount = ceil($totalRecords / $request->get('size'));
|
||||||
|
|
||||||
|
// Calculate the current page number
|
||||||
|
$currentPage = 0 + 1;
|
||||||
|
|
||||||
|
// Return the response data as a JSON object
|
||||||
|
return response()->json([
|
||||||
|
'draw' => $request->get('draw'),
|
||||||
|
'recordsTotal' => $totalRecords,
|
||||||
|
'recordsFiltered' => $filteredRecords,
|
||||||
|
'pageCount' => $pageCount,
|
||||||
|
'page' => $currentPage,
|
||||||
|
'totalCount' => $totalRecords,
|
||||||
|
'data' => $data,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,211 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Modules\Lpj\Http\Controllers;
|
||||||
|
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Maatwebsite\Excel\Facades\Excel;
|
||||||
|
use Modules\Lpj\Exports\LaporanHasilPenilaianJaminanInternalExternalExport;
|
||||||
|
use Modules\Lpj\Models\Permohonan;
|
||||||
|
|
||||||
|
class LaporanHasilPenilaianJaminanInternalExternalController extends Controller
|
||||||
|
{
|
||||||
|
public $user;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Display a listing of the resource.
|
||||||
|
*/
|
||||||
|
public function index()
|
||||||
|
{
|
||||||
|
return view('lpj::laporan_hasil_penilaian_jaminan_internal_external.index');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function dataForDatatables(Request $request)
|
||||||
|
{
|
||||||
|
if (is_null($this->user) || !$this->user->can('laporan-admin-kredit.view')) {
|
||||||
|
//abort(403, 'Sorry! You are not allowed to view laporan admin kredit.');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Retrieve data from the database
|
||||||
|
$query = Permohonan::query();
|
||||||
|
$query = $query->where('status', 'done');
|
||||||
|
|
||||||
|
// Apply search filter if provided
|
||||||
|
if ($request->has('search') && !empty($request->get('search'))) {
|
||||||
|
$search = json_decode($request->get('search'));
|
||||||
|
|
||||||
|
if (isset($search->start_date) || isset($search->end_date)) {
|
||||||
|
$query->whereBetween('tanggal_permohonan', [
|
||||||
|
$search->start_date ?? '1900-01-01',
|
||||||
|
$search->end_date ?? now()->toDateString()
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Filter by branch if provided
|
||||||
|
if (isset($search->branch_id) && !empty($search->branch_id)) {
|
||||||
|
$query->where('branch_id', $search->branch_id);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($search->penilai_id) && !empty($search->penilai_id)) {
|
||||||
|
$query->whereHas('penilaian._user_penilai.userPenilaiTeam', function ($q) use ($search) {
|
||||||
|
$q->where('user_id', $search->penilai_id);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($search->search)) {
|
||||||
|
|
||||||
|
$query->where(function ($q) use ($search) {
|
||||||
|
$q->where('nomor_registrasi', 'LIKE', '%' . $search->search . '%');
|
||||||
|
$q->orWhere('tanggal_permohonan', 'LIKE', '%' . $search->search . '%');
|
||||||
|
$q->orWhereRelation('user', 'name', 'LIKE', '%' . $search->search . '%');
|
||||||
|
$q->orWhereRelation('tujuanPenilaian', 'name', 'LIKE', '%' . $search->search . '%');
|
||||||
|
$q->orWhereRelation('branch', 'name', 'LIKE', '%' . $search->search . '%');
|
||||||
|
$q->orWhereRelation('jenisFasilitasKredit', 'name', 'LIKE', '%' . $search->search . '%');
|
||||||
|
$q->orWhereRelation('jenisPenilaian', 'name', 'LIKE', '%' . $search->search . '%');
|
||||||
|
$q->orWhere('status', 'LIKE', '%' . $search->search . '%');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Apply sorting if provided
|
||||||
|
if ($request->has('sortOrder') && !empty($request->get('sortOrder'))) {
|
||||||
|
$order = $request->get('sortOrder');
|
||||||
|
$column = $request->get('sortField');
|
||||||
|
$query->orderBy($column, $order);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get the total count of records
|
||||||
|
$totalRecords = $query->count();
|
||||||
|
|
||||||
|
// Apply pagination if provided
|
||||||
|
if ($request->has('page') && $request->has('size')) {
|
||||||
|
$page = $request->get('page');
|
||||||
|
$size = $request->get('size');
|
||||||
|
$offset = ($page - 1) * $size; // Calculate the offset
|
||||||
|
|
||||||
|
$query->skip($offset)->take($size);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get the filtered count of records
|
||||||
|
$filteredRecords = $query->count();
|
||||||
|
|
||||||
|
// Get the data for the current page
|
||||||
|
$data = $query->with(['debiture.branch'])->get();
|
||||||
|
|
||||||
|
$data = $data->map(function ($permohonan) {
|
||||||
|
$luas_tanah = 0;
|
||||||
|
$luas_bangunan = 0;
|
||||||
|
$nilai_tanah = 0;
|
||||||
|
$nilai_bangunan = 0;
|
||||||
|
$npw = 0;
|
||||||
|
$nilai_liquidasi = 0;
|
||||||
|
|
||||||
|
if (isset($permohonan->penilai->lpj)) {
|
||||||
|
$lpj = json_decode($permohonan->penilai->lpj, true);
|
||||||
|
$npw = str_replace('.', '', $lpj['total_nilai_pasar_wajar'] ?? 0);
|
||||||
|
|
||||||
|
$luas_tanah = $lpj['luas_tanah'] ?? 0;
|
||||||
|
$luas_bangunan = $lpj['luas_bangunan'] ?? 0;
|
||||||
|
// Calculate nilai_tanah dynamically by looking for all keys that start with 'nilai_tanah_'
|
||||||
|
$nilai_tanah = str_replace('.', '', $lpj['nilai_tanah_2'] ?? 0);
|
||||||
|
|
||||||
|
$nilai_bangunan = str_replace('.', '', $lpj['nilai_bangunan_2'] ?? 0);
|
||||||
|
$nilai_liquidasi = str_replace('.', '', $lpj['likuidasi_nilai_2'] ?? 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
return [
|
||||||
|
'id' => $permohonan->id,
|
||||||
|
'nomor_registrasi' => $permohonan->nomor_registrasi,
|
||||||
|
'jenis_penilaian' => $permohonan->jenisPenilaian?->name,
|
||||||
|
'tujuan_penilaian' => $permohonan->tujuanPenilaian?->name,
|
||||||
|
'jenis_fasilitas_kredit' => $permohonan->jenisFasilitasKredit?->name,
|
||||||
|
'branch' => $permohonan->debiture->branch?->name,
|
||||||
|
'pemohon' => $permohonan->creator?->name,
|
||||||
|
'cif' => $permohonan->debiture->cif,
|
||||||
|
'name' => $permohonan->debiture?->name,
|
||||||
|
'jenis_agunan' => $permohonan->documents?->pluck('jenisJaminan.name')
|
||||||
|
->unique()
|
||||||
|
->implode(', '),
|
||||||
|
'alamat_agunan' => $permohonan->documents?->map(function ($document) {
|
||||||
|
return formatAlamat($document);
|
||||||
|
})->unique()->implode(', '),
|
||||||
|
'bukti_kepemilikan' => (function() use ($permohonan) {
|
||||||
|
$legalitasItems = $permohonan->documents?->flatMap(function ($document) {
|
||||||
|
return $document->detail->map(function ($detail) {
|
||||||
|
// Jika tidak ada jenis legalitas jaminan, lewati
|
||||||
|
if (empty($detail->jenisLegalitasJaminan)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Hanya tampilkan detail yang memiliki dokumen_jaminan
|
||||||
|
if (empty($detail->dokumen_jaminan)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Tampilkan nama legalitas jaminan saja
|
||||||
|
return $detail->jenisLegalitasJaminan->name ?? '';
|
||||||
|
});
|
||||||
|
})->filter()->unique()->values()->toArray();
|
||||||
|
|
||||||
|
// Buat daftar bernomor
|
||||||
|
$result = '';
|
||||||
|
foreach ($legalitasItems as $index => $item) {
|
||||||
|
$result .= ($index + 1) . '. ' . $item . "\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
return $result;
|
||||||
|
})(),
|
||||||
|
'nama_pemilik' => $permohonan->documents?->pluck('pemilik.name')
|
||||||
|
->unique()
|
||||||
|
->implode(', '),
|
||||||
|
'luas_tanah' => $luas_tanah . ' m²',
|
||||||
|
'nilai_tanah' => formatRupiah($nilai_tanah, 2),
|
||||||
|
'luas_bangunan' => $luas_bangunan . ' m²',
|
||||||
|
'nilai_bangunan' => formatRupiah($nilai_bangunan, 2),
|
||||||
|
'nilai_njop' => formatRupiah($permohonan->nilai_njop, 2),
|
||||||
|
'nilai_pasar_wajar' => formatRupiah($npw, 2),
|
||||||
|
'nilai_likuidasi' => formatRupiah($nilai_liquidasi, 2),
|
||||||
|
'tanggal_documen_diterima' => $permohonan->documents?->map(function ($document) {
|
||||||
|
return $document->created_at->format('d-m-Y');
|
||||||
|
}),
|
||||||
|
'tanggal_spk' => '',
|
||||||
|
'nomor_spk' => '',
|
||||||
|
'tanggal_rencana_kunjunagn' => '',
|
||||||
|
'tanggal_kunjungan' => '',
|
||||||
|
'taggal_delivered' => '',
|
||||||
|
'jangka_waktu_sla' => '',
|
||||||
|
'nama_penilai' => $permohonan->penilaian?->_user_penilai?->userPenilaiTeam?->name,
|
||||||
|
'nama_team_leader' => $permohonan->penilaian?->teams,
|
||||||
|
'saran' => '',
|
||||||
|
'catatan' => '',
|
||||||
|
|
||||||
|
|
||||||
|
'tanggal_permohonan' => $permohonan->tanggal_permohonan,
|
||||||
|
'tanggal_laporan' => $permohonan->approval_dd_at ?? $permohonan->approval_eo_at ?? '',
|
||||||
|
'tanggal_review' => $permohonan->penilaian?->tanggal_kunjungan ?? '',
|
||||||
|
];
|
||||||
|
});
|
||||||
|
|
||||||
|
// Calculate the page count
|
||||||
|
$pageCount = ceil($totalRecords / $request->get('size'));
|
||||||
|
|
||||||
|
// Calculate the current page number
|
||||||
|
$currentPage = $request->get('page', 1);
|
||||||
|
|
||||||
|
// Return the response data as a JSON object
|
||||||
|
return response()->json([
|
||||||
|
'draw' => $request->get('draw'),
|
||||||
|
'recordsTotal' => $totalRecords,
|
||||||
|
'recordsFiltered' => $filteredRecords,
|
||||||
|
'pageCount' => $pageCount,
|
||||||
|
'page' => $currentPage,
|
||||||
|
'totalCount' => $totalRecords,
|
||||||
|
'data' => $data,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function export(Request $request)
|
||||||
|
{
|
||||||
|
return Excel::download(new LaporanHasilPenilaianJaminanInternalExternalExport($request), 'laporan_hasil_penilaian_jaminan_internal_external.xlsx');
|
||||||
|
}
|
||||||
|
}
|
||||||
140
app/Http/Controllers/LaporanPembatalanController.php
Normal file
140
app/Http/Controllers/LaporanPembatalanController.php
Normal file
@@ -0,0 +1,140 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Modules\Lpj\Http\Controllers;
|
||||||
|
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Facades\Auth;
|
||||||
|
use Illuminate\Support\Facades\DB;
|
||||||
|
use Maatwebsite\Excel\Facades\Excel;
|
||||||
|
use Modules\Lpj\Exports\LaporanPembatalanExport;
|
||||||
|
use Modules\Lpj\Models\PermohonanPembatalan;
|
||||||
|
|
||||||
|
class LaporanPembatalanController extends Controller
|
||||||
|
{
|
||||||
|
public $user;
|
||||||
|
|
||||||
|
public function index()
|
||||||
|
{
|
||||||
|
return view('lpj::laporan_pembatalan.index');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function export(Request $request)
|
||||||
|
{
|
||||||
|
return Excel::download(new LaporanPembatalanExport($request), 'laporan_pembatalan.xlsx');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function dataForDatatables(Request $request)
|
||||||
|
{
|
||||||
|
if (is_null($this->user) || !$this->user->can('debitur.view')) {
|
||||||
|
//abort(403, 'Sorry! You are not allowed to view users.');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Retrieve data from the database
|
||||||
|
$query = PermohonanPembatalan::query();
|
||||||
|
|
||||||
|
|
||||||
|
if (!Auth::user()->hasAnyRole(['administrator'])) {
|
||||||
|
$query = $query->whereHas('permohonan', function ($q) {
|
||||||
|
$q->where('branch_id', Auth::user()->branch_id);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
$query = $query->orderBy('created_at', 'desc');
|
||||||
|
|
||||||
|
// Apply search filter if provided
|
||||||
|
if ($request->has('search') && !empty($request->get('search'))) {
|
||||||
|
$search = json_decode($request->get('search'));
|
||||||
|
|
||||||
|
if (isset($search->start_date) || isset($search->end_date)) {
|
||||||
|
$query->whereBetween('created_at', [
|
||||||
|
$search->start_date ?? '1900-01-01',
|
||||||
|
$search->end_date ?? now()->toDateString()
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Filter by branch if provided
|
||||||
|
if (isset($search->branch_id) && !empty($search->branch_id)) {
|
||||||
|
$query->whereHas('permohonan', function ($q) use ($search) {
|
||||||
|
$q->where('branch_id', $search->branch_id);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($search->search)) {
|
||||||
|
$query->where(function ($q) use ($search) {
|
||||||
|
$q->whereHas('permohonan', function ($subq) use ($search) {
|
||||||
|
$subq->where('nomor_registrasi', 'LIKE', '%' . $search->search . '%');
|
||||||
|
$subq->orWhereRelation('user', 'name', 'LIKE', '%' . $search->search . '%');
|
||||||
|
$subq->orWhereRelation('branch', 'name', 'LIKE', '%' . $search->search . '%');
|
||||||
|
});
|
||||||
|
$q->orWhere('alasan_pembatalan', 'LIKE', '%' . $search->search . '%');
|
||||||
|
$q->orWhere('status', 'LIKE', '%' . $search->search . '%');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Apply sorting if provided
|
||||||
|
if ($request->has('sortOrder') && !empty($request->get('sortOrder'))) {
|
||||||
|
$order = $request->get('sortOrder');
|
||||||
|
$column = $request->get('sortField');
|
||||||
|
$query->orderBy($column, $order);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get the total count of records
|
||||||
|
$totalRecords = $query->count();
|
||||||
|
$size = $request->get('size', 10);
|
||||||
|
if ($size == 0) {
|
||||||
|
$size = 10;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Apply pagination if provided
|
||||||
|
if ($request->has('page') && $request->has('size')) {
|
||||||
|
$page = $request->get('page');
|
||||||
|
$size = $request->get('size');
|
||||||
|
$offset = ($page - 1) * $size; // Calculate the offset
|
||||||
|
|
||||||
|
$query->skip($offset)->take($size);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get the filtered count of records
|
||||||
|
$filteredRecords = $query->count();
|
||||||
|
|
||||||
|
// Get the data for the current page
|
||||||
|
$data = $query->get();
|
||||||
|
|
||||||
|
$data = $data->map(function ($item) {
|
||||||
|
return [
|
||||||
|
'id' => $item->id,
|
||||||
|
'nomor_registrasi' => $item->permohonan->nomor_registrasi ?? '-',
|
||||||
|
'tanggal_permohonan' => $item->permohonan->tanggal_permohonan ? date('d-m-Y', strtotime($item->permohonan->tanggal_permohonan)) : '-',
|
||||||
|
'tanggal_pembatalan' => date('d-m-Y', strtotime($item->created_at)),
|
||||||
|
'cabang' => $item->permohonan->branch->name ?? '-',
|
||||||
|
'pemohon' => $item->permohonan->user->name ?? '-',
|
||||||
|
'debitur' => $item->permohonan->debiture->name ?? '-',
|
||||||
|
'alasan_pembatalan' => $item->alasan_pembatalan,
|
||||||
|
'status' => $item->status,
|
||||||
|
'diajukan_oleh' => $item->user->name ?? '-',
|
||||||
|
'disetujui_oleh' => $item->authorized_by ? $item->authorizedUser->name : '-',
|
||||||
|
'tanggal_disetujui' => $item->authorized_at ? formatTanggalIndonesia(strtotime($item->authorized_at),1) : '-'
|
||||||
|
];
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
// Calculate the page count
|
||||||
|
$pageCount = ceil($totalRecords / $size);
|
||||||
|
|
||||||
|
// Calculate the current page number
|
||||||
|
$currentPage = max(1, $request->get('page', 1));
|
||||||
|
|
||||||
|
// Return the response data as a JSON object
|
||||||
|
return response()->json([
|
||||||
|
'draw' => $request->get('draw'),
|
||||||
|
'recordsTotal' => $totalRecords,
|
||||||
|
'recordsFiltered' => $filteredRecords,
|
||||||
|
'pageCount' => $pageCount,
|
||||||
|
'page' => $currentPage,
|
||||||
|
'totalCount' => $totalRecords,
|
||||||
|
'data' => $data,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
200
app/Http/Controllers/LaporanPenilaiJaminanController.php
Normal file
200
app/Http/Controllers/LaporanPenilaiJaminanController.php
Normal file
@@ -0,0 +1,200 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Modules\Lpj\Http\Controllers;
|
||||||
|
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Facades\DB;
|
||||||
|
use Modules\Lpj\Models\Permohonan;
|
||||||
|
use Modules\Lpj\Models\TeamsUsers;
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use Maatwebsite\Excel\Facades\Excel;
|
||||||
|
use Modules\Lpj\Models\StatusPermohonan;
|
||||||
|
use Modules\Lpj\Exports\LaporanPenilaiJaminanExport;
|
||||||
|
|
||||||
|
class LaporanPenilaiJaminanController extends Controller
|
||||||
|
{
|
||||||
|
public $user;
|
||||||
|
/**
|
||||||
|
* Display a listing of the resource.
|
||||||
|
*/
|
||||||
|
public function index()
|
||||||
|
{
|
||||||
|
$status_permohonan = StatusPermohonan::all();
|
||||||
|
return view('lpj::laporan-penilai-jaminan.index', compact('status_permohonan'));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show the form for creating a new resource.
|
||||||
|
*/
|
||||||
|
public function create()
|
||||||
|
{
|
||||||
|
return view('lpj::create');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Store a newly created resource in storage.
|
||||||
|
*/
|
||||||
|
public function store(Request $request)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show the specified resource.
|
||||||
|
*/
|
||||||
|
public function show($id)
|
||||||
|
{
|
||||||
|
return view('lpj::laporan-penilai-jaminan.show');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show the form for editing the specified resource.
|
||||||
|
*/
|
||||||
|
public function edit($id)
|
||||||
|
{
|
||||||
|
return view('lpj::edit');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update the specified resource in storage.
|
||||||
|
*/
|
||||||
|
public function update(Request $request, $id)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove the specified resource from storage.
|
||||||
|
*/
|
||||||
|
public function destroy($id)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
}
|
||||||
|
|
||||||
|
public function dataForDatatables(Request $request)
|
||||||
|
{
|
||||||
|
|
||||||
|
$user = auth()->user();
|
||||||
|
|
||||||
|
|
||||||
|
// Check permissions
|
||||||
|
if (is_null($this->user) || !$this->user->can('debitur.view')) {
|
||||||
|
// abort(403, 'Sorry! You are not allowed to view users.');
|
||||||
|
}
|
||||||
|
|
||||||
|
$userRole = $user->roles->pluck('name')->first();
|
||||||
|
$regionId = null;
|
||||||
|
|
||||||
|
// If user is senior-officer, get their regionId
|
||||||
|
if ($userRole === 'senior-officer') {
|
||||||
|
$userTeam = TeamsUsers::with('team')->firstWhere('user_id', $user->id);
|
||||||
|
$regionId = $userTeam?->team->regions_id;
|
||||||
|
}
|
||||||
|
$paramsSearch = null;
|
||||||
|
// dd($startDate);
|
||||||
|
// Retrieve data from the database
|
||||||
|
$query = Permohonan::query();
|
||||||
|
|
||||||
|
// Apply search filter if provided
|
||||||
|
if ($request->has('search') && !empty($request->get('search'))) {
|
||||||
|
$search = $request->get('search');
|
||||||
|
$paramsSearch = json_decode($search);
|
||||||
|
|
||||||
|
$query->where(function ($q) use ($search) {
|
||||||
|
$q->where('nomor_registrasi', 'LIKE', '%' . $search . '%')
|
||||||
|
->orWhere('tanggal_permohonan', 'LIKE', '%' . $search . '%')
|
||||||
|
->orWhereRelation('user', 'name', 'LIKE', '%' . $search . '%')
|
||||||
|
->orWhereRelation('debiture', 'name', 'LIKE', '%' . $search . '%')
|
||||||
|
->orWhereRelation('tujuanPenilaian', 'name', 'LIKE', '%' . $search . '%')
|
||||||
|
->orWhereRelation('branch', 'name', 'LIKE', '%' . $search . '%');
|
||||||
|
|
||||||
|
if (!empty($paramsSearch->tanggal_awal) && !empty($paramsSearch->tanggal_akhir)) {
|
||||||
|
$q->whereBetween('tanggal_permohonan', [$paramsSearch->tanggal_awal, $paramsSearch->tanggal_akhir]);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
$statusKeywords = explode(',', $search);
|
||||||
|
foreach ($statusKeywords as $keyword) {
|
||||||
|
$q->orWhereRelation('penilai', 'type_penilai', 'LIKE', '%' . trim($keyword) . '%');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
$query->where('status', 'done');
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// Default sorting if no sort provided
|
||||||
|
if ($request->has('sortOrder') && !empty($request->get('sortOrder'))) {
|
||||||
|
$order = $request->get('sortOrder');
|
||||||
|
$column = $request->get('sortField');
|
||||||
|
$query->orderBy($column, $order);
|
||||||
|
} else {
|
||||||
|
$query->orderBy('nomor_registrasi', 'asc');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get total count of records before pagination
|
||||||
|
$totalRecords = $query->count();
|
||||||
|
|
||||||
|
// Pagination
|
||||||
|
if ($request->has('page') && $request->has('size')) {
|
||||||
|
$page = (int) $request->get('page', 1);
|
||||||
|
$size = (int) $request->get('size', 10);
|
||||||
|
$offset = ($page - 1) * $size;
|
||||||
|
$query->skip($offset)->take($size);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get filtered count
|
||||||
|
$filteredRecords = $query->count();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
$totalRecords = $query->count();
|
||||||
|
|
||||||
|
// Pagination
|
||||||
|
if ($request->has('page') && $request->has('size')) {
|
||||||
|
$page = (int) $request->get('page', 1);
|
||||||
|
$size = (int) $request->get('size', 10);
|
||||||
|
$offset = ($page - 1) * $size;
|
||||||
|
$query->skip($offset)->take($size);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get filtered count
|
||||||
|
$filteredRecords = $query->count();
|
||||||
|
|
||||||
|
// Get data with necessary relationships
|
||||||
|
$data = $query->with(['user', 'debiture', 'branch', 'tujuanPenilaian', 'penilaian', 'dokumenjaminan.jenisJaminan', 'nilaiPlafond', 'penilai'])->get();
|
||||||
|
|
||||||
|
// Calculate total pages
|
||||||
|
$pageCount = ceil($totalRecords / $request->get('size', 10));
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// Calculate total pages
|
||||||
|
$pageCount = ceil($totalRecords / $request->get('size', 10));
|
||||||
|
|
||||||
|
return response()->json([
|
||||||
|
'draw' => $request->get('draw'),
|
||||||
|
'recordsTotal' => $totalRecords,
|
||||||
|
'recordsFiltered' => $filteredRecords,
|
||||||
|
'pageCount' => $pageCount,
|
||||||
|
'page' => $request->get('page', 1),
|
||||||
|
'totalCount' => $totalRecords,
|
||||||
|
'data' => $data,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function export(Request $request)
|
||||||
|
{
|
||||||
|
$tanggalAwal = $request->input('tanggal_awal');
|
||||||
|
$tanggalAkhir = $request->input('tanggal_akhir');
|
||||||
|
$status = $request->input('status');
|
||||||
|
$selectedIds = $request->input('selected_ids');
|
||||||
|
|
||||||
|
$filename = 'laporan_penilai_jaminan_' . date('YmdHis') . '.xlsx';
|
||||||
|
return Excel::download(
|
||||||
|
new LaporanPenilaiJaminanExport($tanggalAwal, $tanggalAkhir, $status, $selectedIds),
|
||||||
|
$filename
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
161
app/Http/Controllers/LaporanPenilaianJaminanController.php
Normal file
161
app/Http/Controllers/LaporanPenilaianJaminanController.php
Normal file
@@ -0,0 +1,161 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Modules\Lpj\Http\Controllers;
|
||||||
|
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Modules\Lpj\Exports\LaporanPenilaianJaminanExport;
|
||||||
|
use Modules\Lpj\Models\Permohonan;
|
||||||
|
use Maatwebsite\Excel\Facades\Excel;
|
||||||
|
|
||||||
|
class LaporanPenilaianJaminanController extends Controller
|
||||||
|
{
|
||||||
|
public $user;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Display a listing of the resource.
|
||||||
|
*/
|
||||||
|
public function index()
|
||||||
|
{
|
||||||
|
return view('lpj::laporan_penilaian_jaminan.index');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function dataForDatatables(Request $request)
|
||||||
|
{
|
||||||
|
if (is_null($this->user) || !$this->user->can('laporan-admin-kredit.view')) {
|
||||||
|
//abort(403, 'Sorry! You are not allowed to view laporan admin kredit.');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Retrieve data from the database
|
||||||
|
$query = Permohonan::query();
|
||||||
|
$query = $query->where('status', 'done');
|
||||||
|
|
||||||
|
// Apply search filter if provided
|
||||||
|
if ($request->has('search') && !empty($request->get('search'))) {
|
||||||
|
$search = json_decode($request->get('search'));
|
||||||
|
|
||||||
|
if (isset($search->start_date) || isset($search->end_date)) {
|
||||||
|
$query->whereBetween('tanggal_permohonan', [
|
||||||
|
$search->start_date ?? '1900-01-01',
|
||||||
|
$search->end_date ?? now()->toDateString()
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Filter by branch if provided
|
||||||
|
if (isset($search->branch_id) && !empty($search->branch_id)) {
|
||||||
|
$query->where('branch_id', $search->branch_id);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($search->penilai_id) && !empty($search->penilai_id)) {
|
||||||
|
$query->whereHas('penilaian._user_penilai.userPenilaiTeam', function($q) use ($search) {
|
||||||
|
$q->where('user_id', $search->penilai_id);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($search->search)) {
|
||||||
|
|
||||||
|
$query->where(function ($q) use ($search) {
|
||||||
|
$q->where('nomor_registrasi', 'LIKE', '%' . $search->search . '%');
|
||||||
|
$q->orWhere('tanggal_permohonan', 'LIKE', '%' . $search->search . '%');
|
||||||
|
$q->orWhereRelation('user', 'name', 'LIKE', '%' . $search->search . '%');
|
||||||
|
$q->orWhereRelation('tujuanPenilaian', 'name', 'LIKE', '%' . $search->search . '%');
|
||||||
|
$q->orWhereRelation('branch', 'name', 'LIKE', '%' . $search->search . '%');
|
||||||
|
$q->orWhereRelation('jenisFasilitasKredit', 'name', 'LIKE', '%' . $search->search . '%');
|
||||||
|
$q->orWhereRelation('jenisPenilaian', 'name', 'LIKE', '%' . $search->search . '%');
|
||||||
|
$q->orWhere('status', 'LIKE', '%' . $search->search . '%');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Apply sorting if provided
|
||||||
|
if ($request->has('sortOrder') && !empty($request->get('sortOrder'))) {
|
||||||
|
$order = $request->get('sortOrder');
|
||||||
|
$column = $request->get('sortField');
|
||||||
|
$query->orderBy($column, $order);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get the total count of records
|
||||||
|
$totalRecords = $query->count();
|
||||||
|
|
||||||
|
// Apply pagination if provided
|
||||||
|
if ($request->has('page') && $request->has('size')) {
|
||||||
|
$page = $request->get('page');
|
||||||
|
$size = $request->get('size');
|
||||||
|
$offset = ($page - 1) * $size; // Calculate the offset
|
||||||
|
|
||||||
|
$query->skip($offset)->take($size);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get the filtered count of records
|
||||||
|
$filteredRecords = $query->count();
|
||||||
|
|
||||||
|
// Get the data for the current page
|
||||||
|
$data = $query->with(['debiture.branch'])->get();
|
||||||
|
|
||||||
|
$data = $data->map(function ($permohonan) {
|
||||||
|
$luas_tanah = 0;
|
||||||
|
$luas_bangunan = 0;
|
||||||
|
$nilai_tanah = 0;
|
||||||
|
$nilai_bangunan = 0;
|
||||||
|
$npw = 0;
|
||||||
|
$nilai_liquidasi = 0;
|
||||||
|
if (isset($permohonan->penilai->lpj)) {
|
||||||
|
$lpj = json_decode($permohonan->penilai->lpj, true);
|
||||||
|
$npw = str_replace('.', '', $lpj['total_nilai_pasar_wajar'] ?? 0);
|
||||||
|
|
||||||
|
$luas_tanah = $lpj['luas_tanah'] ?? 0;
|
||||||
|
$luas_bangunan = $lpj['luas_bangunan'] ?? 0;
|
||||||
|
// Calculate nilai_tanah dynamically by looking for all keys that start with 'nilai_tanah_'
|
||||||
|
$nilai_tanah = str_replace('.', '', $lpj['nilai_tanah_2'] ?? 0);
|
||||||
|
|
||||||
|
$nilai_bangunan = str_replace('.', '', $lpj['nilai_bangunan_2'] ?? 0);
|
||||||
|
$nilai_liquidasi = str_replace('.', '', $lpj['likuidasi_nilai_2'] ?? 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
return [
|
||||||
|
'id' => $permohonan->id,
|
||||||
|
'nomor_registrasi' => $permohonan->nomor_registrasi,
|
||||||
|
'tanggal_permohonan' => $permohonan->tanggal_permohonan,
|
||||||
|
'branch' => $permohonan->debiture?->branch?->name,
|
||||||
|
'name' => $permohonan->debiture?->name,
|
||||||
|
'pemohon' => $permohonan->creator?->name,
|
||||||
|
'tujuan_penilaian' => $permohonan->tujuanPenilaian?->name,
|
||||||
|
'jenis_agunan' => $permohonan->documents?->pluck('jenisJaminan.name')->unique()->implode(', '),
|
||||||
|
'alamat_agunan' => $permohonan->documents?->map(function ($document) {
|
||||||
|
return formatAlamat($document);
|
||||||
|
})->unique()->implode(', '),
|
||||||
|
'luas_tanah' => $luas_tanah . ' m²',
|
||||||
|
'nilai_tanah' => formatRupiah($nilai_tanah,2),
|
||||||
|
'luas_bangunan' => $luas_bangunan . ' m²',
|
||||||
|
'nilai_bangunan' => formatRupiah($nilai_bangunan,2),
|
||||||
|
'tanggal_laporan' => $permohonan->approval_dd_at ?? $permohonan->approval_eo_at ?? '',
|
||||||
|
'tanggal_review' => $permohonan->penilaian?->tanggal_kunjungan ?? '',
|
||||||
|
'nilai_pasar_wajar' => formatRupiah($npw,2),
|
||||||
|
'nilai_likuidasi' => formatRupiah($nilai_liquidasi,2),
|
||||||
|
'nama_penilai' => $permohonan->penilaian?->_user_penilai?->userPenilaiTeam?->name,
|
||||||
|
];
|
||||||
|
});
|
||||||
|
|
||||||
|
// Calculate the page count
|
||||||
|
$pageCount = ceil($totalRecords / $request->get('size'));
|
||||||
|
|
||||||
|
// Calculate the current page number
|
||||||
|
$currentPage = $request->get('page', 1);
|
||||||
|
|
||||||
|
// Return the response data as a JSON object
|
||||||
|
return response()->json([
|
||||||
|
'draw' => $request->get('draw'),
|
||||||
|
'recordsTotal' => $totalRecords,
|
||||||
|
'recordsFiltered' => $filteredRecords,
|
||||||
|
'pageCount' => $pageCount,
|
||||||
|
'page' => $currentPage,
|
||||||
|
'totalCount' => $totalRecords,
|
||||||
|
'data' => $data,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function export(Request $request)
|
||||||
|
{
|
||||||
|
return Excel::download(new LaporanPenilaianJaminanExport($request), 'laporan_penilaian_jaminan.xlsx');
|
||||||
|
}
|
||||||
|
}
|
||||||
124
app/Http/Controllers/LaporanPermohonanController.php
Normal file
124
app/Http/Controllers/LaporanPermohonanController.php
Normal file
@@ -0,0 +1,124 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Modules\Lpj\Http\Controllers;
|
||||||
|
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Facades\DB;
|
||||||
|
use Modules\Lpj\Models\Permohonan;
|
||||||
|
use Modules\Lpj\Models\StatusPermohonan;
|
||||||
|
use Modules\Lpj\Exports\LaporanPermohonanExport;
|
||||||
|
use Maatwebsite\Excel\Facades\Excel;
|
||||||
|
use Illuminate\Support\Facades\Auth;
|
||||||
|
|
||||||
|
class LaporanPermohonanController extends Controller
|
||||||
|
{
|
||||||
|
public $user;
|
||||||
|
public function index()
|
||||||
|
{
|
||||||
|
return view('lpj::laporan_permohonan.index');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function export(Request $request)
|
||||||
|
{
|
||||||
|
return Excel::download(new LaporanPermohonanExport($request), 'laporan_permohonan.xlsx');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function dataForDatatables(Request $request)
|
||||||
|
{
|
||||||
|
if (is_null($this->user) || !$this->user->can('debitur.view')) {
|
||||||
|
//abort(403, 'Sorry! You are not allowed to view users.');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Retrieve data from the database
|
||||||
|
$query = Permohonan::query();
|
||||||
|
|
||||||
|
if (!Auth::user()->hasAnyRole(['administrator'])) {
|
||||||
|
$query = $query->where('branch_id', Auth::user()->branch_id);
|
||||||
|
}
|
||||||
|
|
||||||
|
$query = $query->orderBy('nomor_registrasi', 'desc');
|
||||||
|
|
||||||
|
// Apply search filter if provided
|
||||||
|
if ($request->has('search') && !empty($request->get('search'))) {
|
||||||
|
$search = json_decode($request->get('search'));
|
||||||
|
|
||||||
|
if (isset($search->start_date) || isset($search->end_date)) {
|
||||||
|
$query->whereBetween('tanggal_permohonan', [
|
||||||
|
$search->start_date ?? '1900-01-01',
|
||||||
|
$search->end_date ?? now()->toDateString()
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Filter by status if provided
|
||||||
|
if (isset($search->status) && !empty($search->status)) {
|
||||||
|
$query->where('status', $search->status);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Filter by branch if provided
|
||||||
|
if (isset($search->branch_id) && !empty($search->branch_id)) {
|
||||||
|
$query->where('branch_id', $search->branch_id);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(isset($search->search)) {
|
||||||
|
|
||||||
|
$query->where(function ($q) use ($search) {
|
||||||
|
$q->where('nomor_registrasi', 'LIKE', '%' . $search->search . '%');
|
||||||
|
$q->orWhere('tanggal_permohonan', 'LIKE', '%' . $search->search . '%');
|
||||||
|
$q->orWhereRelation('user', 'name', 'LIKE', '%' . $search->search . '%');
|
||||||
|
$q->orWhereRelation('tujuanPenilaian', 'name', 'LIKE', '%' . $search->search . '%');
|
||||||
|
$q->orWhereRelation('branch', 'name', 'LIKE', '%' . $search->search . '%');
|
||||||
|
$q->orWhereRelation('jenisFasilitasKredit', 'name', 'LIKE', '%' . $search->search . '%');
|
||||||
|
$q->orWhereRelation('jenisPenilaian', 'name', 'LIKE', '%' . $search->search . '%');
|
||||||
|
$q->orWhere('status', 'LIKE', '%' . $search->search . '%');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Apply sorting if provided
|
||||||
|
if ($request->has('sortOrder') && !empty($request->get('sortOrder'))) {
|
||||||
|
$order = $request->get('sortOrder');
|
||||||
|
$column = $request->get('sortField');
|
||||||
|
$query->orderBy($column, $order);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get the total count of records
|
||||||
|
$totalRecords = $query->count();
|
||||||
|
$size = $request->get('size', 10);
|
||||||
|
if ($size == 0) {
|
||||||
|
$size = 10;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Apply pagination if provided
|
||||||
|
if ($request->has('page') && $request->has('size')) {
|
||||||
|
$page = $request->get('page');
|
||||||
|
$size = $request->get('size');
|
||||||
|
$offset = ($page - 1) * $size; // Calculate the offset
|
||||||
|
|
||||||
|
$query->skip($offset)->take($size);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get the filtered count of records
|
||||||
|
$filteredRecords = $query->count();
|
||||||
|
|
||||||
|
// Get the data for the current page
|
||||||
|
$data = $query->with(['user', 'debiture', 'branch', 'tujuanPenilaian', 'penilaian','documents','jenisFasilitasKredit', 'jenisPenilaian'])->get();
|
||||||
|
|
||||||
|
// Calculate the page count
|
||||||
|
$pageCount = ceil($totalRecords / $size);
|
||||||
|
|
||||||
|
// Calculate the current page number
|
||||||
|
$currentPage = max(1, $request->get('page', 1));
|
||||||
|
|
||||||
|
// Return the response data as a JSON object
|
||||||
|
return response()->json([
|
||||||
|
'draw' => $request->get('draw'),
|
||||||
|
'recordsTotal' => $totalRecords,
|
||||||
|
'recordsFiltered' => $filteredRecords,
|
||||||
|
'pageCount' => $pageCount,
|
||||||
|
'page' => $currentPage,
|
||||||
|
'totalCount' => $totalRecords,
|
||||||
|
'data' => $data,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
150
app/Http/Controllers/NilaiPlafondController.php
Normal file
150
app/Http/Controllers/NilaiPlafondController.php
Normal file
@@ -0,0 +1,150 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Modules\Lpj\Http\Controllers;
|
||||||
|
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use Exception;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Maatwebsite\Excel\Facades\Excel;
|
||||||
|
use Modules\Lpj\Exports\NilaiPlafondExport;
|
||||||
|
use Modules\Lpj\Http\Requests\NilaiPlafondRequest;
|
||||||
|
use Modules\Lpj\Models\NilaiPlafond;
|
||||||
|
|
||||||
|
class NilaiPlafondController extends Controller
|
||||||
|
{
|
||||||
|
public $user;
|
||||||
|
|
||||||
|
public function index()
|
||||||
|
{
|
||||||
|
return view('lpj::nilai_plafond.index');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function store(NilaiPlafondRequest $request)
|
||||||
|
{
|
||||||
|
$validate = $request->validated();
|
||||||
|
|
||||||
|
if ($validate) {
|
||||||
|
try {
|
||||||
|
// Save to database
|
||||||
|
NilaiPlafond::create($validate);
|
||||||
|
return redirect()
|
||||||
|
->route('basicdata.nilai-plafond.index')
|
||||||
|
->with('success', 'Jenis Aset created successfully');
|
||||||
|
} catch (Exception $e) {
|
||||||
|
return redirect()
|
||||||
|
->route('basicdata.nilai-plafond.create')
|
||||||
|
->with('error', 'Failed to create nilai plafond');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function create()
|
||||||
|
{
|
||||||
|
return view('lpj::nilai_plafond.create');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function edit($id)
|
||||||
|
{
|
||||||
|
$nilaiPlafond = NilaiPlafond::find($id);
|
||||||
|
return view('lpj::nilai_plafond.create', compact('nilaiPlafond'));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function update(NilaiPlafondRequest $request, $id)
|
||||||
|
{
|
||||||
|
$validate = $request->validated();
|
||||||
|
|
||||||
|
if ($validate) {
|
||||||
|
try {
|
||||||
|
// Update in database
|
||||||
|
$nilaiPlafond = NilaiPlafond::find($id);
|
||||||
|
$nilaiPlafond->update($validate);
|
||||||
|
return redirect()
|
||||||
|
->route('basicdata.nilai-plafond.index')
|
||||||
|
->with('success', 'Jenis Aset updated successfully');
|
||||||
|
} catch (Exception $e) {
|
||||||
|
return redirect()
|
||||||
|
->route('basicdata.nilai-plafond.edit', $id)
|
||||||
|
->with('error', 'Failed to update nilai plafond');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function destroy($id)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
// Delete from database
|
||||||
|
$nilaiPlafond = NilaiPlafond::find($id);
|
||||||
|
$nilaiPlafond->delete();
|
||||||
|
|
||||||
|
echo json_encode(['success' => true, 'message' => 'Jenis Aset deleted successfully']);
|
||||||
|
} catch (Exception $e) {
|
||||||
|
echo json_encode(['success' => false, 'message' => 'Failed to delete nilai plafond']);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function dataForDatatables(Request $request)
|
||||||
|
{
|
||||||
|
if (is_null($this->user) || !$this->user->can('nilai_plafond.view')) {
|
||||||
|
//abort(403, 'Sorry! You are not allowed to view users.');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Retrieve data from the database
|
||||||
|
$query = NilaiPlafond::query();
|
||||||
|
|
||||||
|
// Apply search filter if provided
|
||||||
|
if ($request->has('search') && !empty($request->get('search'))) {
|
||||||
|
$search = $request->get('search');
|
||||||
|
$query->where(function ($q) use ($search) {
|
||||||
|
$q->where('code', 'LIKE', "%$search%");
|
||||||
|
$q->orWhere('name', 'LIKE', "%$search%");
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// Apply sorting if provided
|
||||||
|
if ($request->has('sortOrder') && !empty($request->get('sortOrder'))) {
|
||||||
|
$order = $request->get('sortOrder');
|
||||||
|
$column = $request->get('sortField');
|
||||||
|
$query->orderBy($column, $order);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get the total count of records
|
||||||
|
$totalRecords = $query->count();
|
||||||
|
|
||||||
|
// Apply pagination if provided
|
||||||
|
if ($request->has('page') && $request->has('size')) {
|
||||||
|
$page = $request->get('page');
|
||||||
|
$size = $request->get('size');
|
||||||
|
$offset = ($page - 1) * $size; // Calculate the offset
|
||||||
|
|
||||||
|
$query->skip($offset)->take($size);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get the filtered count of records
|
||||||
|
$filteredRecords = $query->count();
|
||||||
|
|
||||||
|
// Get the data for the current page
|
||||||
|
$data = $query->get();
|
||||||
|
|
||||||
|
// Calculate the page count
|
||||||
|
$pageCount = ceil($totalRecords / $request->get('size'));
|
||||||
|
|
||||||
|
// Calculate the current page number
|
||||||
|
$currentPage = 0 + 1;
|
||||||
|
|
||||||
|
// Return the response data as a JSON object
|
||||||
|
return response()->json([
|
||||||
|
'draw' => $request->get('draw'),
|
||||||
|
'recordsTotal' => $totalRecords,
|
||||||
|
'recordsFiltered' => $filteredRecords,
|
||||||
|
'pageCount' => $pageCount,
|
||||||
|
'page' => $currentPage,
|
||||||
|
'totalCount' => $totalRecords,
|
||||||
|
'data' => $data,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function export()
|
||||||
|
{
|
||||||
|
return Excel::download(new NilaiPlafondExport, 'nilai_plafond.xlsx');
|
||||||
|
}
|
||||||
|
}
|
||||||
228
app/Http/Controllers/NocController.php
Normal file
228
app/Http/Controllers/NocController.php
Normal file
@@ -0,0 +1,228 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Modules\Lpj\Http\Controllers;
|
||||||
|
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Facades\Auth;
|
||||||
|
use Modules\Lpj\Http\Requests\NocRequest;
|
||||||
|
use Modules\Lpj\Models\Noc;
|
||||||
|
use Modules\Lpj\Models\PenawaranTender;
|
||||||
|
use Modules\Lpj\Models\Permohonan;
|
||||||
|
use Modules\Lpj\Models\PersetujuanPenawaran;
|
||||||
|
|
||||||
|
class NocController extends Controller
|
||||||
|
{
|
||||||
|
public $user;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Display a listing of the resource.
|
||||||
|
*/
|
||||||
|
public function index()
|
||||||
|
{
|
||||||
|
$persetujuanPenawarans = PersetujuanPenawaran::all();
|
||||||
|
return view('lpj::noc.index', compact('persetujuanPenawarans'));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Store a newly created resource in storage.
|
||||||
|
*/
|
||||||
|
/**
|
||||||
|
* Store a newly created resource in storage.
|
||||||
|
*/
|
||||||
|
/**
|
||||||
|
* Store a newly created resource in storage.
|
||||||
|
*/
|
||||||
|
public function store(NocRequest $request)
|
||||||
|
{
|
||||||
|
$validated = $request->validated();
|
||||||
|
$validated['updated_by'] = Auth::id();
|
||||||
|
if (request()->get('status_bayar') == "sudah_bayar") {
|
||||||
|
$validated['status'] = '1';
|
||||||
|
$status = "spk";
|
||||||
|
} else {
|
||||||
|
$status = "persetujuan-penawaran";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
$dataNoc = [
|
||||||
|
'nominal_bayar' => $validated['nominal_bayar'],
|
||||||
|
'tanggal_pembayaran' => date('Y-m-d'),
|
||||||
|
'status_bayar' => $validated['nominal_bayar'] < $validated['total_harus_bayar'] ? false : true,
|
||||||
|
'catatan_noc' => $validated['catatan_noc'],
|
||||||
|
];
|
||||||
|
$noc = Noc::updateOrCreate(
|
||||||
|
[
|
||||||
|
'permohonan_id' => $validated['permohonan_id'],
|
||||||
|
'persetujuan_penawaran_id' => $validated['persetujuan_penawaran_id']
|
||||||
|
],$dataNoc
|
||||||
|
);
|
||||||
|
|
||||||
|
$folderPath = 'noc/' . request()->get('penawaran_id');
|
||||||
|
|
||||||
|
if ($request->hasFile('bukti_ksl')) {
|
||||||
|
$noc->bukti_ksl = $request->file('bukti_ksl')->store(
|
||||||
|
$folderPath,
|
||||||
|
'public',
|
||||||
|
);
|
||||||
|
}
|
||||||
|
$noc->save();
|
||||||
|
|
||||||
|
// Update the status of the related permohonan to 'spk'
|
||||||
|
$permohonan = Permohonan::find(request()->get('permohonan_id'));
|
||||||
|
if ($permohonan) {
|
||||||
|
$permohonan->status_bayar = request()->get('status_pembayar');
|
||||||
|
if ($permohonan->jenis_penilaian_id == 2) {
|
||||||
|
$permohonan->status = $status;
|
||||||
|
}
|
||||||
|
$permohonan->save();
|
||||||
|
|
||||||
|
// andy add, update status penawaran.status='spk'
|
||||||
|
// $penawaran = PenawaranTender::where('nomor_registrasi',$permohonan->nomor_registrasi)->first();
|
||||||
|
if ($permohonan->jenis_penilaian_id == 2) {
|
||||||
|
PenawaranTender::where('nomor_registrasi', $permohonan->nomor_registrasi)->update([
|
||||||
|
'status' => $status,
|
||||||
|
'updated_by' => Auth::id(),
|
||||||
|
'updated_at' => now(),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
// andy add, update status penawaran.status='spk'
|
||||||
|
}
|
||||||
|
|
||||||
|
return redirect()
|
||||||
|
->route('noc.index')->with('success', 'Penyelesaian KSL berhasil disimpan.');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update the specified resource in storage.
|
||||||
|
*/
|
||||||
|
public function update(NocRequest $request, PersetujuanPenawaran $persetujuanPenawaran)
|
||||||
|
{
|
||||||
|
$validated = $request->validated();
|
||||||
|
$validated['updated_by'] = Auth::id();
|
||||||
|
|
||||||
|
$persetujuanPenawaran->update($validated);
|
||||||
|
|
||||||
|
return redirect()
|
||||||
|
->route('noc.index')->with('success', 'Persetujuan Penawaran updated successfully');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show the form for creating a new resource.
|
||||||
|
*/
|
||||||
|
public function create()
|
||||||
|
{
|
||||||
|
return view('lpj::noc.create');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Display the specified resource.
|
||||||
|
*/
|
||||||
|
public function show($id) {}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show the form for editing the specified resource.
|
||||||
|
*/
|
||||||
|
public function edit($id)
|
||||||
|
{
|
||||||
|
$persetujuanPenawaran = PersetujuanPenawaran::where('id', $id)->first();
|
||||||
|
return view('lpj::noc.form', compact('persetujuanPenawaran'));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove the specified resource from storage.
|
||||||
|
*/
|
||||||
|
public function destroy(PersetujuanPenawaran $persetujuanPenawaran)
|
||||||
|
{
|
||||||
|
$persetujuanPenawaran->delete();
|
||||||
|
|
||||||
|
return redirect()
|
||||||
|
->route('noc.index')->with('success', 'Persetujuan Penawaran deleted successfully');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function dataForDatatables(Request $request)
|
||||||
|
{
|
||||||
|
if (is_null($this->user) || !$this->user->can('noc.view')) {
|
||||||
|
//abort(403, 'Sorry! You are not allowed to view persetujuan penawaran.');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Retrieve data from the database
|
||||||
|
$query = PersetujuanPenawaran::query();
|
||||||
|
|
||||||
|
// Apply search filter if provided
|
||||||
|
if ($request->has('search') && !empty($request->get('search'))) {
|
||||||
|
$search = $request->get('search');
|
||||||
|
$query->where(function ($q) use ($search) {
|
||||||
|
$q->orWhereRelation('penawaran', 'nomor_registrasi', 'LIKE', '%' . $search . '%');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// Apply sorting if provided
|
||||||
|
if ($request->has('sortOrder') && !empty($request->get('sortOrder'))) {
|
||||||
|
$order = $request->get('sortOrder');
|
||||||
|
$column = $request->get('sortField');
|
||||||
|
$query->orderBy($column, $order);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get the total count of records
|
||||||
|
$totalRecords = $query->count();
|
||||||
|
|
||||||
|
// Apply pagination if provided
|
||||||
|
if ($request->has('page') && $request->has('size')) {
|
||||||
|
$page = $request->get('page');
|
||||||
|
$size = $request->get('size');
|
||||||
|
$offset = ($page - 1) * $size; // Calculate the offset
|
||||||
|
|
||||||
|
$query->skip($offset)->take($size);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get the filtered count of records
|
||||||
|
$filteredRecords = $query->count();
|
||||||
|
|
||||||
|
// Get the data for the current page
|
||||||
|
$data = $query->get();
|
||||||
|
|
||||||
|
$data = $data->map(function ($persetujuanPenawaran) {
|
||||||
|
return [
|
||||||
|
'id' => $persetujuanPenawaran->id,
|
||||||
|
'nomor_registrasi' => $persetujuanPenawaran->permohonan->nomor_registrasi ?? $persetujuanPenawaran->penawaran->nomor_registrasi,
|
||||||
|
'nama_debitur' => $persetujuanPenawaran->permohonan->debiture->name ?? $persetujuanPenawaran->penawaran->permohonan->debiture->name,
|
||||||
|
'cabang' => $persetujuanPenawaran->permohonan->branch->name ?? $persetujuanPenawaran->penawaran->permohonan->branch->name,
|
||||||
|
'tanggal_setor' => dateFormat(
|
||||||
|
$persetujuanPenawaran->moc->created_at ?? $persetujuanPenawaran->created_at,
|
||||||
|
true,
|
||||||
|
),
|
||||||
|
'nominal_bayar' => currencyFormat(
|
||||||
|
$persetujuanPenawaran->noc->nominal_bayar ?? $persetujuanPenawaran->nominal_bayar ?? 0,
|
||||||
|
),
|
||||||
|
'bukti_ksl' => $persetujuanPenawaran->noc->bukti_ksl ?? $persetujuanPenawaran->bukti_ksl ?? null,
|
||||||
|
'memo_penyelesaian' => $persetujuanPenawaran->noc->memo_penyelesaian ?? $persetujuanPenawaran->memo_penyelesaian ?? null,
|
||||||
|
'nominal_penyelesaian' => currencyFormat(
|
||||||
|
$persetujuanPenawaran->noc->nominal_penyelesaian ?? $persetujuanPenawaran->nominal_penyelesaian ?? 0,
|
||||||
|
),
|
||||||
|
'bukti_penyelesaian' => $persetujuanPenawaran->noc->bukti_penyelesaian ?? $persetujuanPenawaran->bukti_penyelesaian ?? null,
|
||||||
|
'tanggal_penyelesaian' => dateFormat(
|
||||||
|
$persetujuanPenawaran->noc->tanggal_penyelesaian ?? $persetujuanPenawaran->updated_at,
|
||||||
|
true,
|
||||||
|
),
|
||||||
|
];
|
||||||
|
});
|
||||||
|
|
||||||
|
// Calculate the page count
|
||||||
|
$pageCount = ceil($totalRecords / $request->get('size'));
|
||||||
|
|
||||||
|
// Calculate the current page number
|
||||||
|
$currentPage = $request->get('page', 1);
|
||||||
|
|
||||||
|
// Return the response data as a JSON object
|
||||||
|
return response()->json([
|
||||||
|
'draw' => $request->get('draw'),
|
||||||
|
'recordsTotal' => $totalRecords,
|
||||||
|
'recordsFiltered' => $filteredRecords,
|
||||||
|
'pageCount' => $pageCount,
|
||||||
|
'page' => $currentPage,
|
||||||
|
'totalCount' => $totalRecords,
|
||||||
|
'data' => $data,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
431
app/Http/Controllers/OtorisasiPenawaranController.php
Normal file
431
app/Http/Controllers/OtorisasiPenawaranController.php
Normal file
@@ -0,0 +1,431 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Modules\Lpj\Http\Controllers;
|
||||||
|
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use Carbon\Carbon;
|
||||||
|
use Exception;
|
||||||
|
use Illuminate\Http\JsonResponse;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Http\Response;
|
||||||
|
use Illuminate\Support\Facades\Auth;
|
||||||
|
use Illuminate\Support\Facades\DB;
|
||||||
|
use Illuminate\Support\Facades\Storage;
|
||||||
|
use Illuminate\Support\Facades\Validator;
|
||||||
|
use Maatwebsite\Excel\Facades\Excel;
|
||||||
|
use Modules\Lpj\Models\KJPP;
|
||||||
|
use Modules\Lpj\Models\PenawaranDetailTender;
|
||||||
|
use Modules\Lpj\Models\PenawaranDetailTenderLog;
|
||||||
|
use Modules\Lpj\Models\PenawaranTender;
|
||||||
|
use Modules\Lpj\Models\Permohonan;
|
||||||
|
|
||||||
|
class OtorisasiPenawaranController extends Controller
|
||||||
|
{
|
||||||
|
public $user;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Display a listing of the resource.
|
||||||
|
*/
|
||||||
|
public function index()
|
||||||
|
{
|
||||||
|
// dd('hai otorisasi');
|
||||||
|
return view('lpj::otorisasipenawaran.index');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function dataForDatatables(Request $request)
|
||||||
|
{
|
||||||
|
if (is_null($this->user) || !$this->user->can('debitur.view')) {
|
||||||
|
//abort(403, 'Sorry! You are not allowed to view users.');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Retrieve data from the database
|
||||||
|
$query = PenawaranTender::query()->select(
|
||||||
|
'penawaran.*',
|
||||||
|
'debitures.name as debitures_name',
|
||||||
|
'permohonan.tanggal_permohonan',
|
||||||
|
'users.name as user_pemohon',
|
||||||
|
'branches.name as branches_name',
|
||||||
|
'tujuan_penilaian.name as tujuan_penilaian_name',
|
||||||
|
'tujuan_penilaian_kjpp.name as tujuan_penilaian_kjpp_name',
|
||||||
|
)->leftJoin('permohonan', 'permohonan.nomor_registrasi', '=', 'penawaran.nomor_registrasi')->leftJoin(
|
||||||
|
'debitures',
|
||||||
|
'debitures.id',
|
||||||
|
'=',
|
||||||
|
'permohonan.debiture_id',
|
||||||
|
)->leftJoin('users', 'users.id', '=', 'permohonan.user_id')->leftJoin(
|
||||||
|
'branches',
|
||||||
|
'branches.id',
|
||||||
|
'=',
|
||||||
|
'permohonan.branch_id',
|
||||||
|
)->leftJoin('tujuan_penilaian', 'tujuan_penilaian.id', '=', 'permohonan.tujuan_penilaian_id')->leftJoin(
|
||||||
|
'tujuan_penilaian_kjpp',
|
||||||
|
'tujuan_penilaian_kjpp.id',
|
||||||
|
'=',
|
||||||
|
'penawaran.tujuan_penilaian_kjpp_id',
|
||||||
|
)->where('penawaran.status', '=', 'proposal-tender')->withCount('penawarandetails');
|
||||||
|
|
||||||
|
// Apply search filter if provided
|
||||||
|
if ($request->has('search') && !empty($request->get('search'))) {
|
||||||
|
$search = $request->get('search');
|
||||||
|
$query->where(function ($q) use ($search) {
|
||||||
|
$q->where('nomor_registrasi', 'LIKE', '%' . $search . '%');
|
||||||
|
$q->orWhere('tanggal_permohonan', 'LIKE', '%' . $search . '%');
|
||||||
|
|
||||||
|
$q->orWhere('status', 'LIKE', '%' . $search . '%');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// Apply sorting if provided
|
||||||
|
if ($request->has('sortOrder') && !empty($request->get('sortOrder'))) {
|
||||||
|
$order = $request->get('sortOrder');
|
||||||
|
$column = $request->get('sortField');
|
||||||
|
$query->orderBy($column, $order);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get the total count of records
|
||||||
|
$totalRecords = $query->count();
|
||||||
|
|
||||||
|
// Apply pagination if provided
|
||||||
|
if ($request->has('page') && $request->has('size')) {
|
||||||
|
$page = $request->get('page');
|
||||||
|
$size = $request->get('size');
|
||||||
|
$offset = ($page - 1) * $size; // Calculate the offset
|
||||||
|
|
||||||
|
$query->skip($offset)->take($size);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get the filtered count of records
|
||||||
|
$filteredRecords = $query->count();
|
||||||
|
|
||||||
|
// Get the data for the current page
|
||||||
|
//$data = $query->with(['user', 'debiture', 'branch', 'tujuanPenilaian'])->get();
|
||||||
|
$data = $query->get();
|
||||||
|
|
||||||
|
// format date
|
||||||
|
$i = 0;
|
||||||
|
foreach ($data as $obj) {
|
||||||
|
// tanggal_permohonan
|
||||||
|
if ($obj->tanggal_permohonan) {
|
||||||
|
$data[$i]->tanggal_permohonan = Carbon::parse($obj->tanggal_permohonan)->format('d M Y');
|
||||||
|
}
|
||||||
|
|
||||||
|
// date_range
|
||||||
|
$data[$i]->date_range = "-";
|
||||||
|
if ($obj->start_date && $obj->end_date) {
|
||||||
|
$data[$i]->date_range = Carbon::parse($obj->start_date)->format('d M Y') . ' - ' . Carbon::parse(
|
||||||
|
$obj->end_date,
|
||||||
|
)->format('d M Y');
|
||||||
|
}
|
||||||
|
|
||||||
|
$i++;
|
||||||
|
}
|
||||||
|
// format date
|
||||||
|
|
||||||
|
// Calculate the page count
|
||||||
|
$pageCount = ceil($totalRecords / $request->get('size'));
|
||||||
|
|
||||||
|
// Calculate the current page number
|
||||||
|
$currentPage = 0 + 1;
|
||||||
|
|
||||||
|
// Return the response data as a JSON object
|
||||||
|
return response()->json([
|
||||||
|
'draw' => $request->get('draw'),
|
||||||
|
'recordsTotal' => $totalRecords,
|
||||||
|
'recordsFiltered' => $filteredRecords,
|
||||||
|
'pageCount' => $pageCount,
|
||||||
|
'page' => $currentPage,
|
||||||
|
'totalCount' => $totalRecords,
|
||||||
|
'data' => $data,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function edit($id)
|
||||||
|
{
|
||||||
|
// id ==> penawaran.id
|
||||||
|
return view('lpj::otorisasipenawaran.edit', compact('id'));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setData(Request $request): JsonResponse
|
||||||
|
{
|
||||||
|
$data = [];
|
||||||
|
$penawaran = [];
|
||||||
|
$penawrandetails = [];
|
||||||
|
$penawarandetailLogs = [];
|
||||||
|
|
||||||
|
if (request()->ajax()) {
|
||||||
|
$id = $request->id;
|
||||||
|
$penawaran = PenawaranTender::where('status','=','proposal-tender')->find($id);
|
||||||
|
|
||||||
|
if ($penawaran) {
|
||||||
|
$penawarandetailLogs = PenawaranDetailTenderLog::where('penawaran_id',$id)
|
||||||
|
->leftJoin('kjpp', 'kjpp.id', '=', 'detail_penawaran_logs.kjpp_rekanan_id')
|
||||||
|
->select('detail_penawaran_logs.*', DB::raw("DATE_FORMAT(detail_penawaran_logs.created_at, '%d-%m-%Y %H:%i') AS created_at2"),'kjpp.code AS kjpp_code', 'kjpp.name AS kjpp_name')
|
||||||
|
->get();
|
||||||
|
$penawrandetails = PenawaranDetailTender::where('penawaran_id','=',$id)
|
||||||
|
->leftJoin('kjpp', 'kjpp.id', '=', 'detail_penawaran.kjpp_rekanan_id')
|
||||||
|
->select('detail_penawaran.*', 'kjpp.code AS kjpp_code', 'kjpp.name AS kjpp_name')
|
||||||
|
->where('detail_penawaran.status','=',1)
|
||||||
|
->get();
|
||||||
|
|
||||||
|
if(sizeof($penawarandetailLogs)>0)
|
||||||
|
{
|
||||||
|
$h=0;
|
||||||
|
foreach($penawarandetailLogs as $obj1)
|
||||||
|
{
|
||||||
|
// tgl_proposal
|
||||||
|
if ($obj1->tgl_proposal) {
|
||||||
|
$penawarandetailLogs[$h]->tgl_proposal = Carbon::parse($obj1->tgl_proposal)->format('d M Y');
|
||||||
|
}
|
||||||
|
|
||||||
|
if($obj1->dokumen_persetujuan && Storage::disk('public')->exists($obj1->dokumen_persetujuan))
|
||||||
|
{
|
||||||
|
$penawarandetailLogs_path = Storage::url($obj1->dokumen_persetujuan);
|
||||||
|
$penawarandetailLogs[$h]->dokumen_persetujuan = $penawarandetailLogs_path;
|
||||||
|
}
|
||||||
|
$h++;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
$i=0;
|
||||||
|
foreach($penawrandetails as $obj)
|
||||||
|
{
|
||||||
|
// tgl_proposal
|
||||||
|
if ($obj->tgl_proposal) {
|
||||||
|
$penawrandetails[$i]->tgl_proposal = Carbon::parse($obj->tgl_proposal)->format('d M Y');
|
||||||
|
}
|
||||||
|
|
||||||
|
if($obj->dokumen_persetujuan && Storage::disk('public')->exists($obj->dokumen_persetujuan))
|
||||||
|
{
|
||||||
|
$penawrandetails_path = Storage::url($obj->dokumen_persetujuan);
|
||||||
|
$penawrandetails[$i]->dokumen_persetujuan = $penawrandetails_path;
|
||||||
|
|
||||||
|
}
|
||||||
|
$i++;
|
||||||
|
}
|
||||||
|
|
||||||
|
$penawaranString = "";
|
||||||
|
if($penawaran->status)
|
||||||
|
{
|
||||||
|
$penawaranString = convertSlug($penawaran->status);
|
||||||
|
$penawaran->status = $penawaranString;
|
||||||
|
}
|
||||||
|
|
||||||
|
$kjpp=null;
|
||||||
|
$kjpp = KJPP::pluck('name', 'id');
|
||||||
|
$data['penawaran'] = $penawaran;
|
||||||
|
$data['penawrandetails'] = $penawrandetails;
|
||||||
|
$data['penawarandetailLogs'] = $penawarandetailLogs;
|
||||||
|
$data['status'] = 'success';
|
||||||
|
$data['message']['message_success'] = array("data successfully found");
|
||||||
|
} else {
|
||||||
|
$data['status'] = 'error';
|
||||||
|
$data['penawaran'] = null;
|
||||||
|
$data['penawrandetails'] = null;
|
||||||
|
$data['message']['message_data'] = array("data not found");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$data['status'] = 'error';
|
||||||
|
$data['message']['message_ajax'] = array("no ajax request");
|
||||||
|
}
|
||||||
|
|
||||||
|
return response()->json($data);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function otorisasiPenawaranKJPP(Request $request, $id): JsonResponse
|
||||||
|
{
|
||||||
|
$data = [];
|
||||||
|
$dataDetailPenawaranLog = [];
|
||||||
|
if (request()->ajax()) {
|
||||||
|
|
||||||
|
// cek masa aktif penawaran
|
||||||
|
$detailpenawaran = PenawaranDetailTender::find($id);
|
||||||
|
$penawaran = PenawaranTender::findOrFail($detailpenawaran->penawaran_id);
|
||||||
|
$checkActiveDateRange = checkActiveDateRangePenawaran($detailpenawaran->penawaran_id);
|
||||||
|
// cek masa aktif penawaran
|
||||||
|
if($checkActiveDateRange)
|
||||||
|
{
|
||||||
|
DB::beginTransaction();
|
||||||
|
try {
|
||||||
|
|
||||||
|
// update status KJPP yg tidak terpilih menjadi 2 -> kalah
|
||||||
|
// update status Penawaran menjadi persetujuan-penawaran (20241205)
|
||||||
|
// update status Permohonan menjadi persetujuan-penawaran (20241205)
|
||||||
|
// insert detail_permohonan_log
|
||||||
|
|
||||||
|
PenawaranDetailTender::where('status', 1)
|
||||||
|
->where('penawaran_id', $request->penawaran_id)
|
||||||
|
->whereNotIn('id', [$id])
|
||||||
|
->update(['status' => 2,
|
||||||
|
'updated_by' => Auth::id(),
|
||||||
|
'updated_at' => now()
|
||||||
|
]);
|
||||||
|
// 20241205 arahkan ke persetujuan-penawaran
|
||||||
|
PenawaranTender::where('id', $request->penawaran_id)
|
||||||
|
->update(['status'=>'persetujuan-penawaran',
|
||||||
|
'nama_kjpp_sebelumnya'=>$request->kjppName,
|
||||||
|
'biaya_kjpp_sebelumnya'=>$request->biaya_penawaran,
|
||||||
|
'tanggal_penilaian_sebelumnya'=>now(),
|
||||||
|
'authorized_status'=>1,
|
||||||
|
'authorized_at'=>now(),
|
||||||
|
'authorized_by'=>Auth::id(),
|
||||||
|
'updated_by' => Auth::id(),
|
||||||
|
'updated_at' => now()
|
||||||
|
]);
|
||||||
|
|
||||||
|
Permohonan::where('nomor_registrasi',$request->noReg)
|
||||||
|
->update(['status'=>'persetujuan-penawaran',
|
||||||
|
'updated_by' => Auth::id(),
|
||||||
|
'updated_at' => now()
|
||||||
|
]);
|
||||||
|
|
||||||
|
// log
|
||||||
|
$detailPenawaran = PenawaranDetailTender::where('penawaran_id', $request->penawaran_id)->get();
|
||||||
|
if(sizeof($detailPenawaran)>0)
|
||||||
|
{
|
||||||
|
|
||||||
|
foreach ($detailPenawaran as $model) {
|
||||||
|
array_push($dataDetailPenawaranLog, [
|
||||||
|
'detail_penawaran_id' =>$model->id,
|
||||||
|
'kjpp_rekanan_id' =>$model->kjpp_rekanan_id,
|
||||||
|
'penawaran_id' =>$model->penawaran_id,
|
||||||
|
'no_proposal' =>$model->no_proposal,
|
||||||
|
'tgl_proposal' =>$model->tgl_proposal,
|
||||||
|
'biaya_penawaran' =>$model->biaya_penawaran,
|
||||||
|
'attachment' =>$model->attachment,
|
||||||
|
'dokumen_persetujuan' =>$model->dokumen_persetujuan,
|
||||||
|
'status' =>$model->status,
|
||||||
|
'authorized_status' =>$model->authorized_status,
|
||||||
|
'authorized_at' =>$model->authorized_at,
|
||||||
|
'authorized_at' =>$model->authorized_at,
|
||||||
|
'created_at' =>$model->created_at,
|
||||||
|
'updated_at' =>$model->updated_at,
|
||||||
|
'deleted_at' =>$model->deleted_at,
|
||||||
|
'created_by' =>$model->created_by,
|
||||||
|
'updated_by' =>$model->updated_by,
|
||||||
|
'deleted_by' =>$model->deleted_by
|
||||||
|
]);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
PenawaranDetailTenderLog::insert($dataDetailPenawaranLog);
|
||||||
|
}
|
||||||
|
// log
|
||||||
|
|
||||||
|
DB::commit();
|
||||||
|
$data['status'] = 'success';
|
||||||
|
$data['message']['message_success'] = array('Otorisasi Penawaran KJPP '.$request->kjppName.' successfully');
|
||||||
|
} catch (Exception $e) {
|
||||||
|
DB::rollBack();
|
||||||
|
$data['status'] = 'error';
|
||||||
|
$data['message']['message_error'] = array("Otorisasi Penawaran KJPP failed..");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$data['status'] = 'error';
|
||||||
|
$data['message']['message_error'] = array("Penawaran sudah di tutup");
|
||||||
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
$data['status'] = 'error';
|
||||||
|
$data['message']['message_error'] = array("no ajax request");
|
||||||
|
}
|
||||||
|
return response()->json($data);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function show($id)
|
||||||
|
{
|
||||||
|
$prosespenawaran = PenawaranTender::with(['permohonan','tujuanPenilaianKjpp'])->find($id);
|
||||||
|
$permohonan = $prosespenawaran->permohonan;
|
||||||
|
return view('lpj::otorisasipenawaran.show', compact('id','prosespenawaran','permohonan'));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function penawaranulang(Request $request, $id): JsonResponse
|
||||||
|
{
|
||||||
|
// $id ==> penawaran.id
|
||||||
|
$data = [];
|
||||||
|
$dataDetailPenawaranLog=[];
|
||||||
|
if (request()->ajax()) {
|
||||||
|
|
||||||
|
|
||||||
|
DB::beginTransaction();
|
||||||
|
try {
|
||||||
|
|
||||||
|
// update detail_penawaran => detail_penawaran.status = 1 (untuk all KJPP)
|
||||||
|
// update penawaran => penawaran.status ="tender", penawaran.updated_at, penawaran.updated_by
|
||||||
|
// update permohonan => permohonan.status ="tender", permohonan.updated_at, permohonan.updated_by
|
||||||
|
// insert detail_permohonan_log
|
||||||
|
|
||||||
|
PenawaranDetailTender::where('penawaran_id', $id)
|
||||||
|
->update(['status' => 1,
|
||||||
|
'updated_by' => Auth::id(),
|
||||||
|
'updated_at' => now()
|
||||||
|
]);
|
||||||
|
|
||||||
|
PenawaranTender::where('id', $id)
|
||||||
|
->update(['status'=>'tender',
|
||||||
|
'updated_by' => Auth::id(),
|
||||||
|
'updated_at' => now()
|
||||||
|
]);
|
||||||
|
|
||||||
|
Permohonan::where('nomor_registrasi',$request->noReg)
|
||||||
|
->update(['status'=>'tender',
|
||||||
|
'updated_by' => Auth::id(),
|
||||||
|
'updated_at' => now()
|
||||||
|
]);
|
||||||
|
|
||||||
|
$detailPenawaran = PenawaranDetailTender::where('penawaran_id', $id)
|
||||||
|
->distinct()
|
||||||
|
->get();
|
||||||
|
|
||||||
|
// log
|
||||||
|
if(sizeof($detailPenawaran)>0)
|
||||||
|
{
|
||||||
|
|
||||||
|
foreach ($detailPenawaran as $model) {
|
||||||
|
array_push($dataDetailPenawaranLog, [
|
||||||
|
'detail_penawaran_id' =>$model->id,
|
||||||
|
'kjpp_rekanan_id' =>$model->kjpp_rekanan_id,
|
||||||
|
'penawaran_id' =>$model->penawaran_id,
|
||||||
|
'no_proposal' =>$model->no_proposal,
|
||||||
|
'tgl_proposal' =>$model->tgl_proposal,
|
||||||
|
'biaya_penawaran' =>$model->biaya_penawaran,
|
||||||
|
'attachment' =>$model->attachment,
|
||||||
|
'dokumen_persetujuan' =>$model->dokumen_persetujuan,
|
||||||
|
'status' =>$model->status,
|
||||||
|
'authorized_status' =>$model->authorized_status,
|
||||||
|
'authorized_at' =>$model->authorized_at,
|
||||||
|
'authorized_at' =>$model->authorized_at,
|
||||||
|
'created_at' =>$model->created_at,
|
||||||
|
'updated_at' =>$model->updated_at,
|
||||||
|
'deleted_at' =>$model->deleted_at,
|
||||||
|
'created_by' =>$model->created_by,
|
||||||
|
'updated_by' =>$model->updated_by,
|
||||||
|
'deleted_by' =>$model->deleted_by
|
||||||
|
]);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
PenawaranDetailTenderLog::insert($dataDetailPenawaranLog);
|
||||||
|
}
|
||||||
|
// log
|
||||||
|
|
||||||
|
DB::commit();
|
||||||
|
$data['detailPenawaran'] = $detailPenawaran;
|
||||||
|
$data['status'] = 'success';
|
||||||
|
$data['message']['message_success'] = array('Penawaran ulang successfully');
|
||||||
|
} catch (Exception $e) {
|
||||||
|
DB::rollBack();
|
||||||
|
$data['status'] = 'error';
|
||||||
|
$data['message']['message_error'] = array("Penawaran ulang failed..");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
} else {
|
||||||
|
$data['status'] = 'error';
|
||||||
|
$data['message']['message_error'] = array("no ajax request");
|
||||||
|
}
|
||||||
|
return response()->json($data);
|
||||||
|
}
|
||||||
|
}
|
||||||
153
app/Http/Controllers/PembatalanController.php
Normal file
153
app/Http/Controllers/PembatalanController.php
Normal file
@@ -0,0 +1,153 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Modules\Lpj\Http\Controllers;
|
||||||
|
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use Barryvdh\DomPDF\Facade\Pdf;
|
||||||
|
use Exception;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Maatwebsite\Excel\Facades\Excel;
|
||||||
|
use Modules\Location\Models\City;
|
||||||
|
use Modules\Location\Models\District;
|
||||||
|
use Modules\Location\Models\Province;
|
||||||
|
use Modules\Location\Models\Village;
|
||||||
|
use Modules\Lpj\Exports\PermohonanExport;
|
||||||
|
use Modules\Lpj\Http\Requests\PermohonanRequest;
|
||||||
|
use Modules\Lpj\Models\Branch;
|
||||||
|
use Modules\Lpj\Models\Debiture;
|
||||||
|
use Modules\Lpj\Models\DokumenJaminan;
|
||||||
|
use Modules\Lpj\Models\JenisFasilitasKredit;
|
||||||
|
use Modules\Lpj\Models\NilaiPlafond;
|
||||||
|
use Modules\Lpj\Models\Permohonan;
|
||||||
|
use Modules\Lpj\Models\PermohonanPembatalan;
|
||||||
|
use Modules\Lpj\Models\StatusPermohonan;
|
||||||
|
use Modules\Lpj\Models\TujuanPenilaian;
|
||||||
|
use Modules\Lpj\Services\PermohonanHistoryService;
|
||||||
|
|
||||||
|
class PembatalanController extends Controller
|
||||||
|
{
|
||||||
|
public $user;
|
||||||
|
protected $historyService;
|
||||||
|
|
||||||
|
public function __construct(PermohonanHistoryService $historyService)
|
||||||
|
{
|
||||||
|
$this->historyService = $historyService;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function index()
|
||||||
|
{
|
||||||
|
return view('lpj::pembatalan.index');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function edit($id)
|
||||||
|
{
|
||||||
|
$pembatalan = PermohonanPembatalan::with(['permohonan.debiture','permohonan.branch'])->find($id);
|
||||||
|
|
||||||
|
return view(
|
||||||
|
'lpj::pembatalan.form',
|
||||||
|
compact(
|
||||||
|
'pembatalan'
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function update(Request $request, $id)
|
||||||
|
{
|
||||||
|
$pembatalan = PermohonanPembatalan::findOrFail($id);
|
||||||
|
$permohonan = Permohonan::find($pembatalan->permohonan_id);
|
||||||
|
$beforeRequest = $permohonan->toArray();
|
||||||
|
|
||||||
|
try {
|
||||||
|
// Update Permohonan Pembatalan
|
||||||
|
if($request->status=='approved'){
|
||||||
|
$pembatalan->status = 'approved';
|
||||||
|
$pembatalan->authorized_at = now();
|
||||||
|
$pembatalan->authorized_by = auth()->user()->id;
|
||||||
|
$pembatalan->authorized_status = 1;
|
||||||
|
$pembatalan->save();
|
||||||
|
|
||||||
|
$permohonan->status = 'batal';
|
||||||
|
$permohonan->save();
|
||||||
|
} else{
|
||||||
|
$pembatalan->status = 'rejected';
|
||||||
|
$pembatalan->authorized_at = now();
|
||||||
|
$pembatalan->authorized_by = auth()->user()->id;
|
||||||
|
$pembatalan->authorized_status = 3;
|
||||||
|
$pembatalan->save();
|
||||||
|
}
|
||||||
|
|
||||||
|
return redirect()
|
||||||
|
->route('pembatalan.index')->with('success', 'Permohonan Pembatalan updated successfully');
|
||||||
|
} catch (Exception $e) {
|
||||||
|
return redirect()
|
||||||
|
->route('pembatalan.edit', $id)->with('error', 'Failed to update permohonan Pembatalan');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function dataForDatatables(Request $request)
|
||||||
|
{
|
||||||
|
if (is_null($this->user) || !$this->user->can('debitur.view')) {
|
||||||
|
//abort(403, 'Sorry! You are not allowed to view users.');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Retrieve data from the database
|
||||||
|
$query = PermohonanPembatalan::query();
|
||||||
|
$query = $query->orderBy('created_at', 'desc');
|
||||||
|
// Apply search filter if provided
|
||||||
|
if ($request->has('search') && !empty($request->get('search'))) {
|
||||||
|
$search = $request->get('search');
|
||||||
|
$query->where(function ($q) use ($search) {
|
||||||
|
$q->orWhereRelation('permohonan', 'nomor_registrasi', 'LIKE', '%' . $search . '%');
|
||||||
|
$q->orWhereRelation('permohonan.debiture', 'name', 'LIKE', '%' . $search . '%');
|
||||||
|
$q->orWhere('alasan_pembatalan', 'LIKE', '%' . $search . '%');
|
||||||
|
$q->orWhere('status', 'LIKE', '%' . $search . '%');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// Apply sorting if provided
|
||||||
|
if ($request->has('sortOrder') && !empty($request->get('sortOrder'))) {
|
||||||
|
$order = $request->get('sortOrder');
|
||||||
|
$column = $request->get('sortField');
|
||||||
|
$query->orderBy($column, $order);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get the total count of records
|
||||||
|
$totalRecords = $query->count();
|
||||||
|
$size = $request->get('size', 10);
|
||||||
|
if ($size == 0) {
|
||||||
|
$size = 10;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Apply pagination if provided
|
||||||
|
if ($request->has('page') && $request->has('size')) {
|
||||||
|
$page = $request->get('page');
|
||||||
|
$size = $request->get('size');
|
||||||
|
$offset = ($page - 1) * $size; // Calculate the offset
|
||||||
|
|
||||||
|
$query->skip($offset)->take($size);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get the filtered count of records
|
||||||
|
$filteredRecords = $query->count();
|
||||||
|
|
||||||
|
// Get the data for the current page
|
||||||
|
$data = $query->with(['permohonan.debiture','permohonan.branch','creator'])->get();
|
||||||
|
|
||||||
|
// Calculate the page count
|
||||||
|
$pageCount = ceil($totalRecords / $size);
|
||||||
|
|
||||||
|
// Calculate the current page number
|
||||||
|
$currentPage = max(1, $request->get('page', 1));
|
||||||
|
|
||||||
|
// Return the response data as a JSON object
|
||||||
|
return response()->json([
|
||||||
|
'draw' => $request->get('draw'),
|
||||||
|
'recordsTotal' => $totalRecords,
|
||||||
|
'recordsFiltered' => $filteredRecords,
|
||||||
|
'pageCount' => $pageCount,
|
||||||
|
'page' => $currentPage,
|
||||||
|
'totalCount' => $totalRecords,
|
||||||
|
'data' => $data,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
335
app/Http/Controllers/PembayaranController.php
Normal file
335
app/Http/Controllers/PembayaranController.php
Normal file
@@ -0,0 +1,335 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Modules\Lpj\Http\Controllers;
|
||||||
|
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use Exception;
|
||||||
|
use Illuminate\Http\JsonResponse;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Facades\Auth;
|
||||||
|
use Illuminate\Support\Facades\Validator;
|
||||||
|
use Maatwebsite\Excel\Facades\Excel;
|
||||||
|
use Modules\Lpj\Http\Requests\PersetujuanPenawaranRequest;
|
||||||
|
use Modules\Lpj\Models\PenawaranTender;
|
||||||
|
use Modules\Lpj\Models\Permohonan;
|
||||||
|
use Modules\Lpj\Models\PersetujuanPenawaran;
|
||||||
|
|
||||||
|
// use Modules\Lpj\Models\JenisPenilaian;
|
||||||
|
|
||||||
|
// use Modules\Lpj\Models\Regions;
|
||||||
|
|
||||||
|
class PembayaranController extends Controller
|
||||||
|
{
|
||||||
|
public $user;
|
||||||
|
|
||||||
|
public function index()
|
||||||
|
{
|
||||||
|
return view('lpj::pembayaran.index');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function approval()
|
||||||
|
{
|
||||||
|
return view('lpj::pembayaran.approval');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function dataApprovalForDatatables(Request $request)
|
||||||
|
{
|
||||||
|
if (is_null($this->user) || !$this->user->can('noc.view')) {
|
||||||
|
//abort(403, 'Sorry! You are not allowed to view persetujuan penawaran.');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Retrieve data from the database
|
||||||
|
$query = PersetujuanPenawaran::query();
|
||||||
|
|
||||||
|
// Apply search filter if provided
|
||||||
|
if ($request->has('search') && !empty($request->get('search'))) {
|
||||||
|
$search = $request->get('search');
|
||||||
|
$query->where(function ($q) use ($search) {
|
||||||
|
$q->orWhereRelation('penawaran', 'nomor_registrasi', 'LIKE', '%' . $search . '%');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// Apply sorting if provided
|
||||||
|
if ($request->has('sortOrder') && !empty($request->get('sortOrder'))) {
|
||||||
|
$order = $request->get('sortOrder');
|
||||||
|
$column = $request->get('sortField');
|
||||||
|
$query->orderBy($column, $order);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get the total count of records
|
||||||
|
$totalRecords = $query->count();
|
||||||
|
|
||||||
|
// Apply pagination if provided
|
||||||
|
if ($request->has('page') && $request->has('size')) {
|
||||||
|
$page = $request->get('page');
|
||||||
|
$size = $request->get('size');
|
||||||
|
$offset = ($page - 1) * $size; // Calculate the offset
|
||||||
|
|
||||||
|
$query->skip($offset)->take($size);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get the filtered count of records
|
||||||
|
$filteredRecords = $query->count();
|
||||||
|
|
||||||
|
// Get the data for the current page
|
||||||
|
$data = $query
|
||||||
|
->with(
|
||||||
|
[
|
||||||
|
'penawaran.permohonan.user',
|
||||||
|
'penawaran.permohonan.debiture',
|
||||||
|
'penawaran.permohonan.branch',
|
||||||
|
'permohonan.debiture',
|
||||||
|
'permohonan.branch',
|
||||||
|
'permohonan.user',
|
||||||
|
'permohonan.approveBayar',
|
||||||
|
'penawaran.permohonan.approveBayar',
|
||||||
|
'penawaran.detail',
|
||||||
|
'penawaran.persetujuan',
|
||||||
|
],
|
||||||
|
)->get();
|
||||||
|
|
||||||
|
|
||||||
|
// Calculate the page count
|
||||||
|
$pageCount = ceil($totalRecords / $request->get('size'));
|
||||||
|
|
||||||
|
// Calculate the current page number
|
||||||
|
$currentPage = $request->get('page', 1);
|
||||||
|
|
||||||
|
// Return the response data as a JSON object
|
||||||
|
return response()->json([
|
||||||
|
'draw' => $request->get('draw'),
|
||||||
|
'recordsTotal' => $totalRecords,
|
||||||
|
'recordsFiltered' => $filteredRecords,
|
||||||
|
'pageCount' => $pageCount,
|
||||||
|
'page' => $currentPage,
|
||||||
|
'totalCount' => $totalRecords,
|
||||||
|
'data' => $data,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function edit($id)
|
||||||
|
{
|
||||||
|
$permohonan = Permohonan::find($id);
|
||||||
|
|
||||||
|
$persetujuanPenawaran = PersetujuanPenawaran::where('permohonan_id', $permohonan->id)->first();
|
||||||
|
return view('lpj::pembayaran.form', compact('permohonan', 'persetujuanPenawaran'));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function store(PersetujuanPenawaranRequest $request)
|
||||||
|
{
|
||||||
|
$validated = $request->validated();
|
||||||
|
$validated['created_by'] = Auth::id();
|
||||||
|
$validated['status'] = '0';
|
||||||
|
|
||||||
|
$persetujuanPenawaran = PersetujuanPenawaran::where('permohonan_id', $validated['permohonan_id'] ?? null)->first();
|
||||||
|
$permohonan = Permohonan::find(request()->get('permohonan_id'));
|
||||||
|
if ($persetujuanPenawaran) {
|
||||||
|
// if (isset($validated['penawaran_id'])) {
|
||||||
|
|
||||||
|
// $persetujuanPenawaran = PersetujuanPenawaran::create(
|
||||||
|
// ['penawaran_id' => $validated['penawaran_id']],
|
||||||
|
// $validated,
|
||||||
|
// );
|
||||||
|
|
||||||
|
$persetujuanPenawaran->fill($validated);
|
||||||
|
|
||||||
|
if ($request->hasFile('bukti_bayar')) {
|
||||||
|
$folderPath = 'persetujuan_penawaran/' . $validated['penawaran_id'];
|
||||||
|
$persetujuanPenawaran->bukti_bayar = $request->file('bukti_bayar')->store($folderPath, 'public');
|
||||||
|
}
|
||||||
|
|
||||||
|
$persetujuanPenawaran->save();
|
||||||
|
|
||||||
|
$permohonan->approve_bayar_by = null;
|
||||||
|
$permohonan->approve_bayar_at = null;
|
||||||
|
$permohonan->status = 'done';
|
||||||
|
$permohonan->save();
|
||||||
|
} else {
|
||||||
|
$persetujuanPenawaran = PersetujuanPenawaran::create(
|
||||||
|
$validated
|
||||||
|
);
|
||||||
|
|
||||||
|
$folderPath = 'persetujuan_penawaran/' . $validated['penawaran_id'];
|
||||||
|
|
||||||
|
if ($request->hasFile('bukti_bayar')) {
|
||||||
|
$persetujuanPenawaran->bukti_bayar = $request->file('bukti_bayar')->store($folderPath, 'public');
|
||||||
|
}
|
||||||
|
$persetujuanPenawaran->save();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update the status of the related permohonan to 'spk'
|
||||||
|
|
||||||
|
if ($permohonan) {
|
||||||
|
$permohonan->status_bayar = request()->get('status_bayar');
|
||||||
|
$permohonan->save();
|
||||||
|
|
||||||
|
// andy add, update status penawaran.status='spk'
|
||||||
|
// $penawaran = PenawaranTender::where('nomor_registrasi',$permohonan->nomor_registrasi)->first();
|
||||||
|
PenawaranTender::where('nomor_registrasi', $permohonan->nomor_registrasi)->update([
|
||||||
|
'status' => 'noc',
|
||||||
|
'updated_by' => Auth::id(),
|
||||||
|
'updated_at' => now(),
|
||||||
|
]);
|
||||||
|
// andy add, update status penawaran.status='spk'
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
return redirect()
|
||||||
|
->route('pembayaran.index')->with('success', 'Pembayaran berhasil disimpan.');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function update(Request $request, $id): JsonResponse
|
||||||
|
{
|
||||||
|
// init
|
||||||
|
$data = [];
|
||||||
|
$output = [];
|
||||||
|
$tindakan = null;
|
||||||
|
if (request()->ajax()) {
|
||||||
|
try {
|
||||||
|
$data = [
|
||||||
|
'approve_bayar_by' => Auth::id(),
|
||||||
|
'approve_bayar_at' => now(),
|
||||||
|
];
|
||||||
|
|
||||||
|
if ($request->keterangan) {
|
||||||
|
$data['approve_keterangan_bayar'] = $request->keterangan;
|
||||||
|
}
|
||||||
|
$output['data'] = $data;
|
||||||
|
|
||||||
|
// Update the status of the related permohonan to 'spk'
|
||||||
|
$permohonan = Permohonan::find($id);
|
||||||
|
|
||||||
|
if ($permohonan) {
|
||||||
|
|
||||||
|
if ($request->type === 'revisi') {
|
||||||
|
$data['status'] = 'revisi-pembayaran';
|
||||||
|
$data['status_bayar'] = 'belum_bayar';
|
||||||
|
} else {
|
||||||
|
$data['status_bayar'] = 'sudah_bayar';
|
||||||
|
$data['status'] = 'proses-laporan';
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($permohonan->jenis_penilaian_id == 2) {
|
||||||
|
if ($request->type === 'revisi') {
|
||||||
|
$data['status'] = 'revisi-pembayaran';
|
||||||
|
$data['status_bayar'] = 'belum_bayar';
|
||||||
|
} else {
|
||||||
|
$data['status_bayar'] = 'sudah_bayar';
|
||||||
|
$data['status'] = 'spk';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($permohonan->jenis_penilaian_id == 1) {
|
||||||
|
unset(
|
||||||
|
$data['approval_so'],
|
||||||
|
$data['approval_so_at'],
|
||||||
|
$data['approval_eo'],
|
||||||
|
$data['approval_eo_at'],
|
||||||
|
$data['approval_dd'],
|
||||||
|
$data['approval_dd_at'],
|
||||||
|
$data['keterangan']
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
$permohonan->update($data);
|
||||||
|
|
||||||
|
if ($permohonan->jenis_penilaian_id == 2 && $permohonan->status_bayar == 'sudah_bayar') {
|
||||||
|
PenawaranTender::where('nomor_registrasi', $permohonan->nomor_registrasi)->update([
|
||||||
|
'status' => 'spk',
|
||||||
|
'updated_by' => Auth::id(),
|
||||||
|
'updated_at' => now(),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$output['status'] = 'success';
|
||||||
|
$output['message'] = ['Otorisasi' . $permohonan->nomor_registrasi . 'berhasil di lakukan'];
|
||||||
|
} catch (Exception $e) {
|
||||||
|
$output['status'] = 'error';
|
||||||
|
$output['message'] = ['Otorisasi gagal di lakukan.'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return response()->json($output);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function dataForDatatables(Request $request)
|
||||||
|
{
|
||||||
|
if (is_null($this->user) || !$this->user->can('debitur.view')) {
|
||||||
|
// abort(403, 'Sorry! You are not allowed to view users.');
|
||||||
|
}
|
||||||
|
|
||||||
|
$query = Permohonan::query()->where(function ($query) {
|
||||||
|
$query->where(['status_bayar' => 'belum_bayar', 'jenis_penilaian_id' => 1])
|
||||||
|
->orWhere('status', 'revisi-pembayaran');
|
||||||
|
})
|
||||||
|
->where(function ($query) {
|
||||||
|
$query->whereNotIn('id', function ($subquery) {
|
||||||
|
$subquery->select('permohonan_id')
|
||||||
|
->from('persetujuan_penawaran')
|
||||||
|
->whereNotNull('permohonan_id');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
// Pencarian berdasarkan parameter search
|
||||||
|
if ($request->has('search') && !empty($request->get('search'))) {
|
||||||
|
$search = $request->get('search');
|
||||||
|
$query->where(function ($q) use ($search) {
|
||||||
|
$q->where('nomor_registrasi', 'LIKE', '%' . $search . '%');
|
||||||
|
$q->orWhere('tanggal_permohonan', 'LIKE', '%' . $search . '%');
|
||||||
|
$q->orWhereRelation('user', 'name', 'LIKE', '%' . $search . '%');
|
||||||
|
$q->orWhereRelation('debiture', 'name', 'LIKE', '%' . $search . '%');
|
||||||
|
$q->orWhereRelation('jenisPenilaian', 'name', 'LIKE', '%' . $search . '%');
|
||||||
|
$q->orWhereRelation('branch', 'name', 'LIKE', '%' . $search . '%');
|
||||||
|
$q->orWhere('status', 'LIKE', '%' . $search . '%');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// Sorting berdasarkan sortField dan sortOrder
|
||||||
|
if ($request->has('sortOrder') && !empty($request->get('sortOrder'))) {
|
||||||
|
$order = $request->get('sortOrder');
|
||||||
|
$column = $request->get('sortField');
|
||||||
|
$query->orderBy($column, $order);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Hitung total records
|
||||||
|
$totalRecords = $query->count();
|
||||||
|
|
||||||
|
// Pagination (default page size 10)
|
||||||
|
$size = $request->get('size', 10);
|
||||||
|
if ($size == 0) {
|
||||||
|
$size = 10;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($request->has('page') && $request->has('size')) {
|
||||||
|
$page = $request->get('page', 1);
|
||||||
|
$offset = ($page - 1) * $size;
|
||||||
|
|
||||||
|
$query->skip($offset)->take($size);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Filtered records
|
||||||
|
$filteredRecords = $query->count();
|
||||||
|
|
||||||
|
// Ambil data dengan relasi
|
||||||
|
$data = $query->with(['user', 'debiture', 'branch', 'jenisPenilaian'])->get();
|
||||||
|
|
||||||
|
|
||||||
|
// Hitung jumlah halaman
|
||||||
|
$pageCount = ceil($totalRecords / $size);
|
||||||
|
|
||||||
|
// Ambil current page
|
||||||
|
$currentPage = max(1, $request->get('page', 1));
|
||||||
|
|
||||||
|
// Return JSON response
|
||||||
|
return response()->json([
|
||||||
|
'draw' => $request->get('draw'),
|
||||||
|
'recordsTotal' => $totalRecords,
|
||||||
|
'recordsFiltered' => $filteredRecords,
|
||||||
|
'pageCount' => $pageCount,
|
||||||
|
'page' => $currentPage,
|
||||||
|
'totalCount' => $totalRecords,
|
||||||
|
'data' => $data,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
119
app/Http/Controllers/PemilikJaminanController.php
Normal file
119
app/Http/Controllers/PemilikJaminanController.php
Normal file
@@ -0,0 +1,119 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Modules\Lpj\Http\Controllers;
|
||||||
|
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use Exception;
|
||||||
|
use Modules\Location\Models\City;
|
||||||
|
use Modules\Location\Models\District;
|
||||||
|
use Modules\Location\Models\Province;
|
||||||
|
use Modules\Location\Models\Village;
|
||||||
|
use Modules\Lpj\Http\Requests\DokumenJaminanRequest;
|
||||||
|
use Modules\Lpj\Http\Requests\PemilikJaminanRequest;
|
||||||
|
use Modules\Lpj\Models\Debiture;
|
||||||
|
use Modules\Lpj\Models\DokumenJaminan;
|
||||||
|
use Modules\Lpj\Models\HubunganPemilikJaminan;
|
||||||
|
use Modules\Lpj\Models\PemilikJaminan;
|
||||||
|
|
||||||
|
class PemilikJaminanController extends Controller
|
||||||
|
{
|
||||||
|
public $user;
|
||||||
|
|
||||||
|
|
||||||
|
public function index($id)
|
||||||
|
{
|
||||||
|
$debitur = Debiture::find($id);
|
||||||
|
$pemilikJaminan = PemilikJaminan::where('debiture_id', $id)->get();
|
||||||
|
|
||||||
|
return view(
|
||||||
|
'lpj::debitur.edit',
|
||||||
|
compact('debitur', 'pemilikJaminan'),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function store(PemilikJaminanRequest $request, $id)
|
||||||
|
{
|
||||||
|
$validate = $request->validated();
|
||||||
|
if ($validate) {
|
||||||
|
try {
|
||||||
|
PemilikJaminan::create($validate);
|
||||||
|
|
||||||
|
if($request->get('from') == 'create-document'){
|
||||||
|
return redirect()->route('debitur.document.create', $id)->with('success', 'Pemilik Jaminan berhasil ditambahkan');
|
||||||
|
}
|
||||||
|
return redirect()->route('debitur.pemilik.index', $id)->with('success', 'Pemilik Jaminan berhasil ditambahkan');
|
||||||
|
} catch (Exception $e) {
|
||||||
|
return redirect()->route('debitur.pemilik.index', $id)->with('error', $e->getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function create($id)
|
||||||
|
{
|
||||||
|
$debitur = Debiture::find($id);
|
||||||
|
$provinces = Province::all();
|
||||||
|
$hubunganPemilik = HubunganPemilikJaminan::all();
|
||||||
|
|
||||||
|
return view(
|
||||||
|
'lpj::pemilik_jaminan.form',
|
||||||
|
compact('debitur', 'provinces', 'hubunganPemilik'),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function update(PemilikJaminanRequest $request, $id, $pemilik)
|
||||||
|
{
|
||||||
|
$validate = $request->validated();
|
||||||
|
|
||||||
|
if ($validate) {
|
||||||
|
try {
|
||||||
|
$pemilik = PemilikJaminan::find($pemilik);
|
||||||
|
$pemilik->update($validate);
|
||||||
|
|
||||||
|
if($request->get('from') == 'update-document'){
|
||||||
|
return redirect()->route('debitur.document.edit', [$id, $request->document])->with('success', 'Pemilik Jaminan berhasil diubah');
|
||||||
|
}
|
||||||
|
|
||||||
|
return redirect()->route('debitur.pemilik.index', $id)->with('success', 'Pemilik Jaminan berhasil diubah');
|
||||||
|
} catch (Exception $e) {
|
||||||
|
return redirect()->route('debitur.pemilik.index', $id)->with('error',$e->getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function edit($id, $pemilik)
|
||||||
|
{
|
||||||
|
$pemilik = PemilikJaminan::find($pemilik);
|
||||||
|
$debitur = Debiture::find($pemilik->debiture_id);
|
||||||
|
$provinces = Province::all();
|
||||||
|
$cities = City::where('province_code', $pemilik->province_code)->get();
|
||||||
|
$districts = District::where('city_code', $pemilik->city_code)->get();
|
||||||
|
$villages = Village::where('district_code', $pemilik->district_code)->get();
|
||||||
|
$hubunganPemilik = HubunganPemilikJaminan::all();
|
||||||
|
$detailSertifikat = $pemilik->detail_sertifikat;
|
||||||
|
|
||||||
|
return view(
|
||||||
|
'lpj::pemilik_jaminan.form',
|
||||||
|
compact(
|
||||||
|
'debitur',
|
||||||
|
'provinces',
|
||||||
|
'cities',
|
||||||
|
'districts',
|
||||||
|
'villages',
|
||||||
|
'hubunganPemilik',
|
||||||
|
'pemilik',
|
||||||
|
'detailSertifikat'
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function destroy($id, $pemilik_id)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
$jaminan = PemilikJaminan::find($pemilik_id);
|
||||||
|
$jaminan->delete();
|
||||||
|
echo json_encode(['success' => true, 'message' => 'Pemilik Jaminan deleted successfully']);
|
||||||
|
} catch (Exception $e) {
|
||||||
|
echo json_encode(['success' => false, 'message' => 'Failed to delete Pemilik Jaminan']);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
1765
app/Http/Controllers/PenilaiController.php
Normal file
1765
app/Http/Controllers/PenilaiController.php
Normal file
File diff suppressed because it is too large
Load Diff
1016
app/Http/Controllers/PenilaianController.php
Normal file
1016
app/Http/Controllers/PenilaianController.php
Normal file
File diff suppressed because it is too large
Load Diff
518
app/Http/Controllers/PermohonanController.php
Normal file
518
app/Http/Controllers/PermohonanController.php
Normal file
@@ -0,0 +1,518 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Modules\Lpj\Http\Controllers;
|
||||||
|
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use Exception;
|
||||||
|
use Illuminate\Http\JsonResponse;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Facades\Auth;
|
||||||
|
use Illuminate\Support\Facades\DB;
|
||||||
|
use Maatwebsite\Excel\Facades\Excel;
|
||||||
|
use Modules\Location\Models\City;
|
||||||
|
use Modules\Location\Models\District;
|
||||||
|
use Modules\Location\Models\Province;
|
||||||
|
use Modules\Location\Models\Village;
|
||||||
|
use Modules\Lpj\Exports\PermohonanExport;
|
||||||
|
use Modules\Lpj\Http\Requests\PermohonanRequest;
|
||||||
|
use Modules\Lpj\Models\Branch;
|
||||||
|
use Modules\Lpj\Models\Debiture;
|
||||||
|
use Modules\Lpj\Models\DokumenJaminan;
|
||||||
|
use Modules\Lpj\Models\JenisFasilitasKredit;
|
||||||
|
use Modules\Lpj\Models\NilaiPlafond;
|
||||||
|
use Modules\Lpj\Models\Penilaian;
|
||||||
|
use Modules\Lpj\Models\Permohonan;
|
||||||
|
use Modules\Lpj\Models\PermohonanPembatalan;
|
||||||
|
use Modules\Lpj\Models\StatusPermohonan;
|
||||||
|
use Modules\Lpj\Models\TujuanPenilaian;
|
||||||
|
use Modules\Lpj\Services\PermohonanHistoryService;
|
||||||
|
|
||||||
|
class PermohonanController extends Controller
|
||||||
|
{
|
||||||
|
public $user;
|
||||||
|
protected $historyService;
|
||||||
|
|
||||||
|
public function __construct(PermohonanHistoryService $historyService)
|
||||||
|
{
|
||||||
|
$this->historyService = $historyService;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function index()
|
||||||
|
{
|
||||||
|
return view('lpj::permohonan.index');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function store(PermohonanRequest $request)
|
||||||
|
{
|
||||||
|
$validate = $request->validated();
|
||||||
|
if ($validate) {
|
||||||
|
try {
|
||||||
|
// Process file upload
|
||||||
|
$filePath = null;
|
||||||
|
if ($request->hasFile('attachment')) {
|
||||||
|
$file = $request->file('attachment');
|
||||||
|
$fileName = time() . '_' . $file->getClientOriginalName();
|
||||||
|
$filePath = $file->storeAs('permohonan_attachments', $fileName, 'public');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get keterangan if provided
|
||||||
|
$keterangan = $request->input('keterangan') ?? null;
|
||||||
|
|
||||||
|
|
||||||
|
// Save to database
|
||||||
|
$permohonan = Permohonan::create($validate);
|
||||||
|
|
||||||
|
// Create history
|
||||||
|
$this->historyService->createHistory(
|
||||||
|
$permohonan,
|
||||||
|
$validate['status'],
|
||||||
|
$keterangan,
|
||||||
|
[], // beforeRequest is empty for new permohonan
|
||||||
|
$permohonan->toArray(),
|
||||||
|
$filePath,
|
||||||
|
);
|
||||||
|
|
||||||
|
$documents = DokumenJaminan::where('permohonan_id', $permohonan->id)->get();
|
||||||
|
if (count($documents) < 1) {
|
||||||
|
return redirect()->route(
|
||||||
|
'debitur.jaminan.create',
|
||||||
|
array_merge(['permohonan_id' => $permohonan->id], ['id' => $permohonan->debiture->id]),
|
||||||
|
)->with('success', 'Permohonan created successfully, Lengkapi data jaminan terlebih dahulu');
|
||||||
|
}
|
||||||
|
return redirect()
|
||||||
|
->route('permohonan.index')->with('success', 'Permohonan created successfully');
|
||||||
|
} catch (Exception $e) {
|
||||||
|
return redirect()
|
||||||
|
->route('permohonan.create')->with('error', 'Failed to create permohonan' . $e->getMessage());
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return redirect()
|
||||||
|
->route('permohonan.create')->with('success', 'error naon iye')->withInput();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function create()
|
||||||
|
{
|
||||||
|
return view('lpj::permohonan.create');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function createPermohonan($debitur)
|
||||||
|
{
|
||||||
|
$branches = Branch::all();
|
||||||
|
$debitur = Debiture::find($debitur);
|
||||||
|
$tujuanPenilaian = TujuanPenilaian::all();
|
||||||
|
$status = StatusPermohonan::all();
|
||||||
|
$fasilitasKredit = JenisFasilitasKredit::all();
|
||||||
|
$plafond = NilaiPlafond::all();
|
||||||
|
|
||||||
|
return view(
|
||||||
|
'lpj::permohonan.form',
|
||||||
|
compact('branches', 'debitur', 'tujuanPenilaian', 'status', 'fasilitasKredit', 'plafond'),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function edit($id)
|
||||||
|
{
|
||||||
|
$permohonan = Permohonan::find($id);
|
||||||
|
$branches = Branch::all();
|
||||||
|
$debitur = Debiture::find($permohonan->debiture_id);
|
||||||
|
$tujuanPenilaian = TujuanPenilaian::all();
|
||||||
|
$status = StatusPermohonan::all();
|
||||||
|
$provinces = Province::all();
|
||||||
|
$cities = City::where('province_code', $debitur->province_code)->get();
|
||||||
|
$districts = District::where('city_code', $debitur->city_code)->get();
|
||||||
|
$villages = Village::where('district_code', $debitur->district_code)->get();
|
||||||
|
$documents = DokumenJaminan::with('pemilik', 'detail')->where('debiture_id', $id)->get();
|
||||||
|
|
||||||
|
$fasilitasKredit = JenisFasilitasKredit::all();
|
||||||
|
$plafond = NilaiPlafond::all();
|
||||||
|
|
||||||
|
return view(
|
||||||
|
'lpj::permohonan.form',
|
||||||
|
compact(
|
||||||
|
'permohonan',
|
||||||
|
'branches',
|
||||||
|
'debitur',
|
||||||
|
'tujuanPenilaian',
|
||||||
|
'status',
|
||||||
|
'provinces',
|
||||||
|
'cities',
|
||||||
|
'districts',
|
||||||
|
'villages',
|
||||||
|
'documents',
|
||||||
|
'fasilitasKredit',
|
||||||
|
'plafond',
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function destroy($id)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
// Delete from database
|
||||||
|
$permohonan = Permohonan::find($id);
|
||||||
|
$permohonan->delete();
|
||||||
|
|
||||||
|
echo json_encode(['success' => true, 'message' => 'Permohonan deleted successfully']);
|
||||||
|
} catch (Exception $e) {
|
||||||
|
echo json_encode(['success' => false, 'message' => 'Failed to delete permohonan']);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function dataForDatatables(Request $request)
|
||||||
|
{
|
||||||
|
if (is_null($this->user) || !$this->user->can('debitur.view')) {
|
||||||
|
//abort(403, 'Sorry! You are not allowed to view users.');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Retrieve data from the database
|
||||||
|
$query = Permohonan::query();
|
||||||
|
|
||||||
|
if (!Auth::user()->hasAnyRole(['administrator'])) {
|
||||||
|
$query = $query->where('branch_id', Auth::user()->branch_id);
|
||||||
|
}
|
||||||
|
|
||||||
|
$query = $query->orderBy('nomor_registrasi', 'desc');
|
||||||
|
// Apply search filter if provided
|
||||||
|
if ($request->has('search') && !empty($request->get('search'))) {
|
||||||
|
$search = $request->get('search');
|
||||||
|
$query->where(function ($q) use ($search) {
|
||||||
|
$q->where('nomor_registrasi', 'LIKE', '%' . $search . '%');
|
||||||
|
$q->orWhere('mig_mst_lpj_nomor_jaminan', 'LIKE', '%' . $search . '%');
|
||||||
|
$q->orWhere('tanggal_permohonan', 'LIKE', '%' . $search . '%');
|
||||||
|
$q->orWhereRelation('user', 'name', 'LIKE', '%' . $search . '%');
|
||||||
|
$q->orWhereRelation('debiture', 'name', 'LIKE', '%' . $search . '%');
|
||||||
|
$q->orWhereRelation('tujuanPenilaian', 'name', 'LIKE', '%' . $search . '%');
|
||||||
|
$q->orWhereRelation('branch', 'name', 'LIKE', '%' . $search . '%');
|
||||||
|
$q->orWhere('status', 'LIKE', '%' . $search . '%');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// Apply sorting if provided
|
||||||
|
if ($request->has('sortOrder') && !empty($request->get('sortOrder'))) {
|
||||||
|
$order = $request->get('sortOrder');
|
||||||
|
$column = $request->get('sortField');
|
||||||
|
$query->orderBy($column, $order);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get the total count of records
|
||||||
|
$totalRecords = $query->count();
|
||||||
|
$size = $request->get('size', 10);
|
||||||
|
if ($size == 0) {
|
||||||
|
$size = 10;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Apply pagination if provided
|
||||||
|
if ($request->has('page') && $request->has('size')) {
|
||||||
|
$page = $request->get('page');
|
||||||
|
$size = $request->get('size');
|
||||||
|
$offset = ($page - 1) * $size; // Calculate the offset
|
||||||
|
|
||||||
|
$query->skip($offset)->take($size);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get the filtered count of records
|
||||||
|
$filteredRecords = $query->count();
|
||||||
|
|
||||||
|
// Get the data for the current page
|
||||||
|
$data = $query->get();
|
||||||
|
|
||||||
|
$data = $data->map(function ($item) {
|
||||||
|
return [
|
||||||
|
'id' => $item->id,
|
||||||
|
'nomor_registrasi' => $item->nomor_registrasi,
|
||||||
|
'mig_mst_lpj_nomor_jaminan' => $item->mig_mst_lpj_nomor_jaminan,
|
||||||
|
'tanggal_permohonan' => $item->tanggal_permohonan ? dateFormat(
|
||||||
|
$item->tanggal_permohonan,
|
||||||
|
) : null,
|
||||||
|
'pemohon' => $item->user->name ?? 'N/A',
|
||||||
|
'branch' => $item->branch->name ?? 'N/A',
|
||||||
|
'debiture' => [
|
||||||
|
'name' => $item->debiture->name,
|
||||||
|
],
|
||||||
|
'tujuan_penilaian' => [
|
||||||
|
'code' => $item->tujuanPenilaian->code ?? null,
|
||||||
|
'name' => $item->tujuanPenilaian->name ?? null,
|
||||||
|
],
|
||||||
|
'status' => $item->status,
|
||||||
|
'documents' => count($item->documents),
|
||||||
|
'keterangan' => $item->keterangan,
|
||||||
|
'penilaian' => [
|
||||||
|
'id' => $item->penilaian->id ?? null,
|
||||||
|
'waktu_penilaian' => $item->penilaian->waktu_penilaian ?? null,
|
||||||
|
'rejected_note' => $item->penilaian->rejected_note ?? null,
|
||||||
|
'authorized_status' => $item->penilaian->authorized_status ?? null,
|
||||||
|
],
|
||||||
|
'registrasi_catatan' => $item->registrasi_catatan,
|
||||||
|
];
|
||||||
|
});
|
||||||
|
|
||||||
|
// Calculate the page count
|
||||||
|
$pageCount = ceil($totalRecords / $size);
|
||||||
|
|
||||||
|
// Calculate the current page number
|
||||||
|
$currentPage = max(1, $request->get('page', 1));
|
||||||
|
|
||||||
|
// Return the response data as a JSON object
|
||||||
|
return response()->json([
|
||||||
|
'draw' => $request->get('draw'),
|
||||||
|
'recordsTotal' => $totalRecords,
|
||||||
|
'recordsFiltered' => $filteredRecords,
|
||||||
|
'pageCount' => $pageCount,
|
||||||
|
'page' => $currentPage,
|
||||||
|
'totalCount' => $totalRecords,
|
||||||
|
'data' => $data,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function export()
|
||||||
|
{
|
||||||
|
return Excel::download(new PermohonanExport(), 'permohonan.xlsx');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function authorization()
|
||||||
|
{
|
||||||
|
return view('lpj::permohonan.authorization.index');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function dataForAuthorization(Request $request)
|
||||||
|
{
|
||||||
|
if (is_null($this->user) || !$this->user->can('debitur.view')) {
|
||||||
|
//abort(403, 'Sorry! You are not allowed to view users.');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Retrieve data from the database
|
||||||
|
$query = Permohonan::query()->with('documents')->has('documents', '>', 0)->where('status', '=', 'order');
|
||||||
|
|
||||||
|
if (!Auth::user()->hasAnyRole(['administrator'])) {
|
||||||
|
$query = $query->where('branch_id', Auth::user()->branch_id);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Apply search filter if provided
|
||||||
|
if ($request->has('search') && !empty($request->get('search'))) {
|
||||||
|
$search = $request->get('search');
|
||||||
|
$query->where(function ($q) use ($search) {
|
||||||
|
$q->where('nomor_registrasi', 'LIKE', '%' . $search . '%');
|
||||||
|
$q->orWhere('tanggal_permohonan', 'LIKE', '%' . $search . '%');
|
||||||
|
$q->orWhereRelation('user', 'name', 'LIKE', '%' . $search . '%');
|
||||||
|
$q->orWhereRelation('debiture', 'name', 'LIKE', '%' . $search . '%');
|
||||||
|
$q->orWhereRelation('tujuanPenilaian', 'name', 'LIKE', '%' . $search . '%');
|
||||||
|
$q->orWhereRelation('branch', 'name', 'LIKE', '%' . $search . '%');
|
||||||
|
$q->orWhere('status', 'LIKE', '%' . $search . '%');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// Apply sorting if provided
|
||||||
|
if ($request->has('sortOrder') && !empty($request->get('sortOrder'))) {
|
||||||
|
$order = $request->get('sortOrder');
|
||||||
|
$column = $request->get('sortField');
|
||||||
|
$query->orderBy($column, $order);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get the total count of records
|
||||||
|
$totalRecords = $query->count();
|
||||||
|
|
||||||
|
// Apply pagination if provided
|
||||||
|
if ($request->has('page') && $request->has('size')) {
|
||||||
|
$page = $request->get('page');
|
||||||
|
$size = $request->get('size');
|
||||||
|
$offset = ($page - 1) * $size; // Calculate the offset
|
||||||
|
|
||||||
|
$query->skip($offset)->take($size);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get the filtered count of records
|
||||||
|
$filteredRecords = $query->count();
|
||||||
|
|
||||||
|
// Get the data for the current page
|
||||||
|
$data = $query->with(['user', 'debiture', 'branch', 'tujuanPenilaian'])->get();
|
||||||
|
|
||||||
|
// Calculate the page count
|
||||||
|
$pageCount = ceil($totalRecords / $request->get('size'));
|
||||||
|
|
||||||
|
// Calculate the current page number
|
||||||
|
$currentPage = 0 + 1;
|
||||||
|
|
||||||
|
// Return the response data as a JSON object
|
||||||
|
return response()->json([
|
||||||
|
'draw' => $request->get('draw'),
|
||||||
|
'recordsTotal' => $totalRecords,
|
||||||
|
'recordsFiltered' => $filteredRecords,
|
||||||
|
'pageCount' => $pageCount,
|
||||||
|
'page' => $currentPage,
|
||||||
|
'totalCount' => $totalRecords,
|
||||||
|
'data' => $data,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function showAuthorization($id)
|
||||||
|
{
|
||||||
|
$permohonan = Permohonan::find($id);
|
||||||
|
return view('lpj::permohonan.authorization.show', compact('permohonan'));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function updateAuthorization(Request $request, $id)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
$permohonan = Permohonan::find($id);
|
||||||
|
$permohonan->status = $request->status;
|
||||||
|
$permohonan->keterangan = $request->keterangan;
|
||||||
|
$permohonan->save();
|
||||||
|
} catch (Exception $e) {
|
||||||
|
return redirect()->route('authorization.show', $id)->with('error', 'Failed to update permohonan');
|
||||||
|
}
|
||||||
|
|
||||||
|
return redirect()->route('authorization.index')->with('success', 'Permohonan updated successfully');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function show($id)
|
||||||
|
{
|
||||||
|
$permohonan = Permohonan::find($id);
|
||||||
|
|
||||||
|
return view('lpj::permohonan.show', compact('permohonan'));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function print($id)
|
||||||
|
{
|
||||||
|
$permohonan = Permohonan::find($id);
|
||||||
|
return view('lpj::permohonan.print', compact('permohonan'));
|
||||||
|
|
||||||
|
// $pdf = Pdf::loadView('lpj::permohonan.print', compact('permohonan'));
|
||||||
|
// return $pdf->stream();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function showPembatalan($id)
|
||||||
|
{
|
||||||
|
$permohonan = Permohonan::with(['pembatalan', 'debiture'])->findOrFail($id);
|
||||||
|
return view('lpj::permohonan.pembatalan-form', compact('permohonan'));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function pembatalan(Request $request)
|
||||||
|
{
|
||||||
|
// Validate the request
|
||||||
|
$validatedData = $request->validate([
|
||||||
|
'permohonan_id' => 'required|exists:permohonan,id',
|
||||||
|
'alasan_pembatalan' => 'required|string',
|
||||||
|
'file_pembatalan' => 'required|file|mimes:pdf,doc,docx|max:2048',
|
||||||
|
]);
|
||||||
|
|
||||||
|
// Handle file upload
|
||||||
|
if ($request->hasFile('file_pembatalan')) {
|
||||||
|
$file = $request->file('file_pembatalan');
|
||||||
|
$filename = time() . '_' . $file->getClientOriginalName();
|
||||||
|
$filePath = $file->storeAs('pembatalan', $filename, 'public');
|
||||||
|
$validatedData['file_pembatalan'] = $filePath;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add created_by
|
||||||
|
$validatedData['created_by'] = auth()->id();
|
||||||
|
|
||||||
|
// Create new PermohonanPembatalan
|
||||||
|
$pembatalan = PermohonanPembatalan::create($validatedData);
|
||||||
|
|
||||||
|
return redirect()->route('permohonan.index')->with('success', 'Pembatalan Permohonan Menunggu Approval');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function storeAproved(Request $request, $id)
|
||||||
|
: JsonResponse {
|
||||||
|
$data = [];
|
||||||
|
if (request()->ajax()) {
|
||||||
|
try {
|
||||||
|
$penilaian = Penilaian::findOrFail($id);
|
||||||
|
$penilaian->update([
|
||||||
|
'authorized_status' => 1,
|
||||||
|
]);
|
||||||
|
|
||||||
|
$permohonan = Permohonan::findOrFail($request->permohonan_id);
|
||||||
|
|
||||||
|
$permohonan->update([
|
||||||
|
'status' => 'proses-survey',
|
||||||
|
]);
|
||||||
|
|
||||||
|
$data['status'] = 'success';
|
||||||
|
$data['message'] = 'Jadwal ' . $request->noReg . ' berhasil di aprove';
|
||||||
|
} catch (Exception $e) {
|
||||||
|
$data['status'] = 'error';
|
||||||
|
$data['message'] = 'Gagal membuat jadwal: ' . $e->getMessage();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$data['status'] = 'error';
|
||||||
|
$data['message'] = "no ajax request";
|
||||||
|
}
|
||||||
|
|
||||||
|
return response()->json($data);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function update(PermohonanRequest $request, $id)
|
||||||
|
{
|
||||||
|
$permohonan = Permohonan::findOrFail($id);
|
||||||
|
$beforeRequest = $permohonan->toArray();
|
||||||
|
|
||||||
|
$validate = $request->validated();
|
||||||
|
if ($validate) {
|
||||||
|
try {
|
||||||
|
// Update in database
|
||||||
|
|
||||||
|
if ($permohonan->status == 'revisi') {
|
||||||
|
$validate['status'] = 'order';
|
||||||
|
}
|
||||||
|
$permohonan->update($validate);
|
||||||
|
|
||||||
|
$documents = DokumenJaminan::where('permohonan_id', $permohonan->id)->get();
|
||||||
|
if (count($documents) < 1) {
|
||||||
|
return redirect()->route(
|
||||||
|
'debitur.jaminan.create',
|
||||||
|
array_merge(['permohonan_id' => $permohonan->id], ['id' => $permohonan->debiture->id]),
|
||||||
|
)->with('success', 'Permohonan created successfully, Lengkapi data jaminan terlebih dahulu');
|
||||||
|
}
|
||||||
|
|
||||||
|
return redirect()
|
||||||
|
->route('permohonan.index')->with('success', 'Permohonan updated successfully');
|
||||||
|
} catch (Exception $e) {
|
||||||
|
return redirect()
|
||||||
|
->route('permohonan.edit', $id)->with('error', 'Failed to update permohonan');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function storeRescheduleSurvey(Request $request, $id)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
$validatedData = $request->validate([
|
||||||
|
'permohonan_id' => 'required|exists:permohonan,id',
|
||||||
|
'penilaian_id' => 'nullable',
|
||||||
|
'nomor_registrasi' => 'required',
|
||||||
|
'reschedule_note' => 'required',
|
||||||
|
'reschedule_date' => 'required',
|
||||||
|
'keterangan' => 'required',
|
||||||
|
]);
|
||||||
|
|
||||||
|
DB::beginTransaction();
|
||||||
|
|
||||||
|
$permohonan = Permohonan::findOrFail($request->permohonan_id);
|
||||||
|
$permohonan->update([
|
||||||
|
'status' => 'request-reschedule',
|
||||||
|
]);
|
||||||
|
|
||||||
|
$penilaian = Penilaian::findOrFail($id);
|
||||||
|
|
||||||
|
$penilaian->update([
|
||||||
|
'reschedule_date' => $request->reschedule_date,
|
||||||
|
'reschedule_note' => $request->reschedule_note,
|
||||||
|
]);
|
||||||
|
|
||||||
|
DB::commit();
|
||||||
|
return response()->json([
|
||||||
|
'status' => 'success',
|
||||||
|
'message' => 'Proses request reschedule permohonan Nomor registrasi ' . $request->nomor_registrasi . ' berhasil',
|
||||||
|
]);
|
||||||
|
} catch (Exception $e) {
|
||||||
|
DB::rollBack();
|
||||||
|
return response()->json([
|
||||||
|
'status' => 'error',
|
||||||
|
'message' => 'Gagal membuat request reschedule: ' . $e->getMessage(),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
256
app/Http/Controllers/PersetujuanPenawaranController.php
Normal file
256
app/Http/Controllers/PersetujuanPenawaranController.php
Normal file
@@ -0,0 +1,256 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Modules\Lpj\Http\Controllers;
|
||||||
|
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Facades\Auth;
|
||||||
|
use Modules\Lpj\Http\Requests\PersetujuanPenawaranRequest;
|
||||||
|
use Modules\Lpj\Models\Noc;
|
||||||
|
use Modules\Lpj\Models\PenawaranDetailTender;
|
||||||
|
use Modules\Lpj\Models\PenawaranDetailTenderLog;
|
||||||
|
use Modules\Lpj\Models\PenawaranTender;
|
||||||
|
use Modules\Lpj\Models\Permohonan;
|
||||||
|
use Modules\Lpj\Models\PersetujuanPenawaran;
|
||||||
|
|
||||||
|
class PersetujuanPenawaranController extends Controller
|
||||||
|
{
|
||||||
|
public $user;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Display a listing of the resource.
|
||||||
|
*/
|
||||||
|
public function index()
|
||||||
|
{
|
||||||
|
$persetujuanPenawarans = PersetujuanPenawaran::all();
|
||||||
|
return view('lpj::persetujuan_penawaran.index', compact('persetujuanPenawarans'));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Store a newly created resource in storage.
|
||||||
|
*/
|
||||||
|
/**
|
||||||
|
* Store a newly created resource in storage.
|
||||||
|
*/
|
||||||
|
/**
|
||||||
|
* Store a newly created resource in storage.
|
||||||
|
*/
|
||||||
|
public function store(PersetujuanPenawaranRequest $request)
|
||||||
|
{
|
||||||
|
$validated = $request->validated();
|
||||||
|
$validated['created_by'] = Auth::id();
|
||||||
|
$validated['status'] = '0';
|
||||||
|
|
||||||
|
$persetujuanPenawaran = PersetujuanPenawaran::updateOrCreate(
|
||||||
|
['penawaran_id' => $validated['penawaran_id']],
|
||||||
|
$validated,
|
||||||
|
);
|
||||||
|
|
||||||
|
$folderPath = 'persetujuan_penawaran/' . $validated['penawaran_id'];
|
||||||
|
|
||||||
|
if ($request->hasFile('file_persetujuan_penawaran')) {
|
||||||
|
$persetujuanPenawaran->file_persetujuan_penawaran = $request->file('file_persetujuan_penawaran')->store(
|
||||||
|
$folderPath,
|
||||||
|
'public',
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($request->hasFile('surat_representasi')) {
|
||||||
|
$persetujuanPenawaran->surat_representasi = $request->file('surat_representasi')->store(
|
||||||
|
$folderPath,
|
||||||
|
'public',
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($request->hasFile('bukti_bayar')) {
|
||||||
|
$persetujuanPenawaran->bukti_bayar = $request->file('bukti_bayar')->store($folderPath, 'public');
|
||||||
|
}
|
||||||
|
|
||||||
|
$persetujuanPenawaran->save();
|
||||||
|
|
||||||
|
|
||||||
|
// Save NOC
|
||||||
|
try {
|
||||||
|
$noc = Noc::updateOrCreate([
|
||||||
|
'permohonan_id' => $persetujuanPenawaran->permohonan_id,
|
||||||
|
'persetujuan_penawaran_id' => $persetujuanPenawaran->id
|
||||||
|
],[
|
||||||
|
'bukti_bayar' => $persetujuanPenawaran->bukti_bayar,
|
||||||
|
]);
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
\Log::error('Failed to create or update NOC: ' . $e->getMessage());
|
||||||
|
return redirect()
|
||||||
|
->route('persetujuan-penawaran.index')
|
||||||
|
->with('error', 'Persetujuan Penawaran berhasil disimpan tetapi gagal membuat NOC: ' . $e->getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
return redirect()
|
||||||
|
->route('persetujuan-penawaran.index')->with('success', 'Persetujuan Penawaran berhasil disimpan.');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update the specified resource in storage.
|
||||||
|
*/
|
||||||
|
public function update(PersetujuanPenawaranRequest $request, PersetujuanPenawaran $persetujuanPenawaran)
|
||||||
|
{
|
||||||
|
$validated = $request->validated();
|
||||||
|
$validated['updated_by'] = Auth::id();
|
||||||
|
|
||||||
|
$persetujuanPenawaran->update($validated);
|
||||||
|
|
||||||
|
return redirect()
|
||||||
|
->route('persetujuan-penawaran.index')->with('success', 'Persetujuan Penawaran updated successfully');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show the form for creating a new resource.
|
||||||
|
*/
|
||||||
|
public function create()
|
||||||
|
{
|
||||||
|
return view('lpj::persetujuan_penawaran.create');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Display the specified resource.
|
||||||
|
*/
|
||||||
|
public function show($id)
|
||||||
|
{
|
||||||
|
$permohonan = Permohonan::find($id);
|
||||||
|
$permohonan->status = 'tender';
|
||||||
|
$dataDetailPenawaranLog = [];
|
||||||
|
|
||||||
|
// andy add update status penawaran
|
||||||
|
// update detail_penawaran => detail_penawaran.status = 1 (untuk all KJPP)
|
||||||
|
// update penawaran => penawaran.status ="tender", penawaran.updated_at, penawaran.updated_by
|
||||||
|
// update permohonan => permohonan.status ="tender", permohonan.updated_at, permohonan.updated_by
|
||||||
|
// insert detail_permohonan_log
|
||||||
|
$penawaran = PenawaranTender::where('nomor_registrasi', $permohonan->nomor_registrasi)->first();
|
||||||
|
// dd($penawaran->id);
|
||||||
|
PenawaranDetailTender::where('penawaran_id', $penawaran->id)->update([
|
||||||
|
'status' => 1,
|
||||||
|
'updated_by' => Auth::id(),
|
||||||
|
'updated_at' => now(),
|
||||||
|
]);
|
||||||
|
|
||||||
|
PenawaranTender::where('id', $penawaran->id)->update([
|
||||||
|
'status' => 'tender',
|
||||||
|
'updated_by' => Auth::id(),
|
||||||
|
'updated_at' => now(),
|
||||||
|
]);
|
||||||
|
|
||||||
|
$detailPenawaran = PenawaranDetailTender::where('penawaran_id', $penawaran->id)->distinct()->get();
|
||||||
|
|
||||||
|
// log
|
||||||
|
if (sizeof($detailPenawaran) > 0) {
|
||||||
|
foreach ($detailPenawaran as $model) {
|
||||||
|
array_push($dataDetailPenawaranLog, [
|
||||||
|
'detail_penawaran_id' => $model->id,
|
||||||
|
'kjpp_rekanan_id' => $model->kjpp_rekanan_id,
|
||||||
|
'penawaran_id' => $model->penawaran_id,
|
||||||
|
'no_proposal' => $model->no_proposal,
|
||||||
|
'tgl_proposal' => $model->tgl_proposal,
|
||||||
|
'biaya_penawaran' => $model->biaya_penawaran,
|
||||||
|
'attachment' => $model->attachment,
|
||||||
|
'dokumen_persetujuan' => $model->dokumen_persetujuan,
|
||||||
|
'status' => $model->status,
|
||||||
|
'authorized_status' => $model->authorized_status,
|
||||||
|
'authorized_at' => $model->authorized_at,
|
||||||
|
'authorized_at' => $model->authorized_at,
|
||||||
|
'created_at' => $model->created_at,
|
||||||
|
'updated_at' => $model->updated_at,
|
||||||
|
'deleted_at' => $model->deleted_at,
|
||||||
|
'created_by' => $model->created_by,
|
||||||
|
'updated_by' => $model->updated_by,
|
||||||
|
'deleted_by' => $model->deleted_by,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
PenawaranDetailTenderLog::insert($dataDetailPenawaranLog);
|
||||||
|
}
|
||||||
|
// log
|
||||||
|
// andy add update status penawaran
|
||||||
|
|
||||||
|
return $permohonan->save();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show the form for editing the specified resource.
|
||||||
|
*/
|
||||||
|
public function edit($id)
|
||||||
|
{
|
||||||
|
$permohonan = Permohonan::with(['debiture', 'penawaranTender.detail'])->find($id);
|
||||||
|
|
||||||
|
return view('lpj::persetujuan_penawaran.form', compact('permohonan'));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove the specified resource from storage.
|
||||||
|
*/
|
||||||
|
public function destroy(PersetujuanPenawaran $persetujuanPenawaran)
|
||||||
|
{
|
||||||
|
$persetujuanPenawaran->delete();
|
||||||
|
|
||||||
|
return redirect()
|
||||||
|
->route('persetujuan-penawaran.index')->with('success', 'Persetujuan Penawaran deleted successfully');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function dataForDatatables(Request $request)
|
||||||
|
{
|
||||||
|
if (is_null($this->user) || !$this->user->can('persetujuan_penawaran.view')) {
|
||||||
|
//abort(403, 'Sorry! You are not allowed to view persetujuan penawaran.');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Retrieve data from the database
|
||||||
|
$query = Permohonan::query()->where(['status' => 'persetujuan-penawaran']);
|
||||||
|
|
||||||
|
// Apply search filter if provided
|
||||||
|
if ($request->has('search') && !empty($request->get('search'))) {
|
||||||
|
$search = $request->get('search');
|
||||||
|
$query->where(function ($q) use ($search) {
|
||||||
|
$q->where('nomor_registrasi', 'LIKE', "%$search%");
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// Apply sorting if provided
|
||||||
|
if ($request->has('sortOrder') && !empty($request->get('sortOrder'))) {
|
||||||
|
$order = $request->get('sortOrder');
|
||||||
|
$column = $request->get('sortField');
|
||||||
|
$query->orderBy($column, $order);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get the total count of records
|
||||||
|
$totalRecords = $query->count();
|
||||||
|
|
||||||
|
// Apply pagination if provided
|
||||||
|
if ($request->has('page') && $request->has('size')) {
|
||||||
|
$page = $request->get('page');
|
||||||
|
$size = $request->get('size');
|
||||||
|
$offset = ($page - 1) * $size; // Calculate the offset
|
||||||
|
|
||||||
|
$query->skip($offset)->take($size);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get the filtered count of records
|
||||||
|
$filteredRecords = $query->count();
|
||||||
|
|
||||||
|
// Get the data for the current page
|
||||||
|
$data = $query->with(['debiture', 'penawaranTender.detail', 'penawaranTender.persetujuan'])->get();
|
||||||
|
|
||||||
|
// Calculate the page count
|
||||||
|
$pageCount = ceil($totalRecords / $request->get('size'));
|
||||||
|
|
||||||
|
// Calculate the current page number
|
||||||
|
$currentPage = $request->get('page', 1);
|
||||||
|
|
||||||
|
// Return the response data as a JSON object
|
||||||
|
return response()->json([
|
||||||
|
'draw' => $request->get('draw'),
|
||||||
|
'recordsTotal' => $totalRecords,
|
||||||
|
'recordsFiltered' => $filteredRecords,
|
||||||
|
'pageCount' => $pageCount,
|
||||||
|
'page' => $currentPage,
|
||||||
|
'totalCount' => $totalRecords,
|
||||||
|
'data' => $data,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
1032
app/Http/Controllers/ProsesPenawaranController.php
Normal file
1032
app/Http/Controllers/ProsesPenawaranController.php
Normal file
File diff suppressed because it is too large
Load Diff
373
app/Http/Controllers/ProsesPenawaranUlangController.php
Normal file
373
app/Http/Controllers/ProsesPenawaranUlangController.php
Normal file
@@ -0,0 +1,373 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Modules\Lpj\Http\Controllers;
|
||||||
|
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Http\Response;
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use Exception;
|
||||||
|
use Maatwebsite\Excel\Facades\Excel;
|
||||||
|
use Illuminate\Http\JsonResponse;
|
||||||
|
use Illuminate\Support\Facades\Validator;
|
||||||
|
use Illuminate\Support\Facades\Auth;
|
||||||
|
use Illuminate\Support\Facades\Storage;
|
||||||
|
use Illuminate\Support\Facades\DB;
|
||||||
|
use Modules\Lpj\Models\KJPP;
|
||||||
|
use Modules\Lpj\Models\PenawaranDetailTender;
|
||||||
|
use Modules\Lpj\Models\PenawaranDetailTenderLog;
|
||||||
|
use Modules\Lpj\Models\PenawaranTender;
|
||||||
|
|
||||||
|
use Modules\Lpj\Models\Permohonan;
|
||||||
|
|
||||||
|
class ProsesPenawaranUlangController extends Controller
|
||||||
|
{
|
||||||
|
public $user;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Display a listing of the resource.
|
||||||
|
*/
|
||||||
|
public function index()
|
||||||
|
{
|
||||||
|
return view('lpj::prosespenawaranulang.index');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function dataForDatatables(Request $request)
|
||||||
|
{
|
||||||
|
if (is_null($this->user) || !$this->user->can('debitur.view')) {
|
||||||
|
//abort(403, 'Sorry! You are not allowed to view users.');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Retrieve data from the database
|
||||||
|
$query =PenawaranTender::query()
|
||||||
|
->select('penawaran.*',DB::raw("CONCAT(DATE_FORMAT(penawaran.start_date, '%d %M %Y'), ' - ', DATE_FORMAT(penawaran.end_date, '%d %M %Y')) AS date_range"), 'tujuan_penilaian_kjpp.name as tujuan_penilaian_kjpp_name')
|
||||||
|
->leftJoin('tujuan_penilaian_kjpp', 'tujuan_penilaian_kjpp.id','=','penawaran.tujuan_penilaian_kjpp_id')
|
||||||
|
->where('penawaran.status','=','proposal-tender')
|
||||||
|
->withCount('penawarandetails');
|
||||||
|
|
||||||
|
// Apply search filter if provided
|
||||||
|
if ($request->has('search') && !empty($request->get('search'))) {
|
||||||
|
$search = $request->get('search');
|
||||||
|
$query->where(function ($q) use ($search) {
|
||||||
|
$q->where('nomor_registrasi', 'LIKE', '%' . $search . '%');
|
||||||
|
$q->orWhere('tanggal_permohonan', 'LIKE', '%' . $search . '%');
|
||||||
|
|
||||||
|
$q->orWhere('status', 'LIKE', '%' . $search . '%');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// Apply sorting if provided
|
||||||
|
if ($request->has('sortOrder') && !empty($request->get('sortOrder'))) {
|
||||||
|
$order = $request->get('sortOrder');
|
||||||
|
$column = $request->get('sortField');
|
||||||
|
$query->orderBy($column, $order);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get the total count of records
|
||||||
|
$totalRecords = $query->count();
|
||||||
|
|
||||||
|
// Apply pagination if provided
|
||||||
|
if ($request->has('page') && $request->has('size')) {
|
||||||
|
$page = $request->get('page');
|
||||||
|
$size = $request->get('size');
|
||||||
|
$offset = ($page - 1) * $size; // Calculate the offset
|
||||||
|
|
||||||
|
$query->skip($offset)->take($size);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get the filtered count of records
|
||||||
|
$filteredRecords = $query->count();
|
||||||
|
|
||||||
|
// Get the data for the current page
|
||||||
|
//$data = $query->with(['user', 'debiture', 'branch', 'tujuanPenilaian'])->get();
|
||||||
|
$data = $query->get();
|
||||||
|
|
||||||
|
// Calculate the page count
|
||||||
|
$pageCount = ceil($totalRecords / $request->get('size'));
|
||||||
|
|
||||||
|
// Calculate the current page number
|
||||||
|
$currentPage = 0 + 1;
|
||||||
|
|
||||||
|
// Return the response data as a JSON object
|
||||||
|
return response()->json([
|
||||||
|
'draw' => $request->get('draw'),
|
||||||
|
'recordsTotal' => $totalRecords,
|
||||||
|
'recordsFiltered' => $filteredRecords,
|
||||||
|
'pageCount' => $pageCount,
|
||||||
|
'page' => $currentPage,
|
||||||
|
'totalCount' => $totalRecords,
|
||||||
|
'data' => $data
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function edit($id)
|
||||||
|
{
|
||||||
|
return view('lpj::prosespenawaranulang.edit', compact('id'));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function show($id)
|
||||||
|
{
|
||||||
|
$prosespenawaran = PenawaranTender::find($id);
|
||||||
|
return view('lpj::prosespenawaranulang.show', compact('id','prosespenawaran'));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setData(Request $request): JsonResponse
|
||||||
|
{
|
||||||
|
$data = array();
|
||||||
|
$penawaran = array();
|
||||||
|
$penawrandetails = array();
|
||||||
|
|
||||||
|
if (request()->ajax()) {
|
||||||
|
$id = $request->id;
|
||||||
|
$penawaran = PenawaranTender::with('permohonan.debiture')->where('status','=','proposal-tender')->find($id);
|
||||||
|
|
||||||
|
if ($penawaran) {
|
||||||
|
$penawrandetails = PenawaranDetailTender::where('penawaran_id','=',$id)
|
||||||
|
->leftJoin('kjpp', 'kjpp.id', '=', 'detail_penawaran.kjpp_rekanan_id')
|
||||||
|
->select('detail_penawaran.*', 'kjpp.code AS kjpp_code', 'kjpp.name AS kjpp_name')
|
||||||
|
->where('detail_penawaran.status','=',1)
|
||||||
|
->get();
|
||||||
|
|
||||||
|
$i=0;
|
||||||
|
foreach($penawrandetails as $obj)
|
||||||
|
{
|
||||||
|
if($obj->dokumen_persetujuan && Storage::disk('public')->exists($obj->dokumen_persetujuan))
|
||||||
|
{
|
||||||
|
$penawrandetails_path = Storage::url($obj->dokumen_persetujuan);
|
||||||
|
$penawrandetails[$i]['dokumen_persetujuan']=$penawrandetails_path;
|
||||||
|
}
|
||||||
|
$i++;
|
||||||
|
}
|
||||||
|
|
||||||
|
$penawaranString = "";
|
||||||
|
if($penawaran->status)
|
||||||
|
{
|
||||||
|
$penawaranString = convertSlug($penawaran->status);
|
||||||
|
$penawaran->status = $penawaranString;
|
||||||
|
}
|
||||||
|
|
||||||
|
$data['penawaran'] = $penawaran;
|
||||||
|
$data['penawrandetails'] = $penawrandetails;
|
||||||
|
$data['status'] = 'success';
|
||||||
|
$data['message']['message_success'] = array("data successfully found");
|
||||||
|
} else {
|
||||||
|
$data['status'] = 'error';
|
||||||
|
$data['penawaran'] = null;
|
||||||
|
$data['penawrandetails'] = null;
|
||||||
|
$data['message']['message_data'] = array("data not found");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$data['status'] = 'error';
|
||||||
|
$data['message']['message_ajax'] = array("no ajax request");
|
||||||
|
}
|
||||||
|
|
||||||
|
return response()->json($data);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function update(Request $request, $id): JsonResponse
|
||||||
|
{
|
||||||
|
// init
|
||||||
|
$data = array();
|
||||||
|
$dataDetailPenawaranLog = array();
|
||||||
|
$dataDetailPenawaran = array();
|
||||||
|
$pleaseCommit= true;
|
||||||
|
if (request()->ajax()) {
|
||||||
|
$validator = ProsesPenawaranUlangController::rulesEditnya($request, $id);
|
||||||
|
|
||||||
|
if ($validator['fails']) {
|
||||||
|
$data['message'] = $validator['errors'];
|
||||||
|
$data['status'] = 'error';
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// cek masa aktif penawaran
|
||||||
|
$detailpenawaran = PenawaranDetailTender::find($id);
|
||||||
|
$checkActiveDateRange = checkActiveDateRangePenawaran($detailpenawaran->penawaran_id);
|
||||||
|
// cek masa aktif penawaran
|
||||||
|
if($checkActiveDateRange)
|
||||||
|
{
|
||||||
|
DB::beginTransaction();
|
||||||
|
try {
|
||||||
|
|
||||||
|
$dataDetailPenawaranLog = [
|
||||||
|
'detail_penawaran_id' =>$detailpenawaran->id,
|
||||||
|
'kjpp_rekanan_id' =>$detailpenawaran->kjpp_rekanan_id,
|
||||||
|
'penawaran_id' =>$detailpenawaran->penawaran_id,
|
||||||
|
'biaya_penawaran' =>$detailpenawaran->biaya_penawaran,
|
||||||
|
'attachment' =>$detailpenawaran->attachment,
|
||||||
|
'dokumen_persetujuan' =>$detailpenawaran->dokumen_persetujuan,
|
||||||
|
'status' =>$detailpenawaran->status,
|
||||||
|
'authorized_status' =>$detailpenawaran->authorized_status,
|
||||||
|
'authorized_at' =>$detailpenawaran->authorized_at,
|
||||||
|
'authorized_at' =>$detailpenawaran->authorized_at,
|
||||||
|
'created_at' =>$detailpenawaran->created_at,
|
||||||
|
'updated_at' =>$detailpenawaran->updated_at,
|
||||||
|
'deleted_at' =>$detailpenawaran->deleted_at,
|
||||||
|
'created_by' =>$detailpenawaran->created_by,
|
||||||
|
'updated_by' =>$detailpenawaran->updated_by,
|
||||||
|
'deleted_by' =>$detailpenawaran->deleted_by
|
||||||
|
|
||||||
|
];
|
||||||
|
|
||||||
|
PenawaranDetailTenderLog::create($dataDetailPenawaranLog);
|
||||||
|
|
||||||
|
$biaya_penawaran="";
|
||||||
|
if($request->biaya_penawaran)
|
||||||
|
$biaya_penawaran= str_replace(".","",$request->biaya_penawaran);
|
||||||
|
$dataDetailPenawaran = ['updated_by' => Auth::id(),
|
||||||
|
'updated_at' => now(),
|
||||||
|
'biaya_penawaran' => $biaya_penawaran
|
||||||
|
];
|
||||||
|
|
||||||
|
if ($request->hasFile('dokumen_persetujuan'))
|
||||||
|
{
|
||||||
|
$file_tmp = $request->file('dokumen_persetujuan');
|
||||||
|
$folderPath = 'uploads/penawaran/';
|
||||||
|
if ($file_tmp->isValid())
|
||||||
|
{
|
||||||
|
$myFile=$file_tmp->getClientOriginalName(); // nama file with extension
|
||||||
|
$file_name = pathinfo($myFile, PATHINFO_FILENAME); // nama file without extension
|
||||||
|
|
||||||
|
$extension = $file_tmp->getClientOriginalExtension();
|
||||||
|
// kjppID_penawaranID_namaFile_userID_time
|
||||||
|
$newFileName = $request->kjpp_rekanan_id.'_'.$id.'_'.$file_name.'_'.Auth::user()->id."_".time() .'.'. $extension;
|
||||||
|
Storage::disk('public')->put($folderPath.'/'.$newFileName,file_get_contents($file_tmp));
|
||||||
|
|
||||||
|
$newFileNameWithPath = $folderPath . $newFileName;
|
||||||
|
$dataDetailPenawaran['attachment'] = $myFile;
|
||||||
|
$dataDetailPenawaran['dokumen_persetujuan'] = $newFileNameWithPath;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$pleaseCommit=false;
|
||||||
|
$data['status'] = 'error';
|
||||||
|
$data['message']['check_file_jenis'] = array("Silahkan upload file pdf");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$data['status'] = 'error';
|
||||||
|
$data['message']['check_file'] = array("Silahkan upload file");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
$detailpenawaran->update($dataDetailPenawaran);
|
||||||
|
|
||||||
|
if($pleaseCommit)
|
||||||
|
{
|
||||||
|
DB::commit();
|
||||||
|
|
||||||
|
$data['id'] = $id;
|
||||||
|
$data['detailpenawaran'] = $detailpenawaran;
|
||||||
|
$data['status'] = 'success';
|
||||||
|
$data['message']['message_success'] = array('Proses Penawarn KJPP Ulang successfully');
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
DB::rollBack();
|
||||||
|
$data['status'] = 'error';
|
||||||
|
$data['message']['message_error'] = array("Proses Penawarn KJPP Ulang failed..");
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch (Exception $e) {
|
||||||
|
DB::rollBack();
|
||||||
|
$data['status'] = 'error';
|
||||||
|
$data['message']['message_error_try_catch'] = array('Proses Penawarn KJPP Ulang failed.');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$data['status'] = 'error';
|
||||||
|
$data['message']['active_date_range'] = array("Penawaran sudah di tutup");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
$data['status'] = 'error';
|
||||||
|
$data['message']['message_ajax'] = array("no ajax request");
|
||||||
|
}
|
||||||
|
|
||||||
|
return response()->json($data);
|
||||||
|
}
|
||||||
|
|
||||||
|
// delete KJPP di detail_penawaran (status di buat 0)
|
||||||
|
public function updateKJPPStatus(Request $request, $id): JsonResponse
|
||||||
|
{
|
||||||
|
// init
|
||||||
|
$data = array();
|
||||||
|
$dataku = array();
|
||||||
|
$dataDetailPenawaranLog = array();
|
||||||
|
|
||||||
|
DB::beginTransaction();
|
||||||
|
try {
|
||||||
|
$model = PenawaranDetailTender::findOrFail($id);
|
||||||
|
|
||||||
|
// log
|
||||||
|
$dataDetailPenawaranLog = [
|
||||||
|
'detail_penawaran_id' =>$model->id,
|
||||||
|
'kjpp_rekanan_id' =>$model->kjpp_rekanan_id,
|
||||||
|
'penawaran_id' =>$model->penawaran_id,
|
||||||
|
'biaya_penawaran' =>$model->biaya_penawaran,
|
||||||
|
'attachment' =>$model->attachment,
|
||||||
|
'dokumen_persetujuan' =>$model->dokumen_persetujuan,
|
||||||
|
'status' =>0,
|
||||||
|
'authorized_status' =>$model->authorized_status,
|
||||||
|
'authorized_at' =>$model->authorized_at,
|
||||||
|
'authorized_at' =>$model->authorized_at,
|
||||||
|
'created_at' =>$model->created_at,
|
||||||
|
'updated_at' =>$model->updated_at,
|
||||||
|
'deleted_at' =>$model->deleted_at,
|
||||||
|
'created_by' =>$model->created_by,
|
||||||
|
'updated_by' =>$model->updated_by,
|
||||||
|
'deleted_by' =>$model->deleted_by
|
||||||
|
|
||||||
|
];
|
||||||
|
|
||||||
|
PenawaranDetailTenderLog::create($dataDetailPenawaranLog);
|
||||||
|
// log
|
||||||
|
|
||||||
|
$data['id']=$id;
|
||||||
|
|
||||||
|
$dataku = ['status' => '0',
|
||||||
|
'updated_by' => Auth::id(),
|
||||||
|
'updated_at' => now()
|
||||||
|
];
|
||||||
|
|
||||||
|
$model->update($dataku);
|
||||||
|
|
||||||
|
DB::commit();
|
||||||
|
$data['status'] = 'success';
|
||||||
|
$data['message']['message_success'] = array('Sukses delete Penawaran KJPP '.$request->kjppName);
|
||||||
|
} catch (Exception $e) {
|
||||||
|
DB::rollBack();
|
||||||
|
// dd($e);
|
||||||
|
$data['status'] = 'error';
|
||||||
|
$data['message']['message_error_try_catch'] = array("Gagal delete Penawaran KJPP ".$request->kjppName);
|
||||||
|
}
|
||||||
|
return response()->json($data);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function rulesEditnya($request, $id)
|
||||||
|
{
|
||||||
|
$validateIt = [
|
||||||
|
// 'name' diambil dari definisi parameter yang di kirim pada POST Data
|
||||||
|
'biaya_penawaran' => 'required',
|
||||||
|
'dokumen_persetujuan' => 'required|file|mimes:pdf'
|
||||||
|
];
|
||||||
|
|
||||||
|
$messageIt = [
|
||||||
|
'biaya_penawaran.required' => 'Silahkan isi Biaya Penawaran',
|
||||||
|
'dokumen_persetujuan.required' => 'Silahkan isi dokumen',
|
||||||
|
'dokumen_persetujuan.file' => 'Silahkan isi file',
|
||||||
|
'dokumen_persetujuan.mimes' => 'Silahkan upload pdf'
|
||||||
|
];
|
||||||
|
|
||||||
|
$validator = Validator::make($request->all(), $validateIt, $messageIt);
|
||||||
|
|
||||||
|
$data['fails'] = $validator->fails();
|
||||||
|
$data['errors'] = $validator->errors();
|
||||||
|
|
||||||
|
return $data;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
164
app/Http/Controllers/RegionController.php
Normal file
164
app/Http/Controllers/RegionController.php
Normal file
@@ -0,0 +1,164 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Modules\Lpj\Http\Controllers;
|
||||||
|
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use Illuminate\Http\RedirectResponse;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Http\Response;
|
||||||
|
use Modules\Lpj\Models\Regions;
|
||||||
|
use Modules\Lpj\Http\Requests\RegionRequest;
|
||||||
|
use Maatwebsite\Excel\Facades\Excel;
|
||||||
|
use Modules\Lpj\Exports\RegionExport;
|
||||||
|
|
||||||
|
|
||||||
|
class RegionController extends Controller
|
||||||
|
{
|
||||||
|
public $user;
|
||||||
|
public function index()
|
||||||
|
{
|
||||||
|
return view('lpj::region.index');
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Show the form for creating a new resource.
|
||||||
|
*/
|
||||||
|
public function create()
|
||||||
|
{
|
||||||
|
return view('lpj::region.create');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Store a newly created resource in storage.
|
||||||
|
*/
|
||||||
|
public function store(RegionRequest $request)
|
||||||
|
{
|
||||||
|
$validate = $request->validated();
|
||||||
|
|
||||||
|
if ($validate) {
|
||||||
|
try {
|
||||||
|
// Save to database
|
||||||
|
Regions::create($validate);
|
||||||
|
return redirect()
|
||||||
|
->route('basicdata.region.index')
|
||||||
|
->with('success', 'region created successfully');
|
||||||
|
} catch (Exception $e) {
|
||||||
|
return redirect()
|
||||||
|
->route('basicdata.region.create')
|
||||||
|
->with('error', 'Failed to create region');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public function edit($id)
|
||||||
|
{
|
||||||
|
$region = Regions::find($id);
|
||||||
|
return view('lpj::region.create', compact('region'));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update the specified resource in storage.
|
||||||
|
*/
|
||||||
|
public function update(RegionRequest $request, $id)
|
||||||
|
{
|
||||||
|
$validate = $request->validated();
|
||||||
|
|
||||||
|
if ($validate) {
|
||||||
|
try {
|
||||||
|
// Update in database
|
||||||
|
$region = Regions::find($id);
|
||||||
|
$region->update($validate);
|
||||||
|
return redirect()
|
||||||
|
->route('basicdata.region.index')
|
||||||
|
->with('success', 'Region updated successfully');
|
||||||
|
} catch (Exception $e) {
|
||||||
|
return redirect()
|
||||||
|
->route('basicdata.region.edit', $id)
|
||||||
|
->with('error', 'Failed to update region');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove the specified resource from storage.
|
||||||
|
*/
|
||||||
|
public function destroy($id)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
// Delete from database
|
||||||
|
$region = Regions::find($id);
|
||||||
|
$region->delete();
|
||||||
|
|
||||||
|
echo json_encode(['success' => true, 'message' => 'Region deleted successfully']);
|
||||||
|
} catch (Exception $e) {
|
||||||
|
echo json_encode(['success' => false, 'message' => 'Failed to delete region']);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function dataForDatatables(Request $request)
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
if (is_null($this->user) || !$this->user->can('region.view')) {
|
||||||
|
//abort(403, 'Sorry! You are not allowed to view users.');
|
||||||
|
}
|
||||||
|
|
||||||
|
$query = Regions::query();
|
||||||
|
|
||||||
|
if ($request->has('search') && !empty($request->get('search'))) {
|
||||||
|
$search = $request->get('search');
|
||||||
|
$query->where(function ($q) use ($search) {
|
||||||
|
$q->where('code', 'LIKE', "%$search%");
|
||||||
|
$q->orWhere('name', 'LIKE', "%$search%");
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if($request->has('sortOrder') && !empty($request->get('sortOrder'))){
|
||||||
|
$order = $request->get('sortOrder');
|
||||||
|
$column = $request->get('sortField');
|
||||||
|
$query->orderBy($column, $order);
|
||||||
|
}
|
||||||
|
|
||||||
|
$totalRecords = $query->count();
|
||||||
|
|
||||||
|
// Apply pagination if provided
|
||||||
|
if ($request->has('page') && $request->has('size')) {
|
||||||
|
$page = $request->get('page');
|
||||||
|
$size = $request->get('size');
|
||||||
|
$offset = ($page - 1) * $size; // Calculate the offset
|
||||||
|
|
||||||
|
$query->skip($offset)->take($size);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get the filtered count of records
|
||||||
|
$filteredRecords = $query->count();
|
||||||
|
|
||||||
|
// Get the data for the current page
|
||||||
|
$data = $query->get();
|
||||||
|
|
||||||
|
// Calculate the page count
|
||||||
|
$pageCount = ceil($totalRecords / $request->get('size'));
|
||||||
|
|
||||||
|
// Calculate the current page number
|
||||||
|
$currentPage = 0 + 1;
|
||||||
|
|
||||||
|
// dump($data);
|
||||||
|
|
||||||
|
// Return the response data as a JSON object
|
||||||
|
return response()->json([
|
||||||
|
'draw' => $request->get('draw'),
|
||||||
|
'recordsTotal' => $totalRecords,
|
||||||
|
'recordsFiltered' => $filteredRecords,
|
||||||
|
'pageCount' => $pageCount,
|
||||||
|
'page' => $currentPage,
|
||||||
|
'totalCount' => $totalRecords,
|
||||||
|
'data' => $data
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function export()
|
||||||
|
{
|
||||||
|
return Excel::download(new RegionExport, 'region.xlsx');
|
||||||
|
}
|
||||||
|
}
|
||||||
265
app/Http/Controllers/RegistrasiController.php
Normal file
265
app/Http/Controllers/RegistrasiController.php
Normal file
@@ -0,0 +1,265 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Modules\Lpj\Http\Controllers;
|
||||||
|
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use Exception;
|
||||||
|
use Illuminate\Http\JsonResponse;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Facades\Auth;
|
||||||
|
use Illuminate\Support\Facades\Validator;
|
||||||
|
use Maatwebsite\Excel\Facades\Excel;
|
||||||
|
use Modules\Lpj\Models\Debiture;
|
||||||
|
use Modules\Lpj\Models\DokumenJaminan;
|
||||||
|
use Modules\Lpj\Models\JenisPenilaian;
|
||||||
|
use Modules\Lpj\Models\Penilai;
|
||||||
|
use Modules\Lpj\Models\Permohonan;
|
||||||
|
use Modules\Lpj\Models\Regions;
|
||||||
|
|
||||||
|
class RegistrasiController extends Controller
|
||||||
|
{
|
||||||
|
public $user;
|
||||||
|
|
||||||
|
public function index()
|
||||||
|
{
|
||||||
|
return view('lpj::registrasi.index');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function dataForDatatables(Request $request)
|
||||||
|
{
|
||||||
|
if (is_null($this->user) || !$this->user->can('debitur.view')) {
|
||||||
|
//abort(403, 'Sorry! You are not allowed to view users.');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Retrieve data from the database
|
||||||
|
$query = Permohonan::query()
|
||||||
|
->whereIn('status', ['preregister', 'revisi']);
|
||||||
|
|
||||||
|
|
||||||
|
// Apply search filter if provided
|
||||||
|
if ($request->has('search') && !empty($request->get('search'))) {
|
||||||
|
$search = $request->get('search');
|
||||||
|
$query->where(function ($q) use ($search) {
|
||||||
|
$q->where('nomor_registrasi', 'LIKE', '%' . $search . '%');
|
||||||
|
$q->orWhere('tanggal_permohonan', 'LIKE', '%' . $search . '%');
|
||||||
|
$q->orWhereRelation('user', 'name', 'LIKE', '%' . $search . '%');
|
||||||
|
$q->orWhereRelation('debiture', 'name', 'LIKE', '%' . $search . '%');
|
||||||
|
$q->orWhereRelation('tujuanPenilaian', 'name', 'LIKE', '%' . $search . '%');
|
||||||
|
$q->orWhereRelation('branch', 'name', 'LIKE', '%' . $search . '%');
|
||||||
|
$q->orWhere('status', 'LIKE', '%' . $search . '%');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// Apply sorting if provided
|
||||||
|
if ($request->has('sortOrder') && !empty($request->get('sortOrder'))) {
|
||||||
|
$order = $request->get('sortOrder');
|
||||||
|
$column = $request->get('sortField');
|
||||||
|
$query->orderBy($column, $order);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get the total count of records
|
||||||
|
$totalRecords = $query->count();
|
||||||
|
|
||||||
|
// Apply pagination if provided
|
||||||
|
if ($request->has('page') && $request->has('size')) {
|
||||||
|
$page = $request->get('page');
|
||||||
|
$size = $request->get('size');
|
||||||
|
$offset = ($page - 1) * $size; // Calculate the offset
|
||||||
|
|
||||||
|
$query->skip($offset)->take($size);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get the filtered count of records
|
||||||
|
$filteredRecords = $query->count();
|
||||||
|
|
||||||
|
// Get the data for the current page
|
||||||
|
$data = $query->with(['user', 'debiture', 'branch', 'tujuanPenilaian'])->get();
|
||||||
|
|
||||||
|
// Calculate the page count
|
||||||
|
$pageCount = ceil($totalRecords / $request->get('size'));
|
||||||
|
|
||||||
|
// Calculate the current page number
|
||||||
|
$currentPage = 0 + 1;
|
||||||
|
|
||||||
|
// Return the response data as a JSON object
|
||||||
|
return response()->json([
|
||||||
|
'draw' => $request->get('draw'),
|
||||||
|
'recordsTotal' => $totalRecords,
|
||||||
|
'recordsFiltered' => $filteredRecords,
|
||||||
|
'pageCount' => $pageCount,
|
||||||
|
'page' => $currentPage,
|
||||||
|
'totalCount' => $totalRecords,
|
||||||
|
'data' => $data,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function edit($id)
|
||||||
|
{
|
||||||
|
return view('lpj::registrasi.edit', compact('id'));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setData(Request $request)
|
||||||
|
: JsonResponse
|
||||||
|
{
|
||||||
|
$data = [];
|
||||||
|
$datas = [];
|
||||||
|
|
||||||
|
if (request()->ajax()) {
|
||||||
|
$id = $request->id;
|
||||||
|
$datas = Permohonan::find($id);
|
||||||
|
|
||||||
|
if ($datas) {
|
||||||
|
$jenisPenilaians = null;
|
||||||
|
$regions = null;
|
||||||
|
$regions = Regions::pluck('name', 'id');
|
||||||
|
$jenisPenilaians = JenisPenilaian::pluck('name', 'id');
|
||||||
|
|
||||||
|
$data['status'] = 'success';
|
||||||
|
$data['regions'] = $regions;
|
||||||
|
$data['jenisPenilaians'] = $jenisPenilaians;
|
||||||
|
$data['datas'] = $datas;
|
||||||
|
$data['message'] ['message_success'] = ["data successfully found"];
|
||||||
|
} else {
|
||||||
|
$data['status'] = 'error';
|
||||||
|
$data['datas'] = null;
|
||||||
|
$data['message'] ['message_data'] = ["data not found"];
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$data['status'] = 'error';
|
||||||
|
$data['message']['message_ajax'] = ["no ajax request"];
|
||||||
|
}
|
||||||
|
|
||||||
|
return response()->json($data);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function show($id)
|
||||||
|
{
|
||||||
|
$permohonan = Permohonan::find($id);
|
||||||
|
$debitur = Debiture::find($permohonan->debiture_id);
|
||||||
|
$documents = DokumenJaminan::with('pemilik', 'detail')->where('permohonan_id', $id)->get();
|
||||||
|
return view('lpj::registrasi.show', compact('id', 'permohonan', 'documents', 'debitur'));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function storeRevisi(Request $request, $id)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
$permohonan = Permohonan::find($id);
|
||||||
|
|
||||||
|
$permohonan->update([
|
||||||
|
'status' => 'registered'
|
||||||
|
]);
|
||||||
|
|
||||||
|
return redirect()->route('registrasi.index')->with('success', 'Submit Revision successfully');
|
||||||
|
} catch (Exception $e) {
|
||||||
|
return redirect()
|
||||||
|
->route('registrasi.index')
|
||||||
|
->with('error', 'Failed to create permohonan' . $e->getMessage());
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function update(Request $request, $id)
|
||||||
|
: JsonResponse
|
||||||
|
{
|
||||||
|
// init
|
||||||
|
$data = [];
|
||||||
|
$dataku = [];
|
||||||
|
$tindakan = null;
|
||||||
|
if (request()->ajax()) {
|
||||||
|
$validator = RegistrasiController::rulesEditnya($request, $id);
|
||||||
|
|
||||||
|
if ($validator['fails']) {
|
||||||
|
$data['message'] = $validator['errors'];
|
||||||
|
$data['status'] = 'error';
|
||||||
|
} else {
|
||||||
|
try {
|
||||||
|
$tindakan = $request->tindakan;
|
||||||
|
$dataku = [
|
||||||
|
'registrasi_by' => Auth::id(),
|
||||||
|
'registrasi_at' => now(),
|
||||||
|
];
|
||||||
|
|
||||||
|
if ($tindakan == 0) {
|
||||||
|
$dataku['jenis_penilaian_id'] = $request->jenis_penilaian;
|
||||||
|
$dataku['region_id'] = $request->region;
|
||||||
|
$dataku['status'] = 'registered';
|
||||||
|
if ($request->catatan2) {
|
||||||
|
$dataku['registrasi_catatan'] = $request->catatan2;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$dataku['registrasi_catatan'] = $request->catatan;
|
||||||
|
$dataku['status'] = 'revisi';
|
||||||
|
}
|
||||||
|
|
||||||
|
$data['dataku'] = $dataku;
|
||||||
|
|
||||||
|
$modal = Permohonan::find($id);
|
||||||
|
|
||||||
|
$modal->update($dataku);
|
||||||
|
|
||||||
|
if ($modal && $request->jenis_laporan) {
|
||||||
|
foreach ($modal->documents as $document) {
|
||||||
|
Penilai::updateOrCreate(
|
||||||
|
[
|
||||||
|
'permohonan_id' => $id,
|
||||||
|
'dokument_id' => $document->id
|
||||||
|
],
|
||||||
|
['type' => $request->jenis_laporan]
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//
|
||||||
|
$data['status'] = 'success';
|
||||||
|
$data['message'] ['message_success'] = ['Regitrasi ' . $modal->nomor_registrasi . ' successfully'];
|
||||||
|
} catch (Exception $e) {
|
||||||
|
$data['status'] = 'error';
|
||||||
|
$data['message'] ['message_try_catch'] = ['Regitrasi updated failed.'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$data['status'] = 'error';
|
||||||
|
$data['message'] ['message_ajax'] = ["no ajax request"];
|
||||||
|
}
|
||||||
|
|
||||||
|
return response()->json($data);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function rulesEditnya($request, $id)
|
||||||
|
{
|
||||||
|
$tindakan = null;
|
||||||
|
$jenis_penilaian = null;
|
||||||
|
$validate_catatan = '';
|
||||||
|
$tindakan = $request->tindakan;
|
||||||
|
$jenis_penilaian = $request->jenis_penilaian;
|
||||||
|
|
||||||
|
$validateIt = [
|
||||||
|
// 'name' diambil dari definisi parameter yang di kirim pada POST Data
|
||||||
|
'tindakan' => 'required',
|
||||||
|
];
|
||||||
|
|
||||||
|
$messageIt = [
|
||||||
|
'tindakan.required' => 'Silahkan pilih Tindakan',
|
||||||
|
];
|
||||||
|
|
||||||
|
if ($tindakan == 0) {
|
||||||
|
$validateIt['jenis_penilaian'] = ['required'];
|
||||||
|
$messageIt ['jenis_penilaian.required'] = 'Silahkan pilih Jenis Penilaian';
|
||||||
|
|
||||||
|
// INTERNAL
|
||||||
|
if (1 == $jenis_penilaian) {
|
||||||
|
$validateIt['region'] = ['required'];
|
||||||
|
$messageIt ['region.required'] = 'Silahkan pilih Region';
|
||||||
|
}
|
||||||
|
} else if ($tindakan == 1) {
|
||||||
|
$validateIt['catatan'] = ['required'];
|
||||||
|
$messageIt ['catatan.required'] = 'Silahkan isi Catatan';
|
||||||
|
}
|
||||||
|
|
||||||
|
$validator = Validator::make($request->all(), $validateIt, $messageIt);
|
||||||
|
|
||||||
|
$data['fails'] = $validator->fails();
|
||||||
|
$data['errors'] = $validator->errors();
|
||||||
|
|
||||||
|
return $data;
|
||||||
|
}
|
||||||
|
}
|
||||||
279
app/Http/Controllers/RegistrasiFinalController.php
Normal file
279
app/Http/Controllers/RegistrasiFinalController.php
Normal file
@@ -0,0 +1,279 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Modules\Lpj\Http\Controllers;
|
||||||
|
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use Carbon\Carbon;
|
||||||
|
use Exception;
|
||||||
|
use Illuminate\Http\JsonResponse;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Facades\Auth;
|
||||||
|
use Illuminate\Support\Facades\DB;
|
||||||
|
use Illuminate\Support\Facades\Storage;
|
||||||
|
use Illuminate\Support\Facades\Validator;
|
||||||
|
use Maatwebsite\Excel\Facades\Excel;
|
||||||
|
use Modules\Lpj\Models\PenawaranTender;
|
||||||
|
use Modules\Lpj\Models\Permohonan;
|
||||||
|
use Modules\Lpj\Models\Regions;
|
||||||
|
|
||||||
|
// use Modules\Location\Models\City;
|
||||||
|
// use Modules\Location\Models\District;
|
||||||
|
// use Modules\Location\Models\Province;
|
||||||
|
// use Modules\Location\Models\Village;
|
||||||
|
// use Modules\Lpj\Exports\DebitureExport;
|
||||||
|
// use Modules\Lpj\Http\Requests\DebitureRequest;
|
||||||
|
// use Modules\Lpj\Http\Requests\DokumenJaminanRequest;
|
||||||
|
// use Modules\Lpj\Models\Branch;
|
||||||
|
// use Modules\Lpj\Models\Debiture;
|
||||||
|
// use Modules\Lpj\Models\DokumenJaminan;
|
||||||
|
// use Modules\Lpj\Models\JenisJaminan;
|
||||||
|
// use Modules\Lpj\Models\JenisLegalitasJaminan;
|
||||||
|
// use Modules\Lpj\Models\PemilikJaminan;
|
||||||
|
|
||||||
|
class RegistrasiFinalController extends Controller
|
||||||
|
{
|
||||||
|
public $user;
|
||||||
|
|
||||||
|
public function index()
|
||||||
|
{
|
||||||
|
return view('lpj::registrasifinal.index');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function dataForDatatables(Request $request)
|
||||||
|
{
|
||||||
|
if (is_null($this->user) || !$this->user->can('debitur.view')) {
|
||||||
|
//abort(403, 'Sorry! You are not allowed to view users.');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Retrieve data from the database
|
||||||
|
$query =PenawaranTender::query()
|
||||||
|
->select('penawaran.*', 'tujuan_penilaian_kjpp.name as tujuan_penilaian_kjpp_name')
|
||||||
|
->leftJoin('tujuan_penilaian_kjpp', 'tujuan_penilaian_kjpp.id','=','penawaran.tujuan_penilaian_kjpp_id')
|
||||||
|
->where('penawaran.status','=','spk')
|
||||||
|
->withCount('penawarandetails');
|
||||||
|
|
||||||
|
// Apply search filter if provided
|
||||||
|
if ($request->has('search') && !empty($request->get('search'))) {
|
||||||
|
$search = $request->get('search');
|
||||||
|
$query->where(function ($q) use ($search) {
|
||||||
|
$q->where('nomor_registrasi', 'LIKE', '%' . $search . '%');
|
||||||
|
//$q->orWhere('tanggal_permohonan', 'LIKE', '%' . $search . '%');
|
||||||
|
//$q->orWhere('status', 'LIKE', '%' . $search . '%');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// Apply sorting if provided
|
||||||
|
if ($request->has('sortOrder') && !empty($request->get('sortOrder'))) {
|
||||||
|
$order = $request->get('sortOrder');
|
||||||
|
$column = $request->get('sortField');
|
||||||
|
$query->orderBy($column, $order);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get the total count of records
|
||||||
|
$totalRecords = $query->count();
|
||||||
|
|
||||||
|
// Apply pagination if provided
|
||||||
|
if ($request->has('page') && $request->has('size')) {
|
||||||
|
$page = $request->get('page');
|
||||||
|
$size = $request->get('size');
|
||||||
|
$offset = ($page - 1) * $size; // Calculate the offset
|
||||||
|
|
||||||
|
$query->skip($offset)->take($size);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get the filtered count of records
|
||||||
|
$filteredRecords = $query->count();
|
||||||
|
|
||||||
|
// Get the data for the current page
|
||||||
|
//$data = $query->with(['user', 'debiture', 'branch', 'tujuanPenilaian'])->get();
|
||||||
|
$data = $query->with(['permohonan.debiture'])->get();
|
||||||
|
// dd($data);
|
||||||
|
$i = 0;
|
||||||
|
foreach ($data as $obj) {
|
||||||
|
if ($obj->tanggal_penilaian_sebelumnya) {
|
||||||
|
$data[$i]->tanggal_penilaian_sebelumnya = Carbon::parse($obj->tanggal_penilaian_sebelumnya)->format(
|
||||||
|
'd F Y H:i:s',
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($obj->biaya_kjpp_sebelumnya) {
|
||||||
|
$data[$i]->biaya_kjpp_sebelumnya = formatRupiah($obj->biaya_kjpp_sebelumnya);
|
||||||
|
}
|
||||||
|
|
||||||
|
// date_range
|
||||||
|
if ($obj->start_date && $obj->end_date) {
|
||||||
|
$data[$i]->date_range = Carbon::parse($obj->start_date)->format('d M Y') . ' - ' . Carbon::parse(
|
||||||
|
$obj->end_date,
|
||||||
|
)->format('d M Y');
|
||||||
|
}
|
||||||
|
|
||||||
|
$i++;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Calculate the page count
|
||||||
|
$pageCount = ceil($totalRecords / $request->get('size'));
|
||||||
|
|
||||||
|
// Calculate the current page number
|
||||||
|
$currentPage = 0 + 1;
|
||||||
|
|
||||||
|
// Return the response data as a JSON object
|
||||||
|
return response()->json([
|
||||||
|
'draw' => $request->get('draw'),
|
||||||
|
'recordsTotal' => $totalRecords,
|
||||||
|
'recordsFiltered' => $filteredRecords,
|
||||||
|
'pageCount' => $pageCount,
|
||||||
|
'page' => $currentPage,
|
||||||
|
'totalCount' => $totalRecords,
|
||||||
|
'data' => $data,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function show($id)
|
||||||
|
{
|
||||||
|
$permohonan = Permohonan::find($id);
|
||||||
|
$document = PenawaranTender::where('nomor_registrasi','=',$permohonan->nomor_registrasi)->first();
|
||||||
|
if ($document) {
|
||||||
|
$pdfSPK_path = Storage::url($document->spk_dokumen_path);
|
||||||
|
$permohonan->pdfSPK_path = '| <a download href="' . $pdfSPK_path . '" class="badge badge-sm badge-outline" target="_blank">Dokumen SPK.pdf <i class="ki-filled ki-cloud-download"></i></a>';
|
||||||
|
}
|
||||||
|
|
||||||
|
return view('lpj::registrasifinal.show', compact('id', 'permohonan'));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function edit($id)
|
||||||
|
{
|
||||||
|
$doc_pdf='';
|
||||||
|
$permohonan = Permohonan::find($id);
|
||||||
|
$document = PenawaranTender::where('nomor_registrasi','=',$permohonan->nomor_registrasi)->first();
|
||||||
|
if ($document) {
|
||||||
|
$pdfSPK_path = Storage::url($document->spk_dokumen_path);
|
||||||
|
$doc_pdf = '<a download href="' . $pdfSPK_path . '" class="badge badge-sm badge-outline" target="_blank">Dokumen SPK.pdf <i class="ki-filled ki-cloud-download"></i></a>';
|
||||||
|
}
|
||||||
|
|
||||||
|
return view('lpj::registrasifinal.edit', compact('id','doc_pdf'));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setData(Request $request)
|
||||||
|
: JsonResponse {
|
||||||
|
$data = [];
|
||||||
|
$datas = [];
|
||||||
|
|
||||||
|
if (request()->ajax()) {
|
||||||
|
$id = $request->id;
|
||||||
|
$datas = Permohonan::find($id);
|
||||||
|
|
||||||
|
if ($datas) {
|
||||||
|
$penawaran = null;
|
||||||
|
$regions = null;
|
||||||
|
$regions = Regions::pluck('name', 'id');
|
||||||
|
$penawaran = PenawaranTender::where('nomor_registrasi', '=', $datas->nomor_registrasi)->first();
|
||||||
|
|
||||||
|
$penawaranString = "";
|
||||||
|
if ($penawaran->status) {
|
||||||
|
$penawaranString = convertSlug($penawaran->status);
|
||||||
|
$penawaran->status = $penawaranString;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($datas->dokumen) {
|
||||||
|
$pdfSPK_path = Storage::url($datas->dokumen);
|
||||||
|
$datas->dokumen = $pdfSPK_path;
|
||||||
|
}
|
||||||
|
|
||||||
|
$data['status'] = 'success';
|
||||||
|
$data['regions'] = $regions;
|
||||||
|
$data['penawaran'] = $penawaran;
|
||||||
|
$data['datas'] = $datas;
|
||||||
|
$data['message']['message_success'] = ["data successfully found"];
|
||||||
|
} else {
|
||||||
|
$data['status'] = 'error';
|
||||||
|
$data['datas'] = null;
|
||||||
|
$data['message']['message_data'] = ["data not found"];
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$data['status'] = 'error';
|
||||||
|
$data['message']['message_ajax'] = ["no ajax request"];
|
||||||
|
}
|
||||||
|
|
||||||
|
return response()->json($data);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function update(Request $request, $id)
|
||||||
|
: JsonResponse {
|
||||||
|
// init
|
||||||
|
$data = [];
|
||||||
|
$dataPermohonan = [];
|
||||||
|
$dataPenawaran = [];
|
||||||
|
|
||||||
|
if (request()->ajax()) {
|
||||||
|
$validator = RegistrasiFinalController::rulesEditnya($request, $id);
|
||||||
|
|
||||||
|
if ($validator['fails']) {
|
||||||
|
$data['message'] = $validator['errors'];
|
||||||
|
$data['status'] = 'error';
|
||||||
|
} else {
|
||||||
|
DB::beginTransaction();
|
||||||
|
try {
|
||||||
|
// update table permohonan => status (registrasi-final), region_id, keterangan, authorized_at, authorized_status, authorized_by
|
||||||
|
// update table penawaran => status (registrasi-final)
|
||||||
|
$dataPermohonan = [
|
||||||
|
'status' => 'registrasi-final',
|
||||||
|
'region_id' => $request->region,
|
||||||
|
'keterangan' => $request->catatan,
|
||||||
|
'authorized_at' => now(),
|
||||||
|
'authorized_status' => 1,
|
||||||
|
'authorized_by' => Auth::id(),
|
||||||
|
];
|
||||||
|
|
||||||
|
$dataPenawaran = ['status' => 'registrasi-final'];
|
||||||
|
|
||||||
|
|
||||||
|
$permohonan = Permohonan::find($id);
|
||||||
|
$penawaran = PenawaranTender::where('nomor_registrasi', '=', $permohonan->nomor_registrasi)
|
||||||
|
->first();
|
||||||
|
|
||||||
|
$permohonan->update($dataPermohonan);
|
||||||
|
$penawaran->update($dataPenawaran);
|
||||||
|
//
|
||||||
|
DB::commit();
|
||||||
|
|
||||||
|
$data['status'] = 'success';
|
||||||
|
$data['message']['message_success'] = ['Regitrasi Final ' . $permohonan->nomor_registrasi . ' successfully'];
|
||||||
|
} catch (Exception $e) {
|
||||||
|
DB::rollBack();
|
||||||
|
$data['status'] = 'error';
|
||||||
|
$data['message']['message_try_catch'] = ['Regitrasi Final ' . $permohonan->nomor_registrasi . ' failed.'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$data['status'] = 'error';
|
||||||
|
$data['message']['message_ajax'] = ["no ajax request"];
|
||||||
|
}
|
||||||
|
|
||||||
|
return response()->json($data);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function rulesEditnya($request, $id)
|
||||||
|
{
|
||||||
|
$validate_catatan = '';
|
||||||
|
|
||||||
|
$validateIt = [
|
||||||
|
// 'name' diambil dari definisi parameter yang di kirim pada POST Data
|
||||||
|
'region' => 'required',
|
||||||
|
'catatan' => 'required',
|
||||||
|
];
|
||||||
|
|
||||||
|
$messageIt = [
|
||||||
|
'region.required' => 'Silahkan pilih Region',
|
||||||
|
'catatan.required' => 'Silahkan isi Catatan',
|
||||||
|
];
|
||||||
|
|
||||||
|
$validator = Validator::make($request->all(), $validateIt, $messageIt);
|
||||||
|
|
||||||
|
$data['fails'] = $validator->fails();
|
||||||
|
$data['errors'] = $validator->errors();
|
||||||
|
|
||||||
|
return $data;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
29
app/Http/Controllers/ResumeController.php
Normal file
29
app/Http/Controllers/ResumeController.php
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Modules\Lpj\Http\Controllers;
|
||||||
|
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
|
||||||
|
class ResumeController extends Controller
|
||||||
|
{
|
||||||
|
public $user;
|
||||||
|
/**
|
||||||
|
* Display a listing of the resource.
|
||||||
|
*/
|
||||||
|
public function index()
|
||||||
|
{
|
||||||
|
return view('lpj::resume.index');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show the specified resource.
|
||||||
|
*/
|
||||||
|
public function show($id) {}
|
||||||
|
/**
|
||||||
|
* Store form inspeksi.
|
||||||
|
*/
|
||||||
|
public function store(Request $request) {}
|
||||||
|
|
||||||
|
public function update(Request $request, $id) {}
|
||||||
|
}
|
||||||
135
app/Http/Controllers/SLAController.php
Normal file
135
app/Http/Controllers/SLAController.php
Normal file
@@ -0,0 +1,135 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Modules\Lpj\Http\Controllers;
|
||||||
|
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Modules\Lpj\Models\Authorization;
|
||||||
|
|
||||||
|
class SLAController extends Controller
|
||||||
|
{
|
||||||
|
public $user;
|
||||||
|
/**
|
||||||
|
* Display a listing of the resource.
|
||||||
|
*/
|
||||||
|
public function index()
|
||||||
|
{
|
||||||
|
return view('lpj::SLA.index');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show the form for creating a new resource.
|
||||||
|
*/
|
||||||
|
public function create()
|
||||||
|
{
|
||||||
|
return view('lpj::create');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Store a newly created resource in storage.
|
||||||
|
*/
|
||||||
|
public function store(Request $request)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show the specified resource.
|
||||||
|
*/
|
||||||
|
public function show($id)
|
||||||
|
{
|
||||||
|
return view('lpj::show');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show the form for editing the specified resource.
|
||||||
|
*/
|
||||||
|
public function edit($id)
|
||||||
|
{
|
||||||
|
return view('lpj::edit');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update the specified resource in storage.
|
||||||
|
*/
|
||||||
|
public function update(Request $request, $id)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove the specified resource from storage.
|
||||||
|
*/
|
||||||
|
public function destroy($id)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
}
|
||||||
|
|
||||||
|
public function dataForDatatables(Request $request)
|
||||||
|
{
|
||||||
|
if (is_null($this->user) || !$this->user->can('debitur.view')) {
|
||||||
|
// abort(403, 'Sorry! You are not allowed to view users.');
|
||||||
|
}
|
||||||
|
|
||||||
|
$query = Authorization::query()->with('permohonan.debiture', 'user', 'approveSo', 'approveEo', 'approveDd')->where('jenis', 'sla')->where('request', 'freeze');
|
||||||
|
|
||||||
|
// Pencarian berdasarkan parameter search
|
||||||
|
if ($request->has('search') && !empty($request->get('search'))) {
|
||||||
|
$search = $request->get('search');
|
||||||
|
$query->where(function ($q) use ($search) {
|
||||||
|
$q->orWhereRelation('permohonan', 'nomor_registrasi', 'LIKE', '%' . $search . '%');
|
||||||
|
$q->orWhereRelation('permohonan', 'tanggal_permohonan', 'LIKE', '%' . $search . '%');
|
||||||
|
$q->orWhereRelation('user', 'name', 'LIKE', '%' . $search . '%');
|
||||||
|
$q->orWhereRelation('permohonan.debiture', 'name', 'LIKE', '%' . $search . '%');
|
||||||
|
$q->orWhere('status', 'LIKE', '%' . $search . '%');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// Sorting berdasarkan sortField dan sortOrder
|
||||||
|
if ($request->has('sortOrder') && !empty($request->get('sortOrder'))) {
|
||||||
|
$order = $request->get('sortOrder');
|
||||||
|
$column = $request->get('sortField');
|
||||||
|
$query->orderBy($column, $order);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Hitung total records
|
||||||
|
$totalRecords = $query->count();
|
||||||
|
|
||||||
|
// Pagination (default page size 10)
|
||||||
|
$size = $request->get('size', 10);
|
||||||
|
if ($size == 0) {
|
||||||
|
$size = 10;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($request->has('page') && $request->has('size')) {
|
||||||
|
$page = $request->get('page', 1);
|
||||||
|
$offset = ($page - 1) * $size;
|
||||||
|
|
||||||
|
$query->skip($offset)->take($size);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Filtered records
|
||||||
|
$filteredRecords = $query->count();
|
||||||
|
|
||||||
|
// Ambil data dengan relasi
|
||||||
|
$data = $query->get();
|
||||||
|
|
||||||
|
|
||||||
|
// Hitung jumlah halaman
|
||||||
|
$pageCount = ceil($totalRecords / $size);
|
||||||
|
|
||||||
|
// Ambil current page
|
||||||
|
$currentPage = max(1, $request->get('page', 1));
|
||||||
|
|
||||||
|
// Return JSON response
|
||||||
|
return response()->json([
|
||||||
|
'draw' => $request->get('draw'),
|
||||||
|
'recordsTotal' => $totalRecords,
|
||||||
|
'recordsFiltered' => $filteredRecords,
|
||||||
|
'pageCount' => $pageCount,
|
||||||
|
'page' => $currentPage,
|
||||||
|
'totalCount' => $totalRecords,
|
||||||
|
'data' => $data,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
405
app/Http/Controllers/SpkController.php
Normal file
405
app/Http/Controllers/SpkController.php
Normal file
@@ -0,0 +1,405 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Modules\Lpj\Http\Controllers;
|
||||||
|
|
||||||
|
use Carbon\Carbon;
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use Barryvdh\DomPDF\Facade\Pdf; // https://github.com/barryvdh/laravel-dompdf
|
||||||
|
use Exception;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Maatwebsite\Excel\Facades\Excel;
|
||||||
|
// use Modules\Lpj\Exports\TujuanPenilaianExport;
|
||||||
|
// use Modules\Lpj\Http\Requests\TujuanPenilaianRequest;
|
||||||
|
// use Modules\Lpj\Models\TujuanPenilaian;
|
||||||
|
use Modules\Lpj\Models\PenawaranTender;
|
||||||
|
use Illuminate\Support\Facades\DB;
|
||||||
|
use Modules\Lpj\Models\Permohonan;
|
||||||
|
use Illuminate\Http\JsonResponse;
|
||||||
|
use Illuminate\Support\Facades\Storage;
|
||||||
|
use Illuminate\Support\Facades\Auth;
|
||||||
|
|
||||||
|
class SpkController extends Controller
|
||||||
|
{
|
||||||
|
public $user;
|
||||||
|
|
||||||
|
public function index()
|
||||||
|
{
|
||||||
|
return view('lpj::spk.index');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function dataForDatatables(Request $request)
|
||||||
|
{
|
||||||
|
if (is_null($this->user) || !$this->user->can('debitur.view')) {
|
||||||
|
//abort(403, 'Sorry! You are not allowed to view users.');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Retrieve data from the database
|
||||||
|
// $query =Permohonan::query()->with(['penawaran','penawaran.tujuanPenilaianKjpp'])->where('permohonan.status','=','spk');
|
||||||
|
// $data = $query->with(['user', 'debiture', 'branch', 'tujuanPenilaian','penilaian'])->get();
|
||||||
|
//$query =Permohonan::query()->with(['user', 'debiture', 'branch', 'tujuanPenilaian','penilaian','penawaran','penawaran.tujuanPenilaianKjpp'])->where('permohonan.status','=','spk');
|
||||||
|
|
||||||
|
$query = PenawaranTender::query()->with(['permohonan.user', 'permohonan.debiture', 'permohonan.branch', 'permohonan.tujuanPenilaian','permohonan.penilaian','tujuanPenilaianKjpp']);
|
||||||
|
|
||||||
|
|
||||||
|
// Apply search filter if provided
|
||||||
|
if ($request->has('search') && !empty($request->get('search'))) {
|
||||||
|
$search = $request->get('search');
|
||||||
|
$query->where(function ($q) use ($search) {
|
||||||
|
$q->whereRelation('permohonan','nomor_registrasi', 'LIKE', '%' . $search . '%');
|
||||||
|
//$q->orWhere('tanggal_permohonan', 'LIKE', '%' . $search . '%');
|
||||||
|
//$q->orWhere('status', 'LIKE', '%' . $search . '%');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// Apply sorting if provided
|
||||||
|
if ($request->has('sortOrder') && !empty($request->get('sortOrder'))) {
|
||||||
|
$order = $request->get('sortOrder');
|
||||||
|
$column = $request->get('sortField');
|
||||||
|
$query->orderBy($column, $order);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get the total count of records
|
||||||
|
$totalRecords = $query->count();
|
||||||
|
|
||||||
|
// Apply pagination if provided
|
||||||
|
if ($request->has('page') && $request->has('size')) {
|
||||||
|
$page = $request->get('page');
|
||||||
|
$size = $request->get('size');
|
||||||
|
$offset = ($page - 1) * $size; // Calculate the offset
|
||||||
|
|
||||||
|
$query->skip($offset)->take($size);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get the filtered count of records
|
||||||
|
$filteredRecords = $query->count();
|
||||||
|
|
||||||
|
// Get the data for the current page
|
||||||
|
//$data = $query->with(['user', 'debiture', 'branch', 'tujuanPenilaian'])->get();
|
||||||
|
|
||||||
|
$data = $query->get();
|
||||||
|
|
||||||
|
$i=0;
|
||||||
|
foreach($data as $obj)
|
||||||
|
{
|
||||||
|
// tanggal_permohonan
|
||||||
|
if ($obj->permohonan->tanggal_permohonan) {
|
||||||
|
$data[$i]->permohonan->tanggal_permohonan = Carbon::parse($obj->permohonan->tanggal_permohonan)->format('d M Y');
|
||||||
|
}
|
||||||
|
|
||||||
|
if($obj->tanggal_penilaian_sebelumnya)
|
||||||
|
{
|
||||||
|
$data[$i]->tanggal_penilaian_sebelumnya = Carbon::parse($obj->tanggal_penilaian_sebelumnya)->format('d F Y H:i:s');
|
||||||
|
}
|
||||||
|
|
||||||
|
if($obj->biaya_kjpp_sebelumnya)
|
||||||
|
{
|
||||||
|
$data[$i]->biaya_kjpp_sebelumnya = formatRupiah($obj->biaya_kjpp_sebelumnya);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// date_range
|
||||||
|
if($obj->start_date && $obj->end_date)
|
||||||
|
{
|
||||||
|
$data[$i]->date_range = Carbon::parse($obj->start_date)->format('d M Y').' - '.
|
||||||
|
Carbon::parse($obj->end_date)->format('d M Y');
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// data spk_dokumen_path
|
||||||
|
if($obj->spk_dokumen_path)
|
||||||
|
{
|
||||||
|
$spk_dokumen_path = Storage::url($obj->spk_dokumen_path);
|
||||||
|
$data[$i]->spk_dokumen_path = $spk_dokumen_path;
|
||||||
|
}
|
||||||
|
|
||||||
|
$i++;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Calculate the page count
|
||||||
|
$pageCount = ceil($totalRecords / $request->get('size'));
|
||||||
|
|
||||||
|
// Calculate the current page number
|
||||||
|
$currentPage = 0 + 1;
|
||||||
|
|
||||||
|
// Return the response data as a JSON object
|
||||||
|
return response()->json([
|
||||||
|
'draw' => $request->get('draw'),
|
||||||
|
'recordsTotal' => $totalRecords,
|
||||||
|
'recordsFiltered' => $filteredRecords,
|
||||||
|
'pageCount' => $pageCount,
|
||||||
|
'page' => $currentPage,
|
||||||
|
'totalCount' => $totalRecords,
|
||||||
|
'data' => $data
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function viewSpk()
|
||||||
|
{
|
||||||
|
// return Excel::download(new TujuanPenilaianExport, 'tujuan_penilaian.xlsx');
|
||||||
|
|
||||||
|
return view('lpj::spk.view');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function show($id)
|
||||||
|
{
|
||||||
|
$penawaran = PenawaranTender::find($id);
|
||||||
|
// return view('lpj::spk.show', compact('id','permohonan'));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function edit($id)
|
||||||
|
{
|
||||||
|
$penawaran = PenawaranTender::with(['jenisLaporan','tujuanPenilaianKjpp','detail.kjpp','penilaian','persetujuan_penawaran'])->where('id',$id)->first();
|
||||||
|
$penawaran->attachmentku = $penawaran->detail->attachment;
|
||||||
|
$penawaran->detail_penawaran_no_proposal = $penawaran->detail->no_proposal;
|
||||||
|
$penawaran->detail_penawaran_tgl_proposal = $penawaran->detail->tgl_proposal;
|
||||||
|
$penawaran->detail_penawaran_biaya_penawaran = $penawaran->detail->biaya_penawaran;
|
||||||
|
$penawaran->kjpp_name = $penawaran->detail->kjpp->name;
|
||||||
|
$penawaran->kjpp_address = $penawaran->detail->kjpp->address;
|
||||||
|
$penawaran->jenis_laporan_name = $penawaran->jenisLaporan->name;
|
||||||
|
$penawaran->jenis_laporan_code = $penawaran->jenisLaporan->code;
|
||||||
|
$penawaran->tujuan_penilaian_kjpp_name = $penawaran->tujuanPenilaianKjpp->name;
|
||||||
|
$penawaran->penilaian_waktu_penilain = $penawaran->penilaian->waktu_penilaian ?? "";
|
||||||
|
|
||||||
|
$permohonan = Permohonan::where('nomor_registrasi','=',$penawaran->nomor_registrasi)
|
||||||
|
->leftJoin('dokumen_jaminan', 'dokumen_jaminan.permohonan_id','=','permohonan.id')
|
||||||
|
->leftJoin('jenis_jaminan', 'jenis_jaminan.id','=','dokumen_jaminan.jenis_jaminan_id')
|
||||||
|
->select('permohonan.*', 'jenis_jaminan.name as jenis_jaminan_name',
|
||||||
|
'dokumen_jaminan.address as dokumen_jaminan_address');
|
||||||
|
|
||||||
|
$data = $permohonan->with(['user', 'debiture', 'branch', 'tujuanPenilaian','dokumenjaminan.detail'])->first();
|
||||||
|
|
||||||
|
if($penawaran->detail_penawaran_tgl_proposal)
|
||||||
|
$penawaran->detail_penawaran_tgl_proposal = Carbon::parse($penawaran->detail_penawaran_tgl_proposal)->format('d F Y');
|
||||||
|
|
||||||
|
// generate no spk
|
||||||
|
$spk_no_last=$penawaran->spk_no;
|
||||||
|
if(!$spk_no_last)
|
||||||
|
{
|
||||||
|
$spk_no_last = onLastnumberCodePenawaranSPK($penawaran->jenis_laporan_code);
|
||||||
|
$penawaran->spk_no = $spk_no_last;
|
||||||
|
}
|
||||||
|
|
||||||
|
// pengecekan perubahan jenis report
|
||||||
|
$array_no_last = explode("/",$spk_no_last);
|
||||||
|
$jenis_report_old=trim($array_no_last[4]);
|
||||||
|
if($jenis_report_old!=$penawaran->jenis_laporan_code)
|
||||||
|
{
|
||||||
|
$penawaran->spk_no=str_replace($jenis_report_old,$penawaran->jenis_laporan_code,$spk_no_last);
|
||||||
|
}
|
||||||
|
// pengecekan perubahan jenis report
|
||||||
|
// generate no spk
|
||||||
|
|
||||||
|
// Jangka Waktu
|
||||||
|
// date_start (penilaian.waktu_penilain + 1 day) - date_end (persetujuan_penawaran.sla_final)
|
||||||
|
$jangka_waktu='';
|
||||||
|
// Jangka Waktu
|
||||||
|
$persetujuan_no_proposal = $penawaran->detail_penawaran_no_proposal;
|
||||||
|
$persetujuan_tgl_proposal = $penawaran->detail_penawaran_tgl_proposal;
|
||||||
|
$persetujuan_sla_resume = '...';
|
||||||
|
$persetujuan_sla_final = '...';
|
||||||
|
if(null !==$penawaran->persetujuan)
|
||||||
|
{
|
||||||
|
$sla_resume_text = ceil($data->sla/2);
|
||||||
|
$sla_final_text = $data->sla;
|
||||||
|
|
||||||
|
$sla_resume_text_terbilang = ucfirst(terbilang($sla_resume_text));
|
||||||
|
$sla_final_text_terbilang = ucfirst(terbilang($sla_final_text));
|
||||||
|
|
||||||
|
$persetujuan_no_proposal = $penawaran->persetujuan->nomor_proposal_penawaran;
|
||||||
|
$persetujuan_tgl_proposal = Carbon::parse($penawaran->persetujuan->tanggal_proposal_penawaran)->format('d F Y');
|
||||||
|
$persetujuan_sla_resume = $sla_resume_text.' ('.$sla_resume_text_terbilang.')';
|
||||||
|
$persetujuan_sla_final = $sla_final_text.' ('.$sla_final_text_terbilang.')';
|
||||||
|
|
||||||
|
if($penawaran->penilaian_waktu_penilain)
|
||||||
|
{
|
||||||
|
$jangka_waktu_date_start=Carbon::parse($penawaran->penilaian_waktu_penilain)->addDays(1)->format('d F Y');
|
||||||
|
$jangka_waktu_date_end=Carbon::parse($penawaran->persetujuan->sla_final)->format('d F Y');
|
||||||
|
// Jangka Waktu
|
||||||
|
// date_start (penilaian.waktu_penilain + 1 day) - date_end (persetujuan_penawaran.sla_final)
|
||||||
|
$jangka_waktu=$jangka_waktu_date_start.' - '.$jangka_waktu_date_end;
|
||||||
|
// Jangka Waktu
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return view('lpj::spk.edit', compact('data', 'penawaran', 'persetujuan_no_proposal', 'persetujuan_tgl_proposal', 'persetujuan_sla_resume', 'persetujuan_sla_final', 'jangka_waktu'));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function update(Request $request, $id): JsonResponse
|
||||||
|
{
|
||||||
|
|
||||||
|
// init
|
||||||
|
$data1 = [];
|
||||||
|
// $dataPermohonan = array();
|
||||||
|
$dataPenawaran = [];
|
||||||
|
// data
|
||||||
|
|
||||||
|
$penawaran = PenawaranTender::with(['jenisLaporan','tujuanPenilaianKjpp','detail.kjpp','penilaian','persetujuan_penawaran'])->where('id',$id)->first();
|
||||||
|
$penawaran->attachmentku = $penawaran->detail->attachment;
|
||||||
|
$penawaran->detail_penawaran_no_proposal = $penawaran->detail->no_proposal;
|
||||||
|
$penawaran->detail_penawaran_tgl_proposal = $penawaran->detail->tgl_proposal;
|
||||||
|
$penawaran->detail_penawaran_biaya_penawaran = $penawaran->detail->biaya_penawaran;
|
||||||
|
$penawaran->kjpp_name = $penawaran->detail->kjpp->name;
|
||||||
|
$penawaran->kjpp_address = $penawaran->detail->kjpp->address;
|
||||||
|
$penawaran->jenis_laporan_name = $penawaran->jenisLaporan->name;
|
||||||
|
$penawaran->jenis_laporan_code = $penawaran->jenisLaporan->code;
|
||||||
|
$penawaran->tujuan_penilaian_kjpp_name = $penawaran->tujuanPenilaianKjpp->name;
|
||||||
|
$penawaran->penilaian_waktu_penilain = $penawaran->penilaian->waktu_penilaian ?? "";
|
||||||
|
|
||||||
|
$permohonan = Permohonan::where('nomor_registrasi','=',$penawaran->nomor_registrasi)
|
||||||
|
->leftJoin('dokumen_jaminan', 'dokumen_jaminan.permohonan_id','=','permohonan.id')
|
||||||
|
->leftJoin('jenis_jaminan', 'jenis_jaminan.id','=','dokumen_jaminan.jenis_jaminan_id')
|
||||||
|
->select('permohonan.*', 'jenis_jaminan.name as jenis_jaminan_name');
|
||||||
|
|
||||||
|
$data = $permohonan->with(['user', 'debiture', 'branch', 'tujuanPenilaian','dokumenjaminan'])->first();
|
||||||
|
|
||||||
|
// Jangka Waktu
|
||||||
|
// date_start (penilaian.waktu_penilain + 1 day) - date_end (persetujuan_penawaran.sla_final)
|
||||||
|
$jangka_waktu='';
|
||||||
|
// Jangka Waktu
|
||||||
|
|
||||||
|
if($penawaran->detail_penawaran_tgl_proposal)
|
||||||
|
$penawaran->detail_penawaran_tgl_proposal = Carbon::parse($penawaran->detail_penawaran_tgl_proposal)->format('d F Y');
|
||||||
|
|
||||||
|
$folderPath = 'uploads/spk/';
|
||||||
|
$extension = '.pdf';
|
||||||
|
$newFileName = "SPK_".$penawaran->nomor_registrasi."_".Auth::user()->id."_".time(). $extension;
|
||||||
|
$newFileNameWithPath = $folderPath . $newFileName;
|
||||||
|
|
||||||
|
// update table permohonan
|
||||||
|
// $dataPermohonan=['dokumen' => $newFileNameWithPath];
|
||||||
|
// $data->update($dataPermohonan);
|
||||||
|
// update table permohonan
|
||||||
|
|
||||||
|
// update table penawaran
|
||||||
|
$dataPenawaran['spk_dokumen_path'] = $newFileNameWithPath;
|
||||||
|
// $spk_no_last=$penawaran->spk_no;
|
||||||
|
if(!$penawaran->spk_no)
|
||||||
|
{
|
||||||
|
$spk_no_last = onLastnumberCodePenawaranSPK($penawaran->jenis_laporan_code);
|
||||||
|
// $penawaran->no_spk = $no_spk_last;
|
||||||
|
$date_now = Carbon::now()->format('Ymd');// 20240124
|
||||||
|
$spk_number = substr ($spk_no_last, 0, 3);
|
||||||
|
$dataPenawaran['spk_no'] = $spk_no_last;
|
||||||
|
$dataPenawaran['spk_no_core'] = $date_now.'_'.$spk_number;
|
||||||
|
|
||||||
|
$penawaran->spk_no = $spk_no_last;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// pengecekan perubahan jenis report
|
||||||
|
$spk_no_old=$penawaran->spk_no;
|
||||||
|
$array_no_last = explode("/",$spk_no_old);
|
||||||
|
$jenis_report_old=trim($array_no_last[4]);
|
||||||
|
if($jenis_report_old!=$penawaran->jenis_laporan_code)
|
||||||
|
{
|
||||||
|
$penawaran_spk_no_new=str_replace($jenis_report_old,$penawaran->jenis_laporan_code,$spk_no_old);
|
||||||
|
$penawaran->spk_no=$penawaran_spk_no_new;
|
||||||
|
$dataPenawaran['spk_no'] = $penawaran_spk_no_new;
|
||||||
|
}
|
||||||
|
// pengecekan perubahan jenis report
|
||||||
|
|
||||||
|
$penawaranM = PenawaranTender::find($penawaran->id);
|
||||||
|
$penawaranM->update($dataPenawaran);
|
||||||
|
// update table penawaran
|
||||||
|
|
||||||
|
// pdf path
|
||||||
|
$spkpenawaran_path = Storage::url($newFileNameWithPath);
|
||||||
|
|
||||||
|
$persetujuan_no_proposal = $penawaran->detail_penawaran_no_proposal;
|
||||||
|
$persetujuan_tgl_proposal = $penawaran->detail_penawaran_tgl_proposal;
|
||||||
|
$persetujuan_sla_resume = '...';
|
||||||
|
$persetujuan_sla_final = '...';
|
||||||
|
if(null !==$penawaran->persetujuan)
|
||||||
|
{
|
||||||
|
//$sla_resume_text = $penawaran->persetujuan->sla_resume;
|
||||||
|
//$sla_final_text = $penawaran->persetujuan->sla_final;
|
||||||
|
|
||||||
|
$sla_resume_text = ceil($data->sla/2);
|
||||||
|
$sla_final_text = $data->sla;
|
||||||
|
|
||||||
|
$sla_resume_text_terbilang = ucfirst(terbilang($sla_resume_text));
|
||||||
|
$sla_final_text_terbilang = ucfirst(terbilang($sla_final_text));
|
||||||
|
|
||||||
|
$persetujuan_no_proposal = $penawaran->persetujuan->nomor_proposal_penawaran;
|
||||||
|
$persetujuan_tgl_proposal = Carbon::parse($penawaran->persetujuan->tanggal_proposal_penawaran)->format('d F Y');
|
||||||
|
$persetujuan_sla_resume = $sla_resume_text.' ('.$sla_resume_text_terbilang.')';
|
||||||
|
$persetujuan_sla_final = $sla_final_text.' ('.$sla_final_text_terbilang.')';
|
||||||
|
|
||||||
|
if($penawaran->penilaian_waktu_penilain)
|
||||||
|
{
|
||||||
|
$jangka_waktu_date_start=Carbon::parse($penawaran->penilaian_waktu_penilain)->addDays(1)->format('d F Y');
|
||||||
|
$jangka_waktu_date_end=Carbon::parse($penawaran->persetujuan->sla_final)->format('d F Y');
|
||||||
|
// Jangka Waktu
|
||||||
|
// date_start (penilaian.waktu_penilain + 1 day) - date_end (persetujuan_penawaran.sla_final)
|
||||||
|
$jangka_waktu=$jangka_waktu_date_start.' - '.$jangka_waktu_date_end;
|
||||||
|
// Jangka Waktu
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
$pdf =Pdf::loadView('lpj::spk.documentSPK', compact('data', 'penawaran', 'persetujuan_no_proposal', 'persetujuan_tgl_proposal', 'persetujuan_sla_resume', 'persetujuan_sla_final', 'jangka_waktu'));
|
||||||
|
$pdf->setPaper('A4', 'portrait');
|
||||||
|
$content = $pdf->download()->getOriginalContent();
|
||||||
|
Storage::put('public/'.$newFileNameWithPath,$content);
|
||||||
|
|
||||||
|
$data1['status'] = 'success';
|
||||||
|
$data1['spkpenawaran_path'] = $spkpenawaran_path;
|
||||||
|
$data1['message']['message_success'] = array('Generate SPK PDF successfully');
|
||||||
|
|
||||||
|
return response()->json($data1);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function dokumennya()
|
||||||
|
{
|
||||||
|
// return view('lpj::spk.dokumennya');
|
||||||
|
$id="3";
|
||||||
|
$penawaran = PenawaranTender::leftJoin('detail_penawaran', 'detail_penawaran.penawaran_id','=','penawaran.id')
|
||||||
|
->leftJoin('jenis_laporan', 'jenis_laporan.id','=','penawaran.jenis_laporan_id')
|
||||||
|
->leftJoin('kjpp', 'kjpp.id','=','detail_penawaran.kjpp_rekanan_id')
|
||||||
|
->where('detail_penawaran.status','=',1)
|
||||||
|
->where('penawaran.id','=', $id)
|
||||||
|
->select('penawaran.*', 'detail_penawaran.attachment as attachmentku',
|
||||||
|
'detail_penawaran.biaya_penawaran as detail_penawaran_biaya_penawaran',
|
||||||
|
'kjpp.name as kjpp_name',
|
||||||
|
'kjpp.address as kjpp_address',
|
||||||
|
'jenis_laporan.name as jenis_laporan_name'
|
||||||
|
)->first();
|
||||||
|
|
||||||
|
$permohonan = Permohonan::where('nomor_registrasi','=',$penawaran->nomor_registrasi)
|
||||||
|
->leftJoin('dokumen_jaminan', 'dokumen_jaminan.permohonan_id','=','permohonan.id')
|
||||||
|
->leftJoin('jenis_jaminan', 'jenis_jaminan.id','=','dokumen_jaminan.jenis_jaminan_id')
|
||||||
|
->select('permohonan.*', 'jenis_jaminan.name as jenis_jaminan_name',
|
||||||
|
'dokumen_jaminan.address as dokumen_jaminan_address');
|
||||||
|
|
||||||
|
$data = $permohonan->with(['user', 'debiture', 'branch', 'tujuanPenilaian'])->first();
|
||||||
|
|
||||||
|
return view('lpj::spk.dokumennya', compact('data', 'penawaran'));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function download($id) {
|
||||||
|
// dokumen pdf diambil dari penawaran.spk_dokumen_path
|
||||||
|
$document = PenawaranTender::find($id);
|
||||||
|
|
||||||
|
return response()->download(storage_path('app/public/' .$document->spk_dokumen_path));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function updateSla(Request $request, $id): JsonResponse
|
||||||
|
{
|
||||||
|
|
||||||
|
$request->validate([
|
||||||
|
'sla' => 'required|integer|min:1',
|
||||||
|
]);
|
||||||
|
|
||||||
|
|
||||||
|
$penawaran = PenawaranTender::find($id);
|
||||||
|
$permohonan = Permohonan::where('nomor_registrasi','=',$penawaran->nomor_registrasi)->first();
|
||||||
|
|
||||||
|
$permohonan->sla = $request->sla;
|
||||||
|
$permohonan->save();
|
||||||
|
|
||||||
|
return response()->json(['message' => 'SLA updated successfully']);
|
||||||
|
}
|
||||||
|
}
|
||||||
150
app/Http/Controllers/StatusPermohonanController.php
Normal file
150
app/Http/Controllers/StatusPermohonanController.php
Normal file
@@ -0,0 +1,150 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Modules\Lpj\Http\Controllers;
|
||||||
|
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use Exception;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Maatwebsite\Excel\Facades\Excel;
|
||||||
|
use Modules\Lpj\Exports\StatusPermohonanExport;
|
||||||
|
use Modules\Lpj\Http\Requests\StatusPermohonanRequest;
|
||||||
|
use Modules\Lpj\Models\StatusPermohonan;
|
||||||
|
|
||||||
|
class StatusPermohonanController extends Controller
|
||||||
|
{
|
||||||
|
public $user;
|
||||||
|
|
||||||
|
public function index()
|
||||||
|
{
|
||||||
|
return view('lpj::status_permohonan.index');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function store(StatusPermohonanRequest $request)
|
||||||
|
{
|
||||||
|
$validate = $request->validated();
|
||||||
|
|
||||||
|
if ($validate) {
|
||||||
|
try {
|
||||||
|
// Save to database
|
||||||
|
StatusPermohonan::create($validate);
|
||||||
|
return redirect()
|
||||||
|
->route('basicdata.status-permohonan.index')
|
||||||
|
->with('success', 'Status Permohonan created successfully');
|
||||||
|
} catch (Exception $e) {
|
||||||
|
return redirect()
|
||||||
|
->route('basicdata.status-permohonan.create')
|
||||||
|
->with('error', 'Failed to create status permohonan');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function create()
|
||||||
|
{
|
||||||
|
return view('lpj::status_permohonan.form');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function edit($id)
|
||||||
|
{
|
||||||
|
$statusPermohonan = StatusPermohonan::find($id);
|
||||||
|
return view('lpj::status_permohonan.form', compact('statusPermohonan'));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function update(StatusPermohonanRequest $request, $id)
|
||||||
|
{
|
||||||
|
$validate = $request->validated();
|
||||||
|
|
||||||
|
if ($validate) {
|
||||||
|
try {
|
||||||
|
// Update in database
|
||||||
|
$statusPermohonan = StatusPermohonan::find($id);
|
||||||
|
$statusPermohonan->update($validate);
|
||||||
|
return redirect()
|
||||||
|
->route('basicdata.status-permohonan.index')
|
||||||
|
->with('success', 'Status Permohonan updated successfully');
|
||||||
|
} catch (Exception $e) {
|
||||||
|
return redirect()
|
||||||
|
->route('basicdata.status-permohonan.edit', $id)
|
||||||
|
->with('error', 'Failed to update status permohonan');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function destroy($id)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
// Delete from database
|
||||||
|
$statusPermohonan = StatusPermohonan::find($id);
|
||||||
|
$statusPermohonan->delete();
|
||||||
|
|
||||||
|
echo json_encode(['success' => true, 'message' => 'Status Permohonan deleted successfully']);
|
||||||
|
} catch (Exception $e) {
|
||||||
|
echo json_encode(['success' => false, 'message' => 'Failed to delete status permohonan']);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function dataForDatatables(Request $request)
|
||||||
|
{
|
||||||
|
if (is_null($this->user) || !$this->user->can('status_permohonan.view')) {
|
||||||
|
//abort(403, 'Sorry! You are not allowed to view users.');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Retrieve data from the database
|
||||||
|
$query = StatusPermohonan::query();
|
||||||
|
|
||||||
|
// Apply search filter if provided
|
||||||
|
if ($request->has('search') && !empty($request->get('search'))) {
|
||||||
|
$search = $request->get('search');
|
||||||
|
$query->where(function ($q) use ($search) {
|
||||||
|
$q->where('name', 'LIKE', "%$search%");
|
||||||
|
$q->orWhere('description', 'LIKE', "%$search%");
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// Apply sorting if provided
|
||||||
|
if ($request->has('sortOrder') && !empty($request->get('sortOrder'))) {
|
||||||
|
$order = $request->get('sortOrder');
|
||||||
|
$column = $request->get('sortField');
|
||||||
|
$query->orderBy($column, $order);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get the total count of records
|
||||||
|
$totalRecords = $query->count();
|
||||||
|
|
||||||
|
// Apply pagination if provided
|
||||||
|
if ($request->has('page') && $request->has('size')) {
|
||||||
|
$page = $request->get('page');
|
||||||
|
$size = $request->get('size');
|
||||||
|
$offset = ($page - 1) * $size; // Calculate the offset
|
||||||
|
|
||||||
|
$query->skip($offset)->take($size);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get the filtered count of records
|
||||||
|
$filteredRecords = $query->count();
|
||||||
|
|
||||||
|
// Get the data for the current page
|
||||||
|
$data = $query->get();
|
||||||
|
|
||||||
|
// Calculate the page count
|
||||||
|
$pageCount = ceil($totalRecords / $request->get('size'));
|
||||||
|
|
||||||
|
// Calculate the current page number
|
||||||
|
$currentPage = 0 + 1;
|
||||||
|
|
||||||
|
// Return the response data as a JSON object
|
||||||
|
return response()->json([
|
||||||
|
'draw' => $request->get('draw'),
|
||||||
|
'recordsTotal' => $totalRecords,
|
||||||
|
'recordsFiltered' => $filteredRecords,
|
||||||
|
'pageCount' => $pageCount,
|
||||||
|
'page' => $currentPage,
|
||||||
|
'totalCount' => $totalRecords,
|
||||||
|
'data' => $data,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function export()
|
||||||
|
{
|
||||||
|
return Excel::download(new StatusPermohonanExport, 'status_permohonan.xlsx');
|
||||||
|
}
|
||||||
|
}
|
||||||
2907
app/Http/Controllers/SurveyorController.php
Normal file
2907
app/Http/Controllers/SurveyorController.php
Normal file
File diff suppressed because it is too large
Load Diff
273
app/Http/Controllers/TeamsController.php
Normal file
273
app/Http/Controllers/TeamsController.php
Normal file
@@ -0,0 +1,273 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Modules\Lpj\Http\Controllers;
|
||||||
|
|
||||||
|
use Exception;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Http\Response;
|
||||||
|
use Modules\Lpj\Models\Teams;
|
||||||
|
use Modules\Lpj\Models\Regions;
|
||||||
|
use Illuminate\Support\Facades\DB;
|
||||||
|
use Modules\Lpj\Models\TeamsUsers;
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use Maatwebsite\Excel\Facades\Excel;
|
||||||
|
use Illuminate\Http\RedirectResponse;
|
||||||
|
use Modules\Usermanagement\Models\User;
|
||||||
|
use Modules\Lpj\Http\Requests\TeamsRequest;
|
||||||
|
use Modules\Lpj\Exports\TeamPenilaianExport;
|
||||||
|
|
||||||
|
class TeamsController extends Controller
|
||||||
|
{
|
||||||
|
public $user;
|
||||||
|
/**
|
||||||
|
* Display a listing of the resource.
|
||||||
|
*/
|
||||||
|
public function index()
|
||||||
|
{
|
||||||
|
return view('lpj::teams.index');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show the form for creating a new resource.
|
||||||
|
*/
|
||||||
|
public function create()
|
||||||
|
{
|
||||||
|
|
||||||
|
$regionTeam = Teams::pluck('regions_id')->toArray();
|
||||||
|
|
||||||
|
$regions = Regions::whereNotIn('id', $regionTeam)->get();
|
||||||
|
|
||||||
|
$userTeam = TeamsUsers::pluck('user_id')->toArray();
|
||||||
|
$usersWithRole = User::whereNotIn('id', $userTeam)
|
||||||
|
->with('roles') // Eager load roles
|
||||||
|
->get();
|
||||||
|
|
||||||
|
$user = $usersWithRole->filter(function ($user) {
|
||||||
|
return $user->roles->contains(function ($role) {
|
||||||
|
return $role->name === 'surveyor' || $role->name === 'surveyor-penilai' || $role->name === 'senior-officer';
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
return view('lpj::teams.form', compact('regions', 'user'));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Store a newly created resource in storage.
|
||||||
|
*/
|
||||||
|
public function store(TeamsRequest $request)
|
||||||
|
{
|
||||||
|
$validate = $request->validated();
|
||||||
|
|
||||||
|
DB::beginTransaction();
|
||||||
|
try {
|
||||||
|
$teams = Teams::create($validate);
|
||||||
|
|
||||||
|
$users = $request->input('user', []);
|
||||||
|
|
||||||
|
// loop untuk insert data users ke tabel teams_users
|
||||||
|
foreach ($users as $user) {
|
||||||
|
TeamsUsers::create([
|
||||||
|
'teams_id' => $teams->id,
|
||||||
|
'user_id' => $user
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
DB::commit();
|
||||||
|
|
||||||
|
return redirect()
|
||||||
|
->route('basicdata.teams.index')
|
||||||
|
->with('success', 'Data saved successfully. ');
|
||||||
|
} catch (Exception $e) {
|
||||||
|
|
||||||
|
DB::rollBack();
|
||||||
|
|
||||||
|
return redirect()
|
||||||
|
->route('basicdata.teams.create')
|
||||||
|
->with('error', 'Failed to save data. ');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show the specified resource.
|
||||||
|
*/
|
||||||
|
public function show($id)
|
||||||
|
{
|
||||||
|
return view('lpj::show');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show the form for editing the specified resource.
|
||||||
|
*/
|
||||||
|
public function edit($id)
|
||||||
|
{
|
||||||
|
$teams = Teams::find($id);
|
||||||
|
|
||||||
|
$regions = Regions::all();
|
||||||
|
$usedUsers = TeamsUsers::where('teams_id', '!=', $id)->pluck('user_id')->toArray();
|
||||||
|
$usersWithRole = User::whereNotIn('id', $usedUsers)
|
||||||
|
->with('roles')
|
||||||
|
->get();
|
||||||
|
|
||||||
|
|
||||||
|
$user = $usersWithRole->filter(function ($user) {
|
||||||
|
return $user->roles->contains(function ($role) {
|
||||||
|
return $role->name === 'surveyor' || $role->name === 'surveyor-penilai' || $role->name === 'senior-officer';
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
// Ambil user yang sudah ada di tim ini
|
||||||
|
$selectedUsers = $teams->teamsUsers->pluck('user_id')->toArray();
|
||||||
|
|
||||||
|
return view('lpj::teams.form', compact('teams', 'regions', 'user', 'selectedUsers'));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update the specified resource in storage.
|
||||||
|
*/
|
||||||
|
public function update(TeamsRequest $request, $id)
|
||||||
|
{
|
||||||
|
$validate = $request->validated();
|
||||||
|
|
||||||
|
DB::beginTransaction();
|
||||||
|
try {
|
||||||
|
$teams = Teams::findOrFail($id);
|
||||||
|
|
||||||
|
// Update data tim
|
||||||
|
$teams->update($validate);
|
||||||
|
$userIds = $request->input('user', []);
|
||||||
|
|
||||||
|
$teams->teamsUsers()->delete();
|
||||||
|
|
||||||
|
|
||||||
|
foreach ($userIds as $userId) {
|
||||||
|
TeamsUsers::create([
|
||||||
|
'teams_id' => $teams->id,
|
||||||
|
'user_id' => $userId
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
DB::commit();
|
||||||
|
|
||||||
|
return redirect()
|
||||||
|
->route('basicdata.teams.index')
|
||||||
|
->with('success', 'Data updated successfully. ');
|
||||||
|
} catch (Exception $e) {
|
||||||
|
|
||||||
|
DB::rollBack();
|
||||||
|
|
||||||
|
return redirect()
|
||||||
|
->route('basicdata.teams.create')
|
||||||
|
->with('error', 'Failed to update data. ');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove the specified resource from storage.
|
||||||
|
*/
|
||||||
|
public function destroy($id)
|
||||||
|
{
|
||||||
|
DB::beginTransaction();
|
||||||
|
try {
|
||||||
|
|
||||||
|
$teams = Teams::findOrFail($id);
|
||||||
|
$teams->teamsUsers()->delete();
|
||||||
|
|
||||||
|
// Hapus tim
|
||||||
|
$teams->delete();
|
||||||
|
|
||||||
|
DB::commit();
|
||||||
|
|
||||||
|
echo json_encode(['success' => true, 'message' => 'Team has been deleted successfully']);
|
||||||
|
} catch (Exception $e) {
|
||||||
|
DB::rollBack();
|
||||||
|
echo json_encode(['success' => false, 'message' => 'Failed to delete Team']);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function dataForDatatables(Request $request)
|
||||||
|
{
|
||||||
|
if (is_null($this->user) || !$this->user->can('teams.view')) {
|
||||||
|
//abort(403, 'Sorry! You are not allowed to view users.');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Inisialisasi query
|
||||||
|
$query = Teams::select('teams.id as id', 'teams.name as team_name', 'regions.name as region_name')
|
||||||
|
->join('regions', 'teams.regions_id', '=', 'regions.id')
|
||||||
|
->leftJoin('teams_users', 'teams.id', '=', 'teams_users.teams_id')
|
||||||
|
->leftJoin('users', 'teams_users.user_id', '=', 'users.id')
|
||||||
|
->addSelect('users.id as user_id', 'users.name as user_name');
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// Filter pencarian
|
||||||
|
if ($request->has('search') && !empty($request->get('search'))) {
|
||||||
|
$search = $request->get('search');
|
||||||
|
$query->where(function ($q) use ($search) {
|
||||||
|
$q->where('teams.name', 'LIKE', "%$search%")
|
||||||
|
->orWhere('regions.name', 'LIKE', "%$search%")
|
||||||
|
->orWhere('users.name', 'LIKE', "%$search%");
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// Sorting
|
||||||
|
if ($request->has('sortOrder') && !empty($request->get('sortOrder'))) {
|
||||||
|
$order = $request->get('sortOrder');
|
||||||
|
$column = $request->get('sortField');
|
||||||
|
$query->orderBy($column, $order);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Hitung total records
|
||||||
|
$totalRecords = $query->count();
|
||||||
|
|
||||||
|
// Pagination
|
||||||
|
$size = $request->get('size', 10);
|
||||||
|
$page = $request->get('page', 1);
|
||||||
|
$offset = ($page - 1) * $size;
|
||||||
|
|
||||||
|
// Ambil data dengan pagination
|
||||||
|
$data = $query->skip($offset)->take($size)->get();
|
||||||
|
$filteredRecords = $data->count();
|
||||||
|
$pageCount = ceil($totalRecords / $size);
|
||||||
|
|
||||||
|
// Ambil ID pengguna dari hasil query
|
||||||
|
$userIds = $data->pluck('user_id')->unique();
|
||||||
|
|
||||||
|
// Ambil data pengguna dengan peran mereka
|
||||||
|
$users = User::whereIn('id', $userIds)
|
||||||
|
->with('roles')
|
||||||
|
->get()
|
||||||
|
->keyBy('id');
|
||||||
|
|
||||||
|
// Format data
|
||||||
|
$formattedData = $data->groupBy('id')->map(function ($group) use ($users) {
|
||||||
|
$team = $group->first();
|
||||||
|
$team->user_team = $group->map(function ($item) use ($users) {
|
||||||
|
$user = $users->get($item->user_id);
|
||||||
|
return [
|
||||||
|
'nama' => $item->user_name,
|
||||||
|
'roles' => $user ? $user->roles->pluck('name')->toArray() : [],
|
||||||
|
];
|
||||||
|
})->toArray();
|
||||||
|
return $team;
|
||||||
|
})->values();
|
||||||
|
|
||||||
|
return response()->json([
|
||||||
|
'draw' => $request->get('draw'),
|
||||||
|
'recordsTotal' => $totalRecords,
|
||||||
|
'recordsFiltered' => $filteredRecords,
|
||||||
|
'pageCount' => $pageCount,
|
||||||
|
'page' => $page,
|
||||||
|
'totalCount' => $totalRecords,
|
||||||
|
'data' => $formattedData
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public function export()
|
||||||
|
{
|
||||||
|
return Excel::download(new TeamPenilaianExport(), 'team-penilai.xlsx');
|
||||||
|
}
|
||||||
|
}
|
||||||
1073
app/Http/Controllers/TenderController.php
Normal file
1073
app/Http/Controllers/TenderController.php
Normal file
File diff suppressed because it is too large
Load Diff
150
app/Http/Controllers/TujuanPenilaianController.php
Normal file
150
app/Http/Controllers/TujuanPenilaianController.php
Normal file
@@ -0,0 +1,150 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Modules\Lpj\Http\Controllers;
|
||||||
|
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use Exception;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Maatwebsite\Excel\Facades\Excel;
|
||||||
|
use Modules\Lpj\Exports\TujuanPenilaianExport;
|
||||||
|
use Modules\Lpj\Http\Requests\TujuanPenilaianRequest;
|
||||||
|
use Modules\Lpj\Models\TujuanPenilaian;
|
||||||
|
|
||||||
|
class TujuanPenilaianController extends Controller
|
||||||
|
{
|
||||||
|
public $user;
|
||||||
|
|
||||||
|
public function index()
|
||||||
|
{
|
||||||
|
return view('lpj::tujuan_penilaian.index');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function store(TujuanPenilaianRequest $request)
|
||||||
|
{
|
||||||
|
$validate = $request->validated();
|
||||||
|
|
||||||
|
if ($validate) {
|
||||||
|
try {
|
||||||
|
// Save to database
|
||||||
|
TujuanPenilaian::create($validate);
|
||||||
|
return redirect()
|
||||||
|
->route('basicdata.tujuan-penilaian.index')
|
||||||
|
->with('success', 'Jenis Jaminan created successfully');
|
||||||
|
} catch (Exception $e) {
|
||||||
|
return redirect()
|
||||||
|
->route('basicdata.tujuan-penilaian.create')
|
||||||
|
->with('error', 'Failed to create jenis jaminan');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function create()
|
||||||
|
{
|
||||||
|
return view('lpj::tujuan_penilaian.create');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function edit($id)
|
||||||
|
{
|
||||||
|
$tujuanPenilaian = TujuanPenilaian::find($id);
|
||||||
|
return view('lpj::tujuan_penilaian.create', compact('tujuanPenilaian'));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function update(TujuanPenilaianRequest $request, $id)
|
||||||
|
{
|
||||||
|
$validate = $request->validated();
|
||||||
|
|
||||||
|
if ($validate) {
|
||||||
|
try {
|
||||||
|
// Update in database
|
||||||
|
$tujuanPenilaian = TujuanPenilaian::find($id);
|
||||||
|
$tujuanPenilaian->update($validate);
|
||||||
|
return redirect()
|
||||||
|
->route('basicdata.tujuan-penilaian.index')
|
||||||
|
->with('success', 'Jenis Jaminan updated successfully');
|
||||||
|
} catch (Exception $e) {
|
||||||
|
return redirect()
|
||||||
|
->route('basicdata.tujuan-penilaian.edit', $id)
|
||||||
|
->with('error', 'Failed to update jenis jaminan');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function destroy($id)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
// Delete from database
|
||||||
|
$tujuanPenilaian = TujuanPenilaian::find($id);
|
||||||
|
$tujuanPenilaian->delete();
|
||||||
|
|
||||||
|
echo json_encode(['success' => true, 'message' => 'Jenis Jaminan deleted successfully']);
|
||||||
|
} catch (Exception $e) {
|
||||||
|
echo json_encode(['success' => false, 'message' => 'Failed to delete jenis jaminan']);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function dataForDatatables(Request $request)
|
||||||
|
{
|
||||||
|
if (is_null($this->user) || !$this->user->can('tujuan_penilaian.view')) {
|
||||||
|
//abort(403, 'Sorry! You are not allowed to view users.');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Retrieve data from the database
|
||||||
|
$query = TujuanPenilaian::query();
|
||||||
|
|
||||||
|
// Apply search filter if provided
|
||||||
|
if ($request->has('search') && !empty($request->get('search'))) {
|
||||||
|
$search = $request->get('search');
|
||||||
|
$query->where(function ($q) use ($search) {
|
||||||
|
$q->where('code', 'LIKE', "%$search%");
|
||||||
|
$q->orWhere('name', 'LIKE', "%$search%");
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// Apply sorting if provided
|
||||||
|
if ($request->has('sortOrder') && !empty($request->get('sortOrder'))) {
|
||||||
|
$order = $request->get('sortOrder');
|
||||||
|
$column = $request->get('sortField');
|
||||||
|
$query->orderBy($column, $order);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get the total count of records
|
||||||
|
$totalRecords = $query->count();
|
||||||
|
|
||||||
|
// Apply pagination if provided
|
||||||
|
if ($request->has('page') && $request->has('size')) {
|
||||||
|
$page = $request->get('page');
|
||||||
|
$size = $request->get('size');
|
||||||
|
$offset = ($page - 1) * $size; // Calculate the offset
|
||||||
|
|
||||||
|
$query->skip($offset)->take($size);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get the filtered count of records
|
||||||
|
$filteredRecords = $query->count();
|
||||||
|
|
||||||
|
// Get the data for the current page
|
||||||
|
$data = $query->get();
|
||||||
|
|
||||||
|
// Calculate the page count
|
||||||
|
$pageCount = ceil($totalRecords / $request->get('size'));
|
||||||
|
|
||||||
|
// Calculate the current page number
|
||||||
|
$currentPage = 0 + 1;
|
||||||
|
|
||||||
|
// Return the response data as a JSON object
|
||||||
|
return response()->json([
|
||||||
|
'draw' => $request->get('draw'),
|
||||||
|
'recordsTotal' => $totalRecords,
|
||||||
|
'recordsFiltered' => $filteredRecords,
|
||||||
|
'pageCount' => $pageCount,
|
||||||
|
'page' => $currentPage,
|
||||||
|
'totalCount' => $totalRecords,
|
||||||
|
'data' => $data,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function export()
|
||||||
|
{
|
||||||
|
return Excel::download(new TujuanPenilaianExport, 'tujuan_penilaian.xlsx');
|
||||||
|
}
|
||||||
|
}
|
||||||
174
app/Http/Controllers/TujuanPenilaianKJPPController.php
Normal file
174
app/Http/Controllers/TujuanPenilaianKJPPController.php
Normal file
@@ -0,0 +1,174 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Modules\Lpj\Http\Controllers;
|
||||||
|
|
||||||
|
use Throwable;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use Maatwebsite\Excel\Facades\Excel;
|
||||||
|
use Modules\Lpj\Models\TujuanPenilaianKJPP;
|
||||||
|
use Modules\Lpj\Exports\TujuanPenilaianKJPPExport;
|
||||||
|
use Modules\Lpj\Http\Requests\JenisPenilaianKJPPRequest;
|
||||||
|
|
||||||
|
class TujuanPenilaianKJPPController extends Controller
|
||||||
|
{
|
||||||
|
public $user;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Display a listing of the resource.
|
||||||
|
*/
|
||||||
|
public function index()
|
||||||
|
{
|
||||||
|
return view('lpj::tujuan_penilaian_kjpp.index');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show the form for creating a new resource.
|
||||||
|
*/
|
||||||
|
public function create()
|
||||||
|
{
|
||||||
|
return view('lpj::tujuan_penilaian_kjpp.create');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Store a newly created resource in storage.
|
||||||
|
*/
|
||||||
|
public function store(JenisPenilaianKJPPRequest $request)
|
||||||
|
{
|
||||||
|
$validate = $request->validated();
|
||||||
|
|
||||||
|
if ($validate) {
|
||||||
|
try {
|
||||||
|
TujuanPenilaianKJPP::create($validate);
|
||||||
|
return redirect()
|
||||||
|
->route('basicdata.tujuan_penilaian_kjpp.index')
|
||||||
|
->with('success', 'Tujuan Penilaian KJPP created successfully');
|
||||||
|
} catch (Throwable $e) {
|
||||||
|
return redirect()
|
||||||
|
->route('basicdata.tujuan_penilaian_kjpp.create')
|
||||||
|
->with('success', 'Failed to create Tujuan Penilaian KJPP: ' . $e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show the specified resource.
|
||||||
|
*/
|
||||||
|
public function show($id)
|
||||||
|
{
|
||||||
|
return view('lpj::show');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show the form for editing the specified resource.
|
||||||
|
*/
|
||||||
|
public function edit($id)
|
||||||
|
{
|
||||||
|
$tujuanPenilaianKJPP = TujuanPenilaianKJPP::find($id);
|
||||||
|
return view('lpj::tujuan_penilaian_kjpp.create', compact('tujuanPenilaianKJPP'));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update the specified resource in storage.
|
||||||
|
*/
|
||||||
|
public function update(JenisPenilaianKJPPRequest $request, $id)
|
||||||
|
{
|
||||||
|
$validate = $request->validated();
|
||||||
|
|
||||||
|
if ($validate) {
|
||||||
|
try {
|
||||||
|
$tujuanPenilaianKJPP = TujuanPenilaianKJPP::find($id);
|
||||||
|
$tujuanPenilaianKJPP->update($validate);
|
||||||
|
return redirect()
|
||||||
|
->route('basicdata.tujuan_penilaian_kjpp.index')
|
||||||
|
->with('success', 'Tujuan Penilaian KJPP updated successfully');
|
||||||
|
} catch (Throwable $e) {
|
||||||
|
return redirect()
|
||||||
|
->route('basicdata.tujuan_penilaian_kjpp.edit', $id)
|
||||||
|
->with('success', 'Failed to update Tujuan Penilaian KJPP: ' . $e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove the specified resource from storage.
|
||||||
|
*/
|
||||||
|
public function destroy($id)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
// Delete from database
|
||||||
|
$tujuanPenilaianKJPP = TujuanPenilaianKJPP::find($id);
|
||||||
|
$tujuanPenilaianKJPP->delete();
|
||||||
|
|
||||||
|
echo json_encode(['success' => true, 'message' => 'Tujuan Penilaian deleted successfully']);
|
||||||
|
} catch (Throwable $e) {
|
||||||
|
echo json_encode(['success' => false, 'message' => 'Failed to delete deleted']);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function dataForDatatables(Request $request)
|
||||||
|
{
|
||||||
|
if (is_null($this->user) || !$this->user->can('jenis_jaminan.view')) {
|
||||||
|
//abort(403, 'Sorry! You are not allowed to view users.');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Retrieve data from the database
|
||||||
|
$query = TujuanPenilaianKJPP::query();
|
||||||
|
|
||||||
|
// Apply search filter if provided
|
||||||
|
if ($request->has('search') && !empty($request->get('search'))) {
|
||||||
|
$search = $request->get('search');
|
||||||
|
$query->where(function ($q) use ($search) {
|
||||||
|
$q->where('code', 'LIKE', "%$search%");
|
||||||
|
$q->orWhere('name', 'LIKE', "%$search%");
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// Apply sorting if provided
|
||||||
|
if ($request->has('sortOrder') && !empty($request->get('sortOrder'))) {
|
||||||
|
$order = $request->get('sortOrder');
|
||||||
|
$column = $request->get('sortField');
|
||||||
|
$query->orderBy($column, $order);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get the total count of records
|
||||||
|
$totalRecords = $query->count();
|
||||||
|
|
||||||
|
// Apply pagination if provided
|
||||||
|
if ($request->has('page') && $request->has('size')) {
|
||||||
|
$page = $request->get('page');
|
||||||
|
$size = $request->get('size');
|
||||||
|
$offset = ($page - 1) * $size; // Calculate the offset
|
||||||
|
|
||||||
|
$query->skip($offset)->take($size);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get the filtered count of records
|
||||||
|
$filteredRecords = $query->count();
|
||||||
|
|
||||||
|
// Get the data for the current page
|
||||||
|
$data = $query->get();
|
||||||
|
|
||||||
|
// Calculate the page count
|
||||||
|
$pageCount = ceil($totalRecords / $request->get('size'));
|
||||||
|
|
||||||
|
// Calculate the current page number
|
||||||
|
$currentPage = 0 + 1;
|
||||||
|
|
||||||
|
// Return the response data as a JSON object
|
||||||
|
return response()->json([
|
||||||
|
'draw' => $request->get('draw'),
|
||||||
|
'recordsTotal' => $totalRecords,
|
||||||
|
'recordsFiltered' => $filteredRecords,
|
||||||
|
'pageCount' => $pageCount,
|
||||||
|
'page' => $currentPage,
|
||||||
|
'totalCount' => $totalRecords,
|
||||||
|
'data' => $data,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function export()
|
||||||
|
{
|
||||||
|
return Excel::download(new TujuanPenilaianKJPPExport, 'jenis_laporan.xlsx');
|
||||||
|
}
|
||||||
|
}
|
||||||
30
app/Http/Requests/ArahMataAnginRequest.php
Normal file
30
app/Http/Requests/ArahMataAnginRequest.php
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Modules\Lpj\Http\Requests;
|
||||||
|
|
||||||
|
use Illuminate\Foundation\Http\FormRequest;
|
||||||
|
|
||||||
|
class ArahMataAnginRequest extends FormRequest
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Get the validation rules that apply to the request.
|
||||||
|
*/
|
||||||
|
public function rules()
|
||||||
|
: array
|
||||||
|
{
|
||||||
|
$rules = [
|
||||||
|
'name' => 'required|max:255',
|
||||||
|
];
|
||||||
|
|
||||||
|
return $rules;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determine if the user is authorized to make this request.
|
||||||
|
*/
|
||||||
|
public function authorize()
|
||||||
|
: bool
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
57
app/Http/Requests/BankDataRequest.php
Normal file
57
app/Http/Requests/BankDataRequest.php
Normal file
@@ -0,0 +1,57 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Modules\Lpj\Http\Requests;
|
||||||
|
|
||||||
|
use Illuminate\Foundation\Http\FormRequest;
|
||||||
|
|
||||||
|
class BankDataRequest extends FormRequest
|
||||||
|
{
|
||||||
|
public function authorize()
|
||||||
|
{
|
||||||
|
return true; // Adjust this based on your authorization logic
|
||||||
|
}
|
||||||
|
|
||||||
|
public function rules()
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'address' => 'nullable|string|max:255',
|
||||||
|
'village_code' => 'nullable|string|max:20',
|
||||||
|
'district_code' => 'nullable|string|max:20',
|
||||||
|
'city_code' => 'nullable|string|max:20',
|
||||||
|
'province_code' => 'nullable|string|max:20',
|
||||||
|
'tahun' => 'nullable|integer',
|
||||||
|
'luas_tanah' => 'nullable|numeric',
|
||||||
|
'luas_bangunan' => 'nullable|numeric',
|
||||||
|
'tahun_bangunan' => 'nullable|integer',
|
||||||
|
'status_nara_sumber' => 'nullable|string|max:50',
|
||||||
|
'harga' => 'nullable|numeric',
|
||||||
|
'harga_diskon' => 'nullable|numeric',
|
||||||
|
'diskon' => 'nullable|numeric',
|
||||||
|
'total' => 'nullable|numeric',
|
||||||
|
'nama_nara_sumber' => 'nullable|string|max:100',
|
||||||
|
'peruntukan' => 'nullable|string|max:100',
|
||||||
|
'penawaran' => 'nullable|string|max:50',
|
||||||
|
'telepon' => 'nullable|string|max:20',
|
||||||
|
'hak_properti' => 'nullable|string|max:50',
|
||||||
|
'kordinat_lat' => 'nullable|numeric',
|
||||||
|
'kordinat_lng' => 'nullable|numeric',
|
||||||
|
'jenis_aset' => 'nullable|string|max:50',
|
||||||
|
'foto_objek' => 'nullable|image|max:2048',
|
||||||
|
'tanggal' => 'nullable|date',
|
||||||
|
'harga_penawaran' => 'nullable|numeric',
|
||||||
|
'nomor_laporan' => 'nullable|string|max:50',
|
||||||
|
'tgl_final_laporan' => 'nullable|date',
|
||||||
|
'nilai_pasar' => 'nullable|numeric',
|
||||||
|
'indikasi_nilai_likuidasi' => 'nullable|numeric',
|
||||||
|
'indikasi_nilai_pasar_tanah' => 'nullable|numeric',
|
||||||
|
'estimasi_harga_tanah' => 'nullable|numeric',
|
||||||
|
'estimasi_harga_bangunan' => 'nullable|numeric',
|
||||||
|
'indikasi_nilai_pasar_bangunan' => 'nullable|numeric',
|
||||||
|
'indikasi_nilai_pasar_sarana_pelengkap' => 'nullable|numeric',
|
||||||
|
'indikasi_nilai_pasar_mesin' => 'nullable|numeric',
|
||||||
|
'indikasi_nilai_pasar_kendaraan_alat_berat' => 'nullable|numeric',
|
||||||
|
'photos' => 'nullable|array',
|
||||||
|
'photos.*' => 'nullable|image|max:2048',
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
58
app/Http/Requests/CustomFieldRequest.php
Normal file
58
app/Http/Requests/CustomFieldRequest.php
Normal file
@@ -0,0 +1,58 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Modules\Lpj\Http\Requests;
|
||||||
|
|
||||||
|
use Illuminate\Foundation\Http\FormRequest;
|
||||||
|
use Modules\Lpj\Models\CustomField;
|
||||||
|
use Illuminate\Validation\Rule;
|
||||||
|
|
||||||
|
class CustomFieldRequest extends FormRequest
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Get the validation rules that apply to the request.
|
||||||
|
*/
|
||||||
|
public function rules(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'name' => 'required|max:255',
|
||||||
|
'type' => 'required|in:text,select,radio,checkbox,date,number',
|
||||||
|
'label' => 'nullable|max:255',
|
||||||
|
'urutan_prioritas' => [
|
||||||
|
'nullable',
|
||||||
|
'integer',
|
||||||
|
Rule::unique('custom_fields')->ignore($this->route('custom_field')),
|
||||||
|
],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determine if the user is authorized to make this request.
|
||||||
|
*/
|
||||||
|
public function authorize(): bool
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function prepareValidationData($data){
|
||||||
|
if(!$this->type){
|
||||||
|
$this->merge(['type' => 'text']);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!$this->urutan_prioritas) {
|
||||||
|
$maxPrioritas = CustomField::max('urutan_prioritas') ?? 0;
|
||||||
|
$this->merge(['urutan_prioritas' => $maxPrioritas + 1]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get custom messages for validator errors.
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function messages()
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'urutan_prioritas.unique' => 'Urutan prioritas sudah digunakan. Silakan pilih nomor lain.',
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
51
app/Http/Requests/DebitureRequest.php
Normal file
51
app/Http/Requests/DebitureRequest.php
Normal file
@@ -0,0 +1,51 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Modules\Lpj\Http\Requests;
|
||||||
|
|
||||||
|
use Illuminate\Foundation\Http\FormRequest;
|
||||||
|
use Modules\Lpj\Rules\UniqueCifExceptZero;
|
||||||
|
use Modules\Lpj\Rules\UniqueExcept;
|
||||||
|
|
||||||
|
class DebitureRequest extends FormRequest
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Get the validation rules that apply to the request.
|
||||||
|
*/
|
||||||
|
public function rules()
|
||||||
|
: array
|
||||||
|
{
|
||||||
|
$rules = [
|
||||||
|
'branch_id' => 'required|exists:branches,id',
|
||||||
|
'province_code' => 'nullable|exists:provinces,code',
|
||||||
|
'city_code' => 'nullable|exists:cities,code',
|
||||||
|
'district_code' => 'nullable|exists:districts,code',
|
||||||
|
'village_code' => 'nullable|exists:villages,code',
|
||||||
|
'nomor_rekening' => 'nullable|string|max:50',
|
||||||
|
'name' => 'required',
|
||||||
|
'registered_at' => 'nullable|date',
|
||||||
|
'npwp' => 'nullable|string|min:15|max:16',
|
||||||
|
'email' => 'nullable|email',
|
||||||
|
'phone' => 'nullable|string|max:15',
|
||||||
|
'address' => 'nullable|string',
|
||||||
|
'postal_code' => 'nullable|string|max:10',
|
||||||
|
'status' => 'nullable|boolean'
|
||||||
|
];
|
||||||
|
|
||||||
|
if($this->method() == 'PUT'){
|
||||||
|
$rules['cif'] = ['required', new UniqueCifExceptZero($this->id)];
|
||||||
|
}else{
|
||||||
|
$rules['cif'] = ['required', new UniqueCifExceptZero(null)];
|
||||||
|
}
|
||||||
|
|
||||||
|
return $rules;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determine if the user is authorized to make this request.
|
||||||
|
*/
|
||||||
|
public function authorize()
|
||||||
|
: bool
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
43
app/Http/Requests/DetailDokumenJaminanRequest.php
Normal file
43
app/Http/Requests/DetailDokumenJaminanRequest.php
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Modules\Lpj\Http\Requests;
|
||||||
|
|
||||||
|
use Illuminate\Foundation\Http\FormRequest;
|
||||||
|
|
||||||
|
class DokumenJaminanRequest extends FormRequest
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Get the validation rules that apply to the request.
|
||||||
|
*/
|
||||||
|
public function rules()
|
||||||
|
: array
|
||||||
|
{
|
||||||
|
$rules = [
|
||||||
|
'debiture_id' => 'required|exists:debitures,id',
|
||||||
|
'pemilik_jaminan_id' => 'required',
|
||||||
|
'jenis_jaminan_id' => 'required',
|
||||||
|
'jenis_legalitas_jaminan_id' => 'required',
|
||||||
|
'dokumen_jaminan' => 'nullable|file|mimes:pdf',
|
||||||
|
'keterangan' => 'nullable|string|max:255',
|
||||||
|
'province_code' => 'nullable|exists:provinces,code',
|
||||||
|
'city_code' => 'nullable|exists:cities,code',
|
||||||
|
'district_code' => 'nullable|exists:districts,code',
|
||||||
|
'village_code' => 'nullable|exists:villages,code',
|
||||||
|
'name' => 'required',
|
||||||
|
'address' => 'nullable|string',
|
||||||
|
'postal_code' => 'nullable|string|max:10',
|
||||||
|
'status' => 'nullable|boolean',
|
||||||
|
];
|
||||||
|
|
||||||
|
return $rules;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determine if the user is authorized to make this request.
|
||||||
|
*/
|
||||||
|
public function authorize()
|
||||||
|
: bool
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
40
app/Http/Requests/DokumenJaminanRequest.php
Normal file
40
app/Http/Requests/DokumenJaminanRequest.php
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Modules\Lpj\Http\Requests;
|
||||||
|
|
||||||
|
use Illuminate\Foundation\Http\FormRequest;
|
||||||
|
|
||||||
|
class DokumenJaminanRequest extends FormRequest
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Get the validation rules that apply to the request.
|
||||||
|
*/
|
||||||
|
public function rules()
|
||||||
|
: array
|
||||||
|
{
|
||||||
|
$rules = [
|
||||||
|
'debiture_id' => 'required|exists:debitures,id',
|
||||||
|
'permohonan_id' => 'required|exists:permohonan,id',
|
||||||
|
'pemilik_jaminan_id' => 'required',
|
||||||
|
'jenis_jaminan_id' => 'required',
|
||||||
|
'province_code' => 'nullable|exists:provinces,code',
|
||||||
|
'city_code' => 'nullable|exists:cities,code',
|
||||||
|
'district_code' => 'nullable|exists:districts,code',
|
||||||
|
'village_code' => 'nullable|exists:villages,code',
|
||||||
|
'address' => 'nullable|string',
|
||||||
|
'postal_code' => 'nullable|string|max:10',
|
||||||
|
'status' => 'nullable|boolean',
|
||||||
|
];
|
||||||
|
|
||||||
|
return $rules;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determine if the user is authorized to make this request.
|
||||||
|
*/
|
||||||
|
public function authorize()
|
||||||
|
: bool
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
699
app/Http/Requests/FormSurveyorRequest.php
Normal file
699
app/Http/Requests/FormSurveyorRequest.php
Normal file
@@ -0,0 +1,699 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Modules\Lpj\Http\Requests;
|
||||||
|
|
||||||
|
use Illuminate\Foundation\Http\FormRequest;
|
||||||
|
|
||||||
|
class FormSurveyorRequest extends FormRequest
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Determine if the user is authorized to make this request.
|
||||||
|
*/
|
||||||
|
public function authorize(): bool
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the validation rules that apply to the request.
|
||||||
|
*/
|
||||||
|
public function rules(): array
|
||||||
|
{
|
||||||
|
|
||||||
|
$actionSpecificRules = $this->getActionSpecificRules();
|
||||||
|
return $actionSpecificRules;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get rules specific to the action.
|
||||||
|
*/
|
||||||
|
private function getActionSpecificRules(): array
|
||||||
|
{
|
||||||
|
$action = $this->input('action');
|
||||||
|
$pisah = explode(',', $action);
|
||||||
|
|
||||||
|
$allRules = [
|
||||||
|
'tanah' => $this->getTanahRules(),
|
||||||
|
'bangunan' => $this->getBangunanRules(),
|
||||||
|
'kapal' => $this->getKapalRules(),
|
||||||
|
'kendaraan' => $this->getKendaraanRules(),
|
||||||
|
'mesin' => $this->getMesinRules(),
|
||||||
|
'pesawat' => $this->getPesawatRules(),
|
||||||
|
'alat-berat' => $this->getAlatBeratRules(),
|
||||||
|
'apartemen-kantor' => $this->getUnitRules(),
|
||||||
|
'lingkungan' => $this->getLinkunganRules(),
|
||||||
|
'fakta' => $this->getCommonRules(),
|
||||||
|
'rap' => $this->getRapRules()
|
||||||
|
];
|
||||||
|
|
||||||
|
$rules = [];
|
||||||
|
$hasAssetDescriptionRules = false;
|
||||||
|
|
||||||
|
foreach ($pisah as $act) {
|
||||||
|
if (isset($allRules[$act])) {
|
||||||
|
$rules = array_merge($rules, $allRules[$act]);
|
||||||
|
if ($act == 'tanah' || $act == 'bangunan' || $act == 'apartemen-kantor' || $act == 'rap') {
|
||||||
|
$hasAssetDescriptionRules = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($hasAssetDescriptionRules) {
|
||||||
|
$rules = array_merge($rules, $this->getAssetDescriptionRules());
|
||||||
|
}
|
||||||
|
|
||||||
|
return $rules;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Get rules specific to tanah action.
|
||||||
|
*/
|
||||||
|
|
||||||
|
public function getTanahRules(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'luas_tanah' => 'required',
|
||||||
|
'luas_tanah_sesuai' => 'nullable',
|
||||||
|
'luas_tanah_tidak_sesuai' => 'nullable',
|
||||||
|
'hadap_mata_angin' => 'required',
|
||||||
|
'hadap_mata_angin_sesuai' => 'nullable',
|
||||||
|
'hadap_mata_angin_tidak_sesuai' => 'nullable',
|
||||||
|
'bentuk_tanah' => 'required|array',
|
||||||
|
'bentuk_tanah_lainnya' => 'nullable',
|
||||||
|
'kontur_tanah' => 'required|array',
|
||||||
|
'ketinggian_jalan' => 'required|array',
|
||||||
|
'kontur_jalan' => 'required',
|
||||||
|
'posisi_kavling' => 'required|array',
|
||||||
|
'posisi_kavling_lainnya' => 'nullable',
|
||||||
|
'tusuk_sate' => 'required',
|
||||||
|
'lockland' => 'required',
|
||||||
|
'kondisi_fisik_tanah' => 'required|array',
|
||||||
|
'ketinggian_lebih_tinggi' => 'nullable',
|
||||||
|
'ketinggian_lebih_rendah' => 'nullable',
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get rules specific to Bangunan action.
|
||||||
|
*/
|
||||||
|
|
||||||
|
private function getBangunanRules(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'action' => 'required',
|
||||||
|
'luas_tanah_bangunan_sesuai' => 'nullable',
|
||||||
|
'luas_tanah_bagunan' => 'required',
|
||||||
|
'luas_tanah_bangunan_tidak_sesuai' => 'nullable',
|
||||||
|
'jenis_bangunan' => 'required|array',
|
||||||
|
'kondisi_bangunan' => 'required|array',
|
||||||
|
'sifat_bangunan' => 'required|array',
|
||||||
|
'sifat_bangunan_input' => 'nullable|array',
|
||||||
|
|
||||||
|
|
||||||
|
'nama_bangunan.*' => 'required|string|max:255',
|
||||||
|
'spek_kategori_bangunan.*' => 'nullable|string',
|
||||||
|
'spek_bangunan.*.*.lainnya' => 'nullable|string',
|
||||||
|
|
||||||
|
'sarana_pelengkap' => 'required',
|
||||||
|
'sarana_pelengkap_input' => 'nullable|array',
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get rules specific to unit action.
|
||||||
|
*/
|
||||||
|
private function getUnitRules(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'action' => 'required',
|
||||||
|
'luas_unit' => 'required',
|
||||||
|
'luas_unit_sesuai' => 'nullable',
|
||||||
|
'luas_unit_tidak_sesuai' => 'nullable',
|
||||||
|
'kondisi_unit' => 'required|array',
|
||||||
|
'posisi_unit' => 'required|array',
|
||||||
|
'lantai' => 'required|array',
|
||||||
|
'view' => 'required|array',
|
||||||
|
'bentuk_unit' => 'required|array',
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get rules specific to Linkungan action.
|
||||||
|
*/
|
||||||
|
|
||||||
|
private function getLinkunganRules(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'action' => 'required',
|
||||||
|
'jarak_jalan_utama' => 'nullable',
|
||||||
|
'jalan_linkungan' => 'nullable',
|
||||||
|
'jarak_cbd_point' => 'nullable',
|
||||||
|
'nama_cbd_point' => 'nullable',
|
||||||
|
'lebar_perkerasan_jalan' => 'nullable',
|
||||||
|
'perkerasan_jalan' => 'nullable|array',
|
||||||
|
'perkerasan_jalan_lainnya' => 'nullable',
|
||||||
|
'lalu_lintas' => 'nullable',
|
||||||
|
'gol_mas_sekitar' => 'nullable',
|
||||||
|
'tingkat_keramaian' => 'nullable',
|
||||||
|
'terletak_diarea' => 'nullable',
|
||||||
|
'terletak_diarea_lainnya' => 'nullable',
|
||||||
|
'disekitar_lokasi' => 'required',
|
||||||
|
'kondisi_bagunan_disekitar_lokasi' => 'nullable',
|
||||||
|
'sifat_bagunan_disekitar_lokasi' => 'nullable',
|
||||||
|
'dekat_makam' => 'nullable',
|
||||||
|
'jarak_makam' => 'nullable',
|
||||||
|
'nama_makam' => 'nullable',
|
||||||
|
'dekat_tps' => 'nullable',
|
||||||
|
'jarak_tps' => 'nullable',
|
||||||
|
'nama_tpu' => 'nullable',
|
||||||
|
'dekat_lainnya' => 'nullable',
|
||||||
|
'merupakan_daerah' => 'nullable',
|
||||||
|
'fasilitas_dekat_object' => 'nullable|array',
|
||||||
|
'fasilitas_dekat_object_input' => 'nullable|array',
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
private function getKapalRules(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'action' => 'required',
|
||||||
|
'nama_wakil_debitur' => 'nullable',
|
||||||
|
'hub_calon_debitur' => 'required',
|
||||||
|
'dermaga' => 'nullable',
|
||||||
|
'nama_jalan' => 'required',
|
||||||
|
'perumahan_gang' => 'required',
|
||||||
|
'blok_nomor' => 'required',
|
||||||
|
|
||||||
|
'village_code' => 'nullable|string',
|
||||||
|
'district_code' => 'nullable|string',
|
||||||
|
'city_code' => 'nullable|string',
|
||||||
|
'province_code' => 'nullable|string',
|
||||||
|
|
||||||
|
'jenis_kapal' => 'required',
|
||||||
|
'jenis_kapal_lainnya' => 'nullable',
|
||||||
|
'size' => 'required',
|
||||||
|
'kondisi' => 'required',
|
||||||
|
'klasifikasi' => 'required',
|
||||||
|
|
||||||
|
'nama_kapal' => 'required',
|
||||||
|
'pemilik_kapal' => 'required',
|
||||||
|
'bendera' => 'required',
|
||||||
|
'nomor_selar' => 'required',
|
||||||
|
'kapal' => 'required',
|
||||||
|
'galangan_kapal' => 'required',
|
||||||
|
'kapal_shipyard' => 'required',
|
||||||
|
'tahun_pembuatan' => 'required',
|
||||||
|
'tahun_launcing' => 'required',
|
||||||
|
'dwt' => 'required',
|
||||||
|
'lwt' => 'required',
|
||||||
|
'gross_tonnage' => 'required',
|
||||||
|
'net_tonnage' => 'required',
|
||||||
|
'tenaga_mesin' => 'required',
|
||||||
|
'loa' => 'required',
|
||||||
|
'lbp' => 'required',
|
||||||
|
'beam' => 'required',
|
||||||
|
'depth' => 'required',
|
||||||
|
'draft' => 'required',
|
||||||
|
|
||||||
|
'lambung_kapal' => 'required',
|
||||||
|
'dek' => 'required',
|
||||||
|
'struktur_rangka' => 'required',
|
||||||
|
'palka' => 'required',
|
||||||
|
'pondasi_mesin' => 'required',
|
||||||
|
'area_mesin' => 'required',
|
||||||
|
'cat_dan_korosi' => 'required',
|
||||||
|
'sistem_pengelasan' => 'required',
|
||||||
|
'deskripsi_struktur' => 'required',
|
||||||
|
|
||||||
|
'sekoci' => 'required',
|
||||||
|
'jaket_pelampung' => 'required',
|
||||||
|
'alat_pemadaman' => 'required',
|
||||||
|
'rambu_darurat' => 'required',
|
||||||
|
'sistem_alarm' => 'required',
|
||||||
|
'sistem_pencegah' => 'required',
|
||||||
|
'kebakaran' => 'required',
|
||||||
|
'lampu_darurat' => 'required',
|
||||||
|
'deskripsi_peralatan' => 'required',
|
||||||
|
|
||||||
|
'gps' => 'required',
|
||||||
|
'radar' => 'required',
|
||||||
|
'radio_komunikasi' => 'required',
|
||||||
|
'lampu_navigasi' => 'required',
|
||||||
|
'sistem_kendali_otomatis' => 'required',
|
||||||
|
'kompas' => 'required',
|
||||||
|
'deskripsi_navigasi' => 'required',
|
||||||
|
|
||||||
|
'mesin_utama' => 'required',
|
||||||
|
'mesin_bantu' => 'required',
|
||||||
|
'pompa_pendingin' => 'required',
|
||||||
|
'sistem_pelumasan' => 'required',
|
||||||
|
'propeller' => 'required',
|
||||||
|
'sistem_kelistrikan' => 'required',
|
||||||
|
'deskripsi_mesin_penggerak' => 'required',
|
||||||
|
|
||||||
|
'lampu_navigasi' => 'required',
|
||||||
|
'sistem_penerangan' => 'required',
|
||||||
|
'sistem_panel_distribusi' => 'required',
|
||||||
|
'kabel_perangkat' => 'required',
|
||||||
|
'deskripsi_kelistrikan' => 'required',
|
||||||
|
|
||||||
|
'kebersihan_dek_luar' => 'nullable',
|
||||||
|
'tangki_limbah' => 'nullable',
|
||||||
|
'sistem_pengelolaan_limbah' => 'nullable',
|
||||||
|
'pengelolaan_air_ballast' => 'nullable',
|
||||||
|
'deskripsi_kebersihan' => 'required',
|
||||||
|
|
||||||
|
'fakta_positif.*' => 'nullable',
|
||||||
|
'fakta_negatif.*' => 'nullable',
|
||||||
|
'analisa_makro.*' => 'nullable',
|
||||||
|
'kesimpulan.*' => 'nullable',
|
||||||
|
'catatan.*' => 'nullable',
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getKendaraanRules(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'action' => 'required',
|
||||||
|
'tanggal_survey' => 'required',
|
||||||
|
'nama_wakil' => 'required',
|
||||||
|
'hub_calon_debitur' => 'required',
|
||||||
|
'nama_jalan' => 'required',
|
||||||
|
'perumahan_gang' => 'required',
|
||||||
|
'blok_nomor' => 'required',
|
||||||
|
|
||||||
|
'village_code' => 'nullable|string',
|
||||||
|
'district_code' => 'nullable|string',
|
||||||
|
'city_code' => 'nullable|string',
|
||||||
|
'province_code' => 'nullable|string',
|
||||||
|
|
||||||
|
'masa_stnk' => 'required',
|
||||||
|
'masa_pajak' => 'required',
|
||||||
|
'kendaraan.*' => 'required',
|
||||||
|
'kendaraan_input.*' => 'nullable',
|
||||||
|
'kondisi' => 'required',
|
||||||
|
'nomor_polisi' => 'required',
|
||||||
|
'nomor_polis_tidak_sesuai' => 'nullable',
|
||||||
|
'merek' => 'required',
|
||||||
|
'merek_tidak_sesuai' => 'nullable',
|
||||||
|
'warna' => 'required',
|
||||||
|
'warna_tidak_sesuai' => 'nullable',
|
||||||
|
'nomor_rangka' => 'required',
|
||||||
|
'nomor_rangka_tidak_sesuai' => 'nullable',
|
||||||
|
'nomor_mesin' => 'required',
|
||||||
|
'nomor_mesin_tidak_sesuai' => 'nullable',
|
||||||
|
'posisi_kilometer' => 'required',
|
||||||
|
'transmisi' => 'required',
|
||||||
|
'transmisi_input' => 'nullable',
|
||||||
|
'mesin_panel_instrument.*' => 'required',
|
||||||
|
'mesin_panel_instrument_input.*' => 'nullable',
|
||||||
|
'fungsi_mesin_panel_instrument.*' => 'required',
|
||||||
|
'fungsi_mesin_panel_instrument_input.*' => 'nullable',
|
||||||
|
'interior.*' => 'required',
|
||||||
|
'interior_input.*' => 'nullable',
|
||||||
|
'jumlah_pintu.*' => 'required',
|
||||||
|
'jumlah_pintu_input.*' => 'nullable',
|
||||||
|
'rangka_karoseri.*' => 'required',
|
||||||
|
'rangka_karoseri_input.*' => 'nullable',
|
||||||
|
'ban.*' => 'required',
|
||||||
|
'ban_input.*' => 'nullable',
|
||||||
|
'velg.*' => 'required',
|
||||||
|
'velg_input.*' => 'nullable',
|
||||||
|
'bamper_depan.*' => 'required',
|
||||||
|
'bamper_depan_input.*' => 'nullable',
|
||||||
|
'bamper_belakang.*' => 'required',
|
||||||
|
'bamper_belakang_input.*' => 'nullable',
|
||||||
|
'lampu_depan.*' => 'required',
|
||||||
|
'lampu_depan_input.*' => 'nullable',
|
||||||
|
'lampu_belakang.*' => 'required',
|
||||||
|
'lampu_belakang_input.*' => 'nullable',
|
||||||
|
'kaca_kendaraan.*' => 'required',
|
||||||
|
'kaca_kendaraan_input.*' => 'nullable',
|
||||||
|
'air_conditioner.*' => 'required',
|
||||||
|
'air_conditioner_input.*' => 'nullable',
|
||||||
|
'tape_radio_cd.*' => 'required',
|
||||||
|
'tape_radio_cd_input.*' => 'nullable',
|
||||||
|
'sensor_parkir.*' => 'required',
|
||||||
|
'sensor_parkir_input.*' => 'nullable',
|
||||||
|
'sensor_camera_recorder.*' => 'required',
|
||||||
|
'sensor_camera_recorder_input.*' => 'nullable',
|
||||||
|
'lcd.*' => 'required',
|
||||||
|
'lcd_input.*' => 'nullable',
|
||||||
|
'sabuk_keselamatan.*' => 'required',
|
||||||
|
'sabuk_keselamatan_input.*' => 'nullable',
|
||||||
|
'airbag.*' => 'required',
|
||||||
|
'airbag_input.*' => 'nullable',
|
||||||
|
'asuransi.*' => 'required',
|
||||||
|
'asuransi_input.*' => 'nullable',
|
||||||
|
'perusahaan_asuransi' => 'required',
|
||||||
|
'tahun_berakhir' => 'required',
|
||||||
|
'fakta_positif.*' => 'nullable',
|
||||||
|
'fakta_negatif.*' => 'nullable',
|
||||||
|
'analisa_makro.*' => 'nullable',
|
||||||
|
'kesimpulan.*' => 'nullable',
|
||||||
|
'catatan.*' => 'nullable',
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public function getMesinRules(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'action' => 'required',
|
||||||
|
'nama_wakil' => 'required',
|
||||||
|
'nama_jalan' => 'required',
|
||||||
|
'perumahan_gang' => 'required',
|
||||||
|
'blok' => 'required',
|
||||||
|
'desa_kelurahan' => 'required',
|
||||||
|
'kecamatan' => 'required',
|
||||||
|
'kota_madya' => 'required',
|
||||||
|
'provinsi' => 'required',
|
||||||
|
'hub_calon_debitur' => 'required',
|
||||||
|
'tipe_model' => 'required',
|
||||||
|
'merek' => 'required',
|
||||||
|
'tahun_pembuatan' => 'required',
|
||||||
|
'negara_pembuat' => 'required',
|
||||||
|
'kondisi_mesin' => 'required',
|
||||||
|
'faktor_positif' => 'nullable',
|
||||||
|
'faktor_negatif' => 'nullable',
|
||||||
|
'kesimpulan' => 'nullable',
|
||||||
|
'catatan' => 'nullable',
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public function getAlatBeratRules(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'action' => 'required',
|
||||||
|
'nama_wakil' => 'required|string',
|
||||||
|
'hub_calon_debitur' => 'required|string',
|
||||||
|
'nama_jalan' => 'required',
|
||||||
|
'perumahan_gang' => 'required',
|
||||||
|
'blok_nomor' => 'required',
|
||||||
|
'village_code' => 'nullable|string',
|
||||||
|
'district_code' => 'nullable|string',
|
||||||
|
'city_code' => 'nullable|string',
|
||||||
|
'province_code' => 'nullable|string',
|
||||||
|
'jenis_model' => 'required',
|
||||||
|
'nomor_lambung' => 'required',
|
||||||
|
'model_unit' => 'required',
|
||||||
|
'tahun_pembuatan' => 'required',
|
||||||
|
'merk' => 'required',
|
||||||
|
'negara_pembuat' => 'required',
|
||||||
|
'tahun_pembelian' => 'required',
|
||||||
|
'nomor_faktur' => 'nullable',
|
||||||
|
'nomor_kontrak' => 'nullable',
|
||||||
|
'nama_pemilik' => 'nullable',
|
||||||
|
'alamat_pemilik' => 'nullable',
|
||||||
|
'nomor_asuransi' => 'nullable',
|
||||||
|
'nomor_rangka' => 'nullable',
|
||||||
|
'nomor_mesin' => 'nullable',
|
||||||
|
'hour_mesters' => 'nullable',
|
||||||
|
'overhaul_mesin' => 'nullable',
|
||||||
|
|
||||||
|
'mesin_panel.*' => 'nullable',
|
||||||
|
'mesin_panel_input.*' => 'nullable',
|
||||||
|
'fungsi_panel.*' => 'nullable',
|
||||||
|
'fungsi_panel_input.*' => 'nullable',
|
||||||
|
'interior.*' => 'nullable',
|
||||||
|
'interior_input.*' => 'nullable',
|
||||||
|
'rangka_Karoseri.*' => 'nullable',
|
||||||
|
'rangka_Karoseri_input.*' => 'nullable',
|
||||||
|
'ban.*' => 'nullable',
|
||||||
|
'ban_innput.*' => 'nullable',
|
||||||
|
'velg.*' => 'nullable',
|
||||||
|
'velg_input.*' => 'nullable',
|
||||||
|
'air_conditioner.*' => 'nullable',
|
||||||
|
'air_conditioner_input.*' => 'nullable',
|
||||||
|
'aksesoris.*' => 'nullable',
|
||||||
|
'aksesoris_input.*' => 'nullable',
|
||||||
|
'lcd.*' => 'nullable',
|
||||||
|
'lcd_innput.*' => 'nullable',
|
||||||
|
'perlengkapan.*' => 'nullable',
|
||||||
|
'perlengkapan_input.*' => 'nullable',
|
||||||
|
'asuransi.*' => 'nullable',
|
||||||
|
'asuransi_input.*' => 'nullable',
|
||||||
|
'perusahaan_asuransi' => 'nullable',
|
||||||
|
'tahun_berakhir.*' => 'nullable',
|
||||||
|
'sensor_kamera.*' => 'nullable',
|
||||||
|
'lcd.*' => 'nullable',
|
||||||
|
'sabuk_keselamatan.*' => 'nullable',
|
||||||
|
'air_bag.*' => 'nullable',
|
||||||
|
'asuransi.*' => 'nullable',
|
||||||
|
'perusahan_asuransi' => 'nullable',
|
||||||
|
'tahun_berakhir' => 'nullable',
|
||||||
|
'fakta_positif' => 'nullable|array',
|
||||||
|
'fakta_negatif' => 'nullable|array',
|
||||||
|
'kesimpulan' => 'nullable',
|
||||||
|
'catatan' => 'nullable|array',
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
private function getPesawatRules(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'action' => 'required',
|
||||||
|
'nama_wakil' => 'required|string',
|
||||||
|
'hub_calon_debitur' => 'required|string',
|
||||||
|
'nama_jalan' => 'required',
|
||||||
|
'perumahan_gang' => 'required',
|
||||||
|
'blok_nomor' => 'required',
|
||||||
|
|
||||||
|
'village_code' => 'nullable|string',
|
||||||
|
'district_code' => 'nullable|string',
|
||||||
|
'city_code' => 'nullable|string',
|
||||||
|
'province_code' => 'nullable|string',
|
||||||
|
|
||||||
|
'jenis_pesawat' => 'required',
|
||||||
|
'jenis_pesawat_lainnya' => 'nullable',
|
||||||
|
'size' => 'required',
|
||||||
|
'kondisi' => 'required',
|
||||||
|
'nama_pesawat' => 'required',
|
||||||
|
'model' => 'required',
|
||||||
|
'nomor_registrasi' => 'required',
|
||||||
|
'tahun_pembuatan' => 'required',
|
||||||
|
'certificate_of_airworthines' => 'required',
|
||||||
|
'certificate_of_registration' => 'required',
|
||||||
|
'total_service_hours' => 'required',
|
||||||
|
'total_service_cycles' => 'required',
|
||||||
|
|
||||||
|
'last_a_check' => 'required',
|
||||||
|
'next_a_check' => 'required',
|
||||||
|
'last_b_check' => 'required',
|
||||||
|
'next_b_check' => 'required',
|
||||||
|
'last_c_check' => 'required',
|
||||||
|
'next_c_check' => 'required',
|
||||||
|
'next_d_check' => 'required',
|
||||||
|
'last_d_check' => 'required',
|
||||||
|
'deskripsi_maintenence' => 'nullable',
|
||||||
|
|
||||||
|
'instrument_landing_system' => 'required',
|
||||||
|
'traffic_collision_avoidance_system' => 'required',
|
||||||
|
'windshear' => 'required',
|
||||||
|
'electronic_flight' => 'required',
|
||||||
|
'winglets' => 'required',
|
||||||
|
'deskripsi_konfigurasi' => 'required',
|
||||||
|
|
||||||
|
|
||||||
|
'maksimal_penumpang' => 'required',
|
||||||
|
'jumlah_kursi' => 'required',
|
||||||
|
'kursi_pramugari_pramugara' => 'required',
|
||||||
|
'kartu_fitur_keselamatan' => 'required',
|
||||||
|
'sabuk_pengaman' => 'required',
|
||||||
|
'lampu_kabin' => 'required',
|
||||||
|
'lampu_pintu_keluar' => 'required',
|
||||||
|
'intercom_kabin' => 'required',
|
||||||
|
'deskripsi_kabin' => 'required',
|
||||||
|
|
||||||
|
|
||||||
|
'badan_pesawat' => 'nullable',
|
||||||
|
'sayap_pesawat' => 'required',
|
||||||
|
'ekor_pesawat' => 'required',
|
||||||
|
'landing_gear' => 'required',
|
||||||
|
'sabuk_pengaman' => 'required',
|
||||||
|
'sistem_pengelasan' => 'required',
|
||||||
|
'deskripsi_struktur' => 'required',
|
||||||
|
|
||||||
|
'gps' => 'required',
|
||||||
|
'radar' => 'required',
|
||||||
|
'radio_komunikasi' => 'required',
|
||||||
|
'lampu_navigasi' => 'required',
|
||||||
|
'sistem_autopilot' => 'required',
|
||||||
|
'deskripsi_navigasi' => 'required',
|
||||||
|
|
||||||
|
'tangki_bahan_bakar' => 'required',
|
||||||
|
'saluran_pipa_bahan_bakar' => 'required',
|
||||||
|
'pompa_bahan_bakar' => 'required',
|
||||||
|
'sistem_hidrolik_utama' => 'required',
|
||||||
|
'sistem_pendigin_hidrolik' => 'required',
|
||||||
|
'deskripsi_hidrolik' => 'required',
|
||||||
|
|
||||||
|
'mesin_utama' => 'required',
|
||||||
|
'sistem_pendorong' => 'required',
|
||||||
|
'sistem_pendigin_mesin' => 'required',
|
||||||
|
'sistem_pelumasan' => 'required',
|
||||||
|
'filter_dan_perangkat_pendukung' => 'required',
|
||||||
|
'deskripsi_kondisi_mesin' => 'required',
|
||||||
|
|
||||||
|
|
||||||
|
'jaket_pelampung' => 'required',
|
||||||
|
'pintu_darurat' => 'required',
|
||||||
|
'alat_pemadaman_kebakaran' => 'required',
|
||||||
|
'sistem_alaram_darurat' => 'required',
|
||||||
|
'sekoci' => 'required',
|
||||||
|
'masker_oxigen' => 'required',
|
||||||
|
'sabuk_pengaman' => 'required',
|
||||||
|
'deskripsi_fungsi_keselamatan' => 'required',
|
||||||
|
|
||||||
|
|
||||||
|
'sistem_ventilasi_ac' => 'required',
|
||||||
|
'sistem_penerangan_kabin' => 'required',
|
||||||
|
'panel_informasi_penumpang' => 'required',
|
||||||
|
'sistem_hiburan_kabin' => 'required',
|
||||||
|
'deskripsi_Interior' => 'required',
|
||||||
|
|
||||||
|
'fakta_positif' => 'nullable|array',
|
||||||
|
'fakta_negatif' => 'nullable|array',
|
||||||
|
'kesimpulan' => 'nullable',
|
||||||
|
'catatan' => 'nullable|array',
|
||||||
|
|
||||||
|
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
private function getAssetDescriptionRules(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'permohonan_id' => 'required',
|
||||||
|
'dokument_id' => 'required',
|
||||||
|
'type' => 'required',
|
||||||
|
'nomor_registrasi' => 'required',
|
||||||
|
'debitur_perwakilan' => 'required|array',
|
||||||
|
'jenis_asset_name' => 'nullable|',
|
||||||
|
'jenis_asset' => 'required',
|
||||||
|
'jenis_asset_tidak_sesuai' => 'nullable|string',
|
||||||
|
'alamat_sesuai' => 'required',
|
||||||
|
'alamat_tidak_sesuai' => 'nullable|string',
|
||||||
|
'pihak_bank' => 'nullable|string',
|
||||||
|
'nomor_nib' => 'nullable|string',
|
||||||
|
'hub_cadeb' => 'nullable|string',
|
||||||
|
'hub_cadeb_sesuai' => 'nullable|string',
|
||||||
|
'hub_cadeb_tidak_sesuai' => 'nullable|string',
|
||||||
|
'hub_cadeb_penghuni' => 'nullable',
|
||||||
|
'hub_cadeb_penghuni_sesuai' => 'nullable|string',
|
||||||
|
'hub_penghuni_tidak_sesuai' => 'nullable|string',
|
||||||
|
|
||||||
|
'address' => 'nullable|string',
|
||||||
|
'village_code' => 'nullable|string',
|
||||||
|
'district_code' => 'nullable|string',
|
||||||
|
'city_code' => 'nullable|string',
|
||||||
|
'province_code' => 'nullable|string',
|
||||||
|
'kordinat_lng' => 'nullable|string',
|
||||||
|
'kordinat_lat' => 'nullable|string',
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get common rules that apply to all actions.
|
||||||
|
*/
|
||||||
|
private function getCommonRules(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'fakta_positif' => 'nullable|array',
|
||||||
|
'fakta_negatif' => 'nullable|array',
|
||||||
|
'rute_menuju' => 'nullable',
|
||||||
|
'batas_batas' => 'required|array',
|
||||||
|
'batas_batas_input' => 'nullable|array',
|
||||||
|
'kondisi_lingkungan' => 'nullable|array',
|
||||||
|
'kondisi_lain_bangunan' => 'nullable|array',
|
||||||
|
'informasi_dokument' => 'nullable|array',
|
||||||
|
'peruntukan' => 'nullable',
|
||||||
|
'kdb' => 'nullable',
|
||||||
|
'kdh' => 'nullable',
|
||||||
|
'gsb' => 'nullable',
|
||||||
|
'max_lantai' => 'nullable',
|
||||||
|
'klb' => 'nullable',
|
||||||
|
'gss' => 'nullable',
|
||||||
|
'pelebaran_jalan' => 'nullable',
|
||||||
|
'nama_petugas' => 'nullable',
|
||||||
|
'lat' => 'nullable|numeric',
|
||||||
|
'lng' => 'nullable|numeric',
|
||||||
|
'foto_gistaru' => 'nullable',
|
||||||
|
'foto_bhumi' => 'nullable',
|
||||||
|
'foto_argis_region' => 'nullable',
|
||||||
|
'foto_tempat' => 'nullable',
|
||||||
|
'upload_gs' => 'nullable',
|
||||||
|
'foto_sentuh_tanahku' => 'nullable',
|
||||||
|
'keterangan' => 'nullable|array',
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
private function getRapRules()
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
|
||||||
|
|
||||||
|
'perizinan' => 'nullable|array',
|
||||||
|
'perizinan.*' => 'nullable|string',
|
||||||
|
'perizinan_file' => 'nullable|array',
|
||||||
|
'perizinan_file.*' => 'nullable|file|mimes:pdf,docx',
|
||||||
|
|
||||||
|
'brosur_price_list' => 'nullable|array',
|
||||||
|
'brosur_price_list.*' => 'nullable|string',
|
||||||
|
'brosur_price_list_file' => 'nullable|array',
|
||||||
|
'brosur_price_list_file.*' => 'nullable|file|mimes:pdf,docx',
|
||||||
|
|
||||||
|
'pengalaman_developer' => 'nullable',
|
||||||
|
'developer_anggota' => 'nullable',
|
||||||
|
'lainnya_developer.*' => 'nullable',
|
||||||
|
'kapan_mulai_dibangun' => 'nullable',
|
||||||
|
'kondisi_perumahan' => 'nullable',
|
||||||
|
'progres_pembangunan' => 'nullable',
|
||||||
|
'kontraktor' => 'nullable',
|
||||||
|
'lingkungan_sekitar' => 'nullable',
|
||||||
|
'komplek_disekitar' => 'nullable',
|
||||||
|
'pusat_keramaian' => 'nullable',
|
||||||
|
'transportasi_umum' => 'nullable',
|
||||||
|
'lainnya_kondisi.*' => 'nullable',
|
||||||
|
|
||||||
|
// Validasi untuk partisi yang diperbarui
|
||||||
|
'partisi' => 'nullable|array',
|
||||||
|
'partisi.*' => 'nullable|array',
|
||||||
|
'partisi.*.nama' => 'nullable|string',
|
||||||
|
'partisi.*.value' => 'nullable|string|max:255',
|
||||||
|
|
||||||
|
'jumlah_unit.*' => 'nullable',
|
||||||
|
'batas_batas_perumahan' => 'nullable',
|
||||||
|
'fasus_fasum.*' => 'nullable',
|
||||||
|
'progres_penjualan.*' => 'nullable',
|
||||||
|
'harga_unit.*' => 'nullable',
|
||||||
|
'target_market.*' => 'nullable',
|
||||||
|
'kerjasama_dengan_bank' => 'nullable',
|
||||||
|
'rute_menuju_lokasi' => 'nullable',
|
||||||
|
'peruntukan' => 'nullable',
|
||||||
|
'kdb' => 'nullable',
|
||||||
|
'kdh' => 'nullable',
|
||||||
|
'gsb' => 'nullable',
|
||||||
|
'max_lantai' => 'nullable',
|
||||||
|
'klb' => 'nullable',
|
||||||
|
'gss' => 'nullable',
|
||||||
|
'pelebaran_jalan' => 'nullable',
|
||||||
|
'nama_petugas' => 'nullable',
|
||||||
|
'lat' => 'nullable|numeric',
|
||||||
|
'lng' => 'nullable|numeric',
|
||||||
|
'foto_gistaru' => 'nullable',
|
||||||
|
'foto_bhumi' => 'nullable',
|
||||||
|
'foto_argis_region' => 'nullable',
|
||||||
|
'foto_tempat' => 'nullable',
|
||||||
|
'upload_gs' => 'nullable',
|
||||||
|
'foto_sentuh_tanahku' => 'nullable',
|
||||||
|
'keterangan' => 'nullable|array',
|
||||||
|
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
30
app/Http/Requests/HubunganPemilikJaminanRequest.php
Normal file
30
app/Http/Requests/HubunganPemilikJaminanRequest.php
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Modules\Lpj\Http\Requests;
|
||||||
|
|
||||||
|
use Illuminate\Foundation\Http\FormRequest;
|
||||||
|
|
||||||
|
class HubunganPemilikJaminanRequest extends FormRequest
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Get the validation rules that apply to the request.
|
||||||
|
*/
|
||||||
|
public function rules()
|
||||||
|
: array
|
||||||
|
{
|
||||||
|
$rules = [
|
||||||
|
'name' => 'required|max:255',
|
||||||
|
];
|
||||||
|
|
||||||
|
return $rules;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determine if the user is authorized to make this request.
|
||||||
|
*/
|
||||||
|
public function authorize()
|
||||||
|
: bool
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
30
app/Http/Requests/HubunganPenghuniJaminanRequest.php
Normal file
30
app/Http/Requests/HubunganPenghuniJaminanRequest.php
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Modules\Lpj\Http\Requests;
|
||||||
|
|
||||||
|
use Illuminate\Foundation\Http\FormRequest;
|
||||||
|
|
||||||
|
class HubunganPenghuniJaminanRequest extends FormRequest
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Get the validation rules that apply to the request.
|
||||||
|
*/
|
||||||
|
public function rules()
|
||||||
|
: array
|
||||||
|
{
|
||||||
|
$rules = [
|
||||||
|
'name' => 'required|max:255',
|
||||||
|
];
|
||||||
|
|
||||||
|
return $rules;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determine if the user is authorized to make this request.
|
||||||
|
*/
|
||||||
|
public function authorize()
|
||||||
|
: bool
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
46
app/Http/Requests/IjinUsahaRequest.php
Normal file
46
app/Http/Requests/IjinUsahaRequest.php
Normal file
@@ -0,0 +1,46 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Modules\Lpj\Http\Requests;
|
||||||
|
|
||||||
|
use Illuminate\Foundation\Http\FormRequest;
|
||||||
|
|
||||||
|
class IjinUsahaRequest extends FormRequest
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Get the validation rules that apply to the request.
|
||||||
|
*/
|
||||||
|
public function rules(): array
|
||||||
|
{
|
||||||
|
$rules = [
|
||||||
|
'name' => 'required|string|not_regex:/^\d+$/|max:255'
|
||||||
|
];
|
||||||
|
|
||||||
|
if ($this->method() == 'PUT') {
|
||||||
|
$rules['code'] = 'required|max:50|unique:ijin_usaha,code,' . $this->id;
|
||||||
|
} else {
|
||||||
|
$rules['code'] = 'required|max:50|unique:ijin_usaha,code';
|
||||||
|
}
|
||||||
|
|
||||||
|
return $rules;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determine if the user is authorized to make this request.
|
||||||
|
*/
|
||||||
|
public function authorize(): bool
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function messages(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'code.required' => 'Kode Ijin Usaha harus diisi!',
|
||||||
|
'code.max' => 'Kode Ijin Usaha maksimal 255 huruf!',
|
||||||
|
'code.unique' => 'Kode Ijin Usaha tidak boleh sama!',
|
||||||
|
'name.required' => 'Nama Ijin Usaha harus diisi!',
|
||||||
|
'name.not_regex' => 'Nama Ijin Usaha harus berupa huruf!',
|
||||||
|
'name.max' => 'Nama Ijin Usaha maksimal 255 huruf!'
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
35
app/Http/Requests/JenisAsetRequest.php
Normal file
35
app/Http/Requests/JenisAsetRequest.php
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Modules\Lpj\Http\Requests;
|
||||||
|
|
||||||
|
use Illuminate\Foundation\Http\FormRequest;
|
||||||
|
|
||||||
|
class JenisAsetRequest extends FormRequest
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Get the validation rules that apply to the request.
|
||||||
|
*/
|
||||||
|
public function rules()
|
||||||
|
: array
|
||||||
|
{
|
||||||
|
$rules = [
|
||||||
|
'name' => 'required|max:255',
|
||||||
|
];
|
||||||
|
|
||||||
|
if ($this->method() == 'PUT') {
|
||||||
|
$rules['code'] = 'required|max:50|unique:jenis_aset,code,' . $this->id;
|
||||||
|
} else {
|
||||||
|
$rules['code'] = 'required|max:50|unique:jenis_aset,code';
|
||||||
|
}
|
||||||
|
return $rules;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determine if the user is authorized to make this request.
|
||||||
|
*/
|
||||||
|
public function authorize()
|
||||||
|
: bool
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
32
app/Http/Requests/JenisDokumenRequest.php
Normal file
32
app/Http/Requests/JenisDokumenRequest.php
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Modules\Lpj\Http\Requests;
|
||||||
|
|
||||||
|
use Illuminate\Foundation\Http\FormRequest;
|
||||||
|
|
||||||
|
class JenisDokumenRequest extends FormRequest
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Get the validation rules that apply to the request.
|
||||||
|
*/
|
||||||
|
public function rules()
|
||||||
|
: array
|
||||||
|
{
|
||||||
|
$rules = [
|
||||||
|
'name' => 'required|max:255',
|
||||||
|
'max_size' => 'nullable|numeric',
|
||||||
|
'description' => 'nullable|max:255'
|
||||||
|
];
|
||||||
|
|
||||||
|
return $rules;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determine if the user is authorized to make this request.
|
||||||
|
*/
|
||||||
|
public function authorize()
|
||||||
|
: bool
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user