<table class="table table-striped table-hover table-bordered" style="margin: 2%; width: 96%;">
    <tbody>
        <tr>
            <th class="col-md-1">Title </th>
            <td colspan="2" class="col-md-11">
                <input type="text" class="form-control" placeholder="Enter Name" 
                       id="preTitle" name="preTitle" value="{$pres->pre_name}" >
            </td>
        </tr>
        <tr>
            <th class="col-md-1">Doctor</th>
            <td class="col-md-10">
                <select class="form-control  "  id="docAddIdPre"  name="docAddIdPre" data-placeholder="Select..." >
                    <option></option>
                    {foreach  $doctorsAll as $data}
                    <option value="{$data.user_id}" {if $pres->doctorid == $data.user_id } selected {/if} >{$data.name}</option>
                    {/foreach}
                </select>
            </td>

            <th class="col-md-1">
                <a href="javascript:;" class="btn btn-primary btn-sm" id="addNewPreDrugRow">
                    <i class="fa fa-plus"></i> Add Drug </a>
            </th>
        </tr>
</table>

<input type="hidden" id="drugPreItr" value="{$drugPreItr}" name="drugPreItr"/>
<input type="hidden" id="drugPreId" value="{$pres->id}" name="drugPreId"/>

<table class="table table-striped table-hover table-bordered" id="prePresTable" >
    <thead>
        <tr>
            <th class="col-md-2">
                Group
            </th>
            <th class="col-md-2">
                Drug
            </th>
            <th class="col-md-2">
                Form
            </th>
            <th class="col-md-5">
                Use
            </th>
            <th >
                Delete
            </th>
        </tr>
    </thead>
    <tbody id="drugPreContent">
        {assign var=itr value=1}
        {foreach $preDrugs  as $preDrug}

        <tr id="preRow{$itr}">
            <td>
                <select class="form-control xx preCat " id="preCat{$itr}" name="preCat{$itr}"  data-itr="{$itr}"  data-placeholder="Select..."  >
                    <option value="">Choose Category</option>
                    {foreach $allDrugcats as $cat}
                    <option value="{$cat['drugcat']}">{$cat['drugcat']}</option>
                    {/foreach}
                </select>
            </td>
            <td>
                <select class="form-control xx preName " id="preName{$itr}"  name="preName{$itr}"   data-createNew="0"    data-itr="{$itr}" data-placeholder="Select..."  >
                    <option value="">Choose Drug</option>
                    {foreach $allDrugs as $drug}
                    <option value="{$drug['id']}"  {if $preDrug->drugid == $drug.id } selected {/if} >{$drug['drugname']} </option>
                    {/foreach}
                </select>
            </td>
            <td>
                <select class="form-control xx preType " id="preType{$itr}"  name="preType{$itr}"     data-itr="{$itr}" data-placeholder="Select..."  >
                    <option value="">Choose Form</option>
                    {foreach $allDrugTypes as $type}
                    <option value="{$type['drugtype']}" {if $preDrug->drugtype == $type.drugtype } selected {/if}  >{$type['drugtype']}</option>
                    {/foreach}
                </select>
            </td>
            <td>
                <select class="form-control xx preDos " id="preDos{$itr}"  name="preDos{$itr}"     data-itr="{$itr}" data-placeholder="Select..."  >
                    <option value="">choose dose </option>
                    {foreach $allDrugDoses as $dos}
                    <option value="{$dos['drugdos']}" {if $preDrug->drugdos == $dos.drugdos } selected {/if}  >{$dos['drugdos']}</option>
                    {/foreach}
                </select>
            </td>

            <td>
                <a class="btn grey-cascade btn-xs deletePreRow"  style=" float: left;" href="#" data-itr="{$itr}" >
                    <i class="fa fa-close"></i>
                </a>
            </td>
        </tr>
        {capture assign=itr}{$itr+1}{/capture}
        {/foreach}

    </tbody>
</table>


{literal}
<script type="text/javascript" >
    $('.preCat').select2();
    $('.preName').select2();
    $('.preType').select2();
    $('.preDos').select2();
    $('#docAddIdPre').select2();
</script>

{/literal}