Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow multiple surveys #118

Merged
merged 2 commits into from
Oct 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions code/webapp/app/Http/Controllers/ClientController.php
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ public function edit($id)
$departmentsList = DepartmentList::all();
$usersList = UserList::where("client_id", $id)->get();
$userDepartments = DepartmentList::where("user_id", $id)->get();
$surveys = InfoContent::where("info_id", 1)->get();
$mentors = User::where("user_type_id", 1)
->orWhere("user_type_id", 3)
->get();
Expand All @@ -139,15 +140,18 @@ public function edit($id)
"departmentsList",
"mentors",
"userDepartments",
"usersList"
"usersList",
"surveys"
)
);
}

public function sendSurvey($id)
public function sendSurvey(Request $request, $id)
{
$url = InfoContent::where("info_id", 1)->first()->url;
$survey = $request->input('survey_id');
$url = InfoContent::find($survey);
$url = $url . $id;

User::find($id)->notify(new Survey($url));
User::find($id)->update(["survey" => now()]);

Expand Down
20 changes: 12 additions & 8 deletions code/webapp/app/Http/Controllers/SurveyController.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public function create()
{
Gate::authorize("allowAdmin");

//
return view("surveys.create");
}

/**
Expand All @@ -46,7 +46,14 @@ public function store(Request $request)
{
Gate::authorize("allowAdmin");

//
// $request->request->add(["section_id" => 5]);
// Info::create($request->all());

$request->request->add(["info_id" => 1]);
InfoContent::create($request->all());

$msg = "New survey Created successful! ";
return redirect("surveys")->with("msg", $msg);
}

/**
Expand All @@ -70,9 +77,8 @@ public function edit($id)
{
Gate::authorize("allowAdmin");

$survey = InfoContent::where("info_id", $id)
->get()
->first();
$survey = InfoContent::find($id);

return view("surveys.edit", compact("survey"));
}

Expand All @@ -87,9 +93,7 @@ public function update(Request $request, $id)
{
Gate::authorize("allowAdmin");

$survey = InfoContent::where("info_id", $id)
->get()
->first();
$survey = InfoContent::find($id);
$survey->update($request->all());

$msg = "Survey Updated successful! ";
Expand Down
36 changes: 22 additions & 14 deletions code/webapp/resources/views/clients/edit.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -126,23 +126,31 @@ class="text-wb-blue ml-2">Verwijder</button>
<div class="border-t-4 rounded border-[#f39c12]">
<div class="m-3">
<h1 class="text-2xl">Tevredenheids meting</h1>
@if ($client->survey == null)
<p class="mt-5 mb-7">Er is nog geen tevredenheids meting verstuurd naar deze client</p>
<a href="{{ route('clients.sendSurvey', ['id' => $client->id]) }}"
class="bg-[#f39c12] rounded px-4 py-2 mt-5 text-white"
onclick="return confirm('Ben je zeker dat je deze tevredenheidsmeting wilt sturen?');">Tevredenheids
meting versturen</a>
@else
<p class="mt-5 mb-7">Een tevredenheids meting is reeds verstuurd naar deze client, laatst
verstuurd op {{ $client->survey }}</p>
<a href="{{ route('clients.sendSurvey', ['id' => $client->id]) }}"
class="bg-[#f39c12] rounded px-4 py-2 mt-5 text-white"
onclick="return confirm('Ben je zeker dat je deze tevredenheidsmeting wilt sturen?');">Tevredenheids
meting opnieuw versturen</a>
@endif
<form action="{{ route('clients.sendSurvey', ['id' => $client->id]) }}?survey_id=">
@csrf
<select name="survey_id" id="surveySelect"
class="border border-[#d2d6de] px-4 py-2 outline-wb-blue mt-5">
@foreach ($surveys as $survey)
<option value="{{ $survey->id }}">{{ $survey->title }}</option>
@endforeach
</select>
@if ($client->survey == null)
<p class="mt-5 mb-7">Er is nog geen tevredenheids meting verstuurd naar deze client</p>
<button type="submit" class="bg-[#f39c12] rounded px-4 py-2 mt-5 text-white"
onclick="return confirm('Ben je zeker dat je deze tevredenheidsmeting wilt sturen?);">Tevredenheids
meting versturen</button>
@else
<p class="mt-5 mb-7">Een tevredenheids meting is reeds verstuurd naar deze client, laatst
verstuurd op {{ $client->survey }}</p>
<button type="submit" class="bg-[#f39c12] rounded px-4 py-2 mt-5 text-white"
onclick="return confirm('Ben je zeker dat je deze tevredenheidsmeting wilt sturen?);">Tevredenheids
meting opnieuw versturen</button>
@endif
</form>
</div>
</div>
</div>

</main>
</body>

Expand Down
21 changes: 21 additions & 0 deletions code/webapp/resources/views/surveys/create.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
@extends('layout')
<title>Waaiburg - Tevredenheids Meting</title>

@section('content')
<h1 class="text-2xl">Tevredenheids meting toevoegen</h1>
<form action="{{ route('surveys.store') }}" method="POST" class="flex flex-col mt-3">
@csrf
@method('POST')

<x-errormessage />

<x-form-input name="title" text="Titel" />
<x-form-input name="url" text="Google forms url" />


<div class="flex gap-5">
<x-form-button text="Aanmaken" />
<x-form-button text="Annuleren" link="surveys.index" />
</div>
</form>
@endsection
1 change: 1 addition & 0 deletions code/webapp/resources/views/surveys/edit.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

<x-errormessage />

<x-form-input name="title" text="Titel" :value="$survey" />
<x-form-input name="url" text="Google form link" :value="$survey" />

<div class="flex gap-5">
Expand Down
6 changes: 4 additions & 2 deletions code/webapp/resources/views/surveys/index.blade.php
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
@extends('layout')
<title>Waaiburg - Tevredenheids Meting</title>
@section('content')
<x-list-title title="Tevredenheids Meting" name="" />
<x-list-title title="Tevredenheids Meting" name="surveys.create" />
<table class="border-collapse border border-[#f4f4f4] w-full" aria-describedby="survey">
<thead>
<tr>
<th class="border border-[#f4f4f4] py-2 px-6 text-left">Google form link</th>
<th class="border border-[#f4f4f4] py-2 px-6 text-left">Titel</th>
<th class="border border-[#f4f4f4] py-2 px-6">Google form link</th>
<th class="border border-[#f4f4f4] py-2 px-6">Acties</th>
</tr>
</thead>
<tbody>
@foreach ($surveys as $survey)
<tr class="font-normal">
<td class="border border-[#f4f4f4] py-2 px-6 w-full">{{ $survey->title }}</td>
<td class="border border-[#f4f4f4] py-2 px-6 w-full">{{ $survey->url }}</td>
<td class="border border-[#f4f4f4] py-2 px-6 w-full">
<a href="{{ route('surveys.edit', $survey->id) }}" class="text-wb-blue">Bewerk</a>
Expand Down