| 1 |
<?php |
| 2 |
/** |
| 3 |
* Setup Wizard Booking Resources editor template. |
| 4 |
* |
| 5 |
* @package Booking Calendar |
| 6 |
* @var array<string,mixed> $template_context Authorized step context. |
| 7 |
*/ |
| 8 |
|
| 9 |
if ( ! defined( 'ABSPATH' ) ) { |
| 10 |
exit; |
| 11 |
} |
| 12 |
|
| 13 |
$step_data = $template_context['step_data']; |
| 14 |
$existing_resources = isset( $step_data['existing_resources'] ) && is_array( $step_data['existing_resources'] ) ? $step_data['existing_resources'] : array(); |
| 15 |
$booking_resources = isset( $step_data['booking_resources'] ) && is_array( $step_data['booking_resources'] ) ? $step_data['booking_resources'] : array(); |
| 16 |
$existing_resource_updates = isset( $step_data['existing_resource_updates'] ) && is_array( $step_data['existing_resource_updates'] ) ? $step_data['existing_resource_updates'] : array(); |
| 17 |
$can_create_resources = ! empty( $step_data['can_create_resources'] ); |
| 18 |
$pricing_available = ! empty( $step_data['pricing_available'] ); |
| 19 |
$media_upload_available = ! empty( $step_data['media_upload_available'] ); |
| 20 |
$currency_symbol = isset( $step_data['currency_symbol'] ) ? (string) $step_data['currency_symbol'] : '$'; |
| 21 |
$max_resource_drafts = isset( $step_data['max_resource_drafts'] ) ? absint( $step_data['max_resource_drafts'] ) : 0; |
| 22 |
$booking_resources_json = wp_json_encode( $booking_resources ); |
| 23 |
$booking_resources_json = false === $booking_resources_json ? '[]' : $booking_resources_json; |
| 24 |
$existing_resources_json = wp_json_encode( $existing_resources ); |
| 25 |
$existing_resources_json = false === $existing_resources_json ? '[]' : $existing_resources_json; |
| 26 |
$existing_updates_json = wp_json_encode( $existing_resource_updates ); |
| 27 |
$existing_updates_json = false === $existing_updates_json ? '[]' : $existing_updates_json; |
| 28 |
?> |
| 29 |
<section class="wpbc_setup_wizard__step-content wpbc_setup_wizard__booking-resources-step" aria-labelledby="wpbc-setup-wizard-step-title"> |
| 30 |
<header class="wpbc_setup_wizard__step-heading"> |
| 31 |
<h1 id="wpbc-setup-wizard-step-title"><?php esc_html_e( 'Create your booking resources', 'booking' ); ?></h1> |
| 32 |
<p class="wpbc_setup_wizard__lead"><?php esc_html_e( 'Add the spaces, equipment, or other full-day items customers can book.', 'booking' ); ?></p> |
| 33 |
</header> |
| 34 |
<?php |
| 35 |
$template_context['templates']->render( |
| 36 |
'settings-hint', |
| 37 |
array( 'settings_hint' => $template_context['settings_hint'] ) |
| 38 |
); |
| 39 |
?> |
| 40 |
|
| 41 |
<form id="wpbc-setup-wizard-step-form" novalidate> |
| 42 |
<input |
| 43 |
type="hidden" |
| 44 |
name="booking_resources" |
| 45 |
value="<?php echo esc_attr( $booking_resources_json ); ?>" |
| 46 |
required |
| 47 |
data-wpbc-setup-wizard-field |
| 48 |
data-wpbc-booking-resource-drafts |
| 49 |
data-max-resource-drafts="<?php echo esc_attr( (string) $max_resource_drafts ); ?>" |
| 50 |
aria-describedby="wpbc-setup-wizard-booking-resources-error" |
| 51 |
> |
| 52 |
<input |
| 53 |
type="hidden" |
| 54 |
name="existing_booking_resources" |
| 55 |
value="<?php echo esc_attr( $existing_updates_json ); ?>" |
| 56 |
data-wpbc-setup-wizard-field |
| 57 |
data-wpbc-existing-resource-updates |
| 58 |
aria-describedby="wpbc-setup-wizard-existing-booking-resources-error" |
| 59 |
> |
| 60 |
<input type="hidden" value="<?php echo esc_attr( $existing_resources_json ); ?>" data-wpbc-existing-resource-source> |
| 61 |
|
| 62 |
<div class="wpbc_setup_wizard__booking-resources-layout" data-wpbc-booking-resources-editor data-can-create="<?php echo $can_create_resources ? 'true' : 'false'; ?>" data-pricing-available="<?php echo $pricing_available ? 'true' : 'false'; ?>" data-media-upload-available="<?php echo $media_upload_available ? 'true' : 'false'; ?>"> |
| 63 |
<aside class="wpbc_setup_wizard__booking-resources-list-panel" aria-labelledby="wpbc-setup-wizard-booking-resources-list-title"> |
| 64 |
<h2 id="wpbc-setup-wizard-booking-resources-list-title"><?php esc_html_e( 'Your booking resources', 'booking' ); ?></h2> |
| 65 |
|
| 66 |
<section class="wpbc_setup_wizard__resource-list-section wpbc_setup_wizard__resource-list-section--new" aria-labelledby="wpbc-setup-wizard-new-resources-title"> |
| 67 |
<h3 id="wpbc-setup-wizard-new-resources-title"><?php esc_html_e( 'New in this setup', 'booking' ); ?></h3> |
| 68 |
<p><?php esc_html_e( 'Create new Booking Resources for this booking flow.', 'booking' ); ?></p> |
| 69 |
<div class="wpbc_setup_wizard__new-resource-list" role="group" aria-label="<?php esc_attr_e( 'New Booking Resources to edit', 'booking' ); ?>" data-wpbc-new-resource-list></div> |
| 70 |
</section> |
| 71 |
|
| 72 |
<div class="wpbc_setup_wizard__add-resource-wrap"> |
| 73 |
<button type="button" class="button button-secondary wpbc_setup_wizard__add-resource" data-wpbc-add-resource <?php disabled( ! $can_create_resources ); ?>> |
| 74 |
<i class="menu_icon icon-1x wpbc_icn_add" aria-hidden="true"></i> |
| 75 |
<span><?php esc_html_e( 'Add another booking resource', 'booking' ); ?></span> |
| 76 |
<?php if ( ! $can_create_resources ) : ?><span class="wpbc_setup_wizard__edition-badge"><?php esc_html_e( 'Pro', 'booking' ); ?></span><?php endif; ?> |
| 77 |
</button> |
| 78 |
<?php if ( ! $can_create_resources ) : ?><p><?php esc_html_e( 'Additional Booking Resources are available in Pro versions.', 'booking' ); ?></p><?php endif; ?> |
| 79 |
</div> |
| 80 |
|
| 81 |
<?php if ( ! empty( $existing_resources ) ) : ?> |
| 82 |
<section class="wpbc_setup_wizard__resource-list-section wpbc_setup_wizard__resource-list-section--existing" aria-labelledby="wpbc-setup-wizard-existing-resources-title"> |
| 83 |
<h3 id="wpbc-setup-wizard-existing-resources-title"><?php esc_html_e( 'Existing booking resources', 'booking' ); ?></h3> |
| 84 |
<p><?php esc_html_e( 'Select an existing Booking Resource to edit its details.', 'booking' ); ?></p> |
| 85 |
<div class="wpbc_setup_wizard__existing-resource-list" role="group" aria-label="<?php esc_attr_e( 'Existing Booking Resources to edit', 'booking' ); ?>" data-wpbc-existing-resource-list> |
| 86 |
<?php foreach ( $existing_resources as $resource_index => $existing_resource ) : ?> |
| 87 |
<label class="wpbc_setup_wizard__existing-resource-card" data-wpbc-existing-resource-card data-resource-index="<?php echo esc_attr( (string) $resource_index ); ?>"> |
| 88 |
<input class="screen-reader-text" type="radio" name="wpbc_setup_wizard_resource_editor_selection" value="existing-<?php echo esc_attr( (string) absint( $existing_resource['id'] ) ); ?>" data-wpbc-resource-selection="existing:<?php echo esc_attr( (string) $resource_index ); ?>"> |
| 89 |
<span class="wpbc_setup_wizard__radio-mark" aria-hidden="true"></span> |
| 90 |
<span class="wpbc_setup_wizard__resource-card-picture"> |
| 91 |
<img src="<?php echo esc_url( $existing_resource['picture_url'] ); ?>" alt="" <?php echo empty( $existing_resource['picture_url'] ) ? 'hidden' : ''; ?>> |
| 92 |
<i class="menu_icon icon-1x wpbc-bi-image-fill" aria-hidden="true" <?php echo empty( $existing_resource['picture_url'] ) ? '' : 'hidden'; ?>></i> |
| 93 |
</span> |
| 94 |
<span class="wpbc_setup_wizard__resource-card-copy"> |
| 95 |
<span class="wpbc_setup_wizard__resource-card-title-row"> |
| 96 |
<strong><?php echo esc_html( $existing_resource['title'] ); ?></strong> |
| 97 |
<span |
| 98 |
class="wpbc_setup_wizard__resource-status-badge is-existing" |
| 99 |
data-wpbc-resource-status |
| 100 |
data-existing-label="<?php esc_attr_e( 'Existing', 'booking' ); ?>" |
| 101 |
data-changed-label="<?php esc_attr_e( 'Changed', 'booking' ); ?>" |
| 102 |
aria-live="polite" |
| 103 |
><?php esc_html_e( 'Existing', 'booking' ); ?></span> |
| 104 |
</span> |
| 105 |
</span> |
| 106 |
</label> |
| 107 |
<?php endforeach; ?> |
| 108 |
</div> |
| 109 |
</section> |
| 110 |
<?php endif; ?> |
| 111 |
</aside> |
| 112 |
|
| 113 |
<section class="wpbc_setup_wizard__resource-details-panel" aria-labelledby="wpbc-setup-wizard-resource-details-title" data-wpbc-resource-details> |
| 114 |
<header class="wpbc_setup_wizard__resource-details-heading"> |
| 115 |
<h2 id="wpbc-setup-wizard-resource-details-title"><?php esc_html_e( 'Booking resource details', 'booking' ); ?></h2> |
| 116 |
<span><?php esc_html_e( '* Required fields', 'booking' ); ?></span> |
| 117 |
</header> |
| 118 |
|
| 119 |
<div class="wpbc_setup_wizard__resource-empty" data-wpbc-resource-empty> |
| 120 |
<p><?php echo esc_html( $can_create_resources ? __( 'Select an existing Booking Resource to edit it, or add a new Resource.', 'booking' ) : __( 'Select your existing Booking Resource to edit its details.', 'booking' ) ); ?></p> |
| 121 |
</div> |
| 122 |
|
| 123 |
<div class="wpbc_setup_wizard__resource-details-fields" data-wpbc-resource-fields hidden> |
| 124 |
<div class="wpbc_setup_wizard__field wpbc_setup_wizard__resource-title-field"> |
| 125 |
<label for="wpbc-setup-wizard-resource-title"><?php esc_html_e( 'Resource name', 'booking' ); ?> <span aria-hidden="true">*</span></label> |
| 126 |
<input id="wpbc-setup-wizard-resource-title" type="text" maxlength="200" required data-wpbc-resource-field="title" data-wpbc-setup-wizard-error-control-for="booking_resources"> |
| 127 |
</div> |
| 128 |
|
| 129 |
<div class="wpbc_setup_wizard__field wpbc_setup_wizard__resource-price-field"> |
| 130 |
<label for="wpbc-setup-wizard-resource-price"> |
| 131 |
<?php printf( esc_html__( 'Base cost (%s)', 'booking' ), esc_html( $currency_symbol ) ); ?> |
| 132 |
<?php if ( ! $pricing_available ) : ?><span class="wpbc_setup_wizard__edition-badge"><?php esc_html_e( 'Business Small+', 'booking' ); ?></span><?php endif; ?> |
| 133 |
</label> |
| 134 |
<input id="wpbc-setup-wizard-resource-price" type="number" min="0" step="0.01" data-wpbc-resource-field="base_cost" <?php disabled( ! $pricing_available ); ?>> |
| 135 |
<span class="wpbc_setup_wizard__field-help"><?php echo esc_html( $pricing_available ? __( 'Default price for this Booking Resource.', 'booking' ) : __( 'Pricing is available in Business Small or higher.', 'booking' ) ); ?></span> |
| 136 |
</div> |
| 137 |
|
| 138 |
<div class="wpbc_setup_wizard__field wpbc_setup_wizard__resource-description-field"> |
| 139 |
<label for="wpbc-setup-wizard-resource-description"><?php esc_html_e( 'Description', 'booking' ); ?></label> |
| 140 |
<textarea id="wpbc-setup-wizard-resource-description" maxlength="2000" rows="7" data-wpbc-resource-field="description"></textarea> |
| 141 |
</div> |
| 142 |
|
| 143 |
<div class="wpbc_setup_wizard__field wpbc_setup_wizard__resource-picture-field"> |
| 144 |
<label><?php esc_html_e( 'Picture (optional)', 'booking' ); ?></label> |
| 145 |
<div class="wpbc_setup_wizard__resource-picture-preview" data-wpbc-resource-picture-preview> |
| 146 |
<img alt="" hidden data-wpbc-resource-picture-image> |
| 147 |
<i class="menu_icon icon-1x wpbc-bi-image-fill" aria-hidden="true" data-wpbc-resource-picture-placeholder></i> |
| 148 |
</div> |
| 149 |
<input id="wpbc-setup-wizard-resource-picture-url" type="hidden" data-wpbc-resource-field="picture_url"> |
| 150 |
<div class="wpbc_setup_wizard__resource-picture-actions"> |
| 151 |
<button type="button" class="button button-secondary wpbc_media_upload_button" data-modal_title="<?php esc_attr_e( 'Select Booking Resource image', 'booking' ); ?>" data-btn_title="<?php esc_attr_e( 'Use this image', 'booking' ); ?>" data-url_field="wpbc-setup-wizard-resource-picture-url" <?php disabled( ! $media_upload_available ); ?>><?php esc_html_e( 'Select image', 'booking' ); ?></button> |
| 152 |
<button type="button" class="button button-secondary" data-wpbc-remove-resource-picture><?php esc_html_e( 'Remove', 'booking' ); ?></button> |
| 153 |
</div> |
| 154 |
</div> |
| 155 |
|
| 156 |
</div> |
| 157 |
</section> |
| 158 |
</div> |
| 159 |
<span class="wpbc_setup_wizard__field-error wpbc_setup_wizard__field-error--group" id="wpbc-setup-wizard-booking-resources-error" data-wpbc-setup-wizard-error-for="booking_resources"></span> |
| 160 |
<span class="wpbc_setup_wizard__field-error wpbc_setup_wizard__field-error--group" id="wpbc-setup-wizard-existing-booking-resources-error" data-wpbc-setup-wizard-error-for="existing_booking_resources"></span> |
| 161 |
</form> |
| 162 |
|
| 163 |
<template data-wpbc-resource-card-template> |
| 164 |
<div class="wpbc_setup_wizard__resource-card"> |
| 165 |
<label class="wpbc_setup_wizard__resource-card-selection"> |
| 166 |
<input class="screen-reader-text" type="radio" name="wpbc_setup_wizard_resource_editor_selection"> |
| 167 |
<span class="wpbc_setup_wizard__radio-mark" aria-hidden="true"></span> |
| 168 |
<span class="wpbc_setup_wizard__resource-card-picture"><img alt="" hidden><i class="menu_icon icon-1x wpbc-bi-image-fill" aria-hidden="true"></i></span> |
| 169 |
<span class="wpbc_setup_wizard__resource-card-copy"> |
| 170 |
<span class="wpbc_setup_wizard__resource-card-title-row"> |
| 171 |
<strong></strong> |
| 172 |
<span class="wpbc_setup_wizard__resource-status-badge is-new"><?php esc_html_e( 'New', 'booking' ); ?></span> |
| 173 |
</span> |
| 174 |
</span> |
| 175 |
</label> |
| 176 |
<button type="button" class="wpbc_setup_wizard__resource-card-remove" data-wpbc-remove-resource aria-label="<?php esc_attr_e( 'Remove Booking Resource', 'booking' ); ?>" title="<?php esc_attr_e( 'Remove Booking Resource', 'booking' ); ?>"><i class="menu_icon icon-1x wpbc_icn_delete_outline" aria-hidden="true"></i></button> |
| 177 |
</div> |
| 178 |
</template> |
| 179 |
</section> |
| 180 |
|