Commit a91ad784 authored by Guilhem's avatar Guilhem
Browse files

Merge branch 'modification-plongee-bug-fix'

parents a61ebb00 675140d3
Loading
Loading
Loading
Loading
+17 −5
Original line number Diff line number Diff line
@@ -4,6 +4,7 @@
use App\Models\User;
use App\Models\DivingSession;
use App\Models\Registration;
use App\Models\Prerogative;
use App\Http\Controllers\ModificationDives;
use Illuminate\View\View;

@@ -12,14 +13,15 @@

class AdherentController extends Controller
{
    static function index($ds_code, $level): View
    static function index($ds_code, $pre_code): View
    {

        $adherents = User::selectRaw('US_FIRST_NAME,US_NAME,US_LICENCE_ID, CAR_USER.US_ID')
        $adherents = User::selectRaw('US_FIRST_NAME,US_NAME,US_LICENCE_ID, CAR_USER.US_ID, PRE_MAX_DEPTH')
        ->join('CAR_PREROGATIVE','CAR_PREROGATIVE.PRE_CODE','=','CAR_USER.PRE_CODE')
        ->where('CAR_PREROGATIVE.PRE_LEVEl','>=',$level)
        ->where('PRE_MAX_DEPTH', '>=', AdherentController::getMaxDepthByPrerogativeCode($pre_code))
        ->get();


        $sessionplongee = DivingSession::selectRaw('CAR_DIVING_SESSION.DS_CODE, CAR_DIVING_SESSION.DS_DATE, CAR_DIVING_LOCATION.DL_NAME, CAR_DIVING_SESSION.CAR_SCHEDULE, CAR_DIVING_SESSION.DS_LEVEL')
        ->join('CAR_DIVING_LOCATION', 'CAR_DIVING_SESSION.DL_ID', '=', 'CAR_DIVING_LOCATION.DL_ID')
        ->where('ds_code', '=', $ds_code)
@@ -32,7 +34,15 @@ static function index($ds_code, $level): View
        ]);    
    }

    static function getMaxDepthByPrerogativeCode(string $pre_code)
    {
        $query = Prerogative::selectRaw('PRE_MAX_DEPTH')
        ->where('PRE_CODE', '=', $pre_code)
        ->get();

        return $query[0]['PRE_MAX_DEPTH'];

    }



