@extends('admin.master')
@section('content')
@section('title','Generate Salary Sheet')
<style>
	.table>tbody>tr>td {
		padding: 5px 7px;
	}
	.address{
		margin-top: 22px;
	}
	.employeeName{
		position: relative;
	}
	#employee_id-error{
		position: absolute;
		top: 66px;
		left: 0;
		width: 100%he;
		width: 100%;
		height: 100%;
	}
	.icon-question {
		color: #7460ee;
		font-size: 16px;
		vertical-align: text-bottom;
	}

</style>
<div class="container-fluid">
	<div class="row bg-title">
		<div class="col-lg-5 col-md-5 col-sm-5 col-xs-12">
			<ol class="breadcrumb">
				<li class="active breadcrumbColor"><a href="{{ url('dashboard') }}"><i class="fa fa-home"></i> Dashboard</a></li>
				<li>@yield('title')</li>

			</ol>
		</div>
		<div class="col-lg-7 col-md-7 col-sm-7 col-xs-12">
			<a href="{{route('generateSalarySheet.index')}}"  class="btn btn-success pull-right m-l-20 hidden-xs hidden-sm waves-effect waves-light"><i class="fa fa-list-ul" aria-hidden="true"></i>  Generate Payslip</a>
		</div>
	</div>
	<div class="row">
		<div class="col-md-12">
			<div class="panel panel-info">
				<div class="panel-heading"><i class="mdi mdi-clipboard-text fa-fw"></i> @yield('title')</div>
				<div class="panel-wrapper collapse in" aria-expanded="true">
					<div class="panel-body">
						@if($errors->any())
							<div class="alert alert-danger alert-dismissible" role="alert">
								<button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span></button>
								@foreach($errors->all() as $error)
									<strong>{!! $error !!}</strong><br>
								@endforeach
							</div>
						@endif
						@if(session()->has('success'))
							<div class="alert alert-success alert-dismissable">
								<button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
								<i class="cr-icon glyphicon glyphicon-ok"></i>&nbsp;<strong>{{ session()->get('success') }}</strong>
							</div>
						@endif
						@if(session()->has('error'))
							<div class="alert alert-danger alert-dismissable">
								<button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
								&nbsp;<strong>{{ session()->get('error') }}</strong>
							</div>
						@endif
						{{ Form::open(array('route' => 'generateSalarySheet.calculateEmployeeSalary','method'=>'GET','id'=>'calculateEmployeeSalaryForm')) }}
						<div class="form-body">
							<div class="row">
								<div class="col-md-offset-2 col-md-3">
									<div class="form-group employeeName">
										<label for="exampleInput">Employee<span class="validateRq">*</span></label>
										{{ Form::select('employee_id',$employeeList, (isset($employee_id)) ? $employee_id : '', array('class' => 'form-control employee_id select2 required')) }}
									</div>
								</div>
								<div class="col-md-3">
									<label for="exampleInput">Month<span class="validateRq">*</span></label>
									<div class="input-group">
										<span class="input-group-addon"><i class="fa fa-calendar"></i></span>
										{!! Form::text('month', (isset($month)) ? $month : '', $attributes = array('class'=>'form-control required monthField','id'=>'month','placeholder'=>'Enter month')) !!}
									</div>
								</div>
								<div class="col-md-2">
									<div class="form-group">
										<button type="submit" class="btn btn-info " style="margin-top: 24px"> Generate Salary</button>
									</div>
								</div>
							</div>
						</div>
						{{ Form::close() }}
					</div>
				</div>
			</div>

            <?php
				$grossSalary = 0;
            ?>
			
			<div class="panel panel-info">
				<div class="panel-heading"><i class="mdi mdi-clipboard-text fa-fw"></i> Employee Salary Details</div>
				<div class="panel-wrapper collapse in" aria-expanded="true">
					<div class="panel-body">
						<div class="form-body">
							{{ Form::open(array('route' => 'saveEmployeeSalaryDetails.store')) }}
							<div class="table-responsive">
								<table class="table table-bordered table-hover">
									<thead class="tr_header">
									<tr>
										<th style="width: 100px">#</th>
										<th>Description</th>
										<th style="width: 300px">Amount</th>
									</tr>
									</thead>
									<tbody>
									<tr>
										<td>1</td>
										<td>Hourly Rate</td>
										<td>
											<div class="input-group">
												<span class="input-group-addon">TK</span>
												<input type="text" readonly  class="form-control" value="{{$hourly_rate}}" name="hourly_rate">
											</div>
										</td>
									</tr>
									<tr>
										<td>2</td>
										<td>Salary
											<span class="icon-question  btn-outline tooltip-primary" data-toggle="tooltip" data-placement="top" title=""
													  data-original-title="Total Working Hour {{$totalWorkingHour}}">
										</td>
										<td>
											<div class="input-group">
												<span class="input-group-addon">TK</span>
												<input type="text" readonly  class="form-control " value="{{$totalSalary}}">
											</div>
										</td>
									</tr>
									<input type="hidden" name="action" value="hourlySalary">
									<input type="hidden" name="employee_id" value="{{$employee_id}}">
									<input type="hidden" name="month_of_salary" value="{{$month}}">
									<tr>
										<td colspan="2" class="text-right"><b>Gross Salary</b></td>
										<td>
											<div class="input-group">
												<span class="input-group-addon"><b>TK</b></span>
												<input type="text" readonly  class="form-control gross_salary" name="gross_salary" value="{{$totalSalary}}">
											</div>
										</td>
									</tr>

									</tbody>
								</table>

								<div class="col-md-12 text-center">
									<div class="form-group">
										<button type="submit" class="btn btn-info btn_style"><i class="fa fa-check"></i> Save</button>
									</div>
								</div>

							</div>

							{{ Form::close() }}
						</div>
					</div>
				</div>
			</div>
				
		</div>
	</div>
</div>
@endsection

@section('page_scripts')
	<script type="text/javascript">
        jQuery(function(){
            $("#calculateEmployeeSalaryForm").validate();
        });
	</script>
@endsection
