@extends('layouts.master')


@section('title', 'User Data')


@include('layouts.nav')

@section('content')

    <h3>Transacciones</h3>
    <h5>Id: {{$user->id}}</h5>
    <h5>Usuario: {{$user->username}}</h5>
    <h5>Nombre: {{$user->name}}</h5>
    <h5>Teléfono: {{$user->phone}}</h5>
    @if($user->enabled == 1)
        <h5>Cuenta: <b class="bg-success">Habilitada</b></h5>
        <h5>
            <b>Bloquear usuario:</b>

            <form action="{{ route('user.update', [$user->id]) }}" method="POST">
                <input type="hidden" name="_method" value="put">
                <input type="hidden" name="enabled" value="0">
                <button class="btn btn-danger">Bloquear</button>
                {{ csrf_field() }}
            </form>
        </h5>
    @else
        <h5>Cuenta: <b class="bg-danger">Bloqueada</b></h5>
        <h5>
            <b>Habilitar usuario:</b>

            <form action="{{ route('user.update', [$user->id]) }}" method="POST">
                <input type="hidden" name="_method" value="put">
                <input type="hidden" name="enabled" value="1">
                <button class="btn btn-success">Habilitar</button>
                {{ csrf_field() }}
            </form>
        </h5>
    @endif




    @if($data)
        <table class="table table-striped">
            <thead>
            <tr>
                <th>Fecha</th>
                <th>Monto</th>
                <th>Descuento</th>
                <th>FirstData: Auth</th>
                <th>LatinoToUp: request_id</th>
                <th>LatinoToUp: result</th>
            </tr>
            </thead>
            <tbody>
            @foreach($data as $item)
                <tr>
                    <td>{{$item->resolve_date}}</td>
                    <td>{{$item->amount}}</td>
                    <td>{{$item->discount}}</td>
                    <td>{{$item->transactionIdentifier}}</td>
                    <td>{{$item->transaction_id}}</td>
                    <td width="20%">{{str_replace(',', "\n", $item->result_doc)}}</td>
                </tr>
            @endforeach
            </tbody>
        </table>
    @else
        <h2>No se encontraron resultados.</h2>
    @endif


    
    <div><a href="{{ route('users.index')}}" class="btn btn-primary">Regresar a usuarios</a></div>

@endsection