<?php $T_EQI = v('T_EQI', true);
$Equipe = v('Equipe');
$champs = array();

if ($Equipe['EQI_ETAT'] != 5) {
    $champs['EQI_ETAT'] = zk_etat_equipe($Equipe['EQI_ETAT']);
}
$champs += array(
    'EQI_JEU' => zk_jeu($Equipe['EQI_JEU']),
    'EQI_TAG',
    'EQI_LOC',
    'EQI_SLOGAN',
    'EQI_DESC',
    'EQI_URL' => !empty($Equipe['EQI_URL']) ? href($Equipe['EQI_URL'], array('url' => $Equipe['EQI_URL'], 'target' => '_blank'), true):'',
    'EQI_CONTACT' => !empty($Equipe['EQI_CONTACT']) ? '<a href="mailto:' . $Equipe['EQI_CONTACT'] . '
                                             title="contacter par mail"
                                             target="_blank">' . $Equipe['EQI_CONTACT'] . '</a>':''
);

?>


<div class="row">
    <div id="side_equipe" class="span2">
        <?php echo $Equipe['EQI_ETAT'] == 5 ? zk_aff_logo_j($T_EQI[0]['JOU_CLE']) : zk_aff_logo_eq($Equipe['EQI_LOGO']); ?>

        <?php if (is_logued() && $Equipe['EQI_ETAT'] == 5) { ?>
        <div id="action-bar">
            <?php echo href('<i class="icon-envelope icon-white"></i> ' . __('com.action.mp'), array('controleur' => 'messagerie', 'action' => 'ecrire', 'params' => $T_EQI[0]['JOU_CLE'], 'class' => 'awesome awesome-small green ajax btn btn-success btn-small ajax')); ?>
        </div>
        <?php } ?>

        <table class="table">


            <?php
            foreach ($champs as $k => $champ) {

                $valeur = is_numeric($k) ? @$Equipe[$champ] : $champ;
                $valeur = trim($valeur);
                $k = is_numeric($k) ? $champ : $k;
                if (!empty($valeur)) {
                    ?>
                    <tr>
                        <td class="champ-cle"><?php echo __('com.champ.' . $k); ?></td>
                    </tr>
                    <tr>
                        <td class="champ-valeur"><?php echo $valeur; ?></td>
                    </tr>
                    <?php
                }
            }
            ?>


        </table>
    </div>
    <div class="span6" id="infos-joueur">

        <div id="nom-joueur">
            <?php echo zk_equipe($Equipe); ?>
            <?php echo do_action('front.profil.equipe.titre', $Equipe); ?>
            <small>#<?php echo $Equipe['EQI_CLE']; ?></small>
        </div>

        <ul class="nav nav-tabs">
            <?php if (OPT_MUR_EQUIPE) { ?>
            <li><a href="#mur" data-toggle="tab">Mur</a></li>
            <?php } ?>
            <li><a href="#joueurs" data-toggle="tab">Joueurs</a></li>
            <li><a href="#competitions" data-toggle="tab">Competitions</a></li>
        </ul>

        <div class="tab-content">
            <?php if (OPT_MUR_EQUIPE) { ?>
            <div class="tab-pane" id="mur">
                <?php mur('EQI', $Equipe['EQI_CLE']); ?>
            </div>
            <?php } ?>
            <div class="tab-pane" id="joueurs">
                <table class="profil table" cellpadding="0" cellspacing="0">
                    <?php
                    $ancien_poste = '';
                    foreach ($T_EQI as $UN_JOU) {
                        if ($UN_JOU['JOU_CLE'] == null) {
                            continue;
                        }
                        ?><tr <?php echo diff_jours($UN_JOU['JOU_DATE_AJ'], date('Y-m-d')) <= OPT_ALERTE_INSCRIPTION ? ' class="alerte"' : ''; ?>>
                              <?php if ($ancien_poste == '' || $ancien_poste != $UN_JOU['JOU_POSTE']) {
                            echo '<td class="g">';
                            echo zk_poste_joueur($UN_JOU['JOU_POSTE']);
                            $ancien_poste = $UN_JOU['JOU_POSTE'];

                        } else {
                            echo '<td class="g">&nbsp;</td>';
                        }
                        echo '<td class="d">' . zk_joueur($UN_JOU) . '</td>';
                        echo '<td>' . $UN_JOU['JOU_LIC'] . '</td>';
                        if (preg_match("/^STEAM/", $UN_JOU['JOU_LIC'])) {
                            ?>
                            <td style="text-align:right">
                                <form method="post" action="http://www.vacbanned.com/engine/check" target="_blank">
                                    <input type="hidden" name="qsearch"
                                           value="<?php echo strip_tags($UN_JOU['JOU_LIC']); ?>"/>
                                    <input type="image" value="submit"
                                           src="<?php echo WWW_WEBROOT . 'images/icons/search_icon.png'; ?>"/>
                                </form>
                            </td>
                            <?php
                        } else {
                            ?>
                            <td>&nbsp;</td><?php
                        }

                        echo '</tr>';
                    } ?>
                </table>
            </div>
            <div class="tab-pane" id="competitions">
                <?php
                foreach (v('Tournois') as $TNS_JEU => $Tournois) {
                    ?>
                    <h2><?php echo zk_jeu($TNS_JEU); ?></h2>
                    <ul class="listeTournois"><?php
                        foreach ($Tournois as $UN_TNS) {
                            $UN_TNS['TNS_NOM'] = strlen($UN_TNS['TNS_NOM']) > OPT_BLOC_COMP_MAX_CAR ? substr($UN_TNS['TNS_NOM'], 0, OPT_BLOC_COMP_MAX_CAR) . ' ..' : $UN_TNS['TNS_NOM'];
                            ?>
                            <li><?php echo href(zk_jeu($UN_TNS['TNS_JEU'], false) . ' ' . $UN_TNS['TNS_NOM'], array('controleur' => 'Tournoi', 'action' => 'voir', 'params' => $UN_TNS['TNS_CLE'])); ?></li><?php
                        }
                        ?></ul><?php
                }
                ?>
            </div>


        </div>
    </div>
