
<?php $__env->startSection('title'); ?> Bénéficiaires <?php $__env->stopSection(); ?>
<?php $__env->startSection('title_card',"Bénéficiaires"); ?>
<?php $__env->startSection('subtitle_card',"Liste"); ?>

<?php $__env->startSection('content'); ?>
    <?php if(Session::has('message')): ?>
        <div class="alert alert-warning"><?php echo Session::get('message'); ?></div>
    <?php endif; ?>

    <?php if($errors): ?>
        <?php $__currentLoopData = $errors->all(); $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $error): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
            <div class='bg-danger alert'><?php echo $error; ?></div>
        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
    <?php endif; ?>

    <?php if(Session::has('success')): ?>
        <div class="alert alert-success"><?php echo \Session::get('success'); ?></div>
    <?php endif; ?>


    <div class="card">
        <div class="card-body">
             <div class="row">   
                <div class="col-xs-3" style="padding-left:0px;">
                    <?php echo Form::select('benef_type',$liste_beneftype,$benef_type,
                        [
                            'id' => 'benef_type',
                            'class' => 'form-control',
                            'onchange' => 'select_filtre()'
                        ]
                    ); ?>

                    <script>
                        function select_filtre() {
                            var select_benef_type = document.getElementById('benef_type');
                            var selected_benef_type = [...select_benef_type.selectedOptions].map(option => option.value);
                            var url="" ; 
                            if(selected_benef_type=="") selected_benef_type=0;
                            url="<?php echo url('/tiers/beneficiaires/limit'); ?>/"+selected_benef_type;
                            location.href=url;
                        }


                    </script>
                </div>
            </div>

            <div class='col-lg-max' style="padding-top:5px">
                <div class="">
                    <table id="_table" style="background-color:white" 
                        class="table table-striped table-bordered table-hover" width="100%" 
                        >
                        <thead>
                            <tr>
                                <th width='1%'>Id</th>
                                <th width='30%'>Nom</th>
                                <th width='5%'>Date de naissance</th>
                                <th width='1%'>NbEnf.</th>
                                <th width='30%'>Conjoint</th>
                                <th width='30%'>Employeur</th> 
                                <th width='30%'>Montant Ret.</th> 
                                <th width='30%'>Montant CSR</th> 
                                <th width='1%'>Statut</th>
                                <th width='1%'>Création</th>
                                <?php if($benef_type=="A"): ?>
                                <th width='1%'>AyantDroit</th>
                                 <?php endif; ?>
                                <?php if($benef_type=="RET"): ?>
                                    <th width='1%'>TypeRet</th>
                                <?php endif; ?>
                                <?php if( $user->can("BEN_VISU") || $user->can("BEN_MAJ") ||
                                    $user->can("BEN_SUP") || $user->HasRole("ADMINISTRATEUR") ): ?>
                                <th width='1%'>&nbsp;</th>
                                <?php endif; ?> 
                            </tr>
                        </thead>
             
                        <tbody>
                            <?php $__currentLoopData = $beneficiaires; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $beneficiaire): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                            <tr>
                                <td><?php echo str_pad($beneficiaire->id, 6, "0", STR_PAD_LEFT); ?></td>
                                <td>
                                    <a href="<?php echo url('tiers/beneficiaires_statut/'.$beneficiaire->id.'/'.$benef_type); ?>">
                                        <?php echo $beneficiaire->nom_complet; ?>

                                    </a>
                                </td>
                                <td><?php echo $beneficiaire->datenaiss; ?></td>
                                <td align="center"><?php echo $beneficiaire->nb_enf."/".$beneficiaire->nb_enf_tot; ?></td>
                                <td><?php echo $beneficiaire->nom_conjoint; ?></td>
                                <td><?php echo $beneficiaire->employeur_court; ?></td>  
                                <td align="center"><?php echo $beneficiaire->ret_montant; ?></td>
                                <td align="center"><?php echo $beneficiaire->csr_montant; ?></td>  
                                <td align="center"><?php echo $beneficiaire->statut; ?></td>
                                <td align="center"><?php echo $beneficiaire->created_at; ?></td>
                                <?php if($benef_type=="A"): ?>
                                <td align="center"><?php echo ($beneficiaire->ayantdroit)?"OUI":"NON"; ?></td>
                                <?php endif; ?>
                                <?php if($benef_type=="RET"): ?>
                                    <td align="center"><?php echo $beneficiaire->ret_type; ?></td>
                                <?php endif; ?>
                                <?php if( $user->can("BEN_VISU") || $user->can("BEN_MAJ") ||
                                    $user->can("BEN_SUP") || $user->HasRole("ADMINISTRATEUR") ): ?>
                                <td>
                                    <!--
                                    <?php if($user->can("BEN_VISU") || $user->HasRole("ADMINISTRATEUR")): ?>
                                        <a href="<?php echo url('tiers/beneficiaires_statut/'.$beneficiaire->id.'/'.$benef_type); ?>" class="btn btn-warning pull-left" style="margin-right: 3px;">Consulter</a>
                                    <?php endif; ?> 
                                -->
                                    <?php if($user->can("BEN_MAJ") || $user->HasRole("ADMINISTRATEUR")): ?>
                                        <a href="<?php echo url('tiers/beneficiaires_statut/'.$beneficiaire->id.'/'.$benef_type.'/edit'); ?>" 
                                            class="btn btn-info pull-left" style="margin-right: 3px;">
                                            Modifier
                                        </a>
                                    <?php endif; ?> 
                                    <?php if($user->can("BEN_SUP") || $user->HasRole("ADMINISTRATEUR")): ?> 
                                        <?php if($beneficiaire->has_cascade): ?>  
                                        <?php echo Form::open(['url' => '/tiers/beneficiaires/' . $beneficiaire->id, 'method' => 'DELETE']); ?>

                                        <?php echo Form::submit('Supprimer', ['class' => 'btn btn-danger']); ?>

                                        <?php echo Form::close(); ?>

                                        <?php endif; ?> 
                                    <?php endif; ?> 
                                </td>
                                <?php endif; ?> 
                            </tr>
                            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                        </tbody>
                    </table>
                    
                </div>
            <?php if($user->can("BEN_AJO") || $user->HasRole("ADMINISTRATEUR")): ?>
                 <div>
                    <h4><a href="<?php echo url('tiers/beneficiaires/create?lst='.$benef_type); ?>" class="btn btn-success">Ajouter un bénéficiaire</a></h4>
                </div> 
            <?php endif; ?>
            </div>
        </div>
    </div>
<?php $__env->stopSection(); ?>


<?php $__env->startSection('scripts'); ?>
    <?php echo $__env->make("forms.scripts_datatable", \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?>
<?php $__env->stopSection(); ?>
<?php echo $__env->make('layouts.dash', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?><?php /**PATH C:\xampp\htdocs\SYSINFO\cpswf\sipre2\resources\views/tiers/beneficiaires/index.blade.php ENDPATH**/ ?>