| 1 |
<?php /** |
| 2 |
* @version 1.0 |
| 3 |
* @package Booking Calendar |
| 4 |
* @category Admin Panel - Dashboard functions |
| 5 |
* @author wpdevelop |
| 6 |
* |
| 7 |
* @web-site https://wpbookingcalendar.com/ |
| 8 |
* @email info@wpbookingcalendar.com |
| 9 |
* |
| 10 |
* @modified 2016-03-16 |
| 11 |
*/ |
| 12 |
|
| 13 |
if ( ! defined( 'ABSPATH' ) ) exit; // Exit, if accessed directly |
| 14 |
|
| 15 |
|
| 16 |
/** |
| 17 |
* Get number of bookings for different parameters |
| 18 |
* |
| 19 |
* @return int[] |
| 20 |
*/ |
| 21 |
function wpbc_db_dashboard_get_bookings_count_arr(){ |
| 22 |
|
| 23 |
|
| 24 |
// <editor-fold defaultstate="collapsed" desc=" Get bookings for counting number of specific bookings " > |
| 25 |
$my_resources = array(); |
| 26 |
if ( class_exists( 'wpdev_bk_multiuser' ) ) { |
| 27 |
$is_superadmin = apply_bk_filter( 'multiuser_is_user_can_be_here', true, 'only_super_admin' ); |
| 28 |
if ( ! $is_superadmin ) { |
| 29 |
|
| 30 |
$bk_ids = apply_bk_filter( 'get_bk_resources_of_user', false ); |
| 31 |
|
| 32 |
if ( $bk_ids !== false ) { |
| 33 |
foreach ( $bk_ids as $bk_id ) { |
| 34 |
$my_resources[] = $bk_id->ID; |
| 35 |
} |
| 36 |
} |
| 37 |
} |
| 38 |
} |
| 39 |
$my_resources = implode( ',', $my_resources ); |
| 40 |
|
| 41 |
global $wpdb; |
| 42 |
|
| 43 |
$trash_bookings = ' bk.trash != 1 '; //FixIn: 6.1.1.10 - check also below usage of {$trash_bookings} |
| 44 |
|
| 45 |
$sql_req = "SELECT DISTINCT bk.booking_id as id, dt.approved, dt.booking_date, bk.modification_date as m_date , bk.is_new as new |
| 46 |
FROM {$wpdb->prefix}bookingdates as dt |
| 47 |
INNER JOIN {$wpdb->prefix}booking as bk |
| 48 |
ON bk.booking_id = dt.booking_id " |
| 49 |
. " WHERE {$trash_bookings} " ; |
| 50 |
if ($my_resources!='') $sql_req .= " AND bk.booking_type IN ({$my_resources}) "; |
| 51 |
|
| 52 |
$sql_req .= "ORDER BY dt.booking_date" ; |
| 53 |
|
| 54 |
$sql_results = $wpdb->get_results( $sql_req ); |
| 55 |
// </editor-fold> |
| 56 |
|
| 57 |
|
| 58 |
// <editor-fold defaultstate="collapsed" desc=" Count bookings " > |
| 59 |
$bk_array = array(); |
| 60 |
if ( ! empty( $sql_results ) ) |
| 61 |
foreach ( $sql_results as $v ) { |
| 62 |
|
| 63 |
if ( !isset( $bk_array[$v->id] ) ) |
| 64 |
$bk_array[$v->id] = array( |
| 65 |
'dates' => array() |
| 66 |
, 'bk_today' => 0 |
| 67 |
, 'm_today' => 0 |
| 68 |
); |
| 69 |
$bk_array[$v->id]['id'] = $v->id; |
| 70 |
$bk_array[$v->id]['approved'] = $v->approved; |
| 71 |
$bk_array[$v->id]['dates'][] = $v->booking_date; |
| 72 |
$bk_array[$v->id]['m_date'] = $v->m_date; // Modification Booking date |
| 73 |
$bk_array[$v->id]['new'] = $v->new; |
| 74 |
if ( wpbc_is_today_date( $v->booking_date ) ) { |
| 75 |
$bk_array[ $v->id ]['bk_today'] = 1; |
| 76 |
} |
| 77 |
if ( wpbc_is_today_date( $v->m_date ) ) { |
| 78 |
$bk_array[ $v->id ]['m_today'] = 1; |
| 79 |
} |
| 80 |
} |
| 81 |
|
| 82 |
$counter = array( |
| 83 |
'all' => 0 |
| 84 |
, 'new' => 0 |
| 85 |
, 'pending' => 0 |
| 86 |
, 'approved' => 0 |
| 87 |
, 'booking_today' => 0 |
| 88 |
, 'was_made_today' => 0 |
| 89 |
); |
| 90 |
foreach ( $bk_array as $k => $v ) { |
| 91 |
|
| 92 |
$counter['all']++; |
| 93 |
if ( $v['new'] ) { |
| 94 |
$counter['new'] ++; |
| 95 |
} |
| 96 |
if ( $v['m_today'] ) { |
| 97 |
$counter['was_made_today'] ++; |
| 98 |
} |
| 99 |
if ( $v['bk_today'] ) { |
| 100 |
$counter['booking_today'] ++; |
| 101 |
} |
| 102 |
if ( $v['approved'] ) { |
| 103 |
$counter['approved'] ++; |
| 104 |
} else { |
| 105 |
$counter['pending'] ++; |
| 106 |
} |
| 107 |
} |
| 108 |
// </editor-fold> |
| 109 |
|
| 110 |
|
| 111 |
return $counter; |
| 112 |
} |
| 113 |
|
| 114 |
|
| 115 |
//////////////////////////////////////////////////////////////////////////////// |
| 116 |
// D a s h b o a r d W i d g e t |
| 117 |
//////////////////////////////////////////////////////////////////////////////// |
| 118 |
|
| 119 |
/** Setup Widget for Dashboard */ |
| 120 |
function wpbc_dashboard_widget_setup(){ |
| 121 |
|
| 122 |
// Check, if we have permission to show Widget /////////////////////////// |
| 123 |
$is_user_activated = apply_bk_filter('multiuser_is_current_user_active', true ); //FixIn: 6.0.1.17 |
| 124 |
if ( ! $is_user_activated ) |
| 125 |
return false; |
| 126 |
|
| 127 |
$user_role = get_bk_option( 'booking_user_role_booking' ); |
| 128 |
if ( ! wpbc_is_current_user_have_this_role( $user_role ) ) |
| 129 |
return false; |
| 130 |
|
| 131 |
|
| 132 |
// Add Booking Calendar Widget to Dashboard /////////////////////////////// |
| 133 |
$bk_dashboard_widget_id = 'booking_dashboard_widget'; |
| 134 |
wp_add_dashboard_widget( $bk_dashboard_widget_id, sprintf( __( 'Booking Calendar', 'booking' ) ), 'wpbc_dashboard_widget_show', null ); |
| 135 |
|
| 136 |
|
| 137 |
// Sort Dashboard. Add Booking Calendar widget to top /////////////////////// |
| 138 |
global $wp_meta_boxes; |
| 139 |
$normal_dashboard = $wp_meta_boxes['dashboard']['normal']['core']; |
| 140 |
if ( isset( $normal_dashboard[$bk_dashboard_widget_id] ) ) { |
| 141 |
// Backup and delete our new dashbaord widget from the end of the array |
| 142 |
$example_widget_backup = array( $bk_dashboard_widget_id => $normal_dashboard[$bk_dashboard_widget_id] ); |
| 143 |
unset( $normal_dashboard[$bk_dashboard_widget_id] ); |
| 144 |
} else |
| 145 |
$example_widget_backup = array(); |
| 146 |
|
| 147 |
// Sometimes, some other plugins can modify this item, so its can be not a array |
| 148 |
if ( is_array( $normal_dashboard ) ) { |
| 149 |
// Merge the two arrays together so our widget is at the beginning |
| 150 |
if ( is_array( $normal_dashboard ) ) |
| 151 |
$sorted_dashboard = array_merge( $example_widget_backup, $normal_dashboard ); |
| 152 |
else |
| 153 |
$sorted_dashboard = $example_widget_backup; |
| 154 |
// Save the sorted array back into the original metaboxes |
| 155 |
$wp_meta_boxes['dashboard']['normal']['core'] = $sorted_dashboard; |
| 156 |
} |
| 157 |
} |
| 158 |
add_action( 'wp_dashboard_setup', 'wpbc_dashboard_widget_setup' ); |
| 159 |
|
| 160 |
|
| 161 |
/** Show Booking Dashboard Widget content */ |
| 162 |
function wpbc_dashboard_widget_show() { |
| 163 |
|
| 164 |
$is_panel_visible = wpbc_is_dismissed_panel_visible( 'wpbc_dashboard_section_statistic' ); //FixIn: 9.9.0.8 |
| 165 |
$counter = $is_panel_visible ? wpbc_db_dashboard_get_bookings_count_arr() : array(); |
| 166 |
|
| 167 |
wpbc_dashboard_widget_css(); |
| 168 |
|
| 169 |
?> |
| 170 |
<div id="wpbc_dashboard_widget_container" ><?php |
| 171 |
|
| 172 |
|
| 173 |
wpbc_dashboard_section_statistic( $counter ); |
| 174 |
|
| 175 |
?><div style="clear:both;margin-bottom:20px;"></div><?php |
| 176 |
|
| 177 |
wpbc_dashboard_section_news(); |
| 178 |
|
| 179 |
?><div style="clear:both;"></div><?php |
| 180 |
wpbc_dashboard_section_version(); |
| 181 |
|
| 182 |
wpbc_dashboard_section_support(); |
| 183 |
|
| 184 |
?><div style="clear:both;"></div><?php |
| 185 |
|
| 186 |
|
| 187 |
wpbc_dashboard_section_video_f(); |
| 188 |
|
| 189 |
wpbc_dashboard_section_video_p(); |
| 190 |
|
| 191 |
|
| 192 |
|
| 193 |
?><div style="clear:both;"></div> |
| 194 |
|
| 195 |
</div> |
| 196 |
<div style="clear:both;"></div> |
| 197 |
<?php |
| 198 |
} |
| 199 |
|
| 200 |
|
| 201 |
/** Get Info for Dashboard */ |
| 202 |
function wpbc_get_dashboard_info() { |
| 203 |
|
| 204 |
ob_start(); |
| 205 |
|
| 206 |
wpbc_dashboard_widget_show(); |
| 207 |
|
| 208 |
return ob_get_clean(); |
| 209 |
} |
| 210 |
|
| 211 |
|
| 212 |
/** CSS for Dashboard Widget */ |
| 213 |
function wpbc_dashboard_widget_css() { |
| 214 |
|
| 215 |
?><style type="text/css"> |
| 216 |
#wpbc_dashboard_widget_container { |
| 217 |
width:100%; |
| 218 |
} |
| 219 |
#wpbc_dashboard_widget_container .wpbc_dashboard_section { |
| 220 |
float:left; |
| 221 |
margin:0px; |
| 222 |
padding:0px; |
| 223 |
width:49%; |
| 224 |
} |
| 225 |
#wpbc_dashboard_widget_container .wpbc_dashboard_section h4 { |
| 226 |
font-size: 14px; |
| 227 |
font-weight: 600; |
| 228 |
margin: 5px 0 15px; |
| 229 |
} |
| 230 |
#bk_upgrade_section p { |
| 231 |
font-size: 13px; |
| 232 |
line-height: 1.5em; |
| 233 |
margin: 15px 0 0; |
| 234 |
padding: 0; |
| 235 |
} |
| 236 |
#dashboard-widgets-wrap #wpbc_dashboard_widget_container .wpbc_dashboard_section { |
| 237 |
width:49%; |
| 238 |
} |
| 239 |
#dashboard-widgets-wrap #wpbc_dashboard_widget_container .bk_right { |
| 240 |
float:right |
| 241 |
} |
| 242 |
#dashboard-widgets-wrap #wpbc_dashboard_widget_container .border_orrange, |
| 243 |
#wpbc_dashboard_widget_container .border_orrange { |
| 244 |
background: #fffaf1 none repeat scroll 0 0; |
| 245 |
border-left: 3px solid #eeab26; |
| 246 |
clear: both; |
| 247 |
margin: 5px 5px 20px; |
| 248 |
padding: 10px 0; |
| 249 |
width: 99%; |
| 250 |
} |
| 251 |
#wpbc_dashboard_widget_container .bk_header { |
| 252 |
color: #555555; |
| 253 |
font-size: 13px; |
| 254 |
font-weight: 600; |
| 255 |
line-height: 1em; |
| 256 |
/* //FixIn: 8.1.3.10 */ |
| 257 |
padding:0 5px; |
| 258 |
} |
| 259 |
#wpbc_dashboard_widget_container .bk_table { |
| 260 |
background:transparent; |
| 261 |
/*border-bottom:none;*/ |
| 262 |
/*border-top:1px solid #ECECEC;*/ |
| 263 |
margin:6px 0 10px 6px; |
| 264 |
padding:2px 10px; |
| 265 |
width:95%; |
| 266 |
-border-radius:4px; |
| 267 |
-moz-border-radius:4px; |
| 268 |
-webkit-border-radius:4px; |
| 269 |
/*-moz-box-shadow:0 0 2px #C5C3C3;*/ |
| 270 |
/*-webkit-box-shadow:0 0 2px #C5C3C3;*/ |
| 271 |
/*-box-shadow:0 0 2px #C5C3C3;*/ |
| 272 |
border:none; |
| 273 |
box-shadow:none; |
| 274 |
} |
| 275 |
#wpbc_dashboard_widget_container .bk_table td{ |
| 276 |
border-bottom:1px solid #DDDDDD; |
| 277 |
line-height:19px; |
| 278 |
padding:4px 0px 4px 10px; |
| 279 |
font-size:13px; |
| 280 |
} |
| 281 |
#wpbc_dashboard_widget_container .bk_table tr td.first{ |
| 282 |
text-align:center; |
| 283 |
padding:4px 0px; |
| 284 |
} |
| 285 |
#wpbc_dashboard_widget_container .bk_table tr td a { |
| 286 |
text-decoration: none; |
| 287 |
} |
| 288 |
#wpbc_dashboard_widget_container .bk_table tr td a span{ |
| 289 |
font-size:18px; |
| 290 |
font-family: Georgia,"Times New Roman","Bitstream Charter",Times,serif; |
| 291 |
} |
| 292 |
#wpbc_dashboard_widget_container .bk_table td.bk_spec_font a{ |
| 293 |
font-family: Georgia,"Times New Roman","Bitstream Charter",Times,serif; |
| 294 |
font-size:14px; |
| 295 |
} |
| 296 |
#wpbc_dashboard_widget_container .bk_table td.bk_spec_font { |
| 297 |
font-family: Georgia,"Times New Roman","Bitstream Charter",Times,serif; |
| 298 |
font-size:13px; |
| 299 |
} |
| 300 |
#wpbc_dashboard_widget_container .bk_table td.pending a{ |
| 301 |
color:#E66F00; |
| 302 |
} |
| 303 |
#wpbc_dashboard_widget_container .bk_table td.new-bookings a{ |
| 304 |
color:red; |
| 305 |
} |
| 306 |
#wpbc_dashboard_widget_container .bk_table td.actual-bookings a{ |
| 307 |
color:green; |
| 308 |
} |
| 309 |
#bk_errror_loading { |
| 310 |
text-align: center; |
| 311 |
font-style: italic; |
| 312 |
font-size:11px; |
| 313 |
} |
| 314 |
#wpbc_dashboard_widget_container .bk_table tr:last-child td { |
| 315 |
border:none; |
| 316 |
} |
| 317 |
</style><?php |
| 318 |
} |
| 319 |
|
| 320 |
|
| 321 |
|
| 322 |
|
| 323 |
//////////////////////////////////////////////////////////////////////////////// |
| 324 |
// S e c t i o n s |
| 325 |
//////////////////////////////////////////////////////////////////////////////// |
| 326 |
|
| 327 |
//FixIn: 8.1.3.11 |
| 328 |
/** Dashboard Section - Video 1 */ |
| 329 |
function wpbc_dashboard_section_video_f() { |
| 330 |
?> |
| 331 |
<div id='wpbc_dashboard_section_video_f' class="wpbc_dashboard_section bk_left"> |
| 332 |
<span class="bk_header"><?php _e('Video guide' ,'booking');?> (free):</span> |
| 333 |
<?php wpbc_is_dismissed( 'wpbc_dashboard_section_video_f' ); //FixIn: 8.1.3.10 ?> |
| 334 |
<?php // Free ?> |
| 335 |
<div style="text-align: center;margin:10px 0;"><iframe style="width:90%;height:auto;" src="https://www.youtube.com/embed/videoseries?list=PLabuVtqCh9dwLA5cpz1p2RrZOitLuVupR&start=28&rel=0" frameborder="0" allow="autoplay; encrypted-media" allowfullscreen></iframe></div> |
| 336 |
</div> |
| 337 |
<?php |
| 338 |
} |
| 339 |
|
| 340 |
//FixIn: 8.1.3.11 |
| 341 |
/** Dashboard Section - Video 2 */ |
| 342 |
function wpbc_dashboard_section_video_p() { |
| 343 |
?> |
| 344 |
<div id='wpbc_dashboard_section_video_p' class="wpbc_dashboard_section bk_right"> |
| 345 |
<?php wpbc_is_dismissed( 'wpbc_dashboard_section_video_p' ); //FixIn: 8.1.3.10 ?> |
| 346 |
<span class="bk_header"><?php _e('Video guide' ,'booking');?> (premium):</span> |
| 347 |
<?php // Premium ?> |
| 348 |
<div style="text-align: center;margin:10px 0;"><iframe style="width:90%;height:auto;" src="https://www.youtube.com/embed/videoseries?list=PLabuVtqCh9dyc_EO8L_1FKJyLpBuIv21_&rel=0" frameborder="0" allow="autoplay; encrypted-media" allowfullscreen></iframe></div> |
| 349 |
</div> |
| 350 |
<?php |
| 351 |
} |
| 352 |
|
| 353 |
/** Dashboard Support Section */ |
| 354 |
function wpbc_dashboard_section_support() { |
| 355 |
?> |
| 356 |
<div id="wpbc_dashboard_section_support" class="wpbc_dashboard_section bk_right"> |
| 357 |
<span class="bk_header"><?php _e('Support' ,'booking');?>:</span> |
| 358 |
<?php wpbc_is_dismissed( 'wpbc_dashboard_section_support', array( 'css' => 'padding: 0 20px;' ) ); //FixIn: 8.1.3.10 ?> |
| 359 |
<?php /* ?> |
| 360 |
<?php // Free ?> |
| 361 |
<div style="text-align: center;margin:10px 0;"><iframe style="width:90%;height:auto;" src="https://www.youtube.com/embed/videoseries?list=PLabuVtqCh9dwLA5cpz1p2RrZOitLuVupR&start=28&rel=0" frameborder="0" allow="autoplay; encrypted-media" allowfullscreen></iframe></div> |
| 362 |
<?php // Premium ?> |
| 363 |
<div style="text-align: center;margin:10px 0;"><iframe style="width:90%;height:auto;" src="https://www.youtube.com/embed/videoseries?list=PLabuVtqCh9dyc_EO8L_1FKJyLpBuIv21_&rel=0" frameborder="0" allow="autoplay; encrypted-media" allowfullscreen></iframe></div> |
| 364 |
<?php */ ?> |
| 365 |
<table class="bk_table"> |
| 366 |
<tr class="first"> |
| 367 |
<td style="text-align:center;" class="bk_spec_font"><a href="<?php echo esc_url( admin_url( add_query_arg( array( 'page' => 'wpbc-getting-started' ), 'index.php' ) ) ); ?>" |
| 368 |
><?php _e('Getting Started' ,'booking');?></a> |
| 369 |
</td> |
| 370 |
</tr> |
| 371 |
<tr> |
| 372 |
<td style="text-align:center;" class="bk_spec_font"><a target="_blank" href="https://wpbookingcalendar.com/help/"><?php _e('Help Info' ,'booking');?></a></td> |
| 373 |
</tr> |
| 374 |
<tr> |
| 375 |
<td style="text-align:center;" class="bk_spec_font"><a target="_blank" href="https://wpbookingcalendar.com/faq/"><?php _e('FAQ' ,'booking');?></a></td> |
| 376 |
</tr> |
| 377 |
<tr> |
| 378 |
<td style="text-align:center;" class="bk_spec_font"><a href="mailto:support@wpbookingcalendar.com"><?php _e('Contact email' ,'booking');?></a></td> |
| 379 |
</tr> |
| 380 |
<tr> |
| 381 |
<td style="text-align:center;" class="bk_spec_font"><a target="_blank" href="https://wordpress.org/plugins/booking/"><?php _e('Rate plugin (thanks:)' ,'booking');?></a></td> |
| 382 |
</tr> |
| 383 |
</table> |
| 384 |
</div> |
| 385 |
<?php |
| 386 |
} |
| 387 |
|
| 388 |
|
| 389 |
/** Dashboard News Section */ |
| 390 |
function wpbc_dashboard_section_news() { |
| 391 |
|
| 392 |
?><div id="wpbc_dashboard_section_news"><?php |
| 393 |
|
| 394 |
wp_nonce_field( 'wpbc_ajax_admin_nonce', "wpbc_admin_panel_nonce_dashboard", true, true ); // Nonce for Ajax |
| 395 |
|
| 396 |
?> |
| 397 |
<div style="width:95%;border:none;clear:both;margin:10px 6px;" id="bk_news_section"> |
| 398 |
<div style="width: 99%;margin-right:0;" > |
| 399 |
<span class="bk_header" style="padding: 0;">Booking Calendar News:</span><?php |
| 400 |
|
| 401 |
wpbc_is_dismissed( 'wpbc_dashboard_section_news' ); //FixIn: 8.1.3.10 |
| 402 |
|
| 403 |
?><br/><br/> |
| 404 |
<div id="bk_news" class="rssSummary"> <span style="font-size:13px;text-align:center;">Loading...</span></div> |
| 405 |
<div id="ajax_bk_respond" class="rssSummary" style="display:none;"></div> |
| 406 |
<script type="text/javascript"> |
| 407 |
jQuery.ajax({ |
| 408 |
url: '<?php echo admin_url( 'admin-ajax.php' ); ?>', |
| 409 |
type:'POST', |
| 410 |
success: function (data, textStatus){ if( textStatus == 'success' ) jQuery('#ajax_bk_respond').html( data ); }, |
| 411 |
error: function (XMLHttpRequest, textStatus, errorThrown){ window.status = 'Ajax sending Error status:' + textStatus; }, |
| 412 |
data:{ |
| 413 |
action: 'CHECK_BK_NEWS', |
| 414 |
wpbc_nonce: document.getElementById('wpbc_admin_panel_nonce_dashboard').value |
| 415 |
} |
| 416 |
}); |
| 417 |
</script> |
| 418 |
</div> |
| 419 |
</div> |
| 420 |
|
| 421 |
</div> |
| 422 |
<?php |
| 423 |
} |
| 424 |
|
| 425 |
|
| 426 |
function wpbc_dashboard_info_get_version_type(){ |
| 427 |
$version = 'free'; |
| 428 |
$version = wpbc_get_plugin_version_type(); |
| 429 |
if ( wpbc_is_this_demo() ) { |
| 430 |
$version = 'free'; |
| 431 |
} |
| 432 |
return $version; |
| 433 |
} |
| 434 |
|
| 435 |
function wpbc_dashboard_info_get_version_type_readable() { |
| 436 |
|
| 437 |
$ver = wpbc_get_plugin_version_type(); |
| 438 |
if ( class_exists( 'wpdev_bk_multiuser' ) ) { |
| 439 |
$ver = 'multiUser'; |
| 440 |
} |
| 441 |
$ver = str_replace( '_m', ' Medium', $ver ); |
| 442 |
$ver = str_replace( '_l', ' Large', $ver ); |
| 443 |
$ver = str_replace( '_s', ' Small', $ver ); |
| 444 |
$ver = str_replace( 'biz', 'Business', $ver ); |
| 445 |
$ver = ucwords( $ver ); |
| 446 |
return $ver; |
| 447 |
} |
| 448 |
|
| 449 |
function wpbc_dashboard_info_get_version_type_sites() { |
| 450 |
|
| 451 |
$v_type = ''; |
| 452 |
if ( strpos( strtolower( WPDEV_BK_VERSION ), 'multisite' ) !== false ) { |
| 453 |
$v_type = '5'; |
| 454 |
} else if ( strpos( strtolower( WPDEV_BK_VERSION ), 'develop' ) !== false ) { |
| 455 |
$v_type = '2'; |
| 456 |
} |
| 457 |
|
| 458 |
if ( ! empty( $v_type ) ) { |
| 459 |
return ' ' . $v_type . ' ' . __( 'websites', 'booking' ); |
| 460 |
} else { |
| 461 |
return ' 1' . ' ' . __( 'website', 'booking' ); |
| 462 |
} |
| 463 |
} |
| 464 |
|
| 465 |
function wpbc_dashboard_info_get_version_number() { |
| 466 |
|
| 467 |
if ( substr( WPDEV_BK_VERSION, 0, 3 ) == '11.' ) { |
| 468 |
|
| 469 |
$show_version = substr( WPDEV_BK_VERSION, 3 ); |
| 470 |
|
| 471 |
if ( substr( $show_version, ( - 1 * ( strlen( WP_BK_VERSION_NUM ) ) ) ) === WP_BK_VERSION_NUM ) { |
| 472 |
$show_version = substr( $show_version, 0, ( - 1 * ( strlen( WP_BK_VERSION_NUM ) ) - 1 ) ); |
| 473 |
$show_version = str_replace( '.', ' ', $show_version ) . " <sup><strong style='font-size:12px;'>" . WP_BK_VERSION_NUM . "</strong></sup>"; |
| 474 |
} |
| 475 |
return $show_version; |
| 476 |
} else { |
| 477 |
return WPDEV_BK_VERSION; |
| 478 |
} |
| 479 |
} |
| 480 |
|
| 481 |
|
| 482 |
/** Dashboard Version Section */ |
| 483 |
function wpbc_dashboard_section_version() { |
| 484 |
|
| 485 |
|
| 486 |
$version = wpbc_dashboard_info_get_version_type(); |
| 487 |
|
| 488 |
/* |
| 489 |
|
| 490 |
Disbale hidded notice about Upgrade to higher version in paid versions |
| 491 |
//FixIn: 8.0.1.6 |
| 492 |
if ( ( $version !== 'free' ) && ( class_exists('wpdev_bk_multiuser') === false ) ) { ?> |
| 493 |
<div class="wpbc_dashboard_section border_orrange" id="bk_upgrade_section"> |
| 494 |
<div style="padding:0px 10px;width:96%;"> |
| 495 |
<h4><?php _e('Upgrade to higher versions' ,'booking') ?>:</h4> |
| 496 |
<p>Check additional advanced functionality, which exist in higher versions and can be interesting for you <a href="https://wpbookingcalendar.com/features/" target="_blank">here »</a></p> |
| 497 |
<p><a class="button button-primary" style="margin-top: 10px;font-weight: 600;" href="<?php echo wpbc_up_link(); ?>" target="_blank"><?php if ( wpbc_get_ver_sufix() == '' ) { _e('Purchase' ,'booking'); } else { _e('Upgrade Now' ,'booking'); } ?></a> </p> |
| 498 |
</div> |
| 499 |
</div> |
| 500 |
<div style="clear:both;"></div> |
| 501 |
<?php if ( wpbc_get_ver_sufix() != '' ) { ?> |
| 502 |
<script type="text/javascript"> |
| 503 |
jQuery(document).ready(function(){ |
| 504 |
jQuery('#bk_upgrade_section').animate({opacity:1},7000).fadeOut(2000); |
| 505 |
}); |
| 506 |
</script> |
| 507 |
<?php } ?> |
| 508 |
<?php } |
| 509 |
*/ |
| 510 |
?> |
| 511 |
<div id="wpbc_dashboard_section_current_version" class="wpbc_dashboard_section" > |
| 512 |
<span class="bk_header"><?php _e('Current version' ,'booking');?>:</span> |
| 513 |
<table class="bk_table"> |
| 514 |
<?php if ( wpbc_is_this_demo() ) { ?> |
| 515 |
<tr class="first"> |
| 516 |
<td></td> |
| 517 |
<td style="font-weight: 600; text-align: left;"><?php _e('Demo' ,'booking');?></td> |
| 518 |
</tr> |
| 519 |
<?php } ?> |
| 520 |
<tr class="first"> |
| 521 |
<td style="width:35%;text-align: right;;" class=""><?php _e('Version' ,'booking');?>:</td> |
| 522 |
<td style="color: #e50;font-size: 13px;font-weight: 600;text-align: left;text-shadow: 0 -1px 0 #eee;;" |
| 523 |
class="bk_spec_font"><?php |
| 524 |
|
| 525 |
echo wpbc_dashboard_info_get_version_number(); |
| 526 |
|
| 527 |
?></td> |
| 528 |
</tr> |
| 529 |
<?php if ($version != 'free') { ?> |
| 530 |
<tr> |
| 531 |
<td style="width:35%;text-align: right;" class="first b"><?php _e('Type' ,'booking');?>:</td> |
| 532 |
<td style="text-align: left; font-weight: 600;" class="bk_spec_font"><?php |
| 533 |
echo wpbc_dashboard_info_get_version_type_readable(); |
| 534 |
?></td> |
| 535 |
</tr> |
| 536 |
<tr> |
| 537 |
<td style="width:35%;text-align: right;" class="first b"><?php _e('Used for' ,'booking');?>:</td> |
| 538 |
<td style="text-align: left; font-weight: 600;" class="bk_spec_font"><?php |
| 539 |
echo wpbc_dashboard_info_get_version_type_sites(); |
| 540 |
?></td> |
| 541 |
</tr> |
| 542 |
<?php } ?> |
| 543 |
<tr> |
| 544 |
<td style="width:35%;text-align: right;" class="first b"><?php _e('Release date' ,'booking');?>:</td> |
| 545 |
<td style="text-align: left; font-weight: 600;" class="bk_spec_font"><?php echo date ("d.m.Y", filemtime(WPBC_FILE)); ?></td> |
| 546 |
</tr> |
| 547 |
</table> |
| 548 |
<div id="wpbc_dashboard_section_current_version_upgrade"> |
| 549 |
|
| 550 |
<table class="bk_table"style="border:none;"> |
| 551 |
<tr> |
| 552 |
<td colspan="2" style="border:none;text-align:center;" class=""><?php |
| 553 |
?><?php wpbc_is_dismissed( 'wpbc_dashboard_section_current_version_upgrade' , array( 'css' => 'padding: 0 0px;' ) ); //FixIn: 8.1.3.10 ?><?php |
| 554 |
if ($version == 'free') { |
| 555 |
?><a class="button-primary button" style="font-weight:600;" target="_blank" href="https://wpbookingcalendar.com/features/"><?php _e('Check Premium Features' ,'booking');?></a><?php |
| 556 |
} elseif ( wpbc_get_ver_sufix() != '' ) { |
| 557 |
?><a class="button-primary button" href="<?php echo wpbc_get_settings_url(); ?>&tab=upgrade"><?php _e('Upgrade' ,'booking');?></a><?php |
| 558 |
} else { |
| 559 |
?><a class="button-primary button" target="_blank" href="https://wpbookingcalendar.com/features/"><?php _e('Explore Premium Features' ,'booking');?></a><?php |
| 560 |
} |
| 561 |
?></td> |
| 562 |
</tr> |
| 563 |
</table> |
| 564 |
</div> |
| 565 |
</div> |
| 566 |
|
| 567 |
<?php |
| 568 |
} |
| 569 |
|
| 570 |
|
| 571 |
/** Dashboard Statistic Section */ |
| 572 |
function wpbc_dashboard_section_statistic( $counter ) { |
| 573 |
//FixIn: 9.3.1.7 |
| 574 |
$bk_admin_url = wpbc_get_bookings_url() . '&wh_approved='; |
| 575 |
?> |
| 576 |
<div id='wpbc_dashboard_section_statistic'> |
| 577 |
<?php |
| 578 |
$is_panel_visible = wpbc_is_dismissed( 'wpbc_dashboard_section_statistic' ); //FixIn: 9.9.0.8 |
| 579 |
if ( $is_panel_visible ) { |
| 580 |
?> |
| 581 |
<div class="wpbc_dashboard_section bk_right"> |
| 582 |
<span class="bk_header"><?php _e('Statistic' ,'booking');?>:</span> |
| 583 |
<table class="bk_table"> |
| 584 |
<tr class="first"> |
| 585 |
<td class="first"> <a href="<?php echo $bk_admin_url,'&wh_what_bookings=new&wh_trash=0&wh_booking_date[]=3&view_mode=vm_listing&overwrite=1'; ?>"><span class=""><?php echo $counter['new']; ?></span></a> </td> |
| 586 |
<td class=""> <a href="<?php echo $bk_admin_url,'&wh_what_bookings=new&wh_trash=0&wh_booking_date[]=3&view_mode=vm_listing&overwrite=1'; ?>"><?php _e('New (unverified) booking(s)' ,'booking');?></a></td> |
| 587 |
</tr> |
| 588 |
<tr> |
| 589 |
<td class="first"> <a href="<?php echo $bk_admin_url,'&wh_approved=0&wh_trash=0&wh_booking_date[]=3&view_mode=vm_listing&overwrite=1'; ?>"><span class=""><?php echo $counter['pending']; ?></span></a></td> |
| 590 |
<td class="pending"><a href="<?php echo $bk_admin_url,'&wh_approved=0&wh_trash=0&wh_booking_date[]=3&view_mode=vm_listing&overwrite=1'; ?>" class=""><?php _e('Pending booking(s)' ,'booking');?></a></td> |
| 591 |
</tr> |
| 592 |
</table> |
| 593 |
</div> |
| 594 |
<div class="wpbc_dashboard_section" > |
| 595 |
<span class="bk_header"><?php _e('Agenda' ,'booking');?>:</span> |
| 596 |
<table class="bk_table"> |
| 597 |
<tr class="first"> |
| 598 |
<td class="first"> <a href="<?php echo $bk_admin_url,'&wh_trash=0&wh_modification_date[]=1&wh_booking_date[]=3&view_mode=vm_listing&overwrite=1'; ?>"><span><?php echo $counter['was_made_today']; ?></span></a> </td> |
| 599 |
<td class="new-bookings"><a href="<?php echo $bk_admin_url,'&wh_trash=0&wh_modification_date[]=1&wh_booking_date[]=3&view_mode=vm_listing&overwrite=1'; ?>" class=""><?php _e('New booking(s) made today' ,'booking');?></a> </td> |
| 600 |
</tr> |
| 601 |
<tr> |
| 602 |
<td class="first"> <a href="<?php echo $bk_admin_url,'&wh_trash=0&wh_booking_date[]=1&view_mode=vm_listing&overwrite=1'; ?>"><span><?php echo $counter['booking_today']; ?></span></a> </td> |
| 603 |
<td class="actual-bookings"> <a href="<?php echo $bk_admin_url,'&wh_trash=0&wh_booking_date[]=1&view_mode=vm_listing&overwrite=1'; ?>" class=""><?php _e('Bookings for today' ,'booking');?></a> </td> |
| 604 |
</tr> |
| 605 |
</table> |
| 606 |
</div> |
| 607 |
<?php } ?> |
| 608 |
</div> |
| 609 |
<?php |
| 610 |
} |
| 611 |
|
| 612 |
|
| 613 |
// --------------------------------------------------------------------------------------------------------------------- |
| 614 |
// 9.8 |
| 615 |
// --------------------------------------------------------------------------------------------------------------------- |
| 616 |
|
| 617 |
/** Get Flex Dashboard */ |
| 618 |
function wpbc_get_flex_dashboard_info() { |
| 619 |
|
| 620 |
ob_start(); |
| 621 |
|
| 622 |
wpbc_flex_dashboard_show(); |
| 623 |
|
| 624 |
return ob_get_clean(); |
| 625 |
} |
| 626 |
|
| 627 |
|
| 628 |
/** Show Flex Dashboard Conatiner */ |
| 629 |
function wpbc_flex_dashboard_show(){ |
| 630 |
|
| 631 |
//FixIn: 9.9.0.40 |
| 632 |
if ( |
| 633 |
( ! empty( $GLOBALS['pagenow'] ) ) |
| 634 |
&& ( is_admin() ) |
| 635 |
&& ( |
| 636 |
( 'index.php' === $GLOBALS['pagenow'] ) |
| 637 |
|| ( |
| 638 |
( 'admin.php' === $GLOBALS['pagenow'] ) |
| 639 |
&& ( ! empty( $_GET['page'] ) ) |
| 640 |
&& ( 'wpbc-settings' === $_GET['page'] ) |
| 641 |
&& ( ( ! isset( $_GET['tab'] ) ) || ( 'general' === $_GET['tab'] ) ) |
| 642 |
) |
| 643 |
) |
| 644 |
) { |
| 645 |
|
| 646 |
} else { |
| 647 |
return; |
| 648 |
} |
| 649 |
|
| 650 |
|
| 651 |
$is_panel_visible = wpbc_is_dismissed_panel_visible( 'wpbc_dashboard_section_statistic' ); //FixIn: 9.9.0.8 |
| 652 |
|
| 653 |
$counter = ( $is_panel_visible ) ? wpbc_db_dashboard_get_bookings_count_arr() : array(); |
| 654 |
|
| 655 |
wpbc_flex_dashboard_widget_css(); |
| 656 |
|
| 657 |
?><div class="wpbc_flex_dashboard_container" ><?php |
| 658 |
|
| 659 |
wpbc_flex_dashboard_section_statistic( $counter ); |
| 660 |
|
| 661 |
?></div><?php |
| 662 |
|
| 663 |
} |
| 664 |
|
| 665 |
|
| 666 |
/** |
| 667 |
* CSS for Flex Dashboard |
| 668 |
* @return void |
| 669 |
*/ |
| 670 |
function wpbc_flex_dashboard_widget_css(){ |
| 671 |
|
| 672 |
?><style type="text/css"> |
| 673 |
.wpbc_flex_dashboard_container{ |
| 674 |
display: flex; |
| 675 |
flex-flow: row wrap; |
| 676 |
justify-content: space-between; |
| 677 |
align-items: center; |
| 678 |
} |
| 679 |
.wpbc_flex_dashboard_container .wpbc_flex_dashboard_item{ |
| 680 |
flex: 1 1 auto; |
| 681 |
display: flex; |
| 682 |
flex-flow: row wrap; |
| 683 |
justify-content: center; |
| 684 |
align-items: center; |
| 685 |
margin: 0 10px; |
| 686 |
line-height: 2.1em; |
| 687 |
} |
| 688 |
.wpbc_flex_dashboard_container .wpbc_flex_dashboard_item:first-child{ |
| 689 |
margin-left: 0; |
| 690 |
} |
| 691 |
.wpbc_flex_dashboard_container .wpbc_flex_dashboard_item:last-child{ |
| 692 |
margin-right:0; |
| 693 |
justify-content: flex-end; |
| 694 |
} |
| 695 |
.wpbc_flex_dashboard_container .wpbc_flex_dashboard_item .wpbc_flex_dashboard_item_number, |
| 696 |
.wpbc_flex_dashboard_container .wpbc_flex_dashboard_item .wpbc_flex_dashboard_item_text{ |
| 697 |
flex: 0 1 auto; |
| 698 |
padding: 0 5px; |
| 699 |
} |
| 700 |
.wpbc_flex_dashboard_container .wpbc_flex_dashboard_item .wpbc_flex_dashboard_item_number a, |
| 701 |
.wpbc_flex_dashboard_container .wpbc_flex_dashboard_item .wpbc_flex_dashboard_item_text a{ |
| 702 |
text-decoration: none; |
| 703 |
outline:0; |
| 704 |
} |
| 705 |
.wpbc_flex_dashboard_container .wpbc_flex_dashboard_item .wpbc_flex_dashboard_item_number span{ |
| 706 |
font-size: 18px; |
| 707 |
font-family: Georgia,"Times New Roman","Bitstream Charter",Times,serif; |
| 708 |
} |
| 709 |
/* Colors */ |
| 710 |
.wpbc_flex_dashboard_container .wpbc_flex_dashboard_item .wpbc_flex_dashboard_item_text_new *{ |
| 711 |
/*color: #135e96;*/ |
| 712 |
} |
| 713 |
.wpbc_flex_dashboard_container .wpbc_flex_dashboard_item .wpbc_flex_dashboard_item_text_pending *{ |
| 714 |
color: #E66F00; |
| 715 |
} |
| 716 |
.wpbc_flex_dashboard_container .wpbc_flex_dashboard_item .wpbc_flex_dashboard_item_text_was_made_today *{ |
| 717 |
color: red; |
| 718 |
} |
| 719 |
.wpbc_flex_dashboard_container .wpbc_flex_dashboard_item .wpbc_flex_dashboard_item_text_made_for_today *{ |
| 720 |
color: green; |
| 721 |
} |
| 722 |
.wpbc_flex_dashboard_container .wpbc_flex_dashboard_item .wpbc_flex_dashboard_item_number.wpbc_flex_dashboard_item_version_number * { |
| 723 |
color: #2b6900; |
| 724 |
color: #7812bd; |
| 725 |
font-size: 11px; |
| 726 |
text-shadow: none; |
| 727 |
} |
| 728 |
.wpbc_flex_dashboard_container .wpbc_flex_dashboard_item .wpbc_flex_dashboard_item_version_type * { |
| 729 |
color: #8f8f8f; |
| 730 |
font-size: 9px; |
| 731 |
text-shadow: none; |
| 732 |
} |
| 733 |
</style><?php |
| 734 |
} |
| 735 |
|
| 736 |
|
| 737 |
/** |
| 738 |
* Flex Dashboard Items |
| 739 |
* |
| 740 |
* @param $counter |
| 741 |
* |
| 742 |
* @return void |
| 743 |
*/ |
| 744 |
function wpbc_flex_dashboard_section_statistic( $counter ){ |
| 745 |
|
| 746 |
$bk_admin_url = wpbc_get_bookings_url();// . '&wh_approved='; |
| 747 |
|
| 748 |
if ( ! empty( $counter ) ) { |
| 749 |
|
| 750 |
// Was made today ----------------------------------------------------------------------------------------------------- |
| 751 |
?> |
| 752 |
<div class="wpbc_flex_dashboard_item"> |
| 753 |
<div class="wpbc_flex_dashboard_item_number"> |
| 754 |
<a href="<?php echo $bk_admin_url,'&wh_trash=0&wh_modification_date[]=1&wh_booking_date[]=3&view_mode=vm_listing&overwrite=1'; ?>"> |
| 755 |
<span><?php echo $counter['was_made_today']; ?></span> |
| 756 |
</a> |
| 757 |
</div> |
| 758 |
<div class="wpbc_flex_dashboard_item_text wpbc_flex_dashboard_item_text_was_made_today"> |
| 759 |
<a href="<?php echo $bk_admin_url,'&wh_trash=0&wh_modification_date[]=1&wh_booking_date[]=3&view_mode=vm_listing&overwrite=1'; ?>" class=""> |
| 760 |
<?php _e('New booking(s) made today' ,'booking');?> |
| 761 |
</a> |
| 762 |
</div> |
| 763 |
</div> |
| 764 |
<?php |
| 765 |
|
| 766 |
// For today --------------------------------------------------------------------------------------------------- |
| 767 |
?> |
| 768 |
<div class="wpbc_flex_dashboard_item"> |
| 769 |
<div class="wpbc_flex_dashboard_item_number"> |
| 770 |
<a href="<?php echo $bk_admin_url,'&wh_trash=0&wh_booking_date[]=1&view_mode=vm_listing&overwrite=1'; ?>"> |
| 771 |
<span><?php echo $counter['booking_today']; ?></span> |
| 772 |
</a> |
| 773 |
</div> |
| 774 |
<div class="wpbc_flex_dashboard_item_text wpbc_flex_dashboard_item_text_made_for_today"> |
| 775 |
<a href="<?php echo $bk_admin_url,'&wh_trash=0&wh_booking_date[]=1&view_mode=vm_listing&overwrite=1'; ?>" class=""> |
| 776 |
<?php _e('Booking(s) for today' ,'booking');?> |
| 777 |
</a> |
| 778 |
</div> |
| 779 |
</div> |
| 780 |
<?php |
| 781 |
|
| 782 |
// Pending ----------------------------------------------------------------------------------------------------- |
| 783 |
?> |
| 784 |
<div class="wpbc_flex_dashboard_item"> |
| 785 |
<div class="wpbc_flex_dashboard_item_number"> |
| 786 |
<a href="<?php echo $bk_admin_url,'&wh_approved=0&wh_trash=0&wh_booking_date[]=3&view_mode=vm_listing&overwrite=1'; ?>"> |
| 787 |
<span class=""><?php echo $counter['pending']; ?></span> |
| 788 |
</a> |
| 789 |
</div> |
| 790 |
<div class="wpbc_flex_dashboard_item_text wpbc_flex_dashboard_item_text_pending"> |
| 791 |
<a href="<?php echo $bk_admin_url,'&wh_approved=0&wh_trash=0&wh_booking_date[]=3&view_mode=vm_listing&overwrite=1'; ?>" class=""> |
| 792 |
<?php _e('Pending booking(s)' ,'booking');?> |
| 793 |
</a> |
| 794 |
</div> |
| 795 |
</div> |
| 796 |
<?php |
| 797 |
|
| 798 |
|
| 799 |
// New --------------------------------------------------------------------------------------------------------- |
| 800 |
?> |
| 801 |
<div class="wpbc_flex_dashboard_item"> |
| 802 |
<div class="wpbc_flex_dashboard_item_number"> |
| 803 |
<a href="<?php echo $bk_admin_url,'&wh_what_bookings=new&wh_trash=0&wh_booking_date[]=3&view_mode=vm_listing&overwrite=1'; ?>"> |
| 804 |
<span class=""><?php echo $counter['new']; ?></span> |
| 805 |
</a> |
| 806 |
</div> |
| 807 |
<div class="wpbc_flex_dashboard_item_text wpbc_flex_dashboard_item_text_new"> |
| 808 |
<a href="<?php echo $bk_admin_url, '&wh_what_bookings=new&wh_trash=0&wh_booking_date[]=3&view_mode=vm_listing&overwrite=1'; ?>"> |
| 809 |
<?php _e( 'New (unverified) booking(s)', 'booking' ); ?> |
| 810 |
</a> |
| 811 |
</div> |
| 812 |
</div> |
| 813 |
<?php |
| 814 |
} |
| 815 |
|
| 816 |
// Version --------------------------------------------------------------------------------------------------------- |
| 817 |
?> |
| 818 |
<div class="wpbc_flex_dashboard_item"> |
| 819 |
<div class="wpbc_flex_dashboard_item_text wpbc_flex_dashboard_item_version_type"> |
| 820 |
<a href="https://wpbookingcalendar.com/faq/difference-single-developer-multi-site/#<?php echo wpbc_get_slug_format( trim( wpbc_dashboard_info_get_version_type_readable() . '_' . wpbc_dashboard_info_get_version_type_sites() . '_' . WP_BK_VERSION_NUM ) ); ?>"> |
| 821 |
<?php |
| 822 |
if ( class_exists( 'wpdev_bk_personal' ) ) { |
| 823 |
echo wpbc_dashboard_info_get_version_type_readable(); |
| 824 |
} |
| 825 |
if ( wpbc_is_this_demo() ) { |
| 826 |
echo ' (Demo)'; |
| 827 |
} else { |
| 828 |
if ( 'free' != wpbc_dashboard_info_get_version_type() ) { |
| 829 |
echo ' (' . __( 'for', 'booking' ) . ' ' . trim( wpbc_dashboard_info_get_version_type_sites() ) . ')'; |
| 830 |
} |
| 831 |
} |
| 832 |
?> |
| 833 |
</a> |
| 834 |
</div> |
| 835 |
<div class="wpbc_flex_dashboard_item_number wpbc_flex_dashboard_item_version_number"> |
| 836 |
<a href="https://wpbookingcalendar.com/changelog/#<?php echo wpbc_get_slug_format( trim( wpbc_dashboard_info_get_version_type_readable() . '_' . wpbc_dashboard_info_get_version_type_sites() . '_' . WP_BK_VERSION_NUM ) ); ?>"> |
| 837 |
<span class=""><?php echo WP_BK_VERSION_NUM; ?></span> |
| 838 |
</a> |
| 839 |
</div> |
| 840 |
</div> |
| 841 |
<?php |
| 842 |
|
| 843 |
} |