@extends('layouts.master')


@section('title', 'Page')


@section('nav')
    @include('layouts.navinfluencer')
@endsection


@section('content')


    @if(count($influencer) > 0)


        <table class="table influencers">
            <thead>
            <tr>
                
                <th>Código</th>
                <th>Usuario</th>
                <th>Usuario fecha registro</th>
                
                <th>Usuario número</th>
                
                <th>Número de recarga</th>
                
                <th>Monto</th>
                
                <th>Carrier</th>
                <th>Telecom carrier_folio</th>
               
                <th>Residual influencer</th>
                
                <th>Porcentaje residual</th>
            </tr>
            </thead>
            <tbody>
            @foreach($influencer as $item)
                <tr>
                    
                    <td>{{$item->influencer_code}}</td>
                    <td>{{$item->user_name}}</td>
                    <td>{{$item->user_created}}</td>
                   
                    <td>{{$item->user_number}}</td>
                    
                 
                    
                    <td>{{$item->beneficiary_number}}</td>
                    
                    <td>${{$item->product_transaction_amount}}</td>

                    <td>{{$item->payment_transactions_carrier}}</td>
                    <td>{{$item->payment_transactions_carrier_folio}}</td>
                   
                    <td>${{ (($item->influencer_residual * $item->product_transaction_amount)/100) }}</td>
                    <td>{{$item->influencer_residual}}%</td>
                </tr>
            @endforeach

                <tr>
                    <td><b>Total</b></td>
                    <td></td>
                    <td></td>
                    <td></td>
                    <td></td>
                    <td></td>
                    <td></td>
                    <td></td>
                
                    <td>${{ $sum_residual }}</td>
                    <td></td>
                </tr>

            </tbody>
        </table>
    


        <div class="chart">
            <canvas id="myChart"></canvas>
        </div>


       




    @else
        <h3>No hay resultados</h3>
    @endif




@endsection


@section('js')

    <script>


    var grafica_meses = [],
        grafica_suma_residual = [];


    @foreach($grafica_meses as $item)
            grafica_meses.push("{{ $item }}");
    @endforeach


    @foreach($grafica_suma_residual as $item)
            grafica_suma_residual.push("{{ $item }}");
    @endforeach





    var ctx = document.getElementById("myChart").getContext('2d');
    var myChart = new Chart(ctx, {
        type: 'bar',
        data: {
            labels: grafica_meses,
            datasets: [{
                label: 'Residual mes',
                data: grafica_suma_residual,
                backgroundColor: [
                    'rgba(255, 99, 132, 0.2)',
                    'rgba(54, 162, 235, 0.2)',
                    'rgba(255, 206, 86, 0.2)',
                    'rgba(75, 192, 192, 0.2)',
                    'rgba(153, 102, 255, 0.2)',
                    'rgba(255, 159, 64, 0.2)'
                ],
                borderColor: [
                    'rgba(255,99,132,1)',
                    'rgba(54, 162, 235, 1)',
                    'rgba(255, 206, 86, 1)',
                    'rgba(75, 192, 192, 1)',
                    'rgba(153, 102, 255, 1)',
                    'rgba(255, 159, 64, 1)'
                ],
                borderWidth: 1
            }]
        }
    });
    </script>


@endsection
