Exemple #1
0
/**
 * admin_custom_room_column()
 * 
 * Display custom column data
 * 
 * @param none
 * @return none
 */
function admin_custom_room_column($column, $post_id)
{
    switch ($column) {
        case 'room_status':
            $status = get_field('room_status', $post_id);
            echo sprintf('<span class="badge %s">%s</span>', sanitize_title_with_dashes($status), $status);
            break;
        case 'room_type':
            echo get_room_type($post_id)->post_title;
            break;
        case 'room_price':
            echo nf(get_field('price', $post_id));
            break;
    }
}
        <th>Check In</th>
        <th>Check Out</th>
        <th width="80px;"></th>
      </tr>
    </thead>
    <tbody>
      <?php 
foreach ($rooms_and_guest as $i => $r) {
    ?>
      <tr>
        <td><?php 
    echo $r['room_title'];
    ?>
</td>
        <td><?php 
    echo get_room_type($r['room_ID'])->post_title;
    ?>
</td>
        <td><?php 
    echo $r['guest'];
    ?>
</td>
        <td><?php 
    echo $r['phone'];
    ?>
</td>
        <td><?php 
    echo $r['no_of_adult'];
    ?>
</td>
        <td><?php 
 public function get_guest_calendar_table($selected_date, $days_to_display, $status)
 {
     $start_date = format_date($selected_date, 'j');
     $end_date = add_days_to_date($selected_date, $days_to_display);
     $calendar = array();
     $rooms = get_all_rooms();
     foreach ($rooms as $i => $r) {
         $calendar[get_the_title($r) . ':' . get_room_type($r)->post_title] = get_guest_calendar_by_room_ID($r, $selected_date, $end_date, $status);
     }
     $total_day = count_days_gap($selected_date, $end_date, $end_date);
     $end_date = minus_days_to_date($end_date, 1);
     $monthHTML = $dateHTML = $dayHTML = $tdHTML = $output = '';
     $date = $selected_date;
     while (strtotime($date) <= strtotime($end_date)) {
         $monthHTML .= '<th colspan="' . ($date != $selected_date && $date != $end_date ? '2' : '') . '">' . format_date($date, 'M') . '</th>';
         $dateHTML .= '<th colspan="' . ($date != $selected_date && $date != $end_date ? '2' : '') . '">' . format_date($date, 'j') . '</th>';
         $dayHTML .= '<th colspan="' . ($date != $selected_date && $date != $end_date ? '2' : '') . '">' . format_date($date, 'D') . '</th>';
         $date = add_days_to_date($date, 1);
     }
     $date = $selected_date;
     $tdHTML .= '<tr>';
     while (strtotime($date) < strtotime($end_date)) {
         $tdHTML .= '<td colspan="2" class="' . strtolower(format_date($date, 'D')) . '"></td>';
         $date = add_days_to_date($date, 1);
     }
     $tdHTML .= '</tr>';
     $output .= '<table class="widefat">';
     $output .= '<thead>';
     $output .= '<tr>';
     $output .= '<th width="10%"></th>';
     $output .= $monthHTML;
     $output .= '</tr>';
     $output .= '<tr>';
     $output .= '<th width="10%"></th>';
     $output .= $dateHTML;
     $output .= '</tr>';
     $output .= '<tr>';
     $output .= '<th width="10%"></th>';
     $output .= $dayHTML;
     $output .= '</tr>';
     $output .= '</thead>';
     $output .= '<tbody>';
     foreach ($calendar as $k => $c) {
         usort($c, function ($a, $b) {
             return strtotime($a['from']) - strtotime($b['from']);
         });
         $output .= '<tr>';
         $output .= '<td class="room">' . $k . '</td>';
         $output .= '<td colspan="' . ($total_day * 2 - 2) . '" class="calendar_row">';
         $output .= '<div class="row_data">';
         $output .= '<div class="bg_row">';
         $output .= '<table>';
         $output .= '<tbody>';
         $output .= $tdHTML;
         $output .= '</tbody>';
         $output .= '</table>';
         $output .= '</div>';
         $output .= '<div class="bg-content">';
         $output .= '<table>';
         $output .= '<tbody>';
         $b = $selected_date;
         foreach ($c as $indx => $cal) {
             if (strtotime($cal['from']) > strtotime($end_date) || strtotime($cal['from']) < strtotime($selected_date) && strtotime($cal['to']) < strtotime($selected_date)) {
                 continue;
             }
             $cal['from'] = strtotime($cal['from']) < strtotime($selected_date) ? $selected_date : $cal['from'];
             if (($f = count_days_gap($b, $cal['from'], $end_date)) > 0) {
                 $output .= '<td colspan="' . $f . '"></td>';
                 $b = add_days_to_date($b, $f);
             }
             $f = count_days_gap($cal['from'], $cal['to'], $end_date);
             if ($f != 0 && $indx < count($c)) {
                 $output .= '<td class="not-available" colspan="' . $f . '"><div class="text bdr-tooltip ' . strtolower($cal['status']) . '" title="' . $cal['guest'] . ' : ' . format_date($cal['from']) . ' to ' . format_date($cal['to']) . '">' . $cal['guest'] . '</div></td>';
             }
             $b = $cal['to'] > $end_date ? $end_date : $cal['to'];
         }
         if (strtotime($end_date) > strtotime($b) && ($f = count_days_gap($b, $end_date, $end_date)) > 0) {
             $output .= '<td colspan="' . $f . '"></td>';
         }
         $output .= '</tbody>';
         $output .= '</table>';
         $output .= '</div>';
         $output .= '</div>';
         $output .= '</td>';
         $output .= '</tr>';
     }
     $output .= '</tbody>';
     $output .= '</table>';
     return $output;
 }