<?php
define('DOCUMENT_ROOT_CLASS','../');
define('DOCUMENT_ROOT_INC_FOLDER','');
$filepath = realpath(dirname(__FILE__));
require "../inc/header.php";
$msg = Session::get('msg');
Session::set("msg", NULL);
?>
<style type="text/css">
	.select2-container{
		width: 100% !important;
	}
</style>
    <?php 
        $rand = @$_GET["receipt_id"];
    ?>
    <div class="row">
        <div class="col-sm-12">
            <div class="page-title-box">
                <div class="row">
                    <div class="col">
                        <h4 class="page-title"><?php echo ($_GET['state'] != "list")?"View Receipt":" Receipt List "; ?></h4>
                        <ol class="breadcrumb">
                            <li class="breadcrumb-item"><a href="javascript:void(0);">Generate Receipt</a></li>
                            <li class="breadcrumb-item"><a href="javascript:void(0);"><?php echo ($_GET['state'] != "list")?"$rand":"Receipt"; ?></a></li>
                        </ol>
                    </div><!--end col-->
                    <div class="col-auto align-self-center">
                        <a href="javascript:void(0);" class="btn btn-secondary btn-sm" onclick='printDiv();'>
                            <i class="fas fa-print align-self-center icon-xs"></i> Print
                        </a>
                    	<a href="receipt.php?state=list"><button type="button" class="btn btn-danger btn-sm">Back to Receipt List </button></a>

                        <!-- <button type="button" class="btn btn-primary save_form" id="save_form">
                            <i class="fa fa-save align-self-center icon-xs"></i> Save Receipt
                        </button> -->
                    </div><!--end col-->  
                </div><!--end row-->                                                              
            </div><!--end page-title-box-->
        </div><!--end col-->
    </div><!--end row-->
    <!-- end page title end breadcrumb -->
    <?php if(@$_GET['state'] == "view"): ?>
    <div class="row">
        <div class="col-12">
            <div class="row justify-content-center">
                <div class="col-md-12 col-lg-12" id="DivIdToPrint">
                    <div class="card report-card">
                        <div class="card-body" >
                            <div class="row d-flex justify-content-center">
                                <style type="text/css">
                                    .receipt-logo{ width: 9em; height: 9em; }
                                </style>
                                <table border="0" cellpadding="0" cellspacing="0" style="width:100%;">
                                    <tr>
                                        <td style="width:30%">
                                            <img src="../uploads/logo-receipt.jpg" class="receipt-logo">
                                        </td>
                                        <td>
                                            <h2 style="text-align: center;" >QATAR GENETIC LAB</h2>
                                            <h5 style="text-align: center;">Racing and Euestrain Club,<br>Al Furousiya Street,<br>Al Rayyan, Doha, Qatar</h5>
                                            <h5 style="text-align: center;">CASH/CHEQUE RECEIPT VOUCHER</h5>
                                        </td>
                                        <td style="text-align: right;">
                                            <img src="../uploads/logo-receipt-1.jpg" class="receipt-logo">
                                        </td>
                                    </tr>
                                    <tr>
                                        <td style="width: 25%;">
                                            <h4>Receipt No. <?php echo $rand;?> </h4>
                                            <img alt='barcode' src='../lib/barcode.php?codetype=Code128&size=40&text=<?php echo $rand;?>&print=false' style="padding-bottom: 0.5em;" />
                                        </td>
                                        <td>
                                            <table border="1" cellpadding="0" cellspacing="0" style="width:100%;">
                                                <tr>
                                                    <td style="width: 20%;padding: 0.3em;"><h4>Amount</h4></td>
                                                    <td style="padding: 0.3em;">
                                                        <h4><?php echo $commonFunctions->getName(@$_GET["receipt_id"],'sys_receipts','Amount','ReceiptNo');?> /- QAR</h4>
                                                    </td>
                                                </tr>
                                            </table>
                                        </td>
                                        <td style="text-align: right;">
                                            <h4>Date: <?php $date = $commonFunctions->getName(@$_GET["receipt_id"],'sys_receipts','CreatedDate','ReceiptNo');
                                            echo date("jS M Y", strtotime($date));
                                            ?></h4>
                                        </td>
                                    </tr>
                                </table>
                                <table border="2" cellpadding="5" cellspacing="5" style="width:100%;">
                                    <tr>
                                        <td>
                                            <table border="0" cellpadding="0" cellspacing="0" style="width:100%;">
                                                <tr>
                                                    <td style="width:20%;">
                                                        <h4>Customer Name </h4> 
                                                    </td>
                                                    <td colspan="2">
                                                        <h4 style="width: 100%;border-bottom: 3px dotted;"><?php echo $commonFunctions->getName(@$_GET["receipt_id"],'sys_receipts','CustomerName','ReceiptNo');?></h4> 
                                                    </td>
                                                </tr>
                                                <tr>
                                                    <td style="width:20%;">
                                                        <h4>Membership Number </h4> 
                                                    </td>
                                                    <td colspan="2">
                                                        <h4 style="width: 100%;border-bottom: 3px dotted;"><?php echo $commonFunctions->getName(@$_GET["receipt_id"],'sys_receipts','MembershipNumber','ReceiptNo');?></h4> 
                                                    </td>
                                                </tr>
                                                <tr>
                                                    <td style="width:20%;">
                                                        <h4>Amount </h4> 
                                                    </td>
                                                    <td colspan="2">
                                                        <h4 style="width: 100%;border-bottom: 3px dotted;"><?php echo $commonFunctions->getName(@$_GET["receipt_id"],'sys_receipts','Amount','ReceiptNo');?></h4> 
                                                    </td>
                                                </tr>
                                                <tr>
                                                    <td style="width:20%;">
                                                        <h4>Payment Type  </h4> 
                                                    </td>
                                                    <td colspan="2">
                                                        <h4 style="width: 100%;border-bottom: 3px dotted;"><?php echo $commonFunctions->getName(@$_GET["receipt_id"],'sys_receipts','PaymentType','ReceiptNo');?></h4>  
                                                    </td>
                                                </tr>
                                                <tr>
                                                    <td style="width:20%;">
                                                        <h4>Service Type </h4> 
                                                    </td>
                                                    <td colspan="2">
                                                        <h4 style="width: 100%;border-bottom: 3px dotted;"><?php echo $commonFunctions->getName(@$_GET["receipt_id"],'sys_receipts','ServiceType','ReceiptNo');?></h4>  
                                                    </td>
                                                </tr>
                                                <tr>
                                                    <td style="width:20%;">
                                                        <h4>Appointment Date </h4> 
                                                    </td>
                                                    <td colspan="2">
                                                        <h4 style="width: 100%;border-bottom: 3px dotted;"><?php echo $commonFunctions->getName(@$_GET["receipt_id"],'sys_receipts','AppointmentDate','ReceiptNo');?></h4>  
                                                    </td>
                                                </tr>
                                            </table>
                                            <table border="0" cellspacing="0" cellpadding="0" style="width: 100%;">
                                                <tr>
                                                    <td style="width: 20%;text-align: center;"> 
                                                        <br><br><br><h4>Receiver Sign</h4><br><br>
                                                        <h4 style="border-bottom: 3px dotted;"></h4>
                                                    </td>
                                                    <td style="width: 60%;">

                                                    </td>
                                                    <td style="width: 20%;text-align: center;"> 
                                                        <br><br><br><h4>Accountant Sign</h4><br><br>
                                                        <h4 style="border-bottom: 3px dotted;"></h4>
                                                    </td>
                                                </tr>

                                            </table>                
                                        </td>
                                    </tr>
                                </table>
                            </div>
                        </div>
                    </div>
                </div>  
                <!-- <div class="col-lg-12 col-xl-12">
                    <div class="float-right d-print-none">
                        <button type="button" class="btn btn-primary btn-sm save_form" id="save_form">
                            <i class="fa fa-save align-self-center icon-xs"></i> Save Receipt
                        </button>
                         
                    </div>
                </div>  -->

            </div>
        </div>
    </div>
    <?php endif; ?>
        
<?php require "../inc/footer.php"; ?>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-validate/1.15.1/jquery.validate.min.js"></script>
<script type="text/javascript">
function printDiv(){
    var printContents = document.getElementById('DivIdToPrint').innerHTML;
    var originalContents = document.body.innerHTML;
    document.body.innerHTML = printContents;
    window.print();
    document.body.innerHTML = originalContents;
}
</script>