Kategorie, Dystans, Opcje

This commit is contained in:
2026-01-27 12:33:46 +01:00
parent 65ad515daf
commit eba19f46ed
+470 -12
View File
@@ -19,6 +19,8 @@ function mystat_activate() {
$table_categories = $wpdb->prefix . 'mystat_categories';
$table_activities = $wpdb->prefix . 'mystat_activities';
$table_event_types = $wpdb->prefix . 'mystat_event_types';
$table_equipment = $wpdb->prefix . 'mystat_equipment';
// SQL dla Kategorii
$sql_cat = "CREATE TABLE $table_categories (
@@ -29,20 +31,51 @@ function mystat_activate() {
PRIMARY KEY (id)
) $charset_collate;";
// SQL dla Typów Wydarzeń
$sql_event_types = "CREATE TABLE $table_event_types (
id mediumint(9) NOT NULL AUTO_INCREMENT,
name varchar(100) NOT NULL,
PRIMARY KEY (id)
) $charset_collate;";
// SQL dla Sprzętu
$sql_equipment = "CREATE TABLE $table_equipment (
id mediumint(9) NOT NULL AUTO_INCREMENT,
name varchar(100) NOT NULL,
PRIMARY KEY (id)
) $charset_collate;";
// SQL dla Aktywności
$sql_act = "CREATE TABLE $table_activities (
id bigint(20) NOT NULL AUTO_INCREMENT,
category_id mediumint(9) NOT NULL,
date date NOT NULL,
title varchar(255) DEFAULT '' NOT NULL,
distance decimal(10,2) DEFAULT 0.00,
duration time DEFAULT '00:00:00',
calories int(11) DEFAULT 0,
comment text,
strava_url varchar(255) DEFAULT NULL,
avg_heart_rate smallint(5) UNSIGNED DEFAULT NULL,
max_heart_rate smallint(5) UNSIGNED DEFAULT NULL,
avg_speed decimal(5,2) DEFAULT NULL,
max_speed decimal(5,2) DEFAULT NULL,
avg_cadence smallint(5) UNSIGNED DEFAULT NULL,
max_cadence smallint(5) UNSIGNED DEFAULT NULL,
total_elevation_gain int(11) DEFAULT NULL,
total_elevation_loss int(11) DEFAULT NULL,
min_altitude int(11) DEFAULT NULL,
max_altitude int(11) DEFAULT NULL,
equipment_id mediumint(9) DEFAULT NULL,
gpx_url varchar(255) DEFAULT NULL,
event_type_id mediumint(9) DEFAULT NULL,
PRIMARY KEY (id)
) $charset_collate;";
require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
dbDelta( $sql_equipment );
dbDelta( $sql_cat );
dbDelta( $sql_event_types );
dbDelta( $sql_act );
// Dodanie domyślnych kategorii, jeśli tabela jest pusta
@@ -50,13 +83,69 @@ function mystat_activate() {
$wpdb->insert( $table_categories, array( 'name' => 'Rower', 'icon' => 'dashicons-buddicons-groups', 'color' => '#3498db' ) );
$wpdb->insert( $table_categories, array( 'name' => 'Bieganie', 'icon' => 'dashicons-businessman', 'color' => '#e74c3c' ) );
}
// Dodanie domyślnych typów wydarzeń, jeśli tabela jest pusta
if ( $wpdb->get_var( "SELECT COUNT(*) FROM $table_event_types" ) == 0 ) {
$default_event_types = ['Bez kategorii', 'Fitness', 'Geocaching', 'Podróżowanie', 'Rekreacyjny', 'Specjalne zdarzenie', 'Transport', 'Trening', 'Wyścig'];
foreach ($default_event_types as $type_name) {
$wpdb->insert( $table_event_types, array( 'name' => $type_name ) );
}
// Ustawienie domyślnego typu "Trening" dla istniejących aktywności, które go nie mają
$training_id = $wpdb->get_var( $wpdb->prepare( "SELECT id FROM $table_event_types WHERE name = %s", 'Trening' ) );
if ($training_id) {
$wpdb->query( $wpdb->prepare( "UPDATE $table_activities SET event_type_id = %d WHERE event_type_id IS NULL OR event_type_id = 0", $training_id ) );
}
}
// Dodanie domyślnego sprzętu, jeśli tabela jest pusta
if ( $wpdb->get_var( "SELECT COUNT(*) FROM $table_equipment" ) == 0 ) {
$default_equipment = ['Giant Revolt', 'Cube LTD', 'Author Agang', 'Liv Tempt 4', 'Cube Acid 24', 'Mongoose BMX', 'Nextbike - Miejski'];
foreach ($default_equipment as $eq_name) {
$wpdb->insert( $table_equipment, array( 'name' => $eq_name ) );
}
}
}
// --- 2. MENU ADMINA I DASHBOARD ---
add_action( 'admin_menu', 'mystat_add_admin_menu' );
function mystat_add_admin_menu() {
add_menu_page( 'Moje Statystyki', 'Statystyki', 'manage_options', 'moje-statystyki', 'mystat_dashboard_page', 'dashicons-chart-line', 6 );
add_menu_page(
'Moje Statystyki', // Tytuł strony
'Statystyki', // Tytuł w menu
'manage_options', // Wymagane uprawnienia
'moje-statystyki', // Slug menu
'mystat_dashboard_page', // Funkcja renderująca stronę główną (dashboard)
'dashicons-chart-line', // Ikona
6 // Pozycja
);
add_submenu_page(
'moje-statystyki', // Slug rodzica
'Dodaj Nowy Trening', // Tytuł strony
'Nowy trening', // Tytuł w podmenu
'manage_options', // Wymagane uprawnienia
'mystat-nowy-trening', // Slug podmenu
'mystat_add_new_page' // Funkcja renderująca stronę dodawania
);
add_submenu_page(
'moje-statystyki',
'Typy Wydarzeń',
'Typy wydarzeń',
'manage_options',
'mystat-event-types',
'mystat_event_types_page'
);
add_submenu_page(
'moje-statystyki',
'Sprzęt',
'Sprzęt',
'manage_options',
'mystat-equipment',
'mystat_equipment_page'
);
}
function mystat_dashboard_page() {
@@ -65,6 +154,369 @@ function mystat_dashboard_page() {
echo '</div>';
}
function mystat_add_new_page() {
echo '<div class="wrap"><h1>Dodaj Nowy Trening</h1>';
// Obsługa zapisu formularza (musi być przed renderowaniem, aby wyświetlić komunikat)
mystat_handle_new_entry();
// Formularz dodawania
mystat_render_add_form();
echo '</div>';
}
function mystat_event_types_page() {
global $wpdb;
$table_event_types = $wpdb->prefix . 'mystat_event_types';
$message = '';
$notice_class = '';
// Handle POST requests (add/update)
if ( isset( $_POST['submit'] ) && check_admin_referer( 'mystat_manage_event_type' ) ) {
$name = sanitize_text_field( $_POST['event_type_name'] );
$type_id = isset( $_POST['event_type_id'] ) ? intval( $_POST['event_type_id'] ) : 0;
if ( ! empty( $name ) ) {
if ( $type_id > 0 ) { // Update
$wpdb->update( $table_event_types, [ 'name' => $name ], [ 'id' => $type_id ] );
$message = 'Typ wydarzenia zaktualizowany.';
$notice_class = 'notice-success';
} else { // Insert
$wpdb->insert( $table_event_types, [ 'name' => $name ] );
$message = 'Typ wydarzenia dodany.';
$notice_class = 'notice-success';
}
} else {
$message = 'Nazwa typu wydarzenia nie może być pusta.';
$notice_class = 'notice-error';
}
}
// Handle GET requests (delete)
if ( isset( $_GET['action'], $_GET['id'], $_GET['_wpnonce'] ) && $_GET['action'] === 'delete' ) {
if ( wp_verify_nonce( $_GET['_wpnonce'], 'mystat_delete_event_type_' . $_GET['id'] ) ) {
$wpdb->delete( $table_event_types, [ 'id' => intval( $_GET['id'] ) ] );
$message = 'Typ wydarzenia usunięty.';
$notice_class = 'notice-success';
}
}
// Prepare for form (for editing)
$item_to_edit = null;
if ( isset( $_GET['action'], $_GET['id'] ) && $_GET['action'] === 'edit' ) {
$item_to_edit = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $table_event_types WHERE id = %d", intval( $_GET['id'] ) ) );
}
$event_types = $wpdb->get_results( "SELECT * FROM $table_event_types ORDER BY name ASC" );
?>
<div class="wrap">
<h1>Typy Wydarzeń</h1>
<?php if ( ! empty( $message ) ) : ?>
<div class="notice <?php echo esc_attr( $notice_class ); ?> is-dismissible"><p><?php echo esc_html( $message ); ?></p></div>
<?php endif; ?>
<div id="col-container" class="wp-clearfix">
<div id="col-left">
<div class="col-wrap">
<div class="form-wrap">
<h2><?php echo $item_to_edit ? 'Edytuj typ wydarzenia' : 'Dodaj nowy typ wydarzenia'; ?></h2>
<form method="post">
<input type="hidden" name="event_type_id" value="<?php echo $item_to_edit ? esc_attr( $item_to_edit->id ) : '0'; ?>">
<?php wp_nonce_field( 'mystat_manage_event_type' ); ?>
<div class="form-field">
<label for="event_type_name">Nazwa</label>
<input type="text" name="event_type_name" id="event_type_name" value="<?php echo $item_to_edit ? esc_attr( $item_to_edit->name ) : ''; ?>" required>
</div>
<?php submit_button( $item_to_edit ? 'Zaktualizuj' : 'Dodaj' ); ?>
</form>
</div>
</div>
</div>
<div id="col-right">
<div class="col-wrap">
<table class="wp-list-table widefat fixed striped">
<thead><tr><th>Nazwa</th><th style="width: 100px;">Akcje</th></tr></thead>
<tbody>
<?php foreach ( $event_types as $type ) : ?>
<tr><td><?php echo esc_html( $type->name ); ?></td><td><a href="<?php echo esc_url( add_query_arg( [ 'action' => 'edit', 'id' => $type->id ] ) ); ?>">Edytuj</a> | <a href="<?php echo esc_url( wp_nonce_url( add_query_arg( [ 'action' => 'delete', 'id' => $type->id ] ), 'mystat_delete_event_type_' . $type->id ) ); ?>" onclick="return confirm('Czy na pewno chcesz usunąć ten typ?')" style="color: #a00;">Usuń</a></td></tr>
<?php endforeach; ?>
</tbody>
</table>
</div>
</div>
</div>
</div>
<?php
}
function mystat_equipment_page() {
global $wpdb;
$table_equipment = $wpdb->prefix . 'mystat_equipment';
$message = '';
$notice_class = '';
// Handle POST requests (add/update)
if ( isset( $_POST['submit'] ) && check_admin_referer( 'mystat_manage_equipment' ) ) {
$name = sanitize_text_field( $_POST['equipment_name'] );
$item_id = isset( $_POST['equipment_id'] ) ? intval( $_POST['equipment_id'] ) : 0;
if ( ! empty( $name ) ) {
if ( $item_id > 0 ) { // Update
$wpdb->update( $table_equipment, [ 'name' => $name ], [ 'id' => $item_id ] );
$message = 'Sprzęt zaktualizowany.';
$notice_class = 'notice-success';
} else { // Insert
$wpdb->insert( $table_equipment, [ 'name' => $name ] );
$message = 'Sprzęt dodany.';
$notice_class = 'notice-success';
}
} else {
$message = 'Nazwa sprzętu nie może być pusta.';
$notice_class = 'notice-error';
}
}
// Handle GET requests (delete)
if ( isset( $_GET['action'], $_GET['id'], $_GET['_wpnonce'] ) && $_GET['action'] === 'delete' ) {
if ( wp_verify_nonce( $_GET['_wpnonce'], 'mystat_delete_equipment_' . $_GET['id'] ) ) {
$wpdb->delete( $table_equipment, [ 'id' => intval( $_GET['id'] ) ] );
$message = 'Sprzęt usunięty.';
$notice_class = 'notice-success';
}
}
// Prepare for form (for editing)
$item_to_edit = null;
if ( isset( $_GET['action'], $_GET['id'] ) && $_GET['action'] === 'edit' ) {
$item_to_edit = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $table_equipment WHERE id = %d", intval( $_GET['id'] ) ) );
}
$equipment_list = $wpdb->get_results( "SELECT * FROM $table_equipment ORDER BY name ASC" );
?>
<div class="wrap">
<h1>Zarządzaj Sprzętem</h1>
<?php if ( ! empty( $message ) ) : ?>
<div class="notice <?php echo esc_attr( $notice_class ); ?> is-dismissible"><p><?php echo esc_html( $message ); ?></p></div>
<?php endif; ?>
<div id="col-container" class="wp-clearfix">
<div id="col-left">
<div class="col-wrap">
<div class="form-wrap">
<h2><?php echo $item_to_edit ? 'Edytuj sprzęt' : 'Dodaj nowy sprzęt'; ?></h2>
<form method="post">
<input type="hidden" name="equipment_id" value="<?php echo $item_to_edit ? esc_attr( $item_to_edit->id ) : '0'; ?>">
<?php wp_nonce_field( 'mystat_manage_equipment' ); ?>
<div class="form-field">
<label for="equipment_name">Nazwa</label>
<input type="text" name="equipment_name" id="equipment_name" value="<?php echo $item_to_edit ? esc_attr( $item_to_edit->name ) : ''; ?>" required>
</div>
<?php submit_button( $item_to_edit ? 'Zaktualizuj' : 'Dodaj' ); ?>
</form>
</div>
</div>
</div>
<div id="col-right">
<div class="col-wrap">
<table class="wp-list-table widefat fixed striped">
<thead><tr><th>Nazwa</th><th style="width: 100px;">Akcje</th></tr></thead>
<tbody>
<?php foreach ( $equipment_list as $item ) : ?>
<tr><td><?php echo esc_html( $item->name ); ?></td><td><a href="<?php echo esc_url( add_query_arg( [ 'action' => 'edit', 'id' => $item->id ] ) ); ?>">Edytuj</a> | <a href="<?php echo esc_url( wp_nonce_url( add_query_arg( [ 'action' => 'delete', 'id' => $item->id ] ), 'mystat_delete_equipment_' . $item->id ) ); ?>" onclick="return confirm('Czy na pewno chcesz usunąć ten sprzęt?')" style="color: #a00;">Usuń</a></td></tr>
<?php endforeach; ?>
</tbody>
</table>
</div>
</div>
</div>
</div>
<?php
}
/**
* Obsługa zapisu nowego wpisu do bazy danych
*/
function mystat_handle_new_entry() {
global $wpdb;
// Sprawdź czy formularz został wysłany
if ( ! isset( $_POST['mystat_submit_activity'] ) ) {
return;
}
// Weryfikacja bezpieczeństwa (Nonce)
if ( ! isset( $_POST['_wpnonce'] ) || ! wp_verify_nonce( $_POST['_wpnonce'], 'mystat_add_entry' ) ) {
echo '<div class="notice notice-error"><p>Błąd weryfikacji bezpieczeństwa formularza.</p></div>';
return;
}
$table_activities = $wpdb->prefix . 'mystat_activities';
// Przygotowanie danych (zamiana przecinka na kropkę w dystansie)
$distance = isset($_POST['distance']) ? floatval( str_replace( ',', '.', $_POST['distance'] ) ) : 0;
// Funkcja pomocnicza do zamiany pustych wartości na NULL, aby poprawnie zapisać je w bazie
$null_if_empty = function($value) {
return $value !== '' ? $value : null;
};
$data = array(
'category_id' => intval( $_POST['category_id'] ),
'date' => sanitize_text_field( $_POST['date'] ),
'title' => sanitize_text_field( $_POST['title'] ),
'distance' => $distance,
'duration' => sanitize_text_field( $_POST['duration'] ),
'calories' => intval( $_POST['calories'] ),
'comment' => sanitize_textarea_field( $_POST['comment'] ),
'strava_url' => $null_if_empty( esc_url_raw( $_POST['strava_url'] ) ),
'avg_heart_rate' => $null_if_empty( intval( $_POST['avg_heart_rate'] ) ),
'max_heart_rate' => $null_if_empty( intval( $_POST['max_heart_rate'] ) ),
'avg_speed' => $null_if_empty( floatval( str_replace( ',', '.', $_POST['avg_speed'] ) ) ),
'max_speed' => $null_if_empty( floatval( str_replace( ',', '.', $_POST['max_speed'] ) ) ),
'avg_cadence' => $null_if_empty( intval( $_POST['avg_cadence'] ) ),
'max_cadence' => $null_if_empty( intval( $_POST['max_cadence'] ) ),
'total_elevation_gain' => $null_if_empty( intval( $_POST['total_elevation_gain'] ) ),
'total_elevation_loss' => $null_if_empty( intval( $_POST['total_elevation_loss'] ) ),
'min_altitude' => $null_if_empty( intval( $_POST['min_altitude'] ) ),
'max_altitude' => $null_if_empty( intval( $_POST['max_altitude'] ) ),
'equipment_id' => $null_if_empty( intval( $_POST['equipment_id'] ) ),
'gpx_url' => $null_if_empty( esc_url_raw( $_POST['gpx_url'] ) ),
'event_type_id' => $null_if_empty( intval( $_POST['event_type_id'] ) ),
);
// Format danych dla $wpdb->insert
$format = array(
'%d', '%s', '%s', '%f', '%s', '%d', '%s', // Pola podstawowe
'%s', '%d', '%d', '%f', '%f', '%d', '%d', // Tętno, prędkość, kadencja
'%d', '%d', '%d', '%d', '%d', '%s', '%d' // Wysokość, sprzęt, linki, typ wydarzenia
);
$result = $wpdb->insert( $table_activities, $data, $format );
if ( $result ) {
echo '<div class="notice notice-success is-dismissible"><p>Trening dodany pomyślnie!</p></div>';
} else {
echo '<div class="notice notice-error is-dismissible"><p>Wystąpił błąd podczas zapisu do bazy.</p></div>';
}
}
/**
* Renderowanie formularza HTML
*/
function mystat_render_add_form() {
global $wpdb;
$table_categories = $wpdb->prefix . 'mystat_categories';
$table_event_types = $wpdb->prefix . 'mystat_event_types';
$table_equipment = $wpdb->prefix . 'mystat_equipment';
$categories = $wpdb->get_results( "SELECT * FROM $table_categories ORDER BY name ASC" );
$event_types = $wpdb->get_results( "SELECT * FROM $table_event_types ORDER BY name ASC" );
$equipment_list = $wpdb->get_results( "SELECT * FROM $table_equipment ORDER BY name ASC" );
$today = current_time( 'Y-m-d' );
?>
<div class="postbox">
<div class="postbox-header"><h2 class="hndle">Dodaj Nową Aktywność</h2></div>
<div class="inside">
<form method="post" action="">
<?php wp_nonce_field( 'mystat_add_entry', '_wpnonce' ); ?>
<table class="form-table">
<tr>
<th scope="row"><label for="title">Tytuł</label></th>
<td><input type="text" name="title" id="title" class="large-text" placeholder="np. Poranny trening w lesie" required></td>
</tr>
<tr>
<th scope="row"><label for="category_id">Kategoria</label></th>
<td>
<select name="category_id" id="category_id" required>
<?php foreach ( $categories as $cat ) : ?>
<option value="<?php echo esc_attr( $cat->id ); ?>" <?php selected( $cat->name, 'Rower' ); ?>><?php echo esc_html( $cat->name ); ?></option>
<?php endforeach; ?>
</select>
</td>
</tr>
<tr>
<th scope="row"><label for="date">Data</label></th>
<td><input type="date" name="date" id="date" value="<?php echo esc_attr( $today ); ?>" class="regular-text" required></td>
</tr>
<tr>
<th scope="row"><label for="distance">Dystans (km)</label></th>
<td><input type="text" name="distance" id="distance" class="regular-text" placeholder="0,00"></td>
</tr>
<tr>
<th scope="row"><label for="duration">Czas (HH:MM:SS)</label></th>
<td><input type="time" name="duration" id="duration" step="1" value="00:00:00" class="regular-text"></td>
</tr>
<tr>
<th scope="row"><label for="calories">Kalorie (kcal)</label></th>
<td><input type="number" name="calories" id="calories" class="regular-text" placeholder="0"></td>
</tr>
<tr>
<th scope="row"><label for="event_type">Typ wydarzenia</label></th>
<td>
<select name="event_type_id" id="event_type_id">
<option value="">-- Wybierz --</option>
<?php foreach ( $event_types as $type ) : ?>
<option value="<?php echo esc_attr( $type->id ); ?>" <?php selected( $type->name, 'Trening' ); ?>><?php echo esc_html( $type->name ); ?></option>
<?php endforeach; ?>
</select>
</td>
</tr>
<tr>
<th scope="row"><label for="equipment">Sprzęt</label></th>
<td>
<select name="equipment_id" id="equipment_id">
<option value="">-- Wybierz --</option>
<?php foreach ( $equipment_list as $item ) : ?>
<option value="<?php echo esc_attr( $item->id ); ?>"><?php echo esc_html( $item->name ); ?></option>
<?php endforeach; ?>
</select>
</td>
</tr>
<tr class="form-field">
<td colspan="2"><hr><h4>Dane szczegółowe (opcjonalne)</h4></td>
</tr>
<tr>
<th scope="row"><label for="avg_speed">Śr. prędkość (km/h)</label></th>
<td><input type="text" name="avg_speed" id="avg_speed" class="small-text" placeholder="0,0"></td>
</tr>
<tr>
<th scope="row"><label for="max_speed">Maks. prędkość (km/h)</label></th>
<td><input type="text" name="max_speed" id="max_speed" class="small-text" placeholder="0,0"></td>
</tr>
<tr>
<th scope="row"><label for="avg_heart_rate">Śr. tętno</label></th>
<td><input type="number" name="avg_heart_rate" id="avg_heart_rate" class="small-text" placeholder="0"></td>
</tr>
<tr>
<th scope="row"><label for="max_heart_rate">Maks. tętno</label></th>
<td><input type="number" name="max_heart_rate" id="max_heart_rate" class="small-text" placeholder="0"></td>
</tr>
<tr>
<th scope="row"><label for="avg_cadence">Śr. rytm pedałowania</label></th>
<td><input type="number" name="avg_cadence" id="avg_cadence" class="small-text" placeholder="0"></td>
</tr>
<tr>
<th scope="row"><label for="total_elevation_gain">Całkowity wznios (m)</label></th>
<td><input type="number" name="total_elevation_gain" id="total_elevation_gain" class="small-text" placeholder="0"></td>
</tr>
<tr>
<th scope="row"><label for="comment">Komentarz</label></th>
<td><textarea name="comment" id="comment" rows="3" class="large-text"></textarea></td>
</tr>
<tr class="form-field">
<td colspan="2"><hr><h4>Linki zewnętrzne (opcjonalne)</h4></td>
</tr>
<tr>
<th scope="row"><label for="strava_url">Link do Strava</label></th>
<td><input type="url" name="strava_url" id="strava_url" class="large-text" placeholder="https://www.strava.com/activities/..."></td>
</tr>
</table>
<p class="submit">
<input type="submit" name="mystat_submit_activity" id="submit" class="button button-primary" value="Zapisz Trening">
</p>
</form>
</div>
</div>
<?php
}
function mystat_render_history_table() {
global $wpdb;
@@ -98,13 +550,15 @@ function mystat_render_history_table() {
// --- 2. POBIERANIE DANYCH (SELECT) ---
// Pobieramy ostatnie 10 wpisów, łącząc z tabelą kategorii, aby mieć nazwę i ikonę
$sql = "
SELECT a.*, c.name as category_name, c.icon, c.color
$sql = $wpdb->prepare("
SELECT a.*, c.name as category_name, c.icon, c.color, et.name as event_type_name, eq.name as equipment_name
FROM $table_activities a
LEFT JOIN $table_categories c ON a.category_id = c.id
LEFT JOIN {$wpdb->prefix}mystat_event_types et ON a.event_type_id = et.id
LEFT JOIN {$wpdb->prefix}mystat_equipment eq ON a.equipment_id = eq.id
ORDER BY a.date DESC, a.id DESC
LIMIT 10
";
LIMIT %d
", 10);
$activities = $wpdb->get_results( $sql );
@@ -118,11 +572,13 @@ function mystat_render_history_table() {
<tr>
<th scope="col" style="width: 50px;">Ikona</th>
<th scope="col">Data</th>
<th scope="col">Kategoria</th>
<th scope="col">Tytuł</th>
<th scope="col" style="width: 120px;">Kategoria</th>
<th scope="col">Typ</th>
<th scope="col">Sprzęt</th>
<th scope="col">Dystans (km)</th>
<th scope="col">Czas</th>
<th scope="col">Kcal</th>
<th scope="col">Komentarz</th>
<th scope="col">Śr. prędkość</th>
<th scope="col" style="width: 80px;">Akcja</th>
</tr>
</thead>
@@ -145,11 +601,13 @@ function mystat_render_history_table() {
<?php endif; ?>
</td>
<td><?php echo esc_html( $row->date ); ?></td>
<td><strong><?php echo esc_html( $row->category_name ); ?></strong></td>
<td><strong><?php echo esc_html( wp_trim_words( $row->title, 6 ) ); ?></strong></td>
<td><?php echo esc_html( $row->category_name ); ?></td>
<td><?php echo esc_html( $row->event_type_name ); ?></td>
<td><?php echo esc_html( $row->equipment_name ); ?></td>
<td><?php echo number_format( $row->distance, 2, ',', ' ' ); ?></td>
<td><?php echo esc_html( $row->duration ); ?></td>
<td><?php echo esc_html( $row->calories ); ?></td>
<td><?php echo esc_html( wp_trim_words( $row->comment, 5 ) ); ?></td>
<td><?php echo $row->avg_speed ? number_format( $row->avg_speed, 1, ',', ' ' ) . ' km/h' : '-'; ?></td>
<td>
<a href="<?php echo esc_url( $delete_url ); ?>"
class="button button-small button-link-delete"
@@ -161,7 +619,7 @@ function mystat_render_history_table() {
<?php endforeach; ?>
<?php else : ?>
<tr>
<td colspan="8">Brak zarejestrowanych aktywności. Dodaj pierwszy trening powyżej!</td>
<td colspan="10">Brak zarejestrowanych aktywności. Dodaj pierwszy trening powyżej!</td>
</tr>
<?php endif; ?>
</tbody>