| 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_ajx_booking_listing__get_default_view_mode() ) { |
| 26 |
//if ( strpos( $_SERVER['REQUEST_URI'], 'view_mode=vm_booking_listing' ) !== false ) { |
| 27 |
|
| 28 |
add_action( 'wpbc_enqueue_js_files', array( $this, 'js_load_files' ), 50 ); |
| 29 |
add_action( 'wpbc_enqueue_css_files', array( $this, 'enqueue_css_files' ), 50 ); |
| 30 |
|
| 31 |
add_action( 'wpbc_hook_settings_page_footer', array( $this, 'hook__page_footer_tmpl' ) ); |
| 32 |
} |
| 33 |
} |
| 34 |
|
| 35 |
/** |
| 36 |
* JSS |
| 37 |
*/ |
| 38 |
public function js_load_files( $where_to_load ) { |
| 39 |
|
| 40 |
$in_footer = true; |
| 41 |
|
| 42 |
if ( ( is_admin() ) && ( in_array( $where_to_load, array( 'admin', 'both' ) ) ) ) { |
| 43 |
|
| 44 |
wp_enqueue_script( 'wpbc-booking_ajx_print', trailingslashit( plugins_url( '', __FILE__ ) ) . '_out/bookings_print.js' /* wpbc_plugin_url( '/_out/js/code_mirror.js' ) */ |
| 45 |
, array( 'wpbc_all' ), WP_BK_VERSION_NUM, $in_footer ); |
| 46 |
/** |
| 47 |
wp_enqueue_script( 'wpbc-booking_ajx_actions' |
| 48 |
, trailingslashit( plugins_url( '', __FILE__ ) ) . '_out/bookings__actions.js' // wpbc_plugin_url( '/_out/js/code_mirror.js' ) |
| 49 |
, array( 'wpbc_all' ), WP_BK_VERSION_NUM, $in_footer ); |
| 50 |
/** |
| 51 |
wp_localize_script( 'wpbc_all', 'wpbc_live_request_obj' |
| 52 |
, array( |
| 53 |
'ajx_booking' => '', |
| 54 |
'reminders' => '' |
| 55 |
) |
| 56 |
); |
| 57 |
*/ |
| 58 |
} |
| 59 |
} |
| 60 |
|
| 61 |
/** |
| 62 |
* CSS |
| 63 |
*/ |
| 64 |
public function enqueue_css_files( $where_to_load ) { |
| 65 |
|
| 66 |
if ( ( is_admin() ) && ( in_array( $where_to_load, array( 'admin', 'both' ) ) ) ) { |
| 67 |
|
| 68 |
wp_enqueue_style( 'wpbc-booking_ajx_print_css', trailingslashit( plugins_url( '', __FILE__ ) ) . '_out/bookings_print.css', array(), WP_BK_VERSION_NUM ); |
| 69 |
//wp_enqueue_style( 'wpbc-listing_ajx_booking', trailingslashit( plugins_url( '', __FILE__ ) ) . '_out/bookings__listing.css' , array(), WP_BK_VERSION_NUM ); |
| 70 |
|
| 71 |
} |
| 72 |
} |
| 73 |
|
| 74 |
/** |
| 75 |
* Templates |
| 76 |
* |
| 77 |
* @param $page |
| 78 |
* |
| 79 |
* @return void |
| 80 |
*/ |
| 81 |
public function hook__page_footer_tmpl( $page ){ |
| 82 |
|
| 83 |
// page=wpbc&view_mode=vm_booking_listing |
| 84 |
if ( 'wpbc-ajx_booking' === $page ) { // it's from >> do_action( 'wpbc_hook_settings_page_footer', 'wpbc-ajx_booking' ); |
| 85 |
$this->wpbc_write_content_for_modal_print(); |
| 86 |
} |
| 87 |
} |
| 88 |
|
| 89 |
/** Print Layout - Modal Window structure */ |
| 90 |
private function wpbc_write_content_for_modal_print() { |
| 91 |
|
| 92 |
?><span class="wpdevelop"><?php |
| 93 |
|
| 94 |
?><div id="wpbc_ajx_print_modal" class="modal wpbc_popup_modal" tabindex="-1" role="dialog"> |
| 95 |
<div class="modal-dialog modal-lg"> |
| 96 |
<div class="modal-content"> |
| 97 |
<div class="modal-header"> |
| 98 |
<h4 class="modal-title"><?php esc_html_e('Print bookings' ,'booking'); ?> |
| 99 |
<div style="float:right;"> |
| 100 |
<a href="javascript:void(0);" |
| 101 |
onclick="javascript: wpbc_print_dialog__do_printing();" |
| 102 |
class="button button-primary" ><?php esc_html_e('Print' ,'booking'); ?></a> |
| 103 |
<a href="javascript:void(0)" class="button" data-dismiss="modal"><?php esc_html_e('Close' ,'booking'); ?></a> |
| 104 |
<?php /* <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button> */ ?> |
| 105 |
|
| 106 |
</div></h4> |
| 107 |
</div> |
| 108 |
<div class="modal-body"> |
| 109 |
<div id="wpbc_content_for_js_print"> |
| 110 |
<div id="wpbc__print_frame__inner"> * </div> |
| 111 |
</div> |
| 112 |
</div> |
| 113 |
<?php /* ?> |
| 114 |
<div class="modal-footer"> |
| 115 |
<button type="button" class="button button-secondary" data-dismiss="modal">Close</button> |
| 116 |
<button type="button" class="button button-primary">Save changes</button> |
| 117 |
</div> |
| 118 |
<?php */ ?> |
| 119 |
</div><!-- /.modal-content --> |
| 120 |
</div><!-- /.modal-dialog --> |
| 121 |
</div><!-- /.modal --> |
| 122 |
<?php |
| 123 |
|
| 124 |
?></span><?php |
| 125 |
} |
| 126 |
} |
| 127 |
|
| 128 |
|
| 129 |
/** |
| 130 |
* Just for loading CSS and JavaScript files |
| 131 |
*/ |
| 132 |
if ( true ) { |
| 133 |
$ajx_booking_print = new WPBC_Print; |
| 134 |
$ajx_booking_print->init_load_css_js_tpl(); |
| 135 |
} |