Beispiel #1
0
 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index()
 {
     $AircraftProductions = AircraftProduction::user()->InProduction()->with('aircraft')->get();
     foreach ($AircraftProductions as $AircraftProduction) {
         $AircraftProduction->secLeft = Carbon::now()->diffInSeconds(Carbon::createFromFormat('Y-m-d G:i:s', $AircraftProduction->end));
     }
     $aircraftUsages = AircraftUsage::user()->with('aircraft')->get();
     return view('template.fleetOverview', ['AircraftProductions' => $AircraftProductions, 'aircraftUsages' => $aircraftUsages]);
 }
Beispiel #2
0
 public static function getAircraftUsageList()
 {
     $aircraft_usages = AircraftUsage::user()->with('Aircraft')->get();
     //get list for Dropdown
     foreach ($aircraft_usages as $aircraft_usage) {
         $aircrafts[$aircraft_usage->id] = $aircraft_usage->aircraft->type;
     }
     return $aircrafts;
 }
Beispiel #3
0
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function handle()
 {
     $time_start = microtime(true);
     $i = false;
     $finished = AircraftProduction::isFinished()->get();
     foreach ($finished as $finish) {
         $usage = new AircraftUsage();
         $usage->aircraft_id = $finish->aircraft_id;
         $usage->user_id = $finish->user_id;
         $usage->save();
         $finish->state = 3;
         $finish->save();
         $i = true;
     }
     $time_end = microtime(true);
     $time = $time_end - $time_start;
     if ($i) {
         Log::info('CheckProduction: Count:' . $finished->count() . ' Runtime:' . $time);
     }
 }
 /**
  * Check Planing Form via ajax
  *
  * @param  \Illuminate\Http\Request  $request
  * @return json
  */
 public function checkPlanning(Request $request)
 {
     //dd($request);
     $arrival_time = strtotime($request->departure_time);
     $arrival_time = Carbon::createFromTimestamp($arrival_time)->addHours(2)->addMinutes(6)->format('H:i');
     //dd($arrival_time);
     foreach ($request->days as $value) {
         if ($request->departure_time) {
             $time = explode(':', $request->departure_time);
             $time[1] = $time[1] + $request->departure_offset[$value];
             if ($time[1] > 59) {
                 $time[1] = $time[1] - 60;
                 $time[0]++;
             } elseif ($time[1] < 00) {
                 $time[1] = $time[1] + 60;
                 $time[0]--;
             }
             $time[1] = sprintf("%02d", $time[1]);
             $time[0] = sprintf("%02d", $time[0]);
             $time = $time[0] . ':' . $time[1];
             if ($time < '00:00' or $time > '23:59') {
                 $abflugszeit = false;
             } else {
                 $abflugszeit = true;
             }
         } else {
             $abflugszeit = false;
         }
         $distance = Geo::getDistance(Station::find($request->departure_station_id)->airport_id, Station::find($request->arrival_station_id)->airport_id);
         $aircraft = AircraftUsage::find($request->aircraft_usage_id);
         if ($distance <= $aircraft->aircraft()->first()->maxKm) {
             $performance = true;
         } else {
             $performance = false;
         }
         //dd
         //dd(Slot::check(date('H:i', $arrival_time), Station::find($request->arrival_station_id)->airport_id, $value));
         if (Slot::check($request->departure_time, Station::find($request->departure_station_id)->airport_id, $value) > 1) {
             $abflugslots = false;
         } else {
             $abflugslots = true;
         }
         if (Slot::check($arrival_time, Station::find($request->arrival_station_id)->airport_id, $value) > 1) {
             $ankunftslots = false;
         } else {
             $ankunftslots = true;
         }
         $return[$value] = ['abflugszeit' => $abflugszeit, 'performance' => $performance, 'abflugslots' => $abflugslots, 'ankunftslots' => $ankunftslots];
     }
     return response()->json($return);
 }
 /**
  * Show the form for creating a new resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function create($slug)
 {
     $aircrafts = AircraftUsage::getAircraftUsageList();
     $flightThread = FlightThread::whereSlug($slug)->User()->first();
     return view('template.flight.create', ['aircrafts' => $aircrafts, 'flightThread' => $flightThread]);
 }