<?php
defined('BASEPATH') OR exit('No direct script access allowed');
?>
<main>
    <div class="row">

        <div class="col s12 xl1">
            <a data-activates="slide-out"
               class="button-collapse btn-floating btn waves-effect waves-light indigo "><i
                        class="material-icons">more_horiz</i></a>
        </div>



    </div>
</main>
<body>


<div class="row">
    <ul id="slide-out" class="side-nav">
        <div class="row">
            <div class="col s6 xl6">
                <table class="bordered">
                    <thead>
                    <tr>
                        <th class="center">M</th>
                    </tr>
                    </thead>
                    <tbody>

                    <?php

                    foreach ($m_weights as $m_weight) { ?>

                        <tr>
                            <td class="center">
                                <a class=" btn-large btn-block indigo center tooltipped"
                                   data-tooltip="<?php echo "Click para ver los combates del peso de menos de " . $m_weight -> descripcion. ' kg'?>"
                                   href="<?php echo base_url() ?>competition/viewcombats/<?php echo $competition -> idCompeticion?>?idWeight=<?php echo $m_weight->idPeso?>">
                                  <?php echo $m_weight->descripcion ?>
                                </a>
                            </td>
                        </tr>


                        <?php
                    } ?>
                    </tbody>
                </table>
            </div>
            <div class="col s6 xl6">
                <table class="bordered ">
                    <thead>
                    <tr>
                        <th class="center">F</th>
                    </tr>
                    </thead>
                    <tbody>
                    <?php

                    foreach ($f_weights as $f_weight) { ?>

                        <tr>
                            <td class="center">
                                <a class=" btn-large btn-block brown lighten-3 center tooltipped"
                                   data-tooltip="<?php echo "Click para ver los combates del peso de menos de " . $f_weight -> descripcion. ' kg'?>"
                                   href="<?php echo base_url() ?>competition/viewcombats/<?php echo $competition -> idCompeticion?>?idWeight=<?php echo $f_weight->idPeso?>">
                                    <?php echo $f_weight->descripcion ?>
                                </a>
                            </td>
                        </tr>


                        <?php
                    } ?>
                    </tbody>
                </table>
            </div>
        </div>
        <div class="row ">
            <form action="<?php echo base_url()?>combat/create_combats/<?php echo $competition -> idCompeticion?> " method="post">
                <input type="hidden" name="idWeight" value="<?php echo $this -> input -> get('idWeight')?>">
                <div class="col s12">
                    <div class="input-field col s12">
                        <select name="tipoSorteo">
                            <option value="" disabled selected><?php echo $text_lateral_nav['nav_lateral_select_algorithm']?></option>
                            <option value="1"><?php echo $text_lateral_nav['nav_lateral_league']?></option>
                            <option value="2"><?php echo $text_lateral_nav['nav_lateral_random']?></option>

                        </select>
                        <label><?php echo $text_lateral_nav['nav_lateral_type_of_pairing']?></label>
                    </div>
                </div>
                <div class="col s12 input-field ">
                    <button class="btn  large waves-effect indigo tooltipped" data-tooltip="<?php echo $text_lateral_nav['nav_lateral_tooltip_generate']?>" >
                        <?php echo $text_lateral_nav['nav_lateral_btn_generate']?>
                    </button>
                </div>
            </form>
        </div>
        <div class="row">
            <div class="col s12">
                <div class="collection">
                    <a href="<?php echo base_url() ?>referee_inscription/<?php echo $competition->idCompeticion ?>"
                       class="collection-item indigo-text"><?php echo $text_lateral_nav['nav_lateral_competition_referee_inscription']; ?><i class="material-icons right">visibility</i></a>
                    <a href="<?php echo base_url() ?>competitor_inscription/<?php echo $competition->idCompeticion ?>"
                       class="collection-item  indigo-text"><?php echo $text_lateral_nav['nav_lateral_competition_competitor_inscription'];?>
                        <i class="material-icons right">visibility</i>
                    </a>
                    <a href="<?php echo base_url() ?>viewcompetition/<?php echo $competition->idCompeticion ?>"
                       class="active collection-item indigo"> <?php echo $text_lateral_nav['nav_lateral_competition_combats']; ?>

                    </a>

                </div>
            </div>


        </div>

    </ul>
