private function display_device_tickets($device_id, $post_number = -1) { $query_arg = array('post_type' => 'ticket', 'orderby' => 'date', 'order' => 'ASC', 'posts_per_page' => $post_number, 'meta_query' => array('relation' => 'and', array('key' => 'ticket_type', 'value' => 'device'), array('key' => 'device_id', 'value' => $device_id))); $ticket_query = new WP_Query($query_arg); // Display Tickets echo '<div class="ticket-list">'; echo '<p>Hier werden die wartende Personen angezeigt:</p>'; global $post; if ($ticket_query->have_posts()) { while ($ticket_query->have_posts()) { $ticket_query->the_post(); $waiting = get_waiting_time_and_persons(get_post_meta($post->ID, 'device_id', true), $post->ID); $color = get_post_meta(get_post_meta($post->ID, 'device_id', true), 'device_color', true); $available = $waiting['time'] == 0; ?> <div class="<?php echo $available ? "fl-ticket-element blink" : "fl-ticket-element"; ?> " style="border-left: 5px solid <?php echo $color; ?> ;"> <p><?php echo the_time('l, j. F, G:i'); ?> <p> <h2><?php echo $post->post_title; ?> </h2> <p>für <?php echo fablab_get_captions('device_caption'); ?> : <b><?php echo get_device_title_by_id(get_post_meta($post->ID, 'device_id', true)); ?> </b> </br> Benutzungsdauer: <b><?php echo get_post_time_string(get_post_meta($post->ID, 'duration', true)); ?> </b></br> Vorraussichtlich Wartezeit: <b><?php echo get_post_time_string($waiting['time'], true); ?> </b></p> </div> <?php } } else { echo '<p style="margin: 10px;"> Keine wartenden Personen! </p>'; } echo '</div>'; wp_reset_query(); }
function get_timediff_string($first_time, $second_time = 0) { if ($second_time == 0) { $second_time = current_time('timestamp'); } $second_time = round($second_time / 60); $first_time = round($first_time / 60); if ($second_time > $first_time) { return 'vor ' . get_post_time_string($second_time - $first_time); } else { if ($first_time > $second_time) { return 'in ' . get_post_time_string($first_time - $second_time); } else { return 'jetzt'; } } }
function print_deactivatet_tickets($device_id = '') { global $post; if ($device_id) { $meta_array = array(array('key' => 'ticket_type', 'value' => 'device'), array('key' => 'device_id', 'value' => $device_id)); } else { $meta_array = array(array('key' => 'ticket_type', 'value' => 'device')); } $query_arg = array('post_type' => 'ticket', 'orderby' => 'date', 'order' => 'ASC', 'post_status' => 'draft', 'meta_query' => $meta_array); $ticket_query = new WP_Query($query_arg); if ($ticket_query->have_posts()) { echo '<div class="draft-box">'; echo '<div class="draft-toggle"><p class="draft-title">Deaktivierte ' . fablab_get_captions('tickets_caption') . '</p></div>'; echo '<div id="draft-ticket-listing" hidden>'; while ($ticket_query->have_posts()) { $ticket_query->the_post(); $color = get_post_meta(get_post_meta($post->ID, 'device_id', true), 'device_color', true); $device_id = get_post_meta($post->ID, 'device_id', true); $availabel = is_device_availabel($device_id); check_and_delete_ticket($post->ID); ?> <div class="fl-ticket-element draft-content" data-ticket-id="<?php echo $post->ID; ?> " style="border-left: 5px solid <?php echo $color; ?> ;" data-ticket-id="<?php echo $post->ID; ?> " data-device-id="<?php echo $device_id; ?> " data-duration="<?php echo get_post_meta($post->ID, 'duration', true); ?> " data-user-id="<?php echo $post->post_author; ?> " data-device-name="<?php echo get_device_title_by_id($device_id); ?> " data-user="******" > <p><?php echo the_time('l, j. F, G:i'); ?> <p> <h2><?php echo $post->post_title; ?> </h2> <p>für <?php echo fablab_get_captions('device_caption'); ?> : <b><?php echo get_device_title_by_id($device_id); ?> </b></br> Benutzungsdauer: <b><?php echo get_post_time_string(get_post_meta($post->ID, 'duration', true)); ?> </b></p> <input type="submit" <?php echo $availabel ? "" : "disabled"; ?> class="ticket-btn assign-ticket" value="<?php echo fablab_get_captions('ticket_caption'); ?> zuweisen"/> <input type="submit" class="ticket-btn activate-ticket" value="<?php echo fablab_get_captions('ticket_caption'); ?> aktivieren"/> <input type="submit" class="ticket-btn delete-ticket" value="<?php echo fablab_get_captions('ticket_caption'); ?> löschen"/> </div> <?php } echo '</div>'; echo '<div class="draft-toggle"><div class="arrow-down"></div></div>'; echo '</div>'; } wp_reset_query(); }
public function display_user_tickets($ticket_query) { global $post; echo '<p>Hier wird dir dein gezogenes ' . fablab_get_captions('ticket_caption') . ' angezeigt:</p>'; echo '<div id="ticket-listing" class="ticket-list">'; while ($ticket_query->have_posts()) { $ticket_query->the_post(); $waiting = get_waiting_time_and_persons(get_post_meta($post->ID, 'device_id', true), $post->ID); $color = get_post_meta(get_post_meta($post->ID, 'device_id', true), 'device_color', true); $device_id = get_post_meta($post->ID, 'device_id', true); $post->post_status == 'draft' ? $opacity = 0.6 : ($opacity = 1); $waiting['time'] == 0 ? $class = "fl-ticket-element blink" : ($class = "fl-ticket-element"); if (get_post_meta($post->ID, 'activation_time', true) == 'not set' || $opacity == 1) { ?> <div class="<?php echo $class; ?> " style="border-left: 5px solid <?php echo $color; ?> ; opacity: <?php echo $opacity; ?> ;" data-ticket-id="<?php echo $post->ID; ?> " data-device-id="<?php echo $device_id; ?> " data-duration="<?php echo get_post_meta($post->ID, 'duration', true); ?> " data-user-id="<?php echo $post->post_author; ?> " data-device-name="<?php echo get_device_title_by_id($device_id); ?> " data-user="******"> <p><?php echo the_time('l, j. F, G:i'); ?> <p> <h2><?php echo fablab_get_captions('ticket_caption'); ?> </h2> <p>für <?php echo fablab_get_captions('device_caption'); ?> : <b><?php echo get_device_title_by_id(get_post_meta($post->ID, 'device_id', true)); ?> </b> </br> Benutzungsdauer: <b><?php echo get_post_time_string(get_post_meta($post->ID, 'duration', true)); ?> </b></p> <p id="waiting-time">Vor dir wartende Personen: <b><?php echo $waiting['persons']; ?> </b></br> Vorraussichtlich Wartezeit: <b><?php echo get_post_time_string($waiting['time'], true); ?> </b></p> <?php if ($opacity == 1) { echo '<input type="submit" class="ticket-btn edit-ticket" value="' . fablab_get_captions('ticket_caption') . ' bearbeiten"/>'; } else { echo '<p></br><b>Dein ' . fablab_get_captions('ticket_caption') . ' ist deaktiviert, bitte melde dich bei dem Manager!</b></p>'; } ?> </div> <?php } } echo '</div>'; wp_reset_query(); // Display overlay change Ticket ?> <div id="overlay-edit-ticket" class="fl-overlay" hidden> <div id="device-edit-ticket-box" class="device-ticket" hidden> <a href="#" class="close">x</a> <h2><?php echo fablab_get_captions('ticket_caption'); ?> bearbeiten</h2> <p><?php echo fablab_get_captions('device_caption'); ?> : <select id="edit-ticket-device-select"></select></p> <p id="edit-ticket-waiting-time"><p> <div id="edit-ticket-device-content"></div> <p>Dauer: <select id="edit-ticket-time-select"></select></p> <input type="submit" id="submit-change-ticket" class="button-primary" value="<?php echo fablab_get_captions('ticket_caption'); ?> speichern"/> <input type="submit" id="delete-change-ticket" class="button-primary" value="Löschen"/> <input type="submit" id="cancel-change-ticket" class="button-primary" value="Abbrechen"/> </div> <div class="fl-overlay-background"></div> </div> <?php }