public function search_programaciones() { if (!Request::ajax() || !Auth::check()) { return Response::json(array('success' => false), 200); } $id = Auth::id(); $data["inside_url"] = Config::get('app.inside_url'); $data["user"] = Session::get('user'); if ($data["user"]->idrol == 1 || $data["user"]->idrol == 2 || $data["user"]->idrol == 3 || $data["user"]->idrol == 4 || $data["user"]->idrol == 5 || $data["user"]->idrol == 6 || $data["user"]->idrol == 7 || $data["user"]->idrol == 8 || $data["user"]->idrol == 9 || $data["user"]->idrol == 10 || $data["user"]->idrol == 11 || $data["user"]->idrol == 12) { // Check if the current user is the "System Admin" $fecha_ini = date("Y-m-d", strtotime("first day of january")); $fecha_fin = date("Y-m-d", strtotime('last day of december')); $array_ot = null; $array_ot = OrdenesTrabajoInspeccionEquipo::getOtXPeriodo(9, $fecha_ini, $fecha_fin)->orderBy('fecha_inicio', 'desc')->get()->toArray(); $programaciones = []; $horas = []; $estados = []; $length = sizeof($array_ot); for ($i = 0; $i < $length; $i++) { $programaciones[] = date("Y-m-d", strtotime($array_ot[$i]['fecha_inicio'])); $hora = date("H:i", strtotime($array_ot[$i]['fecha_inicio'])); $idestado = $array_ot[$i]['idestado']; $estado = Estado::getEstadoById($idestado)->get(); $estado = $estado[0]; array_push($horas, $hora); array_push($estados, $estado); } return Response::json(array('success' => true, 'programaciones' => $programaciones, 'horas' => $horas, 'estados' => $estados, 'ots' => $array_ot), 200); } else { return Response::json(array('success' => false), 200); } }