</div>

<div class="row">


    <div class="row">
        <div class="col s12 xl4">
            <div class="center"><span style="font-weight: bold"><?php echo $combats_text['combat_list_combats_without_score']?></span>

            </div>
<?php $number_of_combats = sizeof($combats )?>
            <?php foreach ($combats as $combat){ ?>
                <?php if($combat -> ippon_w == null) { ?>


            <ul class="collapsible" data-collapsible="accordion">
                <li>
                    <div class="collapsible-header ">
                        <div class="row">
                            <div class="col s8">
                                <span style="font-weight: bold">[Fase : <?php echo $combat -> fase?>]</span>
                            </div>
                            <div class="col s2">
                                <a
                                        onclick=" return infoReferees('<?php echo $combat -> dni_w?>',
                                                '<?php echo $combat -> dni_b?>',
                                                '<?php echo $competition -> idCompeticion?>',
                                                ' <?php echo $combat -> idTatami?>',
                                                '<?php echo base_url()?>combat/getReferees')"

                                        class=" waves-light  right lighten-2 tooltipped " data-tooltip="<?php echo "Click para ver la informacion para ver los árbitros disponibles"?>">
                                    <i class="material-icons right">info</i>
                                </a>

                            </div>
                            <div class=" col s2">
                                <a
                                        onclick=" return deleteCombat('<?php echo $combat-> idCombate?>','<?php echo $combat -> dni_w?>','<?php echo $combat -> dni_b?>','<?php echo $competition -> idCompeticion?>','<?php echo $this -> input -> get ('idWeight')?>')"

                                        class=" waves-light  right lighten-2 tooltipped" data-tooltip="<?php echo $combats_text['combat_toast_msg_delete_combat']?>">
                                    <i class="material-icons  ">delete</i></a>
                            </div>

                            <div class="col s6">
                                <?php echo $combat -> nombre_w .',' . $combat -> apellido1_w .' '. $combat -> apellido2_w .'('. $combat -> dni_w .')'?>
                            </div>
                            <div class="col s6 indigo lighten-3">
                                <?php echo $combat -> nombre_b .',' . $combat -> apellido1_b .' '. $combat -> apellido2_b .'('. $combat -> dni_b .')'?>
                            </div>
                        </div>
                    </div>
                    <div class="collapsible-body">
                        <div class="row">

                            <form action="<?php echo base_url()?>score/addScore/<?php echo $combat -> idCombate?>" method="post">
                                <input type="hidden" name="dniWhite" value="<?php echo $combat -> dni_w?>">
                                <input type="hidden" name="dniBlue" value="<?php echo $combat -> dni_b?>">
                                <input type="hidden" name="idCompetition" value="<?php echo $competition -> idCompeticion?>">
                                <input type="hidden" name="idWeight" value="<?php echo $this -> input -> get('idWeight')?>">
                            <div class="col s12">
                               <div class="row">
                                   <div class="col s3"> I </div>
                                   <div class="col s3"> W </div>
                                   <div class="col s3"> S </div>
                                   <div class="col s3"> H </div>
                               </div>
                                <div class="row">

                                        <div class="input-field col s3">
                                            <input type="number" min ="0" max="1" name="ippon_white">
                                        </div>
                                        <div class="input-field col s3">
                                            <input type="number" min ="0" max="1" name="wazari_white">
                                        </div>
                                        <div class="input-field col s3">
                                            <input type="number" min ="0" max="2" name="shido_white">
                                        </div>
                                        <div class="input-field col s3">
                                            <input type="number" min ="0" max="1" name="hansoku_white">
                                        </div>


                                </div>
                            </div>
                            <div class="col s12 indigo lighten-3">
                                <div class="row ">
                                    <div class="col s3"> I </div>
                                    <div class="col s3"> W </div>
                                    <div class="col s3"> S </div>
                                    <div class="col s3"> H </div>
                                </div>
                                <div class="row ">

                                    <div class="input-field col s3">
                                        <input type="number" min ="0" max="1" name="ippon_blue">
                                    </div>
                                    <div class="input-field col s3">
                                        <input type="number" min ="0" max="1" name="wazari_blue">
                                    </div>
                                    <div class="input-field col s3">
                                        <input type="number" min ="0" max="2" name="shido_blue">
                                    </div>
                                    <div class="input-field col s3">
                                        <input type="number" min ="0" max="1" name="hansoku_blue">
                                    </div>


                                </div>
                            </div>


                        </div>
                        <div class="row">

                            <div class="col s12 xl4 offset-xl8">
                                <button class="btn btn-large waves-effect indigo"><?php echo $combats_text['combat_modal_btn_add_score']?></button>
                            </div>
                        </div>


                        </form>
                        <div class="row">
                            <form  action="<?php echo base_url()?>combat/updateMat" method="post">
                                <input type="hidden" name="idCombat" value="<?php echo $combat -> idCombate?>">
                                <input type="hidden" name="idWeight" value="<?php echo $this -> input -> get('idWeight')?>">
                                <input type="hidden" name="idCompetition" value="<?php echo $competition -> idCompeticion?>">
                                <div class="input-field col s12 xl4 offset-xl8 z-depth-3 brown lighten-3" >

                                    <select name="mat" onchange="this.form.submit();">
                                        <option value="" disabled selected>Choose your option</option>
                                        <?php foreach ($mats as $mat){?>
                                            <option value="<?php echo $mat -> idTatami?>" <?php echo $combat -> idTatami == $mat -> idTatami ? 'selected' : null?>><?php echo $mat -> numero?></option>
                                        <?php } ?>
                                    </select>
                                    <label><?php echo $combats_text['combat_modal_change_mat']?></label>
                                </div>
                            </form>
                        </div>

                    </div>

                </li>

            </ul>
                <?php } ?>
            <?php }?>
            <div class="col s2 offset-s10">
                <a class="waves-effect waves-light btn-floating modal-trigger indigo tooltipped" data-tooltip="<?php echo $combats_text['combat_toast_msg_create_combat']?>" href="#create_combat"><i
                            class="material-icons">add</i></a>
            </div>

        </div>

        <div class="col s12 xl4">

            <div class="center"><span style="font-weight: bold"><?php echo $combats_text['combat_list_with_score']?></span></div>
            <?php foreach ($combats as $combat){ ?>
                <?php if($combat -> ippon_w != null) { ?>


                    <ul class="collapsible" data-collapsible="accordion">
                        <li>
                            <div class="collapsible-header ">
                                <div class="row">
                                    <div class="col s8">
                                        <span style="font-weight: bold">[Fase : <?php echo $combat -> fase?>]</span>
                                    </div>
                                    <!--                            <div class="col s4">-->
                                    <!--                                <a-->
                                    <!--                                        onclick=" return deleteCombat('--><?php //echo $combats[$i]-> idCombate?><!--','--><?php //echo $combats[$i] -> dniCompetidor?><!--','--><?php //echo $combats[$i + 1] -> dniCompetidor?><!--')"-->

                                    <!--                                        class=" waves-light btn red lighten-2">-->
                                    <!--                                    <i class="material-icons right">delete</i></a>-->

                                    <!--                            </div>-->
                                    <div class="col s4">
                                        <a
                                                onclick=" return deleteCombat('<?php echo $combat-> idCombate?>','<?php echo $combat -> dni_w?>','<?php echo $combat -> dni_b?>','<?php echo $competition -> idCompeticion?>','<?php echo $this -> input -> get ('idWeight')?>')"

                                                class=" waves-light  right lighten-2 tooltipped" data-tooltip="<?php echo $combats_text['combat_toast_msg_delete_combat']?>">
                                            <i class="material-icons  ">delete</i></a>

                                    </div>
                                    <div class="col s6">
                                        <?php echo $combat -> nombre_w .',' . $combat -> apellido1_w .' '. $combat -> apellido2_w .'('. $combat -> dni_w .')'?>
                                    </div>
                                    <div class="col s6 indigo lighten-3">
                                        <?php echo $combat -> nombre_b .',' . $combat -> apellido1_b .' '. $combat -> apellido2_b .'('. $combat -> dni_b .')'?>
                                    </div>
                                </div>
                            </div>
                            <div class="collapsible-body">
                                <div class="row">

                                    <form action="<?php echo base_url()?>score/addScore/<?php echo $combat -> idCombate?>" method="post">
                                        <input type="hidden" name="dniWhite" value="<?php echo $combat -> dni_w?>">
                                        <input type="hidden" name="dniBlue" value="<?php echo $combat -> dni_b?>">
                                        <input type="hidden" name="idCompetition" value="<?php echo $competition -> idCompeticion?>">
                                        <input type="hidden" name="idWeight" value="<?php echo $this -> input -> get('idWeight')?>">
                                        <div class="col s12">
                                            <div class="row">
                                                <div class="col s3"> I </div>
                                                <div class="col s3"> W </div>
                                                <div class="col s3"> S </div>
                                                <div class="col s3"> H </div>
                                            </div>
                                            <div class="row">

                                                <div class="input-field col s3">
                                                    <input type="number" min ="0" max="1" name="ippon_white" value="<?php echo $combat -> ippon_w?>">
                                                </div>
                                                <div class="input-field col s3">
                                                    <input type="number" min ="0" max="1" name="wazari_white" value="<?php echo $combat -> waza_ari_w?>">
                                                </div>
                                                <div class="input-field col s3">
                                                    <input type="number" min ="0" max="2" name="shido_white" value="<?php echo $combat -> shido_w?>">
                                                </div>
                                                <div class="input-field col s3">
                                                    <input type="number" min ="0" max="1" name="hansoku_white" value="<?php echo $combat -> hansokumake_w?>">
                                                </div>


                                            </div>
                                        </div>
                                        <div class="col s12 indigo lighten-3">
                                            <div class="row ">
                                                <div class="col s3"> I </div>
                                                <div class="col s3"> W </div>
                                                <div class="col s3"> S </div>
                                                <div class="col s3"> H </div>
                                            </div>
                                            <div class="row ">

                                                <div class="input-field col s3">
                                                    <input type="number" min ="0" max="1" name="ippon_blue" value="<?php echo $combat -> ippon_b?>">
                                                </div>
                                                <div class="input-field col s3">
                                                    <input type="number" min ="0" max="1" name="wazari_blue" value="<?php echo $combat -> waza_ari_b?>">
                                                </div>
                                                <div class="input-field col s3">
                                                    <input type="number" min ="0" max="2" name="shido_blue" value="<?php echo $combat -> shido_b?>">
                                                </div>
                                                <div class="input-field col s3">
                                                    <input type="number" min ="0" max="1" name="hansoku_blue" value="<?php echo $combat -> hansokumake_b?>">
                                                </div>


                                            </div>
                                        </div>


                                </div>
                                <div class="row">

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

                                </form>
                            </div>
                        </li>

                    </ul>
                <?php } ?>
            <?php }?>
        </div>

        <div class="col s12 xl4 center ">
            <span style="font-weight: bold"> <?php echo $combats_text['combat_results']?> : </span>
            <table class="bordered  center">
                <thead>
                <tr>
                    <th></th>
                    <th><?php echo $combats_text['combat_name']?></th>
                    <th><?php echo $combats_text['combat_surname']?></th>
                    <th><?php echo $combats_text['combat_surname2']?></th>
                    <th><?php echo $combats_text['combat_team_name']?></th>
                </tr>
                </thead>

                <tbody>
                <tr class="tooltipped" data-tooltip="<?php echo $combats_text['combat_winner']?>" onclick="introducirPuntuacion(1)">
                    <?php $number_competitors = sizeof($competitors_position); ?>
                    <?php $count = 0; ?>
                    <?php foreach ($competitors_position as $cp){?>
                        <?php if($cp -> puesto == 1){?>
                            <td class="amber lighten-4"><span style="font-weight: bold">1</span></td>
                            <td> <?php  echo $cp ->nombre ?></td>
                            <td><?php  echo $cp ->apellido1 ?></td>
                            <td><?php  echo $cp ->apellido2 ?></td>
                            <td><?php  echo $cp ->nombreEquipo ?></td>
                        <?php }else {
                            $count ++;
                        }?>
                        <?php if($count == $number_competitors){?>
                            <td class="amber lighten-4"><span style="font-weight: bold">1</span></td>
                            <td></td>
                            <td></td>
                            <td></td>
                            <td></td>
                        <?php }?>
                    <?php }?>

                </tr>
                <tr class="tooltipped" data-tooltip="<?php echo $combats_text['combat_2']?>" onclick="introducirPuntuacion(2)">
                    <?php $count = 0; ?>
                    <?php foreach ($competitors_position as $cp){?>
                        <?php if($cp -> puesto == 2){?>
                            <td class="grey lighten-2"><span style="font-weight: bold">2</span></td>
                            <td> <?php  echo $cp ->nombre ?></td>
                            <td><?php  echo $cp ->apellido1 ?></td>
                            <td><?php  echo $cp ->apellido2 ?></td>
                            <td><?php  echo $cp ->nombreEquipo ?></td>
                        <?php }else {
                            $count ++;
                        }?>
                        <?php if($count == $number_competitors){?>
                            <td class="grey lighten-4"><span style="font-weight: bold">2</span></td>
                            <td></td>
                            <td></td>
                            <td></td>
                            <td></td>
                        <?php }?>
                    <?php }?>
                </tr>
                <tr class="tooltipped" data-tooltip="<?php echo $combats_text['combat_3']?>" onclick="introducirPuntuacion(3)">

                    <?php $count = 0; ?>
                    <?php foreach ($competitors_position as $cp){?>
                        <?php if($cp -> puesto == 3){?>
                            <td class="brown lighten-2"><span style="font-weight: bold">3</span></td>
                            <td> <?php  echo $cp ->nombre ?></td>
                            <td><?php  echo $cp ->apellido1 ?></td>
                            <td><?php  echo $cp ->apellido2 ?></td>
                            <td><?php  echo $cp ->nombreEquipo ?></td>
                        <?php }else {
                            $count ++;
                        }?>
                        <?php if($count == $number_competitors){?>
                            <td class="brown lighten-2"><span style="font-weight: bold">3</span></td>
                            <td></td>
                            <td></td>
                            <td></td>
                            <td></td>
                        <?php }?>
                    <?php }?>

                </tr>
                <tr class="tooltipped" data-tooltip="<?php echo $combats_text['combat_3']?>" onclick="introducirPuntuacion(4)">

                    <?php $count = 0; ?>
                    <?php foreach ($competitors_position as $cp){?>
                        <?php if($cp -> puesto == 4){?>
                            <td class="brown lighten-2"><span style="font-weight: bold">3</span></td>
                            <td> <?php  echo $cp ->nombre ?></td>
                            <td><?php  echo $cp ->apellido1 ?></td>
                            <td><?php  echo $cp ->apellido2 ?></td>
                            <td><?php  echo $cp ->nombreEquipo ?></td>
                        <?php }
                                else  {
                                $count ++;
                        }?>
                        <?php if($count == $number_competitors){?>
                            <td class="brown lighten-2"><span style="font-weight: bold">3</span></td>
                            <td></td>
                            <td></td>
                            <td></td>
                            <td></td>
                        <?php }?>
                    <?php }?>

                </tr>
                <tr class="tooltipped" data-tooltip="<?php echo $combats_text['combat_5']?>" onclick="introducirPuntuacion(5)">
                    <?php $count = 0; ?>
                    <?php foreach ($competitors_position as $cp){?>
                        <?php if($cp -> puesto == 5){?>
                            <td class=""><span style="font-weight: bold">5</span></td>
                            <td> <?php  echo $cp ->nombre ?></td>
                            <td><?php  echo $cp ->apellido1 ?></td>
                            <td><?php  echo $cp ->apellido2 ?></td>
                            <td><?php  echo $cp ->nombreEquipo ?></td>
                        <?php }
                        else  {
                            $count ++;
                        }?>
                        <?php if($count == $number_competitors){?>
                            <td class=""><span style="font-weight: bold">5</span></td>
                            <td></td>
                            <td></td>
                            <td></td>
                            <td></td>
                        <?php }?>
                    <?php }?>
                </tr>
                <tr class="tooltipped" data-tooltip="<?php echo $combats_text['combat_5']?>" onclick="introducirPuntuacion(6)">
                    <?php $count = 0; ?>
                    <?php foreach ($competitors_position as $cp){?>
                        <?php if($cp -> puesto == 6){?>
                            <td class=""><span style="font-weight: bold">5</span></td>
                            <td> <?php  echo $cp ->nombre ?></td>
                            <td><?php  echo $cp ->apellido1 ?></td>
                            <td><?php  echo $cp ->apellido2 ?></td>
                            <td><?php  echo $cp ->nombreEquipo ?></td>
                        <?php }
                        else  {
                            $count ++;
                        }?>
                        <?php if($count == $number_competitors){?>
                            <td class=""><span style="font-weight: bold">5</span></td>
                            <td></td>
                            <td></td>
                            <td></td>
                            <td></td>
                        <?php }?>
                    <?php }?>
                </tr>
                <tr class="tooltipped" data-tooltip="<?php echo $combats_text['combat_7']?>" onclick="introducirPuntuacion(7)">
                    <?php $count = 0; ?>
                    <?php foreach ($competitors_position as $cp){?>
                        <?php if($cp -> puesto == 7){?>
                            <td class=""><span style="font-weight: bold">7</span></td>
                            <td> <?php  echo $cp ->nombre ?></td>
                            <td><?php  echo $cp ->apellido1 ?></td>
                            <td><?php  echo $cp ->apellido2 ?></td>
                            <td><?php  echo $cp ->nombreEquipo ?></td>
                        <?php }
                        else  {
                            $count ++;
                        }?>
                        <?php if($count == $number_competitors){?>
                            <td class=""><span style="font-weight: bold">7</span></td>
                            <td></td>
                            <td></td>
                            <td></td>
                            <td></td>
                        <?php }?>
                    <?php }?>
                </tr>
                <tr class="tooltipped" data-tooltip="<?php echo $combats_text['combat_7']?>" onclick="introducirPuntuacion(8)">
                    <?php $count = 0; ?>
                    <?php foreach ($competitors_position as $cp){?>
                        <?php if($cp -> puesto == 8){?>
                            <td class=""><span style="font-weight: bold">7</span></td>
                            <td> <?php  echo $cp ->nombre ?></td>
                            <td><?php  echo $cp ->apellido1 ?></td>
                            <td><?php  echo $cp ->apellido2 ?></td>
                            <td><?php  echo $cp ->nombreEquipo ?></td>
                        <?php }
                        else  {
                            $count ++;
                        }?>
                        <?php if($count == $number_competitors){?>
                            <td class=""><span style="font-weight: bold">7</span></td>
                            <td></td>
                            <td></td>
                            <td></td>
                            <td></td>
                        <?php }?>
                    <?php }?>
                </tr>

                </tbody>
            </table>
        </div>

    </div>


