Created
February 7, 2022 06:29
-
-
Save AshlinRejo/757a5b2055071b36e74a895fa99eb7a2 to your computer and use it in GitHub Desktop.
J2Store Booking: Loading default date in date fields
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$month_before_day = strpos( ( 'F j, Y' ), 'F' ) < strpos( ( 'F j, Y' ), 'j' ); | |
?> | |
<fieldset class="bookings-date-picker bookings-date-picker-<?php echo $vars->product_type; ?> <?php echo implode( ' ', (array)$vars->field->class ); ?>" data-appid="<?php echo $vars->id; ?>"> | |
<legend> | |
<span class="label"><?php echo isset($vars->field->label) ? $vars->field->label: ''; ?></span>: <small class="bookings-date-picker-choose-date"><?php echo JText::_( 'Choose...' ); ?></small> | |
</legend> | |
<div class="picker" data-display="<?php echo $vars->field->display; ?>" data-duration-unit="<?php echo $vars->field->duration_unit;?>" data-availability='<?php echo json_encode( $vars->field->availability_rules ) ; ?>' | |
data-default-availability="<?php echo $vars->field->default_availability ? 'true' : 'false'; ?>" data-fully-booked-days='<?php echo json_encode( $vars->field->fully_booked_days ); ?>' | |
data-partially-booked-days='<?php echo json_encode( $vars->field->partially_booked_days ); ?>' data-buffer-days='<?php echo json_encode( $vars->field->buffer_days ); ?>' | |
data-min_date="<?php echo ! empty( $vars->field->min_date_js ) ? $vars->field->min_date_js : 0; ?>" data-max_date="<?php echo $vars->field->max_date_js; ?>" | |
data-default_date="<?php echo $vars->field->default_date; ?>" data-is_range_picker_enabled="<?php echo $vars->field->is_range_picker_enabled ? 1 : 0; ?>"></div> | |
<div class="bookings-date-picker-date-fields"> | |
<?php if ( 'customer' == $vars->field->duration_type && $vars->field->is_range_picker_enabled ) : ?> | |
<span><?php echo JText::_( 'J2STORE_APPBOOKINGPRODUCT_START_DATE' ); ?>:</span><br /> | |
<?php endif; ?> | |
<?php | |
$day = $month = $year = ''; | |
if(!empty($vars->field->default_date)){ | |
$timestamp = strtotime($vars->field->default_date); | |
$day = date('d', $timestamp); | |
$month = date('m', $timestamp); | |
$year = date('Y', $timestamp); | |
} | |
if ( $month_before_day ) : ?> | |
<label> | |
<input type="text" name="<?php echo $vars->field->name; ?>_month" placeholder="<?php echo JText::_( 'mm' ); ?>" value="<?php echo $month; ?>" size="2" class="booking_date_month" /> | |
<br/><span><?php echo JText::_( 'J2STORE_BOOKING_MONTH_FIELD' ); ?></span> | |
</label> / <label> | |
<input type="text" name="<?php echo $vars->field->name; ?>_day" placeholder="<?php echo JText::_( 'dd' ); ?>" value="<?php echo $day; ?>" size="2" class="booking_date_day" /> | |
<br/><span><?php echo JText::_( 'J2STORE_BOOKING_DAY_FIELD' ); ?></span> | |
</label> | |
<?php else : ?> | |
<label> | |
<input type="text" name="<?php echo $vars->field->name; ?>_day" placeholder="<?php echo JText::_( 'dd' ); ?>" value="<?php echo $day; ?>" size="2" class="booking_date_day" /> | |
<br/><span><?php echo JText::_( 'J2STORE_BOOKING_DAY_FIELD' ); ?></span> | |
</label> / <label> | |
<input type="text" name="<?php echo $vars->field->name; ?>_month" placeholder="<?php echo JText::_( 'mm' ); ?>" value="<?php echo $month; ?>" size="2" class="booking_date_month" /> | |
<br/><span><?php echo JText::_( 'J2STORE_BOOKING_MONTH_FIELD' ); ?></span> | |
</label> | |
<?php endif; ?> / <label> | |
<input type="text" value="<?php echo $year; ?>" name="<?php echo $vars->field->name; ?>_year" placeholder="<?php echo JText::_( 'YYYY' ); ?>" size="4" class="booking_date_year" /> | |
<br/><span><?php echo JText::_( 'J2STORE_BOOKING_YEAR_FIELD' ); ?></span> | |
</label> | |
</div> | |
<?php if ( 'customer' == $vars->field->duration_type && $vars->field->is_range_picker_enabled ) : ?> | |
<div class="bookings-date-picker-date-fields"> | |
<span><?php echo JText::_( 'J2STORE_APPBOOKINGPRODUCT_END_DATE' ); ?>:</span><br /> | |
<?php if ( $month_before_day ) : ?> | |
<label> | |
<input type="text" name="<?php echo $vars->field->name; ?>_to_month" placeholder="<?php echo JText::_( 'mm' ); ?>" value="02" size="2" class="booking_to_date_month" /> | |
<br/><span><?php echo JText::_( 'J2STORE_BOOKING_MONTH_FIELD' ); ?></span> | |
</label> / <label> | |
<input type="text" name="<?php echo $vars->field->name; ?>_to_day" placeholder="<?php echo JText::_( 'dd' ); ?>" value="07" size="2" class="booking_to_date_day" /> | |
<br/><span><?php echo JText::_( 'J2STORE_BOOKING_DAY_FIELD' ); ?></span> | |
</label> | |
<?php else : ?> | |
<label> | |
<input type="text" name="<?php echo $vars->field->name; ?>_to_day" placeholder="<?php echo JText::_( 'dd' ); ?>" size="2" class="booking_to_date_day" /> | |
<br/><span><?php echo JText::_( 'J2STORE_BOOKING_DAY_FIELD' ); ?></span> | |
</label> / <label> | |
<input type="text" name="<?php echo $vars->field->name; ?>_to_month" placeholder="<?php echo JText::_( 'mm' ); ?>" size="2" class="booking_to_date_month" /> | |
<br/><span><?php echo JText::_( 'J2STORE_BOOKING_MONTH_FIELD' ); ?></span> | |
</label> | |
<?php endif; ?> / <label> | |
<input type="text" name="<?php echo $vars->field->name; ?>_to_year" placeholder="<?php echo JText::_( 'YYYY' ); ?>" value="2022" size="4" class="booking_to_date_year" /> | |
<br/><span><?php echo JText::_( 'J2STORE_BOOKING_YEAR_FIELD' ); ?></span> | |
</label> | |
</div> | |
<?php endif; ?> | |
<input type="hidden" name="duration_type" value="<?php echo $vars->field->duration_type; ?>"/> | |
<input type="hidden" name="block_quantity" class="block_quantity" value="1"/> | |
<div class="hide booking_date_msg alert alert-block alert-info"></div> | |
</fieldset> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment