@extends('admin/layouts/default')
{{-- Page title --}}
@section('title')
Order List
@parent
@stop
{{-- page level styles --}}
@section('header_styles')
<link href="{{ asset('assets/css/pages/tables.css') }}" rel="stylesheet" type="text/css" />
<!-- end of page level css-->
@stop
{{-- Page content --}}
@section('content')
<section class="content-header">
    <!--section starts-->
    <h1>Order List</h1>
    <ol class="breadcrumb">
        <li>
            <a href="{{ route('admin.dashboard') }}">
            <i class="livicon" data-name="home" data-size="18" data-loop="true"></i>
            Dashboard
            </a>
        </li>
        <li class="active">Order List</li>
    </ol>
</section>
<!--section ends-->
<section class="content">
    <div class="row">
        <div class="col-md-12">
            <!-- BEGIN SAMPLE TABLE PORTLET-->
            <div class="portlet box primary">
                <div class="portlet-title">
                    <div class="caption">
                        <i class="livicon" data-name="responsive" data-size="16" data-loop="true" data-c="#fff" data-hc="white"></i>
                        Order List
                    </div>
                </div>
                <div class="portlet-body table-responsive">
					<form action="{{ route('admin.order','list') }}" method="post"  enctype="multipart/form-data">
                        <input type="hidden" name="_token" value="{{csrf_token()}}">
                        <div class="form-group col-md-2">
                            <label>Order ID</label>
                            <input type="text" class="form-control" name="order_id" placeholder="Enter text">
                        </div>   

                        <div class="form-group col-md-2">
                            <label>Order Status</label>
                           <select class="form-control" id="order_status" name="order_status">
                                <option value="">All Orders</option>
                             @foreach ($ord_status as $o_status)
                                <option value="{{$o_status->order_status_id}}" @if(old('order_status') == $o_status->order_status_id) {{ 'selected' }} @endif> {{$o_status->title}}</option>
                            @endforeach
                           </select>
                        </div>                      

                        <div class="form-group col-md-2">
                            <label>Source</label>
                            <select id="e1" class="form-control" name="source">
                                <option value="">All</option>
                                <option value="trendmd" @if(old('source') == 'trendmd') {{ 'selected' }} @endif>TrendMD</option>
                                <option value="BSP" @if(old('source') == 'BSP') {{ 'selected' }} @endif>Bentham</option>
                                <option value="jw" @if(old('source') == 'jw') {{ 'selected' }} @endif>Journal Website</option>
                                <option value="disease" @if(old('source') == 'disease') {{ 'selected' }} @endif>Disease Wise</option>
                            </select>
                        </div>                      

                        <div class="form-group col-md-2">
                            <label>From Date</label>
                            <input type="date" class="form-control" name="from_date" placeholder="Enter text">
                        </div>                      

                        <div class="form-group col-md-2">
                            <label>To Date</label>
                            <input type="date" class="form-control" name="to_date" placeholder="Enter text">
                        </div>                      

                        <div class="form-group col-md-2">
                            <label>Customer Email</label>
                            <input type="email" class="form-control" name="customer_email" placeholder="Enter text">
                        </div>                      

                        <div class="form-group col-md-6">
                            <button type="submit" class="btn btn-primary" name="frm_search" value ="true">
                                <span class="glyphicon glyphicon-search"></span>  Search
                            </button>
                            <button type="reset" id="btn_reset" class="btn btn-default">Reset</button>
							<a href="{{ URL::to('admin/order/export') }}" id="btn_export" class="btn btn-success"><span class="glyphicon glyphicon-export"></span> Export</a>
                        </div>   

                        <div class="form-group col-md-3">
                            <label>Number of orders: </label>
                            <label>{{ $order_counts->total_order }}</label>
                        </div>                      

                        <div class="form-group col-md-3">
                            <label>Total Revenue: </label>
                            @if($order_counts->ostatus == 'completed')
                            <label>${{ number_format($order_counts->total_revenue,2) }}</label>
                            @endif
                        </div>                      

					</form>
					
								
                    <table class="table table-striped table-bordered" id="Issue_table">
                        <thead>
                            <tr>
                                <th>Order ID</th>
                                <th>Customer</th>
                                <th>Total</th>
								<th>Purchase date</th>
                                <th>Status</th>
                                <th width="180">Action</th>
                            </tr>
                        </thead>
                        <tbody>
                            @foreach($orders as $value)
                            <tr>
                                <td>{{ $value->order_id }}</td>
                                <td>{{ $value->email }}</td>
								<td>{{ number_format($value->order_total,2) }}</td>
                                <td>{{ date('m/d/Y', $value->created) }}</td>
								<td>{{ $value->order_status }}</td>
                                                           
                                <td width="220">
                                    <a href="{{ URL::to('admin/order/invoice/'.$value->order_id.'') }}" target="_blank" class="btn btn-success btn-xs" title="Invoice">
                                    <i class="livicon" data-name="download" data-loop="true" data-color="#fff" data-hovercolor="White" data-size="20"></i></a>                                    <a href="{{ URL::to('admin/order/detail/'.$value->order_id.'') }}" class="btn btn-primary btn-xs">
                                    <i class="livicon" data-name="eye-open" data-loop="true" data-color="#fff" data-hovercolor="White" data-size="20" title="Details"></i></a>
                                    @if($deletePermission)
                                    <a type="button" class="btn btn-danger btn-xs" data-toggle="modal" data-target="#{{ $value->order_id}}"><i class="livicon" data-name="trash" data-loop="true" data-color="#fff" data-hovercolor="white" data-size="20" title="Delete"></i></a>
                                    <!-- Modal -->
                                    <div class="modal fade" id="{{ $value->order_id}}" role="dialog">
                                        <div class="modal-dialog">
                                            <!-- Modal content-->
                                            <div class="modal-content">
                                                <div class="modal-header">
                                                    <button type="button" class="close" data-dismiss="modal">&times;</button>
                                                    <h4 class="modal-title">Warning</h4>
                                                </div>
                                                <div class="modal-body">
                                                    <p>Do you really want to delete order: {{ $value->order_id }}</p>
                                                </div>
                                                <div class="modal-footer">
                                                    <form method="POST" action="{{ route('issue.destroy', $value->order_id) }}">                                                        @csrf                                                        <input name="_method" type="hidden" value="DELETE">                                                        <input name="id" type="hidden" value="{{$value->order_id}}">                                                        <input class="btn btn-danger" type="submit" value="Delete">                                                        <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>                                                    </form>
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                    @endif
                                </td>
                            </tr>
                            @endforeach
                        </tbody>
                    </table>
                    <center>{{$orders->appends(request()->input())->links()}}</center>
                </div>
            </div>
            <!-- END SAMPLE TABLE PORTLET-->
        </div>
    </div>
</section>
@stop

{{-- page level scripts --}}
@section('footer_scripts')

@stop