<div class="widget widget-table">
	<div class="widget-header">
		<h3><i class="fa fa-table"></i> Sales</h3>
	</div>
	<div class="widget-content">
	<table id="datatable-data-export" class="table table-sorting table-striped table-hover table-bordered datatable">
			<thead>
				<tr>
					<th colspan="3">EXPENSES</th>				
				</tr>
			</thead>
			<tbody>			
				<tr>
					<td>1</td>
					<td>Purchase</td>
					<td><?php		
			$total =0;
			$totqty = 0;
			$i=1;
			foreach($data['purchaserecords'] as $Item)
			{
				$totqty = $totqty + $Item->bit_qty;
				$total = $total + ($Item->bit_qty * $Item->bit_cost);
				$i++;
			}
			 echo $totalpurchase = $total; ?></td>							
				</tr>
			</tbody>
			<thead>
				<tr>
					<th colspan="3">INCOME</th>				
				</tr>
			</thead>
			<tbody>			
				<tr>
					<td>1</td>
					<td>Sales</td>
					<td><?php
			$total =0;
			$totqty = 0;
			$i=1;
			foreach($data['salesrecords'] as $Item)
			{
				$totqty = $totqty + $Item->bit_qty;
				$total = $total + ($Item->bit_qty * $Item->bit_cost);
				$i++;
			}
						echo $totalsales = $total; 
						?></td>							
				</tr>
			</tbody>
			<tfoot>	
				<tr>
					<th colspan="2">TOTAL </th>
					<th></th>					
				</tr>
				<tr>
					<th colspan="2">PROFIT/ LOSS </th>
					<th><?php echo $totalsales - $totalpurchase; ?></th>					
				</tr>
			</tfoot>
		</table>
	</div>
</div>