<html>
<head>
<title>Orderform Demo</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<!-- Start AShop Deluxe OrderForm Header Script --> 
<SCRIPT LANGUAGE=JavaScript TYPE="TEXT/JAVASCRIPT"> 
<!--Hide script from old browsers
	     function buyItem(itemno, discountcode, quantity)
	     {
		    if ((quantity > 0) && (discountcode != null) && (discountcode != '')) {
				window.open("buy.php?item="+itemno+"&discount="+discountcode+"&quantity="+quantity,"_blank","toolbar=no, location=no, scrollbars=no, width=300, height=300");
			}
			else if (quantity > 0) {
				window.open("buy.php?item="+itemno+"&quantity="+quantity,"_blank","toolbar=no, location=no, scrollbars=no, width=300, height=300");
			}

				return false;
	     }

function newWindow(newContent) 
 { 
  winContent = window.open(newContent, 'nextWin', 'right=0, top=0,width=600,height=600, toolbar=no,scrollbars=yes, resizable=yes')          
 } 
function showlicense(product) 
 { 
  window.open("license.php?"+product,"_blank","toolbar=no, location=no, scrollbars=yes, width=500, height=600") 
 } 
function checkLicense(form) 
 { 
  if (form.acceptlicense.checked) form.submit(); 
  else { 
    w = window.open("","_blank","toolbar=no, location=no, scrollbars=no, width=300, height=150"); 
   w.document.write('<html><head><title>You must accept the license agreement!</title></head><body bgcolor="#FFFFFF" text="#000000" link="#000000"><center><font face="Arial, Helvetica, sans-serif" size="3">To be allowed to buy and use this product you have to accept the license agreement!<br><br><font size="2"><a href="javascript:this.close()">Close this window</a></font></font><br></center></body></html>'); 
  } 
 } 
function cancelSubmit() 
 { 
   return false; 
 } 
 //Stop hiding script from old browsers --> 
  
</SCRIPT> 
<?php 
  include "admin/config.inc.php"; 
  include "counter.php"; 
  $db = @mysql_connect("$databaseserver", "$databaseuser", "$databasepasswd"); 
  @mysql_select_db("$databasename",$db); 
  $subtotal = 0;
  $items = explode("a", $basket);
  $arraycount = 1;
  if ($items[0] && count($items)==1) $arraycount = 0;
  for ($i = 0; $i < count($items)-$arraycount; $i++) {

   $thisitem = explode("b", $items[$i]);
   // Get the products price from the database...
    $sql="SELECT price FROM product WHERE productid=".$thisitem[count($thisitem)-1];
    $result = @mysql_query("$sql",$db);
    if (@mysql_num_rows($result) == 0) {
      $price = 0;
    } else {
		$price = @mysql_result($result, 0, "price");
    }
	eval ("\$thisproductdiscount = \$discount".$thisitem[count($thisitem)-1].";");
	if ($thisproductdiscount) {
		$sql="SELECT * FROM discount WHERE productid=".$thisitem[count($thisitem)-1];
		$result2 = @mysql_query("$sql",$db);
		$discountcode= @mysql_result($result2, 0, "code");
		$discounttype = @mysql_result($result2, 0, "type");
		$discountvalue = @mysql_result($result2, 0, "value");
		$discountcookiestring = md5($thisitem[1].$discountcode."ashopdiscounts");
		if ($thisproductdiscount == $discountcookiestring) {
			if ($discounttype == "%") $price = $price - ($price * ($discountvalue/100));
			else if ($discounttype == "$") $price -= $discountvalue;
		}
	}
	$price = $price * $thisitem[0];
    $subtotal += $price;
  }
?> 
<!-- End AShop Deluxe OrderForm Header Script --> 
</head>
<body bgcolor="#FFFFFF" text="#000000" topmargin="0">
<p>&nbsp;</p><table width="750" border="1" align="center" bordercolor="#000000">
  <tr> 
    <td height="2" valign="top" align="center" bgcolor="#FFFFFF"> 
      <table width="100%" border="0" cellspacing="0" cellpadding="3">
        <tr> 
          <td width="5%">&nbsp;</td>
          <td width="45%"><img src="images/ashoplogo.gif" width="59" height="22" border="1" alt="Shopping Cart by AShop Software"></td>
          <td width="45%"> 
            <!-- Shopping cart subtotal text box and view cart and checkout buttons. The "amount" field must be present only one time within the body of the html. If you don't want the subtotal to appear, change the field type from "text" to "hidden". Place the view cart and checkout links in convenient locations on the page. If you don't want the view cart or checkout links to appear, omit the links. --> 
