<div class="page-content-wrapper">
    <div class="page-content">
        <div class="row">
            <div class="col-md-12">
                <div class="portlet light portlet-fit bordered calendar">
                    <div class="portlet-title">
                        <div class="caption">
                            <i class=" icon-layers font-green"></i>
                            <span class="caption-subject font-green sbold uppercase">Calendar</span>
                        </div>
                    </div>
                    <div class="portlet-body">
                        <div class="row">
                            <h3>Residences</h3>
                            <div class="col-md-12 col-sm-12" id="cal_container">
                                <div id="residence_rooms_calendar" class="has-toolbar"></div>
                            </div>
                            <div class="clearfix"></div>
                            <hr style="margin-top: 20px;margin-bottom: 20px"/>
                            <h3>Operations</h3>
                            <div class="col-md-4" style="margin-bottom: 20px;">
                                <div class="form-group">
                                    <label class="col-md-3 txtl">Doctor</label>
                                    <div class="col-md-8">
                                        <select class="form-control select2 filters_inputs" required="required" name="filter_doctor" id="filter_doctor" data-placeholder="Select doctor to filter">
                                            <option></option>
                                            {foreach $doctors as $doctor}
                                                <option value="{$doctor.user_id}">{$doctor.name}</option>
                                            {/foreach}
                                        </select>
                                    </div>
                                </div>
                            </div>
                            <div class="col-md-4" style="margin-bottom: 20px;">
                                <div class="form-group">
                                    <label class="col-md-3 txtl">Operation</label>
                                    <div class="col-md-9">
                                        <select class="form-control select2 filters_inputs" required="required" name="filter_operation_type" id="filter_operation_type"
                                                data-placeholder="Select operation">
                                            <option></option>
                                            {foreach $operation_types as $operation_type}
                                                <option value="{$operation_type->id}">{$operation_type->title}</option>
                                            {/foreach}
                                        </select>
                                    </div>
                                </div>
                            </div>
                            <div class="col-md-12 col-sm-12" id="cal_container">
                                <div id="operation_rooms_calendar" class="has-toolbar"></div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>


