<?php $__env->startSection('search-bar'); ?>
    <div class="row g-3 mb-4 align-items-center justify-content-between">
        <div class="col-auto">
            <h1 class="app-page-title mb-0" style="color: #404242">LES FOURNISSEURS CLIENTS</h1>
        </div>
        <div class="col-auto">
            <div class="page-utilities">
                <div class="row g-2 justify-content-start justify-content-md-end align-items-center">
                    <div class="col-auto">
                        <form action="#" method="GET"
                            class="table-search-form row gx-1 align-items-center">
                            <div class="col-auto">
                                <input type="text" id="searchInput" name="search" class="form-control search-orders"
                                    placeholder="Recherche ... " onkeyup="searchClientFournisseur()">
                            </div>
                        </form>
                    </div><!--//col-->

                    <div class="col-auto d-flex align-items-center gap-2">
                        <?php if(auth()->user()->role == 'super-admin'): ?>
                        <div class="dropdown">
                            <button class="btn app-btn-secondary dropdown-toggle" type="button" id="exportDropdown" data-bs-toggle="dropdown" aria-expanded="false">
                                <i class="fas fa-file-pdf"></i> Exporter en pdf
                            </button>
                            <ul class="dropdown-menu" aria-labelledby="exportDropdown">
                                <li><a class="dropdown-item" href="<?php echo e(route('clients.pdf')); ?>"><i class="fas fa-file-pdf"></i> Exporter Prosperts</a></li>
                                <li><a class="dropdown-item" href="<?php echo e(route('prospects.pdf')); ?>"><i class="fas fa-file-pdf"></i> Exporter Clients</a></li>
                                <li><a class="dropdown-item" href="<?php echo e(route('fournisseurs.pdf')); ?>"><i class="fas fa-file-pdf"></i> Exporter Fournisseurs</a></li>
                                <li><a class="dropdown-item" href="<?php echo e(route('fournisseurClients.pdf')); ?>"><i class="fas fa-file-pdf"></i> Exporter Fournisseur Clients</a></li>
                                <li><hr class="dropdown-divider"></li>
                                <li><a class="dropdown-item" href="<?php echo e(route('allData.pdf')); ?>"><i class="fas fa-file-pdf"></i> Exporter Toutes les Tables</a></li>
                            </ul>
                        </div>
                        <div class="dropdown">
                            <button class="btn app-btn-secondary dropdown-toggle" type="button" id="exportDropdown" data-bs-toggle="dropdown" aria-expanded="false">
                                <i class="fas fa-file-excel"></i> Exporter en Excel
                            </button>
                            <ul class="dropdown-menu" aria-labelledby="exportDropdown">
                                <li><a class="dropdown-item" href="<?php echo e(route('export.clients')); ?>"><i class="fas fa-file-excel"></i> Exporter Prosperts</a></li>
                                <li><a class="dropdown-item" href="<?php echo e(route('export.prospects')); ?>"><i class="fas fa-file-excel"></i> Exporter Clients</a></li>
                                <li><a class="dropdown-item" href="<?php echo e(route('export.fournisseurs')); ?>"><i class="fas fa-file-excel"></i> Exporter Fournisseurs</a></li>
                                <li><a class="dropdown-item" href="<?php echo e(route('export.fournisseurClients')); ?>"><i class="fas fa-file-excel"></i> Exporter Fournisseur Clients</a></li>
                                <li><hr class="dropdown-divider"></li>
                                <li><a class="dropdown-item" href="<?php echo e(route('export.excel')); ?>"><i class="fas fa-file-excel"></i> Exporter Toutes les Tables</a></li>
                            </ul>
                        </div>
                        <?php elseif(auth()->user()->role == 'admin'): ?>
                        <div class="dropdown">
                            <button class="btn app-btn-secondary dropdown-toggle" type="button" id="exportDropdown" data-bs-toggle="dropdown" aria-expanded="false">
                                <i class="fas fa-file-pdf"></i> Exporter en pdf
                            </button>
                            <ul class="dropdown-menu" aria-labelledby="exportDropdown">
                                <li><a class="dropdown-item" href="<?php echo e(route('clients.pdf')); ?>"><i class="fas fa-file-pdf"></i> Exporter Prosperts</a></li>
                                <li><a class="dropdown-item" href="<?php echo e(route('prospects.pdf')); ?>"><i class="fas fa-file-pdf"></i> Exporter Clients</a></li>
                                <li><a class="dropdown-item" href="<?php echo e(route('fournisseurs.pdf')); ?>"><i class="fas fa-file-pdf"></i> Exporter Fournisseurs</a></li>
                                <li><a class="dropdown-item" href="<?php echo e(route('fournisseurClients.pdf')); ?>"><i class="fas fa-file-pdf"></i> Exporter Fournisseur Clients</a></li>
                                <li><hr class="dropdown-divider"></li>
                                <li><a class="dropdown-item" href="<?php echo e(route('allData.pdf')); ?>"><i class="fas fa-file-pdf"></i> Exporter Toutes les Tables</a></li>
                            </ul>
                        </div>
                        <div class="dropdown">
                            <button class="btn app-btn-secondary dropdown-toggle" type="button" id="exportDropdown" data-bs-toggle="dropdown" aria-expanded="false">
                                <i class="fas fa-file-excel"></i> Exporter en Excel
                            </button>
                            <ul class="dropdown-menu" aria-labelledby="exportDropdown">
                                <li><a class="dropdown-item" href="<?php echo e(route('export.clients')); ?>"><i class="fas fa-file-excel"></i> Exporter Prosperts</a></li>
                                <li><a class="dropdown-item" href="<?php echo e(route('export.prospects')); ?>"><i class="fas fa-file-excel"></i> Exporter Clients</a></li>
                                <li><a class="dropdown-item" href="<?php echo e(route('export.fournisseurs')); ?>"><i class="fas fa-file-excel"></i> Exporter Fournisseurs</a></li>
                                <li><a class="dropdown-item" href="<?php echo e(route('export.fournisseurClients')); ?>"><i class="fas fa-file-excel"></i> Exporter Fournisseur Clients</a></li>
                                <li><hr class="dropdown-divider"></li>
                                <li><a class="dropdown-item" href="<?php echo e(route('export.excel')); ?>"><i class="fas fa-file-excel"></i> Exporter Toutes les Tables</a></li>
                            </ul>
                        </div>
                        <?php endif; ?>
                    </div>
                </div><!--//row-->
            </div><!--//table-utilities-->
        </div><!--//col-auto-->
    </div><!--//row-->
<?php $__env->stopSection(); ?>

<?php $__env->startSection('errorContent'); ?>
    <script>
        document.addEventListener("DOMContentLoaded", function() {
            var modalType = document.getElementById('modals').getAttribute('data-error');

            if (modalType === 'default') {
                var addModal = new bootstrap.Modal(document.getElementById('add_fournisseurClient'));
                addModal.show();
            } else if (modalType === 'update') {
                var updateModal = new bootstrap.Modal(document.getElementById('update_fournisseurClient'));
                updateModal.show();
            } else if (modalType === 'remark') {
                var remark = new bootstrap.Modal(document.getElementById('remark'));
                remark.show();
            }
        });
    </script>
