@extends('backend.layouts.master')

@section('title', 'Condition Sales')

@push('css')
	<link rel="stylesheet" href="{{asset('backend/plugins/select2.min.css')}}">
@endpush

@section('content')
	<div class="right_col" role="main">
        <div class="">
            <div class="clearfix"></div>
            @if(Session::has('success'))
                <div class="alert alert-success">
                    {{ Session::get('success') }}
                </div>
            @endif
            @if(Session::has('error'))
                <div class="alert alert-danger">
                    {{ Session::get('error') }}
                </div>
            @endif
            <div class="row">
                <div class="col-md-7 col-sm-7 col-xs-12">
                    <div class="x_panel">
                        <div class="x_title">
                            <h2>
								Condition Cancel 
								<a href="{{route('sales.list')}}" class="btn btn-xs btn-primary">Sales List</a>
							</h2>
                            <ul class="nav navbar-right panel_toolbox">
                                <li><a class="collapse-link"><i class="fa fa-chevron-up"></i></a>
                                </li>
                                <li class="dropdown">
                                    <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button"
                                       aria-expanded="false"><i class="fa fa-wrench"></i></a>
                                    <ul class="dropdown-menu" role="menu">
                                        <li><a href="#">Settings 1</a>
                                        </li>
                                        <li><a href="#">Settings 2</a>
                                        </li>
                                    </ul>
                                </li>
                                <li><a class="close-link"><i class="fa fa-close"></i></a>
                                </li>
                            </ul>
                            <div class="clearfix"></div>
                        </div>
                        <div class="x_content">
							<div class="row search-section">
								<form action="{{route('account.cpi')}}" id="searchForm" method="Get">
									<div class="col-sm-3">
										<select class="form-control" name="show" id="show">
											<option value="{{$sales->count()}}">{{$sales->count()}}</option>
											<option value="10">10</option>
											<option value="25">25</option>
											<option value="50">50</option>
											<option value="100">100</option>
											<option value="250">250</option>
											<option value="500">500</option>
										</select>
									</div>
									<div class="col-sm-6"></div>
									<div class="col-sm-3">
										<div class="input-group">
											<input type="text" id="myInput" class="form-control" placeholder="Search">
											<span class="input-group-btn">
												<button type="button" class="btn btn-primary">
												<span class="ace-icon fa fa-search icon-on-right bigger-110"></span></button>
											</span>
										</div>
									</div>
								</form> 
							</div>
							<div class="table-content">
								<table id="" class="table table-bordered table-condensed" role="grid" aria-describedby="dynamic-table_info">
									<thead>
										<tr class="bg-primary">
											<th>SL</th>
											<th>Cancel Date</th>
											<th>Customer Name</th>
											<th>Amount</th>
											<th>Action</th>
										</tr>
									</thead>
									<tbody>
										@foreach($sales as $key=>$ex)
											<tr>
												<td>{{$key + 1}}</td>
												<td>{{date('d-m-Y',strtotime($ex->cancel_date))}}</td>
												<td>{{$ex->customer->name}}</td>
												<td>{{$ex->grand_total_price}}</td>
												<td><a href="{{route('sales.show',$ex->id)}}" class="btn-xs btn-primary"><i class="fa fa-eye fa-x"></i></a>  </td>
											</tr>
										@endforeach
									</tbody>
								</table>
								<div class="text-center">
									{{$sales->links()}}
								</div>
							</div>
						</div>
					</div>
				</div>
				<div class="col-xs-12 col-sm-5 col-md-5">
					<div class="x_panel">
                        <div class="x_title">
                            <h2>Customer Search </h2>
                            <ul class="nav navbar-right panel_toolbox">
                                <li><a class="collapse-link"><i class="fa fa-chevron-up"></i></a>
                                </li>
                                <li class="dropdown">
                                    <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button"
                                       aria-expanded="false"><i class="fa fa-wrench"></i></a>
                                    <ul class="dropdown-menu" role="menu">
                                        <li><a href="#">Settings 1</a>
                                        </li>
                                        <li><a href="#">Settings 2</a>
                                        </li>
                                    </ul>
                                </li>
                                <li><a class="close-link"><i class="fa fa-close"></i></a>
                                </li>
                            </ul>
                            <div class="clearfix"></div>
                        </div>
                        <div class="x_content">
						<form action="{{route('sales.condition_change')}}" method="POST" class="form-horizontal" role="form" >
							{{ csrf_field() }}
                            {{ method_field('Get') }}
							<div class="form-group">
								<label class="col-sm-4 control-label no-padding-right" for="form-field-1">Condition Invoice *</label>
								<div class="col-sm-8">
									<select name="sale_id"  class="form-control select2">
										<option value="">- Select Customer -</option>
										@foreach($conditions as $con)
											<option value="{{$con->id}}" {{$con->id == old('sale_id') ? 'selected' : ''}}>{{$con->customer->name}} ({{$con->invoice_no}})</option>
										@endforeach
									</select> 
									<p class="error-sms">{{ $errors->first('sale_id') }}</p>
								</div>
							</div>
							<div class="form-group">
								<div class="col-md-6 col-sm-6 col-xs-12 col-md-offset-5">
								  <button class="btn btn-warning" type="reset">Reset</button>
								  <button type="submit"  class="btn btn-primary">Search</button>
								</div>
							</div>
						</form>
					</div>
					</div>
				</div>
			</div>
		</div>
	</div>
@endsection

@push('js')
	<script src="{{asset('backend/plugins/select2.min.js')}}"></script>
<script>
	$(document).ready(function(){
		// select2 section
		$('.select2').select2()	;
	})
	</script>
@endpush