Commit c5e93ed7 authored by Guilhem's avatar Guilhem
Browse files

feat : the page to manage, add and delete persons from dives

parent eb0e1d4f
Loading
Loading
Loading
Loading
+58 −0
Original line number Diff line number Diff line
<?php

namespace App\Http\Controllers;

use Illuminate\View\View;

use App\Models\DivingSession;

class ModificationDives extends Controller
{
    function index(): View {

        $request = DivingSession::selectRaw('ds_code, ds_date, car_schedule, dl_depth, dl_name')
        ->join('car_diving_location','car_diving_session.DL_ID', '=', 'car_diving_location.DL_ID')
        ->where('car_diving_session.DS_ACTIVE', '=', 1)
        ->get();

        /*
        select ds_code, dl_name, ds_date, CAR_SCHEDULE, dl_depth
        from car_diving_session
        join car_diving_location using(DL_ID)
        where car_diving_session.DS_ACTIVE = 1;*/

        return view('modification_dives', ['dives' => $request]);
    }

    static function removalOfAMemberFromASession(){

    }

    static function modificationMembers(string $ds_code){

        $members = DivingSession::selectRaw('car_diving_session.DS_CODE, car_user.US_ID, car_user.us_name, car_user.us_first_name, car_role_attribution.ROL_CODE, car_user.US_SUB_DATE')
        ->join('car_registration', 'car_diving_session.DS_CODE', '=', 'car_registration.DS_CODE')
        ->join('car_user', 'car_registration.US_ID', '=', 'car_user.US_ID')
        ->join('car_role_attribution', 'car_user.US_ID', '=', 'car_role_attribution.US_ID')
        ->where('car_diving_session.ds_code', '=', $ds_code)
        ->get();

        /*select car_diving_session.DS_CODE, car_user.US_ID, car_user.us_name, car_user.US_FIRST_NAME, car_role_attribution.ROL_CODE
        from car_diving_session
        join car_registration on car_diving_session.DS_CODE = car_registration.DS_CODE
        join car_user on car_registration.US_ID = car_user.US_ID
        join car_role_attribution on car_user.US_ID = car_role_attribution.US_ID
        where car_diving_session.DS_CODE = 'DS2';*/

        $sessionplongee = DivingSession::selectRaw('car_diving_session.DS_CODE, car_diving_session.DS_DATE, car_diving_location.DL_NAME, car_diving_session.CAR_SCHEDULE')
        ->join('car_diving_location', 'car_diving_session.dl_id', '=', 'car_diving_location.dl_id')
        ->where('ds_code', '=', $ds_code)
        ->get();


        return view('modification_members_of_session', [
            'persons' => $members,
            'sessionplongee' => $sessionplongee,
        ]);
    }
}
+40 −0
Original line number Diff line number Diff line
<x-layout>
    <link rel="stylesheet" href="/css/drop-down.css">
    <x-page-title>Modification des plongées</x-page-title>
    <div class="shadow-md max-w-full rounded-lg overflow-hidden border-2">
        <table class="text-sm text-left text-gray-500 w-full">
            <thead class="text-xs text-gray-700 uppercase bg-gray-50">
            <tr>
                <th scope="col" class="px-6 py-3">Prénom</th>
                <th scope="col" class="px-6 py-3">Nom</th>
                <th scope="col" class="px-6 py-3">Profondeur</th>
                <th scope="col" class="px-6 py-3">Lieu</th>
                <th scope="col" class="px-6 py-3">Actions</th>
            </tr>
            </thead>
            <tbody>
            @foreach ($dives as $dive)
                <tr class="odd:bg-white even:bg-gray-50 border-b">
                    <td class="px-6 py-4">{{ $dive['ds_date'] }}</td>
                    <td class="px-6 py-4">{{ $dive['car_schedule'] }}</td>
                    <td class="px-6 py-4">{{ $dive['dl_depth'] }}m</td>
                    <td class="px-6 py-4">{{ $dive['dl_name'] }}</td>
                    <td class="px-8 py-4">
                        <a href='\modificationdives'>
                            <x-button color="#ec9f21" colorHover="hover:bg-green-800">
                                Modifier
                            </x-button>
                        </a>
                        <a href="\modificationdives\members\{{$dive['ds_code']}}">
                            <x-button>
                                Adhérents
                            </x-button>
                        </a>
                    </td>
                </tr>
            @endforeach
            </tbody>
        </table>
    </div>
    <script type="text/javascript" src="/js/drop-down.js"></script>
