Exemplo n.º 1
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 {
         $orgs_selected = array();
         $subproceso = \Ermtool\Subprocess::find($id);
         $procesos = \Ermtool\Process::where('status', 0)->lists('name', 'id');
         //obtenemos organizaciones del subproceso
         $orgs = DB::table('organization_subprocess')->where('subprocess_id', '=', $id)->select('organization_id')->get();
         $i = 0;
         foreach ($orgs as $org) {
             $orgs_selected[$i] = $org->organization_id;
             $i += 1;
         }
         //Seleccionamos subprocesos que pueden ser padres
         $subprocesos = \Ermtool\Subprocess::where('subprocess_id', NULL)->where('status', 0)->where('id', '<>', $id)->lists('name', 'id');
         $organizaciones = \Ermtool\Organization::where('status', 0)->lists('name', 'id');
         if (Session::get('languaje') == 'en') {
             return view('en.datos_maestros.subprocesos.edit', ['procesos' => $procesos, 'subprocesos' => $subprocesos, 'subproceso' => $subproceso, 'organizaciones' => $organizaciones, 'orgs_selected' => $orgs_selected]);
         } else {
             return view('datos_maestros.subprocesos.edit', ['procesos' => $procesos, 'subprocesos' => $subprocesos, 'subproceso' => $subproceso, 'organizaciones' => $organizaciones, 'orgs_selected' => $orgs_selected]);
         }
     }
 }
Exemplo n.º 2
0
 /**
  * Show the form for editing the specified resource.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function edit()
 {
     if (Auth::guest()) {
         return view('login');
     } else {
         if (isset($_GET['test_id'])) {
             $test_id = $_GET['test_id'];
             $eval_id = NULL;
         } else {
             if (isset($_GET['evaluation'])) {
                 $eval_id = $_GET['evaluation'];
                 $test_id = NULL;
             } else {
                 $test_id = NULL;
                 $eval_id = NULL;
             }
         }
         $org = \Ermtool\Organization::where('id', $_GET['org'])->value('name');
         $org_id = \Ermtool\Organization::where('id', $_GET['org'])->value('id');
         //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');
         $issue = \Ermtool\Issue::find($_GET['id']);
         //vemos si es que tiene plan de accion
         $action_plan = NULL;
         $action_plan = DB::table('action_plans')->where('issue_id', '=', $_GET['id'])->select('id', 'stakeholder_id', 'description', 'final_date', 'status')->first();
         //vemos si es hallazgo de proceso, organización, u otro
         if ($issue['process_id'] != NULL) {
             $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');
             $process_selected = $issue->process_id;
             if (Session::get('languaje') == 'en') {
                 return view('en.hallazgos.edit', ['org' => $org, 'org_id' => $org_id, 'issue' => $issue, 'stakeholders' => $stakes, 'processes' => $processes, 'process_selected' => $process_selected, 'action_plan' => $action_plan, 'test_id' => $test_id, 'kind' => $_GET['kind']]);
             } else {
                 return view('hallazgos.edit', ['org' => $org, 'org_id' => $org_id, 'issue' => $issue, 'stakeholders' => $stakes, 'processes' => $processes, 'process_selected' => $process_selected, 'action_plan' => $action_plan, 'test_id' => $test_id, 'kind' => $_GET['kind']]);
             }
         } else {
             if ($issue['organization_id'] != NULL) {
                 if (Session::get('languaje') == 'en') {
                     return view('en.hallazgos.edit', ['org' => $org, 'org_id' => $org_id, 'issue' => $issue, 'stakeholders' => $stakes, 'org_id' => $_GET['org'], 'action_plan' => $action_plan, 'test_id' => $test_id, 'eval_id' => $eval_id, 'kind' => $_GET['kind']]);
                 } else {
                     return view('hallazgos.edit', ['org' => $org, 'org_id' => $org_id, 'issue' => $issue, 'stakeholders' => $stakes, 'org_id' => $_GET['org'], 'action_plan' => $action_plan, 'test_id' => $test_id, 'eval_id' => $eval_id, 'kind' => $_GET['kind']]);
                 }
             } else {
                 if (!isset($_GET['kind'])) {
                     if (Session::get('languaje') == 'en') {
                         return view('en.hallazgos.edit', ['org' => $org, 'org_id' => $org_id, 'issue' => $issue, 'stakeholders' => $stakes, 'action_plan' => $action_plan, 'test_id' => $test_id, 'eval_id' => $eval_id, 'kind' => NULL]);
                     } else {
                         return view('hallazgos.edit', ['org' => $org, 'org_id' => $org_id, 'issue' => $issue, 'stakeholders' => $stakes, 'action_plan' => $action_plan, 'test_id' => $test_id, 'eval_id' => $eval_id, 'kind' => NULL]);
                     }
                 }
                 if (Session::get('languaje') == 'en') {
                     return view('en.hallazgos.edit', ['org' => $org, 'org_id' => $org_id, 'issue' => $issue, 'stakeholders' => $stakes, 'action_plan' => $action_plan, 'test_id' => $test_id, 'eval_id' => $eval_id, 'kind' => $_GET['kind']]);
                 } else {
                     return view('hallazgos.edit', ['org' => $org, 'org_id' => $org_id, 'issue' => $issue, 'stakeholders' => $stakes, 'action_plan' => $action_plan, 'test_id' => $test_id, 'eval_id' => $eval_id, 'kind' => $_GET['kind']]);
                 }
             }
         }
     }
 }
Exemplo n.º 3
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;
     }
 }
Exemplo n.º 4
0
 public function getProcesses($org)
 {
     $processes = \Ermtool\Process::getProcesses($org);
     return json_encode($processes);
 }