feat: add status field in filter and export report
This commit is contained in:
parent
7a6bfddb21
commit
8798e2b2c2
@ -19,14 +19,16 @@ class ReportExport implements FromCollection, WithHeadings, WithStyles, WithMapp
|
|||||||
|
|
||||||
protected $no = 1;
|
protected $no = 1;
|
||||||
protected $media;
|
protected $media;
|
||||||
|
protected $status;
|
||||||
protected $year;
|
protected $year;
|
||||||
protected $from_month;
|
protected $from_month;
|
||||||
protected $to_month;
|
protected $to_month;
|
||||||
protected $date;
|
protected $date;
|
||||||
|
|
||||||
public function __construct($media, $year, $from_month, $to_month, $date)
|
public function __construct($media, $status, $year, $from_month, $to_month, $date)
|
||||||
{
|
{
|
||||||
$this->media = $media;
|
$this->media = $media;
|
||||||
|
$this->status = $status;
|
||||||
$this->year = $year;
|
$this->year = $year;
|
||||||
$this->from_month = $from_month;
|
$this->from_month = $from_month;
|
||||||
$this->to_month = $to_month;
|
$this->to_month = $to_month;
|
||||||
@ -46,6 +48,20 @@ public function collection()
|
|||||||
$query->whereIn('media_id', $this->media);
|
$query->whereIn('media_id', $this->media);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($this->status) {
|
||||||
|
switch($this->status){
|
||||||
|
case 'waiting':
|
||||||
|
$query->where('status', '0');
|
||||||
|
break;
|
||||||
|
case 'accepted':
|
||||||
|
$query->where('status', '1');
|
||||||
|
break;
|
||||||
|
case 'rejected':
|
||||||
|
$query->where('status', '2');
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if ($this->year) {
|
if ($this->year) {
|
||||||
$query->whereYear('created_at', $this->year);
|
$query->whereYear('created_at', $this->year);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -2257,6 +2257,8 @@ public function reportIndex(Request $request){
|
|||||||
$mediaStrArr = $request->input('media', null);
|
$mediaStrArr = $request->input('media', null);
|
||||||
$media = explode(',', $mediaStrArr);
|
$media = explode(',', $mediaStrArr);
|
||||||
|
|
||||||
|
$status = $request->input('status', null);
|
||||||
|
|
||||||
$year = $request->input('year', null);
|
$year = $request->input('year', null);
|
||||||
$from_month = $request->input('from_month', null);
|
$from_month = $request->input('from_month', null);
|
||||||
$to_month = $request->input('to_month', null);
|
$to_month = $request->input('to_month', null);
|
||||||
@ -2273,6 +2275,20 @@ public function reportIndex(Request $request){
|
|||||||
$query->whereIn('media_id', $media);
|
$query->whereIn('media_id', $media);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($status) {
|
||||||
|
switch($status){
|
||||||
|
case 'waiting':
|
||||||
|
$query->where('status', '0');
|
||||||
|
break;
|
||||||
|
case 'accepted':
|
||||||
|
$query->where('status', '1');
|
||||||
|
break;
|
||||||
|
case 'rejected':
|
||||||
|
$query->where('status', '2');
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if ($year) {
|
if ($year) {
|
||||||
$query->whereYear('created_at', $year);
|
$query->whereYear('created_at', $year);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -22,6 +22,7 @@ public function index(Request $request){
|
|||||||
'title' => 'Laporan Bukti Tayang',
|
'title' => 'Laporan Bukti Tayang',
|
||||||
'mediaCollection' => Media::all(),
|
'mediaCollection' => Media::all(),
|
||||||
'media' => $request->input('media', []),
|
'media' => $request->input('media', []),
|
||||||
|
'status' => $request->input('status', null),
|
||||||
'date' => $request->input('date', null),
|
'date' => $request->input('date', null),
|
||||||
'from_month' => $request->input('from_month', null),
|
'from_month' => $request->input('from_month', null),
|
||||||
'to_month' => $request->input('to_month', null),
|
'to_month' => $request->input('to_month', null),
|
||||||
@ -253,6 +254,7 @@ public function export(Request $request)
|
|||||||
$export_type = $request->input('export_type', 'excel');
|
$export_type = $request->input('export_type', 'excel');
|
||||||
|
|
||||||
$media = $request->input('media', null);
|
$media = $request->input('media', null);
|
||||||
|
$status = $request->input('status', null);
|
||||||
$year = $request->input('year', null);
|
$year = $request->input('year', null);
|
||||||
$from_month = $request->input('from_month', null);
|
$from_month = $request->input('from_month', null);
|
||||||
$to_month = $request->input('to_month', null);
|
$to_month = $request->input('to_month', null);
|
||||||
@ -260,7 +262,7 @@ public function export(Request $request)
|
|||||||
|
|
||||||
if($export_type === 'excel'){
|
if($export_type === 'excel'){
|
||||||
$formattedNow = Carbon::parse(now())->locale('id')->translatedFormat('d-m-Y');
|
$formattedNow = Carbon::parse(now())->locale('id')->translatedFormat('d-m-Y');
|
||||||
return Excel::download(new ReportExport($media, $year, $from_month, $to_month, $date), 'reports-'.$formattedNow.'.xlsx');
|
return Excel::download(new ReportExport($media, $status, $year, $from_month, $to_month, $date), 'reports-'.$formattedNow.'.xlsx');
|
||||||
}elseif($export_type === 'pdf'){
|
}elseif($export_type === 'pdf'){
|
||||||
if(is_role(['1', '5'])){
|
if(is_role(['1', '5'])){
|
||||||
$query = Report::with(['media.company', 'order.cooperation']);
|
$query = Report::with(['media.company', 'order.cooperation']);
|
||||||
@ -273,6 +275,20 @@ public function export(Request $request)
|
|||||||
$query->whereIn('media_id', $media);
|
$query->whereIn('media_id', $media);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($status) {
|
||||||
|
switch($status){
|
||||||
|
case 'waiting':
|
||||||
|
$query->where('status', '0');
|
||||||
|
break;
|
||||||
|
case 'accepted':
|
||||||
|
$query->where('status', '1');
|
||||||
|
break;
|
||||||
|
case 'rejected':
|
||||||
|
$query->where('status', '2');
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if ($year) {
|
if ($year) {
|
||||||
$query->whereYear('created_at', $year);
|
$query->whereYear('created_at', $year);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -91,7 +91,7 @@
|
|||||||
<div class="form-control-wrap">
|
<div class="form-control-wrap">
|
||||||
<select class="form-select js-select2" multiple="multiple" data-placeholder="Media" name="media[]">
|
<select class="form-select js-select2" multiple="multiple" data-placeholder="Media" name="media[]">
|
||||||
@foreach ($mediaCollection as $item)
|
@foreach ($mediaCollection as $item)
|
||||||
<option value="{{$item->id}}">{{$item->name}}</option>
|
<option value="{{$item->id}}" @selected(in_array($item->id, $media))>{{$item->name}}</option>
|
||||||
@endforeach
|
@endforeach
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
@ -100,10 +100,10 @@
|
|||||||
<label class="form-label">Status</label>
|
<label class="form-label">Status</label>
|
||||||
<div class="form-control-wrap">
|
<div class="form-control-wrap">
|
||||||
<select class="form-select js-select2" name="status">
|
<select class="form-select js-select2" name="status">
|
||||||
<option value="all">Semua</option>
|
<option value="all" selected>Semua</option>
|
||||||
<option value="waiting">Menunggu</option>
|
<option value="waiting" @selected($status === 'waiting')>Menunggu</option>
|
||||||
<option value="accepted">Diterima</option>
|
<option value="accepted" @selected($status === 'accepted')>Diterima</option>
|
||||||
<option value="rejected">Ditolak</option>
|
<option value="rejected" @selected($status === 'rejected')>Ditolak</option>
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@ -30,7 +30,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</li> --}}
|
</li> --}}
|
||||||
<li>
|
<li>
|
||||||
@if ((filled(value: $media) && !empty($media[0])) || filled(value: $date) || (filled(value: $from_month) && filled(value: $to_month)) ||filled(value: $year))
|
@if ((filled(value: $media) && !empty($media[0])) || filled($status) || filled(value: $date) || (filled(value: $from_month) && filled(value: $to_month)) ||filled(value: $year))
|
||||||
<span class="mx-1">
|
<span class="mx-1">
|
||||||
<a href="{{route('dashboard.reports.index')}}" class="text-secondary">
|
<a href="{{route('dashboard.reports.index')}}" class="text-secondary">
|
||||||
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="currentColor" class="icon icon-tabler icons-tabler-filled icon-tabler-xbox-x"><path stroke="none" d="M0 0h24v24H0z" fill="none"/><path d="M12 2c5.523 0 10 4.477 10 10s-4.477 10 -10 10s-10 -4.477 -10 -10s4.477 -10 10 -10m3.6 5.2a1 1 0 0 0 -1.4 .2l-2.2 2.933l-2.2 -2.933a1 1 0 1 0 -1.6 1.2l2.55 3.4l-2.55 3.4a1 1 0 1 0 1.6 1.2l2.2 -2.933l2.2 2.933a1 1 0 0 0 1.6 -1.2l-2.55 -3.4l2.55 -3.4a1 1 0 0 0 -.2 -1.4" /></svg>
|
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="currentColor" class="icon icon-tabler icons-tabler-filled icon-tabler-xbox-x"><path stroke="none" d="M0 0h24v24H0z" fill="none"/><path d="M12 2c5.523 0 10 4.477 10 10s-4.477 10 -10 10s-10 -4.477 -10 -10s4.477 -10 10 -10m3.6 5.2a1 1 0 0 0 -1.4 .2l-2.2 2.933l-2.2 -2.933a1 1 0 1 0 -1.6 1.2l2.55 3.4l-2.55 3.4a1 1 0 1 0 1.6 1.2l2.2 -2.933l2.2 2.933a1 1 0 0 0 1.6 -1.2l-2.55 -3.4l2.55 -3.4a1 1 0 0 0 -.2 -1.4" /></svg>
|
||||||
@ -93,11 +93,22 @@
|
|||||||
<div class="form-control-wrap">
|
<div class="form-control-wrap">
|
||||||
<select class="form-select js-select2" multiple="multiple" data-placeholder="Media" name="media[]">
|
<select class="form-select js-select2" multiple="multiple" data-placeholder="Media" name="media[]">
|
||||||
@foreach ($mediaCollection as $item)
|
@foreach ($mediaCollection as $item)
|
||||||
<option value="{{$item->id}}">{{$item->name}}</option>
|
<option value="{{$item->id}}" @selected(in_array($item->id, $media))>{{$item->name}}</option>
|
||||||
@endforeach
|
@endforeach
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="form-label">Status</label>
|
||||||
|
<div class="form-control-wrap">
|
||||||
|
<select class="form-select js-select2" name="status">
|
||||||
|
<option value="all" selected>Semua</option>
|
||||||
|
<option value="waiting" @selected($status === 'waiting')>Menunggu</option>
|
||||||
|
<option value="accepted" @selected($status === 'accepted')>Diterima</option>
|
||||||
|
<option value="rejected" @selected($status === 'rejected')>Ditolak</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label class="form-label" for="year">Tahun</label>
|
<label class="form-label" for="year">Tahun</label>
|
||||||
<div class="form-control-wrap">
|
<div class="form-control-wrap">
|
||||||
@ -181,6 +192,17 @@
|
|||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="form-label">Status</label>
|
||||||
|
<div class="form-control-wrap">
|
||||||
|
<select class="form-select js-select2" name="status">
|
||||||
|
<option value="all">Semua</option>
|
||||||
|
<option value="waiting">Menunggu</option>
|
||||||
|
<option value="accepted">Diterima</option>
|
||||||
|
<option value="rejected">Ditolak</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label class="form-label" for="year">Tahun</label>
|
<label class="form-label" for="year">Tahun</label>
|
||||||
<div class="form-control-wrap">
|
<div class="form-control-wrap">
|
||||||
|
|||||||
@ -1032,6 +1032,7 @@
|
|||||||
type: 'GET',
|
type: 'GET',
|
||||||
data: function(d) {
|
data: function(d) {
|
||||||
d.media = '{{ implode(',', $media) }}';
|
d.media = '{{ implode(',', $media) }}';
|
||||||
|
d.status = '{{ $status }}';
|
||||||
d.year = '{{ $year }}';
|
d.year = '{{ $year }}';
|
||||||
d.from_month = '{{ $from_month }}';
|
d.from_month = '{{ $from_month }}';
|
||||||
d.to_month = '{{ $to_month }}';
|
d.to_month = '{{ $to_month }}';
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user