<?php $__env->stopSection(); ?>
<?php $__env->startSection('parties-prenantes'); ?>
    <nav id="orders-table-tab" class="orders-table-tab app-nav-tabs nav shadow-sm flex-column flex-sm-row mb-4">
        <a href="/prospectsSection" class="flex-sm-fill text-sm-center nav-link">Clients</a>
        <a href="/clientsSection" class="flex-sm-fill text-sm-center nav-link">Prosperts</a>
        <a href="/suppliersSection" class="flex-sm-fill text-sm-center nav-link">Fournisseurs</a>
        <a href="/suppliersAndClientsSection" class="flex-sm-fill text-sm-center nav-link active">Fournisseurs Clients</a>
    </nav>
<?php $__env->stopSection(); ?>
<?php $__env->startSection('content'); ?>
    <div id="modals" style="display:none;" data-error="<?php echo e(session('modalType')); ?>"></div>
    <form action="<?php echo e(route('fournisseurClient.add')); ?>" method="POST">
        <?php echo csrf_field(); ?>
        <div class="modal fade" id="add_fournisseurClient" tabindex="-1" aria-labelledby="exampleModalLabel"
            aria-hidden="true">
            <div class="modal-dialog">
                <div class="modal-content">
                    <div class="modal-header">
                        <h5 class="modal-title" id="exampleModalLabel">Ajouter un client & fournisseur</h5>
                        <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
                    </div>
                    <div class="modal-body">
                        <label class="form-label"><strong class="det">Nom de la société</strong></label>
                        <input type="text" class="form-control" name="nomSociete_fournisseurClient"
                            placeholder="Entrer le nom de la société..."
                            value="<?php echo e(old('nomSociete_fournisseurClient')); ?>" />
                        <?php $__errorArgs = ['nomSociete_fournisseurClient', 'default'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?>
                            <span class="text-danger"><?php echo e($message); ?></span><br>
                        <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>
                        <label class="form-label"><strong class="det">GSM1 de la société</strong></label>
                        <input type="tel" class="form-control" name="GSM1_fournisseurClient"
                            placeholder="Entrer le GSM1..." value="<?php echo e(old('GSM1_fournisseurClient')); ?>" pattern="[0-9]{10,15}" oninput="this.value = this.value.replace(/[^0-9]/g, '')"/>
                        <?php $__errorArgs = ['GSM1_fournisseurClient', 'default'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?>
                            <span class="text-danger"><?php echo e($message); ?></span><br>
                        <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>
                        <label class="form-label"><strong class="det">GSM2 de la société</strong></label>
                        <input type="tel" class="form-control" name="GSM2_fournisseurClient"
                            placeholder="Entrer le GSM2..." value="<?php echo e(old('GSM2_fournisseurClient')); ?>" pattern="[0-9]{10,15}" oninput="this.value = this.value.replace(/[^0-9]/g, '')"/>
                        <?php $__errorArgs = ['GSM2_fournisseurClient', 'default'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?>
                            <span class="text-danger"><?php echo e($message); ?></span><br>
                        <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>
                        <label class="form-label"><strong class="det">Personne à contacter</strong></label>
                        <input type="text" class="form-control" name="nom_fournisseurClient"
                            placeholder="Entrer le fournisseurClient..." value="<?php echo e(old('nom_fournisseurClient')); ?>" />
                        <?php $__errorArgs = ['nom_fournisseurClient', 'default'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?>
                            <span class="text-danger"><?php echo e($message); ?></span><br>
                        <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>
                        <label class="form-label"><strong class="det">Numero de telephone</strong></label>
                        <input type="tel" class="form-control" name="tele_fournisseurClient"
                            placeholder="Entrer le contact..." value="<?php echo e(old('tele_fournisseurClient')); ?>" pattern="[0-9]{10,15}" oninput="this.value = this.value.replace(/[^0-9]/g, '')"/>
                        <?php $__errorArgs = ['tele_fournisseurClient', 'default'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?>
                            <span class="text-danger"><?php echo e($message); ?></span><br>
                        <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>
                        <label class="form-label"><strong class="det">Email</strong></label>
                        <input type="email" class="form-control" name="email_fournisseurClient"
                            placeholder="Entrer l'émail..." value="<?php echo e(old('email_fournisseurClient')); ?>" />
                        <?php $__errorArgs = ['email_fournisseurClient', 'default'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?>
                            <span class="text-danger"><?php echo e($message); ?></span><br>
                        <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>
                        <label class="form-label"><strong class="det">Lien de la société</strong></label>
                        <input type="url" class="form-control" name="lien_fournisseurClient"
                            placeholder="Entrer le Lien..." value="<?php echo e(old('lien_fournisseurClient')); ?>"/>
                        <?php $__errorArgs = ['lien_fournisseurClient', 'default'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?>
                            <span class="text-danger"><?php echo e($message); ?></span><br>
                        <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>
                        <label class="form-label"><strong class="det">Ville</strong></label>
                        <input type="text" class="form-control" name="ville_fournisseurClient"
                            placeholder="Entrer la ville..." value="<?php echo e(old('ville_fournisseurClient')); ?>" />
                        <?php $__errorArgs = ['ville_fournisseurClient', 'default'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?>
                            <span class="text-danger"><?php echo e($message); ?></span><br>
                        <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>
                        <label class="form-label"><strong class="det">Catégorie</strong></label>
                        <select class="form-select form-select-sm" aria-label=".form-select-sm example"
                            name="categorie_id" id="categorie" style="height: 39px">
                            <option value="">Selectionner la catégorie</option>
                            <?php $__currentLoopData = $categories; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $category): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                <option value="<?php echo e($category->id); ?>"
                                    <?php echo e(old('categorie_id') == $category->id ? 'selected' : ''); ?>>
                                    <?php echo e($category->nom_categorie); ?>

                                </option>
                            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                        </select>
                        <?php $__errorArgs = ['categorie_id', 'default'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?>
                            <span class="text-danger"><?php echo e($message); ?></span><br>
                        <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>
                        <!-- Label pour les sous-catégories, caché tant qu'une catégorie n'est pas sélectionnée -->
                        <label for="sous-categorie" class="form-label" id="label-sous-categorie"
                            <?php echo e(request('categorie_id') ? '' : 'style=display:none;'); ?>>
                            <strong class="det">Sous-Catégorie</strong>
                        </label>

                        <!-- Sélecteur de sous-catégorie, caché tant qu'une catégorie n'est pas sélectionnée -->
                        <select id="sous-categorie" class="form-control" name="sous_categorie_id"
                            <?php echo e(request('categorie_id') ? '' : 'style=display:none;'); ?>>
                            <option value="">Sélectionner une sous-catégorie</option>
                            <?php if(request('categorie_id')): ?>
                                <?php $__currentLoopData = $sousCategories; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $sousCategorie): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                    <option value="<?php echo e($sousCategorie->id); ?>"
                                        <?php echo e(request('sous_categorie_id') == $sousCategorie->id ? 'selected' : ''); ?>>
                                        <?php echo e($sousCategorie->nom_produit); ?>

                                    </option>
                                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                            <?php endif; ?>
                        </select>
                    </div>
                    <div class="modal-footer">
                        <input type="submit" class="btn btn-success" value="Ajouter" data-bs-dismiss="modal">
                    </div>
                </div>
            </div>
        </div>
    </form>

    <div class="page-inner">
        <div class="app-card app-card-orders-table mb-5">
            <div class="app-card-body">
                <div class="table-responsive">
                    <table id="fc-table" class="table app-table-hover mb-0 text-center">
                        <thead>
                            <tr>
                                <th class="cell">Nom de la société</th>
                                <th class="cell">GSM1 de la société</th>
                                <th class="cell">GSM2 de la société</th>
                                <th class="cell">Personne à contacter</th>
                                <th class="cell">Numero De Telephone</th>
                                <th class="cell">Email</th>
                                <th class="cell">Lien de la société</th>
                                <th class="cell">Ville</th>
                                <th class="cell">Catégorie</th>
                                <th class="cell">Contacté Par</th>
                                <th class="cell text-end">
                                        <button type="button" class="btn app-btn-secondary" data-bs-toggle="modal"
                                            data-bs-target="#add_fournisseurClient">
                                            Ajouter
                                        </button>
                                </th>
                            </tr>
                        </thead>
                        <tbody>
                            <?php
                                $utilisateurs = \App\Models\User::get();
                            ?>
                            <?php $__currentLoopData = $fournisseurClients; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $fc): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                <tr>
                                    <td class="cell2">
                                        <?php echo !empty($fc->nomSociete_fournisseurClient) ? $fc->nomSociete_fournisseurClient : '<span class="text-danger">Particulier</span>'; ?>

                                    </td>
                                    <td class="cell2">
                                        <?php echo !empty($fc->GSM1_fournisseurClient) ? $fc->GSM1_fournisseurClient : '<span class="text-danger">Non disponible</span>'; ?>

                                    </td>
                                    <td class="cell2">
                                        <?php echo !empty($fc->GSM2_fournisseurClient) ? $fc->GSM2_fournisseurClient : '<span class="text-danger">Non disponible</span>'; ?>

                                    </td>
                                    <td class="cell2">
                                        <?php echo !empty($fc->nom_fournisseurClient) ? $fc->nom_fournisseurClient : '<span class="text-danger">Non disponible</span>'; ?>

                                    </td>
                                    <td class="cell2">
                                        <?php echo !empty($fc->tele_fournisseurClient) ? $fc->tele_fournisseurClient : '<span class="text-danger">Non disponible</span>'; ?>

                                    </td>
                                    <td class="cell2">
                                        <?php echo !empty($fc->email_fournisseurClient) ? $fc->email_fournisseurClient : '<span class="text-danger">Non disponible</span>'; ?>

                                    </td>
                                    <td class="cell2">
                                        <?php if(!empty($fc->lien_fournisseurClient)): ?>
                                            <a href="<?php echo e($fc->lien_fournisseurClient); ?>" target="_blank" class="text-primary">
                                                <?php echo e(Str::limit($fc->lien_fournisseurClient, 20)); ?> <!-- Limite l'affichage -->
                                            </a>
                                        <?php else: ?>
                                            <span class="text-danger">Non disponible</span>
                                        <?php endif; ?>
                                    </td>
                                    <td class="cell2"><?php echo e($fc->ville_fournisseurClient); ?></td>
                                    <td class="cell2">
                                        <?php $__empty_1 = true; $__currentLoopData = $fc->categorieClientFournisseurs; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $assoc): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?>
                                            <?php if($assoc->categorie): ?>
                                                <?php echo e($assoc->categorie->nom_categorie); ?>

                                            <?php endif; ?>
                                        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>
                                            Non catégorisé
                                        <?php endif; ?>
                                    </td>
                                    <td class="cell2">
                                        <?php echo e(!empty($fc->utilisateur->name) ? $fc->utilisateur->name : 'Personne'); ?>

                                    </td>


                                    <?php if(auth()->user()->role == 'super-admin'): ?>
                                        <td class="button-container">
                                            <div class="d-flex align-items-center gap-2"
                                                style="display: inline; border-radius: 1cap; border-style: inherit; color: transparent;">
                                                <a href="#" class="btn btn-outline-primary border-btn me-4"
                                                    data-bs-toggle="modal" data-bs-target="#update_fournisseurClient"
                                                    data-id="<?php echo e($fc->id); ?>"
                                                    data-society="<?php echo e($fc->nomSociete_fournisseurClient); ?>"
                                                    data-GSM1="<?php echo e($fc->GSM1_fournisseurClient); ?>"
                                                    data-GSM2="<?php echo e($fc->GSM2_fournisseurClient); ?>"
                                                    data-lien="<?php echo e($fc->lien_fournisseurClient); ?>"
                                                    data-name="<?php echo e($fc->nom_fournisseurClient); ?>"
                                                    data-tele="<?php echo e($fc->tele_fournisseurClient); ?>"
                                                    data-email="<?php echo e($fc->email_fournisseurClient); ?>"
                                                    data-ville="<?php echo e($fc->ville_fournisseurClient); ?>"
                                                    data-category="<?php echo e($fc->categories->first()?->id ?? ''); ?>">
                                                    Modifier
                                                </a>



                                                <button type="button" class="btn btn-outline-success border-btn me-4"
                                                    data-bs-toggle="modal" data-bs-target="#remark-<?php echo e($fc->id); ?>">
                                                    Remarque
                                                </button>



                                                <button type="button"
                                                    class="btn btn-outline-info detailButton border-btn me-4"
                                                    data-bs-toggle="modal"
                                                    data-bs-target="#ModalFCDetails-<?php echo e($fc->id); ?>"
                                                    data-name="<?php echo e($fc->nom_fournisseurClient); ?>"
                                                    data-email="<?php echo e($fc->email_fournisseurClient); ?>"
                                                    data-tele="<?php echo e($fc->tele_fournisseurClient); ?>"
                                                    data-ville="<?php echo e($fc->ville_fournisseurClient); ?>"
                                                    data-society-name="<?php echo e(!empty($fc->nomSociete_fournisseurClient) ? $fc->nomSociete_fournisseurClient : 'Particulier'); ?>"
                                                    data-GSM1="<?php echo e(!empty($fc->GSM1_fournisseurClient) ? $fc->GSM1_fournisseurClient : 'Non disponible'); ?>"
                                                    data-GSM2="<?php echo e(!empty($fc->GSM2_fournisseurClient) ? $fc->GSM2_fournisseurClient : 'Non disponible'); ?>"
                                                    data-lien="<?php echo e(!empty($fc->lien_fournisseurClient) ? $fc->lien_fournisseurClient : 'Non disponible'); ?>"
                                                    data-remark="<?php echo e($fc->remark); ?>"
                                                    data-user="<?php echo e(!empty($fc->utilisateur->name) ? $fc->utilisateur->name : 'Personne'); ?>">

                                                    Details
                                                </button>

                                                <form action="<?php echo e(route('fournisseurClient.destroy', $fc->id)); ?>"
                                                    method="POST"
                                                    style="display: inline; border-radius: 1cap; border-style: inherit; color: transparent;"
                                                    id="delete-form-<?php echo e($fc->id); ?>">
                                                    <?php echo csrf_field(); ?>
                                                    <?php echo method_field('DELETE'); ?>
                                                    <button type="button" class="btn btn-outline-danger border-btn me-4"
                                                        onclick="confirmDelete(<?php echo e($fc->id); ?>)">
                                                        Supprimer
                                                    </button>
                                                </form>


                                                <form class="user-form" action="<?php echo e(route('user.select.fc', $fc->id)); ?>"
                                                    method="POST">
                                                    <?php echo csrf_field(); ?>
                                                    <?php echo method_field('POST'); ?>
                                                    <select class="form-select userSelect"
                                                        aria-label="Default select example"
                                                        data-fc-id="<?php echo e($fc->id); ?>" style="margin-right:100px"
                                                        name="user_id">
                                                        <option value="">Contacté Par</option>
                                                        <?php $__currentLoopData = $utilisateurs; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $user): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                                            <option value="<?php echo e($user->id); ?>"
                                                                <?php echo e(old('user_id') == $user->id ? 'selected' : ''); ?>>
                                                                <?php echo e($user->name); ?>

                                                            </option>
                                                        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                                    </select>
                                                </form>

                                                <form class="fc-form"
                                                    action="<?php echo e(route('fournisseurClient.select', $fc->id)); ?>"
                                                    method="POST">
                                                    <?php echo csrf_field(); ?>
                                                    <?php echo method_field('POST'); ?>
                                                    <select name="status" id=""
                                                        class="form-select status-select">
                                                        <option value="" selected>Selectionner la table</option>
                                                        <?php $__currentLoopData = $select; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $item): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                                            <option value="<?php echo e($item); ?>"><?php echo e($item); ?>

                                                            </option>
                                                        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                                    </select>
                                                </form>
                                            </div>
                                        </td>
                                    <?php elseif(auth()->user()->role == 'admin'): ?>
                                        <td class="button-container">
                                            <div class="d-flex align-items-center gap-2"
                                                style="display: inline; border-radius: 1cap; border-style: inherit; color: transparent;">
                                                <a href="#" class="btn btn-outline-primary border-btn me-4"
                                                    data-bs-toggle="modal" data-bs-target="#update_fournisseurClient"
                                                    data-id="<?php echo e($fc->id); ?>"
                                                    data-society="<?php echo e($fc->nomSociete_fournisseurClient); ?>"
                                                    data-GSM1="<?php echo e($fc->GSM1_fournisseurClient); ?>"
                                                    data-GSM2="<?php echo e($fc->GSM2_fournisseurClient); ?>"
                                                    data-lien="<?php echo e($fc->lien_fournisseurClient); ?>"
                                                    data-name="<?php echo e($fc->nom_fournisseurClient); ?>"
                                                    data-tele="<?php echo e($fc->tele_fournisseurClient); ?>"
                                                    data-email="<?php echo e($fc->email_fournisseurClient); ?>"
                                                    data-ville="<?php echo e($fc->ville_fournisseurClient); ?>"
                                                    data-category="<?php echo e($fc->categories->first()?->id ?? ''); ?>">
                                                    Modifier
                                                </a>



                                                <button type="button" class="btn btn-outline-success border-btn me-4"
                                                    data-bs-toggle="modal" data-bs-target="#remark-<?php echo e($fc->id); ?>">
                                                    Remarque
                                                </button>

                                                <button type="button"
                                                    class="btn btn-outline-info detailButton border-btn me-4"
                                                    data-bs-toggle="modal"
                                                    data-bs-target="#ModalFCDetails-<?php echo e($fc->id); ?>"
                                                    data-name="<?php echo e($fc->nom_fournisseurClient); ?>"
                                                    data-email="<?php echo e($fc->email_fournisseurClient); ?>"
                                                    data-tele="<?php echo e($fc->tele_fournisseurClient); ?>"
                                                    data-ville="<?php echo e($fc->ville_fournisseurClient); ?>"
                                                    data-society-name="<?php echo e(!empty($fc->nomSociete_fournisseurClient) ? $fc->nomSociete_fournisseurClient : 'Particulier'); ?>"
                                                    data-GSM1="<?php echo e(!empty($fc->GSM1_fournisseurClient) ? $fc->GSM1_fournisseurClient : 'Non disponible'); ?>"
                                                    data-GSM2="<?php echo e(!empty($fc->GSM2_fournisseurClient) ? $fc->GSM2_fournisseurClient : 'Non disponible'); ?>"
                                                    data-lien="<?php echo e(!empty($fc->lien_fournisseurClient) ? $fc->lien_fournisseurClient : 'Non disponible'); ?>"
                                                    data-remark="<?php echo e($fc->remark); ?>"
                                                    data-user="<?php echo e(!empty($fc->utilisateur->name) ? $fc->utilisateur->name : 'Personne'); ?>">

                                                    Details
                                                </button>

                                                <form class="user-form" action="<?php echo e(route('user.select.fc', $fc->id)); ?>"
                                                    method="POST">
                                                    <?php echo csrf_field(); ?>
                                                    <?php echo method_field('POST'); ?>
                                                    <select class="form-select userSelect"
                                                        aria-label="Default select example"
                                                        data-fc-id="<?php echo e($fc->id); ?>" style="margin-right:100px"
                                                        name="user_id">
                                                        <option value="">Contacté Par</option>
                                                        <?php $__currentLoopData = $utilisateurs; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $user): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                                            <option value="<?php echo e($user->id); ?>"
                                                                <?php echo e(old('user_id') == $user->id ? 'selected' : ''); ?>>
                                                                <?php echo e($user->name); ?>

                                                            </option>
                                                        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                                    </select>
                                                </form>

                                                <form class="fc-form"
                                                    action="<?php echo e(route('fournisseurClient.select', $fc->id)); ?>"
                                                    method="POST">
                                                    <?php echo csrf_field(); ?>
                                                    <?php echo method_field('POST'); ?>
                                                    <select name="status" id=""
                                                        class="form-select status-select">
                                                        <option value="" selected>Selectionner la table</option>
                                                        <?php $__currentLoopData = $select; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $item): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                                            <option value="<?php echo e($item); ?>"><?php echo e($item); ?>

                                                            </option>
                                                        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                                    </select>
                                                </form>

                                            </div>
                                        </td>
                                    <?php elseif(auth()->user()->role == 'utilisateur'): ?>
                                        <td class="button-container">
                                            <div class="d-flex align-items-center gap-2"
                                                style="display: inline; border-radius: 1cap; border-style: inherit; color: transparent;">


                                                <button type="button" class="btn btn-outline-success border-btn me-4"
                                                    data-bs-toggle="modal" data-bs-target="#remark-<?php echo e($fc->id); ?>">
                                                    Remarque
                                                </button>


                                                <button type="button"
                                                    class="btn btn-outline-info detailButton border-btn me-4"
                                                    data-bs-toggle="modal"
                                                    data-bs-target="#ModalFCDetails-<?php echo e($fc->id); ?>"
                                                    data-name="<?php echo e($fc->nom_fournisseurClient); ?>"
                                                    data-email="<?php echo e($fc->email_fournisseurClient); ?>"
                                                    data-tele="<?php echo e($fc->tele_fournisseurClient); ?>"
                                                    data-ville="<?php echo e($fc->ville_fournisseurClient); ?>"
                                                    data-society-name="<?php echo e(!empty($fc->nomSociete_fournisseurClient) ? $fc->nomSociete_fournisseurClient : 'Particulier'); ?>"
                                                    data-GSM1="<?php echo e(!empty($fc->GSM1_fournisseurClient) ? $fc->GSM1_fournisseurClient : 'Non disponible'); ?>"
                                                    data-GSM2="<?php echo e(!empty($fc->GSM2_fournisseurClient) ? $fc->GSM2_fournisseurClient : 'Non disponible'); ?>"
                                                    data-lien="<?php echo e(!empty($fc->lien_fournisseurClient) ? $fc->lien_fournisseurClient : 'Non disponible'); ?>"
                                                    data-remark="<?php echo e($fc->remark); ?>"
                                                    data-user="<?php echo e(!empty($fc->utilisateur->name) ? $fc->utilisateur->name : 'Personne'); ?>">

                                                    Details
                                                </button>
                                                <form class="user-form" action="<?php echo e(route('user.select.fc', $fc->id)); ?>"
                                                    method="POST">
                                                    <?php echo csrf_field(); ?>
                                                    <?php echo method_field('POST'); ?>
                                                    <select class="form-select userSelect"
                                                        aria-label="Default select example"
                                                        data-fc-id="<?php echo e($fc->id); ?>" style="margin-right:100px"
                                                        name="user_id">
                                                        <option value="">Contacté Par</option>
                                                        <?php $__currentLoopData = $utilisateurs; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $user): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                                            <option value="<?php echo e($user->id); ?>"
                                                                <?php echo e(old('user_id') == $user->id ? 'selected' : ''); ?>>
                                                                <?php echo e($user->name); ?>

                                                            </option>
                                                        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                                    </select>
                                                </form>
                                                <form class="fc-form"
                                                    action="<?php echo e(route('fournisseurClient.select', $fc->id)); ?>"
                                                    method="POST">
                                                    <?php echo csrf_field(); ?>
                                                    <?php echo method_field('POST'); ?>
                                                    <select name="status" id=""
                                                        class="form-select status-select">
                                                        <option value="" selected>Selectionner la table</option>
                                                        <?php $__currentLoopData = $select; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $item): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                                            <option value="<?php echo e($item); ?>"><?php echo e($item); ?>

                                                            </option>
                                                        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                                    </select>
                                                </form>
                                            </div>
                                        </td>
                                    <?php endif; ?>
                                    <form action="<?php echo e(route('remark.fc', $fc->id)); ?>" method="POST">
                                        <?php echo csrf_field(); ?>
                                        <div class="modal fade" id="remark-<?php echo e($fc->id); ?>" tabindex="-1"
                                            aria-labelledby="exampleModalLabel" aria-hidden="true">
                                            <div class="modal-dialog modal-dialog-centered">
                                                <div class="modal-content">
                                                    <div class="modal-header">
                                                        <h5 class="modal-title" id="exampleModalLabel">REMARQUE</h5>
                                                        <button type="button" class="btn-close" data-bs-dismiss="modal"
                                                            aria-label="Close"></button>
                                                    </div>
                                                    <div class="modal-body">

                                                        <div class="form-group">
                                                            <textarea name="remark" id="remarque" class="form-control" style="height: 100px"><?php echo e(old('remark', $fc->remark)); ?></textarea>
                                                            <?php $__errorArgs = ['remark'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?>
                                                                <div class="alert alert-danger">
                                                                    <?php echo e($message); ?></div>
                                                            <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>
                                                        </div>

                                                    </div>
                                                    <div class="modal-footer">
                                                        <button type="submit" class="btn btn-success">Ajouter la
                                                            remarque</button>
                                                    </div>
                                                </div>
                                            </div>
                                        </div>
                                    </form>


                                </tr>
                                <div class="modal fade" id="ModalFCDetails-<?php echo e($fc->id); ?>" tabindex="-1"
                                    aria-labelledby="exampleModalLabel" aria-hidden="true">
                                    <div class="modal-dialog modal-dialog-centered">
                                        <div class="modal-content">
                                            <div class="modal-header">
                                                <h5>Details du fournisseur-client
                                                </h5>
                                                <button type="button" class="btn-close" data-bs-dismiss="modal"
                                                    aria-label="Close"></button>
                                            </div>
                                            <div class="modal-body">
                                                <div class="row">

                                                    <div class="col-6 det" style="font-size: 18px">Nom de la socité</div>
                                                    <div class="col-6 showSocietyfc"><span style="font-size: 18px" id="showSocietyDetail-<?php echo e($fc->id); ?>"></span></div>
                                            
                                                    <div class="col-6 det" style="font-size: 18px">GSM1 de la société</strong></div>
                                                    <div class="col-6 showGSM1fc"><span style="font-size: 18px" id="showGSM1Detail-<?php echo e($fc->id); ?>"></span></div>
                                            
                                                    <div class="col-6 det" style="font-size: 18px">GSM2 de la société</strong></div>
                                                    <div class="col-6 showGSM2fc"><span style="font-size: 18px" id="showGSM2Detail-<?php echo e($fc->id); ?>"></span></div>
                                            
                                                    <div class="col-6 det" style="font-size: 18px">Personne à contacter</strong></div>
                                                    <div class="col-6 showNamefc"><span style="font-size: 18px" id="showNameDetail-<?php echo e($fc->id); ?>"></span></div>
                                            
                                                    <div class="col-6 det" style="font-size: 18px">Numero De Telephone</strong></div>
                                                    <div class="col-6 showContactfc"><span style="font-size: 18px" id="showContactDetail-<?php echo e($fc->id); ?>"></span></div>
                                            
                                                    <div class="col-6 det" style="font-size: 18px">Email</strong></div>
                                                    <div class="col-6 showEmailfc"><span style="font-size: 18px" id="showEmailDetail-<?php echo e($fc->id); ?>"></span></div>
                                            
                                                    <div class="col-6 det" style="font-size: 18px">Lien de la société</strong></div>
                                                    <div class="col-6 showLienfc"><a href="<?php echo e($fc->lien_fournisseurClient); ?>" target="_blank" class="text-primary" style="font-size: 18px">
                                                        <?php echo e(Str::limit($fc->lien_fournisseurClient, 20)); ?> <!-- Limite l'affichage -->
                                                    </a></div>

                                                    <div class="col-6 det" style="font-size: 18px">Ville</strong></div>
                                                    <div class="col-6 showVillefc"><span style="font-size: 18px" id="showVilleDetail-<?php echo e($fc->id); ?>"></span></div>
                                            
                                            
                                            
                                                    <div class="col-6 det" style="font-size: 18px">Les catégories</strong></div>
                                                    <div class="col-6">
                                                        <select class="form-select form-select-sm col-6 info-fournisseurClient showCategoryfc"
                                                            aria-label=".form-select-sm example" id="categories-<?php echo e($fc->id); ?>" style="color: #5d6778">
                                                            <option class="col-6" value="" selected>Voir la(les) catégories</option>
                                                            <?php $__currentLoopData = $fc->allCategories; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $categorie): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                                                <option value="<?php echo e($categorie->id); ?>">
                                                                    <?php echo e($categorie->nom_categorie); ?>

                                                                </option>
                                                            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                                        </select>
                                                    </div>
                                            
                                                    <div class="col-6 det" style="font-size: 18px">Sous-Catégorie</strong></div>
                                                    <div class="col-6">
                                                        <select class="form-select form-select-sm col-6 info-fournisseurClient showProductfc"
                                                            aria-label=".form-select-sm example" id="products-<?php echo e($fc->id); ?>" style="color: #5d6778; font-size: 15px"><strong>
                                                            <option class="col-6" value="" selected>Voir les produits associé</option></strong>
                                                        </select>
                                                    </div>
                                            
                                                    <div class="col-6 det" style="font-size: 18px">Contacté Par</strong></div>
                                                    <div class="col-6 showUserfc"><span style="font-size: 18px" id="showUserDetail-<?php echo e($fc->id); ?>"></span></div>
                                            
                                                    <div class="col-6 det" style="font-size: 18px">Remarque</strong></div>
                                                    <div class="col-6 showRemarkfc"><span style="font-size: 18px" id="showRemarkDetail-<?php echo e($fc->id); ?>"></span></div>
                                            </div>

                                            </div>
                                           
                                        </div>
                                    </div>
                                </div>
                            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                        </tbody>
                    </table>
                </div>
            </div>
        </div>
    </div>
    </div>
    <?php if(isset($fc)): ?>
        <div class="modal fade" id="update_fournisseurClient" tabindex="-1" aria-labelledby="exampleModalLabel"
            aria-hidden="true">
            <div class="modal-dialog">
                <div class="modal-content">
                    <form action="<?php echo e(route('fournisseurClient.update')); ?>" method="POST">
                        <?php echo csrf_field(); ?>
                        <input type="hidden" name="id" id="updateFCId">
                        <div class="modal-header">
                            <h5 class="modal-title" id="exampleModalLabel">Modifier le client & fournisseur</h5>
                            <button type="button" class="btn-close" data-bs-dismiss="modal"
                                aria-label="Close"></button>
                        </div>
                        <div class="modal-body">
                            <div>
                                <label class="form-label">Nom de la
                                    société</label>
                                <input type="text" class="form-control" name="newNomSociete_fournisseurClient"
                                    placeholder="Entrer le nom de la société..." id="updateFCSociety"
                                    value="<?php echo e(old('newNomSociete_fournisseurClient', $fc->nomSociete_fournisseurClient)); ?>" />
                                <?php if($errors->has('newNomSociete_fournisseurClient')): ?>
                                    <span class="text-danger">
                                        <?php echo e($errors->first('newNomSociete_fournisseurClient')); ?></span><br>
                                <?php endif; ?>

                            </div>
                            <div>
                                <label class="form-label">GSM1 de la
                                    société</label>
                                <input type="tel" class="form-control" name="newGSM1_fournisseurClient"
                                    placeholder="Entrer GSM1..." id="updateFCGSM1"
                                    value="<?php echo e(old('newGSM1_fournisseurClient', $fc->GSM1_fournisseurClient)); ?>" pattern="[0-9]{10,15}" oninput="this.value = this.value.replace(/[^0-9]/g, '')"/>
                                <?php if($errors->has('newGSM1_fournisseurClient')): ?>
                                    <span class="text-danger">
                                        <?php echo e($errors->first('newGSM1_fournisseurClient')); ?></span><br>
                                <?php endif; ?>

                            </div>
                            <div>
                                <label class="form-label">GSM2 de la
                                    société</label>
                                <input type="tel" class="form-control" name="newGSM2_fournisseurClient"
                                    placeholder="Entrer GSM2..." id="updateFCGSM2"
                                    value="<?php echo e(old('newGSM2_fournisseurClient', $fc->GSM2_fournisseurClient)); ?>" pattern="[0-9]{10,15}" oninput="this.value = this.value.replace(/[^0-9]/g, '')"/>
                                <?php if($errors->has('newGSM2_fournisseurClient')): ?>
                                    <span class="text-danger">
                                        <?php echo e($errors->first('newGSM2_fournisseurClient')); ?></span><br>
                                <?php endif; ?>

                            </div>
                            <div>
                                <label class="form-label">Personne à contacter</label>
                                <input id="updateFCName" type="text" class="form-control"
                                    name="newNom_fournisseurClient" placeholder="Entrer le client & fournisseur..."
                                    value="<?php echo e(old('newNom_fournisseurClient', $fc->nom_fournisseurClient)); ?>" />
                                <?php if($errors->has('newNom_fournisseurClient')): ?>
                                    <span class="text-danger">
                                        <?php echo e($errors->first('newNom_fournisseurClient')); ?></span><br>
                                <?php endif; ?>

                            </div>
                            <div>
                                <label class="form-label">Numero De Telephone</label>
                                <input id="updateFCContact" type="tel" class="form-control"
                                    name="newTele_fournisseurClient" placeholder="Entrer le contact..."
                                    value="<?php echo e(old('newTele_fournisseurClient', $fc->tele_fournisseurClient)); ?>" pattern="[0-9]{10,15}" oninput="this.value = this.value.replace(/[^0-9]/g, '')"/>
                                <?php if($errors->has('newTele_fournisseurClient')): ?>
                                    <span class="text-danger">
                                        <?php echo e($errors->first('newTele_fournisseurClient')); ?></span><br>
                                <?php endif; ?>

                            </div>
                            <div>
                                <label class="form-label">Email</label>
                                <input id="updateFCEmail" type="email" class="form-control"
                                    name="newEmail_fournisseurClient" placeholder="Entrer l'émail..."
                                    value="<?php echo e(old('newEmail_fournisseurClient', $fc->email_fournisseurClient)); ?>" />
                                <?php if($errors->has('newEmail_fournisseurClient')): ?>
                                    <span class="text-danger">
                                        <?php echo e($errors->first('newEmail_fournisseurClient')); ?></span><br>
                                <?php endif; ?>

                            </div>
                            <div>
                                <label class="form-label">Lien de la
                                    société</label>
                                <input type="tel" class="form-control" name="newLien_fournisseurClient"
                                    placeholder="Entrer Lien..." id="updateFCLien"
                                    value="<?php echo e(old('newLien_fournisseurClient', $fc->lien_fournisseurClient)); ?>"/>
                                <?php if($errors->has('newLien_fournisseurClient')): ?>
                                    <span class="text-danger">
                                        <?php echo e($errors->first('newLien_fournisseurClient')); ?></span><br>
                                <?php endif; ?>

                            </div>
                            <div>
                                <label class="form-label">Ville</label>
                                <input id="updateFCVille" type="text" class="form-control"
                                    name="newVille_fournisseurClient" placeholder="Entrer la ville..."
                                    value="<?php echo e(old('newVille_fournisseurClient', $fc->ville_fournisseurClient)); ?>" />
                                <?php if($errors->has('newVille_fournisseurClient')): ?>
                                    <span class="text-danger">
                                        <?php echo e($errors->first('newVille_fournisseurClient')); ?></span><br>
                                <?php endif; ?>

                            </div>

                            <div>
                                <label class="form-label">Catégorie</label>
                                <select id="updateFCCategory" class="form-select form-select-sm"
                                    aria-label=".form-select-sm example" name="newCategorie_id" style="height: 39px">
                                    <?php $__currentLoopData = $categories; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $cat): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                        <option value="<?php echo e($cat->id); ?>">

                                            <?php echo e($cat->nom_categorie); ?>

                                        </option>
                                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                </select>
                                <?php if($errors->has('newCategorie_id')): ?>
                                    <span class="text-danger">
                                        <?php echo e($errors->first('newCategorie_id')); ?></span><br>
                                <?php endif; ?>
                            </div>
                        </div>
                        <div class="modal-footer">
                            <input type="submit" class="btn btn-primary" data-bs-dismiss="modal" value="Modifier">
                        </div>
                    </form>
                </div>
            </div>
        </div>
    <?php endif; ?>
    <div>
      
        <div>
            <?php echo e($fournisseurClients->links('vendor.pagination.bootstrap-4')); ?>


        </div>
    </div>

