| 1 |
<?php |
| 2 |
/** |
| 3 |
* Class to Payment Request - 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_Booking_Note { |
| 16 |
|
| 17 |
const ACTION = 'set_booking_note'; |
| 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_personal' ) ) { |
| 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_booking_note( {{data['parsed_fields']['booking_id']}}, jQuery( '#set_booking_note_text_{{data.parsed_fields.booking_id}}').val() );\" |
| 37 |
>" . |
| 38 |
'<# if ( \'\' == data.parsed_fields.remark.trim() ) { #>' . |
| 39 |
esc_js( __( 'Add notes', 'booking' ) ) . |
| 40 |
'<# } else { #>' . |
| 41 |
esc_js( __( 'Edit note', 'booking' ) ) . |
| 42 |
'<# } #>' . |
| 43 |
"<i class='menu_icon icon-1x wpbc_icn_mode_comment'></i>" . |
| 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_personal' ) ) { |
| 58 |
return false; |
| 59 |
} |
| 60 |
|
| 61 |
?> |
| 62 |
<span class="wpdevelop"> |
| 63 |
<div id="wpbc_modal__set_booking_note__section" class="modal wpbc_popup_modal wpbc_modal_in_listing" tabindex="-1" role="dialog"> |
| 64 |
<div class="modal-dialog"> |
| 65 |
<div class="modal-content"> |
| 66 |
<div class="modal-header"> |
| 67 |
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button> |
| 68 |
<h4 class="modal-title"><?php esc_html_e( 'Edit note', 'booking' ); ?><sup class="wpbc_modal__set_booking_note__booking_id wpbc_modal__booking_id__in_title"></sup></h4> |
| 69 |
</div> |
| 70 |
<div class="modal-body"> |
| 71 |
<textarea id="wpbc_modal__set_booking_note__value" name="wpbc_modal__set_booking_note__value" cols="87" rows="5"></textarea> |
| 72 |
<input type="hidden" id="wpbc_modal__set_booking_note__booking_id" value=""/> |
| 73 |
<label class="help-block"><?php esc_html_e( 'Add notes for the booking', 'booking' ); ?></label> |
| 74 |
</div> |
| 75 |
<div class="modal-footer"> |
| 76 |
<a id="wpbc_modal__set_booking_note__button_send" class="button button-primary" |
| 77 |
href="javascript:void(0);" |
| 78 |
onclick="javascript: wpbc_ajx_booking_ajax_action_request( { |
| 79 |
'booking_action' : '<?php echo esc_js( self::ACTION ); ?>', |
| 80 |
'booking_id' : jQuery( '#wpbc_modal__set_booking_note__booking_id').val(), |
| 81 |
'remark' : jQuery( '#wpbc_modal__set_booking_note__value' ).val(), |
| 82 |
'ui_clicked_element_id' : 'wpbc_modal__set_booking_note__button_send' |
| 83 |
} ); |
| 84 |
wpbc_button_enable_loading_icon( this ); |
| 85 |
jQuery( '#wpbc_modal__set_booking_note__section' ).wpbc_my_modal( 'hide' ); |
| 86 |
" |
| 87 |
><?php esc_html_e( 'Save Changes', 'booking' ); ?> </a> |
| 88 |
<a href="javascript:void(0)" class="button button-secondary" data-dismiss="modal"><?php esc_html_e( 'Cancel', 'booking' ); ?> </a> |
| 89 |
</div> |
| 90 |
</div><!-- /.modal-content --> |
| 91 |
</div><!-- /.modal-dialog --> |
| 92 |
</div><!-- /.modal --> |
| 93 |
</span> |
| 94 |
<?php |
| 95 |
} |
| 96 |
} |
| 97 |
|
| 98 |
// Loads hidden modal template. |
| 99 |
add_action( 'wpbc_hook_booking_template__hidden_templates', array( new WPBC_Action_Booking_Note(), 'template_for_modal' ) ); |
| 100 |
|