PluginProbe
Booking Calendar / 11.8.4
Booking Calendar v11.8.4
11.8.4 11.8.3 11.8.2 11.8.1 11.8 11.7 11.6.1 11.6 11.5 11.4.3 11.4.2 11.4.1 11.4 11.3 11.2.1 11.2 11.1 11.0 10.15.7 10.15.6 10.1.3 10.10 10.10.1 10.10.2 10.11 All 204 releases
booking / includes / page-bookings / listing_actions / export_csv.php

export_csv.php in Booking Calendar 11.8.4, at includes/page-bookings/listing_actions/export_csv.php

196 lines 7.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Class to Export CSV -- Option for "Bulk Actions - Dropdown Menu"
4 *
5 * @package Support functions.
6 */
7
8 if ( ! defined( 'ABSPATH' ) ) {
9 exit; // Exit, if accessed directly.
10 }
11
12 // JavaScript: in ../includes/page-bookings/_src/bookings__actions.js -> function wpbc_ajx_booking__ui_click__export_csv() { ... } .
13
14 /**
15 * Class WPBC_Listing_Actions__Export_CSV
16 */
17 class WPBC_Listing_Actions__Export_CSV{
18
19 const ACTION = 'export_csv';
20
21 /**
22 * Get Action Button
23 *
24 * @return false|string
25 */
26 public static function get_option() {
27
28 if ( ! class_exists( 'wpdev_bk_personal' ) ) {
29 return false;
30 }
31 if ( ! wpbc_is_user_can( self::ACTION, wpbc_get_current_user_id() ) ) {
32 return false;
33 }
34
35 $css_class = 'ul_dropdown_menu_li_action ';
36 $css_class .= 'ul_dropdown_menu_li_action_' . self::ACTION;
37
38 // Option Title.
39 $html = "<a href=\"javascript:void(0)\" class=\"" . esc_attr( $css_class ) . "\"
40 onclick=\"if ( 'function' === typeof( jQuery('#wpbc_modal__export_csv__section').wpbc_my_modal ) ) {
41 jQuery('#wpbc_modal__export_csv__section').wpbc_my_modal('show');
42 } else {
43 alert( 'Warning! wpbc_my_modal module has not found. Please, recheck about any conflicts by deactivating other plugins.');
44 }\"
45 title=\"" . esc_attr( __( 'Export bookings to CSV format', 'booking' ) ) . "\"
46 >" .
47 esc_js( __( 'Export to CSV', 'booking' ) ) .
48 ' ' .
49 ' <i class="menu_icon icon-1x wpbc-bi-filetype-csv"></i>'.
50 // "<span class='hint_value_instead_icon'>{{{data['parsed_fields']['currency_symbol']}}} {{data['parsed_fields']['cost']}}</span>" .
51 '</a>';
52
53 return $html;
54
55 // onclick=\"wpbc_ajx_booking_send_search_request_with_params({ '" . esc_attr( self::ID ) . "': '{$option_value}' }); \" //.
56 }
57
58
59 /**
60 * Get Template for Modal Window
61 *
62 * @return false|void
63 */
64 public static function template_for_modal() {
65
66 if ( ! class_exists( 'wpdev_bk_personal' ) ) {
67 return false;
68 }
69
70 // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing
71 $user_id = ( isset( $_REQUEST['wpbc_ajx_user_id'] ) ) ? intval( $_REQUEST['wpbc_ajx_user_id'] ) : wpbc_get_current_user_id();
72
73 $booking_csv_export_params = get_user_option( 'booking_csv_export_params', (int) $user_id );
74 $booking_csv_export_params = ( ! empty( $booking_csv_export_params ) ) ? $booking_csv_export_params : array();
75 $defaults = array(
76 'export_type' => 'csv_all',
77 'selected_id' => '',
78 'csv_export_separator' => 'semicolon',
79 'csv_export_skip_fields' => '',
80 );
81 $export_params_arr = wp_parse_args( $booking_csv_export_params, $defaults );
82
83 ?>
84 <span class="wpdevelop">
85 <div id="wpbc_modal__export_csv__section" class="modal wpbc_popup_modal wpbc_modal_in_listing" tabindex="-1" role="dialog">
86 <div class="modal-dialog">
87 <div class="modal-content">
88 <div class="modal-header">
89 <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
90 <h4 class="modal-title">
91 <?php
92 esc_html_e( 'CSV Export', 'booking' );
93 ?>
94 <sup class="wpbc_modal__export_csv__booking_id wpbc_modal__booking_id__in_title"></sup>
95 </h4>
96 </div>
97 <div class="modal-body">
98 <table class="form-table"><tbody>
99 <?php
100 $default_options_values = wpbc_get_default_options();
101
102 $field_options = array(
103 'semicolon' => '; - ' . __( 'semicolon', 'booking' ),
104 'comma' => ', - ' . __( 'comma', 'booking' ),
105 );
106 $fields = array(
107 'type' => 'select',
108 'value' => $export_params_arr['csv_export_separator'],
109 'title' => __( 'CSV data separator', 'booking' ),
110 'description' => '',
111 'options' => $field_options,
112 'label' => '',
113 'disabled' => false,
114 'disabled_options' => array(),
115 'multiple' => false,
116 'description_tag' => 'p',
117 'tr_class' => '',
118 'class' => '',
119 'css' => '',
120 'only_field' => false,
121 'attr' => array(),
122 );
123 WPBC_Settings_API::field_select_row_static( 'wpbc_field_booking_csv_export_separator', $fields );
124
125
126 $field_options = array(
127 'csv_page' => __( 'Current page', 'booking' ),
128 'csv_all' => __( 'All pages', 'booking' ),
129 );
130 $fields = array(
131 'type' => 'select',
132 'value' => $export_params_arr['export_type'],
133 'title' => __( 'Export pages', 'booking' ),
134 'description' => '',
135 'options' => $field_options,
136 'label' => '',
137 'disabled' => false,
138 'disabled_options' => array(),
139 'multiple' => false,
140 'description_tag' => 'p',
141 'tr_class' => '',
142 'class' => '',
143 'css' => '',
144 'only_field' => false,
145 'attr' => array(),
146 );
147 WPBC_Settings_API::field_select_row_static( 'wpbc_field_booking_csv_export_type', $fields );
148
149 ?>
150 </tbody></table>
151 <textarea id="wpbc_field_booking_csv_export_skip_fields"
152 name="wpbc_field_booking_csv_export_skip_fields"
153 style="width:100%;" cols="87" rows="2"
154 placeholder="<?php echo 'trash,is_new,secondname'; ?>"
155 ><?php
156 echo esc_textarea( $export_params_arr['csv_export_skip_fields'] );
157 ?></textarea>
158 <label class="help-block">
159 <?php
160 /* translators: 1: ... */
161 echo wp_kses_post( sprintf( __( 'Enter field names separated by commas to %1$sskip the export%2$s', 'booking' ), '<b>', '</b>' ) );
162 ?>
163 </label>
164 <input type="hidden" id="wpbc_modal__export_csv__booking_id" value="" />
165 </div>
166 <div class="modal-footer">
167 <a id="wpbc_modal__export_csv__button_send" class="button button-primary"
168 href="javascript:void(0);"
169 onclick="javascript: wpbc_ajx_booking__ui_click__export_csv( {
170 'booking_action' : '<?php echo esc_js( self::ACTION ); ?>',
171 'ui_clicked_element_id' : 'wpbc_modal__export_csv__button_send',
172 'export_type' : jQuery('#wpbc_field_booking_csv_export_type option:selected').val(),
173 'csv_export_separator' : jQuery('#wpbc_field_booking_csv_export_separator option:selected').val(),
174 'csv_export_skip_fields': jQuery('#wpbc_field_booking_csv_export_skip_fields').val()
175 } );"
176 >
177 <?php
178 esc_html_e( 'Export', 'booking' );
179 ?>
180 </a>
181 <a href="javascript:void(0)" class="button button-secondary" data-dismiss="modal">
182 <?php
183 esc_html_e( 'Cancel', 'booking' );
184 ?>
185 </a>
186 </div>
187 </div><!-- /.modal-content -->
188 </div><!-- /.modal-dialog -->
189 </div><!-- /.modal -->
190 </span>
191 <?php
192 }
193 }
194
195 // Loads hidden template.
196 add_action( 'wpbc_hook_booking_template__hidden_templates', array( new WPBC_Listing_Actions__Export_CSV(), 'template_for_modal' ) );