<?php
    $logo_label = true;

    if (intval($api_attributes['category_primary']) == 2) {
        $mu_sub_category = [4, 14, 21, 25, 26, 31];

        if (in_array(intval($api_attributes['sub_category']), $mu_sub_category)) {
            $logo_label = false;
        }
    }

    if (intval($api_attributes['category_primary']) == 7) {
        $mu_sub_category = [4, 26, 27];

        if (in_array(intval($api_attributes['sub_category']), $mu_sub_category)) {
            $logo_label = false;
        }
    }

    $fields = $block_admin_cappers->getFieldsValidate();
?>
<?php foreach($cappers as $capper):?>
    <?php if (!$rdgb->helpers->validateFields($fields, $capper)) continue; ?>
    <div class="capper">
        <div class="content">
            <div class="capper-content">
                <div class="content-category">
                    <div class="category <?php echo $source; ?>">
                        <span><?php echo (isset($titles_sports[$category])) ? $titles_sports[$category] : ''; ?></span>
                    </div>
                </div>
                
                <div class="content-teams-logo">
                    <div class="teams">
                        <div class="team team-a">
                            <div class="team-logo">
                                <?php if (isset($capper['home_image']) && $capper['home_image'] != ''): ?>
                                    <?php
                                        $home_image = $block_admin_cappers->get_image($capper['home_image'], [
                                            'image_type' => 'admin_capper_simple',
                                            'image_alt' => $capper['home_name'],
                                            'logo_label' => $logo_label
                                        ]);
                                    ?>
                                    <img src="<?php echo $home_image['url']; ?>" alt="<?php echo $home_image['alt']; ?>">
                                <?php endif; ?>
                            </div>
                            <div class="team-name"><span><?php echo $capper['home_name']; ?></span></div>
                        </div>

                        <div class="team team-vs">
                            <div class="vs-logo"><span>vs</span></div>
                        </div>

                        <div class="team team-b">
                            <div class="team-logo">
                                <?php if (isset($capper['visitor_image']) && $capper['visitor_image'] != ''): ?>
                                    <?php
                                        $visitor_image = $block_admin_cappers->get_image($capper['visitor_image'], [
                                            'image_type' => 'admin_capper_simple',
                                            'image_alt' => $capper['visitor_name'],
                                            'logo_label' => $logo_label
                                        ]);
                                    ?>
                                    <img src="<?php echo $visitor_image['url']; ?>" alt="<?php echo $visitor_image['alt']; ?>">
                                <?php endif; ?>
                            </div>
                            <div class="team-name"><span><?php echo $capper['visitor_name']; ?></span></div>
                        </div>
                    </div>
                </div>


                <div class="content-release">
                    <hr>
                    <span class="release-date">Release Date:
                        <span><?php echo$capper['game_date']; ?></span>
                    </span>
                </div>
            </div>
        </div>

        <div class="capper-footer">
            <div class="footer-link">
                <?php if ($link_options != 'none'): ?>
                    <?php
                        $url = '';
                        $target = '_self';

                        if ($link_options == 'custom') {
                            if (is_array($custom_link)) {
                                if (isset($custom_link['url'])) {
                                    $url = $custom_link['url'];
                                }

                                if (isset($custom_link['target']) && !empty($custom_link['target'])) {
                                    $target = $custom_link['target'];
                                }
                            }
                        } else {
                            $url = (!empty($capper['game_url'])) ? $capper['game_url'] : '#';
                            $target = '_blank';
                        }
                    ?>
                    <a href="<?php echo $url; ?>" target="<?php echo $target; ?>" rel="noopener nofollow">
                        <div class="vs-name">
                            <?php
                                $link_title = $capper['num_picks'].' PICKS';
                                if ($link_options == 'custom') {
                                    $link_title = (!empty($custom_link['title'])) ? $custom_link['title'] : $capper['num_picks'].' PICKS';
                                }
                            ?>
                            <span><?php echo $link_title; ?></span>
                        </div>
                    </a>
                <?php endif; ?>
            </div>
            <div class="footer-status">
                <span><?php echo $capper['game_stat']; ?></span>
            </div>
        </div>
    </div>
<?php endforeach; ?>
