diff --git a/skolehjem/app/Http/Controllers/LocationController.php b/skolehjem/app/Http/Controllers/LocationController.php index d60aba5..33b73f5 100644 --- a/skolehjem/app/Http/Controllers/LocationController.php +++ b/skolehjem/app/Http/Controllers/LocationController.php @@ -165,82 +165,4 @@ class LocationController extends Controller return 1; } } - - - - - public function search(Request $request){ - if($request->ajax()){ - $output = "". - "Navn". - "Lokation". - "\"Update\"". - "\"Delete\"". - ""; - - if($request->option !== 'all') { - $locations = DB::table('washing_machines') - ->join('locations', 'washing_machines.location_id','=', 'locations.id') - ->select(DB::raw('washing_machines.name as washing_name, locations.name as location_name, locations.id as id')) - ->where('locations.id', '=', $request->option) - ->get(); - - if(count($locations) !== 0){ - foreach ($locations as $key => $location){ - $output.=''. - '' . $location->washing_name . ''. - '' . $location->location_name . ''. - '
$location->id ]). '" class="w-100 nostyle">'. - ' $location->id ]). '" class="w-100 nostyle">'. - csrf_field(). - method_field("delete"). - - ''. - '
'. - ''. - ''; - } - }else{ - $output.=''. - 'Det er ikke blivet oprettet nogen vaskmaskine på denne lokation i nu'. - ''. - ''. - ''. - ''; - } - } - elseif($request->option === "all"){ - $machines = WashingMachine::all(); - - if(count($machines) !== 0){ - foreach($machines as $machine) { - $output.= ''. - ''.$machine->name.''. - ''.Location::query()->where("id", "=", $machine->location_id)->first()->name.''. - ' $machine->id]) . '">Update'. - '
'. - csrf_field(). - method_field("delete"). - ''. - '
'. - ''. - ''; - } - }else{ - $output.=''. - 'Det er ikke blivet oprettet nogen vaskmaskine på denne lokation i nu'. - ''. - ''. - ''. - ''; - } - } - - - - - return Response($output); - } - } - } diff --git a/skolehjem/app/Http/Controllers/WashingMachineController.php b/skolehjem/app/Http/Controllers/WashingMachineController.php index 921e5bb..85b458d 100644 --- a/skolehjem/app/Http/Controllers/WashingMachineController.php +++ b/skolehjem/app/Http/Controllers/WashingMachineController.php @@ -10,6 +10,7 @@ use Illuminate\Http\Request; use Illuminate\Http\Response; use App\WashingMachine; +use Illuminate\Support\Facades\DB; use Illuminate\View\View; class WashingMachineController extends Controller @@ -167,4 +168,78 @@ class WashingMachineController extends Controller return 1; } } + + public function search(Request $request){ + if($request->ajax()){ + $output = "". + "Navn". + "Lokation". + "\"Update\"". + "\"Delete\"". + ""; + + if($request->option !== 'all') { + $machines = DB::table('washing_machines') + ->join('locations', 'washing_machines.location_id','=', 'locations.id') + ->select(DB::raw('washing_machines.name as washing_name, locations.name as location_name, washing_machines.id as id')) + ->where('locations.id', '=', $request->option) + ->get(); + + if(count($machines) !== 0){ + foreach ($machines as $machine){ + $output.=''. + '' . $machine->washing_name . ''. + '' . $machine->location_name . ''. + ' $machine->id ]) . '">Update'. + '
$machine->id ]). '" class="w-100 nostyle">'. + csrf_field(). + method_field("delete"). + + ''. + '
'. + ''. + ''; + } + }else{ + $output.=''. + 'Det er ikke blivet oprettet nogen vaskmaskine på denne lokation i nu'. + ''. + ''. + ''. + ''; + } + } + elseif($request->option === "all"){ + $machines = WashingMachine::all(); + + if(count($machines) !== 0){ + foreach($machines as $machine) { + $output.= ''. + ''.$machine->name.''. + ''.Location::query()->where("id", "=", $machine->location_id)->first()->name.''. + ' $machine->id]) . '">Update'. + '
'. + csrf_field(). + method_field("delete"). + ''. + '
'. + ''. + ''; + } + }else{ + $output.=''. + 'Det er ikke blivet oprettet nogen vaskmaskine på denne lokation i nu'. + ''. + ''. + ''. + ''; + } + } + + + + + return Response($output); + } + } } diff --git a/skolehjem/app/Http/Controllers/WashingReservationController.php b/skolehjem/app/Http/Controllers/WashingReservationController.php index a2fca22..e187c80 100644 --- a/skolehjem/app/Http/Controllers/WashingReservationController.php +++ b/skolehjem/app/Http/Controllers/WashingReservationController.php @@ -15,6 +15,8 @@ use App\WashingReservation; use Illuminate\Support\Facades\DB; use Illuminate\View\View; +date_default_timezone_set('Europe/Copenhagen'); + class WashingReservationController extends Controller { public function __construct() @@ -37,6 +39,8 @@ class WashingReservationController extends Controller */ public function index(Request $request) { + WashingReservation::query()->where('time', '<', date('Y-m-d H:i:s', strtotime('-1 hour')))->delete(); + $reservations = WashingReservation::query()->orderBY('time' , 'asc')->paginate($request->query("limit", 20)); return Response::detect("washing-reservations.index", [ "reservations" => $reservations]); @@ -260,6 +264,8 @@ class WashingReservationController extends Controller public function appindex(Request $request) { + WashingReservation::query()->where('time', '<', date('Y-m-d H:i:s', strtotime('-1 hour')))->delete(); + $reservations = WashingReservation::query()->where("user_id", "=", auth()->user()->id)->orderBY('time' , 'asc')->paginate($request->query("limit", 20)); return Response::detect("washing-reservations.index", [ "reservations" => $reservations]); diff --git a/skolehjem/public/css/admin.css b/skolehjem/public/css/admin.css index ee7f16d..7803f31 100644 --- a/skolehjem/public/css/admin.css +++ b/skolehjem/public/css/admin.css @@ -6667,7 +6667,7 @@ main { background-color: #00788A; } -.segment > h3 { +.segment > div > h3 { margin-left: -1rem; margin-top: 0; width: calc(100% + 1rem); @@ -6675,12 +6675,12 @@ main { font-size: 1.15em; } -.segment > h3 > a { +.segment > div > h3 > a { padding: 1rem 2rem; display: flex; } -.segment > h3 > a > img { +.segment > div > h3 > a > img { width: 1.5em; } @@ -6691,7 +6691,7 @@ main { margin-bottom: .5rem;*/ } -.segment > h3:hover { +.segment > div > h3:hover { background-color: rgba(0, 0, 0, 0.2); } diff --git a/skolehjem/resources/lang/dk/msg.php b/skolehjem/resources/lang/dk/msg.php index 8400730..1cb10fb 100644 --- a/skolehjem/resources/lang/dk/msg.php +++ b/skolehjem/resources/lang/dk/msg.php @@ -59,6 +59,8 @@ return[ "sedeltagere" => "Se deltagere", "af" => "Af", "programmedby" => "Programmeret af", + "omappen" => "Om appen", + "infoomappen" => "Denne app er udviklet til Odense erhvervskollegie.", "error" => "Fejl", "404" => "Denne side findes ikke.", "canceled" => "Aflyst" diff --git a/skolehjem/resources/lang/en/msg.php b/skolehjem/resources/lang/en/msg.php index 0aa43e8..587823e 100644 --- a/skolehjem/resources/lang/en/msg.php +++ b/skolehjem/resources/lang/en/msg.php @@ -66,6 +66,8 @@ return[ "sedeltagere" => "See participants", "af" => "By", "programmedby" => "Programmed by", + "omappen" => "The App", + "infoomappen" => "The app is developed and designed for 'Odense erhvervskollegie'.", "error" => "Error", "404" => "This page doesn't exist.", "canceled" => "Canceled" diff --git a/skolehjem/resources/sass/admin/nav/nav.scss b/skolehjem/resources/sass/admin/nav/nav.scss index be2c737..44a326e 100644 --- a/skolehjem/resources/sass/admin/nav/nav.scss +++ b/skolehjem/resources/sass/admin/nav/nav.scss @@ -13,7 +13,7 @@ div.w-85 { background-color: #00788A; } -.segment > h3 { +.segment > div > h3 { margin-left: -1rem; margin-top: 0; width: calc(100% + 1rem); @@ -21,12 +21,12 @@ div.w-85 { font-size: 1.15em; } -.segment > h3 > a { +.segment > div > h3 > a { padding: 1rem 2rem; display: flex; } -.segment > h3 > a > img { +.segment > div > h3 > a > img { width: 1.5em; } @@ -37,7 +37,7 @@ div.w-85 { margin-bottom: .5rem;*/ } -.segment > h3:hover { +.segment > div > h3:hover { background-color: rgba(0,0,0, 0.2); } @@ -46,10 +46,6 @@ div.w-85 { padding-right: 8px; } -.segment > div > a { - -} - .btn-inline { display: inline-flex; align-items: center; diff --git a/skolehjem/resources/views/admin/layout/base.blade.php b/skolehjem/resources/views/admin/layout/base.blade.php index b34963c..85bb23a 100644 --- a/skolehjem/resources/views/admin/layout/base.blade.php +++ b/skolehjem/resources/views/admin/layout/base.blade.php @@ -20,11 +20,19 @@ var w85 = document.getElementsByClassName("w-85")[0]; $(".w-85").css({ "width": "85%" }); - $(".segment > h3").css({"margin-left": "", "width": ""}); - $(".segment > h3 > a").css({ "display": ""}); - $(".segment > h3 > a > span").css({"display": ""}); + $(".segment > div > h3").css({"margin-left": "", "width": ""}); + $(".segment > div > h3 > a").css({ "display": ""}); + $(".segment > div > h3 > a > span").css({"display": ""}); - $(".segment > div").css({"margin-left": "-1rem", "padding": "1rem 0rem 1rem 2rem", "width": "calc(100% - 3rem)"}); + $(document).on({ + mouseenter: function() { + $(this).find('.tooltiptext').css("visibility", "hidden"); + }, + mouseleave: function() { + $(this).find('.tooltiptext').css("visibility", "hidden"); + } + }, ".tooltip"); + $(".segment .hamburger > div").css({"margin-left": "-1rem", "width": "calc(100% - 3rem)"}); $(".segment > div > a").css({"margin-left": "auto", "margin-right": ""}); localStorage.setItem("collapsed", "false"); @@ -46,11 +54,20 @@ var w85 = document.getElementsByClassName("w-85")[0]; $(".w-85").css({ "width": "calc(100% - 64px)"}); - $(".segment > h3").css({"margin-left": "0", "width": "100%"}); - $(".segment > h3 > a").css({"display": "flex"}); - $(".segment > h3 > a > span").css({"display": "none"}); + $(".segment > div > h3").css({"margin-left": "0", "width": "100%"}); + $(".segment > div > h3 > a").css({"display": "flex"}); + $(".segment > div > h3 > a > span").css({"display": "none"}); - $(".segment > div").css({"margin-left": "0", "padding": "1rem 0", "width": "100%"}); + $(document).on({ + mouseenter: function() { + $(this).find('.tooltiptext').css("visibility", "visible"); + }, + mouseleave: function() { + $(this).find('.tooltiptext').css("visibility", "hidden"); + } + }, ".tooltip"); + + $(".segment.hamburger > div").css({"margin-left": "0", "width": "calc(100% - 4rem)"}); $(".segment > div > a").css({"margin-left": "auto", "margin-right": "auto"}); localStorage.setItem("collapsed", "true"); @@ -66,102 +83,80 @@ + @yield("header")
diff --git a/skolehjem/resources/views/admin/locations/show.blade.php b/skolehjem/resources/views/admin/locations/show.blade.php index 43c8a97..d32860c 100644 --- a/skolehjem/resources/views/admin/locations/show.blade.php +++ b/skolehjem/resources/views/admin/locations/show.blade.php @@ -18,23 +18,23 @@ $i = 1; ?>
- @foreach(\App\WashingMachine::query()->where("location_id", "=", $location->id)->get() as $machine) - @foreach(\App\WashingReservation::query()->where("machine_id", "=", $machine->id)->where("time", "LIKE", date("Y-m-d"). "%")->orderBy("time", "asc")->get() as $reservation) - @if (date('Y-m-d H:i:s', strtotime('-1 hour')) < $reservation->time) - @if($i % 3 == 1) -
-
- @endif -
-

