<meta charset="utf8">
<style>
    #mainDiv 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: #c1c1c1;
    }
</style>
<div class="page-content-wrapper">
    <div class="page-content">
        <div class="row">
            <div class="col-md-12" id="gprinModel">
                <!-- BEGIN EXAMPLE TABLE PORTLET-->
                <div class="portlet box blue">
                    <div class="portlet-title">
                        <div class="caption">
                            <i class="fa fa-user"></i>صحيفة دخول وخروج
                        </div>
                        <div class="actions">
                            {if isset($is_add)}
                            <a href="{$hosturl}/controllers/{$controllname}.php?ac=complete_one&show={$show}&patientid={$patientId}&id={$entry_discharge_data.id}&tname={$tableName}"
                                class="btn btn-default btn-sm pull-left" style="margin-right: 5px;">
                                save </a>
                            {/if}
                            <a href="{$hosturl}/controllers/{$controllname}.php?ac=entry_discharge_show&patientid={$patientId}"
                                class="btn btn-default btn-sm">
                                Show </a>

                            <a class="btn btn-default btn-sm assessmentFormPrint" data-id="{$entry_discharge_data.id}"
                                data-fn="entry_discharge_print">
                                <i class="fa fa-print"></i> </a>
                        </div>
                    </div>
                    <div class="portlet-body all rtl">
                        <!---======================================================== tab1============================================================================================ ----->
                        <div class="row">
                            <div id="mainDiv">
                                <div class="row">
                                    <div class="portlet-body form">
                                        <form>
                                            <div class="form-body">
                                                <table>
                                                    <tr>
                                                        <th>تاريخ الميلاد</th>
                                                        <td>
                                                            <input type="text" class="form-control"
                                                                value="{$dateofbirth}" readonly />
                                                        </td>
                                                        <th>النوع</th>
                                                        <td>
                                                            <input type="text" class="form-control" value="{$sex}"
                                                                readonly />
                                                        </td>
                                                        <th>الرقم القومي</th>
                                                        <td>
                                                            <input type="text" class="form-control"
                                                                value="{$nationalid}" readonly />
                                                        </td>
                                                    </tr>
                                                    <tr>
                                                        <th>الحالة الاجتماعية</th>
                                                        <td>
                                                            <input type="text" class="form-control"
                                                                value="{$marital_st}" readonly />
                                                        </td>
                                                        <th>المهنة</th>
                                                        <td>
                                                            <input type="text" class="form-control" value="{$job}"
                                                                readonly />
                                                        </td>
                                                        <th>القسم</th>
                                                        <td>
                                                            <input type="text" class="form-control" value="{$deptName}"
                                                                readonly />
                                                        </td>
                                                    </tr>
                                                    <tr>
                                                        <th>رقم التليفون</th>
                                                        <td>
                                                            <input type="text" class="form-control" value="{$phone}"
                                                                readonly />
                                                        </td>
                                                        <th>الوقت</th>
                                                        <td>
                                                            <input type="text" class="form-control"
                                                                value="{$entry_discharge_data.visittime}" readonly />
                                                        </td>
                                                        <th>العنوان</th>
                                                        <td>
                                                            <input type="text" class="form-control" value="{$address}"
                                                                readonly />
                                                        </td>
                                                    </tr>
                                                    <tr>
                                                        <th class="wds12">الطبيب المعالج الآمر بالدخول</th>
                                                        <td colspan="2">
                                                            <input type="text" class="form-control" readonly
                                                                value="{$entry_discharge_data.docName}" />
                                                        </td>
                                                        <th> تاريخ الدخول </th>
                                                        <td colspan="2">
                                                            <input type="text" class="form-control"
                                                                value="{$entry_discharge_data.visitdate}" readonly />
                                                        </td>
                                                    </tr>
                                                    <tr>
                                                        <th class="wds12">التشخيص المبدئي</th>
                                                        <td colspan="5">
                                                            <textarea class="form-control" rows="2" readonly
                                                                placeholder="التشخيص">{$entry_discharge_data.diagnosis}
                                                        </textarea>
                                                        </td>
                                                    </tr>
                                                    <tr>
                                                        <th class="wds10"> الحساسية </th>
                                                        <td colspan="5">
                                                            <div class="allergies_div">
                                                                <select name="allergies"
                                                                    class="form-control select2me allergies updatePresentHistory"
                                                                    id="allergies" data-placeholder="Select..."
                                                                    data-id="{$entry_discharge_data.id}" multiple
                                                                    data-colName="allergies"
                                                                    data-tableName="entry_patient_discharge">
                                                                    <option value="">choose</option>
                                                                    {foreach $allAllergies as $data}
                                                                    <option value="{$data.id}" {if
                                                                        $data.id|in_array:$entry_discharge_data.allergies}
                                                                        selected {/if}>{$data.name}</option>
                                                                    {/foreach}
                                                                    <option value="-1" class="addpresentHistory">Add
                                                                    </option>
                                                                    <option value="-2" class="deleteoptincompo">
                                                                        Delete</option>
                                                                </select>
                                                            </div>
                                                        </td>
                                                    </tr>
                                                    <tr>
                                                        <th class="wds10"> الأمراض المعدية </th>
                                                        <td colspan="5">
                                                            <div class="contagious_disease_div">
                                                                <select name="contagious_disease"
                                                                    class="form-control select2me contagious_disease updatePresentHistory"
                                                                    id="contagious_disease" data-placeholder="Select..."
                                                                    data-id="{$entry_discharge_data.id}" multiple
                                                                    data-colName="contagious_disease"
                                                                    data-tableName="entry_patient_discharge">
                                                                    <option value="">choose</option>
                                                                    {foreach $allDiseases as $data}
                                                                    <option value="{$data.id}" {if
                                                                        $data.id|in_array:$entry_discharge_data.contagious_disease}
                                                                        selected {/if}>{$data.name}</option>
                                                                    {/foreach}
                                                                    <option value="-1" class="addpresentHistory">Add
                                                                    </option>
                                                                    <option value="-2" class="deleteoptincompo">
                                                                        Delete</option>
                                                                </select>
                                                            </div>
                                                        </td>
                                                    </tr>
                                                </table>
                                                <div class="clearfix"></div>
                                                <hr>
                                                <h4 class="bold underline">حركة المريض بالأقسام</h4>
                                                <table>
                                                    <thead>
                                                        <tr>
                                                            <th>تاريخ الدخول </th>
                                                            <th>الساعة</th>
                                                            <th>القسم</th>
                                                            <th>المعاملة المالية</th>
                                                            <th>تاريخ الخروج</th>
                                                            <th>الساعة</th>
                                                            <th>نتيجة الخروج</th>
                                                            <th>رقم الغرفة</th>
                                                            <th>رقم السرير</th>
                                                            <th>ملاحظات</th>
                                                        </tr>
                                                    </thead>
                                                    <tbody>
                                                        {foreach $allVisits as $visit}
                                                        <tr>
                                                            <td>{$visit.visitdate}</td>
                                                            <td>{$visit.visittime}</td>
                                                            <td>{$visit.deptName}</td>
                                                            <td>{$visit.organization_name}</td>
                                                            <td>{$visit.res_p_exit|date_format:"Y-m-d"}</td>
                                                            <td>{$visit.res_p_exit|date_format:"H:i"}</td>
                                                            <td>{$visit.enddate}</td>
                                                            <td>{$visit.roomNo}</td>
                                                            <td>{$visit.bed_no}</td>
                                                            <td>{$visit.notes}</td>
                                                        </tr>
                                                        {/foreach}
                                                    </tbody>
                                                </table>
                                                <div class="clearfix"></div>
                                                <hr>
                                                <h4 class="bold underline">ولي الأمر</h4>
                                                <table>
                                                    <thead>
                                                        <tr>
                                                            <th>رقم حساب</th>
                                                            <th>اسم المرافق</th>
                                                            <th>السن</th>
                                                            <th>رقم التليفون</th>
                                                            <th>المعاملة المالية</th>
                                                            <th>تاريخ الدخول</th>
                                                            <th>تاريخ الخروج</th>
                                                        </tr>
                                                    </thead>
                                                    <tbody>
                                                        {foreach $allCareGivers as $one}
                                                        <tr>
                                                            <td>{$one.account_no}</td>
                                                            <td>{$one.name}</td>
                                                            <td>{$one.age}</td>
                                                            <td>{$one.phone}</td>
                                                            <td>{$one.financial}</td>
                                                            <td>{$one.entry_date|date_format:"Y-m-d"}</td>
                                                            <td>{$one.exit_date|date_format:"Y-m-d"}</td>
                                                        </tr>
                                                        {/foreach}
                                                    </tbody>
                                                </table>

                                            </div>
                                        </form>
                                    </div>
                                </div>
                                <div class="clearfix"></div>
                            </div>
                        </div>
                        <div class="clearfix"></div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<div class="clearfix"></div>