<?php $__env->stopSection(); ?>
<?php $__env->startSection('script'); ?>
<script>
    document.addEventListener('DOMContentLoaded', function () {
        const select = document.getElementById('pagination-select');
        const form = document.getElementById('pagination-form');
        const perPageInput = document.getElementById('per-page-input');

        select.addEventListener('change', function () {
            perPageInput.value = this.value;
            form.submit();
        });
    });
</script>
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
<script>
    $(document).ready(function () {
        // Quand une catégorie est sélectionnée
        $('#categorie').change(function () {
            var categorieId = $(this).val();

            // Si une catégorie est sélectionnée
            if (categorieId) {
                // Afficher le champ des sous-catégories et son label
                $('#label-sous-categorie').show();
                $('#sous-categorie').show();

                // Faire une requête AJAX pour récupérer les sous-catégories
                $.ajax({
                    url: '/sous-categories/' + categorieId, // L'URL de ta route
                    type: 'GET',
                    success: function (response) {
                        // Vider le select de sous-catégories
                        $('#sous-categorie').empty();
                        $('#sous-categorie').append(
                            '<option value="">Sélectionner une sous-catégorie</option>');

                        // Ajouter les sous-catégories au select
                        $.each(response, function (index, sousCategorie) {
                            $('#sous-categorie').append('<option value="' +
                                sousCategorie.id + '">' + sousCategorie
                                    .nom_produit + '</option>');
                        });
                    },
                    error: function (xhr, status, error) {
                        // Si une erreur se produit
                        console.log('Erreur :', error);
                    }
                });
            } else {
                // Si aucune catégorie n'est sélectionnée, cacher le champ des sous-catégories et son label
                $('#label-sous-categorie').hide();
                $('#sous-categorie').hide();
            }
        });
    });