</x-layout>
+56 −0
Original line number Diff line number Diff line
{{$persons}}
<x-layout>
    <link rel="stylesheet" href="/css/drop-down.css">
    <x-page-title>Modification de la plongée du {{$sessionplongee[0]['DS_DATE']}}, à {{$sessionplongee[0]['DL_NAME']}}, {{$sessionplongee[0]['CAR_SCHEDULE']}}</x-page-title>
    <div class="shadow-md max-w-full rounded-lg overflow-hidden border-2">
        <table class="text-sm text-left text-gray-500 w-full">
            <thead class="text-xs text-gray-700 uppercase bg-gray-50">
            <tr>
                <th scope="col" class="px-6 py-4">Prénom</th>
                <th scope="col" class="px-6 py-4">Nom</th>
                <th scope="col" class="px-6 py-4">Rôle</th>
                <th scope="col" class="px-6 py-4">Date d'inscription</th>
            </tr>
            </thead>
            <tbody>
                
            @foreach ($persons as $person)
                <tr class="odd:bg-white even:bg-gray-50 border-b">
                    <td class="px-6 py-4">{{ $person['us_name'] }}</td>
                    <td class="px-6 py-4">{{ $person['us_first_name'] }}</td>
                    <td class="px-6 py-4">
                    @if($person['ROL_CODE'] == 'DIV')
                        Plongeur
                    @elseif($person['ROL_CODE'] == 'DIR')
                        Directeur
                    @elseif($person['ROL_CODE'] == 'PIL')
                        Pilote
                    @elseif($person['ROL_CODE'] == 'SEC')
                        Sécurité de surface
                    @endif
                    </td>
                    <td class="px-6 py-4">{{$person['US_SUB_DATE']}}</td>
                    <td class="px-6 py-4">
                        <a href='/modificationdives/members/{{$sessionplongee[0]['DS_CODE']}}' method="POST">
                            <x-button color="bg-red-500" colorHover="hover:bg-red-600">
                                supprimer
                            </x-button>
                        </a>
                    </td>
                </tr>
            @endforeach
                <tr class="odd:bg-white even:bg-gray-50 border-b">
                    
                </tr>
            </tbody>
        </table>
    </div>
    <div class="mt-3 shadow-md max-w-fit w-1/6 mx-left rounded-lg overflow-hidden border-2">
        <a href='/modificationdives/members/{{$sessionplongee[0]['DS_CODE']}}'>
            <x-button color="red" colorHover="hover:bg-green-800">
                Ajouter un adhérent
            </x-button>
        </a>
    </div>
    <script type="text/javascript" src="/js/drop-down.js"></script>
</x-layout>
+12 −0
Original line number Diff line number Diff line
@@ -8,6 +8,7 @@
use App\Http\Controllers\DiveSessionCreation;
use App\Http\Controllers\DiveSessionUpdate;
use App\Http\Controllers\AuthController;
use App\Http\Controllers\ModificationDives;
use Illuminate\Support\Facades\Route;
use Illuminate\Http\Request;
/*
@@ -99,3 +100,14 @@
Route::get('/sessions', [DiversBySession::class,'getAllSessions']);

Route::get('/session/{ds_code}', [DiversBySession::class,'getDiversBySession']);

Route::get('/modificationdives', [ModificationDives::class, 'index']);

Route::get('modificationdives/members/{ds_code}', function($ds_code){
    
    return ModificationDives::modificationMembers($ds_code);
});

Route::post('modificationdives/members/{ds_code}/deletion', function($ds_code, Request $request){

});
 No newline at end of file