Browse Source

update claim for Ayer Keroh, Alor Gajah, Menglembu, Ipoh

ifah
Siti Hajar Ibrahim 5 years ago
parent
commit
77708c83b2
1 changed files with 333 additions and 4 deletions
  1. 333
    4
      app/Http/Controllers/DS/DealerController.php

+ 333
- 4
app/Http/Controllers/DS/DealerController.php View File



$dataR = array(); $dataB = array(); $combineData = array(); $dataR = array(); $dataB = array(); $combineData = array();


$count_cyberjaya = array(); $count_jasin = array();
$count_cyberjaya = array(); $count_jasin = array(); $count_ayerKeroh = array(); $count_alorGajah = array(); $count_menglembu = array(); $count_ipoh = 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'){
if (strpos($d['address'], 'Jasin') !== false) { if (strpos($d['address'], 'Jasin') !== false) {
$count_jasin[] = $d; $count_jasin[] = $d;
} }

if (strpos($d['address'], 'Ayer Keroh') !== false) {
$count_ayerKeroh[] = $d;
}

if (strpos($d['address'], 'Alor Gajah') !== false) {
$count_alorGajah[] = $d;
}

if (strpos($d['address'], 'Menglembu') !== false) {
$count_menglembu[] = $d;
}

if (strpos($d['address'], 'Ipoh') !== false) {
$count_ipoh[] = $d;
}
} }
} }
if (strpos($d['address'], 'Jasin') !== false) { if (strpos($d['address'], 'Jasin') !== false) {
$count_jasin[] = $d; $count_jasin[] = $d;
} }

if (strpos($d['address'], 'Ayer Keroh') !== false) {
$count_ayerKeroh[] = $d;
}

if (strpos($d['address'], 'Alor Gajah') !== false) {
$count_alorGajah[] = $d;
}

if (strpos($d['address'], 'Menglembu') !== false) {
$count_menglembu[] = $d;
}

if (strpos($d['address'], 'Ipoh') !== false) {
$count_ipoh[] = $d;
}
} }
} }


if (strpos($d['address'], 'Jasin') !== false) { if (strpos($d['address'], 'Jasin') !== false) {
$count_jasin[] = $d; $count_jasin[] = $d;
} }

if (strpos($d['address'], 'Ayer Keroh') !== false) {
$count_ayerKeroh[] = $d;
}
if (strpos($d['address'], 'Alor Gajah') !== false) {
$count_alorGajah[] = $d;
}
if (strpos($d['address'], 'Menglembu') !== false) {
$count_menglembu[] = $d;
}
if (strpos($d['address'], 'Ipoh') !== false) {
$count_ipoh[] = $d;
}
} }
} }
if (strpos($d['address'], 'Jasin') !== false) { if (strpos($d['address'], 'Jasin') !== false) {
$count_jasin[] = $d; $count_jasin[] = $d;
} }

if (strpos($d['address'], 'Ayer Keroh') !== false) {
$count_ayerKeroh[] = $d;
}
if (strpos($d['address'], 'Alor Gajah') !== false) {
$count_alorGajah[] = $d;
}
if (strpos($d['address'], 'Menglembu') !== false) {
$count_menglembu[] = $d;
}
if (strpos($d['address'], 'Ipoh') !== false) {
$count_ipoh[] = $d;
}
} }
} }


$extra += $balance * 50; $extra += $balance * 50;
} }


if(count($count_ayerKeroh) > 50){
$balance = count($count_ayerKeroh) - 50;
$extra += $balance * 50;
}

if(count($count_alorGajah) > 50){
$balance = count($count_alorGajah) - 50;
$extra += $balance * 50;
}

if(count($count_menglembu) > 50){
$balance = count($count_menglembu) - 50;
$extra += $balance * 50;
}

if(count($count_ipoh) > 50){
$balance = count($count_ipoh) - 50;
$extra += $balance * 50;
}

if(count($count_jasin) > 10){ if(count($count_jasin) > 10){
$balance = count($count_jasin) - 10; $balance = count($count_jasin) - 10;
$extra += $balance * 50; $extra += $balance * 50;
$extra += $balance * 50; $extra += $balance * 50;
} }