<form name="shoppingcart"> 
              <table width="100%" cellpadding="2" cellspacing="0" border="0" align="right"> 
                <tr>  
                  <td width="819" align="right" bgcolor="#CCCCCC"><font face="Arial, Helvetica, sans-serif" size="2" color="#000000">Subtotal:  
                    $ </font><font face="Arial, Helvetica, sans-serif" size="2">  
                    <input type="text" name="amount" style="border: 1px solid black; background: #ffffff; width: 60px; font: 11px verdana, arial, helvetica; color: #000000;" size="6" readonly value="<?php echo number_format($subtotal,2,'.',''); ?>"> 
                  </font></td> 
                  <td width="76" bgcolor="#CCCCCC">
                <div align="right"><a href="basket.php"><img src="images/viewcart.gif" alt="View Cart:" border="0" width="76" height="21"></a></div>
              </td> 
                  <td width="76" bgcolor="#CCCCCC">
                <div align="left"><a href="shipping.php?action=checkout"><img src="images/checkout.gif" alt="Check out" border="0" width="76" height="21"></a></div>
              </td> 
                </tr> 
              </table> 
            </form>
<!-- end of shopping cart subtotal box and buttons -->
          </td>
          <td width="5%">&nbsp;</td>
        </tr>
      </table>
    </td>
  </tr>
  <tr> 
    <td valign="top" width="75%" bgcolor="#FFFFFF" height="167"> 
      <table width="750" border="0" align="center">
        <tr> 
          <td valign="top" align="center" height="150"> 
            <table width="100%" border="0" cellpadding="0">
              <tr> 
                <td width="564"><font face="Arial, Helvetica, sans-serif"><b><font size="3">OrderForm 
                  Example</font></b></font></td>
                <td align="center" width="174"><font face="Arial, Helvetica, sans-serif" size="2">Price 
                  $</font><b> <span style='font-size:10.0pt;font-family:Arial'> 
                  <?php $get = "price of 1"; include "productinfo.inc"; ?>
                  </span></b></td>
              </tr>
              <tr> 
                <td valign="top" width="564" height="112"> 
                  <p><font face="Arial, Helvetica, sans-serif"><font face="Arial, Helvetica, sans-serif" size="2">Use 
                    the commented source code from this page to include AShop 
                    Deluxe shopping cart functionality within HTML pages. OrderForm 
                    pages must be within the AShop directory. The subtotal field 
                    must be included in the page once. Make the subtotal field 
                    type="hidden" if you don't want it to appear.<br>
                    <br>
                    IMPORTANT: An .htaccess file containing the line "AddType 
                    application/x-httpd-php .html .htm" must be present in this 
                    directory if the web server is not configured to run php within 
                    htm and html file</font></font><font face="Arial, Helvetica, sans-serif"><font face="Arial, Helvetica, sans-serif" size="2">s.</font></font></p>
                  </td>
                <td height="112" width="174" align="center"> 
                  <!-- Begin AShop Deluxe OrderForm Buy Button -->
                  <!-- Change the productid ["buyIem(1,] to correspond with the AShop productid that appears next to each product in the Administration Panel > Edit Catalogue for each product. -->
                  <form style="margin-bottom: 0px;" action="" onSubmit="return buyItem(4,this.discountcode.value,this.quantity.value)">
                    <font face="Arial, Helvetica, sans-serif" size="2">Quantity: 
                    <input type="text" name="quantity" size="6" value="1" style="border: 1px solid black; background: #ffffff; width: 30px; font: 11px verdana, arial, helvetica; color: #000000;">
                    <br>
                    <input type="image" border="0" name="imageField" src="images/buysp.gif" width="111" height="21" align="bottom">
                    <br>
                    Discount code <font size="1">[Optional]</font> <br>
                    <input type="text" name="discountcode" size="18">
                    </font> 
                  </form>
<!-- end Buy Button -->
                </td>
              </tr>
            </table>
          </td>
        </tr>
      </table>
    </td>
  </tr>
</table>
</body>
</html>
