diff --git a/app/Console/Kernel.php b/app/Console/Kernel.php index 881838a..122e2f7 100644 --- a/app/Console/Kernel.php +++ b/app/Console/Kernel.php @@ -27,109 +27,107 @@ class Kernel extends ConsoleKernel * @param \Illuminate\Console\Scheduling\Schedule $schedule * @return void */ - - protected function schedule(Schedule $schedule) - { + { + // $schedule->exec('nohup php /home/u111286300/domains/sirpremium.com.co/public_html/app/artisan queue:work --sleep=3 --tries=3 > /dev/null 2>&1 &')->everyMinute(); - //$schedule->exec('nohup php /var/www/sirpremium/artisan queue:work --sleep=3 --tries=3 > /dev/null 2>&1 &')->everyMinute(); + // $schedule->exec('nohup php /var/www/sirpremium/artisan queue:work --sleep=3 --tries=3 > /dev/null 2>&1 &')->everyMinute(); + $schedule->call(function () { $fechaHoy = Carbon::now(); $fechaManana = $fechaHoy->copy()->addDay(); // Obtenemos la fecha de mañana sumando un día a la fecha actual - + $consulta_historial = Historiale::whereDate('fecha_final', $fechaManana)->with('cliente')->get(); - - foreach ($consulta_historial as $item) { - - $user = User::find($item->cliente->id); - if (!empty($item->promocion_id)) { + foreach ($consulta_historial as $item) { - $nombre= $item->promocion->nombre; + $user = User::find($item->cliente->id); + + if (!empty($item->promocion_id)) { + + $nombre = $item->promocion->nombre; + } + if (!empty($item->tarifa_id)) { + $nombre = $item->tarifa->servicio->nombre . '-' . $item->tarifa->pantallas . 'P'; } - if (!empty($item->tarifa_id)) { - $nombre = $item->tarifa->servicio->nombre . '-' . $item->tarifa->pantallas . 'P'; - } - $notificacion = [ - //'valor' => $value['precio'], - 'fecha_final' => $item->fecha_final, - 'cliente' => $item->cliente->name, - 'servicio' => $nombre, - 'tipo' => 'vencimiento', - 'vendedor' =>$item->vendedor->name, - - ]; - - Notification::sendNow($user, new Vencimiento($notificacion)); + $notificacion = [ + //'valor' => $value['precio'], + 'fecha_final' => $item->fecha_final, + 'cliente' => $item->cliente->name, + 'servicio' => $nombre, + 'tipo' => 'vencimiento', + 'vendedor' => $item->vendedor->name, - //$fecha=Carbon::parse($item->fecha_final)->format('d/m/Y'); - - //$message = 'Su '.$nombre.', Vence Hoy, '.$fecha.'. Renueva ahora!!' ; - //$recipients= '+57'.$item->cliente->celular; + ]; - //$auth_basic = base64_encode('admin@jaguarws.ga:9u3xxXhHt8maeiOexg07pFKI0rpYazI0'); + Notification::sendNow($user, new Vencimiento($notificacion)); - //$curl = curl_init(); + //$fecha=Carbon::parse($item->fecha_final)->format('d/m/Y'); - //curl_setopt_array($curl, array( - //CURLOPT_URL => "https://api.labsmobile.com/json/send", - //CURLOPT_RETURNTRANSFER => true, - //CURLOPT_ENCODING => "", - //CURLOPT_MAXREDIRS => 10, - //CURLOPT_TIMEOUT => 30, - //CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, - //CURLOPT_CUSTOMREQUEST => "POST", - //CURLOPT_POSTFIELDS => '{"message":"'.$message.'", "tpoa":"Sender","recipient":[{"msisdn":"'.$recipients.'"}]}', - //CURLOPT_HTTPHEADER => array( - // "Authorization: Basic ".$auth_basic, - // "Cache-Control: no-cache", - // "Content-Type: application/json" - // ), - //)); + //$message = 'Su '.$nombre.', Vence Hoy, '.$fecha.'. Renueva ahora!!' ; + //$recipients= '+57'.$item->cliente->celular; - // $response = curl_exec($curl); - // $err = curl_error($curl); -// - //curl_close($curl); - //return $response; - // if ($err) { - // - - //} else { - // - //} - + //$auth_basic = base64_encode('admin@jaguarws.ga:9u3xxXhHt8maeiOexg07pFKI0rpYazI0'); - } + //$curl = curl_init(); + + //curl_setopt_array($curl, array( + //CURLOPT_URL => "https://api.labsmobile.com/json/send", + //CURLOPT_RETURNTRANSFER => true, + //CURLOPT_ENCODING => "", + //CURLOPT_MAXREDIRS => 10, + //CURLOPT_TIMEOUT => 30, + //CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, + //CURLOPT_CUSTOMREQUEST => "POST", + //CURLOPT_POSTFIELDS => '{"message":"'.$message.'", "tpoa":"Sender","recipient":[{"msisdn":"'.$recipients.'"}]}', + //CURLOPT_HTTPHEADER => array( + // "Authorization: Basic ".$auth_basic, + // "Cache-Control: no-cache", + // "Content-Type: application/json" + // ), + //)); + + // $response = curl_exec($curl); + // $err = curl_error($curl); + // + //curl_close($curl); + //return $response; + // if ($err) { + // + + //} else { + // + //} + + + } $fechaHoy1 = Carbon::now(); $fechaHoy1 = Carbon::parse($fechaHoy1)->subDay(1); - - $consulta_historial1= Historiale::whereDate('fecha_final','<',$fechaHoy1)->with('cliente','cuentas')->get(); + + $consulta_historial1 = Historiale::whereDate('fecha_final', '<', $fechaHoy1)->with('cliente', 'cuentas')->get(); + foreach ($consulta_historial1 as $item1) { - - foreach($item1->cuentas->unique() as $item2){ - //dd($item2); + + foreach ($item1->cuentas->unique() as $item2) { $logs = new log; $logs->historial_id = $item1->id; $logs->cuenta_id = $item2->id; $logs->save(); + + Historial_cuenta::where('historial_id', $item1->id)->where('cuenta_id', $item2->id)->delete(); } - //$eliminar_cuentas = Historial_cuenta::where('historial_id',$item1->id)->truncate(); - //dd('termine'); - } - })->dailyAt(Configuracione::orderby('id','desc')->first()->hora); - + })->dailyAt(Configuracione::orderby('id', 'desc')->first()->hora); } - + /** * Register the commands for the application. @@ -138,7 +136,7 @@ class Kernel extends ConsoleKernel */ protected function commands() { - $this->load(__DIR__.'/Commands'); + $this->load(__DIR__ . '/Commands'); require base_path('routes/console.php'); } diff --git a/resources/views/components/listado-planes.blade.php b/resources/views/components/listado-planes.blade.php index c2a86b5..d556a10 100644 --- a/resources/views/components/listado-planes.blade.php +++ b/resources/views/components/listado-planes.blade.php @@ -8,7 +8,7 @@ {{ $cuenta->correo ?? '' }} {{ $cuenta->password ?? '' }} - + {{ carbon\Carbon::parse($cuenta->inicio)->format('d M Y') ?? '' }} - {{ carbon\Carbon::parse($cuenta->vencimiento)->format('d M Y') ?? '' }} @@ -72,7 +72,7 @@ Inactiva @endif - + @@ -108,7 +108,7 @@ @endif - + @if (!empty($cuenta->observaciones))
diff --git a/resources/views/livewire/show-planes.blade.php b/resources/views/livewire/show-planes.blade.php index 463a5bc..1fc87be 100644 --- a/resources/views/livewire/show-planes.blade.php +++ b/resources/views/livewire/show-planes.blade.php @@ -142,13 +142,13 @@ Servicio Correo Contraseña - Inicio - Final + Inicio - Final Restante Ocupado - + - +