
<form action="#" method="POST" id="addresultform">
    <div class="container-fluid">
        <div class="col-xs-12">
            <input type="hidden" name="id" value="<?php echo e($game->id); ?>">
            <div class="col-md-5 col-xs-12" style="background: whitesmoke; padding: 15px;">
                <h1 class="text-center"><?php echo e($game->teamone); ?></h1><hr>

                <div class="form-group col-md-12 col-xs-12">
                    <label for="score1">SCORE/GOAL(S)</label>
                    <input type="number" name="score1" class="form-control" required maxlength="5" value="<?php echo e($game->teamonescore); ?>">
                </div>

                <div class="form-group col-md-12 col-xs-12">
                    <label for="status1">STATUS (Won, Loose, Draw)</label>
                    <select name="status1" class="form-control" required>
                        <option value="<?php echo e($game->teamonewon); ?>"><?php echo e($game->teamonewon); ?></option>
                        <option value="Won">Won</option>
                        <option value="Loose">Loose</option>
                        <option value="Draw">Draw</option>
                    </select>
                </div>

            </div>

            <div class="col-md-2 col-xs-12" style="margin: 10px 0px; background: grey; border-radius: 0px 0px 8px 8px;"><center><span style="padding: 5px 10px; background: grey; color: white; border-radius: 100px; margin-top: -30px;">VS</span></center>
                <br>
                <div class="form-group">
                    <input class="form-control" name="matchdate" id="matchdate" type="text" placeholder="MATCH DATE" required value="<?php echo e($game->gamedate); ?>" disabled>
                </div>
                <div class="form-group">
                    <input class="form-control" name="matchtime" id="matchtime" type="text" placeholder="MATCH TIME" required value="<?php echo e($game->gametime); ?>" disabled>
                </div>
            </div>

            <div class="col-md-5 col-xs-12" style="background: whitesmoke; padding: 15px;">
                <h1 class="text-center"><?php echo e($game->teamtwo); ?></h1><hr>

                <div class="form-group col-md-12 col-xs-12">
                    <label for="score2">SCORE/GOAL(S)</label>
                    <input type="number" name="score2" class="form-control" required maxlength="5" value="<?php echo e($game->teamtwoscore); ?>">
                </div>

                <div class="form-group col-md-12 col-xs-12">
                    <label for="status2">STATUS (Won, Loose, Draw)</label>
                    <select name="status2" class="form-control" required>
                        <option value="<?php echo e($game->teamtwowon); ?>"><?php echo e($game->teamtwowon); ?></option>
                        <option value="Won">Won</option>
                        <option value="Loose">Loose</option>
                        <option value="Draw">Draw</option>
                    </select>
                </div>

            </div>
        </div>
    </div>
    <hr>
    <div class="container-fluid">
        <?php echo csrf_field(); ?>


        <div id="settingstatus" class="col-xs-6"></div>
        <div class="form-group col-sm-12">
            <button class="btn btn-md btn-success" name="submit" id="submitsetting">SAVE RESULT</button>
        </div>

    </div>
</form>

<script>
    $.ajaxSetup({
        headers: {
            'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
        }
    });

    $(document).ready(function () {
        $('#addresultform').submit(function (e) {
            e.preventDefault();
            $('#settingstatus').html('Adding Result... Please wait');
            $('#submitsetting').prop('disabled', true);
            var dataString = $(this).serialize();
            $.ajax({
                type: "POST",
                url: "ajaxresult",
                data: dataString,
                dataType: "JSON",
                success: function(data){
                    if (data.status == 1) {
                        $('#submitsetting').prop('disabled', false);
                        $('#settingstatus').html(data.encounters);
                        console.log(data);
                    }
                    else{
//                        $('#settingstatus').html(data.encounters);
                        alert(data.encounters);
                        $('#addresult').modal('hide');
                    }
                }
            });

        });
    });
</script>