first commit
This commit is contained in:
@@ -0,0 +1,243 @@
|
||||
<?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_id = $yacht ? \YachtBooking\Yacht::get_gcal_id( $yacht->ID ) : '';
|
||||
$ical_import_url = $yacht ? \YachtBooking\Integrations\ICal\ICal_Import::get_import_url( $yacht->ID ) : '';
|
||||
$ical_feed_url = $yacht ? \YachtBooking\Integrations\ICal\ICal_Feed::get_feed_url( $yacht->ID ) : '';
|
||||
$ical_last_import = $yacht ? \YachtBooking\Integrations\ICal\ICal_Import::get_last_import_time( $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>
|
||||
|
||||
<!-- Google Calendar ID -->
|
||||
<tr>
|
||||
<th scope="row">
|
||||
<label for="yacht_gcal_id">
|
||||
<?php esc_html_e( 'Google Calendar ID', 'yacht-booking' ); ?>
|
||||
</label>
|
||||
</th>
|
||||
<td>
|
||||
<input
|
||||
type="text"
|
||||
name="yacht_gcal_id"
|
||||
id="yacht_gcal_id"
|
||||
value="<?php echo esc_attr( $gcal_id ); ?>"
|
||||
class="regular-text code"
|
||||
placeholder="nazwa@group.calendar.google.com"
|
||||
/>
|
||||
<p class="description">
|
||||
<?php
|
||||
echo wp_kses_post(
|
||||
sprintf(
|
||||
/* translators: %s: link to Google Calendar settings */
|
||||
__( 'ID kalendarza Google do synchronizacji rezerwacji. <a href="%s" target="_blank">Jak znaleźć Calendar ID?</a>', 'yacht-booking' ),
|
||||
'https://docs.simplecalendar.io/find-google-calendar-id/'
|
||||
)
|
||||
);
|
||||
?>
|
||||
</p>
|
||||
<?php if ( $gcal_id ) : ?>
|
||||
<p class="gcal-status connected">
|
||||
<span class="dashicons dashicons-yes-alt"></span>
|
||||
<?php esc_html_e( 'Połączony z Google Calendar', 'yacht-booking' ); ?>
|
||||
</p>
|
||||
<?php endif; ?>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<!-- iCal Import URL -->
|
||||
<tr>
|
||||
<th scope="row">
|
||||
<label for="yacht_ical_import_url">
|
||||
<?php esc_html_e( 'Import iCal (URL)', 'yacht-booking' ); ?>
|
||||
</label>
|
||||
</th>
|
||||
<td>
|
||||
<input
|
||||
type="url"
|
||||
name="yacht_ical_import_url"
|
||||
id="yacht_ical_import_url"
|
||||
value="<?php echo esc_attr( $ical_import_url ); ?>"
|
||||
class="large-text code"
|
||||
placeholder="https://calendar.google.com/calendar/ical/...basic.ics"
|
||||
/>
|
||||
<p class="description">
|
||||
<?php esc_html_e( 'Wklej adres URL pliku .ics z Google Calendar (lub innego kalendarza). Wydarzenia zostaną zaimportowane jako zablokowane terminy (synchronizacja co godzinę).', 'yacht-booking' ); ?>
|
||||
</p>
|
||||
<p class="description">
|
||||
<strong><?php esc_html_e( 'Jak uzyskać link iCal z Google Calendar:', 'yacht-booking' ); ?></strong>
|
||||
<?php esc_html_e( 'Google Calendar → Ustawienia → Wybierz kalendarz → „Tajny adres w formacie iCal" → Skopiuj link.', 'yacht-booking' ); ?>
|
||||
</p>
|
||||
<?php if ( $ical_last_import ) : ?>
|
||||
<p>
|
||||
<span class="dashicons dashicons-update" style="color: #2271b1;"></span>
|
||||
<?php
|
||||
printf(
|
||||
/* translators: %s: date/time */
|
||||
esc_html__( 'Ostatni import: %s', 'yacht-booking' ),
|
||||
esc_html( $ical_last_import )
|
||||
);
|
||||
?>
|
||||
</p>
|
||||
<?php endif; ?>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<?php if ( $yacht ) : ?>
|
||||
<!-- iCal Export Feed URL -->
|
||||
<tr>
|
||||
<th scope="row">
|
||||
<?php esc_html_e( 'Eksport iCal (feed)', 'yacht-booking' ); ?>
|
||||
</th>
|
||||
<td>
|
||||
<input
|
||||
type="text"
|
||||
value="<?php echo esc_attr( $ical_feed_url ); ?>"
|
||||
class="large-text code"
|
||||
readonly
|
||||
onclick="this.select();"
|
||||
/>
|
||||
<p class="description">
|
||||
<?php esc_html_e( 'Skopiuj ten link i dodaj go w Google Calendar (Inne kalendarze → Z adresu URL), aby rezerwacje z tego systemu pojawiły się w Twoim kalendarzu.', 'yacht-booking' ); ?>
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endif; ?>
|
||||
</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>
|
||||
Reference in New Issue
Block a user