@extends('layout.main')
@section('content')

<style>
.previewImage{
    height: 150px;
    width: 95%;
    overflow:hidden;
    object-fit: contain;
}
</style>
<!-- <div class="row">
	<div class="col-md-12">
		<img src="{{asset('public/images/logo.png')}}" class="" height="100px" />
	</div>
</div>
<hr> -->
<div class="row">
    <div class="col-md-12">
        <ol class="breadcrumb">
            <li><a href="{{url('/')}}">Home</a></li>
            <li class="active">My Cart</li>
        </ol>
    </div>
</div>

<div class="row">
    <div class="col-md-12">
        <h1>My Cart</h1>
        <hr>
    </div>
</div>

@if(count($row) > 0)

<div class="row">
    <div class="col-md-8">
       
        @foreach($item_group as $item)

            @if($item->Order == "Jersey")

                @define $itemOrder    = " (Jersey Only)"
                @define $thumb_display = "-front-thumbnail.png"

            @elseif ($item->Order == "Shorts")

                @define $itemOrder = " (Shorts Only)"
                @define $thumb_display = "-left-thumbnail.png"
            
            @else
          
                @define $itemOrder = " (w/ Shorts)"
                @define $thumb_display = "-front-thumbnail.png"
            @endif
        
            <div style="border: 1px solid #e2e2e2; padding: 10px; margin-bottom: 10px;">
                <!-- <div class="row">
                    <div class="col-md-12">
                        <a class="btn btn-link pull-right" href="{{ url('removeitem') }}/{{ $item->Id }}"><span class="glyphicon glyphicon-remove"></span></a>
                    </div>
                </div> -->
                <div class="row">
                    <div class="col-md-3">
                        <div class="text-center">
                            @foreach($img_thumb as $img)
                                @if($img->ProductId  == $item->ProductId)
                                    <img class="previewImage" src="http://{{ config('site_config.prod_private_server_ip')  }}/images/{{  $img->Image }}">
                                @endif
                            @endforeach
                            
                        </div>
                    </div>
                    <div class="col-md-9">
                        <h4><a href="{{ url('teamstore') . '/' . $item->StoreURL . '/' . 'product/' .  $item->ProductURL }}">{{ $item->ProductName }}</a></h4>
                        <p>Total Price: ${{ $item->total_price }} &bull; Row(s): {{ $item->qty }} </p>
                        <div class="table-responsive">  
                            <table class="table table-striped table-condensed">

                                    @if($item->FormUsed=="jersey-and-shorts-form")
                                        <tr>
                                            <th>Name</th>
                                            <th>Number</th>
                                            <th>Jersey Size</th>
                                            <th>Shorts Size</th>
                                            <th>Price</th>
                                            <th>Quantity</th>
                                            <th></th>
                                        </tr>
                                    @elseif($item->FormUsed=="tshirt-form")
                                        <tr>
                                            <th>Size</th>
                                            <th>Price</th>
                                            <th>Quantity</th>
                                            <th></th>
                                        </tr>

                                    @elseif($item->FormUsed=="quantity-form")
                                        <tr>
                                            <th>Price</th>
                                            <th>Quantity</th>
                                            <th></th>
                                        </tr>

                                    
                                    @elseif($item->FormUsed=="name-number-form")
                                        <tr>
                                            <th>Name</th>
                                            <th>Number</th>
                                            <th>Price</th>
                                            <th>Quantity</th>
                                            <th></th>
                                        </tr>
                                    
                                    @elseif($item->FormUsed=="name-number-size-form")
                                        <tr>
                                            <th>Name</th>
                                            <th>Number</th>
                                            <th>Size</th>
                                            <th>Price</th>
                                            <th>Quantity</th>
                                            <th></th>
                                        </tr>
                                    
                                    @elseif($item->FormUsed=="number-form")
                                        <tr>
                                            <th>Number</th>
                                            <th>Price</th>
                                            <th>Quantity</th>
                                            <th></th>
                                        </tr>

                                    @else

                                    @endif
                                    

                                    @foreach($row as $sub_item)
                                        @if($sub_item->ProductId == $item->ProductId)

                                            @if($item->FormUsed=="jersey-and-shorts-form")
                                                <tr>
                                                    <td> @if($sub_item->Name != '') {{ $sub_item->Name }} @else -- @endif </td>
                                                    <td>{{ $sub_item->Number }}</td>
                                                    <td>{{ $sub_item->JerseySize }}</td>
                                                    <td>{{ $sub_item->ShortsSize }}</td>
                                                    <td>{{ $sub_item->Price }}</td>
                                                    <td>{{ $sub_item->Quantity }}</td>
                                                    <td><a class="btn btn-xs btn-link pull-right" href="{{ url('removeitem') }}/{{ $sub_item->Id }}"><span class="glyphicon glyphicon-remove"></span></a></td>
                                                </tr>
                                            @elseif($item->FormUsed=="tshirt-form")
                                                <tr>
                                                    <td>{{ $sub_item->Size }}</td>
                                                    <td>{{ $sub_item->Price }}</td>
                                                    <td>{{ $sub_item->Quantity }}</td>
                                                    <td><a class="btn btn-xs btn-link pull-right" href="{{ url('removeitem') }}/{{ $sub_item->Id }}"><span class="glyphicon glyphicon-remove"></span></a></td>
                                                </tr>
                                            @elseif($item->FormUsed=="quantity-form")
                                                <tr>
                                                    <td>{{ $sub_item->Price }}</td>
                                                    <td>{{ $sub_item->Quantity }}</td>
                                                    <td><a class="btn btn-xs btn-link pull-right" href="{{ url('removeitem') }}/{{ $sub_item->Id }}"><span class="glyphicon glyphicon-remove"></span></a></td>
                                                </tr>
                                            @elseif($item->FormUsed=="name-number-form")
                                                <tr>
                                                    <td>{{ $sub_item->Name }}</td>
                                                    <td>{{ $sub_item->Number }}</td>
                                                    <td>{{ $sub_item->Price }}</td>
                                                    <td>{{ $sub_item->Quantity }}</td>
                                                    <td><a class="btn btn-xs btn-link pull-right" href="{{ url('removeitem') }}/{{ $sub_item->Id }}"><span class="glyphicon glyphicon-remove"></span></a></td>
                                                </tr>
                                             @elseif($item->FormUsed=="name-number-size-form")
                                                <tr>
                                                    <td>{{ $sub_item->Name }}</td>
                                                    <td>{{ $sub_item->Number }}</td>
                                                    <td>{{ $sub_item->Size }}</td>
                                                    <td>{{ $sub_item->Price }}</td>
                                                    <td>{{ $sub_item->Quantity }}</td>
                                                    <td><a class="btn btn-xs btn-link pull-right" href="{{ url('removeitem') }}/{{ $sub_item->Id }}"><span class="glyphicon glyphicon-remove"></span></a></td>
                                                </tr>
                                            @elseif($item->FormUsed=="number-form")
                                                <tr>
                                                    <td>{{ $sub_item->Number }}</td>
                                                    <td>{{ $sub_item->Price }}</td>
                                                    <td>{{ $sub_item->Quantity }}</td>
                                                    <td><a class="btn btn-xs btn-link pull-right" href="{{ url('removeitem') }}/{{ $sub_item->Id }}"><span class="glyphicon glyphicon-remove"></span></a></td>
                                                </tr>

                                            @else

                                            @endif
                                           
                                        @endif
                                    @endforeach
                            </table>
                        </div>
                    </div>
                </div>
            </div>
        @endforeach
    </div>

    <div class="col-md-4 order-summary" >
        <div class="row" style="background-color: #f5f5f5;">
            <div class="col-sm-12">
                @if(Session::has('msg'))
                    <div class="alert alert-danger alert-dismissible">
                        <button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
                            <h4><i class="icon fa fa-ban"></i> ERROR:</h4>
                            {{ Session::get('msg') }}
                    </div>
                @endif
                <h3>Order Summary</h3>
                <hr class="hr-design">
                <h4 class="text-center">
                    <b>Subtotal : </b> $ {{ $getSubtotal[0]->Subtotal }}
                </h4>
                <hr class="hr-design">
                <a @if($getSubtotal[0]->Subtotal <= 0 ) disabled  @endif href="{{ url('getCheckout') }}" class="btn btn-primary btn-block" style="background-color: #ffc300; border-color: #e2ad00; text-align: -webkit-center;" ><img src="{{asset('/public/images/paypal1.png')}}" class="img img-responsive" style="height:30px;"></a><br>
                <a href="{{ url('/')}}" class="btn btn-default btn-block" type="submit">Continue Shopping</a>
                <br><br><br>
            </div>
        </div>
    </div>
</div>
@else
<div class="row">
    <div class="col-md-12">
        <h3 style="color:#d2d2d2;">Your cart is currently empty.</h3>
    </div>
</div>

@endif
@endsection