</script>

</script>

<script>
    document.addEventListener("DOMContentLoaded", function () {
        const updateFCModal = document.getElementById('update_fournisseurClient');
        updateFCModal.addEventListener('show.bs.modal', event => {
            const button = event.relatedTarget;

            const fcId = button.getAttribute('data-id');
            const fcName = button.getAttribute('data-name');
            const fcEmail = button.getAttribute('data-email');
            const fcContact = button.getAttribute('data-tele');
            const fcVille = button.getAttribute('data-ville');
            const fcSociety = button.getAttribute('data-society');
            const fcGSM1 = button.getAttribute('data-GSM1');
            const fcGSM2 = button.getAttribute('data-GSM2');
            const fcLien = button.getAttribute('data-lien');
            const fcCategory = button.getAttribute('data-category')

            document.getElementById('updateFCId').value = fcId;
            document.getElementById('updateFCName').value = fcName;
            document.getElementById('updateFCEmail').value = fcEmail;
            document.getElementById('updateFCContact').value = fcContact;
            document.getElementById('updateFCVille').value = fcVille;
            document.getElementById('updateFCSociety').value = fcSociety;
            document.getElementById('updateFCGSM1').value = fcGSM1;
            document.getElementById('updateFCGSM2').value = fcGSM2;
            document.getElementById('updateFCLien').value = fcLien;
            document.getElementById('updateFCCategory').value = fcCategory;


        });
    });