<div class="modal fade" id="add_operation_modal" tabindex="-1" role="dialog" aria-labelledby="add_operation_modal">
    <div class="modal-dialog modal-lg" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                <h4 class="modal-title" id="add_operation_modal">Add new Residence & Operation</h4>
            </div>
            <form role="form" id="new_operation_form" action="{$hosturl}/controllers/operations_calendar.php?ac=save" method="post">
                <div class="modal-body">
                    <div class="row">
                        <div class="col-md-6" style="padding: 10px 15px;">
                            <div class="form-group">
                                <label class="col-md-3 txtl">Date</label>
                                <div class="col-md-9">
                                    <input type="text" class="form-control notPop datepicker" name="date" id="date" value="{$today}" required="required"/>
                                </div>
                            </div>
                        </div>
                        <div class="col-md-6" style="padding: 10px 15px;">
                            <div class="form-group">
                                <label class="col-md-3 txtl">Doctor</label>
                                <div class="col-md-9">
                                    <select class="form-control select2" required="required" name="doctor_id" data-placeholder="Select...">
                                        <option></option>
                                        {foreach $doctors as $doctor}
                                            <option value="{$doctor.user_id}">{$doctor.name}</option>
                                        {/foreach}
                                    </select>
                                </div>
                            </div>
                        </div>

                        <div class="col-md-6" style="padding: 10px 15px;">
                            <div class="form-group">
                                <label class="col-md-3 txtl">Assistant</label>
                                <div class="col-md-9">
                                    <select class="form-control select2" name="assistant_id" data-placeholder="Select...">
                                        <option></option>
                                        {foreach $doctors as $doctor}
                                            <option value="{$doctor.user_id}">{$doctor.name}</option>
                                        {/foreach}
                                    </select>
                                </div>
                            </div>
                        </div>

                        <div class="col-md-6" style="padding: 10px 15px;">
                            <div class="form-group">
                                <label class="col-md-3 txtl">Operation</label>
                                <div class="col-md-9">
                                    <select class="form-control select2" required="required" name="operation_type_id" id="operation_type_id" data-placeholder="Select...">
                                        <option></option>
                                        {foreach $operation_types as $operation_type}
                                            <option value="{$operation_type->id}">{$operation_type->title}</option>
                                        {/foreach}
                                    </select>
                                </div>
                            </div>
                        </div>
                        <div class="clearfix"></div>
                        <hr>
                        <h3 style="padding: 10px 15px;text-align: center;">Residence</h3>

                        <div class="col-md-6" style="padding: 10px 15px;">
                            <div class="form-group">
                                <label class="col-md-3 txtl">Start time</label>
                                <div class="col-md-9">
                                    <input type="text" class="form-control notPop timepicker timepicker-custom start_time_change" data-type="residence" data-time-plus="0.5"
                                           name="res_start_time" id="res_start_time" value="7:00 AM" required="required"/>
                                </div>
                            </div>
                        </div>

                        <div class="col-md-6" style="padding: 10px 15px;">
                            <div class="form-group">
                                <label class="col-md-3 txtl">End time</label>
                                <div class="col-md-9">
                                    <input type="text" class="form-control notPop timepicker timepicker-custom"
                                           name="res_end_time" id="res_end_time" value="7:30 AM" required="required"/>
                                </div>
                            </div>
                        </div>

                        <div class="col-md-6" style="padding: 10px 15px;">
                            <div class="form-group">
                                <label class="col-md-3 txtl">Room</label>
                                <div class="col-md-6">
                                    <select class="form-control select2" required="required" name="res_room_id" id="res_room_id" data-placeholder="Select...">
                                        <option></option>
                                        {foreach $residenceRooms as $room}
                                            <option value="{$room->id}">{$room->name}</option>
                                        {/foreach}
                                    </select>
                                </div>
                            </div>
                        </div>

                        <div class="col-md-2">
                            <div class="col-md-5" style="margin-top: 12px;">
                                <input type="checkbox" id="vip" class="md-check" name="vip" value="1">
                                <label for="vip">
                                    حجز </label>
                            </div>
                        </div>
                        <div class="clearfix"></div>
                        <hr>
                        <h3 style="padding: 10px 15px;text-align: center;">Operation</h3>


                        <div class="col-md-6" style="padding: 10px 15px;">
                            <div class="form-group">
                                <label class="col-md-3 txtl">Start time</label>
                                <div class="col-md-9">
                                    <input type="text" class="form-control notPop timepicker timepicker-custom start_time_change" data-type="operation" data-time-plus="15"
                                           name="start_time" id="start_time" value="7:00 AM" required="required"/>
                                </div>
                            </div>
                        </div>

                        <div class="col-md-6" style="padding: 10px 15px;">
                            <div class="form-group">
                                <label class="col-md-3 txtl">End time</label>
                                <div class="col-md-9">
                                    <input type="text" class="form-control notPop timepicker timepicker-custom"
                                           name="end_time" id="end_time" value="7:15 AM" required="required"/>
                                </div>
                            </div>
                        </div>

                        <div class="col-md-6" style="padding: 10px 15px;">
                            <div class="form-group">
                                <label class="col-md-3 txtl">Room</label>
                                <div class="col-md-9">
                                    <select class="form-control select2" required="required" name="room_id" id="room_id" data-placeholder="Select...">
                                        <option></option>
                                        {foreach $operation_rooms as $room}
                                            <option value="{$room->id}">{$room->name}</option>
                                        {/foreach}
                                    </select>
                                </div>
                            </div>
                        </div>

                        <div class="col-md-6" style="padding: 10px 15px;">
                            <div class="form-group">
                                <label class="col-md-3 txtl">Patient</label>
                                <div class="col-md-9">
                                    <input type="text" class="form-control" name="patient_id" id="search_patient_op" data-placeholder="Select..."/>
                                </div>
                            </div>
                        </div>

                        <div class="col-md-6" style="padding: 10px 15px;">
                            <div class="form-group">
                                <label class="col-md-3 txtl">Cost</label>
                                <div class="col-md-9">
                                    <input type="text" class="form-control notPop" number="true" name="cost" id="cost" value="0" required="required"/>
                                </div>
                            </div>
                        </div>

                        <div class="col-md-6" style="padding: 10px 15px;">
                            <div class="form-group">
                                <label class="col-md-3 txtl">Visit for</label>
                                <div class="col-md-9">
                                    <div class="md-radio-inline">
                                        <div class="md-radio">
                                            <input type="radio" id="for_husband0" name="for_husband" class="md-radiobtn for_husband" value="0" checked>
                                            <label for="for_husband0">
                                                <span></span>
                                                <span class="check"></span>
                                                <span class="box"></span>
                                                Wife </label>
                                        </div>

                                        <div class="md-radio">
                                            <input type="radio" id="for_husband_1" name="for_husband" class="md-radiobtn for_husband" value="1">
                                            <label for="for_husband_1">
                                                <span></span>
                                                <span class="check"></span>
                                                <span class="box"></span>
                                                Husband </label>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>

                        <div class="col-md-6" style="padding: 10px 15px;">
                            <div class="form-group">

                            </div>
                        </div>


                        <div class="col-md-12" style="padding: 10px 15px;">
                            <div class="form-group">
                                <label class="col-md-2 txtl">Notes</label>
                                <div class="col-md-10">
                                    <input type="text" class="form-control notPop" name="notes" id="notes"/>
                                </div>
                            </div>
                        </div>

                        <div class="col-md-6" style="padding: 10px 15px;">
                            <div class="form-group">
                                <label class="col-md-3 txtl">Cost details</label>
                                <div class="col-md-9">
                                    <input type="text" class="form-control notPop" name="cost_details" id="cost_details"/>
                                </div>
                            </div>
                        </div>

                        <div class="col-md-6" style="padding: 10px 15px;">
                            <div class="form-group">
                                <label class="col-md-3 txtl">instructions</label>
                                <div class="col-md-9">
                                    <input type="text" class="form-control notPop" name="instructions" id="instructions"/>
                                </div>
                            </div>
                        </div>

                    </div>
                </div>
                <div class="modal-footer">
                    {*<input type="hidden" name="date" id="date" value="">*}
                    <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
                    <button type="button" id="save_operation_btn" class="btn btn-primary">Save changes</button>
                </div>
            </form>
        </div>
    </div>
