Skip to content

Commit

Permalink
v3.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
rishabhmwb committed Jun 23, 2023
1 parent 8708266 commit 191411f
Show file tree
Hide file tree
Showing 19 changed files with 1,798 additions and 552 deletions.
121 changes: 66 additions & 55 deletions README.txt

Large diffs are not rendered by default.

42 changes: 41 additions & 1 deletion admin/class-mwb-bookings-for-woocommerce-admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ public function mbfw_admin_enqueue_styles( $hook ) {
wp_enqueue_style( 'mwb-datatable-css', MWB_BOOKINGS_FOR_WOOCOMMERCE_DIR_URL . 'package/lib/datatables/media/css/jquery.dataTables.min.css', array(), $this->version, 'all' );
wp_enqueue_style( 'mwb-admin-full-calendar-css', MWB_BOOKINGS_FOR_WOOCOMMERCE_DIR_URL . 'package/lib/full-calendar/main.css', array(), '5.8.0', 'all' );
}

wp_enqueue_style( 'mwb-mbfw-global-custom-css', MWB_BOOKINGS_FOR_WOOCOMMERCE_DIR_URL . 'admin/css/mwb-admin-global-custom.min.css', array(), $this->version, 'all' );
}

Expand Down Expand Up @@ -124,6 +125,7 @@ public function mbfw_admin_enqueue_scripts( $hook ) {
wp_enqueue_script( 'mwb-mbfw-admin-min-js', MWB_BOOKINGS_FOR_WOOCOMMERCE_DIR_URL . 'admin/js/mwb-admin.min.js', array( 'jquery' ), time(), true );
wp_enqueue_script( 'mwb-admin-full-calendar-js', MWB_BOOKINGS_FOR_WOOCOMMERCE_DIR_URL . 'package/lib/full-calendar/main.js', array( 'jquery' ), time(), true );
}

wp_enqueue_script( 'mwb-mbfw-admin-custom-global-js', MWB_BOOKINGS_FOR_WOOCOMMERCE_DIR_URL . 'admin/js/mwb-admin-global-custom.js', array( 'jquery' ), time(), true );
}

