<?php
/**
 * Created by: Khoapq
 * Date: 15/10/2015
 */
$html       = '';
$group_id   = 'accordion_' . uniqid();
$title      = $instance['title'] ? $instance['title'] : '';
$panel_list = $instance['panel'] ? $instance['panel'] : '';
?>

<div class="thim-widget-accordion">
	<?php
	if ( $title != '' ) {
		echo '<h3 class="widget-title">' . $title . '</h3>';
	}
	?>
	<div id="<?php echo esc_attr( $group_id ); ?>" class="panel-group" role="tablist" aria-multiselectable="true">
		<!-- List Panel -->
		<?php foreach ( $panel_list as $key => $panel ) : ?>

			<div class="panel panel-default">
				<div class="panel-heading" role="tab" id="<?php echo esc_attr( 'heading_' . $group_id . '_' . $key ); ?>">
					<h4 class="panel-title">
						<a role="button" class="collapsed" data-toggle="collapse" data-parent="#<?php echo esc_attr( $group_id ); ?>" href="<?php echo esc_attr( '#collapse_' . $group_id . '_' . $key ); ?>" aria-expanded="false" aria-controls="<?php echo esc_attr( 'collapse_' . $group_id . '_' . $key ); ?>">
							<?php echo esc_html( $panel['panel_title'] ); ?>
						</a>
					</h4>
				</div>
				<div id="<?php echo esc_attr( 'collapse_' . $group_id . '_' . $key ); ?>" class="panel-collapse collapse" role="tabpanel" aria-labelledby="<?php echo esc_attr( 'heading_' . $group_id . '_' . $key ); ?>">
					<div class="panel-body">
						<?php echo ent2ncr( $panel['panel_body'] ); ?>
					</div>
				</div>
			</div>

		<?php endforeach; ?>
		<!-- End: List Panel -->
	</div>

</div>