Skip to content

Commit

Permalink
clonar nacional before
Browse files Browse the repository at this point in the history
  • Loading branch information
elsoftpy committed Jul 15, 2020
1 parent ec0552b commit 2d88b78
Show file tree
Hide file tree
Showing 7 changed files with 154 additions and 28 deletions.
2 changes: 1 addition & 1 deletion app/Http/Controllers/EncuestasCargosController.php
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ public function getCargos($id){
//$dbCargos->prepend("Elija una opción", "0");
$index = 0;
$dbData = $dbData->map(function($item) use($dbCargos, $index){
$cargos = '';
$cargos = '<option value="">No homologado aun...</option>';
foreach ($dbCargos as $id => $cargo) {
//dd($cargo, $item);
if($id == $item->cargo_id ){
Expand Down
68 changes: 68 additions & 0 deletions app/Http/Controllers/EncuestasController.php
Original file line number Diff line number Diff line change
Expand Up @@ -473,4 +473,72 @@ public function clonarIndustrial(Request $request){

return redirect()->route('clonar.industrial')->with('toast', $toast);
}

public function cloneBancosNacionales()
{
return view('encuestas.clonar_bancos_nacional')->with('toast', false);
}

public function clonarBancosNacionales(Request $request){
ini_set('max_execution_time', 0);
ini_set('memory_limit', '500M');
$periodo = $request->periodo;

$encuestas = Cabecera_encuesta::where('periodo', $periodo)
->where('rubro_id', 1)
->whereIn('empresa_id', [1, 2, 5, 6, 8, 10, 53])
->get();
foreach($encuestas as $encuesta){
$cabecera = $encuesta->replicate();
$cabecera->rubro_id = 12;

switch ($cabecera->empresa_id) {
case 1:
$cabecera->empresa_id = 179;
break;
case 2:
$cabecera->empresa_id = 185;
break;
case 5:
$cabecera->empresa_id = 184;
break;

case 6:
$cabecera->empresa_id = 180;
break;
case 8:
$cabecera->empresa_id = 183;
break;
case 10:
$cabecera->empresa_id = 182;
break;
case 53:
$cabecera->empresa_id = 181;
break;

default:
$cabecera->empresa_id = 186;
break;
}
$cabecera->save();
$encuestaCargo = $encuesta->encuestasCargo;
foreach($encuestaCargo as $cargo){
$newCargo = $cargo->replicate();
$newCargo->cabecera_encuesta_id = $cabecera->id;
$newCargo->save();
$detalle = $cargo->detalleEncuestas;
if($detalle){
$newDetalle = $detalle->replicate();
$newDetalle->cabecera_encuesta_id = $cabecera->id;
$newDetalle->encuestas_cargo_id = $newCargo->id;
$newDetalle->save();
}
}

}

$toast = true;

return redirect()->route('clonar.bancard')->with('toast', $toast);
}
}
4 changes: 2 additions & 2 deletions app/Http/Controllers/ReporteController_bkp.php
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ public function ficha($id){
}else{
$cargos = 174;
}
}elseif($rubro == 1){
}elseif($rubro == 1 || $rubro == 15){
$cargos = 400;
}elseif($rubro == 2){
$cargos = 172;
Expand Down Expand Up @@ -1400,7 +1400,7 @@ private function segmenter( &$collection,
$segmento,
$dbCargo,
$muestraComision){
if($rubro == 1 ){ // Bancos
if($rubro == 1 || $rubro == 15){ // Bancos
$salariosBase = $detalle->where('salario_base', '>', '0')->pluck('salario_base');
$salarioMin = $salariosBase->min();
$salarioMax = $salariosBase->max();
Expand Down
40 changes: 20 additions & 20 deletions app/Traits/ReportTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -249,25 +249,25 @@ public function cargaDetalle($item, &$itemArray){
}

array_push( $itemArray,
$compMinSal,
$comp25PercSal,
$compPromSal,
$compMedSal,
$comp75PercSal,
$compMaxSal,
$ratioSalBaseTotalEfectivoMin,
$ratioSalBaseTotalEfectivo25,
$ratioSalBaseTotalEfectivoProm,
$ratioSalBaseTotalEfectivoMed,
$ratioSalBaseTotalEfectivo75,
$ratioSalBaseTotalEfectivoMax,
$ratioSalEmpresaTotalEfectivoMin,
$ratioSalEmpresaTotalEfectivo25,
$ratioSalEmpresaTotalEfectivoProm,
$ratioSalEmpresaTotalEfectivoMed,
$ratioSalEmpresaTotalEfectivo75,
$ratioSalEmpresaTotalEfectivoMax,
);
$compMinSal,
$comp25PercSal,
$compPromSal,
$compMedSal,
$comp75PercSal,
$compMaxSal,
$ratioSalBaseTotalEfectivoMin,
$ratioSalBaseTotalEfectivo25,
$ratioSalBaseTotalEfectivoProm,
$ratioSalBaseTotalEfectivoMed,
$ratioSalBaseTotalEfectivo75,
$ratioSalBaseTotalEfectivoMax,
$ratioSalEmpresaTotalEfectivoMin,
$ratioSalEmpresaTotalEfectivo25,
$ratioSalEmpresaTotalEfectivoProm,
$ratioSalEmpresaTotalEfectivoMed,
$ratioSalEmpresaTotalEfectivo75,
$ratioSalEmpresaTotalEfectivoMax,
);
}else{

if($itemArray[10] > 0){
Expand Down Expand Up @@ -377,7 +377,7 @@ public function segmenter( &$collection,
$segmento,
$dbCargo,
$muestraComision){
if($rubro == 1 ){ // Bancos
if($rubro == 1 || $rubro == 15 ){ // Bancos
$salariosBase = $detalle->where('salario_base', '>', '0')->pluck('salario_base');
$salarioMin = $salariosBase->min();
$salarioMax = $salariosBase->max();
Expand Down
9 changes: 4 additions & 5 deletions resources/views/cargos_clientes/sheet.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@

<div class="row">
<div class="input-field col s12">
input.validate
<select name="area_id" id="area_id">
<option value="" disabled selected>Elija una opción</option>
@foreach($dbArea as $id=>$descripcion)
Expand Down Expand Up @@ -300,13 +299,13 @@
<div class="row">
<div class="input-field col s12">
<select name="zona_id" id="zona_id">
<option value="" disabled selected>Elija una opción</option>
<option value="" disabled selected>@lang("cargosClientesEdit.select_label_choose")</option>
@foreach($dbZona as $id=>$descripcion)
<option value="{{$id}}">{{$descripcion}}</option>
@endforeach

</select>
<label for="zona_id">Región</label><br>
<label for="zona_id" class="active">@lang("cargosClientesEdit.form_label_region")</label><br>
</div>
</div>
<div class="row">
Expand All @@ -329,7 +328,7 @@
@push('scripts')
<script type="text/javascript">
$(document).ready(function() {
$('select').material_select();
$('select').select2();
});
$('#area_id').val('{{ $dbDetalle->area_id}}');
Expand All @@ -354,7 +353,7 @@ function(json){
.text(data[i].text));
}
selectModelos.material_select();
selectModelos.select2();
}
);
});
Expand Down
55 changes: 55 additions & 0 deletions resources/views/encuestas/clonar_bancos_nacional.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
@extends('layout')
@section('content')
<div class="row">
<div class="browser-window">
<div class="top-bar">
<h4>Clonar Periodo Bancard</h4>
</div>
<div class="content">
<form class="col s12" id="realForm" action="{{route('clonar.bancos.nacional.action')}}" method="POST">
<div class="row">
<div class="input-field col s6">
<input type="text" class="validate" id="periodo" name="periodo"/>
<label for="periodo">Periodo</label>
</div>
</div>
<input type="hidden" name="_token" value="{{{ csrf_token() }}}" />
<div class="button-group">
<button class="btn waves-effect waves-light" type="submit" name="submit">Guardar
<i class="material-icons left">save</i>
</button>
</div>
</form>
</div>
</div>
</div>
@if($toast)
<div id="toast"></div>
@endif
@stop
@push('scripts')
<script>
if($("#toast").length > 0){
M.toast({html: 'Archivo Procesado'});
}
var options = [];
$('#realForm').submit(function(e){
if($('#fields').val() === ''){
e.preventDefault();
}
});
$('#realForm').keypress(function(event){
if (event.keyCode === 10 || event.keyCode === 13){
event.preventDefault();
}
});
$(document).ready(function() {
$('select').select2();
});
</script>
@endpush
4 changes: 4 additions & 0 deletions routes/web.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@
'as'=> 'encuestas.clone'
]);

Route::get('clone_banca_nacional', 'EncuestasController@cloneBancosNacionales')->name('clonar.BancosNacionales');

Route::post('clone_banca_nacional', 'EncuestasController@clonarBancosNacionales')->name('clonar.BancosNacionalesAction');

Route::get('clone_bancard', 'EncuestasController@cloneBancard')->name('clonar.bancard');

Route::post('clone_bancard', 'EncuestasController@clonarBancard')->name('clonar.bancardAction');
Expand Down

0 comments on commit 2d88b78

Please sign in to comment.