
<form action="{{route('/addResult')}}" method="POST" id="addresultform">
    <div class="container-fluid">
        <div class="col-xs-12">
            <input type="hidden" name="id" value="{{$game->id}}">
            <div class="col-md-5 col-xs-12" style="background: whitesmoke; padding: 15px;">
                <h1 class="text-center">{{$game->teamOne}}</h1><hr>

                <div class="form-group col-md-12 col-xs-12">
                    <label for="score1">SCORE/GOAL(S)</label>
                    <input type="text" name="score1" class="form-control" required value="{{$game->teamOneScore}}">
                </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="{{$game->gameDate}}" disabled>
                </div>
                <div class="form-group">
                    <input class="form-control" name="matchtime" id="matchtime" type="text" placeholder="MATCH TIME" required value="{{$game->gameTime}}" disabled>
                </div>
            </div>

            <div class="col-md-5 col-xs-12" style="background: whitesmoke; padding: 15px;">
                <h1 class="text-center">{{$game->teamTwo}}</h1><hr>

                <div class="form-group col-md-12 col-xs-12">
                    <label for="score2">SCORE/GOAL(S)</label>
                    <input type="text" name="score2" class="form-control" value="{{$game->teamTwoScore}}">
                </div>

            </div>
        </div>
        <div class="row">
            <div class="col-sm-12">
                <div class="col-sm-12">
                    <span class="text-danger">If the match is postponed, just type "<strong>pstp</strong>" in the home-team result box!</span>
                </div>
            </div>
        </div>
    </div>
    <hr>
    <div class="col-sm-12">
        <div class="form-group col-sm-6">
            <label for="">CORNER RESULT</label>
            <input type="text" name="cornerResult" class="form-control" value="{{$game->cornerResult}}">
        </div>
        <div class="form-group col-sm-6">
            <label>SELECT POTENTIAL PREDICTION</label>
            <select name="potential" class="form-control">
                <option value="">Select here...</option>
                @if($game->gameType=='1')
                    @if($game->multiBetOne!='No')<option value="{{$game->multiBetOneTip}}"  @if($game->testimonialValue==$game->multiBetOneTip) selected @endif><b>Multibet 1</b> : {{$game->multiBetOneTip}}</option> @endif
                    @if($game->multiBetTwo!='No')<option value="{{$game->multiBetTwoTip}}"  @if($game->testimonialValue==$game->multiBetTwoTip) selected @endif><b>Multibet 2</b> : {{$game->multiBetTwoTip}}</option> @endif
                    @if($game->multiBetThree!='No')<option value="{{$game->multiBetThreeTip}}"  @if($game->testimonialValue==$game->multiBetThreeTip) selected @endif><b>Multibet 3</b> : {{$game->multiBetThreeTip}}</option> @endif

                    @if($game->super!='No')<option value="{{$game->superTip}}"  @if($game->testimonialValue==$game->superTip) selected @endif><b>Super Tip</b> : {{$game->superTip}}</option> @endif
                    @if($game->mega!='No')<option value="{{$game->megaTip}}"  @if($game->testimonialValue==$game->megaTip) selected @endif><b>Mega Jackpot</b> : {{$game->megaTip}}</option> @endif

                    @if($game->HTFT!='No')<option value="{{$game->HTFT}}"  @if($game->testimonialValue==$game->HTFT) selected @endif><b>HT/FT</b> : {{$game->HTFT}}</option> @endif

                    @if($game->midWeek=='Yes')<option value="{{$game->midWeekTip}}"   @if($game->testimonialValue==$game->midWeekTip) selected @endif><b>Midweek Jackpot</b> : {{$game->midWeekTip}}</option> @endif

                @else
                    <option value="{{$game->FTRecommendation}}" @if($game->testimonialValue==$game->FTRecommendation) selected @endif><b>Full-Time Recommendation</b> : {{$game->FTRecommendation}}</option>
                    <option value="{{$game->doubleChance}}" @if($game->testimonialValue==$game->doubleChance) selected @endif><b>Double Chance</b> : {{$game->doubleChance}}</option>
                    <option value="{{$game->directWins}}" @if($game->testimonialValue==$game->directWins) selected @endif><b>Direct Wins</b> : {{$game->directWins}}</option>
                    <option value="{{$game->oneFiveGoals}}"   @if($game->testimonialValue==$game->oneFiveGoals) selected @endif><b>Over 1.5</b> : {{$game->oneFiveGoals}}</option>
                    <option value="{{$game->twoFiveGoals}}" @if($game->testimonialValue==$game->twoFiveGoals) selected @endif><b>2.5 Goals</b> : {{$game->twoFiveGoals}}</option>
                    <option value="{{$game->overZeroFiveHT}}" @if($game->testimonialValue==$game->overZeroFiveHT) selected @endif><b>Over 0.5 HT</b> : {{$game->overZeroFiveHT}}</option>
                    <option value="{{$game->matchCorners}}" @if($game->testimonialValue==$game->matchCorners) selected @endif><b>Match Corners</b> : {{$game->matchCorners}}</option>
                    <option value="{{$game->drawNoBet}}" @if($game->testimonialValue==$game->drawNoBet) selected @endif><b>Draw No Bet</b> : {{$game->drawNoBet}}</option>
                @endif
            </select>
        </div>
    </div>
    <div class="container-fluid">
        {!! 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 & CLOSE</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();
            $('#submitsetting').prop('disabled', true).html('SAVING RESULT');
            var url = $(this).attr('action');
            var dataString = $(this).serialize();
            $.ajax({
                type: "POST",
                url: url,
                data: dataString,
                dataType: "JSON",
                success: function(data){
                    if (data.status == 1) {
                        $('#submitsetting').prop('disabled', false).html('SAVE RESULT');
                        swal(data.encounters, '', 'warning');
                    }
                    else{
                        swal(data.encounters, '', 'success');
                        $('#pred{{$game->id}}').css({'background':'lightgreen', 'color':'darkgreen'});
                        $('#addresult').modal('hide');
                    }
                }
            });

        });
    });
</script>