</script>
<script>
    document.addEventListener('DOMContentLoaded', function () {
        const selects = document.querySelectorAll('.status-select');
        selects.forEach(select => {
            select.addEventListener('change', function () {
                const form = this.closest('.fc-form');
                if (form) {
                    form.submit();
                }
            });
        });
    });
</script>
<script>
    document.addEventListener('DOMContentLoaded', function () {
        const selects = document.querySelectorAll('.userSelect'); // Sélectionne tous les selects
        selects.forEach(select => {
            select.addEventListener('change', function () {
                const form = this.closest(
                    '.user-form'); // Trouve le formulaire correspondant
                if (form) {
                    form.submit();
                }
            });
        });
    });
</script>

<script>
    function confirmDelete(fcId) {
        Swal.fire({
            title: 'Supprimer le fournisseur-client !',
            text: "êtes-vous sûr que vous voulez supprimer ce fournisseur-client ?",
            icon: 'warning',
            showCancelButton: true,
            confirmButtonColor: '#d33',
            cancelButtonColor: '#3085d6',
            cancelButtonText: 'Annuler',
            confirmButtonText: 'Oui, Supprimer-le !'
        }).then((result) => {
    if (result.isConfirmed) {
        document.getElementById('delete-form-' + fcId).submit();
        
        Swal.fire(
            "Supprimé !",
            "Le fournisseur-client a été supprimé avec succès.",
            "success"
        );
    }
});

    }
