<?php

global $bp, $wpdb;

    $eventData     = $wpdb->get_row('select * from wp_jet_events where slug = "' . $_GET['view'] . '"');
    $eventAdmins   = $wpdb->get_results('select * from wp_jet_events_members where event_id = "' . $eventData->id . '" and is_confirmed = "1" and is_banned = "0" and is_admin = "1"');
    $eventUsers    = $wpdb->get_results('select * from wp_jet_events_members where event_id = "' . $eventData->id . '" and is_confirmed = "1" and is_banned = "0" and is_admin = "0"');
    $eventBanned   = $wpdb->get_results('select * from wp_jet_events_members where event_id = "' . $eventData->id . '" and is_confirmed = "1" and is_banned = "1"');
    $eventInvited  = $wpdb->get_results('select * from wp_jet_events_members where event_id = "' . $eventData->id . '" and is_confirmed = "0" and is_banned = "0"');
?>
<script type="text/javascript" src="wp-content/themes/cvp-irontec/events/custom/js/scripts.js"></script>
<style>
li.iron-encabezado-li a.selected {
    background: whiteSmoke;
    color: #444;
    padding: 5px 7px;
}

li.iron-encabezado-li a:HOVER {
    text-decoration: none;
}

.bp-widget { display: block; float: left; width: 100%;}
</style>

<div id="iron-encabezado-container">
    <h2 class="iron-encabezado-seccion"><?php echo __('Eventos','buddypress'); ?></h2>

    <ul class="iron-encabezado-ul">
        <li class="iron-encabezado-li">
            <a href="<?php bp_root_domain() ?>/eventos/">
                <?php _e ( 'Todos', 'buddypress' ); ?>
            </a>
        </li>
        </li>
        <li class="iron-encabezado-li">&middot;&nbsp;
            <a href="<?php echo bp_get_root_domain() . '/eventos/?view=' . $_GET['view']; ?>">
                <?php _e ( 'Volver al evento', 'buddypress' ) ; ?>
            </a>
        </li>
        <li class="iron-encabezado-li">&middot;&nbsp;
            <a href="<?php echo bp_get_root_domain() . '/eventos/?view=' . $_GET['view'] . '&Admin=details'; ?>">
                <?php _e ( 'Administración', 'buddypress' ) ; ?>
            </a>
        </li>
    </ul>
</div>

