<?php 
//OJB: Check if for excel export process
if($export_excel == 1){
	ob_start();
	$this->load->view("partial/header_excel");
}else{
	$this->load->view("partial/header");
}


//$safe_string_to_store = base64_encode(serialize($data));
$safe_string_to_store = base64_encode(serialize($filename));
$safe_string_to_payment = base64_encode(serialize($payment_data));
$safe_string_title = base64_encode(serialize($title));
$safe_string_subtitle = base64_encode(serialize($subtitle));

?>
<div id="page_title" style="margin-bottom:8px;"><?php echo $title ?></div>

<table style="width:100%">
<tr>
<td style="background-color:#327789;text-align:center;font-weight:bold;font-size: 17px;padding-top: 5px;padding-bottom: 5px;padding-left: 100px;color:#FFFFFF;">
<?php echo "Date Range : ".$subtitle ?>
</td>
<td style="background-color:#327789;text-align:right;font-weight:bold;font-size: 17px;padding: 5px;color:#FFFFFF;width:10%;padding-right:20px;">
<a class="notificationContainerReport" href="<?php echo LOCAL_PATH."/pdf_report/mpdf60/print/summary_stock_transaction.php?data=".$safe_string_to_store."&payment_data=".$safe_string_to_payment."&title=".$safe_string_title."&subtitle=".$safe_string_subtitle; ?>" target="_blank">
</a>
</td>
</tr>
</table>


<style>
thead{
    background-color:white;
}
table tr td:first-child::after {
   content: "";
   display: inline-block;
   vertical-align: middle;
   min-height: 22px;
}
table tr th:first-child::after {
   content: "";
   display: inline-block;
   vertical-align: middle;
   min-height: 22px;
}
</style>
<script type="text/javascript" language="javascript">
function moveScroll(){
	var scroll = $(window).scrollTop();
	var anchor_top = $("#maintable").offset().top;
	var anchor_bottom = $("#bottom_anchor").offset().top;
	if (scroll>anchor_top && scroll<anchor_bottom) {
		clone_table = $("#clone");
		if(clone_table.length == 0){
			clone_table = $("#maintable").clone();
			clone_table.attr('id', 'clone');
			clone_table.css({position:'fixed',
			'pointer-events': 'none',
			top:-13});
			clone_table.width($("#maintable").width()+3);
			$("#table-container").append(clone_table);
			$("#clone").css({visibility:'hidden'});
			$("#clone thead").css({'visibility':'visible','pointer-events':'auto'});
		}
	} else {
		$("#clone").remove();
	}
}
$(window).scroll(moveScroll);
</script>


