<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>GST Report Summary</title>
<link rel="stylesheet" href="<?php echo base_url()?>css/stylesheets.css" type="text/css" />
<?php //echo put_headers(); ?>
<style>
	.thPrint tr{
		height: 41px;
	}
	.table thead th{
		  vertical-align: middle;
	}
</style>
<style media="print" type="text/css">
	/*body{FONT-SIZE: 14px;FONT-FAMILY: Arial;COLOR: #000000}*/
	.printButton { display: none; }
	
	@media print {
                .td-print,.td-print*{display:none !important;}
				.printTbl hr{
					margin:0 !important;
				}
				.thPrint th{
					/*background:url(<?php echo base_url() ?>img/rptPaymentAdvice.png) !important;*/
                	/*-webkit-print-color-adjust: exact;*/
					
				}
                /*body{overflow:visible !important;}*/
                @page{ 
                    size: auto;   /* auto is the initial value */ 

                    /* this affects the margin in the printer settings */ 
                    margin: 10px 10px 10px 10px;  
                } 
                .compLogo{
                    width: 150px;
                }

            }
</style>
<script language="javascript" type="text/javascript">	
	$(document).ready(function(){
		//$('.image').height($('.thPrint').height());
		//$('.image').width($('.thPrint').width());
	});
	function do_print(){
		window.print();
	}
	function do_printexcel(){
		var url = "<?php echo base_url()?>gstReport/gstReportSummary_excel/<?php echo $dateFrom?>/<?php echo $dateTo?>";
		window.location.href = url;
	}
</script>
</head>

<table width="100%" border="0" align="center" cellpadding="1" cellspacing="0">
    
    <!--<tr>
        <td align="center" colspan="2">
            <div class="printButton" align="center">
        	<?php 
			/*$js = 'onClick="do_print()" class="btn-icon btn-success-form Print" title="Print"';
			echo form_button('Print','<span class="i-printer">',$js);?>&nbsp;&nbsp; <?php
			$js = 'onClick="do_printexcel()" class="btn-icon btn-warning-form EXCEL" title="Download"';
			echo form_button('EXCEL','<span class="i-download">',$js);?>&nbsp;&nbsp; <?php
			$js = 'onClick="javascript:window.close();" class="btn-icon btn-danger-form Close" title="Close"';
			echo form_button('Close','<span class="i-switch">',$js);*/?>
            </div>
        </td>
    </tr>-->
    <tr>
                            <td colspan="2" >
                            	<img class="compLogo" src="<?php echo base_url(). 'images/'.element('logo', $this->session->userdata('logged_in'));?>" style="max-width:150px; max-height:150px; position:absolute; left:20px;top:20px;" />
                                <p style="text-align: right; margin:0; padding-right: 10px; font-weight: 500; line-height: 2; padding-bottom: 0px; padding-top: 0px; color: black; font-size: 25px;">
                                    <?php echo $this->lang->line('module');?>
                                </p>
                                        <p style="text-align:center; font-size:16px;"> 
                                            <span style=" font-weight:800;"><?php echo $companyInfo->companyName; ?></span> <span style="font-size:10px;"><?php echo "(".$companyInfo->companyNo.")";?></span><br />
                                            <span style="font-size:10px;"><?php echo "GST Registration No : ".$companyInfo->gstRegisteredNo; ?></span><br />
                                        </p>
                                        <p style="text-align:center; font-size:10px; line-height:1.4; padding:0 0 5px; margin:0; border-bottom:1px solid #eeeeee;">

                                            <?php if(!empty($companyInfo->line1)): ?><span><?php echo $companyInfo->line1; ?></span><br /><?php endif; ?>
                                            <?php if(!empty($companyInfo->line2) || !empty($companyInfo->line3)): ?><span><?php echo $companyInfo->line2.", ".$companyInfo->line3; ?></span><br /><?php endif; ?>
                                            <?php if(!empty($companyInfo->companyPostCode) || !empty($companyInfo->city)): ?><span><?php echo $companyInfo->companyPostCode . '  ' . $companyInfo->city; ?> </span><br /><?php endif; ?>
                                            <?php if(!empty($companyInfo->fldname) || !empty($companyInfo->fldcountry)): ?><span><?php echo $companyInfo->fldname . '  ' . $companyInfo->fldcountry; ?> </span><br /><?php endif; ?>
                                            <?php if(!empty($companyInfo->phoneNo) || !empty($companyInfo->faxNo)): ?><span><?php echo 'Phone : ' . $companyInfo->phoneNo . '  Fax : ' . $companyInfo->faxNo; ?> </span><?php endif; ?>
                                        </p>
                            </td>
                        </tr>
                        <tr>
                            <td>
                                <?php
                                if (isset($leftContentHeader)){
                                    echo "<p style='padding-left:10px; margin:0; font-size:11px; '>"
                                    . "<strong>".$leftContentHeader."</strong></p>";
                                }
                                 
                                 if (isset($leftContent)){
                                   echo '<p style="padding-left:10px; margin:0; line-height:1.4;">';
                                    foreach ($leftContent as $value) {
                                         echo $value != ''?"<span>".$value."</span><br />":'';
                                     }
                                  echo '</p>';
                                 }
                                
                                ?>
                            </td>
                                
                                <td style="float:right;" valign="top">
                                    <p style="line-height:1.4; text-align:left;">
                                        <?php
	                                        if (isset($rightContentHeader)){
	                                        	echo "<p style='padding-right:10px; margin:0; font-size:11px; '>"
	                                        			. "<strong>".$rightContentHeader."</strong></p>";
	                                        } 
                                            if (isset($rightContent)){
                                                 foreach ($rightContent as $value) {
                                                    echo $value != ''?"<span>".$value."</span><br />":'';
                                                }
                                            }
                                        ?>
                                    </p>
                                  </td>
                            </tr>
