| } | } | ||||
| public function test1(){ | |||||
| $d = DealerClaim::where('formT' == 'R')->all(); | |||||
| // public function test1(){ | |||||
| // $d = DealerClaim::where('formT' == 'R')->all(); | |||||
| $data12 = array(); $data24 = array(); $final = array(); | |||||
| foreach($d as $dc){ | |||||
| if($dc->activated_my == $mY){ | |||||
| if($dc->contract == "12"){ | |||||
| $data12[] = $dc; | |||||
| }else if($dc->contract == "24"){ | |||||
| $data24[] = $dc; | |||||
| } | |||||
| } | |||||
| } | |||||
| $countD24 = count($data24); | |||||
| $countD12 = count($data12); | |||||
| $comm = Commission::where('formT','R')->get(); | |||||
| $commV12 = 0; $commV24 = 0; | |||||
| $comm12 = ''; $comm24 = ''; | |||||
| foreach($comm as $c){ | |||||
| if($c->contract =='12'){ | |||||
| if(strpos($c->ranges, '>') !== false) { | |||||
| $pieces = explode(">", $c->ranges); | |||||
| if($countD12 >= intval($pieces[1])){ | |||||
| $commV12 = floatval($c->comm)/100; | |||||
| $comm12 = $c->comm.'%'; | |||||
| } | |||||
| } | |||||
| if(strpos($c->ranges,'-') !== false){ | |||||
| $pieces = explode("-", $c->ranges); | |||||
| if($countD12 >= intval($pieces[0]) && $countD12 <= intval($pieces[1])){ | |||||
| $commV12 = floatval($c->comm)/100; | |||||
| $comm12 = $c->comm.'%'; | |||||
| } | |||||
| } | |||||
| }else if($c->contract =='24'){ | |||||
| // Contract => 24 | |||||
| if($countD24 != 0){ | |||||
| if(strpos($c->ranges, '>') !== false) { | |||||
| $pieces = explode(">", $c->ranges); | |||||
| if($countD24 > intval($pieces[1])){ | |||||
| $commV24 = floatval($c->comm)/100; | |||||
| $comm24 = $c->comm.'%'; | |||||
| } | |||||
| } | |||||
| if(strpos($c->ranges,'-') !== false){ | |||||
| $pieces = explode("-", $c->ranges); | |||||
| if($countD24 >= intval($pieces[0]) && $countD24 <= intval($pieces[1])){ | |||||
| $commV24 = floatval($c->comm)/100; | |||||
| $comm24 = $c->comm.'%'; | |||||
| } | |||||
| } | |||||
| } | |||||
| } | |||||
| } | |||||
| foreach ($data12 as $key => $d) { | |||||
| $customer = Subscriber::where('_id', $d['customer_id'])->first(); | |||||
| $address = $customer->unit_no.', '.$customer->building.', '.$customer->street.', '.$customer->postcode.', '.$customer->city.', '.$customer->state; | |||||
| $final[] = array( | |||||
| 'index' => $d['formT'], | |||||
| 'contract' => $d['contract'], | |||||
| 'wo' => $d['wo'], | |||||
| 'activation' => $d['activated_dt'], | |||||
| 'name' => $customer->name, | |||||
| 'address' => $address, | |||||
| 'package' => $d['package'], | |||||
| 'retail_price' => 'RM '.$d['retail_price'], | |||||
| 'incentives1' => $comm12, | |||||
| 'incentives2' => '', | |||||
| 'total' => 'RM '.number_format($d['retail_price']*$commV12,2), | |||||
| 'claim' => $d['claim_dt'], | |||||
| ); | |||||
| } | |||||
| foreach ($data24 as $key => $d) { | |||||
| $customer = Subscriber::where('_id', $d['customer_id'])->first(); | |||||
| $address = $customer->unit_no.', '.$customer->building.', '.$customer->street.', '.$customer->postcode.', '.$customer->city.', '.$customer->state; | |||||
| $final[] = array( | |||||
| 'index' => $d['formT'], | |||||
| 'contract' => $d['contract'], | |||||
| 'wo' => $d['wo'], | |||||
| 'activation' => $d['activated_dt'], | |||||
| 'name' => $customer->name, | |||||
| 'address' => $address, | |||||
| 'package' => $d['package'], | |||||
| 'retail_price' => 'RM '.$d['retail_price'], | |||||
| 'incentives1' => $comm24, | |||||
| 'incentives2' => '', | |||||
| 'total' => 'RM '.number_format($d['retail_price']*$commV24,2), | |||||
| 'claim' => $d['claim_dt'], | |||||
| ); | |||||
| } | |||||
| dd($final); | |||||
| } | |||||
| // $data12 = array(); $data24 = array(); $final = array(); | |||||
| // foreach($d as $dc){ | |||||
| // if($dc->activated_my == $mY){ | |||||
| // if($dc->contract == "12"){ | |||||
| // $data12[] = $dc; | |||||
| // }else if($dc->contract == "24"){ | |||||
| // $data24[] = $dc; | |||||
| // } | |||||
| // } | |||||
| // } | |||||
| // $countD24 = count($data24); | |||||
| // $countD12 = count($data12); | |||||
| // $comm = Commission::where('formT','R')->get(); | |||||
| // $commV12 = 0; $commV24 = 0; | |||||
| // $comm12 = ''; $comm24 = ''; | |||||
| // foreach($comm as $c){ | |||||
| // if($c->contract =='12'){ | |||||
| // if(strpos($c->ranges, '>') !== false) { | |||||
| // $pieces = explode(">", $c->ranges); | |||||
| // if($countD12 >= intval($pieces[1])){ | |||||
| // $commV12 = floatval($c->comm)/100; | |||||
| // $comm12 = $c->comm.'%'; | |||||
| // } | |||||
| // } | |||||
| // if(strpos($c->ranges,'-') !== false){ | |||||
| // $pieces = explode("-", $c->ranges); | |||||
| // if($countD12 >= intval($pieces[0]) && $countD12 <= intval($pieces[1])){ | |||||
| // $commV12 = floatval($c->comm)/100; | |||||
| // $comm12 = $c->comm.'%'; | |||||
| // } | |||||
| // } | |||||
| // }else if($c->contract =='24'){ | |||||
| // // Contract => 24 | |||||
| // if($countD24 != 0){ | |||||
| // if(strpos($c->ranges, '>') !== false) { | |||||
| // $pieces = explode(">", $c->ranges); | |||||
| // if($countD24 > intval($pieces[1])){ | |||||
| // $commV24 = floatval($c->comm)/100; | |||||
| // $comm24 = $c->comm.'%'; | |||||
| // } | |||||
| // } | |||||
| // if(strpos($c->ranges,'-') !== false){ | |||||
| // $pieces = explode("-", $c->ranges); | |||||
| // if($countD24 >= intval($pieces[0]) && $countD24 <= intval($pieces[1])){ | |||||
| // $commV24 = floatval($c->comm)/100; | |||||
| // $comm24 = $c->comm.'%'; | |||||
| // } | |||||
| // } | |||||
| // } | |||||
| // } | |||||
| // } | |||||
| // foreach ($data12 as $key => $d) { | |||||
| // $customer = Subscriber::where('_id', $d['customer_id'])->first(); | |||||
| // $address = $customer->unit_no.', '.$customer->building.', '.$customer->street.', '.$customer->postcode.', '.$customer->city.', '.$customer->state; | |||||
| // $final[] = array( | |||||
| // 'index' => $d['formT'], | |||||
| // 'contract' => $d['contract'], | |||||
| // 'wo' => $d['wo'], | |||||
| // 'activation' => $d['activated_dt'], | |||||
| // 'name' => $customer->name, | |||||
| // 'address' => $address, | |||||
| // 'package' => $d['package'], | |||||
| // 'retail_price' => 'RM '.$d['retail_price'], | |||||
| // 'incentives1' => $comm12, | |||||
| // 'incentives2' => '', | |||||
| // 'total' => 'RM '.number_format($d['retail_price']*$commV12,2), | |||||
| // 'claim' => $d['claim_dt'], | |||||
| // ); | |||||
| // } | |||||
| // foreach ($data24 as $key => $d) { | |||||
| // $customer = Subscriber::where('_id', $d['customer_id'])->first(); | |||||
| // $address = $customer->unit_no.', '.$customer->building.', '.$customer->street.', '.$customer->postcode.', '.$customer->city.', '.$customer->state; | |||||
| // $final[] = array( | |||||
| // 'index' => $d['formT'], | |||||
| // 'contract' => $d['contract'], | |||||
| // 'wo' => $d['wo'], | |||||
| // 'activation' => $d['activated_dt'], | |||||
| // 'name' => $customer->name, | |||||
| // 'address' => $address, | |||||
| // 'package' => $d['package'], | |||||
| // 'retail_price' => 'RM '.$d['retail_price'], | |||||
| // 'incentives1' => $comm24, | |||||
| // 'incentives2' => '', | |||||
| // 'total' => 'RM '.number_format($d['retail_price']*$commV24,2), | |||||
| // 'claim' => $d['claim_dt'], | |||||
| // ); | |||||
| // } | |||||
| // dd($final); | |||||
| // } | |||||
| public function getDealerCompany(){ | public function getDealerCompany(){ |