Commit 4ca37861 authored by Julien Sailly's avatar Julien Sailly
Browse files

Merge avec numberDives

parents afd7c593 72014658
Loading
Loading
Loading
Loading
+44 −0
Original line number Diff line number Diff line
<?php

namespace App\Http\Controllers;

use App\Models\RoleAttribution;
use App\Models\User;
use Illuminate\Http\Request;

class ManageAdherentController extends Controller {
    function index() {
        $users = User::select('car_user.US_ID', 'car_user.US_FIRST_NAME', 'car_user.US_NAME', 'car_role_attribution.ROL_CODE')->leftjoin('car_role_attribution', 'car_role_attribution.US_ID', '=', 'car_user.US_ID')->orderBy('car_user.US_ID')->get();

        $user_role = array();
        $usersInfos = array();

        foreach ($users as $user) {
            $usersInfos[$user->US_ID] = [$user->US_ID, $user->US_FIRST_NAME, $user->US_NAME];
            if (!array_key_exists($user->US_ID, $user_role)){
                $user_role[$user->US_ID] = array();
            }
            $user_role[$user->US_ID][] = $user->ROL_CODE;
        }
        $users = [$usersInfos, $user_role];

        return view('manageAdherent', ['users' => $users]);
    }

    function update(Request $request) {
        $uptUser = $request->all();
        RoleAttribution::truncate();
        foreach ($uptUser as $key => $value) {
            if ($key != '_token') {
                $roleAttribution = new RoleAttribution();
                $roleAttribution->US_ID = explode("_", $key)[1];
                $roleAttribution->ROL_CODE = $value;
                $roleAttribution->save();
            }
        }
        return redirect()->route('manage_members');
    }


}
+33 −11
Original line number Diff line number Diff line
@@ -5,17 +5,25 @@
        </a>
        <div class="flex items-center md:order-2 space-x-3 md:space-x-0 rtl:space-x-reverse">
            @if (!session()->has('user'))
                <a href="{{ route('login') }}" class="text-sm text-white">
                    <x-button color="bg-blue-700" colorHover="hover:bg-[#0C57A6]">
                    <a href="{{ route('login') }}" class="text-sm text-white">Se connecter</a>
                        Se connecter
                    </x-button>
                </a>
            @else
                <button type="button" class="flex text-sm bg-blue-500 rounded-full md:me-0 focus:ring-4 focus:ring-blue-700" id="user-menu-button" aria-expanded="false" data-dropdown-toggle="user-dropdown" data-dropdown-placement="bottom">
                    <span class="w-8 h-8 rounded-full py-1 font-bold text-white">{{ substr(session('user')->US_FIRST_NAME, 0, 1) . substr(session('user')->US_NAME, 0, 1) }}</span>
                <button type="button"
                        class="flex text-sm bg-blue-500 rounded-full md:me-0 focus:ring-4 focus:ring-blue-700"
                        id="user-menu-button" aria-expanded="false" data-dropdown-toggle="user-dropdown"
                        data-dropdown-placement="bottom">
                    <span
                        class="w-8 h-8 rounded-full py-1 font-bold text-white">{{ substr(session('user')->US_FIRST_NAME, 0, 1) . substr(session('user')->US_NAME, 0, 1) }}</span>
                </button>
                <!-- Dropdown menu -->
                <div class="z-50 hidden my-4 text-base list-none divide-y rounded-lg shadow bg-blue-700 divide-blue-500" id="user-dropdown">
                <div class="z-50 hidden my-4 text-base list-none divide-y rounded-lg shadow bg-blue-700 divide-blue-500"
                     id="user-dropdown">
                    <div class="px-4 py-3">
                        <span class="block text-sm text-white">{{ session('user')->US_FIRST_NAME . " " . session('user')->US_NAME }}</span>
                        <span
                            class="block text-sm text-white">{{ session('user')->US_FIRST_NAME . " " . session('user')->US_NAME }}</span>
                        <span class="block text-sm truncate text-gray-400">{{ session('user')->US_EMAIL }}</span>
                    </div>
                    <ul class="py-2" aria-labelledby="user-menu-button">
