var/cache/dev/twig/cb/cbd8b7a89d81c1fd98d462db501ec9b3e6a07289ad209a8743f64ffa4923d461.php line 212

Open in your IDE?
  1. <?php
  2. use Twig\Environment;
  3. use Twig\Error\LoaderError;
  4. use Twig\Error\RuntimeError;
  5. use Twig\Extension\SandboxExtension;
  6. use Twig\Markup;
  7. use Twig\Sandbox\SecurityError;
  8. use Twig\Sandbox\SecurityNotAllowedTagError;
  9. use Twig\Sandbox\SecurityNotAllowedFilterError;
  10. use Twig\Sandbox\SecurityNotAllowedFunctionError;
  11. use Twig\Source;
  12. use Twig\Template;
  13. /* @SyliusAdmin/Vingeanne/files_list.html.twig */
  14. class __TwigTemplate_2de44eae96777535f476bc6fdd130784fd9141cbd489e0e776032a98204a91f4 extends \Twig\Template
  15. {
  16.     private $source;
  17.     private $macros = [];
  18.     public function __construct(Environment $env)
  19.     {
  20.         parent::__construct($env);
  21.         $this->source $this->getSourceContext();
  22.         $this->blocks = [
  23.             'content' => [$this'block_content'],
  24.             'javascripts' => [$this'block_javascripts'],
  25.         ];
  26.     }
  27.     protected function doGetParent(array $context)
  28.     {
  29.         // line 1
  30.         return "@SyliusAdmin/layout.html.twig";
  31.     }
  32.     protected function doDisplay(array $context, array $blocks = [])
  33.     {
  34.         $macros $this->macros;
  35.         $__internal_085b0142806202599c7fe3b329164a92397d8978207a37e79d70b8c52599e33e $this->extensions["Symfony\\Bundle\\WebProfilerBundle\\Twig\\WebProfilerExtension"];
  36.         $__internal_085b0142806202599c7fe3b329164a92397d8978207a37e79d70b8c52599e33e->enter($__internal_085b0142806202599c7fe3b329164a92397d8978207a37e79d70b8c52599e33e_prof = new \Twig\Profiler\Profile($this->getTemplateName(), "template""@SyliusAdmin/Vingeanne/files_list.html.twig"));
  37.         $__internal_319393461309892924ff6e74d6d6e64287df64b63545b994e100d4ab223aed02 $this->extensions["Symfony\\Bridge\\Twig\\Extension\\ProfilerExtension"];
  38.         $__internal_319393461309892924ff6e74d6d6e64287df64b63545b994e100d4ab223aed02->enter($__internal_319393461309892924ff6e74d6d6e64287df64b63545b994e100d4ab223aed02_prof = new \Twig\Profiler\Profile($this->getTemplateName(), "template""@SyliusAdmin/Vingeanne/files_list.html.twig"));
  39.         $this->parent $this->loadTemplate("@SyliusAdmin/layout.html.twig""@SyliusAdmin/Vingeanne/files_list.html.twig"1);
  40.         $this->parent->display($contextarray_merge($this->blocks$blocks));
  41.         
  42.         $__internal_085b0142806202599c7fe3b329164a92397d8978207a37e79d70b8c52599e33e->leave($__internal_085b0142806202599c7fe3b329164a92397d8978207a37e79d70b8c52599e33e_prof);
  43.         
  44.         $__internal_319393461309892924ff6e74d6d6e64287df64b63545b994e100d4ab223aed02->leave($__internal_319393461309892924ff6e74d6d6e64287df64b63545b994e100d4ab223aed02_prof);
  45.     }
  46.     // line 3
  47.     public function block_content($context, array $blocks = [])
  48.     {
  49.         $macros $this->macros;
  50.         $__internal_085b0142806202599c7fe3b329164a92397d8978207a37e79d70b8c52599e33e $this->extensions["Symfony\\Bundle\\WebProfilerBundle\\Twig\\WebProfilerExtension"];
  51.         $__internal_085b0142806202599c7fe3b329164a92397d8978207a37e79d70b8c52599e33e->enter($__internal_085b0142806202599c7fe3b329164a92397d8978207a37e79d70b8c52599e33e_prof = new \Twig\Profiler\Profile($this->getTemplateName(), "block""content"));
  52.         $__internal_319393461309892924ff6e74d6d6e64287df64b63545b994e100d4ab223aed02 $this->extensions["Symfony\\Bridge\\Twig\\Extension\\ProfilerExtension"];
  53.         $__internal_319393461309892924ff6e74d6d6e64287df64b63545b994e100d4ab223aed02->enter($__internal_319393461309892924ff6e74d6d6e64287df64b63545b994e100d4ab223aed02_prof = new \Twig\Profiler\Profile($this->getTemplateName(), "block""content"));
  54.         // line 4
  55.         echo "    <div class=\"ui stackable two column grid\">
  56.         <div class=\"ten wide column\">
  57.             <h1 class=\"ui header\">
  58.                 <i class=\"circular folder open outline icon\"></i>
  59.                 <div class=\"content\">
  60.                     Fichiers Archive Vingeanne
  61.                 </div>
  62.             </h1>
  63.             <div class=\"ui breadcrumb\">
  64.                 <a href=\"/admin/\" class=\"section\">Admin</a>
  65.                 <i class=\"right chevron icon divider\"></i>
  66.                 <a href=\"/admin/vingeanne\" class=\"section\">Vingeanne</a>
  67.                 <i class=\"right chevron icon divider\"></i>
  68.                 <div class=\"active section\">Fichiers Archive</div>
  69.             </div>
  70.         </div>
  71.         <div class=\"six wide right aligned column\">
  72.         </div>
  73.     </div>
  74.     ";
  75.         // line 25
  76.         echo "    <div class=\"ui segment\" style=\"margin-top: 20px;\">
  77.         <h3 class=\"ui dividing header\">
  78.             <i class=\"filter icon\"></i>
  79.             Filtres
  80.         </h3>
  81.         
  82.         <form id=\"filter-form\" class=\"ui form\">
  83.             <div class=\"four fields\">
  84.                 <div class=\"field\">
  85.                     <label>Type de fichier</label>
  86.                     <div class=\"ui dropdown\" id=\"filter-type\">
  87.                         <input type=\"hidden\" name=\"type\">
  88.                         <i class=\"dropdown icon\"></i>
  89.                         <div class=\"default text\">Tous les types</div>
  90.                         <div class=\"menu\">
  91.                             <div class=\"item active selected\" data-value=\"TOUS\">Tous les types</div>
  92.                             <div class=\"item\" data-value=\"REA\">REA (Réassort)</div>
  93.                             <div class=\"item\" data-value=\"OFF\">OFF (Office)</div>
  94.                             <div class=\"item\" data-value=\"INCONNU\">Inconnu</div>
  95.                         </div>
  96.                     </div>
  97.                 </div>
  98.                 <div class=\"field\">
  99.                     <label>Nom du fichier</label>
  100.                     <input type=\"text\" id=\"filter-name\" placeholder=\"Rechercher...\" />
  101.                 </div>
  102.                 <div class=\"field\">
  103.                     <label>Date de</label>
  104.                     <input type=\"date\" id=\"filter-date-from\" />
  105.                 </div>
  106.                 <div class=\"field\">
  107.                     <label>Date à</label>
  108.                     <input type=\"date\" id=\"filter-date-to\" />
  109.                 </div>
  110.             </div>
  111.             <div class=\"field\">
  112.                 <button type=\"submit\" class=\"ui primary button\">
  113.                     <i class=\"search icon\"></i>
  114.                     Rechercher
  115.                 </button>
  116.                 <button type=\"button\" id=\"reset-filters\" class=\"ui button\">
  117.                     <i class=\"redo icon\"></i>
  118.                     Réinitialiser
  119.                 </button>
  120.             </div>
  121.         </form>
  122.     </div>
  123.     ";
  124.         // line 74
  125.         echo "    <div id=\"results-section\" style=\"margin-top: 20px;\">
  126.         <div class=\"ui segment\">
  127.             <h4 class=\"ui dividing header\">
  128.                 Résultats
  129.                 <span id=\"result-count\" class=\"ui label\"></span>
  130.             </h4>
  131.             
  132.             ";
  133.         // line 82
  134.         echo "            <div id=\"loading-indicator\" style=\"display: none;\">
  135.                 <div class=\"ui active centered inline loader\"></div>
  136.                 <p style=\"text-align: center; margin-top: 10px;\">Chargement des fichiers...</p>
  137.             </div>
  138.             ";
  139.         // line 88
  140.         echo "            <div class=\"ui segment spaceless sylius-grid-table-wrapper\" style=\"overflow-x: auto;\">
  141.                 <table id=\"files-table\" class=\"ui sortable stackable very basic celled table\">
  142.                     <thead>
  143.                         <tr>
  144.                             <th>Type</th>
  145.                             <th>Nom du fichier</th>
  146.                             <th>Date de création</th>
  147.                             <th>Taille</th>
  148.                             <th>Actions</th>
  149.                         </tr>
  150.                     </thead>
  151.                     <tbody id=\"files-table-body\">
  152.                         <tr>
  153.                             <td colspan=\"5\" class=\"center aligned\">
  154.                                 <div class=\"ui icon message\">
  155.                                     <i class=\"circle notched loading icon\"></i>
  156.                                     <div class=\"content\">
  157.                                         <div class=\"header\">
  158.                                             Chargement des données...
  159.                                         </div>
  160.                                     </div>
  161.                                 </div>
  162.                             </td>
  163.                         </tr>
  164.                     </tbody>
  165.                 </table>
  166.             </div>
  167.             ";
  168.         // line 117
  169.         echo "            <div id=\"pagination-container\" style=\"margin-top: 20px; text-align: center;\"></div>
  170.         </div>
  171.     </div>
  172. ";
  173.         
  174.         $__internal_319393461309892924ff6e74d6d6e64287df64b63545b994e100d4ab223aed02->leave($__internal_319393461309892924ff6e74d6d6e64287df64b63545b994e100d4ab223aed02_prof);
  175.         
  176.         $__internal_085b0142806202599c7fe3b329164a92397d8978207a37e79d70b8c52599e33e->leave($__internal_085b0142806202599c7fe3b329164a92397d8978207a37e79d70b8c52599e33e_prof);
  177.     }
  178.     // line 123
  179.     public function block_javascripts($context, array $blocks = [])
  180.     {
  181.         $macros $this->macros;
  182.         $__internal_085b0142806202599c7fe3b329164a92397d8978207a37e79d70b8c52599e33e $this->extensions["Symfony\\Bundle\\WebProfilerBundle\\Twig\\WebProfilerExtension"];
  183.         $__internal_085b0142806202599c7fe3b329164a92397d8978207a37e79d70b8c52599e33e->enter($__internal_085b0142806202599c7fe3b329164a92397d8978207a37e79d70b8c52599e33e_prof = new \Twig\Profiler\Profile($this->getTemplateName(), "block""javascripts"));
  184.         $__internal_319393461309892924ff6e74d6d6e64287df64b63545b994e100d4ab223aed02 $this->extensions["Symfony\\Bridge\\Twig\\Extension\\ProfilerExtension"];
  185.         $__internal_319393461309892924ff6e74d6d6e64287df64b63545b994e100d4ab223aed02->enter($__internal_319393461309892924ff6e74d6d6e64287df64b63545b994e100d4ab223aed02_prof = new \Twig\Profiler\Profile($this->getTemplateName(), "block""javascripts"));
  186.         // line 124
  187.         echo "    ";
  188.         $this->displayParentBlock("javascripts"$context$blocks);
  189.         echo "
  190.     
  191.     <script>
  192.         (function() {
  193.             // Wait for jQuery to be available
  194.             function initVingeanneModule() {
  195.                 if (typeof jQuery === 'undefined') {
  196.                     console.error('jQuery is not loaded! Retrying in 100ms...');
  197.                     setTimeout(initVingeanneModule, 100);
  198.                     return;
  199.                 }
  200.                 jQuery(document).ready(function(\$) {
  201.                     console.log('Vingeanne Module initialized');
  202.                     let currentPage = 1;
  203.                     let currentFilters = {};
  204.                     // Initialize dropdowns
  205.                     \$('.ui.dropdown').dropdown();
  206.                     // Auto-load data on page load
  207.                     loadFiles(1);
  208.                     // Filter form submission
  209.                     \$('#filter-form').on('submit', function(e) {
  210.                         e.preventDefault();
  211.                         currentPage = 1;
  212.                         loadFiles(1);
  213.                     });
  214.                     // Reset filters
  215.                     \$('#reset-filters').on('click', function() {
  216.                         \$('#filter-form')[0].reset();
  217.                         \$('.ui.dropdown').dropdown('clear');
  218.                         currentPage = 1;
  219.                         currentFilters = {};
  220.                         loadFiles(1);
  221.                     });
  222.                     // Load files function
  223.                     function loadFiles(page) {
  224.                         console.log('Loading files for page:', page);
  225.                         currentPage = page;
  226.                         \$('#loading-indicator').show();
  227.                         
  228.                         currentFilters = {
  229.                             type: \$('#filter-type').dropdown('get value') || 'TOUS',
  230.                             name: \$('#filter-name').val(),
  231.                             dateFrom: \$('#filter-date-from').val(),
  232.                             dateTo: \$('#filter-date-to').val(),
  233.                             page: page,
  234.                             limit: 50
  235.                         };
  236.                         // Remove empty values
  237.                         Object.keys(currentFilters).forEach(function(key) {
  238.                             if (currentFilters[key] === '' || currentFilters[key] === null) {
  239.                                 delete currentFilters[key];
  240.                             }
  241.                         });
  242.                         console.log('Filters:', currentFilters);
  243.                         \$.ajax({
  244.                             url: '/admin/vingeanne/files/load',
  245.                             method: 'GET',
  246.                             data: currentFilters,
  247.                             dataType: 'json',
  248.                             success: function(response) {
  249.                                 console.log('Response received:', response);
  250.                                 \$('#loading-indicator').hide();
  251.                                 
  252.                                 if (response.success) {
  253.                                     renderTable(response.data);
  254.                                     renderPagination(response.pagination);
  255.                                     \$('#result-count').text(response.pagination.total + ' fichier(s)');
  256.                                 } else {
  257.                                     console.error('API error:', response.error);
  258.                                     alert('Erreur: ' + response.error);
  259.                                 }
  260.                             },
  261.                             error: function(xhr, status, error) {
  262.                                 console.error('AJAX error:', status, error, xhr.responseText);
  263.                                 \$('#loading-indicator').hide();
  264.                                 alert('Erreur lors du chargement des fichiers: ' + error);
  265.                             }
  266.                         });
  267.                     }
  268.                     // Render table function
  269.                     function renderTable(data) {
  270.                         console.log('Rendering table with', data.length, 'files');
  271.                         const tbody = \$('#files-table-body');
  272.                         tbody.empty();
  273.                         if (data.length === 0) {
  274.                             tbody.append(
  275.                                 '<tr>' +
  276.                                 '<td colspan=\"5\" class=\"center aligned\">' +
  277.                                 '<div class=\"ui icon message\">' +
  278.                                 '<i class=\"inbox icon\"></i>' +
  279.                                 '<div class=\"content\">' +
  280.                                 '<div class=\"header\">Aucun fichier trouvé</div>' +
  281.                                 '<p>Essayez de modifier vos critères de recherche</p>' +
  282.                                 '</div>' +
  283.                                 '</div>' +
  284.                                 '</td>' +
  285.                                 '</tr>'
  286.                             );
  287.                             return;
  288.                         }
  289.                         data.forEach(function(file) {
  290.                             let typeClass = '';
  291.                             let typeIcon = 'file icon';
  292.                             let typeLabel = file.type;
  293.                             
  294.                             if (file.type === 'REA') {
  295.                                 typeClass = 'green';
  296.                                 typeIcon = 'refresh icon';
  297.                             } else if (file.type === 'OFF') {
  298.                                 typeClass = 'blue';
  299.                                 typeIcon = 'file alternate icon';
  300.                             } else {
  301.                                 typeClass = 'grey';
  302.                                 typeIcon = 'question icon';
  303.                             }
  304.                             
  305.                             const row = 
  306.                                 '<tr>' +
  307.                                 '<td><span class=\"ui ' + typeClass + ' label\"><i class=\"' + typeIcon + '\"></i> ' + typeLabel + '</span></td>' +
  308.                                 '<td><strong>' + (file.name || '') + '</strong></td>' +
  309.                                 '<td>' + (file.createdAt || 'N/A') + '</td>' +
  310.                                 '<td>' + (file.size || 'N/A') + '</td>' +
  311.                                 '<td>' +
  312.                                 '<a href=\"/admin/vingeanne/files/download/' + encodeURIComponent(file.name) + '\" class=\"ui small primary labeled icon button\">' +
  313.                                 '<i class=\"download icon\"></i> Télécharger' +
  314.                                 '</a>' +
  315.                                 '</td>' +
  316.                                 '</tr>';
  317.                             tbody.append(row);
  318.                         });
  319.                         
  320.                         console.log('Table rendered successfully');
  321.                     }
  322.                     // Render pagination function
  323.                     function renderPagination(pagination) {
  324.                         console.log('Rendering pagination:', pagination);
  325.                         const paginationContainer = \$('#pagination-container');
  326.                         paginationContainer.empty();
  327.                         if (pagination.pages <= 1) {
  328.                             return;
  329.                         }
  330.                         let html = '<div class=\"ui pagination menu\">';
  331.                         if (pagination.page > 1) {
  332.                             html += '<a class=\"icon item\" data-page=\"' + (pagination.page - 1) + '\"><i class=\"left chevron icon\"></i></a>';
  333.                         } else {
  334.                             html += '<a class=\"icon item disabled\"><i class=\"left chevron icon\"></i></a>';
  335.                         }
  336.                         const maxPages = 10;
  337.                         let startPage = Math.max(1, pagination.page - Math.floor(maxPages / 2));
  338.                         let endPage = Math.min(pagination.pages, startPage + maxPages - 1);
  339.                         if (endPage - startPage < maxPages - 1) {
  340.                             startPage = Math.max(1, endPage - maxPages + 1);
  341.                         }
  342.                         for (let i = startPage; i <= endPage; i++) {
  343.                             if (i === pagination.page) {
  344.                                 html += '<a class=\"item active\">' + i + '</a>';
  345.                             } else {
  346.                                 html += '<a class=\"item\" data-page=\"' + i + '\">' + i + '</a>';
  347.                             }
  348.                         }
  349.                         if (pagination.page < pagination.pages) {
  350.                             html += '<a class=\"icon item\" data-page=\"' + (pagination.page + 1) + '\"><i class=\"right chevron icon\"></i></a>';
  351.                         } else {
  352.                             html += '<a class=\"icon item disabled\"><i class=\"right chevron icon\"></i></a>';
  353.                         }
  354.                         html += '</div>';
  355.                         paginationContainer.html(html);
  356.                         paginationContainer.find('a.item:not(.disabled):not(.active)').on('click', function() {
  357.                             const page = \$(this).data('page');
  358.                             if (page) {
  359.                                 loadFiles(page);
  360.                                 \$('html, body').animate({
  361.                                     scrollTop: \$('#results-section').offset().top - 100
  362.                                 }, 300);
  363.                             }
  364.                         });
  365.                     }
  366.                 });
  367.             }
  368.             // Start initialization
  369.             initVingeanneModule();
  370.         })();
  371.     </script>
  372.     <style>
  373.         #files-table {
  374.             font-size: 0.9em;
  375.         }
  376.         #files-table th {
  377.             white-space: nowrap;
  378.         }
  379.         #files-table td {
  380.             white-space: normal;
  381.         }
  382.     </style>
  383. ";
  384.         
  385.         $__internal_319393461309892924ff6e74d6d6e64287df64b63545b994e100d4ab223aed02->leave($__internal_319393461309892924ff6e74d6d6e64287df64b63545b994e100d4ab223aed02_prof);
  386.         
  387.         $__internal_085b0142806202599c7fe3b329164a92397d8978207a37e79d70b8c52599e33e->leave($__internal_085b0142806202599c7fe3b329164a92397d8978207a37e79d70b8c52599e33e_prof);
  388.     }
  389.     public function getTemplateName()
  390.     {
  391.         return "@SyliusAdmin/Vingeanne/files_list.html.twig";
  392.     }
  393.     public function isTraitable()
  394.     {
  395.         return false;
  396.     }
  397.     public function getDebugInfo()
  398.     {
  399.         return array (  211 => 124,  201 => 123,  187 => 117,  157 => 88,  150 => 82,  141 => 74,  91 => 25,  69 => 4,  59 => 3,  36 => 1,);
  400.     }
  401.     public function getSourceContext()
  402.     {
  403.         return new Source("{% extends '@SyliusAdmin/layout.html.twig' %}
  404. {% block content %}
  405.     <div class=\"ui stackable two column grid\">
  406.         <div class=\"ten wide column\">
  407.             <h1 class=\"ui header\">
  408.                 <i class=\"circular folder open outline icon\"></i>
  409.                 <div class=\"content\">
  410.                     Fichiers Archive Vingeanne
  411.                 </div>
  412.             </h1>
  413.             <div class=\"ui breadcrumb\">
  414.                 <a href=\"/admin/\" class=\"section\">Admin</a>
  415.                 <i class=\"right chevron icon divider\"></i>
  416.                 <a href=\"/admin/vingeanne\" class=\"section\">Vingeanne</a>
  417.                 <i class=\"right chevron icon divider\"></i>
  418.                 <div class=\"active section\">Fichiers Archive</div>
  419.             </div>
  420.         </div>
  421.         <div class=\"six wide right aligned column\">
  422.         </div>
  423.     </div>
  424.     {# Filters Section #}
  425.     <div class=\"ui segment\" style=\"margin-top: 20px;\">
  426.         <h3 class=\"ui dividing header\">
  427.             <i class=\"filter icon\"></i>
  428.             Filtres
  429.         </h3>
  430.         
  431.         <form id=\"filter-form\" class=\"ui form\">
  432.             <div class=\"four fields\">
  433.                 <div class=\"field\">
  434.                     <label>Type de fichier</label>
  435.                     <div class=\"ui dropdown\" id=\"filter-type\">
  436.                         <input type=\"hidden\" name=\"type\">
  437.                         <i class=\"dropdown icon\"></i>
  438.                         <div class=\"default text\">Tous les types</div>
  439.                         <div class=\"menu\">
  440.                             <div class=\"item active selected\" data-value=\"TOUS\">Tous les types</div>
  441.                             <div class=\"item\" data-value=\"REA\">REA (Réassort)</div>
  442.                             <div class=\"item\" data-value=\"OFF\">OFF (Office)</div>
  443.                             <div class=\"item\" data-value=\"INCONNU\">Inconnu</div>
  444.                         </div>
  445.                     </div>
  446.                 </div>
  447.                 <div class=\"field\">
  448.                     <label>Nom du fichier</label>
  449.                     <input type=\"text\" id=\"filter-name\" placeholder=\"Rechercher...\" />
  450.                 </div>
  451.                 <div class=\"field\">
  452.                     <label>Date de</label>
  453.                     <input type=\"date\" id=\"filter-date-from\" />
  454.                 </div>
  455.                 <div class=\"field\">
  456.                     <label>Date à</label>
  457.                     <input type=\"date\" id=\"filter-date-to\" />
  458.                 </div>
  459.             </div>
  460.             <div class=\"field\">
  461.                 <button type=\"submit\" class=\"ui primary button\">
  462.                     <i class=\"search icon\"></i>
  463.                     Rechercher
  464.                 </button>
  465.                 <button type=\"button\" id=\"reset-filters\" class=\"ui button\">
  466.                     <i class=\"redo icon\"></i>
  467.                     Réinitialiser
  468.                 </button>
  469.             </div>
  470.         </form>
  471.     </div>
  472.     {# Results Section #}
  473.     <div id=\"results-section\" style=\"margin-top: 20px;\">
  474.         <div class=\"ui segment\">
  475.             <h4 class=\"ui dividing header\">
  476.                 Résultats
  477.                 <span id=\"result-count\" class=\"ui label\"></span>
  478.             </h4>
  479.             
  480.             {# Loading Indicator #}
  481.             <div id=\"loading-indicator\" style=\"display: none;\">
  482.                 <div class=\"ui active centered inline loader\"></div>
  483.                 <p style=\"text-align: center; margin-top: 10px;\">Chargement des fichiers...</p>
  484.             </div>
  485.             {# Table #}
  486.             <div class=\"ui segment spaceless sylius-grid-table-wrapper\" style=\"overflow-x: auto;\">
  487.                 <table id=\"files-table\" class=\"ui sortable stackable very basic celled table\">
  488.                     <thead>
  489.                         <tr>
  490.                             <th>Type</th>
  491.                             <th>Nom du fichier</th>
  492.                             <th>Date de création</th>
  493.                             <th>Taille</th>
  494.                             <th>Actions</th>
  495.                         </tr>
  496.                     </thead>
  497.                     <tbody id=\"files-table-body\">
  498.                         <tr>
  499.                             <td colspan=\"5\" class=\"center aligned\">
  500.                                 <div class=\"ui icon message\">
  501.                                     <i class=\"circle notched loading icon\"></i>
  502.                                     <div class=\"content\">
  503.                                         <div class=\"header\">
  504.                                             Chargement des données...
  505.                                         </div>
  506.                                     </div>
  507.                                 </div>
  508.                             </td>
  509.                         </tr>
  510.                     </tbody>
  511.                 </table>
  512.             </div>
  513.             {# Pagination #}
  514.             <div id=\"pagination-container\" style=\"margin-top: 20px; text-align: center;\"></div>
  515.         </div>
  516.     </div>
  517. {% endblock %}
  518. {% block javascripts %}
  519.     {{ parent() }}
  520.     
  521.     <script>
  522.         (function() {
  523.             // Wait for jQuery to be available
  524.             function initVingeanneModule() {
  525.                 if (typeof jQuery === 'undefined') {
  526.                     console.error('jQuery is not loaded! Retrying in 100ms...');
  527.                     setTimeout(initVingeanneModule, 100);
  528.                     return;
  529.                 }
  530.                 jQuery(document).ready(function(\$) {
  531.                     console.log('Vingeanne Module initialized');
  532.                     let currentPage = 1;
  533.                     let currentFilters = {};
  534.                     // Initialize dropdowns
  535.                     \$('.ui.dropdown').dropdown();
  536.                     // Auto-load data on page load
  537.                     loadFiles(1);
  538.                     // Filter form submission
  539.                     \$('#filter-form').on('submit', function(e) {
  540.                         e.preventDefault();
  541.                         currentPage = 1;
  542.                         loadFiles(1);
  543.                     });
  544.                     // Reset filters
  545.                     \$('#reset-filters').on('click', function() {
  546.                         \$('#filter-form')[0].reset();
  547.                         \$('.ui.dropdown').dropdown('clear');
  548.                         currentPage = 1;
  549.                         currentFilters = {};
  550.                         loadFiles(1);
  551.                     });
  552.                     // Load files function
  553.                     function loadFiles(page) {
  554.                         console.log('Loading files for page:', page);
  555.                         currentPage = page;
  556.                         \$('#loading-indicator').show();
  557.                         
  558.                         currentFilters = {
  559.                             type: \$('#filter-type').dropdown('get value') || 'TOUS',
  560.                             name: \$('#filter-name').val(),
  561.                             dateFrom: \$('#filter-date-from').val(),
  562.                             dateTo: \$('#filter-date-to').val(),
  563.                             page: page,
  564.                             limit: 50
  565.                         };
  566.                         // Remove empty values
  567.                         Object.keys(currentFilters).forEach(function(key) {
  568.                             if (currentFilters[key] === '' || currentFilters[key] === null) {
  569.                                 delete currentFilters[key];
  570.                             }
  571.                         });
  572.                         console.log('Filters:', currentFilters);
  573.                         \$.ajax({
  574.                             url: '/admin/vingeanne/files/load',
  575.                             method: 'GET',
  576.                             data: currentFilters,
  577.                             dataType: 'json',
  578.                             success: function(response) {
  579.                                 console.log('Response received:', response);
  580.                                 \$('#loading-indicator').hide();
  581.                                 
  582.                                 if (response.success) {
  583.                                     renderTable(response.data);
  584.                                     renderPagination(response.pagination);
  585.                                     \$('#result-count').text(response.pagination.total + ' fichier(s)');
  586.                                 } else {
  587.                                     console.error('API error:', response.error);
  588.                                     alert('Erreur: ' + response.error);
  589.                                 }
  590.                             },
  591.                             error: function(xhr, status, error) {
  592.                                 console.error('AJAX error:', status, error, xhr.responseText);
  593.                                 \$('#loading-indicator').hide();
  594.                                 alert('Erreur lors du chargement des fichiers: ' + error);
  595.                             }
  596.                         });
  597.                     }
  598.                     // Render table function
  599.                     function renderTable(data) {
  600.                         console.log('Rendering table with', data.length, 'files');
  601.                         const tbody = \$('#files-table-body');
  602.                         tbody.empty();
  603.                         if (data.length === 0) {
  604.                             tbody.append(
  605.                                 '<tr>' +
  606.                                 '<td colspan=\"5\" class=\"center aligned\">' +
  607.                                 '<div class=\"ui icon message\">' +
  608.                                 '<i class=\"inbox icon\"></i>' +
  609.                                 '<div class=\"content\">' +
  610.                                 '<div class=\"header\">Aucun fichier trouvé</div>' +
  611.                                 '<p>Essayez de modifier vos critères de recherche</p>' +
  612.                                 '</div>' +
  613.                                 '</div>' +
  614.                                 '</td>' +
  615.                                 '</tr>'
  616.                             );
  617.                             return;
  618.                         }
  619.                         data.forEach(function(file) {
  620.                             let typeClass = '';
  621.                             let typeIcon = 'file icon';
  622.                             let typeLabel = file.type;
  623.                             
  624.                             if (file.type === 'REA') {
  625.                                 typeClass = 'green';
  626.                                 typeIcon = 'refresh icon';
  627.                             } else if (file.type === 'OFF') {
  628.                                 typeClass = 'blue';
  629.                                 typeIcon = 'file alternate icon';
  630.                             } else {
  631.                                 typeClass = 'grey';
  632.                                 typeIcon = 'question icon';
  633.                             }
  634.                             
  635.                             const row = 
  636.                                 '<tr>' +
  637.                                 '<td><span class=\"ui ' + typeClass + ' label\"><i class=\"' + typeIcon + '\"></i> ' + typeLabel + '</span></td>' +
  638.                                 '<td><strong>' + (file.name || '') + '</strong></td>' +
  639.                                 '<td>' + (file.createdAt || 'N/A') + '</td>' +
  640.                                 '<td>' + (file.size || 'N/A') + '</td>' +
  641.                                 '<td>' +
  642.                                 '<a href=\"/admin/vingeanne/files/download/' + encodeURIComponent(file.name) + '\" class=\"ui small primary labeled icon button\">' +
  643.                                 '<i class=\"download icon\"></i> Télécharger' +
  644.                                 '</a>' +
  645.                                 '</td>' +
  646.                                 '</tr>';
  647.                             tbody.append(row);
  648.                         });
  649.                         
  650.                         console.log('Table rendered successfully');
  651.                     }
  652.                     // Render pagination function
  653.                     function renderPagination(pagination) {
  654.                         console.log('Rendering pagination:', pagination);
  655.                         const paginationContainer = \$('#pagination-container');
  656.                         paginationContainer.empty();
  657.                         if (pagination.pages <= 1) {
  658.                             return;
  659.                         }
  660.                         let html = '<div class=\"ui pagination menu\">';
  661.                         if (pagination.page > 1) {
  662.                             html += '<a class=\"icon item\" data-page=\"' + (pagination.page - 1) + '\"><i class=\"left chevron icon\"></i></a>';
  663.                         } else {
  664.                             html += '<a class=\"icon item disabled\"><i class=\"left chevron icon\"></i></a>';
  665.                         }
  666.                         const maxPages = 10;
  667.                         let startPage = Math.max(1, pagination.page - Math.floor(maxPages / 2));
  668.                         let endPage = Math.min(pagination.pages, startPage + maxPages - 1);
  669.                         if (endPage - startPage < maxPages - 1) {
  670.                             startPage = Math.max(1, endPage - maxPages + 1);
  671.                         }
  672.                         for (let i = startPage; i <= endPage; i++) {
  673.                             if (i === pagination.page) {
  674.                                 html += '<a class=\"item active\">' + i + '</a>';
  675.                             } else {
  676.                                 html += '<a class=\"item\" data-page=\"' + i + '\">' + i + '</a>';
  677.                             }
  678.                         }
  679.                         if (pagination.page < pagination.pages) {
  680.                             html += '<a class=\"icon item\" data-page=\"' + (pagination.page + 1) + '\"><i class=\"right chevron icon\"></i></a>';
  681.                         } else {
  682.                             html += '<a class=\"icon item disabled\"><i class=\"right chevron icon\"></i></a>';
  683.                         }
  684.                         html += '</div>';
  685.                         paginationContainer.html(html);
  686.                         paginationContainer.find('a.item:not(.disabled):not(.active)').on('click', function() {
  687.                             const page = \$(this).data('page');
  688.                             if (page) {
  689.                                 loadFiles(page);
  690.                                 \$('html, body').animate({
  691.                                     scrollTop: \$('#results-section').offset().top - 100
  692.                                 }, 300);
  693.                             }
  694.                         });
  695.                     }
  696.                 });
  697.             }
  698.             // Start initialization
  699.             initVingeanneModule();
  700.         })();
  701.     </script>
  702.     <style>
  703.         #files-table {
  704.             font-size: 0.9em;
  705.         }
  706.         #files-table th {
  707.             white-space: nowrap;
  708.         }
  709.         #files-table td {
  710.             white-space: normal;
  711.         }
  712.     </style>
  713. {% endblock %}
  714. ""@SyliusAdmin/Vingeanne/files_list.html.twig""/var/www/erpdodcie/erpdodcie_api/templates/bundles/SyliusAdminBundle/Vingeanne/files_list.html.twig");
  715.     }
  716. }