| 1 |
<?php /** |
| 2 |
* @version 1.0 |
| 3 |
* @description AJX Bookings Print |
| 4 |
* @category AJX_Bookings Print Class |
| 5 |
* @author wpdevelop |
| 6 |
* |
| 7 |
* @web-site http://oplugins.com/ |
| 8 |
* @email info@oplugins.com |
| 9 |
* |
| 10 |
* @modified 2022-06-20 |
| 11 |
*/ |
| 12 |
|
| 13 |
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly |
| 14 |
|
| 15 |
|
| 16 |
class WPBC_Print { |
| 17 |
|
| 18 |
/** |
| 19 |
* Define HOOKs for loading CSS and JavaScript files |
| 20 |
*/ |
| 21 |
public function init_load_css_js_tpl() { |
| 22 |
// JS & CSS. |
| 23 |
|
| 24 |
// Load only at AJX_Bookings Settings Page. |
| 25 |
if ( 'vm_booking_listing' === wpbc_get_default_saved_view_mode_for_wpbc_page() ) { |
| 26 |
|
| 27 |
add_action( 'wpbc_enqueue_js_files', array( $this, 'js_load_files' ), 50 ); |
| 28 |
add_action( 'wpbc_enqueue_css_files', array( $this, 'enqueue_css_files' ), 50 ); |
| 29 |
|
| 30 |
add_action( 'wpbc_hook_settings_page_footer', array( $this, 'hook__page_footer_tmpl' ) ); |
| 31 |
} |
| 32 |
} |
| 33 |
|
| 34 |
/** |
| 35 |
* JSS |
| 36 |
*/ |
| 37 |
public function js_load_files( $where_to_load ) { |
| 38 |
|
| 39 |
$in_footer = true; |
| 40 |
|
| 41 |
if ( ( is_admin() ) && ( in_array( $where_to_load, array( 'admin', 'both' ) ) ) ) { |
| 42 |
|
| 43 |
wp_enqueue_script( 'wpbc-booking_ajx_print', trailingslashit( plugins_url( '', __FILE__ ) ) . '_out/bookings_print.js' /* wpbc_plugin_url( '/_out/js/code_mirror.js' ) */ |
| 44 |
, array( 'wpbc_all' ), WP_BK_VERSION_NUM, $in_footer ); |
| 45 |
/** |
| 46 |
wp_enqueue_script( 'wpbc-booking_ajx_actions' |
| 47 |
, trailingslashit( plugins_url( '', __FILE__ ) ) . '_out/bookings__actions.js' // wpbc_plugin_url( '/_out/js/code_mirror.js' ) |
| 48 |
, array( 'wpbc_all' ), WP_BK_VERSION_NUM, $in_footer ); |
| 49 |
/** |
| 50 |
wp_localize_script( 'wpbc_all', 'wpbc_live_request_obj' |
| 51 |
, array( |
| 52 |
'ajx_booking' => '', |
| 53 |
'reminders' => '' |
| 54 |
) |
| 55 |
); |
| 56 |
*/ |
| 57 |
} |
| 58 |
} |
| 59 |
|
| 60 |
/** |
| 61 |
* CSS |
| 62 |
*/ |
| 63 |
public function enqueue_css_files( $where_to_load ) { |
| 64 |
|
| 65 |
if ( ( is_admin() ) && ( in_array( $where_to_load, array( 'admin', 'both' ) ) ) ) { |
| 66 |
|
| 67 |
wp_enqueue_style( 'wpbc-booking_ajx_print_css', trailingslashit( plugins_url( '', __FILE__ ) ) . '_out/bookings_print.css', array(), WP_BK_VERSION_NUM ); |
| 68 |
//wp_enqueue_style( 'wpbc-listing_ajx_booking', trailingslashit( plugins_url( '', __FILE__ ) ) . '_out/bookings__listing.css' , array(), WP_BK_VERSION_NUM ); |
| 69 |
|
| 70 |
} |
| 71 |
} |
| 72 |
|
| 73 |
/** |
| 74 |
* Templates |
| 75 |
* |
| 76 |
* @param $page |
| 77 |
* |
| 78 |
* @return void |
| 79 |
*/ |
| 80 |
public function hook__page_footer_tmpl( $page ){ |
| 81 |
|
| 82 |
// page=wpbc&tab=vm_booking_listing |
| 83 |
if ( 'wpbc-ajx_booking' === $page ) { // it's from >> do_action( 'wpbc_hook_settings_page_footer', 'wpbc-ajx_booking' ); |
| 84 |
$this->wpbc_write_content_for_modal_print(); |
| 85 |
} |
| 86 |
} |
| 87 |
|
| 88 |
/** Print Layout - Modal Window structure */ |
| 89 |
private function wpbc_write_content_for_modal_print() { |
| 90 |
|
| 91 |
?><span class="wpdevelop"><?php |
| 92 |
|
| 93 |
?><div id="wpbc_ajx_print_modal" class="modal wpbc_popup_modal" tabindex="-1" role="dialog"> |
| 94 |
<div class="modal-dialog modal-lg"> |
| 95 |
<div class="modal-content"> |
| 96 |
<div class="modal-header"> |
| 97 |
<h4 class="modal-title"><?php esc_html_e('Print bookings' ,'booking'); ?> |
| 98 |
<div style="float:right;"> |
| 99 |
<a href="javascript:void(0);" |
| 100 |
onclick="javascript: wpbc_print_dialog__do_printing();" |
| 101 |
class="button button-primary" ><?php esc_html_e('Print' ,'booking'); ?></a> |
| 102 |
<a href="javascript:void(0)" class="button" data-dismiss="modal"><?php esc_html_e('Close' ,'booking'); ?></a> |
| 103 |
<?php /* <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button> */ ?> |
| 104 |
|
| 105 |
</div></h4> |
| 106 |
</div> |
| 107 |
<div class="modal-body"> |
| 108 |
<div id="wpbc_content_for_js_print"> |
| 109 |
<div id="wpbc__print_frame__inner"> * </div> |
| 110 |
</div> |
| 111 |
</div> |
| 112 |
<?php /* ?> |
| 113 |
<div class="modal-footer"> |
| 114 |
<button type="button" class="button button-secondary" data-dismiss="modal">Close</button> |
| 115 |
<button type="button" class="button button-primary">Save changes</button> |
| 116 |
</div> |
| 117 |
<?php */ ?> |
| 118 |
</div><!-- /.modal-content --> |
| 119 |
</div><!-- /.modal-dialog --> |
| 120 |
</div><!-- /.modal --> |
| 121 |
<?php |
| 122 |
|
| 123 |
?></span><?php |
| 124 |
} |
| 125 |
} |
| 126 |
|
| 127 |
|
| 128 |
/** |
| 129 |
* Just for loading CSS and JavaScript files |
| 130 |
*/ |
| 131 |
if ( true ) { |
| 132 |
$wpbc_ajx_booking_print = new WPBC_Print; |
| 133 |
$wpbc_ajx_booking_print->init_load_css_js_tpl(); |
| 134 |
} |