<div class="modal-dialog  modal-lg wds95" style="max-width: 90%;">
    <div class="modal-content">
        <div class="modal-header">
            <button type="button" class="close" data-dismiss="modal" aria-hidden="true"></button>
            <h4 class="modal-title">ICSI  </h4>
        </div>
        <div class="modal-body">
            <div class="portlet-body form">
                <form class="form-horizontal" role="form" action="" method="post" id="phform" enctype="multipart/form-data">
                    <div class="row">
                        <div class="portlet grey-cascade box">
                            <div class="portlet-title">
                                <div class="caption">Fresh    </div>
                                <div class="actions">
                                    <a href="javascript:;" class="btn btn-default btn-sm addIcsiRow"  data-type="icsi_fresh">
                                        <i class="fa fa-plus"></i> Add </a>
                                </div>
                            </div>
                            <div class="portlet-body">

                                <div class="form-body">
                                    <div class="row">
                                        <input type="hidden" id="freshItr" value="{$icsi_freshItr}"/>

                                        <table class="table table-striped table-hover table-bordered">
                                            <thead>
                                                <tr>
                                                    <th rowspan="2" class="wds8">     Date </th>
                                                    <th rowspan="2" class="wds8">     LMP </th>
                                                    <th rowspan="2" class="wds12">     Protocol +  TTT </th>
                                                    <th colspan="2" class="wds10">     Trigger </th>
                                                    <th rowspan="2" class="wds7">     Follicles Last Size </th>
                                                    <th colspan="3" class="wds12">     Ovums </th>
                                                    <th rowspan="2" class="wds7">     Semen </th>
                                                    <th rowspan="2" class="wds10">     Embryos </th>
                                                    <th rowspan="2" class="wds8">     Groups </th>
                                                    <th rowspan="2" style="width: 5%;">     Preg. </th>
                                                    <th rowspan="2">     Notes </th>
                                                    <th rowspan="2" class="wds3">  </th>
                                                </tr>
                                                <tr>
                                                    <th style="width: 5%;">     Name </th>
                                                    <th style="width: 5%;">     Day </th>
                                                    <th style="width: 4%;">     MI </th>
                                                    <th style="width: 4%;">     MII </th>
                                                    <th style="width: 4%;">     G.V </th>
                                                </tr>
                                            </thead>
                                            <tbody id="icsi_freshContainer">
                                                {assign var=i value=1}
                                                {foreach $icsi_fresh  as $record }
                                                <tr>
                                                    <td>
                                                        <input type="text" class="form-control  datepicker updateElement" data-id="{$record->id}" 
                                                               data-colName="try_date" data-tableName="icsi_fresh" 
                                                               value="{$record->try_date}" readonly />
                                                    </td>
                                                    <td>
                                                        <input type="text" class="form-control  datepicker updateElement" data-id="{$record->id}" 
                                                               data-colName="lmp" data-tableName="icsi_fresh" 
                                                               value="{$record->lmp}" readonly />
                                                    </td>
                                                    <td>
                                                        <select class="form-control  updateElement editModelSel  icsi_protocol"data-colName="icsi_protocol" 
                                                                data-id="{$record->id}"  data-tableName="icsi_fresh"    id="icsi_protocol{$record->id}"
                                                                select-tableName="icsi_protocol" >
                                                            <option value=""></option>
                                                            {foreach $protocols as $data}
                                                            <option value="{$data->id}" {if $record->icsi_protocol eq  $data->id}selected{/if}>{$data->name}</option>
                                                            {/foreach}
                                                            <option value="0" class="deleteoptincompo">حذف</option>
                                                        </select>
                                                    </td>
                                                    <td>
                                                        <select class="form-control  updateElement editModelSel  icsi_trigname"data-colName="icsi_trigname" 
                                                                data-id="{$record->id}"  data-tableName="icsi_fresh"    id="icsi_trigname{$record->id}">
                                                            <option value=""></option>
                                                            {foreach $trignames as $data}
                                                            <option value="{$data->id}" {if $record->icsi_trigname eq  $data->id}selected{/if}>{$data->name}</option>
                                                            {/foreach}
                                                            <option value="0" class="deleteoptincompo">حذف</option>
                                                        </select>
                                                    </td>
                                                    <td>
                                                        <select class="form-control  updateElement editModelSel  icsi_trigday"data-colName="icsi_trigday" 
                                                                data-id="{$record->id}"  data-tableName="icsi_fresh"    id="icsi_trigday{$record->id}">
                                                            <option value=""></option>
                                                            {foreach $trigdays as $data}
                                                            <option value="{$data->id}" {if $record->icsi_trigday eq  $data->id}selected{/if}>{$data->name}</option>
                                                            {/foreach}
                                                            <option value="0" class="deleteoptincompo">حذف</option>
                                                        </select>
                                                    </td>
                                                    <td>
                                                        <input type="text" class="form-control  updateElement" data-id="{$record->id}" 
                                                               data-colName="last_size" data-tableName="icsi_fresh" 
                                                               value="{$record->last_size}"  />
                                                    </td>
                                                    <td>
                                                        <input type="text" class="form-control  updateElement" data-id="{$record->id}" 
                                                               data-colName="mi" data-tableName="icsi_fresh" 
                                                               value="{$record->mi}"  />
                                                    </td>
                                                    <td>
                                                        <input type="text" class="form-control  updateElement" data-id="{$record->id}" 
                                                               data-colName="mii" data-tableName="icsi_fresh" 
                                                               value="{$record->mii}"  />
                                                    </td>
                                                    <td>
                                                        <input type="text" class="form-control  updateElement" data-id="{$record->id}" 
                                                               data-colName="gv" data-tableName="icsi_fresh" 
                                                               value="{$record->gv}" />
                                                    </td>
                                                    <td>
                                                        <input type="text" class="form-control  updateElement" data-id="{$record->id}" 
                                                               data-colName="semen" data-tableName="icsi_fresh" 
                                                               value="{$record->semen}" />
                                                    </td>
                                                    <td>
                                                        <input type="text" class="form-control  updateElement" data-id="{$record->id}" 
                                                               data-colName="embryos" data-tableName="icsi_fresh" 
                                                               value="{$record->embryos}" />
                                                    </td>
                                                    <td>
                                                        <input type="text" class="form-control  updateElement" data-id="{$record->id}" 
                                                               data-colName="groups" data-tableName="icsi_fresh" 
                                                               value="{$record->groups}" />
                                                    </td>
                                                    <td>
                                                        <input type="checkbox"  value="1" class="updateElementCheck" 
                                                               data-id="{$record->id}" data-tableName="icsi_fresh" data-colName="pregnancy"  
                                                               {if {$record->pregnancy}  == 1 } checked {/if}>
                                                    </td>
                                                    <td>
                                                        <textarea class="form-control updateElement txtc" rows="1" data-id="{$record->id}" 
                                                                  data-colName="notes" data-tableName="icsi_fresh" placeholder="Enter more text" 
                                                                  data-toggle="popover" data-trigger="hover" data-placement="bottom" 
                                                                  data-content="{$record->notes}" 
                                                                  >{$record->notes}</textarea>
                                                    </td>
                                                    <td>
                                                        <button class="btn btn-xs red-intense deleteelement " type="button"  data-id="{$record->id}"
                                                                data-link="gyna"  data-fun="deldata" data-tableName="icsi_fresh" 
                                                                ><i class="fa fa-close"></i></button>
                                                    </td>
                                                </tr>
                                                {capture assign=i}{$i+1}{/capture}
                                                {/foreach}
                                            </tbody>
                                        </table>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>


                    <div class="row">
                        <div class="portlet grey-cascade box">
                            <div class="portlet-title">
                                <div class="caption">Frozen    </div>
                                <div class="actions">
                                    <a href="javascript:;" class="btn btn-default btn-sm addIcsiRow" data-type="icsi_frozen">
                                        <i class="fa fa-plus"></i> Add </a>
                                </div>
                            </div>
                            <div class="portlet-body">

                                <div class="form-body">
                                    <div class="row">
                                        <input type="hidden" id="icsi_frozenItr" value="{$frozenItr}"/>

                                        <table class="table table-striped table-hover table-bordered">
                                            <thead>
                                                <tr>
                                                    <th rowspan="2" class="wds8">     Date </th>
                                                    <th rowspan="2" class="wds8">     LMP </th>
                                                    <th rowspan="2" class="wds12">      TTT </th>
                                                    <th colspan="3" class="wds18">     Endometrium </th>
                                                    <th colspan="4" class="wds24">     Transfer </th>
                                                    <th rowspan="2" style="width: 5%;">     Preg. </th>
                                                    <th rowspan="2" class="wds8">     Delivery </th>
                                                    <th rowspan="2">     Notes </th>
                                                    <th rowspan="2" class="wds3">  </th>
                                                </tr>
                                                <tr>
                                                    <th style="width: 6%;">     Size </th>
                                                    <th style="width: 6%;">     Shape </th>
                                                    <th style="width: 6%;">     Trig. Day </th>
                                                    <th style="width: 6%;">     Difficulty </th>
                                                    <th style="width: 6%;">     Location </th>
                                                    <th style="width: 6%;">     Cather </th>
                                                    <th style="width: 6%;">     No. </th>
                                                </tr>
                                            </thead>
                                            <tbody id="icsi_frozenContainer">
                                                {assign var=i value=1}
                                                {foreach $icsi_frozen  as $record }
                                                <tr>
                                                    <td>
                                                        <input type="text" class="form-control  datepicker updateElement" data-id="{$record->id}" 
                                                               data-colName="try_date" data-tableName="icsi_frozen" 
                                                               value="{$record->try_date}" readonly />
                                                    </td>
                                                    <td>
                                                        <input type="text" class="form-control  datepicker updateElement" data-id="{$record->id}" 
                                                               data-colName="lmp" data-tableName="icsi_frozen" 
                                                               value="{$record->lmp}" readonly />
                                                    </td>
                                                    <td>
                                                        <input type="text" class="form-control  updateElement" data-id="{$record->id}" 
                                                               data-colName="ttt" data-tableName="icsi_frozen" 
                                                               value="{$record->ttt}"  />
                                                    </td>
                                                    <td>
                                                        <input type="text" class="form-control  updateElement" data-id="{$record->id}" 
                                                               data-colName="end_size" data-tableName="icsi_frozen" 
                                                               value="{$record->end_size}"  />
                                                    </td>
                                                    <td>
                                                        <input type="text" class="form-control  updateElement" data-id="{$record->id}" 
                                                               data-colName="end_shape" data-tableName="icsi_frozen" 
                                                               value="{$record->end_shape}"  />
                                                    </td>
                                                    <td>
                                                        <input type="text" class="form-control  updateElement" data-id="{$record->id}" 
                                                               data-colName="end_trigg" data-tableName="icsi_frozen" 
                                                               value="{$record->end_trigg}"  />
                                                    </td>
                                                    <td>
                                                        <select class="form-control  updateElement select2h"data-colName="trans_diff" 
                                                                data-id="{$record->id}"  data-tableName="icsi_frozen" id="trans_diff{$record->id}">
                                                            <option value=""></option>
                                                            <option value="1" {if $record->trans_diff eq  1}selected{/if}>Easy</option>
                                                            <option value="2" {if $record->trans_diff eq  2}selected{/if}>Difficult</option>
                                                            <option value="3" {if $record->trans_diff eq  3}selected{/if}>Traction</option>
                                                        </select>
                                                    </td>
                                                    <td>
                                                        <select class="form-control  updateElement select2h"data-colName="trans_location" 
                                                                data-id="{$record->id}"  data-tableName="icsi_frozen" id="trans_location{$record->id}">
                                                            <option value=""></option>
                                                            <option value="1" {if $record->trans_location eq  1}selected{/if}>Mid</option>
                                                            <option value="2" {if $record->trans_location eq  2}selected{/if}>Fundal</option>
                                                            <option value="3" {if $record->trans_location eq  3}selected{/if}>Low</option>
                                                            <option value="4" {if $record->trans_location eq  4}selected{/if}>Ostial</option>
                                                        </select>
                                                    </td>
                                                    <td>
                                                        <select class="form-control  updateElement editModelSel  trans_cather"data-colName="trans_cather" 
                                                                data-id="{$record->id}"  data-tableName="icsi_frozen"    id="trans_cather{$record->id}">
                                                            <option value=""></option>
                                                            {foreach $cathers as $data}
                                                            <option value="{$data->id}" {if $record->trans_cather eq  $data->id}selected{/if}>{$data->name}</option>
                                                            {/foreach}
                                                            <option value="0" class="deleteoptincompo">حذف</option>
                                                        </select>
                                                    </td>
                                                    <td>
                                                        <select class="form-control  updateElement editModelSel  trans_no"data-colName="trans_no" 
                                                                data-id="{$record->id}"  data-tableName="icsi_frozen"    id="trans_no{$record->id}">
                                                            <option value=""></option>
                                                            {foreach $numbers as $data}
                                                            <option value="{$data->id}" {if $record->trans_no eq  $data->id}selected{/if}>{$data->name}</option>
                                                            {/foreach}
                                                            <option value="0" class="deleteoptincompo">حذف</option>
                                                        </select>
                                                    </td>
                                                    <td>
                                                        <input type="checkbox"  value="1" class="updateElementCheck" 
                                                               data-id="{$record->id}" data-tableName="icsi_frozen" data-colName="pregnancy"  
                                                               {if {$record->pregnancy}  == 1 } checked {/if}>
                                                    </td>
                                                    <td>
                                                        <input type="text" class="form-control  updateElement" data-id="{$record->id}" 
                                                               data-colName="delivery" data-tableName="icsi_frozen" 
                                                               value="{$record->delivery}"  />
                                                    </td>
                                                    <td>
                                                        <textarea class="form-control updateElement txtc" rows="1" data-id="{$record->id}" 
                                                                  data-colName="notes" data-tableName="icsi_frozen" placeholder="Enter more text" 
                                                                  data-toggle="popover" data-trigger="hover" data-placement="bottom" 
                                                                  data-content="{$record->notes}" 
                                                                  >{$record->notes}</textarea>
                                                    </td>
                                                    <td>
                                                        <button class="btn btn-xs red-intense deleteelement " type="button"  data-id="{$record->id}"
                                                                data-link="gyna"  data-fun="deldata" data-tableName="icsi_frozen" 
                                                                ><i class="fa fa-close"></i></button>
                                                    </td>
                                                </tr>
                                                {capture assign=i}{$i+1}{/capture}
                                                {/foreach}
                                            </tbody>
                                        </table>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </form>
            </div>
        </div>

        <div class="modal-footer">

            <button type="button" class="btn default" id="closemodel" data-dismiss="modal"> Close</button>

        </div>

    </div>
