<!DOCTYPE html>
<html lang="en">
<head>
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Doxbin (Admin) - Order History</title>
    @include('_scripts', ['adminPage' => 1])
    <meta name="robots" content="noindex">
    <script src="https://{{$currentDomain}}/legacy/jscolor.js"></script>
    <link rel="stylesheet" href="https://{{$currentDomain}}/legacy/index.css">
    <script type="text/javascript" src="https://code.jquery.com/ui/1.11.4/jquery-ui.min.js"></script>
    
    <style>
        body{
            position:relative;
        }
        *{
            box-sizing: border-box;
        }
        @media only screen and (max-width: 992px){
        }
        textarea{
            background-color: #282828;
            border: none;
            border-radius: 2px;
            color: white;
        }
        .blacklist-container td{
            padding: 3px;
        }
        .blacklist-container tr:hover{
            background-color: #323232;
        }
        .blacklist-container tr{
            background-color: #444444;
        }
        a.button{
            display: inline-block;
            padding: 5px 8px;
            background-color: #272727;
            color: white;
            border-radius: 2px;
            text-transform: uppercase;
            font-size: 15px;
            font-weight: bold;
            margin: 0;
            width: auto;
        }
        a.button:focus{
            text-decoration: none;
        }
        a.button:hover{
            background-color: #232323;
            text-decoration:none;
        }
        a.button.button-red{
            border: solid 1px #ff0000;
        }
        a.button.button-green{
            border: solid 1px #00ff00;
        }
        a.button.button-green{
            border: solid 1px #0000ff;
        }
        .add-to-blacklist > div > a.button{
            display: inline-block;
            padding: 5px 8px;
            border: solid 1px #00ff00;
            background-color: #272727;
            color: white;
            border-radius: 2px;
            text-transform: uppercase;
            font-size: 15px;
            font-weight: bold;
            margin: 0;
            width: 50%;
        }
        .add-to-blacklist > div > a.button:hover{
            text-decoration: none;
            color: white;
            background-color: #1D1D1D;
        }
        .add-to-blacklist{
            width: 50%;
        }
        @media only screen and (max-width: 600px){
            .add-to-blacklist > div > a.button{
                width: 100%;
            }
            .add-to-blacklist{
                width: 100%;
            }
        }
        select, option{
            color: white;
            background: #282828;
            border: 0;
            border-radius: 2px;
            display: inline-block;
            -webkit-font-smoothing: antialiased;
            outline: none;
            padding: 3px;
            width: 200px;
        }

        input[type=text]::placeholder{
            color: rgb(167, 167, 167);
        }
        input, select, option{
            font-size: 100%;
        }

        input[type=submit]:hover{
            color: white;
            background: #3d3d3d;
            text-decoration: none;
        }
        .center {
            text-align: center;
        }
        .add{
            background-color: green;
        }
        .add:hover{
            background-color: #1b6e10;
        }

        a.confirm{
            background-color: green;
            font-size: 15px;
            font-weight: bold;
            padding: 7px 10px;
        }
        a.confirm:hover{
            background-color: #1b6e10;
        }
        .word-container{
            background-color: #282828;
            width: 50%;
            border-radius: 7px;
            margin-top: 20px;
            box-shadow: 0 1px 3px #181a1f;
            padding: 0px 10px;
            position:relative;
            display: inline-block;
            -webkit-box-shadow: inset 0px 0px 3px 0px rgba(0,0,0,0.75);
            -moz-box-shadow: inset 0px 0px 3px 0px rgba(0,0,0,0.75);
            box-shadow: inset 0px 0px 3px 0px rgba(0,0,0,0.75);
        }

        .word-container .word-row{
            padding: 10px 10px;
            border-bottom: solid 1px gray;
        }
        .word-container .word-row:last-of-type{
            border: none;
        }
        .row {
            display: -ms-flexbox;
            display: flex;
            -ms-flex-wrap: wrap;
            flex-wrap: wrap;
            margin-right: -15px;
            margin-left: -15px;
        }
        .col {
            position: relative;
            width: 100%;
            padding-right: 15px;
            padding-left: 15px;
            -ms-flex-preferred-size: 0;
            flex-basis: 0;
            -ms-flex-positive: 1;
            flex-grow: 1;
            max-width: 100%;
        }
        .top-btn, .top-btn p{
            display: block;
            outline: none;
            background: #303030;
            letter-spacing: .5px;
            line-height: 1.5;
            border-right: 1px solid #26282e;
            padding: 12px 0;
            font-size: 14px;
            font-weight: 600;
            text-align: center;
            cursor: pointer;
            color: #a8a8a8;
            margin: 0;
        }

        .top-btn-disabled, .top-btn-disabled p{
            display: block;
            outline: none;
            background: #292929;
            letter-spacing: .5px;
            line-height: 1.5;
            border-right: 1px solid #26282e;
            padding: 12px 0;
            font-size: 14px;
            font-weight: 600;
            text-align: center;
            cursor: not-allowed;
            color: #5d5d5d;
            margin: 0;
        }
        .top-btn:hover, .top-btn p:hover{
            color: white !important;
            text-decoration: none;
        }
        .top-btn p:focus{
            color: #a8a8a8;
            text-decoration: none;
        }
        .active p{
            color: white;
        }
        .checkbox{
            height: 0;
            width: 0;
            visibility: hidden;
        }
        .checkbox-label {
            cursor: pointer;
            text-indent: -9999px;
            width: 60px;
            height: 30px;
            background: grey;
            display: block;
            border-radius: 100px;
            position: relative;
            transition: 0.3s;
        }
        .checkbox-label:after {
            content: '';
            position: absolute;
            top: 3px;
            left: 4px;
            width: 24px;
            height: 24px;
            background: #fff;
            border-radius: 90px;
            transition: 0.3s;
        }
        .checkbox:checked + label {
            background: #4cba30;
            transition: 0.3s;
        }
        .checkbox:checked + .checkbox-label:after {
            left: calc(100% - 5px);
            transform: translateX(-100%);
        }
        /* .checkbox-label:active:after {
            width: 30px;
        } */
        .word-container input[type=text]{
            background-color: rgb(31,31,31);
            border: solid 1px rgb(26,26,26);  
        }
        .word-row input.role-weight{
            color: white;
            background: #282828;
            border: none;
            display: inline-block;
            -webkit-font-smoothing: antialiased;
            outline: none;
            padding: 2px;
            width: 30px;
            height: 100%;
            float: left;
            text-align: center;
            margin-right: 7px;
            border-right: solid 1px gray;
            border-radius: 0;
        }

        .anx{
            font-size: 17px;
        }

        .anxs{
            font-size: 19px;
        }

        .b-wrd{
            display: inline;
            color: white;
            font-size: 15px;
        }
        @media only screen and (max-width: 900px) {
        .word-container {
            width:100%;
        }
        }

        @media screen and (max-width:500px){
            body{
                font-size: 10px;
            }
            .col-md-12{
                padding: 0;
                width: 100%;
            }
            .col-md-7{
                padding: 0;
                width: 100%;
            }
            .top-btn, .top-btn p{
                font-size: 10px;
            }
            .anx{
                font-size: 14px;
            }
            .anxs{
                font-size: 16px;
            }
            a.confirm{
                font-size: 13px;
            }
            .b-wrd{
                font-size: 12px;
            }
        }
        div.search-box{

        }
        input.search-input{
            padding: 2px 3px;
            background-color: #282828;
            outline: none;
            border: none;
            width: 100%;
        }


        .search-button{
            padding: 3px;
            /* background-color: #282828; */
            outline: none;
            border: none;
            color: white;
            display: inline-block;
            padding: 5px 8px;
            background-color: #272727;
            color: white;
            border-radius: 2px;
            text-transform: uppercase;
            font-size: 15px;
            font-weight: bold;
            margin: 0;
            width: auto;
        }

        .search-button:focus{
            text-decoration: none;
        }
        .button:hover{
            background-color: #232323;
            text-decoration:none;
        }
        .button.button-red{
            border: solid 1px #ff0000;
        }
        .button.button-green{
            border: solid 1px #00ff00;
        }
        .button.button-green{
            border: solid 1px #0000ff;
        }
        .add-to-blacklist > div > a.button{
            display: inline-block;
            padding: 5px 8px;
            border: solid 1px #00ff00;
            background-color: #272727;
            color: white;
            border-radius: 2px;
            text-transform: uppercase;
            font-size: 15px;
            font-weight: bold;
            margin: 0;
            width: 50%;
        }
        .add-to-blacklist > div > a.button:hover{
            text-decoration: none;
            color: white;
            background-color: #1D1D1D;
        }
        #search-table{
            background-color: inherit;
        }
        #search-table td{
            padding: 3px;
        }
        td label{
            margin: 0;
        }
        .button-small{
            padding: 2px 3px;
            font-size: 14px;
        }
        td.auto-size{
            width: 1px;
            white-space: nowrap;
        }
        </style>