</div>
<script type="text/javascript">
    $(function(){
       $(".nav-tabs li:first-child").addClass('active');
       $(".tab-content div:first-child").addClass('active');
    });
</script>

<?php /*

<div style="display: none;">
<div id="side_equipe">
    <?php echo $Equipe['EQI_ETAT'] == 5 ? zk_aff_logo_j($T_EQI[0]['JOU_CLE']) : zk_aff_logo_eq($Equipe['EQI_LOGO']); ?>
</div>
<div id="content_equipe">

<div id="tabs">
<ul id="mes-tabs">
    <li><a href="#tabs-resume">Infos</a></li>
    <li><a href="#tabs-joueurs" title="tabs-joueurs"><?php echo __('com.txt.joueurs'); ?></a></li>
    <?php if (OPT_MUR_EQUIPE) { ?>
    <li><a href="#tabs-mur" title="tabs-mur">Mur</a></li><?php } ?>
    <li><a href="#tabs-competitions" title="tabs-competitions"><?php echo __('com.bloc.tournois'); ?></a>
    </li>
    <li><a href="#tabs-matchs" title="tabs-matchs"><?php echo __('com.bloc.matchs'); ?></a></li>
</ul>

<div id="tabs-resume">
    <table class="profil" cellpadding="0" cellspacing="0" align="left">
        <tr>
            <td colspan="4" class="caption">
                <?php echo zk_equipe($Equipe); ?>
                <small>#<?php echo $Equipe['EQI_CLE']; ?></small>
                <?php if (is_logued() && $Equipe['EQI_ETAT'] == 5) { ?>
                <div class="right"><?php echo href(__('com.action.mp'), array('controleur' => 'messagerie', 'action' => 'ecrire', 'params' => $T_EQI[0]['JOU_CLE'], 'class' => 'awesome awesome-small green ajax')); ?></div>
                <?php } ?>
                <?php echo do_action('front.profil.equipe.titre', $Equipe); ?>
            </td>
        </tr>

        <?php


        if (isset($Equipe['EQI_TAG']) && $Equipe['EQI_TAG'] != '') {
            ?>
            <tr>
                <td class="g"><?php echo __('com.eq.tag'); ?></td>
                <td class="d" colspan="3"><?php echo $Equipe['EQI_TAG']; ?></td>
            </tr>
            <?php } ?>

        <?php if (isset($Equipe['EQI_LOC']) && $Equipe['EQI_LOC'] != '') { ?>
        <tr>
            <td class="g"><?php echo __('com.txt.lieu'); ?></td>
            <td class="d"
                colspan="3"><?php echo pays($Equipe['EQI_PAYS']) . ' ' . $Equipe['EQI_LOC']; ?></td>
        </tr>
        <?php } ?>

        <?php if ($Equipe['EQI_ETAT'] != 5) { ?>
        <tr>
            <td class="g"><?php echo __('com.txt.jeu'); ?></td>
            <td class="d" colspan="3"><?php echo zk_jeu($Equipe['EQI_JEU']); ?></td>
        </tr>
        <?php } ?>

        <?php if (isset($Equipe['EQI_URL']) && $Equipe['EQI_URL'] != '') { ?>
        <tr>
            <td class="g"><?php echo __('com.txt.url'); ?></td>
            <td class="d"
                colspan="3"><?php echo href($Equipe['EQI_URL'], array('url' => $Equipe['EQI_URL'], 'target' => '_blank'), true); ?></td>
        </tr>
        <?php } ?>



        <?php if (isset($Equipe['EQI_SLOGAN']) && $Equipe['EQI_SLOGAN'] != '') { ?>
        <tr>
            <td class="g"><?php echo __('com.txt.slogan'); ?></td>
            <td class="d" colspan="3"><?php echo $Equipe['EQI_SLOGAN']; ?></td>
        </tr>
        <?php } ?>



        <?php if (isset($Equipe['EQI_CONTACT']) && $Equipe['EQI_CONTACT'] != '') { ?>
        <tr>
            <td class="g"><?php echo __('com.txt.contact'); ?></td>
            <td class="d" colspan="3"><a href="mailto:<?php echo $Equipe['EQI_CONTACT']; ?>"
                                         title="contacter par mail"
                                         target="_blank"><?php echo $Equipe['EQI_CONTACT']; ?></a>&nbsp;
            </td>
        </tr>
        <?php } ?>


        <?php
        if (isset($Equipe['EQI_DESC']) && $Equipe['EQI_DESC'] != '') {
            ?>
            <tr>
                <td colspan="2"><?php echo $Equipe['EQI_DESC']; ?>&nbsp;</td>
            </tr>
            <?php
        }
        ?>


    </table>
</div>

<div id="tabs-joueurs" class="ui-tabs-hide">
    <h2><?php echo __('com.txt.joueurs'); ?></h2>
    <table class="profil" cellpadding="0" cellspacing="0" align="left">
        <?php
        $ancien_poste = '';
        foreach ($T_EQI as $UN_JOU) {
            if ($UN_JOU['JOU_CLE'] == null) {
                continue;
            }
            ?><tr <?php echo diff_jours($UN_JOU['JOU_DATE_AJ'], date('Y-m-d')) <= OPT_ALERTE_INSCRIPTION ? ' class="alerte"' : ''; ?>>
            <?php if ($ancien_poste == '' || $ancien_poste != $UN_JOU['JOU_POSTE']) {
                echo '<td class="g">';
                echo zk_poste_joueur($UN_JOU['JOU_POSTE']);
                $ancien_poste = $UN_JOU['JOU_POSTE'];

            } else {
                echo '<td class="g">&nbsp;</td>';
            }
            echo '<td class="d">' . zk_joueur($UN_JOU) . '</td>';
            echo '<td>' . $UN_JOU['JOU_LIC'] . '</td>';
            if (preg_match("/^STEAM/", $UN_JOU['JOU_LIC'])) {
                ?>
                <td style="text-align:right">
                    <form method="post" action="http://www.vacbanned.com/engine/check" target="_blank">
                        <input type="hidden" name="qsearch"
                               value="<?php echo strip_tags($UN_JOU['JOU_LIC']); ?>"/>
                        <input type="image" value="submit"
                               src="<?php echo WWW_WEBROOT . 'images/icons/search_icon.png'; ?>"/>
                    </form>
                </td>
                <?php
            } else {
                ?>
                <td>&nbsp;</td><?php
            }

            echo '</tr>';
        } ?>
    </table>
</div>

<div id="tabs-competitions" class="ui-tabs-hide">
    <?php
    foreach (v('Tournois') as $TNS_JEU => $Tournois) {
        ?>
        <h2><?php echo zk_jeu($TNS_JEU); ?></h2>
        <ul class="listeTournois"><?php
            foreach ($Tournois as $UN_TNS) {
                $UN_TNS['TNS_NOM'] = strlen($UN_TNS['TNS_NOM']) > OPT_BLOC_COMP_MAX_CAR ? substr($UN_TNS['TNS_NOM'], 0, OPT_BLOC_COMP_MAX_CAR) . ' ..' : $UN_TNS['TNS_NOM'];
                ?>
                <li><?php echo href(zk_jeu($UN_TNS['TNS_JEU'], false) . ' ' . $UN_TNS['TNS_NOM'], array('controleur' => 'Tournoi', 'action' => 'voir', 'params' => $UN_TNS['TNS_CLE'])); ?></li><?php
            }
            ?></ul><?php
    }
    ?>
</div>

<div id="tabs-matchs" class="ui-tabs-hide">
    <h2><?php echo __('com.bloc.matchs'); ?></h2>

    <?php

    $html = '';
    foreach (v('Matchs') as $TNS_JEU => $Competitions) {
        $html .= '<h2>' . zk_jeu($TNS_JEU) . '</h2>';
        foreach ($Competitions as $TNS_NOM => $Matchs) {
            $html .= '<table class="listeMatchs listeMatchsProfil" border="0" cellspacing="0" cellpadding="0">';
            $html .= '<tr><th colspan="5"><h3>' . $TNS_NOM . '</h3></th></tr>';

            foreach ($Matchs as $UN_MAT) {
                $c1 = null;
                $c2 = null;

                $eq1 = array('EQI_CLE' => $UN_MAT['EQI_CLE1'], 'EQI_TAG' => $UN_MAT['EQI_TAG1'], 'EQI_NOM' => $UN_MAT['EQI_NOM1']);
                $eq2 = array('EQI_CLE' => $UN_MAT['EQI_CLE2'], 'EQI_TAG' => $UN_MAT['EQI_TAG2'], 'EQI_NOM' => $UN_MAT['EQI_NOM2']);

                if ($UN_MAT['MAT_ETAT'] == 0) {
                    $UN_MAT['EQI_S1'] = '&nbsp;';
                    $UN_MAT['EQI_S2'] = '&nbsp;';
                } else {
                    $c1 = $UN_MAT['EQI_S1'] != '' && $UN_MAT['EQI_S2'] != '' ? ($UN_MAT['EQI_S1'] == $UN_MAT['EQI_S2'] ? 'egalite' : ($UN_MAT['EQI_S1'] > $UN_MAT['EQI_S2'] ? 'gagnant' : 'perdant')) : '';
                    $c2 = $UN_MAT['EQI_S1'] != '' && $UN_MAT['EQI_S2'] != '' ? ($UN_MAT['EQI_S1'] == $UN_MAT['EQI_S2'] ? 'egalite' : ($UN_MAT['EQI_S1'] < $UN_MAT['EQI_S2'] ? 'gagnant' : 'perdant')) : '';
                }

                $html .= '
                        <tr>
                            <td class="eq d">' . zk_eq_tn($eq1) . '</td>';
                if (OPT_CACHER_SCORE_BLOC_MATCHS === false) {
                    $html .= $UN_MAT['MAT_ETAT'] >= 1 ? '
                            <td class="s ' . $c1 . '">' . $UN_MAT['EQI_S1'] . '</td>
                            <td class="s ' . $c2 . '">' . $UN_MAT['EQI_S2'] . '</td>' : '<td class="vs" colspan="2">vs</td>';
                } else {
                    $html .= $UN_MAT['MAT_ETAT'] >= 1 ? '
                            <td class="ss ' . $c1 . '">&nbsp;</td>
                            <td class="ss ' . $c2 . '">&nbsp;</td>' : '<td class="vs" colspan="2">vs</td>';
                }
                $html .= '
                            <td class="eq g">' . zk_eq_tn($eq2) . '</td>
                            <td class="infos">' . href(img('icons/bullet_go.png', 'plus d\'informations'), array('controleur' => 'Tournoi', 'action' => 'voir', 'params' => $UN_MAT['TNS_CLE']), false, false, true, true, 'tabs-matchs') . '</td>
                        </tr>';
            }
            $html .= '</table>';
        }

    }

    echo $html;

    ?>
    <div class="clean">&nbsp;</div>
</div>

<?php mur('EQI', $Equipe['EQI_CLE']); ?>

</div>
</div>

<script type="text/javascript">
    $(function () {
        $("#tabs").tabs();
    });
</script>
<hr class="espace"/>
</div>

 */
?>