<?php  include('techsyn_header.php'); ?>
<!-- Main Content Container for side bar and body-->
<div class="main-container ace-save-state" id="main-container">
    <?php  include('techsyn_sidebar.php'); ?>
    <!--breadcrumb-->
    <div class="main-content">
        <div class="main-content-inner">
            <div class="breadcrumbs ace-save-state" id="breadcrumbs">
                <ul class="breadcrumb">
                    <li class="#">Patient Management</li>
                    <li class="active">Day Care Patients List</li>
                </ul>
            </div>
            <!-- End of breadcrumb -->
            <div class="page-content">
                <form name="f1" method="post" id="flex_form_opd" action="">
                    <div id="flex1" style="width: 100%">
                        <input type="hidden" name="flex_employee_appointment_id" id="flex_employee_appointment_id" />

                    </div>
                </form>
                <form name="export_form" method="post" id="export_form" action="">
                    <input type="hidden" name="flex_employee_appointment_id" id="flex_employee_appointment_id" /> <input
                        type="hidden" name="pdf_action" id="pdf_action" value="pdf_detention_list.php" /> <input
                        type="hidden" name="excel_action" id="excel_action" value="excel_detention_list.php" />
                </form>
                <form name="flex_appointment_form" method="post" id="flex_appointment_form" action="">
                    <input type="hidden" name="appointmentId" id="appointmentId" /> <input type="hidden"
                        name="flex_opd_id" id="flex_opd_id" /> <input type="hidden" name="returnPage" id="returnPage" />
                </form>
            </div>
        </div>
        <!-- /.page-content -->
    </div>
</div>
<!-- /.main-content -->
<link rel="stylesheet" href="assets/font-awesome/4.5.0/css/font-awesome.min.css" />
<link rel="stylesheet" href="assets/css/jquery-ui.custom.min.css" />
<link rel="stylesheet" href="assets/css/chosen.min.css" />
<link rel="stylesheet" href="assets/css/bootstrap-datepicker3.min.css" />
<link rel="stylesheet" href="assets/css/bootstrap-timepicker.min.css" />
<link rel="stylesheet" href="assets/css/daterangepicker.min.css" />
<link rel="stylesheet" href="assets/css/bootstrap-datetimepicker.min.css" />
<link rel="stylesheet" href="assets/css/bootstrap-colorpicker.min.css" />
<script type="text/javascript" src="js/typeahead.bundle.js"></script>
<script src="assets/js/jquery-ui.custom.min.js" type="text/javascript"></script>
<script src="assets/js/jquery.ui.touch-punch.min.js" type="text/javascript"></script>
<script src="assets/js/chosen.jquery.min.js" type="text/javascript"></script>
<script src="assets/js/spinbox.min.js" type="text/javascript"></script>
<script src="assets/js/bootstrap-datepicker.min.js" type="text/javascript"></script>
<script src="assets/js/bootstrap-timepicker.min.js" type="text/javascript"></script>
<script src="assets/js/jquery.dataTables.min.js" type="text/javascript"></script>
<script src="assets/js/jquery.dataTables.bootstrap.min.js" type="text/javascript"></script>
<script src="assets/js/dataTables.buttons.min.js" type="text/javascript"></script>
<script src="assets/js/buttons.flash.min.js" type="text/javascript"></script>
<script src="assets/js/buttons.html5.min.js" type="text/javascript"></script>
<script src="assets/js/buttons.print.min.js" type="text/javascript"></script>
<script src="assets/js/buttons.colVis.min.js" type="text/javascript"></script>
<script src="assets/js/dataTables.select.min.js" type="text/javascript"></script>
<script src="assets/js/moment.min.js" type="text/javascript"></script>
<script src="assets/js/daterangepicker.min.js" type="text/javascript"></script>
<script src="assets/js/bootstrap-datetimepicker.min.js" type="text/javascript"></script>
<script src="assets/js/bootstrap-colorpicker.min.js" type="text/javascript"></script>
<script src="assets/js/jquery.knob.min.js" type="text/javascript"></script>
<script src="assets/js/autosize.min.js" type="text/javascript"></script>
<script src="assets/js/jquery.inputlimiter.min.js" type="text/javascript"></script>
<script src="assets/js/jquery.maskedinput.min.js" type="text/javascript"></script>
<script src="assets/js/bootstrap-tag.min.js" type="text/javascript"></script>
<script src="assets/js/ace-elements.min.js" type="text/javascript"></script>
<style type="text/css">
.emergency {
    background-color: red;
}