if(count($count_ayerKeroh) > 50){
$balance = count($count_ayerKeroh) - 50;
$extra += $balance * 50;
}

if(count($count_alorGajah) > 50){
$balance = count($count_alorGajah) - 50;
$extra += $balance * 50;
}

if(count($count_menglembu) > 50){
$balance = count($count_menglembu) - 50;
$extra += $balance * 50;
}

if(count($count_ipoh) > 50){
$balance = count($count_ipoh) - 50;
$extra += $balance * 50;
}

if(count($count_jasin) > 20){ if(count($count_jasin) > 20){
$balance = count($count_jasin) - 20; $balance = count($count_jasin) - 20;
$extra += $balance * 50; $extra += $balance * 50;
if (strpos($d['address'], 'Jasin') !== false) { if (strpos($d['address'], 'Jasin') !== false) {
$count_jasin[] = $d; $count_jasin[] = $d;
} }

if (strpos($d['address'], 'Ayer Keroh') !== false) {
$count_ayerKeroh[] = $d;
}

if (strpos($d['address'], 'Alor Gajah') !== false) {
$count_alorGajah[] = $d;
}

if (strpos($d['address'], 'Menglembu') !== false) {
$count_menglembu[] = $d;
}

if (strpos($d['address'], 'Ipoh') !== false) {
$count_ipoh[] = $d;
}
} }
} }
if (strpos($d['address'], 'Jasin') !== false) { if (strpos($d['address'], 'Jasin') !== false) {
$count_jasin[] = $d; $count_jasin[] = $d;
} }

if (strpos($d['address'], 'Ayer Keroh') !== false) {
$count_ayerKeroh[] = $d;
}

if (strpos($d['address'], 'Alor Gajah') !== false) {
$count_alorGajah[] = $d;
}

if (strpos($d['address'], 'Menglembu') !== false) {
$count_menglembu[] = $d;
}

if (strpos($d['address'], 'Ipoh') !== false) {
$count_ipoh[] = $d;
}
} }
} }


if (strpos($d['address'], 'Jasin') !== false) { if (strpos($d['address'], 'Jasin') !== false) {
$count_jasin[] = $d; $count_jasin[] = $d;
} }

if (strpos($d['address'], 'Ayer Keroh') !== false) {
$count_ayerKeroh[] = $d;
}
if (strpos($d['address'], 'Alor Gajah') !== false) {
$count_alorGajah[] = $d;
}
if (strpos($d['address'], 'Menglembu') !== false) {
$count_menglembu[] = $d;
}
if (strpos($d['address'], 'Ipoh') !== false) {
$count_ipoh[] = $d;
}
} }
} }
if (strpos($d['address'], 'Jasin') !== false) { if (strpos($d['address'], 'Jasin') !== false) {
$count_jasin[] = $d; $count_jasin[] = $d;
} }

if (strpos($d['address'], 'Ayer Keroh') !== false) {
$count_ayerKeroh[] = $d;
}
if (strpos($d['address'], 'Alor Gajah') !== false) {
$count_alorGajah[] = $d;
}
if (strpos($d['address'], 'Menglembu') !== false) {
$count_menglembu[] = $d;
}
if (strpos($d['address'], 'Ipoh') !== false) {
$count_ipoh[] = $d;
}
} }
} }




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


$count_cyberjaya = array(); $count_jasin = array(); $count_ayerKeroh = array(); $count_alorGajah = array();
$count_cyberjaya = array(); $count_jasin = array(); $count_ayerKeroh = array(); $count_alorGajah = array(); $count_menglembu = array(); $count_ipoh = array();
$extra = 0; $basic_total = 0; $totals = 0; $extra = 0; $basic_total = 0; $totals = 0;


// if(($year == '2019' || $year == '2020') && ($month == '12' || $month == '01')){ // if(($year == '2019' || $year == '2020') && ($month == '12' || $month == '01')){
if (strpos($d['address'], 'Jasin') !== false) { if (strpos($d['address'], 'Jasin') !== false) {
$count_jasin[] = $d; $count_jasin[] = $d;
} }

