public function desbloquear($id) { if (Auth::guest()) { return view('login'); } else { global $id1; $id1 = $id; DB::transaction(function () { $objective_category = \Ermtool\Objective_category::find($GLOBALS['id1']); $objective_category->status = 0; $objective_category->save(); if (Session::get('languaje') == 'en') { Session::flash('message', 'Category unblocked successfully'); } else { Session::flash('message', 'Categoría de objetivo desbloqueada correctamente'); } }); return Redirect::to('/categorias_objetivos'); } }
public function objetivosPlan($plan_id) { if (strpos($_SERVER['REQUEST_URI'], "verbloqueados")) { $objetivos = \Ermtool\Objective::where('strategic_plan_id', $plan_id)->where('status', 1)->get(); } else { $objetivos = \Ermtool\Objective::where('strategic_plan_id', $plan_id)->where('status', 0)->get(); } //seleccionamos todos los datos del plan para mostrarlo $datos_plan = \Ermtool\Strategic_plan::find($plan_id); $nombre_organizacion = \Ermtool\Organization::name($datos_plan->organization_id); $i = 0; //para saber si hay objetivos $objectives = array(); //almacenará los objetivos con el formato correcto de sus atributos foreach ($objetivos as $objetivo) { //damos formato a fecha expiración if ($objetivo['expiration_date'] == NULL or $objetivo['expiration_date'] == "0000-00-00") { $fecha_exp = NULL; } else { $expiration_date = new DateTime($objetivo['expiration_date']); $fecha_exp = date_format($expiration_date, 'd-m-Y'); } //damos formato a fecha creación if ($objetivo['created_at'] != NULL) { $fecha_creacion = date_format($objetivo['created_at'], "d-m-Y"); } else { $fecha_creacion = NULL; } //damos formato a fecha de actualización if ($objetivo['updated_at'] != NULL) { $fecha_act = date_format($objetivo['updated_at'], "d-m-Y"); } else { $fecha_act = NULL; } //damos formato a categoría de objetivo if ($objetivo['objective_category_id'] == NULL) { $categoria = NULL; } else { $categoria = \Ermtool\Objective_category::where('id', $objetivo['objective_category_id'])->value('name'); } if ($objetivo['perspective'] == NULL) { $perspective = NULL; } else { $perspective = $objetivo['perspective']; } $objectives[$i] = array('id' => $objetivo['id'], 'nombre' => $objetivo['name'], 'descripcion' => $objetivo['description'], 'fecha_creacion' => $fecha_creacion, 'fecha_act' => $fecha_act, 'fecha_exp' => $fecha_exp, 'categoria' => $categoria, 'estado' => $objetivo['status'], 'perspective' => $perspective); $i += 1; } if (Session::get('languaje') == 'en') { return view('en.datos_maestros.objetivos.index', ['objetivos' => $objectives, 'nombre_organizacion' => $nombre_organizacion, 'datos_plan' => $datos_plan, 'probador' => $i, 'strategic_plan_id' => $plan_id]); } else { return view('datos_maestros.objetivos.index', ['objetivos' => $objectives, 'nombre_organizacion' => $nombre_organizacion, 'datos_plan' => $datos_plan, 'probador' => $i, 'strategic_plan_id' => $plan_id]); } }