<?php
defined('BASEPATH') OR exit('No direct script access allowed');
?>
<main>

</main>
<body>
<br>


<div class="row">
    <div class="col s12 xl8">
        <div class="row z-depth-1 center indigo lighten-5">
            <span style="font-weight: bold"> <?php echo $text['team_info_num_teams']?></span> <br>
            <span style="font-weight: bold">  <?php echo $text['team_total_teams']?> : </span><span style="font-weight: bold;color: #251e96"><?php echo $num_teams?></span>
        </div>

        <div class="row">
            <div class="col s3"><span style="font-weight: bold"> <?php echo $text['team_team_name'] ?></span></div>
            <div class="col s3"><span style="font-weight: bold"> <?php echo $text['team_technical_director'] ?></span>
            </div>
            <!--            <div class="col s1"><span style="font-weight: bold"> --><?php //echo $text['team_country'] ?><!--</span></div>-->
            <div class="col s3"><span style="font-weight: bold"> <?php echo $text['team_autonomous_community'] ?></span>
            </div>
            <div class="col s3"><span style="font-weight: bold"> <?php echo $text['team_province'] ?></span></div>
        </div>

        <ul class="collapsible " data-collapsible="accordion">
            <?php $count = 0; ?>
            <?php foreach ($teams as $row) { ?>
                <li>
                    <?php $count++;
                    $class = $count % 2 != 0 ? 'grey lighten-2' : '';
                    ?>

                    <div class="collapsible-header <?php echo $class ?> ">
                        <div class="row">
                            <div class="col s3"> <?php echo $row->nombre ?></div>
                            <div class="col s3"> <?php echo $row->directorTecnico ?></div>
                            <!--                            <div class="col s1"> --><?php //echo $row->paisISOA3 ?><!--</div>-->
                            <div class="col s3"> <?php echo $row->autonomia ?></div>
                            <div class="col s3"> <?php echo $row->provincia ?></div>

                        </div>

                    </div>
                    <div class="collapsible-body ">
                        <form method="post" action="<?php echo base_url() ?>team/deleteTeam"
                              onsubmit=" return confirm('Estas seguro de que quieres eliminar el equipo?')">
                            <input type="hidden" name="nombreEquipo" value="<?php echo $row->nombre; ?>">

                            <div class="row">
                                <div class="col s12 xl6">

                                    <button style="width: 170px" id="delete_button"
                                            class="btn btn-neutral waves-effect red lighten-1"><?php echo $text['team_delete'] ?> <i
                                                class="material-icons right">delete</i></button>
                                </div>


                                <div class="col s12 xl6">
                                    <button onclick="return updateModal(<?php echo $count ?>)" style="width: 170px"
                                            id="delete_button" class="btn btn-neutral waves-effect indigo"> <?php echo $text['team_update'] ?><i
                                                class="material-icons right">edit</i></button>
                                </div>
                            </div>
                        </form>
                    </div>

                </li>
                <!-- Modal Structure -->
                <div id="updateTeamModal<?php echo $count; ?>" class="modal ">
                    <div class="modal-content ">
                        <div class="container">
                            <form method="post" action="<?php echo base_url() ?>team/updateTeam">
                                <div>
                                    <span style="font-weight: bold"> <?php echo $text['team_update'] ?></span>
                                </div>
                                <div class="row">
                                    <div class="input-field col s12 xl6">
                                        <input class="validate " type="text" name="nombreEquipo" id="nombreEquipo"
                                               required value="<?php echo $row->nombre ?>"/>
                                        <label for="nombre"><?php echo $text['team_team_name'] ?></label>
                                    </div>
                                    <div class="input-field col s12 xl6">
                                        <input class="validate" type="text" name="directorTecnico" id="directorTecnico"
                                               value="<?php echo $row->directorTecnico ?>"/>
                                        <label for="directorTecnico"><?php echo $text['team_technical_director'] ?></label>
                                    </div>
                                </div>
                                <div class="row">
                                    <div class="input-field col s12 xl6">
                                        <select name="pais">
                                            <option value="" disabled
                                                    selected><?php echo $text['team_country'] ?></option>
                                            <option value="ESP">España</option>
                                            <option value="ALE">Alemania</option>
                                            <option value="FRE">Francia</option>

                                        </select>
                                        <label><?php echo $text['team_country'] ?></label>
                                    </div>
                                    <div class="input-field col s12 xl6">
                                        <input class="validate" type="text" name="comunidadAutonoma"
                                               id="directorTecnico" value="<?php echo $row->autonomia ?>"/>
                                        <label for="autonomia"><?php echo $text['team_autonomous_community'] ?></label>
                                    </div>
                                    <div class="input-field col s12 xl6">
                                        <input class="validate" type="text" name="provincia" id="directorTecnico"
                                               value="<?php echo $row->provincia ?>"/>
                                        <label for="autonomia"><?php echo $text['team_province'] ?></label>
                                    </div>

                                </div>

                        </div>
                    </div>
                    <div class="modal-footer">
                        <button class="btn btn-large waves-effect indigo"><?php echo $text['team_update'] ?></button>
                    </div>
                    </form>
                </div>

            <?php } ?>
        </ul>
        <?php echo $this->pagination->create_links(); ?>
    </div>
    <div class="col s12 xl4">
        <div class="container">
            <form method="get" action="<?php echo base_url() ?>team/addTeam">
                <div>
                    <span style="font-weight: bold"> <?php echo $text['team_create_btn'] ?></span> <br>
                    <span style="font-weight:bold"> <i class="material-icons">warning</i> <?php echo $text['team_not_empty_fields'];?></span>
                </div>
                <div class="row">
                    <div class="input-field col s12">
                        <i class="material-icons prefix">create</i>
                        <input class="validate" type="text" name="nombreEquipo" id="nombreEquipo" required  maxlength="30" data-length="30"/>
                        <label for="nombre"><?php echo $text['team_team_name'] ?>(*)</label>
                    </div>
                    <div class="input-field col s12">
                        <i class="material-icons prefix">create</i>
                        <input class="validate" type="text" name="directorTecnico" id="directorTecnico" maxlength="30" data-length="30"/>
                        <label for="directorTecnico"><?php echo $text['team_technical_director'] ?></label>
                    </div>
                </div>
                <div class="row">
                    <div class="input-field col s12">
                        <i class="material-icons prefix">list</i>
                        <select name="pais">
                            <option value="" disabled selected><?php echo $text['team_country'] ?></option>
                            <option value="ESP">España</option>
                            <option value="ALE">Alemania</option>
                            <option value="FRE">Francia</option>

                        </select>
                        <label><?php echo $text['team_country'] ?></label>
                    </div>
                    <div class="input-field col s12">
                        <i class="material-icons prefix">create</i>
                        <input class="validate" type="text" name="comunidadAutonoma" id="autonomia" required maxlength="30" data-length="30"/>
                        <label for="autonomia"><?php echo $text['team_autonomous_community'] ?>(*)</label>
                    </div>
                    <div class="input-field col s12">
                        <i class="material-icons prefix">create</i>
                        <input class="validate" type="text" name="provincia" id="provincia" required maxlength="30" data-length="30"/>
                        <label for="provincia"><?php echo $text['team_province'] ?>(*)</label>
                    </div>
                   <div class="row">

                   </div>
                    <div class="col s6 offset-s6">
                        <button class="btn btn-large waves-effect indigo"><?php echo $text['team_create_btn'] ?></button>
                    </div>
                </div>
            </form>
        </div>
    </div>



</div>


</body>
