
<!----------------------------------------------------------------------------------------------------------------------------------------------------->
{if $type == "drugedit"}

<tr style="display: none"><td colspan="5" ><input type="hidden" id="drugItr" value="{$preItr}" name="drugItr"/></td></tr>


{assign var=itr value=1}
{foreach $PatientPresByDate as $pre}
<tr>
    <td>
        <select class="form-control xx dcat " id="dcat{$itr}" name="dcat{$itr}"  data-itr="{$itr}"  data-placeholder="Select..."  >
            <option value="" {if $pre->drugcat == ""}selected{/if}>Choose Category</option>
            {foreach $allDrugcats as $cat}
            <option value="{$cat['drugcat']}" {if $pre->drugcat == $cat['drugcat'] }selected{/if}>{$cat['drugcat']}</option>
            {/foreach}
            <option value="" {if $pre->drugcat == ""}selected{/if}>Choose Category</option>
        </select>
    </td>
    <td>
        <select class="form-control xx dname  updateElement" id="dname{$itr}" data-id="{$pre->id}" data-colName="drugid" data-tableName="gynadrugs" data-itr="{$itr}" data-placeholder="Select..."  >
            <option value="" {if $pre->drugid == ""}selected{/if}>Choose Drug</option>
            {foreach $drugs as $drug}
            <option value="{$drug['id']}" {if $pre->drugid == $drug['id'] }selected{/if}>{$drug['drugname']} {if $ProgramesettingData->visitsform eq 3}(left {$drug['currentbalance']}){/if}</option>
            {/foreach}
            <option value="" {if $pre->drugid == ""}selected{/if}>Choose Drug</option>
        </select>

    </td>
    <td>
        <select class="form-control xx dtype  updateElement" id="dtype{$itr}" data-id="{$pre->id}" data-colName="drugtype" data-tableName="gynadrugs" data-itr="{$itr}" data-placeholder="Select..."  >
            <option value="" {if $pre->drugtype == ""}selected{/if}>Choose Form</option>
            {foreach $allDrugTypes as $type}
            <option value="{$type['drugtype']}" {if $pre->drugtype == $type['drugtype'] }selected{/if}>{$type['drugtype']}</option>
            {/foreach}
            <option value="" {if $pre->drugtype == ""}selected{/if}>Choose Form</option>
        </select>
    </td>
    <td>
        <select class="form-control xx  updateElement" id="ddos{$itr}" data-id="{$pre->id}" data-colName="drugdos" data-tableName="gynadrugs" data-itr="{$itr}" data-placeholder="Select..."  >
            <option value="" {if $pre->drugdos == ""}selected{/if}>choose dose </option>
            {foreach $allDrugDoses as $dos}
            <option value="{$dos['drugdos']}" {if $pre->drugdos == $dos['drugdos'] }selected{/if}>{$dos['drugdos']}</option>
            {/foreach}
            <option value="" {if $pre->drugdos == ""}selected{/if}>choose dose </option>
        </select>
    </td>

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

<!----------------------------------------------------------------------------------------------------------------------------------------------------->
{/if}





{literal}
<script type="text/javascript" >
    var preItr = $('#drugItr').val();
    for (var itr = 1; itr <= preItr; itr++)
    {
        if ($().select2)
        {
            $('#dcat' + itr).select2({placeholder: "Select", allowClear: true});
            $('#dname' + itr).select2({placeholder: "Select", allowClear: true});
            $('#dtype' + itr).select2({placeholder: "Select", allowClear: true});
            $('#ddos' + itr).select2({placeholder: "Select", allowClear: true});
        }

    }
</script>
{/literal}
