<?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"; ?>
<body>
<?php include "include/head2.php"; ?>
<?php include "include/leftmenu.php"; ?>
<?php include "include/top.php"; ?>
   
  <h1><i class="icon-bar-chart"></i> History Order Form</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="history_orderform.php">
                         <div class="form-group">
                          <label class="control-label">Tanggal Order Form</label>
                           <input type="text" class="inputDate" name="inputDate"  value="<?php echo date('d-m-Y'); ?>" id="inputDate" >
                           <input type="text" class="inputDate2" name="inputDate2"  value="<?php echo date('d-m-Y'); ?>" id="inputDate2" >
                           <button class="btn btn-primary" type="submit">Submit</button>
                        <button class="btn btn-default" type="reset">Reset</button>
                        </div>
                        
                      </form>
                    </div>
             </div>
              <div class="widget-content-white glossed">
                <div class="padded">
                <table class="table table-striped table-bordered table-hover">
                   <thead>
                        <tr>
                       		<th>Order Form Date</th>
                            <th>Order Form ID</th>
                            <th>Branch</th>
                            <th>Engraving Details</th>
                            <th>Description</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="history_orderform.php";
										</script>
						<?php
						}
						else
						{
						$sql = mysql_query("select *
						from  orderform a
						left join tbl_branch c on a.id_branch = c.id_branch
						where status_orderform = 1 and status in ('done') and orderform_date between '$datepicker' and '$datepicker1' 
						order by id_orderform");
						while($fetch = mysql_fetch_array($sql))
						{
								$id_orderform = $fetch['id_orderform'];
								$kode_orderform = $fetch['kode_orderform'];
								$details = $fetch['details'];
								$status = $fetch['status'];
								$id_branch = $fetch['id_branch'];
								$nama_branch = $fetch['nama_branch'];
								list($y, $m, $d)=split ("[-]",$fetch['orderform_date']);
								$orderform_date=$d."-".$m."-".$y;
								if($id_branch == 0)
								{
									$branch = "Head Office";
								}
								else
								{
									$branch = $nama_branch;
								}
								
					?>
                      <tr class="gradeX">
                        <td><?php echo $orderform_date; ?></td>
                          <td ><a href="view_orderform.php?id_orderform=<?php echo $id_orderform; ?>"><?php echo $fetch['kode_orderform']; ?></a></td>
                          <td><?php echo $branch; ?></td>
                          <td><?php echo $fetch['details'];?></td>
                          <td><?php echo $fetch['description'];?></td>
                       </tr>
                       <?php
						}
						}
						?>
                  </tbody>
                </table>
                </div>
              </div>
            </div>
          </div>
        </div>
      </div>

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

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

</html>