<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Preview Journal Transaction</title>
<link rel="stylesheet" type="text/css" href="<?php echo base_url()?>assets/custom/css/print_new.css">
<style type="text/css">
@media print {
.noPrint { display: none; }
}
.ahover:hover{
	cursor: pointer;
	color:blue;
}
</style>
</head>
<body style="width:auto; margin:auto">
	<div id="form-header" data-options="region:'north',border:false">
        <div id="form-header-wrapper">
            <table cellpadding="0" cellspacing="0" width="100%">
              <tr>
                  <td  valign="middle">
                      <a href="#" class="easyui-linkbutton noPrint" data-options="plain:true,iconCls:'icon-print'" onClick="print_detail()">Print</a>
                   </td>
              </tr>
              </table>  
          </div>      
      </div>
      <div id="list-print-container">
			<table width="90%" border="0" cellspacing="0" cellpadding="0" align="center">
				<tr>
					<td colspan="6" class="s0 text-center " align="center"><span class="normal_bold"><?php echo $branch->CompanyName;?></span></td>
				</tr>
			    <tr>
					<td colspan="6" class="s0 text-center" align="center"><span class="normal_bold"><?php echo $branch->BranchName;?></span></td>
				</tr>
				<tr>
					<td colspan="6" class="s1 text-center" align="center"><span class="normal_bold">List Journal Profit &amp; Loss</span></td>
				</tr>

				<tr><td colspan="6" class="s2 text-center">From : <?= date('d M Y', strtotime($begin_date)) ?>  s/d  <?= date('d M Y', strtotime($end_date)) ?></td></tr>
				<tr>
					<td colspan="6" class="s2 text-center" align="center" height="20"></td>
				</tr>

				<tr>
					<td width="150" class="s4 text-left"><span class="normal_bold">Journal Date</span></td>
					<td width="150" class="s4 text-left"><span class="normal_bold">Journal Number</span></td>
					<td width="150" class="s4 text-left"><span class="normal_bold">Journal Desc</span></td>
					<td width="160" class="s4 text-right" ><span class="normal_bold">Debet</span></td>
					<td width="160" class="s4 text-right" ><span class="normal_bold">Credit</span></td>
					<td width="160" class="s4 text-right" ><span class="normal_bold">Type</span></td>
				</tr>
				
				<tr>
					 <td height="23" class="s3" colspan="6"> <?php echo 'Account Number : ';?> <?php echo $Account_Number; ?> <?php echo 'Account Name : ';?> <?php echo $Account_Name; ?></td>
				</tr> 
				<?php $ind = 0;?>
				<?php $arrDate = array();?>
				<?php foreach($all_journal as $row):?>
					<?php if($ind > 0):?>
						<?php if($arrDate[$ind-1] == substr($row->Journal_Date,0,7)):?>
							<tr>
								<td class="s3 text-left"><span class="normal_bold"><?php echo convert_to_dmy($row->Journal_Date); ?></span></td>
								<td class="s5 text-left"><span class="normal_bold ahover" onclick="open_transaction('<?php echo $row->Journal_Number;?>','<?php echo $row->Trans_Type;?>')"><?php echo $row->Journal_Number; ?></span></td> 
								<td class="s5 text-left"><span class="normal_bold"><?php echo $row->Journal_Desc; ?></span></td>
								<td class="s5 text-right"><span class="normal_bold"><?php echo number_format($row->Saldo_Debet,"2",",","."); ?></span></td>
								<td class="s5 text-right"><span class="normal_bold"><?php echo number_format($row->Saldo_Credit,"2",",","."); ?></span></td>
								<td class="s5 text-right"><span class="normal_bold"><?php echo $row->Trans_Type; ?></span></td>
							</tr>
						<?php else:?>
							<tr>
								<td class="s3 text-left" colspan="6"><span class="normal_bold">&nbsp;</span></td>
							</tr>
							<tr>
								<td class="s3 text-left" colspan="6"><span class="normal_bold">&nbsp;</span></td>
							</tr>
							<tr>
								<td class="s3 text-left"><span class="normal_bold"><?php echo convert_to_dmy($row->Journal_Date); ?></span></td>
								<td class="s5 text-left"><span class="normal_bold ahover" onclick="open_transaction('<?php echo $row->Journal_Number;?>','<?php echo $row->Trans_Type;?>')"><?php echo $row->Journal_Number; ?></span></td> 
								<td class="s5 text-left"><span class="normal_bold"><?php echo $row->Journal_Desc; ?></span></td>
								<td class="s5 text-right"><span class="normal_bold"><?php echo number_format($row->Saldo_Debet,"2",",","."); ?></span></td>
								<td class="s5 text-right"><span class="normal_bold"><?php echo number_format($row->Saldo_Credit,"2",",","."); ?></span></td>
								<td class="s5 text-right"><span class="normal_bold"><?php echo $row->Trans_Type; ?></span></td>
							</tr>
						<?php endif;?>
					<?php else:?>
						<tr>
							<td class="s3 text-left"><span class="normal_bold"><?php echo convert_to_dmy($row->Journal_Date); ?></span></td>
							<td class="s5 text-left"><span class="normal_bold ahover" onclick="open_transaction('<?php echo $row->Journal_Number;?>','<?php echo $row->Trans_Type;?>')"><?php echo $row->Journal_Number; ?></span></td> 
							<td class="s5 text-left"><span class="normal_bold"><?php echo $row->Journal_Desc; ?></span></td>
							<td class="s5 text-right"><span class="normal_bold"><?php echo number_format($row->Saldo_Debet,"2",",","."); ?></span></td>
							<td class="s5 text-right"><span class="normal_bold"><?php echo number_format($row->Saldo_Credit,"2",",","."); ?></span></td>
							<td class="s5 text-right"><span class="normal_bold"><?php echo $row->Trans_Type; ?></span></td>
						</tr>
					<?php endif;?>
					<?php array_push($arrDate,substr($row->Journal_Date,0,7));?> 
					<?php $ind++;?>
				<?php endforeach;?>
			</table>
		</div>
	</div>
</body>
</html>
<script type="text/javascript">
	function print_detail(){
      //var opt_print   = $("input[type='radio'][name='opt_print']:checked").val();
      var data_print  = $("#list-print-container").html();
      Popup(data_print);
      
    }

    function Popup(data) 
    {
        var mywindow = window.open('', 'list-print-container', 'height=528,width=700');
        var css = css_print_lama();
        mywindow.document.write('<html><head><title>Print Detail</title>');
        mywindow.document.write(css);
        mywindow.document.write('</head><body >');
        mywindow.document.write(data);
        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>