<?php 
include 'dheader.php'; 
if (isset($_GET["delete"])) {
 		$delete = $db->query("DELETE FROM other_accounts WHERE id = '".$_GET["delete"]."'");
}
?>
<style type="text/css">
	@media print {
		.table>thead>tr>td {
	    line-height: 1;
	    border: 1px solid #000;
			}

			.table>tbody>tr>td {
			    line-height: 1;
			    border: 1px solid #000;
			}
		}
	.table{
		font-size: 12px;
		padding: 0px;
	}
	.table>thead>tr>td {
	    line-height: 1;
	    border: 1px solid #000;
	}

	.table>tbody>tr>td {
	    line-height: 1;
	    border: 1px solid #000;
	}

	.manage-table tr td {
    height: 24px !important;
}
</style>
	<div class="modal fade hidden-print" id="myModal" tabindex="-1" role="dialog" aria-hidden="true"></div>
	<div class="wrapper ">
		<?php include 'leftbar.php'; ?>
		<!-- left-bar -->
		<?php include 'topbar.php'; ?>
			<!-- top-bar -->
			<div class="main-content">

<form action="" method="get">
<div class="manage_buttons hidden-print">
	<div class="row">
		
		<div class="col-md-3">
			<div class="input-group input-daterange" id="reportrange2">
				
					<datalist id="careof">
					<?php 
						$allcareofs = $db->query("SELECT * FROM careof");
						while ($fcus = $allcareofs->fetchArray()) {
					?>
						<option value="<?php echo $fcus['name']; ?>">:sales person
					<?php
						}
					?>	
				
					</datalist>
				<input type="text" id="report" name="report" class="add-customer-input ui-autocomplete-input" list="careof" value="<?php echo $_GET['report']; ?>">
            </div>
		</div>

		<div class="col-md-2">
			<div class="input-group input-daterange" id="reportrange1">
                <span class="input-group-addon bg">
                    To			                                </span>
                <input type="text" class="form-control end_date datepicker" value="<?php echo $_GET['date']; ?>" name="date" id="date">
            </div>	
		</div>
		<div class="col-md-2">
			<div class="input-group input-daterange" id="reportrange1">
		<button type="submit" title="Submit" class="btn btn-success">Submit</button>
			</div>
		</div>	
	</div>
</div>

</form>
	<div class="container-fluid">
		<div class="row manage-table">

	
			<div class="panel panel-piluku">
				<div class="panel-heading">
				<h3 class="panel-title">
				<?php
				if (isset($_GET['date'])) {
				
					$sdate = $_GET['date'];
					$scus_date = explode('/', $sdate);
					$sget_sdate = $scus_date[2].'/'.$scus_date[0].'/'.$scus_date[1];


					$show_date = $_GET['date'];
					$shows_date = explode('/', $show_date);
					$sget_show_date = $shows_date[1].'/'.$shows_date[0].'/'.$shows_date[2];

				}
				?>
					Reports of - <?php echo $_GET['report'];; ?> - Date: <?php echo @$sget_show_date; ?>		
					<span class="panel-options custom">
											</span>
				</h3>
			</div>
				<div class="panel-body nopadding table_holder table-responsive" >
					<table class="tablesorter table  table-hover" id="sortable_table">
						<thead>
							<tr>
								<th>Item</th>
								<th>QTY</th>
								<th>Return</th>
							</tr>
						</thead>
						<tbody>
			           	<?php
			           			$sql = "SELECT item_name, sum(qty + discount_rs) as total_qty_of_pro, sum(remaining) as total_amount FROM customerinvoice WHERE bilty = '".$_GET['report']."' AND php_date = '$sget_sdate' group by item_name ";
								$run = $db->query($sql);
						
		            			$subqty = 0;
		            			$total_amount = 0;
								$i = 0;
		            			while($row = $run->fetchArray()){
		            				$subqty += $row['total_qty_of_pro'];
		            				$total_amount += $row['total_amount'];
								$i++;
		            	?>
		            		<tr>
			            		<td><?php echo $row['item_name']; ?></td>
			            		<td><?php echo $row['total_qty_of_pro']; ?></td>
			            		<td></td>
			            	</tr>
		            	<?php } ?>
		            	
			           
			            	<tr>
								<td colspan="11" align="center" style="color: green;">
								Total Items : <?php echo $i; ?> 
								<br>
								Total Qty : <?php echo $subqty; ?> 
								<br>
								Total Amount : <?php echo $total_amount; ?></td>
							</tr>
							</tbody>
						</table>			
				</div>	
		</div>	
				</div>
	</div>
</div>

			
<?php include 'dfooter.php'; ?>
<script>
	// window.print();
</script>