<div id="vvv"></div>
<input type="hidden" id="controllName" value="{$controllname}">
<input type="hidden" id="patientId" value="{$patientid}" />

<div id="forPrint"></div>
<!----#########################################################################  model ##############################################################################################################--->
<div class="all">
    <!--------------------------------------------------------------------------- add Present History Model-------------------------------------------------------------------------------------->
    <div class="bootbox modal fade bootbox-alert in" tabindex="-1" role="dialog" aria-hidden="false" id="add_model">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true"></button>
                    <h4 class="modal-title"> Add New </h4>
                </div>
                <div class="modal-body">
                    <div class="portlet-body form">
                        <form action="" id="" method="post" class="form-horizontal  emptyform">
                            <div class="form-body">
                                <!------===========================================------->
                                <div class="form-group">
                                    <div class="col-md-1"></div>
                                    <label class="col-md-3 control-label txtl"> Name </label>
                                    <div class="col-md-8">
                                        <input type="text" class="addpresentHistoryName wds95" id="presentHistoryName"
                                            data-select="" data-tablename="" data-id="" data-mainTable="" value="">
                                    </div>
                                </div>

                                <!------===========================================------->
                                <div class="modal-footer">
                                    <button type="button" id="amountcloseinput" class="btn default"
                                        data-dismiss="modal">Close</button>
                                </div>
                            </div>
                        </form>
                    </div>
                </div>
                <!-- /.modal-content -->
            </div>
        </div>
    </div>
    <!--------------------------------------------------------------------------- edit Present History  Model-------------------------------------------------------------------------------------->
    <div class="bootbox modal fade bootbox-alert in" tabindex="-1" role="dialog" aria-hidden="false" id="edit_model">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true"></button>
                    <h4 class="modal-title"> Edit </h4>
                </div>
                <div class="modal-body">
                    <div class="portlet-body form">
                        <form action="" id="" method="post" class="form-horizontal  emptyform">
                            <div class="form-body">
                                <!------===========================================------->
                                <div class="form-group">
                                    <label class="col-md-1 control-label"> </label>
                                    <div class="col-md-10">
                                        <div id="alldatadiv" class=""> </div>
                                    </div>
                                    <label class="col-md-1 control-label"> </label>
                                </div>

                                <!------===========================================------->
                                <div class="modal-footer">
                                    <button type="button" id="amountcloseinput" class="btn default"
                                        data-dismiss="modal">Close</button>
                                </div>
                            </div>
                        </form>
                    </div>
                </div>
                <!-- /.modal-content -->
            </div>
        </div>
    </div>

</div>

<script>
    $(".amrpop,input[type='text']:not(.datepicker):not(.notPop),textarea:not(.notPop)").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>