<?php
$conn = mysqli_connect("localhost", "root", "", "heartlandpersia");
$sale_date = "";
$sale_date_to_date = "";
$queryCondition = "";
if(!empty($_POST["search"]["sale_date"])) {
$sale_date = $_POST["search"]["sale_date"];
list($fid,$fim,$fiy) = explode("-",$sale_date);
$sale_date_todate = date('Y-m-d');
if(!empty($_POST["search"]["sale_date_to_date"])) {
$sale_date_to_date = $_POST["search"]["sale_date_to_date"];
list($tid,$tim,$tiy) = explode("-",$_POST["search"]["sale_date_to_date"]);
$sale_date_todate = "$tiy-$tim-$tid";
}
$queryCondition .= "WHERE sale_date BETWEEN '$fiy-$fim-$fid' AND '" . $sale_date_todate . "'";
}
$sql = "SELECT * from tbl_sales " . $queryCondition . " ORDER BY sale_date desc";
$result = mysqli_query($conn,$sql);
?>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.0/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.0/js/bootstrap.min.js"></script>
<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
<link rel="stylesheet" href="http://code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css">
<style>
.table-content{border-top:#CCCCCC 4px solid; width:30%;}
.table-content th {padding:5px 20px; background: #F0F0F0;vertical-align:top;}
.table-content td {padding:5px 20px; border-bottom: #F0F0F0 1px solid;vertical-align:top;}
</style>
</head>
<body>
<div class="demo-content">
<form name="frmSearch" method="post" action="">
<p class="search_input">
<input type="text" placeholder="From Date" id="sale_date" name="search[sale_date]" value="<?php echo $sale_date; ?>" class="input-control" />
<input type="text" placeholder="To Date" id="sale_date_to_date" name="search[sale_date_to_date]" style="margin-left:10px" value="<?php echo $sale_date_to_date; ?>" class="input-control" />
<input type="submit" name="go" value="Search" >
</p>
<?php if(!empty($result)) { ?>
<table class="table table-bordered" id="sample-table-1" style="width:100%">
<tr>
<th align="center">Id</th>
<th align="center">Invoice no</th>
<th align="center">Date</th>
<th align="center">customer name</th>
<th align="center">subtotal</th>
<th align="center">service charge</th>
<th align="center">GST</th>
</tr>
<?php
if ($result->num_rows > 0) {
while($row = mysqli_fetch_array($result)) {
echo "<tr>";
echo "<td align=center>".$row['id']."</td>";
echo "<td align=center>".$row['sale_no']."</td>";
echo "<td align=center>".$row['sale_date']."</td>";
echo "<td align=center>".$row['customer_id']."</td>";
echo "<td align=center>".$row['sub_total']."</td>";
echo "<td align=center>".$row['delivery_charge']."</td>";
echo "<td><table class='table table-bordered'>";
$i =0 ;
$a = json_decode($row['sale_vat_objects']);
for($i=0;$i<count($a);$i++){
echo "<tr><td>".$a[$i]->tax_field_type."</td><td>".$a[$i]->tax_field_amount."</td></tr>";
}
echo "</table></td>";
}}else {echo "0";}
?>
</table>
<?php } ?>
</form>
<script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
<script>
$.datepicker.setDefaults({
showOn: "button",
buttonImage: "datepicker.png",
buttonText: "Date Picker",
buttonImageOnly: true,
dateFormat: 'dd-mm-yy'
});
$(function() {
$("#sale_date").datepicker();
$("#sale_date_to_date").datepicker();
});
</script>
</body>