.injury {
    background-color: red;
}
</style>
<script type="text/javascript">
$(function() {
    var w = screen.width * .90;
    var h = 0;
    h = (window.innerHeight - ($("#navbar").height() + $(".breadcrumbs").height())) * .75;
    $("#flex1").flexigrid({
        url: 'detention_list_script.php',
        dataType: 'json',
        colModel: [{
                display: 'Sr',
                name: 'count',
                width: w * .02,
                sortable: false,
                align: 'left'
            },
            {
                display: '',
                name: 'link',
                width: w * .1,
                sortable: false,
                align: 'left'
            },
            {
                display: 'Date',
                name: 'appointment_date',
                width: w * .1,
                sortable: true,
                align: 'left'
            },
            {
                display: 'Ticket No',
                name: 'appointment_id',
                width: w * .07,
                sortable: true,
                align: 'left'
            },
            {
                display: 'ECode/G.Pass',
                name: 'emp_code',
                width: w * .08,
                sortable: true,
                align: 'left'
            },
            {
                display: 'Patient Name',
                name: 'patient_name',
                width: w * .1,
                sortable: true,
                align: 'left'
            },
            // {display: 'Emergency', name : 'IsEmergency', width : w*.07, sortable : true, align: 'left'},
            // {display: 'Injury', name : 'appointment_type', width : w*.07, sortable : true, align: 'left'},
            {
                display: 'Doctor Consulted',
                name: 'doctor_attended_flag',
                width: w * .07,
                sortable: true,
                align: 'left'
            },
            {
                display: 'Day Care Status',
                name: 'disposal_time',
                width: w * .07,
                sortable: true,
                align: 'left'
            },
            {
                display: 'Complaints',
                name: 'complaints',
                width: w * .1,
                sortable: true,
                align: 'left'
            },
            {
                display: 'Examination Findings',
                name: 'examination_remarks',
                width: w * .1,
                sortable: true,
                align: 'left'
            },
            {
                display: 'Diagnosis',
                name: 'injury_types_new',
                width: w * .1,
                sortable: true,
                align: 'left'
            },
            {
                display: 'Treatments',
                name: 'hospital_treatment',
                width: w * .15,
                sortable: true,
                align: 'left'
            },
            {
                display: 'Referral',
                name: 'referral',
                width: w * .05,
                sortable: true,
                align: 'left'
            },
            {
                display: 'Follow-up',
                name: 'followup',
                width: w * .05,
                sortable: true,
                align: 'left'
            },
            {
                display: 'Vitals',
                name: 'bp_sbp',
                width: w * .07,
                sortable: true,
                align: 'left'
            }
        ],
        buttons: [{
                name: 'PDF',
                bclass: 'print',
                onpress: pdf
            },
            {
                separator: true
            },
            {
                name: 'Excel',
                bclass: 'print_excel',
                onpress: excel
            },
            {
                separator: true
            }
        ],
        searchitems: [{
                display: 'Patient Name',
                name: 'patient_name'
            },
            {
                display: 'ECode/GPassNo',
                name: 'emp_code'
            },
            {
                display: 'Doctor Consulted(Y/N)',
                name: 'doctor_attended_flag'
            },
            {
                display: 'Ticket No',
                name: 'ticket_no',
                isdefault: true
            },
            // 					{display: 'Appointment Date (dd/mm/yyyy)', name : 'appointment_date'},
            // 					{display: 'Appointment Date Between (dd/mm/yyyy-dd/mm/yyyy)', name : 'appointment_date_between'},
            {
                display: 'Complaints',
                name: 'complaints',
            },
            {
                display: 'Examination Findings',
                name: 'examination_remarks'
            },
            // 					{display: 'Diagnosis', name : 'ailment_name'},
            //                  {display: 'Treatments', name : 'hospital_treatment'},
            //                     {display: 'Emergency', name : 'IsEmergency'},
            // {display: 'Injury Only(I)', name : 'appointment_type'},
            // {display: 'OPD Only(O)', name : 'appointment_type'},
            //                     {display: 'Remarks', name : 'remarks'},
        ],
        sortname: "appointment_date",
        sortorder: "desc",
        usepager: true, //pagination
        //title:"Employee OPD",
        useRp: true,
        rp: 50, //records per page
        showTableToggleBtn: false, //toggle button for the whole table
        resizable: true,
        //	width: w, 
        height: h,
        singleSelect: true
    });
});

