<?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> Payment History</h1>
</div>


   <div class="main-content">
   
            <div class="widget">
          
              <div class="widget-content-white glossed">
                <div class="padded">
                <table class="table table-striped table-bordered table-hover">
                   <thead>
                        <tr>
                            <th>Invoice No.</th>
                            <th>Invoice Date</th>
                            <th>Customer No. - Customer Name</th>
                            <th>Stock No</th>
                            <th>Sales Name</th>
                            <th>Payment Date</th>
                            <th>Nominal</th>
                            
                        </tr>
                    </thead>
                    <tbody>
                  <?php
						$id_sales = $_REQUEST['id_sales'];
						$sql = mysql_query("select *,a.id_sales as aid_sales, d.kode_stock from sales a
						inner join tbl_customer b on a.id_customer  = b.id_customer
						inner join  sales_payment c on a.id_sales = c.id_sales 
						LEFT JOIN salesdetails d ON a.id_sales = d.id_sales
						where a.status_sales = 1 and a.id_sales='$id_sales'");
						while($fetch = mysql_fetch_array($sql))
						{
								$user_update = $fetch['user_update'];
								$id_sales = $fetch['aid_sales'];
								$invoice = $fetch['invoice'];
								list($d, $e, $f)=split ("[-]", $fetch['invoice_date']);
								$invoice_date   =$f."-".$e."-".$d;
								list($d, $e, $f)=split ("[-]", $fetch['paymentdate']);
								$paymentdate =$f."-".$e."-".$d;
								$nominal = $fetch['nominal'];
								
					?>
                      <tr class="gradeX">
                          <td><a href="view_sales.php?id_sales=<?php echo $id_sales; ?>"><?php echo $fetch['invoice']; ?></a></td>
                          <td align="center"><?php echo $invoice_date; ?></td>
                           <td><?php echo $fetch['kode_customer'];?> - <?php echo $fetch['nama_customer'];?></td>
                             <td align="center"><?php echo $fetch['kode_stock']; ?></td>
                              <td><?php echo $user_update; ?></td>
                                <td><?php echo $paymentdate; ?></td>
                                  <td><?php echo $nominal; ?></td>
                                  
                       </tr>
                       <?php
								}
						
						//}
						?>
                  </tbody>
                </table>
                <input type="button" value=" Back " class="btn btn-default" onClick="document.location='javascript:history.back(-1)'" />
                </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>