<?php
session_name("AUTHENUSER");
session_start();
$USERNAME = $_SESSION['SES_USERNAME'];
if(!session_name("AUTHENUSER"))
	{
?>
						<script language="javascript">
						 alert("Waktu Login telah habis.Silahkan Login Kembali");
						document.location="index.php";
						</script>
<?php
	}
if(!$USERNAME)
	{
?>
						<script language="javascript">
						 alert("Harap Login Dahulu.");
						document.location="index.php";
						</script>
<?php
	}
	?>
	<?php include "common/config.php";
	include "include/head.php"; ?>
    <?php
	$act  = $_REQUEST['act'];
	?>

<body>
<?php include "include/head2.php"; ?>
<?php include "include/leftmenu.php"; ?>
<?php include "include/top.php"; ?>
   
  <h1><i class="icon-bar-chart"></i> Report Delete</h1>
</div>


   <div class="main-content">
   
            <div class="widget">
            <div class="widget-content-white glossed">
                    <div class="padded">
                      <form role="form" class="form-horizontal" method="post" action="report_delete.php?act=1">
                         <div class="form-group">
                         <div class="col-md-6"> 
                          <label class="control-label">Date Delete Inventory</label>
                           <input type="text" class="inputDate" name="inputDate"  value="<?php echo date('d-m-Y'); ?>" id="inputDate" >
                           </label class="control-label">
                       <input type="text" class="inputDate2" name="inputDate2"  value="<?php echo date('d-m-Y'); ?>" id="inputDate2" >
                            </div>
                        </div>
                        <button class="btn btn-primary" type="submit">Submit</button>
                        <button class="btn btn-default" type="reset">Reset</button>
                      </form>
                    </div>
             </div>
              <?php if($act == 1) { ?>
              <div class="widget-content-white glossed">
                <div class="padded">
                <table class="table table-striped table-bordered table-hover">
                   <thead>
                        <tr>
                        	<th>Inventory</th>
                       		<th>Kode Stock</th>
                            <th>Barcode No.</th>
                            <th>Reason Delete</th>
                            <th>User Delete</th>
                            <th>Date Delete</th>
                        </tr>
                    </thead>
                    <tbody>
                    <?php
					list($d, $e, $f)=split ("[-]", $_REQUEST['inputDate']);
						$datepicker=$f."-".$e."-".$d;
						list($d, $e, $f)=split ("[-]", $_REQUEST['inputDate2']);
						$datepicker1=$f."-".$e."-".$d;
						if(strtotime($datepicker1) < strtotime($datepicker))
						{
						?>
						<script language="javascript">
										 alert("Date From < Date To");
										document.location="report_delete.php";
										</script>
						<?php
						}
						else
						{
						  $sql = mysql_query("select * from
								  (select 'Diamond' as type,kode_stock,barcodeno,id_stock,reasondelete,date_update,user_update from  inventory_diamond where status_stock=2
								  union all
								  select 'Gold' as type,kode_stock,barcodeno,id_stock,reasondelete,date_update,user_update from  inventory_gold  where status_stock=2
								  union all
								  select 'LogamMulia' as type,kode_stock,barcodeno,id_stock,reasondelete,date_update,user_update from  inventory_logam  where status_stock=2
								  union all
								  select 'ReadyItem' as type,kode_stock,barcodeno,id_stock,reasondelete,date_update,user_update from  inventory_readyitem  where status_stock=2
								   union all
									  select 'Cincin' as type,kode_stock,barcodeno,id_stock,reasondelete,date_update,user_update from  inventory_cincin  where status_stock=2  							
									  union all
									  select 'Mastura' as type,kode_stock,barcodeno,id_stock,reasondelete,date_update,user_update from  inventory_mastura  where status_stock=2
									   union all
									  select 'Liontin' as type,kode_stock,barcodeno,id_stock,reasondelete,date_update,user_update from  inventory_liontin  where status_stock=2
									  union all
									  select 'Kerabu' as type,kode_stock,barcodeno,id_stock,reasondelete,date_update,user_update from  inventory_kerabu  where  status_stock=2
									  union all
										select 'GKGR' as type,kode_stock,barcodeno,id_stock,reasondelete,date_update,user_update from  inventory_gkgr  where status_stock=2
									  union all
									  select 'Rangka' as type,kode_stock,barcodeno,id_stock,reasondelete,date_update,user_update from  inventory_rangka  where status_stock=2) a
									where date(date_update) between '$datepicker' and '$datepicker1' 
								  	order by a.type");
											
			
						while($fetch = mysql_fetch_array($sql))
						{
								$type = $fetch['type'];
								$kode_stock = $fetch['kode_stock'];
								$barcodeno = $fetch['barcodeno'];
								$reasondelete = $fetch['reasondelete'];
								$user_update = $fetch['user_update'];
								$date_update = $fetch['date_update'];

					?>
                      <tr class="gradeX">
                        <td><?php echo $type; ?></td>
                          <td ><?php echo $kode_stock; ?></td>
                           <td ><?php echo $barcodeno; ?></td>
                          <td><?php echo $reasondelete; ?></td>
                          <td align="center"><?php  echo $user_update; ?></td>
                            <td align="center"><?php  echo $date_update; ?></td>
                       </tr>
                       <?php
						}
						}
						?>
                  </tbody>
                </table>
                </div>
              </div>
              <?php
			  }
			  ?>
            </div>
          </div>
        </div>
      </div>

    </div>
  </div>
</div>       

<?php include "include/foot.php"; ?>
<script src='assets/js/for_pages/dashboard.js'></script>
</body>

</html>