v1.3.4 - Small fixes
This commit is contained in:
@@ -154,6 +154,76 @@ class WashingMachineController extends Controller
|
||||
return redirect()->route("washing-machines.index");
|
||||
}
|
||||
|
||||
public function search(Request $request)
|
||||
{
|
||||
if ($request->ajax()) {
|
||||
$output = "<tr>" .
|
||||
"<th>Navn</th>" .
|
||||
"<th>Lokation</th>" .
|
||||
"<th style=\"width: 1em;\"><img class=\"w-100\" src=" . asset('/images/icons/pencil.svg') . " alt=\"Update\"></th>" .
|
||||
"<th style=\"width: 1em;\"><img class=\"w-100\" src=" . asset('/images/icons/trashcan.svg') . " alt=\"Delete\"></th>" .
|
||||
"</tr>";
|
||||
|
||||
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 .= '<tr>' .
|
||||
'<td>' . $machine->washing_name . '</td>' .
|
||||
'<td>' . $machine->location_name . '</td>' .
|
||||
'<td><a href="' . route("washing-machines.edit", ["washing_machine" => $machine->id]) . '"><img class="w-100" src="' . asset('/images/icons/pencil-dark.svg') . '" alt="Update"></a></td>' .
|
||||
'<td><form method="post" action="' . route("washing-machines.destroy", ["washing_machine" => $machine->id]) . '" class="w-100 nostyle">' .
|
||||
csrf_field() .
|
||||
method_field("delete") .
|
||||
|
||||
'<button class="w-100 nostyle" onclick="return confirm(\'Are you sure you want to delete?\');" type="submit"><img class="w-100 cursor-pointer" src="' . asset('/images/icons/trashcan-dark.svg') . '" alt="Delete"></button>' .
|
||||
'</form>' .
|
||||
'</td>' .
|
||||
'</tr>';
|
||||
}
|
||||
} else {
|
||||
$output .= '<tr>' .
|
||||
'<td>Det er ikke blivet oprettet nogen vaskmaskine på denne lokation endnu</td>' .
|
||||
'<td></td>' .
|
||||
'<td></td>' .
|
||||
'<td></td>' .
|
||||
'</tr>';
|
||||
}
|
||||
} elseif ($request->option === "all") {
|
||||
$machines = WashingMachine::all();
|
||||
|
||||
if (count($machines) !== 0) {
|
||||
foreach ($machines as $machine) {
|
||||
$output .= '<tr>' .
|
||||
'<td>' . $machine->name . '</td>' .
|
||||
'<td>' . Location::query()->where("id", "=", $machine->location_id)->first()->name . '</td>' .
|
||||
'<td><a href="' . route("washing-machines.edit", ["washing_machine" => $machine->id]) . '"><img class="w-100" src="' . asset('/images/icons/pencil-dark.svg') . '" alt="Update"></a></td>' .
|
||||
'<td><form method="post" action="' . route('washing-machines.destroy', ['washing_machine' => $machine->id]) . '" class="w-100 nostyle">' .
|
||||
csrf_field() .
|
||||
method_field("delete") .
|
||||
'<button class="w-100 nostyle" onclick="return confirm(' . "'Are you sure you want to delete?'" . ');" type="submit"><img class="w-100 cursor-pointer" src="' . asset('/images/icons/trashcan-dark.svg') . '" alt="Delete"></button>' .
|
||||
'</form>' .
|
||||
'</td>' .
|
||||
'</tr>';
|
||||
}
|
||||
} else {
|
||||
$output .= '<tr>' .
|
||||
'<td>Det er ikke blivet oprettet nogen vaskmaskine på denne lokation endnu</td>' .
|
||||
'<td></td>' .
|
||||
'<td></td>' .
|
||||
'<td></td>' .
|
||||
'</tr>';
|
||||
}
|
||||
}
|
||||
return Response($output);
|
||||
}
|
||||
}
|
||||
|
||||
//Used for checking if the currently typed washingmachine name is unique. Create version
|
||||
public function nameCheck(Request $request){
|
||||
$washing = WashingMachine::query()->where('name', 'LIKE',$request->nameCheck)->where('location_id', '=', $request->location)->get();
|
||||
|
||||
Reference in New Issue
Block a user