Example #1
0
function get_booking_info_4_tooltip($bk_id, $bookings, $booking_types, $title_in_day = '', $title = '', $title_hint = '')
{
    $user = wp_get_current_user();
    $user_bk_id = $user->ID;
    //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    // Gathering data  about the booking to  show in the calendar !!! ////////////////////////////////////////////////////
    //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    // Get it from the option settings
    $what_show_in_day_template = get_bk_option('booking_default_title_in_day_for_calendar_view_mode');
    // '<span style="font-size:07px;">[id]</span>:[name]';
    if ($title != '') {
        $title .= ' / ';
    }
    // Other Booking in the same day
    $title .= $bk_id;
    if ($title_in_day != '') {
        $title_in_day .= ',';
    }
    // Other Booking in the same day
    //$title_in_day .=  $bk_id ;
    if (function_exists('get_title_for_showing_in_day')) {
        $title_in_day .= get_title_for_showing_in_day($bk_id, $bookings, $what_show_in_day_template);
    } else {
        $title_in_day .= $bk_id . ':' . $bookings[$bk_id]->form_data['_all_fields_']['name'];
    }
    if ($title_hint != '') {
        $title_hint .= ' <hr style="margin:10px 5px;" /> ';
    }
    // Other Booking in the same day
    $title_hint .= '<div class=\'booking-listing-collumn\' >';
    if (function_exists('get_booking_title')) {
        if (isset($booking_types[$bookings[$bk_id]->booking_type])) {
            $bk_title = $booking_types[$bookings[$bk_id]->booking_type]->title;
        } else {
            $bk_title = get_booking_title($bookings[$bk_id]->booking_type);
        }
        $bk_title = '<span class=\'label label-resource label-info\'>' . $bk_title . '</span>';
    } else {
        $bk_title = '';
    }
    $title_hint .= '<span class=\'field-id\'>' . $bk_id . '</span>' . ' ' . $bk_title;
    if (class_exists('wpdev_bk_biz_s')) {
        $title_hint .= '<div style=\'float:right;\'>';
        if (function_exists('wpdev_bk_get_payment_status_simple')) {
            $pay_status = wpdev_bk_get_payment_status_simple($bookings[$bk_id]->pay_status);
            $pay_status = '<span class=\'label label-payment-status payment-label-unknown\'><span style=\'font-size:07px;\'>' . __('Payment', 'wpdev-booking') . '</span> ' . $pay_status . '</span>';
        } else {
            $pay_status = '';
        }
        $title_hint .= ' ' . $pay_status;
        $currency = apply_bk_filter('get_currency_info');
        $show_cost_value = wpdev_bk_cost_number_format($bookings[$bk_id]->cost);
        $title_hint .= ' <div class="cost-fields-group" style=\'float:right; margin:2px;\'>' . $currency . ' ' . $show_cost_value . '</div>';
        $title_hint .= '</div>';
    }
    $title_hint .= '<div>' . $bookings[$bk_id]->form_show . '</div>';
    //$bookings[$bk_id]->form_data['name'].' ' . $bookings[$bk_id]->form_data['secondname'] ;
    //$title_hint .= ' '. $bookings[$bk_id]->remark;
    //BL
    $bk_dates_short_id = array();
    if (count($bookings[$bk_id]->dates) > 0) {
        $bk_dates_short_id = isset($bookings[$bk_id]->dates_short_id) ? $bookings[$bk_id]->dates_short_id : array();
    }
    // Array ([0] => [1] => .... [4] => 6... [11] => [12] => 8 )
    $is_approved = 0;
    if (count($bookings[$bk_id]->dates) > 0) {
        $is_approved = $bookings[$bk_id]->dates[0]->approved;
    }
    $short_dates_content = wpdevbk_get_str_from_dates_short($bookings[$bk_id]->dates_short, $is_approved, $bk_dates_short_id, $booking_types);
    $short_dates_content = str_replace('"', "'", $short_dates_content);
    $title_hint .= '<div style=\'margin-top:5px;\'>' . $short_dates_content . '</div>';
    // $reload_time = 2000;
    // setTimeout(function ( ) {location.reload(true);} ,'.$reload_time.');
    /**
       $title_hint .= '<div style=\'text-align:right;\'>';
       if ( class_exists('wpdev_bk_personal') ) {
            $bk_url_add         = 'admin.php?page=' . WPDEV_BK_PLUGIN_DIRNAME . '/'. WPDEV_BK_PLUGIN_FILENAME . 'wpdev-booking-reservation' ;        
            $bk_hash            = (isset($bookings[$bk_id]->hash))?$bookings[$bk_id]->hash:'';         
            $bk_booking_type    = $bookings[$bk_id]->booking_type;
            $edit_booking_url = $bk_url_add . '&booking_type='.$bk_booking_type.'&booking_hash='.$bk_hash.'&parent_res=1' ; 
            $title_hint .= '<a style=\'margin:-60px 20px 0 2px;position:absolute;right:0px;\' href=\''.$edit_booking_url .'\' onclick=\'\' ><i class=\'icon-edit\'></i><!--img src=\'' . WPDEV_BK_PLUGIN_URL .'/img/edit_type.png\' style=\'width:12px; height:13px;\'--></a>';
       }
       $title_hint .= '<a style=\'margin:-40px 20px 0 0;position:absolute;right:0px;\' href=\'javascript:;\' onclick=\'javascript:approve_unapprove_booking('. $bk_id.',1, '. $user_bk_id .', &quot;'. getBookingLocale() .'&quot; , 1   );\' ><i class=\'icon-ok-circle\'></i><!--img src=\'' . WPDEV_BK_PLUGIN_URL .'/img/accept-24x24.gif\' style=\'width:14px; height:14px;\'--></a>';   
       $title_hint .= '<a style=\'margin:-22px 20px 0 0;position:absolute;right:0px;\' href=\'javascript:;\' onclick=\'javascript:approve_unapprove_booking('. $bk_id.',0, '. $user_bk_id .', &quot;'. getBookingLocale() .'&quot; , 1   );\' ><i class=\'icon-ban-circle\'></i><!--img src=\'' . WPDEV_BK_PLUGIN_URL .'/img/remove-16x16.png\' style=\'margin:0px 5px;width:15px; height:15px;\'--></a>';
       $title_hint .= '<a href=\'javascript:;\' onclick=\'javascript:delete_booking('. $bk_id.', '. $user_bk_id .', &quot;'. getBookingLocale() .'&quot; , 1   );\' ><i class=\'icon-trash\'></i><!--img src=\'' . WPDEV_BK_PLUGIN_URL .'/img/delete_type.png\' style=\'width:13px; height:13px;\'--></a>';
       $title_hint .= '</div>';
       /**/
    $is_approved = 0;
    if (!empty($bookings[$bk_id]->dates)) {
        $is_approved = $bookings[$bk_id]->dates[0]->approved;
    }
    $title .= '<div class=\'timeline_info_bk_actionsbar_' . $bk_id . '\'  style=\'display: inline;
    line-height: 1em;
    padding: 10px;
    vertical-align: text-top;\'>';
    if (class_exists('wpdev_bk_personal')) {
        $bk_url_add = 'admin.php?page=' . WPDEV_BK_PLUGIN_DIRNAME . '/' . WPDEV_BK_PLUGIN_FILENAME . 'wpdev-booking-reservation';
        $bk_hash = isset($bookings[$bk_id]->hash) ? $bookings[$bk_id]->hash : '';
        $bk_booking_type = $bookings[$bk_id]->booking_type;
        $edit_booking_url = $bk_url_add . '&booking_type=' . $bk_booking_type . '&booking_hash=' . $bk_hash . '&parent_res=1';
        $title .= '<a class=\'button button-secondary\' style=\'margin-right:5px;\' href=\'' . $edit_booking_url . '\' onclick=\'\' ><i class=\'icon-edit\'></i></a>';
    }
    $title .= '<a class=\'button button-secondary approve_bk_link ' . ($is_approved ? 'hidden_items' : '') . '\' style=\'margin-right:5px;\' href=\'javascript:;\' onclick=\'javascript:approve_unapprove_booking(' . $bk_id . ',1, ' . $user_bk_id . ', &quot;' . getBookingLocale() . '&quot; , 1   );\' ><i class=\'icon-ok-circle\'></i></a>';
    $title .= '<a class=\'button button-secondary pending_bk_link ' . ($is_approved ? '' : 'hidden_items') . '\' style=\'margin-right:5px;\' href=\'javascript:;\' onclick=\'javascript:approve_unapprove_booking(' . $bk_id . ',0, ' . $user_bk_id . ', &quot;' . getBookingLocale() . '&quot; , 1   );\' ><i class=\'icon-ban-circle\'></i></a>';
    $title .= '<a class=\'button button-secondary\' style=\'margin-right:5px;\' href=\'javascript:;\' onclick=\'javascript:delete_booking(' . $bk_id . ', ' . $user_bk_id . ', &quot;' . getBookingLocale() . '&quot; , 1   );\' ><i class=\'icon-trash\'></i></a>';
    $title .= '</div>';
    //cell_bk_id_10  time_section_in_day timeslots_in_this_day1 time_hour0  time_in_days_num_30 time_booked_in_day   approved
    /**
       $title_hint .= '<div style=\'text-align:right;\'>';
       $title_hint .= '<a style=\'margin:-40px 0 0 0;position:absolute;\' href=\'javascript:;\' onclick=\'javascript:approve_unapprove_booking('. $bk_id.',1, '. $user_bk_id .', &quot;'. getBookingLocale() .'&quot; , 1   );setTimeout(function ( ) {location.reload(true);} ,'.$reload_time.');\' ><img src=\'' . WPDEV_BK_PLUGIN_URL .'/img/accept-24x24.gif\' style=\'width:14px; height:14px;\'></a>';   
    //   $title_hint .= ' <a href="javascript:void(0)"  class="tooltip_bottom approve_bk_link  '. ( ($is_approved)?' hidden_items ':'') .' "
    //       onclick="javascript:approve_unapprove_booking('. $bk_id.',1, '. $user_bk_id. ', \''. getBookingLocale() .'\' , 1  );"
    //        ><img src="' . WPDEV_BK_PLUGIN_URL .'/img/accept-24x24.gif" style="width:14px; height:14px;"></a>';
    //
       $title_hint .= '<a style=\'margin:-22px 0 0 -6px;position:absolute;\' href=\'javascript:;\' onclick=\'javascript:approve_unapprove_booking('. $bk_id.',0, '. $user_bk_id .', &quot;'. getBookingLocale() .'&quot; , 1   );setTimeout(function ( ) {location.reload(true);} ,'.$reload_time.');\' ><img src=\'' . WPDEV_BK_PLUGIN_URL .'/img/remove-16x16.png\' style=\'margin:0px 5px;width:15px; height:15px;\'></a>';
    //   $title_hint .= '<a href="javascript:void(0)"  class="tooltip_bottom pending_bk_link  '. ( (! $is_approved)?  ' hidden_items ':'' ) .' "
    //       onclick="javascript:approve_unapprove_booking('. $bk_id .',0, '. $user_bk_id .', \''. getBookingLocale() .'\' , 1  );"
    //        ><img src="' . WPDEV_BK_PLUGIN_URL .'/img/remove-16x16.png" style="width:15px; height:15px;"></a>';
    //    //if ( bk_are_you_sure(\''. esc_js(__('Do you really want to set booking as pending ?', 'wpdev-booking')) .'\') ) 
       
       $title_hint .= '<a href=\'javascript:;\' onclick=\'javascript:delete_booking('. $bk_id.', '. $user_bk_id .', &quot;'. getBookingLocale() .'&quot; , 1   );setTimeout(function ( ) {location.reload(true);} ,'.$reload_time.');\' ><img src=\'' . WPDEV_BK_PLUGIN_URL .'/img/delete_type.png\' style=\'width:13px; height:13px;\'></a>';
       //if ( bk_are_you_sure(\''. esc_js(__('Do you really want to delete this booking ?', 'wpdev-booking')) .'\') ) 
       $title_hint .= '</div>';
       /**/
    $title_hint .= '</div>';
    //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    return array($title_in_day, $title, $title_hint, $is_approved);
}
function get_booking_info_4_tooltip($bk_id, $bookings, $booking_types, $title_in_day = '', $title = '', $title_hint = '')
{
    $user = wp_get_current_user();
    $user_bk_id = $user->ID;
    //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    // Gathering data  about the booking to  show in the calendar !!! ////////////////////////////////////////////////////
    //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    // Get it from the option settings
    $what_show_in_day_template = get_bk_option('booking_default_title_in_day_for_calendar_view_mode');
    // '<span style="font-size:07px;">[id]</span>:[name]';
    if ($title != '') {
        $title .= ' / ';
    }
    // Other Booking in the same day
    $title .= $bk_id;
    if ($title_in_day != '') {
        $title_in_day .= ',';
    }
    // Other Booking in the same day
    //$title_in_day .=  $bk_id ;
    if (function_exists('get_title_for_showing_in_day')) {
        $title_in_day .= get_title_for_showing_in_day($bk_id, $bookings, $what_show_in_day_template);
    } else {
        $title_in_day .= $bk_id . ':' . $bookings[$bk_id]->form_data['_all_fields_']['name'];
    }
    if ($title_hint != '') {
        $title_hint .= ' <hr style="margin:10px 5px;" /> ';
    }
    // Other Booking in the same day
    $title_hint .= '<div class=\'booking-listing-collumn\' >';
    if (function_exists('get_booking_title')) {
        if (isset($booking_types[$bookings[$bk_id]->booking_type])) {
            $bk_title = $booking_types[$bookings[$bk_id]->booking_type]->title;
        } else {
            $bk_title = get_booking_title($bookings[$bk_id]->booking_type);
        }
        $bk_title = '<span class=\'label label-resource label-info\'>' . $bk_title . '</span>';
    } else {
        $bk_title = '';
    }
    $title_hint .= '<span class=\'field-id\'>' . $bk_id . '</span>' . ' ' . $bk_title;
    if (class_exists('wpdev_bk_biz_s')) {
        $title_hint .= '<div style=\'float:right;\'>';
        if (function_exists('wpdev_bk_get_payment_status_simple')) {
            $pay_status = wpdev_bk_get_payment_status_simple($bookings[$bk_id]->pay_status);
            $pay_status = '<span class=\'label label-payment-status payment-label-unknown\'><span style=\'font-size:07px;\'>' . __('Payment', 'booking') . '</span> ' . $pay_status . '</span>';
        } else {
            $pay_status = '';
        }
        $title_hint .= ' ' . $pay_status;
        $currency = apply_bk_filter('get_currency_info');
        $show_cost_value = wpdev_bk_cost_number_format($bookings[$bk_id]->cost);
        $title_hint .= ' <div class="cost-fields-group" style=\'float:right; margin:2px;\'>' . $currency . ' ' . $show_cost_value . '</div>';
        $title_hint .= '</div>';
    }
    $title_hint .= '<div>' . $bookings[$bk_id]->form_show . '</div>';
    //$bookings[$bk_id]->form_data['name'].' ' . $bookings[$bk_id]->form_data['secondname'] ;
    //$title_hint .= ' '. $bookings[$bk_id]->remark;
    //BL
    $bk_dates_short_id = array();
    if (count($bookings[$bk_id]->dates) > 0) {
        $bk_dates_short_id = isset($bookings[$bk_id]->dates_short_id) ? $bookings[$bk_id]->dates_short_id : array();
    }
    // Array ([0] => [1] => .... [4] => 6... [11] => [12] => 8 )
    $is_approved = 0;
    if (count($bookings[$bk_id]->dates) > 0) {
        $is_approved = $bookings[$bk_id]->dates[0]->approved;
    }
    $short_dates_content = wpdevbk_get_str_from_dates_short($bookings[$bk_id]->dates_short, $is_approved, $bk_dates_short_id, $booking_types);
    $short_dates_content = str_replace('"', "'", $short_dates_content);
    $title_hint .= '<div style=\'margin-top:5px;\'>' . $short_dates_content . '</div>';
    $is_approved = 0;
    if (!empty($bookings[$bk_id]->dates)) {
        $is_approved = $bookings[$bk_id]->dates[0]->approved;
    }
    $title .= '<div class=\'timeline_info_bk_actionsbar_' . $bk_id . '\'  style=\'display: inline;
    line-height: 1em;
    padding: 10px;
    vertical-align: text-top;\'>';
    $is_can = true;
    //current_user_can( 'edit_posts' );
    if ($is_can) {
        if (class_exists('wpdev_bk_personal')) {
            $bk_url_add = 'admin.php?page=' . WPDEV_BK_PLUGIN_DIRNAME . '/' . WPDEV_BK_PLUGIN_FILENAME . 'wpdev-booking-reservation';
            $bk_hash = isset($bookings[$bk_id]->hash) ? $bookings[$bk_id]->hash : '';
            $bk_booking_type = $bookings[$bk_id]->booking_type;
            $edit_booking_url = $bk_url_add . '&booking_type=' . $bk_booking_type . '&booking_hash=' . $bk_hash . '&parent_res=1';
            $title .= '<a class=\'button button-secondary\' style=\'margin-right:5px;\' href=\'' . $edit_booking_url . '\' onclick=\'\' ><i class=\'icon-edit\'></i></a>';
        }
        $title .= '<a class=\'button button-secondary approve_bk_link ' . ($is_approved ? 'hidden_items' : '') . '\' style=\'margin-right:5px;\' href=\'javascript:;\' onclick=\'javascript:approve_unapprove_booking(' . $bk_id . ',1, ' . $user_bk_id . ', &quot;' . getBookingLocale() . '&quot; , 1   );\' ><i class=\'icon-ok-circle\'></i></a>';
        $title .= '<a class=\'button button-secondary pending_bk_link ' . ($is_approved ? '' : 'hidden_items') . '\' style=\'margin-right:5px;\' href=\'javascript:;\' onclick=\'javascript:approve_unapprove_booking(' . $bk_id . ',0, ' . $user_bk_id . ', &quot;' . getBookingLocale() . '&quot; , 1   );\' ><i class=\'icon-ban-circle\'></i></a>';
        $title .= '<a class=\'button button-secondary\' style=\'margin-right:5px;\' href=\'javascript:;\' onclick=\'javascript:delete_booking(' . $bk_id . ', ' . $user_bk_id . ', &quot;' . getBookingLocale() . '&quot; , 1   );\' ><i class=\'icon-trash\'></i></a>';
    }
    $title .= '</div>';
    $title_hint .= '</div>';
    //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    return array($title_in_day, $title, $title_hint, $is_approved);
}