<?php 

$page_name="sales_list";  

include ('../common/library.php');  

include ('../common/helper.php');  

include ('../template/header.php'); 

include ('../template/sidebar.php');
 ?>



		

		<div class="main-panel">

			<div class="content">

                     <div class="row">

						<div class="col-md-12">

							<div class="card">

								<div class="card-header">

									<div class="d-flex align-items-center">

										<h4 class="card-title"><?=$msg?></h4>

										

									</div>

									<div class="row">

									   <div class="col-12 center">

									   <form action="" method="post">

									     <div class="row">

									      <div class="col-4">

										     <input type="date" class="form-control" name="fdate" value="<? if($_POST['fdate'] !=''){ echo $_POST['fdate'];}else{ echo date('Y-m-01'); }?>"  />

										  </div>

										  <div class="col-4">

										     <input type="date" class="form-control" name="tdate" value="<? if($_POST['tdate'] !=''){ echo $_POST['tdate'];}else{ echo date('Y-m-d'); }?>"  />

										  </div>

										   <div class="col-2">

										     <button class="btn btn-info" name="show">Show</button>

										   </div>

										 </div> 

									   </form> 

									   </div>

									   

									</div>

								</div>

								<div class="card-body">

									<!-- Modal -->

									



									<div class="table-responsive">

						<?php if(isset($_POST['show'])) { ?>			

										<table id="add-row" class="display table table-striped table-hover" >

											<thead>

												<tr>

													<th>SL</th>
													<th>SO NO</th>
													<th>Customer name</th>
													<th>Item name</th>
													<th>Date</th>
													<th>Qty</th>
													<th>Amount</th>
													<th style="width: 10%">Action</th>
												</tr>

											</thead>

											

											<tbody>

											<?php

											$sql = "select m.*, sum(d.amount) as amount, d.qty, i.item_name  

											from sales_master m, sales_order d , item_info i

											where m.s_no = d.s_no  and m.group_for=".$_SESSION['group_for']." and m.warehouse=".$_SESSION['warehouse']."  and m.sales_date between '".$_POST['fdate']."' 

											and '".$_POST['tdate']."' and i.item_id=d.item_id group by m.s_no order by m.sales_date desc ";

											  $select =$conn->query($sql);

											 while($c_data = $select->fetch_assoc()){ ?>



												<tr>

												    <td><?=++$i?></td>
													<td><?=$c_data['s_no']?></td>

													<td><?=$c_data['dealer_name']?></td>

													<td><?=$c_data['item_name']?></td>

													<td><?=$c_data['sales_date']?></td>

													<td><?=$c_data['qty']?></td>

													<td><?=$c_data['amount']?></td>

													<td>

														<div class="form-button-action">

														<a href="sale_entry.php?s_no=<?php echo $c_data['s_no']?>" target="blank"><button type="button"   class="btn btn-link btn-primary btn-lg" data-original-title="Edit sales">

																<i class="fa fa-edit"></i>

															</button></a>

															<a href="sales_print_view.php?s_no=<?php echo $c_data['s_no']?>" target="blank">
															<button type="button"   class="btn btn-link btn-primary btn-lg" data-original-title="View sales">
															<i class="fa fa-eye"></i>

															</button></a>	

												

														</div>

													</td>

												</tr>

												<?php } ?>

												

											</tbody>

										</table>

									<?php  } ?>	

										

									</div>

								</div>

							</div>

						</div>

					</div>





			</div>





<?php include('../template/footer.php');?>