Browse Source

edit route&contr. to filter ptype in marketingdb

ifah
Siti Hajar Ibrahim 5 years ago
parent
commit
6e9bb62343
2 changed files with 62 additions and 116 deletions
  1. 60
    114
      app/Http/Controllers/DS/MarketingController.php
  2. 2
    2
      routes/web.php

+ 60
- 114
app/Http/Controllers/DS/MarketingController.php View File

// } // }
// } // }


public function filterclaim($company,$year,$month,$app)
public function filterclaim($company,$year,$month,$app,$ptype)
{ {
$id = Auth::guard('ms')->id(); $id = Auth::guard('ms')->id();
$user = Staff::with('StaffDetail')->find($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) { $dataClaim = DealerClaim::with(['Subscriber' => function($q) {
$q->with('Form'); $q->with('Form');
}],'Staff')->where('dealer',$company)->where('activated_my',$month.'/'.$year)->orderBy('activated_dt','DESC')->get(); }],'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'){ if($app == 'Residential'){
$dataClaim = DealerClaim::with(['Subscriber' => function($q) { $dataClaim = DealerClaim::with(['Subscriber' => function($q) {
$q->with('Form'); $q->with('Form');
}],'Staff')->where('formT', 'R')->where('dealer',$company)->where('activated_my',$month.'/'.$year)->orderBy('activated_dt','DESC')->get(); }],'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'){ }else if($app == 'Business'){
$dataClaim = DealerClaim::with(['Subscriber' => function($q) { $dataClaim = DealerClaim::with(['Subscriber' => function($q) {
$q->with('Form'); $q->with('Form');
}],'Staff')->where('formT', 'B')->where('dealer',$company)->where('activated_my',$month.'/'.$year)->orderBy('activated_dt','DESC')->get(); }],'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; $i = 0;
return \DataTables::of($nested_data)->make(true); return \DataTables::of($nested_data)->make(true);
} }


public function exportPDFClaim($company,$year,$month,$app) {
public function exportPDFClaim($company,$year,$month,$app,$ptype) {


$final = array(); $final = array();


$count_cyberjaya = array(); $count_jasin = array(); $count_ayerKeroh = array(); $count_alorGajah = array(); $count_cyberjaya = array(); $count_jasin = array(); $count_ayerKeroh = array(); $count_alorGajah = array();
$extra = 0; $basic_total = 0; $totals = 0; $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) { $dataClaim = DealerClaim::with(['Subscriber' => function($q) {
$q->with('Form'); $q->with('Form');


} }


}else if($year!='null' && $month!='null' && $app!='null'){
}else if($year!='null' && $month!='null' && $app!='null' && $ptype=='null'){


if($app == 'Residential'){ if($app == 'Residential'){
$dataClaim = DealerClaim::with(['Subscriber' => function($q) { $dataClaim = DealerClaim::with(['Subscriber' => function($q) {
}],'Staff')->where('formT', 'B')->where('dealer',$company)->where('activated_my',$month.'/'.$year)->orderBy('activated_dt','DESC')->get(); }],'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)){ if(!empty($dataClaim)){

+ 2
- 2
routes/web.php View File

Route::post('/marketing/agent/update-agent', ['uses' => 'DS\MarketingController@updateAgent', 'as' => 'updateAgent']); Route::post('/marketing/agent/update-agent', ['uses' => 'DS\MarketingController@updateAgent', 'as' => 'updateAgent']);


Route::get('/marketing/agent/claim-all/{agent_id}', ['uses' => 'DS\MarketingController@mClaimAll', 'as' => 'mClaimAll']); Route::get('/marketing/agent/claim-all/{agent_id}', ['uses' => 'DS\MarketingController@mClaimAll', 'as' => 'mClaimAll']);
Route::get('/marketing/download/claim/{company}/{year}/{month}/{app}/pdf', ['uses' => 'DS\MarketingController@exportPDFClaim', 'as' => 'mexportPDFC']);
Route::get('/marketing/download/claim/{company}/{year}/{month}/{app}/{ptype}/pdf', ['uses' => 'DS\MarketingController@exportPDFClaim', 'as' => 'mexportPDFC']);
Route::get('/marketing/agent/get-claim-list/{company}', ['uses' => 'DS\MarketingController@mClaimListAll', 'as' => 'mClaimList']); Route::get('/marketing/agent/get-claim-list/{company}', ['uses' => 'DS\MarketingController@mClaimListAll', 'as' => 'mClaimList']);
Route::get('/marketing/agent/filter/{company}/{year}/{month}/{app}', ['uses' => 'DS\MarketingController@filterclaim', 'as' => 'filterclaim']);
Route::get('/marketing/agent/filter/{company}/{year}/{month}/{app}/{ptype}', ['uses' => 'DS\MarketingController@filterclaim', 'as' => 'filterclaim']);
Route::post('/marketing/agent/request-claim', ['uses' => 'DS\MarketingController@requestClaim', 'as' => 'requestClaim']); Route::post('/marketing/agent/request-claim', ['uses' => 'DS\MarketingController@requestClaim', 'as' => 'requestClaim']);
Route::post('/marketing/agent/update-claimdate', ['uses' => 'DS\MarketingController@updateClaimDate', 'as' => 'updateClaimDate']); Route::post('/marketing/agent/update-claimdate', ['uses' => 'DS\MarketingController@updateClaimDate', 'as' => 'updateClaimDate']);



Loading…
Cancel
Save