if (strpos($d['address'], 'Ayer Keroh') !== false) { if (strpos($d['address'], 'Ayer Keroh') !== false) {
$count_ayerKeroh[] = $d; $count_ayerKeroh[] = $d;
} }

if (strpos($d['address'], 'Alor Gajah') !== false) { if (strpos($d['address'], 'Alor Gajah') !== false) {
$count_alorGajah[] = $d; $count_alorGajah[] = $d;
} }


if (strpos($d['address'], 'Menglembu') !== false) {
$count_menglembu[] = $d;
}

if (strpos($d['address'], 'Ipoh') !== false) {
$count_ipoh[] = $d;
}

} }
else { else {
if(date('m/Y', strtotime($d['activation'])) == $month.'/'.$year){ if(date('m/Y', strtotime($d['activation'])) == $month.'/'.$year){
if (strpos($d['address'], 'Jasin') !== false) { if (strpos($d['address'], 'Jasin') !== false) {
$count_jasin[] = $d; $count_jasin[] = $d;
} }
if (strpos($d['address'], 'Ayer Keroh') !== false) { if (strpos($d['address'], 'Ayer Keroh') !== false) {
$count_ayerKeroh[] = $d; $count_ayerKeroh[] = $d;
} }

if (strpos($d['address'], 'Alor Gajah') !== false) { if (strpos($d['address'], 'Alor Gajah') !== false) {
$count_alorGajah[] = $d; $count_alorGajah[] = $d;
} }

if (strpos($d['address'], 'Menglembu') !== false) {
$count_menglembu[] = $d;
}

if (strpos($d['address'], 'Ipoh') !== false) {
$count_ipoh[] = $d;
}
} }


foreach ($dataJune as $key => $d) { foreach ($dataJune as $key => $d) {
if (strpos($d['address'], 'Jasin') !== false) { if (strpos($d['address'], 'Jasin') !== false) {
$count_jasin[] = $d; $count_jasin[] = $d;
} }
if (strpos($d['address'], 'Ayer Keroh') !== false) { if (strpos($d['address'], 'Ayer Keroh') !== false) {
$count_ayerKeroh[] = $d; $count_ayerKeroh[] = $d;
} }

if (strpos($d['address'], 'Alor Gajah') !== false) { if (strpos($d['address'], 'Alor Gajah') !== false) {
$count_alorGajah[] = $d; $count_alorGajah[] = $d;
} }

if (strpos($d['address'], 'Menglembu') !== false) {
$count_menglembu[] = $d;
}

if (strpos($d['address'], 'Ipoh') !== false) {
$count_ipoh[] = $d;
}
} }


foreach ($dataJuly as $key => $d) { foreach ($dataJuly as $key => $d) {
if (strpos($d['address'], 'Jasin') !== false) { if (strpos($d['address'], 'Jasin') !== false) {
$count_jasin[] = $d; $count_jasin[] = $d;
} }

if (strpos($d['address'], 'Ayer Keroh') !== false) { if (strpos($d['address'], 'Ayer Keroh') !== false) {
$count_ayerKeroh[] = $d; $count_ayerKeroh[] = $d;
} }

if (strpos($d['address'], 'Alor Gajah') !== false) { if (strpos($d['address'], 'Alor Gajah') !== false) {
$count_alorGajah[] = $d; $count_alorGajah[] = $d;
} }

if (strpos($d['address'], 'Menglembu') !== false) {
$count_menglembu[] = $d;
}

if (strpos($d['address'], 'Ipoh') !== false) {
$count_ipoh[] = $d;
}
} }


// Store to combineData New Incentives Cyberjaya // Store to combineData New Incentives Cyberjaya
} }
} }


