Переглянути джерело

edit route&contr. to filter ptype in marketingdb

ifah
Siti Hajar Ibrahim 5 роки тому
джерело
коміт
6e9bb62343
2 змінених файлів з 62 додано та 116 видалено
  1. 60
    114
      app/Http/Controllers/DS/MarketingController.php
  2. 2
    2
      routes/web.php

+ 60
- 114
app/Http/Controllers/DS/MarketingController.php Переглянути файл

@@ -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)){

+ 2
- 2
routes/web.php Переглянути файл

@@ -242,9 +242,9 @@ Route::group(['middleware' => 'marketAuth'], function ()
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/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/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/update-claimdate', ['uses' => 'DS\MarketingController@updateClaimDate', 'as' => 'updateClaimDate']);


Завантаження…
Відмінити
Зберегти