<?php
?>
<link href="<?php echo THEME_PATH; ?>css/style.css" rel="stylesheet" type="text/css"/>
<link href="<?php echo THEME_PATH; ?>css/style-responsive.css" rel="stylesheet">
<link href="<?php echo THEME_PATH; ?>/css/bootstrap.rtl.css" rel="stylesheet">
<link href="<?php echo THEME_PATH; ?>/css/style.rtl.css" rel="stylesheet">
<link href="<?php echo THEME_PATH; ?>/plugins/bootstrap-datepicker/css/datepicker3.rtl.css" rel="stylesheet">
<style>
    #headerDiv span {font-size:15px;}
    #headerDiv h3{
        margin-bottom: 0px;
    }
    table.first,table.secondTbl {color: #000;font-family: aealarabiya; font-size: 15px;}
    th,td{
        font-size:12px;text-align: center;}
    .second{display:none;}
    body{
        margin:0;
    }</style>
<body style="" onload="window.print()">
    <div id="myDivToPrint">
        <div style="text-align: center;" id="headerDiv">
              <h3><?php echo smc_session()['org_detail']['Organization_Name'];?></h3>
            <span><?php echo smc_session()['org_detail']['Org_Address'];?></span><br/>
            <span><?php echo smc_session()['org_detail']['Organization_Phone'];?></span>
           <br/><span>VAT #: <?php echo smc_session()['org_detail']['Organization_Commercial_Registry'] ?></span><br/>
            <span><?php echo CommonLanguage::getMessage('range_date') . ': '.$data_filter['from_date'].' - '.$data_filter['to_date']; ?></span>
            <?php if(!empty($data_filter['user'])){?>
            <br><span><?php echo  CommonLanguage::getMessage('user_name')  . ': '.$data_filter['user']; ?></span>
            <?php }?>
            <?php if(!empty($data_filter['class'])){?>
            <br><span><?php echo  CommonLanguage::getMessage('pricing_class')  . ': '.$data_filter['class']; ?></span>
            <?php }?>
            <hr>
            <table class="first "  cellspacing='' style="width:100%;">
                <thead>
                    <tr>
                        <th>#</th>
                        <th><?php print CommonLanguage::getMessage('customer_name') ?></th>
                        <th><?php print CommonLanguage::getMessage('Date') ?></th>
                        <th><?php print CommonLanguage::getMessage('total') ?></th>
                        <th><?php print CommonLanguage::getMessage('Type') ?></th>
                    </tr>
                </thead>
                <tbody>
                    <?php 
    foreach ($data as $row) {
//                            print_r($row);
        
                    ?>
                    <tr>
                        <td><?php echo $row['id'] ?></td>
                        <td><?php echo $row['customer_name'] ?></td>
                        <td ><?php echo $row['date_created']; ?></td>
                        <td ><?php echo CommonFunctions::formatNumber($row['total']* $row['current_rate']).' '.smc_session()['local_currency_symbol']; ?></td>
                        <td ><?php echo $row['type'] == 'Invoice' ? 'I' : 'R'; ?></td>
                    </tr>
                    <?php } ?>
                </tbody>
            </table>
            <hr>
            <table class="secondTbl">
                <thead>
                    <tr class="second">
                        <th ></th>
                        <th ></th>
                    </tr>
                </thead>
                <tbody>
                    <tr>
                        <td><?php echo CommonLanguage::getMessage('total') ?> </td>
                        <td> <?php echo CommonFunctions::formatNumber($totals['total']).' '.smc_session()['local_currency_symbol'];?></td>
                    </tr>
                    <tr>
                        <td><?php echo CommonLanguage::getMessage('cash') ?> </td>
                        <td> <?php echo CommonFunctions::formatNumber($totals['total_cash']).' '.smc_session()['local_currency_symbol'];?> </td>
                    </tr>
                    <tr>
                        <td><?php echo CommonLanguage::getMessage('debit') ?></td>
                        <td> <?php echo  CommonFunctions::formatNumber($totals['total'] - $totals['total_cash']).' '.smc_session()['local_currency_symbol'];?> </td>
                    </tr> 
                    <tr>
                        <td><?php echo CommonLanguage::getMessage('discount') ?></td>
                        <td><?php echo CommonFunctions::formatNumber($totals['discount']).' '.smc_session()['local_currency_symbol'];?>  </td>
                    </tr>
                </tbody>
            </table>
            <hr>
        </div>
    </div>
    <script>
        function PrintElem(elem)
        {
            var mywindow = window.open('', 'PRINT', 'height=600,width=800');
            mywindow.document.write('<html><head><style>#headerDiv span {font-size:12px;} table.first,table.secondTbl {color: #000;font-family: aealarabiya; font-size: 12px;}th,td{' +
                                    'font-size:12px;}' +
                                    '.second{display:none;}</style>');
            mywindow.document.write('</head><body style="direction:rtl;">');
            mywindow.document.write(elem.html());
            mywindow.document.write('</body></html>');
            mywindow.document.close(); // necessary for IE >= 10
            mywindow.focus(); // necessary for IE >= 10*/
            mywindow.print();
            mywindow.close();
            return true;
        }
    </script>
</body>
