Commit 36b9a3f4 authored by Victor Friboulet's avatar Victor Friboulet
Browse files
parents aa6a9421 045e3e88
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -40,7 +40,7 @@ public function register()
    {
        $this->renderable(function(QueryException $queryException, Request $request){
            if ($queryException->getCode()==45000)
            return response()->view('erreur-page',['message'=>$queryException->getMessage()]);
            return response()->view('error-page',['message'=>$queryException->getMessage()]);
        });
        $this->reportable(function (Throwable $e) {
            //
+76 −0
Original line number Diff line number Diff line
<?php

namespace App\Http\Controllers;
use App\Models\User;
use App\Models\DivingSession;
use App\Models\Registration;
use App\Http\Controllers\ModificationDives;
use Illuminate\View\View;


use Illuminate\Http\Request;

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

        $adherents = User::selectRaw('US_FIRST_NAME,US_NAME,US_LICENCE_ID, CAR_USER.US_ID')
        ->join('CAR_PREROGATIVE','CAR_PREROGATIVE.PRE_CODE','=','CAR_USER.PRE_CODE')
        ->where('CAR_PREROGATIVE.PRE_LEVEl','>=',$level)
        ->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)
        ->get();


        return view('adherents', [
            'adherents' => $adherents,
            'sessionplongee' => $sessionplongee[0],
            ]);    
    }





    static function addUserToDive($ds_code, $us_id): View
    {

        $query = Registration::insert([
            'US_ID' => $us_id,
            'DS_CODE' => $ds_code,
            'REG_ACTIVE' => 1
        ]);

        return ModificationDives::modificationMembers($ds_code);

    }



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

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

        $request = User::selectRaw('US_FIRST_NAME,US_NAME,US_LICENCE_ID, CAR_USER.US_ID')
        ->where('US_NAME', 'LIKE', "%".$nom."%")
        ->where('US_FIRST_NAME', 'LIKE', "%".$prenom."%")
        ->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)
        ->get();

        return view('adherents', [
            'adherents' => $request,
            'sessionplongee' => $sessionplongee[0],
        ]); 

    }

}
+3 −0
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@ class DiveSessionCreation extends Controller
    public static function add($request)
    {
        $dv = new DivingSession();

        $dv->DS_CODE = 'DS'.sizeof(DivingSession::all())+1;
        $dv->US_ID = $request->pilot;
        $dv->DL_ID = $request->location;
@@ -27,6 +28,8 @@ public static function add($request)
        $dv->DS_MAX_DEPTH = DivingLocation::find($request->location)->DL_DEPTH;
        $dv->DS_ACTIVE = 1;
        $dv->DS_MAX_DIVERS = $request->max;
        $dv->DS_MIN_DIVERS = $request->min;

        if(intval($dv->DS_MAX_DIVERS) > Boat::find($request->boat)->BO_NUMBER_OF_SEATS)
        {
            return "Le nombre de plongeurs est supérieur au nombre de places du bateau";
+2 −0
Original line number Diff line number Diff line
@@ -17,6 +17,8 @@ public static function update($request, $id)
        $dv->BO_ID = $request->boat;
        $dv->US_ID_CAR_SECURE = $request->security;
        $dv->US_ID_CAR_DIRECT = $request->manager;
        $dv->DS_DATE = $request->day;
        $dv->CAR_SCHEDULE = $request->hour;
        $dv->DS_MAX_DEPTH = $request->maxDepth;
        $dv->DS_ACTIVE = 1;
        $dv->DS_MAX_DIVERS = $request->max;
+8 −1
Original line number Diff line number Diff line
@@ -3,11 +3,18 @@
namespace App\Http\Controllers;

use App\Models\DivingSession;
use App\Models\User;

class DivesAPI extends Controller
{
    function getDivers($diveID): array
    {
        return DivingSession::find($diveID)->getParticipants();
        $participants = User::select('*')
            ->join('CAR_REGISTRATION', 'CAR_REGISTRATION.US_ID', '=', 'CAR_USER.US_ID')
            ->join('CAR_DIVING_SESSION', 'CAR_DIVING_SESSION.DS_CODE', '=', 'CAR_REGISTRATION.DS_CODE')
            ->join('CAR_DIVING_LOCATION', 'CAR_DIVING_LOCATION.DL_ID', '=', 'CAR_DIVING_SESSION.DL_ID')
            ->where('CAR_REGISTRATION.DS_CODE', $diveID);
        $participants = $participants->get()->toArray();
        return $participants;
    }
}
Loading