Ejemplo n.º 1
0
 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index()
 {
     if (Auth::guest()) {
         return view('login');
     } else {
         $causas = array();
         if (isset($_GET['verbloqueados'])) {
             $causas2 = \Ermtool\Cause::where('status', 1)->get();
             //select causas bloqueadas
         } else {
             $causas2 = \Ermtool\Cause::where('status', 0)->get();
             //select causas desbloqueadas
         }
         $i = 0;
         // ---recorremos todas las causas para asignar formato de datos correspondientes--- //
         foreach ($causas2 as $causa) {
             //damos formato a fecha de creación
             if ($causa['created_at'] != NULL) {
                 $fecha_creacion = date_format($causa['created_at'], "d-m-Y");
             } else {
                 $fecha_creacion = NULL;
             }
             //damos formato a fecha de actualización
             if ($causa['updated_at'] != NULL) {
                 $fecha_act = date_format($causa['updated_at'], "d-m-Y");
             } else {
                 $fecha_act = NULL;
             }
             $causas[$i] = array('id' => $causa['id'], 'nombre' => $causa['name'], 'descripcion' => $causa['description'], 'fecha_creacion' => $fecha_creacion, 'fecha_act' => $fecha_act, 'estado' => $causa['status']);
             $i += 1;
         }
         if (Session::get('languaje') == 'en') {
             return view('en.datos_maestros.causas.index', ['causas' => $causas]);
         } else {
             return view('datos_maestros.causas.index', ['causas' => $causas]);
         }
     }
 }
