/** * Store a newly created resource in storage. * * @param \Illuminate\Http\Request $request * @return \Illuminate\Http\Response */ public function store(Request $request) { if (Auth::guest()) { return view('login'); } else { //print_r($_POST); global $req; $req = $request; DB::transaction(function () { //verificamos ingreso de datos if (isset($_POST['description'])) { $description = $_POST['description']; } else { $description = NULL; } if (isset($_POST['recommendations'])) { $recommendations = $_POST['recommendations']; } else { $recommendations = NULL; } if (isset($_POST['classification']) && $_POST['classification'] != "") { $classification = $_POST['classification']; } else { $classification = NULL; } if (isset($_POST['kind'])) { if ($_POST['kind'] == 0) { $issue = DB::table('issues')->insertGetId(['name' => $_POST['name'], 'description' => $description, 'recommendations' => $recommendations, 'classification' => $classification, 'process_id' => $_POST['process_id'], 'created_at' => date('Y-m-d H:i:s'), 'updated_at' => date('Y-m-d H:i:s')]); } else { if ($_POST['kind'] == 1) { $issue = DB::table('issues')->insertGetId(['name' => $_POST['name'], 'description' => $description, 'recommendations' => $recommendations, 'classification' => $classification, 'subprocess_id' => $_POST['subprocess_id'], 'created_at' => date('Y-m-d H:i:s'), 'updated_at' => date('Y-m-d H:i:s')]); } else { if ($_POST['kind'] == 2) { $issue = DB::table('issues')->insertGetId(['name' => $_POST['name'], 'description' => $description, 'recommendations' => $recommendations, 'classification' => $classification, 'organization_id' => $_POST['org_id'], 'created_at' => date('Y-m-d H:i:s'), 'updated_at' => date('Y-m-d H:i:s')]); } else { if ($_POST['kind'] == 3 || $_POST['kind'] == 4) { $issue = DB::table('issues')->insertGetId(['name' => $_POST['name'], 'description' => $description, 'recommendations' => $recommendations, 'classification' => $classification, 'control_id' => $_POST['control_id'], 'created_at' => date('Y-m-d H:i:s'), 'updated_at' => date('Y-m-d H:i:s')]); } else { if ($_POST['kind'] == 5) { $issue = DB::table('issues')->insertGetId(['name' => $_POST['name'], 'description' => $description, 'recommendations' => $recommendations, 'classification' => $classification, 'audit_audit_plan_audit_program_id' => $_POST['audit_audit_plan_audit_program_id'], 'created_at' => date('Y-m-d H:i:s'), 'updated_at' => date('Y-m-d H:i:s')]); } else { if ($_POST['kind'] == 6) { $issue = DB::table('issues')->insertGetId(['name' => $_POST['name'], 'description' => $description, 'recommendations' => $recommendations, 'classification' => $classification, 'audit_audit_plan_id' => $_POST['audit_audit_plan_id'], 'created_at' => date('Y-m-d H:i:s'), 'updated_at' => date('Y-m-d H:i:s')]); } } } } } } } else { if (isset($_POST['test_id'])) { $issue = DB::table('issues')->insertGetId(['name' => $_POST['name'], 'description' => $description, 'recommendations' => $recommendations, 'classification' => $classification, 'audit_test_id' => $_POST['test_id'], 'created_at' => date('Y-m-d H:i:s'), 'updated_at' => date('Y-m-d H:i:s')]); } else { if (isset($_POST['evaluation_id'])) { $issue = DB::table('issues')->insertGetId(['name' => $_POST['name'], 'description' => $description, 'recommendations' => $recommendations, 'classification' => $classification, 'control_evaluation_id' => $_POST['evaluation_id'], 'created_at' => date('Y-m-d H:i:s'), 'updated_at' => date('Y-m-d H:i:s')]); } } } //agregamos evidencia (si es que existe) if ($GLOBALS['req']->file('evidence_doc') != NULL) { foreach ($GLOBALS['req']->file('evidence_doc') as $file) { if ($file != NULL) { upload_file($file, 'evidencias_hallazgos', $issue); } } } //vemos si tiene al menos la descripción del plan de acción, si es así se agrega el plan if (isset($_POST['description_plan']) and $_POST['description_plan'] != "") { if (isset($_POST['stakeholder_id']) and $_POST['stakeholder_id'] != "") { $stakeholder = $_POST['stakeholder_id']; } else { $stakeholder = NULL; } if (isset($_POST['final_date']) and $_POST['final_date'] != "") { $final_date = $_POST['final_date']; } else { $final_date = NULL; } $plan = new PlanesAccion(); $newplan = $plan->store($issue, $_POST['description_plan'], $stakeholder, $final_date); } if (Session::get('languaje') == 'en') { if (isset($newplan)) { Session::flash('message', 'Issue and action plan successfully created'); } else { Session::flash('message', 'Issue successfully created'); } } else { if (isset($newplan)) { Session::flash('message', 'Hallazgo y plan de acción creado correctamente'); } else { Session::flash('message', 'Hallazgo creado correctamente'); } } }); return Redirect::to('hallazgos'); } }
public function generarExcelGraficos($id) { //generamos variable global para usarla en la función excel /*id identifica el tipo de control gráfico que es 1 = Controles ejecutados 2 = Controles pendientes 3 = Controles efectivos 4 = Controles inefectivos 5 = Planes de auditoría abiertos 6 = Planes de auditoría en ejecución 7 = Planes de auditoría cerrados 8 = Planes de acción por evaluación de controles 9 = Planes de acción por ejecución de auditoría 10 = Planes - op. de mejora 11 = Planes - Deficiencia 12 = Planes - Deb. significativa 13 = Planes estado - Abierto 14 = Planes estado - próximos a cerrar 15 = Planes estado - Fecha final terminada y aun abierto 16 = Planes estado - Cerrado 17 = Pruebas de auditoría abiertas 18 = Pruebas de auditoría en ejecución 19 = Pruebas de auditoría cerradas */ global $id2; $id2 = $id; if ($GLOBALS['id2'] == 1) { Excel::create('Reporte Controles ejecutados ' . date("d-m-Y"), function ($excel) { // título excel $excel->setTitle('Controles ejecutados'); //creador y compañia $excel->setCreator('Administrador B-GRC')->setCompany('B-GRC - IXUS Consulting'); //descripción $excel->setDescription('Reporte de controles ejecutados'); $excel->sheet('Controles', function ($sheet) { $control = new Controles(); $datos = $control->indexGraficos($GLOBALS['id2']); //$datos2 = json_decode($datos); $sheet->fromArray($datos); //editamos formato de salida de celdas $sheet->cells('A1:C1', function ($cells) { $cells->setBackground('#013ADF'); $cells->setFontColor('#ffffff'); $cells->setFontFamily('Calibri'); $cells->setFontWeight('bold'); $cells->setFontSize(16); }); $sheet->freezeFirstRow(); }); })->export('xls'); } else { if ($GLOBALS['id2'] == 2) { Excel::create('Reporte Controles pendientes ' . date("d-m-Y"), function ($excel) { $excel->setTitle('Controles pendientes'); $excel->setCreator('Administrador B-GRC')->setCompany('B-GRC - IXUS Consulting'); $excel->setDescription('Reporte de controles pendientes'); $excel->sheet('Controles', function ($sheet) { $control = new Controles(); $datos = $control->indexGraficos($GLOBALS['id2']); $sheet->fromArray($datos); $sheet->cells('A1:C1', function ($cells) { $cells->setBackground('#013ADF'); $cells->setFontColor('#ffffff'); $cells->setFontFamily('Calibri'); $cells->setFontWeight('bold'); $cells->setFontSize(16); }); $sheet->freezeFirstRow(); }); })->export('xls'); } else { if ($GLOBALS['id2'] == 3) { Excel::create('Reporte Controles efectivos ' . date("d-m-Y"), function ($excel) { $excel->setTitle('Controles efectivos'); $excel->setCreator('Administrador B-GRC')->setCompany('B-GRC - IXUS Consulting'); $excel->setDescription('Reporte de controles efectivos'); $excel->sheet('Controles', function ($sheet) { $control = new Controles(); $datos = $control->indexGraficos($GLOBALS['id2']); $sheet->fromArray($datos); $sheet->cells('A1:C1', function ($cells) { $cells->setBackground('#013ADF'); $cells->setFontColor('#ffffff'); $cells->setFontFamily('Calibri'); $cells->setFontWeight('bold'); $cells->setFontSize(16); }); $sheet->freezeFirstRow(); }); })->export('xls'); } else { if ($GLOBALS['id2'] == 4) { Excel::create('Reporte Controles inefectivos ' . date("d-m-Y"), function ($excel) { $excel->setTitle('Controles inefectivos'); $excel->setCreator('Administrador B-GRC')->setCompany('B-GRC - IXUS Consulting'); $excel->setDescription('Reporte de controles inefectivos'); $excel->sheet('Controles', function ($sheet) { $control = new Controles(); $datos = $control->indexGraficos($GLOBALS['id2']); $sheet->fromArray($datos); $sheet->cells('A1:C1', function ($cells) { $cells->setBackground('#013ADF'); $cells->setFontColor('#ffffff'); $cells->setFontFamily('Calibri'); $cells->setFontWeight('bold'); $cells->setFontSize(16); }); $sheet->freezeFirstRow(); }); })->export('xls'); } else { if ($GLOBALS['id2'] == 5) { Excel::create('Reporte Planes de auditoría abiertos ' . date("d-m-Y"), function ($excel) { $excel->setTitle('Planes de auditoría abiertos'); $excel->setCreator('Administrador B-GRC')->setCompany('B-GRC - IXUS Consulting'); $excel->setDescription('Reporte de planes de auditoría abiertos'); $excel->sheet('Planes de auditoría', function ($sheet) { $plan = new Audits(); $datos = $plan->indexGraficos($GLOBALS['id2']); $sheet->fromArray($datos); $sheet->cells('A1:E1', function ($cells) { $cells->setBackground('#013ADF'); $cells->setFontColor('#ffffff'); $cells->setFontFamily('Calibri'); $cells->setFontWeight('bold'); $cells->setFontSize(16); }); $sheet->freezeFirstRow(); }); })->export('xls'); } else { if ($GLOBALS['id2'] == 6) { Excel::create('Reporte Planes de auditoría en ejecución ' . date("d-m-Y"), function ($excel) { $excel->setTitle('Planes de auditoría en ejecución'); $excel->setCreator('Administrador B-GRC')->setCompany('B-GRC - IXUS Consulting'); $excel->setDescription('Reporte de planes de auditoría en ejecución'); $excel->sheet('Planes de auditoría', function ($sheet) { $plan = new Audits(); $datos = $plan->indexGraficos($GLOBALS['id2']); $sheet->fromArray($datos); $sheet->cells('A1:E1', function ($cells) { $cells->setBackground('#013ADF'); $cells->setFontColor('#ffffff'); $cells->setFontFamily('Calibri'); $cells->setFontWeight('bold'); $cells->setFontSize(16); }); $sheet->freezeFirstRow(); }); })->export('xls'); } else { if ($GLOBALS['id2'] == 7) { Excel::create('Reporte Planes de auditoría cerrados ' . date("d-m-Y"), function ($excel) { $excel->setTitle('Planes de auditoría cerrados'); $excel->setCreator('Administrador B-GRC')->setCompany('B-GRC - IXUS Consulting'); $excel->setDescription('Reporte de planes de auditoría cerrados'); $excel->sheet('Planes de auditoría', function ($sheet) { $plan = new Audits(); $datos = $plan->indexGraficos($GLOBALS['id2']); $sheet->fromArray($datos); $sheet->cells('A1:E1', function ($cells) { $cells->setBackground('#013ADF'); $cells->setFontColor('#ffffff'); $cells->setFontFamily('Calibri'); $cells->setFontWeight('bold'); $cells->setFontSize(16); }); $sheet->freezeFirstRow(); }); })->export('xls'); } else { if ($GLOBALS['id2'] == 8) { Excel::create('Planes de acción en evaluación de controles ' . date("d-m-Y"), function ($excel) { $excel->setTitle('Planes de acción'); $excel->setCreator('Administrador B-GRC')->setCompany('B-GRC - IXUS Consulting'); $excel->setDescription('Reporte de planes de acción creados a través de la evaluación de controles'); $excel->sheet('Planes de acción', function ($sheet) { $plan = new PlanesAccion(); $datos = $plan->indexGraficos($GLOBALS['id2']); $sheet->fromArray($datos); $sheet->cells('A1:G1', function ($cells) { $cells->setBackground('#013ADF'); $cells->setFontColor('#ffffff'); $cells->setFontFamily('Calibri'); $cells->setFontWeight('bold'); $cells->setFontSize(16); }); $sheet->freezeFirstRow(); }); })->export('xls'); } else { if ($GLOBALS['id2'] == 9) { Excel::create('Planes de acción en auditorías ' . date("d-m-Y"), function ($excel) { $excel->setTitle('Planes de acción'); $excel->setCreator('Administrador B-GRC')->setCompany('B-GRC - IXUS Consulting'); $excel->setDescription('Reporte de planes de acción creados a través de auditorías'); $excel->sheet('Planes de acción', function ($sheet) { $plan = new PlanesAccion(); $datos = $plan->indexGraficos($GLOBALS['id2']); $sheet->fromArray($datos); $sheet->cells('A1:J1', function ($cells) { $cells->setBackground('#013ADF'); $cells->setFontColor('#ffffff'); $cells->setFontFamily('Calibri'); $cells->setFontWeight('bold'); $cells->setFontSize(16); }); $sheet->freezeFirstRow(); }); })->export('xls'); } else { if ($GLOBALS['id2'] == 10) { Excel::create('Planes de acción para oportunidades de mejora ' . date("d-m-Y"), function ($excel) { $excel->setTitle('Planes de acción'); $excel->setCreator('Administrador B-GRC')->setCompany('B-GRC - IXUS Consulting'); $excel->setDescription('Reporte de planes de acción creados a través de hallazgos clasificados como oportunidad de mejora'); $excel->sheet('Planes de acción', function ($sheet) { $plan = new PlanesAccion(); $datos = $plan->indexGraficos($GLOBALS['id2']); $sheet->fromArray($datos); $sheet->cells('A1:I1', function ($cells) { $cells->setBackground('#013ADF'); $cells->setFontColor('#ffffff'); $cells->setFontFamily('Calibri'); $cells->setFontWeight('bold'); $cells->setFontSize(16); }); $sheet->freezeFirstRow(); }); })->export('xls'); } else { if ($GLOBALS['id2'] == 11) { Excel::create('Planes de acción para deficiencias ' . date("d-m-Y"), function ($excel) { $excel->setTitle('Planes de acción'); $excel->setCreator('Administrador B-GRC')->setCompany('B-GRC - IXUS Consulting'); $excel->setDescription('Reporte de planes de acción creados a través de hallazgos clasificados como deficiencias'); $excel->sheet('Planes de acción', function ($sheet) { $plan = new PlanesAccion(); $datos = $plan->indexGraficos($GLOBALS['id2']); $sheet->fromArray($datos); $sheet->cells('A1:I1', function ($cells) { $cells->setBackground('#013ADF'); $cells->setFontColor('#ffffff'); $cells->setFontFamily('Calibri'); $cells->setFontWeight('bold'); $cells->setFontSize(16); }); $sheet->freezeFirstRow(); }); })->export('xls'); } else { if ($GLOBALS['id2'] == 12) { Excel::create('Planes de acción para debilidades significativas ' . date("d-m-Y"), function ($excel) { $excel->setTitle('Planes de acción'); $excel->setCreator('Administrador B-GRC')->setCompany('B-GRC - IXUS Consulting'); $excel->setDescription('Reporte de planes de acción creados a través de hallazgos clasificados como debilidades significativas'); $excel->sheet('Planes de acción', function ($sheet) { $plan = new PlanesAccion(); $datos = $plan->indexGraficos($GLOBALS['id2']); $sheet->fromArray($datos); $sheet->cells('A1:I1', function ($cells) { $cells->setBackground('#013ADF'); $cells->setFontColor('#ffffff'); $cells->setFontFamily('Calibri'); $cells->setFontWeight('bold'); $cells->setFontSize(16); }); $sheet->freezeFirstRow(); }); })->export('xls'); } else { if ($GLOBALS['id2'] == 13) { Excel::create('Planes de acción abiertos ' . date("d-m-Y"), function ($excel) { $excel->setTitle('Planes de acción abiertos'); $excel->setCreator('Administrador B-GRC')->setCompany('B-GRC - IXUS Consulting'); $excel->setDescription('Reporte de planes de acción que se encuentran abiertos'); $excel->sheet('Planes de acción', function ($sheet) { $plan = new PlanesAccion(); $datos = $plan->indexGraficos($GLOBALS['id2']); $sheet->fromArray($datos); $sheet->cells('A1:G1', function ($cells) { $cells->setBackground('#013ADF'); $cells->setFontColor('#ffffff'); $cells->setFontFamily('Calibri'); $cells->setFontWeight('bold'); $cells->setFontSize(16); }); $sheet->freezeFirstRow(); }); })->export('xls'); } else { if ($GLOBALS['id2'] == 14) { Excel::create('Planes de acción próximos a cerrar ' . date("d-m-Y"), function ($excel) { $excel->setTitle('Planes de acción próximos a cerrar'); $excel->setCreator('Administrador B-GRC')->setCompany('B-GRC - IXUS Consulting'); $excel->setDescription('Reporte de planes de acción en que su fecha límite se encuentra próxima a cumplirse'); $excel->sheet('Planes de acción', function ($sheet) { $plan = new PlanesAccion(); $datos = $plan->indexGraficos($GLOBALS['id2']); $sheet->fromArray($datos); $sheet->cells('A1:G1', function ($cells) { $cells->setBackground('#013ADF'); $cells->setFontColor('#ffffff'); $cells->setFontFamily('Calibri'); $cells->setFontWeight('bold'); $cells->setFontSize(16); }); $sheet->freezeFirstRow(); }); })->export('xls'); } else { if ($GLOBALS['id2'] == 15) { Excel::create('Planes de acción abiertos con fecha pasada ' . date("d-m-Y"), function ($excel) { $excel->setTitle('Planes de acción abiertos fecha límite terminada'); $excel->setCreator('Administrador B-GRC')->setCompany('B-GRC - IXUS Consulting'); $excel->setDescription('Reporte de planes de acción que se encuentran abiertos siendo que la fecha final del mismo se encuentra pasada'); $excel->sheet('Planes de acción', function ($sheet) { $plan = new PlanesAccion(); $datos = $plan->indexGraficos($GLOBALS['id2']); $sheet->fromArray($datos); $sheet->cells('A1:G1', function ($cells) { $cells->setBackground('#013ADF'); $cells->setFontColor('#ffffff'); $cells->setFontFamily('Calibri'); $cells->setFontWeight('bold'); $cells->setFontSize(16); }); $sheet->freezeFirstRow(); }); })->export('xls'); } else { if ($GLOBALS['id2'] == 16) { Excel::create('Planes de acción cerrados ' . date("d-m-Y"), function ($excel) { $excel->setTitle('Planes de acción cerrados'); $excel->setCreator('Administrador B-GRC')->setCompany('B-GRC - IXUS Consulting'); $excel->setDescription('Reporte de planes de acción cerrados'); $excel->sheet('Planes de acción', function ($sheet) { $plan = new PlanesAccion(); $datos = $plan->indexGraficos($GLOBALS['id2']); $sheet->fromArray($datos); $sheet->cells('A1:G1', function ($cells) { $cells->setBackground('#013ADF'); $cells->setFontColor('#ffffff'); $cells->setFontFamily('Calibri'); $cells->setFontWeight('bold'); $cells->setFontSize(16); }); $sheet->freezeFirstRow(); }); })->export('xls'); } } } } } } } } } } } } } } } } }