<div id="table-container" style="width:100%">
<table id="maintable" style='border-collapse: collapse; border: 2px solid #318ee1;width: 97%;margin: 12px;box-shadow: 0px 8px 8px #000;'>
    <thead>
        <tr>
		<th  rowspan="2" style="width:300px;vertical-align: middle;background-color: #0084C3; color:#FFFFFF;font-size:12px; text-align:center;border: 1px solid #000000;border-collapse: collapse;padding: 2px;">
		 Item 
		</th>
		<th colspan="2" style="background-color: #0084C3; color:#FFFFFF;font-size:12px; text-align:center;border: 1px solid #000000;border-collapse: collapse;padding: 2px;">
		 Opening 
		</th>
		<th colspan="2" style="background-color: #0084C3; color:#FFFFFF;font-size:12px; text-align:center;border: 1px solid #000000;border-collapse: collapse;padding: 2px;">
		 Receive 
		</th>
		<th colspan="2" style="background-color: #0084C3; color:#FFFFFF;font-size:12px; text-align:center;border: 1px solid #000000;border-collapse: collapse;padding: 2px;">
		 Local Sale 
		</th>
		<th colspan="2" style="background-color: #0084C3; color:#FFFFFF;font-size:12px; text-align:center;border: 1px solid #000000;border-collapse: collapse;padding: 2px;">
		 Network Sale 
		</th>
		<th colspan="2" style="background-color: #0084C3; color:#FFFFFF;font-size:12px; text-align:center;border: 1px solid #000000;border-collapse: collapse;padding: 2px;">
		 Network Delivery 
		</th>
		<th colspan="2" style="background-color: #0084C3; color:#FFFFFF;font-size:12px; text-align:center;border: 1px solid #000000;border-collapse: collapse;padding: 2px;">
		 Return
		</th>
		<th colspan="2" style="background-color: #0084C3; color:#FFFFFF;font-size:12px; text-align:center;border: 1px solid #000000;border-collapse: collapse;padding: 2px;">
		 Closing
		</th>
	</tr>
	<tr>
		<th style="background-color: #0084C3; color:#FFFFFF;font-size:12px; text-align:center;border: 1px solid #000000;border-collapse: collapse;padding: 2px;">
		 Qty 
		</th>
		<th style="background-color: #0084C3; color:#FFFFFF;font-size:12px; text-align:center;border: 1px solid #000000;border-collapse: collapse;padding: 2px;">
		 Price 
		</th>
		
		<th style="background-color: #0084C3; color:#FFFFFF;font-size:12px; text-align:center;border: 1px solid #000000;border-collapse: collapse;padding: 2px;">
		 Qty 
		</th>
		<th style="background-color: #0084C3; color:#FFFFFF;font-size:12px; text-align:center;border: 1px solid #000000;border-collapse: collapse;padding: 2px;">
		 Price 
		</th>
		
		<th style="background-color: #0084C3; color:#FFFFFF;font-size:12px; text-align:center;border: 1px solid #000000;border-collapse: collapse;padding: 2px;">
		 Qty 
		</th>
		<th style="background-color: #0084C3; color:#FFFFFF;font-size:12px; text-align:center;border: 1px solid #000000;border-collapse: collapse;padding: 2px;">
		 Price 
		</th>
		
		<th style="background-color: #0084C3; color:#FFFFFF;font-size:12px; text-align:center;border: 1px solid #000000;border-collapse: collapse;padding: 2px;">
		 Qty 
		</th>
		<th style="background-color: #0084C3; color:#FFFFFF;font-size:12px; text-align:center;border: 1px solid #000000;border-collapse: collapse;padding: 2px;">
		 Price 
		</th>
		
		<th style="background-color: #0084C3; color:#FFFFFF;font-size:12px; text-align:center;border: 1px solid #000000;border-collapse: collapse;padding: 2px;">
		 Qty 
		</th>
		<th style="background-color: #0084C3; color:#FFFFFF;font-size:12px; text-align:center;border: 1px solid #000000;border-collapse: collapse;padding: 2px;">
		 Price 
		</th>
		
		<th style="background-color: #0084C3; color:#FFFFFF;font-size:12px; text-align:center;border: 1px solid #000000;border-collapse: collapse;padding: 2px;">
		 Qty 
		</th>
		<th style="background-color: #0084C3; color:#FFFFFF;font-size:12px; text-align:center;border: 1px solid #000000;border-collapse: collapse;padding: 2px;">
		 Price 
		</th>
		
		<th style="background-color: #0084C3; color:#FFFFFF;font-size:12px; text-align:center;border: 1px solid #000000;border-collapse: collapse;padding: 2px;">
		 Qty 
		</th>
		<th style="background-color: #0084C3; color:#FFFFFF;font-size:12px; text-align:center;border: 1px solid #000000;border-collapse: collapse;padding: 2px;">
		 Price 
		</th>
		
	</tr>
    </thead>
    <tbody>
    
    <?php 
    $root_serial=1;
    ksort($data);



    $cat_total_total_qty_opening=0;
    $cat_total_total_amount_opening=0;

    $cat_total_total_qty_receive=0;
    $cat_total_total_amount_receive=0;

    $cat_total_total_qty_local_sale=0;
    $cat_total_total_amount_local_sale=0;

    $cat_total_total_qty_network_sale=0;
    $cat_total_total_amount_network_sale=0;

    $cat_total_total_qty_network_delivery=0;
    $cat_total_total_amount_network_delivery=0;

    $cat_total_total_qty_network_return=0;
    $cat_total_total_amount_network_return=0;

    $cat_total_total_qty_network_closing=0;
    $cat_total_total_amount_network_closing=0;


    $grand_total_discount=0;
    $grand_total_adjustment=0;
    $grand_total_vatable_price=0;
    $grand_total_vat=0;





    foreach ($data as $key => $value) {
    ?>	
    	<tr>
            <td colspan="15" style=" padding-left: 5px;font-size:14px; font-weight:bold;background-color: #37ABF2; color:#000000;font-size:12px; text-align:left;border: 1px solid #000000;border-collapse: collapse;"> <?php echo "&nbsp;".$root_serial." &nbsp;".$key;?></td>
        </tr>
    	
    <?php 
    $root_serial_cat=1;
    ksort($value);
    foreach ($value as $cat_key => $cat_value) {
    	?>
    	<tr>
            <td colspan="15" style=" padding-left: 5px;font-size:14px; font-weight:bold;background-color: #A5DDFF; color:#000000;font-size:12px; text-align:left;border: 1px solid #000000;border-collapse: collapse;"> <?php echo "&nbsp;".$root_serial.".".str_pad($root_serial_cat, 2, "0", STR_PAD_LEFT)." &nbsp;".$cat_key;?></td>
        </tr>
    	
        
        <?php 
        $serial_item=1;

        $cat_total_qty_opening=0;
        $cat_total_amount_opening=0;

        $cat_total_qty_receive=0;
        $cat_total_amount_receive=0;

        $cat_total_qty_local_sale=0;
        $cat_total_amount_local_sale=0;

        $cat_total_qty_network_sale=0;
        $cat_total_amount_network_sale=0;

        $cat_total_qty_network_delivery=0;
        $cat_total_amount_network_delivery=0;

        $cat_total_qty_network_return=0;
        $cat_total_amount_network_return=0;

        $cat_total_qty_network_closing=0;
        $cat_total_amount_network_closing=0;

        ksort($cat_value);

        foreach ($cat_value as $d_key => $d_value) {

        	$closing_qty=0;
        	$closing_amount=0;

        	$grand_total_discount+=$d_value['discount_amount'];
        	$grand_total_discount-=abs($d_value['return_discount_amount']);
        	$grand_total_discount+=$d_value['global_discount_amount'];


        	$grand_total_adjustment+=$d_value['adjustment_amount'];
        	$grand_total_adjustment-=abs($d_value['return_adjustment_amount']);
        	$grand_total_adjustment+=$d_value['global_adjustment_amount'];

        	$grand_total_vatable_price+=$d_value['vat_enable_price'];
        	$grand_total_vatable_price-=abs($d_value['return_vat_enable_price']);
        	$grand_total_vatable_price+=$d_value['global_vat_enable_price'];


        	$grand_total_vat+=$d_value['vat_amount'];
        	$grand_total_vat-=abs($d_value['return_vat_amount']);
        	$grand_total_vat+=$d_value['global_vat_amount'];


        	?>
        <tr>
            <td style=" padding-left: 5px;font-size:14px; font-weight:bold;background-color: #FFFFFF; color:#000000;font-size:12px; text-align:left;border: 1px solid #000000;border-collapse: collapse;"> <?php echo "&nbsp;".$root_serial.".".str_pad($root_serial_cat, 2, "0", STR_PAD_LEFT).".".str_pad($serial_item, 2, "0", STR_PAD_LEFT)." &nbsp;".$d_key;?></td>

            
            <td style=" font-size:14px; font-weight:bold;background-color: #FFFFFF; color:#000000;font-size:12px; text-align:center;border: 1px solid #000000;border-collapse: collapse;"> 
            <?php if($d_value['opening_qty']){echo $d_value['opening_qty'];}else{echo "-";}?>
            </td>
       		<td style=" font-size:14px; font-weight:bold;background-color: #FFFFFF; color:#000000;font-size:12px; text-align:right;border: 1px solid #000000;border-collapse: collapse;"> 
            <?php if($d_value['opening_price']){echo number_format($d_value['opening_price'],2,'.','');}else{echo "-";}?>
            </td>
            <?php
            $closing_qty+=$d_value['opening_qty'];
            $closing_amount+=number_format($d_value['opening_price'],2,'.','');
            ?>
       
            <td style=" font-size:14px; font-weight:bold;background-color: #FFFFFF; color:#000000;font-size:12px; text-align:center;border: 1px solid #000000;border-collapse: collapse;"> 
            <?php if($d_value['receive_qty']){echo $d_value['receive_qty'];}else{echo "-";}?>
            </td>
       		<td style=" font-size:14px; font-weight:bold;background-color: #FFFFFF; color:#000000;font-size:12px; text-align:right;border: 1px solid #000000;border-collapse: collapse;"> 
            <?php if($d_value['receive_qty_price']){echo number_format($d_value['receive_qty_price'],2,'.','');}else{echo "-";}?>
            </td>
            
             <?php
             $closing_qty+=$d_value['receive_qty'];
             $closing_amount+=number_format($d_value['receive_qty_price'],2,'.','');
            ?>
            
       
            <td style=" font-size:14px; font-weight:bold;background-color: #FFFFFF; color:#000000;font-size:12px; text-align:center;border: 1px solid #000000;border-collapse: collapse;"> 
            <?php if($d_value['sales_qty']){echo $d_value['sales_qty'];}else{echo "-";}?>
            </td>
       		<td style=" font-size:14px; font-weight:bold;background-color: #FFFFFF; color:#000000;font-size:12px; text-align:right;border: 1px solid #000000;border-collapse: collapse;"> 
            <?php if($d_value['product_amount']){echo number_format($d_value['product_amount'],2,'.','');}else{echo "-";}?>
            </td>
            
            <?php
            $closing_qty-=$d_value['sales_qty'];
            $closing_amount-=number_format($d_value['product_amount'],2,'.','');
            ?>     

            <td style=" font-size:14px; font-weight:bold;background-color: #FFFFFF; color:#000000;font-size:12px; text-align:center;border: 1px solid #000000;border-collapse: collapse;"> 
            <?php if($d_value['global_sales_qty']){echo $d_value['global_sales_qty'];}else{echo "-";}?>
            </td>
       		<td style=" font-size:14px; font-weight:bold;background-color: #FFFFFF; color:#000000;font-size:12px; text-align:right;border: 1px solid #000000;border-collapse: collapse;"> 
            <?php if($d_value['global_product_amount']){echo number_format($d_value['global_product_amount'],2,'.','');}else{echo "-";}?>
            </td>
       
            <?php
            //$closing_qty-=$d_value['sales_qty'];
            //$closing_amount-=number_format($d_value['product_amount'],2,'.','');
            ?>  
            
            
            <td style=" font-size:14px; font-weight:bold;background-color: #FFFFFF; color:#000000;font-size:12px; text-align:center;border: 1px solid #000000;border-collapse: collapse;"> 
            <?php if($d_value['global_delivery_sales_qty']){echo $d_value['global_delivery_sales_qty'];}else{echo "-";}?>
            </td>
       		<td style=" font-size:14px; font-weight:bold;background-color: #FFFFFF; color:#000000;font-size:12px; text-align:right;border: 1px solid #000000;border-collapse: collapse;"> 
            <?php if($d_value['global_delivery_product_amount']){echo number_format($d_value['global_delivery_product_amount'],2,'.','');}else{echo "-";}?>
            </td>
             <?php
             $closing_qty-=$d_value['global_delivery_sales_qty'];
             $closing_amount-=number_format($d_value['global_delivery_product_amount'],2,'.','');
            ?>
            
            <td style=" font-size:14px; font-weight:bold;background-color: #FFFFFF; color:#000000;font-size:12px; text-align:center;border: 1px solid #000000;border-collapse: collapse;"> 
            <?php if($d_value['return_sales_qty']){echo $d_value['return_sales_qty'];}else{echo "-";}?>
            </td>
       		<td style=" font-size:14px; font-weight:bold;background-color: #FFFFFF; color:#000000;font-size:12px; text-align:right;border: 1px solid #000000;border-collapse: collapse;"> 
            <?php if($d_value['return_product_amount']){echo number_format(($d_value['return_product_amount']*-1),2,'.','');}else{echo "-";}?>
            </td>
            <?php
            $closing_qty+=$d_value['return_sales_qty'];
            $closing_amount+=number_format(($d_value['return_product_amount']*-1),2,'.','');
            ?>
            
            <td style=" font-size:14px; font-weight:bold;background-color: #FFFFFF; color:#000000;font-size:12px; text-align:center;border: 1px solid #000000;border-collapse: collapse;"> 
            <?php if($closing_qty){echo $closing_qty;}else{echo "0";}?>
            </td>
       		<td style=" padding-right: 5px;font-size:14px; font-weight:bold;background-color: #FFFFFF; color:#000000;font-size:12px; text-align:right;border: 1px solid #000000;border-collapse: collapse;"> 
            <?php if($closing_amount){echo number_format($closing_amount,2,'.','');}else{echo "0.00";}?>
            </td>
            <?php

            $cat_total_qty_opening+=$d_value['opening_qty'];
            $cat_total_amount_opening+=number_format($d_value['opening_price'],2,'.','');

            $cat_total_qty_receive+=$d_value['receive_qty'];
            $cat_total_amount_receive+=number_format($d_value['receive_qty_price'],2,'.','');

            $cat_total_qty_local_sale+=$d_value['sales_qty'];
            $cat_total_amount_local_sale+=number_format($d_value['product_amount'],2,'.','');

            $cat_total_qty_network_sale+=$d_value['global_sales_qty'];
            $cat_total_amount_network_sale+=number_format($d_value['global_product_amount'],2,'.','');

            $cat_total_qty_network_delivery+=$d_value['global_delivery_sales_qty'];
            $cat_total_amount_network_delivery+=number_format($d_value['global_delivery_product_amount'],2,'.','');

            $cat_total_qty_network_return+=$d_value['return_sales_qty'];
            $cat_total_amount_network_return+=number_format(($d_value['return_product_amount']*-1),2,'.','');

            $cat_total_qty_network_closing+=$closing_qty;
            $cat_total_amount_network_closing+=number_format($closing_amount,2,'.','');
            ?>
            
         </tr>
    <?php 	
    $serial_item++;
        }

        $cat_total_total_qty_opening+=$cat_total_qty_opening;
        $cat_total_total_amount_opening+=$cat_total_amount_opening;

        $cat_total_total_qty_receive+=$cat_total_qty_receive;
        $cat_total_total_amount_receive+=$cat_total_amount_receive;

        $cat_total_total_qty_local_sale+=$cat_total_qty_local_sale;
        $cat_total_total_amount_local_sale+=$cat_total_amount_local_sale;

        $cat_total_total_qty_network_sale+=$cat_total_qty_network_sale;
        $cat_total_total_amount_network_sale+=$cat_total_amount_network_sale;

        $cat_total_total_qty_network_delivery+=$cat_total_qty_network_delivery;
        $cat_total_total_amount_network_delivery+=$cat_total_amount_network_delivery;

        $cat_total_total_qty_network_return+=$cat_total_qty_network_return;
        $cat_total_total_amount_network_return+=$cat_total_amount_network_return;

        $cat_total_total_qty_network_closing+=$cat_total_qty_network_closing;
        $cat_total_total_amount_network_closing+=$cat_total_amount_network_closing;

        ?>
        <tr>
        	<td style=" font-size:14px; font-weight:bold;background-color: #D2D2D2; color:#000000;font-size:12px; text-align:right;border: 1px solid #000000;border-collapse: collapse;"> <?php echo "Sub-Total (".$cat_key.")&nbsp;"?></td>
        	
        	<td style=" font-size:14px; font-weight:bold;background-color: #D2D2D2; color:#000000;font-size:12px; text-align:center;border: 1px solid #000000;border-collapse: collapse;"> <?php echo $cat_total_qty_opening;?></td>
        	<td style=" font-size:14px; font-weight:bold;background-color: #D2D2D2; color:#000000;font-size:12px; text-align:right;border: 1px solid #000000;border-collapse: collapse;"> <?php echo number_format($cat_total_amount_opening,2,'.','');?></td>
        
        	<td style=" font-size:14px; font-weight:bold;background-color: #D2D2D2; color:#000000;font-size:12px; text-align:center;border: 1px solid #000000;border-collapse: collapse;"> <?php echo $cat_total_qty_receive;?></td>
        	<td style=" font-size:14px; font-weight:bold;background-color: #D2D2D2; color:#000000;font-size:12px; text-align:right;border: 1px solid #000000;border-collapse: collapse;"> <?php echo number_format($cat_total_amount_receive,2,'.','');?></td>
        	
        	<td style=" font-size:14px; font-weight:bold;background-color: #D2D2D2; color:#000000;font-size:12px; text-align:center;border: 1px solid #000000;border-collapse: collapse;"> <?php echo $cat_total_qty_local_sale;?></td>
        	<td style=" font-size:14px; font-weight:bold;background-color: #D2D2D2; color:#000000;font-size:12px; text-align:right;border: 1px solid #000000;border-collapse: collapse;"> <?php echo number_format($cat_total_amount_local_sale,2,'.','');?></td>
        
        	<td style=" font-size:14px; font-weight:bold;background-color: #D2D2D2; color:#000000;font-size:12px; text-align:center;border: 1px solid #000000;border-collapse: collapse;"> <?php echo $cat_total_qty_network_sale;?></td>
        	<td style=" font-size:14px; font-weight:bold;background-color: #D2D2D2; color:#000000;font-size:12px; text-align:right;border: 1px solid #000000;border-collapse: collapse;"> <?php echo number_format($cat_total_amount_network_sale,2,'.','');?></td>
        
        	<td style=" font-size:14px; font-weight:bold;background-color: #D2D2D2; color:#000000;font-size:12px; text-align:center;border: 1px solid #000000;border-collapse: collapse;"> <?php echo $cat_total_qty_network_delivery;?></td>
        	<td style=" font-size:14px; font-weight:bold;background-color: #D2D2D2; color:#000000;font-size:12px; text-align:right;border: 1px solid #000000;border-collapse: collapse;"> <?php echo number_format($cat_total_amount_network_delivery,2,'.','');?></td>
        
        	<td style=" font-size:14px; font-weight:bold;background-color: #D2D2D2; color:#000000;font-size:12px; text-align:center;border: 1px solid #000000;border-collapse: collapse;"> <?php echo $cat_total_qty_network_return;?></td>
        	<td style=" font-size:14px; font-weight:bold;background-color: #D2D2D2; color:#000000;font-size:12px; text-align:right;border: 1px solid #000000;border-collapse: collapse;"> <?php echo number_format($cat_total_amount_network_return,2,'.','');?></td>
        
        	<td style=" font-size:14px; font-weight:bold;background-color: #D2D2D2; color:#000000;font-size:12px; text-align:center;border: 1px solid #000000;border-collapse: collapse;"> <?php echo $cat_total_qty_network_closing;?></td>
        	<td style=" padding-right: 5px;font-size:14px; font-weight:bold;background-color: #D2D2D2; color:#000000;font-size:12px; text-align:right;border: 1px solid #000000;border-collapse: collapse;"> <?php echo number_format($cat_total_amount_network_closing,2,'.','');?></td>
        
        	
        </tr>
        
        
        <?php
        $root_serial_cat++;
    }

    ?>	
    <tr>
        	<td style=" font-size:14px; font-weight:bold;background-color: #33748E; color:#FFFFFF;font-size:12px; text-align:right;border: 1px solid #000000;border-collapse: collapse;"> <?php echo "Total (".$key.")&nbsp;"?></td>
        	
        	<td style=" font-size:14px; font-weight:bold;background-color: #33748E; color:#FFFFFF;font-size:12px; text-align:center;border: 1px solid #000000;border-collapse: collapse;"> <?php echo $cat_total_total_qty_opening;?></td>
        	<td style=" font-size:14px; font-weight:bold;background-color: #33748E; color:#FFFFFF;font-size:12px; text-align:right;border: 1px solid #000000;border-collapse: collapse;"> <?php echo number_format($cat_total_total_amount_opening,2,'.','');?></td>
        
        	<td style=" font-size:14px; font-weight:bold;background-color: #33748E; color:#FFFFFF;font-size:12px; text-align:center;border: 1px solid #000000;border-collapse: collapse;"> <?php echo $cat_total_total_qty_receive;?></td>
        	<td style=" font-size:14px; font-weight:bold;background-color: #33748E; color:#FFFFFF;font-size:12px; text-align:right;border: 1px solid #000000;border-collapse: collapse;"> <?php echo number_format($cat_total_total_amount_receive,2,'.','');?></td>
        	
        	<td style=" font-size:14px; font-weight:bold;background-color: #33748E; color:#FFFFFF;font-size:12px; text-align:center;border: 1px solid #000000;border-collapse: collapse;"> <?php echo $cat_total_total_qty_local_sale;?></td>
        	<td style=" font-size:14px; font-weight:bold;background-color: #33748E; color:#FFFFFF;font-size:12px; text-align:right;border: 1px solid #000000;border-collapse: collapse;"> <?php echo number_format($cat_total_total_amount_local_sale,2,'.','');?></td>
        
        	<td style=" font-size:14px; font-weight:bold;background-color: #33748E; color:#FFFFFF;font-size:12px; text-align:center;border: 1px solid #000000;border-collapse: collapse;"> <?php echo $cat_total_total_qty_network_sale;?></td>
        	<td style=" font-size:14px; font-weight:bold;background-color: #33748E; color:#FFFFFF;font-size:12px; text-align:right;border: 1px solid #000000;border-collapse: collapse;"> <?php echo number_format($cat_total_total_amount_network_sale,2,'.','');?></td>
        
        	<td style=" font-size:14px; font-weight:bold;background-color: #33748E; color:#FFFFFF;font-size:12px; text-align:center;border: 1px solid #000000;border-collapse: collapse;"> <?php echo $cat_total_total_qty_network_delivery;?></td>
        	<td style=" font-size:14px; font-weight:bold;background-color: #33748E; color:#FFFFFF;font-size:12px; text-align:right;border: 1px solid #000000;border-collapse: collapse;"> <?php echo number_format($cat_total_total_amount_network_delivery,2,'.','');?></td>
        
        	<td style=" font-size:14px; font-weight:bold;background-color: #33748E; color:#FFFFFF;font-size:12px; text-align:center;border: 1px solid #000000;border-collapse: collapse;"> <?php echo $cat_total_total_qty_network_return;?></td>
        	<td style=" font-size:14px; font-weight:bold;background-color: #33748E; color:#FFFFFF;font-size:12px; text-align:right;border: 1px solid #000000;border-collapse: collapse;"> <?php echo number_format($cat_total_total_amount_network_return,2,'.','');?></td>
        
        	<td style=" font-size:14px; font-weight:bold;background-color: #33748E; color:#FFFFFF;font-size:12px; text-align:center;border: 1px solid #000000;border-collapse: collapse;"> <?php echo $cat_total_total_qty_network_closing;?></td>
        	<td style=" padding-right: 5px;font-size:14px; font-weight:bold;background-color: #33748E; color:#FFFFFF;font-size:12px; text-align:right;border: 1px solid #000000;border-collapse: collapse;"> <?php echo number_format($cat_total_total_amount_network_closing,2,'.','');?></td>
        
        	
        </tr>   
    
     
   <?php

   $cat_grand_total_qty_opening+=$cat_total_total_qty_opening;
   $cat_grand_total_amount_opening+=$cat_total_total_amount_opening;

   $cat_grand_total_qty_receive+=$cat_total_total_qty_receive;
   $cat_grand_total_amount_receive+=$cat_total_total_amount_receive;

   $cat_grand_total_qty_local_sale+=$cat_total_total_qty_local_sale;
   $cat_grand_total_amount_local_sale+=$cat_total_total_amount_local_sale;

   $cat_grand_total_qty_network_sale+=$cat_total_total_qty_network_sale;
   $cat_grand_total_amount_network_sale+=$cat_total_total_amount_network_sale;

   $cat_grand_total_qty_network_delivery+=$cat_total_total_qty_network_delivery;
   $cat_grand_total_amount_network_delivery+=$cat_total_total_amount_network_delivery;

   $cat_grand_total_qty_network_return+=$cat_total_total_qty_network_return;
   $cat_grand_total_amount_network_return+=$cat_total_total_amount_network_return;

   $cat_grand_total_qty_network_closing+=$cat_total_total_qty_network_closing;
   $cat_grand_total_amount_network_closing+=$cat_total_total_amount_network_closing;


   $cat_total_total_qty_opening=0;
   $cat_total_total_amount_opening=0;

   $cat_total_total_qty_receive=0;
   $cat_total_total_amount_receive=0;

   $cat_total_total_qty_local_sale=0;
   $cat_total_total_amount_local_sale=0;

   $cat_total_total_qty_network_sale=0;
   $cat_total_total_amount_network_sale=0;

   $cat_total_total_qty_network_delivery=0;
   $cat_total_total_amount_network_delivery=0;

   $cat_total_total_qty_network_return=0;
   $cat_total_total_amount_network_return=0;

   $cat_total_total_qty_network_closing=0;
   $cat_total_total_amount_network_closing=0;


   $root_serial++;
    }

    ?>
    
    <tr>
        	<td style=" font-size:14px; font-weight:bold;background-color: #0084C3; color:#FFFFFF;font-size:12px; text-align:right;border: 1px solid #000000;border-collapse: collapse;"> <?php echo "Grand Total &nbsp;"?></td>
        	
        	<td style=" font-size:14px; font-weight:bold;background-color: #0084C3; color:#FFFFFF;font-size:12px; text-align:center;border: 1px solid #000000;border-collapse: collapse;"> <?php echo $cat_grand_total_qty_opening;?></td>
        	<td style=" font-size:14px; font-weight:bold;background-color: #0084C3; color:#FFFFFF;font-size:12px; text-align:right;border: 1px solid #000000;border-collapse: collapse;"> <?php echo number_format($cat_grand_total_amount_opening,2,'.','');?></td>
        
        	<td style=" font-size:14px; font-weight:bold;background-color: #0084C3; color:#FFFFFF;font-size:12px; text-align:center;border: 1px solid #000000;border-collapse: collapse;"> <?php echo $cat_grand_total_qty_receive;?></td>
        	<td style=" font-size:14px; font-weight:bold;background-color: #0084C3; color:#FFFFFF;font-size:12px; text-align:right;border: 1px solid #000000;border-collapse: collapse;"> <?php echo number_format($cat_grand_total_amount_receive,2,'.','');?></td>
        	
        	<td style=" font-size:14px; font-weight:bold;background-color: #0084C3; color:#FFFFFF;font-size:12px; text-align:center;border: 1px solid #000000;border-collapse: collapse;"> <?php echo $cat_grand_total_qty_local_sale;?></td>
        	<td style=" font-size:14px; font-weight:bold;background-color: #0084C3; color:#FFFFFF;font-size:12px; text-align:right;border: 1px solid #000000;border-collapse: collapse;"> <?php echo number_format($cat_grand_total_amount_local_sale,2,'.','');?></td>
        
        	<td style=" font-size:14px; font-weight:bold;background-color: #0084C3; color:#FFFFFF;font-size:12px; text-align:center;border: 1px solid #000000;border-collapse: collapse;"> <?php echo $cat_grand_total_qty_network_sale;?></td>
        	<td style=" font-size:14px; font-weight:bold;background-color: #0084C3; color:#FFFFFF;font-size:12px; text-align:right;border: 1px solid #000000;border-collapse: collapse;"> <?php echo number_format($cat_grand_total_amount_network_sale,2,'.','');?></td>
        
        	<td style=" font-size:14px; font-weight:bold;background-color: #0084C3; color:#FFFFFF;font-size:12px; text-align:center;border: 1px solid #000000;border-collapse: collapse;"> <?php echo $cat_grand_total_qty_network_delivery;?></td>
        	<td style=" font-size:14px; font-weight:bold;background-color: #0084C3; color:#FFFFFF;font-size:12px; text-align:right;border: 1px solid #000000;border-collapse: collapse;"> <?php echo number_format($cat_grand_total_amount_network_delivery,2,'.','');?></td>
        
        	<td style=" font-size:14px; font-weight:bold;background-color: #0084C3; color:#FFFFFF;font-size:12px; text-align:center;border: 1px solid #000000;border-collapse: collapse;"> <?php echo $cat_grand_total_qty_network_return;?></td>
        	<td style=" font-size:14px; font-weight:bold;background-color: #0084C3; color:#FFFFFF;font-size:12px; text-align:right;border: 1px solid #000000;border-collapse: collapse;"> <?php echo number_format($cat_grand_total_amount_network_return,2,'.','');?></td>
        
        	<td style=" font-size:14px; font-weight:bold;background-color: #0084C3; color:#FFFFFF;font-size:12px; text-align:center;border: 1px solid #000000;border-collapse: collapse;"> <?php echo $cat_grand_total_qty_network_closing;?></td>
        	<td style=" padding-right: 5px;font-size:14px; font-weight:bold;background-color: #0084C3; color:#FFFFFF;font-size:12px; text-align:right;border: 1px solid #000000;border-collapse: collapse;"> <?php echo number_format($cat_grand_total_amount_network_closing,2,'.','');?></td>
        	
        </tr>   
    </tbody>
    
    
    <tr>
    <td>
    &nbsp;
    </td>
    
    </tr>
</table>

<div id="bottom_anchor"></div>
</div>
<div style="height:20px;">&nbsp;</div>
<?php
$this->load->view("partial/footer");
?>
