From d0ef0e8715fbada62fd3e53b332e02099851e531 Mon Sep 17 00:00:00 2001 From: elyambay Date: Thu, 5 Dec 2019 07:44:18 -0300 Subject: [PATCH] Cubo Cargos --- .../Controllers/Admin/ReportController.php | 8 + app/Http/Controllers/ReporteController.php | 1294 ++--------------- app/Traits/ReportTrait.php | 594 ++++++++ .../admin/reportes/filter_cargos.blade.php | 64 + .../admin/reportes/filter_niveles.blade.php | 2 +- resources/views/layout.blade.php | 1 + routes/web.php | 2 + 7 files changed, 794 insertions(+), 1171 deletions(-) create mode 100644 resources/views/admin/reportes/filter_cargos.blade.php diff --git a/app/Http/Controllers/Admin/ReportController.php b/app/Http/Controllers/Admin/ReportController.php index 626d1b3..baed6b1 100644 --- a/app/Http/Controllers/Admin/ReportController.php +++ b/app/Http/Controllers/Admin/ReportController.php @@ -38,6 +38,14 @@ public function filterNiveles(){ ->with('rubros', $rubros); } + public function filterCargos(){ + $rubro = Rubro::first()->id; + $periodos = $this->getPeriodos($rubro); + $rubros = $this->getRubros(); + return view('admin.reportes.filter_cargos')->with('periodos', $periodos) + ->with('rubros', $rubros); + } + /** * Show the form for creating a new resource. * diff --git a/app/Http/Controllers/ReporteController.php b/app/Http/Controllers/ReporteController.php index 082b0f8..56813db 100644 --- a/app/Http/Controllers/ReporteController.php +++ b/app/Http/Controllers/ReporteController.php @@ -340,1179 +340,63 @@ public function cargoReportClubExcel(Request $request){ $cargos = Cargos_rubro::where('rubro_id', $rubro) ->whereIn('cargo_id', $cargosIds) ->get(); - //dd($cargos); - // recupera los cargos del periodo para todos los que tengan homologación - /* $encuestasCargos = Encuestas_cargo::where('cabecera_encuesta_id', $dbEncuesta->id) - ->whereNotNull('cargo_id') - ->where('incluir', 1) - ->get(); */ - // variables de detalle para cada segmento - $detalleUniverso = collect(); - $detalleNacional = collect(); - $detalleInternacional = collect(); - // Procesamiento por cargo - foreach ($cargos as $cargo) { - $request->request->add(["cargo_id"=> $cargo->cargo_id]); - // procesamos el reporte - if($reporteEspecial){ - $respuesta = $this->cargoReportEspecial($request, "clubExcel", true); - $filename = 'Resultados_especial_'.$periodo; - }else{ - $respuesta = $this->cargoReportAll($request, "clubExcel", true); - $filename = 'Resultados_'.$periodo; - } - $encuestaCargo = Encuestas_cargo::where('cabecera_encuesta_id', $dbEncuesta->id) - ->where('cargo_id', $cargo->cargo_id) - ->where('incluir', 1) - ->first(); - if($encuestaCargo){ - $descripcion = $encuestaCargo->descripcion; - }else{ - $descripcion = 'N/A'; - } - // preparamos los datos para el array final del cargo - $itemArray = array( $descripcion, - $cargo->cargo->descripcion, - ); - $itemArrayNac = $itemArray; - $itemArrayInt = $itemArray; - // por cada item del detalle - //$cantConceptos = 0; - foreach ($respuesta as $key => $item) { - // dd($item); - switch ($key) { - case 'detalle_universo': - $this->CargaDetalle($item, $itemArray); - break; - - case 'detalle_nacional': - $this->CargaDetalle($item, $itemArrayNac); - break; - case 'detalleInternacional': - $this->CargaDetalle($item, $itemArrayInt); - break; - } - - } - //dd($itemArray); - $detalleUniverso->push($itemArray); - $detalleNacional->push($itemArrayNac); - $detalleInternacional->push($itemArrayInt); - } - - - Excel::create($filename, function($excel) use($detalleUniverso, $detalleNacional, $detalleInternacional, $rubro) { - $excel->sheet("universo", function($sheet) use($detalleUniverso, $rubro){ - - $objDrawing = new PHPExcel_Worksheet_Drawing; - $objDrawing->setPath(public_path('images/logo.jpg')); //your image path - $objDrawing->setCoordinates('A1'); - $objDrawing->setWidthAndHeight(304,60); - $objDrawing->setWorksheet($sheet); - - - $sheet->cell('A5', function($cell){ - $cell->setValue('CARGO'); - }); - $sheet->mergeCells('A5:D5'); - $sheet->cells('A5:D5', function($cells){ - $cells->setBackground('#00897b'); - $cells->setFontColor("#FFFFFF"); - $cells->setFontWeight("bold"); - // $cells->setValignment('center'); - $cells->setAlignment('center'); - }); - // Salario Base Header - $sheet->cell('E5', function($cell){ - $cell->setValue('SALARIO BASE'); - }); - $sheet->mergeCells('E5:J5'); - $sheet->cells('E5:J5', function($cells){ - $cells->setBackground('#0288d1'); - $cells->setFontColor("#FFFFFF"); - $cells->setFontWeight("bold"); - // $cells->setValignment('center'); - $cells->setAlignment('center'); - }); - if($rubro == 1){ - - // Salario Efectivo Anual Garantizado - $sheet->cell('K5', function($cell){ - $cell->setValue('EFECTIVO ANUAL GARANTIZADO'); - }); - $sheet->mergeCells('K5:P5'); - $sheet->cells('K5:P5', function($cells){ - $cells->setBackground('#388e3c'); - $cells->setFontColor("#FFFFFF"); - $cells->setFontWeight("bold"); - // $cells->setValignment('center'); - $cells->setAlignment('center'); - }); - - // Total Adicional Anual - $sheet->cell('Q5', function($cell){ - $cell->setValue('TOTAL ADICIONAL ANUAL'); - }); - $sheet->mergeCells('Q5:V5'); - $sheet->cells('Q5:V5', function($cells){ - $cells->setBackground('#fbc02d'); - $cells->setFontColor("#FFFFFF"); - $cells->setFontWeight("bold"); - // $cells->setValignment('center'); - $cells->setAlignment('center'); - }); - // Bono Anual - $sheet->cell('W5', function($cell){ - $cell->setValue('BONO ANUAL'); - }); - $sheet->mergeCells('W5:AB5'); - $sheet->cells('W5:AB5', function($cells){ - $cells->setBackground('#ffa000'); - $cells->setFontColor("#FFFFFF"); - $cells->setFontWeight("bold"); - // $cells->setValignment('center'); - $cells->setAlignment('center'); - }); - - // Comision - - $sheet->cell('AC5', function($cell){ - $cell->setValue('COMISION'); - }); - $sheet->mergeCells('AC5:AH5'); - $sheet->cells('AC5:AH5', function($cells){ - $cells->setBackground('#6a1b9a'); - $cells->setFontColor("#FFFFFF"); - $cells->setFontWeight("bold"); - // $cells->setValignment('center'); - $cells->setAlignment('center'); - }); - - - // Compensación Total Anual - $sheet->cell('AI5', function($cell){ - $cell->setValue('COMPENSACION TOTAL ANUAL'); - }); - $sheet->mergeCells('AI5:AN5'); - $sheet->cells('AI5:AN5', function($cells){ - $cells->setBackground('#0288d1'); - $cells->setFontColor("#FFFFFF"); - $cells->setFontWeight("bold"); - // $cells->setValignment('center'); - $cells->setAlignment('center'); - }); - // Salario Variable Anual comp. - $sheet->cell('AO5', function($cell){ - $cell->setValue('SALARIO BASE COMPARATIVO ORGANIZACION VS MERCADO'); - }); - $sheet->mergeCells('AO5:AT5'); - $sheet->cells('AO5:AT5', function($cells){ - $cells->setBackground('#afb42b'); - $cells->setFontColor("#FFFFFF"); - $cells->setFontWeight("bold"); - // $cells->setValignment('center'); - $cells->setAlignment('center'); - }); - - // Salario Variable Anual comp. - $sheet->cell('AU5', function($cell){ - $cell->setValue('RATIO SALARIO BASE ANUAL / TOTAL EFECTIVO ANUAL GARANTIZADO'); - }); - $sheet->mergeCells('AU5:AZ5'); - $sheet->cells('AU5:AZ5', function($cells){ - $cells->setBackground('#388e3c'); - $cells->setFontColor("#FFFFFF"); - $cells->setFontWeight("bold"); - // $cells->setValignment('center'); - $cells->setAlignment('center'); - }); - - $topeHeader = 8; - $rango = 'A6:AZ6'; - - }elseif($rubro == 4){ - // Salario Variable Anual - $sheet->cell('K5', function($cell){ - $cell->setValue('VARIABLE ANUAL'); - }); - $sheet->mergeCells('K5:P5'); - $sheet->cells('K5:P5', function($cells){ - $cells->setBackground('#afb42b'); - $cells->setFontColor("#FFFFFF"); - $cells->setFontWeight("bold"); - // $cells->setValignment('center'); - $cells->setAlignment('center'); - }); - // Total Adicional Anual - $sheet->cell('Q5', function($cell){ - $cell->setValue('TOTAL ADICIONAL ANUAL'); - }); - $sheet->mergeCells('Q5:V5'); - $sheet->cells('Q5:V5', function($cells){ - $cells->setBackground('#388e3c'); - $cells->setFontColor("#FFFFFF"); - $cells->setFontWeight("bold"); - // $cells->setValignment('center'); - $cells->setAlignment('center'); - }); - - // Bono Anual - $sheet->cell('W5', function($cell){ - $cell->setValue('BONO ANUAL'); - }); - $sheet->mergeCells('W5:AB5'); - $sheet->cells('W5:AB5', function($cells){ - $cells->setBackground('#fbc02d'); - $cells->setFontColor("#FFFFFF"); - $cells->setFontWeight("bold"); - // $cells->setValignment('center'); - $cells->setAlignment('center'); - }); - // Comisión - $sheet->cell('AC5', function($cell){ - $cell->setValue('COMISION'); - }); - $sheet->mergeCells('AC5:AH5'); - $sheet->cells('AC5:AH5', function($cells){ - $cells->setBackground('#ffa000'); - $cells->setFontColor("#FFFFFF"); - $cells->setFontWeight("bold"); - // $cells->setValignment('center'); - $cells->setAlignment('center'); - }); - - // Efectivo Total Anual - - $sheet->cell('AI5', function($cell){ - $cell->setValue('EFECTIVO TOTAL ANUAL'); - }); - $sheet->mergeCells('AI5:AN5'); - $sheet->cells('AI5:AN5', function($cells){ - $cells->setBackground('#6a1b9a'); - $cells->setFontColor("#FFFFFF"); - $cells->setFontWeight("bold"); - // $cells->setValignment('center'); - $cells->setAlignment('center'); - }); - - // Compensación Total Anual - $sheet->cell('AO5', function($cell){ - $cell->setValue('COMPENSACION ANUAL TOTAL'); - }); - $sheet->mergeCells('AO5:AT5'); - $sheet->cells('AO5:AT5', function($cells){ - $cells->setBackground('#f57c00'); - $cells->setFontColor("#FFFFFF"); - $cells->setFontWeight("bold"); - // $cells->setValignment('center'); - $cells->setAlignment('center'); - }); - // Salario Base Comparativo Header - $sheet->cell('AU5', function($cell){ - $cell->setValue('SALARIO BASE COMPARATIVO ORGANIZACION VS MERCADO'); - }); - $sheet->mergeCells('AU5:AZ5'); - $sheet->cells('AU5:AZ5', function($cells){ - $cells->setBackground('#0288d1'); - $cells->setFontColor("#FFFFFF"); - $cells->setFontWeight("bold"); - // $cells->setValignment('center'); - $cells->setAlignment('center'); - }); - // Salario Variable Anual comp. - $sheet->cell('BA5', function($cell){ - $cell->setValue('VARIABLE ANUAL COMPARATIVO ORGANIZACION VS MERCADO'); - }); - $sheet->mergeCells('BA5:BF5'); - $sheet->cells('BA5:BF5', function($cells){ - $cells->setBackground('#afb42b'); - $cells->setFontColor("#FFFFFF"); - $cells->setFontWeight("bold"); - // $cells->setValignment('center'); - $cells->setAlignment('center'); - }); - - // Salario Variable Anual comp. - $sheet->cell('BG5', function($cell){ - $cell->setValue('RATIO SALARIO BASE ANUAL / TOTAL EFECTIVO ANUAL'); - }); - $sheet->mergeCells('BG5:BL5'); - $sheet->cells('BG5:BL5', function($cells){ - $cells->setBackground('#fbc02d'); - $cells->setFontColor("#FFFFFF"); - $cells->setFontWeight("bold"); - // $cells->setValignment('center'); - $cells->setAlignment('center'); - }); - - $topeHeader = 10; - $rango = 'A6:BL6'; - - }else{ - // Salario Efectivo Anual Garantizado - $sheet->cell('K5', function($cell){ - $cell->setValue('EFECTIVO ANUAL GARANTIZADO'); - }); - $sheet->mergeCells('K5:P5'); - $sheet->cells('K5:P5', function($cells){ - $cells->setBackground('#388e3c'); - $cells->setFontColor("#FFFFFF"); - $cells->setFontWeight("bold"); - // $cells->setValignment('center'); - $cells->setAlignment('center'); - }); - - // Total Adicional Anual - $sheet->cell('Q5', function($cell){ - $cell->setValue('TOTAL ADICIONAL ANUAL'); - }); - $sheet->mergeCells('Q5:V5'); - $sheet->cells('Q5:V5', function($cells){ - $cells->setBackground('#fbc02d'); - $cells->setFontColor("#FFFFFF"); - $cells->setFontWeight("bold"); - // $cells->setValignment('center'); - $cells->setAlignment('center'); - }); - // Bono Anual - $sheet->cell('W5', function($cell){ - $cell->setValue('BONO ANUAL'); - }); - $sheet->mergeCells('W5:AB5'); - $sheet->cells('W5:AB5', function($cells){ - $cells->setBackground('#ffa000'); - $cells->setFontColor("#FFFFFF"); - $cells->setFontWeight("bold"); - // $cells->setValignment('center'); - $cells->setAlignment('center'); - }); - - // Comision - - $sheet->cell('AC5', function($cell){ - $cell->setValue('COMISION'); - }); - $sheet->mergeCells('AC5:AH5'); - $sheet->cells('AC5:AH5', function($cells){ - $cells->setBackground('#6a1b9a'); - $cells->setFontColor("#FFFFFF"); - $cells->setFontWeight("bold"); - // $cells->setValignment('center'); - $cells->setAlignment('center'); - }); - - // Efectivo Total Anual - $sheet->cell('AI5', function($cell){ - $cell->setValue('EFECTIVO TOTAL ANUAL'); - }); - $sheet->mergeCells('AI5:AN5'); - $sheet->cells('AI5:AN5', function($cells){ - $cells->setBackground('#f57c00'); - $cells->setFontColor("#FFFFFF"); - $cells->setFontWeight("bold"); - // $cells->setValignment('center'); - $cells->setAlignment('center'); - }); - // Compensación total anual - $sheet->cell('AO5', function($cell){ - $cell->setValue('COMPENSACION TOTAL ANUAL'); - }); - $sheet->mergeCells('AO5:AT5'); - $sheet->cells('AO5:AT5', function($cells){ - $cells->setBackground('#0288d1'); - $cells->setFontColor("#FFFFFF"); - $cells->setFontWeight("bold"); - // $cells->setValignment('center'); - $cells->setAlignment('center'); - }); - // Salario Variable Anual comp. - $sheet->cell('AU5', function($cell){ - $cell->setValue('SALARIO BASE COMPARATIVO ORGANIZACION VS MERCADO'); - }); - $sheet->mergeCells('AU5:AZ5'); - $sheet->cells('AU5:AZ5', function($cells){ - $cells->setBackground('#afb42b'); - $cells->setFontColor("#FFFFFF"); - $cells->setFontWeight("bold"); - // $cells->setValignment('center'); - $cells->setAlignment('center'); - }); - - // Salario Variable Anual comp. - $sheet->cell('BA5', function($cell){ - $cell->setValue('RATIO SALARIO BASE ANUAL / TOTAL EFECTIVO ANUAL'); - }); - $sheet->mergeCells('BA5:BF5'); - $sheet->cells('BA5:BF5', function($cells){ - $cells->setBackground('#fbc02d'); - $cells->setFontColor("#FFFFFF"); - $cells->setFontWeight("bold"); - // $cells->setValignment('center'); - $cells->setAlignment('center'); - }); - - $topeHeader = 9; - $rango = 'A6:BF6'; - } - - $itemsHeader = array("Mínimo", "25 Perc.", "Promedio", "Mediana", "75 Perc.", "Máximo"); - $cargoHeader = array("Cargo Company", "Oficial", "Ocupantes", "Casos"); - - for ($i= 0; $i < $topeHeader; $i++) { - foreach ($itemsHeader as $key => $value) { - array_push($cargoHeader, $value); - } - - } - - $sheet->row(6, $cargoHeader); - $sheet->rows($detalleUniverso); - $sheet->cells($rango, function($cells){ - $cells->setBackground('#a7ffeb'); - }); - $sheet->setFreeze('A7'); - }); - // hoja nacional - $excel->sheet("nacional", function($sheet) use($detalleNacional, $rubro){ - $objDrawing = new PHPExcel_Worksheet_Drawing; - $objDrawing->setPath(public_path('images/logo.jpg')); //your image path - $objDrawing->setCoordinates('A1'); - $objDrawing->setWidthAndHeight(304,60); - $objDrawing->setWorksheet($sheet); - - $sheet->cell('A5', function($cell){ - $cell->setValue('CARGO'); - }); - $sheet->mergeCells('A5:D5'); - $sheet->cells('A5:D5', function($cells){ - $cells->setBackground('#00897b'); - $cells->setFontColor("#FFFFFF"); - $cells->setFontWeight("bold"); - // $cells->setValignment('center'); - $cells->setAlignment('center'); - }); - // Salario Base Header - $sheet->cell('E5', function($cell){ - $cell->setValue('SALARIO BASE'); - }); - $sheet->mergeCells('E5:J5'); - $sheet->cells('E5:J5', function($cells){ - $cells->setBackground('#0288d1'); - $cells->setFontColor("#FFFFFF"); - $cells->setFontWeight("bold"); - // $cells->setValignment('center'); - $cells->setAlignment('center'); - }); - if($rubro == 1){ - - // Salario Efectivo Anual Garantizado - $sheet->cell('K5', function($cell){ - $cell->setValue('EFECTIVO ANUAL GARANTIZADO'); - }); - $sheet->mergeCells('K5:P5'); - $sheet->cells('K5:P5', function($cells){ - $cells->setBackground('#388e3c'); - $cells->setFontColor("#FFFFFF"); - $cells->setFontWeight("bold"); - // $cells->setValignment('center'); - $cells->setAlignment('center'); - }); - - // Total Adicional Anual - $sheet->cell('Q5', function($cell){ - $cell->setValue('TOTAL ADICIONAL ANUAL'); - }); - $sheet->mergeCells('Q5:V5'); - $sheet->cells('Q5:V5', function($cells){ - $cells->setBackground('#fbc02d'); - $cells->setFontColor("#FFFFFF"); - $cells->setFontWeight("bold"); - // $cells->setValignment('center'); - $cells->setAlignment('center'); - }); - // Bono Anual - $sheet->cell('W5', function($cell){ - $cell->setValue('BONO ANUAL'); - }); - $sheet->mergeCells('W5:AB5'); - $sheet->cells('W5:AB5', function($cells){ - $cells->setBackground('#ffa000'); - $cells->setFontColor("#FFFFFF"); - $cells->setFontWeight("bold"); - // $cells->setValignment('center'); - $cells->setAlignment('center'); - }); - - // Comision - - $sheet->cell('AC5', function($cell){ - $cell->setValue('COMISION'); - }); - $sheet->mergeCells('AC5:AH5'); - $sheet->cells('AC5:AH5', function($cells){ - $cells->setBackground('#6a1b9a'); - $cells->setFontColor("#FFFFFF"); - $cells->setFontWeight("bold"); - // $cells->setValignment('center'); - $cells->setAlignment('center'); - }); - - - // Compensación Total Anual - $sheet->cell('AI5', function($cell){ - $cell->setValue('COMPENSACION TOTAL ANUAL'); - }); - $sheet->mergeCells('AI5:AN5'); - $sheet->cells('AI5:AN5', function($cells){ - $cells->setBackground('#0288d1'); - $cells->setFontColor("#FFFFFF"); - $cells->setFontWeight("bold"); - // $cells->setValignment('center'); - $cells->setAlignment('center'); - }); - // Salario Variable Anual comp. - $sheet->cell('AO5', function($cell){ - $cell->setValue('SALARIO BASE COMPARATIVO ORGANIZACION VS MERCADO'); - }); - $sheet->mergeCells('AO5:AT5'); - $sheet->cells('AO5:AT5', function($cells){ - $cells->setBackground('#afb42b'); - $cells->setFontColor("#FFFFFF"); - $cells->setFontWeight("bold"); - // $cells->setValignment('center'); - $cells->setAlignment('center'); - }); - - // Salario Variable Anual comp. - $sheet->cell('AU5', function($cell){ - $cell->setValue('RATIO SALARIO BASE ANUAL / TOTAL EFECTIVO ANUAL GARANTIZADO'); - }); - $sheet->mergeCells('AU5:AZ5'); - $sheet->cells('AU5:AZ5', function($cells){ - $cells->setBackground('#388e3c'); - $cells->setFontColor("#FFFFFF"); - $cells->setFontWeight("bold"); - // $cells->setValignment('center'); - $cells->setAlignment('center'); - }); - - $topeHeader = 8; - $rango = 'A6:AZ6'; - - }elseif($rubro == 4){ - // Salario Variable Anual - $sheet->cell('K5', function($cell){ - $cell->setValue('VARIABLE ANUAL'); - }); - $sheet->mergeCells('K5:P5'); - $sheet->cells('K5:P5', function($cells){ - $cells->setBackground('#afb42b'); - $cells->setFontColor("#FFFFFF"); - $cells->setFontWeight("bold"); - // $cells->setValignment('center'); - $cells->setAlignment('center'); - }); - // Total Adicional Anual - $sheet->cell('Q5', function($cell){ - $cell->setValue('TOTAL ADICIONAL ANUAL'); - }); - $sheet->mergeCells('Q5:V5'); - $sheet->cells('Q5:V5', function($cells){ - $cells->setBackground('#388e3c'); - $cells->setFontColor("#FFFFFF"); - $cells->setFontWeight("bold"); - // $cells->setValignment('center'); - $cells->setAlignment('center'); - }); - - // Bono Anual - $sheet->cell('W5', function($cell){ - $cell->setValue('BONO ANUAL'); - }); - $sheet->mergeCells('W5:AB5'); - $sheet->cells('W5:AB5', function($cells){ - $cells->setBackground('#fbc02d'); - $cells->setFontColor("#FFFFFF"); - $cells->setFontWeight("bold"); - // $cells->setValignment('center'); - $cells->setAlignment('center'); - }); - // Comisión - $sheet->cell('AC5', function($cell){ - $cell->setValue('COMISION'); - }); - $sheet->mergeCells('AC5:AH5'); - $sheet->cells('AC5:AH5', function($cells){ - $cells->setBackground('#ffa000'); - $cells->setFontColor("#FFFFFF"); - $cells->setFontWeight("bold"); - // $cells->setValignment('center'); - $cells->setAlignment('center'); - }); - - // Efectivo Total Anual - - $sheet->cell('AI5', function($cell){ - $cell->setValue('EFECTIVO TOTAL ANUAL'); - }); - $sheet->mergeCells('AI5:AN5'); - $sheet->cells('AI5:AN5', function($cells){ - $cells->setBackground('#6a1b9a'); - $cells->setFontColor("#FFFFFF"); - $cells->setFontWeight("bold"); - // $cells->setValignment('center'); - $cells->setAlignment('center'); - }); - - // Compensación Total Anual - $sheet->cell('AO5', function($cell){ - $cell->setValue('COMPENSACION ANUAL TOTAL'); - }); - $sheet->mergeCells('AO5:AT5'); - $sheet->cells('AO5:AT5', function($cells){ - $cells->setBackground('#f57c00'); - $cells->setFontColor("#FFFFFF"); - $cells->setFontWeight("bold"); - // $cells->setValignment('center'); - $cells->setAlignment('center'); - }); - // Salario Base Comparativo Header - $sheet->cell('AU5', function($cell){ - $cell->setValue('SALARIO BASE COMPARATIVO ORGANIZACION VS MERCADO'); - }); - $sheet->mergeCells('AU5:AZ5'); - $sheet->cells('AU5:AZ5', function($cells){ - $cells->setBackground('#0288d1'); - $cells->setFontColor("#FFFFFF"); - $cells->setFontWeight("bold"); - // $cells->setValignment('center'); - $cells->setAlignment('center'); - }); - // Salario Variable Anual comp. - $sheet->cell('BA5', function($cell){ - $cell->setValue('VARIABLE ANUAL COMPARATIVO ORGANIZACION VS MERCADO'); - }); - $sheet->mergeCells('BA5:BF5'); - $sheet->cells('BA5:BF5', function($cells){ - $cells->setBackground('#afb42b'); - $cells->setFontColor("#FFFFFF"); - $cells->setFontWeight("bold"); - // $cells->setValignment('center'); - $cells->setAlignment('center'); - }); - - // Salario Variable Anual comp. - $sheet->cell('BG5', function($cell){ - $cell->setValue('RATIO SALARIO BASE ANUAL / TOTAL EFECTIVO ANUAL'); - }); - $sheet->mergeCells('BG5:BL5'); - $sheet->cells('BG5:BL5', function($cells){ - $cells->setBackground('#fbc02d'); - $cells->setFontColor("#FFFFFF"); - $cells->setFontWeight("bold"); - // $cells->setValignment('center'); - $cells->setAlignment('center'); - }); - - $topeHeader = 10; - $rango = 'A6:BL6'; - - }else{ - // Salario Efectivo Anual Garantizado - $sheet->cell('K5', function($cell){ - $cell->setValue('EFECTIVO ANUAL GARANTIZADO'); - }); - $sheet->mergeCells('K5:P5'); - $sheet->cells('K5:P5', function($cells){ - $cells->setBackground('#388e3c'); - $cells->setFontColor("#FFFFFF"); - $cells->setFontWeight("bold"); - // $cells->setValignment('center'); - $cells->setAlignment('center'); - }); - - // Total Adicional Anual - $sheet->cell('Q5', function($cell){ - $cell->setValue('TOTAL ADICIONAL ANUAL'); - }); - $sheet->mergeCells('Q5:V5'); - $sheet->cells('Q5:V5', function($cells){ - $cells->setBackground('#fbc02d'); - $cells->setFontColor("#FFFFFF"); - $cells->setFontWeight("bold"); - // $cells->setValignment('center'); - $cells->setAlignment('center'); - }); - // Bono Anual - $sheet->cell('W5', function($cell){ - $cell->setValue('BONO ANUAL'); - }); - $sheet->mergeCells('W5:AB5'); - $sheet->cells('W5:AB5', function($cells){ - $cells->setBackground('#ffa000'); - $cells->setFontColor("#FFFFFF"); - $cells->setFontWeight("bold"); - // $cells->setValignment('center'); - $cells->setAlignment('center'); - }); - - // Comision - - $sheet->cell('AC5', function($cell){ - $cell->setValue('COMISION'); - }); - $sheet->mergeCells('AC5:AH5'); - $sheet->cells('AC5:AH5', function($cells){ - $cells->setBackground('#6a1b9a'); - $cells->setFontColor("#FFFFFF"); - $cells->setFontWeight("bold"); - // $cells->setValignment('center'); - $cells->setAlignment('center'); - }); - - // Efectivo Total Anual - $sheet->cell('AI5', function($cell){ - $cell->setValue('EFECTIVO TOTAL ANUAL'); - }); - $sheet->mergeCells('AI5:AN5'); - $sheet->cells('AI5:AN5', function($cells){ - $cells->setBackground('#f57c00'); - $cells->setFontColor("#FFFFFF"); - $cells->setFontWeight("bold"); - // $cells->setValignment('center'); - $cells->setAlignment('center'); - }); - // Compensación total anual - $sheet->cell('AO5', function($cell){ - $cell->setValue('COMPENSACION TOTAL ANUAL'); - }); - $sheet->mergeCells('AO5:AT5'); - $sheet->cells('AO5:AT5', function($cells){ - $cells->setBackground('#0288d1'); - $cells->setFontColor("#FFFFFF"); - $cells->setFontWeight("bold"); - // $cells->setValignment('center'); - $cells->setAlignment('center'); - }); - // Salario Variable Anual comp. - $sheet->cell('AU5', function($cell){ - $cell->setValue('SALARIO BASE COMPARATIVO ORGANIZACION VS MERCADO'); - }); - $sheet->mergeCells('AU5:AZ5'); - $sheet->cells('AU5:AZ5', function($cells){ - $cells->setBackground('#afb42b'); - $cells->setFontColor("#FFFFFF"); - $cells->setFontWeight("bold"); - // $cells->setValignment('center'); - $cells->setAlignment('center'); - }); - - // Salario Variable Anual comp. - $sheet->cell('BA5', function($cell){ - $cell->setValue('RATIO SALARIO BASE ANUAL / TOTAL EFECTIVO ANUAL'); - }); - $sheet->mergeCells('BA5:BF5'); - $sheet->cells('BA5:BF5', function($cells){ - $cells->setBackground('#fbc02d'); - $cells->setFontColor("#FFFFFF"); - $cells->setFontWeight("bold"); - // $cells->setValignment('center'); - $cells->setAlignment('center'); - }); - - $topeHeader = 9; - $rango = 'A6:BF6'; - } - - $itemsHeader = array("Mínimo", "25 Perc.", "Promedio", "Mediana", "75 Perc.", "Máximo"); - $cargoHeader = array("Cargo Company", "Oficial", "Ocupantes", "Casos"); - - for ($i= 0; $i < $topeHeader; $i++) { - foreach ($itemsHeader as $key => $value) { - array_push($cargoHeader, $value); - } - - } - - $sheet->row(6, $cargoHeader); - $sheet->rows($detalleNacional); - $sheet->cells($rango, function($cells){ - $cells->setBackground('#a7ffeb'); - }); - $sheet->setFreeze('A7'); - }); - // hoja internacional - $excel->sheet("internacional", function($sheet) use($detalleInternacional, $rubro){ - $objDrawing = new PHPExcel_Worksheet_Drawing; - $objDrawing->setPath(public_path('images/logo.jpg')); //your image path - $objDrawing->setCoordinates('A1'); - $objDrawing->setWidthAndHeight(304,60); - $objDrawing->setWorksheet($sheet); - - $sheet->cell('A5', function($cell){ - $cell->setValue('CARGO'); - }); - $sheet->mergeCells('A5:D5'); - $sheet->cells('A5:D5', function($cells){ - $cells->setBackground('#00897b'); - $cells->setFontColor("#FFFFFF"); - $cells->setFontWeight("bold"); - // $cells->setValignment('center'); - $cells->setAlignment('center'); - }); - // Salario Base Header - $sheet->cell('E5', function($cell){ - $cell->setValue('SALARIO BASE'); - }); - $sheet->mergeCells('E5:J5'); - $sheet->cells('E5:J5', function($cells){ - $cells->setBackground('#0288d1'); - $cells->setFontColor("#FFFFFF"); - $cells->setFontWeight("bold"); - // $cells->setValignment('center'); - $cells->setAlignment('center'); - }); - if($rubro == 1){ - - // Salario Efectivo Anual Garantizado - $sheet->cell('K5', function($cell){ - $cell->setValue('EFECTIVO ANUAL GARANTIZADO'); - }); - $sheet->mergeCells('K5:P5'); - $sheet->cells('K5:P5', function($cells){ - $cells->setBackground('#388e3c'); - $cells->setFontColor("#FFFFFF"); - $cells->setFontWeight("bold"); - // $cells->setValignment('center'); - $cells->setAlignment('center'); - }); - - // Total Adicional Anual - $sheet->cell('Q5', function($cell){ - $cell->setValue('TOTAL ADICIONAL ANUAL'); - }); - $sheet->mergeCells('Q5:V5'); - $sheet->cells('Q5:V5', function($cells){ - $cells->setBackground('#fbc02d'); - $cells->setFontColor("#FFFFFF"); - $cells->setFontWeight("bold"); - // $cells->setValignment('center'); - $cells->setAlignment('center'); - }); - // Bono Anual - $sheet->cell('W5', function($cell){ - $cell->setValue('BONO ANUAL'); - }); - $sheet->mergeCells('W5:AB5'); - $sheet->cells('W5:AB5', function($cells){ - $cells->setBackground('#ffa000'); - $cells->setFontColor("#FFFFFF"); - $cells->setFontWeight("bold"); - // $cells->setValignment('center'); - $cells->setAlignment('center'); - }); - - // Comision - - $sheet->cell('AC5', function($cell){ - $cell->setValue('COMISION'); - }); - $sheet->mergeCells('AC5:AH5'); - $sheet->cells('AC5:AH5', function($cells){ - $cells->setBackground('#6a1b9a'); - $cells->setFontColor("#FFFFFF"); - $cells->setFontWeight("bold"); - // $cells->setValignment('center'); - $cells->setAlignment('center'); - }); - - - // Compensación Total Anual - $sheet->cell('AI5', function($cell){ - $cell->setValue('COMPENSACION TOTAL ANUAL'); - }); - $sheet->mergeCells('AI5:AN5'); - $sheet->cells('AI5:AN5', function($cells){ - $cells->setBackground('#0288d1'); - $cells->setFontColor("#FFFFFF"); - $cells->setFontWeight("bold"); - // $cells->setValignment('center'); - $cells->setAlignment('center'); - }); - // Salario Variable Anual comp. - $sheet->cell('AO5', function($cell){ - $cell->setValue('SALARIO BASE COMPARATIVO ORGANIZACION VS MERCADO'); - }); - $sheet->mergeCells('AO5:AT5'); - $sheet->cells('AO5:AT5', function($cells){ - $cells->setBackground('#afb42b'); - $cells->setFontColor("#FFFFFF"); - $cells->setFontWeight("bold"); - // $cells->setValignment('center'); - $cells->setAlignment('center'); - }); - - // Salario Variable Anual comp. - $sheet->cell('AU5', function($cell){ - $cell->setValue('RATIO SALARIO BASE ANUAL / TOTAL EFECTIVO ANUAL GARANTIZADO'); - }); - $sheet->mergeCells('AU5:AZ5'); - $sheet->cells('AU5:AZ5', function($cells){ - $cells->setBackground('#388e3c'); - $cells->setFontColor("#FFFFFF"); - $cells->setFontWeight("bold"); - // $cells->setValignment('center'); - $cells->setAlignment('center'); - }); - - $topeHeader = 8; - $rango = 'A6:AZ6'; - - }elseif($rubro == 4){ - // Salario Variable Anual - $sheet->cell('K5', function($cell){ - $cell->setValue('VARIABLE ANUAL'); - }); - $sheet->mergeCells('K5:P5'); - $sheet->cells('K5:P5', function($cells){ - $cells->setBackground('#afb42b'); - $cells->setFontColor("#FFFFFF"); - $cells->setFontWeight("bold"); - // $cells->setValignment('center'); - $cells->setAlignment('center'); - }); - // Total Adicional Anual - $sheet->cell('Q5', function($cell){ - $cell->setValue('TOTAL ADICIONAL ANUAL'); - }); - $sheet->mergeCells('Q5:V5'); - $sheet->cells('Q5:V5', function($cells){ - $cells->setBackground('#388e3c'); - $cells->setFontColor("#FFFFFF"); - $cells->setFontWeight("bold"); - // $cells->setValignment('center'); - $cells->setAlignment('center'); - }); - - // Bono Anual - $sheet->cell('W5', function($cell){ - $cell->setValue('BONO ANUAL'); - }); - $sheet->mergeCells('W5:AB5'); - $sheet->cells('W5:AB5', function($cells){ - $cells->setBackground('#fbc02d'); - $cells->setFontColor("#FFFFFF"); - $cells->setFontWeight("bold"); - // $cells->setValignment('center'); - $cells->setAlignment('center'); - }); - // Comisión - $sheet->cell('AC5', function($cell){ - $cell->setValue('COMISION'); - }); - $sheet->mergeCells('AC5:AH5'); - $sheet->cells('AC5:AH5', function($cells){ - $cells->setBackground('#ffa000'); - $cells->setFontColor("#FFFFFF"); - $cells->setFontWeight("bold"); - // $cells->setValignment('center'); - $cells->setAlignment('center'); - }); - - // Efectivo Total Anual - - $sheet->cell('AI5', function($cell){ - $cell->setValue('EFECTIVO TOTAL ANUAL'); - }); - $sheet->mergeCells('AI5:AN5'); - $sheet->cells('AI5:AN5', function($cells){ - $cells->setBackground('#6a1b9a'); - $cells->setFontColor("#FFFFFF"); - $cells->setFontWeight("bold"); - // $cells->setValignment('center'); - $cells->setAlignment('center'); - }); - - // Compensación Total Anual - $sheet->cell('AO5', function($cell){ - $cell->setValue('COMPENSACION ANUAL TOTAL'); - }); - $sheet->mergeCells('AO5:AT5'); - $sheet->cells('AO5:AT5', function($cells){ - $cells->setBackground('#f57c00'); - $cells->setFontColor("#FFFFFF"); - $cells->setFontWeight("bold"); - // $cells->setValignment('center'); - $cells->setAlignment('center'); - }); - // Salario Base Comparativo Header - $sheet->cell('AU5', function($cell){ - $cell->setValue('SALARIO BASE COMPARATIVO ORGANIZACION VS MERCADO'); - }); - $sheet->mergeCells('AU5:AZ5'); - $sheet->cells('AU5:AZ5', function($cells){ - $cells->setBackground('#0288d1'); - $cells->setFontColor("#FFFFFF"); - $cells->setFontWeight("bold"); - // $cells->setValignment('center'); - $cells->setAlignment('center'); - }); - // Salario Variable Anual comp. - $sheet->cell('BA5', function($cell){ - $cell->setValue('VARIABLE ANUAL COMPARATIVO ORGANIZACION VS MERCADO'); - }); - $sheet->mergeCells('BA5:BF5'); - $sheet->cells('BA5:BF5', function($cells){ - $cells->setBackground('#afb42b'); - $cells->setFontColor("#FFFFFF"); - $cells->setFontWeight("bold"); - // $cells->setValignment('center'); - $cells->setAlignment('center'); - }); - - // Salario Variable Anual comp. - $sheet->cell('BG5', function($cell){ - $cell->setValue('RATIO SALARIO BASE ANUAL / TOTAL EFECTIVO ANUAL'); - }); - $sheet->mergeCells('BG5:BL5'); - $sheet->cells('BG5:BL5', function($cells){ - $cells->setBackground('#fbc02d'); - $cells->setFontColor("#FFFFFF"); - $cells->setFontWeight("bold"); - // $cells->setValignment('center'); - $cells->setAlignment('center'); - }); - - $topeHeader = 10; - $rango = 'A6:BL6'; - - }else{ - // Salario Efectivo Anual Garantizado - $sheet->cell('K5', function($cell){ - $cell->setValue('EFECTIVO ANUAL GARANTIZADO'); - }); - $sheet->mergeCells('K5:P5'); - $sheet->cells('K5:P5', function($cells){ - $cells->setBackground('#388e3c'); - $cells->setFontColor("#FFFFFF"); - $cells->setFontWeight("bold"); - // $cells->setValignment('center'); - $cells->setAlignment('center'); - }); - - // Total Adicional Anual - $sheet->cell('Q5', function($cell){ - $cell->setValue('TOTAL ADICIONAL ANUAL'); - }); - $sheet->mergeCells('Q5:V5'); - $sheet->cells('Q5:V5', function($cells){ - $cells->setBackground('#fbc02d'); - $cells->setFontColor("#FFFFFF"); - $cells->setFontWeight("bold"); - // $cells->setValignment('center'); - $cells->setAlignment('center'); - }); - // Bono Anual - $sheet->cell('W5', function($cell){ - $cell->setValue('BONO ANUAL'); - }); - $sheet->mergeCells('W5:AB5'); - $sheet->cells('W5:AB5', function($cells){ - $cells->setBackground('#ffa000'); - $cells->setFontColor("#FFFFFF"); - $cells->setFontWeight("bold"); - // $cells->setValignment('center'); - $cells->setAlignment('center'); - }); - - // Comision - - $sheet->cell('AC5', function($cell){ - $cell->setValue('COMISION'); - }); - $sheet->mergeCells('AC5:AH5'); - $sheet->cells('AC5:AH5', function($cells){ - $cells->setBackground('#6a1b9a'); - $cells->setFontColor("#FFFFFF"); - $cells->setFontWeight("bold"); - // $cells->setValignment('center'); - $cells->setAlignment('center'); - }); - - // Efectivo Total Anual - $sheet->cell('AI5', function($cell){ - $cell->setValue('EFECTIVO TOTAL ANUAL'); - }); - $sheet->mergeCells('AI5:AN5'); - $sheet->cells('AI5:AN5', function($cells){ - $cells->setBackground('#f57c00'); - $cells->setFontColor("#FFFFFF"); - $cells->setFontWeight("bold"); - // $cells->setValignment('center'); - $cells->setAlignment('center'); - }); - // Compensación total anual - $sheet->cell('AO5', function($cell){ - $cell->setValue('COMPENSACION TOTAL ANUAL'); - }); - $sheet->mergeCells('AO5:AT5'); - $sheet->cells('AO5:AT5', function($cells){ - $cells->setBackground('#0288d1'); - $cells->setFontColor("#FFFFFF"); - $cells->setFontWeight("bold"); - // $cells->setValignment('center'); - $cells->setAlignment('center'); - }); - // Salario Variable Anual comp. - $sheet->cell('AU5', function($cell){ - $cell->setValue('SALARIO BASE COMPARATIVO ORGANIZACION VS MERCADO'); - }); - $sheet->mergeCells('AU5:AZ5'); - $sheet->cells('AU5:AZ5', function($cells){ - $cells->setBackground('#afb42b'); - $cells->setFontColor("#FFFFFF"); - $cells->setFontWeight("bold"); - // $cells->setValignment('center'); - $cells->setAlignment('center'); - }); - - // Salario Variable Anual comp. - $sheet->cell('BA5', function($cell){ - $cell->setValue('RATIO SALARIO BASE ANUAL / TOTAL EFECTIVO ANUAL'); - }); - $sheet->mergeCells('BA5:BF5'); - $sheet->cells('BA5:BF5', function($cells){ - $cells->setBackground('#fbc02d'); - $cells->setFontColor("#FFFFFF"); - $cells->setFontWeight("bold"); - // $cells->setValignment('center'); - $cells->setAlignment('center'); - }); + dd($cargosIds); + // variables de detalle para cada segmento + $detalleUniverso = collect(); + $detalleNacional = collect(); + $detalleInternacional = collect(); + // Procesamiento por cargo + foreach ($cargos as $cargo) { + $request->request->add(["cargo_id"=> $cargo->cargo_id]); + // procesamos el reporte + if($reporteEspecial){ + $respuesta = $this->cargoReportEspecial($request, "clubExcel", true); + $filename = 'Resultados_especial_'.$periodo; + }else{ + $respuesta = $this->cargoReportAll($request, "clubExcel", true); + $filename = 'Resultados_'.$periodo; + } + $encuestaCargo = Encuestas_cargo::where('cabecera_encuesta_id', $dbEncuesta->id) + ->where('cargo_id', $cargo->cargo_id) + ->where('incluir', 1) + ->first(); + if($encuestaCargo){ + $descripcion = $encuestaCargo->descripcion; + }else{ + $descripcion = 'N/A'; + } + // preparamos los datos para el array final del cargo + $itemArray = array( $descripcion, + $cargo->cargo->descripcion, + ); + $itemArrayNac = $itemArray; + $itemArrayInt = $itemArray; + // por cada item del detalle + //$cantConceptos = 0; + foreach ($respuesta as $key => $item) { + // dd($item); + switch ($key) { + case 'detalle_universo': + $this->CargaDetalle($item, $itemArray); + break; - $topeHeader = 9; - $rango = 'A6:BF6'; + case 'detalle_nacional': + $this->CargaDetalle($item, $itemArrayNac); + break; + case 'detalleInternacional': + $this->CargaDetalle($item, $itemArrayInt); + break; } - - $itemsHeader = array("Mínimo", "25 Perc.", "Promedio", "Mediana", "75 Perc.", "Máximo"); - $cargoHeader = array("Cargo Company", "Oficial", "Ocupantes", "Casos"); - for ($i= 0; $i < $topeHeader; $i++) { - foreach ($itemsHeader as $key => $value) { - array_push($cargoHeader, $value); - } - - } - - $sheet->row(6, $cargoHeader); - $sheet->rows($detalleInternacional); + } + //dd($itemArray); + $detalleUniverso->push($itemArray); + $detalleNacional->push($itemArrayNac); + $detalleInternacional->push($itemArrayInt); + } + + $this->excelClubCargos($detalleUniverso, $detalleNacional, $detalleInternacional, $rubro, $filename); - $sheet->cells($rango, function($cells){ - $cells->setBackground('#a7ffeb'); - }); - $sheet->setFreeze('A7'); - }); - $excel->setActiveSheetIndex(0); - })->export('xlsx'); } public function cargoReportClubEspecial(Request $request){ @@ -2542,7 +1426,77 @@ public function nivelReportClubExcel(Request $request){ }); $excel->setActiveSheetIndex(0); })->export('xlsx'); - } + } + + public function cargosReportExcel(Request $request){ + ini_set('max_execution_time', 0); + $cubo = true; + // periodo de la encuesta actual (semestral para navieras) + $periodo = $request->periodo; + // rubro de la empresa del cliente + $rubro = $request->rubro_id; + + $cargosIds = $this->getCargosHomologados($rubro, $periodo); + + $cargos = Cargos_rubro::where('rubro_id', $rubro) + ->whereIn('cargo_id', $cargosIds) + ->get(); + $empresa = Empresa::where('rubro_id', $rubro) + ->first() + ->id; + // variables de detalle para cada segmento + $detalleUniverso = collect(); + $detalleNacional = collect(); + $detalleInternacional = collect(); + // Procesamiento por cargo + foreach ($cargos as $cargo) { + $request->request->add(["cargo_id"=> $cargo->cargo_id, "empresa_id" => $empresa]); + // procesamos el reporte + $respuesta = $this->cargoReportAll($request, "clubExcel", true); + $filename = 'Cubo_Resultados_'.$periodo; + + /* $encuestaCargo = Encuestas_cargo::where('cabecera_encuesta_id', $dbEncuesta->id) + ->where('cargo_id', $cargo->cargo_id) + ->where('incluir', 1) + ->first(); + if($encuestaCargo){ + $descripcion = $encuestaCargo->descripcion; + }else{ + $descripcion = 'N/A'; + } */ + // preparamos los datos para el array final del cargo + $itemArray = array( //$descripcion, + $cargo->cargo->descripcion, + ); + $itemArrayNac = $itemArray; + $itemArrayInt = $itemArray; + // por cada item del detalle + //$cantConceptos = 0; + foreach ($respuesta as $key => $item) { + // dd($item); + switch ($key) { + case 'detalle_universo': + $this->CargaDetalle($item, $itemArray); + break; + + case 'detalle_nacional': + $this->CargaDetalle($item, $itemArrayNac); + break; + case 'detalleInternacional': + $this->CargaDetalle($item, $itemArrayInt); + break; + } + + } + //dd($itemArray); + $detalleUniverso->push($itemArray); + $detalleNacional->push($itemArrayNac); + $detalleInternacional->push($itemArrayInt); + } + + $this->excelClubCargos($detalleUniverso, $detalleNacional, $detalleInternacional, $rubro, $filename, $cubo); + + } public function resultados(){ diff --git a/app/Traits/ReportTrait.php b/app/Traits/ReportTrait.php index 04b62b9..2dfc78d 100644 --- a/app/Traits/ReportTrait.php +++ b/app/Traits/ReportTrait.php @@ -17,6 +17,7 @@ use App\Cargo_en; use App\Rubro; use App\User; +use PHPExcel_Worksheet_Drawing; use Hash; use DB; use Auth; @@ -3359,4 +3360,597 @@ public function getCargosHomologados($rubro, $periodo){ return $cargosIds; } + + public function excelClubCargos($detalleUniverso, $detalleNacional, $detalleInternacional, $rubro, $filename, $cubo = false){ + Excel::create($filename, function($excel) use($detalleUniverso, $detalleNacional, $detalleInternacional, $rubro, $cubo) { + // hoja universo + $excel->sheet("universo", function($sheet) use($detalleUniverso, $rubro, $cubo){ + + if(!$cubo){ + $rango = $this->cabeceraExcelFactory($sheet, $rubro); + + $sheet->rows($detalleUniverso); + $sheet->cells($rango, function($cells){ + $cells->setBackground('#a7ffeb'); + }); + $sheet->setFreeze('A7'); + }else{ + $rango = $this->cabeceraExcelFactoryCubo($sheet, $rubro); + + $sheet->rows($detalleUniverso); + $sheet->cells($rango, function($cells){ + $cells->setBackground('#a7ffeb'); + }); + $sheet->setFreeze('A6'); + } + + + + }); + // hoja nacional + $excel->sheet("nacional", function($sheet) use($detalleNacional, $rubro, $cubo){ + if(!$cubo){ + $rango = $this->cabeceraExcelFactory($sheet, $rubro); + + $sheet->rows($detalleNacional); + $sheet->cells($rango, function($cells){ + $cells->setBackground('#a7ffeb'); + }); + $sheet->setFreeze('A7'); + }else{ + $rango = $this->cabeceraExcelFactoryCubo($sheet, $rubro); + + $sheet->rows($detalleNacional); + $sheet->cells($rango, function($cells){ + $cells->setBackground('#a7ffeb'); + }); + $sheet->setFreeze('A6'); + } + + }); + // hoja internacional + $excel->sheet("internacional", function($sheet) use($detalleInternacional, $rubro, $cubo){ + + if(!$cubo){ + $rango = $this->cabeceraExcelFactory($sheet, $rubro); + + $sheet->rows($detalleInternacional); + $sheet->cells($rango, function($cells){ + $cells->setBackground('#a7ffeb'); + }); + $sheet->setFreeze('A7'); + }else{ + $rango = $this->cabeceraExcelFactoryCubo($sheet, $rubro); + + $sheet->rows($detalleInternacional); + $sheet->cells($rango, function($cells){ + $cells->setBackground('#a7ffeb'); + }); + $sheet->setFreeze('A6'); + } + + }); + + $excel->setActiveSheetIndex(0); + + })->export('xlsx'); + } + + private function cabeceraExcelFactory($sheet, $rubro){ + + $objDrawing = new PHPExcel_Worksheet_Drawing; + $objDrawing->setPath(public_path('images/logo.jpg')); //your image path + $objDrawing->setCoordinates('A1'); + $objDrawing->setWidthAndHeight(304,60); + $objDrawing->setWorksheet($sheet); + + $sheet->cell('A5', function($cell){ + $cell->setValue('CARGO'); + }); + $sheet->mergeCells('A5:D5'); + $sheet->cells('A5:D5', function($cells){ + $cells->setBackground('#00897b'); + $cells->setFontColor("#FFFFFF"); + $cells->setFontWeight("bold"); + // $cells->setValignment('center'); + $cells->setAlignment('center'); + }); + // Salario Base Header + $sheet->cell('E5', function($cell){ + $cell->setValue('SALARIO BASE'); + }); + $sheet->mergeCells('E5:J5'); + $sheet->cells('E5:J5', function($cells){ + $cells->setBackground('#0288d1'); + $cells->setFontColor("#FFFFFF"); + $cells->setFontWeight("bold"); + // $cells->setValignment('center'); + $cells->setAlignment('center'); + }); + if($rubro == 1){ + + // Salario Efectivo Anual Garantizado + $sheet->cell('K5', function($cell){ + $cell->setValue('EFECTIVO ANUAL GARANTIZADO'); + }); + $sheet->mergeCells('K5:P5'); + $sheet->cells('K5:P5', function($cells){ + $cells->setBackground('#388e3c'); + $cells->setFontColor("#FFFFFF"); + $cells->setFontWeight("bold"); + // $cells->setValignment('center'); + $cells->setAlignment('center'); + }); + + // Total Adicional Anual + $sheet->cell('Q5', function($cell){ + $cell->setValue('TOTAL ADICIONAL ANUAL'); + }); + $sheet->mergeCells('Q5:V5'); + $sheet->cells('Q5:V5', function($cells){ + $cells->setBackground('#fbc02d'); + $cells->setFontColor("#FFFFFF"); + $cells->setFontWeight("bold"); + // $cells->setValignment('center'); + $cells->setAlignment('center'); + }); + // Bono Anual + $sheet->cell('W5', function($cell){ + $cell->setValue('BONO ANUAL'); + }); + $sheet->mergeCells('W5:AB5'); + $sheet->cells('W5:AB5', function($cells){ + $cells->setBackground('#ffa000'); + $cells->setFontColor("#FFFFFF"); + $cells->setFontWeight("bold"); + // $cells->setValignment('center'); + $cells->setAlignment('center'); + }); + + // Comision + + $sheet->cell('AC5', function($cell){ + $cell->setValue('COMISION'); + }); + $sheet->mergeCells('AC5:AH5'); + $sheet->cells('AC5:AH5', function($cells){ + $cells->setBackground('#6a1b9a'); + $cells->setFontColor("#FFFFFF"); + $cells->setFontWeight("bold"); + // $cells->setValignment('center'); + $cells->setAlignment('center'); + }); + + + // Compensación Total Anual + $sheet->cell('AI5', function($cell){ + $cell->setValue('COMPENSACION TOTAL ANUAL'); + }); + $sheet->mergeCells('AI5:AN5'); + $sheet->cells('AI5:AN5', function($cells){ + $cells->setBackground('#0288d1'); + $cells->setFontColor("#FFFFFF"); + $cells->setFontWeight("bold"); + // $cells->setValignment('center'); + $cells->setAlignment('center'); + }); + // Salario Variable Anual comp. + $sheet->cell('AO5', function($cell){ + $cell->setValue('SALARIO BASE COMPARATIVO ORGANIZACION VS MERCADO'); + }); + $sheet->mergeCells('AO5:AT5'); + $sheet->cells('AO5:AT5', function($cells){ + $cells->setBackground('#afb42b'); + $cells->setFontColor("#FFFFFF"); + $cells->setFontWeight("bold"); + // $cells->setValignment('center'); + $cells->setAlignment('center'); + }); + + // Salario Variable Anual comp. + $sheet->cell('AU5', function($cell){ + $cell->setValue('RATIO SALARIO BASE ANUAL / TOTAL EFECTIVO ANUAL GARANTIZADO'); + }); + $sheet->mergeCells('AU5:AZ5'); + $sheet->cells('AU5:AZ5', function($cells){ + $cells->setBackground('#388e3c'); + $cells->setFontColor("#FFFFFF"); + $cells->setFontWeight("bold"); + // $cells->setValignment('center'); + $cells->setAlignment('center'); + }); + + $topeHeader = 8; + $rango = 'A6:AZ6'; + + }elseif($rubro == 4){ + // Salario Variable Anual + $sheet->cell('K5', function($cell){ + $cell->setValue('VARIABLE ANUAL'); + }); + $sheet->mergeCells('K5:P5'); + $sheet->cells('K5:P5', function($cells){ + $cells->setBackground('#afb42b'); + $cells->setFontColor("#FFFFFF"); + $cells->setFontWeight("bold"); + // $cells->setValignment('center'); + $cells->setAlignment('center'); + }); + // Total Adicional Anual + $sheet->cell('Q5', function($cell){ + $cell->setValue('TOTAL ADICIONAL ANUAL'); + }); + $sheet->mergeCells('Q5:V5'); + $sheet->cells('Q5:V5', function($cells){ + $cells->setBackground('#388e3c'); + $cells->setFontColor("#FFFFFF"); + $cells->setFontWeight("bold"); + // $cells->setValignment('center'); + $cells->setAlignment('center'); + }); + + // Bono Anual + $sheet->cell('W5', function($cell){ + $cell->setValue('BONO ANUAL'); + }); + $sheet->mergeCells('W5:AB5'); + $sheet->cells('W5:AB5', function($cells){ + $cells->setBackground('#fbc02d'); + $cells->setFontColor("#FFFFFF"); + $cells->setFontWeight("bold"); + // $cells->setValignment('center'); + $cells->setAlignment('center'); + }); + // Comisión + $sheet->cell('AC5', function($cell){ + $cell->setValue('COMISION'); + }); + $sheet->mergeCells('AC5:AH5'); + $sheet->cells('AC5:AH5', function($cells){ + $cells->setBackground('#ffa000'); + $cells->setFontColor("#FFFFFF"); + $cells->setFontWeight("bold"); + // $cells->setValignment('center'); + $cells->setAlignment('center'); + }); + + // Efectivo Total Anual + + $sheet->cell('AI5', function($cell){ + $cell->setValue('EFECTIVO TOTAL ANUAL'); + }); + $sheet->mergeCells('AI5:AN5'); + $sheet->cells('AI5:AN5', function($cells){ + $cells->setBackground('#6a1b9a'); + $cells->setFontColor("#FFFFFF"); + $cells->setFontWeight("bold"); + // $cells->setValignment('center'); + $cells->setAlignment('center'); + }); + + // Compensación Total Anual + $sheet->cell('AO5', function($cell){ + $cell->setValue('COMPENSACION ANUAL TOTAL'); + }); + $sheet->mergeCells('AO5:AT5'); + $sheet->cells('AO5:AT5', function($cells){ + $cells->setBackground('#f57c00'); + $cells->setFontColor("#FFFFFF"); + $cells->setFontWeight("bold"); + // $cells->setValignment('center'); + $cells->setAlignment('center'); + }); + // Salario Base Comparativo Header + $sheet->cell('AU5', function($cell){ + $cell->setValue('SALARIO BASE COMPARATIVO ORGANIZACION VS MERCADO'); + }); + $sheet->mergeCells('AU5:AZ5'); + $sheet->cells('AU5:AZ5', function($cells){ + $cells->setBackground('#0288d1'); + $cells->setFontColor("#FFFFFF"); + $cells->setFontWeight("bold"); + // $cells->setValignment('center'); + $cells->setAlignment('center'); + }); + // Salario Variable Anual comp. + $sheet->cell('BA5', function($cell){ + $cell->setValue('VARIABLE ANUAL COMPARATIVO ORGANIZACION VS MERCADO'); + }); + $sheet->mergeCells('BA5:BF5'); + $sheet->cells('BA5:BF5', function($cells){ + $cells->setBackground('#afb42b'); + $cells->setFontColor("#FFFFFF"); + $cells->setFontWeight("bold"); + // $cells->setValignment('center'); + $cells->setAlignment('center'); + }); + + // Salario Variable Anual comp. + $sheet->cell('BG5', function($cell){ + $cell->setValue('RATIO SALARIO BASE ANUAL / TOTAL EFECTIVO ANUAL'); + }); + $sheet->mergeCells('BG5:BL5'); + $sheet->cells('BG5:BL5', function($cells){ + $cells->setBackground('#fbc02d'); + $cells->setFontColor("#FFFFFF"); + $cells->setFontWeight("bold"); + // $cells->setValignment('center'); + $cells->setAlignment('center'); + }); + + $topeHeader = 10; + $rango = 'A6:BL6'; + + }else{ + // Salario Efectivo Anual Garantizado + $sheet->cell('K5', function($cell){ + $cell->setValue('EFECTIVO ANUAL GARANTIZADO'); + }); + $sheet->mergeCells('K5:P5'); + $sheet->cells('K5:P5', function($cells){ + $cells->setBackground('#388e3c'); + $cells->setFontColor("#FFFFFF"); + $cells->setFontWeight("bold"); + // $cells->setValignment('center'); + $cells->setAlignment('center'); + }); + + // Total Adicional Anual + $sheet->cell('Q5', function($cell){ + $cell->setValue('TOTAL ADICIONAL ANUAL'); + }); + $sheet->mergeCells('Q5:V5'); + $sheet->cells('Q5:V5', function($cells){ + $cells->setBackground('#fbc02d'); + $cells->setFontColor("#FFFFFF"); + $cells->setFontWeight("bold"); + // $cells->setValignment('center'); + $cells->setAlignment('center'); + }); + // Bono Anual + $sheet->cell('W5', function($cell){ + $cell->setValue('BONO ANUAL'); + }); + $sheet->mergeCells('W5:AB5'); + $sheet->cells('W5:AB5', function($cells){ + $cells->setBackground('#ffa000'); + $cells->setFontColor("#FFFFFF"); + $cells->setFontWeight("bold"); + // $cells->setValignment('center'); + $cells->setAlignment('center'); + }); + + // Comision + + $sheet->cell('AC5', function($cell){ + $cell->setValue('COMISION'); + }); + $sheet->mergeCells('AC5:AH5'); + $sheet->cells('AC5:AH5', function($cells){ + $cells->setBackground('#6a1b9a'); + $cells->setFontColor("#FFFFFF"); + $cells->setFontWeight("bold"); + // $cells->setValignment('center'); + $cells->setAlignment('center'); + }); + + // Efectivo Total Anual + $sheet->cell('AI5', function($cell){ + $cell->setValue('EFECTIVO TOTAL ANUAL'); + }); + $sheet->mergeCells('AI5:AN5'); + $sheet->cells('AI5:AN5', function($cells){ + $cells->setBackground('#f57c00'); + $cells->setFontColor("#FFFFFF"); + $cells->setFontWeight("bold"); + // $cells->setValignment('center'); + $cells->setAlignment('center'); + }); + // Compensación total anual + $sheet->cell('AO5', function($cell){ + $cell->setValue('COMPENSACION TOTAL ANUAL'); + }); + $sheet->mergeCells('AO5:AT5'); + $sheet->cells('AO5:AT5', function($cells){ + $cells->setBackground('#0288d1'); + $cells->setFontColor("#FFFFFF"); + $cells->setFontWeight("bold"); + // $cells->setValignment('center'); + $cells->setAlignment('center'); + }); + // Salario Variable Anual comp. + $sheet->cell('AU5', function($cell){ + $cell->setValue('SALARIO BASE COMPARATIVO ORGANIZACION VS MERCADO'); + }); + $sheet->mergeCells('AU5:AZ5'); + $sheet->cells('AU5:AZ5', function($cells){ + $cells->setBackground('#afb42b'); + $cells->setFontColor("#FFFFFF"); + $cells->setFontWeight("bold"); + // $cells->setValignment('center'); + $cells->setAlignment('center'); + }); + + // Salario Variable Anual comp. + $sheet->cell('BA5', function($cell){ + $cell->setValue('RATIO SALARIO BASE ANUAL / TOTAL EFECTIVO ANUAL'); + }); + $sheet->mergeCells('BA5:BF5'); + $sheet->cells('BA5:BF5', function($cells){ + $cells->setBackground('#fbc02d'); + $cells->setFontColor("#FFFFFF"); + $cells->setFontWeight("bold"); + // $cells->setValignment('center'); + $cells->setAlignment('center'); + }); + + $topeHeader = 9; + $rango = 'A6:BF6'; + } + + $itemsHeader = array("Mínimo", "25 Perc.", "Promedio", "Mediana", "75 Perc.", "Máximo"); + $cargoHeader = array("Cargo Company", "Oficial", "Ocupantes", "Casos"); + + for ($i= 0; $i < $topeHeader; $i++) { + foreach ($itemsHeader as $key => $value) { + array_push($cargoHeader, $value); + } + + } + + $sheet->row(6, $cargoHeader); + + return $rango; + + } + + private function cabeceraExcelFactoryCubo($sheet, $rubro){ + + $objDrawing = new PHPExcel_Worksheet_Drawing; + $objDrawing->setPath(public_path('images/logo.jpg')); //your image path + $objDrawing->setCoordinates('A1'); + $objDrawing->setWidthAndHeight(304,60); + $objDrawing->setWorksheet($sheet); + + + + + $header = array("CARGO OFICIAL", "OCUPANTES", "CASOS"); + + + $sbHeader = array("SB Min", "SB 25P", "SB Prom", "SB Med", "SB 75P", "SB Max"); + + $header = $this->headerFactory($header, $sbHeader); + + if($rubro == 1){ + + $eagHeader = array("EAG Min", "EAG 25P", "EAG Prom", "EAG Med", "EAG 75P", "EAG Max"); + + $header = $this->headerFactory($header, $eagHeader); + + $taHeader = array("TA Min", "TA 25P", "TA Prom", "TA Med", "TA 75P", "TA Max"); + + $header = $this->headerFactory($header, $taHeader); + + $baHeader = array("BA Min", "BA 25P", "BA Prom", "BA Med", "BA 75P", "BA Max"); + + $header = $this->headerFactory($header, $baHeader); + + $caHeader = array("CA Min", "CA 25P", "CA Prom", "CA Med", "CA 75P", "CA Max"); + + $header = $this->headerFactory($header, $caHeader); + + + $ctaHeader = array("CTA Min", "CTA 25P", "CTA Prom", "CTA Med", "CTA 75P", "CTA Max"); + + $header = $this->headerFactory($header, $ctaHeader); + + $sbmHeader = array("sbm Min", "sbm 25P", "sbm Prom", "sbm Med", "sbm 75P", "sbm Max"); + + $header = $this->headerFactory($header, $sbmHeader); + + $sbRatioHeader = array("sbRatio Min", "sbRatio 25P", "sbRatio Prom", "sbRatio Med", "sbRatio 75P", "sbRatio Max"); + + $header = $this->headerFactory($header, $sbRatioHeader); + + $topeHeader = 8; + $rango = 'A5:AZ5'; + + }elseif($rubro == 4){ + $varHeader = array("VAR Min", "VAR 25P", "VAR Prom", "VAR Med", "VAR 75P", "VAR Max"); + + $header = $this->headerFactory($header, $varHeader); + + $taHeader = array("TA Min", "TA 25P", "TA Prom", "TA Med", "TA 75P", "TA Max"); + + $header = $this->headerFactory($header, $taHeader); + + $baHeader = array("BA Min", "BA 25P", "BA Prom", "BA Med", "BA 75P", "BA Max"); + + $header = $this->headerFactory($header, $baHeader); + + $caHeader = array("CA Min", "CA 25P", "CA Prom", "CA Med", "CA 75P", "CA Max"); + + $header = $this->headerFactory($header, $caHeader); + + $etaHeader = array("ETA Min", "ETA 25P", "ETA Prom", "ETA Med", "ETA 75P", "ETA Max"); + + $header = $this->headerFactory($header, $etaHeader); + + $ctaHeader = array("CTA Min", "CTA 25P", "CTA Prom", "CTA Med", "CTA 75P", "CTA Max"); + + $header = $this->headerFactory($header, $ctaHeader); + + $sbmHeader = array("sbm Min", "sbm 25P", "sbm Prom", "sbm Med", "sbm 75P", "sbm Max"); + + $header = $this->headerFactory($header, $sbmHeader); + + $varCompHeader = array("VARCOMP Min", "VARCOMP 25P", "VARCOMP Prom", "VARCOMP Med", "VARCOMP 75P", "VARCOMP Max"); + + $header = $this->headerFactory($header, $varCompHeader); + + $header = $this->headerFactory($header, $sbmHeader); + + $sbRatioHeader = array("sbRatio Min", "sbRatio 25P", "sbRatio Prom", "sbRatio Med", "sbRatio 75P", "sbRatio Max"); + + $header = $this->headerFactory($header, $sbRatioHeader); + + + $topeHeader = 10; + $rango = 'A5:BL5'; + + }else{ + $eagHeader = array("EAG Min", "EAG 25P", "EAG Prom", "EAG Med", "EAG 75P", "EAG Max"); + + $header = $this->headerFactory($header, $eagHeader); + + $taHeader = array("TA Min", "TA 25P", "TA Prom", "TA Med", "TA 75P", "TA Max"); + + $header = $this->headerFactory($header, $taHeader); + + $baHeader = array("BA Min", "BA 25P", "BA Prom", "BA Med", "BA 75P", "BA Max"); + + $header = $this->headerFactory($header, $baHeader); + + $caHeader = array("CA Min", "CA 25P", "CA Prom", "CA Med", "CA 75P", "CA Max"); + + $header = $this->headerFactory($header, $caHeader); + + + $etaHeader = array("ETA Min", "ETA 25P", "ETA Prom", "ETA Med", "ETA 75P", "ETA Max"); + + $header = $this->headerFactory($header, $etaHeader); + + $ctaHeader = array("CTA Min", "CTA 25P", "CTA Prom", "CTA Med", "CTA 75P", "CTA Max"); + + $header = $this->headerFactory($header, $ctaHeader); + + $sbmHeader = array("SBM Min", "SBM 25P", "SBM Prom", "SBM Med", "SBM 75P", "SBM Max"); + + $header = $this->headerFactory($header, $sbmHeader); + + + $sbRatioHeader = array("SBRATIO Min", "SBRATIO 25P", "SBRATIO Prom", "SBRATIO Med", "SBRATIO 75P", "SBRATIO Max"); + + $header = $this->headerFactory($header, $sbRatioHeader); + + + $topeHeader = 9; + $rango = 'A5:BF5'; + } + + $sheet->row(5, $header); + + return $rango; + + } + + private function headerFactory($header, $itemHeader){ + + foreach ($itemHeader as $key => $value) { + array_push($header, $value); + } + + return $header; + } } \ No newline at end of file diff --git a/resources/views/admin/reportes/filter_cargos.blade.php b/resources/views/admin/reportes/filter_cargos.blade.php new file mode 100644 index 0000000..e25db25 --- /dev/null +++ b/resources/views/admin/reportes/filter_cargos.blade.php @@ -0,0 +1,64 @@ +@extends('layout') +@section('content') +
+
+
+

