@extends('backend.layouts.master')

@section('title', 'Payment')

@push('css')
	<link rel="stylesheet" href="{{asset('backend/plugins/select2.min.css')}}">
	<!-- date Calender-->
	<link rel="stylesheet" href="{{ asset('myfile/backend/assets/datepicker/zebra_datepicker.min.css') }}" type="text/css">
	<link rel="stylesheet" href="{{ asset('myfile/backend/assets/datepicker/examples.css') }}" type="text/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>
								Employee Payment
								<a href="{{route('employee.list')}}" class="btn btn-xs btn-primary">Employee 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 ">
							    <div class="col-sm-2"></div>
							    <div class="col-sm-4">
							        <h3>{{$employee->name}}</h3> 
    								<p>{{$employee->phone}}</p>
    								<p>{{$employee->email}}</p>
    								<p>{{$employee->address}}</p>
							    </div>
							    <div class="col-sm-2">
							        <img src="{{asset('storage/employee/'.$employee->image)}}" height="75" width="60" > 
							    </div>
							</div>
							<div class="table-content table-">
								<form action="{{route('salary.store')}}"  class="form-horizontal" role="form" method="Post" autocomplete="off" >
									{{csrf_field() }}
									<div class="text-center">
										<input type="hidden" name="employee_id" value="{{$employee->id}}">
										<div class="form-group">
											<label class="col-sm-4 control-label no-padding-right" for="form-field-1">Payment Date <span class='red'>*</span></label>
											<div class="col-sm-8">
												<input id="datepicker" type="text" name="pay_date"  class="form-control input-sm" data-zdp_readonly_element="true" value="{{ date('d-m-Y')}}" placeholder="dd-mm-yyyy" >
												<p class="error-sms">{{ $errors->first('pay_date') }}</p>
											</div>
										</div>
										<div class="form-group">
											<label class="col-sm-4 control-label no-padding-right" for="form-field-1">Payment Amount <span class='red'>*</span></label>
											<div class="col-sm-4">
												<input id="payment" type="text" name="payment"  class="form-control input-sm"  value="{{ old('amount')}}" placeholder="xxxx">
												<p class="error-sms">{{ $errors->first('payment') }}</p>
											</div>
											<div class="col-sm-4">
												<input id="total_payment" type="text" name="total_payment" class="form-control input-sm" readonly="" value="{{ old('total_payment')}}" placeholder="xxxx">
												<p class="error-sms">{{ $errors->first('total_payment') }}</p>
											</div>
										</div>
										<div class="form-group">
											<label class="col-sm-4 control-label no-padding-right" for="form-field-1">Note </label>
											<div class="col-sm-8">
												<input id="" type="text" name="note"  class="form-control"  value="{{ old('note')}}" placeholder="Say somothing about payment">
												<p class="error-sms">{{ $errors->first('note') }}</p>
											</div>
										</div>
										<!--<div class="form-group">
											<label class="control-label col-sm-4">SMS: </label>
											<div class="col-sm-2">
												<div class="checkbox">
													<label><input type="checkbox" class="ch" name="sms"> Send </label>
												</div>
											</div> 
										</div>-->
										<div class="form-group">
											<div class="col-md-6 col-sm-6 col-xs-12 col-md-offset-5">
											    <a href="{{route('salary.list')}}" class="btn btn-danger">Cancel</a>
												<button class="btn btn-warning" type="reset">Reset</button>
												<button type="submit" class="btn btn-primary">Save</button>
											</div>
										</div>
									</div>
								</form>
							</div>	
						</div>
					</div>
				</div>
				<div class="col-md-5 col-sm-5 col-xs-12">
					<div class="x_panel">
                        <div class="x_title">
                            <h2>Employee 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('salary.create')}}" method="Get" class="form-horizontal" role="form" >
							{{ csrf_field() }}
								<div class="form-group">
									<label class="col-sm-4 control-label no-padding-right" for="form-field-1">Employee <span class='red'>*</span></label>
									<div class="col-sm-8">
										<select name="employee_name"  class="form-control select2">
											<option value="">- Select Employee -</option>
											@foreach($employees as $cus)
												<option value="{{$cus->id}}" {{$cus->id == old('employee_name') ? 'selected' : ''}}>{{$cus->name}} ({{$cus->phone}})</option>
											@endforeach
										</select>
										<p class="error-sms">{{ $errors->first('employee_name') }}</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>
	<!-- Jquery Plugin For Date Calender-->
	<script type="text/javascript" src="{{ asset('myfile/backend/assets/datepicker/zebra_datepicker.src.js') }}"></script>
	<script>
		$(document).ready(function(){
			$('#datepicker').Zebra_DatePicker({
				format: 'd-m-Y',
				direction:<?php echo setting()->previous_date; ?>,
			});
			// select2 section
			$('.select2').select2();
		})
		
		$(document).on('keyup','#payment',function(){
			total_payment();
		})
		$(document).on('keyup','#discount_amount',function(){
			total_payment();
		})
		function total_payment(){
			var payment = $('#payment').val() || 0;
			var discount = $('#discount_amount').val() || 0;
			var total_pay = parseFloat(payment) + parseFloat(discount);
			$('#total_payment').val(total_pay.toFixed(2))
		}
	</script>
@endpush