public function __construct($ticket_query) { global $post; if ($ticket_query->have_posts()) { echo '<div id="time-ticket-listing">'; echo '<h2>' . fablab_get_captions('time_ticket_caption') . '</h2>'; echo '<p>Hier wird dir dein aktives ' . fablab_get_captions('time_ticket_caption') . ' angezeigt:</p>'; while ($ticket_query->have_posts()) { $ticket_query->the_post(); $device_id = get_post_meta($post->ID, 'timeticket_device', true); $color = get_post_meta($device_id, 'device_color', true); ?> <div class="fl-ticket-element" style="border: 4px solid <?php echo $color; ?> ;" data-user="******" data-time-ticket-id="<?php echo $post->ID; ?> "> <p><?php echo fablab_get_captions('device_caption'); ?> : <b><?php echo get_device_title_by_id($device_id); ?> </b> </p> <h2><?php echo $post->post_title; ?> </h2> <p>Start Zeit: <b><?php echo get_timediff_string(get_post_meta($post->ID, 'timeticket_start_time', true)); ?> </b></p> <p>End Zeit: <b><?php echo get_timediff_string(get_post_meta($post->ID, 'timeticket_end_time', true)); ?> </b></p> <input type="submit" class="ticket-btn stop-time-ticket" value="Jetzt Beenden"/> <input type="submit" data-minutes="30" class="ticket-btn extend-time-ticket" value="+30 Minuten"/> </div> <?php } echo '<div>'; } wp_reset_query(); }
function insert_timeticket() { $device_id = $_POST['device_id']; $duration = $_POST['duration']; $user_id = $_POST['user_id']; $ticket_id = $_POST['ticket_id']; $start_time = current_time('timestamp'); $end_time = current_time('timestamp') + 60 * $duration; $post_information = array('post_title' => fablab_get_captions('time_ticket_caption') . ' von: ' . get_user_by('id', $user_id)->display_name, 'post_type' => 'timeticket', 'author' => $user_id, 'post_status' => 'publish'); $ID = wp_insert_post($post_information); if ($ID != 0) { add_post_meta($ID, 'timeticket_device', $device_id); add_post_meta($ID, 'timeticket_start_time', $start_time); add_post_meta($ID, 'timeticket_end_time', $end_time); add_post_meta($ID, 'timeticket_user', $user_id); } deactivate_ticket($ticket_id); set_activation_time($ticket_id); die($ID != 0); }
function fl_options_page() { $parent_slug = 'edit.php?post_type=device'; $page_title = __('Options', 'fl'); $menu_title = __('Options', 'fl'); $capability = 'delete_others_posts'; $menu_slug = 'fablab_options'; $function = 'fablab_options_page'; add_submenu_page($parent_slug, $page_title, $menu_title, $capability, $menu_slug, $function); // ------------------------------------------------------------------ // Add all your sections, fields and settings during admin_menu // ------------------------------------------------------------------ // Add the section to reading settings so we can add our // fields to it add_settings_section('fablab_settings', 'Allgemeine Einstellungen', 'fablab_settings_function', 'fablab_options'); // Set Ticketing system online add_settings_field('ticket_online', fablab_get_captions('ticket_system_caption') . ' Online', 'fablab_ticket_online_function', 'fablab_options', 'fablab_settings'); // If user need ticket for permission add_settings_field('ticket_permission', fablab_get_captions('instructions_caption') . ' erforderlich', 'fablab_ticket_permission_function', 'fablab_options', 'fablab_settings'); // Add the field with the names and function to use for our new // settings, put it in our new section add_settings_field('tickets_per_user', fablab_get_captions('tickets_caption') . ' pro User', 'fablab_tickets_per_user_function', 'fablab_options', 'fablab_settings'); add_settings_field('ticket_time_interval', 'Zeit Intervall (min)', 'fablab_ticket_time_interval_function', 'fablab_options', 'fablab_settings'); add_settings_field('ticket_max_time', 'Maximale ' . fablab_get_captions('ticket_caption') . ' Zeit (min)', 'fablab_ticket_max_time_function', 'fablab_options', 'fablab_settings'); add_settings_field('ticket_delay', 'Zeit bis zur automatischen Deaktivierung (min)', 'fablab_ticket_delay_function', 'fablab_options', 'fablab_settings'); // Register our setting so that $_POST handling is done for us and // our callback function just has to echo the <input> register_setting('fablab_settings_section', 'option_fields', 'validate_options'); // ------------------------------------------------------------------ // Add all your sections, fields and settings during admin_menu // ------------------------------------------------------------------ // Add the section to reading settings so we can add our // fields to it add_settings_section('fablab_settings_capions', 'Captions', 'fablab_captions_function', 'fablab_options'); add_settings_field('fablab_ticket_system_caption', 'System Caption', 'fablab_ticket_system_caption_function', 'fablab_options', 'fablab_settings_capions'); add_settings_field('fablab_device_caption', 'Device (EZ) Caption', 'fablab_device_caption_function', 'fablab_options', 'fablab_settings_capions'); add_settings_field('fablab_devices_caption', 'Devices (MZ) Caption', 'fablab_devices_caption_function', 'fablab_options', 'fablab_settings_capions'); add_settings_field('fablab_ticket_caption', 'Ticket (EZ) Caption', 'fablab_ticket_caption_function', 'fablab_options', 'fablab_settings_capions'); add_settings_field('fablab_tickets_caption', 'Tickets (MZ) Caption', 'fablab_tickets_caption_function', 'fablab_options', 'fablab_settings_capions'); add_settings_field('fablab_time_ticket_caption', 'Time-Ticket (EZ) Caption', 'fablab_time_ticket_caption_function', 'fablab_options', 'fablab_settings_capions'); add_settings_field('fablab_time_tickets_caption', 'Time-Tickets (MZ) Caption', 'fablab_time_tickets_caption_function', 'fablab_options', 'fablab_settings_capions'); add_settings_field('fablab_instruction_caption', 'Instruction (EZ) Caption', 'fablab_instruction_caption_function', 'fablab_options', 'fablab_settings_capions'); add_settings_field('fablab_instructions_caption', 'Instructions (MZ) Caption', 'fablab_instructions_caption_function', 'fablab_options', 'fablab_settings_capions'); add_settings_field('fablab_instruction_request_caption', 'Instruction Requet (EZ) Caption', 'fablab_instruction_request_caption_function', 'fablab_options', 'fablab_settings_capions'); add_settings_field('fablab_nstruction_requests_caption', 'Instruction Requets (MZ) Caption', 'fablab_instruction_requests_caption_function', 'fablab_options', 'fablab_settings_capions'); // Register our setting so that $_POST handling is done for us and // our callback function just has to echo the <input> register_setting('fablab_settings_section', 'caption_fields', 'validate_captions'); // ------------------------------------------------------------------ // Add all your sections, fields and settings during admin_menu // ------------------------------------------------------------------ // Add the section to reading settings so we can add our // fields to it add_settings_section('fablab_settings_tac', 'AGBs', 'fablab_tac_function', 'fablab_options'); add_settings_field('fablab_tac_needed', 'AGB Zustimmung erforderlich', 'fablab_tac_needed_function', 'fablab_options', 'fablab_settings_tac'); add_settings_field('fablab_tac', 'AGB Page', 'fablab_tac_pageid_function', 'fablab_options', 'fablab_settings_tac'); add_settings_field('fablab_tac_date', 'Änderungsdatum', 'fablab_tac_date_function', 'fablab_options', 'fablab_settings_tac'); // Register our setting so that $_POST handling is done for us and // our callback function just has to echo the <input> register_setting('fablab_settings_section', 'tac_fields', 'validate_tacs'); }
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 device_details_meta() { ?> <table> <tr> <th><?php echo fablab_get_captions('device_caption'); ?> Status:</th> <th> <form name="" id="deviceStatus"> <?php if (get_device_field("device_status") == 'online') { echo '<input type="radio" name="device_status" checked value="online">Online '; echo '<input type="radio" name="device_status" value="offline">Offline '; } else { if (get_device_field("device_status") == 'offline') { echo '<input type="radio" name="device_status" value="online">Online '; echo '<input type="radio" name="device_status" checked value="offline">Offline '; } else { echo '<input type="radio" name="device_status" value="online">Online '; echo '<input type="radio" name="device_status" checked value="offline">Offline '; } } ?> </form> </th> </tr> <tr> <th><?php echo fablab_get_captions('device_caption'); ?> Color:</th> <th> <div id="colorPicker"> <a class="color"><div class="colorInner" style="background-color: <?php echo get_timeticket_field("device_color"); ?> ;"></div></a> <div class="track"></div> <ul class="dropdown"><li></li></ul> <input type="hidden" name="device_color" class="colorInput" value="<?php echo get_timeticket_field("device_color"); ?> "/> </div> </th> </tr> </table> <?php }
public function display_available_instruction_devices() { global $post; $query_arg = array('post_type' => 'device', 'meta_query' => array('relation' => 'OR', array('key' => 'device_status', 'value' => 'online', 'compare' => '='))); $device_query = new WP_Query($query_arg); $user_id = get_current_user_id(); $devices_availabel = false; get_current_user_id(); if ($device_query->have_posts()) { echo '<p>Hier werden dir die verfügbaren ' . fablab_get_captions('devices_caption') . ' für ' . fablab_get_captions('instructions_caption') . ' angezeigt:</p>'; echo '<div id="fl-getticket" class="device-list">'; while ($device_query->have_posts()) { $device_query->the_post(); if (!get_user_meta($user_id, $post->ID, true) && !user_has_ticket($user_id, $post->ID, 'instruction')) { ?> <div class="fl-device-element get-instruction" data-device-id="<?php echo $post->ID; ?> " data-device-name="<?php echo get_device_title_by_id($post->ID); ?> "> <div class="fl-device-element-content"> <h2><?php echo $post->post_title; ?> </h2> <p>Nächste <?php echo fablab_get_captions('instruction_caption'); ?> : <b><?php echo next_instruction($post->ID); ?> </b></p> <p>Ich möchte für dieses <?php echo fablab_get_captions('device_caption'); ?> eine <?php echo fablab_get_captions('instruction_caption'); ?> </p> </div> </div> <?php $devices_availabel = true; } } if (!$devices_availabel) { echo '<p class="device-message">Keine ' . fablab_get_captions('instruction_requests_caption') . ' verfügbar!</p>'; } echo '</div>'; } wp_reset_query(); }
function print_assign_overlay() { ?> <div id="overlay" class="fl-overlay" hidden> <div id="device-ticket-box" class="device-ticket" hidden> <a href="#" class="close">x</a> <h2><?php echo fablab_get_captions('ticket_caption'); ?> zuweisen</h2> <p id="user-name"></p> <p id="device-name"></p> <p id="waiting-time"><p> <p>Dauer: <select id="time-select"></select></p> <input type="submit" id="submit-ticket" class="button-primary" value="<?php echo fablab_get_captions('ticket_caption'); ?> zuweisen"/> <input type="submit" class="button-primary cancel-overlay" value="Abbrechen"/> </div> <div class="fl-overlay-layer"></div> </div> <div id="overlay-background" class="fl-overlay-background" hidden></div> <?php }
function set_instruction_title($data, $postarr) { if ($data['post_type'] == 'instruction') { $title = fablab_get_captions('instruction_caption') . ' am ' . date_i18n('D, d. M', strtotime($_POST['instruction_start_time'])); $data['post_title'] = $title; $data['post_name'] = sanitize_title_with_dashes($title, '', save); } return $data; }
function get_ticket_shortcode($atts) { global $post; global $fl_ticket_script; $fl_ticket_script = true; $user_id = get_current_user_id(); //-------------------------------------------------------- // User not Logged in //-------------------------------------------------------- if ($user_id == 0) { ?> <div id="message" class="message-box"> <p>Du bist nicht eingeloggt!</br> Du kannst dich <a href="<?php echo bloginfo('url'); ?> /wp-login.php?redirect_to=<?php echo get_permalink($post->ID); ?> ">hier</a> einloggen, oder <a href="<?php echo bloginfo('url'); ?> /wp-login.php?action=register">hier</a> registrieren!</p> </div> <?php return; } $permission_needed = fablab_get_option('tickets_permission') == '1'; ?> <div id="message-container"></div> <div class="busy" hidden></div> <?php new TicketShortcodeHelp(); //-------------------------------------------------------- // Check TAC //-------------------------------------------------------- $tac_options = fablab_get_tac(); $tac_acceptance_date = get_user_meta($user_id, 'tac_acceptance_date', true); $agb_page = get_post($tac_options['tac_pageid'], ARRAY_A); $content = apply_filters("the_content", $agb_page['post_content']); if (fablab_user_tac_acceptance()) { ?> <div id="tac-message" class="message-box"> <p class="tac-toggle">Um ein Gerät zu nutzen, bitte den AGBs zustimmen! <a id="tac-show">Anzeigen</a></p> </div> <?php echo '<div id="tac-content" hidden class="tac-box">'; if (!empty($content)) { echo $content; echo '<input type="submit" id="accept-tac" class="button-primary" value="Zustimmen"/>'; echo '<input type="submit" id="cancel-tac" class="button-primary" value="Abbrechen"/>'; } else { echo '<p>Keine AGBs vorhanden!</br>Bitte kontaktiere den Administrator!</p>'; } echo '</div>'; } else { //-------------------------------------------------------- // Display Ticket options //-------------------------------------------------------- $ticket_query = get_ticket_query_from_user($user_id); $timeticket_query = get_active_user_ticket($user_id); new TicketShortcodeTimeticket($timeticket_query); //print_active_user_timetickets($timeticket_query); $ticket_online = fablab_get_option('ticket_online') == 1; $ticket_count = $ticket_query->found_posts; $timeticket_count = $timeticket_query->found_posts; $tickets_per_user = fablab_get_option('tickets_per_user'); $max_tickets = $ticket_count + $timeticket_count >= $tickets_per_user; $ticket_caption = fablab_get_captions('ticket_caption'); $tickets_caption = fablab_get_captions('tickets_caption'); $tickets = new TicketShortcodeTicket(); if ($ticket_query->have_posts() && $timeticket_count < $tickets_per_user) { echo '<h2>' . $tickets_caption . '</h2>'; $tickets->display_user_tickets($ticket_query); } echo '<h2>' . fablab_get_captions('devices_caption') . '</h2>'; if (!$ticket_online) { echo '<p class="device-message">Zurzeit können keine ' . $tickets_caption . ' gezogen werden!</p>'; } else { if (!$max_tickets) { $tickets->display_available_devices($permission_needed); } else { echo '<p class="device-message">Du hast die maximale Anzahl von ' . $tickets_caption . ' gezogen!</p>'; } } } $instuctions = new TicketShortcodeInstructions(); $instruction_query = get_instruction_query_from_user($user_id); echo '<h2>' . fablab_get_captions('instruction_requests_caption') . '</h2>'; if ($instruction_query->have_posts()) { $instuctions->display_user_instructions($instruction_query); } if ($permission_needed) { $instuctions->display_available_instruction_devices(); } }
function insert_instruction_ticket() { $device_id = sanitize_text_field($_POST['device_id']); $options = fablab_get_option(); $user_id = get_current_user_id(); //valide input if (is_no_device_entry($device_id) || user_has_ticket($user_id, $device_id, 'instruction')) { die(false); } $post_information = array('post_title' => fablab_get_captions('instruction_request_caption') . ', von: ' . wp_get_current_user()->display_name, 'post_type' => 'ticket', 'author' => $user_id, 'post_status' => 'publish'); $ID = wp_insert_post($post_information); if ($ID != 0) { add_post_meta($ID, 'device_id', $device_id); add_post_meta($ID, 'ticket_type', 'instruction'); } die($ID != 0); }
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 }
public function __construct() { $devices = get_online_devices(); $user_id = get_current_user_id(); $show = true; foreach ($devices as $device) { if (get_user_meta($user_id, $device['id'], true)) { $show = false; } } $captions = fablab_get_captions(); $ticket_caption = $captions['ticket_caption']; $tickets_caption = $_captions['tickets_caption']; $device_caption = $captions['device_caption']; $devices_caption = $captions['devices_caption']; ?> <div class="help-container"> <input type="submit" class="help-button" value="Erste Schritte" /> <div class="help-box" <?php echo $show ? "" : "hidden"; ?> > <div><p class="help-headder">1. <?php echo fablab_get_captions('instruction_caption'); ?> </p> <div class="help-content" hidden> <p><?php echo $devices_caption; ?> für die du noch nicht eingeschult wurdest, werden grau angezeigt.</p> <ol> <li>Stelle eine <?php echo fablab_get_captions('instruction_request_caption'); ?> für dein gewünschtes <?php echo $device_caption; ?> </li> <li>Komm zu einer <?php echo fablab_get_captions('instruction_caption'); ?> </li> </ol> </div></div> <div><p class="help-headder">2. Zugang zu einem <?php echo $device_caption; ?> </p> <div class="help-content" hidden> <p>Für dich verfügbare <?php echo $devices_caption; ?> werden farbig angezeigt.</p> <ol> <li>Gewünschtes <?php echo $device_caption; ?> auswählen</li> <li>Benutzungsdauer auswählen</li> <li><?php echo $ticket_caption; ?> ziehen</li> </ol> </div></div> <div><p class="help-headder">3. <?php echo $ticket_caption; ?> ändern</p> <div class="help-content" hidden> <p>Gezogene <?php echo $tickets_caption; ?> werden unter <?php $tickets_caption; ?> angezeigt.</p> <ol> <li><?php echo $ticket_caption; ?> bearbeiten klicken</li> <li><?php echo $device_caption; ?> oder Dauer ändern</li> <li><?php echo $ticket_caption; ?> speichern</li> </ol> </div></div> <div><p class="help-headder">4. Du bist an der Reihe</p> <div class="help-content" hidden> <p>Wenn dein gewünschtes <?php echo $device_caption; ?> verfügbar ist (<?php echo $ticket_caption; ?> blinkt), melde dich bei dem Manager, er wird dir dein <?php echo $device_caption; ?> zuweisen.</p> </div></div> <div><p class="help-headder">5. <?php echo $device_caption; ?> benutzen</p> <div class="help-content" hidden> <p>Wenn dir ein <?php echo $device_caption; ?> zugewiesen wurde, wird dir ein <?php echo fablab_get_captions('time_ticket_caption'); ?> angezeigt.</p> <ul> <li>Du bist früher fertig: <b>"Jetzt Beenden"</b> klicken.</li> <li>Du brauchst länger: <b>"+30 Minuten"</b> klicken. (Maximale Benutzungsdauer: 2h)</li> </ul> </div></div> </div> </div> <?php }