@@ -51,12 +61,14 @@ static function addUserToDive($ds_code, $us_id): View



    static function searchByName($ds_code, $level, Request $request){
    static function searchByName($ds_code, $pre_code, Request $request){

        $nom = $request['nom'];
        $prenom = $request['prenom'];

        $request = User::selectRaw('US_FIRST_NAME,US_NAME,US_LICENCE_ID, CAR_USER.US_ID')
        $request = User::selectRaw('US_FIRST_NAME,US_NAME,US_LICENCE_ID, CAR_USER.US_ID, PRE_MAX_DEPTH')
        ->join('CAR_PREROGATIVE','CAR_PREROGATIVE.PRE_CODE','=','CAR_USER.PRE_CODE')
        ->where('PRE_MAX_DEPTH', '>=', AdherentController::getMaxDepthByPrerogativeCode($pre_code))
        ->where('US_NAME', 'LIKE', "%".$nom."%")
        ->where('US_FIRST_NAME', 'LIKE', "%".$prenom."%")
        ->get();
+22 −6
Original line number Diff line number Diff line
@@ -7,6 +7,7 @@
use App\Models\DivingSession;
use App\Models\Registration;
use App\Models\User;
use League\CommonMark\Extension\Footnote\Event\NumberFootnotesListener;

class ModificationDives extends Controller
{
@@ -34,7 +35,7 @@ static function sessionContainsDirector($ds_code){

    function index(): View {

        $request = DivingSession::selectRaw('DS_CODE, DS_DATE, CAR_SCHEDULE, DL_DEPTH, DL_NAME')
        $request = DivingSession::selectRaw('DS_CODE, DS_DATE, CAR_SCHEDULE, DL_DEPTH, DL_NAME, CAR_DIVING_SESSION.PRE_CODE')
        ->join('CAR_DIVING_LOCATION','CAR_DIVING_SESSION.DL_ID', '=', 'CAR_DIVING_LOCATION.DL_ID')
        ->where('CAR_DIVING_SESSION.DS_ACTIVE', '=', 1)
        ->get();
@@ -46,6 +47,8 @@ function index(): View {
        where car_diving_session.DS_ACTIVE = 1;*/

        


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

@@ -67,7 +70,7 @@ static function removalOfAMemberFromASession(string $ds_code, int $us_id){

    static function modificationMembers(string $ds_code){

        $pilote_temp = DivingSession::selectRaw('US_FIRST_NAME,US_NAME,US_LICENCE_ID, CAR_USER.US_ID')
        $pilote_temp = DivingSession::selectRaw('US_FIRST_NAME,US_NAME,US_LICENCE_ID, CAR_USER.US_ID, CAR_DIVING_SESSION.PRE_CODE')
        ->join('CAR_USER','CAR_DIVING_SESSION.US_ID','=','CAR_USER.US_ID')
        ->where('CAR_DIVING_SESSION.DS_CODE', '=', $ds_code)
        ->get();
@@ -81,7 +84,7 @@ static function modificationMembers(string $ds_code){
            'ROL_LABEL' => "Pilote"
        ];

        $securite_temp = DivingSession::selectRaw('US_FIRST_NAME,US_NAME,US_LICENCE_ID, CAR_USER.US_ID')
        $securite_temp = DivingSession::selectRaw('US_FIRST_NAME,US_NAME,US_LICENCE_ID, CAR_USER.US_ID, CAR_DIVING_SESSION.PRE_CODE')
        ->join('CAR_USER','CAR_DIVING_SESSION.US_ID_CAR_SECURE','=','CAR_USER.US_ID')
        ->where('CAR_DIVING_SESSION.DS_CODE', '=', $ds_code)
        ->get();
@@ -94,7 +97,7 @@ static function modificationMembers(string $ds_code){
            'ROL_LABEL' => "Sécurité de surface"
        ];

        $directeur_temp = DivingSession::selectRaw('US_FIRST_NAME,US_NAME,US_LICENCE_ID, CAR_USER.US_ID')
        $directeur_temp = DivingSession::selectRaw('US_FIRST_NAME,US_NAME,US_LICENCE_ID, CAR_USER.US_ID, CAR_DIVING_SESSION.PRE_CODE')
        ->join('CAR_USER','CAR_DIVING_SESSION.US_ID_CAR_DIRECT','=','CAR_USER.US_ID')
        ->where('CAR_DIVING_SESSION.DS_CODE', '=', $ds_code)
        ->get();
@@ -125,18 +128,31 @@ static function modificationMembers(string $ds_code){
            array_push($adherents, $plongeur);
        }

        $sessionplongee = DivingSession::selectRaw('CAR_DIVING_SESSION.DS_CODE, CAR_DIVING_SESSION.DS_DATE, CAR_DIVING_LOCATION.DL_NAME, CAR_DIVING_SESSION.CAR_SCHEDULE, CAR_DIVING_SESSION.DS_LEVEL')
        $sessionplongee = DivingSession::selectRaw('CAR_DIVING_SESSION.DS_CODE, CAR_DIVING_SESSION.DS_DATE, CAR_DIVING_LOCATION.DL_NAME, CAR_DIVING_SESSION.CAR_SCHEDULE, CAR_DIVING_SESSION.DS_LEVEL, CAR_DIVING_SESSION.PRE_CODE')
        ->join('CAR_DIVING_LOCATION', 'CAR_DIVING_SESSION.DL_ID', '=', 'CAR_DIVING_LOCATION.DL_ID')
        ->where('DS_CODE', '=', $ds_code)
        ->get();



        $numberOfSubscribedPeople = DivingSession::selectRaw('DS_MAX_DIVERS, DS_DIVERS_COUNT')
        ->where('DS_CODE', '=', $ds_code)
        ->get();

        $full = false;

        if(!($numberOfSubscribedPeople[0]['DS_MAX_DIVERS'] == null)){
            $full = $numberOfSubscribedPeople[0]['DS_MAX_DIVERS'] <= $numberOfSubscribedPeople[0]['DS_DIVERS_COUNT'];
        }


        return view('modification_members_of_session', [
            'persons' => $adherents,
            'sessionplongee' => $sessionplongee[0],
            'directeurpresent' => ModificationDives::sessionContainsDirector($ds_code),
            'pilotepresent' => ModificationDives::sessionContainsPilot($ds_code),
            'securitepresent' => ModificationDives::sessionContainsSecurity($ds_code)
            'securitepresent' => ModificationDives::sessionContainsSecurity($ds_code),
            'full' => $full
        ]);    
    }
}
+9 −17
Original line number Diff line number Diff line
<button class="
<button
    @if (isset($disabledVal) && $disabledVal == "true") disabled @endif
    class="
    m-1 
    @if (isset($color) && $color != "") 
        {{ $color }} 
    @if (isset($color) && $color != '') {{ $color }} 
    @else 
        bg-gray-400 
    @endif 
    @if (isset($colorHover) && $colorHover != "") 
        {{ $colorHover }} 
    @else hover:bg-gray-500 
    @endif 
        bg-gray-400 @endif 
    @if (isset($colorHover) && $colorHover != '') {{ $colorHover }} 
    @else hover:bg-gray-500 @endif 
    text-gray-800 font-bold py-2 px-4 rounded inline-flex items-center
    @if (isset($diveId) && $diveId!="")
    diveDropdownButton
    @endif
    @if (isset($diveId) && $diveId != '') diveDropdownButton @endif
"
@if (isset($diveId) && $diveId!="")
    id = "{{$diveId}}"
@endif

>
    @if (isset($diveId) && $diveId != '') id = "{{ $diveId }}" @endif>
    {{ $slot }}
</button>
+12 −2
Original line number Diff line number Diff line
@@ -47,13 +47,23 @@
    </div>
    <div>
    </div>
    @if($full == false)
        <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['DS_CODE']}}/ajoutadherent/{{$sessionplongee['DS_LEVEL']}}" class="text-blue-500 underline">
            <a href="/modificationdives/members/{{$sessionplongee['DS_CODE']}}/ajoutadherent/{{$sessionplongee['PRE_CODE']}}" class="text-blue-500 underline">
                <x-button color="red" colorHover="hover:bg-green-800">
                    Ajouter un plongeur
                </x-button>
            </a>
        </div>

    @endif
    @if($full == true)
        <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['DS_CODE']}}/ajoutadherent/{{$sessionplongee['PRE_CODE']}}" class="text-blue-500 underline">
                <x-button disabledVal="true" color="bg-gray-400" colorHover="hover:bg-gray-400">
                    Ajouter un plongeur
                </x-button>
            </a>
        </div>
    @endif
    <script type="text/javascript" src="/js/drop-down.js"></script>
</x-layout>
+5 −121
Original line number Diff line number Diff line
@@ -25,6 +25,8 @@
use App\Http\Controllers\DiveCreation;
use App\Http\Controllers\SecuritySheets\PreviewStrategy;
use App\Http\Controllers\SecuritySheets\SecuritySheetController;
use App\Http\Controllers\AdherentController;
use App\Http\Controllers\ModificationDives;

/*
|--------------------------------------------------------------------------
@@ -190,47 +192,6 @@
 */
Route::get('/alldivings?{afterthe}&{beforethe}', [DivingNumberController::class, 'filteredSearch({afterthe}, {beforethe})']);

/**
 * Leads to a page that allows to manage every member and change their roles.
 * Only accessible to the diving section manager.
 */
Route::middleware('App\Http\Middleware\RightChecker')
    ->get('manage/members', [ManageAdherentController::class, 'index'])
    ->name('manage_members');

/**
 * Updates every user's roles.
 * Only accessible to the diving section manager.
 */
Route::middleware('App\Http\Middleware\RightChecker')
    ->post('manage/members/roles', [ManageAdherentController::class, 'update'])
    ->name('updateMembersRole');

Route::middleware('App\Http\Middleware\RightChecker')
    ->get('dive/{id}', [DivesList::class, 'show'])
    ->name('dives_show');

Route::middleware('App\Http\Middleware\RightChecker')
    ->get('manage/dives', [DivesList::class, 'showManagementList'])
->name('manage_dives_dir');

/**
 * List all the diving sessions of the user, as well as its remaining sessions for the current year.
 */
Route::get('/divings', [DivingNumberController::class, 'index'])->name('divings');

/**
 * Leads to a page that shows each divers and their number and allows to select a period.
 */
Route::get('/alldivings', [DivingNumberController::class, 'allIndex'])->name('alldivings');

/**
 * Leads to a page that show each divers and their number of diving sessions for the selected period (not set by default).
 * @param $afterthe the first day of the filtering period (if unset, the page will show divings until the "before" date)
 * @param $beforethe the last day of the filtering period (if unset, the page will show divings starting from the "after" date)
 */
Route::get('/alldivings?{afterthe}&{beforethe}', [DivingNumberController::class, 'filteredSearch({afterthe}, {beforethe})']);

/**
 * Leads to a page that allows to manage every member and change their roles.
 * Only accessible to the diving section manager.
@@ -254,7 +215,6 @@
Route::middleware('App\Http\Middleware\rightChecker')
    ->get('manage/dives', [DivesList::class, 'showManagementList'])
->name('manage_dives_dir');

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

Route::get('modificationdives/members/{ds_code}', function($ds_code){
@@ -269,88 +229,12 @@



Route::get('/modificationdives/members/{ds_code}/ajoutadherent/{level}', function($ds_code, $level){
    return AdherentController::index($ds_code, $level);
Route::get('/modificationdives/members/{ds_code}/ajoutadherent/{pre_code}', function($ds_code, $pre_code){
    return AdherentController::index($ds_code, $pre_code);
});

Route::post('/modificationdives/members/{ds_code}/ajoutadherent/{us_id}', function($ds_code, $us_id){
    return AdherentController::addUserToDive($ds_code, $us_id);
});

Route::get('/modificationdives/members/{ds_code}/ajoutadherent/{level}', [AdherentController::class, 'searchByName']);

/** Unsuscribe the user from a diving session
 */
Route::middleware('App\Http\Middleware\rightChecker')
    ->get('/unsubscribe/{ds_code}', [DivingUnsubscribeController::class, 'index']);

/**
 * List all the diving sessions of the user, as well as its remaining sessions for the current year.
 */
Route::get('/divings', [DivingNumberController::class, 'index'])->name('divings');

/**
 * Leads to a page that shows each divers and their number and allows to select a period.
 */
Route::get('/alldivings', [DivingNumberController::class, 'allIndex'])->name('alldivings');

/**
 * Leads to a page that show each divers and their number of diving sessions for the selected period (not set by default).
 * @param $afterthe the first day of the filtering period (if unset, the page will show divings until the "before" date)
 * @param $beforethe the last day of the filtering period (if unset, the page will show divings starting from the "after" date)
 */
Route::get('/alldivings?{afterthe}&{beforethe}', [DivingNumberController::class, 'filteredSearch({afterthe}, {beforethe})']);

/**
 * Leads to a page that allows to manage every member and change their roles.
 * Only accessible to the diving section manager.
 */
Route::middleware('App\Http\Middleware\rightChecker')
    ->get('manage/members', [ManageAdherentController::class, 'index'])
    ->name('manage_members');

/**
 * Updates every user's roles.
 * Only accessible to the diving section manager.
 */
Route::middleware('App\Http\Middleware\rightChecker')
    ->post('manage/members/roles', [ManageAdherentController::class, 'update'])
    ->name('updateMembersRole');

Route::middleware('App\Http\Middleware\rightChecker')
    ->get('dive/{id}', [DivesList::class, 'show'])
    ->name('dives_show');

Route::middleware('App\Http\Middleware\rightChecker')
    ->get('manage/dives', [DivesList::class, 'showManagementList'])
->name('manage_dives_dir');

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}/deletiondiver/{us_id}', function($ds_code, $us_id){
     return ModificationDives::removalOfAMemberFromASession($ds_code, $us_id);
});



Route::get('/modificationdives/members/{ds_code}/ajoutadherent/{level}', function($ds_code, $level){
    return AdherentController::index($ds_code, $level);
});

Route::post('/modificationdives/members/{ds_code}/ajoutadherent/{us_id}', function($ds_code, $us_id){
    return AdherentController::addUserToDive($ds_code, $us_id);
});

Route::get('/modificationdives/members/{ds_code}/ajoutadherent/{level}', [AdherentController::class, 'searchByName'])
    ->name('manage_dives_dir');

Route::middleware('App\Http\Middleware\RightChecker')
    ->get('dodo', function () {
        return view('dodo');
    });
Route::get('/modificationdives/members/{ds_code}/ajoutadherent/{pre_code}', [AdherentController::class, 'searchByName']);