Example #1
0
 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index()
 {
     if (!Auth::user()->can(allPermissionTypeString('issue.report'))) {
         return view('errors/404');
     }
     return view('site/site-issue/list');
 }
Example #2
0
 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index()
 {
     // Check authorisation and throw 404 if not
     if (!Auth::user()->can(allPermissionTypeString('wms'))) {
         return view('errors/404');
     }
     return view('safety.doc.wms.list');
 }
 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index()
 {
     // Check authorisation and throw 404 if not
     if (!Auth::user()->can(allPermissionTypeString('accident.report'))) {
         return view('errors/404');
     }
     return view('site/accident/list');
 }
Example #4
0
 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index()
 {
     // Check authorisation and throw 404 if not
     if (!Auth::user()->can(allPermissionTypeString('sds'))) {
         return view('errors/404');
     }
     $cats = SafetyDocCategory::where('type', 'SDS')->where('status', '1')->get();
     $categories = [];
     foreach ($cats as $cat) {
         $categories[$cat->id] = $cat->name;
     }
     asort($categories);
     $categories = [' ' => 'All'] + $categories;
     return view('safety.doc.sds.list', compact('categories'));
 }
Example #5
0
 /**
  * Display a listing of the resource.
  */
 public function index(Request $request)
 {
     if ($request->ajax()) {
         $trades = Trade::select(['id', 'name', 'company_id', 'status'])->where('company_id', '=', Auth::user()->company_id)->get();
         foreach ($trades as $trade) {
             $trade['open'] = false;
         }
         return $trades;
     }
     // Check authorisation and throw 404 if not
     if (!Auth::user()->can(allPermissionTypeString('trade'))) {
         return view('errors/404');
     }
     $trades = Trade::select(['id', 'name'])->where('company_id', '=', Auth::user()->company_id)->where('trades.status', '=', '1');
     return view('trade.list', compact('trades'));
 }
Example #6
0
 /**
  * Get Users current user is authorised to manage + Process datatables ajax request.
  *
  * @return \Illuminate\Http\JsonResponse
  */
 public function getUsers(Request $request)
 {
     $user_list = [Auth::user()->id];
     if (Auth::user()->can(allPermissionTypeString('user'))) {
         $user_list = Auth::user()->company->userList($request->get('status'))->pluck('id')->toArray();
     }
     $user_records = User::select(['users.id', 'users.username', 'users.firstname', 'users.lastname', DB::raw('CONCAT(users.firstname, " ", users.lastname) AS full_name'), 'companys.name', 'companys.slug', 'users.address', 'users.last_login', 'users.status'])->join('companys', 'users.company_id', '=', 'companys.id')->whereIn('users.id', $user_list);
     $dt = Datatables::of($user_records)->filterColumn('full_name', 'whereRaw', "CONCAT(users.firstname,' ',users.lastname) like ?", ["%\$1%"])->editColumn('id', '<div class="text-center"><a href="/user/{{$username}}"><i class="fa fa-search"></i></a></div>')->editColumn('full_name', function ($user) {
         if ($user->is('leading.hand')) {
             return $user->firstname . ' ' . $user->lastname . ' <span class="badge badge-info badge-roundless">LH</span>';
         }
         if ($user->is('contractor.admin')) {
             return $user->firstname . ' ' . $user->lastname . ' <span class="badge badge-warning badge-roundless">CA</span>';
         }
         return $user->firstname . ' ' . $user->lastname;
     })->editColumn('name', '<a href="company/{{$slug}}">{{$name}}</a>')->editColumn('last_login', function ($user) {
         return $user->last_login != '-0001-11-30 00:00:00' ? with(new Carbon($user->last_login))->format('d/m/Y') : 'never';
     })->removeColumn('slug')->addColumn('action', function ($user) {
         if (Auth::user()->can('edit.user')) {
             //if (Auth::user()->allowedTo('edit', 'user', $user))
             return '<a href="/user/' . $user->username . '/settings" class="btn blue btn-xs btn-outline sbold uppercase margin-bottom"><i class="fa fa-pencil"></i> Edit</a>';
         }
     })->make(true);
     //var_dump($dt);
     return $dt;
 }
