$my_resources = array(); if ( class_exists( 'wpdev_bk_multiuser' ) ) { $is_superadmin = apply_bk_filter( 'multiuser_is_user_can_be_here', true, 'only_super_admin' ); if ( ! $is_superadmin ) { $bk_ids = apply_bk_filter( 'get_bk_resources_of_user', false ); if ( $bk_ids !== false ) { foreach ( $bk_ids as $bk_id ) { $my_resources[] = $bk_id->ID; } } } } $my_resources = implode( ',', $my_resources ); global $wpdb; $trash_bookings = ' bk.trash != 1 '; //FixIn: 6.1.1.10 - check also below usage of {$trash_bookings} $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 FROM {$wpdb->prefix}bookingdates as dt INNER JOIN {$wpdb->prefix}booking as bk ON bk.booking_id = dt.booking_id " . " WHERE {$trash_bookings} " ; if ($my_resources!='') $sql_req .= " AND bk.booking_type IN ({$my_resources}) "; $sql_req .= "ORDER BY dt.booking_date" ; // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.NotPrepared, PluginCheck.Security.DirectDB.UnescapedDBParameter $sql_results = $wpdb->get_results( $sql_req ); // // $bk_array = array(); if ( ! empty( $sql_results ) ) foreach ( $sql_results as $v ) { if ( !isset( $bk_array[$v->id] ) ) $bk_array[$v->id] = array( 'dates' => array() , 'check_in_date' => array() , 'check_out_date' => array() , 'bk_today' => 0 , 'm_today' => 0 ); $bk_array[$v->id]['id'] = $v->id; $bk_array[$v->id]['approved'] = $v->approved; $bk_array[$v->id]['dates'][] = $v->booking_date; if ( intval( substr( $v->booking_date, -1 ) ) == 1 ) { $bk_array[$v->id]['check_in_date'][] = $v->booking_date; } if ( intval( substr( $v->booking_date, -1 ) ) == 2 ) { $bk_array[$v->id]['check_out_date'][] = $v->booking_date; } $bk_array[$v->id]['m_date'] = $v->m_date; // Modification Booking date $bk_array[$v->id]['new'] = $v->new; if ( wpbc_is_today_date( $v->booking_date ) ) { $bk_array[ $v->id ]['bk_today'] = 1; } if ( wpbc_is_today_date( $v->m_date ) ) { $bk_array[ $v->id ]['m_today'] = 1; } } $counter = array( 'all' => 0 , 'new' => 0 , 'pending' => 0 , 'approved' => 0 , 'booking_today' => 0 , 'was_made_today' => 0 , 'check_in_today' => 0 , 'check_out_today' => 0 , 'check_in_tomorrow' => 0 , 'check_out_tomorrow' => 0 ); foreach ( $bk_array as $k => $v ) { $counter['all']++; if ( $v['new'] ) { $counter['new'] ++; } if ( $v['m_today'] ) { $counter['was_made_today'] ++; } if ( $v['bk_today'] ) { $counter['booking_today'] ++; } if ( $v['approved'] ) { $counter['approved'] ++; } else { $counter['pending'] ++; } // Check in if ( ! empty( $v['check_in_date'] ) ) { foreach ( $v['check_in_date'] as $check_in ) { if ( wpbc_is_today_date( $check_in ) ) { $counter['check_in_today']++; } if ( wpbc_is_tomorrow_date( $check_in ) ) { $counter['check_in_tomorrow']++; } } } else { $check_in = $v['dates'][0]; if ( wpbc_is_today_date( $check_in ) ) { $counter['check_in_today']++; } if ( wpbc_is_tomorrow_date( $check_in ) ) { $counter['check_in_tomorrow']++; } } // Check out if ( ! empty( $v['check_out_date'] ) ) { foreach ( $v['check_out_date'] as $check_out ) { if ( wpbc_is_today_date( $check_out ) ) { $counter['check_out_today']++; } if ( wpbc_is_tomorrow_date( $check_out ) ) { $counter['check_out_tomorrow']++; } } } else { $check_out = $v['dates'][ ( count( $v['dates'] ) - 1 ) ]; if ( wpbc_is_today_date( $check_out ) ) { $counter['check_out_today']++; } if ( wpbc_is_tomorrow_date( $check_out ) ) { $counter['check_out_tomorrow']++; } } } // return $counter; } //////////////////////////////////////////////////////////////////////////////// // D a s h b o a r d W i d g e t //////////////////////////////////////////////////////////////////////////////// /** Setup Widget for Dashboard */ function wpbc_dashboard_widget_setup(){ // Check, if we have permission to show Widget /////////////////////////// $is_user_activated = apply_bk_filter('multiuser_is_current_user_active', true ); // FixIn: 6.0.1.17. if ( ! $is_user_activated ) return false; $user_role = get_bk_option( 'booking_user_role_booking' ); if ( ! wpbc_is_current_user_have_this_role( $user_role ) ) return false; // Add Booking Calendar Widget to Dashboard /////////////////////////////// $bk_dashboard_widget_id = 'booking_dashboard_widget'; wp_add_dashboard_widget( $bk_dashboard_widget_id, sprintf( __( 'Booking Calendar', 'booking' ) ), 'wpbc_dashboard_widget_show', null ); // Sort Dashboard. Add Booking Calendar widget to top /////////////////////// global $wp_meta_boxes; $normal_dashboard = $wp_meta_boxes['dashboard']['normal']['core']; if ( isset( $normal_dashboard[$bk_dashboard_widget_id] ) ) { // Backup and delete our new dashbaord widget from the end of the array $example_widget_backup = array( $bk_dashboard_widget_id => $normal_dashboard[$bk_dashboard_widget_id] ); unset( $normal_dashboard[$bk_dashboard_widget_id] ); } else $example_widget_backup = array(); // Sometimes, some other plugins can modify this item, so its can be not a array if ( is_array( $normal_dashboard ) ) { // Merge the two arrays together so our widget is at the beginning if ( is_array( $normal_dashboard ) ) $sorted_dashboard = array_merge( $example_widget_backup, $normal_dashboard ); else $sorted_dashboard = $example_widget_backup; // Save the sorted array back into the original metaboxes $wp_meta_boxes['dashboard']['normal']['core'] = $sorted_dashboard; } } add_action( 'wp_dashboard_setup', 'wpbc_dashboard_widget_setup' ); /** Show Booking Dashboard Widget content */ function wpbc_dashboard_widget_show() { $is_panel_visible = wpbc_is_dismissed_panel_visible( 'wpbc_dashboard_section_statistic' ); // FixIn: 9.9.0.8. $counter = $is_panel_visible ? wpbc_db_dashboard_get_bookings_count_arr() : array(); wpbc_dashboard_widget_css(); ?>
(free):
(premium):
: 'padding: 0 20px;' ) ); //FixIn: 8.1.3.10 ?>
Booking Calendar News:

Loading...
" . esc_attr( WP_BK_VERSION_NUM ) . ""; } return $show_version; } else { return WPDEV_BK_VERSION; } } /** Dashboard Version Section */ function wpbc_dashboard_section_version() { $version = wpbc_dashboard_info_get_version_type(); /* Disbale hidded notice about Upgrade to higher version in paid versions // FixIn: 8.0.1.6. if ( ( $version !== 'free' ) && ( class_exists('wpdev_bk_multiuser') === false ) ) { ?>

:

Check additional advanced functionality, which exist in higher versions and can be interesting for you here »

:
:
:
:
:
'padding: 0 0px;' ) ); //FixIn: 8.1.3.10 ?>
:
: