update
This commit is contained in:
@@ -54,11 +54,11 @@ class ShowIndexServicio extends Component
|
||||
$this->fecha= $date->format('Y-m-d');
|
||||
|
||||
if (!empty($this->tarifa_id)) {
|
||||
|
||||
|
||||
|
||||
$tarifas = Tarifas::with('servicio')->where('id', $this->tarifa_id)->first();
|
||||
$this->fecha_final_1 = $today = Carbon::now()->addDays($tarifas->dias-15);
|
||||
$this->fecha_final_2 = $today = Carbon::now()->addDays($tarifas->dias+15);
|
||||
|
||||
$tarifas = Tarifas::with('servicio')->where('id', $this->tarifa_id)->first();
|
||||
|
||||
$cuentas_creadas = Cuentas::whereDate('inicio','>=',$this->fecha)->where('servicio_id',$this->servicio_id)->where('estado','activo')->get();
|
||||
$cuentas_tomadas = Historial_cuenta::whereIn('cuenta_id', $cuentas_creadas->pluck('id'))->count();
|
||||
|
||||
@@ -274,7 +274,7 @@ class ShowServicios extends Component
|
||||
|
||||
if ((int) $pantalla_servicio >= (int) $cantidad_solicitada && (int) $pantalla_servicio_completa != (int) $this->pantallas_tarjetaPlan) {
|
||||
$suma = $pantalla_servicio - $cantidad_solicitada;
|
||||
$cantidad_necesaria = 1;
|
||||
$cantidad_necesaria = $this->cantidad_tarjetaPlan;
|
||||
$cuenta = Cuentas::where('servicio_id', $this->servicio_id)->whereDate('inicio', '>=', $this->fecha)->Orderby('created_at', 'ASC')->withCount('historiales')->where('estado', 'activo')->having('historiales_count', '<=', $suma)->get();
|
||||
|
||||
} elseif ((int) $pantalla_servicio_completa == (int) $this->pantallas_tarjetaPlan) {
|
||||
@@ -292,10 +292,11 @@ class ShowServicios extends Component
|
||||
$cuenta = null;
|
||||
$cantidad_necesaria = null;
|
||||
}
|
||||
|
||||
//dd($cuenta, $cantidad_necesaria);
|
||||
for ($h = 0; $h < (int) $cantidad_necesaria; $h++) {
|
||||
|
||||
//dd($h);
|
||||
if (!empty($cuenta)) {
|
||||
|
||||
$perfil = $cuenta[$h]->historiales_count;
|
||||
|
||||
for ($y = 0; $y < (int) $pantallas; $y++) {
|
||||
@@ -315,6 +316,7 @@ class ShowServicios extends Component
|
||||
}
|
||||
|
||||
}
|
||||
//dd($historial->cuentas);
|
||||
$descuento = Saldo::where('usuario_id', Auth::user()->id)->first();
|
||||
|
||||
$saldo_anterior = $descuento->valor;
|
||||
@@ -323,6 +325,7 @@ class ShowServicios extends Component
|
||||
$cobro = $descuento->update(['valor' => $nuevo_saldo]);
|
||||
if ($cobro) {
|
||||
$historial->update(['estado' => 'activo']);
|
||||
|
||||
$this->credenciales($historial);
|
||||
} else {
|
||||
$this->alert('warning', 'Error en el cobro, comuniquese con soporte!', [
|
||||
|
||||
@@ -77,6 +77,7 @@ class ShowUsuarios extends Component
|
||||
public $precio_modTarifas = 0;
|
||||
public $consulta_saldo;
|
||||
public $modTarifas;
|
||||
public $modalSaldoDesc;
|
||||
|
||||
|
||||
|
||||
@@ -173,6 +174,23 @@ class ShowUsuarios extends Component
|
||||
$this->saldo_actual = $this->consulta_saldo->valor;
|
||||
$this->modalSaldo = true;
|
||||
|
||||
}
|
||||
public function saldodesc($user_saldo)
|
||||
{
|
||||
$this->user_saldo = $user_saldo;
|
||||
$this->consulta_saldo = Saldo::where('usuario_id', $this->user_saldo)->first();
|
||||
|
||||
if (is_null($this->consulta_saldo)) {
|
||||
$saldo = new Saldo;
|
||||
$saldo->valor = 0;
|
||||
$saldo->usuario_id = $this->user_saldo;
|
||||
$saldo->save();
|
||||
$this->consulta_saldo = $saldo;
|
||||
}
|
||||
|
||||
$this->saldo_actual = $this->consulta_saldo->valor;
|
||||
$this->modalSaldoDesc = true;
|
||||
|
||||
}
|
||||
|
||||
public function addSaldo()
|
||||
@@ -200,6 +218,31 @@ class ShowUsuarios extends Component
|
||||
|
||||
}
|
||||
|
||||
public function descontar()
|
||||
{
|
||||
$recarga = new recarga;
|
||||
$recarga->payment_method_id = 'manual';
|
||||
$recarga->status = 'Descuento';
|
||||
$recarga->usuario_id = $this->user_saldo;
|
||||
$recarga->saldo_id = $this->consulta_saldo->id;
|
||||
$recarga->monto = $this->valor_recargar;
|
||||
$recarga->valor_recarga = $this->valor_recargar;
|
||||
$recarga->save();
|
||||
|
||||
|
||||
$this->consulta_saldo->update([
|
||||
'valor' => $this->saldo_actual - $this->valor_recargar
|
||||
]);
|
||||
|
||||
$this->alert('success', 'Saldo actualizado con exito!', [
|
||||
'position' => 'top'
|
||||
]);
|
||||
|
||||
|
||||
$this->limpiarSaldo();
|
||||
|
||||
}
|
||||
|
||||
public function editar($id)
|
||||
{
|
||||
$this->id_edit = $id;
|
||||
@@ -455,6 +498,7 @@ $usuarioEliminado = User::where('name', 'usuarioEliminado')->value('id');
|
||||
{
|
||||
$this->valor_recargar = null;
|
||||
$this->modalSaldo = false;
|
||||
$this->modalSaldoDesc = false;
|
||||
}
|
||||
|
||||
/* ------------- ACTUALIZAR ------------- */
|
||||
|
||||
Reference in New Issue
Block a user