<?php
session_start() ;
if(!session_is_registered("login_true_admin")) {
 echo "<meta http-equiv='refresh' content='0;url=../home.php'>" ;
exit() ;
}
?>

<?
//session_start();
//echo "$status";
//if($status!="on") header("Location:./login.php");
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-874" />
<title>GoldPrice</title>
<style type="text/css">
<!--
.style2 {font-size: 12px}
.style4 {font-size: 12px; font-weight: bold; }
-->
</style>
</head>

<script type="text/javascript" src="calendarDateInput.js">

/***********************************************
* Jason's Date Input Calendar- By Jason Moon http://calendar.moonscript.com/dateinput.cfm
* Script featured on and available at http://www.dynamicdrive.com
* Keep this notice intact for use.
***********************************************/
</script>

<body>
  <?php
  			$d=date("Y-m-d",strtotime("-1 week"));  		
            $sd=date(" D, d/M/Y     H:i:s");


$user="cp037684_tbadm";
$password="siamnovaTho1220!";
$database="cp037684_tbadm";



mysql_connect(localhost,$user,$password);
@mysql_select_db($database) or die( "Unable to select database");


														
$query="SELECT * FROM goldprice   ORDER BY date  DESC, time DESC LIMIT 2"; //
$result=mysql_query($query);

//$num=mysql_numrows($result);
$num=1;

mysql_close();

