<!-- Home Design Inner Pages -->
<div class="ulockd-inner-home">
    <div class="container">
        <div class="row">
            <div class="inner-conraimer-details">
                <div class="col-md-12">
                    <h1 class="text-uppercase"><?php echo $this->lang->line('appointment'); ?></h1>
                </div>
            </div>
        </div>
    </div>
</div>
<!-- Home Design Inner Pages -->
<div class="ulockd-inner-page">
    <div class="container">
        <div class="row">
            <div class="col-md-12">
                <div class="ulockd-icd-layer">
                    <ul class="list-inline ulockd-icd-sub-menu">
                        <li><a href="<?php echo site_url(); ?>"> <?php echo $this->lang->line('home'); ?> </a></li>
                        <li>></li>
                        <li><a href="<?php echo site_url('appointment'); ?>"><?php echo $this->lang->line('appointment'); ?></a> </li>
                        <li>></li>
                        <li><?php echo $this->lang->line('appointment'); ?></li>
                    </ul>
                </div>
            </div>
        </div>
    </div>
</div>
<!-- Inner Pages Main Section -->

<!-- Appointment Success-->
<section class="ulockd-about2">
    <div class="container">
        <div class="row">
            <div class="col-md-6 col-md-offset-3 text-center">
                <div class="ulockd-main-title">
                    <h2><span class="text-thm2"><?php echo $this->lang->line('appointment'); ?></span> <?php echo $this->lang->line('info'); ?></h2>
                    <div class="mt-separator"></div>
                </div>
            </div>
        </div>
        <div class="row">
            <div class="col-md-8 col-md-offset-2">
                <table class="table table-bordered">
                    <tbody>
                        <tr>
                            <td width="20%"><?php echo $this->lang->line('appointment_no'); ?></td>
                            <td width="30%"><?php echo $appointment->appointment_no; ?></td>
                            <td width="20%"><?php echo $this->lang->line('date'); ?></td>
                            <td width="30%"><?php echo $appointment->date; ?></td>
                        </tr>
                        <tr>
                            <td><?php echo $this->lang->line('serial_no'); ?></td>
                            <td><?php echo $appointment->serial_no; ?></td>
                            <td><?php echo $this->lang->line('patient_id'); ?></td>
                            <td><?php echo $appointment->patient_unique_id; ?></td>
                        </tr>
                        <tr>
                            <td><?php echo $this->lang->line('doctor'); ?></td>
                            <td colspan="3"><?php echo $appointment->doctor; ?>, <?php echo $appointment->specialist; ?></td>
                        </tr>
                        <tr>
                            <td><?php echo $this->lang->line('name'); ?></td>
                            <td><?php echo $appointment->name; ?></td>
                            <td><?php echo $this->lang->line('gender'); ?></td>
                            <td><?php echo $this->lang->line($appointment->gender); ?></td>
                        </tr>
                        <tr>
                            <td><?php echo $this->lang->line('phone'); ?></td>
                            <td><?php echo $appointment->phone; ?></td>
                            <td><?php echo $this->lang->line('address'); ?></td>
                            <td><?php echo $appointment->address; ?></td>
                        </tr>
                        <tr>
                            <td><?php echo $this->lang->line('remark'); ?></td>
                            <td colspan="3"><?php echo $appointment->note; ?></td>
                        </tr>
                    </tbody>
                </table>

                <button class="btn btn-success btn-xs" type="button" onclick="print(<?php echo $appointment->id; ?>);">
                    <i class="fa fa-print"></i>
                    <?php echo $this->lang->line('print'); ?>
                </button>
                <a class="btn btn-primary btn-xs" href="<?php echo site_url('appointment/pdf/' . $appointment->id); ?>">
                    <i class="fa fa-download"></i>
                    <?php echo $this->lang->line('download'); ?>
                </a>
            </div>
        </div>
    </div>
</section>

<script>
    function print(id) {
        var base_url = '<?php echo base_url() ?>';
        $.ajax({
            url: base_url + 'appointment/print',
            type: 'POST',
            data: {
                id: id
            },
            success: function(result) {
                $("#testdata").html(result);
                popup(result);
            }
        });
    }

    function popup(data) {
        var base_url = '<?php echo base_url() ?>';
        var frame1 = $('<iframe />');
        frame1[0].name = "frame1";
        frame1.css({
            "position": "absolute",
            "top": "-1000000px"
        });
        $("body").append(frame1);
        var frameDoc = frame1[0].contentWindow ? frame1[0].contentWindow : frame1[0].contentDocument.document ? frame1[0].contentDocument.document : frame1[0].contentDocument;
        frameDoc.document.open();
        //Create a new HTML document.
        frameDoc.document.write('<html>');
        frameDoc.document.write('<head>');
        frameDoc.document.write('<title>Invoice</title>');

        frameDoc.document.write('</head>');
        frameDoc.document.write('<body>');
        frameDoc.document.write(data);
        frameDoc.document.write('</body>');
        frameDoc.document.write('</html>');
        frameDoc.document.close();
        setTimeout(function() {
            window.frames["frame1"].focus();
            window.frames["frame1"].print();
            frame1.remove();
        }, 500);

        return true;

    }
</script>