コード例 #1
0
ファイル: wpdev-bk-lib.php プロジェクト: RetinaInc/booking-2
function wpdev_calendar_overview_buttons_navigations()
{
    if (isset($_REQUEST['view_days_num'])) {
        $view_days_num = $_REQUEST['view_days_num'];
    } else {
        $view_days_num = get_bk_option('booking_view_days_num');
    }
    if (isset($_REQUEST['wh_booking_type']) && strpos($_REQUEST['wh_booking_type'], ',') !== false) {
        $is_show_resources_matrix = true;
    } else {
        $is_show_resources_matrix = false;
    }
    if (!$is_show_resources_matrix) {
        switch ($view_days_num) {
            case '90':
                if (isset($_REQUEST['scroll_day'])) {
                    $scroll_day = $_REQUEST['scroll_day'];
                } else {
                    $scroll_day = 0;
                }
                $scroll_params = array('&scroll_day=' . intval($scroll_day - 4 * 7), '&scroll_day=' . intval($scroll_day - 7), '&scroll_day=0', '&scroll_day=' . intval($scroll_day + 7), '&scroll_day=' . intval($scroll_day + 4 * 7));
                $scroll_titles = array(__('Previous 4 weeks', 'wpdev-booking'), __('Previous week', 'wpdev-booking'), __('Current week', 'wpdev-booking'), __('Next week', 'wpdev-booking'), __('Next 4 weeks', 'wpdev-booking'));
                break;
            case '30':
                if (isset($_REQUEST['scroll_day'])) {
                    $scroll_day = $_REQUEST['scroll_day'];
                } else {
                    $scroll_day = 0;
                }
                $scroll_params = array('&scroll_day=' . intval($scroll_day - 4 * 7), '&scroll_day=' . intval($scroll_day - 7), '&scroll_day=0', '&scroll_day=' . intval($scroll_day + 7), '&scroll_day=' . intval($scroll_day + 4 * 7));
                $scroll_titles = array(__('Previous 4 weeks', 'wpdev-booking'), __('Previous week', 'wpdev-booking'), __('Current week', 'wpdev-booking'), __('Next week', 'wpdev-booking'), __('Next 4 weeks', 'wpdev-booking'));
                break;
            default:
                // 365
                if (!isset($_REQUEST['scroll_month'])) {
                    $_REQUEST['scroll_month'] = 0;
                }
                $scroll_month = $_REQUEST['scroll_month'];
                $scroll_params = array('&scroll_month=' . intval($scroll_month - 3), '&scroll_month=' . intval($scroll_month - 1), '&scroll_month=0', '&scroll_month=' . intval($scroll_month + 1), '&scroll_month=' . intval($scroll_month + 3));
                $scroll_titles = array(__('Previous 3 months', 'wpdev-booking'), __('Previous month', 'wpdev-booking'), __('Current month', 'wpdev-booking'), __('Next month', 'wpdev-booking'), __('Next 3 months', 'wpdev-booking'));
                break;
        }
    } else {
        // Matrix
        switch ($view_days_num) {
            case '1':
                //Day
                if (isset($_REQUEST['scroll_day'])) {
                    $scroll_day = $_REQUEST['scroll_day'];
                } else {
                    $scroll_day = 0;
                }
                $scroll_params = array('&scroll_day=' . intval($scroll_day - 7), '&scroll_day=' . intval($scroll_day - 1), '&scroll_day=0', '&scroll_day=' . intval($scroll_day + 1), '&scroll_day=' . intval($scroll_day + 7));
                $scroll_titles = array(__('Previous 7 days', 'wpdev-booking'), __('Previous day', 'wpdev-booking'), __('Current day', 'wpdev-booking'), __('Next day', 'wpdev-booking'), __('Next 7 days', 'wpdev-booking'));
                break;
            case '7':
                //Week
                if (isset($_REQUEST['scroll_day'])) {
                    $scroll_day = $_REQUEST['scroll_day'];
                } else {
                    $scroll_day = 0;
                }
                $scroll_params = array('&scroll_day=' . intval($scroll_day - 4 * 7), '&scroll_day=' . intval($scroll_day - 7), '&scroll_day=0', '&scroll_day=' . intval($scroll_day + 7), '&scroll_day=' . intval($scroll_day + 4 * 7));
                $scroll_titles = array(__('Previous 4 weeks', 'wpdev-booking'), __('Previous week', 'wpdev-booking'), __('Current week', 'wpdev-booking'), __('Next week', 'wpdev-booking'), __('Next 4 weeks', 'wpdev-booking'));
                break;
            case '30':
            case '60':
            case '90':
                //3 months
                if (!isset($_REQUEST['scroll_month'])) {
                    $_REQUEST['scroll_month'] = 0;
                }
                $scroll_month = $_REQUEST['scroll_month'];
                $scroll_params = array('&scroll_month=' . intval($scroll_month - 3), '&scroll_month=' . intval($scroll_month - 1), '&scroll_month=0', '&scroll_month=' . intval($scroll_month + 1), '&scroll_month=' . intval($scroll_month + 3));
                $scroll_titles = array(__('Previous 3 months', 'wpdev-booking'), __('Previous month', 'wpdev-booking'), __('Current month', 'wpdev-booking'), __('Next month', 'wpdev-booking'), __('Next 3 months', 'wpdev-booking'));
                break;
            default:
                // 30, 60, 90...
                if (!isset($_REQUEST['scroll_month'])) {
                    $_REQUEST['scroll_month'] = 0;
                }
                $scroll_month = $_REQUEST['scroll_month'];
                $scroll_params = array('&scroll_month=' . intval($scroll_month - 3), '&scroll_month=' . intval($scroll_month - 1), '&scroll_month=0', '&scroll_month=' . intval($scroll_month + 1), '&scroll_month=' . intval($scroll_month + 3));
                $scroll_titles = array(__('Previous 3 months', 'wpdev-booking'), __('Previous month', 'wpdev-booking'), __('Current month', 'wpdev-booking'), __('Next month', 'wpdev-booking'), __('Next 3 months', 'wpdev-booking'));
                break;
        }
    }
    $bk_admin_url = get_params_in_url(array('scroll_month', 'scroll_day'));
    ?>
<div class="btn-toolbar">
                <div class="btn-group">
                    <a     data-original-title="<?php 
    echo $scroll_titles[0];
    ?>
"  rel="tooltip" class="tooltip_top button button-secondary "
                           href="<?php 
    echo $bk_admin_url . $scroll_params[0] . '';
    ?>
"       /><i class="icon-backward"></i></a>
                    <a     data-original-title="<?php 
    echo $scroll_titles[1];
    ?>
"  rel="tooltip" class="tooltip_top button button-secondary"
                           href="<?php 
    echo $bk_admin_url . $scroll_params[1] . '';
    ?>
"        /><i class="icon-chevron-left"></i></a>

                    <?php 
    $bk_admin_url_today = get_params_in_url(array('scroll_month', 'scroll_day', 'scroll_start_date'));
    wpdevbk_date_selection_for_navigation('start_date_selection_in_navigation', $bk_admin_url_today, $scroll_titles, $scroll_params);
    ?>
       
<!--                    <a     data-original-title="<?php 
    echo $scroll_titles[2];
    ?>
"  rel="tooltip" class="tooltip_top btn btn"
                           href="<?php 
    echo $bk_admin_url . $scroll_params[2];
    ?>
"        /><i class="icon-screenshot"></i></a>-->

                    <a     data-original-title="<?php 
    echo $scroll_titles[3];
    ?>
"  rel="tooltip" class="tooltip_top button button-secondary"
                           href="<?php 
    echo $bk_admin_url . $scroll_params[3] . '';
    ?>
"       /><i class="icon-chevron-right"></i></a>
                    <a     data-original-title="<?php 
    echo $scroll_titles[4];
    ?>
"  rel="tooltip" class="tooltip_top button button-secondary"
                           href="<?php 
    echo $bk_admin_url . $scroll_params[4] . '';
    ?>
"       /><i class="icon-forward"></i></a>
                </div>
                <p class="help-block" style="margin:27px 0 0;"><?php 
    _e('Calendar Navigation', 'wpdev-booking');
    ?>
</p>
          </div>

          <?php 
}
コード例 #2
0
ファイル: wpdev-bk-timeline.php プロジェクト: dev-lav/htdocs
function wpdev_bk_timeline($dates_array, $bookings, $booking_types, $time_array_new = array())
{
    if (isset($_REQUEST['wh_booking_type']) && strpos($_REQUEST['wh_booking_type'], ',') !== false) {
        $is_show_resources_matrix = true;
    } else {
        $is_show_resources_matrix = false;
    }
    $scroll_day = 0;
    $scroll_month = 0;
    $start_year = date("Y");
    // 2012
    $start_month = date("m");
    // 09
    // Set the correct  start  date, if was selected the stard date different from the today  in the Filters Tab.
    if (!empty($_REQUEST['scroll_start_date'])) {
        // scroll_start_date=2013-07-01
        $scroll_start_date = explode('-', $_REQUEST['scroll_start_date']);
        $start_year = $scroll_start_date[0];
        //2012
        $start_month = $scroll_start_date[1];
        //09
        $start_day = $scroll_start_date[2];
        //date("d");//1;     //31
    }
    $view_days_num = $_REQUEST['view_days_num'];
    // Get start date and number of rows, which is depend from the view days mode
    ////////////////////////////////////////////////////////////////////////////////////////////////
    // Get Start Date and Scroll Day/Month Variables ///////////////////////////////////////////////
    ////////////////////////////////////////////////////////////////////////////////////////////////
    if ($is_show_resources_matrix) {
        // MATRIX VIEW
        //debuge($_REQUEST['wh_booking_type']);
        $bk_resources_id = explode(',', $_REQUEST['wh_booking_type']);
        $max_rows_number = count($bk_resources_id);
        //debuge($bk_resources_id);
        switch ($view_days_num) {
            case '1':
                if (isset($_REQUEST['scroll_day'])) {
                    $scroll_day = $_REQUEST['scroll_day'];
                }
                if (empty($_REQUEST['scroll_start_date'])) {
                    $start_day = date("d");
                }
                break;
            case '30':
            case '60':
                if (isset($_REQUEST['scroll_month'])) {
                    $scroll_month = $_REQUEST['scroll_month'];
                }
                if (empty($_REQUEST['scroll_start_date'])) {
                    $start_day = 1;
                }
                break;
            case '7':
                // 7 Week - start from Monday (or other start week day)
                if (isset($_REQUEST['scroll_day'])) {
                    $scroll_day = $_REQUEST['scroll_day'];
                }
                if (empty($_REQUEST['scroll_start_date'])) {
                    $start_day = date("d");
                }
                $start_week_day_num = date("w");
                $start_day_weeek = get_bk_option('booking_start_day_weeek');
                //[0]:Sun .. [6]:Sut
                if ($start_week_day_num != $start_day_weeek) {
                    for ($d_inc = 1; $d_inc < 8; $d_inc++) {
                        // Just get week  back
                        $real_date = mktime(0, 0, 0, $start_month, $start_day - $d_inc, $start_year);
                        $start_week_day_num = date("w", $real_date);
                        if ($start_week_day_num == $start_day_weeek) {
                            $start_day = date("d", $real_date);
                            $start_year = date("Y", $real_date);
                            $start_month = date("m", $real_date);
                            $d_inc = 9;
                        }
                    }
                }
                break;
            default:
                //30
                if (isset($_REQUEST['scroll_month'])) {
                    $scroll_month = $_REQUEST['scroll_month'];
                }
                if (empty($_REQUEST['scroll_start_date'])) {
                    $start_day = 1;
                }
                break;
        }
    } else {
        // SINGLE Resource VIEW
        switch ($view_days_num) {
            case '90':
                if (isset($_REQUEST['scroll_day'])) {
                    $scroll_day = $_REQUEST['scroll_day'];
                } else {
                    $scroll_day = 0;
                }
                $max_rows_number = 12;
                if (empty($_REQUEST['scroll_start_date'])) {
                    $start_day = date("d");
                }
                $start_week_day_num = date("w");
                $start_day_weeek = get_bk_option('booking_start_day_weeek');
                //[0]:Sun .. [6]:Sut
                if ($start_week_day_num != $start_day_weeek) {
                    for ($d_inc = 1; $d_inc < 8; $d_inc++) {
                        // Just get week  back
                        $real_date = mktime(0, 0, 0, $start_month, $start_day - $d_inc, $start_year);
                        $start_week_day_num = date("w", $real_date);
                        if ($start_week_day_num == $start_day_weeek) {
                            $start_day = date("d", $real_date);
                            $start_year = date("Y", $real_date);
                            $start_month = date("m", $real_date);
                            $d_inc = 9;
                        }
                    }
                }
                break;
            case '365':
                if (isset($_REQUEST['scroll_month'])) {
                    $scroll_month = $_REQUEST['scroll_month'];
                } else {
                    $scroll_month = 0;
                }
                $max_rows_number = 12;
                if (empty($_REQUEST['scroll_start_date'])) {
                    $start_day = 1;
                }
                break;
            default:
                // 30
                if (isset($_REQUEST['scroll_day'])) {
                    $scroll_day = $_REQUEST['scroll_day'];
                } else {
                    $scroll_day = 0;
                }
                $max_rows_number = 31;
                if (empty($_REQUEST['scroll_start_date'])) {
                    $start_day = date("d");
                }
                break;
        }
    }
    ////////////////////////////////////////////////////////////////////////////////////////////////
    ?>
<div class="bookings_overview_in_calendar_frame">
        <table class="bookings_overview_in_calendar booking_table table table-striped" cellpadding="0" cellspacing="0">
        <tr>
            <th style="width:200px;"><?php 
    if ($is_show_resources_matrix) {
        _e('Resources', 'wpdev-booking');
    }
    ?>
</th>
            <th style="text-align:center;"><?php 
    _e('Dates', 'wpdev-booking');
    //wpdev_calendar_overview_buttons_navigations();
    ?>
</th>
        </tr>
        <tr><td colspan="2"> </td></tr>
        <tr>
            <td class="bk_resource_selector"></td>
            <td style="padding:0px;"><?php 
    // Header above the calendar table
    $real_date = mktime(0, 0, 0, $start_month, $start_day, $start_year);
    if ($is_show_resources_matrix) {
        // MATRIX VIEW
        switch ($view_days_num) {
            // Set real start date for the each rows in calendar
            case '1':
            case '7':
                $real_date = mktime(0, 0, 0, $start_month, $start_day + $scroll_day, $start_year);
                break;
            case '30':
            case '60':
                $real_date = mktime(0, 0, 0, $start_month + $scroll_month, $start_day, $start_year);
                break;
            default:
                // 30
                $real_date = mktime(0, 0, 0, $start_month + $scroll_month, $start_day, $start_year);
                break;
        }
    } else {
        // Single Resource View
        switch ($view_days_num) {
            // Set real start date for the each rows in calendar
            case '90':
                $real_date = mktime(0, 0, 0, $start_month, $start_day + $scroll_day, $start_year);
                break;
            case '365':
                $real_date = mktime(0, 0, 0, $start_month + $scroll_month, $start_day, $start_year);
                break;
            default:
                // 30
                $real_date = mktime(0, 0, 0, $start_month, $start_day + $scroll_day, $start_year);
                break;
        }
    }
    wpdev_bk_timeline_header_row($real_date);
    ?>
            </td>
        </tr><?php 
    for ($d_inc = 0; $d_inc < $max_rows_number; $d_inc++) {
        // Ger Start Date to real_date  variabale  /////////////////////
        if ($is_show_resources_matrix) {
            // MATRIX VIEW
            switch ($view_days_num) {
                // Set real start date for the each rows in calendar
                case '1':
                case '7':
                    $real_date = mktime(0, 0, 0, $start_month, $start_day + $scroll_day, $start_year);
                    break;
                case '30':
                case '90':
                    $real_date = mktime(0, 0, 0, $start_month + $scroll_month, $start_day, $start_year);
                    break;
                default:
                    // 30
                    $real_date = mktime(0, 0, 0, $start_month + $scroll_month, $start_day, $start_year);
                    break;
            }
        } else {
            // Single Resource View
            switch ($view_days_num) {
                // Set real start date for the each rows in calendar
                case '90':
                    $real_date = mktime(0, 0, 0, $start_month, $start_day + $d_inc * 7 + $scroll_day, $start_year);
                    break;
                case '365':
                    $real_date = mktime(0, 0, 0, $start_month + $d_inc + $scroll_month, $start_day, $start_year);
                    break;
                default:
                    // 30
                    $real_date = mktime(0, 0, 0, $start_month, $start_day + $d_inc + $scroll_day, $start_year);
                    break;
            }
        }
        ////////////////////////////////////////////////////////////////
        ?>
          <tr>
            <td style="border-right:2px solid #CC5544;">
                <div class="resource_title"><?php 
        // Title in first collumn of the each row in calendar //////
        if ($is_show_resources_matrix && isset($bk_resources_id[$d_inc]) && isset($booking_types[$bk_resources_id[$d_inc]])) {
            // Matrix - resource titles
            $resource_value = $booking_types[$bk_resources_id[$d_inc]];
            $bk_admin_url = get_params_in_url(array('wh_booking_type'));
            ?>
<div class="resource_title <?php 
            if (isset($resource_value->parent)) {
                if ($resource_value->parent == 0) {
                    echo 'parent';
                } else {
                    echo 'child';
                }
            }
            ?>
 ">
                        <a href="<?php 
            echo $bk_admin_url . '&wh_booking_type=' . $bk_resources_id[$d_inc];
            ?>
" /><?php 
            echo $resource_value->title;
            ?>
 
                        </a>
                       </div><?php 
        } else {
            // Single Resource - Dates titles
            switch ($view_days_num) {
                case '90':
                    $end_real_date = mktime(0, 0, 0, $start_month, $start_day + $d_inc * 7 + $scroll_day + 6, $start_year);
                    $date_format = ' j, Y';
                    //get_bk_option( 'booking_date_format');
                    echo __(date_i18n("M", $real_date)) . date($date_format, $real_date) . ' - ' . __(date_i18n("M", $end_real_date)) . date($date_format, $end_real_date);
                    break;
                case '365':
                    echo __(date("F", $real_date)) . ', ' . date("Y", $real_date);
                    break;
                default:
                    // 30
                    $date_format = 'd / m / Y';
                    echo __(date("D", $real_date)) . ', ' . date($date_format, $real_date);
                    break;
            }
        }
        ?>
</div>
            </td>
            <td  style="padding:0px;">
                <div class="resource_dates"><?php 
        if ($is_show_resources_matrix) {
            $resource_id = $bk_resources_id[$d_inc];
        } else {
            if (isset($_REQUEST['wh_booking_type'])) {
                $resource_id = $_REQUEST['wh_booking_type'];
            } elseif (isset($_GET['booking_type'])) {
                $resource_id = $_GET['booking_type'];
            } else {
                $resource_id = '';
            }
        }
        wpdev_bk_timeline_booking_row($resource_id, $real_date, array($dates_array, $bookings, $booking_types, $time_array_new));
        ?>
</div>
            </td>
          </tr>
        <?php 
    }
    ?>
</table></div><?php 
}
コード例 #3
0
function wpdevbk_show_pagination($summ_number_of_items, $active_page_num, $num_items_per_page, $only_these_parameters = false)
{
    if (empty($num_items_per_page)) {
        $num_items_per_page = '10';
    }
    $pages_number = ceil($summ_number_of_items / $num_items_per_page);
    if ($pages_number < 2) {
        return;
    }
    $bk_admin_url = get_params_in_url(array('page_num'), $only_these_parameters);
    ?>
        <div class="pagination pagination-centered" style="height:auto;">
          <ul>
              
            <?php 
    if ($pages_number > 1) {
        ?>
                <li <?php 
        if ($active_page_num == 1) {
            echo ' class="disabled" ';
        }
        ?>
 >
                    <a href="<?php 
        echo $bk_admin_url;
        ?>
&page_num=<?php 
        if ($active_page_num == 1) {
            echo $active_page_num;
        } else {
            echo $active_page_num - 1;
        }
        ?>
">
                        <?php 
        _e('Prev', 'wpdev-booking');
        ?>
                    </a>
                </li>
            <?php 
    }
    ?>
            
            <?php 
    for ($pg_num = 1; $pg_num <= $pages_number; $pg_num++) {
        ?>

              <li <?php 
        if ($pg_num == $active_page_num) {
            echo ' class="active" ';
        }
        ?>
 >
                  <a href="<?php 
        echo $bk_admin_url;
        ?>
&page_num=<?php 
        echo $pg_num;
        ?>
">
                    <?php 
        echo $pg_num;
        ?>
                  </a>
              </li>

            <?php 
    }
    ?>

            <?php 
    if ($pages_number > 1) {
        ?>
                <li <?php 
        if ($active_page_num == $pages_number) {
            echo ' class="disabled" ';
        }
        ?>
 >
                    <a href="<?php 
        echo $bk_admin_url;
        ?>
&page_num=<?php 
        if ($active_page_num == $pages_number) {
            echo $active_page_num;
        } else {
            echo $active_page_num + 1;
        }
        ?>
">
                        <?php 
        _e('Next', 'wpdev-booking');
        ?>
                    </a>
                </li>
            <?php 
    }
    ?>

          </ul>
        </div>
        <?php 
}