/** * 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']]); } } } }
public function getTests($kind, $id) { $i = 0; //contador de pruebas $audit_plan = \Ermtool\Audit_plan::where('id', $id)->value('name'); $pruebas_ejec = 0; //pruebas en ejecución $pruebas_abiertas = 0; //pruebas abiertas $pruebas_cerradas = 0; //pruebas cerradas $type = NULL; //identifica si es una prueba asociada a un riesgo, subproceso o control (1=Riesgo, 2=Subproceso, 3=Control) $audit_tests = array(); $tests = DB::table('audit_tests')->join('audit_audit_plan_audit_program', 'audit_audit_plan_audit_program.id', '=', 'audit_tests.audit_audit_plan_audit_program_id')->join('audit_programs', 'audit_programs.id', '=', 'audit_audit_plan_audit_program.audit_program_id')->join('audit_audit_plan', 'audit_audit_plan.id', '=', 'audit_audit_plan_audit_program.audit_audit_plan_id')->join('audits', 'audits.id', '=', 'audit_audit_plan.audit_id')->join('audit_plans', 'audit_plans.id', '=', 'audit_audit_plan.audit_plan_id')->where('audit_plans.id', '=', $id)->select('audit_plans.name AS audit_plan_name', 'audits.name AS audit_name', 'audit_programs.name as audit_program_name', 'audit_tests.description AS description', 'audit_tests.name AS name', 'audit_tests.type', 'audit_tests.status', 'audit_tests.results', 'audit_tests.hh', 'audit_tests.control_id', 'audit_tests.subprocess_id', 'audit_tests.risk_id', 'audit_tests.stakeholder_id')->get(); foreach ($tests as $test) { //sumamos a prueba ejec abierta o cerrada según el estado que posea if ($test->status == 0) { $pruebas_abiertas += 1; } else { if ($test->status == 1) { $pruebas_ejec += 1; } else { if ($test->status == 2) { $pruebas_cerradas += 1; } } } //obtenemos nombre de stakeholder $resp = \Ermtool\Stakeholder::find($test->stakeholder_id); $resp = $resp['name'] . ' ' . $resp['surnames']; //obtenemos nombre de riesgo, control o subproceso según corresponda if ($test->risk_id != NULL) { $relacionado = \Ermtool\Risk::where('id', $test->risk_id)->value('name'); $type = 1; } else { if ($test->subprocess_id != NULL) { $relacionado = \Ermtool\Subprocess::where('id', $test->subprocess_id)->value('name'); $type = 2; } else { if ($test->control_id != NULL) { $relacionado = \Ermtool\Control::where('id', $test->control_id)->value('name'); $type = 3; } } } if (strstr($_SERVER["REQUEST_URI"], 'genexcelgraficosdinamicos')) { if (Session::get('languaje') == 'en') { if ($kind == 1 && $test->status == 0) { //tipo if ($test->type == 0) { $test_type = 'Design test'; } else { if ($test->type == 1) { $test_type = 'Operationa effectiveness test'; } else { if ($test->type == 2) { $test_type = 'Compliance test'; } else { if ($test->type == 3) { $test_type = 'Sustantive tests'; } else { $test_type = 'Not defined'; } } } } //resultado if ($test->results == 0) { $results = 'Ineffective'; } else { if ($test->results == 1) { $results = 'Effective'; } else { if ($test->results == 2) { $results = 'In process'; } } } if ($type == 1) { $related = 'Risk: ' . $relacionado; } else { if ($type == 2) { $related = 'Subprocess: ' . $relacionado; } else { if ($type == 3) { $related = 'Control: ' . $relacionado; } } } $audit_tests[$i] = ['Audit plan' => $audit_plan, 'Audit' => $test->audit_name, 'Program' => $test->audit_program_name, 'Test' => $test->name, 'Description' => $test->description, 'Kind' => $test_type, 'Results' => $results, 'Hours-man' => $test->hh, 'Responsable' => $resp, 'Related object' => $related]; } else { if ($kind == 2 && $test->status == 1) { //tipo if ($test->type == 0) { $test_type = 'Design test'; } else { if ($test->type == 1) { $test_type = 'Operationa effectiveness test'; } else { if ($test->type == 2) { $test_type = 'Compliance test'; } else { if ($test->type == 3) { $test_type = 'Sustantive tests'; } else { $test_type = 'Not defined'; } } } } //resultado if ($test->results == 0) { $results = 'Ineffective'; } else { if ($test->results == 1) { $results = 'Effective'; } else { if ($test->results == 2) { $results = 'In process'; } } } if ($type == 1) { $related = 'Risk: ' . $relacionado; } else { if ($type == 2) { $related = 'Subprocess: ' . $relacionado; } else { if ($type == 3) { $related = 'Control: ' . $relacionado; } } } $audit_tests[$i] = ['Audit plan' => $audit_plan, 'Audit' => $test->audit_name, 'Program' => $test->audit_program_name, 'Test' => $test->name, 'Description' => $test->description, 'Kind' => $test_type, 'Results' => $results, 'Hours-man' => $test->hh, 'Responsable' => $resp, 'Related object' => $related]; } else { if ($kind == 3 && $test->status == 2) { //tipo if ($test->type == 0) { $test_type = 'Design test'; } else { if ($test->type == 1) { $test_type = 'Operationa effectiveness test'; } else { if ($test->type == 2) { $test_type = 'Compliance test'; } else { if ($test->type == 3) { $test_type = 'Sustantive tests'; } else { $test_type = 'Not defined'; } } } } //resultado if ($test->results == 0) { $results = 'Ineffective'; } else { if ($test->results == 1) { $results = 'Effective'; } else { if ($test->results == 2) { $results = 'In process'; } } } if ($type == 1) { $related = 'Risk: ' . $relacionado; } else { if ($type == 2) { $related = 'Subprocess: ' . $relacionado; } else { if ($type == 3) { $related = 'Control: ' . $relacionado; } } } $audit_tests[$i] = ['Audit plan' => $audit_plan, 'Audit' => $test->audit_name, 'Program' => $test->audit_program_name, 'Test' => $test->name, 'Description' => $test->description, 'Kind' => $test_type, 'Results' => $results, 'Hours-man' => $test->hh, 'Responsable' => $resp, 'Related object' => $related]; } } } } else { if ($kind == 1 && $test->status == 0) { //tipo if ($test->type == 0) { $test_type = 'Prueba de diseño'; } else { if ($test->type == 1) { $test_type = 'Prueba de efectividad operativa'; } else { if ($test->type == 2) { $test_type = 'Prueba de cumplimiento'; } else { if ($test->type == 3) { $test_type = 'Prueba sustantiva'; } else { $test_type = 'No definido'; } } } } //resultado if ($test->results == 0) { $results = 'Inefectiva'; } else { if ($test->results == 1) { $results = 'Efectiva'; } else { if ($test->results == 2) { $results = 'En proceso'; } } } if ($type == 1) { $related = 'Riesgo: ' . $relacionado; } else { if ($type == 2) { $related = 'Subproceso: ' . $relacionado; } else { if ($type == 3) { $related = 'Control: ' . $relacionado; } } } $audit_tests[$i] = ['Plan de auditoría' => $audit_plan, 'Auditoría' => $test->audit_name, 'Programa' => $test->audit_program_name, 'Prueba' => $test->name, 'Descripción' => $test->description, 'Tipo' => $test_type, 'Resultado' => $results, 'Horas-hombre' => $test->hh, 'Responsable' => $resp, 'Objeto relacionado' => $related]; } else { if ($kind == 2 && $test->status == 1) { //tipo if ($test->type == 0) { $test_type = 'Prueba de diseño'; } else { if ($test->type == 1) { $test_type = 'Prueba de efectividad operativa'; } else { if ($test->type == 2) { $test_type = 'Prueba de cumplimiento'; } else { if ($test->type == 3) { $test_type = 'Prueba sustantiva'; } else { $test_type = 'No definido'; } } } } //resultado if ($test->results == 0) { $results = 'Inefectiva'; } else { if ($test->results == 1) { $results = 'Efectiva'; } else { if ($test->results == 2) { $results = 'En proceso'; } } } if ($type == 1) { $related = 'Riesgo: ' . $relacionado; } else { if ($type == 2) { $related = 'Subproceso: ' . $relacionado; } else { if ($type == 3) { $related = 'Control: ' . $relacionado; } } } $audit_tests[$i] = ['Plan de auditoría' => $audit_plan, 'Auditoría' => $test->audit_name, 'Programa' => $test->audit_program_name, 'Prueba' => $test->name, 'Descripción' => $test->description, 'Tipo' => $test_type, 'Resultado' => $results, 'Horas-hombre' => $test->hh, 'Responsable' => $resp, 'Objeto relacionado' => $related]; } else { if ($kind == 3 && $test->status == 2) { //tipo if ($test->type == 0) { $test_type = 'Prueba de diseño'; } else { if ($test->type == 1) { $test_type = 'Prueba de efectividad operativa'; } else { if ($test->type == 2) { $test_type = 'Prueba de cumplimiento'; } else { if ($test->type == 3) { $test_type = 'Prueba sustantiva'; } else { $test_type = 'No definido'; } } } } //resultado if ($test->results == 0) { $results = 'Inefectiva'; } else { if ($test->results == 1) { $results = 'Efectiva'; } else { if ($test->results == 2) { $results = 'En proceso'; } } } if ($type == 1) { $related = 'Riesgo: ' . $relacionado; } else { if ($type == 2) { $related = 'Subproceso: ' . $relacionado; } else { if ($type == 3) { $related = 'Control: ' . $relacionado; } } } $audit_tests[$i] = ['Plan de auditoría' => $audit_plan, 'Auditoría' => $test->audit_name, 'Programa' => $test->audit_program_name, 'Prueba' => $test->name, 'Descripción' => $test->description, 'Tipo' => $test_type, 'Resultado' => $results, 'Horas-hombre' => $test->hh, 'Responsable' => $resp, 'Objeto relacionado' => $related]; } } } } } else { $audit_tests[$i] = ['audit_name' => $test->audit_name, 'audit_program_name' => $test->audit_program_name, 'name' => $test->name, 'description' => $test->description, 'type' => $test->type, 'status' => $test->status, 'results' => $test->results, 'hh' => $test->hh, 'stakeholder' => $resp, 'related' => $relacionado, 'related_type' => $type]; } $i += 1; } if (strstr($_SERVER["REQUEST_URI"], 'genexcelgraficos')) { return $audit_tests; } else { return json_encode(['audit_plan' => $audit_plan, 'audit_tests' => $audit_tests, 'pruebas_abiertas' => $pruebas_abiertas, 'pruebas_ejec' => $pruebas_ejec, 'pruebas_cerradas' => $pruebas_cerradas]); } }
/** * Display a listing of the resource. * * @return \Illuminate\Http\Response */ public function index() { if (Auth::guest()) { return view('login'); } else { $riesgostipo = array(); if (isset($_GET['verbloqueados'])) { $riesgostipo2 = \Ermtool\Risk::where('type2', 0)->where('status', 1)->get(); //select riesgos tipo bloqueados } else { $riesgostipo2 = \Ermtool\Risk::where('type2', 0)->where('status', 0)->get(); //select riesgos tipo desbloqueados } $i = 0; // ---recorremos todos los riesgos tipo para asignar formato de datos correspondientes--- // foreach ($riesgostipo2 as $riesgo) { //damos formato a fecha expiración if ($riesgo['expiration_date'] == NULL or $riesgo['expiration_date'] == "0000-00-00") { $fecha_exp = NULL; } else { $expiration_date = new DateTime($riesgo['expiration_date']); $fecha_exp = date_format($expiration_date, 'd-m-Y'); $fecha_exp .= " a las " . date_format($expiration_date, "H:i:s"); } //damos formato a fecha creación if ($riesgo['created_at'] != NULL) { $fecha_creacion = date_format($riesgo['created_at'], "d-m-Y"); } else { $fecha_creacion = NULL; } //damos formato a fecha de actualización if ($riesgo['updated_at'] != NULL) { $fecha_act = date_format($riesgo['updated_at'], "d-m-Y"); } else { $fecha_act = NULL; } //obtenemos categoría de riesgo $categoria = \Ermtool\Risk_category::find($riesgo['risk_category_id']); //obtenemos causas si es que tiene $causes = DB::table('cause_risk')->join('causes', 'causes.id', '=', 'cause_risk.cause_id')->where('cause_risk.risk_id', '=', $riesgo['id'])->select('causes.name')->get(); if ($causes) { $causas = array(); $j = 0; foreach ($causes as $cause) { $causas[$j] = $cause->name; $j += 1; } } else { $causas = NULL; } //obtenemos efectos si es que existen $effects = DB::table('effect_risk')->join('effects', 'effects.id', '=', 'effect_risk.effect_id')->where('effect_risk.risk_id', '=', $riesgo['id'])->select('effects.name')->get(); if ($effects) { $efectos = array(); $j = 0; foreach ($effects as $effect) { $efectos[$j] = $effect->name; $j += 1; } } else { $efectos = NULL; } $riesgostipo[$i] = array('id' => $riesgo['id'], 'nombre' => $riesgo['name'], 'descripcion' => $riesgo['description'], 'fecha_creacion' => $fecha_creacion, 'fecha_act' => $fecha_act, 'fecha_exp' => $fecha_exp, 'causas' => $causas, 'efectos' => $efectos, 'categoria' => $categoria['name'], 'estado' => $riesgo['status']); $i += 1; } if (Session::get('languaje') == 'en') { return view('en.datos_maestros.riesgos_tipo.index', ['riesgos' => $riesgostipo]); } else { return view('datos_maestros.riesgos_tipo.index', ['riesgos' => $riesgostipo]); } } }