id(); $user = Staff::with('StaffDetail')->find($id); $site = SiteSetting::first(); $company = Company::where('team','Dealer')->get(); $coverage = Coverage::where('Type','R')->orderBy('building_name')->get(); $c1 = 0; $c2 = 0; $c3 = 0; $c3_r = 0; $c3_b = 0;$c4 = 0; $c5 = 0; $form = Form::with('Subscriber','PackageDetail','WorkOrder')->orderBy('created_at', 'desc')->withTrashed()->get(); foreach ($form as $key => $f) { if(empty($f->WorkOrder) && !empty($f->Subscriber) && $f->type_service != "Rectification" && !$f->trashed()){ $c1++; }else if(!empty($f->WorkOrder) && $f->type_service != "Rectification"){ if($f->WorkOrder->status == 'Completed') { $c3++; if($f->type_application == 'R'){ $c3_r++; }else if($f->type_application == 'B'){ $c3_b++; } }else{ $c2++; } }else if(empty($f->WorkOrder) && $f->trashed()){ $c4++; }else if($f->type_service == "Rectification"){ $c5++; } } return view('v3.main-dashboard.form.application_form', compact('user','site','company','coverage','c1','c2','c3','c3_r','c3_b','c4','c5')); } /*** /* Rectification Form **/ public function rectificationForm(){ $id = Auth::guard('main')->id(); $user = Staff::with('StaffDetail')->find($id); $site = SiteSetting::first(); $coverage = Coverage::where('Type','R')->orderBy('building_name')->get(); $c1 = 0; $c2 = 0; $c3 = 0; $c3_r = 0; $c3_b = 0;$c4 = 0; $c5 = 0; $form = Form::with('Subscriber','PackageDetail','WorkOrder')->orderBy('created_at', 'desc')->withTrashed()->get(); foreach ($form as $key => $f) { if(empty($f->WorkOrder) && $f->type_service != "Rectification" && !$f->trashed()){ $c1++; }else if(!empty($f->WorkOrder) && $f->type_service != "Rectification"){ if($f->WorkOrder->status == 'Completed') { $c3++; if($f->type_application == 'R'){ $c3_r++; }else if($f->type_application == 'B'){ $c3_b++; } }else{ $c2++; } }else if(empty($f->WorkOrder) && $f->trashed()){ $c4++; }else if($f->type_service == "Rectification"){ $c5++; } } return view('v3.main-dashboard.form.rectification_form', compact('user','site','coverage','c1','c2','c3','c3_r','c3_b','c4','c5')); } /*** /* Pending Form **/ public function pendingForm(){ $id = Auth::guard('main')->id(); $user = Staff::with('StaffDetail')->find($id); $site = SiteSetting::first(); $company = Company::where('team','Dealer')->get(); $coverage = Coverage::where('Type','R')->orderBy('building_name')->get(); $c1 = 0; $c2 = 0; $c3 = 0; $c3_r = 0; $c3_b = 0;$c4 = 0; $c5 = 0; $form = Form::with('Subscriber','PackageDetail','WorkOrder')->orderBy('created_at', 'desc')->withTrashed()->get(); foreach ($form as $key => $f) { if(empty($f->WorkOrder) && $f->type_service != "Rectification" && !$f->trashed()){ $c1++; }else if(!empty($f->WorkOrder) && $f->type_service != "Rectification"){ if($f->WorkOrder->status == 'Completed') { $c3++; if($f->type_application == 'R'){ $c3_r++; }else if($f->type_application == 'B'){ $c3_b++; } }else{ $c2++; } }else if(empty($f->WorkOrder) && $f->trashed()){ $c4++; }else if($f->type_service == "Rectification"){ $c5++; } } return view('v3.main-dashboard.form.pending_form', compact('user','site','company','coverage','c1','c2','c3','c3_r','c3_b','c4','c5')); } /*** /* Activated Form **/ public function activatedFormResidential(){ $id = Auth::guard('main')->id(); $user = Staff::with('StaffDetail')->find($id); $site = SiteSetting::first(); $company = Company::where('team','Dealer')->get(); $coverage = Coverage::where('Type','R')->orderBy('building_name')->get(); $c1 = 0; $c2 = 0; $c3 = 0; $c3_r = 0; $c3_b = 0;$c4 = 0; $c5 = 0; $form = Form::with('Subscriber','PackageDetail','WorkOrder')->orderBy('created_at', 'desc')->withTrashed()->get(); foreach ($form as $key => $f) { if(empty($f->WorkOrder) && $f->type_service != "Rectification" && !$f->trashed()){ $c1++; }else if(!empty($f->WorkOrder) && $f->type_service != "Rectification"){ if($f->WorkOrder->status == 'Completed') { $c3++; if($f->type_application == 'R'){ $c3_r++; }else if($f->type_application == 'B'){ $c3_b++; } }else{ $c2++; } }else if(empty($f->WorkOrder) && $f->trashed()){ $c4++; }else if($f->type_service == "Rectification"){ $c5++; } } return view('v3.main-dashboard.form.activated_form_residential', compact('user','site','company','coverage','c1','c2','c3','c3_r','c3_b','c4','c5')); } public function activatedFormBusiness(){ $id = Auth::guard('main')->id(); $user = Staff::with('StaffDetail')->find($id); $site = SiteSetting::first(); $company = Company::where('team','Dealer')->get(); $coverage = Coverage::where('Type','B')->orderBy('building_name')->get(); $c1 = 0; $c2 = 0; $c3 = 0; $c3_r = 0; $c3_b = 0;$c4 = 0; $c5 = 0; $form = Form::with('Subscriber','PackageDetail','WorkOrder')->orderBy('created_at', 'desc')->withTrashed()->get(); foreach ($form as $key => $f) { if(empty($f->WorkOrder) && $f->type_service != "Rectification" && !$f->trashed()){ $c1++; }else if(!empty($f->WorkOrder) && $f->type_service != "Rectification"){ if($f->WorkOrder->status == 'Completed') { $c3++; if($f->type_application == 'R'){ $c3_r++; }else if($f->type_application == 'B'){ $c3_b++; } }else{ $c2++; } }else if(empty($f->WorkOrder) && $f->trashed()){ $c4++; }else if($f->type_service == "Rectification"){ $c5++; } } return view('v3.main-dashboard.form.activated_form_business', compact('user','site','company','coverage','c1','c2','c3','c3_r','c3_b','c4','c5')); } /*** /* Rejected Form **/ public function rejectedForm(){ $id = Auth::guard('main')->id(); $user = Staff::with('StaffDetail')->find($id); $site = SiteSetting::first(); $company = Company::where('team','Dealer')->get(); $coverage = Coverage::where('Type','R')->orderBy('building_name')->get(); $c1 = 0; $c2 = 0; $c3 = 0; $c3_r = 0; $c3_b = 0;$c4 = 0; $c5 = 0; $form = Form::with('Subscriber','PackageDetail','WorkOrder')->orderBy('created_at', 'desc')->withTrashed()->get(); foreach ($form as $key => $f) { if(empty($f->WorkOrder) && $f->type_service != "Rectification" && !$f->trashed()){ $c1++; }else if(!empty($f->WorkOrder) && $f->type_service != "Rectification"){ if($f->WorkOrder->status == 'Completed') { $c3++; if($f->type_application == 'R'){ $c3_r++; }else if($f->type_application == 'B'){ $c3_b++; } }else{ $c2++; } }else if(empty($f->WorkOrder) && $f->trashed()){ $c4++; }else if($f->type_service == "Rectification"){ $c5++; } } return view('v3.main-dashboard.form.rejected_form', compact('user','site','company','coverage','c1','c2','c3','c3_r','c3_b','c4','c5')); } /* Dealer Form List **/ public function dealerFormList(){ $id = Auth::guard('main')->id(); $user = Staff::with('StaffDetail')->find($id); $site = SiteSetting::first(); $company = Company::where('team','Dealer')->get(); $coverage = Coverage::where('Type','R')->orderBy('building_name')->get(); $c1 = 0; $c2 = 0; $c3 = 0; $c3_r = 0; $c3_b = 0;$c4 = 0; $c5 = 0; $form = Form::with('Subscriber','PackageDetail','WorkOrder')->orderBy('created_at', 'desc')->withTrashed()->get(); foreach ($form as $key => $f) { if(empty($f->WorkOrder) && $f->type_service != "Rectification" && !$f->trashed()){ $c1++; }else if(!empty($f->WorkOrder) && $f->type_service != "Rectification"){ if($f->WorkOrder->status == 'Completed') { $c3++; if($f->type_application == 'R'){ $c3_r++; }else if($f->type_application == 'B'){ $c3_b++; } }else{ $c2++; } }else if(empty($f->WorkOrder) && $f->trashed()){ $c4++; }else if($f->type_service == "Rectification"){ $c5++; } } return view('v3.main-dashboard.form.view_dealer_form', compact('user','site','company','coverage','c1','c2','c3','c3_r','c3_b','c4','c5')); } /*** /* Form Details **/ public function viewFormDetail($subscriber){ $id = Auth::guard('main')->id(); $user = Staff::with('StaffDetail')->find($id); $site = SiteSetting::first(); $subsc = Subscriber::where('subscriber_id',$subscriber)->first(); $form = Form::with('Subscriber','PackageDetail')->where('_id',$subsc->_id)->first(); if($form->type_application == 'R'){ $coverage = Coverage::where('Type','R')->get(); if(empty($coverage)){ $coverage = 'null'; } }else if($form->type_application == 'B'){ $coverage = Coverage::where('Type','B')->get(); if(empty($coverage)){ $coverage = 'null'; } } if(isset($form->company_id)){ $company = Company::where('_id', $form->company_id)->first(); $company = $company->name; $agent = Staff::with('StaffDetail')->where('_id', $form->dealer_id)->first(); $agent = $agent->StaffDetail->name; }else{ $company = 'null'; $agent = 'null'; } return view('v3.main-dashboard.view_customer_detail', compact('user','site','form','company','agent','coverage')); } public function updateFormDetail(Request $request){ $id = Auth::guard('main')->id(); $user = Staff::with('StaffDetail')->find($id); $subscriber = Subscriber::with('Form')->where('subscriber_id',$request->subscriber_id)->first(); if(!empty($subscriber)){ if($subscriber->Form->type_application == 'R'){ if($request->street != null){ $street = $request->street; } $cov = Coverage::where('building_name',$request->building)->where('Type','R')->first(); $subscriber->name = $request->name; $subscriber->ic = $request->ic; $subscriber->email = $request->email; $subscriber->phone1 = $request->phone1; $subscriber->phone2 = $request->phone2; $subscriber->unit_no = $request->unit_no; $subscriber->building_name = $cov->building_name; $subscriber->street = $request->street; $subscriber->city = $cov->city; $subscriber->postcode = $cov->postcode; $subscriber->state = $cov->state; $subscriber->save(); return redirect()->back()->with('success_msg', 'Success! Update customer '.$request->get('name')); }else if($subscriber->Form->type_application == 'B'){ if($request->company_fax != null){ $fax = $request->company_fax; } $cov = Coverage::where('building_name',$request->building)->where('Type','B')->first(); if(empty($cov)){ } $subscriber->company_reg = $request->company_reg; $subscriber->company_num = $request->company_num; $subscriber->company_fax = $fax; $subscriber->company_name = $request->company_name; $subscriber->unit_no = $request->unit_no; $subscriber->street = $request->address; $subscriber->city = $request->city; $subscriber->postcode = $request->postcode; $subscriber->state = $request->state; $subscriber->name = $request->name; $subscriber->ic = $request->ic; $subscriber->designation = $request->designation; $subscriber->email = $request->email; $subscriber->phone1 = $request->phone1; $subscriber->phone2 = $request->phone2; $subscriber->save(); return redirect()->back()->with('success_msg', 'Success! Update customer '.$request->get('name')); } } } }