| No | +Nama Media | +Perusahaan | +Jenis | +Klasifikasi | +Link | +Alamat | +Status | +Status Edit | ++ |
|---|
diff --git a/app/Exports/CompanyExport.php b/app/Exports/CompanyExport.php index d6bc18a..4fe4518 100644 --- a/app/Exports/CompanyExport.php +++ b/app/Exports/CompanyExport.php @@ -92,8 +92,8 @@ public function map($company): array $company->name, $company->email, $company->director_name, - get_user_status($company->user->status), $company->address, + get_user_status($company->user->status), get_edit_status($company->edit_status), Carbon::parse($company->created_at)->locale('id')->translatedFormat('l, d F Y'), Carbon::parse($company->validated_at)->locale('id')->translatedFormat('l, d F Y') @@ -104,7 +104,7 @@ public function headings(): array { return [ ['Data Perusahaan', '', '', '', '', '', '', '', '', ''], - ['NO', 'Nama Perusahaan', 'Email', 'Direktur', 'Status Akun', 'Alamat', 'Status Edit', 'Tanggal Daftar', 'Tanggal Validasi'] + ['NO', 'Nama Perusahaan', 'Email', 'Direktur', 'Alamat', 'Status', 'Status Edit', 'Tanggal Daftar', 'Tanggal Validasi'] ]; } diff --git a/app/Exports/MediaExport.php b/app/Exports/MediaExport.php new file mode 100644 index 0000000..8e135f0 --- /dev/null +++ b/app/Exports/MediaExport.php @@ -0,0 +1,165 @@ +type = $type; + $this->classification = $classification; + $this->status = $status; + $this->edit_status = $edit_status; + $this->address = $address; + $this->register_year = $register_year; + $this->register_month = $register_month; + $this->register_date = $register_date; + } + + public function collection() + { + $query = Media::with(['company.user']); + + if($this->type !== 'all'){ + if($this->type === 'online'){ + $query->where('type', 'online'); + }elseif($this->type === 'print'){ + $query->where('type', 'cetak'); + }else if($this->type === 'radio'){ + $query->where('type', 'radio'); + }else if($this->type === 'television'){ + $query->where('type', 'televisi'); + } + } + + if($this->classification !== 'all'){ + if($this->classification === 'local'){ + $query->where('classification', 'lokal'); + }elseif($this->classification === 'regional'){ + $query->where('classification', 'regional'); + }else if($this->classification === 'national'){ + $query->where('classification', 'nasional'); + } + } + + if($this->status !== 'all'){ + if($this->status === 'waiting'){ + $query->whereHas('user', function ($q){ + $q->where('status', '0'); + }); + }else if($this->status === 'accepted'){ + $query->whereHas('user', function ($q){ + $q->where('status', '1'); + }); + }else if($this->status === 'rejected'){ + $query->whereHas('user', function ($q){ + $q->where('status', '2'); + }); + } + } + + if($this->edit_status !== 'all'){ + if($this->edit_status === 'no-edit'){ + $query->where('edit_status', '0'); + }elseif($this->edit_status === 'waiting'){ + $query->where('edit_status', '1'); + }else if($this->edit_status === 'accepted'){ + $query->where('edit_status', '2'); + }else if($this->edit_status === 'rejected'){ + $query->where('edit_status', '3'); + } + } + + if ($this->address) { + $query->where('address', 'LIKE', '%'.$this->address.'%'); + } + + if ($this->register_year) { + $query->whereYear('created_at', $this->register_year); + } + + if ($this->register_month) { + $monthYear = Carbon::parse($this->register_month); + $query->whereYear('created_at', $monthYear->year) + ->whereMonth('created_at', $monthYear->month); + } + + if ($this->register_date) { + $query->whereDate('created_at', $this->register_date); + } + + return $query->get(); + } + + public function map($media): array + { + return [ + $this->no++, + $media->name, + $media->company->name, + $media->company->email, + ucfirst($media->type), + ucfirst($media->classification), + $media->address, + get_user_status($media->company->user->status), + get_edit_status($media->edit_status), + Carbon::parse($media->created_at)->locale('id')->translatedFormat('l, d F Y'), + Carbon::parse($media->company->validated_at)->locale('id')->translatedFormat('l, d F Y') + ]; + } + + public function headings(): array + { + return [ + ['Data Media', '', '', '', '', '', '', '', '', '', '', ''], + ['NO', 'Nama Media', 'Nama Perusahaan', 'Email', 'Tipe', 'Klasifikasi', 'Alamat', 'Status', 'Status Edit', 'Tanggal Daftar', 'Tanggal Validasi'] + ]; + } + + public function styles(Worksheet $sheet) + { + $sheet->mergeCells('A1:K1'); // A1 sampai D1 digabung + + // Set alignment untuk pusat horizontal dan vertikal + $sheet->getStyle('A1:K1')->getAlignment()->setHorizontal('center'); + $sheet->getStyle('A1:K1')->getAlignment()->setVertical('center'); + + $sheet->getColumnDimension('A')->setWidth(7); // Set column A width + $sheet->getColumnDimension('B')->setAutoSize(true); + $sheet->getColumnDimension('C')->setAutoSize(true); + $sheet->getColumnDimension('D')->setAutoSize(true); + $sheet->getColumnDimension('E')->setAutoSize(true); + $sheet->getColumnDimension('F')->setAutoSize(true); + $sheet->getColumnDimension('G')->setAutoSize(true); + $sheet->getColumnDimension('H')->setAutoSize(true); + $sheet->getColumnDimension('I')->setAutoSize(true); + $sheet->getColumnDimension('J')->setAutoSize(true); + $sheet->getColumnDimension('K')->setAutoSize(true); + + // Menambahkan gaya lain jika diperlukan + $sheet->getStyle('A1:K1')->getFont()->setBold(true); + $sheet->getStyle('A1:K1')->getFont()->setSize(14); + } +} diff --git a/app/Helpers/CustomHelper.php b/app/Helpers/CustomHelper.php index c5d3ee8..1d5dde7 100644 --- a/app/Helpers/CustomHelper.php +++ b/app/Helpers/CustomHelper.php @@ -297,7 +297,7 @@ function display_file($dir, $filename) if (! function_exists('change_status')) { function change_status($status, $category) { - if($category === 'company_edit'){ + if(in_array($category, ['company_edit', 'media_edit'])){ switch($status){ case '0': return '1'; diff --git a/app/Http/Controllers/Dashboard/DatatableController.php b/app/Http/Controllers/Dashboard/DatatableController.php index d3613b0..ac12a10 100644 --- a/app/Http/Controllers/Dashboard/DatatableController.php +++ b/app/Http/Controllers/Dashboard/DatatableController.php @@ -762,7 +762,7 @@ public function company(Request $request){ case 0: return 'Tidak Ada'; case 1: - return 'Menunggu'; + return 'Menunggu'; case 2: return 'Diterima'; case 3: @@ -823,9 +823,90 @@ public function company(Request $request){ public function media(Request $request){ if ($request->ajax()) { + $type = $request->input('type', null); + $classification = $request->input('classification', null); + $status = $request->input('status', null); + $edit_status = $request->input('edit_status', null); + $address = $request->input('address', null); + $register_year = $request->input('register_year', null); + $register_month = $request->input('register_month', null); + $register_date = $request->input('register_date', null); + + $query = Media::with(['company.user']); + + if($type !== 'all'){ + if($type === 'online'){ + $query->where('type', 'online'); + }elseif($type === 'print'){ + $query->where('type', 'cetak'); + }else if($type === 'radio'){ + $query->where('type', 'radio'); + }else if($type === 'television'){ + $query->where('type', 'televisi'); + } + } + + if($classification !== 'all'){ + if($classification === 'local'){ + $query->where('classification', 'lokal'); + }elseif($classification === 'regional'){ + $query->where('classification', 'regional'); + }else if($classification === 'national'){ + $query->where('classification', 'nasional'); + } + } + + if($status !== 'all'){ + if($status === 'waiting'){ + $query->whereHas('user', function ($q){ + $q->where('status', '0'); + }); + }else if($status === 'accepted'){ + $query->whereHas('user', function ($q){ + $q->where('status', '1'); + }); + }else if($status === 'rejected'){ + $query->whereHas('user', function ($q){ + $q->where('status', '2'); + }); + } + } + + if($edit_status !== 'all'){ + if($edit_status === 'no-edit'){ + $query->where('edit_status', '0'); + }elseif($edit_status === 'waiting'){ + $query->where('edit_status', '1'); + }else if($edit_status === 'accepted'){ + $query->where('edit_status', '2'); + }else if($edit_status === 'rejected'){ + $query->where('edit_status', '3'); + } + } + + if ($address) { + $query->where('address', 'LIKE', '%'.$address.'%'); + } + + if ($register_year) { + $query->whereYear('created_at', $register_year); + } + + if ($register_month) { + $monthYear = Carbon::parse($register_month); + $query->whereYear('created_at', $monthYear->year) + ->whereMonth('created_at', $monthYear->month); + } + + if ($register_date) { + $query->whereDate('created_at', $register_date); + } + + $data = $query->get(); - $data = Media::with(['company.user'])->get(); + + // $data = ->get(); return DataTables::of($data) ->addIndexColumn() @@ -858,40 +939,46 @@ public function media(Request $request){ case 1: return 'Diterima'; case 2: - return 'Ditolak'; - case 3: + return 'Ditolak'; + default: return 'Tidak Diketahui'; } }) ->addColumn('status_edit', function ($data) { switch($data->edit_status){ case 0: - return 'Menunggu'; + return 'Tidak Ada'; case 1: - return 'Diterima'; + return 'Menunggu'; case 2: - return 'Ditolak'; + return 'Diterima'; case 3: + return 'Ditolak'; + default: return 'Tidak Diketahui'; } }) ->addColumn('action', function ($data) { - $showUrl = route('dashboard.media.show', ['id' => encrypt_id($data->id)]); - - $editUrl = route('dashboard.media.edit', ['id' => encrypt_id($data->id)]); + $showUrl = route('dashboard.media.show', ['id' => encrypt_id($data->user->id), 'type' => 'media']); $deleteUrl = route('dashboard.media.destroy', ['id' => encrypt_id($data->id)]); + $processEditRequestCompanyUrl = route('dashboard.media.process', ['id' => encrypt_id($data->user->id), 'type' => 'media', 'category' => 'edit-request']); + $dropdown = '
diff --git a/resources/views/dashboard/companies/index.blade.php b/resources/views/dashboard/companies/index.blade.php index 25b14a7..ca90cd1 100644 --- a/resources/views/dashboard/companies/index.blade.php +++ b/resources/views/dashboard/companies/index.blade.php @@ -269,7 +269,7 @@| No | -Nama Media | -Perusahaan | -Jenis | -Klasifikasi | -Link | -Alamat | -Status | -Status Edit | -- |
|---|
Informasi umum terkait media Anda
+Basic info, like your name and address, that you use on Nio Platform.
-