@@ -23,25 +31,39 @@
                             <a  href="{{--{{route('divings')}}--}}#" class="block px-4 py-2 text-sm hover:bg-gray-600 text-gray-200 hover:text-white">Historique de mes plongées</a> 
                        </li>
                        <li>
                            <a href="{{ route('logout') }}" class="block px-4 py-2 text-sm hover:bg-gray-600 text-gray-200 hover:text-white">Se déconnecter</a>
                            <a href="{{ route('logout') }}"
                               class="block px-4 py-2 text-sm hover:bg-gray-600 text-gray-200 hover:text-white">Se
                                déconnecter</a>
                        </li>
                    </ul>
                </div>
            @endif
            <button data-collapse-toggle="navbar-user" type="button" class="inline-flex items-center p-2 w-10 h-10 justify-center text-sm text-gray-500 rounded-lg md:hidden hover:bg-gray-100 focus:outline-none focus:ring-2 focus:ring-gray-200 dark:text-gray-400 dark:hover:bg-[#002550] dark:focus:ring-gray-600" aria-controls="navbar-user" aria-expanded="false">
            <button data-collapse-toggle="navbar-user" type="button"
                    class="inline-flex items-center p-2 w-10 h-10 justify-center text-sm text-gray-500 rounded-lg md:hidden hover:bg-gray-100 focus:outline-none focus:ring-2 focus:ring-gray-200 dark:text-gray-400 dark:hover:bg-[#002550] dark:focus:ring-gray-600"
                    aria-controls="navbar-user" aria-expanded="false">
                <span class="sr-only">Open main menu</span>
                <svg class="w-5 h-5" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 17 14">
                    <path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M1 1h15M1 7h15M1 13h15"/>
                <svg class="w-5 h-5" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" fill="none"
                     viewBox="0 0 17 14">
                    <path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
                          d="M1 1h15M1 7h15M1 13h15"/>
                </svg>
            </button>
        </div>
        <div class="items-center justify-between hidden w-full md:flex md:w-auto md:order-1" id="navbar-user">
            <ul class="flex flex-col font-medium p-4 md:p-0 mt-4 rounded-lg md:space-x-8 rtl:space-x-reverse md:flex-row md:mt-0 md:border-0 bg-[#063E7B] md:bg-[#002550]">
                <li class="py-2 @if(request()->routeIs('homepage')) md:border-b md:border-b-[#FFBE55] border-b-0 @endif">
                    <a href="{{ route('homepage') }}" @if(request()->routeIs('homepage')) class="block py-2 px-3 text-white bg-blue-700 rounded md:bg-transparent md:text-blue-700 md:p-0 md:dark:text-blue-500" aria-current="page" @else class="block py-2 px-3 rounded hover:bg-blue-700 md:p-0 text-white md:hover:text-blue-500 hover:text-white md:hover:bg-transparent border-gray-700" @endif>Page d'accueil</a>
                    <a href="{{ route('homepage') }}"
                       @if(request()->routeIs('homepage')) class="block py-2 px-3 text-white bg-blue-700 rounded md:bg-transparent md:text-blue-700 md:p-0 md:dark:text-blue-500"
                       aria-current="page"
                       @else class="block py-2 px-3 rounded hover:bg-blue-700 md:p-0 text-white md:hover:text-blue-500 hover:text-white md:hover:bg-transparent border-gray-700" @endif>Page
                        d'accueil</a>
                </li>
                <li class="py-2 @if(request()->routeIs('dives'))border-b border-b-[#FFBE55]@endif">
                    <a href="{{ route('dives') }}" @if(request()->routeIs('dives')) class="block py-2 px-3 text-white bg-blue-700 rounded md:bg-transparent md:text-blue-700 md:p-0 md:dark:text-blue-500" aria-current="page" @else class="block py-2 px-3 rounded hover:bg-blue-700 md:p-0 text-white md:hover:text-blue-500 hover:text-white md:hover:bg-transparent border-gray-700" @endif>Inscription aux plongées</a>
                    <a href="{{ route('dives') }}"
                       @if(request()->routeIs('dives')) class="block py-2 px-3 text-white bg-blue-700 rounded md:bg-transparent md:text-blue-700 md:p-0 md:dark:text-blue-500"
                       aria-current="page"
                       @else class="block py-2 px-3 rounded hover:bg-blue-700 md:p-0 text-white md:hover:text-blue-500 hover:text-white md:hover:bg-transparent border-gray-700" @endif>Inscription
                        aux plongées</a>
                </li>
            </ul>
        </div>
+7 −2
Original line number Diff line number Diff line
@@ -4,13 +4,18 @@
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <script src="https://cdn.tailwindcss.com"></script>
    <style>* {box-sizing: border-box}</style>
    <style>* {
            box-sizing: border-box
        }</style>
