<?php ob_start(); include "../connect/db.php"; ?>
<!DOCTYPE html>
<html lang="en">

<head>
    <!-- Required meta tags-->
    <meta name="robots" content="noindex,nofollow">
<meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <meta name="description" content="au theme template">
    <meta name="author" content="Hau Nguyen">
    <meta name="keywords" content="au theme template">

    <!-- Title Page-->
    <title>Trade | Admin </title>

    <!-- Fontfaces CSS-->
    <link href="vendor/font-awesome.min.css" rel="stylesheet" media="all">
    <link href="css/font-face.css" rel="stylesheet" media="all">
    <link href="vendor/font-awesome-4.7/css/font-awesome.min.css" rel="stylesheet" media="all">
    <link href="vendor/font-awesome-5/css/fontawesome-all.min.css" rel="stylesheet" media="all">
    <link href="vendor/mdi-font/css/material-design-iconic-font.min.css" rel="stylesheet" media="all">

    <!-- Bootstrap CSS-->
    <link href="vendor/bootstrap-4.1/bootstrap.min.css" rel="stylesheet" media="all">

    <!-- Vendor CSS-->
    <link href="vendor/animsition/animsition.min.css" rel="stylesheet" media="all">
    <link href="vendor/bootstrap-progressbar/bootstrap-progressbar-3.3.4.min.css" rel="stylesheet" media="all">
    <link href="vendor/wow/animate.css" rel="stylesheet" media="all">
    <link href="vendor/css-hamburgers/hamburgers.min.css" rel="stylesheet" media="all">
    <link href="vendor/slick/slick.css" rel="stylesheet" media="all">
    <link href="vendor/select2/select2.min.css" rel="stylesheet" media="all">
    <link href="vendor/perfect-scrollbar/perfect-scrollbar.css" rel="stylesheet" media="all">

    <!-- Main CSS-->
    <link href="css/theme.css" rel="stylesheet" media="all">
    <style>
        #upload {
            opacity: 0;
        }

        #upload-label {
            position: absolute;
            top: 50%;
            left: 1rem;
            transform: translateY(-50%);
        }

        .image-area {
            border: 2px dashed rgba(255, 255, 255, 0.7);
            padding: 1rem;
            position: relative;
        }

        .image-area::before {
            content: 'Uploaded image result';
            color: #fff;
            font-weight: bold;
            text-transform: uppercase;
            position: absolute;
            top: 50%;
            left: 50%;
            transform: translate(-50%, -50%);
            font-size: 0.8rem;
            z-index: 1;
        }

        .image-area img {
            z-index: 2;
            position: relative;
        }        
    </style>
</head>

