<?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"; 
	$act  = $_REQUEST['act'];
	$id_customer  = $_REQUEST['id_customer'];
	?>
 <script type="text/javascript">

// JK Pop up image viewer script- By JavaScriptKit.com
// Visit JavaScript Kit (http://javascriptkit.com)
// for free JavaScript tutorials and scripts
// This notice must stay intact for use

var popbackground="white" //specify backcolor or background image for pop window
var windowtitle="Image Window"  //pop window title

function detectexist(obj){
return (typeof obj !="undefined")
}

function jkpopimage(imgpath, popwidth, popheight, textdescription){

function getpos(){
leftpos=(detectexist(window.screenLeft))? screenLeft+document.body.clientWidth/2-popwidth/2 : detectexist(window.screenX)? screenX+innerWidth/2-popwidth/2 : 0
toppos=(detectexist(window.screenTop))? screenTop+document.body.clientHeight/2-popheight/2 : detectexist(window.screenY)? screenY+innerHeight/2-popheight/2 : 0
if (window.opera){
leftpos-=screenLeft
toppos-=screenTop
}
}

getpos()
var winattributes='width='+popwidth+',height='+popheight+',resizable=yes,left='+leftpos+',top='+toppos
var bodyattribute=(popbackground.indexOf(".")!=-1)? 'background="'+popbackground+'"' : 'bgcolor="'+popbackground+'"'
if (typeof jkpopwin=="undefined" || jkpopwin.closed)
jkpopwin=window.open("","",winattributes)
else{
//getpos() //uncomment these 2 lines if you wish subsequent popups to be centered too
//jkpopwin.moveTo(leftpos, toppos)
jkpopwin.resizeTo(popwidth, popheight+30)
}
jkpopwin.document.open()
jkpopwin.document.write('<html><title>'+windowtitle+'</title><body '+bodyattribute+'><img src="'+imgpath+'" style="margin-bottom: 0.5em"></html>')
jkpopwin.document.close()
jkpopwin.focus()
}

</script>   
<body>
<?php include "include/head2.php"; ?>
<?php include "include/leftmenu.php"; ?>
<?php include "include/top.php"; ?>
  <h1><i class="icon-shopping-cart"></i> History Customer</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>Item No.</th>
                      
                            <th>Price</th> 
                             <th>Sales Name</th> 
                             <th>IDR KURS</th> 
                    </tr>
                  </thead>
                  <tbody>
                     <?php
						$sql = mysql_query("select *,d.user_update as salesname from tbl_customer a
						inner join tbl_kota b on a.id_kota = b.id_kota
						inner join sales c on a.id_customer = c.id_customer
						inner join salesdetails d on c.id_sales = d.id_sales
						where status_sales = 1 and d.status  = 1 and a.id_customer = '$id_customer'");
						while($fetch = mysql_fetch_array($sql))
						{
								$id_customer = $fetch['id_customer'];	
								$inventory = $fetch['inventory'];
								$id_sales = $fetch['id_sales'];
								list($d, $e, $f)=split ("[-]", $fetch['invoice_date']);
								$invoice_date   =$f."-".$e."-".$d;
								
								if($inventory == "Diamond")
								{
										$fetch4 = mysql_fetch_array(mysql_query("select * from inventory_diamond where barcodeno ='$barcodeno'"));
										$picture = $fetch4['picture'];
										$loc = "diamond/";
										$all = $loc.$picture; 
								}
								elseif($inventory == "LogamMulia")
								{
										$fetch4 = mysql_fetch_array(mysql_query("select * from  inventory_logam where barcodeno ='$barcodeno'"));
										$picture = $fetch4['picture'];
										$loc = "gold/";
										$all = ""; 
								}
								elseif($inventory == "Gold")
								{
										$fetch4 = mysql_fetch_array(mysql_query("select * from  inventory_gold where barcodeno ='$barcodeno'"));
										$picture = $fetch4['picture'];
										$loc = "gold/";
										$all = $loc.$picture; 
								}
								elseif($inventory == "ReadyItem")
								{
										$fetch4 = mysql_fetch_array(mysql_query("select * from  inventory_readyitem where barcodeno ='$barcodeno'"));
										$picture = $fetch4['picture'];
										$loc = "readyitem/";
										$all = $loc.$picture; 
								}
								elseif($inventory == "Cincin")
								{
										$fetch4 = mysql_fetch_array(mysql_query("select * from  inventory_cincin where barcodeno ='$barcodeno'"));
										$picture = $fetch4['picture'];
										$loc = "cincin/";
										$all = $loc.$picture; 
								}
								elseif($inventory == "Mastura")
								{
										$fetch4 = mysql_fetch_array(mysql_query("select * from   inventory_mastura where barcodeno ='$barcodeno'"));
										$picture = $fetch4['picture'];
										$loc = "mastura/";
										$all = $loc.$picture; 
								}
								elseif($inventory == "Liontin")
								{
										$fetch4 = mysql_fetch_array(mysql_query("select * from   inventory_liontin where barcodeno ='$barcodeno'"));
										$picture = $fetch4['picture'];
										$loc = "liontin/";
										$all = $loc.$picture; 
								}
								elseif($inventory == "Kerabu")
								{
										$fetch4 = mysql_fetch_array(mysql_query("select * from   inventory_kerabu where barcodeno ='$barcodeno'"));
										$picture = $fetch4['picture'];
										$loc = "kerabu/";
										$all = $loc.$picture; 
								}
								elseif($inventory == "GKGR")
								{
										$fetch4 = mysql_fetch_array(mysql_query("select * from    inventory_gkgr where barcodeno ='$barcodeno'"));
										$picture = $fetch4['picture'];
										$loc = "gkgr/";
										$all = $loc.$picture; 
								}
								elseif($inventory == "Rangka")
								{
										$fetch4 = mysql_fetch_array(mysql_query("select * from   inventory_rangka where barcodeno ='$barcodeno'"));
										$picture = $fetch4['picture'];
										$loc = "rangka/";
										$all = $loc.$picture; 
								}
					?>
                        <tr class="gradeX">
                         <td><a href="view_sales.php?id_sales=<?php echo $id_sales; ?>"><?php echo $fetch['invoice'];?></a></td>
                            <td><?php echo $invoice_date;?></td>
                            <td><?php echo $fetch['kode_stock'];?></td>
                            
                            <td><?php echo $fetch['currency'];?> <?php echo $fetch['price'];?></td>
                            <td><?php echo $fetch['salesname'];?></td>
                            <td><?php echo $fetch['idr'];?></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>