</head>
<body class="min-h-[100vh] flex justify-between flex-col">
<div>
    <x-header/>
  <main class="mx-auto max-w-[1440px] w-full p-4 min-h-[80vh]">
    <main class="mx-auto max-w-[1440px] w-full p-4">
        {{ $slot }}
    </main>
</div>

<x-footer/>
</body>
</html>
+32 −11
Original line number Diff line number Diff line
@@ -13,36 +13,57 @@
        </div>
    @else
        <x-page-title>Tableau de bord</x-page-title>
        <h2 class="text-2xl font-semibold text-gray-800">Bonjour {{ session('user')->US_FIRST_NAME . " " . session('user')->US_NAME . "," }}</h2>
        <h2 class="text-2xl font-semibold text-gray-800">Bonjour
            {{ session('user')->US_FIRST_NAME . ' ' . session('user')->US_NAME . ',' }}</h2>
        <div class="flex flex-row justify-evenly mt-10">
            <x-square-button bgColor="bg-[#e37373]" textColor="text-black" textSubtitle="Mes plongées" link="{{ route('divings')}}">
                <svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="w-12 h-12">
                    <path stroke-linecap="round" stroke-linejoin="round" d="M8.25 6.75h12M8.25 12h12m-12 5.25h12M3.75 6.75h.007v.008H3.75V6.75Zm.375 0a.375.375 0 1 1-.75 0 .375.375 0 0 1 .75 0ZM3.75 12h.007v.008H3.75V12Zm.375 0a.375.375 0 1 1-.75 0 .375.375 0 0 1 .75 0Zm-.375 5.25h.007v.008H3.75v-.008Zm.375 0a.375.375 0 1 1-.75 0 .375.375 0 0 1 .75 0Z" />
                </svg>
            </x-square-button>
            <x-square-button bgColor="bg-[#87c868]" textColor="text-black" textSubtitle="S'inscrire à une plongée" link="{{ route('dives') }}">
            <x-square-button bgColor="bg-[#87c868]" textColor="text-black" textSubtitle="S'inscrire à une plongée"
                link="{{ route('dives') }}">
                <svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5"
                    stroke="currentColor" class="w-12 h-12">
                    <path stroke-linecap="round" stroke-linejoin="round"
                        d="M11.35 3.836c-.065.21-.1.433-.1.664 0 .414.336.75.75.75h4.5a.75.75 0 0 0 .75-.75 2.25 2.25 0 0 0-.1-.664m-5.8 0A2.251 2.251 0 0 1 13.5 2.25H15c1.012 0 1.867.668 2.15 1.586m-5.8 0c-.376.023-.75.05-1.124.08C9.095 4.01 8.25 4.973 8.25 6.108V8.25m8.9-4.414c.376.023.75.05 1.124.08 1.131.094 1.976 1.057 1.976 2.192V16.5A2.25 2.25 0 0 1 18 18.75h-2.25m-7.5-10.5H4.875c-.621 0-1.125.504-1.125 1.125v11.25c0 .621.504 1.125 1.125 1.125h9.75c.621 0 1.125-.504 1.125-1.125V18.75m-7.5-10.5h6.375c.621 0 1.125.504 1.125 1.125v9.375m-8.25-3 1.5 1.5 3-3.75" />
                </svg>
            </x-square-button>
            @if (array_search('DIR', $highestRole))
                <x-square-button bgColor="bg-[#909aef]" textColor="text-black" textSubtitle="Gérer mes plongées (directeur)"
                    link="#">
                    <svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="w-12 h-12">
                    <path stroke-linecap="round" stroke-linejoin="round" d="M11.35 3.836c-.065.21-.1.433-.1.664 0 .414.336.75.75.75h4.5a.75.75 0 0 0 .75-.75 2.25 2.25 0 0 0-.1-.664m-5.8 0A2.251 2.251 0 0 1 13.5 2.25H15c1.012 0 1.867.668 2.15 1.586m-5.8 0c-.376.023-.75.05-1.124.08C9.095 4.01 8.25 4.973 8.25 6.108V8.25m8.9-4.414c.376.023.75.05 1.124.08 1.131.094 1.976 1.057 1.976 2.192V16.5A2.25 2.25 0 0 1 18 18.75h-2.25m-7.5-10.5H4.875c-.621 0-1.125.504-1.125 1.125v11.25c0 .621.504 1.125 1.125 1.125h9.75c.621 0 1.125-.504 1.125-1.125V18.75m-7.5-10.5h6.375c.621 0 1.125.504 1.125 1.125v9.375m-8.25-3 1.5 1.5 3-3.75" />
                        <path stroke-linecap="round" stroke-linejoin="round" d="M4.26 10.147a60.438 60.438 0 0 0-.491 6.347A48.62 48.62 0 0 1 12 20.904a48.62 48.62 0 0 1 8.232-4.41 60.46 60.46 0 0 0-.491-6.347m-15.482 0a50.636 50.636 0 0 0-2.658-.813A59.906 59.906 0 0 1 12 3.493a59.903 59.903 0 0 1 10.399 5.84c-.896.248-1.783.52-2.658.814m-15.482 0A50.717 50.717 0 0 1 12 13.489a50.702 50.702 0 0 1 7.74-3.342M6.75 15a.75.75 0 1 0 0-1.5.75.75 0 0 0 0 1.5Zm0 0v-3.675A55.378 55.378 0 0 1 12 8.443m-7.007 11.55A5.981 5.981 0 0 0 6.75 15.75v-1.5" />
                      </svg>
                      
                </x-square-button>
            @endif
        </div>
        @if (array_search('RES', $highestRole))
            <hr class="mt-8 mb-4">
            <h2 class="text-2xl font-semibold text-gray-800">Responsable</h2>
            <div class="flex flex-row justify-evenly mt-6 mb-14">
                <x-square-button bgColor="bg-[#909aef]" textColor="text-black" textSubtitle="Gérer des adhérents" link="#">
                    <svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="w-12 h-12">
                        <path stroke-linecap="round" stroke-linejoin="round" d="M18 18.72a9.094 9.094 0 0 0 3.741-.479 3 3 0 0 0-4.682-2.72m.94 3.198.001.031c0 .225-.012.447-.037.666A11.944 11.944 0 0 1 12 21c-2.17 0-4.207-.576-5.963-1.584A6.062 6.062 0 0 1 6 18.719m12 0a5.971 5.971 0 0 0-.941-3.197m0 0A5.995 5.995 0 0 0 12 12.75a5.995 5.995 0 0 0-5.058 2.772m0 0a3 3 0 0 0-4.681 2.72 8.986 8.986 0 0 0 3.74.477m.94-3.197a5.971 5.971 0 0 0-.94 3.197M15 6.75a3 3 0 1 1-6 0 3 3 0 0 1 6 0Zm6 3a2.25 2.25 0 1 1-4.5 0 2.25 2.25 0 0 1 4.5 0Zm-13.5 0a2.25 2.25 0 1 1-4.5 0 2.25 2.25 0 0 1 4.5 0Z" />
                <x-square-button bgColor="bg-[#909aef]" textColor="text-black" textSubtitle="Gérer des adhérents"
                    link="{{ route('manage_members') }}">
                    <svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5"
                        stroke="currentColor" class="w-12 h-12">
                        <path stroke-linecap="round" stroke-linejoin="round"
                            d="M18 18.72a9.094 9.094 0 0 0 3.741-.479 3 3 0 0 0-4.682-2.72m.94 3.198.001.031c0 .225-.012.447-.037.666A11.944 11.944 0 0 1 12 21c-2.17 0-4.207-.576-5.963-1.584A6.062 6.062 0 0 1 6 18.719m12 0a5.971 5.971 0 0 0-.941-3.197m0 0A5.995 5.995 0 0 0 12 12.75a5.995 5.995 0 0 0-5.058 2.772m0 0a3 3 0 0 0-4.681 2.72 8.986 8.986 0 0 0 3.74.477m.94-3.197a5.971 5.971 0 0 0-.94 3.197M15 6.75a3 3 0 1 1-6 0 3 3 0 0 1 6 0Zm6 3a2.25 2.25 0 1 1-4.5 0 2.25 2.25 0 0 1 4.5 0Zm-13.5 0a2.25 2.25 0 1 1-4.5 0 2.25 2.25 0 0 1 4.5 0Z" />
                    </svg>
                </x-square-button>
                <x-square-button bgColor="bg-[#ffba35]" textColor="text-black" textSubtitle="Créer une plongée" link="{{ route('create_dive') }}">
                    <svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="w-12 h-12">
                <x-square-button bgColor="bg-[#ffba35]" textColor="text-black" textSubtitle="Créer une plongée"
                    link="{{ route('create_dive') }}">
                    <svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5"
                        stroke="currentColor" class="w-12 h-12">
                        <path stroke-linecap="round" stroke-linejoin="round" d="M12 4.5v15m7.5-7.5h-15" />
                    </svg>
                </x-square-button>
                <x-square-button bgColor="bg-[#3b82f6]" textColor="text-black" textSubtitle="Gérer des plongées" link="#">
                    <svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="w-12 h-12">
                        <path stroke-linecap="round" stroke-linejoin="round" d="M10.5 6h9.75M10.5 6a1.5 1.5 0 1 1-3 0m3 0a1.5 1.5 0 1 0-3 0M3.75 6H7.5m3 12h9.75m-9.75 0a1.5 1.5 0 0 1-3 0m3 0a1.5 1.5 0 0 0-3 0m-3.75 0H7.5m9-6h3.75m-3.75 0a1.5 1.5 0 0 1-3 0m3 0a1.5 1.5 0 0 0-3 0m-9.75 0h9.75" />
                <x-square-button bgColor="bg-[#3b82f6]" textColor="text-black" textSubtitle="Gérer des plongées"
                    link="#">
                    <svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5"
                        stroke="currentColor" class="w-12 h-12">
                        <path stroke-linecap="round" stroke-linejoin="round"
                            d="M10.5 6h9.75M10.5 6a1.5 1.5 0 1 1-3 0m3 0a1.5 1.5 0 1 0-3 0M3.75 6H7.5m3 12h9.75m-9.75 0a1.5 1.5 0 0 1-3 0m3 0a1.5 1.5 0 0 0-3 0m-3.75 0H7.5m9-6h3.75m-3.75 0a1.5 1.5 0 0 1-3 0m3 0a1.5 1.5 0 0 0-3 0m-9.75 0h9.75" />
                    </svg>

                </x-square-button>
