public function getPosition($placa) { $vehicle = Vehicle::where('plate', $placa)->first(); $position = $vehicle->Positions()->orderBy('memory_index', 'desc')->first(); $retorno = array('latitude' => $position->latitude, 'longitude' => $position->longitude, 'speed' => $position->speed, 'ignition' => $position->ignition); echo json_encode($retorno); }
public function audit($id) { $vehicle = Vehicle::findOrFail($id); $logs = $vehicle->logs; $audit = array(); $labels = array('plate' => 'Placa', 'brand' => 'Marca', 'model' => 'Modelo', 'year' => 'Ano', 'color' => 'Cor', 'active' => 'Ativo', 'account_id' => 'Cliente'); if ($logs) { foreach ($logs as $log) { foreach ($log->new_value as $key => $value) { switch ($key) { case 'active': $audit[] = array('label' => $labels[$key], 'old' => testVal($log->old_value, $key) ? "Ativo" : "Inativo", 'new' => testVal($log->new_value, $key) ? "Ativo" : "Inativo", 'user' => $log->user->username, 'date' => date('d/m/Y H:i:s', strtotime($log->updated_at))); break; default: $audit[] = array('label' => $labels[$key], 'old' => testVal($log->old_value, $key) ? $log->old_value[$key] : '', 'new' => testVal($log->new_value, $key) ? $log->new_value[$key] : '', 'user' => $log->user->username, 'date' => date('d/m/Y H:i:s', strtotime($log->updated_at))); break; } } } } $grid = \DataGrid::source($audit); $grid->attributes(array("class" => "table table-striped .table-condensed")); $grid->add('label', 'Campo'); $grid->add('old', 'Valor Anterior'); $grid->add('new', 'Novo Valor'); $grid->add('user', 'Alterado por'); $grid->add('date', 'Data/Hora da Alteração'); $grid->paginate(10); return view('layouts.audit', compact('grid')); }
public function showLast($id, Request $request) { $pag = $request->input('pag'); // dd($request); $new = array('dataini' => $request->input('dataini'), 'datafin' => $request->input('datafin'), 'search' => $request->input('search'), 'page' => $request->input('page')); $request->replace($new); $vehicle = Vehicle::find($id); $now = new Carbon(); $now->subDays(5); if ($request->input('search')) { $filter = \DataFilter::source($vehicle->Positions()); } else { $filter = \DataFilter::source($vehicle->Positions()->limit(10)); } // $filter = \DataFilter::source($vehicle->Positions()); $filter->add('dataini', 'Data Inicial', 'datetime')->format('d/m/Y H:i:s')->scope(function ($query, $value) { $test = (bool) strtotime($value); if ($test) { return $query->whereRaw("date >= ?", array($value)); } else { return $query; } }); $filter->add('datafin', 'Data Final', 'datetime')->format('d/m/Y H:i:s')->scope(function ($query, $value) { $test = (bool) strtotime($value); if ($test) { return $query->whereRaw("date <= ?", array($value)); } else { return $query; } }); $filter->submit('Buscar'); $filter->reset('Limpar'); $filter->add('pag', '', 'select')->options(array('' => 'Itens por Página', 10 => '10', 20 => '20', 30 => '30', 40 => '40', 50 => '50', 100 => '100', 200 => '200', 500 => '500', 1000 => '1000')); $grid = \DataGrid::source($filter); $grid->attributes(array("class" => "table table-striped")); $grid->add('<input type="checkbox" name="ids[]" value="{{ $id }}" onclick="checkSelected()">', '<input type="checkbox" name="todos" id="todos" onclick="selectTodos()">'); $grid->add('date|strtotime|date[d/m/Y H:i:s]', 'Data', true); $grid->add('<span id="{{$id}}" class="address" geo-lat="{{ $latitude }}" geo-lng="{{ $longitude }}"></span>', 'Endereço'); $grid->add('<i class="fa fa-lg fa-circle {{ $ignition == 1 ? \'on\' : \'off\' }}">', 'Ignição'); $grid->add('speed', 'Velocidade'); $grid->add('<a class="btn btn-success btn-xs" title="Ver no Mapa" href="/positions/showMap/{{$id}}"><i class="fa fa-lg fa-map-marker"></i></a><a class="btn btn-danger btn-xs" title="Informações" href="/positions/showInfo/{{$id}}"><i class="fa fa-lg fa-info"></i></a><button type="button" class="btn btn-info btn-xs" title="Buscar Endereço" onclick="searchAddr(\'{{$id}}\')"><i class="fa fa-lg fa-search"></i></button>', 'Ações', true); $grid->orderBy('memory_index', 'desc'); if ($pag) { $grid->paginate($pag); } return view('positions::last', compact('filter', 'grid', 'vehicle')); }
public function audit($id) { $device = Device::findOrFail($id); $logs = $device->logs; //dd($logs); $audit = array(); $labels = array('name' => 'Identificação', 'serial' => 'Número de Série', 'model' => 'Modelo', 'company_id' => 'Empresa', 'vehicle_id' => 'Veículo', 'description' => 'Observações'); if ($logs) { foreach ($logs as $log) { foreach ($log->new_value as $key => $value) { switch ($key) { case 'model': $audit[] = array('label' => $labels[$key], 'old' => testVal($log->old_value, $key) ? fieldValue("devices", $log->old_value[$key]) : '[novo]', 'new' => fieldValue("devices", $value), 'user' => $log->user->username, 'date' => date('d/m/Y H:i:s', strtotime($log->updated_at))); break; case 'vehicle_id': $audit[] = array('label' => $labels[$key], 'old' => testVal($log->old_value, $key) ? Vehicle::find($log->old_value[$key])->plate : '[não associado]', 'new' => testVal($log->new_value, $key) ? Vehicle::find($log->new_value[$key])->plate : '[não associado]', 'user' => $log->user->username, 'date' => date('d/m/Y H:i:s', strtotime($log->updated_at))); break; case 'company_id': $audit[] = array('label' => $labels[$key], 'old' => testVal($log->old_value, $key) ? Company::find($log->old_value[$key])->name : '[não associado]', 'new' => testVal($log->new_value, $key) ? Company::find($log->new_value[$key])->name : '[não associado]', 'user' => $log->user->username, 'date' => date('d/m/Y H:i:s', strtotime($log->updated_at))); break; default: $audit[] = array('label' => $labels[$key], 'old' => testVal($log->old_value, $key) ? $log->old_value[$key] : '', 'new' => testVal($log->new_value, $key) ? $log->new_value[$key] : '', 'user' => $log->user->username, 'date' => date('d/m/Y H:i:s', strtotime($log->updated_at))); break; } } } } $grid = \DataGrid::source($audit); $grid->attributes(array("class" => "table table-striped .table-condensed")); $grid->add('label', 'Campo'); $grid->add('old', 'Valor Anterior'); $grid->add('new', 'Novo Valor'); $grid->add('user', 'Usuário'); $grid->add('date', 'Data/Hora'); $grid->orderBy('date', 'DESC'); $grid->paginate(10); return view('layouts.audit', compact('grid')); }
public function getAutocomplete() { return Vehicle::where("plate", "like", strtoupper(\Input::get("q")) . "%")->whereHas('Account', function ($query) { $query->where('company_id', Auth::user()->company_id); })->take(10)->select(\DB::raw('plate, id'))->get(); }