diff --git a/app/Http/Livewire/ShowPlanes.php b/app/Http/Livewire/ShowPlanes.php index 8f3a451..e1b5536 100644 --- a/app/Http/Livewire/ShowPlanes.php +++ b/app/Http/Livewire/ShowPlanes.php @@ -472,6 +472,10 @@ class ShowPlanes extends Component $tarifa = json_decode($this->tarifa, true); + + + // dd($tarifa) + //dd($this->tarifa['dias']); $usuario_existe = User::firstWhere('email', $this->searchTerm)->id ?? null; $usuario_id = $usuario_existe; @@ -484,11 +488,12 @@ class ShowPlanes extends Component $usuario->password = '123456'; $usuario->celular = '+57'; $usuario->rol_id = $rol_id; - $usuario->save(); + // $usuario->save(); $usuario_id = $usuario->id; } + dd($this->tarifa); $historial = new Historiale; $historial->fecha_inicio = Carbon::now(); @@ -500,28 +505,59 @@ class ShowPlanes extends Component $historial->tarifa_id = $tarifa['id']; $historial->cliente_id = $usuario_id; $historial->cantidad = $tarifa['pantallas']; - $historial->save(); + // $historial->save(); - $consultaHC = Historial_cuenta::where('cuenta_id', $this->consulta_verUsuarios->id)->where('perfil', $this->perfil)->exists(); - if (!$consultaHC) { + if ($this->consulta_verUsuarios->estado == 'pendiente') { // completa + $perfiles = $this->consulta_verUsuarios->servicio->completa; + } + + if ($this->consulta_verUsuarios->estado == 'activo') { // pantallas + $perfiles = $this->consulta_verUsuarios->servicio->pantallas; + } + + + dd($this->consulta_verUsuarios); + + + + $consultaHC = Historial_cuenta::where('cuenta_id', $this->consulta_verUsuarios->id)->orderBy('created_at', 'desc')->first()->perfil ?? 0; + + if ($consultaHC) { + if ($consultaHC < 5) { + $historial_cuenta = new Historial_cuenta; + $historial_cuenta->cuenta_id = $this->consulta_verUsuarios->id; + $historial_cuenta->historial_id = $historial->id; + $historial_cuenta->perfil = $consultaHC + 1; + // $historial_cuenta->save(); + + $this->alert('success', 'Usuario añadido correctamente!', [ + 'position' => 'top' + ]); + + + $this->addUser = false; + $this->consulta_verUsuarios = Cuentas::with('historiales', 'servicio')->where('id', $this->id_cuentaVer)->first(); + }else{ + $historial->delete(); + $this->alert('warning', 'Ya haz alcanzado el maximo de perfiles!', [ + 'position' => 'top' + ]); + } + } else { $historial_cuenta = new Historial_cuenta; $historial_cuenta->cuenta_id = $this->consulta_verUsuarios->id; $historial_cuenta->historial_id = $historial->id; - $historial_cuenta->perfil = $this->perfil; - $historial_cuenta->save(); - + $historial_cuenta->perfil = $consultaHC + 1; + // $historial_cuenta->save(); + $this->alert('success', 'Usuario añadido correctamente!', [ 'position' => 'top' ]); + $this->addUser = false; $this->consulta_verUsuarios = Cuentas::with('historiales', 'servicio')->where('id', $this->id_cuentaVer)->first(); - } else { - $historial->delete(); - $this->alert('warning', 'El perfil ya se encuentra en uso!', [ - 'position' => 'top' - ]); } } diff --git a/resources/views/components/listado-planes.blade.php b/resources/views/components/listado-planes.blade.php index d556a10..fbe6374 100644 --- a/resources/views/components/listado-planes.blade.php +++ b/resources/views/components/listado-planes.blade.php @@ -55,8 +55,7 @@

Ocupado

@endif @else -

+

{{ $cuenta->historiales_count ?? '0' }}/{{ $cuenta->servicio->pantallas ?? '0' }} @endif @if ($historiales >= '1') {{ $historiales }} diff --git a/resources/views/livewire/show-planes.blade.php b/resources/views/livewire/show-planes.blade.php index 1fc87be..a596eb1 100644 --- a/resources/views/livewire/show-planes.blade.php +++ b/resources/views/livewire/show-planes.blade.php @@ -6,8 +6,8 @@ serviciosModal: @entangle('serviciosModal'), ver: false, renovar: @entangle('renovar'), - addUser:@entangle('addUser'), - editarTarifaRol:@entangle('editarTarifaRol'), + addUser: @entangle('addUser'), + editarTarifaRol: @entangle('editarTarifaRol'), }" class="h-full w-full md:my-2">