</head>
<body style="min-height: 100%;height:100%">
    {!! csrf_field() !!}
    @include('_nav')
    <div class="nav-space"></div>
    <div class="page">
        @include('_admin_sidebar')
        <div class="page-content">
            <div class="search-box">
                <form action="" method="GET">
                    <input type="hidden" name="search" value="1">
                    <table id="search-table">
                        <tr>
                            <td>
                                <label for="userid">Invoice ID:</label>
                            </td>
                            <td>
                                <input class="search-input" type="text" name="orderid" value="{{$formData['orderid']}}" placeholder="Order ID...">
                            </td>
                        </tr>
                        <tr>
                            <td>
                                <label for="userid">User ID:</label>
                            </td>
                            <td>
                                <input class="search-input" type="number" name="userid" value="{{$formData['userid']}}" placeholder="User ID...">
                            </td>
                        </tr>
                        <tr>
                            <td>
                                <label for="status">Order status:</label>
                            </td>
                            <td>
                                <select name="status" id="status">
                                    <option value="" {{is_null($formData['status']) ? 'selected' : '' }}>(none)</option>
        @foreach($statuses as $status)
                                    <option value="{{$status}}" {{!is_null($formData['status']) && $formData['status'] == $status ? 'selected' : ''}}>{{$status}}</option>
        @endforeach
                                </select>
                            </td>
                        </tr>
                        <tr>
                            <td>
                                <label for="product">Product:</label>
                            </td>
                            <td>
                                <select name="productid" id="product">
                                    <option {{is_null($formData['status']) ? 'selected' : '' }} value="">(none)</option>
                @foreach($products as $product)
                                    <option {{$product->id == $formData['productid'] ? 'selected' : ''}} value="{{$product->id}}">{{$product->title}}</option>
                @endforeach
                                </select>
                            </td>
                        </tr>
                        <tr>
                            <td>
                                <label for="limit">Results:</label>
                            </td>
                            <td>
                                <input class="search-input" type="number" id="limit" name="limit" value="{{$formData['limit']}}" placeholder="Results...">
                            </td>
                        </tr>
                        <tr>
                            <td>
                                <span>{{($orderCount > 0 ? $orderCount : 'No') . str_plural(' result', $orderCount)}}</span>
                            </td>
                            <td style="text-align: right;">
                                <input class="button button-green button-small search-button" type="submit" name="submit" value="Search" style="width: 50%;">
                            </td>
                        </tr>
        
                    </table>
                </form>
            </div>
            <div class="orders">
            @if($orderCount > 0)
            
                <table class="table table-striped table-hover">
                    <thead>
                        <tr>
                            <th>User</th>
                            <th>Product</th>
                            <th>Price</th>
                            <th>Status</th>
                            <th class="text-center">Date</th>
                        </tr>
                    </thead>
                    <tbody>
                        @foreach ($orders as $order)
                            @php
                                $user = \App\User::find($order->user_id);
                                if(is_null($user)){
                                    continue;
                                }
                                $product = $products->where('id', $order->product_id)->first();
                            @endphp
                            <tr class="doxentry">
                                <td class="auto-size">{!! $user->getNameHtml(false, true) !!}</td>
                                <td>{{ $product->title }}</td>
                                <td>${{ empty($order->price) ? '---' : $order->price }}</td>
                                <td>{{ $order->status }}</td>
                                <td class="text-center" title="{{$order->created_at}}">{{ $order->created_at->diffForHumans() }}</td>
                            </tr> 
                        @endforeach
                    </tbody>
                </table>
            @endif
            </div>
        </div> 
    </div>
    <script src="https://{{$currentDomain}}/legacy/admin.js"></script>
    <script>
        function delWord(id){
            $.post('https://{{$currentDomain}}/admin/api/blacklist', {
                _token: $('input[name=_token]').val(),
                id: id,
                type: 'del',
            }, function(resp){
                if(resp.status == "done"){
                    window.location = '/admin?sel=blacklist';
                }
            });
        }
        $(document).ready(function(e){
            
            var logsDropdown = false;
            $('#logs-button').on('click', function(e){
                if(!logsDropdown){
                    $('.logs-dropdown').show();
                    logsDropdown = true;
                }else{
                    $('.logs-dropdown').hide();
                    logsDropdown = false;
                }
                e.preventDefault();
            });
        });
    </script>
</body>
</html>