Reporte de Cargos

+
+
+
+
+
+ + +
+
+ + +
+
+ + +
+
+
+
+@stop +@push('scripts') + +@endpush \ No newline at end of file diff --git a/resources/views/admin/reportes/filter_niveles.blade.php b/resources/views/admin/reportes/filter_niveles.blade.php index 6a7b5a2..c5059db 100644 --- a/resources/views/admin/reportes/filter_niveles.blade.php +++ b/resources/views/admin/reportes/filter_niveles.blade.php @@ -3,7 +3,7 @@
-

Seleccionar Periodo

+

Reporte de Niveles

diff --git a/resources/views/layout.blade.php b/resources/views/layout.blade.php index 193c047..a3a0b3b 100644 --- a/resources/views/layout.blade.php +++ b/resources/views/layout.blade.php @@ -47,6 +47,7 @@
  • Excel
  • Reporte - Cargos
  • Reporte - Niveles
  • +
  • Cubo - Cargos
  • @if(Auth::check()) diff --git a/routes/web.php b/routes/web.php index d64337b..acf9b57 100644 --- a/routes/web.php +++ b/routes/web.php @@ -146,8 +146,10 @@ Route::get('admin_reportes_filter', 'Admin\ReportController@index')->name('admin.reporte.filter'); Route::get('admin_reportes_filter/niveles', 'Admin\ReportController@filterNiveles')->name('admin.reporte.filter.niveles'); + Route::get('admin_reportes_filter/cargos', 'Admin\ReportController@filterCargos')->name('admin.reporte.filter.cargos'); Route::post('admin_reportes_filter/periodos', 'Admin\ReportController@getPeriodosEmpresa')->name('admin.reporte.filter.periodos'); Route::post('admin_reportes_excel/niveles', 'ReporteController@nivelReportClubExcel')->name('reportes.nivelesClubExcel'); + Route::post('admin_reportes_excel/cargos', 'ReporteController@cargosReportExcel')->name('reportes.cargosExcel'); Route::post('admin_ficha/contar_emergentes', 'FichasController@countEmergentes')->name('admin.ficha.contar'); Route::resource('admin_ficha', 'FichasController');