Expand Down Expand Up @@ -647,9 +649,17 @@ public function mbfw_add_product_data_tabs( $tabs ) {
*/
public function mbfw_product_data_tabs_html() {
$booking_criteria = get_post_meta( get_the_ID(), 'mwb_mbfw_booking_criteria', true );
$booking_type = get_post_meta( get_the_ID(), 'wps_mbfw_booking_type', true );
wp_nonce_field( 'mwb_booking_product_meta', '_mwb_nonce' );
?>
<div id="mwb_booking_general_data" class="panel woocommerce_options_panel show_if_mwb_booking">
<p class="form-field mwb_mbfw_booking_type_field">
<label for="wps_mbfw_booking_type"><?php esc_html_e( 'Booking type', 'mwb-bookings-for-woocommerce' ); ?></label>
<select name="wps_mbfw_booking_type" id="wps_mbfw_booking_type">
<option value="dual_cal" <?php selected( 'dual_cal', $booking_type ); ?>><?php esc_html_e( 'Dual Calendar', 'mwb-bookings-for-woocommerce' ); ?></option>
<option value="single_cal" <?php selected( 'single_cal', $booking_type ); ?>><?php esc_html_e( 'Single Calendar', 'mwb-bookings-for-woocommerce' ); ?></option>
</select>
</p>
<p class="form-field mwb_mbfw_booking_criteria_field">
<label for="mwb_mbfw_booking_criteria"><?php esc_html_e( 'Quantity', 'mwb-bookings-for-woocommerce' ); ?></label>
<select name="mwb_mbfw_booking_criteria" id="mwb_mbfw_booking_criteria">
Expand Down Expand Up @@ -907,7 +917,9 @@ public function mbfw_product_data_tabs_html() {
</div>
<div id="mwb_booking_availability_data" class="panel woocommerce_options_panel show_if_mwb_booking">
<?php



$active_plugins = get_option( 'active_plugins' );
if( ! in_array( 'bookings-for-woocommerce-pro/bookings-for-woocommerce-pro.php', $active_plugins ) ) {

Expand All @@ -924,7 +936,9 @@ public function mbfw_product_data_tabs_html() {
)
);
}




/**
* Filter is for returning something.
*
Expand All @@ -941,6 +955,21 @@ public function mbfw_product_data_tabs_html() {
);
?>
</p>
<?php
woocommerce_wp_text_input(
array(
'label' => __( 'Set days availability', 'mwb-bookings-for-woocommerce' ),
'id' => 'wps_mbfw_set_availability',
'value' => get_post_meta( get_the_ID(), 'wps_mbfw_set_availability', true ),
'description' => __( 'Bookings will be available on these days.', 'mwb-bookings-for-woocommerce' ),
'type' => 'text',
'desc_tip' => true,
'style' => 'width:10em;',
'custom_attributes' => array( 'autocomplete' => 'off' ),
)
);
require_once MWB_BOOKINGS_FOR_WOOCOMMERCE_DIR_PATH .'/admin/partials/mwb-bookings-for-woocommerce-time-slot.php';
?>
</div>
<?php
}
Expand Down Expand Up @@ -1007,6 +1036,7 @@ public function mbfw_save_custom_product_meta_boxes_data( $id, $post ) {

$product_meta_data = array(
'mwb_mbfw_booking_criteria' => array_key_exists( 'mwb_mbfw_booking_criteria', $_POST ) ? sanitize_text_field( wp_unslash( $_POST['mwb_mbfw_booking_criteria'] ) ) : '',
'wps_mbfw_booking_type' => array_key_exists( 'wps_mbfw_booking_type', $_POST ) ? sanitize_text_field( wp_unslash( $_POST['wps_mbfw_booking_type'] ) ) : '',
'mwb_mbfw_booking_count' => array_key_exists( 'mwb_mbfw_booking_count', $_POST ) ? sanitize_text_field( wp_unslash( $_POST['mwb_mbfw_booking_count'] ) ) : '',
'mwb_mbfw_booking_unit' => array_key_exists( 'mwb_mbfw_booking_unit', $_POST ) ? sanitize_text_field( wp_unslash( $_POST['mwb_mbfw_booking_unit'] ) ) : '',
'mwb_mbfw_enable_calendar' => array_key_exists( 'mwb_mbfw_enable_calendar', $_POST ) ? sanitize_text_field( wp_unslash( $_POST['mwb_mbfw_enable_calendar'] ) ) : '',
Expand All @@ -1029,6 +1059,9 @@ public function mbfw_save_custom_product_meta_boxes_data( $id, $post ) {
'mwb_mbfw_daily_calendar_start_time' => array_key_exists( 'mwb_mbfw_daily_calendar_start_time', $_POST ) ? sanitize_text_field( wp_unslash( $_POST['mwb_mbfw_daily_calendar_start_time'] ) ) : '',
'mwb_mbfw_daily_calendar_end_time' => array_key_exists( 'mwb_mbfw_daily_calendar_end_time', $_POST ) ? sanitize_text_field( wp_unslash( $_POST['mwb_mbfw_daily_calendar_end_time'] ) ) : '',
'mwb_mbfw_choose_holiday' => array_key_exists( 'mwb_mbfw_choose_holiday', $_POST ) ? sanitize_text_field( wp_unslash( $_POST['mwb_mbfw_choose_holiday'] ) ) : '',
'wps_mbfw_set_availability' => array_key_exists( 'wps_mbfw_set_availability', $_POST ) ? sanitize_text_field( wp_unslash( $_POST['wps_mbfw_set_availability'] ) ) : '',
'wps_mbfw_time_slots' => array_key_exists( 'mbfw_fields', $_POST ) ? ( is_array( $_POST['mbfw_fields'] ) ? map_deep( wp_unslash( $_POST['mbfw_fields'] ), 'sanitize_text_field' ) : sanitize_text_field( wp_unslash( $_POST['mbfw_fields'] ) ) ) : array(),



);
Expand Down Expand Up @@ -1612,6 +1645,13 @@ public function mbfw_change_line_item_meta_key_order_edit_page( $display_key, $m
return __( 'From', 'mwb-bookings-for-woocommerce' );
case '_mwb_bfwp_date_time_to':
return __( 'To', 'mwb-bookings-for-woocommerce' );

case '_wps_single_cal_date_time_from':
return __( 'From', 'mwb-bookings-for-woocommerce' );
case '_wps_single_cal_date_time_to':
return __( 'To', 'mwb-bookings-for-woocommerce' );
case '_wps_single_cal_booking_dates':
return __( 'Booking Dates', 'mwb-bookings-for-woocommerce' );
default:
break;
}
Expand Down
89 changes: 88 additions & 1 deletion admin/js/mwb-admin-global-custom.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,93 @@ jQuery(document).ready(function($){
}
});


if ($('#wps_mbfw_booking_type').val() == 'single_cal') {
$(document).find('.mwb_mbfw_show_date_with_time_field').hide();
$(document).find('.mwb_mbfw_daily_calendar_start_time_field').hide();
$(document).find('.mwb_mbfw_daily_calendar_end_time_field').hide();
$(document).find('.mwb_bfwp_choose_multiple_holiday_field').hide();
$(document).find('.wps_bfwp_weekly_off_day_field').hide();
$(document).find('.mwb_mbfw_rescheduling_allowed_field').hide();
$(document).find('.mwb_bfwp_order_statuses_to_reschedule_field').hide();
$(document).find('.wps_mbfw_set_availability_field').show();
$(document).find('#wps_mbfw_add_fields_wrapper').show();
} else {
$(document).find('.mwb_mbfw_show_date_with_time_field').show();
$(document).find('.mwb_mbfw_daily_calendar_start_time_field').show();
$(document).find('.mwb_mbfw_daily_calendar_end_time_field').show();
$(document).find('.mwb_bfwp_choose_multiple_holiday_field').show();
$(document).find('.wps_bfwp_weekly_off_day_field').show();
$(document).find('.wps_mbfw_set_availability_field').hide();
$(document).find('#wps_mbfw_add_fields_wrapper').hide();
$(document).find('.mwb_mbfw_rescheduling_allowed_field').show();
$(document).find('.mwb_bfwp_order_statuses_to_reschedule_field').show();

}

$(document).on('change', '#wps_mbfw_booking_type', function () {
if ($(this).val() == 'single_cal') {
$(document).find('.mwb_mbfw_show_date_with_time_field').hide();
$(document).find('.mwb_mbfw_daily_calendar_start_time_field').hide();
$(document).find('.mwb_mbfw_daily_calendar_end_time_field').hide();
$(document).find('.mwb_bfwp_choose_multiple_holiday_field').hide();
$(document).find('.wps_bfwp_weekly_off_day_field').hide();
$(document).find('.mwb_mbfw_rescheduling_allowed_field').hide();
$(document).find('.mwb_bfwp_order_statuses_to_reschedule_field').hide();
$(document).find('.wps_mbfw_set_availability_field').show();
$(document).find('#wps_mbfw_add_fields_wrapper').show();
} else {
$(document).find('.mwb_mbfw_show_date_with_time_field').show();
$(document).find('.mwb_mbfw_daily_calendar_start_time_field').show();
$(document).find('.mwb_mbfw_daily_calendar_end_time_field').show();
$(document).find('.mwb_bfwp_choose_multiple_holiday_field').show();
$(document).find('.wps_bfwp_weekly_off_day_field').show();
$(document).find('.wps_mbfw_set_availability_field').hide();
$(document).find('#wps_mbfw_add_fields_wrapper').hide();
$(document).find('.mwb_mbfw_rescheduling_allowed_field').show();
$(document).find('.mwb_bfwp_order_statuses_to_reschedule_field').show();

}
});



$('#wps_mbfw_set_availability').multiDatesPicker({
dateFormat: "dd-mm-yy",
minDate: new Date(),
});



$(document).on( 'click', '.wps_mbfw_add_fields_button', function(){
var fieldsetId = $(document).find('.wps_mbfw_field_table').find('.wps_mbfw_field_wrap').last().attr('data-id');
fieldsetId = fieldsetId?fieldsetId.replace(/[^0-9]/gi, ''):0;
let mainId = Number(fieldsetId) + 1;
var field_html = '<tr class="wps_mbfw_field_wrap" data-id="'+mainId+'"><td class="drag-icon"><i class="dashicons dashicons-move"></i></td><td class="form-field wps_mbfw_from_fields"><input type="text" class="wps_mbfw_field_from" style="" name="mbfw_fields['+mainId+'][_from]" id="from_fields_'+mainId+'" value="" placeholder=""></td><td class="form-field wps_mbfw_to_fields"><input type="text" class="wps_mbfw_field_to" style="" name="mbfw_fields['+mainId+'][_to]" id="to_fields_'+mainId+'"></td><td class="wps_mbfw_remove_row"><input type="button" name="wps_mbfw_remove_fields_button" class="wps_mbfw_remove_row_btn" value="Remove"></td></tr>';
$(document).find('.wps_mbfw_field_body').append(field_html);
$('.wps_mbfw_field_from').datetimepicker({
format : 'H:i',
datepicker : false,

});
$('.wps_mbfw_field_to').datetimepicker({
format : 'H:i',
datepicker : false,

});
});

$(document).on("click", ".wps_mbfw_remove_row_btn", function(e){
e.preventDefault();
$(this).parents(".wps_mbfw_field_wrap").remove();
});
$('.wps_mbfw_field_from').datetimepicker({
format : 'H:i',
datepicker : false,

});
$('.wps_mbfw_field_to').datetimepicker({
format : 'H:i',
datepicker : false,

});
});
87 changes: 87 additions & 0 deletions admin/partials/mwb-bookings-for-woocommerce-time-slot.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
<?php
/**
* Provide a admin area view for the plugin
*
* This file is used from markup the admin-facing aspects of the plugin.
*
* @link https://wpswings.com/
* @since 1.0.0
*
* @package Mwb_Bookings_For_Woocommerce
* @subpackage Mwb_Bookings_For_Woocommerce/admin/partials
*/

if ( ! defined( 'ABSPATH' ) ) {
exit(); // Exit if accessed directly.
}
$wps_mbfw_field_data = get_post_meta(get_the_ID(), 'wps_mbfw_time_slots', true );

?>
<div id="wps_mbfw_add_fields_wrapper">
<div class="wps_mbfw_add_fields_title">
<h2>
<strong class="attribute_name"><?php esc_html_e( 'Set Daily time slots', 'event-tickets-manager-for-woocommerce' ); ?></strong></h2>
</div>
<div class="wps_mbfw_add_fields_data">
<div class="wps_mbfw_fields_panel">
<table class="field-options wp-list-table widefat wps_mbfw_field_table">
<thead>
<tr>
<th></th>
<th class="mbfw_field_from"><?php esc_html_e( 'From', 'event-tickets-manager-for-woocommerce' ); ?></th>
<th class="mbfw_field_to"><?php esc_html_e( 'To', 'event-tickets-manager-for-woocommerce' ); ?></th>
<th class="etmfw_field_actions"><?php esc_html_e( 'Actions', 'event-tickets-manager-for-woocommerce' ); ?></th>
</tr>
</thead>
<tbody class="wps_mbfw_field_body">
<?php if ( empty( $wps_mbfw_field_data ) ) : ?>
<tr class="wps_mbfw_field_wrap" data-id="0">
<td class="drag-icon">
<i class="dashicons dashicons-move"></i>
</td>
<td class="form-field wps_mbfw_from_fields">
<input type="text" class="wps_mbfw_field_from" style="" name="mbfw_fields[0][_from]" id="from_fields_0" value="" placeholder="">
</td>

<td class="form-field wps_mbfw_to_fields">
<input type="text" class="wps_mbfw_field_to" style="" name="mbfw_fields[0][_to]" id="to_fields_0">
</td>
<td class="wps_mbfw_remove_row">
<input type="button" name="wps_mbfw_remove_fields_button" class="wps_mbfw_remove_row_btn" value="Remove">
</td>
</tr>
<?php
else :
foreach ( $wps_mbfw_field_data as $row_id => $row_value ) :

?>
<tr class="wps_mbfw_field_wrap" data-id="<?php echo esc_attr( $row_id ); ?>">
<td class="drag-icon">
<i class="dashicons dashicons-move"></i>
</td>
<td class="form-field wps_mbfw_from_fields">
<input type="text" class="wps_mbfw_field_from" style="" name="mbfw_fields[<?php echo esc_attr( $row_id ); ?>][_from]" id="from_fields_<?php echo esc_attr( $row_id ); ?>" value="<?php echo esc_attr( $row_value['_from'] ); ?>" placeholder="">
</td>
<td class="form-field wps_mbfw_to_fields">
<input type="text" class="wps_mbfw_field_to" style="" name="mbfw_fields[<?php echo esc_attr( $row_id ); ?>][_to]" id="to_fields_<?php echo esc_attr( $row_id ); ?>" value="<?php echo esc_attr( $row_value['_to'] ); ?>">
</td>
<td class="wps_mbfw_remove_row">
<input type="button" name="wps_mbfw_remove_fields_button" class="wps_mbfw_remove_row_btn" value="Remove">
</td>
</tr>
<?php endforeach; ?>
<?php endif; ?>
</tbody>
<tfoot>
<tr>
<td colspan="5">
<input type="button" name="wps_mbfw_add_fields_button" class="button wps_mbfw_add_fields_button" value="<?php esc_attr_e( 'Add More', 'event-tickets-manager-for-woocommerce' ); ?>">
</td>
</tr>
</tfoot>
</table>
</div>
</div>
</div>
</div>
<?php
Loading

0 comments on commit 191411f

Please sign in to comment.