public function getMantenimientos() { if (Request::ajax()) { $fecha_inicio = date('Y-m-d', Input::get('from') / 1000); $fecha_fin = date('Y-m-d', Input::get('to') / 1000); $out = array(); foreach (Mantenimiento::whereBetween('fecha_realizacion', array($fecha_inicio, $fecha_fin))->get() as $mantenimientos) { $activo = Activo::where('id', $mantenimientos->id_activo)->first(); $out[] = array('id' => $mantenimientos->id, 'title' => $activo->num_activo . ' - ' . utf8_encode($activo->nombre) . ' (Mantenimiento Realizado)', 'url' => route('datos.mantenimientos.edit', $mantenimientos->id), 'class' => 'event-success', 'start' => strtotime($mantenimientos->fecha_realizacion) * 1000 + 42799000, 'end' => strtotime($mantenimientos->fecha_realizacion) * 1000 + 42799000); } foreach (Activo::all() as $activos) { $mantenimientos = Mantenimiento::where('id_activo', $activos->id)->orderBy('created_at', 'desc')->first(); if (!empty($mantenimientos)) { $out[] = array('id' => $mantenimientos->id . 'c', 'title' => $activos->num_activo . ' - ' . utf8_encode($activos->nombre) . ' (Prox. Mantenimiento)', 'url' => route('datos.mantenimientos.show', $activos->id), 'class' => 'event-important', 'start' => strtotime($mantenimientos->proximo_mant) * 1000 + 42799000, 'end' => strtotime($mantenimientos->proximo_mant) * 1000 + 42799000); } } return Response::json(array('success' => 1, 'result' => $out)); } else { App::abort(403); } }
public function getGrafmayorcosto() { JpGraph::module('bar'); $graph = new Graph(680, 300); $graph->SetScale("textlin"); $graph->yscale->SetGrace(5); $graph->SetBox(true); $labels = array(); $valores = array(); foreach (Activo::where('id', '>', '0')->orderBy('costo', 'desc')->take(10)->get() as $activo) { $labels[] = $activo->num_activo; $valores[] = $activo->costo; } //titulo de la grafica $graph->title->SetColor('black'); $graph->title->Set('Gráfica: Activos con Mayor Costo'); //valores de los labels en ambas axis y como se ubicaran $graph->xaxis->SetTickLabels($labels); $graph->xaxis->SetLabelAlign('center', 'top', 'center'); $graph->ygrid->SetFill(false); $graph->yaxis->HideLabels(false); $graph->yaxis->HideTicks(false, false); //Fonts para las axis $graph->xaxis->SetColor('black'); $graph->yaxis->SetColor('black'); //grafica de activos con mayor costo $mayorCosto = new BarPlot($valores); $mayorCosto->SetColor('white'); $mayorCosto->SetWidth(0.6); //agrega la grafica generada a la instancia de la grafica $graph->Add($mayorCosto); //Despliega la grafica $graph->Stroke(); }