<?
$kotanya = $db->dataku("kota", $user_session);
 
include "../ong-kir.php";
$hargax = $harga*$jumlah;
$ongkirx = $ongkirnya*$jumlah;
$tariff = $hargax + $ongkirx;
$beratnya = $brt*$jumlah;
$bulatin = ceil($beratnya);
$ongkiry = $ongkirnya*$bulatin;
$tariffx = $hargax + $ongkiry;
 
?>
</p>
  <h4 align="center">HISTORY TRANSAKSI</h4>
  <p align="center"><strong> <span class="style1"></span></strong></p>
  <p align="center">&nbsp;</p>
  <form action="" method="post" name="form1" id="form3">
    <table width="98%" border="0" align="center" cellpadding="2" cellspacing="0">
      <tr>
        <td width="17%">Transaksi Bulan </td>
        <td width="83%"><strong><font size="2" face="Verdana, Arial, Helvetica, sans-serif">
          <? 
		$thn=substr($clientdate, 0, 4);
	$bln=substr($clientdate, 5, 2);
	$tgl=substr($clientdate, 8, 2);
	if(!$bulan && !$tahun) {
		$bulan = $bln;
		$tahun = $thn;
	}	
		echo "<select name=bulan size=1 class=form>";
	$bulan0=array("Januari", "Februari", "Maret", "April", "Mei", "Juni", "Juli", "Agustus", "September", "Oktober", "November", "Desember");
	$jbln=count($bulan0);
	if($bulan =="") {
		$bulan2 = $bln;
	} else {
		$bulan2 = $bulan;
	}
	for($b=0;$b<$jbln;$b++) {
		if($bulan2-1 == $b) {
			$pil="selected";
			} else {
			$pil="";
			}
			if($b+1 < 10) {
			$k2=$b+1;
			$k="0$k2";
			} else {
				$k=$b+1;
			}
		echo "<option value=$k $pil>$bulan0[$b]</option>";
	}
	echo "</select>";
	echo "<select name=tahun size=1 class=form>";
	$jthn=15;
	for($t=8;$t<$jthn;$t++) {
		$thn2 = (2012 + $t);	
		if($tahun == $thn2) {
			$pil="selected";
			} else {
			$pil="";
			}
		echo "<option value='$thn2' $pil>$thn2</option>";
	}
	echo "</select>";
	$tgaktif = $db->dataku("tglaktif", $user_session); 
	$dtfrom = "$tahun-$bulan-01 00:00:00";
	$dtto = "$tahun-$bulan-31 23:59:59";
		?>
          <input type="submit" name="Submit2" value="LIHAT TRANSAKSI" class="tombol" />
        </font></strong>
        </td>
      </tr>
    </table>
  </form>
  <table width="800" border="1" align="center" cellpadding="5" cellspacing="0" class="bordertable">
<tr bgcolor="#FFFF99" class="tbl_header">
            <td align="center">NO.</td>
            <td align="center">TANGGAL</td>
            <td align="center">JUMLAH</td>
            <td align="center">URAIAN</td>
			<td align="center">STATUS</td>
</tr>
<?
	$db->select("kode, uraian, username, jumlah, tujuan, poinn, tgl, status", "banner_kiri", "username='$user_session' and (tgl between '$dtfrom' and '$dtto') or tujuan='$user_session' and (tgl between '$dtfrom' and '$dtto')", "tgl desc");
	$ada = $db->num_rows();
	if($ada > 0) {
		$nom=1;
		while($row=$db->fetch_row()) {
			if($row[2] == "admin-1") {
				$user = "admin";
			} else {
				$user = $row[2];
			}		
			if($row[4] == $user_session) {
				$ket = "$row[1]";
				$kot =  "$row[5]";
			} else {
				$ket = 	"$row[1] (transfer ke $row[4])";
				$kot =  "$row[5]";
			}
			
			if(is_odd($nom) == 0) {
				$class = "tblrow_ganjil";
			} else {
				$class = "tblrow_genap";
			} 	
			if($row[7] > 0) {
				$st = "DONE";
			} else {
				$st = "<font color=red>PENDING</font>";
			}		
?>
          <tr class="<?= $class; ?>">
            <td width="4%" align="right"><?= $nom; ?>.</td>
            <td width="9%" align="center"><?= date("d-m-Y", strtotime($row[6])); ?></td>
            
            <td width="15%" align="right"><div align="center"><?= rupiah($row[3]); ?>
            </div></td>
            <td width="52%"><div align="center"><?= $ket; ?>
            </div></td>
			<td width="9%"><div align="center"><?= $st; ?>
            </div></td>
    </tr>
	<?
		$nom++;
		}
	} else {
	?>
    	<tr class="<?= $class; ?>">
            <td colspan="4" align="center"><strong>Belum ada data transaksi bulan ini.</strong></td>
    </tr>
	<?
	}
	?>
  </table>