</table>
<div>
	<table border="0" cellpadding="1" cellspacing="0" width="100%">
		<thead>
        <tr>
        	<td></td>
        	<td></td>
            <td></td>
            <td></td>
            <td>&nbsp;</td>
        </tr>
        <tr>
        	<td></td>
        	<td></td>
            <td></td>
            <td></td>
            <td>&nbsp;</td>
        </tr>
        <tr>
        	<td></td>
        	<td></td>
            <td></td>
            <td></td>
          <td>&nbsp;</td>
        </tr>
        <tr>
        	<td></td>
        	<td></td>
            <td></td>
            <td></td>
            <td class="tar"><b><?php echo $this->lang->line('as').":"." ".date('d-m-Y'); ?></b></td>
        </tr>
        <tr>
        	<td></td>
        	<td></td>
            <td></td>
            <td></td>
            <td>&nbsp;</td>
        </tr>
        <tr>
        	<td></td>
        	<td><b><?php echo $this->lang->line('taxablePeriod').":"." ".date('d-m-Y', strtotime($dateFrom))." ".$this->lang->line('to')." ".date('d-m-Y', strtotime($dateTo)) ?></b></td>
            <td></td>
            <td></td>
            <td>&nbsp;</td>
        </tr>
        <tr>
        	<td></td>
        	<td></td>
            <td></td>
            <td></td>
            <td>&nbsp;</td>
        </tr>
        <tr>
        	<td></td>
        	<td><b><?php echo $this->lang->line('supply') ?></b></td>
            <td></td>
            <td></td>
            <td>&nbsp;</td>
        </tr>
        </tbody>
        </table>
        <script type="text/javascript" src="<?php echo base_url(); ?>js/jquery/jquery-2.0.0.min.js"></script>
        <script type="text/javascript">
			$(window).load(function(){      
				$(window).resize();
			});
        	$(window).resize(function(){ 
				if($('.image').length){
					$('.image').width($('.image').parents('thead').width());
					$('.image').height($('.image').parents('thead').find('tr:nth-child(2)').height());
				}
			});
        </script>
        <table border="0" cellpadding="0" cellspacing="0" width="100%" style="">
						<img class="image" style="position:absolute;left:0;top:10;z-index: -1000;width:100%" alt="" src="<?php echo base_url() ?>img/rptPaymentAdvice.png" />
                            <?php 
							$count = 0;
							echo "<table cellpadding='0' cellspacing='0' width='100%' id='test' class='editable' style='position:relative;'>
                                <thead  class=\"thPrint\">
								<tr style=\"height:0px;\">
									<th colspan='".$monthDiff."'>"; ?>
                						<img class="image" style="position:absolute;left:0;top:10;z-index: -1000;width:100%" alt="" src="<?php echo base_url() ?>img/rptPaymentAdvice.png" />
                					<?php echo "</th>
            					</tr>
                                <tr>
                                    <th class='tac'>No.</th>
                                    <th class='tac' width='10%'>".$this->lang->line('taxCode')."</th>";
									for($i=0; $i<$monthDiff; $i++){
										if($monthDiff > 1){
												if($i == 0){	
													if(date("M", strtotime($i." months", strtotime($dateFrom))) == "Dec"){
														echo "<th class='tac'>".date("M", strtotime($i." months", strtotime($dateFrom)))."'".date("y", strtotime($count." years", strtotime($dateFrom)))."</th>";
														$count ++;
													}
													else{
														echo "<th class='tac'>".date("M", strtotime($i." months", strtotime($dateFrom)))."'".date("y", strtotime($count." years", strtotime($dateFrom)))."</th>";
													}
												}
												else{
													if(date("M", strtotime($i." months", strtotime($dateFrom))) == "Dec"){
														echo "<th class='tac'>".date("M", strtotime($i." months", strtotime($dateFrom)))."'".date("y", strtotime($count." years", strtotime($dateFrom)))."</th>";
														$count ++;
													}
													else{
														echo "<th class='tac'>".date("M", strtotime($i." months", strtotime($dateFrom)))."'".date("y", strtotime($count." years", strtotime($dateFrom)))."</th>";
													}
												}
										}
										else{
											echo "<th class='tac'>".date("M", strtotime($dateFrom))."'".date("y", strtotime($count." years", strtotime($dateFrom)))."</th>";
										}
									}
									echo "<th class='tac'><b>".$this->lang->line('total')."</b></th>";
                                "</tr>
                                </thead>
                                <tbody>";
                                    	$bil = 0;
										//$bil2 = 0;
										$totCol = array();
										if($datatbls){
										foreach($datatbls as $datatbl):
										$bil++;
										echo"<tr class='itemList' style=\"height:20px;\">
                                            <td class='tac' style='border-top:1px solid #dddddd;'>".$bil."</td>
                                        	<td class='tac' width='200' style='border-top:1px solid #dddddd;'>".$datatbl->code."</td>";
											//for($i=0; $i<$monthDiff; $i++){
											$total = 0;
											$i = 0;
											
											foreach ($datatbl as $col => $val) {
												if (strtoupper(substr($col,0,5))=='MONTH'){
													echo '<td align="right" style="border-top:1px solid #dddddd;">'.number_format($val, 2, '.', ',').'</td>';
													$total += $val;
													if($bil == 1)
														$totCol[] += $val;
													else
														$totCol[$i] += $val;	
													$i++;
												}
													//echo "<td class='tac'>".$datatbl->month3."</td>";
											}
											//foreach ($totSales as $totSale) {
												echo '<td align="right" style="border-top:1px solid #dddddd;"><b>'.number_format($total, 2, '.', ',').'</b></td>';
												//echo '<td align="right">'.number_format($totSales[$bil]->totGstSales, 2, '.', ',').'</td>';
												//$bil2++;
											//}
                                        "</tr>";
										
										
									endforeach;
											}
									$bil = $bil + 1;
									echo"<tr>
											<td class='tac' style='border-bottom:1px solid #424242;border-top:1px solid #424242;'></td>
											<td class='tar' style='border-bottom:1px solid #424242;border-top:1px solid #424242;'><b>".$this->lang->line('subTotSupply')."</b></td>";
											//var_dump($totCol);
											$totAmount = 0;
											if($datatbls){
												for($j=0; $j<$i; $j++){
													$totAmount += $totCol[$j];
													echo '<td align="right" style="border-bottom:1px solid #424242;border-top:1px solid #424242;"><b>'.number_format($totCol[$j], 2, '.', ',').'</b></td>';
												}
											}
											else{
												for($j=0; $j<$i; $j++){
													echo '<td align="right" style="border-bottom:1px solid #424242;border-top:1px solid #424242;"><b>'.number_format(0, 2, '.', ',').'</b></td>';
												}
											}
											echo"<td align='right' style='border-bottom:1px solid #424242;border-top:1px solid #424242;'><b>".number_format($totAmount, 2, '.', ',')."</b></td>";
										"</tr>";
                                echo"</tbody>         
                            </table>";  ?>
            
            <br /><br /><br /><br />
            
            
            	<tr>
        			<td></td>
        			<td>&nbsp;&nbsp;&nbsp;&nbsp;<b><?php echo $this->lang->line('purchase') ?></b></td>
            		<td></td>
            		<td></td>
            		<td>&nbsp;</td>
        		</tr>
            			<?php
						$count = 0;
                        echo "<table cellpadding='0' cellspacing='0' width='100%' id='test' class='editable' style='position:relative'>
                                <thead  class=\"thPrint\">
								<tr style=\"height:0px;\">
									<th colspan='".$monthDiff."'>"; ?>
                						<img class="image" style="position:absolute;left:0;top:10;z-index: -1000;width:100%" alt="" src="<?php echo base_url() ?>img/rptPaymentAdvice.png" />
                					<?php echo "</th>
            					</tr>
                                <tr>
                                    <th class='tac'>No.</th>
                                    <th class='tac' width='10%'>".$this->lang->line('taxCode')."</th>";
									for($i=0; $i<$monthDiff; $i++){
										if($monthDiff > 1){
												if($i == 0){	
													if(date("M", strtotime($i." months", strtotime($dateFrom))) == "Dec"){
														echo "<th class='tac'>".date("M", strtotime($i." months", strtotime($dateFrom)))."'".date("y", strtotime($count." years", strtotime($dateFrom)))."</th>";
														$count ++;
													}
													else{
														echo "<th class='tac'>".date("M", strtotime($i." months", strtotime($dateFrom)))."'".date("y", strtotime($count." years", strtotime($dateFrom)))."</th>";
													}
												}
												else{
													if(date("M", strtotime($i." months", strtotime($dateFrom))) == "Dec"){
														echo "<th class='tac'>".date("M", strtotime($i." months", strtotime($dateFrom)))."'".date("y", strtotime($count." years", strtotime($dateFrom)))."</th>";
														$count ++;
													}
													else{
														echo "<th class='tac'>".date("M", strtotime($i." months", strtotime($dateFrom)))."'".date("y", strtotime($count." years", strtotime($dateFrom)))."</th>";
													}
												}
										}
										else{
											echo "<th class='tac'>".date("M", strtotime($dateFrom))."'".date("y", strtotime($count." years", strtotime($dateFrom)))."</th>";
										}
									}
									echo "<th class='tac'><b>".$this->lang->line('total')."</b></th>";
                                "</tr>
                                </thead>
                                <tbody>";
                                    	$bil = 0;
										//$bil2 = 0;
										$totCol = array();
										if($datatbls2){
										foreach($datatbls2 as $datatbl2):
										$bil++;
										echo"<tr class='itemList' style=\"height:20px;\">
                                            <td class='tac' style='border-top:1px solid #dddddd;'>".$bil."</td>
                                        	<td class='tac' width='200' style='border-top:1px solid #dddddd;'>".$datatbl2->code."</td>";
											//for($i=0; $i<$monthDiff; $i++){
											$total = 0;
											$i = 0;
											
											foreach ($datatbl2 as $col => $val) {
												if (strtoupper(substr($col,0,5))=='MONTH'){
													echo '<td align="right" style="border-top:1px solid #dddddd;">'.number_format($val, 2, '.', ',').'</td>';
													$total += $val;
													if($bil == 1)
														$totCol[] += $val;
													else
														$totCol[$i] += $val;	
													$i++;
												}
													//echo "<td class='tac'>".$datatbl->month3."</td>";
											}
											//foreach ($totSales as $totSale) {
												echo '<td align="right" style="border-top:1px solid #dddddd;"><b>'.number_format($total, 2, '.', ',').'</b></td>';
												//echo '<td align="right">'.number_format($totSales[$bil]->totGstSales, 2, '.', ',').'</td>';
												//$bil2++;
											//}
                                        "</tr>";
										
										
									endforeach;
											}
									$bil = $bil + 1;
									echo"<tr>
											<td class='tac' style='border-bottom:1px solid #424242;border-top:1px solid #424242;'></td>
											<td class='tar' style='border-bottom:1px solid #424242;border-top:1px solid #424242;'><b>".$this->lang->line('subTotPurchase')."</b></td>";
											//var_dump($totCol);
											$totAmount = 0;
											if($datatbls2){
												for($j=0; $j<$i; $j++){
													$totAmount += $totCol[$j];
													echo '<td align="right" style="border-bottom:1px solid #424242;border-top:1px solid #424242;"><b>'.number_format($totCol[$j], 2, '.', ',').'</b></td>';
												}
											}
											else{
												for($j=0; $j<$i; $j++){
													echo '<td align="right" style="border-bottom:1px solid #424242;border-top:1px solid #424242;"><b>'.number_format(0, 2, '.', ',').'</b></td>';
												}
											}
											echo"<td align='right' style='border-bottom:1px solid #424242;border-top:1px solid #424242;'><b>".number_format($totAmount, 2, '.', ',')."</b></td>";
										"</tr>";
                                echo"</tbody>         
                            </table>";  ?>
            
            
	</table>
    <table width="100%" border="0" align="center" cellpadding="1" cellspacing="0">
        <tr>
            <td align="center" colspan="2">
            <br />
                <div class="printButton" align="left">
                &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
				<?php 
                $js = 'onClick="do_print()" class="btn-icon btn-success-form Print" title="Print"';
                echo form_button('Print','<span class="icon-print">',$js);?> <?php
                $js = 'onClick="do_printexcel()" class="btn-icon btn-warning-form EXCEL" title="Download"';
                echo form_button('EXCEL','<span class="icon-download">',$js);?> <?php
                $js = 'onClick="javascript:window.close();" class="btn-icon btn-danger-form Close" title="Close"';
                echo form_button('Close','<span class="icon-off">',$js);?>
                </div>
            </td>
        </tr>
    </table>
    <br /><br /><br /><br />                                         
</div>
<div style="page-break-after:always"></div>
</html>