</div>


</body>
<div class="modal" id="introducir_puntuacion">

    <div class="modal-content">
       <span> <?php echo $combats_text['combat_model_select_position']?></span>

        <form action="<?php echo base_url()?>combat/enterPosition" method="post">
            <input type="hidden" name = "position"id="puesto" value="">
            <input type="hidden" name = "idWeight" value ="<?php echo $this -> input -> get('idWeight')?>">
            <input type="hidden" name="competition" value="<?php echo $competition -> idCompeticion?>">
            <input type="hidden" name="date" value="<?php echo $competition -> fecha?>">
            <div class="input-field col s12 xl6 offset-xl3" >

                <select name="competitor" onchange="this.form.submit()" >
                    <option value="" disabled selected><?php echo $combats_text['combat_modal_choose_option']?></option>
                    <?php foreach ($competitors as $competitor){?>
                        <option value="<?php echo $competitor -> dni?>"  ><?php echo $competitor->nombre . ',' . $competitor -> apellido1?></option>
                    <?php } ?>

                </select>
                <label><?php echo $combats_text['combat_model_competitor']?></label>
            </div>
        </form>
    </div>
</div>

<div id="create_combat" class="modal">
    <div class="modal-content">
        <h5 class="center"><?php echo $combats_text['combat_modal_header']?></h5>

        <div class="row">
            <span style="font-weight: bold"><?php echo $combats_text['combat_modal_requiered_fields']?></span>
        <form action="<?php echo base_url()?>combat/create/<?php echo $competition -> idCompeticion?>" method="post">

            <div class="input-field col s12 xl6 offset-xl3" >
                <p><?php echo $combats_text['combat_modal_select_white']?> (*)</p>
                <select name="competitor1" id="competitor1ID">
                    <option value="" disabled selected><?php echo $combats_text['combat_modal_choose_option']?></option>
                    <?php foreach ($competitors as $competitor){?>
                        <option value="<?php echo $competitor -> dni?>"  ><?php echo $competitor->nombre . ',' . $competitor -> apellido1?></option>
                    <?php } ?>
                </select>
                <label><?php echo $combats_text['combat_modal_competitor_white']?></label>
            </div>


            <div class="input-field col s12 xl6 offset-xl3 indigo lighten-3" >
                <p>  <?php echo $combats_text['combat_modal_select_blue']?>(*)</p>
                <select name="competitor2" id="competitor2ID">
                    <option value="" disabled selected><?php echo $combats_text['combat_modal_choose_option']?></option>
                    <?php foreach ($competitors as $competitor){?>
                        <option value="<?php echo $competitor -> dni?>"  ><?php echo $competitor->nombre . ',' . $competitor -> apellido1?></option>
                    <?php } ?>
                </select>
                <label><?php echo $combats_text['combat_modal_competitor_blue']?></label>
            </div>

            <div class="input-field col s12 xl6 offset-xl3" >
                <p>  <?php echo $combats_text['combat_modal_select_mat']?> (*)</p>
                <select name="mat"  id="matID">
                    <option value="" disabled selected><?php echo $combats_text['combat_modal_choose_option']?></option>
                   <?php foreach ($mats as $mat){?>
                       <option value="<?php echo $mat -> idTatami?>"  ><?php echo $mat -> numero?></option>
                    <?php } ?>
                </select>
                <label><?php echo $combats_text['combat_modal_mat']?></label>
            </div>
            <div class="input-field col s12 xl6 offset-xl3" >
                <p> <?php echo $combats_text['combat_modal_phase']?></p>
                <select name="fase"  id="faseID">
                    <option value="" disabled selected><?php echo $combats_text['combat_modal_choose_option']?></option>

                        <option value="32-final">32-final</option>
                        <option value="16-final">16-final</option>
                        <option value="8-final">8-final</option>
                        <option value="4-final">4-final</option>
                        <option value="semi-final">semi-final</option>
                        <option value="final">final</option>

                </select>
                <label>Tatami</label>
            </div>
            <div class="col s6 offset-s3">
                <div class="col s6 offset-s3">
                    <button onclick="return validateFields()" class="btn btn-large waves-effect indigo"><?php echo $combats_text['combat_modal_btn_create']?></button>
                </div>
            </div>
            <input type="hidden" name="idWeight" value="<?php echo $this -> input -> get ('idWeight')?>">
        </form>
            </div>

    </div>

</div>

<script>
    function validateFields() {
        var mat = $('#matID').val();
        var competitor1 = $('#competitor1ID').val();
        var competitor2 = $('#competitor2ID').val();
        if(mat == null || competitor1 == null || competitor2 == null){
            Materialize.toast('Rellene los campos obligatorios',2000)
            return false;
        }
    }
    function introducirPuntuacion(puesto) {
            $('#puesto').val(puesto);
            $('#introducir_puntuacion').modal('open');
    }

    function deleteCombat(idCombat,dniW,dniB,idCompetition,idWeight) {

       if(confirm('<?php echo $combats_text['combat_confirm_delete']?>')) {

           $.ajax({
               type: "POST",
               url: "<?php echo base_url()?>combat/delete",
               data: {
                   dniW: dniW,
                   dniB: dniB,
                   idCombat: idCombat,
                   idCompetition:idCompetition,
                   idWeight :idWeight
               },
               success: function (result) {
                       document.location.replace(result);
               },
               error: function (result) {
                   Materialize.toast('No fue posible conectarse al servidor en este momento. Inténtalo de nuevo más tarde.',5000,'amber lighten-1');
                   console.log(result);
               }
           })

       }
       else {

           console.log('No se elimina el combate')
       }

    }



</script>
