| 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_Payment_Request { |
| 16 |
|
| 17 |
const ACTION = 'send_payment_request'; |
| 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__send_payment_request( {{data['parsed_fields']['booking_id']}}, '{{data.parsed_fields.visitorbookingpayurl}}', '{{{data.parsed_fields.currency_symbol}}}{{data.parsed_fields.cost}}' );\" |
| 37 |
>" . |
| 38 |
esc_js( __( 'Charge with pay link', 'booking' ) ) . |
| 39 |
"<i class='menu_icon icon-1x wpbc_icn_forward_to_inbox'></i>" . |
| 40 |
'</a>'; |
| 41 |
|
| 42 |
return $html; |
| 43 |
} |
| 44 |
|
| 45 |
|
| 46 |
/** |
| 47 |
* Get Template for Modal Window - Booking Cost Edit - Layout - Modal Window structure |
| 48 |
* |
| 49 |
* @return false|void |
| 50 |
*/ |
| 51 |
public static function template_for_modal() { |
| 52 |
|
| 53 |
if ( ! class_exists( 'wpdev_bk_biz_s' ) ) { |
| 54 |
return false; |
| 55 |
} |
| 56 |
|
| 57 |
?> |
| 58 |
<span class="wpdevelop"> |
| 59 |
<div id="wpbc_modal__send_payment_request__section" class="modal wpbc_popup_modal wpbc_modal_in_listing" tabindex="-1" role="dialog"> |
| 60 |
<div class="modal-dialog"> |
| 61 |
<div class="modal-content"> |
| 62 |
<div class="modal-header"> |
| 63 |
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button> |
| 64 |
<h4 class="modal-title"> |
| 65 |
<?php |
| 66 |
esc_html_e( 'Payment request', 'booking' ); |
| 67 |
?> |
| 68 |
<sup class="wpbc_modal__send_payment_request__booking_id wpbc_modal__booking_id__in_title"></sup> |
| 69 |
<span class="wpbc_modal__send_payment_request__cost"></span> |
| 70 |
</h4> |
| 71 |
</div> |
| 72 |
<div class="modal-body"> |
| 73 |
<div class="wpbc_modal__2_fields"> |
| 74 |
<input type="text" id="wpbc_modal__send_payment_request__url" value=""> |
| 75 |
<a href="javascript:void(0)" |
| 76 |
onclick="javascript: wpbc_copy_text_to_clipbrd_from_element('wpbc_modal__send_payment_request__url');" |
| 77 |
class="button button-secondary wpbc_modal__2_fields_button" |
| 78 |
title="<?php esc_attr_e( 'Copy', 'booking' ); ?>" |
| 79 |
><i class="menu_icon icon-1x wpbc_icn_content_copy"></i></a> |
| 80 |
</div> |
| 81 |
<label class="help-block"> |
| 82 |
<?php |
| 83 |
esc_html_e( 'Payment link URL', 'booking' ); |
| 84 |
?> |
| 85 |
</label> |
| 86 |
<textarea id="wpbc_modal__send_payment_request__value" name="wpbc_modal__send_payment_request__value" cols="87" rows="5" |
| 87 |
placeholder="<?php |
| 88 |
// esc_attr_e( 'Optional', 'booking' ); |
| 89 |
// echo '. '; |
| 90 |
// /* translators: 1: ... */ |
| 91 |
// echo esc_attr( sprintf( __( 'Type your %1$sreason for payment%2$s request', 'booking' ),'','') ); |
| 92 |
// echo '.'; |
| 93 |
?>" |
| 94 |
></textarea> |
| 95 |
<input type="hidden" id="wpbc_modal__send_payment_request__booking_id" value=""/> |
| 96 |
<!--p class="help-block"> |
| 97 |
<?php |
| 98 |
/* translators: 1: ... */ |
| 99 |
echo wp_kses_post( sprintf( __( 'To send a %1$spayment request%2$s, either click send email or copy the link and share it elsewhere', 'booking' ), '<a href="' . esc_url( wpbc_get_settings_url( true, false ) . '&tab=email&subtab=payment_request' ) . '">', '</a>', '<b>', '</b>' ) ); |
| 100 |
?> |
| 101 |
</p--> |
| 102 |
<label class="help-block"> |
| 103 |
<?php |
| 104 |
/* translators: 1: ... */ |
| 105 |
echo wp_kses_post( sprintf( __( 'Type your %1$sreason for payment%2$s request', 'booking' ), '<b>', ',</b>' ) ); |
| 106 |
?> |
| 107 |
</label> |
| 108 |
</div> |
| 109 |
<div class="modal-footer"> |
| 110 |
<a id="wpbc_modal__send_payment_request__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__send_payment_request__booking_id').val(), |
| 115 |
'reason_of_action' : jQuery( '#wpbc_modal__send_payment_request__value' ).val(), |
| 116 |
'ui_clicked_element_id' : 'wpbc_modal__send_payment_request__button_send' |
| 117 |
} ); |
| 118 |
wpbc_button_enable_loading_icon( this ); |
| 119 |
jQuery( '#wpbc_modal__send_payment_request__section' ).wpbc_my_modal( 'hide' ); |
| 120 |
" > |
| 121 |
<?php |
| 122 |
esc_html_e( 'Send Email', 'booking' ); |
| 123 |
?> |
| 124 |
</a> |
| 125 |
<a href="javascript:void(0)" class="button button-secondary" data-dismiss="modal"> |
| 126 |
<?php |
| 127 |
esc_html_e( 'Cancel', 'booking' ); |
| 128 |
?> |
| 129 |
</a> |
| 130 |
</div> |
| 131 |
</div><!-- /.modal-content --> |
| 132 |
</div><!-- /.modal-dialog --> |
| 133 |
</div><!-- /.modal --> |
| 134 |
</span> |
| 135 |
<?php |
| 136 |
} |
| 137 |
} |
| 138 |
|
| 139 |
// Loads hidden modal template. |
| 140 |
add_action( 'wpbc_hook_booking_template__hidden_templates', array( new WPBC_Action_Payment_Request(), 'template_for_modal' ) ); |
| 141 |
|