diff --git a/app/Http/Livewire/ShowPlanes.php b/app/Http/Livewire/ShowPlanes.php index bb86aee..5dd5358 100755 --- a/app/Http/Livewire/ShowPlanes.php +++ b/app/Http/Livewire/ShowPlanes.php @@ -277,7 +277,11 @@ class ShowPlanes extends Component { $id = $this->id_cuentaVer; - Historial_cuenta::where('cuenta_id', $id)->delete(); + $historial = Historial_cuenta::where('cuenta_id', $id)->first(); + + Historiale::where('id', $historial->historiale_id)->update([ + 'fecha_final' => date('Y-m-d', strtotime(strval($this->fecha_final_renovar))), + ]); $cuenta_renovar = Cuentas::find($id); @@ -289,6 +293,8 @@ class ShowPlanes extends Component 'estado' => $this->estado, ]); + $historial->delete(); + Log_historial::create([ 'user_id' => Auth::user()->id, 'detalle' => 'El usuario ha renovado y liberado la cuenta ' . $cuenta_renovar->correo @@ -313,6 +319,14 @@ class ShowPlanes extends Component 'estado' => $this->estado, ]); + $historial = Historial_cuenta::where('cuenta_id', $id)->first(); + + if ($historial) { + Historiale::where('id', $historial->historial_id)->update([ + 'fecha_final' => date('Y-m-d', strtotime(strval($this->fecha_final_renovar))), + ]); + } + $cuenta_renovar = Cuentas::find($id); Log_historial::create([ diff --git a/app/Http/Livewire/ShowPromociones.php b/app/Http/Livewire/ShowPromociones.php index c6674bf..c8c6608 100755 --- a/app/Http/Livewire/ShowPromociones.php +++ b/app/Http/Livewire/ShowPromociones.php @@ -331,12 +331,14 @@ class ShowPromociones extends Component 'confirmButtonText' => 'Sí, comprar.', ]); } + + } else { $descuento = Saldo::where('usuario_id', Auth::user()->id)->first(); $saldo_anterior = $descuento->valor; $nuevo_saldo = $saldo_anterior - ($this->precioAhora * $this->cantidad_comprarPromo); $cobro = $descuento->update(['valor' => $nuevo_saldo]); - + if ($cobro) { $historial->update(['estado' => 'activo']); $this->modalComprarPromo = false; diff --git a/app/Http/Livewire/ShowServicios.php b/app/Http/Livewire/ShowServicios.php index 0d395b5..28f5c0b 100755 --- a/app/Http/Livewire/ShowServicios.php +++ b/app/Http/Livewire/ShowServicios.php @@ -225,6 +225,20 @@ class ShowServicios extends Component { $this->validate(); + if ($this->cantidad_tarjetaPlan == 0) { + $this->alert('error', 'La cantidad debe ser mayor a 0', [ + 'position' => 'top' + ]); + return; + } + + if (auth()->user()->saldo->valor < $this->valor_tarjetaPlan * $this->cantidad_tarjetaPlan) { + $this->alert('error', 'Saldo insuficiente', [ + 'position' => 'top' + ]); + return; + } + $cantidad_solicitada = (int) $this->cantidad_tarjetaPlan * (int) $this->pantallas_tarjetaPlan; $total_valor = (int) $this->valor_tarjetaPlan * (int) $this->cantidad_tarjetaPlan; $utilidad_total = (int) $this->utilidad * (int) $this->cantidad_tarjetaPlan; @@ -352,7 +366,7 @@ class ShowServicios extends Component $this->credenciales($historial); } else { - $eliminar = Historial_cuenta::where('historial_id',$historial->id)->delete(); + $eliminar = Historial_cuenta::where('historial_id', $historial->id)->delete(); $this->alert('warning', 'Error en el cobro, comuniquese con soporte!', [ 'position' => 'top' ]); diff --git a/resources/views/livewire/show-planes.blade.php b/resources/views/livewire/show-planes.blade.php index b331c06..4ba392f 100755 --- a/resources/views/livewire/show-planes.blade.php +++ b/resources/views/livewire/show-planes.blade.php @@ -260,10 +260,10 @@ @endif - {{ \Carbon\Carbon::parse($consulta_verUsuarios->inicio)->format('d/m/Y') }} + {{ \Carbon\Carbon::parse($verUsuarios->fecha_inicio)->format('d/m/Y') }} - {{ \Carbon\Carbon::parse($consulta_verUsuarios->vencimiento)->format('d/m/Y') }} + {{ \Carbon\Carbon::parse($verUsuarios->fecha_final)->format('d/m/Y') }} @php