//=================================================================================
//10112009 new Function Show Hidden
function display_cart_hidden($cart,$change)
{
global $items;
global $total_price;
foreach ($cart as $isbn => $qty)
{
$book = get_book_details($isbn);
$book["title"];
number_format($book["price"], 2);
$qty;
number_format($book["price"]*$qty,2)."";
}
}
//=================================================================================
//แสดงรายการสินค้าที่เลือกซื้อ
function display_cart($cart,$change)
{
global $items;
global $total_price;
$productCount=1;
// 28102009 แก้ขนาดหน้าจอล่าสุด
echo "<style type=text/css>
a:link {
text-decoration: none;
color: #000000;
}
a:visited {
text-decoration: none;
color: #000000;
}
a:hover {
text-decoration: none;
color: #FFFFFF;
}
a:active {
text-decoration: none;
}
.style2 {color: #0000FF}
</style>
<table width = 1024 border = 0 align=center cellspacing = 0 background=http://www.link-distribution.com/link_lab/images/bg_show_cart.jpg>
<form action = show_cart.php method = post>
<tr bgcolor=#12C732>
<th align = left><font face=MS Sans Serif size=2> No.</font></th>
<th align = left><font face=MS Sans Serif size=2> Title</font></th>
<th align = left><font face=MS Sans Serif size=2></font></th>
<th><font face=MS Sans Serif size=2></font></th>
<th><font face=MS Sans Serif size=2>Price</font></th>
<th><font face=MS Sans Serif size=2></font></th>
<th><font face=MS Sans Serif size=2>PCS</font></th>
<th align = right><font face=MS Sans Serif size=2>Price Total</font> </th>
</tr>";
foreach ($cart as $isbn => $qty)
{
$book = get_book_details($isbn);
echo "<tr>";
echo "<td> $productCount";
$productCount++;
//echo "<td align = center>";
// โชว์สินค้าส่วนหลางและแก้รายละเอียดสินค้า เปิดหน้าใหม่เป็น popup
?>
<td><A href="javascript:void(0)" title="<?php echo $isbn ?>" onClick="Popup=window.open('detailwatch.php?isbn=<?php echo $isbn;?>','Popup','toolbar=no,location=no,status=no,menubar=no,scrollbars=no,resizable=no,width=500,height=720,left=50,top=23'); return false;" ><B><font face="MS Sans Serif" size="1"><?php echo $book["title"];?></font></A></td>
<?php
// 08092009
//echo "<td><font face=\"MS Sans serif\" size=2>".$book["page"]."</font></td>";
/*
if($book["page"]=='40'){
echo "<td align = left><font face=\"MS Sans serif\" size=2>JUMBO</font></td>";
}
elseif($book["page"]=='32'){
echo "<td><font face=\"MS Sans serif\" size=2>BOY-SIZE</font></td>";
}
*/
// 30/07/2009
echo "<td><font face=\"MS Sans serif\" size=2></font></td>";
echo "<td align = center>";
echo "<td align = center><font face=\"MS Sans Serif\" size=2>".number_format($book["price"], 2) ."</font></td>";
echo "<td align = center>";
echo "<td align = center>";
if ($change == true){
//echo "<input type = text name = \"$isbn\" value = $qty size = 2>";
$balance=$book["balance"];
if($balance==0){
echo "Empty";
}else{
?>
<select name="<?php echo $isbn;?>" style="width:40px">
<option value="<?php echo $qty;?>"><?php echo $qty;?></option>
<?php
for($i=0;$i<=$balance and $i<=10;$i++){
?>
<option value="<?php echo $i;?>"><?php echo $i;?></option>
<?php
}
?>
</select>
<?php
}
}else
echo "<font face=\"MS Sans serif\" size=2>".$qty."</font>";
echo "</td><td align = right><font face=\"MS Sans Serif\" size=2>" .number_format($book["price"]*$qty,2). " US$</font> </td></tr>\n";
}
// แสดงผลรวมของราคายังไม่รวมค่าขนส่งกับ vat7%
echo "<tr bgcolor=#12C732>
<th align = left colspan=3><font face=\"MS Sans Serif\" size=2> The Total Price</font></th>
<th align = center></th>
<th align = center></th>
<th align = center></th>
<th align = center><font face=\"MS Sans Serif\" size=2>$items</font></th>
<th align = right><font face=\"MS Sans Serif\" size=2>".number_format($total_price, 2)." US$</font> </th></tr>";
if($change == true)
{
echo "<tr>
<td colspan =4> </td>
<td align = center>
</td>
<td> </td>
</tr>";
echo "<tr>
<td colspan =4> </td>
<td align = center>
<input type = hidden name = new value =0 >
<input type = hidden name = save value = true>
<input type = submit value = \"บันทึกการเปลี่ยนแปลง\">
</td>
<td> </td>
</tr>";
}
echo "</form></table>";
}
//=================================================================================
/*$host = "61.19.248.20" ;
$username = "ktpbook" ;
$password = "saisamphan" ;
$db = "ktpbook" ;
$connect = mysql_connect($host,$username,$password) or dir("เชื่อทต่อฐานข้อมูลไม่ได้");
mysql_query("SET CHARACTER SET utf8;");
mysql_query("SET collation_connection = 'utf8_general_ci';");
mysql_select_db($db) ;*/
//$result = mysql_query("select * from member where user='$login_true'") or die ("Err Can not to result") ;
//$dbarr = mysql_fetch_array($result) ;
//******************************//
/*
print $dbarr["member_id"];
print $dbarr["name"];
print $dbarr["email"];
*/
//=================================================================================
function checkout_form()
{
//แสดงรูปแบบสำหรับป้อนรายละเอียดลูกค้า
$login_true=$_SESSION['login_true']; //วิธีดึงค่าใน session
include("host.inc.php");
$sql="select * from member where user='$login_true'";
$dbquery=mysql_db_query($dbname,$sql);
$numrows=mysql_num_rows($dbquery);
$result=mysql_fetch_array($dbquery);
//ดึงส่วนของชื่อประเทศ
$sql="select
member.name,
transportation.destination,weight_price
from
member,
transportation
where
member.member_id='". $result['member_id'] ."' and
transportation.tran_id=member.country";
$dbquery=mysql_db_query($dbname,$sql);
$dbarr=mysql_fetch_array($dbquery);
//print $result["destination"];
?>
<table width = "1024" border = "0" align="center" cellspacing = "0" background="http://www.link-distribution.com/link_lab/images/bg_card.jpg">
<form action = "purchase.php" method = "post">
<?php $date = date("Y-m-d");?>
<input type=hidden name="date" value="<?php echo $date?>">
<tr bgcolor="#12C732">
<th colspan = "2" bgcolor="#009933"><font size="3" face="MS Sans Serif">Details of Customer</font></th>
</tr>
<tr>
<th width="46%" align="left"><font face="MS Sans Serif" size="2" style="margin: 2cm">Name</font></th>
<td width="54%"><font face="MS Sans Serif">
<input name = "name" type = "text" id="name2" value="<?php echo $result["name"]; ?>" size = "30" maxlength = "35" /readonly />
</font></td>
</tr>
<tr>
<th align="left"><font face="MS Sans Serif" size="2" style="margin: 2cm">Surname</font></th>
<td><font face="MS Sans Serif">
<input name = "surname" type = "text" id="surname2" value="<?php echo $result["surname"]; ?>" size = "30" maxlength = "35" /readonly />
</font></td>
</tr>
<tr>
<th align="left"><font face="MS Sans Serif" size="2" style="margin: 2cm">Telephone</font></th>
<td><font face="MS Sans Serif">
<input name = "phone" type = "text" id="phone" value="<?php echo $result["phone"]; ?>" size = "20" maxlength = "10" /readonly />
</font></td>
</tr>
<tr>
<th align="left"><font face="MS Sans Serif" size="2" style="margin: 2cm">Email</font></th>
<td><font face="MS Sans Serif">
<input name = "email" type = "text" id="email" value="<?php echo $result["email"]; ?>" size = "30" maxlength = "40" /readonly />
</font></td>
</tr>
<tr>
<th align="left"><font face="MS Sans Serif" size="2" style="margin: 2cm">Shop-Name</font></th>
<td><font face="MS Sans Serif">
<input name = "shopname" type = "text" id="shopname" value="<?php echo $result["shopname"]; ?>" size = "30" maxlength = "60" /readonly />
</font></td>
</tr>
<tr>
<th align="left"><font face="MS Sans Serif" size="2" style="margin: 2cm">Address</font></th>
<td><font face="MS Sans Serif">
<label>
<input name="address" type="text" id="address" value="<?php echo $result["address"]; ?>" size="40" maxlength="200" /readonly />
</label>
</font></td>
</tr>
<tr>
<th align="left"><font face="MS Sans Serif" size="2" style="margin: 2cm">Country</font></th>
<td><font face="MS Sans Serif">
<input name = "country" type = "text" id="country2" value="<?php echo $dbarr["destination"]; ?>" size = "30" maxlength = "150" /readonly />
</font></td>
</tr>
<tr>
<th align="left"><font face="MS Sans Serif" size="2" style="margin: 2cm">Zipcode</font></th>
<td><font face="MS Sans Serif">
<input name = "zipcode" type = "text" id="zipcode" value="<?php echo $result["zipcode"]; ?>" size = "10" maxlength = "10" /readonly />
</font></td>
</tr>
<tr>
<th colspan = "2" bgcolor="#009933"><font size="3" face="MS Sans Serif">Product details of recipients. (Do not enter if the same customer details)</font></th>
</tr>
<tr>
<th align="left"><font face="MS Sans Serif" size="2" style="margin: 2cm">Name</font></th>
<td><font size="2" face="MS Sans Serif">
<input type = "text" name = "ship_name" value = "" maxlength = "20" size = "30" />
</font></td>
</tr>
<tr>
<th align="left"><font face="MS Sans Serif" size="2" style="margin: 2cm">Surname</font></th>
<td><font size="2" face="MS Sans Serif">
<input type = "text" name = "ship_surname" value = "" maxlength = "20" size = "30" />
</font></td>
</tr>
<tr>
<th align="left"><font face="MS Sans Serif" size="2" style="margin: 2cm">Telephone</font></th>
<td><font size="2" face="MS Sans Serif">
<input type = "text" name = "ship_phone" value = "" maxlength = "10" size = "20" />
</font></td>
</tr>
<tr>
<th align="left"><font face="MS Sans Serif" size="2" style="margin: 2cm">Email</font></th>
<td><font size="2" face="MS Sans Serif">
<input type = "text" name = "ship_email" value = "" maxlength = "40" size = "30" />
</font></td>
</tr>
<tr>
<th align="left"><font face="MS Sans Serif" size="2" style="margin: 2cm">Shop-Name</font></th>
<td><font size="2" face="MS Sans Serif">
<input type = "text" name = "ship_shopname" value = "" maxlength = "60" size = "30" />
</font></td>
</tr>
<tr>
<th align="left"><font face="MS Sans Serif" size="2" style="margin: 2cm">Address</font></th>
<td><font size="2" face="MS Sans Serif">
<input type = "text" name = "ship_address" value = "" maxlength = "200" size = "40" />
</font></td>
</tr>
<tr>
<th align="left"><font face="MS Sans Serif" size="2" style="margin: 2cm">Country</font></th>
<td><font size="2" face="MS Sans Serif">
<input type = "text" name = "ship_country" value = "" maxlength = "150" size = "30" />
</font></td>
</tr>
<tr>
<th align="left"><font face="MS Sans Serif" size="2" style="margin: 2cm">Zipcode</font></th>
<td><font size="2" face="MS Sans Serif">
<input type = "text" name = "ship_zipcode" value = "" maxlength = "10" size = "10" />
</font></td>
</tr>
<tr>
<th colspan="2" align="left" bgcolor="#009933"><div align="center"><font face="MS Sans Serif">Payment</font></div></th>
</tr>
<tr>
<th align="left"> </th>
<td> </td>
</tr>
<tr>
<th align="left"><div align="center"> <font size="2" face="MS Sans Serif">
<input type=radio name=payment value=Paypal id=rad1><label for=rad1><strong>Paypal</strong> (A/C # [email protected])
</label></font></div></th>
<td><div align="center"> <font size="2" face="MS Sans Serif">
<input type=radio name=payment value=TNT id=rad2>
<strong>
<label for=rad2><strong>T/T (Bank Transfer)</label>
</strong></font></div></td>
</tr>
<tr>
<th align="left"> </th>
<td> </td>
</tr>
<tr>
<th colspan="2" align="left"><div align="center">
<input type="submit" value=" สิ้นสุดการซื้อ" />
</div></th>
</tr>
<tr>
<th colspan="2" align="left"> </th>
</tr>
<!--<tr> -->
<!--<td align="center"><input type="submit" value=" สิ้นสุดการซื้อ"></td> -->
</form>
<!--// แก้ไขไม่เอาปุ่ม 30102009 (เก็บต้นฉบับไว้) -->
<!--<td align="center"><form action="home.php" method="post"><input type="submit" value="เลือกสินค้าต่อ"></form></td> -->
<!--<td align="center"></td> -->
<!--</tr> -->
</table>
<?php
}
function display_cart_invoice($cart,$change)
{
global $items;
global $total_price;
$productCount=1;
foreach ($cart as $isbn => $qty)
{
$book = get_book_details($isbn);
//echo "<tr>";
//echo "<td>";
// โชว์สินค้าส่วนหลางและแก้รายละเอียดสินค้า เปิดหน้าใหม่เป็น popup
?>
<tr>
<td><div align="left"><font size="2" face="MS Sans Serif"> <?php echo $productCount;?></font></strong> </div></td>
<td><div align="left"><font size="2" face="MS Sans Serif"> <?php echo $book["title"];?></font></strong> </div></td>
<td><div align="right"><font size="2" face="MS Sans Serif"><?php echo number_format($book["price"], 2);?></font></strong> </div></td>
<td><div align="right"><font size="2" face="MS Sans Serif"> <?php echo $qty;?></font></strong> </div></td>
<td><div align="right"><font size="2" face="MS Sans Serif"> <?php echo number_format($book["price"]*$qty,2). " ";?></font></strong> </div></td>
</tr>
<?php
$productCount++;
}
}
function card_form($name)
{
global $cart;
global $items;
global $total_price;
global $freight;
global $date;
$date = date("Y-m-d");
$DateOfRequest = date("YmdHis");