</div>

<div class="modal fade" id="edit_modal" tabindex="-1" role="dialog" aria-labelledby="edit_modal">
    <div class="modal-dialog modal-lg" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                <h4 class="modal-title" id="edit_modal">Edit data</h4>
            </div>
            <form role="form" id="edit_form" action="{$hosturl}/controllers/operations_calendar.php?ac=update" method="post">
                <div class="modal-body text-center" style="padding: 20px 0px 0px;">
                    <img src="{$path}/_assets/global/img/loading-spinner-grey.gif" alt="" class="loading">
                    <span> &nbsp;&nbsp;Loading... </span>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
                    {*<button type="button" id="save_btn" class="btn btn-primary">Save changes</button>*}
                </div>
            </form>
        </div>
    </div>
</div>

<style>

    #operation_rooms_calendar {
        /*max-width: 1100px;*/
    }

    .fc-title {
        width: 100%;
        white-space: nowrap;
        text-align: right !important;
        padding-right: 2px;
        height: 100%;
    }

    .e-content {
        display: block;
        margin-right: 15px;
        height: 100%;
    }

    .fc-license-message {
        display: none;
    }

    .fc-button {
        color: #FFFFFF !important;
        background-color: #4b8df8 !important;
        font-size: 12px !important;
        padding: 3px 8px 3px 8px !important;
        border: 0px solid #000 !important;
        border-radius: 11px !important;
    }

    .portlet.calendar.light .fc-button {
        top: 0;
    }

    .portlet.calendar .fc-toolbar {
        margin-bottom: 9px;
    }

    .fc-content {
        overflow: hidden;
        height: 100%;
    }

    .remove_it {
        /*border: 1px solid;
        border-radius: 12px;
        padding: 2px 4px;*/
        font-size: 14px !important;
        margin-left: 4px;
        float: right;
    }

    .fc-time-tip, .fc-doctor-tip, .fc-operation-type-tip, .fc-content-tip {
        white-space: nowrap;
    }

    .tooltip {
        opacity: 1 !important;
        display: block !important;
        border: none !important;
        border-radius: 5px !important;
    }

    .tooltip-inner {
        max-width: fit-content;
        background-color: transparent;
        color: #000;
    }

    .tooltip-arrow {
        display: block;
    }

    .popper,
    .tooltip {
        position: absolute;
        z-index: 9999;
        background: #FFC107;
        color: black;
        width: fit-content;
        border-radius: 3px;
        box-shadow: 0 0 2px rgba(0, 0, 0, 0.5);
        padding: 10px;
        text-align: center;
    }

    .style5 .tooltip {
        background: #1E252B;
        color: #FFFFFF;
        max-width: 200px;
        width: auto;
        font-size: .8rem;
        padding: .5em 1em;
    }

    .popper .popper__arrow,
    .tooltip .tooltip-arrow {
        width: 0;
        height: 0;
        border-style: solid;
        position: absolute;
        margin: 5px;
    }

    .tooltip .tooltip-arrow,
    .popper .popper__arrow {
        border-color: #FFC107;
    }

    .style5 .tooltip .tooltip-arrow {
        border-color: #1E252B;
    }

    .popper[x-placement^="top"],
    .tooltip[x-placement^="top"] {
        margin-bottom: 5px;
    }

    .popper[x-placement^="top"] .popper__arrow,
    .tooltip[x-placement^="top"] .tooltip-arrow {
        border-width: 5px 5px 0 5px;
        border-left-color: transparent;
        border-right-color: transparent;
        border-bottom-color: transparent;
        bottom: -5px;
        left: calc(50% - 5px);
        margin-top: 0;
        margin-bottom: 0;
    }

    .popper[x-placement^="bottom"],
    .tooltip[x-placement^="bottom"] {
        margin-top: 5px;
    }

    .tooltip[x-placement^="bottom"] .tooltip-arrow,
    .popper[x-placement^="bottom"] .popper__arrow {
        border-width: 0 5px 5px 5px;
        border-left-color: transparent;
        border-right-color: transparent;
        border-top-color: transparent;
        top: -5px;
        left: calc(50% - 5px);
        margin-top: 0;
        margin-bottom: 0;
    }

    .tooltip[x-placement^="right"],
    .popper[x-placement^="right"] {
        margin-left: 5px;
    }

    .popper[x-placement^="right"] .popper__arrow,
    .tooltip[x-placement^="right"] .tooltip-arrow {
        border-width: 5px 5px 5px 0;
        border-left-color: transparent;
        border-top-color: transparent;
        border-bottom-color: transparent;
        left: -5px;
        top: calc(50% - 5px);
        margin-left: 0;
        margin-right: 0;
    }

    .popper[x-placement^="left"],
    .tooltip[x-placement^="left"] {
        margin-right: 5px;
    }

    .popper[x-placement^="left"] .popper__arrow,
    .tooltip[x-placement^="left"] .tooltip-arrow {
        border-width: 5px 0 5px 5px;
        border-top-color: transparent;
        border-right-color: transparent;
        border-bottom-color: transparent;
        right: -5px;
        top: calc(50% - 5px);
        margin-left: 0;
        margin-right: 0;
    }

    table{
        color: #000;
        font-weight: bolder;
    }

    thead, th {
        background: none;

    }

    .fc-theme-standard td, .fc-theme-standard th {
        border: 1px solid #000;
    }

    .fc .fc-col-header-cell-cushion {
        display: inline-block;
        padding: 10px 4px;
    }

    .portlet.calendar .fc-event .fc-title {
        color: #000;
        font-weight: bolder;
    }

</style>