function pdf() {
    window.open('ajax_pdf.php', 'Detention List');
}

function excel() {
    window.open('ajax_excel.php', 'Detention List');
}

function delete_employee_appointment_history(appointmnentId) {
    //$("#flex_employee_appointment_id").val(appointmnentId);
    BootstrapDialog.confirm('Are you sure to delete?', function(result) {
        if (result) {
            $.ajax({
                url: 'delete_appointment_emp.php',
                type: "POST",
                data: {
                    'flex_employee_appointment_id': appointmnentId
                },
                success: function(data) {
                    if (data.indexOf("SUCCESS") != -1) {
                        BootstrapDialog.alert('Deleted Successfully.');
                        $("#flex1").flexReload();
                        //loadAppointmentHistory('<?php  echo $_REQUEST['flex_opd_id']?>');
                    } else {
                        BootstrapDialog.alert('Error Deleting');
                    }
                    return;
                },
                error: function(data) {
                    BootstrapDialog.alert('Error Deleting');
                    return;
                }
            });
        }
    });
}
var appointment_id = "";

function open_detention(appointmentId, appointment_status, emp_id, action) {

    if (action == 'V') {
        document.forms['flex_appointment_form'].action = "view_ipd.php";
    } else if (action == 'E') {
        document.forms["flex_appointment_form"].action = "edit_ipd.php";

    }
    $("#flex_appointment_form").method = "post";
    $("#flex_appointment_form").find("#appointmentId").val(appointmentId);
    $("#flex_appointment_form").find("#flex_opd_id").val(emp_id);
    $("#flex_appointment_form").find("#returnPage").val("appointment_list.php");
    $("#flex_appointment_form").submit();
}