Ejemplo n.º 2
0
 /**
  * Show the form for editing the specified resource.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function edit($id)
 {
     if (Auth::guest()) {
         return view('login');
     } else {
         //obtenemos riesgo
         $risk = \Ermtool\Risk::find($id);
         if ($risk->type == 0) {
             $subprocesos = DB::table('subprocesses')->join('organization_subprocess', 'organization_subprocess.subprocess_id', '=', 'subprocesses.id')->where('organization_subprocess.organization_id', '=', $_GET['org'])->where('subprocesses.status', '=', 0)->lists('subprocesses.name', 'subprocesses.id');
             $sub_selected = array();
             $subs = DB::table('risk_subprocess')->where('risk_subprocess.risk_id', '=', $id)->select('risk_subprocess.subprocess_id')->get();
             $i = 0;
             foreach ($subs as $sub) {
                 $sub_selected[$i] = $sub->subprocess_id;
                 $i += 1;
             }
         } else {
             if ($risk->type == 1) {
                 $objectives = DB::table('objectives')->where('organization_id', '=', $_GET['org'])->where('status', '=', 0)->lists('name', 'id');
                 $obj_selected = array();
                 $orgs = DB::table('objective_risk')->where('objective_risk.risk_id', '=', $id)->select('objective_risk.objective_id')->get();
                 $i = 0;
                 foreach ($subs as $sub) {
                     $obj_selected[$i] = $obj->objective_id;
                     $i += 1;
                 }
             }
         }
         //categorias de riesgo
         $categorias = \Ermtool\Risk_category::where('status', 0)->lists('name', 'id');
         //causas
         $causas = \Ermtool\Cause::where('status', 0)->lists('name', 'id');
         //efectos
         $efectos = \Ermtool\Effect::where('status', 0)->lists('name', 'id');
         $causes_selected = array();
         $effects_selected = array();
         //obtenemos causas seleccionadas
         $causes = DB::table('cause_risk')->where('risk_id', '=', $id)->select('cause_risk.cause_id')->get();
         $i = 0;
         foreach ($causes as $cause) {
             $causes_selected[$i] = $cause->cause_id;
             $i += 1;
         }
         //obtenemos efectos seleccionados
         $effects = DB::table('effect_risk')->where('risk_id', '=', $id)->select('effect_risk.effect_id')->get();
         $i = 0;
         foreach ($effects as $effect) {
             $effects_selected[$i] = $effect->effect_id;
             $i += 1;
         }
         //riesgos tipo
         $riesgos_tipo = \Ermtool\Risk::where('status', 0)->where('type2', 0)->lists('name', 'id');
         //obtenemos lista de stakeholders
         $stakeholders = \Ermtool\Stakeholder::where('status', 0)->select('id', DB::raw('CONCAT(name, " ", surnames) AS full_name'))->orderBy('name')->lists('full_name', 'id');
         if (Session::get('languaje') == 'en') {
             if ($risk->type == 0) {
                 return view('en.riesgos.edit', ['risk' => $risk, 'riesgos_tipo' => $riesgos_tipo, 'causas' => $causas, 'categorias' => $categorias, 'efectos' => $efectos, 'stakeholders' => $stakeholders, 'causes_selected' => $causes_selected, 'effects_selected' => $effects_selected, 'subprocesos' => $subprocesos, 'sub_selected' => $sub_selected, 'org_id' => $_GET['org']]);
             } else {
                 return view('en.riesgos.edit', ['risk' => $risk, 'riesgos_tipo' => $riesgos_tipo, 'causas' => $causas, 'categorias' => $categorias, 'efectos' => $efectos, 'stakeholders' => $stakeholders, 'causes_selected' => $causes_selected, 'effects_selected' => $effects_selected, 'objetivos' => $objetivos, 'obj_selected' => $obj_selected, 'org_id' => $_GET['org']]);
             }
         } else {
             if ($risk->type == 0) {
                 return view('riesgos.edit', ['risk' => $risk, 'riesgos_tipo' => $riesgos_tipo, 'causas' => $causas, 'categorias' => $categorias, 'efectos' => $efectos, 'stakeholders' => $stakeholders, 'causes_selected' => $causes_selected, 'effects_selected' => $effects_selected, 'subprocesos' => $subprocesos, 'sub_selected' => $sub_selected, 'org_id' => $_GET['org']]);
             } else {
                 return view('riesgos.edit', ['risk' => $risk, 'riesgos_tipo' => $riesgos_tipo, 'causas' => $causas, 'categorias' => $categorias, 'efectos' => $efectos, 'stakeholders' => $stakeholders, 'causes_selected' => $causes_selected, 'effects_selected' => $effects_selected, 'objetivos' => $objetivos, 'obj_selected' => $obj_selected, 'org_id' => $_GET['org']]);
             }
         }
     }
 }
Ejemplo n.º 3
0
 /**
  * Show the form for editing the specified resource.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function edit($id)
 {
     if (Auth::guest()) {
         return view('login');
     } else {
         $riesgo = \Ermtool\Risk::find($id);
         $categorias = \Ermtool\Risk_category::where('status', 0)->lists('name', 'id');
         $causas = \Ermtool\Cause::where('status', 0)->lists('name', 'id');
         $efectos = \Ermtool\Effect::where('status', 0)->lists('name', 'id');
         $causes_selected = array();
         $effects_selected = array();
         //obtenemos causas seleccionadas
         $causes = DB::table('cause_risk')->where('risk_id', '=', $riesgo->id)->select('cause_risk.cause_id')->get();
         $i = 0;
         foreach ($causes as $cause) {
             $causes_selected[$i] = $cause->cause_id;
             $i += 1;
         }
         //obtenemos efectos seleccionados
         $effects = DB::table('effect_risk')->where('risk_id', '=', $riesgo->id)->select('effect_risk.effect_id')->get();
         $i = 0;
         foreach ($effects as $effect) {
             $effects_selected[$i] = $effect->effect_id;
             $i += 1;
         }
         if (Session::get('languaje') == 'en') {
             return view('en.datos_maestros.riesgos_tipo.edit', ['riesgo' => $riesgo, 'categorias' => $categorias, 'causas' => $causas, 'efectos' => $efectos, 'causes_selected' => $causes_selected, 'effects_selected' => $effects_selected]);
         } else {
             return view('datos_maestros.riesgos_tipo.edit', ['riesgo' => $riesgo, 'categorias' => $categorias, 'causas' => $causas, 'efectos' => $efectos, 'causes_selected' => $causes_selected, 'effects_selected' => $effects_selected]);
         }
     }
 }