<?php include('techsyn_header.php'); ?>
<!-- Main Content Container for side bar and body-->
<div class="main-container ace-save-state" id="main-container">
    <script type="text/javascript">
        try {
            ace.settings.loadState('main-container')
        } catch (e) {}
    </script>
    <?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="#">Home</li>
                    <li class="#">Patient Management</li>
                    <li class="active">Device Order</li>
                </ul>
            </div>
            <!-- End of breadcrumb -->

            <div class="page-content">
                <div id="flexigridDiv" class="table-responsive">

                    <form name="f1" method="post" action="" id="flex_form_health_advice">
                        <div id="flex1" style="width:100%">
                        </div>
                        <input type="hidden" name="flex_health_advice_id" id="flex_health_advice_id" />
                    </form>
                </div>
            </div>



        </div><!-- /.page-content -->
    </div>
</div><!-- /.main-content -->




<script type="text/javascript">
    $(function() {
        var w = screen.width * .90;
        var h = 0;
        h = (window.innerHeight - ($("#navbar").height() + $(".breadcrumbs").height())) * .75;
        $("#flex1").flexigrid({
            url: 'device_order_script.php',
            dataType: 'json',
            colModel: [{
                    display: 'Sr',
                    name: 'count',
                    width: w * .04,
                    sortable: false,
                    align: 'left'
                },

                {
                    display: 'Accession Number',
                    name: 'accession_number',
                    width: w * .1,
                    sortable: true,
                    align: 'left'
                },
                {
                    display: 'Online Test Code',
                    name: 'online_testcode',
                    width: w * .1,
                    sortable: true,
                    align: 'left'
                },
                {
                    display: 'Patient Name',
                    name: 'patient_id',
                    width: w * .1,
                    sortable: true,
                    align: 'left'
                },
                {
                    display: 'Emp Code',
                    name: 'emp_code',
                    width: w * .1,
                    sortable: true,
                    align: 'left'
                },
                {
                    display: 'Order Status',
                    name: 'isordersent',
                    width: w * .1,
                    sortable: true,
                    align: 'left'
                },
                {
                    display: 'Sample Type',
                    name: 'sampletype',
                    width: w * .1,
                    sortable: true,
                    align: 'left'
                },
                {
                    display: 'Device Name',
                    name: 'device_name',
                    width: w * .1,
                    sortable: true,
                    align: 'left'
                },
                {
                    display: 'Date',
                    name: 'insert_datetime',
                    width: w * .1,
                    sortable: true,
                    align: 'left'
                },
                {
                    display: '',
                    name: '',
                    width: w * .3,
                    sortable: false,
                    align: 'left'
                },

            ],
            buttons: [

                {
                    name: 'HISTORY',
                    bclass: 'print',
                    onpress: go_to_history
                },
                {
                    separator: true
                },
                // {
                //     name: 'Excel',
                //     bclass: 'print_excel',
                //     onpress: excel
                // },
                // {
                //     separator: true
                // }
            ],
            searchitems: [{
                    display: 'Emp Code',
                    name: 'emp_code',
                    isdefault: true
                }, {
                    display: 'Accession Number',
                    name: 'accession_number',
                },

                {
                    display: 'Device Name',
                    name: 'device_name',
                },
                {
                    display: 'Online TestCode Name',
                    name: 'online_testcode'
                }
            ],
            sortname: "device_order_id",
            sortorder: "desc",
            usepager: true, //pagination

            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('health_advice_pdf.php');
    }

    function excel() {
        window.location = 'health_advice_excel.php';
    }

    function go_to_history() {
        window.location.replace('device_order_history.php');
    }

    // function delete_health_advice(health_adviceId) {
    //     $("#flex_health_advice_id").val(health_adviceId);

    //     BootstrapDialog.confirm('Are you sure to delete the Health Advice?', function(result) {
    //         if (result) {
    //             $.ajax({
    //                 url: 'delete_health_advice.php',
    //                 type: "POST",
    //                 data: $("#flex_form_health_advice").serialize(),
    //                 success: function(data) {
    //                     if (data.indexOf("SUCCESS") != -1) {
    //                         BootstrapDialog.alert('Health Advice Deleted Successfully.');
    //                         $("#flex1").flexReload();

    //                     } else {
    //                         BootstrapDialog.alert('Error Deleting Health Advice');
    //                     }
    //                     return;
    //                 },
    //                 error: function(data) {
    //                     BootstrapDialog.alert('Error Deleting Health Advice');
    //                     return;
    //                 }
    //             });
    //         }
    //     });

    // }

    // function validate() {
    //     var health_advice_name = $('#health_advice_name').val();
    //     if (health_advice_name == '') {
    //         BootstrapDialog.alert('Please Enter Health Advice Name.!!!');
    //         return false;
    //     }
    //     var health_advice_cat = $('#health_advice_cat').val();
    //     if (health_advice_cat == '') {
    //         BootstrapDialog.alert('Please Enter Health Advice Category.!!!');
    //         return false;
    //     }

    //     for (let i = 0; i < health_advice_cat.length; i++) {
    //         let result = isValid(health_advice_cat[i]);
    //         if (!result) {
    //             BootstrapDialog.alert("You can not enter spaces and special characters in column name");
    //             return result;
    //         }
    //     }

    //     for (let i = 0; i < health_advice_name.length; i++) {
    //         let result = isValid(health_advice_name[i]);
    //         if (!result) {
    //             BootstrapDialog.alert("You can not enter spaces and special characters in column name");
    //             return result;
    //         }
    //     }

    //     function isValid(str) {
    //         return !/[~`!@#$%\^&*()+=\-\\\[\]\\';,/{}|\\":<>\?]/g.test(str);
    //     }
    //     save_health_advice();
    // }

    // function save_health_advice() {
    //     $.ajax({
    //         url: 'save_health_advice.php ',
    //         type: "POST",
    //         data: $("#health_advice_form").serialize(),
    //         success: function(data) {
    //             BootstrapDialog.alert('Health Advice Saved Successfully.');
    //             $("#flex1").flexReload();
    //             return;
    //         },
    //         error: function(data) {
    //             BootstrapDialog.alert('Error Saving Health Advice');
    //             return;
    //         }
    //     });
    //     $('.close').click();
    // }


    // function open_health_advice(health_adviceId, action) {
    //     var health_advice_id = "";
    //     if (action == "V") {
    //         $(".save_button").hide();
    //     } else {
    //         $(".save_button").show();
    //     }
    //     $.ajax({
    //         url: 'select_health_advice.php?health_adviceId=' + health_adviceId + ' ',
    //         type: 'POST',
    //         success: function(data) {
    //             // alert(data);
    //             var data = $.parseJSON(data);
    //             // alert(data);
    //             $("#health_advice_id").val(data.health_advice_id);
    //             // alert(data.health_advice_id);
    //             $("#health_advice_name").val(data.health_advice_name);
    //             $("#health_advice_cat").val(data.health_advice_cat);
    //             $('#modal-add-health_advice').modal("show");

    //             // $(".save_button").on('click' , function(){
    //             // 	save_health_advice();
    //             // })
    //         },
    //         error: function(data) {
    //             BootstrapDialog.alert('Error Populating Health Advice');
    //             return;
    //         }
    //     });
    // }
</script>

<?php include('techsyn_footer.php'); ?>