Skip to content

Commit

Permalink
Merge branch 'development'
Browse files Browse the repository at this point in the history
  • Loading branch information
orkit committed Sep 3, 2024
2 parents edb8952 + 9c365fb commit 038e7cd
Show file tree
Hide file tree
Showing 8 changed files with 63 additions and 5 deletions.
4 changes: 3 additions & 1 deletion app/Http/Controllers/FOController.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ class FOController extends Controller
{
public function __construct()
{
$this->middleware('fo')->except(['list', 'svlist']);
$this->middleware('fo')->except(['list', 'svlist', 'download']);
$this->middleware('download')->only('download');
}

/**
Expand Down Expand Up @@ -52,6 +53,7 @@ public function svlist()

public function pdfview($id)
{
//Custom middleware
$tr = TravelRequest::find($id);
$user = User::find(Dashboard::where('request_id', $tr->id)->first()->user_id);
$manager = User::find(Dashboard::where('request_id', $tr->id)->first()->manager_id);
Expand Down
1 change: 1 addition & 0 deletions app/Http/Kernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,5 +69,6 @@ class Kernel extends HttpKernel
'fo' => \App\Http\Middleware\EnsureUserIsFO::class,
'checklang' => \App\Http\Middleware\CheckLocalizaion::class,
'locale' => \App\Http\Middleware\Switchlocale::class,
'download' => \App\Http\Middleware\EnsureUserForDownload::class,
];
}
36 changes: 36 additions & 0 deletions app/Http/Middleware/EnsureUserForDownload.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?php

namespace App\Http\Middleware;

use App\Models\Dashboard;
use Closure;
use Illuminate\Http\Request;
use Statamic\Auth\User;
use Symfony\Component\HttpFoundation\Response;

class EnsureUserForDownload
{
/**
* Handle an incoming request.
*
* @param \Closure(\Illuminate\Http\Request): (\Symfony\Component\HttpFoundation\Response) $next
*/
public function handle(Request $request, Closure $next): Response
{
/****
* Ensure the right user downloads the request
*/

$id = basename($request->getUri());
$user = User::current();
$dashboard = Dashboard::where('request_id',$id)->first();
$valid_viewers = [$dashboard->user_id, $dashboard->manager_id, $dashboard->fo_id, $dashboard->head_id];

if(in_array($user->id, $valid_viewers) or \Statamic\Auth\User::current()->can('financial_officer')) {
return $next($request);
}

abort(401);
return redirect('/');
}
}

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion public/build/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"src": "node_modules/@fortawesome/fontawesome-free/webfonts/fa-v4compatibility.woff2"
},
"resources/css/site.css": {
"file": "assets/site-7511ffe8.css",
"file": "assets/site-e2b62d43.css",
"isEntry": true,
"src": "resources/css/site.css"
},
Expand Down
10 changes: 10 additions & 0 deletions resources/views/navbar/navbar.blade.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,19 @@
<nav class="bg-white border-b border-susecondary dark:bg-gray-900 dark:border-gray-700">
<div class="relative flex flex-wrap md:flex-row lg:flex-nowrap w-full p-5 mx-auto bg-white items-center justify-between md:px-6 lg:px-8 dark:border-gray-600 dark:bg-gray-900">
<a href="{{ config('app.url') }}" class="flex items-center mr-4">

<span class="flex opacity-90 items-center h-full px-0.5 py-px ml-2 text-xl leading-none border-[2px] border-suprimary rounded dark:text-white dark:border-white">
DSV
</span>
{{--}}
<div class="inline-block bg-gradient-to-tl from-suprimary via-transparent to-susecondary p-px rounded-xl">
<div class="bg-white rounded-xl py-1 px-2 text-lg font-bold md:text-xl lg:text-2xl lg:leading-tight dark:bg-neutral-900">
<span class="bg-clip-text bg-gradient-to-tl from-suprimary to-susecondary text-transparent">
DSV
</span>
</div>
</div>
{{--}}
<span class="hidden md:block font-sudepartment ml-1 mb-1 text-xl font whitespace-nowrap dark:text-white">{{__("Intranet")}}</span>

@if(config('app.name') == 'IntranetDev')
Expand Down
9 changes: 9 additions & 0 deletions resources/views/requests/travel/comments.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,13 @@
<hr class="m-2">
@endif
@endif
<!-- Download if approved -->
@if($tr->state == 'fo_approved')
<div class="grid grid-cols-1 mt-2">
<a href="{{route('travel-request-pdf', $tr->id)}}" class="inline-flex items-center justify-center gap-x-1.5 text-blue-800 font-medium py-2 px-4 border border-susecondary rounded-lg w-full text-center dark:text-black">
{{__("Download")}}
</a>
</div>
@endif
<!-- end download -->
</article>
2 changes: 1 addition & 1 deletion resources/views/vendor/live-search/dropdown.blade.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<div id="searchinput" class="relative grow max-w-96 ml-4 mr-2 md:order-none">
<div id="searchinput" class="relative grow max-w-96 ml-4 mr-2 mt-2 md:order-none md:mt-0">
<div class="pointer-events-none absolute inset-y-0 left-0 pl-3 flex items-center">
<span class="absolute inset-y-0 left-0 flex items-center pl-3">
<svg class="w-5 h-5 text-blue-800 dark:text-gray-200" viewBox="0 0 24 24" fill="none">
Expand Down

0 comments on commit 038e7cd

Please sign in to comment.