<?php
/**
 * This template is used for display dashboard pagination.
 *
 * This template can be overridden by copying it to yourtheme/affs/dashboard/pagination.php
 *
 * To maintain compatibility, affiliates pro for Woocommerce will update the template files and you have to copy the updated files to your theme
 */
if (!defined('ABSPATH')) {
    exit; // Exit if accessed directly.
}

do_action('fs_affiliates_before_dashboard_pagination_table');
?>
<nav class="pagination pagination-centered woocommerce-pagination">
    <ul>
        <?php if (1 != $pagination['current_page']): ?>
            <li><a href="#" class="fs-pagination fs-first-pagination" data-page="1"><<</a>
            <li><a href="#" class="fs-pagination fs-prev-pagination" data-page="<?php echo esc_attr($pagination['prev_page_count']); ?>"><</a></li>  
        <?php endif; ?>
        <li><a href="#" class="<?php echo esc_attr(implode(' ', fs_get_pagination_classes(1, $pagination['current_page']))); ?>" data-page="1">1</a></li> 
        <?php if (3 <= $pagination['current_page']) : ?>
            <li><span class="fs-prev-pagination-dot" disabled="disabled">...</a></li> 
            <?php
        endif;
        $start_page = $pagination['current_page'] - 1;
        $start_page = $start_page < 2 ? 2 : $start_page;
        $end_page = $pagination['current_page'] + 1;
        $end_page = $end_page < $pagination['page_count'] ? $end_page : $pagination['page_count'];
        for ($start = $start_page; $start <= $end_page; $start++) :
            $page_no = fs_get_pagination_number($start, $pagination['page_count'], $pagination['current_page']);
            ?>                            
            <li>
                <a href="#" class="<?php echo esc_attr(implode(' ', fs_get_pagination_classes($start, $pagination['current_page']))); ?>"
                   data-page="<?php echo esc_attr($page_no); ?>">
                       <?php echo esc_html($page_no); ?>
                </a>
            </li>                       
            <?php
        endfor;
        if (($pagination['page_count'] - 1) != $pagination['current_page'] && $pagination['page_count'] != $pagination['current_page']) :
            ?>
            <li><span class="fs-next-pagination-dot" disabled="disabled">...</a></li> 
            <?php
        endif;
        if ($pagination['page_count'] != $pagination['current_page']) :
            if (($pagination['page_count'] - 1) != $pagination['current_page']) :
                ?>
                <li><a href="#" class="fs-pagination fs-end-pagination" data-page="<?php echo esc_attr($pagination['page_count']); ?>"><?php echo esc_attr($pagination['page_count']); ?></a></li>  
            <?php endif; ?>
            <li><a href="#" class="fs-pagination fs-next-pagination" data-page="<?php echo esc_attr($pagination['next_page_count']); ?>">></a></li>
            <li><a href="#" class="fs-pagination fs-last-pagination" data-page="<?php echo esc_attr($pagination['page_count']); ?>">>></a></li>
            <?php endif; ?>    
    </ul>
</nav>
<?php
do_action('fs_affiliates_before_dashboard_pagination_table');
