Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

['ET-2103] Populate Start and End sale dates when creating a new ticket. #3132

Merged
Merged
Show file tree
Hide file tree
Changes from 12 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions changelog/tweak-ET-2103_populate_start_end_sale_dates
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: minor
Type: tweak

Start Sale and End Sale date will autopopulate when creating a new ticket. [ET-2103]
20 changes: 16 additions & 4 deletions src/admin-views/editor/panel/fields/dates.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,18 @@
* @var array<string,mixed> $ticket The ticket.
*/

use Tribe__Date_Utils as Date_Utils;

// Default values for the Start date & time fields.
$datepicker_format = Tribe__Date_Utils::datepicker_formats( Tribe__Date_Utils::get_datepicker_format_index() );
//phpcs:ignore WordPress.DateTime.RestrictedFunctions.date_date
$default_start_date = Date_Utils::build_date_object( 'now' )->format( $datepicker_format );
$default_start_time = '00:00:00';
//phpcs:ignore WordPress.DateTime.RestrictedFunctions.date_date
$default_end_date = Date_Utils::build_date_object( strtotime( '+1 day' ) )->format( $datepicker_format );
redscar marked this conversation as resolved.
Show resolved Hide resolved

$default_end_time = '00:00:00';

?>
<div class="input_block">
<label class="ticket_form_label ticket_form_left" for="ticket_start_date">
Expand All @@ -33,7 +45,7 @@
class="tribe-datepicker tribe-field-start_date ticket_field"
name="ticket_start_date"
id="ticket_start_date"
value="<?php echo esc_attr( $ticket ? $ticket_start_date : null ); ?>"
value="<?php echo esc_attr( $ticket ? $ticket_start_date : $default_start_date ); ?>"
data-validation-type="datepicker"
data-validation-is-less-or-equal-to="#ticket_end_date"
data-validation-error="<?php echo esc_attr( wp_json_encode( $start_date_errors ) ); ?>"
Expand All @@ -49,7 +61,7 @@ class="tribe-timepicker tribe-field-start_time ticket_field"
<?php echo Tribe__View_Helpers::is_24hr_format() ? 'data-format="H:i"' : ''; ?>
data-step="<?php echo esc_attr( $timepicker_step ); ?>"
data-round="<?php echo esc_attr( $timepicker_round ); ?>"
value="<?php echo esc_attr( $ticket_start_time ); ?>"
value="<?php echo esc_attr( $ticket ? $ticket_start_time : $default_start_time ); ?>"
aria-label="<?php echo esc_attr( $ticket_start_date_aria_label ); ?>"
/>
<span class="helper-text hide-if-js"><?php esc_html_e( 'HH:MM', 'event-tickets' ); ?></span>
Expand All @@ -67,7 +79,7 @@ class="tribe-timepicker tribe-field-start_time ticket_field"
class="tribe-datepicker tribe-field-end_date ticket_field"
name="ticket_end_date"
id="ticket_end_date"
value="<?php echo esc_attr( $ticket ? $ticket_end_date : null ); ?>"
value="<?php echo esc_attr( $ticket ? $ticket_end_date : $default_end_date ); ?>"
/>
<span class="helper-text hide-if-js"><?php esc_html_e( 'YYYY-MM-DD', 'event-tickets' ); ?></span>
<span class="datetime_seperator"> <?php esc_html_e( 'at', 'event-tickets' ); ?> </span>
Expand All @@ -80,7 +92,7 @@ class="tribe-timepicker tribe-field-end_time ticket_field"
<?php echo Tribe__View_Helpers::is_24hr_format() ? 'data-format="H:i"' : ''; ?>
data-step="<?php echo esc_attr( $timepicker_step ); ?>"
data-round="<?php echo esc_attr( $timepicker_round ); ?>"
value="<?php echo esc_attr( $ticket_end_time ); ?>"
value="<?php echo esc_attr( $ticket ? $ticket_end_time : $default_end_time ); ?>"
aria-label="<?php echo esc_attr( $ticket_end_date_aria_label ); ?>"
/>
<span class="helper-text hide-if-js"><?php esc_html_e( 'HH:MM', 'event-tickets' ); ?></span>
Expand Down
1 change: 1 addition & 0 deletions tests/ft_integration/Tribe/Tickets/MetaboxTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ public function ensure_preconditions(): void {
tribe_update_option( 'ticket-enabled-post-types', $ticketable_post_types );
// To be able to edit the posts.
wp_set_current_user( static::factory()->user->create( [ 'role' => 'administrator' ] ) );
$this->set_fn_return( 'gmdate', '7/25/2024' );
}

public function get_panels_provider(): Generator {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
aria-hidden="false"
data-save-prompt="You have unsaved changes to your tickets. Discard those changes?"
>
<div class="tribe_sectionheader ticket_list_container">
<div class="tribe_sectionheader ticket_list_container tribe_no_capacity">
<div class="ticket_table_intro">
<button
id="ticket_form_toggle"
Expand All @@ -18,6 +18,8 @@
aria-label="Add a new RSVP"
>
New RSVP</button>
<button id="settings_form_toggle" class="button-secondary tribe-button-icon tribe-button-icon-settings">
Settings</button>
</div>

<div class="ticket_table_intro__warnings">
Expand All @@ -41,109 +43,14 @@
</div>
</div>


<div class="ticket_list_wrapper">
<table class="tribe_ticket_list_table tribe-tickets-editor-table eventtable ticket_list eventForm widefat fixed">
<thead>
<tr class="table-header">
<th class="ticket_name column-primary">

<img
class="tribe-tickets-svgicon tec-tickets-icon tec-tickets-icon__ticket-type"
src="http://wordpress.test/wp-content/plugins/event-tickets/src/resources/icons/ticket-rsvp-icon.svg"
alt="RSVP"
/>
RSVPs </th>

<th class="ticket_price"></th>
<th class="ticket_capacity">Capacity</th>
<th class="ticket_available">Available</th>
<th class="ticket_edit"></th>
</tr>
</thead>
<tbody class="tribe-tickets-editor-table-tickets-body">
<tr class="Tribe__Tickets__RSVP is-expanded"
data-ticket-order-id="order_{{ID}}"
data-ticket-type-id="{{ID}}"
data-ticket-type="rsvp">
<td class="column-primary ticket_name Tribe__Tickets__RSVP" data-label="Ticket Type:">
<input
type="hidden"
class="tribe-ticket-field-order"
name="tribe-tickets[list][{{ID}}][order]"
value="0"
disabled >
<div class="tribe-tickets__tickets-editor-ticket-name">
<div class="tribe-tickets__tickets-editor-ticket-name-sortable">
<span class="dashicons dashicons-screenoptions tribe-handle"></span>
</div>
<div class="tribe-tickets__tickets-editor-ticket-name-title">


Test RSVP ticket for {{ID}}
<div class="tribe-tickets__tickets-editor-ticket-available-dates dashicons-before dashicons-clock" >
January 2, 2020 - March 1, 2050</div> </div>
</div>
</td>

<td></td>
<td class="ticket_capacity">
<span class='tribe-mobile-only'>Capacity:</span>
100 </td>

<td class="ticket_available">
<span class='tribe-mobile-only'>Available:</span>
100 </td>

<td class="ticket_edit">
<button
data-provider='Tribe__Tickets__RSVP'
data-ticket-id='{{ID}}'
title='Edit Ticket ID: {{ID}}'
class='ticket_edit_button'>
<span class='ticket_edit_text'>Test RSVP ticket for {{ID}}</span>
</button>

<button
data-provider='Tribe__Tickets__RSVP'
data-ticket-id='{{ID}}'
title='Duplicate Ticket ID: {{ID}}'
class='ticket_duplicate'>
<span class='ticket_duplicate_text'>Test RSVP ticket for {{ID}}</span>
</button>

<button
attr-provider='Tribe__Tickets__RSVP'
attr-ticket-id='{{ID}}'
title='Delete Ticket ID: {{ID}}'
class='ticket_delete'>
<span class='ticket_delete_text'>Test RSVP ticket for {{ID}}</span>
</button>
</td>
</tr>
</tbody>
</table>

</div>
</div>
<div class="tribe-ticket-control-wrap">
<div class="tribe-ticket-control-wrap__ctas">
<a
href="http://wordpress.test/wp-admin/edit.php?post_type=post&#038;page=tickets-attendees&#038;event_id={{ID}}"
>
View Attendees </a>

</div>
</div>

<div class="tribe-ticket-control-wrap__settings">
<span id="ticket_form_total_capacity">
Total Post Capacity: <span id="ticket_form_total_capacity_value" title="The total number of possible attendees for this post">
<a href="#" id="capacity_form_toggle">100</a> </span>
</span>

<button id="settings_form_toggle" class="button-secondary tribe-button-icon tribe-button-icon-settings">
Settings</button>
</div>
</div>
</div>

</div>
Expand Down Expand Up @@ -342,7 +249,7 @@ <h4>Ticket Settings </h4>
class="tribe-datepicker tribe-field-start_date ticket_field"
name="ticket_start_date"
id="ticket_start_date"
value=""
value="7/25/2024"
data-validation-type="datepicker"
data-validation-is-less-or-equal-to="#ticket_end_date"
data-validation-error="{&quot;is-required&quot;:&quot;Start sale date cannot be empty.&quot;,&quot;is-less-or-equal-to&quot;:&quot;Start sale date cannot be greater than End Sale date&quot;}"
Expand All @@ -357,7 +264,7 @@ <h4>Ticket Settings </h4>
id="ticket_start_time"
data-step="30"
data-round="00:00:00"
value=""
value="00:00:00"
aria-label="Ticket start date"
/>
<span class="helper-text hide-if-js">HH:MM</span>
Expand All @@ -374,7 +281,7 @@ <h4>Ticket Settings </h4>
class="tribe-datepicker tribe-field-end_date ticket_field"
name="ticket_end_date"
id="ticket_end_date"
value=""
value="7/25/2024"
/>
<span class="helper-text hide-if-js">YYYY-MM-DD</span>
<span class="datetime_seperator"> at </span>
Expand All @@ -386,7 +293,7 @@ <h4>Ticket Settings </h4>
id="ticket_end_time"
data-step="30"
data-round="00:00:00"
value=""
value="00:00:00"
aria-label="Ticket end date"
/>
<span class="helper-text hide-if-js">HH:MM</span>
Expand Down
Loading
Loading