<body class="animsition">
    <div class="page-wrapper">

        <!-- START HEADER -->
        <?php include"includes/header.php" ?><br>
        <!-- END HEADER -->

        <!-- PAGE CONTAINER-->
        <div class="page-container"> 
            <div class="main-content">
                <div class="section__content section__content--p30">
                    <div class="container-fluid">
                        <div class="row">
                            <div class="col-lg-4"></div>
                            <div class="col-lg-4" style="text-align: center;">
                                <span data-toggle="modal" data-target="#modalCreate" class="btn btn-md btn-success">Create Trade &nbsp;<i class="fa fa-plus"></i></span>
                            </div>
                            <div class="col-lg-4"></div>
                        </div>
                        <div class="row">
                            <div class="col-lg-1"></div>
                            <div class="col-lg-10"><br><br>
                                <div class="card">
                                    <div class="card-body" style="border-radius: 5px;box-shadow: 0 0 10px 5px #cecece;">
                                        <h5 class="card-title">Trades</h5>
                                        <div class="table-responsive">
                                            <table class="table table-striped">
                                                <thead>
                                                    <tr>
                                                        <th scope="col">#</th>
                                                        <th scope="col">User</th>
                                                        <th scope="col">Amount</th>
                                                        <th scope="col">Action</th>
                                                        <th scope="col">Date</th>
                                                        <th scope="col">Result</th>
                                                    </tr>
                                                </thead>
                                                <tbody> 
                                                    <?php
                                                        $tosin = mysqli_query($con,"SELECT * FROM trade");
                                                        $transactions = mysqli_num_rows($tosin);
                                                        if( $transactions == 0 ){
                                                            echo'
                                                                <tr>
                                                                    <td colspan="8">Oops! No Trades have been made</td>
                                                                </tr>
                                                            '
                                                            ;
                                                        }
                                                        else{
                                                            $i = 1;
                                                            while( $tosin_req = mysqli_fetch_assoc($tosin) ){
                                                                echo'
                                                                    <tr>
                                                                        <td>'.$i.'</td>
                                                                        <td>'.$tosin_req['user'].'</td>
                                                                        <td>$'.$tosin_req['amount'].'</td>
                                                                        <td>'.$tosin_req['action'].'</td>
                                                                        <td>'.$tosin_req['trade_date'].'</td>
                                                                        <td>'.$tosin_req['result'].'</td>
                                                                        <td><a href="edittrans.php?id='.$tosin_req['id'].'" ><span class="btn btn-md btn-dark" ><i class="fa fa-edit" ></i></span></a></td>
                                                                        <td><span onclick=deleteTrans("'.$tosin_req['id'].'") class="btn btn-md btn-danger" ><i class="fa fa-trash" ></i></span></td>
                                                                    </tr>
                                                                '
                                                                ;
                                                                $i++ ;
                                                            }                                                    
                                                        }
                                                    ?>                      
                                                </tbody>
                                            </table>
                                        </div>
                                    </div>
                                </div>                                               
                            </div>
                            <div class="col-lg-1"></div>
                        </div>
                        <?php include"includes/footer.php"; ?>
                    </div>
                </div>
            </div>
            <span id="modalUploadBtn" data-toggle="modal" data-target="#modalUpload"></span>
        </div>

        <!-- MODAL VIEW -->

        <div class="modal fade" id="modalView" tabindex="-1" role="dialog" aria-labelledby="exampleModalCenterTitle" aria-hidden="true">
          <div class="modal-dialog modal-dialog-centered" role="document">
            <div class="modal-content" style="background-color: #cacaca;">
              <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                  <span aria-hidden="true">&times;</span>
                </button>
              </div>
              <div class="modal-body">
                <div class="text-center">
                  <img src="" id="uploadView" class="rounded" alt="...">
                </div>
              </div>
              <div class="modal-footer">
                <button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
              </div>
            </div>
          </div>
        </div>

        <!-- MODAL CREATE TRANSACTION -->

        <div class="modal fade" id="modalCreate" tabindex="-1" role="dialog" aria-labelledby="exampleModalCenterTitle" aria-hidden="true">
          <div class="modal-dialog modal-dialog-centered" role="document">
            <div class="modal-content">
              <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                  <span aria-hidden="true">&times;</span>
                </button>
              </div>
              <div class="modal-body">
                <form method="POST" action="../apps/man/createtrans.php">
                  <?= csrf_field() ?>
                  <div class="form-group">
                    <label for="user">User Email</label>
                    <input type="email" class="form-control" required name="user" id="user">
                  </div>
                  <div class="form-group">
                    <label for="action">Action</label>
                    <input type="text" class="form-control" required name="action" id="action">
                  </div>
                  <div class="form-group">
                    <label for="asset">Asset</label>
                    <input type="text" class="form-control" required name="asset" id="asset">
                  </div>                                    
                  <div class="form-group">
                    <label for="amount">Amount</label>
                    <input type="text" class="form-control" required name="amount" id="amount">
                  </div>
                  <div class="form-group">
                    <label for="trade_time">Trade Time</label>
                    <input type="text" class="form-control" required name="trade_time" id="trade_time">
                  </div>
                  <div class="form-group">
                    <label for="trade_date">Trade Date</label>
                    <input type="date" class="form-control" required name="trade_date" id="trade_date">
                  </div>
                  <div class="form-group">
                    <label for="result">Result</label>
                    <input type="text" class="form-control" placeholder="win or loss" required name="result" id="result">
                  </div>                  
                    <div class="row">
                        <div class="col-lg-3"></div>
                        <div class="col-lg-6" style="text-align: center;">
                            <button type="submit" class="btn btn-md btn-dark" >Submit</button>
                        </div>
                        <div class="col-lg-3"></div>
                    </div>                         
                </form>                                        
              </div>
              <div class="modal-footer">
                <button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
              </div>
            </div>
          </div>
        </div>        
        </div>  
    </div>

    <!-- Jquery JS-->
    <script src="vendor/jquery-3.2.1.min.js"></script>
    <!-- Bootstrap JS-->
    <script src="vendor/bootstrap-4.1/popper.min.js"></script>
    <script src="vendor/bootstrap-4.1/bootstrap.min.js"></script>
    <!-- Vendor JS       -->
    <script src="vendor/slick/slick.min.js">
    </script>
    <script src="vendor/wow/wow.min.js"></script>
    <script src="vendor/animsition/animsition.min.js"></script>
    <script src="vendor/bootstrap-progressbar/bootstrap-progressbar.min.js">
    </script>
    <script src="vendor/counter-up/jquery.waypoints.min.js"></script>
    <script src="vendor/counter-up/jquery.counterup.min.js">
    </script>
    <script src="vendor/circle-progress/circle-progress.min.js"></script>
    <script src="vendor/perfect-scrollbar/perfect-scrollbar.js"></script>
    <script src="vendor/chartjs/Chart.bundle.min.js"></script>
    <script src="vendor/select2/select2.min.js">
    </script>
    <script src="js/sweetalert2.all.min.js"></script>
    <!-- Main JS-->
    <script src="js/main.js"></script>
    <script src="js/custom.js"></script>


</body>

</html>
<!-- end document-->
