This commit is contained in:
2026-04-22 22:00:50 +02:00
parent 16be247ce1
commit e979fbe755
46 changed files with 5302 additions and 274 deletions

View File

@@ -8,14 +8,28 @@ class Carei_Admin_Panel {
const POST_TYPE = 'carei_reservation';
const META_PREFIX = '_carei_';
const PROTECTION_OPTION = 'carei_protection_packages';
const PROTECTION_OPTION = 'carei_protection_packages';
const EXTRAS_SEEN_OPTION = 'carei_extras_seen';
const EXTRAS_TRANSLATIONS_OPTION = 'carei_extras_translations';
private static $statuses = array(
'nowe' => array( 'label' => 'Nowe', 'color' => '#2F2482' ),
'przeczytane' => array( 'label' => 'Przeczytane', 'color' => '#f59e0b' ),
'zrealizowane' => array( 'label' => 'Zrealizowane', 'color' => '#22c55e' ),
'nowe' => array( 'color' => '#2F2482' ),
'przeczytane' => array( 'color' => '#f59e0b' ),
'zrealizowane' => array( 'color' => '#22c55e' ),
);
private static function get_status_label( $key ) {
switch ( $key ) {
case 'nowe':
return __( 'Nowe', 'carei-reservation' );
case 'przeczytane':
return __( 'Przeczytane', 'carei-reservation' );
case 'zrealizowane':
return __( 'Zrealizowane', 'carei-reservation' );
}
return $key;
}
public function __construct() {
add_action( 'init', array( $this, 'register_post_type' ) );
add_filter( 'manage_' . self::POST_TYPE . '_posts_columns', array( $this, 'admin_columns' ) );
@@ -28,6 +42,135 @@ class Carei_Admin_Panel {
add_action( 'admin_head', array( $this, 'admin_styles' ) );
add_action( 'admin_menu', array( $this, 'register_protection_packages_page' ) );
add_action( 'admin_post_carei_save_protection_packages', array( $this, 'handle_protection_packages_save' ) );
add_action( 'admin_menu', array( $this, 'register_extras_translations_page' ) );
add_action( 'admin_post_carei_save_extras_translations', array( $this, 'handle_extras_translations_save' ) );
}
// ─── Extras Translations (dynamic Softra pricelist item names) ────
public static function get_extras_seen() {
$seen = get_option( self::EXTRAS_SEEN_OPTION, array() );
if ( ! is_array( $seen ) ) return array();
$seen = array_values( array_unique( array_filter( array_map( 'strval', $seen ), 'strlen' ) ) );
sort( $seen, SORT_NATURAL | SORT_FLAG_CASE );
return $seen;
}
public static function get_extras_translations() {
$map = get_option( self::EXTRAS_TRANSLATIONS_OPTION, array() );
return is_array( $map ) ? $map : array();
}
public static function remember_extra_name( $pl_name ) {
$pl_name = trim( (string) $pl_name );
if ( $pl_name === '' ) return;
$seen = get_option( self::EXTRAS_SEEN_OPTION, array() );
if ( ! is_array( $seen ) ) $seen = array();
if ( ! in_array( $pl_name, $seen, true ) ) {
$seen[] = $pl_name;
update_option( self::EXTRAS_SEEN_OPTION, $seen, false );
}
}
public static function translate_extra_name( $pl_name, $locale = null ) {
if ( $locale === null ) {
$wp_locale = function_exists( 'determine_locale' ) ? determine_locale() : get_locale();
$locale = ( 0 === strpos( (string) $wp_locale, 'en' ) ) ? 'en' : 'pl';
}
if ( $locale !== 'en' ) return $pl_name;
$map = self::get_extras_translations();
if ( isset( $map[ $pl_name ] ) && $map[ $pl_name ] !== '' ) {
return $map[ $pl_name ];
}
return $pl_name;
}
public function register_extras_translations_page() {
add_submenu_page(
'edit.php?post_type=' . self::POST_TYPE,
__( 'Tłumaczenia extras', 'carei-reservation' ),
__( 'Tłumaczenia extras', 'carei-reservation' ),
'manage_options',
'carei-extras-translations',
array( $this, 'render_extras_translations_page' )
);
}
public function render_extras_translations_page() {
if ( ! current_user_can( 'manage_options' ) ) {
wp_die( esc_html__( 'Brak uprawnień.', 'carei-reservation' ) );
}
$seen = self::get_extras_seen();
$trans = self::get_extras_translations();
$saved = isset( $_GET['carei_saved'] ) && $_GET['carei_saved'] === '1';
?>
<div class="wrap">
<h1><?php esc_html_e( 'Tłumaczenia extras', 'carei-reservation' ); ?></h1>
<p><?php esc_html_e( 'Tłumaczenia nazw dodatkowych opcji (extras) zwracanych z API Softra. Puste pole = wersja polska jest używana także w wersji angielskiej (fallback).', 'carei-reservation' ); ?></p>
<?php if ( $saved ) : ?>
<div class="notice notice-success is-dismissible"><p><?php esc_html_e( 'Zapisano.', 'carei-reservation' ); ?></p></div>
<?php endif; ?>
<?php if ( empty( $seen ) ) : ?>
<div class="notice notice-info"><p><?php esc_html_e( 'Brak zebranych pozycji. Otwórz formularz rezerwacji i wybierz daty/oddział/klasę aby załadować pricelist — pozycje pojawią się tutaj automatycznie.', 'carei-reservation' ); ?></p></div>
<?php else : ?>
<form method="post" action="<?php echo esc_url( admin_url( 'admin-post.php' ) ); ?>" class="carei-extras-form">
<input type="hidden" name="action" value="carei_save_extras_translations">
<?php wp_nonce_field( 'carei_extras_translations', 'carei_extras_nonce' ); ?>
<table class="form-table striped">
<thead>
<tr>
<th style="width: 40%;"><?php esc_html_e( 'Nazwa PL (z API Softra)', 'carei-reservation' ); ?></th>
<th><?php esc_html_e( 'Tłumaczenie EN', 'carei-reservation' ); ?></th>
</tr>
</thead>
<tbody>
<?php foreach ( $seen as $pl_name ) :
$en = isset( $trans[ $pl_name ] ) ? (string) $trans[ $pl_name ] : '';
?>
<tr>
<td><strong><?php echo esc_html( $pl_name ); ?></strong></td>
<td>
<input type="text" name="translations[<?php echo esc_attr( $pl_name ); ?>]" value="<?php echo esc_attr( $en ); ?>" class="regular-text" placeholder="<?php echo esc_attr__( 'EN translation...', 'carei-reservation' ); ?>">
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
<?php submit_button( __( 'Zapisz tłumaczenia', 'carei-reservation' ) ); ?>
</form>
<?php endif; ?>
</div>
<?php
}
public function handle_extras_translations_save() {
if ( ! current_user_can( 'manage_options' ) ) {
wp_die( esc_html__( 'Brak uprawnień.', 'carei-reservation' ) );
}
if ( ! isset( $_POST['carei_extras_nonce'] ) || ! wp_verify_nonce( $_POST['carei_extras_nonce'], 'carei_extras_translations' ) ) {
wp_die( esc_html__( 'Nieprawidłowy token.', 'carei-reservation' ) );
}
$input = isset( $_POST['translations'] ) && is_array( $_POST['translations'] ) ? $_POST['translations'] : array();
$clean = array();
foreach ( $input as $pl_name => $en_value ) {
$pl = trim( (string) wp_unslash( $pl_name ) );
$en = sanitize_text_field( wp_unslash( (string) $en_value ) );
if ( $pl === '' ) continue;
$clean[ $pl ] = $en;
}
update_option( self::EXTRAS_TRANSLATIONS_OPTION, $clean, false );
$redirect = add_query_arg(
array(
'post_type' => self::POST_TYPE,
'page' => 'carei-extras-translations',
'carei_saved' => '1',
),
admin_url( 'edit.php' )
);
wp_safe_redirect( $redirect );
exit;
}
// ─── Protection Packages (SOFT / PREMIUM) ────────────────────
@@ -35,16 +178,20 @@ class Carei_Admin_Panel {
public static function get_protection_packages_defaults() {
return array(
'soft' => array(
'name' => 'Ubezpieczenie SOFT',
'pricePerDay' => 0,
'active' => true,
'description' => '',
'name' => __( 'Ubezpieczenie SOFT', 'carei-reservation' ),
'name_en' => 'SOFT Protection',
'pricePerDay' => 0,
'active' => true,
'description' => '',
'description_en' => '',
),
'premium' => array(
'name' => 'Ubezpieczenie PREMIUM',
'pricePerDay' => 0,
'active' => true,
'description' => '',
'name' => __( 'Ubezpieczenie PREMIUM', 'carei-reservation' ),
'name_en' => 'PREMIUM Protection',
'pricePerDay' => 0,
'active' => true,
'description' => '',
'description_en' => '',
),
);
}
@@ -59,10 +206,12 @@ class Carei_Admin_Panel {
foreach ( $defaults as $key => $def ) {
$item = isset( $stored[ $key ] ) && is_array( $stored[ $key ] ) ? $stored[ $key ] : array();
$out[ $key ] = array(
'name' => isset( $item['name'] ) && $item['name'] !== '' ? (string) $item['name'] : $def['name'],
'pricePerDay' => isset( $item['pricePerDay'] ) ? (float) $item['pricePerDay'] : (float) $def['pricePerDay'],
'active' => isset( $item['active'] ) ? (bool) $item['active'] : (bool) $def['active'],
'description' => isset( $item['description'] ) ? (string) $item['description'] : $def['description'],
'name' => isset( $item['name'] ) && $item['name'] !== '' ? (string) $item['name'] : $def['name'],
'name_en' => isset( $item['name_en'] ) ? (string) $item['name_en'] : '',
'pricePerDay' => isset( $item['pricePerDay'] ) ? (float) $item['pricePerDay'] : (float) $def['pricePerDay'],
'active' => isset( $item['active'] ) ? (bool) $item['active'] : (bool) $def['active'],
'description' => isset( $item['description'] ) ? (string) $item['description'] : $def['description'],
'description_en' => isset( $item['description_en'] ) ? (string) $item['description_en'] : '',
);
}
return $out;
@@ -71,8 +220,8 @@ class Carei_Admin_Panel {
public function register_protection_packages_page() {
add_submenu_page(
'edit.php?post_type=' . self::POST_TYPE,
'Pakiety ochronne',
'Pakiety ochronne',
__( 'Pakiety ochronne', 'carei-reservation' ),
__( 'Pakiety ochronne', 'carei-reservation' ),
'manage_options',
'carei-protection-packages',
array( $this, 'render_protection_packages_page' )
@@ -81,16 +230,16 @@ class Carei_Admin_Panel {
public function render_protection_packages_page() {
if ( ! current_user_can( 'manage_options' ) ) {
wp_die( 'Brak uprawnień.' );
wp_die( esc_html__( 'Brak uprawnień.', 'carei-reservation' ) );
}
$data = self::get_protection_packages();
$saved = isset( $_GET['carei_saved'] ) && $_GET['carei_saved'] === '1';
?>
<div class="wrap">
<h1>Pakiety ochronne</h1>
<p>Konfiguracja pakietów wyświetlanych w sekcji <strong>Pakiety ochronne</strong> formularza rezerwacji. Cena podawana jest za dobę — total = cena × liczba dób rezerwacji.</p>
<h1><?php esc_html_e( 'Pakiety ochronne', 'carei-reservation' ); ?></h1>
<p><?php echo wp_kses( __( 'Konfiguracja pakietów wyświetlanych w sekcji <strong>Pakiety ochronne</strong> formularza rezerwacji. Cena podawana jest za dobę — total = cena × liczba dób rezerwacji.', 'carei-reservation' ), array( 'strong' => array() ) ); ?></p>
<?php if ( $saved ) : ?>
<div class="notice notice-success is-dismissible"><p>Zapisano.</p></div>
<div class="notice notice-success is-dismissible"><p><?php esc_html_e( 'Zapisano.', 'carei-reservation' ); ?></p></div>
<?php endif; ?>
<form method="post" action="<?php echo esc_url( admin_url( 'admin-post.php' ) ); ?>" class="carei-protection-form">
<input type="hidden" name="action" value="carei_save_protection_packages">
@@ -100,29 +249,43 @@ class Carei_Admin_Panel {
$pkg = $data[ $key ];
?>
<div class="carei-protection-card">
<h2>Pakiet <?php echo esc_html( $label ); ?></h2>
<h2><?php echo esc_html( sprintf( __( 'Pakiet %s', 'carei-reservation' ), $label ) ); ?></h2>
<table class="form-table">
<tr>
<th><label for="carei_<?php echo esc_attr( $key ); ?>_name">Nazwa wyświetlana</label></th>
<th><label for="carei_<?php echo esc_attr( $key ); ?>_name"><?php esc_html_e( 'Nazwa wyświetlana (PL)', 'carei-reservation' ); ?></label></th>
<td><input type="text" id="carei_<?php echo esc_attr( $key ); ?>_name" name="packages[<?php echo esc_attr( $key ); ?>][name]" value="<?php echo esc_attr( $pkg['name'] ); ?>" class="regular-text" required></td>
</tr>
<tr>
<th><label for="carei_<?php echo esc_attr( $key ); ?>_price">Cena za dobę (zł)</label></th>
<th><label for="carei_<?php echo esc_attr( $key ); ?>_name_en"><?php esc_html_e( 'Nazwa wyświetlana (EN)', 'carei-reservation' ); ?></label></th>
<td>
<input type="text" id="carei_<?php echo esc_attr( $key ); ?>_name_en" name="packages[<?php echo esc_attr( $key ); ?>][name_en]" value="<?php echo esc_attr( $pkg['name_en'] ); ?>" class="regular-text" placeholder="<?php echo esc_attr__( 'Np. SOFT Protection', 'carei-reservation' ); ?>">
<p class="description"><?php esc_html_e( 'Puste = fallback do wersji polskiej.', 'carei-reservation' ); ?></p>
</td>
</tr>
<tr>
<th><label for="carei_<?php echo esc_attr( $key ); ?>_price"><?php esc_html_e( 'Cena za dobę (zł)', 'carei-reservation' ); ?></label></th>
<td><input type="number" id="carei_<?php echo esc_attr( $key ); ?>_price" name="packages[<?php echo esc_attr( $key ); ?>][pricePerDay]" value="<?php echo esc_attr( $pkg['pricePerDay'] ); ?>" min="0" step="0.01" class="small-text" required></td>
</tr>
<tr>
<th>Status</th>
<td><label><input type="checkbox" name="packages[<?php echo esc_attr( $key ); ?>][active]" value="1" <?php checked( $pkg['active'] ); ?>> Aktywny (widoczny w modalu)</label></td>
<th><?php esc_html_e( 'Status', 'carei-reservation' ); ?></th>
<td><label><input type="checkbox" name="packages[<?php echo esc_attr( $key ); ?>][active]" value="1" <?php checked( $pkg['active'] ); ?>> <?php esc_html_e( 'Aktywny (widoczny w modalu)', 'carei-reservation' ); ?></label></td>
</tr>
<tr>
<th><label for="carei_<?php echo esc_attr( $key ); ?>_desc">Opis / zakres usług</label></th>
<th><label for="carei_<?php echo esc_attr( $key ); ?>_desc"><?php esc_html_e( 'Opis / zakres usług (PL)', 'carei-reservation' ); ?></label></th>
<td><textarea id="carei_<?php echo esc_attr( $key ); ?>_desc" name="packages[<?php echo esc_attr( $key ); ?>][description]" rows="3" cols="60" class="large-text"><?php echo esc_textarea( $pkg['description'] ); ?></textarea></td>
</tr>
<tr>
<th><label for="carei_<?php echo esc_attr( $key ); ?>_desc_en"><?php esc_html_e( 'Opis / zakres usług (EN)', 'carei-reservation' ); ?></label></th>
<td>
<textarea id="carei_<?php echo esc_attr( $key ); ?>_desc_en" name="packages[<?php echo esc_attr( $key ); ?>][description_en]" rows="3" cols="60" class="large-text" placeholder="<?php echo esc_attr__( 'Basic protection package...', 'carei-reservation' ); ?>"><?php echo esc_textarea( $pkg['description_en'] ); ?></textarea>
<p class="description"><?php esc_html_e( 'Puste = fallback do wersji polskiej.', 'carei-reservation' ); ?></p>
</td>
</tr>
</table>
</div>
<?php endforeach; ?>
<?php submit_button( 'Zapisz pakiety' ); ?>
<?php submit_button( __( 'Zapisz pakiety', 'carei-reservation' ) ); ?>
</form>
</div>
<style>
@@ -134,10 +297,10 @@ class Carei_Admin_Panel {
public function handle_protection_packages_save() {
if ( ! current_user_can( 'manage_options' ) ) {
wp_die( 'Brak uprawnień.' );
wp_die( esc_html__( 'Brak uprawnień.', 'carei-reservation' ) );
}
if ( ! isset( $_POST['carei_protection_nonce'] ) || ! wp_verify_nonce( $_POST['carei_protection_nonce'], 'carei_protection_packages' ) ) {
wp_die( 'Nieprawidłowy token.' );
wp_die( esc_html__( 'Nieprawidłowy token.', 'carei-reservation' ) );
}
$input = isset( $_POST['packages'] ) && is_array( $_POST['packages'] ) ? $_POST['packages'] : array();
@@ -145,16 +308,20 @@ class Carei_Admin_Panel {
$clean = array();
foreach ( $defaults as $key => $def ) {
$raw = isset( $input[ $key ] ) && is_array( $input[ $key ] ) ? $input[ $key ] : array();
$name = isset( $raw['name'] ) ? sanitize_text_field( wp_unslash( $raw['name'] ) ) : $def['name'];
$price = isset( $raw['pricePerDay'] ) ? (float) $raw['pricePerDay'] : 0;
$name = isset( $raw['name'] ) ? sanitize_text_field( wp_unslash( $raw['name'] ) ) : $def['name'];
$name_en = isset( $raw['name_en'] ) ? sanitize_text_field( wp_unslash( $raw['name_en'] ) ) : '';
$price = isset( $raw['pricePerDay'] ) ? (float) $raw['pricePerDay'] : 0;
if ( $price < 0 ) { $price = 0; }
$active = ! empty( $raw['active'] );
$desc = isset( $raw['description'] ) ? sanitize_textarea_field( wp_unslash( $raw['description'] ) ) : '';
$active = ! empty( $raw['active'] );
$desc = isset( $raw['description'] ) ? sanitize_textarea_field( wp_unslash( $raw['description'] ) ) : '';
$desc_en = isset( $raw['description_en'] ) ? sanitize_textarea_field( wp_unslash( $raw['description_en'] ) ) : '';
$clean[ $key ] = array(
'name' => $name !== '' ? $name : $def['name'],
'pricePerDay' => $price,
'active' => $active,
'description' => $desc,
'name' => $name !== '' ? $name : $def['name'],
'name_en' => $name_en,
'pricePerDay' => $price,
'active' => $active,
'description' => $desc,
'description_en' => $desc_en,
);
}
update_option( self::PROTECTION_OPTION, $clean );
@@ -174,15 +341,15 @@ class Carei_Admin_Panel {
public function register_post_type() {
register_post_type( self::POST_TYPE, array(
'labels' => array(
'name' => 'Rezerwacje',
'singular_name' => 'Rezerwacja',
'menu_name' => 'Rezerwacje',
'all_items' => 'Wszystkie rezerwacje',
'view_item' => 'Zobacz rezerwację',
'edit_item' => 'Szczegóły rezerwacji',
'search_items' => 'Szukaj rezerwacji',
'not_found' => 'Nie znaleziono rezerwacji',
'not_found_in_trash' => 'Brak rezerwacji w koszu',
'name' => __( 'Rezerwacje', 'carei-reservation' ),
'singular_name' => __( 'Rezerwacja', 'carei-reservation' ),
'menu_name' => __( 'Rezerwacje', 'carei-reservation' ),
'all_items' => __( 'Wszystkie rezerwacje', 'carei-reservation' ),
'view_item' => __( 'Zobacz rezerwację', 'carei-reservation' ),
'edit_item' => __( 'Szczegóły rezerwacji', 'carei-reservation' ),
'search_items' => __( 'Szukaj rezerwacji', 'carei-reservation' ),
'not_found' => __( 'Nie znaleziono rezerwacji', 'carei-reservation' ),
'not_found_in_trash' => __( 'Brak rezerwacji w koszu', 'carei-reservation' ),
),
'public' => false,
'show_ui' => true,
@@ -202,13 +369,13 @@ class Carei_Admin_Panel {
public function admin_columns( $columns ) {
return array(
'cb' => '<input type="checkbox" />',
'reservation_no' => 'Nr rezerwacji',
'client' => 'Klient',
'segment' => 'Segment',
'dates' => 'Daty',
'branch' => 'Oddział',
'carei_status' => 'Status',
'date' => 'Data',
'reservation_no' => __( 'Nr rezerwacji', 'carei-reservation' ),
'client' => __( 'Klient', 'carei-reservation' ),
'segment' => __( 'Segment', 'carei-reservation' ),
'dates' => __( 'Daty', 'carei-reservation' ),
'branch' => __( 'Oddział', 'carei-reservation' ),
'carei_status' => __( 'Status', 'carei-reservation' ),
'date' => __( 'Data', 'carei-reservation' ),
);
}
@@ -250,7 +417,7 @@ class Carei_Admin_Panel {
printf(
'<span class="carei-status-badge" style="background:%s;">%s</span>',
esc_attr( $info['color'] ),
esc_html( $info['label'] )
esc_html( self::get_status_label( $status ) )
);
break;
}
@@ -264,13 +431,13 @@ class Carei_Admin_Panel {
}
$current = isset( $_GET['carei_status'] ) ? sanitize_text_field( $_GET['carei_status'] ) : '';
echo '<select name="carei_status">';
echo '<option value="">Wszystkie statusy</option>';
echo '<option value="">' . esc_html__( 'Wszystkie statusy', 'carei-reservation' ) . '</option>';
foreach ( self::$statuses as $key => $info ) {
printf(
'<option value="%s"%s>%s</option>',
esc_attr( $key ),
selected( $current, $key, false ),
esc_html( $info['label'] )
esc_html( self::get_status_label( $key ) )
);
}
echo '</select>';
@@ -306,7 +473,7 @@ class Carei_Admin_Panel {
public function add_meta_boxes() {
add_meta_box(
'carei_reservation_details',
'Szczegóły rezerwacji',
__( 'Szczegóły rezerwacji', 'carei-reservation' ),
array( $this, 'render_meta_box' ),
self::POST_TYPE,
'normal',
@@ -345,7 +512,14 @@ class Carei_Admin_Panel {
$price = isset( $protection['pricePerDay'] ) ? (float) $protection['pricePerDay'] : 0;
$days = isset( $protection['days'] ) ? (int) $protection['days'] : 0;
$total = isset( $protection['total'] ) ? (float) $protection['total'] : ( $price * $days );
$protection_str = sprintf( '%s — %s zł/doba × %d = %s zł', $name, number_format( $price, 2, ',', ' ' ), $days, number_format( $total, 2, ',', ' ' ) );
$protection_str = sprintf(
/* translators: 1: package name, 2: price per day, 3: number of days, 4: total */
__( '%1$s — %2$s zł/doba × %3$d = %4$s zł', 'carei-reservation' ),
$name,
number_format( $price, 2, ',', ' ' ),
$days,
number_format( $total, 2, ',', ' ' )
);
}
$address = $meta['address'] ? json_decode( $meta['address'], true ) : null;
@@ -373,34 +547,34 @@ class Carei_Admin_Panel {
?>
<table class="carei-meta-table">
<tr><th>Nr rezerwacji</th><td><?php echo esc_html( $meta['reservation_no'] ?: '—' ); ?></td></tr>
<tr><th>ID rezerwacji (Softra)</th><td><?php echo esc_html( $meta['reservation_id'] ?: '—' ); ?></td></tr>
<tr><th>ID klienta (Softra)</th><td><?php echo esc_html( $meta['customer_id'] ?: '—' ); ?></td></tr>
<tr><th><?php esc_html_e( 'Nr rezerwacji', 'carei-reservation' ); ?></th><td><?php echo esc_html( $meta['reservation_no'] ?: '—' ); ?></td></tr>
<tr><th><?php esc_html_e( 'ID rezerwacji (Softra)', 'carei-reservation' ); ?></th><td><?php echo esc_html( $meta['reservation_id'] ?: '—' ); ?></td></tr>
<tr><th><?php esc_html_e( 'ID klienta (Softra)', 'carei-reservation' ); ?></th><td><?php echo esc_html( $meta['customer_id'] ?: '—' ); ?></td></tr>
<tr class="carei-meta-divider"><td colspan="2"><hr></td></tr>
<tr><th>Segment</th><td><?php echo esc_html( $meta['segment'] ?: '—' ); ?></td></tr>
<tr><th>Data od</th><td><?php echo esc_html( $from_fmt ); ?></td></tr>
<tr><th>Data do</th><td><?php echo esc_html( $to_fmt ); ?></td></tr>
<tr><th>Oddział odbioru</th><td><?php echo esc_html( $meta['pickup_branch'] ?: '—' ); ?></td></tr>
<tr><th>Oddział zwrotu</th><td><?php echo esc_html( $meta['return_branch'] ?: $meta['pickup_branch'] ?: '—' ); ?></td></tr>
<tr><th><?php esc_html_e( 'Segment', 'carei-reservation' ); ?></th><td><?php echo esc_html( $meta['segment'] ?: '—' ); ?></td></tr>
<tr><th><?php esc_html_e( 'Data od', 'carei-reservation' ); ?></th><td><?php echo esc_html( $from_fmt ); ?></td></tr>
<tr><th><?php esc_html_e( 'Data do', 'carei-reservation' ); ?></th><td><?php echo esc_html( $to_fmt ); ?></td></tr>
<tr><th><?php esc_html_e( 'Oddział odbioru', 'carei-reservation' ); ?></th><td><?php echo esc_html( $meta['pickup_branch'] ?: '—' ); ?></td></tr>
<tr><th><?php esc_html_e( 'Oddział zwrotu', 'carei-reservation' ); ?></th><td><?php echo esc_html( $meta['return_branch'] ?: $meta['pickup_branch'] ?: '—' ); ?></td></tr>
<tr class="carei-meta-divider"><td colspan="2"><hr></td></tr>
<tr><th>Imię</th><td><?php echo esc_html( $meta['first_name'] ?: '—' ); ?></td></tr>
<tr><th>Nazwisko</th><td><?php echo esc_html( $meta['last_name'] ?: '—' ); ?></td></tr>
<tr><th>Email</th><td><?php echo esc_html( $meta['email'] ?: '—' ); ?></td></tr>
<tr><th>Telefon</th><td><?php echo esc_html( $meta['phone'] ?: '—' ); ?></td></tr>
<tr><th>PESEL</th><td><?php echo esc_html( $meta['pesel'] ?: '—' ); ?></td></tr>
<tr><th>Adres</th><td><?php echo esc_html( $address_str ?: '—' ); ?></td></tr>
<tr><th><?php esc_html_e( 'Imię', 'carei-reservation' ); ?></th><td><?php echo esc_html( $meta['first_name'] ?: '—' ); ?></td></tr>
<tr><th><?php esc_html_e( 'Nazwisko', 'carei-reservation' ); ?></th><td><?php echo esc_html( $meta['last_name'] ?: '—' ); ?></td></tr>
<tr><th><?php esc_html_e( 'Email', 'carei-reservation' ); ?></th><td><?php echo esc_html( $meta['email'] ?: '—' ); ?></td></tr>
<tr><th><?php esc_html_e( 'Telefon', 'carei-reservation' ); ?></th><td><?php echo esc_html( $meta['phone'] ?: '—' ); ?></td></tr>
<tr><th><?php esc_html_e( 'PESEL', 'carei-reservation' ); ?></th><td><?php echo esc_html( $meta['pesel'] ?: '—' ); ?></td></tr>
<tr><th><?php esc_html_e( 'Adres', 'carei-reservation' ); ?></th><td><?php echo esc_html( $address_str ?: '—' ); ?></td></tr>
<tr class="carei-meta-divider"><td colspan="2"><hr></td></tr>
<tr><th>Opcje dodatkowe</th><td><?php echo esc_html( $extras_str ?: 'Brak' ); ?></td></tr>
<tr><th>Pakiet ochronny</th><td><?php echo esc_html( $protection_str ?: 'Brak' ); ?></td></tr>
<tr><th>Wiadomość</th><td><?php echo esc_html( $meta['comments'] ?: '—' ); ?></td></tr>
<tr><th><?php esc_html_e( 'Opcje dodatkowe', 'carei-reservation' ); ?></th><td><?php echo esc_html( $extras_str ?: __( 'Brak', 'carei-reservation' ) ); ?></td></tr>
<tr><th><?php esc_html_e( 'Pakiet ochronny', 'carei-reservation' ); ?></th><td><?php echo esc_html( $protection_str ?: __( 'Brak', 'carei-reservation' ) ); ?></td></tr>
<tr><th><?php esc_html_e( 'Wiadomość', 'carei-reservation' ); ?></th><td><?php echo esc_html( $meta['comments'] ?: '—' ); ?></td></tr>
<tr class="carei-meta-divider"><td colspan="2"><hr></td></tr>
<tr>
<th>Status</th>
<th><?php esc_html_e( 'Status', 'carei-reservation' ); ?></th>
<td>
<select name="carei_status">
<?php foreach ( self::$statuses as $key => $info ) : ?>
<option value="<?php echo esc_attr( $key ); ?>" <?php selected( $meta['status'], $key ); ?>>
<?php echo esc_html( $info['label'] ); ?>
<?php echo esc_html( self::get_status_label( $key ) ); ?>
</option>
<?php endforeach; ?>
</select>
@@ -513,7 +687,13 @@ class Carei_Admin_Panel {
$first_name = isset( $driver['firstName'] ) ? $driver['firstName'] : '';
$last_name = isset( $driver['lastName'] ) ? $driver['lastName'] : '';
$title = sprintf( 'Rezerwacja #%s — %s %s', $reservation_no ?: $reservation_id, $first_name, $last_name );
$title = sprintf(
/* translators: 1: reservation number or ID, 2: first name, 3: last name */
__( 'Rezerwacja #%1$s — %2$s %3$s', 'carei-reservation' ),
$reservation_no ?: $reservation_id,
$first_name,
$last_name
);
$post_id = wp_insert_post( array(
'post_type' => self::POST_TYPE,