| 1 |
<?php |
| 2 |
/** |
| 3 |
* Class to Payment Status Change - Option for "Actions Dropdown Menu" |
| 4 |
* |
| 5 |
* @package Support functions. |
| 6 |
*/ |
| 7 |
|
| 8 |
if ( ! defined( 'ABSPATH' ) ) { |
| 9 |
exit; // Exit, if accessed directly. |
| 10 |
} |
| 11 |
|
| 12 |
/** |
| 13 |
* Class WPBC_Action_Payment_Satatus |
| 14 |
*/ |
| 15 |
class WPBC_Action_Payment_Satatus { |
| 16 |
|
| 17 |
const ACTION = 'set_payment_status'; |
| 18 |
|
| 19 |
/** |
| 20 |
* Get Action Button |
| 21 |
* |
| 22 |
* @return false|string |
| 23 |
*/ |
| 24 |
public static function get_button() { |
| 25 |
|
| 26 |
if ( ! class_exists( 'wpdev_bk_biz_s' ) ) { |
| 27 |
return false; |
| 28 |
} |
| 29 |
if ( ! wpbc_is_user_can( self::ACTION, wpbc_get_current_user_id() ) ) { |
| 30 |
return false; |
| 31 |
} |
| 32 |
|
| 33 |
// Send payment request to visitor. |
| 34 |
$html = "<a class=\"ul_dropdown_menu_li_action ul_dropdown_menu_li_action_" . esc_js( self::ACTION ) . "\" |
| 35 |
href=\"javascript:void(0)\" |
| 36 |
onclick=\"wpbc_boo_listing__click__set_payment_status( {{data['parsed_fields']['booking_id']}}, '{{data.parsed_fields.pay_status}}' );\" |
| 37 |
>" . |
| 38 |
esc_js( __( 'Edit payment status', 'booking' ) ) . |
| 39 |
" <# if ( ( '' === data.parsed_fields.pay_status ) || ( ! isNaN( parseFloat( data.parsed_fields.pay_status ) )) ) { #>" . |
| 40 |
"<i class='menu_icon icon-1x wpbc_icn_sell'></i>" . |
| 41 |
' <# } else { #>' . |
| 42 |
"<span class='hint_value_instead_icon'>{{data.parsed_fields.pay_status}}</span>" . |
| 43 |
' <# } #>' . |
| 44 |
'</a>'; |
| 45 |
|
| 46 |
return $html; |
| 47 |
} |
| 48 |
|
| 49 |
|
| 50 |
/** |
| 51 |
* Get Template for Modal Window - Booking Cost Edit - Layout - Modal Window structure |
| 52 |
* |
| 53 |
* @return false|void |
| 54 |
*/ |
| 55 |
public static function template_for_modal() { |
| 56 |
|
| 57 |
if ( ! class_exists( 'wpdev_bk_biz_s' ) ) { |
| 58 |
return false; |
| 59 |
} |
| 60 |
|
| 61 |
$select_box_options = get_payment_status_titles(); |
| 62 |
$select_box_options = array_flip( $select_box_options ); |
| 63 |
$params_select = array( |
| 64 |
'id' => 'wpbc_modal__payment_status_edit__value', // HTML ID of element. |
| 65 |
'name' => 'wpbc_modal__payment_status_edit__value', |
| 66 |
'label' => '', // Payment status // Label (optional). |
| 67 |
'style' => '', // CSS of select element. |
| 68 |
'class' => '', // CSS Class of select element. |
| 69 |
'multiple' => false, |
| 70 |
'attr' => array( |
| 71 |
'data-placeholder' => __( 'Change status', 'booking' ), |
| 72 |
'ajx-selected-value' => '{{data.parsed_fields.pay_status}}', |
| 73 |
), |
| 74 |
'disabled' => false, |
| 75 |
'disabled_options' => array(), // If some options disabled, then it has to list here. |
| 76 |
'options' => $select_box_options, |
| 77 |
|
| 78 |
/* |
| 79 |
//, 'value' => "{{data['parsed_fields']['pay_status']}}"//isset( $escaped_search_request_params[ $el_id ] ) ? $escaped_search_request_params[ $el_id ] : $defaults[ $el_id ] // Some Value from options array that selected by default |
| 80 |
//, 'onfocus' => "console.log( 'ON FOCUS:', jQuery( this ).val(), 'in element:' , jQuery( this ) );" // JavaScript code |
| 81 |
//, 'onchange' => "console.log( 'ON CHANGE:', jQuery( this ).val(), 'in element:' , jQuery( this ) );" // JavaScript code |
| 82 |
*/ |
| 83 |
); |
| 84 |
?> |
| 85 |
<span class="wpdevelop"> |
| 86 |
<div id="wpbc_modal__payment_status_edit__section" class="modal wpbc_popup_modal wpbc_modal_in_listing" tabindex="-1" role="dialog"> |
| 87 |
<div class="modal-dialog"> |
| 88 |
<div class="modal-content"> |
| 89 |
<div class="modal-header"> |
| 90 |
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button> |
| 91 |
<h4 class="modal-title"> |
| 92 |
<?php |
| 93 |
esc_html_e( 'Update the booking payment status', 'booking' ); |
| 94 |
?> |
| 95 |
<sup class="wpbc_modal__payment_status_edit__booking_id wpbc_modal__booking_id__in_title"></sup> |
| 96 |
</h4> |
| 97 |
</div> |
| 98 |
<div class="modal-body"> |
| 99 |
<?php |
| 100 |
wpbc_flex_select( $params_select ); |
| 101 |
?> |
| 102 |
<label class="help-block"> |
| 103 |
<?php |
| 104 |
esc_html_e( 'Select the payment status for booking', 'booking' ); |
| 105 |
?> |
| 106 |
</label> |
| 107 |
<input type="hidden" id="wpbc_modal__payment_status_edit__booking_id" value=""/> |
| 108 |
</div> |
| 109 |
<div class="modal-footer"> |
| 110 |
<a id="wpbc_modal__payment_status_edit__button_send" class="button button-primary" |
| 111 |
href="javascript:void(0);" |
| 112 |
onclick="javascript: wpbc_ajx_booking_ajax_action_request( { |
| 113 |
'booking_action' : '<?php echo esc_js( self::ACTION ); ?>', |
| 114 |
'booking_id' : jQuery( '#wpbc_modal__payment_status_edit__booking_id').val(), |
| 115 |
'selected_payment_status': jQuery( '#wpbc_modal__payment_status_edit__value' ).val(), |
| 116 |
'ui_clicked_element_id' : 'wpbc_modal__payment_status_edit__button_send' |
| 117 |
} ); |
| 118 |
wpbc_button_enable_loading_icon( this ); |
| 119 |
jQuery( '#wpbc_modal__payment_status_edit__section' ).wpbc_my_modal( 'hide' );" > |
| 120 |
<?php |
| 121 |
esc_html_e( 'Save Changes', 'booking' ); |
| 122 |
?> |
| 123 |
</a> |
| 124 |
<a href="javascript:void(0)" class="button button-secondary" data-dismiss="modal"> |
| 125 |
<?php |
| 126 |
esc_html_e( 'Cancel', 'booking' ); |
| 127 |
?> |
| 128 |
</a> |
| 129 |
</div> |
| 130 |
</div><!-- /.modal-content --> |
| 131 |
</div><!-- /.modal-dialog --> |
| 132 |
</div><!-- /.modal --> |
| 133 |
</span> |
| 134 |
<?php |
| 135 |
} |
| 136 |
} |
| 137 |
|
| 138 |
// Loads hidden modal template. |
| 139 |
add_action( 'wpbc_hook_booking_template__hidden_templates', array( new WPBC_Action_Payment_Satatus(), 'template_for_modal' ) ); |
| 140 |
|