<?php
if (!defined('ABSPATH')) {
    exit;
}

global $wpdb;
$gamadsmbai_table_main = $wpdb->prefix . 'gamadsmbai_ads';
// phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared,WordPress.DB.DirectDatabaseQuery.DirectQuery,WordPress.DB.DirectDatabaseQuery.NoCaching,PluginCheck.Security.DirectDB.UnescapedDBParameter -- $gamadsmbai_table_main derived from $wpdb->prefix and escaped; safe internal query; No need of cache
$gamadsmbai_total_ads = $wpdb->get_var("SELECT COUNT(*) FROM $gamadsmbai_table_main");
// phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared,WordPress.DB.DirectDatabaseQuery.DirectQuery,WordPress.DB.DirectDatabaseQuery.NoCaching,PluginCheck.Security.DirectDB.UnescapedDBParameter -- $gamadsmbai_table_main derived from $wpdb->prefix and escaped;No need of cache
$gamadsmbai_active_ads = $wpdb->get_var("SELECT COUNT(*) FROM $gamadsmbai_table_main WHERE is_active = 1");
// phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared,WordPress.DB.DirectDatabaseQuery.DirectQuery,WordPress.DB.DirectDatabaseQuery.NoCaching,PluginCheck.Security.DirectDB.UnescapedDBParameter -- $gamadsmbai_table_main derived from $wpdb->prefix and escaped;No need of cache
$gamadsmbai_inactive_ads = $wpdb->get_var("SELECT COUNT(*) FROM $gamadsmbai_table_main WHERE is_active = 0");
?>

<div class="gam-dashboard-tabs">
    <button class="gam-tab-button active" data-tab="total-ads" data-adcounts=<?php echo esc_attr($gamadsmbai_total_ads); ?>>
        Total Ads (<?php echo intval($gamadsmbai_total_ads); ?>)
    </button>
    <button class="gam-tab-button" data-tab="active-ads" data-adcounts=<?php echo esc_attr($gamadsmbai_active_ads); ?>>
        Active Ads (<?php echo intval($gamadsmbai_active_ads); ?>)
    </button>
    <button class="gam-tab-button" data-tab="inactive-ads" data-adcounts=<?php echo esc_attr($gamadsmbai_inactive_ads); ?>>
        Inactive Ads (<?php echo intval($gamadsmbai_inactive_ads); ?>)
    </button>
</div>

<div class="gam-dashboard-content" id="gam-dashboard-content">
    <h3>Total Ads</h3>
    <p><?php /* translators: %d: total number of ads */
        echo esc_html(sprintf(_n('%d ad total.', '%d ads total.', intval( $gamadsmbai_total_ads ), 'gam-ads-ad-manager-and-ad-exchange'), intval($gamadsmbai_total_ads)));
        ?></p>
</div>