<style>
    table {
        font-family: arial, sans-serif;
        border-collapse: collapse;
        width: 100%;
        table-layout: fixed
    }

    td, th {
        border: 1px solid #000000;
        text-align: center;
        padding: 2px;
    }

    tr:nth-child(even) {
        background-color: #dddddd;
    }
</style>


<div class="page-content-wrapper">
    <div class="page-content">
        <div class="row rtl">
            <div class="col-md-12 clinick invz" id="gprinModel">
                <!-- BEGIN EXAMPLE TABLE PORTLET-->
                <div class="portlet box blue">
                    <div class="portlet-title">
                        <div class="caption fright">
                            <i class="fa fa-user fright" style="margin-left: 5px;"></i>تقرير التحويلات الخارجية
                        </div>
                        <div class="actions fleft">
                            <a href="{$hosturl}/controllers/{$controllname}.php?ac=external_show" class="btn btn-default btn-sm">
                                عرض الكل  </a>

                        </div>
                    </div>
                    <div class="portlet-body all">
                        <div class="row">
                            <div class="portlet-body form">
                                <form action="{$hosturl}/controllers/{$controllname}.php?ac={$toDo}"
                                      method="post" class="clinick " enctype="multipart/form-data">
                                    <div class="form-body">
                                        <table>
                                            <thead>
                                                <tr>
                                                    <th class="wds12">      رقم الحالة  :  </th>
                                                    <td class="wds17">
                                                        <input type="text"  id="statusNoRemote" value="{$external_transfer.statusno}"
                                                               class="form-control  txtc searchPatRemote positiveNo "  data-alert="no"  >
                                                    </td>

                                                    <th class="wds12">      إسم  الحالة  :  </th>
                                                    <td>
                                                        <input type="hidden" class="form-control "    id="patientIdRemote"
                                                               required name="patientId" >
                                                        <input type="hidden"    id="patientStatus" value="{$external_transfer.statusno}" >
                                                    </td>
                                                </tr>

                                                <tr>
                                                    <th>      التاريخ :  </th>
                                                    <td>
                                                        <input type="text" class="form-control  datepicker " readonly
                                                               name="transfer_date" value="{$transfer_date}"  />
                                                    </td>

                                                    <th>   التكلفة :  </th>
                                                    <td>
                                                        <input type="text" class="form-control positivefloat " required
                                                               name="cost" value="{$external_transfer.cost}"  />
                                                    </td>
                                                </tr>

                                                <tr>
                                                    <th>      رقم الايصال :  </th>
                                                    <td>
                                                        <input type="text" class="form-control  " 
                                                               name="receipt_no" value="{$external_transfer.receipt_no}"  />
                                                    </td>

                                                    <th>      المركز  :  </th>
                                                    <td>
                                                        <select  class="form-control refer_center"  name="refer_center"
                                                                 id="refer_center">
                                                            <option value="">choose</option>
                                                            {foreach  $refer_center as $one}
                                                            <option value="{$one.id}" {if $external_transfer.refer_center == $one.id } selected {/if} >{$one.name}</option>
                                                            {/foreach}
                                                            <option value="-1" class="deleteoptincompo">تعديل </option>
                                                        </select>
                                                    </td>
                                                </tr>


                                                <tr>
                                                    <th>      وصف  العملية   :  </th>
                                                    <td colspan="3">
                                                        <textarea class="form-control" rows="5"  placeholder=""
                                                                  name="discription" >{$external_transfer.discription}</textarea>
                                                    </td>
                                                </tr>

                                                <tr>
                                                    <th>      صورة مرفقة     :  </th>
                                                    <td colspan="3">
                                                        <div class="col-md-12">
                                                            <div class="fileinput fileinput-new" data-provides="fileinput">
                                                                <div class="fileinput-preview thumbnail" data-trigger="fileinput" style="width: 200px; height: 150px;">
                                                                    <img {if $external_transfer.img}  src="{$hosturl}/../upload/transferimg/{$external_transfer.img}" {/if}/>
                                                                </div>

                                                                {if $external_transfer.img}
                                                                <input type="hidden" id="imageurl" name="imageurl" value="{$external_transfer.img}" />
                                                                {/if}
                                                                <div>
                                                                    <span class="btn default btn-file">
                                                                        <span class="fileinput-new"> Select image </span>
                                                                        <span class="fileinput-exists"> Change </span>
                                                                        <input type="file" name="img" id="img"  class=" form-control">
                                                                    </span>
                                                                    <a  class="input-group-addon btn" target="_blank"
                                                                        {if !$external_transfer.img}style="display: none;"
                                                                        {else}
                                                                        href="{$hosturl}/../upload/transferimg/{$external_transfer.img}"
                                                                        {/if}> Show </a>
                                                                    <a href="#" class="btn red fileinput-exists  "

                                                                       data-dismiss="fileinput"> Remove </a> </div>
                                                            </div>



                                                        </div>
                                                    </td>
                                                </tr>
                                            </thead>
                                        </table>
                                    </div>

                                    <input type="hidden" id="id" name="id" value="{$external_transfer.id}" />

                                    <div class="form-actions">
                                        <div class="row">
                                            <div class="col-md-offset-2 col-md-10">
                                                <a class="btn default" href="{$hosturl}/controllers/{$controllname}.php?ac=external_show">إلغاء </a>
                                                <button type="submit" class="btn blue">حفظ </button>
                                            </div>
                                        </div>
                                    </div>
                                </form>
                            </div>
                        </div>
                        <div class="clearfix"></div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

<input type="hidden" id="controllName" value="{$controllname}">
<div  id="editModalDiv"></div>
{literal}
<script>
    $(document).ready(function (e) {
        var hosturl = $('#hosturl').val();
        var statusNo = $('#statusNoRemote').val();
        if (statusNo > 0) {
            $.post(hosturl + '/controllers/visits.php?ac=getnameswithstatus', {statusNo: statusNo}, function (res) {
                var obj = JSON.parse(res);
                $('#patientIdRemote').val(null).empty().trigger("change");
                var option = new Option(obj.name, obj.id, true, true);
                $("#patientIdRemote").append(option);
                $('#patientIdRemote').select2("val", obj.id).trigger("change").trigger('select2:select');
                $("#select2-chosen-1").html(obj.name);
            });
        } else {
            $('#patientIdRemote').val(null).empty().trigger("change");
        }
    });

    $(".amrpop,input[type='text']:not(.datepicker),textarea").hover(function () {
        var pop_value = $(this).val();
        $(this).attr({
            "data-toggle": "popover",
            "data-trigger": "hover",
            "data-placement": "bottom",
            "data-content": pop_value
        });
        $(this).popover("show");
    });

</script>
{/literal}