diff --git a/app/Http/Controllers/ProjectController.php b/app/Http/Controllers/ProjectController.php index 44292755555115e71c6ddae34a4a3c6c3d90501f..a613a2a21248794d9ee5f1ace36e5cd96c3b97ad 100644 --- a/app/Http/Controllers/ProjectController.php +++ b/app/Http/Controllers/ProjectController.php @@ -23,6 +23,7 @@ class ProjectController extends Controller */ public function index($id) { + $project = DB::table('projects')->where('id', $id)->first(); $requirements = DB::table('requirements')->where('idProject', $id)->get(); $role = DB::table('userprojects')->where('idProject', $id)->where('idUser', Auth::id())->first()->role; $moderatorId = DB::table('userprojects')->where('idProject', $id)->where('role', 1)->first()->idUser; @@ -60,7 +61,7 @@ class ProjectController extends Controller } } - return view('project', ['requirements' => $requirements, 'id' => $id, 'role' => $role, 'moderator' => $moderatorName, 'members' => $memberNames, 'users' => $pickableUsers]); + return view('project', ['project' => $project, 'requirements' => $requirements, 'id' => $id, 'role' => $role, 'moderator' => $moderatorName, 'members' => $memberNames, 'users' => $pickableUsers, 'maxPhase' => 5]); } /** @@ -95,4 +96,14 @@ class ProjectController extends Controller return redirect()->route('project', ['id' => $request->projectId, 'msg' => 2]); } + + /** + * Update phase + */ + public function updatePhase(Request $request) + { + DB::table('projects')->increment('phase'); + + return redirect()->route('project', ['id' => $request->projectId, 'msg' => 3]); + } } diff --git a/resources/views/home.blade.php b/resources/views/home.blade.php index 2d64c924e252316e5f57f6b99f4ba6d4e7d29c06..56007317ab10b692a8fed44c3581c39daa9f1a3e 100644 --- a/resources/views/home.blade.php +++ b/resources/views/home.blade.php @@ -15,19 +15,19 @@ <div class="row justify-content-center"> <div class="col-md-12"> <div class="card"> - <div class="card-header font-weight-bold">My Projects</div> + <div class="card-header font-weight-bold bg-primary text-white">My Projects</div> <div class="card-body"> @if(count($projects) == 0) There is no project @else - <table class="table table-striped"> + <table class="table"> <thead> - <tr> - <th scope="col">#</th> - <th scope="col">Project Name</th> - <th scope="col">Role</th> - <th scope="col">Action</th> + <tr class="table-active"> + <th scope="col">#</th> + <th scope="col">Project Name</th> + <th scope="col">Role</th> + <th scope="col">Action</th> </tr> </thead> <tbody> diff --git a/resources/views/layouts/app.blade.php b/resources/views/layouts/app.blade.php index 2b42c6aa54f19d0c21558d5e43af4b7968a37af6..388bca7f94dd6634f42cd9ac894c24b9e2c91032 100644 --- a/resources/views/layouts/app.blade.php +++ b/resources/views/layouts/app.blade.php @@ -21,9 +21,9 @@ </head> <body> <div id="app"> - <nav class="navbar navbar-expand-md navbar-light bg-white shadow-sm"> + <nav class="navbar navbar-expand-md navbar-light shadow-sm bg-primary"> <div class="container"> - <a class="navbar-brand" href="{{ url('/') }}"> + <a class="navbar-brand font-weight-bold text-white" href="{{ url('/') }}"> {{ config('app.name', 'Laravel') }} </a> <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="{{ __('Toggle navigation') }}"> @@ -53,7 +53,7 @@ @endif @else <li class="nav-item dropdown"> - <a id="navbarDropdown" class="nav-link dropdown-toggle" href="#" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" v-pre> + <a id="navbarDropdown" class="nav-link dropdown-toggle font-weight-bold text-white" href="#" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" v-pre> {{ Auth::user()->name }} </a> diff --git a/resources/views/project.blade.php b/resources/views/project.blade.php index 1ebf90d3856b22388af59f4f06d2140fae47cd97..bfd0facd6ef71ffadfb71856737397cf7b58d9ef 100644 --- a/resources/views/project.blade.php +++ b/resources/views/project.blade.php @@ -17,20 +17,27 @@ <span aria-hidden="true">×</span> </button> </div> + @elseif( request()->get('msg') == 3 ) + <div class="alert alert-success alert-dismissible fade show" role="alert"> + Phase updated successfully + <button type="button" class="close" data-dismiss="alert" aria-label="Close"> + <span aria-hidden="true">×</span> + </button> + </div> @endif @endisset <div class="row justify-content-center"> <div class="col-md-8"> <div class="card"> - <div class="card-header font-weight-bold">Software Requirements</div> + <div class="card-header font-weight-bold bg-primary text-white">Software Requirements</div> <div class="card-body"> @if(count($requirements) == 0) There is no requirements @else - <table class="table table-striped"> + <table class="table"> <thead> - <tr> + <tr class="table-active"> <th scope="col">#</th> <th scope="col">Requirement</th> <th scope="col">Score</th> @@ -47,58 +54,70 @@ </tbody> </table> @endif - - <button type="button" class="btn btn-primary float-right" data-toggle="modal" data-target="#exampleModal"> - Add Requirement - </button> + @if($role == 1) + <button type="button" class="btn btn-primary float-right" data-toggle="modal" data-target="#exampleModal"> + Add Requirement + </button> + @endif </div> </div> </div> <div class="col-md-4"> <div class="card"> - <div class="card-header font-weight-bold">Phases</div> + <div class="card-header font-weight-bold bg-primary text-white">Phases</div> <div class="card-body"> <table class="table"> <thead> - <tr> + <tr class="table-active"> <th scope="col">Phase</th> <th scope="col">Status</th> <th scope="col">Action</th> </tr> </thead> <tbody> - <tr class="table-success"> - <th scope="row" class="align-middle">1</th> - <td class="align-middle">Done</td> - <td class="align-middle"><a class="btn btn-primary" href="#" role="button">Open</a></td> - </tr> - <tr class="table-primary"> - <th scope="row" class="align-middle">2</th> - <td class="align-middle">WIP</td> - <td class="align-middle"><a class="btn btn-primary" href="#" role="button">Open</a></td> - </tr> - <tr class="table-secondary"> - <th scope="row" class="align-middle">3</th> - <td class="align-middle">Closed</td> - <td class="align-middle"><a class="btn btn-primary" href="#" role="button">Open</a></td> - </tr> - <tr class="table-secondary"> - <th scope="row" class="align-middle">4</th> - <td class="align-middle">Closed</td> - <td class="align-middle"><a class="btn btn-primary" href="#" role="button">Open</a></td> - </tr> - <tr class="table-secondary"> - <th scope="row" class="align-middle">5</th> - <td class="align-middle">Closed</td> - <td class="align-middle"><a class="btn btn-primary" href="#" role="button">Open</a></td> - </tr> + @for($i = 1; $i <= $maxPhase; $i++) + @if($i < $project->phase) + <tr class="table-success"> + <th scope="row" class="align-middle">{{ $i }}</th> + <td class="align-middle">Done</td> + <td class="align-middle"><a class="btn btn-primary" href="{{ $id }}/phase/{{ $i }}" role="button">Show result</a></td> + </tr> + @elseif($i == $project->phase) + <tr class="table-primary"> + <th scope="row" class="align-middle">{{ $i }}</th> + <td class="align-middle">WIP</td> + <td class="align-middle"><a class="btn btn-primary" href="{{ $id }}/phase/{{ $i }}" role="button">Open</a></td> + </tr> + @else + <tr class=""> + <th scope="row" class="align-middle">{{ $i }}</th> + <td class="align-middle">Closed</td> + <td class="align-middle">-</td> + </tr> + @endif + @endfor </tbody> </table> + @if($project->phase <= $maxPhase) + <form action="/project/updatephase" method="post"> + {{ csrf_field() }} + <input type="hidden" id="projectId" name="projectId" value="{{ $id }}"> + <button type="submit" class="btn btn-success mt-1"> + @if($project->phase == 0) + Open phase 1 + @elseif($project->phase == $maxPhase) + Finish phase {{ $maxPhase }} + @else + Finish phase {{ $project->phase }} and open phase {{ $project->phase + 1 }} + @endif + </button> + </form> + @endif </div> </div> <div class="card mt-4"> - <div class="card-header font-weight-bold">Participants</div> + <div class="card-header font-weight-bold bg-primary text-white">Participants</div> <div class="card-body"> <h5>Moderator:</h5> diff --git a/routes/web.php b/routes/web.php index 419e0adc8d85b8f4b74abf44a7a3e9b36e294636..a2ea0e886a1487c7da4748976cca52508978ab8a 100644 --- a/routes/web.php +++ b/routes/web.php @@ -26,6 +26,7 @@ Route::get('/project/{id}', [ProjectController::class, 'index'])->name('project' // POST Route::post('/project/add', [ProjectController::class, 'add']); Route::post('/project/addmember', [ProjectController::class, 'addMember']); +Route::post('/project/updatephase', [ProjectController::class, 'updatePhase']); Route::post('/requirement/add', [RequirementController::class, 'add']); // Redirect