+52 −0
Original line number Diff line number Diff line
<x-layout>
    <x-page-title>Gestion des adhérents</x-page-title>
    <form action="{{ route('updateMembersRole') }}" method="POST">
        @csrf <!-- {{ csrf_field() }} -->
        <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 NOM</th>
                    <th scope="col" class="px-6 py-3">Plongeur</th>
                    <th scope="col" class="px-6 py-3">Sécurité surface</th>
                    <th scope="col" class="px-6 py-3">Pilote</th>
                    <th scope="col" class="px-6 py-3">Directeur de plongée</th>
                </tr>
                </thead>
                <tbody>
                @foreach ($users[0] as $i => $value)
                    <tr class="odd:bg-white even:bg-gray-50 border-b">
                        <td class="px-6 py-4">{{ $users[0][$i][1] . " " . strtoupper($users[0][$i][2]) }}</td>
                        <td class="px-6 py-4">
                            <input type="checkbox" id="checkbox{{ $users[0][$i][0] }}" name="checkbox_{{ $users[0][$i][0] }}_DIV" value="DIV" @if(array_search('DIV', $users[1][$i]) !== false) checked @endif>
                        </td>
                        <td class="px-6 py-4">
                            <input type="checkbox" id="checkbox{{ $users[0][$i][0] }}" name="checkbox_{{ $users[0][$i][0] }}_SEC" value="SEC" @if(array_search('SEC', $users[1][$i]) !== false) checked @endif>
                        </td>
                        <td class="px-6 py-4">
                            <input type="checkbox" id="checkbox{{ $users[0][$i][0] }}" name="checkbox_{{ $users[0][$i][0] }}_PIL" value="PIL" @if(array_search('PIL', $users[1][$i]) !== false) checked @endif>
                        </td>
                        <td class="px-6 py-4">
                            <input type="checkbox" id="checkbox{{ $users[0][$i][0] }}" name="checkbox_{{ $users[0][$i][0] }}_DIR" value="DIR" @if(array_search('DIR', $users[1][$i]) !== false) checked @endif>
                        </td>
                    </tr>
                @endforeach
                </tbody>
            </table>

        </div>
        <div class="text-right">
            <button type="submit" class="bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded mt-4">
                Valider
            </button>
        </div>
    </form>

    <h2 class="underline">Accéder aux plongées par période :</h2>
    <a href="{{ route('alldivings') }}">
        <button class="bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded mt-4">
            Plongées par période
        </button>
    </a>
</x-layout>
Loading