12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958 |
- <?php
-
- namespace App\Http\Controllers\EEP;
-
- use Illuminate\Http\Request;
- use App\Http\Controllers\Controller;
- use Illuminate\Support\Facades\Auth;
-
- use Carbon\Carbon;
- use Validator;
- use PDF;
-
- use App\Staff;
- use App\Model\StaffDetail;
-
- use App\Model\Coverage;
- use App\Model\DealerClaim;
- use App\Model\DealerClaim2;
-
- use App\Model\Commission;
- use App\Model\Company;
-
- use App\Model\Form;
- use App\Model\FormStatus;
- use App\Model\Subscriber;
- use App\Model\PackageDetail;
- use App\Model\WorkOrder;
- use App\Model\Docket;
-
- class EephrController extends Controller
- {
- public function dashboard()
- {
- $id = Auth::guard('eephr')->id();
- $user = Staff::with('StaffDetail')->find($id);
-
- $finalD1 = array();
- $finalD2 = array();
- $finalD3 = array();
- $finalD4 = array();
- $finalD5 = array();
- $finalD6 = array();
-
- $jan = array();
- $feb = array();
- $mac = array();
- $april = array();
- $may = array();
- $jun = array();
- $july = array();
- $august = array();
- $sep = array();
- $oct = array();
- $nov = array();
- $dec = array();
-
- $jan1 = array();
- $feb1 = array();
- $mac1 = array();
- $april1 = array();
- $may1 = array();
- $jun1 = array();
- $july1 = array();
- $august1 = array();
- $sep1 = array();
- $oct1 = array();
- $nov1 = array();
- $dec1 = array();
-
- $de = Form::all();
- foreach ($de as $key => $d) {
-
- if (!empty($d->dealer_id)) {
- $finalD1[] = $d;
-
- $mY = Carbon::parse($d->created_at)->format('m/Y');
- if ($mY == '01/2019') {
- $jan[] = $d;
- } else if ($mY == '02/2019') {
- $feb[] = $d;
- } else if ($mY == '03/2019') {
- $mac[] = $d;
- } else if ($mY == '04/2019') {
- $april[] = $d;
- } else if ($mY == '05/2019') {
- $may[] = $d;
- } else if ($mY == '06/2019') {
- $jun[] = $d;
- } else if ($mY == '07/2019') {
- $july[] = $d;
- } else if ($mY == '08/2019') {
- $august[] = $d;
- } else if ($mY == '09/2019') {
- $sep[] = $d;
- } else if ($mY == '10/2019') {
- $oct[] = $d;
- } else if ($mY == '11/2019') {
- $nov[] = $d;
- } else if ($mY == '12/2019') {
- $dec[] = $d;
- }
-
- $finalD6 = [count($jan), count($feb), count($mac), count($april), count($may), count($jun), count($july), count($august), count($sep), count($oct), count($nov), count($dec)];
- } else if (empty($d->dealer_id)) {
- $mY = Carbon::parse($d->created_at)->format('m/Y');
- if ($mY == '01/2019') {
- $jan1[] = $d;
- } else if ($mY == '02/2019') {
- $feb1[] = $d;
- } else if ($mY == '03/2019') {
- $mac1[] = $d;
- } else if ($mY == '04/2019') {
- $april1[] = $d;
- } else if ($mY == '05/2019') {
- $may1[] = $d;
- } else if ($mY == '06/2019') {
- $jun1[] = $d;
- } else if ($mY == '07/2019') {
- $july1[] = $d;
- } else if ($mY == '08/2019') {
- $august1[] = $d;
- } else if ($mY == '09/2019') {
- $sep1[] = $d;
- } else if ($mY == '10/2019') {
- $oct1[] = $d;
- } else if ($mY == '11/2019') {
- $nov1[] = $d;
- } else if ($mY == '12/2019') {
- $dec1[] = $d;
- }
-
- $finalD5 = [count($jan1), count($feb1), count($mac1), count($april1), count($may1), count($jun1), count($july1), count($august1), count($sep1), count($oct1), count($nov1), count($dec1)];
-
- if ($d->type_service != 'Rectification') {
- $finalD2[] = $d;
- $finalD4[] = $d;
- }
- }
-
- if ($d->type_service == 'Rectification') {
- $finalD3[] = $d;
- }
- }
-
- $total = count($finalD4);
- $dealer = count($finalD1);
- $normal = count($finalD2);
- $rec = count($finalD3);
- $rejected = count(Form::onlyTrashed()->get());
- return view('eep-hr.dashboard', compact('user', 'total', 'rec', 'dealer', 'normal', 'rejected', 'finalD5', 'finalD6'));
- }
-
- public function viewList()
- {
- $id = Auth::guard('eephr')->id();
- $user = Staff::with('StaffDetail')->find($id);
- return view('eep-hr.index', compact('user'));
- }
-
- /***
- / Application Form List
- ***/
- public function viewAppList()
- {
-
- $id = Auth::guard('ds')->id();
- $user = Staff::with('StaffDetail')->find($id);
- return view('dealer.application-form-list', compact('user'));
- }
-
- /***
- / Get Application Form List
- ***/
-
-
- public function getOrderHistory($id)
- {
-
- $data = array();
- $order_history = FormStatus::where('form_id', $id)->get();
- foreach ($order_history as $oh) {
- $utcdatetime = new \MongoDB\BSON\UTCDateTime((string) $oh->date);
- $datetime = $utcdatetime->toDateTime();
- $time = $datetime->format(DATE_RSS);
- $time = strtotime($time . ' UTC');
- $dateInLocal = date("d/m/Y h:i a", $time);
- $data[] = array(
- 'date' => $dateInLocal,
- 'status' => $oh->status,
- 'desc' => $oh->desc
- );
- }
-
- $json = json_encode($data);
- return $json;
- }
-
- public function gApplicationList2()
- {
- $id = Auth::guard('eephr')->id();
- $user = Staff::with('StaffDetail')->find($id);
-
- $fm = Form::with('Subscriber')->where('company_id', $user->StaffDetail->company_id)->orderBy('created_at', 'desc')->get();
-
- $nested_data = array();
- $i = 0;
-
- foreach ($fm as $f) {
- $dname = "";
- $wo = WorkOrder::where('_id', $f->_id)->first();
- $dealer = StaffDetail::where('_id', $f->dealer_id)->first();
-
- if (!empty($dealer)) {
- $dname = $dealer->name;
- }
-
- $address = '';
- $name = '';
- if ($f->type_application == 'R') {
- if (!empty($f->Subscriber->building_name)) {
- $address = $f->Subscriber->building_name;
- $name = $f->Subscriber->name;
- }
- } else if ($f->type_application == 'B') {
- $address = '-';
- $name = $f->Subscriber->company_name;
- }
-
-
- if (!empty($wo) && $wo->status != 'Completed') {
- $i++;
- array_push($nested_data, array(
- 'index' => $i . $f->type_application,
- 'name' => $name,
- 'phone' => $f->Subscriber->phone1,
- 'unit' => $f->Subscriber->unit_no,
- 'building' => $address,
- 'street' => $f->Subscriber->street,
- 'postcode' => $f->Subscriber->postcode,
- 'city' => $f->Subscriber->city,
- 'sales' => $dname,
- 'action' => $f->_id
- ));
- }
- }
-
- return \DataTables::of($nested_data)->make(true);
- }
-
- public function getCompletedList($year, $month)
- {
-
- $id = Auth::guard('ds')->id();
- $user = Staff::find($id);
- $email = $user->email;
-
- $userDetails = StaffDetail::where('email', $email)->first();
-
- $subs = $this->getSubscribers($userDetails->company_id);
- $buss = $this->getBusiness($userDetails->company_id);
-
- // Combine
- $cdata = array();
- foreach ($subs as $key => $s) {
- $cdata[] = $s;
- }
-
- foreach ($buss as $key => $b) {
- $cdata[] = $b;
- }
-
- // Sort based on TimeStamp
- $sort = array();
- foreach ($cdata as $key => $r) {
- $sort[$key] = $r['created_at'];
- }
- array_multisort($sort, SORT_DESC, $cdata);
-
- $wK = WorkDetail::get();
- $curr = Carbon::now()->getTimestamp();
-
- $mY = '';
- if ($year != 'null' && $month != 'null') {
- $mY = $year . '/' . $month;
- }
-
- $final = array();
- $filter = array();
- $dW = array();
-
- foreach ($cdata as $c) {
- if ($c['wo'] != '') {
- foreach ($wK as $key => $w) {
- if ($c['wo'] == $w->wo && $w->status == 'Completed') {
- $dW[] = $c;
- }
- }
- }
- }
-
- foreach ($dW as $d) {
- if ($mY != '') {
- $docket = Docket::where('work_order_id', $d['wo'])->first();
- $cDate = date('Y/m', strtotime($docket->end_job));;
- if ($mY == $cDate) {
- $filter[] = $d;
- }
- } else {
- $filter[] = $d;
- }
- }
-
- foreach ($filter as $c) {
- $do = Docket::where('work_order_id', $c['wo'])->first();
-
- $n1 = '';
- $reg_time = Carbon::createFromTimestamp(strtotime($do->end_job));
- $expiry_date = $reg_time->addDays(3);
- $expiry_date = $expiry_date->getTimestamp();
-
- if ($curr < $expiry_date) {
- $n1 = "New/";
- }
-
- $final[] = array(
- 'formT' => $c['formT'],
- 'wo' => $c['wo'],
- 'do' => $do->docket_id,
- 'activated' => $do->end_job,
- 'name' => $n1 . str_replace("New/", "", $c['name']),
- 'no' => $c['no'],
- 'unit' => $c['unit'],
- 'building' => $c['building'],
- 'street' => $c['street'],
- 'postcode' => $c['postcode'],
- 'city' => $c['city'],
- 'sales' => $c['sales'],
- 'created_at' => $c['created_at'],
- 'action' => $c['action'],
- );
- }
-
- return $final;
- }
- public function gApplicationList3($year, $month)
- {
- $id = Auth::guard('ds')->id();
- $user = Staff::with('StaffDetail')->find($id);
-
- $mY = '';
- if ($year != 'null' && $month != 'null') {
- $mY = $month . '/' . $year;
- }
-
- $fm = Form::with('Subscriber', 'WorkOrder')->where('company_id', $user->StaffDetail->company_id)->orderBy('created_at', 'desc')->get();
-
- $nested_data = array();
- $i = 0;
- foreach ($fm as $f) {
- if (!empty($f->WorkOrder)) {
- if ($f->WorkOrder->status == 'Completed') {
-
- $wo = WorkOrder::with('Docket')->where('wo', $f->WorkOrder->wo)->first();
- $dealer = StaffDetail::where('_id', $f->dealer_id)->withTrashed()->first();
- $i++;
-
- $address = '';
- $name = '';
- if ($f->type_application == 'R') {
- if (!empty($f->Subscriber->building_name)) {
- $address = $f->Subscriber->building_name;
- $name = $f->Subscriber->name;
- }
- } else if ($f->type_application == 'B') {
- $address = '-';
- $name = $f->Subscriber->company_name;
- }
-
- if (!empty($wo->Docket)) {
- $end = date('m/Y', strtotime($wo->Docket->end_job));
-
- if ($mY == '') {
- array_push($nested_data, array(
- 'index' => $i . $f->type_application,
- 'wo' => $wo->wo,
- 'do' => $f->WorkOrder->docket_id,
- 'name' => $name,
- 'phone' => $f->Subscriber->phone1,
- 'unit' => $f->Subscriber->unit_no,
- 'building' => $address,
- 'street' => $f->Subscriber->street,
- 'postcode' => $f->Subscriber->postcode,
- 'city' => $f->Subscriber->city,
- 'sales' => $dealer->name,
- 'action' => $f->_id
- ));
- } else if ($mY == $end) {
- array_push($nested_data, array(
- 'index' => $i . $f->type_application,
- 'wo' => $wo->wo,
- 'do' => $f->WorkOrder->docket_id,
- 'name' => $name,
- 'phone' => $f->Subscriber->phone1,
- 'unit' => $f->Subscriber->unit_no,
- 'building' => $address,
- 'street' => $f->Subscriber->street,
- 'postcode' => $f->Subscriber->postcode,
- 'city' => $f->Subscriber->city,
- 'sales' => $dealer->name,
- 'action' => $f->_id
- ));
- }
- }
- }
- }
- }
-
- return \DataTables::of($nested_data)->make(true);
- }
-
- /***
- / Encrypt Password
- ***/
- public function encryptPassword($action, $string)
- {
- $output = false;
- $encrypt_method = "AES-256-CBC";
- $secret_key = '28472B4B6250655368566D5970337336';
- $secret_iv = md5(md5($string)); //'This is my secret iv';
-
- // hash
- $key = hash('sha256', $secret_key);
-
- $iv = substr(hash('sha256', $secret_iv), 0, 16);
- if ($action == 'encrypt') {
- $output = openssl_encrypt($string, $encrypt_method, $key, 0, $iv);
- $output = base64_encode($output);
- } else if ($action == 'decrypt') {
- $output = openssl_decrypt(base64_decode($string), $encrypt_method, $key, 0, $iv);
- }
- return $output;
- }
-
- /***
- / Application Form
- ***/
- public function showResidentialForm()
- {
-
- $id = Auth::guard('eephr')->id();
- $user = Staff::find($id);
- $email = $user->email;
-
- $userDetails = StaffDetail::where('email', $email)->first();
-
- return view('eep-hr.residential-form', compact('userDetails', 'user'));
- }
-
-
- public function exportDealerJson(Request $request)
- {
-
- $final = array();
-
- $id = Auth::guard('ds')->id();
- // $user = Staff::with('StaffDetail')->find($id);
- // $com = Company::where('_id',$user->StaffDetail->company_id)->first();
-
- $dataR = array();
- $dataB = array();
- $combineData = array();
- $extra = 0;
-
- $year = $request->year;
- $month = $request->month;
- $app = $request->app;
- $company = $request->company;
-
- if ($year != 'null' && $month != 'null' && $app == 'null') {
-
- $count_cyberjaya = array();
- $count_jasin = array();
- $count_ayerKeroh = array();
- $count_alorGajah = array();
- $count_menglembu = array();
- $count_ipoh = array();
- $extra = 0;
- $basic_total = 0;
- $countAugustR = array();
- $countAugustB = array();
-
- // if(($year == '2019' || $year == '2020') && ($month == '12' || $month == '01')){
- // $dataDis = $this->returnDataR($company,'2019','12');
- // $dataJan = $this->returnDataR($company,'2020','1');
- if ($year == '2020' && ($month == '04' || $month == '05' || $month == '06' || $month == '07')) {
- $dataApril = $this->returnDataR($company, '2020', '4');
- $dataMay = $this->returnDataR($company, '2020', '5');
- $dataJune = $this->returnDataR($company, '2020', '6');
- $dataJuly = $this->returnDataR($company, '2020', '7');
-
- foreach ($dataApril as $key => $d) {
- // if(date('d/m/Y', strtotime($d['activation'])) >= '12/12/2019'){
- // if (strpos($d['address'], 'Cyberjaya') !== false) {
- // $count_cyberjaya[] = $d;
- // }
-
- // if (strpos($d['address'], 'Jasin') !== false) {
- // $count_jasin[] = $d;
- // }
-
- // }
- // // else
- if (date('d/m/Y', strtotime($d['activation'])) >= '27/4/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;
- }
-
- if (strpos($d['address'], 'Menglembu') !== false) {
- $count_menglembu[] = $d;
- }
-
- if (strpos($d['address'], 'Ipoh') !== false) {
- $count_ipoh[] = $d;
- }
- } else {
- if (date('m/Y', strtotime($d['activation'])) == $month . '/' . $year) {
- $combineData[] = $d;
- }
- }
- }
-
- foreach ($dataMay as $key => $d) {
- 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;
- }
-
- if (strpos($d['address'], 'Menglembu') !== false) {
- $count_menglembu[] = $d;
- }
-
- if (strpos($d['address'], 'Ipoh') !== false) {
- $count_ipoh[] = $d;
- }
- }
-
- foreach ($dataJune as $key => $d) {
- 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;
- }
-
- if (strpos($d['address'], 'Menglembu') !== false) {
- $count_menglembu[] = $d;
- }
-
- if (strpos($d['address'], 'Ipoh') !== false) {
- $count_ipoh[] = $d;
- }
- }
-
- foreach ($dataJuly as $key => $d) {
- 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;
- }
-
- if (strpos($d['address'], 'Menglembu') !== false) {
- $count_menglembu[] = $d;
- }
-
- if (strpos($d['address'], 'Ipoh') !== false) {
- $count_ipoh[] = $d;
- }
- }
-
- // Store to combineData New Incentives Cyberjaya
- foreach ($count_cyberjaya as $key => $d) {
- if (count($count_cyberjaya) > 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_cyberjaya) < 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 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
- foreach ($count_ayerKeroh as $key => $d) {
- if (count($count_ayerKeroh) > 50) {
-
- 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 {
-
- if (date('m/Y', strtotime($d['activation'])) == $month . '/' . $year) {
- $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_ayerKeroh) < 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 Alor Gajah
- foreach ($count_alorGajah as $key => $d) {
- if (count($count_alorGajah) > 50) {
-
- 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 {
-
- if (date('m/Y', strtotime($d['activation'])) == $month . '/' . $year) {
- $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_alorGajah) < 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 Jasin
- foreach ($count_jasin as $key => $d) {
- if (count($count_jasin) > 20) {
-
- 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 {
-
- if (date('m/Y', strtotime($d['activation'])) == $month . '/' . $year) {
- $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_jasin) < 20) {
- 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'],
- ));
- }
- }
- }
- } else if ($year == '2020' && ($month == '08' || $month == '09' || $month == '10')) {
- $dataAugustR = $this->returnDataR($company, '2020', '8');
- $dataAugustB = $this->returnDataB($company, '2020', '8');
- $dataSeptemberR = $this->returnDataR($company, '2020', '9');
- $dataSeptemberB = $this->returnDataB($company, '2020', '9');
- $dataOctoberR = $this->returnDataR($company, '2020', '10');
- $dataOctoberB = $this->returnDataB($company, '2020', '10');
-
- foreach ($dataAugustR as $key => $d) {
- if ((date('m/Y', strtotime($d['submission'])) == $month . '/' . $year) && date('d/m/Y', strtotime($d['submission'])) >= '11/8/2020') {
- if ($d['contract'] == '24') {
- if ($d['package'] == 50) {
- $d['retail_price'] = 69;
- } elseif ($d['package'] == 100) {
- $d['retail_price'] = 89;
- } elseif ($d['package'] == 500) {
- $d['retail_price'] = 129;
- }
- }
-
- if (date('d/m/Y', strtotime($d['activation'])) >= '11/8/2020') {
- $countAugustR[] = $d;
- }
- } else {
- if (date('d/m/Y', strtotime($d['activation'])) >= '11/8/2020') {
- $countAugustR[] = $d;
- } else {
- $combineData[] = $d;
- }
- }
- }
- // Store to combineData New Incentive August
- foreach ($countAugustR as $key => $d) {
- if (count($dataAugustR) >= 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.5 + 50, 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' => '250% + RM50',
- 'incentives2' => $d['incentives2'],
- 'total' => 'RM ' . $total,
- 'claim' => $d['claim'],
- ));
- }
- }
- } else if (count($dataAugustR) < 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.5, 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' => '250%',
- 'incentives2' => $d['incentives2'],
- 'total' => 'RM ' . $total,
- 'claim' => $d['claim'],
- ));
- }
- }
- }
- }
-
- foreach ($dataAugustB as $key => $d) {
- if ((date('m/Y', strtotime($d['submission'])) == $month . '/' . $year) && date('d/m/Y', strtotime($d['submission'])) >= '11/8/2020') {
- if ($d['contract'] == '24') {
- if ($d['package'] == 50) {
- $d['retail_price'] = 89;
- } elseif ($d['package'] == 100) {
- $d['retail_price'] = 119;
- } elseif ($d['package'] == 300) {
- $d['retail_price'] = 179;
- } elseif ($d['package'] == 500) {
- $d['retail_price'] = 249;
- }
- }
-
- if (date('d/m/Y', strtotime($d['activation'])) >= '11/8/2020') {
- $countAugustB[] = $d;
- }
- } else {
- if (date('d/m/Y', strtotime($d['activation'])) >= '11/8/2020') {
- $countAugustB[] = $d;
- } else {
- $combineData[] = $d;
- }
- }
- }
- // Store to combineData New Incentive August
- foreach ($countAugustB as $key => $d) {
- if (count($dataAugustB) >= 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 {
- if ($d['package'] == 1) {
- $total = 1500;
- } else {
- $total = number_format(floatval(str_replace("RM ", "", $d['retail_price'])) * 2.5 + 50, 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' => '250% + RM50',
- 'incentives2' => '',
- 'total' => 'RM ' . $total,
- 'claim' => $d['claim'],
- ));
- }
- }
- } else if (count($dataAugustB) < 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 {
- if ($d['package'] == 1) {
- $total = 1500;
- } else {
- $total = number_format(floatval(str_replace("RM ", "", $d['retail_price'])) * 2.5, 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' => '250%',
- 'incentives2' => '',
- 'total' => 'RM ' . $total,
- 'claim' => $d['claim'],
- ));
- }
- }
- }
- }
-
- foreach ($dataSeptemberR as $key => $d) {
- if (((date('m/Y', strtotime($d['submission'])) == '08/2020') && (date('d/m/Y', strtotime($d['submission'])) >= '11/8/2020')) || (date('m/Y', strtotime($d['submission'])) == $month . '/' . $year)) {
- if ($d['contract'] == '24') {
- if ($d['package'] == 50) {
- $d['retail_price'] = 69;
- } elseif ($d['package'] == 100) {
- $d['retail_price'] = 89;
- } elseif ($d['package'] == 500) {
- $d['retail_price'] = 129;
- }
- }
- }
-
- if (count($dataSeptemberR) >= 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.5 + 50, 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' => '250% + RM50',
- 'incentives2' => $d['incentives2'],
- 'total' => 'RM ' . $total,
- 'claim' => $d['claim'],
- ));
- }
- }
- } else if (count($dataSeptemberR) < 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.5, 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' => '250%',
- 'incentives2' => $d['incentives2'],
- 'total' => 'RM ' . $total,
- 'claim' => $d['claim'],
- ));
- }
- }
- }
- }
-
- foreach ($dataSeptemberB as $key => $d) {
- if (((date('m/Y', strtotime($d['submission'])) == '08/2020') && (date('d/m/Y', strtotime($d['submission'])) >= '11/8/2020')) || (date('m/Y', strtotime($d['submission'])) == $month . '/' . $year)) {
- if ($d['contract'] == '24') {
- if ($d['package'] == 50) {
- $d['retail_price'] = 89;
- } elseif ($d['package'] == 100) {
- $d['retail_price'] = 119;
- } elseif ($d['package'] == 300) {
- $d['retail_price'] = 179;
- } elseif ($d['package'] == 500) {
- $d['retail_price'] = 249;
- }
- }
- }
-
- if (count($dataSeptemberB) >= 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 {
- if ($d['package'] == 1) {
- $total = 1500;
- } else {
- $total = number_format(floatval(str_replace("RM ", "", $d['retail_price'])) * 2.5 + 50, 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' => '250% + RM50',
- 'incentives2' => '',
- 'total' => 'RM ' . $total,
- 'claim' => $d['claim'],
- ));
- }
- }
- } else if (count($dataSeptemberB) < 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 {
- if ($d['package'] == 1) {
- $total = 1500;
- } else {
- $total = number_format(floatval(str_replace("RM ", "", $d['retail_price'])) * 2.5, 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' => '250%',
- 'incentives2' => '',
- 'total' => 'RM ' . $total,
- 'claim' => $d['claim'],
- ));
- }
- }
- }
- }
-
- foreach ($dataOctoberR as $key => $d) {
- if (((date('m/Y', strtotime($d['submission'])) == '08/2020') && (date('d/m/Y', strtotime($d['submission'])) >= '11/8/2020')) || (date('m/Y', strtotime($d['submission'])) == $month . '/' . $year) || (date('m/Y', strtotime($d['submission'])) == '09/2020')) {
- if ($d['contract'] == '24') {
- if ($d['package'] == 50) {
- $d['retail_price'] = 69;
- } elseif ($d['package'] == 100) {
- $d['retail_price'] = 89;
- } elseif ($d['package'] == 500) {
- $d['retail_price'] = 129;
- }
- }
- }
-
- if (count($dataOctoberR) >= 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.5 + 50, 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' => '250% + RM50',
- 'incentives2' => $d['incentives2'],
- 'total' => 'RM ' . $total,
- 'claim' => $d['claim'],
- ));
- }
- }
- } else if (count($dataOctoberR) < 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.5, 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' => '250%',
- 'incentives2' => $d['incentives2'],
- 'total' => 'RM ' . $total,
- 'claim' => $d['claim'],
- ));
- }
- }
- }
- }
-
- foreach ($dataOctoberB as $key => $d) {
- if (((date('m/Y', strtotime($d['submission'])) == '08/2020') && (date('d/m/Y', strtotime($d['submission'])) >= '11/8/2020')) || (date('m/Y', strtotime($d['submission'])) == $month . '/' . $year) || (date('m/Y', strtotime($d['submission'])) == '09/2020')) {
- if ($d['contract'] == '24') {
- if ($d['package'] == 50) {
- $d['retail_price'] = 89;
- } elseif ($d['package'] == 100) {
- $d['retail_price'] = 119;
- } elseif ($d['package'] == 300) {
- $d['retail_price'] = 179;
- } elseif ($d['package'] == 500) {
- $d['retail_price'] = 249;
- }
- }
- }
-
- if (count($dataOctoberB) >= 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 {
- if ($d['package'] == 1) {
- $total = 1500;
- } else {
- $total = number_format(floatval(str_replace("RM ", "", $d['retail_price'])) * 2.5 + 50, 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' => '250% + RM50',
- 'incentives2' => '',
- 'total' => 'RM ' . $total,
- 'claim' => $d['claim'],
- ));
- }
- }
- } else if (count($dataOctoberB) < 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 {
- if ($d['package'] == 1) {
- $total = 1500;
- } else {
- $total = number_format(floatval(str_replace("RM ", "", $d['retail_price'])) * 2.5, 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' => '250%',
- 'incentives2' => '',
- 'total' => 'RM ' . $total,
- 'claim' => $d['claim'],
- ));
- }
- }
- }
- }
- } else if ($year == '2020' && ($month == '12')) {
- $dataDecemberR = $this->returnDataR($company, '2020', '12');
- foreach ($dataDecemberR as $r) {
- $combineData[] = $r;
- }
-
- $dataDecemberB = $this->returnDataB($company, '2020', '12');
- foreach ($dataDecemberB as $b) {
- if ((date('m/Y', strtotime($b['submission'])) == $month . '/' . $year) && date('d/m/Y', strtotime($b['submission'])) >= '21/12/2020') {
- if (strpos($b['address'], 'CYBERJAYA') !== false && $b['contract'] == '24' && $b['package'] == 1) {
- $b['retail_price'] = 999;
- $count_businessCyber[] = $b;
- }
- else {
- $combineData[] = $b;
- }
- } else {
- $combineData[] = $b;
- }
- }
-
- if(!empty($count_businessCyber)){
- for ($i=0;$i<count($count_businessCyber);$i++){
- info('i' . $i);
- for($j=0; ($j<count($count_businessCyber)&&$j<51);$j++){
- info('j' . $j);
- $total = number_format(floatval(str_replace("RM ", "", $count_businessCyber[$j]['retail_price'])) * 2.0, 2);
- array_push($combineData, array(
- 'index' => $count_businessCyber[$j]['index'],
- 'contract' => $count_businessCyber[$j]['contract'],
- 'wo' => $count_businessCyber[$j]['wo'],
- 'activation' => $count_businessCyber[$j]['activation'],
- 'name' => $count_businessCyber[$j]['name'],
- 'address' => $count_businessCyber[$j]['address'],
- 'package' => $count_businessCyber[$j]['package'],
- 'retail_price' => $count_businessCyber[$j]['retail_price'],
- 'incentives1' => '200%',
- 'incentives2' => $count_businessCyber[$j]['incentives2'],
- 'total' => 'RM ' . $total,
- 'claim' => $count_businessCyber[$j]['claim'],
- ));
- }
- for($j=51; ($j < count($count_businessCyber) && $j>=51);$j++){
- $total = number_format(floatval(str_replace("RM ", "", $count_businessCyber[$j]['retail_price'])) * 2.5, 2);
- array_push($combineData, array(
- 'index' => $count_businessCyber[$j]['index'],
- 'contract' => $count_businessCyber[$j]['contract'],
- 'wo' => $count_businessCyber[$j]['wo'],
- 'activation' => $count_businessCyber[$j]['activation'],
- 'name' => $count_businessCyber[$j]['name'],
- 'address' => $count_businessCyber[$j]['address'],
- 'package' => $count_businessCyber[$j]['package'],
- 'retail_price' => $count_businessCyber[$j]['retail_price'],
- 'incentives1' => '250%',
- 'incentives2' => $count_businessCyber[$j]['incentives2'],
- 'total' => 'RM ' . $total,
- 'claim' => $count_businessCyber[$j]['claim'],
- ));
- }
- }
- }
-
- } else {
- $dataR = $this->returnDataR($company, $year, $month);
- foreach ($dataR as $r) {
- $combineData[] = $r;
- }
-
- $dataB = $this->returnDataB($company, $year, $month);
-
- foreach ($dataB as $b) {
- $combineData[] = $b;
- }
- }
-
- $i = 0;
- $nested_data = array();
- if (!empty($combineData)) {
- foreach ($combineData as $c) {
- $update_dealer = DealerClaim::where('wo', $c['wo'])->first();
- if (!empty($update_dealer)) {
- $update_dealer->incentives1 = $c['incentives1'];
- $update_dealer->incentives2 = $c['incentives2'];
- $update_dealer->retail_price = $c['retail_price'];
- $update_dealer->total_claim = $c['total'];
- $update_dealer->save();
- }
- }
- }
-
- $dataClaim = DealerClaim::with(['Subscriber' => function ($q) {
- $q->with('Form');
- }], 'Staff')->where('dealer', $company)->where('activated_my', $month . '/' . $year)->get();
-
- if (!empty($dataClaim)) {
- foreach ($dataClaim as $c) {
-
- $address = '';
- $name = '';
- if ($c->Subscriber->Form->type_application == 'R') {
-
- if ($c->Subscriber->street != '') {
- $address = $c->Subscriber->unit_no . ' , ' . $c->Subscriber->street . ' , ' . $c->Subscriber->building_name . ' , ' . $c->Subscriber->postcode . ' , ' . $c->Subscriber->city . ' , ' . $c->Subscriber->state;
- } else {
- $address = $c->Subscriber->unit_no . ' , ' . $c->Subscriber->building_name . ' , ' . $c->Subscriber->postcode . ' , ' . $c->Subscriber->city . ' , ' . $c->Subscriber->state;
- }
-
- $name = $c->Subscriber->name;
- } else if ($c->Subscriber->Form->type_application == 'B') {
-
- if ($c->Subscriber->unit_no != '') {
- $unit = $c->Subscriber->unit_no;
- } else {
- $unit = ' ';
- }
-
- if ($c->Subscriber->building_name == null) {
- $address = $unit . ' , ' . $c->Subscriber->street . ' , ' . $c->Subscriber->postcode . ' , ' . $c->Subscriber->city . ' , ' . $c->Subscriber->state;
- } else {
- $address = $unit . ' , ' . $c->Subscriber->street . ' , ' . $c->Subscriber->building_name . ' , ' . $c->Subscriber->postcode . ' , ' . $c->Subscriber->city . ' , ' . $c->Subscriber->state;
- }
-
- $name = $c->Subscriber->company_name;
- }
-
- $i++;
- array_push($final, array(
- 'index' => $c->formT,
- 'contract' => $c->contract,
- 'wo' => $c->wo,
- 'activated_dt' => $c->activated_dt,
- 'name' => $name,
- 'address' => $address,
- 'package' => $c->package,
- 'retail_price' => $c->retail_price,
- 'incentives1' => $c->incentives1,
- 'incentives2' => $c->incentives2,
- 'total' => $c->total_claim,
- 'claimed' => $c->claim_dt,
- ));
- }
- }
-
- foreach ($final as $f) {
- $basic_total += floatval(str_replace('RM ', '', $f['total']));
- }
-
- // Calculate extra incentves
- // if($month == '1' && $year == '2020'){
- // if(count($count_cyberjaya) > 50){
- // $balance = count($count_cyberjaya) - 50;
- // $extra += $balance * 50;
- // }
-
- // if(count($count_jasin) > 10){
- // $balance = count($count_jasin) - 10;
- // $extra += $balance * 50;
- // }
- // }else if(($month == '4' || $month == '5'|| $month == '6' || $month == '7') && $year == '2020'){
- // if(count($count_cyberjaya) > 50){
- // $balance = count($count_cyberjaya) - 50;
- // $extra += $balance * 50;
- // }
-
- // if(count($count_jasin) > 20){
- // $balance = count($count_jasin) - 10;
- // $extra += $balance * 50;
- // }
- // }else {
- // $extra = 0;
- // }
-
- $extra = 0;
- $totals = $basic_total + $extra;
-
- // $pdf = PDF::loadView('pdf.agent-claim', compact('final', 'month', 'year','com','basic_total','extra','totals'));
- // $pdf->setPaper('A4', 'landscape');
- // $pdfName = preg_replace('/\s+/', '-', $com->name).'-'.$month.'-'.$year.'.pdf';
-
- // return $pdf->download( $pdfName );
-
- return $final;
- }
- // else if($year!='null' && $month!='null' && $app!='null'){
-
- // $count_cyberjaya = array(); $count_jasin = array();
- // $extra = 0; $basic_total = 0; $totals = 0;
-
- // if($app == 'Residential'){
-
- // if(($year == '2019' || $year == '2020') && ($month == '12' || $month == '1')){
- // $dataDis = $this->returnDataR($company,'2019','12');
- // $dataJan = $this->returnDataR($company,'2020','1');
-
- // foreach ($dataDis as $key => $d) {
- // if(date('d/m/Y', strtotime($d['activation'])) >= '12/12/2019'){
- // if (strpos($d['address'], 'Cyberjaya') !== false) {
- // $count_cyberjaya[] = $d;
- // }
-
- // if (strpos($d['address'], 'Jasin') !== false) {
- // $count_jasin[] = $d;
- // }
-
- // }else if(date('d/m/Y', strtotime($d['activation'])) >= '27/4/2020' && date('d/m/Y', strtotime($d['activation'])) <= '31/7/2020'){
-
- // if (strpos($d['address'], 'Cyberjaya') !== false) {
- // $count_cyberjaya[] = $d;
- // }
-
- // if (strpos($d['address'], 'Jasin') !== false) {
- // $count_jasin[] = $d;
- // }
-
- // }else {
- // if(date('n/Y', strtotime($d['activation'])) == $month.'/'.$year){
- // $combineData[] = $d;
- // }
- // }
- // }
-
- // foreach ($dataJan as $key => $d) {
- // if (strpos($d['address'], 'Cyberjaya') !== false) {
- // $count_cyberjaya[] = $d;
- // }
-
- // if (strpos($d['address'], 'Jasin') !== false) {
- // $count_jasin[] = $d;
- // }
- // }
-
- // // Store to combineData New Incentives Cyberjaya
- // foreach ($count_cyberjaya as $key => $d) {
- // if(count($count_cyberjaya) > 50){
- // if(date('n/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_cyberjaya) < 50){
- // if(date('n/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 Jasin
- // foreach ($count_jasin as $key => $d) {
- // if(count($count_jasin) > 10){
- // if(date('n/Y', strtotime($d['activation'])) == $month.'/'.$year){
- // $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_jasin) < 10){
- // if(date('n/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'],
- // ));
- // }
- // }
- // }
-
- // }else {
- // $dataR = $this->returnDataR($company,$year,$month);
- // foreach($dataR as $r){
- // $combineData[] = $r;
- // }
- // }
-
- // }else if($app == 'Business'){
- // $dataB = $this->returnDataB($company,$year,$month);
- // }
-
- // foreach($dataB as $b){
- // $combineData[] = $b;
- // }
-
- // $i = 0;
- // $nested_data = array();
- // if(!empty($combineData)){
- // foreach ($combineData as $c){
- // $i++;
- // array_push($final, array(
- // 'index' => $c['index'],
- // 'contract' => $c['contract'],
- // 'wo' => $c['wo'],
- // 'activated_dt' => $c['activation'],
- // 'name' => $c['name'],
- // 'address' => $c['address'],
- // 'package' => $c['package'],
- // 'retail_price' => $c['retail_price'],
- // 'incentives1' => $c['incentives1'],
- // 'incentives2' => $c['incentives2'],
- // 'total' => $c['total'],
- // 'claimed' => $c['claim'],
- // ));
- // }
- // }
-
- // foreach($final as $f){
- // $basic_total += floatval(str_replace('RM ', '', $f['total']));
- // }
-
- // //Calculate extra incentves
- // if($month == '1' && $year == '2020'){
- // if(count($count_cyberjaya) > 50){
- // $balance = count($count_cyberjaya) - 50;
- // $extra += $balance * 50;
- // }
-
- // if(count($count_jasin) > 10){
- // $balance = count($count_jasin) - 10;
- // $extra += $balance * 50;
- // }
- // }else if(($month == '4' || $month == '5'|| $month == '6' || $month == '7') && $year == '2020'){
- // if(count($count_cyberjaya) > 50){
- // $balance = count($count_cyberjaya) - 50;
- // $extra += $balance * 50;
- // }
-
- // if(count($count_jasin) > 20){
- // $balance = count($count_jasin) - 10;
- // $extra += $balance * 50;
- // }
- // }else {
- // $extra = 0;
- // }
-
- // $totals = $basic_total + $extra;
-
- // $pdf = PDF::loadView('pdf.agent-claim', compact('final', 'month', 'year','com','basic_total','extra','totals'));
- // $pdf->setPaper('A4', 'landscape');
- // $pdfName = preg_replace('/\s+/', '-', $com->name).'-'.$month.'-'.$year.'.pdf';
-
- // return $pdf->download( $pdfName );
- // }
- }
- }
|