</script>

<script>
    document.querySelectorAll(`.detailButton`).forEach(button => {

        button.addEventListener('click', function () {
            const fcId = this.getAttribute('data-bs-target').split('-').pop();
            const fcName = this.getAttribute('data-name') || 'Non disponible'
            const fcEmail = this.getAttribute('data-email') || 'Non disponible'
            const fcContact = this.getAttribute('data-tele') || 'Non disponible'
            const fcVille = this.getAttribute('data-ville')
            const fcSociety = this.getAttribute('data-society-name')
            const fcGSM1 = this.getAttribute('data-GSM1')
            const fcGSM2 = this.getAttribute('data-GSM2')
            const fcLien = this.getAttribute('data-lien')
            const fcRemark = this.getAttribute('data-remark')
            const fcUser = this.getAttribute('data-user')

            document.querySelector(`#showNameDetail-${fcId}`).innerText = fcName
            document.querySelector(`#showEmailDetail-${fcId}`).innerText = fcEmail
            document.querySelector(`#showContactDetail-${fcId}`).innerText = fcContact
            document.querySelector(`#showVilleDetail-${fcId}`).innerText = fcVille
            document.querySelector(`#showSocietyDetail-${fcId}`).innerText = fcSociety
            document.querySelector(`#showGSM1Detail-${fcId}`).innerText = fcGSM1
            document.querySelector(`#showGSM2Detail-${fcId}`).innerText = fcGSM2
            document.querySelector(`#showLienDetail-${fcId}`).innerText = fcLien
            document.querySelector(`#showRemarkDetail-${fcId}`).innerText = fcRemark
            document.querySelector(`#showUserDetail-${fcId}`).innerText = fcUser
        })
    });

    document.addEventListener('DOMContentLoaded', function () {

        const categories = <?php echo json_encode($categories, 15, 512) ?>;
        // console.log(categories);

        document.querySelectorAll('.showCategoryfc').forEach(selectCategory => {
            const fcId = selectCategory.id.split('-').pop();
            const products = document.getElementById(`products-${fcId}`);


            if (products) {
                selectCategory.addEventListener('change', function () {
                    const selectedCategoryId = this.value;
                    products.innerHTML = '';

                    if (selectedCategoryId) {
                        const selectedCategory = categories.find(category => {
                            return category.id == selectedCategoryId;
                        });

                        if (selectedCategory && selectedCategory.sous_categories.length > 0) {
                            selectedCategory.sous_categories.forEach(sous_category => {
                                const option = document.createElement('option');
                                option.value = sous_category.id;
                                option.textContent = sous_category.nom_produit;
                                option.selected = true;
                                option.disabled = true;

                                products.appendChild(option);
                            });
                        } else {
                            const emptyOption = document.createElement('option');
                            emptyOption.textContent = 'Aucun produit trouvé';
                            emptyOption.disabled = true;
                            products.appendChild(emptyOption);
                        }
                    }
                });
            }
        });
    });
