
{if $type == "usantenatal"}
<tr>
    <td>
        <input type="checkbox" class="usPrint" id="usPrint{$aUs->id}"  name="pic[]"  value="{$aUs->id}"/>
    </td>
    <td>{$itr}</td>

    <td>
        <input type="text" class="form-control datepicker updateElement usDate" readonly="" placeholder="Date" data-colName="date" data-id="{$aUs->id}"  data-tableName="mainantenentalus" value="{$aUs->date}"/>
    </td>
    <td>
        <label id="usLabel{$aUs->id}" {if $aUs->dateFlag == 1}style="color: red;font-size: 18px;" {else} style="color: maroon; font-weight : bolder; font-size: 18px;" {/if}>{$aUs->w}</label>
    </td>

    <td>
        <input type="text" class="form-control updateElement" placeholder="Notes" data-colName="notes" data-id="{$aUs->id}"  data-tableName="mainantenentalus" value="{$aUs->notes}">
    </td>

    <td>
        <input type="text" class="form-control updateElement" placeholder="Placenta" data-colName="placenta" data-id="{$aUs->id}"  data-tableName="mainantenentalus" value="{$aUs->placenta}">
    </td>
    <td>
        <input type="text" class="form-control updateElement" placeholder="AI" data-colName="ai" data-id="{$aUs->id}"  data-tableName="mainantenentalus" value="{$aUs->ai}">
    </td>
    <td>
        <input type="text" class="form-control updateElement" placeholder="FWT" data-colName="fwt" data-id="{$aUs->id}"  data-tableName="mainantenentalus" value="{$aUs->fwt}">
    </td>

    <td>
        <a class="btn grey-cascade btn-xs deletemsgEX" data-id="{$aUs->id}" style=" float: left;" href="#" data-link="antenalvisit" data-fn="delantus">
            <i class="fa fa-close"></i>
        </a>
    </td>
    {if $ProgramesettingData->displaydoctorname eq 1}
    <td class="bold">
        {$aUs->doctorname}
    </td>
    {/if}
</tr>
<!----------------------------------------------------------------------------------------------------------------------------------------------------->
{else if $type == "drug"}
<tr>
    <td>
        <select class="form-control xx dcat " id="dcat{$itr}" name="dcat{$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 dname updateElement dnameSelect" id="dname{$itr}" data-createNew="0" data-id="{$gynaDrug->id}" data-colName="drugid" data-tableName="mainantenentaldrugs" data-itr="{$itr}" data-placeholder="Select..."  >
            <option value="">Choose Drug</option>
            {foreach $drugs as $drug}
            <option value="{$drug['id']}">{$drug['drugname']} {if $programSettingData->visitsform eq 3}(left {$drug['currentbalance']}){/if}</option>
            {/foreach}
            <option value="" class="deleteoptincompo" >choose Drug</option>
        </select>
    </td>
    <td>
        <select class="form-control xx dtype updateElement dtypeSelect" id="dtype{$itr}" data-id="{$gynaDrug->id}" data-colName="drugtype" data-tableName="mainantenentaldrugs" data-itr="{$itr}" data-placeholder="Select..."  >
            <option value="">Choose Form</option>
            {foreach $allDrugTypes as $type}
            <option value="{$type['drugtype']}">{$type['drugtype']}</option>
            {/foreach}
            <option value="" class="deleteoptincompo" >choose Form</option>
        </select>
    </td>
    <td>
        <select class="form-control xx ddos updateElement ddosSelect" id="ddos{$itr}" data-id="{$gynaDrug->id}" data-colName="drugdos" data-tableName="mainantenentaldrugs" data-itr="{$itr}" data-placeholder="Select..."  >
            <option value="">choose dose </option>
            {foreach $allDrugDoses as $dos}
            <option value="{$dos['drugdos']}">{$dos['drugdos']}</option>
            {/foreach}
            <option value="" class="deleteoptincompo" >choose dose</option>
        </select>
    </td>

    <td>
        <a class="btn grey-cascade btn-xs deletemsgEX" data-id="{$gynaDrug->id}" style=" float: left;" href="#" data-link="antenalvisit" data-fn="addprescription">
            <i class="fa fa-close"></i>
        </a>
    </td>
