<?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
	$id_sales  = $_REQUEST['id_sales'];
	?>

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


   <div class="main-content">
              <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>Payment Date</th>
                            <th>Nominal</th>
                             <th>Payment Method</th>
                             <th>Nomor Kartu</th>
                              <th>Notes</th>
                        </tr>
                    </thead>
                    <tbody>
                    <?php
					
							$sql = mysql_query("select *
							from  sales_payment a
							left join tbl_term b on a.id_term = b.id_term
							inner join sales c on a.id_sales = c.id_sales
							where a.id_sales = '$id_sales'");
						while($fetch = mysql_fetch_array($sql))
						{
								$id_sales = $fetch['id_sales'];
								$invoice = $fetch['invoice'];
								$term = $fetch['term'];
								list($y, $m, $d)=split ("[-]",$fetch['paymentdate']);
								$paymentdate=$d."-".$m."-".$y;
								$nomorkartu = $fetch['nomorkartu'];
								$nominal = $fetch['nominal'];
								$notes = $fetch['notes'];
								
					?>
                      <tr class="gradeX">
                       	<td><a href="view_sales.php?id_sales=<?php echo $id_sales; ?>"><?php echo $fetch['invoice'];?></a></td>
                            <td><?php echo $paymentdate;?></td>
                            <td><?php echo $nominal;?></td>
                             <td><?php echo $term;?></td>
                             <td><?php echo $nomorkartu;?></td>
                             <td><?php echo $notes;?></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>