Example #7
0
 /**
  * Get Companies current user is authorised to manage + Process datatables ajax request.
  */
 public function getCompanies(Request $request)
 {
     $companies = [];
     if (Auth::user()->company->subscription && Auth::user()->can(allPermissionTypeString('company'))) {
         $companies = Auth::user()->company->companyList($request->get('status'));
     }
     $dt = Datatables::of($companies)->editColumn('slug', '<div class="text-center"><a href="/company/{{$slug}}"><i class="fa fa-search"></i></a></div>')->editColumn('name', function ($company) {
         return $company->transient ? $company->name . ' &nbsp; <span class="label label-sm label-info">' . $company->supervisedBySeparatedByComma() . '</span>' : $company->name;
     })->addColumn('trade', function ($company) {
         return $company->tradesSkilledInSeparatedByComma();
     })->addColumn('manager', function ($company) {
         return $company->securityBySeparatedByComma();
     })->editColumn('transient', function ($company) {
         return $company->transient ? 'Yes' : 'No';
     })->addColumn('action', function ($company) {
         if (Auth::user()->can('edit.company')) {
             return '<a href="/company/' . $company->slug . '/settings" class="btn blue btn-xs btn-outline sbold uppercase margin-bottom"><i class="fa fa-pencil"></i> Edit</a>';
         }
     })->make(true);
     return $dt;
 }
 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index(Request $request)
 {
     if ($request->ajax()) {
         $site_list = [];
         // Allow Supervisor only to view their sites
         if (Auth::user()->is('supervisor')) {
             $site_list = Auth::user()->supervisorSiteList()->pluck('id')->toArray();
         } else {
             if (Auth::user()->is('full.access|full.read.access|general.admin|whs.admin|construction.manager')) {
                 $site_list = Auth::user()->company->siteList()->pluck('id')->toArray();
             }
         }
         $compliance_recs = SiteCompliance::whereIn('site_id', $site_list)->get();
         $compliance = [];
         $sites = [];
         $users = [];
         foreach ($compliance_recs as $comply) {
             $array = [];
             $array['id'] = $comply->id;
             // Site Info - Array of unique sites (stores previous sites to speed up)
             if (isset($sites[$comply->site_id])) {
                 $site = $sites[$comply->site_id];
                 $supers = $site->supers;
             } else {
                 $site = Site::find($comply->site_id);
                 $sites[$comply->site_id] = (object) ['id' => $site->id, 'name' => $site->name, 'supers' => $site->supervisorsSeparatedByComma()];
                 $supers = $site->supervisorsSeparatedByComma();
             }
             $array['site_id'] = $site->id;
             $array['site_name'] = $site->name;
             $array['site_supers'] = $supers;
             // User Info - Array of unique users (store previous users to speed up)
             if (isset($users[$comply->user_id])) {
                 $user = $users[$comply->user_id];
                 $company_name = $user->company_name;
             } else {
                 $user = User::find($comply->user_id);
                 $users[$comply->user_id] = (object) ['id' => $user->id, 'full_name' => $user->full_name, 'company_name' => $user->company->name];
                 $company_name = $user->company->name;
             }
             $array['user_id'] = $user->id;
             $array['user_name'] = $user->full_name;
             $array['user_company'] = $company_name;
             //$array['reason_name'] = $comply->name;
             $reason = $comply->reason;
             if ($comply->reason == null) {
                 $reason = '';
             }
             $array['reason'] = $reason;
             $array['date'] = $comply->date->format('Y-m-d');
             $array['resolved_date'] = $comply->resolved_date->format('Y-m-d');
             $array['status'] = $comply->status;
             $array['notes'] = $comply->notes;
             $compliance[] = $array;
         }
         // Reasons array in specific Vuejs 'select' format.
         $reason_recs = SiteComplianceReason::where('status', '1')->where('company_id', Auth::user()->company->id)->orderBy('name')->get();
         $reasons = [];
         $reasons[] = ['value' => '', 'text' => 'Unassigned Reason'];
         foreach ($reason_recs as $reason) {
             $reasons[] = ['value' => $reason->id, 'text' => $reason->name, 'name' => $reason->name];
         }
         $json = [];
         $json[] = $compliance;
         $json[] = $reasons;
         return $json;
     }
     // Check authorisation and throw 404 if not
     if (!Auth::user()->can(allPermissionTypeString('compliance'))) {
         return view('errors/404');
     }
     return view('site/compliance/list');
 }