<?php
/**
 * @file
 * Displays the items of the accordion.
 *
 * @ingroup views_templates
 *
 * Note that the accordion NEEDS <?php print $row ?> to be wrapped by an
 * element, or it will hide all fields on all rows under the first field.
 *
 * Also, if you use field grouping and use the headers of the groups as the
 * accordion headers, these NEED to be inside h3 tags exactly as below
 * (though you can add classes).
 *
 * The current div wraping each row gets two css classes, which should be
 * enough for most cases:
 *     "views-accordion-item"
 *      and a unique per row class like item-0
 */

?>
  <?php $class_value = 'default'; ?>
  <?php if (arg(0) != 'admin'): ?>
    <div class="assets-multiacordeon">
      <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css">
      <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
      <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js"></script>
    </div> 
  <?php endif; ?>
  <?php if (!empty($title)): ?>
    <h3 class="<?php print $view_accordion_id; ?>">
      <?php print $title; ?>
    </h3>
  <?php endif; ?>
  <?php if ($use_group_header): ?><div><?php endif; ?>
  <?php foreach ($rows as $id => $row): ?>
  <?php preg_match('/<span class="clase">(.*?)<\/span>/s', $row, $match);  
    $class_value = $match[TRUE];
    if (!empty($class_value)) {
       $args_class = explode(" ", $class_value);
       $check = reset($args_class);
    }
  ?>
  <?php if ($check == 'multiacordeon'): ?>
    <?php preg_match('/<span class="title-acordeon">(.*?)<\/div>/s', $row, $title); ?>
    <?php preg_match('/<div class="body-acordeon">(.*?)<\/div>/s', $row, $body); ?>
  
  <!-- Acordeon -->
  <div class="list-acordeon ui-accordion-header ui-helper-reset ui-state-default ui-corner-all">
      <div class="<?php print($class_value); ?>">
        <a data-toggle="collapse" data-parent="#accordion" href="#<?php print($id); ?>">
            <div><?php print($title[TRUE]); ?></div>  
        </a>
        <div id="<?php print($id); ?>" class="panel-collapse collapse">
          <div class="panel-body"><?php print($body[TRUE]); ?> </div>
       </div>
     </div>
  </div>
  <!-- End Acordeon -->

 <?php unset($row); ?>
  <?php endif; ?>
    <?php if($check != 'multiacordeon'): ?>
      <div class="<?php print($class_value);  ?>">
        <?php print $row; ?>
      </div>
    <?php endif; ?>
<?php endforeach; ?>
<?php if ($use_group_header): ?></div><?php endif; ?>