{{ \App\WashingMachine::query()->find($reservation->machine_id)->name }}

-
- Dato: {{ \Illuminate\Support\Facades\Date::createFromTimeStamp(strtotime($reservation->time))->format('d/m/Y') }} - Tid: {{ \Illuminate\Support\Facades\Date::createFromTimeStamp(strtotime($reservation->time))->format('\k\l\. H:i') }} - {{ \App\User::query()->where("id", "=", $reservation->user_id)->first()->name_first }} {{ \App\User::query()->where("id", "=", $reservation->user_id)->first()->name_last }} -
+ @foreach(\App\WashingReservation::query()->join('washing_machines', 'washing_machines.id', '=', 'washing_reservations.machine_id')->where("location_id", "=", $location->id)->where("time", "LIKE", date("Y-m-d"). "%")->orderBy("time", "asc")->get() as $reservation) + @if (date('Y-m-d H:i:s', strtotime('-1 hour')) < $reservation->time) + @if($i % 3 == 1)
- +
@endif - @endforeach +
+

{{ \App\WashingMachine::query()->find($reservation->machine_id)->name }}

+
+ Dato: {{ \Illuminate\Support\Facades\Date::createFromTimeStamp(strtotime($reservation->time))->format('d/m/Y') }} + Tid: {{ \Illuminate\Support\Facades\Date::createFromTimeStamp(strtotime($reservation->time))->format('\k\l\. H:i') }} - {{ \App\User::query()->where("id", "=", $reservation->user_id)->first()->name_first }} {{ \App\User::query()->where("id", "=", $reservation->user_id)->first()->name_last }} +
+
+ + @else + {{ \App\WashingReservation::query()->join('washing_machines', 'washing_machines.id', '=', 'washing_reservations.machine_id')->where("location_id", "=", $location->id)->where('time', '<', date('Y-m-d H:i:s'). '%')->delete() }} + @endif @endforeach @if($i == 1) Der er ingen vaskemaskine reservationer for i dag. @@ -46,8 +46,8 @@ @yield("scripts") diff --git a/skolehjem/resources/views/admin/washing-machines/index.blade.php b/skolehjem/resources/views/admin/washing-machines/index.blade.php index 8e1844b..9be1d94 100644 --- a/skolehjem/resources/views/admin/washing-machines/index.blade.php +++ b/skolehjem/resources/views/admin/washing-machines/index.blade.php @@ -49,7 +49,7 @@ console.log($value); $.ajax({ type: 'get', - url: '{{route('locations.search')}}', + url: '{{route('washing-machines.search')}}', data: {'option':$value}, success:function (data) { console.log($value); diff --git a/skolehjem/resources/views/app/about/index.blade.php b/skolehjem/resources/views/app/about/index.blade.php index fdab4ff..3f62ebd 100644 --- a/skolehjem/resources/views/app/about/index.blade.php +++ b/skolehjem/resources/views/app/about/index.blade.php @@ -8,13 +8,13 @@

{{ __('msg.omkring') }}

Version:

1.0

-

Om appen:

-

Denne app er udviklet til Odense erhvervskollegie.

+

{{__("msg.omappen")}}:

+

{{__("msg.infoomappen")}}

{{__("msg.programmedby")}}:

Anders Rasmussen,anders164a@gmail.com Frederik Milling Pytlick,frederikpyt@gmail.com - Vedran Zelen,vedr0021@gmail.com + Vedran Zelen,zelenvedran@gmail.com Victor Neerholt,victorneerholt@gmail.com - Sebastian Davaris,seba4928@edu.sde.dk + Sebastian Davaris,sebastian@davaris.dk @endsection diff --git a/skolehjem/routes/web.php b/skolehjem/routes/web.php index d03be30..9690eb4 100644 --- a/skolehjem/routes/web.php +++ b/skolehjem/routes/web.php @@ -49,7 +49,7 @@ Route::get("/rolesapi", "RolesController@search")->name("roles.search"); Route::get("/userapi", "UserController@search")->name("users.search"); Route::get("/vaskeapi", "WashingReservationController@search")->name("washing-reservations.search"); Route::get("/risrosapi", "FeedbackController@search")->name("feedbacks.search"); -Route::get("/locationapi", "LocationController@search")->name("locations.search"); +Route::get("/machineapi", "WashingMachineController@search")->name("washing-machines.search"); //Cookies Route::get("/languages", "UserController@setLanguages")->name("users.setLanguages");