diff --git a/app/Http/Controllers/MenuController.php b/app/Http/Controllers/MenuController.php index f560e07..ea8e1b2 100644 --- a/app/Http/Controllers/MenuController.php +++ b/app/Http/Controllers/MenuController.php @@ -53,6 +53,9 @@ class MenuController extends Controller public function showperfil(){ return view('menu/perfil'); } + public function showpendientes(){ + return view('menu/pendientes'); + } public function showconfiguracion(){ return view('menu/configuracion'); } diff --git a/app/Http/Livewire/ShowConfiguracion.php b/app/Http/Livewire/ShowConfiguracion.php index 88575ac..c41d32d 100644 --- a/app/Http/Livewire/ShowConfiguracion.php +++ b/app/Http/Livewire/ShowConfiguracion.php @@ -11,6 +11,8 @@ use Livewire\WithFileUploads; use App\Models\Cuentas; use App\Models\Historial_cuenta; use App\Models\Historiale; +use App\Models\Notificacion; +use App\Models\User; use Intervention\Image\ImageManagerStatic as Img; use Illuminate\Support\Str; use Artisan; @@ -55,13 +57,13 @@ class ShowConfiguracion extends Component public $premio_8; public $premio_9; public $premio_10; - + public $mensaje_top; public $img_top; public $mensaje_msj_compra; public $mensaje_msj_wp; - + public $clave_1; public $clave_2; public $clave_3; @@ -69,18 +71,22 @@ class ShowConfiguracion extends Component public $clave_5; public $clave_6; - public $iptv; - public $notificacion; + public $iptv; + public $notificacion; public $consulta_configuracion; - + + public $titulo_noti; + public $descripcion_noti; + public $destinatario_noti; + public function render() - { + { //$consulta = Configuracione::with('usuario')->orderby('id','desc'); - $consulta_configuracion= Configuracione::with('usuario')->orderby('id','desc')->first(); + $consulta_configuracion = Configuracione::with('usuario')->orderby('id', 'desc')->first(); $this->consulta_configuracion = $consulta_configuracion; //dd($consulta_configuraciones); - if (empty($this->nombre) && empty($this->slogan) && empty($this->color_boton) ) { + if (empty($this->nombre) && empty($this->slogan) && empty($this->color_boton)) { $this->nombre = $consulta_configuracion->nombre; $this->slogan = $consulta_configuracion->slogan; @@ -117,9 +123,9 @@ class ShowConfiguracion extends Component //msj - $this->mensaje_msj_compra= $consulta_configuracion->msj_compra; - $this->mensaje_msj_wp= $consulta_configuracion->msj_wp; - + $this->mensaje_msj_compra = $consulta_configuracion->msj_compra; + $this->mensaje_msj_wp = $consulta_configuracion->msj_wp; + $this->clave_1 = $consulta_configuracion->clave_1; $this->clave_2 = $consulta_configuracion->clave_2; $this->clave_3 = $consulta_configuracion->clave_3; @@ -129,19 +135,44 @@ class ShowConfiguracion extends Component $this->iptv = $consulta_configuracion->iptv; $this->notificacion = $consulta_configuracion->hora; - - } - - - return view('livewire.show-configuracion',[ + return view('livewire.show-configuracion', [ 'sliders' => slider::get(), + 'usuarios' => User::get(), ]); } - public function guardarclaves(){ - $claves=$this->consulta_configuracion->update([ + + public function guardarNoti() + { + $this->validate([ + 'titulo_noti' => 'required', + 'descripcion_noti' => 'required', + ]); + + $consulta = new Notificacion(); + $consulta->remitente_id = Auth::user()->id; + $consulta->destinatario_id = $this->destinatario_noti == 'todos' ? Auth::user()->id : $this->destinatario_noti; + $consulta->titulo = trim($this->titulo_noti); + $consulta->descripcion = trim($this->descripcion_noti); + $consulta->estado = true; + $consulta->todos = $this->destinatario_noti == 'todos' || !$this->destinatario_noti ? true : false; + $consulta->save(); + + $this->alert('success', 'Notificacion creada exitosamente!', [ + 'position' => 'top' + ]); + + + $this->titulo_noti = null; + $this->descripcion_noti = null; + $this->destinatario_noti = null; + } + + public function guardarclaves() + { + $claves = $this->consulta_configuracion->update([ 'clave_1' => $this->clave_1, 'clave_2' => $this->clave_2, 'clave_3' => $this->clave_3, @@ -151,74 +182,72 @@ class ShowConfiguracion extends Component ]); if ($claves) { - + $this->alert('success', 'claves actualizado', [ 'position' => 'top' - ]); - - } + ]); + } } - public function guardar(){ + public function guardar() + { if (!empty($this->photo)) { - $nombre=Str::random(10); - - $img = img::make($this->photo)->orientate()->resize(1000, null, function($constraint){ + $nombre = Str::random(10); + + $img = img::make($this->photo)->orientate()->resize(1000, null, function ($constraint) { $constraint->aspectRatio(); $constraint->upsize(); })->encode('webp'); - - $location = "photos/".$nombre.".webp"; - + + $location = "photos/" . $nombre . ".webp"; + Storage::disk('local')->put($location, $img); - + $url_logo = $location; - }else{ - $url_logo = $this->url_logo ; + } else { + $url_logo = $this->url_logo; } - - $configuracion=$this->consulta_configuracion->update([ + + $configuracion = $this->consulta_configuracion->update([ 'nombre' => $this->nombre, 'slogan' => $this->slogan, 'color_boton' => $this->color_boton, 'url_logo' => $url_logo, 'color_barra' => $this->color_barra, - 'color_menu'=> $this->color_menu, - 'usermodifico_id'=>Auth::user()->id, + 'color_menu' => $this->color_menu, + 'usermodifico_id' => Auth::user()->id, ]); if ($configuracion) { - + $this->alert('success', 'Configuración actualizada', [ 'position' => 'top' - ]); - + ]); } - - } - public function guardarSlider(){ + public function guardarSlider() + { if (!empty($this->slider)) { - - $nombre=Str::random(12); - - $img = img::make($this->slider)->orientate()->resize(1000, null, function($constraint){ + + $nombre = Str::random(12); + + $img = img::make($this->slider)->orientate()->resize(1000, null, function ($constraint) { $constraint->aspectRatio(); $constraint->upsize(); })->encode('webp'); - - $location = "photos/".$nombre.".webp"; - + + $location = "photos/" . $nombre . ".webp"; + Storage::disk('local')->put($location, $img); - + $url_slider = $location; - }else{ - $url_slider = '' ; + } else { + $url_slider = ''; } - + $guardar = new slider; $guardar->slider = $url_slider; $guardar->save(); @@ -247,196 +276,200 @@ class ShowConfiguracion extends Component 'onDismissed' => '', 'cancelButtonText' => 'Salir', 'confirmButtonText' => 'Si', - ]); + ]); } public function getListeners() { - return [ - 'confirmed' - ]; + return [ + 'confirmed' + ]; } - public function confirmed(){ - slider::where('id',$this->delete_slider)->delete(); + public function confirmed() + { + slider::where('id', $this->delete_slider)->delete(); $this->alert('success', 'Imagen eliminada correctamente!', [ 'position' => 'top' ]); } - public function guardarTop(){ + public function guardarTop() + { if (!empty($this->photo_top)) { - $nombre=Str::random(10); - $img = img::make($this->photo_top)->orientate()->resize(1000, null, function($constraint){ + $nombre = Str::random(10); + $img = img::make($this->photo_top)->orientate()->resize(1000, null, function ($constraint) { $constraint->aspectRatio(); $constraint->upsize(); })->encode('webp'); - $location = "photos/".$nombre.".webp"; - Storage::disk('local')->put($location, $img); - $photo_top = $location; - - }else{ - $photo_top = $this->img_top ; + $location = "photos/" . $nombre . ".webp"; + Storage::disk('local')->put($location, $img); + $photo_top = $location; + } else { + $photo_top = $this->img_top; } if (!empty($this->imgP1)) { - $imgP1=$this->imgP1->store('photos'); - }else{ - $imgP1 = $this->top_1 ; + $imgP1 = $this->imgP1->store('photos'); + } else { + $imgP1 = $this->top_1; } if (!empty($this->imgP2)) { - $imgP2=$this->imgP2->store('photos'); - }else{ - $imgP2 = $this->top_2 ; + $imgP2 = $this->imgP2->store('photos'); + } else { + $imgP2 = $this->top_2; } if (!empty($this->imgP3)) { - $imgP3=$this->imgP3->store('photos'); - }else{ - $imgP3 = $this->top_3 ; + $imgP3 = $this->imgP3->store('photos'); + } else { + $imgP3 = $this->top_3; } if (!empty($this->imgP4)) { - $imgP4=$this->imgP4->store('photos'); - }else{ - $imgP4 = $this->top_4 ; + $imgP4 = $this->imgP4->store('photos'); + } else { + $imgP4 = $this->top_4; } if (!empty($this->imgP5)) { - $imgP5=$this->imgP5->store('photos'); - }else{ - $imgP5 = $this->top_5 ; + $imgP5 = $this->imgP5->store('photos'); + } else { + $imgP5 = $this->top_5; } if (!empty($this->imgP6)) { - $imgP6=$this->imgP6->store('photos'); - }else{ - $imgP6 = $this->top_6 ; + $imgP6 = $this->imgP6->store('photos'); + } else { + $imgP6 = $this->top_6; } if (!empty($this->imgP7)) { - $imgP7=$this->imgP7->store('photos'); - }else{ - $imgP7 = $this->top_7 ; + $imgP7 = $this->imgP7->store('photos'); + } else { + $imgP7 = $this->top_7; } if (!empty($this->imgP8)) { - $imgP8=$this->imgP8->store('photos'); - }else{ - $imgP8 = $this->top_8 ; + $imgP8 = $this->imgP8->store('photos'); + } else { + $imgP8 = $this->top_8; } if (!empty($this->imgP9)) { - $imgP9=$this->imgP9->store('photos'); - }else{ - $imgP9 = $this->top_9 ; + $imgP9 = $this->imgP9->store('photos'); + } else { + $imgP9 = $this->top_9; } if (!empty($this->imgP10)) { - $imgP10=$this->imgP10->store('photos'); - }else{ - $imgP10 = $this->top_10 ; + $imgP10 = $this->imgP10->store('photos'); + } else { + $imgP10 = $this->top_10; } - + $top = $this->consulta_configuracion->update([ - 'top_1' => $imgP1, - 'top_2' => $imgP2, - 'top_3' => $imgP3, - 'top_4' => $imgP4, - 'top_5' => $imgP5, - 'top_6' => $imgP6, - 'top_7' => $imgP7, - 'top_8' => $imgP8, - 'top_9' => $imgP9, - 'top_10' => $imgP10, - - 'img_top' => $photo_top, - 'mensaje_top' => $this->mensaje_top, - 'premio_1' => $this->premio_1, - 'premio_2' => $this->premio_2, - 'premio_3' => $this->premio_3, - 'premio_4' => $this->premio_4, - 'premio_5' => $this->premio_5, - 'premio_6' => $this->premio_6, - 'premio_7' => $this->premio_7, - 'premio_8' => $this->premio_8, - 'premio_9' => $this->premio_9, - 'premio_10' => $this->premio_10, + 'top_1' => $imgP1, + 'top_2' => $imgP2, + 'top_3' => $imgP3, + 'top_4' => $imgP4, + 'top_5' => $imgP5, + 'top_6' => $imgP6, + 'top_7' => $imgP7, + 'top_8' => $imgP8, + 'top_9' => $imgP9, + 'top_10' => $imgP10, + + 'img_top' => $photo_top, + 'mensaje_top' => $this->mensaje_top, + 'premio_1' => $this->premio_1, + 'premio_2' => $this->premio_2, + 'premio_3' => $this->premio_3, + 'premio_4' => $this->premio_4, + 'premio_5' => $this->premio_5, + 'premio_6' => $this->premio_6, + 'premio_7' => $this->premio_7, + 'premio_8' => $this->premio_8, + 'premio_9' => $this->premio_9, + 'premio_10' => $this->premio_10, + - ]); - - if($top){ + + if ($top) { $this->alert('success', 'Top distribuidores actualizado', [ 'position' => 'top' - ]); + ]); } - } - public function guardarMsjCompra(){ + public function guardarMsjCompra() + { $msj = $this->consulta_configuracion->update([ 'msj_compra' => $this->mensaje_msj_compra, 'msj_wp' => $this->mensaje_msj_wp, ]); if ($msj) { - - $this->alert('success', 'Mensaje actualizado', [ - 'position' => 'top' - ]); - + + $this->alert('success', 'Mensaje actualizado', [ + 'position' => 'top' + ]); } } - public function guardariptv(){ - // dd($this->iptv); + public function guardariptv() + { + // dd($this->iptv); $iptv = $this->consulta_configuracion->update([ 'iptv' => $this->iptv, ]); if ($iptv) { - - $this->alert('success', 'iptv actualizado', [ - 'position' => 'top' - ]); - + + $this->alert('success', 'iptv actualizado', [ + 'position' => 'top' + ]); } } - public function eliminarC(){ + public function eliminarC() + { //$eliminar_cuentas = Cuentas::truncate(); $this->alert('warning', 'Funcion deshabilitada ', [ 'position' => 'top' - ]); - + ]); } - public function eliminarR(){ - // $eliminar_cuentas = Historial_cuenta::truncate(); + public function eliminarR() + { + // $eliminar_cuentas = Historial_cuenta::truncate(); $this->alert('warning', 'Funcion deshabilitada ', [ 'position' => 'top' - ]); + ]); } - public function eliminarH(){ + public function eliminarH() + { //$desasociar_cuentas = Historiale::truncate(); $this->alert('warning', 'Funcion deshabilitada ', [ 'position' => 'top' - ]); + ]); } - public function guardarnot(){ + public function guardarnot() + { $notificacion = $this->consulta_configuracion->update([ 'hora' => $this->notificacion, ]); $this->alert('success', 'La hora de notificación ha sido actualizada.', [ 'position' => 'top' - ]); + ]); } - public function eliminarCache(){ + public function eliminarCache() + { Artisan::call('cache:clear'); Artisan::call('config:clear'); Artisan::call('view:clear'); @@ -445,7 +478,6 @@ class ShowConfiguracion extends Component $this->alert('success', 'Cache removido correctamente', [ 'position' => 'top' - ]); + ]); } - } diff --git a/app/Http/Livewire/ShowPendientes.php b/app/Http/Livewire/ShowPendientes.php new file mode 100644 index 0000000..d95d133 --- /dev/null +++ b/app/Http/Livewire/ShowPendientes.php @@ -0,0 +1,20 @@ +entradas); + + return view('livewire.show-pendientes',[ + 'consulta' => $consulta, + ]); + } +} diff --git a/app/Http/Livewire/ShowPlanes.php b/app/Http/Livewire/ShowPlanes.php index 46edcbb..e6c223b 100644 --- a/app/Http/Livewire/ShowPlanes.php +++ b/app/Http/Livewire/ShowPlanes.php @@ -6,12 +6,15 @@ use App\Models\Cuentas; use App\Models\Historiale; use App\Models\Historial_cuenta; use App\Models\Log_general; +use App\Models\Notificacion; use App\Models\Pendientes; use App\Models\Role; use App\Models\Servicio; use App\Models\Tarifas; use App\Models\user; +use App\Notifications\NotificacionPendiente; use Carbon\Carbon; +use Illuminate\Support\Facades\Auth; use Livewire\Component; use Jantinnerezo\LivewireAlert\LivewireAlert; use Livewire\WithFileUploads; @@ -242,12 +245,25 @@ class ShowPlanes extends Component $cuentasPendientes = Pendientes::where('estado', 'pendiente')->where('servicio_id', $this->servicio_newCuenta)->take($servicioPantallas)->get(); foreach ($cuentasPendientes as $i => $cuentaPendiente) { + $servicioName = $cuentaPendiente->servicio->nombre; + $historial_cuenta = new Historial_cuenta(); $historial_cuenta->historial_id = $cuentaPendiente->historial_id; $historial_cuenta->cuenta_id = $cuenta->id; $historial_cuenta->perfil = $i + 1; $historial_cuenta->save(); $cuentaPendiente->update(['estado' => 'cerrado']); + + $cuentaPendiente->historial->vendedor->notify(new NotificacionPendiente($servicioName)); + + $consulta = new Notificacion(); + $consulta->remitente_id = Auth::user()->id; + $consulta->destinatario_id = $historial_cuenta->historial->vendedor_id; + $consulta->titulo = "Licencia asignada para $servicioName"; + $consulta->descripcion = "La licencia de $servicioName ha sido activada y ahora puedes utilizar tu cuenta sin problemas."; + $consulta->estado = true; + $consulta->todos = false; + $consulta->save(); } } diff --git a/app/Imports/UsersImport.php b/app/Imports/UsersImport.php index 0b47e57..3e9791d 100644 --- a/app/Imports/UsersImport.php +++ b/app/Imports/UsersImport.php @@ -5,8 +5,11 @@ namespace App\Imports; use Illuminate\Support\Facades\Hash; use App\Models\Cuentas; use App\Models\Historial_cuenta; +use App\Models\Notificacion; use App\Models\Pendientes; use App\Models\Servicio; +use App\Notifications\NotificacionPendiente; +use Illuminate\Support\Facades\Auth; use Maatwebsite\Excel\Concerns\ToModel; class UsersImport implements ToModel @@ -39,12 +42,25 @@ class UsersImport implements ToModel ->get(); foreach ($cuentasPendientes as $i => $cuentaPendiente) { + $servicioName = $cuentaPendiente->servicio->nombre; + $historial_cuenta = new Historial_cuenta(); $historial_cuenta->historial_id = $cuentaPendiente->historial_id; $historial_cuenta->cuenta_id = $cuenta->id; $historial_cuenta->perfil = $i + 1; $historial_cuenta->save(); $cuentaPendiente->update(['estado' => 'cerrado']); + + $historial_cuenta->historial->vendedor->notify(new NotificacionPendiente($servicioName)); + + $consulta = new Notificacion(); + $consulta->remitente_id = Auth::user()->id; + $consulta->destinatario_id = $historial_cuenta->historial->vendedor_id; + $consulta->titulo = "Licencia asignada para $servicioName"; + $consulta->descripcion = "La licencia de $servicioName ha sido activada y ahora puedes utilizar tu cuenta sin problemas."; + $consulta->estado = true; + $consulta->todos = false; + $consulta->save(); } } diff --git a/app/Models/Historial_cuenta.php b/app/Models/Historial_cuenta.php index a63bf17..016dde1 100644 --- a/app/Models/Historial_cuenta.php +++ b/app/Models/Historial_cuenta.php @@ -11,6 +11,10 @@ class Historial_cuenta extends Model protected $fillable = [ 'historial_id', 'cuenta_id', - ]; + + public function historial() + { + return $this->belongsTo(Historiale::class, 'historial_id'); + } } diff --git a/app/Models/Historiale.php b/app/Models/Historiale.php index c50be30..e71fa0b 100644 --- a/app/Models/Historiale.php +++ b/app/Models/Historiale.php @@ -24,7 +24,7 @@ class Historiale extends Model public function vendedor() { - return $this->belongsTo(User::class); + return $this->belongsTo(User::class , 'vendedor_id'); } public function tarifa() diff --git a/app/Models/Pendientes.php b/app/Models/Pendientes.php index d67260c..73bf063 100644 --- a/app/Models/Pendientes.php +++ b/app/Models/Pendientes.php @@ -18,10 +18,10 @@ class Pendientes extends Model public function servicio() { - return $this->hasMany(Servicio::class, 'servicio_id'); + return $this->belongsTo(Servicio::class, 'servicio_id'); } public function historial() { - return $this->hasMany(Historiale::class, 'historial_id'); + return $this->belongsTo(Historiale::class, 'historial_id'); } } diff --git a/app/Notifications/NotificacionPendiente.php b/app/Notifications/NotificacionPendiente.php new file mode 100644 index 0000000..77786e3 --- /dev/null +++ b/app/Notifications/NotificacionPendiente.php @@ -0,0 +1,43 @@ +servicioName = $servicioName; + } + + public function via($notifiable) + { + return ['mail']; + } + + public function toMail($notifiable) + { + return (new MailMessage) + ->subject('Licencia asignada para ' . $this->servicioName) + ->greeting('Tu cuenta de ' . $this->servicioName . ' ha sido asignada') + ->line('titulo: ' . 'Licencia asignada para ' . $this->servicioName) + ->line('descripcion: La licencia de ' . $this->servicioName . ' ha sido activada y ahora puedes utilizar tu cuenta sin problemas.') + ->salutation('¡Gracias por tu atención!'); + } + + public function toArray($notifiable) + { + return [ + // + ]; + } +} diff --git a/resources/views/components/listado-planes.blade.php b/resources/views/components/listado-planes.blade.php index d62138a..c2a86b5 100644 --- a/resources/views/components/listado-planes.blade.php +++ b/resources/views/components/listado-planes.blade.php @@ -1,129 +1,143 @@
{{ $cuenta->servicio->nombre ?? ''}} - email: - {{ $cuenta->correo ?? '' }} - Pass: {{ $cuenta->password ?? '' }}
-Disponible
- @else -Ocupado
- @endif + @endphp - @else -{{ $cuenta->historiales_count ?? '0' }}/{{$cuenta->servicio->pantallas?? '0'}} @endif @if($historiales >= '1'){{$historiales}}
@endif -+
Gestión Planes + Gestión Pendientes Importar cuentas @if (auth()->user()->rol->nombre == "super" || auth()->user()->rol->nombre == "administrador") Gestión Promociones diff --git a/resources/views/livewire/bell.blade.php b/resources/views/livewire/bell.blade.php index 682273e..a2cd1e3 100644 --- a/resources/views/livewire/bell.blade.php +++ b/resources/views/livewire/bell.blade.php @@ -21,7 +21,7 @@
{{ $item->descripcion }}
- @if (!$item->todos) + @if (!$item->todos || Auth::user()->rol->nombre == 'administrador') x diff --git a/resources/views/livewire/show-configuracion.blade.php b/resources/views/livewire/show-configuracion.blade.php index c1f5b9c..ccb810c 100644 --- a/resources/views/livewire/show-configuracion.blade.php +++ b/resources/views/livewire/show-configuracion.blade.php @@ -1,5 +1,6 @@
@@ -8,14 +9,14 @@
Distribuidor
{{-- img distribuidor --}} -Mensaje de compra html
+Mensaje de compra html
- {{-- mensaje --}} + {{-- mensaje --}}Claves perfil netflix
+Claves perfil netflix
-URL IPTV
-URL IPTV
+Notificaciones globales
+Área critica
- - - - + + + + +