+
+ xmlns:svgjs="http://svgjs.com/svgjs" version="1.1" x="0" y="0" viewBox="0 0 24 24" + style="enable-background:new 0 0 512 512" xml:space="preserve"> Planes
- + Nueva cuenta + id="Capa_1" x="0px" y="0px" viewBox="0 0 512 512" style="enable-background:new 0 0 512 512;" + xml:space="preserve" class="w-[0.87rem] ml-2"> - @if ( auth()->user()->rol->nombre != "editor") - - Modificar tarifas - - - - - + @if (auth()->user()->rol->nombre != 'editor') + + Modificar tarifas + + + + + @endif
@@ -72,8 +70,8 @@ class="w-full md:w-auto shadow-md border-2 active:border-neutral-200 focus:ring-0 border-neutral-200 rounded-[0.8rem] pr-7 py-1 m-auto focus:border-neutral-300 focus:outline-none focus:shadow-outline"> + x="0" y="0" viewBox="0 0 24 24" style="enable-background:new 0 0 512 512;rotate: 90deg;" + xml:space="preserve" class="">
- -
- + +
+ -
-
- +
+
+ +
+
+ + + +
+
+
+ +
- - - + +
-
- - -
-
- - -
-
- - -
- - + +
- @if (auth()->user()->rol->nombre != "editor") + + +
+ @if (auth()->user()->rol->nombre != 'editor')
- +
- @endif - - + @endif + +
- - - - - - + + + +
@@ -440,61 +446,71 @@ class="fixed backdrop-blur-sm bg-black/20 left-0 bottom-0 top-0 right-0 h-full z-20">
-
- - + + - + @if ($usuarios) @foreach ($usuarios as $option) @endforeach @endif -
- @if(!empty($consulta_verUsuarios->servicio->perfiles)) + {{-- @if (!empty($consulta_verUsuarios->servicio->perfiles))
- + @if ($consulta_verUsuarios) @php $pantallas = $consulta_verUsuarios->servicio->pantallas; @endphp - @for($i = 1; $i <= $pantallas; $i++) + @for ($i = 1; $i <= $pantallas; $i++) @endfor @endif
- @endif - @if(!empty($consulta_verUsuarios->servicio->tarifas )) - - + + @foreach ($consulta_verUsuarios->servicio->tarifas as $tarifaItem) + @if ($consulta_verUsuarios->estado == 'pendiente' && $tarifaItem->rol_id == '5' ) + @if ($tarifaItem->pantallas == $tarifaItem->servicio->completa) + @if ($tarifaItem->servicio->por_tiempo) + @else - - @endif + + @endif @endif - @endforeach - - @error('tarifa')

{{ 'Requerido*' }}

@enderror - @endif + @else + @if ($tarifaItem->pantallas == '1' && $tarifaItem->rol_id == '5') + @if ($tarifaItem->servicio->por_tiempo) + + @else + + @endif + @endif + @endif + @endforeach + + @error('tarifa') +

{{ 'Requerido*' }}

+ @enderror + @endif + -
@@ -598,12 +614,13 @@ @endforeach - @error('servicio_newCuenta')
{{ 'Requerido*' }}
@enderror + @error('servicio_newCuenta') +
{{ 'Requerido*' }}
+ @enderror
@@ -622,19 +641,23 @@ class="block text-gray-700 text-sm font-bold mb-2">Contraseña: - @error('password_newCuenta')
{{ 'Requerido*' }}
@enderror + @error('password_newCuenta') +
{{ 'Requerido*' }}
+ @enderror
- - - @error('estado')
{{ 'Requerido*' }}
@enderror - + + + @error('estado') +
{{ 'Requerido*' }}
+ @enderror +
@@ -643,7 +666,9 @@ inicio: - @error('fecha_inicial')
{{ 'Requerido*' }}
@enderror + @error('fecha_inicial') +
{{ 'Requerido*' }}
+ @enderror
@@ -651,7 +676,9 @@ Final: - @error('fecha_final')
{{ 'Requerido*' }}
@enderror + @error('fecha_final') +
{{ 'Requerido*' }}
+ @enderror
@@ -693,8 +720,7 @@ - - - @endforeach + + @endforeach @endif
- - + +
@@ -801,78 +831,81 @@
-
-
- @if($informacionTarifaRol) -
- -
-
- - -
-
- - -
-
- - -
-
- - + x-transition:enter-start="opacity-0 scale-100" x-transition:enter-end="opacity-100 scale-100" + x-transition:leave="transition duration-350" x-transition:leave-start="opacity-100 scale-100" + x-transition:leave-end="opacity-0 scale-100" + class="fixed backdrop-blur-sm bg-black/20 left-0 bottom-0 top-0 right-0 h-full z-20"> +
+
+ @if ($informacionTarifaRol) +
+ +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+ +
+
+ + +
+ +
+ + +
+
+ + + +
+
+
+ @endif + + + +
+ + + +
-
-
- - -
- -
- - -
-
- - - -
-
- @endif - - - -
- - - - -
-
-
{{-- Modal agregar servicios --}}
@else -
+
@endif
@@ -906,10 +938,11 @@
- + class="text-white bg-[#B221FD] hover:bg-[#7a02b8] px-3 py-1 rounded-md cursor-pointer">Img + inicio + +
@@ -917,8 +950,7 @@ @else -
+
@endif
@@ -968,7 +1000,7 @@
- @include('layouts.footer') + @include('layouts.footer')