@php
$i = 1;
if(file_exists('json_files/json-file.json')){
$json = file_get_contents('json_files/json-file.json');
//Decode JSON
$json_data = json_decode($json,true);
$results = array();
}
@endphp
@foreach($data as $result2)
<tr>
    <!--  <td align="center" valign="top"><input class="form-check-input" type="checkbox" value="1" name="TreatChk1">
                                                           </td> -->
    <td>
        <!-- <input value="{{$result2->TreatType1}}" class="form-control" type="text" list="Treat_Type1" name="TreatType1[]"  id="SvTreatType{{$i}}">
        <datalist id="Treat_Type1">

            <?php
        foreach($json_data['JsonData']['TreatType'] as $result) {?>
            <option value="{{$result['Values']}}">
                <?php } ?>
        </datalist> -->

        <select class="form-control"  name="TreatType1[]"  id="SvTreatType{{$i}}"  onchange="getDrugByType(this.value,{{$i}})">
       <option value="" selected>...</option>
                                            <?php
        foreach($json_data['JsonData']['TreatType'] as $result) {?>
        <option value="{{$result['Values']}}" <?php if($result['Values'] == $result2->TreatType1){?> selected <?php } ?>>{{$result['Values']}}</option>
        <?php } ?>
        </select>
    </td>
    <td>
        <input value="{{$result2->TreatName1}}" class="form-control" type="text" name="TreatName1[]"  list="Treat_Name{{$i}}" id="SvTreatName{{$i}}"
                          
                            oninput="getTreatNameDetails('SvTreatName{{$i}}','SvTreatDose{{$i}}','SvTreatFreq{{$i}}')">
                        <datalist id="Treat_Name{{$i}}" class="treatments">
                            @foreach($drugList as $drugdata)
                            <option value="{{$drugdata->Name}}">
                                @endforeach
                        </datalist>
    </td>
    <td>
        <!-- <input value="{{$result2->TreatDose1}}" class="form-control" type="text" list="Treat_Dose1" name="TreatDose1[]"  id="SvTreatDose{{$i}}">
        <datalist id="Treat_Dose1">

            <?php
        foreach($json_data['JsonData']['TreatDose'] as $result) {?>
            <option value="{{$result['Values']}}">
                <?php } ?>
        </datalist> -->

        <select class="form-control"  name="TreatDose1[]"  id="SvTreatDose{{$i}}">
       <option value="" selected>...</option>
                                            <?php
        foreach($json_data['JsonData']['TreatDose'] as $result) {?>
        <option value="{{$result['Values']}}" <?php if($result['Values'] == $result2->TreatDose1){?> selected <?php } ?>>{{$result['Values']}}</option>
        <?php } ?>
        </select>
    </td>
    <td>
        <!-- <input value="{{$result2->TreatFreq1}}" class="form-control" type="text" list="Treat_Freq1" name="TreatFreq1[]"  id="SvTreatFreq{{$i}}">
        <datalist id="Treat_Freq1">

            <?php
        foreach($json_data['JsonData']['TreatFreq'] as $result) {?>
            <option value="{{$result['Values']}}">
                <?php } ?>
        </datalist> -->
        <select class="form-control"  name="TreatFreq1[]"  id="SvTreatFreq{{$i}}">
       <option value="" selected>...</option>
                                            <?php
        foreach($json_data['JsonData']['TreatFreq'] as $result) {?>
        <option value="{{$result['Values']}}" <?php if($result['Values'] == $result2->TreatFreq1){?> selected <?php } ?>>{{$result['Values']}}</option>
        <?php } ?>
        </select>
    </td>
    <td>
        <!-- <input value="{{$result2->TreatDur1}}" class="form-control" type="text" list="Treat_Dur1" name="TreatDur1[]"  id="SvTreatDur{{$i}}">
        <datalist id="Treat_Dur1">

            <?php
        foreach($json_data['JsonData']['TreatDur'] as $result) {?>
            <option value="{{$result['Values']}}">
                <?php } ?>
        </datalist> -->

        <select class="form-control"  name="TreatDur1[]"  id="SvTreatDur{{$i}}">
       <option value="" selected>...</option>
                                            <?php
        foreach($json_data['JsonData']['TreatDur'] as $result) {?>
        <option value="{{$result['Values']}}" <?php if($result['Values'] == $result2->TreatDur1){?> selected <?php } ?>>{{$result['Values']}}</option>
        <?php } ?>
        </select>
    </td>
    <td>
        <!-- <input value="{{$result2->TreatEye1}}" class="form-control" type="text" list="Treat_Eye1" name="TreatEye1[]" id="SvTreatEye{{$i}}">
        <datalist id="Treat_Eye1">

            <?php
        foreach($json_data['JsonData']['TreatEye'] as $result) {?>
            <option value="{{$result['Values']}}">
                <?php } ?>
        </datalist> -->

        <select class="form-control"  name="TreatEye1[]"  id="SvTreatEye{{$i}}">
       <option value="" selected>...</option>
                                            <?php
        foreach($json_data['JsonData']['TreatEye'] as $result) {?>
        <option value="{{$result['Values']}}" <?php if($result['Values'] == $result2->TreatEye1){?> selected <?php } ?>>{{$result['Values']}}</option>
        <?php } ?>
        </select>
    </td>

    <td align="center" valign="top">
    <button class="btn btn-danger" type="button" onclick="removeTreatment({{$i}})"><i class="feather icon-x"></i></button>
    </td>
    </td>

</tr>
@php $i++;@endphp
@endforeach