@extends('layouts.app')

@section('content')
	<section class="page-header row">
		<h2> {{$task}} </h2>
		<ol class="breadcrumb">
			<li><a href="{{ url('') }}"> Dashboard </a></li>
			<li class="active"> {{$task}} </li>
		</ol>
	</section>
	<div class="page-content row">
		<div class="page-content-wrapper no-margin">
			<h3 class="section-title">All Records</h3>
			<div class="sbox">

				<div class="sbox-content">
					<!-- Toolbar Top -->
					<div class="toolbar-top">
						<div class="row">
							<div class="col-lg-7 col-md-6">
								<a href="{{ url('/manage/tasks/create') }}?task={{$task}}" class="btn btn-primary btn-sm"
								   title="{{ __('core.btn_create') }}"><i class=" fa fa-plus "></i> Create New </a>

								@if($access['is_excel'] ==1)
									<div style="display: inline-flex">
										<button type="button" id="exportBtn" class="btn btn-success" onclick="moduleExport()" style="display: inline-flex; margin-left: 20px">Export CSV</button>
										<div id="exportError" class="text-danger" style="margin: auto 15px; display: none">Error while Exporting Data!</div>
									</div>
								@endif
							</div>

							<div class="col-lg-5 col-md-6 text-right toolbar-right">
							</div>
						</div>
					</div>
					<!-- End Toolbar Top -->

					<div class="row">
						{!! (isset($search_map) ? $search_map : '') !!}
					</div>

					<!-- Table Grid -->
					<div class="table-responsive">

						<table class="table table-striped table-hover " id="storeDealsTable">
							<thead>
							<tr>
								<th style="width: 3% !important;" class="number"> No</th>
								<th>Action</th>
								<th>Run At</th>
								<th>Data</th>
							</tr>
							</thead>

							<tbody>
							@foreach ($tasks as $row)
								<tr>
									<td> {{ $loop->iteration }} </td>
									<td> @if($row->job_id) <a href="{{ url('/manage/tasks/delete/' . $row->job_id) }}?task={{$row->task}}" class="tips action-delete  btn btn-sm btn-danger btn-fs" data-toggle="tooltip" title="{{ __('core.btn_remove') }}">
											<i class="fa  fa-trash"></i></a> @endif </td>
									<td>{{$row->run_at}}</td>
									<td>
										@foreach($row->data as $key => $value)
											{{$key}}: {{is_array($value) ? implode(' , ', $value) : $value}}
											@if(!$loop->last)
												<br>
											@endif
										@endforeach
									</td>
								</tr>

							@endforeach

							</tbody>

						</table>
						<input type="hidden" name="action_task" value=""/>

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