$i=0;
while ($i < $num) {

$date2 =$date;

$id=mysql_result($result,$i,"id");
$date=mysql_result($result,$i,"date");
$time=mysql_result($result,$i,"time");
$b96sb=mysql_result($result,$i,"b96sb");
$b96bb =mysql_result($result,$i,"b96bb");
$o96bg =mysql_result($result,$i,"o96bg");
$o96sb=mysql_result($result,$i,"o96sb");
$o96bb=mysql_result($result,$i,"o96bb");
$g90bg=$o96bg*.9;
$g90sb=$g90bg*15.16;
$g40bg=round($o96bg*.35);
$g40sb=$g40bg*15.16;

$dateshow=date("d/M/Y",strtotime($date));
$dd=date("w",strtotime($date));

                  $p_old =mysql_result($result,($i+1),"b96bb");
				  $diff=$b96bb-$p_old ;
			      $err=0;

switch ($dd)
{
case 0 :
$fc="#FFCACA";
break;  
case 1:
$fc="#FFFF99";
break;
case 2:
$fc="#FFD2FF";
break;
case 3:
$fc="#A8FFA8";
break;
case 4:
$fc="#FFD280";
break;
case 5:
$fc="#8CFFFF";
break;
case 6:
$fc="#E3CFF1";
break;
default:
$fc="#FFFFFF";
}

?>

<table border="0" cellpadding="3" cellspacing="2" bgcolor="#FF9900">
  <tr>
    <td>Username : <?php echo $login_true_admin ?> </td>
    <td bgcolor="#FFCC00"><a href="../member/admin/menu.php">MainMenu(Admin)</a></td>
    <td bgcolor="#FFFF66"><a href="add_p.php?<?php echo "date=$date&time=$time&b96sb=$b96sb&b96bb=$b96bb&o96bg=$o96bg&o96sb=$o96sb&o96bb=$o96bb" ?>">Add</a></td>
    <td bgcolor="#FFCCCC"><a href="logout.php">Logout</a></td>
  </tr>
</table>
<p><?php echo $sd ?></p>
<p>ราคาในขณะนี้</p>

<table border="0" cellpadding="3" cellspacing="1" bgcolor="#990000">
  <tr>
    <td align="center" valign="top" bgcolor="#FFCC00"><span class="style4">วันที่</span></td>
    <td align="center" valign="top" bgcolor="#FFCC00"><span class="style4">เวลา</span></td>
    <td align="center" valign="top" bgcolor="#FFCC00"><span class="style4">ทองคำแท่ง <br />
      96.5%<br />
      รับซื้อบาทละ </span></td>
    <td align="center" valign="top" bgcolor="#FFCC00"><span class="style4">ทองคำแท่ง <br />
      96.5%<br />
      ขายบาทละ </span></td>
    <td align="center" valign="top" bgcolor="#FFCC00"><span class="style4">ทองรูปพรรณ <br />
      96.5%<br />
      รับซื้อกรัมละ </span></td>
    <td align="center" valign="top" bgcolor="#FFCC00"><span class="style4">ทองรูปพรรณ <br />
      96.5%<br />
      รับซื้อบาทละ </span></td>
    <td align="center" valign="top" bgcolor="#FFCC00"><span class="style4">ทองรูปพรรณ <br />
      96.5%<br />
      ขายบาทละ</span></td>
    <td align="center" valign="top" bgcolor="#FFCC00"><span class="style4">ทอง 90%<br />
      รับซื้อกรัมละ </span></td>
    <td align="center" valign="top" bgcolor="#FFCC00"><span class="style4">ทอง 90%<br />
      ซื้อบาทละ</span></td>
    <td align="center" valign="top" bgcolor="#FFCC00"><span class="style4">ทอง 40%<br />
      รับซื้อกรัมละ </span></td>
    <td align="center" valign="top" bgcolor="#FFCC00"><span class="style4">ทอง 40%<br />
      ซื้อบาทละ</span></td>
    <td align="center" valign="top" bgcolor="#FFCC00">&nbsp;</td>
  </tr>

  <tr>
    <td bgcolor="<?php echo $fc ?>" class="style2"><?php if($date2!=$date)echo $dateshow?></td>
    <td bgcolor="<?php echo $fc ?>" class="style2"><?php echo $time ?> </td>
    <td align="center" bgcolor="<?php echo $fc ?>" class="style2"><strong><?php echo $b96bb ?></strong></td>
    <td align="center" bgcolor="<?php echo $fc ?>" class="style2"><strong><?php echo $b96sb ?></strong></td>
    <td align="center" bgcolor="<?php echo $fc ?>" class="style2"><strong><?php echo $o96bg ?></strong></td>
    <td align="center" bgcolor="<?php echo $fc ?>"class="style2"><?php echo $o96bb ?></td>
    <td align="center" bgcolor="<?php echo $fc ?>" class="style2"><?php echo $o96sb ?></td>
    <td align="center" bgcolor="<?php echo $fc ?>" class="style2"><?php echo $g90bg ?></td>
    <td align="center" bgcolor="<?php echo $fc ?>" class="style2"><?php echo $g90sb ?></td>
    <td align="center" bgcolor="<?php echo $fc ?>" class="style2"><?php echo $g40bg ?></td>
    <td align="center" bgcolor="<?php echo $fc ?>" class="style2"><?php echo $g40sb ?></td>
    <td align="center" bgcolor="<?php echo $fc ?>" class="style2"><strong>
      <?php
	   if($err==1)
	       {
		   			echo "";
		   }elseif($diff==0)
	       {
		   			echo "<img src=\"e.gif\" width=\"20\" height=\"20\" /> ($diff)";
		   }elseif($diff>0)
			       {
	 	   			     echo "<img src=\"u.gif\" width=\"20\" height=\"20\" /> ($diff)";
				   }elseif($diff<0)
				   		{
	 	   			          echo "<img src=\"d.gif\" width=\"20\" height=\"20\" /> ($diff)";
						}
		
	?>
    </strong></td>
  </tr>
  <?

//echo "<b>| $date | $time | $b96sb | $b96bb | $o96sg | $o96sb | $o96bb</b><br>";

$i++;
}
$i=0;
$id=mysql_result($result,$i,"id");
$date=mysql_result($result,$i,"date");
$time=mysql_result($result,$i,"time");
$b96sb=mysql_result($result,$i,"b96sb");
$b96bb =mysql_result($result,$i,"b96bb");
$o96bg =mysql_result($result,$i,"o96bg");
$o96sb=mysql_result($result,$i,"o96sb");
$o96bb=mysql_result($result,$i,"o96bb");

?>
</table>

