Jeg sætter virkelig pris på din store hjælp DeeDawg - super super fedt! Det ser dog stadig ud til at drille lidt.. Den vil ikke rigtigt opdaterer input'et og siger stadig 'Din kurv er tom' når man prøver at bestille :S
Smider lige hele kildekoden her:
<?
ini_set('session.cache_limiter', 'private');
/*
Note : return htmlentities(strtoupper($row['name'])); //Uncomment for local
return mb_strtoupper($row['name']); //Un comment when u upload
*/
function getFirstElement($array) {
if (count($array) != 0) {
return utf8_decode($array[0]);
} else {
return '';
}
}
class shoppen
{
var $db;
var $fields_val;
var $possible_items = array();
function getEniro()
{
// Ændre standard værdier her når siden hentes
$navn = '';
$adresse = '';
$stedNavn = '';
$postNummer = '';
$postDistrikt = '';
$hostName = '
http://partner.eniro.dk'; $path = '/servlets/XQuery';
$pincodeParam = 'pincode';
$pincodeValue = 'xxx'; // Din pincode til tjenesten
$typeParam = 'type';
$typeValue = 'person';
$phoneParam = 'phone';
// Sæt telefonnumeret fra søgningen på.
$phoneValue = $_REQUEST['tbOpslagsNummer'];
// Hvad er status når siden er submitted.
$status = '';
$url = $hostName.$path.'?'.$pincodeParam.'='.$pincodeValue.'&'.$typeParam.'='.$typeValue.'&'.$phoneParam.'='.$phoneValue;
if($_POST['btHentBillAdresse'] || $_POST['btHentShipAdresse']) {
if ($phoneValue == null) {
$status = 'Der er ikke indtastet et telefon nummer';
} else {
$response = file_get_contents($url);
$xml = simplexml_load_string($response);
if (count($xml->xpath("//eniro-result/person-list/person")) > 0) {
// Her henter vi så værdierne fra XMLen og sætter værdierne på person objektet.
$fornavn = getFirstElement( $xml->xpath("//eniro-result/person-list/person/firstname"));
$efternavn = getFirstElement( $xml->xpath('//eniro-result/person-list/person/lastname'));
$vejNavn = getFirstElement( $xml->xpath('//eniro-result/person-list/person/address/street-name'));
$vejNummer = getFirstElement( $xml->xpath('//eniro-result/person-list/person/address/street-number'));
$stedNavn = getFirstElement( $xml->xpath('//eniro-result/person-list/person/address/place-name'));
$postNummer = getFirstElement( $xml->xpath('//eniro-result/person-list/person/address/zipcode'));
$postDistrikt = getFirstElement( $xml->xpath('//eniro-result/person-list/person/address/district'));
// Her sætter vi nogle af værdierne sammen.
$navn = '';
if($fornavn != null) {
$navn = $fornavn.' '.$efternavn;
} else {
$navn = $efternavn;
}
$adresse = $vejNavn.' '.$vejNummer;
if($stedNavn != null) {
$adresse = $adresse.', '.$stedNavn;
}
} else {
$status = 'Kunne ikke finde oplysninger, indtast venligst manuelt.';
}
}
if($_POST['btHentBillAdresse']) {
$this->fields_val['bill_navn'] = $navn;
$this->fields_val['bill_adresse'] = $adresse;
$this->fields_val['bill_tlf'] = $phoneValue;
$this->fields_val['bill_postnr'] = $postNummer;
$this->fields_val['bill_postdistr'] = $postDistrikt;
$this->fields_val['bill_status'] = $status;
}
if($_POST['btHentShipAdresse']) {
$this->fields_val['ship_navn'] = $navn;
$this->fields_val['ship_adresse'] = $adresse;
$this->fields_val['ship_tlf'] = $phoneValue;
$this->fields_val['ship_postnr'] = $postNummer;
$this->fields_val['ship_postdistr'] = $postDistrikt;
$this->fields_val['ship_status'] = $status;
}
}
}
function shoppen()
{
global $db;
$this->db = $db;
//$this->ordId = ($_GET['ordId']) ? $_GET['ordId'] : $_POST['ordId'];
$this->ordId = $_SESSION['order_id'];
}/*---constructor----*/
function listProducts($cid)
{
global $tbl_product,$currency,$tblCart;
$path = "./uploads/";
$pid = $_GET['pid'] ? $_GET['pid'] : $_POST['pid'];
$cid = $_GET['cid'] ? $_GET['cid'] : $_POST['cid'];
if($_POST['overview_x'] || $_POST['overview_y'])
{
//echo "Session id:".$_SESSION['order_id'];
if($this->chkAddress($_SESSION['order_id']))
{
header("Location:popupItems.php?id=".$_SESSION['order_id']);
}
}
/*if($_POST['pay'] || $_GET['pay'])
{
$this->addToOrders($_SESSION['order_id']);
header("location: thankspage.php");
}*/
if($_POST['add_cart_x'] || $_GET['add_cart'])
{
$this->addToCart($pid,$_REQUEST['units']);
}
if ($cid)
{
$begin = $_GET['s'] ? $_GET['s'] : "0";
$this->listProdNo = 15;
$sql = "SELECT COUNT(*) FROM ".$tbl_product." WHERE category_id='".$cid."' AND status='A'";
//echo "<br><font color='pink'>".$sql."</font>";
$result = mysql_query($sql,$this->db) or die("query error in listProducts1()".mysql_error($this->db));
$total_prod = mysql_result($result,0);
/*$sql = "SELECT COUNT(*) FROM ".$tbl_product." WHERE category_id='".$cid."' AND status='A' AND archive='N'";
echo "<br><font color='red'>".$sql."</font>";
$result = mysql_query($sql,$this->db) or die("query error in listProducts2()".mysql_error($this->db));
$this->totalProd = mysql_result($result,0);*/
//$sql = "SELECT * FROM ".$tbl_product." WHERE category_id='".$cid."' AND status='A' AND archive='N' ORDER BY `date` DESC LIMIT ".$begin.",".$this->listProdNo;
$sql = "SELECT * FROM ".$tbl_product." WHERE category_id='".$cid."' AND status='A' AND archive='N' ORDER BY sequence ASC LIMIT ".$begin.",".$this->listProdNo;
//echo "<br><font color='blue'>".$sql."</font>";
$result = mysql_query($sql,$this->db) or die("query error in listProducts2()".mysql_error($this->db));
if(mysql_num_rows($result) > 0)
{ //border changed
echo "<table cellpadding='5' cellspacing='0' border='0' width='100%' class='blackText' bordercolor='red'><tr>".
"<td width='27 0' class='blackText' valign='top'><table border='0' cellpadding='0' cellspacing='0' bordercolor='green' class='blackText' width='270'><tr><td width='260' id='imgDisp' height='330' valign='top' class='blackText'><img src='images/mouseover.jpg'></td></tr><tr><td class='blackText' style='padding-bottom:5px;padding-left:10px;'><img src='images/text.gif'></td></tr><tr><td class='blackBoldText' style='padding-bottom:0px;padding-left:10px;padding-top:0px;'><a href='java script:leftPrint();'>Se leverings- og lejebetingelser her</a></td></tr></table></td>".
"<td align='left' valign='top' style='padding-top:0px;'>";
echo "<table cellpadding='2' cellspacing='0' border='0' width='100%' class='whiteText' align='left' bordercolor='pink'>";
echo "<tr><td align='left' height='40' class='blackBoldText' >".$this->getCategoryName($cid)."</td><td class='blackText' align='left'>Størrelse</td><td class='blackText' align='center'>Farve</td><td class='blackText' align='right'>(pr.del)</td><td class='blackText' align='center'>Antal</td><td class='blackText' align='center' >Bestil</td></tr>";
//Cart Form
echo "<form name='cartFrm' id='cartFrm' method='post' action='".$_SERVER['PHP_SELF']."?".$_SERVER['QUERY_STRING']."' onSubmit='return validateCart();'>";
while($row = mysql_fetch_assoc($result))
{
//$link = $_SERVER['PHP_SELF']."?cid=".$cid."&pid=".$row['id']."&mid=".$mid;
?>
<tr id="<?=$row['id']?>" class="blackText" onMouseOver='showimage("<?=$row['image']?>","<?=$row['description']?>","<?=$row['id']?>")' onmouseout='hideimage("<?=$row['id']?>")'>
<td align='left' class='blackText'><?=$row['name']?></td>
<td align='left' class='blackText'><?=(($row['size']) ? ($row['size']) : ' ')?></td>
<td align='center' class='blackText'><?=(($row['pro_color']) ? ($row['pro_color']) : ' ')?></td>
<td align='right' class='blackText'>
<?
echo number_format($row['price'],2,",",".");
?>
</td>
<?php
$sql_sel = "SELECT units FROM ".$tblCart." WHERE orders_id = '".$this->ordId."' AND product_id = '".$row['id']."'";
$result_sel = mysql_query($sql_sel, $this->db) or die("query error in listProducts2()".mysql_error($this->db));
if(mysql_num_rows($result_sel)){
$row_sel = mysql_fetch_assoc($result_sel);
$numberofUnits = $row_sel['units'];
}
$unitsID = 1;
?>
<td align="center" class="blackText">
<label for="units"></label>
<select name="units[]" id="units<?php echo $unitsID;$unitsID++; ?>">
<?php
for($i = 5;$i < 26;$i = $i + 5){
$selected = ($numberofUnits == $i ? " selected=\"selected\"" : NULL);
echo "<option value=\"$i\"$selected>$i</option>\n";
}
?>
</select>
</td>
<td align='center' class='blackText'><INPUT name='add_cart' id='add_cart' type='image' src='./images/cart.gif' style='border:0px;' value='add_cart' alt='Tilføj'></td>
<!-- <td><input type='submit' name='add_cart' id='add_cart' value='add_cart'></td> -->
</tr>
<?
echo "<input type='hidden' name='pid[]' value='".$row['id']."'>";
}
echo "<input type='hidden' name='cid' value='".$cid."'>";
echo "</form>";
if($total_prod > $this->listProdNo)
{
echo "<tr align='right'><td colspan='5' class='whiteHead' valign='top' >";
echo "<table cellpadding='5' cellspacing='0' border='0' align='right' bgcolor='#FFFFFF'>";
echo "<tr>";
for($i=0;$i<$total_prod;$i=$i+$this->listProdNo)
{
if($begin == $i)
{
echo "<td class='blackText'>".++$k."</td>";
}
else
{
echo "<td class='whiteHead'><a class='blackLink' href='".$_SERVER['PHP_SELF']."?mid=".$mid."&cid=".$cid."&s=".$i."'>".++$k."</a></td>";
}
}
echo "</tr>";
echo "</table>";
echo "</td></tr>";
}
echo "</table>";//end of outer pink table
echo "</td>";
echo "<td width='300' align='center' valign='top'>";//This is for the right shopping cart...
echo "<table border='1' cellspacing='0' cellpadding='0' width='300' style='border-collapse:collapse' bordercolor='black' >";
echo "<tr>";
echo "<td>";
echo "<table border='0' cellspacing='0' cellpadding='0' width='330' style='border-collapse:collapse' bordercolor='black' >";
echo "<tr><td colspan='5' class='blackBoldText' style='padding:5px;'>BESTILLINGSSEDDEL</td></tr>";
echo "<tr>";
echo "<td background='images/bluestrip.gif' height='22' class='blackBoldText'>  </td><td background='images/bluestrip.gif' height='19' class='whiteText_blueBg'>Produkter</td><td background='images/bluestrip.gif' height='19' class='whiteText_blueBg'>Farve</td><td background='images/bluestrip.gif' height='19' class='whiteText_blueBg' align='center'>Pris</td><td background='images/bluestrip.gif' height='19' class='whiteText_blueBg' align='center'>Antal</td>";
echo "</tr>";
$this->viewCart();// tr,td is given within the viewcart....
echo "</table>";
echo "</td>";
echo "</tr>";
if($_SESSION['order_id'])
{
?>
<tr><td background='images/bluestrip.gif' class='whiteText' height='22' style='padding-left:10px'><a href="java script:showMenu('terms')" class='billLink'>Leverings- og lejebetingelser</a></td></tr>
<?
//Comment statrted by mari instead of popup window - terms of delivery
echo "<tr style='display:none;' id='deliverTermsRow'><td class='blackText'>";
echo $this->getTermsofDelivery();
echo "</td></tr>";
//Comment statrted by mari instead of popup window - terms of delivery
echo "<tr><td height='3'></td></tr>";
?>
<tr><td background='images/bluestrip.gif' class='whiteText' height='22' style='padding-left:10px'><a href="java script:showMenu('bill')" class='billLink'>Adresse</a></td></tr>
<?
//Comment statrted by mari instead of popup window - shipping address
if ($_POST['btHentBillAdresse'])
{
echo "<tr style='display:block;' id='billTemplateRow'><td class='blackText'>";
if($_SESSION['order_id'] != "")
echo $this->getDetails();
echo $this->getEniro();
echo $this->getBillingTemplate();
echo "</td></tr>";
}
elseif ($_REQUEST['doBill'] == "update")
{
echo "<tr style='display:block;' id='billTemplateRow'><td class='blackText'>";
if($_SESSION['order_id'] != "")
echo $this->getDetails();
echo $this->getEniro();
echo $this->getBillingTemplate();
echo "</td></tr>";
}
else
{
echo "<tr style='display:none;' id='billTemplateRow'><td class='blackText'>";
if($_SESSION['order_id'] != "")
echo $this->getDetails();
echo $this->getBillingTemplate();
echo "</td></tr>";
}
//Comment statrted by mari instead of popup window - shipping address
echo "<tr><td height='3'></td></tr>";
?><tr><td background='images/bluestrip.gif' class='whiteText' height='22' style='padding-left:10px'><a href="java script:showMenu('ship')" class='billLink'>Evt. leveringsadresse</a></td></tr>
<?
//Comment statrted by mari instead of popup window - shipping address
if ($_POST['btHentShipAdresse'])
{
echo "<tr style='display:block;'id='shipTemplateRow'><td class='blackText'>";
if($_SESSION['order_id'] != "")
echo $this->getDetails();
echo $this->getEniro();
echo $this->getShippingTemplate();
echo "</td></tr>";
}
elseif ($_REQUEST['doShip'] == "update")
{
echo "<tr style='display:block;'id='shipTemplateRow'><td class='blackText'>";
if($_SESSION['order_id'] != "")
echo $this->getDetails();
echo $this->getEniro();
echo $this->getShippingTemplate();
echo "</td></tr>";
}
else
{
echo "<tr style='display:none;' id='shipTemplateRow'><td class='blackText'>";
if($_SESSION['order_id'] != "")
echo $this->getDetails();
echo $this->getShippingTemplate();
echo "</td></tr>";
}
//Comment statrted by mari instead of popup window - shipping address
echo "<tr><td height='3'></td></tr>";
}
echo "</table>";
/* if($_SESSION['order_id'])
{
//This is for the checkout
echo "<form name='checkoutFrm' id='checkoutFrm' method='post' action='".$_SERVER['PHP_SELF']."?".$_SERVER['QUERY_STRING']."'>";
echo "<input type='hidden' name='pay' id='pay' value='1'>";
echo "</form>";
}*/
echo "<form name='overviewFrm' id='overviewFrm' method='post' action='".$_SERVER['PHP_SELF']."?".$_SERVER['QUERY_STRING']."'>";
if($_SESSION['order_id'])
{
?>
<input type="image" src='./images/overview.gif' id="overview" name="overview" vspace="10">
<!-- onclick='' -->
<?
}
else
{
?>
<img src='./images/overview.gif' id="overview" name="overview" vspace="10">
<?
}
echo "</form>";
echo "</td>";
echo "</tr>";
echo "</table>";//end of outer red table
}
else
{
echo "<table cellpadding='45' cellspacing='0' border='0' width='100%' align='center'>";
echo "<tr><td align='center' class='blackText'>".
"p.t. ingen produkter i kategorien";
echo "</td></tr></table>";
}
}
}/*---listProducts()----*/
function getTermsofDelivery()
{
global $tbl_terms,$url;
$path = "./print/";
$sql = "SELECT * FROM ".$tbl_terms;
//echo $sql;
$result = mysql_query($sql,$this->db) or die("query error in getTermsofDelivery() : ".mysql_error($this->db));
$row = mysql_fetch_assoc($result);
?>
<table cellpadding='10' cellspacing='0' border='1' width='330px' bordercolor="#04519C" style="BORDER-RIGHT: #04519C 1px solid;BORDER-TOP: #04519C 1px solid;BORDER-LEFT: #04519C 1px solid;BORDER-BOTTOM: #04519C 1px solid; border-collapse:collapse;">
<tr>
<td class='blackText'><?=stripslashes($row['terms'])?>
</td>
</tr>
</table>
<?
}/*------------- getTermsofDelivery() - End--------------*/
function addToCart($prd_id,$units)
{
global $tblOrders, $tblCart, $tblOrderDetails,$tbl_product,$tblAddress;
$_SESSION['order_id'] = $_SESSION['order_id'] ? $_SESSION['order_id'] : "";
if($_SESSION['order_id'] == "")
{
$sql = "INSERT INTO ".$tblOrders." SET ip_address='".$_SERVER['REMOTE_ADDR']."', `datetime`=now()";
//echo "<font color='blue'>INSERT".$sql."</font><br>";
$result = mysql_query($sql,$this->db) or die("query error addToCart".mysql_error($this->db));
$order_id = mysql_insert_id();
$_SESSION['order_id'] = mysql_insert_id();
//For inserting the order id in the address table
$sql_addr = "INSERT INTO ".$tblAddress." SET orders_id='".$_SESSION['order_id']."'";
//echo "<font color='blue'>Addr".$sql_addr."</font><br>";
$result_addr = mysql_query($sql_addr,$this->db) or die("query error addToCart--Address".mysql_error($this->db));
}
$ord_id = $_SESSION['order_id'];
$this->ord_id = $_SESSION['order_id'];
if($ord_id)
{
for($i=0;$i<count($_POST['pid']);$i++)
{
$sql1 = "SELECT * FROM ".$tblCart." WHERE orders_id='".$ord_id."' AND product_id='".$_POST['pid'][$i]."'";
//echo "<font color='blue'>addToCart-1".$sql1."</font><br>";
$result1 = mysql_query($sql1,$this->db) or die("query error addToCart-1".mysql_error($this->db));
//-----------
if(mysql_num_rows($result1) == 0)
{
$sql2 = "SELECT * FROM ".$tbl_product." WHERE id='".$_POST['pid'][$i]."'";
//echo "<font color='blue'>".$sql2."</font><br>";
$result2 = mysql_query($sql2,$this->db);
$row2 = mysql_fetch_assoc($result2);
if($_POST['units'][$i] != "")
{
$sql3 = "INSERT INTO ".$tblCart." SET orders_id='".$ord_id."',".
" product_id='".$_POST['pid'][$i]."',".
" units='".$_POST['units'][$i]."',".
" price='".($row2['price'])."',opvask='".$row2['dishwashprice']."',`datetime`=now()";
//echo "<font color='blue'>".$sql3."</font><br>";
$result3 = mysql_query($sql3,$this->db) or die("query error--addTocart--2".mysql_error($this->db));
echo "<script language='javascript'>document.location.href=document.location.href;</script>";
}
}
else
{
$sql2 = "SELECT * FROM ".$tbl_product." WHERE id='".$_POST['pid'][$i]."'";
//echo "<font color='blue'>".$sql2."</font><br>";
$result2 = mysql_query($sql2,$this->db);
$row2 = mysql_fetch_assoc($result2);
if($_POST['units'][$i] != "")
{
$sql3 = "UPDATE ".$tblCart." SET ".
" units='".$_POST['units'][$i]."',".
" product_id='".$_POST['pid'][$i]."',orders_id='".$ord_id."',".
" price='".($row2['price'])."',opvask='".$row2['dishwashprice']."',`datetime`=now()".
" WHERE ".
" product_id='".$_POST['pid'][$i]."' AND orders_id='".$ord_id."'";
//echo "<font color='blue'>".$sql3."</font><br>";
$result3 = mysql_query($sql3,$this->db) or die("query error--addTocart--2".mysql_error($this->db));
echo "<script language='javascript'>document.location.href=document.location.href;</script>";
}
}
}
}
$cok_add = $_SESSION['order_id']."cart";
//echo "0 IS HERE".$cok_add;
setcookie($cok_add,"");
}//end of addToCart();
function viewCart()
{
$pid = $_GET['pid'] ? $_GET['pid'] : $_POST['pid'];
$cid = $_GET['cid'] ? $_GET['cid'] : $_POST['cid'];
$mid = $_GET['mid'] ? $_GET['mid'] : $_POST['mid'];
if($_POST['update_cart'] || $_GET['update_cart'])
{
$cok_name = $_SESSION['order_id']."order";
//echo "<font color='red'>cooke name--".$cok_name."/----value--".$_COOKIE[$cok_name];
if($_COOKIE[$cok_name] == "update")
{
$this->updateCart();
echo "<script language='javascript'>document.location.href=document.location.href;</script>";
}
}
elseif ($_POST['remove_cart'] || $_GET['remove_cart'])
{
$cok_name = $_SESSION['order_id']."order";
if($_COOKIE[$cok_name] == "update")
{
$this->removeCart();
echo "<script language='javascript'>document.location.href=document.location.href;</script>";
}
}
$ord_id = $_SESSION['order_id'];
//echo $ord_id;
global $tblOrders, $tblCart, $tblOrderDetails,$tbl_product;
$sql = "SELECT * FROM ".$tblCart." WHERE orders_id='".$ord_id."' ORDER BY `datetime` DESC";
//echo $sql."<br>";
$result = mysql_query($sql,$this->db) or die("query error in viewCart()".mysql_error($this->db));
echo "<form name='updateCartFrm' id='updateCartFrm' method='post' action='".$_SERVER['PHP_SELF']."?".$_SERVER['QUERY_STRING']."'>";
//echo "<table cellpadding='0' cellspacing='1' border='1' width='100%' align='center' bordercolor='green'>";
if(mysql_num_rows($result) > 0)
{
$no=1;
while ($row = mysql_fetch_assoc($result))
{
echo "<tr align='center' class='whiteText'>";
echo "<td width='1%'><input type='checkbox' id='chk' name='chk[]' value='".$row['id']."' class='noborder'></td>".
"<td class='blackText' align='left'>".$this->getProdName($row['product_id'])."</td><td class='blackText' width='10px'>".$this->getProdColor($row['product_id'])."</td><td class='blackText' align='right' style='padding-right:7px;'>";
echo number_format(($row['price'] * $row['units']),2,",",".");
echo "</td>";
echo "<td width='4%' style='padding-right:2px;'><input type='text' id='units_".$row['id']."' name='units_".$row['id']."' onKeyPress='if (event.keyCode < 48 || event.keyCode > 57) event.returnValue = false;' value='".$row['units']."' size='3' class='blue' align='right' ></td>";
echo "</tr>";
$total = $total + ($row['price'] * $row['units']);
if($row['opvask'])
{
$opvaskPrice = $opvaskPrice + ($row['opvask'] * $row['units']);
}
//echo $total;
}
//The below coding is for opvask
echo "<tr><td colspan='5' class='blackText'><hr color='#000000' style='height: 1px;'></td></tr>";
echo "<tr><td class='blackText'> </td><td colspan='2' class='blackText'>".(($_COOKIE['opvask'] == "opvaskchecked") ? 'Total' : 'Total ekskl. moms.')."</td><td align='right' style='padding-right:7px;' class='blackText'>";
echo number_format($total,2,",",".");
echo "</td><td class='blackText'> </td></tr>";
echo "<tr class='blackText' id='attachOpvask'>";
if($_COOKIE['opvask'] == "opvaskchecked")
{
$this->opvaskSel = "checked";
}
else
{
$this->opvaskSel = "";
}
echo "<td class='blackText'> </td><td id='colSpanEdit' colspan='2' class='blackText'>ønsker opvask <input type='checkbox' name='attach' id='attach' class='noborder' onClick='showOpvask();' $this->opvaskSel></td><td align='right' class='blackText' id='opvaskPriceCol' style='visibility:hidden;padding-right:7px;'>".number_format($opvaskPrice,2,",",".")."</td>";
echo "</tr>";
?>
<script language="javascript">
if(document.getElementById("attach").checked)
{
document.getElementById("opvaskPriceCol").style.visibility='visible';
}
</script>
<?
if($_COOKIE['opvask'] == "opvaskchecked")
{
echo "<tr id='attachOpvaskRow'>";
echo "<td class='blackText'> </td><td colspan='2' class='blackText'>Total ekskl. moms</td><td align='right' style='padding-right:7px;' class='blackText'>";
echo number_format(($opvaskPrice + $total),2,",",".");
echo "</td><td class='blackText'> </td>";
echo "</tr>";
}
//echo "<tr><td colspan='5' class='blackText'> </td></tr>";
echo "<tr>";
echo "<td class='blackText'> </td><td colspan='2' class='blackText'>25% moms</td><td align='right' style='padding-right:7px;' class='blackText'>";
if($_COOKIE['opvask'] == "opvaskchecked")
$taxCalAmt = ($opvaskPrice + $total);
else
$taxCalAmt = $total;
//$taxCalAmt = (($_COOKIE['opvask'] == "opvaskchecked") ? $total : ($opvaskPrice + $total));
echo number_format(((25*$taxCalAmt)/100),2,",",".");
echo "</td><td class='blackText'> </td>";
echo "</tr>";
echo "<tr>";
echo "<td class='blackText'> </td><td colspan='2' class='blackText'>Total inkl. moms</td><td align='right' style='padding-right:7px;' class='blackText'>";
if($_COOKIE['opvask'] == "opvaskchecked")
{
$total = $total + $opvaskPrice;
}
$grandTotal = ((25*$total)/100) + $total;
echo number_format(($grandTotal),2,",",".");
echo "</td><td class='blackText'> </td>";
echo "</tr>";
echo "<tr><td colspan='5' class='blackText' style='padding-top:7px;padding-bottom:7px;'>".
" <input type='submit' name='remove_cart' id='remove_cart' value='Fjern' class='blueButton' onClick='return removeCheck(\"".$_SESSION['order_id']."\")'>".
" <input type='submit' name='update_cart' id='update_cart' value='Opdater Kurven' class='blueButton' onClick='return checkUnit(\"".$_SESSION['order_id']."\")'>".
"</td></tr>";
}
else
{
echo "<tr>";
echo "<td align='center' bgcolor='#FFFFFF' colspan='5' class='blackText'>Din kurv er tom</td>";
echo "</tr>";
}
echo "<input type='hidden' name='pid' id='pid' value='".$pid."'>";
echo "<input type='hidden' name='cid' id='cid' value='".$cid."'>";
//echo "</table>";
echo "</form>";
}// end of viewCart
function updateCart()
{
global $tblCart;
foreach ($_POST as $key => $val)
//foreach ($_GET as $key => $val)
{
if (eregi("units",$key))
{
$t = explode("_",$key);
$tempcart[$t[1]] = $val;
}
}
//print_r($tempcart);
$ord_id = $_SESSION['order_id'];
foreach ($tempcart as $key => $val)
{
$sql = "UPDATE ".$tblCart." SET units='".$val."' WHERE id='".$key."' AND orders_id='".$ord_id."'";
//echo $sql."<br>";
$result = mysql_query($sql,$this->db) or die("query error in updateCart()".mysql_error($this->db));
}
$cok_name = $_SESSION['order_id']."order";
$_COOKIE[$cok_name] = "";
setcookie($cok_name,"");
}
function removeCart()
{
global $tblCart;
$ord_id = $_SESSION['order_id'];
foreach ($_POST['chk'] as $key => $val)
//foreach ($_GET['chk'] as $key => $val)
{
$sql = "DELETE FROM ".$tblCart." WHERE id='".$val."' AND orders_id='".$ord_id."'";
//echo $sql."<br>";
$result = mysql_query($sql,$this->db) or die("query error in removeCart()".mysql_error($this->db));
}
$cok_name = $_SESSION['order_id']."order";
$_COOKIE[$cok_name] = "";
setcookie($cok_name,"");
}
function getCategoryName($id)
{
global $tbl_category;
$sql = "SELECT * FROM ".$tbl_category." WHERE id='".$id."'";
//echo $sql."<br>";
$result = mysql_query($sql,$this->db) or die("query error in getCategoryName()".mysql_error($this->db));
$row = mysql_fetch_assoc($result);
//return htmlentities(strtoupper($row['name'])); //Uncomment in lcoal
return ($row['name']); //Un comment when u upload
}/*---getCategoryName()----*/
function getProdName($id)
{
global $tbl_product;
$sql = "SELECT * FROM ".$tbl_product." WHERE id='".$id."'";
//echo $sql."<br>";
$result = mysql_query($sql,$this->db) or die("query error in getProdName()".mysql_error($this->db));
$row = mysql_fetch_assoc($result);
return $row['name'];
}//end of getProdName
function getProdColor($id)
{
global $tbl_product;
$sql = "SELECT * FROM ".$tbl_product." WHERE id='".$id."'";
//echo $sql."<br>";
$result = mysql_query($sql,$this->db) or die("query error in getProdName()".mysql_error($this->db));
$row = mysql_fetch_assoc($result);
return $row['pro_color'];
}//end of getProdName
function chkAddress($ord_id)
{
global $tblAddress;
$sql = "SELECT ship_navn,bill_navn,bill_tlf,bill_email FROM ".$tblAddress." WHERE orders_id='".$ord_id."'";
//echo $sql;
$result = mysql_query($sql,$this->db) or die("query error in chkAddress()".mysql_error($this->db));
if(mysql_num_rows($result) > 0)
{
$row = mysql_fetch_assoc($result);
//if(($row['bill_navn'] == "" || $row['bill_tlf'] == "" || $row['bill_email'] == "") && ($row['ship_navn'] == ""))
//{
?>
<!-- <script language='javascript' type="text/javascript">
alert("Betalings- og Evt. leveringsadresse er tom");
</script> -->
<?
//return false;
//}
if($row['bill_navn'] == "" || $row['bill_tlf'] == "" || $row['bill_email'] == "")
{
?>
<script language='javascript' type="text/javascript">
alert("Adresse er tom");
</script>
<?
return false;
}
else
{
return true;
}
//elseif($row['ship_navn'] == "")
//{
?>
<!-- <script language='javascript' type="text/javascript">
alert("Evt. leveringsadresse er tom");
</script> -->
<?
//return false;
//}
}
}//end of chkAddress()
// Functions for shipping address
function assignPost($post_arr)
{
$ok = true;
foreach ($post_arr as $key => $val)
{
$this->fields_val[$key] = $val;
}
if($this->fields_val['bill_elevator'] == "Y")
$this->fields_val['bill_elevator'] = "Y";
else
$this->fields_val['bill_elevator'] = "N";
if($this->fields_val['ship_elevator'] == "Y")
$this->fields_val['ship_elevator'] = "Y";
else
$this->fields_val['ship_elevator'] = "N";
return($ok);
}/*.........end of assignPost().....................*/
function addShipDB()
{
global $tblAddress;
if($this->fields_val['ship_elevator_person']=='0')
{
$ship_elevator_person = 'None';
}
elseif($this->fields_val['ship_elevator_person']=='1')
{
$ship_elevator_person = 'Y';
}
elseif($this->fields_val['ship_elevator_person']=='2')
{
$ship_elevator_person = 'N';
}
else
{
$ship_elevator_person = '';
}
$sql = "UPDATE ".$tblAddress." SET ship_navn ='".addslashes($this->fields_val['ship_navn']).
"', ship_att='".$this->fields_val['ship_att'].
"', ship_adresse ='".$this->fields_val['ship_adresse'].
"', ship_etage='".$this->fields_val['ship_etage'].
"', ship_elevator='".$this->fields_val['ship_elevator'].
"', ship_elevator_person='".$ship_elevator_person.
"', ship_postnr='".$this->fields_val['ship_postnr'].
"', ship_postdistr='".$this->fields_val['ship_postdistr'].
"', ship_tlf ='".$this->fields_val['ship_tlf']."' WHERE orders_id='".$this->ordId."'";
//echo "<br>".$sql;
$result = mysql_query($sql,$this->db) or die("query error in addShipDB".mysql_error($this->db));
$msg = $result ? "Evt. leveringsadresse er opdateret" : "Evt. leveringsadresse ikke tilføjet";//Shipping Address Details Updated Successfully
return $msg;
}/*........... end of addDb function........................*/
function addBillDB()
{
global $tblAddress;
if($this->fields_val['bill_elevator_person']=='0')
{
$bill_elevator_person = 'None';
}
elseif($this->fields_val['bill_elevator_person']=='1')
{
$bill_elevator_person = 'Y';
}
elseif($this->fields_val['bill_elevator_person']=='2')
{
$bill_elevator_person = 'N';
}
else
{
$bill_elevator_person = '';
}
$dtstring_lev = substr($this->fields_val['bill_leverings'],0,2);
$monthstring_lev = substr($this->fields_val['bill_leverings'],3,2);
$ystring_lev = substr($this->fields_val['bill_leverings'],6,4);
$year_lev = $ystring_lev;
$d_lev = $year_lev."-".$monthstring_lev."-".$dtstring_lev." ".date("H:i:s");
$dtstring_bru = substr($this->fields_val['bill_brugs'],0,2);
$monthstring_bru = substr($this->fields_val['bill_brugs'],3,2);
$ystring_bru = substr($this->fields_val['bill_brugs'],6,4);
$year_bru = $ystring_bru;
$d_bru = $year_bru."-".$monthstring_bru."-".$dtstring_bru." ".date("H:i:s");
$dtstring_aft = substr($this->fields_val['bill_afhentnings'],0,2);
$monthstring_aft = substr($this->fields_val['bill_afhentnings'],3,2);
$ystring_aft = substr($this->fields_val['bill_afhentnings'],6,4);
$year_aft = $ystring_aft;
$d_aft = $year_aft."-".$monthstring_aft."-".$dtstring_aft." ".date("H:i:s");
$dtstring_hen = substr($this->fields_val['bill_henter'],0,2);
$monthstring_hen = substr($this->fields_val['bill_henter'],3,2);
$ystring_hen = substr($this->fields_val['bill_henter'],6,4);
$year_hen = $ystring_hen;
$d_hen = $year_hen."-".$monthstring_hen."-".$dtstring_hen." ".date("H:i:s");
$sql = "UPDATE ".$tblAddress." SET bill_navn ='".addslashes($this->fields_val['bill_navn']).
"', bill_att='".$this->fields_val['bill_att'].
"', bill_adresse ='".$this->fields_val['bill_adresse'].
"', bill_etage='".$this->fields_val['bill_etage'].
"', bill_adgangs ='".$this->fields_val['bill_adgangs'].
"', bill_elevator='".$this->fields_val['bill_elevator'].
"', bill_elevator_person='".$bill_elevator_person.
"', bill_postnr='".$this->fields_val['bill_postnr'].
"', bill_postdistr='".$this->fields_val['bill_postdistr'].
"', bill_tlf ='".$this->fields_val['bill_tlf'].
"', bill_fax='".$this->fields_val['bill_fax'].
"', bill_leverings='".$d_lev.
"', bill_brugs='".$d_bru.
"', bill_afhentnings='".$d_aft.
"', bill_henter ='".$d_hen.
"', bill_evtlevaftale='".$this->fields_val['bill_evtlevaftale'].
"', bill_email='".$this->fields_val['bill_email']."' WHERE orders_id='".$this->ordId."'";
//echo "<br>".$sql;
$result = mysql_query($sql,$this->db) or die("query error in addBillDB".mysql_error($this->db));
$msg = $result ? "Adresse er opdateret" : "Adresse er ikke opdateret";
return $msg;
}/*........... end of addDb function........................*/
function getDetails()
{
global $tblAddress;
//$sql = "SELECT * FROM ".$tblAddress." WHERE orders_id='".$this->ordId."'";
$sql = "SELECT *,DATE_FORMAT(`bill_leverings`,'%d-%m-%Y') as date_lev,DATE_FORMAT(`bill_brugs`,'%d-%m-%Y') as date_bru,DATE_FORMAT(`bill_afhentnings`,'%d-%m-%Y') as date_aft,DATE_FORMAT(`bill_henter`,'%d-%m-%Y') as date_hen FROM ".$tblAddress." WHERE orders_id='".$_SESSION['order_id']."'";
//echo $sql;
$result = mysql_query($sql,$this->db) or die("query error in getDetails()".mysql_error($this->db));
$row = mysql_fetch_assoc($result);
foreach ($row as $key => $val)
{
$this->fields_val[$key] = $val;
}
/*echo "<pre>";
print_r ($this->fields_val);
echo "</pre>";*/
}/*........... end of getDetails function........................*/
// Functions for shipping address - Ending
// Function for shipping address table - Starting
function getShippingTemplate()
{
?>
<table cellpadding="0" cellspacing='0' border="0" class="text" width="100%" bordercolor="red">
<tr><td style="padding-top:2px;">
<form name="printShipFrm" action="<?= $_SERVER['PHP_SELF']."?".$_SERVER['QUERY_STRING']?>" method="post">
<table cellpadding="4" cellspacing="0" bordercolor="#04519C" border="1" align="center" width="330" style="BORDER-RIGHT: #04519C 1px solid;BORDER-TOP: #04519C 1px solid;BORDER-LEFT: #04519C 1px solid;BORDER-BOTTOM: #04519C 1px solid; border-collapse:collapse;">
<!--<tr>
<td class="blackText">Hent adresse ved at indtaste telefonnummer:
<td colspan="2" class="blackText">
<input type="text" name="tbOpslagsNummer">
<input type="submit" name="btHentShipAdresse" value="Hent">
<?php if ($this->fields_val['ship_status'] != "") { ?><br /><font color="red"><?= $this->fields_val['ship_status'] ?></font><?php }?></td>
</tr>-->
<tr>
<td class="blackText"> Navn:</td>
<td colspan="1" ><input type="text" name="ship_navn" id="ship_navn" class="buttons1" value="<?=stripslashes($this->fields_val['ship_navn'])?>" size="20"></td>
</tr>
<tr>
<td class="blackText"> Att.:</td>
<td colspan="1" ><input type="text" name="ship_att" id="ship_att" class="buttons1" value="<?=stripslashes($this->fields_val['ship_att'])?>" size="20"></td>
</tr>
<tr>
<td class="blackText"> Adresse:</td>
<td colspan="1" ><input type="text" name="ship_adresse" id="ship_adresse" class="buttons1" value="<?=stripslashes($this->fields_val['ship_adresse'])?>" size="20"></td>
</tr>
<tr>
<td class="blackText"> Etage:</td>
<td colspan="2" class="blackText">
<select name="ship_etage" onchange="if (this.value>0|this.value<0) {document.getElementById('trshipElevator').style.display='block';} else { document.getElementById('trshipElevator').style.display='none';}">
<option value="-1" <?php if (!(strcmp(-1, $this->fields_val['ship_etage']))) {echo "selected=\"selected\"";} ?>>Kælder</option>
<option value="" <?php if (!(strcmp("", $this->fields_val['ship_etage']))) {echo "selected=\"selected\"";} ?>>-- vælg --</option>
<option value="0" <?php if (!(strcmp(0, $this->fields_val['ship_etage']))) {echo "selected=\"selected\"";} ?>>Ingen etage</option>
<option value="1" <?php if (!(strcmp(1, $this->fields_val['ship_etage']))) {echo "selected=\"selected\"";} ?>>1</option>
<option value="2" <?php if (!(strcmp(2, $this->fields_val['ship_etage']))) {echo "selected=\"selected\"";} ?>>2</option>
<option value="3" <?php if (!(strcmp(3, $this->fields_val['ship_etage']))) {echo "selected=\"selected\"";} ?>>3</option>
<option value="4" <?php if (!(strcmp(4, $this->fields_val['ship_etage']))) {echo "selected=\"selected\"";} ?>>4</option>
<option value="5" <?php if (!(strcmp(5, $this->fields_val['ship_etage']))) {echo "selected=\"selected\"";} ?>>5</option>
<option value="6" <?php if (!(strcmp(6, $this->fields_val['ship_etage']))) {echo "selected=\"selected\"";} ?>>6</option>
<option value="99" <?php if (!(strcmp(99, $this->fields_val['ship_etage']))) {echo "selected=\"selected\"";} ?>>over 6</option>
</select></td>
</tr>
<?
if($this->fields_val['ship_elevator_person']=="Y")
{
$chkShipElevPer = "1";
$dispShipElevator = "block";
}
elseif($this->fields_val['ship_elevator_person']=="N")
{
$chkShipElevPer = "2";
$dispShipElevator = "block";
}
elseif($this->fields_val['ship_elevator_person']=="None")
{
$chkShipElevPer = "0";
$dispShipElevator = "block";
}
else
{
$chkShipElevPer = "";
$dispShipElevator = "none";
}
?>
<tr id="trshipElevator" style='display:<?php echo $dispShipElevator ?>;'>
<td class="blackText"> Elevator:</td>
<td colspan="2" class="blackText"><select name="ship_elevator_person">
<option value="" <?php if (!(strcmp("", "$chkShipElevPer"))) {echo "selected=\"selected\"";} ?>>-- vælg --</option>
<option value="0" <?php if (!(strcmp(0, "$chkShipElevPer"))) {echo "selected=\"selected\"";} ?>>Ingen elevator</option>
<option value="1" <?php if (!(strcmp(1, "$chkShipElevPer"))) {echo "selected=\"selected\"";} ?>>Personelevator</option>
<option value="2" <?php if (!(strcmp(2, "$chkShipElevPer"))) {echo "selected=\"selected\"";} ?>>Vareelevator</option>
</select></td>
</tr>
<tr>
<td class="blackText"> Postnr:</td>
<td colspan="1" ><input type="text" name="ship_postnr" id="ship_postnr" class="buttons1" value="<?=stripslashes($this->fields_val['ship_postnr'])?>" size="20"></td>
</tr>
<tr>
<td class="blackText"> By:</td>
<td colspan="1" ><input type="text" name="ship_postdistr" id="ship_postdistr" class="buttons1" value="<?=stripslashes($this->fields_val['ship_postdistr'])?>" size="20"></td>
</tr>
<tr>
<td class="blackText"> Tlf. mellem 8-16:</td>
<td colspan="1" ><input type="text" name="ship_tlf" id="ship_tlf" class="buttons1" value="<?=stripslashes($this->fields_val['ship_tlf'])?>" size="20"></td>
</tr>
<tr>
<td align="left" class="blackText" colspan="2" >
<input type="image" name="updateShip" id="updateSship" src="./images/update_danish.gif" class="noborder" onClick="return checkShipPrint();"><input name="doShip" type="hidden" value="" /> </td>
</tr>
</table>
<input type="hidden" name="ordId" value="<?=$this->ordId?>">
</form>
</td></tr>
</table>
<?
}/*------getShippingTemplate------*/
// Function for shipping address table - Ending
// Function for billing address table - Starting
function getBillingTemplate()
{
?>
<table cellpadding="0" cellspacing='0' border="0" class="text" width="100%" bordercolor="red">
<tr><td style="padding-top:2px;">
<form name="printBillFrm" action="<?= $_SERVER['PHP_SELF']."?".$_SERVER['QUERY_STRING']?>" method="post">
<table cellpadding="4" cellspacing="0" bordercolor="#04519C" border="1" align="center" width="330" style="BORDER-RIGHT: #04519C 1px solid;BORDER-TOP: #04519C 1px solid;BORDER-LEFT: #04519C 1px solid;BORDER-BOTTOM: #04519C 1px solid; border-collapse:collapse;">
<!--<tr>
<td class="blackText">Hent adresse ved at indtaste telefonnummer:
<td colspan="2" class="blackText">
<input type="text" name="tbOpslagsNummer">
<input type="submit" name="btHentBillAdresse" value="Hent">
<?php if ($this->fields_val['bill_status'] != "") { ?><br /><font color="red"><?= $this->fields_val['bill_status'] ?></font><?php }?></td>
</tr> -->
<tr>
<td class="blackText"><font color="red">*</font> Navn:</td>
<td colspan="2" ><input type="text" name="bill_navn" id="bill_navn" class="buttons1" value="<?=stripslashes($this->fields_val['bill_navn'])?>" size="20"></td>
</tr>
<tr>
<td class="blackText"> Att.:</td>
<td colspan="2" ><input type="text" name="bill_att" id="bill_att" class="buttons1" value="<?=stripslashes($this->fields_val['bill_att'])?>" size="20"></td>
</tr>
<tr>
<td class="blackText"><font color="red">*</font> Adresse:</td>
<td colspan="2" ><input type="text" name="bill_adresse" id="bill_adresse" class="buttons1" value="<?=stripslashes($this->fields_val['bill_adresse'])?>" size="20"></td>
</tr>
<tr>
<td class="blackText"><font color="red">*</font> Etage:</td>
<td colspan="2" class="blackText">
<select name="bill_etage" onchange="if (this.value>0|this.value<0) {document.getElementById('trBillElevator').style.display='block';} else { document.getElementById('trBillElevator').style.display='none';}">
<option value="-1" <?php if (!(strcmp(-1, $this->fields_val['bill_etage']))) {echo "selected=\"selected\"";} ?>>Kælder</option>
<option value="" <?php if (!(strcmp("", $this->fields_val['bill_etage']))) {echo "selected=\"selected\"";} ?>>-- vælg --</option>
<option value="0" <?php if (!(strcmp(0, $this->fields_val['bill_etage']))) {echo "selected=\"selected\"";} ?>>Ingen etage</option>
<option value="1" <?php if (!(strcmp(1, $this->fields_val['bill_etage']))) {echo "selected=\"selected\"";} ?>>1</option>
<option value="2" <?php if (!(strcmp(2, $this->fields_val['bill_etage']))) {echo "selected=\"selected\"";} ?>>2</option>
<option value="3" <?php if (!(strcmp(3, $this->fields_val['bill_etage']))) {echo "selected=\"selected\"";} ?>>3</option>
<option value="4" <?php if (!(strcmp(4, $this->fields_val['bill_etage']))) {echo "selected=\"selected\"";} ?>>4</option>
<option value="5" <?php if (!(strcmp(5, $this->fields_val['bill_etage']))) {echo "selected=\"selected\"";} ?>>5</option>
<option value="6" <?php if (!(strcmp(6, $this->fields_val['bill_etage']))) {echo "selected=\"selected\"";} ?>>6</option>
<option value="99" <?php if (!(strcmp(99, $this->fields_val['bill_etage']))) {echo "selected=\"selected\"";} ?>>over 6</option>
</select></td>
</tr>
<?
if($this->fields_val['bill_elevator_person']=="Y")
{
$chkBillElevPer = "1";
$dispElevator = "block";
}
elseif($this->fields_val['bill_elevator_person']=="N")
{
$chkBillElevPer = "2";
$dispElevator = "block";
}
elseif($this->fields_val['bill_elevator_person']=="None")
{
$chkBillElevPer = "0";
$dispElevator = "block";
}
else
{
$chkBillElevPer = "";
$dispElevator = "none";
}
?>
<tr id="trBillElevator" style='display:<?php echo $dispElevator ?>;'>
<td class="blackText"><font color="red">*</font> Elevator:</td>
<td colspan="2" class="blackText"><select name="bill_elevator_person">
<option value="" <?php if (!(strcmp("", "$chkBillElevPer"))) {echo "selected=\"selected\"";} ?>>-- vælg --</option>
<option value="0" <?php if (!(strcmp(0, "$chkBillElevPer"))) {echo "selected=\"selected\"";} ?>>Ingen elevator</option>
<option value="1" <?php if (!(strcmp(1, "$chkBillElevPer"))) {echo "selected=\"selected\"";} ?>>Personelevator</option>
<option value="2" <?php if (!(strcmp(2, "$chkBillElevPer"))) {echo "selected=\"selected\"";} ?>>Vareelevator</option>
</select></td>
</tr>
<tr>
<td class="blackText"><!-- <font color="red">*</font> --> Spec. adgangsforhold:</td>
<td colspan="2" class="blackText"><textarea name="bill_adgangs" id="bill_adgangs" maxlength="255"><?=$this->fields_val['bill_adgangs']?></textarea></td>
</tr>
<tr>
<td class="blackText"><font color="red">*</font> Postnr:</td>
<td colspan="2" ><input type="text" name="bill_postnr" id="bill_postnr" class="buttons1" value="<?=stripslashes($this->fields_val['bill_postnr'])?>" size="20"></td>
</tr>
<tr>
<td class="blackText"><font color="red">*</font> By:</td>
<td colspan="2" ><input type="text" name="bill_postdistr" id="bill_postdistr" class="buttons1" value="<?=stripslashes($this->fields_val['bill_postdistr'])?>" size="20"></td>
</tr>
<tr>
<td class="blackText"><font color="red">*</font> Tlf. (Firmahovednr.) :</td>
<td colspan="2" ><input type="text" name="bill_tlf" id="bill_tlf" class="buttons1" value="<?=stripslashes($this->fields_val['bill_tlf'])?>" size="20"></td>
</tr>
<tr>
<td class="blackText"> Evt. mobil/direkte nr:</td>
<td colspan="2" ><input type="text" name="bill_fax" id="bill_fax" class="buttons1" value="<?=stripslashes($this->fields_val['bill_fax'])?>" size="20"></td>
</tr>
<tr>
<td class="blackText"><font color="red">*</font> Email:</td>
<td colspan="2" ><input type="text" name="bill_email" id="bill_email" class="buttons1" value="<?=stripslashes($this->fields_val['bill_email'])?>" size="20"></td>
</tr>
<?
if($this->fields_val['date_lev'] != "00-00-0000")
$leveringsStr = $this->fields_val['date_lev'];
else
$leveringsStr = "";
?>
<tr>
<td class="blackText"> Leveringsdato: <img src="images/calendar.gif" onClick="dp.show(dp,event,document.getElementById('bill_leverings'))" style="cursor:hand;" alt="Click Here"></td>
<td colspan="2">
<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr>
<td>
<input type="text" name="bill_leverings" id="bill_leverings" class="buttons1" value="<?=$leveringsStr?>" size="20" readonly>
</td>
<td style="padding-top:1px" align="center">
<span onclick="clearDate('bill_leverings')" style="cursor:pointer"><img src="./images/reset.gif" border="0"></span>
</td>
</tr>
</table>
</td>
</tr>
<?
if($this->fields_val['date_bru'] != "00-00-0000")
$brugsStr = $this->fields_val['date_bru'];
else
$brugsStr = "";
?>
<tr>
<td class="blackText"><font color="red">*</font> Brugsdato: <img src="images/calendar.gif" onClick="dp.show(dp,event,document.getElementById('bill_brugs'))" style="cursor:hand;" alt="Click Here"></td>
<td colspan="2" ><input type="text" name="bill_brugs" id="bill_brugs" class="buttons1" value="<?=$brugsStr?>" size="20" readonly></td>
</tr>
<?
if($this->fields_val['date_hen'] != "00-00-0000")
$henterStr = $this->fields_val['date_hen'];
else
$henterStr = "";
?>
<tr>
<td class="blackText"> Henter selv: <img src="images/calendar.gif" onClick="dp.show(dp,event,document.getElementById('bill_henter'))" style="cursor:hand;" alt="Click Here"></td>
<td colspan="2">
<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr>
<td>
<input type="text" name="bill_henter" id="bill_henter" class="buttons1" value="<?=$henterStr?>" size="20" readonly>
</td>
<td style="padding-top:1px" align="center">
<span onclick="clearDate('bill_henter')" style="cursor:pointer"><img src="./images/reset.gif" border="0"></span>
</td>
</tr>
</table>
</td>
</tr>
<?
if($this->fields_val['date_aft'] != "00-00-0000")
$evtlevaftaleStr = $this->fields_val['date_aft'];
else
$evtlevaftaleStr = "";
?>
<tr>
<td class="blackText"> Returdato: <img src="images/calendar.gif" onClick="dp.show(dp,event,document.getElementById('bill_afhentnings'))" style="cursor:hand;" alt="Click Here"></td>
<td colspan="2">
<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr>
<td>
<input type="text" name="bill_afhentnings" id="bill_afhentnings" class="buttons1" value="<?=$evtlevaftaleStr?>" size="20" readonly>
</td>
<td style="padding-top:1px" align="center">
<span onclick="clearDate('bill_afhentnings')" style="cursor:pointer"><img src="./images/reset.gif" border="0"></span>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td class="blackText"> Særlige ønsker:</td>
<!-- <td colspan="2" ><input type="text" name="bill_evtlevaftale" id="bill_evtlevaftale" class="buttons1" value="<?=stripslashes($this->fields_val['bill_evtlevaftale']);?>" size="20"></td> -->
<td colspan="2" class="blackText"><textarea name="bill_evtlevaftale" id="bill_evtlevaftale"><?=stripslashes($this->fields_val['bill_evtlevaftale']);?></textarea></td>
</tr>
<tr>
<td align="left" class="blackText" colspan="3" valign="middle">
<table border="0" cellspacing="0" cellpadding="0"><tr><td> <input type="image" name="updateBill" id="updateBill" src="./images/update_danish.gif" class="noborder" onClick="return checkBillPrint()"><input name="doBill" type="hidden" value="" /></td><td class="blackBoldText"> Opdatér for at gå til "bestilling"</td></tr></table>
<!-- <img src="./images/checkout.gif"> -->
</td>
</tr>
</table>
<input type="hidden" name="ordId" value="<?=$this->ordId?>">
</form>
</td></tr>
</table>
<?
}/*------getBillingTemplate------*/
// Function for billing address table - Ending
} //Class Ends
?>
<script language="javascript">
function validateCart()
{
var i,flagVar;
flagVar = 0;
for(i=0;i<document.cartFrm.elements.length;i++)
{
if(document.cartFrm.elements[i].type == "text")
if(trim(document.cartFrm.elements[i].value) != "")
flagVar = 1;
}
if(flagVar == 0)
{
alert("Din kurv er tom");
return false;
}
else
{
for(i=0;i<document.cartFrm.elements.length;i++)
{
if(document.cartFrm.elements[i].type == "text")
{
if(trim(document.cartFrm.elements[i].value) != "")
{
if(isOnlyNumeric(document.cartFrm.elements[i].value))
{
//no code comes here.........
}
else
{
alert("Indtast et gyldigt antal");
document.cartFrm.elements[i].focus();
return false;
}
}
}
}
}
return true;
}
function trim(sStr)
{
var s;
sStr = sStr.toString();
sStr = sStr.replace(/(^\s*)|(\s*$)/g,"");
sStr = sStr.replace(/\s{2,}/g," "); /*----- Removes the unwanted spaces(more than one)-----*/
return(sStr);
}/*---- Regular expression functions for clearing the spaces ----*/
function isOnlyNumeric(string)
{
if(string == "" ) return false;
var invalidCharRegExp = /[^\d]/;
var isValid = !(invalidCharRegExp.test(string));
return isValid;
}
function showItemsPopup(id)
{
window.open("popupItems.php?id="+id,"","top=10,left=200,height=700,width=700,scrollbars=yes");
}
function openCalendar(element)
{
window.open('popupCalendar.php?e='+element, 'Calendar', 'top=250,left=250 width=300 height=300,titlebar=no');
}
function showMenu(id)
{
switch(id)
{
case "terms":
document.getElementById("deliverTermsRow").style.display='';
document.getElementById("shipTemplateRow").style.display='none';
document.getElementById("billTemplateRow").style.display='none';
break;
case "ship":
document.getElementById("deliverTermsRow").style.display='none';
document.getElementById("shipTemplateRow").style.display='';
document.getElementById("billTemplateRow").style.display='none';
break;
case "bill":
document.getElementById("deliverTermsRow").style.display='none';
document.getElementById("shipTemplateRow").style.display='none';
document.getElementById("billTemplateRow").style.display='';
break;
}
}
function showimage(id,desc,rowId)
{
path="uploads/";
if(id != "")
{
document.getElementById("imgDisp").innerHTML="<table cellpadding='0' cellspacing='5' border='0'><tr><td height='260' width='260'><img src='"+path+id+"' ></td></tr><tr class='blackText'><td>"+desc+"</td></tr></table>";
document.getElementById(rowId).style.backgroundColor ="#CCCCCC";
}
else
{
document.getElementById("imgDisp").innerHTML="<table cellpadding='0' cellspacing='5' border='0'><tr><td height='260' width='260'> </td></tr><tr class='blackText'><td>"+desc+"</td></tr></table>";
document.getElementById(rowId).style.backgroundColor ="#CCCCCC";
}
}
function hideimage(rowId)
{
path="uploads/";
document.getElementById("imgDisp").innerHTML="<table cellpadding='0' cellspacing='5' border='0'><tr><td></td></tr><tr class='blackText'><td></td></tr></table>";
document.getElementById("imgDisp").innerHTML="<img src='images/mouseover.jpg'>";
document.getElementById(rowId).style.backgroundColor ="#FFFFFF";
}
function removeCheck(sessid)
{
frm = document.updateCartFrm;
clear_spaces(frm);
var s=0;
for (var i=0;i < frm.length;i++)
{
fldObj = frm.elements[i];
if(fldObj.type=="checkbox")
{
s = s+1;
if(fldObj.checked == true)
{
//if(confirm("Do you want to remove the selected item(s)?"))
if(confirm("Vil du fjerne valgte vare"))
{
cname = sessid + "order";
var today = new Date();
var expire = new Date();
expire.setTime(today.getTime() + 3600000);
document.cookie = cname + "=update;expires="+expire.toGMTString();
return true;
}
else
{
return false;
}
}
}
}
alert("Vælg vare for at slette");
return false;
}
function checkUnit(sess)
{
frm = document.updateCartFrm;
clear_spaces(frm);
var s=0;
for (var i=0;i < frm.length;i++)
{
fldObj = frm.elements[i];
if(fldObj.type=="text")
{
s = s+1;
if(checkText(fldObj) == false)
{
alert("Enheden er tom");
fldObj.focus();
return false;
}
}
}
cname = sess+"order";
var today = new Date();
var expire = new Date();
expire.setTime(today.getTime() + 3600000);
document.cookie = cname + "=update;expires="+expire.toGMTString();
return true;
}
function showOpvask()
{
if(document.getElementById("attach").checked)
{
var today = new Date();
var expire = new Date();
expire.setTime(today.getTime() + 3600000);
document.cookie = "opvask=opvaskchecked;expires="+expire.toGMTString();
document.getElementById("opvaskPriceCol").style.visibility='visible';
document.location.href=document.location.href;
}
else
{
document.cookie = "opvask=opvasknotchecked;";
document.location.href=document.location.href;
}
}
function billingAddress(element)
{
window.open( 'billingAddress.php?ordId='+element, 'Schluntz', 'top=50,left=50,width=350,height=445,titlebar=no');
}
function shippingAddress(element)
{
window.open( 'shippingAddress.php?ordId='+element, 'Schluntz', 'top=50,left=50,width=350,height=400,titlebar=no');
}
function leftPrint()
{
window.open( 'print.php?opt=y', 'Schluntz', 'top=50,left=50,width=350,height=440,titlebar=no,scrollbars=yes');
}
function rightPrint()
{
window.open( 'termsofdeliver.php', 'Schluntz', 'top=50,left=50,width=350,height=440,titlebar=no,scrollbars=yes');
}
function checkShipPrint()
{
frm = document.printShipFrm;
var error = new Array();
var errorMessage = "";
var marker = "";
clear_spaces(frm);
if (frm.ship_adresse.value != "")
{
error[0] = checkText(frm.ship_etage) ? "" : "Etage skal vælges";
if (frm.ship_etage.value != "0") // if etage not 0 check elevator
{ error[1] = checkSelected(frm.ship_elevator_person) ? "" : "Elevatortype skal vælges hvis etage";}
else
{ error[1] = ""}
error[2] = checkText(frm.ship_postnr) ? "" : "Postnr. er tomt";
error[3] = checkText(frm.ship_postdistr) ? "" : "By er tomt";
error[4] = checkText(frm.ship_tlf) ? "" : "Tlf. (kontakt nr.) er tomt" ;
}
marker = "Hvis du angiver leveringsadresse skal du også pålyse\n * ";
for(i= 0 ;i<error.length; ++i)
{
errorMessage+= error[i] != "" ? marker +error[i]+"\n" : "";
marker = " * ";
}
if(errorMessage == "")
{
frm.doShip.value = "update";
return true;
}
else
{
alert(errorMessage);
return false;
}
}
function checkBillPrint()
{
frm = document.printBillFrm;
var error = new Array();
var errorMessage = "";
clear_spaces(frm);
error[0] = checkText(frm.bill_navn) ? "" : "Navn er tomt";
error[1] = checkText(frm.bill_adresse) ? "" : "Adresse er tomt";
error[2] = checkText(frm.bill_etage) ? "" : "Etage skal vælges";
error[3] = checkText(frm.bill_postnr) ? "" : "Postnr. er tomt";
error[4] = checkText(frm.bill_postdistr) ? "" : "By er tomt";
error[5] = checkText(frm.bill_tlf) ? "" : "Tlf. (Firmahovednr.) er tomt" ;
error[6] = checkText(frm.bill_email) ? "" : "Email-adresse er tomt";
error[7] = checkText(frm.bill_brugs) ? "" : "Brugsdato er tomt";
if (frm.bill_etage.value != "0" && error[2] == "") // if etage not 0 check elevator
{
error[8] = checkSelected(frm.bill_elevator_person) ? "" : "Elevatortype skal vælges";
}
//error[8] = ((frm.bill_elevator_person1.checked==true) || (frm.bill_elevator_person2.checked==true)) ? "" : "Elevator er tomt";
if(error[6] == "")
{
error[6] = emailCheck(frm.bill_email.value) ? "" : "Email er ikke korrekt";
}
for(i= 0 ;i<error.length; ++i)
{
errorMessage+= error[i] != "" ? " * " +error[i]+"\n" : "";
}
if(errorMessage == "")
{
frm.doBill.value = "update";
return true;
}
else
{
alert(errorMessage);
return false;
}
}
function clearDate(fieldName)
{
document.getElementById(fieldName).value = "";
}
</script>