| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376 |
- <?php
-
- namespace App\Http\Controllers\v3\Main;
-
- use Illuminate\Http\Request;
- use App\Http\Controllers\Controller;
- use Illuminate\Support\Facades\Auth;
-
- use Carbon\Carbon;
-
- use App\SiteSetting;
- use App\LatestModel\Staff;
- use App\LatestModel\StaffDetail;
- use App\LatestModel\Module\Form;
- use App\LatestModel\Module\Subscriber;
- use App\LatestModel\Module\WorkOrder;
- use App\LatestModel\Module\PackageDetail;
- use App\LatestModel\Module\Company;
- use App\LatestModel\Module\Coverage;
- use App\LatestModel\Module\Product;
- use App\LatestModel\Module\Docket;
-
- class ApplicationController extends Controller
- {
- /***
- /* Application Form
- **/
- public function applicationForm(){
-
- $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) && !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'));
- }
- }
- }
- }
|