function open_dashboard(emp_id) {
    if (emp_id != null && emp_id != '') {
        $("#flex_opd_id").val(emp_id);

        $("#flex_appointment_form").attr('method', 'POST');
        $("#flex_appointment_form").attr('action', 'emp_dashboard.php');
        $("#flex_appointment_form").submit();

    }
}
</script>
<script type="text/javascript">
jQuery(function($) {
    var myTable =
        $('#dynamic-table')
        //.wrap("<div class='dataTables_borderWrap' />")   //if you are applying horizontal scrolling (sScrollX)
        .DataTable({
            bAutoWidth: false,
            "aoColumns": [{
                    "bSortable": false
                },
                null, null, null, null, null,
                {
                    "bSortable": false
                }
            ],
            "aaSorting": [],
            select: {
                style: 'multi'
            }
        });
    //style the message box
    var defaultCopyAction = myTable.button(1).action();
    myTable.button(1).action(function(e, dt, button, config) {
        defaultCopyAction(e, dt, button, config);
        $('.dt-button-info').addClass('gritter-item-wrapper gritter-info gritter-center white');
    });
    var defaultColvisAction = myTable.button(0).action();
    myTable.button(0).action(function(e, dt, button, config) {
        defaultColvisAction(e, dt, button, config);
        if ($('.dt-button-collection > .dropdown-menu').length == 0) {
            $('.dt-button-collection')
                .wrapInner('<ul class="dropdown-menu dropdown-light dropdown-caret dropdown-caret" />')
                .find('a').attr('href', '#').wrap("<li />")
        }
        $('.dt-button-collection').appendTo('.tableTools-container .dt-buttons')
    });
    ////
    setTimeout(function() {
        $($('.tableTools-container')).find('a.dt-button').each(function() {
            var div = $(this).find(' > div').first();
            if (div.length == 1) div.tooltip({
                container: 'body',
                title: div.parent().text()
            });
            else $(this).tooltip({
                container: 'body',
                title: $(this).text()
            });
        });
    }, 500);
    myTable.on('select', function(e, dt, type, index) {
        if (type === 'row') {
            $(myTable.row(index).node()).find('input:checkbox').prop('checked', true);
        }
    });
    myTable.on('deselect', function(e, dt, type, index) {
        if (type === 'row') {
            $(myTable.row(index).node()).find('input:checkbox').prop('checked', false);
        }
    });
    /////////////////////////////////
    //table checkboxes
    $('th input[type=checkbox], td input[type=checkbox]').prop('checked', false);
    //select/deselect all rows according to table header checkbox
    $('#dynamic-table > thead > tr > th input[type=checkbox], #dynamic-table_wrapper input[type=checkbox]').eq(
        0).on('click', function() {
        var th_checked = this.checked; //checkbox inside "TH" table header
        $('#dynamic-table').find('tbody > tr').each(function() {
            var row = this;
            if (th_checked) myTable.row(row).select();
            else myTable.row(row).deselect();
        });
    });
    //select/deselect a row when the checkbox is checked/unchecked
    $('#dynamic-table').on('click', 'td input[type=checkbox]', function() {
        var row = $(this).closest('tr').get(0);
        if (this.checked) myTable.row(row).deselect();
        else myTable.row(row).select();
    });
    $(document).on('click', '#dynamic-table .dropdown-toggle', function(e) {
        e.stopImmediatePropagation();
        e.stopPropagation();
        e.preventDefault();
    });
    //And for the first simple table, which doesn't have TableTools or dataTables
    //select/deselect all rows according to table header checkbox
    var active_class = 'active';
    $('#simple-table > thead > tr > th input[type=checkbox]').eq(0).on('click', function() {
        var th_checked = this.checked; //checkbox inside "TH" table header
        $(this).closest('table').find('tbody > tr').each(function() {
            var row = this;
            if (th_checked) $(row).addClass(active_class).find('input[type=checkbox]').eq(0)
                .prop('checked', true);
            else $(row).removeClass(active_class).find('input[type=checkbox]').eq(0).prop(
                'checked', false);
        });
    });
    //select/deselect a row when the checkbox is checked/unchecked
    $('#simple-table').on('click', 'td input[type=checkbox]', function() {
        var $row = $(this).closest('tr');
        if ($row.is('.detail-row ')) return;
        if (this.checked) $row.addClass(active_class);
        else $row.removeClass(active_class);
    });
    /********************************/
    //add tooltip for small view action buttons in dropdown menu
    $('[data-rel="tooltip"]').tooltip({
        placement: tooltip_placement
    });
    //tooltip placement on right or left
    function tooltip_placement(context, source) {
        var $source = $(source);
        var $parent = $source.closest('table')
        var off1 = $parent.offset();
        var w1 = $parent.width();
        var off2 = $source.offset();
        //var w2 = $source.width();
        if (parseInt(off2.left) < parseInt(off1.left) + parseInt(w1 / 2)) return 'right';
        return 'left';
    }
    /***************/
    $('.show-details-btn').on('click', function(e) {
        e.preventDefault();
        $(this).closest('tr').next().toggleClass('open');
        $(this).find(ace.vars['.icon']).toggleClass('fa-angle-double-down').toggleClass(
            'fa-angle-double-up');
    });
    /***************/
    /**
    //add horizontal scrollbars to a simple table
    $('#simple-table').css({'width':'2000px', 'max-width': 'none'}).wrap('<div style="width: 1000px;" />').parent().ace_scroll(
      {
    	horizontal: true,
    	styleClass: 'scroll-top scroll-dark scroll-visible',//show the scrollbars on top(default is bottom)
    	size: 2000,
    	mouseWheelLock: true
      }
    ).css('padding-top', '12px');
    */
})
$('#doj').datepicker({
    autoclose: true,
    format: 'dd/mm/yyyy',
    startDate: '1d/1m/2000y',
    endDate: 'current',
    todayHighlight: true
}).next().on(ace.click_event, function() {
    $(this).prev().focus();
});
$('#dob').datepicker({
    autoclose: true,
    format: 'dd/mm/yyyy',
    startDate: '1d/1m/1970y',
}).next().on(ace.click_event, function() {
    $(this).prev().focus();
});
</script>
<?php  include('common_list.php'); ?>
<?php  include('techsyn_footer.php'); ?>
<?php  include('common_ace.php'); ?>