Skip to content
This repository has been archived by the owner on Sep 14, 2023. It is now read-only.

Commit

Permalink
Merge pull request #12 from swan58/master
Browse files Browse the repository at this point in the history
Fixed and styled import for schedule and fleet
  • Loading branch information
swan58 committed Jan 29, 2017
2 parents 989c01b + b1cd821 commit d1711be
Show file tree
Hide file tree
Showing 5 changed files with 138 additions and 15 deletions.
28 changes: 18 additions & 10 deletions app/Http/Controllers/Admin/ImportExportController.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,25 +68,29 @@ public function postFleet(Request $request)
$path = $request->file('file')->store('imports');
//dd($path);
// Load the Excel Import Object

$sheet = Excel::load('storage/app/'.$path, function ($reader) {})->get();

foreach ($sheet as $row)
{
//$airline_id = Airline::where('icao', $row['airline'])->first();
//$row['airline'] = $airline_id->id;
$data = [
'airline' => number_format($row->airline),
'airline' => $row->airline,
'icao' => $row->icao,
'name' => $row->name,
'manufacturer' => $row->manufacturer,
'registration' => $row->registration,
'range' => number_format($row->range),
'maxgw' => number_format($row->maxgw),
'maxpax' => number_format($row->maxpax),
'enabled' => number_format($row->enabled)
'range' => $row->range,
'maxgw' => $row->maxgw,
'maxpax' => $row->maxpax,
'enabled' => $row->status
];
AircraftData::createAircraft($data);
}

$request->session()->flash('success', 'Fleet imported successfully.');

return redirect('/admin/fleet');
}
}
Expand Down Expand Up @@ -117,17 +121,21 @@ public function postSchedule(Request $request)
foreach ($sheet as $row)
{
$data = [
'airline' => number_format($row->airline),
'airline' => number_format($row->airline),
'airline' => $row->airline,
'flightnum' => $row->flightnum,
'depicao' => $row->depicao,
'arricao' => $row->arricao,
'aircraft_group' => number_format($row->aircraft_group),
'type' => number_format($row->type),
'enabled' => number_format($row->enabled)
'aircraft_group' => $row->aircraft_group,
'deptime' => $row->deptime,
'arrtime' => $row->arrtime,
'type' => $row->type,
'enabled' => $row->enabled
];
VAOS_Schedule::newRoute($data);
}

$request->session()->flash('success', 'Routes imported successfully.')

return redirect('/admin/schedule');
}
}
Expand Down
42 changes: 37 additions & 5 deletions resources/views/admin/data/import.blade.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,40 @@
@extends('layouts.admin')

@section('breadcrumb')
<li class="breadcrumb-item">Home</li>
<li class="breadcrumb-item"><a href="{{ url('admin') }}">Admin</a>
</li>
<li class="breadcrumb-item"><a href="{{ url('admin/'.$route) }}">{{ ucfirst($route) }}</a>
</li>
<li class="breadcrumb-item active">Import &amp; Export</li>
@endsection

@section('content')
<form class="form-horizontal" role="form" method="POST" enctype="multipart/form-data" action="{{ url('/admin/data/'.$route.'?action=import') }}">
{{ csrf_field() }}
<input type="file" name="file" id="file">
<button type="submit" class="btn btn-success" role="button">Submit</button>
</form>
<div class="row">
<div class="col-lg-4">
<div class="card">
<div class="card-header">File Import</div>
<div class="card-block">
<p>Upload an XLSX file to be imported into the {{ $route }} table.</p>
<form class="form-horizontal" role="form" method="POST" enctype="multipart/form-data" action="{{ url('/admin/data/'.$route.'?action=import') }}">
{{ csrf_field() }}
<input type="file" name="file" id="file">
<button type="submit" class="btn btn-success pull-right" role="button">Import</button>
</form>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-lg-12">
<div class="card">
<div class="card-header">File Format Example</div>
<div class="card-block">
<p>The file must be uploaded as a Microsoft Excel Worksheet (.xlsx) format in the following structure. Below is an example of the structure that should be used.</p>
@include('admin.partials.import_format.'.$route)
</div>
</div>
</div>
</div>

@endsection
35 changes: 35 additions & 0 deletions resources/views/admin/partials/import_format/fleet.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<table class="table table-border table-inverse">
<tr>
<td>airline</td>
<td>icao</td>
<td>name</td>
<td>manufacturer</td>
<td>registration</td>
<td>range</td>
<td>maxgw</td>
<td>maxpax</td>
<td>status</td>
</tr>
<tr>
<td>1</td>
<td>B738</td>
<td>B737-800</td>
<td>Boeing</td>
<td>N351JX</td>
<td>5500</td>
<td>155000</td>
<td>200</td>
<td>1</td>
</tr>
<tr>
<td>1</td>
<td>A320</td>
<td>A320-200</td>
<td>Airbus</td>
<td>N352JX</td>
<td>5500</td>
<td>155000</td>
<td>200</td>
<td>1</td>
</tr>
</table>
44 changes: 44 additions & 0 deletions resources/views/admin/partials/import_format/schedule.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<table class="table table-border table-inverse">
<tr>
<td>airline</td>
<td>flightnum</td>
<td>depicao</td>
<td>arricao</td>
<td>route</td>
<td>aircraft_group</td>
<td>deptime</td>
<td>arrtime</td>
<td>notes</td>
<td>type</td>
<td>daysofweek</td>
<td>enabled</td>
</tr>
<tr>
<td>1</td>
<td>66</td>
<td>KABQ</td>
<td>KJFK</td>
<td></td>
<td>A320</td>
<td>5:09:00</td>
<td>10:09:00</td>
<td>FlightAware Schedule</td>
<td>1</td>
<td>123456</td>
<td>1</td>
</tr>
<tr>
<td>1</td>
<td>1492</td>
<td>KACK</td>
<td>KJFK</td>
<td></td>
<td>RJ85</td>
<td>13:08:00</td>
<td>14:08:00</td>
<td>FlightAware Schedule</td>
<td>1</td>
<td>123456</td>
<td>1</td>
</tr>
</table>
4 changes: 4 additions & 0 deletions resources/views/layouts/admin.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,10 @@
<div class="container-fluid">

<div class="animated fadeIn">
@if(session('success'))
<div class="alert alert-success">{{ session('success') }}</div>
@endif

@yield('content')
</div>

Expand Down

0 comments on commit d1711be

Please sign in to comment.