</div>


{literal}
<script>
    $(".select2h").select2({placeholder: "Select", allowClear: true});
    $('.datepicker').datepicker();
    $(".icsi_protocol").select2({
//   width: '240px',
        allowClear: true,
        formatNoMatches: function (term) {
            /* customize the no matches output */
            var thisId = $(this).attr("id");
            return "<input class='form-control' id='newicsi_protocolSelectTerm' value='" + term + "'><a href='#' id='addNewicsi_protocolSelect' data-id='" + thisId + "' class='btn blue custombtnstyle'>ADD</a>"
        }
    }).parent().find('.select2-with-searchbox').on('click', '#addNewicsi_protocolSelect', function () {
        /* add the new term */
        var Protocol = $('#newicsi_protocolSelectTerm').val();
        var thisId = $(this).attr("data-id");
        $.post(hosturl + "/controllers/embryoslab.php?ac=addRow", {value: Protocol, table: 'icsi_protocol'}, function (data) {

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

            $('.updateElement[id=' + thisId + ']').trigger("change");
        });
    });

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

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

            $('.updateElement[id=' + thisId + ']').trigger("change");
        });
    });

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

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

            $('.updateElement[id=' + thisId + ']').trigger("change");
        });
    });


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

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

            $('.updateElement[id=' + thisId + ']').trigger("change");
        });
    });


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

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

            $('.updateElement[id=' + thisId + ']').trigger("change");
        });
    });
</script>
{/literal}
