Exemple #1
0
 public function getControlsFromPerspective($org, $perspective)
 {
     $controls = \Ermtool\Control::getControlsFromPerspective($org, $perspective);
     return json_encode($controls);
 }
Exemple #2
0
 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function show($id)
 {
     //print_r($_GET);
     switch ($_GET['kind']) {
         case 1:
             //archivos de controles
             if ($_GET['control_type'] == 0) {
                 $controls = \Ermtool\Control::getProcessesControls($_GET['organization_id']);
             } else {
                 if ($_GET['control_type'] == 1) {
                     $controls = \Ermtool\Control::getBussinessControls($_GET['organization_id']);
                 }
             }
             $i = 0;
             $org_name = \Ermtool\Organization::name($_GET['organization_id']);
             //recorremos los controles para ver cuales tienen archivos
             $controls2 = array();
             foreach ($controls as $control) {
                 $files = Storage::files('controles/' . $control->id);
                 //vemos si existe la carpeta (si existe es porque tiene archivos)
                 if ($files != NULL) {
                     //obtenemos los riesgos asociados a este control
                     $risks = \Ermtool\Risk::getRisksFromControl($control->id, $_GET['control_type']);
                     $controls2[$i] = ['name' => $control->name, 'description' => $control->description, 'risks' => $risks, 'files' => $files];
                     $i += 1;
                 }
             }
             if (Session::get('languaje') == 'en') {
                 return view('en.documentos.show', ['elements' => $controls2, 'kind' => $_GET['kind'], 'control_type' => $_GET['control_type'], 'org_name' => $org_name]);
             } else {
                 return view('documentos.show', ['elements' => $controls2, 'kind' => $_GET['kind'], 'control_type' => $_GET['control_type'], 'org_name' => $org_name]);
             }
             break;
         case 2:
             //hallazgos
             //$files = Storage::files('evidencias_hallazgos');
             //obtenemos id de los issues que son del tipo "kind_issue"
             switch ($_GET['kind_issue']) {
                 case 0:
                     //obtenemos issues de proceso
                     $processes = \Ermtool\Process::getProcessFromIssues($_GET['organization_id']);
                     $process_issues = array();
                     //se guardaran los procesos que tienen issues que además tienen documentos
                     $i = 0;
                     foreach ($processes as $process) {
                         //obtenemos issues del proceso
                         $issues = \Ermtool\Issue::getProcessIssues($process->id);
                         $issues2 = array();
                         //array donde se guardaran los issues que tienen documentos
                         //recorremos los issues para ver por cada uno si posee archivos
                         $j = 0;
                         foreach ($issues as $issue) {
                             $files = Storage::files('evidencias_hallazgos/' . $issue->id);
                             //vemos si existe la carpeta (si existe es porque tiene archivos)
                             if ($files != NULL) {
                                 $issues2[$j] = ['name' => $issue->name, 'description' => $issue->description, 'classification' => $issue->classification, 'recommendations' => $issue->recommendations, 'files' => $files];
                                 $j += 1;
                             }
                             //else
                             //{
                             //    echo 'el issue ' . $issue->id . ' no tiene evidencia<br>';
                             //}
                         }
                         //ahora guardamos solo aquellos procesos que tienen documentos asociados
                         if (!empty($issues2)) {
                             $process_issues[$i] = ['name' => $process->name, 'description' => $process->description, 'issues' => $issues2];
                             $i += 1;
                         }
                     }
                     if (Session::get('languaje') == 'en') {
                         return view('en.documentos.show', ['elements' => $process_issues, 'kind2' => $_GET['kind_issue']]);
                     } else {
                         return view('documentos.show', ['elements' => $process_issues, 'kind2' => $_GET['kind_issue']]);
                     }
                     break;
                 case 1:
                     //issues de subprocesos
                     $subprocesses = \Ermtool\Subprocess::getSubprocessFromIssues($_GET['organization_id']);
                     $subprocess_issues = array();
                     //se guardaran los subprocesos que tienen issues que además tienen documentos
                     $i = 0;
                     foreach ($subprocesses as $subprocess) {
                         //obtenemos issues del proceso
                         $issues = \Ermtool\Issue::getSubprocessIssuesBySubprocess($subprocess->id);
                         $issues2 = array();
                         //array donde se guardaran los issues que tienen documentos
                         //recorremos los issues para ver por cada uno si posee archivos
                         $j = 0;
                         foreach ($issues as $issue) {
                             $files = Storage::files('evidencias_hallazgos/' . $issue->id);
                             //vemos si existe la carpeta (si existe es porque tiene archivos)
                             if ($files != NULL) {
                                 $issues2[$j] = ['name' => $issue->name, 'description' => $issue->description, 'classification' => $issue->classification, 'recommendations' => $issue->recommendations, 'files' => $files];
                                 $j += 1;
                             }
                         }
                         //ahora guardamos solo aquellos subprocesos que tienen documentos asociados
                         if (!empty($issues2)) {
                             $subprocess_issues[$i] = ['name' => $subprocess->name, 'description' => $subprocess->description, 'issues' => $issues2, 'process' => $subprocess->process_name];
                             $i += 1;
                         }
                     }
                     if (Session::get('languaje') == 'en') {
                         return view('en.documentos.show', ['elements' => $subprocess_issues, 'kind2' => $_GET['kind_issue']]);
                     } else {
                         return view('documentos.show', ['elements' => $subprocess_issues, 'kind2' => $_GET['kind_issue']]);
                     }
                     break;
                 case 2:
                     //issues de organización
                     $issues = \Ermtool\Organization::find($_GET['organization_id'])->issues;
                     $org_name = \Ermtool\Organization::name($_GET['organization_id']);
                     $org_description = \Ermtool\Organization::description($_GET['organization_id']);
                     $issues2 = array();
                     //array donde se guardaran los issues que tienen documentos
                     //recorremos los issues para ver por cada uno si posee archivos
                     $j = 0;
                     foreach ($issues as $issue) {
                         $files = Storage::files('evidencias_hallazgos/' . $issue->id);
                         //vemos si existe la carpeta (si existe es porque tiene archivos)
                         if ($files != NULL) {
                             $issues2[$j] = ['name' => $issue['name'], 'description' => $issue['description'], 'classification' => $issue['classification'], 'recommendations' => $issue['recommendations'], 'files' => $files];
                             $j += 1;
                         }
                     }
                     if (Session::get('languaje') == 'en') {
                         return view('en.documentos.show', ['issues' => $issues2, 'org_name' => $org_name, 'org_description' => $org_description, 'kind2' => $_GET['kind_issue']]);
                     } else {
                         return view('documentos.show', ['issues' => $issues2, 'org_name' => $org_name, 'org_description' => $org_description, 'kind2' => $_GET['kind_issue']]);
                     }
                     break;
                 case 3:
                     //issues de control de proceso
                     $controls = \Ermtool\Control::getProcessesControlsFromIssues($_GET['organization_id']);
                     $controls_issues = array();
                     //se guardaran los controles que tienen issues que además tienen documentos
                     $i = 0;
                     foreach ($controls as $control) {
                         //obtenemos issues del control
                         $issues = \Ermtool\Issue::getControlIssues($control->id);
                         $issues2 = array();
                         //array donde se guardaran los issues que tienen documentos
                         //recorremos los issues para ver por cada uno si posee archivos
                         $j = 0;
                         foreach ($issues as $issue) {
                             $files = Storage::files('evidencias_hallazgos/' . $issue->id);
                             //vemos si existe la carpeta (si existe es porque tiene archivos)
                             if ($files != NULL) {
                                 $issues2[$j] = ['name' => $issue->name, 'description' => $issue->description, 'classification' => $issue->classification, 'recommendations' => $issue->recommendations, 'files' => $files];
                                 $j += 1;
                             }
                         }
                         //ahora guardamos solo aquellos controles que tienen documentos asociados
                         if (!empty($issues2)) {
                             $control_issues[$i] = ['name' => $control->name, 'description' => $control->description, 'issues' => $issues2];
                             $i += 1;
                         }
                     }
                     if (Session::get('languaje') == 'en') {
                         return view('en.documentos.show', ['elements' => $control_issues, 'kind2' => $_GET['kind_issue']]);
                     } else {
                         return view('documentos.show', ['elements' => $control_issues, 'kind2' => $_GET['kind_issue']]);
                     }
                     break;
                 case 4:
                     //issues de control de entidad
                     $controls = \Ermtool\Control::getObjectivesControlsFromIssues($_GET['organization_id']);
                     $control_issues = array();
                     //se guardaran los controles que tienen issues que además tienen documentos
                     $i = 0;
                     foreach ($controls as $control) {
                         //obtenemos issues del control
                         $issues = \Ermtool\Issue::getControlIssues($control->id);
                         $issues2 = array();
                         //array donde se guardaran los issues que tienen documentos
                         //recorremos los issues para ver por cada uno si posee archivos
                         $j = 0;
                         foreach ($issues as $issue) {
                             $files = Storage::files('evidencias_hallazgos/' . $issue->id);
                             //vemos si existe la carpeta (si existe es porque tiene archivos)
                             if ($files != NULL) {
                                 $issues2[$j] = ['name' => $issue->name, 'description' => $issue->description, 'classification' => $issue->classification, 'recommendations' => $issue->recommendations, 'files' => $files];
                                 $j += 1;
                             }
                         }
                         //ahora guardamos solo aquellos controles que tienen documentos asociados
                         if (!empty($issues2)) {
                             $control_issues[$i] = ['name' => $control->name, 'description' => $control->description, 'issues' => $issues2];
                             $i += 1;
                         }
                     }
                     if (Session::get('languaje') == 'en') {
                         return view('en.documentos.show', ['elements' => $control_issues, 'kind2' => $_GET['kind_issue']]);
                     } else {
                         return view('documentos.show', ['elements' => $control_issues, 'kind2' => $_GET['kind_issue']]);
                     }
                     break;
                 case 5:
                     //issues de programas de auditoría
                     //(audit_audit_plan_audit_program)
                     $audit_programs = \Ermtool\Audit_program::getProgramsFromIssues($_GET['organization_id']);
                     $audit_program_issues = array();
                     //se guardaran los programas que tienen issues que además tienen documentos
                     $i = 0;
                     foreach ($audit_programs as $audit_program) {
                         //obtenemos issues del programa
                         $issues = \Ermtool\Issue::getAuditProgramIssues($audit_program->id);
                         $issues2 = array();
                         //array donde se guardaran los issues que tienen documentos
                         //recorremos los issues para ver por cada uno si posee archivos
                         $j = 0;
                         foreach ($issues as $issue) {
                             $files = Storage::files('evidencias_hallazgos/' . $issue->id);
                             //vemos si existe la carpeta (si existe es porque tiene archivos)
                             if ($files != NULL) {
                                 $issues2[$j] = ['name' => $issue->name, 'description' => $issue->description, 'classification' => $issue->classification, 'recommendations' => $issue->recommendations, 'files' => $files];
                                 $j += 1;
                             }
                         }
                         //ahora guardamos solo aquellos controles que tienen documentos asociados
                         if (!empty($issues2)) {
                             $audit_program_issues[$i] = ['name' => $audit_program->name, 'description' => $audit_program->description, 'issues' => $issues2];
                             $i += 1;
                         }
                     }
                     if (Session::get('languaje') == 'en') {
                         return view('en.documentos.show', ['elements' => $audit_program_issues, 'kind2' => $_GET['kind_issue']]);
                     } else {
                         return view('documentos.show', ['elements' => $audit_program_issues, 'kind2' => $_GET['kind_issue']]);
                     }
                     break;
                 case 6:
                     //issues de auditoría
                     //(audit_audit_plan)
                     $audits = \Ermtool\Audit::getAuditsFromIssues($_GET['organization_id']);
                     $audit_issues = array();
                     //se guardaran las auditorías que tienen issues que además tienen documentos
                     $i = 0;
                     foreach ($audits as $audit) {
                         //obtenemos issues de la auditoría
                         $issues = \Ermtool\Issue::getAuditIssues($audit->id);
                         $issues2 = array();
                         //array donde se guardaran los issues que tienen documentos
                         //recorremos los issues para ver por cada uno si posee archivos
                         $j = 0;
                         foreach ($issues as $issue) {
                             $files = Storage::files('evidencias_hallazgos/' . $issue->id);
                             //vemos si existe la carpeta (si existe es porque tiene archivos)
                             if ($files != NULL) {
                                 $issues2[$j] = ['name' => $issue->name, 'description' => $issue->description, 'classification' => $issue->classification, 'recommendations' => $issue->recommendations, 'files' => $files];
                                 $j += 1;
                             }
                         }
                         //ahora guardamos solo aquellos controles que tienen documentos asociados
                         if (!empty($issues2)) {
                             $audit_issues[$i] = ['audit_plan' => $audit->audit_plan, 'name' => $audit->name, 'description' => $audit->description, 'issues' => $issues2];
                             $i += 1;
                         }
                     }
                     if (Session::get('languaje') == 'en') {
                         return view('en.documentos.show', ['elements' => $audit_issues, 'kind2' => $_GET['kind_issue']]);
                     } else {
                         return view('documentos.show', ['elements' => $audit_issues, 'kind2' => $_GET['kind_issue']]);
                     }
                     break;
                 default:
                     # code...
                     break;
             }
             break;
         case 3:
             //notas
             $notes = \Ermtool\Note::getNotes($_GET['organization_id'], $_GET['audit_plan_id']);
             $i = 0;
             //recorremos las notas para ver cuales tienen archivos
             $notes2 = array();
             foreach ($notes as $note) {
                 //obtenemos posibles respuestas
                 $answers = \Ermtool\Note::find($note->id)->notes_answers;
                 $j = 0;
                 $answers2 = array();
                 foreach ($answers as $ans) {
                     $files1 = Storage::files('evidencias_resp_notas/' . $ans->id);
                     if ($files1 != NULL) {
                         //seteamos fecha
                         $created_at = date_format($ans['created_at'], 'd-m-Y');
                         $answers2[$j] = ['answer' => $ans['answer'], 'created_at' => $created_at, 'files' => $files1];
                         $j += 1;
                     }
                 }
                 $files = Storage::files('evidencias_notas/' . $note->id);
                 //vemos si existe la carpeta (si existe es porque tiene archivos)
                 if ($files != NULL) {
                     $notes2[$j] = ['name' => $note->name, 'description' => $note->description, 'files' => $files, 'answers' => $answers2];
                     $i += 1;
                 }
                 //puede ser que la respuesta tenga archivos
             }
             if (Session::get('languaje') == 'en') {
                 return view('en.documentos.show', ['elements' => $notes2, 'kind' => $_GET['kind']]);
             } else {
                 return view('documentos.show', ['elements' => $notes2, 'kind' => $_GET['kind']]);
             }
             break;
         case 4:
             //programas
             $programs = \Ermtool\Audit_program::getPrograms($_GET['organization_id'], $_GET['audit_plan_id']);
             $plan = \Ermtool\Audit_plan::name($_GET['audit_plan_id']);
             $i = 0;
             //recorremos los programas para ver cuales tienen archivos
             $programs2 = array();
             foreach ($programs as $program) {
                 $files = Storage::files('programas_auditoria/' . $program->id);
                 //vemos si existe la carpeta (si existe es porque tiene archivos)
                 if ($files != NULL) {
                     $programs2[$i] = ['audit' => $program->audit, 'name' => $program->name, 'description' => $program->description, 'files' => $files];
                     $i += 1;
                 }
             }
             if (Session::get('languaje') == 'en') {
                 return view('en.documentos.show', ['elements' => $programs2, 'kind' => $_GET['kind'], 'audit_plan' => $plan]);
             } else {
                 return view('documentos.show', ['elements' => $programs2, 'kind' => $_GET['kind'], 'audit_plan' => $plan]);
             }
             break;
         case 5:
             //pruebas
             $tests = \Ermtool\Audit_test::getTests($_GET['organization_id'], $_GET['audit_plan_id']);
             $plan = \Ermtool\Audit_plan::name($_GET['audit_plan_id']);
             $i = 0;
             //recorremos los programas para ver cuales tienen archivos
             $tests2 = array();
             foreach ($tests as $test) {
                 $files = Storage::files('pruebas_auditoria/' . $test->id);
                 //vemos si existe la carpeta (si existe es porque tiene archivos)
                 if ($files != NULL) {
                     $tests2[$i] = ['audit' => $test->audit, 'program' => $test->program, 'name' => $test->name, 'description' => $test->description, 'files' => $files];
                     $i += 1;
                 }
             }
             if (Session::get('languaje') == 'en') {
                 return view('en.documentos.show', ['elements' => $tests2, 'kind' => $_GET['kind'], 'audit_plan' => $plan]);
             } else {
                 return view('documentos.show', ['elements' => $tests2, 'kind' => $_GET['kind'], 'audit_plan' => $plan]);
             }
             break;
         default:
             break;
     }
 }
Exemple #3
0
 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]);
     }
 }
Exemple #4
0
 /**
  * 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 getSubprocessControls($subprocess)
 {
     $controls = \Ermtool\Control::getSubprocessControls($subprocess);
     return json_encode($controls);
 }