Beispiel #1
0
 public function enviar(Request $request)
 {
     if (Auth::guest()) {
         return view('login');
     } else {
         if (isset($_GET['aplicar'])) {
             //$tipo = Request::input('destinatarios');
             if ($request['destinatarios'] == 0) {
                 //seleccionamos lista de stakeholders
                 $dest = \Ermtool\Stakeholder::select('id', DB::raw('CONCAT(name, " ", surnames) AS full_name'))->orderBy('name')->lists('full_name', 'id');
             } else {
                 if ($request['destinatarios'] == 1) {
                     $dest = \Ermtool\Organization::lists('name', 'id');
                 } else {
                     if ($request['destinatarios'] == 2) {
                         $dest = \Ermtool\Role::lists('name', 'id');
                     }
                 }
             }
             $encuesta = \Ermtool\Poll::find($request['encuesta']);
             //obtenemos preguntas
             $preguntas = DB::table('questions')->where('poll_id', '=', $encuesta['id'])->get();
             $answers = array();
             //almacenaremos aquí respuestas posibles para las preguntas
             $i = 0;
             //contador de respuestas
             foreach ($preguntas as $pregunta) {
                 if ($pregunta->answers_type != 0) {
                     $posible_answers = DB::table('posible_answers')->where('question_id', $pregunta->id)->get();
                     foreach ($posible_answers as $posible_answer) {
                         $answers[$i] = array('id' => $posible_answer->id, 'respuesta' => $posible_answer->answer, 'question_id' => $posible_answer->question_id);
                         $i += 1;
                     }
                 }
             }
             if (Session::get('languaje') == 'en') {
                 return view('en.identificacion_eventos_riesgos.enviarencuesta2', ['tipo' => $request['destinatarios'], 'dest' => $dest, 'encuesta' => $encuesta, 'preguntas' => $preguntas, 'respuestas' => $answers, 'mensaje' => $this->mensaje($encuesta['id'])]);
             } else {
                 return view('identificacion_eventos_riesgos.enviarencuesta2', ['tipo' => $request['destinatarios'], 'dest' => $dest, 'encuesta' => $encuesta, 'preguntas' => $preguntas, 'respuestas' => $answers, 'mensaje' => $this->mensaje($encuesta['id'])]);
             }
         } else {
             if (isset($_GET['volver'])) {
                 $polls = \Ermtool\Poll::lists('name', 'id');
                 if (Session::get('languaje') == 'en') {
                     return view('en.identificacion_eventos_riesgos.enviarencuesta', ['polls' => $polls]);
                 } else {
                     return view('identificacion_eventos_riesgos.enviarencuesta', ['polls' => $polls]);
                 }
             } else {
                 $polls = \Ermtool\Poll::lists('name', 'id');
                 if (Session::get('languaje') == 'en') {
                     return view('en.identificacion_eventos_riesgos.enviarencuesta', ['polls' => $polls]);
                 } else {
                     return view('identificacion_eventos_riesgos.enviarencuesta', ['polls' => $polls]);
                 }
             }
         }
     }
 }
Beispiel #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 {
         $types_selected = array();
         $orgs_selected = array();
         $stakeholder = \Ermtool\Stakeholder::find($id);
         $organizations = \Ermtool\Organization::where('status', 0)->lists('name', 'id');
         $roles = \Ermtool\Role::all()->lists('name', 'id');
         $dv = ['0' => '0', '1' => '1', '2' => '2', '3' => '3', '4' => '4', '5' => '5', '6' => '6', '7' => '7', '8' => '8', '9' => '9', 'k' => 'k'];
         //buscamos el o los tipos del stakeholder
         $types = DB::table('role_stakeholder')->where('stakeholder_id', '=', $stakeholder->id)->select('role_id')->get();
         $i = 0;
         foreach ($types as $type) {
             $types_selected[$i] = $type->role_id;
             $i += 1;
         }
         //buscamos organizaciones del stakeholder
         $orgs = DB::table('organization_stakeholder')->where('stakeholder_id', '=', $stakeholder->id)->select('organization_id')->get();
         $i = 0;
         foreach ($orgs as $org) {
             $orgs_selected[$i] = $org->organization_id;
             $i += 1;
         }
         //si es edit, campo rut estara bloqueado y no habrá required
         $disabled = 'disabled';
         if (Session::get('languaje') == 'en') {
             return view('en.datos_maestros.stakeholders.edit', ['stakeholder' => $stakeholder, 'organizations' => $organizations, 'disabled' => $disabled, 'required' => '', 'roles' => $roles, 'dv' => $dv, 'types_selected' => $types_selected, 'orgs_selected' => $orgs_selected]);
         } else {
             return view('datos_maestros.stakeholders.edit', ['stakeholder' => $stakeholder, 'organizations' => $organizations, 'disabled' => $disabled, 'required' => '', 'roles' => $roles, 'dv' => $dv, 'types_selected' => $types_selected, 'orgs_selected' => $orgs_selected]);
         }
     }
 }
Beispiel #3
0
 public function desbloquear($id)
 {
     if (Auth::guest()) {
         return view('login');
     } else {
         $role = \Ermtool\Role::find($id);
         $role->status = 0;
         $role->save();
         if (Session::get('languaje') == 'en') {
             Session::flash('message', 'Role successfully unblocked');
         } else {
             Session::flash('message', 'Rol desbloqueado correctamente');
         }
         return Redirect::to('/roles');
     }
 }