@extends('layouts.app')

@section('title',"Instalador de modulos del sistema")

@section('content')
@section('scripts_url')
<script src="{!! asset('assets/file/js/piexif.min.js') !!}" type="text/javascript"></script>
<link href="{!! asset('assets/file/css/fileinput.min.css') !!}" rel="stylesheet" type="text/css">
<script src="{!! asset('assets/file/js/fileinput.min.js') !!}"></script>
@endsection
<div class="response-data" style="display: none;"></div>
<div class="card">
	<ul class="nav nav-tabs nav-tabs-highlight">
		<li class="nav-item"><a href="#highlighted-tab1" class="nav-link active" data-toggle="tab"> <i class=" {{ (!empty($data['get'])) ? 'icon-new' : '' }}" ></i> Install</a></li>
		<li class="nav-item"><a href="#highlighted-tab2" class="nav-link" data-toggle="tab">Installed</a></li>
	</ul>

	<div class="card-body">
		<div class="tab-content">
			<div class="tab-pane fade show active" id="highlighted-tab1">
				<div class="response-apis" style="display: none;"></div>
				<div class="row">
					<div class="col-12 text-right">
					
						<button type="button" class="btn btn-primary" data-toggle="modal" data-target="#createModal">
						 <i class="icon-database-add "></i>  Agregar nuevo modulo
						</button>
					</div>
				</div>
				<div class="row">
					@foreach ($data['get'] as $m)
						<div class="col-3 codenv{{$m->carpeta}}">
							<form action="{{ url('moduleinstall') }}" data-carpeta="codenv{{$m->carpeta}}" method="POST" onsubmit="installModule(this); return false">
								<input type="hidden" name="action" value="install">
								<input type="hidden" name="carpeta" value="{{$m->carpeta}}">
								<div class="alert alert-info mb-0 module-install">
									<div class="text-center new-install">
										<i class="icon-new" ></i>
									</div>
									<p><b>Nombre:</b> {{$m->nombre}}</p>
									<p><b>Version:</b> {{$m->version}}</p>
									<p><b>Carpeta:</b> {{$m->carpeta}}</p>
									<div class="text-center">
										<button class="btn btn-warning"><i class="icon-folder-upload2"></i> Install</button>
									</div>
								</div>
							</form>
						</div>
						
					@endforeach
				</div>
			</div>

			<div class="tab-pane fade" id="highlighted-tab2">
				<table class="table datatable-basic">
					<thead>
						<tr>
							<th>Nº</th>
							<th>Module</th>
							<th>Version</th>
							<th>Carpeta</th>
							<th>Fecha</th>
							<th class="text-center">Actions</th>
						</tr>
					</thead>
					<tbody>
						@foreach ($data['installed'] as $m)
							<tr>
								<td>{{$m->id}}</td>
								<td>{{$m->module}}</td>
								<td>{{$m->version}}</td>
								<td>{{$m->carpeta}}</td>
								<td>{{$m->created_at}}</td>
								<td></td>
							</tr>
						@endforeach
					</tbody>
				</table>
			</div>
		</div>
	</div>
</div>
@include('Install.views.add.zipmodule')
	@section('scripts')
	<script src="{!! asset('assets/views_functions/install.js') !!}"></script>
	<script src="{!! asset('assets/views_functions/config.js') !!}"></script>
	<script>
	    $.extend( $.fn.dataTable.defaults, {
	        autoWidth: false,
	        dom: '<"datatable-header"fl><"datatable-scroll"t><"datatable-footer"ip>',
	        language: {
	            search: '<span>Buscar:</span> _INPUT_',
	            searchPlaceholder: 'Buscar...',
	            lengthMenu: '<span>Mostrar:</span> _MENU_',
	            paginate: { 'first': 'First', 'last': 'Last', 'next': $('html').attr('dir') == 'rtl' ? '&larr;' : '&rarr;', 'previous': $('html').attr('dir') == 'rtl' ? '&rarr;' : '&larr;' }
	        }
	    });
	    var table = $('.datatable-basic').DataTable();
	</script>
		@if (session('install_success'))
			<script>
				$.noty_success("{{ session('install_success') }}");
			</script>
		@endif
	@endsection
@endsection