<p><a href="email_price.php?<?php echo "date=$date&time=$time&b96sb=$b96sb&b96bb=$b96bb&b99bb=$b99bb&b99bg=$b99bg&o96bg=$o96bg&o96sb=$o96sb&o96bb=$o96bb" ?>">ส่งราคาให้กลับสมาชิก VIP </a></p>
<form action="modi.php" method="get" >

<script>DateInput('orderdate1', true, 'YYYY-MM-DD','<?php echo $d ?>')</script>
<script>DateInput('orderdate2', true, 'YYYY-MM-DD')</script>

<label>
<input type="submit" name="Submit" value="Submit" />
</label>
</form>

<table border="0" cellspacing="0" cellpadding="10">
  <tr>
    <td align="left" valign="top">ราคาทองคำปี 2009<br />
        <a href="modi.php?orderdate1=2009-01-01&amp;orderdate2=2009-01-31&amp;Submit=Submit">1.เดือนมกราคม</a><br />
        <a href="modi.php?orderdate1=2009-02-01&amp;orderdate2=2009-02-28&amp;Submit=Submit">2.เดือนกุมภาพันธ์</a><br />
        <a href="modi.php?orderdate1=2009-03-01&amp;orderdate2=2009-03-31&amp;Submit=Submit">3.เดือนมีนาคม</a><br />        <br />
    </td>
    <td align="left" valign="top">&nbsp;</td>
    <td align="left" valign="top"><p>ราคาทองคำปี 2008<br />
        <a href="modi.php?orderdate1=2008-01-01&amp;orderdate2=2008-01-31&amp;Submit=Submit">1.เดือนมกราคม</a><br />
        <a href="modi.php?orderdate1=2008-02-01&amp;orderdate2=2008-02-28&amp;Submit=Submit">2.เดือนกุมภาพันธ์</a><br />
        <a href="modi.php?orderdate1=2008-03-01&amp;orderdate2=2008-03-31&amp;Submit=Submit">3.เดือนมีนาคม</a><br />
		<a href="modi.php?orderdate1=2008-04-01&amp;orderdate2=2008-04-30&amp;Submit=Submit">4.เดือนเมษายน</a><br />
        <a href="modi.php?orderdate1=2008-05-01&amp;orderdate2=2008-05-31&amp;Submit=Submit">5.เดือนพฤษภาคม</a><br />
        <a href="modi.php?orderdate1=2008-06-01&amp;orderdate2=2008-06-30&amp;Submit=Submit">6.เดือนมิถุนายน</a><br />
        <a href="modi.php?orderdate1=2008-07-01&amp;orderdate2=2008-07-31&amp;Submit=Submit">7.เดือนกรกฎาคม</a><br />
        <a href="modi.php?orderdate1=2008-08-01&amp;orderdate2=2008-08-31&amp;Submit=Submit">8.เดือนสิงหาคม</a><br />
        <a href="modi.php?orderdate1=2008-09-01&amp;orderdate2=2008-09-30&amp;Submit=Submit">9.เดือนกันยายน</a><br />
        <a href="modi.php?orderdate1=2008-10-01&amp;orderdate2=2008-10-31&amp;Submit=Submit">10.เดือนตุลาคม</a><br />
        <a href="modi.php?orderdate1=2008-11-01&amp;orderdate2=2008-11-30&amp;Submit=Submit">11.เดือนพฤษจิกายน</a><br />
        <a href="modi.php?orderdate1=2008-12-01&amp;orderdate2=2008-12-31&amp;Submit=Submit">12.เดือนธันวาคม</a>      </p>    </td>
    <td align="left" valign="top">ราคาทองคำปี 2007<br />
      <a href="modi.php?orderdate1=2007-01-01&amp;orderdate2=2007-01-31&amp;Submit=Submit">1.เดือนมกราคม</a><br />
      <a href="modi.php?orderdate1=2007-02-01&amp;orderdate2=2007-02-28&amp;Submit=Submit">2.เดือนกุมภาพันธ์</a><br />
      <a href="modi.php?orderdate1=2007-03-01&amp;orderdate2=2007-03-31&amp;Submit=Submit">3.เดือนมีนาคม</a><br />
      <a href="modi.php?orderdate1=2007-04-01&amp;orderdate2=2007-04-30&amp;Submit=Submit">4.เดือนเมษายน</a><br />
      <a href="modi.php?orderdate1=2007-05-01&amp;orderdate2=2007-05-31&amp;Submit=Submit">5.เดือนพฤษภาคม</a><br />
      <a href="modi.php?orderdate1=2007-06-01&amp;orderdate2=2007-06-30&amp;Submit=Submit">6.เดือนมิถุนายน</a><br />
      <a href="modi.php?orderdate1=2007-07-01&amp;orderdate2=2007-07-31&amp;Submit=Submit">7.เดือนกรกฎาคม</a><br />
      <a href="modi.php?orderdate1=2007-08-01&amp;orderdate2=2007-08-31&amp;Submit=Submit">8.เดือนสิงหาคม</a><br />
      <a href="modi.php?orderdate1=2007-09-01&amp;orderdate2=2007-09-30&amp;Submit=Submit">9.เดือนกันยายน</a><br />
      <a href="modi.php?orderdate1=2007-10-01&amp;orderdate2=2007-10-31&amp;Submit=Submit">10.เดือนตุลาคม</a><br />
      <a href="modi.php?orderdate1=2007-11-01&amp;orderdate2=2007-11-30&amp;Submit=Submit">11.เดือนพฤษจิกายน</a><br />
      <a href="modi.php?orderdate1=2007-12-01&amp;orderdate2=2007-12-31&amp;Submit=Submit">12.เดือนธันวาคม</a><br />    </td>
    <td align="left" valign="top">ราคาทองคำปี 2006<br />
      <a href="modi.php?orderdate1=2006-01-01&amp;orderdate2=2006-01-31&amp;Submit=Submit">1.เดือนมกราคม</a><br />
      <a href="modi.php?orderdate1=2006-02-01&amp;orderdate2=2006-02-28&amp;Submit=Submit">2.เดือนกุมภาพันธ์</a><br />
      <a href="modi.php?orderdate1=2006-03-01&amp;orderdate2=2006-03-31&amp;Submit=Submit">3.เดือนมีนาคม</a><br />
      <a href="modi.php?orderdate1=2006-04-01&amp;orderdate2=2006-04-30&amp;Submit=Submit">4.เดือนเมษายน</a><br />
      <a href="modi.php?orderdate1=2006-05-01&amp;orderdate2=2006-05-31&amp;Submit=Submit">5.เดือนพฤษภาคม</a><br />
      <a href="modi.php?orderdate1=2006-06-01&amp;orderdate2=2006-06-30&amp;Submit=Submit">6.เดือนมิถุนายน</a><br />
      <a href="modi.php?orderdate1=2006-07-01&amp;orderdate2=2006-07-31&amp;Submit=Submit">7.เดือนกรกฎาคม</a><br />
      <a href="modi.php?orderdate1=2006-08-01&amp;orderdate2=2006-08-31&amp;Submit=Submit">8.เดือนสิงหาคม</a><br />
      <a href="modi.php?orderdate1=2006-09-01&amp;orderdate2=2006-09-30&amp;Submit=Submit">9.เดือนกันยายน</a><br />
      <a href="modi.php?orderdate1=2006-10-01&amp;orderdate2=2006-10-31&amp;Submit=Submit">10.เดือนตุลาคม</a><br />
      <a href="modi.php?orderdate1=2006-11-01&amp;orderdate2=2006-11-30&amp;Submit=Submit">11.เดือนพฤษจิกายน</a><br />
      <a href="modi.php?orderdate1=2006-12-01&amp;orderdate2=2006-12-31&amp;Submit=Submit">12.เดือนธันวาคม</a><br />    </td>
  </tr>
</table>
<p><br />
  <a href="modi.php?orderdate1=2008-04-01&amp;orderdate2=2008-04-30&amp;Submit=Submit"></a></p>
<p><br />
</p>
</body>
</html>