</tr>

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





{literal}
<script type="text/javascript" >
    var itr = $('#drugItr').val();
    var hosturl = $('#hosturl').val();
    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});


        $('#dname' + itr).select2({
//   width: '240px',
            allowClear: true,
            formatNoMatches: function (term) {
                /* customize the no matches output */
                var thisId = $(this).attr("id");
                // var itr = $(this).attr("data-itr");
                return "<input class='form-control' id='newdnameSelectTerm' value='" + term + "'><a href='#' id='addNewdnameSelect' data-id='" + thisId + "' class='btn blue custombtnstyle'>ADD</a>"
            }
        }).parent().find('.select2-with-searchbox').on('click', '#addNewdnameSelect', function () {
            /* add the new term */
            var dnameSelect = $('#newdnameSelectTerm').val();
            var thisId = $(this).attr("data-id");
            $.post(hosturl + "/controllers/patienthistory.php?ac=addRow", {value: dnameSelect, table: 'drugname'}, function (data) {

                $('.dnameSelect > .deleteoptincompo').before('<option value="' + Number(data) + '" >' + dnameSelect + '</option>');
                $('#' + thisId + '').select2('val', Number(data)).trigger("change"); // select the new term
                $('.dnameSelect').select2('close'); // close the dropdown
            });
        });

        $('#dtype' + itr).select2({
//   width: '240px',
            allowClear: true,
            formatNoMatches: function (term) {
                /* customize the no matches output */
                var thisId = $(this).attr("id");
                // var itr = $(this).attr("data-itr");
                return "<input class='form-control' id='newdtypeSelectTerm' value='" + term + "'><a href='#' id='addNewdtypeSelect' data-id='" + thisId + "' class='btn blue custombtnstyle'>ADD</a>"
            }
        }).parent().find('.select2-with-searchbox').on('click', '#addNewdtypeSelect', function () {
            /* add the new term */
            var dtypeSelect = $('#newdtypeSelectTerm').val();
            var thisId = $(this).attr("data-id");
            $.post(hosturl + "/controllers/patienthistory.php?ac=addRow", {value: dtypeSelect, table: 'drugtype'}, function (data) {

                $('.dtypeSelect > .deleteoptincompo').before('<option value="' + dtypeSelect + '" >' + dtypeSelect + '</option>');
                $('#' + thisId + '').select2('val', dtypeSelect).trigger("change"); // select the new term
                $('.dtypeSelect').select2('close'); // close the dropdown
            });
        });



        $('#ddos' + itr).select2({
//   width: '240px',
            allowClear: true,
            formatNoMatches: function (term) {
                /* customize the no matches output */
                var thisId = $(this).attr("id");
                // var itr = $(this).attr("data-itr");
                return "<input class='form-control' id='newddosSelectTerm' value='" + term + "'><a href='#' id='addNewddosSelect' data-id='" + thisId + "' class='btn blue custombtnstyle'>ADD</a>"
            }
        }).parent().find('.select2-with-searchbox').on('click', '#addNewddosSelect', function () {
            /* add the new term */
            var ddosSelect = $('#newddosSelectTerm').val();
            var thisId = $(this).attr("data-id");
            $.post(hosturl + "/controllers/patienthistory.php?ac=addRow", {value: ddosSelect, table: 'drugdos'}, function (data) {

                $('.ddosSelect > .deleteoptincompo').before('<option value="' + ddosSelect + '" >' + ddosSelect + '</option>');
                $('#' + thisId + '').select2('val', ddosSelect).trigger("change"); // select the new term
                $('.ddosSelect').select2('close'); // close the dropdown
            });
        });

    }

    $('.datepickertoday').datepicker('setDate', '+0');
    $(".datepicker").datepicker({
        todayBtn: "linked",
        autoclose: true,
        todayHighlight: true,
        format: 'yy-mm-dd',
        isRTL: true
    });
</script>
{/literal}
