192 lines
5.8 KiB
PHP
192 lines
5.8 KiB
PHP
<?php
|
|
/**
|
|
* Yacht Edit Form View
|
|
*
|
|
* @package YachtBooking
|
|
*/
|
|
|
|
// Exit if accessed directly
|
|
if ( ! defined( 'ABSPATH' ) ) {
|
|
exit;
|
|
}
|
|
|
|
// Get yacht data
|
|
$title = $yacht ? $yacht->post_title : '';
|
|
$content = $yacht ? $yacht->post_content : '';
|
|
$gcal_alias = $yacht ? \YachtBooking\Yacht::get_gcal_alias( $yacht->ID ) : '';
|
|
$yacht_color = $yacht ? \YachtBooking\Yacht::get_color( $yacht->ID ) : '';
|
|
|
|
$page_title = $yacht ? __( 'Edytuj Jacht', 'yacht-booking' ) : __( 'Dodaj Jacht', 'yacht-booking' );
|
|
?>
|
|
|
|
<div class="wrap">
|
|
<h1><?php echo esc_html( $page_title ); ?></h1>
|
|
|
|
<?php
|
|
// Success message
|
|
if ( isset( $_GET['saved'] ) ) {
|
|
echo '<div class="notice notice-success is-dismissible"><p>' . esc_html__( 'Jacht został zapisany.', 'yacht-booking' ) . '</p></div>';
|
|
}
|
|
?>
|
|
|
|
<form method="post" action="" class="yacht-edit-form">
|
|
<?php wp_nonce_field( 'yacht_booking_save_yacht', 'yacht_booking_nonce' ); ?>
|
|
<input type="hidden" name="yacht_booking_save_yacht" value="1" />
|
|
|
|
<table class="form-table" role="presentation">
|
|
<tbody>
|
|
<!-- Nazwa jachtu -->
|
|
<tr>
|
|
<th scope="row">
|
|
<label for="yacht_title">
|
|
<?php esc_html_e( 'Nazwa jachtu', 'yacht-booking' ); ?>
|
|
<span class="description"> (<?php esc_html_e( 'wymagane', 'yacht-booking' ); ?>)</span>
|
|
</label>
|
|
</th>
|
|
<td>
|
|
<input
|
|
type="text"
|
|
name="yacht_title"
|
|
id="yacht_title"
|
|
value="<?php echo esc_attr( $title ); ?>"
|
|
class="regular-text"
|
|
required
|
|
/>
|
|
<p class="description">
|
|
<?php esc_html_e( 'Podaj nazwę jachtu, np. "Laguna 42" lub "Bavaria Cruiser 46"', 'yacht-booking' ); ?>
|
|
</p>
|
|
</td>
|
|
</tr>
|
|
|
|
<!-- Opis jachtu -->
|
|
<tr>
|
|
<th scope="row">
|
|
<label for="yacht_description">
|
|
<?php esc_html_e( 'Opis jachtu', 'yacht-booking' ); ?>
|
|
</label>
|
|
</th>
|
|
<td>
|
|
<?php
|
|
wp_editor(
|
|
$content,
|
|
'yacht_description',
|
|
array(
|
|
'textarea_name' => 'yacht_description',
|
|
'textarea_rows' => 10,
|
|
'media_buttons' => true,
|
|
'teeny' => false,
|
|
'tinymce' => array(
|
|
'toolbar1' => 'formatselect,bold,italic,underline,bullist,numlist,link,unlink,blockquote,alignleft,aligncenter,alignright',
|
|
),
|
|
)
|
|
);
|
|
?>
|
|
<p class="description">
|
|
<?php esc_html_e( 'Szczegółowy opis jachtu: parametry techniczne, wyposażenie, udogodnienia itp.', 'yacht-booking' ); ?>
|
|
</p>
|
|
</td>
|
|
</tr>
|
|
|
|
<!-- Kolor jachtu w kalendarzu zbiorczym -->
|
|
<tr>
|
|
<th scope="row">
|
|
<label for="yacht_color">
|
|
<?php esc_html_e( 'Kolor w kalendarzu zbiorczym', 'yacht-booking' ); ?>
|
|
</label>
|
|
</th>
|
|
<td>
|
|
<input
|
|
type="text"
|
|
name="yacht_color"
|
|
id="yacht_color"
|
|
class="yacht-color-picker"
|
|
value="<?php echo esc_attr( $yacht_color ); ?>"
|
|
data-default-color=""
|
|
/>
|
|
<p class="description">
|
|
<?php esc_html_e( 'Kolor pasków rezerwacji tego jachtu w widgecie zbiorczym (/rezerwacja/). Pozostaw puste, aby użyć automatycznego koloru z palety.', 'yacht-booking' ); ?>
|
|
</p>
|
|
</td>
|
|
</tr>
|
|
|
|
<!-- Alias dla globalnej synchronizacji iCal -->
|
|
<tr>
|
|
<th scope="row">
|
|
<label for="yacht_gcal_alias">
|
|
<?php esc_html_e( 'Alias dla Google Calendar', 'yacht-booking' ); ?>
|
|
</label>
|
|
</th>
|
|
<td>
|
|
<input
|
|
type="text"
|
|
name="yacht_gcal_alias"
|
|
id="yacht_gcal_alias"
|
|
value="<?php echo esc_attr( $gcal_alias ); ?>"
|
|
class="regular-text"
|
|
placeholder="<?php echo esc_attr( $title ); ?>"
|
|
/>
|
|
<p class="description">
|
|
<?php esc_html_e( 'Opcjonalny krótki alias używany w tytule eventu Google Calendar (np. "Maja" zamiast "Marina Maja Sailing 35"). Plugin rozpoznaje jacht po prefiksie tytułu eventu w formacie "Alias - opis". Jeśli puste — używana jest pełna nazwa jachtu.', 'yacht-booking' ); ?>
|
|
</p>
|
|
</td>
|
|
</tr>
|
|
|
|
</tbody>
|
|
</table>
|
|
|
|
<?php submit_button( __( 'Zapisz jacht', 'yacht-booking' ), 'primary large', 'submit', true ); ?>
|
|
|
|
<?php if ( $yacht ) : ?>
|
|
<p>
|
|
<a href="<?php echo esc_url( admin_url( 'admin.php?page=yacht-bookings' ) ); ?>" class="button button-secondary">
|
|
<?php esc_html_e( 'Anuluj', 'yacht-booking' ); ?>
|
|
</a>
|
|
<a
|
|
href="<?php echo esc_url( wp_nonce_url( admin_url( 'admin.php?page=yacht-bookings&action=delete&yacht=' . $yacht->ID ), 'delete_yacht_' . $yacht->ID ) ); ?>"
|
|
class="button button-link-delete"
|
|
onclick="return confirm('<?php echo esc_js( __( 'Czy na pewno chcesz usunąć ten jacht? Spowoduje to również usunięcie wszystkich powiązanych rezerwacji.', 'yacht-booking' ) ); ?>');"
|
|
style="color: #b32d2e; margin-left: 10px;"
|
|
>
|
|
<?php esc_html_e( 'Usuń jacht', 'yacht-booking' ); ?>
|
|
</a>
|
|
</p>
|
|
<?php endif; ?>
|
|
</form>
|
|
|
|
<?php if ( $yacht ) : ?>
|
|
<!-- Informacje o rezerwacjach -->
|
|
<hr />
|
|
<h2><?php esc_html_e( 'Powiązane rezerwacje', 'yacht-booking' ); ?></h2>
|
|
<?php
|
|
$bookings = get_posts(
|
|
array(
|
|
'post_type' => 'yacht_booking',
|
|
'posts_per_page' => -1,
|
|
'meta_query' => array(
|
|
array(
|
|
'key' => '_booking_yacht_id',
|
|
'value' => $yacht->ID,
|
|
),
|
|
),
|
|
)
|
|
);
|
|
|
|
if ( $bookings ) :
|
|
?>
|
|
<p>
|
|
<?php
|
|
printf(
|
|
esc_html( _n( 'Ten jacht ma %d rezerwację.', 'Ten jacht ma %d rezerwacji.', count( $bookings ), 'yacht-booking' ) ),
|
|
count( $bookings )
|
|
);
|
|
?>
|
|
<a href="<?php echo esc_url( admin_url( 'admin.php?page=yacht-bookings-list&yacht_id=' . $yacht->ID ) ); ?>">
|
|
<?php esc_html_e( 'Zobacz rezerwacje', 'yacht-booking' ); ?>
|
|
</a>
|
|
</p>
|
|
<?php else : ?>
|
|
<p><?php esc_html_e( 'Brak rezerwacji dla tego jachtu.', 'yacht-booking' ); ?></p>
|
|
<?php endif; ?>
|
|
<?php endif; ?>
|
|
</div>
|