/** * Show the form for creating a new resource. * * @return \Illuminate\Http\Response */ public function create() { if (Auth::guest()) { return view('login'); } else { if (isset($_GET['org'])) { $org = \Ermtool\Organization::where('id', $_GET['org'])->value('name'); //obtenemos stakeholders de la misma organización $stakes = DB::table('stakeholders')->join('organization_stakeholder', 'organization_stakeholder.stakeholder_id', '=', 'stakeholders.id')->where('organization_stakeholder.organization_id', '=', $_GET['org'])->select('stakeholders.id', DB::raw('CONCAT(name, " ", surnames) AS full_name'))->orderBy('name')->lists('full_name', 'id'); if ($_GET['kind'] == 0) { $processes = \Ermtool\Process::where('processes.status', 0)->join('subprocesses', 'subprocesses.process_id', '=', 'processes.id')->join('organization_subprocess', 'organization_subprocess.subprocess_id', '=', 'subprocesses.id')->where('organization_subprocess.organization_id', '=', $_GET['org'])->lists('processes.name', 'processes.id'); if (Session::get('languaje') == 'en') { return view('en.hallazgos.create', ['org' => $org, 'processes' => $processes, 'kind' => $_GET['kind'], 'stakeholders' => $stakes, 'org_id' => $_GET['org']]); } else { return view('hallazgos.create', ['org' => $org, 'processes' => $processes, 'kind' => $_GET['kind'], 'stakeholders' => $stakes, 'org_id' => $_GET['org']]); } } else { if ($_GET['kind'] == 1) { $subprocesses = \Ermtool\Subprocess::where('subprocesses.status', 0)->join('organization_subprocess', 'organization_subprocess.subprocess_id', '=', 'subprocesses.id')->where('organization_subprocess.organization_id', '=', $_GET['org'])->lists('subprocesses.name', 'subprocesses.id'); if (Session::get('languaje') == 'en') { return view('en.hallazgos.create', ['org' => $org, 'subprocesses' => $subprocesses, 'kind' => $_GET['kind'], 'stakeholders' => $stakes, 'org_id' => $_GET['org']]); } else { return view('hallazgos.create', ['org' => $org, 'subprocesses' => $subprocesses, 'kind' => $_GET['kind'], 'stakeholders' => $stakes, 'org_id' => $_GET['org']]); } } else { if ($_GET['kind'] == 2) { if (Session::get('languaje') == 'en') { return view('en.hallazgos.create', ['org' => $org, 'kind' => $_GET['kind'], 'org_id' => $_GET['org'], 'stakeholders' => $stakes, 'org_id' => $_GET['org']]); } else { return view('hallazgos.create', ['org' => $org, 'kind' => $_GET['kind'], 'org_id' => $_GET['org'], 'stakeholders' => $stakes, 'org_id' => $_GET['org']]); } } else { if ($_GET['kind'] == 3) { $controls = DB::table('controls')->join('control_risk_subprocess', 'control_risk_subprocess.control_id', '=', 'controls.id')->join('risk_subprocess', 'risk_subprocess.id', '=', 'control_risk_subprocess.risk_subprocess_id')->join('organization_subprocess', 'organization_subprocess.subprocess_id', '=', 'risk_subprocess.subprocess_id')->where('organization_subprocess.organization_id', '=', $_GET['org'])->lists('controls.name', 'controls.id'); if (Session::get('languaje') == 'en') { return view('en.hallazgos.create', ['org' => $org, 'controls' => $controls, 'kind' => $_GET['kind'], 'stakeholders' => $stakes, 'org_id' => $_GET['org']]); } else { return view('hallazgos.create', ['org' => $org, 'controls' => $controls, 'kind' => $_GET['kind'], 'stakeholders' => $stakes, 'org_id' => $_GET['org']]); } } else { if ($_GET['kind'] == 4) { $controls = DB::table('controls')->join('control_objective_risk', 'control_objective_risk.control_id', '=', 'controls.id')->join('objective_risk', 'objective_risk.id', '=', 'control_objective_risk.objective_risk_id')->join('objectives', 'objectives.id', '=', 'objective_risk.objective_id')->where('objectives.organization_id', '=', $_GET['org'])->select('controls.*')->lists('controls.name', 'controls.id'); if (Session::get('languaje') == 'en') { return view('en.hallazgos.create', ['org' => $org, 'controls' => $controls, 'kind' => $_GET['kind'], 'stakeholders' => $stakes, 'org_id' => $_GET['org']]); } else { return view('hallazgos.create', ['org' => $org, 'controls' => $controls, 'kind' => $_GET['kind'], 'stakeholders' => $stakes, 'org_id' => $_GET['org']]); } } else { if ($_GET['kind'] == 5) { $audit_programs = DB::table('audit_programs')->join('audit_audit_plan_audit_program', 'audit_audit_plan_audit_program.audit_program_id', '=', 'audit_programs.id')->join('audit_audit_plan', 'audit_audit_plan.id', '=', 'audit_audit_plan_audit_program.audit_audit_plan_id')->join('audit_plans', 'audit_plans.id', '=', 'audit_audit_plan.audit_plan_id')->where('audit_plans.organization_id', '=', $_GET['org'])->lists('audit_programs.name', 'audit_audit_plan_audit_program.id'); if (Session::get('languaje') == 'en') { return view('en.hallazgos.create', ['org' => $org, 'audit_programs' => $audit_programs, 'kind' => $_GET['kind'], 'stakeholders' => $stakes, 'org_id' => $_GET['org']]); } else { return view('hallazgos.create', ['org' => $org, 'audit_programs' => $audit_programs, 'kind' => $_GET['kind'], 'stakeholders' => $stakes, 'org_id' => $_GET['org']]); } } else { if ($_GET['kind'] == 6) { $audits = DB::table('audit_audit_plan')->join('audits', 'audits.id', '=', 'audit_audit_plan.audit_id')->join('audit_plans', 'audit_plans.id', '=', 'audit_audit_plan.audit_plan_id')->where('audit_plans.organization_id', '=', $_GET['org'])->select('audit_audit_plan.id', DB::raw('CONCAT(audit_plans.name, " - ", audits.name) AS audit_name'))->lists('audit_name', 'audit_audit_plan.id'); if (Session::get('languaje') == 'en') { return view('en.hallazgos.create', ['org' => $org, 'audits' => $audits, 'kind' => $_GET['kind'], 'stakeholders' => $stakes, 'org_id' => $_GET['org']]); } else { return view('hallazgos.create', ['org' => $org, 'audits' => $audits, 'kind' => $_GET['kind'], 'stakeholders' => $stakes, 'org_id' => $_GET['org']]); } } } } } } } } } else { if (isset($_GET['test'])) { $org = \Ermtool\Organization::getOrgIdByTestId($_GET['test']); //obtenemos stakeholders de la misma organización $stakes = \Ermtool\Stakeholder::listStakeholders($org); $test = \Ermtool\Audit_test::getTestNameById($_GET['test']); if (Session::get('languaje') == 'en') { return view('en.hallazgos.create', ['test' => $test, 'test_id' => $_GET['test'], 'stakeholders' => $stakes]); } else { return view('hallazgos.create', ['test' => $test, 'test_id' => $_GET['test'], 'stakeholders' => $stakes]); } } else { if (isset($_GET['evaluation'])) { $evaluation = \Ermtool\Control_evaluation::find($_GET['evaluation']); $org = \Ermtool\Organization::getOrganizationIdFromControl($evaluation->control_id); //obtenemos stakeholders de la misma organización $stakes = \Ermtool\Stakeholder::listStakeholders($org->id); $control = \Ermtool\Control::name($evaluation->control_id); if (Session::get('languaje') == 'en') { return view('en.hallazgos.create', ['control' => $control, 'evaluation_id' => $_GET['evaluation'], 'stakeholders' => $stakes]); } else { return view('hallazgos.create', ['control' => $control, 'evaluation_id' => $_GET['evaluation'], 'stakeholders' => $stakes]); } } } } } }
public function hallazgos($id) { if (Auth::guest()) { return view('login'); } else { //datos de evaluación de control $evaluation = \Ermtool\Control_evaluation::find($id); $issues = array(); $issues1 = \Ermtool\Issue::getIssueByControlEvaluation($id); $control_name = \Ermtool\Control::name($evaluation->control_id); $iss = new IssuesController(); //print_r($_POST); $i = 0; foreach ($issues1 as $issue) { if ($issue['plan_description'] != NULL) { $temp = $iss->formatearIssue($issue['id'], $issue['name'], $issue['classification'], $issue['recommendations'], $issue['plan_description'], $issue['plan_status'], $issue['plan_final_date']); } else { $temp = $iss->formatearIssue($issue['id'], $issue['name'], $issue['classification'], $issue['recommendations'], NULL, NULL, NULL); } $issues[$i] = ['id' => $temp['id'], 'name' => $temp['name'], 'classification' => $temp['classification'], 'recommendations' => $temp['recommendations'], 'plan' => $temp['plan'], 'status' => $temp['status'], 'status_origin' => $temp['status_origin'], 'final_date' => $temp['final_date'], 'evidence' => $issue['evidences']]; $i += 1; } $org_id = \Ermtool\Organization::getOrganizationIdFromControl($evaluation->control_id); if (Session::get('languaje') == 'en') { switch ($evaluation->kind) { case 0: $kind = 'Design test'; break; case 1: $kind = 'Operational effectiveness test'; break; case 2: $kind = 'Sustantive test'; break; case 3: $kind = 'Compliance test'; break; default: # code... break; } return view('en.hallazgos.index3', ['issues' => $issues, 'evaluation' => $evaluation, 'org_id' => $org_id, 'kind' => $kind]); } else { switch ($evaluation->kind) { case 0: $kind = 'Prueba de diseño'; break; case 1: $kind = 'Prueba de efectividad operativa'; break; case 2: $kind = 'Prueba sustantiva'; break; case 3: $kind = 'Prueba de cumplimiento'; break; default: # code... break; } return view('hallazgos.index3', ['issues' => $issues, 'evaluation' => $evaluation, 'control_name' => $control_name, 'org_id' => $org_id, 'kind' => $kind]); } } }
public function closeEvaluation($id) { global $id1; $id1 = $id; DB::transaction(function () { //primero que todo, cerramos el estado de la prueba de id = $id $eval = \Ermtool\Control_evaluation::find($GLOBALS['id1']); $eval->status = 2; $eval->save(); //ahora calcularemos el resultado del control $control = \Ermtool\Control::calcControlValue($eval->control_id); }); }