<div class="padder" id="jes-padder">
    
    <div id="content-top"></div>

    <div id="content-middle">
    
    <div id="content-middle-add">

        <div id="item-body">

            <div id="iron-encabezado-container-sub">
                <ul class="iron-encabezado-ul">
                    <li class="iron-encabezado-li">
                        <a href="<?php echo bp_get_root_domain() . '/eventos/?view=' . $_GET['view'] .'&Admin=details' ?>">
                            <?php _e('Editar', 'buddypress'); ?>
                        </a>
                    </li>
                    <li class="iron-encabezado-li">&nbsp;
                        <a href="<?php echo bp_get_root_domain() . '/eventos/?view=' . $_GET['view'] .'&Admin=avatar' ?>">
                            <?php _e('Avatar', 'buddypress'); ?>
                        </a>
                    </li>
                    <li class="iron-encabezado-li">&nbsp;
                        <a class="selected" href="<?php echo bp_get_root_domain() . '/eventos/?view=' . $_GET['view'] .'&Admin=members' ?>">
                                <?php _e('Miembros', 'buddypress'); ?>
                        </a>
                    </li>
                    <li class="iron-encabezado-li">&nbsp;
                        <a href="<?php echo bp_get_root_domain() . '/eventos/?view=' . $_GET['view'] .'&Admin=sendInvites' ?>">
                            <?php _e('Enviar invitaciones', 'buddypress'); ?>
                        </a>
                    </li>
                    <li class="iron-encabezado-li">&nbsp;
                        <a href="<?php echo bp_get_root_domain() . '/eventos/?view=' . $_GET['view'] .'&Admin=delete' ?>">
                            <?php _e('Delete', 'buddypress'); ?>
                        </a>
                    </li>
                </ul>
            </div>
            
            <div class="bp-widget">
                
                <h4>
                    <?php _e('Administradores', 'buddypress')?>
                </h4>
                    <ul id="admins-list" class="item-list single-line">
                    
                        <?php
                        foreach ($eventAdmins as $admins) {
                            ?>
                            <li class="user-<?php echo $admins->user_id ?>" style="min-height: 42px;">
                            <?php echo bp_core_fetch_avatar( array( 'item_id' => $admins->user_id, 'type' => $avatar_size, 'width' => 32, 'height' => 32 ) ) ?>
                                    <h5>
                                        <a href="<?php echo bp_core_get_user_domain( $admins->user_id )  ?>" title="<?php echo bp_core_get_user_displayname( $admins->user_id )?>">
                                            <?php echo bp_core_get_user_displayname( $admins->user_id )?>
                                        </a>
                                            <?php
                                            if ($admins->user_id != $eventData->creator_id) {
                                                ?>
                                                <span class="normal-user-<?php echo $admins->user_id ?>" id="event-<?php echo $eventData->id ?>">
                                                    <p>
                                                        — <?php _e('Convertir en miembro', 'buddypress'); ?>
                                                    </p>
                                                </span>
                                                <?php
                                            }
                                            ?>
                                    </h5>
                                    <div id="user-info-event" style="display: none;">
                                        <?php _e('este usuario ya no esta administrador del evento', 'buddypress')?>
                                    </div>
                            </li>
                            <?php
                        }
                        ?>
                        
                    </ul>
                </div>
            
            <div class="bp-widget">
                <h4>
                    <?php _e('Usuarios', 'buddypress'); ?>
                </h4>
                <?php
                if (count($eventUsers) >= 1) {
                    ?>
                    
                    <ul id="members-list" class="item-list single-line">
                        <?php
                        foreach ($eventUsers as $users) {
                            ?>
                            <li class="event-user-<?php echo $users->user_id ?>" style=" margin: 0; width: 230px; ">
                            <?php echo bp_core_fetch_avatar( array( 'item_id' => $users->user_id, 'type' => $avatar_size, 'width' => 32, 'height' => 32 ) ) ?>
                                    <h5>
                                        <a href="<?php echo bp_core_get_user_domain( $users->user_id )  ?>" title="<?php echo bp_core_get_user_displayname( $users->user_id )?>">
                                            <?php echo bp_core_get_user_displayname( $users->user_id )?>
                                        </a>
                                        <div id="users-options">
                                            <span class="user-banned-<?php echo $users->user_id ?>" id="event-<?php echo $eventData->id ?>">
                                                    <?php _e('Expulsar', 'buddypress'); ?>
                                            </span>
                                            <span class="user-admin-<?php echo $users->user_id ?>" id="event-<?php echo $eventData->id ?>">
                                                    | <?php _e('Convertir en admin', 'buddypress'); ?>
                                            </span>
                                        </div>
                                    </h5>
                                    <div id="user-info-event-banned" style="display: none;">
                                        <?php _e('este usuario a sido baneado', 'buddypress')?>
                                    </div>
                                    <div id="user-info-event-admin" style="display: none;">
                                        <?php _e('este usuario ahora es administrador del evento', 'buddypress')?>
                                    </div>
                            </li>
                            <?php
                        }
                        ?>
                        
                    </ul>
                    
                    <?php
                } else {
                    ?>
                        <div id="message" class="info">
                            <p>
                                <?php _e('Este evento no tiene miembros.', 'buddypress'); ?>
                            </p>
                        </div>
                    <?php
                }
                ?>
            </div>
            
            <div class="bp-widget">
                
                <h4>
                    <?php _e('Usuarios banados', 'buddypress'); ?>
                </h4>
                <?php
                if (count($eventBanned) >= 1 ) {
                    ?>
                    <ul id="banned-list" class="item-list single-line" style="list-style: none;">
                        <?php
                        foreach ($eventBanned as $banneds) {
                            ?>
                            <li class="event-user-<?php echo $banneds->user_id ?>" style=" margin: 0; width: 230px; ">
                            <?php echo bp_core_fetch_avatar( array( 'item_id' => $banneds->user_id, 'type' => $avatar_size, 'width' => 32, 'height' => 32 ) ) ?>
                                    <h5>
                                        <a href="<?php echo bp_core_get_user_domain( $banneds->user_id )  ?>" title="<?php echo bp_core_get_user_displayname( $banneds->user_id )?>">
                                            <?php echo bp_core_get_user_displayname( $banneds->user_id )?>
                                        </a>
                                        <div id="users-options">
                                            <span class="user-banned-<?php echo $banneds->user_id ?>" id="event-<?php echo $eventData->id ?>">
                                                    <?php _e('Quitar baneo', 'buddypress'); ?>
                                            </span>
                                        </div>
                                    </h5>
                                    <div id="user-info-event-banned" style="display: none;">
                                        <?php _e('este usuario ya no esta baneado', 'buddypress')?>
                                    </div>
                            </li>
                            <?php
                        }
                        ?>
                        
                    </ul>
                    
                    <?php
                } else {
                    ?>
                        <div id="message" class="info">
                            <p><?php _e('Este evento no tiene usuarios baneados.', 'buddypress'); ?></p>
                        </div>
                    <?php
                }
                ?>
            </div>
            
            
            <div class="bp-widget">
                
                <h4>
                    <?php _e('Usuarios a espera de confirmacion', 'buddypress'); ?>
                </h4>
                <?php
                if (count($eventInvited) >= 1 ) {
                    ?>
                    <ul id="banned-list" class="item-list single-line" >
                        <?php
                        foreach ($eventInvited as $inviteds) {
                            ?>
                            <li class="event-user-<?php echo $inviteds->user_id ?>" style=" margin: 0; width: 230px; ">
                            <?php echo bp_core_fetch_avatar( array( 'item_id' => $inviteds->user_id, 'type' => $avatar_size, 'width' => 32, 'height' => 32 ) ) ?>
                                <h5>
                                    <a href="<?php echo bp_core_get_user_domain( $inviteds->user_id )  ?>" title="<?php echo bp_core_get_user_displayname( $inviteds->user_id )?>">
                                        <?php echo bp_core_get_user_displayname( $inviteds->user_id )?>
                                    </a>
                                </h5>
                            </li>
                            <?php
                        }
                        ?>
                    </ul>
                    
                    <?php
                } else {
                    ?>
                    <div id="message" class="info">
                        <p><?php _e('Este evento no tiene usuarios con invitacion enviada.', 'buddypress'); ?></p>
                    </div>
                    <?php
                }
                ?>
            </div>
            
        </div><!-- #item-body -->

        </div>
    
    </div><!-- #content-middle -->
    
    <div id="content-bottom"></div>
    
</div><!-- .padder -->