// Store to combineData New Incentives Menglembu
foreach ($count_menglembu as $key => $d) {
if(count($count_menglembu) > 50){
if(date('m/Y', strtotime($d['activation'])) == $month.'/'.$year){

if($d['contract'] == '12'){
array_push($combineData, array(
'index' => $d['index'],
'contract' => $d['contract'],
'wo' => $d['wo'],
'activation' => $d['activation'],
'name' => $d['name'],
'address' => $d['address'],
'package' => $d['package'],
'retail_price' => $d['retail_price'],
'incentives1' => $d['incentives1'],
'incentives2' => $d['incentives2'],
'total' => $d['total'],
'claim' => $d['claim'],
));

}else {

$total = number_format(floatval(str_replace("RM ", "" , $d['retail_price'])) * 2.3, 2);
array_push($combineData, array(
'index' => $d['index'],
'contract' => $d['contract'],
'wo' => $d['wo'],
'activation' => $d['activation'],
'name' => $d['name'],
'address' => $d['address'],
'package' => $d['package'],
'retail_price' => $d['retail_price'],
'incentives1' => '230%',
'incentives2' => $d['incentives2'],
'total' => 'RM '.$total,
'claim' => $d['claim'],
));
}
}

}else if(count($count_menglembu) < 50){
if(date('m/Y', strtotime($d['activation'])) == $month.'/'.$year){
array_push($combineData, array(
'index' => $d['index'],
'contract' => $d['contract'],
'wo' => $d['wo'],
'activation' => $d['activation'],
'name' => $d['name'],
'address' => $d['address'],
'package' => $d['package'],
'retail_price' => $d['retail_price'],
'incentives1' => $d['incentives1'],
'incentives2' => $d['incentives2'],
'total' => $d['total'],
'claim' => $d['claim'],
));
}
}
}

// Store to combineData New Incentives Ipoh
foreach ($count_ipoh as $key => $d) {
if(count($count_ipoh) > 50){
if(date('m/Y', strtotime($d['activation'])) == $month.'/'.$year){

if($d['contract'] == '12'){
array_push($combineData, array(
'index' => $d['index'],
'contract' => $d['contract'],
'wo' => $d['wo'],
'activation' => $d['activation'],
'name' => $d['name'],
'address' => $d['address'],
'package' => $d['package'],
'retail_price' => $d['retail_price'],
'incentives1' => $d['incentives1'],
'incentives2' => $d['incentives2'],
'total' => $d['total'],
'claim' => $d['claim'],
));

}else {

$total = number_format(floatval(str_replace("RM ", "" , $d['retail_price'])) * 2.3, 2);
array_push($combineData, array(
'index' => $d['index'],
'contract' => $d['contract'],
'wo' => $d['wo'],
'activation' => $d['activation'],
'name' => $d['name'],
'address' => $d['address'],
'package' => $d['package'],
'retail_price' => $d['retail_price'],
'incentives1' => '230%',
'incentives2' => $d['incentives2'],
'total' => 'RM '.$total,
'claim' => $d['claim'],
));
}
}

}else if(count($count_ipoh) < 50){
if(date('m/Y', strtotime($d['activation'])) == $month.'/'.$year){
array_push($combineData, array(
'index' => $d['index'],
'contract' => $d['contract'],
'wo' => $d['wo'],
'activation' => $d['activation'],
'name' => $d['name'],
'address' => $d['address'],
'package' => $d['package'],
'retail_price' => $d['retail_price'],
'incentives1' => $d['incentives1'],
'incentives2' => $d['incentives2'],
'total' => $d['total'],
'claim' => $d['claim'],
));
}
}
}
// Store to combineData New Incentives Ayer Keroh // Store to combineData New Incentives Ayer Keroh
foreach ($count_ayerKeroh as $key => $d) { foreach ($count_ayerKeroh as $key => $d) {
if(count($count_ayerKeroh) > 50){ if(count($count_ayerKeroh) > 50){
} }
// Store to combineData New Incentives Alor Gajah // Store to combineData New Incentives Alor Gajah
foreach ($count_alorGajah as $key => $d) { foreach ($count_alorGajah as $key => $d) {
if(count($count_alorGajah) > 20){
if(count($count_alorGajah) > 50){


if($d['contract'] == '12'){ if($d['contract'] == '12'){




} }


}else if(count($count_alorGajah) < 20){
}else if(count($count_alorGajah) < 50){
if(date('m/Y', strtotime($d['activation'])) == $month.'/'.$year){ if(date('m/Y', strtotime($d['activation'])) == $month.'/'.$year){
array_push($combineData, array( array_push($combineData, array(
'index' => $d['index'], 'index' => $d['index'],

Loading…
Cancel
Save