Commit 90e37fa1 authored by Julien Ait azzouzene's avatar Julien Ait azzouzene
Browse files

🐛 fix: added driver, diver function recognition

parent 2ced9499
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -38,6 +38,7 @@ private function callPdfBuilderView(string $ds_code){

        $director = User::find($dive->US_ID_CAR_DIRECT);
        $surfaceSecurity = User::find($dive->US_ID_CAR_SECURE);
        $driver = User::find($dive->US_ID);

        $location = DivingLocation::find($dive->DL_ID);

@@ -56,6 +57,7 @@ private function callPdfBuilderView(string $ds_code){
            'dive' => $dive,
            'director' => $director,
            'surfaceSecurity' => $surfaceSecurity,
            'driver' => $driver,
            'location' => $location,
            'divingGroups' => $divingGroupsForView
        ]);
+24 −0
Original line number Diff line number Diff line
@@ -41,4 +41,28 @@ public function disable()
        $this->DS_ACTIVE = 0;
        $this->save();
    }

    public function getRoleForUser(User $user){
        if($user->US_ID === $this->US_ID_CAR_DIRECT){
            return "Directeur de plongée";
        }

        if($user->US_ID === $this->US_ID){
            return "Pilote";
        }

        if($user->US_ID === $this->US_ID_CAR_SECURE){
            return "Sécurité de surface";
        }

        if($user->US_TEACHING_LEVEL > 0){
            return "Encadrant";
        }

        if(strpos($user->PRE_CODE, 'GP')){
            return "Guide de palanquée";
        }
        
        return "Plongeur";
    }
}
+11 −14
Original line number Diff line number Diff line
@@ -55,6 +55,10 @@
        <td><strong>Sécurité de surface</strong></td>
        <td>{{$surfaceSecurity->US_FIRST_NAME}} {{$surfaceSecurity->US_NAME}}</td>
    </tr>
    <tr>
        <td><strong>Pilote</strong></td>
        <td>{{$driver->US_FIRST_NAME}} {{$driver->US_NAME}}</td>
    </tr>
    <tr>
        <td><strong>
            Observation
@@ -96,7 +100,7 @@

        <!-- Members table header -->
        <tr class="members-header">
            <td colspan="2"><strong>Nom Prénom</strong></td>
            <td colspan="2"><strong>Prénom Nom</strong></td>
            <td>Aptitudes</td>
            <td><strong>Fonction</strong></td>
        </tr>
@@ -107,22 +111,15 @@
                <td colspan="2">
                    {{$diver->US_NAME}} {{$diver->US_FIRST_NAME}}
                </td>
                <td>{{$diver->PRE_CODE}}</td>
                <td>
                    @if($diver->US_ID === 5)
                        <!--dd($diver->roles)-->
                    @endif

                    @if($diver->US_ID === $dive->US_ID_CAR_DIRECT)
                        Directeur de plongée
                    @elseif ($diver->US_ID === $dive->US_ID)
                        Pilote
                    @elseif ($diver->US_ID === $dive->US_ID_CAR_SECURE)
                        Sécurité de surface
                    @else
                        Plongeur
                    {{$diver->PRE_CODE}}
                    @if($diver->US_TEACHING_LEVEL > 0)
                        / E{{$diver->US_TEACHING_LEVEL}}
                    @endif
                </td>
                <td>
                    {{$dive->getRoleForUser($diver)}}
                </td>
            </tr>
        @endforeach
    </x-security-sheets.diving-group-table>