vista tarifas

This commit is contained in:
Juan Felipe Duarte
2025-06-19 17:54:22 -07:00
parent 6eb6e3bd2f
commit e8050ea19f
10 changed files with 866 additions and 640 deletions
+199 -207
View File
@@ -31,98 +31,120 @@ use AshAllenDesign\ShortURL\Facades\ShortURL;
class MenuController extends Controller
{
public function showwelcome(){
public function showwelcome()
{
$consulta_promociones = slider::get();
return view('welcome',[
return view('welcome', [
'promociones' => $consulta_promociones,
]);
}
public function showclientes(){
public function showtarifas()
{
return view('menu/tarifas');
}
public function showclientes()
{
return view('menu/clientes');
}
public function showservicios(){
public function showservicios()
{
return view('menu/servicios');
}
public function showtop(){
public function showtop()
{
return view('menu/top');
}
public function showreportes(){
public function showreportes()
{
return view('menu/reportes');
}
public function showperfil(){
public function showperfil()
{
return view('menu/perfil');
}
public function showpendientes(){
public function showpendientes()
{
return view('menu/pendientes');
}
public function showconfiguracion(){
public function showconfiguracion()
{
return view('menu/configuracion');
}
public function showplanes(){
public function showplanes()
{
return view('menu/planes');
}
public function showusuarios(){
public function showusuarios()
{
return view('menu/usuarios');
}
public function showadmin(){
public function showadmin()
{
return view('menu/admin');
}
public function showrecarga(){
public function showrecarga()
{
return view('menu/recarga');
}
public function showcomprar(){
public function showcomprar()
{
return view('menu/comprar');
}
public function showLogRecargas(){
public function showLogRecargas()
{
return view('menu/logs_recargas');
}
public function showLogGeneral(){
public function showLogGeneral()
{
return view('menu/log_general');
}
public function showLogHistorial(){
public function showLogHistorial()
{
return view('menu/log_historial');
}
public function showroles(){
public function showroles()
{
return view('menu/roles');
}
public function mantenimiento(){
public function mantenimiento()
{
return view('menu/mantenimiento');
}
public function pay($estado){
return view('menu/order',[
public function pay($estado)
{
return view('menu/order', [
'estado' => $estado,
]);
}
public function showcredenciales(Request $request){
public function showcredenciales(Request $request)
{
$credencial = Crypt::decryptString($request->id);
$consulta_historiales = Historiale::where('id',$credencial)->with('cuentas')->first();
$msj = Configuracione::orderby('id','desc')->select('msj_compra','msj_wp','clave_1','clave_2','clave_3','clave_4','clave_5','clave_6','iptv')->first();
$consulta_historiales = Historiale::where('id', $credencial)->with('cuentas')->first();
$msj = Configuracione::orderby('id', 'desc')->select('msj_compra', 'msj_wp', 'clave_1', 'clave_2', 'clave_3', 'clave_4', 'clave_5', 'clave_6', 'iptv')->first();
return view('menu/credenciales',[
'consulta' =>$consulta_historiales,
return view('menu/credenciales', [
'consulta' => $consulta_historiales,
'msj' => $msj,
]);
}
public function order( Request $request ){
public function order(Request $request)
{
$payment_id= $request->get('payment_id');
$payment_id = $request->get('payment_id');
$response = Http::get("https://api.mercadopago.com/v1/payments/$payment_id" . "?access_token=APP_USR-7353579040069171-102716-58fdd1f52a604a1febd18a638227f603-260361439");
$response = json_decode($response);
@@ -131,11 +153,11 @@ class MenuController extends Controller
$metodo_pago = $response->payment_method_id;
$referencia = $response->external_reference;
$consulta = recarga::where('reference',$referencia)->where('status',$status)->exists();
if ($consulta == false){
$update_recargas = recarga::where('reference',$referencia)->update(['status' => $status,'payment_method_id'=> $metodo_pago]);
$recarga = recarga::where('reference',$referencia)->with('usuario')->first();
$usuario= $recarga->usuario;
$consulta = recarga::where('reference', $referencia)->where('status', $status)->exists();
if ($consulta == false) {
$update_recargas = recarga::where('reference', $referencia)->update(['status' => $status, 'payment_method_id' => $metodo_pago]);
$recarga = recarga::where('reference', $referencia)->with('usuario')->first();
$usuario = $recarga->usuario;
$saldo = $usuario->saldo;
$saldo_anterior = $saldo->valor;
@@ -144,14 +166,13 @@ class MenuController extends Controller
if (!empty($saldo_anterior)) {
$valor= (float)$saldo_anterior + (float)$monto ;
$nuevo_saldo = $saldo->update(['valor'=>$valor]);
}else{
$nuevo_saldo = $saldo->update(['valor'=>$monto]);
$valor = (float)$saldo_anterior + (float)$monto;
$nuevo_saldo = $saldo->update(['valor' => $valor]);
} else {
$nuevo_saldo = $saldo->update(['valor' => $monto]);
}
$consulta_recarga= recarga::where('reference',$referencia)->where('status',$status)->first();
$consulta_recarga = recarga::where('reference', $referencia)->where('status', $status)->first();
$usuario_a_recargar = User::find($consulta_recarga->usuario_id);
$nombre = $usuario_a_recargar->name;
@@ -159,102 +180,109 @@ class MenuController extends Controller
$logsGeneral = new Log_general();
$logsGeneral->user_id = $consulta_recarga->usuario_id;
$logsGeneral->detalle = 'El usuario '.$nombre.' - '.$email.'ha recargador por MP el monto de ' . $monto . ', Nuevo saldo disponible: $'.$nuevo_saldo;
$logsGeneral->detalle = 'El usuario ' . $nombre . ' - ' . $email . 'ha recargador por MP el monto de ' . $monto . ', Nuevo saldo disponible: $' . $nuevo_saldo;
$logsGeneral->tipo = 'recarga';
$logsGeneral->historial_id = null;
$logsGeneral->save();
}
$estado= 'aprobado';
}elseif($status == 'pending'){
$estado = 'aprobado';
} elseif ($status == 'pending') {
$metodo_pago = $response->payment_method_id;
$referencia = $response->external_reference;
$update_recargas = recarga::where('reference',$referencia)->update(['status' => $status,'payment_method_id'=> $metodo_pago]);
$usuario = recarga::where('reference',$referencia)->with('usuario')->first()->usuario;
$update_recargas = recarga::where('reference', $referencia)->update(['status' => $status, 'payment_method_id' => $metodo_pago]);
$usuario = recarga::where('reference', $referencia)->with('usuario')->first()->usuario;
$estado= 'pendiente';
}else{
$estado = 'pendiente';
} else {
$metodo_pago = $response->payment_method_id;
$referencia = $response->external_reference;
$update_recargas = recarga::where('reference',$referencia)->update(['status' => $status,'payment_method_id'=> $metodo_pago]);
$usuario = recarga::where('reference',$referencia)->with('usuario')->first()->usuario;
$update_recargas = recarga::where('reference', $referencia)->update(['status' => $status, 'payment_method_id' => $metodo_pago]);
$usuario = recarga::where('reference', $referencia)->with('usuario')->first()->usuario;
$estado ='rechazado';
$estado = 'rechazado';
};
return redirect()->route('pay',$estado);
return redirect()->route('pay', $estado);
}
public function showwebhooks(Request $request){
public function showwebhooks(Request $request) {}
}
public function recargas(){
public function recargas()
{
return view('menu/recargas');
}
public function showutilidad(){
public function showutilidad()
{
return view('menu/utilidades');
}
public function showwompi($monto){
return view('menu/wompi',[
public function showwompi($monto)
{
return view('menu/wompi', [
'monto' => $monto,
]);
}
public function showoferta(){
public function showoferta()
{
return view('portadaservicio');
}
public function showsingle(){
public function showsingle()
{
return view('menu/single');
}
public function showpromo(){
public function showpromo()
{
return view('menu/promo');
}
public function showlogs(){
public function showlogs()
{
return view('menu/logs');
}
public function showpromociones(){
public function showpromociones()
{
return view('menu/promociones');
}
public function showimport(){
public function showimport()
{
return view('menu/importar');
}
public function showcategoria(){
public function showcategoria()
{
return view('menu/categoria');
}
public function showcategorias(){
public function showcategorias()
{
return view('menu/ver');
}
public function showservicio(){
public function showservicio()
{
return view('menu/servicio');
}
public function compras( Request $request ){
public function compras(Request $request)
{
$payment_id= $request->get('payment_id');
$payment_id = $request->get('payment_id');
$response = Http::get("https://api.mercadopago.com/v1/payments/$payment_id" . "?access_token=APP_USR-7353579040069171-102716-58fdd1f52a604a1febd18a638227f603-260361439");
$response = json_decode($response);
@@ -262,30 +290,30 @@ class MenuController extends Controller
$status = $response->status;
if ($status == 'approved') {
foreach($response->additional_info->items as $item){
foreach ($response->additional_info->items as $item) {
$consulta = Historiale::where('id', $item->id)->first();
$tarifa_id=$consulta->tarifa_id;
$tarifa_id = $consulta->tarifa_id;
}
$date = Carbon::now()->subDay(30);
$fecha= $date->format('Y-m-d');
$fecha = $date->format('Y-m-d');
//SERVICIO//
if (!empty($consulta->tarifa_id)) {
$pantallas = Tarifas::where('id', $tarifa_id)->with('servicio')->first();
$servicio_id= $pantallas->servicio_id;
$servicio_id = $pantallas->servicio_id;
$pantalla_servicio = $pantallas->servicio->pantallas;
$pantalla_servicio_completa = $pantallas->servicio->completa;
$pantallas= $pantallas ->pantallas ?? null;
$pantallas = $pantallas->pantallas ?? null;
$cantidad_tarjetaPlan = $consulta->cantidad;
$cantidad_solicitada = (int)$cantidad_tarjetaPlan*(int)$pantallas;
$cantidad_solicitada = (int)$cantidad_tarjetaPlan * (int)$pantallas;
//dd($cantidad_tarjetaPlan);
if((int)$pantalla_servicio_completa >= (int)$cantidad_solicitada ){
$suma = $pantalla_servicio-$cantidad_solicitada;
if ((int)$pantalla_servicio_completa >= (int)$cantidad_solicitada) {
$suma = $pantalla_servicio - $cantidad_solicitada;
$cuenta = Cuentas::where('servicio_id', $servicio_id)
->whereDate('inicio', '>=', $fecha)
->where('estado', 'activo')
@@ -299,10 +327,9 @@ class MenuController extends Controller
// La cuenta no cumple con el filtro (tiene más historiales de los permitidos o no existe).
$cuenta = null;
}
}elseif((int)$pantalla_servicio_completa == (int)$cantidad_solicitada){
$this->fecha_final_1 = $today = Carbon::now()->addDays($pantallas->dias-15);
$this->fecha_final_2 = $today = Carbon::now()->addDays($pantallas->dias+15);
} elseif ((int)$pantalla_servicio_completa == (int)$cantidad_solicitada) {
$this->fecha_final_1 = $today = Carbon::now()->addDays($pantallas->dias - 15);
$this->fecha_final_2 = $today = Carbon::now()->addDays($pantallas->dias + 15);
//completas
$cuentas = Cuentas::where('servicio_id', $this->servicio_id)
->whereDate('inicio', '>=', $this->fecha)
@@ -316,16 +343,15 @@ class MenuController extends Controller
$cuenta = $cuentas->first(function ($cuenta) {
return $cuenta->historiales_count == 0; // Filtrar solo cuentas que no tengan historiales
});
}else{
$cuenta=null;
} else {
$cuenta = null;
}
if (!empty($cuenta) ) {
if (!empty($cuenta)) {
$perfil = $cuenta->historiales_count;
for ($n=1; $n <= $cantidad_solicitada ; $n++) {
for ($n = 1; $n <= $cantidad_solicitada; $n++) {
$historial_cuenta = new Historial_cuenta();
$historial_cuenta->cuenta_id = $cuenta->id;
@@ -335,27 +361,23 @@ class MenuController extends Controller
//dd($historial_cuenta->id);
}
if (($n-1) == $cantidad_solicitada) {
if (($n - 1) == $cantidad_solicitada) {
$consulta->update(['estado'=>'activo']);
$consulta->update(['estado' => 'activo']);
$this->cred($consulta);
$encryptado = Crypt::encryptString($consulta->id);
//dd('llegue');
return redirect('/credenciales?id='.$encryptado);
}else{
return redirect('/credenciales?id=' . $encryptado);
} else {
return 'Error en la asignacion de cuentas, comuniquese con soporte!';
}
}else{
} else {
//dd($cuenta);
$suma2= $pantalla_servicio - $pantallas;
$suma2 = $pantalla_servicio - $pantallas;
for ($h=0; $h < (int)$cantidad_tarjetaPlan ; $h++) {
for ($h = 0; $h < (int)$cantidad_tarjetaPlan; $h++) {
//dd($n);
$cuentas = Cuentas::where('servicio_id', $servicio_id)
->whereDate('inicio', '>=', $fecha)
@@ -371,37 +393,29 @@ class MenuController extends Controller
//dd($cuenta);
if (!empty($cuenta)) {
$perfil = $cuenta->historiales_count;
for ($y=0; $y < (int)$pantallas ; $y++) {
for ($y = 0; $y < (int)$pantallas; $y++) {
//dd($pantallas);
$historial_cuenta = new Historial_cuenta;
$historial_cuenta->cuenta_id = $cuenta->id;
$historial_cuenta->historial_id = $item->id;
$historial_cuenta->perfil = (int)$perfil + (int)$y+1;
$historial_cuenta->perfil = (int)$perfil + (int)$y + 1;
$historial_cuenta->save();
}
}else{
} else {
return 'No hay cuentas disponibles, comuniquese con soporte!';
}
}
$consulta->update(['estado'=>'activo']);
$consulta->update(['estado' => 'activo']);
$this->cred($consulta);
$encryptado = Crypt::encryptString($consulta->id);
return redirect('/credenciales?id='.$encryptado);
return redirect('/credenciales?id=' . $encryptado);
}
}
//PROMOCION
if (!empty($consulta->promocion_id)){
if (!empty($consulta->promocion_id)) {
for ($p = 0; $p < (int)$consulta->cantidad; $p++) {
//dd($this->cantidad_comprarPromo);
@@ -414,8 +428,8 @@ class MenuController extends Controller
$faltante = $pantalla_servicio - $pantallas_tarifa;
if ($pantalla_servicio_completa == $pantallas_tarifa) {
$this->fecha_final_1 = $today = Carbon::now()->addDays($tarifa->dias-15);
$this->fecha_final_2 = $today = Carbon::now()->addDays($tarifa->dias+15);
$this->fecha_final_1 = $today = Carbon::now()->addDays($tarifa->dias - 15);
$this->fecha_final_2 = $today = Carbon::now()->addDays($tarifa->dias + 15);
$cuentas = Cuentas::where('servicio_id', $servicio_id)
->whereDate('inicio', '>=', $fecha)
->whereDate('vencimiento', '>=', $this->fecha_final_1)
@@ -429,8 +443,7 @@ class MenuController extends Controller
$cuenta = $cuentas->first(function ($cuenta) {
return $cuenta->historiales_count == 0; // Filtrar solo cuentas que no tengan historiales
});
}else{
} else {
$cuentas = Cuentas::where('servicio_id', $servicio_id)
->whereDate('inicio', '>=', $fecha)
->orderBy('created_at', 'ASC')
@@ -442,8 +455,6 @@ class MenuController extends Controller
$cuenta = $cuentas->first(function ($cuenta) use ($faltante) {
return $cuenta->historiales_count <= (int) $faltante;
});
}
//dd($tarifa);
@@ -455,11 +466,9 @@ class MenuController extends Controller
$historial_cuenta = new Historial_cuenta();
$historial_cuenta->cuenta_id = $cuenta->id;
$historial_cuenta->historial_id = $item->id;
$historial_cuenta->perfil = (int)$perfil + (int)$y+1;
$historial_cuenta->perfil = (int)$perfil + (int)$y + 1;
$historial_cuenta->save();
}
} else {
return 'No hay cuentas disponibles, comuniquese con soporte!';
@@ -469,56 +478,49 @@ class MenuController extends Controller
if (!empty($y)) {
$consulta->update(['estado'=>'activo']);
$consulta->update(['estado' => 'activo']);
$this->cred($consulta);
$encryptado = Crypt::encryptString($consulta->id);
//dd('llegue');
return redirect('/credenciales?id='.$encryptado);
}else{
return redirect('/credenciales?id=' . $encryptado);
} else {
return 'No hay cuentas disponibles, comuniquese con soporte!';
}
}
}
}
//wompi
}
}
//wompi
public function wompi_pagos(Request $request){
public function wompi_pagos(Request $request)
{
$response = Http::get("https://sandbox.wompi.co/v1/transactions/136099-1677473887-65588");
$response = json_decode($response);
//dd($response);
}
}
public function wompi_hook(Request $request){
public function wompi_hook(Request $request)
{
//return json_encode('hola');
if (!empty($request)) {
foreach($request->data as $item ){
foreach ($request->data as $item) {
//return $item;
$status = $item['status'];
$user_id = $item['reference'];
$monto = substr($item['amount_in_cents'], 0, -2);
$metodo_pago = $item['payment_method_type'];
}
$update_recargas = recarga::where('reference',$referencia)->update(['status' => $status,'payment_method_id'=> $metodo_pago]);
$update_recargas = recarga::where('reference', $referencia)->update(['status' => $status, 'payment_method_id' => $metodo_pago]);
if ($status == 'APPROVED') {
$usuario = recarga::where('reference',$referencia)->with('usuario')->first()->usuario;
$usuario = recarga::where('reference', $referencia)->with('usuario')->first()->usuario;
$saldo = $usuario->saldo;
$saldo_anterior = $saldo->valor;
$rol = $usuario->rol->nombre;
@@ -531,33 +533,31 @@ public function wompi_hook(Request $request){
if (!empty($saldo_anterior)) {
$valor= (float)$saldo_anterior + (float)$monto - (float)$monto_adicional;
$nuevo_saldo = $saldo->update(['valor'=>$valor]);
$valor = (float)$saldo_anterior + (float)$monto - (float)$monto_adicional;
$nuevo_saldo = $saldo->update(['valor' => $valor]);
// return $nuevo_saldo;
}
}
}
}
}
public function cred($consulta){
public function cred($consulta)
{
$encryptado = Crypt::encryptString($consulta->id);
$enlace = '/credenciales?id='.$encryptado;
$enlace = '/credenciales?id=' . $encryptado;
$user=User::find($consulta->cliente);
if (!empty($consulta->promocion_id)){ {
$user = User::find($consulta->cliente);
if (!empty($consulta->promocion_id)) { {
$shortURLObject = ShortURL::destinationUrl('https://app.sirpremium.com.co'.$enlace)->make();
$shortURLObject = ShortURL::destinationUrl('https://app.sirpremium.com.co' . $enlace)->make();
$shortURL = $shortURLObject->default_short_url;
$message = $consulta->promocion->nombre.'. Ver credenciales: '.$shortURL ;
$recipients= '+57'.$consulta->cliente->celular;
$message = $consulta->promocion->nombre . '. Ver credenciales: ' . $shortURL;
$recipients = '+57' . $consulta->cliente->celular;
$this->sendMessage($message, $recipients);
@@ -567,17 +567,17 @@ public function cred($consulta){
'cliente' => $consulta->cliente->name,
'servicio' => $consulta->promocion->nombre,
'tipo' => 'compra',
'vendedor' => Role::where('nombre','super')->first()->usuarios->first()->name,
'vendedor' => Role::where('nombre', 'super')->first()->usuarios->first()->name,
];
}
if (!empty($consulta->tarifa_id)){
if (!empty($consulta->tarifa_id)) {
$shortURLObject = ShortURL::destinationUrl('https://app.sirpremium.com.co'.$enlace)->make();
$shortURLObject = ShortURL::destinationUrl('https://app.sirpremium.com.co' . $enlace)->make();
$shortURL = $shortURLObject->default_short_url;
$message = $consulta->tarifa->servicio->nombre.'-'.$consulta->tarifa->pantallas. 'P. Ver credenciales: '.$shortURL ;
$recipients= '+57'.$consulta->cliente->celular;
$message = $consulta->tarifa->servicio->nombre . '-' . $consulta->tarifa->pantallas . 'P. Ver credenciales: ' . $shortURL;
$recipients = '+57' . $consulta->cliente->celular;
$this->sendMessage($message, $recipients);
@@ -586,26 +586,23 @@ public function cred($consulta){
'enlace' => $enlace,
'fecha_final' => $consulta->fecha_final,
'cliente' => $consulta->cliente->name,
'servicio' => $consulta->tarifa->servicio->nombre.'-'.$consulta->tarifa->pantallas. 'pantallas',
'servicio' => $consulta->tarifa->servicio->nombre . '-' . $consulta->tarifa->pantallas . 'pantallas',
'tipo' => 'compra',
'vendedor' => Role::where('nombre','super')->first()->usuarios->first()->name,
'vendedor' => Role::where('nombre', 'super')->first()->usuarios->first()->name,
];
}
Notification::send($user, new compra($notificacion));
}
}
public function sendMessage($message, $recipients)
{
}
}
public function sendMessage($message, $recipients)
{
$auth_basic = base64_encode(getenv("USER_LABSMOBILE").':'.getenv("PASS_LABSMOBILE"));
$auth_basic = base64_encode(getenv("USER_LABSMOBILE") . ':' . getenv("PASS_LABSMOBILE"));
$curl = curl_init();
@@ -617,9 +614,9 @@ public function sendMessage($message, $recipients)
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => '{"message":"'.$message.'", "tpoa":"Sender","recipient":[{"msisdn":"'.$recipients.'"}]}',
CURLOPT_POSTFIELDS => '{"message":"' . $message . '", "tpoa":"Sender","recipient":[{"msisdn":"' . $recipients . '"}]}',
CURLOPT_HTTPHEADER => array(
"Authorization: Basic ".$auth_basic,
"Authorization: Basic " . $auth_basic,
"Cache-Control: no-cache",
"Content-Type: application/json"
),
@@ -631,14 +628,11 @@ public function sendMessage($message, $recipients)
curl_close($curl);
if ($err) {
} else {
}
}
public function showmp(Request $request){
}
public function showmp(Request $request)
{
Log::info('MercadoPago webhook received', $request->all());
@@ -654,34 +648,31 @@ public function showmp(Request $request){
if ($status == 'approved') {
$metodo_pago = $response->payment_method_id;
$referencia = $response->external_reference;
$consulta = recarga::where('reference',$referencia)->where('status',$status)->exists();
if ($consulta == false){
$update_recargas = recarga::where('reference',$referencia)->update(['status' => $status,'payment_method_id'=> $metodo_pago]);
$recarga = recarga::where('reference',$referencia)->with('usuario')->first();
$usuario= $recarga->usuario;
$consulta = recarga::where('reference', $referencia)->where('status', $status)->exists();
if ($consulta == false) {
$update_recargas = recarga::where('reference', $referencia)->update(['status' => $status, 'payment_method_id' => $metodo_pago]);
$recarga = recarga::where('reference', $referencia)->with('usuario')->first();
$usuario = $recarga->usuario;
$saldo = $usuario->saldo;
$saldo_anterior = $saldo->valor;
$monto = $recarga->valor_recarga;
$valor= (float)$saldo_anterior + (float)$monto ;
$nuevo_saldo = $saldo->update(['valor'=>$valor]);
$valor = (float)$saldo_anterior + (float)$monto;
$nuevo_saldo = $saldo->update(['valor' => $valor]);
}
}
return response()->json(['status' => 'ok']);
}
}
public function pruebas (){
public function pruebas()
{
$fechaHoy = Carbon::now()->format('Y-m-d');
$consulta_historial = Historiale::whereDate('fecha_final', $fechaHoy)->with('cliente')->get();
$consulta_historial = Historiale::whereDate('fecha_final', $fechaHoy)->with('cliente')->get();
foreach ($consulta_historial as $item) {
@@ -689,7 +680,7 @@ $consulta_historial = Historiale::whereDate('fecha_final', $fechaHoy)->with('cli
if (!empty($item->promocion_id)) {
$nombre= $item->promocion->nombre;
$nombre = $item->promocion->nombre;
}
if (!empty($item->tarifa_id)) {
$nombre = $item->tarifa->servicio->nombre . '-' . $item->tarifa->pantallas . 'P';
@@ -701,7 +692,7 @@ $consulta_historial = Historiale::whereDate('fecha_final', $fechaHoy)->with('cli
'cliente' => $item->cliente->name,
'servicio' => $nombre,
'tipo' => 'vencimiento',
'vendedor' =>$item->vendedor->name,
'vendedor' => $item->vendedor->name,
];
@@ -750,10 +741,10 @@ $consulta_historial = Historiale::whereDate('fecha_final', $fechaHoy)->with('cli
$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){
foreach ($item1->cuentas->unique() as $item2) {
//dd($item2);
$logs = new log;
$logs->historial_id = $item1->id;
@@ -764,17 +755,18 @@ $consulta_historial = Historiale::whereDate('fecha_final', $fechaHoy)->with('cli
//dd('termine');
}
}
}
public function click_compra(Request $request) {
public function click_compra(Request $request)
{
// Aquí puedes guardar, registrar o procesar la info
RegistroCompra::create([
'user_id' => auth()->id(),
'nombre' => $request->nombre,
'email' => $request->email,
'saldo' => $request->saldo,
]);
]);
return response()->json(['success' => true]);
}
return response()->json(['success' => true]);
}
}
+67 -1
View File
@@ -2,12 +2,78 @@
namespace App\Http\Livewire;
use App\Models\Promociones;
use App\Models\Role;
use App\Models\Servicio;
use App\Models\Tarifas;
use Livewire\Component;
use Livewire\WithPagination;
use Jantinnerezo\LivewireAlert\LivewireAlert;
use Illuminate\Support\Facades\Auth;
class ShowTarifas extends Component
{
use LivewireAlert;
use WithPagination;
public $tarifas;
public $planes;
// Tarifa datos
public $pantallas;
public $dias = 30;
public $precio;
public $utilidad;
public $estado;
public $servicio_id;
public $plan_id;
public $rol_id;
public function render()
{
return view('livewire.show-tarifas');
$this->tarifas = Tarifas::where('servicio_id', $this->servicio_id)->where('rol_id', Auth::user()->rol->id)->where('estado', 'activo')->get();
$this->planes = Tarifas::where('servicio_id', $this->servicio_id)->where('rol_id', Auth::user()->rol->id)->where('estado', 'activo')->get();
return view('livewire.show-tarifas', [
'roles' => Role::where('subvendedor_id', auth()->user()->id)->get(),
'promo' => Promociones::where('visible', 'true')->get(),
'servicios' => Servicio::where('estado', 'activo')->get(),
]);
}
public function guardarTarifa()
{
$this->validate([
'pantallas' => 'required',
'dias' => 'required',
'precio' => 'required',
'utilidad' => 'required',
'estado' => 'required',
'servicio_id' => 'required',
'rol_id' => 'required',
], [
'pantallas.required' => 'El campo pantallas es obligatorio',
'dias.required' => 'El campo días es obligatorio',
'precio.required' => 'El campo precio es obligatorio',
'utilidad.required' => 'El campo utilidad es obligatorio',
'estado.required' => 'El campo estado es obligatorio',
'servicio_id.required' => 'El campo servicio es obligatorio',
'rol_id.required' => 'El campo rol es obligatorio',
]);
Tarifas::create([
'pantallas' => $this->pantallas,
'dias' => $this->dias,
'valor' => $this->precio,
'utilidad' => $this->utilidad,
'estado' => $this->estado ? 'activo' : 'inactivo',
'servicio_id' => $this->servicio_id,
'rol_id' => $this->rol_id,
'subvendedor_id' => Auth::user()->id,
]);
$this->alert('success', '¡Tarifas creada correctamente!', [
'position' => 'top'
]);
}
}
+25 -3
View File
@@ -100,7 +100,6 @@ class ShowUsuarios extends Component
public function render()
{
$consulta_tarifas = TarifaPromo::take(1);
$consulta_usuarios = User::withCount(['usuario_tarifas as active_tarifas' => function ($query) {
@@ -114,9 +113,15 @@ class ShowUsuarios extends Component
->orWhere('email', 'ILIKE', '%' . $this->buscar . '%');
});
if ($this->verPreciosPersonalizados) {
$consulta_usuarios = $consulta_usuarios->havingRaw('active_tarifas > 0 OR active_promos > 0');
$consulta_usuarios = $consulta_usuarios->where(function ($query) {
$query->whereHas('usuario_tarifas', function ($q) {
$q->where('visible', true);
})
->orWhereHas('usuario_promos', function ($q) {
$q->where('visible', true);
});
});
}
if (!(Auth::user()->rol->nombre == "super")) {
@@ -316,6 +321,23 @@ class ShowUsuarios extends Component
$this->limpiarSaldo();
}
public function quitarSubvendedor($id)
{
User::FindOrFail($id);
User::find($id)->update([
'subvendedor' => false
]);
}
public function ponerSubvendedor($id)
{
User::FindOrFail($id);
User::find($id)->update([
'subvendedor' => true
]);
}
public function editar($id)
{
$this->id_edit = $id;
+24 -18
View File
@@ -8,6 +8,7 @@ use Illuminate\Database\Eloquent\Model;
class Tarifas extends Model
{
use HasFactory;
protected $fillable = [
'pantallas',
'dias',
@@ -15,37 +16,42 @@ class Tarifas extends Model
'utilidad',
'estado',
'servicio_id',
'rol_id'
'rol_id',
'subvendedor_id',
];
public function servicio(){
return $this ->belongsTo(Servicio::class);
public function servicio()
{
return $this->belongsTo(Servicio::class);
}
public function preferenciales(){
return $this ->hasMany(Preferencial::class,'tarifa_id');
public function preferenciales()
{
return $this->hasMany(Preferencial::class, 'tarifa_id');
}
public function cuentas(){
return $this ->hasMany(Cuentas::class,'tarifa_id');
public function cuentas()
{
return $this->hasMany(Cuentas::class, 'tarifa_id');
}
public function historiales(){
return $this ->hasMany(Historiale::class,'tarifa_id');
public function historiales()
{
return $this->hasMany(Historiale::class, 'tarifa_id');
}
public function promociones(){
return $this ->belongsToMany(Promociones::class,'promocion_tarifas','tarifa_id','promocion_id');
public function promociones()
{
return $this->belongsToMany(Promociones::class, 'promocion_tarifas', 'tarifa_id', 'promocion_id');
}
public function rol(){
return $this ->belongsTo(Role::class);
public function rol()
{
return $this->belongsTo(Role::class);
}
public function usuario_tarifas(){
return $this ->hasMany(Usuario_tarifa::class,'tarifa_id');
public function usuario_tarifas()
{
return $this->hasMany(Usuario_tarifa::class, 'tarifa_id');
}
}
+2 -1
View File
@@ -113,10 +113,11 @@
<h4 @click="selected !== 0 ? selected = 0 : selected = null" class="cursor-pointer px-5 py-3 bg-[#b221fd] text-white text-center inline-block hover:bg-[#7a02b8] hover:shadow rounded-lg">
Admin
</h4>
<p class="absolute bg-[#f2f4ff] rounded-md @if (auth()->user()->rol->nombre == 'editor') -top-[400%] @elseif (auth()->user()->rol->nombre == 'administrador') -top-[200%] @elseif (auth()->user()->subvendedor) -top-3 @else -top-[800%] @endif -right-[20%] sm:-right-[55%]" x-show="selected == 0">
<p class="absolute bg-[#f2f4ff] rounded-md @if (auth()->user()->rol->nombre == 'editor') -top-[400%] @elseif (auth()->user()->rol->nombre == 'administrador') -top-[200%] @elseif (auth()->user()->rol->nombre == 'super') -top-[300%] @elseif (auth()->user()->subvendedor) -top-3 @else -top-[800%] @endif -right-[20%] sm:-right-[55%]" x-show="selected == 0">
@if (auth()->user()->subvendedor)
<a class="block cursor-pointer text-center hover:bg-[#d1d3e1] border-b w-full px-3 py-1" href="{{ route('roles') }}">Gestión Roles</a>
<a class="block cursor-pointer text-center hover:bg-[#d1d3e1] border-b w-full px-3 py-1" href="{{ route('usuarios') }}">Gestión Usuarios</a>
<a class="block cursor-pointer text-center hover:bg-[#d1d3e1] border-b w-full px-3 py-1" href="{{ route('tarifas') }}">Gestión Tarifas</a>
@if ( auth()->user()->rol->nombre == 'super' || auth()->user()->rol->nombre == 'administrador' || auth()->user()->rol->nombre == 'editor')
<a class="block cursor-pointer hover:rounded-t-md rounded-t-md text-center hover:bg-[#d1d3e1] border-b w-full px-3 py-1" href="{{ route('planes') }}">Gestión Planes</a>
<a class="block cursor-pointer hover:rounded-b-md rounded-b-md text-center hover:bg-[#d1d3e1] w-full px-3 py-1" href="{{ route('import') }}">Importar cuentas</a>
+11 -28
View File
@@ -24,7 +24,7 @@
{{-- Buscador --}}
<div class="bg-[#f5f5f5] md:w-[100%] m-auto p-2 md:p-5 rounded-[1.2rem] relative mb-4">
<div class="bg-[#f5f5f5] md:w-full m-auto p-2 md:p-5 rounded-2xl relative mb-4">
<div class="grid grid-cols-1 text-center sm:flex justify-between my-2 items-center text-sm ">
<div class="grid grid-cols-1 sm:flex items-center gap-4">
<div class="flex text-sm">
@@ -32,45 +32,28 @@
Planes
</div>
<a x-on:click="newCuenta = true"
class="justify-center flex px-4 py-2 rounded-lg cursor-pointer text-white bg-[#B221FD] hover:bg-[#7a02b8]">
<a x-on:click="newCuenta = true" class="justify-center flex px-4 py-2 rounded-lg cursor-pointer text-white bg-[#B221FD] hover:bg-[#7a02b8]">
Nueva cuenta
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1"
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">
<path
d="M480,224H288V32c0-17.673-14.327-32-32-32s-32,14.327-32,32v192H32c-17.673,0-32,14.327-32,32s14.327,32,32,32h192v192 c0,17.673,14.327,32,32,32s32-14.327,32-32V288h192c17.673,0,32-14.327,32-32S497.673,224,480,224z"
fill="#ffffff" />
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" 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">
<path d="M480,224H288V32c0-17.673-14.327-32-32-32s-32,14.327-32,32v192H32c-17.673,0-32,14.327-32,32s14.327,32,32,32h192v192 c0,17.673,14.327,32,32,32s32-14.327,32-32V288h192c17.673,0,32-14.327,32-32S497.673,224,480,224z" fill="#ffffff" />
</svg>
</a>
@if (auth()->user()->rol->nombre != 'editor' && auth()->user()->rol->nombre != 'administrador')
<a x-on:click="modTarifas = true"
class="justify-center flex px-4 py-2 rounded-lg cursor-pointer text-white bg-[#B221FD] hover:bg-[#7a02b8]">
<a x-on:click="modTarifas = true" class="justify-center flex px-4 py-2 rounded-lg cursor-pointer text-white bg-[#B221FD] hover:bg-[#7a02b8]">
Modificar tarifas
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"
xmlns:svgjs="http://svgjs.com/svgjs" version="1.1" class="w-4 ml-2" x="0" y="0"
viewBox="0 0 24 24" style="enable-background:new 0 0 512 512" xml:space="preserve">
<polygon points="14.604 5.687 0 20.29 0 24 3.71 24 18.313 9.396 14.604 5.687" fill="#ffffff"
data-original="#000000" />
<path
d="M23.232.768a2.624,2.624,0,0,0-3.71,0l-3.5,3.505,3.709,3.709,3.5-3.5A2.624,2.624,0,0,0,23.232.768Z"
fill="#ffffff" data-original="#000000" />
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:svgjs="http://svgjs.com/svgjs" version="1.1" class="w-4 ml-2" x="0" y="0" viewBox="0 0 24 24" style="enable-background:new 0 0 512 512" xml:space="preserve">
<polygon points="14.604 5.687 0 20.29 0 24 3.71 24 18.313 9.396 14.604 5.687" fill="#ffffff" data-original="#000000" />
<path d="M23.232.768a2.624,2.624,0,0,0-3.71,0l-3.5,3.505,3.709,3.709,3.5-3.5A2.624,2.624,0,0,0,23.232.768Z" fill="#ffffff" data-original="#000000" />
</svg>
</a>
@endif
</div>
<div class="flex relative my-2">
<input id="buscar" type="search" wire:model="buscar" placeholder="Buscar"
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">
<svg class="w-5 absolute top-2 right-3" xmlns="http://www.w3.org/2000/svg" version="1.1"
xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:svgjs="http://svgjs.com/svgjs" class="w-4 absolute"
x="0" y="0" viewBox="0 0 24 24" style="enable-background:new 0 0 512 512;rotate: 90deg;"
xml:space="preserve" class="">
<input id="buscar" type="search" wire:model="buscar" placeholder="Buscar" 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">
<svg class="w-5 absolute top-2 right-3" xmlns="http://www.w3.org/2000/svg" version="1.1" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:svgjs="http://svgjs.com/svgjs" class="w-4 absolute" x="0" y="0" viewBox="0 0 24 24" style="enable-background:new 0 0 512 512;rotate: 90deg;" xml:space="preserve" class="">
<g>
<g id="Layer_31" data-name="Layer 31">
<path
d="m21.71 20.29-5.4-5.39a7.92 7.92 0 0 0 1.69-4.9 8 8 0 1 0 -8 8 7.92 7.92 0 0 0 4.9-1.69l5.39 5.4a1 1 0 0 0 1.42 0 1 1 0 0 0 0-1.42zm-17.71-10.29a6 6 0 1 1 6 6 6 6 0 0 1 -6-6z"
fill="#b221fd" data-original="#000000" class=""></path>
<path d="m21.71 20.29-5.4-5.39a7.92 7.92 0 0 0 1.69-4.9 8 8 0 1 0 -8 8 7.92 7.92 0 0 0 4.9-1.69l5.39 5.4a1 1 0 0 0 1.42 0 1 1 0 0 0 0-1.42zm-17.71-10.29a6 6 0 1 1 6 6 6 6 0 0 1 -6-6z" fill="#b221fd" data-original="#000000" class=""></path>
</g>
</g>
</svg>
+149 -2
View File
@@ -1,3 +1,150 @@
<div>
<h1>Tarifas</h1>
<div x-data="{
modTarifas: @entangle('modTarifas'),
}" class="h-full w-full md:my-2">
<div class=" fixed backdrop-blur-sm bg-white/70 left-0 bottom-0 top-0 right-0 h-full z-40" wire:loading wire:target="">
<div class="grid h-full place-items-center">
<div class="max-w-xs">
<img src="./img/loading.gif" alt="" class="w-full text-center">
<p class="text-gray-500 text-center">Cargando</p>
</div>
</div>
</div>
<div class="bg-[#f5f5f5] md:w-full m-auto p-2 md:p-5 rounded-2xl relative mb-4">
<div class="grid grid-cols-1 text-center sm:flex justify-between my-2 items-center text-sm">
<div class="grid grid-cols-1 sm:flex items-center gap-4">
<div class="flex text-sm">
<x-icon-arrow-right />
Tarifas
</div>
@if (auth()->user()->subvendedor)
<a x-on:click="modTarifas = true" class="justify-center flex px-4 py-2 rounded-lg cursor-pointer text-white bg-[#B221FD] hover:bg-[#7a02b8]">
Modificar tarifas
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:svgjs="http://svgjs.com/svgjs" version="1.1" class="w-4 ml-2" x="0" y="0" viewBox="0 0 24 24" style="enable-background:new 0 0 512 512" xml:space="preserve">
<polygon points="14.604 5.687 0 20.29 0 24 3.71 24 18.313 9.396 14.604 5.687" fill="#ffffff" data-original="#000000" />
<path d="M23.232.768a2.624,2.624,0,0,0-3.71,0l-3.5,3.505,3.709,3.709,3.5-3.5A2.624,2.624,0,0,0,23.232.768Z" fill="#ffffff" data-original="#000000" />
</svg>
</a>
@endif
@if (auth()->user()->subvendedor)
<a x-on:click="modTarifas = true" class="justify-center flex px-4 py-2 rounded-lg cursor-pointer text-white bg-[#B221FD] hover:bg-[#7a02b8]">Mod.
tarifas promos.
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:svgjs="http://svgjs.com/svgjs" version="1.1" class="w-4 ml-2" x="0" y="0" viewBox="0 0 24 24" style="enable-background:new 0 0 512 512" xml:space="preserve">
<polygon points="14.604 5.687 0 20.29 0 24 3.71 24 18.313 9.396 14.604 5.687" fill="#ffffff" data-original="#000000" />
<path d="M23.232.768a2.624,2.624,0,0,0-3.71,0l-3.5,3.505,3.709,3.709,3.5-3.5A2.624,2.624,0,0,0,23.232.768Z" fill="#ffffff" data-original="#000000" />
</svg>
</a>
@endif
</div>
</div>
<x-ver-entrada />
<div x-cloak x-show="modTarifas" x-transition:enter="transition duration-350" 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">
<div class="grid h-full place-items-center">
<div class="bg-white px-4 pt-5 pb-4 sm:p-6 sm:pb-4 rounded-2xl shadow-md">
<div class="mb-4">
<select name="servicio" id="servicio_id" name="servicio_id" wire:model="servicio_id" class="border-2 border-neutral-200 rounded-[0.8rem] shadow apperance-none focus:border-neutral-300 focus:ring-0 w-[72%] sm:w-60 py-2 px-3 text-gray-700 leading-tight focus:outline-none focus:shadow-outline">
<option value="" selected>Servicios</option>
@foreach ($servicios as $servicio)
<option value="{{ $servicio->id }}">{{ $servicio->nombre ?? '' }}</option>
@endforeach
</select>
</div>
<div>
<label class="block text-gray-700 text-sm font-bold mb-2">Pantallas:</label>
<div class="grid grid-cols-6 gap-2 text-left mb-4">
<div>
<label for="rol_id" class="text-gray-500 text-sm">Rol</label>
<select id="rol_id" name="rol_id" wire:model="rol_id" class="border-2 border-neutral-200 rounded-[0.8rem] shadow apperance-none focus:border-neutral-300 focus:ring-0 w-full py-2 px-3 text-gray-700 leading-tight focus:outline-none focus:shadow-outline">
<option value="" selected>Roles</option>
@foreach ($roles as $rol)
<option value="{{ $rol->id }}">{{ $rol->nombre ?? '' }}</option>
@endforeach
</select>
</div>
<div>
<label id="plan_id" class="text-gray-500 text-sm">Plan</label>
<select id="plan_id" name="plan_id" wire:model="plan_id" class="border-2 border-neutral-200 rounded-[0.8rem] shadow apperance-none focus:border-neutral-300 focus:ring-0 w-full py-2 px-3 text-gray-700 leading-tight focus:outline-none focus:shadow-outline">
<option value="" selected>Planes</option>
@foreach ($planes as $plan)
<option value="{{ $plan->id }}">{{ $plan->pantallas ?? 0 }} pantallas - {{ $plan->dias ?? 0 }} dias</option>
@endforeach
</select>
</div>
<div>
<label for="precio" class="text-gray-500 text-sm">Precio</label>
<input type="number" id="precio" name="precio" wire:model="precio" min="0" class="w-full border-2 border-neutral-200 rounded-[0.8rem] focus:ring-0 shadow apperance-none focus:border-neutral-300 py-2 pl-2 text-gray-700 leading-tight focus:outline-none focus:shadow-outline">
</div>
<div>
<label for="utilidad" class="text-gray-500 text-sm">Utilidad</label>
<input type="number" id="utilidad" name="utilidad" wire:model="utilidad" min="0" class="w-full border-2 border-neutral-200 rounded-[0.8rem] focus:ring-0 shadow apperance-none focus:border-neutral-300 py-2 pl-2 text-gray-700 leading-tight focus:outline-none focus:shadow-outline">
</div>
<div class="flex m-auto items-center">
<label for="estado" class="text-gray-500 text-sm mr-2">Activa</label>
<input type="checkbox" id="estado" name="estado" wire:model="estado" checked class="border-2 border-neutral-200 focus:ring-0 shadow apperance-none focus:border-neutral-300 text-[#B221FD] leading-tight focus:outline-none focus:shadow-outline">
</div>
<div class="mb-3 mt-3 flex justify-end">
<button wire:click="guardarTarifa" type="button" class="inline-flex justify-center w-full md:w-auto rounded-md border border-transparent px-4 py-1 sm:mb-[0] mb-2 text-white bg-[#B221FD] hover:bg-[#7a02b8] focus:shadow-outline-green ease-in-out sm-text-sm sm-leading-5">Añadir</button>
</div>
</div>
</div>
<div class="overflow-y-auto max-h-48">
<table class="w-full sm-w-[20rem] text-center mt-4 border-separate border-spacing-y-2 mb-4">
<thead class="font-normal bg-[#000029] text-white h-9">
<tr class="text-left">
<th class="rounded-l-lg font-normal pl-[1rem]">Estado</th>
<th class="font-normal pl-[1rem]">Rol</th>
<th class="font-normal pl-[1rem] whitespace-nowrap">Pantallas</th>
<th class="font-normal pl-[1rem]">Valor</th>
<th class="font-normal pl-[1rem]">Dias</th>
<th class="font-normal pl-[1rem]">Utilidad</th>
<th class="font-normal pl-[1rem]"></th>
<th class="rounded-r-lg font-normal w-[1rem]"></th>
</tr>
</thead>
<tbody class="text-gray-500 select-none">
@if (!empty($tarifas))
@foreach ($tarifas as $tarifa)
<tr class="border-gray-200 text-left w-full pl-4">
<td class="pl-[1rem]">
@if ($tarifa->estado == 'activo')
<div class="bg-green-500 rounded-full w-3 h-3"></div>
@else
<div class="bg-red-500 rounded-full w-3 h-3"></div>
@endif
</td>
<td class="pl-[1rem]">{{ $tarifa->rol->nombre ?? '' }}</td>
<td class="pl-[1rem]">{{ $tarifa->pantallas ?? '' }}</td>
<td class="pl-[1rem]">{{ number_format($tarifa->valor ?? 0) }}</td>
<td class="pl-[1rem]">{{ $tarifa->dias ?? '' }}</td>
<td class="pl-[1rem]">{{ number_format($tarifa->utilidad ?? 0) }}</td>
<td class="pl-[1rem]">
<button wire:click="editar({{ $tarifa }})"
class="justify-center flex px-3 py-2 rounded-lg text-xs cursor-pointer text-white bg-[#B221FD] hover:bg-[#7a02b8]">Editar</button>
</td>
</tr>
@endforeach
@endif
</tbody>
</table>
</div>
<div class="bg-white px-4 py-3 sm:px-6 sm:flex sm:flex-row-reverse sm:justify-evenly gap-5 mt-4">
<span>
<button x-on:click="modTarifas=false" wire:click="" type="button"
class="inline-flex justify-center w-full rounded-md border border-transparent px-4 py-2 text-white bg-[#585858] hover:bg-[#3a3a3a] focus:shadow-outline-green ease-in-out sm-text-sm sm-leading-5">Cerrar</button>
</span>
</div>
</div>
</div>
</div>
</div>
</div>
@@ -9,8 +9,7 @@
modalSaldoDesc: @entangle('modalSaldoDesc'),
editarTarifaRol: @entangle('editarTarifaRol')
}" class="h-full w-full md:my-2">
<div class="absolute backdrop-blur-sm bg-white/70 left-0 bottom-0 top-0 right-0 h-full z-40" wire:loading
wire:target="gestionarPromociones,actualizarTarifaRol,addpromos,eliminarUsuarioPromo,gestionar,eliminarUsuarioTarifa,addtarifas,crear,actualizar,editar,eliminar,limpiarInputAdd,limpiarInputEdit,editarPassword,limpiarContra,confirmarNewPassword,saldo,addSaldo">
<div class="absolute backdrop-blur-sm bg-white/70 left-0 bottom-0 top-0 right-0 h-full z-40" wire:loading wire:target="gestionarPromociones,quitarSubvendedor,ponerSubvendedor,actualizarTarifaRol,addpromos,eliminarUsuarioPromo,gestionar,eliminarUsuarioTarifa,addtarifas,crear,actualizar,editar,eliminar,limpiarInputAdd,limpiarInputEdit,editarPassword,limpiarContra,confirmarNewPassword,saldo,addSaldo">
<div class="grid h-full place-items-center ">
<div class="max-w-xs">
<img src="./img/loading.gif" alt="" class="w-full text-center">
@@ -19,28 +18,24 @@
</div>
</div>
<div class="bg-[#f5f5f5] md:w-full m-auto p-2 md:p-5 rounded-lg relative mb-4">
<div class="md:flex gap-4 justify-center my-2 items-center text-center">
<div class="bg-[#f5f5f5] md:w-full m-auto p-2 md:p-5 rounded-2xl relative mb-4">
<div class="grid grid-cols-1 text-center sm:flex justify-between my-2 items-center text-sm">
<div class="grid grid-cols-1 sm:flex items-center gap-4">
<div class="flex text-sm">
<x-icon-arrow-right />
Usuario
</div>
<div class="flex gap-4">
@if (auth()->user()->subvendedor || auth()->user()->rol->nombre === 'administrador' || auth()->user()->rol->nombre === 'editor' || auth()->user()->rol->nombre === 'super')
<a x-on:click="add = !add"
class="justify-center flex px-4 py-2 rounded-lg cursor-pointer text-white bg-[#B221FD] hover:bg-[#7a02b8] mb-3 md:mb-0">Añadir
<a x-on:click="add = !add" class="justify-center flex px-4 py-2 rounded-lg cursor-pointer text-white bg-[#B221FD] hover:bg-[#7a02b8] mb-3 md:mb-0">Añadir
usuario
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"
version="1.1" 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">
<path
d="M480,224H288V32c0-17.673-14.327-32-32-32s-32,14.327-32,32v192H32c-17.673,0-32,14.327-32,32s14.327,32,32,32h192v192 c0,17.673,14.327,32,32,32s32-14.327,32-32V288h192c17.673,0,32-14.327,32-32S497.673,224,480,224z"
fill="#ffffff" />
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" 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">
<path d="M480,224H288V32c0-17.673-14.327-32-32-32s-32,14.327-32,32v192H32c-17.673,0-32,14.327-32,32s14.327,32,32,32h192v192 c0,17.673,14.327,32,32,32s32-14.327,32-32V288h192c17.673,0,32-14.327,32-32S497.673,224,480,224z" fill="#ffffff" />
</svg>
</a>
@endif
@if (auth()->user()->rol->nombre === 'super')
@if (auth()->user()->rol->nombre === 'super' || auth()->user()->rol->nombre === 'administrador')
<a x-on:click="modTarifas = true" class="justify-center flex px-4 py-2 rounded-lg cursor-pointer text-white bg-[#B221FD] hover:bg-[#7a02b8]">Mod.
tarifas promos.
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:svgjs="http://svgjs.com/svgjs" version="1.1" class="w-4 ml-2" x="0" y="0" viewBox="0 0 24 24" style="enable-background:new 0 0 512 512" xml:space="preserve">
@@ -50,6 +45,7 @@
</a>
@endif
</div>
</div>
<div class="flex relative text-sm mx-auto w-64 md:w-auto my-2">
<input id="buscar" type="search" wire:model="buscar" placeholder="Buscar" class=" shadow-sm border-2 active:border-neutral-200 focus:ring-0 border-neutral-200 w-64 md:w-auto rounded-md pr-7 py-1 m-auto focus:border-neutral-300 focus:outline-none focus:shadow-outline">
@@ -144,6 +140,11 @@
<div x-cloak x-show="openOption" @click.away="openOption = false" class="sm:absolute bg-white text-center w-[8rem] rounded-[1rem] border-b border-gray-200 shadow-lg right-10">
<button x-on:click="openOption=false" wire:click="editar({{ $usuario->id }})" class="text-gray-500 w-full py-1 hover:bg-gray-200 border-b border-gray-300 hover:rounded-t-[1rem]">Editar</button>
<button x-on:click="openOption=!openOption" wire:click="editarPassword({{ $usuario->id }})" class="text-gray-500 w-full py-1 hover:bg-gray-200 border-b border-gray-300">Editar password</button>
@if ($usuario->subvendedor)
<button x-on:click="openOption=!openOption" wire:click="quitarSubvendedor({{ $usuario->id }})" class="text-gray-500 w-full py-1 hover:bg-gray-200 border-b border-gray-300">Quitar subvendedor</button>
@else
<button x-on:click="openOption=!openOption" wire:click="ponerSubvendedor({{ $usuario->id }})" class="text-gray-500 w-full py-1 hover:bg-gray-200 border-b border-gray-300">Habilitar subvendedor</button>
@endif
<button x-on:click="openOption=false,gestion=true" wire:click="gestionar({{ $usuario->id }},'{{ $usuario->rol_id }}','{{ $usuario->name }}')" class="text-gray-500 w-full py-1 hover:bg-gray-200 border-b border-gray-300">Precio servicio</button>
<button x-on:click="openOption=false,gestionPromo=true" wire:click="gestionarPromociones({{ $usuario->id }},'{{ $usuario->name }}')" class="text-gray-500 w-full py-1 hover:bg-gray-200 border-b border-gray-300">Precio promocion</button>
<button x-on:click="openOption=false" wire:click="eliminar({{ $usuario->id }})" class="text-white w-full py-1 bg-red-400 rounded-b-[1rem] hover:bg-red-600 hover:rounded-b-[1rem]">Eliminar</button>
+7
View File
@@ -0,0 +1,7 @@
<x-app-layout>
<div class="pb-4">
<livewire:show-tarifas />
</div>
@include('layouts.footer')
</x-app-layout>
+2 -1
View File
@@ -43,12 +43,13 @@ Route::middleware(["auth"])->group(function () {
Route::any('/logs', [MenuController::class, 'showlogs'])->name('logs');
Route::any('/usuarios', [MenuController::class, 'showusuarios'])->name('usuarios');
Route::any('/roles', [MenuController::class, 'showroles'])->name('roles');
Route::any('/tarifas', [MenuController::class, 'showtarifas'])->name('tarifas');
});
// Editores
Route::middleware(["auth", "solo_usuario_editor"])->group(function () {
Route::any('/planes', [MenuController::class, 'showplanes'])->name('planes');
Route::get('/import', [MenuController::class, 'showimport'])->name('import');
Route::any('/planes', [MenuController::class, 'showplanes'])->name('planes');
});
//Administradores