Skip to content

Commit

Permalink
Cambios varios
Browse files Browse the repository at this point in the history
  • Loading branch information
elsoftpy committed Feb 27, 2021
1 parent 5f3d1d7 commit 0d754cb
Show file tree
Hide file tree
Showing 9 changed files with 147 additions and 12 deletions.
2 changes: 1 addition & 1 deletion app/Http/Controllers/EncuestasCargosController.php
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ public function addCargoStore(Request $request, $id){
public function getCargos($id){
ini_set('memory_limit', '1020M');
ini_set('max_execution_time', 300);
$dbData = Encuestas_cargo::where('cabecera_encuesta_id', $id)->get();
$dbData = Encuestas_cargo::where('cabecera_encuesta_id', $id)->with('detalleEncuestas')->get();
$dbEncuesta = Cabecera_encuesta::find($id);
$dbEmpresa = $dbEncuesta->empresa->descripcion;
$dbPeriodo = $dbEncuesta->periodo;
Expand Down
2 changes: 2 additions & 0 deletions app/Http/Controllers/ReporteController.php
Original file line number Diff line number Diff line change
Expand Up @@ -1241,6 +1241,7 @@ public function cargosReportExcel(Request $request){
$request->request->add(["cargo_id"=> $cargo->cargo_id, "empresa_id" => $empresa]);
// procesamos el reporte
$respuesta = $this->cargoReportAll($request, "clubExcel", true);

$filename = 'Cubo_Resultados_'.$periodo;

// preparamos los datos para el array final del cargo
Expand All @@ -1252,6 +1253,7 @@ public function cargosReportExcel(Request $request){
// por cada item del detalle
//$cantConceptos = 0;
foreach ($respuesta as $key => $item) {

switch ($key) {
case 'detalle_universo':
$this->CargaDetalle($item, $itemArray);
Expand Down
25 changes: 19 additions & 6 deletions app/Traits/ReportTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,13 @@ public function countEmergentesSegmento($rubro, $subRubro, $periodo){
return $count;
}
public function cargaDetalle($item, &$itemArray){

$variableAnual = false;
$efectivoTotal = false;
$efectivoGarantizado = false;
$salarioEmpresa = 0;
$variableAnualEmp = 0;

//dd($item, $itemArray);
foreach ($item as $key => $value) {
switch ($value["Concepto"]) {
case "Comision":
Expand Down Expand Up @@ -180,7 +181,13 @@ public function cargaDetalle($item, &$itemArray){
$ratioSalBaseTotalEfectivo75 = 0;
}
if($itemArray[39] > 0){
$ratioSalBaseTotalEfectivoMax = round(($itemArray[9]*12)/$itemArray[39], 2);

if($itemArray[9] > 0){
$ratioSalBaseTotalEfectivoMax = round(($itemArray[9]*12)/$itemArray[39], 2);
}else{
$ratioSalBaseTotalEfectivoMax = 0;
}

}else{
$ratioSalBaseTotalEfectivoMax = 0;
}
Expand Down Expand Up @@ -668,13 +675,14 @@ public function segmenter( &$collection,
}elseif ($rubro == 4) { // Navieras
// Salario Base
$salariosBase = $detalle->where('salario_base', '>', '0')->pluck('salario_base');

$salarioMin = $salariosBase->min();
$salarioMax = $salariosBase->max();
$salarioProm = $salariosBase->avg();
$salarioMed = $this->median($salariosBase);
$salario25Per = $this->percentile(25,$salariosBase);
$salario75Per = $this->percentile(75, $salariosBase);

//dd($salariosBase);
$this->pusher( $collection,
$countCasos,
Lang::get('reportReport.concept_salary'),
Expand All @@ -686,7 +694,9 @@ public function segmenter( &$collection,
round($salario75Per, 0),
$dbClienteEnc->salario_base,
$segmento,
$dbCargo);
$dbCargo);


// Salario Base Anual
$salariosBaseAnual = $salariosBase->map(function($item){
return $item * 12;
Expand Down Expand Up @@ -976,6 +986,7 @@ public function segmenter( &$collection,

//Beneficios
$beneficiosNavieras = $detalle->where('beneficios_navieras', '>', '0')->pluck('beneficios_navieras');

$beneficiosMin = $beneficiosNavieras->min();
$beneficiosMax = $beneficiosNavieras->max();
$beneficiosProm = $beneficiosNavieras->avg();
Expand All @@ -992,7 +1003,7 @@ public function segmenter( &$collection,
round($beneficiosMed, 0),
round($beneficios25Per, 0),
round($beneficios75Per, 0),
$dbClienteEnc->beneficios_bancos,
$dbClienteEnc->beneficios_navieras,
$segmento,
$dbCargo);

Expand Down Expand Up @@ -2438,6 +2449,7 @@ public function cargoReportAll(Request $request, $tipo, $muestraComision = true)
->where('cargo_id', $cargo)
->where('incluir', 1)
->get();


$dbCargosEncuestasNac = Encuestas_cargo::whereIn('cabecera_encuesta_id', $encuestadasNacIds)->where('cargo_id', $cargo)->where('incluir', 1)->get();
$dbCargosEncuestasInter = Encuestas_cargo::whereIn('cabecera_encuesta_id', $encuestadasInterIds)->where('cargo_id', $cargo)->where('incluir', 1)->get();
Expand All @@ -2448,6 +2460,7 @@ public function cargoReportAll(Request $request, $tipo, $muestraComision = true)

// Recuperamos los datos de las encuestas
$dbDetalle = Detalle_encuesta::whereIn('encuestas_cargo_id', $cargosEncuestasIds)->get();

// Datos de la encuesta llenada por el cliente
$dbClienteEnc = $dbDetalle->where('cabecera_encuesta_id', $dbEncuesta->id)->first();
if(empty($dbClienteEnc)){
Expand All @@ -2462,7 +2475,7 @@ public function cargoReportAll(Request $request, $tipo, $muestraComision = true)
$countCasos = $dbDetalle->where('cantidad_ocupantes', '>', '0')
->unique('cabecera_encuesta_id')
->count();

$countOcupantes = $dbDetalle->sum('cantidad_ocupantes');
$countCasosGratif = $dbDetalle->where('cantidad_ocupantes', '>', '0')
->where('gratificacion', '>', '0')
Expand Down
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
"php": ">=5.6.4",
"laravel/framework": "5.3.*",
"maatwebsite/excel": "^2.1",
"barryvdh/laravel-dompdf": "^0.8.1"
"barryvdh/laravel-dompdf": "^0.8.1",
"barryvdh/laravel-debugbar": "~2.4"
},
"require-dev": {
"fzaninotto/faker": "~1.4",
Expand Down
119 changes: 117 additions & 2 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions config/app.php
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,7 @@
elsoftpy\Utiles\Flash\elsoftpyFlashProvider::class,
Maatwebsite\Excel\ExcelServiceProvider::class,
Barryvdh\DomPDF\ServiceProvider::class,
Barryvdh\Debugbar\ServiceProvider::class,


],
Expand Down Expand Up @@ -239,6 +240,7 @@
'flash' => elsoftpy\Utiles\Flash\Flash::class,
'Excel' => 'Maatwebsite\Excel\Facades\Excel',
'PDF' => Barryvdh\DomPDF\Facade::class,
'Debugbar' => Barryvdh\Debugbar\Facade::class,


],
Expand Down
2 changes: 1 addition & 1 deletion resources/lang/es/reportReport.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
"concept_variable_pay_trip" => "Variable por Viaje",
"concept_mooring" => "Adicional por Amarre",
"concept_fuel_type" => "Adicional por Tipo de Combustible",
"concept_shipping" => "Adicional por Disponibilidad/Emarque",
"concept_shipping" => "Adicional por Disponibilidad/Embarque",
"concept_load" => "Adicional por Carga",
"concept_total_benefits" => "Total Beneficios Anual",
"concept_annual_cash_total" => "Efectivo Total Anual",
Expand Down
2 changes: 1 addition & 1 deletion resources/views/report/cargos_club.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
</div>
</div>
<div class="col s12">
<h4>Club {!! $club !!}</h4>
<h4> {!! $club !!}</h4>
<div class="hoverable bordered">
<ul class="collapsible" data-collapsible="expandable">
@foreach ($niveles as $element)
Expand Down
2 changes: 2 additions & 0 deletions storage/debugbar/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
*
!.gitignore

0 comments on commit 0d754cb

Please sign in to comment.