</script>

<script>
    function searchClientFournisseur() {
        let input = document.getElementById('searchInput');
        let filter = input.value.toLowerCase();
        let table = document.getElementById('fc-table');
        let tr = table.getElementsByTagName('tr');


        for (let i = 1; i < tr.length; i++) {
            let tds = tr[i].getElementsByTagName('td');
            let matchFound = false;


            for (let j = 0; j < tds.length; j++) {
                let td = tds[j];
                if (td) {
                    if (td.textContent.toLowerCase().includes(filter)) {
                        matchFound = true;
                        break;
                    }
                }
            }


            if (matchFound) {
                tr[i].style.display = '';
            } else {
                tr[i].style.display = 'none';
            }
        }
    }
</script>

<?php $__env->stopSection(); ?>
<?php $__env->startSection('content2'); ?>
    <div class="modal fade" id="QueryFournisseurClientsDetails" tabindex="-1" aria-labelledby="exampleModalLabel"
        aria-hidden="true">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
                </div>
                <div class="modal-body">
                    <div class="show-info-fournisseurClient show-society">
                        <label class="label-detail-fournisseurClient">Nom de la société</label>
                        <h6 class="info-fournisseurClient" id="showSocietyfc">
                        </h6>
                    </div>
                    <div class="show-info-fournisseurClient show-society">
                        <label class="label-detail-fournisseurClient">GSM1 de la société</label>
                        <h6 class="info-fournisseurClient" id="showGSM1fc">
                        </h6>
                    </div>
                    <div class="show-info-fournisseurClient show-society">
                        <label class="label-detail-fournisseurClient">GSM2 de la société</label>
                        <h6 class="info-fournisseurClient" id="showGSM2fc">
                        </h6>
                    </div>
                    <div class="show-info-fournisseurClient show-name">
                        <label class="label-detail-fournisseurClient">Personne à contacter</label>
                        <h6 class="info-fournisseurClient" id="showNamefc"></h6>
                    </div>
                    <div class="show-info-fournisseurClient show-contact">
                        <label class="label-detail-fournisseurClient">Numero De Telephone</label>
                        <h6 class="info-fournisseurClient" id="showContactfc"></h6>
                    </div>
                    <div class="show-info-fournisseurClient show-email">
                        <label class="label-detail-fournisseurClient">Email</label>
                        <h6 class="info-fournisseurClient" id="showEmailfc">
                        </h6>
                    </div>

                    <div class="show-info-fournisseurClient show-society">
                        <label class="label-detail-fournisseurClient">Lien de la société</label>
                        <h6 class="info-fournisseurClient" id="showLienfc">
                        </h6>
                    </div>

                    <div class="show-info-fournisseurClient show-ville">
                        <label class="label-detail-fournisseurClient">Ville</label>
                        <h6 class="info-fournisseurClient" id="showVillefc">
                        </h6>
                    </div>
                    <div class="show-info-fournisseurClient show-category" style="margin-top:10px">
                        <label class="label-detail-fournisseurClient">Les catégories</label>
                        <select class="form-select form-select-sm info-fournisseurClient showCategoryfc"
                            aria-label=".form-select-sm example" style="width: 200px; height: 30px"
                            id="categoriesQuery-1">
                            <option value="" selected>Voir la(les) catégories</option>

                        </select>
                    </div>

                    <div class="show-info-fournisseurClient show-product" style="margin-bottom: 40px; margin-top:10px">
                        <label class="form-label label-detail-fournisseurClient">Sous-Catégorie</label>
                        <select class="form-select form-select-sm info-fournisseurClient showProductfc"
                            aria-label=".form-select-sm example" id="productsQuery-1" style="width: 200px; height: 30px">

                        </select>
                    </div>
                    <div class="show-info-fournisseurClient show-user">
                        <label class="label-detail-fournisseurClient">Contacté Par</label>
                        <h6 class="info-fournisseurClient" id="showUserfc">
                        </h6>
                    </div>

                    <div class="show-info-fournisseurClient show-remark">
                        <label class="label-detail-fournisseurClient">Remarque</label>
                        <p class="info-fournisseurClient" id="showRemarkfc" style="font-size: 12px">
                        </p>
                    </div>


                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Fermer</button>
                </div>
            </div>
        </div>
    </div>
<?php $__env->stopSection(); ?>

<?php echo $__env->make('myApp.admin.adminLayout.adminPage', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?><?php /**PATH /home/nettoyagecasabla/fournisseurs.materiel-levage-maroc.com/resources/views/myApp/admin/links/clientFournisseur.blade.php ENDPATH**/ ?>