|
|
|
@@ -3567,140 +3567,69 @@ class MarketingController extends Controller |
|
|
|
// } |
|
|
|
// } |
|
|
|
|
|
|
|
public function filterclaim($company,$year,$month,$app) |
|
|
|
public function filterclaim($company,$year,$month,$app,$ptype) |
|
|
|
{ |
|
|
|
$id = Auth::guard('ms')->id(); |
|
|
|
$user = Staff::with('StaffDetail')->find($id); |
|
|
|
|
|
|
|
$count_cyberjaya = array(); $count_jasin = array(); $count_ayerKeroh = array(); $count_alorGajah = array(); |
|
|
|
$extra = 0; $basic_total = 0; $totals = 0; |
|
|
|
|
|
|
|
if($year!='null' && $month!='null' && $app=='null'){ |
|
|
|
if($year!='null' && $month!='null' && $app=='null' && $ptype=='null'){ |
|
|
|
|
|
|
|
$dataClaim = DealerClaim::with(['Subscriber' => function($q) { |
|
|
|
$q->with('Form'); |
|
|
|
}],'Staff')->where('dealer',$company)->where('activated_my',$month.'/'.$year)->orderBy('activated_dt','DESC')->get(); |
|
|
|
|
|
|
|
if(($year == '2019' || $year == '2020') && ($month == '12' || $month == '01')){ |
|
|
|
|
|
|
|
foreach ($dataClaim as $key => $d) { |
|
|
|
if(date('d/m/Y', strtotime($d->activated_dt)) >= '12/12/2019' && |
|
|
|
date('d/m/Y', strtotime($d->activated_dt)) <= '31/01/2020'){ |
|
|
|
if (strpos($d['address'], 'Cyberjaya') !== false) { |
|
|
|
$count_cyberjaya[] = $d; |
|
|
|
} |
|
|
|
|
|
|
|
if (strpos($d['address'], 'Jasin') !== false) { |
|
|
|
$count_jasin[] = $d; |
|
|
|
} |
|
|
|
|
|
|
|
if (strpos($d['address'], 'Ayer Keroh') !== false) { |
|
|
|
$count_ayerKeroh[] = $d; |
|
|
|
} |
|
|
|
|
|
|
|
if (strpos($d['address'], 'Alor Gajah') !== false) { |
|
|
|
$count_alorGajah[] = $d; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
}else if($year == '2020' && ($month == '04' || $month == '05' || $month == '06' || $month == '07')){ |
|
|
|
|
|
|
|
foreach ($dataClaim as $key => $d) { |
|
|
|
if(date('d/m/Y', strtotime($d->activated_dt)) >= '27/04/2020' && |
|
|
|
date('d/m/Y', strtotime($d->activated_dt)) <= '31/07/2020'){ |
|
|
|
if (strpos($d['address'], 'Cyberjaya') !== false) { |
|
|
|
$count_cyberjaya[] = $d; |
|
|
|
} |
|
|
|
|
|
|
|
if (strpos($d['address'], 'Jasin') !== false) { |
|
|
|
$count_jasin[] = $d; |
|
|
|
} |
|
|
|
|
|
|
|
if (strpos($d['address'], 'Ayer Keroh') !== false) { |
|
|
|
$count_ayerKeroh[] = $d; |
|
|
|
} |
|
|
|
|
|
|
|
if (strpos($d['address'], 'Alor Gajah') !== false) { |
|
|
|
$count_alorGajah[] = $d; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
}else if($year=='null' && $month=='null' && $app!='null' && $ptype=='null'){ |
|
|
|
|
|
|
|
if($app == 'Residential'){ |
|
|
|
$dataClaim = DealerClaim::with(['Subscriber' => function($q) { |
|
|
|
$q->with('Form'); |
|
|
|
}],'Staff')->where('formT', 'R')->where('dealer',$company)->orderBy('activated_dt','DESC')->get(); |
|
|
|
}else if($app == 'Business'){ |
|
|
|
$dataClaim = DealerClaim::with(['Subscriber' => function($q) { |
|
|
|
$q->with('Form'); |
|
|
|
}],'Staff')->where('formT', 'B')->where('dealer',$company)->orderBy('activated_dt','DESC')->get(); |
|
|
|
} |
|
|
|
|
|
|
|
}else if($year=='null' && $month=='null' && $app!='null'){ |
|
|
|
|
|
|
|
// if($app == 'Residential'){ |
|
|
|
// $dataClaim = DealerClaim::with(['Subscriber' => function($q) { |
|
|
|
// $q->with('Form'); |
|
|
|
// }],'Staff')->where('formT', 'R')->where('dealer',$company)->where('activated_my',$month.'/'.$year)->orderBy('activated_dt','DESC')->get(); |
|
|
|
// }else if($app == 'Business'){ |
|
|
|
// $dataClaim = DealerClaim::with(['Subscriber' => function($q) { |
|
|
|
// $q->with('Form'); |
|
|
|
// }],'Staff')->where('formT', 'B')->where('dealer',$company)->where('activated_my',$month.'/'.$year)->orderBy('activated_dt','DESC')->get(); |
|
|
|
// } |
|
|
|
|
|
|
|
}else if($year!='null' && $month!='null' && $app!='null'){ |
|
|
|
}else if($year!='null' && $month!='null' && $app!='null' && $ptype=='null'){ |
|
|
|
|
|
|
|
if($app == 'Residential'){ |
|
|
|
$dataClaim = DealerClaim::with(['Subscriber' => function($q) { |
|
|
|
$q->with('Form'); |
|
|
|
}],'Staff')->where('formT', 'R')->where('dealer',$company)->where('activated_my',$month.'/'.$year)->orderBy('activated_dt','DESC')->get(); |
|
|
|
|
|
|
|
if(($year == '2019' || $year == '2020') && ($month == '12' || $month == '01')){ |
|
|
|
|
|
|
|
foreach ($dataClaim as $key => $d) { |
|
|
|
if(date('d/m/Y', strtotime($d->activated_dt)) >= '12/12/2019' && |
|
|
|
date('d/m/Y', strtotime($d->activated_dt)) <= '31/01/2020'){ |
|
|
|
if (strpos($d['address'], 'Cyberjaya') !== false) { |
|
|
|
$count_cyberjaya[] = $d; |
|
|
|
} |
|
|
|
|
|
|
|
if (strpos($d['address'], 'Jasin') !== false) { |
|
|
|
$count_jasin[] = $d; |
|
|
|
} |
|
|
|
|
|
|
|
if (strpos($d['address'], 'Ayer Keroh') !== false) { |
|
|
|
$count_ayerKeroh[] = $d; |
|
|
|
} |
|
|
|
|
|
|
|
if (strpos($d['address'], 'Alor Gajah') !== false) { |
|
|
|
$count_alorGajah[] = $d; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
}else if($year == '2020' && ($month == '04' || $month == '05' || $month == '06' || $month == '07')){ |
|
|
|
|
|
|
|
foreach ($dataClaim as $key => $d) { |
|
|
|
if(date('d/m/Y', strtotime($d->activated_dt)) >= '27/04/2020' && |
|
|
|
date('d/m/Y', strtotime($d->activated_dt)) <= '31/07/2020'){ |
|
|
|
if (strpos($d['address'], 'Cyberjaya') !== false) { |
|
|
|
$count_cyberjaya[] = $d; |
|
|
|
} |
|
|
|
|
|
|
|
if (strpos($d['address'], 'Jasin') !== false) { |
|
|
|
$count_jasin[] = $d; |
|
|
|
} |
|
|
|
|
|
|
|
if (strpos($d['address'], 'Ayer Keroh') !== false) { |
|
|
|
$count_ayerKeroh[] = $d; |
|
|
|
} |
|
|
|
|
|
|
|
if (strpos($d['address'], 'Alor Gajah') !== false) { |
|
|
|
$count_alorGajah[] = $d; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}else if($app == 'Business'){ |
|
|
|
$dataClaim = DealerClaim::with(['Subscriber' => function($q) { |
|
|
|
$q->with('Form'); |
|
|
|
}],'Staff')->where('formT', 'B')->where('dealer',$company)->where('activated_my',$month.'/'.$year)->orderBy('activated_dt','DESC')->get(); |
|
|
|
} |
|
|
|
}else if($year!='null' && $month!='null' && $app=='null' && $ptype!='null'){ |
|
|
|
$dataClaim = DealerClaim::with(['Subscriber' => function($q) { |
|
|
|
$q->with('Form'); |
|
|
|
}],'Staff')->where('dealer',$company)->where('activated_my',$month.'/'.$year)->where('projectT',$ptype)->orderBy('activated_dt','DESC')->get(); |
|
|
|
}else if($year=='null' && $month=='null' && $app=='null' && $ptype!='null'){ |
|
|
|
$dataClaim = DealerClaim::with(['Subscriber' => function($q) { |
|
|
|
$q->with('Form'); |
|
|
|
}],'Staff')->where('projectT', $ptype)->where('dealer',$company)->orderBy('activated_dt','DESC')->get(); |
|
|
|
}else if($year!='null' && $month!='null' && $app!='null' && $ptype!='null'){ |
|
|
|
if($app == 'Residential'){ |
|
|
|
$dataClaim = DealerClaim::with(['Subscriber' => function($q) { |
|
|
|
$q->with('Form'); |
|
|
|
}],'Staff')->where('formT','R')->where('dealer',$company)->where('activated_my',$month.'/'.$year)->where('projectT',$ptype)->orderBy('activated_dt','DESC')->get(); |
|
|
|
} else if ($app == 'Business'){ |
|
|
|
$dataClaim = DealerClaim::with(['Subscriber' => function($q) { |
|
|
|
$q->with('Form'); |
|
|
|
}],'Staff')->where('formT','B')->where('dealer',$company)->where('activated_my',$month.'/'.$year)->where('projectT',$ptype)->orderBy('activated_dt','DESC')->get(); |
|
|
|
} |
|
|
|
}else if($year=='null' && $month=='null' && $app!='null' && $ptype!='null'){ |
|
|
|
if($app == 'Residential'){ |
|
|
|
$dataClaim = DealerClaim::with(['Subscriber' => function($q) { |
|
|
|
$q->with('Form'); |
|
|
|
}],'Staff')->where('formT','R')->where('dealer',$company)->where('projectT',$ptype)->orderBy('activated_dt','DESC')->get(); |
|
|
|
} else if ($app == 'Business'){ |
|
|
|
$dataClaim = DealerClaim::with(['Subscriber' => function($q) { |
|
|
|
$q->with('Form'); |
|
|
|
}],'Staff')->where('formT','B')->where('dealer',$company)->where('projectT',$ptype)->orderBy('activated_dt','DESC')->get(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
$i = 0; |
|
|
|
@@ -3751,7 +3680,7 @@ class MarketingController extends Controller |
|
|
|
return \DataTables::of($nested_data)->make(true); |
|
|
|
} |
|
|
|
|
|
|
|
public function exportPDFClaim($company,$year,$month,$app) { |
|
|
|
public function exportPDFClaim($company,$year,$month,$app,$ptype) { |
|
|
|
|
|
|
|
$final = array(); |
|
|
|
|
|
|
|
@@ -3765,7 +3694,7 @@ class MarketingController extends Controller |
|
|
|
$count_cyberjaya = array(); $count_jasin = array(); $count_ayerKeroh = array(); $count_alorGajah = array(); |
|
|
|
$extra = 0; $basic_total = 0; $totals = 0; |
|
|
|
|
|
|
|
if($year!='null' && $month!='null' && $app=='null'){ |
|
|
|
if($year!='null' && $month!='null' && $app=='null' && $ptype=='null'){ |
|
|
|
|
|
|
|
$dataClaim = DealerClaim::with(['Subscriber' => function($q) { |
|
|
|
$q->with('Form'); |
|
|
|
@@ -3819,7 +3748,7 @@ class MarketingController extends Controller |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}else if($year!='null' && $month!='null' && $app!='null'){ |
|
|
|
}else if($year!='null' && $month!='null' && $app!='null' && $ptype=='null'){ |
|
|
|
|
|
|
|
if($app == 'Residential'){ |
|
|
|
$dataClaim = DealerClaim::with(['Subscriber' => function($q) { |
|
|
|
@@ -3879,6 +3808,23 @@ class MarketingController extends Controller |
|
|
|
}],'Staff')->where('formT', 'B')->where('dealer',$company)->where('activated_my',$month.'/'.$year)->orderBy('activated_dt','DESC')->get(); |
|
|
|
} |
|
|
|
|
|
|
|
}else if($year!='null' && $month!='null' && $app=='null' && $ptype!='null'){ |
|
|
|
$dataClaim = DealerClaim::with(['Subscriber' => function($q) { |
|
|
|
$q->with('Form'); |
|
|
|
}],'Staff')->where('dealer',$company)->where('activated_my',$month.'/'.$year)->where('projectT',$ptype)->orderBy('activated_dt','DESC')->get(); |
|
|
|
}else if($year!='null' && $month!='null' && $app!='null' && $ptype!='null'){ |
|
|
|
if($app == 'Residential'){ |
|
|
|
$dataClaim = DealerClaim::with(['Subscriber' => function($q) { |
|
|
|
$q->with('Form'); |
|
|
|
}],'Staff')->where('formT', 'R')->where('dealer',$company)->where('activated_my',$month.'/'.$year)->where('projectT',$ptype)->orderBy('activated_dt','DESC')->get(); |
|
|
|
}else if($app == 'Business'){ |
|
|
|
$dataClaim = DealerClaim::with(['Subscriber' => function($q) { |
|
|
|
$q->with('Form'); |
|
|
|
}],'Staff')->where('formT', 'B')->where('dealer',$company)->where('activated_my',$month.'/'.$year)->where('projectT',$ptype)->orderBy('activated_dt','DESC')->get(); |
|
|
|
} |
|
|
|
|
|
|
|
}else{ |
|
|
|
dd('Cannot download pdf without choosing month and year'); |
|
|
|
} |
|
|
|
|
|
|
|
if(!empty($dataClaim)){ |